@splinetool/loader 0.9.38 → 0.9.41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -4
- package/build/SplineLoader.js +13 -13
- package/package.json +2 -2
package/build/SplineLoader.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
var sm=Object.create;var Dn=Object.defineProperty,am=Object.defineProperties,lm=Object.getOwnPropertyDescriptor,cm=Object.getOwnPropertyDescriptors,pm=Object.getOwnPropertyNames,tc=Object.getOwnPropertySymbols,hm=Object.getPrototypeOf,ic=Object.prototype.hasOwnProperty,dm=Object.prototype.propertyIsEnumerable;var rc=(n,t,e)=>t in n?Dn(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,P=(n,t)=>{for(var e in t||(t={}))ic.call(t,e)&&rc(n,e,t[e]);if(tc)for(var e of tc(t))dm.call(t,e)&&rc(n,e,t[e]);return n},W=(n,t)=>am(n,cm(t));var um=(n,t)=>()=>(t||n((t={exports:{}}).exports,t),t.exports),mm=(n,t)=>{for(var e in t)Dn(n,e,{get:t[e],enumerable:!0})},fm=(n,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of pm(t))!ic.call(n,i)&&i!==e&&Dn(n,i,{get:()=>t[i],enumerable:!(r=lm(t,i))||r.enumerable});return n};var ym=(n,t,e)=>(e=n!=null?sm(hm(n)):{},fm(t||!n||!n.__esModule?Dn(e,"default",{value:n,enumerable:!0}):e,n));var Ru=um((Sa,zu)=>{(function(n,t){typeof Sa=="object"&&typeof zu<"u"?t(Sa):typeof define=="function"&&define.amd?define(["exports"],t):t((n=typeof globalThis<"u"?globalThis:n||self).SVDJS={})})(Sa,function(n){"use strict";n.SVD=function(t,e,r,i,o){if(e=e===void 0||e,r=r===void 0||r,o=1e-64/(i=i||Math.pow(2,-52)),!t)throw new TypeError("Matrix a is not defined");var s,a,l,c,p,h,d,m,f,T,w,y,L=t[0].length,A=t.length;if(A<L)throw new TypeError("Invalid matrix: m < n");for(var I=[],b=[],V=[],x=e==="f"?A:L,u=T=d=0;u<A;u++)b[u]=new Array(x).fill(0);for(u=0;u<L;u++)V[u]=new Array(L).fill(0);var M,g=new Array(L).fill(0);for(u=0;u<A;u++)for(s=0;s<L;s++)b[u][s]=t[u][s];for(u=0;u<L;u++){for(I[u]=d,f=0,l=u+1,s=u;s<A;s++)f+=Math.pow(b[s][u],2);if(f<o)d=0;else for(m=(h=b[u][u])*(d=h<0?Math.sqrt(f):-Math.sqrt(f))-f,b[u][u]=h-d,s=l;s<L;s++){for(f=0,a=u;a<A;a++)f+=b[a][u]*b[a][s];for(h=f/m,a=u;a<A;a++)b[a][s]=b[a][s]+h*b[a][u]}for(g[u]=d,f=0,s=l;s<L;s++)f+=Math.pow(b[u][s],2);if(f<o)d=0;else{for(m=(h=b[u][u+1])*(d=h<0?Math.sqrt(f):-Math.sqrt(f))-f,b[u][u+1]=h-d,s=l;s<L;s++)I[s]=b[u][s]/m;for(s=l;s<A;s++){for(f=0,a=l;a<L;a++)f+=b[s][a]*b[u][a];for(a=l;a<L;a++)b[s][a]=b[s][a]+f*I[a]}}T<(w=Math.abs(g[u])+Math.abs(I[u]))&&(T=w)}if(r)for(u=L-1;0<=u;u--){if(d!==0){for(m=b[u][u+1]*d,s=l;s<L;s++)V[s][u]=b[u][s]/m;for(s=l;s<L;s++){for(f=0,a=l;a<L;a++)f+=b[u][a]*V[a][s];for(a=l;a<L;a++)V[a][s]=V[a][s]+f*V[a][u]}}for(s=l;s<L;s++)V[u][s]=0,V[s][u]=0;V[u][u]=1,d=I[u],l=u}if(e){if(e==="f")for(u=L;u<A;u++){for(s=L;s<A;s++)b[u][s]=0;b[u][u]=1}for(u=L-1;0<=u;u--){for(l=u+1,d=g[u],s=l;s<x;s++)b[u][s]=0;if(d!==0){for(m=b[u][u]*d,s=l;s<x;s++){for(f=0,a=l;a<A;a++)f+=b[a][u]*b[a][s];for(h=f/m,a=u;a<A;a++)b[a][s]=b[a][s]+h*b[a][u]}for(s=u;s<A;s++)b[s][u]=b[s][u]/d}else for(s=u;s<A;s++)b[s][u]=0;b[u][u]=b[u][u]+1}}for(i*=T,a=L-1;0<=a;a--)for(var N=0;N<50;N++){for(M=!1,l=a;0<=l;l--){if(Math.abs(I[l])<=i){M=!0;break}if(Math.abs(g[l-1])<=i)break}if(!M){for(p=0,c=l-(f=1),u=l;u<a+1&&(h=f*I[u],I[u]=p*I[u],!(Math.abs(h)<=i));u++)if(d=g[u],g[u]=Math.sqrt(h*h+d*d),p=d/(m=g[u]),f=-h/m,e)for(s=0;s<A;s++)w=b[s][c],y=b[s][u],b[s][c]=w*p+y*f,b[s][u]=-w*f+y*p}if(y=g[a],l===a){if(y<0&&(g[a]=-y,r))for(s=0;s<L;s++)V[s][a]=-V[s][a];break}for(T=g[l],h=(((w=g[a-1])-y)*(w+y)+((d=I[a-1])-(m=I[a]))*(d+m))/(2*m*w),d=Math.sqrt(h*h+1),h=((T-y)*(T+y)+m*(w/(h<0?h-d:h+d)-m))/T,u=l+(f=p=1);u<a+1;u++){if(d=I[u],w=g[u],m=f*d,d*=p,y=Math.sqrt(h*h+m*m),h=T*(p=h/(I[u-1]=y))+d*(f=m/y),d=-T*f+d*p,m=w*f,w*=p,r)for(s=0;s<L;s++)T=V[s][u-1],y=V[s][u],V[s][u-1]=T*p+y*f,V[s][u]=-T*f+y*p;if(y=Math.sqrt(h*h+m*m),h=(p=h/(g[u-1]=y))*d+(f=m/y)*w,T=-f*d+p*w,e)for(s=0;s<A;s++)w=b[s][u-1],y=b[s][u],b[s][u-1]=w*p+y*f,b[s][u]=-w*f+y*p}I[l]=0,I[a]=h,g[a]=T}for(u=0;u<L;u++)g[u]<i&&(g[u]=0);return{u:b,q:g,v:V}},n.VERSION="1.1.1",Object.defineProperty(n,"__esModule",{value:!0})})});import{FileLoader as Gw,Loader as zw}from"three";function oc(n){return Array.isArray(n)?n:[n]}var gm=typeof global=="object"&&global&&global.Object===Object&&global,_n=gm;var xm=typeof self=="object"&&self&&self.Object===Object&&self,bm=_n||xm||Function("return this")(),Ze=bm;var vm=Ze.Symbol,Lt=vm;var nc=Object.prototype,Sm=nc.hasOwnProperty,wm=nc.toString,Po=Lt?Lt.toStringTag:void 0;function Lm(n){var t=Sm.call(n,Po),e=n[Po];try{n[Po]=void 0;var r=!0}catch{}var i=wm.call(n);return r&&(t?n[Po]=e:delete n[Po]),i}var sc=Lm;var Cm=Object.prototype,Tm=Cm.toString;function Nm(n){return Tm.call(n)}var ac=Nm;var Mm="[object Null]",Om="[object Undefined]",lc=Lt?Lt.toStringTag:void 0;function Im(n){return n==null?n===void 0?Om:Mm:lc&&lc in Object(n)?sc(n):ac(n)}var Bt=Im;function Pm(n){return n!=null&&typeof n=="object"}var gt=Pm;var Am="[object Symbol]";function Dm(n){return typeof n=="symbol"||gt(n)&&Bt(n)==Am}var wi=Dm;function _m(n,t){for(var e=-1,r=n==null?0:n.length,i=Array(r);++e<r;)i[e]=t(n[e],e,n);return i}var Bn=_m;var Bm=Array.isArray,Qe=Bm;var Em=1/0,cc=Lt?Lt.prototype:void 0,pc=cc?cc.toString:void 0;function hc(n){if(typeof n=="string")return n;if(Qe(n))return Bn(n,hc)+"";if(wi(n))return pc?pc.call(n):"";var t=n+"";return t=="0"&&1/n==-Em?"-0":t}var dc=hc;function Gm(n){var t=typeof n;return n!=null&&(t=="object"||t=="function")}var xt=Gm;function zm(n){return n}var En=zm;var Rm="[object AsyncFunction]",Vm="[object Function]",Fm="[object GeneratorFunction]",jm="[object Proxy]";function Um(n){if(!xt(n))return!1;var t=Bt(n);return t==Vm||t==Fm||t==Rm||t==jm}var Li=Um;var km=Ze["__core-js_shared__"],Gn=km;var uc=function(){var n=/[^.]+$/.exec(Gn&&Gn.keys&&Gn.keys.IE_PROTO||"");return n?"Symbol(src)_1."+n:""}();function Hm(n){return!!uc&&uc in n}var mc=Hm;var qm=Function.prototype,Wm=qm.toString;function $m(n){if(n!=null){try{return Wm.call(n)}catch{}try{return n+""}catch{}}return""}var wr=$m;var Jm=/[\\^$.*+?()[\]{}|]/g,Km=/^\[object .+?Constructor\]$/,Ym=Function.prototype,Xm=Object.prototype,Zm=Ym.toString,Qm=Xm.hasOwnProperty,ef=RegExp("^"+Zm.call(Qm).replace(Jm,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function tf(n){if(!xt(n)||mc(n))return!1;var t=Li(n)?ef:Km;return t.test(wr(n))}var fc=tf;function rf(n,t){return n==null?void 0:n[t]}var yc=rf;function of(n,t){var e=yc(n,t);return fc(e)?e:void 0}var Ot=of;var nf=Ot(Ze,"WeakMap"),zn=nf;var gc=Object.create,sf=function(){function n(){}return function(t){if(!xt(t))return{};if(gc)return gc(t);n.prototype=t;var e=new n;return n.prototype=void 0,e}}(),xc=sf;function af(n,t,e){switch(e.length){case 0:return n.call(t);case 1:return n.call(t,e[0]);case 2:return n.call(t,e[0],e[1]);case 3:return n.call(t,e[0],e[1],e[2])}return n.apply(t,e)}var bc=af;function lf(n,t){var e=-1,r=n.length;for(t||(t=Array(r));++e<r;)t[e]=n[e];return t}var Rn=lf;var cf=800,pf=16,hf=Date.now;function df(n){var t=0,e=0;return function(){var r=hf(),i=pf-(r-e);if(e=r,i>0){if(++t>=cf)return arguments[0]}else t=0;return n.apply(void 0,arguments)}}var vc=df;function uf(n){return function(){return n}}var Sc=uf;var mf=function(){try{var n=Ot(Object,"defineProperty");return n({},"",{}),n}catch{}}(),Ci=mf;var ff=Ci?function(n,t){return Ci(n,"toString",{configurable:!0,enumerable:!1,value:Sc(t),writable:!0})}:En,wc=ff;var yf=vc(wc),Vn=yf;function gf(n,t){for(var e=-1,r=n==null?0:n.length;++e<r&&t(n[e],e,n)!==!1;);return n}var Lc=gf;var xf=9007199254740991,bf=/^(?:0|[1-9]\d*)$/;function vf(n,t){var e=typeof n;return t=t==null?xf:t,!!t&&(e=="number"||e!="symbol"&&bf.test(n))&&n>-1&&n%1==0&&n<t}var Fn=vf;function Sf(n,t,e){t=="__proto__"&&Ci?Ci(n,t,{configurable:!0,enumerable:!0,value:e,writable:!0}):n[t]=e}var Ti=Sf;function wf(n,t){return n===t||n!==n&&t!==t}var Gr=wf;var Lf=Object.prototype,Cf=Lf.hasOwnProperty;function Tf(n,t,e){var r=n[t];(!(Cf.call(n,t)&&Gr(r,e))||e===void 0&&!(t in n))&&Ti(n,t,e)}var jn=Tf;function Nf(n,t,e,r){var i=!e;e||(e={});for(var o=-1,s=t.length;++o<s;){var a=t[o],l=r?r(e[a],n[a],a,e,n):void 0;l===void 0&&(l=n[a]),i?Ti(e,a,l):jn(e,a,l)}return e}var kt=Nf;var Cc=Math.max;function Mf(n,t,e){return t=Cc(t===void 0?n.length-1:t,0),function(){for(var r=arguments,i=-1,o=Cc(r.length-t,0),s=Array(o);++i<o;)s[i]=r[t+i];i=-1;for(var a=Array(t+1);++i<t;)a[i]=r[i];return a[t]=e(s),bc(n,this,a)}}var Un=Mf;function Of(n,t){return Vn(Un(n,t,En),n+"")}var Tc=Of;var If=9007199254740991;function Pf(n){return typeof n=="number"&&n>-1&&n%1==0&&n<=If}var kn=Pf;function Af(n){return n!=null&&kn(n.length)&&!Li(n)}var zr=Af;function Df(n,t,e){if(!xt(e))return!1;var r=typeof t;return(r=="number"?zr(e)&&Fn(t,e.length):r=="string"&&t in e)?Gr(e[t],n):!1}var Nc=Df;function _f(n){return Tc(function(t,e){var r=-1,i=e.length,o=i>1?e[i-1]:void 0,s=i>2?e[2]:void 0;for(o=n.length>3&&typeof o=="function"?(i--,o):void 0,s&&Nc(e[0],e[1],s)&&(o=i<3?void 0:o,i=1),t=Object(t);++r<i;){var a=e[r];a&&n(t,a,r,o)}return t})}var Mc=_f;var Bf=Object.prototype;function Ef(n){var t=n&&n.constructor,e=typeof t=="function"&&t.prototype||Bf;return n===e}var Ni=Ef;function Gf(n,t){for(var e=-1,r=Array(n);++e<n;)r[e]=t(e);return r}var Oc=Gf;var zf="[object Arguments]";function Rf(n){return gt(n)&&Bt(n)==zf}var Ca=Rf;var Ic=Object.prototype,Vf=Ic.hasOwnProperty,Ff=Ic.propertyIsEnumerable,jf=Ca(function(){return arguments}())?Ca:function(n){return gt(n)&&Vf.call(n,"callee")&&!Ff.call(n,"callee")},ni=jf;function Uf(){return!1}var Pc=Uf;var _c=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Ac=_c&&typeof module=="object"&&module&&!module.nodeType&&module,kf=Ac&&Ac.exports===_c,Dc=kf?Ze.Buffer:void 0,Hf=Dc?Dc.isBuffer:void 0,qf=Hf||Pc,Mi=qf;var Wf="[object Arguments]",$f="[object Array]",Jf="[object Boolean]",Kf="[object Date]",Yf="[object Error]",Xf="[object Function]",Zf="[object Map]",Qf="[object Number]",ey="[object Object]",ty="[object RegExp]",ry="[object Set]",iy="[object String]",oy="[object WeakMap]",ny="[object ArrayBuffer]",sy="[object DataView]",ay="[object Float32Array]",ly="[object Float64Array]",cy="[object Int8Array]",py="[object Int16Array]",hy="[object Int32Array]",dy="[object Uint8Array]",uy="[object Uint8ClampedArray]",my="[object Uint16Array]",fy="[object Uint32Array]",je={};je[ay]=je[ly]=je[cy]=je[py]=je[hy]=je[dy]=je[uy]=je[my]=je[fy]=!0;je[Wf]=je[$f]=je[ny]=je[Jf]=je[sy]=je[Kf]=je[Yf]=je[Xf]=je[Zf]=je[Qf]=je[ey]=je[ty]=je[ry]=je[iy]=je[oy]=!1;function yy(n){return gt(n)&&kn(n.length)&&!!je[Bt(n)]}var Bc=yy;function gy(n){return function(t){return n(t)}}var Oi=gy;var Ec=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Ao=Ec&&typeof module=="object"&&module&&!module.nodeType&&module,xy=Ao&&Ao.exports===Ec,Ta=xy&&_n.process,by=function(){try{var n=Ao&&Ao.require&&Ao.require("util").types;return n||Ta&&Ta.binding&&Ta.binding("util")}catch{}}(),Lr=by;var Gc=Lr&&Lr.isTypedArray,vy=Gc?Oi(Gc):Bc,Hn=vy;var Sy=Object.prototype,wy=Sy.hasOwnProperty;function Ly(n,t){var e=Qe(n),r=!e&&ni(n),i=!e&&!r&&Mi(n),o=!e&&!r&&!i&&Hn(n),s=e||r||i||o,a=s?Oc(n.length,String):[],l=a.length;for(var c in n)(t||wy.call(n,c))&&!(s&&(c=="length"||i&&(c=="offset"||c=="parent")||o&&(c=="buffer"||c=="byteLength"||c=="byteOffset")||Fn(c,l)))&&a.push(c);return a}var qn=Ly;function Cy(n,t){return function(e){return n(t(e))}}var Wn=Cy;var Ty=Wn(Object.keys,Object),zc=Ty;var Ny=Object.prototype,My=Ny.hasOwnProperty;function Oy(n){if(!Ni(n))return zc(n);var t=[];for(var e in Object(n))My.call(n,e)&&e!="constructor"&&t.push(e);return t}var Rc=Oy;function Iy(n){return zr(n)?qn(n):Rc(n)}var Ii=Iy;function Py(n){var t=[];if(n!=null)for(var e in Object(n))t.push(e);return t}var Vc=Py;var Ay=Object.prototype,Dy=Ay.hasOwnProperty;function _y(n){if(!xt(n))return Vc(n);var t=Ni(n),e=[];for(var r in n)r=="constructor"&&(t||!Dy.call(n,r))||e.push(r);return e}var Fc=_y;function By(n){return zr(n)?qn(n,!0):Fc(n)}var nr=By;var Ey=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Gy=/^\w*$/;function zy(n,t){if(Qe(n))return!1;var e=typeof n;return e=="number"||e=="symbol"||e=="boolean"||n==null||wi(n)?!0:Gy.test(n)||!Ey.test(n)||t!=null&&n in Object(t)}var jc=zy;var Ry=Ot(Object,"create"),Cr=Ry;function Vy(){this.__data__=Cr?Cr(null):{},this.size=0}var Uc=Vy;function Fy(n){var t=this.has(n)&&delete this.__data__[n];return this.size-=t?1:0,t}var kc=Fy;var jy="__lodash_hash_undefined__",Uy=Object.prototype,ky=Uy.hasOwnProperty;function Hy(n){var t=this.__data__;if(Cr){var e=t[n];return e===jy?void 0:e}return ky.call(t,n)?t[n]:void 0}var Hc=Hy;var qy=Object.prototype,Wy=qy.hasOwnProperty;function $y(n){var t=this.__data__;return Cr?t[n]!==void 0:Wy.call(t,n)}var qc=$y;var Jy="__lodash_hash_undefined__";function Ky(n,t){var e=this.__data__;return this.size+=this.has(n)?0:1,e[n]=Cr&&t===void 0?Jy:t,this}var Wc=Ky;function Pi(n){var t=-1,e=n==null?0:n.length;for(this.clear();++t<e;){var r=n[t];this.set(r[0],r[1])}}Pi.prototype.clear=Uc;Pi.prototype.delete=kc;Pi.prototype.get=Hc;Pi.prototype.has=qc;Pi.prototype.set=Wc;var Na=Pi;function Yy(){this.__data__=[],this.size=0}var $c=Yy;function Xy(n,t){for(var e=n.length;e--;)if(Gr(n[e][0],t))return e;return-1}var Rr=Xy;var Zy=Array.prototype,Qy=Zy.splice;function eg(n){var t=this.__data__,e=Rr(t,n);if(e<0)return!1;var r=t.length-1;return e==r?t.pop():Qy.call(t,e,1),--this.size,!0}var Jc=eg;function tg(n){var t=this.__data__,e=Rr(t,n);return e<0?void 0:t[e][1]}var Kc=tg;function rg(n){return Rr(this.__data__,n)>-1}var Yc=rg;function ig(n,t){var e=this.__data__,r=Rr(e,n);return r<0?(++this.size,e.push([n,t])):e[r][1]=t,this}var Xc=ig;function Ai(n){var t=-1,e=n==null?0:n.length;for(this.clear();++t<e;){var r=n[t];this.set(r[0],r[1])}}Ai.prototype.clear=$c;Ai.prototype.delete=Jc;Ai.prototype.get=Kc;Ai.prototype.has=Yc;Ai.prototype.set=Xc;var Vr=Ai;var og=Ot(Ze,"Map"),Fr=og;function ng(){this.size=0,this.__data__={hash:new Na,map:new(Fr||Vr),string:new Na}}var Zc=ng;function sg(n){var t=typeof n;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?n!=="__proto__":n===null}var Qc=sg;function ag(n,t){var e=n.__data__;return Qc(t)?e[typeof t=="string"?"string":"hash"]:e.map}var jr=ag;function lg(n){var t=jr(this,n).delete(n);return this.size-=t?1:0,t}var ep=lg;function cg(n){return jr(this,n).get(n)}var tp=cg;function pg(n){return jr(this,n).has(n)}var rp=pg;function hg(n,t){var e=jr(this,n),r=e.size;return e.set(n,t),this.size+=e.size==r?0:1,this}var ip=hg;function Di(n){var t=-1,e=n==null?0:n.length;for(this.clear();++t<e;){var r=n[t];this.set(r[0],r[1])}}Di.prototype.clear=Zc;Di.prototype.delete=ep;Di.prototype.get=tp;Di.prototype.has=rp;Di.prototype.set=ip;var Do=Di;var dg="Expected a function";function Ma(n,t){if(typeof n!="function"||t!=null&&typeof t!="function")throw new TypeError(dg);var e=function(){var r=arguments,i=t?t.apply(this,r):r[0],o=e.cache;if(o.has(i))return o.get(i);var s=n.apply(this,r);return e.cache=o.set(i,s)||o,s};return e.cache=new(Ma.Cache||Do),e}Ma.Cache=Do;var op=Ma;var ug=500;function mg(n){var t=op(n,function(r){return e.size===ug&&e.clear(),r}),e=t.cache;return t}var np=mg;var fg=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,yg=/\\(\\)?/g,gg=np(function(n){var t=[];return n.charCodeAt(0)===46&&t.push(""),n.replace(fg,function(e,r,i,o){t.push(i?o.replace(yg,"$1"):r||e)}),t}),sp=gg;function xg(n){return n==null?"":dc(n)}var ap=xg;function bg(n,t){return Qe(n)?n:jc(n,t)?[n]:sp(ap(n))}var _i=bg;var vg=1/0;function Sg(n){if(typeof n=="string"||wi(n))return n;var t=n+"";return t=="0"&&1/n==-vg?"-0":t}var $n=Sg;function wg(n,t){t=_i(t,n);for(var e=0,r=t.length;n!=null&&e<r;)n=n[$n(t[e++])];return e&&e==r?n:void 0}var lp=wg;function Lg(n,t){for(var e=-1,r=t.length,i=n.length;++e<r;)n[i+e]=t[e];return n}var Bi=Lg;var cp=Lt?Lt.isConcatSpreadable:void 0;function Cg(n){return Qe(n)||ni(n)||!!(cp&&n&&n[cp])}var pp=Cg;function hp(n,t,e,r,i){var o=-1,s=n.length;for(e||(e=pp),i||(i=[]);++o<s;){var a=n[o];t>0&&e(a)?t>1?hp(a,t-1,e,r,i):Bi(i,a):r||(i[i.length]=a)}return i}var dp=hp;function Tg(n){var t=n==null?0:n.length;return t?dp(n,1):[]}var up=Tg;function Ng(n){return Vn(Un(n,void 0,up),n+"")}var mp=Ng;var Mg=Wn(Object.getPrototypeOf,Object),Ei=Mg;var Og="[object Object]",Ig=Function.prototype,Pg=Object.prototype,fp=Ig.toString,Ag=Pg.hasOwnProperty,Dg=fp.call(Object);function _g(n){if(!gt(n)||Bt(n)!=Og)return!1;var t=Ei(n);if(t===null)return!0;var e=Ag.call(t,"constructor")&&t.constructor;return typeof e=="function"&&e instanceof e&&fp.call(e)==Dg}var Jn=_g;function Bg(n,t,e){var r=-1,i=n.length;t<0&&(t=-t>i?0:i+t),e=e>i?i:e,e<0&&(e+=i),i=t>e?0:e-t>>>0,t>>>=0;for(var o=Array(i);++r<i;)o[r]=n[r+t];return o}var yp=Bg;function Eg(){this.__data__=new Vr,this.size=0}var gp=Eg;function Gg(n){var t=this.__data__,e=t.delete(n);return this.size=t.size,e}var xp=Gg;function zg(n){return this.__data__.get(n)}var bp=zg;function Rg(n){return this.__data__.has(n)}var vp=Rg;var Vg=200;function Fg(n,t){var e=this.__data__;if(e instanceof Vr){var r=e.__data__;if(!Fr||r.length<Vg-1)return r.push([n,t]),this.size=++e.size,this;e=this.__data__=new Do(r)}return e.set(n,t),this.size=e.size,this}var Sp=Fg;function Gi(n){var t=this.__data__=new Vr(n);this.size=t.size}Gi.prototype.clear=gp;Gi.prototype.delete=xp;Gi.prototype.get=bp;Gi.prototype.has=vp;Gi.prototype.set=Sp;var Kn=Gi;function jg(n,t){return n&&kt(t,Ii(t),n)}var wp=jg;function Ug(n,t){return n&&kt(t,nr(t),n)}var Lp=Ug;var Mp=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Cp=Mp&&typeof module=="object"&&module&&!module.nodeType&&module,kg=Cp&&Cp.exports===Mp,Tp=kg?Ze.Buffer:void 0,Np=Tp?Tp.allocUnsafe:void 0;function Hg(n,t){if(t)return n.slice();var e=n.length,r=Np?Np(e):new n.constructor(e);return n.copy(r),r}var Yn=Hg;function qg(n,t){for(var e=-1,r=n==null?0:n.length,i=0,o=[];++e<r;){var s=n[e];t(s,e,n)&&(o[i++]=s)}return o}var Op=qg;function Wg(){return[]}var Xn=Wg;var $g=Object.prototype,Jg=$g.propertyIsEnumerable,Ip=Object.getOwnPropertySymbols,Kg=Ip?function(n){return n==null?[]:(n=Object(n),Op(Ip(n),function(t){return Jg.call(n,t)}))}:Xn,zi=Kg;function Yg(n,t){return kt(n,zi(n),t)}var Pp=Yg;var Xg=Object.getOwnPropertySymbols,Zg=Xg?function(n){for(var t=[];n;)Bi(t,zi(n)),n=Ei(n);return t}:Xn,Zn=Zg;function Qg(n,t){return kt(n,Zn(n),t)}var Ap=Qg;function ex(n,t,e){var r=t(n);return Qe(n)?r:Bi(r,e(n))}var Qn=ex;function tx(n){return Qn(n,Ii,zi)}var Dp=tx;function rx(n){return Qn(n,nr,Zn)}var es=rx;var ix=Ot(Ze,"DataView"),ts=ix;var ox=Ot(Ze,"Promise"),rs=ox;var nx=Ot(Ze,"Set"),is=nx;var _p="[object Map]",sx="[object Object]",Bp="[object Promise]",Ep="[object Set]",Gp="[object WeakMap]",zp="[object DataView]",ax=wr(ts),lx=wr(Fr),cx=wr(rs),px=wr(is),hx=wr(zn),si=Bt;(ts&&si(new ts(new ArrayBuffer(1)))!=zp||Fr&&si(new Fr)!=_p||rs&&si(rs.resolve())!=Bp||is&&si(new is)!=Ep||zn&&si(new zn)!=Gp)&&(si=function(n){var t=Bt(n),e=t==sx?n.constructor:void 0,r=e?wr(e):"";if(r)switch(r){case ax:return zp;case lx:return _p;case cx:return Bp;case px:return Ep;case hx:return Gp}return t});var Ri=si;var dx=Object.prototype,ux=dx.hasOwnProperty;function mx(n){var t=n.length,e=new n.constructor(t);return t&&typeof n[0]=="string"&&ux.call(n,"index")&&(e.index=n.index,e.input=n.input),e}var Rp=mx;var fx=Ze.Uint8Array,Oa=fx;function yx(n){var t=new n.constructor(n.byteLength);return new Oa(t).set(new Oa(n)),t}var Vi=yx;function gx(n,t){var e=t?Vi(n.buffer):n.buffer;return new n.constructor(e,n.byteOffset,n.byteLength)}var Vp=gx;var xx=/\w*$/;function bx(n){var t=new n.constructor(n.source,xx.exec(n));return t.lastIndex=n.lastIndex,t}var Fp=bx;var jp=Lt?Lt.prototype:void 0,Up=jp?jp.valueOf:void 0;function vx(n){return Up?Object(Up.call(n)):{}}var kp=vx;function Sx(n,t){var e=t?Vi(n.buffer):n.buffer;return new n.constructor(e,n.byteOffset,n.length)}var os=Sx;var wx="[object Boolean]",Lx="[object Date]",Cx="[object Map]",Tx="[object Number]",Nx="[object RegExp]",Mx="[object Set]",Ox="[object String]",Ix="[object Symbol]",Px="[object ArrayBuffer]",Ax="[object DataView]",Dx="[object Float32Array]",_x="[object Float64Array]",Bx="[object Int8Array]",Ex="[object Int16Array]",Gx="[object Int32Array]",zx="[object Uint8Array]",Rx="[object Uint8ClampedArray]",Vx="[object Uint16Array]",Fx="[object Uint32Array]";function jx(n,t,e){var r=n.constructor;switch(t){case Px:return Vi(n);case wx:case Lx:return new r(+n);case Ax:return Vp(n,e);case Dx:case _x:case Bx:case Ex:case Gx:case zx:case Rx:case Vx:case Fx:return os(n,e);case Cx:return new r;case Tx:case Ox:return new r(n);case Nx:return Fp(n);case Mx:return new r;case Ix:return kp(n)}}var Hp=jx;function Ux(n){return typeof n.constructor=="function"&&!Ni(n)?xc(Ei(n)):{}}var ns=Ux;var kx="[object Map]";function Hx(n){return gt(n)&&Ri(n)==kx}var qp=Hx;var Wp=Lr&&Lr.isMap,qx=Wp?Oi(Wp):qp,$p=qx;var Wx="[object Set]";function $x(n){return gt(n)&&Ri(n)==Wx}var Jp=$x;var Kp=Lr&&Lr.isSet,Jx=Kp?Oi(Kp):Jp,Yp=Jx;var Kx=1,Yx=2,Xx=4,Xp="[object Arguments]",Zx="[object Array]",Qx="[object Boolean]",e0="[object Date]",t0="[object Error]",Zp="[object Function]",r0="[object GeneratorFunction]",i0="[object Map]",o0="[object Number]",Qp="[object Object]",n0="[object RegExp]",s0="[object Set]",a0="[object String]",l0="[object Symbol]",c0="[object WeakMap]",p0="[object ArrayBuffer]",h0="[object DataView]",d0="[object Float32Array]",u0="[object Float64Array]",m0="[object Int8Array]",f0="[object Int16Array]",y0="[object Int32Array]",g0="[object Uint8Array]",x0="[object Uint8ClampedArray]",b0="[object Uint16Array]",v0="[object Uint32Array]",Re={};Re[Xp]=Re[Zx]=Re[p0]=Re[h0]=Re[Qx]=Re[e0]=Re[d0]=Re[u0]=Re[m0]=Re[f0]=Re[y0]=Re[i0]=Re[o0]=Re[Qp]=Re[n0]=Re[s0]=Re[a0]=Re[l0]=Re[g0]=Re[x0]=Re[b0]=Re[v0]=!0;Re[t0]=Re[Zp]=Re[c0]=!1;function ss(n,t,e,r,i,o){var s,a=t&Kx,l=t&Yx,c=t&Xx;if(e&&(s=i?e(n,r,i,o):e(n)),s!==void 0)return s;if(!xt(n))return n;var p=Qe(n);if(p){if(s=Rp(n),!a)return Rn(n,s)}else{var h=Ri(n),d=h==Zp||h==r0;if(Mi(n))return Yn(n,a);if(h==Qp||h==Xp||d&&!i){if(s=l||d?{}:ns(n),!a)return l?Ap(n,Lp(s,n)):Pp(n,wp(s,n))}else{if(!Re[h])return i?n:{};s=Hp(n,h,a)}}o||(o=new Kn);var m=o.get(n);if(m)return m;o.set(n,s),Yp(n)?n.forEach(function(w){s.add(ss(w,t,e,w,n,o))}):$p(n)&&n.forEach(function(w,y){s.set(y,ss(w,t,e,y,n,o))});var f=c?l?es:Dp:l?nr:Ii,T=p?void 0:f(n);return Lc(T||n,function(w,y){T&&(y=w,w=n[y]),jn(s,y,ss(w,t,e,y,n,o))}),s}var as=ss;var S0=1,w0=4;function L0(n){return as(n,S0|w0)}var _o=L0;function C0(n){return function(t,e,r){for(var i=-1,o=Object(t),s=r(t),a=s.length;a--;){var l=s[n?a:++i];if(e(o[l],l,o)===!1)break}return t}}var eh=C0;var T0=eh(),th=T0;function N0(n,t,e){(e!==void 0&&!Gr(n[t],e)||e===void 0&&!(t in n))&&Ti(n,t,e)}var Bo=N0;function M0(n){return gt(n)&&zr(n)}var rh=M0;function O0(n,t){if(!(t==="constructor"&&typeof n[t]=="function")&&t!="__proto__")return n[t]}var Eo=O0;function I0(n){return kt(n,nr(n))}var ih=I0;function P0(n,t,e,r,i,o,s){var a=Eo(n,e),l=Eo(t,e),c=s.get(l);if(c){Bo(n,e,c);return}var p=o?o(a,l,e+"",n,t,s):void 0,h=p===void 0;if(h){var d=Qe(l),m=!d&&Mi(l),f=!d&&!m&&Hn(l);p=l,d||m||f?Qe(a)?p=a:rh(a)?p=Rn(a):m?(h=!1,p=Yn(l,!0)):f?(h=!1,p=os(l,!0)):p=[]:Jn(l)||ni(l)?(p=a,ni(a)?p=ih(a):(!xt(a)||Li(a))&&(p=ns(l))):h=!1}h&&(s.set(l,p),i(p,l,r,o,s),s.delete(l)),Bo(n,e,p)}var oh=P0;function nh(n,t,e,r,i){n!==t&&th(t,function(o,s){if(i||(i=new Kn),xt(o))oh(n,t,s,e,nh,r,i);else{var a=r?r(Eo(n,s),o,s+"",n,t,i):void 0;a===void 0&&(a=o),Bo(n,s,a)}},nr)}var sh=nh;function A0(n){var t=n==null?0:n.length;return t?n[t-1]:void 0}var ah=A0;function D0(n,t){return t.length<2?n:lp(n,yp(t,0,-1))}var lh=D0;var _0=Mc(function(n,t,e){sh(n,t,e)}),ai=_0;function B0(n,t){return t=_i(t,n),n=lh(n,t),n==null||delete n[$n(ah(t))]}var ch=B0;function E0(n){return Jn(n)?void 0:n}var ph=E0;var G0=1,z0=2,R0=4,V0=mp(function(n,t){var e={};if(n==null)return e;var r=!1;t=Bn(t,function(o){return o=_i(o,n),r||(r=o.length>1),o}),kt(n,es(n),e),r&&(e=as(e,G0|z0|R0,ph));for(var i=t.length;i--;)ch(e,t[i]);return e}),Fi=V0;var ji;(e=>{e.all=["PerspectiveCamera","OrthographicCamera"];function t(r){return e.all.includes(r)}e.is=t})(ji||(ji={}));var li;(i=>{i.DefaultUp=[0,1,0],i.DefaultTargetOffset=1e3,i.defaultData={far:1e5,type:"OrthographicCamera",perspective:{near:5,fov:45,zoom:1},orthographic:{near:-1e5,zoom:1},up:i.DefaultUp,isUpVectorFlipped:!1,targetOffset:i.DefaultTargetOffset};function r(o){return o.type==="PerspectiveCamera"?o.perspective.zoom:o.orthographic.zoom}i.getZoom=r})(li||(li={}));var hh;(e=>{function n(r,i){return r[0]===i[0]&&r[1]===i[1]}e.isEqual=n;function t(r,i,o){return[r[0]+(i[0]-r[0])*o,r[1]+(i[1]-r[1])*o]}e.lerp=t})(hh||(hh={}));var Ui;(i=>{function n(o,s){return o[0]===s[0]&&o[1]===s[1]&&o[2]===s[2]}i.isEqual=n;function t(o,s){return[o[0]+s[0],o[1]+s[1],o[2]+s[2]]}i.add=t;function e(o,s){return[o[0]-s[0],o[1]-s[1],o[2]-s[2]]}i.sub=e;function r(o,s,a){return[o[0]+(s[0]-o[0])*a,o[1]+(s[1]-o[1])*a,o[2]+(s[2]-o[2])*a]}i.lerp=r})(Ui||(Ui={}));var dh;(e=>{function n(r,i){return r[0]===i[0]&&r[1]===i[1]&&r[2]===i[2]&&r[3]===i[3]}e.isEqual=n;function t(r,i,o){return[r[0]+(i[0]-r[0])*o,r[1]+(i[1]-r[1])*o,r[2]+(i[2]-r[2])*o,r[3]+(i[3]-r[3])*o]}e.lerp=t})(dh||(dh={}));var Ur;(o=>{o.identity=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];function t(s,a){for(let l=0;l<16;l++)if(s[l]!==a[l])return!1;return!0}o.isEqual=t;function e(s){return s!=null?s:o.identity}o.simplify=e;function r(s,a){let l=a.slice(0);for(var c=0,p=a.length;c<p;c+=3){let h=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])*h,l[c+1]=(s[1]*a[c]+s[5]*a[c+1]+s[9]*a[c+2]+s[13])*h,l[c+2]=(s[2]*a[c]+s[6]*a[c+1]+s[10]*a[c+2]+s[14])*h}return l}o.applyMatrix4=r;function i(s,a){let l=a.slice(0);for(var c=0,p=a.length;c<p;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}o.applyMatrix3Components=i})(Ur||(Ur={}));var Et;(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 i(c){return{r:c.r,g:c.g,b:c.b}}l.clone=i;function o(c){return c=Math.floor(c),{r:(c>>16&255)/255,g:(c>>8&255)/255,b:(c&255)/255}}l.fromHex=o;function s(c,p){return c.r===p.r&&c.g===p.g&&c.b===p.b}l.equals=s;function a(c,p,h){return{r:c.r+(p.r-c.r)*h,g:c.g+(p.g-c.g)*h,b:c.b+(p.b-c.b)*h}}l.lerp=a})(Et||(Et={}));var sr;(s=>{s.white=W(P({},Et.white),{a:1});function t(a){return{r:a[0],g:a[1],b:a[2],a:a[3]}}s.from0to1=t;function e(a,l){return W(P({},Et.fromHex(a)),{a:l})}s.fromHexAndA=e;function r(a){return{r:Math.round(a.r*255),g:Math.round(a.g*255),b:Math.round(a.b*255),a:a.a}}s.toRgb255a1=r;function i(a,l){return Et.equals(a,l)&&a.a===l.a}s.equals=i;function o(a,l,c){return{r:a.r+(l.r-a.r)*c,g:a.g+(l.g-a.g)*c,b:a.b+(l.b-a.b)*c,a:a.a+(l.a-a.a)*c}}s.lerp=o})(sr||(sr={}));var ls;(t=>t.identity={position:[0,0,0],rotation:[0,0,0],scale:[1,1,1]})(ls||(ls={}));var uh;(t=>t.defaultData={mass:1,stiffness:80,damping:10,velocity:0})(uh||(uh={}));var mh;(t=>t.defaultData={control1:[.5,.05],control2:[.1,.3]})(mh||(mh={}));var cs;(t=>{function n(e,r=.1){return{type:"radial",hideBase:!1,count:3,radial:{radius:Math.max(e[0],e[1])*2,start:0,end:360,alignment:!1,axis:"y",scale:[1,1,1],rotation:[0,0,0],position:[0,0,0]},linear:{scale:[1,1,1],rotation:[0,0,0],position:[e[0]+e[0]*r,0,0]},grid:{count:[2,2,2],size:e.map(i=>i*(1+r)),useCenter:!0}}}t.defaultData=n})(cs||(cs={}));var Ht=class{modifyById(t,e){let r=this;if(r[t]===void 0)throw new Error("not expected");{let o=W(P({},r),{[t]:e});return Object.setPrototypeOf(o,Ht.prototype),o}}add(t,e){var i;let r=this.runOp({type:1,id:t,data:e});return(i=r==null?void 0:r.data)!=null?i:this}runOp(t){let e=this;if(t.type===1){let r=e[t.id],i;r===void 0?i={type:2,id:t.id}:i={type:1,id:t.id,data:r};let{id:o,data:s}=t,a=W(P({},e),{[o]:s});return Object.setPrototypeOf(a,Ht.prototype),{data:a,actual:t,reverse:i}}else if(t.type===2){let{id:r}=t,i=e[r];if(i===void 0)return null;{let o=P({},e);return Object.setPrototypeOf(o,Ht.prototype),delete o[r],{data:o,actual:t,reverse:{type:1,id:r,data:i}}}}throw new Error("illegal arg")}};function Go(n){if(n.deepFreeze!==void 0){n.deepFreeze(n);return}let t=Object.getOwnPropertyNames(n);for(let e of t){let r=n[e];r&&typeof r=="object"&&Go(r)}return Object.freeze(n)}function fh(n,t){let e=0;for(;e<n.length&&e<t.length;){if(n[e]<t[e])return-1;if(n[e]>t[e])return 1;e+=1}return e!==t.length?-1:e!==n.length?1:0}var ps=class extends Error{};function ar(n,t,e){if(n===void 0?t===void 0?(n=0,t=10):n=t-10:t===void 0&&(t=n+10),n>t){let o=n;n=t,t=o}let r=[],i=1/(e+1);for(let o=0;o<e;o++){let s=n+(t-n)*(o+.75+Math.random()*.5)*i;r.push(s)}return r}function yh(n){return n instanceof Uint8Array||n instanceof Uint16Array||n instanceof Uint32Array||n instanceof Int8Array||n instanceof Int16Array||n instanceof Int32Array||n instanceof Float32Array||n instanceof Float64Array}function gh(){return typeof process<"u"}function xh(n,t){for(let e of n)t(e.id,e.data),xh(e.children,t)}function bh(n,t){t(n.id,n.data);for(let e of n.children)bh(e,t)}var qt=class extends Array{constructor(...e){super(...e);Object.setPrototypeOf(this,qt.prototype)}deepFreeze(){let e=0;for(;e<this.length;)Go(this[e]),e++}fillCaches0(e,r){var i;if((i=this.objCaches)!=null&&i.has(e.id))throw new Error("duplicated item");this.objCaches.set(e.id,e),this.parentCaches.set(e.id,r);for(let o of e.children)this.fillCaches0(o,e.id)}fillCaches(){if(this.objCaches===void 0){this.objCaches=new Map,this.parentCaches=new Map;for(let e of this)this.fillCaches0(e,null)}}randomId(){this.fillCaches();let e=Array.from(this.objCaches.keys());if(e.length!==0)return e[Math.max(0,Math.floor(Math.random()*e.length)-1)]}isDescendantOf(e,r){for(;e;){let i=this.parent(e);if(i===r)return!0;e=i}return!1}data(e){var r;return(r=this.get(e))==null?void 0:r.data}has(e){return this.childrenOf(e)!==void 0}get(e){return this.fillCaches(),this.objCaches.get(e)}childrenOf(e){var r;return e===null?this:(r=this.get(e))==null?void 0:r.children}traverseFrom(e,r){if(e===null)this.traverse(r);else{let i=this.get(e);i&&bh(i,r)}}traverse(e){xh(this,e)}totalSize(){return this.fillCaches(),this.objCaches.size}parent(e){return this.fillCaches(),this.parentCaches.get(e)}childrenArray(e){return e===null?this:this.get(e).children}modifyById(e,r){if(this.get(e)===void 0)throw new Error("not expected");{let o=this.parent(e),s=this.childrenArray(o),a=s.findIndex(p=>p.id===e);if(a<0)throw new Error("not expected");let l=s[a];return s=[...s],s[a]=W(P({},l),{data:r}),this.modifyArrayBy(o,s)}}modifyArrayBy(e,r){let i=e,o=r;for(;i!==null;){let a=o,l=i;if(i=this.parent(i),i===void 0)throw new Error;o=this.childrenArray(i);let c=o.findIndex(p=>p.id===l);if(c<0)throw new Error;o=[...o],o[c]=W(P({},o[c]),{children:a})}Object.setPrototypeOf(o,qt.prototype);let s=o;return s.fillCaches(),s}runOp(e){switch(e.type){case 7:return this.addOp(e);case 8:return this.deleteOp(e);case 9:return this.moveOp(e)}}addOp(e){let{parent:r,fi:i,id:o,data:s,children:a}=e;if(r!==null&&this.get(r)===void 0)return null;if(this.get(o)!==void 0)return null;{let l=r,c=this.childrenArray(l),p={fi:i,id:o,data:s,children:a};return c=[...c,p],c.sort((d,m)=>d.fi-m.fi),e.localIndex=c.indexOf(p),{data:this.modifyArrayBy(l,c),actual:e,reverse:{type:8,id:o}}}}deleteOp(e){let{id:r}=e;if(this.get(r)===null)return null;{let i=this.parent(r);if(i===void 0)return null;let o=this.childrenArray(i),s=o.findIndex(c=>c.id===r);e.localIndex=s,o=[...o];let a=o.splice(s,1)[0];return{data:this.modifyArrayBy(i,o),actual:e,reverse:W(P({type:7},a),{parent:i})}}}moveOp(e){let{parent:r,fi:i,id:o}=e;if(r!==null&&this.get(r)===void 0)return this.deleteOp({type:8,id:o});if(r!==null){let m=r;for(;m!==null;){if(m===void 0)throw new Error;if(m===o)throw new ps("cyclic tree");m=this.parent(m)}}let s=this.parent(o);if(s===void 0)return null;let a=s,l=this.childrenArray(s),c=l.findIndex(m=>m.id===o);l=[...l];let p=l.splice(c,1)[0],h=this.modifyArrayBy(s,l);s=r,l=h.childrenArray(s);let d=p.fi;return p=W(P({},p),{fi:i}),l=[...l,p],l.sort((m,f)=>m.fi-f.fi),e.localIndex=l.indexOf(p),h=h.modifyArrayBy(s,l),{data:h,actual:e,reverse:{type:9,parent:a,fi:d,id:o}}}previous(e,r){if(r===null){let o=this.childrenArray(e);return o.length===0?null:o[o.length-1].id}let i=null;for(let o of this.childrenArray(e)){if(o.id===r)return i;i=o.id}return null}traverseSortNext(e){let r=this.parent(e);if(r!==void 0){let i=this.childrenArray(r),o=i.findIndex(s=>s.id===e)+1;if(o<i.length)return i[o].id;if(r)return this.traverseSortNext(r)}}sortNext(e){let r=this.childrenArray(e);return r.length>0?r[0].id:this.traverseSortNext(e)}traverseSortPrevious(e){let r=this.childrenArray(e);return r.length>0?this.traverseSortPrevious(r[r.length-1].id):e}sortPrevious(e){let r=this.parent(e);if(r!==void 0){let i=this.childrenArray(r),o=i.findIndex(s=>s.id===e)-1;return o>=0?this.traverseSortPrevious(i[o].id):r}}getAllSorted(e){let r=[];for(let i of e){let o=this.getWithSortKey(i.id);o!==void 0&&r.push(P(P({},i),o))}r.sort((i,o)=>fh(i.sortKey,o.sortKey));for(let i of r)delete i.sortKey;return r}getWithSortKey(e){var r=e;let i=[],o=this.get(r),s=o;if(o!==void 0){for(;r;)i.splice(0,0,o.fi),r=this.parent(r),r!==null&&(o=this.get(r));return W(P({},s),{sortKey:i})}}insertBeforeHelper(e,r,i){return this.insertAfterHelper(e,this.previous(e,r),i)}insertAfterHelper(e,r,i){let o=this.childrenArray(e);if(r===null){if(o.length===0)return ar(0,i,i);{let s=o[0].fi;return ar(s-i,s,i)}}else{let s=this.get(r);if(s===void 0||this.parent(r)!==e)throw new Error("illegal args");let a=o.find(l=>l.fi>s.fi);if(a===void 0){let l=o[o.length-1].fi;return ar(l,l+i,i)}else return ar(s.fi,a.fi,i)}}};var hs;(t=>{function n(e,r){if(Array.isArray(e)){let i=r.props,o={},s=[...e],a=!1;if(i)for(let l of Object.keys(i)){let c=parseInt(l);if(isNaN(c))throw new Error("wrong index");o[l]=s[c],s[c]=i[l],a=!0}return a?{data:s,actual:r,reverse:{type:0,props:o}}:null}else{let i=r.props,o={},s=P({},e),a=!1;if(i)for(let l of Object.keys(i)){o[l]=s[l];let c=i[l];c===void 0?delete s[l]:s[l]=c,a=!0}return a?{data:s,actual:r,reverse:{type:0,props:o}}:null}}t.runOp=n})(hs||(hs={}));var $e=class extends Array{constructor(...e){super(...e);Object.setPrototypeOf(this,$e.prototype)}deepFreeze(){let e=0;for(;e<this.length;)Go(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 r;return(r=this.get(e))==null?void 0:r.data}get(e){return this.fillCaches(),this.objCaches.get(e)}modifyById(e,r){if(this.get(e)===void 0)throw new Error("not expected");{let o=this,s=o.findIndex(c=>c.id===e);if(s<0)throw new Error("not expected");let a=o[s];return o=[...o],o[s]=W(P({},a),{data:r}),this.modifyArrayBy(o)}}modifyArrayBy(e){Object.setPrototypeOf(e,$e.prototype);let r=e;return gh()||r.fillCaches(),r}runOp(e){switch(e.type){case 4:return this.addOp(e);case 5:return this.deleteOp(e);case 6:return this.moveOp(e)}}addOp(e){let{fi:r,id:i,data:o}=e,s=this,a={fi:r,id:i,data:o};return s=[...s,a],s.sort((c,p)=>c.fi-p.fi),e.localIndex=s.indexOf(a),{data:this.modifyArrayBy(s),actual:e,reverse:{type:5,id:i}}}deleteOp(e){let{id:r}=e,i=this,o=i.findIndex(l=>l.id===r);if(o===-1)return null;e.localIndex=o,i=[...i];let s=i.splice(o,1)[0];return{data:this.modifyArrayBy(i),actual:e,reverse:P({type:4},s)}}moveOp(e){let{fi:r,id:i}=e,o=this;o=[...o];let s=o.findIndex(p=>p.id===i);if(s===-1)return null;let a=o[s].fi,l=W(P({},o[s]),{fi:r});return o[s]=l,o.sort((p,h)=>p.fi-h.fi),e.localIndex=o.indexOf(l),{data:this.modifyArrayBy(o),actual:e,reverse:{type:6,fi:a,id:i}}}previous(e){if(e===null)return this.length===0?null:this[this.length-1].id;let r=null;for(let i of this){if(i.id===e)return r;r=i.id}return null}insertBeforeHelper(e,r){return this.insertAfterHelper(this.previous(e),r)}insertAfterHelper(e,r){let i=this;if(e===null){if(i.length===0)return ar(0,r,r);{let o=i[0].fi;return ar(o-r,o,r)}}else{let o=this.get(e);if(o===void 0)throw new Error("illegal args");let s=i.find(a=>a.fi>o.fi);if(s===void 0){let a=i[i.length-1].fi;return ar(a,a+r,r)}else return ar(o.fi,s.fi,r)}}};var vh=Symbol(),us=Symbol(),ki=class{reportOp(t,e){let r=this;if(e===null)return;r._current=e.data;let i=[];for(;!(r instanceof ds);){let o=r._path,s=r._current;if(o!==""&&i.splice(0,0,o),r=r._parent,r===null)return;r.update(o,s)}r.push(i,t,e.actual,e.reverse)}deleteChildren(t){if(this._children){let e=this._children[t];if(e){let r=e[us];r&&r(),delete this._children[t]}}}},Pa=class extends ki{constructor(t,e,r){super(),this._parent=t,this._path=e,this._current=r}update(t,e){if(Array.isArray(this._current)){if(typeof t=="string"&&(t=parseInt(t),isNaN(t)))throw new Error("Invalid path");this._current=[...this._current],this._current[t]=e}else this._current=W(P({},this._current),{[t]:e})}runOp(t){this.reportOp(t,hs.runOp(this._current,t))}},Aa=class extends ki{constructor(t,e,r){super(),this._parent=t,this._path=e,this._current=r}update(t,e){this._current=W(P({},this._current),{[t]:e}),Object.setPrototypeOf(this._current,Ht.prototype)}runOp(t){this.reportOp(t,this._current.runOp(t))}},Sh={get(n,t){if(t===us)return()=>{n._parent=null};if(t===vh)return n._current;let{_current:e,_children:r}=n;if(t==="push"&&Array.isArray(e))throw new Error("not supported to expand array");let i=r===void 0?void 0:r[t];if(i!==void 0)return i;let o=e[t],s=ms(n,t,o);return s!==o?(r===void 0&&(r={},n._children=r),r[t]=s,s):o},has(n,t){return t in n._current},ownKeys(n){return Reflect.ownKeys(n._current)},defineProperty(){throw Error("not supported")},getPrototypeOf(n){return Object.getPrototypeOf(n._current)},setPrototypeOf(){throw Error("not supported")},getOwnPropertyDescriptor(n,t){let e=n._current,r=Reflect.getOwnPropertyDescriptor(e,t);return r&&{writable:!0,configurable:!0,enumerable:r.enumerable,value:e[t]}}},F0=W(P({},Sh),{set(n,t,e){var i;let r={type:0,props:{[t]:(i=Ba(e))!=null?i:e}};return n.deleteChildren(t),n.runOp(r),!0},deleteProperty(n,t){let e={type:0,props:{[t]:void 0}};return n.deleteChildren(t),n.runOp(e),!0}}),j0=W(P({},Sh),{set(n,t,e){return e===void 0?this.deleteProperty(n,t):(n.deleteChildren(t),n.runOp({type:1,id:t,data:e})),!0},deleteProperty(n,t){return n.runOp({type:2,id:t}),!0}}),Hi=class extends ki{constructor(t,e,r){super(),this._children={},this._parent=t,this._path=e,this._current=r,this[us]=()=>{this._parent=null}}unproxy(){return this._current}update(t,e){this._current=this._current.modifyById(t,e)}runOp(t){this.reportOp(t,this._current.runOp(t))}randomId(){return this._current.randomId()}isDescendantOf(t,e){return this._current.isDescendantOf(t,e)}childrenOf(t){return this._current.childrenOf(t)}traverse(t){return this._current.traverse(t)}get(t){return this._current.get(t)}parent(t){return this._current.parent(t)}traverse(t){this._current.traverse((e,r)=>{t(e,this.data(e))})}data(t){var a;let{_current:e,_children:r}=this,i=r===void 0?void 0:r[t];if(i!==void 0)return i;let o=(a=e.get(t))==null?void 0:a.data,s=ms(this,t,o);return s!==o?(r===void 0&&(r={},this._children=r),r[t]=s,s):o}add(t,e,r,i,o){this.runOp({type:7,parent:t,fi:e,id:r,data:i,children:o})}move(t,e,r){this.runOp({type:9,parent:t,fi:e,id:r})}insertAfter(t,e,r){let i=this._current.insertAfterHelper(t,e,r.length);for(let o=0;o<r.length;o++){let s=r[o];this.add(t,i[o],s.id,s.data,s.children)}}insertBefore(t,e,r){let i=this._current.insertBeforeHelper(t,e,r.length);for(let o=0;o<r.length;o++){let s=r[o];this.add(t,i[o],s.id,s.data,s.children)}}moveAfter(t,e,r){let i=this._current.insertAfterHelper(t,e,r.length);for(let o=0;o<r.length;o++){let s=r[o];this.move(t,i[o],s)}}moveBefore(t,e,r){let i=this._current.insertBeforeHelper(t,e,r.length);for(let o=0;o<r.length;o++){let s=r[o];this.move(t,i[o],s)}}delete(t){this.deleteChildren(t),this.runOp({type:8,id:t})}sortNext(t){return this._current.sortNext(t)}sortPrevious(t){return this._current.sortPrevious(t)}getAllSorted(t){return this._current.getAllSorted(t)}},qi=class extends ki{constructor(t,e,r){super(),this._children={},this._parent=t,this._path=e,this._current=r,this[us]=()=>{this._parent=null}}unproxy(){return this._current}get length(){return this._current.length}forEach(t){let e=this.length;for(let r=0;r<e;r++){let i=this._current[r].id;t(this.data(this._current[r].id),i)}}update(t,e){this._current=this._current.modifyById(t,e)}randomId(){return this._current.randomId()}get(t){return W(P({},this._current.get(t)),{data:this.data(t)})}data(t){var a;let{_current:e,_children:r}=this,i=r===void 0?void 0:r[t];if(i!==void 0)return i;let o=(a=e.get(t))==null?void 0:a.data,s=ms(this,t,o);return s!==o?(r===void 0&&(r={},this._children=r),r[t]=s,s):o}runOp(t){this.reportOp(t,this._current.runOp(t))}add(t,e,r){this.runOp({type:4,fi:t,id:e,data:r})}move(t,e){this.runOp({type:6,fi:t,id:e})}insertAfter(t,e){let r=this._current.insertAfterHelper(t,e.length);for(let i=0;i<e.length;i++){let o=e[i];this.add(r[i],o.id,o.data)}}insertBefore(t,e){let r=this._current.insertBeforeHelper(t,e.length);for(let i=0;i<e.length;i++){let o=e[i];this.add(r[i],o.id,o.data)}}moveAfter(t,e){let r=this._current.insertAfterHelper(t,e.length);for(let i=0;i<e.length;i++){let o=e[i];this.move(r[i],o)}}moveBefore(t,e){let r=this._current.insertBeforeHelper(t,e.length);for(let i=0;i<e.length;i++){let o=e[i];this.move(r[i],o)}}delete(t){this.deleteChildren(t),this.runOp({type:5,id:t})}};function Ia(n,t,e){if(n.length>0){let r=n[n.length-1];if(r.type===0&&t.type===0&&fs.equal(r.path,e)){Object.assign(r.props,t.props);return}}n.push(W(P({},t),{path:e}))}var ds=class{constructor(t){this.ts=[],this.actual=[],this.reverse=[],this._current=t}update(t,e){if(t!=="")throw new Error("");this._current=e}push(t,e,r,i){Ia(this.ts,e,t),Ia(this.actual,r,t),Ia(this.reverse,i,t)}result(){return{data:this._current,ts:this.ts,actual:this.actual,reverse:this.reverse.reverse()}}};function ms(n,t,e){return e instanceof qt?new Hi(n,t,e):e instanceof $e?new qi(n,t,e):e instanceof Ht?new Proxy(new Aa(n,t,e),j0):e!==null&&typeof e=="object"?yh(e)?e:new Proxy(new Pa(n,t,e),F0):e}function Da(n){let t=new ds(n);return[ms(t,"",n),t]}function _a(n,t){let[e,r]=Da(n);return t(e),r.result()}function Ba(n){return n instanceof Hi||n instanceof qi?n._current:n!==null&&typeof n=="object"?n[vh]:n}var fs;(r=>{function n(i,o){if(o.length===i.length)for(var s=0;s<i.length;){if(i[s]!==o[s])return!1;s+=1}else return!1;return!0}r.equal=n;function t(i,o,s){let a=e(s,i);if(a!==void 0&&typeof a=="object"&&a!==null){let l=P({},o);return Object.keys(a).forEach(c=>{delete l[c]}),l}else return o}r.removeOverridden=t;function e(i,o,s=0){if(o.length<=s)return i;if((i instanceof qt||i instanceof Hi)&&typeof o[s]=="string")return e(i.data(o[s]),o,s+1);if((i instanceof $e||i instanceof qi)&&typeof o[s]=="string")return e(i.data(o[s]),o,s+1);if(typeof o[s]=="number"&&Array.isArray(i))return e(i[o[s]],o,s+1);if(typeof o[s]=="string"&&typeof i=="object")return e(i[o[s]],o,s+1)}r.zoom=e})(fs||(fs={}));var ys=class{},zo=class extends ys{constructor(e){super();this.id=e}},Ro=class extends ys{constructor(e){super();this.data=e}};var Ga;try{Ga=new TextDecoder}catch{}var ee,Hr,S=0;var Ih=[],za=Ih,Ra=0,It={},Oe,kr,Wt=0,lr=0,Gt,Tr,Ct=[],Ie,wh={useRecords:!1,mapsAsObjects:!0},Vo=class{},Fa=new Vo;Fa.name="MessagePack 0xC1";var Wi=!1,cr=class{constructor(t){t&&(t.useRecords===!1&&t.mapsAsObjects===void 0&&(t.mapsAsObjects=!0),t.structures?t.structures.sharedLength=t.structures.length:t.getStructures&&((t.structures=[]).uninitialized=!0,t.structures.sharedLength=0)),Object.assign(this,t)}unpack(t,e){if(ee)return Bh(()=>(xs(),this?this.unpack(t,e):cr.prototype.unpack.call(wh,t,e)));Hr=e>-1?e:t.length,S=0,Ra=0,lr=0,kr=null,za=Ih,Gt=null,ee=t;try{Ie=t.dataView||(t.dataView=new DataView(t.buffer,t.byteOffset,t.byteLength))}catch(r){throw ee=null,t instanceof Uint8Array?r:new Error("Source must be a Uint8Array or Buffer but was a "+(t&&typeof t=="object"?t.constructor.name:typeof t))}if(this instanceof cr){if(It=this,this.structures)return Oe=this.structures,gs();(!Oe||Oe.length>0)&&(Oe=[])}else It=wh,(!Oe||Oe.length>0)&&(Oe=[]);return gs()}unpackMultiple(t,e){let r,i=0;try{Wi=!0;let o=t.length,s=this?this.unpack(t,o):Ss.unpack(t,o);if(e){for(e(s);S<o;)if(i=S,e(gs())===!1)return}else{for(r=[s];S<o;)i=S,r.push(gs());return r}}catch(o){throw o.lastPosition=i,o.values=r,o}finally{Wi=!1,xs()}}_mergeStructures(t,e){t=t||[];for(let r=0,i=t.length;r<i;r++){let o=t[r];o&&(o.isShared=!0,r>=32&&(o.highByte=r-32>>5))}t.sharedLength=t.length;for(let r in e||[])if(r>=0){let i=t[r],o=e[r];o&&(i&&((t.restoreStructures||(t.restoreStructures=[]))[r]=i),t[r]=o)}return this.structures=t}decode(t,e){return this.unpack(t,e)}};function gs(){try{if(!It.trusted&&!Wi){let t=Oe.sharedLength||0;t<Oe.length&&(Oe.length=t)}let n=Je();if(S==Hr)Oe.restoreStructures&&Lh(),Oe=null,ee=null,Tr&&(Tr=null);else if(S>Hr){let t=new Error("Unexpected end of MessagePack data");throw t.incomplete=!0,t}else if(!Wi)throw new Error("Data read, but end of buffer not reached");return n}catch(n){throw Oe.restoreStructures&&Lh(),xs(),(n instanceof RangeError||n.message.startsWith("Unexpected end of buffer"))&&(n.incomplete=!0),n}}function Lh(){for(let n in Oe.restoreStructures)Oe[n]=Oe.restoreStructures[n];Oe.restoreStructures=null}function Je(){let n=ee[S++];if(n<160)if(n<128){if(n<64)return n;{let t=Oe[n&63]||It.getStructures&&Ph()[n&63];return t?(t.read||(t.read=ja(t,n&63)),t.read()):n}}else if(n<144)if(n-=128,It.mapsAsObjects){let t={};for(let e=0;e<n;e++)t[Dh()]=Je();return t}else{let t=new Map;for(let e=0;e<n;e++)t.set(Je(),Je());return t}else{n-=144;let t=new Array(n);for(let e=0;e<n;e++)t[e]=Je();return t}else if(n<192){let t=n-160;if(lr>=S)return kr.slice(S-Wt,(S+=t)-Wt);if(lr==0&&Hr<140){let e=t<16?Ua(t):Ah(t);if(e!=null)return e}return Va(t)}else{let t;switch(n){case 192:return null;case 193:return Gt?(t=Je(),t>0?Gt[1].slice(Gt.position1,Gt.position1+=t):Gt[0].slice(Gt.position0,Gt.position0-=t)):Fa;case 194:return!1;case 195:return!0;case 196:return Ea(ee[S++]);case 197:return t=Ie.getUint16(S),S+=2,Ea(t);case 198:return t=Ie.getUint32(S),S+=4,Ea(t);case 199:return ci(ee[S++]);case 200:return t=Ie.getUint16(S),S+=2,ci(t);case 201:return t=Ie.getUint32(S),S+=4,ci(t);case 202:if(t=Ie.getFloat32(S),It.useFloat32>2){let e=vs[(ee[S]&127)<<1|ee[S+1]>>7];return S+=4,(e*t+(t>0?.5:-.5)>>0)/e}return S+=4,t;case 203:return t=Ie.getFloat64(S),S+=8,t;case 204:return ee[S++];case 205:return t=Ie.getUint16(S),S+=2,t;case 206:return t=Ie.getUint32(S),S+=4,t;case 207:return It.int64AsNumber?(t=Ie.getUint32(S)*4294967296,t+=Ie.getUint32(S+4)):t=Ie.getBigUint64(S),S+=8,t;case 208:return Ie.getInt8(S++);case 209:return t=Ie.getInt16(S),S+=2,t;case 210:return t=Ie.getInt32(S),S+=4,t;case 211:return It.int64AsNumber?(t=Ie.getInt32(S)*4294967296,t+=Ie.getUint32(S+4)):t=Ie.getBigInt64(S),S+=8,t;case 212:if(t=ee[S++],t==114)return Oh(ee[S++]&63);{let e=Ct[t];if(e)return e.read?(S++,e.read(Je())):e.noBuffer?(S++,e()):e(ee.subarray(S,++S));throw new Error("Unknown extension "+t)}case 213:return t=ee[S],t==114?(S++,Oh(ee[S++]&63,ee[S++])):ci(2);case 214:return ci(4);case 215:return ci(8);case 216:return ci(16);case 217:return t=ee[S++],lr>=S?kr.slice(S-Wt,(S+=t)-Wt):k0(t);case 218:return t=Ie.getUint16(S),S+=2,lr>=S?kr.slice(S-Wt,(S+=t)-Wt):H0(t);case 219:return t=Ie.getUint32(S),S+=4,lr>=S?kr.slice(S-Wt,(S+=t)-Wt):q0(t);case 220:return t=Ie.getUint16(S),S+=2,Th(t);case 221:return t=Ie.getUint32(S),S+=4,Th(t);case 222:return t=Ie.getUint16(S),S+=2,Nh(t);case 223:return t=Ie.getUint32(S),S+=4,Nh(t);default:if(n>=224)return n-256;if(n===void 0){let e=new Error("Unexpected end of MessagePack data");throw e.incomplete=!0,e}throw new Error("Unknown MessagePack token "+n)}}}var U0=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function ja(n,t){function e(){if(e.count++>2){let i=n.read=new Function("r","return function(){return {"+n.map(o=>U0.test(o)?o+":r()":"["+JSON.stringify(o)+"]:r()").join(",")+"}}")(Je);return n.highByte===0&&(n.read=Ch(t,n.read)),i()}let r={};for(let i=0,o=n.length;i<o;i++){let s=n[i];r[s]=Je()}return r}return e.count=0,n.highByte===0?Ch(t,e):e}var Ch=(n,t)=>function(){let e=ee[S++];if(e===0)return t();let r=n<32?-(n+(e<<5)):n+(e<<5),i=Oe[r]||Ph()[r];if(!i)throw new Error("Record id is not defined for "+r);return i.read||(i.read=ja(i,n)),i.read()};function Ph(){let n=Bh(()=>(ee=null,It.getStructures()));return Oe=It._mergeStructures(n,Oe)}var Va=bs,k0=bs,H0=bs,q0=bs;function bs(n){let t;if(n<16&&(t=Ua(n)))return t;if(n>64&&Ga)return Ga.decode(ee.subarray(S,S+=n));let e=S+n,r=[];for(t="";S<e;){let i=ee[S++];if((i&128)===0)r.push(i);else if((i&224)===192){let o=ee[S++]&63;r.push((i&31)<<6|o)}else if((i&240)===224){let o=ee[S++]&63,s=ee[S++]&63;r.push((i&31)<<12|o<<6|s)}else if((i&248)===240){let o=ee[S++]&63,s=ee[S++]&63,a=ee[S++]&63,l=(i&7)<<18|o<<12|s<<6|a;l>65535&&(l-=65536,r.push(l>>>10&1023|55296),l=56320|l&1023),r.push(l)}else r.push(i);r.length>=4096&&(t+=nt.apply(String,r),r.length=0)}return r.length>0&&(t+=nt.apply(String,r)),t}function Th(n){let t=new Array(n);for(let e=0;e<n;e++)t[e]=Je();return t}function Nh(n){if(It.mapsAsObjects){let t={};for(let e=0;e<n;e++)t[Dh()]=Je();return t}else{let t=new Map;for(let e=0;e<n;e++)t.set(Je(),Je());return t}}var nt=String.fromCharCode;function Ah(n){let t=S,e=new Array(n);for(let r=0;r<n;r++){let i=ee[S++];if((i&128)>0){S=t;return}e[r]=i}return nt.apply(String,e)}function Ua(n){if(n<4)if(n<2){if(n===0)return"";{let t=ee[S++];if((t&128)>1){S-=1;return}return nt(t)}}else{let t=ee[S++],e=ee[S++];if((t&128)>0||(e&128)>0){S-=2;return}if(n<3)return nt(t,e);let r=ee[S++];if((r&128)>0){S-=3;return}return nt(t,e,r)}else{let t=ee[S++],e=ee[S++],r=ee[S++],i=ee[S++];if((t&128)>0||(e&128)>0||(r&128)>0||(i&128)>0){S-=4;return}if(n<6){if(n===4)return nt(t,e,r,i);{let o=ee[S++];if((o&128)>0){S-=5;return}return nt(t,e,r,i,o)}}else if(n<8){let o=ee[S++],s=ee[S++];if((o&128)>0||(s&128)>0){S-=6;return}if(n<7)return nt(t,e,r,i,o,s);let a=ee[S++];if((a&128)>0){S-=7;return}return nt(t,e,r,i,o,s,a)}else{let o=ee[S++],s=ee[S++],a=ee[S++],l=ee[S++];if((o&128)>0||(s&128)>0||(a&128)>0||(l&128)>0){S-=8;return}if(n<10){if(n===8)return nt(t,e,r,i,o,s,a,l);{let c=ee[S++];if((c&128)>0){S-=9;return}return nt(t,e,r,i,o,s,a,l,c)}}else if(n<12){let c=ee[S++],p=ee[S++];if((c&128)>0||(p&128)>0){S-=10;return}if(n<11)return nt(t,e,r,i,o,s,a,l,c,p);let h=ee[S++];if((h&128)>0){S-=11;return}return nt(t,e,r,i,o,s,a,l,c,p,h)}else{let c=ee[S++],p=ee[S++],h=ee[S++],d=ee[S++];if((c&128)>0||(p&128)>0||(h&128)>0||(d&128)>0){S-=12;return}if(n<14){if(n===12)return nt(t,e,r,i,o,s,a,l,c,p,h,d);{let m=ee[S++];if((m&128)>0){S-=13;return}return nt(t,e,r,i,o,s,a,l,c,p,h,d,m)}}else{let m=ee[S++],f=ee[S++];if((m&128)>0||(f&128)>0){S-=14;return}if(n<15)return nt(t,e,r,i,o,s,a,l,c,p,h,d,m,f);let T=ee[S++];if((T&128)>0){S-=15;return}return nt(t,e,r,i,o,s,a,l,c,p,h,d,m,f,T)}}}}}function Ea(n){return It.copyBuffers?Uint8Array.prototype.slice.call(ee,S,S+=n):ee.subarray(S,S+=n)}function ci(n){let t=ee[S++];if(Ct[t])return Ct[t](ee.subarray(S,S+=n));throw new Error("Unknown extension type "+t)}var Mh=new Array(4096);function Dh(){let n=ee[S++];if(n>=160&&n<192){if(n=n-160,lr>=S)return kr.slice(S-Wt,(S+=n)-Wt);if(!(lr==0&&Hr<180))return Va(n)}else return S--,Je();let t=(n<<5^(n>1?Ie.getUint16(S):n>0?ee[S]:0))&4095,e=Mh[t],r=S,i=S+n-3,o,s=0;if(e&&e.bytes==n){for(;r<i;){if(o=Ie.getUint32(r),o!=e[s++]){r=1879048192;break}r+=4}for(i+=3;r<i;)if(o=ee[r++],o!=e[s++]){r=1879048192;break}if(r===i)return S=r,e.string;i-=3,r=S}for(e=[],Mh[t]=e,e.bytes=n;r<i;)o=Ie.getUint32(r),e.push(o),r+=4;for(i+=3;r<i;)o=ee[r++],e.push(o);let a=n<16?Ua(n):Ah(n);return a!=null?e.string=a:e.string=Va(n)}var Oh=(n,t)=>{var e=Je();let r=n;t!==void 0&&(n=n<32?-((t<<5)+n):(t<<5)+n,e.highByte=t);let i=Oe[n];return i&&i.isShared&&((Oe.restoreStructures||(Oe.restoreStructures=[]))[n]=i),Oe[n]=e,e.read=ja(e,r),e.read()},_h=typeof self=="object"?self:global;Ct[0]=()=>{};Ct[0].noBuffer=!0;Ct[101]=()=>{let n=Je();return(_h[n[0]]||Error)(n[1])};Ct[105]=n=>{let t=Ie.getUint32(S-4);Tr||(Tr=new Map);let e=ee[S],r;e>=144&&e<160||e==220||e==221?r=[]:r={};let i={target:r};Tr.set(t,i);let o=Je();return i.used?Object.assign(r,o):(i.target=o,o)};Ct[112]=n=>{let t=Ie.getUint32(S-4),e=Tr.get(t);return e.used=!0,e.target};Ct[115]=()=>new Set(Je());var ka=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(n=>n+"Array");Ct[116]=n=>{let t=n[0],e=ka[t];if(!e)throw new Error("Could not find typed array for code "+t);return new _h[e](Uint8Array.prototype.slice.call(n,1).buffer)};Ct[120]=()=>{let n=Je();return new RegExp(n[0],n[1])};Ct[98]=n=>{let t=(n[0]<<24)+(n[1]<<16)+(n[2]<<8)+n[3],e=S;S+=t-4,Gt=[Je(),Je()],Gt.position0=0,Gt.position1=0;let r=S;S=e;try{return Je()}finally{S=r}};Ct[255]=n=>n.length==4?new Date((n[0]*16777216+(n[1]<<16)+(n[2]<<8)+n[3])*1e3):n.length==8?new Date(((n[0]<<22)+(n[1]<<14)+(n[2]<<6)+(n[3]>>2))/1e6+((n[3]&3)*4294967296+n[4]*16777216+(n[5]<<16)+(n[6]<<8)+n[7])*1e3):n.length==12?new Date(((n[0]<<24)+(n[1]<<16)+(n[2]<<8)+n[3])/1e6+((n[4]&128?-281474976710656:0)+n[6]*1099511627776+n[7]*4294967296+n[8]*16777216+(n[9]<<16)+(n[10]<<8)+n[11])*1e3):new Date("invalid");function Bh(n){let t=Hr,e=S,r=Ra,i=Wt,o=lr,s=kr,a=za,l=Tr,c=Gt,p=new Uint8Array(ee.slice(0,Hr)),h=Oe,d=Oe.slice(0,Oe.length),m=It,f=Wi,T=n();return Hr=t,S=e,Ra=r,Wt=i,lr=o,kr=s,za=a,Tr=l,Gt=c,ee=p,Wi=f,Oe=h,Oe.splice(0,Oe.length,...d),It=m,Ie=new DataView(ee.buffer,ee.byteOffset,ee.byteLength),T}function xs(){ee=null,Tr=null,Oe=null}function Eh(n){n.unpack?Ct[n.type]=n.unpack:Ct[n.type]=n}var vs=new Array(147);for(let n=0;n<256;n++)vs[n]=+("1e"+Math.floor(45.15-n*.30103));var Ss=new cr({useRecords:!1}),W0=Ss.unpack,$0=Ss.unpackMultiple,J0=Ss.unpack,ws={NEVER:0,ALWAYS:1,DECIMAL_ROUND:3,DECIMAL_FIT:4},K0=new Float32Array(1),uP=new Uint8Array(K0.buffer,0,4);var Ls;try{Ls=new TextEncoder}catch{}var Cs,qa,Ts=typeof Buffer<"u",Ha=Ts?Buffer.allocUnsafeSlow:Uint8Array,Vh=Ts?Buffer:Uint8Array,Gh=Ts?4294967296:2144337920,E,Ke,O=0,pr,hr=null,Y0=/[\u0080-\uFFFF]/,Fo=Symbol("record-id"),pi=class extends cr{constructor(t){super(t),this.offset=0;let e,r,i,o,s,a,l=0,c=Vh.prototype.utf8Write?function(u,M,g){return E.utf8Write(u,M,g)}:Ls&&Ls.encodeInto?function(u,M){return Ls.encodeInto(u,E.subarray(M)).written}:!1,p=this;t||(t={});let h=t&&t.sequential,d=t.structures||t.saveStructures,m=t.maxSharedStructures;if(m==null&&(m=d?32:0),m>8160)throw new Error("Maximum maxSharedStructure is 8160");let f=t.maxOwnStructures;f==null&&(f=d?32:64),h&&!t.saveStructures&&(this.structures=[]);let T=m>32||f+m>64,w=m+64,y=m+f+64;if(y>8256)throw new Error("Maximum maxSharedStructure + maxOwnStructure is 8192");let L=[],A=0,I=0;this.pack=this.encode=function(u,M){if(E||(E=new Ha(8192),Ke=new DataView(E.buffer,0,8192),O=0),pr=E.length-10,pr-O<2048?(E=new Ha(E.length),Ke=new DataView(E.buffer,0,E.length),pr=E.length-10,O=0):O=O+7&2147483640,r=O,a=p.structuredClone?new Map:null,p.bundleStrings?(hr=["",""],E[O++]=214,E[O++]=98,hr.position=O-r,O+=4):hr=null,i=p.structures,i){i.uninitialized&&(i=p._mergeStructures(p.getStructures()));let g=i.sharedLength||0;if(g>m)throw new Error("Shared structures is larger than maximum shared structures, try increasing maxSharedStructures to "+i.sharedLength);if(!i.transitions){i.transitions=Object.create(null);for(let N=0;N<g;N++){let v=i[N];if(!v)continue;let C,$=i.transitions;for(let H=0,ie=v.length;H<ie;H++){let pe=v[H];C=$[pe],C||(C=$[pe]=Object.create(null)),$=C}$[Fo]=N+64}l=g}h||(i.nextId=g+64)}o&&(o=!1),s=i||[];try{if(b(u),hr){Ke.setUint32(hr.position+r,O-hr.position-r);let g=hr;hr=null,b(g[0]),b(g[1])}if(p.offset=O,a&&a.idsToInsert){O+=a.idsToInsert.length*6,O>pr&&x(O),p.offset=O;let g=Z0(E.subarray(r,O),a.idsToInsert);return a=null,g}return M&jh?(E.start=r,E.end=O,E):E.subarray(r,O)}finally{if(i){if(I<10&&I++,A>1e4)i.transitions=null,I=0,A=0,L.length>0&&(L=[]);else if(L.length>0&&!h){for(let g=0,N=L.length;g<N;g++)L[g][Fo]=0;L=[]}if(o&&p.saveStructures){let g=i.sharedLength||m;i.length>g&&(i=i.slice(0,g));let N=E.subarray(r,O);return p.saveStructures(i,l)===!1?(p._mergeStructures(p.getStructures()),p.pack(u)):(l=g,N)}}M&nb&&(O=r)}};let b=u=>{O>pr&&(E=x(O));var M=typeof u,g;if(M==="string"){let N=u.length;if(hr&&N>=8&&N<4096){let $=Y0.test(u);hr[$?0:1]+=u,E[O++]=193,b($?-N:N);return}let v;N<32?v=1:N<256?v=2:N<65536?v=3:v=5;let C=N*3;if(O+C>pr&&(E=x(O+C)),N<64||!c){let $,H,ie,pe=O+v;for($=0;$<N;$++)H=u.charCodeAt($),H<128?E[pe++]=H:H<2048?(E[pe++]=H>>6|192,E[pe++]=H&63|128):(H&64512)===55296&&((ie=u.charCodeAt($+1))&64512)===56320?(H=65536+((H&1023)<<10)+(ie&1023),$++,E[pe++]=H>>18|240,E[pe++]=H>>12&63|128,E[pe++]=H>>6&63|128,E[pe++]=H&63|128):(E[pe++]=H>>12|224,E[pe++]=H>>6&63|128,E[pe++]=H&63|128);g=pe-O-v}else g=c(u,O+v,C);g<32?E[O++]=160|g:g<256?(v<2&&E.copyWithin(O+2,O+1,O+1+g),E[O++]=217,E[O++]=g):g<65536?(v<3&&E.copyWithin(O+3,O+2,O+2+g),E[O++]=218,E[O++]=g>>8,E[O++]=g&255):(v<5&&E.copyWithin(O+5,O+3,O+3+g),E[O++]=219,Ke.setUint32(O,g),O+=4),O+=g}else if(M==="number")if(u>>>0===u)u<64?E[O++]=u:u<256?(E[O++]=204,E[O++]=u):u<65536?(E[O++]=205,E[O++]=u>>8,E[O++]=u&255):(E[O++]=206,Ke.setUint32(O,u),O+=4);else if(u>>0===u)u>=-32?E[O++]=256+u:u>=-128?(E[O++]=208,E[O++]=u+256):u>=-32768?(E[O++]=209,Ke.setInt16(O,u),O+=2):(E[O++]=210,Ke.setInt32(O,u),O+=4);else{let N;if((N=this.useFloat32)>0&&u<4294967296&&u>=-2147483648){E[O++]=202,Ke.setFloat32(O,u);let v;if(N<4||(v=u*vs[(E[O]&127)<<1|E[O+1]>>7])>>0===v){O+=4;return}else O--}E[O++]=203,Ke.setFloat64(O,u),O+=8}else if(M==="object")if(!u)E[O++]=192;else{if(a){let v=a.get(u);if(v){if(!v.id){let C=a.idsToInsert||(a.idsToInsert=[]);v.id=C.push(v)}E[O++]=214,E[O++]=112,Ke.setUint32(O,v.id),O+=4;return}else a.set(u,{offset:O-r})}let N=u.constructor;if(N===Object)V(u,!0);else if(N===Array){g=u.length,g<16?E[O++]=144|g:g<65536?(E[O++]=220,E[O++]=g>>8,E[O++]=g&255):(E[O++]=221,Ke.setUint32(O,g),O+=4);for(let v=0;v<g;v++)b(u[v])}else if(N===Map){g=u.size,g<16?E[O++]=128|g:g<65536?(E[O++]=222,E[O++]=g>>8,E[O++]=g&255):(E[O++]=223,Ke.setUint32(O,g),O+=4);for(let[v,C]of u)b(v),b(C)}else{for(let v=0,C=Cs.length;v<C;v++){let $=qa[v];if(u instanceof $){let H=Cs[v];if(H.write){H.type&&(E[O++]=212,E[O++]=H.type,E[O++]=0),b(H.write.call(this,u));return}let ie=E,pe=Ke,ce=O;E=null;let be;try{be=H.pack.call(this,u,F=>(E=ie,ie=null,O+=F,O>pr&&x(O),{target:E,targetView:Ke,position:O-F}),b)}finally{ie&&(E=ie,Ke=pe,O=ce,pr=E.length-10)}be&&(be.length+O>pr&&x(be.length+O),O=X0(be,E,O,H.type));return}}V(u,!u.hasOwnProperty)}}else if(M==="boolean")E[O++]=u?195:194;else if(M==="bigint"){if(u<BigInt(1)<<BigInt(63)&&u>=-(BigInt(1)<<BigInt(63)))E[O++]=211,Ke.setBigInt64(O,u);else if(u<BigInt(1)<<BigInt(64)&&u>0)E[O++]=207,Ke.setBigUint64(O,u);else if(this.largeBigIntToFloat)E[O++]=203,Ke.setFloat64(O,Number(u));else throw new RangeError(u+" was too large to fit in MessagePack 64-bit integer format, set largeBigIntToFloat to convert to float-64");O+=8}else if(M==="undefined")this.encodeUndefinedAsNil?E[O++]=192:(E[O++]=212,E[O++]=0,E[O++]=0);else if(M==="function")b(this.writeFunction&&this.writeFunction());else throw new Error("Unknown type: "+M)},V=this.useRecords===!1?this.variableMapSize?u=>{let M=Object.keys(u),g=M.length;g<16?E[O++]=128|g:g<65536?(E[O++]=222,E[O++]=g>>8,E[O++]=g&255):(E[O++]=223,Ke.setUint32(O,g),O+=4);let N;for(let v=0;v<g;v++)b(N=M[v]),b(u[N])}:(u,M)=>{E[O++]=222;let g=O-r;O+=2;let N=0;for(let v in u)(M||u.hasOwnProperty(v))&&(b(v),b(u[v]),N++);E[g+++r]=N>>8,E[g+r]=N&255}:u=>{let M=Object.keys(u),g,N=s.transitions||(s.transitions=Object.create(null)),v=0;for(let $=0,H=M.length;$<H;$++){let ie=M[$];g=N[ie],g||(g=N[ie]=Object.create(null),v++),N=g}let C=N[Fo];if(C)C>=96&&T?(E[O++]=((C-=96)&31)+96,E[O++]=C>>5):E[O++]=C;else{C=s.nextId,C||(C=64),C<w&&this.shouldShareStructure&&!this.shouldShareStructure(M)?(C=s.nextOwnId,C<y||(C=w),s.nextOwnId=C+1):(C>=y&&(C=w),s.nextId=C+1);let $=M.highByte=C>=96&&T?C-96>>5:-1;N[Fo]=C,s[C-64]=M,C<w?(M.isShared=!0,s.sharedLength=C-63,o=!0,$>=0?(E[O++]=(C&31)+96,E[O++]=$):E[O++]=C):($>=0?(E[O++]=213,E[O++]=114,E[O++]=(C&31)+96,E[O++]=$):(E[O++]=212,E[O++]=114,E[O++]=C),v&&(A+=I*v),L.length>=f&&(L.shift()[Fo]=0),L.push(N),b(M))}for(let $=0,H=M.length;$<H;$++)b(u[M[$]])},x=u=>{let M;if(u>16777216){if(u-r>Gh)throw new Error("Packed buffer would be larger than maximum buffer size");M=Math.min(Gh,Math.round(Math.max((u-r)*(u>67108864?1.25:2),4194304)/4096)*4096)}else M=(Math.max(u-r<<2,E.length-1)>>12)+1<<12;let g=new Ha(M);return Ke=new DataView(g.buffer,0,M),E.copy?E.copy(g,0,r,u):g.set(E.slice(r,u)),O-=r,r=0,pr=g.length-10,E=g}}useBuffer(t){E=t,Ke=new DataView(E.buffer,E.byteOffset,E.byteLength),O=0}};qa=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,Vo];Cs=[{pack(n,t,e){let r=n.getTime()/1e3;if((this.useTimestamp32||n.getMilliseconds()===0)&&r>=0&&r<4294967296){let{target:i,targetView:o,position:s}=t(6);i[s++]=214,i[s++]=255,o.setUint32(s,r)}else if(r>0&&r<17179869184){let{target:i,targetView:o,position:s}=t(10);i[s++]=215,i[s++]=255,o.setUint32(s,n.getMilliseconds()*4e6+(r/1e3/4294967296>>0)),o.setUint32(s+4,r)}else if(isNaN(r)){if(this.onInvalidDate)return t(0),e(this.onInvalidDate());let{target:i,targetView:o,position:s}=t(3);i[s++]=212,i[s++]=255,i[s++]=255}else{let{target:i,targetView:o,position:s}=t(15);i[s++]=199,i[s++]=12,i[s++]=255,o.setUint32(s,n.getMilliseconds()*1e6),o.setBigInt64(s+4,BigInt(Math.floor(r)))}}},{pack(n,t,e){let r=Array.from(n),{target:i,position:o}=t(this.structuredClone?3:0);this.structuredClone&&(i[o++]=212,i[o++]=115,i[o++]=0),e(r)}},{pack(n,t,e){let{target:r,position:i}=t(this.structuredClone?3:0);this.structuredClone&&(r[i++]=212,r[i++]=101,r[i++]=0),e([n.name,n.message])}},{pack(n,t,e){let{target:r,position:i}=t(this.structuredClone?3:0);this.structuredClone&&(r[i++]=212,r[i++]=120,r[i++]=0),e([n.source,n.flags])}},{pack(n,t){this.structuredClone?zh(n,16,t):Rh(Ts?Buffer.from(n):new Uint8Array(n),t)}},{pack(n,t){let e=n.constructor;e!==Vh&&this.structuredClone?zh(n,ka.indexOf(e.name),t):Rh(n,t)}},{pack(n,t){let{target:e,position:r}=t(1);e[r]=193}}];function zh(n,t,e,r){let i=n.byteLength;if(i+1<256){var{target:o,position:s}=e(4+i);o[s++]=199,o[s++]=i+1}else if(i+1<65536){var{target:o,position:s}=e(5+i);o[s++]=200,o[s++]=i+1>>8,o[s++]=i+1&255}else{var{target:o,position:s,targetView:a}=e(7+i);o[s++]=201,a.setUint32(s,i+1),s+=4}o[s++]=116,o[s++]=t,o.set(new Uint8Array(n.buffer,n.byteOffset,n.byteLength),s)}function Rh(n,t){let e=n.byteLength;var r,i;if(e<256){var{target:r,position:i}=t(e+2);r[i++]=196,r[i++]=e}else if(e<65536){var{target:r,position:i}=t(e+3);r[i++]=197,r[i++]=e>>8,r[i++]=e&255}else{var{target:r,position:i,targetView:o}=t(e+5);r[i++]=198,o.setUint32(i,e),i+=4}r.set(n,i)}function X0(n,t,e,r){let i=n.length;switch(i){case 1:t[e++]=212;break;case 2:t[e++]=213;break;case 4:t[e++]=214;break;case 8:t[e++]=215;break;case 16:t[e++]=216;break;default:i<256?(t[e++]=199,t[e++]=i):i<65536?(t[e++]=200,t[e++]=i>>8,t[e++]=i&255):(t[e++]=201,t[e++]=i>>24,t[e++]=i>>16&255,t[e++]=i>>8&255,t[e++]=i&255)}return t[e++]=r,t.set(n,e),e+=i,e}function Z0(n,t){let e,r=t.length*6,i=n.length-r;for(t.sort((o,s)=>o.offset>s.offset?1:-1);e=t.pop();){let o=e.offset,s=e.id;n.copyWithin(o+r,o,i),r-=6;let a=o+r;n[a++]=214,n[a++]=105,n[a++]=s>>24,n[a++]=s>>16&255,n[a++]=s>>8&255,n[a++]=s&255,i=o}return n}function hi(n){if(n.Class){if(!n.pack&&!n.write)throw new Error("Extension has no pack or write function");if(n.pack&&!n.type)throw new Error("Extension has no type (numeric code to identify the extension)");qa.unshift(n.Class),Cs.unshift(n)}Eh(n)}var Fh=new pi({useRecords:!1}),Q0=Fh.pack,eb=Fh.pack;var{NEVER:tb,ALWAYS:rb,DECIMAL_ROUND:ib,DECIMAL_FIT:ob}=ws,jh=512,nb=1024;var Uh=new pi({structuredClone:!0});hi({Class:Ht.prototype.constructor,type:1,write(n){return P({},n)},read(n){return Object.setPrototypeOf(n,Ht.prototype),n}});hi({Class:$e.prototype.constructor,type:2,write(n){return[...n]},read(n){return Object.setPrototypeOf(n,$e.prototype),n}});hi({Class:qt.prototype.constructor,type:3,write(n){return[...n]},read(n){return Object.setPrototypeOf(n,qt.prototype),n}});hi({Class:zo.prototype.constructor,type:4,write(n){return n.id},read(n){return new zo(n)}});hi({Class:Ro.prototype.constructor,type:5,write(n){return n.data},read(n){return new Ro(n)}});function sb(n){var t=0;if(n.length===0)return t;for(let e=0;e<n.length;e++){let r=n[e];t=(t<<5)-t+r,t=t&t}return t}var Ns;(r=>{function n(i){return Uh.pack(i)}r.serialize=n;function t(i){return Uh.unpack(i)}r.deserialize=t;function e(i){return sb(n(i)).toString()}r.checksum=e})(Ns||(Ns={}));var Ms;(e=>{e.all=["PointLight","SpotLight","DirectionalLight","HemisphereLight"];function t(r){return e.all.includes(r)}e.is=t})(Ms||(Ms={}));var Os;(e=>{function n(r){return t(r)}e.defaultData=n;function t(r){if(r==="PointLight")return{type:r,color:sr.white,intensity:1,distance:2e3,decay:1,shadows:!0,shadowResolution:1024,shadowRadius:1,depth:2500,helper:!0};if(r==="SpotLight")return{type:r,color:sr.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:sr.white,intensity:1,shadows:!0,size:2500,depth:2500,helper:!0};throw new Error("not implemented")}})(Os||(Os={}));var Wa;(e=>{e.defaultData={castShadow:!0,receiveShadow:!0};function t(r,i){return r.castShadow===i.castShadow&&r.receiveShadow===i.receiveShadow}e.equals=t})(Wa||(Wa={}));var $a;(e=>{e.defaultData={flatShading:!1,wireframe:!1,side:0};function t(r,i){return r.flatShading===i.flatShading&&r.side===i.side&&r.wireframe===i.wireframe}e.equals=t})($a||($a={}));var Is;(t=>t.defaultData=W(P(P({},$a.defaultData),Wa.defaultData),{cloner:null}))(Is||(Is={}));var Ja=(i=>(i[i.Left=1]="Left",i[i.Right=2]="Right",i[i.Center=3]="Center",i[i.Justify=4]="Justify",i))(Ja||{}),Ka=(r=>(r[r.Top=1]="Top",r[r.Center=2]="Center",r[r.Bottom=3]="Bottom",r))(Ka||{}),Ya=(r=>(r[r.None=1]="None",r[r.Upper=2]="Upper",r[r.Lower=3]="Lower",r))(Ya||{}),Ps;(t=>t.defaultData={width:100,height:100,horizontalAlign:1,verticalAlign:1,fontSize:16,lineHeight:1.5,letterSpacing:1,text:"",textTransform:1,color:sr.fromHexAndA(6974058,1),alpha:1,font:"roboto_regular"})(Ps||(Ps={}));var $i;(r=>{function n(i,o){return i==="light"&&o?t(o):e(i)}r.defaultData=n;function t(i){switch(i){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:0,g:0,b:0,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 e(i){switch(i){case"texture":return{alpha:1,visible:!0,size:[128,128],mode:0,axis:"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:Et.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:W(P({},Et.fromHex(6710886)),{a:1}),colorB:W(P({},Et.fromHex(6710886)),{a:1}),colorC:W(P({},Et.fromHex(16777215)),{a:1}),colorD:W(P({},Et.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:sr.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}}}})($i||($i={}));var Ji;(a=>{function n(l){return!l.layers.some(p=>{if(p.data.type==="texture"&&p.data.projection!==0||p.data.type==="depth"&&!p.data.isWorldSpace||p.data.type==="noise"||p.data.type==="displace")return!0})&&!e(l)}a.isMergable=n;function t(l){let c="";return l.layers.forEach(p=>{Object.entries(p.data).forEach(([h,d])=>{c+=`${h}${d}`,Array.isArray(d)?d.forEach(m=>c+=`${m}`):typeof d=="object"?Object.values(d).forEach(m=>{typeof m=="number"?c+=`${m.toFixed(4)}`:c+=`${m}`}):c+=`${d}`})}),c}a.getHash=t;function e(l){let c=0;for(let p of l.layers)"alpha"in p.data&&p.data.type!=="light"&&p.data.type!=="fresnel"&&(c+=(1-c)*p.data.alpha);return c<1}a.isTransparent=e;function r(){return{layers:new $e}}a.defaultEmptyData=r;function i(l="layer1",c="layer2"){return o("phong",l,c)}a.defaultData=i;function o(l,c="layer1",p="layer2"){let h=new $e;return h.push({fi:0,data:$i.defaultData("light",l),id:c}),h.push({fi:1,data:$i.defaultData("color"),id:p}),{layers:h}}a.defaultTwoLayerData=o;function s(l,c="basic",p="layer1",h="layer2"){let d=$i.defaultData("texture");Object.assign(d.texture,{image:l});let m=new $e;return m.push({fi:0,data:d,id:p}),m.push({fi:1,data:$i.defaultData("light",c),id:h}),{layers:m}}a.defaultTwoLayerTextureData=s})(Ji||(Ji={}));var Ki;(r=>{function n(){return{points:new $e,roundness:0,shapeHoles:[],isClosed:!1}}r.defaultData=n;function t(i,o){let{points:s}=o;if(s){for(let a of s)if(a.data.position[0]===i[0]&&a.data.position[1]===i[1])return!0}return!1}r.isOverlappingExistingPoint=t;function e(i,o){let s=i.controlNext,a=o.controlPrevious;return i.position[0]===s.position[0]&&i.position[1]===s.position[1]&&o.position[0]===a.position[0]&&o.position[1]===a.position[1]}r.isStraightLine=e})(Ki||(Ki={}));var As;(t=>{function n(e){return e==="PolygonGeometry"||e==="RectangleGeometry"||e==="StarGeometry"||e==="TriangleGeometry"||e==="EllipseGeometry"}t.is2DParametricMesh=n})(As||(As={}));var Ds;(t=>{function n(e){if(e==="RectangleGeometry")return{width:320,height:320,type:e,cornerRadius:[0,0,0,0],cornerType:0,depth:0,extrudeBevelSize:0,extrudeBevelSegments:1};if(e==="VectorGeometry")return{width:100,height:100,type:e,subdivisions:12,shape:Ki.defaultData(),depth:0,extrudeBevelSize:0,extrudeBevelSegments:1};throw new Error("not implemented")}t.defaultData=n})(Ds||(Ds={}));var jo;(i=>{i.identity=W(P({},ls.identity),{hiddenMatrix:Ur.identity});function t(o){return{position:o.position,rotation:o.rotation,scale:o.scale,hiddenMatrix:o.hiddenMatrix}}i.fromObject=t;function e(o,s){return{position:(s==null?void 0:s.position)||o.position,rotation:(s==null?void 0:s.rotation)||o.rotation,scale:(s==null?void 0:s.scale)||o.scale,hiddenMatrix:(s==null?void 0:s.hiddenMatrix)||o.hiddenMatrix}}i.merge=e;function r(o,s){return{position:Ui.isEqual(o.position,s.position)?null:s.position,rotation:Ui.isEqual(o.rotation,s.rotation)?null:s.rotation,scale:Ui.isEqual(o.scale,s.scale)?null:s.scale,hiddenMatrix:Ur.isEqual(o.hiddenMatrix,s.hiddenMatrix)?null:s.hiddenMatrix}}i.diff=r})(jo||(jo={}));var qr;(t=>t.defaultData=P({states:new $e,events:new $e,visible:!0,raycastLock:!1},jo.identity))(qr||(qr={}));var kh;(t=>t.defaultData=P({type:"Empty"},qr.defaultData))(kh||(kh={}));var Xa;(t=>t.defaultData=P(P({type:"Mesh"},qr.defaultData),Is.defaultData))(Xa||(Xa={}));var Hh;(t=>t.defaultData=P(P({type:"TextFrame"},qr.defaultData),Ps.defaultData))(Hh||(Hh={}));var _s;(t=>t.defaultData=P(P(P({},qr.defaultData),jo.identity),li.defaultData))(_s||(_s={}));var qh;(t=>{function n(e){return P(P({},qr.defaultData),Os.defaultData(e))}t.defaultData=n})(qh||(qh={}));var Wh;(e=>(e.defaultCamera=P({position:[0,0,1e3],scale:[1,1,1],rotation:[0,0,0],hiddenMatrix:Ur.identity,name:"Play Camera",visible:!0,raycastLock:!1,states:new $e,events:new $e},li.defaultData),e.defaultMeshObject=W(P(P({name:"Rectangle"},qr.defaultData),Xa.defaultData),{geometry:Ds.defaultData("RectangleGeometry"),material:Ji.defaultTwoLayerData("basic","layer1","layer2")})))(Wh||(Wh={}));var $h;(e=>{function n(r,i){if(i===void 0)return r;let o=P({},r);return"material"in o&&"material"in i&&i.material&&(o.material=_a(o.material,s=>{if(typeof s!="string")for(let[a,l]of Object.entries(i.material.layers)){let c=s.layers.data(a);c&&ai(c,l)}}).data),o.materials&&i.materials&&(o.materials=_a(o.materials,s=>{var a,l;for(let c=0;c<o.materials.length;c++){let p=i.materials[c];if(typeof p!="string")for(let[h,d]of Object.entries(p.layers)){let m=(l=(a=s[c])==null?void 0:a.layers)==null?void 0:l.data(h);m&&ai(m,d)}}}).data),o}e.patchMaterialState=n;function t(r,i){var s,a;if(i===void 0)return r;let o=P({},r);if(Object.assign(o,jo.merge(o,i)),ji.is(r.type)){o.orthographic=P({},o.orthographic),o.perspective=P({},o.perspective);let l=i;((s=l.orthographic)==null?void 0:s.zoom)!==void 0&&(o.orthographic.zoom=l.orthographic.zoom),((a=l.perspective)==null?void 0:a.zoom)!==void 0&&(o.perspective.zoom=l.perspective.zoom)}else if(r.type==="Mesh")o.geometry=P({},o.geometry),Object.assign(o.geometry,i.geometry),o=n(o,i);else if(Ms.is(r.type)){let l=i;o.intensity!==void 0&&(o.intensity=l.intensity),l.color!==void 0&&(typeof l.color=="string"?o.color=l.color:o.color=Et.clone(l.color))}return o}e.patch=t})($h||($h={}));import{BufferGeometry as OA,ConeBufferGeometry as cb,Float32BufferAttribute as IA,Vector2 as PA,Vector3 as AA}from"three";import{BufferGeometry as ab,CylinderBufferGeometry as lb,Float32BufferAttribute as Za,Vector2 as Xt,Vector3 as Bs}from"three";var Kh=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){var s,a,l,c,p;let e=Object.assign({},(s=t==null?void 0:t.parameters)!=null?s:{width:100,radialSegments:64,heightSegments:1,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadius:0,cornerSegments:8,hollow:0},n.parameters),r=e.width/2,i=(a=e.radiusTop)!=null?a:r,o=(l=e.radiusBottom)!=null?l:r;return i===o?(i=r,o=r):i>o?(i=r,o=o*r/i):(i=i*r/o,o=r),{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs((c=e.height)!=null?c:e.width),depth:Math.abs((p=e.depth)!=null?p:e.width),radiusTop:i,radiusBottom:o})}}static build(n){let{width:t,depth:e,height:r,radialSegments:i,heightSegments:o,openEnded:s,thetaStart:a,thetaLength:l,radiusTop:c,radiusBottom:p,cornerRadius:h,cornerSegments:d,hollow:m}=n.parameters,f;return h||m?f=new Uo(c,p,r,i,o,s,a,l*Math.PI/180,h,h,d,m):f=new lb(c,p,r,i,o,s,a,l*Math.PI/180),f.scale(1,1,e/t),Object.assign(f,{userData:W(P({},n),{type:"CylinderGeometry"})})}};function Wr(n,t,e){e.x=n.x*t.x,e.y=n.y,e.z=n.x*t.y}function Jh(n){return new Xt(n.y,-n.x)}var Uo=class extends ab{constructor(t,e,r,i,o,s,a,l,c,p,h,d,m=!1){super(),this.type="RoundedCylinderBufferGeometry",t=t!==void 0?t:1,e=e!==void 0?e:1,r=r||1,i=Math.floor(i)||8,o=Math.floor(o)||1,s=s!==void 0?s:!1,a=a!==void 0?a:0,l=l!==void 0?l:Math.PI*2,s&&(c=0,p=0);let f=[],T=[],w=[],y=[],L=0,A=r/2,I=new Bs,b=new Bs;m&&t==0&&(t=c),m&&e==0&&(e=p);let V=new Xt(t,A),x=new Xt(e,-A),u=null,M=null,g=null,N=null,v=V.clone().sub(x),C=0,$=0,H=0;d>0&&(C=Math.min(t,e)*(1-d),$=t-C,H=e-C);let ie=V.clone();ie.x-=C;let pe=Math.PI-v.angle(),ce=v.angle(),be=Math.tan(ce/2),F=Math.tan(pe/2),G=be+F,_=d?G:F,z=d?G:be;if(c=Math.min(c,(t-$)/_,v.length()/G),p=Math.min(p,(e-H)/z,v.length()/G),c>0){let j=c/be;u=V.clone().sub(new Xt(j,c)),d&&(g=u.clone(),g.x-=C-G*c),V.sub(v.clone().setLength(j))}if(p>0){let j=p/F;M=x.clone().sub(new Xt(j,-p)),x.add(v.clone().setLength(j)),d&&(N=M.clone(),N.x-=C-G*p,ie.sub(v.clone().setLength(j)))}v=V.clone().sub(x);let D=v.length()<.5,R=[];for(let j=0;j<=i;j++){let B=[],k=j/i,ne=k*l+a,q=new Xt(Math.sin(ne),Math.cos(ne));N&&M?(K(B,k,q,pe,p,N,-1,!0),K(B,k,q,ce,p,M,-1,!1)):M?(Z(B,q,M.x,0,-1),K(B,k,q,ce,p,M,-1,!1)):s||Z(B,q,e,H,-1);let J=Jh(v).normalize();if(Wr(J,q,I),!D)for(let Y=0;Y<=o;Y++){let X=Y/o,Q=v.clone().multiplyScalar(X).add(x);Wr(Q,q,b),T.push(b.x,b.y,b.z),w.push(I.x,I.y,I.z),y.push(k,.5+b.y/r),B.push(L++)}if(g&&u?(K(B,k,q,pe,c,u,1,!1),K(B,k,q,ce,c,g,1,!0)):u?(K(B,k,q,pe,c,u,1,!1),Z(B,q,u.x,0,1)):s||Z(B,q,t,$,1),d&&!D){let Y=Jh(v).multiplyScalar(-1).normalize();Wr(Y,q,I);for(let X=0;X<=o;X++){let Q=X/o,se=v.clone().multiplyScalar(-Q).add(ie);Wr(se,q,b),T.push(b.x,b.y,b.z),w.push(I.x,I.y,I.z),y.push(k,.5+b.y/r),B.push(L++)}}d&&!s&&B.push(B[0]),R.push(B)}for(let j=0;j<R.length-1;j++)for(let B=0;B<R[0].length-1;B++){if(s&&d&&B==o)continue;let k=R[j][B],ne=R[j+1][B],q=R[j+1][B+1],J=R[j][B+1],Y=T[q*3+0],X=T[q*3+2];f.push(k,ne,J),(Y!=0||X!=0)&&f.push(ne,q,J)}l<Math.PI*2&&(U(-1,R[0],a),U(1,R[R.length-1],a+l)),this.setIndex(f),this.setAttribute("position",new Za(T,3)),this.setAttribute("normal",new Za(w,3)),this.setAttribute("uv",new Za(y,2));function K(j,B,k,ne,q,J,Y,X){for(let Q=0;Q<h+1;Q++){let se=Q/h,oe=Y<0?se:1-se;X&&(oe-=1),oe*=ne;let he=new Xt(Math.sin(oe),Math.cos(oe)*Y),Ee=he.clone().multiplyScalar(q).add(J);Wr(Ee,k,b),T.push(b.x,b.y,b.z),Wr(he,k,I),w.push(I.x,I.y,I.z),y.push(B,.5+b.y/r),j.push(L++)}}function Z(j,B,k,ne,q){let J=new Bs,Y=new Xt,X=[k,ne];q<0&&X.reverse();for(let Q of X)Y.set(Q,A*q),Wr(Y,B,J),T.push(J.x,J.y,J.z),w.push(0,q,0),y.push(.5,.5),j.push(L++)}function U(j,B,k){let ne=new Xt(Math.sin(k),Math.cos(k)),q=new Xt(-Math.cos(k),Math.sin(k)),J=new Bs,Y=j<0?(se,oe,he)=>f.push(se,oe,he):(se,oe,he)=>f.push(se,he,oe),X=new Xt((t+e+$+H)/4,0);Wr(X,ne,J),T.push(J.x,J.y,J.z),w.push(q.x,0,q.y),y.push(.5,.5);let Q=L++;for(let se of B){let oe=T.slice(se*3,se*3+3);T.push(...oe),w.push(q.x,0,q.y);let he=y.slice(se*2,se*2+2);y.push(...he),L++}for(let se=Q+1;se<L-1;se++)Y(Q,se,se+1);Y(Q,L-1,Q+1)}}};var Yh=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){var r,i,o;let e=Object.assign({},(r=t==null?void 0:t.parameters)!=null?r:{width:100,radialSegments:32,heightSegments:8,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadiusTop:0,cornerRadiusBottom:0,cornerSegments:8},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs((i=e.height)!=null?i:e.width),depth:Math.abs((o=e.depth)!=null?o:e.width)})}}static build(n){let{width:t,depth:e,height:r,radialSegments:i,heightSegments:o,openEnded:s,thetaStart:a,thetaLength:l,cornerRadiusTop:c,cornerRadiusBottom:p,cornerSegments:h}=n.parameters,d;return c>0||p>0||l<360?d=new Uo(0,t/2,r,i,o,s,a,l*Math.PI/180,c,p,h,0,!0):d=new cb(t/2,r,i,o,s),d.scale(1,1,e/t),Object.assign(d,{userData:W(P({},n),{type:"ConeGeometry"})})}};import{BoxBufferGeometry as pb,BufferGeometry as hb,Float32BufferAttribute as Qa,Vector3 as ko}from"three";var Xh=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){var r,i,o;let e=Object.assign({},(r=t==null?void 0:t.parameters)!=null?r:{width:100,widthSegments:1,heightSegments:1,depthSegments:1,cornerRadius:0,cornerSegments:8},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs((i=e.height)!=null?i:e.width),depth:Math.abs((o=e.depth)!=null?o:e.width)})}}static build(n){let{width:t,height:e,depth:r,widthSegments:i,heightSegments:o,depthSegments:s,cornerRadius:a,cornerSegments:l}=n.parameters,c;return a==0?c=new pb(t,e,r,i,o,s):c=new tl(t,e,r,i,o,s,a,l),Object.assign(c,{userData:W(P({},n),{type:"CubeGeometry"})})}},el=Math.PI/2,tl=class extends hb{constructor(t=1,e=1,r=1,i=1,o=1,s=1,a=0,l=4){super(),this.type="BoxBufferGeometry";let c=this;i=Math.floor(i),o=Math.floor(o),s=Math.floor(s),l=Math.floor(l),a=Math.min(a,t/2,e/2,r/2);let p=[],h=[],d=[],m=[],f=0,T=0;w("z","y","x",-1,-1,r,e,t,s,o,0),w("z","y","x",1,-1,r,e,-t,s,o,1),w("x","z","y",1,1,t,r,e,i,s,2),w("x","z","y",1,-1,t,r,-e,i,s,3),w("x","y","z",1,-1,t,e,r,i,o,4),w("x","y","z",-1,-1,t,e,-r,i,o,5),a>0&&(y("z","y","x",-1,-1,1,r,e,t,s,0),y("z","y","x",1,-1,-1,r,e,t,s,1),y("z","y","x",-1,1,-1,r,e,t,s,1),y("z","y","x",1,1,1,r,e,t,s,0),y("x","y","z",-1,-1,-1,t,e,r,i,0),y("x","y","z",1,-1,1,t,e,r,i,1),y("x","y","z",-1,1,1,t,e,r,i,0),y("x","y","z",1,1,-1,t,e,r,i,1),y("y","x","z",-1,-1,1,e,t,r,o,0),y("y","x","z",1,-1,-1,e,t,r,o,1),y("y","x","z",1,1,1,e,t,r,o,1),y("y","x","z",-1,1,-1,e,t,r,o,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(p),this.setAttribute("position",new Qa(h,3)),this.setAttribute("normal",new Qa(d,3)),this.setAttribute("uv",new Qa(m,2));function w(A,I,b,V,x,u,M,g,N,v,C){let $=(u-2*a)/N,H=(M-2*a)/v,ie=u/2-a,pe=M/2-a,ce=g/2,be=N+1,F=v+1,G=0,_=0,z=new ko;for(let D=0;D<F;D++){let R=D*H-pe;for(let K=0;K<be;K++){let Z=K*$-ie;z[A]=Z*V,z[I]=R*x,z[b]=ce,h.push(z.x,z.y,z.z),z[A]=0,z[I]=0,z[b]=g>0?1:-1,d.push(z.x,z.y,z.z),m.push(K/N),m.push(1-D/v),G+=1}}for(let D=0;D<v;D++)for(let R=0;R<N;R++){let K=f+R+be*D,Z=f+R+be*(D+1),U=f+(R+1)+be*(D+1),j=f+(R+1)+be*D;p.push(K,Z,j),p.push(Z,U,j),_+=6}c.addGroup(T,_,C),T+=_,f+=G}function y(A,I,b,V,x,u,M,g,N,v,C){let $=(M-2*a)/v,H=M/2-a,ie=g/2-a,pe=N/2,ce=v+1,be=0,F=0,G=new ko,_=new ko;for(let z=0;z<l+1;z++){let D=z/l*el,R=Math.sin(D)*a,K=(1-Math.cos(D))*a,Z=Math.sin(D),U=Math.cos(D);G[I]=(ie+R)*x,G[b]=(pe-K)*u,_[A]=0,_[I]=Z*Math.sign(G[I]),_[b]=U*Math.sign(G[b]);for(let j=0;j<ce;j++){let B=j*$-H;G[A]=B*V,h.push(G.x,G.y,G.z),d.push(_.x,_.y,_.z),m.push(j/v),m.push(0),be+=1}}for(let z=0;z<l;z++)for(let D=0;D<v;D++){let R=f+D+ce*z,K=f+D+ce*(z+1),Z=f+(D+1)+ce*(z+1),U=f+(D+1)+ce*z;p.push(R,K,U),p.push(K,Z,U),F+=6}c.addGroup(T,F,C),T+=F,f+=be}function L(A,I,b){let V=new ko,x=new ko(t/2,e/2,r/2);x.subScalar(a);let u=[],M=A*I*b>0?(N,v,C)=>p.push(N,v,C):(N,v,C)=>p.push(N,C,v);for(let N=0;N<=l;N++){let v=[],C=el*(1-N/l),$=Math.cos(C),H=Math.sin(C),ie=0;for(let pe=0;pe<=N;pe++){let ce=Math.cos(ie),be=Math.sin(ie);V.x=$*ce,V.y=H,V.z=$*be;let F=x.clone().addScaledVector(V,a);h.push(A*F.x,I*F.y,b*F.z),d.push(A*V.x,I*V.y,b*V.z),m.push(0,0),v.push(f++),ie+=el/N}u.push(v)}let g=u.length-1;for(let N=0;N<g;N++){let v=u[N],C=u[N+1],$=v.length-1;M(v[0],C[1],C[0]);for(let H=1;H<=$;H++)M(v[H-1],v[H],C[H]),M(v[H],C[H+1],C[H])}}}};import{BufferGeometry as db,Float32BufferAttribute as rl,Triangle as ub,Vector3 as Nr,Vector2 as il}from"three";var $r=class extends db{constructor(t=[],e=[],r="",i=1,o=.2,s=4){super(),this.type="PolyhedronGeometryRound";let a=[],l=[],c=[];p(),h(),this.setAttribute("position",new rl(a,3)),this.setAttribute("normal",new rl(c,3)),this.setAttribute("uv",new rl(l,2));return;function p(){var be;o=Math.min(1-1e-5,o),o==0&&(s=0);let m={IcosahedronGeometry:5,DodecahedronGeometry:3,HexahedronGeometry:3,OctahedronGeometry:4,TetrahedronGeometry:3}[r],f=new Nr,T=f.clone(),w=new ub,y=o*i,L=i-y,A=s+1,I=new Nr,b=(F,G)=>I.subVectors(F,G).normalize(),V=(F,G)=>Array(F).fill(void 0).map(G),x=V(t.length/3,(F,G)=>new Nr().fromArray(t,G*3).setLength(i)),u=[],M=1e6;for(let F=0;F<x.length;F++){let G=x[F],_=[],z,D,R,K=1e10,Z=-1;for(;(Z=e.indexOf(F,Z+1))!=-1;){let k=Z-Z%3;z=e[k+(Z+1)%3],D=e[k+(Z+2)%3],R=G.distanceToSquared(x[z]),K=Math.min(K,R),_.push([z,D,R])}K+=1e-6;let U=[],j=0,B=_.length;for(let k=0;k<B;k++){[z,D,R]=_[j];let ne=((be=u[z])==null?void 0:be.includes(F))==!0;R<=K&&U.push(z+ +ne*M),j=_.findIndex(q=>q[0]==D)}u.push(U)}let g=[];{let F=0,G=0,_,z,D=m==3;for(let R=0;R<=s;R++){_=R*(R+1)/2,z=(R+1)*(R+2)/2;for(let K=0;K<s-R;K++)[F,G]=[_+K+R+2,z+K+R+3],g.push(_,z,...D?[G,_]:[F,z],G,F),[_,z]=[F,G];g.push(_,z,_+s+2)}}let N=f.clone(),v=f.clone(),C=f.clone(),$=f.clone(),H=f.clone(),ie=[],pe=V(x.length,()=>V(m,()=>f.clone()));for(let F=0;F<x.length;F++){f.copy(x[F]).normalize(),N.copy(f).multiplyScalar(L);let G=u[F];for(let U=0;U<G.length;U++){let j=G[U],B=G[(U+1)%m];w.setFromPointsAndIndices(x,F,j%M,B%M),w.b.sub(w.a).setLength(1e10).add(w.a),w.c.sub(w.a).setLength(1e10).add(w.a),w.closestPointToPoint(N,pe[F][U])}let _=[],z=[],D=[],R=new Nr;s==0&&[...pe[F]].reduce((U,j)=>U.add(j),R).multiplyScalar(1/m);for(let U=0;U<m;U++){let j=[],B=(U-1+m)%m,k=pe[F][B],ne=pe[F][U];f.copy(k).sub(N),T.copy(ne).sub(N);let q=N.angleTo(f),J=f.angleTo(T),Y=Math.cos(q)*y;s==0?v.copy(R):v.copy(N).setLength(L+Y),z.push(Y);let X=[v,k,ne];for(let Q=0;Q<2;Q++){let se=X[Q],oe=X[Q+1];$.subVectors(se,N),H.subVectors(oe,N),C.crossVectors($,H).normalize();for(let he=0;he<A;he++){let Ee=[q,J][Q]*he/A;f.copy($).applyAxisAngle(C,Ee).add(N),_.push(f.clone()),Q&&(b(f,N),j.push([he==0?se:f.clone(),I.clone()]))}Q&&(b(oe,N),j.push([oe,I.clone()]))}D.push(j)}ie.push(D);let K=2*A,Z=2;for(let U=0;U<m;U++){let j=K*U,B=K*((U+1)%m),k=[_[j]];for(let q=1;q<A;q++){$=_[j+q],H=_[B+q],k.push($);for(let J=1,Y=q-Z+1;J<=Y;J++)f.lerpVectors($,H,J/(Y+1)),f.sub(N).setLength(z[U]).add(N),k.push(f.clone());k.push(H)}for(let q=0;q<A;q++)k.push(_[q+A+j]);k.push(_[B+A]);let ne=g.map(q=>k[q]);a.push(...ne.map(q=>[q.x,q.y,q.z]).flat()),c.push(...ne.map(q=>(b(q,N),[I.x,I.y,I.z])).flat())}}let ce=[];for(let F=0;F<u.length;F++)for(let G=0;G<m;G++){let _=u[F][G];if(_<M){let z=u[_].findIndex(K=>K%M==F),D=ie[F][G],R=ie[_][z];for(let K=0;K<A;K++){let Z=D[K],U=R[A-K],j=D[K+1],B=R[A-(K+1)];[Z,U,j,j,U,B].forEach(k=>{a.push(k[0].x,k[0].y,k[0].z),c.push(k[1].x,k[1].y,k[1].z)})}ce.push(D[0][0],R[A][0],D[A][0],R[0][0])}}for(;ce.length;){let F,G,_,z;[F,G]=ce.splice(0,2);let D=[F];for(;F!=G;)D.push(G),_=ce.indexOf(G),z=_%2,G=ce.splice(_-z,2)[1-z];I.subVectors(D[0],D[1]).cross(f.subVectors(D[0],D[2])).normalize();let R=I.dot(D[0])<0;R&&I.negate();for(let K=1;K<=D.length-2;K++)[D[K+ +R],D[K+1-+R],D[0]].forEach(Z=>{a.push(Z.x,Z.y,Z.z),c.push(I.x,I.y,I.z)})}}function h(){let d=new Nr;for(let x=0;x<a.length;x+=3){d.x=a[x+0],d.y=a[x+1],d.z=a[x+2];let u=b(d)/2/Math.PI+.5,M=V(d)/Math.PI+.5;l.push(u,1-M)}let m=new Nr,f=new Nr,T=new Nr,w=new Nr,y=new il,L=new il,A=new il,I=(x,u,M,g)=>{g<0&&x.x===1&&(l[u]=x.x-1),M.x===0&&M.z===0&&(l[u]=g/2/Math.PI+.5)};for(let x=0,u=0;x<a.length;x+=9,u+=6){m.set(a[x+0],a[x+1],a[x+2]),f.set(a[x+3],a[x+4],a[x+5]),T.set(a[x+6],a[x+7],a[x+8]),y.set(l[u+0],l[u+1]),L.set(l[u+2],l[u+3]),A.set(l[u+4],l[u+5]),w.copy(m).add(f).add(T).divideScalar(3);let M=b(w);I(y,u+0,m,M),I(L,u+2,f,M),I(A,u+4,T,M)}for(let x=0;x<l.length;x+=6){let u=l[x+0],M=l[x+2],g=l[x+4],N=Math.max(u,M,g),v=Math.min(u,M,g);N>.9&&v<.1&&(u<.2&&(l[x+0]+=1),M<.2&&(l[x+2]+=1),g<.2&&(l[x+4]+=1))}function b(x){return Math.atan2(x.z,-x.x)}function V(x){return Math.atan2(-x.y,Math.sqrt(x.x*x.x+x.z*x.z))}}}static fromJSON(t){return new $r(t.vertices,t.indices,t.radius,t.corner,t.cornerSides)}};import{DodecahedronBufferGeometry as mb}from"three";var Zh=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){var r,i,o;let e=Object.assign({},(r=t==null?void 0:t.parameters)!=null?r:{width:100,detail:0,corner:0,cornerSides:4},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs((i=e.height)!=null?i:e.width),depth:Math.abs((o=e.depth)!=null?o:e.width)})}}static build(n){let{width:t,height:e,depth:r,detail:i,corner:o,cornerSides:s}=n.parameters,a=i===0&&o!==0?new Ho(t*.5,o,s):new mb(t*.5,i);return a.scale(1,e/t,r/t),Object.assign(a,{userData:W(P({},n),{type:"DodecahedronGeometry"})})}},Ho=class extends $r{constructor(t=1,e=.2,r=4){let i=(1+Math.sqrt(5))/2,o=1/i,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,-o,-i,0,-o,i,0,o,-i,0,o,i,-o,-i,0,-o,i,0,o,-i,0,o,i,0,-i,0,-o,i,0,-o,-i,0,o,i,0,o],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,t,e,r),this.type=l}static fromJSON(t){return new Ho(t.radius,t.corner,t.cornerSides)}};import{EventDispatcher as Tb,Plane as Nb,Shape as pd,Vector2 as Mr,Vector3 as Mb,MathUtils as pl,LineCurve as hl,QuadraticBezierCurve as hd,CubicBezierCurve as zs}from"three";import{CubicBezierCurve as Es,EllipseCurve as fb,LineCurve as Gs,LineCurve3 as yb,MathUtils as gb,QuadraticBezierCurve as ol,SplineCurve as xb,Vector2 as Zt,Vector3 as Qh}from"three";var qo=1e-12,Yi=class{constructor(t){this.position=new Zt;this.startPosition=new Zt;this.uuid=gb.generateUUID();this.position=t.clone()}start(){this.reset()}reset(){this.startPosition.copy(this.position)}applyOffset(t){this.position.copy(this.startPosition).add(t)}copy(t){return this.position.copy(t.position),this.startPosition.copy(t.startPosition),this}clone(){return new Yi(this.position).copy(this)}toJSON(){return[this.position.x,this.position.y]}},Xi=class extends Yi{constructor(e){super(e.position);this.parent=e}copy(e){return super.copy(e),this}clone(){return new Xi(this.parent).copy(this)}},Qt=class extends Yi{constructor(e,r){super(r);this.controls=[];this.roundness=0;this.areControlsDirectionsMirrored=!0;this.uuid=e,this.controls.push(new Xi(this),new Xi(this))}static create(e,r){let i=new Qt(e,new Zt(...r.position));return i.controls[0].position.set(...r.controlPrevious.position),i.controls[1].position.set(...r.controlNext.position),i.roundness=r.roundness,i.areControlsDirectionsMirrored=r.areControlsDirectionsMirrored,i}getOppositeControl(e){let r=this.controls.indexOf(e);return r===0?this.controls[1]:r===1?this.controls[0]:null}applyOffsetToControls(e,r=1){for(let i=0,o=this.controls.length;i<o;i++){let s=this.controls[i];this.position.distanceTo(s.position)<=r?s.position.copy(this.position):s.applyOffset(e)}}controlsMoved(){return!(this.position.equals(this.controls[0].position)&&this.position.equals(this.controls[1].position))}copy(e){return super.copy(e),this.controls[0].copy(e.controls[0]),this.controls[1].copy(e.controls[1]),this.roundness=e.roundness,this.uuid=e.uuid,this}clone(){return new Qt(this.uuid,this.position).copy(this)}toJSON(){return super.toJSON().concat(this.controls[0].toJSON(),this.controls[1].toJSON(),[this.roundness])}},nl=n=>n,$o=new Zt,sl=new Zt,bb=new Zt,vb=new Zt,Sb=new Zt,wb=new Zt,ed=new Qh,td=new Qh;function rd(n){let t=new Zt;t.addVectors(n.v0,$o.subVectors(n.v1,n.v0).multiplyScalar(2/3));let e=new Zt;return e.addVectors(n.v2,sl.subVectors(n.v1,n.v2).multiplyScalar(2/3)),new Es(n.v0,t,e,n.v2)}function Wo(n,t,e=Number.EPSILON){return Math.abs(n-t)<e}function Lb(n,t,e=Number.EPSILON){return n.distanceTo(t)<e}function Cb(n,t,e=Number.EPSILON){return n.distanceTo(t)<e}function al(n,t,e){let r=Math.sqrt(Math.pow(t.x-n.x,2)+Math.pow(t.y-n.y,2)),i=Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2)),o=Math.sqrt(Math.pow(e.x-n.x,2)+Math.pow(e.y-n.y,2));return Math.acos((i*i+r*r-o*o)/(2*i*r))}function id(n,t,e,r,i){let o=Math.sqrt(Math.pow(t.x-n.x,2)+Math.pow(t.y-n.y,2)),s=(n.y+t.y)/2,a=(n.x+t.x)/2,l=Math.sqrt(Math.pow(e,2)-Math.pow(o/2,2))*(n.y-t.y)/o,c=Math.sqrt(Math.pow(e,2)-Math.pow(o/2,2))*(t.x-n.x)/o;return r.set(a+l,s+c),i.set(a-l,s-c),[r,i]}function od(n,t,e){let r=n.distanceTo(e),i=t.distanceTo(e);return r<i?t:n}function nd(n,t,e,r,i,o){let s=t.x-n.x,a=t.y-n.y,l=e.x-n.x,c=e.y-n.y,p=Math.sqrt((s+l)*(s+l)+(a+c)*(a+c)),h;return al(t,n,e)>Math.PI&&(p*=-1),Wo(c,a)?h=(a+c)*(r/p-.5)*8/3/(s-l):h=(s+l)*(r/p-.5)*8/3/(c-a),i.set(t.x-h*a,t.y+h*s),o.set(e.x+h*c,e.y-h*l),[i,o]}function ll(n,t){return n.position.equals(n.controls[1].position)&&t.position.equals(t.controls[0].position)}function sd(n,t,e,r,i=.5){let o=$o.subVectors(t,n).multiplyScalar(i).add(n),s=sl.subVectors(e,t).multiplyScalar(i).add(t),a=bb.subVectors(r,e).multiplyScalar(i).add(e),l=o,c=vb.subVectors(s,o).multiplyScalar(i).add(o),p=Sb.subVectors(a,s).multiplyScalar(i).add(s),h=a,d=wb.subVectors(p,c).multiplyScalar(i).add(c);return[n.x,n.y,l.x,l.y,c.x,c.y,d.x,d.y,p.x,p.y,h.x,h.y,r.x,r.y]}function ad(n,t,e=12,r=!0){let i=td.set(0,0,0),o,s=0,a=[];for(let l=0;l<t.length;l++){let c=nl(t[l]),p=$o,h=Jr(c,e);a.push(h);for(let d=0;d<=h;d++)if(c instanceof Es||c instanceof ol||c instanceof Gs){if(c.getPoint(d/h,p),i.set(p.x,p.y,0),o!==void 0&&Cb(o,i))continue;o===void 0&&(o=ed),o.copy(i),n.setXYZ(s,i.x,i.y,i.z),s++}}return r&&s>1&&!(n.getX(s-1)===n.getX(0)&&n.getY(s-1)===n.getY(0)&&n.getZ(s-1)===n.getZ(0))&&(n.setXYZ(s,n.getX(0),n.getY(0),n.getZ(0)),s++),n}function ld(n,t,e,r=12,i=!0){let o=td.set(0,0,0),s=0,a=[];for(let l=0;l<t.length;l++){if(e[l]===!1)continue;let c,p=nl(t[l]),h=$o,d=Jr(p,r);a.push(d);for(let m=0;m<=d;m++)if(p instanceof Es||p instanceof ol||p instanceof Gs){if(p.getPoint(m/d,h),o.set(h.x,h.y,0),c!=null&&c.equals(o))continue;c===void 0?c=ed:(n.setXYZ(s,c.x,c.y,c.z),s++,n.setXYZ(s,o.x,o.y,o.z),s++),c.copy(o)}}return i&&s>1&&!(n.getX(s-1)===n.getX(0)&&n.getY(s-1)===n.getY(0)&&n.getZ(s-1)===n.getZ(0))&&(n.setXYZ(s,n.getX(0),n.getY(0),n.getZ(0)),s++),a}function cl(n,t=12,e=!1){let r=[];for(let i=0,o=n.length;i<o;i++){let s=n[i],a=0;if(e&&s.roundedCurveCorner!==void 0){let l=Jr(s.roundedCurveCorner,t)*.5;i>0&&(r[i-1]+=l),a+=l}s.curveAfter!==void 0&&(a+=Jr(s.curveAfter,t)),r.push(a)}return n.length>0&&e&&n[0].roundedCurveCorner!==void 0&&(r[n.length-1]+=Jr(n[0].roundedCurveCorner,t)*.5),r}function Jr(n,t=12){return n&&n instanceof fb?t*2:n&&(n instanceof Gs||n instanceof yb)?1:n&&n instanceof xb?t*n.points.length:t}function cd(n,t,e=12,r=!0){let i,o=0;for(let s=0;s<t.length;s++){let a=nl(t[s]),l=Jr(a,e),c=$o;for(let p=0;p<=l;p++)if(a instanceof Es||a instanceof ol||a instanceof Gs){if(a.getPoint(p/l,c),i!==void 0&&Lb(i,c,qo))continue;i===void 0&&(i=sl),i.copy(c),n.push(c.x,c.y),o++}}return Wo(n[0],n[n.length-2],qo)&&Wo(n[1],n[n.length-1],qo)&&(n.pop(),n.pop()),r&&o>1&&!(Wo(n[o-1],n[1],qo)&&Wo(n[o-2],n[0],qo))&&(n.push(n[0],n[1]),o++),n}var dl=new Mr,Ob=new Mr,Ib=new Mr,Pb=new Mr,Ab=new Mr,Db=new Mr,Me=class extends pd{constructor(e=100,r=100){super();this.points=[];this.shapeHoles=[];this.eventDispatcher=new Tb;this.plane=new Nb(new Mb(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=r}static createFromState(e,r,i){let o=new Me;return o.isClosed=e.isClosed,o.points=e.points.map(s=>Qt.create(s.id,s.data)),typeof e.roundness=="number"&&(o.roundness=e.roundness),o.shapeHoles=e.shapeHoles.map(s=>Me.createFromState(s)),r!==void 0&&i!==void 0&&o.applySize(r,i),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 r=0,i=this.points.length;r<i;r++)this.points[r].roundness=e;this.needsUpdate=!0}}getPointsIndexesByIds(e){return e.map(r=>this.getPointIndexById(r)).filter(r=>r>=0)}getPointIndexById(e){return this.points.findIndex(r=>r.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 r=0,i=this.shapeHoles.length;r<i;r++){let o=this.shapeHoles[r],s=e-this.points.length;if(s<=o.points.length-1)return o.points[s]}throw new Error("This shape does not have a point for this index: "+e)}getBezierPointIndex(e){let r=this.points.indexOf(e);if(r>=0)return r;if(r=this.points.length,this.shapeHoles.length>0)for(let i=0,o=this.shapeHoles.length;i<o;i++){let s=this.shapeHoles[i],a=s.points.indexOf(e);if(a>=0)return r+a;r+=s.points.length}return-1}getAllPoints(){let e=[].concat(...this.shapeHoles.map(r=>r.points));return[...this.points,...e]}applySize(e,r){e===0&&(e=.001),r===0&&(r=.001),this._width=e,this._height=r}applyScale(e,r){let i=dl.set(e,r);for(let o=0,s=this.points.length;o<s;o++){let a=this.points[o];a.position.multiply(i),a.controls[0].position.multiply(i),a.controls[1].position.multiply(i)}for(let o=0,s=this.shapeHoles.length;o<s;o++)this.shapeHoles[o].applyScale(e,r);this._update(!1)}createPoint(e,r=0,i=pl.generateUUID()){let o;e instanceof Mr?o=e:o=new Mr(e,r);let s=new Qt(i,o);return s.roundness=this.roundness,s}addPoint(e){this.points.push(e),this.needsUpdate=!0}addPointAt(e,r){this.points.splice(r,0,e),this.needsUpdate=!0}getPointByUuid(e){for(let r=0,i=this.points.length;r<i;r++){let o=this.points[r];if(o.uuid===e)return o}}getFirstPoint(){return this.points[0]}getLastPoint(){return this.points[this.points.length-1]}removePoint(e){let r=this.points.indexOf(e);r>=0&&this.points.splice(r,1),this.needsUpdate=!0}removePointById(e){let r=this.points.find(i=>i.uuid===e);r&&this.removePoint(r)}update(e=!0){for(let r=0,i=this.shapeHoles.length;r<i;r++)this.shapeHoles[r].update(!1);this._update(e)}extractShapePointsToBuffer(e,r=12,i=!1){this.subdivision=r,this.curveDivisions===void 0&&this.computeCurveDivisions(r);let o=i?this.roundedCurveDivisions:this.curveDivisions;return ad(e,i?this.roundedCurves:this.curves,r,this.autoClose),o.reduce((s,a)=>s+a,0)+1}computeCurveDivisions(e=12){return this.curveDivisions=cl(this.points,e,!1),this.roundedCurveDivisions=cl(this.points,e,!0),this.curveDivisions}extractFilteredShapePointsToBuffer(e,r,i=12){return ld(e,this.curves,r,i,this.autoClose).reduce((s,a)=>s+a,0)*2}extractShapePointsToFlatArray(e,r=12){return this.subdivision=r,this.curveDivisions===void 0&&this.computeCurveDivisions(r),cd(e,this.roundedCurves,r,this.autoClose)}getCurveIndexFromVertexId(e,r=!1){let i=0;this.curveDivisions===void 0&&this.computeCurveDivisions(this.subdivision);let o=r?this.roundedCurveDivisions:this.curveDivisions,s=0;r&&this.points[0].roundedCurveCorner!==void 0&&(s=Jr(this.points[0].roundedCurveCorner,this.subdivision)*.5);let a=e-s;a<0&&(a+=o.reduce((l,c)=>l+c,0));for(let l=0,c=o.length;l<c;l++){let p=o[l];if(a<i+p)return[l,(a-i+1)/p];i+=p}return[0,1]}getCurveT(e,r,i){let o=this.points[e],s=this.points[e>=this.points.length-1?0:e+1],a=this.curveDivisions,l=a[e];if(ll(o,s)){let h=o.position.distanceTo(s.position);return o.position.distanceTo(dl.set(i.x,i.y))/h}let c=0;for(let h=0;h<e;h++)c+=a[h];return(r-c)/l}dispose(){this.eventDispatcher=null}_applyCurveForPoint(e,r){ll(r,e)?this.lineTo(e.position.x,e.position.y):this.bezierCurveTo(r.controls[1].position.x,r.controls[1].position.y,e.controls[0].position.x,e.controls[0].position.y,e.position.x,e.position.y);let i=this.curves[this.curves.length-1];e.curveBefore=i,r.curveAfter=i;let o=i.clone();e.roundedCurveBefore=o,r.roundedCurveAfter=o,e.roundedCurveCorner=void 0,this.roundedCurves.push(o)}_update(e=!0){var i;if(this.curves=[],this.roundedCurves=[],!this.points.length)return;for(let o=0,s=this.points.length;o<s;o++){let a=this.points[o];if(o===0)this.moveTo(a.position.x,a.position.y);else{let l=this.points[o-1];this._applyCurveForPoint(a,l)}}let r=this.getLastPoint();if(r!=null&&r.curveAfter&&(r.curveAfter=void 0),this.isClosed){let o=this.points[0],s=this.points[this.points.length-1];this._applyCurveForPoint(o,s)}if(this.points.length>2){let o=0;for(let s=0,a=this.points.length;s<a;s++){let l=this.points[s],c=l.roundness;if(!l.controlsMoved()&&c>0){let p=l.curveBefore,h=l.curveAfter;if(p===void 0||h===void 0)continue;let d=l.roundedCurveBefore,m=l.roundedCurveAfter,f=p.getLength(),T=h.getLength(),w=Math.min(c,f*.499),y=Math.min(c,T*.499),L=Math.min(w,y),A=1-L/f,I=L/T,b=p.getPointAt(A,dl),V=h.getPointAt(I,Ob);this._subSplitCurve(p,d,A,b,void 0),this._subSplitCurve(h,m,I,void 0,V);let x;if(this.useCubicForRoundedCorners){let u=al(b,l.position,V)/2,M=Math.tan(u)*b.distanceTo(l.position),[g,N]=id(b,V,M,Ib,Pb),v=od(g,N,l.position),[C,$]=nd(v,b,V,M,Ab,Db);x=new zs(b.clone(),C.clone(),$.clone(),V.clone())}else x=new hd(b.clone(),l.position.clone(),V.clone());l.roundedCurveCorner=x,this.roundedCurves.splice(s+o,0,x),o++}}}e&&((i=this.eventDispatcher)==null||i.dispatchEvent({type:"update"}))}_subSplitCurve(e,r,i,o,s){if(e instanceof hl)o!==void 0&&r.v2.copy(o),s!==void 0&&r.v1.copy(s);else{let a=e,l=r,c=a.getUtoTmapping(i,0),p=sd(a.v0,a.v1,a.v2,a.v3,c);return o!==void 0&&(l.v0.set(p[0],p[1]),l.v1.set(p[2],p[3]),l.v2.set(p[4],p[5]),l.v3.set(p[6],p[7])),s!==void 0&&(l.v0.set(p[6],p[7]),l.v1.set(p[8],p[9]),l.v2.set(p[10],p[11]),l.v3.set(p[12],p[13])),l}return r}clone(){let e=new Me(this._width,this._height);return e.points=this.points.map(r=>r.clone()),e.isClosed=this.isClosed,e.roundness=this.roundness,e.isMesh2D=this.isMesh2D,e.shapeHoles=this.shapeHoles.map(r=>r.clone()),e}toJSON(){return{points:this.points.reduce((e,r)=>e.concat(r.toJSON()),[]),shapeHoles:this.shapeHoles.map(e=>e.toJSON()),isClosed:this.isClosed,roundness:this.roundness}}fromJSON(e){var i;this.points=[],this.pointIDs=0;let r=e.points.length/7;for(let o=0;o<r;o++){let s=o*7,a=e.points[s+0],l=e.points[s+1],c=e.points[s+2],p=e.points[s+3],h=e.points[s+4],d=e.points[s+5],m=e.points[s+6],f=new Qt(pl.generateUUID(),new Mr(a,l));f.controls[0].position.set(c,p),f.controls[1].position.set(h,d),f.roundness=m,this.points.push(f)}return this.shapeHoles=(i=e.shapeHoles)!=null&&i.length?e.shapeHoles.map(o=>{let s=new Me;return s.fromJSON(o),s}):[],this.isClosed=e.isClosed,this._roundness=e.roundness,this._update(),this}fromShape(e){let r=(o,s)=>{s instanceof zs&&s.v3.equals(o.position)&&o.controls[0].position.copy(s.v2)},i=o=>{let s=[],a,l;for(a=0,l=o.length;a<l;a++)o[a]instanceof hd&&(o[a]=rd(o[a]));for(a=0,l=o.length;a<l;a++){let h=o[a],d=a>0?o[a-1]:null,m;h instanceof zs?(m=this.createPoint(h.v0),m.controls[1].position.copy(h.v1)):h instanceof hl&&(m=this.createPoint(h.v1)),m!==void 0&&(d!==null&&r(m,d),s.push(m))}let c=o[o.length-1],p=!1;return c instanceof zs?c.v3.equals(s[0].position)&&(s[0].controls[0].position.copy(c.v2),p=!0):c instanceof hl&&c.v2.equals(s[0].position)&&(p=!0),this.isClosed=p,s};return this.points=i(e.curves),e instanceof pd&&(this.shapeHoles=e.holes.map(o=>{let s=new Me;return s.fromShape(o),s})),this.update(),this}};var ml=Math.PI*2;function ul({x:n,y:t},e,r,i,o){return{x:n*e+i,y:t*r+o}}function _b(n,t){let e=t===1.5707963267948966?.551915024494:t===-1.5707963267948966?-.551915024494:1.3333333333333333*Math.tan(t/4),r=Math.cos(n),i=Math.sin(n),o=Math.cos(n+t),s=Math.sin(n+t);return[{x:r-i*e,y:i+r*e},{x:o+s*e,y:s-o*e},{x:o,y:s}]}function dd(n,t,e,r){let i=n*r-t*e<0?-1:1,o=Math.min(1,Math.max(-1,n*e+t*r));return i*Math.acos(o)}function Bb(n,t,e,r,i,o,s,a,l,c){let p=Math.pow(i,2),h=Math.pow(o,2),d=Math.pow(s,2),m=Math.pow(a,2),f=p*h-p*m-h*d;f<0&&(f=0),f/=p*m+h*d,f=Math.sqrt(f)*(l===c?-1:1);let T=f*i/o*a,w=f*-o/i*s,y=T+(n+e)/2,L=w+(t+r)/2,A=(s-T)/i,I=(a-w)/o,b=(-s-T)/i,V=(-a-w)/o,x=dd(1,0,A,I),u=dd(A,I,b,V);return!c&&u>0&&(u-=ml),c&&u<0&&(u+=ml),{centerx:y,centery:L,ang1:x,ang2:u}}function ud({px:n,py:t,cx:e,cy:r,rx:i,ry:o,largeArcFlag:s,sweepFlag:a}){let l=[];if(i===0||o===0)return[];let c=(n-e)/2,p=(t-r)/2;if(c===0&&p===0)return[];i=Math.abs(i),o=Math.abs(o);let h=Math.pow(c,2)/Math.pow(i,2)+Math.pow(p,2)/Math.pow(o,2);h>1&&(i*=Math.sqrt(h),o*=Math.sqrt(h));let d=Bb(n,t,e,r,i,o,c,p,s,a),{ang1:m,ang2:f}=d,{centerx:T,centery:w}=d,y=Math.abs(f)/(ml/4);Math.abs(1-y)<1e-7&&(y=1);let L=Math.max(Math.ceil(y),1);f/=L;for(let A=0;A<L;A++)l.push(_b(m,f)),m+=f;return l.map(A=>{let{x:I,y:b}=ul(A[0],i,o,T,w),{x:V,y:x}=ul(A[1],i,o,T,w),{x:u,y:M}=ul(A[2],i,o,T,w);return{x1:I,y1:b,x2:V,y2:x,x:u,y:M}})}import{BufferAttribute as Vs,BufferGeometry as Vb}from"three";var He;(function(n){n[n.ODD=0]="ODD",n[n.NONZERO=1]="NONZERO",n[n.POSITIVE=2]="POSITIVE",n[n.NEGATIVE=3]="NEGATIVE",n[n.ABS_GEQ_TWO=4]="ABS_GEQ_TWO"})(He||(He={}));var rt;(function(n){n[n.POLYGONS=0]="POLYGONS",n[n.CONNECTED_POLYGONS=1]="CONNECTED_POLYGONS",n[n.BOUNDARY_CONTOURS=2]="BOUNDARY_CONTOURS"})(rt||(rt={}));function ue(n,t){if(!n)throw t||"Assertion Failed!"}var ae=function(){function n(){}return n.vertEq=function(t,e){return t.s===e.s&&t.t===e.t},n.vertLeq=function(t,e){return t.s<e.s||t.s===e.s&&t.t<=e.t},n.transLeq=function(t,e){return t.t<e.t||t.t===e.t&&t.s<=e.s},n.edgeGoesLeft=function(t){return n.vertLeq(t.Dst,t.Org)},n.edgeGoesRight=function(t){return n.vertLeq(t.Org,t.Dst)},n.vertL1dist=function(t,e){return Math.abs(t.s-e.s)+Math.abs(t.t-e.t)},n.edgeEval=function(t,e,r){ue(n.vertLeq(t,e)&&n.vertLeq(e,r));var i=e.s-t.s,o=r.s-e.s;return i+o>0?i<o?e.t-t.t+(t.t-r.t)*(i/(i+o)):e.t-r.t+(r.t-t.t)*(o/(i+o)):0},n.edgeSign=function(t,e,r){ue(n.vertLeq(t,e)&&n.vertLeq(e,r));var i=e.s-t.s,o=r.s-e.s;return i+o>0?(e.t-r.t)*i+(e.t-t.t)*o:0},n.transEval=function(t,e,r){ue(n.transLeq(t,e)&&n.transLeq(e,r));var i=e.t-t.t,o=r.t-e.t;return i+o>0?i<o?e.s-t.s+(t.s-r.s)*(i/(i+o)):e.s-r.s+(r.s-t.s)*(o/(i+o)):0},n.transSign=function(t,e,r){ue(n.transLeq(t,e)&&n.transLeq(e,r));var i=e.t-t.t,o=r.t-e.t;return i+o>0?(e.s-r.s)*i+(e.s-t.s)*o:0},n.vertCCW=function(t,e,r){return t.s*(e.t-r.t)+e.s*(r.t-t.t)+r.s*(t.t-e.t)>=0},n.interpolate=function(t,e,r,i){return t=t<0?0:t,r=r<0?0:r,t<=r?r===0?(e+i)/2:e+(i-e)*(t/(t+r)):i+(e-i)*(r/(t+r))},n.intersect=function(t,e,r,i,o){var s,a,l;n.vertLeq(t,e)||(l=t,t=e,e=l),n.vertLeq(r,i)||(l=r,r=i,i=l),n.vertLeq(t,r)||(l=t,t=r,r=l,l=e,e=i,i=l),n.vertLeq(r,e)?n.vertLeq(e,i)?(s=n.edgeEval(t,r,e),a=n.edgeEval(r,e,i),s+a<0&&(s=-s,a=-a),o.s=n.interpolate(s,r.s,a,e.s)):(s=n.edgeSign(t,r,e),a=-n.edgeSign(t,i,e),s+a<0&&(s=-s,a=-a),o.s=n.interpolate(s,r.s,a,i.s)):o.s=(r.s+e.s)/2,n.transLeq(t,e)||(l=t,t=e,e=l),n.transLeq(r,i)||(l=r,r=i,i=l),n.transLeq(t,r)||(l=t,t=r,r=l,l=e,e=i,i=l),n.transLeq(r,e)?n.transLeq(e,i)?(s=n.transEval(t,r,e),a=n.transEval(r,e,i),s+a<0&&(s=-s,a=-a),o.t=n.interpolate(s,r.t,a,e.t)):(s=n.transSign(t,r,e),a=-n.transSign(t,i,e),s+a<0&&(s=-s,a=-a),o.t=n.interpolate(s,r.t,a,i.t)):o.t=(r.t+e.t)/2},n}(),Jo=function(){function n(){this.next=null,this.prev=null,this.anEdge=null,this.trail=null,this.n=0,this.marked=!1,this.inside=!1}return n}(),Rs=function(){function n(t){this.side=t,this.next=null,this.Org=null,this.Sym=null,this.Onext=null,this.Lnext=null,this.Lface=null,this.activeRegion=null,this.winding=0}return Object.defineProperty(n.prototype,"Rface",{get:function(){return this.Sym.Lface},set:function(t){this.Sym.Lface=t},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Dst",{get:function(){return this.Sym.Org},set:function(t){this.Sym.Org=t},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Oprev",{get:function(){return this.Sym.Lnext},set:function(t){this.Sym.Lnext=t},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Lprev",{get:function(){return this.Onext.Sym},set:function(t){this.Onext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Dprev",{get:function(){return this.Lnext.Sym},set:function(t){this.Lnext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Rprev",{get:function(){return this.Sym.Onext},set:function(t){this.Sym.Onext=t},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Dnext",{get:function(){return this.Sym.Onext.Sym},set:function(t){this.Sym.Onext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Rnext",{get:function(){return this.Sym.Lnext.Sym},set:function(t){this.Sym.Lnext.Sym=t},enumerable:!0,configurable:!0}),n}(),Zi=function(){function n(){this.next=null,this.prev=null,this.anEdge=null,this.coords=[0,0,0],this.s=0,this.t=0,this.pqHandle=0,this.n=0,this.idx=0}return n}(),md=function(){function n(){var t=new Zi,e=new Jo,r=new Rs(0),i=new Rs(1);t.next=t.prev=t,t.anEdge=null,e.next=e.prev=e,r.next=r,r.Sym=i,i.next=i,i.Sym=r,this.vHead=t,this.fHead=e,this.eHead=r,this.eHeadSym=i}return n.prototype.makeEdge_=function(t){var e=new Rs(0),r=new Rs(1);t.Sym.side<t.side&&(t=t.Sym);var i=t.Sym.next;return r.next=i,i.Sym.next=e,e.next=t,t.Sym.next=r,e.Sym=r,e.Onext=e,e.Lnext=r,e.Org=null,e.Lface=null,e.winding=0,e.activeRegion=null,r.Sym=e,r.Onext=r,r.Lnext=e,r.Org=null,r.Lface=null,r.winding=0,r.activeRegion=null,e},n.prototype.splice_=function(t,e){var r=t.Onext,i=e.Onext;r.Sym.Lnext=e,i.Sym.Lnext=t,t.Onext=i,e.Onext=r},n.prototype.makeVertex_=function(t,e,r){var i=t;ue(i,"Vertex can't be null!");var o=r.prev;i.prev=o,o.next=i,i.next=r,r.prev=i,i.anEdge=e;var s=e;do s.Org=i,s=s.Onext;while(s!==e)},n.prototype.makeFace_=function(t,e,r){var i=t;ue(i,"Face can't be null");var o=r.prev;i.prev=o,o.next=i,i.next=r,r.prev=i,i.anEdge=e,i.trail=null,i.marked=!1,i.inside=r.inside;var s=e;do s.Lface=i,s=s.Lnext;while(s!==e)},n.prototype.killEdge_=function(t){t.Sym.side<t.side&&(t=t.Sym);var e=t.next,r=t.Sym.next;e.Sym.next=r,r.Sym.next=e},n.prototype.killVertex_=function(t,e){var r=t.anEdge,i=r;do i.Org=e,i=i.Onext;while(i!==r);var o=t.prev,s=t.next;s.prev=o,o.next=s},n.prototype.killFace_=function(t,e){var r=t.anEdge,i=r;do i.Lface=e,i=i.Lnext;while(i!==r);var o=t.prev,s=t.next;s.prev=o,o.next=s},n.prototype.makeEdge=function(){var t=new Zi,e=new Zi,r=new Jo,i=this.makeEdge_(this.eHead);return this.makeVertex_(t,i,this.vHead),this.makeVertex_(e,i.Sym,this.vHead),this.makeFace_(r,i,this.fHead),i},n.prototype.splice=function(t,e){var r=!1,i=!1;if(t!==e){if(e.Org!==t.Org&&(i=!0,this.killVertex_(e.Org,t.Org)),e.Lface!==t.Lface&&(r=!0,this.killFace_(e.Lface,t.Lface)),this.splice_(e,t),!i){var o=new Zi;this.makeVertex_(o,e,t.Org),t.Org.anEdge=t}if(!r){var s=new Jo;this.makeFace_(s,e,t.Lface),t.Lface.anEdge=t}}},n.prototype.delete=function(t){var e=t.Sym,r=!1;if(t.Lface!==t.Rface&&(r=!0,this.killFace_(t.Lface,t.Rface)),t.Onext===t)this.killVertex_(t.Org,null);else if(t.Rface.anEdge=t.Oprev,t.Org.anEdge=t.Onext,this.splice_(t,t.Oprev),!r){var i=new Jo;this.makeFace_(i,t,t.Lface)}e.Onext===e?(this.killVertex_(e.Org,null),this.killFace_(e.Lface,null)):(t.Lface.anEdge=e.Oprev,e.Org.anEdge=e.Onext,this.splice_(e,e.Oprev)),this.killEdge_(t)},n.prototype.addEdgeVertex=function(t){var e=this.makeEdge_(t),r=e.Sym;this.splice_(e,t.Lnext),e.Org=t.Dst;var i=new Zi;return this.makeVertex_(i,r,e.Org),e.Lface=r.Lface=t.Lface,e},n.prototype.splitEdge=function(t){var e=this.addEdgeVertex(t),r=e.Sym;return this.splice_(t.Sym,t.Sym.Oprev),this.splice_(t.Sym,r),t.Dst=r.Org,r.Dst.anEdge=r.Sym,r.Rface=t.Rface,r.winding=t.winding,r.Sym.winding=t.Sym.winding,r.idx=t.idx,r.Sym.idx=t.Sym.idx,r},n.prototype.connect=function(t,e){var r=!1,i=this.makeEdge_(t),o=i.Sym;if(e.Lface!==t.Lface&&(r=!0,this.killFace_(e.Lface,t.Lface)),this.splice_(i,t.Lnext),this.splice_(o,e),i.Org=t.Dst,o.Org=e.Org,i.Lface=o.Lface=t.Lface,t.Lface.anEdge=o,!r){var s=new Jo;this.makeFace_(s,i,t.Lface)}return i},n.prototype.zapFace=function(t){var e=t.anEdge,r,i,o,s,a;i=e.Lnext;do r=i,i=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)),o=r.Sym,o.Onext===o?this.killVertex_(o.Org,null):(o.Org.anEdge=o.Onext,this.splice_(o,o.Oprev)),this.killEdge_(r));while(r!=e);s=t.prev,a=t.next,a.prev=s,s.next=a},n.prototype.countFaceVerts_=function(t){var e=t.anEdge,r=0;do r++,e=e.Lnext;while(e!==t.anEdge);return r},n.prototype.mergeConvexFaces=function(t){var e,r,i,o,s,a,l;for(e=this.fHead.next;e!==this.fHead;e=e.next)if(!!e.inside)for(r=e.anEdge,s=r.Org;i=r.Lnext,o=r.Sym,o&&o.Lface&&o.Lface.inside&&(a=this.countFaceVerts_(e),l=this.countFaceVerts_(o.Lface),a+l-2<=t&&ae.vertCCW(r.Lprev.Org,r.Org,o.Lnext.Lnext.Org)&&ae.vertCCW(o.Lprev.Org,o.Org,r.Lnext.Lnext.Org)&&(i=o.Lnext,this.delete(o),r=null,o=null)),!(r&&r.Lnext.Org===s);)r=i;return!0},n.prototype.check=function(){var t=this.fHead,e=this.vHead,r=this.eHead,i,o,s,a,l,c;for(o=t,o=t;(i=o.next)!==t;o=i){ue(i.prev===o),l=i.anEdge;do ue(l.Sym!==l),ue(l.Sym.Sym===l),ue(l.Lnext.Onext.Sym===l),ue(l.Onext.Sym.Lnext===l),ue(l.Lface===i),l=l.Lnext;while(l!==i.anEdge)}for(ue(i.prev===o&&i.anEdge===null),a=e,a=e;(s=a.next)!==e;a=s){ue(s.prev===a),l=s.anEdge;do ue(l.Sym!==l),ue(l.Sym.Sym===l),ue(l.Lnext.Onext.Sym===l),ue(l.Onext.Sym.Lnext===l),ue(l.Org===s),l=l.Onext;while(l!==s.anEdge)}for(ue(s.prev===a&&s.anEdge===null),c=r,c=r;(l=c.next)!==r;c=l)ue(l.Sym.next===c.Sym),ue(l.Sym!==l),ue(l.Sym.Sym===l),ue(l.Org!==null),ue(l.Dst!==null),ue(l.Lnext.Onext.Sym===l),ue(l.Onext.Sym.Lnext===l);ue(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)},n}(),fd=function(){function n(){this.handle=null}return n}(),yd=function(){function n(){this.key=null,this.node=0}return n}(),Eb=function(){function n(t,e){this.leq=e,this.max=0,this.nodes=[],this.handles=[],this.initialized=!1,this.freeList=0,this.size=0,this.max=t,this.nodes=[],this.handles=[];for(var r=0;r<t+1;r++)this.nodes[r]=new fd,this.handles[r]=new yd;this.initialized=!1,this.nodes[1].handle=1,this.handles[1].key=null}return n.prototype.floatDown_=function(t){var e=this.nodes,r=this.handles,i,o,s;for(i=e[t].handle;;){if(s=t<<1,s<this.size&&this.leq(r[e[s+1].handle].key,r[e[s].handle].key)&&++s,ue(s<=this.max),o=e[s].handle,s>this.size||this.leq(r[i].key,r[o].key)){e[t].handle=i,r[i].node=t;break}e[t].handle=o,r[o].node=t,t=s}},n.prototype.floatUp_=function(t){var e=this.nodes,r=this.handles,i,o,s;for(i=e[t].handle;;){if(s=t>>1,o=e[s].handle,s===0||this.leq(r[o].key,r[i].key)){e[t].handle=i,r[i].node=t;break}e[t].handle=o,r[o].node=t,t=s}},n.prototype.init=function(){for(var t=this.size;t>=1;--t)this.floatDown_(t);this.initialized=!0},n.prototype.min=function(){return this.handles[this.nodes[1].handle].key},n.prototype.insert=function(t){var e,r;if(e=++this.size,e*2>this.max){this.max*=2;var i,o;for(o=this.nodes.length,this.nodes.length=this.max+1,i=o;i<this.nodes.length;i++)this.nodes[i]=new fd;for(o=this.handles.length,this.handles.length=this.max+1,i=o;i<this.handles.length;i++)this.handles[i]=new yd}return this.freeList===0?r=e:(r=this.freeList,this.freeList=this.handles[r].node),this.nodes[e].handle=r,this.handles[r].node=e,this.handles[r].key=t,this.initialized&&this.floatUp_(e),r},n.prototype.extractMin=function(){var t=this.nodes,e=this.handles,r=t[1].handle,i=e[r].key;return this.size>0&&(t[1].handle=t[this.size].handle,e[t[1].handle].node=1,e[r].key=null,e[r].node=this.freeList,this.freeList=r,--this.size,this.size>0&&this.floatDown_(1)),i},n.prototype.delete=function(t){var e=this.nodes,r=this.handles,i;ue(t>=1&&t<=this.max&&r[t].key!==null),i=r[t].node,e[i].handle=e[this.size].handle,r[e[i].handle].node=i,--this.size,i<=this.size&&(i<=1||this.leq(r[e[i>>1].handle].key,r[e[i].handle].key)?this.floatDown_(i):this.floatUp_(i)),r[t].key=null,r[t].node=this.freeList,this.freeList=t},n}(),fl=function(){function n(){this.eUp=null,this.nodeUp=null,this.windingNumber=0,this.inside=!1,this.sentinel=!1,this.dirty=!1,this.fixUpperEdge=!1}return n}(),gd=function(){function n(){this.key=null,this.next=null,this.prev=null}return n}(),Gb=function(){function n(t,e){this.frame=t,this.leq=e,this.head=new gd,this.head.next=this.head,this.head.prev=this.head}return n.prototype.min=function(){return this.head.next},n.prototype.max=function(){return this.head.prev},n.prototype.insert=function(t){return this.insertBefore(this.head,t)},n.prototype.search=function(t){var e=this.head;do e=e.next;while(e.key!==null&&!this.leq(this.frame,t,e.key));return e},n.prototype.insertBefore=function(t,e){do t=t.prev;while(t.key!==null&&!this.leq(this.frame,t.key,e));var r=new gd;return r.key=e,r.next=t.next,t.next.prev=r,r.prev=t,t.next=r,r},n.prototype.delete=function(t){t.next.prev=t.prev,t.prev.next=t.next},n}(),zb=function(){function n(){}return n.regionBelow=function(t){return t.nodeUp.prev.key},n.regionAbove=function(t){return t.nodeUp.next.key},n.debugEvent=function(t){},n.addWinding=function(t,e){t.winding+=e.winding,t.Sym.winding+=e.Sym.winding},n.edgeLeq=function(t,e,r){var i=t.event,o=e.eUp,s=r.eUp;if(o.Dst===i)return s.Dst===i?ae.vertLeq(o.Org,s.Org)?ae.edgeSign(s.Dst,o.Org,s.Org)<=0:ae.edgeSign(o.Dst,s.Org,o.Org)>=0:ae.edgeSign(s.Dst,i,s.Org)<=0;if(s.Dst===i)return ae.edgeSign(o.Dst,i,o.Org)>=0;var a=ae.edgeEval(o.Dst,i,o.Org),l=ae.edgeEval(s.Dst,i,s.Org);return a>=l},n.deleteRegion=function(t,e){e.fixUpperEdge&&ue(e.eUp.winding===0),e.eUp.activeRegion=null,t.dict.delete(e.nodeUp)},n.fixUpperEdge=function(t,e,r){ue(e.fixUpperEdge),t.mesh.delete(e.eUp),e.fixUpperEdge=!1,e.eUp=r,r.activeRegion=e},n.topLeftRegion=function(t,e){var r=e.eUp.Org,i;do e=n.regionAbove(e);while(e.eUp.Org===r);if(e.fixUpperEdge){if(i=t.mesh.connect(n.regionBelow(e).eUp.Sym,e.eUp.Lnext),i===null)return null;n.fixUpperEdge(t,e,i),e=n.regionAbove(e)}return e},n.topRightRegion=function(t){var e=t.eUp.Dst;do t=n.regionAbove(t);while(t.eUp.Dst===e);return t},n.addRegionBelow=function(t,e,r){var i=new fl;return i.eUp=r,i.nodeUp=t.dict.insertBefore(e.nodeUp,i),i.fixUpperEdge=!1,i.sentinel=!1,i.dirty=!1,r.activeRegion=i,i},n.isWindingInside=function(t,e){switch(t.windingRule){case He.ODD:return(e&1)!==0;case He.NONZERO:return e!==0;case He.POSITIVE:return e>0;case He.NEGATIVE:return e<0;case He.ABS_GEQ_TWO:return e>=2||e<=-2}throw new Error("Invalid winding rulle")},n.computeWinding=function(t,e){e.windingNumber=n.regionAbove(e).windingNumber+e.eUp.winding,e.inside=n.isWindingInside(t,e.windingNumber)},n.finishRegion=function(t,e){var r=e.eUp,i=r.Lface;i.inside=e.inside,i.anEdge=r,n.deleteRegion(t,e)},n.finishLeftRegions=function(t,e,r){for(var i,o=null,s=e,a=e.eUp;s!==r;){if(s.fixUpperEdge=!1,o=n.regionBelow(s),i=o.eUp,i.Org!=a.Org){if(!o.fixUpperEdge){n.finishRegion(t,s);break}i=t.mesh.connect(a.Lprev,i.Sym),n.fixUpperEdge(t,o,i)}a.Onext!==i&&(t.mesh.splice(i.Oprev,i),t.mesh.splice(a,i)),n.finishRegion(t,s),a=o.eUp,s=o}return a},n.addRightEdges=function(t,e,r,i,o,s){var a,l,c,p,h=!0;c=r;do ue(ae.vertLeq(c.Org,c.Dst)),n.addRegionBelow(t,e,c.Sym),c=c.Onext;while(c!==i);for(o===null&&(o=n.regionBelow(e).eUp.Rprev),l=e,p=o;a=n.regionBelow(l),c=a.eUp.Sym,c.Org===p.Org;)c.Onext!==p&&(t.mesh.splice(c.Oprev,c),t.mesh.splice(p.Oprev,c)),a.windingNumber=l.windingNumber-c.winding,a.inside=n.isWindingInside(t,a.windingNumber),l.dirty=!0,!h&&n.checkForRightSplice(t,l)&&(n.addWinding(c,p),n.deleteRegion(t,l),t.mesh.delete(p)),h=!1,l=a,p=c;l.dirty=!0,ue(l.windingNumber-c.winding===a.windingNumber),s&&n.walkDirtyRegions(t,l)},n.spliceMergeVertices=function(t,e,r){t.mesh.splice(e,r)},n.vertexWeights=function(t,e,r){var i=ae.vertL1dist(e,t),o=ae.vertL1dist(r,t),s=.5*o/(i+o),a=.5*i/(i+o);t.coords[0]+=s*e.coords[0]+a*r.coords[0],t.coords[1]+=s*e.coords[1]+a*r.coords[1],t.coords[2]+=s*e.coords[2]+a*r.coords[2]},n.getIntersectData=function(t,e,r,i,o,s){e.coords[0]=e.coords[1]=e.coords[2]=0,e.idx=-1,n.vertexWeights(e,r,i),n.vertexWeights(e,o,s)},n.checkForRightSplice=function(t,e){var r=n.regionBelow(e),i=e.eUp,o=r.eUp;if(ae.vertLeq(i.Org,o.Org)){if(ae.edgeSign(o.Dst,i.Org,o.Org)>0)return!1;ae.vertEq(i.Org,o.Org)?i.Org!==o.Org&&(t.pq.delete(i.Org.pqHandle),n.spliceMergeVertices(t,o.Oprev,i)):(t.mesh.splitEdge(o.Sym),t.mesh.splice(i,o.Oprev),e.dirty=r.dirty=!0)}else{if(ae.edgeSign(i.Dst,o.Org,i.Org)<0)return!1;n.regionAbove(e).dirty=e.dirty=!0,t.mesh.splitEdge(i.Sym),t.mesh.splice(o.Oprev,i)}return!0},n.checkForLeftSplice=function(t,e){var r=n.regionBelow(e),i=e.eUp,o=r.eUp,s;if(ue(!ae.vertEq(i.Dst,o.Dst)),ae.vertLeq(i.Dst,o.Dst)){if(ae.edgeSign(i.Dst,o.Dst,i.Org)<0)return!1;n.regionAbove(e).dirty=e.dirty=!0,s=t.mesh.splitEdge(i),t.mesh.splice(o.Sym,s),s.Lface.inside=e.inside}else{if(ae.edgeSign(o.Dst,i.Dst,o.Org)>0)return!1;e.dirty=r.dirty=!0,s=t.mesh.splitEdge(o),t.mesh.splice(i.Lnext,o.Sym),s.Rface.inside=e.inside}return!0},n.checkForIntersect=function(t,e){var r=n.regionBelow(e),i=e.eUp,o=r.eUp,s=i.Org,a=o.Org,l=i.Dst,c=o.Dst,p,h,d=new Zi,m,f;if(ue(!ae.vertEq(c,l)),ue(ae.edgeSign(l,t.event,s)<=0),ue(ae.edgeSign(c,t.event,a)>=0),ue(s!==t.event&&a!==t.event),ue(!e.fixUpperEdge&&!r.fixUpperEdge),s===a||(p=Math.min(s.t,l.t),h=Math.max(a.t,c.t),p>h))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 n.debugEvent(t),ae.intersect(l,s,c,a,d),ue(Math.min(s.t,l.t)<=d.t),ue(d.t<=Math.max(a.t,c.t)),ue(Math.min(c.s,l.s)<=d.s),ue(d.s<=Math.max(a.s,s.s)),ae.vertLeq(d,t.event)&&(d.s=t.event.s,d.t=t.event.t),m=ae.vertLeq(s,a)?s:a,ae.vertLeq(m,d)&&(d.s=m.s,d.t=m.t),ae.vertEq(d,s)||ae.vertEq(d,a)?(n.checkForRightSplice(t,e),!1):!ae.vertEq(l,t.event)&&ae.edgeSign(l,t.event,d)>=0||!ae.vertEq(c,t.event)&&ae.edgeSign(c,t.event,d)<=0?c===t.event?(t.mesh.splitEdge(i.Sym),t.mesh.splice(o.Sym,i),e=n.topLeftRegion(t,e),i=n.regionBelow(e).eUp,n.finishLeftRegions(t,n.regionBelow(e),r),n.addRightEdges(t,e,i.Oprev,i,i,!0),!0):l===t.event?(t.mesh.splitEdge(o.Sym),t.mesh.splice(i.Lnext,o.Oprev),r=e,e=n.topRightRegion(e),f=n.regionBelow(e).eUp.Rprev,r.eUp=o.Oprev,o=n.finishLeftRegions(t,r,null),n.addRightEdges(t,e,o.Onext,i.Rprev,f,!0),!0):(ae.edgeSign(l,t.event,d)>=0&&(n.regionAbove(e).dirty=e.dirty=!0,t.mesh.splitEdge(i.Sym),i.Org.s=t.event.s,i.Org.t=t.event.t),ae.edgeSign(c,t.event,d)<=0&&(e.dirty=r.dirty=!0,t.mesh.splitEdge(o.Sym),o.Org.s=t.event.s,o.Org.t=t.event.t),!1):(t.mesh.splitEdge(i.Sym),t.mesh.splitEdge(o.Sym),t.mesh.splice(o.Oprev,i),i.Org.s=d.s,i.Org.t=d.t,i.Org.pqHandle=t.pq.insert(i.Org),n.getIntersectData(t,i.Org,s,l,a,c),n.regionAbove(e).dirty=e.dirty=r.dirty=!0,!1)},n.walkDirtyRegions=function(t,e){for(var r=n.regionBelow(e),i,o;;){for(;r.dirty;)e=r,r=n.regionBelow(r);if(!e.dirty&&(r=e,e=n.regionAbove(e),e===null||!e.dirty))return;if(e.dirty=!1,i=e.eUp,o=r.eUp,i.Dst!==o.Dst&&n.checkForLeftSplice(t,e)&&(r.fixUpperEdge?(n.deleteRegion(t,r),t.mesh.delete(o),r=n.regionBelow(e),o=r.eUp):e.fixUpperEdge&&(n.deleteRegion(t,e),t.mesh.delete(i),e=n.regionAbove(r),i=e.eUp)),i.Org!==o.Org)if(i.Dst!==o.Dst&&!e.fixUpperEdge&&!r.fixUpperEdge&&(i.Dst===t.event||o.Dst===t.event)){if(n.checkForIntersect(t,e))return}else n.checkForRightSplice(t,e);i.Org===o.Org&&i.Dst===o.Dst&&(n.addWinding(o,i),n.deleteRegion(t,e),t.mesh.delete(i),e=n.regionAbove(r))}},n.connectRightVertex=function(t,e,r){var i,o=r.Onext,s=n.regionBelow(e),a=e.eUp,l=s.eUp,c=!1;if(a.Dst!==l.Dst&&n.checkForIntersect(t,e),ae.vertEq(a.Org,t.event)&&(t.mesh.splice(o.Oprev,a),e=n.topLeftRegion(t,e),o=n.regionBelow(e).eUp,n.finishLeftRegions(t,n.regionBelow(e),s),c=!0),ae.vertEq(l.Org,t.event)&&(t.mesh.splice(r,l.Oprev),r=n.finishLeftRegions(t,s,null),c=!0),c){n.addRightEdges(t,e,r.Onext,o,o,!0);return}ae.vertLeq(l.Org,a.Org)?i=l.Oprev:i=a,i=t.mesh.connect(r.Lprev,i),n.addRightEdges(t,e,i,i.Onext,i.Onext,!1),i.Sym.activeRegion.fixUpperEdge=!0,n.walkDirtyRegions(t,e)},n.connectLeftDegenerate=function(t,e,r){var i,o,s,a,l;if(i=e.eUp,ae.vertEq(i.Org,r)){ue(!1),n.spliceMergeVertices(t,i,r.anEdge);return}if(!ae.vertEq(i.Dst,r)){t.mesh.splitEdge(i.Sym),e.fixUpperEdge&&(t.mesh.delete(i.Onext),e.fixUpperEdge=!1),t.mesh.splice(r.anEdge,i),n.sweepEvent(t,r);return}ue(!1),e=n.topRightRegion(e),l=n.regionBelow(e),s=l.eUp.Sym,o=a=s.Onext,l.fixUpperEdge&&(ue(o!==s),n.deleteRegion(t,l),t.mesh.delete(s),s=o.Oprev),t.mesh.splice(r.anEdge,s),ae.edgeGoesLeft(o)||(o=null),n.addRightEdges(t,e,s.Onext,a,o,!0)},n.connectLeftVertex=function(t,e){var r,i,o,s,a,l,c=new fl;if(c.eUp=e.anEdge.Sym,r=t.dict.search(c).key,i=n.regionBelow(r),!!i){if(s=r.eUp,a=i.eUp,ae.edgeSign(s.Dst,e,s.Org)===0){n.connectLeftDegenerate(t,r,e);return}if(o=ae.vertLeq(a.Dst,s.Dst)?r:i,r.inside||o.fixUpperEdge){if(o===r)l=t.mesh.connect(e.anEdge.Sym,s.Lnext);else{var p=t.mesh.connect(a.Dnext,e.anEdge);l=p.Sym}o.fixUpperEdge?n.fixUpperEdge(t,o,l):n.computeWinding(t,n.addRegionBelow(t,r,l)),n.sweepEvent(t,e)}else n.addRightEdges(t,r,e.anEdge,e.anEdge,null,!0)}},n.sweepEvent=function(t,e){t.event=e,n.debugEvent(t);for(var r=e.anEdge;r.activeRegion===null;)if(r=r.Onext,r===e.anEdge){n.connectLeftVertex(t,e);return}var i=n.topLeftRegion(t,r.activeRegion);ue(i!==null);var o=n.regionBelow(i),s=o.eUp,a=n.finishLeftRegions(t,o,null);a.Onext===s?n.connectRightVertex(t,i,a):n.addRightEdges(t,i,a.Onext,s,s,!0)},n.addSentinel=function(t,e,r,i){var o=new fl,s=t.mesh.makeEdge();s.Org.s=r,s.Org.t=i,s.Dst.s=e,s.Dst.t=i,t.event=s.Dst,o.eUp=s,o.windingNumber=0,o.inside=!1,o.fixUpperEdge=!1,o.sentinel=!0,o.dirty=!1,o.nodeUp=t.dict.insert(o)},n.initEdgeDict=function(t){t.dict=new Gb(t,n.edgeLeq);var e=t.bmax[0]-t.bmin[0],r=t.bmax[1]-t.bmin[1],i=t.bmin[0]-e,o=t.bmax[0]+e,s=t.bmin[1]-r,a=t.bmax[1]+r;n.addSentinel(t,i,o,s),n.addSentinel(t,i,o,a)},n.doneEdgeDict=function(t){for(var e,r=0;(e=t.dict.min().key)!==null;)e.sentinel||(ue(e.fixUpperEdge),ue(++r===1)),ue(e.windingNumber===0),n.deleteRegion(t,e)},n.removeDegenerateEdges=function(t){var e,r,i,o=t.mesh.eHead;for(e=o.next;e!==o;e=r)r=e.next,i=e.Lnext,ae.vertEq(e.Org,e.Dst)&&e.Lnext.Lnext!==e&&(n.spliceMergeVertices(t,i,e),t.mesh.delete(e),e=i,i=e.Lnext),i.Lnext===e&&(i!==e&&((i===r||i===r.Sym)&&(r=r.next),t.mesh.delete(i)),(e===r||e===r.Sym)&&(r=r.next),t.mesh.delete(e))},n.initPriorityQ=function(t){var e,r,i,o=0;for(i=t.mesh.vHead,r=i.next;r!==i;r=r.next)o++;for(o+=8,e=t.pq=new Eb(o,ae.vertLeq),i=t.mesh.vHead,r=i.next;r!==i;r=r.next)r.pqHandle=e.insert(r);return r!==i?!1:(e.init(),!0)},n.donePriorityQ=function(t){t.pq=null},n.removeDegenerateFaces=function(t,e){var r,i,o;for(r=e.fHead.next;r!==e.fHead;r=i)i=r.next,o=r.anEdge,ue(o.Lnext!==o),o.Lnext.Lnext===o&&(n.addWinding(o.Onext,o),t.mesh.delete(o));return!0},n.computeInterior=function(t,e){e===void 0&&(e=!0);var r,i;if(n.removeDegenerateEdges(t),!n.initPriorityQ(t))return!1;for(n.initEdgeDict(t);(r=t.pq.extractMin())!==null;){for(;i=t.pq.min(),!(i===null||!ae.vertEq(i,r));)i=t.pq.extractMin(),n.spliceMergeVertices(t,r.anEdge,i.anEdge);n.sweepEvent(t,r)}return t.event=t.dict.min().key.eUp.Org,n.debugEvent(t),n.doneEdgeDict(t),n.donePriorityQ(t),n.removeDegenerateFaces(t,t.mesh)?(e&&t.mesh.check(),!0):!1},n}(),Rb=function(){function n(){this.mesh=new md,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=He.ODD,this.dict=null,this.pq=null,this.event=null,this.vertexIndexCounter=0,this.vertices=[],this.vertexIndices=[],this.vertexCount=0,this.elements=[],this.elementCount=0}return n.prototype.dot_=function(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]},n.prototype.normalize_=function(t){var e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2];if(!e)throw"Zero-size vector!";e=Math.sqrt(e),t[0]/=e,t[1]/=e,t[2]/=e},n.prototype.longAxis_=function(t){var e=0;return Math.abs(t[1])>Math.abs(t[0])&&(e=1),Math.abs(t[2])>Math.abs(t[e])&&(e=2),e},n.prototype.computeNormal_=function(t){var e,r,i,o,s,a,l=[0,0,0],c=[0,0,0],p=[0,0,0],h=[0,0,0],d=[0,0,0],m=[null,null,null],f=[null,null,null],T=this.mesh.vHead;e=T.next;for(var w=0;w<3;++w)o=e.coords[w],c[w]=o,f[w]=e,l[w]=o,m[w]=e;for(e=T.next;e!==T;e=e.next)for(var y=0;y<3;++y)o=e.coords[y],o<c[y]&&(c[y]=o,f[y]=e),o>l[y]&&(l[y]=o,m[y]=e);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]){t[0]=0,t[1]=0,t[2]=1;return}for(a=0,r=f[L],i=m[L],p[0]=r.coords[0]-i.coords[0],p[1]=r.coords[1]-i.coords[1],p[2]=r.coords[2]-i.coords[2],e=T.next;e!==T;e=e.next)h[0]=e.coords[0]-i.coords[0],h[1]=e.coords[1]-i.coords[1],h[2]=e.coords[2]-i.coords[2],d[0]=p[1]*h[2]-p[2]*h[1],d[1]=p[2]*h[0]-p[0]*h[2],d[2]=p[0]*h[1]-p[1]*h[0],s=d[0]*d[0]+d[1]*d[1]+d[2]*d[2],s>a&&(a=s,t[0]=d[0],t[1]=d[1],t[2]=d[2]);a<=0&&(t[0]=t[1]=t[2]=0,t[this.longAxis_(p)]=1)},n.prototype.checkOrientation_=function(){for(var t=this.mesh.fHead,e,r=this.mesh.vHead,i,o=0,s=t.next;s!==t;s=s.next)if(i=s.anEdge,!(i.winding<=0))do o+=(i.Org.s-i.Dst.s)*(i.Org.t+i.Dst.t),i=i.Lnext;while(i!==s.anEdge);if(o<0){for(e=r.next;e!==r;e=e.next)e.t=-e.t;this.tUnit[0]=-this.tUnit[0],this.tUnit[1]=-this.tUnit[1],this.tUnit[2]=-this.tUnit[2]}},n.prototype.projectPolygon_=function(){var t=this.mesh.vHead,e=[0,0,0],r,i,o=!1;e[0]=this.normal[0],e[1]=this.normal[1],e[2]=this.normal[2],!e[0]&&!e[1]&&!e[2]&&(this.computeNormal_(e),o=!0),r=this.sUnit,i=this.tUnit;var s=this.longAxis_(e);r[s]=0,r[(s+1)%3]=1,r[(s+2)%3]=0,i[s]=0,i[(s+1)%3]=0,i[(s+2)%3]=e[s]>0?1:-1;for(var a=t.next;a!==t;a=a.next)a.s=this.dot_(a.coords,r),a.t=this.dot_(a.coords,i);o&&this.checkOrientation_();for(var l=!0,c=t.next;c!==t;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))},n.prototype.addWinding_=function(t,e){t.winding+=e.winding,t.Sym.winding+=e.Sym.winding},n.prototype.tessellateMonoRegion_=function(t,e){var r,i;if(r=e.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);i=r.Lprev;for(var o=void 0;r.Lnext!==i;)if(ae.vertLeq(r.Dst,i.Org)){for(;i.Lnext!==r&&(ae.edgeGoesLeft(i.Lnext)||ae.edgeSign(i.Org,i.Dst,i.Lnext.Dst)<=0);)o=t.connect(i.Lnext,i),i=o.Sym;i=i.Lprev}else{for(;i.Lnext!==r&&(ae.edgeGoesRight(r.Lprev)||ae.edgeSign(r.Dst,r.Org,r.Lprev.Org)>=0);)o=t.connect(r,r.Lprev),r=o.Sym;r=r.Lnext}if(i.Lnext===r)throw"Mono region invalid";for(;i.Lnext.Lnext!==r;)o=t.connect(i.Lnext,i),i=o.Sym;return!0},n.prototype.tessellateInterior_=function(t){for(var e,r=t.fHead.next;r!==t.fHead;r=e)if(e=r.next,r.inside&&!this.tessellateMonoRegion_(t,r))return!1;return!0},n.prototype.discardExterior_=function(t){for(var e,r=t.fHead.next;r!==t.fHead;r=e)e=r.next,r.inside||t.zapFace(r)},n.prototype.setWindingNumber_=function(t,e,r){for(var i,o=t.eHead.next;o!==t.eHead;o=i)i=o.next,o.Rface.inside!==o.Lface.inside?o.winding=o.Lface.inside?e:-e:r?t.delete(o):o.winding=0},n.prototype.getNeighbourFace_=function(t){return!t.Rface||!t.Rface.inside?-1:t.Rface.n},n.prototype.outputPolymesh_=function(t,e,r,i){var o,s=0,a=0,l;r>3&&t.mergeConvexFaces(r);for(var c=t.vHead.next;c!==t.vHead;c=c.next)c.n=-1;for(var p=t.fHead.next;p!==t.fHead;p=p.next)if(p.n=-1,!!p.inside){o=p.anEdge,l=0;do{var c=o.Org;c.n===-1&&(c.n=a,a++),l++,o=o.Lnext}while(o!==p.anEdge);if(l>r)throw"Face vertex greater that support polygon";p.n=s,++s}this.elementCount=s,e===rt.CONNECTED_POLYGONS&&(s*=2),this.elements=[],this.elements.length=s*r,this.vertexCount=a,this.vertices=[],this.vertices.length=a*i,this.vertexIndices=[],this.vertexIndices.length=a;for(var c=t.vHead.next;c!==t.vHead;c=c.next)if(c.n!==-1){var h=c.n*i;this.vertices[h+0]=c.coords[0],this.vertices[h+1]=c.coords[1],i>2&&(this.vertices[h+2]=c.coords[2]),this.vertexIndices[c.n]=c.idx}for(var d=0,p=t.fHead.next;p!==t.fHead;p=p.next)if(!!p.inside){o=p.anEdge,l=0;do{var c=o.Org;this.elements[d++]=c.n,l++,o=o.Lnext}while(o!==p.anEdge);for(var m=l;m<r;++m)this.elements[d++]=-1;if(e===rt.CONNECTED_POLYGONS){o=p.anEdge;do this.elements[d++]=this.getNeighbourFace_(o),o=o.Lnext;while(o!==p.anEdge);for(var f=l;f<r;++f)this.elements[d++]=-1}}},n.prototype.outputContours_=function(t,e){var r,i,o=0,s=0;this.vertexCount=0,this.elementCount=0;for(var a=t.fHead.next;a!==t.fHead;a=a.next)if(!!a.inside){i=r=a.anEdge;do this.vertexCount++,r=r.Lnext;while(r!==i);this.elementCount++}this.elements=[],this.elements.length=this.elementCount*2,this.vertices=[],this.vertices.length=this.vertexCount*e,this.vertexIndices=[],this.vertexIndices.length=this.vertexCount;var l=0,c=0,p=0;o=0;for(var a=t.fHead.next;a!==t.fHead;a=a.next)if(!!a.inside){s=0,i=r=a.anEdge;do this.vertices[l++]=r.Org.coords[0],this.vertices[l++]=r.Org.coords[1],e>2&&(this.vertices[l++]=r.Org.coords[2]),this.vertexIndices[c++]=this.vertexIdCallback?this.vertexIdCallback(r):r.Org.idx,s++,r=r.Lnext;while(r!==i);this.elements[p++]=o,this.elements[p++]=s,o+=s}},n.prototype.addContour=function(t,e){this.mesh===null&&(this.mesh=new md),t<2&&(t=2),t>3&&(t=3);for(var r=null,i=0;i<e.length;i+=t)r===null?(r=this.mesh.makeEdge(),this.mesh.splice(r,r.Sym)):(this.mesh.splitEdge(r),r=r.Lnext),r.Org.coords[0]=e[i+0],r.Org.coords[1]=e[i+1],t>2?r.Org.coords[2]=e[i+2]:r.Org.coords[2]=0,r.Org.idx=this.vertexIndexCounter++,this.edgeCreateCallback&&this.edgeCreateCallback(r),r.winding=1,r.Sym.winding=-1},n.prototype.tesselate=function(t,e,r,i,o,s){if(t===void 0&&(t=He.ODD),e===void 0&&(e=rt.POLYGONS),s===void 0&&(s=!0),this.vertices=[],this.elements=[],this.vertexIndices=[],this.vertexIndexCounter=0,o&&(this.normal[0]=o[0],this.normal[1]=o[1],this.normal[2]=o[2]),this.windingRule=t,i<2&&(i=2),i>3&&(i=3),!this.mesh)return!1;this.projectPolygon_(),zb.computeInterior(this,s);var a=this.mesh;return e===rt.BOUNDARY_CONTOURS?this.setWindingNumber_(a,1,!0):this.tessellateInterior_(a),s&&a.check(),e===rt.BOUNDARY_CONTOURS?this.outputContours_(a,i):this.outputPolymesh_(a,e,r,i),!0},n}();function di(n){var t=n.windingRule,e=t===void 0?He.ODD:t,r=n.elementType,i=r===void 0?rt.POLYGONS:r,o=n.polySize,s=o===void 0?3:o,a=n.vertexSize,l=a===void 0?2:a,c=n.normal,p=c===void 0?[0,0,1]:c,h=n.contours,d=h===void 0?[]:h,m=n.strict,f=m===void 0?!0:m,T=n.debug,w=T===void 0?!1:T;if(!d&&f)throw new Error("Contours can't be empty");if(!!d){var y=new Rb;n.edgeCreateCallback&&(y.edgeCreateCallback=n.edgeCreateCallback),n.vertexIdCallback&&(y.vertexIdCallback=n.vertexIdCallback);for(var L=0;L<d.length;L++)y.addContour(l||2,d[L]);return y.tesselate(e,i,s,l,p,f),{vertices:y.vertices,vertexIndices:y.vertexIndices,vertexCount:y.vertexCount,elements:y.elements,elementCount:y.elementCount,mesh:w?y.mesh:void 0}}}var tD=He.ODD,rD=He.NONZERO,iD=He.POSITIVE,oD=He.NEGATIVE,nD=He.ABS_GEQ_TWO,sD=rt.POLYGONS,aD=rt.CONNECTED_POLYGONS,lD=rt.BOUNDARY_CONTOURS;var Qi=class extends Vb{constructor(e,r=12,i={}){var f,T,w;super();this.type="ShapeGeometry";this.windingRule=He.ODD;this.elementType=rt.POLYGONS;this.polySize=3;this.vertexSize=2;this.strict=!0;this._shape=e,this._curveSegments=r,this._triangulationOptions=Object.assign({windingRule:He.ODD,elementType:rt.POLYGONS,polySize:3,vertexSize:2,strict:!0},i);let o=this._shape.extractShapePointsToFlatArray([],this._curveSegments),s=this._shape.shapeHoles.map(y=>y.extractShapePointsToFlatArray([],this._curveSegments)),a,l=!0,c=!0,p,h;for(let y=0,L=o.length/2;y<L;y++){let A=y*2,I=o[A+0],b=o[A+1];if(p!==void 0&&I!==p&&(l=!1),h!==void 0&&b!==h&&(c=!1),p=I,h=b,!l&&!c)break}!l&&!c&&(a=di({contours:[o,...s],windingRule:this._triangulationOptions.windingRule,elementType:this._triangulationOptions.elementType,polySize:this._triangulationOptions.polySize,vertexSize:this._triangulationOptions.vertexSize,strict:this._triangulationOptions.strict}));let d=(f=a==null?void 0:a.vertexCount)!=null?f:1,m=(T=a==null?void 0:a.elementCount)!=null?T:1;if(this._positionAttribute=new Vs(new Float32Array(d*3),3),this._normalAttribute=new Vs(new Float32Array(d*3),3),this._uvAttribute=new Vs(new Float32Array(d*2),2),this._indexAttribute=new Vs(new Uint32Array(m*3),1),a){let y=1/0,L=-1/0,A=1/0,I=-1/0;for(let x=0,u=d;x<u;x++){let M=x*2,g=a.vertices[M+0],N=a.vertices[M+1];g<y&&(y=g),g>L&&(L=g),N<A&&(A=N),N>I&&(I=N)}let b=L-y,V=I-A;for(let x=0,u=d;x<u;x++){let M=x*2,g=a.vertices[M+0],N=a.vertices[M+1],v=(g-y)/b,C=(N-A)/V;this._positionAttribute.setXYZ(x,g,N,0),this._normalAttribute.setXYZ(x,0,0,1),this._uvAttribute.setXY(x,v,C)}for(let x=0,u=m;x<u;x++){let M=x*3,g=a.elements[M+0],N=a.elements[M+1],v=a.elements[M+2];this._indexAttribute.setX(M+0,g),this._indexAttribute.setX(M+1,N),this._indexAttribute.setX(M+2,v)}}this.setAttribute("position",this._positionAttribute),this.setAttribute("normal",this._normalAttribute),this.setAttribute("uv",this._uvAttribute),this.setIndex(this._indexAttribute),this.setDrawRange(0,((w=a==null?void 0:a.elementCount)!=null?w:1)*3)}clone(){let e=new Qi(this._shape,this._curveSegments);return e.userData=_o(this.userData),e}};import{BufferAttribute as js,BufferGeometry as Fb}from"three";var Fs=class{constructor(t=256,e=!1){this.capacity=t,this.size=0,this.debug=e,this.debug&&console.log(`allocating with cap ${t}`);let r=t*Fs.eSize;this.buffer=new ArrayBuffer(r);let i=Float32Array.BYTES_PER_ELEMENT,o=0;this.positions=new Float32Array(this.buffer,o*i,3*t),o+=3*t,this.normals=new Float32Array(this.buffer,o*i,3*t),o+=3*t,this.uvs=new Float32Array(this.buffer,o*i,2*t)}realloc(t,e=!1){if(t<this.size)throw Error("cannot shrink buffer");if(t<=this.capacity&&!e)return;this.debug&&console.log(`resizing from ${this.capacity} \u2192 ${t}`);let r=t*Fs.eSize,i=new ArrayBuffer(r),o=Float32Array.BYTES_PER_ELEMENT,s=0,a=new Float32Array(i,s*o,3*t);s+=3*t;let l=new Float32Array(i,s*o,3*t);s+=3*t;let c=new Float32Array(i,s*o,2*t);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=i,this.positions=a,this.normals=l,this.uvs=c,this.capacity=t}get(t=1){let e=this.size+t;if(e>this.capacity){let i=this.capacity;for(;e>i;)i*=2;this.realloc(i)}let r=this.size;return this.size=e,r}reserve(t){let e=this.size+t;e>this.capacity&&this.realloc(e)}shrink(){this.debug&&console.log(`shrinking ${this.capacity} \u2192 ${this.size}`),this.realloc(this.size,!0)}},Ko=Fs;Ko.eSize=(3+3+2)*Float32Array.BYTES_PER_ELEMENT;var yl=(n,t)=>([e,r])=>(r<e&&(r+=t),(n>=e?n:n+t)<=r),eo=class extends Fb{constructor(e,r,i=0,o=12,s=3){super();this.type="ShapeGeometry";this.vertexCache={};this._shape=e,this._depth=r,this._bevel=i,this._curveSegments=o,this._bevelSegmentsInput=s,i<=0?(this._bevelSize=0,this._bevelSegments=0):(this._bevelSize=Math.min(i,r/2-1e-12),this._bevelSegments=Math.floor(s));let a=this._shape.extractShapePointsToFlatArray([],o),l=this._shape.shapeHoles.map(x=>{let u=x.extractShapePointsToFlatArray([],o),M=[];for(let g=u.length-1;g>=1;g-=2){let N=u[g-1],v=u[g-0];M.push(N,v)}return M}),c=di({windingRule:He.ODD,elementType:rt.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[a]}),p=di({windingRule:He.ODD,elementType:rt.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...l]});if(!c)throw new Error("error generating geometry");let h=c.elementCount;if(p){c.elementCount+=p.elementCount;for(let x=0;x<p.elements.length;x++){let u=p.elements[x],M=x%2===0?c.vertexCount:0;c.elements.push(u+M)}for(let x=0;x<p.vertexIndices.length;x++){let u=p.vertexIndices[x],M=c.vertexCount;c.vertexIndices.push(u+M)}for(let x=0;x<p.vertices.length;x++){let u=p.vertices[x];c.vertices.push(u)}}let d=1/0,m=-1/0,f=1/0,T=-1/0;for(let x=0,u=c.vertexCount;x<u;x++){let M=x*2,g=c.vertices[M+0],N=c.vertices[M+1];g<d&&(d=g),g>m&&(m=g),N<f&&(f=N),N>T&&(T=N)}this._minX=d,this._minY=f,this._width=m-d,this._height=T-f;let w=c.vertexCount*2*(2+this._bevelSegments);this._buffer=new Ko(w);let y=[],L=[];for(let x=c.elementCount-1;x>=0;x--){let u=x>=h,M=x*2,g=c.elements[M+0],N=c.elements[M+1],v=g+N,C={start:g,count:N,normals:[],continuous:[],concave:[]},$=g,H=v-1,ie=g+1,pe=this._shape.roundedCurves.length;do{let G=$-g,_=c.vertices[H*2+0],z=c.vertices[H*2+1],D=c.vertices[$*2+0],R=c.vertices[$*2+1],K=c.vertices[ie*2+0],Z=c.vertices[ie*2+1],U=D-_,j=R-z,B=Math.sqrt(U*U+j*j);U/=B,j/=B;let k=D-K,ne=R-Z,q=Math.sqrt(k*k+ne*ne);k/=q,ne/=q,C.normals[G*2+0]=-ne,C.normals[G*2+1]=k,C.concave[G]=U*ne-j*k>0;let J=c.vertexIndices[$];if(Array.isArray(J))C.continuous[G]=!1;else{let[Y,X]=this._shape.getCurveIndexFromVertexId(J-1,!0);if(X>0&&X<1)C.continuous[G]=!0;else{let Q=X===1?Y+1:Y-1;Q=(Q+pe)%pe;let se=X===1?0:1,oe=this._shape.roundedCurves[Y].getTangent(X),he=this._shape.roundedCurves[Q].getTangent(se);C.continuous[G]=oe.dot(he)>.95}}u&&(C.normals[G*2+0]*=-1,C.normals[G*2+1]*=-1),[H,$,ie]=[$,ie,ie+1],ie>=v&&(ie-=N)}while(ie!==g+1);let ce=[];ce.push({bevelI:0,angle:0,size:0,boundary:{vertices:c.vertices.slice(g*2,v*2),vertexCount:N,vertexIndices:new Array(N).fill(!0).map((G,_)=>[_,_]),elements:[0,N],elementCount:1,mesh:null},reverseMap:[],insetPoints:c.vertices.slice(g*2,v*2)});for(let G=1;G<=this._bevelSegments;G++){let _=G/this._bevelSegments*Math.PI/2,z=(1-Math.cos(_))*this._bevelSize,D=[],R=[],K=[],Z=[],U=0;for(let B=0;B<N;B++){let k=B*2,ne=(B-1+N)%N*2,q=c.vertices[C.start*2+k+0],J=c.vertices[C.start*2+k+1],Y=-C.normals[ne+0]*z,X=-C.normals[ne+1]*z,Q=-C.normals[k+0]*z,se=-C.normals[k+1]*z;if(C.concave[B]||!C.concave[B]&&u){let oe=Math.atan2(X,Y),he=Math.atan2(se,Q);he>oe&&(he-=Math.PI*2);let Ee=he-oe;if(C.continuous[B]||u){let xe=oe+Ee/2,We=Math.cos(xe)*z,Ce=Math.sin(xe)*z;D[2*U+0]=q+We*(u?-1:1),D[2*U+1]=J+Ce*(u?-1:1),Z[U]=B,U++}else{let xe=Math.max(1,Math.floor(o/4*Math.abs(Ee)/Math.PI));for(let We=0;We<=xe;We++){let Ce=oe+Ee*(We/xe),ct=Math.cos(Ce)*z,wt=Math.sin(Ce)*z;D[2*U+0]=q+ct,D[2*U+1]=J+wt,Z[U]=B,U++}}}else D[2*U+0]=q+Y,D[2*U+1]=J+X,Z[U]=B,R[B]=U,U++,D[2*U+0]=q,D[2*U+1]=J,Z[U]=B,U++,D[2*U+0]=q+Q,D[2*U+1]=J+se,Z[U]=B,K[B]=U,U++}let j=di({windingRule:He.POSITIVE,elementType:rt.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[D],edgeCreateCallback:B=>{let ne=B.Org.idx,q=Z[ne],J=Z[(ne+1)%Z.length];B.idx=[q,J],B.Sym.idx=[J,q]},vertexIdCallback:B=>{let k=B.Lprev.idx;return[k?k[1]:0,B.idx[0]]}});if(!j)throw console.log("Error"),new Error(`error generating bevel geometry for ${G}'th loop`);if(!j.vertexCount)break;for(let B=0;B<j.vertexIndices.length;B++){let[k,ne]=j.vertexIndices[B];if(k===ne)continue;let q=ne;ne<k&&(q+=N);for(let J=k;J<q;J++){let Y=J%N,X=(J+1)%N;if(!C.continuous[Y]||!C.continuous[X]){j.vertexIndices[B]=[k,Y],j.vertexIndices.splice(B+1,0,[X,ne]),j.vertices.splice((B+1)*2,0,j.vertices[B*2],j.vertices[B*2+1]);break}}}ce.push({bevelI:G,angle:_,size:z,boundary:j,reverseMap:Z,insetPoints:D})}let be=(G,_,z)=>{let D=0,R=G.boundary.vertexIndices.length;for(;D<R&&z(G.boundary.vertexIndices[_]);)_=(_+1)%R,D++;return D},F=y.length;for(let G=1;G<ce.length;G++){let _=ce[G-1],z=ce[G],D=_.boundary.vertexIndices.length,R=z.boundary.vertexIndices.length;if(!D||!R)break;let K=C.concave.length,Z=0,U=yl(Z,N);for(;!_.boundary.vertexIndices.filter(U).length||!z.boundary.vertexIndices.filter(U).length;)Z++,U=yl(Z,N);let j=_.boundary.vertexIndices.findIndex(U),B=z.boundary.vertexIndices.findIndex(U);do j=(j+1)%D;while(U(_.boundary.vertexIndices[j]));do B=(B+1)%R;while(U(z.boundary.vertexIndices[B]));Z=(Z+1)%N;let k=Z,ne=this.buildBevelVert(C,_,(j-1+D)%D),q=this.buildBevelVert(C,z,(B-1+R)%R),J=ne,Y=q,X,Q,se=!1;do{U=yl(Z,N);let oe=be(_,j,U),he=be(z,B,U),Ee=se;if(se=!1,oe&&!he){for(let xe=0;xe<oe;xe++)X=this.buildBevelVert(C,_,(j+xe)%D,xe/(oe-1)),y.push(J.topN,X.topP,Y.topN),y.push(X.bottomP,J.bottomN,Y.bottomN),J=X;se=!0}else if(!oe&&he)for(let xe=0;xe<he;xe++)Q=this.buildBevelVert(C,z,(B+xe)%R,xe/(he-1)),y.push(Y.topN,J.topP,Q.topP),y.push(J.bottomP,Y.bottomN,Q.bottomP),Y=Q;else if(oe&&he)if(X=this.buildBevelVert(C,_,j,0),Q=this.buildBevelVert(C,z,B,0),Ee?(y.push(J.topN,Q.topP,Y.topN),y.push(J.topN,X.topP,Q.topP),y.push(Q.bottomP,J.bottomN,Y.bottomN),y.push(X.bottomP,J.bottomN,Q.bottomP)):(y.push(J.topN,X.topP,Y.topN),y.push(Y.topN,X.topP,Q.topP),y.push(X.bottomP,J.bottomN,Y.bottomN),y.push(X.bottomP,Y.bottomN,Q.bottomP)),J=X,Y=Q,oe===he)for(let xe=1;xe<oe;xe++)X=this.buildBevelVert(C,_,(j+xe)%D,xe/(oe-1)),Q=this.buildBevelVert(C,z,(B+xe)%R,xe/(he-1)),y.push(J.topN,X.topP,Y.topN),y.push(Y.topN,X.topP,Q.topP),y.push(X.bottomP,J.bottomN,Y.bottomN),y.push(X.bottomP,Y.bottomN,Q.bottomP),J=X,Y=Q;else if(oe>he){let xe=oe/he,We=0;for(let Ce=1;Ce<oe;Ce++)X=this.buildBevelVert(C,_,(j+Ce)%D,Ce/(oe-1)),y.push(J.topN,X.topP,Y.topN),y.push(X.bottomP,J.bottomN,Y.bottomN),J=X,Ce>(We+1)*xe&&(We++,Q=this.buildBevelVert(C,z,(B+We)%R,We/(he-1)),y.push(Y.topN,X.topP,Q.topP),y.push(X.bottomP,Y.bottomN,Q.bottomP),Y=Q)}else{let xe=he/oe,We=0;for(let Ce=1;Ce<he;Ce++)Q=this.buildBevelVert(C,z,(B+Ce)%R,Ce/(he-1)),y.push(Y.topN,X.topP,Q.topP),y.push(X.bottomP,Y.bottomN,Q.bottomP),Y=Q,Ce>(We+1)*xe&&(We++,X=this.buildBevelVert(C,_,(j+We)%D,We/(oe-1)),y.push(J.topN,X.topP,Y.topN),y.push(X.bottomP,J.bottomN,Y.bottomN),J=X)}j=(j+oe)%D,B=(B+he)%R,Z=(Z+1)%K}while(Z!==k)}{let G=ce[0];for(let _=0,z=G.boundary.vertexCount;_<z;_++){let D=this.buildBevelVert(C,G,_),R=this.buildBevelVert(C,G,(_+1)%z);y.push(R.topP,D.topN,D.bottomN),y.push(R.topP,D.bottomN,R.bottomP)}}if(u){let G=[];for(let _=y.length-1;_>=F+2;_-=3){let z=y[_-2],D=y[_-1],R=y[_-0];G.push(R,D,z)}y.splice(F,y.length-F,...G)}if(u){let G=[];for(let _=ce[ce.length-1].boundary.vertices.length-1;_>=1;_-=2){let z=ce[ce.length-1].boundary.vertices[_-1],D=ce[ce.length-1].boundary.vertices[_-0];G.push(z,D)}L.push(G)}if(!u){let G=ce[ce.length-1],_=di({windingRule:ce.length>1?He.POSITIVE:He.ODD,elementType:rt.POLYGONS,vertexSize:2,strict:!0,contours:[G.insetPoints,...L]});if(!_)throw new Error("Error generating geometry for surface");for(let z=0;z<_.elementCount*3;z+=3){let D=this.buildSurfaceVert(_,_.elements[z+0]),R=this.buildSurfaceVert(_,_.elements[z+1]),K=this.buildSurfaceVert(_,_.elements[z+2]);y.push(D.top,R.top,K.top),y.push(K.bottom,R.bottom,D.bottom)}}this.vertexCache={}}this._buffer.shrink();let A=new js(Uint32Array.from(y),1),I=new js(this._buffer.positions,3),b=new js(this._buffer.normals,3),V=new js(this._buffer.uvs,2);I.needsUpdate=!0,b.needsUpdate=!0,V.needsUpdate=!0,A.needsUpdate=!0,this.setAttribute("position",I),this.setAttribute("normal",b),this.setAttribute("uv",V),this.setIndex(A)}buildSurfaceVert(e,r){let i=r.toString();if(i in this.vertexCache)return this.vertexCache[i];let o=e.vertices[r*2+0],s=e.vertices[r*2+1],a=(o-this._minX)/this._width,l=(s-this._minY)/this._height,c=this._buffer.get(2),p=c*3,h=c*2,d={top:c+0,bottom:c+1};return this._buffer.positions[p+0]=o,this._buffer.positions[p+1]=s,this._buffer.positions[p+2]=this._depth,this._buffer.normals[p+0]=0,this._buffer.normals[p+1]=0,this._buffer.normals[p+2]=1,this._buffer.uvs[h+0]=a,this._buffer.uvs[h+1]=l,this._buffer.positions[p+3]=o,this._buffer.positions[p+4]=s,this._buffer.positions[p+5]=0,this._buffer.normals[p+3]=0,this._buffer.normals[p+4]=0,this._buffer.normals[p+5]=-1,this._buffer.uvs[h+2]=a,this._buffer.uvs[h+3]=l,this.vertexCache[i]=d,d}buildBevelVert(e,r,i,o=1){let s=`${r.bevelI}:${i}`;if(s in this.vertexCache)return this.vertexCache[s];let[a,l]=r.boundary.vertexIndices[i],c,p,h,d;a!==l?(p=a,c=l,d=!1,h=e.continuous[p]&&e.continuous[c]):(c=a,p=(c-1+e.count)%e.count,d=e.concave[c]&&r.bevelI>0,h=e.continuous[c]||d);let m=Math.cos(r.angle),f=Math.sin(r.angle),T=i*2,w=c*2,y=p*2,L=r.boundary.vertices[T+0],A=r.boundary.vertices[T+1],I=(1-f)*this._bevelSize,b=(L-this._minX)/this._width,V=(A-this._minY)/this._height,x=e.normals[w+0],u=e.normals[w+1],M=e.normals[y+0],g=e.normals[y+1];if(d){let H=M-x,ie=g-u;x=x+H*(1-o),u=u+ie*(1-o);let pe=Math.sqrt(x*x+u*u);x/=pe,u/=pe}let N=this._buffer.get(h?2:4),v=N*3,C=N*2,$={i,fi:c,topP:N+0,topN:N+0,bottomP:N+1,bottomN:N+1};return this._buffer.positions[v+0]=L,this._buffer.positions[v+1]=A,this._buffer.positions[v+2]=this._depth-I,this._buffer.normals[v+0]=x*m,this._buffer.normals[v+1]=u*m,this._buffer.normals[v+2]=f,this._buffer.uvs[C+0]=b,this._buffer.uvs[C+1]=V,this._buffer.positions[v+3]=L,this._buffer.positions[v+4]=A,this._buffer.positions[v+5]=I,this._buffer.normals[v+3]=x*m,this._buffer.normals[v+4]=u*m,this._buffer.normals[v+5]=-f,this._buffer.uvs[C+2]=V,this._buffer.uvs[C+3]=b,h||(N+=2,v+=6,C+=4,$.topP=N+0,$.bottomP=N+1,this._buffer.positions[v+0]=L,this._buffer.positions[v+1]=A,this._buffer.positions[v+2]=this._depth-I,this._buffer.normals[v+0]=M*m,this._buffer.normals[v+1]=g*m,this._buffer.normals[v+2]=f,this._buffer.uvs[C+0]=b,this._buffer.uvs[C+1]=V,this._buffer.positions[v+3]=L,this._buffer.positions[v+4]=A,this._buffer.positions[v+5]=I,this._buffer.normals[v+3]=M*m,this._buffer.normals[v+4]=g*m,this._buffer.normals[v+5]=-f,this._buffer.uvs[C+2]=V,this._buffer.uvs[C+3]=b),this.vertexCache[s]=$,$}clone(){let e=new eo(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=_o(this.userData),e}};var ht=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){var c,p,h,d,m,f,T;let e=Object.assign({},(c=t==null?void 0:t.parameters)!=null?c:{width:100,subdivisions:40,roundness:0,extrudeDepth:0,extrudeBevelSize:0,extrudeBevelSegments:3},n.parameters),r=Math.abs(e.width),i=Math.abs((p=e.height)!=null?p:e.width),o=Math.abs(e.depth!==void 0&&e.depth===0&&e.extrudeDepth>0?e.extrudeDepth:(h=e.depth)!=null?h:0),s=(d=n.shape)!=null?d:t==null?void 0:t.shape,a=(m=s==null?void 0:s.roundness)!=null?m:e.roundness;s!==void 0&&(s instanceof Me?(s.width!==r||s.height!==i)&&s.applySize(r,i):s=new Me(r,i).fromJSON(s),((f=n.parameters)==null?void 0:f.roundness)!==void 0&&((T=n.parameters)==null?void 0:T.roundness)>0&&s.update(!1));let l=s!=null?s:new Me(r,i);return{parameters:Object.assign(e,{width:r,height:i,depth:o,extrudeDepth:o,roundness:a}),shape:l}}static build(n){let{extrudeDepth:t,extrudeBevelSize:e,extrudeBevelSegments:r,subdivisions:i,roundness:o}=n.parameters;n.shape.roundness=o;let s;return t<=0?s=new Qi(n.shape,i):s=new eo(n.shape,t,e,i,r),Object.assign(s,{userData:W(P({},n),{type:"VectorGeometry"})})}};import{MathUtils as bd,Vector2 as vd}from"three";var Sd=Math.PI*2,wd=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){var i,o,s;let e=Object.assign({},(i=t==null?void 0:t.parameters)!=null?i:{width:100,depth:0,spikes:64,angle:360,innerRadius:0,extrudeDepth:0,extrudeBevelSize:0,extrudeBevelSegments:1},n.parameters);return{shape:n.shape&&n.shape instanceof Me?n.shape:new Me,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs((o=e.height)!=null?o:e.width),depth:Math.abs(e.depth!==void 0&&e.depth===0&&e.extrudeDepth>0?e.extrudeDepth:(s=e.depth)!=null?s:0)})}}static build(n){let{width:t,height:e,spikes:r,angle:i,innerRadius:o,depth:s,extrudeBevelSize:a,extrudeBevelSegments:l}=n.parameters,c=n.shape,p=t*.5,h=e*.5,d=jb(c,p,h,i*Math.PI/180,r,o);c.isClosed=!0,c.update();let m=ht.create({shape:c,parameters:{subdivisions:d,depth:s,extrudeBevelSize:a,extrudeBevelSegments:l}});return Object.assign(m,{userData:W(P({},n),{type:"EllipseGeometry"})})}};function jb(n,t,e,r,i,o){if(r>=Sd)return i>30||i%4===0?(kb(n,t,e,o),Math.round(i/4)):xd(n,r,i,t,e,o);let s={x:0,y:e},a=r+Math.PI*.5,l={x:Math.cos(a)*t,y:Math.sin(a)*e},c=ud({px:s.x,py:s.y,cx:l.x,cy:l.y,rx:t,ry:e,largeArcFlag:r>Math.PI,sweepFlag:!0});return i>30||i%c.length===0?Ub(n,s.x,s.y,c,i,t,e,o):xd(n,r,i,t,e,o)}function Ub(n,t,e,r,i,o,s,a){let l=Math.round(i/r.length);n.addPoint(to(t,e));for(let c=0,p=r.length;c<p;c++){let h=r[c],d=n.points[c],m=to(h.x,h.y);d.controls[1].position.set(h.x1,h.y1),m.controls[0].position.set(h.x2,h.y2),n.addPoint(m)}return a>0?Ld(n,o,s,a):n.addPoint(to(0,0)),l}function xd(n,t,e,r,i,o){let s=-t/e;for(let a=0;a<=e;a++){let l=s*a,c=Math.sin(l)*r,p=Math.cos(l)*i;n.addPoint(to(c,p))}return t<Sd?o>0?Ld(n,r,i,o):n.addPoint(to(0,0)):(n.removePoint(n.points[n.points.length-1]),o>0&&Cd(n,r,i,o)),1}function kb(n,t,e,r=0,i=0,o=0){let s=.5522847498,a=t*s,l=e*s;n.addPoint(Us(i-t,o,i-t,o-l,i-t,o+l)),n.addPoint(Us(i,o+e,i-a,o+e,i+a,o+e)),n.addPoint(Us(i+t,o,i+t,o+l,i+t,o-l)),n.addPoint(Us(i,o-e,i+a,o-e,i-a,o-e)),r>0&&Cd(n,t,e,r)}function to(n,t){return new Qt(bd.generateUUID(),new vd(n,t))}function Us(n,t,e,r,i,o){let s=to(n,t);return s.controls[0].position.set(e,r),s.controls[1].position.set(i,o),s}function Ld(n,t,e,r){Td(n,t,e,r).forEach(o=>n.addPoint(o))}function Cd(n,t,e,r){let i=Td(n,t,e,r),o=new Me;i.forEach(s=>o.addPoint(s)),o.isClosed=!0,n.shapeHoles.push(o)}function Td(n,t,e,r){let i=r*t/100,o=i*(Math.abs(e)/Math.abs(t)),s=new vd(i/t,o/e),a=n.points.map(l=>{let c=l.clone();return c.uuid=bd.generateUUID(),c}).reverse();return a.forEach(l=>{l.position.multiply(s);let c=l.controls[0].position.clone().multiply(s),p=l.controls[1].position.clone().multiply(s);l.controls[0].position.copy(p),l.controls[1].position.copy(c)}),a}import{BufferGeometry as Hb,Float32BufferAttribute as gl,Vector3 as Nd}from"three";var Md=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){var a,l,c;let e=Object.assign({},(a=t==null?void 0:t.parameters)!=null?a:{width:100,revolutions:2,segments:40,pathRadius:10,pathType:0,pathSegments:30,cornerRadius:30,cornerSegments:4},n.parameters),r=Math.abs(e.width),i=Math.abs((l=e.height)!=null?l:r),o=Math.abs((c=e.depth)!=null?c:r),s=Math.abs(Math.min(r,o))/2;return{parameters:Object.assign(e,{width:r,height:i,depth:o,radius:s,segments:Math.round(e.segments),pathSegments:Math.round(e.pathSegments),cornerSegments:Math.round(e.cornerSegments)})}}static build(n){let{width:t,height:e,depth:r,radius:i,revolutions:o,segments:s,pathRadius:a,pathType:l,pathSegments:c,cornerRadius:p,cornerSegments:h}=n.parameters,d=new Yo(!1,t,e,r,i,o,s,a,l,c,p,h);return Object.assign(d,{userData:W(P({},n),{type:"HelixGeometry"})})}},Yo=class extends Hb{constructor(t=!0,e=1,r=1,i=1,o=1,s=1,a=1,l=1,c=1,p=1,h=1,d=1){super();let m=t&&s===1;m&&(d=0),h>100&&(h=100);let f=()=>new Nd,T=new Nd,w=f(),y=f(),L=f(),A,I,b,V,x,u,M,g,N=f(),v=f(),C=f(),$=f(),H=f(),ie=f(),pe=f(),ce=f(),be=r-2*l+.001,F=be/s,G=Math.ceil(a*s),_=G+1,z=be/G,D=-be/2,R=p+1,K=2*Math.PI/p,Z=Math.PI/2/d,U=.01,j=Math.min((1-h/100)*l,l-U),B=l-j,k=0,ne=2,q=d*ne+ne,J=R*q/ne,Y=J+R*_,X=R*(_+q),[Q,se,oe]=[3,3,2].map(Ue=>Array(X*Ue).fill(0)),he=[],Ee=o-l;function xe(Ue,yt){let _t=Math.PI/2;u=yt*z,g=2*Math.PI*(u%F)/F+_t,u+=D,M=Math.sin(g)*Ee,x=Math.cos(g)*Ee,t?Ue.set(x,M,u):Ue.set(x,u,M)}xe(T,-1e-10),xe(w,0),N.copy(T),xe(T,1);let We=T.distanceTo(w),Ce=B+j,ct=We*G+2*Ce,wt=j,br=ct-Ce;for(let Ue=0;Ue<=G;Ue++){xe(y,Ue),ce.subVectors(y,N).normalize(),N.copy(y),ie.copy(y).setComponent(+t+1,0).normalize(),pe.crossVectors(ce,ie).normalize();let yt=Ue===0,_t=Ue===G,Tn=yt?3*Math.PI/2:Z,Nn=yt?wt:br,Mn=yt?R:Y,On=yt?0:X-R,In=ce.clone().multiplyScalar(yt?-B:B).add(y),Pn=ce.clone().multiplyScalar(yt?-1:1).normalize();for(let jt=0;jt<R;jt++){let Io=jt*K;if(v.addVectors(T.copy(ie).multiplyScalar(l*Math.cos(Io)),w.copy(pe).multiplyScalar(l*Math.sin(Io))),C.copy(v).normalize(),yt||_t){m||(k=On+jt,[0,1,2].forEach(pt=>{Q[k*3+pt]=In.getComponent(pt),se[k*3+pt]=Pn.getComponent(pt)}),oe[k*2]=+_t,oe[k*2+1]=jt/p),w.copy(C).multiplyScalar(j),L.addVectors(y,w);for(let pt=0;pt<d;pt++){let Si=pt*Z+Tn;$.addVectors(T.copy(ce).multiplyScalar(B*Math.sin(Si)),w.copy(C).multiplyScalar(B*Math.cos(Si))),H.copy($).normalize(),w.addVectors(L,$),$.normalize(),k=Mn+pt*R+jt,[0,1,2].forEach(ge=>{Q[k*3+ge]=w.getComponent(ge),se[k*3+ge]=H.getComponent(ge)});let An=+yt+Math.sin(Si);oe[k*2]=(Nn+B*An)/ct,oe[k*2+1]=jt/p}}w.addVectors(y,v),k=J+Ue*R+jt,[0,1,2].forEach(pt=>{Q[k*3+pt]=w.getComponent(pt),se[k*3+pt]=C.getComponent(pt)}),oe[k*2]=(Ce+Ue*We)/ct,oe[k*2+1]=jt/p}}let ft=_+2*d+ne,vr=1,[ii,oi]=m?[vr,vr+_-1]:[0,ft-1];for(let Ue=ii;Ue<=oi-1;Ue++){let yt=m&&Ue===oi-1;for(let _t=0;_t<R-1;_t++)A=Ue*R+_t,I=A+1,b=(yt?_t:A)+R,V=(yt?_t+1:I)+R,Ue===0?he.push(I,V,b):Ue===ft-2?he.push(A,I,b):he.push(A,I,b,I,V,b)}this.setIndex(he),this.setAttribute("position",new gl(Q,3)),this.setAttribute("normal",new gl(se,3)),this.setAttribute("uv",new gl(oe,2))}};import{IcosahedronBufferGeometry as qb}from"three";var Od=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){var r,i,o;let e=Object.assign({},(r=t==null?void 0:t.parameters)!=null?r:{width:100,detail:0,corner:0,cornerSides:4},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs((i=e.height)!=null?i:e.width),depth:Math.abs((o=e.depth)!=null?o:e.width)})}}static build(n){let{width:t,height:e,depth:r,detail:i,corner:o,cornerSides:s}=n.parameters,a=i===0&&o!==0?new Xo(t*.5,o,s):new qb(t*.5,i);return a.scale(1,e/t,r/t),Object.assign(a,{userData:W(P({},n),{type:"IcosahedronGeometry"})})}},Xo=class extends $r{constructor(t=1,e=.2,r=4){let i=(1+Math.sqrt(5))/2,o=[-1,i,0,1,i,0,-1,-i,0,1,-i,0,0,-1,i,0,1,i,0,-1,-i,0,1,-i,i,0,-1,i,0,1,-i,0,-1,-i,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(o,s,a,t,e,r),this.type=a}static fromJSON(t){return new Xo(t.radius,t.corner,t.cornerSides)}};import{LatheBufferGeometry as Wb,Shape as $b}from"three";var Id=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){var r,i,o,s,a;((i=(r=n.parameters)==null?void 0:r.points)!=null?i:[]).forEach(l=>{Array.isArray(l)&&(l.x=l[0],l.y=l[1])});let e=Object.assign({},(o=t==null?void 0:t.parameters)!=null?o:{width:100,segments:64,verticalSegments:64,points:[{x:0,y:-50,id:0},{x:50,y:-50,id:1},{x:50,y:50,id:2},{x:0,y:50,id:3}]},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs((s=e.height)!=null?s:e.width),depth:Math.abs((a=e.depth)!=null?a:e.width)})}}static build(n){let{points:t,segments:e,verticalSegments:r}=n.parameters,i=new $b;i.moveTo(t[0].x,t[0].y),i.bezierCurveTo(t[1].x,t[1].y,t[2].x,t[2].y,t[3].x,t[3].y);let o=new Wb(i.extractPoints(r).shape,e);return o.rotateZ(Math.PI),Object.assign(o,{userData:W(P({},n),{type:"LatheGeometry"})})}};import{BufferGeometry as Ad,BufferGeometryLoader as ev,Vector3 as tv,BoxBufferGeometry as Dd}from"three";import{BufferGeometry as Jb,Vector2 as xl,Vector3 as Pd}from"three";import{Geometry as Kb,Face3 as Yb}from"three/examples/jsm/deprecated/Geometry.js";var Xb=["a","b","c"];function Zb(n,t){switch(t){case"c":return n.c;case"b":return n.b;case"a":default:return n.a}}function bl(n,t,e){let r=Math.min(n,t),i=Math.max(n,t),o=r+"_"+i;return e.get(o)}function vl(n,t,e,r,i,o){let s=Math.min(n,t),a=Math.max(n,t),l=s+"_"+a,c;if(r.has(l))c=r.get(l);else{let p=e[s],h=e[a];c={a:p,b:h,newEdge:null,faces:[]},r.set(l,c)}c.faces.push(i),o[n].edges.push(c),o[t].edges.push(c)}function Qb(n,t,e,r){let i,o,s;for(i=0,o=n.length;i<o;i++)e[i]={edges:[]};for(i=0,o=t.length;i<o;i++)s=t[i],vl(s.a,s.b,n,r,s,e),vl(s.b,s.c,n,r,s,e),vl(s.c,s.a,n,r,s,e)}function ks(n,t,e,r,i){n.push(new Yb(t,e,r,void 0,void 0,i))}function ro(n,t){return Math.abs(t-n)/2+Math.min(n,t)}function Hs(n,t,e,r){n.push([t.clone(),e.clone(),r.clone()])}var qs=class{constructor(t=1){this.subdivisions=t}modify(t){t instanceof Jb?t=new Kb().fromBufferGeometry(t):t=t.clone(),t.mergeVertices();let e=this.subdivisions;for(;e-- >0;)this._smooth(t);return t.computeFaceNormals(),t.computeVertexNormals(),t}_smooth(t){let e=new Pd,r,i,o,s,a,l=t.vertices,c=t.faces,p=t.faceVertexUvs[0],h=p!==void 0&&p.length>0,d=[],m=new Map;Qb(l,c,d,m);let f=[],T,w,y,L,A,I,b;for(let U of Array.from(m.keys())){for(w=m.get(U),y=new Pd,A=3/8,I=1/8,b=w.faces.length,b!=2&&(A=.5,I=0,b!=1),y.addVectors(w.a,w.b).multiplyScalar(A),e.set(0,0,0),s=0;s<b;s++){for(L=w.faces[s],a=0;a<3&&(T=l[Zb(L,Xb[a])],!(T!==w.a&&T!==w.b));a++);T&&e.add(T)}e.multiplyScalar(I),y.add(e),w.newEdge=f.length,f.push(y)}let V,x,u,M,g,N,v,C=[];for(i=0,o=l.length;i<o;i++){for(N=l[i],g=d[i].edges,r=g.length,r==3?V=3/16:r>3&&(V=3/(8*r)),x=1-r*Number(V),u=V,r<=2&&(r==2?(x=3/4,u=1/8):r==1||r==0),v=N.clone().multiplyScalar(x),e.set(0,0,0),s=0;s<r;s++)M=g[s],T=M.a!==N?M.a:M.b,e.add(T);e.multiplyScalar(Number(u)),v.add(e),C.push(v)}let $=C.concat(f),H=C.length,ie,pe,ce,be=[],F=[],G,_,z,D,R=new xl,K=new xl,Z=new xl;for(i=0,o=c.length;i<o;i++)L=c[i],ie=Number(bl(L.a,L.b,m).newEdge)+H,pe=Number(bl(L.b,L.c,m).newEdge)+H,ce=Number(bl(L.c,L.a,m).newEdge)+H,ks(be,ie,pe,ce,L.materialIndex),ks(be,L.a,ie,ce,L.materialIndex),ks(be,L.b,pe,ie,L.materialIndex),ks(be,L.c,ce,pe,L.materialIndex),h&&(G=p[i],_=G[0],z=G[1],D=G[2],R.set(ro(_.x,z.x),ro(_.y,z.y)),K.set(ro(z.x,D.x),ro(z.y,D.y)),Z.set(ro(_.x,D.x),ro(_.y,D.y)),Hs(F,R,K,Z),Hs(F,_,R,Z),Hs(F,z,K,R),Hs(F,D,Z,K));t.vertices=$,t.faces=be,h&&(t.faceVertexUvs[0]=F)}};var it=new tv,_d=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){var o,s;let e=(s=(o=n.geometry)!=null?o:t==null?void 0:t.geometry)!=null?s:new Ad().copy(new Dd(100,100,100)),r;t===void 0?(e.computeBoundingBox(),e.boundingBox.getSize(it),r={width:it.x,height:it.y,depth:it.z,subdivisions:0}):r=t.parameters;let i=P(P({},r),n.parameters);return{parameters:{width:Math.abs(i.width),height:Math.abs(i.height),depth:Math.abs(i.depth),subdivisions:Math.abs(i.subdivisions)},geometry:e}}static build(n){var l;let{width:t,height:e,depth:r,subdivisions:i}=n.parameters,o=(l=n.geometry)!=null?l:new Ad().copy(new Dd(100,100,100)),s=o.userData.parameters;s===void 0?(o.computeBoundingBox(),o.boundingBox.getSize(it)):it.set(s.width,s.height,s.depth),(t!==it.x||e!==it.y||r!==it.z)&&o.scale(it.x===0?1:t/it.x,it.y===0?1:e/it.y,it.z===0?1:r/it.z);let a=o.originalGeometry;return i>0?(a===void 0||(s==null?void 0:s.subdivisions)!==i)&&(a===void 0&&(a=o),o=new qs(i).modify(a).toBufferGeometry()):(a!==void 0&&(o=a),a=void 0,o.getAttribute("normal")===void 0&&o.computeVertexNormals()),a!==void 0&&Object.assign(o,{originalGeometry:a}),delete n.geometry,Object.assign(o,{userData:W(P({},n),{type:"NonParametricGeometry"})})}static loadFromUrl(n,t,e){new ev(e).load(n,i=>{let o=this.normalizeInputs({geometry:i});i.boundingBox.getSize(it);let s=100/it.x;Object.assign(o.parameters,{width:100,height:it.y*s,depth:it.z*s}),t(this.build(o))})}};var Bd=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){var i,o,s;let e=Object.assign({},(i=t==null?void 0:t.parameters)!=null?i:{width:100,depth:0,spikes:5,cornerRadius:0,extrudeDepth:0,extrudeBevelSize:0,extrudeBevelSegments:3},n.parameters);return{shape:n.shape&&n.shape instanceof Me?n.shape:new Me,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs((o=e.height)!=null?o:e.width),depth:Math.abs(e.depth!==void 0&&e.depth===0&&e.extrudeDepth>0?e.extrudeDepth:(s=e.depth)!=null?s:0)})}}static build(n){let{width:t,height:e,spikes:r,cornerRadius:i,depth:o,extrudeBevelSize:s,extrudeBevelSegments:a}=n.parameters,l=n.shape,c=t*.5,p=e*.5,h=0,d=0,m=2*Math.PI/r;for(let T=0;T<r;T++){let w=m*T,y=h+Math.sin(w)*c,L=d+Math.cos(w)*p;l.addPoint(l.createPoint(y,L))}l.isClosed=!0;for(let T=0,w=l.points.length;T<w;T++)l.points[T].roundness=i;l.roundness=i,l.update();let f=ht.create({shape:l,parameters:{roundness:i,depth:o,extrudeBevelSize:s,extrudeBevelSegments:a}});return Object.assign(f,{userData:W(P({},n),{type:"PolygonGeometry"})})}};import{BufferGeometry as rv,Float32BufferAttribute as Sl,Vector2 as dr,Vector3 as st}from"three";var Ed=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){var r,i,o;let e=Object.assign({},(r=t==null?void 0:t.parameters)!=null?r:{width:100,radialSegments:4,heightSegments:1,cornerRadius:0,cornerSegments:8,openEnded:!1},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs((i=e.height)!=null?i:e.width),depth:Math.abs((o=e.depth)!=null?o:e.width)})}}static build(n){let{width:t,height:e,depth:r,radialSegments:i,heightSegments:o,openEnded:s,cornerRadius:a,cornerSegments:l}=n.parameters,c=new Ll(t*.5,e,i,o,s,a,l);return c.scale(1,1,r/t),Object.assign(c,{userData:W(P({},n),{type:"PyramidGeometry"})})}};function Zo(n,t,e){e.x=n.x*t.x,e.y=n.y,e.z=n.x*t.y}function wl(n,t,e,r,i,o){let s=t.clone().sub(n),a=e.clone().sub(n),l=s.angleTo(a);if(s.normalize(),a.normalize(),r===i){let c=s.add(a).normalize();o.copy(n).addScaledVector(c,r/Math.sin(l/2))}else{let c=s.angleTo(a);o.copy(n),o.addScaledVector(s,i/Math.sin(c)),o.addScaledVector(a,r/Math.sin(c))}}function iv(n,t,e){let r=n.clone().sub(t),i=e.clone().sub(t);return r.projectOnVector(i),r.add(t)}var Ll=class extends rv{constructor(t=.5,e=1,r=4,i=1,o=!1,s=0,a=4){super(),r=Math.floor(Math.max(3,r)),i=Math.floor(i),a=Math.floor(a);let l=[],c=[],p=[],h=[],d=0,m=e/2,f=Math.PI/r,T=t*Math.cos(Math.PI/r),w=2*Math.PI/r,y=(r-2)*Math.PI/r,L=Math.PI-y,A=new st(0,-m,0),I=new st(0,m,0),b=new dr(t,-m),V=new dr(T,-m),x=new dr(0,I.y).sub(V),u=new dr(0,I.y).sub(b),M=new dr(x.y,-x.x).normalize(),g=new dr(u.y,-u.x).normalize(),v=t*Math.cos(Math.PI/r)*Math.tan((Math.PI-x.angle())/2)-1e-8;s=Math.min(s,v);let C;{let F=new st(M.x,M.y,0),G=new st(Math.cos(w)*F.x,F.y,Math.sin(w)*F.x);C=F.angleTo(G)}let $=s/Math.tan((Math.PI-x.angle())/2),H=s/Math.tan((Math.PI-C)/2),ie=new st;if(!o){c.push(A.x,A.y,A.z),p.push(0,-1,0),h.push(0,0);let F=d++,G=[],_=b.clone(),z=$/Math.cos(Math.PI/r);_.x-=z;for(let D=0;D<r;D++){let R=D/r*Math.PI*2+f,K=new dr(Math.sin(R),Math.cos(R));Zo(_,K,ie),c.push(ie.x,ie.y,ie.z),p.push(0,-1,0),h.push(0,0),G.push(d++)}for(let D=0;D<G.length;D++)l.push(G[D],F,G[(D+1)%G.length])}let pe=[];{let F=new st,G=new st,_=new st,z=new st,D=new st,R=new st;for(let K=0;K<r;K++){let Z=K/r*Math.PI*2+f,U=(K+.5)/r*Math.PI*2+f,j=(K+1)/r*Math.PI*2+f,B=new dr(Math.sin(Z),Math.cos(Z)),k=new dr(Math.sin(U),Math.cos(U)),ne=new dr(Math.sin(j),Math.cos(j));Zo(b,B,G),Zo(b,ne,_),Zo(M,k,F),wl(I,G,_,H,H,z),c.push(z.x,z.y,z.z),wl(G,I,_,H,$,D),c.push(D.x,D.y,D.z),wl(_,G,I,$,H,R),c.push(R.x,R.y,R.z),p.push(F.x,F.y,F.z),p.push(F.x,F.y,F.z),p.push(F.x,F.y,F.z),h.push(0,0),h.push(0,0),h.push(0,0);let q=d++,J=d++,Y=d++;if(l.push(q,J,Y),s>0){{let se=G.clone().add(_).multiplyScalar(.5),oe=I.clone().sub(se).normalize(),Ee=A.clone().sub(se).normalize().add(oe).normalize().multiplyScalar(-1),xe=R.clone().sub(D);ce(se,xe,Ee,x.angle())}let X,Q;{let se=new st;Zo(g,ne,se);let oe=R.clone().add(z).multiplyScalar(.5);oe=iv(oe,_,I);let he=R.clone().sub(z);[X,Q]=ce(oe,he,se,C,z.y)}{let se=X,oe=se.clone().setY(0).normalize(),he=new st(0,-1,0),Ee=oe.clone().cross(he);be(se,oe,he,Ee)}pe.concat(Q);{let se=x.angle(),oe=Math.PI-se,he=I.clone();he.y-=s/Math.sin(se-Math.PI/2);let Ee=new st,xe=[];for(let Ce=0;Ce<a;Ce++){let ct=[],wt=Math.PI/2-oe*Ce/a,br=Math.cos(wt),ft=Math.sin(wt),vr=U;for(let ii=0;ii<=Ce;ii++){let oi=Math.cos(vr),Ue=Math.sin(vr);F.x=br*Ue,F.y=ft,F.z=br*oi,Ee.copy(he).addScaledVector(F,s),c.push(Ee.x,Ee.y,Ee.z),p.push(F.x,F.y,F.z),h.push(0,0),ct.push(d++),vr+=Math.PI*2/Ce/r}xe.push(ct)}Q.reverse(),xe.push(Q);let We=xe.length-1;for(let Ce=0;Ce<We;Ce++){let ct=xe[Ce],wt=xe[Ce+1],br=ct.length-1;l.push(wt[1],ct[0],wt[0]);for(let ft=1;ft<=br;ft++)l.push(ct[ft],ct[ft-1],wt[ft]),l.push(wt[ft+1],ct[ft],wt[ft])}}}}}this.setIndex(l),this.setAttribute("position",new Sl(c,3)),this.setAttribute("normal",new Sl(p,3)),this.setAttribute("uv",new Sl(h,2));function ce(F,G,_,z,D){let R=-z/2,K=(Math.PI-z)/2,Z=G.clone().normalize().cross(_);F.addScaledVector(_,-s/Math.sin(K));let U=new st,j=new st,B=1,k=d,ne=[];for(let q=0;q<=a;q++){let J=R+q/a*z;j.set(0,0,0),j.addScaledVector(Z,Math.sin(J)),j.addScaledVector(_,Math.cos(J));for(let Y=0;Y<=B;Y++){let X=Y/B-.5;if(U.copy(F),U.addScaledVector(G,X),U.addScaledVector(j,s),D!=null){let Q=Math.max(0,U.y-D);U.addScaledVector(G,-Q/G.y)}c.push(U.x,U.y,U.z),p.push(j.x,j.y,j.z),h.push(0,0),Y===0&&ne.push(d),d++}}for(let q=0;q<a;q++)for(let J=0;J<B;J++){let Y=k+J+(B+1)*q,X=Y+(B+1),Q=X+1,se=Y+1;l.push(Y,X,se),l.push(X,Q,se)}return[F.clone().addScaledVector(G,.5),ne]}function be(F,G,_,z){let D=Math.PI/2,R=u.angle()-D,K=[],Z=new st,U=new st;for(let B=0;B<=a;B++){let k=[],ne=B/a;for(let q=0;q<=B;q++){let Y=((B?q/B:0)-.5)*L,X=Math.cos(Y),Q=Math.sin(Y),se=Math.atan(Math.tan(R)*X),oe=(D+se)*ne,he=Math.cos(oe),Ee=Math.sin(oe);Z.set(0,0,0),Z.addScaledVector(G,Ee*X),Z.addScaledVector(_,he),Z.addScaledVector(z,Ee*Q),U.copy(F).addScaledVector(Z,s),c.push(U.x,U.y,U.z),p.push(Z.x,Z.y,Z.z),h.push(0,0),k.push(d++)}K.push(k)}let j=K.length-1;for(let B=0;B<j;B++){let k=K[B],ne=K[B+1],q=k.length-1;l.push(k[0],ne[1],ne[0]);for(let J=1;J<=q;J++)l.push(k[J-1],k[J],ne[J]),l.push(k[J],ne[J+1],ne[J])}}}};var Ws=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){var o,s,a,l;let e=Object.assign({},(o=t==null?void 0:t.parameters)!=null?o:{width:100,depth:0,cornerRadius:[0,0,0,0],cornerType:1,extrudeDepth:0,extrudeBevelSize:0,extrudeBevelSegments:1},n.parameters),r=Object.assign((s=t==null?void 0:t.ui)!=null?s:{enabledIndieCorners:!1},n.ui);return{shape:n.shape&&n.shape instanceof Me?n.shape:new Me,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs((a=e.height)!=null?a:e.width),depth:Math.abs(e.depth!==void 0&&e.depth===0&&e.extrudeDepth>0?e.extrudeDepth:(l=e.depth)!=null?l:0)}),ui:r}}static build(n){let t=n.shape,{width:e,height:r,cornerRadius:i,cornerType:o,depth:s,extrudeBevelSize:a,extrudeBevelSegments:l}=n.parameters,c={x:e*.5,y:r*.5},p={x:-c.x,y:-c.y},h={x:c.x,y:c.y};function d(I,b,V){return b>e&&V>r?Math.min(I*e/b,I*r/V):b>e?I*e/b:V>r?I*r/V:I}let m=[];m[0]=i[0]===0?0:d(i[0],i[0]+i[3],i[0]+i[1]),m[1]=i[1]===0?0:d(i[1],i[1]+i[2],i[1]+i[0]),m[2]=i[2]===0?0:d(i[2],i[2]+i[1],i[2]+i[3]),m[3]=i[3]===0?0:d(i[3],i[3]+i[0],i[3]+i[2]);let f=p.x,T=h.x,w=h.y,y=p.y;t.addPoint(t.createPoint(f,w)),t.addPoint(t.createPoint(T,w)),t.addPoint(t.createPoint(T,y)),t.addPoint(t.createPoint(f,y)),t.isClosed=!0;let L=!0;for(let I=0,b=t.points.length;I<b;I++)t.points[I].roundness=m[I],I>0&&m[I]!==m[I-1]&&(L=!1);L&&(t.roundness=m[0]),t.useCubicForRoundedCorners=o!==1,t.update();let A=ht.create({shape:t,parameters:{depth:s,extrudeBevelSize:a,extrudeBevelSegments:l}});return Object.assign(A,{userData:W(P({},n),{type:"RectangleGeometry"})})}};import{SphereBufferGeometry as ov}from"three";var Gd=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){var r,i,o;let e=Object.assign({},(r=t==null?void 0:t.parameters)!=null?r:{width:100,widthSegments:64,heightSegments:64,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:Math.PI},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs((i=e.height)!=null?i:e.width),depth:Math.abs((o=e.depth)!=null?o:e.width)})}}static build(n){let{width:t=100,height:e=t,depth:r=t,widthSegments:i=64,heightSegments:o=64,phiStart:s,phiLength:a,thetaStart:l,thetaLength:c}=n.parameters,p=new ov(.5*t,i,o,s,a,l,c);return p.scale(1,e/t,r/t),Object.assign(p,{userData:W(P({},n),{type:"SphereGeometry"})})}};import{PlaneBufferGeometry as nv}from"three";var zd=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){var r,i;let e=Object.assign({},(r=t==null?void 0:t.parameters)!=null?r:{width:100,depth:0,widthSegments:8,heightSegments:8},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs((i=e.height)!=null?i:e.width),depth:0})}}static build(n){let{width:t=100,height:e=t,widthSegments:r=8,heightSegments:i=8}=n.parameters,o=new nv(t,e,r,i);return o.scale(1,1,1),Object.assign(o,{userData:W(P({},n),{type:"PlaneGeometry"})})}};var Rd=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){var i,o,s;let e=Object.assign({},(i=t==null?void 0:t.parameters)!=null?i:{width:100,depth:0,innerRadiusPercent:38.19,spikes:5,cornerRadius:0,angle:360,extrudeDepth:0,extrudeBevelSize:0,extrudeBevelSegments:1},n.parameters);return{shape:n.shape&&n.shape instanceof Me?n.shape:new Me,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs((o=e.height)!=null?o:e.width),depth:Math.abs(e.depth!==void 0&&e.depth===0&&e.extrudeDepth>0?e.extrudeDepth:(s=e.depth)!=null?s:0)})}}static build(n){let{width:t,height:e,innerRadiusPercent:r,spikes:i,cornerRadius:o,angle:s,depth:a,extrudeBevelSize:l,extrudeBevelSegments:c}=n.parameters,p=n.shape,h=t*.5,d=e*.5,m=0,f=0,T=s*Math.PI/360/i,w=Math.PI/2*3*-1,y=h*r/100,L=d*r/100;if(i===3&&r===50){T=2*Math.PI/i;for(let I=0;I<i;I++){let b=T*I,V=m+Math.sin(b)*h,x=f+Math.cos(b)*d;p.addPoint(p.createPoint(V,x))}}else for(let I=0;I<i;I++){let b=m+Math.cos(w)*h,V=f+Math.sin(w)*d;p.addPoint(p.createPoint(b,V)),w+=T,b=m+Math.cos(w)*y,V=f+Math.sin(w)*L,I<=i,p.addPoint(p.createPoint(b,V)),w+=T}p.isClosed=!0;for(let I=0,b=p.points.length;I<b;I++)p.points[I].roundness=o;p.roundness=o,p.update();let A=ht.create({shape:p,parameters:{roundness:o,depth:a,extrudeBevelSize:l,extrudeBevelSegments:c}});return Object.assign(A,{userData:W(P({},n),{type:"StarGeometry"})})}};import{PlaneBufferGeometry as sv}from"three";var $s=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){var r,i,o;let e=Object.assign({},(r=t==null?void 0:t.parameters)!=null?r:{width:100,depth:0},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs((i=e.height)!=null?i:e.width),depth:Math.abs((o=e.depth)!=null?o:0)})}}static build(n){let{width:t,height:e}=n.parameters,r=new sv(t,e);return Object.assign(r,{userData:W(P({},n),{type:"TextFrameGeometry"})})}};var Vd=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){var s,a,l;let e=Object.assign({},(s=t==null?void 0:t.parameters)!=null?s:{width:100,radialSegments:32,tubularSegments:64,arc:Math.PI*2,cornerRadius:30,cornerSegments:8},n.parameters),r=Math.abs(e.width),i=Math.abs((a=e.height)!=null?a:e.width),o=Math.abs((l=e.depth)!=null?l:e.width*.25);return{parameters:Object.assign(e,{width:r,height:i,depth:o})}}static build(n){let{width:t,height:e,depth:r,radialSegments:i,tubularSegments:o,arc:s,cornerRadius:a,cornerSegments:l}=n.parameters,c=av(t,e,r,t*.5,s,o,0,0,i,a,l);return c.scale(1,e/t,1),Object.assign(c,{userData:W(P({},n),{type:"TorusGeometry"})})}};function av(n,t,e,r,i,o,s,a,l,c,p){return[t,e]=[e,t],s=t/2,i/=2*Math.PI,i==1&&(c=0),new Yo(!0,n,t,e,r,i,o,s,a,l,c,p)}import{TorusKnotBufferGeometry as lv}from"three";var Fd=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){var r,i,o,s;let e=Object.assign({},(r=t==null?void 0:t.parameters)!=null?r:{width:100,tubularSegments:64,radialSegments:32,p:2,q:3},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs((i=e.height)!=null?i:e.width),depth:Math.abs((o=e.depth)!=null?o:e.width),tube:(s=e.tube)!=null?s:e.width*.125})}}static build(n){let{width:t,tube:e,tubularSegments:r,radialSegments:i,p:o,q:s}=n.parameters,a=t*.5;a!==e&&(a-=e);let l=new lv(a,e,r,i,o,s);return Object.assign(l,{userData:W(P({},n),{type:"TorusKnotGeometry"})})}};var jd=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){var i,o,s;let e=Object.assign({},(i=t==null?void 0:t.parameters)!=null?i:{width:100,depth:0,spikes:5,cornerRadius:0,extrudeDepth:0,extrudeBevelSize:0,extrudeBevelSegments:1,isRect:!1},n.parameters);return{shape:n.shape&&n.shape instanceof Me?n.shape:new Me,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs((o=e.height)!=null?o:e.width*(e.isRect?1:Math.sqrt(3)/2)),depth:Math.abs(e.depth!==void 0&&e.depth===0&&e.extrudeDepth>0?e.extrudeDepth:(s=e.depth)!=null?s:0)})}}static build(n){let{width:t=100,height:e,cornerRadius:r,depth:i,extrudeBevelSize:o,extrudeBevelSegments:s,isRect:a}=n.parameters,l=n.shape,c=t*.5,p=e*.5;a?(l.addPoint(l.createPoint(-c,p)),l.addPoint(l.createPoint(c,-p)),l.addPoint(l.createPoint(-c,-p))):(l.addPoint(l.createPoint(0,p)),l.addPoint(l.createPoint(c,-p)),l.addPoint(l.createPoint(-c,-p))),l.isClosed=!0;for(let d=0,m=l.points.length;d<m;d++)l.points[d].roundness=r;l.roundness=r,l.update();let h=ht.create({shape:l,parameters:{roundness:r,depth:i,extrudeBevelSize:o,extrudeBevelSegments:s}});return Object.assign(h,{userData:W(P({},n),{type:"TriangleGeometry"})})}};var Qo={};mm(Qo,{addBarycentricAttribute:()=>uv,fixUvs:()=>fv,loadFromUrl:()=>mv,resizeGeometry:()=>dv,roundShapePolygon:()=>hv});import{BufferGeometryLoader as cv,Float32BufferAttribute as pv,Vector3 as Cl}from"three";var Ud=function(n,t){let e=t.x-n.x,r=t.y-n.y,i=Math.sqrt(e*e+r*r),o=e/i,s=r/i,a=Math.atan2(s,o);return{x:e,y:r,len:i,nx:o,ny:s,ang:a}},hv=(n,t,e)=>{let r,i,o,s,a,l,c,p,h,d,m,f,T,w,y=t.length;for(s=t[y-2],n.curves=[],r=1;r<y-1;r++){a=t[r%y],l=t[(r+1)%y];let L=Ud(a,s),A=Ud(a,l);c=L.nx*A.ny-L.ny*A.nx,p=L.nx*A.nx-L.ny*-A.ny,m=Math.asin(c),h=1,d=!1,p<0?m<0?m=Math.PI+m:(m=Math.PI-m,h=-1,d=!0):m>0&&(h=-1,d=!0),f=m/2,w=Math.abs(Math.cos(f)*e/Math.sin(f)),w>Math.min(L.len/2,A.len/2)?(w=Math.min(L.len/2,A.len/2),T=Math.abs(w*Math.sin(f)/Math.cos(f))):T=e,i=a.x+A.nx*w,o=a.y+A.ny*w,i+=-A.ny*T*h,o+=A.nx*T*h,n.absarc(i,o,T,L.ang+Math.PI/2*h,A.ang-Math.PI/2*h,d),s=a,a=l}n.closePath()},dv=(n,{width:t,height:e,depth:r})=>{t=Math.abs(t),e=Math.abs(e),r=Math.abs(r);let i=n.userData.parameters,o,s,a;t===0?(t=i.width,o=1):o=t/i.width,e===0?(e=i.height,s=1):s=e/i.height,r===0?(r=i.depth,a=1):a=r/i.depth,n.scale(o,s,a),i.width=t,i.height=e,i.depth=r},uv=(n,t)=>{let e=[new Cl(1,0,0),new Cl(0,1,0),new Cl(0,0,1)],r=n.attributes.position,i=new Float32Array(r.count*3);for(let o=0,s=r.count;o<s;o++)e[o%3].toArray(i,o*3);n.setAttribute(t,new pv(i,3))},mv=n=>new Promise(t=>{new cv().load(n,r=>t(r))}),fv=(n,t,e)=>{let r=n.getAttribute("uv");if(r)for(let i=0;i<r.count;i++){let o=r.getX(i),s=r.getY(i);r.setXY(i,(o+t/2)/t,1-(s-e/2)/e*-1)}};import{BufferGeometry as kd,BufferAttribute as Hd,Uint32BufferAttribute as Tl,Float32BufferAttribute as Nl,Matrix4 as gv}from"three";import{mergeVertices as xv}from"three/examples/jsm/utils/BufferGeometryUtils.js";var yv,Js=new Promise(n=>{yv=n});var me;Js.then(n=>{me=n});var qd=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),Wd=new Uint32Array([0,1,2,3]),$d=new Uint8Array([4]),zt=class{static build(n,t,e,r,i){let o,s,a;if(n===void 0)o=zt.allocate(i,e),me.set_destination_refinement_level(o,0),s=zt.buildLevel(o,!0,r);else if(n.positionWASM!==void 0){t&&t!==0&&(me.free_bvh(t),me.free_subdivision_surface(t));try{o=zt.allocate(i,void 0,n)}catch(l){console.error(l,n),o=zt.allocate(i,void 0,{positionWASM:qd,indexWASM:Wd,verticesPerFaceWASM:$d})}me.set_destination_refinement_level(o,0),s=zt.buildLevel(o,!0,r)}else o=t;if(n!==void 0&&n.subdivisions!==void 0){let l=bv(n.subdivisions,n.positionWASM.length);me.set_destination_refinement_level(o,l),l>0?a=zt.buildLevel(o,!1,r):a=null}return{subdivPointer:o,originalGeometry:s,subdividedGeometry:a}}static allocate(n,t,e){var b;let r,i,o,s=[],a=[];if(e)e.positionWASM&&e.positionWASM.length>0?(r=e.positionWASM,i=e.indexWASM,o=e.verticesPerFaceWASM):(r=qd,i=Wd,o=$d);else{t.deleteAttribute("normal"),t.deleteAttribute("uv");let V=xv(t);r=V.attributes.position.array;let x=V.getIndex().array,u=x.length;switch(t.userData.type==="TorusGeometry"&&(t==null?void 0:t.userData.parameters.arc)===Math.PI*2&&(t.userData.type="ClosedTorusGeometry"),t.userData.type){case"ClosedTorusGeometry":case"PlaneGeometry":case"TorusKnotGeometry":case"CubeGeometry":i=new Uint32Array(u/3*2),o=new Uint8Array(u/6).fill(4);for(let H=0,ie=0;H<u;H+=6)i[ie++]=x[H],i[ie++]=x[H+1],i[ie++]=x[H+4],i[ie++]=x[H+5];break;case"TorusGeometry":case"SphereGeometry":case"HelixGeometry":case"CylinderGeometry":case"ConeGeometry":let M,g,N;if(t.userData.type==="SphereGeometry")g=t.parameters.heightSegments,M=t.parameters.widthSegments,t.parameters.thetaLength!==Math.PI&&(N=!0);else if(t.userData.type==="CylinderGeometry")g=t.parameters.heightSegments+2,M=t.parameters.radialSegments;else if(t.userData.type==="ConeGeometry")g=t.parameters.heightSegments+1,M=t.parameters.radialSegments;else if(t.userData.type==="TorusGeometry"){let H=t.userData.parameters;g=Math.ceil(H.tubularSegments*H.arc/(2*Math.PI))+2,M=H.radialSegments}else{let{pathSegments:H,segments:ie,revolutions:pe}=t.userData.parameters;g=Math.ceil(ie*pe)+2,M=H}N?(i=new Uint32Array(1*M*3+(g-1)*M*4),o=new Uint8Array(1*M+(g-1)*M)):(i=new Uint32Array(2*M*3+(g-2)*M*4),o=new Uint8Array(2*M+(g-2)*M));let v=0,C=0,$=0;if(t.userData.type==="SphereGeometry"||t.userData.type==="HelixGeometry"||t.userData.type==="TorusGeometry"){for(;C<3*M;)i[C++]=x[v++],i[C++]=x[v++],i[C++]=x[v++],o[$++]=3;let H=N?i.length:3*M+4*(g-2)*M;for(;C<H;v+=6)i[C++]=x[v],i[C++]=x[v+1],i[C++]=x[v+4],i[C++]=x[v+5],o[$++]=4}else for(;C<4*(g-2)*M;v+=6)i[C++]=x[v],i[C++]=x[v+1],i[C++]=x[v+4],i[C++]=x[v+5],o[$++]=4;for(;C<i.length;)i[C++]=x[v++],i[C++]=x[v++],i[C++]=x[v++],o[$++]=3;break;default:i=x,o=new Uint8Array(u/3).fill(3);break}}let l=r.length,c=i.length,p=o.length,h=r.length+s.length+a.length,d=i.length+o.length,m=h*Float32Array.BYTES_PER_ELEMENT+d*Uint32Array.BYTES_PER_ELEMENT,f=h*Float32Array.BYTES_PER_ELEMENT,T=d*Uint32Array.BYTES_PER_ELEMENT,w=me._malloc(m),y=new Float32Array(me.HEAPF32.buffer,w,h),L=new Uint32Array(me.HEAPU32.buffer,w+f,d);y.set(r,0),y.set(s,r.length),y.set(a,r.length+s.length),L.set(i,0),L.set(o,i.length);let A;(b=e==null?void 0:e.scaleBaked)!=null&&b.some(V=>V!==1)&&(A=new gv().makeScale(...e.scaleBaked)),n&&(A?A.premultiply(n):A=n);let I=A?me.alloc_subdivision_surface2(w,l,w+f,c,w+f+i.length*Uint32Array.BYTES_PER_ELEMENT,p,A.elements):me.alloc_subdivision_surface(w,l,w+f,c,w+f+i.length*Uint32Array.BYTES_PER_ELEMENT,p);return me._free(w),I}static buildLevel(n,t,e,r,i){let o=i?me.get_mesh_data2(n,t?me.Level.CONTROL:me.Level.REFINED,e!=null?e:!t,i.elements):me.get_mesh_data(n,t?me.Level.CONTROL:me.Level.REFINED,e!=null?e:!t),s=8,a=me.HEAPU32.subarray(o>>2,(o>>2)+s),l=a.subarray(4,4+4),c=0,p=me.HEAPU32[a[c]>>2],h=me.HEAPF32.subarray(p>>2,(p>>2)+l[c]);c++;let d=me.HEAPU32[a[c]>>2],m=me.HEAPF32.subarray(d>>2,(d>>2)+l[c]);c++;let f=me.HEAPU32[a[c]>>2],T=me.HEAPU32.subarray(f>>2,(f>>2)+l[c]);c++;let w=me.HEAPU32[a[c]>>2],y=me.HEAPU32.subarray(w>>2,(w>>2)+l[c]);if(c++,r===void 0){let L=new kd;if(L.setIndex(new Tl(y,1)),L.setAttribute("position",new Nl(h,3)),L.setAttribute("normal",new Nl(m,3)),t){L.setAttribute("faceMap",new Tl(T,1));let A=new Float32Array(m.length/3*4).fill(0);L.setAttribute("color",new Hd(A,4))}return me.free_mesh_data(o),L.userData.type="SubdivGeometry",L}r.getAttribute("position").copyArray(h),r.getAttribute("normal").copyArray(m),r.attributes.position.needsUpdate=!0,r.attributes.normal.needsUpdate=!0,me.free_mesh_data(o)}static buildControlCageWireframe(n,t,e){let r=me.get_wireframe_data_for_base_level(n),i=4,o=me.HEAPU32.subarray(r>>2,(r>>2)+i),s=o.subarray(2,2+2),a=0,l=me.HEAPU32[o[a]>>2],c=me.HEAPF32.subarray(l>>2,(l>>2)+s[a]);a++;let p=me.HEAPU32[o[a]>>2],h=me.HEAPU32.subarray(p>>2,(p>>2)+s[a]);if(t===void 0){let d=new kd;d.setAttribute("position",new Nl(c,3));let m=new Float32Array(c.length);for(let f=0,T=c.length;f<T;)m[f++]=e.r,m[f++]=e.g,m[f++]=e.b;return d.setAttribute("color",new Hd(m,3)),d.setIndex(new Tl(h,1)),me.free_wireframe_data_for_base_level(r),d}t.getAttribute("position").copyArray(c),t.attributes.position.needsUpdate=!0,me.free_wireframe_data_for_base_level(r)}static updateCollabMesh(n,t,e){t||me.set_destination_refinement_level(n,1);let r=e?me.get_topological_data2(n,t?me.Level.CONTROL:me.Level.REFINED,e.elements):me.get_topological_data(n,t?me.Level.CONTROL:me.Level.REFINED),i=6,o=me.HEAPU32.subarray(r>>2,(r>>2)+i),s=o.subarray(3,3+3),a=0,l=me.HEAPU32[o[a]>>2],c=new Float32Array(me.HEAPF32.subarray(l>>2,(l>>2)+s[a]));a++;let p=me.HEAPU32[o[a]>>2],h=new Uint32Array(me.HEAPU32.subarray(p>>2,(p>>2)+s[a]));a++;let d=me.HEAPU32[o[a]>>2],m=new Uint8Array(me.HEAPU32.subarray(d>>2,(d>>2)+s[a]));return me.free_topological_data(r),{positions:c,indices:h,verticesPerFace:m}}};function bv(n,t){let e=n;return e=Math.min(e,3-Math.ceil(Math.log(t/172e3)/Math.log(4))),Math.max(e,0)}var Ml={ConeGeometry:Yh,CubeGeometry:Xh,CylinderGeometry:Kh,DodecahedronGeometry:Zh,EllipseGeometry:wd,HelixGeometry:Md,IcosahedronGeometry:Od,LatheGeometry:Id,NonParametricGeometry:_d,PolygonGeometry:Bd,PyramidGeometry:Ed,RectangleGeometry:Ws,SphereGeometry:Gd,PlaneGeometry:zd,StarGeometry:Rd,TextFrameGeometry:$s,TorusGeometry:Vd,TorusKnotGeometry:Fd,TriangleGeometry:jd,VectorGeometry:ht},en=n=>Ml[n.type].create(n);import{HemisphereLight as Jd}from"three";import{Color as vv}from"three";var Pt=class extends vv{constructor(e,r,i,o){super(e,r,i);this.isColorA=!0;this.a=o}setRGBA(e,r,i,o){super.setRGB(e,r,i),this.a=o}copy(e){return super.copy(e),this.a="a"in e?e.a:1,this}clone(){return new this.constructor(this.r,this.g,this.b,this.a)}get x(){return this.r}get y(){return this.g}get z(){return this.b}get w(){return this.a}set x(e){this.r=e}set y(e){this.g=e}set z(e){this.b=e}set w(e){this.a=e}};function Ye(n,t){let e;if(typeof n=="string"){let r=t==null?void 0:t.getColor(n);r?e=r:(console.warn("Tried to create color layer params with a color key that does not exist in the assets manager"),e=new Pt(0,0,0,0))}else return"a"in n?new Pt(n.r,n.g,n.b,n.a):new Pt(n.r,n.g,n.b,1);return e}var Ks=n=>"isEntity"in n,io=n=>"isAbstractMesh"in n,Kd=n=>n.objectType==="CombinedCamera";var Or=n=>"objectHelper"in n;function Sv(n,t){var r;let e=!1;t.position&&(n.position.fromArray(t.position),e=!0),t.rotation&&(n.rotation.fromArray(t.rotation),e=!0),t.scale&&(e=!0,n.scale.fromArray(t.scale)),t.hiddenMatrix!==void 0&&"hiddenMatrix"in n&&(e=!0,n.hiddenMatrix.fromArray((r=t.hiddenMatrix)!=null?r:Ur.identity)),e&&n.updateMatrix(),t.position&&t.rotation&&t.scale&&t.hiddenMatrix!==void 0&&n.updateWorldMatrix(!1,!0),n.objectType==="CombinedCamera"&&(t.isUpVectorFlipped!==void 0&&(n.isUpVectorFlipped=t.isUpVectorFlipped),n.updateUp())}function wv(n,t){Sv(n,t),t.name!==void 0&&(n.name=t.name),t.visible!==void 0&&(n.isEntity?n.visibility=t.visible:n.visible=t.visible)}function Yd(n,t,e){wv(n,t),t.color!==void 0&&(n.color=Ye(t.color,e)),t.intensity!==void 0&&(n.intensity=t.intensity),t.shadows!==void 0&&!(n instanceof Jd)&&(n.castShadow=t.shadows),n.shadow&&!(n instanceof Jd)&&t.depth!==void 0&&(n.shadow.camera.far=t.depth,n.shadow.needsUpdate=!0),t.helper!==void 0&&Or(n)&&(n.enableHelper=t.helper,n.gizmos.shadowmap.visible=t.helper)}function Xd(n,t){n.shadow.camera.right=t/2,n.shadow.camera.left=-t/2,n.shadow.camera.top=t/2,n.shadow.camera.bottom=-t/2,n.shadow.needsUpdate=!0}import{VideoTexture as vS}from"three";import{Mesh as Iv}from"three";import{Matrix4 as Il}from"three";import{Box3 as Qd,Line3 as $t,Matrix4 as Ol,Vector3 as Ve}from"three";var oo=new Qd,dt=new Ve,le=new Ve,et=new Ol;function Lv(n,t,e=0,r=t.count){let i=1/0,o=1/0,s=1/0,a=-1/0,l=-1/0,c=-1/0;for(let p=e;p<r;p++){let h=t.getX(p),d=t.getY(p),m=t.getZ(p);h<i&&(i=h),d<o&&(o=d),m<s&&(s=m),h>a&&(a=h),d>l&&(l=d),m>c&&(c=m)}return n.min.set(i,o,s),n.max.set(a,l,c),n}var Zd=(n,t,e,r)=>{var i;if(io(n)){let o=n.geometry.userData.parameters,s=n.geometry.getAttribute("position");n.geometry.userData.type==="SubdivGeometry"?dt.copy(n.originalGeometry.boundingSphere.center):(Lv(oo,s,n.geometry.drawRange.start,n.geometry.drawRange.count<1/0?n.geometry.drawRange.count:s.count),oo.getCenter(dt)),n.forceComputeSize?oo.getSize(le).multiplyScalar(.5):le.set(o.width,o.height,(i=o.depth)!=null?i:0).multiplyScalar(.5)}else if(Or(n)&&r===!0){let o=n.geometryHelper.getAttribute("position");oo.setFromArray(o.array),oo.getCenter(dt),oo.getSize(le).multiplyScalar(.5)}else dt.setScalar(0),le.setScalar(0);et.copy(t).multiply(n.matrixWorld),le.x===0&&le.y===0&&le.z===0?e.push(new Ve(dt.x,dt.y,dt.z).applyMatrix4(et)):e.push(new Ve(-le.x,le.y,le.z).add(dt).applyMatrix4(et),new Ve(-le.x,-le.y,le.z).add(dt).applyMatrix4(et),new Ve(le.x,-le.y,le.z).add(dt).applyMatrix4(et),new Ve(le.x,le.y,le.z).add(dt).applyMatrix4(et),new Ve(-le.x,le.y,-le.z).add(dt).applyMatrix4(et),new Ve(-le.x,-le.y,-le.z).add(dt).applyMatrix4(et),new Ve(le.x,-le.y,-le.z).add(dt).applyMatrix4(et),new Ve(le.x,le.y,-le.z).add(dt).applyMatrix4(et))},tn=class extends Qd{constructor(){super(...arguments);this.matrix=new Ol;this.vertices=[];this.faces=[];this.edges=[];this.centerEdges=[]}copy(e){return super.copy(e),this.matrix.copy(e.matrix),this.vertices=e.vertices.map(r=>r.clone()),this.faces=e.faces.map(r=>r.clone()),this.edges=e.edges.map(r=>r.clone()),this.centerEdges=e.centerEdges.map(r=>r.clone()),this}setFromObjectSize(e,r=!1){e.updateWorldMatrix(!1,r),this.makeEmpty(),this.matrix.copy(e.matrixWorld);let i=new Ol().copy(e.matrixWorld).invert();return this.expandByObjectSize(e,i,r)}expandByObjectSize(e,r,i=!1){let o=[];return i===!0?e.traverseEntity(s=>{s.visible&&Zd(s,r,o,e.enableHelper===!0)}):Zd(e,r,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(et.copy(this.matrix).setPosition(0,0,0)),e}computeVertices(){this.getSize(le).multiplyScalar(.5),this.getCenter(dt),et.copy(this.matrix).setPosition(dt),this.vertices=[new Ve(-le.x,le.y,le.z).applyMatrix4(et),new Ve(-le.x,-le.y,le.z).applyMatrix4(et),new Ve(le.x,-le.y,le.z).applyMatrix4(et),new Ve(le.x,le.y,le.z).applyMatrix4(et),new Ve(-le.x,le.y,-le.z).applyMatrix4(et),new Ve(-le.x,-le.y,-le.z).applyMatrix4(et),new Ve(le.x,-le.y,-le.z).applyMatrix4(et),new Ve(le.x,le.y,-le.z).applyMatrix4(et)]}computeEdges(){this.vertices.length>0&&this.computeVertices(),this.edges=[new $t(this.vertices[0],this.vertices[3]),new $t(this.vertices[1],this.vertices[2]),new $t(this.vertices[5],this.vertices[6]),new $t(this.vertices[4],this.vertices[7]),new $t(this.vertices[0],this.vertices[1]),new $t(this.vertices[3],this.vertices[2]),new $t(this.vertices[7],this.vertices[6]),new $t(this.vertices[4],this.vertices[5]),new $t(this.vertices[0],this.vertices[4]),new $t(this.vertices[1],this.vertices[5]),new $t(this.vertices[2],this.vertices[6]),new $t(this.vertices[3],this.vertices[7])],this.centerEdges=this.edges.map(e=>e.getCenter(new Ve))}computeFaces(){this.vertices.length>0&&this.computeVertices(),this.faces=[new Ve().copy(this.vertices[0]).sub(this.vertices[2]).multiplyScalar(.5).add(this.vertices[2]),new Ve().copy(this.vertices[7]).sub(this.vertices[5]).multiplyScalar(.5).add(this.vertices[5]),new Ve().copy(this.vertices[4]).sub(this.vertices[1]).multiplyScalar(.5).add(this.vertices[1]),new Ve().copy(this.vertices[3]).sub(this.vertices[6]).multiplyScalar(.5).add(this.vertices[6]),new Ve().copy(this.vertices[4]).sub(this.vertices[3]).multiplyScalar(.5).add(this.vertices[3]),new Ve().copy(this.vertices[1]).sub(this.vertices[6]).multiplyScalar(.5).add(this.vertices[6])]}};import{Object3D as Cv,Matrix4 as Tv,Light as Nv}from"three";function rn(n){let t=[];for(let e in n){let r=n[e];delete r.metadata,t.push(r)}return t}function Mv(n){let t=[];for(let e in n)t.push(n[e]);return t}var Ys=n=>class extends n{hasEntityChild(){return this.children.some(e=>Ks(e))}isDescendantOf(e){e instanceof Cv&&(e=e.uuid);let r=this;for(;r.parent;){if(r.parent.uuid===e)return!0;r=r.parent}return!1}attach(e,r){this.updateWorldMatrix(!0,!1);let i=new Tv().copy(this.matrixWorld).invert();return e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),i.multiply(e.parent.matrixWorld)),Ks(e)?e.hiddenMatrix.premultiply(i):e.applyMatrix4(i),e.updateWorldMatrix(!1,!1),this.add(e),r!==void 0&&(this.children.pop(),this.children.splice(r,0,e)),this}copy(e,r=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.userData=JSON.parse(JSON.stringify(e.userData)),r===!0)for(let i=0;i<e.children.length;i++){let o=e.children[i];this.add(o.clone())}return this}toJSON(e){let r=e===void 0,i={object:{uuid:"",objectType:""}};e===void 0&&(e={geometries:{},materials:{},textures:{},images:{},interactionStates:{},nodes:{}},i.metadata={version:1.5,type:"Object",generator:"Object3D.toJSON"});let o={uuid:this.uuid,objectType:this.type};if(this.name!==""&&(o.name=this.name),o.matrix=this.matrix.toArray(),this.castShadow===!0&&(o.castShadow=!0),this.receiveShadow===!0&&(o.receiveShadow=!0),this.visible===!1&&(o.visible=!1),this.frustumCulled===!1&&(o.frustumCulled=!1),this.renderOrder!==0&&(o.renderOrder=this.renderOrder),o.layers=this.layers.mask,JSON.stringify(this.userData)!=="{}"&&(o.userData=this.userData),this.children.length>0){o.children=[];for(let s of this.children)(Ks(s)||s instanceof Nv)&&o.children.push(s.toJSON(e).object)}if(r){let s=rn(e.geometries),a=rn(e.materials),l=rn(e.textures),c=rn(e.images),p=rn(e.interactionStates),h=Mv(e.nodes);s.length>0&&(i.geometries=s),a.length>0&&(i.materials=a),l.length>0&&(i.textures=l),c.length>0&&(i.images=c),p.length>0&&(i.interactionStates=p),h.length>0&&(i.nodes=h)}return i.object=o,i}fromJSON(e){return this.uuid=e.uuid,e.name!==void 0&&(this.name=e.name),e.matrix!==void 0?(this.matrix.fromArray(e.matrix),e.matrixAutoUpdate!==void 0&&(this.matrixAutoUpdate=e.matrixAutoUpdate),this.matrixAutoUpdate&&this.matrix.decompose(this.position,this.quaternion,this.scale)):(e.position!==void 0&&this.position.fromArray(e.position),e.rotation!==void 0&&this.rotation.fromArray(e.rotation),e.quaternion!==void 0&&this.quaternion.fromArray(e.quaternion),e.scale!==void 0&&this.scale.fromArray(e.scale)),this.castShadow=e.castShadow!==void 0,this.receiveShadow=e.receiveShadow!==void 0,e.visible!==void 0&&(this.visible=e.visible),e.frustumCulled!==void 0&&(this.frustumCulled=e.frustumCulled),e.renderOrder!==void 0&&(this.renderOrder=e.renderOrder),e.layers!==void 0&&(this.layers.mask=e.layers),e.userData!==void 0&&(this.userData=e.userData),this}};var Jt=n=>"isEntity"in n;var Kt=n=>class extends Ys(n){constructor(){super(...arguments);this.objectType="";this.isEntity=!0;this.raycastLock=!1;this.scaleLock=!1;this.hiddenMatrix=new Il;this._singleBBox=new tn;this._recursiveBBox=new tn;this.singleBBoxNeedsUpdate=!0;this.recursiveBBoxNeedsUpdate=!0;this.forceComputeSize=!1}set visibility(r){this.visible=r;for(let i of this.children)Jt(i)&&i.traverseEntity(o=>{Or(o)&&o.visible&&(o.objectHelper.visible=r)})}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(r=>{Jt(r)&&(r.singleBBoxNeedsUpdate=!0,r.recursiveBBoxNeedsUpdate=!0)}),this.traverseEntity(r=>{r.singleBBoxNeedsUpdate=!0,r.recursiveBBoxNeedsUpdate=!0})}traverseEntity(r){r(this);for(let i of this.children)Jt(i)&&i.traverseEntity(r)}updateMatrixWorld(r){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||r)&&(this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,r=!0);for(let i of this.children)i.updateMatrixWorld(r)}updateWorldMatrix(r,i){let o=this.parent;if(r&&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)),i)for(let s of this.children)s.updateWorldMatrix(!1,!0)}shallowClone(r){return new this.constructor().shallowCopy(this,r)}shallowCopy(r,i=!0){if(super.copy(r,!1),this.raycastLock=r.raycastLock,this.scaleLock=r.scaleLock,this.hiddenMatrix.copy(r.hiddenMatrix),i===!0)for(let o of r.children)Jt(o)&&this.add(o.shallowClone());return this}clone(r){return new this.constructor().copy(this,r)}copy(r,i=!0){if(super.copy(r,!1),this.raycastLock=r.raycastLock,this.scaleLock=r.scaleLock,this.hiddenMatrix.copy(r.hiddenMatrix),i===!0)for(let o of r.children)Jt(o)&&this.add(o.clone());return this}keepChildrenMatrixWorld(){let r=new Il,i=this.matrixWorld.clone();this.updateWorldMatrix(!1,!1),r.copy(this.matrixWorld).invert(),r.multiply(i);for(let o of this.children)Jt(o)&&o.hiddenMatrix.premultiply(r)}toJSON(r){let i=super.toJSON(r),o=i.object;return this.raycastLock===!0&&(o.raycastLock=!0),this.scaleLock===!0&&(o.scaleLock=!0),o.hiddenMatrix=this.hiddenMatrix.toArray(),i}fromJSON(r){return super.fromJSON(r),r.raycastLock!==void 0&&(this.raycastLock=r.raycastLock),r.scaleLock!==void 0&&(this.scaleLock=r.scaleLock),this.hiddenMatrix.fromArray(r.hiddenMatrix),this}fromObject3D(r){let i=r.children;return r.children=[],Object.assign(r,{raycastLock:!1,scaleLock:!1,hiddenMatrix:new Il}),this.copy(r),r.children=i,this}toObjectTransformState(r=[]){this.updateWorldMatrix(!0,!1);let i={position:this.position.toArray(),rotation:[this.rotation.x,this.rotation.y,this.rotation.z],scale:this.scale.toArray(),hiddenMatrix:this.hiddenMatrix.toArray()};return Fi(i,r)}fromObjectTransformState(r){return r.position&&this.position.fromArray(r.position),r.rotation&&this.rotation.fromArray(r.rotation),r.scale&&this.scale.fromArray(r.scale),r.hiddenMatrix&&this.hiddenMatrix.fromArray(r.hiddenMatrix),this.updateMatrix(),this}toState(r=[]){let i=P({name:this.name,visible:this.visible,raycastLock:this.raycastLock},this.toObjectTransformState(r));return Fi(i,r)}fromState(r,i){return r.name&&(this.name=r.name),r.raycastLock!==void 0&&(this.raycastLock=r.raycastLock),r.type!=="OrthographicCamera"&&r.type!=="PerspectiveCamera"&&(this.matrixAutoUpdate=!1),r.visible!==void 0&&(this.visibility=r.visible),this.fromObjectTransformState(r),this}};import{Object3D as Ov,Vector3 as on,Euler as eu,MathUtils as Kr}from"three";var ui=class extends Ov{constructor(e,r={}){super();this.object=e;let i=e.recursiveBBox.getSize(new on),o=.1;this.parameters=cs.defaultData(i.toArray(),o),ai(this.parameters,r),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 r of this.object.material)r.visible=!0;if(e){let r=this.object.material.map(i=>i.clone());for(let i of this.children)i.material=r}else for(let r of this.children)r.material=this.object.material}for(let r of this.object.material)r.visible=!e}else{if(this.children.length>0)if(this.object.material.visible=!0,e){let r=this.object.material.clone();for(let i of this.children)i.material=r}else for(let r of this.children)r.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 r=0,i=e-this.children.length;r<i;++r){let o=this.object.shallowClone(!1);o.visible=!0,this.add(o),this.parameters.hideBase&&this.setHideBase(!0)}else for(let r=0,i=this.children.length-e;r<i;++r)this.remove(this.children[0])}_updateRadial(e){let r=e.radial,i=r.start*Kr.DEG2RAD,o=r.end*Kr.DEG2RAD,s=i-o,a=new eu(r.rotation[0]*Kr.DEG2RAD,r.rotation[1]*Kr.DEG2RAD,r.rotation[2]*Kr.DEG2RAD),l;switch(r.axis){case"z":l=new on(0,0,1);break;case"y":l=new on(0,1,0);break;default:case"x":l=new on(1,0,0);break}for(let[c,p]of this.children.entries()){p.hiddenMatrix.identity(),p.scale.x=r.scale[0],p.scale.y=r.scale[1],p.scale.z=r.scale[2],p.position.setScalar(0);let h=s/e.count*c-i;switch(r.axis){case"x":p.rotation.set(0,h,0);break;case"y":p.rotation.set(0,0,h);break;case"z":p.rotation.set(h,0,0);break}p.translateOnAxis(l,r.radius),p.position.x+=r.position[0],p.position.y+=r.position[1],p.position.z+=r.position[2],r.alignment===!0?(p.rotation.x+=a.x,p.rotation.y+=a.y,p.rotation.z+=a.z):p.rotation.copy(a)}}_updateLinear(e){if(e.type!=="linear")throw new Error;let r=e.linear,i=new eu(r.rotation[0]*Kr.DEG2RAD,r.rotation[1]*Kr.DEG2RAD,r.rotation[2]*Kr.DEG2RAD);for(let[o,s]of this.children.entries())s.hiddenMatrix.identity(),s.scale.x=1+(r.scale[0]-1)*o,s.scale.y=1+(r.scale[1]-1)*o,s.scale.z=1+(r.scale[2]-1)*o,s.rotation.x=i.x*o,s.rotation.y=i.y*o,s.rotation.z=i.z*o,s.position.x=r.position[0]*o,s.position.y=r.position[1]*o,s.position.z=r.position[2]*o}_updateGrid(e){let r=0,i=e.grid;if(i.useCenter===!0){let o={x:i.count[0]%2===0?2:1,y:i.count[1]%2===0?2:1,z:i.count[2]%2===0?2:1},s=new on(i.size[0]*(i.count[0]-o.x)*.5,i.size[1]*(i.count[1]-o.y)*.5,i.size[2]*(i.count[2]-o.z)*.5);for(let a=0;a<i.count[0];a++)for(let l=0;l<i.count[1];l++)for(let c=0;c<i.count[2];c++){let p=this.children[r++];p.hiddenMatrix.identity(),p.scale.setScalar(1),p.rotation.set(0,0,0),p.position.x=i.size[0]*a-s.x,p.position.y=i.size[1]*l-s.y,p.position.z=i.size[2]*c-s.z}}else for(let o=0;o<i.count[0];o++)for(let s=0;s<i.count[1];s++)for(let a=0;a<i.count[2];a++){let l=this.children[r++];l.hiddenMatrix.identity(),l.scale.setScalar(1),l.rotation.set(0,0,0),l.position.x=i.size[0]*o,l.position.y=-i.size[1]*s,l.position.z=-i.size[2]*a}}fromJSON(e){return this}toJSON(){return{}}fromClonerState(e){return e.hideBase!==void 0&&this.setHideBase(e.hideBase),ai(this.parameters,e),this.update(),this}};var at=class extends Kt(Iv){constructor(e,r){super(e,r);this.isAbstractMesh=!0;Array.isArray(r)&&(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,r){Array.isArray(this.material)?(this.selectedMaterial===void 0&&(this.selectedMaterial=r!=null?r:0),r=r!=null?r:this.selectedMaterial,this.material[r].dispose(),this.material[r]=e):(this.material.dispose(),this.material=e)}updateGeometry(e){let r=this.geometry,i=Ml[r.userData.type],o=this.objectType==="NonParametric"?Object.assign({},r.userData,{geometry:r}):r.userData,s=i.build(i.normalizeInputs(e,o)),a=r.uuid;if(this.geometry.dispose(),this.geometry=s,this.geometry.uuid=a,this.geometry.computeBoundingSphere(),this.cloner)for(let l of this.cloner.children)l.geometry=this.geometry}resizeGeometry(e,r,i){Qo.resizeGeometry(this.geometry,{width:e,height:r,depth:i})}shallowClone(e){return new this.constructor(this.geometry,this.material).shallowCopy(this,e)}clone(e){let r=this.objectType==="NonParametric"?Object.assign({},this.geometry.userData,{geometry:this.geometry.clone()}):this.geometry.userData,i=en(r),o=Array.isArray(this.material)?this.material.map(s=>s.clone()):this.material.clone();return new this.constructor(i,o).copy(this,e)}copy(e,r=!0){return super.copy(e,r),e.cloner&&(this.cloner=new ui(e,e.cloner.parameters),this.add(this.cloner)),this}setFromClonerState(e){e===null?this.cloner=void 0:(this.cloner===void 0&&(this.cloner=new ui(this)),this.cloner.fromClonerState(e))}fromState(e,r){var i,o;return super.fromState(e),e.type==="Mesh"&&(this.setFromClonerState(e.cloner),this.castShadow=(i=e.castShadow)!=null?i:!0,this.receiveShadow=(o=e.receiveShadow)!=null?o:!0),this}};import{NormalBlending as Yv,ShaderMaterial as Xv,FrontSide as Zv}from"three";import{CubeReflectionMapping as jv,CubeRefractionMapping as Uv,CubeUVReflectionMapping as kv,LinearEncoding as nu,sRGBEncoding as Hv}from"three";var nn=class{constructor(t){t=t!=null?t:{},this.name=t.name,this.type=t.type,this.node=t.node,this.size=t.size,this.needsUpdate=t.needsUpdate}get value(){return this.node.value}set value(t){this.node.value=t}};import{MathUtils as Pv}from"three";var de=class{constructor(t){this.hashProperties=void 0;this.isNode=!0;this.shortcuts={};this.uuid=Pv.generateUUID(),this.type=t,this.name="",this.userData={}}analyze(t,e){e=e!=null?e:{},t.analyzing=!0,this.build(t.addFlow(e.slot,e.cache,e.context),"v4"),t.clearVertexNodeCode(),t.clearFragmentNodeCode(),t.removeFlow(),t.analyzing=!1}analyzeAndFlow(t,e,r){return r=r!=null?r:{},this.analyze(t,r),this.flow(t,e,r)}flow(t,e,r){r=r!=null?r:{},t.addFlow(r.slot,r.cache,r.context);let i={result:this.build(t,e),code:t.clearNodeCode(),extra:t.context.extra};return t.removeFlow(),i}build(t,e,r){e=e!=null?e:this.getType(t,e);let i=t.getNodeData(r!=null?r:this);return t.analyzing&&this.appendDepsNode(t,i,e),t.nodes.indexOf(this)===-1&&t.nodes.push(this),this.updateFrame!==void 0&&t.updaters.indexOf(this)===-1&&t.updaters.push(this),this.generate(t,e,r)}updateFrame(t){}generateReadonly(t,e,r,i,o,s){return""}generate(t,e,r,i,o){return""}parse(t,e,r,i){}appendDepsNode(t,e,r){e.deps=(e.deps||0)+1;let i=t.getTypeLength(r);(i>(e.outputMax||0)||this.getType(t,r))&&(e.outputMax=i,e.output=r)}setName(t){this.name=t}getName(){return this.name}getType(t,e){return e==="sampler2D"||e==="samplerCube"?e:this.type}getJSONNode(t){if((t==null?void 0:t.materials)&&(t==null?void 0:t.materials[this.uuid])!==void 0)return t.materials[this.uuid]}getHash(){let t="{",e,r;for(e in this)r=this[e],r instanceof de&&(t+='"'+e+'":'+r.getHash()+",");if(this.hashProperties)for(let i=0;i<this.hashProperties.length;i++)e=this.hashProperties[i],r=this[e],t+='"'+e+'":"'+String(r)+'",';return t+='"id":"'+this.uuid+'"}',t}copy(t){return this.name=t.name,t.type&&(this.type=t.type),t.frameId&&(this.frameId=t.frameId),t.hashProperties&&(this.hashProperties=t.hashProperties.map(e=>e)),this.userData=JSON.parse(JSON.stringify(t.userData)),this.shortcuts=JSON.parse(JSON.stringify(t.shortcuts)),this}clone(){return new this.constructor().copy(this)}createJSONNode(t){let e=t===void 0||typeof t=="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),!e&&t&&(t.nodes[this.uuid]=r),r}toJSON(t){var e;return(e=this.getJSONNode(t))!=null?e:this.createJSONNode(t)}fromJSON(t,e){return this.uuid=t.uuid,this.type=t.type,t.name&&(this.name=t.name),t.userData&&(this.userData=t.userData),this}};var Pl=class{constructor(){this.nodes={};this.keywords={}}add(t){this.nodes[t.name]=t}addKeyword(t,e,r){r=r!==void 0?r:!0,this.keywords[t]={callback:e,cache:r}}remove(t){delete this.nodes[t.name]}removeKeyword(t){delete this.keywords[t]}get(t){return this.nodes[t]}getKeyword(t,e){return this.keywords[t].callback(e)}getKeywordData(t){return this.keywords[t]}contains(t){return this.nodes[t]!==void 0}containsKeyword(t){return this.keywords[t]!==void 0}},ot=new Pl;import{Vector2 as tu}from"three";import{MathUtils as Av}from"three";var fe=class extends de{constructor(e,r){super(e);this.scope="";r=r!=null?r:{},this.shared=r.shared!==void 0?r.shared:!0,this.unique=r.unique!==void 0?r.unique:!1}build(e,r,i,o){if(r=r!=null?r:this.getType(e),this.getShared(e,r)){let s=this.getUnique(e,r);s&&this.uuid===void 0&&(this.uuid=Av.generateUUID()),i=e.getUUID(i!=null?i:this.getUUID(),!s);let a=e.getNodeData(i),l=a.output||this.getType(e);if(e.analyzing)return(a.deps||0)>0||this.getLabel()?(this.appendDepsNode(e,a,r),this.generate(e,r,i)):super.build(e,r,i);if(s)return a.name=a.name||super.build(e,r,i),a.name;if(!this.getLabel()&&(!this.getShared(e,l)||e.context.ignoreCache||a.deps===1))return super.build(e,r,i);i=this.getUUID(!1);let c=this.getTemp(e,i);if(c)return e.format(c,l,r);{c=super.generate(e,r,i,a.output,o);let p=this.generate(e,l,i);return e.addNodeCode(c+" = "+p+";"),e.format(c,l,r)}}return super.build(e,r,i)}getShared(e,r){return r!=="sampler2D"&&r!=="samplerCube"&&this.shared}getUnique(e,r){return this.unique}setLabel(e){return this.label=e,this}getLabel(){return this.label}getUUID(e){let r=this.uuid;return typeof this.scope=="string"&&(r=this.scope+"-"+r),r}getTemp(e,r){r=r||this.uuid;let i=e.getVars()[r];return i?i.name:void 0}generate(e,r,i,o,s){return this.getShared(e,r)||console.error("TempNode is not shared"),i=i!=null?i:this.uuid,e.getTempVar(i,o!=null?o:this.getType(e),s,this.getLabel()).name}};var Fe=class extends fe{constructor(e,r){r=r!=null?r:{},r.shared=r.shared!==void 0?r.shared:!1;super(e,r);this.readonly=!1}setReadonly(e){return this.readonly=e,this.hashProperties=this.readonly?["value"]:void 0,this}getReadonly(){return this.readonly}createJSONNode(e){let r=super.createJSONNode(e);return this.readonly===!0&&(r.readonly=this.readonly),r}fromJSON(e,r){return super.fromJSON(e,r),e.readonly!==void 0&&this.setReadonly(e.readonly),this}generate(e,r,i,o,s,a){i=e.getUUID(i!=null?i:this.getUUID()),o=o!=null?o:this.getType(e);let l=e.getNodeData(i);return this.getReadonly()&&this.generateReadonly!==void 0?this.generateReadonly(e,r,i,o,s,a):e.isShader("vertex")?(l.vertex||(l.vertex=e.createVertexUniform(o,this,s,a,this.getLabel())),e.format(l.vertex.name,o,r)):(l.fragment||(l.fragment=e.createFragmentUniform(o,this,s,a,this.getLabel())),e.format(l.fragment.name,o,r))}copy(e){return super.copy(e),this.readonly=e.readonly,this}};var bt=class extends Fe{constructor(e=0,r){super("v2");this.nodeType="Vector2";this.value=e instanceof tu?e:new tu(e,r)}get x(){return this.value.x}set x(e){this.value.x=e}get y(){return this.value.y}set y(e){this.value.y=e}generateReadonly(e,r,i,o,s,a){return e.format("vec2("+this.value.x+", "+this.value.y+")",o,r)}copy(e){return super.copy(e),this.value.copy(e.value),this}};import{Vector3 as ru}from"three";var vt=class extends Fe{constructor(e=0,r,i){super("v3");this.nodeType="Vector3";this.value=e instanceof ru?e:new ru(e,r,i)}get x(){return this.value.x}set x(e){this.value.x=e}get y(){return this.value.y}set y(e){this.value.y=e}get z(){return this.value.z}set z(e){this.value.z=e}generateReadonly(e,r,i,o,s,a){return e.format("vec3("+this.value.x+", "+this.value.y+", "+this.value.z+")",o,r)}copy(e){return super.copy(e),this.value.copy(e.value),this}};var Ir=class extends Fe{constructor(e){super("v4");this.nodeType="Vector4";this.value=e instanceof Pt?e:new Pt(e.r,e.g,e.b,e.a)}generateReadonly(e,r,i,o,s,a){return e.format("vec4("+this.value.r+", "+this.value.g+", "+this.value.b+", "+this.value.a+")",o,r)}copy(e){return super.copy(e),this.value.copy(e.value),this}};var Dv=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,iu=/[a-z_0-9]+/gi,re=class extends fe{constructor(e,r,i,o,s){super(s);this.src="";this.nodeType="Function";this.useKeywords=!0;this.includes=[];this.extensions={};this.keywords={};this.isMethod=s===void 0,this.isInterface=!1,this.parse(e,r,i,o)}getShared(e,r){return!this.isMethod}getType(e){return e.getTypeByFormat(this.type)}getInputByName(e){if(this.inputs){let r=this.inputs.length;for(;r--;)if(this.inputs[r].name===e)return this.inputs[r]}}getIncludeByName(e){if(this.includes){let r=this.includes.length;for(;r--;)if(this.includes[r].name===e)return this.includes[r]}}generate(e,r,i,o,s){let a,l=0,c=this.src;if(this.includes)for(let h=0;h<this.includes.length;h++)e.include(this.includes[h],this);for(let h in this.extensions)e.extensions[h]=!0;let p=[];for(;a=iu.exec(this.src);)p.push(a);for(let h=0;h<p.length;h++){let d=p[h],m=d[0],f=this.isMethod?!this.getInputByName(m):!0,T=m;if(this.keywords[m]||this.useKeywords&&f&&ot.containsKeyword(m)){let w=this.keywords[m];if(!w){let y=ot.getKeywordData(m);y.cache&&(w=e.keywords[m]),w=w||ot.getKeyword(m,e),y.cache&&(e.keywords[m]=w)}T=w.build(e)}m!==T&&(c=c.substring(0,d.index+l)+T+c.substring(d.index+m.length+l),l+=T.length-m.length),this.getIncludeByName(T)===void 0&&ot.contains(T)&&e.include(ot.get(T))}return r==="source"?c:this.isMethod?(this.isInterface||e.include(this,void 0,c),this.name):e.format("( "+c+" )",this.getType(e),r)}parse(e,r,i,o){if(this.src=e||"",this.includes=r!=null?r:[],this.extensions=i!=null?i:{},this.keywords=o!=null?o:{},this.isMethod){let s=Dv.exec(this.src);if(this.inputs=[],s&&s.length==4){this.type=s[1],this.name=s[2];let a=s[3].match(iu);if(a){let l=0;for(;l<a.length;){let c=a[l++],p;c==="in"||c==="out"||c==="inout"?p=a[l++]:(p=c,c="");let h=a[l++];this.inputs.push({name:h,type:p,qualifier:c})}}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 i;let r=this.getJSONNode(e);if(!r){r=this.createJSONNode(e),r.src=this.src,r.isMethod=this.isMethod,r.useKeywords=this.useKeywords,this.isMethod||(r.type=this.type),r.extensions=JSON.parse(JSON.stringify(this.extensions));let o={};for(let s in this.keywords)o[s]=this.keywords[s].toJSON(e).uuid;if(r.keywords=o,(i=this.includes)!=null&&i.length){let s=[];for(let a=0;a<this.includes.length;a++)s.push(this.includes[a].toJSON(e).uuid);r.includes=s}r.isMethod=this.isMethod,r.inputs=this.inputs}return r.nodeType=this.nodeType,r}fromJSON(e,r){if(super.fromJSON(e,r),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&&r){this.keywords={};for(let i in e.keywords)this.keywords[i]=r.getNode(e.keywords[i])}return e.includes&&r&&(this.includes=e.includes.map(i=>r.getNode(i))),this}};var _v=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=?\s?(.*?)(\;|$)/i,Al=class extends fe{constructor(e="",r){super();this.src="";this.useDefine=!1;this.nodeType="Const";this.parse(e||Al.PI,void 0,void 0,void 0,r)}getType(e){return e.getTypeByFormat(this.type)}parse(e,r,i,o,s){this.src=e||"";let a,l,c="",p=_v.exec(e);this.useDefine=s!=null?s:this.src.charAt(0)==="#",p&&p.length>1?(l=p[1],a=p[2],c=p[3]):(a=this.src,l="f"),this.name=a,this.type=l,this.value=c}build(e,r){if(r==="source"){if(this.value)return this.useDefine?"#define "+this.name+" "+this.value:"const "+this.type+" "+this.name+" = "+this.value+";";if(this.useDefine)return this.src}return e.include(this),e.format(this.name,this.getType(e),r)}generate(e,r,i,o,s){return e.format(this.name,this.getType(e),r)}copy(e){return super.copy(e),this.parse(e.src,void 0,void 0,void 0,e.useDefine),this}},Te=Al;Te.PI="PI",Te.PI2="PI2",Te.RECIPROCAL_PI="RECIPROCAL_PI",Te.RECIPROCAL_PI2="RECIPROCAL_PI2",Te.LOG2="LOG2",Te.EPSILON="EPSILON";var Bv=new RegExp(`^structs*([a-z_0-9]+)s*{s*((.|
|
|
2
|
-
)*?)}`,"gim"),
|
|
1
|
+
var am=Object.create;var Dn=Object.defineProperty,lm=Object.defineProperties,cm=Object.getOwnPropertyDescriptor,pm=Object.getOwnPropertyDescriptors,hm=Object.getOwnPropertyNames,tc=Object.getOwnPropertySymbols,dm=Object.getPrototypeOf,ic=Object.prototype.hasOwnProperty,um=Object.prototype.propertyIsEnumerable;var rc=(n,t,e)=>t in n?Dn(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,P=(n,t)=>{for(var e in t||(t={}))ic.call(t,e)&&rc(n,e,t[e]);if(tc)for(var e of tc(t))um.call(t,e)&&rc(n,e,t[e]);return n},W=(n,t)=>lm(n,pm(t));var mm=(n,t)=>()=>(t||n((t={exports:{}}).exports,t),t.exports),fm=(n,t)=>{for(var e in t)Dn(n,e,{get:t[e],enumerable:!0})},ym=(n,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of hm(t))!ic.call(n,i)&&i!==e&&Dn(n,i,{get:()=>t[i],enumerable:!(r=cm(t,i))||r.enumerable});return n};var gm=(n,t,e)=>(e=n!=null?am(dm(n)):{},ym(t||!n||!n.__esModule?Dn(e,"default",{value:n,enumerable:!0}):e,n));var Ru=mm((Sa,zu)=>{(function(n,t){typeof Sa=="object"&&typeof zu<"u"?t(Sa):typeof define=="function"&&define.amd?define(["exports"],t):t((n=typeof globalThis<"u"?globalThis:n||self).SVDJS={})})(Sa,function(n){"use strict";n.SVD=function(t,e,r,i,o){if(e=e===void 0||e,r=r===void 0||r,o=1e-64/(i=i||Math.pow(2,-52)),!t)throw new TypeError("Matrix a is not defined");var s,a,l,c,p,h,d,m,f,T,w,y,L=t[0].length,A=t.length;if(A<L)throw new TypeError("Invalid matrix: m < n");for(var I=[],b=[],V=[],x=e==="f"?A:L,u=T=d=0;u<A;u++)b[u]=new Array(x).fill(0);for(u=0;u<L;u++)V[u]=new Array(L).fill(0);var M,g=new Array(L).fill(0);for(u=0;u<A;u++)for(s=0;s<L;s++)b[u][s]=t[u][s];for(u=0;u<L;u++){for(I[u]=d,f=0,l=u+1,s=u;s<A;s++)f+=Math.pow(b[s][u],2);if(f<o)d=0;else for(m=(h=b[u][u])*(d=h<0?Math.sqrt(f):-Math.sqrt(f))-f,b[u][u]=h-d,s=l;s<L;s++){for(f=0,a=u;a<A;a++)f+=b[a][u]*b[a][s];for(h=f/m,a=u;a<A;a++)b[a][s]=b[a][s]+h*b[a][u]}for(g[u]=d,f=0,s=l;s<L;s++)f+=Math.pow(b[u][s],2);if(f<o)d=0;else{for(m=(h=b[u][u+1])*(d=h<0?Math.sqrt(f):-Math.sqrt(f))-f,b[u][u+1]=h-d,s=l;s<L;s++)I[s]=b[u][s]/m;for(s=l;s<A;s++){for(f=0,a=l;a<L;a++)f+=b[s][a]*b[u][a];for(a=l;a<L;a++)b[s][a]=b[s][a]+f*I[a]}}T<(w=Math.abs(g[u])+Math.abs(I[u]))&&(T=w)}if(r)for(u=L-1;0<=u;u--){if(d!==0){for(m=b[u][u+1]*d,s=l;s<L;s++)V[s][u]=b[u][s]/m;for(s=l;s<L;s++){for(f=0,a=l;a<L;a++)f+=b[u][a]*V[a][s];for(a=l;a<L;a++)V[a][s]=V[a][s]+f*V[a][u]}}for(s=l;s<L;s++)V[u][s]=0,V[s][u]=0;V[u][u]=1,d=I[u],l=u}if(e){if(e==="f")for(u=L;u<A;u++){for(s=L;s<A;s++)b[u][s]=0;b[u][u]=1}for(u=L-1;0<=u;u--){for(l=u+1,d=g[u],s=l;s<x;s++)b[u][s]=0;if(d!==0){for(m=b[u][u]*d,s=l;s<x;s++){for(f=0,a=l;a<A;a++)f+=b[a][u]*b[a][s];for(h=f/m,a=u;a<A;a++)b[a][s]=b[a][s]+h*b[a][u]}for(s=u;s<A;s++)b[s][u]=b[s][u]/d}else for(s=u;s<A;s++)b[s][u]=0;b[u][u]=b[u][u]+1}}for(i*=T,a=L-1;0<=a;a--)for(var N=0;N<50;N++){for(M=!1,l=a;0<=l;l--){if(Math.abs(I[l])<=i){M=!0;break}if(Math.abs(g[l-1])<=i)break}if(!M){for(p=0,c=l-(f=1),u=l;u<a+1&&(h=f*I[u],I[u]=p*I[u],!(Math.abs(h)<=i));u++)if(d=g[u],g[u]=Math.sqrt(h*h+d*d),p=d/(m=g[u]),f=-h/m,e)for(s=0;s<A;s++)w=b[s][c],y=b[s][u],b[s][c]=w*p+y*f,b[s][u]=-w*f+y*p}if(y=g[a],l===a){if(y<0&&(g[a]=-y,r))for(s=0;s<L;s++)V[s][a]=-V[s][a];break}for(T=g[l],h=(((w=g[a-1])-y)*(w+y)+((d=I[a-1])-(m=I[a]))*(d+m))/(2*m*w),d=Math.sqrt(h*h+1),h=((T-y)*(T+y)+m*(w/(h<0?h-d:h+d)-m))/T,u=l+(f=p=1);u<a+1;u++){if(d=I[u],w=g[u],m=f*d,d*=p,y=Math.sqrt(h*h+m*m),h=T*(p=h/(I[u-1]=y))+d*(f=m/y),d=-T*f+d*p,m=w*f,w*=p,r)for(s=0;s<L;s++)T=V[s][u-1],y=V[s][u],V[s][u-1]=T*p+y*f,V[s][u]=-T*f+y*p;if(y=Math.sqrt(h*h+m*m),h=(p=h/(g[u-1]=y))*d+(f=m/y)*w,T=-f*d+p*w,e)for(s=0;s<A;s++)w=b[s][u-1],y=b[s][u],b[s][u-1]=w*p+y*f,b[s][u]=-w*f+y*p}I[l]=0,I[a]=h,g[a]=T}for(u=0;u<L;u++)g[u]<i&&(g[u]=0);return{u:b,q:g,v:V}},n.VERSION="1.1.1",Object.defineProperty(n,"__esModule",{value:!0})})});import{FileLoader as zw,Loader as Rw}from"three";function oc(n){return Array.isArray(n)?n:[n]}var xm=typeof global=="object"&&global&&global.Object===Object&&global,_n=xm;var bm=typeof self=="object"&&self&&self.Object===Object&&self,vm=_n||bm||Function("return this")(),Ze=vm;var Sm=Ze.Symbol,Lt=Sm;var nc=Object.prototype,wm=nc.hasOwnProperty,Lm=nc.toString,Po=Lt?Lt.toStringTag:void 0;function Cm(n){var t=wm.call(n,Po),e=n[Po];try{n[Po]=void 0;var r=!0}catch{}var i=Lm.call(n);return r&&(t?n[Po]=e:delete n[Po]),i}var sc=Cm;var Tm=Object.prototype,Nm=Tm.toString;function Mm(n){return Nm.call(n)}var ac=Mm;var Om="[object Null]",Im="[object Undefined]",lc=Lt?Lt.toStringTag:void 0;function Pm(n){return n==null?n===void 0?Im:Om:lc&&lc in Object(n)?sc(n):ac(n)}var Bt=Pm;function Am(n){return n!=null&&typeof n=="object"}var gt=Am;var Dm="[object Symbol]";function _m(n){return typeof n=="symbol"||gt(n)&&Bt(n)==Dm}var wi=_m;function Bm(n,t){for(var e=-1,r=n==null?0:n.length,i=Array(r);++e<r;)i[e]=t(n[e],e,n);return i}var Bn=Bm;var Em=Array.isArray,Qe=Em;var Gm=1/0,cc=Lt?Lt.prototype:void 0,pc=cc?cc.toString:void 0;function hc(n){if(typeof n=="string")return n;if(Qe(n))return Bn(n,hc)+"";if(wi(n))return pc?pc.call(n):"";var t=n+"";return t=="0"&&1/n==-Gm?"-0":t}var dc=hc;function zm(n){var t=typeof n;return n!=null&&(t=="object"||t=="function")}var xt=zm;function Rm(n){return n}var En=Rm;var Vm="[object AsyncFunction]",Fm="[object Function]",jm="[object GeneratorFunction]",Um="[object Proxy]";function km(n){if(!xt(n))return!1;var t=Bt(n);return t==Fm||t==jm||t==Vm||t==Um}var Li=km;var Hm=Ze["__core-js_shared__"],Gn=Hm;var uc=function(){var n=/[^.]+$/.exec(Gn&&Gn.keys&&Gn.keys.IE_PROTO||"");return n?"Symbol(src)_1."+n:""}();function qm(n){return!!uc&&uc in n}var mc=qm;var Wm=Function.prototype,$m=Wm.toString;function Jm(n){if(n!=null){try{return $m.call(n)}catch{}try{return n+""}catch{}}return""}var wr=Jm;var Km=/[\\^$.*+?()[\]{}|]/g,Ym=/^\[object .+?Constructor\]$/,Xm=Function.prototype,Zm=Object.prototype,Qm=Xm.toString,ef=Zm.hasOwnProperty,tf=RegExp("^"+Qm.call(ef).replace(Km,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function rf(n){if(!xt(n)||mc(n))return!1;var t=Li(n)?tf:Ym;return t.test(wr(n))}var fc=rf;function of(n,t){return n==null?void 0:n[t]}var yc=of;function nf(n,t){var e=yc(n,t);return fc(e)?e:void 0}var Ot=nf;var sf=Ot(Ze,"WeakMap"),zn=sf;var gc=Object.create,af=function(){function n(){}return function(t){if(!xt(t))return{};if(gc)return gc(t);n.prototype=t;var e=new n;return n.prototype=void 0,e}}(),xc=af;function lf(n,t,e){switch(e.length){case 0:return n.call(t);case 1:return n.call(t,e[0]);case 2:return n.call(t,e[0],e[1]);case 3:return n.call(t,e[0],e[1],e[2])}return n.apply(t,e)}var bc=lf;function cf(n,t){var e=-1,r=n.length;for(t||(t=Array(r));++e<r;)t[e]=n[e];return t}var Rn=cf;var pf=800,hf=16,df=Date.now;function uf(n){var t=0,e=0;return function(){var r=df(),i=hf-(r-e);if(e=r,i>0){if(++t>=pf)return arguments[0]}else t=0;return n.apply(void 0,arguments)}}var vc=uf;function mf(n){return function(){return n}}var Sc=mf;var ff=function(){try{var n=Ot(Object,"defineProperty");return n({},"",{}),n}catch{}}(),Ci=ff;var yf=Ci?function(n,t){return Ci(n,"toString",{configurable:!0,enumerable:!1,value:Sc(t),writable:!0})}:En,wc=yf;var gf=vc(wc),Vn=gf;function xf(n,t){for(var e=-1,r=n==null?0:n.length;++e<r&&t(n[e],e,n)!==!1;);return n}var Lc=xf;var bf=9007199254740991,vf=/^(?:0|[1-9]\d*)$/;function Sf(n,t){var e=typeof n;return t=t==null?bf:t,!!t&&(e=="number"||e!="symbol"&&vf.test(n))&&n>-1&&n%1==0&&n<t}var Fn=Sf;function wf(n,t,e){t=="__proto__"&&Ci?Ci(n,t,{configurable:!0,enumerable:!0,value:e,writable:!0}):n[t]=e}var Ti=wf;function Lf(n,t){return n===t||n!==n&&t!==t}var Gr=Lf;var Cf=Object.prototype,Tf=Cf.hasOwnProperty;function Nf(n,t,e){var r=n[t];(!(Tf.call(n,t)&&Gr(r,e))||e===void 0&&!(t in n))&&Ti(n,t,e)}var jn=Nf;function Mf(n,t,e,r){var i=!e;e||(e={});for(var o=-1,s=t.length;++o<s;){var a=t[o],l=r?r(e[a],n[a],a,e,n):void 0;l===void 0&&(l=n[a]),i?Ti(e,a,l):jn(e,a,l)}return e}var kt=Mf;var Cc=Math.max;function Of(n,t,e){return t=Cc(t===void 0?n.length-1:t,0),function(){for(var r=arguments,i=-1,o=Cc(r.length-t,0),s=Array(o);++i<o;)s[i]=r[t+i];i=-1;for(var a=Array(t+1);++i<t;)a[i]=r[i];return a[t]=e(s),bc(n,this,a)}}var Un=Of;function If(n,t){return Vn(Un(n,t,En),n+"")}var Tc=If;var Pf=9007199254740991;function Af(n){return typeof n=="number"&&n>-1&&n%1==0&&n<=Pf}var kn=Af;function Df(n){return n!=null&&kn(n.length)&&!Li(n)}var zr=Df;function _f(n,t,e){if(!xt(e))return!1;var r=typeof t;return(r=="number"?zr(e)&&Fn(t,e.length):r=="string"&&t in e)?Gr(e[t],n):!1}var Nc=_f;function Bf(n){return Tc(function(t,e){var r=-1,i=e.length,o=i>1?e[i-1]:void 0,s=i>2?e[2]:void 0;for(o=n.length>3&&typeof o=="function"?(i--,o):void 0,s&&Nc(e[0],e[1],s)&&(o=i<3?void 0:o,i=1),t=Object(t);++r<i;){var a=e[r];a&&n(t,a,r,o)}return t})}var Mc=Bf;var Ef=Object.prototype;function Gf(n){var t=n&&n.constructor,e=typeof t=="function"&&t.prototype||Ef;return n===e}var Ni=Gf;function zf(n,t){for(var e=-1,r=Array(n);++e<n;)r[e]=t(e);return r}var Oc=zf;var Rf="[object Arguments]";function Vf(n){return gt(n)&&Bt(n)==Rf}var Ca=Vf;var Ic=Object.prototype,Ff=Ic.hasOwnProperty,jf=Ic.propertyIsEnumerable,Uf=Ca(function(){return arguments}())?Ca:function(n){return gt(n)&&Ff.call(n,"callee")&&!jf.call(n,"callee")},ni=Uf;function kf(){return!1}var Pc=kf;var _c=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Ac=_c&&typeof module=="object"&&module&&!module.nodeType&&module,Hf=Ac&&Ac.exports===_c,Dc=Hf?Ze.Buffer:void 0,qf=Dc?Dc.isBuffer:void 0,Wf=qf||Pc,Mi=Wf;var $f="[object Arguments]",Jf="[object Array]",Kf="[object Boolean]",Yf="[object Date]",Xf="[object Error]",Zf="[object Function]",Qf="[object Map]",ey="[object Number]",ty="[object Object]",ry="[object RegExp]",iy="[object Set]",oy="[object String]",ny="[object WeakMap]",sy="[object ArrayBuffer]",ay="[object DataView]",ly="[object Float32Array]",cy="[object Float64Array]",py="[object Int8Array]",hy="[object Int16Array]",dy="[object Int32Array]",uy="[object Uint8Array]",my="[object Uint8ClampedArray]",fy="[object Uint16Array]",yy="[object Uint32Array]",je={};je[ly]=je[cy]=je[py]=je[hy]=je[dy]=je[uy]=je[my]=je[fy]=je[yy]=!0;je[$f]=je[Jf]=je[sy]=je[Kf]=je[ay]=je[Yf]=je[Xf]=je[Zf]=je[Qf]=je[ey]=je[ty]=je[ry]=je[iy]=je[oy]=je[ny]=!1;function gy(n){return gt(n)&&kn(n.length)&&!!je[Bt(n)]}var Bc=gy;function xy(n){return function(t){return n(t)}}var Oi=xy;var Ec=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Ao=Ec&&typeof module=="object"&&module&&!module.nodeType&&module,by=Ao&&Ao.exports===Ec,Ta=by&&_n.process,vy=function(){try{var n=Ao&&Ao.require&&Ao.require("util").types;return n||Ta&&Ta.binding&&Ta.binding("util")}catch{}}(),Lr=vy;var Gc=Lr&&Lr.isTypedArray,Sy=Gc?Oi(Gc):Bc,Hn=Sy;var wy=Object.prototype,Ly=wy.hasOwnProperty;function Cy(n,t){var e=Qe(n),r=!e&&ni(n),i=!e&&!r&&Mi(n),o=!e&&!r&&!i&&Hn(n),s=e||r||i||o,a=s?Oc(n.length,String):[],l=a.length;for(var c in n)(t||Ly.call(n,c))&&!(s&&(c=="length"||i&&(c=="offset"||c=="parent")||o&&(c=="buffer"||c=="byteLength"||c=="byteOffset")||Fn(c,l)))&&a.push(c);return a}var qn=Cy;function Ty(n,t){return function(e){return n(t(e))}}var Wn=Ty;var Ny=Wn(Object.keys,Object),zc=Ny;var My=Object.prototype,Oy=My.hasOwnProperty;function Iy(n){if(!Ni(n))return zc(n);var t=[];for(var e in Object(n))Oy.call(n,e)&&e!="constructor"&&t.push(e);return t}var Rc=Iy;function Py(n){return zr(n)?qn(n):Rc(n)}var Ii=Py;function Ay(n){var t=[];if(n!=null)for(var e in Object(n))t.push(e);return t}var Vc=Ay;var Dy=Object.prototype,_y=Dy.hasOwnProperty;function By(n){if(!xt(n))return Vc(n);var t=Ni(n),e=[];for(var r in n)r=="constructor"&&(t||!_y.call(n,r))||e.push(r);return e}var Fc=By;function Ey(n){return zr(n)?qn(n,!0):Fc(n)}var nr=Ey;var Gy=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,zy=/^\w*$/;function Ry(n,t){if(Qe(n))return!1;var e=typeof n;return e=="number"||e=="symbol"||e=="boolean"||n==null||wi(n)?!0:zy.test(n)||!Gy.test(n)||t!=null&&n in Object(t)}var jc=Ry;var Vy=Ot(Object,"create"),Cr=Vy;function Fy(){this.__data__=Cr?Cr(null):{},this.size=0}var Uc=Fy;function jy(n){var t=this.has(n)&&delete this.__data__[n];return this.size-=t?1:0,t}var kc=jy;var Uy="__lodash_hash_undefined__",ky=Object.prototype,Hy=ky.hasOwnProperty;function qy(n){var t=this.__data__;if(Cr){var e=t[n];return e===Uy?void 0:e}return Hy.call(t,n)?t[n]:void 0}var Hc=qy;var Wy=Object.prototype,$y=Wy.hasOwnProperty;function Jy(n){var t=this.__data__;return Cr?t[n]!==void 0:$y.call(t,n)}var qc=Jy;var Ky="__lodash_hash_undefined__";function Yy(n,t){var e=this.__data__;return this.size+=this.has(n)?0:1,e[n]=Cr&&t===void 0?Ky:t,this}var Wc=Yy;function Pi(n){var t=-1,e=n==null?0:n.length;for(this.clear();++t<e;){var r=n[t];this.set(r[0],r[1])}}Pi.prototype.clear=Uc;Pi.prototype.delete=kc;Pi.prototype.get=Hc;Pi.prototype.has=qc;Pi.prototype.set=Wc;var Na=Pi;function Xy(){this.__data__=[],this.size=0}var $c=Xy;function Zy(n,t){for(var e=n.length;e--;)if(Gr(n[e][0],t))return e;return-1}var Rr=Zy;var Qy=Array.prototype,eg=Qy.splice;function tg(n){var t=this.__data__,e=Rr(t,n);if(e<0)return!1;var r=t.length-1;return e==r?t.pop():eg.call(t,e,1),--this.size,!0}var Jc=tg;function rg(n){var t=this.__data__,e=Rr(t,n);return e<0?void 0:t[e][1]}var Kc=rg;function ig(n){return Rr(this.__data__,n)>-1}var Yc=ig;function og(n,t){var e=this.__data__,r=Rr(e,n);return r<0?(++this.size,e.push([n,t])):e[r][1]=t,this}var Xc=og;function Ai(n){var t=-1,e=n==null?0:n.length;for(this.clear();++t<e;){var r=n[t];this.set(r[0],r[1])}}Ai.prototype.clear=$c;Ai.prototype.delete=Jc;Ai.prototype.get=Kc;Ai.prototype.has=Yc;Ai.prototype.set=Xc;var Vr=Ai;var ng=Ot(Ze,"Map"),Fr=ng;function sg(){this.size=0,this.__data__={hash:new Na,map:new(Fr||Vr),string:new Na}}var Zc=sg;function ag(n){var t=typeof n;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?n!=="__proto__":n===null}var Qc=ag;function lg(n,t){var e=n.__data__;return Qc(t)?e[typeof t=="string"?"string":"hash"]:e.map}var jr=lg;function cg(n){var t=jr(this,n).delete(n);return this.size-=t?1:0,t}var ep=cg;function pg(n){return jr(this,n).get(n)}var tp=pg;function hg(n){return jr(this,n).has(n)}var rp=hg;function dg(n,t){var e=jr(this,n),r=e.size;return e.set(n,t),this.size+=e.size==r?0:1,this}var ip=dg;function Di(n){var t=-1,e=n==null?0:n.length;for(this.clear();++t<e;){var r=n[t];this.set(r[0],r[1])}}Di.prototype.clear=Zc;Di.prototype.delete=ep;Di.prototype.get=tp;Di.prototype.has=rp;Di.prototype.set=ip;var Do=Di;var ug="Expected a function";function Ma(n,t){if(typeof n!="function"||t!=null&&typeof t!="function")throw new TypeError(ug);var e=function(){var r=arguments,i=t?t.apply(this,r):r[0],o=e.cache;if(o.has(i))return o.get(i);var s=n.apply(this,r);return e.cache=o.set(i,s)||o,s};return e.cache=new(Ma.Cache||Do),e}Ma.Cache=Do;var op=Ma;var mg=500;function fg(n){var t=op(n,function(r){return e.size===mg&&e.clear(),r}),e=t.cache;return t}var np=fg;var yg=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,gg=/\\(\\)?/g,xg=np(function(n){var t=[];return n.charCodeAt(0)===46&&t.push(""),n.replace(yg,function(e,r,i,o){t.push(i?o.replace(gg,"$1"):r||e)}),t}),sp=xg;function bg(n){return n==null?"":dc(n)}var ap=bg;function vg(n,t){return Qe(n)?n:jc(n,t)?[n]:sp(ap(n))}var _i=vg;var Sg=1/0;function wg(n){if(typeof n=="string"||wi(n))return n;var t=n+"";return t=="0"&&1/n==-Sg?"-0":t}var $n=wg;function Lg(n,t){t=_i(t,n);for(var e=0,r=t.length;n!=null&&e<r;)n=n[$n(t[e++])];return e&&e==r?n:void 0}var lp=Lg;function Cg(n,t){for(var e=-1,r=t.length,i=n.length;++e<r;)n[i+e]=t[e];return n}var Bi=Cg;var cp=Lt?Lt.isConcatSpreadable:void 0;function Tg(n){return Qe(n)||ni(n)||!!(cp&&n&&n[cp])}var pp=Tg;function hp(n,t,e,r,i){var o=-1,s=n.length;for(e||(e=pp),i||(i=[]);++o<s;){var a=n[o];t>0&&e(a)?t>1?hp(a,t-1,e,r,i):Bi(i,a):r||(i[i.length]=a)}return i}var dp=hp;function Ng(n){var t=n==null?0:n.length;return t?dp(n,1):[]}var up=Ng;function Mg(n){return Vn(Un(n,void 0,up),n+"")}var mp=Mg;var Og=Wn(Object.getPrototypeOf,Object),Ei=Og;var Ig="[object Object]",Pg=Function.prototype,Ag=Object.prototype,fp=Pg.toString,Dg=Ag.hasOwnProperty,_g=fp.call(Object);function Bg(n){if(!gt(n)||Bt(n)!=Ig)return!1;var t=Ei(n);if(t===null)return!0;var e=Dg.call(t,"constructor")&&t.constructor;return typeof e=="function"&&e instanceof e&&fp.call(e)==_g}var Jn=Bg;function Eg(n,t,e){var r=-1,i=n.length;t<0&&(t=-t>i?0:i+t),e=e>i?i:e,e<0&&(e+=i),i=t>e?0:e-t>>>0,t>>>=0;for(var o=Array(i);++r<i;)o[r]=n[r+t];return o}var yp=Eg;function Gg(){this.__data__=new Vr,this.size=0}var gp=Gg;function zg(n){var t=this.__data__,e=t.delete(n);return this.size=t.size,e}var xp=zg;function Rg(n){return this.__data__.get(n)}var bp=Rg;function Vg(n){return this.__data__.has(n)}var vp=Vg;var Fg=200;function jg(n,t){var e=this.__data__;if(e instanceof Vr){var r=e.__data__;if(!Fr||r.length<Fg-1)return r.push([n,t]),this.size=++e.size,this;e=this.__data__=new Do(r)}return e.set(n,t),this.size=e.size,this}var Sp=jg;function Gi(n){var t=this.__data__=new Vr(n);this.size=t.size}Gi.prototype.clear=gp;Gi.prototype.delete=xp;Gi.prototype.get=bp;Gi.prototype.has=vp;Gi.prototype.set=Sp;var Kn=Gi;function Ug(n,t){return n&&kt(t,Ii(t),n)}var wp=Ug;function kg(n,t){return n&&kt(t,nr(t),n)}var Lp=kg;var Mp=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Cp=Mp&&typeof module=="object"&&module&&!module.nodeType&&module,Hg=Cp&&Cp.exports===Mp,Tp=Hg?Ze.Buffer:void 0,Np=Tp?Tp.allocUnsafe:void 0;function qg(n,t){if(t)return n.slice();var e=n.length,r=Np?Np(e):new n.constructor(e);return n.copy(r),r}var Yn=qg;function Wg(n,t){for(var e=-1,r=n==null?0:n.length,i=0,o=[];++e<r;){var s=n[e];t(s,e,n)&&(o[i++]=s)}return o}var Op=Wg;function $g(){return[]}var Xn=$g;var Jg=Object.prototype,Kg=Jg.propertyIsEnumerable,Ip=Object.getOwnPropertySymbols,Yg=Ip?function(n){return n==null?[]:(n=Object(n),Op(Ip(n),function(t){return Kg.call(n,t)}))}:Xn,zi=Yg;function Xg(n,t){return kt(n,zi(n),t)}var Pp=Xg;var Zg=Object.getOwnPropertySymbols,Qg=Zg?function(n){for(var t=[];n;)Bi(t,zi(n)),n=Ei(n);return t}:Xn,Zn=Qg;function ex(n,t){return kt(n,Zn(n),t)}var Ap=ex;function tx(n,t,e){var r=t(n);return Qe(n)?r:Bi(r,e(n))}var Qn=tx;function rx(n){return Qn(n,Ii,zi)}var Dp=rx;function ix(n){return Qn(n,nr,Zn)}var es=ix;var ox=Ot(Ze,"DataView"),ts=ox;var nx=Ot(Ze,"Promise"),rs=nx;var sx=Ot(Ze,"Set"),is=sx;var _p="[object Map]",ax="[object Object]",Bp="[object Promise]",Ep="[object Set]",Gp="[object WeakMap]",zp="[object DataView]",lx=wr(ts),cx=wr(Fr),px=wr(rs),hx=wr(is),dx=wr(zn),si=Bt;(ts&&si(new ts(new ArrayBuffer(1)))!=zp||Fr&&si(new Fr)!=_p||rs&&si(rs.resolve())!=Bp||is&&si(new is)!=Ep||zn&&si(new zn)!=Gp)&&(si=function(n){var t=Bt(n),e=t==ax?n.constructor:void 0,r=e?wr(e):"";if(r)switch(r){case lx:return zp;case cx:return _p;case px:return Bp;case hx:return Ep;case dx:return Gp}return t});var Ri=si;var ux=Object.prototype,mx=ux.hasOwnProperty;function fx(n){var t=n.length,e=new n.constructor(t);return t&&typeof n[0]=="string"&&mx.call(n,"index")&&(e.index=n.index,e.input=n.input),e}var Rp=fx;var yx=Ze.Uint8Array,Oa=yx;function gx(n){var t=new n.constructor(n.byteLength);return new Oa(t).set(new Oa(n)),t}var Vi=gx;function xx(n,t){var e=t?Vi(n.buffer):n.buffer;return new n.constructor(e,n.byteOffset,n.byteLength)}var Vp=xx;var bx=/\w*$/;function vx(n){var t=new n.constructor(n.source,bx.exec(n));return t.lastIndex=n.lastIndex,t}var Fp=vx;var jp=Lt?Lt.prototype:void 0,Up=jp?jp.valueOf:void 0;function Sx(n){return Up?Object(Up.call(n)):{}}var kp=Sx;function wx(n,t){var e=t?Vi(n.buffer):n.buffer;return new n.constructor(e,n.byteOffset,n.length)}var os=wx;var Lx="[object Boolean]",Cx="[object Date]",Tx="[object Map]",Nx="[object Number]",Mx="[object RegExp]",Ox="[object Set]",Ix="[object String]",Px="[object Symbol]",Ax="[object ArrayBuffer]",Dx="[object DataView]",_x="[object Float32Array]",Bx="[object Float64Array]",Ex="[object Int8Array]",Gx="[object Int16Array]",zx="[object Int32Array]",Rx="[object Uint8Array]",Vx="[object Uint8ClampedArray]",Fx="[object Uint16Array]",jx="[object Uint32Array]";function Ux(n,t,e){var r=n.constructor;switch(t){case Ax:return Vi(n);case Lx:case Cx:return new r(+n);case Dx:return Vp(n,e);case _x:case Bx:case Ex:case Gx:case zx:case Rx:case Vx:case Fx:case jx:return os(n,e);case Tx:return new r;case Nx:case Ix:return new r(n);case Mx:return Fp(n);case Ox:return new r;case Px:return kp(n)}}var Hp=Ux;function kx(n){return typeof n.constructor=="function"&&!Ni(n)?xc(Ei(n)):{}}var ns=kx;var Hx="[object Map]";function qx(n){return gt(n)&&Ri(n)==Hx}var qp=qx;var Wp=Lr&&Lr.isMap,Wx=Wp?Oi(Wp):qp,$p=Wx;var $x="[object Set]";function Jx(n){return gt(n)&&Ri(n)==$x}var Jp=Jx;var Kp=Lr&&Lr.isSet,Kx=Kp?Oi(Kp):Jp,Yp=Kx;var Yx=1,Xx=2,Zx=4,Xp="[object Arguments]",Qx="[object Array]",e0="[object Boolean]",t0="[object Date]",r0="[object Error]",Zp="[object Function]",i0="[object GeneratorFunction]",o0="[object Map]",n0="[object Number]",Qp="[object Object]",s0="[object RegExp]",a0="[object Set]",l0="[object String]",c0="[object Symbol]",p0="[object WeakMap]",h0="[object ArrayBuffer]",d0="[object DataView]",u0="[object Float32Array]",m0="[object Float64Array]",f0="[object Int8Array]",y0="[object Int16Array]",g0="[object Int32Array]",x0="[object Uint8Array]",b0="[object Uint8ClampedArray]",v0="[object Uint16Array]",S0="[object Uint32Array]",Re={};Re[Xp]=Re[Qx]=Re[h0]=Re[d0]=Re[e0]=Re[t0]=Re[u0]=Re[m0]=Re[f0]=Re[y0]=Re[g0]=Re[o0]=Re[n0]=Re[Qp]=Re[s0]=Re[a0]=Re[l0]=Re[c0]=Re[x0]=Re[b0]=Re[v0]=Re[S0]=!0;Re[r0]=Re[Zp]=Re[p0]=!1;function ss(n,t,e,r,i,o){var s,a=t&Yx,l=t&Xx,c=t&Zx;if(e&&(s=i?e(n,r,i,o):e(n)),s!==void 0)return s;if(!xt(n))return n;var p=Qe(n);if(p){if(s=Rp(n),!a)return Rn(n,s)}else{var h=Ri(n),d=h==Zp||h==i0;if(Mi(n))return Yn(n,a);if(h==Qp||h==Xp||d&&!i){if(s=l||d?{}:ns(n),!a)return l?Ap(n,Lp(s,n)):Pp(n,wp(s,n))}else{if(!Re[h])return i?n:{};s=Hp(n,h,a)}}o||(o=new Kn);var m=o.get(n);if(m)return m;o.set(n,s),Yp(n)?n.forEach(function(w){s.add(ss(w,t,e,w,n,o))}):$p(n)&&n.forEach(function(w,y){s.set(y,ss(w,t,e,y,n,o))});var f=c?l?es:Dp:l?nr:Ii,T=p?void 0:f(n);return Lc(T||n,function(w,y){T&&(y=w,w=n[y]),jn(s,y,ss(w,t,e,y,n,o))}),s}var as=ss;var w0=1,L0=4;function C0(n){return as(n,w0|L0)}var _o=C0;function T0(n){return function(t,e,r){for(var i=-1,o=Object(t),s=r(t),a=s.length;a--;){var l=s[n?a:++i];if(e(o[l],l,o)===!1)break}return t}}var eh=T0;var N0=eh(),th=N0;function M0(n,t,e){(e!==void 0&&!Gr(n[t],e)||e===void 0&&!(t in n))&&Ti(n,t,e)}var Bo=M0;function O0(n){return gt(n)&&zr(n)}var rh=O0;function I0(n,t){if(!(t==="constructor"&&typeof n[t]=="function")&&t!="__proto__")return n[t]}var Eo=I0;function P0(n){return kt(n,nr(n))}var ih=P0;function A0(n,t,e,r,i,o,s){var a=Eo(n,e),l=Eo(t,e),c=s.get(l);if(c){Bo(n,e,c);return}var p=o?o(a,l,e+"",n,t,s):void 0,h=p===void 0;if(h){var d=Qe(l),m=!d&&Mi(l),f=!d&&!m&&Hn(l);p=l,d||m||f?Qe(a)?p=a:rh(a)?p=Rn(a):m?(h=!1,p=Yn(l,!0)):f?(h=!1,p=os(l,!0)):p=[]:Jn(l)||ni(l)?(p=a,ni(a)?p=ih(a):(!xt(a)||Li(a))&&(p=ns(l))):h=!1}h&&(s.set(l,p),i(p,l,r,o,s),s.delete(l)),Bo(n,e,p)}var oh=A0;function nh(n,t,e,r,i){n!==t&&th(t,function(o,s){if(i||(i=new Kn),xt(o))oh(n,t,s,e,nh,r,i);else{var a=r?r(Eo(n,s),o,s+"",n,t,i):void 0;a===void 0&&(a=o),Bo(n,s,a)}},nr)}var sh=nh;function D0(n){var t=n==null?0:n.length;return t?n[t-1]:void 0}var ah=D0;function _0(n,t){return t.length<2?n:lp(n,yp(t,0,-1))}var lh=_0;var B0=Mc(function(n,t,e){sh(n,t,e)}),ai=B0;function E0(n,t){return t=_i(t,n),n=lh(n,t),n==null||delete n[$n(ah(t))]}var ch=E0;function G0(n){return Jn(n)?void 0:n}var ph=G0;var z0=1,R0=2,V0=4,F0=mp(function(n,t){var e={};if(n==null)return e;var r=!1;t=Bn(t,function(o){return o=_i(o,n),r||(r=o.length>1),o}),kt(n,es(n),e),r&&(e=as(e,z0|R0|V0,ph));for(var i=t.length;i--;)ch(e,t[i]);return e}),Fi=F0;var ji;(e=>{e.all=["PerspectiveCamera","OrthographicCamera"];function t(r){return e.all.includes(r)}e.is=t})(ji||(ji={}));var li;(i=>{i.DefaultUp=[0,1,0],i.DefaultTargetOffset=1e3,i.defaultData={far:1e5,type:"OrthographicCamera",perspective:{near:5,fov:45,zoom:1},orthographic:{near:-1e5,zoom:1},up:i.DefaultUp,isUpVectorFlipped:!1,targetOffset:i.DefaultTargetOffset};function r(o){return o.type==="PerspectiveCamera"?o.perspective.zoom:o.orthographic.zoom}i.getZoom=r})(li||(li={}));var hh;(e=>{function n(r,i){return r[0]===i[0]&&r[1]===i[1]}e.isEqual=n;function t(r,i,o){return[r[0]+(i[0]-r[0])*o,r[1]+(i[1]-r[1])*o]}e.lerp=t})(hh||(hh={}));var Ui;(i=>{function n(o,s){return o[0]===s[0]&&o[1]===s[1]&&o[2]===s[2]}i.isEqual=n;function t(o,s){return[o[0]+s[0],o[1]+s[1],o[2]+s[2]]}i.add=t;function e(o,s){return[o[0]-s[0],o[1]-s[1],o[2]-s[2]]}i.sub=e;function r(o,s,a){return[o[0]+(s[0]-o[0])*a,o[1]+(s[1]-o[1])*a,o[2]+(s[2]-o[2])*a]}i.lerp=r})(Ui||(Ui={}));var dh;(e=>{function n(r,i){return r[0]===i[0]&&r[1]===i[1]&&r[2]===i[2]&&r[3]===i[3]}e.isEqual=n;function t(r,i,o){return[r[0]+(i[0]-r[0])*o,r[1]+(i[1]-r[1])*o,r[2]+(i[2]-r[2])*o,r[3]+(i[3]-r[3])*o]}e.lerp=t})(dh||(dh={}));var Ur;(o=>{o.identity=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];function t(s,a){for(let l=0;l<16;l++)if(s[l]!==a[l])return!1;return!0}o.isEqual=t;function e(s){return s!=null?s:o.identity}o.simplify=e;function r(s,a){let l=a.slice(0);for(var c=0,p=a.length;c<p;c+=3){let h=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])*h,l[c+1]=(s[1]*a[c]+s[5]*a[c+1]+s[9]*a[c+2]+s[13])*h,l[c+2]=(s[2]*a[c]+s[6]*a[c+1]+s[10]*a[c+2]+s[14])*h}return l}o.applyMatrix4=r;function i(s,a){let l=a.slice(0);for(var c=0,p=a.length;c<p;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}o.applyMatrix3Components=i})(Ur||(Ur={}));var Et;(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 i(c){return{r:c.r,g:c.g,b:c.b}}l.clone=i;function o(c){return c=Math.floor(c),{r:(c>>16&255)/255,g:(c>>8&255)/255,b:(c&255)/255}}l.fromHex=o;function s(c,p){return c.r===p.r&&c.g===p.g&&c.b===p.b}l.equals=s;function a(c,p,h){return{r:c.r+(p.r-c.r)*h,g:c.g+(p.g-c.g)*h,b:c.b+(p.b-c.b)*h}}l.lerp=a})(Et||(Et={}));var sr;(s=>{s.white=W(P({},Et.white),{a:1});function t(a){return{r:a[0],g:a[1],b:a[2],a:a[3]}}s.from0to1=t;function e(a,l){return W(P({},Et.fromHex(a)),{a:l})}s.fromHexAndA=e;function r(a){return{r:Math.round(a.r*255),g:Math.round(a.g*255),b:Math.round(a.b*255),a:a.a}}s.toRgb255a1=r;function i(a,l){return Et.equals(a,l)&&a.a===l.a}s.equals=i;function o(a,l,c){return{r:a.r+(l.r-a.r)*c,g:a.g+(l.g-a.g)*c,b:a.b+(l.b-a.b)*c,a:a.a+(l.a-a.a)*c}}s.lerp=o})(sr||(sr={}));var ls;(t=>t.identity={position:[0,0,0],rotation:[0,0,0],scale:[1,1,1]})(ls||(ls={}));var uh;(t=>t.defaultData={mass:1,stiffness:80,damping:10,velocity:0})(uh||(uh={}));var mh;(t=>t.defaultData={control1:[.5,.05],control2:[.1,.3]})(mh||(mh={}));var cs;(t=>{function n(e,r=.1){return{type:"radial",hideBase:!1,count:3,radial:{radius:Math.max(e[0],e[1])*2,start:0,end:360,alignment:!1,axis:"y",scale:[1,1,1],rotation:[0,0,0],position:[0,0,0]},linear:{scale:[1,1,1],rotation:[0,0,0],position:[e[0]+e[0]*r,0,0]},grid:{count:[2,2,2],size:e.map(i=>i*(1+r)),useCenter:!0}}}t.defaultData=n})(cs||(cs={}));var Ht=class{modifyById(t,e){let r=this;if(r[t]===void 0)throw new Error("not expected");{let o=W(P({},r),{[t]:e});return Object.setPrototypeOf(o,Ht.prototype),o}}add(t,e){var i;let r=this.runOp({type:1,id:t,data:e});return(i=r==null?void 0:r.data)!=null?i:this}runOp(t){let e=this;if(t.type===1){let r=e[t.id],i;r===void 0?i={type:2,id:t.id}:i={type:1,id:t.id,data:r};let{id:o,data:s}=t,a=W(P({},e),{[o]:s});return Object.setPrototypeOf(a,Ht.prototype),{data:a,actual:t,reverse:i}}else if(t.type===2){let{id:r}=t,i=e[r];if(i===void 0)return null;{let o=P({},e);return Object.setPrototypeOf(o,Ht.prototype),delete o[r],{data:o,actual:t,reverse:{type:1,id:r,data:i}}}}throw new Error("illegal arg")}};function Go(n){if(n.deepFreeze!==void 0){n.deepFreeze(n);return}let t=Object.getOwnPropertyNames(n);for(let e of t){let r=n[e];r&&typeof r=="object"&&Go(r)}return Object.freeze(n)}function fh(n,t){let e=0;for(;e<n.length&&e<t.length;){if(n[e]<t[e])return-1;if(n[e]>t[e])return 1;e+=1}return e!==t.length?-1:e!==n.length?1:0}var ps=class extends Error{};function ar(n,t,e){if(n===void 0?t===void 0?(n=0,t=10):n=t-10:t===void 0&&(t=n+10),n>t){let o=n;n=t,t=o}let r=[],i=1/(e+1);for(let o=0;o<e;o++){let s=n+(t-n)*(o+.75+Math.random()*.5)*i;r.push(s)}return r}function yh(n){return n instanceof Uint8Array||n instanceof Uint16Array||n instanceof Uint32Array||n instanceof Int8Array||n instanceof Int16Array||n instanceof Int32Array||n instanceof Float32Array||n instanceof Float64Array}function gh(){return typeof process<"u"}function xh(n,t){for(let e of n)t(e.id,e.data),xh(e.children,t)}function bh(n,t){t(n.id,n.data);for(let e of n.children)bh(e,t)}var qt=class extends Array{constructor(...e){super(...e);Object.setPrototypeOf(this,qt.prototype)}deepFreeze(){let e=0;for(;e<this.length;)Go(this[e]),e++}fillCaches0(e,r){this.objCaches.set(e.id,e),this.parentCaches.set(e.id,r);for(let i of e.children)this.fillCaches0(i,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,r){for(;e;){let i=this.parent(e);if(i===r)return!0;e=i}return!1}data(e){var r;return(r=this.get(e))==null?void 0:r.data}has(e){return this.childrenOf(e)!==void 0}get(e){return this.fillCaches(),this.objCaches.get(e)}childrenOf(e){var r;return e===null?this:(r=this.get(e))==null?void 0:r.children}traverseFrom(e,r){if(e===null)this.traverse(r);else{let i=this.get(e);i&&bh(i,r)}}traverse(e){xh(this,e)}totalSize(){return this.fillCaches(),this.objCaches.size}parent(e){return this.fillCaches(),this.parentCaches.get(e)}childrenArray(e){return e===null?this:this.get(e).children}modifyById(e,r){if(this.get(e)===void 0)throw new Error("not expected");{let o=this.parent(e),s=this.childrenArray(o),a=s.findIndex(p=>p.id===e);if(a<0)throw new Error("not expected");let l=s[a];return s=[...s],s[a]=W(P({},l),{data:r}),this.modifyArrayBy(o,s)}}modifyArrayBy(e,r){let i=e,o=r;for(;i!==null;){let a=o,l=i;if(i=this.parent(i),i===void 0)throw new Error;o=this.childrenArray(i);let c=o.findIndex(p=>p.id===l);if(c<0)throw new Error;o=[...o],o[c]=W(P({},o[c]),{children:a})}Object.setPrototypeOf(o,qt.prototype);let s=o;return s.fillCaches(),s}runOp(e){switch(e.type){case 7:return this.addOp(e);case 8:return this.deleteOp(e);case 9:return this.moveOp(e)}}checkDuplicatedIdRec({id:e,children:r}){if(this.get(e)!==void 0)return!0;for(let i of r)if(this.checkDuplicatedIdRec(i))return!0;return!1}addOp(e){let{parent:r,fi:i,id:o,data:s,children:a}=e;if(r!==null&&this.get(r)===void 0)return null;if(this.checkDuplicatedIdRec(e))return null;{let l=r,c=this.childrenArray(l),p={fi:i,id:o,data:s,children:a};return c=[...c,p],c.sort((d,m)=>d.fi-m.fi),e.localIndex=c.indexOf(p),{data:this.modifyArrayBy(l,c),actual:e,reverse:{type:8,id:o}}}}deleteOp(e){let{id:r}=e;if(this.get(r)===null)return null;{let i=this.parent(r);if(i===void 0)return null;let o=this.childrenArray(i),s=o.findIndex(c=>c.id===r);e.localIndex=s,o=[...o];let a=o.splice(s,1)[0];return{data:this.modifyArrayBy(i,o),actual:e,reverse:W(P({type:7},a),{parent:i})}}}moveOp(e){let{parent:r,fi:i,id:o}=e;if(r!==null&&this.get(r)===void 0)return this.deleteOp({type:8,id:o});if(r!==null){let m=r;for(;m!==null;){if(m===void 0)throw new Error;if(m===o)throw new ps("cyclic tree");m=this.parent(m)}}let s=this.parent(o);if(s===void 0)return null;let a=s,l=this.childrenArray(s),c=l.findIndex(m=>m.id===o);l=[...l];let p=l.splice(c,1)[0],h=this.modifyArrayBy(s,l);s=r,l=h.childrenArray(s);let d=p.fi;return p=W(P({},p),{fi:i}),l=[...l,p],l.sort((m,f)=>m.fi-f.fi),e.localIndex=l.indexOf(p),h=h.modifyArrayBy(s,l),{data:h,actual:e,reverse:{type:9,parent:a,fi:d,id:o}}}previous(e,r){if(r===null){let o=this.childrenArray(e);return o.length===0?null:o[o.length-1].id}let i=null;for(let o of this.childrenArray(e)){if(o.id===r)return i;i=o.id}return null}traverseSortNext(e){let r=this.parent(e);if(r!==void 0){let i=this.childrenArray(r),o=i.findIndex(s=>s.id===e)+1;if(o<i.length)return i[o].id;if(r)return this.traverseSortNext(r)}}sortNext(e){let r=this.childrenArray(e);return r.length>0?r[0].id:this.traverseSortNext(e)}traverseSortPrevious(e){let r=this.childrenArray(e);return r.length>0?this.traverseSortPrevious(r[r.length-1].id):e}sortPrevious(e){let r=this.parent(e);if(r!==void 0){let i=this.childrenArray(r),o=i.findIndex(s=>s.id===e)-1;return o>=0?this.traverseSortPrevious(i[o].id):r}}getAllSorted(e){let r=[];for(let i of e){let o=this.getWithSortKey(i.id);o!==void 0&&r.push(P(P({},i),o))}r.sort((i,o)=>fh(i.sortKey,o.sortKey));for(let i of r)delete i.sortKey;return r}getWithSortKey(e){var r=e;let i=[],o=this.get(r),s=o;if(o!==void 0){for(;r;)i.splice(0,0,o.fi),r=this.parent(r),r!==null&&(o=this.get(r));return W(P({},s),{sortKey:i})}}insertBeforeHelper(e,r,i){return this.insertAfterHelper(e,this.previous(e,r),i)}insertAfterHelper(e,r,i){let o=this.childrenArray(e);if(r===null){if(o.length===0)return ar(0,i,i);{let s=o[0].fi;return ar(s-i,s,i)}}else{let s=this.get(r);if(s===void 0||this.parent(r)!==e)throw new Error("illegal args");let a=o.find(l=>l.fi>s.fi);if(a===void 0){let l=o[o.length-1].fi;return ar(l,l+i,i)}else return ar(s.fi,a.fi,i)}}};var hs;(t=>{function n(e,r){if(Array.isArray(e)){let i=r.props,o={},s=[...e],a=!1;if(i)for(let l of Object.keys(i)){let c=parseInt(l);if(isNaN(c))throw new Error("wrong index");o[l]=s[c],s[c]=i[l],a=!0}return a?{data:s,actual:r,reverse:{type:0,props:o}}:null}else{let i=r.props,o={},s=P({},e),a=!1;if(i)for(let l of Object.keys(i)){o[l]=s[l];let c=i[l];c===void 0?delete s[l]:s[l]=c,a=!0}return a?{data:s,actual:r,reverse:{type:0,props:o}}:null}}t.runOp=n})(hs||(hs={}));var $e=class extends Array{constructor(...e){super(...e);Object.setPrototypeOf(this,$e.prototype)}deepFreeze(){let e=0;for(;e<this.length;)Go(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 r;return(r=this.get(e))==null?void 0:r.data}get(e){return this.fillCaches(),this.objCaches.get(e)}modifyById(e,r){if(this.get(e)===void 0)throw new Error("not expected");{let o=this,s=o.findIndex(c=>c.id===e);if(s<0)throw new Error("not expected");let a=o[s];return o=[...o],o[s]=W(P({},a),{data:r}),this.modifyArrayBy(o)}}modifyArrayBy(e){Object.setPrototypeOf(e,$e.prototype);let r=e;return gh()||r.fillCaches(),r}runOp(e){switch(e.type){case 4:return this.addOp(e);case 5:return this.deleteOp(e);case 6:return this.moveOp(e)}}addOp(e){let{fi:r,id:i,data:o}=e,s=this,a={fi:r,id:i,data:o};return s=[...s,a],s.sort((c,p)=>c.fi-p.fi),e.localIndex=s.indexOf(a),{data:this.modifyArrayBy(s),actual:e,reverse:{type:5,id:i}}}deleteOp(e){let{id:r}=e,i=this,o=i.findIndex(l=>l.id===r);if(o===-1)return null;e.localIndex=o,i=[...i];let s=i.splice(o,1)[0];return{data:this.modifyArrayBy(i),actual:e,reverse:P({type:4},s)}}moveOp(e){let{fi:r,id:i}=e,o=this;o=[...o];let s=o.findIndex(p=>p.id===i);if(s===-1)return null;let a=o[s].fi,l=W(P({},o[s]),{fi:r});return o[s]=l,o.sort((p,h)=>p.fi-h.fi),e.localIndex=o.indexOf(l),{data:this.modifyArrayBy(o),actual:e,reverse:{type:6,fi:a,id:i}}}previous(e){if(e===null)return this.length===0?null:this[this.length-1].id;let r=null;for(let i of this){if(i.id===e)return r;r=i.id}return null}insertBeforeHelper(e,r){return this.insertAfterHelper(this.previous(e),r)}insertAfterHelper(e,r){let i=this;if(e===null){if(i.length===0)return ar(0,r,r);{let o=i[0].fi;return ar(o-r,o,r)}}else{let o=this.get(e);if(o===void 0)throw new Error("illegal args");let s=i.find(a=>a.fi>o.fi);if(s===void 0){let a=i[i.length-1].fi;return ar(a,a+r,r)}else return ar(o.fi,s.fi,r)}}};var vh=Symbol(),us=Symbol(),ki=class{reportOp(t,e){let r=this;if(e===null)return;r._current=e.data;let i=[];for(;!(r instanceof ds);){let o=r._path,s=r._current;if(o!==""&&i.splice(0,0,o),r=r._parent,r===null)return;r.update(o,s)}r.push(i,t,e.actual,e.reverse)}deleteChildren(t){if(this._children){let e=this._children[t];if(e){let r=e[us];r&&r(),delete this._children[t]}}}},Pa=class extends ki{constructor(t,e,r){super(),this._parent=t,this._path=e,this._current=r}update(t,e){if(Array.isArray(this._current)){if(typeof t=="string"&&(t=parseInt(t),isNaN(t)))throw new Error("Invalid path");this._current=[...this._current],this._current[t]=e}else this._current=W(P({},this._current),{[t]:e})}runOp(t){this.reportOp(t,hs.runOp(this._current,t))}},Aa=class extends ki{constructor(t,e,r){super(),this._parent=t,this._path=e,this._current=r}update(t,e){this._current=W(P({},this._current),{[t]:e}),Object.setPrototypeOf(this._current,Ht.prototype)}runOp(t){this.reportOp(t,this._current.runOp(t))}},Sh={get(n,t){if(t===us)return()=>{n._parent=null};if(t===vh)return n._current;let{_current:e,_children:r}=n;if(t==="push"&&Array.isArray(e))throw new Error("not supported to expand array");let i=r===void 0?void 0:r[t];if(i!==void 0)return i;let o=e[t],s=ms(n,t,o);return s!==o?(r===void 0&&(r={},n._children=r),r[t]=s,s):o},has(n,t){return t in n._current},ownKeys(n){return Reflect.ownKeys(n._current)},defineProperty(){throw Error("not supported")},getPrototypeOf(n){return Object.getPrototypeOf(n._current)},setPrototypeOf(){throw Error("not supported")},getOwnPropertyDescriptor(n,t){let e=n._current,r=Reflect.getOwnPropertyDescriptor(e,t);return r&&{writable:!0,configurable:!0,enumerable:r.enumerable,value:e[t]}}},j0=W(P({},Sh),{set(n,t,e){var i;let r={type:0,props:{[t]:(i=Ba(e))!=null?i:e}};return n.deleteChildren(t),n.runOp(r),!0},deleteProperty(n,t){let e={type:0,props:{[t]:void 0}};return n.deleteChildren(t),n.runOp(e),!0}}),U0=W(P({},Sh),{set(n,t,e){return e===void 0?this.deleteProperty(n,t):(n.deleteChildren(t),n.runOp({type:1,id:t,data:e})),!0},deleteProperty(n,t){return n.runOp({type:2,id:t}),!0}}),Hi=class extends ki{constructor(t,e,r){super(),this._children={},this._parent=t,this._path=e,this._current=r,this[us]=()=>{this._parent=null}}unproxy(){return this._current}update(t,e){this._current=this._current.modifyById(t,e)}runOp(t){this.reportOp(t,this._current.runOp(t))}randomId(){return this._current.randomId()}isDescendantOf(t,e){return this._current.isDescendantOf(t,e)}childrenOf(t){return this._current.childrenOf(t)}traverse(t){return this._current.traverse(t)}get(t){return this._current.get(t)}parent(t){return this._current.parent(t)}traverse(t){this._current.traverse((e,r)=>{t(e,this.data(e))})}data(t){var a;let{_current:e,_children:r}=this,i=r===void 0?void 0:r[t];if(i!==void 0)return i;let o=(a=e.get(t))==null?void 0:a.data,s=ms(this,t,o);return s!==o?(r===void 0&&(r={},this._children=r),r[t]=s,s):o}add(t,e,r,i,o){this.runOp({type:7,parent:t,fi:e,id:r,data:i,children:o})}move(t,e,r){this.runOp({type:9,parent:t,fi:e,id:r})}insertAfter(t,e,r){let i=this._current.insertAfterHelper(t,e,r.length);for(let o=0;o<r.length;o++){let s=r[o];this.add(t,i[o],s.id,s.data,s.children)}}insertBefore(t,e,r){let i=this._current.insertBeforeHelper(t,e,r.length);for(let o=0;o<r.length;o++){let s=r[o];this.add(t,i[o],s.id,s.data,s.children)}}moveAfter(t,e,r){let i=this._current.insertAfterHelper(t,e,r.length);for(let o=0;o<r.length;o++){let s=r[o];this.move(t,i[o],s)}}moveBefore(t,e,r){let i=this._current.insertBeforeHelper(t,e,r.length);for(let o=0;o<r.length;o++){let s=r[o];this.move(t,i[o],s)}}delete(t){this.deleteChildren(t),this.runOp({type:8,id:t})}sortNext(t){return this._current.sortNext(t)}sortPrevious(t){return this._current.sortPrevious(t)}getAllSorted(t){return this._current.getAllSorted(t)}},qi=class extends ki{constructor(t,e,r){super(),this._children={},this._parent=t,this._path=e,this._current=r,this[us]=()=>{this._parent=null}}unproxy(){return this._current}get length(){return this._current.length}forEach(t){let e=this.length;for(let r=0;r<e;r++){let i=this._current[r].id;t(this.data(this._current[r].id),i)}}update(t,e){this._current=this._current.modifyById(t,e)}randomId(){return this._current.randomId()}get(t){return W(P({},this._current.get(t)),{data:this.data(t)})}data(t){var a;let{_current:e,_children:r}=this,i=r===void 0?void 0:r[t];if(i!==void 0)return i;let o=(a=e.get(t))==null?void 0:a.data,s=ms(this,t,o);return s!==o?(r===void 0&&(r={},this._children=r),r[t]=s,s):o}runOp(t){this.reportOp(t,this._current.runOp(t))}add(t,e,r){this.runOp({type:4,fi:t,id:e,data:r})}move(t,e){this.runOp({type:6,fi:t,id:e})}insertAfter(t,e){let r=this._current.insertAfterHelper(t,e.length);for(let i=0;i<e.length;i++){let o=e[i];this.add(r[i],o.id,o.data)}}insertBefore(t,e){let r=this._current.insertBeforeHelper(t,e.length);for(let i=0;i<e.length;i++){let o=e[i];this.add(r[i],o.id,o.data)}}moveAfter(t,e){let r=this._current.insertAfterHelper(t,e.length);for(let i=0;i<e.length;i++){let o=e[i];this.move(r[i],o)}}moveBefore(t,e){let r=this._current.insertBeforeHelper(t,e.length);for(let i=0;i<e.length;i++){let o=e[i];this.move(r[i],o)}}delete(t){this.deleteChildren(t),this.runOp({type:5,id:t})}};function Ia(n,t,e){if(n.length>0){let r=n[n.length-1];if(r.type===0&&t.type===0&&fs.equal(r.path,e)){Object.assign(r.props,t.props);return}}n.push(W(P({},t),{path:e}))}var ds=class{constructor(t){this.ts=[],this.actual=[],this.reverse=[],this._current=t}update(t,e){if(t!=="")throw new Error("");this._current=e}push(t,e,r,i){Ia(this.ts,e,t),Ia(this.actual,r,t),Ia(this.reverse,i,t)}result(){return{data:this._current,ts:this.ts,actual:this.actual,reverse:this.reverse.reverse()}}};function ms(n,t,e){return e instanceof qt?new Hi(n,t,e):e instanceof $e?new qi(n,t,e):e instanceof Ht?new Proxy(new Aa(n,t,e),U0):e!==null&&typeof e=="object"?yh(e)?e:new Proxy(new Pa(n,t,e),j0):e}function Da(n){let t=new ds(n);return[ms(t,"",n),t]}function _a(n,t){let[e,r]=Da(n);return t(e),r.result()}function Ba(n){return n instanceof Hi||n instanceof qi?n._current:n!==null&&typeof n=="object"?n[vh]:n}var fs;(r=>{function n(i,o){if(o.length===i.length)for(var s=0;s<i.length;){if(i[s]!==o[s])return!1;s+=1}else return!1;return!0}r.equal=n;function t(i,o,s){let a=e(s,i);if(a!==void 0&&typeof a=="object"&&a!==null){let l=P({},o);return Object.keys(a).forEach(c=>{delete l[c]}),l}else return o}r.removeOverridden=t;function e(i,o,s=0){if(o.length<=s)return i;if((i instanceof qt||i instanceof Hi)&&typeof o[s]=="string")return e(i.data(o[s]),o,s+1);if((i instanceof $e||i instanceof qi)&&typeof o[s]=="string")return e(i.data(o[s]),o,s+1);if(typeof o[s]=="number"&&Array.isArray(i))return e(i[o[s]],o,s+1);if(typeof o[s]=="string"&&typeof i=="object")return e(i[o[s]],o,s+1)}r.zoom=e})(fs||(fs={}));var ys=class{},zo=class extends ys{constructor(e){super();this.id=e}},Ro=class extends ys{constructor(e){super();this.data=e}};var Ga;try{Ga=new TextDecoder}catch{}var ee,Hr,S=0;var Ih=[],za=Ih,Ra=0,It={},Oe,kr,Wt=0,lr=0,Gt,Tr,Ct=[],Ie,wh={useRecords:!1,mapsAsObjects:!0},Vo=class{},Fa=new Vo;Fa.name="MessagePack 0xC1";var Wi=!1,cr=class{constructor(t){t&&(t.useRecords===!1&&t.mapsAsObjects===void 0&&(t.mapsAsObjects=!0),t.structures?t.structures.sharedLength=t.structures.length:t.getStructures&&((t.structures=[]).uninitialized=!0,t.structures.sharedLength=0)),Object.assign(this,t)}unpack(t,e){if(ee)return Bh(()=>(xs(),this?this.unpack(t,e):cr.prototype.unpack.call(wh,t,e)));Hr=e>-1?e:t.length,S=0,Ra=0,lr=0,kr=null,za=Ih,Gt=null,ee=t;try{Ie=t.dataView||(t.dataView=new DataView(t.buffer,t.byteOffset,t.byteLength))}catch(r){throw ee=null,t instanceof Uint8Array?r:new Error("Source must be a Uint8Array or Buffer but was a "+(t&&typeof t=="object"?t.constructor.name:typeof t))}if(this instanceof cr){if(It=this,this.structures)return Oe=this.structures,gs();(!Oe||Oe.length>0)&&(Oe=[])}else It=wh,(!Oe||Oe.length>0)&&(Oe=[]);return gs()}unpackMultiple(t,e){let r,i=0;try{Wi=!0;let o=t.length,s=this?this.unpack(t,o):Ss.unpack(t,o);if(e){for(e(s);S<o;)if(i=S,e(gs())===!1)return}else{for(r=[s];S<o;)i=S,r.push(gs());return r}}catch(o){throw o.lastPosition=i,o.values=r,o}finally{Wi=!1,xs()}}_mergeStructures(t,e){t=t||[];for(let r=0,i=t.length;r<i;r++){let o=t[r];o&&(o.isShared=!0,r>=32&&(o.highByte=r-32>>5))}t.sharedLength=t.length;for(let r in e||[])if(r>=0){let i=t[r],o=e[r];o&&(i&&((t.restoreStructures||(t.restoreStructures=[]))[r]=i),t[r]=o)}return this.structures=t}decode(t,e){return this.unpack(t,e)}};function gs(){try{if(!It.trusted&&!Wi){let t=Oe.sharedLength||0;t<Oe.length&&(Oe.length=t)}let n=Je();if(S==Hr)Oe.restoreStructures&&Lh(),Oe=null,ee=null,Tr&&(Tr=null);else if(S>Hr){let t=new Error("Unexpected end of MessagePack data");throw t.incomplete=!0,t}else if(!Wi)throw new Error("Data read, but end of buffer not reached");return n}catch(n){throw Oe.restoreStructures&&Lh(),xs(),(n instanceof RangeError||n.message.startsWith("Unexpected end of buffer"))&&(n.incomplete=!0),n}}function Lh(){for(let n in Oe.restoreStructures)Oe[n]=Oe.restoreStructures[n];Oe.restoreStructures=null}function Je(){let n=ee[S++];if(n<160)if(n<128){if(n<64)return n;{let t=Oe[n&63]||It.getStructures&&Ph()[n&63];return t?(t.read||(t.read=ja(t,n&63)),t.read()):n}}else if(n<144)if(n-=128,It.mapsAsObjects){let t={};for(let e=0;e<n;e++)t[Dh()]=Je();return t}else{let t=new Map;for(let e=0;e<n;e++)t.set(Je(),Je());return t}else{n-=144;let t=new Array(n);for(let e=0;e<n;e++)t[e]=Je();return t}else if(n<192){let t=n-160;if(lr>=S)return kr.slice(S-Wt,(S+=t)-Wt);if(lr==0&&Hr<140){let e=t<16?Ua(t):Ah(t);if(e!=null)return e}return Va(t)}else{let t;switch(n){case 192:return null;case 193:return Gt?(t=Je(),t>0?Gt[1].slice(Gt.position1,Gt.position1+=t):Gt[0].slice(Gt.position0,Gt.position0-=t)):Fa;case 194:return!1;case 195:return!0;case 196:return Ea(ee[S++]);case 197:return t=Ie.getUint16(S),S+=2,Ea(t);case 198:return t=Ie.getUint32(S),S+=4,Ea(t);case 199:return ci(ee[S++]);case 200:return t=Ie.getUint16(S),S+=2,ci(t);case 201:return t=Ie.getUint32(S),S+=4,ci(t);case 202:if(t=Ie.getFloat32(S),It.useFloat32>2){let e=vs[(ee[S]&127)<<1|ee[S+1]>>7];return S+=4,(e*t+(t>0?.5:-.5)>>0)/e}return S+=4,t;case 203:return t=Ie.getFloat64(S),S+=8,t;case 204:return ee[S++];case 205:return t=Ie.getUint16(S),S+=2,t;case 206:return t=Ie.getUint32(S),S+=4,t;case 207:return It.int64AsNumber?(t=Ie.getUint32(S)*4294967296,t+=Ie.getUint32(S+4)):t=Ie.getBigUint64(S),S+=8,t;case 208:return Ie.getInt8(S++);case 209:return t=Ie.getInt16(S),S+=2,t;case 210:return t=Ie.getInt32(S),S+=4,t;case 211:return It.int64AsNumber?(t=Ie.getInt32(S)*4294967296,t+=Ie.getUint32(S+4)):t=Ie.getBigInt64(S),S+=8,t;case 212:if(t=ee[S++],t==114)return Oh(ee[S++]&63);{let e=Ct[t];if(e)return e.read?(S++,e.read(Je())):e.noBuffer?(S++,e()):e(ee.subarray(S,++S));throw new Error("Unknown extension "+t)}case 213:return t=ee[S],t==114?(S++,Oh(ee[S++]&63,ee[S++])):ci(2);case 214:return ci(4);case 215:return ci(8);case 216:return ci(16);case 217:return t=ee[S++],lr>=S?kr.slice(S-Wt,(S+=t)-Wt):H0(t);case 218:return t=Ie.getUint16(S),S+=2,lr>=S?kr.slice(S-Wt,(S+=t)-Wt):q0(t);case 219:return t=Ie.getUint32(S),S+=4,lr>=S?kr.slice(S-Wt,(S+=t)-Wt):W0(t);case 220:return t=Ie.getUint16(S),S+=2,Th(t);case 221:return t=Ie.getUint32(S),S+=4,Th(t);case 222:return t=Ie.getUint16(S),S+=2,Nh(t);case 223:return t=Ie.getUint32(S),S+=4,Nh(t);default:if(n>=224)return n-256;if(n===void 0){let e=new Error("Unexpected end of MessagePack data");throw e.incomplete=!0,e}throw new Error("Unknown MessagePack token "+n)}}}var k0=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function ja(n,t){function e(){if(e.count++>2){let i=n.read=new Function("r","return function(){return {"+n.map(o=>k0.test(o)?o+":r()":"["+JSON.stringify(o)+"]:r()").join(",")+"}}")(Je);return n.highByte===0&&(n.read=Ch(t,n.read)),i()}let r={};for(let i=0,o=n.length;i<o;i++){let s=n[i];r[s]=Je()}return r}return e.count=0,n.highByte===0?Ch(t,e):e}var Ch=(n,t)=>function(){let e=ee[S++];if(e===0)return t();let r=n<32?-(n+(e<<5)):n+(e<<5),i=Oe[r]||Ph()[r];if(!i)throw new Error("Record id is not defined for "+r);return i.read||(i.read=ja(i,n)),i.read()};function Ph(){let n=Bh(()=>(ee=null,It.getStructures()));return Oe=It._mergeStructures(n,Oe)}var Va=bs,H0=bs,q0=bs,W0=bs;function bs(n){let t;if(n<16&&(t=Ua(n)))return t;if(n>64&&Ga)return Ga.decode(ee.subarray(S,S+=n));let e=S+n,r=[];for(t="";S<e;){let i=ee[S++];if((i&128)===0)r.push(i);else if((i&224)===192){let o=ee[S++]&63;r.push((i&31)<<6|o)}else if((i&240)===224){let o=ee[S++]&63,s=ee[S++]&63;r.push((i&31)<<12|o<<6|s)}else if((i&248)===240){let o=ee[S++]&63,s=ee[S++]&63,a=ee[S++]&63,l=(i&7)<<18|o<<12|s<<6|a;l>65535&&(l-=65536,r.push(l>>>10&1023|55296),l=56320|l&1023),r.push(l)}else r.push(i);r.length>=4096&&(t+=nt.apply(String,r),r.length=0)}return r.length>0&&(t+=nt.apply(String,r)),t}function Th(n){let t=new Array(n);for(let e=0;e<n;e++)t[e]=Je();return t}function Nh(n){if(It.mapsAsObjects){let t={};for(let e=0;e<n;e++)t[Dh()]=Je();return t}else{let t=new Map;for(let e=0;e<n;e++)t.set(Je(),Je());return t}}var nt=String.fromCharCode;function Ah(n){let t=S,e=new Array(n);for(let r=0;r<n;r++){let i=ee[S++];if((i&128)>0){S=t;return}e[r]=i}return nt.apply(String,e)}function Ua(n){if(n<4)if(n<2){if(n===0)return"";{let t=ee[S++];if((t&128)>1){S-=1;return}return nt(t)}}else{let t=ee[S++],e=ee[S++];if((t&128)>0||(e&128)>0){S-=2;return}if(n<3)return nt(t,e);let r=ee[S++];if((r&128)>0){S-=3;return}return nt(t,e,r)}else{let t=ee[S++],e=ee[S++],r=ee[S++],i=ee[S++];if((t&128)>0||(e&128)>0||(r&128)>0||(i&128)>0){S-=4;return}if(n<6){if(n===4)return nt(t,e,r,i);{let o=ee[S++];if((o&128)>0){S-=5;return}return nt(t,e,r,i,o)}}else if(n<8){let o=ee[S++],s=ee[S++];if((o&128)>0||(s&128)>0){S-=6;return}if(n<7)return nt(t,e,r,i,o,s);let a=ee[S++];if((a&128)>0){S-=7;return}return nt(t,e,r,i,o,s,a)}else{let o=ee[S++],s=ee[S++],a=ee[S++],l=ee[S++];if((o&128)>0||(s&128)>0||(a&128)>0||(l&128)>0){S-=8;return}if(n<10){if(n===8)return nt(t,e,r,i,o,s,a,l);{let c=ee[S++];if((c&128)>0){S-=9;return}return nt(t,e,r,i,o,s,a,l,c)}}else if(n<12){let c=ee[S++],p=ee[S++];if((c&128)>0||(p&128)>0){S-=10;return}if(n<11)return nt(t,e,r,i,o,s,a,l,c,p);let h=ee[S++];if((h&128)>0){S-=11;return}return nt(t,e,r,i,o,s,a,l,c,p,h)}else{let c=ee[S++],p=ee[S++],h=ee[S++],d=ee[S++];if((c&128)>0||(p&128)>0||(h&128)>0||(d&128)>0){S-=12;return}if(n<14){if(n===12)return nt(t,e,r,i,o,s,a,l,c,p,h,d);{let m=ee[S++];if((m&128)>0){S-=13;return}return nt(t,e,r,i,o,s,a,l,c,p,h,d,m)}}else{let m=ee[S++],f=ee[S++];if((m&128)>0||(f&128)>0){S-=14;return}if(n<15)return nt(t,e,r,i,o,s,a,l,c,p,h,d,m,f);let T=ee[S++];if((T&128)>0){S-=15;return}return nt(t,e,r,i,o,s,a,l,c,p,h,d,m,f,T)}}}}}function Ea(n){return It.copyBuffers?Uint8Array.prototype.slice.call(ee,S,S+=n):ee.subarray(S,S+=n)}function ci(n){let t=ee[S++];if(Ct[t])return Ct[t](ee.subarray(S,S+=n));throw new Error("Unknown extension type "+t)}var Mh=new Array(4096);function Dh(){let n=ee[S++];if(n>=160&&n<192){if(n=n-160,lr>=S)return kr.slice(S-Wt,(S+=n)-Wt);if(!(lr==0&&Hr<180))return Va(n)}else return S--,Je();let t=(n<<5^(n>1?Ie.getUint16(S):n>0?ee[S]:0))&4095,e=Mh[t],r=S,i=S+n-3,o,s=0;if(e&&e.bytes==n){for(;r<i;){if(o=Ie.getUint32(r),o!=e[s++]){r=1879048192;break}r+=4}for(i+=3;r<i;)if(o=ee[r++],o!=e[s++]){r=1879048192;break}if(r===i)return S=r,e.string;i-=3,r=S}for(e=[],Mh[t]=e,e.bytes=n;r<i;)o=Ie.getUint32(r),e.push(o),r+=4;for(i+=3;r<i;)o=ee[r++],e.push(o);let a=n<16?Ua(n):Ah(n);return a!=null?e.string=a:e.string=Va(n)}var Oh=(n,t)=>{var e=Je();let r=n;t!==void 0&&(n=n<32?-((t<<5)+n):(t<<5)+n,e.highByte=t);let i=Oe[n];return i&&i.isShared&&((Oe.restoreStructures||(Oe.restoreStructures=[]))[n]=i),Oe[n]=e,e.read=ja(e,r),e.read()},_h=typeof self=="object"?self:global;Ct[0]=()=>{};Ct[0].noBuffer=!0;Ct[101]=()=>{let n=Je();return(_h[n[0]]||Error)(n[1])};Ct[105]=n=>{let t=Ie.getUint32(S-4);Tr||(Tr=new Map);let e=ee[S],r;e>=144&&e<160||e==220||e==221?r=[]:r={};let i={target:r};Tr.set(t,i);let o=Je();return i.used?Object.assign(r,o):(i.target=o,o)};Ct[112]=n=>{let t=Ie.getUint32(S-4),e=Tr.get(t);return e.used=!0,e.target};Ct[115]=()=>new Set(Je());var ka=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(n=>n+"Array");Ct[116]=n=>{let t=n[0],e=ka[t];if(!e)throw new Error("Could not find typed array for code "+t);return new _h[e](Uint8Array.prototype.slice.call(n,1).buffer)};Ct[120]=()=>{let n=Je();return new RegExp(n[0],n[1])};Ct[98]=n=>{let t=(n[0]<<24)+(n[1]<<16)+(n[2]<<8)+n[3],e=S;S+=t-4,Gt=[Je(),Je()],Gt.position0=0,Gt.position1=0;let r=S;S=e;try{return Je()}finally{S=r}};Ct[255]=n=>n.length==4?new Date((n[0]*16777216+(n[1]<<16)+(n[2]<<8)+n[3])*1e3):n.length==8?new Date(((n[0]<<22)+(n[1]<<14)+(n[2]<<6)+(n[3]>>2))/1e6+((n[3]&3)*4294967296+n[4]*16777216+(n[5]<<16)+(n[6]<<8)+n[7])*1e3):n.length==12?new Date(((n[0]<<24)+(n[1]<<16)+(n[2]<<8)+n[3])/1e6+((n[4]&128?-281474976710656:0)+n[6]*1099511627776+n[7]*4294967296+n[8]*16777216+(n[9]<<16)+(n[10]<<8)+n[11])*1e3):new Date("invalid");function Bh(n){let t=Hr,e=S,r=Ra,i=Wt,o=lr,s=kr,a=za,l=Tr,c=Gt,p=new Uint8Array(ee.slice(0,Hr)),h=Oe,d=Oe.slice(0,Oe.length),m=It,f=Wi,T=n();return Hr=t,S=e,Ra=r,Wt=i,lr=o,kr=s,za=a,Tr=l,Gt=c,ee=p,Wi=f,Oe=h,Oe.splice(0,Oe.length,...d),It=m,Ie=new DataView(ee.buffer,ee.byteOffset,ee.byteLength),T}function xs(){ee=null,Tr=null,Oe=null}function Eh(n){n.unpack?Ct[n.type]=n.unpack:Ct[n.type]=n}var vs=new Array(147);for(let n=0;n<256;n++)vs[n]=+("1e"+Math.floor(45.15-n*.30103));var Ss=new cr({useRecords:!1}),$0=Ss.unpack,J0=Ss.unpackMultiple,K0=Ss.unpack,ws={NEVER:0,ALWAYS:1,DECIMAL_ROUND:3,DECIMAL_FIT:4},Y0=new Float32Array(1),mP=new Uint8Array(Y0.buffer,0,4);var Ls;try{Ls=new TextEncoder}catch{}var Cs,qa,Ts=typeof Buffer<"u",Ha=Ts?Buffer.allocUnsafeSlow:Uint8Array,Vh=Ts?Buffer:Uint8Array,Gh=Ts?4294967296:2144337920,E,Ke,O=0,pr,hr=null,X0=/[\u0080-\uFFFF]/,Fo=Symbol("record-id"),pi=class extends cr{constructor(t){super(t),this.offset=0;let e,r,i,o,s,a,l=0,c=Vh.prototype.utf8Write?function(u,M,g){return E.utf8Write(u,M,g)}:Ls&&Ls.encodeInto?function(u,M){return Ls.encodeInto(u,E.subarray(M)).written}:!1,p=this;t||(t={});let h=t&&t.sequential,d=t.structures||t.saveStructures,m=t.maxSharedStructures;if(m==null&&(m=d?32:0),m>8160)throw new Error("Maximum maxSharedStructure is 8160");let f=t.maxOwnStructures;f==null&&(f=d?32:64),h&&!t.saveStructures&&(this.structures=[]);let T=m>32||f+m>64,w=m+64,y=m+f+64;if(y>8256)throw new Error("Maximum maxSharedStructure + maxOwnStructure is 8192");let L=[],A=0,I=0;this.pack=this.encode=function(u,M){if(E||(E=new Ha(8192),Ke=new DataView(E.buffer,0,8192),O=0),pr=E.length-10,pr-O<2048?(E=new Ha(E.length),Ke=new DataView(E.buffer,0,E.length),pr=E.length-10,O=0):O=O+7&2147483640,r=O,a=p.structuredClone?new Map:null,p.bundleStrings?(hr=["",""],E[O++]=214,E[O++]=98,hr.position=O-r,O+=4):hr=null,i=p.structures,i){i.uninitialized&&(i=p._mergeStructures(p.getStructures()));let g=i.sharedLength||0;if(g>m)throw new Error("Shared structures is larger than maximum shared structures, try increasing maxSharedStructures to "+i.sharedLength);if(!i.transitions){i.transitions=Object.create(null);for(let N=0;N<g;N++){let v=i[N];if(!v)continue;let C,$=i.transitions;for(let H=0,ie=v.length;H<ie;H++){let pe=v[H];C=$[pe],C||(C=$[pe]=Object.create(null)),$=C}$[Fo]=N+64}l=g}h||(i.nextId=g+64)}o&&(o=!1),s=i||[];try{if(b(u),hr){Ke.setUint32(hr.position+r,O-hr.position-r);let g=hr;hr=null,b(g[0]),b(g[1])}if(p.offset=O,a&&a.idsToInsert){O+=a.idsToInsert.length*6,O>pr&&x(O),p.offset=O;let g=Q0(E.subarray(r,O),a.idsToInsert);return a=null,g}return M&jh?(E.start=r,E.end=O,E):E.subarray(r,O)}finally{if(i){if(I<10&&I++,A>1e4)i.transitions=null,I=0,A=0,L.length>0&&(L=[]);else if(L.length>0&&!h){for(let g=0,N=L.length;g<N;g++)L[g][Fo]=0;L=[]}if(o&&p.saveStructures){let g=i.sharedLength||m;i.length>g&&(i=i.slice(0,g));let N=E.subarray(r,O);return p.saveStructures(i,l)===!1?(p._mergeStructures(p.getStructures()),p.pack(u)):(l=g,N)}}M&sb&&(O=r)}};let b=u=>{O>pr&&(E=x(O));var M=typeof u,g;if(M==="string"){let N=u.length;if(hr&&N>=8&&N<4096){let $=X0.test(u);hr[$?0:1]+=u,E[O++]=193,b($?-N:N);return}let v;N<32?v=1:N<256?v=2:N<65536?v=3:v=5;let C=N*3;if(O+C>pr&&(E=x(O+C)),N<64||!c){let $,H,ie,pe=O+v;for($=0;$<N;$++)H=u.charCodeAt($),H<128?E[pe++]=H:H<2048?(E[pe++]=H>>6|192,E[pe++]=H&63|128):(H&64512)===55296&&((ie=u.charCodeAt($+1))&64512)===56320?(H=65536+((H&1023)<<10)+(ie&1023),$++,E[pe++]=H>>18|240,E[pe++]=H>>12&63|128,E[pe++]=H>>6&63|128,E[pe++]=H&63|128):(E[pe++]=H>>12|224,E[pe++]=H>>6&63|128,E[pe++]=H&63|128);g=pe-O-v}else g=c(u,O+v,C);g<32?E[O++]=160|g:g<256?(v<2&&E.copyWithin(O+2,O+1,O+1+g),E[O++]=217,E[O++]=g):g<65536?(v<3&&E.copyWithin(O+3,O+2,O+2+g),E[O++]=218,E[O++]=g>>8,E[O++]=g&255):(v<5&&E.copyWithin(O+5,O+3,O+3+g),E[O++]=219,Ke.setUint32(O,g),O+=4),O+=g}else if(M==="number")if(u>>>0===u)u<64?E[O++]=u:u<256?(E[O++]=204,E[O++]=u):u<65536?(E[O++]=205,E[O++]=u>>8,E[O++]=u&255):(E[O++]=206,Ke.setUint32(O,u),O+=4);else if(u>>0===u)u>=-32?E[O++]=256+u:u>=-128?(E[O++]=208,E[O++]=u+256):u>=-32768?(E[O++]=209,Ke.setInt16(O,u),O+=2):(E[O++]=210,Ke.setInt32(O,u),O+=4);else{let N;if((N=this.useFloat32)>0&&u<4294967296&&u>=-2147483648){E[O++]=202,Ke.setFloat32(O,u);let v;if(N<4||(v=u*vs[(E[O]&127)<<1|E[O+1]>>7])>>0===v){O+=4;return}else O--}E[O++]=203,Ke.setFloat64(O,u),O+=8}else if(M==="object")if(!u)E[O++]=192;else{if(a){let v=a.get(u);if(v){if(!v.id){let C=a.idsToInsert||(a.idsToInsert=[]);v.id=C.push(v)}E[O++]=214,E[O++]=112,Ke.setUint32(O,v.id),O+=4;return}else a.set(u,{offset:O-r})}let N=u.constructor;if(N===Object)V(u,!0);else if(N===Array){g=u.length,g<16?E[O++]=144|g:g<65536?(E[O++]=220,E[O++]=g>>8,E[O++]=g&255):(E[O++]=221,Ke.setUint32(O,g),O+=4);for(let v=0;v<g;v++)b(u[v])}else if(N===Map){g=u.size,g<16?E[O++]=128|g:g<65536?(E[O++]=222,E[O++]=g>>8,E[O++]=g&255):(E[O++]=223,Ke.setUint32(O,g),O+=4);for(let[v,C]of u)b(v),b(C)}else{for(let v=0,C=Cs.length;v<C;v++){let $=qa[v];if(u instanceof $){let H=Cs[v];if(H.write){H.type&&(E[O++]=212,E[O++]=H.type,E[O++]=0),b(H.write.call(this,u));return}let ie=E,pe=Ke,ce=O;E=null;let be;try{be=H.pack.call(this,u,F=>(E=ie,ie=null,O+=F,O>pr&&x(O),{target:E,targetView:Ke,position:O-F}),b)}finally{ie&&(E=ie,Ke=pe,O=ce,pr=E.length-10)}be&&(be.length+O>pr&&x(be.length+O),O=Z0(be,E,O,H.type));return}}V(u,!u.hasOwnProperty)}}else if(M==="boolean")E[O++]=u?195:194;else if(M==="bigint"){if(u<BigInt(1)<<BigInt(63)&&u>=-(BigInt(1)<<BigInt(63)))E[O++]=211,Ke.setBigInt64(O,u);else if(u<BigInt(1)<<BigInt(64)&&u>0)E[O++]=207,Ke.setBigUint64(O,u);else if(this.largeBigIntToFloat)E[O++]=203,Ke.setFloat64(O,Number(u));else throw new RangeError(u+" was too large to fit in MessagePack 64-bit integer format, set largeBigIntToFloat to convert to float-64");O+=8}else if(M==="undefined")this.encodeUndefinedAsNil?E[O++]=192:(E[O++]=212,E[O++]=0,E[O++]=0);else if(M==="function")b(this.writeFunction&&this.writeFunction());else throw new Error("Unknown type: "+M)},V=this.useRecords===!1?this.variableMapSize?u=>{let M=Object.keys(u),g=M.length;g<16?E[O++]=128|g:g<65536?(E[O++]=222,E[O++]=g>>8,E[O++]=g&255):(E[O++]=223,Ke.setUint32(O,g),O+=4);let N;for(let v=0;v<g;v++)b(N=M[v]),b(u[N])}:(u,M)=>{E[O++]=222;let g=O-r;O+=2;let N=0;for(let v in u)(M||u.hasOwnProperty(v))&&(b(v),b(u[v]),N++);E[g+++r]=N>>8,E[g+r]=N&255}:u=>{let M=Object.keys(u),g,N=s.transitions||(s.transitions=Object.create(null)),v=0;for(let $=0,H=M.length;$<H;$++){let ie=M[$];g=N[ie],g||(g=N[ie]=Object.create(null),v++),N=g}let C=N[Fo];if(C)C>=96&&T?(E[O++]=((C-=96)&31)+96,E[O++]=C>>5):E[O++]=C;else{C=s.nextId,C||(C=64),C<w&&this.shouldShareStructure&&!this.shouldShareStructure(M)?(C=s.nextOwnId,C<y||(C=w),s.nextOwnId=C+1):(C>=y&&(C=w),s.nextId=C+1);let $=M.highByte=C>=96&&T?C-96>>5:-1;N[Fo]=C,s[C-64]=M,C<w?(M.isShared=!0,s.sharedLength=C-63,o=!0,$>=0?(E[O++]=(C&31)+96,E[O++]=$):E[O++]=C):($>=0?(E[O++]=213,E[O++]=114,E[O++]=(C&31)+96,E[O++]=$):(E[O++]=212,E[O++]=114,E[O++]=C),v&&(A+=I*v),L.length>=f&&(L.shift()[Fo]=0),L.push(N),b(M))}for(let $=0,H=M.length;$<H;$++)b(u[M[$]])},x=u=>{let M;if(u>16777216){if(u-r>Gh)throw new Error("Packed buffer would be larger than maximum buffer size");M=Math.min(Gh,Math.round(Math.max((u-r)*(u>67108864?1.25:2),4194304)/4096)*4096)}else M=(Math.max(u-r<<2,E.length-1)>>12)+1<<12;let g=new Ha(M);return Ke=new DataView(g.buffer,0,M),E.copy?E.copy(g,0,r,u):g.set(E.slice(r,u)),O-=r,r=0,pr=g.length-10,E=g}}useBuffer(t){E=t,Ke=new DataView(E.buffer,E.byteOffset,E.byteLength),O=0}};qa=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,Vo];Cs=[{pack(n,t,e){let r=n.getTime()/1e3;if((this.useTimestamp32||n.getMilliseconds()===0)&&r>=0&&r<4294967296){let{target:i,targetView:o,position:s}=t(6);i[s++]=214,i[s++]=255,o.setUint32(s,r)}else if(r>0&&r<17179869184){let{target:i,targetView:o,position:s}=t(10);i[s++]=215,i[s++]=255,o.setUint32(s,n.getMilliseconds()*4e6+(r/1e3/4294967296>>0)),o.setUint32(s+4,r)}else if(isNaN(r)){if(this.onInvalidDate)return t(0),e(this.onInvalidDate());let{target:i,targetView:o,position:s}=t(3);i[s++]=212,i[s++]=255,i[s++]=255}else{let{target:i,targetView:o,position:s}=t(15);i[s++]=199,i[s++]=12,i[s++]=255,o.setUint32(s,n.getMilliseconds()*1e6),o.setBigInt64(s+4,BigInt(Math.floor(r)))}}},{pack(n,t,e){let r=Array.from(n),{target:i,position:o}=t(this.structuredClone?3:0);this.structuredClone&&(i[o++]=212,i[o++]=115,i[o++]=0),e(r)}},{pack(n,t,e){let{target:r,position:i}=t(this.structuredClone?3:0);this.structuredClone&&(r[i++]=212,r[i++]=101,r[i++]=0),e([n.name,n.message])}},{pack(n,t,e){let{target:r,position:i}=t(this.structuredClone?3:0);this.structuredClone&&(r[i++]=212,r[i++]=120,r[i++]=0),e([n.source,n.flags])}},{pack(n,t){this.structuredClone?zh(n,16,t):Rh(Ts?Buffer.from(n):new Uint8Array(n),t)}},{pack(n,t){let e=n.constructor;e!==Vh&&this.structuredClone?zh(n,ka.indexOf(e.name),t):Rh(n,t)}},{pack(n,t){let{target:e,position:r}=t(1);e[r]=193}}];function zh(n,t,e,r){let i=n.byteLength;if(i+1<256){var{target:o,position:s}=e(4+i);o[s++]=199,o[s++]=i+1}else if(i+1<65536){var{target:o,position:s}=e(5+i);o[s++]=200,o[s++]=i+1>>8,o[s++]=i+1&255}else{var{target:o,position:s,targetView:a}=e(7+i);o[s++]=201,a.setUint32(s,i+1),s+=4}o[s++]=116,o[s++]=t,o.set(new Uint8Array(n.buffer,n.byteOffset,n.byteLength),s)}function Rh(n,t){let e=n.byteLength;var r,i;if(e<256){var{target:r,position:i}=t(e+2);r[i++]=196,r[i++]=e}else if(e<65536){var{target:r,position:i}=t(e+3);r[i++]=197,r[i++]=e>>8,r[i++]=e&255}else{var{target:r,position:i,targetView:o}=t(e+5);r[i++]=198,o.setUint32(i,e),i+=4}r.set(n,i)}function Z0(n,t,e,r){let i=n.length;switch(i){case 1:t[e++]=212;break;case 2:t[e++]=213;break;case 4:t[e++]=214;break;case 8:t[e++]=215;break;case 16:t[e++]=216;break;default:i<256?(t[e++]=199,t[e++]=i):i<65536?(t[e++]=200,t[e++]=i>>8,t[e++]=i&255):(t[e++]=201,t[e++]=i>>24,t[e++]=i>>16&255,t[e++]=i>>8&255,t[e++]=i&255)}return t[e++]=r,t.set(n,e),e+=i,e}function Q0(n,t){let e,r=t.length*6,i=n.length-r;for(t.sort((o,s)=>o.offset>s.offset?1:-1);e=t.pop();){let o=e.offset,s=e.id;n.copyWithin(o+r,o,i),r-=6;let a=o+r;n[a++]=214,n[a++]=105,n[a++]=s>>24,n[a++]=s>>16&255,n[a++]=s>>8&255,n[a++]=s&255,i=o}return n}function hi(n){if(n.Class){if(!n.pack&&!n.write)throw new Error("Extension has no pack or write function");if(n.pack&&!n.type)throw new Error("Extension has no type (numeric code to identify the extension)");qa.unshift(n.Class),Cs.unshift(n)}Eh(n)}var Fh=new pi({useRecords:!1}),eb=Fh.pack,tb=Fh.pack;var{NEVER:rb,ALWAYS:ib,DECIMAL_ROUND:ob,DECIMAL_FIT:nb}=ws,jh=512,sb=1024;var Uh=new pi({structuredClone:!0});hi({Class:Ht.prototype.constructor,type:1,write(n){return P({},n)},read(n){return Object.setPrototypeOf(n,Ht.prototype),n}});hi({Class:$e.prototype.constructor,type:2,write(n){return[...n]},read(n){return Object.setPrototypeOf(n,$e.prototype),n}});hi({Class:qt.prototype.constructor,type:3,write(n){return[...n]},read(n){return Object.setPrototypeOf(n,qt.prototype),n}});hi({Class:zo.prototype.constructor,type:4,write(n){return n.id},read(n){return new zo(n)}});hi({Class:Ro.prototype.constructor,type:5,write(n){return n.data},read(n){return new Ro(n)}});function ab(n){var t=0;if(n.length===0)return t;for(let e=0;e<n.length;e++){let r=n[e];t=(t<<5)-t+r,t=t&t}return t}var Ns;(r=>{function n(i){return Uh.pack(i)}r.serialize=n;function t(i){return Uh.unpack(i)}r.deserialize=t;function e(i){return ab(n(i)).toString()}r.checksum=e})(Ns||(Ns={}));var Ms;(e=>{e.all=["PointLight","SpotLight","DirectionalLight","HemisphereLight"];function t(r){return e.all.includes(r)}e.is=t})(Ms||(Ms={}));var Os;(e=>{function n(r){return t(r)}e.defaultData=n;function t(r){if(r==="PointLight")return{type:r,color:sr.white,intensity:1,distance:2e3,decay:1,shadows:!0,shadowResolution:1024,shadowRadius:1,depth:2500,helper:!0};if(r==="SpotLight")return{type:r,color:sr.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:sr.white,intensity:1,shadows:!0,size:2500,depth:2500,helper:!0};throw new Error("not implemented")}})(Os||(Os={}));var Wa;(e=>{e.defaultData={castShadow:!0,receiveShadow:!0};function t(r,i){return r.castShadow===i.castShadow&&r.receiveShadow===i.receiveShadow}e.equals=t})(Wa||(Wa={}));var $a;(e=>{e.defaultData={flatShading:!1,wireframe:!1,side:0};function t(r,i){return r.flatShading===i.flatShading&&r.side===i.side&&r.wireframe===i.wireframe}e.equals=t})($a||($a={}));var Is;(t=>t.defaultData=W(P(P({},$a.defaultData),Wa.defaultData),{cloner:null}))(Is||(Is={}));var Ja=(i=>(i[i.Left=1]="Left",i[i.Right=2]="Right",i[i.Center=3]="Center",i[i.Justify=4]="Justify",i))(Ja||{}),Ka=(r=>(r[r.Top=1]="Top",r[r.Center=2]="Center",r[r.Bottom=3]="Bottom",r))(Ka||{}),Ya=(r=>(r[r.None=1]="None",r[r.Upper=2]="Upper",r[r.Lower=3]="Lower",r))(Ya||{}),Ps;(t=>t.defaultData={width:100,height:100,horizontalAlign:1,verticalAlign:1,fontSize:16,lineHeight:1.5,letterSpacing:1,text:"",textTransform:1,color:sr.fromHexAndA(6974058,1),alpha:1,font:"roboto_regular"})(Ps||(Ps={}));var $i;(r=>{function n(i,o){return i==="light"&&o?t(o):e(i)}r.defaultData=n;function t(i){switch(i){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:0,g:0,b:0,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 e(i){switch(i){case"texture":return{alpha:1,visible:!0,size:[128,128],mode:0,axis:"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:Et.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:W(P({},Et.fromHex(6710886)),{a:1}),colorB:W(P({},Et.fromHex(6710886)),{a:1}),colorC:W(P({},Et.fromHex(16777215)),{a:1}),colorD:W(P({},Et.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:sr.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}}}})($i||($i={}));var Ji;(a=>{function n(l){return!l.layers.some(p=>{if(p.data.type==="texture"&&p.data.projection!==0||p.data.type==="depth"&&!p.data.isWorldSpace||p.data.type==="noise"||p.data.type==="displace")return!0})&&!e(l)}a.isMergable=n;function t(l){let c="";return l.layers.forEach(p=>{Object.entries(p.data).forEach(([h,d])=>{c+=`${h}${d}`,Array.isArray(d)?d.forEach(m=>c+=`${m}`):typeof d=="object"?Object.values(d).forEach(m=>{typeof m=="number"?c+=`${m.toFixed(4)}`:c+=`${m}`}):c+=`${d}`})}),c}a.getHash=t;function e(l){let c=0;for(let p of l.layers)"alpha"in p.data&&p.data.type!=="light"&&p.data.type!=="fresnel"&&(c+=(1-c)*p.data.alpha);return c<1}a.isTransparent=e;function r(){return{layers:new $e}}a.defaultEmptyData=r;function i(l="layer1",c="layer2"){return o("phong",l,c)}a.defaultData=i;function o(l,c="layer1",p="layer2"){let h=new $e;return h.push({fi:0,data:$i.defaultData("light",l),id:c}),h.push({fi:1,data:$i.defaultData("color"),id:p}),{layers:h}}a.defaultTwoLayerData=o;function s(l,c="basic",p="layer1",h="layer2"){let d=$i.defaultData("texture");Object.assign(d.texture,{image:l});let m=new $e;return m.push({fi:0,data:d,id:p}),m.push({fi:1,data:$i.defaultData("light",c),id:h}),{layers:m}}a.defaultTwoLayerTextureData=s})(Ji||(Ji={}));var Ki;(r=>{function n(){return{points:new $e,roundness:0,shapeHoles:[],isClosed:!1}}r.defaultData=n;function t(i,o){let{points:s}=o;if(s){for(let a of s)if(a.data.position[0]===i[0]&&a.data.position[1]===i[1])return!0}return!1}r.isOverlappingExistingPoint=t;function e(i,o){let s=i.controlNext,a=o.controlPrevious;return i.position[0]===s.position[0]&&i.position[1]===s.position[1]&&o.position[0]===a.position[0]&&o.position[1]===a.position[1]}r.isStraightLine=e})(Ki||(Ki={}));var As;(t=>{function n(e){return e==="PolygonGeometry"||e==="RectangleGeometry"||e==="StarGeometry"||e==="TriangleGeometry"||e==="EllipseGeometry"}t.is2DParametricMesh=n})(As||(As={}));var Ds;(t=>{function n(e){if(e==="RectangleGeometry")return{width:320,height:320,type:e,cornerRadius:[0,0,0,0],cornerType:0,depth:0,extrudeBevelSize:0,extrudeBevelSegments:1};if(e==="VectorGeometry")return{width:1,height:1,type:e,subdivisions:12,shape:Ki.defaultData(),depth:0,extrudeBevelSize:0,extrudeBevelSegments:1};throw new Error("not implemented")}t.defaultData=n})(Ds||(Ds={}));var jo;(i=>{i.identity=W(P({},ls.identity),{hiddenMatrix:Ur.identity});function t(o){return{position:o.position,rotation:o.rotation,scale:o.scale,hiddenMatrix:o.hiddenMatrix}}i.fromObject=t;function e(o,s){return{position:(s==null?void 0:s.position)||o.position,rotation:(s==null?void 0:s.rotation)||o.rotation,scale:(s==null?void 0:s.scale)||o.scale,hiddenMatrix:(s==null?void 0:s.hiddenMatrix)||o.hiddenMatrix}}i.merge=e;function r(o,s){return{position:Ui.isEqual(o.position,s.position)?null:s.position,rotation:Ui.isEqual(o.rotation,s.rotation)?null:s.rotation,scale:Ui.isEqual(o.scale,s.scale)?null:s.scale,hiddenMatrix:Ur.isEqual(o.hiddenMatrix,s.hiddenMatrix)?null:s.hiddenMatrix}}i.diff=r})(jo||(jo={}));var qr;(t=>t.defaultData=P({states:new $e,events:new $e,visible:!0,raycastLock:!1},jo.identity))(qr||(qr={}));var kh;(t=>t.defaultData=P({type:"Empty"},qr.defaultData))(kh||(kh={}));var Xa;(t=>t.defaultData=P(P({type:"Mesh"},qr.defaultData),Is.defaultData))(Xa||(Xa={}));var Hh;(t=>t.defaultData=P(P({type:"TextFrame"},qr.defaultData),Ps.defaultData))(Hh||(Hh={}));var _s;(t=>t.defaultData=P(P(P({},qr.defaultData),jo.identity),li.defaultData))(_s||(_s={}));var qh;(t=>{function n(e){return P(P({},qr.defaultData),Os.defaultData(e))}t.defaultData=n})(qh||(qh={}));var Wh;(e=>(e.defaultCamera=P({position:[0,0,1e3],scale:[1,1,1],rotation:[0,0,0],hiddenMatrix:Ur.identity,name:"Play Camera",visible:!0,raycastLock:!1,states:new $e,events:new $e},li.defaultData),e.defaultMeshObject=W(P(P({name:"Rectangle"},qr.defaultData),Xa.defaultData),{geometry:Ds.defaultData("RectangleGeometry"),material:Ji.defaultTwoLayerData("basic","layer1","layer2")})))(Wh||(Wh={}));var $h;(e=>{function n(r,i){if(i===void 0)return r;let o=P({},r);return"material"in o&&"material"in i&&i.material&&(o.material=_a(o.material,s=>{if(typeof s!="string")for(let[a,l]of Object.entries(i.material.layers)){let c=s.layers.data(a);c&&ai(c,l)}}).data),o.materials&&i.materials&&(o.materials=_a(o.materials,s=>{var a,l;for(let c=0;c<o.materials.length;c++){let p=i.materials[c];if(typeof p!="string")for(let[h,d]of Object.entries(p.layers)){let m=(l=(a=s[c])==null?void 0:a.layers)==null?void 0:l.data(h);m&&ai(m,d)}}}).data),o}e.patchMaterialState=n;function t(r,i){var s,a;if(i===void 0)return r;let o=P({},r);if(Object.assign(o,jo.merge(o,i)),ji.is(r.type)){o.orthographic=P({},o.orthographic),o.perspective=P({},o.perspective);let l=i;((s=l.orthographic)==null?void 0:s.zoom)!==void 0&&(o.orthographic.zoom=l.orthographic.zoom),((a=l.perspective)==null?void 0:a.zoom)!==void 0&&(o.perspective.zoom=l.perspective.zoom)}else if(r.type==="Mesh")o.geometry=P({},o.geometry),Object.assign(o.geometry,i.geometry),o=n(o,i);else if(Ms.is(r.type)){let l=i;o.intensity!==void 0&&(o.intensity=l.intensity),l.color!==void 0&&(typeof l.color=="string"?o.color=l.color:o.color=Et.clone(l.color))}return o}e.patch=t})($h||($h={}));import{BufferGeometry as IA,ConeBufferGeometry as pb,Float32BufferAttribute as PA,Vector2 as AA,Vector3 as DA}from"three";import{BufferGeometry as lb,CylinderBufferGeometry as cb,Float32BufferAttribute as Za,Vector2 as Xt,Vector3 as Bs}from"three";var Kh=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){var s,a,l,c,p;let e=Object.assign({},(s=t==null?void 0:t.parameters)!=null?s:{width:100,radialSegments:64,heightSegments:1,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadius:0,cornerSegments:8,hollow:0},n.parameters),r=e.width/2,i=(a=e.radiusTop)!=null?a:r,o=(l=e.radiusBottom)!=null?l:r;return i===o?(i=r,o=r):i>o?(i=r,o=o*r/i):(i=i*r/o,o=r),{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs((c=e.height)!=null?c:e.width),depth:Math.abs((p=e.depth)!=null?p:e.width),radiusTop:i,radiusBottom:o})}}static build(n){let{width:t,depth:e,height:r,radialSegments:i,heightSegments:o,openEnded:s,thetaStart:a,thetaLength:l,radiusTop:c,radiusBottom:p,cornerRadius:h,cornerSegments:d,hollow:m}=n.parameters,f;return h||m?f=new Uo(c,p,r,i,o,s,a,l*Math.PI/180,h,h,d,m):f=new cb(c,p,r,i,o,s,a,l*Math.PI/180),f.scale(1,1,e/t),Object.assign(f,{userData:W(P({},n),{type:"CylinderGeometry"})})}};function Wr(n,t,e){e.x=n.x*t.x,e.y=n.y,e.z=n.x*t.y}function Jh(n){return new Xt(n.y,-n.x)}var Uo=class extends lb{constructor(t,e,r,i,o,s,a,l,c,p,h,d,m=!1){super(),this.type="RoundedCylinderBufferGeometry",t=t!==void 0?t:1,e=e!==void 0?e:1,r=r||1,i=Math.floor(i)||8,o=Math.floor(o)||1,s=s!==void 0?s:!1,a=a!==void 0?a:0,l=l!==void 0?l:Math.PI*2,s&&(c=0,p=0);let f=[],T=[],w=[],y=[],L=0,A=r/2,I=new Bs,b=new Bs;m&&t==0&&(t=c),m&&e==0&&(e=p);let V=new Xt(t,A),x=new Xt(e,-A),u=null,M=null,g=null,N=null,v=V.clone().sub(x),C=0,$=0,H=0;d>0&&(C=Math.min(t,e)*(1-d),$=t-C,H=e-C);let ie=V.clone();ie.x-=C;let pe=Math.PI-v.angle(),ce=v.angle(),be=Math.tan(ce/2),F=Math.tan(pe/2),G=be+F,_=d?G:F,z=d?G:be;if(c=Math.min(c,(t-$)/_,v.length()/G),p=Math.min(p,(e-H)/z,v.length()/G),c>0){let j=c/be;u=V.clone().sub(new Xt(j,c)),d&&(g=u.clone(),g.x-=C-G*c),V.sub(v.clone().setLength(j))}if(p>0){let j=p/F;M=x.clone().sub(new Xt(j,-p)),x.add(v.clone().setLength(j)),d&&(N=M.clone(),N.x-=C-G*p,ie.sub(v.clone().setLength(j)))}v=V.clone().sub(x);let D=v.length()<.5,R=[];for(let j=0;j<=i;j++){let B=[],k=j/i,ne=k*l+a,q=new Xt(Math.sin(ne),Math.cos(ne));N&&M?(K(B,k,q,pe,p,N,-1,!0),K(B,k,q,ce,p,M,-1,!1)):M?(Z(B,q,M.x,0,-1),K(B,k,q,ce,p,M,-1,!1)):s||Z(B,q,e,H,-1);let J=Jh(v).normalize();if(Wr(J,q,I),!D)for(let Y=0;Y<=o;Y++){let X=Y/o,Q=v.clone().multiplyScalar(X).add(x);Wr(Q,q,b),T.push(b.x,b.y,b.z),w.push(I.x,I.y,I.z),y.push(k,.5+b.y/r),B.push(L++)}if(g&&u?(K(B,k,q,pe,c,u,1,!1),K(B,k,q,ce,c,g,1,!0)):u?(K(B,k,q,pe,c,u,1,!1),Z(B,q,u.x,0,1)):s||Z(B,q,t,$,1),d&&!D){let Y=Jh(v).multiplyScalar(-1).normalize();Wr(Y,q,I);for(let X=0;X<=o;X++){let Q=X/o,se=v.clone().multiplyScalar(-Q).add(ie);Wr(se,q,b),T.push(b.x,b.y,b.z),w.push(I.x,I.y,I.z),y.push(k,.5+b.y/r),B.push(L++)}}d&&!s&&B.push(B[0]),R.push(B)}for(let j=0;j<R.length-1;j++)for(let B=0;B<R[0].length-1;B++){if(s&&d&&B==o)continue;let k=R[j][B],ne=R[j+1][B],q=R[j+1][B+1],J=R[j][B+1],Y=T[q*3+0],X=T[q*3+2];f.push(k,ne,J),(Y!=0||X!=0)&&f.push(ne,q,J)}l<Math.PI*2&&(U(-1,R[0],a),U(1,R[R.length-1],a+l)),this.setIndex(f),this.setAttribute("position",new Za(T,3)),this.setAttribute("normal",new Za(w,3)),this.setAttribute("uv",new Za(y,2));function K(j,B,k,ne,q,J,Y,X){for(let Q=0;Q<h+1;Q++){let se=Q/h,oe=Y<0?se:1-se;X&&(oe-=1),oe*=ne;let he=new Xt(Math.sin(oe),Math.cos(oe)*Y),Ee=he.clone().multiplyScalar(q).add(J);Wr(Ee,k,b),T.push(b.x,b.y,b.z),Wr(he,k,I),w.push(I.x,I.y,I.z),y.push(B,.5+b.y/r),j.push(L++)}}function Z(j,B,k,ne,q){let J=new Bs,Y=new Xt,X=[k,ne];q<0&&X.reverse();for(let Q of X)Y.set(Q,A*q),Wr(Y,B,J),T.push(J.x,J.y,J.z),w.push(0,q,0),y.push(.5,.5),j.push(L++)}function U(j,B,k){let ne=new Xt(Math.sin(k),Math.cos(k)),q=new Xt(-Math.cos(k),Math.sin(k)),J=new Bs,Y=j<0?(se,oe,he)=>f.push(se,oe,he):(se,oe,he)=>f.push(se,he,oe),X=new Xt((t+e+$+H)/4,0);Wr(X,ne,J),T.push(J.x,J.y,J.z),w.push(q.x,0,q.y),y.push(.5,.5);let Q=L++;for(let se of B){let oe=T.slice(se*3,se*3+3);T.push(...oe),w.push(q.x,0,q.y);let he=y.slice(se*2,se*2+2);y.push(...he),L++}for(let se=Q+1;se<L-1;se++)Y(Q,se,se+1);Y(Q,L-1,Q+1)}}};var Yh=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){var r,i,o;let e=Object.assign({},(r=t==null?void 0:t.parameters)!=null?r:{width:100,radialSegments:32,heightSegments:8,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadiusTop:0,cornerRadiusBottom:0,cornerSegments:8},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs((i=e.height)!=null?i:e.width),depth:Math.abs((o=e.depth)!=null?o:e.width)})}}static build(n){let{width:t,depth:e,height:r,radialSegments:i,heightSegments:o,openEnded:s,thetaStart:a,thetaLength:l,cornerRadiusTop:c,cornerRadiusBottom:p,cornerSegments:h}=n.parameters,d;return c>0||p>0||l<360?d=new Uo(0,t/2,r,i,o,s,a,l*Math.PI/180,c,p,h,0,!0):d=new pb(t/2,r,i,o,s),d.scale(1,1,e/t),Object.assign(d,{userData:W(P({},n),{type:"ConeGeometry"})})}};import{BoxBufferGeometry as hb,BufferGeometry as db,Float32BufferAttribute as Qa,Vector3 as ko}from"three";var Xh=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){var r,i,o;let e=Object.assign({},(r=t==null?void 0:t.parameters)!=null?r:{width:100,widthSegments:1,heightSegments:1,depthSegments:1,cornerRadius:0,cornerSegments:8},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs((i=e.height)!=null?i:e.width),depth:Math.abs((o=e.depth)!=null?o:e.width)})}}static build(n){let{width:t,height:e,depth:r,widthSegments:i,heightSegments:o,depthSegments:s,cornerRadius:a,cornerSegments:l}=n.parameters,c;return a==0?c=new hb(t,e,r,i,o,s):c=new tl(t,e,r,i,o,s,a,l),Object.assign(c,{userData:W(P({},n),{type:"CubeGeometry"})})}},el=Math.PI/2,tl=class extends db{constructor(t=1,e=1,r=1,i=1,o=1,s=1,a=0,l=4){super(),this.type="BoxBufferGeometry";let c=this;i=Math.floor(i),o=Math.floor(o),s=Math.floor(s),l=Math.floor(l),a=Math.min(a,t/2,e/2,r/2);let p=[],h=[],d=[],m=[],f=0,T=0;w("z","y","x",-1,-1,r,e,t,s,o,0),w("z","y","x",1,-1,r,e,-t,s,o,1),w("x","z","y",1,1,t,r,e,i,s,2),w("x","z","y",1,-1,t,r,-e,i,s,3),w("x","y","z",1,-1,t,e,r,i,o,4),w("x","y","z",-1,-1,t,e,-r,i,o,5),a>0&&(y("z","y","x",-1,-1,1,r,e,t,s,0),y("z","y","x",1,-1,-1,r,e,t,s,1),y("z","y","x",-1,1,-1,r,e,t,s,1),y("z","y","x",1,1,1,r,e,t,s,0),y("x","y","z",-1,-1,-1,t,e,r,i,0),y("x","y","z",1,-1,1,t,e,r,i,1),y("x","y","z",-1,1,1,t,e,r,i,0),y("x","y","z",1,1,-1,t,e,r,i,1),y("y","x","z",-1,-1,1,e,t,r,o,0),y("y","x","z",1,-1,-1,e,t,r,o,1),y("y","x","z",1,1,1,e,t,r,o,1),y("y","x","z",-1,1,-1,e,t,r,o,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(p),this.setAttribute("position",new Qa(h,3)),this.setAttribute("normal",new Qa(d,3)),this.setAttribute("uv",new Qa(m,2));function w(A,I,b,V,x,u,M,g,N,v,C){let $=(u-2*a)/N,H=(M-2*a)/v,ie=u/2-a,pe=M/2-a,ce=g/2,be=N+1,F=v+1,G=0,_=0,z=new ko;for(let D=0;D<F;D++){let R=D*H-pe;for(let K=0;K<be;K++){let Z=K*$-ie;z[A]=Z*V,z[I]=R*x,z[b]=ce,h.push(z.x,z.y,z.z),z[A]=0,z[I]=0,z[b]=g>0?1:-1,d.push(z.x,z.y,z.z),m.push(K/N),m.push(1-D/v),G+=1}}for(let D=0;D<v;D++)for(let R=0;R<N;R++){let K=f+R+be*D,Z=f+R+be*(D+1),U=f+(R+1)+be*(D+1),j=f+(R+1)+be*D;p.push(K,Z,j),p.push(Z,U,j),_+=6}c.addGroup(T,_,C),T+=_,f+=G}function y(A,I,b,V,x,u,M,g,N,v,C){let $=(M-2*a)/v,H=M/2-a,ie=g/2-a,pe=N/2,ce=v+1,be=0,F=0,G=new ko,_=new ko;for(let z=0;z<l+1;z++){let D=z/l*el,R=Math.sin(D)*a,K=(1-Math.cos(D))*a,Z=Math.sin(D),U=Math.cos(D);G[I]=(ie+R)*x,G[b]=(pe-K)*u,_[A]=0,_[I]=Z*Math.sign(G[I]),_[b]=U*Math.sign(G[b]);for(let j=0;j<ce;j++){let B=j*$-H;G[A]=B*V,h.push(G.x,G.y,G.z),d.push(_.x,_.y,_.z),m.push(j/v),m.push(0),be+=1}}for(let z=0;z<l;z++)for(let D=0;D<v;D++){let R=f+D+ce*z,K=f+D+ce*(z+1),Z=f+(D+1)+ce*(z+1),U=f+(D+1)+ce*z;p.push(R,K,U),p.push(K,Z,U),F+=6}c.addGroup(T,F,C),T+=F,f+=be}function L(A,I,b){let V=new ko,x=new ko(t/2,e/2,r/2);x.subScalar(a);let u=[],M=A*I*b>0?(N,v,C)=>p.push(N,v,C):(N,v,C)=>p.push(N,C,v);for(let N=0;N<=l;N++){let v=[],C=el*(1-N/l),$=Math.cos(C),H=Math.sin(C),ie=0;for(let pe=0;pe<=N;pe++){let ce=Math.cos(ie),be=Math.sin(ie);V.x=$*ce,V.y=H,V.z=$*be;let F=x.clone().addScaledVector(V,a);h.push(A*F.x,I*F.y,b*F.z),d.push(A*V.x,I*V.y,b*V.z),m.push(0,0),v.push(f++),ie+=el/N}u.push(v)}let g=u.length-1;for(let N=0;N<g;N++){let v=u[N],C=u[N+1],$=v.length-1;M(v[0],C[1],C[0]);for(let H=1;H<=$;H++)M(v[H-1],v[H],C[H]),M(v[H],C[H+1],C[H])}}}};import{BufferGeometry as ub,Float32BufferAttribute as rl,Triangle as mb,Vector3 as Nr,Vector2 as il}from"three";var $r=class extends ub{constructor(t=[],e=[],r="",i=1,o=.2,s=4){super(),this.type="PolyhedronGeometryRound";let a=[],l=[],c=[];p(),h(),this.setAttribute("position",new rl(a,3)),this.setAttribute("normal",new rl(c,3)),this.setAttribute("uv",new rl(l,2));return;function p(){var be;o=Math.min(1-1e-5,o),o==0&&(s=0);let m={IcosahedronGeometry:5,DodecahedronGeometry:3,HexahedronGeometry:3,OctahedronGeometry:4,TetrahedronGeometry:3}[r],f=new Nr,T=f.clone(),w=new mb,y=o*i,L=i-y,A=s+1,I=new Nr,b=(F,G)=>I.subVectors(F,G).normalize(),V=(F,G)=>Array(F).fill(void 0).map(G),x=V(t.length/3,(F,G)=>new Nr().fromArray(t,G*3).setLength(i)),u=[],M=1e6;for(let F=0;F<x.length;F++){let G=x[F],_=[],z,D,R,K=1e10,Z=-1;for(;(Z=e.indexOf(F,Z+1))!=-1;){let k=Z-Z%3;z=e[k+(Z+1)%3],D=e[k+(Z+2)%3],R=G.distanceToSquared(x[z]),K=Math.min(K,R),_.push([z,D,R])}K+=1e-6;let U=[],j=0,B=_.length;for(let k=0;k<B;k++){[z,D,R]=_[j];let ne=((be=u[z])==null?void 0:be.includes(F))==!0;R<=K&&U.push(z+ +ne*M),j=_.findIndex(q=>q[0]==D)}u.push(U)}let g=[];{let F=0,G=0,_,z,D=m==3;for(let R=0;R<=s;R++){_=R*(R+1)/2,z=(R+1)*(R+2)/2;for(let K=0;K<s-R;K++)[F,G]=[_+K+R+2,z+K+R+3],g.push(_,z,...D?[G,_]:[F,z],G,F),[_,z]=[F,G];g.push(_,z,_+s+2)}}let N=f.clone(),v=f.clone(),C=f.clone(),$=f.clone(),H=f.clone(),ie=[],pe=V(x.length,()=>V(m,()=>f.clone()));for(let F=0;F<x.length;F++){f.copy(x[F]).normalize(),N.copy(f).multiplyScalar(L);let G=u[F];for(let U=0;U<G.length;U++){let j=G[U],B=G[(U+1)%m];w.setFromPointsAndIndices(x,F,j%M,B%M),w.b.sub(w.a).setLength(1e10).add(w.a),w.c.sub(w.a).setLength(1e10).add(w.a),w.closestPointToPoint(N,pe[F][U])}let _=[],z=[],D=[],R=new Nr;s==0&&[...pe[F]].reduce((U,j)=>U.add(j),R).multiplyScalar(1/m);for(let U=0;U<m;U++){let j=[],B=(U-1+m)%m,k=pe[F][B],ne=pe[F][U];f.copy(k).sub(N),T.copy(ne).sub(N);let q=N.angleTo(f),J=f.angleTo(T),Y=Math.cos(q)*y;s==0?v.copy(R):v.copy(N).setLength(L+Y),z.push(Y);let X=[v,k,ne];for(let Q=0;Q<2;Q++){let se=X[Q],oe=X[Q+1];$.subVectors(se,N),H.subVectors(oe,N),C.crossVectors($,H).normalize();for(let he=0;he<A;he++){let Ee=[q,J][Q]*he/A;f.copy($).applyAxisAngle(C,Ee).add(N),_.push(f.clone()),Q&&(b(f,N),j.push([he==0?se:f.clone(),I.clone()]))}Q&&(b(oe,N),j.push([oe,I.clone()]))}D.push(j)}ie.push(D);let K=2*A,Z=2;for(let U=0;U<m;U++){let j=K*U,B=K*((U+1)%m),k=[_[j]];for(let q=1;q<A;q++){$=_[j+q],H=_[B+q],k.push($);for(let J=1,Y=q-Z+1;J<=Y;J++)f.lerpVectors($,H,J/(Y+1)),f.sub(N).setLength(z[U]).add(N),k.push(f.clone());k.push(H)}for(let q=0;q<A;q++)k.push(_[q+A+j]);k.push(_[B+A]);let ne=g.map(q=>k[q]);a.push(...ne.map(q=>[q.x,q.y,q.z]).flat()),c.push(...ne.map(q=>(b(q,N),[I.x,I.y,I.z])).flat())}}let ce=[];for(let F=0;F<u.length;F++)for(let G=0;G<m;G++){let _=u[F][G];if(_<M){let z=u[_].findIndex(K=>K%M==F),D=ie[F][G],R=ie[_][z];for(let K=0;K<A;K++){let Z=D[K],U=R[A-K],j=D[K+1],B=R[A-(K+1)];[Z,U,j,j,U,B].forEach(k=>{a.push(k[0].x,k[0].y,k[0].z),c.push(k[1].x,k[1].y,k[1].z)})}ce.push(D[0][0],R[A][0],D[A][0],R[0][0])}}for(;ce.length;){let F,G,_,z;[F,G]=ce.splice(0,2);let D=[F];for(;F!=G;)D.push(G),_=ce.indexOf(G),z=_%2,G=ce.splice(_-z,2)[1-z];I.subVectors(D[0],D[1]).cross(f.subVectors(D[0],D[2])).normalize();let R=I.dot(D[0])<0;R&&I.negate();for(let K=1;K<=D.length-2;K++)[D[K+ +R],D[K+1-+R],D[0]].forEach(Z=>{a.push(Z.x,Z.y,Z.z),c.push(I.x,I.y,I.z)})}}function h(){let d=new Nr;for(let x=0;x<a.length;x+=3){d.x=a[x+0],d.y=a[x+1],d.z=a[x+2];let u=b(d)/2/Math.PI+.5,M=V(d)/Math.PI+.5;l.push(u,1-M)}let m=new Nr,f=new Nr,T=new Nr,w=new Nr,y=new il,L=new il,A=new il,I=(x,u,M,g)=>{g<0&&x.x===1&&(l[u]=x.x-1),M.x===0&&M.z===0&&(l[u]=g/2/Math.PI+.5)};for(let x=0,u=0;x<a.length;x+=9,u+=6){m.set(a[x+0],a[x+1],a[x+2]),f.set(a[x+3],a[x+4],a[x+5]),T.set(a[x+6],a[x+7],a[x+8]),y.set(l[u+0],l[u+1]),L.set(l[u+2],l[u+3]),A.set(l[u+4],l[u+5]),w.copy(m).add(f).add(T).divideScalar(3);let M=b(w);I(y,u+0,m,M),I(L,u+2,f,M),I(A,u+4,T,M)}for(let x=0;x<l.length;x+=6){let u=l[x+0],M=l[x+2],g=l[x+4],N=Math.max(u,M,g),v=Math.min(u,M,g);N>.9&&v<.1&&(u<.2&&(l[x+0]+=1),M<.2&&(l[x+2]+=1),g<.2&&(l[x+4]+=1))}function b(x){return Math.atan2(x.z,-x.x)}function V(x){return Math.atan2(-x.y,Math.sqrt(x.x*x.x+x.z*x.z))}}}static fromJSON(t){return new $r(t.vertices,t.indices,t.radius,t.corner,t.cornerSides)}};import{DodecahedronBufferGeometry as fb}from"three";var Zh=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){var r,i,o;let e=Object.assign({},(r=t==null?void 0:t.parameters)!=null?r:{width:100,detail:0,corner:0,cornerSides:4},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs((i=e.height)!=null?i:e.width),depth:Math.abs((o=e.depth)!=null?o:e.width)})}}static build(n){let{width:t,height:e,depth:r,detail:i,corner:o,cornerSides:s}=n.parameters,a=i===0&&o!==0?new Ho(t*.5,o,s):new fb(t*.5,i);return a.scale(1,e/t,r/t),Object.assign(a,{userData:W(P({},n),{type:"DodecahedronGeometry"})})}},Ho=class extends $r{constructor(t=1,e=.2,r=4){let i=(1+Math.sqrt(5))/2,o=1/i,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,-o,-i,0,-o,i,0,o,-i,0,o,i,-o,-i,0,-o,i,0,o,-i,0,o,i,0,-i,0,-o,i,0,-o,-i,0,o,i,0,o],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,t,e,r),this.type=l}static fromJSON(t){return new Ho(t.radius,t.corner,t.cornerSides)}};import{EventDispatcher as Nb,Plane as Mb,Shape as pd,Vector2 as Mr,Vector3 as Ob,MathUtils as pl,LineCurve as hl,QuadraticBezierCurve as hd,CubicBezierCurve as zs}from"three";import{CubicBezierCurve as Es,EllipseCurve as yb,LineCurve as Gs,LineCurve3 as gb,MathUtils as xb,QuadraticBezierCurve as ol,SplineCurve as bb,Vector2 as Zt,Vector3 as Qh}from"three";var qo=1e-12,Yi=class{constructor(t){this.position=new Zt;this.startPosition=new Zt;this.uuid=xb.generateUUID();this.position=t.clone()}start(){this.reset()}reset(){this.startPosition.copy(this.position)}applyOffset(t){this.position.copy(this.startPosition).add(t)}copy(t){return this.position.copy(t.position),this.startPosition.copy(t.startPosition),this}clone(){return new Yi(this.position).copy(this)}toJSON(){return[this.position.x,this.position.y]}},Xi=class extends Yi{constructor(e){super(e.position);this.parent=e}copy(e){return super.copy(e),this}clone(){return new Xi(this.parent).copy(this)}},Qt=class extends Yi{constructor(e,r){super(r);this.controls=[];this.roundness=0;this.areControlsDirectionsMirrored=!0;this.uuid=e,this.controls.push(new Xi(this),new Xi(this))}static create(e,r){let i=new Qt(e,new Zt(...r.position));return i.controls[0].position.set(...r.controlPrevious.position),i.controls[1].position.set(...r.controlNext.position),i.roundness=r.roundness,i.areControlsDirectionsMirrored=r.areControlsDirectionsMirrored,i}getOppositeControl(e){let r=this.controls.indexOf(e);return r===0?this.controls[1]:r===1?this.controls[0]:null}applyOffsetToControls(e,r=1){for(let i=0,o=this.controls.length;i<o;i++){let s=this.controls[i];this.position.distanceTo(s.position)<=r?s.position.copy(this.position):s.applyOffset(e)}}controlsMoved(){return!(this.position.equals(this.controls[0].position)&&this.position.equals(this.controls[1].position))}copy(e){return super.copy(e),this.controls[0].copy(e.controls[0]),this.controls[1].copy(e.controls[1]),this.roundness=e.roundness,this.uuid=e.uuid,this}clone(){return new Qt(this.uuid,this.position).copy(this)}toJSON(){return super.toJSON().concat(this.controls[0].toJSON(),this.controls[1].toJSON(),[this.roundness])}},nl=n=>n,$o=new Zt,sl=new Zt,vb=new Zt,Sb=new Zt,wb=new Zt,Lb=new Zt,ed=new Qh,td=new Qh;function rd(n){let t=new Zt;t.addVectors(n.v0,$o.subVectors(n.v1,n.v0).multiplyScalar(2/3));let e=new Zt;return e.addVectors(n.v2,sl.subVectors(n.v1,n.v2).multiplyScalar(2/3)),new Es(n.v0,t,e,n.v2)}function Wo(n,t,e=Number.EPSILON){return Math.abs(n-t)<e}function Cb(n,t,e=Number.EPSILON){return n.distanceTo(t)<e}function Tb(n,t,e=Number.EPSILON){return n.distanceTo(t)<e}function al(n,t,e){let r=Math.sqrt(Math.pow(t.x-n.x,2)+Math.pow(t.y-n.y,2)),i=Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2)),o=Math.sqrt(Math.pow(e.x-n.x,2)+Math.pow(e.y-n.y,2));return Math.acos((i*i+r*r-o*o)/(2*i*r))}function id(n,t,e,r,i){let o=Math.sqrt(Math.pow(t.x-n.x,2)+Math.pow(t.y-n.y,2)),s=(n.y+t.y)/2,a=(n.x+t.x)/2,l=Math.sqrt(Math.pow(e,2)-Math.pow(o/2,2))*(n.y-t.y)/o,c=Math.sqrt(Math.pow(e,2)-Math.pow(o/2,2))*(t.x-n.x)/o;return r.set(a+l,s+c),i.set(a-l,s-c),[r,i]}function od(n,t,e){let r=n.distanceTo(e),i=t.distanceTo(e);return r<i?t:n}function nd(n,t,e,r,i,o){let s=t.x-n.x,a=t.y-n.y,l=e.x-n.x,c=e.y-n.y,p=Math.sqrt((s+l)*(s+l)+(a+c)*(a+c)),h;return al(t,n,e)>Math.PI&&(p*=-1),Wo(c,a)?h=(a+c)*(r/p-.5)*8/3/(s-l):h=(s+l)*(r/p-.5)*8/3/(c-a),i.set(t.x-h*a,t.y+h*s),o.set(e.x+h*c,e.y-h*l),[i,o]}function ll(n,t){return n.position.equals(n.controls[1].position)&&t.position.equals(t.controls[0].position)}function sd(n,t,e,r,i=.5){let o=$o.subVectors(t,n).multiplyScalar(i).add(n),s=sl.subVectors(e,t).multiplyScalar(i).add(t),a=vb.subVectors(r,e).multiplyScalar(i).add(e),l=o,c=Sb.subVectors(s,o).multiplyScalar(i).add(o),p=wb.subVectors(a,s).multiplyScalar(i).add(s),h=a,d=Lb.subVectors(p,c).multiplyScalar(i).add(c);return[n.x,n.y,l.x,l.y,c.x,c.y,d.x,d.y,p.x,p.y,h.x,h.y,r.x,r.y]}function ad(n,t,e=12,r=!0){let i=td.set(0,0,0),o,s=0,a=[];for(let l=0;l<t.length;l++){let c=nl(t[l]),p=$o,h=Jr(c,e);a.push(h);for(let d=0;d<=h;d++)if(c instanceof Es||c instanceof ol||c instanceof Gs){if(c.getPoint(d/h,p),i.set(p.x,p.y,0),o!==void 0&&Tb(o,i))continue;o===void 0&&(o=ed),o.copy(i),n.setXYZ(s,i.x,i.y,i.z),s++}}return r&&s>1&&!(n.getX(s-1)===n.getX(0)&&n.getY(s-1)===n.getY(0)&&n.getZ(s-1)===n.getZ(0))&&(n.setXYZ(s,n.getX(0),n.getY(0),n.getZ(0)),s++),n}function ld(n,t,e,r=12,i=!0){let o=td.set(0,0,0),s=0,a=[];for(let l=0;l<t.length;l++){if(e[l]===!1)continue;let c,p=nl(t[l]),h=$o,d=Jr(p,r);a.push(d);for(let m=0;m<=d;m++)if(p instanceof Es||p instanceof ol||p instanceof Gs){if(p.getPoint(m/d,h),o.set(h.x,h.y,0),c!=null&&c.equals(o))continue;c===void 0?c=ed:(n.setXYZ(s,c.x,c.y,c.z),s++,n.setXYZ(s,o.x,o.y,o.z),s++),c.copy(o)}}return i&&s>1&&!(n.getX(s-1)===n.getX(0)&&n.getY(s-1)===n.getY(0)&&n.getZ(s-1)===n.getZ(0))&&(n.setXYZ(s,n.getX(0),n.getY(0),n.getZ(0)),s++),a}function cl(n,t=12,e=!1){let r=[];for(let i=0,o=n.length;i<o;i++){let s=n[i],a=0;if(e&&s.roundedCurveCorner!==void 0){let l=Jr(s.roundedCurveCorner,t)*.5;i>0&&(r[i-1]+=l),a+=l}s.curveAfter!==void 0&&(a+=Jr(s.curveAfter,t)),r.push(a)}return n.length>0&&e&&n[0].roundedCurveCorner!==void 0&&(r[n.length-1]+=Jr(n[0].roundedCurveCorner,t)*.5),r}function Jr(n,t=12){return n&&n instanceof yb?t*2:n&&(n instanceof Gs||n instanceof gb)?1:n&&n instanceof bb?t*n.points.length:t}function cd(n,t,e=12,r=!0){let i,o=0;for(let s=0;s<t.length;s++){let a=nl(t[s]),l=Jr(a,e),c=$o;for(let p=0;p<=l;p++)if(a instanceof Es||a instanceof ol||a instanceof Gs){if(a.getPoint(p/l,c),i!==void 0&&Cb(i,c,qo))continue;i===void 0&&(i=sl),i.copy(c),n.push(c.x,c.y),o++}}return Wo(n[0],n[n.length-2],qo)&&Wo(n[1],n[n.length-1],qo)&&(n.pop(),n.pop()),r&&o>1&&!(Wo(n[o-1],n[1],qo)&&Wo(n[o-2],n[0],qo))&&(n.push(n[0],n[1]),o++),n}var dl=new Mr,Ib=new Mr,Pb=new Mr,Ab=new Mr,Db=new Mr,_b=new Mr,Me=class extends pd{constructor(e=100,r=100){super();this.points=[];this.shapeHoles=[];this.eventDispatcher=new Nb;this.plane=new Mb(new Ob(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=r}static createFromState(e,r,i){let o=new Me;return o.isClosed=e.isClosed,o.points=e.points.map(s=>Qt.create(s.id,s.data)),typeof e.roundness=="number"&&(o.roundness=e.roundness),o.shapeHoles=e.shapeHoles.map(s=>Me.createFromState(s)),r!==void 0&&i!==void 0&&o.applySize(r,i),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 r=0,i=this.points.length;r<i;r++)this.points[r].roundness=e;this.needsUpdate=!0}}getPointsIndexesByIds(e){return e.map(r=>this.getPointIndexById(r)).filter(r=>r>=0)}getPointIndexById(e){return this.points.findIndex(r=>r.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 r=0,i=this.shapeHoles.length;r<i;r++){let o=this.shapeHoles[r],s=e-this.points.length;if(s<=o.points.length-1)return o.points[s]}throw new Error("This shape does not have a point for this index: "+e)}getBezierPointIndex(e){let r=this.points.indexOf(e);if(r>=0)return r;if(r=this.points.length,this.shapeHoles.length>0)for(let i=0,o=this.shapeHoles.length;i<o;i++){let s=this.shapeHoles[i],a=s.points.indexOf(e);if(a>=0)return r+a;r+=s.points.length}return-1}getAllPoints(){let e=[].concat(...this.shapeHoles.map(r=>r.points));return[...this.points,...e]}applySize(e,r){e===0&&(e=.001),r===0&&(r=.001),this._width=e,this._height=r}applyScale(e,r){let i=dl.set(e,r);for(let o=0,s=this.points.length;o<s;o++){let a=this.points[o];a.position.multiply(i),a.controls[0].position.multiply(i),a.controls[1].position.multiply(i)}for(let o=0,s=this.shapeHoles.length;o<s;o++)this.shapeHoles[o].applyScale(e,r);this._update(!1)}createPoint(e,r=0,i=pl.generateUUID()){let o;e instanceof Mr?o=e:o=new Mr(e,r);let s=new Qt(i,o);return s.roundness=this.roundness,s}addPoint(e){this.points.push(e),this.needsUpdate=!0}addPointAt(e,r){this.points.splice(r,0,e),this.needsUpdate=!0}getPointByUuid(e){for(let r=0,i=this.points.length;r<i;r++){let o=this.points[r];if(o.uuid===e)return o}}getFirstPoint(){return this.points[0]}getLastPoint(){return this.points[this.points.length-1]}removePoint(e){let r=this.points.indexOf(e);r>=0&&this.points.splice(r,1),this.needsUpdate=!0}removePointById(e){let r=this.points.find(i=>i.uuid===e);r&&this.removePoint(r)}update(e=!0){for(let r=0,i=this.shapeHoles.length;r<i;r++)this.shapeHoles[r].update(!1);this._update(e)}extractShapePointsToBuffer(e,r=12,i=!1){this.subdivision=r,this.curveDivisions===void 0&&this.computeCurveDivisions(r);let o=i?this.roundedCurveDivisions:this.curveDivisions;return ad(e,i?this.roundedCurves:this.curves,r,this.autoClose),o.reduce((s,a)=>s+a,0)+1}computeCurveDivisions(e=12){return this.curveDivisions=cl(this.points,e,!1),this.roundedCurveDivisions=cl(this.points,e,!0),this.curveDivisions}extractFilteredShapePointsToBuffer(e,r,i=12){return ld(e,this.curves,r,i,this.autoClose).reduce((s,a)=>s+a,0)*2}extractShapePointsToFlatArray(e,r=12){return this.subdivision=r,this.curveDivisions===void 0&&this.computeCurveDivisions(r),cd(e,this.roundedCurves,r,this.autoClose)}getCurveIndexFromVertexId(e,r=!1){let i=0;this.curveDivisions===void 0&&this.computeCurveDivisions(this.subdivision);let o=r?this.roundedCurveDivisions:this.curveDivisions,s=0;r&&this.points[0].roundedCurveCorner!==void 0&&(s=Jr(this.points[0].roundedCurveCorner,this.subdivision)*.5);let a=e-s;a<0&&(a+=o.reduce((l,c)=>l+c,0));for(let l=0,c=o.length;l<c;l++){let p=o[l];if(a<i+p)return[l,(a-i+1)/p];i+=p}return[0,1]}getCurveT(e,r,i){let o=this.points[e],s=this.points[e>=this.points.length-1?0:e+1],a=this.curveDivisions,l=a[e];if(ll(o,s)){let h=o.position.distanceTo(s.position);return o.position.distanceTo(dl.set(i.x,i.y))/h}let c=0;for(let h=0;h<e;h++)c+=a[h];return(r-c)/l}dispose(){this.eventDispatcher=null}_applyCurveForPoint(e,r){ll(r,e)?this.lineTo(e.position.x,e.position.y):this.bezierCurveTo(r.controls[1].position.x,r.controls[1].position.y,e.controls[0].position.x,e.controls[0].position.y,e.position.x,e.position.y);let i=this.curves[this.curves.length-1];e.curveBefore=i,r.curveAfter=i;let o=i.clone();e.roundedCurveBefore=o,r.roundedCurveAfter=o,e.roundedCurveCorner=void 0,this.roundedCurves.push(o)}_update(e=!0){var i;if(this.curves=[],this.roundedCurves=[],!this.points.length)return;for(let o=0,s=this.points.length;o<s;o++){let a=this.points[o];if(o===0)this.moveTo(a.position.x,a.position.y);else{let l=this.points[o-1];this._applyCurveForPoint(a,l)}}let r=this.getLastPoint();if(r!=null&&r.curveAfter&&(r.curveAfter=void 0),this.isClosed){let o=this.points[0],s=this.points[this.points.length-1];this._applyCurveForPoint(o,s)}if(this.points.length>2){let o=0;for(let s=0,a=this.points.length;s<a;s++){let l=this.points[s],c=l.roundness;if(!l.controlsMoved()&&c>0){let p=l.curveBefore,h=l.curveAfter;if(p===void 0||h===void 0)continue;let d=l.roundedCurveBefore,m=l.roundedCurveAfter,f=p.getLength(),T=h.getLength(),w=Math.min(c,f*.499),y=Math.min(c,T*.499),L=Math.min(w,y),A=1-L/f,I=L/T,b=p.getPointAt(A,dl),V=h.getPointAt(I,Ib);this._subSplitCurve(p,d,A,b,void 0),this._subSplitCurve(h,m,I,void 0,V);let x;if(this.useCubicForRoundedCorners){let u=al(b,l.position,V)/2,M=Math.tan(u)*b.distanceTo(l.position),[g,N]=id(b,V,M,Pb,Ab),v=od(g,N,l.position),[C,$]=nd(v,b,V,M,Db,_b);x=new zs(b.clone(),C.clone(),$.clone(),V.clone())}else x=new hd(b.clone(),l.position.clone(),V.clone());l.roundedCurveCorner=x,this.roundedCurves.splice(s+o,0,x),o++}}}e&&((i=this.eventDispatcher)==null||i.dispatchEvent({type:"update"}))}_subSplitCurve(e,r,i,o,s){if(e instanceof hl)o!==void 0&&r.v2.copy(o),s!==void 0&&r.v1.copy(s);else{let a=e,l=r,c=a.getUtoTmapping(i,0),p=sd(a.v0,a.v1,a.v2,a.v3,c);return o!==void 0&&(l.v0.set(p[0],p[1]),l.v1.set(p[2],p[3]),l.v2.set(p[4],p[5]),l.v3.set(p[6],p[7])),s!==void 0&&(l.v0.set(p[6],p[7]),l.v1.set(p[8],p[9]),l.v2.set(p[10],p[11]),l.v3.set(p[12],p[13])),l}return r}clone(){let e=new Me(this._width,this._height);return e.points=this.points.map(r=>r.clone()),e.isClosed=this.isClosed,e.roundness=this.roundness,e.isMesh2D=this.isMesh2D,e.shapeHoles=this.shapeHoles.map(r=>r.clone()),e}toJSON(){return{points:this.points.reduce((e,r)=>e.concat(r.toJSON()),[]),shapeHoles:this.shapeHoles.map(e=>e.toJSON()),isClosed:this.isClosed,roundness:this.roundness}}fromJSON(e){var i;this.points=[],this.pointIDs=0;let r=e.points.length/7;for(let o=0;o<r;o++){let s=o*7,a=e.points[s+0],l=e.points[s+1],c=e.points[s+2],p=e.points[s+3],h=e.points[s+4],d=e.points[s+5],m=e.points[s+6],f=new Qt(pl.generateUUID(),new Mr(a,l));f.controls[0].position.set(c,p),f.controls[1].position.set(h,d),f.roundness=m,this.points.push(f)}return this.shapeHoles=(i=e.shapeHoles)!=null&&i.length?e.shapeHoles.map(o=>{let s=new Me;return s.fromJSON(o),s}):[],this.isClosed=e.isClosed,this._roundness=e.roundness,this._update(),this}fromShape(e){let r=(o,s)=>{s instanceof zs&&s.v3.equals(o.position)&&o.controls[0].position.copy(s.v2)},i=o=>{let s=[],a,l;for(a=0,l=o.length;a<l;a++)o[a]instanceof hd&&(o[a]=rd(o[a]));for(a=0,l=o.length;a<l;a++){let h=o[a],d=a>0?o[a-1]:null,m;h instanceof zs?(m=this.createPoint(h.v0),m.controls[1].position.copy(h.v1)):h instanceof hl&&(m=this.createPoint(h.v1)),m!==void 0&&(d!==null&&r(m,d),s.push(m))}let c=o[o.length-1],p=!1;return c instanceof zs?c.v3.equals(s[0].position)&&(s[0].controls[0].position.copy(c.v2),p=!0):c instanceof hl&&c.v2.equals(s[0].position)&&(p=!0),this.isClosed=p,s};return this.points=i(e.curves),e instanceof pd&&(this.shapeHoles=e.holes.map(o=>{let s=new Me;return s.fromShape(o),s})),this.update(),this}};var ml=Math.PI*2;function ul({x:n,y:t},e,r,i,o){return{x:n*e+i,y:t*r+o}}function Bb(n,t){let e=t===1.5707963267948966?.551915024494:t===-1.5707963267948966?-.551915024494:1.3333333333333333*Math.tan(t/4),r=Math.cos(n),i=Math.sin(n),o=Math.cos(n+t),s=Math.sin(n+t);return[{x:r-i*e,y:i+r*e},{x:o+s*e,y:s-o*e},{x:o,y:s}]}function dd(n,t,e,r){let i=n*r-t*e<0?-1:1,o=Math.min(1,Math.max(-1,n*e+t*r));return i*Math.acos(o)}function Eb(n,t,e,r,i,o,s,a,l,c){let p=Math.pow(i,2),h=Math.pow(o,2),d=Math.pow(s,2),m=Math.pow(a,2),f=p*h-p*m-h*d;f<0&&(f=0),f/=p*m+h*d,f=Math.sqrt(f)*(l===c?-1:1);let T=f*i/o*a,w=f*-o/i*s,y=T+(n+e)/2,L=w+(t+r)/2,A=(s-T)/i,I=(a-w)/o,b=(-s-T)/i,V=(-a-w)/o,x=dd(1,0,A,I),u=dd(A,I,b,V);return!c&&u>0&&(u-=ml),c&&u<0&&(u+=ml),{centerx:y,centery:L,ang1:x,ang2:u}}function ud({px:n,py:t,cx:e,cy:r,rx:i,ry:o,largeArcFlag:s,sweepFlag:a}){let l=[];if(i===0||o===0)return[];let c=(n-e)/2,p=(t-r)/2;if(c===0&&p===0)return[];i=Math.abs(i),o=Math.abs(o);let h=Math.pow(c,2)/Math.pow(i,2)+Math.pow(p,2)/Math.pow(o,2);h>1&&(i*=Math.sqrt(h),o*=Math.sqrt(h));let d=Eb(n,t,e,r,i,o,c,p,s,a),{ang1:m,ang2:f}=d,{centerx:T,centery:w}=d,y=Math.abs(f)/(ml/4);Math.abs(1-y)<1e-7&&(y=1);let L=Math.max(Math.ceil(y),1);f/=L;for(let A=0;A<L;A++)l.push(Bb(m,f)),m+=f;return l.map(A=>{let{x:I,y:b}=ul(A[0],i,o,T,w),{x:V,y:x}=ul(A[1],i,o,T,w),{x:u,y:M}=ul(A[2],i,o,T,w);return{x1:I,y1:b,x2:V,y2:x,x:u,y:M}})}import{BufferAttribute as Vs,BufferGeometry as Fb}from"three";var He;(function(n){n[n.ODD=0]="ODD",n[n.NONZERO=1]="NONZERO",n[n.POSITIVE=2]="POSITIVE",n[n.NEGATIVE=3]="NEGATIVE",n[n.ABS_GEQ_TWO=4]="ABS_GEQ_TWO"})(He||(He={}));var rt;(function(n){n[n.POLYGONS=0]="POLYGONS",n[n.CONNECTED_POLYGONS=1]="CONNECTED_POLYGONS",n[n.BOUNDARY_CONTOURS=2]="BOUNDARY_CONTOURS"})(rt||(rt={}));function ue(n,t){if(!n)throw t||"Assertion Failed!"}var ae=function(){function n(){}return n.vertEq=function(t,e){return t.s===e.s&&t.t===e.t},n.vertLeq=function(t,e){return t.s<e.s||t.s===e.s&&t.t<=e.t},n.transLeq=function(t,e){return t.t<e.t||t.t===e.t&&t.s<=e.s},n.edgeGoesLeft=function(t){return n.vertLeq(t.Dst,t.Org)},n.edgeGoesRight=function(t){return n.vertLeq(t.Org,t.Dst)},n.vertL1dist=function(t,e){return Math.abs(t.s-e.s)+Math.abs(t.t-e.t)},n.edgeEval=function(t,e,r){ue(n.vertLeq(t,e)&&n.vertLeq(e,r));var i=e.s-t.s,o=r.s-e.s;return i+o>0?i<o?e.t-t.t+(t.t-r.t)*(i/(i+o)):e.t-r.t+(r.t-t.t)*(o/(i+o)):0},n.edgeSign=function(t,e,r){ue(n.vertLeq(t,e)&&n.vertLeq(e,r));var i=e.s-t.s,o=r.s-e.s;return i+o>0?(e.t-r.t)*i+(e.t-t.t)*o:0},n.transEval=function(t,e,r){ue(n.transLeq(t,e)&&n.transLeq(e,r));var i=e.t-t.t,o=r.t-e.t;return i+o>0?i<o?e.s-t.s+(t.s-r.s)*(i/(i+o)):e.s-r.s+(r.s-t.s)*(o/(i+o)):0},n.transSign=function(t,e,r){ue(n.transLeq(t,e)&&n.transLeq(e,r));var i=e.t-t.t,o=r.t-e.t;return i+o>0?(e.s-r.s)*i+(e.s-t.s)*o:0},n.vertCCW=function(t,e,r){return t.s*(e.t-r.t)+e.s*(r.t-t.t)+r.s*(t.t-e.t)>=0},n.interpolate=function(t,e,r,i){return t=t<0?0:t,r=r<0?0:r,t<=r?r===0?(e+i)/2:e+(i-e)*(t/(t+r)):i+(e-i)*(r/(t+r))},n.intersect=function(t,e,r,i,o){var s,a,l;n.vertLeq(t,e)||(l=t,t=e,e=l),n.vertLeq(r,i)||(l=r,r=i,i=l),n.vertLeq(t,r)||(l=t,t=r,r=l,l=e,e=i,i=l),n.vertLeq(r,e)?n.vertLeq(e,i)?(s=n.edgeEval(t,r,e),a=n.edgeEval(r,e,i),s+a<0&&(s=-s,a=-a),o.s=n.interpolate(s,r.s,a,e.s)):(s=n.edgeSign(t,r,e),a=-n.edgeSign(t,i,e),s+a<0&&(s=-s,a=-a),o.s=n.interpolate(s,r.s,a,i.s)):o.s=(r.s+e.s)/2,n.transLeq(t,e)||(l=t,t=e,e=l),n.transLeq(r,i)||(l=r,r=i,i=l),n.transLeq(t,r)||(l=t,t=r,r=l,l=e,e=i,i=l),n.transLeq(r,e)?n.transLeq(e,i)?(s=n.transEval(t,r,e),a=n.transEval(r,e,i),s+a<0&&(s=-s,a=-a),o.t=n.interpolate(s,r.t,a,e.t)):(s=n.transSign(t,r,e),a=-n.transSign(t,i,e),s+a<0&&(s=-s,a=-a),o.t=n.interpolate(s,r.t,a,i.t)):o.t=(r.t+e.t)/2},n}(),Jo=function(){function n(){this.next=null,this.prev=null,this.anEdge=null,this.trail=null,this.n=0,this.marked=!1,this.inside=!1}return n}(),Rs=function(){function n(t){this.side=t,this.next=null,this.Org=null,this.Sym=null,this.Onext=null,this.Lnext=null,this.Lface=null,this.activeRegion=null,this.winding=0}return Object.defineProperty(n.prototype,"Rface",{get:function(){return this.Sym.Lface},set:function(t){this.Sym.Lface=t},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Dst",{get:function(){return this.Sym.Org},set:function(t){this.Sym.Org=t},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Oprev",{get:function(){return this.Sym.Lnext},set:function(t){this.Sym.Lnext=t},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Lprev",{get:function(){return this.Onext.Sym},set:function(t){this.Onext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Dprev",{get:function(){return this.Lnext.Sym},set:function(t){this.Lnext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Rprev",{get:function(){return this.Sym.Onext},set:function(t){this.Sym.Onext=t},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Dnext",{get:function(){return this.Sym.Onext.Sym},set:function(t){this.Sym.Onext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Rnext",{get:function(){return this.Sym.Lnext.Sym},set:function(t){this.Sym.Lnext.Sym=t},enumerable:!0,configurable:!0}),n}(),Zi=function(){function n(){this.next=null,this.prev=null,this.anEdge=null,this.coords=[0,0,0],this.s=0,this.t=0,this.pqHandle=0,this.n=0,this.idx=0}return n}(),md=function(){function n(){var t=new Zi,e=new Jo,r=new Rs(0),i=new Rs(1);t.next=t.prev=t,t.anEdge=null,e.next=e.prev=e,r.next=r,r.Sym=i,i.next=i,i.Sym=r,this.vHead=t,this.fHead=e,this.eHead=r,this.eHeadSym=i}return n.prototype.makeEdge_=function(t){var e=new Rs(0),r=new Rs(1);t.Sym.side<t.side&&(t=t.Sym);var i=t.Sym.next;return r.next=i,i.Sym.next=e,e.next=t,t.Sym.next=r,e.Sym=r,e.Onext=e,e.Lnext=r,e.Org=null,e.Lface=null,e.winding=0,e.activeRegion=null,r.Sym=e,r.Onext=r,r.Lnext=e,r.Org=null,r.Lface=null,r.winding=0,r.activeRegion=null,e},n.prototype.splice_=function(t,e){var r=t.Onext,i=e.Onext;r.Sym.Lnext=e,i.Sym.Lnext=t,t.Onext=i,e.Onext=r},n.prototype.makeVertex_=function(t,e,r){var i=t;ue(i,"Vertex can't be null!");var o=r.prev;i.prev=o,o.next=i,i.next=r,r.prev=i,i.anEdge=e;var s=e;do s.Org=i,s=s.Onext;while(s!==e)},n.prototype.makeFace_=function(t,e,r){var i=t;ue(i,"Face can't be null");var o=r.prev;i.prev=o,o.next=i,i.next=r,r.prev=i,i.anEdge=e,i.trail=null,i.marked=!1,i.inside=r.inside;var s=e;do s.Lface=i,s=s.Lnext;while(s!==e)},n.prototype.killEdge_=function(t){t.Sym.side<t.side&&(t=t.Sym);var e=t.next,r=t.Sym.next;e.Sym.next=r,r.Sym.next=e},n.prototype.killVertex_=function(t,e){var r=t.anEdge,i=r;do i.Org=e,i=i.Onext;while(i!==r);var o=t.prev,s=t.next;s.prev=o,o.next=s},n.prototype.killFace_=function(t,e){var r=t.anEdge,i=r;do i.Lface=e,i=i.Lnext;while(i!==r);var o=t.prev,s=t.next;s.prev=o,o.next=s},n.prototype.makeEdge=function(){var t=new Zi,e=new Zi,r=new Jo,i=this.makeEdge_(this.eHead);return this.makeVertex_(t,i,this.vHead),this.makeVertex_(e,i.Sym,this.vHead),this.makeFace_(r,i,this.fHead),i},n.prototype.splice=function(t,e){var r=!1,i=!1;if(t!==e){if(e.Org!==t.Org&&(i=!0,this.killVertex_(e.Org,t.Org)),e.Lface!==t.Lface&&(r=!0,this.killFace_(e.Lface,t.Lface)),this.splice_(e,t),!i){var o=new Zi;this.makeVertex_(o,e,t.Org),t.Org.anEdge=t}if(!r){var s=new Jo;this.makeFace_(s,e,t.Lface),t.Lface.anEdge=t}}},n.prototype.delete=function(t){var e=t.Sym,r=!1;if(t.Lface!==t.Rface&&(r=!0,this.killFace_(t.Lface,t.Rface)),t.Onext===t)this.killVertex_(t.Org,null);else if(t.Rface.anEdge=t.Oprev,t.Org.anEdge=t.Onext,this.splice_(t,t.Oprev),!r){var i=new Jo;this.makeFace_(i,t,t.Lface)}e.Onext===e?(this.killVertex_(e.Org,null),this.killFace_(e.Lface,null)):(t.Lface.anEdge=e.Oprev,e.Org.anEdge=e.Onext,this.splice_(e,e.Oprev)),this.killEdge_(t)},n.prototype.addEdgeVertex=function(t){var e=this.makeEdge_(t),r=e.Sym;this.splice_(e,t.Lnext),e.Org=t.Dst;var i=new Zi;return this.makeVertex_(i,r,e.Org),e.Lface=r.Lface=t.Lface,e},n.prototype.splitEdge=function(t){var e=this.addEdgeVertex(t),r=e.Sym;return this.splice_(t.Sym,t.Sym.Oprev),this.splice_(t.Sym,r),t.Dst=r.Org,r.Dst.anEdge=r.Sym,r.Rface=t.Rface,r.winding=t.winding,r.Sym.winding=t.Sym.winding,r.idx=t.idx,r.Sym.idx=t.Sym.idx,r},n.prototype.connect=function(t,e){var r=!1,i=this.makeEdge_(t),o=i.Sym;if(e.Lface!==t.Lface&&(r=!0,this.killFace_(e.Lface,t.Lface)),this.splice_(i,t.Lnext),this.splice_(o,e),i.Org=t.Dst,o.Org=e.Org,i.Lface=o.Lface=t.Lface,t.Lface.anEdge=o,!r){var s=new Jo;this.makeFace_(s,i,t.Lface)}return i},n.prototype.zapFace=function(t){var e=t.anEdge,r,i,o,s,a;i=e.Lnext;do r=i,i=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)),o=r.Sym,o.Onext===o?this.killVertex_(o.Org,null):(o.Org.anEdge=o.Onext,this.splice_(o,o.Oprev)),this.killEdge_(r));while(r!=e);s=t.prev,a=t.next,a.prev=s,s.next=a},n.prototype.countFaceVerts_=function(t){var e=t.anEdge,r=0;do r++,e=e.Lnext;while(e!==t.anEdge);return r},n.prototype.mergeConvexFaces=function(t){var e,r,i,o,s,a,l;for(e=this.fHead.next;e!==this.fHead;e=e.next)if(!!e.inside)for(r=e.anEdge,s=r.Org;i=r.Lnext,o=r.Sym,o&&o.Lface&&o.Lface.inside&&(a=this.countFaceVerts_(e),l=this.countFaceVerts_(o.Lface),a+l-2<=t&&ae.vertCCW(r.Lprev.Org,r.Org,o.Lnext.Lnext.Org)&&ae.vertCCW(o.Lprev.Org,o.Org,r.Lnext.Lnext.Org)&&(i=o.Lnext,this.delete(o),r=null,o=null)),!(r&&r.Lnext.Org===s);)r=i;return!0},n.prototype.check=function(){var t=this.fHead,e=this.vHead,r=this.eHead,i,o,s,a,l,c;for(o=t,o=t;(i=o.next)!==t;o=i){ue(i.prev===o),l=i.anEdge;do ue(l.Sym!==l),ue(l.Sym.Sym===l),ue(l.Lnext.Onext.Sym===l),ue(l.Onext.Sym.Lnext===l),ue(l.Lface===i),l=l.Lnext;while(l!==i.anEdge)}for(ue(i.prev===o&&i.anEdge===null),a=e,a=e;(s=a.next)!==e;a=s){ue(s.prev===a),l=s.anEdge;do ue(l.Sym!==l),ue(l.Sym.Sym===l),ue(l.Lnext.Onext.Sym===l),ue(l.Onext.Sym.Lnext===l),ue(l.Org===s),l=l.Onext;while(l!==s.anEdge)}for(ue(s.prev===a&&s.anEdge===null),c=r,c=r;(l=c.next)!==r;c=l)ue(l.Sym.next===c.Sym),ue(l.Sym!==l),ue(l.Sym.Sym===l),ue(l.Org!==null),ue(l.Dst!==null),ue(l.Lnext.Onext.Sym===l),ue(l.Onext.Sym.Lnext===l);ue(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)},n}(),fd=function(){function n(){this.handle=null}return n}(),yd=function(){function n(){this.key=null,this.node=0}return n}(),Gb=function(){function n(t,e){this.leq=e,this.max=0,this.nodes=[],this.handles=[],this.initialized=!1,this.freeList=0,this.size=0,this.max=t,this.nodes=[],this.handles=[];for(var r=0;r<t+1;r++)this.nodes[r]=new fd,this.handles[r]=new yd;this.initialized=!1,this.nodes[1].handle=1,this.handles[1].key=null}return n.prototype.floatDown_=function(t){var e=this.nodes,r=this.handles,i,o,s;for(i=e[t].handle;;){if(s=t<<1,s<this.size&&this.leq(r[e[s+1].handle].key,r[e[s].handle].key)&&++s,ue(s<=this.max),o=e[s].handle,s>this.size||this.leq(r[i].key,r[o].key)){e[t].handle=i,r[i].node=t;break}e[t].handle=o,r[o].node=t,t=s}},n.prototype.floatUp_=function(t){var e=this.nodes,r=this.handles,i,o,s;for(i=e[t].handle;;){if(s=t>>1,o=e[s].handle,s===0||this.leq(r[o].key,r[i].key)){e[t].handle=i,r[i].node=t;break}e[t].handle=o,r[o].node=t,t=s}},n.prototype.init=function(){for(var t=this.size;t>=1;--t)this.floatDown_(t);this.initialized=!0},n.prototype.min=function(){return this.handles[this.nodes[1].handle].key},n.prototype.insert=function(t){var e,r;if(e=++this.size,e*2>this.max){this.max*=2;var i,o;for(o=this.nodes.length,this.nodes.length=this.max+1,i=o;i<this.nodes.length;i++)this.nodes[i]=new fd;for(o=this.handles.length,this.handles.length=this.max+1,i=o;i<this.handles.length;i++)this.handles[i]=new yd}return this.freeList===0?r=e:(r=this.freeList,this.freeList=this.handles[r].node),this.nodes[e].handle=r,this.handles[r].node=e,this.handles[r].key=t,this.initialized&&this.floatUp_(e),r},n.prototype.extractMin=function(){var t=this.nodes,e=this.handles,r=t[1].handle,i=e[r].key;return this.size>0&&(t[1].handle=t[this.size].handle,e[t[1].handle].node=1,e[r].key=null,e[r].node=this.freeList,this.freeList=r,--this.size,this.size>0&&this.floatDown_(1)),i},n.prototype.delete=function(t){var e=this.nodes,r=this.handles,i;ue(t>=1&&t<=this.max&&r[t].key!==null),i=r[t].node,e[i].handle=e[this.size].handle,r[e[i].handle].node=i,--this.size,i<=this.size&&(i<=1||this.leq(r[e[i>>1].handle].key,r[e[i].handle].key)?this.floatDown_(i):this.floatUp_(i)),r[t].key=null,r[t].node=this.freeList,this.freeList=t},n}(),fl=function(){function n(){this.eUp=null,this.nodeUp=null,this.windingNumber=0,this.inside=!1,this.sentinel=!1,this.dirty=!1,this.fixUpperEdge=!1}return n}(),gd=function(){function n(){this.key=null,this.next=null,this.prev=null}return n}(),zb=function(){function n(t,e){this.frame=t,this.leq=e,this.head=new gd,this.head.next=this.head,this.head.prev=this.head}return n.prototype.min=function(){return this.head.next},n.prototype.max=function(){return this.head.prev},n.prototype.insert=function(t){return this.insertBefore(this.head,t)},n.prototype.search=function(t){var e=this.head;do e=e.next;while(e.key!==null&&!this.leq(this.frame,t,e.key));return e},n.prototype.insertBefore=function(t,e){do t=t.prev;while(t.key!==null&&!this.leq(this.frame,t.key,e));var r=new gd;return r.key=e,r.next=t.next,t.next.prev=r,r.prev=t,t.next=r,r},n.prototype.delete=function(t){t.next.prev=t.prev,t.prev.next=t.next},n}(),Rb=function(){function n(){}return n.regionBelow=function(t){return t.nodeUp.prev.key},n.regionAbove=function(t){return t.nodeUp.next.key},n.debugEvent=function(t){},n.addWinding=function(t,e){t.winding+=e.winding,t.Sym.winding+=e.Sym.winding},n.edgeLeq=function(t,e,r){var i=t.event,o=e.eUp,s=r.eUp;if(o.Dst===i)return s.Dst===i?ae.vertLeq(o.Org,s.Org)?ae.edgeSign(s.Dst,o.Org,s.Org)<=0:ae.edgeSign(o.Dst,s.Org,o.Org)>=0:ae.edgeSign(s.Dst,i,s.Org)<=0;if(s.Dst===i)return ae.edgeSign(o.Dst,i,o.Org)>=0;var a=ae.edgeEval(o.Dst,i,o.Org),l=ae.edgeEval(s.Dst,i,s.Org);return a>=l},n.deleteRegion=function(t,e){e.fixUpperEdge&&ue(e.eUp.winding===0),e.eUp.activeRegion=null,t.dict.delete(e.nodeUp)},n.fixUpperEdge=function(t,e,r){ue(e.fixUpperEdge),t.mesh.delete(e.eUp),e.fixUpperEdge=!1,e.eUp=r,r.activeRegion=e},n.topLeftRegion=function(t,e){var r=e.eUp.Org,i;do e=n.regionAbove(e);while(e.eUp.Org===r);if(e.fixUpperEdge){if(i=t.mesh.connect(n.regionBelow(e).eUp.Sym,e.eUp.Lnext),i===null)return null;n.fixUpperEdge(t,e,i),e=n.regionAbove(e)}return e},n.topRightRegion=function(t){var e=t.eUp.Dst;do t=n.regionAbove(t);while(t.eUp.Dst===e);return t},n.addRegionBelow=function(t,e,r){var i=new fl;return i.eUp=r,i.nodeUp=t.dict.insertBefore(e.nodeUp,i),i.fixUpperEdge=!1,i.sentinel=!1,i.dirty=!1,r.activeRegion=i,i},n.isWindingInside=function(t,e){switch(t.windingRule){case He.ODD:return(e&1)!==0;case He.NONZERO:return e!==0;case He.POSITIVE:return e>0;case He.NEGATIVE:return e<0;case He.ABS_GEQ_TWO:return e>=2||e<=-2}throw new Error("Invalid winding rulle")},n.computeWinding=function(t,e){e.windingNumber=n.regionAbove(e).windingNumber+e.eUp.winding,e.inside=n.isWindingInside(t,e.windingNumber)},n.finishRegion=function(t,e){var r=e.eUp,i=r.Lface;i.inside=e.inside,i.anEdge=r,n.deleteRegion(t,e)},n.finishLeftRegions=function(t,e,r){for(var i,o=null,s=e,a=e.eUp;s!==r;){if(s.fixUpperEdge=!1,o=n.regionBelow(s),i=o.eUp,i.Org!=a.Org){if(!o.fixUpperEdge){n.finishRegion(t,s);break}i=t.mesh.connect(a.Lprev,i.Sym),n.fixUpperEdge(t,o,i)}a.Onext!==i&&(t.mesh.splice(i.Oprev,i),t.mesh.splice(a,i)),n.finishRegion(t,s),a=o.eUp,s=o}return a},n.addRightEdges=function(t,e,r,i,o,s){var a,l,c,p,h=!0;c=r;do ue(ae.vertLeq(c.Org,c.Dst)),n.addRegionBelow(t,e,c.Sym),c=c.Onext;while(c!==i);for(o===null&&(o=n.regionBelow(e).eUp.Rprev),l=e,p=o;a=n.regionBelow(l),c=a.eUp.Sym,c.Org===p.Org;)c.Onext!==p&&(t.mesh.splice(c.Oprev,c),t.mesh.splice(p.Oprev,c)),a.windingNumber=l.windingNumber-c.winding,a.inside=n.isWindingInside(t,a.windingNumber),l.dirty=!0,!h&&n.checkForRightSplice(t,l)&&(n.addWinding(c,p),n.deleteRegion(t,l),t.mesh.delete(p)),h=!1,l=a,p=c;l.dirty=!0,ue(l.windingNumber-c.winding===a.windingNumber),s&&n.walkDirtyRegions(t,l)},n.spliceMergeVertices=function(t,e,r){t.mesh.splice(e,r)},n.vertexWeights=function(t,e,r){var i=ae.vertL1dist(e,t),o=ae.vertL1dist(r,t),s=.5*o/(i+o),a=.5*i/(i+o);t.coords[0]+=s*e.coords[0]+a*r.coords[0],t.coords[1]+=s*e.coords[1]+a*r.coords[1],t.coords[2]+=s*e.coords[2]+a*r.coords[2]},n.getIntersectData=function(t,e,r,i,o,s){e.coords[0]=e.coords[1]=e.coords[2]=0,e.idx=-1,n.vertexWeights(e,r,i),n.vertexWeights(e,o,s)},n.checkForRightSplice=function(t,e){var r=n.regionBelow(e),i=e.eUp,o=r.eUp;if(ae.vertLeq(i.Org,o.Org)){if(ae.edgeSign(o.Dst,i.Org,o.Org)>0)return!1;ae.vertEq(i.Org,o.Org)?i.Org!==o.Org&&(t.pq.delete(i.Org.pqHandle),n.spliceMergeVertices(t,o.Oprev,i)):(t.mesh.splitEdge(o.Sym),t.mesh.splice(i,o.Oprev),e.dirty=r.dirty=!0)}else{if(ae.edgeSign(i.Dst,o.Org,i.Org)<0)return!1;n.regionAbove(e).dirty=e.dirty=!0,t.mesh.splitEdge(i.Sym),t.mesh.splice(o.Oprev,i)}return!0},n.checkForLeftSplice=function(t,e){var r=n.regionBelow(e),i=e.eUp,o=r.eUp,s;if(ue(!ae.vertEq(i.Dst,o.Dst)),ae.vertLeq(i.Dst,o.Dst)){if(ae.edgeSign(i.Dst,o.Dst,i.Org)<0)return!1;n.regionAbove(e).dirty=e.dirty=!0,s=t.mesh.splitEdge(i),t.mesh.splice(o.Sym,s),s.Lface.inside=e.inside}else{if(ae.edgeSign(o.Dst,i.Dst,o.Org)>0)return!1;e.dirty=r.dirty=!0,s=t.mesh.splitEdge(o),t.mesh.splice(i.Lnext,o.Sym),s.Rface.inside=e.inside}return!0},n.checkForIntersect=function(t,e){var r=n.regionBelow(e),i=e.eUp,o=r.eUp,s=i.Org,a=o.Org,l=i.Dst,c=o.Dst,p,h,d=new Zi,m,f;if(ue(!ae.vertEq(c,l)),ue(ae.edgeSign(l,t.event,s)<=0),ue(ae.edgeSign(c,t.event,a)>=0),ue(s!==t.event&&a!==t.event),ue(!e.fixUpperEdge&&!r.fixUpperEdge),s===a||(p=Math.min(s.t,l.t),h=Math.max(a.t,c.t),p>h))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 n.debugEvent(t),ae.intersect(l,s,c,a,d),ue(Math.min(s.t,l.t)<=d.t),ue(d.t<=Math.max(a.t,c.t)),ue(Math.min(c.s,l.s)<=d.s),ue(d.s<=Math.max(a.s,s.s)),ae.vertLeq(d,t.event)&&(d.s=t.event.s,d.t=t.event.t),m=ae.vertLeq(s,a)?s:a,ae.vertLeq(m,d)&&(d.s=m.s,d.t=m.t),ae.vertEq(d,s)||ae.vertEq(d,a)?(n.checkForRightSplice(t,e),!1):!ae.vertEq(l,t.event)&&ae.edgeSign(l,t.event,d)>=0||!ae.vertEq(c,t.event)&&ae.edgeSign(c,t.event,d)<=0?c===t.event?(t.mesh.splitEdge(i.Sym),t.mesh.splice(o.Sym,i),e=n.topLeftRegion(t,e),i=n.regionBelow(e).eUp,n.finishLeftRegions(t,n.regionBelow(e),r),n.addRightEdges(t,e,i.Oprev,i,i,!0),!0):l===t.event?(t.mesh.splitEdge(o.Sym),t.mesh.splice(i.Lnext,o.Oprev),r=e,e=n.topRightRegion(e),f=n.regionBelow(e).eUp.Rprev,r.eUp=o.Oprev,o=n.finishLeftRegions(t,r,null),n.addRightEdges(t,e,o.Onext,i.Rprev,f,!0),!0):(ae.edgeSign(l,t.event,d)>=0&&(n.regionAbove(e).dirty=e.dirty=!0,t.mesh.splitEdge(i.Sym),i.Org.s=t.event.s,i.Org.t=t.event.t),ae.edgeSign(c,t.event,d)<=0&&(e.dirty=r.dirty=!0,t.mesh.splitEdge(o.Sym),o.Org.s=t.event.s,o.Org.t=t.event.t),!1):(t.mesh.splitEdge(i.Sym),t.mesh.splitEdge(o.Sym),t.mesh.splice(o.Oprev,i),i.Org.s=d.s,i.Org.t=d.t,i.Org.pqHandle=t.pq.insert(i.Org),n.getIntersectData(t,i.Org,s,l,a,c),n.regionAbove(e).dirty=e.dirty=r.dirty=!0,!1)},n.walkDirtyRegions=function(t,e){for(var r=n.regionBelow(e),i,o;;){for(;r.dirty;)e=r,r=n.regionBelow(r);if(!e.dirty&&(r=e,e=n.regionAbove(e),e===null||!e.dirty))return;if(e.dirty=!1,i=e.eUp,o=r.eUp,i.Dst!==o.Dst&&n.checkForLeftSplice(t,e)&&(r.fixUpperEdge?(n.deleteRegion(t,r),t.mesh.delete(o),r=n.regionBelow(e),o=r.eUp):e.fixUpperEdge&&(n.deleteRegion(t,e),t.mesh.delete(i),e=n.regionAbove(r),i=e.eUp)),i.Org!==o.Org)if(i.Dst!==o.Dst&&!e.fixUpperEdge&&!r.fixUpperEdge&&(i.Dst===t.event||o.Dst===t.event)){if(n.checkForIntersect(t,e))return}else n.checkForRightSplice(t,e);i.Org===o.Org&&i.Dst===o.Dst&&(n.addWinding(o,i),n.deleteRegion(t,e),t.mesh.delete(i),e=n.regionAbove(r))}},n.connectRightVertex=function(t,e,r){var i,o=r.Onext,s=n.regionBelow(e),a=e.eUp,l=s.eUp,c=!1;if(a.Dst!==l.Dst&&n.checkForIntersect(t,e),ae.vertEq(a.Org,t.event)&&(t.mesh.splice(o.Oprev,a),e=n.topLeftRegion(t,e),o=n.regionBelow(e).eUp,n.finishLeftRegions(t,n.regionBelow(e),s),c=!0),ae.vertEq(l.Org,t.event)&&(t.mesh.splice(r,l.Oprev),r=n.finishLeftRegions(t,s,null),c=!0),c){n.addRightEdges(t,e,r.Onext,o,o,!0);return}ae.vertLeq(l.Org,a.Org)?i=l.Oprev:i=a,i=t.mesh.connect(r.Lprev,i),n.addRightEdges(t,e,i,i.Onext,i.Onext,!1),i.Sym.activeRegion.fixUpperEdge=!0,n.walkDirtyRegions(t,e)},n.connectLeftDegenerate=function(t,e,r){var i,o,s,a,l;if(i=e.eUp,ae.vertEq(i.Org,r)){ue(!1),n.spliceMergeVertices(t,i,r.anEdge);return}if(!ae.vertEq(i.Dst,r)){t.mesh.splitEdge(i.Sym),e.fixUpperEdge&&(t.mesh.delete(i.Onext),e.fixUpperEdge=!1),t.mesh.splice(r.anEdge,i),n.sweepEvent(t,r);return}ue(!1),e=n.topRightRegion(e),l=n.regionBelow(e),s=l.eUp.Sym,o=a=s.Onext,l.fixUpperEdge&&(ue(o!==s),n.deleteRegion(t,l),t.mesh.delete(s),s=o.Oprev),t.mesh.splice(r.anEdge,s),ae.edgeGoesLeft(o)||(o=null),n.addRightEdges(t,e,s.Onext,a,o,!0)},n.connectLeftVertex=function(t,e){var r,i,o,s,a,l,c=new fl;if(c.eUp=e.anEdge.Sym,r=t.dict.search(c).key,i=n.regionBelow(r),!!i){if(s=r.eUp,a=i.eUp,ae.edgeSign(s.Dst,e,s.Org)===0){n.connectLeftDegenerate(t,r,e);return}if(o=ae.vertLeq(a.Dst,s.Dst)?r:i,r.inside||o.fixUpperEdge){if(o===r)l=t.mesh.connect(e.anEdge.Sym,s.Lnext);else{var p=t.mesh.connect(a.Dnext,e.anEdge);l=p.Sym}o.fixUpperEdge?n.fixUpperEdge(t,o,l):n.computeWinding(t,n.addRegionBelow(t,r,l)),n.sweepEvent(t,e)}else n.addRightEdges(t,r,e.anEdge,e.anEdge,null,!0)}},n.sweepEvent=function(t,e){t.event=e,n.debugEvent(t);for(var r=e.anEdge;r.activeRegion===null;)if(r=r.Onext,r===e.anEdge){n.connectLeftVertex(t,e);return}var i=n.topLeftRegion(t,r.activeRegion);ue(i!==null);var o=n.regionBelow(i),s=o.eUp,a=n.finishLeftRegions(t,o,null);a.Onext===s?n.connectRightVertex(t,i,a):n.addRightEdges(t,i,a.Onext,s,s,!0)},n.addSentinel=function(t,e,r,i){var o=new fl,s=t.mesh.makeEdge();s.Org.s=r,s.Org.t=i,s.Dst.s=e,s.Dst.t=i,t.event=s.Dst,o.eUp=s,o.windingNumber=0,o.inside=!1,o.fixUpperEdge=!1,o.sentinel=!0,o.dirty=!1,o.nodeUp=t.dict.insert(o)},n.initEdgeDict=function(t){t.dict=new zb(t,n.edgeLeq);var e=t.bmax[0]-t.bmin[0],r=t.bmax[1]-t.bmin[1],i=t.bmin[0]-e,o=t.bmax[0]+e,s=t.bmin[1]-r,a=t.bmax[1]+r;n.addSentinel(t,i,o,s),n.addSentinel(t,i,o,a)},n.doneEdgeDict=function(t){for(var e,r=0;(e=t.dict.min().key)!==null;)e.sentinel||(ue(e.fixUpperEdge),ue(++r===1)),ue(e.windingNumber===0),n.deleteRegion(t,e)},n.removeDegenerateEdges=function(t){var e,r,i,o=t.mesh.eHead;for(e=o.next;e!==o;e=r)r=e.next,i=e.Lnext,ae.vertEq(e.Org,e.Dst)&&e.Lnext.Lnext!==e&&(n.spliceMergeVertices(t,i,e),t.mesh.delete(e),e=i,i=e.Lnext),i.Lnext===e&&(i!==e&&((i===r||i===r.Sym)&&(r=r.next),t.mesh.delete(i)),(e===r||e===r.Sym)&&(r=r.next),t.mesh.delete(e))},n.initPriorityQ=function(t){var e,r,i,o=0;for(i=t.mesh.vHead,r=i.next;r!==i;r=r.next)o++;for(o+=8,e=t.pq=new Gb(o,ae.vertLeq),i=t.mesh.vHead,r=i.next;r!==i;r=r.next)r.pqHandle=e.insert(r);return r!==i?!1:(e.init(),!0)},n.donePriorityQ=function(t){t.pq=null},n.removeDegenerateFaces=function(t,e){var r,i,o;for(r=e.fHead.next;r!==e.fHead;r=i)i=r.next,o=r.anEdge,ue(o.Lnext!==o),o.Lnext.Lnext===o&&(n.addWinding(o.Onext,o),t.mesh.delete(o));return!0},n.computeInterior=function(t,e){e===void 0&&(e=!0);var r,i;if(n.removeDegenerateEdges(t),!n.initPriorityQ(t))return!1;for(n.initEdgeDict(t);(r=t.pq.extractMin())!==null;){for(;i=t.pq.min(),!(i===null||!ae.vertEq(i,r));)i=t.pq.extractMin(),n.spliceMergeVertices(t,r.anEdge,i.anEdge);n.sweepEvent(t,r)}return t.event=t.dict.min().key.eUp.Org,n.debugEvent(t),n.doneEdgeDict(t),n.donePriorityQ(t),n.removeDegenerateFaces(t,t.mesh)?(e&&t.mesh.check(),!0):!1},n}(),Vb=function(){function n(){this.mesh=new md,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=He.ODD,this.dict=null,this.pq=null,this.event=null,this.vertexIndexCounter=0,this.vertices=[],this.vertexIndices=[],this.vertexCount=0,this.elements=[],this.elementCount=0}return n.prototype.dot_=function(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]},n.prototype.normalize_=function(t){var e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2];if(!e)throw"Zero-size vector!";e=Math.sqrt(e),t[0]/=e,t[1]/=e,t[2]/=e},n.prototype.longAxis_=function(t){var e=0;return Math.abs(t[1])>Math.abs(t[0])&&(e=1),Math.abs(t[2])>Math.abs(t[e])&&(e=2),e},n.prototype.computeNormal_=function(t){var e,r,i,o,s,a,l=[0,0,0],c=[0,0,0],p=[0,0,0],h=[0,0,0],d=[0,0,0],m=[null,null,null],f=[null,null,null],T=this.mesh.vHead;e=T.next;for(var w=0;w<3;++w)o=e.coords[w],c[w]=o,f[w]=e,l[w]=o,m[w]=e;for(e=T.next;e!==T;e=e.next)for(var y=0;y<3;++y)o=e.coords[y],o<c[y]&&(c[y]=o,f[y]=e),o>l[y]&&(l[y]=o,m[y]=e);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]){t[0]=0,t[1]=0,t[2]=1;return}for(a=0,r=f[L],i=m[L],p[0]=r.coords[0]-i.coords[0],p[1]=r.coords[1]-i.coords[1],p[2]=r.coords[2]-i.coords[2],e=T.next;e!==T;e=e.next)h[0]=e.coords[0]-i.coords[0],h[1]=e.coords[1]-i.coords[1],h[2]=e.coords[2]-i.coords[2],d[0]=p[1]*h[2]-p[2]*h[1],d[1]=p[2]*h[0]-p[0]*h[2],d[2]=p[0]*h[1]-p[1]*h[0],s=d[0]*d[0]+d[1]*d[1]+d[2]*d[2],s>a&&(a=s,t[0]=d[0],t[1]=d[1],t[2]=d[2]);a<=0&&(t[0]=t[1]=t[2]=0,t[this.longAxis_(p)]=1)},n.prototype.checkOrientation_=function(){for(var t=this.mesh.fHead,e,r=this.mesh.vHead,i,o=0,s=t.next;s!==t;s=s.next)if(i=s.anEdge,!(i.winding<=0))do o+=(i.Org.s-i.Dst.s)*(i.Org.t+i.Dst.t),i=i.Lnext;while(i!==s.anEdge);if(o<0){for(e=r.next;e!==r;e=e.next)e.t=-e.t;this.tUnit[0]=-this.tUnit[0],this.tUnit[1]=-this.tUnit[1],this.tUnit[2]=-this.tUnit[2]}},n.prototype.projectPolygon_=function(){var t=this.mesh.vHead,e=[0,0,0],r,i,o=!1;e[0]=this.normal[0],e[1]=this.normal[1],e[2]=this.normal[2],!e[0]&&!e[1]&&!e[2]&&(this.computeNormal_(e),o=!0),r=this.sUnit,i=this.tUnit;var s=this.longAxis_(e);r[s]=0,r[(s+1)%3]=1,r[(s+2)%3]=0,i[s]=0,i[(s+1)%3]=0,i[(s+2)%3]=e[s]>0?1:-1;for(var a=t.next;a!==t;a=a.next)a.s=this.dot_(a.coords,r),a.t=this.dot_(a.coords,i);o&&this.checkOrientation_();for(var l=!0,c=t.next;c!==t;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))},n.prototype.addWinding_=function(t,e){t.winding+=e.winding,t.Sym.winding+=e.Sym.winding},n.prototype.tessellateMonoRegion_=function(t,e){var r,i;if(r=e.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);i=r.Lprev;for(var o=void 0;r.Lnext!==i;)if(ae.vertLeq(r.Dst,i.Org)){for(;i.Lnext!==r&&(ae.edgeGoesLeft(i.Lnext)||ae.edgeSign(i.Org,i.Dst,i.Lnext.Dst)<=0);)o=t.connect(i.Lnext,i),i=o.Sym;i=i.Lprev}else{for(;i.Lnext!==r&&(ae.edgeGoesRight(r.Lprev)||ae.edgeSign(r.Dst,r.Org,r.Lprev.Org)>=0);)o=t.connect(r,r.Lprev),r=o.Sym;r=r.Lnext}if(i.Lnext===r)throw"Mono region invalid";for(;i.Lnext.Lnext!==r;)o=t.connect(i.Lnext,i),i=o.Sym;return!0},n.prototype.tessellateInterior_=function(t){for(var e,r=t.fHead.next;r!==t.fHead;r=e)if(e=r.next,r.inside&&!this.tessellateMonoRegion_(t,r))return!1;return!0},n.prototype.discardExterior_=function(t){for(var e,r=t.fHead.next;r!==t.fHead;r=e)e=r.next,r.inside||t.zapFace(r)},n.prototype.setWindingNumber_=function(t,e,r){for(var i,o=t.eHead.next;o!==t.eHead;o=i)i=o.next,o.Rface.inside!==o.Lface.inside?o.winding=o.Lface.inside?e:-e:r?t.delete(o):o.winding=0},n.prototype.getNeighbourFace_=function(t){return!t.Rface||!t.Rface.inside?-1:t.Rface.n},n.prototype.outputPolymesh_=function(t,e,r,i){var o,s=0,a=0,l;r>3&&t.mergeConvexFaces(r);for(var c=t.vHead.next;c!==t.vHead;c=c.next)c.n=-1;for(var p=t.fHead.next;p!==t.fHead;p=p.next)if(p.n=-1,!!p.inside){o=p.anEdge,l=0;do{var c=o.Org;c.n===-1&&(c.n=a,a++),l++,o=o.Lnext}while(o!==p.anEdge);if(l>r)throw"Face vertex greater that support polygon";p.n=s,++s}this.elementCount=s,e===rt.CONNECTED_POLYGONS&&(s*=2),this.elements=[],this.elements.length=s*r,this.vertexCount=a,this.vertices=[],this.vertices.length=a*i,this.vertexIndices=[],this.vertexIndices.length=a;for(var c=t.vHead.next;c!==t.vHead;c=c.next)if(c.n!==-1){var h=c.n*i;this.vertices[h+0]=c.coords[0],this.vertices[h+1]=c.coords[1],i>2&&(this.vertices[h+2]=c.coords[2]),this.vertexIndices[c.n]=c.idx}for(var d=0,p=t.fHead.next;p!==t.fHead;p=p.next)if(!!p.inside){o=p.anEdge,l=0;do{var c=o.Org;this.elements[d++]=c.n,l++,o=o.Lnext}while(o!==p.anEdge);for(var m=l;m<r;++m)this.elements[d++]=-1;if(e===rt.CONNECTED_POLYGONS){o=p.anEdge;do this.elements[d++]=this.getNeighbourFace_(o),o=o.Lnext;while(o!==p.anEdge);for(var f=l;f<r;++f)this.elements[d++]=-1}}},n.prototype.outputContours_=function(t,e){var r,i,o=0,s=0;this.vertexCount=0,this.elementCount=0;for(var a=t.fHead.next;a!==t.fHead;a=a.next)if(!!a.inside){i=r=a.anEdge;do this.vertexCount++,r=r.Lnext;while(r!==i);this.elementCount++}this.elements=[],this.elements.length=this.elementCount*2,this.vertices=[],this.vertices.length=this.vertexCount*e,this.vertexIndices=[],this.vertexIndices.length=this.vertexCount;var l=0,c=0,p=0;o=0;for(var a=t.fHead.next;a!==t.fHead;a=a.next)if(!!a.inside){s=0,i=r=a.anEdge;do this.vertices[l++]=r.Org.coords[0],this.vertices[l++]=r.Org.coords[1],e>2&&(this.vertices[l++]=r.Org.coords[2]),this.vertexIndices[c++]=this.vertexIdCallback?this.vertexIdCallback(r):r.Org.idx,s++,r=r.Lnext;while(r!==i);this.elements[p++]=o,this.elements[p++]=s,o+=s}},n.prototype.addContour=function(t,e){this.mesh===null&&(this.mesh=new md),t<2&&(t=2),t>3&&(t=3);for(var r=null,i=0;i<e.length;i+=t)r===null?(r=this.mesh.makeEdge(),this.mesh.splice(r,r.Sym)):(this.mesh.splitEdge(r),r=r.Lnext),r.Org.coords[0]=e[i+0],r.Org.coords[1]=e[i+1],t>2?r.Org.coords[2]=e[i+2]:r.Org.coords[2]=0,r.Org.idx=this.vertexIndexCounter++,this.edgeCreateCallback&&this.edgeCreateCallback(r),r.winding=1,r.Sym.winding=-1},n.prototype.tesselate=function(t,e,r,i,o,s){if(t===void 0&&(t=He.ODD),e===void 0&&(e=rt.POLYGONS),s===void 0&&(s=!0),this.vertices=[],this.elements=[],this.vertexIndices=[],this.vertexIndexCounter=0,o&&(this.normal[0]=o[0],this.normal[1]=o[1],this.normal[2]=o[2]),this.windingRule=t,i<2&&(i=2),i>3&&(i=3),!this.mesh)return!1;this.projectPolygon_(),Rb.computeInterior(this,s);var a=this.mesh;return e===rt.BOUNDARY_CONTOURS?this.setWindingNumber_(a,1,!0):this.tessellateInterior_(a),s&&a.check(),e===rt.BOUNDARY_CONTOURS?this.outputContours_(a,i):this.outputPolymesh_(a,e,r,i),!0},n}();function di(n){var t=n.windingRule,e=t===void 0?He.ODD:t,r=n.elementType,i=r===void 0?rt.POLYGONS:r,o=n.polySize,s=o===void 0?3:o,a=n.vertexSize,l=a===void 0?2:a,c=n.normal,p=c===void 0?[0,0,1]:c,h=n.contours,d=h===void 0?[]:h,m=n.strict,f=m===void 0?!0:m,T=n.debug,w=T===void 0?!1:T;if(!d&&f)throw new Error("Contours can't be empty");if(!!d){var y=new Vb;n.edgeCreateCallback&&(y.edgeCreateCallback=n.edgeCreateCallback),n.vertexIdCallback&&(y.vertexIdCallback=n.vertexIdCallback);for(var L=0;L<d.length;L++)y.addContour(l||2,d[L]);return y.tesselate(e,i,s,l,p,f),{vertices:y.vertices,vertexIndices:y.vertexIndices,vertexCount:y.vertexCount,elements:y.elements,elementCount:y.elementCount,mesh:w?y.mesh:void 0}}}var rD=He.ODD,iD=He.NONZERO,oD=He.POSITIVE,nD=He.NEGATIVE,sD=He.ABS_GEQ_TWO,aD=rt.POLYGONS,lD=rt.CONNECTED_POLYGONS,cD=rt.BOUNDARY_CONTOURS;var Qi=class extends Fb{constructor(e,r=12,i={}){var f,T,w;super();this.type="ShapeGeometry";this.windingRule=He.ODD;this.elementType=rt.POLYGONS;this.polySize=3;this.vertexSize=2;this.strict=!0;this._shape=e,this._curveSegments=r,this._triangulationOptions=Object.assign({windingRule:He.ODD,elementType:rt.POLYGONS,polySize:3,vertexSize:2,strict:!0},i);let o=this._shape.extractShapePointsToFlatArray([],this._curveSegments),s=this._shape.shapeHoles.map(y=>y.extractShapePointsToFlatArray([],this._curveSegments)),a,l=!0,c=!0,p,h;for(let y=0,L=o.length/2;y<L;y++){let A=y*2,I=o[A+0],b=o[A+1];if(p!==void 0&&I!==p&&(l=!1),h!==void 0&&b!==h&&(c=!1),p=I,h=b,!l&&!c)break}!l&&!c&&(a=di({contours:[o,...s],windingRule:this._triangulationOptions.windingRule,elementType:this._triangulationOptions.elementType,polySize:this._triangulationOptions.polySize,vertexSize:this._triangulationOptions.vertexSize,strict:this._triangulationOptions.strict}));let d=(f=a==null?void 0:a.vertexCount)!=null?f:1,m=(T=a==null?void 0:a.elementCount)!=null?T:1;if(this._positionAttribute=new Vs(new Float32Array(d*3),3),this._normalAttribute=new Vs(new Float32Array(d*3),3),this._uvAttribute=new Vs(new Float32Array(d*2),2),this._indexAttribute=new Vs(new Uint32Array(m*3),1),a){let y=1/0,L=-1/0,A=1/0,I=-1/0;for(let x=0,u=d;x<u;x++){let M=x*2,g=a.vertices[M+0],N=a.vertices[M+1];g<y&&(y=g),g>L&&(L=g),N<A&&(A=N),N>I&&(I=N)}let b=L-y,V=I-A;for(let x=0,u=d;x<u;x++){let M=x*2,g=a.vertices[M+0],N=a.vertices[M+1],v=(g-y)/b,C=(N-A)/V;this._positionAttribute.setXYZ(x,g,N,0),this._normalAttribute.setXYZ(x,0,0,1),this._uvAttribute.setXY(x,v,C)}for(let x=0,u=m;x<u;x++){let M=x*3,g=a.elements[M+0],N=a.elements[M+1],v=a.elements[M+2];this._indexAttribute.setX(M+0,g),this._indexAttribute.setX(M+1,N),this._indexAttribute.setX(M+2,v)}}this.setAttribute("position",this._positionAttribute),this.setAttribute("normal",this._normalAttribute),this.setAttribute("uv",this._uvAttribute),this.setIndex(this._indexAttribute),this.setDrawRange(0,((w=a==null?void 0:a.elementCount)!=null?w:1)*3)}clone(){let e=new Qi(this._shape,this._curveSegments);return e.userData=_o(this.userData),e}};import{BufferAttribute as js,BufferGeometry as jb}from"three";var Fs=class{constructor(t=256,e=!1){this.capacity=t,this.size=0,this.debug=e,this.debug&&console.log(`allocating with cap ${t}`);let r=t*Fs.eSize;this.buffer=new ArrayBuffer(r);let i=Float32Array.BYTES_PER_ELEMENT,o=0;this.positions=new Float32Array(this.buffer,o*i,3*t),o+=3*t,this.normals=new Float32Array(this.buffer,o*i,3*t),o+=3*t,this.uvs=new Float32Array(this.buffer,o*i,2*t)}realloc(t,e=!1){if(t<this.size)throw Error("cannot shrink buffer");if(t<=this.capacity&&!e)return;this.debug&&console.log(`resizing from ${this.capacity} \u2192 ${t}`);let r=t*Fs.eSize,i=new ArrayBuffer(r),o=Float32Array.BYTES_PER_ELEMENT,s=0,a=new Float32Array(i,s*o,3*t);s+=3*t;let l=new Float32Array(i,s*o,3*t);s+=3*t;let c=new Float32Array(i,s*o,2*t);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=i,this.positions=a,this.normals=l,this.uvs=c,this.capacity=t}get(t=1){let e=this.size+t;if(e>this.capacity){let i=this.capacity;for(;e>i;)i*=2;this.realloc(i)}let r=this.size;return this.size=e,r}reserve(t){let e=this.size+t;e>this.capacity&&this.realloc(e)}shrink(){this.debug&&console.log(`shrinking ${this.capacity} \u2192 ${this.size}`),this.realloc(this.size,!0)}},Ko=Fs;Ko.eSize=(3+3+2)*Float32Array.BYTES_PER_ELEMENT;var yl=(n,t)=>([e,r])=>(r<e&&(r+=t),(n>=e?n:n+t)<=r),eo=class extends jb{constructor(e,r,i=0,o=12,s=3){super();this.type="ShapeGeometry";this.vertexCache={};this._shape=e,this._depth=r,this._bevel=i,this._curveSegments=o,this._bevelSegmentsInput=s,i<=0?(this._bevelSize=0,this._bevelSegments=0):(this._bevelSize=Math.min(i,r/2-1e-12),this._bevelSegments=Math.floor(s));let a=this._shape.extractShapePointsToFlatArray([],o),l=this._shape.shapeHoles.map(x=>{let u=x.extractShapePointsToFlatArray([],o),M=[];for(let g=u.length-1;g>=1;g-=2){let N=u[g-1],v=u[g-0];M.push(N,v)}return M}),c=di({windingRule:He.ODD,elementType:rt.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[a]}),p=di({windingRule:He.ODD,elementType:rt.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...l]});if(!c)throw new Error("error generating geometry");let h=c.elementCount;if(p){c.elementCount+=p.elementCount;for(let x=0;x<p.elements.length;x++){let u=p.elements[x],M=x%2===0?c.vertexCount:0;c.elements.push(u+M)}for(let x=0;x<p.vertexIndices.length;x++){let u=p.vertexIndices[x],M=c.vertexCount;c.vertexIndices.push(u+M)}for(let x=0;x<p.vertices.length;x++){let u=p.vertices[x];c.vertices.push(u)}}let d=1/0,m=-1/0,f=1/0,T=-1/0;for(let x=0,u=c.vertexCount;x<u;x++){let M=x*2,g=c.vertices[M+0],N=c.vertices[M+1];g<d&&(d=g),g>m&&(m=g),N<f&&(f=N),N>T&&(T=N)}this._minX=d,this._minY=f,this._width=m-d,this._height=T-f;let w=c.vertexCount*2*(2+this._bevelSegments);this._buffer=new Ko(w);let y=[],L=[];for(let x=c.elementCount-1;x>=0;x--){let u=x>=h,M=x*2,g=c.elements[M+0],N=c.elements[M+1],v=g+N,C={start:g,count:N,normals:[],continuous:[],concave:[]},$=g,H=v-1,ie=g+1,pe=this._shape.roundedCurves.length;do{let G=$-g,_=c.vertices[H*2+0],z=c.vertices[H*2+1],D=c.vertices[$*2+0],R=c.vertices[$*2+1],K=c.vertices[ie*2+0],Z=c.vertices[ie*2+1],U=D-_,j=R-z,B=Math.sqrt(U*U+j*j);U/=B,j/=B;let k=D-K,ne=R-Z,q=Math.sqrt(k*k+ne*ne);k/=q,ne/=q,C.normals[G*2+0]=-ne,C.normals[G*2+1]=k,C.concave[G]=U*ne-j*k>0;let J=c.vertexIndices[$];if(Array.isArray(J))C.continuous[G]=!1;else{let[Y,X]=this._shape.getCurveIndexFromVertexId(J-1,!0);if(X>0&&X<1)C.continuous[G]=!0;else{let Q=X===1?Y+1:Y-1;Q=(Q+pe)%pe;let se=X===1?0:1,oe=this._shape.roundedCurves[Y].getTangent(X),he=this._shape.roundedCurves[Q].getTangent(se);C.continuous[G]=oe.dot(he)>.95}}u&&(C.normals[G*2+0]*=-1,C.normals[G*2+1]*=-1),[H,$,ie]=[$,ie,ie+1],ie>=v&&(ie-=N)}while(ie!==g+1);let ce=[];ce.push({bevelI:0,angle:0,size:0,boundary:{vertices:c.vertices.slice(g*2,v*2),vertexCount:N,vertexIndices:new Array(N).fill(!0).map((G,_)=>[_,_]),elements:[0,N],elementCount:1,mesh:null},reverseMap:[],insetPoints:c.vertices.slice(g*2,v*2)});for(let G=1;G<=this._bevelSegments;G++){let _=G/this._bevelSegments*Math.PI/2,z=(1-Math.cos(_))*this._bevelSize,D=[],R=[],K=[],Z=[],U=0;for(let B=0;B<N;B++){let k=B*2,ne=(B-1+N)%N*2,q=c.vertices[C.start*2+k+0],J=c.vertices[C.start*2+k+1],Y=-C.normals[ne+0]*z,X=-C.normals[ne+1]*z,Q=-C.normals[k+0]*z,se=-C.normals[k+1]*z;if(C.concave[B]||!C.concave[B]&&u){let oe=Math.atan2(X,Y),he=Math.atan2(se,Q);he>oe&&(he-=Math.PI*2);let Ee=he-oe;if(C.continuous[B]||u){let xe=oe+Ee/2,We=Math.cos(xe)*z,Ce=Math.sin(xe)*z;D[2*U+0]=q+We*(u?-1:1),D[2*U+1]=J+Ce*(u?-1:1),Z[U]=B,U++}else{let xe=Math.max(1,Math.floor(o/4*Math.abs(Ee)/Math.PI));for(let We=0;We<=xe;We++){let Ce=oe+Ee*(We/xe),ct=Math.cos(Ce)*z,wt=Math.sin(Ce)*z;D[2*U+0]=q+ct,D[2*U+1]=J+wt,Z[U]=B,U++}}}else D[2*U+0]=q+Y,D[2*U+1]=J+X,Z[U]=B,R[B]=U,U++,D[2*U+0]=q,D[2*U+1]=J,Z[U]=B,U++,D[2*U+0]=q+Q,D[2*U+1]=J+se,Z[U]=B,K[B]=U,U++}let j=di({windingRule:He.POSITIVE,elementType:rt.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[D],edgeCreateCallback:B=>{let ne=B.Org.idx,q=Z[ne],J=Z[(ne+1)%Z.length];B.idx=[q,J],B.Sym.idx=[J,q]},vertexIdCallback:B=>{let k=B.Lprev.idx;return[k?k[1]:0,B.idx[0]]}});if(!j)throw console.log("Error"),new Error(`error generating bevel geometry for ${G}'th loop`);if(!j.vertexCount)break;for(let B=0;B<j.vertexIndices.length;B++){let[k,ne]=j.vertexIndices[B];if(k===ne)continue;let q=ne;ne<k&&(q+=N);for(let J=k;J<q;J++){let Y=J%N,X=(J+1)%N;if(!C.continuous[Y]||!C.continuous[X]){j.vertexIndices[B]=[k,Y],j.vertexIndices.splice(B+1,0,[X,ne]),j.vertices.splice((B+1)*2,0,j.vertices[B*2],j.vertices[B*2+1]);break}}}ce.push({bevelI:G,angle:_,size:z,boundary:j,reverseMap:Z,insetPoints:D})}let be=(G,_,z)=>{let D=0,R=G.boundary.vertexIndices.length;for(;D<R&&z(G.boundary.vertexIndices[_]);)_=(_+1)%R,D++;return D},F=y.length;for(let G=1;G<ce.length;G++){let _=ce[G-1],z=ce[G],D=_.boundary.vertexIndices.length,R=z.boundary.vertexIndices.length;if(!D||!R)break;let K=C.concave.length,Z=0,U=yl(Z,N);for(;!_.boundary.vertexIndices.filter(U).length||!z.boundary.vertexIndices.filter(U).length;)Z++,U=yl(Z,N);let j=_.boundary.vertexIndices.findIndex(U),B=z.boundary.vertexIndices.findIndex(U);do j=(j+1)%D;while(U(_.boundary.vertexIndices[j]));do B=(B+1)%R;while(U(z.boundary.vertexIndices[B]));Z=(Z+1)%N;let k=Z,ne=this.buildBevelVert(C,_,(j-1+D)%D),q=this.buildBevelVert(C,z,(B-1+R)%R),J=ne,Y=q,X,Q,se=!1;do{U=yl(Z,N);let oe=be(_,j,U),he=be(z,B,U),Ee=se;if(se=!1,oe&&!he){for(let xe=0;xe<oe;xe++)X=this.buildBevelVert(C,_,(j+xe)%D,xe/(oe-1)),y.push(J.topN,X.topP,Y.topN),y.push(X.bottomP,J.bottomN,Y.bottomN),J=X;se=!0}else if(!oe&&he)for(let xe=0;xe<he;xe++)Q=this.buildBevelVert(C,z,(B+xe)%R,xe/(he-1)),y.push(Y.topN,J.topP,Q.topP),y.push(J.bottomP,Y.bottomN,Q.bottomP),Y=Q;else if(oe&&he)if(X=this.buildBevelVert(C,_,j,0),Q=this.buildBevelVert(C,z,B,0),Ee?(y.push(J.topN,Q.topP,Y.topN),y.push(J.topN,X.topP,Q.topP),y.push(Q.bottomP,J.bottomN,Y.bottomN),y.push(X.bottomP,J.bottomN,Q.bottomP)):(y.push(J.topN,X.topP,Y.topN),y.push(Y.topN,X.topP,Q.topP),y.push(X.bottomP,J.bottomN,Y.bottomN),y.push(X.bottomP,Y.bottomN,Q.bottomP)),J=X,Y=Q,oe===he)for(let xe=1;xe<oe;xe++)X=this.buildBevelVert(C,_,(j+xe)%D,xe/(oe-1)),Q=this.buildBevelVert(C,z,(B+xe)%R,xe/(he-1)),y.push(J.topN,X.topP,Y.topN),y.push(Y.topN,X.topP,Q.topP),y.push(X.bottomP,J.bottomN,Y.bottomN),y.push(X.bottomP,Y.bottomN,Q.bottomP),J=X,Y=Q;else if(oe>he){let xe=oe/he,We=0;for(let Ce=1;Ce<oe;Ce++)X=this.buildBevelVert(C,_,(j+Ce)%D,Ce/(oe-1)),y.push(J.topN,X.topP,Y.topN),y.push(X.bottomP,J.bottomN,Y.bottomN),J=X,Ce>(We+1)*xe&&(We++,Q=this.buildBevelVert(C,z,(B+We)%R,We/(he-1)),y.push(Y.topN,X.topP,Q.topP),y.push(X.bottomP,Y.bottomN,Q.bottomP),Y=Q)}else{let xe=he/oe,We=0;for(let Ce=1;Ce<he;Ce++)Q=this.buildBevelVert(C,z,(B+Ce)%R,Ce/(he-1)),y.push(Y.topN,X.topP,Q.topP),y.push(X.bottomP,Y.bottomN,Q.bottomP),Y=Q,Ce>(We+1)*xe&&(We++,X=this.buildBevelVert(C,_,(j+We)%D,We/(oe-1)),y.push(J.topN,X.topP,Y.topN),y.push(X.bottomP,J.bottomN,Y.bottomN),J=X)}j=(j+oe)%D,B=(B+he)%R,Z=(Z+1)%K}while(Z!==k)}{let G=ce[0];for(let _=0,z=G.boundary.vertexCount;_<z;_++){let D=this.buildBevelVert(C,G,_),R=this.buildBevelVert(C,G,(_+1)%z);y.push(R.topP,D.topN,D.bottomN),y.push(R.topP,D.bottomN,R.bottomP)}}if(u){let G=[];for(let _=y.length-1;_>=F+2;_-=3){let z=y[_-2],D=y[_-1],R=y[_-0];G.push(R,D,z)}y.splice(F,y.length-F,...G)}if(u){let G=[];for(let _=ce[ce.length-1].boundary.vertices.length-1;_>=1;_-=2){let z=ce[ce.length-1].boundary.vertices[_-1],D=ce[ce.length-1].boundary.vertices[_-0];G.push(z,D)}L.push(G)}if(!u){let G=ce[ce.length-1],_=di({windingRule:ce.length>1?He.POSITIVE:He.ODD,elementType:rt.POLYGONS,vertexSize:2,strict:!0,contours:[G.insetPoints,...L]});if(!_)throw new Error("Error generating geometry for surface");for(let z=0;z<_.elementCount*3;z+=3){let D=this.buildSurfaceVert(_,_.elements[z+0]),R=this.buildSurfaceVert(_,_.elements[z+1]),K=this.buildSurfaceVert(_,_.elements[z+2]);y.push(D.top,R.top,K.top),y.push(K.bottom,R.bottom,D.bottom)}}this.vertexCache={}}this._buffer.shrink();let A=new js(Uint32Array.from(y),1),I=new js(this._buffer.positions,3),b=new js(this._buffer.normals,3),V=new js(this._buffer.uvs,2);I.needsUpdate=!0,b.needsUpdate=!0,V.needsUpdate=!0,A.needsUpdate=!0,this.setAttribute("position",I),this.setAttribute("normal",b),this.setAttribute("uv",V),this.setIndex(A)}buildSurfaceVert(e,r){let i=r.toString();if(i in this.vertexCache)return this.vertexCache[i];let o=e.vertices[r*2+0],s=e.vertices[r*2+1],a=(o-this._minX)/this._width,l=(s-this._minY)/this._height,c=this._buffer.get(2),p=c*3,h=c*2,d={top:c+0,bottom:c+1};return this._buffer.positions[p+0]=o,this._buffer.positions[p+1]=s,this._buffer.positions[p+2]=this._depth,this._buffer.normals[p+0]=0,this._buffer.normals[p+1]=0,this._buffer.normals[p+2]=1,this._buffer.uvs[h+0]=a,this._buffer.uvs[h+1]=l,this._buffer.positions[p+3]=o,this._buffer.positions[p+4]=s,this._buffer.positions[p+5]=0,this._buffer.normals[p+3]=0,this._buffer.normals[p+4]=0,this._buffer.normals[p+5]=-1,this._buffer.uvs[h+2]=a,this._buffer.uvs[h+3]=l,this.vertexCache[i]=d,d}buildBevelVert(e,r,i,o=1){let s=`${r.bevelI}:${i}`;if(s in this.vertexCache)return this.vertexCache[s];let[a,l]=r.boundary.vertexIndices[i],c,p,h,d;a!==l?(p=a,c=l,d=!1,h=e.continuous[p]&&e.continuous[c]):(c=a,p=(c-1+e.count)%e.count,d=e.concave[c]&&r.bevelI>0,h=e.continuous[c]||d);let m=Math.cos(r.angle),f=Math.sin(r.angle),T=i*2,w=c*2,y=p*2,L=r.boundary.vertices[T+0],A=r.boundary.vertices[T+1],I=(1-f)*this._bevelSize,b=(L-this._minX)/this._width,V=(A-this._minY)/this._height,x=e.normals[w+0],u=e.normals[w+1],M=e.normals[y+0],g=e.normals[y+1];if(d){let H=M-x,ie=g-u;x=x+H*(1-o),u=u+ie*(1-o);let pe=Math.sqrt(x*x+u*u);x/=pe,u/=pe}let N=this._buffer.get(h?2:4),v=N*3,C=N*2,$={i,fi:c,topP:N+0,topN:N+0,bottomP:N+1,bottomN:N+1};return this._buffer.positions[v+0]=L,this._buffer.positions[v+1]=A,this._buffer.positions[v+2]=this._depth-I,this._buffer.normals[v+0]=x*m,this._buffer.normals[v+1]=u*m,this._buffer.normals[v+2]=f,this._buffer.uvs[C+0]=b,this._buffer.uvs[C+1]=V,this._buffer.positions[v+3]=L,this._buffer.positions[v+4]=A,this._buffer.positions[v+5]=I,this._buffer.normals[v+3]=x*m,this._buffer.normals[v+4]=u*m,this._buffer.normals[v+5]=-f,this._buffer.uvs[C+2]=V,this._buffer.uvs[C+3]=b,h||(N+=2,v+=6,C+=4,$.topP=N+0,$.bottomP=N+1,this._buffer.positions[v+0]=L,this._buffer.positions[v+1]=A,this._buffer.positions[v+2]=this._depth-I,this._buffer.normals[v+0]=M*m,this._buffer.normals[v+1]=g*m,this._buffer.normals[v+2]=f,this._buffer.uvs[C+0]=b,this._buffer.uvs[C+1]=V,this._buffer.positions[v+3]=L,this._buffer.positions[v+4]=A,this._buffer.positions[v+5]=I,this._buffer.normals[v+3]=M*m,this._buffer.normals[v+4]=g*m,this._buffer.normals[v+5]=-f,this._buffer.uvs[C+2]=V,this._buffer.uvs[C+3]=b),this.vertexCache[s]=$,$}clone(){let e=new eo(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=_o(this.userData),e}};var ht=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){var c,p,h,d,m,f,T;let e=Object.assign({},(c=t==null?void 0:t.parameters)!=null?c:{width:100,subdivisions:40,roundness:0,extrudeDepth:0,extrudeBevelSize:0,extrudeBevelSegments:3},n.parameters),r=Math.abs(e.width),i=Math.abs((p=e.height)!=null?p:e.width),o=Math.abs(e.depth!==void 0&&e.depth===0&&e.extrudeDepth>0?e.extrudeDepth:(h=e.depth)!=null?h:0),s=(d=n.shape)!=null?d:t==null?void 0:t.shape,a=(m=s==null?void 0:s.roundness)!=null?m:e.roundness;s!==void 0&&(s instanceof Me?(s.width!==r||s.height!==i)&&s.applySize(r,i):s=new Me(r,i).fromJSON(s),((f=n.parameters)==null?void 0:f.roundness)!==void 0&&((T=n.parameters)==null?void 0:T.roundness)>0&&s.update(!1));let l=s!=null?s:new Me(r,i);return{parameters:Object.assign(e,{width:r,height:i,depth:o,extrudeDepth:o,roundness:a}),shape:l}}static build(n){let{extrudeDepth:t,extrudeBevelSize:e,extrudeBevelSegments:r,subdivisions:i,roundness:o}=n.parameters;n.shape.roundness=o;let s;return t<=0?s=new Qi(n.shape,i):s=new eo(n.shape,t,e,i,r),Object.assign(s,{userData:W(P({},n),{type:"VectorGeometry"})})}};import{MathUtils as bd,Vector2 as vd}from"three";var Sd=Math.PI*2,wd=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){var i,o,s;let e=Object.assign({},(i=t==null?void 0:t.parameters)!=null?i:{width:100,depth:0,spikes:64,angle:360,innerRadius:0,extrudeDepth:0,extrudeBevelSize:0,extrudeBevelSegments:1},n.parameters);return{shape:n.shape&&n.shape instanceof Me?n.shape:new Me,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs((o=e.height)!=null?o:e.width),depth:Math.abs(e.depth!==void 0&&e.depth===0&&e.extrudeDepth>0?e.extrudeDepth:(s=e.depth)!=null?s:0)})}}static build(n){let{width:t,height:e,spikes:r,angle:i,innerRadius:o,depth:s,extrudeBevelSize:a,extrudeBevelSegments:l}=n.parameters,c=n.shape,p=t*.5,h=e*.5,d=Ub(c,p,h,i*Math.PI/180,r,o);c.isClosed=!0,c.update();let m=ht.create({shape:c,parameters:{subdivisions:d,depth:s,extrudeBevelSize:a,extrudeBevelSegments:l}});return Object.assign(m,{userData:W(P({},n),{type:"EllipseGeometry"})})}};function Ub(n,t,e,r,i,o){if(r>=Sd)return i>30||i%4===0?(Hb(n,t,e,o),Math.round(i/4)):xd(n,r,i,t,e,o);let s={x:0,y:e},a=r+Math.PI*.5,l={x:Math.cos(a)*t,y:Math.sin(a)*e},c=ud({px:s.x,py:s.y,cx:l.x,cy:l.y,rx:t,ry:e,largeArcFlag:r>Math.PI,sweepFlag:!0});return i>30||i%c.length===0?kb(n,s.x,s.y,c,i,t,e,o):xd(n,r,i,t,e,o)}function kb(n,t,e,r,i,o,s,a){let l=Math.round(i/r.length);n.addPoint(to(t,e));for(let c=0,p=r.length;c<p;c++){let h=r[c],d=n.points[c],m=to(h.x,h.y);d.controls[1].position.set(h.x1,h.y1),m.controls[0].position.set(h.x2,h.y2),n.addPoint(m)}return a>0?Ld(n,o,s,a):n.addPoint(to(0,0)),l}function xd(n,t,e,r,i,o){let s=-t/e;for(let a=0;a<=e;a++){let l=s*a,c=Math.sin(l)*r,p=Math.cos(l)*i;n.addPoint(to(c,p))}return t<Sd?o>0?Ld(n,r,i,o):n.addPoint(to(0,0)):(n.removePoint(n.points[n.points.length-1]),o>0&&Cd(n,r,i,o)),1}function Hb(n,t,e,r=0,i=0,o=0){let s=.5522847498,a=t*s,l=e*s;n.addPoint(Us(i-t,o,i-t,o-l,i-t,o+l)),n.addPoint(Us(i,o+e,i-a,o+e,i+a,o+e)),n.addPoint(Us(i+t,o,i+t,o+l,i+t,o-l)),n.addPoint(Us(i,o-e,i+a,o-e,i-a,o-e)),r>0&&Cd(n,t,e,r)}function to(n,t){return new Qt(bd.generateUUID(),new vd(n,t))}function Us(n,t,e,r,i,o){let s=to(n,t);return s.controls[0].position.set(e,r),s.controls[1].position.set(i,o),s}function Ld(n,t,e,r){Td(n,t,e,r).forEach(o=>n.addPoint(o))}function Cd(n,t,e,r){let i=Td(n,t,e,r),o=new Me;i.forEach(s=>o.addPoint(s)),o.isClosed=!0,n.shapeHoles.push(o)}function Td(n,t,e,r){let i=r*t/100,o=i*(Math.abs(e)/Math.abs(t)),s=new vd(i/t,o/e),a=n.points.map(l=>{let c=l.clone();return c.uuid=bd.generateUUID(),c}).reverse();return a.forEach(l=>{l.position.multiply(s);let c=l.controls[0].position.clone().multiply(s),p=l.controls[1].position.clone().multiply(s);l.controls[0].position.copy(p),l.controls[1].position.copy(c)}),a}import{BufferGeometry as qb,Float32BufferAttribute as gl,Vector3 as Nd}from"three";var Md=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){var a,l,c;let e=Object.assign({},(a=t==null?void 0:t.parameters)!=null?a:{width:100,revolutions:2,segments:40,pathRadius:10,pathType:0,pathSegments:30,cornerRadius:30,cornerSegments:4},n.parameters),r=Math.abs(e.width),i=Math.abs((l=e.height)!=null?l:r),o=Math.abs((c=e.depth)!=null?c:r),s=Math.abs(Math.min(r,o))/2;return{parameters:Object.assign(e,{width:r,height:i,depth:o,radius:s,segments:Math.round(e.segments),pathSegments:Math.round(e.pathSegments),cornerSegments:Math.round(e.cornerSegments)})}}static build(n){let{width:t,height:e,depth:r,radius:i,revolutions:o,segments:s,pathRadius:a,pathType:l,pathSegments:c,cornerRadius:p,cornerSegments:h}=n.parameters,d=new Yo(!1,t,e,r,i,o,s,a,l,c,p,h);return Object.assign(d,{userData:W(P({},n),{type:"HelixGeometry"})})}},Yo=class extends qb{constructor(t=!0,e=1,r=1,i=1,o=1,s=1,a=1,l=1,c=1,p=1,h=1,d=1){super();let m=t&&s===1;m&&(d=0),h>100&&(h=100);let f=()=>new Nd,T=new Nd,w=f(),y=f(),L=f(),A,I,b,V,x,u,M,g,N=f(),v=f(),C=f(),$=f(),H=f(),ie=f(),pe=f(),ce=f(),be=r-2*l+.001,F=be/s,G=Math.ceil(a*s),_=G+1,z=be/G,D=-be/2,R=p+1,K=2*Math.PI/p,Z=Math.PI/2/d,U=.01,j=Math.min((1-h/100)*l,l-U),B=l-j,k=0,ne=2,q=d*ne+ne,J=R*q/ne,Y=J+R*_,X=R*(_+q),[Q,se,oe]=[3,3,2].map(Ue=>Array(X*Ue).fill(0)),he=[],Ee=o-l;function xe(Ue,yt){let _t=Math.PI/2;u=yt*z,g=2*Math.PI*(u%F)/F+_t,u+=D,M=Math.sin(g)*Ee,x=Math.cos(g)*Ee,t?Ue.set(x,M,u):Ue.set(x,u,M)}xe(T,-1e-10),xe(w,0),N.copy(T),xe(T,1);let We=T.distanceTo(w),Ce=B+j,ct=We*G+2*Ce,wt=j,br=ct-Ce;for(let Ue=0;Ue<=G;Ue++){xe(y,Ue),ce.subVectors(y,N).normalize(),N.copy(y),ie.copy(y).setComponent(+t+1,0).normalize(),pe.crossVectors(ce,ie).normalize();let yt=Ue===0,_t=Ue===G,Tn=yt?3*Math.PI/2:Z,Nn=yt?wt:br,Mn=yt?R:Y,On=yt?0:X-R,In=ce.clone().multiplyScalar(yt?-B:B).add(y),Pn=ce.clone().multiplyScalar(yt?-1:1).normalize();for(let jt=0;jt<R;jt++){let Io=jt*K;if(v.addVectors(T.copy(ie).multiplyScalar(l*Math.cos(Io)),w.copy(pe).multiplyScalar(l*Math.sin(Io))),C.copy(v).normalize(),yt||_t){m||(k=On+jt,[0,1,2].forEach(pt=>{Q[k*3+pt]=In.getComponent(pt),se[k*3+pt]=Pn.getComponent(pt)}),oe[k*2]=+_t,oe[k*2+1]=jt/p),w.copy(C).multiplyScalar(j),L.addVectors(y,w);for(let pt=0;pt<d;pt++){let Si=pt*Z+Tn;$.addVectors(T.copy(ce).multiplyScalar(B*Math.sin(Si)),w.copy(C).multiplyScalar(B*Math.cos(Si))),H.copy($).normalize(),w.addVectors(L,$),$.normalize(),k=Mn+pt*R+jt,[0,1,2].forEach(ge=>{Q[k*3+ge]=w.getComponent(ge),se[k*3+ge]=H.getComponent(ge)});let An=+yt+Math.sin(Si);oe[k*2]=(Nn+B*An)/ct,oe[k*2+1]=jt/p}}w.addVectors(y,v),k=J+Ue*R+jt,[0,1,2].forEach(pt=>{Q[k*3+pt]=w.getComponent(pt),se[k*3+pt]=C.getComponent(pt)}),oe[k*2]=(Ce+Ue*We)/ct,oe[k*2+1]=jt/p}}let ft=_+2*d+ne,vr=1,[ii,oi]=m?[vr,vr+_-1]:[0,ft-1];for(let Ue=ii;Ue<=oi-1;Ue++){let yt=m&&Ue===oi-1;for(let _t=0;_t<R-1;_t++)A=Ue*R+_t,I=A+1,b=(yt?_t:A)+R,V=(yt?_t+1:I)+R,Ue===0?he.push(I,V,b):Ue===ft-2?he.push(A,I,b):he.push(A,I,b,I,V,b)}this.setIndex(he),this.setAttribute("position",new gl(Q,3)),this.setAttribute("normal",new gl(se,3)),this.setAttribute("uv",new gl(oe,2))}};import{IcosahedronBufferGeometry as Wb}from"three";var Od=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){var r,i,o;let e=Object.assign({},(r=t==null?void 0:t.parameters)!=null?r:{width:100,detail:0,corner:0,cornerSides:4},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs((i=e.height)!=null?i:e.width),depth:Math.abs((o=e.depth)!=null?o:e.width)})}}static build(n){let{width:t,height:e,depth:r,detail:i,corner:o,cornerSides:s}=n.parameters,a=i===0&&o!==0?new Xo(t*.5,o,s):new Wb(t*.5,i);return a.scale(1,e/t,r/t),Object.assign(a,{userData:W(P({},n),{type:"IcosahedronGeometry"})})}},Xo=class extends $r{constructor(t=1,e=.2,r=4){let i=(1+Math.sqrt(5))/2,o=[-1,i,0,1,i,0,-1,-i,0,1,-i,0,0,-1,i,0,1,i,0,-1,-i,0,1,-i,i,0,-1,i,0,1,-i,0,-1,-i,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(o,s,a,t,e,r),this.type=a}static fromJSON(t){return new Xo(t.radius,t.corner,t.cornerSides)}};import{LatheBufferGeometry as $b,Shape as Jb}from"three";var Id=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){var r,i,o,s,a;((i=(r=n.parameters)==null?void 0:r.points)!=null?i:[]).forEach(l=>{Array.isArray(l)&&(l.x=l[0],l.y=l[1])});let e=Object.assign({},(o=t==null?void 0:t.parameters)!=null?o:{width:100,segments:64,verticalSegments:64,points:[{x:0,y:-50,id:0},{x:50,y:-50,id:1},{x:50,y:50,id:2},{x:0,y:50,id:3}]},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs((s=e.height)!=null?s:e.width),depth:Math.abs((a=e.depth)!=null?a:e.width)})}}static build(n){let{points:t,segments:e,verticalSegments:r}=n.parameters,i=new Jb;i.moveTo(t[0].x,t[0].y),i.bezierCurveTo(t[1].x,t[1].y,t[2].x,t[2].y,t[3].x,t[3].y);let o=new $b(i.extractPoints(r).shape,e);return o.rotateZ(Math.PI),Object.assign(o,{userData:W(P({},n),{type:"LatheGeometry"})})}};import{BufferGeometry as Ad,BufferGeometryLoader as tv,Vector3 as rv,BoxBufferGeometry as Dd}from"three";import{BufferGeometry as Kb,Vector2 as xl,Vector3 as Pd}from"three";import{Geometry as Yb,Face3 as Xb}from"three/examples/jsm/deprecated/Geometry.js";var Zb=["a","b","c"];function Qb(n,t){switch(t){case"c":return n.c;case"b":return n.b;case"a":default:return n.a}}function bl(n,t,e){let r=Math.min(n,t),i=Math.max(n,t),o=r+"_"+i;return e.get(o)}function vl(n,t,e,r,i,o){let s=Math.min(n,t),a=Math.max(n,t),l=s+"_"+a,c;if(r.has(l))c=r.get(l);else{let p=e[s],h=e[a];c={a:p,b:h,newEdge:null,faces:[]},r.set(l,c)}c.faces.push(i),o[n].edges.push(c),o[t].edges.push(c)}function ev(n,t,e,r){let i,o,s;for(i=0,o=n.length;i<o;i++)e[i]={edges:[]};for(i=0,o=t.length;i<o;i++)s=t[i],vl(s.a,s.b,n,r,s,e),vl(s.b,s.c,n,r,s,e),vl(s.c,s.a,n,r,s,e)}function ks(n,t,e,r,i){n.push(new Xb(t,e,r,void 0,void 0,i))}function ro(n,t){return Math.abs(t-n)/2+Math.min(n,t)}function Hs(n,t,e,r){n.push([t.clone(),e.clone(),r.clone()])}var qs=class{constructor(t=1){this.subdivisions=t}modify(t){t instanceof Kb?t=new Yb().fromBufferGeometry(t):t=t.clone(),t.mergeVertices();let e=this.subdivisions;for(;e-- >0;)this._smooth(t);return t.computeFaceNormals(),t.computeVertexNormals(),t}_smooth(t){let e=new Pd,r,i,o,s,a,l=t.vertices,c=t.faces,p=t.faceVertexUvs[0],h=p!==void 0&&p.length>0,d=[],m=new Map;ev(l,c,d,m);let f=[],T,w,y,L,A,I,b;for(let U of Array.from(m.keys())){for(w=m.get(U),y=new Pd,A=3/8,I=1/8,b=w.faces.length,b!=2&&(A=.5,I=0,b!=1),y.addVectors(w.a,w.b).multiplyScalar(A),e.set(0,0,0),s=0;s<b;s++){for(L=w.faces[s],a=0;a<3&&(T=l[Qb(L,Zb[a])],!(T!==w.a&&T!==w.b));a++);T&&e.add(T)}e.multiplyScalar(I),y.add(e),w.newEdge=f.length,f.push(y)}let V,x,u,M,g,N,v,C=[];for(i=0,o=l.length;i<o;i++){for(N=l[i],g=d[i].edges,r=g.length,r==3?V=3/16:r>3&&(V=3/(8*r)),x=1-r*Number(V),u=V,r<=2&&(r==2?(x=3/4,u=1/8):r==1||r==0),v=N.clone().multiplyScalar(x),e.set(0,0,0),s=0;s<r;s++)M=g[s],T=M.a!==N?M.a:M.b,e.add(T);e.multiplyScalar(Number(u)),v.add(e),C.push(v)}let $=C.concat(f),H=C.length,ie,pe,ce,be=[],F=[],G,_,z,D,R=new xl,K=new xl,Z=new xl;for(i=0,o=c.length;i<o;i++)L=c[i],ie=Number(bl(L.a,L.b,m).newEdge)+H,pe=Number(bl(L.b,L.c,m).newEdge)+H,ce=Number(bl(L.c,L.a,m).newEdge)+H,ks(be,ie,pe,ce,L.materialIndex),ks(be,L.a,ie,ce,L.materialIndex),ks(be,L.b,pe,ie,L.materialIndex),ks(be,L.c,ce,pe,L.materialIndex),h&&(G=p[i],_=G[0],z=G[1],D=G[2],R.set(ro(_.x,z.x),ro(_.y,z.y)),K.set(ro(z.x,D.x),ro(z.y,D.y)),Z.set(ro(_.x,D.x),ro(_.y,D.y)),Hs(F,R,K,Z),Hs(F,_,R,Z),Hs(F,z,K,R),Hs(F,D,Z,K));t.vertices=$,t.faces=be,h&&(t.faceVertexUvs[0]=F)}};var it=new rv,_d=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){var o,s;let e=(s=(o=n.geometry)!=null?o:t==null?void 0:t.geometry)!=null?s:new Ad().copy(new Dd(100,100,100)),r;t===void 0?(e.computeBoundingBox(),e.boundingBox.getSize(it),r={width:it.x,height:it.y,depth:it.z,subdivisions:0}):r=t.parameters;let i=P(P({},r),n.parameters);return{parameters:{width:Math.abs(i.width),height:Math.abs(i.height),depth:Math.abs(i.depth),subdivisions:Math.abs(i.subdivisions)},geometry:e}}static build(n){var l;let{width:t,height:e,depth:r,subdivisions:i}=n.parameters,o=(l=n.geometry)!=null?l:new Ad().copy(new Dd(100,100,100)),s=o.userData.parameters;s===void 0?(o.computeBoundingBox(),o.boundingBox.getSize(it)):it.set(s.width,s.height,s.depth),(t!==it.x||e!==it.y||r!==it.z)&&o.scale(it.x===0?1:t/it.x,it.y===0?1:e/it.y,it.z===0?1:r/it.z);let a=o.originalGeometry;return i>0?(a===void 0||(s==null?void 0:s.subdivisions)!==i)&&(a===void 0&&(a=o),o=new qs(i).modify(a).toBufferGeometry()):(a!==void 0&&(o=a),a=void 0,o.getAttribute("normal")===void 0&&o.computeVertexNormals()),a!==void 0&&Object.assign(o,{originalGeometry:a}),delete n.geometry,Object.assign(o,{userData:W(P({},n),{type:"NonParametricGeometry"})})}static loadFromUrl(n,t,e){new tv(e).load(n,i=>{let o=this.normalizeInputs({geometry:i});i.boundingBox.getSize(it);let s=100/it.x;Object.assign(o.parameters,{width:100,height:it.y*s,depth:it.z*s}),t(this.build(o))})}};var Bd=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){var i,o,s;let e=Object.assign({},(i=t==null?void 0:t.parameters)!=null?i:{width:100,depth:0,spikes:5,cornerRadius:0,extrudeDepth:0,extrudeBevelSize:0,extrudeBevelSegments:3},n.parameters);return{shape:n.shape&&n.shape instanceof Me?n.shape:new Me,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs((o=e.height)!=null?o:e.width),depth:Math.abs(e.depth!==void 0&&e.depth===0&&e.extrudeDepth>0?e.extrudeDepth:(s=e.depth)!=null?s:0)})}}static build(n){let{width:t,height:e,spikes:r,cornerRadius:i,depth:o,extrudeBevelSize:s,extrudeBevelSegments:a}=n.parameters,l=n.shape,c=t*.5,p=e*.5,h=0,d=0,m=2*Math.PI/r;for(let T=0;T<r;T++){let w=m*T,y=h+Math.sin(w)*c,L=d+Math.cos(w)*p;l.addPoint(l.createPoint(y,L))}l.isClosed=!0;for(let T=0,w=l.points.length;T<w;T++)l.points[T].roundness=i;l.roundness=i,l.update();let f=ht.create({shape:l,parameters:{roundness:i,depth:o,extrudeBevelSize:s,extrudeBevelSegments:a}});return Object.assign(f,{userData:W(P({},n),{type:"PolygonGeometry"})})}};import{BufferGeometry as iv,Float32BufferAttribute as Sl,Vector2 as dr,Vector3 as st}from"three";var Ed=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){var r,i,o;let e=Object.assign({},(r=t==null?void 0:t.parameters)!=null?r:{width:100,radialSegments:4,heightSegments:1,cornerRadius:0,cornerSegments:8,openEnded:!1},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs((i=e.height)!=null?i:e.width),depth:Math.abs((o=e.depth)!=null?o:e.width)})}}static build(n){let{width:t,height:e,depth:r,radialSegments:i,heightSegments:o,openEnded:s,cornerRadius:a,cornerSegments:l}=n.parameters,c=new Ll(t*.5,e,i,o,s,a,l);return c.scale(1,1,r/t),Object.assign(c,{userData:W(P({},n),{type:"PyramidGeometry"})})}};function Zo(n,t,e){e.x=n.x*t.x,e.y=n.y,e.z=n.x*t.y}function wl(n,t,e,r,i,o){let s=t.clone().sub(n),a=e.clone().sub(n),l=s.angleTo(a);if(s.normalize(),a.normalize(),r===i){let c=s.add(a).normalize();o.copy(n).addScaledVector(c,r/Math.sin(l/2))}else{let c=s.angleTo(a);o.copy(n),o.addScaledVector(s,i/Math.sin(c)),o.addScaledVector(a,r/Math.sin(c))}}function ov(n,t,e){let r=n.clone().sub(t),i=e.clone().sub(t);return r.projectOnVector(i),r.add(t)}var Ll=class extends iv{constructor(t=.5,e=1,r=4,i=1,o=!1,s=0,a=4){super(),r=Math.floor(Math.max(3,r)),i=Math.floor(i),a=Math.floor(a);let l=[],c=[],p=[],h=[],d=0,m=e/2,f=Math.PI/r,T=t*Math.cos(Math.PI/r),w=2*Math.PI/r,y=(r-2)*Math.PI/r,L=Math.PI-y,A=new st(0,-m,0),I=new st(0,m,0),b=new dr(t,-m),V=new dr(T,-m),x=new dr(0,I.y).sub(V),u=new dr(0,I.y).sub(b),M=new dr(x.y,-x.x).normalize(),g=new dr(u.y,-u.x).normalize(),v=t*Math.cos(Math.PI/r)*Math.tan((Math.PI-x.angle())/2)-1e-8;s=Math.min(s,v);let C;{let F=new st(M.x,M.y,0),G=new st(Math.cos(w)*F.x,F.y,Math.sin(w)*F.x);C=F.angleTo(G)}let $=s/Math.tan((Math.PI-x.angle())/2),H=s/Math.tan((Math.PI-C)/2),ie=new st;if(!o){c.push(A.x,A.y,A.z),p.push(0,-1,0),h.push(0,0);let F=d++,G=[],_=b.clone(),z=$/Math.cos(Math.PI/r);_.x-=z;for(let D=0;D<r;D++){let R=D/r*Math.PI*2+f,K=new dr(Math.sin(R),Math.cos(R));Zo(_,K,ie),c.push(ie.x,ie.y,ie.z),p.push(0,-1,0),h.push(0,0),G.push(d++)}for(let D=0;D<G.length;D++)l.push(G[D],F,G[(D+1)%G.length])}let pe=[];{let F=new st,G=new st,_=new st,z=new st,D=new st,R=new st;for(let K=0;K<r;K++){let Z=K/r*Math.PI*2+f,U=(K+.5)/r*Math.PI*2+f,j=(K+1)/r*Math.PI*2+f,B=new dr(Math.sin(Z),Math.cos(Z)),k=new dr(Math.sin(U),Math.cos(U)),ne=new dr(Math.sin(j),Math.cos(j));Zo(b,B,G),Zo(b,ne,_),Zo(M,k,F),wl(I,G,_,H,H,z),c.push(z.x,z.y,z.z),wl(G,I,_,H,$,D),c.push(D.x,D.y,D.z),wl(_,G,I,$,H,R),c.push(R.x,R.y,R.z),p.push(F.x,F.y,F.z),p.push(F.x,F.y,F.z),p.push(F.x,F.y,F.z),h.push(0,0),h.push(0,0),h.push(0,0);let q=d++,J=d++,Y=d++;if(l.push(q,J,Y),s>0){{let se=G.clone().add(_).multiplyScalar(.5),oe=I.clone().sub(se).normalize(),Ee=A.clone().sub(se).normalize().add(oe).normalize().multiplyScalar(-1),xe=R.clone().sub(D);ce(se,xe,Ee,x.angle())}let X,Q;{let se=new st;Zo(g,ne,se);let oe=R.clone().add(z).multiplyScalar(.5);oe=ov(oe,_,I);let he=R.clone().sub(z);[X,Q]=ce(oe,he,se,C,z.y)}{let se=X,oe=se.clone().setY(0).normalize(),he=new st(0,-1,0),Ee=oe.clone().cross(he);be(se,oe,he,Ee)}pe.concat(Q);{let se=x.angle(),oe=Math.PI-se,he=I.clone();he.y-=s/Math.sin(se-Math.PI/2);let Ee=new st,xe=[];for(let Ce=0;Ce<a;Ce++){let ct=[],wt=Math.PI/2-oe*Ce/a,br=Math.cos(wt),ft=Math.sin(wt),vr=U;for(let ii=0;ii<=Ce;ii++){let oi=Math.cos(vr),Ue=Math.sin(vr);F.x=br*Ue,F.y=ft,F.z=br*oi,Ee.copy(he).addScaledVector(F,s),c.push(Ee.x,Ee.y,Ee.z),p.push(F.x,F.y,F.z),h.push(0,0),ct.push(d++),vr+=Math.PI*2/Ce/r}xe.push(ct)}Q.reverse(),xe.push(Q);let We=xe.length-1;for(let Ce=0;Ce<We;Ce++){let ct=xe[Ce],wt=xe[Ce+1],br=ct.length-1;l.push(wt[1],ct[0],wt[0]);for(let ft=1;ft<=br;ft++)l.push(ct[ft],ct[ft-1],wt[ft]),l.push(wt[ft+1],ct[ft],wt[ft])}}}}}this.setIndex(l),this.setAttribute("position",new Sl(c,3)),this.setAttribute("normal",new Sl(p,3)),this.setAttribute("uv",new Sl(h,2));function ce(F,G,_,z,D){let R=-z/2,K=(Math.PI-z)/2,Z=G.clone().normalize().cross(_);F.addScaledVector(_,-s/Math.sin(K));let U=new st,j=new st,B=1,k=d,ne=[];for(let q=0;q<=a;q++){let J=R+q/a*z;j.set(0,0,0),j.addScaledVector(Z,Math.sin(J)),j.addScaledVector(_,Math.cos(J));for(let Y=0;Y<=B;Y++){let X=Y/B-.5;if(U.copy(F),U.addScaledVector(G,X),U.addScaledVector(j,s),D!=null){let Q=Math.max(0,U.y-D);U.addScaledVector(G,-Q/G.y)}c.push(U.x,U.y,U.z),p.push(j.x,j.y,j.z),h.push(0,0),Y===0&&ne.push(d),d++}}for(let q=0;q<a;q++)for(let J=0;J<B;J++){let Y=k+J+(B+1)*q,X=Y+(B+1),Q=X+1,se=Y+1;l.push(Y,X,se),l.push(X,Q,se)}return[F.clone().addScaledVector(G,.5),ne]}function be(F,G,_,z){let D=Math.PI/2,R=u.angle()-D,K=[],Z=new st,U=new st;for(let B=0;B<=a;B++){let k=[],ne=B/a;for(let q=0;q<=B;q++){let Y=((B?q/B:0)-.5)*L,X=Math.cos(Y),Q=Math.sin(Y),se=Math.atan(Math.tan(R)*X),oe=(D+se)*ne,he=Math.cos(oe),Ee=Math.sin(oe);Z.set(0,0,0),Z.addScaledVector(G,Ee*X),Z.addScaledVector(_,he),Z.addScaledVector(z,Ee*Q),U.copy(F).addScaledVector(Z,s),c.push(U.x,U.y,U.z),p.push(Z.x,Z.y,Z.z),h.push(0,0),k.push(d++)}K.push(k)}let j=K.length-1;for(let B=0;B<j;B++){let k=K[B],ne=K[B+1],q=k.length-1;l.push(k[0],ne[1],ne[0]);for(let J=1;J<=q;J++)l.push(k[J-1],k[J],ne[J]),l.push(k[J],ne[J+1],ne[J])}}}};var Ws=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){var o,s,a,l;let e=Object.assign({},(o=t==null?void 0:t.parameters)!=null?o:{width:100,depth:0,cornerRadius:[0,0,0,0],cornerType:1,extrudeDepth:0,extrudeBevelSize:0,extrudeBevelSegments:1},n.parameters),r=Object.assign((s=t==null?void 0:t.ui)!=null?s:{enabledIndieCorners:!1},n.ui);return{shape:n.shape&&n.shape instanceof Me?n.shape:new Me,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs((a=e.height)!=null?a:e.width),depth:Math.abs(e.depth!==void 0&&e.depth===0&&e.extrudeDepth>0?e.extrudeDepth:(l=e.depth)!=null?l:0)}),ui:r}}static build(n){let t=n.shape,{width:e,height:r,cornerRadius:i,cornerType:o,depth:s,extrudeBevelSize:a,extrudeBevelSegments:l}=n.parameters,c={x:e*.5,y:r*.5},p={x:-c.x,y:-c.y},h={x:c.x,y:c.y};function d(I,b,V){return b>e&&V>r?Math.min(I*e/b,I*r/V):b>e?I*e/b:V>r?I*r/V:I}let m=[];m[0]=i[0]===0?0:d(i[0],i[0]+i[3],i[0]+i[1]),m[1]=i[1]===0?0:d(i[1],i[1]+i[2],i[1]+i[0]),m[2]=i[2]===0?0:d(i[2],i[2]+i[1],i[2]+i[3]),m[3]=i[3]===0?0:d(i[3],i[3]+i[0],i[3]+i[2]);let f=p.x,T=h.x,w=h.y,y=p.y;t.addPoint(t.createPoint(f,w)),t.addPoint(t.createPoint(T,w)),t.addPoint(t.createPoint(T,y)),t.addPoint(t.createPoint(f,y)),t.isClosed=!0;let L=!0;for(let I=0,b=t.points.length;I<b;I++)t.points[I].roundness=m[I],I>0&&m[I]!==m[I-1]&&(L=!1);L&&(t.roundness=m[0]),t.useCubicForRoundedCorners=o!==1,t.update();let A=ht.create({shape:t,parameters:{depth:s,extrudeBevelSize:a,extrudeBevelSegments:l}});return Object.assign(A,{userData:W(P({},n),{type:"RectangleGeometry"})})}};import{SphereBufferGeometry as nv}from"three";var Gd=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){var r,i,o;let e=Object.assign({},(r=t==null?void 0:t.parameters)!=null?r:{width:100,widthSegments:64,heightSegments:64,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:Math.PI},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs((i=e.height)!=null?i:e.width),depth:Math.abs((o=e.depth)!=null?o:e.width)})}}static build(n){let{width:t=100,height:e=t,depth:r=t,widthSegments:i=64,heightSegments:o=64,phiStart:s,phiLength:a,thetaStart:l,thetaLength:c}=n.parameters,p=new nv(.5*t,i,o,s,a,l,c);return p.scale(1,e/t,r/t),Object.assign(p,{userData:W(P({},n),{type:"SphereGeometry"})})}};import{PlaneBufferGeometry as sv}from"three";var zd=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){var r,i;let e=Object.assign({},(r=t==null?void 0:t.parameters)!=null?r:{width:100,depth:0,widthSegments:8,heightSegments:8},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs((i=e.height)!=null?i:e.width),depth:0})}}static build(n){let{width:t=100,height:e=t,widthSegments:r=8,heightSegments:i=8}=n.parameters,o=new sv(t,e,r,i);return o.scale(1,1,1),Object.assign(o,{userData:W(P({},n),{type:"PlaneGeometry"})})}};var Rd=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){var i,o,s;let e=Object.assign({},(i=t==null?void 0:t.parameters)!=null?i:{width:100,depth:0,innerRadiusPercent:38.19,spikes:5,cornerRadius:0,angle:360,extrudeDepth:0,extrudeBevelSize:0,extrudeBevelSegments:1},n.parameters);return{shape:n.shape&&n.shape instanceof Me?n.shape:new Me,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs((o=e.height)!=null?o:e.width),depth:Math.abs(e.depth!==void 0&&e.depth===0&&e.extrudeDepth>0?e.extrudeDepth:(s=e.depth)!=null?s:0)})}}static build(n){let{width:t,height:e,innerRadiusPercent:r,spikes:i,cornerRadius:o,angle:s,depth:a,extrudeBevelSize:l,extrudeBevelSegments:c}=n.parameters,p=n.shape,h=t*.5,d=e*.5,m=0,f=0,T=s*Math.PI/360/i,w=Math.PI/2*3*-1,y=h*r/100,L=d*r/100;if(i===3&&r===50){T=2*Math.PI/i;for(let I=0;I<i;I++){let b=T*I,V=m+Math.sin(b)*h,x=f+Math.cos(b)*d;p.addPoint(p.createPoint(V,x))}}else for(let I=0;I<i;I++){let b=m+Math.cos(w)*h,V=f+Math.sin(w)*d;p.addPoint(p.createPoint(b,V)),w+=T,b=m+Math.cos(w)*y,V=f+Math.sin(w)*L,I<=i,p.addPoint(p.createPoint(b,V)),w+=T}p.isClosed=!0;for(let I=0,b=p.points.length;I<b;I++)p.points[I].roundness=o;p.roundness=o,p.update();let A=ht.create({shape:p,parameters:{roundness:o,depth:a,extrudeBevelSize:l,extrudeBevelSegments:c}});return Object.assign(A,{userData:W(P({},n),{type:"StarGeometry"})})}};import{PlaneBufferGeometry as av}from"three";var $s=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){var r,i,o;let e=Object.assign({},(r=t==null?void 0:t.parameters)!=null?r:{width:100,depth:0},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs((i=e.height)!=null?i:e.width),depth:Math.abs((o=e.depth)!=null?o:0)})}}static build(n){let{width:t,height:e}=n.parameters,r=new av(t,e);return Object.assign(r,{userData:W(P({},n),{type:"TextFrameGeometry"})})}};var Vd=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){var s,a,l;let e=Object.assign({},(s=t==null?void 0:t.parameters)!=null?s:{width:100,radialSegments:32,tubularSegments:64,arc:Math.PI*2,cornerRadius:30,cornerSegments:8},n.parameters),r=Math.abs(e.width),i=Math.abs((a=e.height)!=null?a:e.width),o=Math.abs((l=e.depth)!=null?l:e.width*.25);return{parameters:Object.assign(e,{width:r,height:i,depth:o})}}static build(n){let{width:t,height:e,depth:r,radialSegments:i,tubularSegments:o,arc:s,cornerRadius:a,cornerSegments:l}=n.parameters,c=lv(t,e,r,t*.5,s,o,0,0,i,a,l);return c.scale(1,e/t,1),Object.assign(c,{userData:W(P({},n),{type:"TorusGeometry"})})}};function lv(n,t,e,r,i,o,s,a,l,c,p){return[t,e]=[e,t],s=t/2,i/=2*Math.PI,i==1&&(c=0),new Yo(!0,n,t,e,r,i,o,s,a,l,c,p)}import{TorusKnotBufferGeometry as cv}from"three";var Fd=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){var r,i,o,s;let e=Object.assign({},(r=t==null?void 0:t.parameters)!=null?r:{width:100,tubularSegments:64,radialSegments:32,p:2,q:3},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs((i=e.height)!=null?i:e.width),depth:Math.abs((o=e.depth)!=null?o:e.width),tube:(s=e.tube)!=null?s:e.width*.125})}}static build(n){let{width:t,tube:e,tubularSegments:r,radialSegments:i,p:o,q:s}=n.parameters,a=t*.5;a!==e&&(a-=e);let l=new cv(a,e,r,i,o,s);return Object.assign(l,{userData:W(P({},n),{type:"TorusKnotGeometry"})})}};var jd=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){var i,o,s;let e=Object.assign({},(i=t==null?void 0:t.parameters)!=null?i:{width:100,depth:0,spikes:5,cornerRadius:0,extrudeDepth:0,extrudeBevelSize:0,extrudeBevelSegments:1,isRect:!1},n.parameters);return{shape:n.shape&&n.shape instanceof Me?n.shape:new Me,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs((o=e.height)!=null?o:e.width*(e.isRect?1:Math.sqrt(3)/2)),depth:Math.abs(e.depth!==void 0&&e.depth===0&&e.extrudeDepth>0?e.extrudeDepth:(s=e.depth)!=null?s:0)})}}static build(n){let{width:t=100,height:e,cornerRadius:r,depth:i,extrudeBevelSize:o,extrudeBevelSegments:s,isRect:a}=n.parameters,l=n.shape,c=t*.5,p=e*.5;a?(l.addPoint(l.createPoint(-c,p)),l.addPoint(l.createPoint(c,-p)),l.addPoint(l.createPoint(-c,-p))):(l.addPoint(l.createPoint(0,p)),l.addPoint(l.createPoint(c,-p)),l.addPoint(l.createPoint(-c,-p))),l.isClosed=!0;for(let d=0,m=l.points.length;d<m;d++)l.points[d].roundness=r;l.roundness=r,l.update();let h=ht.create({shape:l,parameters:{roundness:r,depth:i,extrudeBevelSize:o,extrudeBevelSegments:s}});return Object.assign(h,{userData:W(P({},n),{type:"TriangleGeometry"})})}};var Qo={};fm(Qo,{addBarycentricAttribute:()=>mv,fixUvs:()=>yv,loadFromUrl:()=>fv,resizeGeometry:()=>uv,roundShapePolygon:()=>dv});import{BufferGeometryLoader as pv,Float32BufferAttribute as hv,Vector3 as Cl}from"three";var Ud=function(n,t){let e=t.x-n.x,r=t.y-n.y,i=Math.sqrt(e*e+r*r),o=e/i,s=r/i,a=Math.atan2(s,o);return{x:e,y:r,len:i,nx:o,ny:s,ang:a}},dv=(n,t,e)=>{let r,i,o,s,a,l,c,p,h,d,m,f,T,w,y=t.length;for(s=t[y-2],n.curves=[],r=1;r<y-1;r++){a=t[r%y],l=t[(r+1)%y];let L=Ud(a,s),A=Ud(a,l);c=L.nx*A.ny-L.ny*A.nx,p=L.nx*A.nx-L.ny*-A.ny,m=Math.asin(c),h=1,d=!1,p<0?m<0?m=Math.PI+m:(m=Math.PI-m,h=-1,d=!0):m>0&&(h=-1,d=!0),f=m/2,w=Math.abs(Math.cos(f)*e/Math.sin(f)),w>Math.min(L.len/2,A.len/2)?(w=Math.min(L.len/2,A.len/2),T=Math.abs(w*Math.sin(f)/Math.cos(f))):T=e,i=a.x+A.nx*w,o=a.y+A.ny*w,i+=-A.ny*T*h,o+=A.nx*T*h,n.absarc(i,o,T,L.ang+Math.PI/2*h,A.ang-Math.PI/2*h,d),s=a,a=l}n.closePath()},uv=(n,{width:t,height:e,depth:r})=>{t=Math.abs(t),e=Math.abs(e),r=Math.abs(r);let i=n.userData.parameters,o,s,a;t===0?(t=i.width,o=1):o=t/i.width,e===0?(e=i.height,s=1):s=e/i.height,r===0?(r=i.depth,a=1):a=r/i.depth,n.scale(o,s,a),i.width=t,i.height=e,i.depth=r},mv=(n,t)=>{let e=[new Cl(1,0,0),new Cl(0,1,0),new Cl(0,0,1)],r=n.attributes.position,i=new Float32Array(r.count*3);for(let o=0,s=r.count;o<s;o++)e[o%3].toArray(i,o*3);n.setAttribute(t,new hv(i,3))},fv=n=>new Promise(t=>{new pv().load(n,r=>t(r))}),yv=(n,t,e)=>{let r=n.getAttribute("uv");if(r)for(let i=0;i<r.count;i++){let o=r.getX(i),s=r.getY(i);r.setXY(i,(o+t/2)/t,1-(s-e/2)/e*-1)}};import{BufferGeometry as kd,BufferAttribute as Hd,Uint32BufferAttribute as Tl,Float32BufferAttribute as Nl,Matrix4 as xv}from"three";import{mergeVertices as bv}from"three/examples/jsm/utils/BufferGeometryUtils.js";var gv,Js=new Promise(n=>{gv=n});var me;Js.then(n=>{me=n});var qd=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),Wd=new Uint32Array([0,1,2,3]),$d=new Uint8Array([4]),zt=class{static build(n,t,e,r,i){let o,s,a;if(n===void 0)o=zt.allocate(i,e),me.set_destination_refinement_level(o,0),s=zt.buildLevel(o,!0,r);else if(n.positionWASM!==void 0){t&&t!==0&&(me.free_bvh(t),me.free_subdivision_surface(t));try{o=zt.allocate(i,void 0,n)}catch(l){console.error(l,n),o=zt.allocate(i,void 0,{positionWASM:qd,indexWASM:Wd,verticesPerFaceWASM:$d})}me.set_destination_refinement_level(o,0),s=zt.buildLevel(o,!0,r)}else o=t;if(n!==void 0&&n.subdivisions!==void 0){let l=vv(n.subdivisions,n.positionWASM.length);me.set_destination_refinement_level(o,l),l>0?a=zt.buildLevel(o,!1,r):a=null}return{subdivPointer:o,originalGeometry:s,subdividedGeometry:a}}static allocate(n,t,e){var b;let r,i,o,s=[],a=[];if(e)e.positionWASM&&e.positionWASM.length>0?(r=e.positionWASM,i=e.indexWASM,o=e.verticesPerFaceWASM):(r=qd,i=Wd,o=$d);else{t.deleteAttribute("normal"),t.deleteAttribute("uv");let V=bv(t);r=V.attributes.position.array;let x=V.getIndex().array,u=x.length;switch(t.userData.type==="TorusGeometry"&&(t==null?void 0:t.userData.parameters.arc)===Math.PI*2&&(t.userData.type="ClosedTorusGeometry"),t.userData.type){case"ClosedTorusGeometry":case"PlaneGeometry":case"TorusKnotGeometry":case"CubeGeometry":i=new Uint32Array(u/3*2),o=new Uint8Array(u/6).fill(4);for(let H=0,ie=0;H<u;H+=6)i[ie++]=x[H],i[ie++]=x[H+1],i[ie++]=x[H+4],i[ie++]=x[H+5];break;case"TorusGeometry":case"SphereGeometry":case"HelixGeometry":case"CylinderGeometry":case"ConeGeometry":let M,g,N;if(t.userData.type==="SphereGeometry")g=t.parameters.heightSegments,M=t.parameters.widthSegments,t.parameters.thetaLength!==Math.PI&&(N=!0);else if(t.userData.type==="CylinderGeometry")g=t.parameters.heightSegments+2,M=t.parameters.radialSegments;else if(t.userData.type==="ConeGeometry")g=t.parameters.heightSegments+1,M=t.parameters.radialSegments;else if(t.userData.type==="TorusGeometry"){let H=t.userData.parameters;g=Math.ceil(H.tubularSegments*H.arc/(2*Math.PI))+2,M=H.radialSegments}else{let{pathSegments:H,segments:ie,revolutions:pe}=t.userData.parameters;g=Math.ceil(ie*pe)+2,M=H}N?(i=new Uint32Array(1*M*3+(g-1)*M*4),o=new Uint8Array(1*M+(g-1)*M)):(i=new Uint32Array(2*M*3+(g-2)*M*4),o=new Uint8Array(2*M+(g-2)*M));let v=0,C=0,$=0;if(t.userData.type==="SphereGeometry"||t.userData.type==="HelixGeometry"||t.userData.type==="TorusGeometry"){for(;C<3*M;)i[C++]=x[v++],i[C++]=x[v++],i[C++]=x[v++],o[$++]=3;let H=N?i.length:3*M+4*(g-2)*M;for(;C<H;v+=6)i[C++]=x[v],i[C++]=x[v+1],i[C++]=x[v+4],i[C++]=x[v+5],o[$++]=4}else for(;C<4*(g-2)*M;v+=6)i[C++]=x[v],i[C++]=x[v+1],i[C++]=x[v+4],i[C++]=x[v+5],o[$++]=4;for(;C<i.length;)i[C++]=x[v++],i[C++]=x[v++],i[C++]=x[v++],o[$++]=3;break;default:i=x,o=new Uint8Array(u/3).fill(3);break}}let l=r.length,c=i.length,p=o.length,h=r.length+s.length+a.length,d=i.length+o.length,m=h*Float32Array.BYTES_PER_ELEMENT+d*Uint32Array.BYTES_PER_ELEMENT,f=h*Float32Array.BYTES_PER_ELEMENT,T=d*Uint32Array.BYTES_PER_ELEMENT,w=me._malloc(m),y=new Float32Array(me.HEAPF32.buffer,w,h),L=new Uint32Array(me.HEAPU32.buffer,w+f,d);y.set(r,0),y.set(s,r.length),y.set(a,r.length+s.length),L.set(i,0),L.set(o,i.length);let A;(b=e==null?void 0:e.scaleBaked)!=null&&b.some(V=>V!==1)&&(A=new xv().makeScale(...e.scaleBaked)),n&&(A?A.premultiply(n):A=n);let I=A?me.alloc_subdivision_surface2(w,l,w+f,c,w+f+i.length*Uint32Array.BYTES_PER_ELEMENT,p,A.elements):me.alloc_subdivision_surface(w,l,w+f,c,w+f+i.length*Uint32Array.BYTES_PER_ELEMENT,p);return me._free(w),I}static buildLevel(n,t,e,r,i){let o=i?me.get_mesh_data2(n,t?me.Level.CONTROL:me.Level.REFINED,e!=null?e:!t,i.elements):me.get_mesh_data(n,t?me.Level.CONTROL:me.Level.REFINED,e!=null?e:!t),s=8,a=me.HEAPU32.subarray(o>>2,(o>>2)+s),l=a.subarray(4,4+4),c=0,p=me.HEAPU32[a[c]>>2],h=me.HEAPF32.subarray(p>>2,(p>>2)+l[c]);c++;let d=me.HEAPU32[a[c]>>2],m=me.HEAPF32.subarray(d>>2,(d>>2)+l[c]);c++;let f=me.HEAPU32[a[c]>>2],T=me.HEAPU32.subarray(f>>2,(f>>2)+l[c]);c++;let w=me.HEAPU32[a[c]>>2],y=me.HEAPU32.subarray(w>>2,(w>>2)+l[c]);if(c++,r===void 0){let L=new kd;if(L.setIndex(new Tl(y,1)),L.setAttribute("position",new Nl(h,3)),L.setAttribute("normal",new Nl(m,3)),t){L.setAttribute("faceMap",new Tl(T,1));let A=new Float32Array(m.length/3*4).fill(0);L.setAttribute("color",new Hd(A,4))}return me.free_mesh_data(o),L.userData.type="SubdivGeometry",L}r.getAttribute("position").copyArray(h),r.getAttribute("normal").copyArray(m),r.attributes.position.needsUpdate=!0,r.attributes.normal.needsUpdate=!0,me.free_mesh_data(o)}static buildControlCageWireframe(n,t,e){let r=me.get_wireframe_data_for_base_level(n),i=4,o=me.HEAPU32.subarray(r>>2,(r>>2)+i),s=o.subarray(2,2+2),a=0,l=me.HEAPU32[o[a]>>2],c=me.HEAPF32.subarray(l>>2,(l>>2)+s[a]);a++;let p=me.HEAPU32[o[a]>>2],h=me.HEAPU32.subarray(p>>2,(p>>2)+s[a]);if(t===void 0){let d=new kd;d.setAttribute("position",new Nl(c,3));let m=new Float32Array(c.length);for(let f=0,T=c.length;f<T;)m[f++]=e.r,m[f++]=e.g,m[f++]=e.b;return d.setAttribute("color",new Hd(m,3)),d.setIndex(new Tl(h,1)),me.free_wireframe_data_for_base_level(r),d}t.getAttribute("position").copyArray(c),t.attributes.position.needsUpdate=!0,me.free_wireframe_data_for_base_level(r)}static updateCollabMesh(n,t,e){t||me.set_destination_refinement_level(n,1);let r=e?me.get_topological_data2(n,t?me.Level.CONTROL:me.Level.REFINED,e.elements):me.get_topological_data(n,t?me.Level.CONTROL:me.Level.REFINED),i=6,o=me.HEAPU32.subarray(r>>2,(r>>2)+i),s=o.subarray(3,3+3),a=0,l=me.HEAPU32[o[a]>>2],c=new Float32Array(me.HEAPF32.subarray(l>>2,(l>>2)+s[a]));a++;let p=me.HEAPU32[o[a]>>2],h=new Uint32Array(me.HEAPU32.subarray(p>>2,(p>>2)+s[a]));a++;let d=me.HEAPU32[o[a]>>2],m=new Uint8Array(me.HEAPU32.subarray(d>>2,(d>>2)+s[a]));return me.free_topological_data(r),{positions:c,indices:h,verticesPerFace:m}}};function vv(n,t){let e=n;return e=Math.min(e,3-Math.ceil(Math.log(t/172e3)/Math.log(4))),Math.max(e,0)}var Ml={ConeGeometry:Yh,CubeGeometry:Xh,CylinderGeometry:Kh,DodecahedronGeometry:Zh,EllipseGeometry:wd,HelixGeometry:Md,IcosahedronGeometry:Od,LatheGeometry:Id,NonParametricGeometry:_d,PolygonGeometry:Bd,PyramidGeometry:Ed,RectangleGeometry:Ws,SphereGeometry:Gd,PlaneGeometry:zd,StarGeometry:Rd,TextFrameGeometry:$s,TorusGeometry:Vd,TorusKnotGeometry:Fd,TriangleGeometry:jd,VectorGeometry:ht},en=n=>Ml[n.type].create(n);import{HemisphereLight as Jd}from"three";import{Color as Sv}from"three";var Pt=class extends Sv{constructor(e,r,i,o){super(e,r,i);this.isColorA=!0;this.a=o}setRGBA(e,r,i,o){super.setRGB(e,r,i),this.a=o}copy(e){return super.copy(e),this.a="a"in e?e.a:1,this}clone(){return new this.constructor(this.r,this.g,this.b,this.a)}get x(){return this.r}get y(){return this.g}get z(){return this.b}get w(){return this.a}set x(e){this.r=e}set y(e){this.g=e}set z(e){this.b=e}set w(e){this.a=e}};function Ye(n,t){let e;if(typeof n=="string"){let r=t==null?void 0:t.getColor(n);r?e=r:(console.warn("Tried to create color layer params with a color key that does not exist in the assets manager"),e=new Pt(0,0,0,0))}else return"a"in n?new Pt(n.r,n.g,n.b,n.a):new Pt(n.r,n.g,n.b,1);return e}var Ks=n=>"isEntity"in n,io=n=>"isAbstractMesh"in n,Kd=n=>n.objectType==="CombinedCamera";var Or=n=>"objectHelper"in n;function wv(n,t){var r;let e=!1;t.position&&(n.position.fromArray(t.position),e=!0),t.rotation&&(n.rotation.fromArray(t.rotation),e=!0),t.scale&&(e=!0,n.scale.fromArray(t.scale)),t.hiddenMatrix!==void 0&&"hiddenMatrix"in n&&(e=!0,n.hiddenMatrix.fromArray((r=t.hiddenMatrix)!=null?r:Ur.identity)),e&&n.updateMatrix(),t.position&&t.rotation&&t.scale&&t.hiddenMatrix!==void 0&&n.updateWorldMatrix(!1,!0),n.objectType==="CombinedCamera"&&(t.isUpVectorFlipped!==void 0&&(n.isUpVectorFlipped=t.isUpVectorFlipped),n.updateUp())}function Lv(n,t){wv(n,t),t.name!==void 0&&(n.name=t.name),t.visible!==void 0&&(n.isEntity?n.visibility=t.visible:n.visible=t.visible)}function Yd(n,t,e){Lv(n,t),t.color!==void 0&&(n.color=Ye(t.color,e)),t.intensity!==void 0&&(n.intensity=t.intensity),t.shadows!==void 0&&!(n instanceof Jd)&&(n.castShadow=t.shadows),n.shadow&&!(n instanceof Jd)&&t.depth!==void 0&&(n.shadow.camera.far=t.depth,n.shadow.needsUpdate=!0),t.helper!==void 0&&Or(n)&&(n.enableHelper=t.helper,n.gizmos.shadowmap.visible=t.helper)}function Xd(n,t){n.shadow.camera.right=t/2,n.shadow.camera.left=-t/2,n.shadow.camera.top=t/2,n.shadow.camera.bottom=-t/2,n.shadow.needsUpdate=!0}import{VideoTexture as SS}from"three";import{Mesh as Pv}from"three";import{Matrix4 as Il}from"three";import{Box3 as Qd,Line3 as $t,Matrix4 as Ol,Vector3 as Ve}from"three";var oo=new Qd,dt=new Ve,le=new Ve,et=new Ol;function Cv(n,t,e=0,r=t.count){let i=1/0,o=1/0,s=1/0,a=-1/0,l=-1/0,c=-1/0;for(let p=e;p<r;p++){let h=t.getX(p),d=t.getY(p),m=t.getZ(p);h<i&&(i=h),d<o&&(o=d),m<s&&(s=m),h>a&&(a=h),d>l&&(l=d),m>c&&(c=m)}return n.min.set(i,o,s),n.max.set(a,l,c),n}var Zd=(n,t,e,r)=>{var i;if(io(n)){let o=n.geometry.userData.parameters,s=n.geometry.getAttribute("position");n.geometry.userData.type==="SubdivGeometry"?dt.copy(n.originalGeometry.boundingSphere.center):(Cv(oo,s,n.geometry.drawRange.start,n.geometry.drawRange.count<1/0?n.geometry.drawRange.count:s.count),oo.getCenter(dt)),n.forceComputeSize?oo.getSize(le).multiplyScalar(.5):le.set(o.width,o.height,(i=o.depth)!=null?i:0).multiplyScalar(.5)}else if(Or(n)&&r===!0){let o=n.geometryHelper.getAttribute("position");oo.setFromArray(o.array),oo.getCenter(dt),oo.getSize(le).multiplyScalar(.5)}else dt.setScalar(0),le.setScalar(0);et.copy(t).multiply(n.matrixWorld),le.x===0&&le.y===0&&le.z===0?e.push(new Ve(dt.x,dt.y,dt.z).applyMatrix4(et)):e.push(new Ve(-le.x,le.y,le.z).add(dt).applyMatrix4(et),new Ve(-le.x,-le.y,le.z).add(dt).applyMatrix4(et),new Ve(le.x,-le.y,le.z).add(dt).applyMatrix4(et),new Ve(le.x,le.y,le.z).add(dt).applyMatrix4(et),new Ve(-le.x,le.y,-le.z).add(dt).applyMatrix4(et),new Ve(-le.x,-le.y,-le.z).add(dt).applyMatrix4(et),new Ve(le.x,-le.y,-le.z).add(dt).applyMatrix4(et),new Ve(le.x,le.y,-le.z).add(dt).applyMatrix4(et))},tn=class extends Qd{constructor(){super(...arguments);this.matrix=new Ol;this.vertices=[];this.faces=[];this.edges=[];this.centerEdges=[]}copy(e){return super.copy(e),this.matrix.copy(e.matrix),this.vertices=e.vertices.map(r=>r.clone()),this.faces=e.faces.map(r=>r.clone()),this.edges=e.edges.map(r=>r.clone()),this.centerEdges=e.centerEdges.map(r=>r.clone()),this}setFromObjectSize(e,r=!1){e.updateWorldMatrix(!1,r),this.makeEmpty(),this.matrix.copy(e.matrixWorld);let i=new Ol().copy(e.matrixWorld).invert();return this.expandByObjectSize(e,i,r)}expandByObjectSize(e,r,i=!1){let o=[];return i===!0?e.traverseEntity(s=>{s.visible&&Zd(s,r,o,e.enableHelper===!0)}):Zd(e,r,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(et.copy(this.matrix).setPosition(0,0,0)),e}computeVertices(){this.getSize(le).multiplyScalar(.5),this.getCenter(dt),et.copy(this.matrix).setPosition(dt),this.vertices=[new Ve(-le.x,le.y,le.z).applyMatrix4(et),new Ve(-le.x,-le.y,le.z).applyMatrix4(et),new Ve(le.x,-le.y,le.z).applyMatrix4(et),new Ve(le.x,le.y,le.z).applyMatrix4(et),new Ve(-le.x,le.y,-le.z).applyMatrix4(et),new Ve(-le.x,-le.y,-le.z).applyMatrix4(et),new Ve(le.x,-le.y,-le.z).applyMatrix4(et),new Ve(le.x,le.y,-le.z).applyMatrix4(et)]}computeEdges(){this.vertices.length>0&&this.computeVertices(),this.edges=[new $t(this.vertices[0],this.vertices[3]),new $t(this.vertices[1],this.vertices[2]),new $t(this.vertices[5],this.vertices[6]),new $t(this.vertices[4],this.vertices[7]),new $t(this.vertices[0],this.vertices[1]),new $t(this.vertices[3],this.vertices[2]),new $t(this.vertices[7],this.vertices[6]),new $t(this.vertices[4],this.vertices[5]),new $t(this.vertices[0],this.vertices[4]),new $t(this.vertices[1],this.vertices[5]),new $t(this.vertices[2],this.vertices[6]),new $t(this.vertices[3],this.vertices[7])],this.centerEdges=this.edges.map(e=>e.getCenter(new Ve))}computeFaces(){this.vertices.length>0&&this.computeVertices(),this.faces=[new Ve().copy(this.vertices[0]).sub(this.vertices[2]).multiplyScalar(.5).add(this.vertices[2]),new Ve().copy(this.vertices[7]).sub(this.vertices[5]).multiplyScalar(.5).add(this.vertices[5]),new Ve().copy(this.vertices[4]).sub(this.vertices[1]).multiplyScalar(.5).add(this.vertices[1]),new Ve().copy(this.vertices[3]).sub(this.vertices[6]).multiplyScalar(.5).add(this.vertices[6]),new Ve().copy(this.vertices[4]).sub(this.vertices[3]).multiplyScalar(.5).add(this.vertices[3]),new Ve().copy(this.vertices[1]).sub(this.vertices[6]).multiplyScalar(.5).add(this.vertices[6])]}};import{Object3D as Tv,Matrix4 as Nv,Light as Mv}from"three";function rn(n){let t=[];for(let e in n){let r=n[e];delete r.metadata,t.push(r)}return t}function Ov(n){let t=[];for(let e in n)t.push(n[e]);return t}var Ys=n=>class extends n{hasEntityChild(){return this.children.some(e=>Ks(e))}isDescendantOf(e){e instanceof Tv&&(e=e.uuid);let r=this;for(;r.parent;){if(r.parent.uuid===e)return!0;r=r.parent}return!1}attach(e,r){this.updateWorldMatrix(!0,!1);let i=new Nv().copy(this.matrixWorld).invert();return e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),i.multiply(e.parent.matrixWorld)),Ks(e)?e.hiddenMatrix.premultiply(i):e.applyMatrix4(i),e.updateWorldMatrix(!1,!1),this.add(e),r!==void 0&&(this.children.pop(),this.children.splice(r,0,e)),this}copy(e,r=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.userData=JSON.parse(JSON.stringify(e.userData)),r===!0)for(let i=0;i<e.children.length;i++){let o=e.children[i];this.add(o.clone())}return this}toJSON(e){let r=e===void 0,i={object:{uuid:"",objectType:""}};e===void 0&&(e={geometries:{},materials:{},textures:{},images:{},interactionStates:{},nodes:{}},i.metadata={version:1.5,type:"Object",generator:"Object3D.toJSON"});let o={uuid:this.uuid,objectType:this.type};if(this.name!==""&&(o.name=this.name),o.matrix=this.matrix.toArray(),this.castShadow===!0&&(o.castShadow=!0),this.receiveShadow===!0&&(o.receiveShadow=!0),this.visible===!1&&(o.visible=!1),this.frustumCulled===!1&&(o.frustumCulled=!1),this.renderOrder!==0&&(o.renderOrder=this.renderOrder),o.layers=this.layers.mask,JSON.stringify(this.userData)!=="{}"&&(o.userData=this.userData),this.children.length>0){o.children=[];for(let s of this.children)(Ks(s)||s instanceof Mv)&&o.children.push(s.toJSON(e).object)}if(r){let s=rn(e.geometries),a=rn(e.materials),l=rn(e.textures),c=rn(e.images),p=rn(e.interactionStates),h=Ov(e.nodes);s.length>0&&(i.geometries=s),a.length>0&&(i.materials=a),l.length>0&&(i.textures=l),c.length>0&&(i.images=c),p.length>0&&(i.interactionStates=p),h.length>0&&(i.nodes=h)}return i.object=o,i}fromJSON(e){return this.uuid=e.uuid,e.name!==void 0&&(this.name=e.name),e.matrix!==void 0?(this.matrix.fromArray(e.matrix),e.matrixAutoUpdate!==void 0&&(this.matrixAutoUpdate=e.matrixAutoUpdate),this.matrixAutoUpdate&&this.matrix.decompose(this.position,this.quaternion,this.scale)):(e.position!==void 0&&this.position.fromArray(e.position),e.rotation!==void 0&&this.rotation.fromArray(e.rotation),e.quaternion!==void 0&&this.quaternion.fromArray(e.quaternion),e.scale!==void 0&&this.scale.fromArray(e.scale)),this.castShadow=e.castShadow!==void 0,this.receiveShadow=e.receiveShadow!==void 0,e.visible!==void 0&&(this.visible=e.visible),e.frustumCulled!==void 0&&(this.frustumCulled=e.frustumCulled),e.renderOrder!==void 0&&(this.renderOrder=e.renderOrder),e.layers!==void 0&&(this.layers.mask=e.layers),e.userData!==void 0&&(this.userData=e.userData),this}};var Jt=n=>"isEntity"in n;var Kt=n=>class extends Ys(n){constructor(){super(...arguments);this.objectType="";this.isEntity=!0;this.raycastLock=!1;this.scaleLock=!1;this.hiddenMatrix=new Il;this._singleBBox=new tn;this._recursiveBBox=new tn;this.singleBBoxNeedsUpdate=!0;this.recursiveBBoxNeedsUpdate=!0;this.forceComputeSize=!1}set visibility(r){this.visible=r;for(let i of this.children)Jt(i)&&i.traverseEntity(o=>{Or(o)&&o.visible&&(o.objectHelper.visible=r)})}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(r=>{Jt(r)&&(r.singleBBoxNeedsUpdate=!0,r.recursiveBBoxNeedsUpdate=!0)}),this.traverseEntity(r=>{r.singleBBoxNeedsUpdate=!0,r.recursiveBBoxNeedsUpdate=!0})}traverseEntity(r){r(this);for(let i of this.children)Jt(i)&&i.traverseEntity(r)}updateMatrixWorld(r){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||r)&&(this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,r=!0);for(let i of this.children)i.updateMatrixWorld(r)}updateWorldMatrix(r,i){let o=this.parent;if(r&&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)),i)for(let s of this.children)s.updateWorldMatrix(!1,!0)}shallowClone(r){return new this.constructor().shallowCopy(this,r)}shallowCopy(r,i=!0){if(super.copy(r,!1),this.raycastLock=r.raycastLock,this.scaleLock=r.scaleLock,this.hiddenMatrix.copy(r.hiddenMatrix),i===!0)for(let o of r.children)Jt(o)&&this.add(o.shallowClone());return this}clone(r){return new this.constructor().copy(this,r)}copy(r,i=!0){if(super.copy(r,!1),this.raycastLock=r.raycastLock,this.scaleLock=r.scaleLock,this.hiddenMatrix.copy(r.hiddenMatrix),i===!0)for(let o of r.children)Jt(o)&&this.add(o.clone());return this}keepChildrenMatrixWorld(){let r=new Il,i=this.matrixWorld.clone();this.updateWorldMatrix(!1,!1),r.copy(this.matrixWorld).invert(),r.multiply(i);for(let o of this.children)Jt(o)&&o.hiddenMatrix.premultiply(r)}toJSON(r){let i=super.toJSON(r),o=i.object;return this.raycastLock===!0&&(o.raycastLock=!0),this.scaleLock===!0&&(o.scaleLock=!0),o.hiddenMatrix=this.hiddenMatrix.toArray(),i}fromJSON(r){return super.fromJSON(r),r.raycastLock!==void 0&&(this.raycastLock=r.raycastLock),r.scaleLock!==void 0&&(this.scaleLock=r.scaleLock),this.hiddenMatrix.fromArray(r.hiddenMatrix),this}fromObject3D(r){let i=r.children;return r.children=[],Object.assign(r,{raycastLock:!1,scaleLock:!1,hiddenMatrix:new Il}),this.copy(r),r.children=i,this}toObjectTransformState(r=[]){this.updateWorldMatrix(!0,!1);let i={position:this.position.toArray(),rotation:[this.rotation.x,this.rotation.y,this.rotation.z],scale:this.scale.toArray(),hiddenMatrix:this.hiddenMatrix.toArray()};return Fi(i,r)}fromObjectTransformState(r){return r.position&&this.position.fromArray(r.position),r.rotation&&this.rotation.fromArray(r.rotation),r.scale&&this.scale.fromArray(r.scale),r.hiddenMatrix&&this.hiddenMatrix.fromArray(r.hiddenMatrix),this.updateMatrix(),this}toState(r=[]){let i=P({name:this.name,visible:this.visible,raycastLock:this.raycastLock},this.toObjectTransformState(r));return Fi(i,r)}fromState(r,i){return r.name&&(this.name=r.name),r.raycastLock!==void 0&&(this.raycastLock=r.raycastLock),r.type!=="OrthographicCamera"&&r.type!=="PerspectiveCamera"&&(this.matrixAutoUpdate=!1),r.visible!==void 0&&(this.visibility=r.visible),this.fromObjectTransformState(r),this}};import{Object3D as Iv,Vector3 as on,Euler as eu,MathUtils as Kr}from"three";var ui=class extends Iv{constructor(e,r={}){super();this.object=e;let i=e.recursiveBBox.getSize(new on),o=.1;this.parameters=cs.defaultData(i.toArray(),o),ai(this.parameters,r),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 r of this.object.material)r.visible=!0;if(e){let r=this.object.material.map(i=>i.clone());for(let i of this.children)i.material=r}else for(let r of this.children)r.material=this.object.material}for(let r of this.object.material)r.visible=!e}else{if(this.children.length>0)if(this.object.material.visible=!0,e){let r=this.object.material.clone();for(let i of this.children)i.material=r}else for(let r of this.children)r.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 r=0,i=e-this.children.length;r<i;++r){let o=this.object.shallowClone(!1);o.visible=!0,this.add(o),this.parameters.hideBase&&this.setHideBase(!0)}else for(let r=0,i=this.children.length-e;r<i;++r)this.remove(this.children[0])}_updateRadial(e){let r=e.radial,i=r.start*Kr.DEG2RAD,o=r.end*Kr.DEG2RAD,s=i-o,a=new eu(r.rotation[0]*Kr.DEG2RAD,r.rotation[1]*Kr.DEG2RAD,r.rotation[2]*Kr.DEG2RAD),l;switch(r.axis){case"z":l=new on(0,0,1);break;case"y":l=new on(0,1,0);break;default:case"x":l=new on(1,0,0);break}for(let[c,p]of this.children.entries()){p.hiddenMatrix.identity(),p.scale.x=r.scale[0],p.scale.y=r.scale[1],p.scale.z=r.scale[2],p.position.setScalar(0);let h=s/e.count*c-i;switch(r.axis){case"x":p.rotation.set(0,h,0);break;case"y":p.rotation.set(0,0,h);break;case"z":p.rotation.set(h,0,0);break}p.translateOnAxis(l,r.radius),p.position.x+=r.position[0],p.position.y+=r.position[1],p.position.z+=r.position[2],r.alignment===!0?(p.rotation.x+=a.x,p.rotation.y+=a.y,p.rotation.z+=a.z):p.rotation.copy(a)}}_updateLinear(e){if(e.type!=="linear")throw new Error;let r=e.linear,i=new eu(r.rotation[0]*Kr.DEG2RAD,r.rotation[1]*Kr.DEG2RAD,r.rotation[2]*Kr.DEG2RAD);for(let[o,s]of this.children.entries())s.hiddenMatrix.identity(),s.scale.x=1+(r.scale[0]-1)*o,s.scale.y=1+(r.scale[1]-1)*o,s.scale.z=1+(r.scale[2]-1)*o,s.rotation.x=i.x*o,s.rotation.y=i.y*o,s.rotation.z=i.z*o,s.position.x=r.position[0]*o,s.position.y=r.position[1]*o,s.position.z=r.position[2]*o}_updateGrid(e){let r=0,i=e.grid;if(i.useCenter===!0){let o={x:i.count[0]%2===0?2:1,y:i.count[1]%2===0?2:1,z:i.count[2]%2===0?2:1},s=new on(i.size[0]*(i.count[0]-o.x)*.5,i.size[1]*(i.count[1]-o.y)*.5,i.size[2]*(i.count[2]-o.z)*.5);for(let a=0;a<i.count[0];a++)for(let l=0;l<i.count[1];l++)for(let c=0;c<i.count[2];c++){let p=this.children[r++];p.hiddenMatrix.identity(),p.scale.setScalar(1),p.rotation.set(0,0,0),p.position.x=i.size[0]*a-s.x,p.position.y=i.size[1]*l-s.y,p.position.z=i.size[2]*c-s.z}}else for(let o=0;o<i.count[0];o++)for(let s=0;s<i.count[1];s++)for(let a=0;a<i.count[2];a++){let l=this.children[r++];l.hiddenMatrix.identity(),l.scale.setScalar(1),l.rotation.set(0,0,0),l.position.x=i.size[0]*o,l.position.y=-i.size[1]*s,l.position.z=-i.size[2]*a}}fromJSON(e){return this}toJSON(){return{}}fromClonerState(e){return e.hideBase!==void 0&&this.setHideBase(e.hideBase),ai(this.parameters,e),this.update(),this}};var at=class extends Kt(Pv){constructor(e,r){super(e,r);this.isAbstractMesh=!0;Array.isArray(r)&&(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,r){Array.isArray(this.material)?(this.selectedMaterial===void 0&&(this.selectedMaterial=r!=null?r:0),r=r!=null?r:this.selectedMaterial,this.material[r].dispose(),this.material[r]=e):(this.material.dispose(),this.material=e)}updateGeometry(e){let r=this.geometry,i=Ml[r.userData.type],o=this.objectType==="NonParametric"?Object.assign({},r.userData,{geometry:r}):r.userData,s=i.build(i.normalizeInputs(e,o)),a=r.uuid;if(this.geometry.dispose(),this.geometry=s,this.geometry.uuid=a,this.geometry.computeBoundingSphere(),this.cloner)for(let l of this.cloner.children)l.geometry=this.geometry}resizeGeometry(e,r,i){Qo.resizeGeometry(this.geometry,{width:e,height:r,depth:i})}shallowClone(e){return new this.constructor(this.geometry,this.material).shallowCopy(this,e)}clone(e){let r=this.objectType==="NonParametric"?Object.assign({},this.geometry.userData,{geometry:this.geometry.clone()}):this.geometry.userData,i=en(r),o=Array.isArray(this.material)?this.material.map(s=>s.clone()):this.material.clone();return new this.constructor(i,o).copy(this,e)}copy(e,r=!0){return super.copy(e,r),e.cloner&&(this.cloner=new ui(e,e.cloner.parameters),this.add(this.cloner)),this}setFromClonerState(e){e===null?this.cloner=void 0:(this.cloner===void 0&&(this.cloner=new ui(this)),this.cloner.fromClonerState(e))}fromState(e,r){var i,o;return super.fromState(e),e.type==="Mesh"&&(this.setFromClonerState(e.cloner),this.castShadow=(i=e.castShadow)!=null?i:!0,this.receiveShadow=(o=e.receiveShadow)!=null?o:!0),this}};import{NormalBlending as Xv,ShaderMaterial as Zv,FrontSide as Qv}from"three";import{CubeReflectionMapping as Uv,CubeRefractionMapping as kv,CubeUVReflectionMapping as Hv,LinearEncoding as nu,sRGBEncoding as qv}from"three";var nn=class{constructor(t){t=t!=null?t:{},this.name=t.name,this.type=t.type,this.node=t.node,this.size=t.size,this.needsUpdate=t.needsUpdate}get value(){return this.node.value}set value(t){this.node.value=t}};import{MathUtils as Av}from"three";var de=class{constructor(t){this.hashProperties=void 0;this.isNode=!0;this.shortcuts={};this.uuid=Av.generateUUID(),this.type=t,this.name="",this.userData={}}analyze(t,e){e=e!=null?e:{},t.analyzing=!0,this.build(t.addFlow(e.slot,e.cache,e.context),"v4"),t.clearVertexNodeCode(),t.clearFragmentNodeCode(),t.removeFlow(),t.analyzing=!1}analyzeAndFlow(t,e,r){return r=r!=null?r:{},this.analyze(t,r),this.flow(t,e,r)}flow(t,e,r){r=r!=null?r:{},t.addFlow(r.slot,r.cache,r.context);let i={result:this.build(t,e),code:t.clearNodeCode(),extra:t.context.extra};return t.removeFlow(),i}build(t,e,r){e=e!=null?e:this.getType(t,e);let i=t.getNodeData(r!=null?r:this);return t.analyzing&&this.appendDepsNode(t,i,e),t.nodes.indexOf(this)===-1&&t.nodes.push(this),this.updateFrame!==void 0&&t.updaters.indexOf(this)===-1&&t.updaters.push(this),this.generate(t,e,r)}updateFrame(t){}generateReadonly(t,e,r,i,o,s){return""}generate(t,e,r,i,o){return""}parse(t,e,r,i){}appendDepsNode(t,e,r){e.deps=(e.deps||0)+1;let i=t.getTypeLength(r);(i>(e.outputMax||0)||this.getType(t,r))&&(e.outputMax=i,e.output=r)}setName(t){this.name=t}getName(){return this.name}getType(t,e){return e==="sampler2D"||e==="samplerCube"?e:this.type}getJSONNode(t){if((t==null?void 0:t.materials)&&(t==null?void 0:t.materials[this.uuid])!==void 0)return t.materials[this.uuid]}getHash(){let t="{",e,r;for(e in this)r=this[e],r instanceof de&&(t+='"'+e+'":'+r.getHash()+",");if(this.hashProperties)for(let i=0;i<this.hashProperties.length;i++)e=this.hashProperties[i],r=this[e],t+='"'+e+'":"'+String(r)+'",';return t+='"id":"'+this.uuid+'"}',t}copy(t){return this.name=t.name,t.type&&(this.type=t.type),t.frameId&&(this.frameId=t.frameId),t.hashProperties&&(this.hashProperties=t.hashProperties.map(e=>e)),this.userData=JSON.parse(JSON.stringify(t.userData)),this.shortcuts=JSON.parse(JSON.stringify(t.shortcuts)),this}clone(){return new this.constructor().copy(this)}createJSONNode(t){let e=t===void 0||typeof t=="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),!e&&t&&(t.nodes[this.uuid]=r),r}toJSON(t){var e;return(e=this.getJSONNode(t))!=null?e:this.createJSONNode(t)}fromJSON(t,e){return this.uuid=t.uuid,this.type=t.type,t.name&&(this.name=t.name),t.userData&&(this.userData=t.userData),this}};var Pl=class{constructor(){this.nodes={};this.keywords={}}add(t){this.nodes[t.name]=t}addKeyword(t,e,r){r=r!==void 0?r:!0,this.keywords[t]={callback:e,cache:r}}remove(t){delete this.nodes[t.name]}removeKeyword(t){delete this.keywords[t]}get(t){return this.nodes[t]}getKeyword(t,e){return this.keywords[t].callback(e)}getKeywordData(t){return this.keywords[t]}contains(t){return this.nodes[t]!==void 0}containsKeyword(t){return this.keywords[t]!==void 0}},ot=new Pl;import{Vector2 as tu}from"three";import{MathUtils as Dv}from"three";var fe=class extends de{constructor(e,r){super(e);this.scope="";r=r!=null?r:{},this.shared=r.shared!==void 0?r.shared:!0,this.unique=r.unique!==void 0?r.unique:!1}build(e,r,i,o){if(r=r!=null?r:this.getType(e),this.getShared(e,r)){let s=this.getUnique(e,r);s&&this.uuid===void 0&&(this.uuid=Dv.generateUUID()),i=e.getUUID(i!=null?i:this.getUUID(),!s);let a=e.getNodeData(i),l=a.output||this.getType(e);if(e.analyzing)return(a.deps||0)>0||this.getLabel()?(this.appendDepsNode(e,a,r),this.generate(e,r,i)):super.build(e,r,i);if(s)return a.name=a.name||super.build(e,r,i),a.name;if(!this.getLabel()&&(!this.getShared(e,l)||e.context.ignoreCache||a.deps===1))return super.build(e,r,i);i=this.getUUID(!1);let c=this.getTemp(e,i);if(c)return e.format(c,l,r);{c=super.generate(e,r,i,a.output,o);let p=this.generate(e,l,i);return e.addNodeCode(c+" = "+p+";"),e.format(c,l,r)}}return super.build(e,r,i)}getShared(e,r){return r!=="sampler2D"&&r!=="samplerCube"&&this.shared}getUnique(e,r){return this.unique}setLabel(e){return this.label=e,this}getLabel(){return this.label}getUUID(e){let r=this.uuid;return typeof this.scope=="string"&&(r=this.scope+"-"+r),r}getTemp(e,r){r=r||this.uuid;let i=e.getVars()[r];return i?i.name:void 0}generate(e,r,i,o,s){return this.getShared(e,r)||console.error("TempNode is not shared"),i=i!=null?i:this.uuid,e.getTempVar(i,o!=null?o:this.getType(e),s,this.getLabel()).name}};var Fe=class extends fe{constructor(e,r){r=r!=null?r:{},r.shared=r.shared!==void 0?r.shared:!1;super(e,r);this.readonly=!1}setReadonly(e){return this.readonly=e,this.hashProperties=this.readonly?["value"]:void 0,this}getReadonly(){return this.readonly}createJSONNode(e){let r=super.createJSONNode(e);return this.readonly===!0&&(r.readonly=this.readonly),r}fromJSON(e,r){return super.fromJSON(e,r),e.readonly!==void 0&&this.setReadonly(e.readonly),this}generate(e,r,i,o,s,a){i=e.getUUID(i!=null?i:this.getUUID()),o=o!=null?o:this.getType(e);let l=e.getNodeData(i);return this.getReadonly()&&this.generateReadonly!==void 0?this.generateReadonly(e,r,i,o,s,a):e.isShader("vertex")?(l.vertex||(l.vertex=e.createVertexUniform(o,this,s,a,this.getLabel())),e.format(l.vertex.name,o,r)):(l.fragment||(l.fragment=e.createFragmentUniform(o,this,s,a,this.getLabel())),e.format(l.fragment.name,o,r))}copy(e){return super.copy(e),this.readonly=e.readonly,this}};var bt=class extends Fe{constructor(e=0,r){super("v2");this.nodeType="Vector2";this.value=e instanceof tu?e:new tu(e,r)}get x(){return this.value.x}set x(e){this.value.x=e}get y(){return this.value.y}set y(e){this.value.y=e}generateReadonly(e,r,i,o,s,a){return e.format("vec2("+this.value.x+", "+this.value.y+")",o,r)}copy(e){return super.copy(e),this.value.copy(e.value),this}};import{Vector3 as ru}from"three";var vt=class extends Fe{constructor(e=0,r,i){super("v3");this.nodeType="Vector3";this.value=e instanceof ru?e:new ru(e,r,i)}get x(){return this.value.x}set x(e){this.value.x=e}get y(){return this.value.y}set y(e){this.value.y=e}get z(){return this.value.z}set z(e){this.value.z=e}generateReadonly(e,r,i,o,s,a){return e.format("vec3("+this.value.x+", "+this.value.y+", "+this.value.z+")",o,r)}copy(e){return super.copy(e),this.value.copy(e.value),this}};var Ir=class extends Fe{constructor(e){super("v4");this.nodeType="Vector4";this.value=e instanceof Pt?e:new Pt(e.r,e.g,e.b,e.a)}generateReadonly(e,r,i,o,s,a){return e.format("vec4("+this.value.r+", "+this.value.g+", "+this.value.b+", "+this.value.a+")",o,r)}copy(e){return super.copy(e),this.value.copy(e.value),this}};var _v=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,iu=/[a-z_0-9]+/gi,re=class extends fe{constructor(e,r,i,o,s){super(s);this.src="";this.nodeType="Function";this.useKeywords=!0;this.includes=[];this.extensions={};this.keywords={};this.isMethod=s===void 0,this.isInterface=!1,this.parse(e,r,i,o)}getShared(e,r){return!this.isMethod}getType(e){return e.getTypeByFormat(this.type)}getInputByName(e){if(this.inputs){let r=this.inputs.length;for(;r--;)if(this.inputs[r].name===e)return this.inputs[r]}}getIncludeByName(e){if(this.includes){let r=this.includes.length;for(;r--;)if(this.includes[r].name===e)return this.includes[r]}}generate(e,r,i,o,s){let a,l=0,c=this.src;if(this.includes)for(let h=0;h<this.includes.length;h++)e.include(this.includes[h],this);for(let h in this.extensions)e.extensions[h]=!0;let p=[];for(;a=iu.exec(this.src);)p.push(a);for(let h=0;h<p.length;h++){let d=p[h],m=d[0],f=this.isMethod?!this.getInputByName(m):!0,T=m;if(this.keywords[m]||this.useKeywords&&f&&ot.containsKeyword(m)){let w=this.keywords[m];if(!w){let y=ot.getKeywordData(m);y.cache&&(w=e.keywords[m]),w=w||ot.getKeyword(m,e),y.cache&&(e.keywords[m]=w)}T=w.build(e)}m!==T&&(c=c.substring(0,d.index+l)+T+c.substring(d.index+m.length+l),l+=T.length-m.length),this.getIncludeByName(T)===void 0&&ot.contains(T)&&e.include(ot.get(T))}return r==="source"?c:this.isMethod?(this.isInterface||e.include(this,void 0,c),this.name):e.format("( "+c+" )",this.getType(e),r)}parse(e,r,i,o){if(this.src=e||"",this.includes=r!=null?r:[],this.extensions=i!=null?i:{},this.keywords=o!=null?o:{},this.isMethod){let s=_v.exec(this.src);if(this.inputs=[],s&&s.length==4){this.type=s[1],this.name=s[2];let a=s[3].match(iu);if(a){let l=0;for(;l<a.length;){let c=a[l++],p;c==="in"||c==="out"||c==="inout"?p=a[l++]:(p=c,c="");let h=a[l++];this.inputs.push({name:h,type:p,qualifier:c})}}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 i;let r=this.getJSONNode(e);if(!r){r=this.createJSONNode(e),r.src=this.src,r.isMethod=this.isMethod,r.useKeywords=this.useKeywords,this.isMethod||(r.type=this.type),r.extensions=JSON.parse(JSON.stringify(this.extensions));let o={};for(let s in this.keywords)o[s]=this.keywords[s].toJSON(e).uuid;if(r.keywords=o,(i=this.includes)!=null&&i.length){let s=[];for(let a=0;a<this.includes.length;a++)s.push(this.includes[a].toJSON(e).uuid);r.includes=s}r.isMethod=this.isMethod,r.inputs=this.inputs}return r.nodeType=this.nodeType,r}fromJSON(e,r){if(super.fromJSON(e,r),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&&r){this.keywords={};for(let i in e.keywords)this.keywords[i]=r.getNode(e.keywords[i])}return e.includes&&r&&(this.includes=e.includes.map(i=>r.getNode(i))),this}};var Bv=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=?\s?(.*?)(\;|$)/i,Al=class extends fe{constructor(e="",r){super();this.src="";this.useDefine=!1;this.nodeType="Const";this.parse(e||Al.PI,void 0,void 0,void 0,r)}getType(e){return e.getTypeByFormat(this.type)}parse(e,r,i,o,s){this.src=e||"";let a,l,c="",p=Bv.exec(e);this.useDefine=s!=null?s:this.src.charAt(0)==="#",p&&p.length>1?(l=p[1],a=p[2],c=p[3]):(a=this.src,l="f"),this.name=a,this.type=l,this.value=c}build(e,r){if(r==="source"){if(this.value)return this.useDefine?"#define "+this.name+" "+this.value:"const "+this.type+" "+this.name+" = "+this.value+";";if(this.useDefine)return this.src}return e.include(this),e.format(this.name,this.getType(e),r)}generate(e,r,i,o,s){return e.format(this.name,this.getType(e),r)}copy(e){return super.copy(e),this.parse(e.src,void 0,void 0,void 0,e.useDefine),this}},Te=Al;Te.PI="PI",Te.PI2="PI2",Te.RECIPROCAL_PI="RECIPROCAL_PI",Te.RECIPROCAL_PI2="RECIPROCAL_PI2",Te.LOG2="LOG2",Te.EPSILON="EPSILON";var Ev=new RegExp(`^structs*([a-z_0-9]+)s*{s*((.|
|
|
2
|
+
)*?)}`,"gim"),Gv=new RegExp("s*(w*?)s*(w*?)(=|;)","gim"),no=class extends fe{constructor(e=""){super();this.inputs=[];this.src="";this.nodeType="Struct";this.parse(e)}getType(e){return e.getTypeByFormat(this.name)}getInputByName(e){let r=this.inputs.length;for(;r--;)if(this.inputs[r].name===e)return this.inputs[r]}generate(e,r,i,o,s){return r==="source"?this.src+";":e.format("( "+this.src+" )",this.getType(e),r)}parse(e=""){this.src=e,this.inputs=[];let r=Ev.exec(e);if(r){let i=r[2],o;for(;o=Gv.exec(i);)this.inputs.push({type:o[1],name:o[2]});this.name=r[1]}else this.name="";this.type=this.name}};var so=class extends fe{constructor(e){super("v2",{shared:!1});this.nodeType="UV";this.index=e!=null?e:0}generate(e,r){e.requires.uv[this.index]=!0;let i=this.index>0?this.index+1:"",o=e.isShader("vertex")?"uv"+i:"vUv"+i;return e.format(o,this.getType(e),r)}copy(e){return super.copy(e),this.index=e.index,this}toJSON(e){let r=this.getJSONNode(e);return r||(r=this.createJSONNode(e),r.index=this.index),r.nodeType=this.nodeType,r}fromJSON(e,r){return super.fromJSON(e,r),e.index&&(this.index=e.index),this}};ot.addKeyword("uv",function(){return new so});ot.addKeyword("uv2",function(){return new so(1)});import{LinearEncoding as zv,sRGBEncoding as Rv}from"three";var mi=class extends fe{constructor(e=new de,r){super("v4");this.nodeType="ColorSpace";this.factor=new de;this.input=e,this.method=r!=null?r:mi.LINEAR_TO_LINEAR,this.hashProperties=["method"]}static getEncodingComponents(e){switch(e){case zv:return["Linear"];case Rv:return["sRGB"];default:return[]}}generate(e,r){var l;let i=this.input.build(e,"v4"),o=this.getType(e),s=mi.Nodes[this.method],a=e.include(s);if(a===mi.LINEAR_TO_LINEAR)return e.format(i,o,r);if(((l=s.inputs)==null?void 0:l.length)===2){let c=this.factor.build(e,"f");return e.format(a+"( "+i+", "+c+" )",o,r)}else return e.format(a+"( "+i+" )",o,r)}fromEncoding(e){let r=mi.getEncodingComponents(e);this.method="LinearTo"+r[0],this.factor=r[1]}fromDecoding(e){let r=mi.getEncodingComponents(e);this.method=r[0]+"ToLinear",this.factor=r[1]}copy(e){return super.copy(e),this.input.copy(e.input),this.method=e.method,this.factor.copy(e.factor),this}},Tt=mi;Tt.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
|
-
`))},Tt.LINEAR_TO_LINEAR="LinearToLinear",Tt.SRGB_TO_LINEAR="sRGBToLinear",Tt.LINEAR_TO_SRGB="LinearTosRGB";var _e=class extends re{constructor(e="",r,i,o,s){super(e,s,o,i,r);this.nodeType="Expression"}};import{Texture as Rv}from"three";var ur=class extends Rv{toJSON(t){let e=super.toJSON(t),r=t===void 0||typeof t=="string";if(this.image!==void 0&&!r){let i=this.image;if(Array.isArray(i)){t.images[i.uuid].url=[];for(let o=0;o<i.length;o++)t.images[i.uuid].url[o]=ou(i[o])}else t.images[i.uuid].url=ou(i)}return e}};function ou(n){return typeof HTMLImageElement<"u"&&n instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&n instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&n instanceof ImageBitmap?Vv(n):(console.warn("THREE.Texture: Unable to serialize Texture."),"")}var ao;function Vv(n){if(/^data:/i.test(n.src))return n.src;let t;if(n instanceof HTMLCanvasElement)t=n;else{ao===void 0&&(ao=document.createElement("canvas")),ao.width=n.width,ao.height=n.height;let r=ao.getContext("2d");n instanceof ImageData?r.putImageData(n,0,0):r.drawImage(n,0,0,n.width,n.height),t=ao}let e=n.src.startsWith("blob:")?n.fileName:n.src;return/\.jpe?g$/i.test(e)?t.toDataURL("image/jpeg",.6):t.toDataURL("image/png")}var Nt=class extends Fe{constructor(e=new ur,r,i,o){super("v4",{shared:!0});this.nodeType="Texture";this.value=e,this.uv=r!=null?r:new so,this.bias=i,this.project=o!==void 0?o:!1}getTexture(e,r){return super.generate(e,r,this.value.uuid,"t")}generate(e,r){var h;if(r==="sampler2D")return this.getTexture(e,r);let i=this.getTexture(e,r),o=this.uv.build(e,this.project?"v4":"v2"),s=this.bias?this.bias.build(e,"f"):void 0;s===void 0&&e.context.bias&&(s=e.context.bias.setTexture(this).build(e,"f"));let a,l;this.project?a="texture2DProj":a=s?"tex2DBias":"tex2D",s?l=a+"( "+i+", "+o+", "+s+" )":l=a+"( "+i+", "+o+" )";let c={include:e.isShader("vertex"),ignoreCache:!0},p=this.getType(e);return e.addContext(c),this.colorSpace=(h=this.colorSpace)!=null?h:new Tt(new _e("",p)),this.colorSpace.fromDecoding(e.getTextureEncodingFromMap(this.value)),this.colorSpace.input.parse(l),l=this.colorSpace.build(e,p),e.removeContext(),e.format(l,p,r)}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 te=class extends Fe{constructor(e){super("f");this.nodeType="Float";this.value=e!=null?e:0}generateReadonly(e,r,i,o,s,a){return e.format(this.value+(this.value%1?"":".0"),o,r)}copy(e){return super.copy(e),this.value=e.value,this}};var sn=class extends fe{constructor(e,r){super();this.inputs=[];this.nodeType="FunctionCall";this.value=e,this.inputs=r!=null?r:[]}getFunction(){return this.value}getType(e){return this.value.getType(e)}generate(e,r,i,o,s){o=this.getType(e);let a=this.value,l=a.build(e,r)+"( ",c=[];if(a.inputs){for(let p=0;p<a.inputs.length;p++){let h=a.inputs[p],d=this.inputs[p]||this.inputs[h.name];c.push(d.build(e,e.getTypeByFormat(h.type)))}l+=c.join(", ")+" )"}return e.format(l,o,r)}copy(e){return super.copy(e),this.value.copy(e.value),this.inputs=e.inputs.map(r=>r.clone()),this}toJSON(e){var i;let r=this.getJSONNode(e);if(!r){let o=this.value;if(r=this.createJSONNode(e),r.value=this.value.toJSON(e).uuid,(i=o.inputs)!=null&&i.length){r.inputs={};for(let s=0;s<o.inputs.length;s++){let a=o.inputs[s],l=this.inputs[s];r.inputs[a.name]=l.toJSON(e).uuid}}}return r}};var Dl=class extends fe{constructor(e=new de,r=new de,i=Dl.ADD){super();this.nodeType="Operator";this.type=e.type,this.a=e,this.b=r,this.op=i}getType(e){let r=this.a.getType(e),i=this.b.getType(e);return e.isTypeMatrix(r)?"v4":e.getTypeLength(i)>e.getTypeLength(r)?i:r}generate(e,r){let i=this.getType(e);this.type=i;let o=this.a.build(e,i),s=this.b.build(e,i);return e.format("( "+o+" "+this.op+" "+s+" )",i,r)}copy(e){return super.copy(e),this.a.copy(e.a),this.b.copy(e.b),this.op=e.op,this}},At=Dl;At.ADD="+",At.SUB="-",At.MUL="*",At.DIV="/";var Pe=class extends fe{constructor(e=new de,r=Pe.ABS,i,o){super();this.nodeType="Math";this.a=e,typeof r!="string"?this.b=r:o=r,typeof i!="string"?this.c=i:o=i,this.method=o,this.hashProperties=["method"]}getNumInputs(e){switch(this.method){case Pe.MIX:case Pe.CLAMP:case Pe.REFRACT:case Pe.SMOOTHSTEP:case Pe.FACEFORWARD:return 3;case Pe.MIN:case Pe.MAX:case Pe.MOD:case Pe.STEP:case Pe.REFLECT:case Pe.DISTANCE:case Pe.DOT:case Pe.CROSS:case Pe.POW:return 2;default:return 1}}getInputType(e){let r=e.getTypeLength(this.a.getType(e)),i=this.b?e.getTypeLength(this.b.getType(e)):0,o=this.c?e.getTypeLength(this.c.getType(e)):0;return r>i&&r>o?this.a.getType(e):i>o?this.b.getType(e):this.c.getType(e)}getType(e){switch(this.method){case Pe.LENGTH:case Pe.DISTANCE:case Pe.DOT:return"f";case Pe.CROSS:return"v3"}return this.getInputType(e)}generate(e,r){let i,o,s,a=this.a?e.getTypeLength(this.a.getType(e)):0,l=this.b?e.getTypeLength(this.b.getType(e)):0,c=this.c?e.getTypeLength(this.c.getType(e)):0,p=this.getInputType(e),h=this.getType(e);switch(this.type=h,this.method){case Pe.NEGATE:return e.format("( -"+this.a.build(e,p)+" )",p,r);case Pe.INVERT:return e.format("( 1.0 - "+this.a.build(e,p)+" )",p,r);case Pe.CROSS:i=this.a.build(e,"v3"),o=this.b.build(e,"v3");break;case Pe.STEP:i=this.a.build(e,a===1?"f":p),o=this.b.build(e,p);break;case Pe.MIN:case Pe.MAX:case Pe.MOD:i=this.a.build(e,p),o=this.b.build(e,l===1?"f":p);break;case Pe.REFRACT:i=this.a.build(e,p),o=this.b.build(e,p),s=this.c.build(e,"f");break;case Pe.MIX:i=this.a.build(e,p),o=this.b.build(e,p),s=this.c.build(e,c===1?"f":p);break;default:i=this.a.build(e,p),this.b&&(o=this.b.build(e,p)),this.c&&(s=this.c.build(e,p));break}let d=[];d.push(i),o&&d.push(o),s&&d.push(s);let m=this.getNumInputs(e);if(d.length!==m)throw Error(`Arguments not match used in "${this.method}". Require ${m}, currently ${d.length}.`);return e.format(this.method+"( "+d.join(", ")+" )",h,r)}copy(e){return super.copy(e),this.a.copy(e.a),this.b=e.b instanceof de?e.b.clone():e.b,this.c=e.c instanceof de?e.c.clone():e.c,this.method=e.method,this}},ye=Pe;ye.RAD="radians",ye.DEG="degrees",ye.EXP="exp",ye.EXP2="exp2",ye.LOG="log",ye.LOG2="log2",ye.SQRT="sqrt",ye.INV_SQRT="inversesqrt",ye.FLOOR="floor",ye.CEIL="ceil",ye.NORMALIZE="normalize",ye.FRACT="fract",ye.SATURATE="saturate",ye.SIN="sin",ye.COS="cos",ye.TAN="tan",ye.ASIN="asin",ye.ACOS="acos",ye.ARCTAN="atan",ye.ABS="abs",ye.SIGN="sign",ye.LENGTH="length",ye.NEGATE="negate",ye.INVERT="invert",ye.MIN="min",ye.MAX="max",ye.MOD="mod",ye.STEP="step",ye.REFLECT="reflect",ye.DISTANCE="distance",ye.DOT="dot",ye.CROSS="cross",ye.POW="pow",ye.MIX="mix",ye.CLAMP="clamp",ye.REFRACT="refract",ye.SMOOTHSTEP="smoothstep",ye.FACEFORWARD="faceforward";var lo=class extends fe{constructor(e=new de,r=new de,i=new de){super("v4");this.nodeType="TextureCubeUV";this.value=e,this.uv=r,this.bias=i}bilinearCubeUV(e,r,i,o){var c,p,h,d;let s=new sn(lo.Nodes.bilinearCubeUV,[r,i,o]);this.colorSpaceTL=(c=this.colorSpaceTL)!=null?c:new Tt(new _e("","v4")),this.colorSpaceTL.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceTL.input.parse(s.build(e)+".tl"),this.colorSpaceTR=(p=this.colorSpaceTR)!=null?p:new Tt(new _e("","v4")),this.colorSpaceTR.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceTR.input.parse(s.build(e)+".tr"),this.colorSpaceBL=(h=this.colorSpaceBL)!=null?h:new Tt(new _e("","v4")),this.colorSpaceBL.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceBL.input.parse(s.build(e)+".bl"),this.colorSpaceBR=(d=this.colorSpaceBR)!=null?d:new Tt(new _e("","v4")),this.colorSpaceBR.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceBR.input.parse(s.build(e)+".br");let a={include:e.isShader("vertex"),ignoreCache:!0};e.addContext(a),this.colorSpaceTLExp=new _e(this.colorSpaceTL.build(e,"v4"),"v4"),this.colorSpaceTRExp=new _e(this.colorSpaceTR.build(e,"v4"),"v4"),this.colorSpaceBLExp=new _e(this.colorSpaceBL.build(e,"v4"),"v4"),this.colorSpaceBRExp=new _e(this.colorSpaceBR.build(e,"v4"),"v4"),e.removeContext();let l=new _e("mix( mix( cubeUV_TL, cubeUV_TR, cubeUV.f.x ), mix( cubeUV_BL, cubeUV_BR, cubeUV.f.x ), cubeUV.f.y )","v4");return l.keywords.cubeUV_TL=this.colorSpaceTLExp,l.keywords.cubeUV_TR=this.colorSpaceTRExp,l.keywords.cubeUV_BL=this.colorSpaceBLExp,l.keywords.cubeUV_BR=this.colorSpaceBRExp,l.keywords.cubeUV=s,l}generate(e,r){if(e.isShader("fragment")){let i=this.uv,o=this.bias||e.context.roughness,s=new sn(lo.Nodes.roughnessToMip,[o]),a=new ye(s,lo.Nodes.m0,lo.Nodes.cubeUV_maxMipLevel,ye.CLAMP),l=new ye(a,ye.FLOOR),c=new ye(a,ye.FRACT),p=this.bilinearCubeUV(e,this.value,i,l),h=this.bilinearCubeUV(e,this.value,i,new At(l,new te(1).setReadonly(!0),At.ADD)),d=new ye(p,h,c,ye.MIX);return e.format(d.build(e),"v4",r)}else return console.warn("TextureCubeUVNode is not compatible with "+e.shader+" shader."),e.format("vec4( 0.0 )",this.getType(e),r)}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}},co=lo;co.Nodes=function(){let e=new no(`struct TextureCubeUVData {
|
|
5
|
+
`))},Tt.LINEAR_TO_LINEAR="LinearToLinear",Tt.SRGB_TO_LINEAR="sRGBToLinear",Tt.LINEAR_TO_SRGB="LinearTosRGB";var _e=class extends re{constructor(e="",r,i,o,s){super(e,s,o,i,r);this.nodeType="Expression"}};import{Texture as Vv}from"three";var ur=class extends Vv{toJSON(t){let e=super.toJSON(t),r=t===void 0||typeof t=="string";if(this.image!==void 0&&!r){let i=this.image;if(Array.isArray(i)){t.images[i.uuid].url=[];for(let o=0;o<i.length;o++)t.images[i.uuid].url[o]=ou(i[o])}else t.images[i.uuid].url=ou(i)}return e}};function ou(n){return typeof HTMLImageElement<"u"&&n instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&n instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&n instanceof ImageBitmap?Fv(n):(console.warn("THREE.Texture: Unable to serialize Texture."),"")}var ao;function Fv(n){if(/^data:/i.test(n.src))return n.src;let t;if(n instanceof HTMLCanvasElement)t=n;else{ao===void 0&&(ao=document.createElement("canvas")),ao.width=n.width,ao.height=n.height;let r=ao.getContext("2d");n instanceof ImageData?r.putImageData(n,0,0):r.drawImage(n,0,0,n.width,n.height),t=ao}let e=n.src.startsWith("blob:")?n.fileName:n.src;return/\.jpe?g$/i.test(e)?t.toDataURL("image/jpeg",.6):t.toDataURL("image/png")}var Nt=class extends Fe{constructor(e=new ur,r,i,o){super("v4",{shared:!0});this.nodeType="Texture";this.value=e,this.uv=r!=null?r:new so,this.bias=i,this.project=o!==void 0?o:!1}getTexture(e,r){return super.generate(e,r,this.value.uuid,"t")}generate(e,r){var h;if(r==="sampler2D")return this.getTexture(e,r);let i=this.getTexture(e,r),o=this.uv.build(e,this.project?"v4":"v2"),s=this.bias?this.bias.build(e,"f"):void 0;s===void 0&&e.context.bias&&(s=e.context.bias.setTexture(this).build(e,"f"));let a,l;this.project?a="texture2DProj":a=s?"tex2DBias":"tex2D",s?l=a+"( "+i+", "+o+", "+s+" )":l=a+"( "+i+", "+o+" )";let c={include:e.isShader("vertex"),ignoreCache:!0},p=this.getType(e);return e.addContext(c),this.colorSpace=(h=this.colorSpace)!=null?h:new Tt(new _e("",p)),this.colorSpace.fromDecoding(e.getTextureEncodingFromMap(this.value)),this.colorSpace.input.parse(l),l=this.colorSpace.build(e,p),e.removeContext(),e.format(l,p,r)}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 te=class extends Fe{constructor(e){super("f");this.nodeType="Float";this.value=e!=null?e:0}generateReadonly(e,r,i,o,s,a){return e.format(this.value+(this.value%1?"":".0"),o,r)}copy(e){return super.copy(e),this.value=e.value,this}};var sn=class extends fe{constructor(e,r){super();this.inputs=[];this.nodeType="FunctionCall";this.value=e,this.inputs=r!=null?r:[]}getFunction(){return this.value}getType(e){return this.value.getType(e)}generate(e,r,i,o,s){o=this.getType(e);let a=this.value,l=a.build(e,r)+"( ",c=[];if(a.inputs){for(let p=0;p<a.inputs.length;p++){let h=a.inputs[p],d=this.inputs[p]||this.inputs[h.name];c.push(d.build(e,e.getTypeByFormat(h.type)))}l+=c.join(", ")+" )"}return e.format(l,o,r)}copy(e){return super.copy(e),this.value.copy(e.value),this.inputs=e.inputs.map(r=>r.clone()),this}toJSON(e){var i;let r=this.getJSONNode(e);if(!r){let o=this.value;if(r=this.createJSONNode(e),r.value=this.value.toJSON(e).uuid,(i=o.inputs)!=null&&i.length){r.inputs={};for(let s=0;s<o.inputs.length;s++){let a=o.inputs[s],l=this.inputs[s];r.inputs[a.name]=l.toJSON(e).uuid}}}return r}};var Dl=class extends fe{constructor(e=new de,r=new de,i=Dl.ADD){super();this.nodeType="Operator";this.type=e.type,this.a=e,this.b=r,this.op=i}getType(e){let r=this.a.getType(e),i=this.b.getType(e);return e.isTypeMatrix(r)?"v4":e.getTypeLength(i)>e.getTypeLength(r)?i:r}generate(e,r){let i=this.getType(e);this.type=i;let o=this.a.build(e,i),s=this.b.build(e,i);return e.format("( "+o+" "+this.op+" "+s+" )",i,r)}copy(e){return super.copy(e),this.a.copy(e.a),this.b.copy(e.b),this.op=e.op,this}},At=Dl;At.ADD="+",At.SUB="-",At.MUL="*",At.DIV="/";var Pe=class extends fe{constructor(e=new de,r=Pe.ABS,i,o){super();this.nodeType="Math";this.a=e,typeof r!="string"?this.b=r:o=r,typeof i!="string"?this.c=i:o=i,this.method=o,this.hashProperties=["method"]}getNumInputs(e){switch(this.method){case Pe.MIX:case Pe.CLAMP:case Pe.REFRACT:case Pe.SMOOTHSTEP:case Pe.FACEFORWARD:return 3;case Pe.MIN:case Pe.MAX:case Pe.MOD:case Pe.STEP:case Pe.REFLECT:case Pe.DISTANCE:case Pe.DOT:case Pe.CROSS:case Pe.POW:return 2;default:return 1}}getInputType(e){let r=e.getTypeLength(this.a.getType(e)),i=this.b?e.getTypeLength(this.b.getType(e)):0,o=this.c?e.getTypeLength(this.c.getType(e)):0;return r>i&&r>o?this.a.getType(e):i>o?this.b.getType(e):this.c.getType(e)}getType(e){switch(this.method){case Pe.LENGTH:case Pe.DISTANCE:case Pe.DOT:return"f";case Pe.CROSS:return"v3"}return this.getInputType(e)}generate(e,r){let i,o,s,a=this.a?e.getTypeLength(this.a.getType(e)):0,l=this.b?e.getTypeLength(this.b.getType(e)):0,c=this.c?e.getTypeLength(this.c.getType(e)):0,p=this.getInputType(e),h=this.getType(e);switch(this.type=h,this.method){case Pe.NEGATE:return e.format("( -"+this.a.build(e,p)+" )",p,r);case Pe.INVERT:return e.format("( 1.0 - "+this.a.build(e,p)+" )",p,r);case Pe.CROSS:i=this.a.build(e,"v3"),o=this.b.build(e,"v3");break;case Pe.STEP:i=this.a.build(e,a===1?"f":p),o=this.b.build(e,p);break;case Pe.MIN:case Pe.MAX:case Pe.MOD:i=this.a.build(e,p),o=this.b.build(e,l===1?"f":p);break;case Pe.REFRACT:i=this.a.build(e,p),o=this.b.build(e,p),s=this.c.build(e,"f");break;case Pe.MIX:i=this.a.build(e,p),o=this.b.build(e,p),s=this.c.build(e,c===1?"f":p);break;default:i=this.a.build(e,p),this.b&&(o=this.b.build(e,p)),this.c&&(s=this.c.build(e,p));break}let d=[];d.push(i),o&&d.push(o),s&&d.push(s);let m=this.getNumInputs(e);if(d.length!==m)throw Error(`Arguments not match used in "${this.method}". Require ${m}, currently ${d.length}.`);return e.format(this.method+"( "+d.join(", ")+" )",h,r)}copy(e){return super.copy(e),this.a.copy(e.a),this.b=e.b instanceof de?e.b.clone():e.b,this.c=e.c instanceof de?e.c.clone():e.c,this.method=e.method,this}},ye=Pe;ye.RAD="radians",ye.DEG="degrees",ye.EXP="exp",ye.EXP2="exp2",ye.LOG="log",ye.LOG2="log2",ye.SQRT="sqrt",ye.INV_SQRT="inversesqrt",ye.FLOOR="floor",ye.CEIL="ceil",ye.NORMALIZE="normalize",ye.FRACT="fract",ye.SATURATE="saturate",ye.SIN="sin",ye.COS="cos",ye.TAN="tan",ye.ASIN="asin",ye.ACOS="acos",ye.ARCTAN="atan",ye.ABS="abs",ye.SIGN="sign",ye.LENGTH="length",ye.NEGATE="negate",ye.INVERT="invert",ye.MIN="min",ye.MAX="max",ye.MOD="mod",ye.STEP="step",ye.REFLECT="reflect",ye.DISTANCE="distance",ye.DOT="dot",ye.CROSS="cross",ye.POW="pow",ye.MIX="mix",ye.CLAMP="clamp",ye.REFRACT="refract",ye.SMOOTHSTEP="smoothstep",ye.FACEFORWARD="faceforward";var lo=class extends fe{constructor(e=new de,r=new de,i=new de){super("v4");this.nodeType="TextureCubeUV";this.value=e,this.uv=r,this.bias=i}bilinearCubeUV(e,r,i,o){var c,p,h,d;let s=new sn(lo.Nodes.bilinearCubeUV,[r,i,o]);this.colorSpaceTL=(c=this.colorSpaceTL)!=null?c:new Tt(new _e("","v4")),this.colorSpaceTL.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceTL.input.parse(s.build(e)+".tl"),this.colorSpaceTR=(p=this.colorSpaceTR)!=null?p:new Tt(new _e("","v4")),this.colorSpaceTR.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceTR.input.parse(s.build(e)+".tr"),this.colorSpaceBL=(h=this.colorSpaceBL)!=null?h:new Tt(new _e("","v4")),this.colorSpaceBL.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceBL.input.parse(s.build(e)+".bl"),this.colorSpaceBR=(d=this.colorSpaceBR)!=null?d:new Tt(new _e("","v4")),this.colorSpaceBR.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceBR.input.parse(s.build(e)+".br");let a={include:e.isShader("vertex"),ignoreCache:!0};e.addContext(a),this.colorSpaceTLExp=new _e(this.colorSpaceTL.build(e,"v4"),"v4"),this.colorSpaceTRExp=new _e(this.colorSpaceTR.build(e,"v4"),"v4"),this.colorSpaceBLExp=new _e(this.colorSpaceBL.build(e,"v4"),"v4"),this.colorSpaceBRExp=new _e(this.colorSpaceBR.build(e,"v4"),"v4"),e.removeContext();let l=new _e("mix( mix( cubeUV_TL, cubeUV_TR, cubeUV.f.x ), mix( cubeUV_BL, cubeUV_BR, cubeUV.f.x ), cubeUV.f.y )","v4");return l.keywords.cubeUV_TL=this.colorSpaceTLExp,l.keywords.cubeUV_TR=this.colorSpaceTRExp,l.keywords.cubeUV_BL=this.colorSpaceBLExp,l.keywords.cubeUV_BR=this.colorSpaceBRExp,l.keywords.cubeUV=s,l}generate(e,r){if(e.isShader("fragment")){let i=this.uv,o=this.bias||e.context.roughness,s=new sn(lo.Nodes.roughnessToMip,[o]),a=new ye(s,lo.Nodes.m0,lo.Nodes.cubeUV_maxMipLevel,ye.CLAMP),l=new ye(a,ye.FLOOR),c=new ye(a,ye.FRACT),p=this.bilinearCubeUV(e,this.value,i,l),h=this.bilinearCubeUV(e,this.value,i,new At(l,new te(1).setReadonly(!0),At.ADD)),d=new ye(p,h,c,ye.MIX);return e.format(d.build(e),"v4",r)}else return console.warn("TextureCubeUVNode is not compatible with "+e.shader+" shader."),e.format("vec4( 0.0 )",this.getType(e),r)}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}},co=lo;co.Nodes=function(){let e=new no(`struct TextureCubeUVData {
|
|
6
6
|
vec4 tl;
|
|
7
7
|
vec4 tr;
|
|
8
8
|
vec4 br;
|
|
@@ -81,7 +81,7 @@ var sm=Object.create;var Dn=Object.defineProperty,am=Object.defineProperties,lm=
|
|
|
81
81
|
mip = -2.0 * log2(1.16 * roughness);// 1.16 = 1.79^0.25
|
|
82
82
|
}
|
|
83
83
|
return mip;
|
|
84
|
-
}`,M);return{bilinearCubeUV:c,roughnessToMip:g,m0:d,cubeUV_maxMipLevel:r}}();var fi=class extends fe{constructor(e){super("v3");this.nodeType="Normal";this.scope=e!=null?e:fi.VIEW}getShared(){return this.scope===fi.WORLD}build(e,r,i,o){let s=e.context[this.scope+"Normal"];return s?s.build(e,r,i,o):super.build(e,r,i)}generate(e,r,i,o,s){let a;switch(this.scope){case fi.VIEW:e.isShader("vertex")?a="transformedNormal":a="geometryNormal";break;case fi.LOCAL:e.isShader("vertex")?a="objectNormal":(e.requires.normal=!0,a="vObjectNormal");break;case fi.WORLD:e.isShader("vertex")?a="inverseTransformDirection( transformedNormal, viewMatrix ).xyz":(e.requires.worldNormal=!0,a="vWNormal");break}return e.format(a,this.getType(e),r)}copy(e){return super.copy(e),this.scope=e.scope,this}toJSON(e){let r=this.getJSONNode(e);return r||(r=this.createJSONNode(e),r.scope=this.scope),r.nodeType=this.nodeType,r}fromJSON(e,r){return super.fromJSON(e,r),e.scope&&(this.scope=e.scope),this}},lt=fi;lt.LOCAL="local",lt.WORLD="world",lt.VIEW="view",lt.NORMAL="normal";ot.addKeyword("viewNormal",function(){return new lt(lt.VIEW)});ot.addKeyword("localNormal",function(){return new lt(lt.NORMAL)});ot.addKeyword("worldNormal",function(){return new lt(lt.WORLD)});var mr=class extends fe{constructor(e){super("v3");this.nodeType="Position";this.scope=e!=null?e:mr.LOCAL}getType(){switch(this.scope){case mr.PROJECTION:return"v4"}return this.type}getShader(){switch(this.scope){case mr.LOCAL:case mr.WORLD:return!1}return!0}generate(e,r,i,o,s){let a;switch(this.scope){case mr.LOCAL:e.isShader("vertex")?a="transformed":(e.requires.position=!0,a="vPosition");break;case mr.WORLD:if(e.isShader("vertex"))return"( modelMatrix * vec4( transformed, 1.0 ) ).xyz";e.requires.worldPosition=!0,a="vWPosition";break;case mr.VIEW:a=e.isShader("vertex")?"-mvPosition.xyz":"vViewPosition";break;case mr.PROJECTION:a=e.isShader("vertex")?"( projectionMatrix * modelViewMatrix * vec4( position, 1.0 ) )":"vec4( 0.0 )";break}return e.format(a,this.getType(),r)}copy(e){return super.copy(e),this.scope=e.scope,this}toJSON(e){let r=this.getJSONNode(e);return r||(r=this.createJSONNode(e),r.scope=this.scope),r.nodeType=this.nodeType,r}fromJSON(e,r){return super.fromJSON(e,r),e.scope&&(this.scope=e.scope),this}},ut=mr;ut.LOCAL="local",ut.WORLD="world",ut.VIEW="view",ut.PROJECTION="projection";ot.addKeyword("position",function(){return new ut});ot.addKeyword("worldPosition",function(){return new ut(ut.WORLD)});ot.addKeyword("viewPosition",function(){return new ut(ut.VIEW)});var er=class extends fe{constructor(e){super("v3");this.nodeType="Reflect";this.scope=e!=null?e:er.CUBE}getUnique(e){return!e.context.viewNormal}getType(){switch(this.scope){case er.SPHERE:return"v2"}return this.type}generate(e,r){let i=this.getUnique(e);if(e.isShader("fragment")){let o;switch(this.scope){case er.VECTOR:{let s=new lt(lt.VIEW),a=e.context.roughness,l=s.build(e,"v3"),c=new ut(ut.VIEW).build(e,"v3"),p=a?a.build(e,"f"):void 0,h=`reflect( -normalize( ${c} ), ${l} )`;p&&(h=`normalize( mix( ${h}, ${l}, ${p} * ${p} ) )`);let d=`inverseTransformDirection( ${h}, viewMatrix )`;i?(e.addNodeCode(`vec3 reflectVec = ${d};`),o="reflectVec"):o=d;break}case er.CUBE:{let s=new er(er.VECTOR).build(e,"v3"),a="vec3( -"+s+".x, "+s+".yz )";i?(e.addNodeCode(`vec3 reflectCubeVec = ${a};`),o="reflectCubeVec"):o=a;break}case er.SPHERE:{let s=new er(er.VECTOR).build(e,"v3"),a="normalize( ( viewMatrix * vec4( "+s+", 0.0 ) ).xyz + vec3( 0.0, 0.0, 1.0 ) ).xy * 0.5 + 0.5";i?(e.addNodeCode(`vec2 reflectSphereVec = ${a};`),o="reflectSphereVec"):o=a;break}}return e.format(o,this.getType(),r)}else return console.warn("ReflectNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.type,r)}copy(e){return super.copy(e),this.scope=e.scope,this}toJSON(e){let r=this.getJSONNode(e);return r||(r=this.createJSONNode(e),r.scope=this.scope),r.nodeType=this.nodeType,r}fromJSON(e,r){return super.fromJSON(e,r),e.scope&&(this.scope=e.scope),this}},fr=er;fr.CUBE="cube",fr.SPHERE="sphere",fr.VECTOR="vector";var Xs=class extends fe{constructor(e=new Nt,r,i){super("v4");this.nodeType="TextureCube";this.value=e,this.radianceNode=new co(this.value,r!=null?r:new fr(fr.VECTOR),i),this.irradianceNode=new co(this.value,new lt(lt.WORLD),new te(1).setReadonly(!0))}generate(e,r){return e.isShader("fragment")?(e.require("irradiance"),e.context.bias&&e.context.bias.setTexture(this.value),(e.slot==="irradiance"?this.irradianceNode:this.radianceNode).build(e,r)):(console.warn("TextureCubeNode is not compatible with "+e.shader+" shader."),e.format("vec4( 0.0 )",this.getType(e),r))}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
|
|
84
|
+
}`,M);return{bilinearCubeUV:c,roughnessToMip:g,m0:d,cubeUV_maxMipLevel:r}}();var fi=class extends fe{constructor(e){super("v3");this.nodeType="Normal";this.scope=e!=null?e:fi.VIEW}getShared(){return this.scope===fi.WORLD}build(e,r,i,o){let s=e.context[this.scope+"Normal"];return s?s.build(e,r,i,o):super.build(e,r,i)}generate(e,r,i,o,s){let a;switch(this.scope){case fi.VIEW:e.isShader("vertex")?a="transformedNormal":a="geometryNormal";break;case fi.LOCAL:e.isShader("vertex")?a="objectNormal":(e.requires.normal=!0,a="vObjectNormal");break;case fi.WORLD:e.isShader("vertex")?a="inverseTransformDirection( transformedNormal, viewMatrix ).xyz":(e.requires.worldNormal=!0,a="vWNormal");break}return e.format(a,this.getType(e),r)}copy(e){return super.copy(e),this.scope=e.scope,this}toJSON(e){let r=this.getJSONNode(e);return r||(r=this.createJSONNode(e),r.scope=this.scope),r.nodeType=this.nodeType,r}fromJSON(e,r){return super.fromJSON(e,r),e.scope&&(this.scope=e.scope),this}},lt=fi;lt.LOCAL="local",lt.WORLD="world",lt.VIEW="view",lt.NORMAL="normal";ot.addKeyword("viewNormal",function(){return new lt(lt.VIEW)});ot.addKeyword("localNormal",function(){return new lt(lt.NORMAL)});ot.addKeyword("worldNormal",function(){return new lt(lt.WORLD)});var mr=class extends fe{constructor(e){super("v3");this.nodeType="Position";this.scope=e!=null?e:mr.LOCAL}getType(){switch(this.scope){case mr.PROJECTION:return"v4"}return this.type}getShader(){switch(this.scope){case mr.LOCAL:case mr.WORLD:return!1}return!0}generate(e,r,i,o,s){let a;switch(this.scope){case mr.LOCAL:e.isShader("vertex")?a="transformed":(e.requires.position=!0,a="vPosition");break;case mr.WORLD:if(e.isShader("vertex"))return"( modelMatrix * vec4( transformed, 1.0 ) ).xyz";e.requires.worldPosition=!0,a="vWPosition";break;case mr.VIEW:a=e.isShader("vertex")?"-mvPosition.xyz":"vViewPosition";break;case mr.PROJECTION:a=e.isShader("vertex")?"( projectionMatrix * modelViewMatrix * vec4( position, 1.0 ) )":"vec4( 0.0 )";break}return e.format(a,this.getType(),r)}copy(e){return super.copy(e),this.scope=e.scope,this}toJSON(e){let r=this.getJSONNode(e);return r||(r=this.createJSONNode(e),r.scope=this.scope),r.nodeType=this.nodeType,r}fromJSON(e,r){return super.fromJSON(e,r),e.scope&&(this.scope=e.scope),this}},ut=mr;ut.LOCAL="local",ut.WORLD="world",ut.VIEW="view",ut.PROJECTION="projection";ot.addKeyword("position",function(){return new ut});ot.addKeyword("worldPosition",function(){return new ut(ut.WORLD)});ot.addKeyword("viewPosition",function(){return new ut(ut.VIEW)});var er=class extends fe{constructor(e){super("v3");this.nodeType="Reflect";this.scope=e!=null?e:er.CUBE}getUnique(e){return!e.context.viewNormal}getType(){switch(this.scope){case er.SPHERE:return"v2"}return this.type}generate(e,r){let i=this.getUnique(e);if(e.isShader("fragment")){let o;switch(this.scope){case er.VECTOR:{let s=new lt(lt.VIEW),a=e.context.roughness,l=s.build(e,"v3"),c=new ut(ut.VIEW).build(e,"v3"),p=a?a.build(e,"f"):void 0,h=`reflect( -normalize( ${c} ), ${l} )`;p&&(h=`normalize( mix( ${h}, ${l}, ${p} * ${p} ) )`);let d=`inverseTransformDirection( ${h}, viewMatrix )`;i?(e.addNodeCode(`vec3 reflectVec = ${d};`),o="reflectVec"):o=d;break}case er.CUBE:{let s=new er(er.VECTOR).build(e,"v3"),a="vec3( -"+s+".x, "+s+".yz )";i?(e.addNodeCode(`vec3 reflectCubeVec = ${a};`),o="reflectCubeVec"):o=a;break}case er.SPHERE:{let s=new er(er.VECTOR).build(e,"v3"),a="normalize( ( viewMatrix * vec4( "+s+", 0.0 ) ).xyz + vec3( 0.0, 0.0, 1.0 ) ).xy * 0.5 + 0.5";i?(e.addNodeCode(`vec2 reflectSphereVec = ${a};`),o="reflectSphereVec"):o=a;break}}return e.format(o,this.getType(),r)}else return console.warn("ReflectNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.type,r)}copy(e){return super.copy(e),this.scope=e.scope,this}toJSON(e){let r=this.getJSONNode(e);return r||(r=this.createJSONNode(e),r.scope=this.scope),r.nodeType=this.nodeType,r}fromJSON(e,r){return super.fromJSON(e,r),e.scope&&(this.scope=e.scope),this}},fr=er;fr.CUBE="cube",fr.SPHERE="sphere",fr.VECTOR="vector";var Xs=class extends fe{constructor(e=new Nt,r,i){super("v4");this.nodeType="TextureCube";this.value=e,this.radianceNode=new co(this.value,r!=null?r:new fr(fr.VECTOR),i),this.irradianceNode=new co(this.value,new lt(lt.WORLD),new te(1).setReadonly(!0))}generate(e,r){return e.isShader("fragment")?(e.require("irradiance"),e.context.bias&&e.context.bias.setTexture(this.value),(e.slot==="irradiance"?this.irradianceNode:this.radianceNode).build(e,r)):(console.warn("TextureCubeNode is not compatible with "+e.shader+" shader."),e.format("vec4( 0.0 )",this.getType(e),r))}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 jv}from"three";var Zs=class extends Fe{constructor(e=new jv,r,i){super("v4",{shared:!0});this.nodeType="CubeTexture";this.value=e,this.uv=r!=null?r:new fr,this.bias=i}getTexture(e,r){return super.generate(e,r,this.value.uuid,"tc")}generate(e,r){var p,h;if(r==="samplerCube")return this.getTexture(e,r);let i=this.getTexture(e,r),o=(p=this.uv)==null?void 0:p.build(e,"v3"),s=this.bias?this.bias.build(e,"f"):void 0;s===void 0&&e.context.bias&&(s=e.context.bias.setTexture(this).build(e,"f"));let a;s?a="texCubeBias( "+i+", "+o+", "+s+" )":a="texCube( "+i+", "+o+" )";let l={include:e.isShader("vertex"),ignoreCache:!0},c=this.getType(e);return e.addContext(l),this.colorSpace=(h=this.colorSpace)!=null?h:new Tt(new _e("",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,r)}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 su=["x","y","z","w"],Wv=["float","vec2","vec3","vec4"],$v={float:"f",vec2:"v2",vec3:"v3",vec4:"v4",mat4:"v4",int:"i",bool:"b","float[]":"f[]","vec4[]":"v4[]"},Jv={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[]"},Qs=class{constructor(){this.includes={consts:{},functions:{},structs:{}};this.cache="";this.slot="";this.shader="";this.context={};this.getIncludesCode=function(){function t(e,r){return e.deps.length-r.deps.length}return function(r,i){let o=this.getIncludes(r,i);if(!o)return"";let s="";o=o.sort(t);for(let a=0;a<o.length;a++)o[a].src&&(s+=o[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
|
|
@@ -126,8 +126,8 @@ var sm=Object.create;var Dn=Object.defineProperty,am=Object.defineProperties,lm=
|
|
|
126
126
|
`}addVaryCode(t){this.addVertexParsCode(t),this.addFragmentParsCode(t)}isCache(t){return this.caches.indexOf(t)!==-1}isSlot(t){return this.slots.indexOf(t)!==-1}define(t,e){this.defines[t]=e===void 0?1:e}require(t){this.requires[t]=!0}isDefined(t){return this.defines[t]!==void 0}getVar(t,e,r,i="varying",o="V",s=""){let a=this.getVars(i),l=a[t];if(!l){let c=a.length;l={name:r||"node"+o+c+(s?"_"+s:""),type:e},a.push(l),a[t]=l}return l}getTempVar(t,e,r,i){return this.getVar(t,e,r,this.shader,"T",i)}getAttribute(t,e){if(!this.attributes[t]){let r=this.getVar(t,e);this.addVertexParsCode("attribute "+e+" "+t+";"),this.addVertexFinalCode(r.name+" = "+t+";"),this.attributes[t]={varying:r,name:t,type:e}}return this.attributes[t]}getCode(t){return[this.prefixCode,this.parsCode[t],this.getVarListCode(this.getVars("varying"),"varying"),this.getVarListCode(this.inputs.uniforms[t],"uniform"),this.getVarListCode(this.inputs.arrayUniforms[t],"uniform"),this.getIncludesCode("consts",t),this.getIncludesCode("structs",t),this.getIncludesCode("functions",t),"void main() {",this.getVarListCode(this.getVars(t)),this.code[t],this.resultCode[t],this.finalCode[t],"}"].join(`
|
|
127
127
|
`)}getVarListCode(t,e){e=e!=null?e:"";let r="";for(let i=0,o=t.length;i<o;++i){let s=t[i],a=s.type,l=s.name,c=s.size,p=this.getFormatByType(a);if(p===void 0)throw new Error("Node pars "+p+" not found.");p.includes("[]")?r+=e+" "+p.substring(0,p.length-2)+" "+l+`[${c}];
|
|
128
128
|
`:r+=e+" "+p+" "+l+`;
|
|
129
|
-
`}return r}getVars(t){return this.inputs.vars[t!=null?t:this.shader]}getNodeData(t){let e=t instanceof de?t.uuid:t;return this.nodeData[e]=this.nodeData[e]||{}}createUniform(t,e,r,i,o,s){if(e.includes("[]")){let a=this.inputs.arrayUniforms,l=a.list.length,c=new nn({type:e,size:r.size,name:i||"nodeUA"+l+(s?"_"+s:""),node:r,needsUpdate:o});return a.list.push(c),a[t].push(c),a[t][c.name]=c,this.uniforms[c.name]=c,c}else{let a=this.inputs.uniforms,l=a.list.length,c=new nn({type:e,name:i||"nodeU"+l+(s?"_"+s:""),node:r,needsUpdate:o});return a.list.push(c),a[t].push(c),a[t][c.name]=c,this.uniforms[c.name]=c,c}}createVertexUniform(t,e,r,i,o){return this.createUniform("vertex",t,e,r,i,o)}createFragmentUniform(t,e,r,i,o){return this.createUniform("fragment",t,e,r,i,o)}include(t,e,r){var s;let i;if(t=typeof t=="string"?ot.get(t):t,this.context.include===!1)return t.name;t instanceof re?i=this.includes.functions:t instanceof Te?i=this.includes.consts:t instanceof no&&(i=this.includes.structs);let o=i[this.shader]=i[this.shader]||[];if(t){let a=o[t.name];if(a||(a=o[t.name]={node:t,deps:[]},o.push(a),a.src=t.build(this,"source")),t instanceof re&&e&&o[e.name]&&o[e.name].deps.indexOf(t)===-1&&(o[e.name].deps.push(t),(s=t.includes)!=null&&s.length)){let l=0;do this.include(t.includes[l++],e);while(l<t.includes.length)}return r&&(a.src=r),t.name}else throw new Error("Include not found.")}colorToVectorProperties(t){return t.replace("r","x").replace("g","y").replace("b","z").replace("a","w")}colorToVector(t){return t.replace(/c/g,"v3")}getIncludes(t,e){return this.includes[t][e||this.shader]}getConstructorFromLength(t){return
|
|
130
|
-
`;return e.isShader("vertex")?i+="gl_Position = "+r.result+";":i+="gl_FragColor = "+r.result+";",i}copy(e){return super.copy(e),this.value.copy(e.value),this}};var Be=class extends Fe{constructor(e=0,r,i,o){super("c");this.nodeType="Color";this.value=e instanceof Pt?e:new Pt(e||0,r,i,o)}setRGBA(e){this.value.setRGBA(e.r,e.g,e.b,e.a)}generate(e,r,i,o,s,a){i=e.getUUID(i!=null?i:this.getUUID()),o=o!=null?o:this.getType(e);let l=e.getNodeData(i),c=this.getReadonly()&&this.generateReadonly!==void 0;if(this.alpha){let p=this.alpha.build(e,"f");e.addFragmentNodeCode(`accumAlpha += ( 1.0 - accumAlpha ) * ${p};`)}return c?this.generateReadonly(e,r,i,o,s,a):e.isShader("vertex")?(l.vertex||(l.vertex=e.createVertexUniform(o,this,s,a,this.getLabel())),e.format(l.vertex.name,o,r)):(l.fragment||(l.fragment=e.createFragmentUniform(o,this,s,a,this.getLabel())),e.format(l.fragment.name,o,r))}generateReadonly(e,r,i,o,s,a){return e.format("vec3("+this.value.r+", "+this.value.g+", "+this.value.b+")",o,r)}};import{MathUtils as Pr,Vector2 as Yr,Vector3 as Xr,Vector4 as ea}from"three";import{Texture as
|
|
129
|
+
`}return r}getVars(t){return this.inputs.vars[t!=null?t:this.shader]}getNodeData(t){let e=t instanceof de?t.uuid:t;return this.nodeData[e]=this.nodeData[e]||{}}createUniform(t,e,r,i,o,s){if(e.includes("[]")){let a=this.inputs.arrayUniforms,l=a.list.length,c=new nn({type:e,size:r.size,name:i||"nodeUA"+l+(s?"_"+s:""),node:r,needsUpdate:o});return a.list.push(c),a[t].push(c),a[t][c.name]=c,this.uniforms[c.name]=c,c}else{let a=this.inputs.uniforms,l=a.list.length,c=new nn({type:e,name:i||"nodeU"+l+(s?"_"+s:""),node:r,needsUpdate:o});return a.list.push(c),a[t].push(c),a[t][c.name]=c,this.uniforms[c.name]=c,c}}createVertexUniform(t,e,r,i,o){return this.createUniform("vertex",t,e,r,i,o)}createFragmentUniform(t,e,r,i,o){return this.createUniform("fragment",t,e,r,i,o)}include(t,e,r){var s;let i;if(t=typeof t=="string"?ot.get(t):t,this.context.include===!1)return t.name;t instanceof re?i=this.includes.functions:t instanceof Te?i=this.includes.consts:t instanceof no&&(i=this.includes.structs);let o=i[this.shader]=i[this.shader]||[];if(t){let a=o[t.name];if(a||(a=o[t.name]={node:t,deps:[]},o.push(a),a.src=t.build(this,"source")),t instanceof re&&e&&o[e.name]&&o[e.name].deps.indexOf(t)===-1&&(o[e.name].deps.push(t),(s=t.includes)!=null&&s.length)){let l=0;do this.include(t.includes[l++],e);while(l<t.includes.length)}return r&&(a.src=r),t.name}else throw new Error("Include not found.")}colorToVectorProperties(t){return t.replace("r","x").replace("g","y").replace("b","z").replace("a","w")}colorToVector(t){return t.replace(/c/g,"v3")}getIncludes(t,e){return this.includes[t][e||this.shader]}getConstructorFromLength(t){return Wv[t-1]}isTypeMatrix(t){return/^m/.test(t)}getTypeLength(t){return t==="f"?1:parseInt(this.colorToVector(t).substr(1))}getTypeFromLength(t){return t===1?"f":"v"+t}findNode(...t){for(let e=0;e<arguments.length;e++){let r=t[e];if(r!=null&&r.isNode)return r}}resolve(...t){for(let e=0;e<arguments.length;e++){let r=t[e];if(r!==void 0){if(r.isNode)return r;if(r.isTexture)switch(r.mapping){case Uv:case kv:return new Zs(r);case Hv:return new Xs(new Nt(r));default:return new Nt(r)}else{if(r.isVector2)return new bt(r);if(r.isVector3)return new vt(r);if(r.isVector4)return new Ir(r)}}}}format(t,e,r){switch(this.colorToVector(r+" <- "+e)){case"f <- v2":return t+".x";case"f <- v3":return t+".x";case"f <- v4":return t+".x";case"f <- i":case"f <- b":return"float( "+t+" )";case"v2 <- f":return"vec2( "+t+" )";case"v2 <- v3":return t+".xy";case"v2 <- v4":return t+".xy";case"v2 <- i":case"v2 <- b":return"vec2( float( "+t+" ) )";case"v3 <- f":return"vec3( "+t+" )";case"v3 <- v2":return"vec3( "+t+", 0.0 )";case"v3 <- v4":return t+".xyz";case"v3 <- i":case"v3 <- b":return"vec2( float( "+t+" ) )";case"v4 <- f":return"vec4( "+t+" )";case"v4 <- v2":return"vec4( "+t+", 0.0, 1.0 )";case"v4 <- v3":return"vec4( "+t+", 1.0 )";case"v4 <- i":case"v4 <- b":return"vec4( float( "+t+" ) )";case"i <- f":case"i <- b":return"int( "+t+" )";case"i <- v2":return"int( "+t+".x )";case"i <- v3":return"int( "+t+".x )";case"i <- v4":return"int( "+t+".x )";case"b <- f":return"( "+t+" != 0.0 )";case"b <- v2":return"( "+t+" != vec2( 0.0 ) )";case"b <- v3":return"( "+t+" != vec3( 0.0 ) )";case"b <- v4":return"( "+t+" != vec4( 0.0 ) )";case"b <- i":return"( "+t+" != 0 )"}return t}getTypeByFormat(t){return $v[t]||t}getFormatByType(t){return Jv[t]||t}getUUID(t,e){return e=e!==void 0?e:!0,e&&this.cache&&(t=this.cache+"-"+t),t}getElementByIndex(t){return su[t]}getIndexByElement(t){return su.indexOf(t)}isShader(t){return this.shader===t}setShader(t){return this.shader=t,this}mergeDefines(t){for(let e in t)this.defines[e]=t[e];return this.defines}mergeUniform(t){for(let e in t)this.uniforms[e]=t[e];return this.uniforms}getTextureEncodingFromMap(t){let e;return t?t.isTexture&&(e=t.encoding):e=nu,e===nu&&this.context.gamma&&(e=qv),e}};var an=class extends de{constructor(e=new de){super("v4");this.nodeType="Raw";this.value=e}generate(e){let r=this.value.analyzeAndFlow(e,this.type),i=r.code+`
|
|
130
|
+
`;return e.isShader("vertex")?i+="gl_Position = "+r.result+";":i+="gl_FragColor = "+r.result+";",i}copy(e){return super.copy(e),this.value.copy(e.value),this}};var Be=class extends Fe{constructor(e=0,r,i,o){super("c");this.nodeType="Color";this.value=e instanceof Pt?e:new Pt(e||0,r,i,o)}setRGBA(e){this.value.setRGBA(e.r,e.g,e.b,e.a)}generate(e,r,i,o,s,a){i=e.getUUID(i!=null?i:this.getUUID()),o=o!=null?o:this.getType(e);let l=e.getNodeData(i),c=this.getReadonly()&&this.generateReadonly!==void 0;if(this.alpha){let p=this.alpha.build(e,"f");e.addFragmentNodeCode(`accumAlpha += ( 1.0 - accumAlpha ) * ${p};`)}return c?this.generateReadonly(e,r,i,o,s,a):e.isShader("vertex")?(l.vertex||(l.vertex=e.createVertexUniform(o,this,s,a,this.getLabel())),e.format(l.vertex.name,o,r)):(l.fragment||(l.fragment=e.createFragmentUniform(o,this,s,a,this.getLabel())),e.format(l.fragment.name,o,r))}generateReadonly(e,r,i,o,s,a){return e.format("vec3("+this.value.r+", "+this.value.g+", "+this.value.b+")",o,r)}};import{MathUtils as Pr,Vector2 as Yr,Vector3 as Xr,Vector4 as ea}from"three";import{Texture as Kv}from"three";var ve=class extends Fe{constructor(e){super("i");this.nodeType="Int";this.value=Math.floor(e!=null?e:0)}generateReadonly(e,r,i,o,s,a){return e.format(this.value.toString(),o,r)}copy(e){return super.copy(e),this.value=e.value,this}};var qe=class{constructor(t,e,r,i){this.next=void 0;this.uniforms={};this.textures={};this.defines={};if(this.id=t,this.uuid=e,r){this.type=r.type;for(let o in r)o!=="type"&&o!=="calpha"&&(this.uniforms[`f${this.id}_${o}`]=r[o]);for(let o in i)this.defines[o]=i[o]}}copy(t){this.id=t.id,this.type=t.type,this.defines=P({},t.defines);for(let e in t.uniforms)this.getName(e)==="transmissionSamplerMap"||this.getName(e)==="transmissionDepthMap"||(this.uniforms[e]?this.uniforms[e].copy(t.uniforms[e]):this.uniforms[e]=t.uniforms[e].clone());return this}clone(){return new qe(this.id).copy(this)}fromJSON(t,e){this.id=t.id,this.defines=P({},t.defines);for(let r in t.uniforms)this.uniforms[r]=e.getNode(t.uniforms[r]);if(t.type==="texture"){if(!(`f${this.id}_textureSize`in this.uniforms)){let r=this.uniforms[`f${this.id}_texture`].value.image;this.uniforms[`f${t.id}_textureSize`]=new vt(r.width,r.height)}`f${this.id}_size`in this.uniforms||(this.uniforms[`f${t.id}_size`]=new bt(200,200)),`f${t.id}_axis`in this.uniforms||(this.uniforms[`f${t.id}_axis`]=new ve(0)),`f${t.id}_projection`in this.uniforms||(this.uniforms[`f${t.id}_projection`]=new ve(0))}else t.type==="noise"?(`f${t.id}_noiseType`in this.uniforms||(this.uniforms[`f${t.id}_noiseType`]=new ve(0)),`f${t.id}_size`in this.uniforms||(this.uniforms[`f${t.id}_size`]=new vt(-1,-1,-1))):t.type==="depth"&&(`f${t.id}_isWorldSpace`in this.uniforms||(this.uniforms[`f${t.id}_isWorldSpace`]=new te(1)));return this}toJSON(t){let e={};for(let i in this.uniforms)e[i]=this.uniforms[i].toJSON(t).uuid;return{id:this.id,type:this.type,defines:JSON.parse(JSON.stringify(this.defines)),uniforms:e,next:this.next==null?void 0:this.next.toJSON(t)}}copyUniforms(t){for(let e in this.uniforms){let r=this.getName(e);r!==void 0&&t.uniforms[`f${t.id}_${r}`]&&r!=="transmissionDepthMap"&&r!=="transmissionSamplerMap"&&this.uniforms[e].copy(t.uniforms[`f${t.id}_${r}`])}return this}hasValueByKey(t){return this.uniforms[t]!==void 0}hasValue(t){return this.hasValueByKey(`f${this.id}_${t}`)}setValue(t,e){let r=`f${this.id}_${t}`;this.hasValueByKey(r)&&e!==void 0&&(this.uniforms[r].value=e)}getValue(t){let e=`f${this.id}_${t}`;if(this.hasValueByKey(e))return this.uniforms[e].value}getValues(){let t={type:this.type};for(let e in this.uniforms){let r=this.getName(e);if(r===void 0)continue;let o=this.uniforms[`f${this.id}_${r}`].value;o!==void 0&&(Array.isArray(o)?t[r]=o.map(s=>s.clone?s.clone():s):t[r]=o.clone?o.clone():o)}return t}getName(t){let r=/f\d+_(.*)/.exec(t);if(r&&r.length>1)return r[1];console.log(`Layer.getName: error ${t}`)}getNames(){let t=[];for(let e in this.uniforms){let r=this.getName(e);r&&t.push(r)}return t}isEqual(t){for(let e in t.uniforms){let r=t.getName(e);if(!r)return!1;let i=this.getValue(r),o=t.uniforms[e].value;if(o.value instanceof Kv){if(i.image!==o.image)return!1}else if(Array.isArray(o)){let s=i;for(let a=0,l=s.length;a<l;++a)if(s[a]!==o[a])return!1}else{let s=i;if(s.equals){if(!s.equals(o))return!1}else if(i!==o)return!1}}return!0}dispose(){}};function au(n){let t=n instanceof qe?n.type:n;return t==="texture"||t==="displace_map"||t==="matcap"}var ln=class extends Fe{constructor(e){super("b");this.nodeType="Bool";this.value=e!=null?e:!1}generateReadonly(e,r,i,o){return e.format(this.value?"true":"false",o,r)}copy(e){return super.copy(e),this.value=e.value,this}};import{Vector4 as lu}from"three";var yi=class extends Fe{constructor(e=1,r){super("v4[]");this.nodeType="Vector4Array";this.size=e,this.value=Array.isArray(r)?r:r instanceof lu?new Array(e).fill(r):new Array(e).fill(new lu(0))}copy(e){return super.copy(e),this.value=e.value.map(r=>r.clone()),this}};var gi=class extends Fe{constructor(e=1,r){super("f[]");this.nodeType="FloatArray";this.size=e,this.value=Array.isArray(r)?r:typeof r=="number"?new Array(e).fill(r):new Array(e).fill(0)}copy(e){return super.copy(e),this.size=e.size,this.value=[...e.value],this}};import{Matrix3 as Yv}from"three";var po=class extends Fe{constructor(e){super("m3");this.nodeType="Matrix3";this.value=e!=null?e:new Yv}generateReadonly(e,r,i,o,s,a){return e.format("mat3("+this.value.elements.join(", ")+")",o,r)}copy(e){return super.copy(e),this.elements=e.elements,this}get elements(){return this.value.elements}set elements(e){this.value.fromArray(e)}};var pn=class extends fe{constructor(e=new Nt,r,i,o,s,a,l,c){super("v3");this.nodeType="CustomTexture";this.firstTime=!0,this.texture=e,this.textureSize=r,this.crop=i,this.projection=o,this.axis=s,this.size=a,this.mat=new po(this.texture.value.matrix),this.alpha=l,this.mode=c,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,r){e.require("position"),e.require("uv"),e.requires.uv=[!0],e.extensions.shaderTextureLOD=!0,e.extensions.derivatives=!0;let i;switch(this.projection.value){case 3:i=e.include(pn.Nodes.cylindrical);break;case 2:i=e.include(pn.Nodes.spherical);break;case 1:let s=new re(`
|
|
131
131
|
vec3 g${this.uuid.toString().replace(/-/g,"")}_planarTexture(sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec2 size, float alpha, int mode, out float calpha) {
|
|
132
132
|
|
|
133
133
|
vec2 uvs = ( mat * vec3( (g${this.uuid.toString().replace(/-/g,"")}_vCustomUv * 2. - 1.) / (size * .5), 1. ) / 2. + 0.5 ).xy;
|
|
@@ -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 St=class{constructor(t){this.id=2,this.layerCount=2,this.uuid=Pr.generateUUID(),this.needsUpdate=!1,this._material=t,this._layerNodes=[];let e=this._createLayer({id:0,type:"color"});this._material.color=e.color,this._material.alpha===void 0&&(this._material.alpha=new te(1));let r=new te(1),i=new ve(0);"shadingAlpha"in this._material&&"shadingBlend"in this._material&&(this._material.shadingAlpha=r,this._material.shadingBlend=i),this._layerNodes.push({id:0,type:"color",color:e.color,alpha:e.alpha,mode:e.mode}),this._layerNodes.push({id:1,type:"light",alpha:r,mode:i}),this.head=e.layer,this.head.next=new qe(1,void 0,{type:"light",alpha:r,mode:i}),this.attachLightNodes(this.getLightLayer())}get material(){return this._material}set material(t){var o;this._material=t;let e,r,i=this.head;for(;i!==void 0;){if(i.type==="light"){e=i.uniforms[`f${i.id}_alpha`],r=i.uniforms[`f${i.id}_mode`];break}i=i.next}"shadingAlpha"in this._material&&"shadingBlend"in this._material&&(this._material.shadingAlpha=e,this._material.shadingBlend=r),this.attachLightNodes((o=t.userData.layers)==null?void 0:o.getLightLayer()),this.blendColors(),this.blendAfterColors(),this.blendPositions()}getLayersOfType(t){let e=[],r=this.head;for(;r;)r.type===t&&e.push(r),r=r.next;return e}addLayer(t){var i;if(t.id=(i=t.id)!=null?i:++this.id,this.layerCount++,t.type==="light"){let o=this.createLightLayer(t);return this.uuid=Pr.generateUUID(),this.blendColors(),this.blendAfterColors(),this.blendPositions(),o}let e=this._createLayer(t),r=e.layer;if(this.head===void 0)this.head=r;else{let o=this.head;for(;o.next!=null;)o=o.next;o.next=r}return e.color&&this._layerNodes.push({id:r.id,type:"color",color:e.color,alpha:e.alpha,mode:e.mode}),e.position&&this._layerNodes.push({id:r.id,type:"position",position:e.position}),this.uuid=Pr.generateUUID(),this.blendColors(),this.blendAfterColors(),this.blendPositions(),r}addLayerBeforeAt(t,e){var a;let r=this.head;t.id=(a=t.id)!=null?a:++this.id,this.layerCount++;let i=this._createLayer(t),o=i.layer;o.next=e;let s=0;if(r===e)this.head=o,i.color&&this._layerNodes.splice(0,0,{id:o.id,type:"color",color:i.color,alpha:i.alpha,mode:i.mode}),i.position&&this._layerNodes.splice(0,0,{id:o.id,type:"position",position:i.position});else{for(s=1;(r==null?void 0:r.next)!==e;)r=r==null?void 0:r.next,s++;r.next=o,i.color&&this._layerNodes.splice(s,0,{id:o.id,type:"color",color:i.color,alpha:i.alpha,mode:i.mode}),i.position&&this._layerNodes.splice(s,0,{id:o.id,type:"position",position:i.position})}return this.uuid=Pr.generateUUID(),this.blendColors(),this.blendAfterColors(),this.blendPositions(),o}addLayerAt(t,e){var o;e.id=(o=e.id)!=null?o:++this.id,this.layerCount++;let r=this._createLayer(e),i=r.layer;if(r.color&&this._layerNodes.splice(t,0,{id:i.id,type:"color",color:r.color,alpha:r.alpha,mode:r.mode}),r.position&&this._layerNodes.splice(t,0,{id:i.id,type:"position",position:r.position}),t==0)i.next=this.head,this.head=i;else{let s=this.head,a=this.head.next;for(let l=0;l<t-1;l++)s=a,a=a.next;i.next=a,s.next=i}return this.uuid=Pr.generateUUID(),this.blendColors(),this.blendAfterColors(),this.blendPositions(),i}removeLayer(t){let e=this.head,r,i=0;if((e==null?void 0:e.id)==t)this.head=e.next;else for(i=1,r=e,e=e==null?void 0:e.next;e!=null;){if(e.id==t){r.next=e.next;break}i++,r=e,e=e.next}return this.cleanupChangedLayer(e),this.blendColors(),this.blendAfterColors(),this.blendPositions(),this.uuid=Pr.generateUUID(),this.layerCount--,i}changeLayer(t,e){let r,i=this.head,o;if((i==null?void 0:i.id)==t){let s=this._createLayer(P({id:t,uuid:i.uuid},e));o=s.layer,o.next=i.next,this.head=o,s.color&&(this._layerNodes[0]={id:o.id,type:"color",color:s.color,alpha:s.alpha,mode:s.mode}),s.position&&(this._layerNodes[0]={id:o.id,type:"position",position:s.position}),o.uniforms[`f${t}_mode`].value=i.uniforms[`f${t}_mode`].value,o.uniforms[`f${t}_alpha`].value=i.uniforms[`f${t}_alpha`].value}else{r=i,i=i.next;let s=1;for(;i!=null;){if(i.id==t){let a=this._createLayer(P({id:t,uuid:i.uuid},e));o=a.layer,r.next=o,o.next=i.next,a.color&&(this._layerNodes[s]={id:t,type:"color",color:a.color,alpha:a.alpha,mode:a.mode}),a.position&&(this._layerNodes[s]={id:t,type:"position",position:a.position}),o.uniforms[`f${t}_mode`].value=i.uniforms[`f${t}_mode`].value,o.uniforms[`f${t}_alpha`].value=i.uniforms[`f${t}_alpha`].value;break}r=i,i=i.next,s++}}return this.uuid=Pr.generateUUID(),this.blendColors(),this.blendAfterColors(),this.blendPositions(),o}getLayer(t){let e=this.head;for(;e!=null&&e.id!=t;)e=e.next;return e}getLayerByUuid(t){let e=this.head;for(;e!==void 0;){if(e.uuid===t)return e;e=e.next}}getLayers(){let t=[],e=this.head;for(;e!=null;)t.push(e),e=e.next;return t}getLayerPosition(t){let e=this.head,r=0;for(;e!==void 0&&e.id!=t;)r++,e=e.next;return r}getDefines(){}getBeforeProgram(){}getLightingProgram(){}getAfterProgram(){}getVarPrograms(){}getUniforms(){}moveLayer(t,e){let r,i=this.head,o;if(t==0)r=this.head,this.head=r.next;else{for(let a=0;a<t;a++)o=i,i=i.next;o.next=i.next,r=i}if(i=this.head,o=void 0,e==0)r.next=this.head,this.head=r;else{for(let a=0;a<e-1;a++)i=i.next;r.next=i==null?void 0:i.next,i.next=r}let s=this._layerNodes.splice(t,1)[0];this._layerNodes.splice(e,0,s),this.uuid=Pr.generateUUID(),this.blendColors(),this.blendAfterColors()}updateLayerUniform(){this.uuid=Pr.generateUUID(),this.blendColors(),this.blendAfterColors()}copy(t){this.needsUpdate=!1,this.layerCount=t.layerCount,this._layerNodes=[],this.layerCount=0,this.head=void 0,this.rebuildLayerNodes(this.head,t.head);let e=t.head,r=this.head;for(;e.next!=null;)this.rebuildLayerNodes(r,e.next),r=r.next,e=e.next;return this.id=t.id,this.uuid=t.uuid,this.blendColors(),this.blendAfterColors(),this.blendPositions(),this}createLightLayer(t){let e=new te(t.alpha),r=new ve(t.mode);this._material.shadingAlpha=e,this._material.shadingBlend=r,this._layerNodes.push({id:t.id,type:"light",alpha:e,mode:r});let i=new qe(t.id,void 0,{type:"light",alpha:e,mode:r});if(this.head===void 0)this.head=i;else{let o=this.head;for(;o.next!=null;)o=o.next;o.next=i}return this.attachLightNodes(this.getLightLayer()),i}rebuildLayerNodes(t,e,r=!1){if(e.type==="light"){let i=r?e.uniforms[`f${e.id}_alpha`]:new te(e.uniforms[`f${e.id}_alpha`].value),o=r?e.uniforms[`f${e.id}_mode`]:new ve(e.uniforms[`f${e.id}_mode`].value);this._material.shadingAlpha=i,this._material.shadingBlend=o,this._layerNodes.push({id:e.id,type:"light",alpha:i,mode:o}),this.head===void 0?this.head=new qe(e.id,e.uuid,{type:"light",alpha:i,mode:o}):t&&(t.next=new qe(e.id,e.uuid,{type:"light",alpha:i,mode:o})),this.attachLightNodes(e)}else{let i={type:e.type,id:e.id};for(let o in e.uniforms){let s=e.getName(o);if(!s)continue;let a=`f${e.id}_${s}`;if(Array.isArray(e.uniforms[a].value))i[s]=e.uniforms[a].value.map(l=>l.clone&&!r?l.clone():l);else{let l=e.uniforms[a].value;if(s==="transmissionDepthMap"){i[s]=l;continue}l!=null&&(i[s]=l.clone&&!r&&!l.isRenderTargetTexture?l.clone():l)}}this.addLayer(i)}}attachLightNodes(t){var i,o,s,a,l,c,p,h,d,m,f;let e={},r=this.getLightLayer();switch(this._material.userData.category){case"Lambert":e.emissive=new Be((o=(i=t==null?void 0:t.getValue("emissive"))==null?void 0:i.clone())!=null?o:0);break;case"Phong":e.shininess=new te((s=t==null?void 0:t.getValue("shininess"))!=null?s:30),e.specular=new Be((l=(a=t==null?void 0:t.getValue("specular"))==null?void 0:a.clone())!=null?l:1118481);break;case"Toon":e.shininess=new te((c=t==null?void 0:t.getValue("shininess"))!=null?c:30),e.specular=new Be((h=(p=t==null?void 0:t.getValue("specular"))==null?void 0:p.clone())!=null?h:1118481);break;case"Physical":e.roughness=new te((d=t==null?void 0:t.getValue("roughness"))!=null?d:.3),e.metalness=new te((m=t==null?void 0:t.getValue("metalness"))!=null?m:0),e.reflectivity=new te((f=t==null?void 0:t.getValue("reflectivity"))!=null?f:.5);break;default:break}Object.keys(e).forEach(T=>{this._material[T]=e[T],r.uniforms[`f${r.id}_${T}`]=e[T]})}clone(t){return new St(t).copy(this)}toJSON(t){return{id:this.id,uuid:this.uuid,head:this.head.toJSON(t)}}fromJSON(t,e,r){let i=new qe(t.head.id,void 0,{type:t.head.type}).fromJSON(t.head,e),o=t.head.next,s=i;for(;o!=null;)s.next=new qe(o.id,void 0,{type:o.type}).fromJSON(o,e),o=o.next,s=s.next;this._layerNodes=[],this.head=void 0,this.rebuildLayerNodes(this.head,i,!0);let a=i;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=t.id,this.uuid=t.uuid,this.blendColors(),this.blendAfterColors(),this.blendPositions(),this}getLightLayer(){var e;let t=this.head;for(;t!==void 0&&t.type!=="light";)t=(e=t.next)!=null?e:t;return t}dispose(){let t=this.head;for(this._layerNodes=[],this.layerCount=0;t!==void 0;)t.hasOwnProperty("dispose")===!0&&t.dispose(),t=t.next;this.head=void 0}_createLayer(t){var r,i,o,s,a,l,c,p,h,d,m,f,T,w,y,L,A,I,b,V,x,u,M,g,N,v,C,$,H,ie,pe,ce,be,F,G,_,z,D,R,K,Z,U,j,B,k,ne,q,J,Y,X,Q,se,oe,he,Ee,xe,We,Ce,ct,wt,br,ft,vr,ii,oi,Ue,yt,_t,Tn,Nn,Mn,On,In,Pn,jt,Io,pt,Si,An;let e=t.type;switch(e){case"color":{let ge=new Be((r=t.color)!=null?r:5855577),Le=new te((i=t.alpha)!=null?i:1),Se=new _e("alpha / clamp(alpha + accumAlpha, 0.00001, 1.0 )","f");Se.keywords.alpha=Le;let we=new ve((o=t.mode)!=null?o:0);return ge.alpha=Le,{layer:new qe(t.id,t.uuid,{type:e,color:ge,alpha:Le,calpha:Se,mode:we}),color:ge,alpha:Se,mode:we}}case"texture":{let ge=(s=t.texture)!=null?s:new ur,Le=ge.matrix;t.mat&&Le.copy(t.mat),ge.needsUpdate=!0;let Se=new te((a=t.crop)!=null?a:0),we=new ve((l=t.projection)!=null?l:0),Ne=new ve((c=t.axis)!=null?c:0),Ae=new bt(t.size?new Yr(t.size[0],t.size[1]):new Yr(100,100)),Ge=new te((p=t.alpha)!=null?p:1),ze=new ve((h=t.mode)!=null?h:0),De=new Nt(ge),ke=new vt((d=t.textureSize)!=null?d:new Xr(ge.image?ge.image.width:0,ge.image?ge.image.height:0)),tt=new cn(De,ke,Se,we,Ne,Ae,Ge,ze),Ut=new _e(tt.calpha,"f");return{layer:new qe(t.id,t.uuid,{type:e,texture:De,textureSize:ke,crop:Se,projection:we,axis:Ne,size:Ae,mat:tt.mat,alpha:Ge,calpha:Ut,mode:ze}),color:tt,alpha:Ut,mode:ze}}case"matcap":{let ge=(m=t.texture)!=null?m:new ur;ge.needsUpdate=!0;let Le=new te((f=t.alpha)!=null?f:1),Se=new Nt(ge),we=new ve((T=t.mode)!=null?T:0),Ne=new vn(Se,Le,we),Ae=new _e(Ne.calpha,"f");return{layer:new qe(t.id,t.uuid,{type:e,texture:Se,alpha:Le,calpha:Ae,mode:we}),color:Ne,alpha:Ae,mode:we}}case"fresnel":{let ge=new Be((w=t.color)!=null?w:16777215),Le=new te((y=t.bias)!=null?y:.1),Se=new te((L=t.scale)!=null?L:1),we=new te((A=t.intensity)!=null?A:2),Ne=new te((I=t.factor)!=null?I:1),Ae=new te((b=t.alpha)!=null?b:1),Ge=new ve((V=t.mode)!=null?V:0),ze=new hn(ge,Le,Se,we,Ne,Ae,Ge),De=new _e(ze.calpha,"f");return{layer:new qe(t.id,t.uuid,{type:e,color:ge,bias:Le,scale:Se,intensity:we,factor:Ne,alpha:Ae,calpha:De,mode:Ge}),color:ze,alpha:De,mode:Ge}}case"rainbow":{let ge=new te((x=t.filmThickness)!=null?x:30),Le=new te((u=t.movement)!=null?u:0),Se=new vt((M=t.wavelengths)!=null?M:new Xr(0,0,0)),we=new te((g=t.noiseStrength)!=null?g:0),Ne=new te((N=t.noiseScale)!=null?N:1),Ae=new vt((v=t.offset)!=null?v:new Xr(0,0,0)),Ge=new te((C=t.alpha)!=null?C:1),ze=new un(ge,Le,Se,we,Ne,Ae,Ge),De=new _e(ze.calpha,"f"),ke=new ve(($=t.mode)!=null?$:0);return{layer:new qe(t.id,t.uuid,{type:e,filmThickness:ge,movement:Le,wavelengths:Se,noiseStrength:we,noiseScale:Ne,offset:Ae,alpha:Ge,calpha:De,mode:ke}),color:ze,alpha:De,mode:ke}}case"transmission":{let ge=new te((H=t.thickness)!=null?H:10),Le=new te((ie=t.ior)!=null?ie:1.5),Se=new te((pe=t.roughness)!=null?pe:.5),we=new bt((ce=t.transmissionSamplerSize)!=null?ce:new Yr(2048,2048)),Ne=(be=t.transmissionSamplerMap)!=null?be:new ur,Ae=(F=t.transmissionDepthMap)!=null?F:new ur,Ge=new Nt(Ne),ze=new Nt(Ae),De=window.innerWidth,ke=window.innerHeight,tt=De>=ke?new bt(ke/De,1):new bt(1,De/ke),Ut=new te((G=t.alpha)!=null?G:1),Sr=new mn(ge,Le,Se,we,Ge,ze,tt,Ut),Br=new _e(Sr.calpha,"f"),Er=new ve((_=t.mode)!=null?_:0);return{layer:new qe(t.id,t.uuid,{type:e,thickness:ge,ior:Le,roughness:Se,transmissionSamplerSize:we,transmissionSamplerMap:Ge,transmissionDepthMap:ze,aspectRatio:tt,alpha:Ut,calpha:Br,mode:Er}),color:Sr,alpha:Br,mode:Er}}case"depth":{let ge=new ve((z=t.gradientType)!=null?z:0),Le=new ln((D=t.smooth)!=null?D:!1),Se=new te((R=t.near)!=null?R:50),we=new te((K=t.far)!=null?K:200),Ne=new te((Z=t.isVector)!=null?Z:1),Ae=new te((U=t.isWorldSpace)!=null?U:0),Ge=new vt((j=t.origin)!=null?j:new Xr),ze=new vt((B=t.direction)!=null?B:new Xr),De=new ve((k=t.num)!=null?k:0),ke;t.colors?ke=new yi(De.value+1,t.colors):(ke=new yi(De.value+1,new ea(0,0,0,1)),ke.value[1]=new ea(1,1,1,1));let tt;t.steps?tt=new gi(t.steps.length,t.steps):(tt=new gi(10,1),tt.value[0]=0);let Ut=new te((ne=t.alpha)!=null?ne:1),Sr=new ve((q=t.mode)!=null?q:0),Br=new bn(ge,Le,Se,we,Ne,Ae,Ge,ze,ke,tt,De,Ut),Er=new _e(Br.calpha,"f");return{layer:new qe(t.id,t.uuid,{type:e,gradientType:ge,smooth:Le,near:Se,far:we,isVector:Ne,isWorldSpace:Ae,origin:Ge,direction:ze,colors:ke,steps:tt,num:De,alpha:Ut,calpha:Er,mode:Sr}),color:Br,alpha:Er,mode:Sr}}case"noise":{let ge=new te((J=t.scale)!=null?J:1),Le=new vt((Y=t.size)!=null?Y:new Xr(100,100,100)),Se=new te((X=t.move)!=null?X:1),we=new bt((Q=t.fA)!=null?Q:new Yr(1.7,9.2)),Ne=new bt((se=t.fB)!=null?se:new Yr(8.3,2.8)),Ae=new bt((oe=t.distortion)!=null?oe:new Yr(1,1)),Ge=new Ir(t.colorA),ze=new Ir(t.colorB),De=new Ir(t.colorC),ke=new Ir(t.colorD),tt=new te((he=t.alpha)!=null?he:1),Ut=new ve((Ee=t.mode)!=null?Ee:0),Sr=new ve((xe=t.noiseType)!=null?xe:0),Br=new gn(ge,Le,Se,we,Ne,Ae,Ge,ze,De,ke,tt,Sr),Er=new _e(Br.calpha,"f");return{layer:new qe(t.id,t.uuid,{type:e,scale:ge,size:Le,move:Se,fA:we,fB:Ne,distortion:Ae,colorA:Ge,colorB:ze,colorC:De,colorD:ke,alpha:tt,calpha:Er,mode:Ut,noiseType:Sr}),color:Br,alpha:Er,mode:Ut}}case"normal":{let ge=new vt((We=t.cnormal)!=null?We:new Xr(1,1,1)),Le=new te((Ce=t.alpha)!=null?Ce:1),Se=new ve((ct=t.mode)!=null?ct:0),we=new fn(ge,Le),Ne=new _e("alpha / clamp(alpha + accumAlpha, 0.00001, 1.0 )","f");return Ne.keywords.alpha=Le,{layer:new qe(t.id,t.uuid,{type:e,cnormal:ge,alpha:Le,calpha:Ne,mode:Se}),color:we,alpha:Ne,mode:Se}}case"gradient":{let ge=new ve((wt=t.gradientType)!=null?wt:0),Le=new ln((br=t.smooth)!=null?br:!1),Se;t.colors?Se=new yi(t.colors.length,t.colors):(Se=new yi(10,new ea(0,0,0,1)),Se.value[1]=new ea(1,1,1,1));let we;t.steps?we=new gi(t.steps.length,t.steps):(we=new gi(10,1),we.value[0]=0);let Ne=new bt((ft=t.offset)!=null?ft:new Yr(0,0)),Ae=new bt((vr=t.morph)!=null?vr:new Yr(0,0)),Ge=new te((ii=t.angle)!=null?ii:0),ze=new te((oi=t.alpha)!=null?oi:1),De=new ve((Ue=t.mode)!=null?Ue:0),ke=new yn(ge,Le,Se,we,Ne,Ae,Ge,ze),tt=new _e(ke.calpha,"f");return{layer:new qe(t.id,t.uuid,{type:e,gradientType:ge,smooth:Le,colors:Se,steps:we,offset:Ne,morph:Ae,angle:Ge,alpha:ze,calpha:tt,mode:De}),color:ke,alpha:tt,mode:De}}case"displace":{let ge=new ve((yt=t.displacementType)!=null?yt:0);if(ge.value===0){let Le=new vt((_t=t.offset)!=null?_t:new Xr(0,0,0)),Se=new te((Tn=t.scale)!=null?Tn:10),we=new te((Nn=t.intensity)!=null?Nn:8),Ne=new te((Mn=t.movement)!=null?Mn:1),Ae=new te((On=t.alpha)!=null?On:1),Ge=new ve((In=t.mode)!=null?In:0),ze=new ve((Pn=t.noiseType)!=null?Pn:0),De=new ho(ge,we,Ne,Le,Se,ze);return{layer:new qe(t.id,t.uuid,{displacementType:ge,type:e,offset:Le,scale:Se,intensity:we,movement:Ne,alpha:Ae,mode:Ge,noiseType:ze}),position:De}}else if(ge.value===1){let Le=(jt=t.texture)!=null?jt:new ur,Se=Le.matrix;t.mat&&Se.copy(t.mat),Le.needsUpdate=!0;let we=new te((Io=t.intensity)!=null?Io:8),Ne=new Nt(Le),Ae=new te((pt=t.crop)!=null?pt:0),Ge=new te((Si=t.alpha)!=null?Si:1),ze=new ve((An=t.mode)!=null?An:0),De=new ho(ge,we,Ne,Ae);return{layer:new qe(t.id,t.uuid,{displacementType:ge,type:e,intensity:we,texture:Ne,crop:Ae,mat:De.mat,alpha:Ge,mode:ze}),position:De}}return{}}}return{}}blendColors(){let t=this._layerNodes.findIndex(r=>r.type==="color"),e=this._layerNodes.findIndex(r=>r.type==="light");if(t!==-1&&t<e){let r=this._layerNodes[t].color;for(let i=t+1;i<e;++i){let o=this._layerNodes[i];o.type==="color"&&(r=new xn(r,o.color,o.alpha,o.mode))}this._material.color=r}else this._material.color=void 0}blendAfterColors(){let t=new _e("outgoingLight","f"),e=this._layerNodes.findIndex(r=>r.type==="light");if(this._layerNodes.length>e+1){for(let r=e+1;r<this._layerNodes.length;++r){let i=this._layerNodes[r];i.type==="color"&&(t=new xn(t,i.color,i.alpha,i.mode))}"afterColor"in this._material&&(this._material.afterColor=t)}else"afterColor"in this._material&&(this._material.afterColor=void 0)}blendPositions(){let t=this._layerNodes.filter(e=>e.type==="position");if(t.length>0){let e=t[0].position;for(let r=1;r<t.length;++r)t[r]&&(e=new At(e,t[r].position,At.ADD),e=new At(e,new te(.5).setReadonly(!0),At.MUL));this._material.position=e}else this._material.position=void 0}cleanupChangedLayer(t){switch(this._layerNodes=this._layerNodes.filter(e=>e.id!==t.id),t.type){case"displace":{this.blendPositions();break}default:{this.blendColors(),this.blendAfterColors();break}}}};var Rt=class extends Xv{constructor(e,r,i){super(i);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 an(new ut(ut.PROJECTION)),this.fragment=r!=null?r:new an(new Be(5855577)),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,r){this.build({renderer:r}),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 r=new St(this);return e&&(async()=>{for(;e.image===void 0;)await new Promise(i=>requestAnimationFrame(i));r.addLayerAt(1,{type:"texture",texture:e}),this.dispose()})(),r}clampUniformsForPreview(e,r){let i=(o,s,a)=>Math.min(Math.max(o,s),a);if(this.userData.layers){for(let o of this.userData.layers.getLayers())if(o.type=="displace"){this.uniformsBackup[`f${o.id}_intensity`]=o.uniforms[`f${o.id}_intensity`].value;let s=i(o.uniforms[`f${o.id}_intensity`].value,e,r);o.uniforms[`f${o.id}_intensity`].value=s}}}restoreClampedUniforms(){if(this.userData.layers)for(let e of this.userData.layers.getLayers())e.type=="displace"&&(e.uniforms[`f${e.id}_intensity`].value=this.uniformsBackup[`f${e.id}_intensity`])}customProgramCacheKey(){return this.getHash()}updateFrame(e){for(let r=0;r<this.updaters.length;++r)e.updateNode(this.updaters[r])}build(e){var i;e=e!=null?e:{};let r=(i=e.builder)!=null?i:new Qs;return r.setMaterial(this,e.renderer),r.build(this.vertex,this.fragment),this.vertexShader=r.getCode("vertex"),this.fragmentShader=r.getCode("fragment"),this.defines=r.defines,this.uniforms=r.uniforms,this.extensions=r.extensions,this.updaters=r.updaters,this.fog=r.requires.fog,this.lights=r.requires.lights,this.transparent=r.requires.transparent||this.blending>Yv,this}getHash(){let e="{";return e+='"vertex":'+this.vertex.getHash()+",",e+='"fragment":'+this.fragment.getHash(),e+="}",e}copy(e){let r=this.uuid;for(let i in e)this[i]=e[i];return this.uuid=r,e.userData!==void 0&&(this.userData=JSON.parse(JSON.stringify(e.userData))),this}toJSON(e){let r=this.userData.layers;this.userData.layers=void 0;let i=super.toJSON(e);return i.type="ShaderMaterial",i.userData={type:this.userData.type,category:this.userData.category,nodeType:this.type,layers:r.toJSON(e)},i.vertex=this.vertex.toJSON(e).uuid,i.fragment=this.fragment.toJSON(e).uuid,delete i.vertexShader,delete i.fragmentShader,delete i.color,delete i.shininess,delete i.specular,delete i.roughness,delete i.metalness,delete i.uniforms,e&&!e.materials[this.uuid]&&(e.materials[this.uuid]=i),this.userData.layers=r,i}fromJSON(e,r){var i;this.defines=(i=e.defines)!=null?i:{},this.depthFunc=e.depthFunc,this.depthWrite=e.depthWrite,this.side=e.side!==void 0?e.side:Zv,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,r,this)}};Object.defineProperties(Rt.prototype,{properties:{get:function(){return this.fragment.properties}},needsUpdate:{set:function(n){n===!0&&this.version++,this.needsCompile=n},get:function(){return this.needsCompile}}});import{UniformsLib as Qv,UniformsUtils as eS}from"three";var ta=class extends de{constructor(){super("basic");this.nodeType="Basic";this.color=new Be(5855577)}generate(e){let r;if(e.isShader("vertex")){let i=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform(eS.merge([Qv.fog])),e.addParsCode(["varying vec3 vViewPosition;","#include <fog_pars_vertex>","#include <normal_pars_vertex>"].join(`
|
|
709
|
+
`)}}();var St=class{constructor(t){this.id=2,this.layerCount=2,this.uuid=Pr.generateUUID(),this.needsUpdate=!1,this._material=t,this._layerNodes=[];let e=this._createLayer({id:0,type:"color"});this._material.color=e.color,this._material.alpha===void 0&&(this._material.alpha=new te(1));let r=new te(1),i=new ve(0);"shadingAlpha"in this._material&&"shadingBlend"in this._material&&(this._material.shadingAlpha=r,this._material.shadingBlend=i),this._layerNodes.push({id:0,type:"color",color:e.color,alpha:e.alpha,mode:e.mode}),this._layerNodes.push({id:1,type:"light",alpha:r,mode:i}),this.head=e.layer,this.head.next=new qe(1,void 0,{type:"light",alpha:r,mode:i}),this.attachLightNodes(this.getLightLayer())}get material(){return this._material}set material(t){var o;this._material=t;let e,r,i=this.head;for(;i!==void 0;){if(i.type==="light"){e=i.uniforms[`f${i.id}_alpha`],r=i.uniforms[`f${i.id}_mode`];break}i=i.next}"shadingAlpha"in this._material&&"shadingBlend"in this._material&&(this._material.shadingAlpha=e,this._material.shadingBlend=r),this.attachLightNodes((o=t.userData.layers)==null?void 0:o.getLightLayer()),this.blendColors(),this.blendAfterColors(),this.blendPositions()}getLayersOfType(t){let e=[],r=this.head;for(;r;)r.type===t&&e.push(r),r=r.next;return e}addLayer(t){var i;if(t.id=(i=t.id)!=null?i:++this.id,this.layerCount++,t.type==="light"){let o=this.createLightLayer(t);return this.uuid=Pr.generateUUID(),this.blendColors(),this.blendAfterColors(),this.blendPositions(),o}let e=this._createLayer(t),r=e.layer;if(this.head===void 0)this.head=r;else{let o=this.head;for(;o.next!=null;)o=o.next;o.next=r}return e.color&&this._layerNodes.push({id:r.id,type:"color",color:e.color,alpha:e.alpha,mode:e.mode}),e.position&&this._layerNodes.push({id:r.id,type:"position",position:e.position}),this.uuid=Pr.generateUUID(),this.blendColors(),this.blendAfterColors(),this.blendPositions(),r}addLayerBeforeAt(t,e){var a;let r=this.head;t.id=(a=t.id)!=null?a:++this.id,this.layerCount++;let i=this._createLayer(t),o=i.layer;o.next=e;let s=0;if(r===e)this.head=o,i.color&&this._layerNodes.splice(0,0,{id:o.id,type:"color",color:i.color,alpha:i.alpha,mode:i.mode}),i.position&&this._layerNodes.splice(0,0,{id:o.id,type:"position",position:i.position});else{for(s=1;(r==null?void 0:r.next)!==e;)r=r==null?void 0:r.next,s++;r.next=o,i.color&&this._layerNodes.splice(s,0,{id:o.id,type:"color",color:i.color,alpha:i.alpha,mode:i.mode}),i.position&&this._layerNodes.splice(s,0,{id:o.id,type:"position",position:i.position})}return this.uuid=Pr.generateUUID(),this.blendColors(),this.blendAfterColors(),this.blendPositions(),o}addLayerAt(t,e){var o;e.id=(o=e.id)!=null?o:++this.id,this.layerCount++;let r=this._createLayer(e),i=r.layer;if(r.color&&this._layerNodes.splice(t,0,{id:i.id,type:"color",color:r.color,alpha:r.alpha,mode:r.mode}),r.position&&this._layerNodes.splice(t,0,{id:i.id,type:"position",position:r.position}),t==0)i.next=this.head,this.head=i;else{let s=this.head,a=this.head.next;for(let l=0;l<t-1;l++)s=a,a=a.next;i.next=a,s.next=i}return this.uuid=Pr.generateUUID(),this.blendColors(),this.blendAfterColors(),this.blendPositions(),i}removeLayer(t){let e=this.head,r,i=0;if((e==null?void 0:e.id)==t)this.head=e.next;else for(i=1,r=e,e=e==null?void 0:e.next;e!=null;){if(e.id==t){r.next=e.next;break}i++,r=e,e=e.next}return this.cleanupChangedLayer(e),this.blendColors(),this.blendAfterColors(),this.blendPositions(),this.uuid=Pr.generateUUID(),this.layerCount--,i}changeLayer(t,e){let r,i=this.head,o;if((i==null?void 0:i.id)==t){let s=this._createLayer(P({id:t,uuid:i.uuid},e));o=s.layer,o.next=i.next,this.head=o,s.color&&(this._layerNodes[0]={id:o.id,type:"color",color:s.color,alpha:s.alpha,mode:s.mode}),s.position&&(this._layerNodes[0]={id:o.id,type:"position",position:s.position}),o.uniforms[`f${t}_mode`].value=i.uniforms[`f${t}_mode`].value,o.uniforms[`f${t}_alpha`].value=i.uniforms[`f${t}_alpha`].value}else{r=i,i=i.next;let s=1;for(;i!=null;){if(i.id==t){let a=this._createLayer(P({id:t,uuid:i.uuid},e));o=a.layer,r.next=o,o.next=i.next,a.color&&(this._layerNodes[s]={id:t,type:"color",color:a.color,alpha:a.alpha,mode:a.mode}),a.position&&(this._layerNodes[s]={id:t,type:"position",position:a.position}),o.uniforms[`f${t}_mode`].value=i.uniforms[`f${t}_mode`].value,o.uniforms[`f${t}_alpha`].value=i.uniforms[`f${t}_alpha`].value;break}r=i,i=i.next,s++}}return this.uuid=Pr.generateUUID(),this.blendColors(),this.blendAfterColors(),this.blendPositions(),o}getLayer(t){let e=this.head;for(;e!=null&&e.id!=t;)e=e.next;return e}getLayerByUuid(t){let e=this.head;for(;e!==void 0;){if(e.uuid===t)return e;e=e.next}}getLayers(){let t=[],e=this.head;for(;e!=null;)t.push(e),e=e.next;return t}getLayerPosition(t){let e=this.head,r=0;for(;e!==void 0&&e.id!=t;)r++,e=e.next;return r}getDefines(){}getBeforeProgram(){}getLightingProgram(){}getAfterProgram(){}getVarPrograms(){}getUniforms(){}moveLayer(t,e){let r,i=this.head,o;if(t==0)r=this.head,this.head=r.next;else{for(let a=0;a<t;a++)o=i,i=i.next;o.next=i.next,r=i}if(i=this.head,o=void 0,e==0)r.next=this.head,this.head=r;else{for(let a=0;a<e-1;a++)i=i.next;r.next=i==null?void 0:i.next,i.next=r}let s=this._layerNodes.splice(t,1)[0];this._layerNodes.splice(e,0,s),this.uuid=Pr.generateUUID(),this.blendColors(),this.blendAfterColors()}updateLayerUniform(){this.uuid=Pr.generateUUID(),this.blendColors(),this.blendAfterColors()}copy(t){this.needsUpdate=!1,this.layerCount=t.layerCount,this._layerNodes=[],this.layerCount=0,this.head=void 0,this.rebuildLayerNodes(this.head,t.head);let e=t.head,r=this.head;for(;e.next!=null;)this.rebuildLayerNodes(r,e.next),r=r.next,e=e.next;return this.id=t.id,this.uuid=t.uuid,this.blendColors(),this.blendAfterColors(),this.blendPositions(),this}createLightLayer(t){let e=new te(t.alpha),r=new ve(t.mode);this._material.shadingAlpha=e,this._material.shadingBlend=r,this._layerNodes.push({id:t.id,type:"light",alpha:e,mode:r});let i=new qe(t.id,void 0,{type:"light",alpha:e,mode:r});if(this.head===void 0)this.head=i;else{let o=this.head;for(;o.next!=null;)o=o.next;o.next=i}return this.attachLightNodes(this.getLightLayer()),i}rebuildLayerNodes(t,e,r=!1){if(e.type==="light"){let i=r?e.uniforms[`f${e.id}_alpha`]:new te(e.uniforms[`f${e.id}_alpha`].value),o=r?e.uniforms[`f${e.id}_mode`]:new ve(e.uniforms[`f${e.id}_mode`].value);this._material.shadingAlpha=i,this._material.shadingBlend=o,this._layerNodes.push({id:e.id,type:"light",alpha:i,mode:o}),this.head===void 0?this.head=new qe(e.id,e.uuid,{type:"light",alpha:i,mode:o}):t&&(t.next=new qe(e.id,e.uuid,{type:"light",alpha:i,mode:o})),this.attachLightNodes(e)}else{let i={type:e.type,id:e.id};for(let o in e.uniforms){let s=e.getName(o);if(!s)continue;let a=`f${e.id}_${s}`;if(Array.isArray(e.uniforms[a].value))i[s]=e.uniforms[a].value.map(l=>l.clone&&!r?l.clone():l);else{let l=e.uniforms[a].value;if(s==="transmissionDepthMap"){i[s]=l;continue}l!=null&&(i[s]=l.clone&&!r&&!l.isRenderTargetTexture?l.clone():l)}}this.addLayer(i)}}attachLightNodes(t){var i,o,s,a,l,c,p,h,d,m,f;let e={},r=this.getLightLayer();switch(this._material.userData.category){case"Lambert":e.emissive=new Be((o=(i=t==null?void 0:t.getValue("emissive"))==null?void 0:i.clone())!=null?o:0);break;case"Phong":e.shininess=new te((s=t==null?void 0:t.getValue("shininess"))!=null?s:30),e.specular=new Be((l=(a=t==null?void 0:t.getValue("specular"))==null?void 0:a.clone())!=null?l:1118481);break;case"Toon":e.shininess=new te((c=t==null?void 0:t.getValue("shininess"))!=null?c:30),e.specular=new Be((h=(p=t==null?void 0:t.getValue("specular"))==null?void 0:p.clone())!=null?h:1118481);break;case"Physical":e.roughness=new te((d=t==null?void 0:t.getValue("roughness"))!=null?d:.3),e.metalness=new te((m=t==null?void 0:t.getValue("metalness"))!=null?m:0),e.reflectivity=new te((f=t==null?void 0:t.getValue("reflectivity"))!=null?f:.5);break;default:break}Object.keys(e).forEach(T=>{this._material[T]=e[T],r.uniforms[`f${r.id}_${T}`]=e[T]})}clone(t){return new St(t).copy(this)}toJSON(t){return{id:this.id,uuid:this.uuid,head:this.head.toJSON(t)}}fromJSON(t,e,r){let i=new qe(t.head.id,void 0,{type:t.head.type}).fromJSON(t.head,e),o=t.head.next,s=i;for(;o!=null;)s.next=new qe(o.id,void 0,{type:o.type}).fromJSON(o,e),o=o.next,s=s.next;this._layerNodes=[],this.head=void 0,this.rebuildLayerNodes(this.head,i,!0);let a=i;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=t.id,this.uuid=t.uuid,this.blendColors(),this.blendAfterColors(),this.blendPositions(),this}getLightLayer(){var e;let t=this.head;for(;t!==void 0&&t.type!=="light";)t=(e=t.next)!=null?e:t;return t}dispose(){let t=this.head;for(this._layerNodes=[],this.layerCount=0;t!==void 0;)t.hasOwnProperty("dispose")===!0&&t.dispose(),t=t.next;this.head=void 0}_createLayer(t){var r,i,o,s,a,l,c,p,h,d,m,f,T,w,y,L,A,I,b,V,x,u,M,g,N,v,C,$,H,ie,pe,ce,be,F,G,_,z,D,R,K,Z,U,j,B,k,ne,q,J,Y,X,Q,se,oe,he,Ee,xe,We,Ce,ct,wt,br,ft,vr,ii,oi,Ue,yt,_t,Tn,Nn,Mn,On,In,Pn,jt,Io,pt,Si,An;let e=t.type;switch(e){case"color":{let ge=new Be((r=t.color)!=null?r:5855577),Le=new te((i=t.alpha)!=null?i:1),Se=new _e("alpha / clamp(alpha + accumAlpha, 0.00001, 1.0 )","f");Se.keywords.alpha=Le;let we=new ve((o=t.mode)!=null?o:0);return ge.alpha=Le,{layer:new qe(t.id,t.uuid,{type:e,color:ge,alpha:Le,calpha:Se,mode:we}),color:ge,alpha:Se,mode:we}}case"texture":{let ge=(s=t.texture)!=null?s:new ur,Le=ge.matrix;t.mat&&Le.copy(t.mat),ge.needsUpdate=!0;let Se=new te((a=t.crop)!=null?a:0),we=new ve((l=t.projection)!=null?l:0),Ne=new ve((c=t.axis)!=null?c:0),Ae=new bt(t.size?new Yr(t.size[0],t.size[1]):new Yr(100,100)),Ge=new te((p=t.alpha)!=null?p:1),ze=new ve((h=t.mode)!=null?h:0),De=new Nt(ge),ke=new vt((d=t.textureSize)!=null?d:new Xr(ge.image?ge.image.width:0,ge.image?ge.image.height:0)),tt=new cn(De,ke,Se,we,Ne,Ae,Ge,ze),Ut=new _e(tt.calpha,"f");return{layer:new qe(t.id,t.uuid,{type:e,texture:De,textureSize:ke,crop:Se,projection:we,axis:Ne,size:Ae,mat:tt.mat,alpha:Ge,calpha:Ut,mode:ze}),color:tt,alpha:Ut,mode:ze}}case"matcap":{let ge=(m=t.texture)!=null?m:new ur;ge.needsUpdate=!0;let Le=new te((f=t.alpha)!=null?f:1),Se=new Nt(ge),we=new ve((T=t.mode)!=null?T:0),Ne=new vn(Se,Le,we),Ae=new _e(Ne.calpha,"f");return{layer:new qe(t.id,t.uuid,{type:e,texture:Se,alpha:Le,calpha:Ae,mode:we}),color:Ne,alpha:Ae,mode:we}}case"fresnel":{let ge=new Be((w=t.color)!=null?w:16777215),Le=new te((y=t.bias)!=null?y:.1),Se=new te((L=t.scale)!=null?L:1),we=new te((A=t.intensity)!=null?A:2),Ne=new te((I=t.factor)!=null?I:1),Ae=new te((b=t.alpha)!=null?b:1),Ge=new ve((V=t.mode)!=null?V:0),ze=new hn(ge,Le,Se,we,Ne,Ae,Ge),De=new _e(ze.calpha,"f");return{layer:new qe(t.id,t.uuid,{type:e,color:ge,bias:Le,scale:Se,intensity:we,factor:Ne,alpha:Ae,calpha:De,mode:Ge}),color:ze,alpha:De,mode:Ge}}case"rainbow":{let ge=new te((x=t.filmThickness)!=null?x:30),Le=new te((u=t.movement)!=null?u:0),Se=new vt((M=t.wavelengths)!=null?M:new Xr(0,0,0)),we=new te((g=t.noiseStrength)!=null?g:0),Ne=new te((N=t.noiseScale)!=null?N:1),Ae=new vt((v=t.offset)!=null?v:new Xr(0,0,0)),Ge=new te((C=t.alpha)!=null?C:1),ze=new un(ge,Le,Se,we,Ne,Ae,Ge),De=new _e(ze.calpha,"f"),ke=new ve(($=t.mode)!=null?$:0);return{layer:new qe(t.id,t.uuid,{type:e,filmThickness:ge,movement:Le,wavelengths:Se,noiseStrength:we,noiseScale:Ne,offset:Ae,alpha:Ge,calpha:De,mode:ke}),color:ze,alpha:De,mode:ke}}case"transmission":{let ge=new te((H=t.thickness)!=null?H:10),Le=new te((ie=t.ior)!=null?ie:1.5),Se=new te((pe=t.roughness)!=null?pe:.5),we=new bt((ce=t.transmissionSamplerSize)!=null?ce:new Yr(2048,2048)),Ne=(be=t.transmissionSamplerMap)!=null?be:new ur,Ae=(F=t.transmissionDepthMap)!=null?F:new ur,Ge=new Nt(Ne),ze=new Nt(Ae),De=window.innerWidth,ke=window.innerHeight,tt=De>=ke?new bt(ke/De,1):new bt(1,De/ke),Ut=new te((G=t.alpha)!=null?G:1),Sr=new mn(ge,Le,Se,we,Ge,ze,tt,Ut),Br=new _e(Sr.calpha,"f"),Er=new ve((_=t.mode)!=null?_:0);return{layer:new qe(t.id,t.uuid,{type:e,thickness:ge,ior:Le,roughness:Se,transmissionSamplerSize:we,transmissionSamplerMap:Ge,transmissionDepthMap:ze,aspectRatio:tt,alpha:Ut,calpha:Br,mode:Er}),color:Sr,alpha:Br,mode:Er}}case"depth":{let ge=new ve((z=t.gradientType)!=null?z:0),Le=new ln((D=t.smooth)!=null?D:!1),Se=new te((R=t.near)!=null?R:50),we=new te((K=t.far)!=null?K:200),Ne=new te((Z=t.isVector)!=null?Z:1),Ae=new te((U=t.isWorldSpace)!=null?U:0),Ge=new vt((j=t.origin)!=null?j:new Xr),ze=new vt((B=t.direction)!=null?B:new Xr),De=new ve((k=t.num)!=null?k:0),ke;t.colors?ke=new yi(De.value+1,t.colors):(ke=new yi(De.value+1,new ea(0,0,0,1)),ke.value[1]=new ea(1,1,1,1));let tt;t.steps?tt=new gi(t.steps.length,t.steps):(tt=new gi(10,1),tt.value[0]=0);let Ut=new te((ne=t.alpha)!=null?ne:1),Sr=new ve((q=t.mode)!=null?q:0),Br=new bn(ge,Le,Se,we,Ne,Ae,Ge,ze,ke,tt,De,Ut),Er=new _e(Br.calpha,"f");return{layer:new qe(t.id,t.uuid,{type:e,gradientType:ge,smooth:Le,near:Se,far:we,isVector:Ne,isWorldSpace:Ae,origin:Ge,direction:ze,colors:ke,steps:tt,num:De,alpha:Ut,calpha:Er,mode:Sr}),color:Br,alpha:Er,mode:Sr}}case"noise":{let ge=new te((J=t.scale)!=null?J:1),Le=new vt((Y=t.size)!=null?Y:new Xr(100,100,100)),Se=new te((X=t.move)!=null?X:1),we=new bt((Q=t.fA)!=null?Q:new Yr(1.7,9.2)),Ne=new bt((se=t.fB)!=null?se:new Yr(8.3,2.8)),Ae=new bt((oe=t.distortion)!=null?oe:new Yr(1,1)),Ge=new Ir(t.colorA),ze=new Ir(t.colorB),De=new Ir(t.colorC),ke=new Ir(t.colorD),tt=new te((he=t.alpha)!=null?he:1),Ut=new ve((Ee=t.mode)!=null?Ee:0),Sr=new ve((xe=t.noiseType)!=null?xe:0),Br=new gn(ge,Le,Se,we,Ne,Ae,Ge,ze,De,ke,tt,Sr),Er=new _e(Br.calpha,"f");return{layer:new qe(t.id,t.uuid,{type:e,scale:ge,size:Le,move:Se,fA:we,fB:Ne,distortion:Ae,colorA:Ge,colorB:ze,colorC:De,colorD:ke,alpha:tt,calpha:Er,mode:Ut,noiseType:Sr}),color:Br,alpha:Er,mode:Ut}}case"normal":{let ge=new vt((We=t.cnormal)!=null?We:new Xr(1,1,1)),Le=new te((Ce=t.alpha)!=null?Ce:1),Se=new ve((ct=t.mode)!=null?ct:0),we=new fn(ge,Le),Ne=new _e("alpha / clamp(alpha + accumAlpha, 0.00001, 1.0 )","f");return Ne.keywords.alpha=Le,{layer:new qe(t.id,t.uuid,{type:e,cnormal:ge,alpha:Le,calpha:Ne,mode:Se}),color:we,alpha:Ne,mode:Se}}case"gradient":{let ge=new ve((wt=t.gradientType)!=null?wt:0),Le=new ln((br=t.smooth)!=null?br:!1),Se;t.colors?Se=new yi(t.colors.length,t.colors):(Se=new yi(10,new ea(0,0,0,1)),Se.value[1]=new ea(1,1,1,1));let we;t.steps?we=new gi(t.steps.length,t.steps):(we=new gi(10,1),we.value[0]=0);let Ne=new bt((ft=t.offset)!=null?ft:new Yr(0,0)),Ae=new bt((vr=t.morph)!=null?vr:new Yr(0,0)),Ge=new te((ii=t.angle)!=null?ii:0),ze=new te((oi=t.alpha)!=null?oi:1),De=new ve((Ue=t.mode)!=null?Ue:0),ke=new yn(ge,Le,Se,we,Ne,Ae,Ge,ze),tt=new _e(ke.calpha,"f");return{layer:new qe(t.id,t.uuid,{type:e,gradientType:ge,smooth:Le,colors:Se,steps:we,offset:Ne,morph:Ae,angle:Ge,alpha:ze,calpha:tt,mode:De}),color:ke,alpha:tt,mode:De}}case"displace":{let ge=new ve((yt=t.displacementType)!=null?yt:0);if(ge.value===0){let Le=new vt((_t=t.offset)!=null?_t:new Xr(0,0,0)),Se=new te((Tn=t.scale)!=null?Tn:10),we=new te((Nn=t.intensity)!=null?Nn:8),Ne=new te((Mn=t.movement)!=null?Mn:1),Ae=new te((On=t.alpha)!=null?On:1),Ge=new ve((In=t.mode)!=null?In:0),ze=new ve((Pn=t.noiseType)!=null?Pn:0),De=new ho(ge,we,Ne,Le,Se,ze);return{layer:new qe(t.id,t.uuid,{displacementType:ge,type:e,offset:Le,scale:Se,intensity:we,movement:Ne,alpha:Ae,mode:Ge,noiseType:ze}),position:De}}else if(ge.value===1){let Le=(jt=t.texture)!=null?jt:new ur,Se=Le.matrix;t.mat&&Se.copy(t.mat),Le.needsUpdate=!0;let we=new te((Io=t.intensity)!=null?Io:8),Ne=new Nt(Le),Ae=new te((pt=t.crop)!=null?pt:0),Ge=new te((Si=t.alpha)!=null?Si:1),ze=new ve((An=t.mode)!=null?An:0),De=new ho(ge,we,Ne,Ae);return{layer:new qe(t.id,t.uuid,{displacementType:ge,type:e,intensity:we,texture:Ne,crop:Ae,mat:De.mat,alpha:Ge,mode:ze}),position:De}}return{}}}return{}}blendColors(){let t=this._layerNodes.findIndex(r=>r.type==="color"),e=this._layerNodes.findIndex(r=>r.type==="light");if(t!==-1&&t<e){let r=this._layerNodes[t].color;for(let i=t+1;i<e;++i){let o=this._layerNodes[i];o.type==="color"&&(r=new xn(r,o.color,o.alpha,o.mode))}this._material.color=r}else this._material.color=void 0}blendAfterColors(){let t=new _e("outgoingLight","f"),e=this._layerNodes.findIndex(r=>r.type==="light");if(this._layerNodes.length>e+1){for(let r=e+1;r<this._layerNodes.length;++r){let i=this._layerNodes[r];i.type==="color"&&(t=new xn(t,i.color,i.alpha,i.mode))}"afterColor"in this._material&&(this._material.afterColor=t)}else"afterColor"in this._material&&(this._material.afterColor=void 0)}blendPositions(){let t=this._layerNodes.filter(e=>e.type==="position");if(t.length>0){let e=t[0].position;for(let r=1;r<t.length;++r)t[r]&&(e=new At(e,t[r].position,At.ADD),e=new At(e,new te(.5).setReadonly(!0),At.MUL));this._material.position=e}else this._material.position=void 0}cleanupChangedLayer(t){switch(this._layerNodes=this._layerNodes.filter(e=>e.id!==t.id),t.type){case"displace":{this.blendPositions();break}default:{this.blendColors(),this.blendAfterColors();break}}}};var Rt=class extends Zv{constructor(e,r,i){super(i);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 an(new ut(ut.PROJECTION)),this.fragment=r!=null?r:new an(new Be(5855577)),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,r){this.build({renderer:r}),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 r=new St(this);return e&&(async()=>{for(;e.image===void 0;)await new Promise(i=>requestAnimationFrame(i));r.addLayerAt(1,{type:"texture",texture:e}),this.dispose()})(),r}clampUniformsForPreview(e,r){let i=(o,s,a)=>Math.min(Math.max(o,s),a);if(this.userData.layers){for(let o of this.userData.layers.getLayers())if(o.type=="displace"){this.uniformsBackup[`f${o.id}_intensity`]=o.uniforms[`f${o.id}_intensity`].value;let s=i(o.uniforms[`f${o.id}_intensity`].value,e,r);o.uniforms[`f${o.id}_intensity`].value=s}}}restoreClampedUniforms(){if(this.userData.layers)for(let e of this.userData.layers.getLayers())e.type=="displace"&&(e.uniforms[`f${e.id}_intensity`].value=this.uniformsBackup[`f${e.id}_intensity`])}customProgramCacheKey(){return this.getHash()}updateFrame(e){for(let r=0;r<this.updaters.length;++r)e.updateNode(this.updaters[r])}build(e){var i;e=e!=null?e:{};let r=(i=e.builder)!=null?i:new Qs;return r.setMaterial(this,e.renderer),r.build(this.vertex,this.fragment),this.vertexShader=r.getCode("vertex"),this.fragmentShader=r.getCode("fragment"),this.defines=r.defines,this.uniforms=r.uniforms,this.extensions=r.extensions,this.updaters=r.updaters,this.fog=r.requires.fog,this.lights=r.requires.lights,this.transparent=r.requires.transparent||this.blending>Xv,this}getHash(){let e="{";return e+='"vertex":'+this.vertex.getHash()+",",e+='"fragment":'+this.fragment.getHash(),e+="}",e}copy(e){let r=this.uuid;for(let i in e)this[i]=e[i];return this.uuid=r,e.userData!==void 0&&(this.userData=JSON.parse(JSON.stringify(e.userData))),this}toJSON(e){let r=this.userData.layers;this.userData.layers=void 0;let i=super.toJSON(e);return i.type="ShaderMaterial",i.userData={type:this.userData.type,category:this.userData.category,nodeType:this.type,layers:r.toJSON(e)},i.vertex=this.vertex.toJSON(e).uuid,i.fragment=this.fragment.toJSON(e).uuid,delete i.vertexShader,delete i.fragmentShader,delete i.color,delete i.shininess,delete i.specular,delete i.roughness,delete i.metalness,delete i.uniforms,e&&!e.materials[this.uuid]&&(e.materials[this.uuid]=i),this.userData.layers=r,i}fromJSON(e,r){var i;this.defines=(i=e.defines)!=null?i:{},this.depthFunc=e.depthFunc,this.depthWrite=e.depthWrite,this.side=e.side!==void 0?e.side:Qv,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,r,this)}};Object.defineProperties(Rt.prototype,{properties:{get:function(){return this.fragment.properties}},needsUpdate:{set:function(n){n===!0&&this.version++,this.needsCompile=n},get:function(){return this.needsCompile}}});import{UniformsLib as eS,UniformsUtils as tS}from"three";var ta=class extends de{constructor(){super("basic");this.nodeType="Basic";this.color=new Be(5855577)}generate(e){let r;if(e.isShader("vertex")){let i=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform(tS.merge([eS.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>
|
|
@@ -726,7 +726,7 @@ vec4 getIBLVolumeRefraction( vec3 n, vec3 v, float roughness, vec3 position, mat
|
|
|
726
726
|
`];i&&o.push(i.code,i.result?"displaced_position = "+i.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>"),r=o.join(`
|
|
727
727
|
`)}else{this.color===void 0&&(this.color=new Be(5855577)),this.color.analyze(e,{slot:"color"}),this.alpha&&this.alpha.analyze(e),this.afterColor&&this.afterColor.analyze(e,{slot:"afterColor"});let i=this.color.flow(e,"c",{slot:"color"}),o=this.alpha?this.alpha.flow(e,"f"):void 0,s=this.afterColor?this.afterColor.flow(e,"c",{slot:"afterColor"}):void 0;e.requires.transparent=o!==void 0,e.addParsCode(["#include <fog_pars_fragment>","#include <dithering_pars_fragment>","varying vec3 vViewPosition;","#include <normal_pars_fragment>"].join(`
|
|
728
728
|
`));let a=["#include <normal_fragment_begin>",i.code];o&&a.push(o.code,"#ifdef ALPHATEST"," if ( "+o.result+" <= ALPHATEST ) discard;","#endif"),s?a.push(s.code,`vec3 outgoingLight = ${i.result};`,`vec3 finalColor = spe_blend(outgoingLight, ${s.result}, 1.0, SPE_BLENDING_NORMAL);`):a.push(`vec3 finalColor = ${i.result};`),o?a.push(`gl_FragColor = vec4( finalColor, accumAlpha * ${o.result} );`):a.push("gl_FragColor = vec4("+i.result+", 1.0 );"),a.push("#include <fog_fragment>","#include <dithering_fragment>"),r=a.join(`
|
|
729
|
-
`)}return r}copy(e){return super.copy(e),e.color&&(this.color=e.color.clone()),e.position&&(this.position=e.position.clone()),e.alpha&&(this.alpha=e.alpha.clone()),e.afterColor&&(this.afterColor=e.afterColor.clone()),e.shadingAlpha&&(this.shadingAlpha=e.shadingAlpha.clone()),e.shadingBlend&&(this.shadingBlend=e.shadingBlend.clone()),this}};var ra=class extends Rt{constructor(e=new ta,r){super(e,e,r);this.type="BasicNodeMaterial",this.fragment=e}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}};var mt=class extends ra{constructor(t,e,r){super(e,t),this.userData.type="BasicMaterial",this.userData.category="Basic",this.userData.layers=r!=null?r:this._getLayerStack(t==null?void 0:t.map)}get layersList(){return this.userData.layers}set layersList(t){this.userData.layers=t}equals(t){return this.userData.type===t.userData.type&&this.userData.layers.uuid==t.userData.layers.uuid}copy(t){if(t.userData.layers!==void 0&&t.userData.layers instanceof St){let e=t.userData.layers,r=t.fragment;super.copy(t);let i=r.clone();this.fragment=i,this.vertex=i;let o=e.clone(this);this.userData.layers=o}else super.copy(t);return this}static fromJSON(t,e,r){let i=r.getNode(e.vertex),o=new mt(void 0,i);return o.fromJSON(e,r),o}static fromMaterial(t){let e=new mt(t.map?{map:t.map}:{}),r=e.fragment;return r.color.value.copy(t.color),r.alpha.value=t.opacity,e}dispose(){super.dispose()}};import{UniformsLib as pu,UniformsUtils as
|
|
729
|
+
`)}return r}copy(e){return super.copy(e),e.color&&(this.color=e.color.clone()),e.position&&(this.position=e.position.clone()),e.alpha&&(this.alpha=e.alpha.clone()),e.afterColor&&(this.afterColor=e.afterColor.clone()),e.shadingAlpha&&(this.shadingAlpha=e.shadingAlpha.clone()),e.shadingBlend&&(this.shadingBlend=e.shadingBlend.clone()),this}};var ra=class extends Rt{constructor(e=new ta,r){super(e,e,r);this.type="BasicNodeMaterial",this.fragment=e}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}};var mt=class extends ra{constructor(t,e,r){super(e,t),this.userData.type="BasicMaterial",this.userData.category="Basic",this.userData.layers=r!=null?r:this._getLayerStack(t==null?void 0:t.map)}get layersList(){return this.userData.layers}set layersList(t){this.userData.layers=t}equals(t){return this.userData.type===t.userData.type&&this.userData.layers.uuid==t.userData.layers.uuid}copy(t){if(t.userData.layers!==void 0&&t.userData.layers instanceof St){let e=t.userData.layers,r=t.fragment;super.copy(t);let i=r.clone();this.fragment=i,this.vertex=i;let o=e.clone(this);this.userData.layers=o}else super.copy(t);return this}static fromJSON(t,e,r){let i=r.getNode(e.vertex),o=new mt(void 0,i);return o.fromJSON(e,r),o}static fromMaterial(t){let e=new mt(t.map?{map:t.map}:{}),r=e.fragment;return r.color.value.copy(t.color),r.alpha.value=t.opacity,e}dispose(){super.dispose()}};import{UniformsLib as pu,UniformsUtils as rS}from"three";var ia=class extends de{constructor(){super("phong");this.nodeType="Phong";this.color=new Be(5855577),this.specular=new Be(1118481),this.shininess=new te(30),this.shadingAlpha=new te(1),this.shadingBlend=new ve(0)}build(e){let r;if(e.define("PHONG"),e.requires.lights=!0,e.extensions.derivatives=!0,e.isShader("vertex")){let i=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform(rS.merge([pu.fog,pu.lights])),e.addParsCode(["varying vec3 vViewPosition;","#include <fog_pars_vertex>","#include <normal_pars_vertex>","#include <shadowmap_pars_vertex>","#include <clipping_planes_pars_vertex>"].join(`
|
|
730
730
|
`));let o=["#include <beginnormal_vertex>",`
|
|
731
731
|
#ifndef USE_LAYER_DISPLACE
|
|
732
732
|
#include <defaultnormal_vertex>
|
|
@@ -760,7 +760,7 @@ vec4 getIBLVolumeRefraction( vec3 n, vec3 v, float roughness, vec3 position, mat
|
|
|
760
760
|
outgoingLight = spe_blend( diffuseColor, outgoingLight, ${a.result}, ${l.result} );
|
|
761
761
|
}
|
|
762
762
|
`),c&&h.push(c.code,`outgoingLight = spe_blend(outgoingLight, ${c.result}, 1.0, SPE_BLENDING_NORMAL);`),p?h.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${p.result} );`):h.push("gl_FragColor = vec4( outgoingLight, 1.0 );"),h.push("#include <encodings_fragment>","#include <fog_fragment>","#include <dithering_fragment>"),r=h.join(`
|
|
763
|
-
`)}return r}copy(e){return super.copy(e),e.color&&(this.color=e.color.clone()),this.specular=e.specular.clone(),this.shininess=e.shininess.clone(),e.position&&(this.position=e.position.clone()),e.afterColor&&(this.afterColor=e.afterColor.clone()),e.alpha&&(this.alpha=e.alpha.clone()),e.shadingAlpha&&(this.shadingAlpha=e.shadingAlpha.clone()),e.shadingBlend&&(this.shadingBlend=e.shadingBlend.clone()),this}};var oa=class extends Rt{constructor(e=new ia,r){super(e,e,r);this.type="PhongNodeMaterial",this.fragment=e}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 specular(){return this.fragment.specular}set specular(e){this.fragment.specular=e}get shininess(){return this.fragment.shininess}set shininess(e){this.fragment.shininess=e}};var Vt=class extends oa{constructor(t,e,r){super(e,t),this.userData.type="PhongMaterial",this.userData.category="Phong",this.userData.layers=r!=null?r:this._getLayerStack(t==null?void 0:t.map)}get layersList(){return this.userData.layers}set layersList(t){this.userData.layers=t}equals(t){return this.userData.type===t.userData.type&&this.userData.layers.uuid==t.userData.layers.uuid}copy(t){if(t.userData.layers!==void 0&&t.userData.layers instanceof St){let e=t.userData.layers,r=t.fragment;super.copy(t);let i=r.clone();this.fragment=i,this.vertex=i;let o=e.clone(this);this.userData.layers=o,i.shadingAlpha.value=r.shadingAlpha.value,i.shadingBlend.value=r.shadingBlend.value}else super.copy(t);return this}static fromJSON(t,e,r){let i=r.getNode(e.vertex),o=new Vt(void 0,i);return o.fromJSON(e,r),o}static fromMaterial(t){let e=new Vt(t.map?{map:t.map}:{}),r=e.fragment;return r.color.value.copy(t.color),r.alpha.value=t.opacity,e}dispose(){super.dispose()}};import{UniformsLib as hu,UniformsUtils as
|
|
763
|
+
`)}return r}copy(e){return super.copy(e),e.color&&(this.color=e.color.clone()),this.specular=e.specular.clone(),this.shininess=e.shininess.clone(),e.position&&(this.position=e.position.clone()),e.afterColor&&(this.afterColor=e.afterColor.clone()),e.alpha&&(this.alpha=e.alpha.clone()),e.shadingAlpha&&(this.shadingAlpha=e.shadingAlpha.clone()),e.shadingBlend&&(this.shadingBlend=e.shadingBlend.clone()),this}};var oa=class extends Rt{constructor(e=new ia,r){super(e,e,r);this.type="PhongNodeMaterial",this.fragment=e}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 specular(){return this.fragment.specular}set specular(e){this.fragment.specular=e}get shininess(){return this.fragment.shininess}set shininess(e){this.fragment.shininess=e}};var Vt=class extends oa{constructor(t,e,r){super(e,t),this.userData.type="PhongMaterial",this.userData.category="Phong",this.userData.layers=r!=null?r:this._getLayerStack(t==null?void 0:t.map)}get layersList(){return this.userData.layers}set layersList(t){this.userData.layers=t}equals(t){return this.userData.type===t.userData.type&&this.userData.layers.uuid==t.userData.layers.uuid}copy(t){if(t.userData.layers!==void 0&&t.userData.layers instanceof St){let e=t.userData.layers,r=t.fragment;super.copy(t);let i=r.clone();this.fragment=i,this.vertex=i;let o=e.clone(this);this.userData.layers=o,i.shadingAlpha.value=r.shadingAlpha.value,i.shadingBlend.value=r.shadingBlend.value}else super.copy(t);return this}static fromJSON(t,e,r){let i=r.getNode(e.vertex),o=new Vt(void 0,i);return o.fromJSON(e,r),o}static fromMaterial(t){let e=new Vt(t.map?{map:t.map}:{}),r=e.fragment;return r.color.value.copy(t.color),r.alpha.value=t.opacity,e}dispose(){super.dispose()}};import{UniformsLib as hu,UniformsUtils as iS}from"three";var na=class extends de{constructor(){super("lambert");this.nodeType="Lambert";this.color=new Be(5855577),this.emissive=new Be(0),this.emissiveIntensity=new te(1),this.shadingAlpha=new te(1),this.shadingBlend=new ve(0)}build(e){let r;if(e.define("LAMBERT"),e.requires.lights=!0,e.extensions.derivatives=!0,e.isShader("vertex")){let i=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform(iS.merge([hu.fog,hu.lights])),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vLightFront;","varying vec3 vIndirectFront;","#ifndef DOUBLE_SIDED"," #define DOUBLE_SIDED","#endif","#ifdef DOUBLE_SIDED"," varying vec3 vLightBack;"," varying vec3 vIndirectBack;","#endif","#include <bsdfs>","#include <lights_pars_begin>","#include <color_pars_vertex>","#include <fog_pars_vertex>","#include <normal_pars_vertex>","#include <shadowmap_pars_vertex>","#include <clipping_planes_pars_vertex>"].join(`
|
|
764
764
|
`));let o=["#include <beginnormal_vertex>",`
|
|
765
765
|
#ifndef USE_LAYER_DISPLACE
|
|
766
766
|
#include <defaultnormal_vertex>
|
|
@@ -866,7 +866,7 @@ vec4 getIBLVolumeRefraction( vec3 n, vec3 v, float roughness, vec3 position, mat
|
|
|
866
866
|
outgoingLight = spe_blend( diffuseColor, outgoingLight, ${a.result}, ${l.result} );
|
|
867
867
|
}
|
|
868
868
|
`),c&&h.push(c.code,`outgoingLight = spe_blend(outgoingLight, ${c.result}, 1.0, SPE_BLENDING_NORMAL);`),p?h.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${p.result} );`):h.push("gl_FragColor = vec4( outgoingLight, 1.0 );"),h.push("#include <encodings_fragment>","#include <fog_fragment>","#include <dithering_fragment>"),r=h.join(`
|
|
869
|
-
`)}return r}copy(e){return super.copy(e),this.emissiveIntensity=e.emissiveIntensity.clone(),e.color&&(this.color=e.color.clone()),e.position&&(this.position=e.position.clone()),e.afterColor&&(this.afterColor=e.afterColor.clone()),e.alpha&&(this.alpha=e.alpha.clone()),e.shadingAlpha&&(this.shadingAlpha=e.shadingAlpha.clone()),e.shadingBlend&&(this.shadingBlend=e.shadingBlend.clone()),e.emissive&&(this.emissive=e.emissive.clone()),this}};var sa=class extends Rt{constructor(e=new na,r){super(e,e,r);this.type="LambertNodeMaterial",this.fragment=e}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 emissive(){return this.fragment.emissive}set emissive(e){this.fragment.emissive=e}get emissiveIntensity(){return this.fragment.emissiveIntensity}set emissiveIntensity(e){this.fragment.emissiveIntensity=e}};var mo=class extends sa{constructor(t,e,r){super(e,t),this.userData.type="LambertMaterial",this.userData.category="Lambert",this.userData.layers=r!=null?r:this._getLayerStack(t==null?void 0:t.map)}get layersList(){return this.userData.layers}set layersList(t){this.userData.layers=t}equals(t){return this.userData.type===t.userData.type&&this.userData.layers.uuid==t.userData.layers.uuid}copy(t){if(t.userData.layers!==void 0&&t.userData.layers instanceof St){let e=t.userData.layers,r=t.fragment;super.copy(t);let i=r.clone();this.fragment=i,this.vertex=i;let o=e.clone(this);this.userData.layers=o,i.shadingAlpha.value=r.shadingAlpha.value,i.shadingBlend.value=r.shadingBlend.value}else super.copy(t);return this}static fromJSON(t,e,r){let i=r.getNode(e.vertex),o=new mo(void 0,i);return o.fromJSON(e,r),o}dispose(){super.dispose()}};import{UniformsLib as du,UniformsUtils as
|
|
869
|
+
`)}return r}copy(e){return super.copy(e),this.emissiveIntensity=e.emissiveIntensity.clone(),e.color&&(this.color=e.color.clone()),e.position&&(this.position=e.position.clone()),e.afterColor&&(this.afterColor=e.afterColor.clone()),e.alpha&&(this.alpha=e.alpha.clone()),e.shadingAlpha&&(this.shadingAlpha=e.shadingAlpha.clone()),e.shadingBlend&&(this.shadingBlend=e.shadingBlend.clone()),e.emissive&&(this.emissive=e.emissive.clone()),this}};var sa=class extends Rt{constructor(e=new na,r){super(e,e,r);this.type="LambertNodeMaterial",this.fragment=e}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 emissive(){return this.fragment.emissive}set emissive(e){this.fragment.emissive=e}get emissiveIntensity(){return this.fragment.emissiveIntensity}set emissiveIntensity(e){this.fragment.emissiveIntensity=e}};var mo=class extends sa{constructor(t,e,r){super(e,t),this.userData.type="LambertMaterial",this.userData.category="Lambert",this.userData.layers=r!=null?r:this._getLayerStack(t==null?void 0:t.map)}get layersList(){return this.userData.layers}set layersList(t){this.userData.layers=t}equals(t){return this.userData.type===t.userData.type&&this.userData.layers.uuid==t.userData.layers.uuid}copy(t){if(t.userData.layers!==void 0&&t.userData.layers instanceof St){let e=t.userData.layers,r=t.fragment;super.copy(t);let i=r.clone();this.fragment=i,this.vertex=i;let o=e.clone(this);this.userData.layers=o,i.shadingAlpha.value=r.shadingAlpha.value,i.shadingBlend.value=r.shadingBlend.value}else super.copy(t);return this}static fromJSON(t,e,r){let i=r.getNode(e.vertex),o=new mo(void 0,i);return o.fromJSON(e,r),o}dispose(){super.dispose()}};import{UniformsLib as du,UniformsUtils as oS}from"three";var aa=class extends de{constructor(){super("toon");this.nodeType="Toon";this.color=new Be(5855577),this.specular=new Be(1118481),this.shininess=new te(30),this.shadingAlpha=new te(1),this.shadingBlend=new ve(0)}build(e){let r;if(e.define("TOON"),e.requires.lights=!0,e.extensions.derivatives=!0,e.isShader("vertex")){let i=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform(oS.merge([du.fog,du.lights])),e.addParsCode(["varying vec3 vViewPosition;","#include <fog_pars_vertex>","#include <normal_pars_vertex>","#include <shadowmap_pars_vertex>","#include <clipping_planes_pars_vertex>"].join(`
|
|
870
870
|
`));let o=["#include <beginnormal_vertex>",`
|
|
871
871
|
#ifndef USE_LAYER_DISPLACE
|
|
872
872
|
#include <defaultnormal_vertex>
|
|
@@ -920,7 +920,7 @@ vec4 getIBLVolumeRefraction( vec3 n, vec3 v, float roughness, vec3 position, mat
|
|
|
920
920
|
outgoingLight = spe_blend( diffuseColor, outgoingLight, ${a.result}, ${l.result} );
|
|
921
921
|
}
|
|
922
922
|
`),c&&h.push(c.code,`outgoingLight = spe_blend(outgoingLight, ${c.result}, 1.0, SPE_BLENDING_NORMAL);`),p?h.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${p.result} );`):h.push("gl_FragColor = vec4( outgoingLight, 1.0 );"),h.push("#include <encodings_fragment>","#include <fog_fragment>","#include <dithering_fragment>"),r=h.join(`
|
|
923
|
-
`)}return r}copy(e){return super.copy(e),e.color&&(this.color=e.color.clone()),this.specular=e.specular.clone(),this.shininess=e.shininess.clone(),e.position&&(this.position=e.position.clone()),e.afterColor&&(this.afterColor=e.afterColor.clone()),e.alpha&&(this.alpha=e.alpha.clone()),e.shadingAlpha&&(this.shadingAlpha=e.shadingAlpha.clone()),e.shadingBlend&&(this.shadingBlend=e.shadingBlend.clone()),this}};var la=class extends Rt{constructor(e=new aa,r){super(e,e,r);this.type="ToonNodeMaterial",this.fragment=e}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 specular(){return this.fragment.specular}set specular(e){this.fragment.specular=e}get shininess(){return this.fragment.shininess}set shininess(e){this.fragment.shininess=e}};var fo=class extends la{constructor(t,e,r){super(e,t),this.userData.type="ToonMaterial",this.userData.category="Toon",this.userData.layers=r!=null?r:this._getLayerStack(t==null?void 0:t.map)}get layersList(){return this.userData.layers}set layersList(t){this.userData.layers=t}equals(t){return this.userData.type===t.userData.type&&this.userData.layers.uuid==t.userData.layers.uuid}copy(t){if(t.userData.layers!==void 0&&t.userData.layers instanceof St){let e=t.userData.layers,r=t.fragment;super.copy(t);let i=r.clone();this.fragment=i,this.vertex=i;let o=e.clone(this);this.userData.layers=o,i.shadingAlpha.value=r.shadingAlpha.value,i.shadingBlend.value=r.shadingBlend.value}else super.copy(t);return this}static fromJSON(t,e,r){let i=r.getNode(e.vertex),o=new fo(void 0,i);return o.fromJSON(e,r),o}dispose(){super.dispose()}};import{UniformsLib as jl,UniformsUtils as
|
|
923
|
+
`)}return r}copy(e){return super.copy(e),e.color&&(this.color=e.color.clone()),this.specular=e.specular.clone(),this.shininess=e.shininess.clone(),e.position&&(this.position=e.position.clone()),e.afterColor&&(this.afterColor=e.afterColor.clone()),e.alpha&&(this.alpha=e.alpha.clone()),e.shadingAlpha&&(this.shadingAlpha=e.shadingAlpha.clone()),e.shadingBlend&&(this.shadingBlend=e.shadingBlend.clone()),this}};var la=class extends Rt{constructor(e=new aa,r){super(e,e,r);this.type="ToonNodeMaterial",this.fragment=e}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 specular(){return this.fragment.specular}set specular(e){this.fragment.specular=e}get shininess(){return this.fragment.shininess}set shininess(e){this.fragment.shininess=e}};var fo=class extends la{constructor(t,e,r){super(e,t),this.userData.type="ToonMaterial",this.userData.category="Toon",this.userData.layers=r!=null?r:this._getLayerStack(t==null?void 0:t.map)}get layersList(){return this.userData.layers}set layersList(t){this.userData.layers=t}equals(t){return this.userData.type===t.userData.type&&this.userData.layers.uuid==t.userData.layers.uuid}copy(t){if(t.userData.layers!==void 0&&t.userData.layers instanceof St){let e=t.userData.layers,r=t.fragment;super.copy(t);let i=r.clone();this.fragment=i,this.vertex=i;let o=e.clone(this);this.userData.layers=o,i.shadingAlpha.value=r.shadingAlpha.value,i.shadingBlend.value=r.shadingBlend.value}else super.copy(t);return this}static fromJSON(t,e,r){let i=r.getNode(e.vertex),o=new fo(void 0,i);return o.fromJSON(e,r),o}dispose(){super.dispose()}};import{UniformsLib as jl,UniformsUtils as nS}from"three";var ca=class extends de{constructor(){super("standard");this.nodeType="Standard";this.color=new Be(5855577),this.roughness=new te(.3),this.metalness=new te(0),this.reflectivity=new te(.5),this.shadingAlpha=new te(1),this.shadingBlend=new ve(0)}build(e){let r;if(e.define("STANDARD"),e.requires.lights=!0,e.extensions.derivatives=!0,e.extensions.shaderTextureLOD=!0,e.isShader("vertex")){let i=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform(nS.merge([jl.fog,jl.lights])),jl.LTC_1&&(e.uniforms.ltc_1={value:void 0},e.uniforms.ltc_2={value:void 0}),e.addParsCode(["varying vec3 vViewPosition;","#include <fog_pars_vertex>","#include <normal_pars_vertex>","#include <shadowmap_pars_vertex>","#include <clipping_planes_pars_vertex>"].join(`
|
|
924
924
|
`));let o=["#include <beginnormal_vertex>",`
|
|
925
925
|
#if !defined( USE_LAYER_DISPLACE )
|
|
926
926
|
#include <defaultnormal_vertex>
|
|
@@ -954,5 +954,5 @@ vec4 getIBLVolumeRefraction( vec3 n, vec3 v, float roughness, vec3 position, mat
|
|
|
954
954
|
outgoingLight = spe_blend( diffuseColor, outgoingLight, ${l.result}, ${c.result} );
|
|
955
955
|
}
|
|
956
956
|
`),p&&m.push(p.code,`outgoingLight = spe_blend(outgoingLight, ${p.result}, 1.0, SPE_BLENDING_NORMAL);`),h?m.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${h.result} );`):m.push("gl_FragColor = vec4( outgoingLight, 1.0 );"),m.push("#include <encodings_fragment>","#include <fog_fragment>","#include <dithering_fragment>"),r=m.join(`
|
|
957
|
-
`)}return r}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 pa=class extends Rt{constructor(e=new ca,r){super(e,e,r);this.type="StandardNodeMaterial",this.fragment=e}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}};var yo=class extends pa{constructor(t,e,r){super(e,t),this.userData.type="PhysicalMaterial",this.userData.category="Physical",this.userData.layers=r!=null?r:this._getLayerStack(t==null?void 0:t.map)}get layersList(){return this.userData.layers}set layersList(t){this.userData.layers=t}equals(t){return this.userData.type===t.userData.type&&this.userData.layers.uuid==t.userData.layers.uuid}copy(t){if(t.userData.layers!==void 0&&t.userData.layers instanceof St){let e=t.userData.layers,r=t.fragment;super.copy(t);let i=r.clone();this.fragment=i,this.vertex=i;let o=e.clone(this);this.userData.layers=o,i.shadingAlpha.value=r.shadingAlpha.value,i.shadingBlend.value=r.shadingBlend.value}else super.copy(t);return this}static fromJSON(t,e,r){let i=r.getNode(e.vertex),o=new yo(void 0,i);return o.fromJSON(e,r),o}dispose(){super.dispose()}};import{Color as kl}from"three";import{Matrix3 as uu,Texture as Ul,Vector2 as Sn,Vector3 as Zr,Vector4 as mu}from"three";function fu(n,t){switch(n.data.type){case"light":return rr(n);case"fresnel":return sS(n,t);case"gradient":return aS(n);case"depth":return lS(n);case"normal":return cS(n);case"noise":return pS(n,t);case"texture":return hS(n,t);case"rainbow":return dS(n);case"transmission":return uS(n,t);case"matcap":return mS(n,t);case"displace":return fS(n);case"color":default:return nS(n,t)}}function yu(n){return{type:n.data.type}}function rr(n){let{alpha:t,mode:e}=n.data;return W(P({},yu(n)),{alpha:t,mode:e})}function nS(n,t){return W(P({},rr(n)),{color:Ye(n.data.color,t)})}function sS(n,t){let{bias:e,scale:r,intensity:i,factor:o,color:s}=n.data;return W(P({},rr(n)),{color:Ye(s,t),bias:e,scale:r,intensity:i,factor:o})}function aS(n){let{gradientType:t,smooth:e,colors:r,steps:i,angle:o,offset:s,morph:a}=n.data;return W(P({},rr(n)),{gradientType:t,smooth:e,colors:r.map(l=>new mu(l[0],l[1],l[2],l[3])),num:r.length,steps:i,offset:new Sn(...s),morph:new Sn(...a),angle:o})}function lS(n){let{gradientType:t,near:e,far:r,isVector:i,isWorldSpace:o,origin:s,direction:a,colors:l,steps:c,smooth:p,num:h}=n.data;return W(P({},rr(n)),{gradientType:t,near:e,far:r,isVector:i,isWorldSpace:o,origin:new Zr(...s),direction:a?new Zr(...a):new Zr(1,0,0),num:h,colors:l.map(d=>new mu(d[0],d[1],d[2],d[3])),steps:c,smooth:p})}function cS(n){let{cnormal:t}=n.data;return W(P({},rr(n)),{cnormal:new Zr(t[0],t[1],t[2])})}function pS(n,t){let{data:e}=n;return W(P({},rr(n)),{scale:e.scale,move:e.move,fA:new Sn(...e.fA),fB:new Sn(...e.fB),size:new Zr(...e.size),distortion:new Sn(...e.distortion),colorA:Ye(e.colorA,t),colorB:Ye(e.colorB,t),colorC:Ye(e.colorC,t),colorD:Ye(e.colorD,t),noiseType:e.noiseType})}function hS(n,t){let{projection:e,axis:r,crop:i,size:o}=n.data,{image:s,wrapping:a,repeat:l,offset:c}=n.data.texture,p=new Ul,h;if(typeof s=="string")h=t==null?void 0:t.getImage(s);else{let d=new Image;d.src=s.data,d.onload=()=>{t!=null&&t.onImageLoad&&(t==null||t.onImageLoad(s.data))},h=d}return p.image=h,p.repeat.set(l[0],l[1]),p.offset.set(c[0],c[1]),p.wrapS=p.wrapT=a,W(P({},rr(n)),{texture:p,mat:new uu().setUvTransform(c[0],c[1],l[0],l[1],0,0,0),crop:i,projection:e,axis:["x","y","z"].indexOf(r),size:o})}function dS(n){let{data:t}=n;return W(P({},rr(n)),{filmThickness:t.filmThickness,movement:t.movement,wavelengths:new Zr(...t.wavelengths),noiseStrength:t.noiseStrength,noiseScale:t.noiseScale,offset:new Zr(...t.offset)})}function uS(n,t){let{data:e}=n;return W(P({},rr(n)),{thickness:e.thickness,ior:e.ior,roughness:e.roughness,transmissionSamplerMap:t.transmissionSamplerMap,transmissionDepthMap:t.transmissionDepthMap})}function mS(n,t){let e=new Ul,{image:r}=n.data.texture,i;if(typeof r=="string")i=t==null?void 0:t.getImage(r);else{let s=new Image;s.src=r.data,s.onload=()=>{t!=null&&t.onImageLoad&&(t==null||t.onImageLoad(r.data))},i=s}e.image=i;let o=16777215;return W(P({},rr(n)),{color:o,texture:e})}function fS(n){let{data:t}=n,e=W(P({},yu(n)),{intensity:t.intensity});if(t.displacementType==="noise")return W(P({},e),{offset:new Zr(...t.offset),scale:t.scale,movement:t.movement,noiseType:t.noiseType});{let r=new Ul,i=new uu().setUvTransform(0,0,1,1,0,0,0);return W(P({},e),{texture:r,mat:i,crop:t.crop})}}function gu(n,t,e){if(e.type==="displace"&&(n==="intensity"||n==="visible")){let r=t.uniforms[`f${t.id}_intensity`];return r?(r.value=e.intensity*(e.visible?1:0),r):void 0}if(e.type!=="displace"&&(n==="alpha"||n==="visible")){let r=t.uniforms[`f${t.id}_alpha`];return r?(r.value=e.alpha*(e.visible?1:0),r):void 0}}import{Color as vu,Vector4 as yS}from"three";var go;(t=>{function n(e){return new vu(e.x,e.y,e.z).getHex()}t.getHex=n})(go||(go={}));var xu;(t=>{function n(e){return new yS(e.r,e.g,e.b,e.a)}t.getThreeVector4=n})(xu||(xu={}));var bu;(e=>{function n(r,i){r.setRGB(i.r,i.g,i.b)}e.setThreeColor=n;function t(r){return new vu(r.r,r.g,r.b).getHex()}e.getHex=t})(bu||(bu={}));function wn(n,t){return typeof n=="string"?t.getMaterialOrDeletedPlaceholder(n):Hl(n,t)}function Su(n,t){return n.map(e=>wn(e,t))}function Hl(n,t){var s,a;let e=(s=n.layers)!=null?s:Ji.defaultTwoLayerData("phong").layers,r=gS(e),i;switch(r.category){case"basic":i=new mt;break;case"lambert":{i=new mo;break}case"toon":{i=new fo;break}case"physical":i=new yo;break;case"phong":default:{i=new Vt;break}}i.name=(a=n.name)!=null?a:"Untitled Material";let o=i.userData.layers;xS(o);for(let l=e.length-1;l>=0;l--)bS(o,e[l],t);switch(r.category){case"basic":break;case"lambert":{let p=i,d=Ye(r.emissive,t);d instanceof kl?p.emissive.value=d:p.emissive.value.setHex(go.getHex(d));break}case"toon":{let p=i,h=r;p.shininess.value=h.shininess;let d=Ye(h.specular,t);d instanceof kl?p.specular.value=d:p.specular.value.setHex(go.getHex(d));break}case"physical":let l=i,c=r;l.metalness.value=c.metalness,l.roughness.value=c.roughness,l.reflectivity.value=c.reflectivity;break;case"phong":default:{let p=i,h=r;p.shininess.value=h.shininess;let d=Ye(h.specular,t);d instanceof kl?p.specular.value=d:p.specular.value.setHex(go.getHex(d));break}}return o.blendColors(),o.blendAfterColors(),o.blendPositions(),i}function gS(n){for(let t of n)if(t.data.type==="light")return t.data;return{type:"light",category:"basic",visible:!0,alpha:1,mode:0}}function xS(n){for(let t of n.getLayers())n.removeLayer(t.id)}function bS(n,t,e){let r=fu(t,e);r.type==="transmission"&&(r.transmissionSamplerMap=e==null?void 0:e.transmissionSamplerMap,r.transmissionDepthMap=e==null?void 0:e.transmissionDepthMap);let i=n.addLayer(r);i.uuid=t.id;for(let o in t.data)gu(o,i,t.data)}var wu=n=>n.tagName==="VIDEO",xi=class{static resize(t,e,r){let i=t/e,o;if(!r.image)return;let s=r.image;wu(s)?o=s.videoWidth/s.videoHeight:o=s.width/s.height,i>o&&(r.imageType=="WEBCAM"?r.repeat.set(-1,1*o/i):r.repeat.set(1,1*o/i)),i<o&&(r.imageType=="WEBCAM"?r.repeat.set(1*i/o*-1,1):r.repeat.set(1*i/o,1)),i==o&&(r.imageType=="WEBCAM"?r.repeat.set(-1,1):r.repeat.set(1,1))}static resizeTextureLayer(t,e,r){let i=t/e,o=r.image!==void 0?r.image.width/r.image.height:1,s;i>o?s={x:1,y:o/i}:i<o?s={x:i/o,y:1}:s={x:1,y:1},r.repeat.set(s.x,s.y),r.updateMatrix()}static resizeTextureLayers(t,e,r){let i=r.userData.layers,o=i.getLayers();for(let s=0;s<o.length;s++){let a=o[s];au(a)&&(xi.resizeTextureLayer(t,e,a.uniforms[`f${a.id}_texture`].value),i.updateLayerUniform())}}static resizeComplex(t,e,r,i){let o=t/e,s,a=r.image;wu(a)?s=a.videoWidth/a.videoHeight:s=a.width/a.height,i.geometry.type.includes("Shape")?(o>s&&(r.imageType=="WEBCAM"?r.repeat.set(1/t*-1,1/e*s/o):r.repeat.set(1/t,1/e*s/o)),o<s&&(r.imageType=="WEBCAM"?r.repeat.set(1/t*o/s*-1,1/e):r.repeat.set(1/t*o/s,1/e)),o==s&&(r.imageType=="WEBCAM"?r.repeat.set(1/t*-1,1/e):r.repeat.set(1/t,1/e))):(o>s&&(r.imageType=="WEBCAM"?r.repeat.set(-1,1*s/o):r.repeat.set(1,1*s/o)),o<s&&(r.imageType=="WEBCAM"?r.repeat.set(1*o/s*-1,1):r.repeat.set(1*o/s,1)),o==s&&(r.imageType=="WEBCAM"?r.repeat.set(-1,1):r.repeat.set(1,1)))}};var xo=class extends at{constructor(e,r=new mt){super(e,r);this.objectType="Mesh2D";this.castShadow=!0,this.receiveShadow=!0}updateGeometry(e){super.updateGeometry(e),this.material.userData.layers&&xi.resizeTextureLayers(this.geometry.userData.parameters.width,this.geometry.userData.parameters.height,this.material)}resizeGeometry(e,r){super.resizeGeometry(e,r,0),this.material.userData.layers&&xi.resizeTextureLayers(this.geometry.userData.parameters.width,this.geometry.userData.parameters.height,this.material)}toJSON(e){let r=super.toJSON(e);return r.object.objectType="Mesh2D",r}clone(){let e=super.clone();return e.updateGeometry({}),e}static fromTexture(e){let r,i;if(e instanceof vS){let a=e.image;r=a.videoWidth*.5,i=a.videoHeight*.5}else{let a=e.image;r=a.width*.5,i=a.height*.5}let o=Ws.create({parameters:{width:r,height:i}}),s=new mt;return s.layersList.changeLayer(0,{type:"texture",texture:e}),s.layersList.moveLayer(0,1),s.dispose(),new xo(o,s)}};import{DoubleSide as SS,EventDispatcher as wS,Matrix3 as LS,Vector3 as ql}from"three";var CS=new ql(0,0,1),Lu=new ql,Cu=new ql,Tu=new LS,Qr=class extends at{constructor(e=ht.create({}),r=new mt({side:SS})){var i;super(e,r);this.recursiveSelection=!1;this.objectType="VectorObject";this.eventDispatcher=new wS;this._onShapeUpdate=()=>{this.updateGeometry({}),this.geometry.computeBoundingSphere(),this.geometry.computeBoundingBox()};this.castShadow=!0,this.receiveShadow=!0,this.forceComputeSize=!0,this.shape=e.userData.shape,(i=this.shape.eventDispatcher)==null||i.addEventListener("update",this._onShapeUpdate)}toJSON(e){let r=super.toJSON(e);return r.object.objectType="VectorObject",r}fromState(e){return super.fromState(e),this.shape.update(),this}setHelperVisibility(){}updateGeometry(e){if(super.updateGeometry(e),"userData"in this.geometry){let r=this.geometry.userData.parameters;this.eventDispatcher.dispatchEvent({type:"geometryUpdate",parameters:r})}}setShape(e){var r,i;this.shape&&((r=this.shape.eventDispatcher)==null||r.removeEventListener("update",this._onShapeUpdate)),this.shape=e,(i=this.shape.eventDispatcher)==null||i.addEventListener("update",this._onShapeUpdate)}updateWorldMatrix(e,r){super.updateWorldMatrix(e,r),Tu.getNormalMatrix(this.matrixWorld),Lu.copy(CS).applyMatrix3(Tu).normalize(),Cu.setFromMatrixPosition(this.matrixWorld),this.shape.plane.setFromNormalAndCoplanarPoint(Lu,Cu)}clone(e){let r=this.shape.clone(),i=this.material.clone(),o=this.geometry.userData,s=ht.create(Object.assign({},o,{shape:r})),a=new Qr(s,i).copy(this,e);return a.shape=r,r.update(),a}raycast(e,r){at.prototype.raycast.call(this,e,r)}};import{Camera as FS,OrthographicCamera as jS,PerspectiveCamera as US,Vector3 as Ft,Object3D as Ou,Quaternion as kS}from"three";import{BoxBufferGeometry as TS}from"three";var yr=n=>{var t;return t=class extends n{constructor(){super(...arguments);this.isObjectHelper=!0}},t.geometryHelper=new TS(30,30,30),t};import{Camera as PS,LineSegments as AS,BufferGeometry as DS,LineBasicMaterial as _S,Color as $l,Vector3 as BS,Float32BufferAttribute as Mu}from"three";import{Ray as NS,Sphere as MS,Matrix4 as OS,Vector3 as Ar}from"three";var ha=new NS,Wl=new MS,Nu=new OS,gr=(n,t,e,r,i=!1)=>{let o=t,s=n.matrixWorld;if(o.boundingSphere===null&&o.computeBoundingSphere(),Wl.copy(o.boundingSphere),Wl.applyMatrix4(s),e.ray.intersectsSphere(Wl)===!1||(Nu.copy(s).invert(),ha.copy(e.ray).applyMatrix4(Nu),o.boundingBox!==null&&ha.intersectsBox(o.boundingBox)===!1))return;let a,l,c,p,h=o.index,d=o.attributes.position,m=o.drawRange,f,T;if(i===!1){let y=Math.max(0,m.start),L=Math.min(h.count,m.start+m.count);for(f=y,T=L;f<T;f+=3)if(l=h.getX(f),c=h.getX(f+1),p=h.getX(f+2),a=w(n,e,ha,d,l,c,p),a){a.faceIndex=Math.floor(f/3),r.push(a);return}}else{let L=o.attributes.position,A=new Ar,I=new Ar,b=new Ar,V=new Ar,x=2,M=1/((n.scale.x+n.scale.y+n.scale.z)/3),g=M*M,N=Math.max(0,m.start),v=Math.min(L.count,m.start+m.count);for(let C=N,$=v-1;C<$;C+=x){if(A.fromBufferAttribute(L,C),I.fromBufferAttribute(L,C+1),ha.distanceSqToSegment(A,I,V,b)>g)continue;V.applyMatrix4(n.matrixWorld);let ie=e.ray.origin.distanceTo(V);ie<e.near||ie>e.far||r.push({distance:ie,point:b.clone().applyMatrix4(n.matrixWorld),object:n})}}function w(y,L,A,I,b,V,x){let u=new Ar,M=new Ar,g=new Ar,N=new Ar,v=new Ar;if(u.fromBufferAttribute(I,b),M.fromBufferAttribute(I,V),g.fromBufferAttribute(I,x),A.intersectTriangle(u,M,g,!1,N)===null)return null;v.copy(N),v.applyMatrix4(y.matrixWorld);let $=L.ray.origin.distanceTo(v);return $<L.near||$>L.far?null:{faceIndex:1,distance:$,point:v.clone(),object:y}}};var da=new BS,Yt=new PS,Jl=class extends AS{constructor(e){let r=new DS,i=new _S({color:16777215,vertexColors:!0,toneMapped:!1}),o=[],s=[],a={},l=new $l(15711266),c=new $l(15711266),p=new $l(2857471);h("n1","n2",l),h("n2","n4",l),h("n4","n3",l),h("n3","n1",l),h("f1","f2",l),h("f2","f4",l),h("f4","f3",l),h("f3","f1",l),h("n1","f1",l),h("n2","f2",l),h("n3","f3",l),h("n4","f4",l),h("p","n1",c),h("p","n2",c),h("p","n3",c),h("p","n4",c),h("u1","u2",p),h("u2","u3",p),h("u3","u1",p);function h(m,f,T){d(m,T),d(f,T)}function d(m,f){o.push(0,0,0),s.push(f.r,f.g,f.b),a[m]===void 0&&(a[m]=[]),a[m].push(o.length/3-1)}r.setAttribute("position",new Mu(o,3)),r.setAttribute("color",new Mu(s,3));super(r,i);this.type="CameraHelper",this.camera=e,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=a,this.update()}update(){let e=this.geometry,r=this.pointMap,i=!0;Yt.projectionMatrixInverse.elements=[.5112609807824982,-0,-0,-0,-0,.41421356237309503,-0,-0,-0,-0,-0,-.099999,-0,-0,-1.0000000000000002,.100001];let o=1,s=1,a=i?.8:1e-4;ir("n1",r,e,Yt,-o,-s,a),ir("n2",r,e,Yt,o,-s,a),ir("n3",r,e,Yt,-o,s,a),ir("n4",r,e,Yt,o,s,a);let l=a;ir("f1",r,e,Yt,-o,-s,l),ir("f2",r,e,Yt,o,-s,l),ir("f3",r,e,Yt,-o,s,l),ir("f4",r,e,Yt,o,s,l);let c=l,p=.5;ir("u1",r,e,Yt,o*.7*p,s*1.1,c),ir("u2",r,e,Yt,-o*.7*p,s*1.1,c),ir("u3",r,e,Yt,0,s*(1.1+.9*p),c),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};function ir(n,t,e,r,i,o,s){da.set(i,o,s).unproject(r);let a=t[n];if(a!==void 0){let l=e.getAttribute("position");for(let c=0,p=a.length;c<p;c++)l.setXYZ(a[c],da.x,da.y,da.z)}}var ua=class extends yr(Jl){constructor(e){super(e);this.object=e;this.object=e,this.name=`CombinedCameraHelper: ${e.uuid}`}updateMatrixWorld(e){super.updateMatrixWorld(e),this.updateTarget()}updateTarget(){let e=this.object.getTarget();this.updateWorldMatrix(!0,!1),this.worldToLocal(e)}raycast(e,r){gr(this.object,this.geometry,e,r,!0)}};import{DirectionalLightHelper as ES}from"three";var bo=class extends yr(ES){constructor(e,r=15,i=10066329){super(e,r,i);this.object=e;this.name=`DirectionalLightHelper: ${e.uuid}`}raycast(e,r){gr(this.object,bo.geometryHelper,e,r)}};import{AxesHelper as GS}from"three";var vo=class extends yr(GS){constructor(e,r=15){super(r);this.object=e;this.object.updateMatrixWorld(),this.name=`EmptyObjectHelper: ${e.uuid}`,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1}raycast(e,r){gr(this.object,vo.geometryHelper,e,r)}update(){}};import{PointLightHelper as zS}from"three";var So=class extends yr(zS){constructor(e,r=15,i=6710886){super(e,r,i);this.object=e;this.name=`PointLightHelper: ${e.uuid}`}raycast(e,r){gr(this.object,So.geometryHelper,e,r)}};import{SpotLightHelper as RS,Vector3 as VS}from"three";var ma=class extends yr(RS){constructor(e,r=6710886){super(e,r);this.object=e;this.name=`SpotLightHelper: ${e.uuid}`}raycast(e,r){gr(this.object,ma.geometryHelper,e,r)}update(){if(this.object!==void 0){let e=ma._vector,r=this.object.distance?this.object.distance:1e3,i=r*Math.tan(this.object.angle);this.cone.scale.set(i,i,r),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 s=0,a=this.cone.material.length;s<a;s++)this.cone.material[s].color.set(o);else this.cone.material.color.set(o)}}},Ln=ma;Ln._vector=new VS;var xr=(n,t)=>class extends n{constructor(){super(...arguments);this.objectHelper=new t(this);this.enableHelper=!1}set visibility(i){this.visible=i,this.setHelperVisibility(i),this.setHelperChildrenVisibility(i)}get visibility(){return this.visible}get geometryHelper(){return t.geometryHelper}setHelperVisibility(i){this.objectHelper.visible=i}setHelperChildrenVisibility(i){for(let o of this.children)Jt(o)&&o.traverseEntity(s=>{Or(s)&&s.visible&&(s.objectHelper.visible=i)})}raycast(i,o){this.objectHelper.raycast(i,o)}copy(i,o=!0){return super.copy(i,o),i.enableHelper!==void 0&&(this.enableHelper=i.enableHelper),i.objectHelper!==void 0&&(this.objectHelper.visible=i.objectHelper.visible),this}toJSON(i){let o=super.toJSON(i),s=o.object;return s.enableHelper=this.enableHelper,o}fromJSON(i){return super.fromJSON(i),i.enableHelper!==void 0&&(this.enableHelper=!0),this}fromLightState(i,o){if(this.objectType==="LightDirectional"||this.objectType==="LightPoint"||this.objectType==="LightSpot"){let s=this;i.color!==void 0&&(s.color=Ye(i.color,o)),i.intensity!==void 0&&(s.intensity=i.intensity),i.depth!==void 0&&(s.shadow.camera.far=i.depth,s.shadow.needsUpdate=!0),i.shadows!==void 0&&(this.castShadow=i.shadows),i.helper!==void 0&&(this.enableHelper=i.helper,s.gizmos.shadowmap.visible=i.helper)}return this}};var wo=new Ft,Kl=new Ft,Dr=class extends xr(Kt(FS),ua){constructor(e=window.innerWidth,r=window.innerHeight,i=45,o,s=1e5){super();this.objectType="CombinedCamera";this._cameraType="OrthographicCamera";this.targetOffset=li.DefaultTargetOffset;this.isUpVectorFlipped=!1;this.angleOffsetFromUp=0;this.width=e,this.height=r,this.orthoCamera=new jS(e*-.5,e*.5,r*.5,r*-.5,o!=null?o:-5e4,s),this.perspCamera=new US(i,e/r,o!=null?o:50,s),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,r){let i=new Dr().fromState(r);return i.enableHelper=!0,i.objectHelper.update(),i.uuid=e,i}get isPerspectiveCamera(){return this.cameraType==="PerspectiveCamera"}get isOrthographicCamera(){return!this.isPerspectiveCamera}get cameraType(){return this._cameraType}setNear(e,r){e==="PerspectiveCamera"?this.perspCamera.near=r:this.orthoCamera.near=r}setZoom(e,r){r>=0&&(e==="PerspectiveCamera"?this.perspCamera.zoom=r:this.orthoCamera.zoom=r)}set cameraType(e){e==="PerspectiveCamera"?this.toPerspective():e==="OrthographicCamera"&&this.toOrthographic()}get near(){return this._cameraType==="PerspectiveCamera"?this.perspCamera.near:this.orthoCamera.near}set near(e){this._cameraType==="PerspectiveCamera"?this.perspCamera.near=e:this.orthoCamera.near=e}get zoom(){return this._cameraType==="PerspectiveCamera"?this.perspCamera.zoom:this.orthoCamera.zoom}set zoom(e){e>=0&&(this._cameraType==="PerspectiveCamera"?this.perspCamera.zoom=e:this.orthoCamera.zoom=e)}lookAt(e){super.lookAt(e),this.getWorldPosition(wo),this.targetOffset=wo.distanceTo(e)}getTarget(e=new Ft){return this.getWorldDirection(Kl),this.getWorldPosition(wo),Kl.multiplyScalar(this.targetOffset),e.copy(wo).add(Kl),e}getDistanceToTarget(){let e=this.getTarget();return this.getWorldPosition(wo),wo.distanceTo(e)}updateUp(){let e=this.getWorldQuaternion(new kS),r=new Ft(0,0,1).applyQuaternion(e),i=new Ft().copy(Ou.DefaultUp);this.isUpVectorFlipped&&i.negate(),i.applyQuaternion(e);let o=new Ft().copy(Ou.DefaultUp).projectOnPlane(r),s=new Ft().crossVectors(o,i).dot(r)>=0?1:-1;this.angleOffsetFromUp=o.angleTo(i)*s}getViewFrontToObject(e){let r=e.getWorldPosition(new Ft),o=e.getWorldDirection(new Ft).multiplyScalar(this.targetOffset);return{position:r.clone().add(o),target:r}}getViewToObject(e){let r=e.getWorldPosition(new Ft),o=this.getWorldDirection(new Ft).multiplyScalar(this.targetOffset);return{position:r.clone().sub(o),target:r}}setViewplaneSize(e,r){this.left=-e*.5,this.right=e*.5,this.top=r*.5,this.bottom=-r*.5,this.aspect=e/r,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,r,i,o,s,a){this._cameraType==="PerspectiveCamera"?this.perspCamera.setViewOffset(e,r,i,o,s,a):this.orthoCamera.setViewOffset(e,r,i,o,s,a)}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,r){super.updateWorldMatrix(e,r),this.matrixWorldInverse.copy(this.matrixWorld).invert()}copy(e,r){return super.copy(e,r),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 r={near:this.orthoCamera.near,far:this.orthoCamera.far},i={near:this.perspCamera.near,far:this.perspCamera.far};return this.copy(e),this.name="",this.enableHelper=!0,this.objectHelper.visible=!0,this.orthoCamera.near=r.near,this.orthoCamera.far=r.far,this.perspCamera.near=i.near,this.perspCamera.far=i.far,this.updateProjectionMatrix(),this}toJSON(e){let r=super.toJSON(e),i=r.object;return i.objectType="CombinedCamera",i.cameraType=this.cameraType,i.targetOffset=this.targetOffset,i.isUpVectorFlipped=this.isUpVectorFlipped,i.angleOffsetFromUp=this.angleOffsetFromUp,i.left=this.left,i.right=this.right,i.top=this.top,i.bottom=this.bottom,this.view!==null&&(i.view=Object.assign({},this.view)),i.zoomOrtho=this.orthoCamera.zoom,i.nearOrtho=this.orthoCamera.near,i.far=this.far,i.aspect=this.aspect,i.fov=this.fov,i.focus=this.focus,i.filmGauge=this.filmGauge,i.filmOffset=this.filmOffset,i.zoomPersp=this.perspCamera.zoom,i.nearPersp=this.perspCamera.near,r}fromJSON(e){var r;if(super.fromJSON(e),this.cameraType=e.cameraType,e.targetOffset!==void 0&&(this.targetOffset=e.targetOffset),e.orbitControlsTarget!==void 0){let i=this.getWorldPosition(new Ft),o=new Ft().fromArray(e.orbitControlsTarget);this.targetOffset=o.distanceTo(i)}else e.targetOffset!==void 0&&(this.targetOffset=e.targetOffset);return this.isUpVectorFlipped=!1,this.angleOffsetFromUp=(r=e.angleOffsetFromUp)!=null?r: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 r={type:this.cameraType,far:this.far,orthographic:{near:this.orthoCamera.near,zoom:this.orthoCamera.zoom},perspective:{near:this.perspCamera.near,fov:this.perspCamera.fov,zoom:this.perspCamera.zoom},up:this.up.toArray(),targetOffset:this.targetOffset,isUpVectorFlipped:this.isUpVectorFlipped};return Fi(r,e)}fromCameraState(e){let{orthographic:r,perspective:i}=e;return e.type!==void 0&&(this.cameraType=e.type),e.far!==void 0&&(this.far=e.far),r!==void 0&&(r.near!==void 0&&(this.orthoCamera.near=r.near),r.zoom!==void 0&&(this.orthoCamera.zoom=r.zoom)),i!==void 0&&(i.near!==void 0&&(this.perspCamera.near=i.near),i.fov!==void 0&&(this.perspCamera.fov=i.fov),i.zoom!==void 0&&(this.perspCamera.zoom=i.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 W(P(P({},super.toState(e)),this.toCameraState(e)),{type:this.cameraType})}fromState(e){return super.fromState(e),this.fromCameraState(e),this}};import{Group as HS}from"three";var _r=class extends xr(Kt(HS),vo){constructor(){super(...arguments);this.objectType="EmptyObject"}static createFromState(e,r){let i=new _r().fromState(r);return i.uuid=e,i.enableHelper=!0,i.objectHelper.update(),i}toJSON(e){let r=super.toJSON(e);return r.object.objectType="EmptyObject",r}};import{DirectionalLight as qS,CameraHelper as fa}from"three";var Lo=class extends xr(Kt(qS),bo){constructor(...e){super(...e);this.objectType="LightDirectional";this._gizmos={};this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024;let i=this.shadow.camera;i.top=1250,i.bottom=-1250,i.right=1250,i.left=-1250,i.near=1,i.far=2500;let o=new fa(this.shadow.camera);o.visible=!1,this._gizmos.shadowmap=o,this.update()}static createFromState(e,r,i){let o=new Lo().fromState(r,i);return o.uuid=e,o}get gizmos(){return this._gizmos}showGizmos(){for(let e in this._gizmos){let r=this._gizmos[e];r instanceof fa&&(r.visible=!0)}}hideGizmos(){for(let e in this._gizmos){let r=this._gizmos[e];r instanceof fa&&(r.visible=!1)}}update(){this.shadow.camera.updateProjectionMatrix();for(let e in this._gizmos){let r=this._gizmos[e];r instanceof fa&&r.update()}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.enableHelper===!0&&this.objectHelper.visible===!0&&this.objectHelper.update()}copy(e,r=!0){return super.copy(e,r),this.color.copy(e.color),this.intensity=e.intensity,this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}toJSON(e){let r=super.toJSON(e),i=r.object;return i.objectType="LightDirectional",i.color=this.color.getHex(),i.intensity=this.intensity,i.shadow=this.shadow.toJSON(),r}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 r=this.shadow.camera,i=e.shadow.camera;return r.near=i.near,r.far=i.far,r.zoom=i.zoom,r.left=i.left,r.right=i.right,r.top=i.top,r.bottom=i.bottom,i.view!==void 0&&(r.view=Object.assign({},i.view)),this}fromDirectionalLightState(e,r){let i=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,r),e.size!==void 0&&Xd(this,e.size),i&&this.update(),this}fromState(e,r){return super.fromState(e),this.fromDirectionalLightState(e,r),this}};import{PointLight as WS,Vector3 as ya,Box3 as $S,Box3Helper as ga,Color as JS}from"three";var Co=class extends xr(Kt(WS),So){constructor(...e){super(...e);this.objectType="LightPoint";this._gizmos={};this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024;let i=this.shadow.camera;i.fov=90,i.aspect=1,i.near=100,i.far=2500;let o=new ya(-i.far+this.position.x,-i.far+this.position.y,-i.far+this.position.z),s=new ya(i.far+this.position.x,i.far+this.position.y,i.far+this.position.z),a=new $S(o,s),l=new ga(a,new JS(16755200));l.visible=!1,this._gizmos.shadowmap=l,this.update()}static createFromState(e,r,i){let o=new Co().fromState(r,i);return o.uuid=e,o}get gizmos(){return this._gizmos}showGizmos(){for(let e in this._gizmos){let r=this._gizmos[e];r instanceof ga&&(r.visible=!0)}}hideGizmos(){for(let e in this._gizmos){let r=this._gizmos[e];r instanceof ga&&(r.visible=!1)}}update(){if(this.shadow&&(this.shadow.camera.updateProjectionMatrix(),this._gizmos))for(let e in this._gizmos){let r=this._gizmos[e];if(r instanceof ga){let i=this.shadow.camera,o=new ya(-i.far+this.position.x,-i.far+this.position.y,-i.far+this.position.z),s=new ya(i.far+this.position.x,i.far+this.position.y,i.far+this.position.z);r.box.set(o,s),r.updateMatrixWorld(!0)}}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.enableHelper===!0&&this.objectHelper.visible===!0&&this.objectHelper.update()}copy(e,r=!0){return super.copy(e,r),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 r=super.toJSON(e),i=r.object;return i.objectType="LightPoint",i.color=this.color.getHex(),i.intensity=this.intensity,i.distance=this.distance,i.decay=this.decay,i.shadow=this.shadow.toJSON(),r}fromJSON(e){var o,s;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((s=e.shadow.mapSize)!=null?s:[512,512]),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null);let r=this.shadow.camera,i=e.shadow.camera;return r.near=i.near,r.far=i.far,r.zoom=i.zoom,r.fov=i.fov,r.focus=i.focus,r.aspect=i.aspect,r.filmGauge=i.filmGauge,r.filmOffset=i.filmOffset,i.view!==void 0&&(r.view=Object.assign({},i.view)),this}fromPointLightState(e,r){return super.fromLightState(e,r),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,r){return super.fromState(e),this.fromPointLightState(e,r),this}};import{SpotLight as KS,CameraHelper as xa,MathUtils as YS,Vector3 as Du,Quaternion as XS}from"three";var Iu=new Du,Pu=new Du,Au=new XS,To=class extends xr(Kt(KS),Ln){constructor(...e){super(...e);this.objectType="LightSpot";this._gizmos={};this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024;let i=this.shadow.camera;i.fov=YS.RAD2DEG*2*this.angle,i.aspect=1,i.near=100,i.far=2500;let o=new xa(this.shadow.camera);o.visible=!1,this._gizmos.shadowmap=o,this.update()}static createFromState(e,r,i){let o=new To().fromState(r,i);return o.uuid=e,o}get gizmos(){return this._gizmos}showGizmos(){for(let e in this._gizmos){let r=this._gizmos[e];r instanceof xa&&(r.visible=!0)}}hideGizmos(){for(let e in this._gizmos){let r=this._gizmos[e];r instanceof xa&&(r.visible=!1)}}update(){this.shadow.camera.updateProjectionMatrix();for(let e in this._gizmos){let r=this._gizmos[e];r instanceof xa&&r.update()}}updateMatrixWorld(e){super.updateMatrixWorld(e),Pu.setFromMatrixPosition(this.matrixWorld),Au.setFromRotationMatrix(this.matrixWorld),Iu.copy(this.up).applyQuaternion(Au).negate().multiplyScalar(this.distance),this.target.position.copy(Pu).add(Iu),this.target.updateMatrixWorld(),this.enableHelper===!0&&this.objectHelper.visible===!0&&this.objectHelper.update()}copy(e,r=!0){return super.copy(e,r),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 r=super.toJSON(e),i=r.object;return i.objectType="LightSpot",i.color=this.color.getHex(),i.intensity=this.intensity,i.distance=this.distance,i.angle=this.angle,i.decay=this.decay,i.penumbra=this.penumbra,i.shadow=this.shadow.toJSON(),r}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 r=this.shadow.camera,i=e.shadow.camera;return r.near=i.near,r.far=i.far,r.zoom=i.zoom,r.fov=i.fov,r.focus=i.focus,r.aspect=i.aspect,r.filmGauge=i.filmGauge,r.filmOffset=i.filmOffset,i.view!==void 0&&(r.view=Object.assign({},i.view)),this}fromSpotLightState(e,r){return super.fromLightState(e,r),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,r){return super.fromState(e),this.fromSpotLightState(e,r),this}};var No=class extends at{constructor(e,r=new Vt){super(e,r);this.objectType="Mesh3D";this.castShadow=!0,this.receiveShadow=!0}toJSON(e){let r=super.toJSON(e);return r.object.objectType="Mesh3D",r}};var Mo=class extends No{constructor(e,r=new Vt){super(e,r);this.objectType="NonParametric"}toJSON(e){let r=super.toJSON(e);return r.object.objectType="NonParametric",r}};import{DoubleSide as ZS,Mesh as QS,MeshBasicMaterial as ew,ShapeBufferGeometry as tw,Vector2 as rw,Vector3 as iw}from"three";import{FontLoader as ow}from"three/examples/jsm/loaders/FontLoader.js";var Xe=class extends QS{constructor({char:e,originalChar:r,fontFamily:i,letterSpacing:o,fontSize:s,LOD:a=16},l=new ew({color:0,opacity:1,visible:!0,transparent:!0,side:ZS})){let c=Xe.loadChar(e,i,a);super(c.geometry,l);this.char=e,this.originalChar=r!=null?r:e,this.fontFamily=i,this.letterSpacing=o,this.fontSize=s,this.LOD=a,this.resolution=c.resolution,this.glyphsHa=c.glyphsHa,this.localPosition=new rw,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 Xe._fontPath}static set FONTS_PATH(e){Xe._fontPath=e}updatePosition(e,r){this.localPosition.copy(e);let i=new iw(this.localPosition.x,-this.localPosition.y,0);this.position.copy(i).add(r)}updateFontSize(e){let r=e/this.resolution;this.fontSize=e,this.scale.set(this.fontSize,this.fontSize,1),this.charSize=this.glyphsHa*r*this.letterSpacing}updateFontFamily(e){if(this.fontFamily===e)return;this.fontFamily=e;let r=Xe.loadChar(this.char,e,this.LOD);this.geometry=r.geometry,this.resolution=r.resolution,this.glyphsHa=r.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 r=Xe.loadChar(e,this.fontFamily,this.LOD);this.geometry=r.geometry,this.resolution=r.resolution,this.glyphsHa=r.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 r=Xe.loadChar(this.char,this.fontFamily,this.LOD);this.geometry=r.geometry,this.resolution=r.resolution,this.glyphsHa=r.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 Xe(e).copy(this)}static loadFont(e){return new Promise(function(r,i){Xe.fontCache[e]?r(Xe.fontCache[e]):new ow().load(Xe.FONTS_PATH+e+".json",s=>{Xe.fontCache[e]=s,r(s)},void 0,i)})}static loadChar(e,r,i){if(Xe.charCache[e]){if(Xe.charCache[e][i]&&Xe.charCache[e][i].fontFamily===r)return Xe.charCache[e][i]}else Xe.charCache[e]={};let o=Xe.fontCache[r],s=o.generateShapes(e,1);return Xe.charCache[e][i]={geometry:new tw(s,i),fontFamily:r,resolution:o.data.resolution,glyphsHa:o.data.glyphs[e].ha},Xe.charCache[e][i]}},Mt=Xe;Mt.charCache={},Mt.fontCache={},Mt._fontPath="/_assets/_fonts/";import{DoubleSide as va,MeshBasicMaterial as Bu,Vector3 as Eu,Object3D as nw}from"three";import{Vector2 as _u}from"three";var ba=new _u,ei=class{constructor(t,e,r){this.message=[];this.endLine=!0;this.yLinePos=t,this.lineHeight=e,this.maxCharSize=r,this.nextChar3DPos=new _u(0,this.yLinePos+this.maxCharSize*this.lineHeight),this.align=1}addChar3D(t,e,r=this.message.length){this.message.splice(r,0,t),t.fontSize>this.maxCharSize?(this.maxCharSize=t.fontSize,this.nextChar3DPos.y=this.yLinePos+this.maxCharSize*this.lineHeight,this.fullUpdate(e)):(t.updatePosition(this.nextChar3DPos,e),this.nextChar3DPos.x+=t.charSize)}deleteChar3D(t=this.message.length-1){let e=this.message[t];if(e)return this.message.splice(t,1),this.nextChar3DPos.x-=e.charSize,e}isEndLine(t){this.endLine=t}fullUpdate(t,e=0){this.nextChar3DPos.x=0;for(let r=e,i=this.message.length;r<i;r+=1)this.message[r].updatePosition(this.nextChar3DPos,t),this.nextChar3DPos.x+=this.message[r].charSize}checkOverFlow(t){let e,r=this.message.length-1;if(r<=0)return!1;for(;r>=0;){if(this.message[r].char!==" "){e=this.message[r];break}r-=1}return!!(r>=0&&e&&e.localPosition.x+e.charSize>t)}containSpaceOverFlow(t=this.message.length-1){for(let e=t;e>=0;e-=1)if(this.message[e].char===" ")return!0;return!1}containSpace(t=this.message.length-1){if(this.endLine)return!0;for(let e=t;e>=0;e-=1)if(this.message[e].char===" ")return!0;return!1}popWord(t=this.message.length-1){let e=[],r=!0,i;for(i=t;i>=0;i-=1)if(this.message[i].char===" "){r=!1,e.length===0&&(i-=1,e.splice(0,0,this.message[i]));break}else e.splice(0,0,this.message[i]);return r?e=[]:this.message.splice(i+1,e.length),e}getWord(t=0,e=1){let r=[],i=t;for(i=t;;i+=e){if(!this.message[i]||this.message[i].char===" "){r.length===0&&this.message[i]&&(r.push(this.message[i]),this.message.splice(i,1));break}e>0?(r.push(this.message[i]),this.message.splice(i,1),i-=e):(r.splice(0,0,this.message[i]),this.message.splice(i,1))}return r}getWordAtIndex(t){let e=[];for(let r=t;r<this.message.length&&this.message[r].char!==" ";r++)e.push(this.message[r]);for(let r=t-1;r>=0&&this.message[r].char!==" ";r--)e.splice(0,0,this.message[r]);return e}wordSize(t=0,e=-1){let r=0,i=t;for(;i>=0&&i<this.message.length;){if(this.message[i].char===" "){r===0&&(r=this.message[i].charSize);break}r+=this.message[i].charSize,i+=e}return(i<0||i>=this.message.length)&&!this.endLine?this.message[t]?this.message[t].charSize:999999999:r===0?999999999:r}spaceLeft(t){return t-this.nextChar3DPos.x}popChar(t=this.message.length-1){return this.nextChar3DPos.x-=this.message[t].charSize,this.message.splice(t,1)}isEmpty(){return!this.message.length}updateNextCharPosY(){this.nextChar3DPos.y=this.yLinePos+this.maxCharSize*this.lineHeight}updateYLinePos(t){this.yLinePos=t,this.updateNextCharPosY()}updatelineHeight(t){this.lineHeight=t,this.updateNextCharPosY()}updateFontSize(t,e=0,r=this.message.length-1){for(let i=e;i<=r;i+=1)this.message[i].updateFontSize(t);this.maxCharSize=t,this.nextChar3DPos.y=this.yLinePos+this.maxCharSize*this.lineHeight}countSpaces(){let t=0;for(let e=0;e<this.message.length;e++)this.message[e].char===" "&&(t+=1);return t}alignText(t,e,r,i,o){switch(r){case 1:this.leftAlign(t,o);break;case 3:this.centerAlign(this.spaceLeft(e),t,o);break;case 2:this.rightAlign(this.spaceLeft(e),t,o);break;case 4:this.justifyAlign(this.spaceLeft(e),t,o);break}}offsetCharacters(t,e,r){ba.set(e,r);let i=this.message.length;for(let o=0;o<i;o++)this.message[o].updatePosition(this.message[o].localPosition.add(ba),t)}leftAlign(t,e){this.align=1,this.offsetCharacters(t,0,e)}centerAlign(t,e,r){this.align=3,this.offsetCharacters(e,t/2,r)}rightAlign(t,e,r){this.align=2,this.offsetCharacters(e,t,r)}justifyAlign(t,e,r){if(this.align=4,this.endLine){this.offsetCharacters(e,0,r);return}let i=this.countSpaces();if(i===0){this.offsetCharacters(e,0,r);return}let o=t/i,s=0;for(let a=0;a<this.message.length;a++)this.message[a].char===" "&&(s+=o),ba.set(s,r),this.message[a].updatePosition(this.message[a].localPosition.add(ba),e)}clone(){let t=new ei(this.yLinePos,this.lineHeight,this.maxCharSize);t.nextChar3DPos=this.nextChar3DPos.clone(),t.align=this.align,t.endLine=this.endLine;for(let e=0;e<this.message.length;e++)t.message.push(this.message[e].clone());return t}};var Yl=class extends at{constructor(e,r=new mt({transparent:!0,opacity:1,visible:!1,side:va})){super(e,r);this.objectType="TextFrame";this.charContainer=new nw,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:1,horizontalAlignment:1,verticalAlignment:1,LOD:16,maxLineSize:this._geometryUserData.parameters.width,textOrigin:new Eu(this._geometryUserData.parameters.width*-.5,this._geometryUserData.parameters.height*.5,0),textLines:[]},this.createTextLine()}static createFromState(e,r,i){let o=$s.create({parameters:{width:r.width,height:r.height}}),s=new Yl(o).fromState(r,i);return s.uuid=e,s}async updateText(e){this.clearText();let r=this.userData.textFrame,i=r.fontFamily;await Mt.loadFont(i),r.text=e;let o=r.textOrigin,s=new Bu({visible:r.visible,transparent:!0,side:va}),a=e.split(`
|
|
958
|
-
`),l=0;this.userData.textFrame.textLines=a.map((c,p)=>{let h=new ei(l,r.lineHeight,r.fontSize);return h.message=c.split("").map(d=>{let m={char:d,fontFamily:i,letterSpacing:r.letterSpacing,fontSize:r.fontSize,LOD:16},f=s.clone();f.color=r.hexColor,f.opacity=r.opacity;let T=new Mt(m,f);return h.addChar3D(T,o),this.charContainer.add(T),T}),l+=h.maxCharSize*h.lineHeight,h}),this.textFullUpdate(),this.checkOverFlow()}clearText(){let e=this.userData.textFrame.textLines;for(;this.charContainer.children.length;){let r=this.charContainer.children[0];this.charContainer.remove(r)}for(;e.length;)e.pop()}raycast(e,r){let i=[];if(super.raycast(e,i),i.length>0){r.push(i[0]);return}let o=[];for(let s=0,a=this.charContainer.children.length;s<a;++s)if(this.charContainer.children[s]instanceof Mt&&(e.intersectObject(this.charContainer.children[s],!1,o),o.length>0)){o[0].object=this,r.push(o[0]);return}}updateGeometry(e){var p,h,d,m;let r=this.userData,i=this.geometry.userData,o=i.parameters.width,s=i.parameters.height,a=(h=(p=e.parameters)==null?void 0:p.width)!=null?h:o,l=(m=(d=e.parameters)==null?void 0:d.height)!=null?m:s,c=r.textFrame;super.updateGeometry(e),c.maxLineSize=a,c.textOrigin.set(-.5*a,.5*l,0),l!==s?(this.checkOverFlow(),this.checkCapacity()):a!==o&&(o<a?this.checkCapacity():o>a&&this.checkOverFlow())}checkOverFlow(e=0){let r=this.userData,i=r.textFrame.textOrigin,o=r.textFrame.textLines;for(let s=e;s<o.length;s++){o[s].updateYLinePos(this.getNewLinePosition(s)),o[s].fullUpdate(i);let a=[];for(;o[s].checkOverFlow(r.textFrame.maxLineSize);)o[s].containSpaceOverFlow()?a.unshift(o[s].getWord(o[s].message.length-1,-1)):a.unshift(o[s].popChar());if(a.length>0){o[s+1]===void 0?(o[s].isEndLine(!1),this.createTextLine()):o[s].endLine&&(this.createTextLine(s+1),o[s].isEndLine(!1),o[s+1].isEndLine(!0));let l=0;for(let c=0;c<a.length;c+=1)for(let p=0;p<a[c].length;p+=1)o[s+1].addChar3D(a[c][p],i,l),l+=1;o[s+1].fullUpdate(i)}o[s].fullUpdate(i)}this.textFullUpdate(e)}checkCapacity(e=0){let r=this.userData,i=r.textFrame.textOrigin,o=r.textFrame.maxLineSize,s=r.textFrame.textLines;for(let a=e;a<s.length;a+=1)if(s[a].updateYLinePos(this.getNewLinePosition(a)),s[a].fullUpdate(i),!!s[a-1])for(;!s[a-1].endLine;){let l,c=s[a-1].spaceLeft(o);if(s[a].wordSize(0,1)<=c){s[a].containSpace()?l=s[a].getWord(0,1):l=s[a].popChar(0);for(let p=0;p<l.length;p+=1)l[p]&&s[a-1].addChar3D(l[p],i)}else{s[a].isEmpty()?(s[a].endLine&&s[a-1].isEndLine(!0),s.splice(a,1),a-=1):(s[a].updateYLinePos(this.getNewLinePosition(a)),s[a].fullUpdate(i));break}}this.textFullUpdate(e)}createTextLine(e=this.userData.textFrame.textLines.length){let i=this.userData.textFrame;i.textLines.splice(e,0,new ei(this.getNewLinePosition(e),i.lineHeight,i.fontSize))}textFullUpdate(e=0){let i=this.userData.textFrame,o=i.textLines,s=this.getVerticalAlignmentOffSet();for(let a=e;a<o.length;a++)o[a].updateYLinePos(this.getNewLinePosition(a)),o[a].fullUpdate(i.textOrigin),o[a].alignText(i.textOrigin,i.maxLineSize,i.horizontalAlignment,i.verticalAlignment,s)}getVerticalAlignmentOffSet(){switch(this.userData.textFrame.verticalAlignment){case 1:return 0;case 2:return this.getRemainingVerticalSpace()/2;case 3:return this.getRemainingVerticalSpace();default:return 0}}getRemainingVerticalSpace(){let r=this.userData.textFrame.textLines;return this.geometry.userData.parameters.height-this.getNewLinePosition(r.length)}getNewLinePosition(e){let i=this.userData.textFrame.textLines,o=0;for(let s=0;s<e;s+=1)o+=i[s].maxCharSize*i[s].lineHeight;return o}updateColor(e){var o;let r=this.userData;r.textFrame.hexColor=e;let i=r.textFrame.textLines;for(let s=0;s<i.length;s++){let a=i[s].message;for(let l=0;l<a.length;l++){let c=a[l].material;(o=c.color)!=null&&o.isColor&&(c.color=e)}}}updateOpacity(e){let r=this.userData;r.textFrame.opacity=e;let i=r.textFrame.textLines;for(let o=0;o<i.length;o++){let s=i[o].message;for(let a=0;a<s.length;a++){let l=s[a].material;l.opacity=e}}}updateVisible(e){let r=this.userData;r.textFrame.visible=e;let i=r.textFrame.textLines;for(let o=0;o<i.length;o++){let s=i[o].message;for(let a=0;a<s.length;a++){let l=s[a].material;l.visible=e}}}async updateFontFamily(e){await Mt.loadFont(e);let i=this.userData.textFrame,o=i.textLines;i.fontFamily=e;for(let s=0;s<o.length;s++){let a=o[s].message;for(let l=0;l<a.length;l++)a[l].updateFontFamily(e)}this.textFullUpdate(),this.checkOverFlow(),this.checkCapacity()}updateFontSize(e){let i=this.userData.textFrame,o=i.textLines,s=i.fontSize;i.fontSize=e;for(let a=0;a<o.length;a++)o[a].updateFontSize(e);this.textFullUpdate(),e>s?this.checkOverFlow():e<s&&this.checkCapacity()}async updateTextTransform(e){let i=this.userData.textFrame;await Mt.loadFont(i.fontFamily);let o=i.textLines;switch(i.textTransform=e,e){case 2:for(let s=0;s<o.length;s++){let a=o[s].message;for(let l=0;l<a.length;l++)o[s].message[l].updateChar(a[l].char.toUpperCase())}break;case 3:for(let s=0;s<o.length;s++){let a=o[s].message;for(let l=0;l<a.length;l++)o[s].message[l].updateChar(a[l].char.toLowerCase())}break;default:for(let s=0;s<o.length;s++){let a=o[s].message;for(let l=0;l<a.length;l++)o[s].message[l].updateChar(a[l].originalChar)}}this.textFullUpdate(),this.checkOverFlow(),this.checkCapacity()}updateLetterSpacing(e){let r=this.userData,i=r.textFrame.textLines;r.textFrame.letterSpacing=e;for(let o=0;o<i.length;o++){let s=i[o].message;for(let a=0;a<s.length;a++)s[a].updateLetterSpacing(e)}this.textFullUpdate(),this.checkOverFlow(),this.checkCapacity()}updateLOD(e){let r=this.userData;r.textFrame.LOD=e;let i=r.textFrame.textLines;for(let o=0;o<i.length;o++);this.textFullUpdate(),this.checkOverFlow(),this.checkCapacity()}updateLineHeight(e){let r=this.userData,i=r.textFrame.textLines;r.textFrame.lineHeight=e;for(let o=0;o<i.length;o++)i[o].updatelineHeight(e);this.textFullUpdate()}updateVerticalAlignment(e){let r=this.userData;r.textFrame.verticalAlignment=e,this.textFullUpdate()}updateHorizontalAlignment(e){let r=this.userData;r.textFrame.horizontalAlignment=e,this.textFullUpdate()}toJSON(e){let r=super.toJSON(e),i=r.object;i.objectType="TextFrame";let s=this.userData.textFrame.textLines.map(a=>{let l=a.message.map(c=>({char:c.char,originalChar:c.originalChar,fontFamily:c.fontFamily,letterSpacing:c.letterSpacing,fontSize:c.fontSize,LOD:c.LOD}));return{align:a.align,endLine:a.endLine,lineHeight:a.lineHeight,maxCharSize:a.maxCharSize,yLinePos:a.yLinePos,message:l}});return i.userData.textFrame.textLinesData=s,r}async fromJSONasync(e){if(super.fromJSON(e),e.userData!==void 0){let r=e.userData.textFrame;await Mt.loadFont(r.fontFamily),r.textOrigin=new Eu(r.textOrigin.x,r.textOrigin.y,r.textOrigin.z);let i=new Bu({color:r.hexColor,opacity:r.opacity,visible:r.visible,transparent:!0,side:va});r.textLinesData&&(r.textLines=r.textLinesData.map((o,s)=>{let a=new ei(Number(o.yLinePos),Number(o.lineHeight),Number(o.maxCharSize)),l=o.message.map((c,p)=>{if(c.char===void 0){let m=r.textLines[s].message[p];if("geometries"in m){let f=m.geometries[0].userData.parameters;Object.assign(c,{LOD:f.lod,char:f.char,fontFamily:f.fontFamily,fontSize:f.fontSize,letterSpacing:f.letterSpacing,originalChar:f.char})}}let h={char:c.char,fontFamily:c.fontFamily,letterSpacing:Number(c.letterSpacing),fontSize:Number(c.fontSize),LOD:c.LOD},d=new Mt(h,i.clone());return a.addChar3D(d,r.textOrigin),this.charContainer.add(d),d});return a.message=l,a}),this.userData.textFrame=r),this.textFullUpdate()}return this}fromTextFrameData(e,r){if(e.color!==void 0){let i=Ye(e.color,r);this.updateColor(i),this.updateOpacity(i.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,r){return super.fromState(e),this.fromTextFrameData(e,r),this}convertToVector(){let{fontFamily:e,hexColor:r}=this.userData.textFrame,i=new _r;i.name="Text Shape";let o=Mt.fontCache[e];for(let s of this.charContainer.children)s instanceof Mt&&o.generateShapes(s.char,1).forEach(a=>{let l=new Me().fromShape(a);l.applyScale(s.scale.x,s.scale.y);let c=ht.create({shape:l}),p=new mt({side:va});p.color=r;let h=new Qr(c,p);h.name=s.char,h.position.copy(s.position),h.rotation.copy(s.rotation),i.attach(h)});return i}},bi=Yl;bi.VerticalAlign=Ka,bi.HorizontalAlign=Ja,bi.TextTransform=Ya;import{HemisphereLight as vw,Scene as Sw,Vector3 as ww,Color as Ku,Fog as Lw,Box3 as Cw}from"three";import{BufferGeometryLoader as sw}from"three";function Gu(n,t){return aw(n)}function aw(n){let t={parameters:n,type:n.type};if(n.type==="VectorGeometry"){let r=Me.createFromState(n.shape,n.width,n.height);t.shape=r}else n.type==="NonParametricGeometry"&&(n.data.groups&&n.data.groups.forEach(r=>{var i;return r.materialIndex=Math.max((i=r.materialIndex)!=null?i:0,0)}),t.geometry=new sw().parse(n));let e;try{e=en(t)}catch(r){console.error(r)}if(!e){let r=Me.createFromState(Ki.defaultData(),100,100);t.shape=r,e=en(t)}return e}import{Box3 as lw,Matrix4 as vi,Sphere as Vu,Vector3 as cw}from"three";var ju=ym(Ru());var Xl;Js.then(n=>{Xl=n});var Uu=new vi,pw=new vi,hw=new vi,or=new lw,ti=new cw,dw=new vi,uw=new vi,Oo=class extends at{constructor(e,r,i,o=new Vt){super(i!=null?i:r,o);this.subdivPointer=e;this.originalGeometry=r;this.subdividedGeometry=i;this.objectType="SubdivObject";this.hiddenMatrixOld=new vi;this.smoothShading=!0;this.matrixWorldRigid=new vi;this.castShadow=!0,this.receiveShadow=!0,this.forceComputeSize=!1}static createFromState(e,r,i){let{subdivPointer:o,originalGeometry:s,subdividedGeometry:a}=zt.build(r.geometry,void 0,void 0,!r.flatShading),l=wn(r.material,i),c=new Oo(o,s,a||void 0,l);return c.calcBoundingBox(),c.freeSubdivPointer(),c.uuid=e,c.fromState(r),c}shallowClone(e){return new Mo(this.geometry,this.material).shallowCopy(this,e)}toJSON(e){let r=super.toJSON(e);return r.object.objectType="SubdivObject",r}buildFromStore(e){var s,a,l;let{originalGeometry:r,subdividedGeometry:i,subdivPointer:o}=zt.build(e,this.subdivPointer,void 0,this.smoothShading,this.shearScale);if(this.subdivPointer=o,r!==void 0&&((s=this.originalGeometry)==null||s.dispose(),this.originalGeometry=r),i!==void 0&&((a=this.subdividedGeometry)==null||a.dispose(),this.subdividedGeometry=i!=null?i:void 0),this.geometry=(l=this.subdividedGeometry)!=null?l:this.originalGeometry,this.cloner)for(let c of this.cloner.children)c.geometry=this.geometry;e.width&&(this.geometry.userData.parameters={width:e.width,height:e.height,depth:e.depth})}updateMesh(e=!1){zt.buildLevel(this.subdivPointer,!0,this.smoothShading,this.originalGeometry,e?this.shearScaleInv:void 0),this.subdividedGeometry&&zt.buildLevel(this.subdivPointer,!1,this.smoothShading,this.subdividedGeometry,e?this.shearScaleInv:void 0)}updateTopology(){var e;this.originalGeometry.dispose(),this.originalGeometry=zt.buildLevel(this.subdivPointer,!0,this.smoothShading),this.subdividedGeometry&&(this.subdividedGeometry.dispose(),this.subdividedGeometry=zt.buildLevel(this.subdivPointer,!1,this.smoothShading)),this.geometry=(e=this.subdividedGeometry)!=null?e:this.originalGeometry}raycast(e,r){var i;this.geometry=this.originalGeometry,at.prototype.raycast.call(this,e,r),this.geometry=(i=this.subdividedGeometry)!=null?i:this.originalGeometry}updateMatrixWorldSVD(){let e=this.matrixWorld.elements,r=[[e[0],e[4],e[8]],[e[1],e[5],e[9]],[e[2],e[6],e[10]]],{u:i,v:o,q:s}=(0,ju.SVD)(r),a=Uu.set(i[0][0],i[0][1],i[0][2],0,i[1][0],i[1][1],i[1][2],0,i[2][0],i[2][1],i[2][2],0,0,0,0,1),l=pw.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),c=hw.copy(l).transpose();this.shearScale=dw.makeScale(s[0],s[1],s[2]).multiply(c).premultiply(l),this.shearScaleInv=uw.copy(this.shearScale).invert(),this.matrixWorldRigid.multiplyMatrices(a,c),s.every(p=>Math.abs(s[0]-p)<.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 Vu);let r=e.attributes.position,i=e.boundingSphere.center;or.setFromBufferAttribute(r),or.getCenter(i),e.boundingSphere.radius=i.distanceTo(or.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),or.getSize(ti);let o={width:ti.x,height:ti.y,depth:ti.z};return this.geometry.userData.parameters=o,o}updateBoundingBox(e){let r=this.originalGeometry;or.min.set(e[0],e[2],e[4]),or.max.set(e[1],e[3],e[5]),this.shearScaleInv&&(or.min.applyMatrix4(this.shearScaleInv),or.max.applyMatrix4(this.shearScaleInv)),r.boundingSphere===null&&(r.boundingSphere=new Vu);let i=r.boundingSphere.center;or.getCenter(i),r.boundingSphere.radius=i.distanceTo(or.max),isNaN(r.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),or.getSize(ti);let o={width:ti.x,height:ti.y,depth:ti.z};return this.geometry.userData.parameters=o,o}freeSubdivPointer(){this.subdivPointer&&(Xl.free_bvh(this.subdivPointer),Xl.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,Fu(this.originalGeometry.attributes,...this.geometry.userData.scale),this.originalGeometry.attributes.position.needsUpdate=!0,this.originalGeometry.attributes.normal.needsUpdate=!0,this.subdividedGeometry&&(Fu(this.subdividedGeometry.attributes,...this.subdividedGeometry.userData.scale),this.subdividedGeometry.attributes.position.needsUpdate=!0,this.subdividedGeometry.attributes.normal.needsUpdate=!0),this.geometry.userData.parameters=P({},e.parameters)}};function Fu(n,t,e,r){let i=n.position.array,o=n.normal.array,s=Uu.makeScale(t,e,r).invert().elements,a,l,c;for(var p=0,h=i.length;p<h;p+=3)i[p]*=t,i[p+1]*=e,i[p+2]*=r,a=o[p],l=o[p+1],c=o[p+2],o[p]=s[0]*a+s[4]*l+s[8]*c,o[p+1]=s[1]*a+s[5]*l+s[9]*c,o[p+2]=s[2]*a+s[6]*l+s[10]*c}import{BackSide as mw,DoubleSide as fw,FrontSide as yw}from"three";function ku(n,t){t.flatShading!==void 0&&(n.flatShading=t.flatShading,n.needsUpdate=!0),t.wireframe!==void 0&&(n.wireframe=t.wireframe),t.side!==void 0&&(t.side===0?n.side=yw:t.side===1?n.side=mw:n.side=fw)}function gw(n,t){if(Array.isArray(n.material))for(let e of n.material)ku(e,t);else{let e=n.material;ku(e,t)}n.objectType==="SubdivObject"&&t.flatShading!==void 0&&(n.material.flatShading=!1,n.smoothShading=!t.flatShading,n.updateMesh())}function Hu(n,t,e){let r;if(t.geometry.type==="SubdivGeometry")r=Oo.createFromState(n,t,e);else{let i=Gu(t.geometry,e),o="materials"in t?Su(t.materials,e):wn(t.material,e);As.is2DParametricMesh(i.userData.type)?r=new xo(i,o):(i==null?void 0:i.userData.type)==="VectorGeometry"?r=new Qr(i,o):t.geometry.type==="NonParametricGeometry"?r=new Mo(i,o):r=new No(i,o),r.uuid=n,r.fromState(t)}return gw(r,t),r}function qu(n,t,e){return t.type==="Mesh"?Hu(n,t,e):t.type==="TextFrame"?bi.createFromState(n,t,e):t.type==="Empty"?_r.createFromState(n,t):t.type==="PointLight"?Co.createFromState(n,t,e):t.type==="SpotLight"?To.createFromState(n,t,e):t.type==="DirectionalLight"?Lo.createFromState(n,t,e):ji.is(t.type)?Dr.createFromState(n,t):(console.error(t),new _r)}function xw(n,t){t.uniforms[`f${t.id}_transmissionSamplerMap`].value=n.texture,t.uniforms[`f${t.id}_transmissionDepthMap`].value=n.depthTexture}function Wu(n,t,e){if(!e.userData.layers)return!1;let r=!1,i=e.userData.layers.getLayersOfType("transmission");return i.length>0?(t.layers.set(3),r=!0,n!==void 0&&i.forEach(o=>xw(n,o))):t.layers.set(0),r}function $u(n,t){let e=!1;return t.traverseEntity(r=>{if(r instanceof at)if(Array.isArray(r.material))for(let i=0;i<r.material.length;i++)Wu(n,r,r.material[i])&&(e=!0);else Wu(n,r,r.material)&&(e=!0)}),e}function Ju(n,t){"material"in n&&bw(n.material,t),"geometry"in n&&n.geometry.dispose()}function bw(n,t){oc(n).forEach(e=>{t.isSharedMaterial(e)||e.dispose()})}var Yu=new ww,Zl=class extends Ys(Sw){constructor(e,r){super();this.objectType="Scene";this.alpha=1;this.backupFog=new Lw(16777215,.1,2e3);this.fogUseBGColor=!1;this.wireframeState=!1;this.needsTransmissionDirty=!0;this._needsTransmission=!1;this._color=new Ku(1,0,0);this.bgColor=new Ku(1,1,1);this.entityByUuid={};this.ambientLight=new vw(13882323,8553090,.75),this.ambientLight.name="Default Ambient Light",this.personalCamera=this.createPersonalCamera(),this.activeCamera=this.personalCamera,this.sharedAssetManager=r,this.init(e,r)}needsTransmission(e){return this.needsTransmissionDirty&&(this._needsTransmission=$u(e,this),e!==void 0&&(this.needsTransmissionDirty=!1)),this._needsTransmission}find(e){if(e===""||e===void 0)return;let r=this.entityByUuid[e];return r===void 0?this.getObjectByProperty("uuid",e):r}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,r){if(this.createChildrenObjects(e.objects,this,r),this.personalCamera.removeFromParent(),this.add(this.personalCamera),this.ambientLight.removeFromParent(),this.add(this.ambientLight),this.setBackgroundColor(Ye(e.backgroundColor,r)),this.updateFog(e.fog,r),this.updateAmbientLight(e.environment.ambientLight,r),this.activeCamera=this.personalCamera,e.publish.playCamera!==null){let i=this.find(e.publish.playCamera);i instanceof Dr&&this.switchActiveCamera(i)}}clearScene(e){this.traverseEntity(r=>{Ju(r,e)});for(let r of this.children)Jt(r)&&r.removeFromParent()}resetAfterClear(e,r){this.init(e,r)}createPersonalCamera(){let e=Dr.createFromState(Zl.PERSONAL_CAMERA_ID,W(P({},_s.defaultData),{name:"Personal Camera"}));return e.enableHelper=!1,e.objectHelper.visible=!1,delete e.isEntity,this.registerObjectCreatedInLegacy(e),e}raycast(e){let r=[],i=o=>{for(let s of o.children)Jt(s)&&!s.raycastLock&&s.visible&&((io(s)||Or(s)&&s.enableHelper&&s.objectHelper.parent)&&e.intersectObject(s,!1,r),i(s))};return i(this),r}traverseEntity(e){for(let r of this.children)Jt(r)&&r.traverseEntity(e)}updateFog(e,r){this.enableFog=e.enabled,this.fogUseBGColor=e.useBackgroundColor,e.useBackgroundColor?this.backupFog.color.set(this.bgColor):this.backupFog.color=Ye(e.color,r),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,r){Yd(this.ambientLight,e,r),e.groundColor!==void 0&&(this.ambientLight.groundColor=Ye(e.groundColor,r)),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,r,i){for(let o of e)this.createChildObject(o.id,o.data,o.children,r,i)}registerObjectCreatedInLegacy(e){this.entityByUuid[e.uuid]=e}unregisterObject(e){delete this.entityByUuid[e.uuid];for(let r of e.children)this.unregisterObject(r)}createChildObject(e,r,i,o,s){let a=qu(e,r,s);return a&&(this.entityByUuid[e]=a,o.add(a),this.createChildrenObjects(i,a,s)),a}getCenter(e){let r=[];for(let o=0,s=e.length;o<s;++o){let{id:a,recursive:l}=e[o],c=this.find(a),p=l?c.recursiveBBox:c.singleBBox;r.push(...p.vertices)}let i=new Cw;return i.setFromPoints(r),i.getCenter(Yu),Yu}copyMatrixWorld(e,r){if(e===null){r.identity();return}let i=this.find(e);i?r.copy(i.matrixWorld):r.identity()}copyParentMatrixWorld(e,r){var o;if(e===null){r.identity();return}let i=(o=this.find(e))==null?void 0:o.parent;i?r.copy(i.matrixWorld):r.identity()}traverseMaterial(e){this.traverseEntity(r=>{if(r instanceof at)if(Array.isArray(r.material))for(let i=0;i<r.material.length;i++)e(r.material[i]);else e(r.material)})}updateCanvasSize(e,r){this.activeCamera.setViewplaneSize(e,r);let i,o;e>=r?(i=r/e,o=1):(i=1,o=e/r),this.traverseMaterial(s=>{s.layersList.getLayersOfType("transmission").forEach(l=>{l.uniforms[`f${l.id}_aspectRatio`].value.x=i,l.uniforms[`f${l.id}_aspectRatio`].value.y=o})})}},Cn=Zl;Cn.PERSONAL_CAMERA_ID="f23858d0-4a3b-4bd8-8173-66ed0af7f6fb-personalCamera";import{DRACOLoader as Tw}from"three/examples/jsm/loaders/DRACOLoader.js";var ri;function Nw(){return ri||(ri=new Tw,ri.setDecoderPath("https://www.gstatic.com/draco/versioned/decoders/1.5.2/").preload()),ri.decoderPending}async function Mw(n){if(ri){let t={attributeIDs:ri.defaultAttributeIDs,attributeTypes:ri.defaultAttributeTypes,useUniqueIDs:!1},e;try{e=await ri.decodeGeometry(new Int8Array(n).buffer,t)}catch(r){console.error(r)}if(e)return{index:e.index?{array:e.index.array}:void 0,attributes:Object.entries(e.attributes).map(([r,i])=>({name:r,itemSize:i.itemSize,array:i.array}))}}return null}async function Xu(n){let[t,e]=Da(Ns.deserialize(new Uint8Array(n))),r=[];t.scene.objects.traverse((i,o)=>{o.type==="Mesh"&&o.geometry.type==="NonParametricGeometry"&&o.geometry.data.draco!==void 0&&r.push(o)}),r.length&&await Nw();for(let i of r){let o=await Mw(Ba(i.geometry.data.draco));if(o){o.index&&(i.geometry.data.index={array:o.index.array,itemSize:1,normalized:!1,type:"Uint32Array"});let s={};o.attributes.forEach(({name:a,array:l,itemSize:c})=>{s[a]={array:l,itemSize:c,type:"Float32Array",normalized:!1}}),i.geometry.data.attributes=s,i.geometry.data.draco=void 0}}return e.result().data}import{WebGLRenderTarget as Ow,LinearMipmapLinearFilter as Iw,LinearFilter as Pw,ClampToEdgeWrapping as Zu,DepthTexture as Aw}from"three";var Qu=new mt,wa=class extends Pt{},La=class{constructor(t){this.materials={};this.images={};this.colors={};this.transmissionRenderTarget=new Ow(2048,2048,{generateMipmaps:!0,minFilter:Iw,magFilter:Pw,wrapS:Zu,wrapT:Zu}),this.transmissionRenderTarget.depthTexture=new Aw(2048,2048),this.reset(t)}reset(t){for(let[e,r]of Object.entries(t.images))this.addImage(e,r.data);for(let[e,r]of Object.entries(t.colors))this.addColor(e,r);for(let[e,r]of Object.entries(t.materials))this.addMaterial(e,Hl(r,this))}get transmissionSamplerMap(){return this.transmissionRenderTarget.texture}get transmissionDepthMap(){return this.transmissionRenderTarget.depthTexture}addMaterial(t,e){e.uuid=t,this.materials[t]=e}deleteMaterial(t){this.materials[t]&&(this.materials[t].dispose(),delete this.materials[t])}isSharedMaterial(t){return t.uuid in this.materials||t===Qu}getMaterial(t){let e=this.materials[t];return e}getMaterialOrDeletedPlaceholder(t){var e;return(e=this.materials[t])!=null?e:Qu}getMaterials(){return this.materials}addImage(t,e){if(this.images[t])return this.images[t].onload=()=>{this.onImageLoad&&this.onImageLoad(t)},this.images[t].src=e,!0;{let r=new Image;return r.src=e,r.onload=()=>{this.onImageLoad&&this.onImageLoad(t)},this.images[t]=r,!1}}deleteImage(t){this.images[t]&&delete this.images[t]}getDefaultImage(){return this.images.image_0}getImage(t){return this.images[t]}getImages(){return this.images}addColor(t,e){return this.colors[t]?("a"in e?this.colors[t].setRGBA(e.r,e.g,e.b,e.a):this.colors[t].setRGBA(e.r,e.g,e.b,1),!0):("a"in e?this.colors[t]=new wa(e.r,e.g,e.b,e.a):this.colors[t]=new wa(e.r,e.g,e.b,1),!1)}updateColor(t,e){var r,i,o,s;if(this.colors[t]){let a=this.colors[t];return this.colors[t].r=(r=e.r)!=null?r:a.r,this.colors[t].g=(i=e.g)!=null?i:a.g,this.colors[t].b=(o=e.b)!=null?o:a.b,this.colors[t].a=(s=e.a)!=null?s:a.a,!0}return!1}deleteColor(t){this.colors[t]&&delete this.colors[t]}getColor(t){return this.colors[t]}dispose(){Object.keys(this.materials).forEach(e=>this.deleteMaterial(e)),this.transmissionRenderTarget.depthTexture.dispose(),this.transmissionRenderTarget.dispose(),this.onImageLoad=void 0}};import{Mesh as Ek}from"three";import{mergeBufferGeometries as Rk}from"three/examples/jsm/utils/BufferGeometryUtils.js";function em(n){let t;if(!!n.index)for(let e=0;e<n.index.array.length;e+=3)t=n.index.array[e],n.index.array[e]=n.index.array[e+2],n.index.array[e+2]=t}import{Color as tm,ShaderLib as Dw}from"three";function rm(n){let t=new Set;return n.traverse(e=>{if(io(e))if(Qe(e.material))e.material.forEach(r=>{let i=r;t.has(i)||t.add(i)});else{let r=e.material;t.has(r)||t.add(r)}}),t.forEach(e=>{if(e instanceof Array)return;let r=e.onBeforeCompile.bind(e);_w(e)?(Object.assign(e,{isMeshStandardMaterial:!0,isMeshPhysicalMaterial:!0,transmission:1,attenuationColor:new tm,specularColor:new tm}),e.onBeforeCompile=(i,o)=>{r&&r(i,o),i.uniforms=Object.assign(Dw.physical.uniforms,i.uniforms),e.userData.layers.getLayersOfType("transmission").forEach(s=>{i.uniforms.transmissionSamplerMap.value&&(s.uniforms["f"+s.id+"_transmissionSamplerMap"].value=i.uniforms.transmissionSamplerMap.value,s.uniforms["f"+s.id+"_transmissionSamplerSize"].value=i.uniforms.transmissionSamplerSize.value)})}):Bw(e)||(e.onBeforeCompile=(i,o)=>{r&&r(i,o),e.transparent=!1})}),n}function _w(n){return n.userData.layers.getLayersOfType("transmission").length>0}function Bw(n){let t=n.userData.layers.head,e=0;for(;t!==void 0;){if(t.type!=="light"&&t.type!=="fresnel"){let r=t.uniforms["f"+t.id+"_alpha"];r&&(e+=(1-e)*r.value)}t=t.next}return e<1}function im(n){return n.traverse(t=>{if(t.type==="Camera"){let e=t;e.type=e.cameraType}}),n}function om(n){let t=[],e=(r,i=0)=>{let o=i>0?r+i:r;return t.includes(o)?e(r,i+1):o};return n.traverse(r=>{if(t.includes(r.name)){let i=r.name,o=e(r.name);if(r.name=o,r.isMesh){let s=r;s.material instanceof Array?s.material.forEach(a=>{a.name=a.name.replace(i,o)}):s.material.isAsset||(s.material.name=s.material.name.replace(i,o))}}t.push(r.name)}),n}import{mergeBufferGeometries as Ew}from"three/examples/jsm/utils/BufferGeometryUtils";function nm(n){let t=[];return n.traverse(e=>{e instanceof ui&&t.push(e)}),t.forEach(e=>{let r=e.object,i=e.children,o=i.map(a=>{a.updateMatrix();let l=a.geometry.clone().applyMatrix4(a.matrix);return a.matrix.determinant()<0&&em(l),l}),s=Ew(e.parameters.hideBase?o:[r.geometry,...o]);r.geometry=s,r.material=i[0].material,r.remove(e)}),n}var Ql=class extends zw{load(t,e,r,i=console.error){let o=new Gw(this.manager);o.setPath(this.path),o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(t,async s=>{try{if(typeof s=="string")throw new Error("The .spline file is not binary!");let a=await this.parse(s);e(a)}catch(a){i(a)}},r,i)}async parse(t){let e=await Xu(t),r=new La(e.shared);Object.values(r.getMaterials()).forEach(s=>Object.assign(s,{isAsset:!0}));let i=new Cn(e.scene,r);i.remove(i.personalCamera),e.scene.environment.ambientLight.enabled||i.remove(i.ambientLight);let o=e.scene.publish.playCamera;if(o){let s=i.find(o);s&&Kd(s)&&Object.assign(s,{makeDefault:!0})}return i=nm(i),i=rm(i),i=im(i),i=om(i),i}};export{Ql as default};
|
|
957
|
+
`)}return r}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 pa=class extends Rt{constructor(e=new ca,r){super(e,e,r);this.type="StandardNodeMaterial",this.fragment=e}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}};var yo=class extends pa{constructor(t,e,r){super(e,t),this.userData.type="PhysicalMaterial",this.userData.category="Physical",this.userData.layers=r!=null?r:this._getLayerStack(t==null?void 0:t.map)}get layersList(){return this.userData.layers}set layersList(t){this.userData.layers=t}equals(t){return this.userData.type===t.userData.type&&this.userData.layers.uuid==t.userData.layers.uuid}copy(t){if(t.userData.layers!==void 0&&t.userData.layers instanceof St){let e=t.userData.layers,r=t.fragment;super.copy(t);let i=r.clone();this.fragment=i,this.vertex=i;let o=e.clone(this);this.userData.layers=o,i.shadingAlpha.value=r.shadingAlpha.value,i.shadingBlend.value=r.shadingBlend.value}else super.copy(t);return this}static fromJSON(t,e,r){let i=r.getNode(e.vertex),o=new yo(void 0,i);return o.fromJSON(e,r),o}dispose(){super.dispose()}};import{Color as kl}from"three";import{Matrix3 as uu,Texture as Ul,Vector2 as Sn,Vector3 as Zr,Vector4 as mu}from"three";function fu(n,t){switch(n.data.type){case"light":return rr(n);case"fresnel":return aS(n,t);case"gradient":return lS(n);case"depth":return cS(n);case"normal":return pS(n);case"noise":return hS(n,t);case"texture":return dS(n,t);case"rainbow":return uS(n);case"transmission":return mS(n,t);case"matcap":return fS(n,t);case"displace":return yS(n);case"color":default:return sS(n,t)}}function yu(n){return{type:n.data.type}}function rr(n){let{alpha:t,mode:e}=n.data;return W(P({},yu(n)),{alpha:t,mode:e})}function sS(n,t){return W(P({},rr(n)),{color:Ye(n.data.color,t)})}function aS(n,t){let{bias:e,scale:r,intensity:i,factor:o,color:s}=n.data;return W(P({},rr(n)),{color:Ye(s,t),bias:e,scale:r,intensity:i,factor:o})}function lS(n){let{gradientType:t,smooth:e,colors:r,steps:i,angle:o,offset:s,morph:a}=n.data;return W(P({},rr(n)),{gradientType:t,smooth:e,colors:r.map(l=>new mu(l[0],l[1],l[2],l[3])),num:r.length,steps:i,offset:new Sn(...s),morph:new Sn(...a),angle:o})}function cS(n){let{gradientType:t,near:e,far:r,isVector:i,isWorldSpace:o,origin:s,direction:a,colors:l,steps:c,smooth:p,num:h}=n.data;return W(P({},rr(n)),{gradientType:t,near:e,far:r,isVector:i,isWorldSpace:o,origin:new Zr(...s),direction:a?new Zr(...a):new Zr(1,0,0),num:h,colors:l.map(d=>new mu(d[0],d[1],d[2],d[3])),steps:c,smooth:p})}function pS(n){let{cnormal:t}=n.data;return W(P({},rr(n)),{cnormal:new Zr(t[0],t[1],t[2])})}function hS(n,t){let{data:e}=n;return W(P({},rr(n)),{scale:e.scale,move:e.move,fA:new Sn(...e.fA),fB:new Sn(...e.fB),size:new Zr(...e.size),distortion:new Sn(...e.distortion),colorA:Ye(e.colorA,t),colorB:Ye(e.colorB,t),colorC:Ye(e.colorC,t),colorD:Ye(e.colorD,t),noiseType:e.noiseType})}function dS(n,t){let{projection:e,axis:r,crop:i,size:o}=n.data,{image:s,wrapping:a,repeat:l,offset:c}=n.data.texture,p=new Ul,h;if(typeof s=="string")h=t==null?void 0:t.getImage(s);else{let d=new Image;d.src=s.data,d.onload=()=>{t!=null&&t.onImageLoad&&(t==null||t.onImageLoad(s.data))},h=d}return p.image=h,p.repeat.set(l[0],l[1]),p.offset.set(c[0],c[1]),p.wrapS=p.wrapT=a,W(P({},rr(n)),{texture:p,mat:new uu().setUvTransform(c[0],c[1],l[0],l[1],0,0,0),crop:i,projection:e,axis:["x","y","z"].indexOf(r),size:o})}function uS(n){let{data:t}=n;return W(P({},rr(n)),{filmThickness:t.filmThickness,movement:t.movement,wavelengths:new Zr(...t.wavelengths),noiseStrength:t.noiseStrength,noiseScale:t.noiseScale,offset:new Zr(...t.offset)})}function mS(n,t){let{data:e}=n;return W(P({},rr(n)),{thickness:e.thickness,ior:e.ior,roughness:e.roughness,transmissionSamplerMap:t.transmissionSamplerMap,transmissionDepthMap:t.transmissionDepthMap})}function fS(n,t){let e=new Ul,{image:r}=n.data.texture,i;if(typeof r=="string")i=t==null?void 0:t.getImage(r);else{let s=new Image;s.src=r.data,s.onload=()=>{t!=null&&t.onImageLoad&&(t==null||t.onImageLoad(r.data))},i=s}e.image=i;let o=16777215;return W(P({},rr(n)),{color:o,texture:e})}function yS(n){let{data:t}=n,e=W(P({},yu(n)),{intensity:t.intensity});if(t.displacementType==="noise")return W(P({},e),{offset:new Zr(...t.offset),scale:t.scale,movement:t.movement,noiseType:t.noiseType});{let r=new Ul,i=new uu().setUvTransform(0,0,1,1,0,0,0);return W(P({},e),{texture:r,mat:i,crop:t.crop})}}function gu(n,t,e){if(e.type==="displace"&&(n==="intensity"||n==="visible")){let r=t.uniforms[`f${t.id}_intensity`];return r?(r.value=e.intensity*(e.visible?1:0),r):void 0}if(e.type!=="displace"&&(n==="alpha"||n==="visible")){let r=t.uniforms[`f${t.id}_alpha`];return r?(r.value=e.alpha*(e.visible?1:0),r):void 0}}import{Color as vu,Vector4 as gS}from"three";var go;(t=>{function n(e){return new vu(e.x,e.y,e.z).getHex()}t.getHex=n})(go||(go={}));var xu;(t=>{function n(e){return new gS(e.r,e.g,e.b,e.a)}t.getThreeVector4=n})(xu||(xu={}));var bu;(e=>{function n(r,i){r.setRGB(i.r,i.g,i.b)}e.setThreeColor=n;function t(r){return new vu(r.r,r.g,r.b).getHex()}e.getHex=t})(bu||(bu={}));function wn(n,t){return typeof n=="string"?t.getMaterialOrDeletedPlaceholder(n):Hl(n,t)}function Su(n,t){return n.map(e=>wn(e,t))}function Hl(n,t){var s,a;let e=(s=n.layers)!=null?s:Ji.defaultTwoLayerData("phong").layers,r=xS(e),i;switch(r.category){case"basic":i=new mt;break;case"lambert":{i=new mo;break}case"toon":{i=new fo;break}case"physical":i=new yo;break;case"phong":default:{i=new Vt;break}}i.name=(a=n.name)!=null?a:"Untitled Material";let o=i.userData.layers;bS(o);for(let l=e.length-1;l>=0;l--)vS(o,e[l],t);switch(r.category){case"basic":break;case"lambert":{let p=i,d=Ye(r.emissive,t);d instanceof kl?p.emissive.value=d:p.emissive.value.setHex(go.getHex(d));break}case"toon":{let p=i,h=r;p.shininess.value=h.shininess;let d=Ye(h.specular,t);d instanceof kl?p.specular.value=d:p.specular.value.setHex(go.getHex(d));break}case"physical":let l=i,c=r;l.metalness.value=c.metalness,l.roughness.value=c.roughness,l.reflectivity.value=c.reflectivity;break;case"phong":default:{let p=i,h=r;p.shininess.value=h.shininess;let d=Ye(h.specular,t);d instanceof kl?p.specular.value=d:p.specular.value.setHex(go.getHex(d));break}}return o.blendColors(),o.blendAfterColors(),o.blendPositions(),i}function xS(n){for(let t of n)if(t.data.type==="light")return t.data;return{type:"light",category:"basic",visible:!0,alpha:1,mode:0}}function bS(n){for(let t of n.getLayers())n.removeLayer(t.id)}function vS(n,t,e){let r=fu(t,e);r.type==="transmission"&&(r.transmissionSamplerMap=e==null?void 0:e.transmissionSamplerMap,r.transmissionDepthMap=e==null?void 0:e.transmissionDepthMap);let i=n.addLayer(r);i.uuid=t.id;for(let o in t.data)gu(o,i,t.data)}var wu=n=>n.tagName==="VIDEO",xi=class{static resize(t,e,r){let i=t/e,o;if(!r.image)return;let s=r.image;wu(s)?o=s.videoWidth/s.videoHeight:o=s.width/s.height,i>o&&(r.imageType=="WEBCAM"?r.repeat.set(-1,1*o/i):r.repeat.set(1,1*o/i)),i<o&&(r.imageType=="WEBCAM"?r.repeat.set(1*i/o*-1,1):r.repeat.set(1*i/o,1)),i==o&&(r.imageType=="WEBCAM"?r.repeat.set(-1,1):r.repeat.set(1,1))}static resizeTextureLayer(t,e,r){let i=t/e,o=r.image!==void 0?r.image.width/r.image.height:1,s;i>o?s={x:1,y:o/i}:i<o?s={x:i/o,y:1}:s={x:1,y:1},r.repeat.set(s.x,s.y),r.updateMatrix()}static resizeTextureLayers(t,e,r){let i=r.userData.layers,o=i.getLayers();for(let s=0;s<o.length;s++){let a=o[s];au(a)&&(xi.resizeTextureLayer(t,e,a.uniforms[`f${a.id}_texture`].value),i.updateLayerUniform())}}static resizeComplex(t,e,r,i){let o=t/e,s,a=r.image;wu(a)?s=a.videoWidth/a.videoHeight:s=a.width/a.height,i.geometry.type.includes("Shape")?(o>s&&(r.imageType=="WEBCAM"?r.repeat.set(1/t*-1,1/e*s/o):r.repeat.set(1/t,1/e*s/o)),o<s&&(r.imageType=="WEBCAM"?r.repeat.set(1/t*o/s*-1,1/e):r.repeat.set(1/t*o/s,1/e)),o==s&&(r.imageType=="WEBCAM"?r.repeat.set(1/t*-1,1/e):r.repeat.set(1/t,1/e))):(o>s&&(r.imageType=="WEBCAM"?r.repeat.set(-1,1*s/o):r.repeat.set(1,1*s/o)),o<s&&(r.imageType=="WEBCAM"?r.repeat.set(1*o/s*-1,1):r.repeat.set(1*o/s,1)),o==s&&(r.imageType=="WEBCAM"?r.repeat.set(-1,1):r.repeat.set(1,1)))}};var xo=class extends at{constructor(e,r=new mt){super(e,r);this.objectType="Mesh2D";this.castShadow=!0,this.receiveShadow=!0}updateGeometry(e){super.updateGeometry(e),this.material.userData.layers&&xi.resizeTextureLayers(this.geometry.userData.parameters.width,this.geometry.userData.parameters.height,this.material)}resizeGeometry(e,r){super.resizeGeometry(e,r,0),this.material.userData.layers&&xi.resizeTextureLayers(this.geometry.userData.parameters.width,this.geometry.userData.parameters.height,this.material)}toJSON(e){let r=super.toJSON(e);return r.object.objectType="Mesh2D",r}clone(){let e=super.clone();return e.updateGeometry({}),e}static fromTexture(e){let r,i;if(e instanceof SS){let a=e.image;r=a.videoWidth*.5,i=a.videoHeight*.5}else{let a=e.image;r=a.width*.5,i=a.height*.5}let o=Ws.create({parameters:{width:r,height:i}}),s=new mt;return s.layersList.changeLayer(0,{type:"texture",texture:e}),s.layersList.moveLayer(0,1),s.dispose(),new xo(o,s)}};import{DoubleSide as wS,EventDispatcher as LS,Matrix3 as CS,Vector3 as ql}from"three";var TS=new ql(0,0,1),Lu=new ql,Cu=new ql,Tu=new CS,Qr=class extends at{constructor(e=ht.create({}),r=new mt({side:wS})){var i;super(e,r);this.recursiveSelection=!1;this.objectType="VectorObject";this.eventDispatcher=new LS;this._onShapeUpdate=()=>{this.updateGeometry({}),this.geometry.computeBoundingSphere(),this.geometry.computeBoundingBox()};this.castShadow=!0,this.receiveShadow=!0,this.forceComputeSize=!0,this.shape=e.userData.shape,(i=this.shape.eventDispatcher)==null||i.addEventListener("update",this._onShapeUpdate)}toJSON(e){let r=super.toJSON(e);return r.object.objectType="VectorObject",r}fromState(e){return super.fromState(e),this.shape.update(),this}setHelperVisibility(){}updateGeometry(e){if(super.updateGeometry(e),"userData"in this.geometry){let r=this.geometry.userData.parameters;this.eventDispatcher.dispatchEvent({type:"geometryUpdate",parameters:r})}}setShape(e){var r,i;this.shape&&((r=this.shape.eventDispatcher)==null||r.removeEventListener("update",this._onShapeUpdate)),this.shape=e,(i=this.shape.eventDispatcher)==null||i.addEventListener("update",this._onShapeUpdate)}updateWorldMatrix(e,r){super.updateWorldMatrix(e,r),Tu.getNormalMatrix(this.matrixWorld),Lu.copy(TS).applyMatrix3(Tu).normalize(),Cu.setFromMatrixPosition(this.matrixWorld),this.shape.plane.setFromNormalAndCoplanarPoint(Lu,Cu)}clone(e){let r=this.shape.clone(),i=this.material.clone(),o=this.geometry.userData,s=ht.create(Object.assign({},o,{shape:r})),a=new Qr(s,i).copy(this,e);return a.shape=r,r.update(),a}raycast(e,r){at.prototype.raycast.call(this,e,r)}};import{Camera as jS,OrthographicCamera as US,PerspectiveCamera as kS,Vector3 as Ft,Object3D as Ou,Quaternion as HS}from"three";import{BoxBufferGeometry as NS}from"three";var yr=n=>{var t;return t=class extends n{constructor(){super(...arguments);this.isObjectHelper=!0}},t.geometryHelper=new NS(30,30,30),t};import{Camera as AS,LineSegments as DS,BufferGeometry as _S,LineBasicMaterial as BS,Color as $l,Vector3 as ES,Float32BufferAttribute as Mu}from"three";import{Ray as MS,Sphere as OS,Matrix4 as IS,Vector3 as Ar}from"three";var ha=new MS,Wl=new OS,Nu=new IS,gr=(n,t,e,r,i=!1)=>{let o=t,s=n.matrixWorld;if(o.boundingSphere===null&&o.computeBoundingSphere(),Wl.copy(o.boundingSphere),Wl.applyMatrix4(s),e.ray.intersectsSphere(Wl)===!1||(Nu.copy(s).invert(),ha.copy(e.ray).applyMatrix4(Nu),o.boundingBox!==null&&ha.intersectsBox(o.boundingBox)===!1))return;let a,l,c,p,h=o.index,d=o.attributes.position,m=o.drawRange,f,T;if(i===!1){let y=Math.max(0,m.start),L=Math.min(h.count,m.start+m.count);for(f=y,T=L;f<T;f+=3)if(l=h.getX(f),c=h.getX(f+1),p=h.getX(f+2),a=w(n,e,ha,d,l,c,p),a){a.faceIndex=Math.floor(f/3),r.push(a);return}}else{let L=o.attributes.position,A=new Ar,I=new Ar,b=new Ar,V=new Ar,x=2,M=1/((n.scale.x+n.scale.y+n.scale.z)/3),g=M*M,N=Math.max(0,m.start),v=Math.min(L.count,m.start+m.count);for(let C=N,$=v-1;C<$;C+=x){if(A.fromBufferAttribute(L,C),I.fromBufferAttribute(L,C+1),ha.distanceSqToSegment(A,I,V,b)>g)continue;V.applyMatrix4(n.matrixWorld);let ie=e.ray.origin.distanceTo(V);ie<e.near||ie>e.far||r.push({distance:ie,point:b.clone().applyMatrix4(n.matrixWorld),object:n})}}function w(y,L,A,I,b,V,x){let u=new Ar,M=new Ar,g=new Ar,N=new Ar,v=new Ar;if(u.fromBufferAttribute(I,b),M.fromBufferAttribute(I,V),g.fromBufferAttribute(I,x),A.intersectTriangle(u,M,g,!1,N)===null)return null;v.copy(N),v.applyMatrix4(y.matrixWorld);let $=L.ray.origin.distanceTo(v);return $<L.near||$>L.far?null:{faceIndex:1,distance:$,point:v.clone(),object:y}}};var da=new ES,Yt=new AS,Jl=class extends DS{constructor(e){let r=new _S,i=new BS({color:16777215,vertexColors:!0,toneMapped:!1}),o=[],s=[],a={},l=new $l(15711266),c=new $l(15711266),p=new $l(2857471);h("n1","n2",l),h("n2","n4",l),h("n4","n3",l),h("n3","n1",l),h("f1","f2",l),h("f2","f4",l),h("f4","f3",l),h("f3","f1",l),h("n1","f1",l),h("n2","f2",l),h("n3","f3",l),h("n4","f4",l),h("p","n1",c),h("p","n2",c),h("p","n3",c),h("p","n4",c),h("u1","u2",p),h("u2","u3",p),h("u3","u1",p);function h(m,f,T){d(m,T),d(f,T)}function d(m,f){o.push(0,0,0),s.push(f.r,f.g,f.b),a[m]===void 0&&(a[m]=[]),a[m].push(o.length/3-1)}r.setAttribute("position",new Mu(o,3)),r.setAttribute("color",new Mu(s,3));super(r,i);this.type="CameraHelper",this.camera=e,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=a,this.update()}update(){let e=this.geometry,r=this.pointMap,i=!0;Yt.projectionMatrixInverse.elements=[.5112609807824982,-0,-0,-0,-0,.41421356237309503,-0,-0,-0,-0,-0,-.099999,-0,-0,-1.0000000000000002,.100001];let o=1,s=1,a=i?.8:1e-4;ir("n1",r,e,Yt,-o,-s,a),ir("n2",r,e,Yt,o,-s,a),ir("n3",r,e,Yt,-o,s,a),ir("n4",r,e,Yt,o,s,a);let l=a;ir("f1",r,e,Yt,-o,-s,l),ir("f2",r,e,Yt,o,-s,l),ir("f3",r,e,Yt,-o,s,l),ir("f4",r,e,Yt,o,s,l);let c=l,p=.5;ir("u1",r,e,Yt,o*.7*p,s*1.1,c),ir("u2",r,e,Yt,-o*.7*p,s*1.1,c),ir("u3",r,e,Yt,0,s*(1.1+.9*p),c),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};function ir(n,t,e,r,i,o,s){da.set(i,o,s).unproject(r);let a=t[n];if(a!==void 0){let l=e.getAttribute("position");for(let c=0,p=a.length;c<p;c++)l.setXYZ(a[c],da.x,da.y,da.z)}}var ua=class extends yr(Jl){constructor(e){super(e);this.object=e;this.object=e,this.name=`CombinedCameraHelper: ${e.uuid}`}updateMatrixWorld(e){super.updateMatrixWorld(e),this.updateTarget()}updateTarget(){let e=this.object.getTarget();this.updateWorldMatrix(!0,!1),this.worldToLocal(e)}raycast(e,r){gr(this.object,this.geometry,e,r,!0)}};import{DirectionalLightHelper as GS}from"three";var bo=class extends yr(GS){constructor(e,r=15,i=10066329){super(e,r,i);this.object=e;this.name=`DirectionalLightHelper: ${e.uuid}`}raycast(e,r){gr(this.object,bo.geometryHelper,e,r)}};import{AxesHelper as zS}from"three";var vo=class extends yr(zS){constructor(e,r=15){super(r);this.object=e;this.object.updateMatrixWorld(),this.name=`EmptyObjectHelper: ${e.uuid}`,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1}raycast(e,r){gr(this.object,vo.geometryHelper,e,r)}update(){}};import{PointLightHelper as RS}from"three";var So=class extends yr(RS){constructor(e,r=15,i=6710886){super(e,r,i);this.object=e;this.name=`PointLightHelper: ${e.uuid}`}raycast(e,r){gr(this.object,So.geometryHelper,e,r)}};import{SpotLightHelper as VS,Vector3 as FS}from"three";var ma=class extends yr(VS){constructor(e,r=6710886){super(e,r);this.object=e;this.name=`SpotLightHelper: ${e.uuid}`}raycast(e,r){gr(this.object,ma.geometryHelper,e,r)}update(){if(this.object!==void 0){let e=ma._vector,r=this.object.distance?this.object.distance:1e3,i=r*Math.tan(this.object.angle);this.cone.scale.set(i,i,r),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 s=0,a=this.cone.material.length;s<a;s++)this.cone.material[s].color.set(o);else this.cone.material.color.set(o)}}},Ln=ma;Ln._vector=new FS;var xr=(n,t)=>class extends n{constructor(){super(...arguments);this.objectHelper=new t(this);this.enableHelper=!1}set visibility(i){this.visible=i,this.setHelperVisibility(i),this.setHelperChildrenVisibility(i)}get visibility(){return this.visible}get geometryHelper(){return t.geometryHelper}setHelperVisibility(i){this.objectHelper.visible=i}setHelperChildrenVisibility(i){for(let o of this.children)Jt(o)&&o.traverseEntity(s=>{Or(s)&&s.visible&&(s.objectHelper.visible=i)})}raycast(i,o){this.objectHelper.raycast(i,o)}copy(i,o=!0){return super.copy(i,o),i.enableHelper!==void 0&&(this.enableHelper=i.enableHelper),i.objectHelper!==void 0&&(this.objectHelper.visible=i.objectHelper.visible),this}toJSON(i){let o=super.toJSON(i),s=o.object;return s.enableHelper=this.enableHelper,o}fromJSON(i){return super.fromJSON(i),i.enableHelper!==void 0&&(this.enableHelper=!0),this}fromLightState(i,o){if(this.objectType==="LightDirectional"||this.objectType==="LightPoint"||this.objectType==="LightSpot"){let s=this;i.color!==void 0&&(s.color=Ye(i.color,o)),i.intensity!==void 0&&(s.intensity=i.intensity),i.depth!==void 0&&(s.shadow.camera.far=i.depth,s.shadow.needsUpdate=!0),i.shadows!==void 0&&(this.castShadow=i.shadows),i.helper!==void 0&&(this.enableHelper=i.helper,s.gizmos.shadowmap.visible=i.helper)}return this}};var wo=new Ft,Kl=new Ft,Dr=class extends xr(Kt(jS),ua){constructor(e=window.innerWidth,r=window.innerHeight,i=45,o,s=1e5){super();this.objectType="CombinedCamera";this._cameraType="OrthographicCamera";this.targetOffset=li.DefaultTargetOffset;this.isUpVectorFlipped=!1;this.angleOffsetFromUp=0;this.width=e,this.height=r,this.orthoCamera=new US(e*-.5,e*.5,r*.5,r*-.5,o!=null?o:-5e4,s),this.perspCamera=new kS(i,e/r,o!=null?o:50,s),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,r){let i=new Dr().fromState(r);return i.enableHelper=!0,i.objectHelper.update(),i.uuid=e,i}get isPerspectiveCamera(){return this.cameraType==="PerspectiveCamera"}get isOrthographicCamera(){return!this.isPerspectiveCamera}get cameraType(){return this._cameraType}setNear(e,r){e==="PerspectiveCamera"?this.perspCamera.near=r:this.orthoCamera.near=r}setZoom(e,r){r>=0&&(e==="PerspectiveCamera"?this.perspCamera.zoom=r:this.orthoCamera.zoom=r)}set cameraType(e){e==="PerspectiveCamera"?this.toPerspective():e==="OrthographicCamera"&&this.toOrthographic()}get near(){return this._cameraType==="PerspectiveCamera"?this.perspCamera.near:this.orthoCamera.near}set near(e){this._cameraType==="PerspectiveCamera"?this.perspCamera.near=e:this.orthoCamera.near=e}get zoom(){return this._cameraType==="PerspectiveCamera"?this.perspCamera.zoom:this.orthoCamera.zoom}set zoom(e){e>=0&&(this._cameraType==="PerspectiveCamera"?this.perspCamera.zoom=e:this.orthoCamera.zoom=e)}lookAt(e){super.lookAt(e),this.getWorldPosition(wo),this.targetOffset=wo.distanceTo(e)}getTarget(e=new Ft){return this.getWorldDirection(Kl),this.getWorldPosition(wo),Kl.multiplyScalar(this.targetOffset),e.copy(wo).add(Kl),e}getDistanceToTarget(){let e=this.getTarget();return this.getWorldPosition(wo),wo.distanceTo(e)}updateUp(){let e=this.getWorldQuaternion(new HS),r=new Ft(0,0,1).applyQuaternion(e),i=new Ft().copy(Ou.DefaultUp);this.isUpVectorFlipped&&i.negate(),i.applyQuaternion(e);let o=new Ft().copy(Ou.DefaultUp).projectOnPlane(r),s=new Ft().crossVectors(o,i).dot(r)>=0?1:-1;this.angleOffsetFromUp=o.angleTo(i)*s}getViewFrontToObject(e){let r=e.getWorldPosition(new Ft),o=e.getWorldDirection(new Ft).multiplyScalar(this.targetOffset);return{position:r.clone().add(o),target:r}}getViewToObject(e){let r=e.getWorldPosition(new Ft),o=this.getWorldDirection(new Ft).multiplyScalar(this.targetOffset);return{position:r.clone().sub(o),target:r}}setViewplaneSize(e,r){this.left=-e*.5,this.right=e*.5,this.top=r*.5,this.bottom=-r*.5,this.aspect=e/r,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,r,i,o,s,a){this._cameraType==="PerspectiveCamera"?this.perspCamera.setViewOffset(e,r,i,o,s,a):this.orthoCamera.setViewOffset(e,r,i,o,s,a)}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,r){super.updateWorldMatrix(e,r),this.matrixWorldInverse.copy(this.matrixWorld).invert()}copy(e,r){return super.copy(e,r),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 r={near:this.orthoCamera.near,far:this.orthoCamera.far},i={near:this.perspCamera.near,far:this.perspCamera.far};return this.copy(e),this.name="",this.enableHelper=!0,this.objectHelper.visible=!0,this.orthoCamera.near=r.near,this.orthoCamera.far=r.far,this.perspCamera.near=i.near,this.perspCamera.far=i.far,this.updateProjectionMatrix(),this}toJSON(e){let r=super.toJSON(e),i=r.object;return i.objectType="CombinedCamera",i.cameraType=this.cameraType,i.targetOffset=this.targetOffset,i.isUpVectorFlipped=this.isUpVectorFlipped,i.angleOffsetFromUp=this.angleOffsetFromUp,i.left=this.left,i.right=this.right,i.top=this.top,i.bottom=this.bottom,this.view!==null&&(i.view=Object.assign({},this.view)),i.zoomOrtho=this.orthoCamera.zoom,i.nearOrtho=this.orthoCamera.near,i.far=this.far,i.aspect=this.aspect,i.fov=this.fov,i.focus=this.focus,i.filmGauge=this.filmGauge,i.filmOffset=this.filmOffset,i.zoomPersp=this.perspCamera.zoom,i.nearPersp=this.perspCamera.near,r}fromJSON(e){var r;if(super.fromJSON(e),this.cameraType=e.cameraType,e.targetOffset!==void 0&&(this.targetOffset=e.targetOffset),e.orbitControlsTarget!==void 0){let i=this.getWorldPosition(new Ft),o=new Ft().fromArray(e.orbitControlsTarget);this.targetOffset=o.distanceTo(i)}else e.targetOffset!==void 0&&(this.targetOffset=e.targetOffset);return this.isUpVectorFlipped=!1,this.angleOffsetFromUp=(r=e.angleOffsetFromUp)!=null?r: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 r={type:this.cameraType,far:this.far,orthographic:{near:this.orthoCamera.near,zoom:this.orthoCamera.zoom},perspective:{near:this.perspCamera.near,fov:this.perspCamera.fov,zoom:this.perspCamera.zoom},up:this.up.toArray(),targetOffset:this.targetOffset,isUpVectorFlipped:this.isUpVectorFlipped};return Fi(r,e)}fromCameraState(e){let{orthographic:r,perspective:i}=e;return e.type!==void 0&&(this.cameraType=e.type),e.far!==void 0&&(this.far=e.far),r!==void 0&&(r.near!==void 0&&(this.orthoCamera.near=r.near),r.zoom!==void 0&&(this.orthoCamera.zoom=r.zoom)),i!==void 0&&(i.near!==void 0&&(this.perspCamera.near=i.near),i.fov!==void 0&&(this.perspCamera.fov=i.fov),i.zoom!==void 0&&(this.perspCamera.zoom=i.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 W(P(P({},super.toState(e)),this.toCameraState(e)),{type:this.cameraType})}fromState(e){return super.fromState(e),this.fromCameraState(e),this}};import{Group as qS}from"three";var _r=class extends xr(Kt(qS),vo){constructor(){super(...arguments);this.objectType="EmptyObject"}static createFromState(e,r){let i=new _r().fromState(r);return i.uuid=e,i.enableHelper=!0,i.objectHelper.update(),i}toJSON(e){let r=super.toJSON(e);return r.object.objectType="EmptyObject",r}};import{DirectionalLight as WS,CameraHelper as fa}from"three";var Lo=class extends xr(Kt(WS),bo){constructor(...e){super(...e);this.objectType="LightDirectional";this._gizmos={};this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024;let i=this.shadow.camera;i.top=1250,i.bottom=-1250,i.right=1250,i.left=-1250,i.near=1,i.far=2500;let o=new fa(this.shadow.camera);o.visible=!1,this._gizmos.shadowmap=o,this.update()}static createFromState(e,r,i){let o=new Lo().fromState(r,i);return o.uuid=e,o}get gizmos(){return this._gizmos}showGizmos(){for(let e in this._gizmos){let r=this._gizmos[e];r instanceof fa&&(r.visible=!0)}}hideGizmos(){for(let e in this._gizmos){let r=this._gizmos[e];r instanceof fa&&(r.visible=!1)}}update(){this.shadow.camera.updateProjectionMatrix();for(let e in this._gizmos){let r=this._gizmos[e];r instanceof fa&&r.update()}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.enableHelper===!0&&this.objectHelper.visible===!0&&this.objectHelper.update()}copy(e,r=!0){return super.copy(e,r),this.color.copy(e.color),this.intensity=e.intensity,this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}toJSON(e){let r=super.toJSON(e),i=r.object;return i.objectType="LightDirectional",i.color=this.color.getHex(),i.intensity=this.intensity,i.shadow=this.shadow.toJSON(),r}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 r=this.shadow.camera,i=e.shadow.camera;return r.near=i.near,r.far=i.far,r.zoom=i.zoom,r.left=i.left,r.right=i.right,r.top=i.top,r.bottom=i.bottom,i.view!==void 0&&(r.view=Object.assign({},i.view)),this}fromDirectionalLightState(e,r){let i=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,r),e.size!==void 0&&Xd(this,e.size),i&&this.update(),this}fromState(e,r){return super.fromState(e),this.fromDirectionalLightState(e,r),this}};import{PointLight as $S,Vector3 as ya,Box3 as JS,Box3Helper as ga,Color as KS}from"three";var Co=class extends xr(Kt($S),So){constructor(...e){super(...e);this.objectType="LightPoint";this._gizmos={};this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024;let i=this.shadow.camera;i.fov=90,i.aspect=1,i.near=100,i.far=2500;let o=new ya(-i.far+this.position.x,-i.far+this.position.y,-i.far+this.position.z),s=new ya(i.far+this.position.x,i.far+this.position.y,i.far+this.position.z),a=new JS(o,s),l=new ga(a,new KS(16755200));l.visible=!1,this._gizmos.shadowmap=l,this.update()}static createFromState(e,r,i){let o=new Co().fromState(r,i);return o.uuid=e,o}get gizmos(){return this._gizmos}showGizmos(){for(let e in this._gizmos){let r=this._gizmos[e];r instanceof ga&&(r.visible=!0)}}hideGizmos(){for(let e in this._gizmos){let r=this._gizmos[e];r instanceof ga&&(r.visible=!1)}}update(){if(this.shadow&&(this.shadow.camera.updateProjectionMatrix(),this._gizmos))for(let e in this._gizmos){let r=this._gizmos[e];if(r instanceof ga){let i=this.shadow.camera,o=new ya(-i.far+this.position.x,-i.far+this.position.y,-i.far+this.position.z),s=new ya(i.far+this.position.x,i.far+this.position.y,i.far+this.position.z);r.box.set(o,s),r.updateMatrixWorld(!0)}}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.enableHelper===!0&&this.objectHelper.visible===!0&&this.objectHelper.update()}copy(e,r=!0){return super.copy(e,r),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 r=super.toJSON(e),i=r.object;return i.objectType="LightPoint",i.color=this.color.getHex(),i.intensity=this.intensity,i.distance=this.distance,i.decay=this.decay,i.shadow=this.shadow.toJSON(),r}fromJSON(e){var o,s;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((s=e.shadow.mapSize)!=null?s:[512,512]),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null);let r=this.shadow.camera,i=e.shadow.camera;return r.near=i.near,r.far=i.far,r.zoom=i.zoom,r.fov=i.fov,r.focus=i.focus,r.aspect=i.aspect,r.filmGauge=i.filmGauge,r.filmOffset=i.filmOffset,i.view!==void 0&&(r.view=Object.assign({},i.view)),this}fromPointLightState(e,r){return super.fromLightState(e,r),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,r){return super.fromState(e),this.fromPointLightState(e,r),this}};import{SpotLight as YS,CameraHelper as xa,MathUtils as XS,Vector3 as Du,Quaternion as ZS}from"three";var Iu=new Du,Pu=new Du,Au=new ZS,To=class extends xr(Kt(YS),Ln){constructor(...e){super(...e);this.objectType="LightSpot";this._gizmos={};this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024;let i=this.shadow.camera;i.fov=XS.RAD2DEG*2*this.angle,i.aspect=1,i.near=100,i.far=2500;let o=new xa(this.shadow.camera);o.visible=!1,this._gizmos.shadowmap=o,this.update()}static createFromState(e,r,i){let o=new To().fromState(r,i);return o.uuid=e,o}get gizmos(){return this._gizmos}showGizmos(){for(let e in this._gizmos){let r=this._gizmos[e];r instanceof xa&&(r.visible=!0)}}hideGizmos(){for(let e in this._gizmos){let r=this._gizmos[e];r instanceof xa&&(r.visible=!1)}}update(){this.shadow.camera.updateProjectionMatrix();for(let e in this._gizmos){let r=this._gizmos[e];r instanceof xa&&r.update()}}updateMatrixWorld(e){super.updateMatrixWorld(e),Pu.setFromMatrixPosition(this.matrixWorld),Au.setFromRotationMatrix(this.matrixWorld),Iu.copy(this.up).applyQuaternion(Au).negate().multiplyScalar(this.distance),this.target.position.copy(Pu).add(Iu),this.target.updateMatrixWorld(),this.enableHelper===!0&&this.objectHelper.visible===!0&&this.objectHelper.update()}copy(e,r=!0){return super.copy(e,r),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 r=super.toJSON(e),i=r.object;return i.objectType="LightSpot",i.color=this.color.getHex(),i.intensity=this.intensity,i.distance=this.distance,i.angle=this.angle,i.decay=this.decay,i.penumbra=this.penumbra,i.shadow=this.shadow.toJSON(),r}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 r=this.shadow.camera,i=e.shadow.camera;return r.near=i.near,r.far=i.far,r.zoom=i.zoom,r.fov=i.fov,r.focus=i.focus,r.aspect=i.aspect,r.filmGauge=i.filmGauge,r.filmOffset=i.filmOffset,i.view!==void 0&&(r.view=Object.assign({},i.view)),this}fromSpotLightState(e,r){return super.fromLightState(e,r),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,r){return super.fromState(e),this.fromSpotLightState(e,r),this}};var No=class extends at{constructor(e,r=new Vt){super(e,r);this.objectType="Mesh3D";this.castShadow=!0,this.receiveShadow=!0}toJSON(e){let r=super.toJSON(e);return r.object.objectType="Mesh3D",r}};var Mo=class extends No{constructor(e,r=new Vt){super(e,r);this.objectType="NonParametric"}toJSON(e){let r=super.toJSON(e);return r.object.objectType="NonParametric",r}};import{DoubleSide as QS,Mesh as ew,MeshBasicMaterial as tw,ShapeBufferGeometry as rw,Vector2 as iw,Vector3 as ow}from"three";import{FontLoader as nw}from"three/examples/jsm/loaders/FontLoader.js";var Xe=class extends ew{constructor({char:e,originalChar:r,fontFamily:i,letterSpacing:o,fontSize:s,LOD:a=16},l=new tw({color:0,opacity:1,visible:!0,transparent:!0,side:QS})){let c=Xe.loadChar(e,i,a);super(c.geometry,l);this.char=e,this.originalChar=r!=null?r:e,this.fontFamily=i,this.letterSpacing=o,this.fontSize=s,this.LOD=a,this.resolution=c.resolution,this.glyphsHa=c.glyphsHa,this.localPosition=new iw,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 Xe._fontPath}static set FONTS_PATH(e){Xe._fontPath=e}updatePosition(e,r){this.localPosition.copy(e);let i=new ow(this.localPosition.x,-this.localPosition.y,0);this.position.copy(i).add(r)}updateFontSize(e){let r=e/this.resolution;this.fontSize=e,this.scale.set(this.fontSize,this.fontSize,1),this.charSize=this.glyphsHa*r*this.letterSpacing}updateFontFamily(e){if(this.fontFamily===e)return;this.fontFamily=e;let r=Xe.loadChar(this.char,e,this.LOD);this.geometry=r.geometry,this.resolution=r.resolution,this.glyphsHa=r.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 r=Xe.loadChar(e,this.fontFamily,this.LOD);this.geometry=r.geometry,this.resolution=r.resolution,this.glyphsHa=r.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 r=Xe.loadChar(this.char,this.fontFamily,this.LOD);this.geometry=r.geometry,this.resolution=r.resolution,this.glyphsHa=r.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 Xe(e).copy(this)}static loadFont(e){return new Promise(function(r,i){Xe.fontCache[e]?r(Xe.fontCache[e]):new nw().load(Xe.FONTS_PATH+e+".json",s=>{Xe.fontCache[e]=s,r(s)},void 0,i)})}static loadChar(e,r,i){if(Xe.charCache[e]){if(Xe.charCache[e][i]&&Xe.charCache[e][i].fontFamily===r)return Xe.charCache[e][i]}else Xe.charCache[e]={};let o=Xe.fontCache[r],s=o.generateShapes(e,1);return Xe.charCache[e][i]={geometry:new rw(s,i),fontFamily:r,resolution:o.data.resolution,glyphsHa:o.data.glyphs[e].ha},Xe.charCache[e][i]}},Mt=Xe;Mt.charCache={},Mt.fontCache={},Mt._fontPath="/_assets/_fonts/";import{DoubleSide as va,MeshBasicMaterial as Bu,Vector3 as Eu,Object3D as sw}from"three";import{Vector2 as _u}from"three";var ba=new _u,ei=class{constructor(t,e,r){this.message=[];this.endLine=!0;this.yLinePos=t,this.lineHeight=e,this.maxCharSize=r,this.nextChar3DPos=new _u(0,this.yLinePos+this.maxCharSize*this.lineHeight),this.align=1}addChar3D(t,e,r=this.message.length){this.message.splice(r,0,t),t.fontSize>this.maxCharSize?(this.maxCharSize=t.fontSize,this.nextChar3DPos.y=this.yLinePos+this.maxCharSize*this.lineHeight,this.fullUpdate(e)):(t.updatePosition(this.nextChar3DPos,e),this.nextChar3DPos.x+=t.charSize)}deleteChar3D(t=this.message.length-1){let e=this.message[t];if(e)return this.message.splice(t,1),this.nextChar3DPos.x-=e.charSize,e}isEndLine(t){this.endLine=t}fullUpdate(t,e=0){this.nextChar3DPos.x=0;for(let r=e,i=this.message.length;r<i;r+=1)this.message[r].updatePosition(this.nextChar3DPos,t),this.nextChar3DPos.x+=this.message[r].charSize}checkOverFlow(t){let e,r=this.message.length-1;if(r<=0)return!1;for(;r>=0;){if(this.message[r].char!==" "){e=this.message[r];break}r-=1}return!!(r>=0&&e&&e.localPosition.x+e.charSize>t)}containSpaceOverFlow(t=this.message.length-1){for(let e=t;e>=0;e-=1)if(this.message[e].char===" ")return!0;return!1}containSpace(t=this.message.length-1){if(this.endLine)return!0;for(let e=t;e>=0;e-=1)if(this.message[e].char===" ")return!0;return!1}popWord(t=this.message.length-1){let e=[],r=!0,i;for(i=t;i>=0;i-=1)if(this.message[i].char===" "){r=!1,e.length===0&&(i-=1,e.splice(0,0,this.message[i]));break}else e.splice(0,0,this.message[i]);return r?e=[]:this.message.splice(i+1,e.length),e}getWord(t=0,e=1){let r=[],i=t;for(i=t;;i+=e){if(!this.message[i]||this.message[i].char===" "){r.length===0&&this.message[i]&&(r.push(this.message[i]),this.message.splice(i,1));break}e>0?(r.push(this.message[i]),this.message.splice(i,1),i-=e):(r.splice(0,0,this.message[i]),this.message.splice(i,1))}return r}getWordAtIndex(t){let e=[];for(let r=t;r<this.message.length&&this.message[r].char!==" ";r++)e.push(this.message[r]);for(let r=t-1;r>=0&&this.message[r].char!==" ";r--)e.splice(0,0,this.message[r]);return e}wordSize(t=0,e=-1){let r=0,i=t;for(;i>=0&&i<this.message.length;){if(this.message[i].char===" "){r===0&&(r=this.message[i].charSize);break}r+=this.message[i].charSize,i+=e}return(i<0||i>=this.message.length)&&!this.endLine?this.message[t]?this.message[t].charSize:999999999:r===0?999999999:r}spaceLeft(t){return t-this.nextChar3DPos.x}popChar(t=this.message.length-1){return this.nextChar3DPos.x-=this.message[t].charSize,this.message.splice(t,1)}isEmpty(){return!this.message.length}updateNextCharPosY(){this.nextChar3DPos.y=this.yLinePos+this.maxCharSize*this.lineHeight}updateYLinePos(t){this.yLinePos=t,this.updateNextCharPosY()}updatelineHeight(t){this.lineHeight=t,this.updateNextCharPosY()}updateFontSize(t,e=0,r=this.message.length-1){for(let i=e;i<=r;i+=1)this.message[i].updateFontSize(t);this.maxCharSize=t,this.nextChar3DPos.y=this.yLinePos+this.maxCharSize*this.lineHeight}countSpaces(){let t=0;for(let e=0;e<this.message.length;e++)this.message[e].char===" "&&(t+=1);return t}alignText(t,e,r,i,o){switch(r){case 1:this.leftAlign(t,o);break;case 3:this.centerAlign(this.spaceLeft(e),t,o);break;case 2:this.rightAlign(this.spaceLeft(e),t,o);break;case 4:this.justifyAlign(this.spaceLeft(e),t,o);break}}offsetCharacters(t,e,r){ba.set(e,r);let i=this.message.length;for(let o=0;o<i;o++)this.message[o].updatePosition(this.message[o].localPosition.add(ba),t)}leftAlign(t,e){this.align=1,this.offsetCharacters(t,0,e)}centerAlign(t,e,r){this.align=3,this.offsetCharacters(e,t/2,r)}rightAlign(t,e,r){this.align=2,this.offsetCharacters(e,t,r)}justifyAlign(t,e,r){if(this.align=4,this.endLine){this.offsetCharacters(e,0,r);return}let i=this.countSpaces();if(i===0){this.offsetCharacters(e,0,r);return}let o=t/i,s=0;for(let a=0;a<this.message.length;a++)this.message[a].char===" "&&(s+=o),ba.set(s,r),this.message[a].updatePosition(this.message[a].localPosition.add(ba),e)}clone(){let t=new ei(this.yLinePos,this.lineHeight,this.maxCharSize);t.nextChar3DPos=this.nextChar3DPos.clone(),t.align=this.align,t.endLine=this.endLine;for(let e=0;e<this.message.length;e++)t.message.push(this.message[e].clone());return t}};var Yl=class extends at{constructor(e,r=new mt({transparent:!0,opacity:1,visible:!1,side:va})){super(e,r);this.objectType="TextFrame";this.charContainer=new sw,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:1,horizontalAlignment:1,verticalAlignment:1,LOD:16,maxLineSize:this._geometryUserData.parameters.width,textOrigin:new Eu(this._geometryUserData.parameters.width*-.5,this._geometryUserData.parameters.height*.5,0),textLines:[]},this.createTextLine()}static createFromState(e,r,i){let o=$s.create({parameters:{width:r.width,height:r.height}}),s=new Yl(o).fromState(r,i);return s.uuid=e,s}async updateText(e){this.clearText();let r=this.userData.textFrame,i=r.fontFamily;await Mt.loadFont(i),r.text=e;let o=r.textOrigin,s=new Bu({visible:r.visible,transparent:!0,side:va}),a=e.split(`
|
|
958
|
+
`),l=0;this.userData.textFrame.textLines=a.map((c,p)=>{let h=new ei(l,r.lineHeight,r.fontSize);return h.message=c.split("").map(d=>{let m={char:d,fontFamily:i,letterSpacing:r.letterSpacing,fontSize:r.fontSize,LOD:16},f=s.clone();f.color=r.hexColor,f.opacity=r.opacity;let T=new Mt(m,f);return h.addChar3D(T,o),this.charContainer.add(T),T}),l+=h.maxCharSize*h.lineHeight,h}),this.textFullUpdate(),this.checkOverFlow()}clearText(){let e=this.userData.textFrame.textLines;for(;this.charContainer.children.length;){let r=this.charContainer.children[0];this.charContainer.remove(r)}for(;e.length;)e.pop()}raycast(e,r){let i=[];if(super.raycast(e,i),i.length>0){r.push(i[0]);return}let o=[];for(let s=0,a=this.charContainer.children.length;s<a;++s)if(this.charContainer.children[s]instanceof Mt&&(e.intersectObject(this.charContainer.children[s],!1,o),o.length>0)){o[0].object=this,r.push(o[0]);return}}updateGeometry(e){var p,h,d,m;let r=this.userData,i=this.geometry.userData,o=i.parameters.width,s=i.parameters.height,a=(h=(p=e.parameters)==null?void 0:p.width)!=null?h:o,l=(m=(d=e.parameters)==null?void 0:d.height)!=null?m:s,c=r.textFrame;super.updateGeometry(e),c.maxLineSize=a,c.textOrigin.set(-.5*a,.5*l,0),l!==s?(this.checkOverFlow(),this.checkCapacity()):a!==o&&(o<a?this.checkCapacity():o>a&&this.checkOverFlow())}checkOverFlow(e=0){let r=this.userData,i=r.textFrame.textOrigin,o=r.textFrame.textLines;for(let s=e;s<o.length;s++){o[s].updateYLinePos(this.getNewLinePosition(s)),o[s].fullUpdate(i);let a=[];for(;o[s].checkOverFlow(r.textFrame.maxLineSize);)o[s].containSpaceOverFlow()?a.unshift(o[s].getWord(o[s].message.length-1,-1)):a.unshift(o[s].popChar());if(a.length>0){o[s+1]===void 0?(o[s].isEndLine(!1),this.createTextLine()):o[s].endLine&&(this.createTextLine(s+1),o[s].isEndLine(!1),o[s+1].isEndLine(!0));let l=0;for(let c=0;c<a.length;c+=1)for(let p=0;p<a[c].length;p+=1)o[s+1].addChar3D(a[c][p],i,l),l+=1;o[s+1].fullUpdate(i)}o[s].fullUpdate(i)}this.textFullUpdate(e)}checkCapacity(e=0){let r=this.userData,i=r.textFrame.textOrigin,o=r.textFrame.maxLineSize,s=r.textFrame.textLines;for(let a=e;a<s.length;a+=1)if(s[a].updateYLinePos(this.getNewLinePosition(a)),s[a].fullUpdate(i),!!s[a-1])for(;!s[a-1].endLine;){let l,c=s[a-1].spaceLeft(o);if(s[a].wordSize(0,1)<=c){s[a].containSpace()?l=s[a].getWord(0,1):l=s[a].popChar(0);for(let p=0;p<l.length;p+=1)l[p]&&s[a-1].addChar3D(l[p],i)}else{s[a].isEmpty()?(s[a].endLine&&s[a-1].isEndLine(!0),s.splice(a,1),a-=1):(s[a].updateYLinePos(this.getNewLinePosition(a)),s[a].fullUpdate(i));break}}this.textFullUpdate(e)}createTextLine(e=this.userData.textFrame.textLines.length){let i=this.userData.textFrame;i.textLines.splice(e,0,new ei(this.getNewLinePosition(e),i.lineHeight,i.fontSize))}textFullUpdate(e=0){let i=this.userData.textFrame,o=i.textLines,s=this.getVerticalAlignmentOffSet();for(let a=e;a<o.length;a++)o[a].updateYLinePos(this.getNewLinePosition(a)),o[a].fullUpdate(i.textOrigin),o[a].alignText(i.textOrigin,i.maxLineSize,i.horizontalAlignment,i.verticalAlignment,s)}getVerticalAlignmentOffSet(){switch(this.userData.textFrame.verticalAlignment){case 1:return 0;case 2:return this.getRemainingVerticalSpace()/2;case 3:return this.getRemainingVerticalSpace();default:return 0}}getRemainingVerticalSpace(){let r=this.userData.textFrame.textLines;return this.geometry.userData.parameters.height-this.getNewLinePosition(r.length)}getNewLinePosition(e){let i=this.userData.textFrame.textLines,o=0;for(let s=0;s<e;s+=1)o+=i[s].maxCharSize*i[s].lineHeight;return o}updateColor(e){var o;let r=this.userData;r.textFrame.hexColor=e;let i=r.textFrame.textLines;for(let s=0;s<i.length;s++){let a=i[s].message;for(let l=0;l<a.length;l++){let c=a[l].material;(o=c.color)!=null&&o.isColor&&(c.color=e)}}}updateOpacity(e){let r=this.userData;r.textFrame.opacity=e;let i=r.textFrame.textLines;for(let o=0;o<i.length;o++){let s=i[o].message;for(let a=0;a<s.length;a++){let l=s[a].material;l.opacity=e}}}updateVisible(e){let r=this.userData;r.textFrame.visible=e;let i=r.textFrame.textLines;for(let o=0;o<i.length;o++){let s=i[o].message;for(let a=0;a<s.length;a++){let l=s[a].material;l.visible=e}}}async updateFontFamily(e){await Mt.loadFont(e);let i=this.userData.textFrame,o=i.textLines;i.fontFamily=e;for(let s=0;s<o.length;s++){let a=o[s].message;for(let l=0;l<a.length;l++)a[l].updateFontFamily(e)}this.textFullUpdate(),this.checkOverFlow(),this.checkCapacity()}updateFontSize(e){let i=this.userData.textFrame,o=i.textLines,s=i.fontSize;i.fontSize=e;for(let a=0;a<o.length;a++)o[a].updateFontSize(e);this.textFullUpdate(),e>s?this.checkOverFlow():e<s&&this.checkCapacity()}async updateTextTransform(e){let i=this.userData.textFrame;await Mt.loadFont(i.fontFamily);let o=i.textLines;switch(i.textTransform=e,e){case 2:for(let s=0;s<o.length;s++){let a=o[s].message;for(let l=0;l<a.length;l++)o[s].message[l].updateChar(a[l].char.toUpperCase())}break;case 3:for(let s=0;s<o.length;s++){let a=o[s].message;for(let l=0;l<a.length;l++)o[s].message[l].updateChar(a[l].char.toLowerCase())}break;default:for(let s=0;s<o.length;s++){let a=o[s].message;for(let l=0;l<a.length;l++)o[s].message[l].updateChar(a[l].originalChar)}}this.textFullUpdate(),this.checkOverFlow(),this.checkCapacity()}updateLetterSpacing(e){let r=this.userData,i=r.textFrame.textLines;r.textFrame.letterSpacing=e;for(let o=0;o<i.length;o++){let s=i[o].message;for(let a=0;a<s.length;a++)s[a].updateLetterSpacing(e)}this.textFullUpdate(),this.checkOverFlow(),this.checkCapacity()}updateLOD(e){let r=this.userData;r.textFrame.LOD=e;let i=r.textFrame.textLines;for(let o=0;o<i.length;o++);this.textFullUpdate(),this.checkOverFlow(),this.checkCapacity()}updateLineHeight(e){let r=this.userData,i=r.textFrame.textLines;r.textFrame.lineHeight=e;for(let o=0;o<i.length;o++)i[o].updatelineHeight(e);this.textFullUpdate()}updateVerticalAlignment(e){let r=this.userData;r.textFrame.verticalAlignment=e,this.textFullUpdate()}updateHorizontalAlignment(e){let r=this.userData;r.textFrame.horizontalAlignment=e,this.textFullUpdate()}toJSON(e){let r=super.toJSON(e),i=r.object;i.objectType="TextFrame";let s=this.userData.textFrame.textLines.map(a=>{let l=a.message.map(c=>({char:c.char,originalChar:c.originalChar,fontFamily:c.fontFamily,letterSpacing:c.letterSpacing,fontSize:c.fontSize,LOD:c.LOD}));return{align:a.align,endLine:a.endLine,lineHeight:a.lineHeight,maxCharSize:a.maxCharSize,yLinePos:a.yLinePos,message:l}});return i.userData.textFrame.textLinesData=s,r}async fromJSONasync(e){if(super.fromJSON(e),e.userData!==void 0){let r=e.userData.textFrame;await Mt.loadFont(r.fontFamily),r.textOrigin=new Eu(r.textOrigin.x,r.textOrigin.y,r.textOrigin.z);let i=new Bu({color:r.hexColor,opacity:r.opacity,visible:r.visible,transparent:!0,side:va});r.textLinesData&&(r.textLines=r.textLinesData.map((o,s)=>{let a=new ei(Number(o.yLinePos),Number(o.lineHeight),Number(o.maxCharSize)),l=o.message.map((c,p)=>{if(c.char===void 0){let m=r.textLines[s].message[p];if("geometries"in m){let f=m.geometries[0].userData.parameters;Object.assign(c,{LOD:f.lod,char:f.char,fontFamily:f.fontFamily,fontSize:f.fontSize,letterSpacing:f.letterSpacing,originalChar:f.char})}}let h={char:c.char,fontFamily:c.fontFamily,letterSpacing:Number(c.letterSpacing),fontSize:Number(c.fontSize),LOD:c.LOD},d=new Mt(h,i.clone());return a.addChar3D(d,r.textOrigin),this.charContainer.add(d),d});return a.message=l,a}),this.userData.textFrame=r),this.textFullUpdate()}return this}fromTextFrameData(e,r){if(e.color!==void 0){let i=Ye(e.color,r);this.updateColor(i),this.updateOpacity(i.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,r){return super.fromState(e),this.fromTextFrameData(e,r),this}convertToVector(){let{fontFamily:e,hexColor:r}=this.userData.textFrame,i=new _r;i.name="Text Shape";let o=Mt.fontCache[e];for(let s of this.charContainer.children)s instanceof Mt&&o.generateShapes(s.char,1).forEach(a=>{let l=new Me().fromShape(a);l.applyScale(s.scale.x,s.scale.y);let c=ht.create({shape:l}),p=new mt({side:va});p.color=r;let h=new Qr(c,p);h.name=s.char,h.position.copy(s.position),h.rotation.copy(s.rotation),i.attach(h)});return i}},bi=Yl;bi.VerticalAlign=Ka,bi.HorizontalAlign=Ja,bi.TextTransform=Ya;import{HemisphereLight as Sw,Scene as ww,Vector3 as Lw,Color as Ku,Fog as Cw,Box3 as Tw}from"three";import{BufferGeometryLoader as aw}from"three";function Gu(n,t){return lw(n)}function lw(n){let t={parameters:n,type:n.type};if(n.type==="VectorGeometry"){let r=Me.createFromState(n.shape,n.width,n.height);t.shape=r}else n.type==="NonParametricGeometry"&&(n.data.groups&&n.data.groups.forEach(r=>{var i;return r.materialIndex=Math.max((i=r.materialIndex)!=null?i:0,0)}),t.geometry=new aw().parse(n));let e;try{e=en(t)}catch(r){console.error(r)}if(!e){let r=Me.createFromState(Ki.defaultData(),100,100);t.shape=r,e=en(t)}return e}import{Box3 as cw,Matrix4 as vi,Sphere as Vu,Vector3 as pw}from"three";var ju=gm(Ru());var Xl;Js.then(n=>{Xl=n});var Uu=new vi,hw=new vi,dw=new vi,or=new cw,ti=new pw,uw=new vi,mw=new vi,Oo=class extends at{constructor(e,r,i,o=new Vt){super(i!=null?i:r,o);this.subdivPointer=e;this.originalGeometry=r;this.subdividedGeometry=i;this.objectType="SubdivObject";this.hiddenMatrixOld=new vi;this.smoothShading=!0;this.matrixWorldRigid=new vi;this.castShadow=!0,this.receiveShadow=!0,this.forceComputeSize=!1}static createFromState(e,r,i){let{subdivPointer:o,originalGeometry:s,subdividedGeometry:a}=zt.build(r.geometry,void 0,void 0,!r.flatShading),l=wn(r.material,i),c=new Oo(o,s,a||void 0,l);return c.calcBoundingBox(),c.freeSubdivPointer(),c.uuid=e,c.fromState(r),c}shallowClone(e){return new Mo(this.geometry,this.material).shallowCopy(this,e)}toJSON(e){let r=super.toJSON(e);return r.object.objectType="SubdivObject",r}buildFromStore(e){var s,a,l;let{originalGeometry:r,subdividedGeometry:i,subdivPointer:o}=zt.build(e,this.subdivPointer,void 0,this.smoothShading,this.shearScale);if(this.subdivPointer=o,r!==void 0&&((s=this.originalGeometry)==null||s.dispose(),this.originalGeometry=r),i!==void 0&&((a=this.subdividedGeometry)==null||a.dispose(),this.subdividedGeometry=i!=null?i:void 0),this.geometry=(l=this.subdividedGeometry)!=null?l:this.originalGeometry,this.cloner)for(let c of this.cloner.children)c.geometry=this.geometry;e.width&&(this.geometry.userData.parameters={width:e.width,height:e.height,depth:e.depth})}updateMesh(e=!1){zt.buildLevel(this.subdivPointer,!0,this.smoothShading,this.originalGeometry,e?this.shearScaleInv:void 0),this.subdividedGeometry&&zt.buildLevel(this.subdivPointer,!1,this.smoothShading,this.subdividedGeometry,e?this.shearScaleInv:void 0)}updateTopology(){var e;this.originalGeometry.dispose(),this.originalGeometry=zt.buildLevel(this.subdivPointer,!0,this.smoothShading),this.subdividedGeometry&&(this.subdividedGeometry.dispose(),this.subdividedGeometry=zt.buildLevel(this.subdivPointer,!1,this.smoothShading)),this.geometry=(e=this.subdividedGeometry)!=null?e:this.originalGeometry}raycast(e,r){var i;this.geometry=this.originalGeometry,at.prototype.raycast.call(this,e,r),this.geometry=(i=this.subdividedGeometry)!=null?i:this.originalGeometry}updateMatrixWorldSVD(){let e=this.matrixWorld.elements,r=[[e[0],e[4],e[8]],[e[1],e[5],e[9]],[e[2],e[6],e[10]]],{u:i,v:o,q:s}=(0,ju.SVD)(r),a=Uu.set(i[0][0],i[0][1],i[0][2],0,i[1][0],i[1][1],i[1][2],0,i[2][0],i[2][1],i[2][2],0,0,0,0,1),l=hw.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),c=dw.copy(l).transpose();this.shearScale=uw.makeScale(s[0],s[1],s[2]).multiply(c).premultiply(l),this.shearScaleInv=mw.copy(this.shearScale).invert(),this.matrixWorldRigid.multiplyMatrices(a,c),s.every(p=>Math.abs(s[0]-p)<.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 Vu);let r=e.attributes.position,i=e.boundingSphere.center;or.setFromBufferAttribute(r),or.getCenter(i),e.boundingSphere.radius=i.distanceTo(or.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),or.getSize(ti);let o={width:ti.x,height:ti.y,depth:ti.z};return this.geometry.userData.parameters=o,o}updateBoundingBox(e){let r=this.originalGeometry;or.min.set(e[0],e[2],e[4]),or.max.set(e[1],e[3],e[5]),this.shearScaleInv&&(or.min.applyMatrix4(this.shearScaleInv),or.max.applyMatrix4(this.shearScaleInv)),r.boundingSphere===null&&(r.boundingSphere=new Vu);let i=r.boundingSphere.center;or.getCenter(i),r.boundingSphere.radius=i.distanceTo(or.max),isNaN(r.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),or.getSize(ti);let o={width:ti.x,height:ti.y,depth:ti.z};return this.geometry.userData.parameters=o,o}freeSubdivPointer(){this.subdivPointer&&(Xl.free_bvh(this.subdivPointer),Xl.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,Fu(this.originalGeometry.attributes,...this.geometry.userData.scale),this.originalGeometry.attributes.position.needsUpdate=!0,this.originalGeometry.attributes.normal.needsUpdate=!0,this.subdividedGeometry&&(Fu(this.subdividedGeometry.attributes,...this.subdividedGeometry.userData.scale),this.subdividedGeometry.attributes.position.needsUpdate=!0,this.subdividedGeometry.attributes.normal.needsUpdate=!0),this.geometry.userData.parameters=P({},e.parameters)}};function Fu(n,t,e,r){let i=n.position.array,o=n.normal.array,s=Uu.makeScale(t,e,r).invert().elements,a,l,c;for(var p=0,h=i.length;p<h;p+=3)i[p]*=t,i[p+1]*=e,i[p+2]*=r,a=o[p],l=o[p+1],c=o[p+2],o[p]=s[0]*a+s[4]*l+s[8]*c,o[p+1]=s[1]*a+s[5]*l+s[9]*c,o[p+2]=s[2]*a+s[6]*l+s[10]*c}import{BackSide as fw,DoubleSide as yw,FrontSide as gw}from"three";function ku(n,t){t.flatShading!==void 0&&(n.flatShading=t.flatShading,n.needsUpdate=!0),t.wireframe!==void 0&&(n.wireframe=t.wireframe),t.side!==void 0&&(t.side===0?n.side=gw:t.side===1?n.side=fw:n.side=yw)}function xw(n,t){if(Array.isArray(n.material))for(let e of n.material)ku(e,t);else{let e=n.material;ku(e,t)}n.objectType==="SubdivObject"&&t.flatShading!==void 0&&(n.material.flatShading=!1,n.smoothShading=!t.flatShading,n.updateMesh())}function Hu(n,t,e){let r;if(t.geometry.type==="SubdivGeometry")r=Oo.createFromState(n,t,e);else{let i=Gu(t.geometry,e),o="materials"in t?Su(t.materials,e):wn(t.material,e);As.is2DParametricMesh(i.userData.type)?r=new xo(i,o):(i==null?void 0:i.userData.type)==="VectorGeometry"?r=new Qr(i,o):t.geometry.type==="NonParametricGeometry"?r=new Mo(i,o):r=new No(i,o),r.uuid=n,r.fromState(t)}return xw(r,t),r}function qu(n,t,e){return t.type==="Mesh"?Hu(n,t,e):t.type==="TextFrame"?bi.createFromState(n,t,e):t.type==="Empty"?_r.createFromState(n,t):t.type==="PointLight"?Co.createFromState(n,t,e):t.type==="SpotLight"?To.createFromState(n,t,e):t.type==="DirectionalLight"?Lo.createFromState(n,t,e):ji.is(t.type)?Dr.createFromState(n,t):(console.error(t),new _r)}function bw(n,t){t.uniforms[`f${t.id}_transmissionSamplerMap`].value=n.texture,t.uniforms[`f${t.id}_transmissionDepthMap`].value=n.depthTexture}function Wu(n,t,e){if(!e.userData.layers)return!1;let r=!1,i=e.userData.layers.getLayersOfType("transmission");return i.length>0?(t.layers.set(3),r=!0,n!==void 0&&i.forEach(o=>bw(n,o))):t.layers.set(0),r}function $u(n,t){let e=!1;return t.traverseEntity(r=>{if(r instanceof at)if(Array.isArray(r.material))for(let i=0;i<r.material.length;i++)Wu(n,r,r.material[i])&&(e=!0);else Wu(n,r,r.material)&&(e=!0)}),e}function Ju(n,t){"material"in n&&vw(n.material,t),"geometry"in n&&n.geometry.dispose()}function vw(n,t){oc(n).forEach(e=>{t.isSharedMaterial(e)||e.dispose()})}var Yu=new Lw,Zl=class extends Ys(ww){constructor(e,r){super();this.objectType="Scene";this.alpha=1;this.backupFog=new Cw(16777215,.1,2e3);this.fogUseBGColor=!1;this.wireframeState=!1;this.needsTransmissionDirty=!0;this._needsTransmission=!1;this._color=new Ku(1,0,0);this.bgColor=new Ku(1,1,1);this.entityByUuid={};this.ambientLight=new Sw(13882323,8553090,.75),this.ambientLight.name="Default Ambient Light",this.personalCamera=this.createPersonalCamera(),this.activeCamera=this.personalCamera,this.sharedAssetManager=r,this.init(e,r)}needsTransmission(e){return this.needsTransmissionDirty&&(this._needsTransmission=$u(e,this),e!==void 0&&(this.needsTransmissionDirty=!1)),this._needsTransmission}find(e){if(e===""||e===void 0)return;let r=this.entityByUuid[e];return r===void 0?this.getObjectByProperty("uuid",e):r}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,r){if(this.createChildrenObjects(e.objects,this,r),this.personalCamera.removeFromParent(),this.add(this.personalCamera),this.ambientLight.removeFromParent(),this.add(this.ambientLight),this.setBackgroundColor(Ye(e.backgroundColor,r)),this.updateFog(e.fog,r),this.updateAmbientLight(e.environment.ambientLight,r),this.activeCamera=this.personalCamera,e.publish.playCamera!==null){let i=this.find(e.publish.playCamera);i instanceof Dr&&this.switchActiveCamera(i)}}clearScene(e){this.traverseEntity(r=>{Ju(r,e)});for(let r of this.children)Jt(r)&&r.removeFromParent()}resetAfterClear(e,r){this.init(e,r)}createPersonalCamera(){let e=Dr.createFromState(Zl.PERSONAL_CAMERA_ID,W(P({},_s.defaultData),{name:"Personal Camera"}));return e.enableHelper=!1,e.objectHelper.visible=!1,delete e.isEntity,this.registerObjectCreatedInLegacy(e),e}raycast(e){let r=[],i=o=>{for(let s of o.children)Jt(s)&&!s.raycastLock&&s.visible&&((io(s)||Or(s)&&s.enableHelper&&s.objectHelper.parent)&&e.intersectObject(s,!1,r),i(s))};return i(this),r}traverseEntity(e){for(let r of this.children)Jt(r)&&r.traverseEntity(e)}updateFog(e,r){this.enableFog=e.enabled,this.fogUseBGColor=e.useBackgroundColor,e.useBackgroundColor?this.backupFog.color.set(this.bgColor):this.backupFog.color=Ye(e.color,r),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,r){Yd(this.ambientLight,e,r),e.groundColor!==void 0&&(this.ambientLight.groundColor=Ye(e.groundColor,r)),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,r,i){for(let o of e)this.createChildObject(o.id,o.data,o.children,r,i)}registerObjectCreatedInLegacy(e){this.entityByUuid[e.uuid]=e}unregisterObject(e){delete this.entityByUuid[e.uuid];for(let r of e.children)this.unregisterObject(r)}createChildObject(e,r,i,o,s){let a=qu(e,r,s);return a&&(this.entityByUuid[e]=a,o.add(a),this.createChildrenObjects(i,a,s)),a}getCenter(e){let r=[];for(let o=0,s=e.length;o<s;++o){let{id:a,recursive:l}=e[o],c=this.find(a),p=l?c.recursiveBBox:c.singleBBox;r.push(...p.vertices)}let i=new Tw;return i.setFromPoints(r),i.getCenter(Yu),Yu}copyMatrixWorld(e,r){if(e===null){r.identity();return}let i=this.find(e);i?r.copy(i.matrixWorld):r.identity()}copyParentMatrixWorld(e,r){var o;if(e===null){r.identity();return}let i=(o=this.find(e))==null?void 0:o.parent;i?r.copy(i.matrixWorld):r.identity()}traverseMaterial(e){this.traverseEntity(r=>{if(r instanceof at)if(Array.isArray(r.material))for(let i=0;i<r.material.length;i++)e(r.material[i]);else e(r.material)})}updateCanvasSize(e,r){this.activeCamera.setViewplaneSize(e,r);let i,o;e>=r?(i=r/e,o=1):(i=1,o=e/r),this.traverseMaterial(s=>{s.layersList.getLayersOfType("transmission").forEach(l=>{l.uniforms[`f${l.id}_aspectRatio`].value.x=i,l.uniforms[`f${l.id}_aspectRatio`].value.y=o})})}},Cn=Zl;Cn.PERSONAL_CAMERA_ID="f23858d0-4a3b-4bd8-8173-66ed0af7f6fb-personalCamera";import{DRACOLoader as Nw}from"three/examples/jsm/loaders/DRACOLoader.js";var ri;function Mw(){return ri||(ri=new Nw,ri.setDecoderPath("https://www.gstatic.com/draco/versioned/decoders/1.5.2/").preload()),ri.decoderPending}async function Ow(n){if(ri){let t={attributeIDs:ri.defaultAttributeIDs,attributeTypes:ri.defaultAttributeTypes,useUniqueIDs:!1},e;try{e=await ri.decodeGeometry(new Int8Array(n).buffer,t)}catch(r){console.error(r)}if(e)return{index:e.index?{array:e.index.array}:void 0,attributes:Object.entries(e.attributes).map(([r,i])=>({name:r,itemSize:i.itemSize,array:i.array}))}}return null}async function Xu(n){let[t,e]=Da(Ns.deserialize(new Uint8Array(n))),r=[];t.scene.objects.traverse((i,o)=>{o.type==="Mesh"&&o.geometry.type==="NonParametricGeometry"&&o.geometry.data.draco!==void 0&&r.push(o)}),r.length&&await Mw();for(let i of r){let o=await Ow(Ba(i.geometry.data.draco));if(o){o.index&&(i.geometry.data.index={array:o.index.array,itemSize:1,normalized:!1,type:"Uint32Array"});let s={};o.attributes.forEach(({name:a,array:l,itemSize:c})=>{s[a]={array:l,itemSize:c,type:"Float32Array",normalized:!1}}),i.geometry.data.attributes=s,i.geometry.data.draco=void 0}}return e.result().data}import{WebGLRenderTarget as Iw,LinearMipmapLinearFilter as Pw,LinearFilter as Aw,ClampToEdgeWrapping as Zu,DepthTexture as Dw}from"three";var Qu=new mt,wa=class extends Pt{},La=class{constructor(t){this.materials={};this.images={};this.colors={};this.transmissionRenderTarget=new Iw(2048,2048,{generateMipmaps:!0,minFilter:Pw,magFilter:Aw,wrapS:Zu,wrapT:Zu}),this.transmissionRenderTarget.depthTexture=new Dw(2048,2048),this.reset(t)}reset(t){for(let[e,r]of Object.entries(t.images))this.addImage(e,r.data);for(let[e,r]of Object.entries(t.colors))this.addColor(e,r);for(let[e,r]of Object.entries(t.materials))this.addMaterial(e,Hl(r,this))}get transmissionSamplerMap(){return this.transmissionRenderTarget.texture}get transmissionDepthMap(){return this.transmissionRenderTarget.depthTexture}addMaterial(t,e){e.uuid=t,this.materials[t]=e}deleteMaterial(t){this.materials[t]&&(this.materials[t].dispose(),delete this.materials[t])}isSharedMaterial(t){return t.uuid in this.materials||t===Qu}getMaterial(t){let e=this.materials[t];return e}getMaterialOrDeletedPlaceholder(t){var e;return(e=this.materials[t])!=null?e:Qu}getMaterials(){return this.materials}addImage(t,e){if(this.images[t])return this.images[t].onload=()=>{this.onImageLoad&&this.onImageLoad(t)},this.images[t].src=e,!0;{let r=new Image;return r.src=e,r.onload=()=>{this.onImageLoad&&this.onImageLoad(t)},this.images[t]=r,!1}}deleteImage(t){this.images[t]&&delete this.images[t]}getDefaultImage(){return this.images.image_0}getImage(t){return this.images[t]}getImages(){return this.images}addColor(t,e){return this.colors[t]?("a"in e?this.colors[t].setRGBA(e.r,e.g,e.b,e.a):this.colors[t].setRGBA(e.r,e.g,e.b,1),!0):("a"in e?this.colors[t]=new wa(e.r,e.g,e.b,e.a):this.colors[t]=new wa(e.r,e.g,e.b,1),!1)}updateColor(t,e){var r,i,o,s;if(this.colors[t]){let a=this.colors[t];return this.colors[t].r=(r=e.r)!=null?r:a.r,this.colors[t].g=(i=e.g)!=null?i:a.g,this.colors[t].b=(o=e.b)!=null?o:a.b,this.colors[t].a=(s=e.a)!=null?s:a.a,!0}return!1}deleteColor(t){this.colors[t]&&delete this.colors[t]}getColor(t){return this.colors[t]}dispose(){Object.keys(this.materials).forEach(e=>this.deleteMaterial(e)),this.transmissionRenderTarget.depthTexture.dispose(),this.transmissionRenderTarget.dispose(),this.onImageLoad=void 0}};import{Mesh as Gk}from"three";import{mergeBufferGeometries as Vk}from"three/examples/jsm/utils/BufferGeometryUtils.js";function em(n){let t;if(!!n.index)for(let e=0;e<n.index.array.length;e+=3)t=n.index.array[e],n.index.array[e]=n.index.array[e+2],n.index.array[e+2]=t}import{Color as tm,ShaderLib as _w}from"three";function rm(n){let t=new Set;return n.traverse(e=>{if(io(e))if(Qe(e.material))e.material.forEach(r=>{let i=r;t.has(i)||t.add(i)});else{let r=e.material;t.has(r)||t.add(r)}}),t.forEach(e=>{if(e instanceof Array)return;let r=e.onBeforeCompile.bind(e);Bw(e)?(Object.assign(e,{isMeshStandardMaterial:!0,isMeshPhysicalMaterial:!0,transmission:1,attenuationColor:new tm,specularColor:new tm}),e.onBeforeCompile=(i,o)=>{r&&r(i,o),i.uniforms=Object.assign(_w.physical.uniforms,i.uniforms),e.userData.layers.getLayersOfType("transmission").forEach(s=>{i.uniforms.transmissionSamplerMap.value&&(s.uniforms["f"+s.id+"_transmissionSamplerMap"].value=i.uniforms.transmissionSamplerMap.value,s.uniforms["f"+s.id+"_transmissionSamplerSize"].value=i.uniforms.transmissionSamplerSize.value)})}):Ew(e)||(e.onBeforeCompile=(i,o)=>{r&&r(i,o),e.transparent=!1})}),n}function Bw(n){return n.userData.layers.getLayersOfType("transmission").length>0}function Ew(n){let t=n.userData.layers.head,e=0;for(;t!==void 0;){if(t.type!=="light"&&t.type!=="fresnel"){let r=t.uniforms["f"+t.id+"_alpha"];r&&(e+=(1-e)*r.value)}t=t.next}return e<1}function im(n){return n.traverse(t=>{if(t.type==="Camera"){let e=t;e.type=e.cameraType}}),n}function om(n){let t=[],e=(r,i=0)=>{let o=i>0?r+i:r;return t.includes(o)?e(r,i+1):o};return n.traverse(r=>{if(t.includes(r.name)){let i=r.name,o=e(r.name);if(r.name=o,r.isMesh){let s=r;s.material instanceof Array?s.material.forEach(a=>{a.name=a.name.replace(i,o)}):s.material.isAsset||(s.material.name=s.material.name.replace(i,o))}}t.push(r.name)}),n}import{mergeBufferGeometries as Gw}from"three/examples/jsm/utils/BufferGeometryUtils";function nm(n){let t=[];return n.traverse(e=>{e instanceof ui&&t.push(e)}),t.forEach(e=>{let r=e.object,i=e.children,o=i.map(a=>{a.updateMatrix();let l=a.geometry.clone().applyMatrix4(a.matrix);return a.matrix.determinant()<0&&em(l),l}),s=Gw(e.parameters.hideBase?o:[r.geometry,...o]);r.geometry=s,r.material=i[0].material,r.remove(e)}),n}var sm="The SplineLoader only accepts .splinecode files that are generated from Spline export panel.",Ql=class extends Rw{load(t,e,r,i=console.error){let o=new zw(this.manager);o.setPath(this.path),o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),t.endsWith(".spline")?console.warn(sm+" The .spline files are only meant to be used by the Editor."):t.endsWith(".splinecode")||console.warn(sm),o.load(t,async s=>{try{if(typeof s=="string")throw new Error("The .spline file is not binary!");let a=await this.parse(s);e(a)}catch(a){i(a)}},r,i)}async parse(t){let e=await Xu(t),r=new La(e.shared);Object.values(r.getMaterials()).forEach(s=>Object.assign(s,{isAsset:!0}));let i=new Cn(e.scene,r);i.remove(i.personalCamera),e.scene.environment.ambientLight.enabled||i.remove(i.ambientLight);let o=e.scene.publish.playCamera;if(o){let s=i.find(o);s&&Kd(s)&&Object.assign(s,{makeDefault:!0})}return i=nm(i),i=rm(i),i=im(i),i=om(i),i}};export{Ql as default};
|