@splinetool/loader 0.9.38 → 0.9.39
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/SplineLoader.js +1 -1
- package/package.json +1 -1
package/build/SplineLoader.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
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*((.|
|
|
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: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 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
2
|
)*?)}`,"gim"),Ev=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=Bv.exec(e);if(r){let i=r[2],o;for(;o=Ev.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 Gv,sRGBEncoding as zv}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 Gv:return["Linear"];case zv: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(`
|