@splinetool/loader 0.9.19 → 0.9.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,14 +1,14 @@
1
- var tm=Object.create;var Ti=Object.defineProperty,rm=Object.defineProperties,om=Object.getOwnPropertyDescriptor,im=Object.getOwnPropertyDescriptors,sm=Object.getOwnPropertyNames,Ds=Object.getOwnPropertySymbols,nm=Object.getPrototypeOf,Ra=Object.prototype.hasOwnProperty,Dc=Object.prototype.propertyIsEnumerable;var Bc=(i,e,t)=>e in i?Ti(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,P=(i,e)=>{for(var t in e||(e={}))Ra.call(e,t)&&Bc(i,t,e[t]);if(Ds)for(var t of Ds(e))Dc.call(e,t)&&Bc(i,t,e[t]);return i},q=(i,e)=>rm(i,im(e)),Gc=i=>Ti(i,"__esModule",{value:!0});var Ec=(i,e)=>{var t={};for(var r in i)Ra.call(i,r)&&e.indexOf(r)<0&&(t[r]=i[r]);if(i!=null&&Ds)for(var r of Ds(i))e.indexOf(r)<0&&Dc.call(i,r)&&(t[r]=i[r]);return t};var zc=(i,e)=>()=>(e||i((e={exports:{}}).exports,e),e.exports),am=(i,e)=>{Gc(i);for(var t in e)Ti(i,t,{get:e[t],enumerable:!0})},lm=(i,e,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of sm(e))!Ra.call(i,r)&&r!=="default"&&Ti(i,r,{get:()=>e[r],enumerable:!(t=om(e,r))||t.enumerable});return i},Fc=i=>lm(Gc(Ti(i!=null?tm(nm(i)):{},"default",i&&i.__esModule&&"default"in i?{get:()=>i.default,enumerable:!0}:{value:i,enumerable:!0})),i);var Ju=zc(la=>{"use strict";la.byteLength=wS;la.toByteArray=LS;la.fromByteArray=MS;var Nr=[],er=[],NS=typeof Uint8Array!="undefined"?Uint8Array:Array,Hl="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(Co=0,ku=Hl.length;Co<ku;++Co)Nr[Co]=Hl[Co],er[Hl.charCodeAt(Co)]=Co;var Co,ku;er["-".charCodeAt(0)]=62;er["_".charCodeAt(0)]=63;function Uu(i){var e=i.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var t=i.indexOf("=");t===-1&&(t=e);var r=t===e?0:4-t%4;return[t,r]}function wS(i){var e=Uu(i),t=e[0],r=e[1];return(t+r)*3/4-r}function CS(i,e,t){return(e+t)*3/4-t}function LS(i){var e,t=Uu(i),r=t[0],o=t[1],s=new NS(CS(i,r,o)),n=0,a=o>0?r-4:r,l;for(l=0;l<a;l+=4)e=er[i.charCodeAt(l)]<<18|er[i.charCodeAt(l+1)]<<12|er[i.charCodeAt(l+2)]<<6|er[i.charCodeAt(l+3)],s[n++]=e>>16&255,s[n++]=e>>8&255,s[n++]=e&255;return o===2&&(e=er[i.charCodeAt(l)]<<2|er[i.charCodeAt(l+1)]>>4,s[n++]=e&255),o===1&&(e=er[i.charCodeAt(l)]<<10|er[i.charCodeAt(l+1)]<<4|er[i.charCodeAt(l+2)]>>2,s[n++]=e>>8&255,s[n++]=e&255),s}function OS(i){return Nr[i>>18&63]+Nr[i>>12&63]+Nr[i>>6&63]+Nr[i&63]}function TS(i,e,t){for(var r,o=[],s=e;s<t;s+=3)r=(i[s]<<16&16711680)+(i[s+1]<<8&65280)+(i[s+2]&255),o.push(OS(r));return o.join("")}function MS(i){for(var e,t=i.length,r=t%3,o=[],s=16383,n=0,a=t-r;n<a;n+=s)o.push(TS(i,n,n+s>a?a:n+s));return r===1?(e=i[t-1],o.push(Nr[e>>2]+Nr[e<<4&63]+"==")):r===2&&(e=(i[t-2]<<8)+i[t-1],o.push(Nr[e>>10]+Nr[e>>4&63]+Nr[e<<2&63]+"=")),o.join("")}});var Ff=zc((za,zf)=>{(function(i,e){typeof za=="object"&&typeof zf!="undefined"?e(za):typeof define=="function"&&define.amd?define(["exports"],e):e((i=typeof globalThis!="undefined"?globalThis:i||self).SVDJS={})})(za,function(i){"use strict";i.SVD=function(e,t,r,o,s){if(t=t===void 0||t,r=r===void 0||r,s=1e-64/(o=o||Math.pow(2,-52)),!e)throw new TypeError("Matrix a is not defined");var n,a,l,c,d,h,p,m,f,x,g,N,C=e[0].length,S=e.length;if(S<C)throw new TypeError("Invalid matrix: m < n");for(var D=[],v=[],j=[],O=t==="f"?S:C,u=x=p=0;u<S;u++)v[u]=new Array(O).fill(0);for(u=0;u<C;u++)j[u]=new Array(C).fill(0);var A,b=new Array(C).fill(0);for(u=0;u<S;u++)for(n=0;n<C;n++)v[u][n]=e[u][n];for(u=0;u<C;u++){for(D[u]=p,f=0,l=u+1,n=u;n<S;n++)f+=Math.pow(v[n][u],2);if(f<s)p=0;else for(m=(h=v[u][u])*(p=h<0?Math.sqrt(f):-Math.sqrt(f))-f,v[u][u]=h-p,n=l;n<C;n++){for(f=0,a=u;a<S;a++)f+=v[a][u]*v[a][n];for(h=f/m,a=u;a<S;a++)v[a][n]=v[a][n]+h*v[a][u]}for(b[u]=p,f=0,n=l;n<C;n++)f+=Math.pow(v[u][n],2);if(f<s)p=0;else{for(m=(h=v[u][u+1])*(p=h<0?Math.sqrt(f):-Math.sqrt(f))-f,v[u][u+1]=h-p,n=l;n<C;n++)D[n]=v[u][n]/m;for(n=l;n<S;n++){for(f=0,a=l;a<C;a++)f+=v[n][a]*v[u][a];for(a=l;a<C;a++)v[n][a]=v[n][a]+f*D[a]}}x<(g=Math.abs(b[u])+Math.abs(D[u]))&&(x=g)}if(r)for(u=C-1;0<=u;u--){if(p!==0){for(m=v[u][u+1]*p,n=l;n<C;n++)j[n][u]=v[u][n]/m;for(n=l;n<C;n++){for(f=0,a=l;a<C;a++)f+=v[u][a]*j[a][n];for(a=l;a<C;a++)j[a][n]=j[a][n]+f*j[a][u]}}for(n=l;n<C;n++)j[u][n]=0,j[n][u]=0;j[u][u]=1,p=D[u],l=u}if(t){if(t==="f")for(u=C;u<S;u++){for(n=C;n<S;n++)v[u][n]=0;v[u][u]=1}for(u=C-1;0<=u;u--){for(l=u+1,p=b[u],n=l;n<O;n++)v[u][n]=0;if(p!==0){for(m=v[u][u]*p,n=l;n<O;n++){for(f=0,a=l;a<S;a++)f+=v[a][u]*v[a][n];for(h=f/m,a=u;a<S;a++)v[a][n]=v[a][n]+h*v[a][u]}for(n=u;n<S;n++)v[n][u]=v[n][u]/p}else for(n=u;n<S;n++)v[n][u]=0;v[u][u]=v[u][u]+1}}for(o*=x,a=C-1;0<=a;a--)for(var L=0;L<50;L++){for(A=!1,l=a;0<=l;l--){if(Math.abs(D[l])<=o){A=!0;break}if(Math.abs(b[l-1])<=o)break}if(!A){for(d=0,c=l-(f=1),u=l;u<a+1&&(h=f*D[u],D[u]=d*D[u],!(Math.abs(h)<=o));u++)if(p=b[u],b[u]=Math.sqrt(h*h+p*p),d=p/(m=b[u]),f=-h/m,t)for(n=0;n<S;n++)g=v[n][c],N=v[n][u],v[n][c]=g*d+N*f,v[n][u]=-g*f+N*d}if(N=b[a],l===a){if(N<0&&(b[a]=-N,r))for(n=0;n<C;n++)j[n][a]=-j[n][a];break}for(x=b[l],h=(((g=b[a-1])-N)*(g+N)+((p=D[a-1])-(m=D[a]))*(p+m))/(2*m*g),p=Math.sqrt(h*h+1),h=((x-N)*(x+N)+m*(g/(h<0?h-p:h+p)-m))/x,u=l+(f=d=1);u<a+1;u++){if(p=D[u],g=b[u],m=f*p,p*=d,N=Math.sqrt(h*h+m*m),h=x*(d=h/(D[u-1]=N))+p*(f=m/N),p=-x*f+p*d,m=g*f,g*=d,r)for(n=0;n<C;n++)x=j[n][u-1],N=j[n][u],j[n][u-1]=x*d+N*f,j[n][u]=-x*f+N*d;if(N=Math.sqrt(h*h+m*m),h=(d=h/(b[u-1]=N))*p+(f=m/N)*g,x=-f*p+d*g,t)for(n=0;n<S;n++)g=v[n][u-1],N=v[n][u],v[n][u-1]=g*d+N*f,v[n][u]=-g*f+N*d}D[l]=0,D[a]=h,b[a]=x}for(u=0;u<C;u++)b[u]<o&&(b[u]=0);return{u:v,q:b,v:j}},i.VERSION="1.1.1",Object.defineProperty(i,"__esModule",{value:!0})})});import{FileLoader as e1,Loader as t1}from"three";function Rc(i){return Array.isArray(i)?i:[i]}var cm=typeof global=="object"&&global&&global.Object===Object&&global,Bs=cm;var dm=typeof self=="object"&&self&&self.Object===Object&&self,hm=Bs||dm||Function("return this")(),tt=hm;var pm=tt.Symbol,Ot=pm;var Vc=Object.prototype,um=Vc.hasOwnProperty,fm=Vc.toString,Mi=Ot?Ot.toStringTag:void 0;function mm(i){var e=um.call(i,Mi),t=i[Mi];try{i[Mi]=void 0;var r=!0}catch(s){}var o=fm.call(i);return r&&(e?i[Mi]=t:delete i[Mi]),o}var kc=mm;var gm=Object.prototype,ym=gm.toString;function xm(i){return ym.call(i)}var Uc=xm;var bm="[object Null]",vm="[object Undefined]",Jc=Ot?Ot.toStringTag:void 0;function Sm(i){return i==null?i===void 0?vm:bm:Jc&&Jc in Object(i)?kc(i):Uc(i)}var Rt=Sm;function Nm(i){return i!=null&&typeof i=="object"}var St=Nm;var wm="[object Symbol]";function Cm(i){return typeof i=="symbol"||St(i)&&Rt(i)==wm}var Do=Cm;function Lm(i,e){for(var t=-1,r=i==null?0:i.length,o=Array(r);++t<r;)o[t]=e(i[t],t,i);return o}var Gs=Lm;var Om=Array.isArray,ft=Om;var Tm=1/0,Hc=Ot?Ot.prototype:void 0,qc=Hc?Hc.toString:void 0;function Wc(i){if(typeof i=="string")return i;if(ft(i))return Gs(i,Wc)+"";if(Do(i))return qc?qc.call(i):"";var e=i+"";return e=="0"&&1/i==-Tm?"-0":e}var $c=Wc;function Mm(i){var e=typeof i;return i!=null&&(e=="object"||e=="function")}var Nt=Mm;function Im(i){return i}var Es=Im;var Pm="[object AsyncFunction]",Am="[object Function]",jm="[object GeneratorFunction]",_m="[object Proxy]";function Dm(i){if(!Nt(i))return!1;var e=Rt(i);return e==Am||e==jm||e==Pm||e==_m}var Bo=Dm;var Bm=tt["__core-js_shared__"],zs=Bm;var Kc=function(){var i=/[^.]+$/.exec(zs&&zs.keys&&zs.keys.IE_PROTO||"");return i?"Symbol(src)_1."+i:""}();function Gm(i){return!!Kc&&Kc in i}var Xc=Gm;var Em=Function.prototype,zm=Em.toString;function Fm(i){if(i!=null){try{return zm.call(i)}catch(e){}try{return i+""}catch(e){}}return""}var Ar=Fm;var Rm=/[\\^$.*+?()[\]{}|]/g,Vm=/^\[object .+?Constructor\]$/,km=Function.prototype,Um=Object.prototype,Jm=km.toString,Hm=Um.hasOwnProperty,qm=RegExp("^"+Jm.call(Hm).replace(Rm,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Wm(i){if(!Nt(i)||Xc(i))return!1;var e=Bo(i)?qm:Vm;return e.test(Ar(i))}var Zc=Wm;function $m(i,e){return i==null?void 0:i[e]}var Qc=$m;function Km(i,e){var t=Qc(i,e);return Zc(t)?t:void 0}var jt=Km;var Xm=jt(tt,"WeakMap"),Fs=Xm;var Yc=Object.create,Zm=function(){function i(){}return function(e){if(!Nt(e))return{};if(Yc)return Yc(e);i.prototype=e;var t=new i;return i.prototype=void 0,t}}(),ed=Zm;function Qm(i,e,t){switch(t.length){case 0:return i.call(e);case 1:return i.call(e,t[0]);case 2:return i.call(e,t[0],t[1]);case 3:return i.call(e,t[0],t[1],t[2])}return i.apply(e,t)}var td=Qm;function Ym(i,e){var t=-1,r=i.length;for(e||(e=Array(r));++t<r;)e[t]=i[t];return e}var Rs=Ym;var eg=800,tg=16,rg=Date.now;function og(i){var e=0,t=0;return function(){var r=rg(),o=tg-(r-t);if(t=r,o>0){if(++e>=eg)return arguments[0]}else e=0;return i.apply(void 0,arguments)}}var rd=og;function ig(i){return function(){return i}}var od=ig;var sg=function(){try{var i=jt(Object,"defineProperty");return i({},"",{}),i}catch(e){}}(),Go=sg;var ng=Go?function(i,e){return Go(i,"toString",{configurable:!0,enumerable:!1,value:od(e),writable:!0})}:Es,id=ng;var ag=rd(id),Vs=ag;function lg(i,e){for(var t=-1,r=i==null?0:i.length;++t<r&&e(i[t],t,i)!==!1;);return i}var sd=lg;var cg=9007199254740991,dg=/^(?:0|[1-9]\d*)$/;function hg(i,e){var t=typeof i;return e=e==null?cg:e,!!e&&(t=="number"||t!="symbol"&&dg.test(i))&&i>-1&&i%1==0&&i<e}var ks=hg;function pg(i,e,t){e=="__proto__"&&Go?Go(i,e,{configurable:!0,enumerable:!0,value:t,writable:!0}):i[e]=t}var Eo=pg;function ug(i,e){return i===e||i!==i&&e!==e}var Wr=ug;var fg=Object.prototype,mg=fg.hasOwnProperty;function gg(i,e,t){var r=i[e];(!(mg.call(i,e)&&Wr(r,t))||t===void 0&&!(e in i))&&Eo(i,e,t)}var Us=gg;function yg(i,e,t,r){var o=!t;t||(t={});for(var s=-1,n=e.length;++s<n;){var a=e[s],l=r?r(t[a],i[a],a,t,i):void 0;l===void 0&&(l=i[a]),o?Eo(t,a,l):Us(t,a,l)}return t}var Kt=yg;var nd=Math.max;function xg(i,e,t){return e=nd(e===void 0?i.length-1:e,0),function(){for(var r=arguments,o=-1,s=nd(r.length-e,0),n=Array(s);++o<s;)n[o]=r[e+o];o=-1;for(var a=Array(e+1);++o<e;)a[o]=r[o];return a[e]=t(n),td(i,this,a)}}var Js=xg;function bg(i,e){return Vs(Js(i,e,Es),i+"")}var ad=bg;var vg=9007199254740991;function Sg(i){return typeof i=="number"&&i>-1&&i%1==0&&i<=vg}var Hs=Sg;function Ng(i){return i!=null&&Hs(i.length)&&!Bo(i)}var $r=Ng;function wg(i,e,t){if(!Nt(t))return!1;var r=typeof e;return(r=="number"?$r(t)&&ks(e,t.length):r=="string"&&e in t)?Wr(t[e],i):!1}var ld=wg;function Cg(i){return ad(function(e,t){var r=-1,o=t.length,s=o>1?t[o-1]:void 0,n=o>2?t[2]:void 0;for(s=i.length>3&&typeof s=="function"?(o--,s):void 0,n&&ld(t[0],t[1],n)&&(s=o<3?void 0:s,o=1),e=Object(e);++r<o;){var a=t[r];a&&i(e,a,r,s)}return e})}var cd=Cg;var Lg=Object.prototype;function Og(i){var e=i&&i.constructor,t=typeof e=="function"&&e.prototype||Lg;return i===t}var zo=Og;function Tg(i,e){for(var t=-1,r=Array(i);++t<i;)r[t]=e(t);return r}var dd=Tg;var Mg="[object Arguments]";function Ig(i){return St(i)&&Rt(i)==Mg}var Va=Ig;var hd=Object.prototype,Pg=hd.hasOwnProperty,Ag=hd.propertyIsEnumerable,jg=Va(function(){return arguments}())?Va:function(i){return St(i)&&Pg.call(i,"callee")&&!Ag.call(i,"callee")},go=jg;function _g(){return!1}var pd=_g;var ud=typeof exports=="object"&&exports&&!exports.nodeType&&exports,fd=ud&&typeof module=="object"&&module&&!module.nodeType&&module,Dg=fd&&fd.exports===ud,md=Dg?tt.Buffer:void 0,Bg=md?md.isBuffer:void 0,Gg=Bg||pd,Fo=Gg;var Eg="[object Arguments]",zg="[object Array]",Fg="[object Boolean]",Rg="[object Date]",Vg="[object Error]",kg="[object Function]",Ug="[object Map]",Jg="[object Number]",Hg="[object Object]",qg="[object RegExp]",Wg="[object Set]",$g="[object String]",Kg="[object WeakMap]",Xg="[object ArrayBuffer]",Zg="[object DataView]",Qg="[object Float32Array]",Yg="[object Float64Array]",ey="[object Int8Array]",ty="[object Int16Array]",ry="[object Int32Array]",oy="[object Uint8Array]",iy="[object Uint8ClampedArray]",sy="[object Uint16Array]",ny="[object Uint32Array]",ke={};ke[Qg]=ke[Yg]=ke[ey]=ke[ty]=ke[ry]=ke[oy]=ke[iy]=ke[sy]=ke[ny]=!0;ke[Eg]=ke[zg]=ke[Xg]=ke[Fg]=ke[Zg]=ke[Rg]=ke[Vg]=ke[kg]=ke[Ug]=ke[Jg]=ke[Hg]=ke[qg]=ke[Wg]=ke[$g]=ke[Kg]=!1;function ay(i){return St(i)&&Hs(i.length)&&!!ke[Rt(i)]}var gd=ay;function ly(i){return function(e){return i(e)}}var Ro=ly;var yd=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Ii=yd&&typeof module=="object"&&module&&!module.nodeType&&module,cy=Ii&&Ii.exports===yd,ka=cy&&Bs.process,dy=function(){try{var i=Ii&&Ii.require&&Ii.require("util").types;return i||ka&&ka.binding&&ka.binding("util")}catch(e){}}(),jr=dy;var xd=jr&&jr.isTypedArray,hy=xd?Ro(xd):gd,qs=hy;var py=Object.prototype,uy=py.hasOwnProperty;function fy(i,e){var t=ft(i),r=!t&&go(i),o=!t&&!r&&Fo(i),s=!t&&!r&&!o&&qs(i),n=t||r||o||s,a=n?dd(i.length,String):[],l=a.length;for(var c in i)(e||uy.call(i,c))&&!(n&&(c=="length"||o&&(c=="offset"||c=="parent")||s&&(c=="buffer"||c=="byteLength"||c=="byteOffset")||ks(c,l)))&&a.push(c);return a}var Ws=fy;function my(i,e){return function(t){return i(e(t))}}var $s=my;var gy=$s(Object.keys,Object),bd=gy;var yy=Object.prototype,xy=yy.hasOwnProperty;function by(i){if(!zo(i))return bd(i);var e=[];for(var t in Object(i))xy.call(i,t)&&t!="constructor"&&e.push(t);return e}var vd=by;function vy(i){return $r(i)?Ws(i):vd(i)}var Vo=vy;function Sy(i){var e=[];if(i!=null)for(var t in Object(i))e.push(t);return e}var Sd=Sy;var Ny=Object.prototype,wy=Ny.hasOwnProperty;function Cy(i){if(!Nt(i))return Sd(i);var e=zo(i),t=[];for(var r in i)r=="constructor"&&(e||!wy.call(i,r))||t.push(r);return t}var Nd=Cy;function Ly(i){return $r(i)?Ws(i,!0):Nd(i)}var fr=Ly;var Oy=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Ty=/^\w*$/;function My(i,e){if(ft(i))return!1;var t=typeof i;return t=="number"||t=="symbol"||t=="boolean"||i==null||Do(i)?!0:Ty.test(i)||!Oy.test(i)||e!=null&&i in Object(e)}var wd=My;var Iy=jt(Object,"create"),_r=Iy;function Py(){this.__data__=_r?_r(null):{},this.size=0}var Cd=Py;function Ay(i){var e=this.has(i)&&delete this.__data__[i];return this.size-=e?1:0,e}var Ld=Ay;var jy="__lodash_hash_undefined__",_y=Object.prototype,Dy=_y.hasOwnProperty;function By(i){var e=this.__data__;if(_r){var t=e[i];return t===jy?void 0:t}return Dy.call(e,i)?e[i]:void 0}var Od=By;var Gy=Object.prototype,Ey=Gy.hasOwnProperty;function zy(i){var e=this.__data__;return _r?e[i]!==void 0:Ey.call(e,i)}var Td=zy;var Fy="__lodash_hash_undefined__";function Ry(i,e){var t=this.__data__;return this.size+=this.has(i)?0:1,t[i]=_r&&e===void 0?Fy:e,this}var Md=Ry;function ko(i){var e=-1,t=i==null?0:i.length;for(this.clear();++e<t;){var r=i[e];this.set(r[0],r[1])}}ko.prototype.clear=Cd;ko.prototype.delete=Ld;ko.prototype.get=Od;ko.prototype.has=Td;ko.prototype.set=Md;var Ua=ko;function Vy(){this.__data__=[],this.size=0}var Id=Vy;function ky(i,e){for(var t=i.length;t--;)if(Wr(i[t][0],e))return t;return-1}var Kr=ky;var Uy=Array.prototype,Jy=Uy.splice;function Hy(i){var e=this.__data__,t=Kr(e,i);if(t<0)return!1;var r=e.length-1;return t==r?e.pop():Jy.call(e,t,1),--this.size,!0}var Pd=Hy;function qy(i){var e=this.__data__,t=Kr(e,i);return t<0?void 0:e[t][1]}var Ad=qy;function Wy(i){return Kr(this.__data__,i)>-1}var jd=Wy;function $y(i,e){var t=this.__data__,r=Kr(t,i);return r<0?(++this.size,t.push([i,e])):t[r][1]=e,this}var _d=$y;function Uo(i){var e=-1,t=i==null?0:i.length;for(this.clear();++e<t;){var r=i[e];this.set(r[0],r[1])}}Uo.prototype.clear=Id;Uo.prototype.delete=Pd;Uo.prototype.get=Ad;Uo.prototype.has=jd;Uo.prototype.set=_d;var Xr=Uo;var Ky=jt(tt,"Map"),Zr=Ky;function Xy(){this.size=0,this.__data__={hash:new Ua,map:new(Zr||Xr),string:new Ua}}var Dd=Xy;function Zy(i){var e=typeof i;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?i!=="__proto__":i===null}var Bd=Zy;function Qy(i,e){var t=i.__data__;return Bd(e)?t[typeof e=="string"?"string":"hash"]:t.map}var Qr=Qy;function Yy(i){var e=Qr(this,i).delete(i);return this.size-=e?1:0,e}var Gd=Yy;function ex(i){return Qr(this,i).get(i)}var Ed=ex;function tx(i){return Qr(this,i).has(i)}var zd=tx;function rx(i,e){var t=Qr(this,i),r=t.size;return t.set(i,e),this.size+=t.size==r?0:1,this}var Fd=rx;function Jo(i){var e=-1,t=i==null?0:i.length;for(this.clear();++e<t;){var r=i[e];this.set(r[0],r[1])}}Jo.prototype.clear=Dd;Jo.prototype.delete=Gd;Jo.prototype.get=Ed;Jo.prototype.has=zd;Jo.prototype.set=Fd;var Pi=Jo;var ox="Expected a function";function Ja(i,e){if(typeof i!="function"||e!=null&&typeof e!="function")throw new TypeError(ox);var t=function(){var r=arguments,o=e?e.apply(this,r):r[0],s=t.cache;if(s.has(o))return s.get(o);var n=i.apply(this,r);return t.cache=s.set(o,n)||s,n};return t.cache=new(Ja.Cache||Pi),t}Ja.Cache=Pi;var Rd=Ja;var ix=500;function sx(i){var e=Rd(i,function(r){return t.size===ix&&t.clear(),r}),t=e.cache;return e}var Vd=sx;var nx=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,ax=/\\(\\)?/g,lx=Vd(function(i){var e=[];return i.charCodeAt(0)===46&&e.push(""),i.replace(nx,function(t,r,o,s){e.push(o?s.replace(ax,"$1"):r||t)}),e}),kd=lx;function cx(i){return i==null?"":$c(i)}var Ud=cx;function dx(i,e){return ft(i)?i:wd(i,e)?[i]:kd(Ud(i))}var Ho=dx;var hx=1/0;function px(i){if(typeof i=="string"||Do(i))return i;var e=i+"";return e=="0"&&1/i==-hx?"-0":e}var Ks=px;function ux(i,e){e=Ho(e,i);for(var t=0,r=e.length;i!=null&&t<r;)i=i[Ks(e[t++])];return t&&t==r?i:void 0}var Jd=ux;function fx(i,e){for(var t=-1,r=e.length,o=i.length;++t<r;)i[o+t]=e[t];return i}var qo=fx;var Hd=Ot?Ot.isConcatSpreadable:void 0;function mx(i){return ft(i)||go(i)||!!(Hd&&i&&i[Hd])}var qd=mx;function Wd(i,e,t,r,o){var s=-1,n=i.length;for(t||(t=qd),o||(o=[]);++s<n;){var a=i[s];e>0&&t(a)?e>1?Wd(a,e-1,t,r,o):qo(o,a):r||(o[o.length]=a)}return o}var $d=Wd;function gx(i){var e=i==null?0:i.length;return e?$d(i,1):[]}var Kd=gx;function yx(i){return Vs(Js(i,void 0,Kd),i+"")}var Xd=yx;var xx=$s(Object.getPrototypeOf,Object),Wo=xx;var bx="[object Object]",vx=Function.prototype,Sx=Object.prototype,Zd=vx.toString,Nx=Sx.hasOwnProperty,wx=Zd.call(Object);function Cx(i){if(!St(i)||Rt(i)!=bx)return!1;var e=Wo(i);if(e===null)return!0;var t=Nx.call(e,"constructor")&&e.constructor;return typeof t=="function"&&t instanceof t&&Zd.call(t)==wx}var Xs=Cx;function Lx(i,e,t){var r=-1,o=i.length;e<0&&(e=-e>o?0:o+e),t=t>o?o:t,t<0&&(t+=o),o=e>t?0:t-e>>>0,e>>>=0;for(var s=Array(o);++r<o;)s[r]=i[r+e];return s}var Qd=Lx;function Ox(){this.__data__=new Xr,this.size=0}var Yd=Ox;function Tx(i){var e=this.__data__,t=e.delete(i);return this.size=e.size,t}var eh=Tx;function Mx(i){return this.__data__.get(i)}var th=Mx;function Ix(i){return this.__data__.has(i)}var rh=Ix;var Px=200;function Ax(i,e){var t=this.__data__;if(t instanceof Xr){var r=t.__data__;if(!Zr||r.length<Px-1)return r.push([i,e]),this.size=++t.size,this;t=this.__data__=new Pi(r)}return t.set(i,e),this.size=t.size,this}var oh=Ax;function $o(i){var e=this.__data__=new Xr(i);this.size=e.size}$o.prototype.clear=Yd;$o.prototype.delete=eh;$o.prototype.get=th;$o.prototype.has=rh;$o.prototype.set=oh;var Zs=$o;function jx(i,e){return i&&Kt(e,Vo(e),i)}var ih=jx;function _x(i,e){return i&&Kt(e,fr(e),i)}var sh=_x;var nh=typeof exports=="object"&&exports&&!exports.nodeType&&exports,ah=nh&&typeof module=="object"&&module&&!module.nodeType&&module,Dx=ah&&ah.exports===nh,lh=Dx?tt.Buffer:void 0,ch=lh?lh.allocUnsafe:void 0;function Bx(i,e){if(e)return i.slice();var t=i.length,r=ch?ch(t):new i.constructor(t);return i.copy(r),r}var Qs=Bx;function Gx(i,e){for(var t=-1,r=i==null?0:i.length,o=0,s=[];++t<r;){var n=i[t];e(n,t,i)&&(s[o++]=n)}return s}var dh=Gx;function Ex(){return[]}var Ys=Ex;var zx=Object.prototype,Fx=zx.propertyIsEnumerable,hh=Object.getOwnPropertySymbols,Rx=hh?function(i){return i==null?[]:(i=Object(i),dh(hh(i),function(e){return Fx.call(i,e)}))}:Ys,Ko=Rx;function Vx(i,e){return Kt(i,Ko(i),e)}var ph=Vx;var kx=Object.getOwnPropertySymbols,Ux=kx?function(i){for(var e=[];i;)qo(e,Ko(i)),i=Wo(i);return e}:Ys,en=Ux;function Jx(i,e){return Kt(i,en(i),e)}var uh=Jx;function Hx(i,e,t){var r=e(i);return ft(i)?r:qo(r,t(i))}var tn=Hx;function qx(i){return tn(i,Vo,Ko)}var fh=qx;function Wx(i){return tn(i,fr,en)}var rn=Wx;var $x=jt(tt,"DataView"),on=$x;var Kx=jt(tt,"Promise"),sn=Kx;var Xx=jt(tt,"Set"),nn=Xx;var mh="[object Map]",Zx="[object Object]",gh="[object Promise]",yh="[object Set]",xh="[object WeakMap]",bh="[object DataView]",Qx=Ar(on),Yx=Ar(Zr),e0=Ar(sn),t0=Ar(nn),r0=Ar(Fs),yo=Rt;(on&&yo(new on(new ArrayBuffer(1)))!=bh||Zr&&yo(new Zr)!=mh||sn&&yo(sn.resolve())!=gh||nn&&yo(new nn)!=yh||Fs&&yo(new Fs)!=xh)&&(yo=function(i){var e=Rt(i),t=e==Zx?i.constructor:void 0,r=t?Ar(t):"";if(r)switch(r){case Qx:return bh;case Yx:return mh;case e0:return gh;case t0:return yh;case r0:return xh}return e});var Xo=yo;var o0=Object.prototype,i0=o0.hasOwnProperty;function s0(i){var e=i.length,t=new i.constructor(e);return e&&typeof i[0]=="string"&&i0.call(i,"index")&&(t.index=i.index,t.input=i.input),t}var vh=s0;var n0=tt.Uint8Array,Ha=n0;function a0(i){var e=new i.constructor(i.byteLength);return new Ha(e).set(new Ha(i)),e}var Zo=a0;function l0(i,e){var t=e?Zo(i.buffer):i.buffer;return new i.constructor(t,i.byteOffset,i.byteLength)}var Sh=l0;var c0=/\w*$/;function d0(i){var e=new i.constructor(i.source,c0.exec(i));return e.lastIndex=i.lastIndex,e}var Nh=d0;var wh=Ot?Ot.prototype:void 0,Ch=wh?wh.valueOf:void 0;function h0(i){return Ch?Object(Ch.call(i)):{}}var Lh=h0;function p0(i,e){var t=e?Zo(i.buffer):i.buffer;return new i.constructor(t,i.byteOffset,i.length)}var an=p0;var u0="[object Boolean]",f0="[object Date]",m0="[object Map]",g0="[object Number]",y0="[object RegExp]",x0="[object Set]",b0="[object String]",v0="[object Symbol]",S0="[object ArrayBuffer]",N0="[object DataView]",w0="[object Float32Array]",C0="[object Float64Array]",L0="[object Int8Array]",O0="[object Int16Array]",T0="[object Int32Array]",M0="[object Uint8Array]",I0="[object Uint8ClampedArray]",P0="[object Uint16Array]",A0="[object Uint32Array]";function j0(i,e,t){var r=i.constructor;switch(e){case S0:return Zo(i);case u0:case f0:return new r(+i);case N0:return Sh(i,t);case w0:case C0:case L0:case O0:case T0:case M0:case I0:case P0:case A0:return an(i,t);case m0:return new r;case g0:case b0:return new r(i);case y0:return Nh(i);case x0:return new r;case v0:return Lh(i)}}var Oh=j0;function _0(i){return typeof i.constructor=="function"&&!zo(i)?ed(Wo(i)):{}}var ln=_0;var D0="[object Map]";function B0(i){return St(i)&&Xo(i)==D0}var Th=B0;var Mh=jr&&jr.isMap,G0=Mh?Ro(Mh):Th,Ih=G0;var E0="[object Set]";function z0(i){return St(i)&&Xo(i)==E0}var Ph=z0;var Ah=jr&&jr.isSet,F0=Ah?Ro(Ah):Ph,jh=F0;var R0=1,V0=2,k0=4,_h="[object Arguments]",U0="[object Array]",J0="[object Boolean]",H0="[object Date]",q0="[object Error]",Dh="[object Function]",W0="[object GeneratorFunction]",$0="[object Map]",K0="[object Number]",Bh="[object Object]",X0="[object RegExp]",Z0="[object Set]",Q0="[object String]",Y0="[object Symbol]",eb="[object WeakMap]",tb="[object ArrayBuffer]",rb="[object DataView]",ob="[object Float32Array]",ib="[object Float64Array]",sb="[object Int8Array]",nb="[object Int16Array]",ab="[object Int32Array]",lb="[object Uint8Array]",cb="[object Uint8ClampedArray]",db="[object Uint16Array]",hb="[object Uint32Array]",Re={};Re[_h]=Re[U0]=Re[tb]=Re[rb]=Re[J0]=Re[H0]=Re[ob]=Re[ib]=Re[sb]=Re[nb]=Re[ab]=Re[$0]=Re[K0]=Re[Bh]=Re[X0]=Re[Z0]=Re[Q0]=Re[Y0]=Re[lb]=Re[cb]=Re[db]=Re[hb]=!0;Re[q0]=Re[Dh]=Re[eb]=!1;function cn(i,e,t,r,o,s){var n,a=e&R0,l=e&V0,c=e&k0;if(t&&(n=o?t(i,r,o,s):t(i)),n!==void 0)return n;if(!Nt(i))return i;var d=ft(i);if(d){if(n=vh(i),!a)return Rs(i,n)}else{var h=Xo(i),p=h==Dh||h==W0;if(Fo(i))return Qs(i,a);if(h==Bh||h==_h||p&&!o){if(n=l||p?{}:ln(i),!a)return l?uh(i,sh(n,i)):ph(i,ih(n,i))}else{if(!Re[h])return o?i:{};n=Oh(i,h,a)}}s||(s=new Zs);var m=s.get(i);if(m)return m;s.set(i,n),jh(i)?i.forEach(function(g){n.add(cn(g,e,t,g,i,s))}):Ih(i)&&i.forEach(function(g,N){n.set(N,cn(g,e,t,N,i,s))});var f=c?l?rn:fh:l?fr:Vo,x=d?void 0:f(i);return sd(x||i,function(g,N){x&&(N=g,g=i[N]),Us(n,N,cn(g,e,t,N,i,s))}),n}var dn=cn;var pb=1,ub=4;function fb(i){return dn(i,pb|ub)}var qa=fb;function mb(i){return function(e,t,r){for(var o=-1,s=Object(e),n=r(e),a=n.length;a--;){var l=n[i?a:++o];if(t(s[l],l,s)===!1)break}return e}}var Gh=mb;var gb=Gh(),Eh=gb;function yb(i,e,t){(t!==void 0&&!Wr(i[e],t)||t===void 0&&!(e in i))&&Eo(i,e,t)}var Ai=yb;function xb(i){return St(i)&&$r(i)}var zh=xb;function bb(i,e){if(!(e==="constructor"&&typeof i[e]=="function")&&e!="__proto__")return i[e]}var ji=bb;function vb(i){return Kt(i,fr(i))}var Fh=vb;function Sb(i,e,t,r,o,s,n){var a=ji(i,t),l=ji(e,t),c=n.get(l);if(c){Ai(i,t,c);return}var d=s?s(a,l,t+"",i,e,n):void 0,h=d===void 0;if(h){var p=ft(l),m=!p&&Fo(l),f=!p&&!m&&qs(l);d=l,p||m||f?ft(a)?d=a:zh(a)?d=Rs(a):m?(h=!1,d=Qs(l,!0)):f?(h=!1,d=an(l,!0)):d=[]:Xs(l)||go(l)?(d=a,go(a)?d=Fh(a):(!Nt(a)||Bo(a))&&(d=ln(l))):h=!1}h&&(n.set(l,d),o(d,l,r,s,n),n.delete(l)),Ai(i,t,d)}var Rh=Sb;function Vh(i,e,t,r,o){i!==e&&Eh(e,function(s,n){if(o||(o=new Zs),Nt(s))Rh(i,e,n,t,Vh,r,o);else{var a=r?r(ji(i,n),s,n+"",i,e,o):void 0;a===void 0&&(a=s),Ai(i,n,a)}},fr)}var kh=Vh;function Nb(i){var e=i==null?0:i.length;return e?i[e-1]:void 0}var Uh=Nb;function wb(i,e){return e.length<2?i:Jd(i,Qd(e,0,-1))}var Jh=wb;var Cb=cd(function(i,e,t){kh(i,e,t)}),xo=Cb;function Lb(i,e){return e=Ho(e,i),i=Jh(i,e),i==null||delete i[Ks(Uh(e))]}var Hh=Lb;function Ob(i){return Xs(i)?void 0:i}var qh=Ob;var Tb=1,Mb=2,Ib=4,Pb=Xd(function(i,e){var t={};if(i==null)return t;var r=!1;e=Gs(e,function(s){return s=Ho(s,i),r||(r=s.length>1),s}),Kt(i,rn(i),t),r&&(t=dn(t,Tb|Mb|Ib,qh));for(var o=e.length;o--;)Hh(t,e[o]);return t}),Qo=Pb;var Yo;(function(t){t.all=["PerspectiveCamera","OrthographicCamera"];function e(r){return t.all.includes(r)}t.is=e})(Yo||(Yo={}));var bo;(function(o){o.DefaultUp=[0,1,0],o.DefaultTargetOffset=1e3,o.defaultData={far:5e5,type:"OrthographicCamera",perspective:{near:5,fov:45,zoom:1},orthographic:{near:-5e5,zoom:1},up:o.DefaultUp,isUpVectorFlipped:!1,targetOffset:o.DefaultTargetOffset};function r(s){return s.type==="PerspectiveCamera"?s.perspective.zoom:s.orthographic.zoom}o.getZoom=r})(bo||(bo={}));var ei;(function(r){r.x="x",r.y="y",r.z="z"})(ei||(ei={}));var Wh;(function(s){s.Top="top",s.Right="right",s.Bottom="bottom",s.Left="left",s.Center="center"})(Wh||(Wh={}));var $h;(function(t){function i(r,o){return r[0]===o[0]&&r[1]===o[1]}t.isEqual=i;function e(r,o,s){return[r[0]+(o[0]-r[0])*s,r[1]+(o[1]-r[1])*s]}t.lerp=e})($h||($h={}));var ti;(function(o){function i(s,n){return s[0]===n[0]&&s[1]===n[1]&&s[2]===n[2]}o.isEqual=i;function e(s,n){return[s[0]+n[0],s[1]+n[1],s[2]+n[2]]}o.add=e;function t(s,n){return[s[0]-n[0],s[1]-n[1],s[2]-n[2]]}o.sub=t;function r(s,n,a){return[s[0]+(n[0]-s[0])*a,s[1]+(n[1]-s[1])*a,s[2]+(n[2]-s[2])*a]}o.lerp=r})(ti||(ti={}));var Kh;(function(t){function i(r,o){return r[0]===o[0]&&r[1]===o[1]&&r[2]===o[2]&&r[3]===o[3]}t.isEqual=i;function e(r,o,s){return[r[0]+(o[0]-r[0])*s,r[1]+(o[1]-r[1])*s,r[2]+(o[2]-r[2])*s,r[3]+(o[3]-r[3])*s]}t.lerp=e})(Kh||(Kh={}));var Yr;(function(s){s.identity=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];function e(n,a){for(let l=0;l<16;l++)if(n[l]!==a[l])return!1;return!0}s.isEqual=e;function t(n){return n!=null?n:s.identity}s.simplify=t;function r(n,a){let l=a.slice(0);for(var c=0,d=a.length;c<d;c+=3){let h=1/(n[3]*a[c]+n[7]*a[c+1]+n[11]*a[c+2]+n[15]);l[c]=(n[0]*a[c]+n[4]*a[c+1]+n[8]*a[c+2]+n[12])*h,l[c+1]=(n[1]*a[c]+n[5]*a[c+1]+n[9]*a[c+2]+n[13])*h,l[c+2]=(n[2]*a[c]+n[6]*a[c+1]+n[10]*a[c+2]+n[14])*h}return l}s.applyMatrix4=r;function o(n,a){let l=a.slice(0);for(var c=0,d=a.length;c<d;c+=3)l[c]=n[0]*a[c]+n[4]*a[c+1]+n[8]*a[c+2],l[c+1]=n[1]*a[c]+n[5]*a[c+1]+n[9]*a[c+2],l[c+2]=n[2]*a[c]+n[6]*a[c+1]+n[10]*a[c+2];return l}s.applyMatrix3Components=o})(Yr||(Yr={}));var Vt;(function(l){l.white={r:1,g:1,b:1},l.red={r:1,g:0,b:0},l.black={r:0,g:0,b:0};function r(c){return{r:Math.round(c.r*255),g:Math.round(c.g*255),b:Math.round(c.b*255),a:1}}l.toRgb255a1=r;function o(c){return{r:c.r,g:c.g,b:c.b}}l.clone=o;function s(c){return c=Math.floor(c),{r:(c>>16&255)/255,g:(c>>8&255)/255,b:(c&255)/255}}l.fromHex=s;function n(c,d){return c.r===d.r&&c.g===d.g&&c.b===d.b}l.equals=n;function a(c,d,h){return{r:c.r+(d.r-c.r)*h,g:c.g+(d.g-c.g)*h,b:c.b+(d.b-c.b)*h}}l.lerp=a})(Vt||(Vt={}));var mr;(function(s){s.white=q(P({},Vt.white),{a:1});function e(n){return{r:n[0],g:n[1],b:n[2],a:n[3]}}s.from0to1=e;function t(n,a){return q(P({},Vt.fromHex(n)),{a})}s.fromHexAndA=t;function r(n){return{r:Math.round(n.r*255),g:Math.round(n.g*255),b:Math.round(n.b*255),a:n.a}}s.toRgb255a1=r;function o(n,a){return Vt.equals(n,a)&&n.a===a.a}s.equals=o})(mr||(mr={}));var hn;(function(e){e.identity={position:[0,0,0],rotation:[0,0,0],scale:[1,1,1]}})(hn||(hn={}));var Xh;(function(S){S[S.SKIP=0]="SKIP",S[S.ADD=1]="ADD",S[S.ALPHA=2]="ALPHA",S[S.AVERAGE=3]="AVERAGE",S[S.COLOR_BURN=4]="COLOR_BURN",S[S.COLOR_DODGE=5]="COLOR_DODGE",S[S.DARKEN=6]="DARKEN",S[S.DIFFERENCE=7]="DIFFERENCE",S[S.EXCLUSION=8]="EXCLUSION",S[S.LIGHTEN=9]="LIGHTEN",S[S.MULTIPLY=10]="MULTIPLY",S[S.DIVIDE=11]="DIVIDE",S[S.NEGATION=12]="NEGATION",S[S.NORMAL=13]="NORMAL",S[S.OVERLAY=14]="OVERLAY",S[S.REFLECT=15]="REFLECT",S[S.SCREEN=16]="SCREEN",S[S.SOFT_LIGHT=17]="SOFT_LIGHT",S[S.SUBTRACT=18]="SUBTRACT"})(Xh||(Xh={}));var Zh;(function(a){a[a.LINEAR=0]="LINEAR",a[a.EASE=1]="EASE",a[a.EASE_IN=2]="EASE_IN",a[a.EASE_OUT=3]="EASE_OUT",a[a.EASE_IN_OUT=4]="EASE_IN_OUT",a[a.CUBIC=5]="CUBIC",a[a.SPRING=6]="SPRING"})(Zh||(Zh={}));var Qh;(function(e){e.defaultData={mass:1,stiffness:80,damping:10,velocity:0}})(Qh||(Qh={}));var Yh;(function(e){e.defaultData={control1:[.5,.05],control2:[.1,.3]}})(Yh||(Yh={}));var pn;(function(e){function i(t,r=.1){return{type:"radial",hideBase:!1,count:3,radial:{radius:Math.max(t[0],t[1])*2,start:0,end:360,alignment:!1,axis:ei.y,scale:[0,0,0],rotation:[0,0,0],position:[0,0,0]},linear:{scale:[0,0,0],rotation:[0,0,0],position:[t[0]+t[0]*r,0,0]},grid:{count:[2,2,2],size:t.map(o=>o*(1+r)),useCenter:!0}}}e.defaultData=i})(pn||(pn={}));var Dr;(function(e){e[e.Update=0]="Update"})(Dr||(Dr={}));var Xt;(function(r){r[r.Add=1]="Add",r[r.Delete=2]="Delete",r[r.Unlink=3]="Unlink"})(Xt||(Xt={}));var kt;(function(r){r[r.Add=4]="Add",r[r.Delete=5]="Delete",r[r.Move=6]="Move"})(kt||(kt={}));var _t;(function(r){r[r.Add=7]="Add",r[r.Delete=8]="Delete",r[r.Move=9]="Move"})(_t||(_t={}));var nr=class{modifyById(e,t){let r=this;if(r[e]===void 0)throw new Error("not expected");{let s=q(P({},r),{[e]:t});return Object.setPrototypeOf(s,nr.prototype),s}}add(e,t){var o;let r=this.runOp({type:Xt.Add,id:e,data:t});return(o=r==null?void 0:r.data)!=null?o:this}runOp(e){let t=this;if(e.type===Xt.Add){let r=t[e.id],o;r===void 0?o={type:Xt.Delete,id:e.id}:o={type:Xt.Add,id:e.id,data:r};let{id:s,data:n}=e,a=q(P({},t),{[s]:n});return Object.setPrototypeOf(a,nr.prototype),{data:a,actual:e,reverse:o}}else if(e.type===Xt.Delete){let{id:r}=e,o=t[r];if(o===void 0)return null;{let s=P({},t);return Object.setPrototypeOf(s,nr.prototype),delete s[r],{data:s,actual:e,reverse:{type:Xt.Add,id:r,data:o}}}}throw new Error("illegal arg")}};function _i(i){if(i.deepFreeze!==void 0){i.deepFreeze(i);return}let e=Object.getOwnPropertyNames(i);for(let t of e){let r=i[t];r&&typeof r=="object"&&_i(r)}return Object.freeze(i)}function ep(i,e){let t=0;for(;t<i.length&&t<e.length;){if(i[t]<e[t])return-1;if(i[t]>e[t])return 1;t+=1}return t!==e.length?-1:t!==i.length?1:0}var Wa=class extends Error{};function gr(i,e,t){if(i===void 0?e===void 0?(i=0,e=10):i=e-10:e===void 0&&(e=i+10),i>e){let s=i;i=e,e=s}let r=[],o=1/(t+1);for(let s=0;s<t;s++){let n=i+(e-i)*(s+.75+Math.random()*.5)*o;r.push(n)}return r}function tp(i){return i instanceof Uint8Array||i instanceof Uint16Array||i instanceof Uint32Array||i instanceof Int8Array||i instanceof Int16Array||i instanceof Int32Array||i instanceof Float32Array||i instanceof Float64Array}function rp(){return typeof process!="undefined"}function op(i,e){for(let t of i)e(t.id,t.data),op(t.children,e)}function ip(i,e){e(i.id,i.data);for(let t of i.children)ip(t,e)}var ar=class extends Array{constructor(...e){super(...e);Object.setPrototypeOf(this,ar.prototype)}deepFreeze(){let e=0;for(;e<this.length;)_i(this[e]),e++}fillCaches0(e,t){var r;if((r=this.objCaches)==null?void 0:r.has(e.id))throw new Error("duplicated item");this.objCaches.set(e.id,e),this.parentCaches.set(e.id,t);for(let o of e.children)this.fillCaches0(o,e.id)}fillCaches(){if(this.objCaches===void 0){this.objCaches=new Map,this.parentCaches=new Map;for(let e of this)this.fillCaches0(e,null)}}randomId(){this.fillCaches();let e=Array.from(this.objCaches.keys());if(e.length!==0)return e[Math.max(0,Math.floor(Math.random()*e.length)-1)]}isDescendantOf(e,t){for(;e;){let r=this.parent(e);if(r===t)return!0;e=r}return!1}data(e){var t;return(t=this.get(e))==null?void 0:t.data}has(e){return this.childrenOf(e)!==void 0}get(e){return this.fillCaches(),this.objCaches.get(e)}childrenOf(e){var t;return e===null?this:(t=this.get(e))==null?void 0:t.children}traverseFrom(e,t){if(e===null)this.traverse(t);else{let r=this.get(e);r&&ip(r,t)}}traverse(e){op(this,e)}totalSize(){return this.fillCaches(),this.objCaches.size}parent(e){return this.fillCaches(),this.parentCaches.get(e)}childrenArray(e){return e===null?this:this.get(e).children}modifyById(e,t){if(this.get(e)===void 0)throw new Error("not expected");{let o=this.parent(e),s=this.childrenArray(o),n=s.findIndex(c=>c.id===e);if(n<0)throw new Error("not expected");let a=s[n];return s=[...s],s[n]=q(P({},a),{data:t}),this.modifyArrayBy(o,s)}}modifyArrayBy(e,t){let r=e,o=t;for(;r!==null;){let n=o,a=r;if(r=this.parent(r),r===void 0)throw new Error;o=this.childrenArray(r);let l=o.findIndex(c=>c.id===a);if(l<0)throw new Error;o=[...o],o[l]=q(P({},o[l]),{children:n})}Object.setPrototypeOf(o,ar.prototype);let s=o;return s.fillCaches(),s}runOp(e){switch(e.type){case _t.Add:return this.addOp(e);case _t.Delete:return this.deleteOp(e);case _t.Move:return this.moveOp(e)}}addOp(e){let{parent:t,fi:r,id:o,data:s,children:n}=e;if(t!==null&&this.get(t)===void 0)return null;if(this.get(o)!==void 0)return null;{let a=t,l=this.childrenArray(a),c={fi:r,id:o,data:s,children:n};return l=[...l,c],l.sort((h,p)=>h.fi-p.fi),e.localIndex=l.indexOf(c),{data:this.modifyArrayBy(a,l),actual:e,reverse:{type:_t.Delete,id:o}}}}deleteOp(e){let{id:t}=e;if(this.get(t)===null)return null;{let r=this.parent(t);if(r===void 0)return null;let o=this.childrenArray(r),s=o.findIndex(l=>l.id===t);e.localIndex=s,o=[...o];let n=o.splice(s,1)[0];return{data:this.modifyArrayBy(r,o),actual:e,reverse:q(P({type:_t.Add},n),{parent:r})}}}moveOp(e){let{parent:t,fi:r,id:o}=e;if(t!==null&&this.get(t)===void 0)return this.deleteOp({type:_t.Delete,id:o});if(t!==null){let p=t;for(;p!==null;){if(p===void 0)throw new Error;if(p===o)throw new Wa("cyclic tree");p=this.parent(p)}}let s=this.parent(o);if(s===void 0)return null;let n=s,a=this.childrenArray(s),l=a.findIndex(p=>p.id===o);a=[...a];let c=a.splice(l,1)[0],d=this.modifyArrayBy(s,a);s=t,a=d.childrenArray(s);let h=c.fi;return c=q(P({},c),{fi:r}),a=[...a,c],a.sort((p,m)=>p.fi-m.fi),e.localIndex=a.indexOf(c),d=d.modifyArrayBy(s,a),{data:d,actual:e,reverse:{type:_t.Move,parent:n,fi:h,id:o}}}previous(e,t){if(t===null){let o=this.childrenArray(e);return o.length===0?null:o[o.length-1].id}let r=null;for(let o of this.childrenArray(e)){if(o.id===t)return r;r=o.id}return null}traverseSortNext(e){let t=this.parent(e);if(t!==void 0){let r=this.childrenArray(t),o=r.findIndex(s=>s.id===e)+1;if(o<r.length)return r[o].id;if(t)return this.traverseSortNext(t)}}sortNext(e){let t=this.childrenArray(e);return t.length>0?t[0].id:this.traverseSortNext(e)}traverseSortPrevious(e){let t=this.childrenArray(e);return t.length>0?this.traverseSortPrevious(t[t.length-1].id):e}sortPrevious(e){let t=this.parent(e);if(t!==void 0){let r=this.childrenArray(t),o=r.findIndex(s=>s.id===e)-1;return o>=0?this.traverseSortPrevious(r[o].id):t}}getAllSorted(e){let t=[];for(let r of e){let o=this.getWithSortKey(r.id);o!==void 0&&t.push(P(P({},r),o))}t.sort((r,o)=>ep(r.sortKey,o.sortKey));for(let r of t)delete r.sortKey;return t}getWithSortKey(e){var t=e;let r=[],o=this.get(t),s=o;if(o!==void 0){for(;t;)r.splice(0,0,o.fi),t=this.parent(t),t!==null&&(o=this.get(t));return q(P({},s),{sortKey:r})}}insertBeforeHelper(e,t,r){return this.insertAfterHelper(e,this.previous(e,t),r)}insertAfterHelper(e,t,r){let o=this.childrenArray(e);if(t===null){if(o.length===0)return gr(0,r,r);{let s=o[0].fi;return gr(s-r,s,r)}}else{let s=this.get(t);if(s===void 0||this.parent(t)!==e)throw new Error("illegal args");let n=o.find(a=>a.fi>s.fi);if(n===void 0){let a=o[o.length-1].fi;return gr(a,a+r,r)}else return gr(s.fi,n.fi,r)}}};var un;(function(e){function i(t,r){if(Array.isArray(t)){let o=r.props,s={},n=[...t],a=!1;if(o)for(let l of Object.keys(o)){let c=parseInt(l);if(isNaN(c))throw new Error("wrong index");s[l]=n[c],n[c]=o[l],a=!0}return a?{data:n,actual:r,reverse:{type:Dr.Update,props:s}}:null}else{let o=r.props,s={},n=P({},t),a=!1;if(o)for(let l of Object.keys(o))s[l]=n[l],n[l]=o[l],a=!0;return a?{data:n,actual:r,reverse:{type:Dr.Update,props:s}}:null}}e.runOp=i})(un||(un={}));var Xe=class extends Array{constructor(...e){super(...e);Object.setPrototypeOf(this,Xe.prototype)}deepFreeze(){let e=0;for(;e<this.length;)_i(this[e]),e++}fillCaches0(e){this.objCaches.set(e.id,e)}fillCaches(){if(this.objCaches===void 0){this.objCaches=new Map,Object.getOwnPropertyDescriptor(this,"objCaches").enumerable=!1;for(let e of this)this.fillCaches0(e)}}randomId(){this.fillCaches();let e=Array.from(this.objCaches.keys());if(e.length!==0)return e[Math.max(0,Math.floor(Math.random()*e.length)-1)]}data(e){var t;return(t=this.get(e))==null?void 0:t.data}get(e){return this.fillCaches(),this.objCaches.get(e)}modifyById(e,t){if(this.get(e)===void 0)throw new Error("not expected");{let o=this,s=o.findIndex(l=>l.id===e);if(s<0)throw new Error("not expected");let n=o[s];return o=[...o],o[s]=q(P({},n),{data:t}),this.modifyArrayBy(o)}}modifyArrayBy(e){Object.setPrototypeOf(e,Xe.prototype);let t=e;return rp()||t.fillCaches(),t}runOp(e){switch(e.type){case kt.Add:return this.addOp(e);case kt.Delete:return this.deleteOp(e);case kt.Move:return this.moveOp(e)}}addOp(e){let{fi:t,id:r,data:o}=e,s=this,n={fi:t,id:r,data:o};return s=[...s,n],s.sort((l,c)=>l.fi-c.fi),e.localIndex=s.indexOf(n),{data:this.modifyArrayBy(s),actual:e,reverse:{type:kt.Delete,id:r}}}deleteOp(e){let{id:t}=e,r=this,o=r.findIndex(a=>a.id===t);if(o===-1)return null;e.localIndex=o,r=[...r];let s=r.splice(o,1)[0];return{data:this.modifyArrayBy(r),actual:e,reverse:P({type:kt.Add},s)}}moveOp(e){let{fi:t,id:r}=e,o=this;o=[...o];let s=o.findIndex(c=>c.id===r);if(s===-1)return null;let n=o[s].fi,a=q(P({},o[s]),{fi:t});return o[s]=a,o.sort((c,d)=>c.fi-d.fi),e.localIndex=o.indexOf(a),{data:this.modifyArrayBy(o),actual:e,reverse:{type:kt.Move,fi:n,id:r}}}previous(e){if(e===null)return this.length===0?null:this[this.length-1].id;let t=null;for(let r of this){if(r.id===e)return t;t=r.id}return null}insertBeforeHelper(e,t){return this.insertAfterHelper(this.previous(e),t)}insertAfterHelper(e,t){let r=this;if(e===null){if(r.length===0)return gr(0,t,t);{let o=r[0].fi;return gr(o-t,o,t)}}else{let o=this.get(e);if(o===void 0)throw new Error("illegal args");let s=r.find(n=>n.fi>o.fi);if(s===void 0){let n=r[r.length-1].fi;return gr(n,n+t,t)}else return gr(o.fi,s.fi,t)}}};var sp=Symbol(),fn=Symbol(),Di=class{reportOp(e,t){let r=this;if(t===null)return;r._current=t.data;let o=[];for(;!(r instanceof Ka);){let s=r._path,n=r._current;if(s!==""&&o.splice(0,0,s),r=r._parent,r===null)return;r.update(s,n)}r.push(o,e,t.actual,t.reverse)}deleteChildren(e){if(this._children){let t=this._children[e];if(t){let r=t[fn];r&&r(),delete this._children[e]}}}},np=class extends Di{constructor(e,t,r){super();this._parent=e,this._path=t,this._current=r}update(e,t){if(Array.isArray(this._current)){if(typeof e=="string"&&(e=parseInt(e),isNaN(e)))throw new Error("Invalid path");this._current=[...this._current],this._current[e]=t}else this._current=q(P({},this._current),{[e]:t})}runOp(e){this.reportOp(e,un.runOp(this._current,e))}},ap=class extends Di{constructor(e,t,r){super();this._parent=e,this._path=t,this._current=r}update(e,t){this._current=q(P({},this._current),{[e]:t}),Object.setPrototypeOf(this._current,nr.prototype)}runOp(e){this.reportOp(e,this._current.runOp(e))}},lp={get(i,e){if(e===fn)return()=>{i._parent=null};if(e===sp)return i._current;let{_current:t,_children:r}=i;if(e==="push"&&Array.isArray(t))throw new Error("not supported to expand array");let o=r===void 0?void 0:r[e];if(o!==void 0)return o;let s=t[e],n=mn(i,e,s);return n!==s?(r===void 0&&(r={},i._children=r),r[e]=n,n):s},has(i,e){return e in i._current},ownKeys(i){return Reflect.ownKeys(i._current)},defineProperty(){throw Error("not supported")},getPrototypeOf(i){return Object.getPrototypeOf(i._current)},setPrototypeOf(){throw Error("not supported")},getOwnPropertyDescriptor(i,e){let t=i._current,r=Reflect.getOwnPropertyDescriptor(t,e);return r&&{writable:!0,configurable:!0,enumerable:r.enumerable,value:t[e]}}},Ab=q(P({},lp),{set(i,e,t){var o;let r;if(t===void 0)throw new Error("set to undefined is not supported!");return r={type:Dr.Update,props:{[e]:(o=Db(t))!=null?o:t}},i.deleteChildren(e),i.runOp(r),!0},deleteProperty(i,e){throw new Error("set to undefined is not supported!")}}),jb=q(P({},lp),{set(i,e,t){return t===void 0?this.deleteProperty(i,e):(i.deleteChildren(e),i.runOp({type:Xt.Add,id:e,data:t})),!0},deleteProperty(i,e){return i.runOp({type:Xt.Delete,id:e}),!0}}),Bi=class extends Di{constructor(e,t,r){super();this._children={},this._parent=e,this._path=t,this._current=r,this[fn]=()=>{this._parent=null}}unproxy(){return this._current}update(e,t){this._current=this._current.modifyById(e,t)}runOp(e){this.reportOp(e,this._current.runOp(e))}randomId(){return this._current.randomId()}isDescendantOf(e,t){return this._current.isDescendantOf(e,t)}childrenOf(e){return this._current.childrenOf(e)}traverse(e){return this._current.traverse(e)}get(e){return this._current.get(e)}parent(e){return this._current.parent(e)}data(e){var a;let{_current:t,_children:r}=this,o=r===void 0?void 0:r[e];if(o!==void 0)return o;let s=(a=t.get(e))==null?void 0:a.data,n=mn(this,e,s);return n!==s?(r===void 0&&(r={},this._children=r),r[e]=n,n):s}add(e,t,r,o,s){this.runOp({type:_t.Add,parent:e,fi:t,id:r,data:o,children:s})}move(e,t,r){this.runOp({type:_t.Move,parent:e,fi:t,id:r})}insertAfter(e,t,r){let o=this._current.insertAfterHelper(e,t,r.length);for(let s=0;s<r.length;s++){let n=r[s];this.add(e,o[s],n.id,n.data,n.children)}}insertBefore(e,t,r){let o=this._current.insertBeforeHelper(e,t,r.length);for(let s=0;s<r.length;s++){let n=r[s];this.add(e,o[s],n.id,n.data,n.children)}}moveAfter(e,t,r){let o=this._current.insertAfterHelper(e,t,r.length);for(let s=0;s<r.length;s++){let n=r[s];this.move(e,o[s],n)}}moveBefore(e,t,r){let o=this._current.insertBeforeHelper(e,t,r.length);for(let s=0;s<r.length;s++){let n=r[s];this.move(e,o[s],n)}}delete(e){this.deleteChildren(e),this.runOp({type:_t.Delete,id:e})}sortNext(e){return this._current.sortNext(e)}sortPrevious(e){return this._current.sortPrevious(e)}getAllSorted(e){return this._current.getAllSorted(e)}},Gi=class extends Di{constructor(e,t,r){super();this._children={},this._parent=e,this._path=t,this._current=r,this[fn]=()=>{this._parent=null}}unproxy(){return this._current}get length(){return this._current.length}forEach(e){let t=this.length;for(let r=0;r<t;r++){let o=this._current[r].id;e(this.data(this._current[r].id),o)}}update(e,t){this._current=this._current.modifyById(e,t)}randomId(){return this._current.randomId()}get(e){return q(P({},this._current.get(e)),{data:this.data(e)})}data(e){var a;let{_current:t,_children:r}=this,o=r===void 0?void 0:r[e];if(o!==void 0)return o;let s=(a=t.get(e))==null?void 0:a.data,n=mn(this,e,s);return n!==s?(r===void 0&&(r={},this._children=r),r[e]=n,n):s}runOp(e){this.reportOp(e,this._current.runOp(e))}add(e,t,r){this.runOp({type:kt.Add,fi:e,id:t,data:r})}move(e,t){this.runOp({type:kt.Move,fi:e,id:t})}insertAfter(e,t){let r=this._current.insertAfterHelper(e,t.length);for(let o=0;o<t.length;o++){let s=t[o];this.add(r[o],s.id,s.data)}}insertBefore(e,t){let r=this._current.insertBeforeHelper(e,t.length);for(let o=0;o<t.length;o++){let s=t[o];this.add(r[o],s.id,s.data)}}moveAfter(e,t){let r=this._current.insertAfterHelper(e,t.length);for(let o=0;o<t.length;o++){let s=t[o];this.move(r[o],s)}}moveBefore(e,t){let r=this._current.insertBeforeHelper(e,t.length);for(let o=0;o<t.length;o++){let s=t[o];this.move(r[o],s)}}delete(e){this.deleteChildren(e),this.runOp({type:kt.Delete,id:e})}};function $a(i,e,t){if(i.length>0){let r=i[i.length-1];if(r.type===Dr.Update&&e.type===Dr.Update&&gn.equal(r.path,t)){Object.assign(r.props,e.props);return}}i.push(q(P({},e),{path:t}))}var Ka=class{constructor(e){this.ts=[],this.actual=[],this.reverse=[],this._current=e}update(e,t){if(e!=="")throw new Error("");this._current=t}push(e,t,r,o){$a(this.ts,t,e),$a(this.actual,r,e),$a(this.reverse,o,e)}result(){return{data:this._current,ts:this.ts,actual:this.actual,reverse:this.reverse.reverse()}}};function mn(i,e,t){return t instanceof ar?new Bi(i,e,t):t instanceof Xe?new Gi(i,e,t):t instanceof nr?new Proxy(new ap(i,e,t),jb):t!==null&&typeof t=="object"?tp(t)?t:new Proxy(new np(i,e,t),Ab):t}function _b(i){let e=new Ka(i);return[mn(e,"",i),e]}function Xa(i,e){let[t,r]=_b(i);return e(t),r.result()}function Db(i){return i instanceof Bi||i instanceof Gi?i._current:i!==null&&typeof i=="object"?i[sp]:i}var gn;(function(r){function i(o,s){if(s.length===o.length)for(var n=0;n<o.length;){if(o[n]!==s[n])return!1;n+=1}else return!1;return!0}r.equal=i;function e(o,s,n){let a=t(n,o);if(a!==void 0&&typeof a=="object"&&a!==null){let l=P({},s);return Object.keys(a).forEach(c=>{delete l[c]}),l}else return s}r.removeOverridden=e;function t(o,s,n=0){if(s.length<=n)return o;if((o instanceof ar||o instanceof Bi)&&typeof s[n]=="string")return t(o.data(s[n]),s,n+1);if((o instanceof Xe||o instanceof Gi)&&typeof s[n]=="string")return t(o.data(s[n]),s,n+1);if(typeof s[n]=="number"&&Array.isArray(o))return t(o[s[n]],s,n+1);if(typeof s[n]=="string"&&typeof o=="object")return t(o[s[n]],s,n+1)}r.zoom=t})(gn||(gn={}));var Za=class{},yn=class extends Za{constructor(e){super();this.id=e}},xn=class extends Za{constructor(e){super();this.data=e}};"use strict";var Qa;try{Qa=new TextDecoder}catch(i){}var ee,eo,w=0;var cp=[],Ya=cp,el=0,Dt={},Ie,to,Zt=0,yr=0,Ut,Br,Tt=[],Ae,dp={useRecords:!1,mapsAsObjects:!0},bn=class{},tl=new bn;tl.name="MessagePack 0xC1";var ri=!1,Gr=class{constructor(e){e&&(e.useRecords===!1&&e.mapsAsObjects===void 0&&(e.mapsAsObjects=!0),e.structures?e.structures.sharedLength=e.structures.length:e.getStructures&&((e.structures=[]).uninitialized=!0,e.structures.sharedLength=0)),Object.assign(this,e)}unpack(e,t){if(ee)return Sp(()=>(Nn(),this?this.unpack(e,t):Gr.prototype.unpack.call(dp,e,t)));eo=t>-1?t:e.length,w=0,el=0,yr=0,to=null,Ya=cp,Ut=null,ee=e;try{Ae=e.dataView||(e.dataView=new DataView(e.buffer,e.byteOffset,e.byteLength))}catch(r){throw ee=null,e instanceof Uint8Array?r:new Error("Source must be a Uint8Array or Buffer but was a "+(e&&typeof e=="object"?e.constructor.name:typeof e))}if(this instanceof Gr){if(Dt=this,this.structures)return Ie=this.structures,vn();(!Ie||Ie.length>0)&&(Ie=[])}else Dt=dp,(!Ie||Ie.length>0)&&(Ie=[]);return vn()}unpackMultiple(e,t){let r,o=0;try{ri=!0;let s=e.length,n=this?this.unpack(e,s):Cn.unpack(e,s);if(t){for(t(n);w<s;)if(o=w,t(vn())===!1)return}else{for(r=[n];w<s;)o=w,r.push(vn());return r}}catch(s){throw s.lastPosition=o,s.values=r,s}finally{ri=!1,Nn()}}_mergeStructures(e,t){e=e||[];for(let r=0,o=e.length;r<o;r++){let s=e[r];s&&(s.isShared=!0,r>=32&&(s.highByte=r-32>>5))}e.sharedLength=e.length;for(let r in t||[])if(r>=0){let o=e[r],s=t[r];s&&(o&&((e.restoreStructures||(e.restoreStructures=[]))[r]=o),e[r]=s)}return this.structures=e}decode(e,t){return this.unpack(e,t)}};function vn(){try{if(!Dt.trusted&&!ri){let e=Ie.sharedLength||0;e<Ie.length&&(Ie.length=e)}let i=Ze();if(w==eo)Ie.restoreStructures&&hp(),Ie=null,ee=null,Br&&(Br=null);else if(w>eo){let e=new Error("Unexpected end of MessagePack data");throw e.incomplete=!0,e}else if(!ri)throw new Error("Data read, but end of buffer not reached");return i}catch(i){throw Ie.restoreStructures&&hp(),Nn(),(i instanceof RangeError||i.message.startsWith("Unexpected end of buffer"))&&(i.incomplete=!0),i}}function hp(){for(let i in Ie.restoreStructures)Ie[i]=Ie.restoreStructures[i];Ie.restoreStructures=null}function Ze(){let i=ee[w++];if(i<160)if(i<128){if(i<64)return i;{let e=Ie[i&63]||Dt.getStructures&&up()[i&63];return e?(e.read||(e.read=rl(e,i&63)),e.read()):i}}else if(i<144)if(i-=128,Dt.mapsAsObjects){let e={};for(let t=0;t<i;t++)e[xp()]=Ze();return e}else{let e=new Map;for(let t=0;t<i;t++)e.set(Ze(),Ze());return e}else{i-=144;let e=new Array(i);for(let t=0;t<i;t++)e[t]=Ze();return e}else if(i<192){let e=i-160;if(yr>=w)return to.slice(w-Zt,(w+=e)-Zt);if(yr==0&&eo<140){let t=e<16?il(e):gp(e);if(t!=null)return t}return ol(e)}else{let e;switch(i){case 192:return null;case 193:return Ut?(e=Ze(),e>0?Ut[1].slice(Ut.position1,Ut.position1+=e):Ut[0].slice(Ut.position0,Ut.position0-=e)):tl;case 194:return!1;case 195:return!0;case 196:return sl(ee[w++]);case 197:return e=Ae.getUint16(w),w+=2,sl(e);case 198:return e=Ae.getUint32(w),w+=4,sl(e);case 199:return vo(ee[w++]);case 200:return e=Ae.getUint16(w),w+=2,vo(e);case 201:return e=Ae.getUint32(w),w+=4,vo(e);case 202:if(e=Ae.getFloat32(w),Dt.useFloat32>2){let t=wn[(ee[w]&127)<<1|ee[w+1]>>7];return w+=4,(t*e+(e>0?.5:-.5)>>0)/t}return w+=4,e;case 203:return e=Ae.getFloat64(w),w+=8,e;case 204:return ee[w++];case 205:return e=Ae.getUint16(w),w+=2,e;case 206:return e=Ae.getUint32(w),w+=4,e;case 207:return Dt.int64AsNumber?(e=Ae.getUint32(w)*4294967296,e+=Ae.getUint32(w+4)):e=Ae.getBigUint64(w),w+=8,e;case 208:return Ae.getInt8(w++);case 209:return e=Ae.getInt16(w),w+=2,e;case 210:return e=Ae.getInt32(w),w+=4,e;case 211:return Dt.int64AsNumber?(e=Ae.getInt32(w)*4294967296,e+=Ae.getUint32(w+4)):e=Ae.getBigInt64(w),w+=8,e;case 212:if(e=ee[w++],e==114)return bp(ee[w++]&63);{let t=Tt[e];if(t)return t.read?(w++,t.read(Ze())):t.noBuffer?(w++,t()):t(ee.subarray(w,++w));throw new Error("Unknown extension "+e)}case 213:return e=ee[w],e==114?(w++,bp(ee[w++]&63,ee[w++])):vo(2);case 214:return vo(4);case 215:return vo(8);case 216:return vo(16);case 217:return e=ee[w++],yr>=w?to.slice(w-Zt,(w+=e)-Zt):Gb(e);case 218:return e=Ae.getUint16(w),w+=2,yr>=w?to.slice(w-Zt,(w+=e)-Zt):Eb(e);case 219:return e=Ae.getUint32(w),w+=4,yr>=w?to.slice(w-Zt,(w+=e)-Zt):zb(e);case 220:return e=Ae.getUint16(w),w+=2,fp(e);case 221:return e=Ae.getUint32(w),w+=4,fp(e);case 222:return e=Ae.getUint16(w),w+=2,mp(e);case 223:return e=Ae.getUint32(w),w+=4,mp(e);default:if(i>=224)return i-256;if(i===void 0){let t=new Error("Unexpected end of MessagePack data");throw t.incomplete=!0,t}throw new Error("Unknown MessagePack token "+i)}}}var Bb=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function rl(i,e){function t(){if(t.count++>2){let o=i.read=new Function("r","return function(){return {"+i.map(s=>Bb.test(s)?s+":r()":"["+JSON.stringify(s)+"]:r()").join(",")+"}}")(Ze);return i.highByte===0&&(i.read=pp(e,i.read)),o()}let r={};for(let o=0,s=i.length;o<s;o++){let n=i[o];r[n]=Ze()}return r}return t.count=0,i.highByte===0?pp(e,t):t}var pp=(i,e)=>function(){let t=ee[w++];if(t===0)return e();let r=i<32?-(i+(t<<5)):i+(t<<5),o=Ie[r]||up()[r];if(!o)throw new Error("Record id is not defined for "+r);return o.read||(o.read=rl(o,i)),o.read()};function up(){let i=Sp(()=>(ee=null,Dt.getStructures()));return Ie=Dt._mergeStructures(i,Ie)}var ol=Sn,Gb=Sn,Eb=Sn,zb=Sn;function Sn(i){let e;if(i<16&&(e=il(i)))return e;if(i>64&&Qa)return Qa.decode(ee.subarray(w,w+=i));let t=w+i,r=[];for(e="";w<t;){let o=ee[w++];if((o&128)==0)r.push(o);else if((o&224)==192){let s=ee[w++]&63;r.push((o&31)<<6|s)}else if((o&240)==224){let s=ee[w++]&63,n=ee[w++]&63;r.push((o&31)<<12|s<<6|n)}else if((o&248)==240){let s=ee[w++]&63,n=ee[w++]&63,a=ee[w++]&63,l=(o&7)<<18|s<<12|n<<6|a;l>65535&&(l-=65536,r.push(l>>>10&1023|55296),l=56320|l&1023),r.push(l)}else r.push(o);r.length>=4096&&(e+=dt.apply(String,r),r.length=0)}return r.length>0&&(e+=dt.apply(String,r)),e}function fp(i){let e=new Array(i);for(let t=0;t<i;t++)e[t]=Ze();return e}function mp(i){if(Dt.mapsAsObjects){let e={};for(let t=0;t<i;t++)e[xp()]=Ze();return e}else{let e=new Map;for(let t=0;t<i;t++)e.set(Ze(),Ze());return e}}var dt=String.fromCharCode;function gp(i){let e=w,t=new Array(i);for(let r=0;r<i;r++){let o=ee[w++];if((o&128)>0){w=e;return}t[r]=o}return dt.apply(String,t)}function il(i){if(i<4)if(i<2){if(i===0)return"";{let e=ee[w++];if((e&128)>1){w-=1;return}return dt(e)}}else{let e=ee[w++],t=ee[w++];if((e&128)>0||(t&128)>0){w-=2;return}if(i<3)return dt(e,t);let r=ee[w++];if((r&128)>0){w-=3;return}return dt(e,t,r)}else{let e=ee[w++],t=ee[w++],r=ee[w++],o=ee[w++];if((e&128)>0||(t&128)>0||(r&128)>0||(o&128)>0){w-=4;return}if(i<6){if(i===4)return dt(e,t,r,o);{let s=ee[w++];if((s&128)>0){w-=5;return}return dt(e,t,r,o,s)}}else if(i<8){let s=ee[w++],n=ee[w++];if((s&128)>0||(n&128)>0){w-=6;return}if(i<7)return dt(e,t,r,o,s,n);let a=ee[w++];if((a&128)>0){w-=7;return}return dt(e,t,r,o,s,n,a)}else{let s=ee[w++],n=ee[w++],a=ee[w++],l=ee[w++];if((s&128)>0||(n&128)>0||(a&128)>0||(l&128)>0){w-=8;return}if(i<10){if(i===8)return dt(e,t,r,o,s,n,a,l);{let c=ee[w++];if((c&128)>0){w-=9;return}return dt(e,t,r,o,s,n,a,l,c)}}else if(i<12){let c=ee[w++],d=ee[w++];if((c&128)>0||(d&128)>0){w-=10;return}if(i<11)return dt(e,t,r,o,s,n,a,l,c,d);let h=ee[w++];if((h&128)>0){w-=11;return}return dt(e,t,r,o,s,n,a,l,c,d,h)}else{let c=ee[w++],d=ee[w++],h=ee[w++],p=ee[w++];if((c&128)>0||(d&128)>0||(h&128)>0||(p&128)>0){w-=12;return}if(i<14){if(i===12)return dt(e,t,r,o,s,n,a,l,c,d,h,p);{let m=ee[w++];if((m&128)>0){w-=13;return}return dt(e,t,r,o,s,n,a,l,c,d,h,p,m)}}else{let m=ee[w++],f=ee[w++];if((m&128)>0||(f&128)>0){w-=14;return}if(i<15)return dt(e,t,r,o,s,n,a,l,c,d,h,p,m,f);let x=ee[w++];if((x&128)>0){w-=15;return}return dt(e,t,r,o,s,n,a,l,c,d,h,p,m,f,x)}}}}}function sl(i){return Dt.copyBuffers?Uint8Array.prototype.slice.call(ee,w,w+=i):ee.subarray(w,w+=i)}function vo(i){let e=ee[w++];if(Tt[e])return Tt[e](ee.subarray(w,w+=i));throw new Error("Unknown extension type "+e)}var yp=new Array(4096);function xp(){let i=ee[w++];if(i>=160&&i<192){if(i=i-160,yr>=w)return to.slice(w-Zt,(w+=i)-Zt);if(!(yr==0&&eo<180))return ol(i)}else return w--,Ze();let e=(i<<5^(i>1?Ae.getUint16(w):i>0?ee[w]:0))&4095,t=yp[e],r=w,o=w+i-3,s,n=0;if(t&&t.bytes==i){for(;r<o;){if(s=Ae.getUint32(r),s!=t[n++]){r=1879048192;break}r+=4}for(o+=3;r<o;)if(s=ee[r++],s!=t[n++]){r=1879048192;break}if(r===o)return w=r,t.string;o-=3,r=w}for(t=[],yp[e]=t,t.bytes=i;r<o;)s=Ae.getUint32(r),t.push(s),r+=4;for(o+=3;r<o;)s=ee[r++],t.push(s);let a=i<16?il(i):gp(i);return a!=null?t.string=a:t.string=ol(i)}var bp=(i,e)=>{var t=Ze();let r=i;e!==void 0&&(i=i<32?-((e<<5)+i):(e<<5)+i,t.highByte=e);let o=Ie[i];return o&&o.isShared&&((Ie.restoreStructures||(Ie.restoreStructures=[]))[i]=o),Ie[i]=t,t.read=rl(t,r),t.read()},vp=typeof self=="object"?self:global;Tt[0]=()=>{};Tt[0].noBuffer=!0;Tt[101]=()=>{let i=Ze();return(vp[i[0]]||Error)(i[1])};Tt[105]=i=>{let e=Ae.getUint32(w-4);Br||(Br=new Map);let t=ee[w],r;t>=144&&t<160||t==220||t==221?r=[]:r={};let o={target:r};Br.set(e,o);let s=Ze();return o.used?Object.assign(r,s):(o.target=s,s)};Tt[112]=i=>{let e=Ae.getUint32(w-4),t=Br.get(e);return t.used=!0,t.target};Tt[115]=()=>new Set(Ze());var nl=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(i=>i+"Array");Tt[116]=i=>{let e=i[0],t=nl[e];if(!t)throw new Error("Could not find typed array for code "+e);return new vp[t](Uint8Array.prototype.slice.call(i,1).buffer)};Tt[120]=()=>{let i=Ze();return new RegExp(i[0],i[1])};Tt[98]=i=>{let e=(i[0]<<24)+(i[1]<<16)+(i[2]<<8)+i[3],t=w;w+=e-4,Ut=[Ze(),Ze()],Ut.position0=0,Ut.position1=0;let r=w;w=t;try{return Ze()}finally{w=r}};Tt[255]=i=>i.length==4?new Date((i[0]*16777216+(i[1]<<16)+(i[2]<<8)+i[3])*1e3):i.length==8?new Date(((i[0]<<22)+(i[1]<<14)+(i[2]<<6)+(i[3]>>2))/1e6+((i[3]&3)*4294967296+i[4]*16777216+(i[5]<<16)+(i[6]<<8)+i[7])*1e3):i.length==12?new Date(((i[0]<<24)+(i[1]<<16)+(i[2]<<8)+i[3])/1e6+((i[4]&128?-281474976710656:0)+i[6]*1099511627776+i[7]*4294967296+i[8]*16777216+(i[9]<<16)+(i[10]<<8)+i[11])*1e3):new Date("invalid");function Sp(i){let e=eo,t=w,r=el,o=Zt,s=yr,n=to,a=Ya,l=Br,c=Ut,d=new Uint8Array(ee.slice(0,eo)),h=Ie,p=Ie.slice(0,Ie.length),m=Dt,f=ri,x=i();return eo=e,w=t,el=r,Zt=o,yr=s,to=n,Ya=a,Br=l,Ut=c,ee=d,ri=f,Ie=h,Ie.splice(0,Ie.length,...p),Dt=m,Ae=new DataView(ee.buffer,ee.byteOffset,ee.byteLength),x}function Nn(){ee=null,Br=null,Ie=null}function Np(i){i.unpack?Tt[i.type]=i.unpack:Tt[i.type]=i}var wn=new Array(147);for(let i=0;i<256;i++)wn[i]=+("1e"+Math.floor(45.15-i*.30103));var Cn=new Gr({useRecords:!1}),Fb=Cn.unpack,Rb=Cn.unpackMultiple,Vb=Cn.unpack;var kb=new Float32Array(1),zA=new Uint8Array(kb.buffer,0,4);"use strict";var Ln;try{Ln=new TextEncoder}catch(i){}var On,al,Tn=typeof Buffer!="undefined",ll=Tn?Buffer.allocUnsafeSlow:Uint8Array,Cp=Tn?Buffer:Uint8Array,Lp=Tn?4294967296:2144337920,G,Qe,M=0,xr,br=null,Ub=/[\u0080-\uFFFF]/,Ei=Symbol("record-id"),oi=class extends Gr{constructor(e){super(e);this.offset=0;let t,r,o,s,n,a,l=0,c=Cp.prototype.utf8Write?function(u,A,b){return G.utf8Write(u,A,b)}:Ln&&Ln.encodeInto?function(u,A){return Ln.encodeInto(u,G.subarray(A)).written}:!1,d=this;e||(e={});let h=e&&e.sequential,p=e.structures||e.saveStructures,m=e.maxSharedStructures;if(m==null&&(m=p?32:0),m>8160)throw new Error("Maximum maxSharedStructure is 8160");let f=e.maxOwnStructures;f==null&&(f=p?32:64),h&&!e.saveStructures&&(this.structures=[]);let x=m>32||f+m>64,g=m+64,N=m+f+64;if(N>8256)throw new Error("Maximum maxSharedStructure + maxOwnStructure is 8192");let C=[],S=0,D=0;this.pack=this.encode=function(u,A){if(G||(G=new ll(8192),Qe=new DataView(G.buffer,0,8192),M=0),xr=G.length-10,xr-M<2048?(G=new ll(G.length),Qe=new DataView(G.buffer,0,G.length),xr=G.length-10,M=0):M=M+7&2147483640,r=M,a=d.structuredClone?new Map:null,d.bundleStrings?(br=["",""],G[M++]=214,G[M++]=98,br.position=M-r,M+=4):br=null,o=d.structures,o){o.uninitialized&&(o=d._mergeStructures(d.getStructures()));let b=o.sharedLength||0;if(b>m)throw new Error("Shared structures is larger than maximum shared structures, try increasing maxSharedStructures to "+o.sharedLength);if(!o.transitions){o.transitions=Object.create(null);for(let L=0;L<b;L++){let I=o[L];if(!I)continue;let T,$=o.transitions;for(let J=0,te=I.length;J<te;J++){let fe=I[J];T=$[fe],T||(T=$[fe]=Object.create(null)),$=T}$[Ei]=L+64}l=b}h||(o.nextId=b+64)}s&&(s=!1),n=o||[];try{if(v(u),br){Qe.setUint32(br.position+r,M-br.position-r);let b=br;br=null,v(b[0]),v(b[1])}if(d.offset=M,a&&a.idsToInsert){M+=a.idsToInsert.length*6,M>xr&&O(M),d.offset=M;let b=Hb(G.subarray(r,M),a.idsToInsert);return a=null,b}return A&Ip?(G.start=r,G.end=M,G):G.subarray(r,M)}finally{if(o){if(D<10&&D++,S>1e4)o.transitions=null,D=0,S=0,C.length>0&&(C=[]);else if(C.length>0&&!h){for(let b=0,L=C.length;b<L;b++)C[b][Ei]=0;C=[]}if(s&&d.saveStructures){let b=o.sharedLength||m;o.length>b&&(o=o.slice(0,b));let L=G.subarray(r,M);return d.saveStructures(o,l)===!1?(d._mergeStructures(d.getStructures()),d.pack(u)):(l=b,L)}}A&$b&&(M=r)}};let v=u=>{M>xr&&(G=O(M));var A=typeof u,b;if(A==="string"){let L=u.length;if(br&&L>=8&&L<4096){let $=Ub.test(u);br[$?0:1]+=u,G[M++]=193,v($?-L:L);return}let I;L<32?I=1:L<256?I=2:L<65536?I=3:I=5;let T=L*3;if(M+T>xr&&(G=O(M+T)),L<64||!c){let $,J,te,fe=M+I;for($=0;$<L;$++)J=u.charCodeAt($),J<128?G[fe++]=J:J<2048?(G[fe++]=J>>6|192,G[fe++]=J&63|128):(J&64512)==55296&&((te=u.charCodeAt($+1))&64512)==56320?(J=65536+((J&1023)<<10)+(te&1023),$++,G[fe++]=J>>18|240,G[fe++]=J>>12&63|128,G[fe++]=J>>6&63|128,G[fe++]=J&63|128):(G[fe++]=J>>12|224,G[fe++]=J>>6&63|128,G[fe++]=J&63|128);b=fe-M-I}else b=c(u,M+I,T);b<32?G[M++]=160|b:b<256?(I<2&&G.copyWithin(M+2,M+1,M+1+b),G[M++]=217,G[M++]=b):b<65536?(I<3&&G.copyWithin(M+3,M+2,M+2+b),G[M++]=218,G[M++]=b>>8,G[M++]=b&255):(I<5&&G.copyWithin(M+5,M+3,M+3+b),G[M++]=219,Qe.setUint32(M,b),M+=4),M+=b}else if(A==="number")if(u>>>0===u)u<64?G[M++]=u:u<256?(G[M++]=204,G[M++]=u):u<65536?(G[M++]=205,G[M++]=u>>8,G[M++]=u&255):(G[M++]=206,Qe.setUint32(M,u),M+=4);else if(u>>0===u)u>=-32?G[M++]=256+u:u>=-128?(G[M++]=208,G[M++]=u+256):u>=-32768?(G[M++]=209,Qe.setInt16(M,u),M+=2):(G[M++]=210,Qe.setInt32(M,u),M+=4);else{let L;if((L=this.useFloat32)>0&&u<4294967296&&u>=-2147483648){G[M++]=202,Qe.setFloat32(M,u);let I;if(L<4||(I=u*wn[(G[M]&127)<<1|G[M+1]>>7])>>0===I){M+=4;return}else M--}G[M++]=203,Qe.setFloat64(M,u),M+=8}else if(A==="object")if(!u)G[M++]=192;else{if(a){let I=a.get(u);if(I){if(!I.id){let T=a.idsToInsert||(a.idsToInsert=[]);I.id=T.push(I)}G[M++]=214,G[M++]=112,Qe.setUint32(M,I.id),M+=4;return}else a.set(u,{offset:M-r})}let L=u.constructor;if(L===Object)j(u,!0);else if(L===Array){b=u.length,b<16?G[M++]=144|b:b<65536?(G[M++]=220,G[M++]=b>>8,G[M++]=b&255):(G[M++]=221,Qe.setUint32(M,b),M+=4);for(let I=0;I<b;I++)v(u[I])}else if(L===Map){b=u.size,b<16?G[M++]=128|b:b<65536?(G[M++]=222,G[M++]=b>>8,G[M++]=b&255):(G[M++]=223,Qe.setUint32(M,b),M+=4);for(let[I,T]of u)v(I),v(T)}else{for(let I=0,T=On.length;I<T;I++){let $=al[I];if(u instanceof $){let J=On[I];if(J.write){J.type&&(G[M++]=212,G[M++]=J.type,G[M++]=0),v(J.write.call(this,u));return}let te=G,fe=Qe,ce=M;G=null;let be;try{be=J.pack.call(this,u,R=>(G=te,te=null,M+=R,M>xr&&O(M),{target:G,targetView:Qe,position:M-R}),v)}finally{te&&(G=te,Qe=fe,M=ce,xr=G.length-10)}be&&(be.length+M>xr&&O(be.length+M),M=Jb(be,G,M,J.type));return}}j(u,!u.hasOwnProperty)}}else if(A==="boolean")G[M++]=u?195:194;else if(A==="bigint"){if(u<BigInt(1)<<BigInt(63)&&u>=-(BigInt(1)<<BigInt(63)))G[M++]=211,Qe.setBigInt64(M,u);else if(u<BigInt(1)<<BigInt(64)&&u>0)G[M++]=207,Qe.setBigUint64(M,u);else if(this.largeBigIntToFloat)G[M++]=203,Qe.setFloat64(M,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");M+=8}else if(A==="undefined")this.encodeUndefinedAsNil?G[M++]=192:(G[M++]=212,G[M++]=0,G[M++]=0);else if(A==="function")v(this.writeFunction&&this.writeFunction());else throw new Error("Unknown type: "+A)},j=this.useRecords===!1?this.variableMapSize?u=>{let A=Object.keys(u),b=A.length;b<16?G[M++]=128|b:b<65536?(G[M++]=222,G[M++]=b>>8,G[M++]=b&255):(G[M++]=223,Qe.setUint32(M,b),M+=4);let L;for(let I=0;I<b;I++)v(L=A[I]),v(u[L])}:(u,A)=>{G[M++]=222;let b=M-r;M+=2;let L=0;for(let I in u)(A||u.hasOwnProperty(I))&&(v(I),v(u[I]),L++);G[b+++r]=L>>8,G[b+r]=L&255}:u=>{let A=Object.keys(u),b,L=n.transitions||(n.transitions=Object.create(null)),I=0;for(let $=0,J=A.length;$<J;$++){let te=A[$];b=L[te],b||(b=L[te]=Object.create(null),I++),L=b}let T=L[Ei];if(T)T>=96&&x?(G[M++]=((T-=96)&31)+96,G[M++]=T>>5):G[M++]=T;else{T=n.nextId,T||(T=64),T<g&&this.shouldShareStructure&&!this.shouldShareStructure(A)?(T=n.nextOwnId,T<N||(T=g),n.nextOwnId=T+1):(T>=N&&(T=g),n.nextId=T+1);let $=A.highByte=T>=96&&x?T-96>>5:-1;L[Ei]=T,n[T-64]=A,T<g?(A.isShared=!0,n.sharedLength=T-63,s=!0,$>=0?(G[M++]=(T&31)+96,G[M++]=$):G[M++]=T):($>=0?(G[M++]=213,G[M++]=114,G[M++]=(T&31)+96,G[M++]=$):(G[M++]=212,G[M++]=114,G[M++]=T),I&&(S+=D*I),C.length>=f&&(C.shift()[Ei]=0),C.push(L),v(A))}for(let $=0,J=A.length;$<J;$++)v(u[A[$]])},O=u=>{let A;if(u>16777216){if(u-r>Lp)throw new Error("Packed buffer would be larger than maximum buffer size");A=Math.min(Lp,Math.round(Math.max((u-r)*(u>67108864?1.25:2),4194304)/4096)*4096)}else A=(Math.max(u-r<<2,G.length-1)>>12)+1<<12;let b=new ll(A);return Qe=new DataView(b.buffer,0,A),G.copy?G.copy(b,0,r,u):b.set(G.slice(r,u)),M-=r,r=0,xr=b.length-10,G=b}}useBuffer(e){G=e,Qe=new DataView(G.buffer,G.byteOffset,G.byteLength),M=0}};al=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,bn];On=[{pack(i,e,t){let r=i.getTime()/1e3;if((this.useTimestamp32||i.getMilliseconds()===0)&&r>=0&&r<4294967296){let{target:o,targetView:s,position:n}=e(6);o[n++]=214,o[n++]=255,s.setUint32(n,r)}else if(r>0&&r<17179869184){let{target:o,targetView:s,position:n}=e(10);o[n++]=215,o[n++]=255,s.setUint32(n,i.getMilliseconds()*4e6+(r/1e3/4294967296>>0)),s.setUint32(n+4,r)}else if(isNaN(r)){if(this.onInvalidDate)return e(0),t(this.onInvalidDate());let{target:o,targetView:s,position:n}=e(3);o[n++]=212,o[n++]=255,o[n++]=255}else{let{target:o,targetView:s,position:n}=e(15);o[n++]=199,o[n++]=12,o[n++]=255,s.setUint32(n,i.getMilliseconds()*1e6),s.setBigInt64(n+4,BigInt(Math.floor(r)))}}},{pack(i,e,t){let r=Array.from(i),{target:o,position:s}=e(this.structuredClone?3:0);this.structuredClone&&(o[s++]=212,o[s++]=115,o[s++]=0),t(r)}},{pack(i,e,t){let{target:r,position:o}=e(this.structuredClone?3:0);this.structuredClone&&(r[o++]=212,r[o++]=101,r[o++]=0),t([i.name,i.message])}},{pack(i,e,t){let{target:r,position:o}=e(this.structuredClone?3:0);this.structuredClone&&(r[o++]=212,r[o++]=120,r[o++]=0),t([i.source,i.flags])}},{pack(i,e){this.structuredClone?Op(i,16,e):Tp(Tn?Buffer.from(i):new Uint8Array(i),e)}},{pack(i,e){let t=i.constructor;t!==Cp&&this.structuredClone?Op(i,nl.indexOf(t.name),e):Tp(i,e)}},{pack(i,e){let{target:t,position:r}=e(1);t[r]=193}}];function Op(i,e,t,r){let o=i.byteLength;if(o+1<256){var{target:s,position:n}=t(4+o);s[n++]=199,s[n++]=o+1}else if(o+1<65536){var{target:s,position:n}=t(5+o);s[n++]=200,s[n++]=o+1>>8,s[n++]=o+1&255}else{var{target:s,position:n,targetView:a}=t(7+o);s[n++]=201,a.setUint32(n,o+1),n+=4}s[n++]=116,s[n++]=e,s.set(new Uint8Array(i.buffer,i.byteOffset,i.byteLength),n)}function Tp(i,e){let t=i.byteLength;var r,o;if(t<256){var{target:r,position:o}=e(t+2);r[o++]=196,r[o++]=t}else if(t<65536){var{target:r,position:o}=e(t+3);r[o++]=197,r[o++]=t>>8,r[o++]=t&255}else{var{target:r,position:o,targetView:s}=e(t+5);r[o++]=198,s.setUint32(o,t),o+=4}r.set(i,o)}function Jb(i,e,t,r){let o=i.length;switch(o){case 1:e[t++]=212;break;case 2:e[t++]=213;break;case 4:e[t++]=214;break;case 8:e[t++]=215;break;case 16:e[t++]=216;break;default:o<256?(e[t++]=199,e[t++]=o):o<65536?(e[t++]=200,e[t++]=o>>8,e[t++]=o&255):(e[t++]=201,e[t++]=o>>24,e[t++]=o>>16&255,e[t++]=o>>8&255,e[t++]=o&255)}return e[t++]=r,e.set(i,t),t+=o,t}function Hb(i,e){let t,r=e.length*6,o=i.length-r;for(e.sort((s,n)=>s.offset>n.offset?1:-1);t=e.pop();){let s=t.offset,n=t.id;i.copyWithin(s+r,s,o),r-=6;let a=s+r;i[a++]=214,i[a++]=105,i[a++]=n>>24,i[a++]=n>>16&255,i[a++]=n>>8&255,i[a++]=n&255,o=s}return i}function So(i){if(i.Class){if(!i.pack&&!i.write)throw new Error("Extension has no pack or write function");if(i.pack&&!i.type)throw new Error("Extension has no type (numeric code to identify the extension)");al.unshift(i.Class),On.unshift(i)}Np(i)}var Mp=new oi({useRecords:!1}),qb=Mp.pack,Wb=Mp.pack;var Ip=512,$b=1024;var Pp=new oi({structuredClone:!0});So({Class:nr.prototype.constructor,type:1,write(i){return P({},i)},read(i){return Object.setPrototypeOf(i,nr.prototype),i}});So({Class:Xe.prototype.constructor,type:2,write(i){return[...i]},read(i){return Object.setPrototypeOf(i,Xe.prototype),i}});So({Class:ar.prototype.constructor,type:3,write(i){return[...i]},read(i){return Object.setPrototypeOf(i,ar.prototype),i}});So({Class:yn.prototype.constructor,type:4,write(i){return i.id},read(i){return new yn(i)}});So({Class:xn.prototype.constructor,type:5,write(i){return i.data},read(i){return new xn(i)}});function Kb(i){var e=0;if(i.length===0)return e;for(let t=0;t<i.length;t++){let r=i[t];e=(e<<5)-e+r,e=e&e}return e}var Mn;(function(r){function i(o){return Pp.pack(o)}r.serialize=i;function e(o){return Pp.unpack(o)}r.deserialize=e;function t(o){return Kb(i(o)).toString()}r.checksum=t})(Mn||(Mn={}));var In;(function(t){t.all=["PointLight","SpotLight","DirectionalLight","HemisphereLight"];function e(r){return t.all.includes(r)}t.is=e})(In||(In={}));var Pn;(function(t){function i(r){return e(r)}t.defaultData=i;function e(r){if(r==="PointLight")return{type:r,color:mr.white,intensity:1,distance:2e3,decay:1,shadows:!0,shadowResolution:1024,shadowRadius:1,depth:2500,helper:!0};if(r==="SpotLight")return{type:r,color:mr.white,intensity:1,distance:2e3,decay:1,shadows:!0,penumbra:0,angle:30/180*Math.PI,depth:2500,helper:!0};if(r==="DirectionalLight")return{type:r,color:mr.white,intensity:1,shadows:!0,size:2500,depth:2500,helper:!0};throw new Error("not implemented")}})(Pn||(Pn={}));var ii;(function(r){r[r.Front=0]="Front",r[r.Back=1]="Back",r[r.Double=2]="Double"})(ii||(ii={}));var cl;(function(t){t.defaultData={castShadow:!0,receiveShadow:!0};function e(r,o){return r.castShadow===o.castShadow&&r.receiveShadow===o.receiveShadow}t.equals=e})(cl||(cl={}));var dl;(function(t){t.defaultData={flatShading:!1,wireframe:!1,side:0};function e(r,o){return r.flatShading===o.flatShading&&r.side===o.side&&r.wireframe===o.wireframe}t.equals=e})(dl||(dl={}));var An;(function(e){e.defaultData=q(P(P({},dl.defaultData),cl.defaultData),{cloner:null})})(An||(An={}));var Mt;(function(o){o[o.Left=1]="Left",o[o.Right=2]="Right",o[o.Center=3]="Center",o[o.Justify=4]="Justify"})(Mt||(Mt={}));var Er;(function(r){r[r.Top=1]="Top",r[r.Center=2]="Center",r[r.Bottom=3]="Bottom"})(Er||(Er={}));var ro;(function(r){r[r.None=1]="None",r[r.Upper=2]="Upper",r[r.Lower=3]="Lower"})(ro||(ro={}));var jn;(function(e){e.defaultData={width:100,height:100,horizontalAlign:1,verticalAlign:1,fontSize:16,lineHeight:1.5,letterSpacing:1,text:"",textTransform:1,color:mr.fromHexAndA(6974058,1),alpha:1,font:"roboto_regular"}})(jn||(jn={}));var st;(function(o){o[o.Normal=0]="Normal",o[o.Multiply=1]="Multiply",o[o.Screen=2]="Screen",o[o.Overlay=3]="Overlay"})(st||(st={}));var si;(function(r){r[r.Linear=0]="Linear",r[r.Radial=1]="Radial",r[r.Polar=2]="Polar"})(si||(si={}));var _n;(function(r){r[r.RepeatWrapping=1e3]="RepeatWrapping",r[r.ClampToEdgeWrapping=1001]="ClampToEdgeWrapping",r[r.MirroredRepeatWrapping=1002]="MirroredRepeatWrapping"})(_n||(_n={}));var Dn;(function(o){o[o.UV=0]="UV",o[o.Planar=1]="Planar",o[o.Spherical=2]="Spherical",o[o.Cylindrical=3]="Cylindrical"})(Dn||(Dn={}));var Bn;(function(s){s[s.Simplex=0]="Simplex",s[s.SimplexFractal=1]="SimplexFractal",s[s.Ashima=2]="Ashima",s[s.Fbm=3]="Fbm",s[s.Perlin=4]="Perlin"})(Bn||(Bn={}));var ni;(function(r){function i(o,s){return o==="light"&&s?e(s):t(o)}r.defaultData=i;function e(o){switch(o){case"basic":return{type:"light",category:"basic",alpha:1,visible:!0,mode:0};case"phong":return{category:"phong",specular:{r:.2,g:.2,b:.2},shininess:10,type:"light",alpha:1,visible:!0,mode:0};case"toon":return{category:"toon",specular:{r:.2,g:.2,b:.2},shininess:10,type:"light",alpha:1,visible:!0,mode:0};case"lambert":return{category:"lambert",emissive:{r:.2,g:.2,b:.2,a:1},type:"light",alpha:1,visible:!0,mode:0};case"physical":return{category:"physical",roughness:.2,metalness:.2,reflectivity:.2,type:"light",alpha:1,visible:!0,mode:0}}}function t(o){switch(o){case"texture":return{alpha:1,visible:!0,size:[128,128],mode:0,axis:ei.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:Vt.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:q(P({},Vt.fromHex(6710886)),{a:1}),colorB:q(P({},Vt.fromHex(6710886)),{a:1}),colorC:q(P({},Vt.fromHex(16777215)),{a:1}),colorD:q(P({},Vt.fromHex(16777215)),{a:1}),distortion:[1,1],fA:[1.7,9.2],fB:[8.3,2.8]};case"fresnel":return{type:"fresnel",alpha:1,visible:!0,mode:0,color:mr.fromHexAndA(16777215,1),bias:.1,scale:1,intensity:2,factor:1};case"rainbow":return{type:"rainbow",alpha:1,visible:!0,mode:0,filmThickness:30,movement:0,wavelengths:[0,0,0],noiseStrength:0,noiseScale:1,offset:[0,0,0]};case"matcap":return{type:"matcap",alpha:1,visible:!0,mode:0,texture:{image:"matcap_0",wrapping:1001,repeat:[1,1],offset:[0,0]}};case"transmission":return{type:"transmission",alpha:1,visible:!0,mode:0,thickness:10,ior:1.5,roughness:1};case"displace":return{type:"displace",displacementType:"noise",noiseType:0,scale:10,movement:1,offset:[0,0,0],intensity:8,visible:!0}}}})(ni||(ni={}));var ai;(function(a){function i(l){return!l.layers.some(d=>{if(d.data.type==="texture"&&d.data.projection!==0||d.data.type==="depth"&&!d.data.isWorldSpace||d.data.type==="noise"||d.data.type==="displace")return!0})&&!t(l)}a.isMergable=i;function e(l){let c="";return l.layers.forEach(d=>{Object.entries(d.data).forEach(([h,p])=>{c+=`${h}${p}`,Array.isArray(p)?p.forEach(m=>c+=`${m}`):typeof p=="object"?Object.values(p).forEach(m=>{typeof m=="number"?c+=`${m.toFixed(4)}`:c+=`${m}`}):c+=`${p}`})}),c}a.getHash=e;function t(l){let c=0;for(let d of l.layers)"alpha"in d.data&&d.data.type!=="light"&&d.data.type!=="fresnel"&&(c+=(1-c)*d.data.alpha);return c<1}a.isTransparent=t;function r(){return{layers:new Xe}}a.defaultEmptyData=r;function o(l="layer1",c="layer2"){return s("phong",l,c)}a.defaultData=o;function s(l,c="layer1",d="layer2"){let h=new Xe;return h.push({fi:0,data:ni.defaultData("light",l),id:c}),h.push({fi:1,data:ni.defaultData("color"),id:d}),{layers:h}}a.defaultTwoLayerData=s;function n(l,c="basic",d="layer1",h="layer2"){let p=ni.defaultData("texture");Object.assign(p.texture,{image:l});let m=new Xe;return m.push({fi:0,data:p,id:d}),m.push({fi:1,data:ni.defaultData("light",c),id:h}),{layers:m}}a.defaultTwoLayerTextureData=n})(ai||(ai={}));var li;(function(r){function i(){return{points:new Xe,roundness:0,shapeHoles:[],isClosed:!1}}r.defaultData=i;function e(o,s){let{points:n}=s;if(n){for(let a of n)if(a.data.position[0]===o[0]&&a.data.position[1]===o[1])return!0}return!1}r.isOverlappingExistingPoint=e;function t(o,s){let n=o.controlNext,a=s.controlPrevious;return o.position[0]===n.position[0]&&o.position[1]===n.position[1]&&s.position[0]===a.position[0]&&s.position[1]===a.position[1]}r.isStraightLine=t})(li||(li={}));var Gn;(function(e){function i(t){return t==="PolygonGeometry"||t==="RectangleGeometry"||t==="StarGeometry"||t==="TriangleGeometry"||t==="EllipseGeometry"}e.is2DParametricMesh=i})(Gn||(Gn={}));var En;(function(e){function i(t){if(t==="RectangleGeometry")return{width:320,height:320,type:t,cornerRadius:[0,0,0,0],cornerType:0,depth:0,extrudeBevelSize:0,extrudeBevelSegments:1,surfaceMaxCount:1};if(t==="VectorGeometry")return{width:100,height:100,type:t,subdivisions:12,shape:li.defaultData(),depth:0,extrudeBevelSize:0,extrudeBevelSegments:1,surfaceMaxCount:1};throw new Error("not implemented")}e.defaultData=i})(En||(En={}));var zi;(function(o){o.identity=q(P({},hn.identity),{hiddenMatrix:Yr.identity});function e(s){return{position:s.position,rotation:s.rotation,scale:s.scale,hiddenMatrix:s.hiddenMatrix}}o.fromObject=e;function t(s,n){return{position:(n==null?void 0:n.position)||s.position,rotation:(n==null?void 0:n.rotation)||s.rotation,scale:(n==null?void 0:n.scale)||s.scale,hiddenMatrix:(n==null?void 0:n.hiddenMatrix)||s.hiddenMatrix}}o.merge=t;function r(s,n){return{position:ti.isEqual(s.position,n.position)?null:n.position,rotation:ti.isEqual(s.rotation,n.rotation)?null:n.rotation,scale:ti.isEqual(s.scale,n.scale)?null:n.scale,hiddenMatrix:Yr.isEqual(s.hiddenMatrix,n.hiddenMatrix)?null:n.hiddenMatrix}}o.diff=r})(zi||(zi={}));var oo;(function(e){e.defaultData=P({states:new Xe,events:new Xe,visible:!0,raycastLock:!1},zi.identity)})(oo||(oo={}));var Ap;(function(e){e.defaultData=P({type:"Empty"},oo.defaultData)})(Ap||(Ap={}));var hl;(function(e){e.defaultData=P(P({type:"Mesh"},oo.defaultData),An.defaultData)})(hl||(hl={}));var jp;(function(e){e.defaultData=P(P({type:"TextFrame"},oo.defaultData),jn.defaultData)})(jp||(jp={}));var zn;(function(e){e.defaultData=P(P(P({},oo.defaultData),zi.identity),bo.defaultData)})(zn||(zn={}));var _p;(function(e){function i(t){return P(P({},oo.defaultData),Pn.defaultData(t))}e.defaultData=i})(_p||(_p={}));var Dp;(function(t){t.defaultCamera=P({position:[0,0,1e3],scale:[1,1,1],rotation:[0,0,0],hiddenMatrix:Yr.identity,name:"Play Camera",visible:!0,raycastLock:!1,states:new Xe,events:new Xe},bo.defaultData),t.defaultMeshObject=q(P(P({name:"Rectangle"},oo.defaultData),hl.defaultData),{geometry:En.defaultData("RectangleGeometry"),material:ai.defaultTwoLayerData("basic","layer1","layer2")})})(Dp||(Dp={}));var Bp;(function(t){function i(r,o){if(o===void 0)return r;let s=P({},r);return"material"in s&&"material"in o&&o.material&&(s.material=Xa(s.material,n=>{if(typeof n!="string")for(let[a,l]of Object.entries(o.material.layers)){let c=n.layers.data(a);c&&xo(c,l)}}).data),s.materials&&o.materials&&(s.materials=Xa(s.materials,n=>{var a,l;for(let c=0;c<s.materials.length;c++){let d=o.materials[c];if(typeof d!="string")for(let[h,p]of Object.entries(d.layers)){let m=(l=(a=n[c])==null?void 0:a.layers)==null?void 0:l.data(h);m&&xo(m,p)}}}).data),s}t.patchMaterialState=i;function e(r,o){var n,a;if(o===void 0)return r;let s=P({},r);if(Object.assign(s,zi.merge(s,o)),Yo.is(r.type)){s.orthographic=P({},s.orthographic),s.perspective=P({},s.perspective);let l=o;((n=l.orthographic)==null?void 0:n.zoom)!==void 0&&(s.orthographic.zoom=l.orthographic.zoom),((a=l.perspective)==null?void 0:a.zoom)!==void 0&&(s.perspective.zoom=l.perspective.zoom)}else if(r.type==="Mesh")s.geometry=P({},s.geometry),Object.assign(s.geometry,o.geometry),s=i(s,o);else if(In.is(r.type)){let l=o;s.intensity!==void 0&&(s.intensity=l.intensity),l.color!==void 0&&(s.color=Vt.clone(l.color))}return s}t.patch=e})(Bp||(Bp={}));var nt=5855577;var Gp=2857471;var pl=15711266;import{DoubleSide as Xb,Mesh as Zb,MeshBasicMaterial as Qb,ShapeBufferGeometry as Yb,Vector2 as ev,Vector3 as tv}from"three";import{FontLoader as rv}from"three/examples/jsm/loaders/FontLoader.js";var Ye=class extends Zb{constructor({char:e,originalChar:t,fontFamily:r,letterSpacing:o,fontSize:s,LOD:n=16},a=new Qb({color:0,opacity:1,visible:!0,transparent:!0,side:Xb})){let l=Ye.loadChar(e,r,n);super(l.geometry,a);this.char=e,this.originalChar=t!=null?t:e,this.fontFamily=r,this.letterSpacing=o,this.fontSize=s,this.LOD=n,this.resolution=l.resolution,this.glyphsHa=l.glyphsHa,this.localPosition=new ev,this.charSize=0,this.geometry.userData={type:"CharacterGeometry",parameters:{char:this.char,fontFamily:this.fontFamily,letterSpacing:this.letterSpacing,fontSize:this.fontSize,lod:this.LOD,resolution:this.resolution,charSize:this.charSize,localPosition:this.localPosition}},this.updateFontSize(this.fontSize)}static get FONTS_PATH(){return Ye._fontPath}static set FONTS_PATH(e){Ye._fontPath=e}updatePosition(e,t){this.localPosition.copy(e);let r=new tv(this.localPosition.x,-this.localPosition.y,0);this.position.copy(r).add(t)}updateFontSize(e){let t=e/this.resolution;this.fontSize=e,this.scale.set(this.fontSize,this.fontSize,1),this.charSize=this.glyphsHa*t*this.letterSpacing}updateFontFamily(e){if(this.fontFamily===e)return;this.fontFamily=e;let t=Ye.loadChar(this.char,e,this.LOD);this.geometry=t.geometry,this.resolution=t.resolution,this.glyphsHa=t.glyphsHa,this.geometry.userData={type:"CharacterGeometry",parameters:{char:this.char,fontFamily:this.fontFamily,letterSpacing:this.letterSpacing,fontSize:this.fontSize,lod:this.LOD,resolution:this.resolution,charSize:this.charSize,localPosition:this.localPosition}},this.updateFontSize(this.fontSize)}updateChar(e){if(this.char===e)return;this.char=e;let t=Ye.loadChar(e,this.fontFamily,this.LOD);this.geometry=t.geometry,this.resolution=t.resolution,this.glyphsHa=t.glyphsHa,this.geometry.userData={type:"CharacterGeometry",parameters:{char:this.char,fontFamily:this.fontFamily,letterSpacing:this.letterSpacing,fontSize:this.fontSize,lod:this.LOD,resolution:this.resolution,charSize:this.charSize,localPosition:this.localPosition}},this.updateFontSize(this.fontSize)}updateLetterSpacing(e){this.letterSpacing!==e&&(this.letterSpacing=e,this.updateFontSize(this.fontSize))}updateLOD(e){if(this.LOD===e)return;this.LOD=e;let t=Ye.loadChar(this.char,this.fontFamily,this.LOD);this.geometry=t.geometry,this.resolution=t.resolution,this.glyphsHa=t.glyphsHa,this.geometry.userData={type:"CharacterGeometry",parameters:{char:this.char,fontFamily:this.fontFamily,letterSpacing:this.letterSpacing,fontSize:this.fontSize,lod:this.LOD,resolution:this.resolution,charSize:this.charSize,localPosition:this.localPosition}},this.updateFontSize(this.fontSize)}clone(){let e={char:this.char,originalChar:this.originalChar,fontFamily:this.fontFamily,letterSpacing:this.letterSpacing,fontSize:this.fontSize,LOD:this.LOD};return new Ye(e).copy(this)}static loadFont(e){return new Promise(function(t,r){Ye.fontCache[e]?t(Ye.fontCache[e]):new rv().load(Ye.FONTS_PATH+e+".json",s=>{Ye.fontCache[e]=s,t(s)},void 0,r)})}static loadChar(e,t,r){if(Ye.charCache[e]){if(Ye.charCache[e][r]&&Ye.charCache[e][r].fontFamily===t)return Ye.charCache[e][r]}else Ye.charCache[e]={};let o=Ye.fontCache[t],s=o.generateShapes(e,1);return Ye.charCache[e][r]={geometry:new Yb(s,r),fontFamily:t,resolution:o.data.resolution,glyphsHa:o.data.glyphs[e].ha},Ye.charCache[e][r]}},Bt=Ye;Bt.charCache={},Bt.fontCache={},Bt._fontPath="/_assets/_fonts/";import{DoubleSide as Ga,MeshBasicMaterial as Af,Vector3 as jf,Object3D as sw}from"three";import{Mesh as GS}from"three";import{BufferGeometry as s_,ConeBufferGeometry as sv,Float32BufferAttribute as n_,Vector2 as a_,Vector3 as l_}from"three";import{BufferGeometry as ov,CylinderBufferGeometry as iv,Float32BufferAttribute as ul,Vector2 as lr,Vector3 as Fn}from"three";var Ep=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,e){var n,a,l,c,d;let t=Object.assign({},(n=e==null?void 0:e.parameters)!=null?n:{width:100,radialSegments:64,heightSegments:1,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadius:0,cornerSegments:8,hollow:0},i.parameters),r=t.width/2,o=(a=t.radiusTop)!=null?a:r,s=(l=t.radiusBottom)!=null?l:r;return o===s?(o=r,s=r):o>s?(o=r,s=s*r/o):(o=o*r/s,s=r),{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs((c=t.height)!=null?c:t.width),depth:Math.abs((d=t.depth)!=null?d:t.width),radiusTop:o,radiusBottom:s})}}static build(i){let{width:e,depth:t,height:r,radialSegments:o,heightSegments:s,openEnded:n,thetaStart:a,thetaLength:l,radiusTop:c,radiusBottom:d,cornerRadius:h,cornerSegments:p,hollow:m}=i.parameters,f;return h||m?f=new Rn(c,d,r,o,s,n,a,l*Math.PI/180,h,h,p,m):f=new iv(c,d,r,o,s,n,a,l*Math.PI/180),f.scale(1,1,t/e),Object.assign(f,{userData:q(P({},i),{type:"CylinderGeometry"})})}};function io(i,e,t){t.x=i.x*e.x,t.y=i.y,t.z=i.x*e.y}function zp(i){return new lr(i.y,-i.x)}var Rn=class extends ov{constructor(e,t,r,o,s,n,a,l,c,d,h,p,m=!1){super();this.type="RoundedCylinderBufferGeometry",e=e!==void 0?e:1,t=t!==void 0?t:1,r=r||1,o=Math.floor(o)||8,s=Math.floor(s)||1,n=n!==void 0?n:!1,a=a!==void 0?a:0,l=l!==void 0?l:Math.PI*2,n&&(c=0,d=0);let f=[],x=[],g=[],N=[],C=0,S=r/2,D=new Fn,v=new Fn;m&&e==0&&(e=c),m&&t==0&&(t=d);let j=new lr(e,S),O=new lr(t,-S),u=null,A=null,b=null,L=null,I=j.clone().sub(O),T=0,$=0,J=0;p>0&&(T=Math.min(e,t)*(1-p),$=e-T,J=t-T);let te=j.clone();te.x-=T;let fe=Math.PI-I.angle(),ce=I.angle(),be=Math.tan(ce/2),R=Math.tan(fe/2),E=be+R,y=p?E:R,z=p?E:be;if(c=Math.min(c,(e-$)/y,I.length()/E),d=Math.min(d,(t-J)/z,I.length()/E),c>0){let V=c/be;u=j.clone().sub(new lr(V,c)),p&&(b=u.clone(),b.x-=T-E*c),j.sub(I.clone().setLength(V))}if(d>0){let V=d/R;A=O.clone().sub(new lr(V,-d)),O.add(I.clone().setLength(V)),p&&(L=A.clone(),L.x-=T-E*d,te.sub(I.clone().setLength(V)))}I=j.clone().sub(O);let _=I.length()<.5,F=[];for(let V=0;V<=o;V++){let B=[],U=V/o,se=U*l+a,H=new lr(Math.sin(se),Math.cos(se));L&&A?(K(B,U,H,fe,d,L,-1,!0),K(B,U,H,ce,d,A,-1,!1)):A?(Q(B,H,A.x,0,-1),K(B,U,H,ce,d,A,-1,!1)):n||Q(B,H,t,J,-1);let W=zp(I).normalize();if(io(W,H,D),!_)for(let X=0;X<=s;X++){let Z=X/s,Y=I.clone().multiplyScalar(Z).add(O);io(Y,H,v),x.push(v.x,v.y,v.z),g.push(D.x,D.y,D.z),N.push(U,.5+v.y/r),B.push(C++)}if(b&&u?(K(B,U,H,fe,c,u,1,!1),K(B,U,H,ce,c,b,1,!0)):u?(K(B,U,H,fe,c,u,1,!1),Q(B,H,u.x,0,1)):n||Q(B,H,e,$,1),p&&!_){let X=zp(I).multiplyScalar(-1).normalize();io(X,H,D);for(let Z=0;Z<=s;Z++){let Y=Z/s,ne=I.clone().multiplyScalar(-Y).add(te);io(ne,H,v),x.push(v.x,v.y,v.z),g.push(D.x,D.y,D.z),N.push(U,.5+v.y/r),B.push(C++)}}p&&!n&&B.push(B[0]),F.push(B)}for(let V=0;V<F.length-1;V++)for(let B=0;B<F[0].length-1;B++){if(n&&p&&B==s)continue;let U=F[V][B],se=F[V+1][B],H=F[V+1][B+1],W=F[V][B+1],X=x[H*3+0],Z=x[H*3+2];f.push(U,se,W),(X!=0||Z!=0)&&f.push(se,H,W)}l<Math.PI*2&&(k(-1,F[0],a),k(1,F[F.length-1],a+l)),this.setIndex(f),this.setAttribute("position",new ul(x,3)),this.setAttribute("normal",new ul(g,3)),this.setAttribute("uv",new ul(N,2));function K(V,B,U,se,H,W,X,Z){for(let Y=0;Y<h+1;Y++){let ne=Y/h,ie=X<0?ne:1-ne;Z&&(ie-=1),ie*=se;let de=new lr(Math.sin(ie),Math.cos(ie)*X),Ge=de.clone().multiplyScalar(H).add(W);io(Ge,U,v),x.push(v.x,v.y,v.z),io(de,U,D),g.push(D.x,D.y,D.z),N.push(B,.5+v.y/r),V.push(C++)}}function Q(V,B,U,se,H){let W=new Fn,X=new lr,Z=[U,se];H<0&&Z.reverse();for(let Y of Z)X.set(Y,S*H),io(X,B,W),x.push(W.x,W.y,W.z),g.push(0,H,0),N.push(.5,.5),V.push(C++)}function k(V,B,U){let se=new lr(Math.sin(U),Math.cos(U)),H=new lr(-Math.cos(U),Math.sin(U)),W=new Fn,X=V<0?(ne,ie,de)=>f.push(ne,ie,de):(ne,ie,de)=>f.push(ne,de,ie),Z=new lr((e+t+$+J)/4,0);io(Z,se,W),x.push(W.x,W.y,W.z),g.push(H.x,0,H.y),N.push(.5,.5);let Y=C++;for(let ne of B){let ie=x.slice(ne*3,ne*3+3);x.push(...ie),g.push(H.x,0,H.y);let de=N.slice(ne*2,ne*2+2);N.push(...de),C++}for(let ne=Y+1;ne<C-1;ne++)X(Y,ne,ne+1);X(Y,C-1,Y+1)}}};var Fp=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,e){var r,o,s;let t=Object.assign({},(r=e==null?void 0:e.parameters)!=null?r:{width:100,radialSegments:32,heightSegments:8,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadiusTop:0,cornerRadiusBottom:0,cornerSegments:8},i.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs((o=t.height)!=null?o:t.width),depth:Math.abs((s=t.depth)!=null?s:t.width)})}}static build(i){let{width:e,depth:t,height:r,radialSegments:o,heightSegments:s,openEnded:n,thetaStart:a,thetaLength:l,cornerRadiusTop:c,cornerRadiusBottom:d,cornerSegments:h}=i.parameters,p;return c>0||d>0||l<360?p=new Rn(0,e/2,r,o,s,n,a,l*Math.PI/180,c,d,h,0,!0):p=new sv(e/2,r,o,s,n),p.scale(1,1,t/e),Object.assign(p,{userData:q(P({},i),{type:"ConeGeometry"})})}};import{BoxBufferGeometry as nv,BufferGeometry as av,Float32BufferAttribute as fl,Vector3 as Fi}from"three";var Rp=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,e){var r,o,s;let t=Object.assign({},(r=e==null?void 0:e.parameters)!=null?r:{width:100,widthSegments:1,heightSegments:1,depthSegments:1,cornerRadius:0,cornerSegments:8},i.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs((o=t.height)!=null?o:t.width),depth:Math.abs((s=t.depth)!=null?s:t.width)})}}static build(i){let{width:e,height:t,depth:r,widthSegments:o,heightSegments:s,depthSegments:n,cornerRadius:a,cornerSegments:l}=i.parameters,c;return a==0?c=new nv(e,t,r,o,s,n):c=new Vp(e,t,r,o,s,n,a,l),Object.assign(c,{userData:q(P({},i),{type:"CubeGeometry"})})}},ml=Math.PI/2,Vp=class extends av{constructor(e=1,t=1,r=1,o=1,s=1,n=1,a=0,l=4){super();this.type="BoxBufferGeometry";let c=this;o=Math.floor(o),s=Math.floor(s),n=Math.floor(n),l=Math.floor(l),a=Math.min(a,e/2,t/2,r/2);let d=[],h=[],p=[],m=[],f=0,x=0;g("z","y","x",-1,-1,r,t,e,n,s,0),g("z","y","x",1,-1,r,t,-e,n,s,1),g("x","z","y",1,1,e,r,t,o,n,2),g("x","z","y",1,-1,e,r,-t,o,n,3),g("x","y","z",1,-1,e,t,r,o,s,4),g("x","y","z",-1,-1,e,t,-r,o,s,5),a>0&&(N("z","y","x",-1,-1,1,r,t,e,n,0),N("z","y","x",1,-1,-1,r,t,e,n,1),N("z","y","x",-1,1,-1,r,t,e,n,1),N("z","y","x",1,1,1,r,t,e,n,0),N("x","y","z",-1,-1,-1,e,t,r,o,0),N("x","y","z",1,-1,1,e,t,r,o,1),N("x","y","z",-1,1,1,e,t,r,o,0),N("x","y","z",1,1,-1,e,t,r,o,1),N("y","x","z",-1,-1,1,t,e,r,s,0),N("y","x","z",1,-1,-1,t,e,r,s,1),N("y","x","z",1,1,1,t,e,r,s,1),N("y","x","z",-1,1,-1,t,e,r,s,0),C(1,1,1),C(-1,1,1),C(1,-1,1),C(-1,-1,1),C(1,1,-1),C(-1,1,-1),C(1,-1,-1),C(-1,-1,-1)),this.setIndex(d),this.setAttribute("position",new fl(h,3)),this.setAttribute("normal",new fl(p,3)),this.setAttribute("uv",new fl(m,2));function g(S,D,v,j,O,u,A,b,L,I,T){let $=(u-2*a)/L,J=(A-2*a)/I,te=u/2-a,fe=A/2-a,ce=b/2,be=L+1,R=I+1,E=0,y=0,z=new Fi;for(let _=0;_<R;_++){let F=_*J-fe;for(let K=0;K<be;K++){let Q=K*$-te;z[S]=Q*j,z[D]=F*O,z[v]=ce,h.push(z.x,z.y,z.z),z[S]=0,z[D]=0,z[v]=b>0?1:-1,p.push(z.x,z.y,z.z),m.push(K/L),m.push(1-_/I),E+=1}}for(let _=0;_<I;_++)for(let F=0;F<L;F++){let K=f+F+be*_,Q=f+F+be*(_+1),k=f+(F+1)+be*(_+1),V=f+(F+1)+be*_;d.push(K,Q,V),d.push(Q,k,V),y+=6}c.addGroup(x,y,T),x+=y,f+=E}function N(S,D,v,j,O,u,A,b,L,I,T){let $=(A-2*a)/I,J=A/2-a,te=b/2-a,fe=L/2,ce=I+1,be=0,R=0,E=new Fi,y=new Fi;for(let z=0;z<l+1;z++){let _=z/l*ml,F=Math.sin(_)*a,K=(1-Math.cos(_))*a,Q=Math.sin(_),k=Math.cos(_);E[D]=(te+F)*O,E[v]=(fe-K)*u,y[S]=0,y[D]=Q*Math.sign(E[D]),y[v]=k*Math.sign(E[v]);for(let V=0;V<ce;V++){let B=V*$-J;E[S]=B*j,h.push(E.x,E.y,E.z),p.push(y.x,y.y,y.z),m.push(V/I),m.push(0),be+=1}}for(let z=0;z<l;z++)for(let _=0;_<I;_++){let F=f+_+ce*z,K=f+_+ce*(z+1),Q=f+(_+1)+ce*(z+1),k=f+(_+1)+ce*z;d.push(F,K,k),d.push(K,Q,k),R+=6}c.addGroup(x,R,T),x+=R,f+=be}function C(S,D,v){let j=new Fi,O=new Fi(e/2,t/2,r/2);O.subScalar(a);let u=[],A=S*D*v>0?(L,I,T)=>d.push(L,I,T):(L,I,T)=>d.push(L,T,I);for(let L=0;L<=l;L++){let I=[],T=ml*(1-L/l),$=Math.cos(T),J=Math.sin(T),te=0;for(let fe=0;fe<=L;fe++){let ce=Math.cos(te),be=Math.sin(te);j.x=$*ce,j.y=J,j.z=$*be;let R=O.clone().addScaledVector(j,a);h.push(S*R.x,D*R.y,v*R.z),p.push(S*j.x,D*j.y,v*j.z),m.push(0,0),I.push(f++),te+=ml/L}u.push(I)}let b=u.length-1;for(let L=0;L<b;L++){let I=u[L],T=u[L+1],$=I.length-1;A(I[0],T[1],T[0]);for(let J=1;J<=$;J++)A(I[J-1],I[J],T[J]),A(I[J],T[J+1],T[J])}}}};import{BufferGeometry as lv,Float32BufferAttribute as gl,Triangle as cv,Vector3 as zr,Vector2 as yl}from"three";var No=class extends lv{constructor(e,t,r,o=1,s=.2,n=4){super();this.type="PolyhedronGeometryRound";let a=[],l=[],c=[];d(),h(),this.setAttribute("position",new gl(a,3)),this.setAttribute("normal",new gl(c,3)),this.setAttribute("uv",new gl(l,2));return;function d(){var be;s=Math.min(1-1e-5,s),s==0&&(n=0);let m={IcosahedronGeometry:5,DodecahedronGeometry:3,HexahedronGeometry:3,OctahedronGeometry:4,TetrahedronGeometry:3}[r],f=new zr,x=f.clone(),g=new cv,N=s*o,C=o-N,S=n+1,D=new zr,v=(R,E)=>D.subVectors(R,E).normalize(),j=(R,E)=>Array(R).fill(void 0).map(E),O=j(e.length/3,(R,E)=>new zr().fromArray(e,E*3).setLength(o)),u=[],A=1e6;for(let R=0;R<O.length;R++){let E=O[R],y=[],z,_,F,K=1e10,Q=-1;for(;(Q=t.indexOf(R,Q+1))!=-1;){let U=Q-Q%3;z=t[U+(Q+1)%3],_=t[U+(Q+2)%3],F=E.distanceToSquared(O[z]),K=Math.min(K,F),y.push([z,_,F])}K+=1e-6;let k=[],V=0,B=y.length;for(let U=0;U<B;U++){[z,_,F]=y[V];let se=((be=u[z])==null?void 0:be.includes(R))==!0;F<=K&&k.push(z+ +se*A),V=y.findIndex(H=>H[0]==_)}u.push(k)}let b=[];{let R=0,E=0,y,z,_=m==3;for(let F=0;F<=n;F++){y=F*(F+1)/2,z=(F+1)*(F+2)/2;for(let K=0;K<n-F;K++)[R,E]=[y+K+F+2,z+K+F+3],b.push(y,z,..._?[E,y]:[R,z],E,R),[y,z]=[R,E];b.push(y,z,y+n+2)}}let L=f.clone(),I=f.clone(),T=f.clone(),$=f.clone(),J=f.clone(),te=[],fe=j(O.length,()=>j(m,()=>f.clone()));for(let R=0;R<O.length;R++){f.copy(O[R]).normalize(),L.copy(f).multiplyScalar(C);let E=u[R];for(let k=0;k<E.length;k++){let V=E[k],B=E[(k+1)%m];g.setFromPointsAndIndices(O,R,V%A,B%A),g.b.sub(g.a).setLength(1e10).add(g.a),g.c.sub(g.a).setLength(1e10).add(g.a),g.closestPointToPoint(L,fe[R][k])}let y=[],z=[],_=[],F=new zr;n==0&&[...fe[R]].reduce((k,V)=>k.add(V),F).multiplyScalar(1/m);for(let k=0;k<m;k++){let V=[],B=(k-1+m)%m,U=fe[R][B],se=fe[R][k];f.copy(U).sub(L),x.copy(se).sub(L);let H=L.angleTo(f),W=f.angleTo(x),X=Math.cos(H)*N;n==0?I.copy(F):I.copy(L).setLength(C+X),z.push(X);let Z=[I,U,se];for(let Y=0;Y<2;Y++){let ne=Z[Y],ie=Z[Y+1];$.subVectors(ne,L),J.subVectors(ie,L),T.crossVectors($,J).normalize();for(let de=0;de<S;de++){let Ge=[H,W][Y]*de/S;f.copy($).applyAxisAngle(T,Ge).add(L),y.push(f.clone()),Y&&(v(f,L),V.push([de==0?ne:f.clone(),D.clone()]))}Y&&(v(ie,L),V.push([ie,D.clone()]))}_.push(V)}te.push(_);let K=2*S,Q=2;for(let k=0;k<m;k++){let V=K*k,B=K*((k+1)%m),U=[y[V]];for(let H=1;H<S;H++){$=y[V+H],J=y[B+H],U.push($);for(let W=1,X=H-Q+1;W<=X;W++)f.lerpVectors($,J,W/(X+1)),f.sub(L).setLength(z[k]).add(L),U.push(f.clone());U.push(J)}for(let H=0;H<S;H++)U.push(y[H+S+V]);U.push(y[B+S]);let se=b.map(H=>U[H]);a.push(...se.map(H=>[H.x,H.y,H.z]).flat()),c.push(...se.map(H=>(v(H,L),[D.x,D.y,D.z])).flat())}}let ce=[];for(let R=0;R<u.length;R++)for(let E=0;E<m;E++){let y=u[R][E];if(y<A){let z=u[y].findIndex(K=>K%A==R),_=te[R][E],F=te[y][z];for(let K=0;K<S;K++){let Q=_[K],k=F[S-K],V=_[K+1],B=F[S-(K+1)];[Q,k,V,V,k,B].forEach(U=>{a.push(U[0].x,U[0].y,U[0].z),c.push(U[1].x,U[1].y,U[1].z)})}ce.push(_[0][0],F[S][0],_[S][0],F[0][0])}}for(;ce.length;){let R,E,y,z;[R,E]=ce.splice(0,2);let _=[R];for(;R!=E;)_.push(E),y=ce.indexOf(E),z=y%2,E=ce.splice(y-z,2)[1-z];D.subVectors(_[0],_[1]).cross(f.subVectors(_[0],_[2])).normalize();let F=D.dot(_[0])<0;F&&D.negate();for(let K=1;K<=_.length-2;K++)[_[K+ +F],_[K+1-+F],_[0]].forEach(Q=>{a.push(Q.x,Q.y,Q.z),c.push(D.x,D.y,D.z)})}}function h(){let p=new zr;for(let O=0;O<a.length;O+=3){p.x=a[O+0],p.y=a[O+1],p.z=a[O+2];let u=v(p)/2/Math.PI+.5,A=j(p)/Math.PI+.5;l.push(u,1-A)}let m=new zr,f=new zr,x=new zr,g=new zr,N=new yl,C=new yl,S=new yl,D=(O,u,A,b)=>{b<0&&O.x===1&&(l[u]=O.x-1),A.x===0&&A.z===0&&(l[u]=b/2/Math.PI+.5)};for(let O=0,u=0;O<a.length;O+=9,u+=6){m.set(a[O+0],a[O+1],a[O+2]),f.set(a[O+3],a[O+4],a[O+5]),x.set(a[O+6],a[O+7],a[O+8]),N.set(l[u+0],l[u+1]),C.set(l[u+2],l[u+3]),S.set(l[u+4],l[u+5]),g.copy(m).add(f).add(x).divideScalar(3);let A=v(g);D(N,u+0,m,A),D(C,u+2,f,A),D(S,u+4,x,A)}for(let O=0;O<l.length;O+=6){let u=l[O+0],A=l[O+2],b=l[O+4],L=Math.max(u,A,b),I=Math.min(u,A,b);L>.9&&I<.1&&(u<.2&&(l[O+0]+=1),A<.2&&(l[O+2]+=1),b<.2&&(l[O+4]+=1))}function v(O){return Math.atan2(O.z,-O.x)}function j(O){return Math.atan2(-O.y,Math.sqrt(O.x*O.x+O.z*O.z))}}}static fromJSON(e){return new No(e.vertices,e.indices,e.radius,e.corner,e.cornerSides)}};import{DodecahedronBufferGeometry as dv}from"three";var kp=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,e){var r,o,s;let t=Object.assign({},(r=e==null?void 0:e.parameters)!=null?r:{width:100,detail:0,corner:0,cornerSides:4},i.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs((o=t.height)!=null?o:t.width),depth:Math.abs((s=t.depth)!=null?s:t.width)})}}static build(i){let{width:e,height:t,depth:r,detail:o,corner:s,cornerSides:n}=i.parameters,a=o===0&&s!==0?new Vn(e*.5,s,n):new dv(e*.5,o);return a.scale(1,t/e,r/e),Object.assign(a,{userData:q(P({},i),{type:"DodecahedronGeometry"})})}},Vn=class extends No{constructor(e=1,t=.2,r=4){let o=(1+Math.sqrt(5))/2,s=1/o,n=[-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,-s,-o,0,-s,o,0,s,-o,0,s,o,-s,-o,0,-s,o,0,s,-o,0,s,o,0,-o,0,-s,o,0,-s,-o,0,s,o,0,s],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(n,a,l,e,t,r);this.type=l}static fromJSON(e){return new Vn(e.radius,e.corner,e.cornerSides)}};import{EventDispatcher as Sv,Plane as Nv,Shape as eu,Vector2 as Fr,Vector3 as wv,MathUtils as Cl,LineCurve as Ll,QuadraticBezierCurve as tu,CubicBezierCurve as Jn}from"three";import{CubicBezierCurve as kn,EllipseCurve as hv,LineCurve as Un,LineCurve3 as pv,MathUtils as uv,QuadraticBezierCurve as xl,SplineCurve as fv,Vector2 as cr,Vector3 as Up}from"three";var Ri=1e-12,Vi=class{constructor(e){this.position=new cr;this.startPosition=new cr;this.uuid=uv.generateUUID();this.position=e.clone()}start(){this.reset()}reset(){this.startPosition.copy(this.position)}applyOffset(e){this.position.copy(this.startPosition).add(e)}copy(e){return this.position.copy(e.position),this.startPosition.copy(e.startPosition),this}clone(){return new Vi(this.position).copy(this)}toJSON(){return[this.position.x,this.position.y]}},ki=class extends Vi{constructor(e){super(e.position);this.parent=e}copy(e){return super.copy(e),this}clone(){return new ki(this.parent).copy(this)}},vr=class extends Vi{constructor(e,t){super(t);this.controls=[];this.roundness=0;this.areControlsDirectionsMirrored=!0;this.uuid=e,this.controls.push(new ki(this),new ki(this))}static create(e,t){let r=new vr(e,new cr(...t.position));return r.controls[0].position.set(...t.controlPrevious.position),r.controls[1].position.set(...t.controlNext.position),r.roundness=t.roundness,r.areControlsDirectionsMirrored=t.areControlsDirectionsMirrored,r}getOppositeControl(e){let t=this.controls.indexOf(e);return t===0?this.controls[1]:t===1?this.controls[0]:null}applyOffsetToControls(e,t=1){for(let r=0,o=this.controls.length;r<o;r++){let s=this.controls[r];this.position.distanceTo(s.position)<=t?s.position.copy(this.position):s.applyOffset(e)}}controlsMoved(){return!(this.position.equals(this.controls[0].position)&&this.position.equals(this.controls[1].position))}copy(e){return super.copy(e),this.controls[0].copy(e.controls[0]),this.controls[1].copy(e.controls[1]),this.roundness=e.roundness,this.uuid=e.uuid,this}clone(){return new vr(this.uuid,this.position).copy(this)}toJSON(){return super.toJSON().concat(this.controls[0].toJSON(),this.controls[1].toJSON(),[this.roundness])}},bl=i=>i,Ui=new cr,vl=new cr,mv=new cr,gv=new cr,yv=new cr,xv=new cr,Jp=new Up,Hp=new Up;function qp(i){let e=new cr;e.addVectors(i.v0,Ui.subVectors(i.v1,i.v0).multiplyScalar(2/3));let t=new cr;return t.addVectors(i.v2,vl.subVectors(i.v1,i.v2).multiplyScalar(2/3)),new kn(i.v0,e,t,i.v2)}function Ji(i,e,t=Number.EPSILON){return Math.abs(i-e)<t}function bv(i,e,t=Number.EPSILON){return i.distanceTo(e)<t}function vv(i,e,t=Number.EPSILON){return i.distanceTo(e)<t}function Sl(i,e,t){let r=Math.sqrt(Math.pow(e.x-i.x,2)+Math.pow(e.y-i.y,2)),o=Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2)),s=Math.sqrt(Math.pow(t.x-i.x,2)+Math.pow(t.y-i.y,2));return Math.acos((o*o+r*r-s*s)/(2*o*r))}function Wp(i,e,t,r,o){let s=Math.sqrt(Math.pow(e.x-i.x,2)+Math.pow(e.y-i.y,2)),n=(i.y+e.y)/2,a=(i.x+e.x)/2,l=Math.sqrt(Math.pow(t,2)-Math.pow(s/2,2))*(i.y-e.y)/s,c=Math.sqrt(Math.pow(t,2)-Math.pow(s/2,2))*(e.x-i.x)/s;return r.set(a+l,n+c),o.set(a-l,n-c),[r,o]}function $p(i,e,t){let r=i.distanceTo(t),o=e.distanceTo(t);return r<o?e:i}function Kp(i,e,t,r,o,s){let n=e.x-i.x,a=e.y-i.y,l=t.x-i.x,c=t.y-i.y,d=Math.sqrt((n+l)*(n+l)+(a+c)*(a+c)),h;return Sl(e,i,t)>Math.PI&&(d*=-1),Ji(c,a)?h=(a+c)*(r/d-.5)*8/3/(n-l):h=(n+l)*(r/d-.5)*8/3/(c-a),o.set(e.x-h*a,e.y+h*n),s.set(t.x+h*c,t.y-h*l),[o,s]}function Nl(i,e){return i.position.equals(i.controls[1].position)&&e.position.equals(e.controls[0].position)}function Xp(i,e,t,r,o=.5){let s=Ui.subVectors(e,i).multiplyScalar(o).add(i),n=vl.subVectors(t,e).multiplyScalar(o).add(e),a=mv.subVectors(r,t).multiplyScalar(o).add(t),l=s,c=gv.subVectors(n,s).multiplyScalar(o).add(s),d=yv.subVectors(a,n).multiplyScalar(o).add(n),h=a,p=xv.subVectors(d,c).multiplyScalar(o).add(c);return[i.x,i.y,l.x,l.y,c.x,c.y,p.x,p.y,d.x,d.y,h.x,h.y,r.x,r.y]}function Zp(i,e,t=12,r=!0){let o=Hp.set(0,0,0),s,n=0,a=[];for(let l=0;l<e.length;l++){let c=bl(e[l]),d=Ui,h=so(c,t);a.push(h);for(let p=0;p<=h;p++)if(c instanceof kn||c instanceof xl||c instanceof Un){if(c.getPoint(p/h,d),o.set(d.x,d.y,0),s!==void 0&&vv(s,o))continue;s===void 0&&(s=Jp),s.copy(o),i.setXYZ(n,o.x,o.y,o.z),n++}}return r&&n>1&&!(i.getX(n-1)===i.getX(0)&&i.getY(n-1)===i.getY(0)&&i.getZ(n-1)===i.getZ(0))&&(i.setXYZ(n,i.getX(0),i.getY(0),i.getZ(0)),n++),i}function Qp(i,e,t,r=12,o=!0){let s=Hp.set(0,0,0),n=0,a=[];for(let l=0;l<e.length;l++){if(t[l]===!1)continue;let c,d=bl(e[l]),h=Ui,p=so(d,r);a.push(p);for(let m=0;m<=p;m++)if(d instanceof kn||d instanceof xl||d instanceof Un){if(d.getPoint(m/p,h),s.set(h.x,h.y,0),c==null?void 0:c.equals(s))continue;c===void 0?c=Jp:(i.setXYZ(n,c.x,c.y,c.z),n++,i.setXYZ(n,s.x,s.y,s.z),n++),c.copy(s)}}return o&&n>1&&!(i.getX(n-1)===i.getX(0)&&i.getY(n-1)===i.getY(0)&&i.getZ(n-1)===i.getZ(0))&&(i.setXYZ(n,i.getX(0),i.getY(0),i.getZ(0)),n++),a}function wl(i,e=12,t=!1){let r=[];for(let o=0,s=i.length;o<s;o++){let n=i[o],a=0;if(t&&n.roundedCurveCorner!==void 0){let l=so(n.roundedCurveCorner,e)*.5;o>0&&(r[o-1]+=l),a+=l}n.curveAfter!==void 0&&(a+=so(n.curveAfter,e)),r.push(a)}return i.length>0&&t&&i[0].roundedCurveCorner!==void 0&&(r[i.length-1]+=so(i[0].roundedCurveCorner,e)*.5),r}function so(i,e=12){return i&&i instanceof hv?e*2:i&&(i instanceof Un||i instanceof pv)?1:i&&i instanceof fv?e*i.points.length:e}function Yp(i,e,t=12,r=!0){let o,s=0;for(let n=0;n<e.length;n++){let a=bl(e[n]),l=so(a,t),c=Ui;for(let d=0;d<=l;d++)if(a instanceof kn||a instanceof xl||a instanceof Un){if(a.getPoint(d/l,c),o!==void 0&&bv(o,c,Ri))continue;o===void 0&&(o=vl),o.copy(c),i.push(c.x,c.y),s++}}return Ji(i[0],i[i.length-2],Ri)&&Ji(i[1],i[i.length-1],Ri)&&(i.pop(),i.pop()),r&&s>1&&!(Ji(i[s-1],i[1],Ri)&&Ji(i[s-2],i[0],Ri))&&(i.push(i[0],i[1]),s++),i}var Ol=new Fr,Cv=new Fr,Lv=new Fr,Ov=new Fr,Tv=new Fr,Mv=new Fr,Pe=class extends eu{constructor(e=100,t=100){super();this.points=[];this.shapeHoles=[];this.eventDispatcher=new Sv;this.plane=new Nv(new wv(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=Cl.generateUUID();this.needsUpdate=!1;this.roundedCurves=[];this._width=e,this._height=t}static createFromState(e,t,r){let o=new Pe;return o.isClosed=e.isClosed,o.points=e.points.map(s=>vr.create(s.id,s.data)),typeof e.roundness=="number"&&(o.roundness=e.roundness),o.shapeHoles=e.shapeHoles.map(s=>Pe.createFromState(s)),t!==void 0&&r!==void 0&&o.applySize(t,r),o.update(),o}get width(){return this._width}get height(){return this._height}get roundness(){return this._roundness}set roundness(e){if(this._roundness!==e){this._roundness=e;for(let t=0,r=this.points.length;t<r;t++)this.points[t].roundness=e;this.needsUpdate=!0}}getPointsIndexesByIds(e){return e.map(t=>this.getPointIndexById(t)).filter(t=>t>=0)}getPointIndexById(e){return this.points.findIndex(t=>t.uuid===e)}getLineIndexById(e){return this.getPointIndexById(e)}getBezierPoint(e){if(e<=this.points.length-1)return this.points[e];if(this.shapeHoles.length>0)for(let t=0,r=this.shapeHoles.length;t<r;t++){let o=this.shapeHoles[t],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 t=this.points.indexOf(e);if(t>=0)return t;if(t=this.points.length,this.shapeHoles.length>0)for(let r=0,o=this.shapeHoles.length;r<o;r++){let s=this.shapeHoles[r],n=s.points.indexOf(e);if(n>=0)return t+n;t+=s.points.length}return-1}getAllPoints(){let e=[].concat(...this.shapeHoles.map(t=>t.points));return[...this.points,...e]}applySize(e,t){e===0&&(e=.001),t===0&&(t=.001),this.applyScale(e/this.width,t/this.height),this._width=e,this._height=t}applyScale(e,t){let r=Ol.set(e,t);for(let o=0,s=this.points.length;o<s;o++){let n=this.points[o];n.position.multiply(r),n.controls[0].position.multiply(r),n.controls[1].position.multiply(r)}for(let o=0,s=this.shapeHoles.length;o<s;o++)this.shapeHoles[o].applyScale(e,t);this._update(!1)}createPoint(e,t=0,r=Cl.generateUUID()){let o;e instanceof Fr?o=e:o=new Fr(e,t);let s=new vr(r,o);return s.roundness=this.roundness,s}addPoint(e){this.points.push(e),this.needsUpdate=!0}addPointAt(e,t){this.points.splice(t,0,e),this.needsUpdate=!0}getPointByUuid(e){for(let t=0,r=this.points.length;t<r;t++){let o=this.points[t];if(o.uuid===e)return o}}getFirstPoint(){return this.points[0]}getLastPoint(){return this.points[this.points.length-1]}removePoint(e){let t=this.points.indexOf(e);t>=0&&this.points.splice(t,1),this.needsUpdate=!0}removePointById(e){let t=this.points.find(r=>r.uuid===e);t&&this.removePoint(t)}update(e=!0){for(let t=0,r=this.shapeHoles.length;t<r;t++)this.shapeHoles[t].update(!1);this._update(e)}extractShapePointsToBuffer(e,t=12,r=!1){this.subdivision=t,this.curveDivisions===void 0&&this.computeCurveDivisions(t);let o=r?this.roundedCurveDivisions:this.curveDivisions;return Zp(e,r?this.roundedCurves:this.curves,t,this.autoClose),o.reduce((s,n)=>s+n,0)+1}computeCurveDivisions(e=12){return this.curveDivisions=wl(this.points,e,!1),this.roundedCurveDivisions=wl(this.points,e,!0),this.curveDivisions}extractFilteredShapePointsToBuffer(e,t,r=12){return Qp(e,this.curves,t,r,this.autoClose).reduce((s,n)=>s+n,0)*2}extractShapePointsToFlatArray(e,t=12){return this.subdivision=t,this.curveDivisions===void 0&&this.computeCurveDivisions(t),Yp(e,this.roundedCurves,t,this.autoClose)}getCurveIndexFromVertexId(e,t=!1){let r=0;this.curveDivisions===void 0&&this.computeCurveDivisions(this.subdivision);let o=t?this.roundedCurveDivisions:this.curveDivisions,s=0;t&&this.points[0].roundedCurveCorner!==void 0&&(s=so(this.points[0].roundedCurveCorner,this.subdivision)*.5);let n=e-s;n<0&&(n+=o.reduce((a,l)=>a+l,0));for(let a=0,l=o.length;a<l;a++){let c=o[a];if(n<r+c)return[a,(n-r+1)/c];r+=c}return[0,1]}getCurveT(e,t,r){let o=this.points[e],s=this.points[e>=this.points.length-1?0:e+1],n=this.curveDivisions,a=n[e];if(Nl(o,s)){let d=o.position.distanceTo(s.position);return o.position.distanceTo(Ol.set(r.x,r.y))/d}let l=0;for(let d=0;d<e;d++)l+=n[d];return(t-l)/a}dispose(){this.eventDispatcher=null}_applyCurveForPoint(e,t){Nl(t,e)?this.lineTo(e.position.x,e.position.y):this.bezierCurveTo(t.controls[1].position.x,t.controls[1].position.y,e.controls[0].position.x,e.controls[0].position.y,e.position.x,e.position.y);let r=this.curves[this.curves.length-1];e.curveBefore=r,t.curveAfter=r;let o=r.clone();e.roundedCurveBefore=o,t.roundedCurveAfter=o,e.roundedCurveCorner=void 0,this.roundedCurves.push(o)}_update(e=!0){var r;if(this.curves=[],this.roundedCurves=[],!this.points.length)return;for(let o=0,s=this.points.length;o<s;o++){let n=this.points[o];if(o===0)this.moveTo(n.position.x,n.position.y);else{let a=this.points[o-1];this._applyCurveForPoint(n,a)}}let t=this.getLastPoint();if((t==null?void 0:t.curveAfter)&&(t.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,n=this.points.length;s<n;s++){let a=this.points[s],l=a.roundness;if(!a.controlsMoved()&&l>0){let c=a.curveBefore,d=a.curveAfter;if(c===void 0||d===void 0)continue;let h=a.roundedCurveBefore,p=a.roundedCurveAfter,m=c.getLength(),f=d.getLength(),x=Math.min(l,m*.499),g=Math.min(l,f*.499),N=Math.min(x,g),C=1-N/m,S=N/f,D=c.getPointAt(C,Ol),v=d.getPointAt(S,Cv);this._subSplitCurve(c,h,C,D,void 0),this._subSplitCurve(d,p,S,void 0,v);let j;if(this.useCubicForRoundedCorners){let O=Sl(D,a.position,v)/2,u=Math.tan(O)*D.distanceTo(a.position),[A,b]=Wp(D,v,u,Lv,Ov),L=$p(A,b,a.position),[I,T]=Kp(L,D,v,u,Tv,Mv);j=new Jn(D.clone(),I.clone(),T.clone(),v.clone())}else j=new tu(D.clone(),a.position.clone(),v.clone());a.roundedCurveCorner=j,this.roundedCurves.splice(s+o,0,j),o++}}}e&&((r=this.eventDispatcher)==null||r.dispatchEvent({type:"update"}))}_subSplitCurve(e,t,r,o,s){if(e instanceof Ll)o!==void 0&&t.v2.copy(o),s!==void 0&&t.v1.copy(s);else{let n=e,a=t,l=n.getUtoTmapping(r,0),c=Xp(n.v0,n.v1,n.v2,n.v3,l);return o!==void 0&&(a.v0.set(c[0],c[1]),a.v1.set(c[2],c[3]),a.v2.set(c[4],c[5]),a.v3.set(c[6],c[7])),s!==void 0&&(a.v0.set(c[6],c[7]),a.v1.set(c[8],c[9]),a.v2.set(c[10],c[11]),a.v3.set(c[12],c[13])),a}return t}clone(){let e=new Pe(this._width,this._height);return e.points=this.points.map(t=>t.clone()),e.isClosed=this.isClosed,e.roundness=this.roundness,e.isMesh2D=this.isMesh2D,e.shapeHoles=this.shapeHoles.map(t=>t.clone()),e}toJSON(){return{points:this.points.reduce((e,t)=>e.concat(t.toJSON()),[]),shapeHoles:this.shapeHoles.map(e=>e.toJSON()),isClosed:this.isClosed,roundness:this.roundness}}fromJSON(e){var r;this.points=[],this.pointIDs=0;let t=e.points.length/7;for(let o=0;o<t;o++){let s=o*7,n=e.points[s+0],a=e.points[s+1],l=e.points[s+2],c=e.points[s+3],d=e.points[s+4],h=e.points[s+5],p=e.points[s+6],m=new vr(Cl.generateUUID(),new Fr(n,a));m.controls[0].position.set(l,c),m.controls[1].position.set(d,h),m.roundness=p,this.points.push(m)}return this.shapeHoles=((r=e.shapeHoles)==null?void 0:r.length)?e.shapeHoles.map(o=>{let s=new Pe;return s.fromJSON(o),s}):[],this.isClosed=e.isClosed,this._roundness=e.roundness,this._update(),this}fromShape(e){let t=(o,s)=>{s instanceof Jn&&s.v3.equals(o.position)&&o.controls[0].position.copy(s.v2)},r=o=>{let s=[],n,a;for(n=0,a=o.length;n<a;n++)o[n]instanceof tu&&(o[n]=qp(o[n]));for(n=0,a=o.length;n<a;n++){let d=o[n],h=n>0?o[n-1]:null,p;d instanceof Jn?(p=this.createPoint(d.v0),p.controls[1].position.copy(d.v1)):d instanceof Ll&&(p=this.createPoint(d.v1)),p!==void 0&&(h!==null&&t(p,h),s.push(p))}let l=o[o.length-1],c=!1;return l instanceof Jn?l.v3.equals(s[0].position)&&(s[0].controls[0].position.copy(l.v2),c=!0):l instanceof Ll&&l.v2.equals(s[0].position)&&(c=!0),this.isClosed=c,s};return this.points=r(e.curves),e instanceof eu&&(this.shapeHoles=e.holes.map(o=>{let s=new Pe;return s.fromShape(o),s})),this.update(),this}};var Tl=Math.PI*2;function Ml({x:i,y:e},t,r,o,s){return{x:i*t+o,y:e*r+s}}function Iv(i,e){let t=e===1.5707963267948966?.551915024494:e===-1.5707963267948966?-.551915024494:4/3*Math.tan(e/4),r=Math.cos(i),o=Math.sin(i),s=Math.cos(i+e),n=Math.sin(i+e);return[{x:r-o*t,y:o+r*t},{x:s+n*t,y:n-s*t},{x:s,y:n}]}function ru(i,e,t,r){let o=i*r-e*t<0?-1:1,s=Math.min(1,Math.max(-1,i*t+e*r));return o*Math.acos(s)}function Pv(i,e,t,r,o,s,n,a,l,c){let d=Math.pow(o,2),h=Math.pow(s,2),p=Math.pow(n,2),m=Math.pow(a,2),f=d*h-d*m-h*p;f<0&&(f=0),f/=d*m+h*p,f=Math.sqrt(f)*(l===c?-1:1);let x=f*o/s*a,g=f*-s/o*n,N=x+(i+t)/2,C=g+(e+r)/2,S=(n-x)/o,D=(a-g)/s,v=(-n-x)/o,j=(-a-g)/s,O=ru(1,0,S,D),u=ru(S,D,v,j);return!c&&u>0&&(u-=Tl),c&&u<0&&(u+=Tl),{centerx:N,centery:C,ang1:O,ang2:u}}function ou({px:i,py:e,cx:t,cy:r,rx:o,ry:s,largeArcFlag:n,sweepFlag:a}){let l=[];if(o===0||s===0)return[];let c=(i-t)/2,d=(e-r)/2;if(c===0&&d===0)return[];o=Math.abs(o),s=Math.abs(s);let h=Math.pow(c,2)/Math.pow(o,2)+Math.pow(d,2)/Math.pow(s,2);h>1&&(o*=Math.sqrt(h),s*=Math.sqrt(h));let p=Pv(i,e,t,r,o,s,c,d,n,a),{ang1:m,ang2:f}=p,{centerx:x,centery:g}=p,N=Math.abs(f)/(Tl/4);Math.abs(1-N)<1e-7&&(N=1);let C=Math.max(Math.ceil(N),1);f/=C;for(let S=0;S<C;S++)l.push(Iv(m,f)),m+=f;return l.map(S=>{let{x:D,y:v}=Ml(S[0],o,s,x,g),{x:j,y:O}=Ml(S[1],o,s,x,g),{x:u,y:A}=Ml(S[2],o,s,x,g);return{x1:D,y1:v,x2:j,y2:O,x:u,y:A}})}import{BufferAttribute as qn,BufferGeometry as Bv}from"three";var We;(function(i){i[i.ODD=0]="ODD",i[i.NONZERO=1]="NONZERO",i[i.POSITIVE=2]="POSITIVE",i[i.NEGATIVE=3]="NEGATIVE",i[i.ABS_GEQ_TWO=4]="ABS_GEQ_TWO"})(We||(We={}));var at;(function(i){i[i.POLYGONS=0]="POLYGONS",i[i.CONNECTED_POLYGONS=1]="CONNECTED_POLYGONS",i[i.BOUNDARY_CONTOURS=2]="BOUNDARY_CONTOURS"})(at||(at={}));function he(i,e){if(!i)throw e||"Assertion Failed!"}var ae=function(){function i(){}return i.vertEq=function(e,t){return e.s===t.s&&e.t===t.t},i.vertLeq=function(e,t){return e.s<t.s||e.s===t.s&&e.t<=t.t},i.transLeq=function(e,t){return e.t<t.t||e.t===t.t&&e.s<=t.s},i.edgeGoesLeft=function(e){return i.vertLeq(e.Dst,e.Org)},i.edgeGoesRight=function(e){return i.vertLeq(e.Org,e.Dst)},i.vertL1dist=function(e,t){return Math.abs(e.s-t.s)+Math.abs(e.t-t.t)},i.edgeEval=function(e,t,r){he(i.vertLeq(e,t)&&i.vertLeq(t,r));var o=t.s-e.s,s=r.s-t.s;return o+s>0?o<s?t.t-e.t+(e.t-r.t)*(o/(o+s)):t.t-r.t+(r.t-e.t)*(s/(o+s)):0},i.edgeSign=function(e,t,r){he(i.vertLeq(e,t)&&i.vertLeq(t,r));var o=t.s-e.s,s=r.s-t.s;return o+s>0?(t.t-r.t)*o+(t.t-e.t)*s:0},i.transEval=function(e,t,r){he(i.transLeq(e,t)&&i.transLeq(t,r));var o=t.t-e.t,s=r.t-t.t;return o+s>0?o<s?t.s-e.s+(e.s-r.s)*(o/(o+s)):t.s-r.s+(r.s-e.s)*(s/(o+s)):0},i.transSign=function(e,t,r){he(i.transLeq(e,t)&&i.transLeq(t,r));var o=t.t-e.t,s=r.t-t.t;return o+s>0?(t.s-r.s)*o+(t.s-e.s)*s:0},i.vertCCW=function(e,t,r){return e.s*(t.t-r.t)+t.s*(r.t-e.t)+r.s*(e.t-t.t)>=0},i.interpolate=function(e,t,r,o){return e=e<0?0:e,r=r<0?0:r,e<=r?r===0?(t+o)/2:t+(o-t)*(e/(e+r)):o+(t-o)*(r/(e+r))},i.intersect=function(e,t,r,o,s){var n,a,l;i.vertLeq(e,t)||(l=e,e=t,t=l),i.vertLeq(r,o)||(l=r,r=o,o=l),i.vertLeq(e,r)||(l=e,e=r,r=l,l=t,t=o,o=l),i.vertLeq(r,t)?i.vertLeq(t,o)?(n=i.edgeEval(e,r,t),a=i.edgeEval(r,t,o),n+a<0&&(n=-n,a=-a),s.s=i.interpolate(n,r.s,a,t.s)):(n=i.edgeSign(e,r,t),a=-i.edgeSign(e,o,t),n+a<0&&(n=-n,a=-a),s.s=i.interpolate(n,r.s,a,o.s)):s.s=(r.s+t.s)/2,i.transLeq(e,t)||(l=e,e=t,t=l),i.transLeq(r,o)||(l=r,r=o,o=l),i.transLeq(e,r)||(l=e,e=r,r=l,l=t,t=o,o=l),i.transLeq(r,t)?i.transLeq(t,o)?(n=i.transEval(e,r,t),a=i.transEval(r,t,o),n+a<0&&(n=-n,a=-a),s.t=i.interpolate(n,r.t,a,t.t)):(n=i.transSign(e,r,t),a=-i.transSign(e,o,t),n+a<0&&(n=-n,a=-a),s.t=i.interpolate(n,r.t,a,o.t)):s.t=(r.t+t.t)/2},i}(),Hi=function(){function i(){this.next=null,this.prev=null,this.anEdge=null,this.trail=null,this.n=0,this.marked=!1,this.inside=!1}return i}(),Hn=function(){function i(e){this.side=e,this.next=null,this.Org=null,this.Sym=null,this.Onext=null,this.Lnext=null,this.Lface=null,this.activeRegion=null,this.winding=0}return Object.defineProperty(i.prototype,"Rface",{get:function(){return this.Sym.Lface},set:function(e){this.Sym.Lface=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Dst",{get:function(){return this.Sym.Org},set:function(e){this.Sym.Org=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Oprev",{get:function(){return this.Sym.Lnext},set:function(e){this.Sym.Lnext=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Lprev",{get:function(){return this.Onext.Sym},set:function(e){this.Onext.Sym=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Dprev",{get:function(){return this.Lnext.Sym},set:function(e){this.Lnext.Sym=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Rprev",{get:function(){return this.Sym.Onext},set:function(e){this.Sym.Onext=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Dnext",{get:function(){return this.Sym.Onext.Sym},set:function(e){this.Sym.Onext.Sym=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Rnext",{get:function(){return this.Sym.Lnext.Sym},set:function(e){this.Sym.Lnext.Sym=e},enumerable:!0,configurable:!0}),i}(),ci=function(){function i(){this.next=null,this.prev=null,this.anEdge=null,this.coords=[0,0,0],this.s=0,this.t=0,this.pqHandle=0,this.n=0,this.idx=0}return i}(),iu=function(){function i(){var e=new ci,t=new Hi,r=new Hn(0),o=new Hn(1);e.next=e.prev=e,e.anEdge=null,t.next=t.prev=t,r.next=r,r.Sym=o,o.next=o,o.Sym=r,this.vHead=e,this.fHead=t,this.eHead=r,this.eHeadSym=o}return i.prototype.makeEdge_=function(e){var t=new Hn(0),r=new Hn(1);e.Sym.side<e.side&&(e=e.Sym);var o=e.Sym.next;return r.next=o,o.Sym.next=t,t.next=e,e.Sym.next=r,t.Sym=r,t.Onext=t,t.Lnext=r,t.Org=null,t.Lface=null,t.winding=0,t.activeRegion=null,r.Sym=t,r.Onext=r,r.Lnext=t,r.Org=null,r.Lface=null,r.winding=0,r.activeRegion=null,t},i.prototype.splice_=function(e,t){var r=e.Onext,o=t.Onext;r.Sym.Lnext=t,o.Sym.Lnext=e,e.Onext=o,t.Onext=r},i.prototype.makeVertex_=function(e,t,r){var o=e;he(o,"Vertex can't be null!");var s=r.prev;o.prev=s,s.next=o,o.next=r,r.prev=o,o.anEdge=t;var n=t;do n.Org=o,n=n.Onext;while(n!==t)},i.prototype.makeFace_=function(e,t,r){var o=e;he(o,"Face can't be null");var s=r.prev;o.prev=s,s.next=o,o.next=r,r.prev=o,o.anEdge=t,o.trail=null,o.marked=!1,o.inside=r.inside;var n=t;do n.Lface=o,n=n.Lnext;while(n!==t)},i.prototype.killEdge_=function(e){e.Sym.side<e.side&&(e=e.Sym);var t=e.next,r=e.Sym.next;t.Sym.next=r,r.Sym.next=t},i.prototype.killVertex_=function(e,t){var r=e.anEdge,o=r;do o.Org=t,o=o.Onext;while(o!==r);var s=e.prev,n=e.next;n.prev=s,s.next=n},i.prototype.killFace_=function(e,t){var r=e.anEdge,o=r;do o.Lface=t,o=o.Lnext;while(o!==r);var s=e.prev,n=e.next;n.prev=s,s.next=n},i.prototype.makeEdge=function(){var e=new ci,t=new ci,r=new Hi,o=this.makeEdge_(this.eHead);return this.makeVertex_(e,o,this.vHead),this.makeVertex_(t,o.Sym,this.vHead),this.makeFace_(r,o,this.fHead),o},i.prototype.splice=function(e,t){var r=!1,o=!1;if(e!==t){if(t.Org!==e.Org&&(o=!0,this.killVertex_(t.Org,e.Org)),t.Lface!==e.Lface&&(r=!0,this.killFace_(t.Lface,e.Lface)),this.splice_(t,e),!o){var s=new ci;this.makeVertex_(s,t,e.Org),e.Org.anEdge=e}if(!r){var n=new Hi;this.makeFace_(n,t,e.Lface),e.Lface.anEdge=e}}},i.prototype.delete=function(e){var t=e.Sym,r=!1;if(e.Lface!==e.Rface&&(r=!0,this.killFace_(e.Lface,e.Rface)),e.Onext===e)this.killVertex_(e.Org,null);else if(e.Rface.anEdge=e.Oprev,e.Org.anEdge=e.Onext,this.splice_(e,e.Oprev),!r){var o=new Hi;this.makeFace_(o,e,e.Lface)}t.Onext===t?(this.killVertex_(t.Org,null),this.killFace_(t.Lface,null)):(e.Lface.anEdge=t.Oprev,t.Org.anEdge=t.Onext,this.splice_(t,t.Oprev)),this.killEdge_(e)},i.prototype.addEdgeVertex=function(e){var t=this.makeEdge_(e),r=t.Sym;this.splice_(t,e.Lnext),t.Org=e.Dst;var o=new ci;return this.makeVertex_(o,r,t.Org),t.Lface=r.Lface=e.Lface,t},i.prototype.splitEdge=function(e){var t=this.addEdgeVertex(e),r=t.Sym;return this.splice_(e.Sym,e.Sym.Oprev),this.splice_(e.Sym,r),e.Dst=r.Org,r.Dst.anEdge=r.Sym,r.Rface=e.Rface,r.winding=e.winding,r.Sym.winding=e.Sym.winding,r.idx=e.idx,r.Sym.idx=e.Sym.idx,r},i.prototype.connect=function(e,t){var r=!1,o=this.makeEdge_(e),s=o.Sym;if(t.Lface!==e.Lface&&(r=!0,this.killFace_(t.Lface,e.Lface)),this.splice_(o,e.Lnext),this.splice_(s,t),o.Org=e.Dst,s.Org=t.Org,o.Lface=s.Lface=e.Lface,e.Lface.anEdge=s,!r){var n=new Hi;this.makeFace_(n,o,e.Lface)}return o},i.prototype.zapFace=function(e){var t=e.anEdge,r,o,s,n,a;o=t.Lnext;do r=o,o=r.Lnext,r.Lface=null,r.Rface===null&&(r.Onext===r?this.killVertex_(r.Org,null):(r.Org.anEdge=r.Onext,this.splice_(r,r.Oprev)),s=r.Sym,s.Onext===s?this.killVertex_(s.Org,null):(s.Org.anEdge=s.Onext,this.splice_(s,s.Oprev)),this.killEdge_(r));while(r!=t);n=e.prev,a=e.next,a.prev=n,n.next=a},i.prototype.countFaceVerts_=function(e){var t=e.anEdge,r=0;do r++,t=t.Lnext;while(t!==e.anEdge);return r},i.prototype.mergeConvexFaces=function(e){var t,r,o,s,n,a,l;for(t=this.fHead.next;t!==this.fHead;t=t.next)if(!!t.inside)for(r=t.anEdge,n=r.Org;o=r.Lnext,s=r.Sym,s&&s.Lface&&s.Lface.inside&&(a=this.countFaceVerts_(t),l=this.countFaceVerts_(s.Lface),a+l-2<=e&&ae.vertCCW(r.Lprev.Org,r.Org,s.Lnext.Lnext.Org)&&ae.vertCCW(s.Lprev.Org,s.Org,r.Lnext.Lnext.Org)&&(o=s.Lnext,this.delete(s),r=null,s=null)),!(r&&r.Lnext.Org===n);)r=o;return!0},i.prototype.check=function(){var e=this.fHead,t=this.vHead,r=this.eHead,o,s,n,a,l,c;for(s=e,s=e;(o=s.next)!==e;s=o){he(o.prev===s),l=o.anEdge;do he(l.Sym!==l),he(l.Sym.Sym===l),he(l.Lnext.Onext.Sym===l),he(l.Onext.Sym.Lnext===l),he(l.Lface===o),l=l.Lnext;while(l!==o.anEdge)}for(he(o.prev===s&&o.anEdge===null),a=t,a=t;(n=a.next)!==t;a=n){he(n.prev===a),l=n.anEdge;do he(l.Sym!==l),he(l.Sym.Sym===l),he(l.Lnext.Onext.Sym===l),he(l.Onext.Sym.Lnext===l),he(l.Org===n),l=l.Onext;while(l!==n.anEdge)}for(he(n.prev===a&&n.anEdge===null),c=r,c=r;(l=c.next)!==r;c=l)he(l.Sym.next===c.Sym),he(l.Sym!==l),he(l.Sym.Sym===l),he(l.Org!==null),he(l.Dst!==null),he(l.Lnext.Onext.Sym===l),he(l.Onext.Sym.Lnext===l);he(l.Sym.next===c.Sym&&l.Sym===this.eHeadSym&&l.Sym.Sym===l&&l.Org===null&&l.Dst===null&&l.Lface===null&&l.Rface===null)},i}(),su=function(){function i(){this.handle=null}return i}(),nu=function(){function i(){this.key=null,this.node=0}return i}(),Av=function(){function i(e,t){this.leq=t,this.max=0,this.nodes=[],this.handles=[],this.initialized=!1,this.freeList=0,this.size=0,this.max=e,this.nodes=[],this.handles=[];for(var r=0;r<e+1;r++)this.nodes[r]=new su,this.handles[r]=new nu;this.initialized=!1,this.nodes[1].handle=1,this.handles[1].key=null}return i.prototype.floatDown_=function(e){var t=this.nodes,r=this.handles,o,s,n;for(o=t[e].handle;;){if(n=e<<1,n<this.size&&this.leq(r[t[n+1].handle].key,r[t[n].handle].key)&&++n,he(n<=this.max),s=t[n].handle,n>this.size||this.leq(r[o].key,r[s].key)){t[e].handle=o,r[o].node=e;break}t[e].handle=s,r[s].node=e,e=n}},i.prototype.floatUp_=function(e){var t=this.nodes,r=this.handles,o,s,n;for(o=t[e].handle;;){if(n=e>>1,s=t[n].handle,n===0||this.leq(r[s].key,r[o].key)){t[e].handle=o,r[o].node=e;break}t[e].handle=s,r[s].node=e,e=n}},i.prototype.init=function(){for(var e=this.size;e>=1;--e)this.floatDown_(e);this.initialized=!0},i.prototype.min=function(){return this.handles[this.nodes[1].handle].key},i.prototype.insert=function(e){var t,r;if(t=++this.size,t*2>this.max){this.max*=2;var o,s;for(s=this.nodes.length,this.nodes.length=this.max+1,o=s;o<this.nodes.length;o++)this.nodes[o]=new su;for(s=this.handles.length,this.handles.length=this.max+1,o=s;o<this.handles.length;o++)this.handles[o]=new nu}return this.freeList===0?r=t:(r=this.freeList,this.freeList=this.handles[r].node),this.nodes[t].handle=r,this.handles[r].node=t,this.handles[r].key=e,this.initialized&&this.floatUp_(t),r},i.prototype.extractMin=function(){var e=this.nodes,t=this.handles,r=e[1].handle,o=t[r].key;return this.size>0&&(e[1].handle=e[this.size].handle,t[e[1].handle].node=1,t[r].key=null,t[r].node=this.freeList,this.freeList=r,--this.size,this.size>0&&this.floatDown_(1)),o},i.prototype.delete=function(e){var t=this.nodes,r=this.handles,o;he(e>=1&&e<=this.max&&r[e].key!==null),o=r[e].node,t[o].handle=t[this.size].handle,r[t[o].handle].node=o,--this.size,o<=this.size&&(o<=1||this.leq(r[t[o>>1].handle].key,r[t[o].handle].key)?this.floatDown_(o):this.floatUp_(o)),r[e].key=null,r[e].node=this.freeList,this.freeList=e},i}(),Il=function(){function i(){this.eUp=null,this.nodeUp=null,this.windingNumber=0,this.inside=!1,this.sentinel=!1,this.dirty=!1,this.fixUpperEdge=!1}return i}(),au=function(){function i(){this.key=null,this.next=null,this.prev=null}return i}(),jv=function(){function i(e,t){this.frame=e,this.leq=t,this.head=new au,this.head.next=this.head,this.head.prev=this.head}return i.prototype.min=function(){return this.head.next},i.prototype.max=function(){return this.head.prev},i.prototype.insert=function(e){return this.insertBefore(this.head,e)},i.prototype.search=function(e){var t=this.head;do t=t.next;while(t.key!==null&&!this.leq(this.frame,e,t.key));return t},i.prototype.insertBefore=function(e,t){do e=e.prev;while(e.key!==null&&!this.leq(this.frame,e.key,t));var r=new au;return r.key=t,r.next=e.next,e.next.prev=r,r.prev=e,e.next=r,r},i.prototype.delete=function(e){e.next.prev=e.prev,e.prev.next=e.next},i}(),_v=function(){function i(){}return i.regionBelow=function(e){return e.nodeUp.prev.key},i.regionAbove=function(e){return e.nodeUp.next.key},i.debugEvent=function(e){},i.addWinding=function(e,t){e.winding+=t.winding,e.Sym.winding+=t.Sym.winding},i.edgeLeq=function(e,t,r){var o=e.event,s=t.eUp,n=r.eUp;if(s.Dst===o)return n.Dst===o?ae.vertLeq(s.Org,n.Org)?ae.edgeSign(n.Dst,s.Org,n.Org)<=0:ae.edgeSign(s.Dst,n.Org,s.Org)>=0:ae.edgeSign(n.Dst,o,n.Org)<=0;if(n.Dst===o)return ae.edgeSign(s.Dst,o,s.Org)>=0;var a=ae.edgeEval(s.Dst,o,s.Org),l=ae.edgeEval(n.Dst,o,n.Org);return a>=l},i.deleteRegion=function(e,t){t.fixUpperEdge&&he(t.eUp.winding===0),t.eUp.activeRegion=null,e.dict.delete(t.nodeUp)},i.fixUpperEdge=function(e,t,r){he(t.fixUpperEdge),e.mesh.delete(t.eUp),t.fixUpperEdge=!1,t.eUp=r,r.activeRegion=t},i.topLeftRegion=function(e,t){var r=t.eUp.Org,o;do t=i.regionAbove(t);while(t.eUp.Org===r);if(t.fixUpperEdge){if(o=e.mesh.connect(i.regionBelow(t).eUp.Sym,t.eUp.Lnext),o===null)return null;i.fixUpperEdge(e,t,o),t=i.regionAbove(t)}return t},i.topRightRegion=function(e){var t=e.eUp.Dst;do e=i.regionAbove(e);while(e.eUp.Dst===t);return e},i.addRegionBelow=function(e,t,r){var o=new Il;return o.eUp=r,o.nodeUp=e.dict.insertBefore(t.nodeUp,o),o.fixUpperEdge=!1,o.sentinel=!1,o.dirty=!1,r.activeRegion=o,o},i.isWindingInside=function(e,t){switch(e.windingRule){case We.ODD:return(t&1)!=0;case We.NONZERO:return t!==0;case We.POSITIVE:return t>0;case We.NEGATIVE:return t<0;case We.ABS_GEQ_TWO:return t>=2||t<=-2}throw new Error("Invalid winding rulle")},i.computeWinding=function(e,t){t.windingNumber=i.regionAbove(t).windingNumber+t.eUp.winding,t.inside=i.isWindingInside(e,t.windingNumber)},i.finishRegion=function(e,t){var r=t.eUp,o=r.Lface;o.inside=t.inside,o.anEdge=r,i.deleteRegion(e,t)},i.finishLeftRegions=function(e,t,r){for(var o,s=null,n=t,a=t.eUp;n!==r;){if(n.fixUpperEdge=!1,s=i.regionBelow(n),o=s.eUp,o.Org!=a.Org){if(!s.fixUpperEdge){i.finishRegion(e,n);break}o=e.mesh.connect(a.Lprev,o.Sym),i.fixUpperEdge(e,s,o)}a.Onext!==o&&(e.mesh.splice(o.Oprev,o),e.mesh.splice(a,o)),i.finishRegion(e,n),a=s.eUp,n=s}return a},i.addRightEdges=function(e,t,r,o,s,n){var a,l,c,d,h=!0;c=r;do he(ae.vertLeq(c.Org,c.Dst)),i.addRegionBelow(e,t,c.Sym),c=c.Onext;while(c!==o);for(s===null&&(s=i.regionBelow(t).eUp.Rprev),l=t,d=s;a=i.regionBelow(l),c=a.eUp.Sym,c.Org===d.Org;)c.Onext!==d&&(e.mesh.splice(c.Oprev,c),e.mesh.splice(d.Oprev,c)),a.windingNumber=l.windingNumber-c.winding,a.inside=i.isWindingInside(e,a.windingNumber),l.dirty=!0,!h&&i.checkForRightSplice(e,l)&&(i.addWinding(c,d),i.deleteRegion(e,l),e.mesh.delete(d)),h=!1,l=a,d=c;l.dirty=!0,he(l.windingNumber-c.winding===a.windingNumber),n&&i.walkDirtyRegions(e,l)},i.spliceMergeVertices=function(e,t,r){e.mesh.splice(t,r)},i.vertexWeights=function(e,t,r){var o=ae.vertL1dist(t,e),s=ae.vertL1dist(r,e),n=.5*s/(o+s),a=.5*o/(o+s);e.coords[0]+=n*t.coords[0]+a*r.coords[0],e.coords[1]+=n*t.coords[1]+a*r.coords[1],e.coords[2]+=n*t.coords[2]+a*r.coords[2]},i.getIntersectData=function(e,t,r,o,s,n){t.coords[0]=t.coords[1]=t.coords[2]=0,t.idx=-1,i.vertexWeights(t,r,o),i.vertexWeights(t,s,n)},i.checkForRightSplice=function(e,t){var r=i.regionBelow(t),o=t.eUp,s=r.eUp;if(ae.vertLeq(o.Org,s.Org)){if(ae.edgeSign(s.Dst,o.Org,s.Org)>0)return!1;ae.vertEq(o.Org,s.Org)?o.Org!==s.Org&&(e.pq.delete(o.Org.pqHandle),i.spliceMergeVertices(e,s.Oprev,o)):(e.mesh.splitEdge(s.Sym),e.mesh.splice(o,s.Oprev),t.dirty=r.dirty=!0)}else{if(ae.edgeSign(o.Dst,s.Org,o.Org)<0)return!1;i.regionAbove(t).dirty=t.dirty=!0,e.mesh.splitEdge(o.Sym),e.mesh.splice(s.Oprev,o)}return!0},i.checkForLeftSplice=function(e,t){var r=i.regionBelow(t),o=t.eUp,s=r.eUp,n;if(he(!ae.vertEq(o.Dst,s.Dst)),ae.vertLeq(o.Dst,s.Dst)){if(ae.edgeSign(o.Dst,s.Dst,o.Org)<0)return!1;i.regionAbove(t).dirty=t.dirty=!0,n=e.mesh.splitEdge(o),e.mesh.splice(s.Sym,n),n.Lface.inside=t.inside}else{if(ae.edgeSign(s.Dst,o.Dst,s.Org)>0)return!1;t.dirty=r.dirty=!0,n=e.mesh.splitEdge(s),e.mesh.splice(o.Lnext,s.Sym),n.Rface.inside=t.inside}return!0},i.checkForIntersect=function(e,t){var r=i.regionBelow(t),o=t.eUp,s=r.eUp,n=o.Org,a=s.Org,l=o.Dst,c=s.Dst,d,h,p=new ci,m,f;if(he(!ae.vertEq(c,l)),he(ae.edgeSign(l,e.event,n)<=0),he(ae.edgeSign(c,e.event,a)>=0),he(n!==e.event&&a!==e.event),he(!t.fixUpperEdge&&!r.fixUpperEdge),n===a||(d=Math.min(n.t,l.t),h=Math.max(a.t,c.t),d>h))return!1;if(ae.vertLeq(n,a)){if(ae.edgeSign(c,n,a)>0)return!1}else if(ae.edgeSign(l,a,n)<0)return!1;return i.debugEvent(e),ae.intersect(l,n,c,a,p),he(Math.min(n.t,l.t)<=p.t),he(p.t<=Math.max(a.t,c.t)),he(Math.min(c.s,l.s)<=p.s),he(p.s<=Math.max(a.s,n.s)),ae.vertLeq(p,e.event)&&(p.s=e.event.s,p.t=e.event.t),m=ae.vertLeq(n,a)?n:a,ae.vertLeq(m,p)&&(p.s=m.s,p.t=m.t),ae.vertEq(p,n)||ae.vertEq(p,a)?(i.checkForRightSplice(e,t),!1):!ae.vertEq(l,e.event)&&ae.edgeSign(l,e.event,p)>=0||!ae.vertEq(c,e.event)&&ae.edgeSign(c,e.event,p)<=0?c===e.event?(e.mesh.splitEdge(o.Sym),e.mesh.splice(s.Sym,o),t=i.topLeftRegion(e,t),o=i.regionBelow(t).eUp,i.finishLeftRegions(e,i.regionBelow(t),r),i.addRightEdges(e,t,o.Oprev,o,o,!0),!0):l===e.event?(e.mesh.splitEdge(s.Sym),e.mesh.splice(o.Lnext,s.Oprev),r=t,t=i.topRightRegion(t),f=i.regionBelow(t).eUp.Rprev,r.eUp=s.Oprev,s=i.finishLeftRegions(e,r,null),i.addRightEdges(e,t,s.Onext,o.Rprev,f,!0),!0):(ae.edgeSign(l,e.event,p)>=0&&(i.regionAbove(t).dirty=t.dirty=!0,e.mesh.splitEdge(o.Sym),o.Org.s=e.event.s,o.Org.t=e.event.t),ae.edgeSign(c,e.event,p)<=0&&(t.dirty=r.dirty=!0,e.mesh.splitEdge(s.Sym),s.Org.s=e.event.s,s.Org.t=e.event.t),!1):(e.mesh.splitEdge(o.Sym),e.mesh.splitEdge(s.Sym),e.mesh.splice(s.Oprev,o),o.Org.s=p.s,o.Org.t=p.t,o.Org.pqHandle=e.pq.insert(o.Org),i.getIntersectData(e,o.Org,n,l,a,c),i.regionAbove(t).dirty=t.dirty=r.dirty=!0,!1)},i.walkDirtyRegions=function(e,t){for(var r=i.regionBelow(t),o,s;;){for(;r.dirty;)t=r,r=i.regionBelow(r);if(!t.dirty&&(r=t,t=i.regionAbove(t),t===null||!t.dirty))return;if(t.dirty=!1,o=t.eUp,s=r.eUp,o.Dst!==s.Dst&&i.checkForLeftSplice(e,t)&&(r.fixUpperEdge?(i.deleteRegion(e,r),e.mesh.delete(s),r=i.regionBelow(t),s=r.eUp):t.fixUpperEdge&&(i.deleteRegion(e,t),e.mesh.delete(o),t=i.regionAbove(r),o=t.eUp)),o.Org!==s.Org)if(o.Dst!==s.Dst&&!t.fixUpperEdge&&!r.fixUpperEdge&&(o.Dst===e.event||s.Dst===e.event)){if(i.checkForIntersect(e,t))return}else i.checkForRightSplice(e,t);o.Org===s.Org&&o.Dst===s.Dst&&(i.addWinding(s,o),i.deleteRegion(e,t),e.mesh.delete(o),t=i.regionAbove(r))}},i.connectRightVertex=function(e,t,r){var o,s=r.Onext,n=i.regionBelow(t),a=t.eUp,l=n.eUp,c=!1;if(a.Dst!==l.Dst&&i.checkForIntersect(e,t),ae.vertEq(a.Org,e.event)&&(e.mesh.splice(s.Oprev,a),t=i.topLeftRegion(e,t),s=i.regionBelow(t).eUp,i.finishLeftRegions(e,i.regionBelow(t),n),c=!0),ae.vertEq(l.Org,e.event)&&(e.mesh.splice(r,l.Oprev),r=i.finishLeftRegions(e,n,null),c=!0),c){i.addRightEdges(e,t,r.Onext,s,s,!0);return}ae.vertLeq(l.Org,a.Org)?o=l.Oprev:o=a,o=e.mesh.connect(r.Lprev,o),i.addRightEdges(e,t,o,o.Onext,o.Onext,!1),o.Sym.activeRegion.fixUpperEdge=!0,i.walkDirtyRegions(e,t)},i.connectLeftDegenerate=function(e,t,r){var o,s,n,a,l;if(o=t.eUp,ae.vertEq(o.Org,r)){he(!1),i.spliceMergeVertices(e,o,r.anEdge);return}if(!ae.vertEq(o.Dst,r)){e.mesh.splitEdge(o.Sym),t.fixUpperEdge&&(e.mesh.delete(o.Onext),t.fixUpperEdge=!1),e.mesh.splice(r.anEdge,o),i.sweepEvent(e,r);return}he(!1),t=i.topRightRegion(t),l=i.regionBelow(t),n=l.eUp.Sym,s=a=n.Onext,l.fixUpperEdge&&(he(s!==n),i.deleteRegion(e,l),e.mesh.delete(n),n=s.Oprev),e.mesh.splice(r.anEdge,n),ae.edgeGoesLeft(s)||(s=null),i.addRightEdges(e,t,n.Onext,a,s,!0)},i.connectLeftVertex=function(e,t){var r,o,s,n,a,l,c=new Il;if(c.eUp=t.anEdge.Sym,r=e.dict.search(c).key,o=i.regionBelow(r),!!o){if(n=r.eUp,a=o.eUp,ae.edgeSign(n.Dst,t,n.Org)===0){i.connectLeftDegenerate(e,r,t);return}if(s=ae.vertLeq(a.Dst,n.Dst)?r:o,r.inside||s.fixUpperEdge){if(s===r)l=e.mesh.connect(t.anEdge.Sym,n.Lnext);else{var d=e.mesh.connect(a.Dnext,t.anEdge);l=d.Sym}s.fixUpperEdge?i.fixUpperEdge(e,s,l):i.computeWinding(e,i.addRegionBelow(e,r,l)),i.sweepEvent(e,t)}else i.addRightEdges(e,r,t.anEdge,t.anEdge,null,!0)}},i.sweepEvent=function(e,t){e.event=t,i.debugEvent(e);for(var r=t.anEdge;r.activeRegion===null;)if(r=r.Onext,r===t.anEdge){i.connectLeftVertex(e,t);return}var o=i.topLeftRegion(e,r.activeRegion);he(o!==null);var s=i.regionBelow(o),n=s.eUp,a=i.finishLeftRegions(e,s,null);a.Onext===n?i.connectRightVertex(e,o,a):i.addRightEdges(e,o,a.Onext,n,n,!0)},i.addSentinel=function(e,t,r,o){var s=new Il,n=e.mesh.makeEdge();n.Org.s=r,n.Org.t=o,n.Dst.s=t,n.Dst.t=o,e.event=n.Dst,s.eUp=n,s.windingNumber=0,s.inside=!1,s.fixUpperEdge=!1,s.sentinel=!0,s.dirty=!1,s.nodeUp=e.dict.insert(s)},i.initEdgeDict=function(e){e.dict=new jv(e,i.edgeLeq);var t=e.bmax[0]-e.bmin[0],r=e.bmax[1]-e.bmin[1],o=e.bmin[0]-t,s=e.bmax[0]+t,n=e.bmin[1]-r,a=e.bmax[1]+r;i.addSentinel(e,o,s,n),i.addSentinel(e,o,s,a)},i.doneEdgeDict=function(e){for(var t,r=0;(t=e.dict.min().key)!==null;)t.sentinel||(he(t.fixUpperEdge),he(++r==1)),he(t.windingNumber===0),i.deleteRegion(e,t)},i.removeDegenerateEdges=function(e){var t,r,o,s=e.mesh.eHead;for(t=s.next;t!==s;t=r)r=t.next,o=t.Lnext,ae.vertEq(t.Org,t.Dst)&&t.Lnext.Lnext!==t&&(i.spliceMergeVertices(e,o,t),e.mesh.delete(t),t=o,o=t.Lnext),o.Lnext===t&&(o!==t&&((o===r||o===r.Sym)&&(r=r.next),e.mesh.delete(o)),(t===r||t===r.Sym)&&(r=r.next),e.mesh.delete(t))},i.initPriorityQ=function(e){var t,r,o,s=0;for(o=e.mesh.vHead,r=o.next;r!==o;r=r.next)s++;for(s+=8,t=e.pq=new Av(s,ae.vertLeq),o=e.mesh.vHead,r=o.next;r!==o;r=r.next)r.pqHandle=t.insert(r);return r!==o?!1:(t.init(),!0)},i.donePriorityQ=function(e){e.pq=null},i.removeDegenerateFaces=function(e,t){var r,o,s;for(r=t.fHead.next;r!==t.fHead;r=o)o=r.next,s=r.anEdge,he(s.Lnext!==s),s.Lnext.Lnext===s&&(i.addWinding(s.Onext,s),e.mesh.delete(s));return!0},i.computeInterior=function(e,t){t===void 0&&(t=!0);var r,o;if(i.removeDegenerateEdges(e),!i.initPriorityQ(e))return!1;for(i.initEdgeDict(e);(r=e.pq.extractMin())!==null;){for(;o=e.pq.min(),!(o===null||!ae.vertEq(o,r));)o=e.pq.extractMin(),i.spliceMergeVertices(e,r.anEdge,o.anEdge);i.sweepEvent(e,r)}return e.event=e.dict.min().key.eUp.Org,i.debugEvent(e),i.doneEdgeDict(e),i.donePriorityQ(e),i.removeDegenerateFaces(e,e.mesh)?(t&&e.mesh.check(),!0):!1},i}(),Dv=function(){function i(){this.mesh=new iu,this.normal=[0,0,0],this.sUnit=[0,0,0],this.tUnit=[0,0,0],this.bmin=[0,0],this.bmax=[0,0],this.windingRule=We.ODD,this.dict=null,this.pq=null,this.event=null,this.vertexIndexCounter=0,this.vertices=[],this.vertexIndices=[],this.vertexCount=0,this.elements=[],this.elementCount=0}return i.prototype.dot_=function(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]},i.prototype.normalize_=function(e){var t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2];if(!t)throw"Zero-size vector!";t=Math.sqrt(t),e[0]/=t,e[1]/=t,e[2]/=t},i.prototype.longAxis_=function(e){var t=0;return Math.abs(e[1])>Math.abs(e[0])&&(t=1),Math.abs(e[2])>Math.abs(e[t])&&(t=2),t},i.prototype.computeNormal_=function(e){var t,r,o,s,n,a,l=[0,0,0],c=[0,0,0],d=[0,0,0],h=[0,0,0],p=[0,0,0],m=[null,null,null],f=[null,null,null],x=this.mesh.vHead;t=x.next;for(var g=0;g<3;++g)s=t.coords[g],c[g]=s,f[g]=t,l[g]=s,m[g]=t;for(t=x.next;t!==x;t=t.next)for(var N=0;N<3;++N)s=t.coords[N],s<c[N]&&(c[N]=s,f[N]=t),s>l[N]&&(l[N]=s,m[N]=t);var C=0;if(l[1]-c[1]>l[0]-c[0]&&(C=1),l[2]-c[2]>l[C]-c[C]&&(C=2),c[C]>=l[C]){e[0]=0,e[1]=0,e[2]=1;return}for(a=0,r=f[C],o=m[C],d[0]=r.coords[0]-o.coords[0],d[1]=r.coords[1]-o.coords[1],d[2]=r.coords[2]-o.coords[2],t=x.next;t!==x;t=t.next)h[0]=t.coords[0]-o.coords[0],h[1]=t.coords[1]-o.coords[1],h[2]=t.coords[2]-o.coords[2],p[0]=d[1]*h[2]-d[2]*h[1],p[1]=d[2]*h[0]-d[0]*h[2],p[2]=d[0]*h[1]-d[1]*h[0],n=p[0]*p[0]+p[1]*p[1]+p[2]*p[2],n>a&&(a=n,e[0]=p[0],e[1]=p[1],e[2]=p[2]);a<=0&&(e[0]=e[1]=e[2]=0,e[this.longAxis_(d)]=1)},i.prototype.checkOrientation_=function(){for(var e=this.mesh.fHead,t,r=this.mesh.vHead,o,s=0,n=e.next;n!==e;n=n.next)if(o=n.anEdge,!(o.winding<=0))do s+=(o.Org.s-o.Dst.s)*(o.Org.t+o.Dst.t),o=o.Lnext;while(o!==n.anEdge);if(s<0){for(t=r.next;t!==r;t=t.next)t.t=-t.t;this.tUnit[0]=-this.tUnit[0],this.tUnit[1]=-this.tUnit[1],this.tUnit[2]=-this.tUnit[2]}},i.prototype.projectPolygon_=function(){var e=this.mesh.vHead,t=[0,0,0],r,o,s=!1;t[0]=this.normal[0],t[1]=this.normal[1],t[2]=this.normal[2],!t[0]&&!t[1]&&!t[2]&&(this.computeNormal_(t),s=!0),r=this.sUnit,o=this.tUnit;var n=this.longAxis_(t);r[n]=0,r[(n+1)%3]=1,r[(n+2)%3]=0,o[n]=0,o[(n+1)%3]=0,o[(n+2)%3]=t[n]>0?1:-1;for(var a=e.next;a!==e;a=a.next)a.s=this.dot_(a.coords,r),a.t=this.dot_(a.coords,o);s&&this.checkOrientation_();for(var l=!0,c=e.next;c!==e;c=c.next)l?(this.bmin[0]=this.bmax[0]=c.s,this.bmin[1]=this.bmax[1]=c.t,l=!1):(c.s<this.bmin[0]&&(this.bmin[0]=c.s),c.s>this.bmax[0]&&(this.bmax[0]=c.s),c.t<this.bmin[1]&&(this.bmin[1]=c.t),c.t>this.bmax[1]&&(this.bmax[1]=c.t))},i.prototype.addWinding_=function(e,t){e.winding+=t.winding,e.Sym.winding+=t.Sym.winding},i.prototype.tessellateMonoRegion_=function(e,t){var r,o;if(r=t.anEdge,!(r.Lnext!==r&&r.Lnext.Lnext!==r))throw"Mono region invalid";for(;ae.vertLeq(r.Dst,r.Org);r=r.Lprev);for(;ae.vertLeq(r.Org,r.Dst);r=r.Lnext);o=r.Lprev;for(var s=void 0;r.Lnext!==o;)if(ae.vertLeq(r.Dst,o.Org)){for(;o.Lnext!==r&&(ae.edgeGoesLeft(o.Lnext)||ae.edgeSign(o.Org,o.Dst,o.Lnext.Dst)<=0);)s=e.connect(o.Lnext,o),o=s.Sym;o=o.Lprev}else{for(;o.Lnext!==r&&(ae.edgeGoesRight(r.Lprev)||ae.edgeSign(r.Dst,r.Org,r.Lprev.Org)>=0);)s=e.connect(r,r.Lprev),r=s.Sym;r=r.Lnext}if(o.Lnext===r)throw"Mono region invalid";for(;o.Lnext.Lnext!==r;)s=e.connect(o.Lnext,o),o=s.Sym;return!0},i.prototype.tessellateInterior_=function(e){for(var t,r=e.fHead.next;r!==e.fHead;r=t)if(t=r.next,r.inside&&!this.tessellateMonoRegion_(e,r))return!1;return!0},i.prototype.discardExterior_=function(e){for(var t,r=e.fHead.next;r!==e.fHead;r=t)t=r.next,r.inside||e.zapFace(r)},i.prototype.setWindingNumber_=function(e,t,r){for(var o,s=e.eHead.next;s!==e.eHead;s=o)o=s.next,s.Rface.inside!==s.Lface.inside?s.winding=s.Lface.inside?t:-t:r?e.delete(s):s.winding=0},i.prototype.getNeighbourFace_=function(e){return!e.Rface||!e.Rface.inside?-1:e.Rface.n},i.prototype.outputPolymesh_=function(e,t,r,o){var s,n=0,a=0,l;r>3&&e.mergeConvexFaces(r);for(var c=e.vHead.next;c!==e.vHead;c=c.next)c.n=-1;for(var d=e.fHead.next;d!==e.fHead;d=d.next)if(d.n=-1,!!d.inside){s=d.anEdge,l=0;do{var c=s.Org;c.n===-1&&(c.n=a,a++),l++,s=s.Lnext}while(s!==d.anEdge);if(l>r)throw"Face vertex greater that support polygon";d.n=n,++n}this.elementCount=n,t===at.CONNECTED_POLYGONS&&(n*=2),this.elements=[],this.elements.length=n*r,this.vertexCount=a,this.vertices=[],this.vertices.length=a*o,this.vertexIndices=[],this.vertexIndices.length=a;for(var c=e.vHead.next;c!==e.vHead;c=c.next)if(c.n!==-1){var h=c.n*o;this.vertices[h+0]=c.coords[0],this.vertices[h+1]=c.coords[1],o>2&&(this.vertices[h+2]=c.coords[2]),this.vertexIndices[c.n]=c.idx}for(var p=0,d=e.fHead.next;d!==e.fHead;d=d.next)if(!!d.inside){s=d.anEdge,l=0;do{var c=s.Org;this.elements[p++]=c.n,l++,s=s.Lnext}while(s!==d.anEdge);for(var m=l;m<r;++m)this.elements[p++]=-1;if(t===at.CONNECTED_POLYGONS){s=d.anEdge;do this.elements[p++]=this.getNeighbourFace_(s),s=s.Lnext;while(s!==d.anEdge);for(var f=l;f<r;++f)this.elements[p++]=-1}}},i.prototype.outputContours_=function(e,t){var r,o,s=0,n=0;this.vertexCount=0,this.elementCount=0;for(var a=e.fHead.next;a!==e.fHead;a=a.next)if(!!a.inside){o=r=a.anEdge;do this.vertexCount++,r=r.Lnext;while(r!==o);this.elementCount++}this.elements=[],this.elements.length=this.elementCount*2,this.vertices=[],this.vertices.length=this.vertexCount*t,this.vertexIndices=[],this.vertexIndices.length=this.vertexCount;var l=0,c=0,d=0;s=0;for(var a=e.fHead.next;a!==e.fHead;a=a.next)if(!!a.inside){n=0,o=r=a.anEdge;do this.vertices[l++]=r.Org.coords[0],this.vertices[l++]=r.Org.coords[1],t>2&&(this.vertices[l++]=r.Org.coords[2]),this.vertexIndices[c++]=this.vertexIdCallback?this.vertexIdCallback(r):r.Org.idx,n++,r=r.Lnext;while(r!==o);this.elements[d++]=s,this.elements[d++]=n,s+=n}},i.prototype.addContour=function(e,t){this.mesh===null&&(this.mesh=new iu),e<2&&(e=2),e>3&&(e=3);for(var r=null,o=0;o<t.length;o+=e)r===null?(r=this.mesh.makeEdge(),this.mesh.splice(r,r.Sym)):(this.mesh.splitEdge(r),r=r.Lnext),r.Org.coords[0]=t[o+0],r.Org.coords[1]=t[o+1],e>2?r.Org.coords[2]=t[o+2]:r.Org.coords[2]=0,r.Org.idx=this.vertexIndexCounter++,this.edgeCreateCallback&&this.edgeCreateCallback(r),r.winding=1,r.Sym.winding=-1},i.prototype.tesselate=function(e,t,r,o,s,n){if(e===void 0&&(e=We.ODD),t===void 0&&(t=at.POLYGONS),n===void 0&&(n=!0),this.vertices=[],this.elements=[],this.vertexIndices=[],this.vertexIndexCounter=0,s&&(this.normal[0]=s[0],this.normal[1]=s[1],this.normal[2]=s[2]),this.windingRule=e,o<2&&(o=2),o>3&&(o=3),!this.mesh)return!1;this.projectPolygon_(),_v.computeInterior(this,n);var a=this.mesh;return t===at.BOUNDARY_CONTOURS?this.setWindingNumber_(a,1,!0):this.tessellateInterior_(a),n&&a.check(),t===at.BOUNDARY_CONTOURS?this.outputContours_(a,o):this.outputPolymesh_(a,t,r,o),!0},i}();function wo(i){var e=i.windingRule,t=e===void 0?We.ODD:e,r=i.elementType,o=r===void 0?at.POLYGONS:r,s=i.polySize,n=s===void 0?3:s,a=i.vertexSize,l=a===void 0?2:a,c=i.normal,d=c===void 0?[0,0,1]:c,h=i.contours,p=h===void 0?[]:h,m=i.strict,f=m===void 0?!0:m,x=i.debug,g=x===void 0?!1:x;if(!p&&f)throw new Error("Contours can't be empty");if(!!p){var N=new Dv;i.edgeCreateCallback&&(N.edgeCreateCallback=i.edgeCreateCallback),i.vertexIdCallback&&(N.vertexIdCallback=i.vertexIdCallback);for(var C=0;C<p.length;C++)N.addContour(l||2,p[C]);return N.tesselate(t,o,n,l,d,f),{vertices:N.vertices,vertexIndices:N.vertexIndices,vertexCount:N.vertexCount,elements:N.elements,elementCount:N.elementCount,mesh:g?N.mesh:void 0}}}var I_=We.ODD,P_=We.NONZERO,A_=We.POSITIVE,j_=We.NEGATIVE,__=We.ABS_GEQ_TWO,D_=at.POLYGONS,B_=at.CONNECTED_POLYGONS,G_=at.BOUNDARY_CONTOURS;var qi=class extends Bv{constructor(e,t=12,r=100,o={}){super();this.type="ShapeGeometry";this.windingRule=We.ODD;this.elementType=at.POLYGONS;this.polySize=3;this.vertexSize=2;this.strict=!0;this._drawCount=0,this._shape=e,this._curveSegments=t,this._maxCount=r,this._maxDrawCount=r*3,this._triangulationOptions=Object.assign({windingRule:We.ODD,elementType:at.POLYGONS,polySize:3,vertexSize:2,strict:!0},o),this._positionAttribute=new qn(new Float32Array(r*3),3),this._normalAttribute=new qn(new Float32Array(r*3),3),this._uvAttribute=new qn(new Float32Array(r*2),2),this._indexAttribute=new qn(new Uint32Array(r*3),1),this.setAttribute("position",this._positionAttribute),this.setAttribute("normal",this._normalAttribute),this.setAttribute("uv",this._uvAttribute),this.setIndex(this._indexAttribute),this.updateFromShape()}copy(e){return this._drawCount=e.drawCount,this._maxDrawCount=e._maxDrawCount,this._maxCount=e.maxCount,super.copy(e)}get curveSegments(){return this._curveSegments}set curveSegments(e){this._curveSegments=e,this.updateFromShape()}get drawCount(){return this._drawCount}get maxDrawCount(){return this._maxDrawCount}get maxCount(){return this._maxCount}updateFromShape(){let e=this._shape.extractShapePointsToFlatArray([],this._curveSegments),t=this._shape.shapeHoles.map(l=>l.extractShapePointsToFlatArray([],this._curveSegments)),r,o=!0,s=!0,n,a;for(let l=0,c=e.length/2;l<c;l++){let d=l*2,h=e[d+0],p=e[d+1];if(n!==void 0&&h!==n&&(o=!1),a!==void 0&&p!==a&&(s=!1),n=h,a=p,!o&&!s)break}if(!o&&!s&&(r=wo({contours:[e,...t],windingRule:this._triangulationOptions.windingRule,elementType:this._triangulationOptions.elementType,polySize:this._triangulationOptions.polySize,vertexSize:this._triangulationOptions.vertexSize,strict:this._triangulationOptions.strict})),this._positionAttribute.array.fill(0),this._normalAttribute.array.fill(0),this._uvAttribute.array.fill(0),this._indexAttribute.array.fill(0),this._drawCount=0,r){let l=1/0,c=-1/0,d=1/0,h=-1/0;for(let f=0,x=r.vertexCount;f<x;f++){let g=f*2,N=r.vertices[g+0],C=r.vertices[g+1];N<l&&(l=N),N>c&&(c=N),C<d&&(d=C),C>h&&(h=C)}let p=c-l,m=h-d;for(let f=0,x=r.vertexCount;f<x;f++){let g=f*2,N=r.vertices[g+0],C=r.vertices[g+1],S=(N-l)/p,D=(C-d)/m;this._positionAttribute.setXYZ(f,N,C,0),this._normalAttribute.setXYZ(f,0,0,1),this._uvAttribute.setXY(f,S,D)}for(let f=0,x=r.elementCount;f<x;f++){let g=f*3,N=r.elements[g+0],C=r.elements[g+1],S=r.elements[g+2];this._indexAttribute.setX(g+0,N),this._indexAttribute.setX(g+1,C),this._indexAttribute.setX(g+2,S),this._drawCount+=3}}return this._positionAttribute.needsUpdate=!0,this._normalAttribute.needsUpdate=!0,this._uvAttribute.needsUpdate=!0,this._indexAttribute.needsUpdate=!0,this.setDrawRange(0,this._drawCount),this._drawCount>this._maxDrawCount}};import{BufferAttribute as Kn,BufferGeometry as Gv}from"three";var $n=class{constructor(e=256,t=!1){this.capacity=e,this.size=0,this.debug=t,this.debug&&console.log(`allocating with cap ${e}`);let r=e*$n.eSize;this.buffer=new ArrayBuffer(r);let o=Float32Array.BYTES_PER_ELEMENT,s=0;this.positions=new Float32Array(this.buffer,s*o,3*e),s+=3*e,this.normals=new Float32Array(this.buffer,s*o,3*e),s+=3*e,this.uvs=new Float32Array(this.buffer,s*o,2*e)}realloc(e,t=!1){if(e<this.size)throw Error("cannot shrink buffer");if(e<=this.capacity&&!t)return;this.debug&&console.log(`resizing from ${this.capacity} \u2192 ${e}`);let r=e*$n.eSize,o=new ArrayBuffer(r),s=Float32Array.BYTES_PER_ELEMENT,n=0,a=new Float32Array(o,n*s,3*e);n+=3*e;let l=new Float32Array(o,n*s,3*e);n+=3*e;let c=new Float32Array(o,n*s,2*e);a.set(this.positions.slice(0,this.size*3)),l.set(this.normals.slice(0,this.size*3)),c.set(this.uvs.slice(0,this.size*2)),this.buffer=o,this.positions=a,this.normals=l,this.uvs=c,this.capacity=e}get(e=1){let t=this.size+e;if(t>this.capacity){let o=this.capacity;for(;t>o;)o*=2;this.realloc(o)}let r=this.size;return this.size=t,r}reserve(e){let t=this.size+e;t>this.capacity&&this.realloc(t)}shrink(){this.debug&&console.log(`shrinking ${this.capacity} \u2192 ${this.size}`),this.realloc(this.size,!0)}},Wn=$n;Wn.eSize=(3+3+2)*Float32Array.BYTES_PER_ELEMENT;var Pl=(i,e)=>([t,r])=>(r<t&&(r+=e),(i>=t?i:i+e)<=r),Al=class extends Gv{constructor(e,t,r=0,o=12,s=3){super();this.type="ShapeGeometry";this.vertexCache={};this._shape=e,this._depth=t,r<=0?(this._bevelSize=0,this._bevelSegments=0):(this._bevelSize=Math.min(r,t/2-1e-12),this._bevelSegments=Math.floor(s));let n=this._shape.extractShapePointsToFlatArray([],o),a=this._shape.shapeHoles.map(j=>{let O=j.extractShapePointsToFlatArray([],o),u=[];for(let A=O.length-1;A>=1;A-=2){let b=O[A-1],L=O[A-0];u.push(b,L)}return u}),l=wo({windingRule:We.ODD,elementType:at.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[n]}),c=wo({windingRule:We.ODD,elementType:at.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...a]});if(!l)throw new Error("error generating geometry");let d=l.elementCount;if(c){l.elementCount+=c.elementCount;for(let j=0;j<c.elements.length;j++){let O=c.elements[j],u=j%2==0?l.vertexCount:0;l.elements.push(O+u)}for(let j=0;j<c.vertexIndices.length;j++){let O=c.vertexIndices[j],u=l.vertexCount;l.vertexIndices.push(O+u)}for(let j=0;j<c.vertices.length;j++){let O=c.vertices[j];l.vertices.push(O)}}let h=1/0,p=-1/0,m=1/0,f=-1/0;for(let j=0,O=l.vertexCount;j<O;j++){let u=j*2,A=l.vertices[u+0],b=l.vertices[u+1];A<h&&(h=A),A>p&&(p=A),b<m&&(m=b),b>f&&(f=b)}this._minX=h,this._minY=m,this._width=p-h,this._height=f-m;let x=l.vertexCount*2*(2+this._bevelSegments);this._buffer=new Wn(x);let g=[],N=[];for(let j=l.elementCount-1,O=l.elementCount;j>=0;j--){let u=j>=d,A=j*2,b=l.elements[A+0],L=l.elements[A+1],I=b+L,T={start:b,count:L,normals:[],continuous:[],concave:[]},$=b,J=I-1,te=b+1,fe=this._shape.roundedCurves.length;do{let E=$-b,y=l.vertices[J*2+0],z=l.vertices[J*2+1],_=l.vertices[$*2+0],F=l.vertices[$*2+1],K=l.vertices[te*2+0],Q=l.vertices[te*2+1],k=_-y,V=F-z,B=Math.sqrt(k*k+V*V);k/=B,V/=B;let U=_-K,se=F-Q,H=Math.sqrt(U*U+se*se);U/=H,se/=H,T.normals[E*2+0]=-se,T.normals[E*2+1]=U,T.concave[E]=k*se-V*U>0;let W=l.vertexIndices[$];if(Array.isArray(W))T.continuous[E]=!1;else{let[X,Z]=this._shape.getCurveIndexFromVertexId(W-1,!0);if(Z>0&&Z<1)T.continuous[E]=!0;else{let Y=Z===1?X+1:X-1;Y=(Y+fe)%fe;let ne=Z===1?0:1,ie=this._shape.roundedCurves[X].getTangent(Z),de=this._shape.roundedCurves[Y].getTangent(ne);T.continuous[E]=ie.dot(de)>.95}}u&&(T.normals[E*2+0]*=-1,T.normals[E*2+1]*=-1),[J,$,te]=[$,te,te+1],te>=I&&(te-=L)}while(te!==b+1);let ce=[];ce.push({bevelI:0,angle:0,size:0,boundary:{vertices:l.vertices.slice(b*2,I*2),vertexCount:L,vertexIndices:new Array(L).fill(!0).map((E,y)=>[y,y]),elements:[0,L],elementCount:1,mesh:null},reverseMap:[],insetPoints:l.vertices.slice(b*2,I*2)});for(let E=1;E<=this._bevelSegments;E++){let y=E/this._bevelSegments*Math.PI/2,z=(1-Math.cos(y))*this._bevelSize,_=[],F=[],K=[],Q=[],k=0;for(let B=0;B<L;B++){let U=B*2,se=(B-1+L)%L*2,H=l.vertices[T.start*2+U+0],W=l.vertices[T.start*2+U+1],X=-T.normals[se+0]*z,Z=-T.normals[se+1]*z,Y=-T.normals[U+0]*z,ne=-T.normals[U+1]*z;if(T.concave[B]||!T.concave[B]&&u){let ie=Math.atan2(Z,X),de=Math.atan2(ne,Y);de>ie&&(de-=Math.PI*2);let Ge=de-ie;if(T.continuous[B]||u){let ye=ie+Ge/2,$e=Math.cos(ye)*z,Oe=Math.sin(ye)*z;_[2*k+0]=H+$e*(u?-1:1),_[2*k+1]=W+Oe*(u?-1:1),Q[k]=B,k++}else{let ye=Math.max(1,Math.floor(o/4*Math.abs(Ge)/Math.PI));for(let $e=0;$e<=ye;$e++){let Oe=ie+Ge*($e/ye),pt=Math.cos(Oe)*z,Lt=Math.sin(Oe)*z;_[2*k+0]=H+pt,_[2*k+1]=W+Lt,Q[k]=B,k++}}}else _[2*k+0]=H+X,_[2*k+1]=W+Z,Q[k]=B,F[B]=k,k++,_[2*k+0]=H,_[2*k+1]=W,Q[k]=B,k++,_[2*k+0]=H+Y,_[2*k+1]=W+ne,Q[k]=B,K[B]=k,k++}let V=wo({windingRule:We.POSITIVE,elementType:at.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[_],edgeCreateCallback:B=>{let se=B.Org.idx,H=Q[se],W=Q[(se+1)%Q.length];B.idx=[H,W],B.Sym.idx=[W,H]},vertexIdCallback:B=>{let U=B.Lprev.idx;return[U?U[1]:0,B.idx[0]]}});if(!V)throw console.log("Error"),new Error(`error generating bevel geometry for ${E}'th loop`);if(!V.vertexCount)break;for(let B=0;B<V.vertexIndices.length;B++){let[U,se]=V.vertexIndices[B];if(U===se)continue;let H=se;se<U&&(H+=L);for(let W=U;W<H;W++){let X=W%L,Z=(W+1)%L;if(!T.continuous[X]||!T.continuous[Z]){V.vertexIndices[B]=[U,X],V.vertexIndices.splice(B+1,0,[Z,se]),V.vertices.splice((B+1)*2,0,V.vertices[B*2],V.vertices[B*2+1]);break}}}ce.push({bevelI:E,angle:y,size:z,boundary:V,reverseMap:Q,insetPoints:_})}let be=(E,y,z)=>{let _=0,F=E.boundary.vertexIndices.length;for(;_<F&&z(E.boundary.vertexIndices[y]);)y=(y+1)%F,_++;return _},R=g.length;for(let E=1;E<ce.length;E++){let y=ce[E-1],z=ce[E],_=y.boundary.vertexIndices.length,F=z.boundary.vertexIndices.length;if(!_||!F)break;let K=T.concave.length,Q=0,k=Pl(Q,L);for(;!y.boundary.vertexIndices.filter(k).length||!z.boundary.vertexIndices.filter(k).length;)Q++,k=Pl(Q,L);let V=y.boundary.vertexIndices.findIndex(k),B=z.boundary.vertexIndices.findIndex(k);do V=(V+1)%_;while(k(y.boundary.vertexIndices[V]));do B=(B+1)%F;while(k(z.boundary.vertexIndices[B]));Q=(Q+1)%L;let U=Q,se=this.buildBevelVert(T,y,(V-1+_)%_),H=this.buildBevelVert(T,z,(B-1+F)%F),W=se,X=H,Z,Y,ne=!1;do{k=Pl(Q,L);let ie=be(y,V,k),de=be(z,B,k),Ge=ne;if(ne=!1,ie&&!de){for(let ye=0;ye<ie;ye++)Z=this.buildBevelVert(T,y,(V+ye)%_,ye/(ie-1)),g.push(W.topN,Z.topP,X.topN),g.push(Z.bottomP,W.bottomN,X.bottomN),W=Z;ne=!0}else if(!ie&&de)for(let ye=0;ye<de;ye++)Y=this.buildBevelVert(T,z,(B+ye)%F,ye/(de-1)),g.push(X.topN,W.topP,Y.topP),g.push(W.bottomP,X.bottomN,Y.bottomP),X=Y;else if(ie&&de)if(Z=this.buildBevelVert(T,y,V,0),Y=this.buildBevelVert(T,z,B,0),Ge?(g.push(W.topN,Y.topP,X.topN),g.push(W.topN,Z.topP,Y.topP),g.push(Y.bottomP,W.bottomN,X.bottomN),g.push(Z.bottomP,W.bottomN,Y.bottomP)):(g.push(W.topN,Z.topP,X.topN),g.push(X.topN,Z.topP,Y.topP),g.push(Z.bottomP,W.bottomN,X.bottomN),g.push(Z.bottomP,X.bottomN,Y.bottomP)),W=Z,X=Y,ie===de)for(let ye=1;ye<ie;ye++)Z=this.buildBevelVert(T,y,(V+ye)%_,ye/(ie-1)),Y=this.buildBevelVert(T,z,(B+ye)%F,ye/(de-1)),g.push(W.topN,Z.topP,X.topN),g.push(X.topN,Z.topP,Y.topP),g.push(Z.bottomP,W.bottomN,X.bottomN),g.push(Z.bottomP,X.bottomN,Y.bottomP),W=Z,X=Y;else if(ie>de){let ye=ie/de,$e=0;for(let Oe=1;Oe<ie;Oe++)Z=this.buildBevelVert(T,y,(V+Oe)%_,Oe/(ie-1)),g.push(W.topN,Z.topP,X.topN),g.push(Z.bottomP,W.bottomN,X.bottomN),W=Z,Oe>($e+1)*ye&&($e++,Y=this.buildBevelVert(T,z,(B+$e)%F,$e/(de-1)),g.push(X.topN,Z.topP,Y.topP),g.push(Z.bottomP,X.bottomN,Y.bottomP),X=Y)}else{let ye=de/ie,$e=0;for(let Oe=1;Oe<de;Oe++)Y=this.buildBevelVert(T,z,(B+Oe)%F,Oe/(de-1)),g.push(X.topN,Z.topP,Y.topP),g.push(Z.bottomP,X.bottomN,Y.bottomP),X=Y,Oe>($e+1)*ye&&($e++,Z=this.buildBevelVert(T,y,(V+$e)%_,$e/(ie-1)),g.push(W.topN,Z.topP,X.topN),g.push(Z.bottomP,W.bottomN,X.bottomN),W=Z)}V=(V+ie)%_,B=(B+de)%F,Q=(Q+1)%K}while(Q!==U)}{let E=ce[0];for(let y=0,z=E.boundary.vertexCount;y<z;y++){let _=this.buildBevelVert(T,E,y),F=this.buildBevelVert(T,E,(y+1)%z);g.push(F.topP,_.topN,_.bottomN),g.push(F.topP,_.bottomN,F.bottomP)}}if(u){let E=[];for(let y=g.length-1;y>=R+2;y-=3){let z=g[y-2],_=g[y-1],F=g[y-0];E.push(F,_,z)}g.splice(R,g.length-R,...E)}if(u){let E=[];for(let y=ce[ce.length-1].boundary.vertices.length-1;y>=1;y-=2){let z=ce[ce.length-1].boundary.vertices[y-1],_=ce[ce.length-1].boundary.vertices[y-0];E.push(z,_)}N.push(E)}if(!u){let E=ce[ce.length-1],y=wo({windingRule:ce.length>1?We.POSITIVE:We.ODD,elementType:at.POLYGONS,vertexSize:2,strict:!0,contours:[E.insetPoints,...N]});if(!y)throw new Error("Error generating geometry for surface");for(let z=0;z<y.elementCount*3;z+=3){let _=this.buildSurfaceVert(y,y.elements[z+0]),F=this.buildSurfaceVert(y,y.elements[z+1]),K=this.buildSurfaceVert(y,y.elements[z+2]);g.push(_.top,F.top,K.top),g.push(K.bottom,F.bottom,_.bottom)}}this.vertexCache={}}this._buffer.shrink();let C=new Kn(Uint32Array.from(g),1),S=new Kn(this._buffer.positions,3),D=new Kn(this._buffer.normals,3),v=new Kn(this._buffer.uvs,2);S.needsUpdate=!0,D.needsUpdate=!0,v.needsUpdate=!0,C.needsUpdate=!0,this.setAttribute("position",S),this.setAttribute("normal",D),this.setAttribute("uv",v),this.setIndex(C)}buildSurfaceVert(e,t){let r=t.toString();if(r in this.vertexCache)return this.vertexCache[r];let o=e.vertices[t*2+0],s=e.vertices[t*2+1],n=(o-this._minX)/this._width,a=(s-this._minY)/this._height,l=this._buffer.get(2),c=l*3,d=l*2,h={top:l+0,bottom:l+1};return this._buffer.positions[c+0]=o,this._buffer.positions[c+1]=s,this._buffer.positions[c+2]=this._depth,this._buffer.normals[c+0]=0,this._buffer.normals[c+1]=0,this._buffer.normals[c+2]=1,this._buffer.uvs[d+0]=n,this._buffer.uvs[d+1]=a,this._buffer.positions[c+3]=o,this._buffer.positions[c+4]=s,this._buffer.positions[c+5]=0,this._buffer.normals[c+3]=0,this._buffer.normals[c+4]=0,this._buffer.normals[c+5]=-1,this._buffer.uvs[d+2]=n,this._buffer.uvs[d+3]=a,this.vertexCache[r]=h,h}buildBevelVert(e,t,r,o=1){let s=`${t.bevelI}:${r}`;if(s in this.vertexCache)return this.vertexCache[s];let[n,a]=t.boundary.vertexIndices[r],l,c,d,h;n!==a?(c=n,l=a,h=!1,d=e.continuous[c]&&e.continuous[l]):(l=n,c=(l-1+e.count)%e.count,h=e.concave[l]&&t.bevelI>0,d=e.continuous[l]||h);let p=Math.cos(t.angle),m=Math.sin(t.angle),f=r*2,x=l*2,g=c*2,N=t.boundary.vertices[f+0],C=t.boundary.vertices[f+1],S=(1-m)*this._bevelSize,D=(N-this._minX)/this._width,v=(C-this._minY)/this._height,j=e.normals[x+0],O=e.normals[x+1],u=e.normals[g+0],A=e.normals[g+1];if(h){let $=u-j,J=A-O;j=j+$*(1-o),O=O+J*(1-o);let te=Math.sqrt(j*j+O*O);j/=te,O/=te}let b=this._buffer.get(d?2:4),L=b*3,I=b*2,T={i:r,fi:l,topP:b+0,topN:b+0,bottomP:b+1,bottomN:b+1};return this._buffer.positions[L+0]=N,this._buffer.positions[L+1]=C,this._buffer.positions[L+2]=this._depth-S,this._buffer.normals[L+0]=j*p,this._buffer.normals[L+1]=O*p,this._buffer.normals[L+2]=m,this._buffer.uvs[I+0]=D,this._buffer.uvs[I+1]=v,this._buffer.positions[L+3]=N,this._buffer.positions[L+4]=C,this._buffer.positions[L+5]=S,this._buffer.normals[L+3]=j*p,this._buffer.normals[L+4]=O*p,this._buffer.normals[L+5]=-m,this._buffer.uvs[I+2]=v,this._buffer.uvs[I+3]=D,d||(b+=2,L+=6,I+=4,T.topP=b+0,T.bottomP=b+1,this._buffer.positions[L+0]=N,this._buffer.positions[L+1]=C,this._buffer.positions[L+2]=this._depth-S,this._buffer.normals[L+0]=u*p,this._buffer.normals[L+1]=A*p,this._buffer.normals[L+2]=m,this._buffer.uvs[I+0]=D,this._buffer.uvs[I+1]=v,this._buffer.positions[L+3]=N,this._buffer.positions[L+4]=C,this._buffer.positions[L+5]=S,this._buffer.normals[L+3]=u*p,this._buffer.normals[L+4]=A*p,this._buffer.normals[L+5]=-m,this._buffer.uvs[I+2]=v,this._buffer.uvs[I+3]=D),this.vertexCache[s]=T,T}};var mt=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,e){var c,d,h,p,m,f,x;let t=Object.assign({},(c=e==null?void 0:e.parameters)!=null?c:{width:100,subdivisions:40,roundness:0,extrudeDepth:0,surfaceMaxCount:100,extrudeBevelSize:0,extrudeBevelSegments:3},i.parameters),r=Math.abs(t.width),o=Math.abs((d=t.height)!=null?d:t.width),s=Math.abs(t.depth!==void 0&&t.depth===0&&t.extrudeDepth>0?t.extrudeDepth:(h=t.depth)!=null?h:0),n=(p=i.shape)!=null?p:e==null?void 0:e.shape,a=(m=n==null?void 0:n.roundness)!=null?m:t.roundness;n!==void 0&&(n instanceof Pe?(n.width!==r||n.height!==o)&&n.applySize(r,o):n=new Pe(r,o).fromJSON(n),((f=i.parameters)==null?void 0:f.roundness)!==void 0&&((x=i.parameters)==null?void 0:x.roundness)>0&&n.update(!1));let l=n!=null?n:new Pe(r,o);return{parameters:Object.assign(t,{width:r,height:o,depth:s,extrudeDepth:s,roundness:a}),shape:l}}static build(i){let{extrudeDepth:e,extrudeBevelSize:t,extrudeBevelSegments:r,subdivisions:o,roundness:s,surfaceMaxCount:n}=i.parameters;i.shape.roundness=s;let a;return e<=0?a=new qi(i.shape,o,n):a=new Al(i.shape,e,t,o,r),Object.assign(a,{userData:q(P({},i),{type:"VectorGeometry"})})}};import{MathUtils as lu,Vector2 as cu}from"three";var du=Math.PI*2,hu=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,e){var o,s,n;let t=Object.assign({},(o=e==null?void 0:e.parameters)!=null?o:{width:100,depth:0,spikes:64,angle:360,innerRadius:0,extrudeDepth:0,extrudeBevelSize:0,extrudeBevelSegments:1,surfaceMaxCount:1e3},i.parameters);return{shape:i.shape&&i.shape instanceof Pe?i.shape:new Pe,parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs((s=t.height)!=null?s:t.width),depth:Math.abs(t.depth!==void 0&&t.depth===0&&t.extrudeDepth>0?t.extrudeDepth:(n=t.depth)!=null?n:0)})}}static build(i){let{width:e,height:t,spikes:r,angle:o,innerRadius:s,depth:n,extrudeBevelSize:a,extrudeBevelSegments:l,surfaceMaxCount:c}=i.parameters,d=i.shape,h=e*.5,p=t*.5,m=Ev(d,h,p,o*Math.PI/180,r,s);d.isClosed=!0,d.update();let f=mt.create({shape:d,parameters:{subdivisions:m,surfaceMaxCount:c,depth:n,extrudeBevelSize:a,extrudeBevelSegments:l}});return Object.assign(f,{userData:q(P({},i),{type:"EllipseGeometry"})})}};function Ev(i,e,t,r,o,s){if(r>=du)return o>30||o%4==0?(Fv(i,e,t,s),Math.round(o/4)):pu(i,r,o,e,t,s);let n={x:0,y:t},a=r+Math.PI*.5,l={x:Math.cos(a)*e,y:Math.sin(a)*t},c=ou({px:n.x,py:n.y,cx:l.x,cy:l.y,rx:e,ry:t,largeArcFlag:r>Math.PI,sweepFlag:!0});return o>30||o%c.length==0?zv(i,n.x,n.y,c,o,e,t,s):pu(i,r,o,e,t,s)}function zv(i,e,t,r,o,s,n,a){let l=Math.round(o/r.length);i.addPoint(di(e,t));for(let c=0,d=r.length;c<d;c++){let h=r[c],p=i.points[c],m=di(h.x,h.y);p.controls[1].position.set(h.x1,h.y1),m.controls[0].position.set(h.x2,h.y2),i.addPoint(m)}return a>0?uu(i,s,n,a):i.addPoint(di(0,0)),l}function pu(i,e,t,r,o,s){let n=-e/t;for(let a=0;a<=t;a++){let l=n*a,c=Math.sin(l)*r,d=Math.cos(l)*o;i.addPoint(di(c,d))}return e<du?s>0?uu(i,r,o,s):i.addPoint(di(0,0)):(i.removePoint(i.points[i.points.length-1]),s>0&&fu(i,r,o,s)),1}function Fv(i,e,t,r=0,o=0,s=0){let n=.5522847498,a=e*n,l=t*n;i.addPoint(Xn(o-e,s,o-e,s-l,o-e,s+l)),i.addPoint(Xn(o,s+t,o-a,s+t,o+a,s+t)),i.addPoint(Xn(o+e,s,o+e,s+l,o+e,s-l)),i.addPoint(Xn(o,s-t,o+a,s-t,o-a,s-t)),r>0&&fu(i,e,t,r)}function di(i,e){return new vr(lu.generateUUID(),new cu(i,e))}function Xn(i,e,t,r,o,s){let n=di(i,e);return n.controls[0].position.set(t,r),n.controls[1].position.set(o,s),n}function uu(i,e,t,r){mu(i,e,t,r).forEach(s=>i.addPoint(s))}function fu(i,e,t,r){let o=mu(i,e,t,r),s=new Pe;o.forEach(n=>s.addPoint(n)),s.isClosed=!0,i.shapeHoles.push(s)}function mu(i,e,t,r){let o=r*e/100,s=o*(Math.abs(t)/Math.abs(e)),n=new cu(o/e,s/t),a=i.points.map(l=>{let c=l.clone();return c.uuid=lu.generateUUID(),c}).reverse();return a.forEach(l=>{l.position.multiply(n);let c=l.controls[0].position.clone().multiply(n),d=l.controls[1].position.clone().multiply(n);l.controls[0].position.copy(d),l.controls[1].position.copy(c)}),a}import{BufferGeometry as Rv,Float32BufferAttribute as jl,Vector3 as gu}from"three";var yu=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,e){var a,l,c;let t=Object.assign({},(a=e==null?void 0:e.parameters)!=null?a:{width:100,revolutions:2,segments:40,pathRadius:10,pathType:0,pathSegments:30,cornerRadius:30,cornerSegments:4},i.parameters),r=Math.abs(t.width),o=Math.abs((l=t.height)!=null?l:r),s=Math.abs((c=t.depth)!=null?c:r),n=Math.abs(Math.min(r,s))/2;return{parameters:Object.assign(t,{width:r,height:o,depth:s,radius:n,segments:Math.round(t.segments),pathSegments:Math.round(t.pathSegments),cornerSegments:Math.round(t.cornerSegments)})}}static build(i){let{width:e,height:t,depth:r,radius:o,revolutions:s,segments:n,pathRadius:a,pathType:l,pathSegments:c,cornerRadius:d,cornerSegments:h}=i.parameters,p=new Zn(!1,e,t,r,o,s,n,a,l,c,d,h);return Object.assign(p,{userData:q(P({},i),{type:"HelixGeometry"})})}},Zn=class extends Rv{constructor(e,t,r,o,s,n,a,l,c,d,h,p){super();let m=e&&n===1;m&&(p=0),h>100&&(h=100);let f=()=>new gu,x=new gu,g=f(),N=f(),C=f(),S,D,v,j,O,u,A,b,L=f(),I=f(),T=f(),$=f(),J=f(),te=f(),fe=f(),ce=f(),be=r-2*l+.001,R=be/n,E=Math.ceil(a*n),y=E+1,z=be/E,_=-be/2,F=d+1,K=2*Math.PI/d,Q=Math.PI/2/p,k=.01,V=Math.min((1-h/100)*l,l-k),B=l-V,U=0,se=2,H=p*se+se,W=F*H/se,X=W+F*y,Z=F*(y+H),[Y,ne,ie]=[3,3,2].map(He=>Array(Z*He).fill(0)),de=[],Ge=s-l;function ye(He,vt){let Ft=Math.PI/2;u=vt*z,b=2*Math.PI*(u%R)/R+Ft,u+=_,A=Math.sin(b)*Ge,O=Math.cos(b)*Ge,e?He.set(O,A,u):He.set(O,u,A)}ye(x,-1e-10),ye(g,0),L.copy(x),ye(x,1);let $e=x.distanceTo(g),Oe=B+V,pt=$e*E+2*Oe,Lt=V,Mr=pt-Oe;for(let He=0;He<=E;He++){ye(N,He),ce.subVectors(N,L).normalize(),L.copy(N),te.copy(N).setComponent(+e+1,0).normalize(),fe.crossVectors(ce,te).normalize();let vt=He===0,Ft=He===E,Ts=vt?3*Math.PI/2:Q,Ms=vt?Lt:Mr,Is=vt?F:X,Ps=vt?0:Z-F,As=ce.clone().multiplyScalar(vt?-B:B).add(N),js=ce.clone().multiplyScalar(vt?-1:1).normalize();for(let Wt=0;Wt<F;Wt++){let Oi=Wt*K;if(I.addVectors(x.copy(te).multiplyScalar(l*Math.cos(Oi)),g.copy(fe).multiplyScalar(l*Math.sin(Oi))),T.copy(I).normalize(),vt||Ft){m||(U=Ps+Wt,[0,1,2].forEach(ut=>{Y[U*3+ut]=As.getComponent(ut),ne[U*3+ut]=js.getComponent(ut)}),ie[U*2]=+Ft,ie[U*2+1]=Wt/d),g.copy(T).multiplyScalar(V),C.addVectors(N,g);for(let ut=0;ut<p;ut++){let _o=ut*Q+Ts;$.addVectors(x.copy(ce).multiplyScalar(B*Math.sin(_o)),g.copy(T).multiplyScalar(B*Math.cos(_o))),J.copy($).normalize(),g.addVectors(C,$),$.normalize(),U=Is+ut*F+Wt,[0,1,2].forEach(mo=>{Y[U*3+mo]=g.getComponent(mo),ne[U*3+mo]=J.getComponent(mo)});let _s=+vt+Math.sin(_o);ie[U*2]=(Ms+B*_s)/pt,ie[U*2+1]=Wt/d}}g.addVectors(N,I),U=W+He*F+Wt,[0,1,2].forEach(ut=>{Y[U*3+ut]=g.getComponent(ut),ne[U*3+ut]=T.getComponent(ut)}),ie[U*2]=(Oe+He*$e)/pt,ie[U*2+1]=Wt/d}}let bt=y+2*p+se,Ir=1,[uo,fo]=m?[Ir,Ir+y-1]:[0,bt-1];for(let He=uo;He<=fo-1;He++){let vt=m&&He===fo-1;for(let Ft=0;Ft<F-1;Ft++)S=He*F+Ft,D=S+1,v=(vt?Ft:S)+F,j=(vt?Ft+1:D)+F,He===0?de.push(D,j,v):He===bt-2?de.push(S,D,v):de.push(S,D,v,D,j,v)}this.setIndex(de),this.setAttribute("position",new jl(Y,3)),this.setAttribute("normal",new jl(ne,3)),this.setAttribute("uv",new jl(ie,2))}};import{IcosahedronBufferGeometry as Vv}from"three";var xu=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,e){var r,o,s;let t=Object.assign({},(r=e==null?void 0:e.parameters)!=null?r:{width:100,detail:0,corner:0,cornerSides:4},i.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs((o=t.height)!=null?o:t.width),depth:Math.abs((s=t.depth)!=null?s:t.width)})}}static build(i){let{width:e,height:t,depth:r,detail:o,corner:s,cornerSides:n}=i.parameters,a=o===0&&s!==0?new Qn(e*.5,s,n):new Vv(e*.5,o);return a.scale(1,t/e,r/e),Object.assign(a,{userData:q(P({},i),{type:"IcosahedronGeometry"})})}},Qn=class extends No{constructor(e=1,t=.2,r=4){let o=(1+Math.sqrt(5))/2,s=[-1,o,0,1,o,0,-1,-o,0,1,-o,0,0,-1,o,0,1,o,0,-1,-o,0,1,-o,o,0,-1,o,0,1,-o,0,-1,-o,0,1],n=[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(s,n,a,e,t,r);this.type=a}static fromJSON(e){return new Qn(e.radius,e.corner,e.cornerSides)}};import{LatheBufferGeometry as kv,Shape as Uv}from"three";var bu=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,e){var r,o,s,n,a;((o=(r=i.parameters)==null?void 0:r.points)!=null?o:[]).forEach(l=>{Array.isArray(l)&&(l.x=l[0],l.y=l[1])});let t=Object.assign({},(s=e==null?void 0:e.parameters)!=null?s:{width:100,segments:64,verticalSegments:64,points:[{x:0,y:-50,id:0},{x:50,y:-50,id:1},{x:50,y:50,id:2},{x:0,y:50,id:3}]},i.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs((n=t.height)!=null?n:t.width),depth:Math.abs((a=t.depth)!=null?a:t.width)})}}static build(i){let{points:e,segments:t,verticalSegments:r}=i.parameters,o=new Uv;o.moveTo(e[0].x,e[0].y),o.bezierCurveTo(e[1].x,e[1].y,e[2].x,e[2].y,e[3].x,e[3].y);let s=new kv(o.extractPoints(r).shape,t);return s.rotateZ(Math.PI),Object.assign(s,{userData:q(P({},i),{type:"LatheGeometry"})})}};import{BufferGeometry as Su,BufferGeometryLoader as Xv,Vector3 as Zv,BoxBufferGeometry as Nu}from"three";import{BufferGeometry as Jv,Vector2 as _l,Vector3 as vu}from"three";import{Geometry as Hv,Face3 as qv}from"three/examples/jsm/deprecated/Geometry.js";var Wv=["a","b","c"];function $v(i,e){switch(e){case"c":return i.c;case"b":return i.b;case"a":default:return i.a}}function Dl(i,e,t){let r=Math.min(i,e),o=Math.max(i,e),s=r+"_"+o;return t.get(s)}function Bl(i,e,t,r,o,s){let n=Math.min(i,e),a=Math.max(i,e),l=n+"_"+a,c;if(r.has(l))c=r.get(l);else{let d=t[n],h=t[a];c={a:d,b:h,newEdge:null,faces:[]},r.set(l,c)}c.faces.push(o),s[i].edges.push(c),s[e].edges.push(c)}function Kv(i,e,t,r){let o,s,n;for(o=0,s=i.length;o<s;o++)t[o]={edges:[]};for(o=0,s=e.length;o<s;o++)n=e[o],Bl(n.a,n.b,i,r,n,t),Bl(n.b,n.c,i,r,n,t),Bl(n.c,n.a,i,r,n,t)}function Yn(i,e,t,r,o){i.push(new qv(e,t,r,void 0,void 0,o))}function hi(i,e){return Math.abs(e-i)/2+Math.min(i,e)}function ea(i,e,t,r){i.push([e.clone(),t.clone(),r.clone()])}var Gl=class{constructor(e=1){this.subdivisions=e}modify(e){e instanceof Jv?e=new Hv().fromBufferGeometry(e):e=e.clone(),e.mergeVertices();let t=this.subdivisions;for(;t-- >0;)this._smooth(e);return e.computeFaceNormals(),e.computeVertexNormals(),e}_smooth(e){let t=new vu,r,o,s,n,a,l=e.vertices,c=e.faces,d=e.faceVertexUvs[0],h=d!==void 0&&d.length>0,p=[],m=new Map;Kv(l,c,p,m);let f=[],x,g,N,C,S,D,v;for(let k of Array.from(m.keys())){for(g=m.get(k),N=new vu,S=3/8,D=1/8,v=g.faces.length,v!=2&&(S=.5,D=0,v!=1),N.addVectors(g.a,g.b).multiplyScalar(S),t.set(0,0,0),n=0;n<v;n++){for(C=g.faces[n],a=0;a<3&&(x=l[$v(C,Wv[a])],!(x!==g.a&&x!==g.b));a++);x&&t.add(x)}t.multiplyScalar(D),N.add(t),g.newEdge=f.length,f.push(N)}let j,O,u,A,b,L,I,T=[];for(o=0,s=l.length;o<s;o++){for(L=l[o],b=p[o].edges,r=b.length,r==3?j=3/16:r>3&&(j=3/(8*r)),O=1-r*Number(j),u=j,r<=2&&(r==2?(O=3/4,u=1/8):r==1||r==0),I=L.clone().multiplyScalar(O),t.set(0,0,0),n=0;n<r;n++)A=b[n],x=A.a!==L?A.a:A.b,t.add(x);t.multiplyScalar(Number(u)),I.add(t),T.push(I)}let $=T.concat(f),J=T.length,te,fe,ce,be=[],R=[],E,y,z,_,F=new _l,K=new _l,Q=new _l;for(o=0,s=c.length;o<s;o++)C=c[o],te=Number(Dl(C.a,C.b,m).newEdge)+J,fe=Number(Dl(C.b,C.c,m).newEdge)+J,ce=Number(Dl(C.c,C.a,m).newEdge)+J,Yn(be,te,fe,ce,C.materialIndex),Yn(be,C.a,te,ce,C.materialIndex),Yn(be,C.b,fe,te,C.materialIndex),Yn(be,C.c,ce,fe,C.materialIndex),h&&(E=d[o],y=E[0],z=E[1],_=E[2],F.set(hi(y.x,z.x),hi(y.y,z.y)),K.set(hi(z.x,_.x),hi(z.y,_.y)),Q.set(hi(y.x,_.x),hi(y.y,_.y)),ea(R,F,K,Q),ea(R,y,F,Q),ea(R,z,K,F),ea(R,_,Q,K));e.vertices=$,e.faces=be,h&&(e.faceVertexUvs[0]=R)}};var lt=new Zv,ta=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,e){var s,n;let t=(n=(s=i.geometry)!=null?s:e==null?void 0:e.geometry)!=null?n:new Su().copy(new Nu(100,100,100)),r;e===void 0?(t.computeBoundingBox(),t.boundingBox.getSize(lt),r={width:lt.x,height:lt.y,depth:lt.z,subdivisions:0}):r=e.parameters;let o=P(P({},r),i.parameters);return{parameters:{width:Math.abs(o.width),height:Math.abs(o.height),depth:Math.abs(o.depth),subdivisions:Math.abs(o.subdivisions)},geometry:t}}static build(i){var l;let{width:e,height:t,depth:r,subdivisions:o}=i.parameters,s=(l=i.geometry)!=null?l:new Su().copy(new Nu(100,100,100)),n=s.userData.parameters;n===void 0?(s.computeBoundingBox(),s.boundingBox.getSize(lt)):lt.set(n.width,n.height,n.depth),(e!==lt.x||t!==lt.y||r!==lt.z)&&s.scale(lt.x===0?1:e/lt.x,lt.y===0?1:t/lt.y,lt.z===0?1:r/lt.z);let a=s.originalGeometry;return o>0?(a===void 0||(n==null?void 0:n.subdivisions)!==o)&&(a===void 0&&(a=s),s=new Gl(o).modify(a).toBufferGeometry()):(a!==void 0&&(s=a),a=void 0,s.getAttribute("normal")===void 0&&s.computeVertexNormals()),a!==void 0&&Object.assign(s,{originalGeometry:a}),delete i.geometry,Object.assign(s,{userData:q(P({},i),{type:"NonParametricGeometry"})})}static loadFromUrl(i,e,t){new Xv(t).load(i,o=>{let s=this.normalizeInputs({geometry:o});o.boundingBox.getSize(lt);let n=100/lt.x;Object.assign(s.parameters,{width:100,height:lt.y*n,depth:lt.z*n}),e(this.build(s))})}};var wu=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,e){var o,s,n,a;let t=Object.assign({},(o=e==null?void 0:e.parameters)!=null?o:{width:100,depth:0,spikes:5,cornerRadius:0,extrudeDepth:0,extrudeBevelSize:0,extrudeBevelSegments:3},i.parameters);return{shape:i.shape&&i.shape instanceof Pe?i.shape:new Pe,parameters:Object.assign(t,{surfaceMaxCount:((s=t.surfaceMaxCount)!=null?s:t.cornerRadius>0)?1e3:100,width:Math.abs(t.width),height:Math.abs((n=t.height)!=null?n:t.width),depth:Math.abs(t.depth!==void 0&&t.depth===0&&t.extrudeDepth>0?t.extrudeDepth:(a=t.depth)!=null?a:0)})}}static build(i){let{width:e,height:t,spikes:r,cornerRadius:o,depth:s,extrudeBevelSize:n,extrudeBevelSegments:a,surfaceMaxCount:l}=i.parameters,c=i.shape,d=e*.5,h=t*.5,p=0,m=0,f=2*Math.PI/r;for(let g=0;g<r;g++){let N=f*g,C=p+Math.sin(N)*d,S=m+Math.cos(N)*h;c.addPoint(c.createPoint(C,S))}c.isClosed=!0;for(let g=0,N=c.points.length;g<N;g++)c.points[g].roundness=o;c.roundness=o,c.update();let x=mt.create({shape:c,parameters:{surfaceMaxCount:l,roundness:o,depth:s,extrudeBevelSize:n,extrudeBevelSegments:a}});return Object.assign(x,{userData:q(P({},i),{type:"PolygonGeometry"})})}};import{BufferGeometry as Qv,Float32BufferAttribute as El,Vector2 as Sr,Vector3 as ht}from"three";var Cu=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,e){var r,o,s;let t=Object.assign({},(r=e==null?void 0:e.parameters)!=null?r:{width:100,radialSegments:4,heightSegments:1,cornerRadius:0,cornerSegments:8,openEnded:!1},i.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs((o=t.height)!=null?o:t.width),depth:Math.abs((s=t.depth)!=null?s:t.width)})}}static build(i){let{width:e,height:t,depth:r,radialSegments:o,heightSegments:s,openEnded:n,cornerRadius:a,cornerSegments:l}=i.parameters,c=new Lu(e*.5,t,o,s,n,a,l);return c.scale(1,1,r/e),Object.assign(c,{userData:q(P({},i),{type:"PyramidGeometry"})})}};function Wi(i,e,t){t.x=i.x*e.x,t.y=i.y,t.z=i.x*e.y}function zl(i,e,t,r,o,s){let n=e.clone().sub(i),a=t.clone().sub(i),l=n.angleTo(a);if(n.normalize(),a.normalize(),r===o){let c=n.add(a).normalize();s.copy(i).addScaledVector(c,r/Math.sin(l/2))}else{let c=n.angleTo(a);s.copy(i),s.addScaledVector(n,o/Math.sin(c)),s.addScaledVector(a,r/Math.sin(c))}}function Yv(i,e,t){let r=i.clone().sub(e),o=t.clone().sub(e);return r.projectOnVector(o),r.add(e)}var Lu=class extends Qv{constructor(e=.5,t=1,r=4,o=1,s=!1,n=0,a=4){super();r=Math.floor(Math.max(3,r)),o=Math.floor(o),a=Math.floor(a);let l=[],c=[],d=[],h=[],p=0,m=t/2,f=Math.PI/r,x=e*Math.cos(Math.PI/r),g=2*Math.PI/r,N=(r-2)*Math.PI/r,C=Math.PI-N,S=new ht(0,-m,0),D=new ht(0,m,0),v=new Sr(e,-m),j=new Sr(x,-m),O=new Sr(0,D.y).sub(j),u=new Sr(0,D.y).sub(v),A=new Sr(O.y,-O.x).normalize(),b=new Sr(u.y,-u.x).normalize(),I=e*Math.cos(Math.PI/r)*Math.tan((Math.PI-O.angle())/2)-1e-8;n=Math.min(n,I);let T;{let R=new ht(A.x,A.y,0),E=new ht(Math.cos(g)*R.x,R.y,Math.sin(g)*R.x);T=R.angleTo(E)}let $=n/Math.tan((Math.PI-O.angle())/2),J=n/Math.tan((Math.PI-T)/2),te=new ht;if(!s){c.push(S.x,S.y,S.z),d.push(0,-1,0),h.push(0,0);let R=p++,E=[],y=v.clone(),z=$/Math.cos(Math.PI/r);y.x-=z;for(let _=0;_<r;_++){let F=_/r*Math.PI*2+f,K=new Sr(Math.sin(F),Math.cos(F));Wi(y,K,te),c.push(te.x,te.y,te.z),d.push(0,-1,0),h.push(0,0),E.push(p++)}for(let _=0;_<E.length;_++)l.push(E[_],R,E[(_+1)%E.length])}let fe=[];{let R=new ht,E=new ht,y=new ht,z=new ht,_=new ht,F=new ht;for(let K=0;K<r;K++){let Q=K/r*Math.PI*2+f,k=(K+.5)/r*Math.PI*2+f,V=(K+1)/r*Math.PI*2+f,B=new Sr(Math.sin(Q),Math.cos(Q)),U=new Sr(Math.sin(k),Math.cos(k)),se=new Sr(Math.sin(V),Math.cos(V));Wi(v,B,E),Wi(v,se,y),Wi(A,U,R),zl(D,E,y,J,J,z),c.push(z.x,z.y,z.z),zl(E,D,y,J,$,_),c.push(_.x,_.y,_.z),zl(y,E,D,$,J,F),c.push(F.x,F.y,F.z),d.push(R.x,R.y,R.z),d.push(R.x,R.y,R.z),d.push(R.x,R.y,R.z),h.push(0,0),h.push(0,0),h.push(0,0);let H=p++,W=p++,X=p++;if(l.push(H,W,X),n>0){{let ne=E.clone().add(y).multiplyScalar(.5),ie=D.clone().sub(ne).normalize(),Ge=S.clone().sub(ne).normalize().add(ie).normalize().multiplyScalar(-1),ye=F.clone().sub(_);ce(ne,ye,Ge,O.angle())}let Z,Y;{let ne=new ht;Wi(b,se,ne);let ie=F.clone().add(z).multiplyScalar(.5);ie=Yv(ie,y,D);let de=F.clone().sub(z);[Z,Y]=ce(ie,de,ne,T,z.y)}{let ne=Z,ie=ne.clone().setY(0).normalize(),de=new ht(0,-1,0),Ge=ie.clone().cross(de);be(ne,ie,de,Ge)}fe.concat(Y);{let ne=O.angle(),ie=Math.PI-ne,de=D.clone();de.y-=n/Math.sin(ne-Math.PI/2);let Ge=new ht,ye=[];for(let Oe=0;Oe<a;Oe++){let pt=[],Lt=Math.PI/2-ie*Oe/a,Mr=Math.cos(Lt),bt=Math.sin(Lt),Ir=k;for(let uo=0;uo<=Oe;uo++){let fo=Math.cos(Ir),He=Math.sin(Ir);R.x=Mr*He,R.y=bt,R.z=Mr*fo,Ge.copy(de).addScaledVector(R,n),c.push(Ge.x,Ge.y,Ge.z),d.push(R.x,R.y,R.z),h.push(0,0),pt.push(p++),Ir+=Math.PI*2/Oe/r}ye.push(pt)}Y.reverse(),ye.push(Y);let $e=ye.length-1;for(let Oe=0;Oe<$e;Oe++){let pt=ye[Oe],Lt=ye[Oe+1],Mr=pt.length-1;l.push(Lt[1],pt[0],Lt[0]);for(let bt=1;bt<=Mr;bt++)l.push(pt[bt],pt[bt-1],Lt[bt]),l.push(Lt[bt+1],pt[bt],Lt[bt])}}}}}this.setIndex(l),this.setAttribute("position",new El(c,3)),this.setAttribute("normal",new El(d,3)),this.setAttribute("uv",new El(h,2));function ce(R,E,y,z,_){let F=-z/2,K=(Math.PI-z)/2,Q=E.clone().normalize().cross(y);R.addScaledVector(y,-n/Math.sin(K));let k=new ht,V=new ht,B=1,U=p,se=[];for(let H=0;H<=a;H++){let W=F+H/a*z;V.set(0,0,0),V.addScaledVector(Q,Math.sin(W)),V.addScaledVector(y,Math.cos(W));for(let X=0;X<=B;X++){let Z=X/B-.5;if(k.copy(R),k.addScaledVector(E,Z),k.addScaledVector(V,n),_!=null){let Y=Math.max(0,k.y-_);k.addScaledVector(E,-Y/E.y)}c.push(k.x,k.y,k.z),d.push(V.x,V.y,V.z),h.push(0,0),X===0&&se.push(p),p++}}for(let H=0;H<a;H++)for(let W=0;W<B;W++){let X=U+W+(B+1)*H,Z=X+(B+1),Y=Z+1,ne=X+1;l.push(X,Z,ne),l.push(Z,Y,ne)}return[R.clone().addScaledVector(E,.5),se]}function be(R,E,y,z){let _=Math.PI/2,F=u.angle()-_,K=[],Q=new ht,k=new ht;for(let B=0;B<=a;B++){let U=[],se=B/a;for(let H=0;H<=B;H++){let X=((B?H/B:0)-.5)*C,Z=Math.cos(X),Y=Math.sin(X),ne=Math.atan(Math.tan(F)*Z),ie=(_+ne)*se,de=Math.cos(ie),Ge=Math.sin(ie);Q.set(0,0,0),Q.addScaledVector(E,Ge*Z),Q.addScaledVector(y,de),Q.addScaledVector(z,Ge*Y),k.copy(R).addScaledVector(Q,n),c.push(k.x,k.y,k.z),d.push(Q.x,Q.y,Q.z),h.push(0,0),U.push(p++)}K.push(U)}let V=K.length-1;for(let B=0;B<V;B++){let U=K[B],se=K[B+1],H=U.length-1;l.push(U[0],se[1],se[0]);for(let W=1;W<=H;W++)l.push(U[W-1],U[W],se[W]),l.push(U[W],se[W+1],se[W])}}}};var ra=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,e){var n,a,l,c,d;let t=Object.assign({},(n=e==null?void 0:e.parameters)!=null?n:{width:100,depth:0,cornerRadius:[0,0,0,0],cornerType:1,extrudeDepth:0,extrudeBevelSize:0,extrudeBevelSegments:1},i.parameters),r=Object.assign((a=e==null?void 0:e.ui)!=null?a:{enabledIndieCorners:!1},i.ui),o=t.cornerRadius.reduce((h,p)=>h+p,0);return{shape:i.shape&&i.shape instanceof Pe?i.shape:new Pe,parameters:Object.assign(t,{surfaceMaxCount:((l=t.surfaceMaxCount)!=null?l:o>0)?1e3:100,width:Math.abs(t.width),height:Math.abs((c=t.height)!=null?c:t.width),depth:Math.abs(t.depth!==void 0&&t.depth===0&&t.extrudeDepth>0?t.extrudeDepth:(d=t.depth)!=null?d:0)}),ui:r}}static build(i){let e=i.shape,{width:t,height:r,cornerRadius:o,cornerType:s,depth:n,extrudeBevelSize:a,extrudeBevelSegments:l,surfaceMaxCount:c}=i.parameters,d={x:t*.5,y:r*.5},h={x:-d.x,y:-d.y},p={x:d.x,y:d.y};function m(v,j,O){return j>t&&O>r?Math.min(v*t/j,v*r/O):j>t?v*t/j:O>r?v*r/O:v}let f=[];f[0]=o[0]===0?0:m(o[0],o[0]+o[3],o[0]+o[1]),f[1]=o[1]===0?0:m(o[1],o[1]+o[2],o[1]+o[0]),f[2]=o[2]===0?0:m(o[2],o[2]+o[1],o[2]+o[3]),f[3]=o[3]===0?0:m(o[3],o[3]+o[0],o[3]+o[2]);let x=h.x,g=p.x,N=p.y,C=h.y;e.addPoint(e.createPoint(x,N)),e.addPoint(e.createPoint(g,N)),e.addPoint(e.createPoint(g,C)),e.addPoint(e.createPoint(x,C)),e.isClosed=!0;let S=!0;for(let v=0,j=e.points.length;v<j;v++)e.points[v].roundness=f[v],v>0&&f[v]!==f[v-1]&&(S=!1);S&&(e.roundness=f[0]),e.useCubicForRoundedCorners=s!==1,e.update();let D=mt.create({shape:e,parameters:{surfaceMaxCount:c,depth:n,extrudeBevelSize:a,extrudeBevelSegments:l}});return Object.assign(D,{userData:q(P({},i),{type:"RectangleGeometry"})})}};import{SphereBufferGeometry as eS}from"three";var Ou=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,e){var r,o,s;let t=Object.assign({},(r=e==null?void 0:e.parameters)!=null?r:{width:100,widthSegments:64,heightSegments:64,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:Math.PI},i.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs((o=t.height)!=null?o:t.width),depth:Math.abs((s=t.depth)!=null?s:t.width)})}}static build(i){let{width:e=100,height:t=e,depth:r=e,widthSegments:o=64,heightSegments:s=64,phiStart:n,phiLength:a,thetaStart:l,thetaLength:c}=i.parameters,d=new eS(.5*e,o,s,n,a,l,c);return d.scale(1,t/e,r/e),Object.assign(d,{userData:q(P({},i),{type:"SphereGeometry"})})}};import{PlaneBufferGeometry as tS}from"three";var Tu=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,e){var r,o;let t=Object.assign({},(r=e==null?void 0:e.parameters)!=null?r:{width:100,depth:0,widthSegments:8,heightSegments:8},i.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs((o=t.height)!=null?o:t.width),depth:0})}}static build(i){let{width:e=100,height:t=e,widthSegments:r=8,heightSegments:o=8}=i.parameters,s=new tS(e,t,r,o);return s.scale(1,1,1),Object.assign(s,{userData:q(P({},i),{type:"PlaneGeometry"})})}};var Mu=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,e){var o,s,n,a;let t=Object.assign({},(o=e==null?void 0:e.parameters)!=null?o:{width:100,depth:0,innerRadiusPercent:38.19,spikes:5,cornerRadius:0,angle:360,extrudeDepth:0,extrudeBevelSize:0,extrudeBevelSegments:1},i.parameters);return{shape:i.shape&&i.shape instanceof Pe?i.shape:new Pe,parameters:Object.assign(t,{surfaceMaxCount:((s=t.surfaceMaxCount)!=null?s:t.cornerRadius>0)?1e3:100,width:Math.abs(t.width),height:Math.abs((n=t.height)!=null?n:t.width),depth:Math.abs(t.depth!==void 0&&t.depth===0&&t.extrudeDepth>0?t.extrudeDepth:(a=t.depth)!=null?a:0)})}}static build(i){let{width:e,height:t,innerRadiusPercent:r,spikes:o,cornerRadius:s,angle:n,depth:a,extrudeBevelSize:l,extrudeBevelSegments:c,surfaceMaxCount:d}=i.parameters,h=i.shape,p=e*.5,m=t*.5,f=0,x=0,g=n*Math.PI/360/o,N=Math.PI/2*3*-1,C=p*r/100,S=m*r/100;if(o==3&&r==50){g=2*Math.PI/o;for(let v=0;v<o;v++){let j=g*v,O=f+Math.sin(j)*p,u=x+Math.cos(j)*m;h.addPoint(h.createPoint(O,u))}}else for(let v=0;v<o;v++){let j=f+Math.cos(N)*p,O=x+Math.sin(N)*m;h.addPoint(h.createPoint(j,O)),N+=g,j=f+Math.cos(N)*C,O=x+Math.sin(N)*S,v<=o,h.addPoint(h.createPoint(j,O)),N+=g}h.isClosed=!0;for(let v=0,j=h.points.length;v<j;v++)h.points[v].roundness=s;h.roundness=s,h.update();let D=mt.create({shape:h,parameters:{surfaceMaxCount:d,roundness:s,depth:a,extrudeBevelSize:l,extrudeBevelSegments:c}});return Object.assign(D,{userData:q(P({},i),{type:"StarGeometry"})})}};import{PlaneBufferGeometry as rS}from"three";var oa=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,e){var r,o,s;let t=Object.assign({},(r=e==null?void 0:e.parameters)!=null?r:{width:100,depth:0},i.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs((o=t.height)!=null?o:t.width),depth:Math.abs((s=t.depth)!=null?s:0)})}}static build(i){let{width:e,height:t}=i.parameters,r=new rS(e,t);return Object.assign(r,{userData:q(P({},i),{type:"TextFrameGeometry"})})}};var Iu=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,e){var n,a,l;let t=Object.assign({},(n=e==null?void 0:e.parameters)!=null?n:{width:100,radialSegments:32,tubularSegments:64,arc:Math.PI*2,cornerRadius:30,cornerSegments:8},i.parameters),r=Math.abs(t.width),o=Math.abs((a=t.height)!=null?a:t.width),s=Math.abs((l=t.depth)!=null?l:t.width*.25);return{parameters:Object.assign(t,{width:r,height:o,depth:s})}}static build(i){let{width:e,height:t,depth:r,radialSegments:o,tubularSegments:s,arc:n,cornerRadius:a,cornerSegments:l}=i.parameters,c=oS(e,t,r,e*.5,n,s,0,0,o,a,l);return c.scale(1,t/e,1),Object.assign(c,{userData:q(P({},i),{type:"TorusGeometry"})})}};function oS(i,e,t,r,o,s,n,a,l,c,d){return[e,t]=[t,e],n=e/2,o/=2*Math.PI,o==1&&(c=0),new Zn(!0,i,e,t,r,o,s,n,a,l,c,d)}import{TorusKnotBufferGeometry as iS}from"three";var Pu=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,e){var r,o,s,n;let t=Object.assign({},(r=e==null?void 0:e.parameters)!=null?r:{width:100,tubularSegments:64,radialSegments:32,p:2,q:3},i.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs((o=t.height)!=null?o:t.width),depth:Math.abs((s=t.depth)!=null?s:t.width),tube:(n=t.tube)!=null?n:t.width*.125})}}static build(i){let{width:e,tube:t,tubularSegments:r,radialSegments:o,p:s,q:n}=i.parameters,a=e*.5;a!==t&&(a-=t);let l=new iS(a,t,r,o,s,n);return Object.assign(l,{userData:q(P({},i),{type:"TorusKnotGeometry"})})}};var Au=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,e){var o,s,n,a;let t=Object.assign({},(o=e==null?void 0:e.parameters)!=null?o:{width:100,depth:0,spikes:5,cornerRadius:0,extrudeDepth:0,extrudeBevelSize:0,extrudeBevelSegments:1,isRect:!1},i.parameters);return{shape:i.shape&&i.shape instanceof Pe?i.shape:new Pe,parameters:Object.assign(t,{surfaceMaxCount:((s=t.surfaceMaxCount)!=null?s:t.cornerRadius>0)?1e3:100,width:Math.abs(t.width),height:Math.abs((n=t.height)!=null?n:t.width*(t.isRect?1:Math.sqrt(3)/2)),depth:Math.abs(t.depth!==void 0&&t.depth===0&&t.extrudeDepth>0?t.extrudeDepth:(a=t.depth)!=null?a:0)})}}static build(i){let{width:e=100,height:t,cornerRadius:r,depth:o,extrudeBevelSize:s,extrudeBevelSegments:n,isRect:a,surfaceMaxCount:l}=i.parameters,c=i.shape,d=e*.5,h=t*.5;a?(c.addPoint(c.createPoint(-d,h)),c.addPoint(c.createPoint(d,-h)),c.addPoint(c.createPoint(-d,-h))):(c.addPoint(c.createPoint(0,h)),c.addPoint(c.createPoint(d,-h)),c.addPoint(c.createPoint(-d,-h))),c.isClosed=!0;for(let m=0,f=c.points.length;m<f;m++)c.points[m].roundness=r;c.roundness=r,c.update();let p=mt.create({shape:c,parameters:{surfaceMaxCount:l,roundness:r,depth:o,extrudeBevelSize:s,extrudeBevelSegments:n}});return Object.assign(p,{userData:q(P({},i),{type:"TriangleGeometry"})})}};var $i={};am($i,{addBarycentricAttribute:()=>cS,fixUvs:()=>hS,loadFromUrl:()=>dS,resizeGeometry:()=>lS,roundShapePolygon:()=>aS});import{BufferGeometryLoader as sS,Float32BufferAttribute as nS,Vector3 as Fl}from"three";var ju=function(i,e){let t=e.x-i.x,r=e.y-i.y,o=Math.sqrt(t*t+r*r),s=t/o,n=r/o,a=Math.atan2(n,s);return{x:t,y:r,len:o,nx:s,ny:n,ang:a}},aS=(i,e,t)=>{let r,o,s,n,a,l,c,d,h,p,m,f,x,g,N=e.length;for(n=e[N-2],i.curves=[],r=1;r<N-1;r++){a=e[r%N],l=e[(r+1)%N];let C=ju(a,n),S=ju(a,l);c=C.nx*S.ny-C.ny*S.nx,d=C.nx*S.nx-C.ny*-S.ny,m=Math.asin(c),h=1,p=!1,d<0?m<0?m=Math.PI+m:(m=Math.PI-m,h=-1,p=!0):m>0&&(h=-1,p=!0),f=m/2,g=Math.abs(Math.cos(f)*t/Math.sin(f)),g>Math.min(C.len/2,S.len/2)?(g=Math.min(C.len/2,S.len/2),x=Math.abs(g*Math.sin(f)/Math.cos(f))):x=t,o=a.x+S.nx*g,s=a.y+S.ny*g,o+=-S.ny*x*h,s+=S.nx*x*h,i.absarc(o,s,x,C.ang+Math.PI/2*h,S.ang-Math.PI/2*h,p),n=a,a=l}i.closePath()},lS=(i,{width:e,height:t,depth:r})=>{e=Math.abs(e),t=Math.abs(t),r=Math.abs(r);let o=i.userData.parameters,s,n,a;e===0?(e=o.width,s=1):s=e/o.width,t===0?(t=o.height,n=1):n=t/o.height,r===0?(r=o.depth,a=1):a=r/o.depth,i.scale(s,n,a),o.width=e,o.height=t,o.depth=r},cS=(i,e)=>{let t=[new Fl(1,0,0),new Fl(0,1,0),new Fl(0,0,1)],r=i.attributes.position,o=new Float32Array(r.count*3);for(let s=0,n=r.count;s<n;s++)t[s%3].toArray(o,s*3);i.setAttribute(e,new nS(o,3))},dS=i=>new Promise(e=>{new sS().load(i,r=>e(r))}),hS=(i,e,t)=>{let r=i.getAttribute("uv");if(r)for(let o=0;o<r.count;o++){let s=r.getX(o),n=r.getY(o);r.setXY(o,(s+e/2)/e,1-(n-t/2)/t*-1)}};import{BufferGeometry as _u,BufferAttribute as Du,Uint32BufferAttribute as Rl,Float32BufferAttribute as Vl,Matrix4 as uS}from"three";import{mergeVertices as fS}from"three/examples/jsm/utils/BufferGeometryUtils.js";var pS,ia=new Promise(i=>{pS=i});var pe;ia.then(i=>{pe=i});var Qt=class{static build(i,e,t,r,o){let s,n,a;if(i===void 0?(s=Qt.allocate(o,t),pe.set_destination_refinement_level(s,0),n=Qt.buildLevel(s,!0,r)):i.positionWASM!==void 0?(e&&e!==0&&(pe.free_bvh(e),pe.free_subdivision_surface(e)),s=Qt.allocate(o,void 0,i),pe.set_destination_refinement_level(s,0),n=Qt.buildLevel(s,!0,r)):s=e,i!==void 0&&i.subdivisions!==void 0){let l=mS(i.subdivisions,i.positionWASM.length);pe.set_destination_refinement_level(s,l),l>0?a=Qt.buildLevel(s,!1,r):a=null}return{subdivPointer:s,originalGeometry:n,subdividedGeometry:a}}static allocate(i,e,t){var v;let r,o,s,n=[],a=[];if(t)t.positionWASM.length>0?(r=t.positionWASM,o=t.indexWASM,s=t.verticesPerFaceWASM):(r=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),o=new Uint32Array([0,1,2,3]),s=new Uint8Array([4]));else{e.deleteAttribute("normal"),e.deleteAttribute("uv");let j=fS(e);r=j.attributes.position.array;let O=j.getIndex().array,u=O.length;switch(e.userData.type==="TorusGeometry"&&(e==null?void 0:e.userData.parameters.arc)===Math.PI*2&&(e.userData.type="ClosedTorusGeometry"),e.userData.type){case"ClosedTorusGeometry":case"PlaneGeometry":case"TorusKnotGeometry":case"CubeGeometry":o=new Uint32Array(u/3*2),s=new Uint8Array(u/6).fill(4);for(let J=0,te=0;J<u;J+=6)o[te++]=O[J],o[te++]=O[J+1],o[te++]=O[J+4],o[te++]=O[J+5];break;case"TorusGeometry":case"SphereGeometry":case"HelixGeometry":case"CylinderGeometry":case"ConeGeometry":let A,b,L;if(e.userData.type==="SphereGeometry")b=e.parameters.heightSegments,A=e.parameters.widthSegments,e.parameters.thetaLength!==Math.PI&&(L=!0);else if(e.userData.type==="CylinderGeometry")b=e.parameters.heightSegments+2,A=e.parameters.radialSegments;else if(e.userData.type==="ConeGeometry")b=e.parameters.heightSegments+1,A=e.parameters.radialSegments;else if(e.userData.type==="TorusGeometry"){let J=e.userData.parameters;b=Math.ceil(J.tubularSegments*J.arc/(2*Math.PI))+2,A=J.radialSegments}else{let{pathSegments:J,segments:te,revolutions:fe}=e.userData.parameters;b=Math.ceil(te*fe)+2,A=J}L?(o=new Uint32Array(1*A*3+(b-1)*A*4),s=new Uint8Array(1*A+(b-1)*A)):(o=new Uint32Array(2*A*3+(b-2)*A*4),s=new Uint8Array(2*A+(b-2)*A));let I=0,T=0,$=0;if(e.userData.type==="SphereGeometry"||e.userData.type==="HelixGeometry"||e.userData.type==="TorusGeometry"){for(;T<3*A;)o[T++]=O[I++],o[T++]=O[I++],o[T++]=O[I++],s[$++]=3;let J=L?o.length:3*A+4*(b-2)*A;for(;T<J;I+=6)o[T++]=O[I],o[T++]=O[I+1],o[T++]=O[I+4],o[T++]=O[I+5],s[$++]=4}else for(;T<4*(b-2)*A;I+=6)o[T++]=O[I],o[T++]=O[I+1],o[T++]=O[I+4],o[T++]=O[I+5],s[$++]=4;for(;T<o.length;)o[T++]=O[I++],o[T++]=O[I++],o[T++]=O[I++],s[$++]=3;break;default:o=O,s=new Uint8Array(u/3).fill(3);break}}let l=r.length,c=o.length,d=s.length,h=r.length+n.length+a.length,p=o.length+s.length,m=h*Float32Array.BYTES_PER_ELEMENT+p*Uint32Array.BYTES_PER_ELEMENT,f=h*Float32Array.BYTES_PER_ELEMENT,x=p*Uint32Array.BYTES_PER_ELEMENT,g=pe._malloc(m),N=new Float32Array(pe.HEAPF32.buffer,g,h),C=new Uint32Array(pe.HEAPU32.buffer,g+f,p);N.set(r,0),N.set(n,r.length),N.set(a,r.length+n.length),C.set(o,0),C.set(s,o.length);let S;((v=t==null?void 0:t.scaleBaked)==null?void 0:v.some(j=>j!==1))&&(S=new uS().makeScale(...t.scaleBaked)),i&&(S?S.premultiply(i):S=i);let D=S?pe.alloc_subdivision_surface2(g,l,g+f,c,g+f+o.length*Uint32Array.BYTES_PER_ELEMENT,d,S.elements):pe.alloc_subdivision_surface(g,l,g+f,c,g+f+o.length*Uint32Array.BYTES_PER_ELEMENT,d);return pe._free(g),D}static buildLevel(i,e,t,r,o){let s=o?pe.get_mesh_data2(i,e?pe.Level.CONTROL:pe.Level.REFINED,t!=null?t:!e,o.elements):pe.get_mesh_data(i,e?pe.Level.CONTROL:pe.Level.REFINED,t!=null?t:!e),n=8,a=pe.HEAPU32.subarray(s>>2,(s>>2)+n),l=a.subarray(4,4+4),c=0,d=pe.HEAPU32[a[c]>>2],h=pe.HEAPF32.subarray(d>>2,(d>>2)+l[c]);c++;let p=pe.HEAPU32[a[c]>>2],m=pe.HEAPF32.subarray(p>>2,(p>>2)+l[c]);c++;let f=pe.HEAPU32[a[c]>>2],x=pe.HEAPU32.subarray(f>>2,(f>>2)+l[c]);c++;let g=pe.HEAPU32[a[c]>>2],N=pe.HEAPU32.subarray(g>>2,(g>>2)+l[c]);if(c++,r===void 0){let C=new _u;if(C.setIndex(new Rl(N,1)),C.setAttribute("position",new Vl(h,3)),C.setAttribute("normal",new Vl(m,3)),e){C.setAttribute("faceMap",new Rl(x,1));let S=new Float32Array(m.length/3*4).fill(0);C.setAttribute("color",new Du(S,4))}return pe.free_mesh_data(s),C.userData.type="SubdivGeometry",C}r.getAttribute("position").copyArray(h),r.getAttribute("normal").copyArray(m),r.attributes.position.needsUpdate=!0,r.attributes.normal.needsUpdate=!0,pe.free_mesh_data(s)}static buildControlCageWireframe(i,e,t){let r=pe.get_wireframe_data_for_base_level(i),o=4,s=pe.HEAPU32.subarray(r>>2,(r>>2)+o),n=s.subarray(2,2+2),a=0,l=pe.HEAPU32[s[a]>>2],c=pe.HEAPF32.subarray(l>>2,(l>>2)+n[a]);a++;let d=pe.HEAPU32[s[a]>>2],h=pe.HEAPU32.subarray(d>>2,(d>>2)+n[a]);if(e===void 0){let p=new _u;p.setAttribute("position",new Vl(c,3));let m=new Float32Array(c.length);for(let f=0,x=c.length;f<x;)m[f++]=t.r,m[f++]=t.g,m[f++]=t.b;return p.setAttribute("color",new Du(m,3)),p.setIndex(new Rl(h,1)),pe.free_wireframe_data_for_base_level(r),p}e.getAttribute("position").copyArray(c),e.attributes.position.needsUpdate=!0,pe.free_wireframe_data_for_base_level(r)}static updateCollabMesh(i,e,t){e||pe.set_destination_refinement_level(i,1);let r=t?pe.get_topological_data2(i,e?pe.Level.CONTROL:pe.Level.REFINED,t.elements):pe.get_topological_data(i,e?pe.Level.CONTROL:pe.Level.REFINED),o=6,s=pe.HEAPU32.subarray(r>>2,(r>>2)+o),n=s.subarray(3,3+3),a=0,l=pe.HEAPU32[s[a]>>2],c=new Float32Array(pe.HEAPF32.subarray(l>>2,(l>>2)+n[a]));a++;let d=pe.HEAPU32[s[a]>>2],h=new Uint32Array(pe.HEAPU32.subarray(d>>2,(d>>2)+n[a]));a++;let p=pe.HEAPU32[s[a]>>2],m=new Uint8Array(pe.HEAPU32.subarray(p>>2,(p>>2)+n[a]));return pe.free_topological_data(r),{positions:c,indices:h,verticesPerFace:m}}};function mS(i,e){let t=i;return t=Math.min(t,3-Math.ceil(Math.log(e/172e3)/Math.log(4))),Math.max(t,0)}var kl={ConeGeometry:Fp,CubeGeometry:Rp,CylinderGeometry:Ep,DodecahedronGeometry:kp,EllipseGeometry:hu,HelixGeometry:yu,IcosahedronGeometry:xu,LatheGeometry:bu,NonParametricGeometry:ta,PolygonGeometry:wu,PyramidGeometry:Cu,RectangleGeometry:ra,SphereGeometry:Ou,PlaneGeometry:Tu,StarGeometry:Mu,TextFrameGeometry:oa,TorusGeometry:Iu,TorusKnotGeometry:Pu,TriangleGeometry:Au,VectorGeometry:mt},Ki=i=>kl[i.type].create(i);import{Matrix4 as Wl}from"three";import{Box3 as zu,Line3 as Yt,Matrix4 as Ul,Vector3 as Ve}from"three";import{HemisphereLight as Bu}from"three";import{Color as gS}from"three";var Jt=class extends gS{constructor(e,t,r,o){super(e,t,r);this.a=o}setRGBA(e,t,r,o){super.setRGB(e,t,r),this.a=o}get x(){return this.r}get y(){return this.g}get z(){return this.b}get w(){return this.a}set x(e){this.r=e}set y(e){this.g=e}set z(e){this.b=e}set w(e){this.a=e}};function et(i,e){let t;if(typeof i=="string"){let r=e==null?void 0:e.getColor(i);r?t=r:(console.warn("Tried to create color layer params with a color key that does not exist in the assets manager"),t=new Jt(0,0,0,0))}else return"a"in i?new Jt(i.r,i.g,i.b,i.a):new Jt(i.r,i.g,i.b,1);return t}var sa=i=>"isEntity"in i,na=i=>"isAbstractMesh"in i;var Rr=i=>"objectHelper"in i;function yS(i,e){var r;let t=!1;e.position&&(i.position.fromArray(e.position),t=!0),e.rotation&&(i.rotation.fromArray(e.rotation),t=!0),e.scale&&(t=!0,i.scale.fromArray(e.scale)),e.hiddenMatrix!==void 0&&"hiddenMatrix"in i&&(t=!0,i.hiddenMatrix.fromArray((r=e.hiddenMatrix)!=null?r:Yr.identity)),t&&i.updateMatrix(),e.position&&e.rotation&&e.scale&&e.hiddenMatrix!==void 0&&i.updateWorldMatrix(!1,!0),i.objectType==="CombinedCamera"&&(e.isUpVectorFlipped!==void 0&&(i.isUpVectorFlipped=e.isUpVectorFlipped),i.updateUp())}function xS(i,e){yS(i,e),e.name!==void 0&&(i.name=e.name),e.visible!==void 0&&(i.isEntity?i.visibility=e.visible:i.visible=e.visible)}function Gu(i,e,t){xS(i,e),e.color!==void 0&&(i.color=et(e.color,t)),e.intensity!==void 0&&(i.intensity=e.intensity),e.shadows!==void 0&&!(i instanceof Bu)&&(i.castShadow=e.shadows),i.shadow&&!(i instanceof Bu)&&e.depth!==void 0&&(i.shadow.camera.far=e.depth,i.shadow.needsUpdate=!0),e.helper!==void 0&&Rr(i)&&(i.enableHelper=e.helper,i.gizmos.shadowmap.visible=e.helper)}function Eu(i,e){i.shadow.camera.right=e/2,i.shadow.camera.left=-e/2,i.shadow.camera.top=e/2,i.shadow.camera.bottom=-e/2,i.shadow.needsUpdate=!0}var pi=new zu,gt=new Ve,le=new Ve,rt=new Ul;function bS(i,e,t=0,r=e.count){let o=1/0,s=1/0,n=1/0,a=-1/0,l=-1/0,c=-1/0;for(let d=t;d<r;d++){let h=e.getX(d),p=e.getY(d),m=e.getZ(d);h<o&&(o=h),p<s&&(s=p),m<n&&(n=m),h>a&&(a=h),p>l&&(l=p),m>c&&(c=m)}return i.min.set(o,s,n),i.max.set(a,l,c),i}var Fu=(i,e,t,r)=>{var o;if(na(i)){let s=i.geometry.userData.parameters,n=i.geometry.getAttribute("position");i.geometry.userData.type==="SubdivGeometry"?gt.copy(i.originalGeometry.boundingSphere.center):(bS(pi,n,i.geometry.drawRange.start,i.geometry.drawRange.count<1/0?i.geometry.drawRange.count:n.count),pi.getCenter(gt)),i.forceComputeSize?pi.getSize(le).multiplyScalar(.5):le.set(s.width,s.height,(o=s.depth)!=null?o:0).multiplyScalar(.5)}else if(Rr(i)&&r===!0){let s=i.geometryHelper.getAttribute("position");pi.setFromArray(s.array),pi.getCenter(gt),pi.getSize(le).multiplyScalar(.5)}else gt.setScalar(0),le.setScalar(0);rt.copy(e).multiply(i.matrixWorld),le.x===0&&le.y===0&&le.z===0?t.push(new Ve(gt.x,gt.y,gt.z).applyMatrix4(rt)):t.push(new Ve(-le.x,le.y,le.z).add(gt).applyMatrix4(rt),new Ve(-le.x,-le.y,le.z).add(gt).applyMatrix4(rt),new Ve(le.x,-le.y,le.z).add(gt).applyMatrix4(rt),new Ve(le.x,le.y,le.z).add(gt).applyMatrix4(rt),new Ve(-le.x,le.y,-le.z).add(gt).applyMatrix4(rt),new Ve(-le.x,-le.y,-le.z).add(gt).applyMatrix4(rt),new Ve(le.x,-le.y,-le.z).add(gt).applyMatrix4(rt),new Ve(le.x,le.y,-le.z).add(gt).applyMatrix4(rt))},aa=class extends zu{constructor(){super(...arguments);this.matrix=new Ul;this.vertices=[];this.faces=[];this.edges=[];this.centerEdges=[]}copy(e){return super.copy(e),this.matrix.copy(e.matrix),this.vertices=e.vertices.map(t=>t.clone()),this.faces=e.faces.map(t=>t.clone()),this.edges=e.edges.map(t=>t.clone()),this.centerEdges=e.centerEdges.map(t=>t.clone()),this}setFromObjectSize(e,t=!1){e.updateWorldMatrix(!1,t),this.makeEmpty(),this.matrix.copy(e.matrixWorld);let r=new Ul().copy(e.matrixWorld).invert();return this.expandByObjectSize(e,r,t)}expandByObjectSize(e,t,r=!1){let o=[];return r===!0?e.traverseEntity(s=>Fu(s,t,o,e.enableHelper===!0)):Fu(e,t,o,e.enableHelper===!0),this.setFromPoints(o)}getCenter(e){return e=super.getCenter(e),e.applyMatrix4(this.matrix),e}getPositionToCenter(e){return e=super.getCenter(e),e.applyMatrix4(rt.copy(this.matrix).setPosition(0,0,0)),e}computeVertices(){this.getSize(le).multiplyScalar(.5),this.getCenter(gt),rt.copy(this.matrix).setPosition(gt),this.vertices=[new Ve(-le.x,le.y,le.z).applyMatrix4(rt),new Ve(-le.x,-le.y,le.z).applyMatrix4(rt),new Ve(le.x,-le.y,le.z).applyMatrix4(rt),new Ve(le.x,le.y,le.z).applyMatrix4(rt),new Ve(-le.x,le.y,-le.z).applyMatrix4(rt),new Ve(-le.x,-le.y,-le.z).applyMatrix4(rt),new Ve(le.x,-le.y,-le.z).applyMatrix4(rt),new Ve(le.x,le.y,-le.z).applyMatrix4(rt)]}computeEdges(){this.vertices.length>0&&this.computeVertices(),this.edges=[new Yt(this.vertices[0],this.vertices[3]),new Yt(this.vertices[1],this.vertices[2]),new Yt(this.vertices[5],this.vertices[6]),new Yt(this.vertices[4],this.vertices[7]),new Yt(this.vertices[0],this.vertices[1]),new Yt(this.vertices[3],this.vertices[2]),new Yt(this.vertices[7],this.vertices[6]),new Yt(this.vertices[4],this.vertices[5]),new Yt(this.vertices[0],this.vertices[4]),new Yt(this.vertices[1],this.vertices[5]),new Yt(this.vertices[2],this.vertices[6]),new Yt(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 jS,Matrix4 as _S,Light as DS}from"three";import{Group as IS,Mesh as Hu,MeshStandardMaterial as qu}from"three";import{BufferGeometry as vS,Float32BufferAttribute as Jl}from"three";function Ru(i){var n;let e=[],t=i.groups,r=i.getAttribute("position").array,o=i.getAttribute("normal").array,s=(n=i.getAttribute("uv"))==null?void 0:n.array;return t.forEach(a=>{let l=a.count,c=new vS,d=new Float32Array(l*3),h=new Float32Array(l*3),p=new Float32Array(l*2);for(let m=0;m<l;m++){let f=3*(a.start+m),x=3*m;if(d[x]=r[f],d[x+1]=r[f+1],d[x+2]=r[f+2],h[x]=o[f],h[x+1]=o[f+1],h[x+2]=o[f+2],s){let g=2*(a.start+m),N=2*m;p[N]=s[g],p[N+1]=s[g+1]}}c.setAttribute("position",new Jl(d,3)),c.setAttribute("normal",new Jl(h,3)),s&&c.setAttribute("uv",new Jl(p,2)),e.push(c)}),e}import{GLTFExporter as PS}from"three/examples/jsm/exporters/GLTFExporter.js";var SS,Vu=new Promise(i=>{SS=i});var Wu=Fc(Ju());var ca={isPublish:!1,gltfQueue:[]};function ql(i,e,t){return i[e.uuid]===void 0&&(i[e.uuid]=e.toJSON(t)),e.uuid}var AS=new PS;function $u(i,e,t){if(i[e.uuid]===void 0)if(e.userData.type==="NonParametricGeometry"||e.userData.type==="SubdivGeometry"){if(e.userData.type==="SubdivGeometry")if(ca.isPublish)e=ta.create({geometry:e.clone()}),e.userData.parameters.subdivisions===0&&(delete e.attributes.color,delete e.attributes.faceMap,delete e.attributes.positionWASM,delete e.attributes.indexWASM,delete e.attributes.verticesPerFaceWASM);else{let o=e.originalGeometry;if(o){let s=e.userData;e=o.clone(),e.userData=s}else e=e.clone();delete e.attributes.color,delete e.attributes.faceMap,delete e.attributes.position,delete e.attributes.normal,e.index=null}let r=e.originalGeometry;if(r!==void 0){let o=e.userData;e=r,e.userData=o}if(!ca.isPublish)i[e.uuid]=e.toJSON();else{let o={type:"NonParametricGeometry",uuid:e.uuid,userData:{}};e.name!==""&&(o.name=e.name),Object.keys(e.userData).length>0&&(o.userData=P({},e.userData));let s=e.index===null,n=new IS;if(Array.isArray(t))Ru(e).forEach((l,c)=>{let d=new Hu(l,new qu);n.add(d),l.userData.groupIndex=c,l.userData.materialIndex=e.groups[c].materialIndex,l.index===null&&(s=!0)});else{let a=new Hu(e,new qu);n.add(a)}ca.gltfQueue.push(new Promise(async a=>{await Promise.all(ca.gltfQueue),AS.parse(n,async l=>{let{gltfTransform:c,DracoMeshCompressionExtension:d,addIndex:h}=await Vu,p=c.readJSON({json:qa(l),resources:{}});p.createExtension(d).setRequired(!0).setEncoderOptions({quantizationVolume:"scene"}),s&&await p.transform(h);try{let{json:m,resources:f}=c.writeJSON(p),x=Wu.default.fromByteArray(new Uint8Array(f[".bin"]));m.buffers[0].uri=`data:application/octet-stream;base64,${x}`,a()}catch(m){a()}},{})})),i[e.uuid]=o}}else{let r=e.userData;if(r.type==="VectorGeometry"){let o=e.userData.shape;r=Object.assign({},r,{shape:o.toJSON()})}i[e.uuid]={uuid:e.uuid,userData:r}}return e.uuid}function ui(i){let e=[];for(let t in i){let r=i[t];delete r.metadata,e.push(r)}return e}function Ku(i){let e=[];for(let t in i)e.push(i[t]);return e}var da=i=>class extends i{hasEntityChild(){return this.children.some(t=>sa(t))}isDescendantOf(t){t instanceof jS&&(t=t.uuid);let r=this;for(;r.parent;){if(r.parent.uuid===t)return!0;r=r.parent}return!1}attach(t,r){this.updateWorldMatrix(!0,!1);let o=new _S().copy(this.matrixWorld).invert();return t.parent!==null&&(t.parent.updateWorldMatrix(!0,!1),o.multiply(t.parent.matrixWorld)),sa(t)?t.hiddenMatrix.premultiply(o):t.applyMatrix4(o),t.updateWorldMatrix(!1,!1),this.add(t),r!==void 0&&(this.children.pop(),this.children.splice(r,0,t)),this}copy(t,r=!0){if(this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.rotation.order=t.rotation.order,this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.userData=JSON.parse(JSON.stringify(t.userData)),r===!0)for(let o=0;o<t.children.length;o++){let s=t.children[o];this.add(s.clone())}return this}toJSON(t){let r=t===void 0,o={object:{uuid:"",objectType:""}};t===void 0&&(t={geometries:{},materials:{},textures:{},images:{},interactionStates:{},nodes:{}},o.metadata={version:1.5,type:"Object",generator:"Object3D.toJSON"});let s={uuid:this.uuid,objectType:this.type};if(this.name!==""&&(s.name=this.name),s.matrix=this.matrix.toArray(),this.castShadow===!0&&(s.castShadow=!0),this.receiveShadow===!0&&(s.receiveShadow=!0),this.visible===!1&&(s.visible=!1),this.frustumCulled===!1&&(s.frustumCulled=!1),this.renderOrder!==0&&(s.renderOrder=this.renderOrder),s.layers=this.layers.mask,JSON.stringify(this.userData)!=="{}"&&(s.userData=this.userData),this.children.length>0){s.children=[];for(let n of this.children)(sa(n)||n instanceof DS)&&s.children.push(n.toJSON(t).object)}if(r){let n=ui(t.geometries),a=ui(t.materials),l=ui(t.textures),c=ui(t.images),d=ui(t.interactionStates),h=Ku(t.nodes);n.length>0&&(o.geometries=n),a.length>0&&(o.materials=a),l.length>0&&(o.textures=l),c.length>0&&(o.images=c),d.length>0&&(o.interactionStates=d),h.length>0&&(o.nodes=h)}return o.object=s,o}fromJSON(t){return this.uuid=t.uuid,t.name!==void 0&&(this.name=t.name),t.matrix!==void 0?(this.matrix.fromArray(t.matrix),t.matrixAutoUpdate!==void 0&&(this.matrixAutoUpdate=t.matrixAutoUpdate),this.matrixAutoUpdate&&this.matrix.decompose(this.position,this.quaternion,this.scale)):(t.position!==void 0&&this.position.fromArray(t.position),t.rotation!==void 0&&this.rotation.fromArray(t.rotation),t.quaternion!==void 0&&this.quaternion.fromArray(t.quaternion),t.scale!==void 0&&this.scale.fromArray(t.scale)),this.castShadow=t.castShadow!==void 0,this.receiveShadow=t.receiveShadow!==void 0,t.visible!==void 0&&(this.visible=t.visible),t.frustumCulled!==void 0&&(this.frustumCulled=t.frustumCulled),t.renderOrder!==void 0&&(this.renderOrder=t.renderOrder),t.layers!==void 0&&(this.layers.mask=t.layers),t.userData!==void 0&&(this.userData=t.userData),this}};var tr=i=>"isEntity"in i;var rr=i=>class extends da(i){constructor(){super(...arguments);this.objectType="";this.isEntity=!0;this.raycastLock=!1;this.scaleLock=!1;this.hiddenMatrix=new Wl;this._singleBBox=new aa;this._recursiveBBox=new aa;this.singleBBoxNeedsUpdate=!0;this.recursiveBBoxNeedsUpdate=!0;this.forceComputeSize=!1}set visibility(t){this.visible=t;for(let r of this.children)tr(r)&&r.traverseEntity(o=>{Rr(o)&&o.visible&&(o.objectHelper.visible=t)})}get visibility(){return this.visible}get interactionCache(){var t,r,o;return((t=this.interaction)==null?void 0:t.cache)===void 0&&((r=this.interaction)==null||r.computeCache()),(o=this.interaction)==null?void 0:o.cache}get singleBBox(){return this.singleBBoxNeedsUpdate&&(this.singleBBoxNeedsUpdate=!1,this._singleBBox.setFromObjectSize(this,!1),this._singleBBox.computeVertices(),this._singleBBox.computeEdges(),this._singleBBox.computeFaces()),this._singleBBox}get recursiveBBox(){return this.recursiveBBoxNeedsUpdate&&(this.recursiveBBoxNeedsUpdate=!1,this._recursiveBBox.setFromObjectSize(this,!0),this._recursiveBBox.computeVertices(),this._recursiveBBox.computeEdges(),this._recursiveBBox.computeFaces()),this._recursiveBBox}resetBBoxNeedsUpdate(){this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0,this.traverseAncestors(t=>{tr(t)&&(t.singleBBoxNeedsUpdate=!0,t.recursiveBBoxNeedsUpdate=!0)}),this.traverseEntity(t=>{t.singleBBoxNeedsUpdate=!0,t.recursiveBBoxNeedsUpdate=!0})}traverseEntity(t){t(this);for(let r of this.children)tr(r)&&r.traverseEntity(t)}updateMatrixWorld(t){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||t)&&(this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,t=!0);for(let r of this.children)r.updateMatrixWorld(t)}updateWorldMatrix(t,r){let o=this.parent;if(t&&o!==null&&o.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),r)for(let s of this.children)s.updateWorldMatrix(!1,!0)}shallowClone(t){return new this.constructor().shallowCopy(this,t)}shallowCopy(t,r=!0){if(super.copy(t,!1),this.raycastLock=t.raycastLock,this.scaleLock=t.scaleLock,this.hiddenMatrix.copy(t.hiddenMatrix),r===!0)for(let o of t.children)tr(o)&&this.add(o.shallowClone());return this}clone(t){return new this.constructor().copy(this,t)}copy(t,r=!0){if(super.copy(t,!1),this.raycastLock=t.raycastLock,this.scaleLock=t.scaleLock,this.hiddenMatrix.copy(t.hiddenMatrix),r===!0)for(let o of t.children)tr(o)&&this.add(o.clone());return this}keepChildrenMatrixWorld(){let t=new Wl,r=this.matrixWorld.clone();this.updateWorldMatrix(!1,!1),t.copy(this.matrixWorld).invert(),t.multiply(r);for(let o of this.children)tr(o)&&o.hiddenMatrix.premultiply(t)}toJSON(t){let r=super.toJSON(t),o=r.object;return this.raycastLock===!0&&(o.raycastLock=!0),this.scaleLock===!0&&(o.scaleLock=!0),o.hiddenMatrix=this.hiddenMatrix.toArray(),r}fromJSON(t){return super.fromJSON(t),t.raycastLock!==void 0&&(this.raycastLock=t.raycastLock),t.scaleLock!==void 0&&(this.scaleLock=t.scaleLock),this.hiddenMatrix.fromArray(t.hiddenMatrix),this}fromObject3D(t){let r=t.children;return t.children=[],Object.assign(t,{raycastLock:!1,scaleLock:!1,hiddenMatrix:new Wl}),this.copy(t),t.children=r,this}toObjectTransformState(t=[]){this.updateWorldMatrix(!0,!1);let r={position:this.position.toArray(),rotation:[this.rotation.x,this.rotation.y,this.rotation.z],scale:this.scale.toArray(),hiddenMatrix:this.hiddenMatrix.toArray()};return Qo(r,t)}fromObjectTransformState(t){return t.position&&this.position.fromArray(t.position),t.rotation&&this.rotation.fromArray(t.rotation),t.scale&&this.scale.fromArray(t.scale),t.hiddenMatrix&&this.hiddenMatrix.fromArray(t.hiddenMatrix),this.updateMatrix(),this}toState(t=[]){let r=P({name:this.name,visible:this.visible,raycastLock:this.raycastLock},this.toObjectTransformState(t));return Qo(r,t)}fromState(t,r){return t.name&&(this.name=t.name),t.raycastLock!==void 0&&(this.raycastLock=t.raycastLock),t.type!=="OrthographicCamera"&&t.type!=="PerspectiveCamera"&&(this.matrixAutoUpdate=!1),t.visible!==void 0&&(this.visibility=t.visible),this.fromObjectTransformState(t),this}};import{Object3D as BS,Vector3 as Xi,Euler as Xu,MathUtils as no}from"three";var ha=class extends BS{constructor(e,t={}){super();this.object=e;let r=e.recursiveBBox.getSize(new Xi),o=.1;this.parameters=pn.defaultData(r.toArray(),o),xo(this.parameters,t),this.update(),this.setHideBase(this.parameters.hideBase)}refreshMaterial(){if("material"in this.object)for(let e of this.children)e.material=this.object.material}setHideBase(e){if("material"in this.object){if(Array.isArray(this.object.material)){if(this.children.length>0){for(let t of this.object.material)t.visible=!0;if(e){let t=this.object.material.map(r=>r.clone());for(let r of this.children)r.material=t}else for(let t of this.children)t.material=this.object.material}for(let t of this.object.material)t.visible=!e}else{if(this.children.length>0)if(this.object.material.visible=!0,e){let t=this.object.material.clone();for(let r of this.children)r.material=t}else for(let t of this.children)t.material=this.object.material;this.object.material.visible=!e}this.parameters.hideBase=e}}update(){switch(this._updateCount(),this.parameters.type){case"radial":this._updateRadial(this.parameters);break;case"linear":this._updateLinear(this.parameters);break;case"grid":this._updateGrid(this.parameters)}this.children.forEach(e=>e.updateMatrix())}_updateCount(){let e=this.parameters.type==="grid"?this.parameters.grid.count[0]*this.parameters.grid.count[1]*this.parameters.grid.count[2]:this.parameters.count;if(this.children.length!==e)if(this.children.length<e)for(let t=0,r=e-this.children.length;t<r;++t){let o=this.object.shallowClone(!1);o.visible=!0,this.add(o),this.parameters.hideBase&&this.setHideBase(!0)}else for(let t=0,r=this.children.length-e;t<r;++t)this.remove(this.children[0])}_updateRadial(e){let t=e.radial,r=t.start*no.DEG2RAD,o=t.end*no.DEG2RAD,s=r-o,n=new Xu(t.rotation[0]*no.DEG2RAD,t.rotation[1]*no.DEG2RAD,t.rotation[2]*no.DEG2RAD),a;switch(t.axis){case"z":a=new Xi(0,0,1);break;case"y":a=new Xi(0,1,0);break;default:case"x":a=new Xi(1,0,0);break}for(let[l,c]of this.children.entries()){c.hiddenMatrix.identity(),c.scale.x=t.scale[0]+1,c.scale.y=t.scale[1]+1,c.scale.z=t.scale[2]+1,c.position.setScalar(0);let d=s/e.count*l-r;switch(t.axis){case"x":c.rotation.set(0,d,0);break;case"y":c.rotation.set(0,0,d);break;case"z":c.rotation.set(d,0,0);break}c.translateOnAxis(a,t.radius),c.position.x+=t.position[0],c.position.y+=t.position[1],c.position.z+=t.position[2],t.alignment===!0?(c.rotation.x+=n.x,c.rotation.y+=n.y,c.rotation.z+=n.z):c.rotation.copy(n)}}_updateLinear(e){if(e.type!=="linear")throw new Error;let t=e.linear,r=new Xu(t.rotation[0]*no.DEG2RAD,t.rotation[1]*no.DEG2RAD,t.rotation[2]*no.DEG2RAD);for(let[o,s]of this.children.entries())s.hiddenMatrix.identity(),s.scale.x=t.scale[0]*o+1,s.scale.y=t.scale[1]*o+1,s.scale.z=t.scale[2]*o+1,s.rotation.x=r.x*o,s.rotation.y=r.y*o,s.rotation.z=r.z*o,s.position.x=t.position[0]*o,s.position.y=t.position[1]*o,s.position.z=t.position[2]*o}_updateGrid(e){let t=0,r=e.grid;if(r.useCenter===!0){let o={x:r.count[0]%2==0?2:1,y:r.count[1]%2==0?2:1,z:r.count[2]%2==0?2:1},s=new Xi(r.size[0]*(r.count[0]-o.x)*.5,r.size[1]*(r.count[1]-o.y)*.5,r.size[2]*(r.count[2]-o.z)*.5);for(let n=0;n<r.count[0];n++)for(let a=0;a<r.count[1];a++)for(let l=0;l<r.count[2];l++){let c=this.children[t++];c.hiddenMatrix.identity(),c.scale.setScalar(1),c.rotation.set(0,0,0),c.position.x=r.size[0]*n-s.x,c.position.y=r.size[1]*a-s.y,c.position.z=r.size[2]*l-s.z}}else for(let o=0;o<r.count[0];o++)for(let s=0;s<r.count[1];s++)for(let n=0;n<r.count[2];n++){let a=this.children[t++];a.hiddenMatrix.identity(),a.scale.setScalar(1),a.rotation.set(0,0,0),a.position.x=r.size[0]*o,a.position.y=-r.size[1]*s,a.position.z=-r.size[2]*n}}fromJSON(e){return this}toJSON(){return{}}fromClonerState(e){return e.hideBase!==void 0&&this.setHideBase(e.hideBase),xo(this.parameters,e),this.update(),this}};var yt=class extends rr(GS){constructor(e,t){super(e,t);this.isAbstractMesh=!0;Array.isArray(t)&&(this.selectedMaterial=0,e.groups.length===0&&e.addGroup(0,e.getAttribute("position").count,0))}get cloner(){return this._cloner}set cloner(e){this._cloner&&this.remove(this._cloner),e&&this.add(e),this._cloner=e}getSelectedMaterial(e){return Array.isArray(this.material)?(this.selectedMaterial===void 0&&(this.selectedMaterial=e!=null?e:0),this.material[e!=null?e:this.selectedMaterial]):this.material}setSelectedMaterial(e,t){Array.isArray(this.material)?(this.selectedMaterial===void 0&&(this.selectedMaterial=t!=null?t:0),t=t!=null?t:this.selectedMaterial,this.material[t].dispose(),this.material[t]=e):(this.material.dispose(),this.material=e)}updateGeometry(e){let t=this.geometry,r=kl[t.userData.type],o=this.objectType==="NonParametric"?Object.assign({},t.userData,{geometry:t}):t.userData,s=r.build(r.normalizeInputs(e,o)),n=t.uuid;if(this.geometry.dispose(),this.geometry=s,this.geometry.uuid=n,this.geometry.computeBoundingSphere(),this.cloner)for(let a of this.cloner.children)a.geometry=this.geometry}resizeGeometry(e,t,r){$i.resizeGeometry(this.geometry,{width:e,height:t,depth:r})}shallowClone(e){return new this.constructor(this.geometry,this.material).shallowCopy(this,e)}clone(e){let t=this.objectType==="NonParametric"?Object.assign({},this.geometry.userData,{geometry:this.geometry.clone()}):this.geometry.userData,r=Ki(t),o=Array.isArray(this.material)?this.material.map(s=>s.clone()):this.material.clone();return new this.constructor(r,o).copy(this,e)}copy(e,t=!0){return super.copy(e,t),e.cloner&&(this.cloner=new ha(e,e.cloner.parameters),this.add(this.cloner)),this}toJSON(e){let t=super.toJSON(e),r=t.object;if(r.geometry=$u(e.geometries,this.geometry,this.material),Array.isArray(this.material)){let o=[];for(let s=0,n=this.material.length;s<n;s++)o.push(ql(e.materials,this.material[s],e));r.material=o}else r.material=ql(e.materials,this.material,e);return t}fromJSON(e){return super.fromJSON(e),e.selectedMaterial!==void 0&&(this.selectedMaterial=e.selectedMaterial),this}setFromClonerState(e){e===null?this.cloner=void 0:(this.cloner===void 0&&(this.cloner=new ha(this)),this.cloner.fromClonerState(e))}fromState(e,t){var r,o;return super.fromState(e),e.type==="Mesh"&&(this.setFromClonerState(e.cloner),this.castShadow=(r=e.castShadow)!=null?r:!0,this.receiveShadow=(o=e.receiveShadow)!=null?o:!0),this}};import{NormalBlending as iN,ShaderMaterial as sN,FrontSide as nN}from"three";import{CubeReflectionMapping as $S,CubeRefractionMapping as KS,CubeUVReflectionMapping as XS,CubeUVRefractionMapping as ZS,LinearEncoding as rf,sRGBEncoding as QS}from"three";var pa=class{constructor(e){e=e!=null?e:{},this.name=e.name,this.type=e.type,this.node=e.node,this.size=e.size,this.needsUpdate=e.needsUpdate}get value(){return this.node.value}set value(e){this.node.value=e}};import{MathUtils as ES}from"three";var ue=class{constructor(e){this.hashProperties=void 0;this.isNode=!0;this.shortcuts={};this.uuid=ES.generateUUID(),this.type=e,this.name="",this.userData={}}analyze(e,t){t=t!=null?t:{},e.analyzing=!0,this.build(e.addFlow(t.slot,t.cache,t.context),"v4"),e.clearVertexNodeCode(),e.clearFragmentNodeCode(),e.removeFlow(),e.analyzing=!1}analyzeAndFlow(e,t,r){return r=r!=null?r:{},this.analyze(e,r),this.flow(e,t,r)}flow(e,t,r){r=r!=null?r:{},e.addFlow(r.slot,r.cache,r.context);let o={result:this.build(e,t),code:e.clearNodeCode(),extra:e.context.extra};return e.removeFlow(),o}build(e,t,r){t=t!=null?t:this.getType(e,t);let o=e.getNodeData(r!=null?r:this);return e.analyzing&&this.appendDepsNode(e,o,t),e.nodes.indexOf(this)===-1&&e.nodes.push(this),this.updateFrame!==void 0&&e.updaters.indexOf(this)===-1&&e.updaters.push(this),this.generate(e,t,r)}updateFrame(e){}generateReadonly(e,t,r,o,s,n){return""}generate(e,t,r,o,s){return""}parse(e,t,r,o){}appendDepsNode(e,t,r){t.deps=(t.deps||0)+1;let o=e.getTypeLength(r);(o>(t.outputMax||0)||this.getType(e,r))&&(t.outputMax=o,t.output=r)}setName(e){this.name=e}getName(){return this.name}getType(e,t){return t==="sampler2D"||t==="samplerCube"?t:this.type}getJSONNode(e){if((e==null?void 0:e.materials)&&(e==null?void 0:e.materials[this.uuid])!==void 0)return e.materials[this.uuid]}getHash(){let e="{",t,r;for(t in this)r=this[t],r instanceof ue&&(e+='"'+t+'":'+r.getHash()+",");if(this.hashProperties)for(let o=0;o<this.hashProperties.length;o++)t=this.hashProperties[o],r=this[t],e+='"'+t+'":"'+String(r)+'",';return e+='"id":"'+this.uuid+'"}',e}copy(e){return this.name=e.name,e.type&&(this.type=e.type),e.frameId&&(this.frameId=e.frameId),e.hashProperties&&(this.hashProperties=e.hashProperties.map(t=>t)),this.userData=JSON.parse(JSON.stringify(e.userData)),this.shortcuts=JSON.parse(JSON.stringify(e.shortcuts)),this}clone(){return new this.constructor().copy(this)}createJSONNode(e){let t=e===void 0||typeof e=="string";if(typeof this.type!="string")throw new Error("Node does not allow serialization.");let r={};return r.uuid=this.uuid,r.type=this.type,this.name!==""&&(r.name=this.name),JSON.stringify(this.userData)!=="{}"&&(r.userData=this.userData),!t&&e&&(e.nodes[this.uuid]=r),r}toJSON(e){var t;return(t=this.getJSONNode(e))!=null?t:this.createJSONNode(e)}fromJSON(e,t){return this.uuid=e.uuid,this.type=e.type,e.name&&(this.name=e.name),e.userData&&(this.userData=e.userData),this}};var Zu=class{constructor(){this.nodes={};this.keywords={}}add(e){this.nodes[e.name]=e}addKeyword(e,t,r){r=r!==void 0?r:!0,this.keywords[e]={callback:t,cache:r}}remove(e){delete this.nodes[e.name]}removeKeyword(e){delete this.keywords[e]}get(e){return this.nodes[e]}getKeyword(e,t){return this.keywords[e].callback(t)}getKeywordData(e){return this.keywords[e]}contains(e){return this.nodes[e]!==void 0}containsKeyword(e){return this.keywords[e]!==void 0}},ct=new Zu;import{Vector2 as Qu}from"three";import{MathUtils as zS}from"three";var me=class extends ue{constructor(e,t){super(e);this.scope="";t=t!=null?t:{},this.shared=t.shared!==void 0?t.shared:!0,this.unique=t.unique!==void 0?t.unique:!1}build(e,t,r,o){if(t=t!=null?t:this.getType(e),this.getShared(e,t)){let s=this.getUnique(e,t);s&&this.uuid===void 0&&(this.uuid=zS.generateUUID()),r=e.getUUID(r!=null?r:this.getUUID(),!s);let n=e.getNodeData(r),a=n.output||this.getType(e);if(e.analyzing)return(n.deps||0)>0||this.getLabel()?(this.appendDepsNode(e,n,t),this.generate(e,t,r)):super.build(e,t,r);if(s)return n.name=n.name||super.build(e,t,r),n.name;if(!this.getLabel()&&(!this.getShared(e,a)||e.context.ignoreCache||n.deps===1))return super.build(e,t,r);r=this.getUUID(!1);let l=this.getTemp(e,r);if(l)return e.format(l,a,t);{l=super.generate(e,t,r,n.output,o);let c=this.generate(e,a,r);return e.addNodeCode(l+" = "+c+";"),e.format(l,a,t)}}return super.build(e,t,r)}getShared(e,t){return t!=="sampler2D"&&t!=="samplerCube"&&this.shared}getUnique(e,t){return this.unique}setLabel(e){return this.label=e,this}getLabel(){return this.label}getUUID(e){let t=this.uuid;return typeof this.scope=="string"&&(t=this.scope+"-"+t),t}getTemp(e,t){t=t||this.uuid;let r=e.getVars()[t];return r?r.name:void 0}generate(e,t,r,o,s){return this.getShared(e,t)||console.error("TempNode is not shared"),r=r!=null?r:this.uuid,e.getTempVar(r,o!=null?o:this.getType(e),s,this.getLabel()).name}};var Ue=class extends me{constructor(e,t){t=t!=null?t:{},t.shared=t.shared!==void 0?t.shared:!1;super(e,t);this.readonly=!1}setReadonly(e){return this.readonly=e,this.hashProperties=this.readonly?["value"]:void 0,this}getReadonly(){return this.readonly}createJSONNode(e){let t=super.createJSONNode(e);return this.readonly===!0&&(t.readonly=this.readonly),t}fromJSON(e,t){return super.fromJSON(e,t),e.readonly!==void 0&&this.setReadonly(e.readonly),this}generate(e,t,r,o,s,n){r=e.getUUID(r!=null?r:this.getUUID()),o=o!=null?o:this.getType(e);let a=e.getNodeData(r);return this.getReadonly()&&this.generateReadonly!==void 0?this.generateReadonly(e,t,r,o,s,n):e.isShader("vertex")?(a.vertex||(a.vertex=e.createVertexUniform(o,this,s,n,this.getLabel())),e.format(a.vertex.name,o,t)):(a.fragment||(a.fragment=e.createFragmentUniform(o,this,s,n,this.getLabel())),e.format(a.fragment.name,o,t))}copy(e){return super.copy(e),this.readonly=e.readonly,this}};var It=class extends Ue{constructor(e=0,t){super("v2");this.nodeType="Vector2";this.value=e instanceof Qu?e:new Qu(e,t)}get x(){return this.value.x}set x(e){this.value.x=e}get y(){return this.value.y}set y(e){this.value.y=e}generateReadonly(e,t,r,o,s,n){return e.format("vec2("+this.value.x+", "+this.value.y+")",o,t)}copy(e){return super.copy(e),this.value.copy(e.value),this}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.x=this.value.x,t.y=this.value.y,this.getReadonly()===!0&&(t.readonly=!0)),t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),e.x&&(this.value.x=e.x),e.y&&(this.value.y=e.y),this}};import{Vector3 as Yu}from"three";var Pt=class extends Ue{constructor(e=0,t,r){super("v3");this.nodeType="Vector3";this.value=e instanceof Yu?e:new Yu(e,t,r)}get x(){return this.value.x}set x(e){this.value.x=e}get y(){return this.value.y}set y(e){this.value.y=e}get z(){return this.value.z}set z(e){this.value.z=e}generateReadonly(e,t,r,o,s,n){return e.format("vec3("+this.value.x+", "+this.value.y+", "+this.value.z+")",o,t)}copy(e){return super.copy(e),this.value.copy(e.value),this}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.x=this.value.x,t.y=this.value.y,t.z=this.value.z,this.getReadonly()===!0&&(t.readonly=!0)),t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),e.x&&(this.value.x=e.x),e.y&&(this.value.y=e.y),e.z&&(this.value.z=e.z),this}};var ao=class extends Ue{constructor(e){super("v4");this.nodeType="Vector4";this.value=e instanceof Jt?e:new Jt(e.r,e.g,e.b,e.a)}generateReadonly(e,t,r,o,s,n){return e.format("vec4("+this.value.r+", "+this.value.g+", "+this.value.b+", "+this.value.a+")",o,t)}copy(e){return super.copy(e),this.value.copy(e.value),this}};var FS=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,ef=/[a-z_0-9]+/gi,oe=class extends me{constructor(e,t,r,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,t,r,o)}getShared(e,t){return!this.isMethod}getType(e){return e.getTypeByFormat(this.type)}getInputByName(e){if(this.inputs){let t=this.inputs.length;for(;t--;)if(this.inputs[t].name===e)return this.inputs[t]}}getIncludeByName(e){if(this.includes){let t=this.includes.length;for(;t--;)if(this.includes[t].name===e)return this.includes[t]}}generate(e,t,r,o,s){let n,a=0,l=this.src;if(this.includes)for(let d=0;d<this.includes.length;d++)e.include(this.includes[d],this);for(let d in this.extensions)e.extensions[d]=!0;let c=[];for(;n=ef.exec(this.src);)c.push(n);for(let d=0;d<c.length;d++){let h=c[d],p=h[0],m=this.isMethod?!this.getInputByName(p):!0,f=p;if(this.keywords[p]||this.useKeywords&&m&&ct.containsKeyword(p)){let x=this.keywords[p];if(!x){let g=ct.getKeywordData(p);g.cache&&(x=e.keywords[p]),x=x||ct.getKeyword(p,e),g.cache&&(e.keywords[p]=x)}f=x.build(e)}p!==f&&(l=l.substring(0,h.index+a)+f+l.substring(h.index+p.length+a),a+=f.length-p.length),this.getIncludeByName(f)===void 0&&ct.contains(f)&&e.include(ct.get(f))}return t==="source"?l:this.isMethod?(this.isInterface||e.include(this,void 0,l),this.name):e.format("( "+l+" )",this.getType(e),t)}parse(e,t,r,o){if(this.src=e||"",this.includes=t!=null?t:[],this.extensions=r!=null?r:{},this.keywords=o!=null?o:{},this.isMethod){let s=FS.exec(this.src);if(this.inputs=[],s&&s.length==4){this.type=s[1],this.name=s[2];let n=s[3].match(ef);if(n){let a=0;for(;a<n.length;){let l=n[a++],c;l==="in"||l==="out"||l==="inout"?c=n[a++]:(c=l,l="");let d=n[a++];this.inputs.push({name:d,type:c,qualifier:l})}}this.isInterface=this.src.indexOf("{")===-1}else this.type="",this.name=""}}copy(e){return super.copy(e),this.isMethod=e.isMethod,this.useKeywords=e.useKeywords,e.type!==void 0&&(this.type=e.type),this.parse(e.src,e.includes,e.extensions,e.keywords),this}toJSON(e){var r;let t=this.getJSONNode(e);if(!t){t=this.createJSONNode(e),t.src=this.src,t.isMethod=this.isMethod,t.useKeywords=this.useKeywords,this.isMethod||(t.type=this.type),t.extensions=JSON.parse(JSON.stringify(this.extensions));let o={};for(let s in this.keywords)o[s]=this.keywords[s].toJSON(e).uuid;if(t.keywords=o,(r=this.includes)==null?void 0:r.length){let s=[];for(let n=0;n<this.includes.length;n++)s.push(this.includes[n].toJSON(e).uuid);t.includes=s}t.isMethod=this.isMethod,t.inputs=this.inputs}return t.nodeType=this.nodeType,t}fromJSON(e,t){if(super.fromJSON(e,t),e.inputs!==void 0&&(this.inputs=e.inputs),e.isMethod!==void 0&&(this.isMethod=e.isMethod),e.src&&(this.src=e.src),e.isMethod&&(this.isMethod=e.isMethod),e.useKeywords&&(this.useKeywords=e.useKeywords),e.type&&(this.type=e.type),e.extensions&&(this.extensions=e.extensions),e.keywords&&t){this.keywords={};for(let r in e.keywords)this.keywords[r]=t.getNode(e.keywords[r])}return e.includes&&t&&(this.includes=e.includes.map(r=>t.getNode(r))),this}};var RS=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=?\s?(.*?)(\;|$)/i,$l=class extends me{constructor(e="",t){super();this.src="";this.useDefine=!1;this.nodeType="Const";this.parse(e||$l.PI,void 0,void 0,void 0,t)}getType(e){return e.getTypeByFormat(this.type)}parse(e,t,r,o,s){this.src=e||"";let n,a,l="",c=RS.exec(e);this.useDefine=s!=null?s:this.src.charAt(0)==="#",c&&c.length>1?(a=c[1],n=c[2],l=c[3]):(n=this.src,a="f"),this.name=n,this.type=a,this.value=l}build(e,t){if(t==="source"){if(this.value)return this.useDefine?"#define "+this.name+" "+this.value:"const "+this.type+" "+this.name+" = "+this.value+";";if(this.useDefine)return this.src}return e.include(this),e.format(this.name,this.getType(e),t)}generate(e,t,r,o,s){return e.format(this.name,this.getType(e),t)}copy(e){return super.copy(e),this.parse(e.src,void 0,void 0,void 0,e.useDefine),this}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.src=this.src,t.useDefine=this.useDefine,t.value=this.value,t.name=this.name),t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),e.src&&(this.src=e.src),e.value&&(this.value=e.value),e.name&&(this.name=e.name),e.useDefine!==void 0&&(this.useDefine=e.useDefine),this}},Me=$l;Me.PI="PI",Me.PI2="PI2",Me.RECIPROCAL_PI="RECIPROCAL_PI",Me.RECIPROCAL_PI2="RECIPROCAL_PI2",Me.LOG2="LOG2",Me.EPSILON="EPSILON";var VS=new RegExp(`^structs*([a-z_0-9]+)s*{s*((.|
2
- )*?)}`,"gim"),kS=new RegExp("s*(w*?)s*(w*?)(=|;)","gim"),Zi=class extends me{constructor(e=""){super();this.inputs=[];this.src="";this.nodeType="Struct";this.parse(e)}getType(e){return e.getTypeByFormat(this.name)}getInputByName(e){let t=this.inputs.length;for(;t--;)if(this.inputs[t].name===e)return this.inputs[t]}generate(e,t,r,o,s){return t==="source"?this.src+";":e.format("( "+this.src+" )",this.getType(e),t)}parse(e=""){this.src=e,this.inputs=[];let t=VS.exec(e);if(t){let r=t[2],o;for(;o=kS.exec(r);)this.inputs.push({type:o[1],name:o[2]});this.name=t[1]}else this.name="";this.type=this.name}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.src=this.src),t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),e.src&&(this.src=e.src,this.parse(this.src)),this}};var Qi=class extends me{constructor(e){super("v2",{shared:!1});this.nodeType="UV";this.index=e!=null?e:0}generate(e,t){e.requires.uv[this.index]=!0;let r=this.index>0?this.index+1:"",o=e.isShader("vertex")?"uv"+r:"vUv"+r;return e.format(o,this.getType(e),t)}copy(e){return super.copy(e),this.index=e.index,this}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.index=this.index),t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),e.index&&(this.index=e.index),this}};ct.addKeyword("uv",function(){return new Qi});ct.addKeyword("uv2",function(){return new Qi(1)});import{LinearEncoding as US,sRGBEncoding as JS}from"three";var Lo=class extends me{constructor(e=new ue,t){super("v4");this.nodeType="ColorSpace";this.factor=new ue;this.input=e,this.method=t!=null?t:Lo.LINEAR_TO_LINEAR,this.hashProperties=["method"]}static getEncodingComponents(e){switch(e){case US:return["Linear"];case JS:return["sRGB"];default:return[]}}generate(e,t){var a;let r=this.input.build(e,"v4"),o=this.getType(e),s=Lo.Nodes[this.method],n=e.include(s);if(n===Lo.LINEAR_TO_LINEAR)return e.format(r,o,t);if(((a=s.inputs)==null?void 0:a.length)===2){let l=this.factor.build(e,"f");return e.format(n+"( "+r+", "+l+" )",o,t)}else return e.format(n+"( "+r+" )",o,t)}fromEncoding(e){let t=Lo.getEncodingComponents(e);this.method="LinearTo"+t[0],this.factor=t[1]}fromDecoding(e){let t=Lo.getEncodingComponents(e);this.method=t[0]+"ToLinear",this.factor=t[1]}copy(e){return super.copy(e),this.input.copy(e.input),this.method=e.method,this.factor.copy(e.factor),this}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.input=this.input.toJSON(e).uuid,t.factor=this.factor.toJSON(e).uuid,t.method=this.method),t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),e.input&&(this.input=t.getNode(e.input)),e.factor&&(this.factor=t.getNode(e.factor)),e.method&&(this.method=e.method),this}},Gt=Lo;Gt.Nodes={LinearToLinear:new oe(["vec4 LinearToLinear( in vec4 value ) {"," return value;","}"].join(`
3
- `)),sRGBToLinear:new oe(["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
- `)),LinearTosRGB:new oe(["vec4 LinearTosRGB( in vec4 value ) {"," return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.w );","}"].join(`
5
- `))},Gt.LINEAR_TO_LINEAR="LinearToLinear",Gt.SRGB_TO_LINEAR="sRGBToLinear",Gt.LINEAR_TO_SRGB="LinearTosRGB";var ze=class extends oe{constructor(e="",t,r,o,s){super(e,s,o,r,t);this.nodeType="Expression"}};import{Texture as HS}from"three";var Vr=class extends HS{toJSON(e){let t=super.toJSON(e),r=e===void 0||typeof e=="string";if(this.image!==void 0&&!r){let o=this.image;if(Array.isArray(o)){e.images[o.uuid].url=[];for(let s=0;s<o.length;s++)e.images[o.uuid].url[s]=tf(o[s])}else e.images[o.uuid].url=tf(o)}return t}};function tf(i){return typeof HTMLImageElement!="undefined"&&i instanceof HTMLImageElement||typeof HTMLCanvasElement!="undefined"&&i instanceof HTMLCanvasElement||typeof ImageBitmap!="undefined"&&i instanceof ImageBitmap?qS(i):(console.warn("THREE.Texture: Unable to serialize Texture."),"")}var fi;function qS(i){if(/^data:/i.test(i.src))return i.src;let e;if(i instanceof HTMLCanvasElement)e=i;else{fi===void 0&&(fi=document.createElement("canvas")),fi.width=i.width,fi.height=i.height;let r=fi.getContext("2d");i instanceof ImageData?r.putImageData(i,0,0):r.drawImage(i,0,0,i.width,i.height),e=fi}let t=i.src.startsWith("blob:")?i.fileName:i.src;return/\.jpe?g$/i.test(t)?e.toDataURL("image/jpeg",.6):e.toDataURL("image/png")}var Et=class extends Ue{constructor(e=new Vr,t,r,o){super("v4",{shared:!0});this.nodeType="Texture";this.value=e,this.uv=t!=null?t:new Qi,this.bias=r,this.project=o!==void 0?o:!1}getTexture(e,t){return super.generate(e,t,this.value.uuid,"t")}generate(e,t){var d;if(t==="sampler2D")return this.getTexture(e,t);let r=this.getTexture(e,t),o=this.uv.build(e,this.project?"v4":"v2"),s=this.bias?this.bias.build(e,"f"):void 0;s===void 0&&e.context.bias&&(s=e.context.bias.setTexture(this).build(e,"f"));let n,a;this.project?n="texture2DProj":n=s?"tex2DBias":"tex2D",s?a=n+"( "+r+", "+o+", "+s+" )":a=n+"( "+r+", "+o+" )";let l={include:e.isShader("vertex"),ignoreCache:!0},c=this.getType(e);return e.addContext(l),this.colorSpace=(d=this.colorSpace)!=null?d:new Gt(new ze("",c)),this.colorSpace.fromDecoding(e.getTextureEncodingFromMap(this.value)),this.colorSpace.input.parse(a),a=this.colorSpace.build(e,c),e.removeContext(),e.format(a,c,t)}copy(e){return super.copy(e),e.value.isRenderTargetTexture?this.value=e.value:this.value.copy(e.value),this.uv.copy(e.uv),e.bias?this.bias?this.bias.copy(e.bias):this.bias=e.bias.clone():this.bias=void 0,e.colorSpace?this.colorSpace?this.colorSpace.copy(e.colorSpace):this.colorSpace=e.colorSpace.clone():this.colorSpace=void 0,this.project=e.project,e.value.isRenderTargetTexture||(this.value.updateMatrix(),this.value.needsUpdate=!0),this}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),this.value&&(t.value=this.value.toJSON(e).uuid),t.uv=this.uv.toJSON(e).uuid,t.project=this.project,this.bias&&(t.bias=this.bias.toJSON(e).uuid)),t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),this.project=e.project,e.value&&(this.value=t.getTexture(e.value),this.value.updateMatrix()),e.uv&&(this.uv=t.getNode(e.uv)),e.bias&&(this.bias=t.getNode(e.bias)),this}};var re=class extends Ue{constructor(e){super("f");this.nodeType="Float";this.value=e!=null?e:0}generateReadonly(e,t,r,o,s,n){return e.format(this.value+(this.value%1?"":".0"),o,t)}copy(e){return super.copy(e),this.value=e.value,this}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.value=this.value,this.getReadonly()===!0&&(t.readonly=!0)),t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),e.value&&(this.value=e.value),this}};var ua=class extends me{constructor(e,t){super();this.inputs=[];this.nodeType="FunctionCall";this.value=e,this.inputs=t!=null?t:[]}getFunction(){return this.value}getType(e){return this.value.getType(e)}generate(e,t,r,o,s){o=this.getType(e);let n=this.value,a=n.build(e,t)+"( ",l=[];if(n.inputs){for(let c=0;c<n.inputs.length;c++){let d=n.inputs[c],h=this.inputs[c]||this.inputs[d.name];l.push(h.build(e,e.getTypeByFormat(d.type)))}a+=l.join(", ")+" )"}return e.format(a,o,t)}copy(e){return super.copy(e),this.value.copy(e.value),this.inputs=e.inputs.map(t=>t.clone()),this}toJSON(e){var r;let t=this.getJSONNode(e);if(!t){let o=this.value;if(t=this.createJSONNode(e),t.value=this.value.toJSON(e).uuid,(r=o.inputs)==null?void 0:r.length){t.inputs={};for(let s=0;s<o.inputs.length;s++){let n=o.inputs[s],a=this.inputs[s];t.inputs[n.name]=a.toJSON(e).uuid}}}return t}};var mi;(function(o){o.ADD="+",o.SUB="-",o.MUL="*",o.DIV="/"})(mi||(mi={}));var Kl=class extends me{constructor(e=new ue,t=new ue,r=Kl.ADD){super();this.nodeType="Operator";this.type=e.type,this.a=e,this.b=t,this.op=r}getType(e){let t=this.a.getType(e),r=this.b.getType(e);return e.isTypeMatrix(t)?"v4":e.getTypeLength(r)>e.getTypeLength(t)?r:t}generate(e,t){let r=this.getType(e);this.type=r;let o=this.a.build(e,r),s=this.b.build(e,r);return e.format("( "+o+" "+this.op+" "+s+" )",r,t)}copy(e){return super.copy(e),this.a.copy(e.a),this.b.copy(e.b),this.op=e.op,this}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.a=this.a.toJSON(e).uuid,t.b=this.b.toJSON(e).uuid,t.op=this.op),t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),e.a&&(this.a=t.getNode(e.a)),e.b&&(this.b=t.getNode(e.b)),e.op&&(this.op=e.op),this}},Ht=Kl;Ht.ADD=mi.ADD,Ht.SUB=mi.SUB,Ht.MUL=mi.MUL,Ht.DIV=mi.DIV;var ve;(function(y){y.RAD="radians",y.DEG="degrees",y.EXP="exp",y.EXP2="exp2",y.LOG="log",y.LOG2="log2",y.SQRT="sqrt",y.INV_SQRT="inversesqrt",y.FLOOR="floor",y.CEIL="ceil",y.NORMALIZE="normalize",y.FRACT="fract",y.SATURATE="saturate",y.SIN="sin",y.COS="cos",y.TAN="tan",y.ASIN="asin",y.ACOS="acos",y.ARCTAN="atan",y.ABS="abs",y.SIGN="sign",y.LENGTH="length",y.NEGATE="negate",y.INVERT="invert",y.MIN="min",y.MAX="max",y.MOD="mod",y.STEP="step",y.REFLECT="reflect",y.DISTANCE="distance",y.DOT="dot",y.CROSS="cross",y.POW="pow",y.MIX="mix",y.CLAMP="clamp",y.REFRACT="refract",y.SMOOTHSTEP="smoothstep",y.FACEFORWARD="faceforward"})(ve||(ve={}));var je=class extends me{constructor(e=new ue,t=je.ABS,r,o){super();this.nodeType="Math";this.a=e,typeof t!="string"?this.b=t:o=t,typeof r!="string"?this.c=r:o=r,this.method=o,this.hashProperties=["method"]}getNumInputs(e){switch(this.method){case je.MIX:case je.CLAMP:case je.REFRACT:case je.SMOOTHSTEP:case je.FACEFORWARD:return 3;case je.MIN:case je.MAX:case je.MOD:case je.STEP:case je.REFLECT:case je.DISTANCE:case je.DOT:case je.CROSS:case je.POW:return 2;default:return 1}}getInputType(e){let t=e.getTypeLength(this.a.getType(e)),r=this.b?e.getTypeLength(this.b.getType(e)):0,o=this.c?e.getTypeLength(this.c.getType(e)):0;return t>r&&t>o?this.a.getType(e):r>o?this.b.getType(e):this.c.getType(e)}getType(e){switch(this.method){case je.LENGTH:case je.DISTANCE:case je.DOT:return"f";case je.CROSS:return"v3"}return this.getInputType(e)}generate(e,t){let r,o,s,n=this.a?e.getTypeLength(this.a.getType(e)):0,a=this.b?e.getTypeLength(this.b.getType(e)):0,l=this.c?e.getTypeLength(this.c.getType(e)):0,c=this.getInputType(e),d=this.getType(e);switch(this.type=d,this.method){case je.NEGATE:return e.format("( -"+this.a.build(e,c)+" )",c,t);case je.INVERT:return e.format("( 1.0 - "+this.a.build(e,c)+" )",c,t);case je.CROSS:r=this.a.build(e,"v3"),o=this.b.build(e,"v3");break;case je.STEP:r=this.a.build(e,n===1?"f":c),o=this.b.build(e,c);break;case je.MIN:case je.MAX:case je.MOD:r=this.a.build(e,c),o=this.b.build(e,a===1?"f":c);break;case je.REFRACT:r=this.a.build(e,c),o=this.b.build(e,c),s=this.c.build(e,"f");break;case je.MIX:r=this.a.build(e,c),o=this.b.build(e,c),s=this.c.build(e,l===1?"f":c);break;default:r=this.a.build(e,c),this.b&&(o=this.b.build(e,c)),this.c&&(s=this.c.build(e,c));break}let h=[];h.push(r),o&&h.push(o),s&&h.push(s);let p=this.getNumInputs(e);if(h.length!==p)throw Error(`Arguments not match used in "${this.method}". Require ${p}, currently ${h.length}.`);return e.format(this.method+"( "+h.join(", ")+" )",d,t)}copy(e){return super.copy(e),this.a.copy(e.a),this.b=e.b instanceof ue?e.b.clone():e.b,this.c=e.c instanceof ue?e.c.clone():e.c,this.method=e.method,this}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.a=this.a.toJSON(e).uuid,this.b&&(t.b=this.b.toJSON(e).uuid),this.c&&(t.c=this.c.toJSON(e).uuid),t.method=this.method),t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),e.a&&(this.a=t.getNode(e.a)),e.b&&(this.b=t.getNode(e.b)),e.c&&(this.c=t.getNode(e.c)),e.method&&(this.method=e.method),this}},ge=je;ge.RAD=ve.RAD,ge.DEG=ve.DEG,ge.EXP=ve.EXP,ge.EXP2=ve.EXP2,ge.LOG=ve.LOG,ge.LOG2=ve.LOG2,ge.SQRT=ve.SQRT,ge.INV_SQRT=ve.INV_SQRT,ge.FLOOR=ve.FLOOR,ge.CEIL=ve.CEIL,ge.NORMALIZE=ve.NORMALIZE,ge.FRACT=ve.FRACT,ge.SATURATE=ve.SATURATE,ge.SIN=ve.SIN,ge.COS=ve.COS,ge.TAN=ve.TAN,ge.ASIN=ve.ASIN,ge.ACOS=ve.ACOS,ge.ARCTAN=ve.ARCTAN,ge.ABS=ve.ABS,ge.SIGN=ve.SIGN,ge.LENGTH=ve.LENGTH,ge.NEGATE=ve.NEGATE,ge.INVERT=ve.INVERT,ge.MIN=ve.MIN,ge.MAX=ve.MAX,ge.MOD=ve.MOD,ge.STEP=ve.STEP,ge.REFLECT=ve.REFLECT,ge.DISTANCE=ve.DISTANCE,ge.DOT=ve.DOT,ge.CROSS=ve.CROSS,ge.POW=ve.POW,ge.MIX=ve.MIX,ge.CLAMP=ve.CLAMP,ge.REFRACT=ve.REFRACT,ge.SMOOTHSTEP=ve.SMOOTHSTEP,ge.FACEFORWARD=ve.FACEFORWARD;var gi=class extends me{constructor(e=new ue,t=new ue,r=new ue){super("v4");this.nodeType="TextureCubeUV";this.value=e,this.uv=t,this.bias=r}bilinearCubeUV(e,t,r,o){var l,c,d,h;let s=new ua(gi.Nodes.bilinearCubeUV,[t,r,o]);this.colorSpaceTL=(l=this.colorSpaceTL)!=null?l:new Gt(new ze("","v4")),this.colorSpaceTL.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceTL.input.parse(s.build(e)+".tl"),this.colorSpaceTR=(c=this.colorSpaceTR)!=null?c:new Gt(new ze("","v4")),this.colorSpaceTR.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceTR.input.parse(s.build(e)+".tr"),this.colorSpaceBL=(d=this.colorSpaceBL)!=null?d:new Gt(new ze("","v4")),this.colorSpaceBL.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceBL.input.parse(s.build(e)+".bl"),this.colorSpaceBR=(h=this.colorSpaceBR)!=null?h:new Gt(new ze("","v4")),this.colorSpaceBR.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceBR.input.parse(s.build(e)+".br");let n={include:e.isShader("vertex"),ignoreCache:!0};e.addContext(n),this.colorSpaceTLExp=new ze(this.colorSpaceTL.build(e,"v4"),"v4"),this.colorSpaceTRExp=new ze(this.colorSpaceTR.build(e,"v4"),"v4"),this.colorSpaceBLExp=new ze(this.colorSpaceBL.build(e,"v4"),"v4"),this.colorSpaceBRExp=new ze(this.colorSpaceBR.build(e,"v4"),"v4"),e.removeContext();let a=new ze("mix( mix( cubeUV_TL, cubeUV_TR, cubeUV.f.x ), mix( cubeUV_BL, cubeUV_BR, cubeUV.f.x ), cubeUV.f.y )","v4");return a.keywords.cubeUV_TL=this.colorSpaceTLExp,a.keywords.cubeUV_TR=this.colorSpaceTRExp,a.keywords.cubeUV_BL=this.colorSpaceBLExp,a.keywords.cubeUV_BR=this.colorSpaceBRExp,a.keywords.cubeUV=s,a}generate(e,t){if(e.isShader("fragment")){let r=this.uv,o=this.bias||e.context.roughness,s=new ua(gi.Nodes.roughnessToMip,[o]),n=new ge(s,gi.Nodes.m0,gi.Nodes.cubeUV_maxMipLevel,ge.CLAMP),a=new ge(n,ge.FLOOR),l=new ge(n,ge.FRACT),c=this.bilinearCubeUV(e,this.value,r,a),d=this.bilinearCubeUV(e,this.value,r,new Ht(a,new re(1).setReadonly(!0),Ht.ADD)),h=new ge(c,d,l,ge.MIX);return e.format(h.build(e),"v4",t)}else return console.warn("TextureCubeUVNode is not compatible with "+e.shader+" shader."),e.format("vec4( 0.0 )",this.getType(e),t)}copy(e){return super.copy(e),this.uv.copy(e.uv),this.bias.copy(e.bias),this.value.copy(e.value),e.colorSpaceTL?this.colorSpaceTL?this.colorSpaceTL.copy(e.colorSpaceTL):this.colorSpaceTL=e.colorSpaceTL.clone():this.colorSpaceTL=void 0,e.colorSpaceTR?this.colorSpaceTR?this.colorSpaceTR.copy(e.colorSpaceTR):this.colorSpaceTR=e.colorSpaceTR.clone():this.colorSpaceTR=void 0,e.colorSpaceBL?this.colorSpaceBL?this.colorSpaceBL.copy(e.colorSpaceBL):this.colorSpaceBL=e.colorSpaceBL.clone():this.colorSpaceBL=void 0,e.colorSpaceBR?this.colorSpaceBR?this.colorSpaceBR.copy(e.colorSpaceBR):this.colorSpaceBR=e.colorSpaceBR.clone():this.colorSpaceBR=void 0,e.colorSpaceTLExp?this.colorSpaceTLExp?this.colorSpaceTLExp.copy(e.colorSpaceTLExp):this.colorSpaceTLExp=e.colorSpaceTLExp.clone():this.colorSpaceTLExp=void 0,e.colorSpaceTRExp?this.colorSpaceTRExp?this.colorSpaceTRExp.copy(e.colorSpaceTRExp):this.colorSpaceTRExp=e.colorSpaceTRExp.clone():this.colorSpaceTRExp=void 0,e.colorSpaceBLExp?this.colorSpaceBLExp?this.colorSpaceBLExp.copy(e.colorSpaceBLExp):this.colorSpaceBLExp=e.colorSpaceBLExp.clone():this.colorSpaceBLExp=void 0,e.colorSpaceBRExp?this.colorSpaceBRExp?this.colorSpaceBRExp.copy(e.colorSpaceBRExp):this.colorSpaceBRExp=e.colorSpaceBRExp.clone():this.colorSpaceBRExp=void 0,this}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.value=this.value.toJSON(e).uuid,t.uv=this.uv.toJSON(e).uuid,t.bias=this.bias.toJSON(e).uuid,this.colorSpaceTL&&this.colorSpaceTL.toJSON(e).uuid,this.colorSpaceTR&&this.colorSpaceTR.toJSON(e).uuid,this.colorSpaceBL&&this.colorSpaceBL.toJSON(e).uuid,this.colorSpaceBR&&this.colorSpaceBR.toJSON(e).uuid,this.colorSpaceTLExp&&this.colorSpaceTLExp.toJSON(e).uuid,this.colorSpaceTRExp&&this.colorSpaceTRExp.toJSON(e).uuid,this.colorSpaceBLExp&&this.colorSpaceBLExp.toJSON(e).uuid,this.colorSpaceBRExp&&this.colorSpaceBRExp.toJSON(e).uuid),t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),e.value&&(this.value=t.getNode(e.value)),e.uv&&(this.uv=t.getNode(e.uv)),e.bias&&(this.bias=t.getNode(e.bias)),e.colorSpaceTL&&(this.colorSpaceTL=t.getNode(e.colorSpaceTL)),e.colorSpaceTR&&(this.colorSpaceTR=t.getNode(e.colorSpaceTR)),e.colorSpaceBL&&(this.colorSpaceBL=t.getNode(e.colorSpaceBL)),e.colorSpaceBR&&(this.colorSpaceBR=t.getNode(e.colorSpaceBR)),e.colorSpaceTLExp&&(this.colorSpaceTLExp=t.getNode(e.colorSpaceTLExp)),e.colorSpaceTRExp&&(this.colorSpaceTRExp=t.getNode(e.colorSpaceTRExp)),e.colorSpaceBLExp&&(this.colorSpaceBLExp=t.getNode(e.colorSpaceBLExp)),e.colorSpaceBRExp&&(this.colorSpaceBRExp=t.getNode(e.colorSpaceBRExp)),this}},Yi=gi;Yi.Nodes=function(){let e=new Zi(`struct TextureCubeUVData {
1
+ var zm=Object.create;var Ti=Object.defineProperty,Em=Object.defineProperties,Fm=Object.getOwnPropertyDescriptor,Rm=Object.getOwnPropertyDescriptors,Vm=Object.getOwnPropertyNames,gc=Object.getOwnPropertySymbols,Um=Object.getPrototypeOf,xc=Object.prototype.hasOwnProperty,km=Object.prototype.propertyIsEnumerable;var bc=(i,e,t)=>e in i?Ti(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,O=(i,e)=>{for(var t in e||(e={}))xc.call(e,t)&&bc(i,t,e[t]);if(gc)for(var t of gc(e))km.call(e,t)&&bc(i,t,e[t]);return i},$=(i,e)=>Em(i,Rm(e)),vc=i=>Ti(i,"__esModule",{value:!0});var Sc=(i,e)=>()=>(e||i((e={exports:{}}).exports,e),e.exports),Hm=(i,e)=>{vc(i);for(var t in e)Ti(i,t,{get:e[t],enumerable:!0})},qm=(i,e,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of Vm(e))!xc.call(i,r)&&r!=="default"&&Ti(i,r,{get:()=>e[r],enumerable:!(t=Fm(e,r))||t.enumerable});return i},wc=i=>qm(vc(Ti(i!=null?zm(Um(i)):{},"default",i&&i.__esModule&&"default"in i?{get:()=>i.default,enumerable:!0}:{value:i,enumerable:!0})),i);var Oh=Sc(Qs=>{"use strict";Qs.byteLength=aS;Qs.toByteArray=cS;Qs.fromByteArray=uS;var Sr=[],Yt=[],sS=typeof Uint8Array!="undefined"?Uint8Array:Array,Al="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(Co=0,Mh=Al.length;Co<Mh;++Co)Sr[Co]=Al[Co],Yt[Al.charCodeAt(Co)]=Co;var Co,Mh;Yt["-".charCodeAt(0)]=62;Yt["_".charCodeAt(0)]=63;function Ph(i){var e=i.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var t=i.indexOf("=");t===-1&&(t=e);var r=t===e?0:4-t%4;return[t,r]}function aS(i){var e=Ph(i),t=e[0],r=e[1];return(t+r)*3/4-r}function lS(i,e,t){return(e+t)*3/4-t}function cS(i){var e,t=Ph(i),r=t[0],o=t[1],n=new sS(lS(i,r,o)),s=0,a=o>0?r-4:r,l;for(l=0;l<a;l+=4)e=Yt[i.charCodeAt(l)]<<18|Yt[i.charCodeAt(l+1)]<<12|Yt[i.charCodeAt(l+2)]<<6|Yt[i.charCodeAt(l+3)],n[s++]=e>>16&255,n[s++]=e>>8&255,n[s++]=e&255;return o===2&&(e=Yt[i.charCodeAt(l)]<<2|Yt[i.charCodeAt(l+1)]>>4,n[s++]=e&255),o===1&&(e=Yt[i.charCodeAt(l)]<<10|Yt[i.charCodeAt(l+1)]<<4|Yt[i.charCodeAt(l+2)]>>2,n[s++]=e>>8&255,n[s++]=e&255),n}function dS(i){return Sr[i>>18&63]+Sr[i>>12&63]+Sr[i>>6&63]+Sr[i&63]}function pS(i,e,t){for(var r,o=[],n=e;n<t;n+=3)r=(i[n]<<16&16711680)+(i[n+1]<<8&65280)+(i[n+2]&255),o.push(dS(r));return o.join("")}function uS(i){for(var e,t=i.length,r=t%3,o=[],n=16383,s=0,a=t-r;s<a;s+=n)o.push(pS(i,s,s+n>a?a:s+n));return r===1?(e=i[t-1],o.push(Sr[e>>2]+Sr[e<<4&63]+"==")):r===2&&(e=(i[t-2]<<8)+i[t-1],o.push(Sr[e>>10]+Sr[e>>4&63]+Sr[e<<2&63]+"=")),o.join("")}});var Sm=Sc((Ia,vm)=>{(function(i,e){typeof Ia=="object"&&typeof vm!="undefined"?e(Ia):typeof define=="function"&&define.amd?define(["exports"],e):e((i=typeof globalThis!="undefined"?globalThis:i||self).SVDJS={})})(Ia,function(i){"use strict";i.SVD=function(e,t,r,o,n){if(t=t===void 0||t,r=r===void 0||r,n=1e-64/(o=o||Math.pow(2,-52)),!e)throw new TypeError("Matrix a is not defined");var s,a,l,c,d,p,u,f,m,x,y,N,L=e[0].length,w=e.length;if(w<L)throw new TypeError("Invalid matrix: m < n");for(var B=[],S=[],_=[],T=t==="f"?w:L,h=x=u=0;h<w;h++)S[h]=new Array(T).fill(0);for(h=0;h<L;h++)_[h]=new Array(L).fill(0);var I,b=new Array(L).fill(0);for(h=0;h<w;h++)for(s=0;s<L;s++)S[h][s]=e[h][s];for(h=0;h<L;h++){for(B[h]=u,m=0,l=h+1,s=h;s<w;s++)m+=Math.pow(S[s][h],2);if(m<n)u=0;else for(f=(p=S[h][h])*(u=p<0?Math.sqrt(m):-Math.sqrt(m))-m,S[h][h]=p-u,s=l;s<L;s++){for(m=0,a=h;a<w;a++)m+=S[a][h]*S[a][s];for(p=m/f,a=h;a<w;a++)S[a][s]=S[a][s]+p*S[a][h]}for(b[h]=u,m=0,s=l;s<L;s++)m+=Math.pow(S[h][s],2);if(m<n)u=0;else{for(f=(p=S[h][h+1])*(u=p<0?Math.sqrt(m):-Math.sqrt(m))-m,S[h][h+1]=p-u,s=l;s<L;s++)B[s]=S[h][s]/f;for(s=l;s<w;s++){for(m=0,a=l;a<L;a++)m+=S[s][a]*S[h][a];for(a=l;a<L;a++)S[s][a]=S[s][a]+m*B[a]}}x<(y=Math.abs(b[h])+Math.abs(B[h]))&&(x=y)}if(r)for(h=L-1;0<=h;h--){if(u!==0){for(f=S[h][h+1]*u,s=l;s<L;s++)_[s][h]=S[h][s]/f;for(s=l;s<L;s++){for(m=0,a=l;a<L;a++)m+=S[h][a]*_[a][s];for(a=l;a<L;a++)_[a][s]=_[a][s]+m*_[a][h]}}for(s=l;s<L;s++)_[h][s]=0,_[s][h]=0;_[h][h]=1,u=B[h],l=h}if(t){if(t==="f")for(h=L;h<w;h++){for(s=L;s<w;s++)S[h][s]=0;S[h][h]=1}for(h=L-1;0<=h;h--){for(l=h+1,u=b[h],s=l;s<T;s++)S[h][s]=0;if(u!==0){for(f=S[h][h]*u,s=l;s<T;s++){for(m=0,a=l;a<w;a++)m+=S[a][h]*S[a][s];for(p=m/f,a=h;a<w;a++)S[a][s]=S[a][s]+p*S[a][h]}for(s=h;s<w;s++)S[s][h]=S[s][h]/u}else for(s=h;s<w;s++)S[s][h]=0;S[h][h]=S[h][h]+1}}for(o*=x,a=L-1;0<=a;a--)for(var P=0;P<50;P++){for(I=!1,l=a;0<=l;l--){if(Math.abs(B[l])<=o){I=!0;break}if(Math.abs(b[l-1])<=o)break}if(!I){for(d=0,c=l-(m=1),h=l;h<a+1&&(p=m*B[h],B[h]=d*B[h],!(Math.abs(p)<=o));h++)if(u=b[h],b[h]=Math.sqrt(p*p+u*u),d=u/(f=b[h]),m=-p/f,t)for(s=0;s<w;s++)y=S[s][c],N=S[s][h],S[s][c]=y*d+N*m,S[s][h]=-y*m+N*d}if(N=b[a],l===a){if(N<0&&(b[a]=-N,r))for(s=0;s<L;s++)_[s][a]=-_[s][a];break}for(x=b[l],p=(((y=b[a-1])-N)*(y+N)+((u=B[a-1])-(f=B[a]))*(u+f))/(2*f*y),u=Math.sqrt(p*p+1),p=((x-N)*(x+N)+f*(y/(p<0?p-u:p+u)-f))/x,h=l+(m=d=1);h<a+1;h++){if(u=B[h],y=b[h],f=m*u,u*=d,N=Math.sqrt(p*p+f*f),p=x*(d=p/(B[h-1]=N))+u*(m=f/N),u=-x*m+u*d,f=y*m,y*=d,r)for(s=0;s<L;s++)x=_[s][h-1],N=_[s][h],_[s][h-1]=x*d+N*m,_[s][h]=-x*m+N*d;if(N=Math.sqrt(p*p+f*f),p=(d=p/(b[h-1]=N))*u+(m=f/N)*y,x=-m*u+d*y,t)for(s=0;s<w;s++)y=S[s][h-1],N=S[s][h],S[s][h-1]=y*d+N*m,S[s][h]=-y*m+N*d}B[l]=0,B[a]=p,b[a]=x}for(h=0;h<L;h++)b[h]<o&&(b[h]=0);return{u:S,q:b,v:_}},i.VERSION="1.1.1",Object.defineProperty(i,"__esModule",{value:!0})})});import{FileLoader as h1,Loader as m1}from"three";function Nc(i){return Array.isArray(i)?i:[i]}var Wm=typeof global=="object"&&global&&global.Object===Object&&global,Tn=Wm;var $m=typeof self=="object"&&self&&self.Object===Object&&self,Jm=Tn||$m||Function("return this")(),et=Jm;var Km=et.Symbol,Ct=Km;var Cc=Object.prototype,Xm=Cc.hasOwnProperty,Zm=Cc.toString,Ii=Ct?Ct.toStringTag:void 0;function Qm(i){var e=Xm.call(i,Ii),t=i[Ii];try{i[Ii]=void 0;var r=!0}catch(n){}var o=Zm.call(i);return r&&(e?i[Ii]=t:delete i[Ii]),o}var Lc=Qm;var Ym=Object.prototype,ef=Ym.toString;function tf(i){return ef.call(i)}var Tc=tf;var rf="[object Null]",of="[object Undefined]",Ic=Ct?Ct.toStringTag:void 0;function nf(i){return i==null?i===void 0?of:rf:Ic&&Ic in Object(i)?Lc(i):Tc(i)}var Ft=nf;function sf(i){return i!=null&&typeof i=="object"}var vt=sf;var af="[object Symbol]";function lf(i){return typeof i=="symbol"||vt(i)&&Ft(i)==af}var _o=lf;function cf(i,e){for(var t=-1,r=i==null?0:i.length,o=Array(r);++t<r;)o[t]=e(i[t],t,i);return o}var In=cf;var df=Array.isArray,ht=df;var pf=1/0,Mc=Ct?Ct.prototype:void 0,Pc=Mc?Mc.toString:void 0;function Oc(i){if(typeof i=="string")return i;if(ht(i))return In(i,Oc)+"";if(_o(i))return Pc?Pc.call(i):"";var e=i+"";return e=="0"&&1/i==-pf?"-0":e}var Ac=Oc;function uf(i){var e=typeof i;return i!=null&&(e=="object"||e=="function")}var St=uf;function hf(i){return i}var Mn=hf;var mf="[object AsyncFunction]",ff="[object Function]",yf="[object GeneratorFunction]",gf="[object Proxy]";function xf(i){if(!St(i))return!1;var e=Ft(i);return e==ff||e==yf||e==mf||e==gf}var Do=xf;var bf=et["__core-js_shared__"],Pn=bf;var jc=function(){var i=/[^.]+$/.exec(Pn&&Pn.keys&&Pn.keys.IE_PROTO||"");return i?"Symbol(src)_1."+i:""}();function vf(i){return!!jc&&jc in i}var _c=vf;var Sf=Function.prototype,wf=Sf.toString;function Nf(i){if(i!=null){try{return wf.call(i)}catch(e){}try{return i+""}catch(e){}}return""}var Pr=Nf;var Cf=/[\\^$.*+?()[\]{}|]/g,Lf=/^\[object .+?Constructor\]$/,Tf=Function.prototype,If=Object.prototype,Mf=Tf.toString,Pf=If.hasOwnProperty,Of=RegExp("^"+Mf.call(Pf).replace(Cf,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Af(i){if(!St(i)||_c(i))return!1;var e=Do(i)?Of:Lf;return e.test(Pr(i))}var Dc=Af;function jf(i,e){return i==null?void 0:i[e]}var Bc=jf;function _f(i,e){var t=Bc(i,e);return Dc(t)?t:void 0}var Ot=_f;var Df=Ot(et,"WeakMap"),On=Df;var Gc=Object.create,Bf=function(){function i(){}return function(e){if(!St(e))return{};if(Gc)return Gc(e);i.prototype=e;var t=new i;return i.prototype=void 0,t}}(),zc=Bf;function Gf(i,e,t){switch(t.length){case 0:return i.call(e);case 1:return i.call(e,t[0]);case 2:return i.call(e,t[0],t[1]);case 3:return i.call(e,t[0],t[1],t[2])}return i.apply(e,t)}var Ec=Gf;function zf(i,e){var t=-1,r=i.length;for(e||(e=Array(r));++t<r;)e[t]=i[t];return e}var An=zf;var Ef=800,Ff=16,Rf=Date.now;function Vf(i){var e=0,t=0;return function(){var r=Rf(),o=Ff-(r-t);if(t=r,o>0){if(++e>=Ef)return arguments[0]}else e=0;return i.apply(void 0,arguments)}}var Fc=Vf;function Uf(i){return function(){return i}}var Rc=Uf;var kf=function(){try{var i=Ot(Object,"defineProperty");return i({},"",{}),i}catch(e){}}(),Bo=kf;var Hf=Bo?function(i,e){return Bo(i,"toString",{configurable:!0,enumerable:!1,value:Rc(e),writable:!0})}:Mn,Vc=Hf;var qf=Fc(Vc),jn=qf;function Wf(i,e){for(var t=-1,r=i==null?0:i.length;++t<r&&e(i[t],t,i)!==!1;);return i}var Uc=Wf;var $f=9007199254740991,Jf=/^(?:0|[1-9]\d*)$/;function Kf(i,e){var t=typeof i;return e=e==null?$f:e,!!e&&(t=="number"||t!="symbol"&&Jf.test(i))&&i>-1&&i%1==0&&i<e}var _n=Kf;function Xf(i,e,t){e=="__proto__"&&Bo?Bo(i,e,{configurable:!0,enumerable:!0,value:t,writable:!0}):i[e]=t}var Go=Xf;function Zf(i,e){return i===e||i!==i&&e!==e}var qr=Zf;var Qf=Object.prototype,Yf=Qf.hasOwnProperty;function ey(i,e,t){var r=i[e];(!(Yf.call(i,e)&&qr(r,t))||t===void 0&&!(e in i))&&Go(i,e,t)}var Dn=ey;function ty(i,e,t,r){var o=!t;t||(t={});for(var n=-1,s=e.length;++n<s;){var a=e[n],l=r?r(t[a],i[a],a,t,i):void 0;l===void 0&&(l=i[a]),o?Go(t,a,l):Dn(t,a,l)}return t}var Kt=ty;var kc=Math.max;function ry(i,e,t){return e=kc(e===void 0?i.length-1:e,0),function(){for(var r=arguments,o=-1,n=kc(r.length-e,0),s=Array(n);++o<n;)s[o]=r[e+o];o=-1;for(var a=Array(e+1);++o<e;)a[o]=r[o];return a[e]=t(s),Ec(i,this,a)}}var Bn=ry;function oy(i,e){return jn(Bn(i,e,Mn),i+"")}var Hc=oy;var iy=9007199254740991;function ny(i){return typeof i=="number"&&i>-1&&i%1==0&&i<=iy}var Gn=ny;function sy(i){return i!=null&&Gn(i.length)&&!Do(i)}var Wr=sy;function ay(i,e,t){if(!St(t))return!1;var r=typeof e;return(r=="number"?Wr(t)&&_n(e,t.length):r=="string"&&e in t)?qr(t[e],i):!1}var qc=ay;function ly(i){return Hc(function(e,t){var r=-1,o=t.length,n=o>1?t[o-1]:void 0,s=o>2?t[2]:void 0;for(n=i.length>3&&typeof n=="function"?(o--,n):void 0,s&&qc(t[0],t[1],s)&&(n=o<3?void 0:n,o=1),e=Object(e);++r<o;){var a=t[r];a&&i(e,a,r,n)}return e})}var Wc=ly;var cy=Object.prototype;function dy(i){var e=i&&i.constructor,t=typeof e=="function"&&e.prototype||cy;return i===t}var zo=dy;function py(i,e){for(var t=-1,r=Array(i);++t<i;)r[t]=e(t);return r}var $c=py;var uy="[object Arguments]";function hy(i){return vt(i)&&Ft(i)==uy}var Pa=hy;var Jc=Object.prototype,my=Jc.hasOwnProperty,fy=Jc.propertyIsEnumerable,yy=Pa(function(){return arguments}())?Pa:function(i){return vt(i)&&my.call(i,"callee")&&!fy.call(i,"callee")},mo=yy;function gy(){return!1}var Kc=gy;var Xc=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Zc=Xc&&typeof module=="object"&&module&&!module.nodeType&&module,xy=Zc&&Zc.exports===Xc,Qc=xy?et.Buffer:void 0,by=Qc?Qc.isBuffer:void 0,vy=by||Kc,Eo=vy;var Sy="[object Arguments]",wy="[object Array]",Ny="[object Boolean]",Cy="[object Date]",Ly="[object Error]",Ty="[object Function]",Iy="[object Map]",My="[object Number]",Py="[object Object]",Oy="[object RegExp]",Ay="[object Set]",jy="[object String]",_y="[object WeakMap]",Dy="[object ArrayBuffer]",By="[object DataView]",Gy="[object Float32Array]",zy="[object Float64Array]",Ey="[object Int8Array]",Fy="[object Int16Array]",Ry="[object Int32Array]",Vy="[object Uint8Array]",Uy="[object Uint8ClampedArray]",ky="[object Uint16Array]",Hy="[object Uint32Array]",Ve={};Ve[Gy]=Ve[zy]=Ve[Ey]=Ve[Fy]=Ve[Ry]=Ve[Vy]=Ve[Uy]=Ve[ky]=Ve[Hy]=!0;Ve[Sy]=Ve[wy]=Ve[Dy]=Ve[Ny]=Ve[By]=Ve[Cy]=Ve[Ly]=Ve[Ty]=Ve[Iy]=Ve[My]=Ve[Py]=Ve[Oy]=Ve[Ay]=Ve[jy]=Ve[_y]=!1;function qy(i){return vt(i)&&Gn(i.length)&&!!Ve[Ft(i)]}var Yc=qy;function Wy(i){return function(e){return i(e)}}var Fo=Wy;var ed=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Mi=ed&&typeof module=="object"&&module&&!module.nodeType&&module,$y=Mi&&Mi.exports===ed,Oa=$y&&Tn.process,Jy=function(){try{var i=Mi&&Mi.require&&Mi.require("util").types;return i||Oa&&Oa.binding&&Oa.binding("util")}catch(e){}}(),Or=Jy;var td=Or&&Or.isTypedArray,Ky=td?Fo(td):Yc,zn=Ky;var Xy=Object.prototype,Zy=Xy.hasOwnProperty;function Qy(i,e){var t=ht(i),r=!t&&mo(i),o=!t&&!r&&Eo(i),n=!t&&!r&&!o&&zn(i),s=t||r||o||n,a=s?$c(i.length,String):[],l=a.length;for(var c in i)(e||Zy.call(i,c))&&!(s&&(c=="length"||o&&(c=="offset"||c=="parent")||n&&(c=="buffer"||c=="byteLength"||c=="byteOffset")||_n(c,l)))&&a.push(c);return a}var En=Qy;function Yy(i,e){return function(t){return i(e(t))}}var Fn=Yy;var eg=Fn(Object.keys,Object),rd=eg;var tg=Object.prototype,rg=tg.hasOwnProperty;function og(i){if(!zo(i))return rd(i);var e=[];for(var t in Object(i))rg.call(i,t)&&t!="constructor"&&e.push(t);return e}var od=og;function ig(i){return Wr(i)?En(i):od(i)}var Ro=ig;function ng(i){var e=[];if(i!=null)for(var t in Object(i))e.push(t);return e}var id=ng;var sg=Object.prototype,ag=sg.hasOwnProperty;function lg(i){if(!St(i))return id(i);var e=zo(i),t=[];for(var r in i)r=="constructor"&&(e||!ag.call(i,r))||t.push(r);return t}var nd=lg;function cg(i){return Wr(i)?En(i,!0):nd(i)}var hr=cg;var dg=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,pg=/^\w*$/;function ug(i,e){if(ht(i))return!1;var t=typeof i;return t=="number"||t=="symbol"||t=="boolean"||i==null||_o(i)?!0:pg.test(i)||!dg.test(i)||e!=null&&i in Object(e)}var sd=ug;var hg=Ot(Object,"create"),Ar=hg;function mg(){this.__data__=Ar?Ar(null):{},this.size=0}var ad=mg;function fg(i){var e=this.has(i)&&delete this.__data__[i];return this.size-=e?1:0,e}var ld=fg;var yg="__lodash_hash_undefined__",gg=Object.prototype,xg=gg.hasOwnProperty;function bg(i){var e=this.__data__;if(Ar){var t=e[i];return t===yg?void 0:t}return xg.call(e,i)?e[i]:void 0}var cd=bg;var vg=Object.prototype,Sg=vg.hasOwnProperty;function wg(i){var e=this.__data__;return Ar?e[i]!==void 0:Sg.call(e,i)}var dd=wg;var Ng="__lodash_hash_undefined__";function Cg(i,e){var t=this.__data__;return this.size+=this.has(i)?0:1,t[i]=Ar&&e===void 0?Ng:e,this}var pd=Cg;function Vo(i){var e=-1,t=i==null?0:i.length;for(this.clear();++e<t;){var r=i[e];this.set(r[0],r[1])}}Vo.prototype.clear=ad;Vo.prototype.delete=ld;Vo.prototype.get=cd;Vo.prototype.has=dd;Vo.prototype.set=pd;var Aa=Vo;function Lg(){this.__data__=[],this.size=0}var ud=Lg;function Tg(i,e){for(var t=i.length;t--;)if(qr(i[t][0],e))return t;return-1}var $r=Tg;var Ig=Array.prototype,Mg=Ig.splice;function Pg(i){var e=this.__data__,t=$r(e,i);if(t<0)return!1;var r=e.length-1;return t==r?e.pop():Mg.call(e,t,1),--this.size,!0}var hd=Pg;function Og(i){var e=this.__data__,t=$r(e,i);return t<0?void 0:e[t][1]}var md=Og;function Ag(i){return $r(this.__data__,i)>-1}var fd=Ag;function jg(i,e){var t=this.__data__,r=$r(t,i);return r<0?(++this.size,t.push([i,e])):t[r][1]=e,this}var yd=jg;function Uo(i){var e=-1,t=i==null?0:i.length;for(this.clear();++e<t;){var r=i[e];this.set(r[0],r[1])}}Uo.prototype.clear=ud;Uo.prototype.delete=hd;Uo.prototype.get=md;Uo.prototype.has=fd;Uo.prototype.set=yd;var Jr=Uo;var _g=Ot(et,"Map"),Kr=_g;function Dg(){this.size=0,this.__data__={hash:new Aa,map:new(Kr||Jr),string:new Aa}}var gd=Dg;function Bg(i){var e=typeof i;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?i!=="__proto__":i===null}var xd=Bg;function Gg(i,e){var t=i.__data__;return xd(e)?t[typeof e=="string"?"string":"hash"]:t.map}var Xr=Gg;function zg(i){var e=Xr(this,i).delete(i);return this.size-=e?1:0,e}var bd=zg;function Eg(i){return Xr(this,i).get(i)}var vd=Eg;function Fg(i){return Xr(this,i).has(i)}var Sd=Fg;function Rg(i,e){var t=Xr(this,i),r=t.size;return t.set(i,e),this.size+=t.size==r?0:1,this}var wd=Rg;function ko(i){var e=-1,t=i==null?0:i.length;for(this.clear();++e<t;){var r=i[e];this.set(r[0],r[1])}}ko.prototype.clear=gd;ko.prototype.delete=bd;ko.prototype.get=vd;ko.prototype.has=Sd;ko.prototype.set=wd;var Pi=ko;var Vg="Expected a function";function ja(i,e){if(typeof i!="function"||e!=null&&typeof e!="function")throw new TypeError(Vg);var t=function(){var r=arguments,o=e?e.apply(this,r):r[0],n=t.cache;if(n.has(o))return n.get(o);var s=i.apply(this,r);return t.cache=n.set(o,s)||n,s};return t.cache=new(ja.Cache||Pi),t}ja.Cache=Pi;var Nd=ja;var Ug=500;function kg(i){var e=Nd(i,function(r){return t.size===Ug&&t.clear(),r}),t=e.cache;return e}var Cd=kg;var Hg=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,qg=/\\(\\)?/g,Wg=Cd(function(i){var e=[];return i.charCodeAt(0)===46&&e.push(""),i.replace(Hg,function(t,r,o,n){e.push(o?n.replace(qg,"$1"):r||t)}),e}),Ld=Wg;function $g(i){return i==null?"":Ac(i)}var Td=$g;function Jg(i,e){return ht(i)?i:sd(i,e)?[i]:Ld(Td(i))}var Ho=Jg;var Kg=1/0;function Xg(i){if(typeof i=="string"||_o(i))return i;var e=i+"";return e=="0"&&1/i==-Kg?"-0":e}var Rn=Xg;function Zg(i,e){e=Ho(e,i);for(var t=0,r=e.length;i!=null&&t<r;)i=i[Rn(e[t++])];return t&&t==r?i:void 0}var Id=Zg;function Qg(i,e){for(var t=-1,r=e.length,o=i.length;++t<r;)i[o+t]=e[t];return i}var qo=Qg;var Md=Ct?Ct.isConcatSpreadable:void 0;function Yg(i){return ht(i)||mo(i)||!!(Md&&i&&i[Md])}var Pd=Yg;function Od(i,e,t,r,o){var n=-1,s=i.length;for(t||(t=Pd),o||(o=[]);++n<s;){var a=i[n];e>0&&t(a)?e>1?Od(a,e-1,t,r,o):qo(o,a):r||(o[o.length]=a)}return o}var Ad=Od;function ex(i){var e=i==null?0:i.length;return e?Ad(i,1):[]}var jd=ex;function tx(i){return jn(Bn(i,void 0,jd),i+"")}var _d=tx;var rx=Fn(Object.getPrototypeOf,Object),Wo=rx;var ox="[object Object]",ix=Function.prototype,nx=Object.prototype,Dd=ix.toString,sx=nx.hasOwnProperty,ax=Dd.call(Object);function lx(i){if(!vt(i)||Ft(i)!=ox)return!1;var e=Wo(i);if(e===null)return!0;var t=sx.call(e,"constructor")&&e.constructor;return typeof t=="function"&&t instanceof t&&Dd.call(t)==ax}var Vn=lx;function cx(i,e,t){var r=-1,o=i.length;e<0&&(e=-e>o?0:o+e),t=t>o?o:t,t<0&&(t+=o),o=e>t?0:t-e>>>0,e>>>=0;for(var n=Array(o);++r<o;)n[r]=i[r+e];return n}var Bd=cx;function dx(){this.__data__=new Jr,this.size=0}var Gd=dx;function px(i){var e=this.__data__,t=e.delete(i);return this.size=e.size,t}var zd=px;function ux(i){return this.__data__.get(i)}var Ed=ux;function hx(i){return this.__data__.has(i)}var Fd=hx;var mx=200;function fx(i,e){var t=this.__data__;if(t instanceof Jr){var r=t.__data__;if(!Kr||r.length<mx-1)return r.push([i,e]),this.size=++t.size,this;t=this.__data__=new Pi(r)}return t.set(i,e),this.size=t.size,this}var Rd=fx;function $o(i){var e=this.__data__=new Jr(i);this.size=e.size}$o.prototype.clear=Gd;$o.prototype.delete=zd;$o.prototype.get=Ed;$o.prototype.has=Fd;$o.prototype.set=Rd;var Un=$o;function yx(i,e){return i&&Kt(e,Ro(e),i)}var Vd=yx;function gx(i,e){return i&&Kt(e,hr(e),i)}var Ud=gx;var kd=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Hd=kd&&typeof module=="object"&&module&&!module.nodeType&&module,xx=Hd&&Hd.exports===kd,qd=xx?et.Buffer:void 0,Wd=qd?qd.allocUnsafe:void 0;function bx(i,e){if(e)return i.slice();var t=i.length,r=Wd?Wd(t):new i.constructor(t);return i.copy(r),r}var kn=bx;function vx(i,e){for(var t=-1,r=i==null?0:i.length,o=0,n=[];++t<r;){var s=i[t];e(s,t,i)&&(n[o++]=s)}return n}var $d=vx;function Sx(){return[]}var Hn=Sx;var wx=Object.prototype,Nx=wx.propertyIsEnumerable,Jd=Object.getOwnPropertySymbols,Cx=Jd?function(i){return i==null?[]:(i=Object(i),$d(Jd(i),function(e){return Nx.call(i,e)}))}:Hn,Jo=Cx;function Lx(i,e){return Kt(i,Jo(i),e)}var Kd=Lx;var Tx=Object.getOwnPropertySymbols,Ix=Tx?function(i){for(var e=[];i;)qo(e,Jo(i)),i=Wo(i);return e}:Hn,qn=Ix;function Mx(i,e){return Kt(i,qn(i),e)}var Xd=Mx;function Px(i,e,t){var r=e(i);return ht(i)?r:qo(r,t(i))}var Wn=Px;function Ox(i){return Wn(i,Ro,Jo)}var Zd=Ox;function Ax(i){return Wn(i,hr,qn)}var $n=Ax;var jx=Ot(et,"DataView"),Jn=jx;var _x=Ot(et,"Promise"),Kn=_x;var Dx=Ot(et,"Set"),Xn=Dx;var Qd="[object Map]",Bx="[object Object]",Yd="[object Promise]",ep="[object Set]",tp="[object WeakMap]",rp="[object DataView]",Gx=Pr(Jn),zx=Pr(Kr),Ex=Pr(Kn),Fx=Pr(Xn),Rx=Pr(On),fo=Ft;(Jn&&fo(new Jn(new ArrayBuffer(1)))!=rp||Kr&&fo(new Kr)!=Qd||Kn&&fo(Kn.resolve())!=Yd||Xn&&fo(new Xn)!=ep||On&&fo(new On)!=tp)&&(fo=function(i){var e=Ft(i),t=e==Bx?i.constructor:void 0,r=t?Pr(t):"";if(r)switch(r){case Gx:return rp;case zx:return Qd;case Ex:return Yd;case Fx:return ep;case Rx:return tp}return e});var Ko=fo;var Vx=Object.prototype,Ux=Vx.hasOwnProperty;function kx(i){var e=i.length,t=new i.constructor(e);return e&&typeof i[0]=="string"&&Ux.call(i,"index")&&(t.index=i.index,t.input=i.input),t}var op=kx;var Hx=et.Uint8Array,_a=Hx;function qx(i){var e=new i.constructor(i.byteLength);return new _a(e).set(new _a(i)),e}var Xo=qx;function Wx(i,e){var t=e?Xo(i.buffer):i.buffer;return new i.constructor(t,i.byteOffset,i.byteLength)}var ip=Wx;var $x=/\w*$/;function Jx(i){var e=new i.constructor(i.source,$x.exec(i));return e.lastIndex=i.lastIndex,e}var np=Jx;var sp=Ct?Ct.prototype:void 0,ap=sp?sp.valueOf:void 0;function Kx(i){return ap?Object(ap.call(i)):{}}var lp=Kx;function Xx(i,e){var t=e?Xo(i.buffer):i.buffer;return new i.constructor(t,i.byteOffset,i.length)}var Zn=Xx;var Zx="[object Boolean]",Qx="[object Date]",Yx="[object Map]",e0="[object Number]",t0="[object RegExp]",r0="[object Set]",o0="[object String]",i0="[object Symbol]",n0="[object ArrayBuffer]",s0="[object DataView]",a0="[object Float32Array]",l0="[object Float64Array]",c0="[object Int8Array]",d0="[object Int16Array]",p0="[object Int32Array]",u0="[object Uint8Array]",h0="[object Uint8ClampedArray]",m0="[object Uint16Array]",f0="[object Uint32Array]";function y0(i,e,t){var r=i.constructor;switch(e){case n0:return Xo(i);case Zx:case Qx:return new r(+i);case s0:return ip(i,t);case a0:case l0:case c0:case d0:case p0:case u0:case h0:case m0:case f0:return Zn(i,t);case Yx:return new r;case e0:case o0:return new r(i);case t0:return np(i);case r0:return new r;case i0:return lp(i)}}var cp=y0;function g0(i){return typeof i.constructor=="function"&&!zo(i)?zc(Wo(i)):{}}var Qn=g0;var x0="[object Map]";function b0(i){return vt(i)&&Ko(i)==x0}var dp=b0;var pp=Or&&Or.isMap,v0=pp?Fo(pp):dp,up=v0;var S0="[object Set]";function w0(i){return vt(i)&&Ko(i)==S0}var hp=w0;var mp=Or&&Or.isSet,N0=mp?Fo(mp):hp,fp=N0;var C0=1,L0=2,T0=4,yp="[object Arguments]",I0="[object Array]",M0="[object Boolean]",P0="[object Date]",O0="[object Error]",gp="[object Function]",A0="[object GeneratorFunction]",j0="[object Map]",_0="[object Number]",xp="[object Object]",D0="[object RegExp]",B0="[object Set]",G0="[object String]",z0="[object Symbol]",E0="[object WeakMap]",F0="[object ArrayBuffer]",R0="[object DataView]",V0="[object Float32Array]",U0="[object Float64Array]",k0="[object Int8Array]",H0="[object Int16Array]",q0="[object Int32Array]",W0="[object Uint8Array]",$0="[object Uint8ClampedArray]",J0="[object Uint16Array]",K0="[object Uint32Array]",Fe={};Fe[yp]=Fe[I0]=Fe[F0]=Fe[R0]=Fe[M0]=Fe[P0]=Fe[V0]=Fe[U0]=Fe[k0]=Fe[H0]=Fe[q0]=Fe[j0]=Fe[_0]=Fe[xp]=Fe[D0]=Fe[B0]=Fe[G0]=Fe[z0]=Fe[W0]=Fe[$0]=Fe[J0]=Fe[K0]=!0;Fe[O0]=Fe[gp]=Fe[E0]=!1;function Yn(i,e,t,r,o,n){var s,a=e&C0,l=e&L0,c=e&T0;if(t&&(s=o?t(i,r,o,n):t(i)),s!==void 0)return s;if(!St(i))return i;var d=ht(i);if(d){if(s=op(i),!a)return An(i,s)}else{var p=Ko(i),u=p==gp||p==A0;if(Eo(i))return kn(i,a);if(p==xp||p==yp||u&&!o){if(s=l||u?{}:Qn(i),!a)return l?Xd(i,Ud(s,i)):Kd(i,Vd(s,i))}else{if(!Fe[p])return o?i:{};s=cp(i,p,a)}}n||(n=new Un);var f=n.get(i);if(f)return f;n.set(i,s),fp(i)?i.forEach(function(y){s.add(Yn(y,e,t,y,i,n))}):up(i)&&i.forEach(function(y,N){s.set(N,Yn(y,e,t,N,i,n))});var m=c?l?$n:Zd:l?hr:Ro,x=d?void 0:m(i);return Uc(x||i,function(y,N){x&&(N=y,y=i[N]),Dn(s,N,Yn(y,e,t,N,i,n))}),s}var es=Yn;var X0=1,Z0=4;function Q0(i){return es(i,X0|Z0)}var yo=Q0;function Y0(i){return function(e,t,r){for(var o=-1,n=Object(e),s=r(e),a=s.length;a--;){var l=s[i?a:++o];if(t(n[l],l,n)===!1)break}return e}}var bp=Y0;var eb=bp(),vp=eb;function tb(i,e,t){(t!==void 0&&!qr(i[e],t)||t===void 0&&!(e in i))&&Go(i,e,t)}var Oi=tb;function rb(i){return vt(i)&&Wr(i)}var Sp=rb;function ob(i,e){if(!(e==="constructor"&&typeof i[e]=="function")&&e!="__proto__")return i[e]}var Ai=ob;function ib(i){return Kt(i,hr(i))}var wp=ib;function nb(i,e,t,r,o,n,s){var a=Ai(i,t),l=Ai(e,t),c=s.get(l);if(c){Oi(i,t,c);return}var d=n?n(a,l,t+"",i,e,s):void 0,p=d===void 0;if(p){var u=ht(l),f=!u&&Eo(l),m=!u&&!f&&zn(l);d=l,u||f||m?ht(a)?d=a:Sp(a)?d=An(a):f?(p=!1,d=kn(l,!0)):m?(p=!1,d=Zn(l,!0)):d=[]:Vn(l)||mo(l)?(d=a,mo(a)?d=wp(a):(!St(a)||Do(a))&&(d=Qn(l))):p=!1}p&&(s.set(l,d),o(d,l,r,n,s),s.delete(l)),Oi(i,t,d)}var Np=nb;function Cp(i,e,t,r,o){i!==e&&vp(e,function(n,s){if(o||(o=new Un),St(n))Np(i,e,s,t,Cp,r,o);else{var a=r?r(Ai(i,s),n,s+"",i,e,o):void 0;a===void 0&&(a=n),Oi(i,s,a)}},hr)}var Lp=Cp;function sb(i){var e=i==null?0:i.length;return e?i[e-1]:void 0}var Tp=sb;function ab(i,e){return e.length<2?i:Id(i,Bd(e,0,-1))}var Ip=ab;var lb=Wc(function(i,e,t){Lp(i,e,t)}),go=lb;function cb(i,e){return e=Ho(e,i),i=Ip(i,e),i==null||delete i[Rn(Tp(e))]}var Mp=cb;function db(i){return Vn(i)?void 0:i}var Pp=db;var pb=1,ub=2,hb=4,mb=_d(function(i,e){var t={};if(i==null)return t;var r=!1;e=In(e,function(n){return n=Ho(n,i),r||(r=n.length>1),n}),Kt(i,$n(i),t),r&&(t=es(t,pb|ub|hb,Pp));for(var o=e.length;o--;)Mp(t,e[o]);return t}),Zo=mb;var Qo;(function(t){t.all=["PerspectiveCamera","OrthographicCamera"];function e(r){return t.all.includes(r)}t.is=e})(Qo||(Qo={}));var xo;(function(o){o.DefaultUp=[0,1,0],o.DefaultTargetOffset=1e3,o.defaultData={far:5e5,type:"OrthographicCamera",perspective:{near:5,fov:45,zoom:1},orthographic:{near:-5e5,zoom:1},up:o.DefaultUp,isUpVectorFlipped:!1,targetOffset:o.DefaultTargetOffset};function r(n){return n.type==="PerspectiveCamera"?n.perspective.zoom:n.orthographic.zoom}o.getZoom=r})(xo||(xo={}));var Yo;(function(r){r.x="x",r.y="y",r.z="z"})(Yo||(Yo={}));var Op;(function(n){n.Top="top",n.Right="right",n.Bottom="bottom",n.Left="left",n.Center="center"})(Op||(Op={}));var Ap;(function(t){function i(r,o){return r[0]===o[0]&&r[1]===o[1]}t.isEqual=i;function e(r,o,n){return[r[0]+(o[0]-r[0])*n,r[1]+(o[1]-r[1])*n]}t.lerp=e})(Ap||(Ap={}));var ei;(function(o){function i(n,s){return n[0]===s[0]&&n[1]===s[1]&&n[2]===s[2]}o.isEqual=i;function e(n,s){return[n[0]+s[0],n[1]+s[1],n[2]+s[2]]}o.add=e;function t(n,s){return[n[0]-s[0],n[1]-s[1],n[2]-s[2]]}o.sub=t;function r(n,s,a){return[n[0]+(s[0]-n[0])*a,n[1]+(s[1]-n[1])*a,n[2]+(s[2]-n[2])*a]}o.lerp=r})(ei||(ei={}));var jp;(function(t){function i(r,o){return r[0]===o[0]&&r[1]===o[1]&&r[2]===o[2]&&r[3]===o[3]}t.isEqual=i;function e(r,o,n){return[r[0]+(o[0]-r[0])*n,r[1]+(o[1]-r[1])*n,r[2]+(o[2]-r[2])*n,r[3]+(o[3]-r[3])*n]}t.lerp=e})(jp||(jp={}));var Zr;(function(n){n.identity=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];function e(s,a){for(let l=0;l<16;l++)if(s[l]!==a[l])return!1;return!0}n.isEqual=e;function t(s){return s!=null?s:n.identity}n.simplify=t;function r(s,a){let l=a.slice(0);for(var c=0,d=a.length;c<d;c+=3){let p=1/(s[3]*a[c]+s[7]*a[c+1]+s[11]*a[c+2]+s[15]);l[c]=(s[0]*a[c]+s[4]*a[c+1]+s[8]*a[c+2]+s[12])*p,l[c+1]=(s[1]*a[c]+s[5]*a[c+1]+s[9]*a[c+2]+s[13])*p,l[c+2]=(s[2]*a[c]+s[6]*a[c+1]+s[10]*a[c+2]+s[14])*p}return l}n.applyMatrix4=r;function o(s,a){let l=a.slice(0);for(var c=0,d=a.length;c<d;c+=3)l[c]=s[0]*a[c]+s[4]*a[c+1]+s[8]*a[c+2],l[c+1]=s[1]*a[c]+s[5]*a[c+1]+s[9]*a[c+2],l[c+2]=s[2]*a[c]+s[6]*a[c+1]+s[10]*a[c+2];return l}n.applyMatrix3Components=o})(Zr||(Zr={}));var Rt;(function(l){l.white={r:1,g:1,b:1},l.red={r:1,g:0,b:0},l.black={r:0,g:0,b:0};function r(c){return{r:Math.round(c.r*255),g:Math.round(c.g*255),b:Math.round(c.b*255),a:1}}l.toRgb255a1=r;function o(c){return{r:c.r,g:c.g,b:c.b}}l.clone=o;function n(c){return c=Math.floor(c),{r:(c>>16&255)/255,g:(c>>8&255)/255,b:(c&255)/255}}l.fromHex=n;function s(c,d){return c.r===d.r&&c.g===d.g&&c.b===d.b}l.equals=s;function a(c,d,p){return{r:c.r+(d.r-c.r)*p,g:c.g+(d.g-c.g)*p,b:c.b+(d.b-c.b)*p}}l.lerp=a})(Rt||(Rt={}));var mr;(function(n){n.white=$(O({},Rt.white),{a:1});function e(s){return{r:s[0],g:s[1],b:s[2],a:s[3]}}n.from0to1=e;function t(s,a){return $(O({},Rt.fromHex(s)),{a})}n.fromHexAndA=t;function r(s){return{r:Math.round(s.r*255),g:Math.round(s.g*255),b:Math.round(s.b*255),a:s.a}}n.toRgb255a1=r;function o(s,a){return Rt.equals(s,a)&&s.a===a.a}n.equals=o})(mr||(mr={}));var ts;(function(e){e.identity={position:[0,0,0],rotation:[0,0,0],scale:[1,1,1]}})(ts||(ts={}));var _p;(function(w){w[w.SKIP=0]="SKIP",w[w.ADD=1]="ADD",w[w.ALPHA=2]="ALPHA",w[w.AVERAGE=3]="AVERAGE",w[w.COLOR_BURN=4]="COLOR_BURN",w[w.COLOR_DODGE=5]="COLOR_DODGE",w[w.DARKEN=6]="DARKEN",w[w.DIFFERENCE=7]="DIFFERENCE",w[w.EXCLUSION=8]="EXCLUSION",w[w.LIGHTEN=9]="LIGHTEN",w[w.MULTIPLY=10]="MULTIPLY",w[w.DIVIDE=11]="DIVIDE",w[w.NEGATION=12]="NEGATION",w[w.NORMAL=13]="NORMAL",w[w.OVERLAY=14]="OVERLAY",w[w.REFLECT=15]="REFLECT",w[w.SCREEN=16]="SCREEN",w[w.SOFT_LIGHT=17]="SOFT_LIGHT",w[w.SUBTRACT=18]="SUBTRACT"})(_p||(_p={}));var Dp;(function(a){a[a.LINEAR=0]="LINEAR",a[a.EASE=1]="EASE",a[a.EASE_IN=2]="EASE_IN",a[a.EASE_OUT=3]="EASE_OUT",a[a.EASE_IN_OUT=4]="EASE_IN_OUT",a[a.CUBIC=5]="CUBIC",a[a.SPRING=6]="SPRING"})(Dp||(Dp={}));var Bp;(function(e){e.defaultData={mass:1,stiffness:80,damping:10,velocity:0}})(Bp||(Bp={}));var Gp;(function(e){e.defaultData={control1:[.5,.05],control2:[.1,.3]}})(Gp||(Gp={}));var rs;(function(e){function i(t,r=.1){return{type:"radial",hideBase:!1,count:3,radial:{radius:Math.max(t[0],t[1])*2,start:0,end:360,alignment:!1,axis:Yo.y,scale:[0,0,0],rotation:[0,0,0],position:[0,0,0]},linear:{scale:[0,0,0],rotation:[0,0,0],position:[t[0]+t[0]*r,0,0]},grid:{count:[2,2,2],size:t.map(o=>o*(1+r)),useCenter:!0}}}e.defaultData=i})(rs||(rs={}));var jr;(function(e){e[e.Update=0]="Update"})(jr||(jr={}));var Xt;(function(r){r[r.Add=1]="Add",r[r.Delete=2]="Delete",r[r.Unlink=3]="Unlink"})(Xt||(Xt={}));var Vt;(function(r){r[r.Add=4]="Add",r[r.Delete=5]="Delete",r[r.Move=6]="Move"})(Vt||(Vt={}));var At;(function(r){r[r.Add=7]="Add",r[r.Delete=8]="Delete",r[r.Move=9]="Move"})(At||(At={}));var nr=class{modifyById(e,t){let r=this;if(r[e]===void 0)throw new Error("not expected");{let n=$(O({},r),{[e]:t});return Object.setPrototypeOf(n,nr.prototype),n}}add(e,t){var o;let r=this.runOp({type:Xt.Add,id:e,data:t});return(o=r==null?void 0:r.data)!=null?o:this}runOp(e){let t=this;if(e.type===Xt.Add){let r=t[e.id],o;r===void 0?o={type:Xt.Delete,id:e.id}:o={type:Xt.Add,id:e.id,data:r};let{id:n,data:s}=e,a=$(O({},t),{[n]:s});return Object.setPrototypeOf(a,nr.prototype),{data:a,actual:e,reverse:o}}else if(e.type===Xt.Delete){let{id:r}=e,o=t[r];if(o===void 0)return null;{let n=O({},t);return Object.setPrototypeOf(n,nr.prototype),delete n[r],{data:n,actual:e,reverse:{type:Xt.Add,id:r,data:o}}}}throw new Error("illegal arg")}};function ji(i){if(i.deepFreeze!==void 0){i.deepFreeze(i);return}let e=Object.getOwnPropertyNames(i);for(let t of e){let r=i[t];r&&typeof r=="object"&&ji(r)}return Object.freeze(i)}function zp(i,e){let t=0;for(;t<i.length&&t<e.length;){if(i[t]<e[t])return-1;if(i[t]>e[t])return 1;t+=1}return t!==e.length?-1:t!==i.length?1:0}var Da=class extends Error{};function fr(i,e,t){if(i===void 0?e===void 0?(i=0,e=10):i=e-10:e===void 0&&(e=i+10),i>e){let n=i;i=e,e=n}let r=[],o=1/(t+1);for(let n=0;n<t;n++){let s=i+(e-i)*(n+.75+Math.random()*.5)*o;r.push(s)}return r}function Ep(i){return i instanceof Uint8Array||i instanceof Uint16Array||i instanceof Uint32Array||i instanceof Int8Array||i instanceof Int16Array||i instanceof Int32Array||i instanceof Float32Array||i instanceof Float64Array}function Fp(){return typeof process!="undefined"}function Rp(i,e){for(let t of i)e(t.id,t.data),Rp(t.children,e)}function Vp(i,e){e(i.id,i.data);for(let t of i.children)Vp(t,e)}var sr=class extends Array{constructor(...e){super(...e);Object.setPrototypeOf(this,sr.prototype)}deepFreeze(){let e=0;for(;e<this.length;)ji(this[e]),e++}fillCaches0(e,t){var r;if((r=this.objCaches)==null?void 0:r.has(e.id))throw new Error("duplicated item");this.objCaches.set(e.id,e),this.parentCaches.set(e.id,t);for(let o of e.children)this.fillCaches0(o,e.id)}fillCaches(){if(this.objCaches===void 0){this.objCaches=new Map,this.parentCaches=new Map;for(let e of this)this.fillCaches0(e,null)}}randomId(){this.fillCaches();let e=Array.from(this.objCaches.keys());if(e.length!==0)return e[Math.max(0,Math.floor(Math.random()*e.length)-1)]}isDescendantOf(e,t){for(;e;){let r=this.parent(e);if(r===t)return!0;e=r}return!1}data(e){var t;return(t=this.get(e))==null?void 0:t.data}has(e){return this.childrenOf(e)!==void 0}get(e){return this.fillCaches(),this.objCaches.get(e)}childrenOf(e){var t;return e===null?this:(t=this.get(e))==null?void 0:t.children}traverseFrom(e,t){if(e===null)this.traverse(t);else{let r=this.get(e);r&&Vp(r,t)}}traverse(e){Rp(this,e)}totalSize(){return this.fillCaches(),this.objCaches.size}parent(e){return this.fillCaches(),this.parentCaches.get(e)}childrenArray(e){return e===null?this:this.get(e).children}modifyById(e,t){if(this.get(e)===void 0)throw new Error("not expected");{let o=this.parent(e),n=this.childrenArray(o),s=n.findIndex(c=>c.id===e);if(s<0)throw new Error("not expected");let a=n[s];return n=[...n],n[s]=$(O({},a),{data:t}),this.modifyArrayBy(o,n)}}modifyArrayBy(e,t){let r=e,o=t;for(;r!==null;){let s=o,a=r;if(r=this.parent(r),r===void 0)throw new Error;o=this.childrenArray(r);let l=o.findIndex(c=>c.id===a);if(l<0)throw new Error;o=[...o],o[l]=$(O({},o[l]),{children:s})}Object.setPrototypeOf(o,sr.prototype);let n=o;return n.fillCaches(),n}runOp(e){switch(e.type){case At.Add:return this.addOp(e);case At.Delete:return this.deleteOp(e);case At.Move:return this.moveOp(e)}}addOp(e){let{parent:t,fi:r,id:o,data:n,children:s}=e;if(t!==null&&this.get(t)===void 0)return null;if(this.get(o)!==void 0)return null;{let a=t,l=this.childrenArray(a),c={fi:r,id:o,data:n,children:s};return l=[...l,c],l.sort((p,u)=>p.fi-u.fi),e.localIndex=l.indexOf(c),{data:this.modifyArrayBy(a,l),actual:e,reverse:{type:At.Delete,id:o}}}}deleteOp(e){let{id:t}=e;if(this.get(t)===null)return null;{let r=this.parent(t);if(r===void 0)return null;let o=this.childrenArray(r),n=o.findIndex(l=>l.id===t);e.localIndex=n,o=[...o];let s=o.splice(n,1)[0];return{data:this.modifyArrayBy(r,o),actual:e,reverse:$(O({type:At.Add},s),{parent:r})}}}moveOp(e){let{parent:t,fi:r,id:o}=e;if(t!==null&&this.get(t)===void 0)return this.deleteOp({type:At.Delete,id:o});if(t!==null){let u=t;for(;u!==null;){if(u===void 0)throw new Error;if(u===o)throw new Da("cyclic tree");u=this.parent(u)}}let n=this.parent(o);if(n===void 0)return null;let s=n,a=this.childrenArray(n),l=a.findIndex(u=>u.id===o);a=[...a];let c=a.splice(l,1)[0],d=this.modifyArrayBy(n,a);n=t,a=d.childrenArray(n);let p=c.fi;return c=$(O({},c),{fi:r}),a=[...a,c],a.sort((u,f)=>u.fi-f.fi),e.localIndex=a.indexOf(c),d=d.modifyArrayBy(n,a),{data:d,actual:e,reverse:{type:At.Move,parent:s,fi:p,id:o}}}previous(e,t){if(t===null){let o=this.childrenArray(e);return o.length===0?null:o[o.length-1].id}let r=null;for(let o of this.childrenArray(e)){if(o.id===t)return r;r=o.id}return null}traverseSortNext(e){let t=this.parent(e);if(t!==void 0){let r=this.childrenArray(t),o=r.findIndex(n=>n.id===e)+1;if(o<r.length)return r[o].id;if(t)return this.traverseSortNext(t)}}sortNext(e){let t=this.childrenArray(e);return t.length>0?t[0].id:this.traverseSortNext(e)}traverseSortPrevious(e){let t=this.childrenArray(e);return t.length>0?this.traverseSortPrevious(t[t.length-1].id):e}sortPrevious(e){let t=this.parent(e);if(t!==void 0){let r=this.childrenArray(t),o=r.findIndex(n=>n.id===e)-1;return o>=0?this.traverseSortPrevious(r[o].id):t}}getAllSorted(e){let t=[];for(let r of e){let o=this.getWithSortKey(r.id);o!==void 0&&t.push(O(O({},r),o))}t.sort((r,o)=>zp(r.sortKey,o.sortKey));for(let r of t)delete r.sortKey;return t}getWithSortKey(e){var t=e;let r=[],o=this.get(t),n=o;if(o!==void 0){for(;t;)r.splice(0,0,o.fi),t=this.parent(t),t!==null&&(o=this.get(t));return $(O({},n),{sortKey:r})}}insertBeforeHelper(e,t,r){return this.insertAfterHelper(e,this.previous(e,t),r)}insertAfterHelper(e,t,r){let o=this.childrenArray(e);if(t===null){if(o.length===0)return fr(0,r,r);{let n=o[0].fi;return fr(n-r,n,r)}}else{let n=this.get(t);if(n===void 0||this.parent(t)!==e)throw new Error("illegal args");let s=o.find(a=>a.fi>n.fi);if(s===void 0){let a=o[o.length-1].fi;return fr(a,a+r,r)}else return fr(n.fi,s.fi,r)}}};var os;(function(e){function i(t,r){if(Array.isArray(t)){let o=r.props,n={},s=[...t],a=!1;if(o)for(let l of Object.keys(o)){let c=parseInt(l);if(isNaN(c))throw new Error("wrong index");n[l]=s[c],s[c]=o[l],a=!0}return a?{data:s,actual:r,reverse:{type:jr.Update,props:n}}:null}else{let o=r.props,n={},s=O({},t),a=!1;if(o)for(let l of Object.keys(o))n[l]=s[l],s[l]=o[l],a=!0;return a?{data:s,actual:r,reverse:{type:jr.Update,props:n}}:null}}e.runOp=i})(os||(os={}));var Ke=class extends Array{constructor(...e){super(...e);Object.setPrototypeOf(this,Ke.prototype)}deepFreeze(){let e=0;for(;e<this.length;)ji(this[e]),e++}fillCaches0(e){this.objCaches.set(e.id,e)}fillCaches(){if(this.objCaches===void 0){this.objCaches=new Map,Object.getOwnPropertyDescriptor(this,"objCaches").enumerable=!1;for(let e of this)this.fillCaches0(e)}}randomId(){this.fillCaches();let e=Array.from(this.objCaches.keys());if(e.length!==0)return e[Math.max(0,Math.floor(Math.random()*e.length)-1)]}data(e){var t;return(t=this.get(e))==null?void 0:t.data}get(e){return this.fillCaches(),this.objCaches.get(e)}modifyById(e,t){if(this.get(e)===void 0)throw new Error("not expected");{let o=this,n=o.findIndex(l=>l.id===e);if(n<0)throw new Error("not expected");let s=o[n];return o=[...o],o[n]=$(O({},s),{data:t}),this.modifyArrayBy(o)}}modifyArrayBy(e){Object.setPrototypeOf(e,Ke.prototype);let t=e;return Fp()||t.fillCaches(),t}runOp(e){switch(e.type){case Vt.Add:return this.addOp(e);case Vt.Delete:return this.deleteOp(e);case Vt.Move:return this.moveOp(e)}}addOp(e){let{fi:t,id:r,data:o}=e,n=this,s={fi:t,id:r,data:o};return n=[...n,s],n.sort((l,c)=>l.fi-c.fi),e.localIndex=n.indexOf(s),{data:this.modifyArrayBy(n),actual:e,reverse:{type:Vt.Delete,id:r}}}deleteOp(e){let{id:t}=e,r=this,o=r.findIndex(a=>a.id===t);if(o===-1)return null;e.localIndex=o,r=[...r];let n=r.splice(o,1)[0];return{data:this.modifyArrayBy(r),actual:e,reverse:O({type:Vt.Add},n)}}moveOp(e){let{fi:t,id:r}=e,o=this;o=[...o];let n=o.findIndex(c=>c.id===r);if(n===-1)return null;let s=o[n].fi,a=$(O({},o[n]),{fi:t});return o[n]=a,o.sort((c,d)=>c.fi-d.fi),e.localIndex=o.indexOf(a),{data:this.modifyArrayBy(o),actual:e,reverse:{type:Vt.Move,fi:s,id:r}}}previous(e){if(e===null)return this.length===0?null:this[this.length-1].id;let t=null;for(let r of this){if(r.id===e)return t;t=r.id}return null}insertBeforeHelper(e,t){return this.insertAfterHelper(this.previous(e),t)}insertAfterHelper(e,t){let r=this;if(e===null){if(r.length===0)return fr(0,t,t);{let o=r[0].fi;return fr(o-t,o,t)}}else{let o=this.get(e);if(o===void 0)throw new Error("illegal args");let n=r.find(s=>s.fi>o.fi);if(n===void 0){let s=r[r.length-1].fi;return fr(s,s+t,t)}else return fr(o.fi,n.fi,t)}}};var Up=Symbol(),is=Symbol(),_i=class{reportOp(e,t){let r=this;if(t===null)return;r._current=t.data;let o=[];for(;!(r instanceof Ga);){let n=r._path,s=r._current;if(n!==""&&o.splice(0,0,n),r=r._parent,r===null)return;r.update(n,s)}r.push(o,e,t.actual,t.reverse)}deleteChildren(e){if(this._children){let t=this._children[e];if(t){let r=t[is];r&&r(),delete this._children[e]}}}},kp=class extends _i{constructor(e,t,r){super();this._parent=e,this._path=t,this._current=r}update(e,t){if(Array.isArray(this._current)){if(typeof e=="string"&&(e=parseInt(e),isNaN(e)))throw new Error("Invalid path");this._current=[...this._current],this._current[e]=t}else this._current=$(O({},this._current),{[e]:t})}runOp(e){this.reportOp(e,os.runOp(this._current,e))}},Hp=class extends _i{constructor(e,t,r){super();this._parent=e,this._path=t,this._current=r}update(e,t){this._current=$(O({},this._current),{[e]:t}),Object.setPrototypeOf(this._current,nr.prototype)}runOp(e){this.reportOp(e,this._current.runOp(e))}},qp={get(i,e){if(e===is)return()=>{i._parent=null};if(e===Up)return i._current;let{_current:t,_children:r}=i;if(e==="push"&&Array.isArray(t))throw new Error("not supported to expand array");let o=r===void 0?void 0:r[e];if(o!==void 0)return o;let n=t[e],s=ns(i,e,n);return s!==n?(r===void 0&&(r={},i._children=r),r[e]=s,s):n},has(i,e){return e in i._current},ownKeys(i){return Reflect.ownKeys(i._current)},defineProperty(){throw Error("not supported")},getPrototypeOf(i){return Object.getPrototypeOf(i._current)},setPrototypeOf(){throw Error("not supported")},getOwnPropertyDescriptor(i,e){let t=i._current,r=Reflect.getOwnPropertyDescriptor(t,e);return r&&{writable:!0,configurable:!0,enumerable:r.enumerable,value:t[e]}}},fb=$(O({},qp),{set(i,e,t){var o;let r;if(t===void 0)throw new Error("set to undefined is not supported!");return r={type:jr.Update,props:{[e]:(o=xb(t))!=null?o:t}},i.deleteChildren(e),i.runOp(r),!0},deleteProperty(i,e){throw new Error("set to undefined is not supported!")}}),yb=$(O({},qp),{set(i,e,t){return t===void 0?this.deleteProperty(i,e):(i.deleteChildren(e),i.runOp({type:Xt.Add,id:e,data:t})),!0},deleteProperty(i,e){return i.runOp({type:Xt.Delete,id:e}),!0}}),Di=class extends _i{constructor(e,t,r){super();this._children={},this._parent=e,this._path=t,this._current=r,this[is]=()=>{this._parent=null}}unproxy(){return this._current}update(e,t){this._current=this._current.modifyById(e,t)}runOp(e){this.reportOp(e,this._current.runOp(e))}randomId(){return this._current.randomId()}isDescendantOf(e,t){return this._current.isDescendantOf(e,t)}childrenOf(e){return this._current.childrenOf(e)}traverse(e){return this._current.traverse(e)}get(e){return this._current.get(e)}parent(e){return this._current.parent(e)}data(e){var a;let{_current:t,_children:r}=this,o=r===void 0?void 0:r[e];if(o!==void 0)return o;let n=(a=t.get(e))==null?void 0:a.data,s=ns(this,e,n);return s!==n?(r===void 0&&(r={},this._children=r),r[e]=s,s):n}add(e,t,r,o,n){this.runOp({type:At.Add,parent:e,fi:t,id:r,data:o,children:n})}move(e,t,r){this.runOp({type:At.Move,parent:e,fi:t,id:r})}insertAfter(e,t,r){let o=this._current.insertAfterHelper(e,t,r.length);for(let n=0;n<r.length;n++){let s=r[n];this.add(e,o[n],s.id,s.data,s.children)}}insertBefore(e,t,r){let o=this._current.insertBeforeHelper(e,t,r.length);for(let n=0;n<r.length;n++){let s=r[n];this.add(e,o[n],s.id,s.data,s.children)}}moveAfter(e,t,r){let o=this._current.insertAfterHelper(e,t,r.length);for(let n=0;n<r.length;n++){let s=r[n];this.move(e,o[n],s)}}moveBefore(e,t,r){let o=this._current.insertBeforeHelper(e,t,r.length);for(let n=0;n<r.length;n++){let s=r[n];this.move(e,o[n],s)}}delete(e){this.deleteChildren(e),this.runOp({type:At.Delete,id:e})}sortNext(e){return this._current.sortNext(e)}sortPrevious(e){return this._current.sortPrevious(e)}getAllSorted(e){return this._current.getAllSorted(e)}},Bi=class extends _i{constructor(e,t,r){super();this._children={},this._parent=e,this._path=t,this._current=r,this[is]=()=>{this._parent=null}}unproxy(){return this._current}get length(){return this._current.length}forEach(e){let t=this.length;for(let r=0;r<t;r++){let o=this._current[r].id;e(this.data(this._current[r].id),o)}}update(e,t){this._current=this._current.modifyById(e,t)}randomId(){return this._current.randomId()}get(e){return $(O({},this._current.get(e)),{data:this.data(e)})}data(e){var a;let{_current:t,_children:r}=this,o=r===void 0?void 0:r[e];if(o!==void 0)return o;let n=(a=t.get(e))==null?void 0:a.data,s=ns(this,e,n);return s!==n?(r===void 0&&(r={},this._children=r),r[e]=s,s):n}runOp(e){this.reportOp(e,this._current.runOp(e))}add(e,t,r){this.runOp({type:Vt.Add,fi:e,id:t,data:r})}move(e,t){this.runOp({type:Vt.Move,fi:e,id:t})}insertAfter(e,t){let r=this._current.insertAfterHelper(e,t.length);for(let o=0;o<t.length;o++){let n=t[o];this.add(r[o],n.id,n.data)}}insertBefore(e,t){let r=this._current.insertBeforeHelper(e,t.length);for(let o=0;o<t.length;o++){let n=t[o];this.add(r[o],n.id,n.data)}}moveAfter(e,t){let r=this._current.insertAfterHelper(e,t.length);for(let o=0;o<t.length;o++){let n=t[o];this.move(r[o],n)}}moveBefore(e,t){let r=this._current.insertBeforeHelper(e,t.length);for(let o=0;o<t.length;o++){let n=t[o];this.move(r[o],n)}}delete(e){this.deleteChildren(e),this.runOp({type:Vt.Delete,id:e})}};function Ba(i,e,t){if(i.length>0){let r=i[i.length-1];if(r.type===jr.Update&&e.type===jr.Update&&ss.equal(r.path,t)){Object.assign(r.props,e.props);return}}i.push($(O({},e),{path:t}))}var Ga=class{constructor(e){this.ts=[],this.actual=[],this.reverse=[],this._current=e}update(e,t){if(e!=="")throw new Error("");this._current=t}push(e,t,r,o){Ba(this.ts,t,e),Ba(this.actual,r,e),Ba(this.reverse,o,e)}result(){return{data:this._current,ts:this.ts,actual:this.actual,reverse:this.reverse.reverse()}}};function ns(i,e,t){return t instanceof sr?new Di(i,e,t):t instanceof Ke?new Bi(i,e,t):t instanceof nr?new Proxy(new Hp(i,e,t),yb):t!==null&&typeof t=="object"?Ep(t)?t:new Proxy(new kp(i,e,t),fb):t}function gb(i){let e=new Ga(i);return[ns(e,"",i),e]}function za(i,e){let[t,r]=gb(i);return e(t),r.result()}function xb(i){return i instanceof Di||i instanceof Bi?i._current:i!==null&&typeof i=="object"?i[Up]:i}var ss;(function(r){function i(o,n){if(n.length===o.length)for(var s=0;s<o.length;){if(o[s]!==n[s])return!1;s+=1}else return!1;return!0}r.equal=i;function e(o,n,s){let a=t(s,o);if(a!==void 0&&typeof a=="object"&&a!==null){let l=O({},n);return Object.keys(a).forEach(c=>{delete l[c]}),l}else return n}r.removeOverridden=e;function t(o,n,s=0){if(n.length<=s)return o;if((o instanceof sr||o instanceof Di)&&typeof n[s]=="string")return t(o.data(n[s]),n,s+1);if((o instanceof Ke||o instanceof Bi)&&typeof n[s]=="string")return t(o.data(n[s]),n,s+1);if(typeof n[s]=="number"&&Array.isArray(o))return t(o[n[s]],n,s+1);if(typeof n[s]=="string"&&typeof o=="object")return t(o[n[s]],n,s+1)}r.zoom=t})(ss||(ss={}));var Ea=class{},as=class extends Ea{constructor(e){super();this.id=e}},ls=class extends Ea{constructor(e){super();this.data=e}};"use strict";var Fa;try{Fa=new TextDecoder}catch(i){}var Q,Qr,C=0;var Wp=[],Ra=Wp,Va=0,jt={},Me,Yr,Zt=0,yr=0,Ut,_r,Lt=[],Ae,$p={useRecords:!1,mapsAsObjects:!0},cs=class{},Ua=new cs;Ua.name="MessagePack 0xC1";var ti=!1,Dr=class{constructor(e){e&&(e.useRecords===!1&&e.mapsAsObjects===void 0&&(e.mapsAsObjects=!0),e.structures?e.structures.sharedLength=e.structures.length:e.getStructures&&((e.structures=[]).uninitialized=!0,e.structures.sharedLength=0)),Object.assign(this,e)}unpack(e,t){if(Q)return iu(()=>(us(),this?this.unpack(e,t):Dr.prototype.unpack.call($p,e,t)));Qr=t>-1?t:e.length,C=0,Va=0,yr=0,Yr=null,Ra=Wp,Ut=null,Q=e;try{Ae=e.dataView||(e.dataView=new DataView(e.buffer,e.byteOffset,e.byteLength))}catch(r){throw Q=null,e instanceof Uint8Array?r:new Error("Source must be a Uint8Array or Buffer but was a "+(e&&typeof e=="object"?e.constructor.name:typeof e))}if(this instanceof Dr){if(jt=this,this.structures)return Me=this.structures,ds();(!Me||Me.length>0)&&(Me=[])}else jt=$p,(!Me||Me.length>0)&&(Me=[]);return ds()}unpackMultiple(e,t){let r,o=0;try{ti=!0;let n=e.length,s=this?this.unpack(e,n):ms.unpack(e,n);if(t){for(t(s);C<n;)if(o=C,t(ds())===!1)return}else{for(r=[s];C<n;)o=C,r.push(ds());return r}}catch(n){throw n.lastPosition=o,n.values=r,n}finally{ti=!1,us()}}_mergeStructures(e,t){e=e||[];for(let r=0,o=e.length;r<o;r++){let n=e[r];n&&(n.isShared=!0,r>=32&&(n.highByte=r-32>>5))}e.sharedLength=e.length;for(let r in t||[])if(r>=0){let o=e[r],n=t[r];n&&(o&&((e.restoreStructures||(e.restoreStructures=[]))[r]=o),e[r]=n)}return this.structures=e}decode(e,t){return this.unpack(e,t)}};function ds(){try{if(!jt.trusted&&!ti){let e=Me.sharedLength||0;e<Me.length&&(Me.length=e)}let i=Xe();if(C==Qr)Me.restoreStructures&&Jp(),Me=null,Q=null,_r&&(_r=null);else if(C>Qr){let e=new Error("Unexpected end of MessagePack data");throw e.incomplete=!0,e}else if(!ti)throw new Error("Data read, but end of buffer not reached");return i}catch(i){throw Me.restoreStructures&&Jp(),us(),(i instanceof RangeError||i.message.startsWith("Unexpected end of buffer"))&&(i.incomplete=!0),i}}function Jp(){for(let i in Me.restoreStructures)Me[i]=Me.restoreStructures[i];Me.restoreStructures=null}function Xe(){let i=Q[C++];if(i<160)if(i<128){if(i<64)return i;{let e=Me[i&63]||jt.getStructures&&Xp()[i&63];return e?(e.read||(e.read=ka(e,i&63)),e.read()):i}}else if(i<144)if(i-=128,jt.mapsAsObjects){let e={};for(let t=0;t<i;t++)e[tu()]=Xe();return e}else{let e=new Map;for(let t=0;t<i;t++)e.set(Xe(),Xe());return e}else{i-=144;let e=new Array(i);for(let t=0;t<i;t++)e[t]=Xe();return e}else if(i<192){let e=i-160;if(yr>=C)return Yr.slice(C-Zt,(C+=e)-Zt);if(yr==0&&Qr<140){let t=e<16?qa(e):Yp(e);if(t!=null)return t}return Ha(e)}else{let e;switch(i){case 192:return null;case 193:return Ut?(e=Xe(),e>0?Ut[1].slice(Ut.position1,Ut.position1+=e):Ut[0].slice(Ut.position0,Ut.position0-=e)):Ua;case 194:return!1;case 195:return!0;case 196:return Wa(Q[C++]);case 197:return e=Ae.getUint16(C),C+=2,Wa(e);case 198:return e=Ae.getUint32(C),C+=4,Wa(e);case 199:return bo(Q[C++]);case 200:return e=Ae.getUint16(C),C+=2,bo(e);case 201:return e=Ae.getUint32(C),C+=4,bo(e);case 202:if(e=Ae.getFloat32(C),jt.useFloat32>2){let t=hs[(Q[C]&127)<<1|Q[C+1]>>7];return C+=4,(t*e+(e>0?.5:-.5)>>0)/t}return C+=4,e;case 203:return e=Ae.getFloat64(C),C+=8,e;case 204:return Q[C++];case 205:return e=Ae.getUint16(C),C+=2,e;case 206:return e=Ae.getUint32(C),C+=4,e;case 207:return jt.int64AsNumber?(e=Ae.getUint32(C)*4294967296,e+=Ae.getUint32(C+4)):e=Ae.getBigUint64(C),C+=8,e;case 208:return Ae.getInt8(C++);case 209:return e=Ae.getInt16(C),C+=2,e;case 210:return e=Ae.getInt32(C),C+=4,e;case 211:return jt.int64AsNumber?(e=Ae.getInt32(C)*4294967296,e+=Ae.getUint32(C+4)):e=Ae.getBigInt64(C),C+=8,e;case 212:if(e=Q[C++],e==114)return ru(Q[C++]&63);{let t=Lt[e];if(t)return t.read?(C++,t.read(Xe())):t.noBuffer?(C++,t()):t(Q.subarray(C,++C));throw new Error("Unknown extension "+e)}case 213:return e=Q[C],e==114?(C++,ru(Q[C++]&63,Q[C++])):bo(2);case 214:return bo(4);case 215:return bo(8);case 216:return bo(16);case 217:return e=Q[C++],yr>=C?Yr.slice(C-Zt,(C+=e)-Zt):vb(e);case 218:return e=Ae.getUint16(C),C+=2,yr>=C?Yr.slice(C-Zt,(C+=e)-Zt):Sb(e);case 219:return e=Ae.getUint32(C),C+=4,yr>=C?Yr.slice(C-Zt,(C+=e)-Zt):wb(e);case 220:return e=Ae.getUint16(C),C+=2,Zp(e);case 221:return e=Ae.getUint32(C),C+=4,Zp(e);case 222:return e=Ae.getUint16(C),C+=2,Qp(e);case 223:return e=Ae.getUint32(C),C+=4,Qp(e);default:if(i>=224)return i-256;if(i===void 0){let t=new Error("Unexpected end of MessagePack data");throw t.incomplete=!0,t}throw new Error("Unknown MessagePack token "+i)}}}var bb=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function ka(i,e){function t(){if(t.count++>2){let o=i.read=new Function("r","return function(){return {"+i.map(n=>bb.test(n)?n+":r()":"["+JSON.stringify(n)+"]:r()").join(",")+"}}")(Xe);return i.highByte===0&&(i.read=Kp(e,i.read)),o()}let r={};for(let o=0,n=i.length;o<n;o++){let s=i[o];r[s]=Xe()}return r}return t.count=0,i.highByte===0?Kp(e,t):t}var Kp=(i,e)=>function(){let t=Q[C++];if(t===0)return e();let r=i<32?-(i+(t<<5)):i+(t<<5),o=Me[r]||Xp()[r];if(!o)throw new Error("Record id is not defined for "+r);return o.read||(o.read=ka(o,i)),o.read()};function Xp(){let i=iu(()=>(Q=null,jt.getStructures()));return Me=jt._mergeStructures(i,Me)}var Ha=ps,vb=ps,Sb=ps,wb=ps;function ps(i){let e;if(i<16&&(e=qa(i)))return e;if(i>64&&Fa)return Fa.decode(Q.subarray(C,C+=i));let t=C+i,r=[];for(e="";C<t;){let o=Q[C++];if((o&128)==0)r.push(o);else if((o&224)==192){let n=Q[C++]&63;r.push((o&31)<<6|n)}else if((o&240)==224){let n=Q[C++]&63,s=Q[C++]&63;r.push((o&31)<<12|n<<6|s)}else if((o&248)==240){let n=Q[C++]&63,s=Q[C++]&63,a=Q[C++]&63,l=(o&7)<<18|n<<12|s<<6|a;l>65535&&(l-=65536,r.push(l>>>10&1023|55296),l=56320|l&1023),r.push(l)}else r.push(o);r.length>=4096&&(e+=ct.apply(String,r),r.length=0)}return r.length>0&&(e+=ct.apply(String,r)),e}function Zp(i){let e=new Array(i);for(let t=0;t<i;t++)e[t]=Xe();return e}function Qp(i){if(jt.mapsAsObjects){let e={};for(let t=0;t<i;t++)e[tu()]=Xe();return e}else{let e=new Map;for(let t=0;t<i;t++)e.set(Xe(),Xe());return e}}var ct=String.fromCharCode;function Yp(i){let e=C,t=new Array(i);for(let r=0;r<i;r++){let o=Q[C++];if((o&128)>0){C=e;return}t[r]=o}return ct.apply(String,t)}function qa(i){if(i<4)if(i<2){if(i===0)return"";{let e=Q[C++];if((e&128)>1){C-=1;return}return ct(e)}}else{let e=Q[C++],t=Q[C++];if((e&128)>0||(t&128)>0){C-=2;return}if(i<3)return ct(e,t);let r=Q[C++];if((r&128)>0){C-=3;return}return ct(e,t,r)}else{let e=Q[C++],t=Q[C++],r=Q[C++],o=Q[C++];if((e&128)>0||(t&128)>0||(r&128)>0||(o&128)>0){C-=4;return}if(i<6){if(i===4)return ct(e,t,r,o);{let n=Q[C++];if((n&128)>0){C-=5;return}return ct(e,t,r,o,n)}}else if(i<8){let n=Q[C++],s=Q[C++];if((n&128)>0||(s&128)>0){C-=6;return}if(i<7)return ct(e,t,r,o,n,s);let a=Q[C++];if((a&128)>0){C-=7;return}return ct(e,t,r,o,n,s,a)}else{let n=Q[C++],s=Q[C++],a=Q[C++],l=Q[C++];if((n&128)>0||(s&128)>0||(a&128)>0||(l&128)>0){C-=8;return}if(i<10){if(i===8)return ct(e,t,r,o,n,s,a,l);{let c=Q[C++];if((c&128)>0){C-=9;return}return ct(e,t,r,o,n,s,a,l,c)}}else if(i<12){let c=Q[C++],d=Q[C++];if((c&128)>0||(d&128)>0){C-=10;return}if(i<11)return ct(e,t,r,o,n,s,a,l,c,d);let p=Q[C++];if((p&128)>0){C-=11;return}return ct(e,t,r,o,n,s,a,l,c,d,p)}else{let c=Q[C++],d=Q[C++],p=Q[C++],u=Q[C++];if((c&128)>0||(d&128)>0||(p&128)>0||(u&128)>0){C-=12;return}if(i<14){if(i===12)return ct(e,t,r,o,n,s,a,l,c,d,p,u);{let f=Q[C++];if((f&128)>0){C-=13;return}return ct(e,t,r,o,n,s,a,l,c,d,p,u,f)}}else{let f=Q[C++],m=Q[C++];if((f&128)>0||(m&128)>0){C-=14;return}if(i<15)return ct(e,t,r,o,n,s,a,l,c,d,p,u,f,m);let x=Q[C++];if((x&128)>0){C-=15;return}return ct(e,t,r,o,n,s,a,l,c,d,p,u,f,m,x)}}}}}function Wa(i){return jt.copyBuffers?Uint8Array.prototype.slice.call(Q,C,C+=i):Q.subarray(C,C+=i)}function bo(i){let e=Q[C++];if(Lt[e])return Lt[e](Q.subarray(C,C+=i));throw new Error("Unknown extension type "+e)}var eu=new Array(4096);function tu(){let i=Q[C++];if(i>=160&&i<192){if(i=i-160,yr>=C)return Yr.slice(C-Zt,(C+=i)-Zt);if(!(yr==0&&Qr<180))return Ha(i)}else return C--,Xe();let e=(i<<5^(i>1?Ae.getUint16(C):i>0?Q[C]:0))&4095,t=eu[e],r=C,o=C+i-3,n,s=0;if(t&&t.bytes==i){for(;r<o;){if(n=Ae.getUint32(r),n!=t[s++]){r=1879048192;break}r+=4}for(o+=3;r<o;)if(n=Q[r++],n!=t[s++]){r=1879048192;break}if(r===o)return C=r,t.string;o-=3,r=C}for(t=[],eu[e]=t,t.bytes=i;r<o;)n=Ae.getUint32(r),t.push(n),r+=4;for(o+=3;r<o;)n=Q[r++],t.push(n);let a=i<16?qa(i):Yp(i);return a!=null?t.string=a:t.string=Ha(i)}var ru=(i,e)=>{var t=Xe();let r=i;e!==void 0&&(i=i<32?-((e<<5)+i):(e<<5)+i,t.highByte=e);let o=Me[i];return o&&o.isShared&&((Me.restoreStructures||(Me.restoreStructures=[]))[i]=o),Me[i]=t,t.read=ka(t,r),t.read()},ou=typeof self=="object"?self:global;Lt[0]=()=>{};Lt[0].noBuffer=!0;Lt[101]=()=>{let i=Xe();return(ou[i[0]]||Error)(i[1])};Lt[105]=i=>{let e=Ae.getUint32(C-4);_r||(_r=new Map);let t=Q[C],r;t>=144&&t<160||t==220||t==221?r=[]:r={};let o={target:r};_r.set(e,o);let n=Xe();return o.used?Object.assign(r,n):(o.target=n,n)};Lt[112]=i=>{let e=Ae.getUint32(C-4),t=_r.get(e);return t.used=!0,t.target};Lt[115]=()=>new Set(Xe());var $a=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(i=>i+"Array");Lt[116]=i=>{let e=i[0],t=$a[e];if(!t)throw new Error("Could not find typed array for code "+e);return new ou[t](Uint8Array.prototype.slice.call(i,1).buffer)};Lt[120]=()=>{let i=Xe();return new RegExp(i[0],i[1])};Lt[98]=i=>{let e=(i[0]<<24)+(i[1]<<16)+(i[2]<<8)+i[3],t=C;C+=e-4,Ut=[Xe(),Xe()],Ut.position0=0,Ut.position1=0;let r=C;C=t;try{return Xe()}finally{C=r}};Lt[255]=i=>i.length==4?new Date((i[0]*16777216+(i[1]<<16)+(i[2]<<8)+i[3])*1e3):i.length==8?new Date(((i[0]<<22)+(i[1]<<14)+(i[2]<<6)+(i[3]>>2))/1e6+((i[3]&3)*4294967296+i[4]*16777216+(i[5]<<16)+(i[6]<<8)+i[7])*1e3):i.length==12?new Date(((i[0]<<24)+(i[1]<<16)+(i[2]<<8)+i[3])/1e6+((i[4]&128?-281474976710656:0)+i[6]*1099511627776+i[7]*4294967296+i[8]*16777216+(i[9]<<16)+(i[10]<<8)+i[11])*1e3):new Date("invalid");function iu(i){let e=Qr,t=C,r=Va,o=Zt,n=yr,s=Yr,a=Ra,l=_r,c=Ut,d=new Uint8Array(Q.slice(0,Qr)),p=Me,u=Me.slice(0,Me.length),f=jt,m=ti,x=i();return Qr=e,C=t,Va=r,Zt=o,yr=n,Yr=s,Ra=a,_r=l,Ut=c,Q=d,ti=m,Me=p,Me.splice(0,Me.length,...u),jt=f,Ae=new DataView(Q.buffer,Q.byteOffset,Q.byteLength),x}function us(){Q=null,_r=null,Me=null}function nu(i){i.unpack?Lt[i.type]=i.unpack:Lt[i.type]=i}var hs=new Array(147);for(let i=0;i<256;i++)hs[i]=+("1e"+Math.floor(45.15-i*.30103));var ms=new Dr({useRecords:!1}),Nb=ms.unpack,Cb=ms.unpackMultiple,Lb=ms.unpack;var Tb=new Float32Array(1),ZO=new Uint8Array(Tb.buffer,0,4);"use strict";var fs;try{fs=new TextEncoder}catch(i){}var ys,Ja,gs=typeof Buffer!="undefined",Ka=gs?Buffer.allocUnsafeSlow:Uint8Array,au=gs?Buffer:Uint8Array,lu=gs?4294967296:2144337920,G,Ze,M=0,gr,xr=null,Ib=/[\u0080-\uFFFF]/,Gi=Symbol("record-id"),ri=class extends Dr{constructor(e){super(e);this.offset=0;let t,r,o,n,s,a,l=0,c=au.prototype.utf8Write?function(h,I,b){return G.utf8Write(h,I,b)}:fs&&fs.encodeInto?function(h,I){return fs.encodeInto(h,G.subarray(I)).written}:!1,d=this;e||(e={});let p=e&&e.sequential,u=e.structures||e.saveStructures,f=e.maxSharedStructures;if(f==null&&(f=u?32:0),f>8160)throw new Error("Maximum maxSharedStructure is 8160");let m=e.maxOwnStructures;m==null&&(m=u?32:64),p&&!e.saveStructures&&(this.structures=[]);let x=f>32||m+f>64,y=f+64,N=f+m+64;if(N>8256)throw new Error("Maximum maxSharedStructure + maxOwnStructure is 8192");let L=[],w=0,B=0;this.pack=this.encode=function(h,I){if(G||(G=new Ka(8192),Ze=new DataView(G.buffer,0,8192),M=0),gr=G.length-10,gr-M<2048?(G=new Ka(G.length),Ze=new DataView(G.buffer,0,G.length),gr=G.length-10,M=0):M=M+7&2147483640,r=M,a=d.structuredClone?new Map:null,d.bundleStrings?(xr=["",""],G[M++]=214,G[M++]=98,xr.position=M-r,M+=4):xr=null,o=d.structures,o){o.uninitialized&&(o=d._mergeStructures(d.getStructures()));let b=o.sharedLength||0;if(b>f)throw new Error("Shared structures is larger than maximum shared structures, try increasing maxSharedStructures to "+o.sharedLength);if(!o.transitions){o.transitions=Object.create(null);for(let P=0;P<b;P++){let v=o[P];if(!v)continue;let D,Z=o.transitions;for(let V=0,ie=v.length;V<ie;V++){let oe=v[V];D=Z[oe],D||(D=Z[oe]=Object.create(null)),Z=D}Z[Gi]=P+64}l=b}p||(o.nextId=b+64)}n&&(n=!1),s=o||[];try{if(S(h),xr){Ze.setUint32(xr.position+r,M-xr.position-r);let b=xr;xr=null,S(b[0]),S(b[1])}if(d.offset=M,a&&a.idsToInsert){M+=a.idsToInsert.length*6,M>gr&&T(M),d.offset=M;let b=Pb(G.subarray(r,M),a.idsToInsert);return a=null,b}return I&uu?(G.start=r,G.end=M,G):G.subarray(r,M)}finally{if(o){if(B<10&&B++,w>1e4)o.transitions=null,B=0,w=0,L.length>0&&(L=[]);else if(L.length>0&&!p){for(let b=0,P=L.length;b<P;b++)L[b][Gi]=0;L=[]}if(n&&d.saveStructures){let b=o.sharedLength||f;o.length>b&&(o=o.slice(0,b));let P=G.subarray(r,M);return d.saveStructures(o,l)===!1?(d._mergeStructures(d.getStructures()),d.pack(h)):(l=b,P)}}I&jb&&(M=r)}};let S=h=>{M>gr&&(G=T(M));var I=typeof h,b;if(I==="string"){let P=h.length;if(xr&&P>=8&&P<4096){let Z=Ib.test(h);xr[Z?0:1]+=h,G[M++]=193,S(Z?-P:P);return}let v;P<32?v=1:P<256?v=2:P<65536?v=3:v=5;let D=P*3;if(M+D>gr&&(G=T(M+D)),P<64||!c){let Z,V,ie,oe=M+v;for(Z=0;Z<P;Z++)V=h.charCodeAt(Z),V<128?G[oe++]=V:V<2048?(G[oe++]=V>>6|192,G[oe++]=V&63|128):(V&64512)==55296&&((ie=h.charCodeAt(Z+1))&64512)==56320?(V=65536+((V&1023)<<10)+(ie&1023),Z++,G[oe++]=V>>18|240,G[oe++]=V>>12&63|128,G[oe++]=V>>6&63|128,G[oe++]=V&63|128):(G[oe++]=V>>12|224,G[oe++]=V>>6&63|128,G[oe++]=V&63|128);b=oe-M-v}else b=c(h,M+v,D);b<32?G[M++]=160|b:b<256?(v<2&&G.copyWithin(M+2,M+1,M+1+b),G[M++]=217,G[M++]=b):b<65536?(v<3&&G.copyWithin(M+3,M+2,M+2+b),G[M++]=218,G[M++]=b>>8,G[M++]=b&255):(v<5&&G.copyWithin(M+5,M+3,M+3+b),G[M++]=219,Ze.setUint32(M,b),M+=4),M+=b}else if(I==="number")if(h>>>0===h)h<64?G[M++]=h:h<256?(G[M++]=204,G[M++]=h):h<65536?(G[M++]=205,G[M++]=h>>8,G[M++]=h&255):(G[M++]=206,Ze.setUint32(M,h),M+=4);else if(h>>0===h)h>=-32?G[M++]=256+h:h>=-128?(G[M++]=208,G[M++]=h+256):h>=-32768?(G[M++]=209,Ze.setInt16(M,h),M+=2):(G[M++]=210,Ze.setInt32(M,h),M+=4);else{let P;if((P=this.useFloat32)>0&&h<4294967296&&h>=-2147483648){G[M++]=202,Ze.setFloat32(M,h);let v;if(P<4||(v=h*hs[(G[M]&127)<<1|G[M+1]>>7])>>0===v){M+=4;return}else M--}G[M++]=203,Ze.setFloat64(M,h),M+=8}else if(I==="object")if(!h)G[M++]=192;else{if(a){let v=a.get(h);if(v){if(!v.id){let D=a.idsToInsert||(a.idsToInsert=[]);v.id=D.push(v)}G[M++]=214,G[M++]=112,Ze.setUint32(M,v.id),M+=4;return}else a.set(h,{offset:M-r})}let P=h.constructor;if(P===Object)_(h,!0);else if(P===Array){b=h.length,b<16?G[M++]=144|b:b<65536?(G[M++]=220,G[M++]=b>>8,G[M++]=b&255):(G[M++]=221,Ze.setUint32(M,b),M+=4);for(let v=0;v<b;v++)S(h[v])}else if(P===Map){b=h.size,b<16?G[M++]=128|b:b<65536?(G[M++]=222,G[M++]=b>>8,G[M++]=b&255):(G[M++]=223,Ze.setUint32(M,b),M+=4);for(let[v,D]of h)S(v),S(D)}else{for(let v=0,D=ys.length;v<D;v++){let Z=Ja[v];if(h instanceof Z){let V=ys[v];if(V.write){V.type&&(G[M++]=212,G[M++]=V.type,G[M++]=0),S(V.write.call(this,h));return}let ie=G,oe=Ze,ge=M;G=null;let xe;try{xe=V.pack.call(this,h,A=>(G=ie,ie=null,M+=A,M>gr&&T(M),{target:G,targetView:Ze,position:M-A}),S)}finally{ie&&(G=ie,Ze=oe,M=ge,gr=G.length-10)}xe&&(xe.length+M>gr&&T(xe.length+M),M=Mb(xe,G,M,V.type));return}}_(h,!h.hasOwnProperty)}}else if(I==="boolean")G[M++]=h?195:194;else if(I==="bigint"){if(h<BigInt(1)<<BigInt(63)&&h>=-(BigInt(1)<<BigInt(63)))G[M++]=211,Ze.setBigInt64(M,h);else if(h<BigInt(1)<<BigInt(64)&&h>0)G[M++]=207,Ze.setBigUint64(M,h);else if(this.largeBigIntToFloat)G[M++]=203,Ze.setFloat64(M,Number(h));else throw new RangeError(h+" was too large to fit in MessagePack 64-bit integer format, set largeBigIntToFloat to convert to float-64");M+=8}else if(I==="undefined")this.encodeUndefinedAsNil?G[M++]=192:(G[M++]=212,G[M++]=0,G[M++]=0);else if(I==="function")S(this.writeFunction&&this.writeFunction());else throw new Error("Unknown type: "+I)},_=this.useRecords===!1?this.variableMapSize?h=>{let I=Object.keys(h),b=I.length;b<16?G[M++]=128|b:b<65536?(G[M++]=222,G[M++]=b>>8,G[M++]=b&255):(G[M++]=223,Ze.setUint32(M,b),M+=4);let P;for(let v=0;v<b;v++)S(P=I[v]),S(h[P])}:(h,I)=>{G[M++]=222;let b=M-r;M+=2;let P=0;for(let v in h)(I||h.hasOwnProperty(v))&&(S(v),S(h[v]),P++);G[b+++r]=P>>8,G[b+r]=P&255}:h=>{let I=Object.keys(h),b,P=s.transitions||(s.transitions=Object.create(null)),v=0;for(let Z=0,V=I.length;Z<V;Z++){let ie=I[Z];b=P[ie],b||(b=P[ie]=Object.create(null),v++),P=b}let D=P[Gi];if(D)D>=96&&x?(G[M++]=((D-=96)&31)+96,G[M++]=D>>5):G[M++]=D;else{D=s.nextId,D||(D=64),D<y&&this.shouldShareStructure&&!this.shouldShareStructure(I)?(D=s.nextOwnId,D<N||(D=y),s.nextOwnId=D+1):(D>=N&&(D=y),s.nextId=D+1);let Z=I.highByte=D>=96&&x?D-96>>5:-1;P[Gi]=D,s[D-64]=I,D<y?(I.isShared=!0,s.sharedLength=D-63,n=!0,Z>=0?(G[M++]=(D&31)+96,G[M++]=Z):G[M++]=D):(Z>=0?(G[M++]=213,G[M++]=114,G[M++]=(D&31)+96,G[M++]=Z):(G[M++]=212,G[M++]=114,G[M++]=D),v&&(w+=B*v),L.length>=m&&(L.shift()[Gi]=0),L.push(P),S(I))}for(let Z=0,V=I.length;Z<V;Z++)S(h[I[Z]])},T=h=>{let I;if(h>16777216){if(h-r>lu)throw new Error("Packed buffer would be larger than maximum buffer size");I=Math.min(lu,Math.round(Math.max((h-r)*(h>67108864?1.25:2),4194304)/4096)*4096)}else I=(Math.max(h-r<<2,G.length-1)>>12)+1<<12;let b=new Ka(I);return Ze=new DataView(b.buffer,0,I),G.copy?G.copy(b,0,r,h):b.set(G.slice(r,h)),M-=r,r=0,gr=b.length-10,G=b}}useBuffer(e){G=e,Ze=new DataView(G.buffer,G.byteOffset,G.byteLength),M=0}};Ja=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,cs];ys=[{pack(i,e,t){let r=i.getTime()/1e3;if((this.useTimestamp32||i.getMilliseconds()===0)&&r>=0&&r<4294967296){let{target:o,targetView:n,position:s}=e(6);o[s++]=214,o[s++]=255,n.setUint32(s,r)}else if(r>0&&r<17179869184){let{target:o,targetView:n,position:s}=e(10);o[s++]=215,o[s++]=255,n.setUint32(s,i.getMilliseconds()*4e6+(r/1e3/4294967296>>0)),n.setUint32(s+4,r)}else if(isNaN(r)){if(this.onInvalidDate)return e(0),t(this.onInvalidDate());let{target:o,targetView:n,position:s}=e(3);o[s++]=212,o[s++]=255,o[s++]=255}else{let{target:o,targetView:n,position:s}=e(15);o[s++]=199,o[s++]=12,o[s++]=255,n.setUint32(s,i.getMilliseconds()*1e6),n.setBigInt64(s+4,BigInt(Math.floor(r)))}}},{pack(i,e,t){let r=Array.from(i),{target:o,position:n}=e(this.structuredClone?3:0);this.structuredClone&&(o[n++]=212,o[n++]=115,o[n++]=0),t(r)}},{pack(i,e,t){let{target:r,position:o}=e(this.structuredClone?3:0);this.structuredClone&&(r[o++]=212,r[o++]=101,r[o++]=0),t([i.name,i.message])}},{pack(i,e,t){let{target:r,position:o}=e(this.structuredClone?3:0);this.structuredClone&&(r[o++]=212,r[o++]=120,r[o++]=0),t([i.source,i.flags])}},{pack(i,e){this.structuredClone?cu(i,16,e):du(gs?Buffer.from(i):new Uint8Array(i),e)}},{pack(i,e){let t=i.constructor;t!==au&&this.structuredClone?cu(i,$a.indexOf(t.name),e):du(i,e)}},{pack(i,e){let{target:t,position:r}=e(1);t[r]=193}}];function cu(i,e,t,r){let o=i.byteLength;if(o+1<256){var{target:n,position:s}=t(4+o);n[s++]=199,n[s++]=o+1}else if(o+1<65536){var{target:n,position:s}=t(5+o);n[s++]=200,n[s++]=o+1>>8,n[s++]=o+1&255}else{var{target:n,position:s,targetView:a}=t(7+o);n[s++]=201,a.setUint32(s,o+1),s+=4}n[s++]=116,n[s++]=e,n.set(new Uint8Array(i.buffer,i.byteOffset,i.byteLength),s)}function du(i,e){let t=i.byteLength;var r,o;if(t<256){var{target:r,position:o}=e(t+2);r[o++]=196,r[o++]=t}else if(t<65536){var{target:r,position:o}=e(t+3);r[o++]=197,r[o++]=t>>8,r[o++]=t&255}else{var{target:r,position:o,targetView:n}=e(t+5);r[o++]=198,n.setUint32(o,t),o+=4}r.set(i,o)}function Mb(i,e,t,r){let o=i.length;switch(o){case 1:e[t++]=212;break;case 2:e[t++]=213;break;case 4:e[t++]=214;break;case 8:e[t++]=215;break;case 16:e[t++]=216;break;default:o<256?(e[t++]=199,e[t++]=o):o<65536?(e[t++]=200,e[t++]=o>>8,e[t++]=o&255):(e[t++]=201,e[t++]=o>>24,e[t++]=o>>16&255,e[t++]=o>>8&255,e[t++]=o&255)}return e[t++]=r,e.set(i,t),t+=o,t}function Pb(i,e){let t,r=e.length*6,o=i.length-r;for(e.sort((n,s)=>n.offset>s.offset?1:-1);t=e.pop();){let n=t.offset,s=t.id;i.copyWithin(n+r,n,o),r-=6;let a=n+r;i[a++]=214,i[a++]=105,i[a++]=s>>24,i[a++]=s>>16&255,i[a++]=s>>8&255,i[a++]=s&255,o=n}return i}function vo(i){if(i.Class){if(!i.pack&&!i.write)throw new Error("Extension has no pack or write function");if(i.pack&&!i.type)throw new Error("Extension has no type (numeric code to identify the extension)");Ja.unshift(i.Class),ys.unshift(i)}nu(i)}var pu=new ri({useRecords:!1}),Ob=pu.pack,Ab=pu.pack;var uu=512,jb=1024;var hu=new ri({structuredClone:!0});vo({Class:nr.prototype.constructor,type:1,write(i){return O({},i)},read(i){return Object.setPrototypeOf(i,nr.prototype),i}});vo({Class:Ke.prototype.constructor,type:2,write(i){return[...i]},read(i){return Object.setPrototypeOf(i,Ke.prototype),i}});vo({Class:sr.prototype.constructor,type:3,write(i){return[...i]},read(i){return Object.setPrototypeOf(i,sr.prototype),i}});vo({Class:as.prototype.constructor,type:4,write(i){return i.id},read(i){return new as(i)}});vo({Class:ls.prototype.constructor,type:5,write(i){return i.data},read(i){return new ls(i)}});function _b(i){var e=0;if(i.length===0)return e;for(let t=0;t<i.length;t++){let r=i[t];e=(e<<5)-e+r,e=e&e}return e}var xs;(function(r){function i(o){return hu.pack(o)}r.serialize=i;function e(o){return hu.unpack(o)}r.deserialize=e;function t(o){return _b(i(o)).toString()}r.checksum=t})(xs||(xs={}));var bs;(function(t){t.all=["PointLight","SpotLight","DirectionalLight","HemisphereLight"];function e(r){return t.all.includes(r)}t.is=e})(bs||(bs={}));var vs;(function(t){function i(r){return e(r)}t.defaultData=i;function e(r){if(r==="PointLight")return{type:r,color:mr.white,intensity:1,distance:2e3,decay:1,shadows:!0,shadowResolution:1024,shadowRadius:1,depth:2500,helper:!0};if(r==="SpotLight")return{type:r,color:mr.white,intensity:1,distance:2e3,decay:1,shadows:!0,penumbra:0,angle:30/180*Math.PI,depth:2500,helper:!0};if(r==="DirectionalLight")return{type:r,color:mr.white,intensity:1,shadows:!0,size:2500,depth:2500,helper:!0};throw new Error("not implemented")}})(vs||(vs={}));var oi;(function(r){r[r.Front=0]="Front",r[r.Back=1]="Back",r[r.Double=2]="Double"})(oi||(oi={}));var Xa;(function(t){t.defaultData={castShadow:!0,receiveShadow:!0};function e(r,o){return r.castShadow===o.castShadow&&r.receiveShadow===o.receiveShadow}t.equals=e})(Xa||(Xa={}));var Za;(function(t){t.defaultData={flatShading:!1,wireframe:!1,side:0};function e(r,o){return r.flatShading===o.flatShading&&r.side===o.side&&r.wireframe===o.wireframe}t.equals=e})(Za||(Za={}));var Ss;(function(e){e.defaultData=$(O(O({},Za.defaultData),Xa.defaultData),{cloner:null})})(Ss||(Ss={}));var Tt;(function(o){o[o.Left=1]="Left",o[o.Right=2]="Right",o[o.Center=3]="Center",o[o.Justify=4]="Justify"})(Tt||(Tt={}));var Br;(function(r){r[r.Top=1]="Top",r[r.Center=2]="Center",r[r.Bottom=3]="Bottom"})(Br||(Br={}));var eo;(function(r){r[r.None=1]="None",r[r.Upper=2]="Upper",r[r.Lower=3]="Lower"})(eo||(eo={}));var ws;(function(e){e.defaultData={width:100,height:100,horizontalAlign:1,verticalAlign:1,fontSize:16,lineHeight:1.5,letterSpacing:1,text:"",textTransform:1,color:mr.fromHexAndA(6974058,1),alpha:1,font:"roboto_regular"}})(ws||(ws={}));var it;(function(o){o[o.Normal=0]="Normal",o[o.Multiply=1]="Multiply",o[o.Screen=2]="Screen",o[o.Overlay=3]="Overlay"})(it||(it={}));var ii;(function(r){r[r.Linear=0]="Linear",r[r.Radial=1]="Radial",r[r.Polar=2]="Polar"})(ii||(ii={}));var Ns;(function(r){r[r.RepeatWrapping=1e3]="RepeatWrapping",r[r.ClampToEdgeWrapping=1001]="ClampToEdgeWrapping",r[r.MirroredRepeatWrapping=1002]="MirroredRepeatWrapping"})(Ns||(Ns={}));var Cs;(function(o){o[o.UV=0]="UV",o[o.Planar=1]="Planar",o[o.Spherical=2]="Spherical",o[o.Cylindrical=3]="Cylindrical"})(Cs||(Cs={}));var Ls;(function(n){n[n.Simplex=0]="Simplex",n[n.SimplexFractal=1]="SimplexFractal",n[n.Ashima=2]="Ashima",n[n.Fbm=3]="Fbm",n[n.Perlin=4]="Perlin"})(Ls||(Ls={}));var ni;(function(r){function i(o,n){return o==="light"&&n?e(n):t(o)}r.defaultData=i;function e(o){switch(o){case"basic":return{type:"light",category:"basic",alpha:1,visible:!0,mode:0};case"phong":return{category:"phong",specular:{r:.2,g:.2,b:.2},shininess:10,type:"light",alpha:1,visible:!0,mode:0};case"toon":return{category:"toon",specular:{r:.2,g:.2,b:.2},shininess:10,type:"light",alpha:1,visible:!0,mode:0};case"lambert":return{category:"lambert",emissive:{r:.2,g:.2,b:.2,a:1},type:"light",alpha:1,visible:!0,mode:0};case"physical":return{category:"physical",roughness:.2,metalness:.2,reflectivity:.2,type:"light",alpha:1,visible:!0,mode:0}}}function t(o){switch(o){case"texture":return{alpha:1,visible:!0,size:[128,128],mode:0,axis:Yo.x,type:"texture",projection:0,texture:{image:"image_0",wrapping:1001,repeat:[1,1],offset:[0,0]},crop:!0};case"color":return{type:"color",alpha:1,visible:!0,mode:0,color:Rt.fromHex(4737101)};case"depth":return{type:"depth",alpha:1,visible:!0,mode:0,gradientType:1,smooth:!1,isVector:!0,isWorldSpace:!1,origin:[0,0,0],direction:[1,0,0],colors:[[1,1,1,1],[0,0,0,1],[0,0,0,1],[0,0,0,1],[0,0,0,1],[0,0,0,1],[0,0,0,1],[0,0,0,1],[0,0,0,1],[0,0,0,1]],steps:[0,1,1,1,1,1,1,1,1,1],num:2,near:50,far:200};case"normal":return{type:"normal",alpha:1,visible:!0,mode:0,cnormal:[1,1,1]};case"gradient":return{type:"gradient",alpha:1,visible:!0,mode:0,gradientType:0,smooth:!1,colors:[[0,0,0,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1]],steps:[0,1,1,1,1,1,1,1,1,1],num:2,angle:0,offset:[0,0],morph:[0,0]};case"noise":return{type:"noise",alpha:1,visible:!0,mode:0,size:[100,100,100],noiseType:0,scale:1,move:1,colorA:$(O({},Rt.fromHex(6710886)),{a:1}),colorB:$(O({},Rt.fromHex(6710886)),{a:1}),colorC:$(O({},Rt.fromHex(16777215)),{a:1}),colorD:$(O({},Rt.fromHex(16777215)),{a:1}),distortion:[1,1],fA:[1.7,9.2],fB:[8.3,2.8]};case"fresnel":return{type:"fresnel",alpha:1,visible:!0,mode:0,color:mr.fromHexAndA(16777215,1),bias:.1,scale:1,intensity:2,factor:1};case"rainbow":return{type:"rainbow",alpha:1,visible:!0,mode:0,filmThickness:30,movement:0,wavelengths:[0,0,0],noiseStrength:0,noiseScale:1,offset:[0,0,0]};case"matcap":return{type:"matcap",alpha:1,visible:!0,mode:0,texture:{image:"matcap_0",wrapping:1001,repeat:[1,1],offset:[0,0]}};case"transmission":return{type:"transmission",alpha:1,visible:!0,mode:0,thickness:10,ior:1.5,roughness:1};case"displace":return{type:"displace",displacementType:"noise",noiseType:0,scale:10,movement:1,offset:[0,0,0],intensity:8,visible:!0}}}})(ni||(ni={}));var si;(function(a){function i(l){return!l.layers.some(d=>{if(d.data.type==="texture"&&d.data.projection!==0||d.data.type==="depth"&&!d.data.isWorldSpace||d.data.type==="noise"||d.data.type==="displace")return!0})&&!t(l)}a.isMergable=i;function e(l){let c="";return l.layers.forEach(d=>{Object.entries(d.data).forEach(([p,u])=>{c+=`${p}${u}`,Array.isArray(u)?u.forEach(f=>c+=`${f}`):typeof u=="object"?Object.values(u).forEach(f=>{typeof f=="number"?c+=`${f.toFixed(4)}`:c+=`${f}`}):c+=`${u}`})}),c}a.getHash=e;function t(l){let c=0;for(let d of l.layers)"alpha"in d.data&&d.data.type!=="light"&&d.data.type!=="fresnel"&&(c+=(1-c)*d.data.alpha);return c<1}a.isTransparent=t;function r(){return{layers:new Ke}}a.defaultEmptyData=r;function o(l="layer1",c="layer2"){return n("phong",l,c)}a.defaultData=o;function n(l,c="layer1",d="layer2"){let p=new Ke;return p.push({fi:0,data:ni.defaultData("light",l),id:c}),p.push({fi:1,data:ni.defaultData("color"),id:d}),{layers:p}}a.defaultTwoLayerData=n;function s(l,c="basic",d="layer1",p="layer2"){let u=ni.defaultData("texture");Object.assign(u.texture,{image:l});let f=new Ke;return f.push({fi:0,data:u,id:d}),f.push({fi:1,data:ni.defaultData("light",c),id:p}),{layers:f}}a.defaultTwoLayerTextureData=s})(si||(si={}));var ai;(function(r){function i(){return{points:new Ke,roundness:0,shapeHoles:[],isClosed:!1}}r.defaultData=i;function e(o,n){let{points:s}=n;if(s){for(let a of s)if(a.data.position[0]===o[0]&&a.data.position[1]===o[1])return!0}return!1}r.isOverlappingExistingPoint=e;function t(o,n){let s=o.controlNext,a=n.controlPrevious;return o.position[0]===s.position[0]&&o.position[1]===s.position[1]&&n.position[0]===a.position[0]&&n.position[1]===a.position[1]}r.isStraightLine=t})(ai||(ai={}));var Ts;(function(e){function i(t){return t==="PolygonGeometry"||t==="RectangleGeometry"||t==="StarGeometry"||t==="TriangleGeometry"||t==="EllipseGeometry"}e.is2DParametricMesh=i})(Ts||(Ts={}));var Is;(function(e){function i(t){if(t==="RectangleGeometry")return{width:320,height:320,type:t,cornerRadius:[0,0,0,0],cornerType:0,depth:0,extrudeBevelSize:0,extrudeBevelSegments:1,surfaceMaxCount:1};if(t==="VectorGeometry")return{width:100,height:100,type:t,subdivisions:12,shape:ai.defaultData(),depth:0,extrudeBevelSize:0,extrudeBevelSegments:1,surfaceMaxCount:1};throw new Error("not implemented")}e.defaultData=i})(Is||(Is={}));var zi;(function(o){o.identity=$(O({},ts.identity),{hiddenMatrix:Zr.identity});function e(n){return{position:n.position,rotation:n.rotation,scale:n.scale,hiddenMatrix:n.hiddenMatrix}}o.fromObject=e;function t(n,s){return{position:(s==null?void 0:s.position)||n.position,rotation:(s==null?void 0:s.rotation)||n.rotation,scale:(s==null?void 0:s.scale)||n.scale,hiddenMatrix:(s==null?void 0:s.hiddenMatrix)||n.hiddenMatrix}}o.merge=t;function r(n,s){return{position:ei.isEqual(n.position,s.position)?null:s.position,rotation:ei.isEqual(n.rotation,s.rotation)?null:s.rotation,scale:ei.isEqual(n.scale,s.scale)?null:s.scale,hiddenMatrix:Zr.isEqual(n.hiddenMatrix,s.hiddenMatrix)?null:s.hiddenMatrix}}o.diff=r})(zi||(zi={}));var to;(function(e){e.defaultData=O({states:new Ke,events:new Ke,visible:!0,raycastLock:!1},zi.identity)})(to||(to={}));var mu;(function(e){e.defaultData=O({type:"Empty"},to.defaultData)})(mu||(mu={}));var Qa;(function(e){e.defaultData=O(O({type:"Mesh"},to.defaultData),Ss.defaultData)})(Qa||(Qa={}));var fu;(function(e){e.defaultData=O(O({type:"TextFrame"},to.defaultData),ws.defaultData)})(fu||(fu={}));var Ms;(function(e){e.defaultData=O(O(O({},to.defaultData),zi.identity),xo.defaultData)})(Ms||(Ms={}));var yu;(function(e){function i(t){return O(O({},to.defaultData),vs.defaultData(t))}e.defaultData=i})(yu||(yu={}));var gu;(function(t){t.defaultCamera=O({position:[0,0,1e3],scale:[1,1,1],rotation:[0,0,0],hiddenMatrix:Zr.identity,name:"Play Camera",visible:!0,raycastLock:!1,states:new Ke,events:new Ke},xo.defaultData),t.defaultMeshObject=$(O(O({name:"Rectangle"},to.defaultData),Qa.defaultData),{geometry:Is.defaultData("RectangleGeometry"),material:si.defaultTwoLayerData("basic","layer1","layer2")})})(gu||(gu={}));var xu;(function(t){function i(r,o){if(o===void 0)return r;let n=O({},r);return"material"in n&&"material"in o&&o.material&&(n.material=za(n.material,s=>{if(typeof s!="string")for(let[a,l]of Object.entries(o.material.layers)){let c=s.layers.data(a);c&&go(c,l)}}).data),n.materials&&o.materials&&(n.materials=za(n.materials,s=>{var a,l;for(let c=0;c<n.materials.length;c++){let d=o.materials[c];if(typeof d!="string")for(let[p,u]of Object.entries(d.layers)){let f=(l=(a=s[c])==null?void 0:a.layers)==null?void 0:l.data(p);f&&go(f,u)}}}).data),n}t.patchMaterialState=i;function e(r,o){var s,a;if(o===void 0)return r;let n=O({},r);if(Object.assign(n,zi.merge(n,o)),Qo.is(r.type)){n.orthographic=O({},n.orthographic),n.perspective=O({},n.perspective);let l=o;((s=l.orthographic)==null?void 0:s.zoom)!==void 0&&(n.orthographic.zoom=l.orthographic.zoom),((a=l.perspective)==null?void 0:a.zoom)!==void 0&&(n.perspective.zoom=l.perspective.zoom)}else if(r.type==="Mesh")n.geometry=O({},n.geometry),Object.assign(n.geometry,o.geometry),n=i(n,o);else if(bs.is(r.type)){let l=o;n.intensity!==void 0&&(n.intensity=l.intensity),l.color!==void 0&&(n.color=Rt.clone(l.color))}return n}t.patch=e})(xu||(xu={}));var nt=5855577;var bu=2857471;var Ya=15711266;import{DoubleSide as Db,Mesh as Bb,MeshBasicMaterial as Gb,ShapeBufferGeometry as zb,Vector2 as Eb,Vector3 as Fb}from"three";import{FontLoader as Rb}from"three/examples/jsm/loaders/FontLoader.js";var Qe=class extends Bb{constructor({char:e,originalChar:t,fontFamily:r,letterSpacing:o,fontSize:n,LOD:s=16},a=new Gb({color:0,opacity:1,visible:!0,transparent:!0,side:Db})){let l=Qe.loadChar(e,r,s);super(l.geometry,a);this.char=e,this.originalChar=t!=null?t:e,this.fontFamily=r,this.letterSpacing=o,this.fontSize=n,this.LOD=s,this.resolution=l.resolution,this.glyphsHa=l.glyphsHa,this.localPosition=new Eb,this.charSize=0,this.geometry.userData={type:"CharacterGeometry",parameters:{char:this.char,fontFamily:this.fontFamily,letterSpacing:this.letterSpacing,fontSize:this.fontSize,lod:this.LOD,resolution:this.resolution,charSize:this.charSize,localPosition:this.localPosition}},this.updateFontSize(this.fontSize)}static get FONTS_PATH(){return Qe._fontPath}static set FONTS_PATH(e){Qe._fontPath=e}updatePosition(e,t){this.localPosition.copy(e);let r=new Fb(this.localPosition.x,-this.localPosition.y,0);this.position.copy(r).add(t)}updateFontSize(e){let t=e/this.resolution;this.fontSize=e,this.scale.set(this.fontSize,this.fontSize,1),this.charSize=this.glyphsHa*t*this.letterSpacing}updateFontFamily(e){if(this.fontFamily===e)return;this.fontFamily=e;let t=Qe.loadChar(this.char,e,this.LOD);this.geometry=t.geometry,this.resolution=t.resolution,this.glyphsHa=t.glyphsHa,this.geometry.userData={type:"CharacterGeometry",parameters:{char:this.char,fontFamily:this.fontFamily,letterSpacing:this.letterSpacing,fontSize:this.fontSize,lod:this.LOD,resolution:this.resolution,charSize:this.charSize,localPosition:this.localPosition}},this.updateFontSize(this.fontSize)}updateChar(e){if(this.char===e)return;this.char=e;let t=Qe.loadChar(e,this.fontFamily,this.LOD);this.geometry=t.geometry,this.resolution=t.resolution,this.glyphsHa=t.glyphsHa,this.geometry.userData={type:"CharacterGeometry",parameters:{char:this.char,fontFamily:this.fontFamily,letterSpacing:this.letterSpacing,fontSize:this.fontSize,lod:this.LOD,resolution:this.resolution,charSize:this.charSize,localPosition:this.localPosition}},this.updateFontSize(this.fontSize)}updateLetterSpacing(e){this.letterSpacing!==e&&(this.letterSpacing=e,this.updateFontSize(this.fontSize))}updateLOD(e){if(this.LOD===e)return;this.LOD=e;let t=Qe.loadChar(this.char,this.fontFamily,this.LOD);this.geometry=t.geometry,this.resolution=t.resolution,this.glyphsHa=t.glyphsHa,this.geometry.userData={type:"CharacterGeometry",parameters:{char:this.char,fontFamily:this.fontFamily,letterSpacing:this.letterSpacing,fontSize:this.fontSize,lod:this.LOD,resolution:this.resolution,charSize:this.charSize,localPosition:this.localPosition}},this.updateFontSize(this.fontSize)}clone(){let e={char:this.char,originalChar:this.originalChar,fontFamily:this.fontFamily,letterSpacing:this.letterSpacing,fontSize:this.fontSize,LOD:this.LOD};return new Qe(e).copy(this)}static loadFont(e){return new Promise(function(t,r){Qe.fontCache[e]?t(Qe.fontCache[e]):new Rb().load(Qe.FONTS_PATH+e+".json",n=>{Qe.fontCache[e]=n,t(n)},void 0,r)})}static loadChar(e,t,r){if(Qe.charCache[e]){if(Qe.charCache[e][r]&&Qe.charCache[e][r].fontFamily===t)return Qe.charCache[e][r]}else Qe.charCache[e]={};let o=Qe.fontCache[t],n=o.generateShapes(e,1);return Qe.charCache[e][r]={geometry:new zb(n,r),fontFamily:t,resolution:o.data.resolution,glyphsHa:o.data.glyphs[e].ha},Qe.charCache[e][r]}},_t=Qe;_t.charCache={},_t.fontCache={},_t._fontPath="/_assets/_fonts/";import{DoubleSide as Ta,MeshBasicMaterial as gm,Vector3 as xm,Object3D as kw}from"three";import{Mesh as vS}from"three";import{BufferGeometry as xj,ConeBufferGeometry as kb,Float32BufferAttribute as bj,Vector2 as vj,Vector3 as Sj}from"three";import{BufferGeometry as Vb,CylinderBufferGeometry as Ub,Float32BufferAttribute as el,Vector2 as ar,Vector3 as Ps}from"three";var vu=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,e){var s,a,l,c,d;let t=Object.assign({},(s=e==null?void 0:e.parameters)!=null?s:{width:100,radialSegments:64,heightSegments:1,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadius:0,cornerSegments:8,hollow:0},i.parameters),r=t.width/2,o=(a=t.radiusTop)!=null?a:r,n=(l=t.radiusBottom)!=null?l:r;return o===n?(o=r,n=r):o>n?(o=r,n=n*r/o):(o=o*r/n,n=r),{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs((c=t.height)!=null?c:t.width),depth:Math.abs((d=t.depth)!=null?d:t.width),radiusTop:o,radiusBottom:n})}}static build(i){let{width:e,depth:t,height:r,radialSegments:o,heightSegments:n,openEnded:s,thetaStart:a,thetaLength:l,radiusTop:c,radiusBottom:d,cornerRadius:p,cornerSegments:u,hollow:f}=i.parameters,m;return p||f?m=new Os(c,d,r,o,n,s,a,l*Math.PI/180,p,p,u,f):m=new Ub(c,d,r,o,n,s,a,l*Math.PI/180),m.scale(1,1,t/e),Object.assign(m,{userData:$(O({},i),{type:"CylinderGeometry"})})}};function ro(i,e,t){t.x=i.x*e.x,t.y=i.y,t.z=i.x*e.y}function Su(i){return new ar(i.y,-i.x)}var Os=class extends Vb{constructor(e,t,r,o,n,s,a,l,c,d,p,u,f=!1){super();this.type="RoundedCylinderBufferGeometry",e=e!==void 0?e:1,t=t!==void 0?t:1,r=r||1,o=Math.floor(o)||8,n=Math.floor(n)||1,s=s!==void 0?s:!1,a=a!==void 0?a:0,l=l!==void 0?l:Math.PI*2,s&&(c=0,d=0);let m=[],x=[],y=[],N=[],L=0,w=r/2,B=new Ps,S=new Ps;f&&e==0&&(e=c),f&&t==0&&(t=d);let _=new ar(e,w),T=new ar(t,-w),h=null,I=null,b=null,P=null,v=_.clone().sub(T),D=0,Z=0,V=0;u>0&&(D=Math.min(e,t)*(1-u),Z=e-D,V=t-D);let ie=_.clone();ie.x-=D;let oe=Math.PI-v.angle(),ge=v.angle(),xe=Math.tan(ge/2),A=Math.tan(oe/2),j=xe+A,g=u?j:A,z=u?j:xe;if(c=Math.min(c,(e-Z)/g,v.length()/j),d=Math.min(d,(t-V)/z,v.length()/j),c>0){let E=c/xe;h=_.clone().sub(new ar(E,c)),u&&(b=h.clone(),b.x-=D-j*c),_.sub(v.clone().setLength(E))}if(d>0){let E=d/A;I=T.clone().sub(new ar(E,-d)),T.add(v.clone().setLength(E)),u&&(P=I.clone(),P.x-=D-j*d,ie.sub(v.clone().setLength(E)))}v=_.clone().sub(T);let R=v.length()<.5,U=[];for(let E=0;E<=o;E++){let H=[],k=E/o,se=k*l+a,F=new ar(Math.sin(se),Math.cos(se));P&&I?(q(H,k,F,oe,d,P,-1,!0),q(H,k,F,ge,d,I,-1,!1)):I?(W(H,F,I.x,0,-1),q(H,k,F,ge,d,I,-1,!1)):s||W(H,F,t,V,-1);let K=Su(v).normalize();if(ro(K,F,B),!R)for(let X=0;X<=n;X++){let te=X/n,he=v.clone().multiplyScalar(te).add(T);ro(he,F,S),x.push(S.x,S.y,S.z),y.push(B.x,B.y,B.z),N.push(k,.5+S.y/r),H.push(L++)}if(b&&h?(q(H,k,F,oe,c,h,1,!1),q(H,k,F,ge,c,b,1,!0)):h?(q(H,k,F,oe,c,h,1,!1),W(H,F,h.x,0,1)):s||W(H,F,e,Z,1),u&&!R){let X=Su(v).multiplyScalar(-1).normalize();ro(X,F,B);for(let te=0;te<=n;te++){let he=te/n,Y=v.clone().multiplyScalar(-he).add(ie);ro(Y,F,S),x.push(S.x,S.y,S.z),y.push(B.x,B.y,B.z),N.push(k,.5+S.y/r),H.push(L++)}}u&&!s&&H.push(H[0]),U.push(H)}for(let E=0;E<U.length-1;E++)for(let H=0;H<U[0].length-1;H++){if(s&&u&&H==n)continue;let k=U[E][H],se=U[E+1][H],F=U[E+1][H+1],K=U[E][H+1],X=x[F*3+0],te=x[F*3+2];m.push(k,se,K),(X!=0||te!=0)&&m.push(se,F,K)}l<Math.PI*2&&(J(-1,U[0],a),J(1,U[U.length-1],a+l)),this.setIndex(m),this.setAttribute("position",new el(x,3)),this.setAttribute("normal",new el(y,3)),this.setAttribute("uv",new el(N,2));function q(E,H,k,se,F,K,X,te){for(let he=0;he<p+1;he++){let Y=he/p,ne=X<0?Y:1-Y;te&&(ne-=1),ne*=se;let Se=new ar(Math.sin(ne),Math.cos(ne)*X),me=Se.clone().multiplyScalar(F).add(K);ro(me,k,S),x.push(S.x,S.y,S.z),ro(Se,k,B),y.push(B.x,B.y,B.z),N.push(H,.5+S.y/r),E.push(L++)}}function W(E,H,k,se,F){let K=new Ps,X=new ar,te=[k,se];F<0&&te.reverse();for(let he of te)X.set(he,w*F),ro(X,H,K),x.push(K.x,K.y,K.z),y.push(0,F,0),N.push(.5,.5),E.push(L++)}function J(E,H,k){let se=new ar(Math.sin(k),Math.cos(k)),F=new ar(-Math.cos(k),Math.sin(k)),K=new Ps,X=E<0?(Y,ne,Se)=>m.push(Y,ne,Se):(Y,ne,Se)=>m.push(Y,Se,ne),te=new ar((e+t+Z+V)/4,0);ro(te,se,K),x.push(K.x,K.y,K.z),y.push(F.x,0,F.y),N.push(.5,.5);let he=L++;for(let Y of H){let ne=x.slice(Y*3,Y*3+3);x.push(...ne),y.push(F.x,0,F.y);let Se=N.slice(Y*2,Y*2+2);N.push(...Se),L++}for(let Y=he+1;Y<L-1;Y++)X(he,Y,Y+1);X(he,L-1,he+1)}}};var wu=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,e){var r,o,n;let t=Object.assign({},(r=e==null?void 0:e.parameters)!=null?r:{width:100,radialSegments:32,heightSegments:8,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadiusTop:0,cornerRadiusBottom:0,cornerSegments:8},i.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs((o=t.height)!=null?o:t.width),depth:Math.abs((n=t.depth)!=null?n:t.width)})}}static build(i){let{width:e,depth:t,height:r,radialSegments:o,heightSegments:n,openEnded:s,thetaStart:a,thetaLength:l,cornerRadiusTop:c,cornerRadiusBottom:d,cornerSegments:p}=i.parameters,u;return c>0||d>0||l<360?u=new Os(0,e/2,r,o,n,s,a,l*Math.PI/180,c,d,p,0,!0):u=new kb(e/2,r,o,n,s),u.scale(1,1,t/e),Object.assign(u,{userData:$(O({},i),{type:"ConeGeometry"})})}};import{BoxBufferGeometry as Hb,BufferGeometry as qb,Float32BufferAttribute as tl,Vector3 as Ei}from"three";var Nu=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,e){var r,o,n;let t=Object.assign({},(r=e==null?void 0:e.parameters)!=null?r:{width:100,widthSegments:1,heightSegments:1,depthSegments:1,cornerRadius:0,cornerSegments:8},i.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs((o=t.height)!=null?o:t.width),depth:Math.abs((n=t.depth)!=null?n:t.width)})}}static build(i){let{width:e,height:t,depth:r,widthSegments:o,heightSegments:n,depthSegments:s,cornerRadius:a,cornerSegments:l}=i.parameters,c;return a==0?c=new Hb(e,t,r,o,n,s):c=new Cu(e,t,r,o,n,s,a,l),Object.assign(c,{userData:$(O({},i),{type:"CubeGeometry"})})}},rl=Math.PI/2,Cu=class extends qb{constructor(e=1,t=1,r=1,o=1,n=1,s=1,a=0,l=4){super();this.type="BoxBufferGeometry";let c=this;o=Math.floor(o),n=Math.floor(n),s=Math.floor(s),l=Math.floor(l),a=Math.min(a,e/2,t/2,r/2);let d=[],p=[],u=[],f=[],m=0,x=0;y("z","y","x",-1,-1,r,t,e,s,n,0),y("z","y","x",1,-1,r,t,-e,s,n,1),y("x","z","y",1,1,e,r,t,o,s,2),y("x","z","y",1,-1,e,r,-t,o,s,3),y("x","y","z",1,-1,e,t,r,o,n,4),y("x","y","z",-1,-1,e,t,-r,o,n,5),a>0&&(N("z","y","x",-1,-1,1,r,t,e,s,0),N("z","y","x",1,-1,-1,r,t,e,s,1),N("z","y","x",-1,1,-1,r,t,e,s,1),N("z","y","x",1,1,1,r,t,e,s,0),N("x","y","z",-1,-1,-1,e,t,r,o,0),N("x","y","z",1,-1,1,e,t,r,o,1),N("x","y","z",-1,1,1,e,t,r,o,0),N("x","y","z",1,1,-1,e,t,r,o,1),N("y","x","z",-1,-1,1,t,e,r,n,0),N("y","x","z",1,-1,-1,t,e,r,n,1),N("y","x","z",1,1,1,t,e,r,n,1),N("y","x","z",-1,1,-1,t,e,r,n,0),L(1,1,1),L(-1,1,1),L(1,-1,1),L(-1,-1,1),L(1,1,-1),L(-1,1,-1),L(1,-1,-1),L(-1,-1,-1)),this.setIndex(d),this.setAttribute("position",new tl(p,3)),this.setAttribute("normal",new tl(u,3)),this.setAttribute("uv",new tl(f,2));function y(w,B,S,_,T,h,I,b,P,v,D){let Z=(h-2*a)/P,V=(I-2*a)/v,ie=h/2-a,oe=I/2-a,ge=b/2,xe=P+1,A=v+1,j=0,g=0,z=new Ei;for(let R=0;R<A;R++){let U=R*V-oe;for(let q=0;q<xe;q++){let W=q*Z-ie;z[w]=W*_,z[B]=U*T,z[S]=ge,p.push(z.x,z.y,z.z),z[w]=0,z[B]=0,z[S]=b>0?1:-1,u.push(z.x,z.y,z.z),f.push(q/P),f.push(1-R/v),j+=1}}for(let R=0;R<v;R++)for(let U=0;U<P;U++){let q=m+U+xe*R,W=m+U+xe*(R+1),J=m+(U+1)+xe*(R+1),E=m+(U+1)+xe*R;d.push(q,W,E),d.push(W,J,E),g+=6}c.addGroup(x,g,D),x+=g,m+=j}function N(w,B,S,_,T,h,I,b,P,v,D){let Z=(I-2*a)/v,V=I/2-a,ie=b/2-a,oe=P/2,ge=v+1,xe=0,A=0,j=new Ei,g=new Ei;for(let z=0;z<l+1;z++){let R=z/l*rl,U=Math.sin(R)*a,q=(1-Math.cos(R))*a,W=Math.sin(R),J=Math.cos(R);j[B]=(ie+U)*T,j[S]=(oe-q)*h,g[w]=0,g[B]=W*Math.sign(j[B]),g[S]=J*Math.sign(j[S]);for(let E=0;E<ge;E++){let H=E*Z-V;j[w]=H*_,p.push(j.x,j.y,j.z),u.push(g.x,g.y,g.z),f.push(E/v),f.push(0),xe+=1}}for(let z=0;z<l;z++)for(let R=0;R<v;R++){let U=m+R+ge*z,q=m+R+ge*(z+1),W=m+(R+1)+ge*(z+1),J=m+(R+1)+ge*z;d.push(U,q,J),d.push(q,W,J),A+=6}c.addGroup(x,A,D),x+=A,m+=xe}function L(w,B,S){let _=new Ei,T=new Ei(e/2,t/2,r/2);T.subScalar(a);let h=[],I=w*B*S>0?(P,v,D)=>d.push(P,v,D):(P,v,D)=>d.push(P,D,v);for(let P=0;P<=l;P++){let v=[],D=rl*(1-P/l),Z=Math.cos(D),V=Math.sin(D),ie=0;for(let oe=0;oe<=P;oe++){let ge=Math.cos(ie),xe=Math.sin(ie);_.x=Z*ge,_.y=V,_.z=Z*xe;let A=T.clone().addScaledVector(_,a);p.push(w*A.x,B*A.y,S*A.z),u.push(w*_.x,B*_.y,S*_.z),f.push(0,0),v.push(m++),ie+=rl/P}h.push(v)}let b=h.length-1;for(let P=0;P<b;P++){let v=h[P],D=h[P+1],Z=v.length-1;I(v[0],D[1],D[0]);for(let V=1;V<=Z;V++)I(v[V-1],v[V],D[V]),I(v[V],D[V+1],D[V])}}}};import{BufferGeometry as Wb,Float32BufferAttribute as ol,Triangle as $b,Vector3 as Gr,Vector2 as il}from"three";var So=class extends Wb{constructor(e=[],t=[],r="",o=1,n=.2,s=4){super();this.type="PolyhedronGeometryRound";let a=[],l=[],c=[];d(),p(),this.setAttribute("position",new ol(a,3)),this.setAttribute("normal",new ol(c,3)),this.setAttribute("uv",new ol(l,2));return;function d(){var xe;n=Math.min(1-1e-5,n),n==0&&(s=0);let f={IcosahedronGeometry:5,DodecahedronGeometry:3,HexahedronGeometry:3,OctahedronGeometry:4,TetrahedronGeometry:3}[r],m=new Gr,x=m.clone(),y=new $b,N=n*o,L=o-N,w=s+1,B=new Gr,S=(A,j)=>B.subVectors(A,j).normalize(),_=(A,j)=>Array(A).fill(void 0).map(j),T=_(e.length/3,(A,j)=>new Gr().fromArray(e,j*3).setLength(o)),h=[],I=1e6;for(let A=0;A<T.length;A++){let j=T[A],g=[],z,R,U,q=1e10,W=-1;for(;(W=t.indexOf(A,W+1))!=-1;){let k=W-W%3;z=t[k+(W+1)%3],R=t[k+(W+2)%3],U=j.distanceToSquared(T[z]),q=Math.min(q,U),g.push([z,R,U])}q+=1e-6;let J=[],E=0,H=g.length;for(let k=0;k<H;k++){[z,R,U]=g[E];let se=((xe=h[z])==null?void 0:xe.includes(A))==!0;U<=q&&J.push(z+ +se*I),E=g.findIndex(F=>F[0]==R)}h.push(J)}let b=[];{let A=0,j=0,g,z,R=f==3;for(let U=0;U<=s;U++){g=U*(U+1)/2,z=(U+1)*(U+2)/2;for(let q=0;q<s-U;q++)[A,j]=[g+q+U+2,z+q+U+3],b.push(g,z,...R?[j,g]:[A,z],j,A),[g,z]=[A,j];b.push(g,z,g+s+2)}}let P=m.clone(),v=m.clone(),D=m.clone(),Z=m.clone(),V=m.clone(),ie=[],oe=_(T.length,()=>_(f,()=>m.clone()));for(let A=0;A<T.length;A++){m.copy(T[A]).normalize(),P.copy(m).multiplyScalar(L);let j=h[A];for(let J=0;J<j.length;J++){let E=j[J],H=j[(J+1)%f];y.setFromPointsAndIndices(T,A,E%I,H%I),y.b.sub(y.a).setLength(1e10).add(y.a),y.c.sub(y.a).setLength(1e10).add(y.a),y.closestPointToPoint(P,oe[A][J])}let g=[],z=[],R=[],U=new Gr;s==0&&[...oe[A]].reduce((J,E)=>J.add(E),U).multiplyScalar(1/f);for(let J=0;J<f;J++){let E=[],H=(J-1+f)%f,k=oe[A][H],se=oe[A][J];m.copy(k).sub(P),x.copy(se).sub(P);let F=P.angleTo(m),K=m.angleTo(x),X=Math.cos(F)*N;s==0?v.copy(U):v.copy(P).setLength(L+X),z.push(X);let te=[v,k,se];for(let he=0;he<2;he++){let Y=te[he],ne=te[he+1];Z.subVectors(Y,P),V.subVectors(ne,P),D.crossVectors(Z,V).normalize();for(let Se=0;Se<w;Se++){let me=[F,K][he]*Se/w;m.copy(Z).applyAxisAngle(D,me).add(P),g.push(m.clone()),he&&(S(m,P),E.push([Se==0?Y:m.clone(),B.clone()]))}he&&(S(ne,P),E.push([ne,B.clone()]))}R.push(E)}ie.push(R);let q=2*w,W=2;for(let J=0;J<f;J++){let E=q*J,H=q*((J+1)%f),k=[g[E]];for(let F=1;F<w;F++){Z=g[E+F],V=g[H+F],k.push(Z);for(let K=1,X=F-W+1;K<=X;K++)m.lerpVectors(Z,V,K/(X+1)),m.sub(P).setLength(z[J]).add(P),k.push(m.clone());k.push(V)}for(let F=0;F<w;F++)k.push(g[F+w+E]);k.push(g[H+w]);let se=b.map(F=>k[F]);a.push(...se.map(F=>[F.x,F.y,F.z]).flat()),c.push(...se.map(F=>(S(F,P),[B.x,B.y,B.z])).flat())}}let ge=[];for(let A=0;A<h.length;A++)for(let j=0;j<f;j++){let g=h[A][j];if(g<I){let z=h[g].findIndex(q=>q%I==A),R=ie[A][j],U=ie[g][z];for(let q=0;q<w;q++){let W=R[q],J=U[w-q],E=R[q+1],H=U[w-(q+1)];[W,J,E,E,J,H].forEach(k=>{a.push(k[0].x,k[0].y,k[0].z),c.push(k[1].x,k[1].y,k[1].z)})}ge.push(R[0][0],U[w][0],R[w][0],U[0][0])}}for(;ge.length;){let A,j,g,z;[A,j]=ge.splice(0,2);let R=[A];for(;A!=j;)R.push(j),g=ge.indexOf(j),z=g%2,j=ge.splice(g-z,2)[1-z];B.subVectors(R[0],R[1]).cross(m.subVectors(R[0],R[2])).normalize();let U=B.dot(R[0])<0;U&&B.negate();for(let q=1;q<=R.length-2;q++)[R[q+ +U],R[q+1-+U],R[0]].forEach(W=>{a.push(W.x,W.y,W.z),c.push(B.x,B.y,B.z)})}}function p(){let u=new Gr;for(let T=0;T<a.length;T+=3){u.x=a[T+0],u.y=a[T+1],u.z=a[T+2];let h=S(u)/2/Math.PI+.5,I=_(u)/Math.PI+.5;l.push(h,1-I)}let f=new Gr,m=new Gr,x=new Gr,y=new Gr,N=new il,L=new il,w=new il,B=(T,h,I,b)=>{b<0&&T.x===1&&(l[h]=T.x-1),I.x===0&&I.z===0&&(l[h]=b/2/Math.PI+.5)};for(let T=0,h=0;T<a.length;T+=9,h+=6){f.set(a[T+0],a[T+1],a[T+2]),m.set(a[T+3],a[T+4],a[T+5]),x.set(a[T+6],a[T+7],a[T+8]),N.set(l[h+0],l[h+1]),L.set(l[h+2],l[h+3]),w.set(l[h+4],l[h+5]),y.copy(f).add(m).add(x).divideScalar(3);let I=S(y);B(N,h+0,f,I),B(L,h+2,m,I),B(w,h+4,x,I)}for(let T=0;T<l.length;T+=6){let h=l[T+0],I=l[T+2],b=l[T+4],P=Math.max(h,I,b),v=Math.min(h,I,b);P>.9&&v<.1&&(h<.2&&(l[T+0]+=1),I<.2&&(l[T+2]+=1),b<.2&&(l[T+4]+=1))}function S(T){return Math.atan2(T.z,-T.x)}function _(T){return Math.atan2(-T.y,Math.sqrt(T.x*T.x+T.z*T.z))}}}static fromJSON(e){return new So(e.vertices,e.indices,e.radius,e.corner,e.cornerSides)}};import{DodecahedronBufferGeometry as Jb}from"three";var Lu=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,e){var r,o,n;let t=Object.assign({},(r=e==null?void 0:e.parameters)!=null?r:{width:100,detail:0,corner:0,cornerSides:4},i.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs((o=t.height)!=null?o:t.width),depth:Math.abs((n=t.depth)!=null?n:t.width)})}}static build(i){let{width:e,height:t,depth:r,detail:o,corner:n,cornerSides:s}=i.parameters,a=o===0&&n!==0?new As(e*.5,n,s):new Jb(e*.5,o);return a.scale(1,t/e,r/e),Object.assign(a,{userData:$(O({},i),{type:"DodecahedronGeometry"})})}},As=class extends So{constructor(e=1,t=.2,r=4){let o=(1+Math.sqrt(5))/2,n=1/o,s=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-n,-o,0,-n,o,0,n,-o,0,n,o,-n,-o,0,-n,o,0,n,-o,0,n,o,0,-o,0,-n,o,0,-n,-o,0,n,o,0,n],a=[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],l="DodecahedronGeometry";super(s,a,l,e,t,r);this.type=l}static fromJSON(e){return new As(e.radius,e.corner,e.cornerSides)}};import{EventDispatcher as nv,Plane as sv,Shape as zu,Vector2 as zr,Vector3 as av,MathUtils as pl,LineCurve as ul,QuadraticBezierCurve as Eu,CubicBezierCurve as Ds}from"three";import{CubicBezierCurve as js,EllipseCurve as Kb,LineCurve as _s,LineCurve3 as Xb,MathUtils as Zb,QuadraticBezierCurve as nl,SplineCurve as Qb,Vector2 as lr,Vector3 as Tu}from"three";var Fi=1e-12,Ri=class{constructor(e){this.position=new lr;this.startPosition=new lr;this.uuid=Zb.generateUUID();this.position=e.clone()}start(){this.reset()}reset(){this.startPosition.copy(this.position)}applyOffset(e){this.position.copy(this.startPosition).add(e)}copy(e){return this.position.copy(e.position),this.startPosition.copy(e.startPosition),this}clone(){return new Ri(this.position).copy(this)}toJSON(){return[this.position.x,this.position.y]}},Vi=class extends Ri{constructor(e){super(e.position);this.parent=e}copy(e){return super.copy(e),this}clone(){return new Vi(this.parent).copy(this)}},br=class extends Ri{constructor(e,t){super(t);this.controls=[];this.roundness=0;this.areControlsDirectionsMirrored=!0;this.uuid=e,this.controls.push(new Vi(this),new Vi(this))}static create(e,t){let r=new br(e,new lr(...t.position));return r.controls[0].position.set(...t.controlPrevious.position),r.controls[1].position.set(...t.controlNext.position),r.roundness=t.roundness,r.areControlsDirectionsMirrored=t.areControlsDirectionsMirrored,r}getOppositeControl(e){let t=this.controls.indexOf(e);return t===0?this.controls[1]:t===1?this.controls[0]:null}applyOffsetToControls(e,t=1){for(let r=0,o=this.controls.length;r<o;r++){let n=this.controls[r];this.position.distanceTo(n.position)<=t?n.position.copy(this.position):n.applyOffset(e)}}controlsMoved(){return!(this.position.equals(this.controls[0].position)&&this.position.equals(this.controls[1].position))}copy(e){return super.copy(e),this.controls[0].copy(e.controls[0]),this.controls[1].copy(e.controls[1]),this.roundness=e.roundness,this.uuid=e.uuid,this}clone(){return new br(this.uuid,this.position).copy(this)}toJSON(){return super.toJSON().concat(this.controls[0].toJSON(),this.controls[1].toJSON(),[this.roundness])}},sl=i=>i,Ui=new lr,al=new lr,Yb=new lr,ev=new lr,tv=new lr,rv=new lr,Iu=new Tu,Mu=new Tu;function Pu(i){let e=new lr;e.addVectors(i.v0,Ui.subVectors(i.v1,i.v0).multiplyScalar(2/3));let t=new lr;return t.addVectors(i.v2,al.subVectors(i.v1,i.v2).multiplyScalar(2/3)),new js(i.v0,e,t,i.v2)}function ki(i,e,t=Number.EPSILON){return Math.abs(i-e)<t}function ov(i,e,t=Number.EPSILON){return i.distanceTo(e)<t}function iv(i,e,t=Number.EPSILON){return i.distanceTo(e)<t}function ll(i,e,t){let r=Math.sqrt(Math.pow(e.x-i.x,2)+Math.pow(e.y-i.y,2)),o=Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2)),n=Math.sqrt(Math.pow(t.x-i.x,2)+Math.pow(t.y-i.y,2));return Math.acos((o*o+r*r-n*n)/(2*o*r))}function Ou(i,e,t,r,o){let n=Math.sqrt(Math.pow(e.x-i.x,2)+Math.pow(e.y-i.y,2)),s=(i.y+e.y)/2,a=(i.x+e.x)/2,l=Math.sqrt(Math.pow(t,2)-Math.pow(n/2,2))*(i.y-e.y)/n,c=Math.sqrt(Math.pow(t,2)-Math.pow(n/2,2))*(e.x-i.x)/n;return r.set(a+l,s+c),o.set(a-l,s-c),[r,o]}function Au(i,e,t){let r=i.distanceTo(t),o=e.distanceTo(t);return r<o?e:i}function ju(i,e,t,r,o,n){let s=e.x-i.x,a=e.y-i.y,l=t.x-i.x,c=t.y-i.y,d=Math.sqrt((s+l)*(s+l)+(a+c)*(a+c)),p;return ll(e,i,t)>Math.PI&&(d*=-1),ki(c,a)?p=(a+c)*(r/d-.5)*8/3/(s-l):p=(s+l)*(r/d-.5)*8/3/(c-a),o.set(e.x-p*a,e.y+p*s),n.set(t.x+p*c,t.y-p*l),[o,n]}function cl(i,e){return i.position.equals(i.controls[1].position)&&e.position.equals(e.controls[0].position)}function _u(i,e,t,r,o=.5){let n=Ui.subVectors(e,i).multiplyScalar(o).add(i),s=al.subVectors(t,e).multiplyScalar(o).add(e),a=Yb.subVectors(r,t).multiplyScalar(o).add(t),l=n,c=ev.subVectors(s,n).multiplyScalar(o).add(n),d=tv.subVectors(a,s).multiplyScalar(o).add(s),p=a,u=rv.subVectors(d,c).multiplyScalar(o).add(c);return[i.x,i.y,l.x,l.y,c.x,c.y,u.x,u.y,d.x,d.y,p.x,p.y,r.x,r.y]}function Du(i,e,t=12,r=!0){let o=Mu.set(0,0,0),n,s=0,a=[];for(let l=0;l<e.length;l++){let c=sl(e[l]),d=Ui,p=oo(c,t);a.push(p);for(let u=0;u<=p;u++)if(c instanceof js||c instanceof nl||c instanceof _s){if(c.getPoint(u/p,d),o.set(d.x,d.y,0),n!==void 0&&iv(n,o))continue;n===void 0&&(n=Iu),n.copy(o),i.setXYZ(s,o.x,o.y,o.z),s++}}return r&&s>1&&!(i.getX(s-1)===i.getX(0)&&i.getY(s-1)===i.getY(0)&&i.getZ(s-1)===i.getZ(0))&&(i.setXYZ(s,i.getX(0),i.getY(0),i.getZ(0)),s++),i}function Bu(i,e,t,r=12,o=!0){let n=Mu.set(0,0,0),s=0,a=[];for(let l=0;l<e.length;l++){if(t[l]===!1)continue;let c,d=sl(e[l]),p=Ui,u=oo(d,r);a.push(u);for(let f=0;f<=u;f++)if(d instanceof js||d instanceof nl||d instanceof _s){if(d.getPoint(f/u,p),n.set(p.x,p.y,0),c==null?void 0:c.equals(n))continue;c===void 0?c=Iu:(i.setXYZ(s,c.x,c.y,c.z),s++,i.setXYZ(s,n.x,n.y,n.z),s++),c.copy(n)}}return o&&s>1&&!(i.getX(s-1)===i.getX(0)&&i.getY(s-1)===i.getY(0)&&i.getZ(s-1)===i.getZ(0))&&(i.setXYZ(s,i.getX(0),i.getY(0),i.getZ(0)),s++),a}function dl(i,e=12,t=!1){let r=[];for(let o=0,n=i.length;o<n;o++){let s=i[o],a=0;if(t&&s.roundedCurveCorner!==void 0){let l=oo(s.roundedCurveCorner,e)*.5;o>0&&(r[o-1]+=l),a+=l}s.curveAfter!==void 0&&(a+=oo(s.curveAfter,e)),r.push(a)}return i.length>0&&t&&i[0].roundedCurveCorner!==void 0&&(r[i.length-1]+=oo(i[0].roundedCurveCorner,e)*.5),r}function oo(i,e=12){return i&&i instanceof Kb?e*2:i&&(i instanceof _s||i instanceof Xb)?1:i&&i instanceof Qb?e*i.points.length:e}function Gu(i,e,t=12,r=!0){let o,n=0;for(let s=0;s<e.length;s++){let a=sl(e[s]),l=oo(a,t),c=Ui;for(let d=0;d<=l;d++)if(a instanceof js||a instanceof nl||a instanceof _s){if(a.getPoint(d/l,c),o!==void 0&&ov(o,c,Fi))continue;o===void 0&&(o=al),o.copy(c),i.push(c.x,c.y),n++}}return ki(i[0],i[i.length-2],Fi)&&ki(i[1],i[i.length-1],Fi)&&(i.pop(),i.pop()),r&&n>1&&!(ki(i[n-1],i[1],Fi)&&ki(i[n-2],i[0],Fi))&&(i.push(i[0],i[1]),n++),i}var hl=new zr,lv=new zr,cv=new zr,dv=new zr,pv=new zr,uv=new zr,Pe=class extends zu{constructor(e=100,t=100){super();this.points=[];this.shapeHoles=[];this.eventDispatcher=new nv;this.plane=new sv(new av(0,0,-1));this.subdivision=0;this.controlSnapDistance=4;this.pointIDs=0;this.isMesh2D=!1;this._roundness=0;this.isClosed=!1;this.useCubicForRoundedCorners=!0;this.uuid=pl.generateUUID();this.needsUpdate=!1;this.roundedCurves=[];this._width=e,this._height=t}static createFromState(e,t,r){let o=new Pe;return o.isClosed=e.isClosed,o.points=e.points.map(n=>br.create(n.id,n.data)),typeof e.roundness=="number"&&(o.roundness=e.roundness),o.shapeHoles=e.shapeHoles.map(n=>Pe.createFromState(n)),t!==void 0&&r!==void 0&&o.applySize(t,r),o.update(),o}get width(){return this._width}get height(){return this._height}get roundness(){return this._roundness}set roundness(e){if(this._roundness!==e){this._roundness=e;for(let t=0,r=this.points.length;t<r;t++)this.points[t].roundness=e;this.needsUpdate=!0}}getPointsIndexesByIds(e){return e.map(t=>this.getPointIndexById(t)).filter(t=>t>=0)}getPointIndexById(e){return this.points.findIndex(t=>t.uuid===e)}getLineIndexById(e){return this.getPointIndexById(e)}getBezierPoint(e){if(e<=this.points.length-1)return this.points[e];if(this.shapeHoles.length>0)for(let t=0,r=this.shapeHoles.length;t<r;t++){let o=this.shapeHoles[t],n=e-this.points.length;if(n<=o.points.length-1)return o.points[n]}throw new Error("This shape does not have a point for this index: "+e)}getBezierPointIndex(e){let t=this.points.indexOf(e);if(t>=0)return t;if(t=this.points.length,this.shapeHoles.length>0)for(let r=0,o=this.shapeHoles.length;r<o;r++){let n=this.shapeHoles[r],s=n.points.indexOf(e);if(s>=0)return t+s;t+=n.points.length}return-1}getAllPoints(){let e=[].concat(...this.shapeHoles.map(t=>t.points));return[...this.points,...e]}applySize(e,t){e===0&&(e=.001),t===0&&(t=.001),this._width=e,this._height=t}applyScale(e,t){let r=hl.set(e,t);for(let o=0,n=this.points.length;o<n;o++){let s=this.points[o];s.position.multiply(r),s.controls[0].position.multiply(r),s.controls[1].position.multiply(r)}for(let o=0,n=this.shapeHoles.length;o<n;o++)this.shapeHoles[o].applyScale(e,t);this._update(!1)}createPoint(e,t=0,r=pl.generateUUID()){let o;e instanceof zr?o=e:o=new zr(e,t);let n=new br(r,o);return n.roundness=this.roundness,n}addPoint(e){this.points.push(e),this.needsUpdate=!0}addPointAt(e,t){this.points.splice(t,0,e),this.needsUpdate=!0}getPointByUuid(e){for(let t=0,r=this.points.length;t<r;t++){let o=this.points[t];if(o.uuid===e)return o}}getFirstPoint(){return this.points[0]}getLastPoint(){return this.points[this.points.length-1]}removePoint(e){let t=this.points.indexOf(e);t>=0&&this.points.splice(t,1),this.needsUpdate=!0}removePointById(e){let t=this.points.find(r=>r.uuid===e);t&&this.removePoint(t)}update(e=!0){for(let t=0,r=this.shapeHoles.length;t<r;t++)this.shapeHoles[t].update(!1);this._update(e)}extractShapePointsToBuffer(e,t=12,r=!1){this.subdivision=t,this.curveDivisions===void 0&&this.computeCurveDivisions(t);let o=r?this.roundedCurveDivisions:this.curveDivisions;return Du(e,r?this.roundedCurves:this.curves,t,this.autoClose),o.reduce((n,s)=>n+s,0)+1}computeCurveDivisions(e=12){return this.curveDivisions=dl(this.points,e,!1),this.roundedCurveDivisions=dl(this.points,e,!0),this.curveDivisions}extractFilteredShapePointsToBuffer(e,t,r=12){return Bu(e,this.curves,t,r,this.autoClose).reduce((n,s)=>n+s,0)*2}extractShapePointsToFlatArray(e,t=12){return this.subdivision=t,this.curveDivisions===void 0&&this.computeCurveDivisions(t),Gu(e,this.roundedCurves,t,this.autoClose)}getCurveIndexFromVertexId(e,t=!1){let r=0;this.curveDivisions===void 0&&this.computeCurveDivisions(this.subdivision);let o=t?this.roundedCurveDivisions:this.curveDivisions,n=0;t&&this.points[0].roundedCurveCorner!==void 0&&(n=oo(this.points[0].roundedCurveCorner,this.subdivision)*.5);let s=e-n;s<0&&(s+=o.reduce((a,l)=>a+l,0));for(let a=0,l=o.length;a<l;a++){let c=o[a];if(s<r+c)return[a,(s-r+1)/c];r+=c}return[0,1]}getCurveT(e,t,r){let o=this.points[e],n=this.points[e>=this.points.length-1?0:e+1],s=this.curveDivisions,a=s[e];if(cl(o,n)){let d=o.position.distanceTo(n.position);return o.position.distanceTo(hl.set(r.x,r.y))/d}let l=0;for(let d=0;d<e;d++)l+=s[d];return(t-l)/a}dispose(){this.eventDispatcher=null}_applyCurveForPoint(e,t){cl(t,e)?this.lineTo(e.position.x,e.position.y):this.bezierCurveTo(t.controls[1].position.x,t.controls[1].position.y,e.controls[0].position.x,e.controls[0].position.y,e.position.x,e.position.y);let r=this.curves[this.curves.length-1];e.curveBefore=r,t.curveAfter=r;let o=r.clone();e.roundedCurveBefore=o,t.roundedCurveAfter=o,e.roundedCurveCorner=void 0,this.roundedCurves.push(o)}_update(e=!0){var r;if(this.curves=[],this.roundedCurves=[],!this.points.length)return;for(let o=0,n=this.points.length;o<n;o++){let s=this.points[o];if(o===0)this.moveTo(s.position.x,s.position.y);else{let a=this.points[o-1];this._applyCurveForPoint(s,a)}}let t=this.getLastPoint();if((t==null?void 0:t.curveAfter)&&(t.curveAfter=void 0),this.isClosed){let o=this.points[0],n=this.points[this.points.length-1];this._applyCurveForPoint(o,n)}if(this.points.length>2){let o=0;for(let n=0,s=this.points.length;n<s;n++){let a=this.points[n],l=a.roundness;if(!a.controlsMoved()&&l>0){let c=a.curveBefore,d=a.curveAfter;if(c===void 0||d===void 0)continue;let p=a.roundedCurveBefore,u=a.roundedCurveAfter,f=c.getLength(),m=d.getLength(),x=Math.min(l,f*.499),y=Math.min(l,m*.499),N=Math.min(x,y),L=1-N/f,w=N/m,B=c.getPointAt(L,hl),S=d.getPointAt(w,lv);this._subSplitCurve(c,p,L,B,void 0),this._subSplitCurve(d,u,w,void 0,S);let _;if(this.useCubicForRoundedCorners){let T=ll(B,a.position,S)/2,h=Math.tan(T)*B.distanceTo(a.position),[I,b]=Ou(B,S,h,cv,dv),P=Au(I,b,a.position),[v,D]=ju(P,B,S,h,pv,uv);_=new Ds(B.clone(),v.clone(),D.clone(),S.clone())}else _=new Eu(B.clone(),a.position.clone(),S.clone());a.roundedCurveCorner=_,this.roundedCurves.splice(n+o,0,_),o++}}}e&&((r=this.eventDispatcher)==null||r.dispatchEvent({type:"update"}))}_subSplitCurve(e,t,r,o,n){if(e instanceof ul)o!==void 0&&t.v2.copy(o),n!==void 0&&t.v1.copy(n);else{let s=e,a=t,l=s.getUtoTmapping(r,0),c=_u(s.v0,s.v1,s.v2,s.v3,l);return o!==void 0&&(a.v0.set(c[0],c[1]),a.v1.set(c[2],c[3]),a.v2.set(c[4],c[5]),a.v3.set(c[6],c[7])),n!==void 0&&(a.v0.set(c[6],c[7]),a.v1.set(c[8],c[9]),a.v2.set(c[10],c[11]),a.v3.set(c[12],c[13])),a}return t}clone(){let e=new Pe(this._width,this._height);return e.points=this.points.map(t=>t.clone()),e.isClosed=this.isClosed,e.roundness=this.roundness,e.isMesh2D=this.isMesh2D,e.shapeHoles=this.shapeHoles.map(t=>t.clone()),e}toJSON(){return{points:this.points.reduce((e,t)=>e.concat(t.toJSON()),[]),shapeHoles:this.shapeHoles.map(e=>e.toJSON()),isClosed:this.isClosed,roundness:this.roundness}}fromJSON(e){var r;this.points=[],this.pointIDs=0;let t=e.points.length/7;for(let o=0;o<t;o++){let n=o*7,s=e.points[n+0],a=e.points[n+1],l=e.points[n+2],c=e.points[n+3],d=e.points[n+4],p=e.points[n+5],u=e.points[n+6],f=new br(pl.generateUUID(),new zr(s,a));f.controls[0].position.set(l,c),f.controls[1].position.set(d,p),f.roundness=u,this.points.push(f)}return this.shapeHoles=((r=e.shapeHoles)==null?void 0:r.length)?e.shapeHoles.map(o=>{let n=new Pe;return n.fromJSON(o),n}):[],this.isClosed=e.isClosed,this._roundness=e.roundness,this._update(),this}fromShape(e){let t=(o,n)=>{n instanceof Ds&&n.v3.equals(o.position)&&o.controls[0].position.copy(n.v2)},r=o=>{let n=[],s,a;for(s=0,a=o.length;s<a;s++)o[s]instanceof Eu&&(o[s]=Pu(o[s]));for(s=0,a=o.length;s<a;s++){let d=o[s],p=s>0?o[s-1]:null,u;d instanceof Ds?(u=this.createPoint(d.v0),u.controls[1].position.copy(d.v1)):d instanceof ul&&(u=this.createPoint(d.v1)),u!==void 0&&(p!==null&&t(u,p),n.push(u))}let l=o[o.length-1],c=!1;return l instanceof Ds?l.v3.equals(n[0].position)&&(n[0].controls[0].position.copy(l.v2),c=!0):l instanceof ul&&l.v2.equals(n[0].position)&&(c=!0),this.isClosed=c,n};return this.points=r(e.curves),e instanceof zu&&(this.shapeHoles=e.holes.map(o=>{let n=new Pe;return n.fromShape(o),n})),this.update(),this}};var ml=Math.PI*2;function fl({x:i,y:e},t,r,o,n){return{x:i*t+o,y:e*r+n}}function hv(i,e){let t=e===1.5707963267948966?.551915024494:e===-1.5707963267948966?-.551915024494:4/3*Math.tan(e/4),r=Math.cos(i),o=Math.sin(i),n=Math.cos(i+e),s=Math.sin(i+e);return[{x:r-o*t,y:o+r*t},{x:n+s*t,y:s-n*t},{x:n,y:s}]}function Fu(i,e,t,r){let o=i*r-e*t<0?-1:1,n=Math.min(1,Math.max(-1,i*t+e*r));return o*Math.acos(n)}function mv(i,e,t,r,o,n,s,a,l,c){let d=Math.pow(o,2),p=Math.pow(n,2),u=Math.pow(s,2),f=Math.pow(a,2),m=d*p-d*f-p*u;m<0&&(m=0),m/=d*f+p*u,m=Math.sqrt(m)*(l===c?-1:1);let x=m*o/n*a,y=m*-n/o*s,N=x+(i+t)/2,L=y+(e+r)/2,w=(s-x)/o,B=(a-y)/n,S=(-s-x)/o,_=(-a-y)/n,T=Fu(1,0,w,B),h=Fu(w,B,S,_);return!c&&h>0&&(h-=ml),c&&h<0&&(h+=ml),{centerx:N,centery:L,ang1:T,ang2:h}}function Ru({px:i,py:e,cx:t,cy:r,rx:o,ry:n,largeArcFlag:s,sweepFlag:a}){let l=[];if(o===0||n===0)return[];let c=(i-t)/2,d=(e-r)/2;if(c===0&&d===0)return[];o=Math.abs(o),n=Math.abs(n);let p=Math.pow(c,2)/Math.pow(o,2)+Math.pow(d,2)/Math.pow(n,2);p>1&&(o*=Math.sqrt(p),n*=Math.sqrt(p));let u=mv(i,e,t,r,o,n,c,d,s,a),{ang1:f,ang2:m}=u,{centerx:x,centery:y}=u,N=Math.abs(m)/(ml/4);Math.abs(1-N)<1e-7&&(N=1);let L=Math.max(Math.ceil(N),1);m/=L;for(let w=0;w<L;w++)l.push(hv(f,m)),f+=m;return l.map(w=>{let{x:B,y:S}=fl(w[0],o,n,x,y),{x:_,y:T}=fl(w[1],o,n,x,y),{x:h,y:I}=fl(w[2],o,n,x,y);return{x1:B,y1:S,x2:_,y2:T,x:h,y:I}})}import{BufferAttribute as Gs,BufferGeometry as bv}from"three";var $e;(function(i){i[i.ODD=0]="ODD",i[i.NONZERO=1]="NONZERO",i[i.POSITIVE=2]="POSITIVE",i[i.NEGATIVE=3]="NEGATIVE",i[i.ABS_GEQ_TWO=4]="ABS_GEQ_TWO"})($e||($e={}));var st;(function(i){i[i.POLYGONS=0]="POLYGONS",i[i.CONNECTED_POLYGONS=1]="CONNECTED_POLYGONS",i[i.BOUNDARY_CONTOURS=2]="BOUNDARY_CONTOURS"})(st||(st={}));function ce(i,e){if(!i)throw e||"Assertion Failed!"}var ae=function(){function i(){}return i.vertEq=function(e,t){return e.s===t.s&&e.t===t.t},i.vertLeq=function(e,t){return e.s<t.s||e.s===t.s&&e.t<=t.t},i.transLeq=function(e,t){return e.t<t.t||e.t===t.t&&e.s<=t.s},i.edgeGoesLeft=function(e){return i.vertLeq(e.Dst,e.Org)},i.edgeGoesRight=function(e){return i.vertLeq(e.Org,e.Dst)},i.vertL1dist=function(e,t){return Math.abs(e.s-t.s)+Math.abs(e.t-t.t)},i.edgeEval=function(e,t,r){ce(i.vertLeq(e,t)&&i.vertLeq(t,r));var o=t.s-e.s,n=r.s-t.s;return o+n>0?o<n?t.t-e.t+(e.t-r.t)*(o/(o+n)):t.t-r.t+(r.t-e.t)*(n/(o+n)):0},i.edgeSign=function(e,t,r){ce(i.vertLeq(e,t)&&i.vertLeq(t,r));var o=t.s-e.s,n=r.s-t.s;return o+n>0?(t.t-r.t)*o+(t.t-e.t)*n:0},i.transEval=function(e,t,r){ce(i.transLeq(e,t)&&i.transLeq(t,r));var o=t.t-e.t,n=r.t-t.t;return o+n>0?o<n?t.s-e.s+(e.s-r.s)*(o/(o+n)):t.s-r.s+(r.s-e.s)*(n/(o+n)):0},i.transSign=function(e,t,r){ce(i.transLeq(e,t)&&i.transLeq(t,r));var o=t.t-e.t,n=r.t-t.t;return o+n>0?(t.s-r.s)*o+(t.s-e.s)*n:0},i.vertCCW=function(e,t,r){return e.s*(t.t-r.t)+t.s*(r.t-e.t)+r.s*(e.t-t.t)>=0},i.interpolate=function(e,t,r,o){return e=e<0?0:e,r=r<0?0:r,e<=r?r===0?(t+o)/2:t+(o-t)*(e/(e+r)):o+(t-o)*(r/(e+r))},i.intersect=function(e,t,r,o,n){var s,a,l;i.vertLeq(e,t)||(l=e,e=t,t=l),i.vertLeq(r,o)||(l=r,r=o,o=l),i.vertLeq(e,r)||(l=e,e=r,r=l,l=t,t=o,o=l),i.vertLeq(r,t)?i.vertLeq(t,o)?(s=i.edgeEval(e,r,t),a=i.edgeEval(r,t,o),s+a<0&&(s=-s,a=-a),n.s=i.interpolate(s,r.s,a,t.s)):(s=i.edgeSign(e,r,t),a=-i.edgeSign(e,o,t),s+a<0&&(s=-s,a=-a),n.s=i.interpolate(s,r.s,a,o.s)):n.s=(r.s+t.s)/2,i.transLeq(e,t)||(l=e,e=t,t=l),i.transLeq(r,o)||(l=r,r=o,o=l),i.transLeq(e,r)||(l=e,e=r,r=l,l=t,t=o,o=l),i.transLeq(r,t)?i.transLeq(t,o)?(s=i.transEval(e,r,t),a=i.transEval(r,t,o),s+a<0&&(s=-s,a=-a),n.t=i.interpolate(s,r.t,a,t.t)):(s=i.transSign(e,r,t),a=-i.transSign(e,o,t),s+a<0&&(s=-s,a=-a),n.t=i.interpolate(s,r.t,a,o.t)):n.t=(r.t+t.t)/2},i}(),Hi=function(){function i(){this.next=null,this.prev=null,this.anEdge=null,this.trail=null,this.n=0,this.marked=!1,this.inside=!1}return i}(),Bs=function(){function i(e){this.side=e,this.next=null,this.Org=null,this.Sym=null,this.Onext=null,this.Lnext=null,this.Lface=null,this.activeRegion=null,this.winding=0}return Object.defineProperty(i.prototype,"Rface",{get:function(){return this.Sym.Lface},set:function(e){this.Sym.Lface=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Dst",{get:function(){return this.Sym.Org},set:function(e){this.Sym.Org=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Oprev",{get:function(){return this.Sym.Lnext},set:function(e){this.Sym.Lnext=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Lprev",{get:function(){return this.Onext.Sym},set:function(e){this.Onext.Sym=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Dprev",{get:function(){return this.Lnext.Sym},set:function(e){this.Lnext.Sym=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Rprev",{get:function(){return this.Sym.Onext},set:function(e){this.Sym.Onext=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Dnext",{get:function(){return this.Sym.Onext.Sym},set:function(e){this.Sym.Onext.Sym=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Rnext",{get:function(){return this.Sym.Lnext.Sym},set:function(e){this.Sym.Lnext.Sym=e},enumerable:!0,configurable:!0}),i}(),li=function(){function i(){this.next=null,this.prev=null,this.anEdge=null,this.coords=[0,0,0],this.s=0,this.t=0,this.pqHandle=0,this.n=0,this.idx=0}return i}(),Vu=function(){function i(){var e=new li,t=new Hi,r=new Bs(0),o=new Bs(1);e.next=e.prev=e,e.anEdge=null,t.next=t.prev=t,r.next=r,r.Sym=o,o.next=o,o.Sym=r,this.vHead=e,this.fHead=t,this.eHead=r,this.eHeadSym=o}return i.prototype.makeEdge_=function(e){var t=new Bs(0),r=new Bs(1);e.Sym.side<e.side&&(e=e.Sym);var o=e.Sym.next;return r.next=o,o.Sym.next=t,t.next=e,e.Sym.next=r,t.Sym=r,t.Onext=t,t.Lnext=r,t.Org=null,t.Lface=null,t.winding=0,t.activeRegion=null,r.Sym=t,r.Onext=r,r.Lnext=t,r.Org=null,r.Lface=null,r.winding=0,r.activeRegion=null,t},i.prototype.splice_=function(e,t){var r=e.Onext,o=t.Onext;r.Sym.Lnext=t,o.Sym.Lnext=e,e.Onext=o,t.Onext=r},i.prototype.makeVertex_=function(e,t,r){var o=e;ce(o,"Vertex can't be null!");var n=r.prev;o.prev=n,n.next=o,o.next=r,r.prev=o,o.anEdge=t;var s=t;do s.Org=o,s=s.Onext;while(s!==t)},i.prototype.makeFace_=function(e,t,r){var o=e;ce(o,"Face can't be null");var n=r.prev;o.prev=n,n.next=o,o.next=r,r.prev=o,o.anEdge=t,o.trail=null,o.marked=!1,o.inside=r.inside;var s=t;do s.Lface=o,s=s.Lnext;while(s!==t)},i.prototype.killEdge_=function(e){e.Sym.side<e.side&&(e=e.Sym);var t=e.next,r=e.Sym.next;t.Sym.next=r,r.Sym.next=t},i.prototype.killVertex_=function(e,t){var r=e.anEdge,o=r;do o.Org=t,o=o.Onext;while(o!==r);var n=e.prev,s=e.next;s.prev=n,n.next=s},i.prototype.killFace_=function(e,t){var r=e.anEdge,o=r;do o.Lface=t,o=o.Lnext;while(o!==r);var n=e.prev,s=e.next;s.prev=n,n.next=s},i.prototype.makeEdge=function(){var e=new li,t=new li,r=new Hi,o=this.makeEdge_(this.eHead);return this.makeVertex_(e,o,this.vHead),this.makeVertex_(t,o.Sym,this.vHead),this.makeFace_(r,o,this.fHead),o},i.prototype.splice=function(e,t){var r=!1,o=!1;if(e!==t){if(t.Org!==e.Org&&(o=!0,this.killVertex_(t.Org,e.Org)),t.Lface!==e.Lface&&(r=!0,this.killFace_(t.Lface,e.Lface)),this.splice_(t,e),!o){var n=new li;this.makeVertex_(n,t,e.Org),e.Org.anEdge=e}if(!r){var s=new Hi;this.makeFace_(s,t,e.Lface),e.Lface.anEdge=e}}},i.prototype.delete=function(e){var t=e.Sym,r=!1;if(e.Lface!==e.Rface&&(r=!0,this.killFace_(e.Lface,e.Rface)),e.Onext===e)this.killVertex_(e.Org,null);else if(e.Rface.anEdge=e.Oprev,e.Org.anEdge=e.Onext,this.splice_(e,e.Oprev),!r){var o=new Hi;this.makeFace_(o,e,e.Lface)}t.Onext===t?(this.killVertex_(t.Org,null),this.killFace_(t.Lface,null)):(e.Lface.anEdge=t.Oprev,t.Org.anEdge=t.Onext,this.splice_(t,t.Oprev)),this.killEdge_(e)},i.prototype.addEdgeVertex=function(e){var t=this.makeEdge_(e),r=t.Sym;this.splice_(t,e.Lnext),t.Org=e.Dst;var o=new li;return this.makeVertex_(o,r,t.Org),t.Lface=r.Lface=e.Lface,t},i.prototype.splitEdge=function(e){var t=this.addEdgeVertex(e),r=t.Sym;return this.splice_(e.Sym,e.Sym.Oprev),this.splice_(e.Sym,r),e.Dst=r.Org,r.Dst.anEdge=r.Sym,r.Rface=e.Rface,r.winding=e.winding,r.Sym.winding=e.Sym.winding,r.idx=e.idx,r.Sym.idx=e.Sym.idx,r},i.prototype.connect=function(e,t){var r=!1,o=this.makeEdge_(e),n=o.Sym;if(t.Lface!==e.Lface&&(r=!0,this.killFace_(t.Lface,e.Lface)),this.splice_(o,e.Lnext),this.splice_(n,t),o.Org=e.Dst,n.Org=t.Org,o.Lface=n.Lface=e.Lface,e.Lface.anEdge=n,!r){var s=new Hi;this.makeFace_(s,o,e.Lface)}return o},i.prototype.zapFace=function(e){var t=e.anEdge,r,o,n,s,a;o=t.Lnext;do r=o,o=r.Lnext,r.Lface=null,r.Rface===null&&(r.Onext===r?this.killVertex_(r.Org,null):(r.Org.anEdge=r.Onext,this.splice_(r,r.Oprev)),n=r.Sym,n.Onext===n?this.killVertex_(n.Org,null):(n.Org.anEdge=n.Onext,this.splice_(n,n.Oprev)),this.killEdge_(r));while(r!=t);s=e.prev,a=e.next,a.prev=s,s.next=a},i.prototype.countFaceVerts_=function(e){var t=e.anEdge,r=0;do r++,t=t.Lnext;while(t!==e.anEdge);return r},i.prototype.mergeConvexFaces=function(e){var t,r,o,n,s,a,l;for(t=this.fHead.next;t!==this.fHead;t=t.next)if(!!t.inside)for(r=t.anEdge,s=r.Org;o=r.Lnext,n=r.Sym,n&&n.Lface&&n.Lface.inside&&(a=this.countFaceVerts_(t),l=this.countFaceVerts_(n.Lface),a+l-2<=e&&ae.vertCCW(r.Lprev.Org,r.Org,n.Lnext.Lnext.Org)&&ae.vertCCW(n.Lprev.Org,n.Org,r.Lnext.Lnext.Org)&&(o=n.Lnext,this.delete(n),r=null,n=null)),!(r&&r.Lnext.Org===s);)r=o;return!0},i.prototype.check=function(){var e=this.fHead,t=this.vHead,r=this.eHead,o,n,s,a,l,c;for(n=e,n=e;(o=n.next)!==e;n=o){ce(o.prev===n),l=o.anEdge;do ce(l.Sym!==l),ce(l.Sym.Sym===l),ce(l.Lnext.Onext.Sym===l),ce(l.Onext.Sym.Lnext===l),ce(l.Lface===o),l=l.Lnext;while(l!==o.anEdge)}for(ce(o.prev===n&&o.anEdge===null),a=t,a=t;(s=a.next)!==t;a=s){ce(s.prev===a),l=s.anEdge;do ce(l.Sym!==l),ce(l.Sym.Sym===l),ce(l.Lnext.Onext.Sym===l),ce(l.Onext.Sym.Lnext===l),ce(l.Org===s),l=l.Onext;while(l!==s.anEdge)}for(ce(s.prev===a&&s.anEdge===null),c=r,c=r;(l=c.next)!==r;c=l)ce(l.Sym.next===c.Sym),ce(l.Sym!==l),ce(l.Sym.Sym===l),ce(l.Org!==null),ce(l.Dst!==null),ce(l.Lnext.Onext.Sym===l),ce(l.Onext.Sym.Lnext===l);ce(l.Sym.next===c.Sym&&l.Sym===this.eHeadSym&&l.Sym.Sym===l&&l.Org===null&&l.Dst===null&&l.Lface===null&&l.Rface===null)},i}(),Uu=function(){function i(){this.handle=null}return i}(),ku=function(){function i(){this.key=null,this.node=0}return i}(),fv=function(){function i(e,t){this.leq=t,this.max=0,this.nodes=[],this.handles=[],this.initialized=!1,this.freeList=0,this.size=0,this.max=e,this.nodes=[],this.handles=[];for(var r=0;r<e+1;r++)this.nodes[r]=new Uu,this.handles[r]=new ku;this.initialized=!1,this.nodes[1].handle=1,this.handles[1].key=null}return i.prototype.floatDown_=function(e){var t=this.nodes,r=this.handles,o,n,s;for(o=t[e].handle;;){if(s=e<<1,s<this.size&&this.leq(r[t[s+1].handle].key,r[t[s].handle].key)&&++s,ce(s<=this.max),n=t[s].handle,s>this.size||this.leq(r[o].key,r[n].key)){t[e].handle=o,r[o].node=e;break}t[e].handle=n,r[n].node=e,e=s}},i.prototype.floatUp_=function(e){var t=this.nodes,r=this.handles,o,n,s;for(o=t[e].handle;;){if(s=e>>1,n=t[s].handle,s===0||this.leq(r[n].key,r[o].key)){t[e].handle=o,r[o].node=e;break}t[e].handle=n,r[n].node=e,e=s}},i.prototype.init=function(){for(var e=this.size;e>=1;--e)this.floatDown_(e);this.initialized=!0},i.prototype.min=function(){return this.handles[this.nodes[1].handle].key},i.prototype.insert=function(e){var t,r;if(t=++this.size,t*2>this.max){this.max*=2;var o,n;for(n=this.nodes.length,this.nodes.length=this.max+1,o=n;o<this.nodes.length;o++)this.nodes[o]=new Uu;for(n=this.handles.length,this.handles.length=this.max+1,o=n;o<this.handles.length;o++)this.handles[o]=new ku}return this.freeList===0?r=t:(r=this.freeList,this.freeList=this.handles[r].node),this.nodes[t].handle=r,this.handles[r].node=t,this.handles[r].key=e,this.initialized&&this.floatUp_(t),r},i.prototype.extractMin=function(){var e=this.nodes,t=this.handles,r=e[1].handle,o=t[r].key;return this.size>0&&(e[1].handle=e[this.size].handle,t[e[1].handle].node=1,t[r].key=null,t[r].node=this.freeList,this.freeList=r,--this.size,this.size>0&&this.floatDown_(1)),o},i.prototype.delete=function(e){var t=this.nodes,r=this.handles,o;ce(e>=1&&e<=this.max&&r[e].key!==null),o=r[e].node,t[o].handle=t[this.size].handle,r[t[o].handle].node=o,--this.size,o<=this.size&&(o<=1||this.leq(r[t[o>>1].handle].key,r[t[o].handle].key)?this.floatDown_(o):this.floatUp_(o)),r[e].key=null,r[e].node=this.freeList,this.freeList=e},i}(),yl=function(){function i(){this.eUp=null,this.nodeUp=null,this.windingNumber=0,this.inside=!1,this.sentinel=!1,this.dirty=!1,this.fixUpperEdge=!1}return i}(),Hu=function(){function i(){this.key=null,this.next=null,this.prev=null}return i}(),yv=function(){function i(e,t){this.frame=e,this.leq=t,this.head=new Hu,this.head.next=this.head,this.head.prev=this.head}return i.prototype.min=function(){return this.head.next},i.prototype.max=function(){return this.head.prev},i.prototype.insert=function(e){return this.insertBefore(this.head,e)},i.prototype.search=function(e){var t=this.head;do t=t.next;while(t.key!==null&&!this.leq(this.frame,e,t.key));return t},i.prototype.insertBefore=function(e,t){do e=e.prev;while(e.key!==null&&!this.leq(this.frame,e.key,t));var r=new Hu;return r.key=t,r.next=e.next,e.next.prev=r,r.prev=e,e.next=r,r},i.prototype.delete=function(e){e.next.prev=e.prev,e.prev.next=e.next},i}(),gv=function(){function i(){}return i.regionBelow=function(e){return e.nodeUp.prev.key},i.regionAbove=function(e){return e.nodeUp.next.key},i.debugEvent=function(e){},i.addWinding=function(e,t){e.winding+=t.winding,e.Sym.winding+=t.Sym.winding},i.edgeLeq=function(e,t,r){var o=e.event,n=t.eUp,s=r.eUp;if(n.Dst===o)return s.Dst===o?ae.vertLeq(n.Org,s.Org)?ae.edgeSign(s.Dst,n.Org,s.Org)<=0:ae.edgeSign(n.Dst,s.Org,n.Org)>=0:ae.edgeSign(s.Dst,o,s.Org)<=0;if(s.Dst===o)return ae.edgeSign(n.Dst,o,n.Org)>=0;var a=ae.edgeEval(n.Dst,o,n.Org),l=ae.edgeEval(s.Dst,o,s.Org);return a>=l},i.deleteRegion=function(e,t){t.fixUpperEdge&&ce(t.eUp.winding===0),t.eUp.activeRegion=null,e.dict.delete(t.nodeUp)},i.fixUpperEdge=function(e,t,r){ce(t.fixUpperEdge),e.mesh.delete(t.eUp),t.fixUpperEdge=!1,t.eUp=r,r.activeRegion=t},i.topLeftRegion=function(e,t){var r=t.eUp.Org,o;do t=i.regionAbove(t);while(t.eUp.Org===r);if(t.fixUpperEdge){if(o=e.mesh.connect(i.regionBelow(t).eUp.Sym,t.eUp.Lnext),o===null)return null;i.fixUpperEdge(e,t,o),t=i.regionAbove(t)}return t},i.topRightRegion=function(e){var t=e.eUp.Dst;do e=i.regionAbove(e);while(e.eUp.Dst===t);return e},i.addRegionBelow=function(e,t,r){var o=new yl;return o.eUp=r,o.nodeUp=e.dict.insertBefore(t.nodeUp,o),o.fixUpperEdge=!1,o.sentinel=!1,o.dirty=!1,r.activeRegion=o,o},i.isWindingInside=function(e,t){switch(e.windingRule){case $e.ODD:return(t&1)!=0;case $e.NONZERO:return t!==0;case $e.POSITIVE:return t>0;case $e.NEGATIVE:return t<0;case $e.ABS_GEQ_TWO:return t>=2||t<=-2}throw new Error("Invalid winding rulle")},i.computeWinding=function(e,t){t.windingNumber=i.regionAbove(t).windingNumber+t.eUp.winding,t.inside=i.isWindingInside(e,t.windingNumber)},i.finishRegion=function(e,t){var r=t.eUp,o=r.Lface;o.inside=t.inside,o.anEdge=r,i.deleteRegion(e,t)},i.finishLeftRegions=function(e,t,r){for(var o,n=null,s=t,a=t.eUp;s!==r;){if(s.fixUpperEdge=!1,n=i.regionBelow(s),o=n.eUp,o.Org!=a.Org){if(!n.fixUpperEdge){i.finishRegion(e,s);break}o=e.mesh.connect(a.Lprev,o.Sym),i.fixUpperEdge(e,n,o)}a.Onext!==o&&(e.mesh.splice(o.Oprev,o),e.mesh.splice(a,o)),i.finishRegion(e,s),a=n.eUp,s=n}return a},i.addRightEdges=function(e,t,r,o,n,s){var a,l,c,d,p=!0;c=r;do ce(ae.vertLeq(c.Org,c.Dst)),i.addRegionBelow(e,t,c.Sym),c=c.Onext;while(c!==o);for(n===null&&(n=i.regionBelow(t).eUp.Rprev),l=t,d=n;a=i.regionBelow(l),c=a.eUp.Sym,c.Org===d.Org;)c.Onext!==d&&(e.mesh.splice(c.Oprev,c),e.mesh.splice(d.Oprev,c)),a.windingNumber=l.windingNumber-c.winding,a.inside=i.isWindingInside(e,a.windingNumber),l.dirty=!0,!p&&i.checkForRightSplice(e,l)&&(i.addWinding(c,d),i.deleteRegion(e,l),e.mesh.delete(d)),p=!1,l=a,d=c;l.dirty=!0,ce(l.windingNumber-c.winding===a.windingNumber),s&&i.walkDirtyRegions(e,l)},i.spliceMergeVertices=function(e,t,r){e.mesh.splice(t,r)},i.vertexWeights=function(e,t,r){var o=ae.vertL1dist(t,e),n=ae.vertL1dist(r,e),s=.5*n/(o+n),a=.5*o/(o+n);e.coords[0]+=s*t.coords[0]+a*r.coords[0],e.coords[1]+=s*t.coords[1]+a*r.coords[1],e.coords[2]+=s*t.coords[2]+a*r.coords[2]},i.getIntersectData=function(e,t,r,o,n,s){t.coords[0]=t.coords[1]=t.coords[2]=0,t.idx=-1,i.vertexWeights(t,r,o),i.vertexWeights(t,n,s)},i.checkForRightSplice=function(e,t){var r=i.regionBelow(t),o=t.eUp,n=r.eUp;if(ae.vertLeq(o.Org,n.Org)){if(ae.edgeSign(n.Dst,o.Org,n.Org)>0)return!1;ae.vertEq(o.Org,n.Org)?o.Org!==n.Org&&(e.pq.delete(o.Org.pqHandle),i.spliceMergeVertices(e,n.Oprev,o)):(e.mesh.splitEdge(n.Sym),e.mesh.splice(o,n.Oprev),t.dirty=r.dirty=!0)}else{if(ae.edgeSign(o.Dst,n.Org,o.Org)<0)return!1;i.regionAbove(t).dirty=t.dirty=!0,e.mesh.splitEdge(o.Sym),e.mesh.splice(n.Oprev,o)}return!0},i.checkForLeftSplice=function(e,t){var r=i.regionBelow(t),o=t.eUp,n=r.eUp,s;if(ce(!ae.vertEq(o.Dst,n.Dst)),ae.vertLeq(o.Dst,n.Dst)){if(ae.edgeSign(o.Dst,n.Dst,o.Org)<0)return!1;i.regionAbove(t).dirty=t.dirty=!0,s=e.mesh.splitEdge(o),e.mesh.splice(n.Sym,s),s.Lface.inside=t.inside}else{if(ae.edgeSign(n.Dst,o.Dst,n.Org)>0)return!1;t.dirty=r.dirty=!0,s=e.mesh.splitEdge(n),e.mesh.splice(o.Lnext,n.Sym),s.Rface.inside=t.inside}return!0},i.checkForIntersect=function(e,t){var r=i.regionBelow(t),o=t.eUp,n=r.eUp,s=o.Org,a=n.Org,l=o.Dst,c=n.Dst,d,p,u=new li,f,m;if(ce(!ae.vertEq(c,l)),ce(ae.edgeSign(l,e.event,s)<=0),ce(ae.edgeSign(c,e.event,a)>=0),ce(s!==e.event&&a!==e.event),ce(!t.fixUpperEdge&&!r.fixUpperEdge),s===a||(d=Math.min(s.t,l.t),p=Math.max(a.t,c.t),d>p))return!1;if(ae.vertLeq(s,a)){if(ae.edgeSign(c,s,a)>0)return!1}else if(ae.edgeSign(l,a,s)<0)return!1;return i.debugEvent(e),ae.intersect(l,s,c,a,u),ce(Math.min(s.t,l.t)<=u.t),ce(u.t<=Math.max(a.t,c.t)),ce(Math.min(c.s,l.s)<=u.s),ce(u.s<=Math.max(a.s,s.s)),ae.vertLeq(u,e.event)&&(u.s=e.event.s,u.t=e.event.t),f=ae.vertLeq(s,a)?s:a,ae.vertLeq(f,u)&&(u.s=f.s,u.t=f.t),ae.vertEq(u,s)||ae.vertEq(u,a)?(i.checkForRightSplice(e,t),!1):!ae.vertEq(l,e.event)&&ae.edgeSign(l,e.event,u)>=0||!ae.vertEq(c,e.event)&&ae.edgeSign(c,e.event,u)<=0?c===e.event?(e.mesh.splitEdge(o.Sym),e.mesh.splice(n.Sym,o),t=i.topLeftRegion(e,t),o=i.regionBelow(t).eUp,i.finishLeftRegions(e,i.regionBelow(t),r),i.addRightEdges(e,t,o.Oprev,o,o,!0),!0):l===e.event?(e.mesh.splitEdge(n.Sym),e.mesh.splice(o.Lnext,n.Oprev),r=t,t=i.topRightRegion(t),m=i.regionBelow(t).eUp.Rprev,r.eUp=n.Oprev,n=i.finishLeftRegions(e,r,null),i.addRightEdges(e,t,n.Onext,o.Rprev,m,!0),!0):(ae.edgeSign(l,e.event,u)>=0&&(i.regionAbove(t).dirty=t.dirty=!0,e.mesh.splitEdge(o.Sym),o.Org.s=e.event.s,o.Org.t=e.event.t),ae.edgeSign(c,e.event,u)<=0&&(t.dirty=r.dirty=!0,e.mesh.splitEdge(n.Sym),n.Org.s=e.event.s,n.Org.t=e.event.t),!1):(e.mesh.splitEdge(o.Sym),e.mesh.splitEdge(n.Sym),e.mesh.splice(n.Oprev,o),o.Org.s=u.s,o.Org.t=u.t,o.Org.pqHandle=e.pq.insert(o.Org),i.getIntersectData(e,o.Org,s,l,a,c),i.regionAbove(t).dirty=t.dirty=r.dirty=!0,!1)},i.walkDirtyRegions=function(e,t){for(var r=i.regionBelow(t),o,n;;){for(;r.dirty;)t=r,r=i.regionBelow(r);if(!t.dirty&&(r=t,t=i.regionAbove(t),t===null||!t.dirty))return;if(t.dirty=!1,o=t.eUp,n=r.eUp,o.Dst!==n.Dst&&i.checkForLeftSplice(e,t)&&(r.fixUpperEdge?(i.deleteRegion(e,r),e.mesh.delete(n),r=i.regionBelow(t),n=r.eUp):t.fixUpperEdge&&(i.deleteRegion(e,t),e.mesh.delete(o),t=i.regionAbove(r),o=t.eUp)),o.Org!==n.Org)if(o.Dst!==n.Dst&&!t.fixUpperEdge&&!r.fixUpperEdge&&(o.Dst===e.event||n.Dst===e.event)){if(i.checkForIntersect(e,t))return}else i.checkForRightSplice(e,t);o.Org===n.Org&&o.Dst===n.Dst&&(i.addWinding(n,o),i.deleteRegion(e,t),e.mesh.delete(o),t=i.regionAbove(r))}},i.connectRightVertex=function(e,t,r){var o,n=r.Onext,s=i.regionBelow(t),a=t.eUp,l=s.eUp,c=!1;if(a.Dst!==l.Dst&&i.checkForIntersect(e,t),ae.vertEq(a.Org,e.event)&&(e.mesh.splice(n.Oprev,a),t=i.topLeftRegion(e,t),n=i.regionBelow(t).eUp,i.finishLeftRegions(e,i.regionBelow(t),s),c=!0),ae.vertEq(l.Org,e.event)&&(e.mesh.splice(r,l.Oprev),r=i.finishLeftRegions(e,s,null),c=!0),c){i.addRightEdges(e,t,r.Onext,n,n,!0);return}ae.vertLeq(l.Org,a.Org)?o=l.Oprev:o=a,o=e.mesh.connect(r.Lprev,o),i.addRightEdges(e,t,o,o.Onext,o.Onext,!1),o.Sym.activeRegion.fixUpperEdge=!0,i.walkDirtyRegions(e,t)},i.connectLeftDegenerate=function(e,t,r){var o,n,s,a,l;if(o=t.eUp,ae.vertEq(o.Org,r)){ce(!1),i.spliceMergeVertices(e,o,r.anEdge);return}if(!ae.vertEq(o.Dst,r)){e.mesh.splitEdge(o.Sym),t.fixUpperEdge&&(e.mesh.delete(o.Onext),t.fixUpperEdge=!1),e.mesh.splice(r.anEdge,o),i.sweepEvent(e,r);return}ce(!1),t=i.topRightRegion(t),l=i.regionBelow(t),s=l.eUp.Sym,n=a=s.Onext,l.fixUpperEdge&&(ce(n!==s),i.deleteRegion(e,l),e.mesh.delete(s),s=n.Oprev),e.mesh.splice(r.anEdge,s),ae.edgeGoesLeft(n)||(n=null),i.addRightEdges(e,t,s.Onext,a,n,!0)},i.connectLeftVertex=function(e,t){var r,o,n,s,a,l,c=new yl;if(c.eUp=t.anEdge.Sym,r=e.dict.search(c).key,o=i.regionBelow(r),!!o){if(s=r.eUp,a=o.eUp,ae.edgeSign(s.Dst,t,s.Org)===0){i.connectLeftDegenerate(e,r,t);return}if(n=ae.vertLeq(a.Dst,s.Dst)?r:o,r.inside||n.fixUpperEdge){if(n===r)l=e.mesh.connect(t.anEdge.Sym,s.Lnext);else{var d=e.mesh.connect(a.Dnext,t.anEdge);l=d.Sym}n.fixUpperEdge?i.fixUpperEdge(e,n,l):i.computeWinding(e,i.addRegionBelow(e,r,l)),i.sweepEvent(e,t)}else i.addRightEdges(e,r,t.anEdge,t.anEdge,null,!0)}},i.sweepEvent=function(e,t){e.event=t,i.debugEvent(e);for(var r=t.anEdge;r.activeRegion===null;)if(r=r.Onext,r===t.anEdge){i.connectLeftVertex(e,t);return}var o=i.topLeftRegion(e,r.activeRegion);ce(o!==null);var n=i.regionBelow(o),s=n.eUp,a=i.finishLeftRegions(e,n,null);a.Onext===s?i.connectRightVertex(e,o,a):i.addRightEdges(e,o,a.Onext,s,s,!0)},i.addSentinel=function(e,t,r,o){var n=new yl,s=e.mesh.makeEdge();s.Org.s=r,s.Org.t=o,s.Dst.s=t,s.Dst.t=o,e.event=s.Dst,n.eUp=s,n.windingNumber=0,n.inside=!1,n.fixUpperEdge=!1,n.sentinel=!0,n.dirty=!1,n.nodeUp=e.dict.insert(n)},i.initEdgeDict=function(e){e.dict=new yv(e,i.edgeLeq);var t=e.bmax[0]-e.bmin[0],r=e.bmax[1]-e.bmin[1],o=e.bmin[0]-t,n=e.bmax[0]+t,s=e.bmin[1]-r,a=e.bmax[1]+r;i.addSentinel(e,o,n,s),i.addSentinel(e,o,n,a)},i.doneEdgeDict=function(e){for(var t,r=0;(t=e.dict.min().key)!==null;)t.sentinel||(ce(t.fixUpperEdge),ce(++r==1)),ce(t.windingNumber===0),i.deleteRegion(e,t)},i.removeDegenerateEdges=function(e){var t,r,o,n=e.mesh.eHead;for(t=n.next;t!==n;t=r)r=t.next,o=t.Lnext,ae.vertEq(t.Org,t.Dst)&&t.Lnext.Lnext!==t&&(i.spliceMergeVertices(e,o,t),e.mesh.delete(t),t=o,o=t.Lnext),o.Lnext===t&&(o!==t&&((o===r||o===r.Sym)&&(r=r.next),e.mesh.delete(o)),(t===r||t===r.Sym)&&(r=r.next),e.mesh.delete(t))},i.initPriorityQ=function(e){var t,r,o,n=0;for(o=e.mesh.vHead,r=o.next;r!==o;r=r.next)n++;for(n+=8,t=e.pq=new fv(n,ae.vertLeq),o=e.mesh.vHead,r=o.next;r!==o;r=r.next)r.pqHandle=t.insert(r);return r!==o?!1:(t.init(),!0)},i.donePriorityQ=function(e){e.pq=null},i.removeDegenerateFaces=function(e,t){var r,o,n;for(r=t.fHead.next;r!==t.fHead;r=o)o=r.next,n=r.anEdge,ce(n.Lnext!==n),n.Lnext.Lnext===n&&(i.addWinding(n.Onext,n),e.mesh.delete(n));return!0},i.computeInterior=function(e,t){t===void 0&&(t=!0);var r,o;if(i.removeDegenerateEdges(e),!i.initPriorityQ(e))return!1;for(i.initEdgeDict(e);(r=e.pq.extractMin())!==null;){for(;o=e.pq.min(),!(o===null||!ae.vertEq(o,r));)o=e.pq.extractMin(),i.spliceMergeVertices(e,r.anEdge,o.anEdge);i.sweepEvent(e,r)}return e.event=e.dict.min().key.eUp.Org,i.debugEvent(e),i.doneEdgeDict(e),i.donePriorityQ(e),i.removeDegenerateFaces(e,e.mesh)?(t&&e.mesh.check(),!0):!1},i}(),xv=function(){function i(){this.mesh=new Vu,this.normal=[0,0,0],this.sUnit=[0,0,0],this.tUnit=[0,0,0],this.bmin=[0,0],this.bmax=[0,0],this.windingRule=$e.ODD,this.dict=null,this.pq=null,this.event=null,this.vertexIndexCounter=0,this.vertices=[],this.vertexIndices=[],this.vertexCount=0,this.elements=[],this.elementCount=0}return i.prototype.dot_=function(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]},i.prototype.normalize_=function(e){var t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2];if(!t)throw"Zero-size vector!";t=Math.sqrt(t),e[0]/=t,e[1]/=t,e[2]/=t},i.prototype.longAxis_=function(e){var t=0;return Math.abs(e[1])>Math.abs(e[0])&&(t=1),Math.abs(e[2])>Math.abs(e[t])&&(t=2),t},i.prototype.computeNormal_=function(e){var t,r,o,n,s,a,l=[0,0,0],c=[0,0,0],d=[0,0,0],p=[0,0,0],u=[0,0,0],f=[null,null,null],m=[null,null,null],x=this.mesh.vHead;t=x.next;for(var y=0;y<3;++y)n=t.coords[y],c[y]=n,m[y]=t,l[y]=n,f[y]=t;for(t=x.next;t!==x;t=t.next)for(var N=0;N<3;++N)n=t.coords[N],n<c[N]&&(c[N]=n,m[N]=t),n>l[N]&&(l[N]=n,f[N]=t);var L=0;if(l[1]-c[1]>l[0]-c[0]&&(L=1),l[2]-c[2]>l[L]-c[L]&&(L=2),c[L]>=l[L]){e[0]=0,e[1]=0,e[2]=1;return}for(a=0,r=m[L],o=f[L],d[0]=r.coords[0]-o.coords[0],d[1]=r.coords[1]-o.coords[1],d[2]=r.coords[2]-o.coords[2],t=x.next;t!==x;t=t.next)p[0]=t.coords[0]-o.coords[0],p[1]=t.coords[1]-o.coords[1],p[2]=t.coords[2]-o.coords[2],u[0]=d[1]*p[2]-d[2]*p[1],u[1]=d[2]*p[0]-d[0]*p[2],u[2]=d[0]*p[1]-d[1]*p[0],s=u[0]*u[0]+u[1]*u[1]+u[2]*u[2],s>a&&(a=s,e[0]=u[0],e[1]=u[1],e[2]=u[2]);a<=0&&(e[0]=e[1]=e[2]=0,e[this.longAxis_(d)]=1)},i.prototype.checkOrientation_=function(){for(var e=this.mesh.fHead,t,r=this.mesh.vHead,o,n=0,s=e.next;s!==e;s=s.next)if(o=s.anEdge,!(o.winding<=0))do n+=(o.Org.s-o.Dst.s)*(o.Org.t+o.Dst.t),o=o.Lnext;while(o!==s.anEdge);if(n<0){for(t=r.next;t!==r;t=t.next)t.t=-t.t;this.tUnit[0]=-this.tUnit[0],this.tUnit[1]=-this.tUnit[1],this.tUnit[2]=-this.tUnit[2]}},i.prototype.projectPolygon_=function(){var e=this.mesh.vHead,t=[0,0,0],r,o,n=!1;t[0]=this.normal[0],t[1]=this.normal[1],t[2]=this.normal[2],!t[0]&&!t[1]&&!t[2]&&(this.computeNormal_(t),n=!0),r=this.sUnit,o=this.tUnit;var s=this.longAxis_(t);r[s]=0,r[(s+1)%3]=1,r[(s+2)%3]=0,o[s]=0,o[(s+1)%3]=0,o[(s+2)%3]=t[s]>0?1:-1;for(var a=e.next;a!==e;a=a.next)a.s=this.dot_(a.coords,r),a.t=this.dot_(a.coords,o);n&&this.checkOrientation_();for(var l=!0,c=e.next;c!==e;c=c.next)l?(this.bmin[0]=this.bmax[0]=c.s,this.bmin[1]=this.bmax[1]=c.t,l=!1):(c.s<this.bmin[0]&&(this.bmin[0]=c.s),c.s>this.bmax[0]&&(this.bmax[0]=c.s),c.t<this.bmin[1]&&(this.bmin[1]=c.t),c.t>this.bmax[1]&&(this.bmax[1]=c.t))},i.prototype.addWinding_=function(e,t){e.winding+=t.winding,e.Sym.winding+=t.Sym.winding},i.prototype.tessellateMonoRegion_=function(e,t){var r,o;if(r=t.anEdge,!(r.Lnext!==r&&r.Lnext.Lnext!==r))throw"Mono region invalid";for(;ae.vertLeq(r.Dst,r.Org);r=r.Lprev);for(;ae.vertLeq(r.Org,r.Dst);r=r.Lnext);o=r.Lprev;for(var n=void 0;r.Lnext!==o;)if(ae.vertLeq(r.Dst,o.Org)){for(;o.Lnext!==r&&(ae.edgeGoesLeft(o.Lnext)||ae.edgeSign(o.Org,o.Dst,o.Lnext.Dst)<=0);)n=e.connect(o.Lnext,o),o=n.Sym;o=o.Lprev}else{for(;o.Lnext!==r&&(ae.edgeGoesRight(r.Lprev)||ae.edgeSign(r.Dst,r.Org,r.Lprev.Org)>=0);)n=e.connect(r,r.Lprev),r=n.Sym;r=r.Lnext}if(o.Lnext===r)throw"Mono region invalid";for(;o.Lnext.Lnext!==r;)n=e.connect(o.Lnext,o),o=n.Sym;return!0},i.prototype.tessellateInterior_=function(e){for(var t,r=e.fHead.next;r!==e.fHead;r=t)if(t=r.next,r.inside&&!this.tessellateMonoRegion_(e,r))return!1;return!0},i.prototype.discardExterior_=function(e){for(var t,r=e.fHead.next;r!==e.fHead;r=t)t=r.next,r.inside||e.zapFace(r)},i.prototype.setWindingNumber_=function(e,t,r){for(var o,n=e.eHead.next;n!==e.eHead;n=o)o=n.next,n.Rface.inside!==n.Lface.inside?n.winding=n.Lface.inside?t:-t:r?e.delete(n):n.winding=0},i.prototype.getNeighbourFace_=function(e){return!e.Rface||!e.Rface.inside?-1:e.Rface.n},i.prototype.outputPolymesh_=function(e,t,r,o){var n,s=0,a=0,l;r>3&&e.mergeConvexFaces(r);for(var c=e.vHead.next;c!==e.vHead;c=c.next)c.n=-1;for(var d=e.fHead.next;d!==e.fHead;d=d.next)if(d.n=-1,!!d.inside){n=d.anEdge,l=0;do{var c=n.Org;c.n===-1&&(c.n=a,a++),l++,n=n.Lnext}while(n!==d.anEdge);if(l>r)throw"Face vertex greater that support polygon";d.n=s,++s}this.elementCount=s,t===st.CONNECTED_POLYGONS&&(s*=2),this.elements=[],this.elements.length=s*r,this.vertexCount=a,this.vertices=[],this.vertices.length=a*o,this.vertexIndices=[],this.vertexIndices.length=a;for(var c=e.vHead.next;c!==e.vHead;c=c.next)if(c.n!==-1){var p=c.n*o;this.vertices[p+0]=c.coords[0],this.vertices[p+1]=c.coords[1],o>2&&(this.vertices[p+2]=c.coords[2]),this.vertexIndices[c.n]=c.idx}for(var u=0,d=e.fHead.next;d!==e.fHead;d=d.next)if(!!d.inside){n=d.anEdge,l=0;do{var c=n.Org;this.elements[u++]=c.n,l++,n=n.Lnext}while(n!==d.anEdge);for(var f=l;f<r;++f)this.elements[u++]=-1;if(t===st.CONNECTED_POLYGONS){n=d.anEdge;do this.elements[u++]=this.getNeighbourFace_(n),n=n.Lnext;while(n!==d.anEdge);for(var m=l;m<r;++m)this.elements[u++]=-1}}},i.prototype.outputContours_=function(e,t){var r,o,n=0,s=0;this.vertexCount=0,this.elementCount=0;for(var a=e.fHead.next;a!==e.fHead;a=a.next)if(!!a.inside){o=r=a.anEdge;do this.vertexCount++,r=r.Lnext;while(r!==o);this.elementCount++}this.elements=[],this.elements.length=this.elementCount*2,this.vertices=[],this.vertices.length=this.vertexCount*t,this.vertexIndices=[],this.vertexIndices.length=this.vertexCount;var l=0,c=0,d=0;n=0;for(var a=e.fHead.next;a!==e.fHead;a=a.next)if(!!a.inside){s=0,o=r=a.anEdge;do this.vertices[l++]=r.Org.coords[0],this.vertices[l++]=r.Org.coords[1],t>2&&(this.vertices[l++]=r.Org.coords[2]),this.vertexIndices[c++]=this.vertexIdCallback?this.vertexIdCallback(r):r.Org.idx,s++,r=r.Lnext;while(r!==o);this.elements[d++]=n,this.elements[d++]=s,n+=s}},i.prototype.addContour=function(e,t){this.mesh===null&&(this.mesh=new Vu),e<2&&(e=2),e>3&&(e=3);for(var r=null,o=0;o<t.length;o+=e)r===null?(r=this.mesh.makeEdge(),this.mesh.splice(r,r.Sym)):(this.mesh.splitEdge(r),r=r.Lnext),r.Org.coords[0]=t[o+0],r.Org.coords[1]=t[o+1],e>2?r.Org.coords[2]=t[o+2]:r.Org.coords[2]=0,r.Org.idx=this.vertexIndexCounter++,this.edgeCreateCallback&&this.edgeCreateCallback(r),r.winding=1,r.Sym.winding=-1},i.prototype.tesselate=function(e,t,r,o,n,s){if(e===void 0&&(e=$e.ODD),t===void 0&&(t=st.POLYGONS),s===void 0&&(s=!0),this.vertices=[],this.elements=[],this.vertexIndices=[],this.vertexIndexCounter=0,n&&(this.normal[0]=n[0],this.normal[1]=n[1],this.normal[2]=n[2]),this.windingRule=e,o<2&&(o=2),o>3&&(o=3),!this.mesh)return!1;this.projectPolygon_(),gv.computeInterior(this,s);var a=this.mesh;return t===st.BOUNDARY_CONTOURS?this.setWindingNumber_(a,1,!0):this.tessellateInterior_(a),s&&a.check(),t===st.BOUNDARY_CONTOURS?this.outputContours_(a,o):this.outputPolymesh_(a,t,r,o),!0},i}();function wo(i){var e=i.windingRule,t=e===void 0?$e.ODD:e,r=i.elementType,o=r===void 0?st.POLYGONS:r,n=i.polySize,s=n===void 0?3:n,a=i.vertexSize,l=a===void 0?2:a,c=i.normal,d=c===void 0?[0,0,1]:c,p=i.contours,u=p===void 0?[]:p,f=i.strict,m=f===void 0?!0:f,x=i.debug,y=x===void 0?!1:x;if(!u&&m)throw new Error("Contours can't be empty");if(!!u){var N=new xv;i.edgeCreateCallback&&(N.edgeCreateCallback=i.edgeCreateCallback),i.vertexIdCallback&&(N.vertexIdCallback=i.vertexIdCallback);for(var L=0;L<u.length;L++)N.addContour(l||2,u[L]);return N.tesselate(t,o,s,l,d,m),{vertices:N.vertices,vertexIndices:N.vertexIndices,vertexCount:N.vertexCount,elements:N.elements,elementCount:N.elementCount,mesh:y?N.mesh:void 0}}}var Uj=$e.ODD,kj=$e.NONZERO,Hj=$e.POSITIVE,qj=$e.NEGATIVE,Wj=$e.ABS_GEQ_TWO,$j=st.POLYGONS,Jj=st.CONNECTED_POLYGONS,Kj=st.BOUNDARY_CONTOURS;var No=class extends bv{constructor(e,t=12,r=100,o={}){super();this.type="ShapeGeometry";this.windingRule=$e.ODD;this.elementType=st.POLYGONS;this.polySize=3;this.vertexSize=2;this.strict=!0;this._drawCount=0,this._shape=e,this._curveSegments=t,this._maxCount=r,this._maxDrawCount=r*3,this._triangulationOptions=Object.assign({windingRule:$e.ODD,elementType:st.POLYGONS,polySize:3,vertexSize:2,strict:!0},o),this._positionAttribute=new Gs(new Float32Array(r*3),3),this._normalAttribute=new Gs(new Float32Array(r*3),3),this._uvAttribute=new Gs(new Float32Array(r*2),2),this._indexAttribute=new Gs(new Uint32Array(r*3),1),this.setAttribute("position",this._positionAttribute),this.setAttribute("normal",this._normalAttribute),this.setAttribute("uv",this._uvAttribute),this.setIndex(this._indexAttribute),this.updateFromShape()}copy(e){return this._drawCount=e.drawCount,this._maxDrawCount=e._maxDrawCount,this._maxCount=e.maxCount,super.copy(e)}get curveSegments(){return this._curveSegments}set curveSegments(e){this._curveSegments=e,this.updateFromShape()}get drawCount(){return this._drawCount}get maxDrawCount(){return this._maxDrawCount}get maxCount(){return this._maxCount}updateFromShape(){let e=this._shape.extractShapePointsToFlatArray([],this._curveSegments),t=this._shape.shapeHoles.map(l=>l.extractShapePointsToFlatArray([],this._curveSegments)),r,o=!0,n=!0,s,a;for(let l=0,c=e.length/2;l<c;l++){let d=l*2,p=e[d+0],u=e[d+1];if(s!==void 0&&p!==s&&(o=!1),a!==void 0&&u!==a&&(n=!1),s=p,a=u,!o&&!n)break}if(!o&&!n&&(r=wo({contours:[e,...t],windingRule:this._triangulationOptions.windingRule,elementType:this._triangulationOptions.elementType,polySize:this._triangulationOptions.polySize,vertexSize:this._triangulationOptions.vertexSize,strict:this._triangulationOptions.strict})),this._positionAttribute.array.fill(0),this._normalAttribute.array.fill(0),this._uvAttribute.array.fill(0),this._indexAttribute.array.fill(0),this._drawCount=0,r){let l=1/0,c=-1/0,d=1/0,p=-1/0;for(let m=0,x=r.vertexCount;m<x;m++){let y=m*2,N=r.vertices[y+0],L=r.vertices[y+1];N<l&&(l=N),N>c&&(c=N),L<d&&(d=L),L>p&&(p=L)}let u=c-l,f=p-d;for(let m=0,x=r.vertexCount;m<x;m++){let y=m*2,N=r.vertices[y+0],L=r.vertices[y+1],w=(N-l)/u,B=(L-d)/f;this._positionAttribute.setXYZ(m,N,L,0),this._normalAttribute.setXYZ(m,0,0,1),this._uvAttribute.setXY(m,w,B)}for(let m=0,x=r.elementCount;m<x;m++){let y=m*3,N=r.elements[y+0],L=r.elements[y+1],w=r.elements[y+2];this._indexAttribute.setX(y+0,N),this._indexAttribute.setX(y+1,L),this._indexAttribute.setX(y+2,w),this._drawCount+=3}}return this._positionAttribute.needsUpdate=!0,this._normalAttribute.needsUpdate=!0,this._uvAttribute.needsUpdate=!0,this._indexAttribute.needsUpdate=!0,this.setDrawRange(0,this._drawCount),this._drawCount>this._maxDrawCount}clone(){let e=new No(this._shape,this._curveSegments,this._maxCount);return e.userData=yo(this.userData),e}};import{BufferAttribute as Fs,BufferGeometry as vv}from"three";var Es=class{constructor(e=256,t=!1){this.capacity=e,this.size=0,this.debug=t,this.debug&&console.log(`allocating with cap ${e}`);let r=e*Es.eSize;this.buffer=new ArrayBuffer(r);let o=Float32Array.BYTES_PER_ELEMENT,n=0;this.positions=new Float32Array(this.buffer,n*o,3*e),n+=3*e,this.normals=new Float32Array(this.buffer,n*o,3*e),n+=3*e,this.uvs=new Float32Array(this.buffer,n*o,2*e)}realloc(e,t=!1){if(e<this.size)throw Error("cannot shrink buffer");if(e<=this.capacity&&!t)return;this.debug&&console.log(`resizing from ${this.capacity} \u2192 ${e}`);let r=e*Es.eSize,o=new ArrayBuffer(r),n=Float32Array.BYTES_PER_ELEMENT,s=0,a=new Float32Array(o,s*n,3*e);s+=3*e;let l=new Float32Array(o,s*n,3*e);s+=3*e;let c=new Float32Array(o,s*n,2*e);a.set(this.positions.slice(0,this.size*3)),l.set(this.normals.slice(0,this.size*3)),c.set(this.uvs.slice(0,this.size*2)),this.buffer=o,this.positions=a,this.normals=l,this.uvs=c,this.capacity=e}get(e=1){let t=this.size+e;if(t>this.capacity){let o=this.capacity;for(;t>o;)o*=2;this.realloc(o)}let r=this.size;return this.size=t,r}reserve(e){let t=this.size+e;t>this.capacity&&this.realloc(t)}shrink(){this.debug&&console.log(`shrinking ${this.capacity} \u2192 ${this.size}`),this.realloc(this.size,!0)}},zs=Es;zs.eSize=(3+3+2)*Float32Array.BYTES_PER_ELEMENT;var gl=(i,e)=>([t,r])=>(r<t&&(r+=e),(i>=t?i:i+e)<=r),qi=class extends vv{constructor(e,t,r=0,o=12,n=3){super();this.type="ShapeGeometry";this.vertexCache={};this._shape=e,this._depth=t,this._bevel=r,this._curveSegments=o,this._bevelSegmentsInput=n,r<=0?(this._bevelSize=0,this._bevelSegments=0):(this._bevelSize=Math.min(r,t/2-1e-12),this._bevelSegments=Math.floor(n));let s=this._shape.extractShapePointsToFlatArray([],o),a=this._shape.shapeHoles.map(_=>{let T=_.extractShapePointsToFlatArray([],o),h=[];for(let I=T.length-1;I>=1;I-=2){let b=T[I-1],P=T[I-0];h.push(b,P)}return h}),l=wo({windingRule:$e.ODD,elementType:st.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[s]}),c=wo({windingRule:$e.ODD,elementType:st.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...a]});if(!l)throw new Error("error generating geometry");let d=l.elementCount;if(c){l.elementCount+=c.elementCount;for(let _=0;_<c.elements.length;_++){let T=c.elements[_],h=_%2==0?l.vertexCount:0;l.elements.push(T+h)}for(let _=0;_<c.vertexIndices.length;_++){let T=c.vertexIndices[_],h=l.vertexCount;l.vertexIndices.push(T+h)}for(let _=0;_<c.vertices.length;_++){let T=c.vertices[_];l.vertices.push(T)}}let p=1/0,u=-1/0,f=1/0,m=-1/0;for(let _=0,T=l.vertexCount;_<T;_++){let h=_*2,I=l.vertices[h+0],b=l.vertices[h+1];I<p&&(p=I),I>u&&(u=I),b<f&&(f=b),b>m&&(m=b)}this._minX=p,this._minY=f,this._width=u-p,this._height=m-f;let x=l.vertexCount*2*(2+this._bevelSegments);this._buffer=new zs(x);let y=[],N=[];for(let _=l.elementCount-1;_>=0;_--){let T=_>=d,h=_*2,I=l.elements[h+0],b=l.elements[h+1],P=I+b,v={start:I,count:b,normals:[],continuous:[],concave:[]},D=I,Z=P-1,V=I+1,ie=this._shape.roundedCurves.length;do{let A=D-I,j=l.vertices[Z*2+0],g=l.vertices[Z*2+1],z=l.vertices[D*2+0],R=l.vertices[D*2+1],U=l.vertices[V*2+0],q=l.vertices[V*2+1],W=z-j,J=R-g,E=Math.sqrt(W*W+J*J);W/=E,J/=E;let H=z-U,k=R-q,se=Math.sqrt(H*H+k*k);H/=se,k/=se,v.normals[A*2+0]=-k,v.normals[A*2+1]=H,v.concave[A]=W*k-J*H>0;let F=l.vertexIndices[D];if(Array.isArray(F))v.continuous[A]=!1;else{let[K,X]=this._shape.getCurveIndexFromVertexId(F-1,!0);if(X>0&&X<1)v.continuous[A]=!0;else{let te=X===1?K+1:K-1;te=(te+ie)%ie;let he=X===1?0:1,Y=this._shape.roundedCurves[K].getTangent(X),ne=this._shape.roundedCurves[te].getTangent(he);v.continuous[A]=Y.dot(ne)>.95}}T&&(v.normals[A*2+0]*=-1,v.normals[A*2+1]*=-1),[Z,D,V]=[D,V,V+1],V>=P&&(V-=b)}while(V!==I+1);let oe=[];oe.push({bevelI:0,angle:0,size:0,boundary:{vertices:l.vertices.slice(I*2,P*2),vertexCount:b,vertexIndices:new Array(b).fill(!0).map((A,j)=>[j,j]),elements:[0,b],elementCount:1,mesh:null},reverseMap:[],insetPoints:l.vertices.slice(I*2,P*2)});for(let A=1;A<=this._bevelSegments;A++){let j=A/this._bevelSegments*Math.PI/2,g=(1-Math.cos(j))*this._bevelSize,z=[],R=[],U=[],q=[],W=0;for(let E=0;E<b;E++){let H=E*2,k=(E-1+b)%b*2,se=l.vertices[v.start*2+H+0],F=l.vertices[v.start*2+H+1],K=-v.normals[k+0]*g,X=-v.normals[k+1]*g,te=-v.normals[H+0]*g,he=-v.normals[H+1]*g;if(v.concave[E]||!v.concave[E]&&T){let Y=Math.atan2(X,K),ne=Math.atan2(he,te);ne>Y&&(ne-=Math.PI*2);let Se=ne-Y;if(v.continuous[E]||T){let me=Y+Se/2,Oe=Math.cos(me)*g,He=Math.sin(me)*g;z[2*W+0]=se+Oe*(T?-1:1),z[2*W+1]=F+He*(T?-1:1),q[W]=E,W++}else{let me=Math.max(1,Math.floor(o/4*Math.abs(Se)/Math.PI));for(let Oe=0;Oe<=me;Oe++){let He=Y+Se*(Oe/me),rt=Math.cos(He)*g,pt=Math.sin(He)*g;z[2*W+0]=se+rt,z[2*W+1]=F+pt,q[W]=E,W++}}}else z[2*W+0]=se+K,z[2*W+1]=F+X,q[W]=E,R[E]=W,W++,z[2*W+0]=se,z[2*W+1]=F,q[W]=E,W++,z[2*W+0]=se+te,z[2*W+1]=F+he,q[W]=E,U[E]=W,W++}let J=wo({windingRule:$e.POSITIVE,elementType:st.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[z],edgeCreateCallback:E=>{let k=E.Org.idx,se=q[k],F=q[(k+1)%q.length];E.idx=[se,F],E.Sym.idx=[F,se]},vertexIdCallback:E=>{let H=E.Lprev.idx;return[H?H[1]:0,E.idx[0]]}});if(!J)throw console.log("Error"),new Error(`error generating bevel geometry for ${A}'th loop`);if(!J.vertexCount)break;for(let E=0;E<J.vertexIndices.length;E++){let[H,k]=J.vertexIndices[E];if(H===k)continue;let se=k;k<H&&(se+=b);for(let F=H;F<se;F++){let K=F%b,X=(F+1)%b;if(!v.continuous[K]||!v.continuous[X]){J.vertexIndices[E]=[H,K],J.vertexIndices.splice(E+1,0,[X,k]),J.vertices.splice((E+1)*2,0,J.vertices[E*2],J.vertices[E*2+1]);break}}}oe.push({bevelI:A,angle:j,size:g,boundary:J,reverseMap:q,insetPoints:z})}let ge=(A,j,g)=>{let z=0,R=A.boundary.vertexIndices.length;for(;z<R&&g(A.boundary.vertexIndices[j]);)j=(j+1)%R,z++;return z},xe=y.length;for(let A=1;A<oe.length;A++){let j=oe[A-1],g=oe[A],z=j.boundary.vertexIndices.length,R=g.boundary.vertexIndices.length;if(!z||!R)break;let U=v.concave.length,q=0,W=gl(q,b);for(;!j.boundary.vertexIndices.filter(W).length||!g.boundary.vertexIndices.filter(W).length;)q++,W=gl(q,b);let J=j.boundary.vertexIndices.findIndex(W),E=g.boundary.vertexIndices.findIndex(W);do J=(J+1)%z;while(W(j.boundary.vertexIndices[J]));do E=(E+1)%R;while(W(g.boundary.vertexIndices[E]));q=(q+1)%b;let H=q,k=this.buildBevelVert(v,j,(J-1+z)%z),se=this.buildBevelVert(v,g,(E-1+R)%R),F=k,K=se,X,te,he=!1;do{W=gl(q,b);let Y=ge(j,J,W),ne=ge(g,E,W),Se=he;if(he=!1,Y&&!ne){for(let me=0;me<Y;me++)X=this.buildBevelVert(v,j,(J+me)%z,me/(Y-1)),y.push(F.topN,X.topP,K.topN),y.push(X.bottomP,F.bottomN,K.bottomN),F=X;he=!0}else if(!Y&&ne)for(let me=0;me<ne;me++)te=this.buildBevelVert(v,g,(E+me)%R,me/(ne-1)),y.push(K.topN,F.topP,te.topP),y.push(F.bottomP,K.bottomN,te.bottomP),K=te;else if(Y&&ne)if(X=this.buildBevelVert(v,j,J,0),te=this.buildBevelVert(v,g,E,0),Se?(y.push(F.topN,te.topP,K.topN),y.push(F.topN,X.topP,te.topP),y.push(te.bottomP,F.bottomN,K.bottomN),y.push(X.bottomP,F.bottomN,te.bottomP)):(y.push(F.topN,X.topP,K.topN),y.push(K.topN,X.topP,te.topP),y.push(X.bottomP,F.bottomN,K.bottomN),y.push(X.bottomP,K.bottomN,te.bottomP)),F=X,K=te,Y===ne)for(let me=1;me<Y;me++)X=this.buildBevelVert(v,j,(J+me)%z,me/(Y-1)),te=this.buildBevelVert(v,g,(E+me)%R,me/(ne-1)),y.push(F.topN,X.topP,K.topN),y.push(K.topN,X.topP,te.topP),y.push(X.bottomP,F.bottomN,K.bottomN),y.push(X.bottomP,K.bottomN,te.bottomP),F=X,K=te;else if(Y>ne){let me=Y/ne,Oe=0;for(let He=1;He<Y;He++)X=this.buildBevelVert(v,j,(J+He)%z,He/(Y-1)),y.push(F.topN,X.topP,K.topN),y.push(X.bottomP,F.bottomN,K.bottomN),F=X,He>(Oe+1)*me&&(Oe++,te=this.buildBevelVert(v,g,(E+Oe)%R,Oe/(ne-1)),y.push(K.topN,X.topP,te.topP),y.push(X.bottomP,K.bottomN,te.bottomP),K=te)}else{let me=ne/Y,Oe=0;for(let He=1;He<ne;He++)te=this.buildBevelVert(v,g,(E+He)%R,He/(ne-1)),y.push(K.topN,X.topP,te.topP),y.push(X.bottomP,K.bottomN,te.bottomP),K=te,He>(Oe+1)*me&&(Oe++,X=this.buildBevelVert(v,j,(J+Oe)%z,Oe/(Y-1)),y.push(F.topN,X.topP,K.topN),y.push(X.bottomP,F.bottomN,K.bottomN),F=X)}J=(J+Y)%z,E=(E+ne)%R,q=(q+1)%U}while(q!==H)}{let A=oe[0];for(let j=0,g=A.boundary.vertexCount;j<g;j++){let z=this.buildBevelVert(v,A,j),R=this.buildBevelVert(v,A,(j+1)%g);y.push(R.topP,z.topN,z.bottomN),y.push(R.topP,z.bottomN,R.bottomP)}}if(T){let A=[];for(let j=y.length-1;j>=xe+2;j-=3){let g=y[j-2],z=y[j-1],R=y[j-0];A.push(R,z,g)}y.splice(xe,y.length-xe,...A)}if(T){let A=[];for(let j=oe[oe.length-1].boundary.vertices.length-1;j>=1;j-=2){let g=oe[oe.length-1].boundary.vertices[j-1],z=oe[oe.length-1].boundary.vertices[j-0];A.push(g,z)}N.push(A)}if(!T){let A=oe[oe.length-1],j=wo({windingRule:oe.length>1?$e.POSITIVE:$e.ODD,elementType:st.POLYGONS,vertexSize:2,strict:!0,contours:[A.insetPoints,...N]});if(!j)throw new Error("Error generating geometry for surface");for(let g=0;g<j.elementCount*3;g+=3){let z=this.buildSurfaceVert(j,j.elements[g+0]),R=this.buildSurfaceVert(j,j.elements[g+1]),U=this.buildSurfaceVert(j,j.elements[g+2]);y.push(z.top,R.top,U.top),y.push(U.bottom,R.bottom,z.bottom)}}this.vertexCache={}}this._buffer.shrink();let L=new Fs(Uint32Array.from(y),1),w=new Fs(this._buffer.positions,3),B=new Fs(this._buffer.normals,3),S=new Fs(this._buffer.uvs,2);w.needsUpdate=!0,B.needsUpdate=!0,S.needsUpdate=!0,L.needsUpdate=!0,this.setAttribute("position",w),this.setAttribute("normal",B),this.setAttribute("uv",S),this.setIndex(L)}buildSurfaceVert(e,t){let r=t.toString();if(r in this.vertexCache)return this.vertexCache[r];let o=e.vertices[t*2+0],n=e.vertices[t*2+1],s=(o-this._minX)/this._width,a=(n-this._minY)/this._height,l=this._buffer.get(2),c=l*3,d=l*2,p={top:l+0,bottom:l+1};return this._buffer.positions[c+0]=o,this._buffer.positions[c+1]=n,this._buffer.positions[c+2]=this._depth,this._buffer.normals[c+0]=0,this._buffer.normals[c+1]=0,this._buffer.normals[c+2]=1,this._buffer.uvs[d+0]=s,this._buffer.uvs[d+1]=a,this._buffer.positions[c+3]=o,this._buffer.positions[c+4]=n,this._buffer.positions[c+5]=0,this._buffer.normals[c+3]=0,this._buffer.normals[c+4]=0,this._buffer.normals[c+5]=-1,this._buffer.uvs[d+2]=s,this._buffer.uvs[d+3]=a,this.vertexCache[r]=p,p}buildBevelVert(e,t,r,o=1){let n=`${t.bevelI}:${r}`;if(n in this.vertexCache)return this.vertexCache[n];let[s,a]=t.boundary.vertexIndices[r],l,c,d,p;s!==a?(c=s,l=a,p=!1,d=e.continuous[c]&&e.continuous[l]):(l=s,c=(l-1+e.count)%e.count,p=e.concave[l]&&t.bevelI>0,d=e.continuous[l]||p);let u=Math.cos(t.angle),f=Math.sin(t.angle),m=r*2,x=l*2,y=c*2,N=t.boundary.vertices[m+0],L=t.boundary.vertices[m+1],w=(1-f)*this._bevelSize,B=(N-this._minX)/this._width,S=(L-this._minY)/this._height,_=e.normals[x+0],T=e.normals[x+1],h=e.normals[y+0],I=e.normals[y+1];if(p){let Z=h-_,V=I-T;_=_+Z*(1-o),T=T+V*(1-o);let ie=Math.sqrt(_*_+T*T);_/=ie,T/=ie}let b=this._buffer.get(d?2:4),P=b*3,v=b*2,D={i:r,fi:l,topP:b+0,topN:b+0,bottomP:b+1,bottomN:b+1};return this._buffer.positions[P+0]=N,this._buffer.positions[P+1]=L,this._buffer.positions[P+2]=this._depth-w,this._buffer.normals[P+0]=_*u,this._buffer.normals[P+1]=T*u,this._buffer.normals[P+2]=f,this._buffer.uvs[v+0]=B,this._buffer.uvs[v+1]=S,this._buffer.positions[P+3]=N,this._buffer.positions[P+4]=L,this._buffer.positions[P+5]=w,this._buffer.normals[P+3]=_*u,this._buffer.normals[P+4]=T*u,this._buffer.normals[P+5]=-f,this._buffer.uvs[v+2]=S,this._buffer.uvs[v+3]=B,d||(b+=2,P+=6,v+=4,D.topP=b+0,D.bottomP=b+1,this._buffer.positions[P+0]=N,this._buffer.positions[P+1]=L,this._buffer.positions[P+2]=this._depth-w,this._buffer.normals[P+0]=h*u,this._buffer.normals[P+1]=I*u,this._buffer.normals[P+2]=f,this._buffer.uvs[v+0]=B,this._buffer.uvs[v+1]=S,this._buffer.positions[P+3]=N,this._buffer.positions[P+4]=L,this._buffer.positions[P+5]=w,this._buffer.normals[P+3]=h*u,this._buffer.normals[P+4]=I*u,this._buffer.normals[P+5]=-f,this._buffer.uvs[v+2]=S,this._buffer.uvs[v+3]=B),this.vertexCache[n]=D,D}clone(){let e=new qi(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=yo(this.userData),e}};var mt=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,e){var c,d,p,u,f,m,x;let t=Object.assign({},(c=e==null?void 0:e.parameters)!=null?c:{width:100,subdivisions:40,roundness:0,extrudeDepth:0,surfaceMaxCount:100,extrudeBevelSize:0,extrudeBevelSegments:3},i.parameters),r=Math.abs(t.width),o=Math.abs((d=t.height)!=null?d:t.width),n=Math.abs(t.depth!==void 0&&t.depth===0&&t.extrudeDepth>0?t.extrudeDepth:(p=t.depth)!=null?p:0),s=(u=i.shape)!=null?u:e==null?void 0:e.shape,a=(f=s==null?void 0:s.roundness)!=null?f:t.roundness;s!==void 0&&(s instanceof Pe?(s.width!==r||s.height!==o)&&s.applySize(r,o):s=new Pe(r,o).fromJSON(s),((m=i.parameters)==null?void 0:m.roundness)!==void 0&&((x=i.parameters)==null?void 0:x.roundness)>0&&s.update(!1));let l=s!=null?s:new Pe(r,o);return{parameters:Object.assign(t,{width:r,height:o,depth:n,extrudeDepth:n,roundness:a}),shape:l}}static build(i){let{extrudeDepth:e,extrudeBevelSize:t,extrudeBevelSegments:r,subdivisions:o,roundness:n,surfaceMaxCount:s}=i.parameters;i.shape.roundness=n;let a;return e<=0?a=new No(i.shape,o,s):a=new qi(i.shape,e,t,o,r),Object.assign(a,{userData:$(O({},i),{type:"VectorGeometry"})})}};import{MathUtils as qu,Vector2 as Wu}from"three";var $u=Math.PI*2,Ju=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,e){var o,n,s;let t=Object.assign({},(o=e==null?void 0:e.parameters)!=null?o:{width:100,depth:0,spikes:64,angle:360,innerRadius:0,extrudeDepth:0,extrudeBevelSize:0,extrudeBevelSegments:1,surfaceMaxCount:1e3},i.parameters);return{shape:i.shape&&i.shape instanceof Pe?i.shape:new Pe,parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs((n=t.height)!=null?n:t.width),depth:Math.abs(t.depth!==void 0&&t.depth===0&&t.extrudeDepth>0?t.extrudeDepth:(s=t.depth)!=null?s:0)})}}static build(i){let{width:e,height:t,spikes:r,angle:o,innerRadius:n,depth:s,extrudeBevelSize:a,extrudeBevelSegments:l,surfaceMaxCount:c}=i.parameters,d=i.shape,p=e*.5,u=t*.5,f=Sv(d,p,u,o*Math.PI/180,r,n);d.isClosed=!0,d.update();let m=mt.create({shape:d,parameters:{subdivisions:f,surfaceMaxCount:c,depth:s,extrudeBevelSize:a,extrudeBevelSegments:l}});return Object.assign(m,{userData:$(O({},i),{type:"EllipseGeometry"})})}};function Sv(i,e,t,r,o,n){if(r>=$u)return o>30||o%4==0?(Nv(i,e,t,n),Math.round(o/4)):Ku(i,r,o,e,t,n);let s={x:0,y:t},a=r+Math.PI*.5,l={x:Math.cos(a)*e,y:Math.sin(a)*t},c=Ru({px:s.x,py:s.y,cx:l.x,cy:l.y,rx:e,ry:t,largeArcFlag:r>Math.PI,sweepFlag:!0});return o>30||o%c.length==0?wv(i,s.x,s.y,c,o,e,t,n):Ku(i,r,o,e,t,n)}function wv(i,e,t,r,o,n,s,a){let l=Math.round(o/r.length);i.addPoint(ci(e,t));for(let c=0,d=r.length;c<d;c++){let p=r[c],u=i.points[c],f=ci(p.x,p.y);u.controls[1].position.set(p.x1,p.y1),f.controls[0].position.set(p.x2,p.y2),i.addPoint(f)}return a>0?Xu(i,n,s,a):i.addPoint(ci(0,0)),l}function Ku(i,e,t,r,o,n){let s=-e/t;for(let a=0;a<=t;a++){let l=s*a,c=Math.sin(l)*r,d=Math.cos(l)*o;i.addPoint(ci(c,d))}return e<$u?n>0?Xu(i,r,o,n):i.addPoint(ci(0,0)):(i.removePoint(i.points[i.points.length-1]),n>0&&Zu(i,r,o,n)),1}function Nv(i,e,t,r=0,o=0,n=0){let s=.5522847498,a=e*s,l=t*s;i.addPoint(Rs(o-e,n,o-e,n-l,o-e,n+l)),i.addPoint(Rs(o,n+t,o-a,n+t,o+a,n+t)),i.addPoint(Rs(o+e,n,o+e,n+l,o+e,n-l)),i.addPoint(Rs(o,n-t,o+a,n-t,o-a,n-t)),r>0&&Zu(i,e,t,r)}function ci(i,e){return new br(qu.generateUUID(),new Wu(i,e))}function Rs(i,e,t,r,o,n){let s=ci(i,e);return s.controls[0].position.set(t,r),s.controls[1].position.set(o,n),s}function Xu(i,e,t,r){Qu(i,e,t,r).forEach(n=>i.addPoint(n))}function Zu(i,e,t,r){let o=Qu(i,e,t,r),n=new Pe;o.forEach(s=>n.addPoint(s)),n.isClosed=!0,i.shapeHoles.push(n)}function Qu(i,e,t,r){let o=r*e/100,n=o*(Math.abs(t)/Math.abs(e)),s=new Wu(o/e,n/t),a=i.points.map(l=>{let c=l.clone();return c.uuid=qu.generateUUID(),c}).reverse();return a.forEach(l=>{l.position.multiply(s);let c=l.controls[0].position.clone().multiply(s),d=l.controls[1].position.clone().multiply(s);l.controls[0].position.copy(d),l.controls[1].position.copy(c)}),a}import{BufferGeometry as Cv,Float32BufferAttribute as xl,Vector3 as Yu}from"three";var eh=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,e){var a,l,c;let t=Object.assign({},(a=e==null?void 0:e.parameters)!=null?a:{width:100,revolutions:2,segments:40,pathRadius:10,pathType:0,pathSegments:30,cornerRadius:30,cornerSegments:4},i.parameters),r=Math.abs(t.width),o=Math.abs((l=t.height)!=null?l:r),n=Math.abs((c=t.depth)!=null?c:r),s=Math.abs(Math.min(r,n))/2;return{parameters:Object.assign(t,{width:r,height:o,depth:n,radius:s,segments:Math.round(t.segments),pathSegments:Math.round(t.pathSegments),cornerSegments:Math.round(t.cornerSegments)})}}static build(i){let{width:e,height:t,depth:r,radius:o,revolutions:n,segments:s,pathRadius:a,pathType:l,pathSegments:c,cornerRadius:d,cornerSegments:p}=i.parameters,u=new Vs(!1,e,t,r,o,n,s,a,l,c,d,p);return Object.assign(u,{userData:$(O({},i),{type:"HelixGeometry"})})}},Vs=class extends Cv{constructor(e=!0,t=1,r=1,o=1,n=1,s=1,a=1,l=1,c=1,d=1,p=1,u=1){super();let f=e&&s===1;f&&(u=0),p>100&&(p=100);let m=()=>new Yu,x=new Yu,y=m(),N=m(),L=m(),w,B,S,_,T,h,I,b,P=m(),v=m(),D=m(),Z=m(),V=m(),ie=m(),oe=m(),ge=m(),xe=r-2*l+.001,A=xe/s,j=Math.ceil(a*s),g=j+1,z=xe/j,R=-xe/2,U=d+1,q=2*Math.PI/d,W=Math.PI/2/u,J=.01,E=Math.min((1-p/100)*l,l-J),H=l-E,k=0,se=2,F=u*se+se,K=U*F/se,X=K+U*g,te=U*(g+F),[he,Y,ne]=[3,3,2].map(qe=>Array(te*qe).fill(0)),Se=[],me=n-l;function Oe(qe,bt){let Et=Math.PI/2;h=bt*z,b=2*Math.PI*(h%A)/A+Et,h+=R,I=Math.sin(b)*me,T=Math.cos(b)*me,e?qe.set(T,I,h):qe.set(T,h,I)}Oe(x,-1e-10),Oe(y,0),P.copy(x),Oe(x,1);let He=x.distanceTo(y),rt=H+E,pt=He*j+2*rt,zt=E,Tr=pt-rt;for(let qe=0;qe<=j;qe++){Oe(N,qe),ge.subVectors(N,P).normalize(),P.copy(N),ie.copy(N).setComponent(+e+1,0).normalize(),oe.crossVectors(ge,ie).normalize();let bt=qe===0,Et=qe===j,bn=bt?3*Math.PI/2:W,vn=bt?zt:Tr,Sn=bt?U:X,wn=bt?0:te-U,Nn=ge.clone().multiplyScalar(bt?-H:H).add(N),Cn=ge.clone().multiplyScalar(bt?-1:1).normalize();for(let $t=0;$t<U;$t++){let Li=$t*q;if(v.addVectors(x.copy(ie).multiplyScalar(l*Math.cos(Li)),y.copy(oe).multiplyScalar(l*Math.sin(Li))),D.copy(v).normalize(),bt||Et){f||(k=wn+$t,[0,1,2].forEach(ut=>{he[k*3+ut]=Nn.getComponent(ut),Y[k*3+ut]=Cn.getComponent(ut)}),ne[k*2]=+Et,ne[k*2+1]=$t/d),y.copy(D).multiplyScalar(E),L.addVectors(N,y);for(let ut=0;ut<u;ut++){let jo=ut*W+bn;Z.addVectors(x.copy(ge).multiplyScalar(H*Math.sin(jo)),y.copy(D).multiplyScalar(H*Math.cos(jo))),V.copy(Z).normalize(),y.addVectors(L,Z),Z.normalize(),k=Sn+ut*U+$t,[0,1,2].forEach(ye=>{he[k*3+ye]=y.getComponent(ye),Y[k*3+ye]=V.getComponent(ye)});let Ln=+bt+Math.sin(jo);ne[k*2]=(vn+H*Ln)/pt,ne[k*2+1]=$t/d}}y.addVectors(N,v),k=K+qe*U+$t,[0,1,2].forEach(ut=>{he[k*3+ut]=y.getComponent(ut),Y[k*3+ut]=D.getComponent(ut)}),ne[k*2]=(rt+qe*He)/pt,ne[k*2+1]=$t/d}}let xt=g+2*u+se,Ir=1,[uo,ho]=f?[Ir,Ir+g-1]:[0,xt-1];for(let qe=uo;qe<=ho-1;qe++){let bt=f&&qe===ho-1;for(let Et=0;Et<U-1;Et++)w=qe*U+Et,B=w+1,S=(bt?Et:w)+U,_=(bt?Et+1:B)+U,qe===0?Se.push(B,_,S):qe===xt-2?Se.push(w,B,S):Se.push(w,B,S,B,_,S)}this.setIndex(Se),this.setAttribute("position",new xl(he,3)),this.setAttribute("normal",new xl(Y,3)),this.setAttribute("uv",new xl(ne,2))}};import{IcosahedronBufferGeometry as Lv}from"three";var th=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,e){var r,o,n;let t=Object.assign({},(r=e==null?void 0:e.parameters)!=null?r:{width:100,detail:0,corner:0,cornerSides:4},i.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs((o=t.height)!=null?o:t.width),depth:Math.abs((n=t.depth)!=null?n:t.width)})}}static build(i){let{width:e,height:t,depth:r,detail:o,corner:n,cornerSides:s}=i.parameters,a=o===0&&n!==0?new Us(e*.5,n,s):new Lv(e*.5,o);return a.scale(1,t/e,r/e),Object.assign(a,{userData:$(O({},i),{type:"IcosahedronGeometry"})})}},Us=class extends So{constructor(e=1,t=.2,r=4){let o=(1+Math.sqrt(5))/2,n=[-1,o,0,1,o,0,-1,-o,0,1,-o,0,0,-1,o,0,1,o,0,-1,-o,0,1,-o,o,0,-1,o,0,1,-o,0,-1,-o,0,1],s=[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1],a="IcosahedronGeometry";super(n,s,a,e,t,r);this.type=a}static fromJSON(e){return new Us(e.radius,e.corner,e.cornerSides)}};import{LatheBufferGeometry as Tv,Shape as Iv}from"three";var rh=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,e){var r,o,n,s,a;((o=(r=i.parameters)==null?void 0:r.points)!=null?o:[]).forEach(l=>{Array.isArray(l)&&(l.x=l[0],l.y=l[1])});let t=Object.assign({},(n=e==null?void 0:e.parameters)!=null?n:{width:100,segments:64,verticalSegments:64,points:[{x:0,y:-50,id:0},{x:50,y:-50,id:1},{x:50,y:50,id:2},{x:0,y:50,id:3}]},i.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs((s=t.height)!=null?s:t.width),depth:Math.abs((a=t.depth)!=null?a:t.width)})}}static build(i){let{points:e,segments:t,verticalSegments:r}=i.parameters,o=new Iv;o.moveTo(e[0].x,e[0].y),o.bezierCurveTo(e[1].x,e[1].y,e[2].x,e[2].y,e[3].x,e[3].y);let n=new Tv(o.extractPoints(r).shape,t);return n.rotateZ(Math.PI),Object.assign(n,{userData:$(O({},i),{type:"LatheGeometry"})})}};import{BufferGeometry as ih,BufferGeometryLoader as Dv,Vector3 as Bv,BoxBufferGeometry as nh}from"three";import{BufferGeometry as Mv,Vector2 as bl,Vector3 as oh}from"three";import{Geometry as Pv,Face3 as Ov}from"three/examples/jsm/deprecated/Geometry.js";var Av=["a","b","c"];function jv(i,e){switch(e){case"c":return i.c;case"b":return i.b;case"a":default:return i.a}}function vl(i,e,t){let r=Math.min(i,e),o=Math.max(i,e),n=r+"_"+o;return t.get(n)}function Sl(i,e,t,r,o,n){let s=Math.min(i,e),a=Math.max(i,e),l=s+"_"+a,c;if(r.has(l))c=r.get(l);else{let d=t[s],p=t[a];c={a:d,b:p,newEdge:null,faces:[]},r.set(l,c)}c.faces.push(o),n[i].edges.push(c),n[e].edges.push(c)}function _v(i,e,t,r){let o,n,s;for(o=0,n=i.length;o<n;o++)t[o]={edges:[]};for(o=0,n=e.length;o<n;o++)s=e[o],Sl(s.a,s.b,i,r,s,t),Sl(s.b,s.c,i,r,s,t),Sl(s.c,s.a,i,r,s,t)}function ks(i,e,t,r,o){i.push(new Ov(e,t,r,void 0,void 0,o))}function di(i,e){return Math.abs(e-i)/2+Math.min(i,e)}function Hs(i,e,t,r){i.push([e.clone(),t.clone(),r.clone()])}var wl=class{constructor(e=1){this.subdivisions=e}modify(e){e instanceof Mv?e=new Pv().fromBufferGeometry(e):e=e.clone(),e.mergeVertices();let t=this.subdivisions;for(;t-- >0;)this._smooth(e);return e.computeFaceNormals(),e.computeVertexNormals(),e}_smooth(e){let t=new oh,r,o,n,s,a,l=e.vertices,c=e.faces,d=e.faceVertexUvs[0],p=d!==void 0&&d.length>0,u=[],f=new Map;_v(l,c,u,f);let m=[],x,y,N,L,w,B,S;for(let J of Array.from(f.keys())){for(y=f.get(J),N=new oh,w=3/8,B=1/8,S=y.faces.length,S!=2&&(w=.5,B=0,S!=1),N.addVectors(y.a,y.b).multiplyScalar(w),t.set(0,0,0),s=0;s<S;s++){for(L=y.faces[s],a=0;a<3&&(x=l[jv(L,Av[a])],!(x!==y.a&&x!==y.b));a++);x&&t.add(x)}t.multiplyScalar(B),N.add(t),y.newEdge=m.length,m.push(N)}let _,T,h,I,b,P,v,D=[];for(o=0,n=l.length;o<n;o++){for(P=l[o],b=u[o].edges,r=b.length,r==3?_=3/16:r>3&&(_=3/(8*r)),T=1-r*Number(_),h=_,r<=2&&(r==2?(T=3/4,h=1/8):r==1||r==0),v=P.clone().multiplyScalar(T),t.set(0,0,0),s=0;s<r;s++)I=b[s],x=I.a!==P?I.a:I.b,t.add(x);t.multiplyScalar(Number(h)),v.add(t),D.push(v)}let Z=D.concat(m),V=D.length,ie,oe,ge,xe=[],A=[],j,g,z,R,U=new bl,q=new bl,W=new bl;for(o=0,n=c.length;o<n;o++)L=c[o],ie=Number(vl(L.a,L.b,f).newEdge)+V,oe=Number(vl(L.b,L.c,f).newEdge)+V,ge=Number(vl(L.c,L.a,f).newEdge)+V,ks(xe,ie,oe,ge,L.materialIndex),ks(xe,L.a,ie,ge,L.materialIndex),ks(xe,L.b,oe,ie,L.materialIndex),ks(xe,L.c,ge,oe,L.materialIndex),p&&(j=d[o],g=j[0],z=j[1],R=j[2],U.set(di(g.x,z.x),di(g.y,z.y)),q.set(di(z.x,R.x),di(z.y,R.y)),W.set(di(g.x,R.x),di(g.y,R.y)),Hs(A,U,q,W),Hs(A,g,U,W),Hs(A,z,q,U),Hs(A,R,W,q));e.vertices=Z,e.faces=xe,p&&(e.faceVertexUvs[0]=A)}};var at=new Bv,qs=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,e){var n,s;let t=(s=(n=i.geometry)!=null?n:e==null?void 0:e.geometry)!=null?s:new ih().copy(new nh(100,100,100)),r;e===void 0?(t.computeBoundingBox(),t.boundingBox.getSize(at),r={width:at.x,height:at.y,depth:at.z,subdivisions:0}):r=e.parameters;let o=O(O({},r),i.parameters);return{parameters:{width:Math.abs(o.width),height:Math.abs(o.height),depth:Math.abs(o.depth),subdivisions:Math.abs(o.subdivisions)},geometry:t}}static build(i){var l;let{width:e,height:t,depth:r,subdivisions:o}=i.parameters,n=(l=i.geometry)!=null?l:new ih().copy(new nh(100,100,100)),s=n.userData.parameters;s===void 0?(n.computeBoundingBox(),n.boundingBox.getSize(at)):at.set(s.width,s.height,s.depth),(e!==at.x||t!==at.y||r!==at.z)&&n.scale(at.x===0?1:e/at.x,at.y===0?1:t/at.y,at.z===0?1:r/at.z);let a=n.originalGeometry;return o>0?(a===void 0||(s==null?void 0:s.subdivisions)!==o)&&(a===void 0&&(a=n),n=new wl(o).modify(a).toBufferGeometry()):(a!==void 0&&(n=a),a=void 0,n.getAttribute("normal")===void 0&&n.computeVertexNormals()),a!==void 0&&Object.assign(n,{originalGeometry:a}),delete i.geometry,Object.assign(n,{userData:$(O({},i),{type:"NonParametricGeometry"})})}static loadFromUrl(i,e,t){new Dv(t).load(i,o=>{let n=this.normalizeInputs({geometry:o});o.boundingBox.getSize(at);let s=100/at.x;Object.assign(n.parameters,{width:100,height:at.y*s,depth:at.z*s}),e(this.build(n))})}};var sh=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,e){var o,n,s,a;let t=Object.assign({},(o=e==null?void 0:e.parameters)!=null?o:{width:100,depth:0,spikes:5,cornerRadius:0,extrudeDepth:0,extrudeBevelSize:0,extrudeBevelSegments:3},i.parameters);return{shape:i.shape&&i.shape instanceof Pe?i.shape:new Pe,parameters:Object.assign(t,{surfaceMaxCount:((n=t.surfaceMaxCount)!=null?n:t.cornerRadius>0)?1e3:100,width:Math.abs(t.width),height:Math.abs((s=t.height)!=null?s:t.width),depth:Math.abs(t.depth!==void 0&&t.depth===0&&t.extrudeDepth>0?t.extrudeDepth:(a=t.depth)!=null?a:0)})}}static build(i){let{width:e,height:t,spikes:r,cornerRadius:o,depth:n,extrudeBevelSize:s,extrudeBevelSegments:a,surfaceMaxCount:l}=i.parameters,c=i.shape,d=e*.5,p=t*.5,u=0,f=0,m=2*Math.PI/r;for(let y=0;y<r;y++){let N=m*y,L=u+Math.sin(N)*d,w=f+Math.cos(N)*p;c.addPoint(c.createPoint(L,w))}c.isClosed=!0;for(let y=0,N=c.points.length;y<N;y++)c.points[y].roundness=o;c.roundness=o,c.update();let x=mt.create({shape:c,parameters:{surfaceMaxCount:l,roundness:o,depth:n,extrudeBevelSize:s,extrudeBevelSegments:a}});return Object.assign(x,{userData:$(O({},i),{type:"PolygonGeometry"})})}};import{BufferGeometry as Gv,Float32BufferAttribute as Nl,Vector2 as vr,Vector3 as dt}from"three";var ah=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,e){var r,o,n;let t=Object.assign({},(r=e==null?void 0:e.parameters)!=null?r:{width:100,radialSegments:4,heightSegments:1,cornerRadius:0,cornerSegments:8,openEnded:!1},i.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs((o=t.height)!=null?o:t.width),depth:Math.abs((n=t.depth)!=null?n:t.width)})}}static build(i){let{width:e,height:t,depth:r,radialSegments:o,heightSegments:n,openEnded:s,cornerRadius:a,cornerSegments:l}=i.parameters,c=new lh(e*.5,t,o,n,s,a,l);return c.scale(1,1,r/e),Object.assign(c,{userData:$(O({},i),{type:"PyramidGeometry"})})}};function Wi(i,e,t){t.x=i.x*e.x,t.y=i.y,t.z=i.x*e.y}function Cl(i,e,t,r,o,n){let s=e.clone().sub(i),a=t.clone().sub(i),l=s.angleTo(a);if(s.normalize(),a.normalize(),r===o){let c=s.add(a).normalize();n.copy(i).addScaledVector(c,r/Math.sin(l/2))}else{let c=s.angleTo(a);n.copy(i),n.addScaledVector(s,o/Math.sin(c)),n.addScaledVector(a,r/Math.sin(c))}}function zv(i,e,t){let r=i.clone().sub(e),o=t.clone().sub(e);return r.projectOnVector(o),r.add(e)}var lh=class extends Gv{constructor(e=.5,t=1,r=4,o=1,n=!1,s=0,a=4){super();r=Math.floor(Math.max(3,r)),o=Math.floor(o),a=Math.floor(a);let l=[],c=[],d=[],p=[],u=0,f=t/2,m=Math.PI/r,x=e*Math.cos(Math.PI/r),y=2*Math.PI/r,N=(r-2)*Math.PI/r,L=Math.PI-N,w=new dt(0,-f,0),B=new dt(0,f,0),S=new vr(e,-f),_=new vr(x,-f),T=new vr(0,B.y).sub(_),h=new vr(0,B.y).sub(S),I=new vr(T.y,-T.x).normalize(),b=new vr(h.y,-h.x).normalize(),v=e*Math.cos(Math.PI/r)*Math.tan((Math.PI-T.angle())/2)-1e-8;s=Math.min(s,v);let D;{let A=new dt(I.x,I.y,0),j=new dt(Math.cos(y)*A.x,A.y,Math.sin(y)*A.x);D=A.angleTo(j)}let Z=s/Math.tan((Math.PI-T.angle())/2),V=s/Math.tan((Math.PI-D)/2),ie=new dt;if(!n){c.push(w.x,w.y,w.z),d.push(0,-1,0),p.push(0,0);let A=u++,j=[],g=S.clone(),z=Z/Math.cos(Math.PI/r);g.x-=z;for(let R=0;R<r;R++){let U=R/r*Math.PI*2+m,q=new vr(Math.sin(U),Math.cos(U));Wi(g,q,ie),c.push(ie.x,ie.y,ie.z),d.push(0,-1,0),p.push(0,0),j.push(u++)}for(let R=0;R<j.length;R++)l.push(j[R],A,j[(R+1)%j.length])}let oe=[];{let A=new dt,j=new dt,g=new dt,z=new dt,R=new dt,U=new dt;for(let q=0;q<r;q++){let W=q/r*Math.PI*2+m,J=(q+.5)/r*Math.PI*2+m,E=(q+1)/r*Math.PI*2+m,H=new vr(Math.sin(W),Math.cos(W)),k=new vr(Math.sin(J),Math.cos(J)),se=new vr(Math.sin(E),Math.cos(E));Wi(S,H,j),Wi(S,se,g),Wi(I,k,A),Cl(B,j,g,V,V,z),c.push(z.x,z.y,z.z),Cl(j,B,g,V,Z,R),c.push(R.x,R.y,R.z),Cl(g,j,B,Z,V,U),c.push(U.x,U.y,U.z),d.push(A.x,A.y,A.z),d.push(A.x,A.y,A.z),d.push(A.x,A.y,A.z),p.push(0,0),p.push(0,0),p.push(0,0);let F=u++,K=u++,X=u++;if(l.push(F,K,X),s>0){{let Y=j.clone().add(g).multiplyScalar(.5),ne=B.clone().sub(Y).normalize(),me=w.clone().sub(Y).normalize().add(ne).normalize().multiplyScalar(-1),Oe=U.clone().sub(R);ge(Y,Oe,me,T.angle())}let te,he;{let Y=new dt;Wi(b,se,Y);let ne=U.clone().add(z).multiplyScalar(.5);ne=zv(ne,g,B);let Se=U.clone().sub(z);[te,he]=ge(ne,Se,Y,D,z.y)}{let Y=te,ne=Y.clone().setY(0).normalize(),Se=new dt(0,-1,0),me=ne.clone().cross(Se);xe(Y,ne,Se,me)}oe.concat(he);{let Y=T.angle(),ne=Math.PI-Y,Se=B.clone();Se.y-=s/Math.sin(Y-Math.PI/2);let me=new dt,Oe=[];for(let rt=0;rt<a;rt++){let pt=[],zt=Math.PI/2-ne*rt/a,Tr=Math.cos(zt),xt=Math.sin(zt),Ir=J;for(let uo=0;uo<=rt;uo++){let ho=Math.cos(Ir),qe=Math.sin(Ir);A.x=Tr*qe,A.y=xt,A.z=Tr*ho,me.copy(Se).addScaledVector(A,s),c.push(me.x,me.y,me.z),d.push(A.x,A.y,A.z),p.push(0,0),pt.push(u++),Ir+=Math.PI*2/rt/r}Oe.push(pt)}he.reverse(),Oe.push(he);let He=Oe.length-1;for(let rt=0;rt<He;rt++){let pt=Oe[rt],zt=Oe[rt+1],Tr=pt.length-1;l.push(zt[1],pt[0],zt[0]);for(let xt=1;xt<=Tr;xt++)l.push(pt[xt],pt[xt-1],zt[xt]),l.push(zt[xt+1],pt[xt],zt[xt])}}}}}this.setIndex(l),this.setAttribute("position",new Nl(c,3)),this.setAttribute("normal",new Nl(d,3)),this.setAttribute("uv",new Nl(p,2));function ge(A,j,g,z,R){let U=-z/2,q=(Math.PI-z)/2,W=j.clone().normalize().cross(g);A.addScaledVector(g,-s/Math.sin(q));let J=new dt,E=new dt,H=1,k=u,se=[];for(let F=0;F<=a;F++){let K=U+F/a*z;E.set(0,0,0),E.addScaledVector(W,Math.sin(K)),E.addScaledVector(g,Math.cos(K));for(let X=0;X<=H;X++){let te=X/H-.5;if(J.copy(A),J.addScaledVector(j,te),J.addScaledVector(E,s),R!=null){let he=Math.max(0,J.y-R);J.addScaledVector(j,-he/j.y)}c.push(J.x,J.y,J.z),d.push(E.x,E.y,E.z),p.push(0,0),X===0&&se.push(u),u++}}for(let F=0;F<a;F++)for(let K=0;K<H;K++){let X=k+K+(H+1)*F,te=X+(H+1),he=te+1,Y=X+1;l.push(X,te,Y),l.push(te,he,Y)}return[A.clone().addScaledVector(j,.5),se]}function xe(A,j,g,z){let R=Math.PI/2,U=h.angle()-R,q=[],W=new dt,J=new dt;for(let H=0;H<=a;H++){let k=[],se=H/a;for(let F=0;F<=H;F++){let X=((H?F/H:0)-.5)*L,te=Math.cos(X),he=Math.sin(X),Y=Math.atan(Math.tan(U)*te),ne=(R+Y)*se,Se=Math.cos(ne),me=Math.sin(ne);W.set(0,0,0),W.addScaledVector(j,me*te),W.addScaledVector(g,Se),W.addScaledVector(z,me*he),J.copy(A).addScaledVector(W,s),c.push(J.x,J.y,J.z),d.push(W.x,W.y,W.z),p.push(0,0),k.push(u++)}q.push(k)}let E=q.length-1;for(let H=0;H<E;H++){let k=q[H],se=q[H+1],F=k.length-1;l.push(k[0],se[1],se[0]);for(let K=1;K<=F;K++)l.push(k[K-1],k[K],se[K]),l.push(k[K],se[K+1],se[K])}}}};var Ws=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,e){var s,a,l,c,d;let t=Object.assign({},(s=e==null?void 0:e.parameters)!=null?s:{width:100,depth:0,cornerRadius:[0,0,0,0],cornerType:1,extrudeDepth:0,extrudeBevelSize:0,extrudeBevelSegments:1},i.parameters),r=Object.assign((a=e==null?void 0:e.ui)!=null?a:{enabledIndieCorners:!1},i.ui),o=t.cornerRadius.reduce((p,u)=>p+u,0);return{shape:i.shape&&i.shape instanceof Pe?i.shape:new Pe,parameters:Object.assign(t,{surfaceMaxCount:((l=t.surfaceMaxCount)!=null?l:o>0)?1e3:100,width:Math.abs(t.width),height:Math.abs((c=t.height)!=null?c:t.width),depth:Math.abs(t.depth!==void 0&&t.depth===0&&t.extrudeDepth>0?t.extrudeDepth:(d=t.depth)!=null?d:0)}),ui:r}}static build(i){let e=i.shape,{width:t,height:r,cornerRadius:o,cornerType:n,depth:s,extrudeBevelSize:a,extrudeBevelSegments:l,surfaceMaxCount:c}=i.parameters,d={x:t*.5,y:r*.5},p={x:-d.x,y:-d.y},u={x:d.x,y:d.y};function f(S,_,T){return _>t&&T>r?Math.min(S*t/_,S*r/T):_>t?S*t/_:T>r?S*r/T:S}let m=[];m[0]=o[0]===0?0:f(o[0],o[0]+o[3],o[0]+o[1]),m[1]=o[1]===0?0:f(o[1],o[1]+o[2],o[1]+o[0]),m[2]=o[2]===0?0:f(o[2],o[2]+o[1],o[2]+o[3]),m[3]=o[3]===0?0:f(o[3],o[3]+o[0],o[3]+o[2]);let x=p.x,y=u.x,N=u.y,L=p.y;e.addPoint(e.createPoint(x,N)),e.addPoint(e.createPoint(y,N)),e.addPoint(e.createPoint(y,L)),e.addPoint(e.createPoint(x,L)),e.isClosed=!0;let w=!0;for(let S=0,_=e.points.length;S<_;S++)e.points[S].roundness=m[S],S>0&&m[S]!==m[S-1]&&(w=!1);w&&(e.roundness=m[0]),e.useCubicForRoundedCorners=n!==1,e.update();let B=mt.create({shape:e,parameters:{surfaceMaxCount:c,depth:s,extrudeBevelSize:a,extrudeBevelSegments:l}});return Object.assign(B,{userData:$(O({},i),{type:"RectangleGeometry"})})}};import{SphereBufferGeometry as Ev}from"three";var ch=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,e){var r,o,n;let t=Object.assign({},(r=e==null?void 0:e.parameters)!=null?r:{width:100,widthSegments:64,heightSegments:64,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:Math.PI},i.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs((o=t.height)!=null?o:t.width),depth:Math.abs((n=t.depth)!=null?n:t.width)})}}static build(i){let{width:e=100,height:t=e,depth:r=e,widthSegments:o=64,heightSegments:n=64,phiStart:s,phiLength:a,thetaStart:l,thetaLength:c}=i.parameters,d=new Ev(.5*e,o,n,s,a,l,c);return d.scale(1,t/e,r/e),Object.assign(d,{userData:$(O({},i),{type:"SphereGeometry"})})}};import{PlaneBufferGeometry as Fv}from"three";var dh=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,e){var r,o;let t=Object.assign({},(r=e==null?void 0:e.parameters)!=null?r:{width:100,depth:0,widthSegments:8,heightSegments:8},i.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs((o=t.height)!=null?o:t.width),depth:0})}}static build(i){let{width:e=100,height:t=e,widthSegments:r=8,heightSegments:o=8}=i.parameters,n=new Fv(e,t,r,o);return n.scale(1,1,1),Object.assign(n,{userData:$(O({},i),{type:"PlaneGeometry"})})}};var ph=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,e){var o,n,s,a;let t=Object.assign({},(o=e==null?void 0:e.parameters)!=null?o:{width:100,depth:0,innerRadiusPercent:38.19,spikes:5,cornerRadius:0,angle:360,extrudeDepth:0,extrudeBevelSize:0,extrudeBevelSegments:1},i.parameters);return{shape:i.shape&&i.shape instanceof Pe?i.shape:new Pe,parameters:Object.assign(t,{surfaceMaxCount:((n=t.surfaceMaxCount)!=null?n:t.cornerRadius>0)?1e3:100,width:Math.abs(t.width),height:Math.abs((s=t.height)!=null?s:t.width),depth:Math.abs(t.depth!==void 0&&t.depth===0&&t.extrudeDepth>0?t.extrudeDepth:(a=t.depth)!=null?a:0)})}}static build(i){let{width:e,height:t,innerRadiusPercent:r,spikes:o,cornerRadius:n,angle:s,depth:a,extrudeBevelSize:l,extrudeBevelSegments:c,surfaceMaxCount:d}=i.parameters,p=i.shape,u=e*.5,f=t*.5,m=0,x=0,y=s*Math.PI/360/o,N=Math.PI/2*3*-1,L=u*r/100,w=f*r/100;if(o==3&&r==50){y=2*Math.PI/o;for(let S=0;S<o;S++){let _=y*S,T=m+Math.sin(_)*u,h=x+Math.cos(_)*f;p.addPoint(p.createPoint(T,h))}}else for(let S=0;S<o;S++){let _=m+Math.cos(N)*u,T=x+Math.sin(N)*f;p.addPoint(p.createPoint(_,T)),N+=y,_=m+Math.cos(N)*L,T=x+Math.sin(N)*w,S<=o,p.addPoint(p.createPoint(_,T)),N+=y}p.isClosed=!0;for(let S=0,_=p.points.length;S<_;S++)p.points[S].roundness=n;p.roundness=n,p.update();let B=mt.create({shape:p,parameters:{surfaceMaxCount:d,roundness:n,depth:a,extrudeBevelSize:l,extrudeBevelSegments:c}});return Object.assign(B,{userData:$(O({},i),{type:"StarGeometry"})})}};import{PlaneBufferGeometry as Rv}from"three";var $s=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,e){var r,o,n;let t=Object.assign({},(r=e==null?void 0:e.parameters)!=null?r:{width:100,depth:0},i.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs((o=t.height)!=null?o:t.width),depth:Math.abs((n=t.depth)!=null?n:0)})}}static build(i){let{width:e,height:t}=i.parameters,r=new Rv(e,t);return Object.assign(r,{userData:$(O({},i),{type:"TextFrameGeometry"})})}};var uh=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,e){var s,a,l;let t=Object.assign({},(s=e==null?void 0:e.parameters)!=null?s:{width:100,radialSegments:32,tubularSegments:64,arc:Math.PI*2,cornerRadius:30,cornerSegments:8},i.parameters),r=Math.abs(t.width),o=Math.abs((a=t.height)!=null?a:t.width),n=Math.abs((l=t.depth)!=null?l:t.width*.25);return{parameters:Object.assign(t,{width:r,height:o,depth:n})}}static build(i){let{width:e,height:t,depth:r,radialSegments:o,tubularSegments:n,arc:s,cornerRadius:a,cornerSegments:l}=i.parameters,c=Vv(e,t,r,e*.5,s,n,0,0,o,a,l);return c.scale(1,t/e,1),Object.assign(c,{userData:$(O({},i),{type:"TorusGeometry"})})}};function Vv(i,e,t,r,o,n,s,a,l,c,d){return[e,t]=[t,e],s=e/2,o/=2*Math.PI,o==1&&(c=0),new Vs(!0,i,e,t,r,o,n,s,a,l,c,d)}import{TorusKnotBufferGeometry as Uv}from"three";var hh=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,e){var r,o,n,s;let t=Object.assign({},(r=e==null?void 0:e.parameters)!=null?r:{width:100,tubularSegments:64,radialSegments:32,p:2,q:3},i.parameters);return{parameters:Object.assign(t,{width:Math.abs(t.width),height:Math.abs((o=t.height)!=null?o:t.width),depth:Math.abs((n=t.depth)!=null?n:t.width),tube:(s=t.tube)!=null?s:t.width*.125})}}static build(i){let{width:e,tube:t,tubularSegments:r,radialSegments:o,p:n,q:s}=i.parameters,a=e*.5;a!==t&&(a-=t);let l=new Uv(a,t,r,o,n,s);return Object.assign(l,{userData:$(O({},i),{type:"TorusKnotGeometry"})})}};var mh=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,e){var o,n,s,a;let t=Object.assign({},(o=e==null?void 0:e.parameters)!=null?o:{width:100,depth:0,spikes:5,cornerRadius:0,extrudeDepth:0,extrudeBevelSize:0,extrudeBevelSegments:1,isRect:!1},i.parameters);return{shape:i.shape&&i.shape instanceof Pe?i.shape:new Pe,parameters:Object.assign(t,{surfaceMaxCount:((n=t.surfaceMaxCount)!=null?n:t.cornerRadius>0)?1e3:100,width:Math.abs(t.width),height:Math.abs((s=t.height)!=null?s:t.width*(t.isRect?1:Math.sqrt(3)/2)),depth:Math.abs(t.depth!==void 0&&t.depth===0&&t.extrudeDepth>0?t.extrudeDepth:(a=t.depth)!=null?a:0)})}}static build(i){let{width:e=100,height:t,cornerRadius:r,depth:o,extrudeBevelSize:n,extrudeBevelSegments:s,isRect:a,surfaceMaxCount:l}=i.parameters,c=i.shape,d=e*.5,p=t*.5;a?(c.addPoint(c.createPoint(-d,p)),c.addPoint(c.createPoint(d,-p)),c.addPoint(c.createPoint(-d,-p))):(c.addPoint(c.createPoint(0,p)),c.addPoint(c.createPoint(d,-p)),c.addPoint(c.createPoint(-d,-p))),c.isClosed=!0;for(let f=0,m=c.points.length;f<m;f++)c.points[f].roundness=r;c.roundness=r,c.update();let u=mt.create({shape:c,parameters:{surfaceMaxCount:l,roundness:r,depth:o,extrudeBevelSize:n,extrudeBevelSegments:s}});return Object.assign(u,{userData:$(O({},i),{type:"TriangleGeometry"})})}};var $i={};Hm($i,{addBarycentricAttribute:()=>$v,fixUvs:()=>Kv,loadFromUrl:()=>Jv,resizeGeometry:()=>Wv,roundShapePolygon:()=>qv});import{BufferGeometryLoader as kv,Float32BufferAttribute as Hv,Vector3 as Ll}from"three";var fh=function(i,e){let t=e.x-i.x,r=e.y-i.y,o=Math.sqrt(t*t+r*r),n=t/o,s=r/o,a=Math.atan2(s,n);return{x:t,y:r,len:o,nx:n,ny:s,ang:a}},qv=(i,e,t)=>{let r,o,n,s,a,l,c,d,p,u,f,m,x,y,N=e.length;for(s=e[N-2],i.curves=[],r=1;r<N-1;r++){a=e[r%N],l=e[(r+1)%N];let L=fh(a,s),w=fh(a,l);c=L.nx*w.ny-L.ny*w.nx,d=L.nx*w.nx-L.ny*-w.ny,f=Math.asin(c),p=1,u=!1,d<0?f<0?f=Math.PI+f:(f=Math.PI-f,p=-1,u=!0):f>0&&(p=-1,u=!0),m=f/2,y=Math.abs(Math.cos(m)*t/Math.sin(m)),y>Math.min(L.len/2,w.len/2)?(y=Math.min(L.len/2,w.len/2),x=Math.abs(y*Math.sin(m)/Math.cos(m))):x=t,o=a.x+w.nx*y,n=a.y+w.ny*y,o+=-w.ny*x*p,n+=w.nx*x*p,i.absarc(o,n,x,L.ang+Math.PI/2*p,w.ang-Math.PI/2*p,u),s=a,a=l}i.closePath()},Wv=(i,{width:e,height:t,depth:r})=>{e=Math.abs(e),t=Math.abs(t),r=Math.abs(r);let o=i.userData.parameters,n,s,a;e===0?(e=o.width,n=1):n=e/o.width,t===0?(t=o.height,s=1):s=t/o.height,r===0?(r=o.depth,a=1):a=r/o.depth,i.scale(n,s,a),o.width=e,o.height=t,o.depth=r},$v=(i,e)=>{let t=[new Ll(1,0,0),new Ll(0,1,0),new Ll(0,0,1)],r=i.attributes.position,o=new Float32Array(r.count*3);for(let n=0,s=r.count;n<s;n++)t[n%3].toArray(o,n*3);i.setAttribute(e,new Hv(o,3))},Jv=i=>new Promise(e=>{new kv().load(i,r=>e(r))}),Kv=(i,e,t)=>{let r=i.getAttribute("uv");if(r)for(let o=0;o<r.count;o++){let n=r.getX(o),s=r.getY(o);r.setXY(o,(n+e/2)/e,1-(s-t/2)/t*-1)}};import{BufferGeometry as yh,BufferAttribute as gh,Uint32BufferAttribute as Tl,Float32BufferAttribute as Il,Matrix4 as Zv}from"three";import{mergeVertices as Qv}from"three/examples/jsm/utils/BufferGeometryUtils.js";var Xv,Js=new Promise(i=>{Xv=i});var de;Js.then(i=>{de=i});var xh=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),bh=new Uint32Array([0,1,2,3]),vh=new Uint8Array([4]),kt=class{static build(i,e,t,r,o){let n,s,a;if(i===void 0)n=kt.allocate(o,t),de.set_destination_refinement_level(n,0),s=kt.buildLevel(n,!0,r);else if(i.positionWASM!==void 0){e&&e!==0&&(de.free_bvh(e),de.free_subdivision_surface(e));try{n=kt.allocate(o,void 0,i)}catch(l){console.error(l,i),n=kt.allocate(o,void 0,{positionWASM:xh,indexWASM:bh,verticesPerFaceWASM:vh})}de.set_destination_refinement_level(n,0),s=kt.buildLevel(n,!0,r)}else n=e;if(i!==void 0&&i.subdivisions!==void 0){let l=Yv(i.subdivisions,i.positionWASM.length);de.set_destination_refinement_level(n,l),l>0?a=kt.buildLevel(n,!1,r):a=null}return{subdivPointer:n,originalGeometry:s,subdividedGeometry:a}}static allocate(i,e,t){var S;let r,o,n,s=[],a=[];if(t)t.positionWASM&&t.positionWASM.length>0?(r=t.positionWASM,o=t.indexWASM,n=t.verticesPerFaceWASM):(r=xh,o=bh,n=vh);else{e.deleteAttribute("normal"),e.deleteAttribute("uv");let _=Qv(e);r=_.attributes.position.array;let T=_.getIndex().array,h=T.length;switch(e.userData.type==="TorusGeometry"&&(e==null?void 0:e.userData.parameters.arc)===Math.PI*2&&(e.userData.type="ClosedTorusGeometry"),e.userData.type){case"ClosedTorusGeometry":case"PlaneGeometry":case"TorusKnotGeometry":case"CubeGeometry":o=new Uint32Array(h/3*2),n=new Uint8Array(h/6).fill(4);for(let V=0,ie=0;V<h;V+=6)o[ie++]=T[V],o[ie++]=T[V+1],o[ie++]=T[V+4],o[ie++]=T[V+5];break;case"TorusGeometry":case"SphereGeometry":case"HelixGeometry":case"CylinderGeometry":case"ConeGeometry":let I,b,P;if(e.userData.type==="SphereGeometry")b=e.parameters.heightSegments,I=e.parameters.widthSegments,e.parameters.thetaLength!==Math.PI&&(P=!0);else if(e.userData.type==="CylinderGeometry")b=e.parameters.heightSegments+2,I=e.parameters.radialSegments;else if(e.userData.type==="ConeGeometry")b=e.parameters.heightSegments+1,I=e.parameters.radialSegments;else if(e.userData.type==="TorusGeometry"){let V=e.userData.parameters;b=Math.ceil(V.tubularSegments*V.arc/(2*Math.PI))+2,I=V.radialSegments}else{let{pathSegments:V,segments:ie,revolutions:oe}=e.userData.parameters;b=Math.ceil(ie*oe)+2,I=V}P?(o=new Uint32Array(1*I*3+(b-1)*I*4),n=new Uint8Array(1*I+(b-1)*I)):(o=new Uint32Array(2*I*3+(b-2)*I*4),n=new Uint8Array(2*I+(b-2)*I));let v=0,D=0,Z=0;if(e.userData.type==="SphereGeometry"||e.userData.type==="HelixGeometry"||e.userData.type==="TorusGeometry"){for(;D<3*I;)o[D++]=T[v++],o[D++]=T[v++],o[D++]=T[v++],n[Z++]=3;let V=P?o.length:3*I+4*(b-2)*I;for(;D<V;v+=6)o[D++]=T[v],o[D++]=T[v+1],o[D++]=T[v+4],o[D++]=T[v+5],n[Z++]=4}else for(;D<4*(b-2)*I;v+=6)o[D++]=T[v],o[D++]=T[v+1],o[D++]=T[v+4],o[D++]=T[v+5],n[Z++]=4;for(;D<o.length;)o[D++]=T[v++],o[D++]=T[v++],o[D++]=T[v++],n[Z++]=3;break;default:o=T,n=new Uint8Array(h/3).fill(3);break}}let l=r.length,c=o.length,d=n.length,p=r.length+s.length+a.length,u=o.length+n.length,f=p*Float32Array.BYTES_PER_ELEMENT+u*Uint32Array.BYTES_PER_ELEMENT,m=p*Float32Array.BYTES_PER_ELEMENT,x=u*Uint32Array.BYTES_PER_ELEMENT,y=de._malloc(f),N=new Float32Array(de.HEAPF32.buffer,y,p),L=new Uint32Array(de.HEAPU32.buffer,y+m,u);N.set(r,0),N.set(s,r.length),N.set(a,r.length+s.length),L.set(o,0),L.set(n,o.length);let w;((S=t==null?void 0:t.scaleBaked)==null?void 0:S.some(_=>_!==1))&&(w=new Zv().makeScale(...t.scaleBaked)),i&&(w?w.premultiply(i):w=i);let B=w?de.alloc_subdivision_surface2(y,l,y+m,c,y+m+o.length*Uint32Array.BYTES_PER_ELEMENT,d,w.elements):de.alloc_subdivision_surface(y,l,y+m,c,y+m+o.length*Uint32Array.BYTES_PER_ELEMENT,d);return de._free(y),B}static buildLevel(i,e,t,r,o){let n=o?de.get_mesh_data2(i,e?de.Level.CONTROL:de.Level.REFINED,t!=null?t:!e,o.elements):de.get_mesh_data(i,e?de.Level.CONTROL:de.Level.REFINED,t!=null?t:!e),s=8,a=de.HEAPU32.subarray(n>>2,(n>>2)+s),l=a.subarray(4,4+4),c=0,d=de.HEAPU32[a[c]>>2],p=de.HEAPF32.subarray(d>>2,(d>>2)+l[c]);c++;let u=de.HEAPU32[a[c]>>2],f=de.HEAPF32.subarray(u>>2,(u>>2)+l[c]);c++;let m=de.HEAPU32[a[c]>>2],x=de.HEAPU32.subarray(m>>2,(m>>2)+l[c]);c++;let y=de.HEAPU32[a[c]>>2],N=de.HEAPU32.subarray(y>>2,(y>>2)+l[c]);if(c++,r===void 0){let L=new yh;if(L.setIndex(new Tl(N,1)),L.setAttribute("position",new Il(p,3)),L.setAttribute("normal",new Il(f,3)),e){L.setAttribute("faceMap",new Tl(x,1));let w=new Float32Array(f.length/3*4).fill(0);L.setAttribute("color",new gh(w,4))}return de.free_mesh_data(n),L.userData.type="SubdivGeometry",L}r.getAttribute("position").copyArray(p),r.getAttribute("normal").copyArray(f),r.attributes.position.needsUpdate=!0,r.attributes.normal.needsUpdate=!0,de.free_mesh_data(n)}static buildControlCageWireframe(i,e,t){let r=de.get_wireframe_data_for_base_level(i),o=4,n=de.HEAPU32.subarray(r>>2,(r>>2)+o),s=n.subarray(2,2+2),a=0,l=de.HEAPU32[n[a]>>2],c=de.HEAPF32.subarray(l>>2,(l>>2)+s[a]);a++;let d=de.HEAPU32[n[a]>>2],p=de.HEAPU32.subarray(d>>2,(d>>2)+s[a]);if(e===void 0){let u=new yh;u.setAttribute("position",new Il(c,3));let f=new Float32Array(c.length);for(let m=0,x=c.length;m<x;)f[m++]=t.r,f[m++]=t.g,f[m++]=t.b;return u.setAttribute("color",new gh(f,3)),u.setIndex(new Tl(p,1)),de.free_wireframe_data_for_base_level(r),u}e.getAttribute("position").copyArray(c),e.attributes.position.needsUpdate=!0,de.free_wireframe_data_for_base_level(r)}static updateCollabMesh(i,e,t){e||de.set_destination_refinement_level(i,1);let r=t?de.get_topological_data2(i,e?de.Level.CONTROL:de.Level.REFINED,t.elements):de.get_topological_data(i,e?de.Level.CONTROL:de.Level.REFINED),o=6,n=de.HEAPU32.subarray(r>>2,(r>>2)+o),s=n.subarray(3,3+3),a=0,l=de.HEAPU32[n[a]>>2],c=new Float32Array(de.HEAPF32.subarray(l>>2,(l>>2)+s[a]));a++;let d=de.HEAPU32[n[a]>>2],p=new Uint32Array(de.HEAPU32.subarray(d>>2,(d>>2)+s[a]));a++;let u=de.HEAPU32[n[a]>>2],f=new Uint8Array(de.HEAPU32.subarray(u>>2,(u>>2)+s[a]));return de.free_topological_data(r),{positions:c,indices:p,verticesPerFace:f}}};function Yv(i,e){let t=i;return t=Math.min(t,3-Math.ceil(Math.log(e/172e3)/Math.log(4))),Math.max(t,0)}var Ml={ConeGeometry:wu,CubeGeometry:Nu,CylinderGeometry:vu,DodecahedronGeometry:Lu,EllipseGeometry:Ju,HelixGeometry:eh,IcosahedronGeometry:th,LatheGeometry:rh,NonParametricGeometry:qs,PolygonGeometry:sh,PyramidGeometry:ah,RectangleGeometry:Ws,SphereGeometry:ch,PlaneGeometry:dh,StarGeometry:ph,TextFrameGeometry:$s,TorusGeometry:uh,TorusKnotGeometry:hh,TriangleGeometry:mh,VectorGeometry:mt},Ji=i=>Ml[i.type].create(i);import{Matrix4 as _l}from"three";import{Box3 as Ch,Line3 as Qt,Matrix4 as Pl,Vector3 as Re}from"three";import{HemisphereLight as Sh}from"three";import{Color as eS}from"three";var Ht=class extends eS{constructor(e,t,r,o){super(e,t,r);this.a=o}setRGBA(e,t,r,o){super.setRGB(e,t,r),this.a=o}get x(){return this.r}get y(){return this.g}get z(){return this.b}get w(){return this.a}set x(e){this.r=e}set y(e){this.g=e}set z(e){this.b=e}set w(e){this.a=e}};function Ye(i,e){let t;if(typeof i=="string"){let r=e==null?void 0:e.getColor(i);r?t=r:(console.warn("Tried to create color layer params with a color key that does not exist in the assets manager"),t=new Ht(0,0,0,0))}else return"a"in i?new Ht(i.r,i.g,i.b,i.a):new Ht(i.r,i.g,i.b,1);return t}var Ks=i=>"isEntity"in i,Xs=i=>"isAbstractMesh"in i;var Er=i=>"objectHelper"in i;function tS(i,e){var r;let t=!1;e.position&&(i.position.fromArray(e.position),t=!0),e.rotation&&(i.rotation.fromArray(e.rotation),t=!0),e.scale&&(t=!0,i.scale.fromArray(e.scale)),e.hiddenMatrix!==void 0&&"hiddenMatrix"in i&&(t=!0,i.hiddenMatrix.fromArray((r=e.hiddenMatrix)!=null?r:Zr.identity)),t&&i.updateMatrix(),e.position&&e.rotation&&e.scale&&e.hiddenMatrix!==void 0&&i.updateWorldMatrix(!1,!0),i.objectType==="CombinedCamera"&&(e.isUpVectorFlipped!==void 0&&(i.isUpVectorFlipped=e.isUpVectorFlipped),i.updateUp())}function rS(i,e){tS(i,e),e.name!==void 0&&(i.name=e.name),e.visible!==void 0&&(i.isEntity?i.visibility=e.visible:i.visible=e.visible)}function wh(i,e,t){rS(i,e),e.color!==void 0&&(i.color=Ye(e.color,t)),e.intensity!==void 0&&(i.intensity=e.intensity),e.shadows!==void 0&&!(i instanceof Sh)&&(i.castShadow=e.shadows),i.shadow&&!(i instanceof Sh)&&e.depth!==void 0&&(i.shadow.camera.far=e.depth,i.shadow.needsUpdate=!0),e.helper!==void 0&&Er(i)&&(i.enableHelper=e.helper,i.gizmos.shadowmap.visible=e.helper)}function Nh(i,e){i.shadow.camera.right=e/2,i.shadow.camera.left=-e/2,i.shadow.camera.top=e/2,i.shadow.camera.bottom=-e/2,i.shadow.needsUpdate=!0}var pi=new Ch,ft=new Re,le=new Re,tt=new Pl;function oS(i,e,t=0,r=e.count){let o=1/0,n=1/0,s=1/0,a=-1/0,l=-1/0,c=-1/0;for(let d=t;d<r;d++){let p=e.getX(d),u=e.getY(d),f=e.getZ(d);p<o&&(o=p),u<n&&(n=u),f<s&&(s=f),p>a&&(a=p),u>l&&(l=u),f>c&&(c=f)}return i.min.set(o,n,s),i.max.set(a,l,c),i}var Lh=(i,e,t,r)=>{var o;if(Xs(i)){let n=i.geometry.userData.parameters,s=i.geometry.getAttribute("position");i.geometry.userData.type==="SubdivGeometry"?ft.copy(i.originalGeometry.boundingSphere.center):(oS(pi,s,i.geometry.drawRange.start,i.geometry.drawRange.count<1/0?i.geometry.drawRange.count:s.count),pi.getCenter(ft)),i.forceComputeSize?pi.getSize(le).multiplyScalar(.5):le.set(n.width,n.height,(o=n.depth)!=null?o:0).multiplyScalar(.5)}else if(Er(i)&&r===!0){let n=i.geometryHelper.getAttribute("position");pi.setFromArray(n.array),pi.getCenter(ft),pi.getSize(le).multiplyScalar(.5)}else ft.setScalar(0),le.setScalar(0);tt.copy(e).multiply(i.matrixWorld),le.x===0&&le.y===0&&le.z===0?t.push(new Re(ft.x,ft.y,ft.z).applyMatrix4(tt)):t.push(new Re(-le.x,le.y,le.z).add(ft).applyMatrix4(tt),new Re(-le.x,-le.y,le.z).add(ft).applyMatrix4(tt),new Re(le.x,-le.y,le.z).add(ft).applyMatrix4(tt),new Re(le.x,le.y,le.z).add(ft).applyMatrix4(tt),new Re(-le.x,le.y,-le.z).add(ft).applyMatrix4(tt),new Re(-le.x,-le.y,-le.z).add(ft).applyMatrix4(tt),new Re(le.x,-le.y,-le.z).add(ft).applyMatrix4(tt),new Re(le.x,le.y,-le.z).add(ft).applyMatrix4(tt))},Zs=class extends Ch{constructor(){super(...arguments);this.matrix=new Pl;this.vertices=[];this.faces=[];this.edges=[];this.centerEdges=[]}copy(e){return super.copy(e),this.matrix.copy(e.matrix),this.vertices=e.vertices.map(t=>t.clone()),this.faces=e.faces.map(t=>t.clone()),this.edges=e.edges.map(t=>t.clone()),this.centerEdges=e.centerEdges.map(t=>t.clone()),this}setFromObjectSize(e,t=!1){e.updateWorldMatrix(!1,t),this.makeEmpty(),this.matrix.copy(e.matrixWorld);let r=new Pl().copy(e.matrixWorld).invert();return this.expandByObjectSize(e,r,t)}expandByObjectSize(e,t,r=!1){let o=[];return r===!0?e.traverseEntity(n=>Lh(n,t,o,e.enableHelper===!0)):Lh(e,t,o,e.enableHelper===!0),this.setFromPoints(o)}getCenter(e){return e=super.getCenter(e),e.applyMatrix4(this.matrix),e}getPositionToCenter(e){return e=super.getCenter(e),e.applyMatrix4(tt.copy(this.matrix).setPosition(0,0,0)),e}computeVertices(){this.getSize(le).multiplyScalar(.5),this.getCenter(ft),tt.copy(this.matrix).setPosition(ft),this.vertices=[new Re(-le.x,le.y,le.z).applyMatrix4(tt),new Re(-le.x,-le.y,le.z).applyMatrix4(tt),new Re(le.x,-le.y,le.z).applyMatrix4(tt),new Re(le.x,le.y,le.z).applyMatrix4(tt),new Re(-le.x,le.y,-le.z).applyMatrix4(tt),new Re(-le.x,-le.y,-le.z).applyMatrix4(tt),new Re(le.x,-le.y,-le.z).applyMatrix4(tt),new Re(le.x,le.y,-le.z).applyMatrix4(tt)]}computeEdges(){this.vertices.length>0&&this.computeVertices(),this.edges=[new Qt(this.vertices[0],this.vertices[3]),new Qt(this.vertices[1],this.vertices[2]),new Qt(this.vertices[5],this.vertices[6]),new Qt(this.vertices[4],this.vertices[7]),new Qt(this.vertices[0],this.vertices[1]),new Qt(this.vertices[3],this.vertices[2]),new Qt(this.vertices[7],this.vertices[6]),new Qt(this.vertices[4],this.vertices[5]),new Qt(this.vertices[0],this.vertices[4]),new Qt(this.vertices[1],this.vertices[5]),new Qt(this.vertices[2],this.vertices[6]),new Qt(this.vertices[3],this.vertices[7])],this.centerEdges=this.edges.map(e=>e.getCenter(new Re))}computeFaces(){this.vertices.length>0&&this.computeVertices(),this.faces=[new Re().copy(this.vertices[0]).sub(this.vertices[2]).multiplyScalar(.5).add(this.vertices[2]),new Re().copy(this.vertices[7]).sub(this.vertices[5]).multiplyScalar(.5).add(this.vertices[5]),new Re().copy(this.vertices[4]).sub(this.vertices[1]).multiplyScalar(.5).add(this.vertices[1]),new Re().copy(this.vertices[3]).sub(this.vertices[6]).multiplyScalar(.5).add(this.vertices[6]),new Re().copy(this.vertices[4]).sub(this.vertices[3]).multiplyScalar(.5).add(this.vertices[3]),new Re().copy(this.vertices[1]).sub(this.vertices[6]).multiplyScalar(.5).add(this.vertices[6])]}};import{Object3D as yS,Matrix4 as gS,Light as xS}from"three";import{Group as hS,Mesh as Ah,MeshStandardMaterial as jh}from"three";import{BufferGeometry as iS,Float32BufferAttribute as Ol}from"three";function Th(i){var s;let e=[],t=i.groups,r=i.getAttribute("position").array,o=i.getAttribute("normal").array,n=(s=i.getAttribute("uv"))==null?void 0:s.array;return t.forEach(a=>{let l=a.count,c=new iS,d=new Float32Array(l*3),p=new Float32Array(l*3),u=new Float32Array(l*2);for(let f=0;f<l;f++){let m=3*(a.start+f),x=3*f;if(d[x]=r[m],d[x+1]=r[m+1],d[x+2]=r[m+2],p[x]=o[m],p[x+1]=o[m+1],p[x+2]=o[m+2],n){let y=2*(a.start+f),N=2*f;u[N]=n[y],u[N+1]=n[y+1]}}c.setAttribute("position",new Ol(d,3)),c.setAttribute("normal",new Ol(p,3)),n&&c.setAttribute("uv",new Ol(u,2)),e.push(c)}),e}import{GLTFExporter as mS}from"three/examples/jsm/exporters/GLTFExporter.js";var nS,Ih=new Promise(i=>{nS=i});var _h=wc(Oh());var Ys={isPublish:!1,gltfQueue:[]};function jl(i,e,t){return i[e.uuid]===void 0&&(i[e.uuid]=e.toJSON(t)),e.uuid}var fS=new mS;function Dh(i,e,t){if(i[e.uuid]===void 0)if(e.userData.type==="NonParametricGeometry"||e.userData.type==="SubdivGeometry"){if(e.userData.type==="SubdivGeometry")if(Ys.isPublish)e=qs.create({geometry:e.clone()}),e.userData.parameters.subdivisions===0&&(delete e.attributes.color,delete e.attributes.faceMap,delete e.attributes.positionWASM,delete e.attributes.indexWASM,delete e.attributes.verticesPerFaceWASM);else{let o=e.originalGeometry;if(o){let n=e.userData;e=o.clone(),e.userData=n}else e=e.clone();delete e.attributes.color,delete e.attributes.faceMap,delete e.attributes.position,delete e.attributes.normal,e.index=null}let r=e.originalGeometry;if(r!==void 0){let o=e.userData;e=r,e.userData=o}if(!Ys.isPublish)i[e.uuid]=e.toJSON();else{let o={type:"NonParametricGeometry",uuid:e.uuid,userData:{}};e.name!==""&&(o.name=e.name),Object.keys(e.userData).length>0&&(o.userData=O({},e.userData));let n=e.index===null,s=new hS;if(Array.isArray(t))Th(e).forEach((l,c)=>{let d=new Ah(l,new jh);s.add(d),l.userData.groupIndex=c,l.userData.materialIndex=e.groups[c].materialIndex,l.index===null&&(n=!0)});else{let a=new Ah(e,new jh);s.add(a)}Ys.gltfQueue.push(new Promise(async a=>{await Promise.all(Ys.gltfQueue),fS.parse(s,async l=>{let{gltfTransform:c,DracoMeshCompressionExtension:d,addIndex:p}=await Ih,u=c.readJSON({json:yo(l),resources:{}});u.createExtension(d).setRequired(!0).setEncoderOptions({quantizationVolume:"scene"}),n&&await u.transform(p);try{let{json:f,resources:m}=c.writeJSON(u),x=_h.default.fromByteArray(new Uint8Array(m[".bin"]));f.buffers[0].uri=`data:application/octet-stream;base64,${x}`,a()}catch(f){a()}},{})})),i[e.uuid]=o}}else{let r=e.userData;if(r.type==="VectorGeometry"){let o=e.userData.shape;r=Object.assign({},r,{shape:o.toJSON()})}i[e.uuid]={uuid:e.uuid,userData:r}}return e.uuid}function ui(i){let e=[];for(let t in i){let r=i[t];delete r.metadata,e.push(r)}return e}function Bh(i){let e=[];for(let t in i)e.push(i[t]);return e}var ea=i=>class extends i{hasEntityChild(){return this.children.some(t=>Ks(t))}isDescendantOf(t){t instanceof yS&&(t=t.uuid);let r=this;for(;r.parent;){if(r.parent.uuid===t)return!0;r=r.parent}return!1}attach(t,r){this.updateWorldMatrix(!0,!1);let o=new gS().copy(this.matrixWorld).invert();return t.parent!==null&&(t.parent.updateWorldMatrix(!0,!1),o.multiply(t.parent.matrixWorld)),Ks(t)?t.hiddenMatrix.premultiply(o):t.applyMatrix4(o),t.updateWorldMatrix(!1,!1),this.add(t),r!==void 0&&(this.children.pop(),this.children.splice(r,0,t)),this}copy(t,r=!0){if(this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.rotation.order=t.rotation.order,this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.userData=JSON.parse(JSON.stringify(t.userData)),r===!0)for(let o=0;o<t.children.length;o++){let n=t.children[o];this.add(n.clone())}return this}toJSON(t){let r=t===void 0,o={object:{uuid:"",objectType:""}};t===void 0&&(t={geometries:{},materials:{},textures:{},images:{},interactionStates:{},nodes:{}},o.metadata={version:1.5,type:"Object",generator:"Object3D.toJSON"});let n={uuid:this.uuid,objectType:this.type};if(this.name!==""&&(n.name=this.name),n.matrix=this.matrix.toArray(),this.castShadow===!0&&(n.castShadow=!0),this.receiveShadow===!0&&(n.receiveShadow=!0),this.visible===!1&&(n.visible=!1),this.frustumCulled===!1&&(n.frustumCulled=!1),this.renderOrder!==0&&(n.renderOrder=this.renderOrder),n.layers=this.layers.mask,JSON.stringify(this.userData)!=="{}"&&(n.userData=this.userData),this.children.length>0){n.children=[];for(let s of this.children)(Ks(s)||s instanceof xS)&&n.children.push(s.toJSON(t).object)}if(r){let s=ui(t.geometries),a=ui(t.materials),l=ui(t.textures),c=ui(t.images),d=ui(t.interactionStates),p=Bh(t.nodes);s.length>0&&(o.geometries=s),a.length>0&&(o.materials=a),l.length>0&&(o.textures=l),c.length>0&&(o.images=c),d.length>0&&(o.interactionStates=d),p.length>0&&(o.nodes=p)}return o.object=n,o}fromJSON(t){return this.uuid=t.uuid,t.name!==void 0&&(this.name=t.name),t.matrix!==void 0?(this.matrix.fromArray(t.matrix),t.matrixAutoUpdate!==void 0&&(this.matrixAutoUpdate=t.matrixAutoUpdate),this.matrixAutoUpdate&&this.matrix.decompose(this.position,this.quaternion,this.scale)):(t.position!==void 0&&this.position.fromArray(t.position),t.rotation!==void 0&&this.rotation.fromArray(t.rotation),t.quaternion!==void 0&&this.quaternion.fromArray(t.quaternion),t.scale!==void 0&&this.scale.fromArray(t.scale)),this.castShadow=t.castShadow!==void 0,this.receiveShadow=t.receiveShadow!==void 0,t.visible!==void 0&&(this.visible=t.visible),t.frustumCulled!==void 0&&(this.frustumCulled=t.frustumCulled),t.renderOrder!==void 0&&(this.renderOrder=t.renderOrder),t.layers!==void 0&&(this.layers.mask=t.layers),t.userData!==void 0&&(this.userData=t.userData),this}};var er=i=>"isEntity"in i;var tr=i=>class extends ea(i){constructor(){super(...arguments);this.objectType="";this.isEntity=!0;this.raycastLock=!1;this.scaleLock=!1;this.hiddenMatrix=new _l;this._singleBBox=new Zs;this._recursiveBBox=new Zs;this.singleBBoxNeedsUpdate=!0;this.recursiveBBoxNeedsUpdate=!0;this.forceComputeSize=!1}set visibility(t){this.visible=t;for(let r of this.children)er(r)&&r.traverseEntity(o=>{Er(o)&&o.visible&&(o.objectHelper.visible=t)})}get visibility(){return this.visible}get interactionCache(){var t,r,o;return((t=this.interaction)==null?void 0:t.cache)===void 0&&((r=this.interaction)==null||r.computeCache()),(o=this.interaction)==null?void 0:o.cache}get singleBBox(){return this.singleBBoxNeedsUpdate&&(this.singleBBoxNeedsUpdate=!1,this._singleBBox.setFromObjectSize(this,!1),this._singleBBox.computeVertices(),this._singleBBox.computeEdges(),this._singleBBox.computeFaces()),this._singleBBox}get recursiveBBox(){return this.recursiveBBoxNeedsUpdate&&(this.recursiveBBoxNeedsUpdate=!1,this._recursiveBBox.setFromObjectSize(this,!0),this._recursiveBBox.computeVertices(),this._recursiveBBox.computeEdges(),this._recursiveBBox.computeFaces()),this._recursiveBBox}resetBBoxNeedsUpdate(){this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0,this.traverseAncestors(t=>{er(t)&&(t.singleBBoxNeedsUpdate=!0,t.recursiveBBoxNeedsUpdate=!0)}),this.traverseEntity(t=>{t.singleBBoxNeedsUpdate=!0,t.recursiveBBoxNeedsUpdate=!0})}traverseEntity(t){t(this);for(let r of this.children)er(r)&&r.traverseEntity(t)}updateMatrixWorld(t){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||t)&&(this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,t=!0);for(let r of this.children)r.updateMatrixWorld(t)}updateWorldMatrix(t,r){let o=this.parent;if(t&&o!==null&&o.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),r)for(let n of this.children)n.updateWorldMatrix(!1,!0)}shallowClone(t){return new this.constructor().shallowCopy(this,t)}shallowCopy(t,r=!0){if(super.copy(t,!1),this.raycastLock=t.raycastLock,this.scaleLock=t.scaleLock,this.hiddenMatrix.copy(t.hiddenMatrix),r===!0)for(let o of t.children)er(o)&&this.add(o.shallowClone());return this}clone(t){return new this.constructor().copy(this,t)}copy(t,r=!0){if(super.copy(t,!1),this.raycastLock=t.raycastLock,this.scaleLock=t.scaleLock,this.hiddenMatrix.copy(t.hiddenMatrix),r===!0)for(let o of t.children)er(o)&&this.add(o.clone());return this}keepChildrenMatrixWorld(){let t=new _l,r=this.matrixWorld.clone();this.updateWorldMatrix(!1,!1),t.copy(this.matrixWorld).invert(),t.multiply(r);for(let o of this.children)er(o)&&o.hiddenMatrix.premultiply(t)}toJSON(t){let r=super.toJSON(t),o=r.object;return this.raycastLock===!0&&(o.raycastLock=!0),this.scaleLock===!0&&(o.scaleLock=!0),o.hiddenMatrix=this.hiddenMatrix.toArray(),r}fromJSON(t){return super.fromJSON(t),t.raycastLock!==void 0&&(this.raycastLock=t.raycastLock),t.scaleLock!==void 0&&(this.scaleLock=t.scaleLock),this.hiddenMatrix.fromArray(t.hiddenMatrix),this}fromObject3D(t){let r=t.children;return t.children=[],Object.assign(t,{raycastLock:!1,scaleLock:!1,hiddenMatrix:new _l}),this.copy(t),t.children=r,this}toObjectTransformState(t=[]){this.updateWorldMatrix(!0,!1);let r={position:this.position.toArray(),rotation:[this.rotation.x,this.rotation.y,this.rotation.z],scale:this.scale.toArray(),hiddenMatrix:this.hiddenMatrix.toArray()};return Zo(r,t)}fromObjectTransformState(t){return t.position&&this.position.fromArray(t.position),t.rotation&&this.rotation.fromArray(t.rotation),t.scale&&this.scale.fromArray(t.scale),t.hiddenMatrix&&this.hiddenMatrix.fromArray(t.hiddenMatrix),this.updateMatrix(),this}toState(t=[]){let r=O({name:this.name,visible:this.visible,raycastLock:this.raycastLock},this.toObjectTransformState(t));return Zo(r,t)}fromState(t,r){return t.name&&(this.name=t.name),t.raycastLock!==void 0&&(this.raycastLock=t.raycastLock),t.type!=="OrthographicCamera"&&t.type!=="PerspectiveCamera"&&(this.matrixAutoUpdate=!1),t.visible!==void 0&&(this.visibility=t.visible),this.fromObjectTransformState(t),this}};import{Object3D as bS,Vector3 as Ki,Euler as Gh,MathUtils as io}from"three";var ta=class extends bS{constructor(e,t={}){super();this.object=e;let r=e.recursiveBBox.getSize(new Ki),o=.1;this.parameters=rs.defaultData(r.toArray(),o),go(this.parameters,t),this.update(),this.setHideBase(this.parameters.hideBase)}refreshMaterial(){if("material"in this.object)for(let e of this.children)e.material=this.object.material}setHideBase(e){if("material"in this.object){if(Array.isArray(this.object.material)){if(this.children.length>0){for(let t of this.object.material)t.visible=!0;if(e){let t=this.object.material.map(r=>r.clone());for(let r of this.children)r.material=t}else for(let t of this.children)t.material=this.object.material}for(let t of this.object.material)t.visible=!e}else{if(this.children.length>0)if(this.object.material.visible=!0,e){let t=this.object.material.clone();for(let r of this.children)r.material=t}else for(let t of this.children)t.material=this.object.material;this.object.material.visible=!e}this.parameters.hideBase=e}}update(){switch(this._updateCount(),this.parameters.type){case"radial":this._updateRadial(this.parameters);break;case"linear":this._updateLinear(this.parameters);break;case"grid":this._updateGrid(this.parameters)}this.children.forEach(e=>e.updateMatrix())}_updateCount(){let e=this.parameters.type==="grid"?this.parameters.grid.count[0]*this.parameters.grid.count[1]*this.parameters.grid.count[2]:this.parameters.count;if(this.children.length!==e)if(this.children.length<e)for(let t=0,r=e-this.children.length;t<r;++t){let o=this.object.shallowClone(!1);o.visible=!0,this.add(o),this.parameters.hideBase&&this.setHideBase(!0)}else for(let t=0,r=this.children.length-e;t<r;++t)this.remove(this.children[0])}_updateRadial(e){let t=e.radial,r=t.start*io.DEG2RAD,o=t.end*io.DEG2RAD,n=r-o,s=new Gh(t.rotation[0]*io.DEG2RAD,t.rotation[1]*io.DEG2RAD,t.rotation[2]*io.DEG2RAD),a;switch(t.axis){case"z":a=new Ki(0,0,1);break;case"y":a=new Ki(0,1,0);break;default:case"x":a=new Ki(1,0,0);break}for(let[l,c]of this.children.entries()){c.hiddenMatrix.identity(),c.scale.x=t.scale[0]+1,c.scale.y=t.scale[1]+1,c.scale.z=t.scale[2]+1,c.position.setScalar(0);let d=n/e.count*l-r;switch(t.axis){case"x":c.rotation.set(0,d,0);break;case"y":c.rotation.set(0,0,d);break;case"z":c.rotation.set(d,0,0);break}c.translateOnAxis(a,t.radius),c.position.x+=t.position[0],c.position.y+=t.position[1],c.position.z+=t.position[2],t.alignment===!0?(c.rotation.x+=s.x,c.rotation.y+=s.y,c.rotation.z+=s.z):c.rotation.copy(s)}}_updateLinear(e){if(e.type!=="linear")throw new Error;let t=e.linear,r=new Gh(t.rotation[0]*io.DEG2RAD,t.rotation[1]*io.DEG2RAD,t.rotation[2]*io.DEG2RAD);for(let[o,n]of this.children.entries())n.hiddenMatrix.identity(),n.scale.x=t.scale[0]*o+1,n.scale.y=t.scale[1]*o+1,n.scale.z=t.scale[2]*o+1,n.rotation.x=r.x*o,n.rotation.y=r.y*o,n.rotation.z=r.z*o,n.position.x=t.position[0]*o,n.position.y=t.position[1]*o,n.position.z=t.position[2]*o}_updateGrid(e){let t=0,r=e.grid;if(r.useCenter===!0){let o={x:r.count[0]%2==0?2:1,y:r.count[1]%2==0?2:1,z:r.count[2]%2==0?2:1},n=new Ki(r.size[0]*(r.count[0]-o.x)*.5,r.size[1]*(r.count[1]-o.y)*.5,r.size[2]*(r.count[2]-o.z)*.5);for(let s=0;s<r.count[0];s++)for(let a=0;a<r.count[1];a++)for(let l=0;l<r.count[2];l++){let c=this.children[t++];c.hiddenMatrix.identity(),c.scale.setScalar(1),c.rotation.set(0,0,0),c.position.x=r.size[0]*s-n.x,c.position.y=r.size[1]*a-n.y,c.position.z=r.size[2]*l-n.z}}else for(let o=0;o<r.count[0];o++)for(let n=0;n<r.count[1];n++)for(let s=0;s<r.count[2];s++){let a=this.children[t++];a.hiddenMatrix.identity(),a.scale.setScalar(1),a.rotation.set(0,0,0),a.position.x=r.size[0]*o,a.position.y=-r.size[1]*n,a.position.z=-r.size[2]*s}}fromJSON(e){return this}toJSON(){return{}}fromClonerState(e){return e.hideBase!==void 0&&this.setHideBase(e.hideBase),go(this.parameters,e),this.update(),this}};var yt=class extends tr(vS){constructor(e,t){super(e,t);this.isAbstractMesh=!0;Array.isArray(t)&&(this.selectedMaterial=0,e.groups.length===0&&e.addGroup(0,e.getAttribute("position").count,0))}get cloner(){return this._cloner}set cloner(e){this._cloner&&this.remove(this._cloner),e&&this.add(e),this._cloner=e}getSelectedMaterial(e){return Array.isArray(this.material)?(this.selectedMaterial===void 0&&(this.selectedMaterial=e!=null?e:0),this.material[e!=null?e:this.selectedMaterial]):this.material}setSelectedMaterial(e,t){Array.isArray(this.material)?(this.selectedMaterial===void 0&&(this.selectedMaterial=t!=null?t:0),t=t!=null?t:this.selectedMaterial,this.material[t].dispose(),this.material[t]=e):(this.material.dispose(),this.material=e)}updateGeometry(e){let t=this.geometry,r=Ml[t.userData.type],o=this.objectType==="NonParametric"?Object.assign({},t.userData,{geometry:t}):t.userData,n=r.build(r.normalizeInputs(e,o)),s=t.uuid;if(this.geometry.dispose(),this.geometry=n,this.geometry.uuid=s,this.geometry.computeBoundingSphere(),this.cloner)for(let a of this.cloner.children)a.geometry=this.geometry}resizeGeometry(e,t,r){$i.resizeGeometry(this.geometry,{width:e,height:t,depth:r})}shallowClone(e){return new this.constructor(this.geometry,this.material).shallowCopy(this,e)}clone(e){let t=this.objectType==="NonParametric"?Object.assign({},this.geometry.userData,{geometry:this.geometry.clone()}):this.geometry.userData,r=Ji(t),o=Array.isArray(this.material)?this.material.map(n=>n.clone()):this.material.clone();return new this.constructor(r,o).copy(this,e)}copy(e,t=!0){return super.copy(e,t),e.cloner&&(this.cloner=new ta(e,e.cloner.parameters),this.add(this.cloner)),this}toJSON(e){let t=super.toJSON(e),r=t.object;if(r.geometry=Dh(e.geometries,this.geometry,this.material),Array.isArray(this.material)){let o=[];for(let n=0,s=this.material.length;n<s;n++)o.push(jl(e.materials,this.material[n],e));r.material=o}else r.material=jl(e.materials,this.material,e);return t}fromJSON(e){return super.fromJSON(e),e.selectedMaterial!==void 0&&(this.selectedMaterial=e.selectedMaterial),this}setFromClonerState(e){e===null?this.cloner=void 0:(this.cloner===void 0&&(this.cloner=new ta(this)),this.cloner.fromClonerState(e))}fromState(e,t){var r,o;return super.fromState(e),e.type==="Mesh"&&(this.setFromClonerState(e.cloner),this.castShadow=(r=e.castShadow)!=null?r:!0,this.receiveShadow=(o=e.receiveShadow)!=null?o:!0),this}};import{NormalBlending as US,ShaderMaterial as kS,FrontSide as HS}from"three";import{CubeReflectionMapping as jS,CubeRefractionMapping as _S,CubeUVReflectionMapping as DS,CubeUVRefractionMapping as BS,LinearEncoding as Uh,sRGBEncoding as GS}from"three";var ra=class{constructor(e){e=e!=null?e:{},this.name=e.name,this.type=e.type,this.node=e.node,this.size=e.size,this.needsUpdate=e.needsUpdate}get value(){return this.node.value}set value(e){this.node.value=e}};import{MathUtils as SS}from"three";var pe=class{constructor(e){this.hashProperties=void 0;this.isNode=!0;this.shortcuts={};this.uuid=SS.generateUUID(),this.type=e,this.name="",this.userData={}}analyze(e,t){t=t!=null?t:{},e.analyzing=!0,this.build(e.addFlow(t.slot,t.cache,t.context),"v4"),e.clearVertexNodeCode(),e.clearFragmentNodeCode(),e.removeFlow(),e.analyzing=!1}analyzeAndFlow(e,t,r){return r=r!=null?r:{},this.analyze(e,r),this.flow(e,t,r)}flow(e,t,r){r=r!=null?r:{},e.addFlow(r.slot,r.cache,r.context);let o={result:this.build(e,t),code:e.clearNodeCode(),extra:e.context.extra};return e.removeFlow(),o}build(e,t,r){t=t!=null?t:this.getType(e,t);let o=e.getNodeData(r!=null?r:this);return e.analyzing&&this.appendDepsNode(e,o,t),e.nodes.indexOf(this)===-1&&e.nodes.push(this),this.updateFrame!==void 0&&e.updaters.indexOf(this)===-1&&e.updaters.push(this),this.generate(e,t,r)}updateFrame(e){}generateReadonly(e,t,r,o,n,s){return""}generate(e,t,r,o,n){return""}parse(e,t,r,o){}appendDepsNode(e,t,r){t.deps=(t.deps||0)+1;let o=e.getTypeLength(r);(o>(t.outputMax||0)||this.getType(e,r))&&(t.outputMax=o,t.output=r)}setName(e){this.name=e}getName(){return this.name}getType(e,t){return t==="sampler2D"||t==="samplerCube"?t:this.type}getJSONNode(e){if((e==null?void 0:e.materials)&&(e==null?void 0:e.materials[this.uuid])!==void 0)return e.materials[this.uuid]}getHash(){let e="{",t,r;for(t in this)r=this[t],r instanceof pe&&(e+='"'+t+'":'+r.getHash()+",");if(this.hashProperties)for(let o=0;o<this.hashProperties.length;o++)t=this.hashProperties[o],r=this[t],e+='"'+t+'":"'+String(r)+'",';return e+='"id":"'+this.uuid+'"}',e}copy(e){return this.name=e.name,e.type&&(this.type=e.type),e.frameId&&(this.frameId=e.frameId),e.hashProperties&&(this.hashProperties=e.hashProperties.map(t=>t)),this.userData=JSON.parse(JSON.stringify(e.userData)),this.shortcuts=JSON.parse(JSON.stringify(e.shortcuts)),this}clone(){return new this.constructor().copy(this)}createJSONNode(e){let t=e===void 0||typeof e=="string";if(typeof this.type!="string")throw new Error("Node does not allow serialization.");let r={};return r.uuid=this.uuid,r.type=this.type,this.name!==""&&(r.name=this.name),JSON.stringify(this.userData)!=="{}"&&(r.userData=this.userData),!t&&e&&(e.nodes[this.uuid]=r),r}toJSON(e){var t;return(t=this.getJSONNode(e))!=null?t:this.createJSONNode(e)}fromJSON(e,t){return this.uuid=e.uuid,this.type=e.type,e.name&&(this.name=e.name),e.userData&&(this.userData=e.userData),this}};var zh=class{constructor(){this.nodes={};this.keywords={}}add(e){this.nodes[e.name]=e}addKeyword(e,t,r){r=r!==void 0?r:!0,this.keywords[e]={callback:t,cache:r}}remove(e){delete this.nodes[e.name]}removeKeyword(e){delete this.keywords[e]}get(e){return this.nodes[e]}getKeyword(e,t){return this.keywords[e].callback(t)}getKeywordData(e){return this.keywords[e]}contains(e){return this.nodes[e]!==void 0}containsKeyword(e){return this.keywords[e]!==void 0}},lt=new zh;import{Vector2 as Eh}from"three";import{MathUtils as wS}from"three";var ue=class extends pe{constructor(e,t){super(e);this.scope="";t=t!=null?t:{},this.shared=t.shared!==void 0?t.shared:!0,this.unique=t.unique!==void 0?t.unique:!1}build(e,t,r,o){if(t=t!=null?t:this.getType(e),this.getShared(e,t)){let n=this.getUnique(e,t);n&&this.uuid===void 0&&(this.uuid=wS.generateUUID()),r=e.getUUID(r!=null?r:this.getUUID(),!n);let s=e.getNodeData(r),a=s.output||this.getType(e);if(e.analyzing)return(s.deps||0)>0||this.getLabel()?(this.appendDepsNode(e,s,t),this.generate(e,t,r)):super.build(e,t,r);if(n)return s.name=s.name||super.build(e,t,r),s.name;if(!this.getLabel()&&(!this.getShared(e,a)||e.context.ignoreCache||s.deps===1))return super.build(e,t,r);r=this.getUUID(!1);let l=this.getTemp(e,r);if(l)return e.format(l,a,t);{l=super.generate(e,t,r,s.output,o);let c=this.generate(e,a,r);return e.addNodeCode(l+" = "+c+";"),e.format(l,a,t)}}return super.build(e,t,r)}getShared(e,t){return t!=="sampler2D"&&t!=="samplerCube"&&this.shared}getUnique(e,t){return this.unique}setLabel(e){return this.label=e,this}getLabel(){return this.label}getUUID(e){let t=this.uuid;return typeof this.scope=="string"&&(t=this.scope+"-"+t),t}getTemp(e,t){t=t||this.uuid;let r=e.getVars()[t];return r?r.name:void 0}generate(e,t,r,o,n){return this.getShared(e,t)||console.error("TempNode is not shared"),r=r!=null?r:this.uuid,e.getTempVar(r,o!=null?o:this.getType(e),n,this.getLabel()).name}};var Ue=class extends ue{constructor(e,t){t=t!=null?t:{},t.shared=t.shared!==void 0?t.shared:!1;super(e,t);this.readonly=!1}setReadonly(e){return this.readonly=e,this.hashProperties=this.readonly?["value"]:void 0,this}getReadonly(){return this.readonly}createJSONNode(e){let t=super.createJSONNode(e);return this.readonly===!0&&(t.readonly=this.readonly),t}fromJSON(e,t){return super.fromJSON(e,t),e.readonly!==void 0&&this.setReadonly(e.readonly),this}generate(e,t,r,o,n,s){r=e.getUUID(r!=null?r:this.getUUID()),o=o!=null?o:this.getType(e);let a=e.getNodeData(r);return this.getReadonly()&&this.generateReadonly!==void 0?this.generateReadonly(e,t,r,o,n,s):e.isShader("vertex")?(a.vertex||(a.vertex=e.createVertexUniform(o,this,n,s,this.getLabel())),e.format(a.vertex.name,o,t)):(a.fragment||(a.fragment=e.createFragmentUniform(o,this,n,s,this.getLabel())),e.format(a.fragment.name,o,t))}copy(e){return super.copy(e),this.readonly=e.readonly,this}};var It=class extends Ue{constructor(e=0,t){super("v2");this.nodeType="Vector2";this.value=e instanceof Eh?e:new Eh(e,t)}get x(){return this.value.x}set x(e){this.value.x=e}get y(){return this.value.y}set y(e){this.value.y=e}generateReadonly(e,t,r,o,n,s){return e.format("vec2("+this.value.x+", "+this.value.y+")",o,t)}copy(e){return super.copy(e),this.value.copy(e.value),this}};import{Vector3 as Fh}from"three";var Mt=class extends Ue{constructor(e=0,t,r){super("v3");this.nodeType="Vector3";this.value=e instanceof Fh?e:new Fh(e,t,r)}get x(){return this.value.x}set x(e){this.value.x=e}get y(){return this.value.y}set y(e){this.value.y=e}get z(){return this.value.z}set z(e){this.value.z=e}generateReadonly(e,t,r,o,n,s){return e.format("vec3("+this.value.x+", "+this.value.y+", "+this.value.z+")",o,t)}copy(e){return super.copy(e),this.value.copy(e.value),this}};var no=class extends Ue{constructor(e){super("v4");this.nodeType="Vector4";this.value=e instanceof Ht?e:new Ht(e.r,e.g,e.b,e.a)}generateReadonly(e,t,r,o,n,s){return e.format("vec4("+this.value.r+", "+this.value.g+", "+this.value.b+", "+this.value.a+")",o,t)}copy(e){return super.copy(e),this.value.copy(e.value),this}};var NS=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,Rh=/[a-z_0-9]+/gi,re=class extends ue{constructor(e,t,r,o,n){super(n);this.src="";this.nodeType="Function";this.useKeywords=!0;this.includes=[];this.extensions={};this.keywords={};this.isMethod=n===void 0,this.isInterface=!1,this.parse(e,t,r,o)}getShared(e,t){return!this.isMethod}getType(e){return e.getTypeByFormat(this.type)}getInputByName(e){if(this.inputs){let t=this.inputs.length;for(;t--;)if(this.inputs[t].name===e)return this.inputs[t]}}getIncludeByName(e){if(this.includes){let t=this.includes.length;for(;t--;)if(this.includes[t].name===e)return this.includes[t]}}generate(e,t,r,o,n){let s,a=0,l=this.src;if(this.includes)for(let d=0;d<this.includes.length;d++)e.include(this.includes[d],this);for(let d in this.extensions)e.extensions[d]=!0;let c=[];for(;s=Rh.exec(this.src);)c.push(s);for(let d=0;d<c.length;d++){let p=c[d],u=p[0],f=this.isMethod?!this.getInputByName(u):!0,m=u;if(this.keywords[u]||this.useKeywords&&f&&lt.containsKeyword(u)){let x=this.keywords[u];if(!x){let y=lt.getKeywordData(u);y.cache&&(x=e.keywords[u]),x=x||lt.getKeyword(u,e),y.cache&&(e.keywords[u]=x)}m=x.build(e)}u!==m&&(l=l.substring(0,p.index+a)+m+l.substring(p.index+u.length+a),a+=m.length-u.length),this.getIncludeByName(m)===void 0&&lt.contains(m)&&e.include(lt.get(m))}return t==="source"?l:this.isMethod?(this.isInterface||e.include(this,void 0,l),this.name):e.format("( "+l+" )",this.getType(e),t)}parse(e,t,r,o){if(this.src=e||"",this.includes=t!=null?t:[],this.extensions=r!=null?r:{},this.keywords=o!=null?o:{},this.isMethod){let n=NS.exec(this.src);if(this.inputs=[],n&&n.length==4){this.type=n[1],this.name=n[2];let s=n[3].match(Rh);if(s){let a=0;for(;a<s.length;){let l=s[a++],c;l==="in"||l==="out"||l==="inout"?c=s[a++]:(c=l,l="");let d=s[a++];this.inputs.push({name:d,type:c,qualifier:l})}}this.isInterface=this.src.indexOf("{")===-1}else this.type="",this.name=""}}copy(e){return super.copy(e),this.isMethod=e.isMethod,this.useKeywords=e.useKeywords,e.type!==void 0&&(this.type=e.type),this.parse(e.src,e.includes,e.extensions,e.keywords),this}toJSON(e){var r;let t=this.getJSONNode(e);if(!t){t=this.createJSONNode(e),t.src=this.src,t.isMethod=this.isMethod,t.useKeywords=this.useKeywords,this.isMethod||(t.type=this.type),t.extensions=JSON.parse(JSON.stringify(this.extensions));let o={};for(let n in this.keywords)o[n]=this.keywords[n].toJSON(e).uuid;if(t.keywords=o,(r=this.includes)==null?void 0:r.length){let n=[];for(let s=0;s<this.includes.length;s++)n.push(this.includes[s].toJSON(e).uuid);t.includes=n}t.isMethod=this.isMethod,t.inputs=this.inputs}return t.nodeType=this.nodeType,t}fromJSON(e,t){if(super.fromJSON(e,t),e.inputs!==void 0&&(this.inputs=e.inputs),e.isMethod!==void 0&&(this.isMethod=e.isMethod),e.src&&(this.src=e.src),e.isMethod&&(this.isMethod=e.isMethod),e.useKeywords&&(this.useKeywords=e.useKeywords),e.type&&(this.type=e.type),e.extensions&&(this.extensions=e.extensions),e.keywords&&t){this.keywords={};for(let r in e.keywords)this.keywords[r]=t.getNode(e.keywords[r])}return e.includes&&t&&(this.includes=e.includes.map(r=>t.getNode(r))),this}};var CS=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=?\s?(.*?)(\;|$)/i,Dl=class extends ue{constructor(e="",t){super();this.src="";this.useDefine=!1;this.nodeType="Const";this.parse(e||Dl.PI,void 0,void 0,void 0,t)}getType(e){return e.getTypeByFormat(this.type)}parse(e,t,r,o,n){this.src=e||"";let s,a,l="",c=CS.exec(e);this.useDefine=n!=null?n:this.src.charAt(0)==="#",c&&c.length>1?(a=c[1],s=c[2],l=c[3]):(s=this.src,a="f"),this.name=s,this.type=a,this.value=l}build(e,t){if(t==="source"){if(this.value)return this.useDefine?"#define "+this.name+" "+this.value:"const "+this.type+" "+this.name+" = "+this.value+";";if(this.useDefine)return this.src}return e.include(this),e.format(this.name,this.getType(e),t)}generate(e,t,r,o,n){return e.format(this.name,this.getType(e),t)}copy(e){return super.copy(e),this.parse(e.src,void 0,void 0,void 0,e.useDefine),this}},Ie=Dl;Ie.PI="PI",Ie.PI2="PI2",Ie.RECIPROCAL_PI="RECIPROCAL_PI",Ie.RECIPROCAL_PI2="RECIPROCAL_PI2",Ie.LOG2="LOG2",Ie.EPSILON="EPSILON";var LS=new RegExp(`^structs*([a-z_0-9]+)s*{s*((.|
2
+ )*?)}`,"gim"),TS=new RegExp("s*(w*?)s*(w*?)(=|;)","gim"),Xi=class extends ue{constructor(e=""){super();this.inputs=[];this.src="";this.nodeType="Struct";this.parse(e)}getType(e){return e.getTypeByFormat(this.name)}getInputByName(e){let t=this.inputs.length;for(;t--;)if(this.inputs[t].name===e)return this.inputs[t]}generate(e,t,r,o,n){return t==="source"?this.src+";":e.format("( "+this.src+" )",this.getType(e),t)}parse(e=""){this.src=e,this.inputs=[];let t=LS.exec(e);if(t){let r=t[2],o;for(;o=TS.exec(r);)this.inputs.push({type:o[1],name:o[2]});this.name=t[1]}else this.name="";this.type=this.name}};var Zi=class extends ue{constructor(e){super("v2",{shared:!1});this.nodeType="UV";this.index=e!=null?e:0}generate(e,t){e.requires.uv[this.index]=!0;let r=this.index>0?this.index+1:"",o=e.isShader("vertex")?"uv"+r:"vUv"+r;return e.format(o,this.getType(e),t)}copy(e){return super.copy(e),this.index=e.index,this}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.index=this.index),t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),e.index&&(this.index=e.index),this}};lt.addKeyword("uv",function(){return new Zi});lt.addKeyword("uv2",function(){return new Zi(1)});import{LinearEncoding as IS,sRGBEncoding as MS}from"three";var Lo=class extends ue{constructor(e=new pe,t){super("v4");this.nodeType="ColorSpace";this.factor=new pe;this.input=e,this.method=t!=null?t:Lo.LINEAR_TO_LINEAR,this.hashProperties=["method"]}static getEncodingComponents(e){switch(e){case IS:return["Linear"];case MS:return["sRGB"];default:return[]}}generate(e,t){var a;let r=this.input.build(e,"v4"),o=this.getType(e),n=Lo.Nodes[this.method],s=e.include(n);if(s===Lo.LINEAR_TO_LINEAR)return e.format(r,o,t);if(((a=n.inputs)==null?void 0:a.length)===2){let l=this.factor.build(e,"f");return e.format(s+"( "+r+", "+l+" )",o,t)}else return e.format(s+"( "+r+" )",o,t)}fromEncoding(e){let t=Lo.getEncodingComponents(e);this.method="LinearTo"+t[0],this.factor=t[1]}fromDecoding(e){let t=Lo.getEncodingComponents(e);this.method=t[0]+"ToLinear",this.factor=t[1]}copy(e){return super.copy(e),this.input.copy(e.input),this.method=e.method,this.factor.copy(e.factor),this}},Dt=Lo;Dt.Nodes={LinearToLinear:new re(["vec4 LinearToLinear( in vec4 value ) {"," return value;","}"].join(`
3
+ `)),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
+ `)),LinearTosRGB:new re(["vec4 LinearTosRGB( in vec4 value ) {"," return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.w );","}"].join(`
5
+ `))},Dt.LINEAR_TO_LINEAR="LinearToLinear",Dt.SRGB_TO_LINEAR="sRGBToLinear",Dt.LINEAR_TO_SRGB="LinearTosRGB";var Be=class extends re{constructor(e="",t,r,o,n){super(e,n,o,r,t);this.nodeType="Expression"}};import{Texture as PS}from"three";var Fr=class extends PS{toJSON(e){let t=super.toJSON(e),r=e===void 0||typeof e=="string";if(this.image!==void 0&&!r){let o=this.image;if(Array.isArray(o)){e.images[o.uuid].url=[];for(let n=0;n<o.length;n++)e.images[o.uuid].url[n]=Vh(o[n])}else e.images[o.uuid].url=Vh(o)}return t}};function Vh(i){return typeof HTMLImageElement!="undefined"&&i instanceof HTMLImageElement||typeof HTMLCanvasElement!="undefined"&&i instanceof HTMLCanvasElement||typeof ImageBitmap!="undefined"&&i instanceof ImageBitmap?OS(i):(console.warn("THREE.Texture: Unable to serialize Texture."),"")}var hi;function OS(i){if(/^data:/i.test(i.src))return i.src;let e;if(i instanceof HTMLCanvasElement)e=i;else{hi===void 0&&(hi=document.createElement("canvas")),hi.width=i.width,hi.height=i.height;let r=hi.getContext("2d");i instanceof ImageData?r.putImageData(i,0,0):r.drawImage(i,0,0,i.width,i.height),e=hi}let t=i.src.startsWith("blob:")?i.fileName:i.src;return/\.jpe?g$/i.test(t)?e.toDataURL("image/jpeg",.6):e.toDataURL("image/png")}var Bt=class extends Ue{constructor(e=new Fr,t,r,o){super("v4",{shared:!0});this.nodeType="Texture";this.value=e,this.uv=t!=null?t:new Zi,this.bias=r,this.project=o!==void 0?o:!1}getTexture(e,t){return super.generate(e,t,this.value.uuid,"t")}generate(e,t){var d;if(t==="sampler2D")return this.getTexture(e,t);let r=this.getTexture(e,t),o=this.uv.build(e,this.project?"v4":"v2"),n=this.bias?this.bias.build(e,"f"):void 0;n===void 0&&e.context.bias&&(n=e.context.bias.setTexture(this).build(e,"f"));let s,a;this.project?s="texture2DProj":s=n?"tex2DBias":"tex2D",n?a=s+"( "+r+", "+o+", "+n+" )":a=s+"( "+r+", "+o+" )";let l={include:e.isShader("vertex"),ignoreCache:!0},c=this.getType(e);return e.addContext(l),this.colorSpace=(d=this.colorSpace)!=null?d:new Dt(new Be("",c)),this.colorSpace.fromDecoding(e.getTextureEncodingFromMap(this.value)),this.colorSpace.input.parse(a),a=this.colorSpace.build(e,c),e.removeContext(),e.format(a,c,t)}copy(e){return super.copy(e),e.value.isRenderTargetTexture?this.value=e.value:this.value.copy(e.value),this.uv.copy(e.uv),e.bias?this.bias?this.bias.copy(e.bias):this.bias=e.bias.clone():this.bias=void 0,e.colorSpace?this.colorSpace?this.colorSpace.copy(e.colorSpace):this.colorSpace=e.colorSpace.clone():this.colorSpace=void 0,this.project=e.project,e.value.isRenderTargetTexture||(this.value.updateMatrix(),this.value.needsUpdate=!0),this}};var ee=class extends Ue{constructor(e){super("f");this.nodeType="Float";this.value=e!=null?e:0}generateReadonly(e,t,r,o,n,s){return e.format(this.value+(this.value%1?"":".0"),o,t)}copy(e){return super.copy(e),this.value=e.value,this}};var oa=class extends ue{constructor(e,t){super();this.inputs=[];this.nodeType="FunctionCall";this.value=e,this.inputs=t!=null?t:[]}getFunction(){return this.value}getType(e){return this.value.getType(e)}generate(e,t,r,o,n){o=this.getType(e);let s=this.value,a=s.build(e,t)+"( ",l=[];if(s.inputs){for(let c=0;c<s.inputs.length;c++){let d=s.inputs[c],p=this.inputs[c]||this.inputs[d.name];l.push(p.build(e,e.getTypeByFormat(d.type)))}a+=l.join(", ")+" )"}return e.format(a,o,t)}copy(e){return super.copy(e),this.value.copy(e.value),this.inputs=e.inputs.map(t=>t.clone()),this}toJSON(e){var r;let t=this.getJSONNode(e);if(!t){let o=this.value;if(t=this.createJSONNode(e),t.value=this.value.toJSON(e).uuid,(r=o.inputs)==null?void 0:r.length){t.inputs={};for(let n=0;n<o.inputs.length;n++){let s=o.inputs[n],a=this.inputs[n];t.inputs[s.name]=a.toJSON(e).uuid}}}return t}};var mi;(function(o){o.ADD="+",o.SUB="-",o.MUL="*",o.DIV="/"})(mi||(mi={}));var Bl=class extends ue{constructor(e=new pe,t=new pe,r=Bl.ADD){super();this.nodeType="Operator";this.type=e.type,this.a=e,this.b=t,this.op=r}getType(e){let t=this.a.getType(e),r=this.b.getType(e);return e.isTypeMatrix(t)?"v4":e.getTypeLength(r)>e.getTypeLength(t)?r:t}generate(e,t){let r=this.getType(e);this.type=r;let o=this.a.build(e,r),n=this.b.build(e,r);return e.format("( "+o+" "+this.op+" "+n+" )",r,t)}copy(e){return super.copy(e),this.a.copy(e.a),this.b.copy(e.b),this.op=e.op,this}},qt=Bl;qt.ADD=mi.ADD,qt.SUB=mi.SUB,qt.MUL=mi.MUL,qt.DIV=mi.DIV;var be;(function(g){g.RAD="radians",g.DEG="degrees",g.EXP="exp",g.EXP2="exp2",g.LOG="log",g.LOG2="log2",g.SQRT="sqrt",g.INV_SQRT="inversesqrt",g.FLOOR="floor",g.CEIL="ceil",g.NORMALIZE="normalize",g.FRACT="fract",g.SATURATE="saturate",g.SIN="sin",g.COS="cos",g.TAN="tan",g.ASIN="asin",g.ACOS="acos",g.ARCTAN="atan",g.ABS="abs",g.SIGN="sign",g.LENGTH="length",g.NEGATE="negate",g.INVERT="invert",g.MIN="min",g.MAX="max",g.MOD="mod",g.STEP="step",g.REFLECT="reflect",g.DISTANCE="distance",g.DOT="dot",g.CROSS="cross",g.POW="pow",g.MIX="mix",g.CLAMP="clamp",g.REFRACT="refract",g.SMOOTHSTEP="smoothstep",g.FACEFORWARD="faceforward"})(be||(be={}));var je=class extends ue{constructor(e=new pe,t=je.ABS,r,o){super();this.nodeType="Math";this.a=e,typeof t!="string"?this.b=t:o=t,typeof r!="string"?this.c=r:o=r,this.method=o,this.hashProperties=["method"]}getNumInputs(e){switch(this.method){case je.MIX:case je.CLAMP:case je.REFRACT:case je.SMOOTHSTEP:case je.FACEFORWARD:return 3;case je.MIN:case je.MAX:case je.MOD:case je.STEP:case je.REFLECT:case je.DISTANCE:case je.DOT:case je.CROSS:case je.POW:return 2;default:return 1}}getInputType(e){let t=e.getTypeLength(this.a.getType(e)),r=this.b?e.getTypeLength(this.b.getType(e)):0,o=this.c?e.getTypeLength(this.c.getType(e)):0;return t>r&&t>o?this.a.getType(e):r>o?this.b.getType(e):this.c.getType(e)}getType(e){switch(this.method){case je.LENGTH:case je.DISTANCE:case je.DOT:return"f";case je.CROSS:return"v3"}return this.getInputType(e)}generate(e,t){let r,o,n,s=this.a?e.getTypeLength(this.a.getType(e)):0,a=this.b?e.getTypeLength(this.b.getType(e)):0,l=this.c?e.getTypeLength(this.c.getType(e)):0,c=this.getInputType(e),d=this.getType(e);switch(this.type=d,this.method){case je.NEGATE:return e.format("( -"+this.a.build(e,c)+" )",c,t);case je.INVERT:return e.format("( 1.0 - "+this.a.build(e,c)+" )",c,t);case je.CROSS:r=this.a.build(e,"v3"),o=this.b.build(e,"v3");break;case je.STEP:r=this.a.build(e,s===1?"f":c),o=this.b.build(e,c);break;case je.MIN:case je.MAX:case je.MOD:r=this.a.build(e,c),o=this.b.build(e,a===1?"f":c);break;case je.REFRACT:r=this.a.build(e,c),o=this.b.build(e,c),n=this.c.build(e,"f");break;case je.MIX:r=this.a.build(e,c),o=this.b.build(e,c),n=this.c.build(e,l===1?"f":c);break;default:r=this.a.build(e,c),this.b&&(o=this.b.build(e,c)),this.c&&(n=this.c.build(e,c));break}let p=[];p.push(r),o&&p.push(o),n&&p.push(n);let u=this.getNumInputs(e);if(p.length!==u)throw Error(`Arguments not match used in "${this.method}". Require ${u}, currently ${p.length}.`);return e.format(this.method+"( "+p.join(", ")+" )",d,t)}copy(e){return super.copy(e),this.a.copy(e.a),this.b=e.b instanceof pe?e.b.clone():e.b,this.c=e.c instanceof pe?e.c.clone():e.c,this.method=e.method,this}},fe=je;fe.RAD=be.RAD,fe.DEG=be.DEG,fe.EXP=be.EXP,fe.EXP2=be.EXP2,fe.LOG=be.LOG,fe.LOG2=be.LOG2,fe.SQRT=be.SQRT,fe.INV_SQRT=be.INV_SQRT,fe.FLOOR=be.FLOOR,fe.CEIL=be.CEIL,fe.NORMALIZE=be.NORMALIZE,fe.FRACT=be.FRACT,fe.SATURATE=be.SATURATE,fe.SIN=be.SIN,fe.COS=be.COS,fe.TAN=be.TAN,fe.ASIN=be.ASIN,fe.ACOS=be.ACOS,fe.ARCTAN=be.ARCTAN,fe.ABS=be.ABS,fe.SIGN=be.SIGN,fe.LENGTH=be.LENGTH,fe.NEGATE=be.NEGATE,fe.INVERT=be.INVERT,fe.MIN=be.MIN,fe.MAX=be.MAX,fe.MOD=be.MOD,fe.STEP=be.STEP,fe.REFLECT=be.REFLECT,fe.DISTANCE=be.DISTANCE,fe.DOT=be.DOT,fe.CROSS=be.CROSS,fe.POW=be.POW,fe.MIX=be.MIX,fe.CLAMP=be.CLAMP,fe.REFRACT=be.REFRACT,fe.SMOOTHSTEP=be.SMOOTHSTEP,fe.FACEFORWARD=be.FACEFORWARD;var fi=class extends ue{constructor(e=new pe,t=new pe,r=new pe){super("v4");this.nodeType="TextureCubeUV";this.value=e,this.uv=t,this.bias=r}bilinearCubeUV(e,t,r,o){var l,c,d,p;let n=new oa(fi.Nodes.bilinearCubeUV,[t,r,o]);this.colorSpaceTL=(l=this.colorSpaceTL)!=null?l:new Dt(new Be("","v4")),this.colorSpaceTL.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceTL.input.parse(n.build(e)+".tl"),this.colorSpaceTR=(c=this.colorSpaceTR)!=null?c:new Dt(new Be("","v4")),this.colorSpaceTR.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceTR.input.parse(n.build(e)+".tr"),this.colorSpaceBL=(d=this.colorSpaceBL)!=null?d:new Dt(new Be("","v4")),this.colorSpaceBL.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceBL.input.parse(n.build(e)+".bl"),this.colorSpaceBR=(p=this.colorSpaceBR)!=null?p:new Dt(new Be("","v4")),this.colorSpaceBR.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceBR.input.parse(n.build(e)+".br");let s={include:e.isShader("vertex"),ignoreCache:!0};e.addContext(s),this.colorSpaceTLExp=new Be(this.colorSpaceTL.build(e,"v4"),"v4"),this.colorSpaceTRExp=new Be(this.colorSpaceTR.build(e,"v4"),"v4"),this.colorSpaceBLExp=new Be(this.colorSpaceBL.build(e,"v4"),"v4"),this.colorSpaceBRExp=new Be(this.colorSpaceBR.build(e,"v4"),"v4"),e.removeContext();let a=new Be("mix( mix( cubeUV_TL, cubeUV_TR, cubeUV.f.x ), mix( cubeUV_BL, cubeUV_BR, cubeUV.f.x ), cubeUV.f.y )","v4");return a.keywords.cubeUV_TL=this.colorSpaceTLExp,a.keywords.cubeUV_TR=this.colorSpaceTRExp,a.keywords.cubeUV_BL=this.colorSpaceBLExp,a.keywords.cubeUV_BR=this.colorSpaceBRExp,a.keywords.cubeUV=n,a}generate(e,t){if(e.isShader("fragment")){let r=this.uv,o=this.bias||e.context.roughness,n=new oa(fi.Nodes.roughnessToMip,[o]),s=new fe(n,fi.Nodes.m0,fi.Nodes.cubeUV_maxMipLevel,fe.CLAMP),a=new fe(s,fe.FLOOR),l=new fe(s,fe.FRACT),c=this.bilinearCubeUV(e,this.value,r,a),d=this.bilinearCubeUV(e,this.value,r,new qt(a,new ee(1).setReadonly(!0),qt.ADD)),p=new fe(c,d,l,fe.MIX);return e.format(p.build(e),"v4",t)}else return console.warn("TextureCubeUVNode is not compatible with "+e.shader+" shader."),e.format("vec4( 0.0 )",this.getType(e),t)}copy(e){return super.copy(e),this.uv.copy(e.uv),this.bias.copy(e.bias),this.value.copy(e.value),e.colorSpaceTL?this.colorSpaceTL?this.colorSpaceTL.copy(e.colorSpaceTL):this.colorSpaceTL=e.colorSpaceTL.clone():this.colorSpaceTL=void 0,e.colorSpaceTR?this.colorSpaceTR?this.colorSpaceTR.copy(e.colorSpaceTR):this.colorSpaceTR=e.colorSpaceTR.clone():this.colorSpaceTR=void 0,e.colorSpaceBL?this.colorSpaceBL?this.colorSpaceBL.copy(e.colorSpaceBL):this.colorSpaceBL=e.colorSpaceBL.clone():this.colorSpaceBL=void 0,e.colorSpaceBR?this.colorSpaceBR?this.colorSpaceBR.copy(e.colorSpaceBR):this.colorSpaceBR=e.colorSpaceBR.clone():this.colorSpaceBR=void 0,e.colorSpaceTLExp?this.colorSpaceTLExp?this.colorSpaceTLExp.copy(e.colorSpaceTLExp):this.colorSpaceTLExp=e.colorSpaceTLExp.clone():this.colorSpaceTLExp=void 0,e.colorSpaceTRExp?this.colorSpaceTRExp?this.colorSpaceTRExp.copy(e.colorSpaceTRExp):this.colorSpaceTRExp=e.colorSpaceTRExp.clone():this.colorSpaceTRExp=void 0,e.colorSpaceBLExp?this.colorSpaceBLExp?this.colorSpaceBLExp.copy(e.colorSpaceBLExp):this.colorSpaceBLExp=e.colorSpaceBLExp.clone():this.colorSpaceBLExp=void 0,e.colorSpaceBRExp?this.colorSpaceBRExp?this.colorSpaceBRExp.copy(e.colorSpaceBRExp):this.colorSpaceBRExp=e.colorSpaceBRExp.clone():this.colorSpaceBRExp=void 0,this}},Qi=fi;Qi.Nodes=function(){let e=new Xi(`struct TextureCubeUVData {
6
6
  vec4 tl;
7
7
  vec4 tr;
8
8
  vec4 br;
9
9
  vec4 bl;
10
10
  vec2 f;
11
- }`),t=new Me("float cubeUV_maxMipLevel 8.0",!0),r=new Me("float cubeUV_minMipLevel 4.0",!0),o=new Me("float cubeUV_maxTileSize 256.0",!0),s=new Me("float cubeUV_minTileSize 16.0",!0),n=new oe(`float getFace(vec3 direction) {
11
+ }`),t=new Ie("float cubeUV_maxMipLevel 8.0",!0),r=new Ie("float cubeUV_minMipLevel 4.0",!0),o=new Ie("float cubeUV_maxTileSize 256.0",!0),n=new Ie("float cubeUV_minTileSize 16.0",!0),s=new re(`float getFace(vec3 direction) {
12
12
  vec3 absDirection = abs(direction);
13
13
  float face = -1.0;
14
14
  if (absDirection.x > absDirection.z) {
@@ -23,7 +23,7 @@ var tm=Object.create;var Ti=Object.defineProperty,rm=Object.defineProperties,om=
23
23
  face = direction.y > 0.0 ? 1.0 : 4.0;
24
24
  }
25
25
  return face;
26
- }`);n.useKeywords=!1;let a=new oe(`vec2 getUV(vec3 direction, float face) {
26
+ }`);s.useKeywords=!1;let a=new re(`vec2 getUV(vec3 direction, float face) {
27
27
  vec2 uv;
28
28
  if (face == 0.0) {
29
29
  uv = vec2(direction.z, direction.y) / abs(direction.x); // pos x
@@ -39,7 +39,7 @@ var tm=Object.create;var Ti=Object.defineProperty,rm=Object.defineProperties,om=
39
39
  uv = vec2(direction.x, direction.y) / abs(direction.z); // neg z
40
40
  }
41
41
  return 0.5 * (uv + 1.0);
42
- }`);a.useKeywords=!1;let l=new oe(`TextureCubeUVData bilinearCubeUV(sampler2D envMap, vec3 direction, float mipInt) {
42
+ }`);a.useKeywords=!1;let l=new re(`TextureCubeUVData bilinearCubeUV(sampler2D envMap, vec3 direction, float mipInt) {
43
43
  float face = getFace(direction);
44
44
  float filterInt = max(cubeUV_minMipLevel - mipInt, 0.0);
45
45
  mipInt = max(mipInt, cubeUV_minMipLevel);
@@ -67,7 +67,7 @@ var tm=Object.create;var Ti=Object.defineProperty,rm=Object.defineProperties,om=
67
67
  uv.x -= texelSize;
68
68
  vec4 bl = texture2D(envMap, uv);
69
69
  return TextureCubeUVData( tl, tr, br, bl, f );
70
- }`,[e,n,a,t,r,o,s]);l.useKeywords=!1;let c=new Me("float r0 1.0",!0),d=new Me("float v0 0.339",!0),h=new Me("float m0 -2.0",!0),p=new Me("float r1 0.8",!0),m=new Me("float v1 0.276",!0),f=new Me("float m1 -1.0",!0),x=new Me("float r4 0.4",!0),g=new Me("float v4 0.046",!0),N=new Me("float m4 2.0",!0),C=new Me("float r5 0.305",!0),S=new Me("float v5 0.016",!0),D=new Me("float m5 3.0",!0),v=new Me("float r6 0.21",!0),j=new Me("float v6 0.0038",!0),O=new Me("float m6 4.0",!0),u=[c,d,h,p,m,f,x,g,N,C,S,D,v,j,O],A=new oe(`float roughnessToMip(float roughness) {
70
+ }`,[e,s,a,t,r,o,n]);l.useKeywords=!1;let c=new Ie("float r0 1.0",!0),d=new Ie("float v0 0.339",!0),p=new Ie("float m0 -2.0",!0),u=new Ie("float r1 0.8",!0),f=new Ie("float v1 0.276",!0),m=new Ie("float m1 -1.0",!0),x=new Ie("float r4 0.4",!0),y=new Ie("float v4 0.046",!0),N=new Ie("float m4 2.0",!0),L=new Ie("float r5 0.305",!0),w=new Ie("float v5 0.016",!0),B=new Ie("float m5 3.0",!0),S=new Ie("float r6 0.21",!0),_=new Ie("float v6 0.0038",!0),T=new Ie("float m6 4.0",!0),h=[c,d,p,u,f,m,x,y,N,L,w,B,S,_,T],I=new re(`float roughnessToMip(float roughness) {
71
71
  float mip = 0.0;
72
72
  if (roughness >= r1) {
73
73
  mip = (r0 - roughness) * (m1 - m0) / (r0 - r1) + m0;
@@ -81,8 +81,8 @@ var tm=Object.create;var Ti=Object.defineProperty,rm=Object.defineProperties,om=
81
81
  mip = -2.0 * log2(1.16 * roughness);// 1.16 = 1.79^0.25
82
82
  }
83
83
  return mip;
84
- }`,u);return{bilinearCubeUV:l,roughnessToMip:A,m0:h,cubeUV_maxMipLevel:t}}();var Oo=class extends me{constructor(e){super("v3");this.nodeType="Normal";this.scope=e!=null?e:Oo.VIEW}getShared(){return this.scope===Oo.WORLD}build(e,t,r,o){let s=e.context[this.scope+"Normal"];return s?s.build(e,t,r,o):super.build(e,t,r)}generate(e,t,r,o,s){let n;switch(this.scope){case Oo.VIEW:e.isShader("vertex")?n="transformedNormal":n="geometryNormal";break;case Oo.LOCAL:e.isShader("vertex")?n="objectNormal":(e.requires.normal=!0,n="vObjectNormal");break;case Oo.WORLD:e.isShader("vertex")?n="inverseTransformDirection( transformedNormal, viewMatrix ).xyz":(e.requires.worldNormal=!0,n="vWNormal");break}return e.format(n,this.getType(e),t)}copy(e){return super.copy(e),this.scope=e.scope,this}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.scope=this.scope),t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),e.scope&&(this.scope=e.scope),this}},xt=Oo;xt.LOCAL="local",xt.WORLD="world",xt.VIEW="view",xt.NORMAL="normal";ct.addKeyword("viewNormal",function(){return new xt(xt.VIEW)});ct.addKeyword("localNormal",function(){return new xt(xt.NORMAL)});ct.addKeyword("worldNormal",function(){return new xt(xt.WORLD)});var wr=class extends me{constructor(e){super("v3");this.nodeType="Position";this.scope=e!=null?e:wr.LOCAL}getType(){switch(this.scope){case wr.PROJECTION:return"v4"}return this.type}getShader(){switch(this.scope){case wr.LOCAL:case wr.WORLD:return!1}return!0}generate(e,t,r,o,s){let n;switch(this.scope){case wr.LOCAL:e.isShader("vertex")?n="transformed":(e.requires.position=!0,n="vPosition");break;case wr.WORLD:if(e.isShader("vertex"))return"( modelMatrix * vec4( transformed, 1.0 ) ).xyz";e.requires.worldPosition=!0,n="vWPosition";break;case wr.VIEW:n=e.isShader("vertex")?"-mvPosition.xyz":"vViewPosition";break;case wr.PROJECTION:n=e.isShader("vertex")?"( projectionMatrix * modelViewMatrix * vec4( position, 1.0 ) )":"vec4( 0.0 )";break}return e.format(n,this.getType(),t)}copy(e){return super.copy(e),this.scope=e.scope,this}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.scope=this.scope),t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),e.scope&&(this.scope=e.scope),this}},wt=wr;wt.LOCAL="local",wt.WORLD="world",wt.VIEW="view",wt.PROJECTION="projection";ct.addKeyword("position",function(){return new wt});ct.addKeyword("worldPosition",function(){return new wt(wt.WORLD)});ct.addKeyword("viewPosition",function(){return new wt(wt.VIEW)});var dr=class extends me{constructor(e){super("v3");this.nodeType="Reflect";this.scope=e!=null?e:dr.CUBE}getUnique(e){return!e.context.viewNormal}getType(){switch(this.scope){case dr.SPHERE:return"v2"}return this.type}generate(e,t){let r=this.getUnique(e);if(e.isShader("fragment")){let o;switch(this.scope){case dr.VECTOR:{let s=new xt(xt.VIEW),n=e.context.roughness,a=s.build(e,"v3"),l=new wt(wt.VIEW).build(e,"v3"),c=n?n.build(e,"f"):void 0,d=`reflect( -normalize( ${l} ), ${a} )`;c&&(d=`normalize( mix( ${d}, ${a}, ${c} * ${c} ) )`);let h=`inverseTransformDirection( ${d}, viewMatrix )`;r?(e.addNodeCode(`vec3 reflectVec = ${h};`),o="reflectVec"):o=h;break}case dr.CUBE:{let s=new dr(dr.VECTOR).build(e,"v3"),n="vec3( -"+s+".x, "+s+".yz )";r?(e.addNodeCode(`vec3 reflectCubeVec = ${n};`),o="reflectCubeVec"):o=n;break}case dr.SPHERE:{let s=new dr(dr.VECTOR).build(e,"v3"),n="normalize( ( viewMatrix * vec4( "+s+", 0.0 ) ).xyz + vec3( 0.0, 0.0, 1.0 ) ).xy * 0.5 + 0.5";r?(e.addNodeCode(`vec2 reflectSphereVec = ${n};`),o="reflectSphereVec"):o=n;break}}return e.format(o,this.getType(),t)}else return console.warn("ReflectNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.type,t)}copy(e){return super.copy(e),this.scope=e.scope,this}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.scope=this.scope),t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),e.scope&&(this.scope=e.scope),this}},kr=dr;kr.CUBE="cube",kr.SPHERE="sphere",kr.VECTOR="vector";var Xl=class extends me{constructor(e=new Et,t,r){super("v4");this.nodeType="TextureCube";this.value=e,this.radianceNode=new Yi(this.value,t!=null?t:new kr(kr.VECTOR),r),this.irradianceNode=new Yi(this.value,new xt(xt.WORLD),new re(1).setReadonly(!0))}generate(e,t){return e.isShader("fragment")?(e.require("irradiance"),e.context.bias&&e.context.bias.setTexture(this.value),(e.slot==="irradiance"?this.irradianceNode:this.radianceNode).build(e,t)):(console.warn("TextureCubeNode is not compatible with "+e.shader+" shader."),e.format("vec4( 0.0 )",this.getType(e),t))}copy(e){return super.copy(e),this.value.copy(e.value),this.radianceNode.copy(e.radianceNode),this.irradianceNode.copy(e.irradianceNode),this}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.value=this.value.toJSON(e).uuid,this.radianceNode&&(t.radianceNode=this.radianceNode.toJSON(e).uuid),this.irradianceNode&&(t.irradianceNode=this.irradianceNode.toJSON(e).uuid)),t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),e.value&&(this.value=t.getNode(e.value)),e.radianceNode&&(this.radianceNode=t.getNode(e.radianceNode)),e.irradianceNode&&(this.irradianceNode=t.getNode(e.irradianceNode)),this}};import{CubeTexture as WS}from"three";var Zl=class extends Ue{constructor(e=new WS,t,r){super("v4",{shared:!0});this.nodeType="CubeTexture";this.value=e,this.uv=t!=null?t:new kr,this.bias=r}getTexture(e,t){return super.generate(e,t,this.value.uuid,"tc")}generate(e,t){var c,d;if(t==="samplerCube")return this.getTexture(e,t);let r=this.getTexture(e,t),o=(c=this.uv)==null?void 0:c.build(e,"v3"),s=this.bias?this.bias.build(e,"f"):void 0;s===void 0&&e.context.bias&&(s=e.context.bias.setTexture(this).build(e,"f"));let n;s?n="texCubeBias( "+r+", "+o+", "+s+" )":n="texCube( "+r+", "+o+" )";let a={include:e.isShader("vertex"),ignoreCache:!0},l=this.getType(e);return e.addContext(a),this.colorSpace=(d=this.colorSpace)!=null?d:new Gt(new ze("",l)),this.colorSpace.fromDecoding(e.getTextureEncodingFromMap(this.value)),this.colorSpace.input.parse(n),n=this.colorSpace.build(e,l),e.removeContext(),e.format(n,l,t)}copy(e){return super.copy(e),this.value.copy(e.value),e.uv?this.uv?this.uv.copy(e.uv):this.uv=e.uv.clone():this.uv=void 0,e.bias?this.bias?this.bias.copy(e.bias):this.bias=e.bias.clone():this.bias=void 0,this}toJSON(e){var r;let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),this.value&&(t.value=this.value.uuid),t.uv=(r=this.uv)==null?void 0:r.toJSON(e).uuid,this.bias&&(t.bias=this.bias.toJSON(e).uuid)),t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),e.value&&(this.value=t.getTexture(e.value)),e.uv&&(this.uv=t.getNode(e.uv)),e.bias&&(this.bias=t.getNode(e.bias)),this}};var of=["x","y","z","w"],YS=["float","vec2","vec3","vec4"],eN={float:"f",vec2:"v2",vec3:"v3",vec4:"v4",mat4:"v4",int:"i",bool:"b","float[]":"f[]","vec4[]":"v4[]"},tN={t:"sampler2D",tc:"samplerCube",b:"bool",i:"int",f:"float",c:"vec3",v2:"vec2",v3:"vec3",v4:"vec4",m3:"mat3",m4:"mat4","f[]":"float[]","v4[]":"vec4[]"},Ql=class{constructor(){this.includes={consts:{},functions:{},structs:{}};this.cache="";this.slot="";this.shader="";this.context={};this.getIncludesCode=function(){function e(t,r){return t.deps.length-r.deps.length}return function(r,o){let s=this.getIncludes(r,o);if(!s)return"";let n="";s=s.sort(e);for(let a=0;a<s.length;a++)s[a].src&&(n+=s[a].src+`
85
- `);return n}}();this.slots=[],this.caches=[],this.contexts=[],this.keywords={},this.nodeData={},this.fragmentVariables={},this.requires={uv:[],color:[],lights:!1,fog:!1,transparent:!1,irradiance:!1,position:!1,worldPosition:!1,normal:!1,worldNormal:!1,vWorldViewDir:!1,modelMatrix:!1,viewMatrix:!1,projectionMatrix:!1},this.includes={consts:[],functions:[],structs:[]},this.attributes={},this.prefixCode=["#ifdef TEXTURE_LOD_EXT"," #define texCube(a, b) textureCube(a, b)"," #define texCubeBias(a, b, c) textureCubeLodEXT(a, b, c)"," #define tex2D(a, b) texture2D(a, b)"," #define tex2DBias(a, b, c) texture2DLodEXT(a, b, c)","#else"," #define texCube(a, b) textureCube(a, b)"," #define texCubeBias(a, b, c) textureCube(a, b, c)"," #define tex2D(a, b) texture2D(a, b)"," #define tex2DBias(a, b, c) texture2D(a, b, c)","#endif",`
84
+ }`,h);return{bilinearCubeUV:l,roughnessToMip:I,m0:p,cubeUV_maxMipLevel:t}}();var To=class extends ue{constructor(e){super("v3");this.nodeType="Normal";this.scope=e!=null?e:To.VIEW}getShared(){return this.scope===To.WORLD}build(e,t,r,o){let n=e.context[this.scope+"Normal"];return n?n.build(e,t,r,o):super.build(e,t,r)}generate(e,t,r,o,n){let s;switch(this.scope){case To.VIEW:e.isShader("vertex")?s="transformedNormal":s="geometryNormal";break;case To.LOCAL:e.isShader("vertex")?s="objectNormal":(e.requires.normal=!0,s="vObjectNormal");break;case To.WORLD:e.isShader("vertex")?s="inverseTransformDirection( transformedNormal, viewMatrix ).xyz":(e.requires.worldNormal=!0,s="vWNormal");break}return e.format(s,this.getType(e),t)}copy(e){return super.copy(e),this.scope=e.scope,this}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.scope=this.scope),t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),e.scope&&(this.scope=e.scope),this}},gt=To;gt.LOCAL="local",gt.WORLD="world",gt.VIEW="view",gt.NORMAL="normal";lt.addKeyword("viewNormal",function(){return new gt(gt.VIEW)});lt.addKeyword("localNormal",function(){return new gt(gt.NORMAL)});lt.addKeyword("worldNormal",function(){return new gt(gt.WORLD)});var wr=class extends ue{constructor(e){super("v3");this.nodeType="Position";this.scope=e!=null?e:wr.LOCAL}getType(){switch(this.scope){case wr.PROJECTION:return"v4"}return this.type}getShader(){switch(this.scope){case wr.LOCAL:case wr.WORLD:return!1}return!0}generate(e,t,r,o,n){let s;switch(this.scope){case wr.LOCAL:e.isShader("vertex")?s="transformed":(e.requires.position=!0,s="vPosition");break;case wr.WORLD:if(e.isShader("vertex"))return"( modelMatrix * vec4( transformed, 1.0 ) ).xyz";e.requires.worldPosition=!0,s="vWPosition";break;case wr.VIEW:s=e.isShader("vertex")?"-mvPosition.xyz":"vViewPosition";break;case wr.PROJECTION:s=e.isShader("vertex")?"( projectionMatrix * modelViewMatrix * vec4( position, 1.0 ) )":"vec4( 0.0 )";break}return e.format(s,this.getType(),t)}copy(e){return super.copy(e),this.scope=e.scope,this}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.scope=this.scope),t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),e.scope&&(this.scope=e.scope),this}},wt=wr;wt.LOCAL="local",wt.WORLD="world",wt.VIEW="view",wt.PROJECTION="projection";lt.addKeyword("position",function(){return new wt});lt.addKeyword("worldPosition",function(){return new wt(wt.WORLD)});lt.addKeyword("viewPosition",function(){return new wt(wt.VIEW)});var cr=class extends ue{constructor(e){super("v3");this.nodeType="Reflect";this.scope=e!=null?e:cr.CUBE}getUnique(e){return!e.context.viewNormal}getType(){switch(this.scope){case cr.SPHERE:return"v2"}return this.type}generate(e,t){let r=this.getUnique(e);if(e.isShader("fragment")){let o;switch(this.scope){case cr.VECTOR:{let n=new gt(gt.VIEW),s=e.context.roughness,a=n.build(e,"v3"),l=new wt(wt.VIEW).build(e,"v3"),c=s?s.build(e,"f"):void 0,d=`reflect( -normalize( ${l} ), ${a} )`;c&&(d=`normalize( mix( ${d}, ${a}, ${c} * ${c} ) )`);let p=`inverseTransformDirection( ${d}, viewMatrix )`;r?(e.addNodeCode(`vec3 reflectVec = ${p};`),o="reflectVec"):o=p;break}case cr.CUBE:{let n=new cr(cr.VECTOR).build(e,"v3"),s="vec3( -"+n+".x, "+n+".yz )";r?(e.addNodeCode(`vec3 reflectCubeVec = ${s};`),o="reflectCubeVec"):o=s;break}case cr.SPHERE:{let n=new cr(cr.VECTOR).build(e,"v3"),s="normalize( ( viewMatrix * vec4( "+n+", 0.0 ) ).xyz + vec3( 0.0, 0.0, 1.0 ) ).xy * 0.5 + 0.5";r?(e.addNodeCode(`vec2 reflectSphereVec = ${s};`),o="reflectSphereVec"):o=s;break}}return e.format(o,this.getType(),t)}else return console.warn("ReflectNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.type,t)}copy(e){return super.copy(e),this.scope=e.scope,this}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.scope=this.scope),t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),e.scope&&(this.scope=e.scope),this}},Rr=cr;Rr.CUBE="cube",Rr.SPHERE="sphere",Rr.VECTOR="vector";var Gl=class extends ue{constructor(e=new Bt,t,r){super("v4");this.nodeType="TextureCube";this.value=e,this.radianceNode=new Qi(this.value,t!=null?t:new Rr(Rr.VECTOR),r),this.irradianceNode=new Qi(this.value,new gt(gt.WORLD),new ee(1).setReadonly(!0))}generate(e,t){return e.isShader("fragment")?(e.require("irradiance"),e.context.bias&&e.context.bias.setTexture(this.value),(e.slot==="irradiance"?this.irradianceNode:this.radianceNode).build(e,t)):(console.warn("TextureCubeNode is not compatible with "+e.shader+" shader."),e.format("vec4( 0.0 )",this.getType(e),t))}copy(e){return super.copy(e),this.value.copy(e.value),this.radianceNode.copy(e.radianceNode),this.irradianceNode.copy(e.irradianceNode),this}};import{CubeTexture as AS}from"three";var zl=class extends Ue{constructor(e=new AS,t,r){super("v4",{shared:!0});this.nodeType="CubeTexture";this.value=e,this.uv=t!=null?t:new Rr,this.bias=r}getTexture(e,t){return super.generate(e,t,this.value.uuid,"tc")}generate(e,t){var c,d;if(t==="samplerCube")return this.getTexture(e,t);let r=this.getTexture(e,t),o=(c=this.uv)==null?void 0:c.build(e,"v3"),n=this.bias?this.bias.build(e,"f"):void 0;n===void 0&&e.context.bias&&(n=e.context.bias.setTexture(this).build(e,"f"));let s;n?s="texCubeBias( "+r+", "+o+", "+n+" )":s="texCube( "+r+", "+o+" )";let a={include:e.isShader("vertex"),ignoreCache:!0},l=this.getType(e);return e.addContext(a),this.colorSpace=(d=this.colorSpace)!=null?d:new Dt(new Be("",l)),this.colorSpace.fromDecoding(e.getTextureEncodingFromMap(this.value)),this.colorSpace.input.parse(s),s=this.colorSpace.build(e,l),e.removeContext(),e.format(s,l,t)}copy(e){return super.copy(e),this.value.copy(e.value),e.uv?this.uv?this.uv.copy(e.uv):this.uv=e.uv.clone():this.uv=void 0,e.bias?this.bias?this.bias.copy(e.bias):this.bias=e.bias.clone():this.bias=void 0,this}};var kh=["x","y","z","w"],zS=["float","vec2","vec3","vec4"],ES={float:"f",vec2:"v2",vec3:"v3",vec4:"v4",mat4:"v4",int:"i",bool:"b","float[]":"f[]","vec4[]":"v4[]"},FS={t:"sampler2D",tc:"samplerCube",b:"bool",i:"int",f:"float",c:"vec3",v2:"vec2",v3:"vec3",v4:"vec4",m3:"mat3",m4:"mat4","f[]":"float[]","v4[]":"vec4[]"},El=class{constructor(){this.includes={consts:{},functions:{},structs:{}};this.cache="";this.slot="";this.shader="";this.context={};this.getIncludesCode=function(){function e(t,r){return t.deps.length-r.deps.length}return function(r,o){let n=this.getIncludes(r,o);if(!n)return"";let s="";n=n.sort(e);for(let a=0;a<n.length;a++)n[a].src&&(s+=n[a].src+`
85
+ `);return s}}();this.slots=[],this.caches=[],this.contexts=[],this.keywords={},this.nodeData={},this.fragmentVariables={},this.requires={uv:[],color:[],lights:!1,fog:!1,transparent:!1,irradiance:!1,position:!1,worldPosition:!1,normal:!1,worldNormal:!1,vWorldViewDir:!1,modelMatrix:!1,viewMatrix:!1,projectionMatrix:!1},this.includes={consts:[],functions:[],structs:[]},this.attributes={},this.prefixCode=["#ifdef TEXTURE_LOD_EXT"," #define texCube(a, b) textureCube(a, b)"," #define texCubeBias(a, b, c) textureCubeLodEXT(a, b, c)"," #define tex2D(a, b) texture2D(a, b)"," #define tex2DBias(a, b, c) texture2DLodEXT(a, b, c)","#else"," #define texCube(a, b) textureCube(a, b)"," #define texCubeBias(a, b, c) textureCube(a, b, c)"," #define tex2D(a, b) texture2D(a, b)"," #define tex2DBias(a, b, c) texture2D(a, b, c)","#endif",`
86
86
  // NOTE: Include Spline's blending modes. This could be part of BlendNode
87
87
  #define SPE_BLENDING_NORMAL 0
88
88
  #define SPE_BLENDING_MULTIPLY 1
@@ -123,11 +123,11 @@ var tm=Object.create;var Ti=Object.defineProperty,rm=Object.defineProperties,om=
123
123
  `}addVertexNodeCode(e){this.addNodeCode(e,"vertex")}addFragmentNodeCode(e){this.addNodeCode(e,"fragment")}addNodeCode(e,t){this.nodeCode[t!=null?t:this.shader]+=e+`
124
124
  `}clearNodeCode(e){e=e!=null?e:this.shader;let t=this.nodeCode[e];return this.nodeCode[e]="",t}clearVertexNodeCode(){return this.clearNodeCode("vertex")}clearFragmentNodeCode(){return this.clearNodeCode("fragment")}addVertexFinalCode(e){this.addFinalCode(e,"vertex")}addFragmentFinalCode(e){this.addFinalCode(e,"fragment")}addFinalCode(e,t){this.finalCode[t!=null?t:this.shader]+=e+`
125
125
  `}addVertexParsCode(e){this.addParsCode(e,"vertex")}addFragmentParsCode(e){this.addParsCode(e,"fragment")}addParsCode(e,t){this.parsCode[t!=null?t:this.shader]+=e+`
126
- `}addVaryCode(e){this.addVertexParsCode(e),this.addFragmentParsCode(e)}isCache(e){return this.caches.indexOf(e)!==-1}isSlot(e){return this.slots.indexOf(e)!==-1}define(e,t){this.defines[e]=t===void 0?1:t}require(e){this.requires[e]=!0}isDefined(e){return this.defines[e]!==void 0}getVar(e,t,r,o="varying",s="V",n=""){let a=this.getVars(o),l=a[e];if(!l){let c=a.length;l={name:r||"node"+s+c+(n?"_"+n:""),type:t},a.push(l),a[e]=l}return l}getTempVar(e,t,r,o){return this.getVar(e,t,r,this.shader,"T",o)}getAttribute(e,t){if(!this.attributes[e]){let r=this.getVar(e,t);this.addVertexParsCode("attribute "+t+" "+e+";"),this.addVertexFinalCode(r.name+" = "+e+";"),this.attributes[e]={varying:r,name:e,type:t}}return this.attributes[e]}getCode(e){return[this.prefixCode,this.parsCode[e],this.getVarListCode(this.getVars("varying"),"varying"),this.getVarListCode(this.inputs.uniforms[e],"uniform"),this.getVarListCode(this.inputs.arrayUniforms[e],"uniform"),this.getIncludesCode("consts",e),this.getIncludesCode("structs",e),this.getIncludesCode("functions",e),"void main() {",this.getVarListCode(this.getVars(e)),this.code[e],this.resultCode[e],this.finalCode[e],"}"].join(`
127
- `)}getVarListCode(e,t){t=t!=null?t:"";let r="";for(let o=0,s=e.length;o<s;++o){let n=e[o],a=n.type,l=n.name,c=n.size,d=this.getFormatByType(a);if(d===void 0)throw new Error("Node pars "+d+" not found.");d.includes("[]")?r+=t+" "+d.substring(0,d.length-2)+" "+l+`[${c}];
126
+ `}addVaryCode(e){this.addVertexParsCode(e),this.addFragmentParsCode(e)}isCache(e){return this.caches.indexOf(e)!==-1}isSlot(e){return this.slots.indexOf(e)!==-1}define(e,t){this.defines[e]=t===void 0?1:t}require(e){this.requires[e]=!0}isDefined(e){return this.defines[e]!==void 0}getVar(e,t,r,o="varying",n="V",s=""){let a=this.getVars(o),l=a[e];if(!l){let c=a.length;l={name:r||"node"+n+c+(s?"_"+s:""),type:t},a.push(l),a[e]=l}return l}getTempVar(e,t,r,o){return this.getVar(e,t,r,this.shader,"T",o)}getAttribute(e,t){if(!this.attributes[e]){let r=this.getVar(e,t);this.addVertexParsCode("attribute "+t+" "+e+";"),this.addVertexFinalCode(r.name+" = "+e+";"),this.attributes[e]={varying:r,name:e,type:t}}return this.attributes[e]}getCode(e){return[this.prefixCode,this.parsCode[e],this.getVarListCode(this.getVars("varying"),"varying"),this.getVarListCode(this.inputs.uniforms[e],"uniform"),this.getVarListCode(this.inputs.arrayUniforms[e],"uniform"),this.getIncludesCode("consts",e),this.getIncludesCode("structs",e),this.getIncludesCode("functions",e),"void main() {",this.getVarListCode(this.getVars(e)),this.code[e],this.resultCode[e],this.finalCode[e],"}"].join(`
127
+ `)}getVarListCode(e,t){t=t!=null?t:"";let r="";for(let o=0,n=e.length;o<n;++o){let s=e[o],a=s.type,l=s.name,c=s.size,d=this.getFormatByType(a);if(d===void 0)throw new Error("Node pars "+d+" not found.");d.includes("[]")?r+=t+" "+d.substring(0,d.length-2)+" "+l+`[${c}];
128
128
  `:r+=t+" "+d+" "+l+`;
129
- `}return r}getVars(e){return this.inputs.vars[e!=null?e:this.shader]}getNodeData(e){let t=e instanceof ue?e.uuid:e;return this.nodeData[t]=this.nodeData[t]||{}}createUniform(e,t,r,o,s,n){if(t.includes("[]")){let a=this.inputs.arrayUniforms,l=a.list.length,c=new pa({type:t,size:r.size,name:o||"nodeUA"+l+(n?"_"+n:""),node:r,needsUpdate:s});return a.list.push(c),a[e].push(c),a[e][c.name]=c,this.uniforms[c.name]=c,c}else{let a=this.inputs.uniforms,l=a.list.length,c=new pa({type:t,name:o||"nodeU"+l+(n?"_"+n:""),node:r,needsUpdate:s});return a.list.push(c),a[e].push(c),a[e][c.name]=c,this.uniforms[c.name]=c,c}}createVertexUniform(e,t,r,o,s){return this.createUniform("vertex",e,t,r,o,s)}createFragmentUniform(e,t,r,o,s){return this.createUniform("fragment",e,t,r,o,s)}include(e,t,r){var n;let o;if(e=typeof e=="string"?ct.get(e):e,this.context.include===!1)return e.name;e instanceof oe?o=this.includes.functions:e instanceof Me?o=this.includes.consts:e instanceof Zi&&(o=this.includes.structs);let s=o[this.shader]=o[this.shader]||[];if(e){let a=s[e.name];if(a||(a=s[e.name]={node:e,deps:[]},s.push(a),a.src=e.build(this,"source")),e instanceof oe&&t&&s[t.name]&&s[t.name].deps.indexOf(e)===-1&&(s[t.name].deps.push(e),(n=e.includes)==null?void 0:n.length)){let l=0;do this.include(e.includes[l++],t);while(l<e.includes.length)}return r&&(a.src=r),e.name}else throw new Error("Include not found.")}colorToVectorProperties(e){return e.replace("r","x").replace("g","y").replace("b","z").replace("a","w")}colorToVector(e){return e.replace(/c/g,"v3")}getIncludes(e,t){return this.includes[e][t||this.shader]}getConstructorFromLength(e){return YS[e-1]}isTypeMatrix(e){return/^m/.test(e)}getTypeLength(e){return e==="f"?1:parseInt(this.colorToVector(e).substr(1))}getTypeFromLength(e){return e===1?"f":"v"+e}findNode(...e){for(let t=0;t<arguments.length;t++){let r=e[t];if(r==null?void 0:r.isNode)return r}}resolve(...e){for(let t=0;t<arguments.length;t++){let r=e[t];if(r!==void 0){if(r.isNode)return r;if(r.isTexture)switch(r.mapping){case $S:case KS:return new Zl(r);case XS:case ZS:return new Xl(new Et(r));default:return new Et(r)}else{if(r.isVector2)return new It(r);if(r.isVector3)return new Pt(r);if(r.isVector4)return new ao(r)}}}}format(e,t,r){switch(this.colorToVector(r+" <- "+t)){case"f <- v2":return e+".x";case"f <- v3":return e+".x";case"f <- v4":return e+".x";case"f <- i":case"f <- b":return"float( "+e+" )";case"v2 <- f":return"vec2( "+e+" )";case"v2 <- v3":return e+".xy";case"v2 <- v4":return e+".xy";case"v2 <- i":case"v2 <- b":return"vec2( float( "+e+" ) )";case"v3 <- f":return"vec3( "+e+" )";case"v3 <- v2":return"vec3( "+e+", 0.0 )";case"v3 <- v4":return e+".xyz";case"v3 <- i":case"v3 <- b":return"vec2( float( "+e+" ) )";case"v4 <- f":return"vec4( "+e+" )";case"v4 <- v2":return"vec4( "+e+", 0.0, 1.0 )";case"v4 <- v3":return"vec4( "+e+", 1.0 )";case"v4 <- i":case"v4 <- b":return"vec4( float( "+e+" ) )";case"i <- f":case"i <- b":return"int( "+e+" )";case"i <- v2":return"int( "+e+".x )";case"i <- v3":return"int( "+e+".x )";case"i <- v4":return"int( "+e+".x )";case"b <- f":return"( "+e+" != 0.0 )";case"b <- v2":return"( "+e+" != vec2( 0.0 ) )";case"b <- v3":return"( "+e+" != vec3( 0.0 ) )";case"b <- v4":return"( "+e+" != vec4( 0.0 ) )";case"b <- i":return"( "+e+" != 0 )"}return e}getTypeByFormat(e){return eN[e]||e}getFormatByType(e){return tN[e]||e}getUUID(e,t){return t=t!==void 0?t:!0,t&&this.cache&&(e=this.cache+"-"+e),e}getElementByIndex(e){return of[e]}getIndexByElement(e){return of.indexOf(e)}isShader(e){return this.shader===e}setShader(e){return this.shader=e,this}mergeDefines(e){for(let t in e)this.defines[t]=e[t];return this.defines}mergeUniform(e){for(let t in e)this.uniforms[t]=e[t];return this.uniforms}getTextureEncodingFromMap(e){let t;return e?e.isTexture&&(t=e.encoding):t=rf,t===rf&&this.context.gamma&&(t=QS),t}};var fa=class extends ue{constructor(e=new ue){super("v4");this.nodeType="Raw";this.value=e}generate(e){let t=this.value.analyzeAndFlow(e,this.type),r=t.code+`
130
- `;return e.isShader("vertex")?r+="gl_Position = "+t.result+";":r+="gl_FragColor = "+t.result+";",r}copy(e){return super.copy(e),this.value.copy(e.value),this}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.value=this.value.toJSON(e).uuid),t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),e.value&&(this.value=t.getNode(e.value)),this}};var Be=class extends Ue{constructor(e=0,t,r,o){super("c");this.nodeType="Color";this.value=e instanceof Jt?e:new Jt(e||0,t,r,o)}setRGBA(e){this.value.setRGBA(e.r,e.g,e.b,e.a)}generate(e,t,r,o,s,n){r=e.getUUID(r!=null?r:this.getUUID()),o=o!=null?o:this.getType(e);let a=e.getNodeData(r),l=this.getReadonly()&&this.generateReadonly!==void 0;if(this.alpha){let c=this.alpha.build(e,"f");e.addFragmentNodeCode(`accumAlpha += ( 1.0 - accumAlpha ) * ${c};`)}return l?this.generateReadonly(e,t,r,o,s,n):e.isShader("vertex")?(a.vertex||(a.vertex=e.createVertexUniform(o,this,s,n,this.getLabel())),e.format(a.vertex.name,o,t)):(a.fragment||(a.fragment=e.createFragmentUniform(o,this,s,n,this.getLabel())),e.format(a.fragment.name,o,t))}generateReadonly(e,t,r,o,s,n){return e.format("vec3("+this.value.r+", "+this.value.g+", "+this.value.b+")",o,t)}};import{MathUtils as Ur,Vector2 as lo,Vector3 as co,Vector4 as Oa}from"three";import{Texture as rN}from"three";var Se=class extends Ue{constructor(e){super("i");this.nodeType="Int";this.value=Math.floor(e!=null?e:0)}generateReadonly(e,t,r,o,s,n){return e.format(this.value.toString(),o,t)}copy(e){return super.copy(e),this.value=e.value,this}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.value=this.value,this.getReadonly()===!0&&(t.readonly=!0)),t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),e.value&&(this.value=e.value),this}};var Le;(function(x){x.POSITION="position",x.LIGHTING="light",x.COLOR="color",x.GRADIENT="gradient",x.NORMAL="normal",x.DEPTH="depth",x.TEXTURE="texture",x.NOISE="noise",x.FRESNEL="fresnel",x.RAINBOW="rainbow",x.TRANSMISSION="transmission",x.POINTS="points",x.MATCAP="matcap",x.LINES="lines",x.DISPLACE="displace"})(Le||(Le={}));var Je;(function(r){r.POSITION="position",r.LIGHTING="light",r.COLOR="color"})(Je||(Je={}));var Ke=class{constructor(e,t,r,o){this.next=void 0;this.uniforms={};this.textures={};this.defines={};if(this.id=e,this.uuid=t,r){this.type=r.type;for(let s in r)s!=="type"&&s!=="calpha"&&(this.uniforms[`f${this.id}_${s}`]=r[s]);for(let s in o)this.defines[s]=o[s]}}copy(e){this.id=e.id,this.type=e.type,this.defines=P({},e.defines);for(let t in e.uniforms)this.getName(t)==="transmissionSamplerMap"||this.getName(t)==="transmissionDepthMap"||(this.uniforms[t]?this.uniforms[t].copy(e.uniforms[t]):this.uniforms[t]=e.uniforms[t].clone());return this}clone(){return new Ke(this.id).copy(this)}fromJSON(e,t){this.id=e.id,this.defines=P({},e.defines);for(let r in e.uniforms)this.uniforms[r]=t.getNode(e.uniforms[r]);if(e.type===Le.TEXTURE){if(!(`f${this.id}_textureSize`in this.uniforms)){let r=this.uniforms[`f${this.id}_texture`].value.image;this.uniforms[`f${e.id}_textureSize`]=new Pt(r.width,r.height)}`f${this.id}_size`in this.uniforms||(this.uniforms[`f${e.id}_size`]=new It(200,200)),`f${e.id}_axis`in this.uniforms||(this.uniforms[`f${e.id}_axis`]=new Se(0)),`f${e.id}_projection`in this.uniforms||(this.uniforms[`f${e.id}_projection`]=new Se(0))}else e.type===Le.NOISE?(`f${e.id}_noiseType`in this.uniforms||(this.uniforms[`f${e.id}_noiseType`]=new Se(0)),`f${e.id}_size`in this.uniforms||(this.uniforms[`f${e.id}_size`]=new Pt(-1,-1,-1))):e.type===Le.DEPTH&&(`f${e.id}_isWorldSpace`in this.uniforms||(this.uniforms[`f${e.id}_isWorldSpace`]=new re(1)));return this}toJSON(e){let t={};for(let o in this.uniforms)t[o]=this.uniforms[o].toJSON(e).uuid;return{id:this.id,type:this.type,defines:JSON.parse(JSON.stringify(this.defines)),uniforms:t,next:this.next==null?void 0:this.next.toJSON(e)}}copyUniforms(e){for(let t in this.uniforms){let r=this.getName(t);r!==void 0&&e.uniforms[`f${e.id}_${r}`]&&r!=="transmissionDepthMap"&&r!=="transmissionSamplerMap"&&this.uniforms[t].copy(e.uniforms[`f${e.id}_${r}`])}return this}hasValueByKey(e){return this.uniforms[e]!==void 0}hasValue(e){return this.hasValueByKey(`f${this.id}_${e}`)}setValue(e,t){let r=`f${this.id}_${e}`;this.hasValueByKey(r)&&t!==void 0&&(this.uniforms[r].value=t)}getValue(e){let t=`f${this.id}_${e}`;if(this.hasValueByKey(t))return this.uniforms[t].value}getValues(){let e={type:this.type};for(let t in this.uniforms){let r=this.getName(t);if(r===void 0)continue;let s=this.uniforms[`f${this.id}_${r}`].value;s!==void 0&&(Array.isArray(s)?e[r]=s.map(n=>n.clone?n.clone():n):e[r]=s.clone?s.clone():s)}return e}getName(e){let r=/f\d+_(.*)/.exec(e);if(r&&r.length>1)return r[1];console.log(`Layer.getName: error ${e}`)}getNames(){let e=[];for(let t in this.uniforms){let r=this.getName(t);r&&e.push(r)}return e}isEqual(e){for(let t in e.uniforms){let r=e.getName(t);if(!r)return!1;let o=this.getValue(r),s=e.uniforms[t].value;if(s.value instanceof rN){if(o.image!==s.image)return!1}else if(Array.isArray(s)){let n=o;for(let a=0,l=n.length;a<l;++a)if(n[a]!==s[a])return!1}else{let n=o;if(n.equals){if(!n.equals(s))return!1}else if(o!==s)return!1}}return!0}dispose(){}};function sf(i){let e=i instanceof Ke?i.type:i;return e==="texture"||e==="displace_map"||e==="matcap"}var ma=class extends Ue{constructor(e){super("b");this.nodeType="Bool";this.value=e!=null?e:!1}generateReadonly(e,t,r,o){return e.format(this.value?"true":"false",o,t)}copy(e){return super.copy(e),this.value=e.value,this}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.value=this.value,this.getReadonly()===!0&&(t.readonly=!0)),t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),e.value&&(this.value=e.value),this}};import{Vector4 as Yl}from"three";var yi=class extends Ue{constructor(e=1,t){super("v4[]");this.nodeType="Vector4Array";this.size=e,this.value=Array.isArray(t)?t:t instanceof Yl?new Array(e).fill(t):new Array(e).fill(new Yl(0))}copy(e){return super.copy(e),this.value=e.value.map(t=>t.clone()),this}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.value=this.value.map(r=>({x:r.x,y:r.y,z:r.z,w:r.w}))),t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),e.value&&(this.value=e.value.map(r=>new Yl(r.x,r.y,r.z,r.w)),this.size=this.value.length),this}};var xi=class extends Ue{constructor(e=1,t){super("f[]");this.nodeType="FloatArray";this.size=e,this.value=Array.isArray(t)?t:typeof t=="number"?new Array(e).fill(t):new Array(e).fill(0)}copy(e){return super.copy(e),this.size=e.size,this.value=[...e.value],this}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.size=this.size,t.value=[...this.value]),t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),e.value&&(this.value=[...e.value]),e.size?this.size=e.size:e.value&&(this.size=this.value.length),this}};import{Matrix3 as oN}from"three";var To=class extends Ue{constructor(e){super("m3");this.nodeType="Matrix3";this.value=e!=null?e:new oN}generateReadonly(e,t,r,o,s,n){return e.format("mat3("+this.value.elements.join(", ")+")",o,t)}copy(e){return super.copy(e),this.elements=e.elements,this}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.elements=this.value.elements.concat()),t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),e.elements&&(this.elements=e.elements),this}get elements(){return this.value.elements}set elements(e){this.value.fromArray(e)}};var bi;(function(o){o[o.UV=0]="UV",o[o.PLANAR=1]="PLANAR",o[o.SPHERICAL=2]="SPHERICAL",o[o.CYLINDRICAL=3]="CYLINDRICAL"})(bi||(bi={}));var es=class extends me{constructor(e=new Et,t,r,o,s,n,a,l){super("v3");this.nodeType="CustomTexture";this.firstTime=!0,this.texture=e,this.textureSize=t,this.crop=r,this.projection=o,this.axis=s,this.size=n,this.mat=new To(this.texture.value.matrix),this.alpha=a,this.mode=l,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){e.require("position"),e.require("uv"),e.requires.uv=[!0],e.extensions.shaderTextureLOD=!0,e.extensions.derivatives=!0;let r;switch(this.projection.value){case 3:r=e.include(es.Nodes.cylindrical);break;case 2:r=e.include(es.Nodes.spherical);break;case 1:let s=new oe(`
129
+ `}return r}getVars(e){return this.inputs.vars[e!=null?e:this.shader]}getNodeData(e){let t=e instanceof pe?e.uuid:e;return this.nodeData[t]=this.nodeData[t]||{}}createUniform(e,t,r,o,n,s){if(t.includes("[]")){let a=this.inputs.arrayUniforms,l=a.list.length,c=new ra({type:t,size:r.size,name:o||"nodeUA"+l+(s?"_"+s:""),node:r,needsUpdate:n});return a.list.push(c),a[e].push(c),a[e][c.name]=c,this.uniforms[c.name]=c,c}else{let a=this.inputs.uniforms,l=a.list.length,c=new ra({type:t,name:o||"nodeU"+l+(s?"_"+s:""),node:r,needsUpdate:n});return a.list.push(c),a[e].push(c),a[e][c.name]=c,this.uniforms[c.name]=c,c}}createVertexUniform(e,t,r,o,n){return this.createUniform("vertex",e,t,r,o,n)}createFragmentUniform(e,t,r,o,n){return this.createUniform("fragment",e,t,r,o,n)}include(e,t,r){var s;let o;if(e=typeof e=="string"?lt.get(e):e,this.context.include===!1)return e.name;e instanceof re?o=this.includes.functions:e instanceof Ie?o=this.includes.consts:e instanceof Xi&&(o=this.includes.structs);let n=o[this.shader]=o[this.shader]||[];if(e){let a=n[e.name];if(a||(a=n[e.name]={node:e,deps:[]},n.push(a),a.src=e.build(this,"source")),e instanceof re&&t&&n[t.name]&&n[t.name].deps.indexOf(e)===-1&&(n[t.name].deps.push(e),(s=e.includes)==null?void 0:s.length)){let l=0;do this.include(e.includes[l++],t);while(l<e.includes.length)}return r&&(a.src=r),e.name}else throw new Error("Include not found.")}colorToVectorProperties(e){return e.replace("r","x").replace("g","y").replace("b","z").replace("a","w")}colorToVector(e){return e.replace(/c/g,"v3")}getIncludes(e,t){return this.includes[e][t||this.shader]}getConstructorFromLength(e){return zS[e-1]}isTypeMatrix(e){return/^m/.test(e)}getTypeLength(e){return e==="f"?1:parseInt(this.colorToVector(e).substr(1))}getTypeFromLength(e){return e===1?"f":"v"+e}findNode(...e){for(let t=0;t<arguments.length;t++){let r=e[t];if(r==null?void 0:r.isNode)return r}}resolve(...e){for(let t=0;t<arguments.length;t++){let r=e[t];if(r!==void 0){if(r.isNode)return r;if(r.isTexture)switch(r.mapping){case jS:case _S:return new zl(r);case DS:case BS:return new Gl(new Bt(r));default:return new Bt(r)}else{if(r.isVector2)return new It(r);if(r.isVector3)return new Mt(r);if(r.isVector4)return new no(r)}}}}format(e,t,r){switch(this.colorToVector(r+" <- "+t)){case"f <- v2":return e+".x";case"f <- v3":return e+".x";case"f <- v4":return e+".x";case"f <- i":case"f <- b":return"float( "+e+" )";case"v2 <- f":return"vec2( "+e+" )";case"v2 <- v3":return e+".xy";case"v2 <- v4":return e+".xy";case"v2 <- i":case"v2 <- b":return"vec2( float( "+e+" ) )";case"v3 <- f":return"vec3( "+e+" )";case"v3 <- v2":return"vec3( "+e+", 0.0 )";case"v3 <- v4":return e+".xyz";case"v3 <- i":case"v3 <- b":return"vec2( float( "+e+" ) )";case"v4 <- f":return"vec4( "+e+" )";case"v4 <- v2":return"vec4( "+e+", 0.0, 1.0 )";case"v4 <- v3":return"vec4( "+e+", 1.0 )";case"v4 <- i":case"v4 <- b":return"vec4( float( "+e+" ) )";case"i <- f":case"i <- b":return"int( "+e+" )";case"i <- v2":return"int( "+e+".x )";case"i <- v3":return"int( "+e+".x )";case"i <- v4":return"int( "+e+".x )";case"b <- f":return"( "+e+" != 0.0 )";case"b <- v2":return"( "+e+" != vec2( 0.0 ) )";case"b <- v3":return"( "+e+" != vec3( 0.0 ) )";case"b <- v4":return"( "+e+" != vec4( 0.0 ) )";case"b <- i":return"( "+e+" != 0 )"}return e}getTypeByFormat(e){return ES[e]||e}getFormatByType(e){return FS[e]||e}getUUID(e,t){return t=t!==void 0?t:!0,t&&this.cache&&(e=this.cache+"-"+e),e}getElementByIndex(e){return kh[e]}getIndexByElement(e){return kh.indexOf(e)}isShader(e){return this.shader===e}setShader(e){return this.shader=e,this}mergeDefines(e){for(let t in e)this.defines[t]=e[t];return this.defines}mergeUniform(e){for(let t in e)this.uniforms[t]=e[t];return this.uniforms}getTextureEncodingFromMap(e){let t;return e?e.isTexture&&(t=e.encoding):t=Uh,t===Uh&&this.context.gamma&&(t=GS),t}};var ia=class extends pe{constructor(e=new pe){super("v4");this.nodeType="Raw";this.value=e}generate(e){let t=this.value.analyzeAndFlow(e,this.type),r=t.code+`
130
+ `;return e.isShader("vertex")?r+="gl_Position = "+t.result+";":r+="gl_FragColor = "+t.result+";",r}copy(e){return super.copy(e),this.value.copy(e.value),this}};var Ge=class extends Ue{constructor(e=0,t,r,o){super("c");this.nodeType="Color";this.value=e instanceof Ht?e:new Ht(e||0,t,r,o)}setRGBA(e){this.value.setRGBA(e.r,e.g,e.b,e.a)}generate(e,t,r,o,n,s){r=e.getUUID(r!=null?r:this.getUUID()),o=o!=null?o:this.getType(e);let a=e.getNodeData(r),l=this.getReadonly()&&this.generateReadonly!==void 0;if(this.alpha){let c=this.alpha.build(e,"f");e.addFragmentNodeCode(`accumAlpha += ( 1.0 - accumAlpha ) * ${c};`)}return l?this.generateReadonly(e,t,r,o,n,s):e.isShader("vertex")?(a.vertex||(a.vertex=e.createVertexUniform(o,this,n,s,this.getLabel())),e.format(a.vertex.name,o,t)):(a.fragment||(a.fragment=e.createFragmentUniform(o,this,n,s,this.getLabel())),e.format(a.fragment.name,o,t))}generateReadonly(e,t,r,o,n,s){return e.format("vec3("+this.value.r+", "+this.value.g+", "+this.value.b+")",o,t)}};import{MathUtils as Vr,Vector2 as so,Vector3 as ao,Vector4 as ya}from"three";import{Texture as RS}from"three";var ve=class extends Ue{constructor(e){super("i");this.nodeType="Int";this.value=Math.floor(e!=null?e:0)}generateReadonly(e,t,r,o,n,s){return e.format(this.value.toString(),o,t)}copy(e){return super.copy(e),this.value=e.value,this}};var Le;(function(x){x.POSITION="position",x.LIGHTING="light",x.COLOR="color",x.GRADIENT="gradient",x.NORMAL="normal",x.DEPTH="depth",x.TEXTURE="texture",x.NOISE="noise",x.FRESNEL="fresnel",x.RAINBOW="rainbow",x.TRANSMISSION="transmission",x.POINTS="points",x.MATCAP="matcap",x.LINES="lines",x.DISPLACE="displace"})(Le||(Le={}));var ke;(function(r){r.POSITION="position",r.LIGHTING="light",r.COLOR="color"})(ke||(ke={}));var Je=class{constructor(e,t,r,o){this.next=void 0;this.uniforms={};this.textures={};this.defines={};if(this.id=e,this.uuid=t,r){this.type=r.type;for(let n in r)n!=="type"&&n!=="calpha"&&(this.uniforms[`f${this.id}_${n}`]=r[n]);for(let n in o)this.defines[n]=o[n]}}copy(e){this.id=e.id,this.type=e.type,this.defines=O({},e.defines);for(let t in e.uniforms)this.getName(t)==="transmissionSamplerMap"||this.getName(t)==="transmissionDepthMap"||(this.uniforms[t]?this.uniforms[t].copy(e.uniforms[t]):this.uniforms[t]=e.uniforms[t].clone());return this}clone(){return new Je(this.id).copy(this)}fromJSON(e,t){this.id=e.id,this.defines=O({},e.defines);for(let r in e.uniforms)this.uniforms[r]=t.getNode(e.uniforms[r]);if(e.type===Le.TEXTURE){if(!(`f${this.id}_textureSize`in this.uniforms)){let r=this.uniforms[`f${this.id}_texture`].value.image;this.uniforms[`f${e.id}_textureSize`]=new Mt(r.width,r.height)}`f${this.id}_size`in this.uniforms||(this.uniforms[`f${e.id}_size`]=new It(200,200)),`f${e.id}_axis`in this.uniforms||(this.uniforms[`f${e.id}_axis`]=new ve(0)),`f${e.id}_projection`in this.uniforms||(this.uniforms[`f${e.id}_projection`]=new ve(0))}else e.type===Le.NOISE?(`f${e.id}_noiseType`in this.uniforms||(this.uniforms[`f${e.id}_noiseType`]=new ve(0)),`f${e.id}_size`in this.uniforms||(this.uniforms[`f${e.id}_size`]=new Mt(-1,-1,-1))):e.type===Le.DEPTH&&(`f${e.id}_isWorldSpace`in this.uniforms||(this.uniforms[`f${e.id}_isWorldSpace`]=new ee(1)));return this}toJSON(e){let t={};for(let o in this.uniforms)t[o]=this.uniforms[o].toJSON(e).uuid;return{id:this.id,type:this.type,defines:JSON.parse(JSON.stringify(this.defines)),uniforms:t,next:this.next==null?void 0:this.next.toJSON(e)}}copyUniforms(e){for(let t in this.uniforms){let r=this.getName(t);r!==void 0&&e.uniforms[`f${e.id}_${r}`]&&r!=="transmissionDepthMap"&&r!=="transmissionSamplerMap"&&this.uniforms[t].copy(e.uniforms[`f${e.id}_${r}`])}return this}hasValueByKey(e){return this.uniforms[e]!==void 0}hasValue(e){return this.hasValueByKey(`f${this.id}_${e}`)}setValue(e,t){let r=`f${this.id}_${e}`;this.hasValueByKey(r)&&t!==void 0&&(this.uniforms[r].value=t)}getValue(e){let t=`f${this.id}_${e}`;if(this.hasValueByKey(t))return this.uniforms[t].value}getValues(){let e={type:this.type};for(let t in this.uniforms){let r=this.getName(t);if(r===void 0)continue;let n=this.uniforms[`f${this.id}_${r}`].value;n!==void 0&&(Array.isArray(n)?e[r]=n.map(s=>s.clone?s.clone():s):e[r]=n.clone?n.clone():n)}return e}getName(e){let r=/f\d+_(.*)/.exec(e);if(r&&r.length>1)return r[1];console.log(`Layer.getName: error ${e}`)}getNames(){let e=[];for(let t in this.uniforms){let r=this.getName(t);r&&e.push(r)}return e}isEqual(e){for(let t in e.uniforms){let r=e.getName(t);if(!r)return!1;let o=this.getValue(r),n=e.uniforms[t].value;if(n.value instanceof RS){if(o.image!==n.image)return!1}else if(Array.isArray(n)){let s=o;for(let a=0,l=s.length;a<l;++a)if(s[a]!==n[a])return!1}else{let s=o;if(s.equals){if(!s.equals(n))return!1}else if(o!==n)return!1}}return!0}dispose(){}};function Hh(i){let e=i instanceof Je?i.type:i;return e==="texture"||e==="displace_map"||e==="matcap"}var na=class extends Ue{constructor(e){super("b");this.nodeType="Bool";this.value=e!=null?e:!1}generateReadonly(e,t,r,o){return e.format(this.value?"true":"false",o,t)}copy(e){return super.copy(e),this.value=e.value,this}};import{Vector4 as qh}from"three";var yi=class extends Ue{constructor(e=1,t){super("v4[]");this.nodeType="Vector4Array";this.size=e,this.value=Array.isArray(t)?t:t instanceof qh?new Array(e).fill(t):new Array(e).fill(new qh(0))}copy(e){return super.copy(e),this.value=e.value.map(t=>t.clone()),this}};var gi=class extends Ue{constructor(e=1,t){super("f[]");this.nodeType="FloatArray";this.size=e,this.value=Array.isArray(t)?t:typeof t=="number"?new Array(e).fill(t):new Array(e).fill(0)}copy(e){return super.copy(e),this.size=e.size,this.value=[...e.value],this}};import{Matrix3 as VS}from"three";var Yi=class extends Ue{constructor(e){super("m3");this.nodeType="Matrix3";this.value=e!=null?e:new VS}generateReadonly(e,t,r,o,n,s){return e.format("mat3("+this.value.elements.join(", ")+")",o,t)}copy(e){return super.copy(e),this.elements=e.elements,this}get elements(){return this.value.elements}set elements(e){this.value.fromArray(e)}};var xi;(function(o){o[o.UV=0]="UV",o[o.PLANAR=1]="PLANAR",o[o.SPHERICAL=2]="SPHERICAL",o[o.CYLINDRICAL=3]="CYLINDRICAL"})(xi||(xi={}));var en=class extends ue{constructor(e=new Bt,t,r,o,n,s,a,l){super("v3");this.nodeType="CustomTexture";this.firstTime=!0,this.texture=e,this.textureSize=t,this.crop=r,this.projection=o,this.axis=n,this.size=s,this.mat=new Yi(this.texture.value.matrix),this.alpha=a,this.mode=l,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){e.require("position"),e.require("uv"),e.requires.uv=[!0],e.extensions.shaderTextureLOD=!0,e.extensions.derivatives=!0;let r;switch(this.projection.value){case 3:r=e.include(en.Nodes.cylindrical);break;case 2:r=e.include(en.Nodes.spherical);break;case 1:let n=new re(`
131
131
  vec3 g${this.uuid.toString().replace(/-/g,"")}_planarTexture(sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec2 size, float alpha, int mode, out float calpha) {
132
132
 
133
133
  vec2 uvs = ( mat * vec3( (g${this.uuid.toString().replace(/-/g,"")}_vCustomUv * 2. - 1.) / (size * .5), 1. ) / 2. + 0.5 ).xy;
@@ -144,25 +144,25 @@ var tm=Object.create;var Ti=Object.defineProperty,rm=Object.defineProperties,om=
144
144
  calpha = lalpha / clamp( lalpha + accumAlpha, 0.00001, 1.0 );
145
145
  accumAlpha += ( 1.0 - accumAlpha ) * lalpha;
146
146
  return col;
147
- }`);r=e.include(s);break;default:r=e.include(es.Nodes.uv);break}if(this.projection.value===1&&this.firstTime){let s=`g${this.uuid.toString().replace(/-/g,"")}`;e.addVertexParsCode(`varying vec2 ${s}_vCustomUv;`),e.addFragmentParsCode(`varying vec2 ${s}_vCustomUv;`),e.addVertexFinalCode(`
148
- vec3 ${s}_posN = transformed;
147
+ }`);r=e.include(n);break;default:r=e.include(en.Nodes.uv);break}if(this.projection.value===1&&this.firstTime){let n=`g${this.uuid.toString().replace(/-/g,"")}`;e.addVertexParsCode(`varying vec2 ${n}_vCustomUv;`),e.addFragmentParsCode(`varying vec2 ${n}_vCustomUv;`),e.addVertexFinalCode(`
148
+ vec3 ${n}_posN = transformed;
149
149
  ${this.axis.value===0?`
150
- float ${s}_u = (1. + (${s}_posN.z)) / 2.;
151
- float ${s}_v = (1. + (${s}_posN.y)) / 2.;
150
+ float ${n}_u = (1. + (${n}_posN.z)) / 2.;
151
+ float ${n}_v = (1. + (${n}_posN.y)) / 2.;
152
152
  `:""}
153
153
 
154
154
  ${this.axis.value===1?`
155
- float ${s}_u = (1. + (${s}_posN.x)) / 2.;
156
- float ${s}_v = (1. - (${s}_posN.z)) / 2.;
155
+ float ${n}_u = (1. + (${n}_posN.x)) / 2.;
156
+ float ${n}_v = (1. - (${n}_posN.z)) / 2.;
157
157
  `:""}
158
158
 
159
159
  ${this.axis.value===2?`
160
- float ${s}_u = (1. + (${s}_posN.x)) / 2.;
161
- float ${s}_v = (1. + (${s}_posN.y)) / 2.;
160
+ float ${n}_u = (1. + (${n}_posN.x)) / 2.;
161
+ float ${n}_v = (1. + (${n}_posN.y)) / 2.;
162
162
  `:""}
163
163
 
164
- ${s}_vCustomUv = vec2(${s}_u, ${s}_v);
165
- `)}e.addFragmentVariable(this.calpha,"float");let o=[];return o.push(this.texture.getTexture(e,"t")),o.push(this.textureSize.build(e,"v2")),o.push(this.crop.build(e,"f")),o.push(this.mat.build(e,"mat3")),o.push(this.size.build(e,"v2")),o.push(this.alpha.build(e,"f")),o.push(this.mode.build(e,"i")),o.push(this.calpha),this.firstTime=!this.firstTime,e.format(r+"("+o.join(",")+")",this.getType(e),t)}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.texture=this.texture.toJSON(e).uuid,t.textureSize=this.textureSize.toJSON(e).uuid,t.crop=this.crop.toJSON(e).uuid,t.projection=this.projection.toJSON(e).uuid,t.axis=this.axis.toJSON(e).uuid,t.size=this.size.toJSON(e).uuid,t.alpha=this.alpha.toJSON(e).uuid,t.mode=this.mode.toJSON(e).uuid,t.calpha=this.calpha),t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),e.texture&&(this.texture=t.getNode(e.texture),this.texture.value.updateMatrix(),this.mat=new To(this.texture.value.matrix)),e.textureSize&&(this.textureSize=t.getNode(e.textureSize)),e.crop&&(this.crop=t.getNode(e.crop)),e.projection&&(this.projection=t.getNode(e.projection)),e.axis&&(this.axis=t.getNode(e.axis)),e.size&&(this.size=t.getNode(e.size)),e.alpha&&(this.alpha=t.getNode(e.alpha)),e.mode&&(this.mode=t.getNode(e.mode)),e.calpha&&(this.calpha=e.calpha),this}copy(e){return super.copy(e),this.texture.copy(e.texture),this.textureSize=e.textureSize.clone(),this.crop=e.crop.clone(),this.projection=e.projection.clone(),this.axis=e.axis.clone(),this.size=e.size.clone(),this.alpha=e.alpha.clone(),this.mode=e.mode.clone(),this}},ga=es;ga.Nodes=function(){let e=new oe(`
164
+ ${n}_vCustomUv = vec2(${n}_u, ${n}_v);
165
+ `)}e.addFragmentVariable(this.calpha,"float");let o=[];return o.push(this.texture.getTexture(e,"t")),o.push(this.textureSize.build(e,"v2")),o.push(this.crop.build(e,"f")),o.push(this.mat.build(e,"mat3")),o.push(this.size.build(e,"v2")),o.push(this.alpha.build(e,"f")),o.push(this.mode.build(e,"i")),o.push(this.calpha),this.firstTime=!this.firstTime,e.format(r+"("+o.join(",")+")",this.getType(e),t)}copy(e){return super.copy(e),this.texture.copy(e.texture),this.textureSize=e.textureSize.clone(),this.crop=e.crop.clone(),this.projection=e.projection.clone(),this.axis=e.axis.clone(),this.size=e.size.clone(),this.alpha=e.alpha.clone(),this.mode=e.mode.clone(),this}},sa=en;sa.Nodes=function(){let e=new re(`
166
166
  vec3 cylindricalTexture(sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec2 size, float alpha, int mode, out float calpha) {
167
167
  vec3 posN = normalize(position);
168
168
  float u = 0.5 + atan(posN.z, posN.x) / (2.*3.1415);
@@ -192,7 +192,7 @@ vec3 cylindricalTexture(sampler2D tex, vec2 textureSize, float crop, mat3 mat, v
192
192
  accumAlpha += ( 1.0 - accumAlpha ) * lalpha;
193
193
  return col;
194
194
  }
195
- `),t=new oe(`
195
+ `),t=new re(`
196
196
  vec3 sphericalTexture(sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec2 size, float alpha, int mode, out float calpha) {
197
197
  vec3 posN = normalize(vPosition);
198
198
  float u = 0.5 + atan(posN.z, posN.x) / (2.*3.1415);
@@ -220,7 +220,7 @@ vec3 sphericalTexture(sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec
220
220
  accumAlpha += ( 1.0 - accumAlpha ) * lalpha;
221
221
  return col;
222
222
  }
223
- `),r=new oe(`vec3 uvTexture(sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec2 size, float alpha, int mode, out float calpha) {
223
+ `),r=new re(`vec3 uvTexture(sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec2 size, float alpha, int mode, out float calpha) {
224
224
 
225
225
  vec2 uvs = ( mat * vec3( vUv * 2. - 1., 1. ) / 2. + 0.5 ).xy;
226
226
  vec4 tmp = texture2D( tex, uvs );
@@ -236,14 +236,14 @@ vec3 sphericalTexture(sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec
236
236
  calpha = lalpha / clamp( lalpha + accumAlpha, 0.00001, 1.0 );
237
237
  accumAlpha += ( 1.0 - accumAlpha ) * lalpha;
238
238
  return col;
239
- }`);return{cylindrical:e,spherical:t,uv:r}}();var ec=class extends me{constructor(e,t,r,o,s,n,a){super("v3");this.nodeType="Fresnel";this.color=e,this.bias=t,this.scale=r,this.intensity=o,this.factor=s,this.alpha=n,this.mode=a,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){if(e.require("vWorldViewDir"),e.require("worldNormal"),e.isShader("fragment")){e.addFragmentVariable(this.calpha,"float");let r=e.include(ec.Nodes.fresnel),o=[];return o.push(this.color.build(e,"c")),o.push(this.bias.build(e,"f")),o.push(this.scale.build(e,"f")),o.push(this.intensity.build(e,"f")),o.push(this.factor.build(e,"f")),o.push(this.alpha.build(e,"f")),o.push(this.mode.build(e,"i")),o.push(this.calpha),e.format(r+"("+o.join(",")+")",this.getType(e),t)}else return console.warn("FresnelNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.color=this.color.toJSON(e).uuid,t.bias=this.bias.toJSON(e).uuid,t.scale=this.scale.toJSON(e).uuid,t.intensity=this.intensity.toJSON(e).uuid,t.factor=this.factor.toJSON(e).uuid,t.alpha=this.alpha.toJSON(e).uuid,t.mode=this.mode.toJSON(e).uuid,t.calpha=this.calpha),t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),e.color&&(this.color=t.getNode(e.color)),e.bias&&(this.bias=t.getNode(e.bias)),e.scale&&(this.scale=t.getNode(e.scale)),e.intensity&&(this.intensity=t.getNode(e.intensity)),e.factor&&(this.factor=t.getNode(e.factor)),e.alpha&&(this.alpha=t.getNode(e.alpha)),e.mode&&(this.mode=t.getNode(e.mode)),e.calpha&&(this.calpha=e.calpha),this}copy(e){return super.copy(e),this.color=e.color.clone(),this.bias=e.bias.clone(),this.scale=e.scale.clone(),this.intensity=e.intensity.clone(),this.factor=e.factor.clone(),this.alpha=e.alpha.clone(),this.mode=e.mode.clone(),this.calpha=e.calpha,this}},ya=ec;ya.Nodes=function(){return{fresnel:new oe(`vec3 fresnel(vec3 color, float bias, float scale, float intensity, float factor, float alpha, int mode, out float calpha) {
239
+ }`);return{cylindrical:e,spherical:t,uv:r}}();var Fl=class extends ue{constructor(e,t,r,o,n,s,a){super("v3");this.nodeType="Fresnel";this.color=e,this.bias=t,this.scale=r,this.intensity=o,this.factor=n,this.alpha=s,this.mode=a,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){if(e.require("vWorldViewDir"),e.require("worldNormal"),e.isShader("fragment")){e.addFragmentVariable(this.calpha,"float");let r=e.include(Fl.Nodes.fresnel),o=[];return o.push(this.color.build(e,"c")),o.push(this.bias.build(e,"f")),o.push(this.scale.build(e,"f")),o.push(this.intensity.build(e,"f")),o.push(this.factor.build(e,"f")),o.push(this.alpha.build(e,"f")),o.push(this.mode.build(e,"i")),o.push(this.calpha),e.format(r+"("+o.join(",")+")",this.getType(e),t)}else return console.warn("FresnelNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}copy(e){return super.copy(e),this.color=e.color.clone(),this.bias=e.bias.clone(),this.scale=e.scale.clone(),this.intensity=e.intensity.clone(),this.factor=e.factor.clone(),this.alpha=e.alpha.clone(),this.mode=e.mode.clone(),this.calpha=e.calpha,this}},aa=Fl;aa.Nodes=function(){return{fresnel:new re(`vec3 fresnel(vec3 color, float bias, float scale, float intensity, float factor, float alpha, int mode, out float calpha) {
240
240
  float fresnel = bias + scale * pow( abs( factor + dot( normalize( vWorldViewDir ), normalize( vWNormal ) ) ), intensity );
241
241
 
242
242
  float lalpha = clamp( fresnel, 0.0, 1.0 ) * alpha;
243
243
  calpha = lalpha / clamp(lalpha + accumAlpha, 0.001, 1.0);
244
244
  accumAlpha += (1.0 - accumAlpha) * lalpha;
245
245
  return color;
246
- }`)}}();var vi;(function(s){s.SIMPLEX="simplex3d",s.SIMPLEX_FRACTAL="simplex3dFractal",s.ASHIMA="simplexAshima",s.FBM="fbm",s.PERLIN="perlin"})(vi||(vi={}));var zt=function(){let i=5,e=new oe(`vec3 random3(vec3 c) {
246
+ }`)}}();var bi;(function(n){n.SIMPLEX="simplex3d",n.SIMPLEX_FRACTAL="simplex3dFractal",n.ASHIMA="simplexAshima",n.FBM="fbm",n.PERLIN="perlin"})(bi||(bi={}));var Gt=function(){let i=5,e=new re(`vec3 random3(vec3 c) {
247
247
  float j = 4096.0*sin(dot(c,vec3(17.0, 59.4, 15.0)));
248
248
  vec3 r;
249
249
  r.z = fract(512.0*j);
@@ -252,7 +252,7 @@ vec3 sphericalTexture(sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec
252
252
  j *= .125;
253
253
  r.y = fract(512.0*j);
254
254
  return r-0.5;
255
- }`),t=new oe(`float simplex3d(vec3 p) {
255
+ }`),t=new re(`float simplex3d(vec3 p) {
256
256
  vec3 s = floor(p + dot(p, vec3(F3)));
257
257
  vec3 x = p - s + dot(s, vec3(G3));
258
258
 
@@ -283,7 +283,7 @@ vec3 sphericalTexture(sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec
283
283
  d *= w;
284
284
 
285
285
  return dot(d, vec4(52.0));
286
- }`,[e]);t.keywords.F3=new Me("float F3 0.3333333"),t.keywords.G3=new Me("float G3 0.1666667");let r=new oe(`float simplex3dFractal(vec3 m) {
286
+ }`,[e]);t.keywords.F3=new Ie("float F3 0.3333333"),t.keywords.G3=new Ie("float G3 0.1666667");let r=new re(`float simplex3dFractal(vec3 m) {
287
287
  mat3 rot1 = mat3(-0.37, 0.36, 0.85,-0.14,-0.93, 0.34,0.92, 0.01,0.4);
288
288
  mat3 rot2 = mat3(-0.55,-0.39, 0.74, 0.33,-0.91,-0.24,0.77, 0.12,0.63);
289
289
  mat3 rot3 = mat3(-0.71, 0.52,-0.47,-0.08,-0.72,-0.68,-0.7,-0.45,0.56);
@@ -291,7 +291,7 @@ vec3 sphericalTexture(sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec
291
291
  + 0.2666667 * simplex3d(2.0 * m * rot2)
292
292
  + 0.1333333 * simplex3d(4.0 * m * rot3)
293
293
  + 0.0666667 * simplex3d(8.0 * m);
294
- }`,[t]),o=new oe("vec4 permute(vec4 x){return mod(((x*34.0)+1.0)*x, 289.0);}"),s=new oe("vec4 taylorInvSqrt(vec4 r){return 1.79284291400159 - 0.85373472095314 * r;}"),n=new oe(`float simplexAshima(vec3 v) {
294
+ }`,[t]),o=new re("vec4 permute(vec4 x){return mod(((x*34.0)+1.0)*x, 289.0);}"),n=new re("vec4 taylorInvSqrt(vec4 r){return 1.79284291400159 - 0.85373472095314 * r;}"),s=new re(`float simplexAshima(vec3 v) {
295
295
  const vec2 C = vec2(1.0/6.0, 1.0/3.0) ;
296
296
  const vec4 D = vec4(0.0, 0.5, 1.0, 2.0);
297
297
  vec3 i = floor(v + dot(v, C.yyy) );
@@ -336,7 +336,7 @@ vec3 sphericalTexture(sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec
336
336
  m = m * m;
337
337
  return 42.0 * dot( m*m, vec4( dot(p0,x0), dot(p1,x1),
338
338
  dot(p2,x2), dot(p3,x3) ) );
339
- }`,[o,s]),a=new oe("vec4 mod289(vec4 x){return x - floor(x * (1.0 / 289.0)) * 289.0;}"),l=new oe("vec4 perm(vec4 x){return mod289(((x * 34.0) + 1.0) * x);}",[a]),c=new oe(`float noise(vec3 p){
339
+ }`,[o,n]),a=new re("vec4 mod289(vec4 x){return x - floor(x * (1.0 / 289.0)) * 289.0;}"),l=new re("vec4 perm(vec4 x){return mod289(((x * 34.0) + 1.0) * x);}",[a]),c=new re(`float noise(vec3 p){
340
340
  vec3 a = floor(p);
341
341
  vec3 d = p - a;
342
342
  d = d * d * (3.0 - 2.0 * d);
@@ -351,7 +351,7 @@ vec3 sphericalTexture(sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec
351
351
  vec4 o3 = o2 * d.z + o1 * (1.0 - d.z);
352
352
  vec2 o4 = o3.yw * d.x + o3.xz * (1.0 - d.x);
353
353
  return o4.y * d.y + o4.x * (1.0 - d.y);
354
- }`,[l]),d=new oe(`float fbm(vec3 x) {
354
+ }`,[l]),d=new re(`float fbm(vec3 x) {
355
355
  float v = 0.0;
356
356
  float a = 0.5;
357
357
  vec3 shift = vec3(100);
@@ -361,7 +361,7 @@ vec3 sphericalTexture(sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec
361
361
  a *= 0.5;
362
362
  }
363
363
  return v;
364
- }`,[c]);d.keywords.NUM_OCTAVES=new Me(`int NUM_OCTAVES ${i}`);let h=new oe("vec3 fade(vec3 t) {return t*t*t*(t*(t*6.0-15.0)+10.0);}"),p=new oe(`float perlin(vec3 P){
364
+ }`,[c]);d.keywords.NUM_OCTAVES=new Ie(`int NUM_OCTAVES ${i}`);let p=new re("vec3 fade(vec3 t) {return t*t*t*(t*(t*6.0-15.0)+10.0);}"),u=new re(`float perlin(vec3 P){
365
365
  vec3 Pi0 = floor(P);
366
366
  vec3 Pi1 = Pi0 + vec3(1.0);
367
367
  Pi0 = mod(Pi0, 289.0);
@@ -420,8 +420,7 @@ vec3 sphericalTexture(sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec
420
420
  vec2 n_yz = mix(n_z.xy, n_z.zw, fade_xyz.y);
421
421
  float n_xyz = mix(n_yz.x, n_yz.y, fade_xyz.x);
422
422
  return 2.2 * n_xyz;
423
- }`,[o,s,h]);return{simplex:t,simplexFractal:r,simplexAshima:n,fbm:d,perlin:p}}();var tc=class extends me{constructor(e,t,r,o,s,n,a){super("v3");this.nodeType="Rainbow";this.filmThickness=e,this.movement=t,this.wavelengths=r,this.noiseStrength=o,this.noiseScale=s,this.offset=n,this.alpha=a,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){if(e.isShader("fragment")){e.require("normal"),e.require("uv"),e.requires.uv=[!0],e.addFragmentVariable(this.calpha,"float");let r=e.include(tc.Nodes.rainbow),o=[];return o.push(this.filmThickness.build(e,"f")),o.push(this.movement.build(e,"f")),o.push(this.wavelengths.build(e,"v3")),o.push(this.noiseStrength.build(e,"f")),o.push(this.noiseScale.build(e,"f")),o.push(this.offset.build(e,"v3")),o.push(this.alpha.build(e,"f")),o.push(this.calpha),e.format(r+"("+o.join(",")+")",this.getType(e),t)}else return console.warn("RainbowNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.filmThickness=this.filmThickness.toJSON(e).uuid,t.movement=this.movement.toJSON(e).uuid,t.wavelengths=this.wavelengths.toJSON(e).uuid,t.noiseStrength=this.noiseStrength.toJSON(e).uuid,t.noiseScale=this.noiseScale.toJSON(e).uuid,t.offset=this.offset.toJSON(e).uuid,t.alpha=this.alpha.toJSON(e).uuid,t.calpha=this.calpha),t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),e.filmThickness&&(this.filmThickness=t.getNode(e.filmThickness)),e.movement&&(this.movement=t.getNode(e.movement)),e.wavelengths&&(this.wavelengths=t.getNode(e.wavelengths)),e.noiseStrength&&(this.noiseStrength=t.getNode(e.noiseStrength)),e.noiseScale&&(this.noiseScale=t.getNode(e.noiseScale)),e.offset&&(this.offset=t.getNode(e.offset)),e.alpha&&(this.alpha=t.getNode(e.alpha)),e.calpha&&(this.calpha=e.calpha),this}copy(e){return super.copy(e),this.filmThickness=e.filmThickness.clone(),this.movement=e.movement.clone(),this.wavelengths=e.wavelengths.clone(),this.noiseStrength=e.noiseStrength.clone(),this.noiseScale=e.noiseScale.clone(),this.offset=e.offset.clone(),this.alpha=e.alpha.clone(),this.calpha=e.calpha,this}},xa=tc;xa.Nodes=function(){let e=new oe(`vec3 attenuation(vec3 wavelengths, float filmThickness, float movement, float noiseStrength, float noiseScale, vec3 offset) {
424
- vec3 viewDir = normalize(-(cameraPosition + offset));
423
+ }`,[o,n,p]);return{simplex:t,simplexFractal:r,simplexAshima:s,fbm:d,perlin:u}}();var Rl=class extends ue{constructor(e,t,r,o,n,s,a){super("v3");this.nodeType="Rainbow";this.filmThickness=e,this.movement=t,this.wavelengths=r,this.noiseStrength=o,this.noiseScale=n,this.offset=s,this.alpha=a,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){if(e.require("vWorldViewDir"),e.require("worldNormal"),e.isShader("fragment")){e.require("uv"),e.requires.uv=[!0],e.addFragmentVariable(this.calpha,"float");let r=e.include(Rl.Nodes.rainbow),o=[];return o.push(this.filmThickness.build(e,"f")),o.push(this.movement.build(e,"f")),o.push(this.wavelengths.build(e,"v3")),o.push(this.noiseStrength.build(e,"f")),o.push(this.noiseScale.build(e,"f")),o.push(this.offset.build(e,"v3")),o.push(this.alpha.build(e,"f")),o.push(this.calpha),e.format(r+"("+o.join(",")+")",this.getType(e),t)}else return console.warn("RainbowNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}copy(e){return super.copy(e),this.filmThickness=e.filmThickness.clone(),this.movement=e.movement.clone(),this.wavelengths=e.wavelengths.clone(),this.noiseStrength=e.noiseStrength.clone(),this.noiseScale=e.noiseScale.clone(),this.offset=e.offset.clone(),this.alpha=e.alpha.clone(),this.calpha=e.calpha,this}},la=Rl;la.Nodes=function(){let e=new re(`vec3 attenuation(vec3 wavelengths, float filmThickness, float movement, float noiseStrength, float noiseScale, vec3 offset) {
425
424
  vec3 st = position / noiseScale;
426
425
  vec3 q = vec3(simplex3d(st),
427
426
  simplex3d(st + vec3(1.0)),
@@ -433,8 +432,8 @@ vec3 sphericalTexture(sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec
433
432
 
434
433
  float noise = simplex3d(st + r);
435
434
 
436
- return .5 + .5 * cos((((filmThickness + (noise * noiseStrength)) / (vec3(wavelengths.r * 1.0, wavelengths.g * 0.8, wavelengths.b * 0.6) + 1.0)) * dot(normalize(vObjectNormal), viewDir)) + movement);
437
- }`,[zt.simplex]);return{rainbow:new oe(`vec3 rainbow(float filmThickness, float movement, vec3 wavelengths, float noiseStrength, float noiseScale, vec3 offset, float alpha, out float calpha) {
435
+ return .5 + .5 * cos((((filmThickness + (noise * noiseStrength)) / (vec3(wavelengths.r * 1.0, wavelengths.g * 0.8, wavelengths.b * 0.6) + 1.0)) * dot(normalize(vWorldViewDir + (offset * -0.001)), normalize(vWNormal))) + movement);
436
+ }`,[Gt.simplex]);return{rainbow:new re(`vec3 rainbow(float filmThickness, float movement, vec3 wavelengths, float noiseStrength, float noiseScale, vec3 offset, float alpha, out float calpha) {
438
437
  vec3 res = clamp(attenuation(wavelengths, filmThickness, movement, noiseStrength, noiseScale, offset), 0.0, 2.0);
439
438
 
440
439
  float rainbowContribution = clamp(res.r + res.g + res.b, 0.0, 1.0);
@@ -443,11 +442,11 @@ vec3 sphericalTexture(sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec
443
442
  accumAlpha += ( 1.0 - accumAlpha ) * lalpha;
444
443
 
445
444
  return res;
446
- }`,[e])}}();var rc=class extends me{constructor(e,t,r,o,s,n,a,l){super("v3");this.nodeType="Transmission";this.thickness=e,this.ior=t,this.roughness=r,this.transmissionSamplerSize=o,this.transmissionSamplerMap=s,this.transmissionDepthMap=n,this.aspectRatio=a,this.alpha=l,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){if(e.extensions.shaderTextureLOD=!0,e.extensions.derivatives=!0,e.isShader("fragment")){e.define("NUM_SAMPLES",30),e.require("worldPosition"),e.requires.worldNormal=!0,e.requires.modelMatrix=!0,e.requires.projectionMatrix=!0,e.addFragmentVariable(this.calpha,"float");let r=e.include(rc.Nodes.transmission),o=[];return o.push(this.thickness.build(e,"f")),o.push(this.ior.build(e,"f")),o.push(this.roughness.build(e,"f")),o.push(this.transmissionSamplerSize.build(e,"v2")),o.push(this.transmissionSamplerMap.getTexture(e,"t")),o.push(this.transmissionDepthMap.getTexture(e,"t")),o.push(this.aspectRatio.build(e,"v2")),o.push("normal"),o.push(this.alpha.build(e,"f")),o.push(this.calpha),e.format(r+"("+o.join(",")+")",this.getType(e),t)}else return console.warn("TransmissionNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.thickness=this.thickness.toJSON(e).uuid,t.ior=this.ior.toJSON(e).uuid,t.roughness=this.roughness.toJSON(e).uuid,t.alpha=this.alpha.toJSON(e).uuid,t.calpha=this.calpha),t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),e.thickness&&(this.thickness=t.getNode(e.thickness)),e.ior&&(this.ior=t.getNode(e.ior)),e.roughness&&(this.roughness=t.getNode(e.roughness)),e.alpha&&(this.alpha=t.getNode(e.alpha)),e.calpha&&(this.calpha=e.calpha),this}copy(e){return super.copy(this),this.thickness=e.thickness.clone(),this.ior=e.ior.clone(),this.roughness=e.roughness.clone(),this.transmissionSamplerSize=e.transmissionSamplerSize.clone(),this.transmissionSamplerMap=e.transmissionSamplerMap,this.transmissionDepthMap=e.transmissionDepthMap,this.alpha=e.alpha.clone(),this.calpha=e.calpha,this}},ba=rc;ba.Nodes=function(){let e=new oe(`
445
+ }`,[e])}}();var Vl=class extends ue{constructor(e,t,r,o,n,s,a,l){super("v3");this.nodeType="Transmission";this.thickness=e,this.ior=t,this.roughness=r,this.transmissionSamplerSize=o,this.transmissionSamplerMap=n,this.transmissionDepthMap=s,this.aspectRatio=a,this.alpha=l,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){if(e.extensions.shaderTextureLOD=!0,e.extensions.derivatives=!0,e.isShader("fragment")){e.define("NUM_SAMPLES",30),e.require("worldPosition"),e.requires.worldNormal=!0,e.requires.modelMatrix=!0,e.requires.projectionMatrix=!0,e.addFragmentVariable(this.calpha,"float");let r=e.include(Vl.Nodes.transmission),o=[];return o.push(this.thickness.build(e,"f")),o.push(this.ior.build(e,"f")),o.push(this.roughness.build(e,"f")),o.push(this.transmissionSamplerSize.build(e,"v2")),o.push(this.transmissionSamplerMap.getTexture(e,"t")),o.push(this.transmissionDepthMap.getTexture(e,"t")),o.push(this.aspectRatio.build(e,"v2")),o.push("normal"),o.push(this.alpha.build(e,"f")),o.push(this.calpha),e.format(r+"("+o.join(",")+")",this.getType(e),t)}else return console.warn("TransmissionNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}copy(e){return super.copy(this),this.thickness=e.thickness.clone(),this.ior=e.ior.clone(),this.roughness=e.roughness.clone(),this.transmissionSamplerSize=e.transmissionSamplerSize.clone(),this.transmissionSamplerMap=e.transmissionSamplerMap,this.transmissionDepthMap=e.transmissionDepthMap,this.alpha=e.alpha.clone(),this.calpha=e.calpha,this}},ca=Vl;ca.Nodes=function(){let e=new re(`
447
446
  float gaussian(vec2 i) {
448
447
  const float sigma = float(NUM_SAMPLES) * .25;
449
448
  return exp( -.5* dot(i/=sigma,i) ) / ( 6.28 * sigma*sigma );
450
- }`),t=new oe(`
449
+ }`),t=new re(`
451
450
  vec4 blur(sampler2D sp, vec2 U, vec2 scale, float lod, sampler2D dm, vec2 unrefractedU, vec2 aspectRatio) {
452
451
  // Slightly modified version of this:
453
452
  // https://www.shadertoy.com/view/ltScRG
@@ -474,7 +473,7 @@ vec3 sphericalTexture(sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec
474
473
  #endif
475
474
  }
476
475
  return O / O.a;
477
- }`,[e]),r=new oe(`
476
+ }`,[e]),r=new re(`
478
477
  vec3 getVolumeTransmissionRay( vec3 n, vec3 v, float thickness, float ior, mat4 modelMatrix ) {
479
478
  // Direction of refracted light.
480
479
  vec3 refractionVector = refract( -v, n, 1.0 / ior );
@@ -485,18 +484,18 @@ vec3 sphericalTexture(sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec
485
484
  modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );
486
485
  // The thickness is specified in local space.
487
486
  return normalize( refractionVector ) * thickness * modelScale;
488
- }`),o=new oe(`
487
+ }`),o=new re(`
489
488
  float applyIorToRoughness( float roughness, float ior ) {
490
489
  // Scale roughness with IOR so that an IOR of 1.0 results in no microfacet refraction and
491
490
  // an IOR of 1.5 results in the default amount of microfacet refraction.
492
491
  return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );
493
- } `),s=new oe(`
492
+ } `),n=new re(`
494
493
  vec4 getTransmissionSample( vec2 fragCoord, float roughness, float ior, vec2 transmissionSamplerSize, sampler2D transmissionSamplerMap, sampler2D transmissionDepthMap, vec2 unrefractedCoords, vec2 aspectRatio) {
495
494
  float framebufferLod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );
496
495
  float lod = applyIorToRoughness(roughness, ior);
497
496
 
498
497
  return blur(transmissionSamplerMap, fragCoord, vec2(lod / (transmissionSamplerSize.x / 2.)), min(framebufferLod / 5.5, 8.5), transmissionDepthMap, unrefractedCoords, aspectRatio);
499
- }`,[o,t]),n=new oe(`
498
+ }`,[o,t]),s=new re(`
500
499
  vec4 getIBLVolumeRefraction( vec3 n, vec3 v, float roughness, vec3 position, mat4 modelMatrix, mat4 viewMatrix, mat4 projMatrix, float ior, float thickness, vec2 transmissionSamplerSize, sampler2D transmissionSamplerMap, sampler2D transmissionDepthMap, vec2 aspectRatio ) {
501
500
  vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );
502
501
  vec3 refractedRayExit = position + transmissionRay;
@@ -516,7 +515,7 @@ vec4 getIBLVolumeRefraction( vec3 n, vec3 v, float roughness, vec3 position, mat
516
515
  vec4 transmittedLight = getTransmissionSample( refractionCoords, roughness, ior, transmissionSamplerSize, transmissionSamplerMap, transmissionDepthMap, unrefractedCoords, aspectRatio );
517
516
  // Get the specular component.
518
517
  return vec4( ( 1.0 ) * transmittedLight.rgb, transmittedLight.a );
519
- }`,[s,r]);return{transmission:new oe(`
518
+ }`,[n,r]);return{transmission:new re(`
520
519
  vec3 transmission(float thickness, float ior, float roughness, vec2 transmissionSamplerSize, sampler2D transmissionSamplerMap, sampler2D transmissionDepthMap, vec2 aspectRatio, vec3 normal, float alpha, out float calpha) {
521
520
  vec3 v = vec3(0.);
522
521
  if (isOrthographic) {
@@ -530,14 +529,14 @@ vec4 getIBLVolumeRefraction( vec3 n, vec3 v, float roughness, vec3 position, mat
530
529
  calpha = lalpha / clamp( lalpha + accumAlpha, 0.00001, 1.0 );
531
530
  accumAlpha += ( 1.0 - accumAlpha ) * lalpha;
532
531
  return transmission.rgb;
533
- }`,[n])}}();var oc=class extends me{constructor(e,t){super("v3");this.nodeType="CustomNormal";this.cnormal=e,this.alpha=t}generate(e,t){if(e.isShader("fragment")){let r=e.include(oc.Nodes.customNormal),o=[];return o.push(this.cnormal.build(e,"v3")),o.push("normal"),o.push(this.alpha.build(e,"f")),e.format(r+"("+o.join(",")+")",this.getType(e),t)}else return console.warn("CustomNormalNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.cnormal=this.cnormal.toJSON(e).uuid,t.alpha=this.alpha.toJSON(e).uuid),t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),e.cnormal&&(this.cnormal=t.getNode(e.cnormal)),e.alpha&&(this.alpha=t.getNode(e.alpha)),this}copy(e){return super.copy(e),this.cnormal.copy(e.cnormal),this.alpha.copy(e.alpha),this}},va=oc;va.Nodes=function(){return{customNormal:new oe(`vec3 customNormal(vec3 cnormal, vec3 norm, float alpha) {
532
+ }`,[s])}}();var Ul=class extends ue{constructor(e,t){super("v3");this.nodeType="CustomNormal";this.cnormal=e,this.alpha=t}generate(e,t){if(e.isShader("fragment")){let r=e.include(Ul.Nodes.customNormal),o=[];return o.push(this.cnormal.build(e,"v3")),o.push("normal"),o.push(this.alpha.build(e,"f")),e.format(r+"("+o.join(",")+")",this.getType(e),t)}else return console.warn("CustomNormalNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}copy(e){return super.copy(e),this.cnormal.copy(e.cnormal),this.alpha.copy(e.alpha),this}},da=Ul;da.Nodes=function(){return{customNormal:new re(`vec3 customNormal(vec3 cnormal, vec3 norm, float alpha) {
534
533
  vec3 normal = packNormalToRGB( norm ).rgb;
535
534
  normal *= step( vec3(0.5), cnormal );
536
535
 
537
536
  accumAlpha += ( 1.0 - accumAlpha ) * alpha;
538
537
 
539
538
  return normal;
540
- }`)}}();var ic=class extends me{constructor(e,t,r,o,s,n,a,l){super("v3");this.nodeType="Gradient";this.gradientType=e,this.smooth=t,this.colors=r,this.steps=o,this.offset=s,this.morph=n,this.angle=a,this.alpha=l,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){if(e.isShader("fragment")){e.define("GRAD_MAX",10),e.require("uv"),e.requires.uv=[!0],e.addFragmentVariable(this.calpha,"float");let r=e.include(ic.Nodes.gradient),o=[];return o.push(this.gradientType.build(e,"i")),o.push(this.smooth.build(e,"b")),o.push(this.colors.build(e,"v4[]")),o.push(this.steps.build(e,"f[]")),o.push(this.offset.build(e,"v2")),o.push(this.morph.build(e,"v2")),o.push(this.angle.build(e,"f")),o.push(this.alpha.build(e,"f")),o.push(this.calpha),e.format(r+"("+o.join(",")+")",this.getType(e),t)}else return console.warn("GradientNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.gradientType=this.gradientType.toJSON(e).uuid,t.smooth=this.smooth.toJSON(e).uuid,t.colors=this.colors.toJSON(e).uuid,t.steps=this.steps.toJSON(e).uuid,t.offset=this.offset.toJSON(e).uuid,t.morph=this.morph.toJSON(e).uuid,t.angle=this.angle.toJSON(e).uuid,t.alpha=this.alpha.toJSON(e).uuid,t.calpha=this.calpha),t.nodeType=this.nodeType,t}copy(e){return super.copy(e),this.gradientType=e.gradientType.clone(),this.smooth=e.smooth.clone(),this.colors=e.colors.clone(),this.steps=e.steps.clone(),this.offset=e.offset.clone(),this.morph=e.morph.clone(),this.angle=e.angle.clone(),this.alpha=e.alpha.clone(),this.calpha=e.calpha,this}fromJSON(e,t){return super.fromJSON(e,t),e.calpha&&(this.calpha=e.calpha),e.gradientType&&(this.gradientType=t.getNode(e.gradientType)),e.smooth&&(this.smooth=t.getNode(e.smooth)),e.colors&&(this.colors=t.getNode(e.colors)),e.steps&&(this.steps=t.getNode(e.steps)),e.offset&&(this.offset=t.getNode(e.offset)),e.morph&&(this.morph=t.getNode(e.morph)),e.angle&&(this.angle=t.getNode(e.angle)),e.alpha&&(this.alpha=t.getNode(e.alpha)),this}},Sa=ic;Sa.Nodes=function(){return{gradient:new oe(`vec3 gradient(int gradientType, bool smoothed, vec4 colors[GRAD_MAX], float steps[GRAD_MAX], vec2 offset, vec2 morph, float angle, float alpha, out float calpha) {
539
+ }`)}}();var kl=class extends ue{constructor(e,t,r,o,n,s,a,l){super("v3");this.nodeType="Gradient";this.gradientType=e,this.smooth=t,this.colors=r,this.steps=o,this.offset=n,this.morph=s,this.angle=a,this.alpha=l,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){if(e.isShader("fragment")){e.define("GRAD_MAX",10),e.require("uv"),e.requires.uv=[!0],e.addFragmentVariable(this.calpha,"float");let r=e.include(kl.Nodes.gradient),o=[];return o.push(this.gradientType.build(e,"i")),o.push(this.smooth.build(e,"b")),o.push(this.colors.build(e,"v4[]")),o.push(this.steps.build(e,"f[]")),o.push(this.offset.build(e,"v2")),o.push(this.morph.build(e,"v2")),o.push(this.angle.build(e,"f")),o.push(this.alpha.build(e,"f")),o.push(this.calpha),e.format(r+"("+o.join(",")+")",this.getType(e),t)}else return console.warn("GradientNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}copy(e){return super.copy(e),this.gradientType=e.gradientType.clone(),this.smooth=e.smooth.clone(),this.colors=e.colors.clone(),this.steps=e.steps.clone(),this.offset=e.offset.clone(),this.morph=e.morph.clone(),this.angle=e.angle.clone(),this.alpha=e.alpha.clone(),this.calpha=e.calpha,this}},pa=kl;pa.Nodes=function(){return{gradient:new re(`vec3 gradient(int gradientType, bool smoothed, vec4 colors[GRAD_MAX], float steps[GRAD_MAX], vec2 offset, vec2 morph, float angle, float alpha, out float calpha) {
541
540
  vec4 color = colors[0];
542
541
  vec2 m = morph / vUv.xy;
543
542
  vec2 rot = vec2( 0.5 + m.x, m.y );
@@ -579,11 +578,11 @@ vec4 getIBLVolumeRefraction( vec3 n, vec3 v, float roughness, vec3 position, mat
579
578
  accumAlpha += ( 1.0 - accumAlpha ) * lalpha;
580
579
 
581
580
  return color.xyz;
582
- }`)}}();var Mo;(function(t){t.NOISE="noise",t.MAP="map"})(Mo||(Mo={}));var sc=class extends me{constructor(e=new Se(0),t,r,o,s,n){super("v3");this.nodeType="VertexDisplacement";this.displacementTypeIndex=e,this.intensity=t,this.movementOrTexture=r,Object.values(Mo)[this.displacementTypeIndex.value]===Mo.MAP&&(this.mat=new To(this.movementOrTexture.value.matrix)),this.cropOrOffset=o,this.scale=s,this.noiseFunctionIndex=n}generate(e,t){if(e.isShader("vertex")){e.define("USE_LAYER_DISPLACE");let r,o=[];switch(o.push("displaced_position"),o.push("displaced_normal"),Object.values(Mo)[this.displacementTypeIndex.value]){case Mo.MAP:{r=e.include(sc.Nodes.map),o.push(this.movementOrTexture.getTexture(e,"t")),o.push("uv"),o.push(this.cropOrOffset.build(e,"f")),this.mat&&o.push(this.mat.build(e,"mat3"));break}case Mo.NOISE:{let n=Object.values(vi)[this.noiseFunctionIndex.value],a=new oe(`vec3 orthogonal(vec3 v) {
581
+ }`)}}();var Io;(function(t){t.NOISE="noise",t.MAP="map"})(Io||(Io={}));var Hl=class extends ue{constructor(e=new ve(0),t,r,o,n,s){super("v3");this.nodeType="VertexDisplacement";this.displacementTypeIndex=e,this.intensity=t,this.movementOrTexture=r,Object.values(Io)[this.displacementTypeIndex.value]===Io.MAP&&(this.mat=new Yi(this.movementOrTexture.value.matrix)),this.cropOrOffset=o,this.scale=n,this.noiseFunctionIndex=s}generate(e,t){if(e.isShader("vertex")){e.define("USE_LAYER_DISPLACE");let r,o=[];switch(o.push("displaced_position"),o.push("displaced_normal"),Object.values(Io)[this.displacementTypeIndex.value]){case Io.MAP:{r=e.include(Hl.Nodes.map),o.push(this.movementOrTexture.getTexture(e,"t")),o.push("uv"),o.push(this.cropOrOffset.build(e,"f")),this.mat&&o.push(this.mat.build(e,"mat3"));break}case Io.NOISE:{let s=Object.values(bi)[this.noiseFunctionIndex.value],a=new re(`vec3 orthogonal(vec3 v) {
583
582
  return normalize(abs(v.x) > abs(v.z) ? vec3(-v.y, v.x, 0.0) : vec3(0.0, -v.z, v.y));
584
- }`),l=new oe(`vec3 distorted(vec3 p, vec3 n, float scale, float intensity, vec3 offset, float neighbour_offset, float movement) {
585
- return p + n * ${n}((p + offset) * scale * 0.001 + neighbour_offset + (movement * 0.1)) * intensity;
586
- }`,[zt.simplex,zt.simplexFractal,zt.simplexAshima,zt.fbm,zt.perlin]),c=new oe(`vec3 vertexDisplacementNoise(vec3 position, vec3 normal, float scale, vec3 offset, float movement, float intensity, out vec3 displaced_normal) {
583
+ }`),l=new re(`vec3 distorted(vec3 p, vec3 n, float scale, float intensity, vec3 offset, float neighbour_offset, float movement) {
584
+ return p + n * ${s}((p + offset) * scale * 0.001 + neighbour_offset + (movement * 0.1)) * intensity;
585
+ }`,[Gt.simplex,Gt.simplexFractal,Gt.simplexAshima,Gt.fbm,Gt.perlin]),c=new re(`vec3 vertexDisplacementNoise(vec3 position, vec3 normal, float scale, vec3 offset, float movement, float intensity, out vec3 displaced_normal) {
587
586
  vec3 displaced_position = distorted(position, normal, scale, intensity, offset, neighbor_offset, movement);
588
587
  vec3 tangent1 = orthogonal(normal);
589
588
  vec3 tangent2 = normalize(cross(normal, tangent1));
@@ -599,9 +598,9 @@ vec4 getIBLVolumeRefraction( vec3 n, vec3 v, float roughness, vec3 position, mat
599
598
  vec3 distorted2 = distorted(nearby2, normal, scale, intensity, offset, neighbor_offset, movement);
600
599
  displaced_normal = normalize(cross(distorted1 - displaced_position, distorted2 - displaced_position));
601
600
  return displaced_position;
602
- }`,[l,a]);r=e.include(c),o.push(this.scale.build(e,"f")),o.push(this.cropOrOffset.build(e,"v3")),o.push(this.movementOrTexture.build(e,"f"));break}}return o.push(this.intensity.build(e,"f")),o.push("displaced_normal"),e.format(r+"("+o.join(",")+")",this.getType(e),t)}else return console.warn("VertexDisplacementNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}toJSON(e){var r;let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.intensity=this.intensity.toJSON(e).uuid,t.scale=(r=this.scale)==null?void 0:r.toJSON(e).uuid,t.movementOrTexture=this.movementOrTexture.toJSON(e).uuid,t.cropOrOffset=this.cropOrOffset.toJSON(e).uuid),t.displacementTypeIndex=this.displacementTypeIndex,t.noiseFunctionIndex=this.noiseFunctionIndex,t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),this.displacementTypeIndex=e.displacementTypeIndex,this.noiseFunctionIndex=e.noiseFunctionIndex,e.cropOrOffset&&(this.cropOrOffset=t.getNode(e.cropOrOffset)),e.intensity&&(this.intensity=t.getNode(e.intensity)),e.movementOrTexture&&(this.displacementTypeIndex.value===1?(this.movementOrTexture=t.getNode(e.movementOrTexture),this.movementOrTexture.value.updateMatrix(),this.mat=new To(this.movementOrTexture.value.matrix)):this.displacementTypeIndex.value===0&&(this.movementOrTexture=t.getNode(e.movementOrTexture))),e.scale&&(this.scale=t.getNode(e.scale)),this}copy(e){var t,r;return super.copy(e),this.noiseFunctionIndex=(t=e.noiseFunctionIndex)==null?void 0:t.clone(),this.scale=(r=e.scale)==null?void 0:r.clone(),this.cropOrOffset=e.cropOrOffset.clone(),this.intensity=e.intensity.clone(),this.movementOrTexture=e.movementOrTexture.clone(),this}},ts=sc;ts.Nodes=function(){let e=new oe(`vec3 orthogonal(vec3 v) {
601
+ }`,[l,a]);r=e.include(c),o.push(this.scale.build(e,"f")),o.push(this.cropOrOffset.build(e,"v3")),o.push(this.movementOrTexture.build(e,"f"));break}}return o.push(this.intensity.build(e,"f")),o.push("displaced_normal"),e.format(r+"("+o.join(",")+")",this.getType(e),t)}else return console.warn("VertexDisplacementNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}copy(e){var t,r;return super.copy(e),this.noiseFunctionIndex=(t=e.noiseFunctionIndex)==null?void 0:t.clone(),this.scale=(r=e.scale)==null?void 0:r.clone(),this.cropOrOffset=e.cropOrOffset.clone(),this.intensity=e.intensity.clone(),this.movementOrTexture=e.movementOrTexture.clone(),this}},tn=Hl;tn.Nodes=function(){let e=new re(`vec3 orthogonal(vec3 v) {
603
602
  return normalize(abs(v.x) > abs(v.z) ? vec3(-v.y, v.x, 0.0) : vec3(0.0, -v.z, v.y));
604
- }`),t=new oe(`float displacementMapTexture(sampler2D tex, float crop, vec2 uv, mat3 mat, vec2 offset) {
603
+ }`),t=new re(`float displacementMapTexture(sampler2D tex, float crop, vec2 uv, mat3 mat, vec2 offset) {
605
604
  vec2 uvs = (mat * vec3(uv * 2.0 - 1.0, 1.0) / 2.0 + 0.5).xy + offset;
606
605
  vec4 tmp = texture2D(tex, uvs);
607
606
  vec3 col = tmp.rgb;
@@ -611,7 +610,7 @@ vec4 getIBLVolumeRefraction( vec3 n, vec3 v, float roughness, vec3 position, mat
611
610
  }
612
611
  }
613
612
  return col.r;
614
- }`);return{map:new oe(`vec3 vertexDisplacementMap(vec3 position, vec3 normal, sampler2D tex, vec2 uv, float crop, mat3 mat, float intensity, out vec3 displaced_normal) {
613
+ }`);return{map:new re(`vec3 vertexDisplacementMap(vec3 position, vec3 normal, sampler2D tex, vec2 uv, float crop, mat3 mat, float intensity, out vec3 displaced_normal) {
615
614
  vec3 displaced_position = position + normal * displacementMapTexture(tex, crop, uv, mat, vec2(0.0)) * intensity;
616
615
  vec3 tangent1 = normalize(orthogonal(normal));
617
616
  vec3 tangent2 = normalize(cross(normal, tangent1));
@@ -621,16 +620,16 @@ vec4 getIBLVolumeRefraction( vec3 n, vec3 v, float roughness, vec3 position, mat
621
620
  vec3 distorted2 = nearby2 + normal * displacementMapTexture(tex, crop, uv, mat, vec2(neighbor_offset)) * intensity;
622
621
  displaced_normal = normalize(cross(distorted1 - displaced_position, distorted2 - displaced_position));
623
622
  return displaced_position;
624
- }`,[e,t])}}();var Na=class extends me{constructor(e=new ue,t=new ue,r=new ue,o=new ue,s=new ue,n=new ue,a=new ue,l=new ue,c=new ue,d=new ue,h=new ue,p=new ue){super("v3");this.nodeType="Noise";this.scale=e,this.size=t,this.move=r,this.fA=o,this.fB=s,this.distortion=n,this.colorA=a,this.colorB=l,this.colorC=c,this.colorD=d,this.alpha=h,this.noiseType=p,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t,r,o,s){e.require("uv"),e.requires.uv=[!0],e.addFragmentVariable(this.calpha,"float");let n=Object.values(vi)[this.noiseType.value],a=new oe(`vec3 ${n}customNoise(float scale, vec3 size, float move, vec2 fA, vec2 fB, vec2 distortion, vec4 colorA, vec4 colorB, vec4 colorC, vec4 colorD, float alpha, out float calpha) {
623
+ }`,[e,t])}}();var ua=class extends ue{constructor(e=new pe,t=new pe,r=new pe,o=new pe,n=new pe,s=new pe,a=new pe,l=new pe,c=new pe,d=new pe,p=new pe,u=new pe){super("v3");this.nodeType="Noise";this.scale=e,this.size=t,this.move=r,this.fA=o,this.fB=n,this.distortion=s,this.colorA=a,this.colorB=l,this.colorC=c,this.colorD=d,this.alpha=p,this.noiseType=u,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t,r,o,n){e.require("uv"),e.requires.uv=[!0],e.addFragmentVariable(this.calpha,"float");let s=Object.values(bi)[this.noiseType.value],a=new re(`vec3 ${s}customNoise(float scale, vec3 size, float move, vec2 fA, vec2 fB, vec2 distortion, vec4 colorA, vec4 colorB, vec4 colorC, vec4 colorD, float alpha, out float calpha) {
625
624
  vec3 st = position / size;
626
625
  st /= scale;
627
- vec3 q = vec3(${n}(st),
628
- ${n}(st + vec3(1.0)),
629
- ${n}(st + vec3(1.0)));
630
- vec3 r = vec3(${n}(st + vec3(distortion, 1.0) * q + vec3(fA, 1.0) + move),
631
- ${n}(st + vec3(distortion, 1.0) * q + vec3(fB, 1.0) + move),
632
- ${n}(st * q));
633
- float f = ${n}(st + r);
626
+ vec3 q = vec3(${s}(st),
627
+ ${s}(st + vec3(1.0)),
628
+ ${s}(st + vec3(1.0)));
629
+ vec3 r = vec3(${s}(st + vec3(distortion, 1.0) * q + vec3(fA, 1.0) + move),
630
+ ${s}(st + vec3(distortion, 1.0) * q + vec3(fB, 1.0) + move),
631
+ ${s}(st * q));
632
+ float f = ${s}(st + r);
634
633
  vec4 color;
635
634
  color = mix(colorA, colorB, clamp((f * f) * 4.0, 0.0, 1.0));
636
635
  color = mix(color, colorC, clamp(length(q), 0.0, 1.0));
@@ -641,7 +640,7 @@ vec4 getIBLVolumeRefraction( vec3 n, vec3 v, float roughness, vec3 position, mat
641
640
 
642
641
  accumAlpha += ( 1.0 - accumAlpha ) * lalpha;
643
642
  return clamp(color, 0.0, 1.0).rgb;
644
- }`,[zt.simplex,zt.simplexFractal,zt.simplexAshima,zt.fbm,zt.perlin]),l=e.include(a),c=[];return c.push(this.scale.build(e,"f")),c.push(this.size.build(e,"v3")),c.push(this.move.build(e,"f")),c.push(this.fA.build(e,"v2")),c.push(this.fB.build(e,"v2")),c.push(this.distortion.build(e,"v2")),c.push(this.colorA.build(e,"v4")),c.push(this.colorB.build(e,"v4")),c.push(this.colorC.build(e,"v4")),c.push(this.colorD.build(e,"v4")),c.push(this.alpha.build(e,"f")),c.push(this.calpha),e.format(l+"("+c.join(",")+")",this.getType(e),t)}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.scale=this.scale.toJSON(e).uuid,t.size=this.size.toJSON(e).uuid,t.move=this.move.toJSON(e).uuid,t.fA=this.fA.toJSON(e).uuid,t.fB=this.fB.toJSON(e).uuid,t.distortion=this.distortion.toJSON(e).uuid,t.colorA=this.colorA.toJSON(e).uuid,t.colorB=this.colorB.toJSON(e).uuid,t.colorC=this.colorC.toJSON(e).uuid,t.colorD=this.colorD.toJSON(e).uuid,t.alpha=this.alpha.toJSON(e).uuid,t.calpha=this.calpha),t.noiseType=this.noiseType,t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),e.scale&&(this.scale=t.getNode(e.scale)),e.size&&(this.size=t.getNode(e.size)),e.move&&(this.move=t.getNode(e.move)),e.fA&&(this.fA=t.getNode(e.fA)),e.fB&&(this.fB=t.getNode(e.fB)),e.distortion&&(this.distortion=t.getNode(e.distortion)),e.colorA&&(this.colorA=t.getNode(e.colorA)),e.colorB&&(this.colorB=t.getNode(e.colorB)),e.colorC&&(this.colorC=t.getNode(e.colorC)),e.colorD&&(this.colorD=t.getNode(e.colorD)),e.alpha&&(this.alpha=t.getNode(e.alpha)),e.noiseType&&(this.noiseType=t.getNode(e.noiseType)),e.calpha&&(this.calpha=e.calpha),this}copy(e){return super.copy(e),this.scale.copy(e.scale),this.size.copy(e.size),this.move.copy(e.move),this.fA.copy(e.fA),this.fB.copy(e.fB),this.distortion.copy(e.distortion),this.colorA.copy(e.colorA),this.colorB.copy(e.colorB),this.colorC.copy(e.colorC),this.colorD.copy(e.colorD),this.alpha.copy(e.alpha),this.calpha=e.calpha,this.noiseType.copy(e.noiseType),this}};Na.numOctaves=5;var wa=class extends me{constructor(e=new ue,t=new ue,r=new ue,o=new ue){super("v3");this.nodeType="Blend";this.a=e,this.b=t,this.alpha=r,this.mode=o}generate(e,t){if(e.isShader("fragment")){let r=[];return r.push(this.a.build(e,"c")),r.push(this.b.build(e,"c")),r.push(this.alpha.build(e,"f")),r.push(this.mode.build(e,"i")),e.format("spe_blend("+r.join(",")+")",this.getType(e),t)}else return console.warn("BlendNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}copy(e){return super.copy(e),this.a.copy(e.a),this.b.copy(e.b),this.alpha.copy(e.alpha),this.mode.copy(e.mode),this}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.a=this.a.toJSON(e).uuid,t.b=this.b.toJSON(e).uuid,t.alpha=this.alpha.toJSON(e).uuid,t.mode=this.mode.toJSON(e).uuid),t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),e.a&&(this.a=t.getNode(e.a)),e.b&&(this.b=t.getNode(e.b)),e.alpha&&(this.alpha=t.getNode(e.alpha)),e.mode&&(this.mode=t.getNode(e.mode)),this}};var Si=class extends me{constructor(e,t,r,o,s,n,a,l,c,d,h,p){super("v3");this.nodeType="Depth";this.gradientType=e,this.smooth=t,this.near=r,this.far=o,this.isVector=s,this.isWorldSpace=n,this.origin=a,this.direction=l,this.colors=c,this.steps=d,this.num=h,this.alpha=p,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){let r=`g${this.uuid.toString().replace(/-/g,"")}`,o=new oe(`vec3 ${r}_sdepth(float near, float far, vec3 origin, vec3 direction, vec4 colors[10], float steps[10], float alpha, out float calpha) {
643
+ }`,[Gt.simplex,Gt.simplexFractal,Gt.simplexAshima,Gt.fbm,Gt.perlin]),l=e.include(a),c=[];return c.push(this.scale.build(e,"f")),c.push(this.size.build(e,"v3")),c.push(this.move.build(e,"f")),c.push(this.fA.build(e,"v2")),c.push(this.fB.build(e,"v2")),c.push(this.distortion.build(e,"v2")),c.push(this.colorA.build(e,"v4")),c.push(this.colorB.build(e,"v4")),c.push(this.colorC.build(e,"v4")),c.push(this.colorD.build(e,"v4")),c.push(this.alpha.build(e,"f")),c.push(this.calpha),e.format(l+"("+c.join(",")+")",this.getType(e),t)}copy(e){return super.copy(e),this.scale.copy(e.scale),this.size.copy(e.size),this.move.copy(e.move),this.fA.copy(e.fA),this.fB.copy(e.fB),this.distortion.copy(e.distortion),this.colorA.copy(e.colorA),this.colorB.copy(e.colorB),this.colorC.copy(e.colorC),this.colorD.copy(e.colorD),this.alpha.copy(e.alpha),this.calpha=e.calpha,this.noiseType.copy(e.noiseType),this}};ua.numOctaves=5;var ha=class extends ue{constructor(e=new pe,t=new pe,r=new pe,o=new pe){super("v3");this.nodeType="Blend";this.a=e,this.b=t,this.alpha=r,this.mode=o}generate(e,t){if(e.isShader("fragment")){let r=[];return r.push(this.a.build(e,"c")),r.push(this.b.build(e,"c")),r.push(this.alpha.build(e,"f")),r.push(this.mode.build(e,"i")),e.format("spe_blend("+r.join(",")+")",this.getType(e),t)}else return console.warn("BlendNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}copy(e){return super.copy(e),this.a.copy(e.a),this.b.copy(e.b),this.alpha.copy(e.alpha),this.mode.copy(e.mode),this}};var vi=class extends ue{constructor(e,t,r,o,n,s,a,l,c,d,p,u){super("v3");this.nodeType="Depth";this.gradientType=e,this.smooth=t,this.near=r,this.far=o,this.isVector=n,this.isWorldSpace=s,this.origin=a,this.direction=l,this.colors=c,this.steps=d,this.num=p,this.alpha=u,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){let r=`g${this.uuid.toString().replace(/-/g,"")}`,o=new re(`vec3 ${r}_sdepth(float near, float far, vec3 origin, vec3 direction, vec4 colors[${r}_MAX_COLORS], float steps[10], float alpha, out float calpha) {
645
644
  vec4 color = colors[0];
646
645
  #ifdef ${r}_IS_VECTOR
647
646
  #ifdef ${r}_LINEAR
@@ -681,35 +680,33 @@ vec4 getIBLVolumeRefraction( vec3 n, vec3 v, float roughness, vec3 position, mat
681
680
 
682
681
  accumAlpha += ( 1.0 - accumAlpha ) * lalpha;
683
682
  return color.rgb;
684
- }`,[Si.Nodes.vectorLinearWorldSpaceDepth,Si.Nodes.vectorLinearObjectSpaceDepth,Si.Nodes.vectorSphericalObjectSpaceDepth,Si.Nodes.vectorSphericalWorldSpaceDepth]);if(e.isShader("fragment")){e.define(`${r}_MAX_COLORS`,this.num.value+1),this.smooth.value&&e.define(`${r}_SMOOTH`),this.isVector.value>.5&&e.define(`${r}_IS_VECTOR`),this.gradientType.value===si.Linear&&e.define(`${r}_LINEAR`),this.isWorldSpace.value>.5&&e.define(`${r}_WORLDSPACE`),e.require("worldPosition"),e.addFragmentVariable(this.calpha,"float");let s=e.include(o),n=[];return n.push(this.near.build(e,"f")),n.push(this.far.build(e,"f")),n.push(this.origin.build(e,"v3")),n.push(this.direction.build(e,"v3")),n.push(this.colors.build(e,"v4[]")),n.push(this.steps.build(e,"f[]")),n.push(this.alpha.build(e,"f")),n.push(this.calpha),e.format(s+"("+n.join(",")+")",this.getType(e),t)}else return console.warn("DepthNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}copy(e){return super.copy(e),this.gradientType=e.gradientType.clone(),this.smooth=e.smooth.clone(),this.near=e.near.clone(),this.far=e.far.clone(),this.isVector=e.isVector.clone(),this.isWorldSpace=e.isWorldSpace.clone(),this.origin=e.origin.clone(),this.direction=e.direction.clone(),this.colors=e.colors.clone(),this.steps=e.steps.clone(),this.alpha=e.alpha.clone(),this.calpha=e.calpha,this}},Ca=Si;Ca.Nodes=function(){let e=new oe(`float vectorLinearWorldSpaceDepth(vec3 direction, vec3 origin, float near, float far) {
683
+ }`,[vi.Nodes.vectorLinearWorldSpaceDepth,vi.Nodes.vectorLinearObjectSpaceDepth,vi.Nodes.vectorSphericalObjectSpaceDepth,vi.Nodes.vectorSphericalWorldSpaceDepth]);if(e.isShader("fragment")){e.define(`${r}_MAX_COLORS`,this.num.value+1),this.smooth.value&&e.define(`${r}_SMOOTH`),this.isVector.value>.5&&e.define(`${r}_IS_VECTOR`),this.gradientType.value===ii.Linear&&e.define(`${r}_LINEAR`),this.isWorldSpace.value>.5&&e.define(`${r}_WORLDSPACE`),e.require("worldPosition"),e.addFragmentVariable(this.calpha,"float");let n=e.include(o),s=[];return s.push(this.near.build(e,"f")),s.push(this.far.build(e,"f")),s.push(this.origin.build(e,"v3")),s.push(this.direction.build(e,"v3")),s.push(this.colors.build(e,"v4[]")),s.push(this.steps.build(e,"f[]")),s.push(this.alpha.build(e,"f")),s.push(this.calpha),e.format(n+"("+s.join(",")+")",this.getType(e),t)}else return console.warn("DepthNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}copy(e){return super.copy(e),this.gradientType=e.gradientType.clone(),this.smooth=e.smooth.clone(),this.near=e.near.clone(),this.far=e.far.clone(),this.isVector=e.isVector.clone(),this.isWorldSpace=e.isWorldSpace.clone(),this.origin=e.origin.clone(),this.direction=e.direction.clone(),this.colors=e.colors.clone(),this.steps=e.steps.clone(),this.alpha=e.alpha.clone(),this.calpha=e.calpha,this}},ma=vi;ma.Nodes=function(){let e=new re(`float vectorLinearWorldSpaceDepth(vec3 direction, vec3 origin, float near, float far) {
685
684
  vec3 n = normalize(direction);
686
685
  float dist = (n.x*(vWPosition.x - origin.x) + n.y*(vWPosition.y - origin.y) + n.z*(vWPosition.z - origin.z));
687
686
  return ( dist - near ) / ( far - near );
688
- }`),t=new oe(`float vectorLinearObjectSpaceDepth(vec3 direction, vec3 origin, float near, float far) {
687
+ }`),t=new re(`float vectorLinearObjectSpaceDepth(vec3 direction, vec3 origin, float near, float far) {
689
688
  vec3 n = normalize(direction);
690
689
  float dist = (n.x*(position.x - origin.x) + n.y*(position.y - origin.y) + n.z*(position.z - origin.z));
691
690
  return ( dist - near ) / ( far - near );
692
- }`),r=new oe(`float vectorSphericalWorldSpaceDepth(vec3 origin, float near, float far) {
691
+ }`),r=new re(`float vectorSphericalWorldSpaceDepth(vec3 origin, float near, float far) {
693
692
  float dist = length(vWPosition - origin);
694
693
  return ( dist - near ) / ( far - near );
695
- }`),o=new oe(`float vectorSphericalObjectSpaceDepth(vec3 origin, float near, float far) {
694
+ }`),o=new re(`float vectorSphericalObjectSpaceDepth(vec3 origin, float near, float far) {
696
695
  float dist = length(position - origin);
697
696
  return ( dist - near ) / ( far - near );
698
- }`);return{vectorLinearWorldSpaceDepth:e,vectorLinearObjectSpaceDepth:t,vectorSphericalWorldSpaceDepth:r,vectorSphericalObjectSpaceDepth:o}}();var nc=class extends me{constructor(e,t,r,o){super("v3");this.nodeType="Matcap";this.color=e,this.texture=t,this.alpha=r,this.mode=o,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){if(e.isShader("fragment")){e.addFragmentVariable(this.calpha,"float");let r=e.include(nc.Nodes.matcap);e.require("normal"),e.requires.normal=!0;let o=[];return o.push(this.color.build(e,"v3")),o.push(this.texture.getTexture(e,"t")),o.push("normal"),o.push(this.alpha.build(e,"f")),o.push(this.mode.build(e,"i")),o.push(this.calpha),e.format(r+"("+o.join(",")+")",this.getType(e),t)}else return console.warn("MatcapNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}copy(e){return super.copy(e),this.texture=e.texture.clone(),this.color=e.color.clone(),this.alpha=e.alpha.clone(),this.mode=e.mode.clone(),this.calpha=e.calpha,this}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.texture=this.texture.toJSON(e).uuid,t.color=this.color.toJSON(e).uuid,t.alpha=this.alpha.toJSON(e).uuid,t.mode=this.mode.toJSON(e).uuid,t.calpha=this.calpha),t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),e.calpha&&(this.calpha=e.calpha),e.alpha&&(this.alpha=t.getNode(e.alpha)),e.texture&&(this.texture=t.getNode(e.texture)),e.color&&(this.color=t.getNode(e.color)),e.mode&&(this.mode=t.getNode(e.mode)),this}},La=nc;La.Nodes=function(){return{matcap:new oe(`vec3 matcap(vec3 color, sampler2D matcapTex, vec3 normal, float alpha, int mode, out float calpha) {
697
+ }`);return{vectorLinearWorldSpaceDepth:e,vectorLinearObjectSpaceDepth:t,vectorSphericalWorldSpaceDepth:r,vectorSphericalObjectSpaceDepth:o}}();var ql=class extends ue{constructor(e,t,r){super("v3");this.nodeType="Matcap";this.texture=e,this.alpha=t,this.mode=r,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){if(e.isShader("fragment")){e.addFragmentVariable(this.calpha,"float");let r=e.include(ql.Nodes.matcap);e.require("normal"),e.requires.normal=!0;let o=[];return o.push(this.texture.getTexture(e,"t")),o.push("normal"),o.push(this.alpha.build(e,"f")),o.push(this.mode.build(e,"i")),o.push(this.calpha),e.format(r+"("+o.join(",")+")",this.getType(e),t)}else return console.warn("MatcapNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}copy(e){return super.copy(e),this.texture=e.texture.clone(),this.alpha=e.alpha.clone(),this.mode=e.mode.clone(),this.calpha=e.calpha,this}},fa=ql;fa.Nodes=function(){return{matcap:new re(`vec3 matcap(sampler2D matcapTex, vec3 normal, float alpha, int mode, out float calpha) {
699
698
  vec3 viewDir = normalize( vViewPosition );
700
699
  vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );
701
700
  vec3 y = cross( viewDir, x );
702
701
  vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5; // 0.495 to remove artifacts caused by undersized matcap disks
703
702
  vec4 matcapColor = texture2D( matcapTex, uv );
704
- // matcapColor = matcapTexelToLinear( matcapColor );
705
- matcapColor.rgb *= color;
706
-
703
+
707
704
  calpha = alpha / clamp( alpha + accumAlpha, 0.00001, 1.0 );
708
705
  accumAlpha += ( 1.0 - accumAlpha ) * alpha;
709
706
 
710
707
  return matcapColor.rgb;
711
708
  }
712
- `)}}();var At=class{constructor(e){this.id=2,this.layerCount=2,this.uuid=Ur.generateUUID(),this.needsUpdate=!1,this._material=e,this._layerNodes=[];let t=this._createLayer({id:0,type:Le.COLOR});this._material.color=t.color,this._material.alpha===void 0&&(this._material.alpha=new re(1));let r=new re(1),o=new Se(0);"shadingAlpha"in this._material&&"shadingBlend"in this._material&&(this._material.shadingAlpha=r,this._material.shadingBlend=o),this._layerNodes.push({id:0,type:Je.COLOR,color:t.color,alpha:t.alpha,mode:t.mode}),this._layerNodes.push({id:1,type:Je.LIGHTING,alpha:r,mode:o}),this.head=t.layer,this.head.next=new Ke(1,void 0,{type:Le.LIGHTING,alpha:r,mode:o}),this.attachLightNodes(this.getLightLayer())}get material(){return this._material}set material(e){var s;this._material=e;let t,r,o=this.head;for(;o!==void 0;){if(o.type===Le.LIGHTING){t=o.uniforms[`f${o.id}_alpha`],r=o.uniforms[`f${o.id}_mode`];break}o=o.next}"shadingAlpha"in this._material&&"shadingBlend"in this._material&&(this._material.shadingAlpha=t,this._material.shadingBlend=r),this.attachLightNodes((s=e.userData.layers)==null?void 0:s.getLightLayer()),this.blendColors(),this.blendAfterColors(),this.blendPositions()}getLayersOfType(e){let t=[],r=this.head;for(;r;)r.type===e&&t.push(r),r=r.next;return t}addLayer(e){var o;if(e.id=(o=e.id)!=null?o:++this.id,this.layerCount++,e.type===Le.LIGHTING){let s=this.createLightLayer(e);return this.uuid=Ur.generateUUID(),this.blendColors(),this.blendAfterColors(),this.blendPositions(),s}let t=this._createLayer(e),r=t.layer;if(this.head===void 0)this.head=r;else{let s=this.head;for(;s.next!=null;)s=s.next;s.next=r}return t.color&&this._layerNodes.push({id:r.id,type:Je.COLOR,color:t.color,alpha:t.alpha,mode:t.mode}),t.position&&this._layerNodes.push({id:r.id,type:Je.POSITION,position:t.position}),this.uuid=Ur.generateUUID(),this.blendColors(),this.blendAfterColors(),this.blendPositions(),r}addLayerBeforeAt(e,t){var a;let r=this.head;e.id=(a=e.id)!=null?a:++this.id,this.layerCount++;let o=this._createLayer(e),s=o.layer;s.next=t;let n=0;if(r===t)this.head=s,o.color&&this._layerNodes.splice(0,0,{id:s.id,type:Je.COLOR,color:o.color,alpha:o.alpha,mode:o.mode}),o.position&&this._layerNodes.splice(0,0,{id:s.id,type:Je.POSITION,position:o.position});else{for(n=1;(r==null?void 0:r.next)!==t;)r=r==null?void 0:r.next,n++;r.next=s,o.color&&this._layerNodes.splice(n,0,{id:s.id,type:Je.COLOR,color:o.color,alpha:o.alpha,mode:o.mode}),o.position&&this._layerNodes.splice(n,0,{id:s.id,type:Je.POSITION,position:o.position})}return this.uuid=Ur.generateUUID(),this.blendColors(),this.blendAfterColors(),this.blendPositions(),s}addLayerAt(e,t){var s;t.id=(s=t.id)!=null?s:++this.id,this.layerCount++;let r=this._createLayer(t),o=r.layer;if(r.color&&this._layerNodes.splice(e,0,{id:o.id,type:Je.COLOR,color:r.color,alpha:r.alpha,mode:r.mode}),r.position&&this._layerNodes.splice(e,0,{id:o.id,type:Je.POSITION,position:r.position}),e==0)o.next=this.head,this.head=o;else{let n=this.head,a=this.head.next;for(let l=0;l<e-1;l++)n=a,a=a.next;o.next=a,n.next=o}return this.uuid=Ur.generateUUID(),this.blendColors(),this.blendAfterColors(),this.blendPositions(),o}removeLayer(e){let t=this.head,r,o=0;if((t==null?void 0:t.id)==e)this.head=t.next;else for(o=1,r=t,t=t==null?void 0:t.next;t!=null;){if(t.id==e){r.next=t.next;break}o++,r=t,t=t.next}return this.cleanupChangedLayer(t),this.blendColors(),this.blendAfterColors(),this.blendPositions(),this.uuid=Ur.generateUUID(),this.layerCount--,o}changeLayer(e,t){let r,o=this.head,s;if((o==null?void 0:o.id)==e){let n=this._createLayer(P({id:e,uuid:o.uuid},t));s=n.layer,s.next=o.next,this.head=s,n.color&&(this._layerNodes[0]={id:s.id,type:Je.COLOR,color:n.color,alpha:n.alpha,mode:n.mode}),n.position&&(this._layerNodes[0]={id:s.id,type:Je.POSITION,position:n.position}),s.uniforms[`f${e}_mode`].value=o.uniforms[`f${e}_mode`].value,s.uniforms[`f${e}_alpha`].value=o.uniforms[`f${e}_alpha`].value}else{r=o,o=o.next;let n=1;for(;o!=null;){if(o.id==e){let a=this._createLayer(P({id:e,uuid:o.uuid},t));s=a.layer,r.next=s,s.next=o.next,a.color&&(this._layerNodes[n]={id:e,type:Je.COLOR,color:a.color,alpha:a.alpha,mode:a.mode}),a.position&&(this._layerNodes[n]={id:e,type:Je.POSITION,position:a.position}),s.uniforms[`f${e}_mode`].value=o.uniforms[`f${e}_mode`].value,s.uniforms[`f${e}_alpha`].value=o.uniforms[`f${e}_alpha`].value;break}r=o,o=o.next,n++}}return this.uuid=Ur.generateUUID(),this.blendColors(),this.blendAfterColors(),this.blendPositions(),s}getLayer(e){let t=this.head;for(;t!=null&&t.id!=e;)t=t.next;return t}getLayerByUuid(e){let t=this.head;for(;t!==void 0;){if(t.uuid===e)return t;t=t.next}}getLayers(){let e=[],t=this.head;for(;t!=null;)e.push(t),t=t.next;return e}getLayerPosition(e){let t=this.head,r=0;for(;t!==void 0&&t.id!=e;)r++,t=t.next;return r}getDefines(){}getBeforeProgram(){}getLightingProgram(){}getAfterProgram(){}getVarPrograms(){}getUniforms(){}moveLayer(e,t){let r,o=this.head,s;if(e==0)r=this.head,this.head=r.next;else{for(let a=0;a<e;a++)s=o,o=o.next;s.next=o.next,r=o}if(o=this.head,s=void 0,t==0)r.next=this.head,this.head=r;else{for(let a=0;a<t-1;a++)o=o.next;r.next=o==null?void 0:o.next,o.next=r}let n=this._layerNodes.splice(e,1)[0];this._layerNodes.splice(t,0,n),this.uuid=Ur.generateUUID(),this.blendColors(),this.blendAfterColors()}updateLayerUniform(){this.uuid=Ur.generateUUID(),this.blendColors(),this.blendAfterColors()}copy(e){this.needsUpdate=!1,this.layerCount=e.layerCount,this._layerNodes=[],this.layerCount=0,this.head=void 0,this.rebuildLayerNodes(this.head,e.head);let t=e.head,r=this.head;for(;t.next!=null;)this.rebuildLayerNodes(r,t.next),r=r.next,t=t.next;return this.id=e.id,this.uuid=e.uuid,this.blendColors(),this.blendAfterColors(),this.blendPositions(),this}createLightLayer(e){let t=new re(e.alpha),r=new Se(e.mode);this._material.shadingAlpha=t,this._material.shadingBlend=r,this._layerNodes.push({id:e.id,type:Je.LIGHTING,alpha:t,mode:r});let o=new Ke(e.id,void 0,{type:Le.LIGHTING,alpha:t,mode:r});if(this.head===void 0)this.head=o;else{let s=this.head;for(;s.next!=null;)s=s.next;s.next=o}return this.attachLightNodes(this.getLightLayer()),o}rebuildLayerNodes(e,t,r=!1){if(t.type===Le.LIGHTING){let o=r?t.uniforms[`f${t.id}_alpha`]:new re(t.uniforms[`f${t.id}_alpha`].value),s=r?t.uniforms[`f${t.id}_mode`]:new Se(t.uniforms[`f${t.id}_mode`].value);this._material.shadingAlpha=o,this._material.shadingBlend=s,this._layerNodes.push({id:t.id,type:Je.LIGHTING,alpha:o,mode:s}),this.head===void 0?this.head=new Ke(t.id,t.uuid,{type:Le.LIGHTING,alpha:o,mode:s}):e&&(e.next=new Ke(t.id,t.uuid,{type:Le.LIGHTING,alpha:o,mode:s})),this.attachLightNodes(t)}else{let o={type:t.type,id:t.id};for(let s in t.uniforms){let n=t.getName(s);if(!n)continue;let a=`f${t.id}_${n}`;if(Array.isArray(t.uniforms[a].value))o[n]=t.uniforms[a].value.map(l=>l.clone&&!r?l.clone():l);else{let l=t.uniforms[a].value;if(n==="transmissionDepthMap"){o[n]=l;continue}l!=null&&(o[n]=l.clone&&!r&&!l.isRenderTargetTexture?l.clone():l)}}this.addLayer(o)}}attachLightNodes(e){var o,s,n,a,l,c,d,h,p,m,f;let t={},r=this.getLightLayer();switch(this._material.userData.category){case"Lambert":t.emissive=new Be((s=(o=e==null?void 0:e.getValue("emissive"))==null?void 0:o.clone())!=null?s:0);break;case"Phong":t.shininess=new re((n=e==null?void 0:e.getValue("shininess"))!=null?n:30),t.specular=new Be((l=(a=e==null?void 0:e.getValue("specular"))==null?void 0:a.clone())!=null?l:1118481);break;case"Toon":t.shininess=new re((c=e==null?void 0:e.getValue("shininess"))!=null?c:30),t.specular=new Be((h=(d=e==null?void 0:e.getValue("specular"))==null?void 0:d.clone())!=null?h:1118481);break;case"Physical":t.roughness=new re((p=e==null?void 0:e.getValue("roughness"))!=null?p:.3),t.metalness=new re((m=e==null?void 0:e.getValue("metalness"))!=null?m:0),t.reflectivity=new re((f=e==null?void 0:e.getValue("reflectivity"))!=null?f:.5);break;default:break}Object.keys(t).forEach(x=>{this._material[x]=t[x],r.uniforms[`f${r.id}_${x}`]=t[x]})}clone(e){return new At(e).copy(this)}toJSON(e){return{id:this.id,uuid:this.uuid,head:this.head.toJSON(e)}}fromJSON(e,t,r){let o=new Ke(e.head.id,void 0,{type:e.head.type}).fromJSON(e.head,t),s=e.head.next,n=o;for(;s!=null;)n.next=new Ke(s.id,void 0,{type:s.type}).fromJSON(s,t),s=s.next,n=n.next;this._layerNodes=[],this.head=void 0,this.rebuildLayerNodes(this.head,o,!0);let a=o;for(n=this.head;a.next!=null;)this.rebuildLayerNodes(n,a.next,!0),n=n.next,a=a.next;return this._material=r,this.id=e.id,this.uuid=e.uuid,this.blendColors(),this.blendAfterColors(),this.blendPositions(),this}getLightLayer(){var t;let e=this.head;for(;e!==void 0&&e.type!=="light";)e=(t=e.next)!=null?t:e;return e}dispose(){let e=this.head;for(this._layerNodes=[],this.layerCount=0;e!==void 0;)e.hasOwnProperty("dispose")===!0&&e.dispose(),e=e.next;this.head=void 0}_createLayer(e){var r,o,s,n,a,l,c,d,h,p,m,f,x,g,N,C,S,D,v,j,O,u,A,b,L,I,T,$,J,te,fe,ce,be,R,E,y,z,_,F,K,Q,k,V,B,U,se,H,W,X,Z,Y,ne,ie,de,Ge,ye,$e,Oe,pt,Lt,Mr,bt,Ir,uo,fo,He,vt,Ft,Ts,Ms,Is,Ps,As,js,Wt,Oi,ut,_o,_s,mo;let t=e.type;switch(t){case Le.COLOR:{let xe=new Be((r=e.color)!=null?r:nt),we=new re((o=e.alpha)!=null?o:1),Ne=new ze("alpha / clamp(alpha + accumAlpha, 0.00001, 1.0 )","f");Ne.keywords.alpha=we;let Ce=new Se((s=e.mode)!=null?s:0);return xe.alpha=we,{layer:new Ke(e.id,e.uuid,{type:t,color:xe,alpha:we,calpha:Ne,mode:Ce}),color:xe,alpha:Ne,mode:Ce}}case Le.TEXTURE:{let xe=(n=e.texture)!=null?n:new Vr,we=xe.matrix;e.mat&&we.copy(e.mat),xe.needsUpdate=!0;let Ne=new re((a=e.crop)!=null?a:0),Ce=new Se((l=e.projection)!=null?l:0),Te=new Se((c=e.axis)!=null?c:0),_e=new It(e.size?new lo(e.size[0],e.size[1]):new lo(100,100)),De=new re((d=e.alpha)!=null?d:1),Ee=new Se((h=e.mode)!=null?h:0),Fe=new Et(xe),qe=new Pt((p=e.textureSize)!=null?p:new co(xe.image?xe.image.width:0,xe.image?xe.image.height:0)),it=new ga(Fe,qe,Ne,Ce,Te,_e,De,Ee),$t=new ze(it.calpha,"f");return{layer:new Ke(e.id,e.uuid,{type:t,texture:Fe,textureSize:qe,crop:Ne,projection:Ce,axis:Te,size:_e,mat:it.mat,alpha:De,calpha:$t,mode:Ee}),color:it,alpha:$t,mode:Ee}}case Le.MATCAP:{let xe=new Be((m=e.color)!=null?m:16777215),we=(f=e.texture)!=null?f:new Vr;we.needsUpdate=!0;let Ne=new re((x=e.alpha)!=null?x:1),Ce=new Et(we),Te=new Se((g=e.mode)!=null?g:0),_e=new La(xe,Ce,Ne,Te),De=new ze(_e.calpha,"f");return{layer:new Ke(e.id,e.uuid,{type:t,texture:Ce,color:xe,alpha:Ne,calpha:De,mode:Te}),color:_e,alpha:De,mode:Te}}case Le.FRESNEL:{let xe=new Be((N=e.color)!=null?N:16777215),we=new re((C=e.bias)!=null?C:.1),Ne=new re((S=e.scale)!=null?S:1),Ce=new re((D=e.intensity)!=null?D:2),Te=new re((v=e.factor)!=null?v:1),_e=new re((j=e.alpha)!=null?j:1),De=new Se((O=e.mode)!=null?O:0),Ee=new ya(xe,we,Ne,Ce,Te,_e,De),Fe=new ze(Ee.calpha,"f");return{layer:new Ke(e.id,e.uuid,{type:t,color:xe,bias:we,scale:Ne,intensity:Ce,factor:Te,alpha:_e,calpha:Fe,mode:De}),color:Ee,alpha:Fe,mode:De}}case Le.RAINBOW:{let xe=new re((u=e.filmThickness)!=null?u:30),we=new re((A=e.movement)!=null?A:0),Ne=new Pt((b=e.wavelengths)!=null?b:new co(0,0,0)),Ce=new re((L=e.noiseStrength)!=null?L:0),Te=new re((I=e.noiseScale)!=null?I:1),_e=new Pt((T=e.offset)!=null?T:new co(0,0,0)),De=new re(($=e.alpha)!=null?$:1),Ee=new xa(xe,we,Ne,Ce,Te,_e,De),Fe=new ze(Ee.calpha,"f"),qe=new Se((J=e.mode)!=null?J:0);return{layer:new Ke(e.id,e.uuid,{type:t,filmThickness:xe,movement:we,wavelengths:Ne,noiseStrength:Ce,noiseScale:Te,offset:_e,alpha:De,calpha:Fe,mode:qe}),color:Ee,alpha:Fe,mode:qe}}case Le.TRANSMISSION:{let xe=new re((te=e.thickness)!=null?te:10),we=new re((fe=e.ior)!=null?fe:1.5),Ne=new re((ce=e.roughness)!=null?ce:.5),Ce=new It((be=e.transmissionSamplerSize)!=null?be:new lo(2048,2048)),Te=(R=e.transmissionSamplerMap)!=null?R:new Vr,_e=(E=e.transmissionDepthMap)!=null?E:new Vr,De=new Et(Te),Ee=new Et(_e),Fe=window.innerWidth,qe=window.innerHeight,it=Fe>=qe?new It(qe/Fe,1):new It(1,Fe/qe),$t=new re((y=e.alpha)!=null?y:1),Pr=new ba(xe,we,Ne,Ce,De,Ee,it,$t),Hr=new ze(Pr.calpha,"f"),qr=new Se((z=e.mode)!=null?z:0);return{layer:new Ke(e.id,e.uuid,{type:t,thickness:xe,ior:we,roughness:Ne,transmissionSamplerSize:Ce,transmissionSamplerMap:De,transmissionDepthMap:Ee,aspectRatio:it,alpha:$t,calpha:Hr,mode:qr}),color:Pr,alpha:Hr,mode:qr}}case Le.DEPTH:{let xe=new Se((_=e.gradientType)!=null?_:0),we=new ma((F=e.smooth)!=null?F:!1),Ne=new re((K=e.near)!=null?K:50),Ce=new re((Q=e.far)!=null?Q:200),Te=new re((k=e.isVector)!=null?k:1),_e=new re((V=e.isWorldSpace)!=null?V:0),De=new Pt((B=e.origin)!=null?B:new co),Ee=new Pt((U=e.direction)!=null?U:new co),Fe=new Se((se=e.num)!=null?se:0),qe;e.colors?qe=new yi(e.colors.length,e.colors):(qe=new yi(10,new Oa(0,0,0,1)),qe.value[1]=new Oa(1,1,1,1));let it;e.steps?it=new xi(e.steps.length,e.steps):(it=new xi(10,1),it.value[0]=0);let $t=new re((H=e.alpha)!=null?H:1),Pr=new Se((W=e.mode)!=null?W:0),Hr=new Ca(xe,we,Ne,Ce,Te,_e,De,Ee,qe,it,Fe,$t),qr=new ze(Hr.calpha,"f");return{layer:new Ke(e.id,e.uuid,{type:t,gradientType:xe,smooth:we,near:Ne,far:Ce,isVector:Te,isWorldSpace:_e,origin:De,direction:Ee,colors:qe,steps:it,num:Fe,alpha:$t,calpha:qr,mode:Pr}),color:Hr,alpha:qr,mode:Pr}}case Le.NOISE:{let xe=new re((X=e.scale)!=null?X:1),we=new Pt((Z=e.size)!=null?Z:new co(100,100,100)),Ne=new re((Y=e.move)!=null?Y:1),Ce=new It((ne=e.fA)!=null?ne:new lo(1.7,9.2)),Te=new It((ie=e.fB)!=null?ie:new lo(8.3,2.8)),_e=new It((de=e.distortion)!=null?de:new lo(1,1)),De=new ao(e.colorA),Ee=new ao(e.colorB),Fe=new ao(e.colorC),qe=new ao(e.colorD),it=new re((Ge=e.alpha)!=null?Ge:1),$t=new Se((ye=e.mode)!=null?ye:0),Pr=new Se(($e=e.noiseType)!=null?$e:0),Hr=new Na(xe,we,Ne,Ce,Te,_e,De,Ee,Fe,qe,it,Pr),qr=new ze(Hr.calpha,"f");return{layer:new Ke(e.id,e.uuid,{type:t,scale:xe,size:we,move:Ne,fA:Ce,fB:Te,distortion:_e,colorA:De,colorB:Ee,colorC:Fe,colorD:qe,alpha:it,calpha:qr,mode:$t,noiseType:Pr}),color:Hr,alpha:qr,mode:$t}}case Le.NORMAL:{let xe=new Pt((Oe=e.cnormal)!=null?Oe:new co(1,1,1)),we=new re((pt=e.alpha)!=null?pt:1),Ne=new Se((Lt=e.mode)!=null?Lt:0),Ce=new va(xe,we),Te=new ze("alpha / clamp(alpha + accumAlpha, 0.00001, 1.0 )","f");return Te.keywords.alpha=we,{layer:new Ke(e.id,e.uuid,{type:t,cnormal:xe,alpha:we,calpha:Te,mode:Ne}),color:Ce,alpha:Te,mode:Ne}}case Le.GRADIENT:{let xe=new Se((Mr=e.gradientType)!=null?Mr:0),we=new ma((bt=e.smooth)!=null?bt:!1),Ne;e.colors?Ne=new yi(e.colors.length,e.colors):(Ne=new yi(10,new Oa(0,0,0,1)),Ne.value[1]=new Oa(1,1,1,1));let Ce;e.steps?Ce=new xi(e.steps.length,e.steps):(Ce=new xi(10,1),Ce.value[0]=0);let Te=new It((Ir=e.offset)!=null?Ir:new lo(0,0)),_e=new It((uo=e.morph)!=null?uo:new lo(0,0)),De=new re((fo=e.angle)!=null?fo:0),Ee=new re((He=e.alpha)!=null?He:1),Fe=new Se((vt=e.mode)!=null?vt:0),qe=new Sa(xe,we,Ne,Ce,Te,_e,De,Ee),it=new ze(qe.calpha,"f");return{layer:new Ke(e.id,e.uuid,{type:t,gradientType:xe,smooth:we,colors:Ne,steps:Ce,offset:Te,morph:_e,angle:De,alpha:Ee,calpha:it,mode:Fe}),color:qe,alpha:it,mode:Fe}}case Le.DISPLACE:{let xe=new Se((Ft=e.displacementType)!=null?Ft:0);if(xe.value===0){let we=new Pt((Ts=e.offset)!=null?Ts:new co(0,0,0)),Ne=new re((Ms=e.scale)!=null?Ms:10),Ce=new re((Is=e.intensity)!=null?Is:8),Te=new re((Ps=e.movement)!=null?Ps:1),_e=new re((As=e.alpha)!=null?As:1),De=new Se((js=e.mode)!=null?js:0),Ee=new Se((Wt=e.noiseType)!=null?Wt:0),Fe=new ts(xe,Ce,Te,we,Ne,Ee);return{layer:new Ke(e.id,e.uuid,{displacementType:xe,type:t,offset:we,scale:Ne,intensity:Ce,movement:Te,alpha:_e,mode:De,noiseType:Ee}),position:Fe}}else if(xe.value===1){let we=(Oi=e.texture)!=null?Oi:new Vr,Ne=we.matrix;e.mat&&Ne.copy(e.mat),we.needsUpdate=!0;let Ce=new re((ut=e.intensity)!=null?ut:8),Te=new Et(we),_e=new re((_o=e.crop)!=null?_o:0),De=new re((_s=e.alpha)!=null?_s:1),Ee=new Se((mo=e.mode)!=null?mo:0),Fe=new ts(xe,Ce,Te,_e);return{layer:new Ke(e.id,e.uuid,{displacementType:xe,type:t,intensity:Ce,texture:Te,crop:_e,mat:Fe.mat,alpha:De,mode:Ee}),position:Fe}}return{}}}return{}}blendColors(){let e=this._layerNodes.findIndex(r=>r.type===Je.COLOR),t=this._layerNodes.findIndex(r=>r.type===Je.LIGHTING);if(e!==-1&&e<t){let r=this._layerNodes[e].color;for(let o=e+1;o<t;++o){let s=this._layerNodes[o];s.type===Je.COLOR&&(r=new wa(r,s.color,s.alpha,s.mode))}this._material.color=r}else this._material.color=void 0}blendAfterColors(){let e=new ze("outgoingLight","f"),t=this._layerNodes.findIndex(r=>r.type===Je.LIGHTING);if(this._layerNodes.length>t+1){for(let r=t+1;r<this._layerNodes.length;++r){let o=this._layerNodes[r];o.type===Je.COLOR&&(e=new wa(e,o.color,o.alpha,o.mode))}"afterColor"in this._material&&(this._material.afterColor=e)}else"afterColor"in this._material&&(this._material.afterColor=void 0)}blendPositions(){let e=this._layerNodes.filter(t=>t.type===Je.POSITION);if(e.length>0){let t=e[0].position;for(let r=1;r<e.length;++r)e[r]&&(t=new Ht(t,e[r].position,Ht.ADD),t=new Ht(t,new re(.5).setReadonly(!0),Ht.MUL));this._material.position=t}else this._material.position=void 0}cleanupChangedLayer(e){switch(this._layerNodes=this._layerNodes.filter(t=>t.id!==e.id),e.type){case Le.DISPLACE:{this.blendPositions();break}default:{this.blendColors(),this.blendAfterColors();break}}}};var or=class extends sN{constructor(e,t,r){super(r);this.isNodeMaterial=!0;this.type="NodeMaterial";this.wireframeLinecap="";this.wireframeLinejoin="";this.uniformsBackup={};this.userData={type:"",category:"",nodeType:""};this.fog=!0,this.vertex=e!=null?e:new fa(new wt(wt.PROJECTION)),this.fragment=t!=null?t:new fa(new Be(nt)),this.updaters=[],this.isDetached=!0,this.dithering=!0,this.onBeforeCompile=this._onBeforeCompile}getDefines(){return this.defines}getUniforms(){return this.uniforms}getVertexShader(){return this.vertexShader}getFragmentShader(){return this.fragmentShader}_onBeforeCompile(e,t){this.build({renderer:t}),e.defines=this.defines,e.uniforms=this.uniforms,e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader,e.extensionDerivatives=this.extensions.derivatives===!0,e.extensionFragDepth=this.extensions.fragDepth===!0,e.extensionDrawBuffers=this.extensions.drawBuffers===!0,e.extensionShaderTextureLOD=this.extensions.shaderTextureLOD===!0}_getLayerStack(e){let t=new At(this);return e&&(async()=>{for(;e.image===void 0;)await new Promise(r=>requestAnimationFrame(r));t.addLayerAt(1,{type:Le.TEXTURE,texture:e}),this.dispose()})(),t}clampUniformsForPreview(e,t){let r=(o,s,n)=>Math.min(Math.max(o,s),n);if(this.userData.layers){for(let o of this.userData.layers.getLayers())if(o.type==Le.DISPLACE){this.uniformsBackup[`f${o.id}_intensity`]=o.uniforms[`f${o.id}_intensity`].value;let s=r(o.uniforms[`f${o.id}_intensity`].value,e,t);o.uniforms[`f${o.id}_intensity`].value=s}}}restoreClampedUniforms(){if(this.userData.layers)for(let e of this.userData.layers.getLayers())e.type==Le.DISPLACE&&(e.uniforms[`f${e.id}_intensity`].value=this.uniformsBackup[`f${e.id}_intensity`])}customProgramCacheKey(){return this.getHash()}updateFrame(e){for(let t=0;t<this.updaters.length;++t)e.updateNode(this.updaters[t])}build(e){var r;e=e!=null?e:{};let t=(r=e.builder)!=null?r:new Ql;return t.setMaterial(this,e.renderer),t.build(this.vertex,this.fragment),this.vertexShader=t.getCode("vertex"),this.fragmentShader=t.getCode("fragment"),this.defines=t.defines,this.uniforms=t.uniforms,this.extensions=t.extensions,this.updaters=t.updaters,this.fog=t.requires.fog,this.lights=t.requires.lights,this.transparent=t.requires.transparent||this.blending>iN,this}getHash(){let e="{";return e+='"vertex":'+this.vertex.getHash()+",",e+='"fragment":'+this.fragment.getHash(),e+="}",e}copy(e){let t=this.uuid;for(let r in e)this[r]=e[r];return this.uuid=t,e.userData!==void 0&&(this.userData=JSON.parse(JSON.stringify(e.userData))),this}toJSON(e){let t=this.userData.layers;this.userData.layers=void 0;let r=super.toJSON(e);return r.type="ShaderMaterial",r.userData={type:this.userData.type,category:this.userData.category,nodeType:this.type,layers:t.toJSON(e)},r.vertex=this.vertex.toJSON(e).uuid,r.fragment=this.fragment.toJSON(e).uuid,delete r.vertexShader,delete r.fragmentShader,delete r.color,delete r.shininess,delete r.specular,delete r.roughness,delete r.metalness,delete r.uniforms,e&&!e.materials[this.uuid]&&(e.materials[this.uuid]=r),this.userData.layers=t,r}fromJSON(e,t){var r;this.defines=(r=e.defines)!=null?r:{},this.depthFunc=e.depthFunc,this.depthWrite=e.depthWrite,this.side=e.side!==void 0?e.side:nN,this.transparent=e.transparent,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.wireframe=e.wireframe,this.userData.layers.fromJSON(e.userData.layers,t,this)}};Object.defineProperties(or.prototype,{properties:{get:function(){return this.fragment.properties}},needsUpdate:{set:function(i){i===!0&&this.version++,this.needsCompile=i},get:function(){return this.needsCompile}}});import{UniformsLib as aN,UniformsUtils as lN}from"three";var ac=class extends ue{constructor(){super("basic");this.nodeType="Basic";this.color=new Be(nt)}generate(e){let t;if(e.isShader("vertex")){let r=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform(lN.merge([aN.fog])),e.addParsCode(["varying vec3 vViewPosition;","#include <fog_pars_vertex>","#include <normal_pars_vertex>"].join(`
709
+ `)}}();var Pt=class{constructor(e){this.id=2,this.layerCount=2,this.uuid=Vr.generateUUID(),this.needsUpdate=!1,this._material=e,this._layerNodes=[];let t=this._createLayer({id:0,type:Le.COLOR});this._material.color=t.color,this._material.alpha===void 0&&(this._material.alpha=new ee(1));let r=new ee(1),o=new ve(0);"shadingAlpha"in this._material&&"shadingBlend"in this._material&&(this._material.shadingAlpha=r,this._material.shadingBlend=o),this._layerNodes.push({id:0,type:ke.COLOR,color:t.color,alpha:t.alpha,mode:t.mode}),this._layerNodes.push({id:1,type:ke.LIGHTING,alpha:r,mode:o}),this.head=t.layer,this.head.next=new Je(1,void 0,{type:Le.LIGHTING,alpha:r,mode:o}),this.attachLightNodes(this.getLightLayer())}get material(){return this._material}set material(e){var n;this._material=e;let t,r,o=this.head;for(;o!==void 0;){if(o.type===Le.LIGHTING){t=o.uniforms[`f${o.id}_alpha`],r=o.uniforms[`f${o.id}_mode`];break}o=o.next}"shadingAlpha"in this._material&&"shadingBlend"in this._material&&(this._material.shadingAlpha=t,this._material.shadingBlend=r),this.attachLightNodes((n=e.userData.layers)==null?void 0:n.getLightLayer()),this.blendColors(),this.blendAfterColors(),this.blendPositions()}getLayersOfType(e){let t=[],r=this.head;for(;r;)r.type===e&&t.push(r),r=r.next;return t}addLayer(e){var o;if(e.id=(o=e.id)!=null?o:++this.id,this.layerCount++,e.type===Le.LIGHTING){let n=this.createLightLayer(e);return this.uuid=Vr.generateUUID(),this.blendColors(),this.blendAfterColors(),this.blendPositions(),n}let t=this._createLayer(e),r=t.layer;if(this.head===void 0)this.head=r;else{let n=this.head;for(;n.next!=null;)n=n.next;n.next=r}return t.color&&this._layerNodes.push({id:r.id,type:ke.COLOR,color:t.color,alpha:t.alpha,mode:t.mode}),t.position&&this._layerNodes.push({id:r.id,type:ke.POSITION,position:t.position}),this.uuid=Vr.generateUUID(),this.blendColors(),this.blendAfterColors(),this.blendPositions(),r}addLayerBeforeAt(e,t){var a;let r=this.head;e.id=(a=e.id)!=null?a:++this.id,this.layerCount++;let o=this._createLayer(e),n=o.layer;n.next=t;let s=0;if(r===t)this.head=n,o.color&&this._layerNodes.splice(0,0,{id:n.id,type:ke.COLOR,color:o.color,alpha:o.alpha,mode:o.mode}),o.position&&this._layerNodes.splice(0,0,{id:n.id,type:ke.POSITION,position:o.position});else{for(s=1;(r==null?void 0:r.next)!==t;)r=r==null?void 0:r.next,s++;r.next=n,o.color&&this._layerNodes.splice(s,0,{id:n.id,type:ke.COLOR,color:o.color,alpha:o.alpha,mode:o.mode}),o.position&&this._layerNodes.splice(s,0,{id:n.id,type:ke.POSITION,position:o.position})}return this.uuid=Vr.generateUUID(),this.blendColors(),this.blendAfterColors(),this.blendPositions(),n}addLayerAt(e,t){var n;t.id=(n=t.id)!=null?n:++this.id,this.layerCount++;let r=this._createLayer(t),o=r.layer;if(r.color&&this._layerNodes.splice(e,0,{id:o.id,type:ke.COLOR,color:r.color,alpha:r.alpha,mode:r.mode}),r.position&&this._layerNodes.splice(e,0,{id:o.id,type:ke.POSITION,position:r.position}),e==0)o.next=this.head,this.head=o;else{let s=this.head,a=this.head.next;for(let l=0;l<e-1;l++)s=a,a=a.next;o.next=a,s.next=o}return this.uuid=Vr.generateUUID(),this.blendColors(),this.blendAfterColors(),this.blendPositions(),o}removeLayer(e){let t=this.head,r,o=0;if((t==null?void 0:t.id)==e)this.head=t.next;else for(o=1,r=t,t=t==null?void 0:t.next;t!=null;){if(t.id==e){r.next=t.next;break}o++,r=t,t=t.next}return this.cleanupChangedLayer(t),this.blendColors(),this.blendAfterColors(),this.blendPositions(),this.uuid=Vr.generateUUID(),this.layerCount--,o}changeLayer(e,t){let r,o=this.head,n;if((o==null?void 0:o.id)==e){let s=this._createLayer(O({id:e,uuid:o.uuid},t));n=s.layer,n.next=o.next,this.head=n,s.color&&(this._layerNodes[0]={id:n.id,type:ke.COLOR,color:s.color,alpha:s.alpha,mode:s.mode}),s.position&&(this._layerNodes[0]={id:n.id,type:ke.POSITION,position:s.position}),n.uniforms[`f${e}_mode`].value=o.uniforms[`f${e}_mode`].value,n.uniforms[`f${e}_alpha`].value=o.uniforms[`f${e}_alpha`].value}else{r=o,o=o.next;let s=1;for(;o!=null;){if(o.id==e){let a=this._createLayer(O({id:e,uuid:o.uuid},t));n=a.layer,r.next=n,n.next=o.next,a.color&&(this._layerNodes[s]={id:e,type:ke.COLOR,color:a.color,alpha:a.alpha,mode:a.mode}),a.position&&(this._layerNodes[s]={id:e,type:ke.POSITION,position:a.position}),n.uniforms[`f${e}_mode`].value=o.uniforms[`f${e}_mode`].value,n.uniforms[`f${e}_alpha`].value=o.uniforms[`f${e}_alpha`].value;break}r=o,o=o.next,s++}}return this.uuid=Vr.generateUUID(),this.blendColors(),this.blendAfterColors(),this.blendPositions(),n}getLayer(e){let t=this.head;for(;t!=null&&t.id!=e;)t=t.next;return t}getLayerByUuid(e){let t=this.head;for(;t!==void 0;){if(t.uuid===e)return t;t=t.next}}getLayers(){let e=[],t=this.head;for(;t!=null;)e.push(t),t=t.next;return e}getLayerPosition(e){let t=this.head,r=0;for(;t!==void 0&&t.id!=e;)r++,t=t.next;return r}getDefines(){}getBeforeProgram(){}getLightingProgram(){}getAfterProgram(){}getVarPrograms(){}getUniforms(){}moveLayer(e,t){let r,o=this.head,n;if(e==0)r=this.head,this.head=r.next;else{for(let a=0;a<e;a++)n=o,o=o.next;n.next=o.next,r=o}if(o=this.head,n=void 0,t==0)r.next=this.head,this.head=r;else{for(let a=0;a<t-1;a++)o=o.next;r.next=o==null?void 0:o.next,o.next=r}let s=this._layerNodes.splice(e,1)[0];this._layerNodes.splice(t,0,s),this.uuid=Vr.generateUUID(),this.blendColors(),this.blendAfterColors()}updateLayerUniform(){this.uuid=Vr.generateUUID(),this.blendColors(),this.blendAfterColors()}copy(e){this.needsUpdate=!1,this.layerCount=e.layerCount,this._layerNodes=[],this.layerCount=0,this.head=void 0,this.rebuildLayerNodes(this.head,e.head);let t=e.head,r=this.head;for(;t.next!=null;)this.rebuildLayerNodes(r,t.next),r=r.next,t=t.next;return this.id=e.id,this.uuid=e.uuid,this.blendColors(),this.blendAfterColors(),this.blendPositions(),this}createLightLayer(e){let t=new ee(e.alpha),r=new ve(e.mode);this._material.shadingAlpha=t,this._material.shadingBlend=r,this._layerNodes.push({id:e.id,type:ke.LIGHTING,alpha:t,mode:r});let o=new Je(e.id,void 0,{type:Le.LIGHTING,alpha:t,mode:r});if(this.head===void 0)this.head=o;else{let n=this.head;for(;n.next!=null;)n=n.next;n.next=o}return this.attachLightNodes(this.getLightLayer()),o}rebuildLayerNodes(e,t,r=!1){if(t.type===Le.LIGHTING){let o=r?t.uniforms[`f${t.id}_alpha`]:new ee(t.uniforms[`f${t.id}_alpha`].value),n=r?t.uniforms[`f${t.id}_mode`]:new ve(t.uniforms[`f${t.id}_mode`].value);this._material.shadingAlpha=o,this._material.shadingBlend=n,this._layerNodes.push({id:t.id,type:ke.LIGHTING,alpha:o,mode:n}),this.head===void 0?this.head=new Je(t.id,t.uuid,{type:Le.LIGHTING,alpha:o,mode:n}):e&&(e.next=new Je(t.id,t.uuid,{type:Le.LIGHTING,alpha:o,mode:n})),this.attachLightNodes(t)}else{let o={type:t.type,id:t.id};for(let n in t.uniforms){let s=t.getName(n);if(!s)continue;let a=`f${t.id}_${s}`;if(Array.isArray(t.uniforms[a].value))o[s]=t.uniforms[a].value.map(l=>l.clone&&!r?l.clone():l);else{let l=t.uniforms[a].value;if(s==="transmissionDepthMap"){o[s]=l;continue}l!=null&&(o[s]=l.clone&&!r&&!l.isRenderTargetTexture?l.clone():l)}}this.addLayer(o)}}attachLightNodes(e){var o,n,s,a,l,c,d,p,u,f,m;let t={},r=this.getLightLayer();switch(this._material.userData.category){case"Lambert":t.emissive=new Ge((n=(o=e==null?void 0:e.getValue("emissive"))==null?void 0:o.clone())!=null?n:0);break;case"Phong":t.shininess=new ee((s=e==null?void 0:e.getValue("shininess"))!=null?s:30),t.specular=new Ge((l=(a=e==null?void 0:e.getValue("specular"))==null?void 0:a.clone())!=null?l:1118481);break;case"Toon":t.shininess=new ee((c=e==null?void 0:e.getValue("shininess"))!=null?c:30),t.specular=new Ge((p=(d=e==null?void 0:e.getValue("specular"))==null?void 0:d.clone())!=null?p:1118481);break;case"Physical":t.roughness=new ee((u=e==null?void 0:e.getValue("roughness"))!=null?u:.3),t.metalness=new ee((f=e==null?void 0:e.getValue("metalness"))!=null?f:0),t.reflectivity=new ee((m=e==null?void 0:e.getValue("reflectivity"))!=null?m:.5);break;default:break}Object.keys(t).forEach(x=>{this._material[x]=t[x],r.uniforms[`f${r.id}_${x}`]=t[x]})}clone(e){return new Pt(e).copy(this)}toJSON(e){return{id:this.id,uuid:this.uuid,head:this.head.toJSON(e)}}fromJSON(e,t,r){let o=new Je(e.head.id,void 0,{type:e.head.type}).fromJSON(e.head,t),n=e.head.next,s=o;for(;n!=null;)s.next=new Je(n.id,void 0,{type:n.type}).fromJSON(n,t),n=n.next,s=s.next;this._layerNodes=[],this.head=void 0,this.rebuildLayerNodes(this.head,o,!0);let a=o;for(s=this.head;a.next!=null;)this.rebuildLayerNodes(s,a.next,!0),s=s.next,a=a.next;return this._material=r,this.id=e.id,this.uuid=e.uuid,this.blendColors(),this.blendAfterColors(),this.blendPositions(),this}getLightLayer(){var t;let e=this.head;for(;e!==void 0&&e.type!=="light";)e=(t=e.next)!=null?t:e;return e}dispose(){let e=this.head;for(this._layerNodes=[],this.layerCount=0;e!==void 0;)e.hasOwnProperty("dispose")===!0&&e.dispose(),e=e.next;this.head=void 0}_createLayer(e){var r,o,n,s,a,l,c,d,p,u,f,m,x,y,N,L,w,B,S,_,T,h,I,b,P,v,D,Z,V,ie,oe,ge,xe,A,j,g,z,R,U,q,W,J,E,H,k,se,F,K,X,te,he,Y,ne,Se,me,Oe,He,rt,pt,zt,Tr,xt,Ir,uo,ho,qe,bt,Et,bn,vn,Sn,wn,Nn,Cn,$t,Li,ut,jo,Ln;let t=e.type;switch(t){case Le.COLOR:{let ye=new Ge((r=e.color)!=null?r:nt),Ce=new ee((o=e.alpha)!=null?o:1),we=new Be("alpha / clamp(alpha + accumAlpha, 0.00001, 1.0 )","f");we.keywords.alpha=Ce;let Ne=new ve((n=e.mode)!=null?n:0);return ye.alpha=Ce,{layer:new Je(e.id,e.uuid,{type:t,color:ye,alpha:Ce,calpha:we,mode:Ne}),color:ye,alpha:we,mode:Ne}}case Le.TEXTURE:{let ye=(s=e.texture)!=null?s:new Fr,Ce=ye.matrix;e.mat&&Ce.copy(e.mat),ye.needsUpdate=!0;let we=new ee((a=e.crop)!=null?a:0),Ne=new ve((l=e.projection)!=null?l:0),Te=new ve((c=e.axis)!=null?c:0),_e=new It(e.size?new so(e.size[0],e.size[1]):new so(100,100)),ze=new ee((d=e.alpha)!=null?d:1),Ee=new ve((p=e.mode)!=null?p:0),De=new Bt(ye),We=new Mt((u=e.textureSize)!=null?u:new ao(ye.image?ye.image.width:0,ye.image?ye.image.height:0)),ot=new sa(De,We,we,Ne,Te,_e,ze,Ee),Jt=new Be(ot.calpha,"f");return{layer:new Je(e.id,e.uuid,{type:t,texture:De,textureSize:We,crop:we,projection:Ne,axis:Te,size:_e,mat:ot.mat,alpha:ze,calpha:Jt,mode:Ee}),color:ot,alpha:Jt,mode:Ee}}case Le.MATCAP:{let ye=(f=e.texture)!=null?f:new Fr;ye.needsUpdate=!0;let Ce=new ee((m=e.alpha)!=null?m:1),we=new Bt(ye),Ne=new ve((x=e.mode)!=null?x:0),Te=new fa(we,Ce,Ne),_e=new Be(Te.calpha,"f");return{layer:new Je(e.id,e.uuid,{type:t,texture:we,alpha:Ce,calpha:_e,mode:Ne}),color:Te,alpha:_e,mode:Ne}}case Le.FRESNEL:{let ye=new Ge((y=e.color)!=null?y:16777215),Ce=new ee((N=e.bias)!=null?N:.1),we=new ee((L=e.scale)!=null?L:1),Ne=new ee((w=e.intensity)!=null?w:2),Te=new ee((B=e.factor)!=null?B:1),_e=new ee((S=e.alpha)!=null?S:1),ze=new ve((_=e.mode)!=null?_:0),Ee=new aa(ye,Ce,we,Ne,Te,_e,ze),De=new Be(Ee.calpha,"f");return{layer:new Je(e.id,e.uuid,{type:t,color:ye,bias:Ce,scale:we,intensity:Ne,factor:Te,alpha:_e,calpha:De,mode:ze}),color:Ee,alpha:De,mode:ze}}case Le.RAINBOW:{let ye=new ee((T=e.filmThickness)!=null?T:30),Ce=new ee((h=e.movement)!=null?h:0),we=new Mt((I=e.wavelengths)!=null?I:new ao(0,0,0)),Ne=new ee((b=e.noiseStrength)!=null?b:0),Te=new ee((P=e.noiseScale)!=null?P:1),_e=new Mt((v=e.offset)!=null?v:new ao(0,0,0)),ze=new ee((D=e.alpha)!=null?D:1),Ee=new la(ye,Ce,we,Ne,Te,_e,ze),De=new Be(Ee.calpha,"f"),We=new ve((Z=e.mode)!=null?Z:0);return{layer:new Je(e.id,e.uuid,{type:t,filmThickness:ye,movement:Ce,wavelengths:we,noiseStrength:Ne,noiseScale:Te,offset:_e,alpha:ze,calpha:De,mode:We}),color:Ee,alpha:De,mode:We}}case Le.TRANSMISSION:{let ye=new ee((V=e.thickness)!=null?V:10),Ce=new ee((ie=e.ior)!=null?ie:1.5),we=new ee((oe=e.roughness)!=null?oe:.5),Ne=new It((ge=e.transmissionSamplerSize)!=null?ge:new so(2048,2048)),Te=(xe=e.transmissionSamplerMap)!=null?xe:new Fr,_e=(A=e.transmissionDepthMap)!=null?A:new Fr,ze=new Bt(Te),Ee=new Bt(_e),De=window.innerWidth,We=window.innerHeight,ot=De>=We?new It(We/De,1):new It(1,De/We),Jt=new ee((j=e.alpha)!=null?j:1),Mr=new ca(ye,Ce,we,Ne,ze,Ee,ot,Jt),kr=new Be(Mr.calpha,"f"),Hr=new ve((g=e.mode)!=null?g:0);return{layer:new Je(e.id,e.uuid,{type:t,thickness:ye,ior:Ce,roughness:we,transmissionSamplerSize:Ne,transmissionSamplerMap:ze,transmissionDepthMap:Ee,aspectRatio:ot,alpha:Jt,calpha:kr,mode:Hr}),color:Mr,alpha:kr,mode:Hr}}case Le.DEPTH:{let ye=new ve((z=e.gradientType)!=null?z:0),Ce=new na((R=e.smooth)!=null?R:!1),we=new ee((U=e.near)!=null?U:50),Ne=new ee((q=e.far)!=null?q:200),Te=new ee((W=e.isVector)!=null?W:1),_e=new ee((J=e.isWorldSpace)!=null?J:0),ze=new Mt((E=e.origin)!=null?E:new ao),Ee=new Mt((H=e.direction)!=null?H:new ao),De=new ve((k=e.num)!=null?k:0),We;e.colors?We=new yi(De.value+1,e.colors):(We=new yi(De.value+1,new ya(0,0,0,1)),We.value[1]=new ya(1,1,1,1));let ot;e.steps?ot=new gi(e.steps.length,e.steps):(ot=new gi(10,1),ot.value[0]=0);let Jt=new ee((se=e.alpha)!=null?se:1),Mr=new ve((F=e.mode)!=null?F:0),kr=new ma(ye,Ce,we,Ne,Te,_e,ze,Ee,We,ot,De,Jt),Hr=new Be(kr.calpha,"f");return{layer:new Je(e.id,e.uuid,{type:t,gradientType:ye,smooth:Ce,near:we,far:Ne,isVector:Te,isWorldSpace:_e,origin:ze,direction:Ee,colors:We,steps:ot,num:De,alpha:Jt,calpha:Hr,mode:Mr}),color:kr,alpha:Hr,mode:Mr}}case Le.NOISE:{let ye=new ee((K=e.scale)!=null?K:1),Ce=new Mt((X=e.size)!=null?X:new ao(100,100,100)),we=new ee((te=e.move)!=null?te:1),Ne=new It((he=e.fA)!=null?he:new so(1.7,9.2)),Te=new It((Y=e.fB)!=null?Y:new so(8.3,2.8)),_e=new It((ne=e.distortion)!=null?ne:new so(1,1)),ze=new no(e.colorA),Ee=new no(e.colorB),De=new no(e.colorC),We=new no(e.colorD),ot=new ee((Se=e.alpha)!=null?Se:1),Jt=new ve((me=e.mode)!=null?me:0),Mr=new ve((Oe=e.noiseType)!=null?Oe:0),kr=new ua(ye,Ce,we,Ne,Te,_e,ze,Ee,De,We,ot,Mr),Hr=new Be(kr.calpha,"f");return{layer:new Je(e.id,e.uuid,{type:t,scale:ye,size:Ce,move:we,fA:Ne,fB:Te,distortion:_e,colorA:ze,colorB:Ee,colorC:De,colorD:We,alpha:ot,calpha:Hr,mode:Jt,noiseType:Mr}),color:kr,alpha:Hr,mode:Jt}}case Le.NORMAL:{let ye=new Mt((He=e.cnormal)!=null?He:new ao(1,1,1)),Ce=new ee((rt=e.alpha)!=null?rt:1),we=new ve((pt=e.mode)!=null?pt:0),Ne=new da(ye,Ce),Te=new Be("alpha / clamp(alpha + accumAlpha, 0.00001, 1.0 )","f");return Te.keywords.alpha=Ce,{layer:new Je(e.id,e.uuid,{type:t,cnormal:ye,alpha:Ce,calpha:Te,mode:we}),color:Ne,alpha:Te,mode:we}}case Le.GRADIENT:{let ye=new ve((zt=e.gradientType)!=null?zt:0),Ce=new na((Tr=e.smooth)!=null?Tr:!1),we;e.colors?we=new yi(e.colors.length,e.colors):(we=new yi(10,new ya(0,0,0,1)),we.value[1]=new ya(1,1,1,1));let Ne;e.steps?Ne=new gi(e.steps.length,e.steps):(Ne=new gi(10,1),Ne.value[0]=0);let Te=new It((xt=e.offset)!=null?xt:new so(0,0)),_e=new It((Ir=e.morph)!=null?Ir:new so(0,0)),ze=new ee((uo=e.angle)!=null?uo:0),Ee=new ee((ho=e.alpha)!=null?ho:1),De=new ve((qe=e.mode)!=null?qe:0),We=new pa(ye,Ce,we,Ne,Te,_e,ze,Ee),ot=new Be(We.calpha,"f");return{layer:new Je(e.id,e.uuid,{type:t,gradientType:ye,smooth:Ce,colors:we,steps:Ne,offset:Te,morph:_e,angle:ze,alpha:Ee,calpha:ot,mode:De}),color:We,alpha:ot,mode:De}}case Le.DISPLACE:{let ye=new ve((bt=e.displacementType)!=null?bt:0);if(ye.value===0){let Ce=new Mt((Et=e.offset)!=null?Et:new ao(0,0,0)),we=new ee((bn=e.scale)!=null?bn:10),Ne=new ee((vn=e.intensity)!=null?vn:8),Te=new ee((Sn=e.movement)!=null?Sn:1),_e=new ee((wn=e.alpha)!=null?wn:1),ze=new ve((Nn=e.mode)!=null?Nn:0),Ee=new ve((Cn=e.noiseType)!=null?Cn:0),De=new tn(ye,Ne,Te,Ce,we,Ee);return{layer:new Je(e.id,e.uuid,{displacementType:ye,type:t,offset:Ce,scale:we,intensity:Ne,movement:Te,alpha:_e,mode:ze,noiseType:Ee}),position:De}}else if(ye.value===1){let Ce=($t=e.texture)!=null?$t:new Fr,we=Ce.matrix;e.mat&&we.copy(e.mat),Ce.needsUpdate=!0;let Ne=new ee((Li=e.intensity)!=null?Li:8),Te=new Bt(Ce),_e=new ee((ut=e.crop)!=null?ut:0),ze=new ee((jo=e.alpha)!=null?jo:1),Ee=new ve((Ln=e.mode)!=null?Ln:0),De=new tn(ye,Ne,Te,_e);return{layer:new Je(e.id,e.uuid,{displacementType:ye,type:t,intensity:Ne,texture:Te,crop:_e,mat:De.mat,alpha:ze,mode:Ee}),position:De}}return{}}}return{}}blendColors(){let e=this._layerNodes.findIndex(r=>r.type===ke.COLOR),t=this._layerNodes.findIndex(r=>r.type===ke.LIGHTING);if(e!==-1&&e<t){let r=this._layerNodes[e].color;for(let o=e+1;o<t;++o){let n=this._layerNodes[o];n.type===ke.COLOR&&(r=new ha(r,n.color,n.alpha,n.mode))}this._material.color=r}else this._material.color=void 0}blendAfterColors(){let e=new Be("outgoingLight","f"),t=this._layerNodes.findIndex(r=>r.type===ke.LIGHTING);if(this._layerNodes.length>t+1){for(let r=t+1;r<this._layerNodes.length;++r){let o=this._layerNodes[r];o.type===ke.COLOR&&(e=new ha(e,o.color,o.alpha,o.mode))}"afterColor"in this._material&&(this._material.afterColor=e)}else"afterColor"in this._material&&(this._material.afterColor=void 0)}blendPositions(){let e=this._layerNodes.filter(t=>t.type===ke.POSITION);if(e.length>0){let t=e[0].position;for(let r=1;r<e.length;++r)e[r]&&(t=new qt(t,e[r].position,qt.ADD),t=new qt(t,new ee(.5).setReadonly(!0),qt.MUL));this._material.position=t}else this._material.position=void 0}cleanupChangedLayer(e){switch(this._layerNodes=this._layerNodes.filter(t=>t.id!==e.id),e.type){case Le.DISPLACE:{this.blendPositions();break}default:{this.blendColors(),this.blendAfterColors();break}}}};var rr=class extends kS{constructor(e,t,r){super(r);this.isNodeMaterial=!0;this.type="NodeMaterial";this.wireframeLinecap="";this.wireframeLinejoin="";this.uniformsBackup={};this.userData={type:"",category:"",nodeType:""};this.fog=!0,this.vertex=e!=null?e:new ia(new wt(wt.PROJECTION)),this.fragment=t!=null?t:new ia(new Ge(nt)),this.updaters=[],this.isDetached=!0,this.dithering=!0,this.onBeforeCompile=this._onBeforeCompile}getDefines(){return this.defines}getUniforms(){return this.uniforms}getVertexShader(){return this.vertexShader}getFragmentShader(){return this.fragmentShader}_onBeforeCompile(e,t){this.build({renderer:t}),e.defines=this.defines,e.uniforms=this.uniforms,e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader,e.extensionDerivatives=this.extensions.derivatives===!0,e.extensionFragDepth=this.extensions.fragDepth===!0,e.extensionDrawBuffers=this.extensions.drawBuffers===!0,e.extensionShaderTextureLOD=this.extensions.shaderTextureLOD===!0}_getLayerStack(e){let t=new Pt(this);return e&&(async()=>{for(;e.image===void 0;)await new Promise(r=>requestAnimationFrame(r));t.addLayerAt(1,{type:Le.TEXTURE,texture:e}),this.dispose()})(),t}clampUniformsForPreview(e,t){let r=(o,n,s)=>Math.min(Math.max(o,n),s);if(this.userData.layers){for(let o of this.userData.layers.getLayers())if(o.type==Le.DISPLACE){this.uniformsBackup[`f${o.id}_intensity`]=o.uniforms[`f${o.id}_intensity`].value;let n=r(o.uniforms[`f${o.id}_intensity`].value,e,t);o.uniforms[`f${o.id}_intensity`].value=n}}}restoreClampedUniforms(){if(this.userData.layers)for(let e of this.userData.layers.getLayers())e.type==Le.DISPLACE&&(e.uniforms[`f${e.id}_intensity`].value=this.uniformsBackup[`f${e.id}_intensity`])}customProgramCacheKey(){return this.getHash()}updateFrame(e){for(let t=0;t<this.updaters.length;++t)e.updateNode(this.updaters[t])}build(e){var r;e=e!=null?e:{};let t=(r=e.builder)!=null?r:new El;return t.setMaterial(this,e.renderer),t.build(this.vertex,this.fragment),this.vertexShader=t.getCode("vertex"),this.fragmentShader=t.getCode("fragment"),this.defines=t.defines,this.uniforms=t.uniforms,this.extensions=t.extensions,this.updaters=t.updaters,this.fog=t.requires.fog,this.lights=t.requires.lights,this.transparent=t.requires.transparent||this.blending>US,this}getHash(){let e="{";return e+='"vertex":'+this.vertex.getHash()+",",e+='"fragment":'+this.fragment.getHash(),e+="}",e}copy(e){let t=this.uuid;for(let r in e)this[r]=e[r];return this.uuid=t,e.userData!==void 0&&(this.userData=JSON.parse(JSON.stringify(e.userData))),this}toJSON(e){let t=this.userData.layers;this.userData.layers=void 0;let r=super.toJSON(e);return r.type="ShaderMaterial",r.userData={type:this.userData.type,category:this.userData.category,nodeType:this.type,layers:t.toJSON(e)},r.vertex=this.vertex.toJSON(e).uuid,r.fragment=this.fragment.toJSON(e).uuid,delete r.vertexShader,delete r.fragmentShader,delete r.color,delete r.shininess,delete r.specular,delete r.roughness,delete r.metalness,delete r.uniforms,e&&!e.materials[this.uuid]&&(e.materials[this.uuid]=r),this.userData.layers=t,r}fromJSON(e,t){var r;this.defines=(r=e.defines)!=null?r:{},this.depthFunc=e.depthFunc,this.depthWrite=e.depthWrite,this.side=e.side!==void 0?e.side:HS,this.transparent=e.transparent,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.wireframe=e.wireframe,this.userData.layers.fromJSON(e.userData.layers,t,this)}};Object.defineProperties(rr.prototype,{properties:{get:function(){return this.fragment.properties}},needsUpdate:{set:function(i){i===!0&&this.version++,this.needsCompile=i},get:function(){return this.needsCompile}}});import{UniformsLib as qS,UniformsUtils as WS}from"three";var Wl=class extends pe{constructor(){super("basic");this.nodeType="Basic";this.color=new Ge(nt)}generate(e){let t;if(e.isShader("vertex")){let r=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform(WS.merge([qS.fog])),e.addParsCode(["varying vec3 vViewPosition;","#include <fog_pars_vertex>","#include <normal_pars_vertex>"].join(`
713
710
  `));let o=["#include <beginnormal_vertex>",`
714
711
  #if !defined( USE_LAYER_DISPLACE )
715
712
  #include <defaultnormal_vertex>
@@ -727,9 +724,9 @@ vec4 getIBLVolumeRefraction( vec3 n, vec3 v, float roughness, vec3 position, mat
727
724
  #include <begin_vertex>
728
725
  #endif /* !USE_LAYER_DISPLACE */
729
726
  `];r&&o.push(r.code,r.result?"displaced_position = "+r.result+";":""),o.push("transformed = displaced_position;","transformedNormal = normalMatrix * displaced_normal;","#ifndef FLAT_SHADED"," vNormal = transformedNormal;","#endif"),o.push("#include <project_vertex>","#include <fog_vertex>","#include <clipping_planes_vertex>"," vViewPosition = - mvPosition.xyz;","#include <worldpos_vertex>"),t=o.join(`
730
- `)}else{this.color===void 0&&(this.color=new Be(nt)),this.color.analyze(e,{slot:"color"}),this.alpha&&this.alpha.analyze(e),this.afterColor&&this.afterColor.analyze(e,{slot:"afterColor"});let r=this.color.flow(e,"c",{slot:"color"}),o=this.alpha?this.alpha.flow(e,"f"):void 0,s=this.afterColor?this.afterColor.flow(e,"c",{slot:"afterColor"}):void 0;e.requires.transparent=o!==void 0,e.addParsCode(["#include <fog_pars_fragment>","#include <dithering_pars_fragment>","varying vec3 vViewPosition;","#include <normal_pars_fragment>"].join(`
731
- `));let n=["#include <normal_fragment_begin>",r.code];o&&n.push(o.code,"#ifdef ALPHATEST"," if ( "+o.result+" <= ALPHATEST ) discard;","#endif"),s?n.push(s.code,`vec3 outgoingLight = ${r.result};`,`vec3 finalColor = spe_blend(outgoingLight, ${s.result}, 1.0, SPE_BLENDING_NORMAL);`):n.push(`vec3 finalColor = ${r.result};`),o?n.push(`gl_FragColor = vec4( finalColor, accumAlpha * ${o.result} );`):n.push("gl_FragColor = vec4("+r.result+", 1.0 );"),n.push("#include <fog_fragment>","#include <dithering_fragment>"),t=n.join(`
732
- `)}return t}copy(e){return super.copy(e),e.color&&(this.color=e.color.clone()),e.position&&(this.position=e.position.clone()),e.alpha&&(this.alpha=e.alpha.clone()),e.afterColor&&(this.afterColor=e.afterColor.clone()),e.shadingAlpha&&(this.shadingAlpha=e.shadingAlpha.clone()),e.shadingBlend&&(this.shadingBlend=e.shadingBlend.clone()),this}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),this.color&&(t.color=this.color.toJSON(e).uuid),this.position&&(t.position=this.position.toJSON(e).uuid),this.alpha&&(t.alpha=this.alpha.toJSON(e).uuid),this.afterColor&&(t.afterColor=this.afterColor.toJSON(e).uuid),this.shadingAlpha&&(t.shadingAlpha=this.shadingAlpha.toJSON(e).uuid),this.shadingBlend&&(t.shadingBlend=this.shadingBlend.toJSON(e).uuid)),t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),e.position&&(this.position=t.getNode(e.position)),e.color&&(this.color=t.getNode(e.color)),e.alpha&&(this.alpha=t.getNode(e.alpha)),e.afterColor&&(this.afterColor=t.getNode(e.afterColor)),e.shadingAlpha&&(this.shadingAlpha=t.getNode(e.shadingAlpha)),e.shadingBlend&&(this.shadingBlend=t.getNode(e.shadingBlend)),this}};var lc=class extends or{get color(){return this.fragment.color}set color(e){this.fragment.color=e}get afterColor(){return this.fragment.afterColor}set afterColor(e){this.fragment.afterColor=e}get alpha(){return this.fragment.alpha}set alpha(e){this.fragment.alpha=e}get shadingAlpha(){return this.fragment.shadingAlpha}set shadingAlpha(e){this.fragment.shadingAlpha=e}get shadingBlend(){return this.fragment.shadingBlend}set shadingBlend(e){this.fragment.shadingBlend=e}get position(){return this.fragment.position}set position(e){this.fragment.position=e}constructor(e=new ac,t){super(e,e,t);this.type="BasicNodeMaterial",this.fragment=e}};var Ct=class extends lc{constructor(e,t,r){super(t,e);this.userData.type="BasicMaterial",this.userData.category="Basic",this.userData.layers=r!=null?r:this._getLayerStack(e==null?void 0:e.map)}get layersList(){return this.userData.layers}set layersList(e){this.userData.layers=e}equals(e){return this.userData.type===e.userData.type&&this.userData.layers.uuid==e.userData.layers.uuid}copy(e){if(e.userData.layers!==void 0&&e.userData.layers instanceof At){let t=e.userData.layers,r=e.fragment;super.copy(e);let o=r.clone();this.fragment=o,this.vertex=o;let s=t.clone(this);this.userData.layers=s}else super.copy(e);return this}static fromJSON(e,t,r){let o=r.getNode(t.vertex),s=new Ct(void 0,o);return s.fromJSON(t,r),s}static fromMaterial(e){let t=new Ct(e.map?{map:e.map}:{}),r=t.fragment;return r.color.value.copy(e.color),r.alpha.value=e.opacity,t}dispose(){super.dispose()}};import{UniformsLib as nf,UniformsUtils as cN}from"three";var cc=class extends ue{constructor(){super("phong");this.nodeType="Phong";this.color=new Be(nt),this.specular=new Be(1118481),this.shininess=new re(30),this.shadingAlpha=new re(1),this.shadingBlend=new Se(0)}build(e){let t;if(e.define("PHONG"),e.requires.lights=!0,e.extensions.derivatives=!0,e.isShader("vertex")){let r=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform(cN.merge([nf.fog,nf.lights])),e.addParsCode(["varying vec3 vViewPosition;","#include <fog_pars_vertex>","#include <normal_pars_vertex>","#include <shadowmap_pars_vertex>","#include <clipping_planes_pars_vertex>"].join(`
727
+ `)}else{this.color===void 0&&(this.color=new Ge(nt)),this.color.analyze(e,{slot:"color"}),this.alpha&&this.alpha.analyze(e),this.afterColor&&this.afterColor.analyze(e,{slot:"afterColor"});let r=this.color.flow(e,"c",{slot:"color"}),o=this.alpha?this.alpha.flow(e,"f"):void 0,n=this.afterColor?this.afterColor.flow(e,"c",{slot:"afterColor"}):void 0;e.requires.transparent=o!==void 0,e.addParsCode(["#include <fog_pars_fragment>","#include <dithering_pars_fragment>","varying vec3 vViewPosition;","#include <normal_pars_fragment>"].join(`
728
+ `));let s=["#include <normal_fragment_begin>",r.code];o&&s.push(o.code,"#ifdef ALPHATEST"," if ( "+o.result+" <= ALPHATEST ) discard;","#endif"),n?s.push(n.code,`vec3 outgoingLight = ${r.result};`,`vec3 finalColor = spe_blend(outgoingLight, ${n.result}, 1.0, SPE_BLENDING_NORMAL);`):s.push(`vec3 finalColor = ${r.result};`),o?s.push(`gl_FragColor = vec4( finalColor, accumAlpha * ${o.result} );`):s.push("gl_FragColor = vec4("+r.result+", 1.0 );"),s.push("#include <fog_fragment>","#include <dithering_fragment>"),t=s.join(`
729
+ `)}return t}copy(e){return super.copy(e),e.color&&(this.color=e.color.clone()),e.position&&(this.position=e.position.clone()),e.alpha&&(this.alpha=e.alpha.clone()),e.afterColor&&(this.afterColor=e.afterColor.clone()),e.shadingAlpha&&(this.shadingAlpha=e.shadingAlpha.clone()),e.shadingBlend&&(this.shadingBlend=e.shadingBlend.clone()),this}};var $l=class extends rr{get color(){return this.fragment.color}set color(e){this.fragment.color=e}get afterColor(){return this.fragment.afterColor}set afterColor(e){this.fragment.afterColor=e}get alpha(){return this.fragment.alpha}set alpha(e){this.fragment.alpha=e}get shadingAlpha(){return this.fragment.shadingAlpha}set shadingAlpha(e){this.fragment.shadingAlpha=e}get shadingBlend(){return this.fragment.shadingBlend}set shadingBlend(e){this.fragment.shadingBlend=e}get position(){return this.fragment.position}set position(e){this.fragment.position=e}constructor(e=new Wl,t){super(e,e,t);this.type="BasicNodeMaterial",this.fragment=e}};var Nt=class extends $l{constructor(e,t,r){super(t,e);this.userData.type="BasicMaterial",this.userData.category="Basic",this.userData.layers=r!=null?r:this._getLayerStack(e==null?void 0:e.map)}get layersList(){return this.userData.layers}set layersList(e){this.userData.layers=e}equals(e){return this.userData.type===e.userData.type&&this.userData.layers.uuid==e.userData.layers.uuid}copy(e){if(e.userData.layers!==void 0&&e.userData.layers instanceof Pt){let t=e.userData.layers,r=e.fragment;super.copy(e);let o=r.clone();this.fragment=o,this.vertex=o;let n=t.clone(this);this.userData.layers=n}else super.copy(e);return this}static fromJSON(e,t,r){let o=r.getNode(t.vertex),n=new Nt(void 0,o);return n.fromJSON(t,r),n}static fromMaterial(e){let t=new Nt(e.map?{map:e.map}:{}),r=t.fragment;return r.color.value.copy(e.color),r.alpha.value=e.opacity,t}dispose(){super.dispose()}};import{UniformsLib as Wh,UniformsUtils as $S}from"three";var Jl=class extends pe{constructor(){super("phong");this.nodeType="Phong";this.color=new Ge(nt),this.specular=new Ge(1118481),this.shininess=new ee(30),this.shadingAlpha=new ee(1),this.shadingBlend=new ve(0)}build(e){let t;if(e.define("PHONG"),e.requires.lights=!0,e.extensions.derivatives=!0,e.isShader("vertex")){let r=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform($S.merge([Wh.fog,Wh.lights])),e.addParsCode(["varying vec3 vViewPosition;","#include <fog_pars_vertex>","#include <normal_pars_vertex>","#include <shadowmap_pars_vertex>","#include <clipping_planes_pars_vertex>"].join(`
733
730
  `));let o=["#include <beginnormal_vertex>",`
734
731
  #ifndef USE_LAYER_DISPLACE
735
732
  #include <defaultnormal_vertex>
@@ -747,7 +744,7 @@ vec4 getIBLVolumeRefraction( vec3 n, vec3 v, float roughness, vec3 position, mat
747
744
  #include <begin_vertex>
748
745
  #endif
749
746
  `];r&&o.push(r.code,r.result?"displaced_position = "+r.result+";":""),o.push("transformed = displaced_position;","transformedNormal = normalMatrix * displaced_normal;","#ifndef FLAT_SHADED"," vNormal = transformedNormal;","#endif"),o.push(" #include <project_vertex>"," #include <clipping_planes_vertex>"," vViewPosition = - mvPosition.xyz;"," #include <worldpos_vertex>"," #include <shadowmap_vertex>"," #include <fog_vertex>"),t=o.join(`
750
- `)}else{this.color===void 0&&(this.color=new Be(nt)),this.color.analyze(e,{slot:"color"}),this.specular.analyze(e),this.shininess.analyze(e),this.shadingAlpha.analyze(e),this.shadingBlend.analyze(e),this.afterColor&&this.afterColor.analyze(e,{slot:"afterColor"}),this.alpha&&this.alpha.analyze(e);let r=this.color.flow(e,"c",{slot:"color"}),o=this.specular.flow(e,"c"),s=this.shininess.flow(e,"f"),n=this.shadingAlpha.flow(e,"f"),a=this.shadingBlend.flow(e,"i"),l=this.afterColor?this.afterColor.flow(e,"c",{slot:"afterColor"}):void 0,c=this.alpha?this.alpha.flow(e,"f"):void 0;e.requires.transparent=c!==void 0,e.addParsCode(["uniform vec3 emissive;","#include <normal_pars_fragment>","#include <fog_pars_fragment>","#include <bsdfs>","#include <lights_pars_begin>","#include <lights_phong_pars_fragment>","#include <shadowmap_pars_fragment>","#include <dithering_pars_fragment>"].join(`
747
+ `)}else{this.color===void 0&&(this.color=new Ge(nt)),this.color.analyze(e,{slot:"color"}),this.specular.analyze(e),this.shininess.analyze(e),this.shadingAlpha.analyze(e),this.shadingBlend.analyze(e),this.afterColor&&this.afterColor.analyze(e,{slot:"afterColor"}),this.alpha&&this.alpha.analyze(e);let r=this.color.flow(e,"c",{slot:"color"}),o=this.specular.flow(e,"c"),n=this.shininess.flow(e,"f"),s=this.shadingAlpha.flow(e,"f"),a=this.shadingBlend.flow(e,"i"),l=this.afterColor?this.afterColor.flow(e,"c",{slot:"afterColor"}):void 0,c=this.alpha?this.alpha.flow(e,"f"):void 0;e.requires.transparent=c!==void 0,e.addParsCode(["uniform vec3 emissive;","#include <normal_pars_fragment>","#include <fog_pars_fragment>","#include <bsdfs>","#include <lights_pars_begin>","#include <lights_phong_pars_fragment>","#include <shadowmap_pars_fragment>","#include <dithering_pars_fragment>"].join(`
751
748
  `));let d=["#include <normal_fragment_begin>",`
752
749
  // NOTE: gl_FrontFacing alternative using face normal estimation.
753
750
  vec3 viewdx = dFdx(vViewPosition);
@@ -756,14 +753,14 @@ vec4 getIBLVolumeRefraction( vec3 n, vec3 v, float roughness, vec3 position, mat
756
753
  if (dot(normal, faceNormal) < 0.0) {
757
754
  normal *= -1.0;
758
755
  }
759
- `," BlinnPhongMaterial material;"];d.push(r.code," vec3 diffuseColor = "+r.result+";"," ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );"," vec3 totalEmissiveRadiance = emissive;",o.code," vec3 specular = "+o.result+";",s.code," float shininess = max( 0.0001, "+s.result+" );"," float specularStrength = 1.0;"),c&&d.push(c.code,"#ifdef ALPHATEST","if ( "+c.result+" <= ALPHATEST ) discard;","#endif"),d.push("material.diffuseColor = diffuseColor;"),d.push("material.specularColor = specular;","material.specularShininess = shininess;","material.specularStrength = specularStrength;","#include <lights_fragment_begin>","#include <lights_fragment_end>"),d.push("vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;"),d.push(`
756
+ `," BlinnPhongMaterial material;"];d.push(r.code," vec3 diffuseColor = "+r.result+";"," ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );"," vec3 totalEmissiveRadiance = emissive;",o.code," vec3 specular = "+o.result+";",n.code," float shininess = max( 0.0001, "+n.result+" );"," float specularStrength = 1.0;"),c&&d.push(c.code,"#ifdef ALPHATEST","if ( "+c.result+" <= ALPHATEST ) discard;","#endif"),d.push("material.diffuseColor = diffuseColor;"),d.push("material.specularColor = specular;","material.specularShininess = shininess;","material.specularStrength = specularStrength;","#include <lights_fragment_begin>","#include <lights_fragment_end>"),d.push("vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;"),d.push(`
760
757
  if (outgoingLight != diffuseColor) {
761
758
  float lightAccu = clamp( length( reflectedLight.directSpecular + reflectedLight.indirectSpecular ), 0.0, 1.0 );
762
- accumAlpha += ( 1.0 - accumAlpha ) * ${n.result} * lightAccu;
763
- outgoingLight = spe_blend( diffuseColor, outgoingLight, ${n.result}, ${a.result} );
759
+ accumAlpha += ( 1.0 - accumAlpha ) * ${s.result} * lightAccu;
760
+ outgoingLight = spe_blend( diffuseColor, outgoingLight, ${s.result}, ${a.result} );
764
761
  }
765
762
  `),l&&d.push(l.code,`outgoingLight = spe_blend(outgoingLight, ${l.result}, 1.0, SPE_BLENDING_NORMAL);`),c?d.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${c.result} );`):d.push("gl_FragColor = vec4( outgoingLight, 1.0 );"),d.push("#include <encodings_fragment>","#include <fog_fragment>","#include <dithering_fragment>"),t=d.join(`
766
- `)}return t}copy(e){return super.copy(e),e.color&&(this.color=e.color.clone()),this.specular=e.specular.clone(),this.shininess=e.shininess.clone(),e.position&&(this.position=e.position.clone()),e.afterColor&&(this.afterColor=e.afterColor.clone()),e.alpha&&(this.alpha=e.alpha.clone()),e.shadingAlpha&&(this.shadingAlpha=e.shadingAlpha.clone()),e.shadingBlend&&(this.shadingBlend=e.shadingBlend.clone()),this}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),this.position&&(t.position=this.position.toJSON(e).uuid),this.color&&(t.color=this.color.toJSON(e).uuid),t.specular=this.specular.toJSON(e).uuid,t.shininess=this.shininess.toJSON(e).uuid,t.shadingAlpha=this.shadingAlpha.toJSON(e).uuid,t.shadingBlend=this.shadingBlend.toJSON(e).uuid,this.afterColor&&(t.afterColor=this.afterColor.toJSON(e).uuid),this.alpha&&(t.alpha=this.alpha.toJSON(e).uuid)),t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),e.position&&(this.position=t.getNode(e.position)),e.color&&(this.color=t.getNode(e.color)),e.specular&&(this.specular=t.getNode(e.specular)),e.shininess&&(this.shininess=t.getNode(e.shininess)),e.alpha&&(this.alpha=t.getNode(e.alpha)),e.shadingAlpha&&(this.shadingAlpha=t.getNode(e.shadingAlpha)),e.shadingBlend&&(this.shadingBlend=t.getNode(e.shadingBlend)),e.afterColor&&(this.afterColor=t.getNode(e.afterColor)),this}};var dc=class extends or{get color(){return this.fragment.color}set color(e){this.fragment.color=e}get afterColor(){return this.fragment.afterColor}set afterColor(e){this.fragment.afterColor=e}get alpha(){return this.fragment.alpha}set alpha(e){this.fragment.alpha=e}get shadingAlpha(){return this.fragment.shadingAlpha}set shadingAlpha(e){this.fragment.shadingAlpha=e}get shadingBlend(){return this.fragment.shadingBlend}set shadingBlend(e){this.fragment.shadingBlend=e}get position(){return this.fragment.position}set position(e){this.fragment.position=e}get specular(){return this.fragment.specular}set specular(e){this.fragment.specular=e}get shininess(){return this.fragment.shininess}set shininess(e){this.fragment.shininess=e}constructor(e=new cc,t){super(e,e,t);this.type="PhongNodeMaterial",this.fragment=e}};var ir=class extends dc{constructor(e,t,r){super(t,e);this.userData.type="PhongMaterial",this.userData.category="Phong",this.userData.layers=r!=null?r:this._getLayerStack(e==null?void 0:e.map)}get layersList(){return this.userData.layers}set layersList(e){this.userData.layers=e}equals(e){return this.userData.type===e.userData.type&&this.userData.layers.uuid==e.userData.layers.uuid}copy(e){if(e.userData.layers!==void 0&&e.userData.layers instanceof At){let t=e.userData.layers,r=e.fragment;super.copy(e);let o=r.clone();this.fragment=o,this.vertex=o;let s=t.clone(this);this.userData.layers=s,o.shadingAlpha.value=r.shadingAlpha.value,o.shadingBlend.value=r.shadingBlend.value}else super.copy(e);return this}static fromJSON(e,t,r){let o=r.getNode(t.vertex),s=new ir(void 0,o);return s.fromJSON(t,r),s}static fromMaterial(e){let t=new ir(e.map?{map:e.map}:{}),r=t.fragment;return r.color.value.copy(e.color),r.alpha.value=e.opacity,t}dispose(){super.dispose()}};import{UniformsLib as af,UniformsUtils as dN}from"three";var hc=class extends ue{constructor(){super("lambert");this.nodeType="Lambert";this.color=new Be(nt),this.emissive=new Be(0),this.emissiveIntensity=new re(1),this.shadingAlpha=new re(1),this.shadingBlend=new Se(0)}build(e){let t;if(e.define("LAMBERT"),e.requires.lights=!0,e.extensions.derivatives=!0,e.isShader("vertex")){let r=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform(dN.merge([af.fog,af.lights])),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vLightFront;","varying vec3 vIndirectFront;","#ifndef DOUBLE_SIDED"," #define DOUBLE_SIDED","#endif","#ifdef DOUBLE_SIDED"," varying vec3 vLightBack;"," varying vec3 vIndirectBack;","#endif","#include <bsdfs>","#include <lights_pars_begin>","#include <color_pars_vertex>","#include <fog_pars_vertex>","#include <normal_pars_vertex>","#include <shadowmap_pars_vertex>","#include <clipping_planes_pars_vertex>"].join(`
763
+ `)}return t}copy(e){return super.copy(e),e.color&&(this.color=e.color.clone()),this.specular=e.specular.clone(),this.shininess=e.shininess.clone(),e.position&&(this.position=e.position.clone()),e.afterColor&&(this.afterColor=e.afterColor.clone()),e.alpha&&(this.alpha=e.alpha.clone()),e.shadingAlpha&&(this.shadingAlpha=e.shadingAlpha.clone()),e.shadingBlend&&(this.shadingBlend=e.shadingBlend.clone()),this}};var Kl=class extends rr{get color(){return this.fragment.color}set color(e){this.fragment.color=e}get afterColor(){return this.fragment.afterColor}set afterColor(e){this.fragment.afterColor=e}get alpha(){return this.fragment.alpha}set alpha(e){this.fragment.alpha=e}get shadingAlpha(){return this.fragment.shadingAlpha}set shadingAlpha(e){this.fragment.shadingAlpha=e}get shadingBlend(){return this.fragment.shadingBlend}set shadingBlend(e){this.fragment.shadingBlend=e}get position(){return this.fragment.position}set position(e){this.fragment.position=e}get specular(){return this.fragment.specular}set specular(e){this.fragment.specular=e}get shininess(){return this.fragment.shininess}set shininess(e){this.fragment.shininess=e}constructor(e=new Jl,t){super(e,e,t);this.type="PhongNodeMaterial",this.fragment=e}};var or=class extends Kl{constructor(e,t,r){super(t,e);this.userData.type="PhongMaterial",this.userData.category="Phong",this.userData.layers=r!=null?r:this._getLayerStack(e==null?void 0:e.map)}get layersList(){return this.userData.layers}set layersList(e){this.userData.layers=e}equals(e){return this.userData.type===e.userData.type&&this.userData.layers.uuid==e.userData.layers.uuid}copy(e){if(e.userData.layers!==void 0&&e.userData.layers instanceof Pt){let t=e.userData.layers,r=e.fragment;super.copy(e);let o=r.clone();this.fragment=o,this.vertex=o;let n=t.clone(this);this.userData.layers=n,o.shadingAlpha.value=r.shadingAlpha.value,o.shadingBlend.value=r.shadingBlend.value}else super.copy(e);return this}static fromJSON(e,t,r){let o=r.getNode(t.vertex),n=new or(void 0,o);return n.fromJSON(t,r),n}static fromMaterial(e){let t=new or(e.map?{map:e.map}:{}),r=t.fragment;return r.color.value.copy(e.color),r.alpha.value=e.opacity,t}dispose(){super.dispose()}};import{UniformsLib as $h,UniformsUtils as JS}from"three";var Xl=class extends pe{constructor(){super("lambert");this.nodeType="Lambert";this.color=new Ge(nt),this.emissive=new Ge(0),this.emissiveIntensity=new ee(1),this.shadingAlpha=new ee(1),this.shadingBlend=new ve(0)}build(e){let t;if(e.define("LAMBERT"),e.requires.lights=!0,e.extensions.derivatives=!0,e.isShader("vertex")){let r=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform(JS.merge([$h.fog,$h.lights])),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vLightFront;","varying vec3 vIndirectFront;","#ifndef DOUBLE_SIDED"," #define DOUBLE_SIDED","#endif","#ifdef DOUBLE_SIDED"," varying vec3 vLightBack;"," varying vec3 vIndirectBack;","#endif","#include <bsdfs>","#include <lights_pars_begin>","#include <color_pars_vertex>","#include <fog_pars_vertex>","#include <normal_pars_vertex>","#include <shadowmap_pars_vertex>","#include <clipping_planes_pars_vertex>"].join(`
767
764
  `));let o=["#include <beginnormal_vertex>",`
768
765
  #ifndef USE_LAYER_DISPLACE
769
766
  #include <defaultnormal_vertex>
@@ -855,21 +852,21 @@ vec4 getIBLVolumeRefraction( vec3 n, vec3 v, float roughness, vec3 position, mat
855
852
  #pragma unroll_loop_end
856
853
  #endif
857
854
  `," #include <shadowmap_vertex>"," #include <fog_vertex>"),t=o.join(`
858
- `)}else{this.color===void 0&&(this.color=new Be(nt)),this.color.analyze(e,{slot:"color"}),this.shadingAlpha.analyze(e),this.shadingBlend.analyze(e),this.afterColor&&this.afterColor.analyze(e,{slot:"afterColor"}),this.alpha&&this.alpha.analyze(e);let r=this.color.flow(e,"c",{slot:"color"}),o=this.emissive.flow(e,"c",{slot:"emissive"}),s=this.emissiveIntensity.flow(e,"f",{slot:"emissive"}),n=this.shadingAlpha.flow(e,"f"),a=this.shadingBlend.flow(e,"i"),l=this.afterColor?this.afterColor.flow(e,"c",{slot:"afterColor"}):void 0,c=this.alpha?this.alpha.flow(e,"f"):void 0;e.requires.transparent=c!==void 0,e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vLightFront;","varying vec3 vIndirectFront;","#ifndef DOUBLE_SIDED"," #define DOUBLE_SIDED","#endif","#include <normal_pars_fragment>","#ifdef DOUBLE_SIDED"," varying vec3 vLightBack;"," varying vec3 vIndirectBack;","#endif","#include <bsdfs>","#include <lights_pars_begin>","#include <fog_pars_fragment>","#include <shadowmap_pars_fragment>","#include <shadowmask_pars_fragment>","#include <clipping_planes_pars_fragment>","#include <dithering_pars_fragment>"].join(`
855
+ `)}else{this.color===void 0&&(this.color=new Ge(nt)),this.color.analyze(e,{slot:"color"}),this.shadingAlpha.analyze(e),this.shadingBlend.analyze(e),this.afterColor&&this.afterColor.analyze(e,{slot:"afterColor"}),this.alpha&&this.alpha.analyze(e);let r=this.color.flow(e,"c",{slot:"color"}),o=this.emissive.flow(e,"c",{slot:"emissive"}),n=this.emissiveIntensity.flow(e,"f",{slot:"emissive"}),s=this.shadingAlpha.flow(e,"f"),a=this.shadingBlend.flow(e,"i"),l=this.afterColor?this.afterColor.flow(e,"c",{slot:"afterColor"}):void 0,c=this.alpha?this.alpha.flow(e,"f"):void 0;e.requires.transparent=c!==void 0,e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vLightFront;","varying vec3 vIndirectFront;","#ifndef DOUBLE_SIDED"," #define DOUBLE_SIDED","#endif","#include <normal_pars_fragment>","#ifdef DOUBLE_SIDED"," varying vec3 vLightBack;"," varying vec3 vIndirectBack;","#endif","#include <bsdfs>","#include <lights_pars_begin>","#include <fog_pars_fragment>","#include <shadowmap_pars_fragment>","#include <shadowmask_pars_fragment>","#include <clipping_planes_pars_fragment>","#include <dithering_pars_fragment>"].join(`
859
856
  `));let d=["#include <normal_fragment_begin>",`
860
857
  // NOTE: gl_FrontFacing alternative using face normal estimation.
861
858
  vec3 viewdx = dFdx(vViewPosition);
862
859
  vec3 viewdy = dFdy(vViewPosition);
863
860
  vec3 faceNormal = normalize(cross(viewdx, viewdy));
864
861
  bool isFrontFacing = (dot(normal, faceNormal) >= 0.0);
865
- `,"#include <clipping_planes_fragment>"];d.push(r.code,"vec3 diffuseColor = "+r.result+";","ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );"),c&&d.push(c.code,"#ifdef ALPHATEST","if ( "+c.result+" <= ALPHATEST ) discard;","#endif"),d.push("#ifdef DOUBLE_SIDED"," reflectedLight.indirectDiffuse += ( isFrontFacing ) ? vIndirectFront : vIndirectBack;","#else"," reflectedLight.indirectDiffuse += vIndirectFront;","#endif","#include <lightmap_fragment>","reflectedLight.indirectDiffuse *= BRDF_Lambert( diffuseColor.rgb );","#ifdef DOUBLE_SIDED"," reflectedLight.directDiffuse = ( isFrontFacing ) ? vLightFront : vLightBack;","#else"," reflectedLight.directDiffuse = vLightFront;","#endif","reflectedLight.directDiffuse *= BRDF_Lambert( diffuseColor.rgb ) * getShadowMask();"),o&&d.push(o.code,"reflectedLight.directDiffuse += "+o.result+" * "+s.result+";"),d.push("vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;"),d.push(`
862
+ `,"#include <clipping_planes_fragment>"];d.push(r.code,"vec3 diffuseColor = "+r.result+";","ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );"),c&&d.push(c.code,"#ifdef ALPHATEST","if ( "+c.result+" <= ALPHATEST ) discard;","#endif"),d.push("#ifdef DOUBLE_SIDED"," reflectedLight.indirectDiffuse += ( isFrontFacing ) ? vIndirectFront : vIndirectBack;","#else"," reflectedLight.indirectDiffuse += vIndirectFront;","#endif","#include <lightmap_fragment>","reflectedLight.indirectDiffuse *= BRDF_Lambert( diffuseColor.rgb );","#ifdef DOUBLE_SIDED"," reflectedLight.directDiffuse = ( isFrontFacing ) ? vLightFront : vLightBack;","#else"," reflectedLight.directDiffuse = vLightFront;","#endif","reflectedLight.directDiffuse *= BRDF_Lambert( diffuseColor.rgb ) * getShadowMask();"),o&&d.push(o.code,"reflectedLight.directDiffuse += "+o.result+" * "+n.result+";"),d.push("vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;"),d.push(`
866
863
  if (outgoingLight != diffuseColor) {
867
864
  float lightAccu = clamp( length( reflectedLight.directSpecular + reflectedLight.indirectSpecular ), 0.0, 1.0 );
868
- accumAlpha += ( 1.0 - accumAlpha ) * ${n.result} * lightAccu;
869
- outgoingLight = spe_blend( diffuseColor, outgoingLight, ${n.result}, ${a.result} );
865
+ accumAlpha += ( 1.0 - accumAlpha ) * ${s.result} * lightAccu;
866
+ outgoingLight = spe_blend( diffuseColor, outgoingLight, ${s.result}, ${a.result} );
870
867
  }
871
868
  `),l&&d.push(l.code,`outgoingLight = spe_blend(outgoingLight, ${l.result}, 1.0, SPE_BLENDING_NORMAL);`),c?d.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${c.result} );`):d.push("gl_FragColor = vec4( outgoingLight, 1.0 );"),d.push("#include <encodings_fragment>","#include <fog_fragment>","#include <dithering_fragment>"),t=d.join(`
872
- `)}return t}copy(e){return super.copy(e),this.emissiveIntensity=e.emissiveIntensity.clone(),e.color&&(this.color=e.color.clone()),e.position&&(this.position=e.position.clone()),e.afterColor&&(this.afterColor=e.afterColor.clone()),e.alpha&&(this.alpha=e.alpha.clone()),e.shadingAlpha&&(this.shadingAlpha=e.shadingAlpha.clone()),e.shadingBlend&&(this.shadingBlend=e.shadingBlend.clone()),e.emissive&&(this.emissive=e.emissive.clone()),this}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),this.position&&(t.position=this.position.toJSON(e).uuid),this.color&&(t.color=this.color.toJSON(e).uuid),t.emissiveIntensity=this.emissiveIntensity.toJSON(e).uuid,t.shadingAlpha=this.shadingAlpha.toJSON(e).uuid,t.shadingBlend=this.shadingBlend.toJSON(e).uuid,this.afterColor&&(t.afterColor=this.afterColor.toJSON(e).uuid),this.alpha&&(t.alpha=this.alpha.toJSON(e).uuid),this.emissive&&(t.emissive=this.emissive.toJSON(e).uuid)),t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),e.position&&(this.position=t.getNode(e.position)),e.color&&(this.color=t.getNode(e.color)),e.shadingAlpha&&(this.shadingAlpha=t.getNode(e.shadingAlpha)),e.shadingBlend&&(this.shadingBlend=t.getNode(e.shadingBlend)),e.afterColor&&(this.afterColor=t.getNode(e.afterColor)),e.alpha&&(this.alpha=t.getNode(e.alpha)),e.emissiveIntensity&&(this.emissiveIntensity=t.getNode(e.emissiveIntensity)),this}};var pc=class extends or{get color(){return this.fragment.color}set color(e){this.fragment.color=e}get afterColor(){return this.fragment.afterColor}set afterColor(e){this.fragment.afterColor=e}get alpha(){return this.fragment.alpha}set alpha(e){this.fragment.alpha=e}get shadingAlpha(){return this.fragment.shadingAlpha}set shadingAlpha(e){this.fragment.shadingAlpha=e}get shadingBlend(){return this.fragment.shadingBlend}set shadingBlend(e){this.fragment.shadingBlend=e}get position(){return this.fragment.position}set position(e){this.fragment.position=e}get emissive(){return this.fragment.emissive}set emissive(e){this.fragment.emissive=e}get emissiveIntensity(){return this.fragment.emissiveIntensity}set emissiveIntensity(e){this.fragment.emissiveIntensity=e}constructor(e=new hc,t){super(e,e,t);this.type="LambertNodeMaterial",this.fragment=e}};var rs=class extends pc{constructor(e,t,r){super(t,e);this.userData.type="LambertMaterial",this.userData.category="Lambert",this.userData.layers=r!=null?r:this._getLayerStack(e==null?void 0:e.map)}get layersList(){return this.userData.layers}set layersList(e){this.userData.layers=e}equals(e){return this.userData.type===e.userData.type&&this.userData.layers.uuid==e.userData.layers.uuid}copy(e){if(e.userData.layers!==void 0&&e.userData.layers instanceof At){let t=e.userData.layers,r=e.fragment;super.copy(e);let o=r.clone();this.fragment=o,this.vertex=o;let s=t.clone(this);this.userData.layers=s,o.shadingAlpha.value=r.shadingAlpha.value,o.shadingBlend.value=r.shadingBlend.value}else super.copy(e);return this}static fromJSON(e,t,r){let o=r.getNode(t.vertex),s=new rs(void 0,o);return s.fromJSON(t,r),s}dispose(){super.dispose()}};import{UniformsLib as lf,UniformsUtils as hN}from"three";var uc=class extends ue{constructor(){super("toon");this.nodeType="Toon";this.color=new Be(nt),this.specular=new Be(1118481),this.shininess=new re(30),this.shadingAlpha=new re(1),this.shadingBlend=new Se(0)}build(e){let t;if(e.define("TOON"),e.requires.lights=!0,e.extensions.derivatives=!0,e.isShader("vertex")){let r=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform(hN.merge([lf.fog,lf.lights])),e.addParsCode(["varying vec3 vViewPosition;","#include <fog_pars_vertex>","#include <normal_pars_vertex>","#include <shadowmap_pars_vertex>","#include <clipping_planes_pars_vertex>"].join(`
869
+ `)}return t}copy(e){return super.copy(e),this.emissiveIntensity=e.emissiveIntensity.clone(),e.color&&(this.color=e.color.clone()),e.position&&(this.position=e.position.clone()),e.afterColor&&(this.afterColor=e.afterColor.clone()),e.alpha&&(this.alpha=e.alpha.clone()),e.shadingAlpha&&(this.shadingAlpha=e.shadingAlpha.clone()),e.shadingBlend&&(this.shadingBlend=e.shadingBlend.clone()),e.emissive&&(this.emissive=e.emissive.clone()),this}};var Zl=class extends rr{get color(){return this.fragment.color}set color(e){this.fragment.color=e}get afterColor(){return this.fragment.afterColor}set afterColor(e){this.fragment.afterColor=e}get alpha(){return this.fragment.alpha}set alpha(e){this.fragment.alpha=e}get shadingAlpha(){return this.fragment.shadingAlpha}set shadingAlpha(e){this.fragment.shadingAlpha=e}get shadingBlend(){return this.fragment.shadingBlend}set shadingBlend(e){this.fragment.shadingBlend=e}get position(){return this.fragment.position}set position(e){this.fragment.position=e}get emissive(){return this.fragment.emissive}set emissive(e){this.fragment.emissive=e}get emissiveIntensity(){return this.fragment.emissiveIntensity}set emissiveIntensity(e){this.fragment.emissiveIntensity=e}constructor(e=new Xl,t){super(e,e,t);this.type="LambertNodeMaterial",this.fragment=e}};var rn=class extends Zl{constructor(e,t,r){super(t,e);this.userData.type="LambertMaterial",this.userData.category="Lambert",this.userData.layers=r!=null?r:this._getLayerStack(e==null?void 0:e.map)}get layersList(){return this.userData.layers}set layersList(e){this.userData.layers=e}equals(e){return this.userData.type===e.userData.type&&this.userData.layers.uuid==e.userData.layers.uuid}copy(e){if(e.userData.layers!==void 0&&e.userData.layers instanceof Pt){let t=e.userData.layers,r=e.fragment;super.copy(e);let o=r.clone();this.fragment=o,this.vertex=o;let n=t.clone(this);this.userData.layers=n,o.shadingAlpha.value=r.shadingAlpha.value,o.shadingBlend.value=r.shadingBlend.value}else super.copy(e);return this}static fromJSON(e,t,r){let o=r.getNode(t.vertex),n=new rn(void 0,o);return n.fromJSON(t,r),n}dispose(){super.dispose()}};import{UniformsLib as Jh,UniformsUtils as KS}from"three";var Ql=class extends pe{constructor(){super("toon");this.nodeType="Toon";this.color=new Ge(nt),this.specular=new Ge(1118481),this.shininess=new ee(30),this.shadingAlpha=new ee(1),this.shadingBlend=new ve(0)}build(e){let t;if(e.define("TOON"),e.requires.lights=!0,e.extensions.derivatives=!0,e.isShader("vertex")){let r=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform(KS.merge([Jh.fog,Jh.lights])),e.addParsCode(["varying vec3 vViewPosition;","#include <fog_pars_vertex>","#include <normal_pars_vertex>","#include <shadowmap_pars_vertex>","#include <clipping_planes_pars_vertex>"].join(`
873
870
  `));let o=["#include <beginnormal_vertex>",`
874
871
  #ifndef USE_LAYER_DISPLACE
875
872
  #include <defaultnormal_vertex>
@@ -887,7 +884,7 @@ vec4 getIBLVolumeRefraction( vec3 n, vec3 v, float roughness, vec3 position, mat
887
884
  #include <begin_vertex>
888
885
  #endif
889
886
  `];r&&o.push(r.code,r.result?"displaced_position = "+r.result+";":""),o.push("transformed = displaced_position;","transformedNormal = normalMatrix * displaced_normal;"," vNormal = transformedNormal;"),o.push(" #include <project_vertex>"," #include <fog_vertex>"," #include <clipping_planes_vertex>"," vViewPosition = - mvPosition.xyz;"," #include <worldpos_vertex>"," #include <shadowmap_vertex>"," #include <fog_vertex>"),t=o.join(`
890
- `)}else{this.color===void 0&&(this.color=new Be(nt)),this.color.analyze(e,{slot:"color"}),this.specular.analyze(e),this.shininess.analyze(e),this.shadingAlpha.analyze(e),this.shadingBlend.analyze(e),this.afterColor&&this.afterColor.analyze(e,{slot:"afterColor"}),this.alpha&&this.alpha.analyze(e);let r=this.color.flow(e,"c",{slot:"color"}),o=this.specular.flow(e,"c"),s=this.shininess.flow(e,"f"),n=this.shadingAlpha.flow(e,"f"),a=this.shadingBlend.flow(e,"i"),l=this.afterColor?this.afterColor.flow(e,"c",{slot:"afterColor"}):void 0,c=this.alpha?this.alpha.flow(e,"f"):void 0;e.requires.transparent=c!==void 0,e.addParsCode(["#include <normal_pars_fragment>","#include <gradientmap_pars_fragment>","#include <fog_pars_fragment>","#include <bsdfs>","#include <lights_pars_begin>","#include <dithering_pars_fragment>",`
887
+ `)}else{this.color===void 0&&(this.color=new Ge(nt)),this.color.analyze(e,{slot:"color"}),this.specular.analyze(e),this.shininess.analyze(e),this.shadingAlpha.analyze(e),this.shadingBlend.analyze(e),this.afterColor&&this.afterColor.analyze(e,{slot:"afterColor"}),this.alpha&&this.alpha.analyze(e);let r=this.color.flow(e,"c",{slot:"color"}),o=this.specular.flow(e,"c"),n=this.shininess.flow(e,"f"),s=this.shadingAlpha.flow(e,"f"),a=this.shadingBlend.flow(e,"i"),l=this.afterColor?this.afterColor.flow(e,"c",{slot:"afterColor"}):void 0,c=this.alpha?this.alpha.flow(e,"f"):void 0;e.requires.transparent=c!==void 0,e.addParsCode(["#include <normal_pars_fragment>","#include <gradientmap_pars_fragment>","#include <fog_pars_fragment>","#include <bsdfs>","#include <lights_pars_begin>","#include <dithering_pars_fragment>",`
891
888
  varying vec3 vViewPosition;
892
889
  struct ToonMaterial {
893
890
  vec3 diffuseColor;
@@ -916,14 +913,14 @@ vec4 getIBLVolumeRefraction( vec3 n, vec3 v, float roughness, vec3 position, mat
916
913
  if (dot(normal, faceNormal) < 0.0) {
917
914
  normal *= -1.0;
918
915
  }
919
- `," ToonMaterial material;"];d.push(r.code," vec3 diffuseColor = "+r.result+";"," ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );",o.code," vec3 specular = "+o.result+";",s.code," float shininess = max( 0.0001, "+s.result+" );"," float specularStrength = 1.0;"),c&&d.push(c.code,"#ifdef ALPHATEST","if ( "+c.result+" <= ALPHATEST ) discard;","#endif"),d.push("material.diffuseColor = diffuseColor;"),d.push("material.specularColor = specular;","material.specularShininess = shininess;","material.specularStrength = specularStrength;","#include <lights_fragment_begin>","#include <lights_fragment_end>"),d.push("vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular;"),d.push(`
916
+ `," ToonMaterial material;"];d.push(r.code," vec3 diffuseColor = "+r.result+";"," ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );",o.code," vec3 specular = "+o.result+";",n.code," float shininess = max( 0.0001, "+n.result+" );"," float specularStrength = 1.0;"),c&&d.push(c.code,"#ifdef ALPHATEST","if ( "+c.result+" <= ALPHATEST ) discard;","#endif"),d.push("material.diffuseColor = diffuseColor;"),d.push("material.specularColor = specular;","material.specularShininess = shininess;","material.specularStrength = specularStrength;","#include <lights_fragment_begin>","#include <lights_fragment_end>"),d.push("vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular;"),d.push(`
920
917
  if (outgoingLight != diffuseColor) {
921
918
  float lightAccu = clamp( length( reflectedLight.directSpecular + reflectedLight.indirectSpecular ), 0.0, 1.0 );
922
- accumAlpha += ( 1.0 - accumAlpha ) * ${n.result} * lightAccu;
923
- outgoingLight = spe_blend( diffuseColor, outgoingLight, ${n.result}, ${a.result} );
919
+ accumAlpha += ( 1.0 - accumAlpha ) * ${s.result} * lightAccu;
920
+ outgoingLight = spe_blend( diffuseColor, outgoingLight, ${s.result}, ${a.result} );
924
921
  }
925
922
  `),l&&d.push(l.code,`outgoingLight = spe_blend(outgoingLight, ${l.result}, 1.0, SPE_BLENDING_NORMAL);`),c?d.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${c.result} );`):d.push("gl_FragColor = vec4( outgoingLight, 1.0 );"),d.push("#include <encodings_fragment>","#include <fog_fragment>","#include <dithering_fragment>"),t=d.join(`
926
- `)}return t}copy(e){return super.copy(e),e.color&&(this.color=e.color.clone()),this.specular=e.specular.clone(),this.shininess=e.shininess.clone(),e.position&&(this.position=e.position.clone()),e.afterColor&&(this.afterColor=e.afterColor.clone()),e.alpha&&(this.alpha=e.alpha.clone()),e.shadingAlpha&&(this.shadingAlpha=e.shadingAlpha.clone()),e.shadingBlend&&(this.shadingBlend=e.shadingBlend.clone()),this}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),this.position&&(t.position=this.position.toJSON(e).uuid),this.color&&(t.color=this.color.toJSON(e).uuid),t.specular=this.specular.toJSON(e).uuid,t.shininess=this.shininess.toJSON(e).uuid,this.alpha&&(t.alpha=this.alpha.toJSON(e).uuid),this.shadingAlpha&&(t.shadingAlpha=this.shadingAlpha.toJSON(e).uuid),this.shadingBlend&&(t.shadingBlend=this.shadingBlend.toJSON(e).uuid),this.afterColor&&(t.afterColor=this.afterColor.toJSON(e).uuid)),t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),e.position&&(this.position=t.getNode(e.position)),e.color&&(this.color=t.getNode(e.color)),e.specular&&(this.specular=t.getNode(e.specular)),e.shininess&&(this.shininess=t.getNode(e.shininess)),e.alpha&&(this.alpha=t.getNode(e.alpha)),e.shadingAlpha&&(this.shadingAlpha=t.getNode(e.shadingAlpha)),e.shadingBlend&&(this.shadingBlend=t.getNode(e.shadingBlend)),e.afterColor&&(this.afterColor=t.getNode(e.afterColor)),this}};var fc=class extends or{get color(){return this.fragment.color}set color(e){this.fragment.color=e}get afterColor(){return this.fragment.afterColor}set afterColor(e){this.fragment.afterColor=e}get alpha(){return this.fragment.alpha}set alpha(e){this.fragment.alpha=e}get shadingAlpha(){return this.fragment.shadingAlpha}set shadingAlpha(e){this.fragment.shadingAlpha=e}get shadingBlend(){return this.fragment.shadingBlend}set shadingBlend(e){this.fragment.shadingBlend=e}get position(){return this.fragment.position}set position(e){this.fragment.position=e}get specular(){return this.fragment.specular}set specular(e){this.fragment.specular=e}get shininess(){return this.fragment.shininess}set shininess(e){this.fragment.shininess=e}constructor(e=new uc,t){super(e,e,t);this.type="ToonNodeMaterial",this.fragment=e}};var os=class extends fc{constructor(e,t,r){super(t,e);this.userData.type="ToonMaterial",this.userData.category="Toon",this.userData.layers=r!=null?r:this._getLayerStack(e==null?void 0:e.map)}get layersList(){return this.userData.layers}set layersList(e){this.userData.layers=e}equals(e){return this.userData.type===e.userData.type&&this.userData.layers.uuid==e.userData.layers.uuid}copy(e){if(e.userData.layers!==void 0&&e.userData.layers instanceof At){let t=e.userData.layers,r=e.fragment;super.copy(e);let o=r.clone();this.fragment=o,this.vertex=o;let s=t.clone(this);this.userData.layers=s,o.shadingAlpha.value=r.shadingAlpha.value,o.shadingBlend.value=r.shadingBlend.value}else super.copy(e);return this}static fromJSON(e,t,r){let o=r.getNode(t.vertex),s=new os(void 0,o);return s.fromJSON(t,r),s}dispose(){super.dispose()}};import{UniformsLib as mc,UniformsUtils as pN}from"three";var gc=class extends ue{constructor(){super("standard");this.nodeType="Standard";this.color=new Be(nt),this.roughness=new re(.3),this.metalness=new re(0),this.reflectivity=new re(.5),this.shadingAlpha=new re(1),this.shadingBlend=new Se(0)}build(e){let t;if(e.define("STANDARD"),e.requires.lights=!0,e.extensions.derivatives=!0,e.extensions.shaderTextureLOD=!0,e.isShader("vertex")){let r=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform(pN.merge([mc.fog,mc.lights])),mc.LTC_1&&(e.uniforms.ltc_1={value:void 0},e.uniforms.ltc_2={value:void 0}),e.addParsCode(["varying vec3 vViewPosition;","#include <fog_pars_vertex>","#include <normal_pars_vertex>","#include <shadowmap_pars_vertex>","#include <clipping_planes_pars_vertex>"].join(`
923
+ `)}return t}copy(e){return super.copy(e),e.color&&(this.color=e.color.clone()),this.specular=e.specular.clone(),this.shininess=e.shininess.clone(),e.position&&(this.position=e.position.clone()),e.afterColor&&(this.afterColor=e.afterColor.clone()),e.alpha&&(this.alpha=e.alpha.clone()),e.shadingAlpha&&(this.shadingAlpha=e.shadingAlpha.clone()),e.shadingBlend&&(this.shadingBlend=e.shadingBlend.clone()),this}};var Yl=class extends rr{get color(){return this.fragment.color}set color(e){this.fragment.color=e}get afterColor(){return this.fragment.afterColor}set afterColor(e){this.fragment.afterColor=e}get alpha(){return this.fragment.alpha}set alpha(e){this.fragment.alpha=e}get shadingAlpha(){return this.fragment.shadingAlpha}set shadingAlpha(e){this.fragment.shadingAlpha=e}get shadingBlend(){return this.fragment.shadingBlend}set shadingBlend(e){this.fragment.shadingBlend=e}get position(){return this.fragment.position}set position(e){this.fragment.position=e}get specular(){return this.fragment.specular}set specular(e){this.fragment.specular=e}get shininess(){return this.fragment.shininess}set shininess(e){this.fragment.shininess=e}constructor(e=new Ql,t){super(e,e,t);this.type="ToonNodeMaterial",this.fragment=e}};var on=class extends Yl{constructor(e,t,r){super(t,e);this.userData.type="ToonMaterial",this.userData.category="Toon",this.userData.layers=r!=null?r:this._getLayerStack(e==null?void 0:e.map)}get layersList(){return this.userData.layers}set layersList(e){this.userData.layers=e}equals(e){return this.userData.type===e.userData.type&&this.userData.layers.uuid==e.userData.layers.uuid}copy(e){if(e.userData.layers!==void 0&&e.userData.layers instanceof Pt){let t=e.userData.layers,r=e.fragment;super.copy(e);let o=r.clone();this.fragment=o,this.vertex=o;let n=t.clone(this);this.userData.layers=n,o.shadingAlpha.value=r.shadingAlpha.value,o.shadingBlend.value=r.shadingBlend.value}else super.copy(e);return this}static fromJSON(e,t,r){let o=r.getNode(t.vertex),n=new on(void 0,o);return n.fromJSON(t,r),n}dispose(){super.dispose()}};import{UniformsLib as ec,UniformsUtils as XS}from"three";var tc=class extends pe{constructor(){super("standard");this.nodeType="Standard";this.color=new Ge(nt),this.roughness=new ee(.3),this.metalness=new ee(0),this.reflectivity=new ee(.5),this.shadingAlpha=new ee(1),this.shadingBlend=new ve(0)}build(e){let t;if(e.define("STANDARD"),e.requires.lights=!0,e.extensions.derivatives=!0,e.extensions.shaderTextureLOD=!0,e.isShader("vertex")){let r=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform(XS.merge([ec.fog,ec.lights])),ec.LTC_1&&(e.uniforms.ltc_1={value:void 0},e.uniforms.ltc_2={value:void 0}),e.addParsCode(["varying vec3 vViewPosition;","#include <fog_pars_vertex>","#include <normal_pars_vertex>","#include <shadowmap_pars_vertex>","#include <clipping_planes_pars_vertex>"].join(`
927
924
  `));let o=["#include <beginnormal_vertex>",`
928
925
  #if !defined( USE_LAYER_DISPLACE )
929
926
  #include <defaultnormal_vertex>
@@ -941,8 +938,8 @@ vec4 getIBLVolumeRefraction( vec3 n, vec3 v, float roughness, vec3 position, mat
941
938
  #include <begin_vertex>
942
939
  #endif /* !USE_LAYER_DISPLACE */
943
940
  `];r&&o.push(r.code,r.result?"displaced_position = "+r.result+";":""),o.push("transformed = displaced_position;","transformedNormal = normalMatrix * displaced_normal;","#ifndef FLAT_SHADED"," vNormal = transformedNormal;","#endif"),o.push("#include <project_vertex>","#include <fog_vertex>","#include <clipping_planes_vertex>"," vViewPosition = - mvPosition.xyz;","#include <worldpos_vertex>","#include <shadowmap_vertex>"),t=o.join(`
944
- `)}else{let r={gamma:!0};this.color===void 0&&(this.color=new Be(nt)),this.color.analyze(e,{slot:"color",context:r}),this.roughness.analyze(e),this.metalness.analyze(e),this.shadingAlpha.analyze(e),this.shadingBlend.analyze(e),this.afterColor&&this.afterColor.analyze(e,{slot:"afterColor"}),this.alpha&&this.alpha.analyze(e),this.reflectivity&&this.reflectivity.analyze(e);let o=this.color.flow(e,"c",{slot:"color",context:r}),s=this.roughness.flow(e,"f"),n=this.metalness.flow(e,"f"),a=this.shadingAlpha.flow(e,"f"),l=this.shadingBlend.flow(e,"i"),c=this.afterColor?this.afterColor.flow(e,"c",{slot:"afterColor"}):void 0,d=this.alpha?this.alpha.flow(e,"f"):void 0,h=this.reflectivity?this.reflectivity.flow(e,"f"):void 0;e.requires.transparent=d!==void 0,e.addParsCode(["varying vec3 vViewPosition;","#include <normal_pars_fragment>","#include <dithering_pars_fragment>","#include <fog_pars_fragment>","#include <bsdfs>","#include <lights_pars_begin>","#include <lights_physical_pars_fragment>","#include <shadowmap_pars_fragment>"].join(`
945
- `));let p=["#include <clipping_planes_fragment>"," #include <normal_fragment_begin>",`
941
+ `)}else{let r={gamma:!0};this.color===void 0&&(this.color=new Ge(nt)),this.color.analyze(e,{slot:"color",context:r}),this.roughness.analyze(e),this.metalness.analyze(e),this.shadingAlpha.analyze(e),this.shadingBlend.analyze(e),this.afterColor&&this.afterColor.analyze(e,{slot:"afterColor"}),this.alpha&&this.alpha.analyze(e),this.reflectivity&&this.reflectivity.analyze(e);let o=this.color.flow(e,"c",{slot:"color",context:r}),n=this.roughness.flow(e,"f"),s=this.metalness.flow(e,"f"),a=this.shadingAlpha.flow(e,"f"),l=this.shadingBlend.flow(e,"i"),c=this.afterColor?this.afterColor.flow(e,"c",{slot:"afterColor"}):void 0,d=this.alpha?this.alpha.flow(e,"f"):void 0,p=this.reflectivity?this.reflectivity.flow(e,"f"):void 0;e.requires.transparent=d!==void 0,e.addParsCode(["varying vec3 vViewPosition;","#include <normal_pars_fragment>","#include <dithering_pars_fragment>","#include <fog_pars_fragment>","#include <bsdfs>","#include <lights_pars_begin>","#include <lights_physical_pars_fragment>","#include <shadowmap_pars_fragment>"].join(`
942
+ `));let u=["#include <clipping_planes_fragment>"," #include <normal_fragment_begin>",`
946
943
  // NOTE: gl_FrontFacing alternative using face normal estimation.
947
944
  vec3 viewdx = dFdx(vViewPosition);
948
945
  vec3 viewdy = dFdy(vViewPosition);
@@ -950,12 +947,12 @@ vec4 getIBLVolumeRefraction( vec3 n, vec3 v, float roughness, vec3 position, mat
950
947
  if (dot(normal, faceNormal) < 0.0) {
951
948
  normal *= -1.0;
952
949
  }
953
- `," PhysicalMaterial material;"," material.diffuseColor = vec3( 1.0 );"];p.push(o.code," vec3 diffuseColor = "+o.result+";"," ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );",s.code," float roughnessFactor = "+s.result+";",n.code," float metalnessFactor = "+n.result+";"),d&&p.push(d.code,"#ifdef ALPHATEST"," if ( "+d.result+" <= ALPHATEST ) discard;","#endif"),p.push("vec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );","float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );"),p.push("material.diffuseColor = diffuseColor * ( 1.0 - metalnessFactor );","material.roughness = max( roughnessFactor, 0.0525 );","material.roughness += geometryRoughness;","material.roughness = min( material.roughness, 1.0 );","material.roughness = clamp( roughnessFactor, 0.04, 1.0 );"),h?p.push(h.code,"material.specularColor = mix( vec3( 0.16 * pow2( "+h.result+" ) ), diffuseColor, metalnessFactor );"):p.push("material.specularColor = mix( vec3( 0.04 ), diffuseColor, metalnessFactor );"),p.push("#include <lights_fragment_begin>"),p.push("#include <lights_fragment_end>"),p.push("vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular;"),p.push(`
950
+ `," PhysicalMaterial material;"," material.diffuseColor = vec3( 1.0 );"];u.push(o.code," vec3 diffuseColor = "+o.result+";"," ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );",n.code," float roughnessFactor = "+n.result+";",s.code," float metalnessFactor = "+s.result+";"),d&&u.push(d.code,"#ifdef ALPHATEST"," if ( "+d.result+" <= ALPHATEST ) discard;","#endif"),u.push("vec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );","float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );"),u.push("material.diffuseColor = diffuseColor * ( 1.0 - metalnessFactor );","material.roughness = max( roughnessFactor, 0.0525 );","material.roughness += geometryRoughness;","material.roughness = min( material.roughness, 1.0 );","material.roughness = clamp( roughnessFactor, 0.04, 1.0 );"),p?u.push(p.code,"material.specularColor = mix( vec3( 0.16 * pow2( "+p.result+" ) ), diffuseColor, metalnessFactor );"):u.push("material.specularColor = mix( vec3( 0.04 ), diffuseColor, metalnessFactor );"),u.push("#include <lights_fragment_begin>"),u.push("#include <lights_fragment_end>"),u.push("vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular;"),u.push(`
954
951
  if (outgoingLight != diffuseColor) {
955
952
  float lightAccu = clamp( length( reflectedLight.directSpecular + reflectedLight.indirectSpecular ), 0.0, 1.0 );
956
953
  accumAlpha += ( 1.0 - accumAlpha ) * ${a.result} * lightAccu;
957
954
  outgoingLight = spe_blend( diffuseColor, outgoingLight, ${a.result}, ${l.result} );
958
955
  }
959
- `),c&&p.push(c.code,`outgoingLight = spe_blend(outgoingLight, ${c.result}, 1.0, SPE_BLENDING_NORMAL);`),d?p.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${d.result} );`):p.push("gl_FragColor = vec4( outgoingLight, 1.0 );"),p.push("#include <encodings_fragment>","#include <fog_fragment>","#include <dithering_fragment>"),t=p.join(`
960
- `)}return t}copy(e){return super.copy(e),e.color&&(this.color=e.color.clone()),this.roughness=e.roughness.clone(),this.metalness=e.metalness.clone(),e.position&&(this.position=e.position.clone()),e.afterColor&&(this.afterColor=e.afterColor.clone()),e.alpha&&(this.alpha=e.alpha.clone()),e.reflectivity&&(this.reflectivity=e.reflectivity.clone()),e.shadingAlpha&&(this.shadingAlpha=e.shadingAlpha.clone()),e.shadingBlend&&(this.shadingBlend=e.shadingBlend.clone()),this}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),this.position&&(t.position=this.position.toJSON(e).uuid),this.color&&(t.color=this.color.toJSON(e).uuid),t.roughness=this.roughness.toJSON(e).uuid,t.metalness=this.metalness.toJSON(e).uuid,this.alpha&&(t.alpha=this.alpha.toJSON(e).uuid),this.reflectivity&&(t.reflectivity=this.reflectivity.toJSON(e).uuid),this.shadingAlpha&&(t.shadingAlpha=this.shadingAlpha.toJSON(e).uuid),this.shadingBlend&&(t.shadingBlend=this.shadingBlend.toJSON(e).uuid),this.afterColor&&(t.afterColor=this.afterColor.toJSON(e).uuid)),t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),e.position&&(this.position=t.getNode(e.position)),e.color&&(this.color=t.getNode(e.color)),e.roughness&&(this.roughness=t.getNode(e.roughness)),e.metalness&&(this.metalness=t.getNode(e.metalness)),e.alpha&&(this.alpha=t.getNode(e.alpha)),e.reflectivity&&(this.reflectivity=t.getNode(e.reflectivity)),e.shadingAlpha&&(this.shadingAlpha=t.getNode(e.shadingAlpha)),e.shadingBlend&&(this.shadingBlend=t.getNode(e.shadingBlend)),e.afterColor&&(this.afterColor=t.getNode(e.afterColor)),this}};var yc=class extends or{get color(){return this.fragment.color}set color(e){this.fragment.color=e}get afterColor(){return this.fragment.afterColor}set afterColor(e){this.fragment.afterColor=e}get alpha(){return this.fragment.alpha}set alpha(e){this.fragment.alpha=e}get shadingAlpha(){return this.fragment.shadingAlpha}set shadingAlpha(e){this.fragment.shadingAlpha=e}get shadingBlend(){return this.fragment.shadingBlend}set shadingBlend(e){this.fragment.shadingBlend=e}get position(){return this.fragment.position}set position(e){this.fragment.position=e}get roughness(){return this.fragment.roughness}set roughness(e){this.fragment.roughness=e}get metalness(){return this.fragment.metalness}set metalness(e){this.fragment.metalness=e}get reflectivity(){return this.fragment.reflectivity}set reflectivity(e){this.fragment.reflectivity=e}constructor(e=new gc,t){super(e,e,t);this.type="StandardNodeMaterial",this.fragment=e}};var is=class extends yc{constructor(e,t,r){super(t,e);this.userData.type="PhysicalMaterial",this.userData.category="Physical",this.userData.layers=r!=null?r:this._getLayerStack(e==null?void 0:e.map)}get layersList(){return this.userData.layers}set layersList(e){this.userData.layers=e}equals(e){return this.userData.type===e.userData.type&&this.userData.layers.uuid==e.userData.layers.uuid}copy(e){if(e.userData.layers!==void 0&&e.userData.layers instanceof At){let t=e.userData.layers,r=e.fragment;super.copy(e);let o=r.clone();this.fragment=o,this.vertex=o;let s=t.clone(this);this.userData.layers=s,o.shadingAlpha.value=r.shadingAlpha.value,o.shadingBlend.value=r.shadingBlend.value}else super.copy(e);return this}static fromJSON(e,t,r){let o=r.getNode(t.vertex),s=new is(void 0,o);return s.fromJSON(t,r),s}dispose(){super.dispose()}};import{Color as bc}from"three";import{Matrix3 as cf,Texture as xc,Vector2 as ss,Vector3 as Io,Vector4 as df}from"three";function hf(i,e){switch(i.data.type){case"light":return hr(i);case"fresnel":return fN(i,e);case"gradient":return mN(i);case"depth":return gN(i);case"normal":return yN(i);case"noise":return xN(i,e);case"texture":return bN(i,e);case"rainbow":return vN(i);case"transmission":return SN(i,e);case"matcap":return NN(i,e);case"displace":return wN(i);case"color":default:return uN(i,e)}}function pf(i){return{type:i.data.type}}function hr(i){let{alpha:e,mode:t}=i.data;return q(P({},pf(i)),{alpha:e,mode:t})}function uN(i,e){return q(P({},hr(i)),{color:et(i.data.color,e)})}function fN(i,e){let{bias:t,scale:r,intensity:o,factor:s,color:n}=i.data;return q(P({},hr(i)),{color:et(n,e),bias:t,scale:r,intensity:o,factor:s})}function mN(i){let{gradientType:e,smooth:t,colors:r,steps:o,angle:s,offset:n,morph:a}=i.data;return q(P({},hr(i)),{gradientType:e,smooth:t,colors:r.map(l=>new df(l[0],l[1],l[2],l[3])),num:r.length,steps:o,offset:new ss(...n),morph:new ss(...a),angle:s})}function gN(i){let{gradientType:e,near:t,far:r,isVector:o,isWorldSpace:s,origin:n,direction:a,colors:l,steps:c,smooth:d,num:h}=i.data;return q(P({},hr(i)),{gradientType:e,near:t,far:r,isVector:o,isWorldSpace:s,origin:new Io(...n),direction:a?new Io(...a):new Io(1,0,0),num:h,colors:l.map(p=>new df(p[0],p[1],p[2],p[3])),steps:c,smooth:d})}function yN(i){let{cnormal:e}=i.data;return q(P({},hr(i)),{cnormal:new Io(e[0],e[1],e[2])})}function xN(i,e){let{data:t}=i;return q(P({},hr(i)),{scale:t.scale,move:t.move,fA:new ss(...t.fA),fB:new ss(...t.fB),distortion:new ss(...t.distortion),colorA:et(t.colorA,e),colorB:et(t.colorB,e),colorC:et(t.colorC,e),colorD:et(t.colorD,e),noiseType:t.noiseType})}function bN(i,e){let{projection:t,axis:r,crop:o,size:s}=i.data,{image:n,wrapping:a,repeat:l,offset:c}=i.data.texture,d=new xc,h;if(typeof n=="string")h=e==null?void 0:e.getImage(n);else{let p=new Image;p.src=n.data,p.onload=()=>{(e==null?void 0:e.onImageLoad)&&(e==null||e.onImageLoad(n.data))},h=p}return d.image=h,d.wrapS=d.wrapT=a,q(P({},hr(i)),{texture:d,mat:new cf().setUvTransform(c[0],c[1],l[0],l[1],0,0,0),crop:o,projection:t,axis:["x","y","z"].indexOf(r),size:s})}function vN(i){let{data:e}=i;return q(P({},hr(i)),{filmThickness:e.filmThickness,movement:e.movement,wavelengths:new Io(...e.wavelengths),noiseStrength:e.noiseStrength,noiseScale:e.noiseScale,offset:new Io(...e.offset)})}function SN(i,e){let{data:t}=i;return q(P({},hr(i)),{thickness:t.thickness,ior:t.ior,roughness:t.roughness,transmissionSamplerMap:e.transmissionSamplerMap,transmissionDepthMap:e.transmissionDepthMap})}function NN(i,e){let t=new xc,{image:r}=i.data.texture,o;if(typeof r=="string")o=e==null?void 0:e.getImage(r);else{let n=new Image;n.src=r.data,n.onload=()=>{(e==null?void 0:e.onImageLoad)&&(e==null||e.onImageLoad(r.data))},o=n}t.image=o;let s=16777215;return q(P({},hr(i)),{color:s,texture:t})}function wN(i){let{data:e}=i,t=q(P({},pf(i)),{intensity:e.intensity});if(e.displacementType==="noise")return q(P({},t),{offset:new Io(...e.offset),scale:e.scale,movement:e.movement,noiseType:e.noiseType});{let r=new xc,o=new cf().setUvTransform(0,0,1,1,0,0,0);return q(P({},t),{texture:r,mat:o,crop:e.crop})}}function uf(i,e,t){if(t.type==="displace"&&(i==="intensity"||i==="visible")){let r=e.uniforms[`f${e.id}_intensity`];return r?(r.value=t.intensity*(t.visible?1:0),r):void 0}if(t.type!=="displace"&&(i==="alpha"||i==="visible")){let r=e.uniforms[`f${e.id}_alpha`];return r?(r.value=t.alpha*(t.visible?1:0),r):void 0}}import{Color as ff,Vector4 as CN}from"three";var Ni;(function(e){function i(t){return new ff(t.x,t.y,t.z).getHex()}e.getHex=i})(Ni||(Ni={}));var mf;(function(e){function i(t){return new CN(t.r,t.g,t.b,t.a)}e.getThreeVector4=i})(mf||(mf={}));var gf;(function(t){function i(r,o){r.setRGB(o.r,o.g,o.b)}t.setThreeColor=i;function e(r){return new ff(r.r,r.g,r.b).getHex()}t.getHex=e})(gf||(gf={}));function ns(i,e){return typeof i=="string"?e.getMaterialOrDeletedPlaceholder(i):vc(i,e)}function yf(i,e){return i.map(t=>ns(t,e))}function vc(i,e){var n;let t=(n=i.layers)!=null?n:ai.defaultTwoLayerData("phong").layers,r=LN(t),o;switch(r.category){case"basic":o=new Ct;break;case"lambert":{o=new rs;break}case"toon":{o=new os;break}case"physical":o=new is;break;case"phong":default:{o=new ir;break}}let s=o.userData.layers;ON(s);for(let a=t.length-1;a>=0;a--)TN(s,t[a],e);switch(r.category){case"basic":break;case"lambert":{let c=o,h=et(r.emissive,e);h instanceof bc?c.emissive.value=h:c.emissive.value.setHex(Ni.getHex(h));break}case"toon":{let c=o,d=r;c.shininess.value=d.shininess;let h=et(d.specular,e);h instanceof bc?c.specular.value=h:c.specular.value.setHex(Ni.getHex(h));break}case"physical":let a=o,l=r;a.metalness.value=l.metalness,a.roughness.value=l.roughness,a.reflectivity.value=l.reflectivity;break;case"phong":default:{let c=o,d=r;c.shininess.value=d.shininess;let h=et(d.specular,e);h instanceof bc?c.specular.value=h:c.specular.value.setHex(Ni.getHex(h));break}}return s.blendColors(),s.blendAfterColors(),s.blendPositions(),o}function LN(i){for(let e of i)if(e.data.type==="light")return e.data;return{type:"light",category:"basic",visible:!0,alpha:1,mode:st.Normal}}function ON(i){for(let e of i.getLayers())i.removeLayer(e.id)}function TN(i,e,t){let r=hf(e,t);r.type==="transmission"&&(r.transmissionSamplerMap=t==null?void 0:t.transmissionSamplerMap,r.transmissionDepthMap=t==null?void 0:t.transmissionDepthMap);let o=i.addLayer(r);o.uuid=e.id;for(let s in e.data)uf(s,o,e.data)}import{Vector2 as xf}from"three";var Ta=new xf,Po=class{constructor(e,t,r){this.message=[];this.endLine=!0;this.yLinePos=e,this.lineHeight=t,this.maxCharSize=r,this.nextChar3DPos=new xf(0,this.yLinePos+this.maxCharSize*this.lineHeight),this.align=Mt.Left}addChar3D(e,t,r=this.message.length){this.message.splice(r,0,e),e.fontSize>this.maxCharSize?(this.maxCharSize=e.fontSize,this.nextChar3DPos.y=this.yLinePos+this.maxCharSize*this.lineHeight,this.fullUpdate(t)):(e.updatePosition(this.nextChar3DPos,t),this.nextChar3DPos.x+=e.charSize)}deleteChar3D(e=this.message.length-1){let t=this.message[e];if(t)return this.message.splice(e,1),this.nextChar3DPos.x-=t.charSize,t}isEndLine(e){this.endLine=e}fullUpdate(e,t=0){this.nextChar3DPos.x=0;for(let r=t,o=this.message.length;r<o;r+=1)this.message[r].updatePosition(this.nextChar3DPos,e),this.nextChar3DPos.x+=this.message[r].charSize}checkOverFlow(e){let t,r=this.message.length-1;if(r<=0)return!1;for(;r>=0;){if(this.message[r].char!==" "){t=this.message[r];break}r-=1}return!!(r>=0&&t&&t.localPosition.x+t.charSize>e)}containSpaceOverFlow(e=this.message.length-1){for(let t=e;t>=0;t-=1)if(this.message[t].char===" ")return!0;return!1}containSpace(e=this.message.length-1){if(this.endLine)return!0;for(let t=e;t>=0;t-=1)if(this.message[t].char===" ")return!0;return!1}popWord(e=this.message.length-1){let t=[],r=!0,o;for(o=e;o>=0;o-=1)if(this.message[o].char===" "){r=!1,t.length===0&&(o-=1,t.splice(0,0,this.message[o]));break}else t.splice(0,0,this.message[o]);return r?t=[]:this.message.splice(o+1,t.length),t}getWord(e=0,t=1){let r=[],o=e;for(o=e;;o+=t){if(!this.message[o]||this.message[o].char===" "){r.length===0&&this.message[o]&&(r.push(this.message[o]),this.message.splice(o,1));break}t>0?(r.push(this.message[o]),this.message.splice(o,1),o-=t):(r.splice(0,0,this.message[o]),this.message.splice(o,1))}return r}getWordAtIndex(e){let t=[];for(let r=e;r<this.message.length&&this.message[r].char!==" ";r++)t.push(this.message[r]);for(let r=e-1;r>=0&&this.message[r].char!==" ";r--)t.splice(0,0,this.message[r]);return t}wordSize(e=0,t=-1){let r=0,o=e;for(;o>=0&&o<this.message.length;){if(this.message[o].char===" "){r===0&&(r=this.message[o].charSize);break}r+=this.message[o].charSize,o+=t}return(o<0||o>=this.message.length)&&!this.endLine?this.message[e]?this.message[e].charSize:999999999:r===0?999999999:r}spaceLeft(e){return e-this.nextChar3DPos.x}popChar(e=this.message.length-1){return this.nextChar3DPos.x-=this.message[e].charSize,this.message.splice(e,1)}isEmpty(){return!this.message.length}updateNextCharPosY(){this.nextChar3DPos.y=this.yLinePos+this.maxCharSize*this.lineHeight}updateYLinePos(e){this.yLinePos=e,this.updateNextCharPosY()}updatelineHeight(e){this.lineHeight=e,this.updateNextCharPosY()}updateFontSize(e,t=0,r=this.message.length-1){for(let o=t;o<=r;o+=1)this.message[o].updateFontSize(e);this.maxCharSize=e,this.nextChar3DPos.y=this.yLinePos+this.maxCharSize*this.lineHeight}countSpaces(){let e=0;for(let t=0;t<this.message.length;t++)this.message[t].char===" "&&(e+=1);return e}alignText(e,t,r,o,s){switch(r){case Mt.Left:this.leftAlign(e,s);break;case Mt.Center:this.centerAlign(this.spaceLeft(t),e,s);break;case Mt.Right:this.rightAlign(this.spaceLeft(t),e,s);break;case Mt.Justify:this.justifyAlign(this.spaceLeft(t),e,s);break}}offsetCharacters(e,t,r){Ta.set(t,r);let o=this.message.length;for(let s=0;s<o;s++)this.message[s].updatePosition(this.message[s].localPosition.add(Ta),e)}leftAlign(e,t){this.align=Mt.Left,this.offsetCharacters(e,0,t)}centerAlign(e,t,r){this.align=Mt.Center,this.offsetCharacters(t,e/2,r)}rightAlign(e,t,r){this.align=Mt.Right,this.offsetCharacters(t,e,r)}justifyAlign(e,t,r){if(this.align=Mt.Justify,this.endLine){this.offsetCharacters(t,0,r);return}let o=this.countSpaces();if(o===0){this.offsetCharacters(t,0,r);return}let s=e/o,n=0;for(let a=0;a<this.message.length;a++)this.message[a].char===" "&&(n+=s),Ta.set(n,r),this.message[a].updatePosition(this.message[a].localPosition.add(Ta),t)}clone(){let e=new Po(this.yLinePos,this.lineHeight,this.maxCharSize);e.nextChar3DPos=this.nextChar3DPos.clone(),e.align=this.align,e.endLine=this.endLine;for(let t=0;t<this.message.length;t++)e.message.push(this.message[t].clone());return e}};import{DoubleSide as MN,EventDispatcher as IN,Matrix3 as PN,Vector3 as Sc}from"three";var AN=new Sc(0,0,1),bf=new Sc,vf=new Sc,Sf=new PN,Ao=class extends yt{constructor(e=mt.create({}),t=new Ct({side:MN})){super(e,t);this.recursiveSelection=!1;this.objectType="VectorObject";this.eventDispatcher=new IN;this._onShapeUpdate=()=>{if(this.geometry instanceof qi){if(this.geometry.updateFromShape()){let e=this.geometry.drawCount,t=this.geometry.userData;this.updateGeometry(Object.assign(this.geometry.userData,{parameters:Object.assign(t.parameters,{surfaceMaxCount:e+1e3})}))}}else this.updateGeometry({});this.geometry.computeBoundingSphere(),this.geometry.computeBoundingBox()};var r;this.castShadow=!0,this.receiveShadow=!0,this.forceComputeSize=!0,this.shape=e.userData.shape,(r=this.shape.eventDispatcher)==null||r.addEventListener("update",this._onShapeUpdate)}toJSON(e){let t=super.toJSON(e);return t.object.objectType="VectorObject",t}fromState(e){return super.fromState(e),this.shape.update(),this}setHelperVisibility(){}updateGeometry(e){if(super.updateGeometry(e),"userData"in this.geometry){let t=this.geometry.userData.parameters;this.eventDispatcher.dispatchEvent({type:"geometryUpdate",parameters:t})}}setShape(e){var t,r;this.shape&&((t=this.shape.eventDispatcher)==null||t.removeEventListener("update",this._onShapeUpdate)),this.shape=e,(r=this.shape.eventDispatcher)==null||r.addEventListener("update",this._onShapeUpdate)}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),Sf.getNormalMatrix(this.matrixWorld),bf.copy(AN).applyMatrix3(Sf).normalize(),vf.setFromMatrixPosition(this.matrixWorld),this.shape.plane.setFromNormalAndCoplanarPoint(bf,vf)}clone(e){let t=this.shape.clone(),r=this.material.clone(),o=this.geometry.userData,s=mt.create(Object.assign({},o,{shape:t})),n=new Ao(s,r).copy(this,e);return n.shape=t,t.update(),n}raycast(e,t){yt.prototype.raycast.call(this,e,t)}};import{Camera as qN,OrthographicCamera as WN,PerspectiveCamera as $N,Vector3 as qt,Object3D as Lf,Quaternion as KN}from"three";import{BoxBufferGeometry as jN}from"three";var Cr=i=>{var e;return e=class extends i{constructor(){super(...arguments);this.isObjectHelper=!0}},e.geometryHelper=new jN(30,30,30),e};import{Camera as GN,LineSegments as EN,BufferGeometry as zN,LineBasicMaterial as FN,Color as wc,Vector3 as RN,Float32BufferAttribute as wf}from"three";import{Ray as _N,Sphere as DN,Matrix4 as BN,Vector3 as Jr}from"three";var Ma=new _N,Nc=new DN,Nf=new BN,Lr=(i,e,t,r,o=!1)=>{let s=e,n=i.matrixWorld;if(s.boundingSphere===null&&s.computeBoundingSphere(),Nc.copy(s.boundingSphere),Nc.applyMatrix4(n),t.ray.intersectsSphere(Nc)===!1||(Nf.copy(n).invert(),Ma.copy(t.ray).applyMatrix4(Nf),s.boundingBox!==null&&Ma.intersectsBox(s.boundingBox)===!1))return;let a,l,c,d,h=s.index,p=s.attributes.position,m=s.drawRange,f,x;if(o===!1){let N=Math.max(0,m.start),C=Math.min(h.count,m.start+m.count);for(f=N,x=C;f<x;f+=3)if(l=h.getX(f),c=h.getX(f+1),d=h.getX(f+2),a=g(i,t,Ma,p,l,c,d),a){a.faceIndex=Math.floor(f/3),r.push(a);return}}else{let C=s.attributes.position,S=new Jr,D=new Jr,v=new Jr,j=new Jr,O=2,A=1/((i.scale.x+i.scale.y+i.scale.z)/3),b=A*A,L=Math.max(0,m.start),I=Math.min(C.count,m.start+m.count);for(let T=L,$=I-1;T<$;T+=O){if(S.fromBufferAttribute(C,T),D.fromBufferAttribute(C,T+1),Ma.distanceSqToSegment(S,D,j,v)>b)continue;j.applyMatrix4(i.matrixWorld);let te=t.ray.origin.distanceTo(j);te<t.near||te>t.far||r.push({distance:te,point:v.clone().applyMatrix4(i.matrixWorld),object:i})}}function g(N,C,S,D,v,j,O){let u=new Jr,A=new Jr,b=new Jr,L=new Jr,I=new Jr;if(u.fromBufferAttribute(D,v),A.fromBufferAttribute(D,j),b.fromBufferAttribute(D,O),S.intersectTriangle(u,A,b,!1,L)===null)return null;I.copy(L),I.applyMatrix4(N.matrixWorld);let $=C.ray.origin.distanceTo(I);return $<C.near||$>C.far?null:{faceIndex:1,distance:$,point:I.clone(),object:N}}};var Ia=new RN,sr=new GN,Cf=class extends EN{constructor(e){let t=new zN,r=new FN({color:16777215,vertexColors:!0,toneMapped:!1}),o=[],s=[],n={},a=new wc(pl),l=new wc(pl),c=new wc(Gp);d("n1","n2",a),d("n2","n4",a),d("n4","n3",a),d("n3","n1",a),d("f1","f2",a),d("f2","f4",a),d("f4","f3",a),d("f3","f1",a),d("n1","f1",a),d("n2","f2",a),d("n3","f3",a),d("n4","f4",a),d("p","n1",l),d("p","n2",l),d("p","n3",l),d("p","n4",l),d("u1","u2",c),d("u2","u3",c),d("u3","u1",c);function d(p,m,f){h(p,f),h(m,f)}function h(p,m){o.push(0,0,0),s.push(m.r,m.g,m.b),n[p]===void 0&&(n[p]=[]),n[p].push(o.length/3-1)}t.setAttribute("position",new wf(o,3)),t.setAttribute("color",new wf(s,3));super(t,r);this.type="CameraHelper",this.camera=e,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=n,this.update()}update(){let e=this.geometry,t=this.pointMap,r=!0;sr.projectionMatrixInverse.elements=[.5112609807824982,-0,-0,-0,-0,.41421356237309503,-0,-0,-0,-0,-0,-.099999,-0,-0,-1.0000000000000002,.100001];let o=1,s=1,n=r?.8:1e-4;pr("n1",t,e,sr,-o,-s,n),pr("n2",t,e,sr,o,-s,n),pr("n3",t,e,sr,-o,s,n),pr("n4",t,e,sr,o,s,n);let a=n;pr("f1",t,e,sr,-o,-s,a),pr("f2",t,e,sr,o,-s,a),pr("f3",t,e,sr,-o,s,a),pr("f4",t,e,sr,o,s,a);let l=a,c=.5;pr("u1",t,e,sr,o*.7*c,s*1.1,l),pr("u2",t,e,sr,-o*.7*c,s*1.1,l),pr("u3",t,e,sr,0,s*(1.1+.9*c),l),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};function pr(i,e,t,r,o,s,n){Ia.set(o,s,n).unproject(r);let a=e[i];if(a!==void 0){let l=t.getAttribute("position");for(let c=0,d=a.length;c<d;c++)l.setXYZ(a[c],Ia.x,Ia.y,Ia.z)}}var Cc=class extends Cr(Cf){constructor(e){super(e);this.object=e;this.object=e,this.name=`CombinedCameraHelper: ${e.uuid}`}updateMatrixWorld(e){super.updateMatrixWorld(e),this.updateTarget()}updateTarget(){let e=this.object.getTarget();this.updateWorldMatrix(!0,!1),this.worldToLocal(e)}raycast(e,t){Lr(this.object,this.geometry,e,t,!0)}};import{DirectionalLightHelper as VN}from"three";var as=class extends Cr(VN){constructor(e,t=15,r=10066329){super(e,t,r);this.object=e;this.name=`DirectionalLightHelper: ${e.uuid}`}raycast(e,t){Lr(this.object,as.geometryHelper,e,t)}};import{AxesHelper as kN}from"three";var ls=class extends Cr(kN){constructor(e,t=15){super(t);this.object=e;this.object.updateMatrixWorld(),this.name=`EmptyObjectHelper: ${e.uuid}`,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1}raycast(e,t){Lr(this.object,ls.geometryHelper,e,t)}update(){}};import{PointLightHelper as UN}from"three";var cs=class extends Cr(UN){constructor(e,t=15,r=6710886){super(e,t,r);this.object=e;this.name=`PointLightHelper: ${e.uuid}`}raycast(e,t){Lr(this.object,cs.geometryHelper,e,t)}};import{SpotLightHelper as JN,Vector3 as HN}from"three";var Aa=class extends Cr(JN){constructor(e,t=6710886){super(e,t);this.object=e;this.name=`SpotLightHelper: ${e.uuid}`}raycast(e,t){Lr(this.object,Aa.geometryHelper,e,t)}update(){if(this.object!==void 0){let e=Aa._vector,t=this.object.distance?this.object.distance:1e3,r=t*Math.tan(this.object.angle);this.cone.scale.set(r,r,t),e.setFromMatrixPosition(this.object.target.matrixWorld),this.cone.lookAt(e);let o=this.color!==void 0?this.color:this.light.color;if(this.cone.material instanceof Array)for(let s=0,n=this.cone.material.length;s<n;s++)this.cone.material[s].color.set(o);else this.cone.material.color.set(o)}}},Pa=Aa;Pa._vector=new HN;var Or=(i,e)=>class extends i{constructor(){super(...arguments);this.objectHelper=new e(this);this.enableHelper=!1}set visibility(r){this.visible=r,this.setHelperVisibility(r),this.setHelperChildrenVisibility(r)}get visibility(){return this.visible}get geometryHelper(){return e.geometryHelper}setHelperVisibility(r){this.objectHelper.visible=r}setHelperChildrenVisibility(r){for(let o of this.children)tr(o)&&o.traverseEntity(s=>{Rr(s)&&s.visible&&(s.objectHelper.visible=r)})}raycast(r,o){this.objectHelper.raycast(r,o)}copy(r,o=!0){return super.copy(r,o),r.enableHelper!==void 0&&(this.enableHelper=r.enableHelper),r.objectHelper!==void 0&&(this.objectHelper.visible=r.objectHelper.visible),this}toJSON(r){let o=super.toJSON(r),s=o.object;return s.enableHelper=this.enableHelper,o}fromJSON(r){return super.fromJSON(r),r.enableHelper!==void 0&&(this.enableHelper=!0),this}fromLightState(r,o){if(this.objectType==="LightDirectional"||this.objectType==="LightPoint"||this.objectType==="LightSpot"){let s=this;r.color!==void 0&&(s.color=et(r.color,o)),r.intensity!==void 0&&(s.intensity=r.intensity),r.depth!==void 0&&(s.shadow.camera.far=r.depth,s.shadow.needsUpdate=!0),r.shadows!==void 0&&(this.castShadow=r.shadows),r.helper!==void 0&&(this.enableHelper=r.helper,s.gizmos.shadowmap.visible=r.helper)}return this}};var wi=new qt,Lc=new qt,Tr=class extends Or(rr(qN),Cc){constructor(e=window.innerWidth,t=window.innerHeight,r=45,o,s=1e5){super();this.objectType="CombinedCamera";this._cameraType="OrthographicCamera";this.targetOffset=bo.DefaultTargetOffset;this.isUpVectorFlipped=!1;this.angleOffsetFromUp=0;this.width=e,this.height=t,this.orthoCamera=new WN(e*-.5,e*.5,t*.5,t*-.5,o!=null?o:-5e4,s),this.perspCamera=new $N(r,e/t,o!=null?o:50,s),this.left=this.orthoCamera.left,this.right=this.orthoCamera.right,this.top=this.orthoCamera.top,this.bottom=this.orthoCamera.bottom,this.far=this.orthoCamera.far,this.view=this.orthoCamera.view,this.aspect=this.perspCamera.aspect,this.fov=this.perspCamera.fov,this.focus=this.perspCamera.focus,this.filmGauge=this.perspCamera.filmGauge,this.filmOffset=this.perspCamera.filmOffset,this.toOrthographic(!0)}static createFromState(e,t){let r=new Tr().fromState(t);return r.enableHelper=!0,r.objectHelper.update(),r.uuid=e,r}get isPerspectiveCamera(){return this.cameraType==="PerspectiveCamera"}get isOrthographicCamera(){return!this.isPerspectiveCamera}get cameraType(){return this._cameraType}setNear(e,t){e==="PerspectiveCamera"?this.perspCamera.near=t:this.orthoCamera.near=t}setZoom(e,t){t>=0&&(e==="PerspectiveCamera"?this.perspCamera.zoom=t:this.orthoCamera.zoom=t)}set cameraType(e){e==="PerspectiveCamera"?this.toPerspective():e==="OrthographicCamera"&&this.toOrthographic()}get near(){return this._cameraType==="PerspectiveCamera"?this.perspCamera.near:this.orthoCamera.near}set near(e){this._cameraType==="PerspectiveCamera"?this.perspCamera.near=e:this.orthoCamera.near=e}get zoom(){return this._cameraType==="PerspectiveCamera"?this.perspCamera.zoom:this.orthoCamera.zoom}set zoom(e){e>=0&&(this._cameraType==="PerspectiveCamera"?this.perspCamera.zoom=e:this.orthoCamera.zoom=e)}lookAt(e){super.lookAt(e),this.getWorldPosition(wi),this.targetOffset=wi.distanceTo(e)}getTarget(e=new qt){return this.getWorldDirection(Lc),this.getWorldPosition(wi),Lc.multiplyScalar(this.targetOffset),e.copy(wi).add(Lc),e}getDistanceToTarget(){let e=this.getTarget();return this.getWorldPosition(wi),wi.distanceTo(e)}updateUp(){let e=this.getWorldQuaternion(new KN),t=new qt(0,0,1).applyQuaternion(e),r=new qt().copy(Lf.DefaultUp);this.isUpVectorFlipped&&r.negate(),r.applyQuaternion(e);let o=new qt().copy(Lf.DefaultUp).projectOnPlane(t),s=new qt().crossVectors(o,r).dot(t)>=0?1:-1;this.angleOffsetFromUp=o.angleTo(r)*s}getViewFrontToObject(e){let t=e.getWorldPosition(new qt),o=e.getWorldDirection(new qt).multiplyScalar(this.targetOffset);return{position:t.clone().add(o),target:t}}getViewToObject(e){let t=e.getWorldPosition(new qt),o=this.getWorldDirection(new qt).multiplyScalar(this.targetOffset);return{position:t.clone().sub(o),target:t}}setViewplaneSize(e,t){this.left=-e*.5,this.right=e*.5,this.top=t*.5,this.bottom=-t*.5,this.aspect=e/t,this.updateProjectionMatrix()}toOrthographic(e){this.orthoCamera.left=this.left,this.orthoCamera.right=this.right,this.orthoCamera.top=this.top,this.orthoCamera.bottom=this.bottom,this.orthoCamera.view=this.view,this.orthoCamera.far=this.far,this.orthoCamera.updateProjectionMatrix(),this.projectionMatrix=this.orthoCamera.projectionMatrix,this.projectionMatrixInverse=this.orthoCamera.projectionMatrixInverse,this._cameraType="OrthographicCamera",(this.enableHelper===!0||e===!0)&&this.objectHelper.update()}toPerspective(e){this.perspCamera.aspect=this.aspect,this.perspCamera.fov=this.fov,this.perspCamera.view=this.view,this.perspCamera.far=this.far,this.perspCamera.updateProjectionMatrix(),this.projectionMatrix=this.perspCamera.projectionMatrix,this.projectionMatrixInverse=this.perspCamera.projectionMatrixInverse,this._cameraType="PerspectiveCamera",(this.enableHelper===!0||e===!0)&&this.objectHelper.update()}setFocalLength(e){this.perspCamera.setFocalLength(e),this.toPerspective()}getFocalLength(){return this.perspCamera.getFocalLength()}getEffectiveFOV(){return this.perspCamera.getEffectiveFOV()}getFilmWidth(){return this.perspCamera.getFilmWidth()}getFilmHeight(){return this.perspCamera.getFilmHeight()}setViewOffset(e,t,r,o,s,n){this._cameraType==="PerspectiveCamera"?this.perspCamera.setViewOffset(e,t,r,o,s,n):this.orthoCamera.setViewOffset(e,t,r,o,s,n)}clearViewOffset(){this._cameraType==="PerspectiveCamera"?(this.perspCamera.clearViewOffset(),this.toPerspective()):(this.orthoCamera.clearViewOffset(),this.toOrthographic())}updateProjectionMatrix(e){this._cameraType==="PerspectiveCamera"?this.toPerspective(e):this._cameraType==="OrthographicCamera"&&this.toOrthographic(e)}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}copy(e,t){return super.copy(e,t),this.orthoCamera.copy(e.orthoCamera),this.perspCamera.copy(e.perspCamera),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.far=e.far,this.view=e.view===null?null:Object.assign({},e.view),this._cameraType=e._cameraType,this.aspect=e.aspect,this.fov=e.fov,this.focus=e.focus,this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this.targetOffset=e.targetOffset,this.updateProjectionMatrix(),this}fromCameraRender(e){let t={near:this.orthoCamera.near,far:this.orthoCamera.far},r={near:this.perspCamera.near,far:this.perspCamera.far};return this.copy(e),this.name="",this.enableHelper=!0,this.objectHelper.visible=!0,this.orthoCamera.near=t.near,this.orthoCamera.far=t.far,this.perspCamera.near=r.near,this.perspCamera.far=r.far,this.updateProjectionMatrix(),this}toJSON(e){let t=super.toJSON(e),r=t.object;return r.objectType="CombinedCamera",r.cameraType=this.cameraType,r.targetOffset=this.targetOffset,r.isUpVectorFlipped=this.isUpVectorFlipped,r.angleOffsetFromUp=this.angleOffsetFromUp,r.left=this.left,r.right=this.right,r.top=this.top,r.bottom=this.bottom,this.view!==null&&(r.view=Object.assign({},this.view)),r.zoomOrtho=this.orthoCamera.zoom,r.nearOrtho=this.orthoCamera.near,r.far=this.far,r.aspect=this.aspect,r.fov=this.fov,r.focus=this.focus,r.filmGauge=this.filmGauge,r.filmOffset=this.filmOffset,r.zoomPersp=this.perspCamera.zoom,r.nearPersp=this.perspCamera.near,t}fromJSON(e){var t;if(super.fromJSON(e),this.cameraType=e.cameraType,e.targetOffset!==void 0&&(this.targetOffset=e.targetOffset),e.orbitControlsTarget!==void 0){let r=this.getWorldPosition(new qt),o=new qt().fromArray(e.orbitControlsTarget);this.targetOffset=o.distanceTo(r)}else e.targetOffset!==void 0&&(this.targetOffset=e.targetOffset);return this.isUpVectorFlipped=!1,this.angleOffsetFromUp=(t=e.angleOffsetFromUp)!=null?t:0,e.left!==void 0&&(this.left=e.left),e.right!==void 0&&(this.right=e.right),e.top!==void 0&&(this.top=e.top),e.bottom!==void 0&&(this.bottom=e.bottom),e.view!==void 0&&(this.view=Object.assign({},e.view)),e.zoomOrtho!==void 0&&(this.orthoCamera.zoom=e.zoomOrtho),e.nearOrtho!==void 0&&(this.orthoCamera.near=e.nearOrtho),e.far!==void 0&&(this.far=e.far),e.aspect!==void 0&&(this.aspect=e.aspect),e.fov!==void 0&&(this.fov=e.fov),e.focus!==void 0&&(this.focus=e.focus),e.filmGauge!==void 0&&(this.filmGauge=e.filmGauge),e.filmOffset!==void 0&&(this.filmOffset=e.filmOffset),e.zoomPersp!==void 0&&(this.perspCamera.zoom=e.zoomPersp),e.nearPersp!==void 0&&(this.perspCamera.near=e.nearPersp),this.updateProjectionMatrix(),this}toCameraState(e=[]){let t={type:this.cameraType,far:this.far,orthographic:{near:this.orthoCamera.near,zoom:this.orthoCamera.zoom},perspective:{near:this.perspCamera.near,fov:this.perspCamera.fov,zoom:this.perspCamera.zoom},up:this.up.toArray(),targetOffset:this.targetOffset,isUpVectorFlipped:this.isUpVectorFlipped};return Qo(t,e)}fromCameraState(e){let{orthographic:t,perspective:r}=e;return e.type!==void 0&&(this.cameraType=e.type),e.far!==void 0&&(this.far=e.far),t!==void 0&&(t.near!==void 0&&(this.orthoCamera.near=t.near),t.zoom!==void 0&&(this.orthoCamera.zoom=t.zoom)),r!==void 0&&(r.near!==void 0&&(this.perspCamera.near=r.near),r.fov!==void 0&&(this.perspCamera.fov=r.fov),r.zoom!==void 0&&(this.perspCamera.zoom=r.zoom)),e.up!==void 0&&this.up.fromArray(e.up),e.targetOffset!==void 0&&(this.targetOffset=e.targetOffset),e.isUpVectorFlipped!==void 0&&(this.isUpVectorFlipped=e.isUpVectorFlipped),this.updateProjectionMatrix(),this}toState(e){return q(P(P({},super.toState(e)),this.toCameraState(e)),{type:this.cameraType})}fromState(e){return super.fromState(e),this.fromCameraState(e),this}};import{Group as XN}from"three";var ho=class extends Or(rr(XN),ls){constructor(){super(...arguments);this.objectType="EmptyObject"}static createFromState(e,t){let r=new ho().fromState(t);return r.uuid=e,r.enableHelper=!0,r.objectHelper.update(),r}toJSON(e){let t=super.toJSON(e);return t.object.objectType="EmptyObject",t}};import{DirectionalLight as ZN,CameraHelper as ja}from"three";var ds=class extends Or(rr(ZN),as){constructor(...e){super(...e);this.objectType="LightDirectional";this._gizmos={};this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024;let r=this.shadow.camera;r.top=1250,r.bottom=-1250,r.right=1250,r.left=-1250,r.near=1,r.far=2500;let o=new ja(this.shadow.camera);o.visible=!1,this._gizmos.shadowmap=o,this.update()}static createFromState(e,t,r){let o=new ds().fromState(t,r);return o.uuid=e,o}get gizmos(){return this._gizmos}showGizmos(){for(let e in this._gizmos){let t=this._gizmos[e];t instanceof ja&&(t.visible=!0)}}hideGizmos(){for(let e in this._gizmos){let t=this._gizmos[e];t instanceof ja&&(t.visible=!1)}}update(){this.shadow.camera.updateProjectionMatrix();for(let e in this._gizmos){let t=this._gizmos[e];t instanceof ja&&t.update()}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.enableHelper===!0&&this.objectHelper.visible===!0&&this.objectHelper.update()}copy(e,t=!0){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}toJSON(e){let t=super.toJSON(e),r=t.object;return r.objectType="LightDirectional",r.color=this.color.getHex(),r.intensity=this.intensity,r.shadow=this.shadow.toJSON(),t}fromJSON(e){var o;super.fromJSON(e),this.color.set(e.color),this.intensity=e.intensity,this.shadow.normalBias=(o=e.shadow.normalBias)!=null?o:0,this.shadow.radius=e.shadow.radius,this.shadow.mapSize.fromArray(e.shadow.mapSize);let t=this.shadow.camera,r=e.shadow.camera;return t.near=r.near,t.far=r.far,t.zoom=r.zoom,t.left=r.left,t.right=r.right,t.top=r.top,t.bottom=r.bottom,r.view!==void 0&&(t.view=Object.assign({},r.view)),this}fromDirectionalLightState(e,t){let r=e.depth!==void 0&&e.depth!==this.shadow.camera.far||e.size!==void 0&&e.size/2!==this.shadow.camera.right;return super.fromLightState(e,t),e.size!==void 0&&Eu(this,e.size),r&&this.update(),this}fromState(e,t){return super.fromState(e),this.fromDirectionalLightState(e,t),this}};import{PointLight as QN,Vector3 as _a,Box3 as YN,Box3Helper as Da,Color as ew}from"three";var hs=class extends Or(rr(QN),cs){constructor(...e){super(...e);this.objectType="LightPoint";this._gizmos={};this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024;let r=this.shadow.camera;r.fov=90,r.aspect=1,r.near=100,r.far=2500;let o=new _a(-r.far+this.position.x,-r.far+this.position.y,-r.far+this.position.z),s=new _a(r.far+this.position.x,r.far+this.position.y,r.far+this.position.z),n=new YN(o,s),a=new Da(n,new ew(16755200));a.visible=!1,this._gizmos.shadowmap=a,this.update()}static createFromState(e,t,r){let o=new hs().fromState(t,r);return o.uuid=e,o}get gizmos(){return this._gizmos}showGizmos(){for(let e in this._gizmos){let t=this._gizmos[e];t instanceof Da&&(t.visible=!0)}}hideGizmos(){for(let e in this._gizmos){let t=this._gizmos[e];t instanceof Da&&(t.visible=!1)}}update(){if(this.shadow&&(this.shadow.camera.updateProjectionMatrix(),this._gizmos))for(let e in this._gizmos){let t=this._gizmos[e];if(t instanceof Da){let r=this.shadow.camera,o=new _a(-r.far+this.position.x,-r.far+this.position.y,-r.far+this.position.z),s=new _a(r.far+this.position.x,r.far+this.position.y,r.far+this.position.z);t.box.set(o,s),t.updateMatrixWorld(!0)}}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.enableHelper===!0&&this.objectHelper.visible===!0&&this.objectHelper.update()}copy(e,t=!0){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}toJSON(e){let t=super.toJSON(e),r=t.object;return r.objectType="LightPoint",r.color=this.color.getHex(),r.intensity=this.intensity,r.distance=this.distance,r.decay=this.decay,r.shadow=this.shadow.toJSON(),t}fromJSON(e){var o,s;super.fromJSON(e),this.color.set(e.color),this.intensity=e.intensity,this.distance=e.distance,this.decay=e.decay,this.shadow.normalBias=(o=e.shadow.normalBias)!=null?o:0,this.shadow.radius=e.shadow.radius,this.shadow.mapSize.fromArray((s=e.shadow.mapSize)!=null?s:[512,512]),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null);let t=this.shadow.camera,r=e.shadow.camera;return t.near=r.near,t.far=r.far,t.zoom=r.zoom,t.fov=r.fov,t.focus=r.focus,t.aspect=r.aspect,t.filmGauge=r.filmGauge,t.filmOffset=r.filmOffset,r.view!==void 0&&(t.view=Object.assign({},r.view)),this}fromPointLightState(e,t){return super.fromLightState(e,t),e.distance!==void 0&&(this.distance=e.distance),e.decay!==void 0&&(this.decay=e.decay),e.shadowRadius!==void 0&&(this.shadow.radius=e.shadowRadius),e.shadowResolution!==void 0&&(this.shadow.mapSize.set(e.shadowResolution,e.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null)),this}fromState(e,t){return super.fromState(e),this.fromPointLightState(e,t),this}};import{SpotLight as tw,CameraHelper as Ba,MathUtils as rw,Vector3 as Of,Quaternion as ow}from"three";var Tf=new Of,Mf=new Of,If=new ow,ps=class extends Or(rr(tw),Pa){constructor(...e){super(...e);this.objectType="LightSpot";this._gizmos={};this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024;let r=this.shadow.camera;r.fov=rw.RAD2DEG*2*this.angle,r.aspect=1,r.near=100,r.far=2500;let o=new Ba(this.shadow.camera);o.visible=!1,this._gizmos.shadowmap=o,this.update()}static createFromState(e,t,r){let o=new ps().fromState(t,r);return o.uuid=e,o}get gizmos(){return this._gizmos}showGizmos(){for(let e in this._gizmos){let t=this._gizmos[e];t instanceof Ba&&(t.visible=!0)}}hideGizmos(){for(let e in this._gizmos){let t=this._gizmos[e];t instanceof Ba&&(t.visible=!1)}}update(){this.shadow.camera.updateProjectionMatrix();for(let e in this._gizmos){let t=this._gizmos[e];t instanceof Ba&&t.update()}}updateMatrixWorld(e){super.updateMatrixWorld(e),Mf.setFromMatrixPosition(this.matrixWorld),If.setFromRotationMatrix(this.matrixWorld),Tf.copy(this.up).applyQuaternion(If).negate().multiplyScalar(this.distance),this.target.position.copy(Mf).add(Tf),this.target.updateMatrixWorld(),this.enableHelper===!0&&this.objectHelper.visible===!0&&this.objectHelper.update()}copy(e,t=!0){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}toJSON(e){let t=super.toJSON(e),r=t.object;return r.objectType="LightSpot",r.color=this.color.getHex(),r.intensity=this.intensity,r.distance=this.distance,r.angle=this.angle,r.decay=this.decay,r.penumbra=this.penumbra,r.shadow=this.shadow.toJSON(),t}fromJSON(e){var o;super.fromJSON(e),this.color.set(e.color),this.intensity=e.intensity,this.distance=e.distance,this.angle=e.angle,this.decay=e.decay,this.penumbra=e.penumbra,this.shadow.normalBias=(o=e.shadow.normalBias)!=null?o:0,this.shadow.radius=e.shadow.radius,this.shadow.mapSize.fromArray(e.shadow.mapSize);let t=this.shadow.camera,r=e.shadow.camera;return t.near=r.near,t.far=r.far,t.zoom=r.zoom,t.fov=r.fov,t.focus=r.focus,t.aspect=r.aspect,t.filmGauge=r.filmGauge,t.filmOffset=r.filmOffset,r.view!==void 0&&(t.view=Object.assign({},r.view)),this}fromSpotLightState(e,t){return super.fromLightState(e,t),e.distance!==void 0&&(this.distance=e.distance),e.decay!==void 0&&(this.decay=e.decay),e.angle!==void 0&&(this.angle=e.angle),e.penumbra!==void 0&&(this.penumbra=e.penumbra),this}fromState(e,t){return super.fromState(e),this.fromSpotLightState(e,t),this}};import{VideoTexture as iw}from"three";var Pf=i=>i.tagName==="VIDEO",Ci=class{static resize(e,t,r){let o=e/t,s;if(!r.image)return;let n=r.image;Pf(n)?s=n.videoWidth/n.videoHeight:s=n.width/n.height,o>s&&(r.imageType=="WEBCAM"?r.repeat.set(-1,1*s/o):r.repeat.set(1,1*s/o)),o<s&&(r.imageType=="WEBCAM"?r.repeat.set(1*o/s*-1,1):r.repeat.set(1*o/s,1)),o==s&&(r.imageType=="WEBCAM"?r.repeat.set(-1,1):r.repeat.set(1,1))}static resizeTextureLayer(e,t,r){let o=e/t,s=r.image!==void 0?r.image.width/r.image.height:1,n;o>s?n={x:1,y:s/o}:o<s?n={x:o/s,y:1}:n={x:1,y:1},r.repeat.set(n.x,n.y),r.updateMatrix()}static resizeTextureLayers(e,t,r){let o=r.userData.layers,s=o.getLayers();for(let n=0;n<s.length;n++){let a=s[n];sf(a)&&(Ci.resizeTextureLayer(e,t,a.uniforms[`f${a.id}_texture`].value),o.updateLayerUniform())}}static resizeComplex(e,t,r,o){let s=e/t,n,a=r.image;Pf(a)?n=a.videoWidth/a.videoHeight:n=a.width/a.height,o.geometry.type.includes("Shape")?(s>n&&(r.imageType=="WEBCAM"?r.repeat.set(1/e*-1,1/t*n/s):r.repeat.set(1/e,1/t*n/s)),s<n&&(r.imageType=="WEBCAM"?r.repeat.set(1/e*s/n*-1,1/t):r.repeat.set(1/e*s/n,1/t)),s==n&&(r.imageType=="WEBCAM"?r.repeat.set(1/e*-1,1/t):r.repeat.set(1/e,1/t))):(s>n&&(r.imageType=="WEBCAM"?r.repeat.set(-1,1*n/s):r.repeat.set(1,1*n/s)),s<n&&(r.imageType=="WEBCAM"?r.repeat.set(1*s/n*-1,1):r.repeat.set(1*s/n,1)),s==n&&(r.imageType=="WEBCAM"?r.repeat.set(-1,1):r.repeat.set(1,1)))}};var us=class extends yt{constructor(e,t=new Ct){super(e,t);this.objectType="Mesh2D";this.castShadow=!0,this.receiveShadow=!0}updateGeometry(e){super.updateGeometry(e),this.material.userData.layers&&Ci.resizeTextureLayers(this.geometry.userData.parameters.width,this.geometry.userData.parameters.height,this.material)}resizeGeometry(e,t){super.resizeGeometry(e,t,0),this.material.userData.layers&&Ci.resizeTextureLayers(this.geometry.userData.parameters.width,this.geometry.userData.parameters.height,this.material)}toJSON(e){let t=super.toJSON(e);return t.object.objectType="Mesh2D",t}clone(){let e=super.clone();return e.updateGeometry({}),e}static fromTexture(e){let t,r;if(e instanceof iw){let n=e.image;t=n.videoWidth*.5,r=n.videoHeight*.5}else{let n=e.image;t=n.width*.5,r=n.height*.5}let o=ra.create({parameters:{width:t,height:r}}),s=new Ct;return s.layersList.changeLayer(0,{type:Le.TEXTURE,texture:e}),s.layersList.moveLayer(0,1),s.dispose(),new us(o,s)}};var fs=class extends yt{constructor(e,t=new ir){super(e,t);this.objectType="Mesh3D";this.castShadow=!0,this.receiveShadow=!0}toJSON(e){let t=super.toJSON(e);return t.object.objectType="Mesh3D",t}};var ms=class extends fs{constructor(e,t=new ir){super(e,t);this.objectType="NonParametric"}toJSON(e){let t=super.toJSON(e);return t.object.objectType="NonParametric",t}};var gs;(function(t){t[t.TO_RIGHT=1]="TO_RIGHT",t[t.TO_LEFT=-1]="TO_LEFT"})(gs||(gs={}));var Oc=class extends yt{constructor(e,t=new Ct({transparent:!0,opacity:1,visible:!1,side:Ga})){super(e,t);this.objectType="TextFrame";this.charContainer=new sw,this.add(this.charContainer),this.material.visible=!1,this._geometryUserData=e.userData,this.userData.textFrame={hexColor:null,opacity:1,visible:!0,text:"",fontSize:16,lineHeight:1.5,letterSpacing:1,fontFamily:"roboto_regular",textTransform:ro.None,horizontalAlignment:1,verticalAlignment:Er.Top,LOD:16,maxLineSize:this._geometryUserData.parameters.width,textOrigin:new jf(this._geometryUserData.parameters.width*-.5,this._geometryUserData.parameters.height*.5,0),textLines:[]},this.createTextLine()}static createFromState(e,t,r){let o=oa.create({parameters:{width:t.width,height:t.height}}),s=new Oc(o).fromState(t,r);return s.uuid=e,s}async updateText(e){this.clearText();let t=this.userData.textFrame,r=t.fontFamily;await Bt.loadFont(r),t.text=e;let o=t.textOrigin,s=new Af({visible:t.visible,transparent:!0,side:Ga}),n=e.split(`
961
- `),a=0;this.userData.textFrame.textLines=n.map((l,c)=>{let d=new Po(a,t.lineHeight,t.fontSize);return d.message=l.split("").map(h=>{let p={char:h,fontFamily:r,letterSpacing:t.letterSpacing,fontSize:t.fontSize,LOD:16},m=s.clone();m.color=t.hexColor,m.opacity=t.opacity;let f=new Bt(p,m);return d.addChar3D(f,o),this.charContainer.add(f),f}),a+=d.maxCharSize*d.lineHeight,d}),this.textFullUpdate(),this.checkOverFlow()}clearText(){let e=this.userData.textFrame.textLines;for(;this.charContainer.children.length;){let t=this.charContainer.children[0];this.charContainer.remove(t)}for(;e.length;)e.pop()}raycast(e,t){let r=[];if(super.raycast(e,r),r.length>0){t.push(r[0]);return}let o=[];for(let s=0,n=this.charContainer.children.length;s<n;++s)if(this.charContainer.children[s]instanceof Bt&&(e.intersectObject(this.charContainer.children[s],!1,o),o.length>0)){o[0].object=this,t.push(o[0]);return}}updateGeometry(e){var c,d,h,p;let t=this.userData,r=this.geometry.userData,o=r.parameters.width,s=r.parameters.height,n=(d=(c=e.parameters)==null?void 0:c.width)!=null?d:o,a=(p=(h=e.parameters)==null?void 0:h.height)!=null?p:s,l=t.textFrame;super.updateGeometry(e),l.maxLineSize=n,l.textOrigin.set(-.5*n,.5*a,0),a!==s?(this.checkOverFlow(),this.checkCapacity()):n!==o&&(o<n?this.checkCapacity():o>n&&this.checkOverFlow())}checkOverFlow(e=0){let t=this.userData,r=t.textFrame.textOrigin,o=t.textFrame.textLines;for(let s=e;s<o.length;s++){o[s].updateYLinePos(this.getNewLinePosition(s)),o[s].fullUpdate(r);let n=[];for(;o[s].checkOverFlow(t.textFrame.maxLineSize);)o[s].containSpaceOverFlow()?n.unshift(o[s].getWord(o[s].message.length-1,-1)):n.unshift(o[s].popChar());if(n.length>0){o[s+1]===void 0?(o[s].isEndLine(!1),this.createTextLine()):o[s].endLine&&(this.createTextLine(s+1),o[s].isEndLine(!1),o[s+1].isEndLine(!0));let a=0;for(let l=0;l<n.length;l+=1)for(let c=0;c<n[l].length;c+=1)o[s+1].addChar3D(n[l][c],r,a),a+=1;o[s+1].fullUpdate(r)}o[s].fullUpdate(r)}this.textFullUpdate(e)}checkCapacity(e=0){let t=this.userData,r=t.textFrame.textOrigin,o=t.textFrame.maxLineSize,s=t.textFrame.textLines;for(let n=e;n<s.length;n+=1)if(s[n].updateYLinePos(this.getNewLinePosition(n)),s[n].fullUpdate(r),!!s[n-1])for(;!s[n-1].endLine;){let a,l=s[n-1].spaceLeft(o);if(s[n].wordSize(0,1)<=l){s[n].containSpace()?a=s[n].getWord(0,1):a=s[n].popChar(0);for(let c=0;c<a.length;c+=1)a[c]&&s[n-1].addChar3D(a[c],r)}else{s[n].isEmpty()?(s[n].endLine&&s[n-1].isEndLine(!0),s.splice(n,1),n-=1):(s[n].updateYLinePos(this.getNewLinePosition(n)),s[n].fullUpdate(r));break}}this.textFullUpdate(e)}createTextLine(e=this.userData.textFrame.textLines.length){let r=this.userData.textFrame;r.textLines.splice(e,0,new Po(this.getNewLinePosition(e),r.lineHeight,r.fontSize))}textFullUpdate(e=0){let r=this.userData.textFrame,o=r.textLines,s=this.getVerticalAlignmentOffSet();for(let n=e;n<o.length;n++)o[n].updateYLinePos(this.getNewLinePosition(n)),o[n].fullUpdate(r.textOrigin),o[n].alignText(r.textOrigin,r.maxLineSize,r.horizontalAlignment,r.verticalAlignment,s)}getVerticalAlignmentOffSet(){switch(this.userData.textFrame.verticalAlignment){case Er.Top:return 0;case Er.Center:return this.getRemainingVerticalSpace()/2;case Er.Bottom:return this.getRemainingVerticalSpace();default:return 0}}getRemainingVerticalSpace(){let t=this.userData.textFrame.textLines;return this.geometry.userData.parameters.height-this.getNewLinePosition(t.length)}getNewLinePosition(e){let r=this.userData.textFrame.textLines,o=0;for(let s=0;s<e;s+=1)o+=r[s].maxCharSize*r[s].lineHeight;return o}updateColor(e){var o;let t=this.userData;t.textFrame.hexColor=e;let r=t.textFrame.textLines;for(let s=0;s<r.length;s++){let n=r[s].message;for(let a=0;a<n.length;a++){let l=n[a].material;((o=l.color)==null?void 0:o.isColor)&&(l.color=e)}}}updateOpacity(e){let t=this.userData;t.textFrame.opacity=e;let r=t.textFrame.textLines;for(let o=0;o<r.length;o++){let s=r[o].message;for(let n=0;n<s.length;n++){let a=s[n].material;a.opacity=e}}}updateVisible(e){let t=this.userData;t.textFrame.visible=e;let r=t.textFrame.textLines;for(let o=0;o<r.length;o++){let s=r[o].message;for(let n=0;n<s.length;n++){let a=s[n].material;a.visible=e}}}async updateFontFamily(e){await Bt.loadFont(e);let r=this.userData.textFrame,o=r.textLines;r.fontFamily=e;for(let s=0;s<o.length;s++){let n=o[s].message;for(let a=0;a<n.length;a++)n[a].updateFontFamily(e)}this.textFullUpdate(),this.checkOverFlow(),this.checkCapacity()}updateFontSize(e){let r=this.userData.textFrame,o=r.textLines,s=r.fontSize;r.fontSize=e;for(let n=0;n<o.length;n++)o[n].updateFontSize(e);this.textFullUpdate(),e>s?this.checkOverFlow():e<s&&this.checkCapacity()}async updateTextTransform(e){let r=this.userData.textFrame;await Bt.loadFont(r.fontFamily);let o=r.textLines;switch(r.textTransform=e,e){case ro.Upper:for(let s=0;s<o.length;s++){let n=o[s].message;for(let a=0;a<n.length;a++)o[s].message[a].updateChar(n[a].char.toUpperCase())}break;case ro.Lower:for(let s=0;s<o.length;s++){let n=o[s].message;for(let a=0;a<n.length;a++)o[s].message[a].updateChar(n[a].char.toLowerCase())}break;default:for(let s=0;s<o.length;s++){let n=o[s].message;for(let a=0;a<n.length;a++)o[s].message[a].updateChar(n[a].originalChar)}}this.textFullUpdate(),this.checkOverFlow(),this.checkCapacity()}updateLetterSpacing(e){let t=this.userData,r=t.textFrame.textLines;t.textFrame.letterSpacing=e;for(let o=0;o<r.length;o++){let s=r[o].message;for(let n=0;n<s.length;n++)s[n].updateLetterSpacing(e)}this.textFullUpdate(),this.checkOverFlow(),this.checkCapacity()}updateLOD(e){let t=this.userData;t.textFrame.LOD=e;let r=t.textFrame.textLines;for(let o=0;o<r.length;o++);this.textFullUpdate(),this.checkOverFlow(),this.checkCapacity()}updateLineHeight(e){let t=this.userData,r=t.textFrame.textLines;t.textFrame.lineHeight=e;for(let o=0;o<r.length;o++)r[o].updatelineHeight(e);this.textFullUpdate()}updateVerticalAlignment(e){let t=this.userData;t.textFrame.verticalAlignment=e,this.textFullUpdate()}updateHorizontalAlignment(e){let t=this.userData;t.textFrame.horizontalAlignment=e,this.textFullUpdate()}toJSON(e){let t=super.toJSON(e),r=t.object;r.objectType="TextFrame";let s=this.userData.textFrame.textLines.map(n=>{let a=n.message.map(l=>({char:l.char,originalChar:l.originalChar,fontFamily:l.fontFamily,letterSpacing:l.letterSpacing,fontSize:l.fontSize,LOD:l.LOD}));return{align:n.align,endLine:n.endLine,lineHeight:n.lineHeight,maxCharSize:n.maxCharSize,yLinePos:n.yLinePos,message:a}});return r.userData.textFrame.textLinesData=s,t}async fromJSONasync(e){if(super.fromJSON(e),e.userData!==void 0){let t=e.userData.textFrame;await Bt.loadFont(t.fontFamily),t.textOrigin=new jf(t.textOrigin.x,t.textOrigin.y,t.textOrigin.z);let r=new Af({color:t.hexColor,opacity:t.opacity,visible:t.visible,transparent:!0,side:Ga});t.textLinesData&&(t.textLines=t.textLinesData.map((o,s)=>{let n=new Po(Number(o.yLinePos),Number(o.lineHeight),Number(o.maxCharSize)),a=o.message.map((l,c)=>{if(l.char===void 0){let p=t.textLines[s].message[c];if("geometries"in p){let m=p.geometries[0].userData.parameters;Object.assign(l,{LOD:m.lod,char:m.char,fontFamily:m.fontFamily,fontSize:m.fontSize,letterSpacing:m.letterSpacing,originalChar:m.char})}}let d={char:l.char,fontFamily:l.fontFamily,letterSpacing:Number(l.letterSpacing),fontSize:Number(l.fontSize),LOD:l.LOD},h=new Bt(d,r.clone());return n.addChar3D(h,t.textOrigin),this.charContainer.add(h),h});return n.message=a,n}),this.userData.textFrame=t),this.textFullUpdate()}return this}fromTextFrameData(e,t){if(e.color!==void 0){let r=et(e.color,t);this.updateColor(r),this.updateOpacity(r.a)}e.alpha!==void 0&&this.updateOpacity(e.alpha),e.font!==void 0&&this.updateFontFamily(e.font),e.horizontalAlign!==void 0&&this.updateHorizontalAlignment(e.horizontalAlign),e.verticalAlign!==void 0&&this.updateVerticalAlignment(e.verticalAlign),e.textTransform!==void 0&&this.updateTextTransform(e.textTransform),e.fontSize!==void 0&&this.updateFontSize(e.fontSize),e.lineHeight!==void 0&&this.updateLineHeight(e.lineHeight),e.letterSpacing!==void 0&&this.updateLetterSpacing(e.letterSpacing),e.text!==void 0&&e.text!==""&&this.updateText(e.text),(e.width!==void 0||e.height!==void 0)&&this.updateGeometry({parameters:{width:e.width,height:e.height}})}fromState(e,t){return super.fromState(e),this.fromTextFrameData(e,t),this}convertToVector(){let{fontFamily:e,hexColor:t}=this.userData.textFrame,r=new ho;r.name="Text Shape";let o=Bt.fontCache[e];for(let s of this.charContainer.children)s instanceof Bt&&o.generateShapes(s.char,1).forEach(n=>{let a=new Pe().fromShape(n);a.applyScale(s.scale.x,s.scale.y);let l=mt.create({shape:a}),c=new Ct({side:Ga});c.color=t;let d=new Ao(l,c);d.name=s.char,d.position.copy(s.position),d.rotation.copy(s.rotation),r.attach(d)});return r}},Li=Oc;Li.VerticalAlign=Er,Li.HorizontalAlign=Mt,Li.TextTransform=ro;import{HemisphereLight as Hw,Scene as qw,Vector3 as Ww,Color as Xf,Fog as $w,Box3 as Kw}from"three";import{EffectComposer as bw,EffectPass as Tc,RenderPass as _f,SMAAEffect as vw,EdgeDetectionMode as Sw,PredicationMode as Nw,SMAAPreset as ww,CopyPass as Cw}from"postprocessing";import{Scene as Lw,Clock as Ow,LoadingManager as Tw,WebGLRenderTarget as Mw,RepeatWrapping as Df,Vector2 as Iw,Vector4 as Bf,EventDispatcher as Pw}from"three";import{BloomEffect as aw,BlendFunction as lw}from"postprocessing";import{BlendFunction as nw}from"postprocessing";var ot=class{constructor(e,t){this.enabled=!1;this.effect=new e(t),Object.defineProperty(this,"opacity",{enumerable:!0,set(r){this.effect.blendMode.opacity.value=r},get(){return this.effect.blendMode.opacity.value}}),Object.defineProperty(this,"blendFunction",{enumerable:!0,set(r){this.effect.blendMode.setBlendFunction(Number(r))},get(){return this.effect.blendMode.blendFunction}}),this.blendFunction=nw.NORMAL}toJSON(){let e=["constructor","effect","subscriptions"],t=P({},this),r=Object.getPrototypeOf(this),o=Object.getOwnPropertyNames(r);for(let s of o){let n=Object.getOwnPropertyDescriptor(r,s);n&&typeof n.get=="function"&&(t[s]=this[s])}return e.forEach(s=>delete t[s]),t}};var ys=class extends ot{constructor(){super(aw);this.blendFunction=lw.SCREEN}set intensity(e){this.effect.intensity=e}get intensity(){return this.effect.intensity}set luminanceThreshold(e){this.effect.luminanceMaterial.threshold=e}get luminanceThreshold(){return this.effect.luminanceMaterial.threshold}set luminanceSmoothing(e){this.effect.luminanceMaterial.smoothing=e}get luminanceSmoothing(){return this.effect.luminanceMaterial.smoothing}set blurScale(e){this.effect.blurPass.scale=e}get blurScale(){return this.effect.blurPass.scale}set kernelSize(e){this.effect.blurPass.kernelSize=e}get kernelSize(){return this.effect.blurPass.kernelSize}};import{BrightnessContrastEffect as cw}from"postprocessing";var xs=class extends ot{constructor(){super(cw)}set contrast(e){this.effect.uniforms.get("contrast").value=e}get contrast(){return this.effect.uniforms.get("contrast").value}set brightness(e){this.effect.uniforms.get("brightness").value=e}get brightness(){return this.effect.uniforms.get("brightness").value}};import{Vector2 as dw}from"three";import{ChromaticAberrationEffect as hw}from"postprocessing";var bs=class extends ot{constructor(){super(hw);this.effect.offset=new dw(.01,.01)}set offset(e){this.effect.offset.set(e[0]/1e3,e[1]/1e3)}get offset(){return[this.effect.offset.x*1e3,this.effect.offset.y*1e3]}};import{ColorAverageEffect as pw}from"postprocessing";var vs=class extends ot{constructor(){super(pw)}};import{HueSaturationEffect as uw}from"postprocessing";var Ss=class extends ot{constructor(){super(uw);this._hue=0}set hue(e){this._hue=e,this.effect.setHue(e)}get hue(){return this._hue}set saturation(e){this.effect.uniforms.get("saturation").value=e}get saturation(){return this.effect.uniforms.get("saturation").value}};import{NoiseEffect as fw,BlendFunction as mw}from"postprocessing";var Ns=class extends ot{constructor(){super(fw);this.blendFunction=mw.OVERLAY}};import{VignetteEffect as gw}from"postprocessing";var ws=class extends ot{constructor(){super(gw)}get eskil(){return this.effect.eskil}set eskil(e){this.effect.eskil=e}get darkness(){return this.effect.uniforms.get("darkness").value}set darkness(e){this.effect.uniforms.get("darkness").value=e}get offset(){return this.effect.uniforms.get("offset").value}set offset(e){this.effect.uniforms.get("offset").value=e}};import{DepthOfFieldEffect as yw}from"postprocessing";var Cs=class extends ot{constructor(e){super(yw,e)}set focalLength(e){this.effect.circleOfConfusionMaterial.uniforms.focalLength.value=e}get focalLength(){return this.effect.circleOfConfusionMaterial.uniforms.focalLength.value}set focusDistance(e){this.effect.circleOfConfusionMaterial.uniforms.focusDistance.value=e}get focusDistance(){return this.effect.circleOfConfusionMaterial.uniforms.focusDistance.value}get bokehScale(){return this.effect.bokehScale}set bokehScale(e){this.effect.bokehScale=e}};import{PixelationEffect as xw}from"postprocessing";var Ls=class extends ot{constructor(){super(xw)}get granularity(){return this.effect.getGranularity()}set granularity(e){this.effect.setGranularity(e)}};function Gf(i,e){return e&&e.enabled&&i.push(e.effect),i}var Ea=class extends Pw{constructor(){super();this._scene=new Lw;this._camera=new Tr;this.effects=new Map;this.loadingManager=new Tw;this.renderPass=new _f;this._renderToScreen=!0;this._hasSmaa=!1;this.clock=new Ow,this.enabled=!1,this.debug=!1,this.effects.set("bloom",new ys),this.effects.set("chromaticAberration",new bs),this.effects.set("vignette",new ws),this.effects.set("noise",new Ns),this.effects.set("colorAverage",new vs),this.effects.set("hueSaturation",new Ss),this.effects.set("brightnessContrast",new xs),this.effects.set("depthOfField",new Cs),this.effects.set("pixelation",new Ls)}get scene(){return this._scene}set scene(e){this._scene=e}get camera(){return this._camera}set camera(e){this._camera=e}_initSmaa(){if(!this.effectComposer)return;let e=this.effectComposer.passes.length,t=new vw({preset:ww.ULTRA,edgeDetectionMode:Sw.COLOR}),r=()=>{t.removeEventListener("load",r),this.dispatchEvent({type:"smaaloaded"})};t.addEventListener("load",r),t.edgeDetectionMaterial.setPredicationMode(Nw.DEPTH),t.edgeDetectionMaterial.setEdgeDetectionThreshold(.05),t.edgeDetectionMaterial.setPredicationThreshold(.002),t.edgeDetectionMaterial.setPredicationScale(1),this.effectComposer.addPass(new Tc(this.camera,t),e),this._hasSmaa=!0}_initPasses(){if(!this.effectComposer||!this.renderer)return;let e;if(this.effectComposer.removeAllPasses(),this._hasSmaa=!1,this.renderPass=new _f(this.scene,this.camera),this.enabled){this.effectComposer.addPass(this.renderPass),this._initSmaa();let t=[this.effects.get("chromaticAberration"),this.effects.get("bloom"),this.effects.get("colorAverage"),this.effects.get("hueSaturation"),this.effects.get("brightnessContrast"),this.effects.get("vignette"),this.effects.get("noise")].reduce(Gf,[]),r=[this.effects.get("pixelation")].reduce(Gf,[]);r.length>0&&this.effectComposer.addPass(new Tc(this.camera,...r)),this.effectComposer.addPass(new Tc(this.camera,...t))}else this.effectComposer.addPass(this.renderPass);if(e)return e}reinit(){if(!this.renderer)return Promise.all([]);this.effectComposer=new bw(this.renderer),this._initPasses()}init({renderer:e,camera:t,scene:r}){this.renderer=e,this.scene=r,this.camera=t,this._initCopyPass(),this.reinit()}_initCopyPass(){if(this._savePass)return;let e=new Iw;this.renderer.getDrawingBufferSize(e),this._rt=new Mw(e.x,e.y,{depthBuffer:!1,stencilBuffer:!1,wrapS:Df,wrapT:Df}),this._rt.samples=this.renderer.capabilities.isWebGL2?4:0,this._savePass=new Cw(this._rt,!1),this._savePass.renderToScreen=!1}get renderToScreen(){return this._renderToScreen}set renderToScreen(e){var r,o;let t=this.effectComposer;!t||(e===!0?(((r=this.renderer)==null?void 0:r.capabilities.isWebGL2)&&(t.multisampling=0),t.removePass(this._savePass),t.passes[t.passes.length-1].renderToScreen=!0,t.autoRenderToScreen=!0):(((o=this.renderer)==null?void 0:o.capabilities.isWebGL2)&&!this._hasSmaa&&(t.multisampling=4),t.autoRenderToScreen=!1,t.passes[t.passes.length-1].renderToScreen=!1,this._savePass.renderToScreen=!1,t.addPass(this._savePass)),this._renderToScreen=e)}get texture(){return this._rt&&this._rt.texture}get renderTarget(){return this._rt}fromJSON(e){e&&(Object.keys(e).forEach(t=>{let r=e[t],o=this.effects.get(t);Object.keys(r).forEach(s=>{o[s]=r[s]})}),this.enabled=e.enabled)}toJSON(){let e={};return this.effects.forEach((t,r)=>{e[r]=t.toJSON()},e),P({enabled:this.enabled},e)}render(){var e;(e=this.effectComposer)==null||e.render(this.clock.getDelta())}setScissor(e,t,r,o){if(!this.effectComposer||!this.renderer)return;e instanceof Bf?(this.effectComposer.inputBuffer.scissor.set(e.x,e.y,e.z,e.w),this.effectComposer.outputBuffer.scissor.set(e.x,e.y,e.z,e.w)):(this.effectComposer.inputBuffer.scissor.set(e,t,r,o),this.effectComposer.outputBuffer.scissor.set(e,t,r,o));let s=this.renderer.getPixelRatio();this.effectComposer.inputBuffer.scissor.multiplyScalar(s),this.effectComposer.outputBuffer.scissor.multiplyScalar(s),this.renderer.setScissor(e,t,r,o)}setScissorTest(e){!this.effectComposer||!this.renderer||(this.effectComposer.inputBuffer.scissorTest=e,this.effectComposer.outputBuffer.scissorTest=e,this.renderer.setScissorTest(e))}setViewport(e,t,r,o){!this.effectComposer||(e instanceof Bf?(this.effectComposer.inputBuffer.viewport.copy(e),this.effectComposer.outputBuffer.viewport.copy(e)):(this.effectComposer.inputBuffer.viewport.set(e,t,r,o),this.effectComposer.outputBuffer.viewport.set(e,t,r,o)))}resize(e,t){var r,o;if((r=this.effectComposer)==null||r.setSize(e,t),this._rt){let s=((o=this.renderer)==null?void 0:o.getPixelRatio())||window.devicePixelRatio;this._rt.setSize(e*s,t*s)}}dispose(){var e;this._listeners=void 0,(e=this.effectComposer)==null||e.dispose()}};import{BufferGeometryLoader as Aw}from"three";function Ef(i,e){return jw(i)}function jw(i){let e={parameters:i,type:i.type};if(i.type==="VectorGeometry"){let r=Pe.createFromState(i.shape,i.width,i.height);e.shape=r}else i.type==="NonParametricGeometry"&&(e.geometry=new Aw().parse(i));let t;try{t=Ki(e)}catch(r){console.error(r)}if(!t){let r=Pe.createFromState(li.defaultData(),100,100);e.shape=r,t=Ki(e)}return t}import{Box3 as _w,Matrix4 as jo,Sphere as Rf,Vector3 as Dw}from"three";var Vf=Fc(Ff());var Mc;ia.then(i=>{Mc=i});var kf=new jo,Bw=new jo,Gw=new jo,ur=new _w,po=new Dw,Ew=new jo,zw=new jo,Os=class extends yt{constructor(e,t,r,o=new ir){super(r!=null?r:t,o);this.subdivPointer=e;this.originalGeometry=t;this.subdividedGeometry=r;this.objectType="SubdivObject";this.hiddenMatrixOld=new jo;this.smoothShading=!0;this.matrixWorldRigid=new jo;this.castShadow=!0,this.receiveShadow=!0,this.forceComputeSize=!1}static createFromState(e,t,r){let{subdivPointer:o,originalGeometry:s,subdividedGeometry:n}=Qt.build(t.geometry,void 0,void 0,!t.flatShading),a=ns(t.material,r),l=new Os(o,s,n||void 0,a);return l.calcBoundingBox(),l.freeSubdivPointer(),l.uuid=e,l.fromState(t),l}shallowClone(e){return new ms(this.geometry,this.material).shallowCopy(this,e)}toJSON(e){let t=super.toJSON(e);return t.object.objectType="SubdivObject",t}buildFromStore(e){var s,n,a;let{originalGeometry:t,subdividedGeometry:r,subdivPointer:o}=Qt.build(e,this.subdivPointer,void 0,this.smoothShading,this.shearScale);if(this.subdivPointer=o,t!==void 0&&((s=this.originalGeometry)==null||s.dispose(),this.originalGeometry=t),r!==void 0&&((n=this.subdividedGeometry)==null||n.dispose(),this.subdividedGeometry=r!=null?r:void 0),this.geometry=(a=this.subdividedGeometry)!=null?a:this.originalGeometry,this.cloner)for(let l of this.cloner.children)l.geometry=this.geometry;e.width&&(this.geometry.userData.parameters={width:e.width,height:e.height,depth:e.depth})}updateMesh(e=!1){Qt.buildLevel(this.subdivPointer,!0,this.smoothShading,this.originalGeometry,e?this.shearScaleInv:void 0),this.subdividedGeometry&&Qt.buildLevel(this.subdivPointer,!1,this.smoothShading,this.subdividedGeometry,e?this.shearScaleInv:void 0)}updateTopology(){var e;this.originalGeometry.dispose(),this.originalGeometry=Qt.buildLevel(this.subdivPointer,!0,this.smoothShading),this.subdividedGeometry&&(this.subdividedGeometry.dispose(),this.subdividedGeometry=Qt.buildLevel(this.subdivPointer,!1,this.smoothShading)),this.geometry=(e=this.subdividedGeometry)!=null?e:this.originalGeometry}raycast(e,t){var r;this.geometry=this.originalGeometry,yt.prototype.raycast.call(this,e,t),this.geometry=(r=this.subdividedGeometry)!=null?r:this.originalGeometry}updateMatrixWorldSVD(){let e=this.matrixWorld.elements,t=[[e[0],e[4],e[8]],[e[1],e[5],e[9]],[e[2],e[6],e[10]]],{u:r,v:o,q:s}=(0,Vf.SVD)(t),n=kf.set(r[0][0],r[0][1],r[0][2],0,r[1][0],r[1][1],r[1][2],0,r[2][0],r[2][1],r[2][2],0,0,0,0,1),a=Bw.set(o[0][0],o[0][1],o[0][2],0,o[1][0],o[1][1],o[1][2],0,o[2][0],o[2][1],o[2][2],0,0,0,0,1),l=Gw.copy(a).transpose();this.shearScale=Ew.makeScale(s[0],s[1],s[2]).multiply(l).premultiply(a),this.shearScaleInv=zw.copy(this.shearScale).invert(),this.matrixWorldRigid.multiplyMatrices(n,l),s.every(c=>Math.abs(s[0]-c)<.01)&&(this.shearScale=void 0,this.shearScaleInv=void 0)}activateSVDCompensation(){this.shearScale!==void 0&&(this.matrixAutoUpdate=!1,this.matrix.copy(this.matrixWorldRigid).copyPosition(this.matrixWorld),this.hiddenMatrixOld.copy(this.hiddenMatrix),this.hiddenMatrix.copy(this.parent.matrixWorld).invert())}deactivateSVDCompensation(){this.shearScale!==void 0&&(this.shearScale=void 0,this.shearScaleInv=void 0,this.matrixAutoUpdate=!0,this.hiddenMatrix.copy(this.hiddenMatrixOld))}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new Rf);let t=e.attributes.position,r=e.boundingSphere.center;ur.setFromBufferAttribute(t),ur.getCenter(r),e.boundingSphere.radius=r.distanceTo(ur.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),ur.getSize(po);let o={width:po.x,height:po.y,depth:po.z};return this.geometry.userData.parameters=o,o}updateBoundingBox(e){let t=this.originalGeometry;ur.min.set(e[0],e[2],e[4]),ur.max.set(e[1],e[3],e[5]),this.shearScaleInv&&(ur.min.applyMatrix4(this.shearScaleInv),ur.max.applyMatrix4(this.shearScaleInv)),t.boundingSphere===null&&(t.boundingSphere=new Rf);let r=t.boundingSphere.center;ur.getCenter(r),t.boundingSphere.radius=r.distanceTo(ur.max),isNaN(t.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),ur.getSize(po);let o={width:po.x,height:po.y,depth:po.z};return this.geometry.userData.parameters=o,o}freeSubdivPointer(){this.subdivPointer&&(Mc.free_bvh(this.subdivPointer),Mc.free_subdivision_surface(this.subdivPointer),this.subdivPointer=0)}updateGeometry(e){this.geometry.userData.scale||(this.geometry.userData.scale=Array(3)),this.geometry.userData.scale[0]=this.geometry.userData.parameters.width===0?1:e.parameters.width/this.geometry.userData.parameters.width,this.geometry.userData.scale[1]=this.geometry.userData.parameters.height===0?1:e.parameters.height/this.geometry.userData.parameters.height,this.geometry.userData.scale[2]=this.geometry.userData.parameters.depth===0?1:e.parameters.depth/this.geometry.userData.parameters.depth,Uf(this.originalGeometry.attributes,...this.geometry.userData.scale),this.originalGeometry.attributes.position.needsUpdate=!0,this.originalGeometry.attributes.normal.needsUpdate=!0,this.subdividedGeometry&&(Uf(this.subdividedGeometry.attributes,...this.subdividedGeometry.userData.scale),this.subdividedGeometry.attributes.position.needsUpdate=!0,this.subdividedGeometry.attributes.normal.needsUpdate=!0),this.geometry.userData.parameters=P({},e.parameters)}};function Uf(i,e,t,r){let o=i.position.array,s=i.normal.array,n=kf.makeScale(e,t,r).invert().elements,a,l,c;for(var d=0,h=o.length;d<h;d+=3)o[d]*=e,o[d+1]*=t,o[d+2]*=r,a=s[d],l=s[d+1],c=s[d+2],s[d]=n[0]*a+n[4]*l+n[8]*c,s[d+1]=n[1]*a+n[5]*l+n[9]*c,s[d+2]=n[2]*a+n[6]*l+n[10]*c}import{BackSide as Fw,DoubleSide as Rw,FrontSide as Vw}from"three";function Jf(i,e){e.flatShading!==void 0&&(i.flatShading=e.flatShading,i.needsUpdate=!0),e.wireframe!==void 0&&(i.wireframe=e.wireframe),e.side!==void 0&&(e.side===ii.Front?i.side=Vw:e.side===ii.Back?i.side=Fw:i.side=Rw)}function kw(i,e){if(Array.isArray(i.material))for(let t of i.material)Jf(t,e);else{let t=i.material;Jf(t,e)}i.objectType==="SubdivObject"&&e.flatShading!==void 0&&(i.material.flatShading=!1,i.smoothShading=!e.flatShading,i.updateMesh())}function Hf(i,e,t){let r;if(e.geometry.type==="SubdivGeometry")r=Os.createFromState(i,e,t);else{let o=Ef(e.geometry,t),s="materials"in e?yf(e.materials,t):ns(e.material,t);Gn.is2DParametricMesh(o.userData.type)?r=new us(o,s):(o==null?void 0:o.userData.type)==="VectorGeometry"?r=new Ao(o,s):e.geometry.type==="NonParametricGeometry"?r=new ms(o,s):r=new fs(o,s),r.uuid=i,r.fromState(e)}return kw(r,e),r}function qf(i,e,t){return e.type==="Mesh"?Hf(i,e,t):e.type==="TextFrame"?Li.createFromState(i,e,t):e.type==="Empty"?ho.createFromState(i,e):e.type==="PointLight"?hs.createFromState(i,e,t):e.type==="SpotLight"?ps.createFromState(i,e,t):e.type==="DirectionalLight"?ds.createFromState(i,e,t):Yo.is(e.type)?Tr.createFromState(i,e):(console.error(e),new ho)}function Uw(i,e){e.uniforms[`f${e.id}_transmissionSamplerMap`].value=i.texture,e.uniforms[`f${e.id}_transmissionDepthMap`].value=i.depthTexture}function Wf(i,e,t){if(!t.userData.layers)return!1;let r=!1,o=t.userData.layers.getLayersOfType(Le.TRANSMISSION);return o.length>0?(e.layers.set(3),r=!0,i!==void 0&&o.forEach(s=>Uw(i,s))):e.layers.set(0),r}function $f(i,e){let t=!1;return e.traverseEntity(r=>{if(r instanceof yt)if(Array.isArray(r.material))for(let o=0;o<r.material.length;o++)Wf(i,r,r.material[o])&&(t=!0);else Wf(i,r,r.material)&&(t=!0)}),t}function Kf(i,e){"material"in i&&Jw(i.material,e),"geometry"in i&&i.geometry.dispose()}function Jw(i,e){Rc(i).forEach(t=>{e.isSharedMaterial(t)||t.dispose()})}var Zf=new Ww,Ic=class extends da(qw){constructor(e,t){super();this.objectType="Scene";this.alpha=1;this.backupFog=new $w(16777215,.1,2e3);this.fogUseBGColor=!1;this.wireframeState=!1;this.needsTransmissionDirty=!0;this._needsTransmission=!1;this._color=new Xf(1,0,0);this.bgColor=new Xf(1,1,1);this.entityByUuid={};this.postprocessing=new Ea,this.ambientLight=new Hw(13882323,8553090,.75),this.ambientLight.name="Default Ambient Light",this.personalCamera=this.createPersonalCamera(),this.activeCamera=this.personalCamera,this.init(e,t)}needsTransmission(e){return this.needsTransmissionDirty&&(this._needsTransmission=$f(e,this),e!==void 0&&(this.needsTransmissionDirty=!1)),this._needsTransmission}find(e){if(e===""||e===void 0)return;let t=this.entityByUuid[e];return t===void 0?this.getObjectByProperty("uuid",e):t}get color(){return this._color}set color(e){this.fogUseBGColor===!0&&this.backupFog.color.copy(e),this._color.copy(e)}get enableFog(){return this.fog!==null}set enableFog(e){this.fog=e===!0?this.backupFog:null}init(e,t){if(this.initPostprocessing(e.postprocessing),this.createChildrenObjects(e.objects,this,t),this.personalCamera.removeFromParent(),this.add(this.personalCamera),this.ambientLight.removeFromParent(),this.add(this.ambientLight),this.setBackgroundColor(et(e.backgroundColor,t)),this.updateFog(e.fog,t),this.updateAmbientLight(e.environment.ambientLight,t),this.activeCamera=this.personalCamera,e.publish.playCamera!==null){let r=this.find(e.publish.playCamera);r instanceof Tr&&this.switchActiveCamera(r)}}initPostprocessing(e){let o=e,{enabled:t}=o,r=Ec(o,["enabled"]);for(let s of Object.entries(r)){let n=s[1],a=this.postprocessing.effects.get(s[0]);if(a){a.enabled=n.enabled;for(let[l,c]of Object.entries(n))a[l]=c}}this.postprocessing.enabled=t,this.postprocessing.reinit()}clearScene(e){this.traverseEntity(t=>{Kf(t,e)});for(let t of this.children)tr(t)&&t.removeFromParent()}resetAfterClear(e,t){this.init(e,t)}createPersonalCamera(){let e=Tr.createFromState(Ic.PERSONAL_CAMERA_ID,q(P({},zn.defaultData),{name:"personal"}));return e.enableHelper=!1,e.objectHelper.visible=!1,delete e.isEntity,this.registerObjectCreatedInLegacy(e),e}raycast(e){let t=[],r=o=>{for(let s of o.children)tr(s)&&!s.raycastLock&&s.visible&&((na(s)||Rr(s)&&s.enableHelper&&s.objectHelper.parent)&&e.intersectObject(s,!1,t),r(s))};return r(this),t}traverseEntity(e){for(let t of this.children)tr(t)&&t.traverseEntity(e)}updateFog(e,t){this.enableFog=e.enabled,this.fogUseBGColor=e.useBackgroundColor,e.useBackgroundColor?this.backupFog.color.set(this.bgColor):this.backupFog.color=et(e.color,t),this.backupFog.near=e.near,this.backupFog.far=e.far}toJSON(e){return{}}fromJSON(e){return this}dispose(){this.traverseEntity(e=>{"geometry"in e&&e.geometry.dispose(),"material"in e&&(e.material instanceof Array?e.material.forEach(t=>t.dispose()):e.material.dispose())}),this.postprocessing.dispose()}updateAmbientLight(e,t){Gu(this.ambientLight,e,t),e.groundColor!==void 0&&(this.ambientLight.groundColor=et(e.groundColor,t)),e.enabled!==void 0&&(this.ambientLight.visible=e.enabled)}switchActiveCamera(e){this.activeCamera!==this.personalCamera&&(this.activeCamera.enableHelper=!0),this.activeCamera=e,this.postprocessing.camera=e,e.enableHelper=!1}setBackgroundColor(e){this.bgColor=e,this.alpha=e.a}createChildrenObjects(e,t,r){for(let o of e)this.createChildObject(o.id,o.data,o.children,t,r)}registerObjectCreatedInLegacy(e){this.entityByUuid[e.uuid]=e}unregisterObject(e){delete this.entityByUuid[e.uuid];for(let t of e.children)this.unregisterObject(t)}createChildObject(e,t,r,o,s){let n=qf(e,t,s);return n&&(this.entityByUuid[e]=n,o.add(n),this.createChildrenObjects(r,n,s)),n}getCenter(e){let t=[];for(let o=0,s=e.length;o<s;++o){let{id:n,recursive:a}=e[o],l=this.find(n),c=a?l.recursiveBBox:l.singleBBox;t.push(...c.vertices)}let r=new Kw;return r.setFromPoints(t),r.getCenter(Zf),Zf}copyMatrixWorld(e,t){if(e===null){t.identity();return}let r=this.find(e);r?t.copy(r.matrixWorld):t.identity()}copyParentMatrixWorld(e,t){var o;if(e===null){t.identity();return}let r=(o=this.find(e))==null?void 0:o.parent;r?t.copy(r.matrixWorld):t.identity()}traverseMaterial(e){this.traverseEntity(t=>{if(t instanceof yt)if(Array.isArray(t.material))for(let r=0;r<t.material.length;r++)e(t.material[r]);else e(t.material)})}updateCanvasSize(e,t){this.activeCamera.setViewplaneSize(e,t);let r,o;e>=t?(r=t/e,o=1):(r=1,o=e/t),this.traverseMaterial(s=>{s.layersList.getLayersOfType(Le.TRANSMISSION).forEach(a=>{a.uniforms[`f${a.id}_aspectRatio`].value.x=r,a.uniforms[`f${a.id}_aspectRatio`].value.y=o})})}},Fa=Ic;Fa.PERSONAL_CAMERA_ID="f23858d0-4a3b-4bd8-8173-66ed0af7f6fb-personalCamera";import{WebGLRenderTarget as Xw,LinearMipmapLinearFilter as Zw,LinearFilter as Qw,ClampToEdgeWrapping as Qf,DepthTexture as Yw}from"three";var Yf=new Ct,Pc=class extends Jt{},Ac=class{constructor(e){this.materials={};this.images={};this.colors={};this.transmissionRenderTarget=new Xw(2048,2048,{generateMipmaps:!0,minFilter:Zw,magFilter:Qw,wrapS:Qf,wrapT:Qf}),this.transmissionRenderTarget.depthTexture=new Yw(2048,2048),this.reset(e)}reset(e){for(let[t,r]of Object.entries(e.images))this.addImage(t,r.data);for(let[t,r]of Object.entries(e.colors))this.addColor(t,r);for(let[t,r]of Object.entries(e.materials))this.addMaterial(t,vc(r,this))}get transmissionSamplerMap(){return this.transmissionRenderTarget.texture}get transmissionDepthMap(){return this.transmissionRenderTarget.depthTexture}addMaterial(e,t){t.uuid=e,this.materials[e]=t}deleteMaterial(e){this.materials[e]&&(this.materials[e].dispose(),delete this.materials[e])}isSharedMaterial(e){return e.uuid in this.materials||e===Yf}getMaterial(e){let t=this.materials[e];return t}getMaterialOrDeletedPlaceholder(e){var t;return(t=this.materials[e])!=null?t:Yf}getMaterials(){return this.materials}addImage(e,t){if(this.images[e])return this.images[e].onload=()=>{this.onImageLoad&&this.onImageLoad(e)},this.images[e].src=t,!0;{let r=new Image;return r.src=t,r.onload=()=>{this.onImageLoad&&this.onImageLoad(e)},this.images[e]=r,!1}}deleteImage(e){this.images[e]&&delete this.images[e]}getDefaultImage(){return this.images.image_0}getImage(e){return this.images[e]}getImages(){return this.images}addColor(e,t){return this.colors[e]?("a"in t?this.colors[e].setRGBA(t.r,t.g,t.b,t.a):this.colors[e].setRGBA(t.r,t.g,t.b,1),!0):("a"in t?this.colors[e]=new Pc(t.r,t.g,t.b,t.a):this.colors[e]=new Pc(t.r,t.g,t.b,1),!1)}updateColor(e,t){var r,o,s,n;if(this.colors[e]){let a=this.colors[e];return this.colors[e].r=(r=t.r)!=null?r:a.r,this.colors[e].g=(o=t.g)!=null?o:a.g,this.colors[e].b=(s=t.b)!=null?s:a.b,this.colors[e].a=(n=t.a)!=null?n:a.a,!0}return!1}deleteColor(e){this.colors[e]&&delete this.colors[e]}getColor(e){return this.colors[e]}dispose(){Object.keys(this.materials).forEach(t=>this.deleteMaterial(t)),this.transmissionRenderTarget.depthTexture.dispose(),this.transmissionRenderTarget.dispose(),this.onImageLoad=void 0}};var jc=class{constructor(e){this.sharedAssets=new Ac(e.shared),this.scene=new Fa(e.scene,this.sharedAssets)}reset(e,t){this.scene.clearScene(this.sharedAssets),this.sharedAssets.reset(e.shared),this.scene.resetAfterClear(e.scene,this.sharedAssets)}dispose(){this.scene.clearScene(this.sharedAssets),this.sharedAssets.dispose()}};var em=class extends t1{load(e,t,r,o=console.error){let s=new e1(this.manager);s.setPath(this.path),s.setResponseType("arraybuffer"),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(e,n=>{try{if(typeof n=="string")throw new Error("The .spline file is not binary!");t(this.parse(n))}catch(a){o(a)}},r,o)}parse(e){let t=Mn.deserialize(new Uint8Array(e));return new jc(t).scene}};export{em as default};
956
+ `),c&&u.push(c.code,`outgoingLight = spe_blend(outgoingLight, ${c.result}, 1.0, SPE_BLENDING_NORMAL);`),d?u.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${d.result} );`):u.push("gl_FragColor = vec4( outgoingLight, 1.0 );"),u.push("#include <encodings_fragment>","#include <fog_fragment>","#include <dithering_fragment>"),t=u.join(`
957
+ `)}return t}copy(e){return super.copy(e),e.color&&(this.color=e.color.clone()),this.roughness=e.roughness.clone(),this.metalness=e.metalness.clone(),e.position&&(this.position=e.position.clone()),e.afterColor&&(this.afterColor=e.afterColor.clone()),e.alpha&&(this.alpha=e.alpha.clone()),e.reflectivity&&(this.reflectivity=e.reflectivity.clone()),e.shadingAlpha&&(this.shadingAlpha=e.shadingAlpha.clone()),e.shadingBlend&&(this.shadingBlend=e.shadingBlend.clone()),this}};var rc=class extends rr{get color(){return this.fragment.color}set color(e){this.fragment.color=e}get afterColor(){return this.fragment.afterColor}set afterColor(e){this.fragment.afterColor=e}get alpha(){return this.fragment.alpha}set alpha(e){this.fragment.alpha=e}get shadingAlpha(){return this.fragment.shadingAlpha}set shadingAlpha(e){this.fragment.shadingAlpha=e}get shadingBlend(){return this.fragment.shadingBlend}set shadingBlend(e){this.fragment.shadingBlend=e}get position(){return this.fragment.position}set position(e){this.fragment.position=e}get roughness(){return this.fragment.roughness}set roughness(e){this.fragment.roughness=e}get metalness(){return this.fragment.metalness}set metalness(e){this.fragment.metalness=e}get reflectivity(){return this.fragment.reflectivity}set reflectivity(e){this.fragment.reflectivity=e}constructor(e=new tc,t){super(e,e,t);this.type="StandardNodeMaterial",this.fragment=e}};var nn=class extends rc{constructor(e,t,r){super(t,e);this.userData.type="PhysicalMaterial",this.userData.category="Physical",this.userData.layers=r!=null?r:this._getLayerStack(e==null?void 0:e.map)}get layersList(){return this.userData.layers}set layersList(e){this.userData.layers=e}equals(e){return this.userData.type===e.userData.type&&this.userData.layers.uuid==e.userData.layers.uuid}copy(e){if(e.userData.layers!==void 0&&e.userData.layers instanceof Pt){let t=e.userData.layers,r=e.fragment;super.copy(e);let o=r.clone();this.fragment=o,this.vertex=o;let n=t.clone(this);this.userData.layers=n,o.shadingAlpha.value=r.shadingAlpha.value,o.shadingBlend.value=r.shadingBlend.value}else super.copy(e);return this}static fromJSON(e,t,r){let o=r.getNode(t.vertex),n=new nn(void 0,o);return n.fromJSON(t,r),n}dispose(){super.dispose()}};import{Color as ic}from"three";import{Matrix3 as Kh,Texture as oc,Vector2 as sn,Vector3 as Mo,Vector4 as Xh}from"three";function Zh(i,e){switch(i.data.type){case"light":return dr(i);case"fresnel":return QS(i,e);case"gradient":return YS(i);case"depth":return ew(i);case"normal":return tw(i);case"noise":return rw(i,e);case"texture":return ow(i,e);case"rainbow":return iw(i);case"transmission":return nw(i,e);case"matcap":return sw(i,e);case"displace":return aw(i);case"color":default:return ZS(i,e)}}function Qh(i){return{type:i.data.type}}function dr(i){let{alpha:e,mode:t}=i.data;return $(O({},Qh(i)),{alpha:e,mode:t})}function ZS(i,e){return $(O({},dr(i)),{color:Ye(i.data.color,e)})}function QS(i,e){let{bias:t,scale:r,intensity:o,factor:n,color:s}=i.data;return $(O({},dr(i)),{color:Ye(s,e),bias:t,scale:r,intensity:o,factor:n})}function YS(i){let{gradientType:e,smooth:t,colors:r,steps:o,angle:n,offset:s,morph:a}=i.data;return $(O({},dr(i)),{gradientType:e,smooth:t,colors:r.map(l=>new Xh(l[0],l[1],l[2],l[3])),num:r.length,steps:o,offset:new sn(...s),morph:new sn(...a),angle:n})}function ew(i){let{gradientType:e,near:t,far:r,isVector:o,isWorldSpace:n,origin:s,direction:a,colors:l,steps:c,smooth:d,num:p}=i.data;return $(O({},dr(i)),{gradientType:e,near:t,far:r,isVector:o,isWorldSpace:n,origin:new Mo(...s),direction:a?new Mo(...a):new Mo(1,0,0),num:p,colors:l.map(u=>new Xh(u[0],u[1],u[2],u[3])),steps:c,smooth:d})}function tw(i){let{cnormal:e}=i.data;return $(O({},dr(i)),{cnormal:new Mo(e[0],e[1],e[2])})}function rw(i,e){let{data:t}=i;return $(O({},dr(i)),{scale:t.scale,move:t.move,fA:new sn(...t.fA),fB:new sn(...t.fB),distortion:new sn(...t.distortion),colorA:Ye(t.colorA,e),colorB:Ye(t.colorB,e),colorC:Ye(t.colorC,e),colorD:Ye(t.colorD,e),noiseType:t.noiseType})}function ow(i,e){let{projection:t,axis:r,crop:o,size:n}=i.data,{image:s,wrapping:a,repeat:l,offset:c}=i.data.texture,d=new oc,p;if(typeof s=="string")p=e==null?void 0:e.getImage(s);else{let u=new Image;u.src=s.data,u.onload=()=>{(e==null?void 0:e.onImageLoad)&&(e==null||e.onImageLoad(s.data))},p=u}return d.image=p,d.wrapS=d.wrapT=a,$(O({},dr(i)),{texture:d,mat:new Kh().setUvTransform(c[0],c[1],l[0],l[1],0,0,0),crop:o,projection:t,axis:["x","y","z"].indexOf(r),size:n})}function iw(i){let{data:e}=i;return $(O({},dr(i)),{filmThickness:e.filmThickness,movement:e.movement,wavelengths:new Mo(...e.wavelengths),noiseStrength:e.noiseStrength,noiseScale:e.noiseScale,offset:new Mo(...e.offset)})}function nw(i,e){let{data:t}=i;return $(O({},dr(i)),{thickness:t.thickness,ior:t.ior,roughness:t.roughness,transmissionSamplerMap:e.transmissionSamplerMap,transmissionDepthMap:e.transmissionDepthMap})}function sw(i,e){let t=new oc,{image:r}=i.data.texture,o;if(typeof r=="string")o=e==null?void 0:e.getImage(r);else{let s=new Image;s.src=r.data,s.onload=()=>{(e==null?void 0:e.onImageLoad)&&(e==null||e.onImageLoad(r.data))},o=s}t.image=o;let n=16777215;return $(O({},dr(i)),{color:n,texture:t})}function aw(i){let{data:e}=i,t=$(O({},Qh(i)),{intensity:e.intensity});if(e.displacementType==="noise")return $(O({},t),{offset:new Mo(...e.offset),scale:e.scale,movement:e.movement,noiseType:e.noiseType});{let r=new oc,o=new Kh().setUvTransform(0,0,1,1,0,0,0);return $(O({},t),{texture:r,mat:o,crop:e.crop})}}function Yh(i,e,t){if(t.type==="displace"&&(i==="intensity"||i==="visible")){let r=e.uniforms[`f${e.id}_intensity`];return r?(r.value=t.intensity*(t.visible?1:0),r):void 0}if(t.type!=="displace"&&(i==="alpha"||i==="visible")){let r=e.uniforms[`f${e.id}_alpha`];return r?(r.value=t.alpha*(t.visible?1:0),r):void 0}}import{Color as em,Vector4 as lw}from"three";var Si;(function(e){function i(t){return new em(t.x,t.y,t.z).getHex()}e.getHex=i})(Si||(Si={}));var tm;(function(e){function i(t){return new lw(t.r,t.g,t.b,t.a)}e.getThreeVector4=i})(tm||(tm={}));var rm;(function(t){function i(r,o){r.setRGB(o.r,o.g,o.b)}t.setThreeColor=i;function e(r){return new em(r.r,r.g,r.b).getHex()}t.getHex=e})(rm||(rm={}));function an(i,e){return typeof i=="string"?e.getMaterialOrDeletedPlaceholder(i):nc(i,e)}function om(i,e){return i.map(t=>an(t,e))}function nc(i,e){var s;let t=(s=i.layers)!=null?s:si.defaultTwoLayerData("phong").layers,r=cw(t),o;switch(r.category){case"basic":o=new Nt;break;case"lambert":{o=new rn;break}case"toon":{o=new on;break}case"physical":o=new nn;break;case"phong":default:{o=new or;break}}let n=o.userData.layers;dw(n);for(let a=t.length-1;a>=0;a--)pw(n,t[a],e);switch(r.category){case"basic":break;case"lambert":{let c=o,p=Ye(r.emissive,e);p instanceof ic?c.emissive.value=p:c.emissive.value.setHex(Si.getHex(p));break}case"toon":{let c=o,d=r;c.shininess.value=d.shininess;let p=Ye(d.specular,e);p instanceof ic?c.specular.value=p:c.specular.value.setHex(Si.getHex(p));break}case"physical":let a=o,l=r;a.metalness.value=l.metalness,a.roughness.value=l.roughness,a.reflectivity.value=l.reflectivity;break;case"phong":default:{let c=o,d=r;c.shininess.value=d.shininess;let p=Ye(d.specular,e);p instanceof ic?c.specular.value=p:c.specular.value.setHex(Si.getHex(p));break}}return n.blendColors(),n.blendAfterColors(),n.blendPositions(),o}function cw(i){for(let e of i)if(e.data.type==="light")return e.data;return{type:"light",category:"basic",visible:!0,alpha:1,mode:it.Normal}}function dw(i){for(let e of i.getLayers())i.removeLayer(e.id)}function pw(i,e,t){let r=Zh(e,t);r.type==="transmission"&&(r.transmissionSamplerMap=t==null?void 0:t.transmissionSamplerMap,r.transmissionDepthMap=t==null?void 0:t.transmissionDepthMap);let o=i.addLayer(r);o.uuid=e.id;for(let n in e.data)Yh(n,o,e.data)}import{Vector2 as im}from"three";var ga=new im,Po=class{constructor(e,t,r){this.message=[];this.endLine=!0;this.yLinePos=e,this.lineHeight=t,this.maxCharSize=r,this.nextChar3DPos=new im(0,this.yLinePos+this.maxCharSize*this.lineHeight),this.align=Tt.Left}addChar3D(e,t,r=this.message.length){this.message.splice(r,0,e),e.fontSize>this.maxCharSize?(this.maxCharSize=e.fontSize,this.nextChar3DPos.y=this.yLinePos+this.maxCharSize*this.lineHeight,this.fullUpdate(t)):(e.updatePosition(this.nextChar3DPos,t),this.nextChar3DPos.x+=e.charSize)}deleteChar3D(e=this.message.length-1){let t=this.message[e];if(t)return this.message.splice(e,1),this.nextChar3DPos.x-=t.charSize,t}isEndLine(e){this.endLine=e}fullUpdate(e,t=0){this.nextChar3DPos.x=0;for(let r=t,o=this.message.length;r<o;r+=1)this.message[r].updatePosition(this.nextChar3DPos,e),this.nextChar3DPos.x+=this.message[r].charSize}checkOverFlow(e){let t,r=this.message.length-1;if(r<=0)return!1;for(;r>=0;){if(this.message[r].char!==" "){t=this.message[r];break}r-=1}return!!(r>=0&&t&&t.localPosition.x+t.charSize>e)}containSpaceOverFlow(e=this.message.length-1){for(let t=e;t>=0;t-=1)if(this.message[t].char===" ")return!0;return!1}containSpace(e=this.message.length-1){if(this.endLine)return!0;for(let t=e;t>=0;t-=1)if(this.message[t].char===" ")return!0;return!1}popWord(e=this.message.length-1){let t=[],r=!0,o;for(o=e;o>=0;o-=1)if(this.message[o].char===" "){r=!1,t.length===0&&(o-=1,t.splice(0,0,this.message[o]));break}else t.splice(0,0,this.message[o]);return r?t=[]:this.message.splice(o+1,t.length),t}getWord(e=0,t=1){let r=[],o=e;for(o=e;;o+=t){if(!this.message[o]||this.message[o].char===" "){r.length===0&&this.message[o]&&(r.push(this.message[o]),this.message.splice(o,1));break}t>0?(r.push(this.message[o]),this.message.splice(o,1),o-=t):(r.splice(0,0,this.message[o]),this.message.splice(o,1))}return r}getWordAtIndex(e){let t=[];for(let r=e;r<this.message.length&&this.message[r].char!==" ";r++)t.push(this.message[r]);for(let r=e-1;r>=0&&this.message[r].char!==" ";r--)t.splice(0,0,this.message[r]);return t}wordSize(e=0,t=-1){let r=0,o=e;for(;o>=0&&o<this.message.length;){if(this.message[o].char===" "){r===0&&(r=this.message[o].charSize);break}r+=this.message[o].charSize,o+=t}return(o<0||o>=this.message.length)&&!this.endLine?this.message[e]?this.message[e].charSize:999999999:r===0?999999999:r}spaceLeft(e){return e-this.nextChar3DPos.x}popChar(e=this.message.length-1){return this.nextChar3DPos.x-=this.message[e].charSize,this.message.splice(e,1)}isEmpty(){return!this.message.length}updateNextCharPosY(){this.nextChar3DPos.y=this.yLinePos+this.maxCharSize*this.lineHeight}updateYLinePos(e){this.yLinePos=e,this.updateNextCharPosY()}updatelineHeight(e){this.lineHeight=e,this.updateNextCharPosY()}updateFontSize(e,t=0,r=this.message.length-1){for(let o=t;o<=r;o+=1)this.message[o].updateFontSize(e);this.maxCharSize=e,this.nextChar3DPos.y=this.yLinePos+this.maxCharSize*this.lineHeight}countSpaces(){let e=0;for(let t=0;t<this.message.length;t++)this.message[t].char===" "&&(e+=1);return e}alignText(e,t,r,o,n){switch(r){case Tt.Left:this.leftAlign(e,n);break;case Tt.Center:this.centerAlign(this.spaceLeft(t),e,n);break;case Tt.Right:this.rightAlign(this.spaceLeft(t),e,n);break;case Tt.Justify:this.justifyAlign(this.spaceLeft(t),e,n);break}}offsetCharacters(e,t,r){ga.set(t,r);let o=this.message.length;for(let n=0;n<o;n++)this.message[n].updatePosition(this.message[n].localPosition.add(ga),e)}leftAlign(e,t){this.align=Tt.Left,this.offsetCharacters(e,0,t)}centerAlign(e,t,r){this.align=Tt.Center,this.offsetCharacters(t,e/2,r)}rightAlign(e,t,r){this.align=Tt.Right,this.offsetCharacters(t,e,r)}justifyAlign(e,t,r){if(this.align=Tt.Justify,this.endLine){this.offsetCharacters(t,0,r);return}let o=this.countSpaces();if(o===0){this.offsetCharacters(t,0,r);return}let n=e/o,s=0;for(let a=0;a<this.message.length;a++)this.message[a].char===" "&&(s+=n),ga.set(s,r),this.message[a].updatePosition(this.message[a].localPosition.add(ga),t)}clone(){let e=new Po(this.yLinePos,this.lineHeight,this.maxCharSize);e.nextChar3DPos=this.nextChar3DPos.clone(),e.align=this.align,e.endLine=this.endLine;for(let t=0;t<this.message.length;t++)e.message.push(this.message[t].clone());return e}};import{DoubleSide as uw,EventDispatcher as hw,Matrix3 as mw,Vector3 as sc}from"three";var fw=new sc(0,0,1),nm=new sc,sm=new sc,am=new mw,Oo=class extends yt{constructor(e=mt.create({}),t=new Nt({side:uw})){super(e,t);this.recursiveSelection=!1;this.objectType="VectorObject";this.eventDispatcher=new hw;this._onShapeUpdate=()=>{if(this.geometry instanceof No){if(this.geometry.updateFromShape()){let e=this.geometry.drawCount,t=this.geometry.userData;this.updateGeometry(Object.assign(this.geometry.userData,{parameters:Object.assign(t.parameters,{surfaceMaxCount:e+1e3})}))}}else this.updateGeometry({});this.geometry.computeBoundingSphere(),this.geometry.computeBoundingBox()};var r;this.castShadow=!0,this.receiveShadow=!0,this.forceComputeSize=!0,this.shape=e.userData.shape,(r=this.shape.eventDispatcher)==null||r.addEventListener("update",this._onShapeUpdate)}toJSON(e){let t=super.toJSON(e);return t.object.objectType="VectorObject",t}fromState(e){return super.fromState(e),this.shape.update(),this}setHelperVisibility(){}updateGeometry(e){if(super.updateGeometry(e),"userData"in this.geometry){let t=this.geometry.userData.parameters;this.eventDispatcher.dispatchEvent({type:"geometryUpdate",parameters:t})}}setShape(e){var t,r;this.shape&&((t=this.shape.eventDispatcher)==null||t.removeEventListener("update",this._onShapeUpdate)),this.shape=e,(r=this.shape.eventDispatcher)==null||r.addEventListener("update",this._onShapeUpdate)}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),am.getNormalMatrix(this.matrixWorld),nm.copy(fw).applyMatrix3(am).normalize(),sm.setFromMatrixPosition(this.matrixWorld),this.shape.plane.setFromNormalAndCoplanarPoint(nm,sm)}clone(e){let t=this.shape.clone(),r=this.material.clone(),o=this.geometry.userData,n=mt.create(Object.assign({},o,{shape:t})),s=new Oo(n,r).copy(this,e);return s.shape=t,t.update(),s}raycast(e,t){yt.prototype.raycast.call(this,e,t)}};import{Camera as Ow,OrthographicCamera as Aw,PerspectiveCamera as jw,Vector3 as Wt,Object3D as pm,Quaternion as _w}from"three";import{BoxBufferGeometry as yw}from"three";var Nr=i=>{var e;return e=class extends i{constructor(){super(...arguments);this.isObjectHelper=!0}},e.geometryHelper=new yw(30,30,30),e};import{Camera as vw,LineSegments as Sw,BufferGeometry as ww,LineBasicMaterial as Nw,Color as lc,Vector3 as Cw,Float32BufferAttribute as cm}from"three";import{Ray as gw,Sphere as xw,Matrix4 as bw,Vector3 as Ur}from"three";var xa=new gw,ac=new xw,lm=new bw,Cr=(i,e,t,r,o=!1)=>{let n=e,s=i.matrixWorld;if(n.boundingSphere===null&&n.computeBoundingSphere(),ac.copy(n.boundingSphere),ac.applyMatrix4(s),t.ray.intersectsSphere(ac)===!1||(lm.copy(s).invert(),xa.copy(t.ray).applyMatrix4(lm),n.boundingBox!==null&&xa.intersectsBox(n.boundingBox)===!1))return;let a,l,c,d,p=n.index,u=n.attributes.position,f=n.drawRange,m,x;if(o===!1){let N=Math.max(0,f.start),L=Math.min(p.count,f.start+f.count);for(m=N,x=L;m<x;m+=3)if(l=p.getX(m),c=p.getX(m+1),d=p.getX(m+2),a=y(i,t,xa,u,l,c,d),a){a.faceIndex=Math.floor(m/3),r.push(a);return}}else{let L=n.attributes.position,w=new Ur,B=new Ur,S=new Ur,_=new Ur,T=2,I=1/((i.scale.x+i.scale.y+i.scale.z)/3),b=I*I,P=Math.max(0,f.start),v=Math.min(L.count,f.start+f.count);for(let D=P,Z=v-1;D<Z;D+=T){if(w.fromBufferAttribute(L,D),B.fromBufferAttribute(L,D+1),xa.distanceSqToSegment(w,B,_,S)>b)continue;_.applyMatrix4(i.matrixWorld);let ie=t.ray.origin.distanceTo(_);ie<t.near||ie>t.far||r.push({distance:ie,point:S.clone().applyMatrix4(i.matrixWorld),object:i})}}function y(N,L,w,B,S,_,T){let h=new Ur,I=new Ur,b=new Ur,P=new Ur,v=new Ur;if(h.fromBufferAttribute(B,S),I.fromBufferAttribute(B,_),b.fromBufferAttribute(B,T),w.intersectTriangle(h,I,b,!1,P)===null)return null;v.copy(P),v.applyMatrix4(N.matrixWorld);let Z=L.ray.origin.distanceTo(v);return Z<L.near||Z>L.far?null:{faceIndex:1,distance:Z,point:v.clone(),object:N}}};var ba=new Cw,ir=new vw,dm=class extends Sw{constructor(e){let t=new ww,r=new Nw({color:16777215,vertexColors:!0,toneMapped:!1}),o=[],n=[],s={},a=new lc(Ya),l=new lc(Ya),c=new lc(bu);d("n1","n2",a),d("n2","n4",a),d("n4","n3",a),d("n3","n1",a),d("f1","f2",a),d("f2","f4",a),d("f4","f3",a),d("f3","f1",a),d("n1","f1",a),d("n2","f2",a),d("n3","f3",a),d("n4","f4",a),d("p","n1",l),d("p","n2",l),d("p","n3",l),d("p","n4",l),d("u1","u2",c),d("u2","u3",c),d("u3","u1",c);function d(u,f,m){p(u,m),p(f,m)}function p(u,f){o.push(0,0,0),n.push(f.r,f.g,f.b),s[u]===void 0&&(s[u]=[]),s[u].push(o.length/3-1)}t.setAttribute("position",new cm(o,3)),t.setAttribute("color",new cm(n,3));super(t,r);this.type="CameraHelper",this.camera=e,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=s,this.update()}update(){let e=this.geometry,t=this.pointMap,r=!0;ir.projectionMatrixInverse.elements=[.5112609807824982,-0,-0,-0,-0,.41421356237309503,-0,-0,-0,-0,-0,-.099999,-0,-0,-1.0000000000000002,.100001];let o=1,n=1,s=r?.8:1e-4;pr("n1",t,e,ir,-o,-n,s),pr("n2",t,e,ir,o,-n,s),pr("n3",t,e,ir,-o,n,s),pr("n4",t,e,ir,o,n,s);let a=s;pr("f1",t,e,ir,-o,-n,a),pr("f2",t,e,ir,o,-n,a),pr("f3",t,e,ir,-o,n,a),pr("f4",t,e,ir,o,n,a);let l=a,c=.5;pr("u1",t,e,ir,o*.7*c,n*1.1,l),pr("u2",t,e,ir,-o*.7*c,n*1.1,l),pr("u3",t,e,ir,0,n*(1.1+.9*c),l),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};function pr(i,e,t,r,o,n,s){ba.set(o,n,s).unproject(r);let a=e[i];if(a!==void 0){let l=t.getAttribute("position");for(let c=0,d=a.length;c<d;c++)l.setXYZ(a[c],ba.x,ba.y,ba.z)}}var cc=class extends Nr(dm){constructor(e){super(e);this.object=e;this.object=e,this.name=`CombinedCameraHelper: ${e.uuid}`}updateMatrixWorld(e){super.updateMatrixWorld(e),this.updateTarget()}updateTarget(){let e=this.object.getTarget();this.updateWorldMatrix(!0,!1),this.worldToLocal(e)}raycast(e,t){Cr(this.object,this.geometry,e,t,!0)}};import{DirectionalLightHelper as Lw}from"three";var ln=class extends Nr(Lw){constructor(e,t=15,r=10066329){super(e,t,r);this.object=e;this.name=`DirectionalLightHelper: ${e.uuid}`}raycast(e,t){Cr(this.object,ln.geometryHelper,e,t)}};import{AxesHelper as Tw}from"three";var cn=class extends Nr(Tw){constructor(e,t=15){super(t);this.object=e;this.object.updateMatrixWorld(),this.name=`EmptyObjectHelper: ${e.uuid}`,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1}raycast(e,t){Cr(this.object,cn.geometryHelper,e,t)}update(){}};import{PointLightHelper as Iw}from"three";var dn=class extends Nr(Iw){constructor(e,t=15,r=6710886){super(e,t,r);this.object=e;this.name=`PointLightHelper: ${e.uuid}`}raycast(e,t){Cr(this.object,dn.geometryHelper,e,t)}};import{SpotLightHelper as Mw,Vector3 as Pw}from"three";var Sa=class extends Nr(Mw){constructor(e,t=6710886){super(e,t);this.object=e;this.name=`SpotLightHelper: ${e.uuid}`}raycast(e,t){Cr(this.object,Sa.geometryHelper,e,t)}update(){if(this.object!==void 0){let e=Sa._vector,t=this.object.distance?this.object.distance:1e3,r=t*Math.tan(this.object.angle);this.cone.scale.set(r,r,t),e.setFromMatrixPosition(this.object.target.matrixWorld),this.cone.lookAt(e);let o=this.color!==void 0?this.color:this.light.color;if(this.cone.material instanceof Array)for(let n=0,s=this.cone.material.length;n<s;n++)this.cone.material[n].color.set(o);else this.cone.material.color.set(o)}}},va=Sa;va._vector=new Pw;var Lr=(i,e)=>class extends i{constructor(){super(...arguments);this.objectHelper=new e(this);this.enableHelper=!1}set visibility(r){this.visible=r,this.setHelperVisibility(r),this.setHelperChildrenVisibility(r)}get visibility(){return this.visible}get geometryHelper(){return e.geometryHelper}setHelperVisibility(r){this.objectHelper.visible=r}setHelperChildrenVisibility(r){for(let o of this.children)er(o)&&o.traverseEntity(n=>{Er(n)&&n.visible&&(n.objectHelper.visible=r)})}raycast(r,o){this.objectHelper.raycast(r,o)}copy(r,o=!0){return super.copy(r,o),r.enableHelper!==void 0&&(this.enableHelper=r.enableHelper),r.objectHelper!==void 0&&(this.objectHelper.visible=r.objectHelper.visible),this}toJSON(r){let o=super.toJSON(r),n=o.object;return n.enableHelper=this.enableHelper,o}fromJSON(r){return super.fromJSON(r),r.enableHelper!==void 0&&(this.enableHelper=!0),this}fromLightState(r,o){if(this.objectType==="LightDirectional"||this.objectType==="LightPoint"||this.objectType==="LightSpot"){let n=this;r.color!==void 0&&(n.color=Ye(r.color,o)),r.intensity!==void 0&&(n.intensity=r.intensity),r.depth!==void 0&&(n.shadow.camera.far=r.depth,n.shadow.needsUpdate=!0),r.shadows!==void 0&&(this.castShadow=r.shadows),r.helper!==void 0&&(this.enableHelper=r.helper,n.gizmos.shadowmap.visible=r.helper)}return this}};var wi=new Wt,dc=new Wt,lo=class extends Lr(tr(Ow),cc){constructor(e=window.innerWidth,t=window.innerHeight,r=45,o,n=1e5){super();this.objectType="CombinedCamera";this._cameraType="OrthographicCamera";this.targetOffset=xo.DefaultTargetOffset;this.isUpVectorFlipped=!1;this.angleOffsetFromUp=0;this.width=e,this.height=t,this.orthoCamera=new Aw(e*-.5,e*.5,t*.5,t*-.5,o!=null?o:-5e4,n),this.perspCamera=new jw(r,e/t,o!=null?o:50,n),this.left=this.orthoCamera.left,this.right=this.orthoCamera.right,this.top=this.orthoCamera.top,this.bottom=this.orthoCamera.bottom,this.far=this.orthoCamera.far,this.view=this.orthoCamera.view,this.aspect=this.perspCamera.aspect,this.fov=this.perspCamera.fov,this.focus=this.perspCamera.focus,this.filmGauge=this.perspCamera.filmGauge,this.filmOffset=this.perspCamera.filmOffset,this.toOrthographic(!0)}static createFromState(e,t){let r=new lo().fromState(t);return r.enableHelper=!0,r.objectHelper.update(),r.uuid=e,r}get isPerspectiveCamera(){return this.cameraType==="PerspectiveCamera"}get isOrthographicCamera(){return!this.isPerspectiveCamera}get cameraType(){return this._cameraType}setNear(e,t){e==="PerspectiveCamera"?this.perspCamera.near=t:this.orthoCamera.near=t}setZoom(e,t){t>=0&&(e==="PerspectiveCamera"?this.perspCamera.zoom=t:this.orthoCamera.zoom=t)}set cameraType(e){e==="PerspectiveCamera"?this.toPerspective():e==="OrthographicCamera"&&this.toOrthographic()}get near(){return this._cameraType==="PerspectiveCamera"?this.perspCamera.near:this.orthoCamera.near}set near(e){this._cameraType==="PerspectiveCamera"?this.perspCamera.near=e:this.orthoCamera.near=e}get zoom(){return this._cameraType==="PerspectiveCamera"?this.perspCamera.zoom:this.orthoCamera.zoom}set zoom(e){e>=0&&(this._cameraType==="PerspectiveCamera"?this.perspCamera.zoom=e:this.orthoCamera.zoom=e)}lookAt(e){super.lookAt(e),this.getWorldPosition(wi),this.targetOffset=wi.distanceTo(e)}getTarget(e=new Wt){return this.getWorldDirection(dc),this.getWorldPosition(wi),dc.multiplyScalar(this.targetOffset),e.copy(wi).add(dc),e}getDistanceToTarget(){let e=this.getTarget();return this.getWorldPosition(wi),wi.distanceTo(e)}updateUp(){let e=this.getWorldQuaternion(new _w),t=new Wt(0,0,1).applyQuaternion(e),r=new Wt().copy(pm.DefaultUp);this.isUpVectorFlipped&&r.negate(),r.applyQuaternion(e);let o=new Wt().copy(pm.DefaultUp).projectOnPlane(t),n=new Wt().crossVectors(o,r).dot(t)>=0?1:-1;this.angleOffsetFromUp=o.angleTo(r)*n}getViewFrontToObject(e){let t=e.getWorldPosition(new Wt),o=e.getWorldDirection(new Wt).multiplyScalar(this.targetOffset);return{position:t.clone().add(o),target:t}}getViewToObject(e){let t=e.getWorldPosition(new Wt),o=this.getWorldDirection(new Wt).multiplyScalar(this.targetOffset);return{position:t.clone().sub(o),target:t}}setViewplaneSize(e,t){this.left=-e*.5,this.right=e*.5,this.top=t*.5,this.bottom=-t*.5,this.aspect=e/t,this.updateProjectionMatrix()}toOrthographic(e){this.orthoCamera.left=this.left,this.orthoCamera.right=this.right,this.orthoCamera.top=this.top,this.orthoCamera.bottom=this.bottom,this.orthoCamera.view=this.view,this.orthoCamera.far=this.far,this.orthoCamera.updateProjectionMatrix(),this.projectionMatrix=this.orthoCamera.projectionMatrix,this.projectionMatrixInverse=this.orthoCamera.projectionMatrixInverse,this._cameraType="OrthographicCamera",(this.enableHelper===!0||e===!0)&&this.objectHelper.update()}toPerspective(e){this.perspCamera.aspect=this.aspect,this.perspCamera.fov=this.fov,this.perspCamera.view=this.view,this.perspCamera.far=this.far,this.perspCamera.updateProjectionMatrix(),this.projectionMatrix=this.perspCamera.projectionMatrix,this.projectionMatrixInverse=this.perspCamera.projectionMatrixInverse,this._cameraType="PerspectiveCamera",(this.enableHelper===!0||e===!0)&&this.objectHelper.update()}setFocalLength(e){this.perspCamera.setFocalLength(e),this.toPerspective()}getFocalLength(){return this.perspCamera.getFocalLength()}getEffectiveFOV(){return this.perspCamera.getEffectiveFOV()}getFilmWidth(){return this.perspCamera.getFilmWidth()}getFilmHeight(){return this.perspCamera.getFilmHeight()}setViewOffset(e,t,r,o,n,s){this._cameraType==="PerspectiveCamera"?this.perspCamera.setViewOffset(e,t,r,o,n,s):this.orthoCamera.setViewOffset(e,t,r,o,n,s)}clearViewOffset(){this._cameraType==="PerspectiveCamera"?(this.perspCamera.clearViewOffset(),this.toPerspective()):(this.orthoCamera.clearViewOffset(),this.toOrthographic())}updateProjectionMatrix(e){this._cameraType==="PerspectiveCamera"?this.toPerspective(e):this._cameraType==="OrthographicCamera"&&this.toOrthographic(e)}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}copy(e,t){return super.copy(e,t),this.orthoCamera.copy(e.orthoCamera),this.perspCamera.copy(e.perspCamera),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.far=e.far,this.view=e.view===null?null:Object.assign({},e.view),this._cameraType=e._cameraType,this.aspect=e.aspect,this.fov=e.fov,this.focus=e.focus,this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this.targetOffset=e.targetOffset,this.updateProjectionMatrix(),this}fromCameraRender(e){let t={near:this.orthoCamera.near,far:this.orthoCamera.far},r={near:this.perspCamera.near,far:this.perspCamera.far};return this.copy(e),this.name="",this.enableHelper=!0,this.objectHelper.visible=!0,this.orthoCamera.near=t.near,this.orthoCamera.far=t.far,this.perspCamera.near=r.near,this.perspCamera.far=r.far,this.updateProjectionMatrix(),this}toJSON(e){let t=super.toJSON(e),r=t.object;return r.objectType="CombinedCamera",r.cameraType=this.cameraType,r.targetOffset=this.targetOffset,r.isUpVectorFlipped=this.isUpVectorFlipped,r.angleOffsetFromUp=this.angleOffsetFromUp,r.left=this.left,r.right=this.right,r.top=this.top,r.bottom=this.bottom,this.view!==null&&(r.view=Object.assign({},this.view)),r.zoomOrtho=this.orthoCamera.zoom,r.nearOrtho=this.orthoCamera.near,r.far=this.far,r.aspect=this.aspect,r.fov=this.fov,r.focus=this.focus,r.filmGauge=this.filmGauge,r.filmOffset=this.filmOffset,r.zoomPersp=this.perspCamera.zoom,r.nearPersp=this.perspCamera.near,t}fromJSON(e){var t;if(super.fromJSON(e),this.cameraType=e.cameraType,e.targetOffset!==void 0&&(this.targetOffset=e.targetOffset),e.orbitControlsTarget!==void 0){let r=this.getWorldPosition(new Wt),o=new Wt().fromArray(e.orbitControlsTarget);this.targetOffset=o.distanceTo(r)}else e.targetOffset!==void 0&&(this.targetOffset=e.targetOffset);return this.isUpVectorFlipped=!1,this.angleOffsetFromUp=(t=e.angleOffsetFromUp)!=null?t:0,e.left!==void 0&&(this.left=e.left),e.right!==void 0&&(this.right=e.right),e.top!==void 0&&(this.top=e.top),e.bottom!==void 0&&(this.bottom=e.bottom),e.view!==void 0&&(this.view=Object.assign({},e.view)),e.zoomOrtho!==void 0&&(this.orthoCamera.zoom=e.zoomOrtho),e.nearOrtho!==void 0&&(this.orthoCamera.near=e.nearOrtho),e.far!==void 0&&(this.far=e.far),e.aspect!==void 0&&(this.aspect=e.aspect),e.fov!==void 0&&(this.fov=e.fov),e.focus!==void 0&&(this.focus=e.focus),e.filmGauge!==void 0&&(this.filmGauge=e.filmGauge),e.filmOffset!==void 0&&(this.filmOffset=e.filmOffset),e.zoomPersp!==void 0&&(this.perspCamera.zoom=e.zoomPersp),e.nearPersp!==void 0&&(this.perspCamera.near=e.nearPersp),this.updateProjectionMatrix(),this}toCameraState(e=[]){let t={type:this.cameraType,far:this.far,orthographic:{near:this.orthoCamera.near,zoom:this.orthoCamera.zoom},perspective:{near:this.perspCamera.near,fov:this.perspCamera.fov,zoom:this.perspCamera.zoom},up:this.up.toArray(),targetOffset:this.targetOffset,isUpVectorFlipped:this.isUpVectorFlipped};return Zo(t,e)}fromCameraState(e){let{orthographic:t,perspective:r}=e;return e.type!==void 0&&(this.cameraType=e.type),e.far!==void 0&&(this.far=e.far),t!==void 0&&(t.near!==void 0&&(this.orthoCamera.near=t.near),t.zoom!==void 0&&(this.orthoCamera.zoom=t.zoom)),r!==void 0&&(r.near!==void 0&&(this.perspCamera.near=r.near),r.fov!==void 0&&(this.perspCamera.fov=r.fov),r.zoom!==void 0&&(this.perspCamera.zoom=r.zoom)),e.up!==void 0&&this.up.fromArray(e.up),e.targetOffset!==void 0&&(this.targetOffset=e.targetOffset),e.isUpVectorFlipped!==void 0&&(this.isUpVectorFlipped=e.isUpVectorFlipped),this.updateProjectionMatrix(),this}toState(e){return $(O(O({},super.toState(e)),this.toCameraState(e)),{type:this.cameraType})}fromState(e){return super.fromState(e),this.fromCameraState(e),this}};import{Group as Dw}from"three";var co=class extends Lr(tr(Dw),cn){constructor(){super(...arguments);this.objectType="EmptyObject"}static createFromState(e,t){let r=new co().fromState(t);return r.uuid=e,r.enableHelper=!0,r.objectHelper.update(),r}toJSON(e){let t=super.toJSON(e);return t.object.objectType="EmptyObject",t}};import{DirectionalLight as Bw,CameraHelper as wa}from"three";var pn=class extends Lr(tr(Bw),ln){constructor(...e){super(...e);this.objectType="LightDirectional";this._gizmos={};this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024;let r=this.shadow.camera;r.top=1250,r.bottom=-1250,r.right=1250,r.left=-1250,r.near=1,r.far=2500;let o=new wa(this.shadow.camera);o.visible=!1,this._gizmos.shadowmap=o,this.update()}static createFromState(e,t,r){let o=new pn().fromState(t,r);return o.uuid=e,o}get gizmos(){return this._gizmos}showGizmos(){for(let e in this._gizmos){let t=this._gizmos[e];t instanceof wa&&(t.visible=!0)}}hideGizmos(){for(let e in this._gizmos){let t=this._gizmos[e];t instanceof wa&&(t.visible=!1)}}update(){this.shadow.camera.updateProjectionMatrix();for(let e in this._gizmos){let t=this._gizmos[e];t instanceof wa&&t.update()}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.enableHelper===!0&&this.objectHelper.visible===!0&&this.objectHelper.update()}copy(e,t=!0){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}toJSON(e){let t=super.toJSON(e),r=t.object;return r.objectType="LightDirectional",r.color=this.color.getHex(),r.intensity=this.intensity,r.shadow=this.shadow.toJSON(),t}fromJSON(e){var o;super.fromJSON(e),this.color.set(e.color),this.intensity=e.intensity,this.shadow.normalBias=(o=e.shadow.normalBias)!=null?o:0,this.shadow.radius=e.shadow.radius,this.shadow.mapSize.fromArray(e.shadow.mapSize);let t=this.shadow.camera,r=e.shadow.camera;return t.near=r.near,t.far=r.far,t.zoom=r.zoom,t.left=r.left,t.right=r.right,t.top=r.top,t.bottom=r.bottom,r.view!==void 0&&(t.view=Object.assign({},r.view)),this}fromDirectionalLightState(e,t){let r=e.depth!==void 0&&e.depth!==this.shadow.camera.far||e.size!==void 0&&e.size/2!==this.shadow.camera.right;return super.fromLightState(e,t),e.size!==void 0&&Nh(this,e.size),r&&this.update(),this}fromState(e,t){return super.fromState(e),this.fromDirectionalLightState(e,t),this}};import{PointLight as Gw,Vector3 as Na,Box3 as zw,Box3Helper as Ca,Color as Ew}from"three";var un=class extends Lr(tr(Gw),dn){constructor(...e){super(...e);this.objectType="LightPoint";this._gizmos={};this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024;let r=this.shadow.camera;r.fov=90,r.aspect=1,r.near=100,r.far=2500;let o=new Na(-r.far+this.position.x,-r.far+this.position.y,-r.far+this.position.z),n=new Na(r.far+this.position.x,r.far+this.position.y,r.far+this.position.z),s=new zw(o,n),a=new Ca(s,new Ew(16755200));a.visible=!1,this._gizmos.shadowmap=a,this.update()}static createFromState(e,t,r){let o=new un().fromState(t,r);return o.uuid=e,o}get gizmos(){return this._gizmos}showGizmos(){for(let e in this._gizmos){let t=this._gizmos[e];t instanceof Ca&&(t.visible=!0)}}hideGizmos(){for(let e in this._gizmos){let t=this._gizmos[e];t instanceof Ca&&(t.visible=!1)}}update(){if(this.shadow&&(this.shadow.camera.updateProjectionMatrix(),this._gizmos))for(let e in this._gizmos){let t=this._gizmos[e];if(t instanceof Ca){let r=this.shadow.camera,o=new Na(-r.far+this.position.x,-r.far+this.position.y,-r.far+this.position.z),n=new Na(r.far+this.position.x,r.far+this.position.y,r.far+this.position.z);t.box.set(o,n),t.updateMatrixWorld(!0)}}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.enableHelper===!0&&this.objectHelper.visible===!0&&this.objectHelper.update()}copy(e,t=!0){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}toJSON(e){let t=super.toJSON(e),r=t.object;return r.objectType="LightPoint",r.color=this.color.getHex(),r.intensity=this.intensity,r.distance=this.distance,r.decay=this.decay,r.shadow=this.shadow.toJSON(),t}fromJSON(e){var o,n;super.fromJSON(e),this.color.set(e.color),this.intensity=e.intensity,this.distance=e.distance,this.decay=e.decay,this.shadow.normalBias=(o=e.shadow.normalBias)!=null?o:0,this.shadow.radius=e.shadow.radius,this.shadow.mapSize.fromArray((n=e.shadow.mapSize)!=null?n:[512,512]),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null);let t=this.shadow.camera,r=e.shadow.camera;return t.near=r.near,t.far=r.far,t.zoom=r.zoom,t.fov=r.fov,t.focus=r.focus,t.aspect=r.aspect,t.filmGauge=r.filmGauge,t.filmOffset=r.filmOffset,r.view!==void 0&&(t.view=Object.assign({},r.view)),this}fromPointLightState(e,t){return super.fromLightState(e,t),e.distance!==void 0&&(this.distance=e.distance),e.decay!==void 0&&(this.decay=e.decay),e.shadowRadius!==void 0&&(this.shadow.radius=e.shadowRadius),e.shadowResolution!==void 0&&(this.shadow.mapSize.set(e.shadowResolution,e.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null)),this}fromState(e,t){return super.fromState(e),this.fromPointLightState(e,t),this}};import{SpotLight as Fw,CameraHelper as La,MathUtils as Rw,Vector3 as um,Quaternion as Vw}from"three";var hm=new um,mm=new um,fm=new Vw,hn=class extends Lr(tr(Fw),va){constructor(...e){super(...e);this.objectType="LightSpot";this._gizmos={};this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024;let r=this.shadow.camera;r.fov=Rw.RAD2DEG*2*this.angle,r.aspect=1,r.near=100,r.far=2500;let o=new La(this.shadow.camera);o.visible=!1,this._gizmos.shadowmap=o,this.update()}static createFromState(e,t,r){let o=new hn().fromState(t,r);return o.uuid=e,o}get gizmos(){return this._gizmos}showGizmos(){for(let e in this._gizmos){let t=this._gizmos[e];t instanceof La&&(t.visible=!0)}}hideGizmos(){for(let e in this._gizmos){let t=this._gizmos[e];t instanceof La&&(t.visible=!1)}}update(){this.shadow.camera.updateProjectionMatrix();for(let e in this._gizmos){let t=this._gizmos[e];t instanceof La&&t.update()}}updateMatrixWorld(e){super.updateMatrixWorld(e),mm.setFromMatrixPosition(this.matrixWorld),fm.setFromRotationMatrix(this.matrixWorld),hm.copy(this.up).applyQuaternion(fm).negate().multiplyScalar(this.distance),this.target.position.copy(mm).add(hm),this.target.updateMatrixWorld(),this.enableHelper===!0&&this.objectHelper.visible===!0&&this.objectHelper.update()}copy(e,t=!0){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}toJSON(e){let t=super.toJSON(e),r=t.object;return r.objectType="LightSpot",r.color=this.color.getHex(),r.intensity=this.intensity,r.distance=this.distance,r.angle=this.angle,r.decay=this.decay,r.penumbra=this.penumbra,r.shadow=this.shadow.toJSON(),t}fromJSON(e){var o;super.fromJSON(e),this.color.set(e.color),this.intensity=e.intensity,this.distance=e.distance,this.angle=e.angle,this.decay=e.decay,this.penumbra=e.penumbra,this.shadow.normalBias=(o=e.shadow.normalBias)!=null?o:0,this.shadow.radius=e.shadow.radius,this.shadow.mapSize.fromArray(e.shadow.mapSize);let t=this.shadow.camera,r=e.shadow.camera;return t.near=r.near,t.far=r.far,t.zoom=r.zoom,t.fov=r.fov,t.focus=r.focus,t.aspect=r.aspect,t.filmGauge=r.filmGauge,t.filmOffset=r.filmOffset,r.view!==void 0&&(t.view=Object.assign({},r.view)),this}fromSpotLightState(e,t){return super.fromLightState(e,t),e.distance!==void 0&&(this.distance=e.distance),e.decay!==void 0&&(this.decay=e.decay),e.angle!==void 0&&(this.angle=e.angle),e.penumbra!==void 0&&(this.penumbra=e.penumbra),this}fromState(e,t){return super.fromState(e),this.fromSpotLightState(e,t),this}};import{VideoTexture as Uw}from"three";var ym=i=>i.tagName==="VIDEO",Ni=class{static resize(e,t,r){let o=e/t,n;if(!r.image)return;let s=r.image;ym(s)?n=s.videoWidth/s.videoHeight:n=s.width/s.height,o>n&&(r.imageType=="WEBCAM"?r.repeat.set(-1,1*n/o):r.repeat.set(1,1*n/o)),o<n&&(r.imageType=="WEBCAM"?r.repeat.set(1*o/n*-1,1):r.repeat.set(1*o/n,1)),o==n&&(r.imageType=="WEBCAM"?r.repeat.set(-1,1):r.repeat.set(1,1))}static resizeTextureLayer(e,t,r){let o=e/t,n=r.image!==void 0?r.image.width/r.image.height:1,s;o>n?s={x:1,y:n/o}:o<n?s={x:o/n,y:1}:s={x:1,y:1},r.repeat.set(s.x,s.y),r.updateMatrix()}static resizeTextureLayers(e,t,r){let o=r.userData.layers,n=o.getLayers();for(let s=0;s<n.length;s++){let a=n[s];Hh(a)&&(Ni.resizeTextureLayer(e,t,a.uniforms[`f${a.id}_texture`].value),o.updateLayerUniform())}}static resizeComplex(e,t,r,o){let n=e/t,s,a=r.image;ym(a)?s=a.videoWidth/a.videoHeight:s=a.width/a.height,o.geometry.type.includes("Shape")?(n>s&&(r.imageType=="WEBCAM"?r.repeat.set(1/e*-1,1/t*s/n):r.repeat.set(1/e,1/t*s/n)),n<s&&(r.imageType=="WEBCAM"?r.repeat.set(1/e*n/s*-1,1/t):r.repeat.set(1/e*n/s,1/t)),n==s&&(r.imageType=="WEBCAM"?r.repeat.set(1/e*-1,1/t):r.repeat.set(1/e,1/t))):(n>s&&(r.imageType=="WEBCAM"?r.repeat.set(-1,1*s/n):r.repeat.set(1,1*s/n)),n<s&&(r.imageType=="WEBCAM"?r.repeat.set(1*n/s*-1,1):r.repeat.set(1*n/s,1)),n==s&&(r.imageType=="WEBCAM"?r.repeat.set(-1,1):r.repeat.set(1,1)))}};var mn=class extends yt{constructor(e,t=new Nt){super(e,t);this.objectType="Mesh2D";this.castShadow=!0,this.receiveShadow=!0}updateGeometry(e){super.updateGeometry(e),this.material.userData.layers&&Ni.resizeTextureLayers(this.geometry.userData.parameters.width,this.geometry.userData.parameters.height,this.material)}resizeGeometry(e,t){super.resizeGeometry(e,t,0),this.material.userData.layers&&Ni.resizeTextureLayers(this.geometry.userData.parameters.width,this.geometry.userData.parameters.height,this.material)}toJSON(e){let t=super.toJSON(e);return t.object.objectType="Mesh2D",t}clone(){let e=super.clone();return e.updateGeometry({}),e}static fromTexture(e){let t,r;if(e instanceof Uw){let s=e.image;t=s.videoWidth*.5,r=s.videoHeight*.5}else{let s=e.image;t=s.width*.5,r=s.height*.5}let o=Ws.create({parameters:{width:t,height:r}}),n=new Nt;return n.layersList.changeLayer(0,{type:Le.TEXTURE,texture:e}),n.layersList.moveLayer(0,1),n.dispose(),new mn(o,n)}};var fn=class extends yt{constructor(e,t=new or){super(e,t);this.objectType="Mesh3D";this.castShadow=!0,this.receiveShadow=!0}toJSON(e){let t=super.toJSON(e);return t.object.objectType="Mesh3D",t}};var yn=class extends fn{constructor(e,t=new or){super(e,t);this.objectType="NonParametric"}toJSON(e){let t=super.toJSON(e);return t.object.objectType="NonParametric",t}};var gn;(function(t){t[t.TO_RIGHT=1]="TO_RIGHT",t[t.TO_LEFT=-1]="TO_LEFT"})(gn||(gn={}));var pc=class extends yt{constructor(e,t=new Nt({transparent:!0,opacity:1,visible:!1,side:Ta})){super(e,t);this.objectType="TextFrame";this.charContainer=new kw,this.add(this.charContainer),this.material.visible=!1,this._geometryUserData=e.userData,this.userData.textFrame={hexColor:null,opacity:1,visible:!0,text:"",fontSize:16,lineHeight:1.5,letterSpacing:1,fontFamily:"roboto_regular",textTransform:eo.None,horizontalAlignment:1,verticalAlignment:Br.Top,LOD:16,maxLineSize:this._geometryUserData.parameters.width,textOrigin:new xm(this._geometryUserData.parameters.width*-.5,this._geometryUserData.parameters.height*.5,0),textLines:[]},this.createTextLine()}static createFromState(e,t,r){let o=$s.create({parameters:{width:t.width,height:t.height}}),n=new pc(o).fromState(t,r);return n.uuid=e,n}async updateText(e){this.clearText();let t=this.userData.textFrame,r=t.fontFamily;await _t.loadFont(r),t.text=e;let o=t.textOrigin,n=new gm({visible:t.visible,transparent:!0,side:Ta}),s=e.split(`
958
+ `),a=0;this.userData.textFrame.textLines=s.map((l,c)=>{let d=new Po(a,t.lineHeight,t.fontSize);return d.message=l.split("").map(p=>{let u={char:p,fontFamily:r,letterSpacing:t.letterSpacing,fontSize:t.fontSize,LOD:16},f=n.clone();f.color=t.hexColor,f.opacity=t.opacity;let m=new _t(u,f);return d.addChar3D(m,o),this.charContainer.add(m),m}),a+=d.maxCharSize*d.lineHeight,d}),this.textFullUpdate(),this.checkOverFlow()}clearText(){let e=this.userData.textFrame.textLines;for(;this.charContainer.children.length;){let t=this.charContainer.children[0];this.charContainer.remove(t)}for(;e.length;)e.pop()}raycast(e,t){let r=[];if(super.raycast(e,r),r.length>0){t.push(r[0]);return}let o=[];for(let n=0,s=this.charContainer.children.length;n<s;++n)if(this.charContainer.children[n]instanceof _t&&(e.intersectObject(this.charContainer.children[n],!1,o),o.length>0)){o[0].object=this,t.push(o[0]);return}}updateGeometry(e){var c,d,p,u;let t=this.userData,r=this.geometry.userData,o=r.parameters.width,n=r.parameters.height,s=(d=(c=e.parameters)==null?void 0:c.width)!=null?d:o,a=(u=(p=e.parameters)==null?void 0:p.height)!=null?u:n,l=t.textFrame;super.updateGeometry(e),l.maxLineSize=s,l.textOrigin.set(-.5*s,.5*a,0),a!==n?(this.checkOverFlow(),this.checkCapacity()):s!==o&&(o<s?this.checkCapacity():o>s&&this.checkOverFlow())}checkOverFlow(e=0){let t=this.userData,r=t.textFrame.textOrigin,o=t.textFrame.textLines;for(let n=e;n<o.length;n++){o[n].updateYLinePos(this.getNewLinePosition(n)),o[n].fullUpdate(r);let s=[];for(;o[n].checkOverFlow(t.textFrame.maxLineSize);)o[n].containSpaceOverFlow()?s.unshift(o[n].getWord(o[n].message.length-1,-1)):s.unshift(o[n].popChar());if(s.length>0){o[n+1]===void 0?(o[n].isEndLine(!1),this.createTextLine()):o[n].endLine&&(this.createTextLine(n+1),o[n].isEndLine(!1),o[n+1].isEndLine(!0));let a=0;for(let l=0;l<s.length;l+=1)for(let c=0;c<s[l].length;c+=1)o[n+1].addChar3D(s[l][c],r,a),a+=1;o[n+1].fullUpdate(r)}o[n].fullUpdate(r)}this.textFullUpdate(e)}checkCapacity(e=0){let t=this.userData,r=t.textFrame.textOrigin,o=t.textFrame.maxLineSize,n=t.textFrame.textLines;for(let s=e;s<n.length;s+=1)if(n[s].updateYLinePos(this.getNewLinePosition(s)),n[s].fullUpdate(r),!!n[s-1])for(;!n[s-1].endLine;){let a,l=n[s-1].spaceLeft(o);if(n[s].wordSize(0,1)<=l){n[s].containSpace()?a=n[s].getWord(0,1):a=n[s].popChar(0);for(let c=0;c<a.length;c+=1)a[c]&&n[s-1].addChar3D(a[c],r)}else{n[s].isEmpty()?(n[s].endLine&&n[s-1].isEndLine(!0),n.splice(s,1),s-=1):(n[s].updateYLinePos(this.getNewLinePosition(s)),n[s].fullUpdate(r));break}}this.textFullUpdate(e)}createTextLine(e=this.userData.textFrame.textLines.length){let r=this.userData.textFrame;r.textLines.splice(e,0,new Po(this.getNewLinePosition(e),r.lineHeight,r.fontSize))}textFullUpdate(e=0){let r=this.userData.textFrame,o=r.textLines,n=this.getVerticalAlignmentOffSet();for(let s=e;s<o.length;s++)o[s].updateYLinePos(this.getNewLinePosition(s)),o[s].fullUpdate(r.textOrigin),o[s].alignText(r.textOrigin,r.maxLineSize,r.horizontalAlignment,r.verticalAlignment,n)}getVerticalAlignmentOffSet(){switch(this.userData.textFrame.verticalAlignment){case Br.Top:return 0;case Br.Center:return this.getRemainingVerticalSpace()/2;case Br.Bottom:return this.getRemainingVerticalSpace();default:return 0}}getRemainingVerticalSpace(){let t=this.userData.textFrame.textLines;return this.geometry.userData.parameters.height-this.getNewLinePosition(t.length)}getNewLinePosition(e){let r=this.userData.textFrame.textLines,o=0;for(let n=0;n<e;n+=1)o+=r[n].maxCharSize*r[n].lineHeight;return o}updateColor(e){var o;let t=this.userData;t.textFrame.hexColor=e;let r=t.textFrame.textLines;for(let n=0;n<r.length;n++){let s=r[n].message;for(let a=0;a<s.length;a++){let l=s[a].material;((o=l.color)==null?void 0:o.isColor)&&(l.color=e)}}}updateOpacity(e){let t=this.userData;t.textFrame.opacity=e;let r=t.textFrame.textLines;for(let o=0;o<r.length;o++){let n=r[o].message;for(let s=0;s<n.length;s++){let a=n[s].material;a.opacity=e}}}updateVisible(e){let t=this.userData;t.textFrame.visible=e;let r=t.textFrame.textLines;for(let o=0;o<r.length;o++){let n=r[o].message;for(let s=0;s<n.length;s++){let a=n[s].material;a.visible=e}}}async updateFontFamily(e){await _t.loadFont(e);let r=this.userData.textFrame,o=r.textLines;r.fontFamily=e;for(let n=0;n<o.length;n++){let s=o[n].message;for(let a=0;a<s.length;a++)s[a].updateFontFamily(e)}this.textFullUpdate(),this.checkOverFlow(),this.checkCapacity()}updateFontSize(e){let r=this.userData.textFrame,o=r.textLines,n=r.fontSize;r.fontSize=e;for(let s=0;s<o.length;s++)o[s].updateFontSize(e);this.textFullUpdate(),e>n?this.checkOverFlow():e<n&&this.checkCapacity()}async updateTextTransform(e){let r=this.userData.textFrame;await _t.loadFont(r.fontFamily);let o=r.textLines;switch(r.textTransform=e,e){case eo.Upper:for(let n=0;n<o.length;n++){let s=o[n].message;for(let a=0;a<s.length;a++)o[n].message[a].updateChar(s[a].char.toUpperCase())}break;case eo.Lower:for(let n=0;n<o.length;n++){let s=o[n].message;for(let a=0;a<s.length;a++)o[n].message[a].updateChar(s[a].char.toLowerCase())}break;default:for(let n=0;n<o.length;n++){let s=o[n].message;for(let a=0;a<s.length;a++)o[n].message[a].updateChar(s[a].originalChar)}}this.textFullUpdate(),this.checkOverFlow(),this.checkCapacity()}updateLetterSpacing(e){let t=this.userData,r=t.textFrame.textLines;t.textFrame.letterSpacing=e;for(let o=0;o<r.length;o++){let n=r[o].message;for(let s=0;s<n.length;s++)n[s].updateLetterSpacing(e)}this.textFullUpdate(),this.checkOverFlow(),this.checkCapacity()}updateLOD(e){let t=this.userData;t.textFrame.LOD=e;let r=t.textFrame.textLines;for(let o=0;o<r.length;o++);this.textFullUpdate(),this.checkOverFlow(),this.checkCapacity()}updateLineHeight(e){let t=this.userData,r=t.textFrame.textLines;t.textFrame.lineHeight=e;for(let o=0;o<r.length;o++)r[o].updatelineHeight(e);this.textFullUpdate()}updateVerticalAlignment(e){let t=this.userData;t.textFrame.verticalAlignment=e,this.textFullUpdate()}updateHorizontalAlignment(e){let t=this.userData;t.textFrame.horizontalAlignment=e,this.textFullUpdate()}toJSON(e){let t=super.toJSON(e),r=t.object;r.objectType="TextFrame";let n=this.userData.textFrame.textLines.map(s=>{let a=s.message.map(l=>({char:l.char,originalChar:l.originalChar,fontFamily:l.fontFamily,letterSpacing:l.letterSpacing,fontSize:l.fontSize,LOD:l.LOD}));return{align:s.align,endLine:s.endLine,lineHeight:s.lineHeight,maxCharSize:s.maxCharSize,yLinePos:s.yLinePos,message:a}});return r.userData.textFrame.textLinesData=n,t}async fromJSONasync(e){if(super.fromJSON(e),e.userData!==void 0){let t=e.userData.textFrame;await _t.loadFont(t.fontFamily),t.textOrigin=new xm(t.textOrigin.x,t.textOrigin.y,t.textOrigin.z);let r=new gm({color:t.hexColor,opacity:t.opacity,visible:t.visible,transparent:!0,side:Ta});t.textLinesData&&(t.textLines=t.textLinesData.map((o,n)=>{let s=new Po(Number(o.yLinePos),Number(o.lineHeight),Number(o.maxCharSize)),a=o.message.map((l,c)=>{if(l.char===void 0){let u=t.textLines[n].message[c];if("geometries"in u){let f=u.geometries[0].userData.parameters;Object.assign(l,{LOD:f.lod,char:f.char,fontFamily:f.fontFamily,fontSize:f.fontSize,letterSpacing:f.letterSpacing,originalChar:f.char})}}let d={char:l.char,fontFamily:l.fontFamily,letterSpacing:Number(l.letterSpacing),fontSize:Number(l.fontSize),LOD:l.LOD},p=new _t(d,r.clone());return s.addChar3D(p,t.textOrigin),this.charContainer.add(p),p});return s.message=a,s}),this.userData.textFrame=t),this.textFullUpdate()}return this}fromTextFrameData(e,t){if(e.color!==void 0){let r=Ye(e.color,t);this.updateColor(r),this.updateOpacity(r.a)}e.alpha!==void 0&&this.updateOpacity(e.alpha),e.font!==void 0&&this.updateFontFamily(e.font),e.horizontalAlign!==void 0&&this.updateHorizontalAlignment(e.horizontalAlign),e.verticalAlign!==void 0&&this.updateVerticalAlignment(e.verticalAlign),e.textTransform!==void 0&&this.updateTextTransform(e.textTransform),e.fontSize!==void 0&&this.updateFontSize(e.fontSize),e.lineHeight!==void 0&&this.updateLineHeight(e.lineHeight),e.letterSpacing!==void 0&&this.updateLetterSpacing(e.letterSpacing),e.text!==void 0&&e.text!==""&&this.updateText(e.text),(e.width!==void 0||e.height!==void 0)&&this.updateGeometry({parameters:{width:e.width,height:e.height}})}fromState(e,t){return super.fromState(e),this.fromTextFrameData(e,t),this}convertToVector(){let{fontFamily:e,hexColor:t}=this.userData.textFrame,r=new co;r.name="Text Shape";let o=_t.fontCache[e];for(let n of this.charContainer.children)n instanceof _t&&o.generateShapes(n.char,1).forEach(s=>{let a=new Pe().fromShape(s);a.applyScale(n.scale.x,n.scale.y);let l=mt.create({shape:a}),c=new Nt({side:Ta});c.color=t;let d=new Oo(l,c);d.name=n.char,d.position.copy(n.position),d.rotation.copy(n.rotation),r.attach(d)});return r}},Ci=pc;Ci.VerticalAlign=Br,Ci.HorizontalAlign=Tt,Ci.TextTransform=eo;import{HemisphereLight as i1,Scene as n1,Vector3 as s1,Color as jm,Fog as a1,Box3 as l1}from"three";import{BufferGeometryLoader as Hw}from"three";function bm(i,e){return qw(i)}function qw(i){let e={parameters:i,type:i.type};if(i.type==="VectorGeometry"){let r=Pe.createFromState(i.shape,i.width,i.height);e.shape=r}else i.type==="NonParametricGeometry"&&(i.data.groups&&i.data.groups.forEach(r=>{var o;return r.materialIndex=Math.max((o=r.materialIndex)!=null?o:0,0)}),e.geometry=new Hw().parse(i));let t;try{t=Ji(e)}catch(r){console.error(r)}if(!t){let r=Pe.createFromState(ai.defaultData(),100,100);e.shape=r,t=Ji(e)}return t}import{Box3 as Ww,Matrix4 as Ao,Sphere as wm,Vector3 as $w}from"three";var Nm=wc(Sm());var uc;Js.then(i=>{uc=i});var Cm=new Ao,Jw=new Ao,Kw=new Ao,ur=new Ww,po=new $w,Xw=new Ao,Zw=new Ao,xn=class extends yt{constructor(e,t,r,o=new or){super(r!=null?r:t,o);this.subdivPointer=e;this.originalGeometry=t;this.subdividedGeometry=r;this.objectType="SubdivObject";this.hiddenMatrixOld=new Ao;this.smoothShading=!0;this.matrixWorldRigid=new Ao;this.castShadow=!0,this.receiveShadow=!0,this.forceComputeSize=!1}static createFromState(e,t,r){let{subdivPointer:o,originalGeometry:n,subdividedGeometry:s}=kt.build(t.geometry,void 0,void 0,!t.flatShading),a=an(t.material,r),l=new xn(o,n,s||void 0,a);return l.calcBoundingBox(),l.freeSubdivPointer(),l.uuid=e,l.fromState(t),l}shallowClone(e){return new yn(this.geometry,this.material).shallowCopy(this,e)}toJSON(e){let t=super.toJSON(e);return t.object.objectType="SubdivObject",t}buildFromStore(e){var n,s,a;let{originalGeometry:t,subdividedGeometry:r,subdivPointer:o}=kt.build(e,this.subdivPointer,void 0,this.smoothShading,this.shearScale);if(this.subdivPointer=o,t!==void 0&&((n=this.originalGeometry)==null||n.dispose(),this.originalGeometry=t),r!==void 0&&((s=this.subdividedGeometry)==null||s.dispose(),this.subdividedGeometry=r!=null?r:void 0),this.geometry=(a=this.subdividedGeometry)!=null?a:this.originalGeometry,this.cloner)for(let l of this.cloner.children)l.geometry=this.geometry;e.width&&(this.geometry.userData.parameters={width:e.width,height:e.height,depth:e.depth})}updateMesh(e=!1){kt.buildLevel(this.subdivPointer,!0,this.smoothShading,this.originalGeometry,e?this.shearScaleInv:void 0),this.subdividedGeometry&&kt.buildLevel(this.subdivPointer,!1,this.smoothShading,this.subdividedGeometry,e?this.shearScaleInv:void 0)}updateTopology(){var e;this.originalGeometry.dispose(),this.originalGeometry=kt.buildLevel(this.subdivPointer,!0,this.smoothShading),this.subdividedGeometry&&(this.subdividedGeometry.dispose(),this.subdividedGeometry=kt.buildLevel(this.subdivPointer,!1,this.smoothShading)),this.geometry=(e=this.subdividedGeometry)!=null?e:this.originalGeometry}raycast(e,t){var r;this.geometry=this.originalGeometry,yt.prototype.raycast.call(this,e,t),this.geometry=(r=this.subdividedGeometry)!=null?r:this.originalGeometry}updateMatrixWorldSVD(){let e=this.matrixWorld.elements,t=[[e[0],e[4],e[8]],[e[1],e[5],e[9]],[e[2],e[6],e[10]]],{u:r,v:o,q:n}=(0,Nm.SVD)(t),s=Cm.set(r[0][0],r[0][1],r[0][2],0,r[1][0],r[1][1],r[1][2],0,r[2][0],r[2][1],r[2][2],0,0,0,0,1),a=Jw.set(o[0][0],o[0][1],o[0][2],0,o[1][0],o[1][1],o[1][2],0,o[2][0],o[2][1],o[2][2],0,0,0,0,1),l=Kw.copy(a).transpose();this.shearScale=Xw.makeScale(n[0],n[1],n[2]).multiply(l).premultiply(a),this.shearScaleInv=Zw.copy(this.shearScale).invert(),this.matrixWorldRigid.multiplyMatrices(s,l),n.every(c=>Math.abs(n[0]-c)<.01)&&(this.shearScale=void 0,this.shearScaleInv=void 0)}activateSVDCompensation(){this.shearScale!==void 0&&(this.matrixAutoUpdate=!1,this.matrix.copy(this.matrixWorldRigid).copyPosition(this.matrixWorld),this.hiddenMatrixOld.copy(this.hiddenMatrix),this.hiddenMatrix.copy(this.parent.matrixWorld).invert())}deactivateSVDCompensation(){this.shearScale!==void 0&&(this.shearScale=void 0,this.shearScaleInv=void 0,this.matrixAutoUpdate=!0,this.hiddenMatrix.copy(this.hiddenMatrixOld))}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new wm);let t=e.attributes.position,r=e.boundingSphere.center;ur.setFromBufferAttribute(t),ur.getCenter(r),e.boundingSphere.radius=r.distanceTo(ur.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),ur.getSize(po);let o={width:po.x,height:po.y,depth:po.z};return this.geometry.userData.parameters=o,o}updateBoundingBox(e){let t=this.originalGeometry;ur.min.set(e[0],e[2],e[4]),ur.max.set(e[1],e[3],e[5]),this.shearScaleInv&&(ur.min.applyMatrix4(this.shearScaleInv),ur.max.applyMatrix4(this.shearScaleInv)),t.boundingSphere===null&&(t.boundingSphere=new wm);let r=t.boundingSphere.center;ur.getCenter(r),t.boundingSphere.radius=r.distanceTo(ur.max),isNaN(t.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),ur.getSize(po);let o={width:po.x,height:po.y,depth:po.z};return this.geometry.userData.parameters=o,o}freeSubdivPointer(){this.subdivPointer&&(uc.free_bvh(this.subdivPointer),uc.free_subdivision_surface(this.subdivPointer),this.subdivPointer=0)}updateGeometry(e){this.geometry.userData.scale||(this.geometry.userData.scale=Array(3)),this.geometry.userData.scale[0]=this.geometry.userData.parameters.width===0?1:e.parameters.width/this.geometry.userData.parameters.width,this.geometry.userData.scale[1]=this.geometry.userData.parameters.height===0?1:e.parameters.height/this.geometry.userData.parameters.height,this.geometry.userData.scale[2]=this.geometry.userData.parameters.depth===0?1:e.parameters.depth/this.geometry.userData.parameters.depth,Lm(this.originalGeometry.attributes,...this.geometry.userData.scale),this.originalGeometry.attributes.position.needsUpdate=!0,this.originalGeometry.attributes.normal.needsUpdate=!0,this.subdividedGeometry&&(Lm(this.subdividedGeometry.attributes,...this.subdividedGeometry.userData.scale),this.subdividedGeometry.attributes.position.needsUpdate=!0,this.subdividedGeometry.attributes.normal.needsUpdate=!0),this.geometry.userData.parameters=O({},e.parameters)}};function Lm(i,e,t,r){let o=i.position.array,n=i.normal.array,s=Cm.makeScale(e,t,r).invert().elements,a,l,c;for(var d=0,p=o.length;d<p;d+=3)o[d]*=e,o[d+1]*=t,o[d+2]*=r,a=n[d],l=n[d+1],c=n[d+2],n[d]=s[0]*a+s[4]*l+s[8]*c,n[d+1]=s[1]*a+s[5]*l+s[9]*c,n[d+2]=s[2]*a+s[6]*l+s[10]*c}import{BackSide as Qw,DoubleSide as Yw,FrontSide as e1}from"three";function Tm(i,e){e.flatShading!==void 0&&(i.flatShading=e.flatShading,i.needsUpdate=!0),e.wireframe!==void 0&&(i.wireframe=e.wireframe),e.side!==void 0&&(e.side===oi.Front?i.side=e1:e.side===oi.Back?i.side=Qw:i.side=Yw)}function t1(i,e){if(Array.isArray(i.material))for(let t of i.material)Tm(t,e);else{let t=i.material;Tm(t,e)}i.objectType==="SubdivObject"&&e.flatShading!==void 0&&(i.material.flatShading=!1,i.smoothShading=!e.flatShading,i.updateMesh())}function Im(i,e,t){let r;if(e.geometry.type==="SubdivGeometry")r=xn.createFromState(i,e,t);else{let o=bm(e.geometry,t),n="materials"in e?om(e.materials,t):an(e.material,t);Ts.is2DParametricMesh(o.userData.type)?r=new mn(o,n):(o==null?void 0:o.userData.type)==="VectorGeometry"?r=new Oo(o,n):e.geometry.type==="NonParametricGeometry"?r=new yn(o,n):r=new fn(o,n),r.uuid=i,r.fromState(e)}return t1(r,e),r}function Mm(i,e,t){return e.type==="Mesh"?Im(i,e,t):e.type==="TextFrame"?Ci.createFromState(i,e,t):e.type==="Empty"?co.createFromState(i,e):e.type==="PointLight"?un.createFromState(i,e,t):e.type==="SpotLight"?hn.createFromState(i,e,t):e.type==="DirectionalLight"?pn.createFromState(i,e,t):Qo.is(e.type)?lo.createFromState(i,e):(console.error(e),new co)}function r1(i,e){e.uniforms[`f${e.id}_transmissionSamplerMap`].value=i.texture,e.uniforms[`f${e.id}_transmissionDepthMap`].value=i.depthTexture}function Pm(i,e,t){if(!t.userData.layers)return!1;let r=!1,o=t.userData.layers.getLayersOfType(Le.TRANSMISSION);return o.length>0?(e.layers.set(3),r=!0,i!==void 0&&o.forEach(n=>r1(i,n))):e.layers.set(0),r}function Om(i,e){let t=!1;return e.traverseEntity(r=>{if(r instanceof yt)if(Array.isArray(r.material))for(let o=0;o<r.material.length;o++)Pm(i,r,r.material[o])&&(t=!0);else Pm(i,r,r.material)&&(t=!0)}),t}function Am(i,e){"material"in i&&o1(i.material,e),"geometry"in i&&i.geometry.dispose()}function o1(i,e){Nc(i).forEach(t=>{e.isSharedMaterial(t)||t.dispose()})}var _m=new s1,hc=class extends ea(n1){constructor(e,t){super();this.objectType="Scene";this.alpha=1;this.backupFog=new a1(16777215,.1,2e3);this.fogUseBGColor=!1;this.wireframeState=!1;this.needsTransmissionDirty=!0;this._needsTransmission=!1;this._color=new jm(1,0,0);this.bgColor=new jm(1,1,1);this.entityByUuid={};this.ambientLight=new i1(13882323,8553090,.75),this.ambientLight.name="Default Ambient Light",this.personalCamera=this.createPersonalCamera(),this.activeCamera=this.personalCamera,this.sharedAssetManager=t,this.init(e,t)}needsTransmission(e){return this.needsTransmissionDirty&&(this._needsTransmission=Om(e,this),e!==void 0&&(this.needsTransmissionDirty=!1)),this._needsTransmission}find(e){if(e===""||e===void 0)return;let t=this.entityByUuid[e];return t===void 0?this.getObjectByProperty("uuid",e):t}get color(){return this._color}set color(e){this.fogUseBGColor===!0&&this.backupFog.color.copy(e),this._color.copy(e)}get enableFog(){return this.fog!==null}set enableFog(e){this.fog=e===!0?this.backupFog:null}init(e,t){if(this.createChildrenObjects(e.objects,this,t),this.personalCamera.removeFromParent(),this.add(this.personalCamera),this.ambientLight.removeFromParent(),this.add(this.ambientLight),this.setBackgroundColor(Ye(e.backgroundColor,t)),this.updateFog(e.fog,t),this.updateAmbientLight(e.environment.ambientLight,t),this.activeCamera=this.personalCamera,e.publish.playCamera!==null){let r=this.find(e.publish.playCamera);r instanceof lo&&this.switchActiveCamera(r)}}clearScene(e){this.traverseEntity(t=>{Am(t,e)});for(let t of this.children)er(t)&&t.removeFromParent()}resetAfterClear(e,t){this.init(e,t)}createPersonalCamera(){let e=lo.createFromState(hc.PERSONAL_CAMERA_ID,$(O({},Ms.defaultData),{name:"Personal Camera"}));return e.enableHelper=!1,e.objectHelper.visible=!1,delete e.isEntity,this.registerObjectCreatedInLegacy(e),e}raycast(e){let t=[],r=o=>{for(let n of o.children)er(n)&&!n.raycastLock&&n.visible&&((Xs(n)||Er(n)&&n.enableHelper&&n.objectHelper.parent)&&e.intersectObject(n,!1,t),r(n))};return r(this),t}traverseEntity(e){for(let t of this.children)er(t)&&t.traverseEntity(e)}updateFog(e,t){this.enableFog=e.enabled,this.fogUseBGColor=e.useBackgroundColor,e.useBackgroundColor?this.backupFog.color.set(this.bgColor):this.backupFog.color=Ye(e.color,t),this.backupFog.near=e.near,this.backupFog.far=e.far}toJSON(e){return{}}fromJSON(e){return this}dispose(){this.clearScene(this.sharedAssetManager),this.sharedAssetManager.dispose()}updateAmbientLight(e,t){wh(this.ambientLight,e,t),e.groundColor!==void 0&&(this.ambientLight.groundColor=Ye(e.groundColor,t)),e.enabled!==void 0&&(this.ambientLight.visible=e.enabled)}switchActiveCamera(e){this.activeCamera!==this.personalCamera&&(this.activeCamera.enableHelper=!0),this.activeCamera=e,e.enableHelper=!1}setBackgroundColor(e){this.bgColor=e,this.alpha=e.a}createChildrenObjects(e,t,r){for(let o of e)this.createChildObject(o.id,o.data,o.children,t,r)}registerObjectCreatedInLegacy(e){this.entityByUuid[e.uuid]=e}unregisterObject(e){delete this.entityByUuid[e.uuid];for(let t of e.children)this.unregisterObject(t)}createChildObject(e,t,r,o,n){let s=Mm(e,t,n);return s&&(this.entityByUuid[e]=s,o.add(s),this.createChildrenObjects(r,s,n)),s}getCenter(e){let t=[];for(let o=0,n=e.length;o<n;++o){let{id:s,recursive:a}=e[o],l=this.find(s),c=a?l.recursiveBBox:l.singleBBox;t.push(...c.vertices)}let r=new l1;return r.setFromPoints(t),r.getCenter(_m),_m}copyMatrixWorld(e,t){if(e===null){t.identity();return}let r=this.find(e);r?t.copy(r.matrixWorld):t.identity()}copyParentMatrixWorld(e,t){var o;if(e===null){t.identity();return}let r=(o=this.find(e))==null?void 0:o.parent;r?t.copy(r.matrixWorld):t.identity()}traverseMaterial(e){this.traverseEntity(t=>{if(t instanceof yt)if(Array.isArray(t.material))for(let r=0;r<t.material.length;r++)e(t.material[r]);else e(t.material)})}updateCanvasSize(e,t){this.activeCamera.setViewplaneSize(e,t);let r,o;e>=t?(r=t/e,o=1):(r=1,o=e/t),this.traverseMaterial(n=>{n.layersList.getLayersOfType(Le.TRANSMISSION).forEach(a=>{a.uniforms[`f${a.id}_aspectRatio`].value.x=r,a.uniforms[`f${a.id}_aspectRatio`].value.y=o})})}},Ma=hc;Ma.PERSONAL_CAMERA_ID="f23858d0-4a3b-4bd8-8173-66ed0af7f6fb-personalCamera";import{WebGLRenderTarget as c1,LinearMipmapLinearFilter as d1,LinearFilter as p1,ClampToEdgeWrapping as Dm,DepthTexture as u1}from"three";var Bm=new Nt,mc=class extends Ht{},fc=class{constructor(e){this.materials={};this.images={};this.colors={};this.transmissionRenderTarget=new c1(2048,2048,{generateMipmaps:!0,minFilter:d1,magFilter:p1,wrapS:Dm,wrapT:Dm}),this.transmissionRenderTarget.depthTexture=new u1(2048,2048),this.reset(e)}reset(e){for(let[t,r]of Object.entries(e.images))this.addImage(t,r.data);for(let[t,r]of Object.entries(e.colors))this.addColor(t,r);for(let[t,r]of Object.entries(e.materials))this.addMaterial(t,nc(r,this))}get transmissionSamplerMap(){return this.transmissionRenderTarget.texture}get transmissionDepthMap(){return this.transmissionRenderTarget.depthTexture}addMaterial(e,t){t.uuid=e,this.materials[e]=t}deleteMaterial(e){this.materials[e]&&(this.materials[e].dispose(),delete this.materials[e])}isSharedMaterial(e){return e.uuid in this.materials||e===Bm}getMaterial(e){let t=this.materials[e];return t}getMaterialOrDeletedPlaceholder(e){var t;return(t=this.materials[e])!=null?t:Bm}getMaterials(){return this.materials}addImage(e,t){if(this.images[e])return this.images[e].onload=()=>{this.onImageLoad&&this.onImageLoad(e)},this.images[e].src=t,!0;{let r=new Image;return r.src=t,r.onload=()=>{this.onImageLoad&&this.onImageLoad(e)},this.images[e]=r,!1}}deleteImage(e){this.images[e]&&delete this.images[e]}getDefaultImage(){return this.images.image_0}getImage(e){return this.images[e]}getImages(){return this.images}addColor(e,t){return this.colors[e]?("a"in t?this.colors[e].setRGBA(t.r,t.g,t.b,t.a):this.colors[e].setRGBA(t.r,t.g,t.b,1),!0):("a"in t?this.colors[e]=new mc(t.r,t.g,t.b,t.a):this.colors[e]=new mc(t.r,t.g,t.b,1),!1)}updateColor(e,t){var r,o,n,s;if(this.colors[e]){let a=this.colors[e];return this.colors[e].r=(r=t.r)!=null?r:a.r,this.colors[e].g=(o=t.g)!=null?o:a.g,this.colors[e].b=(n=t.b)!=null?n:a.b,this.colors[e].a=(s=t.a)!=null?s:a.a,!0}return!1}deleteColor(e){this.colors[e]&&delete this.colors[e]}getColor(e){return this.colors[e]}dispose(){Object.keys(this.materials).forEach(t=>this.deleteMaterial(t)),this.transmissionRenderTarget.depthTexture.dispose(),this.transmissionRenderTarget.dispose(),this.onImageLoad=void 0}};var Gm=class extends m1{load(e,t,r,o=console.error){let n=new h1(this.manager);n.setPath(this.path),n.setResponseType("arraybuffer"),n.setRequestHeader(this.requestHeader),n.setWithCredentials(this.withCredentials),n.load(e,s=>{try{if(typeof s=="string")throw new Error("The .spline file is not binary!");t(this.parse(s))}catch(a){o(a)}},r,o)}parse(e){let t=xs.deserialize(new Uint8Array(e)),r=new fc(t.shared);return new Ma(t.scene,r)}};export{Gm as default};