@splinetool/loader 0.9.19

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.
@@ -0,0 +1,961 @@
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 {
6
+ vec4 tl;
7
+ vec4 tr;
8
+ vec4 br;
9
+ vec4 bl;
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) {
12
+ vec3 absDirection = abs(direction);
13
+ float face = -1.0;
14
+ if (absDirection.x > absDirection.z) {
15
+ if (absDirection.x > absDirection.y)
16
+ face = direction.x > 0.0 ? 0.0 : 3.0;
17
+ else
18
+ face = direction.y > 0.0 ? 1.0 : 4.0;
19
+ } else {
20
+ if (absDirection.z > absDirection.y)
21
+ face = direction.z > 0.0 ? 2.0 : 5.0;
22
+ else
23
+ face = direction.y > 0.0 ? 1.0 : 4.0;
24
+ }
25
+ return face;
26
+ }`);n.useKeywords=!1;let a=new oe(`vec2 getUV(vec3 direction, float face) {
27
+ vec2 uv;
28
+ if (face == 0.0) {
29
+ uv = vec2(direction.z, direction.y) / abs(direction.x); // pos x
30
+ } else if (face == 1.0) {
31
+ uv = vec2(-direction.x, -direction.z) / abs(direction.y); // pos y
32
+ } else if (face == 2.0) {
33
+ uv = vec2(-direction.x, direction.y) / abs(direction.z); // pos z
34
+ } else if (face == 3.0) {
35
+ uv = vec2(-direction.z, direction.y) / abs(direction.x); // neg x
36
+ } else if (face == 4.0) {
37
+ uv = vec2(-direction.x, direction.z) / abs(direction.y); // neg y
38
+ } else {
39
+ uv = vec2(direction.x, direction.y) / abs(direction.z); // neg z
40
+ }
41
+ return 0.5 * (uv + 1.0);
42
+ }`);a.useKeywords=!1;let l=new oe(`TextureCubeUVData bilinearCubeUV(sampler2D envMap, vec3 direction, float mipInt) {
43
+ float face = getFace(direction);
44
+ float filterInt = max(cubeUV_minMipLevel - mipInt, 0.0);
45
+ mipInt = max(mipInt, cubeUV_minMipLevel);
46
+ float faceSize = exp2(mipInt);
47
+ float texelSize = 1.0 / (3.0 * cubeUV_maxTileSize);
48
+ vec2 uv = getUV(direction, face) * (faceSize - 1.0);
49
+ vec2 f = fract(uv);
50
+ uv += 0.5 - f;
51
+ if (face > 2.0) {
52
+ uv.y += faceSize;
53
+ face -= 3.0;
54
+ }
55
+ uv.x += face * faceSize;
56
+ if(mipInt < cubeUV_maxMipLevel){
57
+ uv.y += 2.0 * cubeUV_maxTileSize;
58
+ }
59
+ uv.y += filterInt * 2.0 * cubeUV_minTileSize;
60
+ uv.x += 3.0 * max(0.0, cubeUV_maxTileSize - 2.0 * faceSize);
61
+ uv *= texelSize;
62
+ vec4 tl = texture2D(envMap, uv);
63
+ uv.x += texelSize;
64
+ vec4 tr = texture2D(envMap, uv);
65
+ uv.y += texelSize;
66
+ vec4 br = texture2D(envMap, uv);
67
+ uv.x -= texelSize;
68
+ vec4 bl = texture2D(envMap, uv);
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) {
71
+ float mip = 0.0;
72
+ if (roughness >= r1) {
73
+ mip = (r0 - roughness) * (m1 - m0) / (r0 - r1) + m0;
74
+ } else if (roughness >= r4) {
75
+ mip = (r1 - roughness) * (m4 - m1) / (r1 - r4) + m1;
76
+ } else if (roughness >= r5) {
77
+ mip = (r4 - roughness) * (m5 - m4) / (r4 - r5) + m4;
78
+ } else if (roughness >= r6) {
79
+ mip = (r5 - roughness) * (m6 - m5) / (r5 - r6) + m5;
80
+ } else {
81
+ mip = -2.0 * log2(1.16 * roughness);// 1.16 = 1.79^0.25
82
+ }
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",`
86
+ // NOTE: Include Spline's blending modes. This could be part of BlendNode
87
+ #define SPE_BLENDING_NORMAL 0
88
+ #define SPE_BLENDING_MULTIPLY 1
89
+ #define SPE_BLENDING_SCREEN 2
90
+ #define SPE_BLENDING_OVERLAY 3
91
+
92
+ vec3 spe_normalBlend( vec3 a, vec3 b, float alpha ) {
93
+ return mix( a, b, alpha );
94
+ }
95
+
96
+ vec3 spe_multiplyBlend( vec3 a, vec3 b, float alpha ) {
97
+ return mix( a, a * b, alpha );
98
+ }
99
+
100
+ vec3 spe_screenBlend( vec3 a, vec3 b, float alpha ) {
101
+ vec3 tmp = 1.0 - ( 1.0 - a ) * ( 1.0 - b );
102
+ return mix( a, tmp, alpha );
103
+ }
104
+
105
+ vec3 spe_overlayBlend( vec3 a, vec3 b, float alpha ) {
106
+ vec3 tmp = mix( 1. - 2. * (1. - a) * (1. - b), 2. * a * b, step( a, vec3(.5) ) );
107
+ return clamp( mix( a, tmp, alpha ), 0.0, 1.0 );
108
+ }
109
+
110
+ vec3 spe_blend( vec3 a, vec3 b, float alpha, int mode ) {
111
+ if ( mode == SPE_BLENDING_NORMAL ) return spe_normalBlend( a, b, alpha );
112
+ else if ( mode == SPE_BLENDING_MULTIPLY ) return spe_multiplyBlend( a, b, alpha );
113
+ else if ( mode == SPE_BLENDING_SCREEN ) return spe_screenBlend( a, b, alpha );
114
+ else if ( mode == SPE_BLENDING_OVERLAY ) return spe_overlayBlend( a, b, alpha );
115
+ return vec3( 1.0 );
116
+ }
117
+ `,"#include <packing>","#include <common>"].join(`
118
+ `),this.parsCode={vertex:["float neighbor_offset = 0.0001;",""].join(`
119
+ `),fragment:["float accumAlpha = 0.0;",`void accumulateAlpha(float alpha) {
120
+ accumAlpha += (1.0 - accumAlpha) * alpha;
121
+ }`,""].join(`
122
+ `)},this.code={vertex:"",fragment:""},this.nodeCode={vertex:"",fragment:""},this.resultCode={vertex:"",fragment:""},this.finalCode={vertex:"",fragment:""},this.inputs={uniforms:{list:[],vertex:[],fragment:[]},arrayUniforms:{list:[],vertex:[],fragment:[]},vars:{varying:[],vertex:[],fragment:[]}},this.defines={},this.uniforms={},this.extensions={derivatives:!1,fragDepth:!1,drawBuffers:!1,shaderTextureLOD:!1},this.updaters=[],this.nodes=[],this.analyzing=!1}build(e,t){this.buildShader("vertex",e),this.buildShader("fragment",t);for(let r=0;r<this.requires.uv.length;r++)if(this.requires.uv[r]){let o=r>0?r+1:"";this.addVaryCode("varying vec2 vUv"+o+";"),r>0&&this.addVertexParsCode("attribute vec2 uv"+o+";"),this.addVertexFinalCode("vUv"+o+" = uv"+o+";")}return this.requires.color[0]&&(this.addVaryCode("varying vec4 vColor;"),this.addVertexParsCode("attribute vec4 color;"),this.addVertexFinalCode("vColor = color;")),this.requires.color[1]&&(this.addVaryCode("varying vec4 vColor2;"),this.addVertexParsCode("attribute vec4 color2;"),this.addVertexFinalCode("vColor2 = color2;")),this.requires.position&&(this.addVaryCode("varying vec3 vPosition;"),this.addVertexFinalCode("vPosition = transformed;")),this.requires.worldPosition&&(this.addVaryCode("varying vec3 vWPosition;"),this.addVertexFinalCode("vWPosition = ( modelMatrix * vec4( transformed, 1.0 ) ).xyz;")),this.requires.normal&&(this.addVaryCode("varying vec3 vObjectNormal;"),this.addVertexFinalCode("vObjectNormal = normal;")),this.requires.modelMatrix&&this.addFragmentParsCode("uniform mat4 modelMatrix;"),this.requires.viewMatrix&&this.addFragmentParsCode("uniform mat4 viewMatrix;"),this.requires.projectionMatrix&&this.addFragmentParsCode("uniform mat4 projectionMatrix;"),this.requires.worldNormal&&(this.addVaryCode("varying vec3 vWNormal;"),this.addVertexFinalCode("vWNormal = inverseTransformDirection( transformedNormal, viewMatrix ).xyz;")),this.requires.vWorldViewDir&&(this.addVaryCode("varying vec3 vWorldViewDir;"),this.addVertexFinalCode("vWorldViewDir = isPerspectiveMatrix( projectionMatrix ) ? ( (modelMatrix * vec4(position, 1.0)).xyz - cameraPosition ) : vec3( -viewMatrix[0][2], -viewMatrix[1][2], -viewMatrix[2][2] );")),this}buildShader(e,t){this.resultCode[e]=t.build(this.setShader(e),"v4")}setMaterial(e,t){return this.material=e,this.renderer=t,this.requires.lights=e.lights,this.requires.fog=e.fog,this.mergeDefines(e.defines),this}addFlow(e,t,r){return this.addSlot(e).addCache(t).addContext(r)}removeFlow(){return this.removeSlot().removeCache().removeContext()}addCache(e){return this.cache=e!=null?e:"",this.caches.push(this.cache),this}removeCache(){return this.caches.pop(),this.cache=this.caches[this.caches.length-1]||"",this}addContext(e){return this.context=Object.assign({},this.context,e),this.context.extra=this.context.extra||{},this.contexts.push(this.context),this}removeContext(){return this.contexts.pop(),this.context=this.contexts[this.contexts.length-1]||{},this}addSlot(e){return this.slot=e||"",this.slots.push(this.slot),this}removeSlot(){return this.slots.pop(),this.slot=this.slots[this.slots.length-1]||"",this}addFragmentVariable(e,t){this.fragmentVariables[e]===void 0&&(this.addFragmentCode(`${t} ${e};`),this.fragmentVariables[e]="")}addVertexCode(e){this.addCode(e,"vertex")}addFragmentCode(e){this.addCode(e,"fragment")}addCode(e,t){this.code[t!=null?t:this.shader]+=e+`
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
+ `}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
+ `}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}];
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(`
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
+
133
+ vec2 uvs = ( mat * vec3( (g${this.uuid.toString().replace(/-/g,"")}_vCustomUv * 2. - 1.) / (size * .5), 1. ) / 2. + 0.5 ).xy;
134
+
135
+ vec4 tmp = texture2D( tex, uvs );
136
+
137
+ vec3 col = tmp.rgb;
138
+ float lalpha = alpha * tmp.a;
139
+ if ( crop > 0.5 ) {
140
+ if ( uvs.x < 0.0 || uvs.x > 1.0 || uvs.y < 0.0 || uvs.y > 1.0 ) {
141
+ lalpha = 0.0;
142
+ }
143
+ }
144
+ calpha = lalpha / clamp( lalpha + accumAlpha, 0.00001, 1.0 );
145
+ accumAlpha += ( 1.0 - accumAlpha ) * lalpha;
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;
149
+ ${this.axis.value===0?`
150
+ float ${s}_u = (1. + (${s}_posN.z)) / 2.;
151
+ float ${s}_v = (1. + (${s}_posN.y)) / 2.;
152
+ `:""}
153
+
154
+ ${this.axis.value===1?`
155
+ float ${s}_u = (1. + (${s}_posN.x)) / 2.;
156
+ float ${s}_v = (1. - (${s}_posN.z)) / 2.;
157
+ `:""}
158
+
159
+ ${this.axis.value===2?`
160
+ float ${s}_u = (1. + (${s}_posN.x)) / 2.;
161
+ float ${s}_v = (1. + (${s}_posN.y)) / 2.;
162
+ `:""}
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(`
166
+ vec3 cylindricalTexture(sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec2 size, float alpha, int mode, out float calpha) {
167
+ vec3 posN = normalize(position);
168
+ float u = 0.5 + atan(posN.z, posN.x) / (2.*3.1415);
169
+ float scaledHeight = position.y / (size.y * 0.5);
170
+ float v = (scaledHeight / 2.) + .5;
171
+
172
+ vec2 calculatedUv = vec2(u,v);
173
+ vec2 uvs = ( mat * vec3( calculatedUv * 2. - 1., 1. ) / 2. + 0.5 ).xy;
174
+
175
+ vec2 df = fwidth(uvs);
176
+ if(df.x > 0.5) df.x = 0.;
177
+
178
+ #ifdef GL_EXT_shader_texture_lod
179
+ vec4 tmp = texture2DLodEXT(tex, uvs, log2(max(df.x, df.y)*min(textureSize.x, textureSize.y)));
180
+ #else
181
+ vec4 tmp = textureLod(tex, uvs, log2(max(df.x, df.y)*min(textureSize.x, textureSize.y)));
182
+ #endif
183
+
184
+ vec3 col = tmp.rgb;
185
+ float lalpha = alpha * tmp.a;
186
+ if ( crop > 0.5 ) {
187
+ if ( uvs.x < 0.0 || uvs.x > 1.0 || uvs.y < 0.0 || uvs.y > 1.0 ) {
188
+ lalpha = 0.0;
189
+ }
190
+ }
191
+ calpha = lalpha / clamp( lalpha + accumAlpha, 0.00001, 1.0 );
192
+ accumAlpha += ( 1.0 - accumAlpha ) * lalpha;
193
+ return col;
194
+ }
195
+ `),t=new oe(`
196
+ vec3 sphericalTexture(sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec2 size, float alpha, int mode, out float calpha) {
197
+ vec3 posN = normalize(vPosition);
198
+ float u = 0.5 + atan(posN.z, posN.x) / (2.*3.1415);
199
+ float v = 0.5 + asin(posN.y) / 3.1415;
200
+
201
+ vec2 calculatedUv = vec2(u,v);
202
+ vec2 uvs = ( mat * vec3( calculatedUv * 2. - 1., 1. ) / 2. + 0.5 ).xy;
203
+
204
+ vec2 df = fwidth(uvs);
205
+ if(df.x > 0.5) df.x = 0.;
206
+ #ifdef GL_EXT_shader_texture_lod
207
+ vec4 tmp = texture2DLodEXT(tex, uvs, log2(max(df.x, df.y)*min(textureSize.x, textureSize.y)));
208
+ #else
209
+ vec4 tmp = textureLod(tex, uvs, log2(max(df.x, df.y)*min(textureSize.x, textureSize.y)));
210
+ #endif
211
+
212
+ vec3 col = tmp.rgb;
213
+ float lalpha = alpha * tmp.a;
214
+ if ( crop > 0.5 ) {
215
+ if ( uvs.x < 0.0 || uvs.x > 1.0 || uvs.y < 0.0 || uvs.y > 1.0 ) {
216
+ lalpha = 0.0;
217
+ }
218
+ }
219
+ calpha = lalpha / clamp( lalpha + accumAlpha, 0.00001, 1.0 );
220
+ accumAlpha += ( 1.0 - accumAlpha ) * lalpha;
221
+ return col;
222
+ }
223
+ `),r=new oe(`vec3 uvTexture(sampler2D tex, vec2 textureSize, float crop, mat3 mat, vec2 size, float alpha, int mode, out float calpha) {
224
+
225
+ vec2 uvs = ( mat * vec3( vUv * 2. - 1., 1. ) / 2. + 0.5 ).xy;
226
+ vec4 tmp = texture2D( tex, uvs );
227
+
228
+ vec3 col = tmp.rgb;
229
+
230
+ float lalpha = alpha * tmp.a;
231
+ if ( crop > 0.5 ) {
232
+ if ( uvs.x < 0.0 || uvs.x > 1.0 || uvs.y < 0.0 || uvs.y > 1.0 ) {
233
+ lalpha = 0.0;
234
+ }
235
+ }
236
+ calpha = lalpha / clamp( lalpha + accumAlpha, 0.00001, 1.0 );
237
+ accumAlpha += ( 1.0 - accumAlpha ) * lalpha;
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) {
240
+ float fresnel = bias + scale * pow( abs( factor + dot( normalize( vWorldViewDir ), normalize( vWNormal ) ) ), intensity );
241
+
242
+ float lalpha = clamp( fresnel, 0.0, 1.0 ) * alpha;
243
+ calpha = lalpha / clamp(lalpha + accumAlpha, 0.001, 1.0);
244
+ accumAlpha += (1.0 - accumAlpha) * lalpha;
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) {
247
+ float j = 4096.0*sin(dot(c,vec3(17.0, 59.4, 15.0)));
248
+ vec3 r;
249
+ r.z = fract(512.0*j);
250
+ j *= .125;
251
+ r.x = fract(512.0*j);
252
+ j *= .125;
253
+ r.y = fract(512.0*j);
254
+ return r-0.5;
255
+ }`),t=new oe(`float simplex3d(vec3 p) {
256
+ vec3 s = floor(p + dot(p, vec3(F3)));
257
+ vec3 x = p - s + dot(s, vec3(G3));
258
+
259
+ vec3 e = step(vec3(0.0), x - x.yzx);
260
+ vec3 i1 = e*(1.0 - e.zxy);
261
+ vec3 i2 = 1.0 - e.zxy*(1.0 - e);
262
+
263
+ vec3 x1 = x - i1 + G3;
264
+ vec3 x2 = x - i2 + 2.0*G3;
265
+ vec3 x3 = x - 1.0 + 3.0*G3;
266
+
267
+ vec4 w, d;
268
+
269
+ w.x = dot(x, x);
270
+ w.y = dot(x1, x1);
271
+ w.z = dot(x2, x2);
272
+ w.w = dot(x3, x3);
273
+
274
+ w = max(0.6 - w, 0.0);
275
+
276
+ d.x = dot(random3(s), x);
277
+ d.y = dot(random3(s + i1), x1);
278
+ d.z = dot(random3(s + i2), x2);
279
+ d.w = dot(random3(s + 1.0), x3);
280
+
281
+ w *= w;
282
+ w *= w;
283
+ d *= w;
284
+
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) {
287
+ mat3 rot1 = mat3(-0.37, 0.36, 0.85,-0.14,-0.93, 0.34,0.92, 0.01,0.4);
288
+ mat3 rot2 = mat3(-0.55,-0.39, 0.74, 0.33,-0.91,-0.24,0.77, 0.12,0.63);
289
+ mat3 rot3 = mat3(-0.71, 0.52,-0.47,-0.08,-0.72,-0.68,-0.7,-0.45,0.56);
290
+ return 0.5333333 * simplex3d(m * rot1)
291
+ + 0.2666667 * simplex3d(2.0 * m * rot2)
292
+ + 0.1333333 * simplex3d(4.0 * m * rot3)
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) {
295
+ const vec2 C = vec2(1.0/6.0, 1.0/3.0) ;
296
+ const vec4 D = vec4(0.0, 0.5, 1.0, 2.0);
297
+ vec3 i = floor(v + dot(v, C.yyy) );
298
+ vec3 x0 = v - i + dot(i, C.xxx) ;
299
+ vec3 g = step(x0.yzx, x0.xyz);
300
+ vec3 l = 1.0 - g;
301
+ vec3 i1 = min( g.xyz, l.zxy );
302
+ vec3 i2 = max( g.xyz, l.zxy );
303
+ vec3 x1 = x0 - i1 + 1.0 * C.xxx;
304
+ vec3 x2 = x0 - i2 + 2.0 * C.xxx;
305
+ vec3 x3 = x0 - 1. + 3.0 * C.xxx;
306
+ i = mod(i, 289.0 );
307
+ vec4 p = permute( permute( permute(
308
+ i.z + vec4(0.0, i1.z, i2.z, 1.0 ))
309
+ + i.y + vec4(0.0, i1.y, i2.y, 1.0 ))
310
+ + i.x + vec4(0.0, i1.x, i2.x, 1.0 ));
311
+ float n_ = 1.0/7.0; // N=7
312
+ vec3 ns = n_ * D.wyz - D.xzx;
313
+ vec4 j = p - 49.0 * floor(p * ns.z *ns.z); // mod(p,N*N)
314
+ vec4 x_ = floor(j * ns.z);
315
+ vec4 y_ = floor(j - 7.0 * x_ ); // mod(j,N)
316
+ vec4 x = x_ *ns.x + ns.yyyy;
317
+ vec4 y = y_ *ns.x + ns.yyyy;
318
+ vec4 h = 1.0 - abs(x) - abs(y);
319
+ vec4 b0 = vec4( x.xy, y.xy );
320
+ vec4 b1 = vec4( x.zw, y.zw );
321
+ vec4 s0 = floor(b0)*2.0 + 1.0;
322
+ vec4 s1 = floor(b1)*2.0 + 1.0;
323
+ vec4 sh = -step(h, vec4(0.0));
324
+ vec4 a0 = b0.xzyw + s0.xzyw*sh.xxyy ;
325
+ vec4 a1 = b1.xzyw + s1.xzyw*sh.zzww ;
326
+ vec3 p0 = vec3(a0.xy,h.x);
327
+ vec3 p1 = vec3(a0.zw,h.y);
328
+ vec3 p2 = vec3(a1.xy,h.z);
329
+ vec3 p3 = vec3(a1.zw,h.w);
330
+ vec4 norm = taylorInvSqrt(vec4(dot(p0,p0), dot(p1,p1), dot(p2, p2), dot(p3,p3)));
331
+ p0 *= norm.x;
332
+ p1 *= norm.y;
333
+ p2 *= norm.z;
334
+ p3 *= norm.w;
335
+ vec4 m = max(0.6 - vec4(dot(x0,x0), dot(x1,x1), dot(x2,x2), dot(x3,x3)), 0.0);
336
+ m = m * m;
337
+ return 42.0 * dot( m*m, vec4( dot(p0,x0), dot(p1,x1),
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){
340
+ vec3 a = floor(p);
341
+ vec3 d = p - a;
342
+ d = d * d * (3.0 - 2.0 * d);
343
+ vec4 b = a.xxyy + vec4(0.0, 1.0, 0.0, 1.0);
344
+ vec4 k1 = perm(b.xyxy);
345
+ vec4 k2 = perm(k1.xyxy + b.zzww);
346
+ vec4 c = k2 + a.zzzz;
347
+ vec4 k3 = perm(c);
348
+ vec4 k4 = perm(c + 1.0);
349
+ vec4 o1 = fract(k3 * (1.0 / 41.0));
350
+ vec4 o2 = fract(k4 * (1.0 / 41.0));
351
+ vec4 o3 = o2 * d.z + o1 * (1.0 - d.z);
352
+ vec2 o4 = o3.yw * d.x + o3.xz * (1.0 - d.x);
353
+ return o4.y * d.y + o4.x * (1.0 - d.y);
354
+ }`,[l]),d=new oe(`float fbm(vec3 x) {
355
+ float v = 0.0;
356
+ float a = 0.5;
357
+ vec3 shift = vec3(100);
358
+ for (int i = 0; i < NUM_OCTAVES; ++i) {
359
+ v += a * noise(x);
360
+ x = x * 2.0 + shift;
361
+ a *= 0.5;
362
+ }
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){
365
+ vec3 Pi0 = floor(P);
366
+ vec3 Pi1 = Pi0 + vec3(1.0);
367
+ Pi0 = mod(Pi0, 289.0);
368
+ Pi1 = mod(Pi1, 289.0);
369
+ vec3 Pf0 = fract(P);
370
+ vec3 Pf1 = Pf0 - vec3(1.0);
371
+ vec4 ix = vec4(Pi0.x, Pi1.x, Pi0.x, Pi1.x);
372
+ vec4 iy = vec4(Pi0.yy, Pi1.yy);
373
+ vec4 iz0 = Pi0.zzzz;
374
+ vec4 iz1 = Pi1.zzzz;
375
+ vec4 ixy = permute(permute(ix) + iy);
376
+ vec4 ixy0 = permute(ixy + iz0);
377
+ vec4 ixy1 = permute(ixy + iz1);
378
+ vec4 gx0 = ixy0 / 7.0;
379
+ vec4 gy0 = fract(floor(gx0) / 7.0) - 0.5;
380
+ gx0 = fract(gx0);
381
+ vec4 gz0 = vec4(0.5) - abs(gx0) - abs(gy0);
382
+ vec4 sz0 = step(gz0, vec4(0.0));
383
+ gx0 -= sz0 * (step(0.0, gx0) - 0.5);
384
+ gy0 -= sz0 * (step(0.0, gy0) - 0.5);
385
+ vec4 gx1 = ixy1 / 7.0;
386
+ vec4 gy1 = fract(floor(gx1) / 7.0) - 0.5;
387
+ gx1 = fract(gx1);
388
+ vec4 gz1 = vec4(0.5) - abs(gx1) - abs(gy1);
389
+ vec4 sz1 = step(gz1, vec4(0.0));
390
+ gx1 -= sz1 * (step(0.0, gx1) - 0.5);
391
+ gy1 -= sz1 * (step(0.0, gy1) - 0.5);
392
+ vec3 g000 = vec3(gx0.x,gy0.x,gz0.x);
393
+ vec3 g100 = vec3(gx0.y,gy0.y,gz0.y);
394
+ vec3 g010 = vec3(gx0.z,gy0.z,gz0.z);
395
+ vec3 g110 = vec3(gx0.w,gy0.w,gz0.w);
396
+ vec3 g001 = vec3(gx1.x,gy1.x,gz1.x);
397
+ vec3 g101 = vec3(gx1.y,gy1.y,gz1.y);
398
+ vec3 g011 = vec3(gx1.z,gy1.z,gz1.z);
399
+ vec3 g111 = vec3(gx1.w,gy1.w,gz1.w);
400
+ vec4 norm0 = taylorInvSqrt(vec4(dot(g000, g000), dot(g010, g010), dot(g100, g100), dot(g110, g110)));
401
+ g000 *= norm0.x;
402
+ g010 *= norm0.y;
403
+ g100 *= norm0.z;
404
+ g110 *= norm0.w;
405
+ vec4 norm1 = taylorInvSqrt(vec4(dot(g001, g001), dot(g011, g011), dot(g101, g101), dot(g111, g111)));
406
+ g001 *= norm1.x;
407
+ g011 *= norm1.y;
408
+ g101 *= norm1.z;
409
+ g111 *= norm1.w;
410
+ float n000 = dot(g000, Pf0);
411
+ float n100 = dot(g100, vec3(Pf1.x, Pf0.yz));
412
+ float n010 = dot(g010, vec3(Pf0.x, Pf1.y, Pf0.z));
413
+ float n110 = dot(g110, vec3(Pf1.xy, Pf0.z));
414
+ float n001 = dot(g001, vec3(Pf0.xy, Pf1.z));
415
+ float n101 = dot(g101, vec3(Pf1.x, Pf0.y, Pf1.z));
416
+ float n011 = dot(g011, vec3(Pf0.x, Pf1.yz));
417
+ float n111 = dot(g111, Pf1);
418
+ vec3 fade_xyz = fade(Pf0);
419
+ vec4 n_z = mix(vec4(n000, n100, n010, n110), vec4(n001, n101, n011, n111), fade_xyz.z);
420
+ vec2 n_yz = mix(n_z.xy, n_z.zw, fade_xyz.y);
421
+ float n_xyz = mix(n_yz.x, n_yz.y, fade_xyz.x);
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));
425
+ vec3 st = position / noiseScale;
426
+ vec3 q = vec3(simplex3d(st),
427
+ simplex3d(st + vec3(1.0)),
428
+ simplex3d(st + vec3(1.0)));
429
+
430
+ vec3 r = vec3(simplex3d(st + vec3(1.4, 1.3, 1.0) * q + vec3(1.7, 9.2, 1.0)),
431
+ simplex3d(st + vec3(2.0, 1.2, 1.0) * q + vec3(8.3, 2.8, 1.0)),
432
+ simplex3d(st * q));
433
+
434
+ float noise = simplex3d(st + r);
435
+
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) {
438
+ vec3 res = clamp(attenuation(wavelengths, filmThickness, movement, noiseStrength, noiseScale, offset), 0.0, 2.0);
439
+
440
+ float rainbowContribution = clamp(res.r + res.g + res.b, 0.0, 1.0);
441
+ float lalpha = alpha * rainbowContribution;
442
+ calpha = lalpha / clamp( lalpha + accumAlpha, 0.00001, 1.0 );
443
+ accumAlpha += ( 1.0 - accumAlpha ) * lalpha;
444
+
445
+ 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(`
447
+ float gaussian(vec2 i) {
448
+ const float sigma = float(NUM_SAMPLES) * .25;
449
+ return exp( -.5* dot(i/=sigma,i) ) / ( 6.28 * sigma*sigma );
450
+ }`),t=new oe(`
451
+ vec4 blur(sampler2D sp, vec2 U, vec2 scale, float lod, sampler2D dm, vec2 unrefractedU, vec2 aspectRatio) {
452
+ // Slightly modified version of this:
453
+ // https://www.shadertoy.com/view/ltScRG
454
+
455
+ const int LOD = 2;
456
+ const int sLOD = 4; // tile size = 2^LOD
457
+
458
+ vec4 O = vec4(0);
459
+ const int s = NUM_SAMPLES/sLOD;
460
+ for ( int i = 0; i < s*s; i++ ) {
461
+ int modulo = (i)-((i)/(s))*(s);
462
+ vec2 d = vec2(float(modulo), float(i/s))*float(sLOD) - float(NUM_SAMPLES)/2.;
463
+ vec2 uv = U + (scale * aspectRatio) * d;
464
+ // What is the depth of the opaque object we're trying to sample
465
+ float opaqueDepth = texture2D(dm, uv).r;
466
+ if (opaqueDepth < gl_FragCoord.z) {
467
+ uv = unrefractedU + ((scale * min(lod / 2., 1.)) * aspectRatio) * d;
468
+ lod = lod > 4.0 ? lod : lod / 2.0;
469
+ }
470
+ #ifdef TEXTURE_LOD_EXT
471
+ O += gaussian(d) * texture2DLodEXT( sp, uv, lod);
472
+ #else
473
+ O += gaussian(d) * textureLod( sp, uv, lod);
474
+ #endif
475
+ }
476
+ return O / O.a;
477
+ }`,[e]),r=new oe(`
478
+ vec3 getVolumeTransmissionRay( vec3 n, vec3 v, float thickness, float ior, mat4 modelMatrix ) {
479
+ // Direction of refracted light.
480
+ vec3 refractionVector = refract( -v, n, 1.0 / ior );
481
+ // Compute rotation-independant scaling of the model matrix.
482
+ vec3 modelScale;
483
+ modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );
484
+ modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );
485
+ modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );
486
+ // The thickness is specified in local space.
487
+ return normalize( refractionVector ) * thickness * modelScale;
488
+ }`),o=new oe(`
489
+ float applyIorToRoughness( float roughness, float ior ) {
490
+ // Scale roughness with IOR so that an IOR of 1.0 results in no microfacet refraction and
491
+ // an IOR of 1.5 results in the default amount of microfacet refraction.
492
+ return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );
493
+ } `),s=new oe(`
494
+ vec4 getTransmissionSample( vec2 fragCoord, float roughness, float ior, vec2 transmissionSamplerSize, sampler2D transmissionSamplerMap, sampler2D transmissionDepthMap, vec2 unrefractedCoords, vec2 aspectRatio) {
495
+ float framebufferLod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );
496
+ float lod = applyIorToRoughness(roughness, ior);
497
+
498
+ return blur(transmissionSamplerMap, fragCoord, vec2(lod / (transmissionSamplerSize.x / 2.)), min(framebufferLod / 5.5, 8.5), transmissionDepthMap, unrefractedCoords, aspectRatio);
499
+ }`,[o,t]),n=new oe(`
500
+ 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
+ vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );
502
+ vec3 refractedRayExit = position + transmissionRay;
503
+
504
+ // Project refracted vector on the framebuffer, while mapping to normalized device coordinates.
505
+ vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
506
+ vec2 refractionCoords = ndcPos.xy / ndcPos.w;
507
+ refractionCoords += 1.0;
508
+ refractionCoords /= 2.0;
509
+
510
+ vec4 ndcPosUnrefracted = projMatrix * viewMatrix * vec4(position, 1.0 );
511
+ vec2 unrefractedCoords = ndcPosUnrefracted.xy / ndcPosUnrefracted.w;
512
+ unrefractedCoords += 1.0;
513
+ unrefractedCoords /= 2.0;
514
+
515
+ // Sample framebuffer to get pixel the refracted ray hits.
516
+ vec4 transmittedLight = getTransmissionSample( refractionCoords, roughness, ior, transmissionSamplerSize, transmissionSamplerMap, transmissionDepthMap, unrefractedCoords, aspectRatio );
517
+ // Get the specular component.
518
+ return vec4( ( 1.0 ) * transmittedLight.rgb, transmittedLight.a );
519
+ }`,[s,r]);return{transmission:new oe(`
520
+ vec3 transmission(float thickness, float ior, float roughness, vec2 transmissionSamplerSize, sampler2D transmissionSamplerMap, sampler2D transmissionDepthMap, vec2 aspectRatio, vec3 normal, float alpha, out float calpha) {
521
+ vec3 v = vec3(0.);
522
+ if (isOrthographic) {
523
+ v = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
524
+ } else {
525
+ v = normalize(vWPosition - cameraPosition);
526
+ }
527
+ vec4 transmission = getIBLVolumeRefraction(vWNormal, -v, roughness, vWPosition, modelMatrix, viewMatrix, projectionMatrix, ior, thickness, transmissionSamplerSize, transmissionSamplerMap, transmissionDepthMap, aspectRatio );
528
+ float lalpha = alpha;
529
+
530
+ calpha = lalpha / clamp( lalpha + accumAlpha, 0.00001, 1.0 );
531
+ accumAlpha += ( 1.0 - accumAlpha ) * lalpha;
532
+ 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) {
534
+ vec3 normal = packNormalToRGB( norm ).rgb;
535
+ normal *= step( vec3(0.5), cnormal );
536
+
537
+ accumAlpha += ( 1.0 - accumAlpha ) * alpha;
538
+
539
+ 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) {
541
+ vec4 color = colors[0];
542
+ vec2 m = morph / vUv.xy;
543
+ vec2 rot = vec2( 0.5 + m.x, m.y );
544
+ vec2 dt = vec2(
545
+ cos( angle ) * rot.x - sin( angle ) * rot.y,
546
+ sin( angle ) * rot.x + cos( angle ) * rot.y
547
+ );
548
+ vec2 pt = ( vUv - 0.5 + offset ) / 2.0 + dt / 2.0;
549
+ float t = dot( pt, dt ) / dot( dt, dt );
550
+ if ( gradientType == 1 ) {
551
+ t = distance (
552
+ ( vUv + morph ) * 3.0,
553
+ ( vUv + offset ) + 1.0
554
+ ) + angle;
555
+ } else if ( gradientType == 2 ) {
556
+ float polar = atan(
557
+ vUv.x + morph.x - 0.5 + offset.x,
558
+ vUv.y + morph.y - 0.5 + offset.y
559
+ ) * -1.0;
560
+ t = fract( ( angle / PI / -2.0 ) + 0.5 * ( polar / PI ) );
561
+ }
562
+
563
+ float p;
564
+ if (smoothed) {
565
+ for ( int i = 1; i < GRAD_MAX; i++ ) {
566
+ p = clamp( ( t - steps[i-1] ) / ( steps[i] - steps[i-1] ), 0.0, 1.0 );
567
+ color = mix(color, colors[i], smoothstep(0.0, 1.0, p));
568
+ }
569
+
570
+ } else {
571
+ for ( int i = 1; i < GRAD_MAX; i++ ) {
572
+ p = clamp( ( t - steps[i-1] ) / ( steps[i] - steps[i-1] ), 0.0, 1.0 );
573
+ color = mix(color, colors[i], p);
574
+ }
575
+ }
576
+
577
+ float lalpha = alpha * color.a;
578
+ calpha = lalpha / clamp( lalpha + accumAlpha, 0.00001, 1.0 );
579
+ accumAlpha += ( 1.0 - accumAlpha ) * lalpha;
580
+
581
+ 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) {
583
+ 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) {
587
+ vec3 displaced_position = distorted(position, normal, scale, intensity, offset, neighbor_offset, movement);
588
+ vec3 tangent1 = orthogonal(normal);
589
+ vec3 tangent2 = normalize(cross(normal, tangent1));
590
+
591
+ // TODO(Max): The distance to the neighbors was originally scaled by 0.1.
592
+ // This caused some small oval/circular visual artifacts in the lighting.
593
+ // For now, simply using neighbors further away betters the problem,
594
+ // but we should figure out the underlying cause when we have some time.
595
+ // Maybe its related to how we calculate the tangent and bitangent?
596
+ vec3 nearby1 = position + tangent1;
597
+ vec3 nearby2 = position + tangent2;
598
+ vec3 distorted1 = distorted(nearby1, normal, scale, intensity, offset, neighbor_offset, movement);
599
+ vec3 distorted2 = distorted(nearby2, normal, scale, intensity, offset, neighbor_offset, movement);
600
+ displaced_normal = normalize(cross(distorted1 - displaced_position, distorted2 - displaced_position));
601
+ 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) {
603
+ 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) {
605
+ vec2 uvs = (mat * vec3(uv * 2.0 - 1.0, 1.0) / 2.0 + 0.5).xy + offset;
606
+ vec4 tmp = texture2D(tex, uvs);
607
+ vec3 col = tmp.rgb;
608
+ if (crop > 0.5) {
609
+ if ( uvs.x < 0.0 || uvs.x > 1.0 || uvs.y < 0.0 || uvs.y > 1.0 ) {
610
+ return 0.0;
611
+ }
612
+ }
613
+ 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) {
615
+ vec3 displaced_position = position + normal * displacementMapTexture(tex, crop, uv, mat, vec2(0.0)) * intensity;
616
+ vec3 tangent1 = normalize(orthogonal(normal));
617
+ vec3 tangent2 = normalize(cross(normal, tangent1));
618
+ vec3 nearby1 = position + tangent1 * 0.1;
619
+ vec3 nearby2 = position + tangent2 * 0.1;
620
+ vec3 distorted1 = nearby1 + normal * displacementMapTexture(tex, crop, uv, mat, vec2(neighbor_offset)) * intensity;
621
+ vec3 distorted2 = nearby2 + normal * displacementMapTexture(tex, crop, uv, mat, vec2(neighbor_offset)) * intensity;
622
+ displaced_normal = normalize(cross(distorted1 - displaced_position, distorted2 - displaced_position));
623
+ 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) {
625
+ vec3 st = position / size;
626
+ 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);
634
+ vec4 color;
635
+ color = mix(colorA, colorB, clamp((f * f) * 4.0, 0.0, 1.0));
636
+ color = mix(color, colorC, clamp(length(q), 0.0, 1.0));
637
+ color = mix(color, colorD, clamp(length(r.x), 0.0, 1.0));
638
+
639
+ float lalpha = alpha * color.a;
640
+ calpha = lalpha / clamp( lalpha + accumAlpha, 0.00001, 1.0 );
641
+
642
+ accumAlpha += ( 1.0 - accumAlpha ) * lalpha;
643
+ 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) {
645
+ vec4 color = colors[0];
646
+ #ifdef ${r}_IS_VECTOR
647
+ #ifdef ${r}_LINEAR
648
+ #ifdef ${r}_WORLDSPACE
649
+ float depth = vectorLinearWorldSpaceDepth(direction, origin, near, far);
650
+ #else
651
+ float depth = vectorLinearObjectSpaceDepth(direction, origin, near, far);
652
+ #endif
653
+ #else
654
+ #ifdef ${r}_WORLDSPACE
655
+ float depth = vectorSphericalWorldSpaceDepth(origin, near, far);
656
+ #else
657
+ float depth = vectorSphericalObjectSpaceDepth(origin, near, far);
658
+ #endif
659
+ #endif
660
+ #else
661
+ float dist = length(vWPosition - cameraPosition);
662
+ float depth = ( dist - near ) / ( far - near );
663
+ #endif
664
+
665
+
666
+ float p;
667
+ #ifdef ${r}_SMOOTH
668
+ for ( int i = 1; i < ${r}_MAX_COLORS; i++ ) {
669
+ p = clamp( ( depth - steps[i-1] ) / ( steps[i] - steps[i-1] ), 0.0, 1.0 );
670
+ color = mix(color, colors[i], smoothstep(0.0, 1.0, p));
671
+ }
672
+ #else
673
+ for ( int i = 1; i < ${r}_MAX_COLORS; i++ ) {
674
+ p = clamp(( depth - steps[i - 1] ) / ( steps[i] - steps[i - 1] ), 0.0, 1.0);
675
+ color = mix(color, colors[i], p);
676
+ }
677
+ #endif
678
+
679
+ float lalpha = alpha * color.a;
680
+ calpha = lalpha / clamp( lalpha + accumAlpha, 0.00001, 1.0 );
681
+
682
+ accumAlpha += ( 1.0 - accumAlpha ) * lalpha;
683
+ 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) {
685
+ vec3 n = normalize(direction);
686
+ float dist = (n.x*(vWPosition.x - origin.x) + n.y*(vWPosition.y - origin.y) + n.z*(vWPosition.z - origin.z));
687
+ return ( dist - near ) / ( far - near );
688
+ }`),t=new oe(`float vectorLinearObjectSpaceDepth(vec3 direction, vec3 origin, float near, float far) {
689
+ vec3 n = normalize(direction);
690
+ float dist = (n.x*(position.x - origin.x) + n.y*(position.y - origin.y) + n.z*(position.z - origin.z));
691
+ return ( dist - near ) / ( far - near );
692
+ }`),r=new oe(`float vectorSphericalWorldSpaceDepth(vec3 origin, float near, float far) {
693
+ float dist = length(vWPosition - origin);
694
+ return ( dist - near ) / ( far - near );
695
+ }`),o=new oe(`float vectorSphericalObjectSpaceDepth(vec3 origin, float near, float far) {
696
+ float dist = length(position - origin);
697
+ 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) {
699
+ vec3 viewDir = normalize( vViewPosition );
700
+ vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );
701
+ vec3 y = cross( viewDir, x );
702
+ vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5; // 0.495 to remove artifacts caused by undersized matcap disks
703
+ vec4 matcapColor = texture2D( matcapTex, uv );
704
+ // matcapColor = matcapTexelToLinear( matcapColor );
705
+ matcapColor.rgb *= color;
706
+
707
+ calpha = alpha / clamp( alpha + accumAlpha, 0.00001, 1.0 );
708
+ accumAlpha += ( 1.0 - accumAlpha ) * alpha;
709
+
710
+ return matcapColor.rgb;
711
+ }
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(`
713
+ `));let o=["#include <beginnormal_vertex>",`
714
+ #if !defined( USE_LAYER_DISPLACE )
715
+ #include <defaultnormal_vertex>
716
+ #endif
717
+
718
+ vec3 displaced_position = position;
719
+ vec3 displaced_normal = normal;
720
+
721
+ #if defined( USE_LAYER_DISPLACE )
722
+ vec3 transformed;
723
+ vec3 transformedNormal;
724
+ #endif
725
+ `,"#include <normal_vertex>",`
726
+ #if !defined( USE_LAYER_DISPLACE )
727
+ #include <begin_vertex>
728
+ #endif /* !USE_LAYER_DISPLACE */
729
+ `];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(`
733
+ `));let o=["#include <beginnormal_vertex>",`
734
+ #ifndef USE_LAYER_DISPLACE
735
+ #include <defaultnormal_vertex>
736
+ #endif
737
+
738
+ vec3 displaced_position = position;
739
+ vec3 displaced_normal = normal;
740
+
741
+ #ifdef USE_LAYER_DISPLACE
742
+ vec3 transformed;
743
+ vec3 transformedNormal;
744
+ #endif
745
+ `,"#include <normal_vertex>",`
746
+ #ifndef USE_LAYER_DISPLACE
747
+ #include <begin_vertex>
748
+ #endif
749
+ `];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(`
751
+ `));let d=["#include <normal_fragment_begin>",`
752
+ // NOTE: gl_FrontFacing alternative using face normal estimation.
753
+ vec3 viewdx = dFdx(vViewPosition);
754
+ vec3 viewdy = dFdy(vViewPosition);
755
+ vec3 faceNormal = normalize(cross(viewdx,viewdy));
756
+ if (dot(normal, faceNormal) < 0.0) {
757
+ normal *= -1.0;
758
+ }
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(`
760
+ if (outgoingLight != diffuseColor) {
761
+ 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} );
764
+ }
765
+ `),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(`
767
+ `));let o=["#include <beginnormal_vertex>",`
768
+ #ifndef USE_LAYER_DISPLACE
769
+ #include <defaultnormal_vertex>
770
+ #endif
771
+
772
+ vec3 displaced_position = position;
773
+ vec3 displaced_normal = normal;
774
+
775
+ #ifdef USE_LAYER_DISPLACE
776
+ vec3 transformed;
777
+ vec3 transformedNormal;
778
+ #endif
779
+ `,"#include <normal_vertex>",`
780
+ #ifndef USE_LAYER_DISPLACE
781
+ #include <begin_vertex>
782
+ #endif
783
+ `];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>",`
784
+ vec3 diffuse = vec3( 1.0 );
785
+ GeometricContext geometry;
786
+ geometry.position = mvPosition.xyz;
787
+ geometry.normal = normalize( transformedNormal );
788
+ geometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( -mvPosition.xyz );
789
+ GeometricContext backGeometry;
790
+ backGeometry.position = geometry.position;
791
+ backGeometry.normal = -geometry.normal;
792
+ backGeometry.viewDir = geometry.viewDir;
793
+ vLightFront = vec3( 0.0 );
794
+ vIndirectFront = vec3( 0.0 );
795
+ #ifdef DOUBLE_SIDED
796
+ vLightBack = vec3( 0.0 );
797
+ vIndirectBack = vec3( 0.0 );
798
+ #endif
799
+ IncidentLight directLight;
800
+ float dotNL;
801
+ vec3 directLightColor_Diffuse;
802
+ vIndirectFront += getAmbientLightIrradiance( ambientLightColor );
803
+ vIndirectFront += getLightProbeIrradiance( lightProbe, geometry.normal );
804
+ #ifdef DOUBLE_SIDED
805
+ vIndirectBack += getAmbientLightIrradiance( ambientLightColor );
806
+ vIndirectBack += getLightProbeIrradiance( lightProbe, backGeometry.normal );
807
+ #endif
808
+ #if NUM_POINT_LIGHTS > 0
809
+ #pragma unroll_loop_start
810
+ for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {
811
+ getPointLightInfo( pointLights[ i ], geometry, directLight );
812
+ dotNL = dot( geometry.normal, directLight.direction );
813
+ directLightColor_Diffuse = directLight.color;
814
+ vLightFront += saturate( dotNL ) * directLightColor_Diffuse;
815
+ #ifdef DOUBLE_SIDED
816
+ vLightBack += saturate( -dotNL ) * directLightColor_Diffuse;
817
+ #endif
818
+ }
819
+ #pragma unroll_loop_end
820
+ #endif
821
+ #if NUM_SPOT_LIGHTS > 0
822
+ #pragma unroll_loop_start
823
+ for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {
824
+ getSpotLightInfo( spotLights[ i ], geometry, directLight );
825
+ dotNL = dot( geometry.normal, directLight.direction );
826
+ directLightColor_Diffuse = directLight.color;
827
+ vLightFront += saturate( dotNL ) * directLightColor_Diffuse;
828
+ #ifdef DOUBLE_SIDED
829
+ vLightBack += saturate( -dotNL ) * directLightColor_Diffuse;
830
+ #endif
831
+ }
832
+ #pragma unroll_loop_end
833
+ #endif
834
+ #if NUM_DIR_LIGHTS > 0
835
+ #pragma unroll_loop_start
836
+ for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {
837
+ getDirectionalLightInfo( directionalLights[ i ], geometry, directLight );
838
+ dotNL = dot( geometry.normal, directLight.direction );
839
+ directLightColor_Diffuse = directLight.color;
840
+ vLightFront += saturate( dotNL ) * directLightColor_Diffuse;
841
+ #ifdef DOUBLE_SIDED
842
+ vLightBack += saturate( -dotNL ) * directLightColor_Diffuse;
843
+ #endif
844
+ }
845
+ #pragma unroll_loop_end
846
+ #endif
847
+ #if NUM_HEMI_LIGHTS > 0
848
+ #pragma unroll_loop_start
849
+ for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
850
+ vIndirectFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry.normal );
851
+ #ifdef DOUBLE_SIDED
852
+ vIndirectBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry.normal );
853
+ #endif
854
+ }
855
+ #pragma unroll_loop_end
856
+ #endif
857
+ `," #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(`
859
+ `));let d=["#include <normal_fragment_begin>",`
860
+ // NOTE: gl_FrontFacing alternative using face normal estimation.
861
+ vec3 viewdx = dFdx(vViewPosition);
862
+ vec3 viewdy = dFdy(vViewPosition);
863
+ vec3 faceNormal = normalize(cross(viewdx, viewdy));
864
+ 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(`
866
+ if (outgoingLight != diffuseColor) {
867
+ 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} );
870
+ }
871
+ `),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(`
873
+ `));let o=["#include <beginnormal_vertex>",`
874
+ #ifndef USE_LAYER_DISPLACE
875
+ #include <defaultnormal_vertex>
876
+ #endif
877
+
878
+ vec3 displaced_position = position;
879
+ vec3 displaced_normal = normal;
880
+
881
+ #ifdef USE_LAYER_DISPLACE
882
+ vec3 transformed;
883
+ vec3 transformedNormal;
884
+ #endif
885
+ `,"#include <normal_vertex>",`
886
+ #ifndef USE_LAYER_DISPLACE
887
+ #include <begin_vertex>
888
+ #endif
889
+ `];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>",`
891
+ varying vec3 vViewPosition;
892
+ struct ToonMaterial {
893
+ vec3 diffuseColor;
894
+ vec3 specularColor;
895
+ float specularShininess;
896
+ float specularStrength;
897
+ };
898
+ void RE_Direct_Toon( const in IncidentLight directLight, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
899
+ vec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color;
900
+
901
+ reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
902
+ reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularShininess ) * material.specularStrength;
903
+ }
904
+ void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
905
+ reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
906
+ }
907
+ #define RE_Direct RE_Direct_Toon
908
+ #define RE_IndirectDiffuse RE_IndirectDiffuse_Toon
909
+ #define Material_LightProbeLOD( material ) (0)
910
+ `,"#include <shadowmap_pars_fragment>","#include <bumpmap_pars_fragment>","#include <normalmap_pars_fragment>"].join(`
911
+ `));let d=["#include <normal_fragment_begin>",`
912
+ // NOTE: gl_FrontFacing alternative using face normal estimation.
913
+ vec3 viewdx = dFdx(vViewPosition);
914
+ vec3 viewdy = dFdy(vViewPosition);
915
+ vec3 faceNormal = normalize(cross(viewdx,viewdy));
916
+ if (dot(normal, faceNormal) < 0.0) {
917
+ normal *= -1.0;
918
+ }
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(`
920
+ if (outgoingLight != diffuseColor) {
921
+ 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} );
924
+ }
925
+ `),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(`
927
+ `));let o=["#include <beginnormal_vertex>",`
928
+ #if !defined( USE_LAYER_DISPLACE )
929
+ #include <defaultnormal_vertex>
930
+ #endif
931
+
932
+ vec3 displaced_position = position;
933
+ vec3 displaced_normal = normal;
934
+
935
+ #if defined( USE_LAYER_DISPLACE )
936
+ vec3 transformed;
937
+ vec3 transformedNormal;
938
+ #endif
939
+ `,"#include <normal_vertex>",`
940
+ #if !defined( USE_LAYER_DISPLACE )
941
+ #include <begin_vertex>
942
+ #endif /* !USE_LAYER_DISPLACE */
943
+ `];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>",`
946
+ // NOTE: gl_FrontFacing alternative using face normal estimation.
947
+ vec3 viewdx = dFdx(vViewPosition);
948
+ vec3 viewdy = dFdy(vViewPosition);
949
+ vec3 faceNormal = normalize(cross(viewdx,viewdy));
950
+ if (dot(normal, faceNormal) < 0.0) {
951
+ normal *= -1.0;
952
+ }
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(`
954
+ if (outgoingLight != diffuseColor) {
955
+ float lightAccu = clamp( length( reflectedLight.directSpecular + reflectedLight.indirectSpecular ), 0.0, 1.0 );
956
+ accumAlpha += ( 1.0 - accumAlpha ) * ${a.result} * lightAccu;
957
+ outgoingLight = spe_blend( diffuseColor, outgoingLight, ${a.result}, ${l.result} );
958
+ }
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};