@splinetool/loader 1.10.77 → 1.10.78

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  "use strict";var NS=Object.create;var Js=Object.defineProperty;var DS=Object.getOwnPropertyDescriptor;var _S=Object.getOwnPropertyNames;var RS=Object.getPrototypeOf,LS=Object.prototype.hasOwnProperty;var BS=(i,t,e)=>t in i?Js(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e;var el=(i,t)=>()=>(t||i((t={exports:{}}).exports,t),t.exports),lm=(i,t)=>{for(var e in t)Js(i,e,{get:t[e],enumerable:!0})},cm=(i,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of _S(t))!LS.call(i,o)&&o!==e&&Js(i,o,{get:()=>t[o],enumerable:!(r=DS(t,o))||r.enumerable});return i};var tl=(i,t,e)=>(e=i!=null?NS(RS(i)):{},cm(t||!i||!i.__esModule?Js(e,"default",{value:i,enumerable:!0}):e,i)),VS=i=>cm(Js({},"__esModule",{value:!0}),i);var yn=(i,t,e)=>(BS(i,typeof t!="symbol"?t+"":t,e),e);var Q0=el((uf,K0)=>{(function(i,t){typeof uf=="object"?K0.exports=t():typeof define=="function"&&define.amd?define(t):i.Alea=t()})(uf,function(){"use strict";return i.importState=function(e){var r=new i;return r.importState(e),r},i;function i(){return function(e){var r=0,o=0,n=0,a=1;e.length==0&&(e=[+new Date]);var s=t();r=s(" "),o=s(" "),n=s(" ");for(var l=0;l<e.length;l++)r-=s(e[l]),r<0&&(r+=1),o-=s(e[l]),o<0&&(o+=1),n-=s(e[l]),n<0&&(n+=1);s=null;var c=function(){var u=2091639*r+a*23283064365386963e-26;return r=o,o=n,n=u-(a=u|0)};return c.next=c,c.uint32=function(){return c()*4294967296},c.fract53=function(){return c()+(c()*2097152|0)*11102230246251565e-32},c.version="Alea 0.9",c.args=e,c.exportState=function(){return[r,o,n,a]},c.importState=function(u){r=+u[0]||0,o=+u[1]||0,n=+u[2]||0,a=+u[3]||0},c}(Array.prototype.slice.call(arguments))}function t(){var e=4022871197,r=function(o){o=o.toString();for(var n=0;n<o.length;n++){e+=o.charCodeAt(n);var a=.02519603282416938*e;e=a>>>0,a-=e,a*=e,e=a>>>0,a-=e,e+=a*4294967296}return(e>>>0)*23283064365386963e-26};return r.version="Mash 0.9",r}})});var ix=el((Bu,ox)=>{(function(i,t){typeof Bu=="object"&&typeof ox<"u"?t(Bu):typeof define=="function"&&define.amd?define(["exports"],t):t((i=typeof globalThis<"u"?globalThis:i||self).SVDJS={})})(Bu,function(i){"use strict";i.SVD=function(t,e,r,o,n){if(e=e===void 0||e,r=r===void 0||r,n=1e-64/(o=o||Math.pow(2,-52)),!t)throw new TypeError("Matrix a is not defined");var a,s,l,c,u,p,d,f,h,m,y,b,v=t[0].length,w=t.length;if(w<v)throw new TypeError("Invalid matrix: m < n");for(var O=[],S=[],T=[],M=e==="f"?w:v,g=m=d=0;g<w;g++)S[g]=new Array(M).fill(0);for(g=0;g<v;g++)T[g]=new Array(v).fill(0);var D,E=new Array(v).fill(0);for(g=0;g<w;g++)for(a=0;a<v;a++)S[g][a]=t[g][a];for(g=0;g<v;g++){for(O[g]=d,h=0,l=g+1,a=g;a<w;a++)h+=Math.pow(S[a][g],2);if(h<n)d=0;else for(f=(p=S[g][g])*(d=p<0?Math.sqrt(h):-Math.sqrt(h))-h,S[g][g]=p-d,a=l;a<v;a++){for(h=0,s=g;s<w;s++)h+=S[s][g]*S[s][a];for(p=h/f,s=g;s<w;s++)S[s][a]=S[s][a]+p*S[s][g]}for(E[g]=d,h=0,a=l;a<v;a++)h+=Math.pow(S[g][a],2);if(h<n)d=0;else{for(f=(p=S[g][g+1])*(d=p<0?Math.sqrt(h):-Math.sqrt(h))-h,S[g][g+1]=p-d,a=l;a<v;a++)O[a]=S[g][a]/f;for(a=l;a<w;a++){for(h=0,s=l;s<v;s++)h+=S[a][s]*S[g][s];for(s=l;s<v;s++)S[a][s]=S[a][s]+h*O[s]}}m<(y=Math.abs(E[g])+Math.abs(O[g]))&&(m=y)}if(r)for(g=v-1;0<=g;g--){if(d!==0){for(f=S[g][g+1]*d,a=l;a<v;a++)T[a][g]=S[g][a]/f;for(a=l;a<v;a++){for(h=0,s=l;s<v;s++)h+=S[g][s]*T[s][a];for(s=l;s<v;s++)T[s][a]=T[s][a]+h*T[s][g]}}for(a=l;a<v;a++)T[g][a]=0,T[a][g]=0;T[g][g]=1,d=O[g],l=g}if(e){if(e==="f")for(g=v;g<w;g++){for(a=v;a<w;a++)S[g][a]=0;S[g][g]=1}for(g=v-1;0<=g;g--){for(l=g+1,d=E[g],a=l;a<M;a++)S[g][a]=0;if(d!==0){for(f=S[g][g]*d,a=l;a<M;a++){for(h=0,s=l;s<w;s++)h+=S[s][g]*S[s][a];for(p=h/f,s=g;s<w;s++)S[s][a]=S[s][a]+p*S[s][g]}for(a=g;a<w;a++)S[a][g]=S[a][g]/d}else for(a=g;a<w;a++)S[a][g]=0;S[g][g]=S[g][g]+1}}for(o*=m,s=v-1;0<=s;s--)for(var I=0;I<50;I++){for(D=!1,l=s;0<=l;l--){if(Math.abs(O[l])<=o){D=!0;break}if(Math.abs(E[l-1])<=o)break}if(!D){for(u=0,c=l-(h=1),g=l;g<s+1&&(p=h*O[g],O[g]=u*O[g],!(Math.abs(p)<=o));g++)if(d=E[g],E[g]=Math.sqrt(p*p+d*d),u=d/(f=E[g]),h=-p/f,e)for(a=0;a<w;a++)y=S[a][c],b=S[a][g],S[a][c]=y*u+b*h,S[a][g]=-y*h+b*u}if(b=E[s],l===s){if(b<0&&(E[s]=-b,r))for(a=0;a<v;a++)T[a][s]=-T[a][s];break}for(m=E[l],p=(((y=E[s-1])-b)*(y+b)+((d=O[s-1])-(f=O[s]))*(d+f))/(2*f*y),d=Math.sqrt(p*p+1),p=((m-b)*(m+b)+f*(y/(p<0?p-d:p+d)-f))/m,g=l+(h=u=1);g<s+1;g++){if(d=O[g],y=E[g],f=h*d,d*=u,b=Math.sqrt(p*p+f*f),p=m*(u=p/(O[g-1]=b))+d*(h=f/b),d=-m*h+d*u,f=y*h,y*=u,r)for(a=0;a<v;a++)m=T[a][g-1],b=T[a][g],T[a][g-1]=m*u+b*h,T[a][g]=-m*h+b*u;if(b=Math.sqrt(p*p+f*f),p=(u=p/(E[g-1]=b))*d+(h=f/b)*y,m=-h*d+u*y,e)for(a=0;a<w;a++)y=S[a][g-1],b=S[a][g],S[a][g-1]=y*u+b*h,S[a][g]=-y*h+b*u}O[l]=0,O[s]=p,E[s]=m}for(g=0;g<v;g++)E[g]<o&&(E[g]=0);return{u:S,q:E,v:T}},i.VERSION="1.1.1",Object.defineProperty(i,"__esModule",{value:!0})})});var e1=el((_re,Jv)=>{"use strict";function Y3(i,t){function e(){this.constructor=i}e.prototype=t.prototype,i.prototype=new e}function Un(i,t,e,r){this.message=i,this.expected=t,this.found=e,this.location=r,this.name="SyntaxError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,Un)}Y3(Un,Error);Un.buildMessage=function(i,t){var e={literal:function(c){return'"'+o(c.text)+'"'},class:function(c){var u="",p;for(p=0;p<c.parts.length;p++)u+=c.parts[p]instanceof Array?n(c.parts[p][0])+"-"+n(c.parts[p][1]):n(c.parts[p]);return"["+(c.inverted?"^":"")+u+"]"},any:function(c){return"any character"},end:function(c){return"end of input"},other:function(c){return c.description}};function r(c){return c.charCodeAt(0).toString(16).toUpperCase()}function o(c){return c.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(u){return"\\x0"+r(u)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(u){return"\\x"+r(u)})}function n(c){return c.replace(/\\/g,"\\\\").replace(/\]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(u){return"\\x0"+r(u)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(u){return"\\x"+r(u)})}function a(c){return e[c.type](c)}function s(c){var u=new Array(c.length),p,d;for(p=0;p<c.length;p++)u[p]=a(c[p]);if(u.sort(),u.length>0){for(p=1,d=1;p<u.length;p++)u[p-1]!==u[p]&&(u[d]=u[p],d++);u.length=d}switch(u.length){case 1:return u[0];case 2:return u[0]+" or "+u[1];default:return u.slice(0,-1).join(", ")+", or "+u[u.length-1]}}function l(c){return c?'"'+o(c)+'"':"end of input"}return"Expected "+s(i)+" but "+l(t)+" found."};function K3(i,t){t=t!==void 0?t:{};var e={},r={svg_path:Zs},o=Zs,n=function(x){if(!x)return[];for(var P=[],L=0;L<x.length;L++)P=P.concat.apply(P,x[L]);var A=P[0];return A&&A.code=="m"&&(delete A.relative,A.code="M"),P},a=function(x,P){return ES(x,P)},s=/^[Mm]/,l=at(["M","m"],!1,!1),c=function(x,P,L){var A=Xn(x,[P]);return L&&(A=A.concat(Xn(x=="M"?"L":"l",L[1]))),A},u=/^[Zz]/,p=at(["Z","z"],!1,!1),d=function(){return Xn("Z")},f=/^[Ll]/,h=at(["L","l"],!1,!1),m=function(x,P){return Xn(x,P)},y=/^[Hh]/,b=at(["H","h"],!1,!1),v=function(x,P){return Xn(x,P.map(function(L){return{x:L}}))},w=/^[Vv]/,O=at(["V","v"],!1,!1),S=function(x,P){return Xn(x,P.map(function(L){return{y:L}}))},T=/^[Cc]/,M=at(["C","c"],!1,!1),g=function(x,P,L){return{x1:x.x,y1:x.y,x2:P.x,y2:P.y,x:L.x,y:L.y}},D=/^[Ss]/,E=at(["S","s"],!1,!1),I=function(x,P){return{x2:x.x,y2:x.y,x:P.x,y:P.y}},N=/^[Qq]/,_=at(["Q","q"],!1,!1),R=function(x,P){return{x1:x.x,y1:x.y,x:P.x,y:P.y}},V=/^[Tt]/,U=at(["T","t"],!1,!1),B=/^[Aa]/,q=at(["A","a"],!1,!1),j=function(x,P,L,A,z,oe){return{rx:x,ry:P,xAxisRotation:L,largeArc:A,sweep:z,x:oe.x,y:oe.y}},F=function(x,P){return{x,y:P}},H=function(x){return x*1},W=function(x){return x.join("")*1},ee=/^[01]/,te=at(["0","1"],!1,!1),Y=function(x){return x=="1"},re=function(){return""},K=",",Z=xt(",",!1),Q=function(x){return x.join("")},$=".",pe=xt(".",!1),le=/^[eE]/,ie=at(["e","E"],!1,!1),ue=/^[+\-]/,ae=at(["+","-"],!1,!1),ge=/^[0-9]/,me=at([["0","9"]],!1,!1),ye=function(x){return x.join("")},ve=/^[ \t\n\r]/,xe=at([" "," ",`
2
- `,"\r"],!1,!1),C=0,ne=0,Ve=[{line:1,column:1}],ke=0,Ge=[],Ce=0,zt;if("startRule"in t){if(!(t.startRule in r))throw new Error(`Can't start parsing from rule "`+t.startRule+'".');o=r[t.startRule]}function _e(){return i.substring(ne,C)}function Bt(){return fn(ne,C)}function Gt(x,P){throw P=P!==void 0?P:fn(ne,C),zr([up(x)],i.substring(ne,C),P)}function pn(x,P){throw P=P!==void 0?P:fn(ne,C),dp(x,P)}function xt(x,P){return{type:"literal",text:x,ignoreCase:P}}function at(x,P,L){return{type:"class",parts:x,inverted:P,ignoreCase:L}}function to(){return{type:"any"}}function cp(){return{type:"end"}}function up(x){return{type:"other",description:x}}function hc(x){var P=Ve[x],L;if(P)return P;for(L=x-1;!Ve[L];)L--;for(P=Ve[L],P={line:P.line,column:P.column};L<x;)i.charCodeAt(L)===10?(P.line++,P.column=1):P.column++,L++;return Ve[x]=P,P}function fn(x,P){var L=hc(x),A=hc(P);return{start:{offset:x,line:L.line,column:L.column},end:{offset:P,line:A.line,column:A.column}}}function Pt(x){C<ke||(C>ke&&(ke=C,Ge=[]),Ge.push(x))}function dp(x,P){return new Un(x,null,null,P)}function zr(x,P,L){return new Un(Un.buildMessage(x,P),x,P,L)}function Zs(){var x,P,L,A,z;for(x=C,P=[],L=He();L!==e;)P.push(L),L=He();if(P!==e)if(L=cr(),L===e&&(L=null),L!==e){for(A=[],z=He();z!==e;)A.push(z),z=He();A!==e?(ne=x,P=n(L),x=P):(C=x,x=e)}else C=x,x=e;else C=x,x=e;return x}function cr(){var x,P,L,A,z,oe;if(x=C,P=hn(),P!==e){for(L=[],A=C,z=[],oe=He();oe!==e;)z.push(oe),oe=He();for(z!==e?(oe=hn(),oe!==e?(z=[z,oe],A=z):(C=A,A=e)):(C=A,A=e);A!==e;){for(L.push(A),A=C,z=[],oe=He();oe!==e;)z.push(oe),oe=He();z!==e?(oe=hn(),oe!==e?(z=[z,oe],A=z):(C=A,A=e)):(C=A,A=e)}L!==e?(ne=x,P=a(P,L),x=P):(C=x,x=e)}else C=x,x=e;return x}function hn(){var x,P,L,A,z,oe;if(x=C,P=qn(),P!==e){for(L=[],A=C,z=[],oe=He();oe!==e;)z.push(oe),oe=He();for(z!==e?(oe=mc(),oe!==e?(z=[z,oe],A=z):(C=A,A=e)):(C=A,A=e);A!==e;){for(L.push(A),A=C,z=[],oe=He();oe!==e;)z.push(oe),oe=He();z!==e?(oe=mc(),oe!==e?(z=[z,oe],A=z):(C=A,A=e)):(C=A,A=e)}L!==e?(ne=x,P=a(P,L),x=P):(C=x,x=e)}else C=x,x=e;return x}function mc(){var x;return x=mS(),x===e&&(x=yS(),x===e&&(x=gS(),x===e&&(x=xS(),x===e&&(x=bS(),x===e&&(x=SS(),x===e&&(x=PS(),x===e&&(x=TS(),x===e&&(x=AS())))))))),x}function qn(){var x,P,L,A,z,oe,Yn;if(x=C,s.test(i.charAt(C))?(P=i.charAt(C),C++):(P=e,Ce===0&&Pt(l)),P!==e){for(L=[],A=He();A!==e;)L.push(A),A=He();L!==e?(A=pr(),A!==e?(z=C,oe=ht(),oe===e&&(oe=null),oe!==e?(Yn=em(),Yn!==e?(oe=[oe,Yn],z=oe):(C=z,z=e)):(C=z,z=e),z===e&&(z=null),z!==e?(ne=x,P=c(P,A,z),x=P):(C=x,x=e)):(C=x,x=e)):(C=x,x=e)}else C=x,x=e;return x}function mS(){var x,P;return x=C,u.test(i.charAt(C))?(P=i.charAt(C),C++):(P=e,Ce===0&&Pt(p)),P!==e&&(ne=x,P=d()),x=P,x}function yS(){var x,P,L,A;if(x=C,f.test(i.charAt(C))?(P=i.charAt(C),C++):(P=e,Ce===0&&Pt(h)),P!==e){for(L=[],A=He();A!==e;)L.push(A),A=He();L!==e?(A=em(),A!==e?(ne=x,P=m(P,A),x=P):(C=x,x=e)):(C=x,x=e)}else C=x,x=e;return x}function em(){var x,P,L,A,z,oe;if(x=C,P=pr(),P!==e){for(L=[],A=C,z=ht(),z===e&&(z=null),z!==e?(oe=pr(),oe!==e?(z=[z,oe],A=z):(C=A,A=e)):(C=A,A=e);A!==e;)L.push(A),A=C,z=ht(),z===e&&(z=null),z!==e?(oe=pr(),oe!==e?(z=[z,oe],A=z):(C=A,A=e)):(C=A,A=e);L!==e?(ne=x,P=a(P,L),x=P):(C=x,x=e)}else C=x,x=e;return x}function gS(){var x,P,L,A;if(x=C,y.test(i.charAt(C))?(P=i.charAt(C),C++):(P=e,Ce===0&&Pt(b)),P!==e){for(L=[],A=He();A!==e;)L.push(A),A=He();L!==e?(A=tm(),A!==e?(ne=x,P=v(P,A),x=P):(C=x,x=e)):(C=x,x=e)}else C=x,x=e;return x}function tm(){var x,P,L,A,z,oe;if(x=C,P=$n(),P!==e){for(L=[],A=C,z=ht(),z===e&&(z=null),z!==e?(oe=$n(),oe!==e?(z=[z,oe],A=z):(C=A,A=e)):(C=A,A=e);A!==e;)L.push(A),A=C,z=ht(),z===e&&(z=null),z!==e?(oe=$n(),oe!==e?(z=[z,oe],A=z):(C=A,A=e)):(C=A,A=e);L!==e?(ne=x,P=a(P,L),x=P):(C=x,x=e)}else C=x,x=e;return x}function xS(){var x,P,L,A;if(x=C,w.test(i.charAt(C))?(P=i.charAt(C),C++):(P=e,Ce===0&&Pt(O)),P!==e){for(L=[],A=He();A!==e;)L.push(A),A=He();L!==e?(A=tm(),A!==e?(ne=x,P=S(P,A),x=P):(C=x,x=e)):(C=x,x=e)}else C=x,x=e;return x}function bS(){var x,P,L,A;if(x=C,T.test(i.charAt(C))?(P=i.charAt(C),C++):(P=e,Ce===0&&Pt(M)),P!==e){for(L=[],A=He();A!==e;)L.push(A),A=He();L!==e?(A=vS(),A!==e?(ne=x,P=m(P,A),x=P):(C=x,x=e)):(C=x,x=e)}else C=x,x=e;return x}function vS(){var x,P,L,A,z,oe;if(x=C,P=pp(),P!==e){for(L=[],A=C,z=ht(),z===e&&(z=null),z!==e?(oe=pp(),oe!==e?(z=[z,oe],A=z):(C=A,A=e)):(C=A,A=e);A!==e;)L.push(A),A=C,z=ht(),z===e&&(z=null),z!==e?(oe=pp(),oe!==e?(z=[z,oe],A=z):(C=A,A=e)):(C=A,A=e);L!==e?(ne=x,P=a(P,L),x=P):(C=x,x=e)}else C=x,x=e;return x}function pp(){var x,P,L,A,z,oe;return x=C,P=pr(),P!==e?(L=ht(),L===e&&(L=null),L!==e?(A=pr(),A!==e?(z=ht(),z===e&&(z=null),z!==e?(oe=pr(),oe!==e?(ne=x,P=g(P,A,oe),x=P):(C=x,x=e)):(C=x,x=e)):(C=x,x=e)):(C=x,x=e)):(C=x,x=e),x}function SS(){var x,P,L,A;if(x=C,D.test(i.charAt(C))?(P=i.charAt(C),C++):(P=e,Ce===0&&Pt(E)),P!==e){for(L=[],A=He();A!==e;)L.push(A),A=He();L!==e?(A=wS(),A!==e?(ne=x,P=m(P,A),x=P):(C=x,x=e)):(C=x,x=e)}else C=x,x=e;return x}function wS(){var x,P,L,A,z,oe;if(x=C,P=fp(),P!==e){for(L=[],A=C,z=ht(),z===e&&(z=null),z!==e?(oe=fp(),oe!==e?(z=[z,oe],A=z):(C=A,A=e)):(C=A,A=e);A!==e;)L.push(A),A=C,z=ht(),z===e&&(z=null),z!==e?(oe=fp(),oe!==e?(z=[z,oe],A=z):(C=A,A=e)):(C=A,A=e);L!==e?(ne=x,P=a(P,L),x=P):(C=x,x=e)}else C=x,x=e;return x}function fp(){var x,P,L,A;return x=C,P=pr(),P!==e?(L=ht(),L===e&&(L=null),L!==e?(A=pr(),A!==e?(ne=x,P=I(P,A),x=P):(C=x,x=e)):(C=x,x=e)):(C=x,x=e),x}function PS(){var x,P,L,A;if(x=C,N.test(i.charAt(C))?(P=i.charAt(C),C++):(P=e,Ce===0&&Pt(_)),P!==e){for(L=[],A=He();A!==e;)L.push(A),A=He();L!==e?(A=OS(),A!==e?(ne=x,P=m(P,A),x=P):(C=x,x=e)):(C=x,x=e)}else C=x,x=e;return x}function OS(){var x,P,L,A,z,oe;if(x=C,P=hp(),P!==e){for(L=[],A=C,z=ht(),z===e&&(z=null),z!==e?(oe=hp(),oe!==e?(z=[z,oe],A=z):(C=A,A=e)):(C=A,A=e);A!==e;)L.push(A),A=C,z=ht(),z===e&&(z=null),z!==e?(oe=hp(),oe!==e?(z=[z,oe],A=z):(C=A,A=e)):(C=A,A=e);L!==e?(ne=x,P=a(P,L),x=P):(C=x,x=e)}else C=x,x=e;return x}function hp(){var x,P,L,A;return x=C,P=pr(),P!==e?(L=ht(),L===e&&(L=null),L!==e?(A=pr(),A!==e?(ne=x,P=R(P,A),x=P):(C=x,x=e)):(C=x,x=e)):(C=x,x=e),x}function TS(){var x,P,L,A;if(x=C,V.test(i.charAt(C))?(P=i.charAt(C),C++):(P=e,Ce===0&&Pt(U)),P!==e){for(L=[],A=He();A!==e;)L.push(A),A=He();L!==e?(A=CS(),A!==e?(ne=x,P=m(P,A),x=P):(C=x,x=e)):(C=x,x=e)}else C=x,x=e;return x}function CS(){var x,P,L,A,z,oe;if(x=C,P=pr(),P!==e){for(L=[],A=C,z=ht(),z===e&&(z=null),z!==e?(oe=pr(),oe!==e?(z=[z,oe],A=z):(C=A,A=e)):(C=A,A=e);A!==e;)L.push(A),A=C,z=ht(),z===e&&(z=null),z!==e?(oe=pr(),oe!==e?(z=[z,oe],A=z):(C=A,A=e)):(C=A,A=e);L!==e?(ne=x,P=a(P,L),x=P):(C=x,x=e)}else C=x,x=e;return x}function AS(){var x,P,L,A;if(x=C,B.test(i.charAt(C))?(P=i.charAt(C),C++):(P=e,Ce===0&&Pt(q)),P!==e){for(L=[],A=He();A!==e;)L.push(A),A=He();L!==e?(A=MS(),A!==e?(ne=x,P=m(P,A),x=P):(C=x,x=e)):(C=x,x=e)}else C=x,x=e;return x}function MS(){var x,P,L,A,z,oe;if(x=C,P=mp(),P!==e){for(L=[],A=C,z=ht(),z===e&&(z=null),z!==e?(oe=mp(),oe!==e?(z=[z,oe],A=z):(C=A,A=e)):(C=A,A=e);A!==e;)L.push(A),A=C,z=ht(),z===e&&(z=null),z!==e?(oe=mp(),oe!==e?(z=[z,oe],A=z):(C=A,A=e)):(C=A,A=e);L!==e?(ne=x,P=a(P,L),x=P):(C=x,x=e)}else C=x,x=e;return x}function mp(){var x,P,L,A,z,oe,Yn,gp,gc,xp,xc,bp;return x=C,P=rm(),P!==e?(L=ht(),L===e&&(L=null),L!==e?(A=rm(),A!==e?(z=ht(),z===e&&(z=null),z!==e?(oe=$n(),oe!==e?(Yn=ht(),Yn!==e?(gp=om(),gp!==e?(gc=ht(),gc===e&&(gc=null),gc!==e?(xp=om(),xp!==e?(xc=ht(),xc===e&&(xc=null),xc!==e?(bp=pr(),bp!==e?(ne=x,P=j(P,A,oe,gp,xp,bp),x=P):(C=x,x=e)):(C=x,x=e)):(C=x,x=e)):(C=x,x=e)):(C=x,x=e)):(C=x,x=e)):(C=x,x=e)):(C=x,x=e)):(C=x,x=e)):(C=x,x=e)):(C=x,x=e),x}function pr(){var x,P,L,A;return x=C,P=$n(),P!==e?(L=ht(),L===e&&(L=null),L!==e?(A=$n(),A!==e?(ne=x,P=F(P,A),x=P):(C=x,x=e)):(C=x,x=e)):(C=x,x=e),x}function rm(){var x,P;return x=C,P=nm(),P===e&&(P=mn()),P!==e&&(ne=x,P=H(P)),x=P,x}function $n(){var x,P,L,A;return x=C,P=C,L=yp(),L===e&&(L=null),L!==e?(A=nm(),A!==e?(L=[L,A],P=L):(C=P,P=e)):(C=P,P=e),P===e&&(P=C,L=yp(),L===e&&(L=null),L!==e?(A=mn(),A!==e?(L=[L,A],P=L):(C=P,P=e)):(C=P,P=e)),P!==e&&(ne=x,P=W(P)),x=P,x}function om(){var x,P;return x=C,ee.test(i.charAt(C))?(P=i.charAt(C),C++):(P=e,Ce===0&&Pt(te)),P!==e&&(ne=x,P=Y(P)),x=P,x}function ht(){var x,P,L,A,z;if(x=C,P=[],L=He(),L!==e)for(;L!==e;)P.push(L),L=He();else P=e;if(P!==e)if(L=im(),L===e&&(L=null),L!==e){for(A=[],z=He();z!==e;)A.push(z),z=He();A!==e?(P=[P,L,A],x=P):(C=x,x=e)}else C=x,x=e;else C=x,x=e;if(x===e){if(x=C,P=C,L=im(),L!==e){for(A=[],z=He();z!==e;)A.push(z),z=He();A!==e?(L=[L,A],P=L):(C=P,P=e)}else C=P,P=e;P!==e&&(ne=x,P=re()),x=P}return x}function im(){var x;return i.charCodeAt(C)===44?(x=K,C++):(x=e,Ce===0&&Pt(Z)),x}function nm(){var x,P,L,A;return x=C,P=C,L=IS(),L!==e?(A=am(),A===e&&(A=null),A!==e?(L=[L,A],P=L):(C=P,P=e)):(C=P,P=e),P===e&&(P=C,L=mn(),L!==e?(A=am(),A!==e?(L=[L,A],P=L):(C=P,P=e)):(C=P,P=e)),P!==e&&(ne=x,P=Q(P)),x=P,x}function IS(){var x,P,L,A,z;return x=C,P=C,L=mn(),L===e&&(L=null),L!==e?(i.charCodeAt(C)===46?(A=$,C++):(A=e,Ce===0&&Pt(pe)),A!==e?(z=mn(),z!==e?(L=[L,A,z],P=L):(C=P,P=e)):(C=P,P=e)):(C=P,P=e),P===e&&(P=C,L=mn(),L!==e?(i.charCodeAt(C)===46?(A=$,C++):(A=e,Ce===0&&Pt(pe)),A!==e?(L=[L,A],P=L):(C=P,P=e)):(C=P,P=e)),P!==e&&(ne=x,P=Q(P)),x=P,x}function am(){var x,P,L,A,z;return x=C,P=C,le.test(i.charAt(C))?(L=i.charAt(C),C++):(L=e,Ce===0&&Pt(ie)),L!==e?(A=yp(),A===e&&(A=null),A!==e?(z=mn(),z!==e?(L=[L,A,z],P=L):(C=P,P=e)):(C=P,P=e)):(C=P,P=e),P!==e&&(ne=x,P=Q(P)),x=P,x}function yp(){var x;return ue.test(i.charAt(C))?(x=i.charAt(C),C++):(x=e,Ce===0&&Pt(ae)),x}function mn(){var x,P,L;if(x=C,P=[],ge.test(i.charAt(C))?(L=i.charAt(C),C++):(L=e,Ce===0&&Pt(me)),L!==e)for(;L!==e;)P.push(L),ge.test(i.charAt(C))?(L=i.charAt(C),C++):(L=e,Ce===0&&Pt(me));else P=e;return P!==e&&(ne=x,P=ye(P)),x=P,x}function He(){var x,P;return x=C,ve.test(i.charAt(C))?(P=i.charAt(C),C++):(P=e,Ce===0&&Pt(xe)),P!==e&&(ne=x,P=re()),x=P,x}function ES(x,P){if(!P)return[x];for(var L=[x],A=0,z=P.length;A<z;A++)L[A+1]=P[A][1];return L}var yc={m:"moveto",l:"lineto",h:"horizontal lineto",v:"vertical lineto",c:"curveto",s:"smooth curveto",q:"quadratic curveto",t:"smooth quadratic curveto",a:"elliptical arc",z:"closepath"};for(var sm in yc)yc[sm.toUpperCase()]=yc[sm];function Xn(x,P){P||(P=[{}]);for(var L=P.length;L--;){var A={code:x,command:yc[x]};x==x.toLowerCase()&&(A.relative=!0);for(var z in P[L])A[z]=P[L][z];P[L]=A}return P}if(zt=o(),zt!==e&&C===i.length)return zt;throw zt!==e&&C<i.length&&Pt(cp()),zr(Ge,ke<i.length?i.charAt(ke):null,ke<i.length?fn(ke,ke+1):fn(ke,ke))}Jv.exports={SyntaxError:Un,parse:K3}});var zh=el((Rre,t1)=>{var kd=e1().parse;kd.parseSVG=kd;kd.makeAbsolute=Q3;t1.exports=kd;function Q3(i){var t,e={x:0,y:0},r={x:"x0",y:"y0",x1:"x0",y1:"y0",x2:"x0",y2:"y0"};return i.forEach(function(o){o.command==="moveto"&&(t=o),o.x0=e.x,o.y0=e.y;for(var n in r)n in o&&(o[n]+=o.relative?o[r[n]]:0);"x"in o||(o.x=e.x),"y"in o||(o.y=e.y),o.relative=!1,o.code=o.code.toUpperCase(),o.command=="closepath"&&(o.x=t.x,o.y=t.y),e=o}),i}});var pS=el((Oce,dS)=>{dS.exports=function(t,e){for(var r=t.split("."),o=e.split("."),n=0;n<3;n++){var a=Number(r[n]),s=Number(o[n]);if(a>s)return 1;if(s>a)return-1;if(!isNaN(a)&&isNaN(s))return 1;if(isNaN(a)&&!isNaN(s))return-1}return 0}});var EE={};lm(EE,{default:()=>sp});module.exports=VS(EE);var lp=require("three");function bc(i){for(let t of Object.keys(i))i[t]===void 0&&delete i[t];return i}function Ft(i,t){return Object.setPrototypeOf(i,t),i}function vc(i){return Array.isArray(i)?i:[i]}function Sc(i,t){let e=0;for(;e<i.length&&e<t.length;){if(i[e]<t[e])return-1;if(i[e]>t[e])return 1;e+=1}return e!==t.length?-1:e!==i.length?1:0}var zS=typeof global=="object"&&global&&global.Object===Object&&global,wc=zS;var GS=typeof self=="object"&&self&&self.Object===Object&&self,FS=wc||GS||Function("return this")(),Ot=FS;var jS=Ot.Symbol,Yt=jS;var um=Object.prototype,US=um.hasOwnProperty,kS=um.toString,rl=Yt?Yt.toStringTag:void 0;function HS(i){var t=US.call(i,rl),e=i[rl];try{i[rl]=void 0;var r=!0}catch{}var o=kS.call(i);return r&&(t?i[rl]=e:delete i[rl]),o}var dm=HS;var WS=Object.prototype,qS=WS.toString;function $S(i){return qS.call(i)}var pm=$S;var XS="[object Null]",YS="[object Undefined]",fm=Yt?Yt.toStringTag:void 0;function KS(i){return i==null?i===void 0?YS:XS:fm&&fm in Object(i)?dm(i):pm(i)}var Nr=KS;function QS(i){return i!=null&&typeof i=="object"}var rr=QS;var ZS="[object Symbol]";function JS(i){return typeof i=="symbol"||rr(i)&&Nr(i)==ZS}var Si=JS;function ew(i,t){for(var e=-1,r=i==null?0:i.length,o=Array(r);++e<r;)o[e]=t(i[e],e,i);return o}var Pc=ew;var tw=Array.isArray,Tt=tw;var rw=1/0,hm=Yt?Yt.prototype:void 0,mm=hm?hm.toString:void 0;function ym(i){if(typeof i=="string")return i;if(Tt(i))return Pc(i,ym)+"";if(Si(i))return mm?mm.call(i):"";var t=i+"";return t=="0"&&1/i==-rw?"-0":t}var gm=ym;var ow=/\s/;function iw(i){for(var t=i.length;t--&&ow.test(i.charAt(t)););return t}var xm=iw;var nw=/^\s+/;function aw(i){return i&&i.slice(0,xm(i)+1).replace(nw,"")}var bm=aw;function sw(i){var t=typeof i;return i!=null&&(t=="object"||t=="function")}var Ct=sw;var vm=0/0,lw=/^[-+]0x[0-9a-f]+$/i,cw=/^0b[01]+$/i,uw=/^0o[0-7]+$/i,dw=parseInt;function pw(i){if(typeof i=="number")return i;if(Si(i))return vm;if(Ct(i)){var t=typeof i.valueOf=="function"?i.valueOf():i;i=Ct(t)?t+"":t}if(typeof i!="string")return i===0?i:+i;i=bm(i);var e=cw.test(i);return e||uw.test(i)?dw(i.slice(2),e?2:8):lw.test(i)?vm:+i}var vp=pw;function fw(i){return i}var Sm=fw;var hw="[object AsyncFunction]",mw="[object Function]",yw="[object GeneratorFunction]",gw="[object Proxy]";function xw(i){if(!Ct(i))return!1;var t=Nr(i);return t==mw||t==yw||t==hw||t==gw}var Oc=xw;var bw=Ot["__core-js_shared__"],Tc=bw;var wm=function(){var i=/[^.]+$/.exec(Tc&&Tc.keys&&Tc.keys.IE_PROTO||"");return i?"Symbol(src)_1."+i:""}();function vw(i){return!!wm&&wm in i}var Pm=vw;var Sw=Function.prototype,ww=Sw.toString;function Pw(i){if(i!=null){try{return ww.call(i)}catch{}try{return i+""}catch{}}return""}var Xo=Pw;var Ow=/[\\^$.*+?()[\]{}|]/g,Tw=/^\[object .+?Constructor\]$/,Cw=Function.prototype,Aw=Object.prototype,Mw=Cw.toString,Iw=Aw.hasOwnProperty,Ew=RegExp("^"+Mw.call(Iw).replace(Ow,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Nw(i){if(!Ct(i)||Pm(i))return!1;var t=Oc(i)?Ew:Tw;return t.test(Xo(i))}var Om=Nw;function Dw(i,t){return i?.[t]}var Tm=Dw;function _w(i,t){var e=Tm(i,t);return Om(e)?e:void 0}var br=_w;var Rw=br(Ot,"WeakMap"),Cc=Rw;var Cm=Object.create,Lw=function(){function i(){}return function(t){if(!Ct(t))return{};if(Cm)return Cm(t);i.prototype=t;var e=new i;return i.prototype=void 0,e}}(),Am=Lw;function Bw(i,t,e){switch(e.length){case 0:return i.call(t);case 1:return i.call(t,e[0]);case 2:return i.call(t,e[0],e[1]);case 3:return i.call(t,e[0],e[1],e[2])}return i.apply(t,e)}var Mm=Bw;function Vw(i,t){var e=-1,r=i.length;for(t||(t=Array(r));++e<r;)t[e]=i[e];return t}var Im=Vw;var zw=800,Gw=16,Fw=Date.now;function jw(i){var t=0,e=0;return function(){var r=Fw(),o=Gw-(r-e);if(e=r,o>0){if(++t>=zw)return arguments[0]}else t=0;return i.apply(void 0,arguments)}}var Em=jw;function Uw(i){return function(){return i}}var Nm=Uw;var kw=function(){try{var i=br(Object,"defineProperty");return i({},"",{}),i}catch{}}(),Kn=kw;var Hw=Kn?function(i,t){return Kn(i,"toString",{configurable:!0,enumerable:!1,value:Nm(t),writable:!0})}:Sm,Dm=Hw;var Ww=Em(Dm),_m=Ww;function qw(i,t){for(var e=-1,r=i==null?0:i.length;++e<r&&t(i[e],e,i)!==!1;);return i}var Rm=qw;var $w=9007199254740991,Xw=/^(?:0|[1-9]\d*)$/;function Yw(i,t){var e=typeof i;return t=t??$w,!!t&&(e=="number"||e!="symbol"&&Xw.test(i))&&i>-1&&i%1==0&&i<t}var Qn=Yw;function Kw(i,t,e){t=="__proto__"&&Kn?Kn(i,t,{configurable:!0,enumerable:!0,value:e,writable:!0}):i[t]=e}var Ac=Kw;function Qw(i,t){return i===t||i!==i&&t!==t}var Zn=Qw;var Zw=Object.prototype,Jw=Zw.hasOwnProperty;function e2(i,t,e){var r=i[t];(!(Jw.call(i,t)&&Zn(r,e))||e===void 0&&!(t in i))&&Ac(i,t,e)}var Jn=e2;function t2(i,t,e,r){var o=!e;e||(e={});for(var n=-1,a=t.length;++n<a;){var s=t[n],l=r?r(e[s],i[s],s,e,i):void 0;l===void 0&&(l=i[s]),o?Ac(e,s,l):Jn(e,s,l)}return e}var So=t2;var Lm=Math.max;function r2(i,t,e){return t=Lm(t===void 0?i.length-1:t,0),function(){for(var r=arguments,o=-1,n=Lm(r.length-t,0),a=Array(n);++o<n;)a[o]=r[t+o];o=-1;for(var s=Array(t+1);++o<t;)s[o]=r[o];return s[t]=e(a),Mm(i,this,s)}}var Bm=r2;var o2=9007199254740991;function i2(i){return typeof i=="number"&&i>-1&&i%1==0&&i<=o2}var ea=i2;function n2(i){return i!=null&&ea(i.length)&&!Oc(i)}var Mc=n2;var a2=Object.prototype;function s2(i){var t=i&&i.constructor,e=typeof t=="function"&&t.prototype||a2;return i===e}var ta=s2;function l2(i,t){for(var e=-1,r=Array(i);++e<i;)r[e]=t(e);return r}var Vm=l2;var c2="[object Arguments]";function u2(i){return rr(i)&&Nr(i)==c2}var Sp=u2;var zm=Object.prototype,d2=zm.hasOwnProperty,p2=zm.propertyIsEnumerable,f2=Sp(function(){return arguments}())?Sp:function(i){return rr(i)&&d2.call(i,"callee")&&!p2.call(i,"callee")},ra=f2;function h2(){return!1}var Gm=h2;var Um=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Fm=Um&&typeof module=="object"&&module&&!module.nodeType&&module,m2=Fm&&Fm.exports===Um,jm=m2?Ot.Buffer:void 0,y2=jm?jm.isBuffer:void 0,g2=y2||Gm,gn=g2;var x2="[object Arguments]",b2="[object Array]",v2="[object Boolean]",S2="[object Date]",w2="[object Error]",P2="[object Function]",O2="[object Map]",T2="[object Number]",C2="[object Object]",A2="[object RegExp]",M2="[object Set]",I2="[object String]",E2="[object WeakMap]",N2="[object ArrayBuffer]",D2="[object DataView]",_2="[object Float32Array]",R2="[object Float64Array]",L2="[object Int8Array]",B2="[object Int16Array]",V2="[object Int32Array]",z2="[object Uint8Array]",G2="[object Uint8ClampedArray]",F2="[object Uint16Array]",j2="[object Uint32Array]",mt={};mt[_2]=mt[R2]=mt[L2]=mt[B2]=mt[V2]=mt[z2]=mt[G2]=mt[F2]=mt[j2]=!0;mt[x2]=mt[b2]=mt[N2]=mt[v2]=mt[D2]=mt[S2]=mt[w2]=mt[P2]=mt[O2]=mt[T2]=mt[C2]=mt[A2]=mt[M2]=mt[I2]=mt[E2]=!1;function U2(i){return rr(i)&&ea(i.length)&&!!mt[Nr(i)]}var km=U2;function k2(i){return function(t){return i(t)}}var oa=k2;var Hm=typeof exports=="object"&&exports&&!exports.nodeType&&exports,ol=Hm&&typeof module=="object"&&module&&!module.nodeType&&module,H2=ol&&ol.exports===Hm,wp=H2&&wc.process,W2=function(){try{var i=ol&&ol.require&&ol.require("util").types;return i||wp&&wp.binding&&wp.binding("util")}catch{}}(),Yo=W2;var Wm=Yo&&Yo.isTypedArray,q2=Wm?oa(Wm):km,Ic=q2;var $2=Object.prototype,X2=$2.hasOwnProperty;function Y2(i,t){var e=Tt(i),r=!e&&ra(i),o=!e&&!r&&gn(i),n=!e&&!r&&!o&&Ic(i),a=e||r||o||n,s=a?Vm(i.length,String):[],l=s.length;for(var c in i)(t||X2.call(i,c))&&!(a&&(c=="length"||o&&(c=="offset"||c=="parent")||n&&(c=="buffer"||c=="byteLength"||c=="byteOffset")||Qn(c,l)))&&s.push(c);return s}var Ec=Y2;function K2(i,t){return function(e){return i(t(e))}}var Nc=K2;var Q2=Nc(Object.keys,Object),qm=Q2;var Z2=Object.prototype,J2=Z2.hasOwnProperty;function eP(i){if(!ta(i))return qm(i);var t=[];for(var e in Object(i))J2.call(i,e)&&e!="constructor"&&t.push(e);return t}var $m=eP;function tP(i){return Mc(i)?Ec(i):$m(i)}var ia=tP;function rP(i){var t=[];if(i!=null)for(var e in Object(i))t.push(e);return t}var Xm=rP;var oP=Object.prototype,iP=oP.hasOwnProperty;function nP(i){if(!Ct(i))return Xm(i);var t=ta(i),e=[];for(var r in i)r=="constructor"&&(t||!iP.call(i,r))||e.push(r);return e}var Ym=nP;function aP(i){return Mc(i)?Ec(i,!0):Ym(i)}var na=aP;var sP=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,lP=/^\w*$/;function cP(i,t){if(Tt(i))return!1;var e=typeof i;return e=="number"||e=="symbol"||e=="boolean"||i==null||Si(i)?!0:lP.test(i)||!sP.test(i)||t!=null&&i in Object(t)}var Km=cP;var uP=br(Object,"create"),Ko=uP;function dP(){this.__data__=Ko?Ko(null):{},this.size=0}var Qm=dP;function pP(i){var t=this.has(i)&&delete this.__data__[i];return this.size-=t?1:0,t}var Zm=pP;var fP="__lodash_hash_undefined__",hP=Object.prototype,mP=hP.hasOwnProperty;function yP(i){var t=this.__data__;if(Ko){var e=t[i];return e===fP?void 0:e}return mP.call(t,i)?t[i]:void 0}var Jm=yP;var gP=Object.prototype,xP=gP.hasOwnProperty;function bP(i){var t=this.__data__;return Ko?t[i]!==void 0:xP.call(t,i)}var ey=bP;var vP="__lodash_hash_undefined__";function SP(i,t){var e=this.__data__;return this.size+=this.has(i)?0:1,e[i]=Ko&&t===void 0?vP:t,this}var ty=SP;function aa(i){var t=-1,e=i==null?0:i.length;for(this.clear();++t<e;){var r=i[t];this.set(r[0],r[1])}}aa.prototype.clear=Qm;aa.prototype.delete=Zm;aa.prototype.get=Jm;aa.prototype.has=ey;aa.prototype.set=ty;var Pp=aa;function wP(){this.__data__=[],this.size=0}var ry=wP;function PP(i,t){for(var e=i.length;e--;)if(Zn(i[e][0],t))return e;return-1}var wi=PP;var OP=Array.prototype,TP=OP.splice;function CP(i){var t=this.__data__,e=wi(t,i);if(e<0)return!1;var r=t.length-1;return e==r?t.pop():TP.call(t,e,1),--this.size,!0}var oy=CP;function AP(i){var t=this.__data__,e=wi(t,i);return e<0?void 0:t[e][1]}var iy=AP;function MP(i){return wi(this.__data__,i)>-1}var ny=MP;function IP(i,t){var e=this.__data__,r=wi(e,i);return r<0?(++this.size,e.push([i,t])):e[r][1]=t,this}var ay=IP;function sa(i){var t=-1,e=i==null?0:i.length;for(this.clear();++t<e;){var r=i[t];this.set(r[0],r[1])}}sa.prototype.clear=ry;sa.prototype.delete=oy;sa.prototype.get=iy;sa.prototype.has=ny;sa.prototype.set=ay;var Pi=sa;var EP=br(Ot,"Map"),Oi=EP;function NP(){this.size=0,this.__data__={hash:new Pp,map:new(Oi||Pi),string:new Pp}}var sy=NP;function DP(i){var t=typeof i;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?i!=="__proto__":i===null}var ly=DP;function _P(i,t){var e=i.__data__;return ly(t)?e[typeof t=="string"?"string":"hash"]:e.map}var Ti=_P;function RP(i){var t=Ti(this,i).delete(i);return this.size-=t?1:0,t}var cy=RP;function LP(i){return Ti(this,i).get(i)}var uy=LP;function BP(i){return Ti(this,i).has(i)}var dy=BP;function VP(i,t){var e=Ti(this,i),r=e.size;return e.set(i,t),this.size+=e.size==r?0:1,this}var py=VP;function la(i){var t=-1,e=i==null?0:i.length;for(this.clear();++t<e;){var r=i[t];this.set(r[0],r[1])}}la.prototype.clear=sy;la.prototype.delete=cy;la.prototype.get=uy;la.prototype.has=dy;la.prototype.set=py;var xn=la;var zP="Expected a function";function Op(i,t){if(typeof i!="function"||t!=null&&typeof t!="function")throw new TypeError(zP);var e=function(){var r=arguments,o=t?t.apply(this,r):r[0],n=e.cache;if(n.has(o))return n.get(o);var a=i.apply(this,r);return e.cache=n.set(o,a)||n,a};return e.cache=new(Op.Cache||xn),e}Op.Cache=xn;var fy=Op;var GP=500;function FP(i){var t=fy(i,function(r){return e.size===GP&&e.clear(),r}),e=t.cache;return t}var hy=FP;var jP=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,UP=/\\(\\)?/g,kP=hy(function(i){var t=[];return i.charCodeAt(0)===46&&t.push(""),i.replace(jP,function(e,r,o,n){t.push(o?n.replace(UP,"$1"):r||e)}),t}),my=kP;function HP(i){return i==null?"":gm(i)}var yy=HP;function WP(i,t){return Tt(i)?i:Km(i,t)?[i]:my(yy(i))}var Gr=WP;var qP=1/0;function $P(i){if(typeof i=="string"||Si(i))return i;var t=i+"";return t=="0"&&1/i==-qP?"-0":t}var Ci=$P;function XP(i,t){t=Gr(t,i);for(var e=0,r=t.length;i!=null&&e<r;)i=i[Ci(t[e++])];return e&&e==r?i:void 0}var Dc=XP;function YP(i,t){for(var e=-1,r=t.length,o=i.length;++e<r;)i[o+e]=t[e];return i}var ca=YP;var gy=Yt?Yt.isConcatSpreadable:void 0;function KP(i){return Tt(i)||ra(i)||!!(gy&&i&&i[gy])}var xy=KP;function by(i,t,e,r,o){var n=-1,a=i.length;for(e||(e=xy),o||(o=[]);++n<a;){var s=i[n];t>0&&e(s)?t>1?by(s,t-1,e,r,o):ca(o,s):r||(o[o.length]=s)}return o}var vy=by;function QP(i){var t=i==null?0:i.length;return t?vy(i,1):[]}var Sy=QP;function ZP(i){return _m(Bm(i,void 0,Sy),i+"")}var _c=ZP;var JP=Nc(Object.getPrototypeOf,Object),ua=JP;var eO="[object Object]",tO=Function.prototype,rO=Object.prototype,wy=tO.toString,oO=rO.hasOwnProperty,iO=wy.call(Object);function nO(i){if(!rr(i)||Nr(i)!=eO)return!1;var t=ua(i);if(t===null)return!0;var e=oO.call(t,"constructor")&&t.constructor;return typeof e=="function"&&e instanceof e&&wy.call(e)==iO}var Py=nO;function aO(i,t,e){var r=-1,o=i.length;t<0&&(t=-t>o?0:o+t),e=e>o?o:e,e<0&&(e+=o),o=t>e?0:e-t>>>0,t>>>=0;for(var n=Array(o);++r<o;)n[r]=i[r+t];return n}var Oy=aO;function sO(){this.__data__=new Pi,this.size=0}var Ty=sO;function lO(i){var t=this.__data__,e=t.delete(i);return this.size=t.size,e}var Cy=lO;function cO(i){return this.__data__.get(i)}var Ay=cO;function uO(i){return this.__data__.has(i)}var My=uO;var dO=200;function pO(i,t){var e=this.__data__;if(e instanceof Pi){var r=e.__data__;if(!Oi||r.length<dO-1)return r.push([i,t]),this.size=++e.size,this;e=this.__data__=new xn(r)}return e.set(i,t),this.size=e.size,this}var Iy=pO;function da(i){var t=this.__data__=new Pi(i);this.size=t.size}da.prototype.clear=Ty;da.prototype.delete=Cy;da.prototype.get=Ay;da.prototype.has=My;da.prototype.set=Iy;var pa=da;function fO(i,t){return i&&So(t,ia(t),i)}var Ey=fO;function hO(i,t){return i&&So(t,na(t),i)}var Ny=hO;var Ly=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Dy=Ly&&typeof module=="object"&&module&&!module.nodeType&&module,mO=Dy&&Dy.exports===Ly,_y=mO?Ot.Buffer:void 0,Ry=_y?_y.allocUnsafe:void 0;function yO(i,t){if(t)return i.slice();var e=i.length,r=Ry?Ry(e):new i.constructor(e);return i.copy(r),r}var By=yO;function gO(i,t){for(var e=-1,r=i==null?0:i.length,o=0,n=[];++e<r;){var a=i[e];t(a,e,i)&&(n[o++]=a)}return n}var Vy=gO;function xO(){return[]}var Rc=xO;var bO=Object.prototype,vO=bO.propertyIsEnumerable,zy=Object.getOwnPropertySymbols,SO=zy?function(i){return i==null?[]:(i=Object(i),Vy(zy(i),function(t){return vO.call(i,t)}))}:Rc,fa=SO;function wO(i,t){return So(i,fa(i),t)}var Gy=wO;var PO=Object.getOwnPropertySymbols,OO=PO?function(i){for(var t=[];i;)ca(t,fa(i)),i=ua(i);return t}:Rc,Lc=OO;function TO(i,t){return So(i,Lc(i),t)}var Fy=TO;function CO(i,t,e){var r=t(i);return Tt(i)?r:ca(r,e(i))}var Bc=CO;function AO(i){return Bc(i,ia,fa)}var il=AO;function MO(i){return Bc(i,na,Lc)}var Vc=MO;var IO=br(Ot,"DataView"),zc=IO;var EO=br(Ot,"Promise"),Gc=EO;var NO=br(Ot,"Set"),Fc=NO;var jy="[object Map]",DO="[object Object]",Uy="[object Promise]",ky="[object Set]",Hy="[object WeakMap]",Wy="[object DataView]",_O=Xo(zc),RO=Xo(Oi),LO=Xo(Gc),BO=Xo(Fc),VO=Xo(Cc),bn=Nr;(zc&&bn(new zc(new ArrayBuffer(1)))!=Wy||Oi&&bn(new Oi)!=jy||Gc&&bn(Gc.resolve())!=Uy||Fc&&bn(new Fc)!=ky||Cc&&bn(new Cc)!=Hy)&&(bn=function(i){var t=Nr(i),e=t==DO?i.constructor:void 0,r=e?Xo(e):"";if(r)switch(r){case _O:return Wy;case RO:return jy;case LO:return Uy;case BO:return ky;case VO:return Hy}return t});var Qo=bn;var zO=Object.prototype,GO=zO.hasOwnProperty;function FO(i){var t=i.length,e=new i.constructor(t);return t&&typeof i[0]=="string"&&GO.call(i,"index")&&(e.index=i.index,e.input=i.input),e}var qy=FO;var jO=Ot.Uint8Array,ha=jO;function UO(i){var t=new i.constructor(i.byteLength);return new ha(t).set(new ha(i)),t}var ma=UO;function kO(i,t){var e=t?ma(i.buffer):i.buffer;return new i.constructor(e,i.byteOffset,i.byteLength)}var $y=kO;var HO=/\w*$/;function WO(i){var t=new i.constructor(i.source,HO.exec(i));return t.lastIndex=i.lastIndex,t}var Xy=WO;var Yy=Yt?Yt.prototype:void 0,Ky=Yy?Yy.valueOf:void 0;function qO(i){return Ky?Object(Ky.call(i)):{}}var Qy=qO;function $O(i,t){var e=t?ma(i.buffer):i.buffer;return new i.constructor(e,i.byteOffset,i.length)}var Zy=$O;var XO="[object Boolean]",YO="[object Date]",KO="[object Map]",QO="[object Number]",ZO="[object RegExp]",JO="[object Set]",eT="[object String]",tT="[object Symbol]",rT="[object ArrayBuffer]",oT="[object DataView]",iT="[object Float32Array]",nT="[object Float64Array]",aT="[object Int8Array]",sT="[object Int16Array]",lT="[object Int32Array]",cT="[object Uint8Array]",uT="[object Uint8ClampedArray]",dT="[object Uint16Array]",pT="[object Uint32Array]";function fT(i,t,e){var r=i.constructor;switch(t){case rT:return ma(i);case XO:case YO:return new r(+i);case oT:return $y(i,e);case iT:case nT:case aT:case sT:case lT:case cT:case uT:case dT:case pT:return Zy(i,e);case KO:return new r;case QO:case eT:return new r(i);case ZO:return Xy(i);case JO:return new r;case tT:return Qy(i)}}var Jy=fT;function hT(i){return typeof i.constructor=="function"&&!ta(i)?Am(ua(i)):{}}var eg=hT;var mT="[object Map]";function yT(i){return rr(i)&&Qo(i)==mT}var tg=yT;var rg=Yo&&Yo.isMap,gT=rg?oa(rg):tg,og=gT;var xT="[object Set]";function bT(i){return rr(i)&&Qo(i)==xT}var ig=bT;var ng=Yo&&Yo.isSet,vT=ng?oa(ng):ig,ag=vT;var ST=1,wT=2,PT=4,sg="[object Arguments]",OT="[object Array]",TT="[object Boolean]",CT="[object Date]",AT="[object Error]",lg="[object Function]",MT="[object GeneratorFunction]",IT="[object Map]",ET="[object Number]",cg="[object Object]",NT="[object RegExp]",DT="[object Set]",_T="[object String]",RT="[object Symbol]",LT="[object WeakMap]",BT="[object ArrayBuffer]",VT="[object DataView]",zT="[object Float32Array]",GT="[object Float64Array]",FT="[object Int8Array]",jT="[object Int16Array]",UT="[object Int32Array]",kT="[object Uint8Array]",HT="[object Uint8ClampedArray]",WT="[object Uint16Array]",qT="[object Uint32Array]",dt={};dt[sg]=dt[OT]=dt[BT]=dt[VT]=dt[TT]=dt[CT]=dt[zT]=dt[GT]=dt[FT]=dt[jT]=dt[UT]=dt[IT]=dt[ET]=dt[cg]=dt[NT]=dt[DT]=dt[_T]=dt[RT]=dt[kT]=dt[HT]=dt[WT]=dt[qT]=!0;dt[AT]=dt[lg]=dt[LT]=!1;function jc(i,t,e,r,o,n){var a,s=t&ST,l=t&wT,c=t&PT;if(e&&(a=o?e(i,r,o,n):e(i)),a!==void 0)return a;if(!Ct(i))return i;var u=Tt(i);if(u){if(a=qy(i),!s)return Im(i,a)}else{var p=Qo(i),d=p==lg||p==MT;if(gn(i))return By(i,s);if(p==cg||p==sg||d&&!o){if(a=l||d?{}:eg(i),!s)return l?Fy(i,Ny(a,i)):Gy(i,Ey(a,i))}else{if(!dt[p])return o?i:{};a=Jy(i,p,s)}}n||(n=new pa);var f=n.get(i);if(f)return f;n.set(i,a),ag(i)?i.forEach(function(y){a.add(jc(y,t,e,y,i,n))}):og(i)&&i.forEach(function(y,b){a.set(b,jc(y,t,e,b,i,n))});var h=c?l?Vc:il:l?na:ia,m=u?void 0:h(i);return Rm(m||i,function(y,b){m&&(b=y,y=i[b]),Jn(a,b,jc(y,t,e,b,i,n))}),a}var Uc=jc;var $T=1,XT=4;function YT(i){return Uc(i,$T|XT)}var Zo=YT;var KT="__lodash_hash_undefined__";function QT(i){return this.__data__.set(i,KT),this}var ug=QT;function ZT(i){return this.__data__.has(i)}var dg=ZT;function kc(i){var t=-1,e=i==null?0:i.length;for(this.__data__=new xn;++t<e;)this.add(i[t])}kc.prototype.add=kc.prototype.push=ug;kc.prototype.has=dg;var pg=kc;function JT(i,t){for(var e=-1,r=i==null?0:i.length;++e<r;)if(t(i[e],e,i))return!0;return!1}var fg=JT;function eC(i,t){return i.has(t)}var hg=eC;var tC=1,rC=2;function oC(i,t,e,r,o,n){var a=e&tC,s=i.length,l=t.length;if(s!=l&&!(a&&l>s))return!1;var c=n.get(i),u=n.get(t);if(c&&u)return c==t&&u==i;var p=-1,d=!0,f=e&rC?new pg:void 0;for(n.set(i,t),n.set(t,i);++p<s;){var h=i[p],m=t[p];if(r)var y=a?r(m,h,p,t,i,n):r(h,m,p,i,t,n);if(y!==void 0){if(y)continue;d=!1;break}if(f){if(!fg(t,function(b,v){if(!hg(f,v)&&(h===b||o(h,b,e,r,n)))return f.push(v)})){d=!1;break}}else if(!(h===m||o(h,m,e,r,n))){d=!1;break}}return n.delete(i),n.delete(t),d}var Hc=oC;function iC(i){var t=-1,e=Array(i.size);return i.forEach(function(r,o){e[++t]=[o,r]}),e}var mg=iC;function nC(i){var t=-1,e=Array(i.size);return i.forEach(function(r){e[++t]=r}),e}var yg=nC;var aC=1,sC=2,lC="[object Boolean]",cC="[object Date]",uC="[object Error]",dC="[object Map]",pC="[object Number]",fC="[object RegExp]",hC="[object Set]",mC="[object String]",yC="[object Symbol]",gC="[object ArrayBuffer]",xC="[object DataView]",gg=Yt?Yt.prototype:void 0,Tp=gg?gg.valueOf:void 0;function bC(i,t,e,r,o,n,a){switch(e){case xC:if(i.byteLength!=t.byteLength||i.byteOffset!=t.byteOffset)return!1;i=i.buffer,t=t.buffer;case gC:return!(i.byteLength!=t.byteLength||!n(new ha(i),new ha(t)));case lC:case cC:case pC:return Zn(+i,+t);case uC:return i.name==t.name&&i.message==t.message;case fC:case mC:return i==t+"";case dC:var s=mg;case hC:var l=r&aC;if(s||(s=yg),i.size!=t.size&&!l)return!1;var c=a.get(i);if(c)return c==t;r|=sC,a.set(i,t);var u=Hc(s(i),s(t),r,o,n,a);return a.delete(i),u;case yC:if(Tp)return Tp.call(i)==Tp.call(t)}return!1}var xg=bC;var vC=1,SC=Object.prototype,wC=SC.hasOwnProperty;function PC(i,t,e,r,o,n){var a=e&vC,s=il(i),l=s.length,c=il(t),u=c.length;if(l!=u&&!a)return!1;for(var p=l;p--;){var d=s[p];if(!(a?d in t:wC.call(t,d)))return!1}var f=n.get(i),h=n.get(t);if(f&&h)return f==t&&h==i;var m=!0;n.set(i,t),n.set(t,i);for(var y=a;++p<l;){d=s[p];var b=i[d],v=t[d];if(r)var w=a?r(v,b,d,t,i,n):r(b,v,d,i,t,n);if(!(w===void 0?b===v||o(b,v,e,r,n):w)){m=!1;break}y||(y=d=="constructor")}if(m&&!y){var O=i.constructor,S=t.constructor;O!=S&&"constructor"in i&&"constructor"in t&&!(typeof O=="function"&&O instanceof O&&typeof S=="function"&&S instanceof S)&&(m=!1)}return n.delete(i),n.delete(t),m}var bg=PC;var OC=1,vg="[object Arguments]",Sg="[object Array]",Wc="[object Object]",TC=Object.prototype,wg=TC.hasOwnProperty;function CC(i,t,e,r,o,n){var a=Tt(i),s=Tt(t),l=a?Sg:Qo(i),c=s?Sg:Qo(t);l=l==vg?Wc:l,c=c==vg?Wc:c;var u=l==Wc,p=c==Wc,d=l==c;if(d&&gn(i)){if(!gn(t))return!1;a=!0,u=!1}if(d&&!u)return n||(n=new pa),a||Ic(i)?Hc(i,t,e,r,o,n):xg(i,t,l,e,r,o,n);if(!(e&OC)){var f=u&&wg.call(i,"__wrapped__"),h=p&&wg.call(t,"__wrapped__");if(f||h){var m=f?i.value():i,y=h?t.value():t;return n||(n=new pa),o(m,y,e,r,n)}}return d?(n||(n=new pa),bg(i,t,e,r,o,n)):!1}var Pg=CC;function Og(i,t,e,r,o){return i===t?!0:i==null||t==null||!rr(i)&&!rr(t)?i!==i&&t!==t:Pg(i,t,e,r,Og,o)}var Tg=Og;function AC(i,t){return i!=null&&t in Object(i)}var Cg=AC;function MC(i,t,e){t=Gr(t,i);for(var r=-1,o=t.length,n=!1;++r<o;){var a=Ci(t[r]);if(!(n=i!=null&&e(i,a)))break;i=i[a]}return n||++r!=o?n:(o=i==null?0:i.length,!!o&&ea(o)&&Qn(a,o)&&(Tt(i)||ra(i)))}var Ag=MC;function IC(i,t){return i!=null&&Ag(i,t,Cg)}var Mg=IC;var EC=function(){return Ot.Date.now()},qc=EC;var NC="Expected a function",DC=Math.max,_C=Math.min;function RC(i,t,e){var r,o,n,a,s,l,c=0,u=!1,p=!1,d=!0;if(typeof i!="function")throw new TypeError(NC);t=vp(t)||0,Ct(e)&&(u=!!e.leading,p="maxWait"in e,n=p?DC(vp(e.maxWait)||0,t):n,d="trailing"in e?!!e.trailing:d);function f(T){var M=r,g=o;return r=o=void 0,c=T,a=i.apply(g,M),a}function h(T){return c=T,s=setTimeout(b,t),u?f(T):a}function m(T){var M=T-l,g=T-c,D=t-M;return p?_C(D,n-g):D}function y(T){var M=T-l,g=T-c;return l===void 0||M>=t||M<0||p&&g>=n}function b(){var T=qc();if(y(T))return v(T);s=setTimeout(b,m(T))}function v(T){return s=void 0,d&&r?f(T):(r=o=void 0,a)}function w(){s!==void 0&&clearTimeout(s),c=0,r=l=o=s=void 0}function O(){return s===void 0?a:v(qc())}function S(){var T=qc(),M=y(T);if(r=arguments,o=this,l=T,M){if(s===void 0)return h(l);if(p)return clearTimeout(s),s=setTimeout(b,t),f(l)}return s===void 0&&(s=setTimeout(b,t)),a}return S.cancel=w,S.flush=O,S}var $c=RC;function LC(i){var t=i==null?0:i.length;return t?i[t-1]:void 0}var Ig=LC;function BC(i,t){return t.length<2?i:Dc(i,Oy(t,0,-1))}var Eg=BC;function VC(i,t){return Tg(i,t)}var Cp=VC;function zC(i,t){return t=Gr(t,i),i=Eg(i,t),i==null||delete i[Ci(Ig(t))]}var Ng=zC;function GC(i){return Py(i)?void 0:i}var Dg=GC;var FC=1,jC=2,UC=4,kC=_c(function(i,t){var e={};if(i==null)return e;var r=!1;t=Pc(t,function(n){return n=Gr(n,i),r||(r=n.length>1),n}),So(i,Vc(i),e),r&&(e=Uc(e,FC|jC|UC,Dg));for(var o=t.length;o--;)Ng(e,t[o]);return e}),ya=kC;function HC(i,t,e,r){if(!Ct(i))return i;t=Gr(t,i);for(var o=-1,n=t.length,a=n-1,s=i;s!=null&&++o<n;){var l=Ci(t[o]),c=e;if(l==="__proto__"||l==="constructor"||l==="prototype")return i;if(o!=a){var u=s[l];c=r?r(u,l,s):void 0,c===void 0&&(c=Ct(u)?u:Qn(t[o+1])?[]:{})}Jn(s,l,c),s=s[l]}return i}var _g=HC;function WC(i,t,e){for(var r=-1,o=t.length,n={};++r<o;){var a=t[r],s=Dc(i,a);e(s,a)&&_g(n,Gr(a,i),s)}return n}var Rg=WC;function qC(i,t){return Rg(i,t,function(e,r){return Mg(i,r)})}var Lg=qC;var $C=_c(function(i,t){return i==null?{}:Lg(i,t)}),ro=$C;var de=class{modifyById(t,e){let r=this;if(r[t]===void 0)throw new Error("not expected");{let n={...r,[t]:e};return Object.setPrototypeOf(n,de.prototype),n}}add(t,e){return this.runOp({type:1,id:t,data:e})?.data??this}runOp(t){let e=this;if(t.type===1){let r=e[t.id],o;r===void 0?o={type:2,id:t.id}:o={type:1,id:t.id,data:r};let{id:n,data:a}=t,s={...e,[n]:a};return Object.setPrototypeOf(s,de.prototype),{data:s,actual:t,reverse:o}}else if(t.type===2){let{id:r}=t,o=e[r];if(o===void 0)return null;{let n={...e};return Object.setPrototypeOf(n,de.prototype),delete n[r],{data:n,actual:t,reverse:{type:1,id:r,data:o}}}}return null}};function nl(i){if(i.deepFreeze!==void 0){i.deepFreeze(i);return}let t=Object.getOwnPropertyNames(i);for(let e of t){let r=i[e];r&&typeof r=="object"&&nl(r)}return Object.freeze(i)}function Bg(i,t){let e=0;for(;e<i.length&&e<t.length;){if(i[e]<t[e])return-1;if(i[e]>t[e])return 1;e+=1}return e!==t.length?-1:e!==i.length?1:0}var ga=class extends Error{};function Xc(i){let t={...i};return Object.setPrototypeOf(t,Object.getPrototypeOf(i)),t}function wo(i,t,e){if(i===void 0?t===void 0?(i=0,t=10):i=t-10:t===void 0&&(t=i+10),i>t){let n=i;i=t,t=n}let r=[],o=1/(e+1);for(let n=0;n<e;n++){let a=i+(t-i)*(n+.75+Math.random()*.5)*o;r.push(a)}return r}function xa(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 Vg(){return typeof process<"u"}function zg(i,t){for(let e of i)t(e.id,e.data)!==!0&&zg(e.children,t)}function Gg(i,t){if(t(i.id,i.data)!==!0)for(let e of i.children)Gg(e,t)}var ct=class extends Array{constructor(...e){super(...e);Object.setPrototypeOf(this,ct.prototype)}deepFreeze(){let e=0;for(;e<this.length;)nl(this[e]),e++}fillCaches0(e,r){this.objCaches.set(e.id,e),this.parentCaches.set(e.id,r);for(let o of e.children)this.fillCaches0(o,e.id)}fillCaches(){if(this.objCaches===void 0){this.objCaches=new Map,this.parentCaches=new Map;for(let e of this)this.fillCaches0(e,null)}}randomId(){this.fillCaches();let e=Array.from(this.objCaches.keys());if(e.length!==0)return e[Math.max(0,Math.floor(Math.random()*e.length)-1)]}nonExistOrDescendantOf(e,r){if(!this.has(e))return!0;for(;e;){let o=this.parent(e);if(o===r)return!0;e=o}return!1}rootAcestor(e){for(;e;){let r=this.parent(e);if(r)e=r;else return e}return e}isDescendantOf(e,r){for(;e;){let o=this.parent(e);if(o===r)return!0;e=o}return!1}data(e){return this.get(e)?.data}has(e){return this.childrenOf(e)!==void 0}get(e){return this.fillCaches(),this.objCaches.get(e)}childrenOf(e){return e===null?this:this.get(e)?.children}traverseFrom(e,r){if(e===null)this.traverse(r);else{let o=this.get(e);o&&Gg(o,r)}}traverse(e){zg(this,e)}totalSize(){return this.fillCaches(),this.objCaches.size}parent(e){return this.fillCaches(),this.parentCaches.get(e)}childrenArray(e){return e===null?this:this.get(e).children}modifyById(e,r){if(this.get(e)===void 0)throw new Error("not expected");{let n=this.parent(e),a=this.childrenArray(n),s=a.findIndex(u=>u.id===e);if(s<0)throw new Error("not expected");let l=a[s];return a=[...a],a[s]={...l,data:r},this.modifyArrayBy(n,a)}}modifyArrayBy(e,r){let o=e,n=r;for(;o!==null;){let s=n,l=o;if(o=this.parent(o),o===void 0)throw new Error;n=this.childrenArray(o);let c=n.findIndex(u=>u.id===l);if(c<0)throw new Error;n=[...n],n[c]={...n[c],children:s}}Object.setPrototypeOf(n,ct.prototype);let a=n;return a.fillCaches(),a}runOp(e){switch(e.type){case 7:return this.addOp(e);case 8:return this.deleteOp(e);case 9:return this.moveOp(e)}return null}checkDuplicatedIdRec({id:e,children:r}){if(this.get(e)!==void 0)return!0;for(let o of r)if(this.checkDuplicatedIdRec(o))return!0;return!1}addOp(e){let{parent:r,fi:o,id:n,data:a,children:s}=e;if(r!==null&&this.get(r)===void 0)return null;if(this.checkDuplicatedIdRec(e))return null;{let l=r,c=this.childrenArray(l),u={fi:o,id:n,data:a,children:s};return c=[...c,u],c.sort((d,f)=>d.fi-f.fi),e.localIndex=c.indexOf(u),{data:this.modifyArrayBy(l,c),actual:e,reverse:{type:8,id:n}}}}deleteOp(e){let{id:r}=e;if(this.get(r)===null)return null;{let o=this.parent(r);if(o===void 0)return null;let n=this.childrenArray(o),a=n.findIndex(c=>c.id===r);e.localIndex=a,n=[...n];let s=n.splice(a,1)[0];return{data:this.modifyArrayBy(o,n),actual:e,reverse:{type:7,...s,parent:o}}}}moveOp(e){let{parent:r,fi:o,id:n}=e;if(r!==null&&this.get(r)===void 0)return this.deleteOp({type:8,id:n});if(r!==null){let f=r;for(;f!==null;){if(f===void 0)throw new Error;if(f===n)throw new ga("cyclic tree");f=this.parent(f)}}let a=this.parent(n);if(a===void 0)return null;let s=a,l=this.childrenArray(a),c=l.findIndex(f=>f.id===n);l=[...l];let u=l.splice(c,1)[0],p=this.modifyArrayBy(a,l);a=r,l=p.childrenArray(a);let d=u.fi;return u={...u,fi:o},l=[...l,u],l.sort((f,h)=>f.fi-h.fi),e.localIndex=l.indexOf(u),p=p.modifyArrayBy(a,l),{data:p,actual:e,reverse:{type:9,parent:s,fi:d,id:n}}}previous(e,r){if(r===null){let n=this.childrenArray(e);return n.length===0?null:n[n.length-1].id}let o=null;for(let n of this.childrenArray(e)){if(n.id===r)return o;o=n.id}return null}traverseSortNext(e){let r=this.parent(e);if(r!==void 0){let o=this.childrenArray(r),n=o.findIndex(a=>a.id===e)+1;if(n<o.length)return o[n].id;if(r)return this.traverseSortNext(r)}}sortNext(e){let r=this.childrenArray(e);return r.length>0?r[0].id:this.traverseSortNext(e)}traverseSortPrevious(e){let r=this.childrenArray(e);return r.length>0?this.traverseSortPrevious(r[r.length-1].id):e}sortPrevious(e){let r=this.parent(e);if(r!==void 0){let o=this.childrenArray(r),n=o.findIndex(a=>a.id===e)-1;return n>=0?this.traverseSortPrevious(o[n].id):r}}getAllSorted(e){let r=[];for(let o of e){let n=this.getWithSortKey(o.id);n!==void 0&&r.push({...o,...n})}r.sort((o,n)=>Bg(o.sortKey,n.sortKey));for(let o of r)delete o.sortKey;return r}getWithSortKey(e){var r=e;let o=[],n=this.get(r),a=n;if(n!==void 0){for(;r;)o.splice(0,0,n.fi),r=this.parent(r),r!==null&&(n=this.get(r));return{...a,sortKey:o}}}insertBeforeHelper(e,r,o){return this.insertAfterHelper(e,this.previous(e,r),o)}insertAfterHelper(e,r,o){let n=this.childrenArray(e);if(r===null){if(n.length===0)return wo(0,o,o);{let a=n[0].fi;return wo(a-o,a,o)}}else{let a=this.get(r);if(a===void 0||this.parent(r)!==e)throw new Error("illegal args");let s=n.find(l=>l.fi>a.fi);if(s===void 0){let l=n[n.length-1].fi;return wo(l,l+o,o)}else return wo(a.fi,s.fi,o)}}};var ba;(t=>{function i(e,r){if(r.type!==0)return null;if(Array.isArray(e)){let o=r.props,n={},a=[...e],s=!1;if(o)for(let l of Object.keys(o)){let c=parseInt(l);if(isNaN(c))throw new Error("wrong index");n[l]=a[c],a[c]=o[l],s=!0}return s?{data:a,actual:r,reverse:{type:0,props:n}}:null}else{let o=r.props,n={},a={...e},s=!1;if(o)for(let l of Object.keys(o)){n[l]=a[l];let c=o[l];c===void 0?delete a[l]:a[l]=c,s=!0}return s?{data:a,actual:r,reverse:{type:0,props:n}}:null}}t.runOp=i})(ba||(ba={}));var Se=class extends Array{constructor(...e){super(...e);Object.setPrototypeOf(this,Se.prototype)}deepFreeze(){let e=0;for(;e<this.length;)nl(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){return this.get(e)?.data}get(e){return this.fillCaches(),this.objCaches.get(e)}modifyById(e,r){if(this.get(e)===void 0)throw new Error("not expected");{let n=this,a=n.findIndex(c=>c.id===e);if(a<0)throw new Error("not expected");let s=n[a];return n=[...n],n[a]={...s,data:r},this.modifyArrayBy(n)}}modifyArrayBy(e){Object.setPrototypeOf(e,Se.prototype);let r=e;return Vg()||r.fillCaches(),r}runOp(e){switch(e.type){case 4:return this.addOp(e);case 5:return this.deleteOp(e);case 6:return this.moveOp(e)}return null}addOp(e){let{fi:r,id:o,data:n}=e,a=this,s={fi:r,id:o,data:n};return a=[...a,s],a.sort((c,u)=>c.fi-u.fi),e.localIndex=a.indexOf(s),{data:this.modifyArrayBy(a),actual:e,reverse:{type:5,id:o}}}deleteOp(e){let{id:r}=e,o=this,n=o.findIndex(l=>l.id===r);if(n===-1)return null;e.localIndex=n,o=[...o];let a=o.splice(n,1)[0];return{data:this.modifyArrayBy(o),actual:e,reverse:{type:4,...a}}}moveOp(e){let{fi:r,id:o}=e,n=this;n=[...n];let a=n.findIndex(u=>u.id===o);if(a===-1)return null;let s=n[a].fi,l={...n[a],fi:r};return n[a]=l,n.sort((u,p)=>u.fi-p.fi),e.localIndex=n.indexOf(l),{data:this.modifyArrayBy(n),actual:e,reverse:{type:6,fi:s,id:o}}}previous(e){if(e===null)return this.length===0?null:this[this.length-1].id;let r=null;for(let o of this){if(o.id===e)return r;r=o.id}return null}insertBeforeHelper(e,r){return this.insertAfterHelper(this.previous(e),r)}insertAfterHelper(e,r){let o=this;if(e===null){if(o.length===0)return wo(0,r,r);{let n=o[0].fi;return wo(n-r,n,r)}}else{let n=this.get(e);if(n===void 0)throw new Error("illegal args");let a=o.find(s=>s.fi>n.fi);if(a===void 0){let s=o[o.length-1].fi;return wo(s,s+r,r)}else return wo(n.fi,a.fi,r)}}};function va(i){return i&&typeof i=="object"&&i instanceof Je}var Je=class{unusedFunOverridesTable(t){}runOp(t){let e=[],r=this,o=0,n={};for(;o<t.path.length;){if(e.push(r),r=r===void 0?void 0:r[t.path[o]],r!==void 0&&!va(r))return null;o+=1}r=r?Xc(r):new Je;for(let[l,c]of Object.entries(t.props)){let u=r[l];n[l]=u,c===void 0?delete r[l]:r[l]=c}for(;o>0;){if(Object.keys(r).length===0){let l=e[o-1];l&&(r=Xc(l),delete r[t.path[o-1]])}else{let l=e[o-1];if(l){let c=Xc(l);c[t.path[o-1]]=r,r=c}else{let c=new Je;c[t.path[o-1]]=r,r=c}}o-=1}let a=Object.setPrototypeOf(r,Je.prototype),s={...t,props:n};return{data:a,actual:t,reverse:s}}},Po;(r=>{function i(o,n){return al(o,n)??o}r.apply=i;function t(o,n){return Mp(o,n)}r.merge=t;function e(o,n){let a=0,s=n.path,l=o;for(;a<s.length&&l!==void 0;){if(l=ut.zoomOnce(l,s[a]),l===void 0)return n;if(!va(l))return;a+=1}if(l===void 0)return n;if(!!va(l))if(n.type===0){let c={...n.props};for(let u of Object.keys(l))delete c[u];return{...n,props:c}}else if(n.type===1||n.type===4||n.type===7){let c=Ap([n],l);return c?c[0]:n}else return n}r.filterOp=e})(Po||(Po={}));function Ap(i,t){if(t===void 0)return;let e=!1,r=i.map(o=>{let n=o.id,a=al(o.data,t[n]);if(e=e||a!==void 0,a===void 0&&(a=o.data),o.children){let s=Ap(o.children,t);return s!==void 0?e=!0:s=o.children,{...o,id:n,data:a,children:s}}else return{...o,id:n,data:a}});if(e)return r}function XC(i,t){if(t===void 0)return;let e=!1,r=i.map(o=>{let n=o.id,a=al(o.data,t[n]);return e=e||a!==void 0,a===void 0&&(a=o.data),{...o,id:n,data:a}});if(e)return Object.setPrototypeOf(r,Object.getPrototypeOf(i)),r}function al(i,t){if(!va(t))return t;if(i instanceof ct){let e=Ap(i,t);return e!==void 0&&Object.setPrototypeOf(e,Object.getPrototypeOf(i)),e}else{if(i instanceof Se)return XC(i,t);if(Array.isArray(i)){let e=!1,r=i.map((o,n)=>{let a=al(o,t[n]);return e=e||a!==void 0,a===void 0&&(a=o),a});return e?(Object.setPrototypeOf(r,Object.getPrototypeOf(i)),r):void 0}else{if(i instanceof Je)return Mp(i,t);if(i&&typeof i=="object"){let e={},r=!1;for(let[o,n]of Object.entries(i)){let a=al(n,t[o]);r=r||a!==void 0,a===void 0&&(a=n),e[o]=a}return r?(Object.setPrototypeOf(e,Object.getPrototypeOf(i)),e):void 0}}}}function Mp(i,t){if(i===void 0)return t;if(t===void 0)return i;if(!va(t))return t;if(!va(i))return Po.apply(i,t);let e=new Set;for(let o of Object.keys(i))e.add(o);for(let o of Object.keys(t))e.add(o);let r=new Je;for(let o of e){let n=Mp(i===void 0?void 0:i[o],t===void 0?void 0:t[o]);r[o]=n}return r}function Fg(i,t){let e={cur:[],result:[],len:0};return i=sl(i,t,e)??i,[i,e.result]}function Yc(i,t){return i===null?null:(i.cur[i.len]=t,i.len+=1,i)}function Kc(i){i&&(i.len-=1)}function YC(i){if(i===null)return null;i.result.push(i.cur.slice(0,i.len))}function jg(i,t,e){let r=!1,o=i.map(n=>{let a=n.id,s=t[a];if(s!==void 0&&typeof s=="string"&&(r=!0,a=s,e!==null))throw new Error("not supported");let l=sl(n.data,t,Yc(e,a));Kc(e),r=r||l!==void 0,l===void 0&&(l=n.data);let c=jg(n.children,t,e);return c!==void 0?r=!0:c=n.children,{...n,id:a,data:l,children:c}});if(r)return o}function KC(i,t,e){let r=!1,o=i.map(n=>{let a=n.id,s=t[a];if(s!==void 0&&typeof s=="string"&&(r=!0,a=s,e!==null))throw new Error("not supported");let l=sl(n.data,t,Yc(e,a));return Kc(e),r=r||l!==void 0,l===void 0&&(l=n.data),{...n,id:a,data:l}});if(r)return Object.setPrototypeOf(o,Object.getPrototypeOf(i)),o}function sl(i,t,e){if(i instanceof ct){let r=jg(i,t,e);return r!==void 0&&Object.setPrototypeOf(r,Object.getPrototypeOf(i)),r}else{if(i instanceof Se)return KC(i,t,e);if(Array.isArray(i)){let r=!1,o=i.map((n,a)=>{let s=sl(n,t,Yc(e,a));return Kc(e),r=r||s!==void 0,s===void 0&&(s=n),s});return r?(Object.setPrototypeOf(o,Object.getPrototypeOf(i)),o):void 0}else if(i&&typeof i=="object"&&!xa(i)){let r={},o=!1;for(let[n,a]of Object.entries(i))if(n!=="name"&&n!=="variableId"){let s=t[n];if(typeof s=="string"){if(e!==null)throw new Error("not supported");o=!0,n=s}let l=sl(a,t,Yc(e,n));Kc(e),o=o||l!==void 0,l===void 0&&(l=a),r[n]=l}else r[n]=a;return o?(Object.setPrototypeOf(r,Object.getPrototypeOf(i)),r):void 0}else if(typeof i=="string"){let r=t[i];return r!==void 0&&YC(e),r}else return}}var Sa;(t=>{function i(e,r){let o=ut.zoom(r,e.path);if(typeof o=="object"){let n={};for(let a of Object.keys(e.props))n[a]=o[a];return{...e,props:n}}else return{...e,props:{}}}t.replaceProps=i})(Sa||(Sa={}));var bt;(s=>{function i(l,c){return{...l,path:l.path.slice(c)}}s.drop=i;function t(l,c){return e(l,c)?.data??l}s.applySimple=t;function e(l,c){let u=c.path;for(var p=[];;){let d;if(l instanceof Je&&c.type===0&&(d=l.runOp({...c,path:u.slice(p.length)}),d===null&&(d=void 0)),d===void 0&&p.length===u.length&&(l instanceof ct||l instanceof Se||l instanceof de?d=l.runOp(c):d=ba.runOp(l,c)),d!==void 0)if(d!==null){let m=d.data;for(let y=p.length-1;y>=0;y--){let b=u[y],v=p[y];if(v instanceof ct){if(typeof b=="number")throw new Error("illegal arg");m=v.modifyById(b,m)}else if(v instanceof Se){if(typeof b=="number")throw new Error("illegal arg");m=v.modifyById(b,m)}else if(v instanceof de){if(typeof b=="number")throw new Error("illegal arg");m=v.modifyById(b,m)}else if(v instanceof Je){let w={...v,[b]:m};m=Object.setPrototypeOf(w,Je.prototype)}else if(typeof v=="object")if(Array.isArray(v)){if(typeof b=="string"&&(b=parseInt(b),isNaN(b)))throw new Error("Invalid path");let w=m;m=[...v],m[b]=w}else m={...v,[b]:m};else return null}return{data:m,actual:{...d.actual,path:u},reverse:{...d.reverse,path:u}}}else return null;let f=u[p.length],h;if(l instanceof ct){if(typeof f=="number")throw new Error("");h=l.get(f)?.data}else if(l instanceof Se){if(typeof f=="number")throw new Error("");h=l.get(f)?.data}else l!==null&&(h=l[f]);if(h!==void 0)p.push(l),l=h;else return null}}s.apply=e;function r(l,c){for(let u=0;u<l.length&&u<c.length;u++)if(l[u]!==c[u])return!0;return!1}s.pathDisjoint=r;function o(l,c){if(l.length!==c.length)return!1;for(let u=0;u<l.length;u++)if(l[u]!==c[u])return!1;return!0}s.pathEq=o;function n(l,c){return r(l.path,c.path)}s.commutative=n;function a(l,c){return l.type===0&&c.type===0&&o(l.path,c.path)?Object.keys(l.props).every(u=>c.props[u]!==void 0):!1}s.subsumed=a})(bt||(bt={}));var ll;(l=>{function i(){return[]}l.empty=i;function t(c,u){let p=[];for(let d of c){let[f,...h]=d.path;f===u&&p.push({...d,path:h})}return p}l.removePrefix=t;function e(c,u){return c.map(p=>({...p,path:[u,...p.path]}))}l.addPrefix=e;function r(c,u){return[...c,...u]}l.concat=r;function o(c,u){return[...c.filter(d=>!u.some(f=>bt.subsumed(d,f))),...u]}l.compress=o;function n(c,u){return c.every(p=>u.every(d=>bt.commutative(p,d)))}l.commutative=n;function a(c,u){for(let p of u){let d=s(c,p);d!==null&&(c=d.data)}return c}l.applyAll=a;function s(c,u){var p=c;let d=[],f=[];for(let h of u)try{if(h.type===3||h.type===5&&h.path[h.path.length-1]==="variables"){let m,y,b;if(h.type===3?(m=ut.zoom(p,[...h.path,h.id]),b=bt.apply(p,{...h,type:2})):(m=ut.zoom(p,[...h.path,h.id,"value"]),b=bt.apply(p,h)),b!==null){p=b.data;let[v,w]=Fg(p,{[h.id]:m});p=v;for(let O=0;O<w.length;O++){let S=w[O],T=S.pop();if(typeof T=="number"){let M=[T];for(let D=O+1;D<w.length;D++){let E=w[D],I=E[E.length-1];if(typeof I=="number"&&ut.equal(S,E.slice(0,E.length-1)))M.push(I),w.splice(D,1);else break}let g=ut.zoom(p,S);y=g.map((D,E)=>M.includes(E)?h.id:D),m=g,T=S.pop()}else{if(T==="alphaOverride"||T==="alpha"){m/=100;let M=m,g=ut.zoom(p,S.slice(0,S.length-2)),D=g.layers.map(E=>E.id===S[S.length-1]?{...E,data:{...E.data,[T]:M}}:E);Object.setPrototypeOf(D,Object.getPrototypeOf(g.layers)),g.layers=D}y=h.id}d.push({type:0,path:S,props:{[T]:m}}),f.push({type:0,path:S,props:{[T]:y}})}f.push(b.reverse),d.push(b.actual)}}else{let m=bt.apply(p,h);m!==null&&(d.push(m.actual),p=m.data,f.push(m.reverse))}}catch(m){if(m instanceof ga)return null;throw m}return{data:p,actual:d,reverse:f.reverse()}}l.apply=s})(ll||(ll={}));var Ug=Symbol(),QC=Symbol(),Zc=Symbol(),vn=class{reportOp(t,e,r=[]){let o=this;if(e===null)return;o._current=e.data;let n=r;for(;!(o instanceof Qc);){let a=o._path,s=o._current;if(a!==""&&n.splice(0,0,a),o=o._parent,o===null)return;o.update(a,s)}o.push(n,t,e.actual,e.reverse)}deleteChildren(t){if(this._children){let e=this._children[t];if(e){let r=e[Zc];r&&r(),delete this._children[t]}}}},Ep=class extends vn{constructor(t,e,r){super(),this._parent=t,this._path=e,this._current=r}update(t,e){if(Array.isArray(this._current)){if(typeof t=="string"&&(t=parseInt(t),isNaN(t)))throw new Error("Invalid path");this._current=[...this._current],this._current[t]=e}else if(this._current instanceof Je){let r={...this._current,[t]:e};this._current=Object.setPrototypeOf(r,Je.prototype)}else this._current={...this._current,[t]:e}}runOp(t){this.reportOp(t,ba.runOp(this._current,t),t.path)}},Np=class extends vn{constructor(t,e,r){super(),this._parent=t,this._path=e,this._current=r}update(t,e){this._current={...this._current,[t]:e},Object.setPrototypeOf(this._current,de.prototype)}runOp(t){this.reportOp(t,this._current.runOp(t))}},kg={get(i,t){if(t===Zc)return()=>{i._parent=null};if(t===Ug)return i._current;if(t===QC)return i;let{_current:e,_children:r}=i;if(t==="push"&&Array.isArray(e))throw new Error("not supported to expand array");let o=r===void 0?void 0:r[t];if(o!==void 0)return o;let n=e[t],a=Jc(i,t,n);return a!==n?(r===void 0&&(r={},i._children=r),r[t]=a,a):n},has(i,t){return t 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,t){let e=i._current,r=Reflect.getOwnPropertyDescriptor(e,t);return r&&{writable:!0,configurable:!0,enumerable:r.enumerable,value:e[t]}}},ZC={...kg,set(i,t,e){let r={type:0,props:{[t]:vt(e)??e}};return i.deleteChildren(t),i.runOp(r),!0},deleteProperty(i,t){let e={type:0,props:{[t]:void 0}};return i.deleteChildren(t),i.runOp(e),!0}},JC={...kg,set(i,t,e){return e===void 0?this.deleteProperty(i,t):(i.deleteChildren(t),i.runOp({type:1,id:t,data:e})),!0},deleteProperty(i,t){return i.runOp({type:2,id:t}),!0}},wa=class extends vn{constructor(t,e,r){super(),this._children={},this._parent=t,this._path=e,this._current=r,this[Zc]=()=>{this._parent=null}}unproxy(){return this._current}update(t,e){this._current=this._current.modifyById(t,e)}runOp(t){this.reportOp(t,this._current.runOp(t))}randomId(){return this._current.randomId()}isDescendantOf(t,e){return this._current.isDescendantOf(t,e)}childrenOf(t){return this._current.childrenOf(t)}traverse(t){return this._current.traverse(t)}get(t){return this._current.get(t)}parent(t){return this._current.parent(t)}traverse(t){this._current.traverse((e,r)=>{t(e,this.data(e))})}data(t){let{_current:e,_children:r}=this,o=r===void 0?void 0:r[t];if(o!==void 0)return o;let n=e.get(t)?.data,a=Jc(this,t,n);return a!==n?(r===void 0&&(r={},this._children=r),r[t]=a,a):n}add(t,e,r,o,n){this.runOp({type:7,parent:t,fi:e,id:r,data:o,children:n})}move(t,e,r){this.runOp({type:9,parent:t,fi:e,id:r})}insertAfter(t,e,r){let o=this._current.insertAfterHelper(t,e,r.length);for(let n=0;n<r.length;n++){let a=r[n];this.add(t,o[n],a.id,a.data,a.children)}}insertBefore(t,e,r){let o=this._current.insertBeforeHelper(t,e,r.length);for(let n=0;n<r.length;n++){let a=r[n];this.add(t,o[n],a.id,a.data,a.children)}}moveAfter(t,e,r){let o=this._current.insertAfterHelper(t,e,r.length);for(let n=0;n<r.length;n++){let a=r[n];this.move(t,o[n],a)}}moveBefore(t,e,r){let o=this._current.insertBeforeHelper(t,e,r.length);for(let n=0;n<r.length;n++){let a=r[n];this.move(t,o[n],a)}}delete(t){this.deleteChildren(t),this.runOp({type:8,id:t})}sortNext(t){return this._current.sortNext(t)}sortPrevious(t){return this._current.sortPrevious(t)}getAllSorted(t){return this._current.getAllSorted(t)}},Pa=class extends vn{constructor(t,e,r){super(),this._children={},this._parent=t,this._path=e,this._current=r,this[Zc]=()=>{this._parent=null}}unproxy(){return this._current}get length(){return this._current.length}forEach(t){let e=this.length;for(let r=0;r<e;r++){let o=this._current[r].id,n=this._current[r].fi;t(this.data(this._current[r].id),o,n)}}find(t){let e=this.length;for(let r=0;r<e;r++){let o=this._current[r].id;if(t(this.data(o),o))return this.get(o)}}update(t,e){this._current=this._current.modifyById(t,e)}randomId(){return this._current.randomId()}get(t){return{...this._current.get(t),data:this.data(t)}}data(t){let{_current:e,_children:r}=this,o=r===void 0?void 0:r[t];if(o!==void 0)return o;let n=e.get(t)?.data,a=Jc(this,t,n);return a!==n?(r===void 0&&(r={},this._children=r),r[t]=a,a):n}runOp(t){this.reportOp(t,this._current.runOp(t))}add(t,e,r){this.runOp({type:4,fi:t,id:e,data:r})}move(t,e){this.runOp({type:6,fi:t,id:e})}insertAfter(t,e){let r=this._current.insertAfterHelper(t,e.length);for(let o=0;o<e.length;o++){let n=e[o];this.add(r[o],n.id,n.data)}}insertBefore(t,e){let r=this._current.insertBeforeHelper(t,e.length);for(let o=0;o<e.length;o++){let n=e[o];this.add(r[o],n.id,n.data)}}moveAfter(t,e){let r=this._current.insertAfterHelper(t,e.length);for(let o=0;o<e.length;o++){let n=e[o];this.move(r[o],n)}}moveBefore(t,e){let r=this._current.insertBeforeHelper(t,e.length);for(let o=0;o<e.length;o++){let n=e[o];this.move(r[o],n)}}delete(t){this.deleteChildren(t),this.runOp({type:5,id:t})}};function Ip(i,t,e){if(i.length>0){let r=i[i.length-1];if(r.type===0&&t.type===0&&ut.equal(r.path,e)){Object.assign(r.props,t.props);return}}i.push({...t,path:e})}var Qc=class extends vn{constructor(t){super(),this.ts=[],this.actual=[],this.reverse=[],this._current=t}update(t,e){if(t!=="")throw new Error("");this._current=e}push(t,e,r,o){Ip(this.ts,e,t),Ip(this.actual,r,t),Ip(this.reverse,o,t)}result(){return{data:this._current,ts:this.ts,actual:this.actual,reverse:this.reverse.reverse()}}};function Jc(i,t,e){return e instanceof ct?new wa(i,t,e):e instanceof Se?new Pa(i,t,e):e instanceof de?new Proxy(new Np(i,t,e),JC):e!==null&&typeof e=="object"?xa(e)?e:new Proxy(new Ep(i,t,e),ZC):e}function Dp(i){let t=new Qc(i);return[Jc(t,"",i),t]}function Ai(i,t){let[e,r]=Dp(i);return t(e),r.result()}function vt(i){return i instanceof wa||i instanceof Pa?i._current:i!==null&&typeof i=="object"?i[Ug]:i}var ut;(o=>{function i(n,a){if(a.length===n.length)for(var s=0;s<n.length;){if(n[s]!==a[s])return!1;s+=1}else return!1;return!0}o.equal=i;function t(n,a,s){let l=r(s,n);if(l!==void 0&&typeof l=="object"&&l!==null){let c={...a};return Object.keys(l).forEach(u=>{delete c[u]}),c}else return a}o.removeOverridden=t;function e(n,a){if((n instanceof ct||n instanceof wa)&&typeof a=="string")return n.data(a);if((n instanceof Se||n instanceof Pa)&&typeof a=="string")return n.data(a);if(typeof a=="number"&&Array.isArray(n))return n[a];if(typeof a=="string"&&typeof n=="object"&&n!==null)return n[a]}o.zoomOnce=e;function r(n,a,s=0){for(;s<a.length&&n!==void 0;)n=e(n,a[s]),s+=1;return n}o.zoom=r})(ut||(ut={}));function Hg(i,t){let e=[];if(t.length===i.length)for(var r=0;r<i.length;){if(t[r]==="*")e.push(i[r]);else if(i[r]!==t[r])return null;r+=1}else return null;return e}function je(i,t){let e=[];if(t.length<=i.length)for(var r=0;r<t.length;){if(t[r]==="*")e.push(i[r]);else if(i[r]!==t[r])return null;r+=1}else return null;return e}var eu=class{},cl=class extends eu{constructor(e){super();this.id=e}},ul=class extends eu{constructor(e){super();this.data=e}};var Rp;try{Rp=new TextDecoder}catch{}var fe,Ii,G=0;var Zg=[],Lp=Zg,Bp=0,vr={},Qe,Mi,Fr=0,Oo=0,Dr,Jo,fr=[],rt,Wg={useRecords:!1,mapsAsObjects:!0},dl=class{},zp=new dl;zp.name="MessagePack 0xC1";var Oa=!1,To=class{constructor(t){t&&(t.useRecords===!1&&t.mapsAsObjects===void 0&&(t.mapsAsObjects=!0),t.structures?t.structures.sharedLength=t.structures.length:t.getStructures&&((t.structures=[]).uninitialized=!0,t.structures.sharedLength=0)),Object.assign(this,t)}unpack(t,e){if(fe)return o0(()=>(ru(),this?this.unpack(t,e):To.prototype.unpack.call(Wg,t,e)));Ii=e>-1?e:t.length,G=0,Bp=0,Oo=0,Mi=null,Lp=Zg,Dr=null,fe=t;try{rt=t.dataView||(t.dataView=new DataView(t.buffer,t.byteOffset,t.byteLength))}catch(r){throw fe=null,t instanceof Uint8Array?r:new Error("Source must be a Uint8Array or Buffer but was a "+(t&&typeof t=="object"?t.constructor.name:typeof t))}if(this instanceof To){if(vr=this,this.structures)return Qe=this.structures,tu();(!Qe||Qe.length>0)&&(Qe=[])}else vr=Wg,(!Qe||Qe.length>0)&&(Qe=[]);return tu()}unpackMultiple(t,e){let r,o=0;try{Oa=!0;let n=t.length,a=this?this.unpack(t,n):nu.unpack(t,n);if(e){for(e(a);G<n;)if(o=G,e(tu())===!1)return}else{for(r=[a];G<n;)o=G,r.push(tu());return r}}catch(n){throw n.lastPosition=o,n.values=r,n}finally{Oa=!1,ru()}}_mergeStructures(t,e){t=t||[];for(let r=0,o=t.length;r<o;r++){let n=t[r];n&&(n.isShared=!0,r>=32&&(n.highByte=r-32>>5))}t.sharedLength=t.length;for(let r in e||[])if(r>=0){let o=t[r],n=e[r];n&&(o&&((t.restoreStructures||(t.restoreStructures=[]))[r]=o),t[r]=n)}return this.structures=t}decode(t,e){return this.unpack(t,e)}};function tu(){try{if(!vr.trusted&&!Oa){let t=Qe.sharedLength||0;t<Qe.length&&(Qe.length=t)}let i=At();if(G==Ii)Qe.restoreStructures&&qg(),Qe=null,fe=null,Jo&&(Jo=null);else if(G>Ii){let t=new Error("Unexpected end of MessagePack data");throw t.incomplete=!0,t}else if(!Oa)throw new Error("Data read, but end of buffer not reached");return i}catch(i){throw Qe.restoreStructures&&qg(),ru(),(i instanceof RangeError||i.message.startsWith("Unexpected end of buffer"))&&(i.incomplete=!0),i}}function qg(){for(let i in Qe.restoreStructures)Qe[i]=Qe.restoreStructures[i];Qe.restoreStructures=null}function At(){let i=fe[G++];if(i<160)if(i<128){if(i<64)return i;{let t=Qe[i&63]||vr.getStructures&&Jg()[i&63];return t?(t.read||(t.read=Gp(t,i&63)),t.read()):i}}else if(i<144)if(i-=128,vr.mapsAsObjects){let t={};for(let e=0;e<i;e++)t[t0()]=At();return t}else{let t=new Map;for(let e=0;e<i;e++)t.set(At(),At());return t}else{i-=144;let t=new Array(i);for(let e=0;e<i;e++)t[e]=At();return t}else if(i<192){let t=i-160;if(Oo>=G)return Mi.slice(G-Fr,(G+=t)-Fr);if(Oo==0&&Ii<140){let e=t<16?Fp(t):e0(t);if(e!=null)return e}return Vp(t)}else{let t;switch(i){case 192:return null;case 193:return Dr?(t=At(),t>0?Dr[1].slice(Dr.position1,Dr.position1+=t):Dr[0].slice(Dr.position0,Dr.position0-=t)):zp;case 194:return!1;case 195:return!0;case 196:return _p(fe[G++]);case 197:return t=rt.getUint16(G),G+=2,_p(t);case 198:return t=rt.getUint32(G),G+=4,_p(t);case 199:return Sn(fe[G++]);case 200:return t=rt.getUint16(G),G+=2,Sn(t);case 201:return t=rt.getUint32(G),G+=4,Sn(t);case 202:if(t=rt.getFloat32(G),vr.useFloat32>2){let e=iu[(fe[G]&127)<<1|fe[G+1]>>7];return G+=4,(e*t+(t>0?.5:-.5)>>0)/e}return G+=4,t;case 203:return t=rt.getFloat64(G),G+=8,t;case 204:return fe[G++];case 205:return t=rt.getUint16(G),G+=2,t;case 206:return t=rt.getUint32(G),G+=4,t;case 207:return vr.int64AsNumber?(t=rt.getUint32(G)*4294967296,t+=rt.getUint32(G+4)):t=rt.getBigUint64(G),G+=8,t;case 208:return rt.getInt8(G++);case 209:return t=rt.getInt16(G),G+=2,t;case 210:return t=rt.getInt32(G),G+=4,t;case 211:return vr.int64AsNumber?(t=rt.getInt32(G)*4294967296,t+=rt.getUint32(G+4)):t=rt.getBigInt64(G),G+=8,t;case 212:if(t=fe[G++],t==114)return Qg(fe[G++]&63);{let e=fr[t];if(e)return e.read?(G++,e.read(At())):e.noBuffer?(G++,e()):e(fe.subarray(G,++G));throw new Error("Unknown extension "+t)}case 213:return t=fe[G],t==114?(G++,Qg(fe[G++]&63,fe[G++])):Sn(2);case 214:return Sn(4);case 215:return Sn(8);case 216:return Sn(16);case 217:return t=fe[G++],Oo>=G?Mi.slice(G-Fr,(G+=t)-Fr):tA(t);case 218:return t=rt.getUint16(G),G+=2,Oo>=G?Mi.slice(G-Fr,(G+=t)-Fr):rA(t);case 219:return t=rt.getUint32(G),G+=4,Oo>=G?Mi.slice(G-Fr,(G+=t)-Fr):oA(t);case 220:return t=rt.getUint16(G),G+=2,Xg(t);case 221:return t=rt.getUint32(G),G+=4,Xg(t);case 222:return t=rt.getUint16(G),G+=2,Yg(t);case 223:return t=rt.getUint32(G),G+=4,Yg(t);default:if(i>=224)return i-256;if(i===void 0){let e=new Error("Unexpected end of MessagePack data");throw e.incomplete=!0,e}throw new Error("Unknown MessagePack token "+i)}}}var eA=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function Gp(i,t){function e(){if(e.count++>2){let o=i.read=new Function("r","return function(){return {"+i.map(n=>eA.test(n)?n+":r()":"["+JSON.stringify(n)+"]:r()").join(",")+"}}")(At);return i.highByte===0&&(i.read=$g(t,i.read)),o()}let r={};for(let o=0,n=i.length;o<n;o++){let a=i[o];r[a]=At()}return r}return e.count=0,i.highByte===0?$g(t,e):e}var $g=(i,t)=>function(){let e=fe[G++];if(e===0)return t();let r=i<32?-(i+(e<<5)):i+(e<<5),o=Qe[r]||Jg()[r];if(!o)throw new Error("Record id is not defined for "+r);return o.read||(o.read=Gp(o,i)),o.read()};function Jg(){let i=o0(()=>(fe=null,vr.getStructures()));return Qe=vr._mergeStructures(i,Qe)}var Vp=ou,tA=ou,rA=ou,oA=ou;function ou(i){let t;if(i<16&&(t=Fp(i)))return t;if(i>64&&Rp)return Rp.decode(fe.subarray(G,G+=i));let e=G+i,r=[];for(t="";G<e;){let o=fe[G++];if((o&128)===0)r.push(o);else if((o&224)===192){let n=fe[G++]&63;r.push((o&31)<<6|n)}else if((o&240)===224){let n=fe[G++]&63,a=fe[G++]&63;r.push((o&31)<<12|n<<6|a)}else if((o&248)===240){let n=fe[G++]&63,a=fe[G++]&63,s=fe[G++]&63,l=(o&7)<<18|n<<12|a<<6|s;l>65535&&(l-=65536,r.push(l>>>10&1023|55296),l=56320|l&1023),r.push(l)}else r.push(o);r.length>=4096&&(t+=Kt.apply(String,r),r.length=0)}return r.length>0&&(t+=Kt.apply(String,r)),t}function Xg(i){let t=new Array(i);for(let e=0;e<i;e++)t[e]=At();return t}function Yg(i){if(vr.mapsAsObjects){let t={};for(let e=0;e<i;e++)t[t0()]=At();return t}else{let t=new Map;for(let e=0;e<i;e++)t.set(At(),At());return t}}var Kt=String.fromCharCode;function e0(i){let t=G,e=new Array(i);for(let r=0;r<i;r++){let o=fe[G++];if((o&128)>0){G=t;return}e[r]=o}return Kt.apply(String,e)}function Fp(i){if(i<4)if(i<2){if(i===0)return"";{let t=fe[G++];if((t&128)>1){G-=1;return}return Kt(t)}}else{let t=fe[G++],e=fe[G++];if((t&128)>0||(e&128)>0){G-=2;return}if(i<3)return Kt(t,e);let r=fe[G++];if((r&128)>0){G-=3;return}return Kt(t,e,r)}else{let t=fe[G++],e=fe[G++],r=fe[G++],o=fe[G++];if((t&128)>0||(e&128)>0||(r&128)>0||(o&128)>0){G-=4;return}if(i<6){if(i===4)return Kt(t,e,r,o);{let n=fe[G++];if((n&128)>0){G-=5;return}return Kt(t,e,r,o,n)}}else if(i<8){let n=fe[G++],a=fe[G++];if((n&128)>0||(a&128)>0){G-=6;return}if(i<7)return Kt(t,e,r,o,n,a);let s=fe[G++];if((s&128)>0){G-=7;return}return Kt(t,e,r,o,n,a,s)}else{let n=fe[G++],a=fe[G++],s=fe[G++],l=fe[G++];if((n&128)>0||(a&128)>0||(s&128)>0||(l&128)>0){G-=8;return}if(i<10){if(i===8)return Kt(t,e,r,o,n,a,s,l);{let c=fe[G++];if((c&128)>0){G-=9;return}return Kt(t,e,r,o,n,a,s,l,c)}}else if(i<12){let c=fe[G++],u=fe[G++];if((c&128)>0||(u&128)>0){G-=10;return}if(i<11)return Kt(t,e,r,o,n,a,s,l,c,u);let p=fe[G++];if((p&128)>0){G-=11;return}return Kt(t,e,r,o,n,a,s,l,c,u,p)}else{let c=fe[G++],u=fe[G++],p=fe[G++],d=fe[G++];if((c&128)>0||(u&128)>0||(p&128)>0||(d&128)>0){G-=12;return}if(i<14){if(i===12)return Kt(t,e,r,o,n,a,s,l,c,u,p,d);{let f=fe[G++];if((f&128)>0){G-=13;return}return Kt(t,e,r,o,n,a,s,l,c,u,p,d,f)}}else{let f=fe[G++],h=fe[G++];if((f&128)>0||(h&128)>0){G-=14;return}if(i<15)return Kt(t,e,r,o,n,a,s,l,c,u,p,d,f,h);let m=fe[G++];if((m&128)>0){G-=15;return}return Kt(t,e,r,o,n,a,s,l,c,u,p,d,f,h,m)}}}}}function _p(i){return vr.copyBuffers?Uint8Array.prototype.slice.call(fe,G,G+=i):fe.subarray(G,G+=i)}function Sn(i){let t=fe[G++];if(fr[t])return fr[t](fe.subarray(G,G+=i));throw new Error("Unknown extension type "+t)}var Kg=new Array(4096);function t0(){let i=fe[G++];if(i>=160&&i<192){if(i=i-160,Oo>=G)return Mi.slice(G-Fr,(G+=i)-Fr);if(!(Oo==0&&Ii<180))return Vp(i)}else return G--,At();let t=(i<<5^(i>1?rt.getUint16(G):i>0?fe[G]:0))&4095,e=Kg[t],r=G,o=G+i-3,n,a=0;if(e&&e.bytes==i){for(;r<o;){if(n=rt.getUint32(r),n!=e[a++]){r=1879048192;break}r+=4}for(o+=3;r<o;)if(n=fe[r++],n!=e[a++]){r=1879048192;break}if(r===o)return G=r,e.string;o-=3,r=G}for(e=[],Kg[t]=e,e.bytes=i;r<o;)n=rt.getUint32(r),e.push(n),r+=4;for(o+=3;r<o;)n=fe[r++],e.push(n);let s=i<16?Fp(i):e0(i);return s!=null?e.string=s:e.string=Vp(i)}var Qg=(i,t)=>{var e=At();let r=i;t!==void 0&&(i=i<32?-((t<<5)+i):(t<<5)+i,e.highByte=t);let o=Qe[i];return o&&o.isShared&&((Qe.restoreStructures||(Qe.restoreStructures=[]))[i]=o),Qe[i]=e,e.read=Gp(e,r),e.read()},r0=typeof self=="object"?self:global;fr[0]=()=>{};fr[0].noBuffer=!0;fr[101]=()=>{let i=At();return(r0[i[0]]||Error)(i[1])};fr[105]=i=>{let t=rt.getUint32(G-4);Jo||(Jo=new Map);let e=fe[G],r;e>=144&&e<160||e==220||e==221?r=[]:r={};let o={target:r};Jo.set(t,o);let n=At();return o.used?Object.assign(r,n):(o.target=n,n)};fr[112]=i=>{let t=rt.getUint32(G-4),e=Jo.get(t);return e.used=!0,e.target};fr[115]=()=>new Set(At());var jp=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(i=>i+"Array");fr[116]=i=>{let t=i[0],e=jp[t];if(!e)throw new Error("Could not find typed array for code "+t);return new r0[e](Uint8Array.prototype.slice.call(i,1).buffer)};fr[120]=()=>{let i=At();return new RegExp(i[0],i[1])};fr[98]=i=>{let t=(i[0]<<24)+(i[1]<<16)+(i[2]<<8)+i[3],e=G;G+=t-4,Dr=[At(),At()],Dr.position0=0,Dr.position1=0;let r=G;G=e;try{return At()}finally{G=r}};fr[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 o0(i){let t=Ii,e=G,r=Bp,o=Fr,n=Oo,a=Mi,s=Lp,l=Jo,c=Dr,u=new Uint8Array(fe.slice(0,Ii)),p=Qe,d=Qe.slice(0,Qe.length),f=vr,h=Oa,m=i();return Ii=t,G=e,Bp=r,Fr=o,Oo=n,Mi=a,Lp=s,Jo=l,Dr=c,fe=u,Oa=h,Qe=p,Qe.splice(0,Qe.length,...d),vr=f,rt=new DataView(fe.buffer,fe.byteOffset,fe.byteLength),m}function ru(){fe=null,Jo=null,Qe=null}function i0(i){i.unpack?fr[i.type]=i.unpack:fr[i.type]=i}var iu=new Array(147);for(let i=0;i<256;i++)iu[i]=+("1e"+Math.floor(45.15-i*.30103));var nu=new To({useRecords:!1}),iA=nu.unpack,nA=nu.unpackMultiple,aA=nu.unpack,au={NEVER:0,ALWAYS:1,DECIMAL_ROUND:3,DECIMAL_FIT:4},sA=new Float32Array(1),dF=new Uint8Array(sA.buffer,0,4);var su;try{su=new TextEncoder}catch{}var lu,kp,cu=typeof Buffer<"u",Up=cu?Buffer.allocUnsafeSlow:Uint8Array,l0=cu?Buffer:Uint8Array,n0=cu?4294967296:2144337920,X,Nt,k=0,Co,Ao=null,lA=/[\u0080-\uFFFF]/,pl=Symbol("record-id"),wn=class extends To{constructor(t){super(t),this.offset=0;let e,r,o,n,a,s,l=0,c=l0.prototype.utf8Write?function(g,D,E){return X.utf8Write(g,D,E)}:su&&su.encodeInto?function(g,D){return su.encodeInto(g,X.subarray(D)).written}:!1,u=this;t||(t={});let p=t&&t.sequential,d=t.structures||t.saveStructures,f=t.maxSharedStructures;if(f==null&&(f=d?32:0),f>8160)throw new Error("Maximum maxSharedStructure is 8160");let h=t.maxOwnStructures;h==null&&(h=d?32:64),p&&!t.saveStructures&&(this.structures=[]);let m=f>32||h+f>64,y=f+64,b=f+h+64;if(b>8256)throw new Error("Maximum maxSharedStructure + maxOwnStructure is 8192");let v=[],w=0,O=0;this.pack=this.encode=function(g,D){if(X||(X=new Up(8192),Nt=new DataView(X.buffer,0,8192),k=0),Co=X.length-10,Co-k<2048?(X=new Up(X.length),Nt=new DataView(X.buffer,0,X.length),Co=X.length-10,k=0):k=k+7&2147483640,r=k,s=u.structuredClone?new Map:null,u.bundleStrings?(Ao=["",""],X[k++]=214,X[k++]=98,Ao.position=k-r,k+=4):Ao=null,o=u.structures,o){o.uninitialized&&(o=u._mergeStructures(u.getStructures()));let E=o.sharedLength||0;if(E>f)throw new Error("Shared structures is larger than maximum shared structures, try increasing maxSharedStructures to "+o.sharedLength);if(!o.transitions){o.transitions=Object.create(null);for(let I=0;I<E;I++){let N=o[I];if(!N)continue;let _,R=o.transitions;for(let V=0,U=N.length;V<U;V++){let B=N[V];_=R[B],_||(_=R[B]=Object.create(null)),R=_}R[pl]=I+64}l=E}p||(o.nextId=E+64)}n&&(n=!1),a=o||[];try{if(S(g),Ao){Nt.setUint32(Ao.position+r,k-Ao.position-r);let E=Ao;Ao=null,S(E[0]),S(E[1])}if(u.offset=k,s&&s.idsToInsert){k+=s.idsToInsert.length*6,k>Co&&M(k),u.offset=k;let E=uA(X.subarray(r,k),s.idsToInsert);return s=null,E}return D&u0?(X.start=r,X.end=k,X):X.subarray(r,k)}finally{if(o){if(O<10&&O++,w>1e4)o.transitions=null,O=0,w=0,v.length>0&&(v=[]);else if(v.length>0&&!p){for(let E=0,I=v.length;E<I;E++)v[E][pl]=0;v=[]}if(n&&u.saveStructures){let E=o.sharedLength||f;o.length>E&&(o=o.slice(0,E));let I=X.subarray(r,k);return u.saveStructures(o,l)===!1?(u._mergeStructures(u.getStructures()),u.pack(g)):(l=E,I)}}D&gA&&(k=r)}};let S=g=>{k>Co&&(X=M(k));var D=typeof g,E;if(D==="string"){let I=g.length;if(Ao&&I>=8&&I<4096){let R=lA.test(g);Ao[R?0:1]+=g,X[k++]=193,S(R?-I:I);return}let N;I<32?N=1:I<256?N=2:I<65536?N=3:N=5;let _=I*3;if(k+_>Co&&(X=M(k+_)),I<64||!c){let R,V,U,B=k+N;for(R=0;R<I;R++)V=g.charCodeAt(R),V<128?X[B++]=V:V<2048?(X[B++]=V>>6|192,X[B++]=V&63|128):(V&64512)===55296&&((U=g.charCodeAt(R+1))&64512)===56320?(V=65536+((V&1023)<<10)+(U&1023),R++,X[B++]=V>>18|240,X[B++]=V>>12&63|128,X[B++]=V>>6&63|128,X[B++]=V&63|128):(X[B++]=V>>12|224,X[B++]=V>>6&63|128,X[B++]=V&63|128);E=B-k-N}else E=c(g,k+N,_);E<32?X[k++]=160|E:E<256?(N<2&&X.copyWithin(k+2,k+1,k+1+E),X[k++]=217,X[k++]=E):E<65536?(N<3&&X.copyWithin(k+3,k+2,k+2+E),X[k++]=218,X[k++]=E>>8,X[k++]=E&255):(N<5&&X.copyWithin(k+5,k+3,k+3+E),X[k++]=219,Nt.setUint32(k,E),k+=4),k+=E}else if(D==="number")if(g>>>0===g)g<64?X[k++]=g:g<256?(X[k++]=204,X[k++]=g):g<65536?(X[k++]=205,X[k++]=g>>8,X[k++]=g&255):(X[k++]=206,Nt.setUint32(k,g),k+=4);else if(g>>0===g)g>=-32?X[k++]=256+g:g>=-128?(X[k++]=208,X[k++]=g+256):g>=-32768?(X[k++]=209,Nt.setInt16(k,g),k+=2):(X[k++]=210,Nt.setInt32(k,g),k+=4);else{let I;if((I=this.useFloat32)>0&&g<4294967296&&g>=-2147483648){X[k++]=202,Nt.setFloat32(k,g);let N;if(I<4||(N=g*iu[(X[k]&127)<<1|X[k+1]>>7])>>0===N){k+=4;return}else k--}X[k++]=203,Nt.setFloat64(k,g),k+=8}else if(D==="object")if(!g)X[k++]=192;else{if(s){let N=s.get(g);if(N){if(!N.id){let _=s.idsToInsert||(s.idsToInsert=[]);N.id=_.push(N)}X[k++]=214,X[k++]=112,Nt.setUint32(k,N.id),k+=4;return}else s.set(g,{offset:k-r})}let I=g.constructor;if(I===Object)T(g,!0);else if(I===Array){E=g.length,E<16?X[k++]=144|E:E<65536?(X[k++]=220,X[k++]=E>>8,X[k++]=E&255):(X[k++]=221,Nt.setUint32(k,E),k+=4);for(let N=0;N<E;N++)S(g[N])}else if(I===Map){E=g.size,E<16?X[k++]=128|E:E<65536?(X[k++]=222,X[k++]=E>>8,X[k++]=E&255):(X[k++]=223,Nt.setUint32(k,E),k+=4);for(let[N,_]of g)S(N),S(_)}else{for(let N=0,_=lu.length;N<_;N++){let R=kp[N];if(g instanceof R){let V=lu[N];if(V.write){V.type&&(X[k++]=212,X[k++]=V.type,X[k++]=0),S(V.write.call(this,g));return}let U=X,B=Nt,q=k;X=null;let j;try{j=V.pack.call(this,g,F=>(X=U,U=null,k+=F,k>Co&&M(k),{target:X,targetView:Nt,position:k-F}),S)}finally{U&&(X=U,Nt=B,k=q,Co=X.length-10)}j&&(j.length+k>Co&&M(j.length+k),k=cA(j,X,k,V.type));return}}T(g,!g.hasOwnProperty)}}else if(D==="boolean")X[k++]=g?195:194;else if(D==="bigint"){if(g<BigInt(1)<<BigInt(63)&&g>=-(BigInt(1)<<BigInt(63)))X[k++]=211,Nt.setBigInt64(k,g);else if(g<BigInt(1)<<BigInt(64)&&g>0)X[k++]=207,Nt.setBigUint64(k,g);else if(this.largeBigIntToFloat)X[k++]=203,Nt.setFloat64(k,Number(g));else throw new RangeError(g+" was too large to fit in MessagePack 64-bit integer format, set largeBigIntToFloat to convert to float-64");k+=8}else if(D==="undefined")this.encodeUndefinedAsNil?X[k++]=192:(X[k++]=212,X[k++]=0,X[k++]=0);else if(D==="function")S(this.writeFunction&&this.writeFunction());else throw new Error("Unknown type: "+D)},T=this.useRecords===!1?this.variableMapSize?g=>{let D=Object.keys(g),E=D.length;E<16?X[k++]=128|E:E<65536?(X[k++]=222,X[k++]=E>>8,X[k++]=E&255):(X[k++]=223,Nt.setUint32(k,E),k+=4);let I;for(let N=0;N<E;N++)S(I=D[N]),S(g[I])}:(g,D)=>{X[k++]=222;let E=k-r;k+=2;let I=0;for(let N in g)(D||g.hasOwnProperty(N))&&(S(N),S(g[N]),I++);X[E+++r]=I>>8,X[E+r]=I&255}:g=>{let D=Object.keys(g),E,I=a.transitions||(a.transitions=Object.create(null)),N=0;for(let R=0,V=D.length;R<V;R++){let U=D[R];E=I[U],E||(E=I[U]=Object.create(null),N++),I=E}let _=I[pl];if(_)_>=96&&m?(X[k++]=((_-=96)&31)+96,X[k++]=_>>5):X[k++]=_;else{_=a.nextId,_||(_=64),_<y&&this.shouldShareStructure&&!this.shouldShareStructure(D)?(_=a.nextOwnId,_<b||(_=y),a.nextOwnId=_+1):(_>=b&&(_=y),a.nextId=_+1);let R=D.highByte=_>=96&&m?_-96>>5:-1;I[pl]=_,a[_-64]=D,_<y?(D.isShared=!0,a.sharedLength=_-63,n=!0,R>=0?(X[k++]=(_&31)+96,X[k++]=R):X[k++]=_):(R>=0?(X[k++]=213,X[k++]=114,X[k++]=(_&31)+96,X[k++]=R):(X[k++]=212,X[k++]=114,X[k++]=_),N&&(w+=O*N),v.length>=h&&(v.shift()[pl]=0),v.push(I),S(D))}for(let R=0,V=D.length;R<V;R++)S(g[D[R]])},M=g=>{let D;if(g>16777216){if(g-r>n0)throw new Error("Packed buffer would be larger than maximum buffer size");D=Math.min(n0,Math.round(Math.max((g-r)*(g>67108864?1.25:2),4194304)/4096)*4096)}else D=(Math.max(g-r<<2,X.length-1)>>12)+1<<12;let E=new Up(D);return Nt=new DataView(E.buffer,0,D),X.copy?X.copy(E,0,r,g):E.set(X.slice(r,g)),k-=r,r=0,Co=E.length-10,X=E}}useBuffer(t){X=t,Nt=new DataView(X.buffer,X.byteOffset,X.byteLength),k=0}};kp=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,dl];lu=[{pack(i,t,e){let r=i.getTime()/1e3;if((this.useTimestamp32||i.getMilliseconds()===0)&&r>=0&&r<4294967296){let{target:o,targetView:n,position:a}=t(6);o[a++]=214,o[a++]=255,n.setUint32(a,r)}else if(r>0&&r<17179869184){let{target:o,targetView:n,position:a}=t(10);o[a++]=215,o[a++]=255,n.setUint32(a,i.getMilliseconds()*4e6+(r/1e3/4294967296>>0)),n.setUint32(a+4,r)}else if(isNaN(r)){if(this.onInvalidDate)return t(0),e(this.onInvalidDate());let{target:o,targetView:n,position:a}=t(3);o[a++]=212,o[a++]=255,o[a++]=255}else{let{target:o,targetView:n,position:a}=t(15);o[a++]=199,o[a++]=12,o[a++]=255,n.setUint32(a,i.getMilliseconds()*1e6),n.setBigInt64(a+4,BigInt(Math.floor(r)))}}},{pack(i,t,e){let r=Array.from(i),{target:o,position:n}=t(this.structuredClone?3:0);this.structuredClone&&(o[n++]=212,o[n++]=115,o[n++]=0),e(r)}},{pack(i,t,e){let{target:r,position:o}=t(this.structuredClone?3:0);this.structuredClone&&(r[o++]=212,r[o++]=101,r[o++]=0),e([i.name,i.message])}},{pack(i,t,e){let{target:r,position:o}=t(this.structuredClone?3:0);this.structuredClone&&(r[o++]=212,r[o++]=120,r[o++]=0),e([i.source,i.flags])}},{pack(i,t){this.structuredClone?a0(i,16,t):s0(cu?Buffer.from(i):new Uint8Array(i),t)}},{pack(i,t){let e=i.constructor;e!==l0&&this.structuredClone?a0(i,jp.indexOf(e.name),t):s0(i,t)}},{pack(i,t){let{target:e,position:r}=t(1);e[r]=193}}];function a0(i,t,e,r){let o=i.byteLength;if(o+1<256){var{target:n,position:a}=e(4+o);n[a++]=199,n[a++]=o+1}else if(o+1<65536){var{target:n,position:a}=e(5+o);n[a++]=200,n[a++]=o+1>>8,n[a++]=o+1&255}else{var{target:n,position:a,targetView:s}=e(7+o);n[a++]=201,s.setUint32(a,o+1),a+=4}n[a++]=116,n[a++]=t,n.set(new Uint8Array(i.buffer,i.byteOffset,i.byteLength),a)}function s0(i,t){let e=i.byteLength;var r,o;if(e<256){var{target:r,position:o}=t(e+2);r[o++]=196,r[o++]=e}else if(e<65536){var{target:r,position:o}=t(e+3);r[o++]=197,r[o++]=e>>8,r[o++]=e&255}else{var{target:r,position:o,targetView:n}=t(e+5);r[o++]=198,n.setUint32(o,e),o+=4}r.set(i,o)}function cA(i,t,e,r){let o=i.length;switch(o){case 1:t[e++]=212;break;case 2:t[e++]=213;break;case 4:t[e++]=214;break;case 8:t[e++]=215;break;case 16:t[e++]=216;break;default:o<256?(t[e++]=199,t[e++]=o):o<65536?(t[e++]=200,t[e++]=o>>8,t[e++]=o&255):(t[e++]=201,t[e++]=o>>24,t[e++]=o>>16&255,t[e++]=o>>8&255,t[e++]=o&255)}return t[e++]=r,t.set(i,e),e+=o,e}function uA(i,t){let e,r=t.length*6,o=i.length-r;for(t.sort((n,a)=>n.offset>a.offset?1:-1);e=t.pop();){let n=e.offset,a=e.id;i.copyWithin(n+r,n,o),r-=6;let s=n+r;i[s++]=214,i[s++]=105,i[s++]=a>>24,i[s++]=a>>16&255,i[s++]=a>>8&255,i[s++]=a&255,o=n}return i}function Ei(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)");kp.unshift(i.Class),lu.unshift(i)}i0(i)}var c0=new wn({useRecords:!1}),dA=c0.pack,pA=c0.pack;var{NEVER:fA,ALWAYS:hA,DECIMAL_ROUND:mA,DECIMAL_FIT:yA}=au,u0=512,gA=1024;var d0=new wn({structuredClone:!0});Ei({Class:de.prototype.constructor,type:1,write(i){return{...i}},read(i){return Object.setPrototypeOf(i,de.prototype),i}});Ei({Class:Se.prototype.constructor,type:2,write(i){return[...i]},read(i){return Object.setPrototypeOf(i,Se.prototype),i}});Ei({Class:ct.prototype.constructor,type:3,write(i){return[...i]},read(i){return Object.setPrototypeOf(i,ct.prototype),i}});Ei({Class:cl.prototype.constructor,type:4,write(i){return i.id},read(i){return new cl(i)}});Ei({Class:ul.prototype.constructor,type:5,write(i){return i.data},read(i){return new ul(i)}});Ei({Class:Je.prototype.constructor,type:6,write(i){return{...i}},read(i){return Object.setPrototypeOf(i,Je.prototype),i}});function xA(i){var t=0;if(i.length===0)return t;for(let e=0;e<i.length;e++){let r=i[e];t=(t<<5)-t+r,t=t&t}return t}function Hp(i){if(xa(i))return i;if(Array.isArray(i))return i.map(Hp);if(typeof i=="object"&&i!==null){let t={};for(let e of Object.keys(i).sort())t[e]=Hp(i[e]);return Object.setPrototypeOf(t,Object.getPrototypeOf(i)),t}else return i}var uu;(r=>{function i(o){return d0.pack(o)}r.serialize=i;function t(o){return d0.unpack(o)}r.deserialize=t;function e(o){return xA(i(Hp(o))).toString()}r.checksum=e})(uu||(uu={}));var _i="personal camera",Ri="a218fcc3-276b-49b9-b485-49037fd14f5f",g0=2960946,Dt=5526619;var Ta;(f=>{function i(h,m){return h[0]===m[0]&&h[1]===m[1]}f.isEqual=i;function t(h,m,y){return[h[0]+(m[0]-h[0])*y,h[1]+(m[1]-h[1])*y]}f.lerp=t;function e(h,m){return[h[0]+m[0],h[1]+m[1]]}f.add=e;function r(h,m){return[h[0]-m[0],h[1]-m[1]]}f.sub=r;function o(h,m){return[h[0]*m[0],h[1]*m[1]]}f.multiply=o;function n(h,m){return[h[0]/m[0],h[1]/m[1]]}f.divide=n;function a(h,m){return Math.pow(m[0]-h[0],2)+Math.pow(m[1]-h[1],2)}f.distanceSquared=a;function s(h,m){return Math.sqrt(a(h,m))}f.distance=s;function l(h,m){return h[0]*m[0]+h[1]*m[1]}f.dot=l;function c(h,m){return[h[0]*m,h[1]*m]}f.scalarMultiply=c;function u(h,m,y){let b=f.sub(m,h),v=f.sub(y,h),w=f.dot(b,v)/f.dot(b,b),O=f.scalarMultiply(b,w);return f.add(h,O)}f.projectionOnto=u;function p(h,m,y){return s(h,u(h,m,y))}f.projectionOntoDistance=p;function d(h,m){return[(h[0]+m[0])*.5,(h[1]+m[1])*.5]}f.center=d})(Ta||(Ta={}));var Ni;(s=>{function i(l,c){return l[0]===c[0]&&l[1]===c[1]&&l[2]===c[2]}s.isEqual=i;function t(l,c){return[l[0]+c[0],l[1]+c[1],l[2]+c[2]]}s.add=t;function e(l,c){return[l[0]-c[0],l[1]-c[1],l[2]-c[2]]}s.sub=e;function r(l,c){return[l[0]/c[0],l[1]/c[1],l[2]/c[2]]}s.div=r;function o(l,c){return[l[0]*c[0],l[1]*c[1],l[2]*c[2]]}s.mul=o;function n(l,c){return Math.hypot(l[0]-c[0],l[1]-c[1],l[2]-c[2])}s.dist=n;function a(l,c,u){return[l[0]+(c[0]-l[0])*u,l[1]+(c[1]-l[1])*u,l[2]+(c[2]-l[2])*u]}s.lerp=a})(Ni||(Ni={}));var p0;(e=>{function i(r,o){return r[0]===o[0]&&r[1]===o[1]&&r[2]===o[2]&&r[3]===o[3]}e.isEqual=i;function t(r,o,n){return[r[0]+(o[0]-r[0])*n,r[1]+(o[1]-r[1])*n,r[2]+(o[2]-r[2])*n,r[3]+(o[3]-r[3])*n]}e.lerp=t})(p0||(p0={}));var f0;(a=>{let i=180/Math.PI,t=Math.PI/180;function e(s){return typeof s=="number"?s*i:s}function r(s){return typeof s=="number"?s*t:s}function o(s){return[e(s[0]),e(s[1]),e(s[2])]}a.radToDeg=o;function n(s){return[r(s[0]),r(s[1]),r(s[2])]}a.degToRad=n})(f0||(f0={}));var Di;(o=>{o.identity=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];function t(n,a){for(let s=0;s<16;s++)if(n[s]!==a[s])return!1;return!0}o.isEqual=t;function e(n){return n??o.identity}o.simplify=e;function r(n,a){let s=a.slice(0);for(var l=0,c=a.length;l<c;l+=3){let u=n[3]*a[l]+n[7]*a[l+1]+n[11]*a[l+2]+n[15];s[l]=(n[0]*a[l]+n[4]*a[l+1]+n[8]*a[l+2]+n[12])/u,s[l+1]=(n[1]*a[l]+n[5]*a[l+1]+n[9]*a[l+2]+n[13])/u,s[l+2]=(n[2]*a[l]+n[6]*a[l+1]+n[10]*a[l+2]+n[14])/u}return s}o.applyMatrix4=r})(Di||(Di={}));var jt;(d=>{function i(f){return typeof f=="object"&&typeof f.r=="number"&&typeof f.g=="number"&&typeof f.b=="number"}d.isRGB=i,d.white={r:1,g:1,b:1},d.red={r:1,g:0,b:0},d.black={r:0,g:0,b:0};function o(f){return{r:Math.round(f.r*255),g:Math.round(f.g*255),b:Math.round(f.b*255),a:1}}d.toRgb255a1=o;function n(f){return{r:f.r,g:f.g,b:f.b}}d.clone=n;function a(f){return f=Math.floor(f),{r:(f>>16&255)/255,g:(f>>8&255)/255,b:(f&255)/255}}d.fromHex=a;function s(f){return Math.round(f.r*255)*65536+Math.round(f.g*255)*256+Math.round(f.b*255)}d.toHex=s;function l(f,h){return f.r===h.r&&f.g===h.g&&f.b===h.b}d.equals=l;function c(f,h){return f.r.toFixed(2)===h.r.toFixed(2)&&f.g.toFixed(2)===h.g.toFixed(2)&&f.b.toFixed(2)===h.b.toFixed(2)}d.equalsFixed=c;function u(f,h,m){return{r:f.r+(h.r-f.r)*m,g:f.g+(h.g-f.g)*m,b:f.b+(h.b-f.b)*m}}d.lerp=u;function p(f){return Ct(f)?"r"in f&&"g"in f&&"b"in f&&!("a"in f):!1}d.is=p})(jt||(jt={}));var Re;(u=>{u.white={...jt.white,a:1};function t(p){return Ct(p)?"r"in p&&"g"in p&&"b"in p&&"a"in p:!1}u.is=t,u.transparent={...jt.white,a:0};function r(p){return{r:p[0],g:p[1],b:p[2],a:p[3]}}u.from0to1=r;function o(p,d){return{...jt.fromHex(p),a:d}}u.fromHexAndA=o;function n(p){return{r:Math.round(p.r*255),g:Math.round(p.g*255),b:Math.round(p.b*255),a:p.a}}u.toRgb255a1=n;function a(p,d){return jt.equals(p,d)&&p.a===d.a}u.equals=a;function s(p,d){return jt.equalsFixed(p,d)&&p.a.toFixed(2)===d.a.toFixed(2)}u.equalsFixed=s;function l(p,d,f){return{r:p.r+(d.r-p.r)*f,g:p.g+(d.g-p.g)*f,b:p.b+(d.b-p.b)*f,a:p.a+(d.a-p.a)*f}}u.lerp=l;function c({r:p,g:d,b:f,a:h}=u.white){return`rgba(${p*255}, ${d*255}, ${f*255}, ${h})`}u.toStyle=c})(Re||(Re={}));var du;(t=>t.identity={position:[0,0,0],rotation:[0,0,0],scale:[1,1,1]})(du||(du={}));var h0;(t=>t.defaultData={mass:1,stiffness:80,damping:10,velocity:0})(h0||(h0={}));var m0;(t=>t.defaultData={control1:[.5,0],control2:[.5,1]})(m0||(m0={}));var y0;(n=>(n.linear=[0,0,1,1],n.ease=[.25,.1,.25,1],n.easeIn=[.42,0,1,1],n.easeOut=[0,0,.58,1],n.easeInOut=[.42,0,.58,1]))(y0||(y0={}));function Wp(i){return typeof i=="string"&&i.length===36?/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(i):!1}var oo;(e=>{e.all=["PerspectiveCamera","OrthographicCamera"];function t(r){return e.all.includes(r)}e.is=t})(oo||(oo={}));var Li;(o=>{o.DefaultUp=[0,1,0],o.DefaultTargetOffset=1e3,o.defaultData={far:1e5,type:"OrthographicCamera",perspective:{near:70,fov:45,zoom:1},orthographic:{near:-1e5,zoom:1},up:o.DefaultUp,isUpVectorFlipped:!1,targetOffset:o.DefaultTargetOffset};function r(n){return n.type==="PerspectiveCamera"?n.perspective?.zoom??1:n.orthographic?.zoom??1}o.getZoom=r})(Li||(Li={}));var Mo;(r=>{function i(o,n=.1){return{disabled:!1,type:"linear",hideBase:!1,count:3,radial:{radius:Math.max(o[0],o[1])*2,start:0,end:360,alignment:!1,axis:"y",scale:[1,1,1],rotation:[0,0,0],position:[0,0,0]},toObject:{object:"",spreadType:"random",scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],axis:"x",seed:0,count:99,align:"normal"},linear:{scale:[1,1,1],rotation:[0,0,0],position:[o[0]+o[0]*n,0,0]},grid:{count:[2,2,2],size:o.map(a=>a*(1+n)),useCenter:!0},randomness:!1,randomnessObject:{strength:100,scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],movement:1,seed:0,freqScale:10,noiseType:"perlin"}}}r.defaultData=i;function t(o,n){let a={...o};if(bA.forEach(s=>{Object.assign(a,{[s]:n[s]??o[s]})}),a.radial={...o.radial},n.radial){let s=o.radial,l=n.radial;vA.forEach(c=>{Object.assign(a.radial,{[c]:l[c]??s[c]})})}if(a.linear={...o.linear},n.linear){let s=o.linear,l=n.linear;SA.forEach(c=>{Object.assign(a.linear,{[c]:l[c]??s[c]})})}if(a.grid={...o.grid},n.grid){let s=o.grid,l=n.grid;wA.forEach(c=>{Object.assign(a.grid,{[c]:l[c]??s[c]})})}if(a.toObject={...o.toObject},n.toObject){let s=o.toObject,l=n.toObject;PA.forEach(c=>{Object.assign(a.toObject,{[c]:l[c]??s[c]})})}if(a.randomnessObject={...o.randomnessObject},n.randomnessObject){let s=o.randomnessObject,l=n.randomnessObject;OA.forEach(c=>{Object.assign(a.randomnessObject,{[c]:l[c]??s[c]})})}return a}r.merge=t;function e(o){return!!(o.randomnessObject||o.toObject)}r.isPartial=e})(Mo||(Mo={}));var pu;(r=>{r.defaultData={radial:{},linear:{},grid:{},toObject:{},randomnessObject:{}};let t=["radial","linear","grid","toObject","randomnessObject"];function e(o,n){let a=[];o.count!==void 0&&a.push({type:0,path:n,props:{count:o.count}});for(let s of t){let l=o[s];l&&Object.keys(l).length>0&&a.push({type:0,path:[...n,s],props:l})}return a}r.toOps=e})(pu||(pu={}));var bA=["count"],vA=["radius","start","end","position","scale","rotation"],SA=["position","scale","rotation"],wA=["count","size"],PA=["count","position","scale","rotation"],OA=["strength","scale","rotation","position","movement","seed","freqScale"];var fu;(e=>{e.all=["PointLight","SpotLight","DirectionalLight","HemisphereLight"];function t(r){return e.all.includes(r)}e.is=t})(fu||(fu={}));var hu;(e=>{function i(r){return t(r)}e.defaultData=i;function t(r){if(r==="PointLight")return{type:r,color:Re.white,intensity:1,distance:2e3,decay:1,shadows:!0,shadowResolution:1024,shadowRadius:1,penumbraSize:.5,depth:1e5};if(r==="SpotLight")return{type:r,color:Re.white,intensity:1,distance:2e3,decay:1,shadows:!0,penumbra:0,angle:30/180*Math.PI,depth:1e5,penumbraSize:.5,shadowResolution:1024,shadowRadius:1};if(r==="DirectionalLight")return{type:r,color:Re.white,intensity:1,shadows:!0,size:2e3,depth:1e5,penumbraSize:.5,shadowResolution:1024,shadowRadius:1};throw new Error("not implemented")}})(hu||(hu={}));var Ca;(r=>(r.defaultShapeData={type:"PlaneEmitterShape",size:[100,100,100]},r.defaultCollisionData={colliderEntityId:null,collisionBounce:.75},r.defaultData={renderMaterial:{type:"particleMaterial",color:{r:1,g:.2,b:.545,a:1},color2:{r:.945,g:.714,b:.184,a:1},coloring:"gradient",ease:"linearFadeOut",easeSize:"linearFadeOut",transparent:!0,size:[40,40],texture:"pt_default_particle",spriteRotation:[0,0]},birthRatePerSec:50,gravity:1,noiseStrength:0,noiseScale:0,noiseSeed:1,noiseType:"curl",randomRotation:0,randomScale:.2,randomMass:.5,rootObjectType:"instancedMesh",life:1,direction:[0,0,0],directionMode:"axis",speed:10,shape:r.defaultShapeData,autoPlay:!0,emitTimeDelay:0,emitTimeCycle:"infinity",emitTimeDuration:1,...r.defaultCollisionData}))(Ca||(Ca={}));var Bi;(t=>t.defaultData={enabled:"visibility",fusedBody:!0,rigidBody:"positioned",density:1,pointMass:0,gravityScale:1,friction:.5,damping:0,restitution:.2,colliderType:"convex",enabledRotation:[!0,!0,!0],enabledTranslation:[!0,!0,!0]})(Bi||(Bi={}));var qp;(e=>{e.defaultData={castShadow:!0,receiveShadow:!0};function t(r,o){return r.castShadow===o.castShadow&&r.receiveShadow===o.receiveShadow}e.equals=t})(qp||(qp={}));var $p;(e=>{e.defaultData={flatShading:!1,wireframe:!1,side:0};function t(r,o){return r.flatShading===o.flatShading&&r.side===o.side&&r.wireframe===o.wireframe}e.equals=t})($p||($p={}));var mu;(t=>t.defaultData={...$p.defaultData,...qp.defaultData})(mu||(mu={}));var x0;(t=>{function i(e,r){let o=[];if("material"in e){let n=typeof e.material=="string"?r.materials[e.material]??r.lib.materials[e.material]?.asset:e.material;n&&o.push(n)}else if("materials"in e)for(let n of e.materials){let a=typeof n=="string"?r.materials[n]??r.lib.materials[n]?.asset:n;a&&o.push(a)}return o}t.getMaterialData=i})(x0||(x0={}));var Aa;(e=>(e.defaultVideo={data:"",thumb:"/_assets/_videos/catThumb.png",type:"video",name:"Cat video"},e.maxSize=3e7))(Aa||(Aa={}));var b0;(t=>{function i(e){return e==="texture"||e==="video"||e==="color"||e==="depth"||e==="normal"||e==="gradient"||e==="noise"||e==="fresnel"||e==="rainbow"||e==="toon"||e==="outline"||e==="particle"||e==="transmission"||e==="matcap"||e==="displace"||e==="pattern"||e==="light"}t.is=i})(b0||(b0={}));function S0(i){return i.type!=="displace"}var v0;(t=>{function i(e){return e==="phong"||e==="toon"||e==="lambert"||e==="physical"}t.is=i})(v0||(v0={}));var w0=["mode","gradientType","noiseType","displacementType","projection","cnormal","crop","axis","side"],P0=["wrapping","image","video","name","minFilter","magFilter"],Vt;(o=>{function i(n,a){let{texture:s,...l}=a;if(Object.assign(n,l),s){let c=n.texture;c&&Object.assign(c,s)}}o.patch=i;function t(n,a){return n==="light"&&a?e(a):r(n)}o.defaultData=t;function e(n){let a={mode:0,isMask:!1,visible:!0,bumpMap:void 0,bumpMapIntensity:5,roughnessMap:void 0,alphaOverride:1};switch(n){case"phong":return{...a,category:"phong",specular:{r:.2,g:.2,b:.2},shininess:5,type:"light",visible:!0,mode:0,occlusion:!0,alpha:.6};case"toon":return{...a,category:"toon",specular:{r:.2,g:.2,b:.2},shininess:10,type:"light",alpha:1};case"lambert":return{...a,category:"lambert",emissive:{r:0,g:0,b:0},type:"light",alpha:1,visible:!0,mode:0,occlusion:!0};case"physical":return{...a,category:"physical",roughness:.2,metalness:.2,reflectivity:.2,type:"light",alpha:1,visible:!0,mode:0,occlusion:!0}}}function r(n){let a={alpha:1,mode:0,isMask:!1,visible:!0};switch(n){case"texture":return{...a,type:"texture",size:[128,128],blending:0,axis:"x",side:2,projection:0,texture:{image:"image_0",wrapping:1e3,repeat:[1,1],offset:[0,0],rotation:0,minFilter:1008,magFilter:1006},crop:!1};case"video":return{...a,type:"video",size:[128,128],blending:0,axis:"x",side:2,projection:0,texture:{video:Aa.defaultVideo,wrapping:1001,repeat:[1,1],offset:[0,0],rotation:0,minFilter:1008,magFilter:1006},crop:!1};case"color":return{...a,type:"color",color:jt.fromHex(Dt)};case"depth":return{...a,type:"depth",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]],steps:[0,1],near:50,far:200};case"normal":return{...a,type:"normal",cnormal:[1,1,1]};case"gradient":return{...a,type:"gradient",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{...a,type:"noise",size:[100,100,100],noiseType:0,scale:1,move:1,colorA:{...jt.fromHex(6710886),a:1},colorB:{...jt.fromHex(6710886),a:1},colorC:{...jt.fromHex(16777215),a:1},colorD:{...jt.fromHex(16777215),a:1},distortion:[1,1],fA:[1.7,9.2],fB:[8.3,2.8],voronoiStyle:0,highCut:1,lowCut:0,smoothness:.3,seed:0,quality:1};case"fresnel":return{...a,type:"fresnel",color:Re.fromHexAndA(16777215,1),bias:.1,scale:1,intensity:2,factor:1};case"rainbow":return{...a,type:"rainbow",filmThickness:30,movement:0,wavelengths:[0,0,0],noiseStrength:0,noiseScale:1,offset:[0,0,0]};case"toon":return{...a,type:"toon",positioning:2,colors:[[0,0,0,1],[.5,.5,.5,1],[.5,.5,.5,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,.475,.525,1,1,1,1,1,1,1],num:4,source:[0,1e3,0],isWorldSpace:!0,noiseStrength:0,noiseScale:1,shadowColor:Re.fromHexAndA(0,0),offset:[0,0,0]};case"outline":return{...a,type:"outline",outlineColor:Re.fromHexAndA(0,1),contourColor:Re.fromHexAndA(0,1),outlineWidth:2,contourWidth:5,outlineThreshold:.4,contourThreshold:0,outlineSmoothing:0,contourFrequency:10,contourDirection:[0,1,0],positionalLines:!1,compensation:!0};case"matcap":return{...a,type:"matcap",texture:{image:"matcap_0",wrapping:1001,repeat:[1,1],offset:[0,0],rotation:0,minFilter:1008,magFilter:1006}};case"transmission":return{...a,type:"transmission",thickness:10,ior:1.5,roughness:1};case"displace":return{visible:!0,type:"displace",displacementType:"noise",noiseType:0,scale:10,movement:1,offset:[0,0,0],intensity:8,voronoiStyle:0,smoothness:.3,seed:0,highCut:1,lowCut:0,quality:1};case"pattern":return{...a,type:"pattern",style:0,projection:0,axis:"y",blending:0,offset:[0,0],colorA:{...jt.fromHex(0),a:1},colorB:{...jt.fromHex(16777215),a:1},frequency:[10,10],size:.5,variation:0,smoothness:.5,zigzag:0,rotation:0,vertical:[0,1],horizontal:[0,1],sides:6}}}})(Vt||(Vt={}));var Ut;(c=>{function i(u){return!u.layers.some(d=>d.data.type==="texture"&&d.data.projection!==0||d.data.type==="depth"&&!d.data.isWorldSpace||d.data.type==="noise"||d.data.type==="displace")}c.isMergable=i;function t(u){let p="";return u.layers.forEach(d=>{Object.entries(d.data).forEach(([f,h])=>{p+=`${f}${h}`,Array.isArray(h)?h.forEach(m=>p+=`${m}`):typeof h=="object"?Object.values(h).forEach(m=>{typeof m=="number"?p+=`${m.toFixed(4)}`:p+=`${m}`}):p+=`${h}`})}),p}c.getHash=t;function e(){return{layers:new Se}}c.defaultEmptyData=e;function r(u="layer1",p="layer2"){return n("phong",u,p)}c.defaultData=r;function o(u,p){return{...u,name:p}}c.withName=o;function n(u,p="layer1",d="layer2"){let f=new Se;return f.push({fi:0,data:Vt.defaultData("light",u),id:p}),f.push({fi:1,data:Vt.defaultData("color"),id:d}),{layers:f}}c.defaultTwoLayerData=n;function a(u){let p=Vt.defaultData("texture");u&&Object.assign(p.texture,{image:u});let d=new Se;return d.push({fi:0,data:p,id:"layer1"}),d.push({fi:1,data:{...Vt.defaultData("transmission"),alpha:1},id:"layer2"}),d.push({fi:2,data:{...Vt.defaultData("light","lambert"),alpha:0},id:"layer3"}),{layers:d}}c.defaultUIObjectMaterial=a;function s(u,p="phong",d="layer1",f="layer2"){let h=Vt.defaultData("texture");Object.assign(h.texture,{image:u});let m=new Se;return m.push({fi:0,data:h,id:d}),m.push({fi:1,data:Vt.defaultData("light",p),id:f}),{layers:m}}c.defaultTwoLayerTextureData=s;function l(u,p="phong",d="layer1",f="layer2"){let h=Vt.defaultData("video");Object.assign(h.texture,{video:u});let m=new Se;return m.push({fi:0,data:h,id:d}),m.push({fi:1,data:Vt.defaultData("light",p),id:f}),{layers:m}}c.defaultTwoLayerVideoTextureData=l})(Ut||(Ut={}));var Ma;(t=>{function i(){return{points:new Se,roundness:0,shapeHoles:[],isClosed:!1}}t.defaultData=i})(Ma||(Ma={}));var Ia;(t=>{function i(){return{points:new Se,lastInsertionPlane:null,subdivisions:12,isClosed:!1}}t.defaultData=i})(Ia||(Ia={}));var Xp={type:"Ellipse",width:50,height:50,spikes:16,angle:360,innerRadius:0};var yu;(t=>{function i(e,r){let o={...e};return TA.forEach(n=>{Object.assign(o,{[n]:r[n]??e[n]})}),o}t.merge=i})(yu||(yu={}));var gu={shape:Xp,depth:1,offset:0,bevel:50,bevelSides:6,angle:0,twist:0,startScale:1,endScale:1,capType:"flat"},TA=["depth","offset","angle","twist","startScale","endScale"];var fl;(r=>{function i(o){return o==="PolygonGeometry"||o==="RectangleGeometry"||o==="StarGeometry"||o==="TriangleGeometry"||o==="EllipseGeometry"||o==="UIGeometry"}r.is2DParametricMesh=i;function t(o){return o==="PolygonGeometry"||o==="RectangleGeometry"||o==="StarGeometry"||o==="TriangleGeometry"||o==="EllipseGeometry"||o==="PathGeometry"||o==="VectorGeometry"||o==="ConeGeometry"||o==="CubeGeometry"||o==="CylinderGeometry"||o==="DodecahedronGeometry"||o==="HelixGeometry"||o==="IcosahedronGeometry"||o==="LatheGeometry"||o==="PyramidGeometry"||o==="SphereGeometry"||o==="PlaneGeometry"||o==="BackdropGeometry"||o==="TorusGeometry"||o==="TorusKnotGeometry"||o==="BooleanGeometry"||o==="TextGeometry"||o==="InputGeometry"}r.isParametricMesh=t;function e(o){return o==="PolygonGeometry"||o==="RectangleGeometry"||o==="StarGeometry"||o==="TriangleGeometry"||o==="EllipseGeometry"||o==="PathGeometry"||o==="VectorGeometry"||o==="ConeGeometry"||o==="CubeGeometry"||o==="CylinderGeometry"||o==="DodecahedronGeometry"||o==="HelixGeometry"||o==="IcosahedronGeometry"||o==="LatheGeometry"||o==="PyramidGeometry"||o==="SphereGeometry"||o==="PlaneGeometry"||o==="BackdropGeometry"||o==="TorusGeometry"||o==="TorusKnotGeometry"||o==="TextGeometry"||o==="SubdivGeometry"||o==="NonParametricGeometry"}r.isSwappableGeometry=e})(fl||(fl={}));var xu;(t=>{function i(e,r){let o={...e};return Object.assign(o,r),o.type==="PathGeometry"&&"extrusion"in r&&r.extrusion&&(o.extrusion={...e.extrusion},Object.assign(o.extrusion,yu.merge(o.extrusion,r.extrusion))),o}t.merge=i})(xu||(xu={}));var Io;(t=>{function i(e){if(e==="RectangleGeometry")return{width:320,height:320,type:e,cornerRadius:[0,0,0,0],cornerType:0,depth:0,extrudeBevelSize:0,extrudeBevelSegments:1};if(e==="UIGeometry")return{type:e,frame:"",cornerRadius:[0,0,0,0],cornerType:0,width:1,height:1};if(e==="PathGeometry")return{type:e,width:1,height:1,depth:1,path:Ia.defaultData(),extrusion:gu};if(e==="VectorGeometry")return{width:1,height:1,type:e,subdivisions:12,shape:Ma.defaultData(),depth:0,extrudeBevelSize:0,extrudeBevelSegments:1};if(e==="BooleanGeometry")return{type:e,operation:2,width:0,height:0,depth:0,phongAngle:35};if(e==="ShapeBlendGeometry")return{type:e,width:0,height:0,depth:0,resolutionLevel:6,blendRange:100,useChildrenColors:!1};if(e==="TextGeometry")return{type:e,width:100,height:100,depth:0,horizontalAlign:1,verticalAlign:1,fontSize:16,lineHeight:1.2,letterSpacing:0,text:{textValue:""},textTransform:1,font:"Roboto_regular",editable:!1,extrudeBevelSize:0,extrudeBevelSegments:1};if(e==="InputGeometry")return{...t.defaultData("TextGeometry"),type:e,editable:!0};if(e==="SphereGeometry")return{type:"SphereGeometry",width:100,height:100,depth:100,widthSegments:64,heightSegments:64,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:180};throw new Error("not implemented")}t.defaultData=i})(Io||(Io={}));var bu;(t=>t.defaultData={enabled:!1,useBackgroundColor:!1,color:jt.white,near:.1,far:2e3})(bu||(bu={}));var vu;(e=>{let i={opacity:1,blendFunction:13,enabled:!1};e.defaultData={enabled:!1,pixelation:{...i,blendFunction:16,granularity:15},bloom:{...i,blendFunction:16,intensity:1,blurScale:1,luminanceThreshold:.25,luminanceSmoothing:.025,kernelSize:3},chromaticAberration:{...i,offset:[2,2]},vignette:{...i,darkness:1,offset:0},hueSaturation:{...i,hue:3,saturation:0},brightnessContrast:{...i,brightness:.25,contrast:0},depthOfField:{...i,focusDistance:100,focalLength:20,bokehScale:5},noise:{...i,blendFunction:16}}})(vu||(vu={}));var Yp;(t=>t.defaultData={softShadowQuality:"low"})(Yp||(Yp={}));var Kp;(t=>t.defaultData={enabled:!0,color:{r:.8274509803921568,g:.8274509803921568,b:.8274509803921568},intensity:.75})(Kp||(Kp={}));var Qp;(t=>t.defaultData={occlusion:!1,aoFullRes:!1,radius:256,bias:.5,aoColor:{r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}})(Qp||(Qp={}));var hl;(t=>t.defaultData={usePhysics:!1,gravity:-10})(hl||(hl={}));var Zp;(t=>t.defaultData={playCamera:_i,gameControlObject:null})(Zp||(Zp={}));var Su;(t=>t.defaultData={backgroundColor:Re.fromHexAndA(g0,1),postprocessing:vu.defaultData,fog:bu.defaultData,globalPhysics:hl.defaultData,ambient:Kp.defaultData,ao:Qp.defaultData,shadow:Yp.defaultData,publish:Zp.defaultData})(Su||(Su={}));var wu;(t=>t.defaultData={colliderType:"box",size:[100,100,100],colliderHelperVisible:!0,forceType:"collider",forceRange:"global",forceIntensity:.5,forceDambing:.95})(wu||(wu={}));var O0;(e=>{function i(r){return r==="Component"||r==="Instance"}e.isComponentRelated=i;function t(r){return r==="Empty"||r==="Instance"}e.isEmptyOrComponent=t})(O0||(O0={}));var Ea;(o=>{o.identity={...du.identity,hiddenMatrix:Di.identity};function t(n){return{position:n.position,rotation:n.rotation,scale:n.scale,hiddenMatrix:n.hiddenMatrix}}o.fromObject=t;function e(n,a){return{position:a?.position||n.position,rotation:a?.rotation||n.rotation,scale:a?.scale||n.scale,hiddenMatrix:a?.hiddenMatrix||n.hiddenMatrix}}o.merge=e;function r(n,a){return bc({position:Ni.isEqual(n.position,a.position)?void 0:a.position,rotation:Ni.isEqual(n.rotation,a.rotation)?void 0:a.rotation,scale:Ni.isEqual(n.scale,a.scale)?null:a.scale,hiddenMatrix:Di.isEqual(n.hiddenMatrix,a.hiddenMatrix)?void 0:a.hiddenMatrix})}o.diff=r})(Ea||(Ea={}));var _t;(t=>t.defaultData={states:new Se,events:new Se,timelineAnimations:new de,visible:!0,raycastLock:!1,physics:Bi.defaultData,pathSnapping:{pathId:null,slide:0,offset:0,orientation:"tangential"},...Ea.identity,cloner:null})(_t||(_t={}));var Pu;(t=>t.defaultData={type:"Empty",..._t.defaultData})(Pu||(Pu={}));var T0;(t=>t.defaultData={type:"ParticleCollider",...wu.defaultData,..._t.defaultData})(T0||(T0={}));var C0;(t=>t.defaultData={type:"Component",..._t.defaultData})(C0||(C0={}));var A0;(t=>t.defaultData={type:"Particle",..._t.defaultData,...Ca.defaultData})(A0||(A0={}));var ei;(t=>t.defaultData={type:"Mesh",..._t.defaultData,...mu.defaultData})(ei||(ei={}));var Pn;(t=>t.defaultData={..._t.defaultData,...Ea.identity,position:[0,0,Li.DefaultTargetOffset],...Li.defaultData})(Pn||(Pn={}));var Ou;(e=>{function i(r){return{..._t.defaultData,...hu.defaultData(r)}}e.defaultData=i,e.defaultDirectionalLightData={...e.defaultData("DirectionalLight"),position:[200,300,300],name:"Directional Light",intensity:.7}})(Ou||(Ou={}));var Na;(e=>{function i(r,o,n=0){for(;n<o.length;){let a=r?r[o[n]]:void 0;if(o.length===n+1)return a;if(a)r=a.descendants,n+=1;else return}}e.resolveWithDes=i;function t(r,o,n=0){let a=i(r,o,n);if(a){let s=Object.keys(a);if(s.length===1&&s[0]==="descendants")return}return a}e.resolve=t})(Na||(Na={}));var Eo;(n=>{n.rootOverrideProps=["physics","events"],n.compositeNonOptionalOverrideProps=["geometry"],n.compositeEntireOverrideOverrideProps=["material"];function r(a,s){return{..._t.defaultData,...s,component:a,overrides:new Je,physics:void 0,events:void 0,type:"Instance"}}n.ofComponent=r;function o(a){let s=Ea.fromObject(a.data);return r(a.id,s)}n.fromComponentData=o})(Eo||(Eo={}));var ti;(e=>{e.defaultData={type:"Page",..._t.defaultData,physics:{...Bi.defaultData,fusedBody:!1},...Su.defaultData,camera:Pn.defaultData};function t(r){return r.uiScene!==void 0}e.isUIPage=t})(ti||(ti={}));var Tu;(s=>(s.defaultCamera={position:[0,0,1e3],scale:[1,1,1],rotation:[0,0,0],hiddenMatrix:Di.identity,name:"Play Camera",visible:!0,raycastLock:!1,physics:Bi.defaultData,states:new Se,events:new Se,timelineAnimations:new de,cloner:null,pathSnapping:{pathId:null,orientation:"tangential",slide:0,offset:0},...Li.defaultData},s.KeysByResetCategory={States:["states"],Events:["events"],Material:["material","materials"],Geometry:["geometry"],Position:["position"],Rotation:["rotation"],Scale:["scale"],Transform:["position","scale","rotation","hiddenMatrix"],Name:["name"],Visibility:["visible","raycastLock","flatShading","wireframe","side"],Shadows:["castShadow","receiveShadow"],Cloner:["cloner"],Physics:["physics"]},s.defaultMeshObject={name:"Rectangle",..._t.defaultData,...ei.defaultData,geometry:Io.defaultData("RectangleGeometry"),material:Ut.defaultTwoLayerData("phong","layer1","layer2")},s.defaultBooleanObject={name:"Boolean",..._t.defaultData,...ei.defaultData,geometry:Io.defaultData("BooleanGeometry"),material:Ut.defaultTwoLayerData("phong","layer1","layer2")},s.defaultShapeBlendObject={name:"Shape Blend",..._t.defaultData,...ei.defaultData,geometry:Io.defaultData("ShapeBlendGeometry"),material:Ut.defaultTwoLayerData("phong","layer1","layer2")},s.defaultTextObject={name:"Text",..._t.defaultData,...ei.defaultData,geometry:Io.defaultData("TextGeometry"),material:Ut.defaultTwoLayerData("phong","layer1","layer2")},s.defaultInputObject={name:"Input",..._t.defaultData,...ei.defaultData,geometry:Io.defaultData("InputGeometry"),material:Ut.defaultTwoLayerData("phong","layer1","layer2")}))(Tu||(Tu={}));var On;(o=>{function i(n,a){let s={name:a};return n.type==="Mesh"?(s.geometry={},"material"in n&&(s.material={layers:new Je}),"materials"in n&&(s.materials=n.materials.map(l=>({layers:new Je})))):oo.is(n.type)&&(s.perspective={},s.orthographic={}),s}o.newEmpty=i;function t(n,a){if(a===void 0)return n;let s={...n};return"material"in s&&"material"in a&&a.material&&(s.material=Ai(s.material,l=>{if(typeof l!="string")for(let[c,u]of Object.entries(a.material.layers)){let p=l.layers.data(c);p&&Vt.patch(p,u)}}).data),s.materials&&a.materials&&(s.materials=Ai(s.materials,l=>{for(let c=0;c<s.materials.length;c++){let u=a.materials[c];if(typeof u!="string")for(let[p,d]of Object.entries(u.layers)){let f=l[c]?.layers?.data(p);f&&Vt.patch(f,d)}}}).data),s}function e(n,a){let s,l=[],c={orthographic:0,perspective:0,geometry:0};function u(p,d){for(let[f,h]of Object.entries(d.layers)){let{texture:m,...y}=h;if(m!==void 0&&Object.keys(m).length>0){let b={path:[...p,"layers",f,"texture"],props:m,type:0};l.push(b)}if(Object.keys(y).length>0){let b={path:[...p,"layers",f],props:y,type:0};l.push(b)}}}for(let[p,d]of Object.entries(a))if(p!=="name")if(p==="cloner")l.push(...pu.toOps(d,["cloner"]));else if(p==="pathSnapping")l.push({path:[p],props:{slide:d.slide,offset:d.offset},type:0});else if(p==="material")u(["material"],d);else if(p==="materials")for(let[f,h]of Object.entries(d))u(["materials",f],h);else if(c[p]===0){if(p==="geometry"&&d.extrusion!==void 0){let f={path:[p,"extrusion"],props:d.extrusion,type:0};l.push(f),d={...d},delete d.extrusion}if(Object.keys(d).length>0){let f={path:[p],props:d,type:0};l.push(f)}}else s===void 0&&(s={path:[],props:{},type:0},l.push(s)),s.props[p]=d;return l}o.toOps=e;function r(n,a){if(a===void 0)return n;let s={...n};if(Object.assign(s,Ea.merge(s,a)),Object.assign(s,{pathSnapping:Object.assign({},s.pathSnapping,{slide:a.pathSnapping?.slide??s.pathSnapping?.slide??0,offset:a.pathSnapping?.offset??s.pathSnapping?.offset??0})}),oo.is(n.type)){s.orthographic={...s.orthographic},s.perspective={...s.perspective};let l=a;l.orthographic?.zoom!==void 0&&(s.orthographic.zoom=l.orthographic.zoom),l.perspective?.zoom!==void 0&&(s.perspective.zoom=l.perspective.zoom),l.isUpVectorFlipped!==void 0&&(s.isUpVectorFlipped=l.isUpVectorFlipped),l.targetOffset!==void 0&&(s.targetOffset=l.targetOffset)}else if(n.type==="Mesh")"geometry"in a&&Object.assign(s,{geometry:xu.merge(s.geometry,a.geometry)}),(a.material||a.materials)&&(s=t(s,a)),s.cloner&&"cloner"in a&&Object.assign(s,{cloner:Mo.merge(s.cloner,a.cloner)});else if(n.type==="Empty")s.cloner&&"cloner"in a&&Object.assign(s,{cloner:Mo.merge(s.cloner,a.cloner)});else if(fu.is(n.type)){let l=a;l.intensity!==void 0&&(s.intensity=l.intensity),l.color!==void 0&&(typeof l.color=="string"?s.color=l.color:s.color=jt.clone(l.color))}return s}o.patch=r})(On||(On={}));var Da;(t=>t.defaultData={enablePan:!0,enableZoom:!0,enableRotate:!0,enableDamping:!0,rotationLimitsMode:0,rotationVerticalOffset:{min:Math.PI/4,max:Math.PI/4},rotationHorizontalOffset:{min:Math.PI/4,max:Math.PI/4},rotationSoftLimit:2,panLimitsMode:0,panVerticalOffset:{min:250,max:250},panHorizontalOffset:{min:250,max:250},panSoftLimit:2,zoomLimitsEnabled:!1,zoomLimits:{min:.1,max:2},autoRotate:!1,autoRotateSpeed:2,autoRotateClockwise:!0,hoverRotatePanMode:0,hoverRotatePanStrength:20,hoverRotateDamping:.125,isTouchZoom:!0,orbitTouches:2,panTouches:3,resetHoverEffectOnPointerLeave:!0})(Da||(Da={}));var Ur;(t=>t.defaultData={orbitControls:Da.defaultData,playPage:Ri,withBackground:!0,preventScroll:!1,preventTouchScroll:!1,hideCursor:!1,mouseEventTarget:"canvas",joystickSizeAndXYOffset:Array(12).fill(0).map((e,r)=>{let o=0,n=0;return r<5?n=-30:r<10&&(n=30),r===0||r===10||r===5?o=30:(r===4||r===11||r===9)&&(o=-30),[120,[o,n],"show"]}),settings:{image:{format:"jpg",ratio:1},videoStatic:{fps:60,mbps:150,ratio:1,duration:1e3,activeTimeline:null},video:{format:"mp4",imageFormat:"jpg",fps:30,mbps:80,ratio:Math.max(1,typeof window<"u"?Math.floor(window.devicePixelRatio):1),stopMode:"manual",duration:5e3},web:{logo:!0,compress:!0,preset:1,preload:!0,hint:!1,imageQuality:70,pixelRatioMobile:0,pixelRatioDesktop:0}},stopRaycast:!0,hdTransmission:!1})(Ur||(Ur={}));var Jp;(t=>t.defaultData={id:"basic",label:"Basic",style:"None",prompt:""})(Jp||(Jp={}));var ef;(t=>t.defaultData={weather:0,shadows:0,lightOrigin:0,temperature:0,sun:0,camera:0,environment:0,particles:0,nature:0,floor:0})(ef||(ef={}));var ri;(e=>(e.defaultData=()=>({mode:"line-art-both",prompt:"",negativePrompt:"",style:{...Jp.defaultData},isRandomSeed:!0,seed:e.generateSeed(),guessMode:!1,advanced:!1,steps:20,guidanceScale:7.5,controlNetScale:1,modifiers:ef.defaultData}),e.generateSeed=()=>Math.round(Math.random()*1e5)))(ri||(ri={}));var M0;(e=>{function i(r){return r.find(o=>o.data.type==="Page"&&o.data.globalPhysics.usePhysics)!==void 0}e.physicsEnabled=i;function t(r,o,n){r.scene.objects.traverseFrom(o,(a,s)=>{if(s.type==="Instance"){let l=_a.getComponentData(r,s.component)?.data;l&&n(a,s,l.events)}else n(a,s,s.events)})}e.traverseModuleInstances=t})(M0||(M0={}));var oi;(c=>{c.TRASH_CAN_ID="830a2708-8ed9-49cf-a68e-085299892222",c.defaultLight={fi:-1,data:Ou.defaultDirectionalLightData,id:"830a2708-8ed9-49cf-a68e-085299899103",children:[]};function e(u=!0,p=[]){let d=[],f=Tu.defaultMeshObject;u&&(d.push({...c.defaultLight}),d.push({fi:1,id:"7ba78968-2a55-48f2-b14c-5191da3e075e",data:f,children:[]})),d.push(...p);let h=new ct;return h.push({fi:1,id:Ri,data:{...ti.defaultData,name:"Scene 1"},children:d}),h}c.createDefaultObjectTreeWithPage=e,c.defaultData={objects:e(),publish:Ur.defaultData,styles:ri.defaultData()},c.emptyDataWithoutPage=function(){return{objects:new ct,publish:Ur.defaultData,styles:ri.defaultData()}},c.emptyDataWithPage=function(u=!0){return{objects:e(u),publish:Ur.defaultData,styles:ri.defaultData()}},c.emptyData=function(){return{objects:new ct,publish:{...Ur.defaultData},styles:ri.defaultData()}};function s(u){return{...c.defaultData,objects:Ft(u,ct.prototype)}}c.withObjs=s;function l(u,p){return s([{id:u,data:p,children:[],fi:0}])}c.withObj=l})(oi||(oi={}));var Ra;(t=>t.defaultData={preset:"fullscreen",allowResponsive:!1,size:[512,512],coords:[0,0],sceneScale:1,color:{r:0,g:0,b:0,a:.5}})(Ra||(Ra={}));var Cu;(e=>(e.defaultData=r=>({url:r,name:"New Webhook",parametersSchemas:new Se}),e.defaultParameterValueByType=r=>r==="number"?0:r==="boolean"?!1:""))(Cu||(Cu={}));var I0;(t=>t.defaultData=(e,r="GET")=>({url:e,method:r,name:"New API",headers:new Se,queries:new Se,autoStart:!0}))(I0||(I0={}));var Vi;(n=>{function i(a){return a.textValue!==void 0}n.isTextValue=i;function t(a){return typeof a=="number"}n.isNumber=t;function e(a){return typeof a=="boolean"}n.isBoolean=e;function r(a){return i(a)?"string":e(a)?"boolean":"number"}n.typeOfVariable=r;function o(a){return n.isTextValue(a)?Array.isArray(a.textValue)?a.textValue.map(s=>s.toString().padStart(a.padding??2,"0")).join(a.deliminator??":")+(a.suffix!==void 0?" "+a.suffix:""):a.textValue.toString():n.isBoolean(a)?a?"True":"False":n.isNumber(a)?parseFloat(a.toFixed(3)).toString():a.toString()}n.getDisplayedValue=o})(Vi||(Vi={}));var tf;(t=>t.all=["images","videos","colors","audios","particles","fonts","materials","variables"])(tf||(tf={}));var E0;(t=>t.all=[...tf.all,"components"])(E0||(E0={}));var N0;(t=>{function i(){return{images:new de,videos:new de,colors:new de,audios:new de,particles:new de,fonts:new de,materials:new de,components:new de,variables:new de,userAPIs:new de,userWebhooks:new de,timelineAnimations:new de}}t.defaultData=i})(N0||(N0={}));var io;(t=>{function i(){return{images:new de,videos:new de,colors:new de,audios:new de,particles:new de,fonts:new de,materials:new de,components:new de,variables:new de,userAPIs:new de,userWebhooks:new de,timelineAnimations:new de}}t.defaultData=i})(io||(io={}));var kr;(n=>{function i(){let a={};return a["89b10010-844c-11ec-a8a3-0242ac120002"]={r:.5,g:.5,b:.5,a:1,name:"Default Color"},Ft(a,de.prototype)}n.defaultColors=i;function t(){return Ft({},de.prototype)}n.defaultImages=t;function e(){return{catelogs:new de,materials:new de,images:new de,videos:new de,colors:new de,timelineAnimations:new de,audios:new de,particles:new de,fonts:new de,variables:new Se,userAPIs:new de,userWebhooks:new de,lib:io.defaultData()}}n.emptyData=e;function r(a){switch(a){case"number":return{value:0,name:"Number"};case"boolean":return{value:!1,name:"Boolean"};case"string":return{value:{textValue:"String value"},name:"String"};case"time":let s=[0,0,0];return{name:"Time",value:{textValue:s,deliminator:":",padding:2,suffix:"AM"},dynamicVariableType:"time",format:"HH:mm:ss",format12h24h:"12ampm",timeZone:null,hasEnd:!1,endValue:{textValue:s,deliminator:":",padding:2,suffix:"AM"},autoStart:!0,repeat:!1};case"counter":return{name:"Counter",value:0,dynamicVariableType:"counter",updateInterval:1e3,increment:1,autoStart:!0,hasEnd:!0,endValue:60,repeat:!0,randomStart:!1,range:[0,100],decimals:0};case"random":return{name:"Random",value:0,dynamicVariableType:"random",updateInterval:1e3,increment:1,autoStart:!0,isStatic:!1,hasEnd:!0,endValue:60,repeat:!0,min:0,max:100,decimals:0};default:console.error("Unknown variable type",a)}}n.defaultVariables=r;function o(a,s){if(s.format==="HH:mm:ss"){let l=Math.floor(a/3600),c=Math.floor((a-l*3600)/60),u=Math.round(a-l*3600-c*60);return{textValue:[l,c,u]}}else if(s.format==="mm:ss"){let l=Math.floor(a/60),c=Math.round(a-l*60);return{textValue:[l,c]}}else return s.format==="number"?a=Math.round(a):a=Math.round(a*1e3)/1e3,a}n.getFormattedTimerTime=o})(kr||(kr={}));var ml=require("three");var Au;(t=>t.list=["idle","move","jump","run"])(Au||(Au={}));var Mu;(e=>(e.defaultColliderData={type:"capsule",height:200,radius:50,position:[0,0,0],rotation:[0,0,0]},e.defaultDataThirdPerson={moveMode:"walk",forwardDirection:"+z",speedTranslate:1e3,speedRotate:100,runMultiplier:2,rotationMode:"normal",rotBy:"keys",rotByTouch:"drag",delayPos:[.3,.3],delayRot:[.3,.3],keyAssignments:[["moveNegZ","W"],["moveNegX","A"],["movePosZ","S"],["movePosX","D"],["rotPosX","\u25B2"],["rotPosY","\u25C0"],["rotNegX","\u25BC"],["rotNegY","\u25B6"],["jump","Space"],["run","\u21E7"],["none","Ctrl"]],touchControl:!0,joystickPosLoc:5,joystickRotLoc:11,jumpTouchButtonLoc:9,collider:e.defaultColliderData,colliderHelperVisible:!0,collisionEnabled:!0,jumpPower:100,resetYPosition:3e3,alignToGround:!1,autoOrientMove:!0,orientWith:"camera",orientMode:"radial",delayPosCamera:.3,delayRotCamera:.3,camera:"",cameraXAxis:"Limit",cameraYAxis:"Free",cameraRotXLimits:[0,Math.PI/2],cameraRotYLimits:[-Math.PI/2,Math.PI/2],gameActions:{idle:new Se,move:new Se,jump:new Se,run:new Se},navmesh:{enabled:!1,ch:6,cs:6,walkableClimb:5,walkableHeight:1,walkableRadius:0,zones:"all",objects:[],helperVisible:!0,destinationHelperRadius:0,destinationHelperColor:Re.fromHexAndA(3728051,1)}}))(Mu||(Mu={}));function D0(i){i.layers.forEach(t=>{if(t.type==="depth"&&t.colorA!==void 0){let e=t.colorA,r=t.colorB,o=[[e.r,e.g,e.b,e.a],[r.r,r.g,r.b,r.a]],n=[0,1];for(let s=2;s<10;s++)o.push(o[1]),n.push(1);let a={...ro(vt(t),"type","visible","isVector","isWorldSpace","origin","alpha","mode"),near:Math.max(0,t.near),far:Math.max(0,t.far),colors:o,steps:n,num:2,direction:[1,0,0],smooth:!1,gradientType:1};Object.assign(t,a)}else if(t.type==="depth"&&t.gradientType===1&&(t.near<0||t.far<0)){let e={...vt(t),near:Math.max(t.near,0),far:Math.max(t.far,0)};Object.assign(t,e)}})}function ii(i,t){Object.values(i.shared.materials).forEach(e=>t(e))}function ni(i,t){i.scene.objects.traverse((e,r)=>{"materials"in r?r.materials.forEach((o,n)=>{o===void 0&&(r.materials[n]=Ut.defaultData(),o=r.materials[n]),typeof o!="string"&&t(o)}):"material"in r?typeof r.material!="string"&&(r.material===void 0&&(r.material=Ut.defaultData()),t(r.material)):r.type==="Mesh"&&(r.material===void 0&&(r.material=Ut.defaultData()),t(r.material)),"overrides"in r&&Object.values(r.overrides).forEach(o=>{o.material&&typeof o.material!="string"&&Object.getPrototypeOf(o.material)!==Je.prototype&&t(o.material)})})}function CA(i){Object.assign(i.scene.publish,{orbitControls:{...Da.defaultData,...vt(i.scene.publish.orbitControls)}})}function AA(i){Object.assign(i.scene.publish.settings,{video:{...Ur.defaultData.settings.video,...vt(i.scene.publish.settings.video)}})}function MA(i){function t(e){if(e.layers){for(let r of Object.values(e.layers))if(r){for(let[o,n]of Object.entries(r))if((w0.includes(o)||typeof n=="boolean")&&delete r[o],o==="texture")for(let[a,s]of Object.entries(n))(P0.includes(a)||typeof s=="boolean")&&delete n[a]}}}i.scene.objects.traverse((e,r)=>{r.states.forEach(o=>{let n=o;n.material?t(n.material):n.materials&&n.materials.forEach(a=>{t(a)})})})}function IA(i){i.scene.publish.withBackground=!0}function EA(i){i.scene.publish.settings.web={compress:!0,preload:!0,preset:1,logo:!0,hint:!1}}function NA(i){i.scene.objects.traverse((t,e)=>{let r=e.cloner;r&&(r.radial.scale=r.radial.scale.map(o=>o+1),r.linear.scale=r.linear.scale.map(o=>o+1))})}function DA(i){i.scene.objects.traverse((t,e)=>{let r=e.geometry;r&&(r.type==="DodecahedronGeometry"||r.type==="IcosahedronGeometry")&&(r.detail=Math.round(r.detail))})}function _A(i){i.scene.objects.traverse((t,e)=>{let r=i.scene.objects.unproxy().parent(t);if(r){let o=vt(i.scene.objects.data(r));o&&o.type==="Mesh"&&o.geometry.type==="BooleanGeometry"&&e.type==="Mesh"&&(e.visible=vt(e).booleanExclude!==!0)}})}function RA(i){i.scene.objects.traverse((t,e)=>{if(e.type==="Mesh"){let r=e;e.geometry.type==="NonParametricGeometry"?r.material!==void 0&&delete r.material:r.materials!==void 0&&delete r.materials}})}function LA(i){function t(r){Object.setPrototypeOf(r,Je.prototype),r.texture&&Object.setPrototypeOf(r.texture,Je.prototype)}function e(r){Object.setPrototypeOf(r,Je.prototype);for(let o in r)t(r[o])}i.scene.objects.traverse((r,o)=>{o.states.forEach(n=>{let a=n;if(a.material){let s=vt(a.material).layers;e(s),a.material.layers=s}if(a.materials)for(let s=0;s<a.materials.length;s++){let l=a.materials[s],c=vt(l).layers;e(c),l.layers=c}})})}function _0(i){i.layers===void 0&&Object.assign(i,Ut.defaultTwoLayerData("lambert"))}function rf(i){!i.layers||i.layers.forEach(t=>{if(t.type==="depth"&&t.colors.length===10){let e=[...t.colors];e.push(t.colors[9]);let r=[...t.steps];r.push(t.steps[9]);let o={...vt(t),colors:e,steps:r};Object.assign(t,o)}})}function BA(i){i.scene.objects.traverse((t,e)=>{e.type==="Mesh"&&(e.geometry.type==="BooleanGeometry"||e.geometry.type==="SubdivGeometry")&&(e.geometry.phongAngle=35)})}function R0(i){i.scene.objects.traverse((t,e)=>{"materials"in e?e.materials.forEach(r=>{typeof r!="string"&&rf(r)}):"material"in e&&typeof e.material!="string"&&rf(e.material)}),Object.values(i.shared.materials).forEach(t=>rf(t))}function VA(i){i.scene.environment.ambientLight.softShadows=!1,i.scene.environment.ambientLight.softShadowQuality="low",i.scene.objects.traverse((t,e)=>{(e.type==="DirectionalLight"||e.type==="SpotLight")&&(e.shadowResolution=1024,e.shadowRadius=1,e.depth=1e5)}),i.shared.penumbraSize=new Array(5).fill(.5)}function zA(i){i.shared.audios=Ft({},de.prototype)}function GA(i){i.shared.videos=Ft({},de.prototype)}function FA(i){let t=i.shared.materials;Object.entries(t).forEach(([e,r])=>{if(!r.layers){let o={name:"Untitled Material",layers:[{fi:0,data:{type:"light",category:"phong",alpha:.6,visible:!0,mode:0,specular:{r:.2,g:.2,b:.2},shininess:5},id:"layer1"},{fi:1,data:{type:"color",alpha:1,visible:!0,mode:0,color:{r:.2823529411764706,g:.2823529411764706,b:.30196078431372547}},id:"layer2"}]};Object.assign(t,{[e]:o})}})}function jA(i){Object.entries(vt(i.shared.images)).filter(r=>r[1].asset===!1).map(r=>r[0]).forEach(r=>{delete i.shared.images[r]}),Object.entries(vt(i.shared.audios)).filter(r=>r[1].asset===!1).map(r=>r[0]).forEach(r=>{delete i.shared.audios[r]})}function UA(i){i.scene.publish.settings.web.preload=!1}function L0(i){i.layers&&i.layers.forEach(t=>{t.type==="depth"&&t.num!==void 0&&(t.colors=t.colors.slice(0,t.num),t.steps=t.steps.slice(0,t.num),delete t.num)})}function B0(i){i.layers&&i.layers.forEach(t=>{S0(t)&&t.isMask===void 0&&(t.isMask=!1),(t.type==="texture"||t.type==="video")&&t.blending===void 0&&(t.blending=0),(t.type==="noise"||t.type==="displace"&&t.displacementType==="noise")&&(t.voronoiStyle===void 0&&(t.voronoiStyle=0),t.highCut===void 0&&(t.highCut=1),t.lowCut===void 0&&(t.lowCut=0),t.smoothness===void 0&&(t.smoothness=.3),t.seed===void 0&&(t.seed=0),t.quality===void 0&&(t.quality=1))})}function kA(i){i.shared.fonts=Ft({},de.prototype)}function HA(i){return i.replace(".typeface","").replace(/optimer/gi,"open sans").replace("space_mono","space mono").replace(/alma_mono/gi,"varela round").replace(/droid_sans_mono/gi,"noto sans mono").replace(/droid_sans|gentilis|gnomon_(simple|foreground)|helvetiker/gi,"roboto").replace(/droid_serif/gi,"roboto slab").replace("_sans"," sans").replace("crimson_text","crimson text").replace("medium_medium","medium").replace("fatface_fatface","fatface").replace("100hairline","thin").replace("200thin","extralight").replace("300light","light").replace("500medium","medium").replace("600semi","semibold").replace("800heavy","extrabold").replace("900black","black").replace(/bodoni_(11|16|24|36|48|72|96)([^_])/gi,"bodoni_$1_$2").replace(/bodoni_(11|16|24|36|48|72|96)/gi,"bodoni moda").replace(/(thin|hairline)(_regular)?/gi,"100").replace(/(extra|ultra)light(_regular)?/gi,"200").replace(/light(_regular)?/gi,"300").replace(/_book|_normal|_roman/gi,"_regular").replace(/medium(_regular)?/gi,"500").replace(/(semi|demi)bold(_regular)?/gi,"600").replace(/(extra|ultra)bold(_regular)?/gi,"800").replace(/bold(_regular)?/gi,"700").replace(/(black|heavy|fatface)(_regular)?/gi,"900").replace(/([1-9]00)_italic/gi,"$1italic").replace(/regularitalic/gi,"italic").replace(/regularitalic/gi,"italic").split(" ").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ")}function WA(i){let t=[];i.scene.objects.traverse((e,r)=>{let o=r;if(o.type==="TextFrame"){let n=Ut.defaultTwoLayerData("phong"),a=typeof o.color=="string"?i.shared.colors[o.color]:o.color;n.layers[1].data.color={r:a.r,g:a.g,b:a.b},n.layers[1].data.alpha=o.alpha;let s=HA(o.font);i.shared.fonts[s]===void 0&&(i.shared.fonts[s]={name:s});let l={name:o.name,..._t.defaultData,...ei.defaultData,flatShading:!1,wireframe:!1,geometry:{...Io.defaultData("TextGeometry"),width:o.width,height:o.height,font:s,depth:0,horizontalAlign:o.horizontalAlign,verticalAlign:o.verticalAlign,fontSize:o.fontSize*1.40625,lineHeight:o.lineHeight/1.40625,letterSpacing:o.letterSpacing-1,text:o.text,textTransform:o.textTransform,extrudeBevelSize:0,extrudeBevelSegments:1},material:n,states:vt(o.states),events:vt(o.events),visible:o.visible,raycastLock:o.raycastLock,position:o.position,rotation:o.rotation,scale:o.scale,hiddenMatrix:o.hiddenMatrix},c=vt(i.scene.objects).parent(e);i.scene.objects.insertAfter(c??null,e,[{id:e+"new",data:l,children:[]}]),t.push(e)}}),t.forEach(e=>{i.scene.objects.delete(e)})}function qA(i){let t={0:"MouseDown",1:"MouseUp",2:"MouseHover",5:"KeyDown",6:"KeyUp",7:"Start",9:"LookAt",10:"Follow",11:"Scroll",12:"Audio",13:"GameControl"};i.scene.objects.traverse((e,r)=>{r.events.forEach(o=>{if(!!t[Number(o.type)])if(Object.assign(o,{type:t[Number(o.type)]}),o.type==="Audio"&&"audioEvent"in o&&(Object.assign(o,{playAudio:o.audioEvent}),delete o.audioEvent),o.type==="GameControl")Object.assign(o,{gameActions:{idle:new Se,move:new Se,jump:new Se}});else{let n=new Se;Object.assign(o,{actions:n}),(o.type==="MouseDown"||o.type==="MouseUp"||o.type==="KeyDown"||o.type==="KeyUp")&&"url"in o&&n.push({fi:0,id:ml.MathUtils.generateUUID(),data:{type:"Link",url:o.url,delay:0}}),"targets"in o&&(o.targets.forEach((a,s,l)=>{let c={state:void 0,repeat:0,delay:0,delayDirection:void 0,direction:"normal",duration:0,easing:4},u={easing:a.easing,duration:a.duration};a.easing===6?Object.assign(u,ro(a,"mass","stiffness","damping","velocity")):a.easing===5&&Object.assign(u,{control1:{...a.control1},control2:{...a.control2}});let p={repeat:a.repeat?-1:0,delay:a.delay,delayDirection:a.delayDirection,direction:a.cycle&&a.rewind?"pingpong-rewind":a.cycle?"pingpong":"normal"},d={state:a.state,...p,...u},f={allowSlerp:!0,type:"Transition",object:a.object,repeat:0,delay:0,delayDirection:void 0,direction:"normal",tweens:new Se({fi:0,id:ml.MathUtils.generateUUID(),data:c},{fi:1,id:ml.MathUtils.generateUUID(),data:d})};n.push({fi:l,id:s,data:f})}),delete o.targets)}})})}function $A(i){i.scene.objects.traverse((t,e)=>{function r(o,n){let a=new Se,s=[];if(e.events.forEach((l,c,u)=>{if(l.type==="Audio"&&l.trigger===n){let p;s.push(c),l.interaction==="play"?p={...ro(l,"interaction","audio","delay","volume","loop"),triggerAfter:"after"in l?l.after:void 0,toggle:"after"in l?l.toggle:void 0,type:"Audio"}:(l.interaction==="pause"||l.interaction==="stop")&&(p={...ro(l,"interaction","delay","object","playAudio"),type:"Audio"}),p&&a.push({fi:u,id:c,data:p})}}),s.forEach(l=>e.events.delete(l)),a.length){let l=e.events.find(c=>c.type===o)?.data;l?"actions"in l&&l.actions.insertBefore(null,a):e.events.insertBefore(null,[{id:ml.MathUtils.generateUUID(),data:{type:o,actions:a}}])}}r("Start","start"),r("MouseDown","mouseDown"),r("MouseUp","mouseUp"),r("KeyDown","keyDown"),r("KeyUp","keyUp")})}function V0(i){let t=i.layers.find(e=>e.type==="light")?.data;if(t?.category==="basic"){let e=Vt.defaultData("light","phong"),r=t;Object.assign(r,e),r.visible=!1}}function z0(i){ii(i,V0),ni(i,V0)}function XA(i){i.scene.objects.traverse((t,e)=>{e.type==="Mesh"&&e.geometry.type==="SubdivGeometry"&&(e.geometry.scaleBaked||(e.geometry.scaleBaked=[1,1,1]))})}function YA(i){i.scene.objects.traverse((t,e)=>{(e.type==="Empty"||e.type==="Mesh")&&e.cloner&&!e.cloner.randomnessObject&&!e.cloner.toObject&&!e.cloner.randomness&&(e.cloner={...e.cloner,toObject:{object:"",spreadType:"random",scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],axis:"x",seed:0,count:99,align:"normal"},randomness:!1,randomnessObject:{strength:100,scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],movement:1,seed:0,freqScale:10,noiseType:"perlin"}})})}function KA(i){i.scene.objects.traverse((t,e)=>{e.type==="Mesh"&&e.geometry.type==="NonParametricGeometry"&&!("material"in e)&&!("materials"in e)&&(e.material=Ut.defaultTwoLayerData("phong"))})}function QA(i){i.scene.publish.orbitControls.autoZoom===void 0&&(i.scene.publish.orbitControls.autoZoom=!1),i.scene.objects.traverse((t,e)=>{(e.type==="OrthographicCamera"||e.type==="PerspectiveCamera")&&(e.orthographic.autoZoom===void 0&&(e.orthographic.autoZoom=!1),e.orthographic.autoZoomFrustumSize===void 0&&(e.orthographic.autoZoomFrustumSize=790))})}function ZA(i){i.scene.objects.traverse((t,e)=>{e.pathSnapping===void 0&&(e.pathSnapping={pathId:null,slide:0,offset:0,orientation:"tangential"}),e.pathSnapping.offset===void 0&&(e.pathSnapping.offset=0)})}function JA(i){i.scene.publish.mouseEventTarget===void 0&&(i.scene.publish.mouseEventTarget="canvas"),i.scene.publish.settings.web.hint===void 0&&(i.scene.publish.settings.web.hint=!1)}function eM(i){let{video:t}=i.scene.publish.settings;t.format==="gif"&&t.fps>48&&(t.fps=15)}function tM(i){i.scene.objects.traverse((t,e)=>{e.events.forEach(r=>{r.type==="GameControl"&&(r.resetYPosition=Math.abs(r.resetYPosition-e.position[1]))})})}function rM(i){let t=i.scene.environment.usePhysics;i.scene.objects.traverse((e,r)=>{t&&r.physics===null?r.collision=!1:r.collision="visibility"})}function oM(i){i.scene.objects.traverse((t,e)=>{e.events.forEach(r=>{r.type==="GameControl"&&(r.navmesh=Mu.defaultDataThirdPerson.navmesh)})})}function iM(i){i.scene.styles||(i.scene.styles=ri.defaultData())}function G0(i){i.layers.forEach(t=>{t.type==="light"&&t.category!=="toon"&&t.occlusion===void 0&&(t.occlusion=!0)})}function nM(i){i.scene.environment.ambientLight.occlusion===void 0&&(i.scene.environment.ambientLight.occlusion=!1),i.scene.environment.ambientLight.aoFullRes===void 0&&(i.scene.environment.ambientLight.aoFullRes=!1),i.scene.environment.ambientLight.radius===void 0&&(i.scene.environment.ambientLight.radius=256),i.scene.environment.ambientLight.bias===void 0&&(i.scene.environment.ambientLight.bias=.5),i.scene.environment.ambientLight.aoColor===void 0&&(i.scene.environment.ambientLight.aoColor={r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}),ni(i,G0),ii(i,G0)}function aM(i){i.scene.objects.traverse((t,e)=>{e.events.forEach(r=>{r.type==="GameControl"&&Object.assign(r.gameActions,{run:new Se})})})}function sM(i){i.scene.objects.traverse((t,e)=>{e.events.forEach(r=>{r.type==="GameControl"&&(r.keyAssignments=[...r.keyAssignments,["run","\u21E7"],["none","Ctrl"]])})})}function F0(i){i.layers&&i.layers.forEach(t=>{t.type==="light"&&t.bumpMapIntensity===void 0&&(t.bumpMapIntensity=5)})}function j0(i,t){if(t<1&&(ni(i,D0),ii(i,D0),i.schema=1),t<2&&(CA(i),i.schema=2),t<3&&(MA(i),i.schema=3),t<4&&(IA(i),i.schema=4),t<5&&(EA(i),i.schema=5),t<6&&(NA(i),i.schema=6),t<7&&(DA(i),i.schema=7),t<8&&(i.schema=8),t<9&&(R0(i),i.schema=9),t<10&&(BA(i),i.schema=10),t<11&&(VA(i),i.schema=11),t<12&&(R0(i),i.schema=12),t<13&&(zA(i),i.schema=13),t<14&&(FA(i),i.schema=14),t<15&&(jA(i),i.schema=15),t<16&&(UA(i),i.schema=16),t<17&&(ni(i,L0),ii(i,L0),i.schema=17),t<18&&(ni(i,_0),ii(i,_0),i.schema=18),t<19&&(AA(i),i.schema=19),t<20&&(kA(i),WA(i),i.schema=20),t<21&&(qA(i),$A(i),i.schema=21),t<22&&(z0(i),i.schema=22),t<23&&(XA(i),i.schema=23),t<24&&(YA(i),i.schema=24),(t<25||i.shared.videos===void 0)&&(GA(i),t<25&&(i.schema=25)),t<26&&(_A(i),i.schema=26),t<27&&(RA(i),i.schema=27),t<28&&(z0(i),i.schema=28),t<29&&(LA(i),i.schema=29),t<30&&(KA(i),i.schema=30),t<31&&(QA(i),i.schema=31),t<33&&(ZA(i),i.schema=33),t<34&&(JA(i),i.schema=34),t<35&&(eM(i),i.schema=35),t<36&&(tM(i),i.schema=36),t<37&&(rM(i),i.schema=37),t<38&&(ni(i,B0),ii(i,B0),i.schema=38),t<39&&(oM(i),i.schema=39),t<40&&(iM(i),i.schema=40),t<41&&(nM(i),i.schema=41),t<42&&(aM(i),i.schema=42),t<43&&(sM(i),i.schema=43),t<99){ni(i,F0),ii(i,F0),i.scene.publish.playCamera===null&&(i.scene.publish.playCamera=_i);let e=vt(i.scene.objects),r=i.scene.objects;i.scene.publish.playPage=Ri,r.insertBefore(null,null,[{id:Ri,data:{...ti.defaultData,backgroundColor:i.scene.backgroundColor,fog:i.scene.fog,postprocessing:i.scene.postprocessing,ao:ro(i.scene.environment.ambientLight,"occlusion","aoFullRes","radius","bias","aoColor"),publish:{playCamera:i.scene.publish.playCamera,gameControlObject:i.scene.publish.gameControlObject},shadow:ro(i.scene.environment.ambientLight,"softShadowQuality"),globalPhysics:{...hl.defaultData,...ro(i.scene.environment,"usePhysics","gravity")},camera:vt(i.scene.ownerCamera)??ti.defaultData.camera,name:"Scene"},children:[]}]);for(let a of e)a.id!==oi.TRASH_CAN_ID&&r.move(Ri,a.fi,a.id);let o=0,n=0;i.shared.penumbraSize&&i.scene.objects.traverse((a,s)=>{s.type==="DirectionalLight"?(s.penumbraSize=i.shared.penumbraSize[Math.min(o,2)],o+=1):s.type==="SpotLight"&&(s.penumbraSize=i.shared.penumbraSize[3+Math.min(n,1)],n+=1),(s.physics===void 0||s.physics===null)&&s.type!=="Instance"&&(s.physics={},Object.assign(s.physics,Bi.defaultData)),s.physics!==void 0&&s.physics!==null&&(s.physics.enabled=s.collision??"visibility",delete s.collision)}),i.schema=99}}function U0(i){i.layers&&i.layers.forEach(t=>{t.type==="light"&&t.alphaOverride===void 0&&(t.alphaOverride=1)})}function lM(i){i.scene.objects.traverse((t,e)=>{let r=e.geometry;r&&r.type==="PathGeometry"&&(r.extrusion.capType="flat",r.extrusion.bevel=50,r.extrusion.bevelSides=6,r.extrusion.shape.type==="Custom"&&(r.extrusion.shape.shapeQuality="low"))})}function cM(i){Array.isArray(vt(i.events))&&i.events?.forEach(t=>{"disabled"in t||(t.disabled=!1),(t.type==="MouseDown"||t.type==="MouseUp"||t.type==="MousePress")&&(t.mode=t.mode||"Object")})}var La=180/Math.PI;function k0(i){i.rotation=i.rotation.slice(0,3).map(t=>t*La)}function H0(i){k0(i),i.type==="Page"&&k0(i.camera),i.states?.forEach(e=>{e.rotation===void 0||e.rotation===null||(e.rotation=e.rotation.slice(0,3).map(r=>r*La))});let t=i.geometry;t&&t.type==="SphereGeometry"&&(t.thetaLength=(t.thetaLength??180)*La),t&&t.type==="TorusGeometry"&&(t.arc=t.arc*La),t&&t.type==="PathGeometry"&&(t.extrusion.angle*=La,t.extrusion.twist*=La),i.type==="Mesh"&&i.geometry.type==="TextGeometry"&&(i.geometry.text={textValue:i.geometry.text}),Array.isArray(vt(i.events))&&i.events?.forEach(e=>{(e.type==="MouseDown"||e.type==="MouseUp"||e.type==="MousePress"||e.type==="KeyDown"||e.type==="KeyUp"||e.type==="KeyPress"||e.type==="Collision"||e.type==="Trigger")&&(e.runMode=e.toggle?"Toggle":"Repeat")})}function uM(i){i.shared.variables=Ft({},de.prototype)}function dM(i){let t=vt(i.shared.variables);i.shared.variables=Ft(Object.entries(t??{}).map(([e,r],o)=>({fi:o,id:e,data:r})),Se.prototype)}var No=118;function of(i,t){t(i.data);for(let e of i.children)of(e,t)}function pM(i){let t=i.schema??104;t!==No&&(t<105&&(of(i.asset,H0),i.schema=105),t<118&&(of(i.asset,W0),i.schema=118))}function fM(i){i.shared.particles=Ft({},de.prototype),i.shared.lib&&(i.shared.lib.particles=io.defaultData().particles)}function hM(i){i.scene.objects.traverse((t,e)=>{e.type==="Particle"&&typeof e.renderMaterial.size=="number"&&Object.assign(e.renderMaterial,{size:[e.renderMaterial.size,e.renderMaterial.size]})})}function mM(i){i.scene.objects.traverse((t,e)=>{e.type==="Page"&&(e.postprocessing.depthOfField.focusDistance=100,e.postprocessing.depthOfField.focalLength=20,e.postprocessing.depthOfField.bokehScale=5)})}function yM(i){i.scene.objects.traverse((t,e)=>{Array.isArray(vt(e.events))!==!1&&e.events?.forEach(r=>{let o=r.runMode;r.type==="MouseDown"||r.type==="MouseUp"||r.type==="KeyDown"||r.type==="KeyUp"||r.type==="Collision"||r.type==="Trigger"?r.actions?.forEach(n=>{n.type==="Transition"&&(n.runMode=o??"Repeat"),(n.type==="Animation"||n.type==="SwitchCamera")&&(n.runMode=o==="Toggle"?"Toggle":"Normal")}):r.type==="MouseHover"||r.type==="MousePress"||r.type==="KeyPress"?r.actions?.forEach(n=>{(n.type==="Transition"||n.type==="Animation"||n.type==="SwitchCamera")&&(n.runMode="Toggle")}):r.type==="GameControl"?(delete r.actions,Object.keys(r.gameActions).forEach(a=>{r.gameActions[a]?.forEach(s=>{s.type==="Transition"&&(s.runMode="Repeat"),s.type==="Animation"&&(s.runMode="Normal")})})):r.type==="DragDrop"?(delete r.actions,r.dragDropActions?.drag?.forEach(n=>{(n.type==="Transition"||n.type==="Animation"||n.type==="SwitchCamera")&&(n.runMode="Toggle")}),r.dragDropActions?.drop?.forEach(n=>{(n.type==="Transition"||n.type==="Animation"||n.type==="SwitchCamera")&&(n.runMode="Toggle")})):r.type==="Resize"?(delete r.actions,r.breakpoints?.forEach(n=>{n.actions?.forEach(a=>{(a.type==="Transition"||a.type==="Animation"||a.type==="SwitchCamera")&&(a.runMode="Toggle")})})):r.type==="Start"?r.actions?.forEach(n=>{n.type==="Transition"&&(n.runMode="Once"),(n.type==="Animation"||n.type==="SwitchCamera")&&(n.runMode="Normal")}):r.type==="VariableChange"||r.type==="Scroll"?r.actions?.forEach(n=>{n.type==="Transition"&&(n.runMode="Repeat"),(n.type==="Animation"||n.type==="SwitchCamera")&&(n.runMode="Normal")}):r.type==="Conditional"&&(delete r.actions,r.inActions?.forEach(n=>{n.type==="Transition"&&(n.runMode="Repeat"),(n.type==="Animation"||n.type==="SwitchCamera")&&(n.runMode="Normal")}),r.outActions?.forEach(n=>{n.type==="Transition"&&(n.runMode="Repeat"),(n.type==="Animation"||n.type==="SwitchCamera")&&(n.runMode="Normal")}))})})}function gM(i){i.shared.userAPIs=Ft({},de.prototype),i.shared.userWebhooks=Ft({},de.prototype),i.shared.lib&&(i.shared.lib.userAPIs=io.defaultData().userAPIs,i.shared.lib.userWebhooks=io.defaultData().userWebhooks)}function xM(i){i.scene.publish.settings.videoStatic===void 0&&(i.scene.publish.settings.videoStatic=Ur.defaultData.settings.videoStatic)}function W0(i){i.timelineAnimations=Ft({},de.prototype)}function Iu(i){let t=i.schema??0;if(t!==No){console.warn("updating from ",t,"to ",No),j0(i,t),t<100&&(i.scene.publish.joystickSizeAndXYOffset===void 0&&(i.scene.publish.joystickSizeAndXYOffset=Ur.defaultData.joystickSizeAndXYOffset),i.schema=100),t<101&&(ni(i,U0),ii(i,U0),i.schema=101),t<102&&(lM(i),i.schema=102),t<104&&(i.shared.catelogs=new de,i.shared.lib=io.defaultData(),i.schema=104),t<105&&(uM(i),i.scene.objects.traverse((e,r)=>{H0(r)}),i.schema=105);for(let e of Object.values(i.shared.lib.components))pM(e);t<106&&(dM(i),i.schema=106),t<107&&(i.shared.lib.variables=io.defaultData().variables,i.schema=107),t<109&&(fM(i),i.schema=109),t<110&&(hM(i),i.schema=110),t<111&&(i.scene.objects.traverse((e,r)=>{cM(r)}),i.schema=111),t<112&&(mM(i),i.schema=112),t<113&&(yM(i),i.schema=113),t<114&&(i.scene.publish.settings.web.imageQuality===void 0&&(i.scene.publish.settings.web.imageQuality=70),i.schema=114),t<115&&(gM(i),i.schema=115),t<116&&(xM(i),i.schema=116),t<117&&(i.scene.publish.settings.web.pixelRatioMobile===void 0&&(i.scene.publish.settings.web.pixelRatioMobile=0),i.scene.publish.settings.web.pixelRatioDesktop===void 0&&(i.scene.publish.settings.web.pixelRatioDesktop=0),i.schema=117),t<118&&(i.shared.timelineAnimations=Ft({},de.prototype),i.scene.objects.traverse((e,r)=>{W0(r)}),i.schema=118)}}var _a;(c=>{c.defaultData={schema:No,scene:oi.defaultData,frames:new de().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",Ra.defaultData),shared:{...kr.emptyData(),colors:kr.defaultColors()}},c.emptyDataForImports=function(){let u=oi.emptyDataWithPage();return{schema:No,scene:u,frames:new de().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",Ra.defaultData),shared:{...kr.emptyData(),colors:kr.defaultColors(),images:kr.defaultImages()}}},c.emptyData=function(){return{schema:No,scene:oi.emptyDataWithPage(),frames:new de().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",Ra.defaultData),shared:kr.emptyData()}},c.clipboard2dData=function(){return{schema:No,scene:oi.emptyData(),frames:new de,shared:kr.emptyData()}},c.collabHelper={...ll,updateSchema(u){return(u.schema??0)<No?Ai(u,Iu):(u.schema??0)-No}};function n(u){let p=c.collabHelper.updateSchema(u);return typeof p=="number"?p===0?u:null:p.data}c.updateSchemaDirectly=n;function a(u){return{...u,shared:{...u.shared,lib:io.defaultData()}}}c.withoutLib=a;function s(u,p){let d=u.scene.objects.get(p);if(d&&d.data.type==="Component")return d;{let f=u.shared.lib.components[p];if(f)return f.asset}}c.getComponentData=s;function l(u){let p=Object.values(u.shared.userAPIs);for(let d of p){let f=d.headers;for(let h of f)if(h.data.key.toLowerCase()==="authorization"&&h.data.value!=="")return!0}return!1}c.hasSensitiveData=l})(_a||(_a={}));var Eu;(t=>t.emptyImage={data:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII=",name:"empty"})(Eu||(Eu={}));var q0;(t=>{function i(e){return!0}t.is=i})(q0||(q0={}));var Nu;(r=>{r.defaultData={position:[0,0],scale:[1,1],rotation:0,shear:[0,0]};function t(o,n){return{position:n?.position??o.position,rotation:n?.rotation??o.rotation,scale:n?.scale??o.scale,shear:n?.shear??o.shear}}r.merge=t;function e(o,n){return bc({position:Ta.isEqual(o.position,n.position)?void 0:n.position,rotation:o.rotation===n.rotation?void 0:n.rotation,scale:Ta.isEqual(o.scale,n.scale)?void 0:n.scale,shear:o.shear&&n.shear&&Ta.isEqual(o.shear,n.shear)?void 0:n.shear})}r.diff=e})(Nu||(Nu={}));var nf;(t=>t.defaultData={horizontalConstraint:0,verticalConstraint:0})(nf||(nf={}));var $0;(t=>t.defaultData={direction:"row",wrap:"unwrap",align:"top-left",gap:10,rowGap:10,autoGap:!1,autoRowGap:!1,leftPadding:8,rightPadding:8,topPadding:8,bottomPadding:8})($0||($0={}));var Du;(t=>t.defaultData={opacity:1,fill:{color:Re.fromHexAndA(Dt,1),enabled:!0},stroke:{color:Re.from0to1([0,0,0,1]),thickness:1,enabled:!1,mode:"inside"},layerBlur:{radius:2,enabled:!1},backgroundBlur:{radius:2,enabled:!1},dropShadow:{offset:[10,10],blurRadius:10,color:Re.from0to1([0,0,0,1]),enabled:!1,spread:0},innerShadow:{offset:[10,10],blurRadius:10,color:Re.from0to1([0,0,0,1]),enabled:!1,spread:0}})(Du||(Du={}));var Tn;(n=>{function i(a,s){return{name:s}}n.newEmpty=i;function t(a,s){if(s===void 0)return a;let l={...a},c=["width","height","cornerRadius"];for(let u of c)u in l&&u in s&&s[u]!==void 0&&Object.assign(l,{[u]:s[u]});return l}function e(a,s){if(s===void 0)return a;let l={...a};return"fill"in l&&"fill"in s&&s.fill!==void 0&&Object.assign(l,{fill:{...l.fill,...s.fill}}),"stroke"in l&&"stroke"in s&&s.stroke!==void 0&&Object.assign(l,{stroke:{...l.stroke,...s.stroke}}),"layerBlur"in l&&"layerBlur"in s&&s.layerBlur!==void 0&&Object.assign(l,{layerBlur:{...l.layerBlur,...s.layerBlur}}),"backgroundBlur"in l&&"backgroundBlur"in s&&s.backgroundBlur!==void 0&&Object.assign(l,{backgroundBlur:{...l.backgroundBlur,...s.backgroundBlur}}),"dropShadow"in l&&"dropShadow"in s&&s.dropShadow!==void 0&&Object.assign(l,{dropShadow:{...l.dropShadow,...s.dropShadow}}),"innerShadow"in l&&"innerShadow"in s&&s.innerShadow!==void 0&&Object.assign(l,{innerShadow:{...l.innerShadow,...s.innerShadow}}),l}function r(a,s){if(s===void 0)return a;let l={...a};return Object.assign(l,Nu.merge(l,s)),l=t(l,s),l=e(l,s),l}n.patch=r;function o(a,s){let l,c=[];for(let[u,p]of Object.entries(s))u!=="name"&&(l===void 0&&(l={path:[],props:{},type:0},c.push(l)),l.props[u]=p);return c}n.toOps=o})(Tn||(Tn={}));var yl;(t=>t.defaultData={...Nu.defaultData,...nf.defaultData,states:new Se,events:new Se,visible:!0,raycastLock:!1})(yl||(yl={}));var Ba;(t=>t.defaultData={...yl.defaultData,...Du.defaultData})(Ba||(Ba={}));var _u;(t=>t.defaultData={cornerRadius:[0,0,0,0]})(_u||(_u={}));var af;(t=>t.defaultData={...Ba.defaultData,type:"ellipse2d",width:100,height:100,name:"Ellipse"})(af||(af={}));var Va;(t=>t.defaultData={...Ba.defaultData,..._u.defaultData,type:"rectangle2d",width:100,height:100,name:"Rectangle"})(Va||(Va={}));var sf;(t=>t.defaultData={...Ba.defaultData,type:"text2d",width:100,height:100,fontSize:12,lineHeight:1.2,letterSpacing:0,text:{textValue:"Hello world"},horizontalAlign:1,verticalAlign:1,textTransform:1,font:"Roboto_regular",name:"Text"})(sf||(sf={}));var lf;(t=>t.defaultData={...Ba.defaultData,type:"path2d",path:"",name:"Path"})(lf||(lf={}));var X0;(t=>{function i(e){return e.type==="ellipse2d"||e.type==="rectangle2d"||e.type==="text2d"||e.type==="vector2d"||e.type==="path2d"}t.is=i})(X0||(X0={}));var gl;(t=>t.defaultData={...yl.defaultData,name:"Group",type:"group2d"})(gl||(gl={}));var cf;(t=>t.defaultData=()=>({...yl.defaultData,..._u.defaultData,...Du.defaultData,name:"Frame",type:"frame2d",clipped:!0,width:200,height:200,fill:{color:Re.fromHexAndA(4737101,1),enabled:!0},stroke:{color:Re.fromHexAndA(0,1),thickness:1,enabled:!1,mode:"inside"},backgroundBlur:{radius:2,enabled:!1},layerBlur:{radius:2,enabled:!1}}))(cf||(cf={}));var ai;(n=>{function i(a){switch(a){case"rectangle2d":return{...Va.defaultData};case"ellipse2d":return{...af.defaultData};case"text2d":return{...sf.defaultData};case"vector2d":return{...Va.defaultData};case"path2d":return{...lf.defaultData};case"frame2d":return{...cf.defaultData()};case"group2d":return{...gl.defaultData}}}n.defaultData=i;function t(a){return"width"in a&&"height"in a?[typeof a.width=="number"?a.width*.5:0,typeof a.height=="number"?a.height*.5:0]:[0,0]}n.getPivot=t;function e(a){return a.type==="rectangle2d"||a.type==="ellipse2d"||a.type==="text2d"||a.type==="frame2d"}n.isResizeable=e;function r(a){return a.type==="frame2d"&&a.autoLayout!==void 0}n.isAutoLayoutable=r;function o(a){return a.type==="rectangle2d"||a.type==="frame2d"}n.hasCorners=o})(ai||(ai={}));var Ru;(e=>(e.defaultData={name:"UI",type:"scene2d",objects:new ct},e.emptyData=function(){return{type:"scene2d",objects:new ct}}))(Ru||(Ru={}));var Y0=require("three"),kt=class extends Y0.Color{constructor(e,r,o,n){super(e,r,o);this.isColorA=!0;this.a=n}setRGBA(e,r,o,n){super.setRGB(e,r,o),this.a=n}copy(e){return super.copy(e),this.a="a"in e?e.a:1,this}clone(){return new this.constructor(this.r,this.g,this.b,this.a)}equals(e){return super.equals(e)&&this.a===e.a}setStyle(e,r="srgb"){let o;if(e==="transparent")return this.setRGBA(0,0,0,0),this;if(o=/^((?:rgb|hsl)a?)\(([^)]*)\)/.exec(e)){let n,a=o[1],s=o[2];switch(a){case"rgb":case"rgba":if(n=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))return this.a=a==="rgba"?parseFloat(n[4]):1,super.setStyle(e,r);break;case"hsl":case"hsla":if(n=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)%\s*,\s*(\d*\.?\d+)%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))return this.a=a==="hsla"?parseFloat(n[4]):1,super.setStyle(e,r);break}}return super.setStyle(e,r)}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}};var tt=require("three"),Id=tl(Q0());var bM=.5*(Math.sqrt(3)-1),xl=(3-Math.sqrt(3))/6,vM=1/3,Do=1/6,o4=(Math.sqrt(5)-1)/4,i4=(5-Math.sqrt(5))/20,bl=i=>Math.floor(i)|0,Z0=new Float64Array([1,1,-1,1,1,-1,-1,-1,1,0,-1,0,1,0,-1,0,0,1,0,-1,0,1,0,-1]),df=new Float64Array([1,1,0,-1,1,0,1,-1,0,-1,-1,0,1,0,1,-1,0,1,1,0,-1,-1,0,-1,0,1,1,0,-1,1,0,1,-1,0,-1,-1]);function J0(i=Math.random){let t=tx(i),e=new Float64Array(t).map(o=>Z0[o%12*2]),r=new Float64Array(t).map(o=>Z0[o%12*2+1]);return function(n,a){let s=0,l=0,c=0,u=(n+a)*bM,p=bl(n+u),d=bl(a+u),f=(p+d)*xl,h=p-f,m=d-f,y=n-h,b=a-m,v,w;y>b?(v=1,w=0):(v=0,w=1);let O=y-v+xl,S=b-w+xl,T=y-1+2*xl,M=b-1+2*xl,g=p&255,D=d&255,E=.5-y*y-b*b;if(E>=0){let _=g+t[D],R=e[_],V=r[_];E*=E,s=E*E*(R*y+V*b)}let I=.5-O*O-S*S;if(I>=0){let _=g+v+t[D+w],R=e[_],V=r[_];I*=I,l=I*I*(R*O+V*S)}let N=.5-T*T-M*M;if(N>=0){let _=g+1+t[D+1],R=e[_],V=r[_];N*=N,c=N*N*(R*T+V*M)}return 70*(s+l+c)}}function ex(i=Math.random){let t=tx(i),e=new Float64Array(t).map(n=>df[n%12*3]),r=new Float64Array(t).map(n=>df[n%12*3+1]),o=new Float64Array(t).map(n=>df[n%12*3+2]);return function(a,s,l){let c,u,p,d,f=(a+s+l)*vM,h=bl(a+f),m=bl(s+f),y=bl(l+f),b=(h+m+y)*Do,v=h-b,w=m-b,O=y-b,S=a-v,T=s-w,M=l-O,g,D,E,I,N,_;S>=T?T>=M?(g=1,D=0,E=0,I=1,N=1,_=0):S>=M?(g=1,D=0,E=0,I=1,N=0,_=1):(g=0,D=0,E=1,I=1,N=0,_=1):T<M?(g=0,D=0,E=1,I=0,N=1,_=1):S<M?(g=0,D=1,E=0,I=0,N=1,_=1):(g=0,D=1,E=0,I=1,N=1,_=0);let R=S-g+Do,V=T-D+Do,U=M-E+Do,B=S-I+2*Do,q=T-N+2*Do,j=M-_+2*Do,F=S-1+3*Do,H=T-1+3*Do,W=M-1+3*Do,ee=h&255,te=m&255,Y=y&255,re=.6-S*S-T*T-M*M;if(re<0)c=0;else{let $=ee+t[te+t[Y]];re*=re,c=re*re*(e[$]*S+r[$]*T+o[$]*M)}let K=.6-R*R-V*V-U*U;if(K<0)u=0;else{let $=ee+g+t[te+D+t[Y+E]];K*=K,u=K*K*(e[$]*R+r[$]*V+o[$]*U)}let Z=.6-B*B-q*q-j*j;if(Z<0)p=0;else{let $=ee+I+t[te+N+t[Y+_]];Z*=Z,p=Z*Z*(e[$]*B+r[$]*q+o[$]*j)}let Q=.6-F*F-H*H-W*W;if(Q<0)d=0;else{let $=ee+1+t[te+1+t[Y+1]];Q*=Q,d=Q*Q*(e[$]*F+r[$]*H+o[$]*W)}return 32*(c+u+p+d)}}function tx(i){let e=new Uint8Array(512);for(let r=0;r<512/2;r++)e[r]=r;for(let r=0;r<512/2-1;r++){let o=r+~~(i()*(256-r)),n=e[r];e[r]=e[o],e[o]=n}for(let r=256;r<512;r++)e[r]=e[r-256];return e}var rx=require("three"),no=new rx.Triangle,Lu=class{constructor(t){this.weightAttribute=null;let e=t.geometry;if(!e.isBufferGeometry||e.attributes.position.itemSize!==3)throw new Error("THREE.MeshSurfaceSampler: Requires BufferGeometry triangle mesh.");e.index&&(e=e.toNonIndexed()),this.geometry=e,this.randomFunction=Math.random,this.positionAttribute=this.geometry.getAttribute("position"),this.distribution=null}build(){let t=this.positionAttribute,e=new Float32Array(t.count/3);for(let o=0;o<t.count;o+=3){let n=1;no.a.fromBufferAttribute(t,o),no.b.fromBufferAttribute(t,o+1),no.c.fromBufferAttribute(t,o+2),n*=no.getArea(),e[o/3]=n}this.distribution=new Float32Array(t.count/3);let r=0;for(let o=0;o<e.length;o++)r+=e[o],this.distribution[o]=r;return this}setRandomGenerator(t){return this.randomFunction=t,this}sample(t,e){if(this.distribution){let r=this.distribution[this.distribution.length-1],o=this.binarySearch(this.randomFunction()*r);return this.sampleFace(o,t,e)}}binarySearch(t){if(!this.distribution)return 0;let e=this.distribution,r=0,o=e.length-1,n=-1;for(;r<=o;){let a=Math.ceil((r+o)/2);if(a===0||e[a-1]<=t&&e[a]>t){n=a;break}else t<e[a]?o=a-1:r=a+1}return n}sampleFace(t,e,r){let o=this.randomFunction(),n=this.randomFunction();return o+n>1&&(o=1-o,n=1-n),no.a.fromBufferAttribute(this.positionAttribute,t*3),no.b.fromBufferAttribute(this.positionAttribute,t*3+1),no.c.fromBufferAttribute(this.positionAttribute,t*3+2),e.set(0,0,0).addScaledVector(no.a,o).addScaledVector(no.b,n).addScaledVector(no.c,1-(o+n)),no.getNormal(r),this}};var ax=require("three");var _r=require("three"),nx=tl(ix()),SM=new _r.Matrix4,wM=new _r.Matrix4,PM=new _r.Matrix4,si;(t=>{function i(e){return e&&e.__isSPEObject}t.is=i})(si||(si={}));var za=i=>class extends i{constructor(){super(...arguments);this.previousModelViewMatrix=new _r.Matrix4;this.copyPreviousMatrix=!0;this.hiddenMatrix=new _r.Matrix4;this.matrixWorldRigid=new _r.Matrix4;this.shearScale=new _r.Matrix4;this.shearScaleInv=new _r.Matrix4}get __isSPEObject(){return!0}isDescendantOf(r){r instanceof _r.Object3D&&(r=r.uuid);let o=this;for(;o.parent;){if(o.parent.uuid===r)return!0;o=o.parent}return!1}updateMatrixWorld(r){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||r)&&(this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,r=!0);for(let o of this.children)o.updateMatrixWorld(r)}updateWorldMatrix(r,o){let n=this.parent;if(r&&n!==null&&n.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)),o)for(let a of this.children)a.updateWorldMatrix(!1,!0)}traverseChildren(r,o=0){for(let n of this.children)si.is(n)&&n.traverseObject(r,o+1)}traverseObject(r,o=0){if(r(this,o)!==!0)for(let a of this.children)si.is(a)&&a.traverseObject(r,o+1)}updateMatrixWorldSVD(){let r=this.matrixWorld.elements,o=[[r[0],r[4],r[8]],[r[1],r[5],r[9]],[r[2],r[6],r[10]]],{u:n,v:a,q:s}=(0,nx.SVD)(o),l=SM.set(n[0][0],n[0][1],n[0][2],0,n[1][0],n[1][1],n[1][2],0,n[2][0],n[2][1],n[2][2],0,0,0,0,1),c=wM.set(a[0][0],a[0][1],a[0][2],0,a[1][0],a[1][1],a[1][2],0,a[2][0],a[2][1],a[2][2],0,0,0,0,1),u=PM.copy(c).transpose();this.shearScale.makeScale(s[0],s[1],s[2]).multiply(u).premultiply(c),this.shearScaleInv.copy(this.shearScale).invert(),this.matrixWorldRigid.multiplyMatrices(l,u).copyPosition(this.matrixWorld),s.every(p=>Math.abs(s[0]-p)<.01)?this.hasNonUniformScale=!1:this.hasNonUniformScale=!0}attach(r,o){this.updateWorldMatrix(!0,!1);let n=new _r.Matrix4().copy(this.matrixWorld).invert();return r.parent!==null&&(r.parent.updateWorldMatrix(!0,!1),n.multiply(r.parent.matrixWorld)),"hiddenMatrix"in r&&r.hiddenMatrix instanceof _r.Matrix4?r.hiddenMatrix.premultiply(n):r.applyMatrix4(n),r.updateWorldMatrix(!1,!1),this.add(r),o!==void 0&&(this.children.pop(),this.children.splice(o,0,r)),this}copy(r,o=!1){return super.copy(r,o),this.hasNonUniformScale=r.hasNonUniformScale,this}onAfterRender(r,o,n,a,s,l){this.copyPreviousMatrix&&this.previousModelViewMatrix.copy(this.modelViewMatrix)}};var pf=class extends za(ax.Object3D){},OM=i=>i.type==="Mesh",ao=class extends pf{constructor(e){super();this.object=e;this.matrixAutoUpdate=!1,this.hasNonUniformScale=e.hasNonUniformScale}raycast(e,r){}expand(){let e=0,r=this.object.entityChildren(e);for(;r;){let o=this.children[e];o?.object!==r&&(o&&this.remove(o),o=new ao(r),this.add(o),this.children.splice(e,0,this.children.pop()),o.matrixWorldNeedsUpdate=!0,o.matrixAutoUpdate=!1,o.matrix=r.matrix,o.hiddenMatrix=r.hiddenMatrix),o.expand(),e+=1,r=this.object.entityChildren(e)}for(;this.children.length>e;)this.remove(this.children[e])}get visible(){return this.playModeVisible!==void 0?this.playModeVisible:this.object.visible||this.object.dataPatched.visible&&this.object.dataPatched.cloner?.hideBase===!0}set visible(e){}get castShadow(){return this.object.castShadow}set castShadow(e){}get receiveShadow(){return this.object.receiveShadow}set receiveShadow(e){}get isMesh(){return OM(this.object)}get isLight(){return this.object.isLight}get layers(){return this.object.layers}set layers(e){}get isCamera(){return!1}get geometry(){if(this.object.geometry)return this.object.geometry}get material(){if(this.object.material)return this.object.material}get morphTargetInfluences(){if(this.object.morphTargetInfluences)return this.object.morphTargetInfluences}set morphTargetInfluences(e){}};var is=require("three");var rd=require("three");var ur=require("three");var Mt=require("three"),Cn=new Mt.Vector3,An=new Mt.Vector3,Ga=new Mt.Matrix4,lx=[new Mt.Vector3(-1,1,1),new Mt.Vector3(-1,-1,1),new Mt.Vector3(1,-1,1),new Mt.Vector3(1,1,1),new Mt.Vector3(-1,1,-1),new Mt.Vector3(-1,-1,-1),new Mt.Vector3(1,-1,-1),new Mt.Vector3(1,1,-1)],TM=[[0,3],[1,2],[5,6],[4,7],[0,1],[3,2],[7,6],[4,5],[0,4],[1,5],[2,6],[3,7]],CM=[[0,2],[7,5],[4,1],[3,6],[4,3],[1,6]],sx=(i,t,e)=>{i.updateEntityBoxSize(Cn,An),Ga.copy(t).multiply(i.matrixWorld),An.x===0&&An.y===0&&An.z===0?e.push(new Mt.Vector3(Cn.x,Cn.y,Cn.z).applyMatrix4(Ga)):lx.forEach(r=>{e.push(r.clone().multiply(An).add(Cn).applyMatrix4(Ga))})},vl=class extends Mt.Box3{constructor(){super(...arguments);this.matrix=new Mt.Matrix4;this.vertices=[];this.faces=[];this.edges=[];this.centerEdges=[]}copy(e){return super.copy(e),this.matrix.copy(e.matrix),this.vertices=e.vertices.map(r=>r.clone()),this.faces=e.faces.map(r=>r.clone()),this.edges=e.edges.map(r=>r.clone()),this.centerEdges=e.centerEdges.map(r=>r.clone()),this}setFromObjectSize(e,r=!1){e.updateWorldMatrix(!1,r),this.makeEmpty(),this.matrix.copy(e.matrixWorld);let o=new Mt.Matrix4().copy(e.matrixWorld).invert();return this.expandByObjectSize(e,o,r)}expandByObjectSize(e,r,o=!1){let n=[];return o===!0?e.traverseEntity(a=>{if(a.visible||a.cloner&&a.data.visible){if(!("geometry"in a)){n.push(new Mt.Vector3);return}sx(a,r,n)}}):sx(e,r,n),this.setFromPoints(n)}getCenter(e){return e=super.getCenter(e),e.applyMatrix4(this.matrix),e}getPositionToCenter(e){return e=super.getCenter(e),e.applyMatrix4(Ga.copy(this.matrix).setPosition(0,0,0)),e}computeVertices(){this.getSize(An).multiplyScalar(.5),this.getCenter(Cn),Ga.copy(this.matrix).setPosition(Cn),this.vertices=lx.map(e=>e.clone().multiply(An).applyMatrix4(Ga))}computeEdges(){this.vertices.length>0&&this.computeVertices(),this.edges=TM.map(([e,r])=>new Mt.Line3(this.vertices[e],this.vertices[r])),this.centerEdges=this.edges.map(e=>e.getCenter(new Mt.Vector3))}computeFaces(){this.vertices.length>0&&this.computeVertices(),this.faces=CM.map(([e,r])=>this.vertices[e].clone().add(this.vertices[r]).multiplyScalar(.5))}};var so={Cloner:()=>{},changeEntityProptotype:()=>{},createEntity:()=>{}};var Qt=require("three"),hf=class extends Qt.CurvePath{constructor(){super()}getPoints(t=12){let e=[],r,o=this.getCurveLengths(),a=o[o.length-1]/o.length;for(let s=0,l=this.curves;s<l.length;s++){let c=l[s],u=s===0?o[s]:o[s]-o[s-1],p=Math.ceil(t*u/a),d=c.getPoints(p);for(let f=0;f<d.length;f++){let h=d[f];r&&r.equals(h)||(e.push(h),r=h)}}return this.autoClose&&e.length>1&&!e[e.length-1].equals(e[0])&&e.push(e[0]),e}};var mf=.001;function yf(i,t,e){return t.clone().sub(i).cross(t.clone().sub(e)).length()<=mf}function ff(i,t){let e=new Qt.Vector3(...i.position),r=new Qt.Vector3(...i.controlNext.position),o=new Qt.Vector3(...t.controlPrevious.position),n=new Qt.Vector3(...t.position);return yf(e,r,n)&&yf(e,o,n)}function Vu(i){let t=i.points.map(u=>new Qt.Vector3(...u.data.position)),e=[i.points[0]],r=new Qt.Vector3(...e[0].data.position);for(let u=0;u<i.points.length-1;u++)yf(r,t[u],t[u+1])||(e.push(i.points[u]),r=t[u]);e.push(i.points[i.points.length-1]);let o=i.isClosed,n=e.length-(o?0:1),a=e.length,s=[];for(let u=0;u<a;u++){let p=e[u].data,d=new Qt.Vector3(...p.position),f=new Qt.Vector3(...p.controlPrevious.position),h=new Qt.Vector3(...p.controlNext.position),m={position:d,baseRoundness:p.roundness,controlPrevious:f,controlNext:h};if(p.roundness===0||!i.isClosed&&(u===0||u===a-1)){s[u]={...m,removedLength:0};continue}let y=o&&u==0?a-1:u-1,b=o&&u==a-1?0:u+1,v=e[y].data,w=e[b].data,O=new Qt.Vector3(...v.position),S=new Qt.Vector3(...w.position),T=O.clone().sub(d).normalize(),M=S.clone().sub(d).normalize();Object.assign(m,{prevDir:T,nextDir:M});let g=ff(v,p),D=ff(p,w);if(!g||!D)s[u]={...m,removedLength:0};else{let E=T.clone().add(M).normalize(),I=E.clone().cross(T).length()/T.dot(E);s[u]={...m,tan:I,removedLength:p.roundness/I}}}for(let u=0;u<n;u++){let p=u,d=o&&u===a-1?0:u+1,f=s[p],h=s[d];if(f.removedLength!==0||h.removedLength!==0){let m=f.position.distanceTo(h.position);f.removedLength=Math.min(f.removedLength,m/2),h.removedLength=Math.min(h.removedLength,m/2)}}let l=[];for(let u=0;u<n;u++){let p=u,d=o&&u===a-1?0:u+1,f=s[p],h=s[d],m=null;if(!ff(e[p].data,e[d].data))f.position.distanceTo(h.position)>mf&&(m=new Qt.CubicBezierCurve3(f.position,f.controlNext,h.controlPrevious,h.position));else{let y=f.position.clone(),b=h.position.clone();(f.removedLength!==0||h.removedLength!==0)&&(f.nextDir&&y.add(f.nextDir.clone().setLength(f.removedLength)),h.prevDir&&b.add(h.prevDir.clone().setLength(h.removedLength))),y.distanceTo(b)>mf&&(m=new Qt.CubicBezierCurve3(y,y.clone().lerp(b,.3),b.clone().lerp(y,.3),b))}l[2*u+1]=m}for(let u=0;u<a;u++){let p=s[u];if(p.removedLength===0){l[2*u]=null;continue}let d=p.position,f=p.prevDir.clone().multiplyScalar(p.removedLength).add(d),h=p.nextDir.clone().multiplyScalar(p.removedLength).add(d),m=p.tan*p.removedLength,y=p.prevDir.clone().add(p.nextDir).normalize(),b=f.clone().lerp(h,.5),v=f.distanceTo(h)/2,w=y.clone().multiplyScalar(Math.sqrt(Math.pow(m,2)-Math.pow(v,2))).add(b),O=y.clone().multiplyScalar(-m).add(w),S=d.distanceTo(O)/d.distanceTo(b),T=p.prevDir.clone().multiplyScalar(S*d.distanceTo(f)).add(d),M=T.clone().lerp(O,2),g=f.clone().lerp(T,4/3),D=h.clone().lerp(M,4/3);l[2*u]=new Qt.CubicBezierCurve3(f,g,D,h)}let c=new hf;return l.forEach(u=>{u&&c.add(u)}),c}var ze;(t=>{function i(e){return e&&e.__isEntity}t.is=i})(ze||(ze={}));var Fa=i=>ze.is(i),AM={type:"completeState",isfromEntity:!0},MM=["x","y","z"],gf=new ur.Vector3,IM=new ur.Vector3().set(0,1,0),ja=i=>class extends za(i){constructor(){super(...arguments);this.raycastLock=!1;this.scaleLock=!1;this.disposed=!1;this.stateSelection=null;this.destroyedInAction=!1;this.instances=[];this.prevState=null;this.currentState=null;this.currentAnimationAction=null;this.reversibleToState=null;this.currentTransitionEvent=null;this.previousAction=null;this._singleBBox=new vl;this._recursiveBBox=new vl;this.singleBBoxNeedsUpdate=!0;this.recursiveBBoxNeedsUpdate=!0;this._needApplyPathSnapping=!0;this.attachedPaths=new Set}get __isEntity(){return!0}entityChildren(r){let o=this.children[r];if(ze.is(o))return o}entityChildrenCount(){let r=this.children.length;for(;r--;)if(ze.is(this.children[r]))return r+1;return 0}get isConcreteEntity(){return typeof this.identity=="string"}get isVirtualEntity(){return typeof this.identity!="string"}get isInstanceRoot(){return this.isConcreteEntity&&this.data.type==="Instance"}nearestInstanceSelfOrParent(){let r=this;for(;r.data.type!=="Instance";){let o=r.parent;if(ze.is(o))r=o;else return}return r}forInstancesRec(r){this.instances.forEach(o=>{o.disposed||r(o),o.forInstancesRec(r)})}super_Entity(r,o){typeof r=="string"&&(this.uuid=r),this.identity=r,this.data=o,this.matrixAutoUpdate=!1,this.dataPatched=this.data}changeSelectedState(r,o,n=!1){if(!(this.data.states.length===0&&!n)){for(let a of this.data.states)On.toOps(this.data,a.data).forEach(l=>{let c=Sa.replaceProps(l,this.data);this.dataPatched=this.data,this.updateByPatchedOp(c,this.data,o)});if(r!==null){let a=this.data.states.data(r);a&&(this.dataPatched=On.patch(this.data,a),On.toOps(this.data,a).forEach(l=>{this.updateByPatchedOp(l,this.dataPatched,o)}))}n&&this.updateTransformState(this.dataPatched,o),this.stateSelection=r,this.updatePathSnapping(this.dataPatched.pathSnapping)}}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}updateEntityBoxSize(r,o){r.setScalar(0),o.setScalar(0)}resetBBoxNeedsUpdateSelf(){this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0}resetBBoxNeedsUpdate(){this.resetBBoxNeedsUpdateSelf(),this.traverseAncestors(r=>{Fa(r)&&r.resetBBoxNeedsUpdateSelf()}),this.traverseEntity(r=>{r.resetBBoxNeedsUpdateSelf()})}find(r){let o;return this.traverseEntity(n=>{n.uuid===r&&(o=n)}),o}traverseSortNextHelper(){let r=this.parent;if(r){let o=r.children,n=o.indexOf(this)+1;if(ze.is(o[n]))return o[n];if(ze.is(r))return r.traverseSortNextHelper()}}sortNext(){let r=this.children;return this.children.length>0&&ze.is(this.children[0])?r[0]:this.traverseSortNextHelper()}goUp(r){let o=this;for(;r>0&&o!==null;)o=o.parent,r-=1;return o}hasAnccestorOrSelf(r){return this===r||this.hasAnccestor(r)}hasAnccestor(r){let o=this.parent;for(;o;){if(r===o)return!0;o=o.parent}return!1}countToAccestor(r){let o=0,n=this;for(;n!==r;){if(n===null)return-1;n=n.parent,o+=1}return o}forEachEntity(r){for(let o of this.children)Fa(o)&&r(o)}traverseEntityAncestors(r){this.traverseAncestors(o=>{ze.is(o)&&r(o)})}traverseConcreteEntity(r,o=0){if(r(this,o)!==!0)for(let a of this.children)Fa(a)&&a.isConcreteEntity&&a.traverseEntity(r,o+1)}traverseEntity(r,o=0){if(r(this,o)!==!0)for(let a of this.children)Fa(a)&&a.traverseEntity(r,o+1)}traverseVisibleEntity(r){r(this);for(let o of this.children)Fa(o)&&o.visible&&o.traverseVisibleEntity(r)}updateMatrix(){super.updateMatrix(),this.cloner&&this.cloner.onObjUpdateMatrix(),this.dispatchEvent({type:"updateMatrix"})}updateMatrixWorld(r){super.updateMatrixWorld(r),this.dispatchEvent({type:"updateMatrixWorld"})}copy(r,o=!1){return super.copy(r,o),this.dataPatched=r.dataPatched,this.raycastLock=r.raycastLock,this.scaleLock=r.scaleLock,this.hiddenMatrix.copy(r.hiddenMatrix),this}hasEntityChild(){return this.children.some(r=>Fa(r))}isAncestorOf(r){if(this.uuid===r)return!1;let o=!1;return this.traverseEntity(n=>{n.uuid===r&&(o=!0)}),o}toObjectTransformState(r=[]){this.updateWorldMatrix(!0,!1);let o={position:this.position.toArray(),rotation:[this.rotation.x*ur.MathUtils.RAD2DEG,this.rotation.y*ur.MathUtils.RAD2DEG,this.rotation.z*ur.MathUtils.RAD2DEG],scale:this.scale.toArray(),hiddenMatrix:this.hiddenMatrix.toArray()};return ya(o,r)}getTransformValues(r,o,n){return o[r].map((a,s)=>n?.shared.getVariable(a,[this.uuid,r,MM[s]])??a)}updateTransformState(r,o){let n=!1;return r.position&&(this.position.fromArray(this.getTransformValues("position",r,o)),n=!0),r.rotation&&(gf.fromArray(this.getTransformValues("rotation",r,o)).multiplyScalar(ur.MathUtils.DEG2RAD),this.rotation.setFromVector3(gf),n=!0),r.scale&&(this.scale.fromArray(this.getTransformValues("scale",r,o)),n=!0),r.hiddenMatrix!==void 0&&(n=!0,this.hiddenMatrix.fromArray(r.hiddenMatrix??Di.identity)),n&&(this.updateMatrix(),this.resetBBoxNeedsUpdate(),this.invalidateClonerTransform(this),this.traverseEntityAncestors(a=>{a.invalidateClonerTransform(this)})),r.position&&r.rotation&&r.scale&&r.hiddenMatrix!==void 0&&this.updateWorldMatrix(!1,!0),n}onVariableUpdate(r=!1){if(r){this.resetBBoxNeedsUpdate();return}this.updateMatrix(),this.resetBBoxNeedsUpdate(),this.invalidateClonerTransform(this),this.traverseEntityAncestors(o=>{o.invalidateClonerTransform(this)})}dispose(){this.disposed=!0,this.cloner&&(this.cloner.removeFromParent(),this.cloner=void 0)}disposeChildrenRecursively(){for(let r of this.children)ze.is(r)&&r.disposeRecursively()}disposeRecursively(){this.dispose(),this.children.forEach(r=>{ze.is(r)&&r.disposeRecursively()})}toState(r=[]){let o={name:this.name,visible:this.visible,raycastLock:this.raycastLock,...this.toObjectTransformState(r)};return ya(o,r)}updateByObjUpdateOp(r,o){r!==void 0&&this.updateByOp({type:0,props:r,path:[]},{...this.data,...r},o,!1)}updateByOp(r,o,n,a){let s=this.data;this.data=o;let l=r,c=je(r.path,["states","*"]);if(c!==null){if(r.type===0){let[u]=c;if(this?.stateSelection===u){let p={...r.props};if(delete p.name,Object.values(r.props).some(d=>d===void 0)){let d=this.data;if(d!==void 0){let f=ut.zoom(d,r.path.slice(2));if(f)for(let h in r.props)r.props[h]===void 0&&h in f&&(p[h]=f[h])}}l={...r,props:p,path:r.path.slice(2)}}}}else if(r.type===0){let u=this.stateSelection?this.data.states.data(this.stateSelection):void 0;if(u!==void 0){if(r.props.name!==void 0&&u.name){let{name:d,...f}=u;u=f}if(r.props.material!==void 0&&"material"in u){let{material:d,...f}=u;u=f}let p=ut.removeOverridden(r.path,r.props,u);l={...r,props:p}}}if(this.updateByPatchedOpBase(l,On.patch(this.data,this.stateSelection?this.data.states.data(this.stateSelection):void 0),n),je(r.path,["overrides"])){let u=[],p=[...r.path];for(u.push(p[1]),p.splice(0,2);p.length>0&&p[0]==="descendants";)u.push(p[1]),p.splice(0,2);if(u[u.length-1]===void 0){if(r.type===0)for(let d of Object.keys(r.props)){u[u.length-1]=d;let f=n.scene.findInstance([this.uuid,...u]);f&&(f.overrideData=r.props[d],f.updateState(Po.apply(f.component.data,f.overrideData),n))}}else{let d=n.scene.findInstance([this.uuid,...u]);if(d){let f=ut.zoom(d.component.data,p);if(r={...r,path:p},r.type===0){let h=r.props;if(f)for(let[m,y]of Object.entries(r.props))y===void 0&&(h===r.props&&(h={...r.props}),h[m]=f[m]);r={...r,props:h}}d.overrideData=Na.resolve(o.overrides,u),d.updateByOp(r,bt.applySimple(d.data,r),n,!1)}}}else if(this.instances.length>0){let u;if(r.path.length===0&&r.type===0){let p;for(let d of Eo.rootOverrideProps)d in r.props&&(p===void 0&&(p={}),p[d]=r.props[d]);p&&(u={...r,props:p})}else for(let p of Eo.rootOverrideProps)if(je(r.path,[p])){u=r;break}u!==void 0&&this.instances.forEach(p=>{if(p.isInstanceRoot){let d=Po.filterOp(p.overrideData,u);d&&p.updateByOp(d,bt.applySimple(p.data,d),n,!0)}}),this.instances.forEach(p=>{if(!p.isInstanceRoot){let d=Po.filterOp(p.overrideData,r);if(d){let f;s===p.data&&r===d?f=o:f=bt.applySimple(p.data,d),p.updateByOp(d,f,n,!0)}}})}}updateByPatchedOpBase(r,o,n){if(this.dataPatched=o,r.path.length===0&&r.type===0)r.props.type!==void 0&&!oo.is(r.props.type)&&so.changeEntityProptotype(this,o,n);else if(r.path.length===1&&r.path[0]==="geometry"&&r.type===0&&"type"in r.props){so.changeEntityProptotype(this,o,n);for(let a of this.children)ze.is(a)&&a.updateVisible(n.scene)}this.updateByPatchedOp(r,o,n)}updateByPatchedOp(r,o,n){if(r.path.length===0&&r.type===0?this.updateState(r.props,n):r.type===0&&("resolutionLevel"in r.props||"useChildrenColors"in r.props)&&this.updateState(o,n),r.path[0]==="morphTargetInfluences"&&r.type===0){let s=o.morphTargetInfluences.get(r.path[1])?.data.name;s&&this.updateMorphInfluences(s,n.shared.getVariable(r.props.value,[this.uuid,"morphTargetInfluences",s]))}if(je(r.path,["pathSnapping"])!==null&&this.updatePathSnapping(o.pathSnapping),je(r.path,["cloner"])!==null){let a=bt.drop(r,1);a.path.length===0&&a.type===0&&a.props.disabled===!0?this.setFromClonerState(null,n):this.cloner?this.cloner.updateState(o.cloner,n.scene):(this.setFromClonerState(o.cloner,n),this.expandCloner(n.scene)),this.updateVisible(n.scene)}}updatePathSnapping(r=this.dataPatched.pathSnapping){this._updatedPathSnapping=r,this._needApplyPathSnapping=!0}get updatedPathSnapping(){return this._updatedPathSnapping}applyPathSnapping(r){let o=this._updatedPathSnapping?.pathId??this.dataPatched.pathSnapping.pathId,n=this._updatedPathSnapping?.slide??this.dataPatched.pathSnapping.slide??0,a=this._updatedPathSnapping?.offset??this.dataPatched.pathSnapping.offset??0,s=this._updatedPathSnapping?.orientation??this.dataPatched.pathSnapping.orientation;if(o===null)return;let l=r.find(o);if(!l||this._needApplyPathSnapping===!1)return;this._needApplyPathSnapping=!1;let c=l.data;if(c.geometry.path.points.length<=1)return;let u=Vu(c.geometry.path),p=(n+a)%1;n+a===1&&p===0&&(p=1);let d=null;try{d=u.curves.length?u.getPointAt(p):null}catch(y){!1&&(console.warn(`The aligned path on ${this.name} is invalid. (${l.name})`),console.error(y))}if(d===null)return;let f=this.parent?this.parent?.matrixWorld:new ur.Matrix4;l.updateMatrixWorld();let h=new ur.Matrix4().multiplyMatrices(f.clone().invert(),l.matrixWorld);d.applyMatrix4(h);let m={position:d.toArray(),rotation:c.rotation};if(s==="tangential"){let y=new ur.Matrix4().extractRotation(l.matrixWorld),b=u.getTangentAt(p).applyMatrix4(y).add(d),v=new ur.Matrix4().lookAt(d,b,IM),w=gf.setFromEuler(new ur.Euler().setFromRotationMatrix(v)).multiplyScalar(ur.MathUtils.RAD2DEG);m={...m,rotation:w.toArray()}}this.updateTransformState(m),this.traverseEntity(y=>{y._cameraType&&y.dispatchEvent(AM)})}updateVisible(r){if(this.visible=this.dataPatched.visible&&(!this.dataPatched.cloner||(this.dataPatched.cloner.disabled??!1)||this.dataPatched.cloner?.hideBase!==!0),!r)return;let o=!1;this.traverseEntity(n=>{if(n.data.type==="Splat")return o=!0,!0}),o&&r.reloadSplats()}updateState_Entity(r,o){r.name!==void 0&&(this.name=r.name),r.raycastLock!==void 0&&(this.raycastLock=r.raycastLock),r.visible!==void 0&&(this.updateVisible(o?.scene),this.resetBBoxNeedsUpdate()),o&&"cloner"in r&&r.cloner!==void 0&&(this.setFromClonerState(r.cloner,o),this.updateVisible(o.scene)),this.updateTransformState(r,o)}get attachedSurfaceCloners(){return this.children.filter(r=>r instanceof so.Cloner&&r.parameters.type==="toObject")}setFromClonerState(r,o){this.disposed||(r===null||r.disabled?(this.cloner&&this.cloner.removeFromParent(),this.cloner=void 0):this.cloner===void 0?(this.cloner=new so.Cloner(this,r),o.scene.addPendingExpandCloner(this)):this.cloner.updateState(r,o.scene))}expandCloner(r){!this.disposed&&this.cloner&&this.cloner.expandClones(r)}invalidateClonerTransform(r){this.cloner&&this.cloner.invalidateTransform(r)}requestRender(){this.dispatchEvent({type:"requestRender"})}};var Gi=require("three");var st=require("three"),ux=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=i.parameters?.radiusTop,r=i.parameters?.radiusBottom,o=Object.assign({},t?.parameters??{width:100,radialSegments:64,heightSegments:1,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadius:8,cornerSegments:8,hollow:0},i.parameters);o.thetaLength=st.MathUtils.clamp(o.thetaLength,0,360);let n=o.width/2,a=o.radiusTop??n,s=o.radiusBottom??n;if(a===s?(a=n,s=n):a>s?(a=n,s=s*n/a):(a=a*n/s,s=n),o.shapeBlendNode){a=e??n,s=r??n;let l=Math.max(a,s)*2;o.width=l,o.depth=l}return{parameters:Object.assign(o,{width:Math.abs(o.width),height:Math.abs(o.height??o.width),depth:Math.abs(o.depth??o.width),radiusTop:a,radiusBottom:s})}}static build(i){let{width:t,depth:e,height:r,radialSegments:o,heightSegments:n,openEnded:a,thetaStart:s,thetaLength:l,radiusTop:c,radiusBottom:u,cornerRadius:p,cornerSegments:d,hollow:f}=i.parameters,h;return l===0?(h=new st.BufferGeometry,h.setAttribute("position",new st.Float32BufferAttribute([],3))):p||f?h=new Sl(c,u,r,o,n,a,s,l*Math.PI/180,p,p,d,f):h=new st.CylinderGeometry(c,u,r,o,n,a,s,l*Math.PI/180),h.scale(1,1,e/t),Object.assign(h,{userData:{...i,type:"CylinderGeometry"}})}};function zi(i,t,e){e.x=i.x*t.x,e.y=i.y,e.z=i.x*t.y}function cx(i){return new st.Vector2(i.y,-i.x)}var Sl=class extends st.BufferGeometry{constructor(t,e,r,o,n,a,s,l,c,u,p,d,f=!1){super(),this.type="RoundedCylinderBufferGeometry",t=t!==void 0?t:1,e=e!==void 0?e:1,r=r||1,o=Math.floor(o)||8,n=Math.floor(n)||1,a=a!==void 0?a:!1,s=s!==void 0?s:0,l=l!==void 0?l:Math.PI*2,a&&(c=0,u=0);let h=[],m=[],y=[],b=[],v=0,w=r/2,O=new st.Vector3,S=new st.Vector3;f&&t==0&&(t=c),f&&e==0&&(e=u);let T=new st.Vector2(t,w),M=new st.Vector2(e,-w),g=null,D=null,E=null,I=null,N=T.clone().sub(M),_=0,R=0,V=0;d>0&&(_=Math.min(t,e)*(1-d),R=t-_,V=e-_);let U=T.clone();U.x-=_;let B=Math.PI-N.angle(),q=N.angle(),j=Math.tan(q/2),F=Math.tan(B/2),H=j+F,W=d?H:F,ee=d?H:j;if(c=Math.min(c,(t-R)/W,N.length()/H),u=Math.min(u,(e-V)/ee,N.length()/H),c>0){let Q=c/j;g=T.clone().sub(new st.Vector2(Q,c)),d&&(E=g.clone(),E.x-=_-H*c),T.sub(N.clone().setLength(Q))}if(u>0){let Q=u/F;D=M.clone().sub(new st.Vector2(Q,-u)),M.add(N.clone().setLength(Q)),d&&(I=D.clone(),I.x-=_-H*u,U.sub(N.clone().setLength(Q)))}N=T.clone().sub(M);let te=N.length()<.5,Y=[];for(let Q=0;Q<=o;Q++){let $=[],pe=Q/o,le=pe*l+s,ie=new st.Vector2(Math.sin(le),Math.cos(le));I&&D?(re($,pe,ie,B,u,I,-1,!0),re($,pe,ie,q,u,D,-1,!1)):D?(K($,ie,D.x,0,-1),re($,pe,ie,q,u,D,-1,!1)):a||K($,ie,e,V,-1);let ue=cx(N).normalize();if(zi(ue,ie,O),!te)for(let ae=0;ae<=n;ae++){let ge=ae/n,me=N.clone().multiplyScalar(ge).add(M);zi(me,ie,S),m.push(S.x,S.y,S.z),y.push(O.x,O.y,O.z),b.push(pe,.5+S.y/r),$.push(v++)}if(E&&g?(re($,pe,ie,B,c,g,1,!1),re($,pe,ie,q,c,E,1,!0)):g?(re($,pe,ie,B,c,g,1,!1),K($,ie,g.x,0,1)):a||K($,ie,t,R,1),d&&!te){let ae=cx(N).multiplyScalar(-1).normalize();zi(ae,ie,O);for(let ge=0;ge<=n;ge++){let me=ge/n,ye=N.clone().multiplyScalar(-me).add(U);zi(ye,ie,S),m.push(S.x,S.y,S.z),y.push(O.x,O.y,O.z),b.push(pe,.5+S.y/r),$.push(v++)}}d&&!a&&$.push($[0]),Y.push($)}for(let Q=0;Q<Y.length-1;Q++)for(let $=0;$<Y[0].length-1;$++){if(a&&d&&$==n)continue;let pe=Y[Q][$],le=Y[Q+1][$],ie=Y[Q+1][$+1],ue=Y[Q][$+1],ae=m[ie*3+0],ge=m[ie*3+2];h.push(pe,le,ue),(ae!=0||ge!=0)&&h.push(le,ie,ue)}l<Math.PI*2&&(Z(-1,Y[0],s),Z(1,Y[Y.length-1],s+l)),this.setIndex(h),this.setAttribute("position",new st.Float32BufferAttribute(m,3)),this.setAttribute("normal",new st.Float32BufferAttribute(y,3)),this.setAttribute("uv",new st.Float32BufferAttribute(b,2));function re(Q,$,pe,le,ie,ue,ae,ge){for(let me=0;me<p+1;me++){let ye=me/p,ve=ae<0?ye:1-ye;ge&&(ve-=1),ve*=le;let xe=new st.Vector2(Math.sin(ve),Math.cos(ve)*ae),C=xe.clone().multiplyScalar(ie).add(ue);zi(C,pe,S),m.push(S.x,S.y,S.z),zi(xe,pe,O),y.push(O.x,O.y,O.z),b.push($,.5+S.y/r),Q.push(v++)}}function K(Q,$,pe,le,ie){let ue=new st.Vector3,ae=new st.Vector2,ge=[pe,le];ie<0&&ge.reverse();for(let me of ge)ae.set(me,w*ie),zi(ae,$,ue),m.push(ue.x,ue.y,ue.z),y.push(0,ie,0),b.push(.5,.5),Q.push(v++)}function Z(Q,$,pe){let le=new st.Vector2(Math.sin(pe),Math.cos(pe)),ie=new st.Vector2(-Math.cos(pe),Math.sin(pe)),ue=new st.Vector3,ae=Q<0?(ye,ve,xe)=>h.push(ye,ve,xe):(ye,ve,xe)=>h.push(ye,xe,ve),ge=new st.Vector2((t+e+R+V)/4,0);zi(ge,le,ue),m.push(ue.x,ue.y,ue.z),y.push(ie.x,0,ie.y),b.push(.5,.5);let me=v++;for(let ye of $){let ve=m.slice(ye*3,ye*3+3);m.push(...ve),y.push(ie.x,0,ie.y);let xe=b.slice(ye*2,ye*2+2);b.push(...xe),v++}for(let ye=me+1;ye<v-1;ye++)ae(me,ye,ye+1);ae(me,v-1,me+1)}}};var dx=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,radialSegments:32,heightSegments:8,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadiusTop:8,cornerRadiusBottom:8,cornerSegments:8},i.parameters);return e.thetaLength=Gi.MathUtils.clamp(e.thetaLength,0,360),{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(i){let{width:t,depth:e,height:r,radialSegments:o,heightSegments:n,openEnded:a,thetaStart:s,thetaLength:l,cornerRadiusTop:c,cornerRadiusBottom:u,cornerSegments:p}=i.parameters,d;return l===0?(d=new Gi.BufferGeometry,d.setAttribute("position",new Gi.Float32BufferAttribute([],3))):c>0||u>0||l<360?d=new Sl(0,t/2,r,o,n,a,s,l*Math.PI/180,c,u,p,0,!0):d=new Gi.ConeGeometry(t/2,r,o,n,a),d.scale(1,1,e/t),Object.assign(d,{userData:{...i,type:"ConeGeometry"}})}};var Sr=require("three"),px=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,widthSegments:1,heightSegments:1,depthSegments:1,cornerRadius:8,cornerSegments:8},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(i){let{width:t,height:e,depth:r,widthSegments:o,heightSegments:n,depthSegments:a,cornerRadius:s,cornerSegments:l}=i.parameters,c;return s===0?c=new Sr.BoxGeometry(t,e,r,o,n,a):c=new bf(t,e,r,o,n,a,s,l),Object.assign(c,{userData:{...i,type:"CubeGeometry"}})}},xf=Math.PI/2,bf=class extends Sr.BufferGeometry{constructor(t=1,e=1,r=1,o=1,n=1,a=1,s=0,l=4){super(),this.type="BoxGeometry",o=Math.floor(o),n=Math.floor(n),a=Math.floor(a),l=Math.floor(l),s=Math.min(s,t/2,e/2,r/2);let c=[],u=[],p=[],d=[],f=0;h("z","y","x",-1,-1,r,e,t,a,n),h("z","y","x",1,-1,r,e,-t,a,n),h("x","z","y",1,1,t,r,e,o,a),h("x","z","y",1,-1,t,r,-e,o,a),h("x","y","z",1,-1,t,e,r,o,n),h("x","y","z",-1,-1,t,e,-r,o,n),s>0&&(m("z","y","x",-1,-1,1,r,e,t,a),m("z","y","x",1,-1,-1,r,e,t,a),m("z","y","x",-1,1,-1,r,e,t,a),m("z","y","x",1,1,1,r,e,t,a),m("x","y","z",-1,-1,-1,t,e,r,o),m("x","y","z",1,-1,1,t,e,r,o),m("x","y","z",-1,1,1,t,e,r,o),m("x","y","z",1,1,-1,t,e,r,o),m("y","x","z",-1,-1,1,e,t,r,n),m("y","x","z",1,-1,-1,e,t,r,n),m("y","x","z",1,1,1,e,t,r,n),m("y","x","z",-1,1,-1,e,t,r,n),y(1,1,1),y(-1,1,1),y(1,-1,1),y(-1,-1,1),y(1,1,-1),y(-1,1,-1),y(1,-1,-1),y(-1,-1,-1)),this.setIndex(c),this.setAttribute("position",new Sr.Float32BufferAttribute(u,3)),this.setAttribute("normal",new Sr.Float32BufferAttribute(p,3)),this.setAttribute("uv",new Sr.Float32BufferAttribute(d,2));function h(b,v,w,O,S,T,M,g,D,E){let I=(T-2*s)/D,N=(M-2*s)/E,_=T/2-s,R=M/2-s,V=g/2,U=D+1,B=E+1,q=0,j=new Sr.Vector3;for(let F=0;F<B;F++){let H=F*N-R;for(let W=0;W<U;W++){let ee=W*I-_;j[b]=ee*O,j[v]=H*S,j[w]=V,u.push(j.x,j.y,j.z),j[b]=0,j[v]=0,j[w]=g>0?1:-1,p.push(j.x,j.y,j.z),d.push(W/D),d.push(1-F/E),q+=1}}for(let F=0;F<E;F++)for(let H=0;H<D;H++){let W=f+H+U*F,ee=f+H+U*(F+1),te=f+(H+1)+U*(F+1),Y=f+(H+1)+U*F;c.push(W,ee,Y),c.push(ee,te,Y)}f+=q}function m(b,v,w,O,S,T,M,g,D,E){let I=(M-2*s)/E,N=M/2-s,_=g/2-s,R=D/2,V=E+1,U=0,B=new Sr.Vector3,q=new Sr.Vector3;for(let j=0;j<l+1;j++){let F=j/l*xf,H=Math.sin(F)*s,W=(1-Math.cos(F))*s,ee=Math.sin(F),te=Math.cos(F);B[v]=(_+H)*S,B[w]=(R-W)*T,q[b]=0,q[v]=ee*Math.sign(B[v]),q[w]=te*Math.sign(B[w]);for(let Y=0;Y<V;Y++){let re=Y*I-N;B[b]=re*O,u.push(B.x,B.y,B.z),p.push(q.x,q.y,q.z),d.push(Y/E),d.push(0),U+=1}}for(let j=0;j<l;j++)for(let F=0;F<E;F++){let H=f+F+V*j,W=f+F+V*(j+1),ee=f+(F+1)+V*(j+1),te=f+(F+1)+V*j;c.push(H,W,te),c.push(W,ee,te)}f+=U}function y(b,v,w){let O=new Sr.Vector3,S=new Sr.Vector3(t/2,e/2,r/2);S.subScalar(s);let T=[],M=b*v*w>0?(D,E,I)=>c.push(D,E,I):(D,E,I)=>c.push(D,I,E);for(let D=0;D<=l;D++){let E=[],I=xf*(1-D/l),N=Math.cos(I),_=Math.sin(I),R=0;for(let V=0;V<=D;V++){let U=Math.cos(R),B=Math.sin(R);O.x=N*U,O.y=_,O.z=N*B;let q=S.clone().addScaledVector(O,s);u.push(b*q.x,v*q.y,w*q.z),p.push(b*O.x,v*O.y,w*O.z),d.push(0,0),E.push(f++),R+=xf/D}T.push(E)}let g=T.length-1;for(let D=0;D<g;D++){let E=T[D],I=T[D+1],N=E.length-1;M(E[0],I[1],I[0]);for(let _=1;_<=N;_++)M(E[_-1],E[_],I[_]),M(E[_],I[_+1],I[_])}}}};var It=require("three"),Fi=class extends It.BufferGeometry{constructor(t=[],e=[],r="",o=1,n=.2,a=4){super(),this.type="PolyhedronGeometryRound";let s=[],l=[],c=[];u(),p(),this.setAttribute("position",new It.Float32BufferAttribute(s,3)),this.setAttribute("normal",new It.Float32BufferAttribute(c,3)),this.setAttribute("uv",new It.Float32BufferAttribute(l,2));return;function u(){n=Math.min(1-1e-5,n),n==0&&(a=0);let f={IcosahedronGeometry:5,DodecahedronGeometry:3,HexahedronGeometry:3,OctahedronGeometry:4,TetrahedronGeometry:3}[r],h=new It.Vector3,m=h.clone(),y=new It.Triangle,b=n*o,v=o-b,w=a+1,O=new It.Vector3,S=(j,F)=>O.subVectors(j,F).normalize(),T=(j,F)=>Array(j).fill(void 0).map(F),M=T(t.length/3,(j,F)=>new It.Vector3().fromArray(t,F*3).setLength(o)),g=[],D=1e6;for(let j=0;j<M.length;j++){let F=M[j],H=[],W,ee,te,Y=1e10,re=-1;for(;(re=e.indexOf(j,re+1))!=-1;){let $=re-re%3;W=e[$+(re+1)%3],ee=e[$+(re+2)%3],te=F.distanceToSquared(M[W]),Y=Math.min(Y,te),H.push([W,ee,te])}Y+=1e-6;let K=[],Z=0,Q=H.length;for(let $=0;$<Q;$++){[W,ee,te]=H[Z];let pe=g[W]?.includes(j)==!0;te<=Y&&K.push(W+ +pe*D),Z=H.findIndex(le=>le[0]==ee)}g.push(K)}let E=[];{let j=0,F=0,H,W,ee=f==3;for(let te=0;te<=a;te++){H=te*(te+1)/2,W=(te+1)*(te+2)/2;for(let Y=0;Y<a-te;Y++)[j,F]=[H+Y+te+2,W+Y+te+3],E.push(H,W,...ee?[F,H]:[j,W],F,j),[H,W]=[j,F];E.push(H,W,H+a+2)}}let I=h.clone(),N=h.clone(),_=h.clone(),R=h.clone(),V=h.clone(),U=[],B=T(M.length,()=>T(f,()=>h.clone()));for(let j=0;j<M.length;j++){h.copy(M[j]).normalize(),I.copy(h).multiplyScalar(v);let F=g[j];for(let K=0;K<F.length;K++){let Z=F[K],Q=F[(K+1)%f];y.setFromPointsAndIndices(M,j,Z%D,Q%D),y.b.sub(y.a).setLength(1e10).add(y.a),y.c.sub(y.a).setLength(1e10).add(y.a),y.closestPointToPoint(I,B[j][K])}let H=[],W=[],ee=[],te=new It.Vector3;a==0&&[...B[j]].reduce((K,Z)=>K.add(Z),te).multiplyScalar(1/f);for(let K=0;K<f;K++){let Z=[],Q=(K-1+f)%f,$=B[j][Q],pe=B[j][K];h.copy($).sub(I),m.copy(pe).sub(I);let le=I.angleTo(h),ie=h.angleTo(m),ue=Math.cos(le)*b;a==0?N.copy(te):N.copy(I).setLength(v+ue),W.push(ue);let ae=[N,$,pe];for(let ge=0;ge<2;ge++){let me=ae[ge],ye=ae[ge+1];R.subVectors(me,I),V.subVectors(ye,I),_.crossVectors(R,V).normalize();for(let ve=0;ve<w;ve++){let xe=[le,ie][ge]*ve/w;h.copy(R).applyAxisAngle(_,xe).add(I),H.push(h.clone()),ge&&(S(h,I),Z.push([ve==0?me:h.clone(),O.clone()]))}ge&&(S(ye,I),Z.push([ye,O.clone()]))}ee.push(Z)}U.push(ee);let Y=2*w,re=2;for(let K=0;K<f;K++){let Z=Y*K,Q=Y*((K+1)%f),$=[H[Z]];for(let le=1;le<w;le++){R=H[Z+le],V=H[Q+le],$.push(R);for(let ie=1,ue=le-re+1;ie<=ue;ie++)h.lerpVectors(R,V,ie/(ue+1)),h.sub(I).setLength(W[K]).add(I),$.push(h.clone());$.push(V)}for(let le=0;le<w;le++)$.push(H[le+w+Z]);$.push(H[Q+w]);let pe=E.map(le=>$[le]);s.push(...pe.map(le=>[le.x,le.y,le.z]).flat()),c.push(...pe.map(le=>(S(le,I),[O.x,O.y,O.z])).flat())}}let q=[];for(let j=0;j<g.length;j++)for(let F=0;F<f;F++){let H=g[j][F];if(H<D){let W=g[H].findIndex(Y=>Y%D==j),ee=U[j][F],te=U[H][W];for(let Y=0;Y<w;Y++){let re=ee[Y],K=te[w-Y],Z=ee[Y+1],Q=te[w-(Y+1)];[re,K,Z,Z,K,Q].forEach($=>{s.push($[0].x,$[0].y,$[0].z),c.push($[1].x,$[1].y,$[1].z)})}q.push(ee[0][0],te[w][0],ee[w][0],te[0][0])}}for(;q.length;){let j,F,H,W;[j,F]=q.splice(0,2);let ee=[j];for(;j!=F;)ee.push(F),H=q.indexOf(F),W=H%2,F=q.splice(H-W,2)[1-W];O.subVectors(ee[0],ee[1]).cross(h.subVectors(ee[0],ee[2])).normalize();let te=O.dot(ee[0])<0;te&&O.negate();for(let Y=1;Y<=ee.length-2;Y++)[ee[Y+ +te],ee[Y+1-+te],ee[0]].forEach(re=>{s.push(re.x,re.y,re.z),c.push(O.x,O.y,O.z)})}}function p(){let d=new It.Vector3;for(let M=0;M<s.length;M+=3){d.x=s[M+0],d.y=s[M+1],d.z=s[M+2];let g=S(d)/2/Math.PI+.5,D=T(d)/Math.PI+.5;l.push(g,1-D)}let f=new It.Vector3,h=new It.Vector3,m=new It.Vector3,y=new It.Vector3,b=new It.Vector2,v=new It.Vector2,w=new It.Vector2,O=(M,g,D,E)=>{E<0&&M.x===1&&(l[g]=M.x-1),D.x===0&&D.z===0&&(l[g]=E/2/Math.PI+.5)};for(let M=0,g=0;M<s.length;M+=9,g+=6){f.set(s[M+0],s[M+1],s[M+2]),h.set(s[M+3],s[M+4],s[M+5]),m.set(s[M+6],s[M+7],s[M+8]),b.set(l[g+0],l[g+1]),v.set(l[g+2],l[g+3]),w.set(l[g+4],l[g+5]),y.copy(f).add(h).add(m).divideScalar(3);let D=S(y);O(b,g+0,f,D),O(v,g+2,h,D),O(w,g+4,m,D)}for(let M=0;M<l.length;M+=6){let g=l[M+0],D=l[M+2],E=l[M+4],I=Math.max(g,D,E),N=Math.min(g,D,E);I>.9&&N<.1&&(g<.2&&(l[M+0]+=1),D<.2&&(l[M+2]+=1),E<.2&&(l[M+4]+=1))}function S(M){return Math.atan2(M.z,-M.x)}function T(M){return Math.atan2(-M.y,Math.sqrt(M.x*M.x+M.z*M.z))}}}static fromJSON(t){return new Fi(t.vertices,t.indices,t.radius,t.corner,t.cornerSides)}};var fx=require("three"),hx=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,detail:0,corner:0,cornerSides:4},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(i){let{width:t,height:e,depth:r,detail:o,corner:n,cornerSides:a}=i.parameters,s=o===0&&n!==0?new wl(t*.5,n,a):new fx.DodecahedronGeometry(t*.5,o);return s.scale(1,e/t,r/t),Object.assign(s,{userData:{...i,type:"DodecahedronGeometry"}})}},wl=class extends Fi{constructor(t=1,e=.2,r=4){let o=(1+Math.sqrt(5))/2,n=1/o,a=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-n,-o,0,-n,o,0,n,-o,0,n,o,-n,-o,0,-n,o,0,n,-o,0,n,o,0,-o,0,-n,o,0,-n,-o,0,n,o,0,n],s=[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(a,s,l,t,e,r),this.type=l}static fromJSON(t){return new wl(t.radius,t.corner,t.cornerSides)}};var Ye=require("three");var Ne=require("three"),Pl=1e-12,Ua=class{constructor(t){this.position=new Ne.Vector2;this.startPosition=new Ne.Vector2;this.uuid=Ne.MathUtils.generateUUID();this.position=t.clone()}start(){this.reset()}reset(){this.startPosition.copy(this.position)}applyOffset(t){this.position.copy(this.startPosition).add(t)}copy(t){return this.position.copy(t.position),this.startPosition.copy(t.startPosition),this}clone(){return new Ua(this.position).copy(this)}toJSON(){return[this.position.x,this.position.y]}},ka=class extends Ua{constructor(e){super(e.position);this.parent=e}copy(e){return super.copy(e),this}clone(){return new ka(this.parent).copy(this)}},lo=class extends Ua{constructor(e,r){super(r);this.controls=[];this.roundness=0;this.areControlsDirectionsMirrored=!0;this.uuid=e,this.controls.push(new ka(this),new ka(this))}static create(e,r){let o=new lo(e,new Ne.Vector2(...r.position));return o.controls[0].position.set(...r.controlPrevious.position),o.controls[1].position.set(...r.controlNext.position),o.roundness=r.roundness,o.areControlsDirectionsMirrored=r.areControlsDirectionsMirrored,o}getOppositeControl(e){let r=this.controls.indexOf(e);return r===0?this.controls[1]:r===1?this.controls[0]:null}applyOffsetToControls(e,r=1){for(let o=0,n=this.controls.length;o<n;o++){let a=this.controls[o];this.position.distanceTo(a.position)<=r?a.position.copy(this.position):a.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 lo(this.uuid,this.position).copy(this)}toJSON(){return super.toJSON().concat(this.controls[0].toJSON(),this.controls[1].toJSON(),[this.roundness])}computeTangents(){let e=this.curveBefore?.getTangentAt(1),r=this.curveAfter?.getTangentAt(0);return[e,r]}computeNormals(e=new Ne.Vector2,r=new Ne.Vector2){let[o,n]=this.computeTangents();return o&&n&&(mx(o,e),mx(n,r)),[e,r]}computeTangent(e=new Ne.Vector2){let[r,o]=this.computeTangents();return r&&o&&e.copy(r).add(o).normalize(),e}computeNormal(e=new Ne.Vector2){let[r,o]=this.computeNormals();return e.copy(r).add(o).normalize(),e}};function mx(i,t=new Ne.Vector2){let e=i.length();return t.set(-i.y/e,i.x/e)}var Sf=i=>i,Ha=new Ne.Vector2,zu=new Ne.Vector2,EM=new Ne.Vector2,NM=new Ne.Vector2,DM=new Ne.Vector2,_M=new Ne.Vector2,gx=new Ne.Vector3,xx=new Ne.Vector3;function bx(i){let t=new Ne.Vector2;t.addVectors(i.v0,Ha.subVectors(i.v1,i.v0).multiplyScalar(2/3));let e=new Ne.Vector2;return e.addVectors(i.v2,zu.subVectors(i.v1,i.v2).multiplyScalar(2/3)),new Ne.CubicBezierCurve(i.v0,t,e,i.v2)}function Ol(i,t,e=Number.EPSILON){return Math.abs(i-t)<e}function RM(i,t,e=Number.EPSILON){return i.distanceTo(t)<e}function LM(i,t,e=Number.EPSILON){return i.distanceTo(t)<e}function wf(i,t,e){let r=Math.sqrt(Math.pow(t.x-i.x,2)+Math.pow(t.y-i.y,2)),o=Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2)),n=Math.sqrt(Math.pow(e.x-i.x,2)+Math.pow(e.y-i.y,2));return Math.acos((o*o+r*r-n*n)/(2*o*r))}function vx(i,t,e){return yx(i,t)&&yx(t,e)&&vf(i.position,t.position,e.position)}function vf(i,t,e){return Ha.copy(t).sub(i).cross(zu.copy(e).sub(i))===0}function Sx(i,t,e,r,o){let n=Math.sqrt(Math.pow(t.x-i.x,2)+Math.pow(t.y-i.y,2)),a=(i.y+t.y)/2,s=(i.x+t.x)/2,l=Math.sqrt(Math.pow(e,2)-Math.pow(n/2,2))*(i.y-t.y)/n,c=Math.sqrt(Math.pow(e,2)-Math.pow(n/2,2))*(t.x-i.x)/n;return r.set(s+l,a+c),o.set(s-l,a-c),[r,o]}function wx(i,t,e){let r=i.distanceTo(e),o=t.distanceTo(e);return r<o?t:i}function Px(i,t,e,r,o,n){let a=t.x-i.x,s=t.y-i.y,l=e.x-i.x,c=e.y-i.y,u=Math.sqrt((a+l)*(a+l)+(s+c)*(s+c)),p;return wf(t,i,e)>Math.PI&&(u*=-1),Ol(c,s)?p=(s+c)*(r/u-.5)*8/3/(a-l):p=(a+l)*(r/u-.5)*8/3/(c-s),o.set(t.x-p*s,t.y+p*a),n.set(e.x+p*c,e.y-p*l),[o,n]}function Pf(i,t){return i.position.equals(i.controls[1].position)&&t.position.equals(t.controls[0].position)}function yx(i,t){return vf(i.position,i.controls[1].position,t.position)&&vf(i.position,t.controls[0].position,t.position)}function Ox(i,t,e,r,o=.5){let n=Ha.subVectors(t,i).multiplyScalar(o).add(i),a=zu.subVectors(e,t).multiplyScalar(o).add(t),s=EM.subVectors(r,e).multiplyScalar(o).add(e),l=n,c=NM.subVectors(a,n).multiplyScalar(o).add(n),u=DM.subVectors(s,a).multiplyScalar(o).add(a),p=s,d=_M.subVectors(u,c).multiplyScalar(o).add(c);return[i.x,i.y,l.x,l.y,c.x,c.y,d.x,d.y,u.x,u.y,p.x,p.y,r.x,r.y]}function Tx(i,t,e=12,r=!0){let o=xx.set(0,0,0),n,a=0,s=[];for(let l=0;l<t.length;l++){let c=Sf(t[l]),u=Ha,p=ji(c,e);s.push(p);for(let d=0;d<=p;d++)if(c instanceof Ne.CubicBezierCurve||c instanceof Ne.QuadraticBezierCurve||c instanceof Ne.LineCurve){if(c.getPoint(d/p,u),o.set(u.x,u.y,0),n!==void 0&&LM(n,o))continue;n===void 0&&(n=gx),n.copy(o),i.setXYZ(a,o.x,o.y,o.z),a++}}return r&&a>1&&!(i.getX(a-1)===i.getX(0)&&i.getY(a-1)===i.getY(0)&&i.getZ(a-1)===i.getZ(0))&&(i.setXYZ(a,i.getX(0),i.getY(0),i.getZ(0)),a++),i}function Cx(i,t,e,r=12,o=!0){let n=xx.set(0,0,0),a=0,s=[];for(let l=0;l<t.length;l++){if(e[l]===!1)continue;let c,u=Sf(t[l]),p=Ha,d=ji(u,r);s.push(d);for(let f=0;f<=d;f++)if(u instanceof Ne.CubicBezierCurve||u instanceof Ne.QuadraticBezierCurve||u instanceof Ne.LineCurve){if(u.getPoint(f/d,p),n.set(p.x,p.y,0),c?.equals(n))continue;c===void 0?c=gx:(i.setXYZ(a,c.x,c.y,c.z),a++,i.setXYZ(a,n.x,n.y,n.z),a++),c.copy(n)}}return o&&a>1&&!(i.getX(a-1)===i.getX(0)&&i.getY(a-1)===i.getY(0)&&i.getZ(a-1)===i.getZ(0))&&(i.setXYZ(a,i.getX(0),i.getY(0),i.getZ(0)),a++),s}function Of(i,t=12,e=!1){let r=[];for(let o=0,n=i.length;o<n;o++){let a=i[o],s=0;if(e&&a.roundedCurveCorner!==void 0){let l=ji(a.roundedCurveCorner,t)*.5;o>0&&(r[o-1]+=l),s+=l}a.curveAfter!==void 0&&(s+=ji(a.curveAfter,t)),r.push(s)}return i.length>0&&e&&i[0].roundedCurveCorner!==void 0&&(r[i.length-1]+=ji(i[0].roundedCurveCorner,t)*.5),r}function ji(i,t=12){return i&&i instanceof Ne.EllipseCurve?t*2:i&&(i instanceof Ne.LineCurve||i instanceof Ne.LineCurve3)?1:i&&i instanceof Ne.SplineCurve?t*i.points.length:t}function Ax(i,t,e=12,r=!0){let o,n=0;for(let a=0;a<t.length;a++){let s=Sf(t[a]),l=ji(s,e),c=Ha;for(let u=0;u<=l;u++)if(s instanceof Ne.CubicBezierCurve||s instanceof Ne.QuadraticBezierCurve||s instanceof Ne.LineCurve){if(s.getPoint(u/l,c),o!==void 0&&RM(o,c,Pl))continue;o===void 0&&(o=zu),o.copy(c),i.push(c.x,c.y),n++}}return Ol(i[0],i[i.length-2],Pl)&&Ol(i[1],i[i.length-1],Pl)&&(i.pop(),i.pop()),r&&n>1&&!(Ol(i[n-1],i[1],Pl)&&Ol(i[n-2],i[0],Pl))&&(i.push(i[0],i[1]),n++),i}var Tf=new Ye.Vector2,BM=new Ye.Vector2,VM=new Ye.Vector2,zM=new Ye.Vector2,GM=new Ye.Vector2,FM=new Ye.Vector2,Xe=class extends Ye.Shape{constructor(e=100,r=100){super();this.points=[];this.shapeHoles=[];this.plane=new Ye.Plane(new Ye.Vector3(0,0,-1));this.subdivision=0;this.controlSnapDistance=4;this.pointIDs=0;this.isMesh2D=!1;this.isText=!1;this._roundness=0;this.isClosed=!1;this.useCubicForRoundedCorners=!0;this.uuid=Ye.MathUtils.generateUUID();this.needsUpdate=!1;this.roundedCurves=[];this._width=e,this._height=r}static createFromState(e,r,o){let n=new Xe;return n.isClosed=e.isClosed,n.points=e.points.map(a=>lo.create(a.id,a.data)),typeof e.roundness=="number"&&(n.roundness=e.roundness),n.shapeHoles=e.shapeHoles.map(a=>Xe.createFromState(a)),r!==void 0&&o!==void 0&&n.applySize(r,o),n.update(),n}get width(){return this._width}get height(){return this._height}get roundness(){return this._roundness}set roundness(e){if(this._roundness!==e){this._roundness=e;for(let r=0,o=this.points.length;r<o;r++)this.points[r].roundness=e;this.needsUpdate=!0}}getPointsIndexesByIds(e){return e.map(r=>this.getPointIndexById(r)).filter(r=>r>=0)}getPointIndexById(e){let r=this.points.length,o=this.points.findIndex(n=>n.uuid===e);if(o<0){let n=r;for(let a=0,s=this.shapeHoles.length;a<s;a++){let l=this.shapeHoles[a],c=l.points.length,u=l.getPointIndexById(e);if(u<0)n+=c;else return u+n}}return o}getLineIndexById(e){return this.getPointIndexById(e)}getBezierPoint(e){if(e<=this.points.length-1)return this.points[e];if(this.shapeHoles.length>0){let r=this.points.length;for(let o=0,n=this.shapeHoles.length;o<n;o++){let a=this.shapeHoles[o],s=e-r;if(s<=a.points.length-1)return a.points[s];r+=a.points.length}}throw new Error("This shape does not have a point for this index: "+e)}getBezierPointIndex(e){let r=this.points.indexOf(e);if(r>=0)return r;if(r=this.points.length,this.shapeHoles.length>0)for(let o=0,n=this.shapeHoles.length;o<n;o++){let a=this.shapeHoles[o],s=a.points.indexOf(e);if(s>=0)return r+s;r+=a.points.length}return-1}getAllPoints(){let e=[].concat(...this.shapeHoles.map(r=>r.points));return[...this.points,...e]}applySize(e,r){e===0&&(e=.001),r===0&&(r=.001),this._width=e,this._height=r}applyScale(e,r){let o=Tf.set(e,r);for(let n=0,a=this.points.length;n<a;n++){let s=this.points[n];s.position.multiply(o),s.controls[0].position.multiply(o),s.controls[1].position.multiply(o)}for(let n=0,a=this.shapeHoles.length;n<a;n++)this.shapeHoles[n].applyScale(e,r);this._update()}createPoint(e,r=0,o=Ye.MathUtils.generateUUID()){let n;e instanceof Ye.Vector2?n=e:n=new Ye.Vector2(e,r);let a=new lo(o,n);return a.roundness=this.roundness,a}addPoint(e){this.points.push(e),this.needsUpdate=!0}addPointAt(e,r){this.points.splice(r,0,e),this.needsUpdate=!0}getPointByUuid(e){for(let r=0,o=this.points.length;r<o;r++){let n=this.points[r];if(n.uuid===e)return n}for(let r=0,o=this.shapeHoles.length;r<o;r++){let a=this.shapeHoles[r].getPointByUuid(e);if(a)return a}}getFirstPoint(){return this.points[0]}getLastPoint(){return this.points[this.points.length-1]}removePoint(e){let r=this.points.indexOf(e);r>=0&&this.points.splice(r,1),this.needsUpdate=!0}removePointById(e){let r=this.points.find(o=>o.uuid===e);r&&this.removePoint(r)}update(){for(let e=0,r=this.shapeHoles.length;e<r;e++)this.shapeHoles[e].update();this._update()}extractShapePointsToBuffer(e,r=12,o=!1){this.subdivision=r,this.curveDivisions===void 0&&this.computeCurveDivisions(r);let n=o?this.roundedCurveDivisions:this.curveDivisions;return Tx(e,o?this.roundedCurves:this.curves,r,this.autoClose),n.reduce((a,s)=>a+s,0)+1}computeCurveDivisions(e=12){return this.curveDivisions=Of(this.points,e,!1),this.roundedCurveDivisions=Of(this.points,e,!0),this.curveDivisions}extractFilteredShapePointsToBuffer(e,r,o=12){return Cx(e,this.curves,r,o,this.autoClose).reduce((a,s)=>a+s,0)*2}extractShapePointsToFlatArray(e,r=12){return this.subdivision=r,this.curveDivisions===void 0&&this.computeCurveDivisions(r),Ax(e,this.roundedCurves,r,this.autoClose)}getCurveIndexFromVertexId(e,r=!1){let o=0;this.curveDivisions===void 0&&this.computeCurveDivisions(this.subdivision);let n=r?this.roundedCurveDivisions:this.curveDivisions,a=0;r&&this.points[0].roundedCurveCorner!==void 0&&(a=ji(this.points[0].roundedCurveCorner,this.subdivision)*.5);let s=e-a;s<0&&(s+=n.reduce((l,c)=>l+c,0));for(let l=0,c=n.length;l<c;l++){let u=n[l];if(s<o+u)return[l,(s-o+1)/u];o+=u}return[0,1]}getCurveT(e,r,o){let n=this.points[e],a=this.points[e>=this.points.length-1?0:e+1],s=this.curveDivisions,l=s[e];if(Pf(n,a)){let p=n.position.distanceTo(a.position);return n.position.distanceTo(Tf.set(o.x,o.y))/p}let c=0;for(let p=0;p<e;p++)c+=s[p];return(r-c)/l}dispose(){}_applyCurveForPoint(e,r){Pf(r,e)?this.lineTo(e.position.x,e.position.y):this.bezierCurveTo(r.controls[1].position.x,r.controls[1].position.y,e.controls[0].position.x,e.controls[0].position.y,e.position.x,e.position.y);let o=this.curves[this.curves.length-1];e.curveBefore=o,r.curveAfter=o;let n=o.clone();e.roundedCurveBefore=n,r.roundedCurveAfter=n,e.roundedCurveCorner=void 0,this.roundedCurves.push(n)}_update(){if(this.curves=[],this.roundedCurves=[],!this.points.length)return;for(let r=0,o=this.points.length;r<o;r++){let n=this.points[r];if(r===0)this.moveTo(n.position.x,n.position.y);else{let a=this.points[r-1];this._applyCurveForPoint(n,a)}}let e=this.getLastPoint();if(e?.curveAfter&&(e.curveAfter=void 0),this.isClosed){let r=this.points[0],o=this.points[this.points.length-1];this._applyCurveForPoint(r,o)}if(this.points.length>2){let r=0;for(let o=0,n=this.points.length;o<n;o++){let a=this.points[o],s=this.points[o-1]??this.points[this.points.length-1],l=this.points[o+1]??this.points[0],c=a.roundness,u=s&&l&&vx(s,a,l);if(!a.controlsMoved()&&c>0&&!u){let p=a.curveBefore,d=a.curveAfter;if(p===void 0||d===void 0)continue;let f=a.roundedCurveBefore,h=a.roundedCurveAfter,m=p.getLength(),y=d.getLength(),b=Math.min(c,m*.499),v=Math.min(c,y*.499),w=Math.min(b,v),O=1-w/m,S=w/y,T=p.getPointAt(O,Tf),M=d.getPointAt(S,BM);this._subSplitCurve(p,f,O,T,void 0),this._subSplitCurve(d,h,S,void 0,M);let g;if(this.useCubicForRoundedCorners){let D=wf(T,a.position,M)/2,E=Math.tan(D)*T.distanceTo(a.position),[I,N]=Sx(T,M,E,VM,zM),_=wx(I,N,a.position),[R,V]=Px(_,T,M,E,GM,FM);g=new Ye.CubicBezierCurve(T.clone(),R.clone(),V.clone(),M.clone())}else g=new Ye.QuadraticBezierCurve(T.clone(),a.position.clone(),M.clone());a.roundedCurveCorner=g,this.roundedCurves.splice(o+r,0,g),r++}}}}_subSplitCurve(e,r,o,n,a){if(e instanceof Ye.LineCurve)n!==void 0&&r.v2.copy(n),a!==void 0&&r.v1.copy(a);else{let s=e,l=r,c=s.getUtoTmapping(o,0),u=Ox(s.v0,s.v1,s.v2,s.v3,c);return n!==void 0&&(l.v0.set(u[0],u[1]),l.v1.set(u[2],u[3]),l.v2.set(u[4],u[5]),l.v3.set(u[6],u[7])),a!==void 0&&(l.v0.set(u[6],u[7]),l.v1.set(u[8],u[9]),l.v2.set(u[10],u[11]),l.v3.set(u[12],u[13])),l}return r}clone(){let e=new Xe(this._width,this._height);return e.points=this.points.map(r=>r.clone()),e.isClosed=this.isClosed,e.roundness=this.roundness,e.isMesh2D=this.isMesh2D,e.shapeHoles=this.shapeHoles.map(r=>r.clone()),e}toJSON(){return{points:this.points.reduce((e,r)=>e.concat(r.toJSON()),[]),shapeHoles:this.shapeHoles.map(e=>e.toJSON()),isClosed:this.isClosed,roundness:this.roundness}}fromJSON(e){this.points=[],this.pointIDs=0;let r=e.points.length/7;for(let o=0;o<r;o++){let n=o*7,a=e.points[n+0],s=e.points[n+1],l=e.points[n+2],c=e.points[n+3],u=e.points[n+4],p=e.points[n+5],d=e.points[n+6],f=new lo(Ye.MathUtils.generateUUID(),new Ye.Vector2(a,s));f.controls[0].position.set(l,c),f.controls[1].position.set(u,p),f.roundness=d,this.points.push(f)}return this.shapeHoles=e.shapeHoles?.length?e.shapeHoles.map(o=>{let n=new Xe;return n.fromJSON(o),n}):[],this.isClosed=e.isClosed,this._roundness=e.roundness,this._update(),this}fromShape(e,r=!1){this.isText=r;let o=(a,s)=>{s instanceof Ye.CubicBezierCurve&&s.v3.equals(a.position)&&a.controls[0].position.copy(s.v2)},n=a=>{let s=[],l,c;for(l=0,c=a.length;l<c;l++)a[l]instanceof Ye.QuadraticBezierCurve&&(a[l]=bx(a[l]));for(l=0,c=a.length;l<c;l++){let d=a[l],f=l>0?a[l-1]:null,h;d instanceof Ye.CubicBezierCurve?(h=this.createPoint(d.v0),h.controls[1].position.copy(d.v1)):d instanceof Ye.LineCurve&&(h=this.createPoint(d.v1)),h!==void 0&&(f!==null&&o(h,f),s.push(h))}let u=a[a.length-1],p=!1;return u instanceof Ye.CubicBezierCurve?u.v3.equals(s[0].position)&&(s[0].controls[0].position.copy(u.v2),p=!0):u instanceof Ye.LineCurve&&u.v2.equals(s[0].position)&&(p=!0),this.isClosed=p,s};return this.points=n(e.curves),e instanceof Ye.Shape&&(this.shapeHoles=e.holes.map(a=>{let s=new Xe;return s.fromShape(a),s})),this.update(),this}updatePoint(e,r){let o=this.getPointByUuid(e);o&&(r.position!==void 0&&o.position.fromArray(r.position),r.roundness!==void 0&&(o.roundness=r.roundness),r.areControlsDirectionsMirrored!==void 0&&(o.areControlsDirectionsMirrored=r.areControlsDirectionsMirrored),this.needsUpdate=!0)}updatePreviousControl(e,r){let n=this.getPointByUuid(e)?.controls[0];n&&(r.position&&n.position.fromArray(r.position),this.needsUpdate=!0)}updateNextControl(e,r){let n=this.getPointByUuid(e)?.controls[1];n&&(r.position&&n.position.fromArray(r.position),this.needsUpdate=!0)}};var Af=Math.PI*2;function Cf({x:i,y:t},e,r,o,n){return{x:i*e+o,y:t*r+n}}function jM(i,t){let e=t===1.5707963267948966?.551915024494:t===-1.5707963267948966?-.551915024494:1.3333333333333333*Math.tan(t/4),r=Math.cos(i),o=Math.sin(i),n=Math.cos(i+t),a=Math.sin(i+t);return[{x:r-o*e,y:o+r*e},{x:n+a*e,y:a-n*e},{x:n,y:a}]}function Mx(i,t,e,r){let o=i*r-t*e<0?-1:1,n=Math.min(1,Math.max(-1,i*e+t*r));return o*Math.acos(n)}function UM(i,t,e,r,o,n,a,s,l,c){let u=Math.pow(o,2),p=Math.pow(n,2),d=Math.pow(a,2),f=Math.pow(s,2),h=u*p-u*f-p*d;h<0&&(h=0),h/=u*f+p*d,h=Math.sqrt(h)*(l===c?-1:1);let m=h*o/n*s,y=h*-n/o*a,b=m+(i+e)/2,v=y+(t+r)/2,w=(a-m)/o,O=(s-y)/n,S=(-a-m)/o,T=(-s-y)/n,M=Mx(1,0,w,O),g=Mx(w,O,S,T);return!c&&g>0&&(g-=Af),c&&g<0&&(g+=Af),{centerx:b,centery:v,ang1:M,ang2:g}}function Ix({px:i,py:t,cx:e,cy:r,rx:o,ry:n,largeArcFlag:a,sweepFlag:s}){let l=[];if(o===0||n===0)return[];let c=(i-e)/2,u=(t-r)/2;if(c===0&&u===0)return[];o=Math.abs(o),n=Math.abs(n);let p=Math.pow(c,2)/Math.pow(o,2)+Math.pow(u,2)/Math.pow(n,2);p>1&&(o*=Math.sqrt(p),n*=Math.sqrt(p));let d=UM(i,t,e,r,o,n,c,u,a,s),{ang1:f,ang2:h}=d,{centerx:m,centery:y}=d,b=Math.abs(h)/(Af/4);Math.abs(1-b)<1e-7&&(b=1);let v=Math.max(Math.ceil(b),1);h/=v;for(let w=0;w<v;w++)l.push(jM(f,h)),f+=h;return l.map(w=>{let{x:O,y:S}=Cf(w[0],o,n,m,y),{x:T,y:M}=Cf(w[1],o,n,m,y),{x:g,y:D}=Cf(w[2],o,n,m,y);return{x1:O,y1:S,x2:T,y2:M,x:g,y:D}})}var Mn=require("three");var $e;(function(i){i[i.ODD=0]="ODD",i[i.NONZERO=1]="NONZERO",i[i.POSITIVE=2]="POSITIVE",i[i.NEGATIVE=3]="NEGATIVE",i[i.ABS_GEQ_TWO=4]="ABS_GEQ_TWO"})($e||($e={}));var St;(function(i){i[i.POLYGONS=0]="POLYGONS",i[i.CONNECTED_POLYGONS=1]="CONNECTED_POLYGONS",i[i.BOUNDARY_CONTOURS=2]="BOUNDARY_CONTOURS"})(St||(St={}));function Oe(i,t){if(!i)throw t||"Assertion Failed!"}var we=function(){function i(){}return i.vertEq=function(t,e){return t.s===e.s&&t.t===e.t},i.vertLeq=function(t,e){return t.s<e.s||t.s===e.s&&t.t<=e.t},i.transLeq=function(t,e){return t.t<e.t||t.t===e.t&&t.s<=e.s},i.edgeGoesLeft=function(t){return i.vertLeq(t.Dst,t.Org)},i.edgeGoesRight=function(t){return i.vertLeq(t.Org,t.Dst)},i.vertL1dist=function(t,e){return Math.abs(t.s-e.s)+Math.abs(t.t-e.t)},i.edgeEval=function(t,e,r){Oe(i.vertLeq(t,e)&&i.vertLeq(e,r));var o=e.s-t.s,n=r.s-e.s;return o+n>0?o<n?e.t-t.t+(t.t-r.t)*(o/(o+n)):e.t-r.t+(r.t-t.t)*(n/(o+n)):0},i.edgeSign=function(t,e,r){Oe(i.vertLeq(t,e)&&i.vertLeq(e,r));var o=e.s-t.s,n=r.s-e.s;return o+n>0?(e.t-r.t)*o+(e.t-t.t)*n:0},i.transEval=function(t,e,r){Oe(i.transLeq(t,e)&&i.transLeq(e,r));var o=e.t-t.t,n=r.t-e.t;return o+n>0?o<n?e.s-t.s+(t.s-r.s)*(o/(o+n)):e.s-r.s+(r.s-t.s)*(n/(o+n)):0},i.transSign=function(t,e,r){Oe(i.transLeq(t,e)&&i.transLeq(e,r));var o=e.t-t.t,n=r.t-e.t;return o+n>0?(e.s-r.s)*o+(e.s-t.s)*n:0},i.vertCCW=function(t,e,r){return t.s*(e.t-r.t)+e.s*(r.t-t.t)+r.s*(t.t-e.t)>=0},i.interpolate=function(t,e,r,o){return t=t<0?0:t,r=r<0?0:r,t<=r?r===0?(e+o)/2:e+(o-e)*(t/(t+r)):o+(e-o)*(r/(t+r))},i.intersect=function(t,e,r,o,n){var a,s,l;i.vertLeq(t,e)||(l=t,t=e,e=l),i.vertLeq(r,o)||(l=r,r=o,o=l),i.vertLeq(t,r)||(l=t,t=r,r=l,l=e,e=o,o=l),i.vertLeq(r,e)?i.vertLeq(e,o)?(a=i.edgeEval(t,r,e),s=i.edgeEval(r,e,o),a+s<0&&(a=-a,s=-s),n.s=i.interpolate(a,r.s,s,e.s)):(a=i.edgeSign(t,r,e),s=-i.edgeSign(t,o,e),a+s<0&&(a=-a,s=-s),n.s=i.interpolate(a,r.s,s,o.s)):n.s=(r.s+e.s)/2,i.transLeq(t,e)||(l=t,t=e,e=l),i.transLeq(r,o)||(l=r,r=o,o=l),i.transLeq(t,r)||(l=t,t=r,r=l,l=e,e=o,o=l),i.transLeq(r,e)?i.transLeq(e,o)?(a=i.transEval(t,r,e),s=i.transEval(r,e,o),a+s<0&&(a=-a,s=-s),n.t=i.interpolate(a,r.t,s,e.t)):(a=i.transSign(t,r,e),s=-i.transSign(t,o,e),a+s<0&&(a=-a,s=-s),n.t=i.interpolate(a,r.t,s,o.t)):n.t=(r.t+e.t)/2},i}(),Tl=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}(),Gu=function(){function i(t){this.side=t,this.next=null,this.Org=null,this.Sym=null,this.Onext=null,this.Lnext=null,this.Lface=null,this.activeRegion=null,this.winding=0}return Object.defineProperty(i.prototype,"Rface",{get:function(){return this.Sym.Lface},set:function(t){this.Sym.Lface=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Dst",{get:function(){return this.Sym.Org},set:function(t){this.Sym.Org=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Oprev",{get:function(){return this.Sym.Lnext},set:function(t){this.Sym.Lnext=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Lprev",{get:function(){return this.Onext.Sym},set:function(t){this.Onext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Dprev",{get:function(){return this.Lnext.Sym},set:function(t){this.Lnext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Rprev",{get:function(){return this.Sym.Onext},set:function(t){this.Sym.Onext=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Dnext",{get:function(){return this.Sym.Onext.Sym},set:function(t){this.Sym.Onext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Rnext",{get:function(){return this.Sym.Lnext.Sym},set:function(t){this.Sym.Lnext.Sym=t},enumerable:!0,configurable:!0}),i}(),Wa=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}(),Ex=function(){function i(){var t=new Wa,e=new Tl,r=new Gu(0),o=new Gu(1);t.next=t.prev=t,t.anEdge=null,e.next=e.prev=e,r.next=r,r.Sym=o,o.next=o,o.Sym=r,this.vHead=t,this.fHead=e,this.eHead=r,this.eHeadSym=o}return i.prototype.makeEdge_=function(t){var e=new Gu(0),r=new Gu(1);t.Sym.side<t.side&&(t=t.Sym);var o=t.Sym.next;return r.next=o,o.Sym.next=e,e.next=t,t.Sym.next=r,e.Sym=r,e.Onext=e,e.Lnext=r,e.Org=null,e.Lface=null,e.winding=0,e.activeRegion=null,r.Sym=e,r.Onext=r,r.Lnext=e,r.Org=null,r.Lface=null,r.winding=0,r.activeRegion=null,e},i.prototype.splice_=function(t,e){var r=t.Onext,o=e.Onext;r.Sym.Lnext=e,o.Sym.Lnext=t,t.Onext=o,e.Onext=r},i.prototype.makeVertex_=function(t,e,r){var o=t;Oe(o,"Vertex can't be null!");var n=r.prev;o.prev=n,n.next=o,o.next=r,r.prev=o,o.anEdge=e;var a=e;do a.Org=o,a=a.Onext;while(a!==e)},i.prototype.makeFace_=function(t,e,r){var o=t;Oe(o,"Face can't be null");var n=r.prev;o.prev=n,n.next=o,o.next=r,r.prev=o,o.anEdge=e,o.trail=null,o.marked=!1,o.inside=r.inside;var a=e;do a.Lface=o,a=a.Lnext;while(a!==e)},i.prototype.killEdge_=function(t){t.Sym.side<t.side&&(t=t.Sym);var e=t.next,r=t.Sym.next;e.Sym.next=r,r.Sym.next=e},i.prototype.killVertex_=function(t,e){var r=t.anEdge,o=r;do o.Org=e,o=o.Onext;while(o!==r);var n=t.prev,a=t.next;a.prev=n,n.next=a},i.prototype.killFace_=function(t,e){var r=t.anEdge,o=r;do o.Lface=e,o=o.Lnext;while(o!==r);var n=t.prev,a=t.next;a.prev=n,n.next=a},i.prototype.makeEdge=function(){var t=new Wa,e=new Wa,r=new Tl,o=this.makeEdge_(this.eHead);return this.makeVertex_(t,o,this.vHead),this.makeVertex_(e,o.Sym,this.vHead),this.makeFace_(r,o,this.fHead),o},i.prototype.splice=function(t,e){var r=!1,o=!1;if(t!==e){if(e.Org!==t.Org&&(o=!0,this.killVertex_(e.Org,t.Org)),e.Lface!==t.Lface&&(r=!0,this.killFace_(e.Lface,t.Lface)),this.splice_(e,t),!o){var n=new Wa;this.makeVertex_(n,e,t.Org),t.Org.anEdge=t}if(!r){var a=new Tl;this.makeFace_(a,e,t.Lface),t.Lface.anEdge=t}}},i.prototype.delete=function(t){var e=t.Sym,r=!1;if(t.Lface!==t.Rface&&(r=!0,this.killFace_(t.Lface,t.Rface)),t.Onext===t)this.killVertex_(t.Org,null);else if(t.Rface.anEdge=t.Oprev,t.Org.anEdge=t.Onext,this.splice_(t,t.Oprev),!r){var o=new Tl;this.makeFace_(o,t,t.Lface)}e.Onext===e?(this.killVertex_(e.Org,null),this.killFace_(e.Lface,null)):(t.Lface.anEdge=e.Oprev,e.Org.anEdge=e.Onext,this.splice_(e,e.Oprev)),this.killEdge_(t)},i.prototype.addEdgeVertex=function(t){var e=this.makeEdge_(t),r=e.Sym;this.splice_(e,t.Lnext),e.Org=t.Dst;var o=new Wa;return this.makeVertex_(o,r,e.Org),e.Lface=r.Lface=t.Lface,e},i.prototype.splitEdge=function(t){var e=this.addEdgeVertex(t),r=e.Sym;return this.splice_(t.Sym,t.Sym.Oprev),this.splice_(t.Sym,r),t.Dst=r.Org,r.Dst.anEdge=r.Sym,r.Rface=t.Rface,r.winding=t.winding,r.Sym.winding=t.Sym.winding,r.idx=t.idx,r.Sym.idx=t.Sym.idx,r},i.prototype.connect=function(t,e){var r=!1,o=this.makeEdge_(t),n=o.Sym;if(e.Lface!==t.Lface&&(r=!0,this.killFace_(e.Lface,t.Lface)),this.splice_(o,t.Lnext),this.splice_(n,e),o.Org=t.Dst,n.Org=e.Org,o.Lface=n.Lface=t.Lface,t.Lface.anEdge=n,!r){var a=new Tl;this.makeFace_(a,o,t.Lface)}return o},i.prototype.zapFace=function(t){var e=t.anEdge,r,o,n,a,s;o=e.Lnext;do r=o,o=r.Lnext,r.Lface=null,r.Rface===null&&(r.Onext===r?this.killVertex_(r.Org,null):(r.Org.anEdge=r.Onext,this.splice_(r,r.Oprev)),n=r.Sym,n.Onext===n?this.killVertex_(n.Org,null):(n.Org.anEdge=n.Onext,this.splice_(n,n.Oprev)),this.killEdge_(r));while(r!=e);a=t.prev,s=t.next,s.prev=a,a.next=s},i.prototype.countFaceVerts_=function(t){var e=t.anEdge,r=0;do r++,e=e.Lnext;while(e!==t.anEdge);return r},i.prototype.mergeConvexFaces=function(t){var e,r,o,n,a,s,l;for(e=this.fHead.next;e!==this.fHead;e=e.next)if(!!e.inside)for(r=e.anEdge,a=r.Org;o=r.Lnext,n=r.Sym,n&&n.Lface&&n.Lface.inside&&(s=this.countFaceVerts_(e),l=this.countFaceVerts_(n.Lface),s+l-2<=t&&we.vertCCW(r.Lprev.Org,r.Org,n.Lnext.Lnext.Org)&&we.vertCCW(n.Lprev.Org,n.Org,r.Lnext.Lnext.Org)&&(o=n.Lnext,this.delete(n),r=null,n=null)),!(r&&r.Lnext.Org===a);)r=o;return!0},i.prototype.check=function(){var t=this.fHead,e=this.vHead,r=this.eHead,o,n,a,s,l,c;for(n=t,n=t;(o=n.next)!==t;n=o){Oe(o.prev===n),l=o.anEdge;do Oe(l.Sym!==l),Oe(l.Sym.Sym===l),Oe(l.Lnext.Onext.Sym===l),Oe(l.Onext.Sym.Lnext===l),Oe(l.Lface===o),l=l.Lnext;while(l!==o.anEdge)}for(Oe(o.prev===n&&o.anEdge===null),s=e,s=e;(a=s.next)!==e;s=a){Oe(a.prev===s),l=a.anEdge;do Oe(l.Sym!==l),Oe(l.Sym.Sym===l),Oe(l.Lnext.Onext.Sym===l),Oe(l.Onext.Sym.Lnext===l),Oe(l.Org===a),l=l.Onext;while(l!==a.anEdge)}for(Oe(a.prev===s&&a.anEdge===null),c=r,c=r;(l=c.next)!==r;c=l)Oe(l.Sym.next===c.Sym),Oe(l.Sym!==l),Oe(l.Sym.Sym===l),Oe(l.Org!==null),Oe(l.Dst!==null),Oe(l.Lnext.Onext.Sym===l),Oe(l.Onext.Sym.Lnext===l);Oe(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}(),Nx=function(){function i(){this.handle=null}return i}(),Dx=function(){function i(){this.key=null,this.node=0}return i}(),kM=function(){function i(t,e){this.leq=e,this.max=0,this.nodes=[],this.handles=[],this.initialized=!1,this.freeList=0,this.size=0,this.max=t,this.nodes=[],this.handles=[];for(var r=0;r<t+1;r++)this.nodes[r]=new Nx,this.handles[r]=new Dx;this.initialized=!1,this.nodes[1].handle=1,this.handles[1].key=null}return i.prototype.floatDown_=function(t){var e=this.nodes,r=this.handles,o,n,a;for(o=e[t].handle;;){if(a=t<<1,a<this.size&&this.leq(r[e[a+1].handle].key,r[e[a].handle].key)&&++a,Oe(a<=this.max),n=e[a].handle,a>this.size||this.leq(r[o].key,r[n].key)){e[t].handle=o,r[o].node=t;break}e[t].handle=n,r[n].node=t,t=a}},i.prototype.floatUp_=function(t){var e=this.nodes,r=this.handles,o,n,a;for(o=e[t].handle;;){if(a=t>>1,n=e[a].handle,a===0||this.leq(r[n].key,r[o].key)){e[t].handle=o,r[o].node=t;break}e[t].handle=n,r[n].node=t,t=a}},i.prototype.init=function(){for(var t=this.size;t>=1;--t)this.floatDown_(t);this.initialized=!0},i.prototype.min=function(){return this.handles[this.nodes[1].handle].key},i.prototype.insert=function(t){var e,r;if(e=++this.size,e*2>this.max){this.max*=2;var o,n;for(n=this.nodes.length,this.nodes.length=this.max+1,o=n;o<this.nodes.length;o++)this.nodes[o]=new Nx;for(n=this.handles.length,this.handles.length=this.max+1,o=n;o<this.handles.length;o++)this.handles[o]=new Dx}return this.freeList===0?r=e:(r=this.freeList,this.freeList=this.handles[r].node),this.nodes[e].handle=r,this.handles[r].node=e,this.handles[r].key=t,this.initialized&&this.floatUp_(e),r},i.prototype.extractMin=function(){var t=this.nodes,e=this.handles,r=t[1].handle,o=e[r].key;return this.size>0&&(t[1].handle=t[this.size].handle,e[t[1].handle].node=1,e[r].key=null,e[r].node=this.freeList,this.freeList=r,--this.size,this.size>0&&this.floatDown_(1)),o},i.prototype.delete=function(t){var e=this.nodes,r=this.handles,o;Oe(t>=1&&t<=this.max&&r[t].key!==null),o=r[t].node,e[o].handle=e[this.size].handle,r[e[o].handle].node=o,--this.size,o<=this.size&&(o<=1||this.leq(r[e[o>>1].handle].key,r[e[o].handle].key)?this.floatDown_(o):this.floatUp_(o)),r[t].key=null,r[t].node=this.freeList,this.freeList=t},i}(),Mf=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}(),_x=function(){function i(){this.key=null,this.next=null,this.prev=null}return i}(),HM=function(){function i(t,e){this.frame=t,this.leq=e,this.head=new _x,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(t){return this.insertBefore(this.head,t)},i.prototype.search=function(t){var e=this.head;do e=e.next;while(e.key!==null&&!this.leq(this.frame,t,e.key));return e},i.prototype.insertBefore=function(t,e){do t=t.prev;while(t.key!==null&&!this.leq(this.frame,t.key,e));var r=new _x;return r.key=e,r.next=t.next,t.next.prev=r,r.prev=t,t.next=r,r},i.prototype.delete=function(t){t.next.prev=t.prev,t.prev.next=t.next},i}(),WM=function(){function i(){}return i.regionBelow=function(t){return t.nodeUp.prev.key},i.regionAbove=function(t){return t.nodeUp.next.key},i.debugEvent=function(t){},i.addWinding=function(t,e){t.winding+=e.winding,t.Sym.winding+=e.Sym.winding},i.edgeLeq=function(t,e,r){var o=t.event,n=e.eUp,a=r.eUp;if(n.Dst===o)return a.Dst===o?we.vertLeq(n.Org,a.Org)?we.edgeSign(a.Dst,n.Org,a.Org)<=0:we.edgeSign(n.Dst,a.Org,n.Org)>=0:we.edgeSign(a.Dst,o,a.Org)<=0;if(a.Dst===o)return we.edgeSign(n.Dst,o,n.Org)>=0;var s=we.edgeEval(n.Dst,o,n.Org),l=we.edgeEval(a.Dst,o,a.Org);return s>=l},i.deleteRegion=function(t,e){e.fixUpperEdge&&Oe(e.eUp.winding===0),e.eUp.activeRegion=null,t.dict.delete(e.nodeUp)},i.fixUpperEdge=function(t,e,r){Oe(e.fixUpperEdge),t.mesh.delete(e.eUp),e.fixUpperEdge=!1,e.eUp=r,r.activeRegion=e},i.topLeftRegion=function(t,e){var r=e.eUp.Org,o;do e=i.regionAbove(e);while(e.eUp.Org===r);if(e.fixUpperEdge){if(o=t.mesh.connect(i.regionBelow(e).eUp.Sym,e.eUp.Lnext),o===null)return null;i.fixUpperEdge(t,e,o),e=i.regionAbove(e)}return e},i.topRightRegion=function(t){var e=t.eUp.Dst;do t=i.regionAbove(t);while(t.eUp.Dst===e);return t},i.addRegionBelow=function(t,e,r){var o=new Mf;return o.eUp=r,o.nodeUp=t.dict.insertBefore(e.nodeUp,o),o.fixUpperEdge=!1,o.sentinel=!1,o.dirty=!1,r.activeRegion=o,o},i.isWindingInside=function(t,e){switch(t.windingRule){case $e.ODD:return(e&1)!==0;case $e.NONZERO:return e!==0;case $e.POSITIVE:return e>0;case $e.NEGATIVE:return e<0;case $e.ABS_GEQ_TWO:return e>=2||e<=-2}throw new Error("Invalid winding rulle")},i.computeWinding=function(t,e){e.windingNumber=i.regionAbove(e).windingNumber+e.eUp.winding,e.inside=i.isWindingInside(t,e.windingNumber)},i.finishRegion=function(t,e){var r=e.eUp,o=r.Lface;o.inside=e.inside,o.anEdge=r,i.deleteRegion(t,e)},i.finishLeftRegions=function(t,e,r){for(var o,n=null,a=e,s=e.eUp;a!==r;){if(a.fixUpperEdge=!1,n=i.regionBelow(a),o=n.eUp,o.Org!=s.Org){if(!n.fixUpperEdge){i.finishRegion(t,a);break}o=t.mesh.connect(s.Lprev,o.Sym),i.fixUpperEdge(t,n,o)}s.Onext!==o&&(t.mesh.splice(o.Oprev,o),t.mesh.splice(s,o)),i.finishRegion(t,a),s=n.eUp,a=n}return s},i.addRightEdges=function(t,e,r,o,n,a){var s,l,c,u,p=!0;c=r;do Oe(we.vertLeq(c.Org,c.Dst)),i.addRegionBelow(t,e,c.Sym),c=c.Onext;while(c!==o);for(n===null&&(n=i.regionBelow(e).eUp.Rprev),l=e,u=n;s=i.regionBelow(l),c=s.eUp.Sym,c.Org===u.Org;)c.Onext!==u&&(t.mesh.splice(c.Oprev,c),t.mesh.splice(u.Oprev,c)),s.windingNumber=l.windingNumber-c.winding,s.inside=i.isWindingInside(t,s.windingNumber),l.dirty=!0,!p&&i.checkForRightSplice(t,l)&&(i.addWinding(c,u),i.deleteRegion(t,l),t.mesh.delete(u)),p=!1,l=s,u=c;l.dirty=!0,Oe(l.windingNumber-c.winding===s.windingNumber),a&&i.walkDirtyRegions(t,l)},i.spliceMergeVertices=function(t,e,r){t.mesh.splice(e,r)},i.vertexWeights=function(t,e,r){var o=we.vertL1dist(e,t),n=we.vertL1dist(r,t),a=.5*n/(o+n),s=.5*o/(o+n);t.coords[0]+=a*e.coords[0]+s*r.coords[0],t.coords[1]+=a*e.coords[1]+s*r.coords[1],t.coords[2]+=a*e.coords[2]+s*r.coords[2]},i.getIntersectData=function(t,e,r,o,n,a){e.coords[0]=e.coords[1]=e.coords[2]=0,e.idx=-1,i.vertexWeights(e,r,o),i.vertexWeights(e,n,a)},i.checkForRightSplice=function(t,e){var r=i.regionBelow(e),o=e.eUp,n=r.eUp;if(we.vertLeq(o.Org,n.Org)){if(we.edgeSign(n.Dst,o.Org,n.Org)>0)return!1;we.vertEq(o.Org,n.Org)?o.Org!==n.Org&&(t.pq.delete(o.Org.pqHandle),i.spliceMergeVertices(t,n.Oprev,o)):(t.mesh.splitEdge(n.Sym),t.mesh.splice(o,n.Oprev),e.dirty=r.dirty=!0)}else{if(we.edgeSign(o.Dst,n.Org,o.Org)<0)return!1;i.regionAbove(e).dirty=e.dirty=!0,t.mesh.splitEdge(o.Sym),t.mesh.splice(n.Oprev,o)}return!0},i.checkForLeftSplice=function(t,e){var r=i.regionBelow(e),o=e.eUp,n=r.eUp,a;if(Oe(!we.vertEq(o.Dst,n.Dst)),we.vertLeq(o.Dst,n.Dst)){if(we.edgeSign(o.Dst,n.Dst,o.Org)<0)return!1;i.regionAbove(e).dirty=e.dirty=!0,a=t.mesh.splitEdge(o),t.mesh.splice(n.Sym,a),a.Lface.inside=e.inside}else{if(we.edgeSign(n.Dst,o.Dst,n.Org)>0)return!1;e.dirty=r.dirty=!0,a=t.mesh.splitEdge(n),t.mesh.splice(o.Lnext,n.Sym),a.Rface.inside=e.inside}return!0},i.checkForIntersect=function(t,e){var r=i.regionBelow(e),o=e.eUp,n=r.eUp,a=o.Org,s=n.Org,l=o.Dst,c=n.Dst,u,p,d=new Wa,f,h;if(Oe(!we.vertEq(c,l)),Oe(we.edgeSign(l,t.event,a)<=0),Oe(we.edgeSign(c,t.event,s)>=0),Oe(a!==t.event&&s!==t.event),Oe(!e.fixUpperEdge&&!r.fixUpperEdge),a===s||(u=Math.min(a.t,l.t),p=Math.max(s.t,c.t),u>p))return!1;if(we.vertLeq(a,s)){if(we.edgeSign(c,a,s)>0)return!1}else if(we.edgeSign(l,s,a)<0)return!1;return i.debugEvent(t),we.intersect(l,a,c,s,d),Oe(Math.min(a.t,l.t)<=d.t),Oe(d.t<=Math.max(s.t,c.t)),Oe(Math.min(c.s,l.s)<=d.s),Oe(d.s<=Math.max(s.s,a.s)),we.vertLeq(d,t.event)&&(d.s=t.event.s,d.t=t.event.t),f=we.vertLeq(a,s)?a:s,we.vertLeq(f,d)&&(d.s=f.s,d.t=f.t),we.vertEq(d,a)||we.vertEq(d,s)?(i.checkForRightSplice(t,e),!1):!we.vertEq(l,t.event)&&we.edgeSign(l,t.event,d)>=0||!we.vertEq(c,t.event)&&we.edgeSign(c,t.event,d)<=0?c===t.event?(t.mesh.splitEdge(o.Sym),t.mesh.splice(n.Sym,o),e=i.topLeftRegion(t,e),o=i.regionBelow(e).eUp,i.finishLeftRegions(t,i.regionBelow(e),r),i.addRightEdges(t,e,o.Oprev,o,o,!0),!0):l===t.event?(t.mesh.splitEdge(n.Sym),t.mesh.splice(o.Lnext,n.Oprev),r=e,e=i.topRightRegion(e),h=i.regionBelow(e).eUp.Rprev,r.eUp=n.Oprev,n=i.finishLeftRegions(t,r,null),i.addRightEdges(t,e,n.Onext,o.Rprev,h,!0),!0):(we.edgeSign(l,t.event,d)>=0&&(i.regionAbove(e).dirty=e.dirty=!0,t.mesh.splitEdge(o.Sym),o.Org.s=t.event.s,o.Org.t=t.event.t),we.edgeSign(c,t.event,d)<=0&&(e.dirty=r.dirty=!0,t.mesh.splitEdge(n.Sym),n.Org.s=t.event.s,n.Org.t=t.event.t),!1):(t.mesh.splitEdge(o.Sym),t.mesh.splitEdge(n.Sym),t.mesh.splice(n.Oprev,o),o.Org.s=d.s,o.Org.t=d.t,o.Org.pqHandle=t.pq.insert(o.Org),i.getIntersectData(t,o.Org,a,l,s,c),i.regionAbove(e).dirty=e.dirty=r.dirty=!0,!1)},i.walkDirtyRegions=function(t,e){for(var r=i.regionBelow(e),o,n;;){for(;r.dirty;)e=r,r=i.regionBelow(r);if(!e.dirty&&(r=e,e=i.regionAbove(e),e===null||!e.dirty))return;if(e.dirty=!1,o=e.eUp,n=r.eUp,o.Dst!==n.Dst&&i.checkForLeftSplice(t,e)&&(r.fixUpperEdge?(i.deleteRegion(t,r),t.mesh.delete(n),r=i.regionBelow(e),n=r.eUp):e.fixUpperEdge&&(i.deleteRegion(t,e),t.mesh.delete(o),e=i.regionAbove(r),o=e.eUp)),o.Org!==n.Org)if(o.Dst!==n.Dst&&!e.fixUpperEdge&&!r.fixUpperEdge&&(o.Dst===t.event||n.Dst===t.event)){if(i.checkForIntersect(t,e))return}else i.checkForRightSplice(t,e);o.Org===n.Org&&o.Dst===n.Dst&&(i.addWinding(n,o),i.deleteRegion(t,e),t.mesh.delete(o),e=i.regionAbove(r))}},i.connectRightVertex=function(t,e,r){var o,n=r.Onext,a=i.regionBelow(e),s=e.eUp,l=a.eUp,c=!1;if(s.Dst!==l.Dst&&i.checkForIntersect(t,e),we.vertEq(s.Org,t.event)&&(t.mesh.splice(n.Oprev,s),e=i.topLeftRegion(t,e),n=i.regionBelow(e).eUp,i.finishLeftRegions(t,i.regionBelow(e),a),c=!0),we.vertEq(l.Org,t.event)&&(t.mesh.splice(r,l.Oprev),r=i.finishLeftRegions(t,a,null),c=!0),c){i.addRightEdges(t,e,r.Onext,n,n,!0);return}we.vertLeq(l.Org,s.Org)?o=l.Oprev:o=s,o=t.mesh.connect(r.Lprev,o),i.addRightEdges(t,e,o,o.Onext,o.Onext,!1),o.Sym.activeRegion.fixUpperEdge=!0,i.walkDirtyRegions(t,e)},i.connectLeftDegenerate=function(t,e,r){var o,n,a,s,l;if(o=e.eUp,we.vertEq(o.Org,r)){Oe(!1),i.spliceMergeVertices(t,o,r.anEdge);return}if(!we.vertEq(o.Dst,r)){t.mesh.splitEdge(o.Sym),e.fixUpperEdge&&(t.mesh.delete(o.Onext),e.fixUpperEdge=!1),t.mesh.splice(r.anEdge,o),i.sweepEvent(t,r);return}Oe(!1),e=i.topRightRegion(e),l=i.regionBelow(e),a=l.eUp.Sym,n=s=a.Onext,l.fixUpperEdge&&(Oe(n!==a),i.deleteRegion(t,l),t.mesh.delete(a),a=n.Oprev),t.mesh.splice(r.anEdge,a),we.edgeGoesLeft(n)||(n=null),i.addRightEdges(t,e,a.Onext,s,n,!0)},i.connectLeftVertex=function(t,e){var r,o,n,a,s,l,c=new Mf;if(c.eUp=e.anEdge.Sym,r=t.dict.search(c).key,o=i.regionBelow(r),!!o){if(a=r.eUp,s=o.eUp,we.edgeSign(a.Dst,e,a.Org)===0){i.connectLeftDegenerate(t,r,e);return}if(n=we.vertLeq(s.Dst,a.Dst)?r:o,r.inside||n.fixUpperEdge){if(n===r)l=t.mesh.connect(e.anEdge.Sym,a.Lnext);else{var u=t.mesh.connect(s.Dnext,e.anEdge);l=u.Sym}n.fixUpperEdge?i.fixUpperEdge(t,n,l):i.computeWinding(t,i.addRegionBelow(t,r,l)),i.sweepEvent(t,e)}else i.addRightEdges(t,r,e.anEdge,e.anEdge,null,!0)}},i.sweepEvent=function(t,e){t.event=e,i.debugEvent(t);for(var r=e.anEdge;r.activeRegion===null;)if(r=r.Onext,r===e.anEdge){i.connectLeftVertex(t,e);return}var o=i.topLeftRegion(t,r.activeRegion);Oe(o!==null);var n=i.regionBelow(o),a=n.eUp,s=i.finishLeftRegions(t,n,null);s.Onext===a?i.connectRightVertex(t,o,s):i.addRightEdges(t,o,s.Onext,a,a,!0)},i.addSentinel=function(t,e,r,o){var n=new Mf,a=t.mesh.makeEdge();a.Org.s=r,a.Org.t=o,a.Dst.s=e,a.Dst.t=o,t.event=a.Dst,n.eUp=a,n.windingNumber=0,n.inside=!1,n.fixUpperEdge=!1,n.sentinel=!0,n.dirty=!1,n.nodeUp=t.dict.insert(n)},i.initEdgeDict=function(t){t.dict=new HM(t,i.edgeLeq);var e=t.bmax[0]-t.bmin[0],r=t.bmax[1]-t.bmin[1],o=t.bmin[0]-e,n=t.bmax[0]+e,a=t.bmin[1]-r,s=t.bmax[1]+r;i.addSentinel(t,o,n,a),i.addSentinel(t,o,n,s)},i.doneEdgeDict=function(t){for(var e,r=0;(e=t.dict.min().key)!==null;)e.sentinel||(Oe(e.fixUpperEdge),Oe(++r===1)),Oe(e.windingNumber===0),i.deleteRegion(t,e)},i.removeDegenerateEdges=function(t){var e,r,o,n=t.mesh.eHead;for(e=n.next;e!==n;e=r)r=e.next,o=e.Lnext,we.vertEq(e.Org,e.Dst)&&e.Lnext.Lnext!==e&&(i.spliceMergeVertices(t,o,e),t.mesh.delete(e),e=o,o=e.Lnext),o.Lnext===e&&(o!==e&&((o===r||o===r.Sym)&&(r=r.next),t.mesh.delete(o)),(e===r||e===r.Sym)&&(r=r.next),t.mesh.delete(e))},i.initPriorityQ=function(t){var e,r,o,n=0;for(o=t.mesh.vHead,r=o.next;r!==o;r=r.next)n++;for(n+=8,e=t.pq=new kM(n,we.vertLeq),o=t.mesh.vHead,r=o.next;r!==o;r=r.next)r.pqHandle=e.insert(r);return r!==o?!1:(e.init(),!0)},i.donePriorityQ=function(t){t.pq=null},i.removeDegenerateFaces=function(t,e){var r,o,n;for(r=e.fHead.next;r!==e.fHead;r=o)o=r.next,n=r.anEdge,Oe(n.Lnext!==n),n.Lnext.Lnext===n&&(i.addWinding(n.Onext,n),t.mesh.delete(n));return!0},i.computeInterior=function(t,e){e===void 0&&(e=!0);var r,o;if(i.removeDegenerateEdges(t),!i.initPriorityQ(t))return!1;for(i.initEdgeDict(t);(r=t.pq.extractMin())!==null;){for(;o=t.pq.min(),!(o===null||!we.vertEq(o,r));)o=t.pq.extractMin(),i.spliceMergeVertices(t,r.anEdge,o.anEdge);i.sweepEvent(t,r)}return t.event=t.dict.min().key.eUp.Org,i.debugEvent(t),i.doneEdgeDict(t),i.donePriorityQ(t),i.removeDegenerateFaces(t,t.mesh)?(e&&t.mesh.check(),!0):!1},i}(),qM=function(){function i(){this.mesh=new Ex,this.normal=[0,0,0],this.sUnit=[0,0,0],this.tUnit=[0,0,0],this.bmin=[0,0],this.bmax=[0,0],this.windingRule=$e.ODD,this.dict=null,this.pq=null,this.event=null,this.vertexIndexCounter=0,this.vertices=[],this.vertexIndices=[],this.vertexCount=0,this.elements=[],this.elementCount=0}return i.prototype.dot_=function(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]},i.prototype.normalize_=function(t){var e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2];if(!e)throw"Zero-size vector!";e=Math.sqrt(e),t[0]/=e,t[1]/=e,t[2]/=e},i.prototype.longAxis_=function(t){var e=0;return Math.abs(t[1])>Math.abs(t[0])&&(e=1),Math.abs(t[2])>Math.abs(t[e])&&(e=2),e},i.prototype.computeNormal_=function(t){var e,r,o,n,a,s,l=[0,0,0],c=[0,0,0],u=[0,0,0],p=[0,0,0],d=[0,0,0],f=[null,null,null],h=[null,null,null],m=this.mesh.vHead;e=m.next;for(var y=0;y<3;++y)n=e.coords[y],c[y]=n,h[y]=e,l[y]=n,f[y]=e;for(e=m.next;e!==m;e=e.next)for(var b=0;b<3;++b)n=e.coords[b],n<c[b]&&(c[b]=n,h[b]=e),n>l[b]&&(l[b]=n,f[b]=e);var v=0;if(l[1]-c[1]>l[0]-c[0]&&(v=1),l[2]-c[2]>l[v]-c[v]&&(v=2),c[v]>=l[v]){t[0]=0,t[1]=0,t[2]=1;return}for(s=0,r=h[v],o=f[v],u[0]=r.coords[0]-o.coords[0],u[1]=r.coords[1]-o.coords[1],u[2]=r.coords[2]-o.coords[2],e=m.next;e!==m;e=e.next)p[0]=e.coords[0]-o.coords[0],p[1]=e.coords[1]-o.coords[1],p[2]=e.coords[2]-o.coords[2],d[0]=u[1]*p[2]-u[2]*p[1],d[1]=u[2]*p[0]-u[0]*p[2],d[2]=u[0]*p[1]-u[1]*p[0],a=d[0]*d[0]+d[1]*d[1]+d[2]*d[2],a>s&&(s=a,t[0]=d[0],t[1]=d[1],t[2]=d[2]);s<=0&&(t[0]=t[1]=t[2]=0,t[this.longAxis_(u)]=1)},i.prototype.checkOrientation_=function(){for(var t=this.mesh.fHead,e,r=this.mesh.vHead,o,n=0,a=t.next;a!==t;a=a.next)if(o=a.anEdge,!(o.winding<=0))do n+=(o.Org.s-o.Dst.s)*(o.Org.t+o.Dst.t),o=o.Lnext;while(o!==a.anEdge);if(n<0){for(e=r.next;e!==r;e=e.next)e.t=-e.t;this.tUnit[0]=-this.tUnit[0],this.tUnit[1]=-this.tUnit[1],this.tUnit[2]=-this.tUnit[2]}},i.prototype.projectPolygon_=function(){var t=this.mesh.vHead,e=[0,0,0],r,o,n=!1;e[0]=this.normal[0],e[1]=this.normal[1],e[2]=this.normal[2],!e[0]&&!e[1]&&!e[2]&&(this.computeNormal_(e),n=!0),r=this.sUnit,o=this.tUnit;var a=this.longAxis_(e);r[a]=0,r[(a+1)%3]=1,r[(a+2)%3]=0,o[a]=0,o[(a+1)%3]=0,o[(a+2)%3]=e[a]>0?1:-1;for(var s=t.next;s!==t;s=s.next)s.s=this.dot_(s.coords,r),s.t=this.dot_(s.coords,o);n&&this.checkOrientation_();for(var l=!0,c=t.next;c!==t;c=c.next)l?(this.bmin[0]=this.bmax[0]=c.s,this.bmin[1]=this.bmax[1]=c.t,l=!1):(c.s<this.bmin[0]&&(this.bmin[0]=c.s),c.s>this.bmax[0]&&(this.bmax[0]=c.s),c.t<this.bmin[1]&&(this.bmin[1]=c.t),c.t>this.bmax[1]&&(this.bmax[1]=c.t))},i.prototype.addWinding_=function(t,e){t.winding+=e.winding,t.Sym.winding+=e.Sym.winding},i.prototype.tessellateMonoRegion_=function(t,e){var r,o;if(r=e.anEdge,!(r.Lnext!==r&&r.Lnext.Lnext!==r))throw"Mono region invalid";for(;we.vertLeq(r.Dst,r.Org);r=r.Lprev);for(;we.vertLeq(r.Org,r.Dst);r=r.Lnext);o=r.Lprev;for(var n=void 0;r.Lnext!==o;)if(we.vertLeq(r.Dst,o.Org)){for(;o.Lnext!==r&&(we.edgeGoesLeft(o.Lnext)||we.edgeSign(o.Org,o.Dst,o.Lnext.Dst)<=0);)n=t.connect(o.Lnext,o),o=n.Sym;o=o.Lprev}else{for(;o.Lnext!==r&&(we.edgeGoesRight(r.Lprev)||we.edgeSign(r.Dst,r.Org,r.Lprev.Org)>=0);)n=t.connect(r,r.Lprev),r=n.Sym;r=r.Lnext}if(o.Lnext===r)throw"Mono region invalid";for(;o.Lnext.Lnext!==r;)n=t.connect(o.Lnext,o),o=n.Sym;return!0},i.prototype.tessellateInterior_=function(t){for(var e,r=t.fHead.next;r!==t.fHead;r=e)if(e=r.next,r.inside&&!this.tessellateMonoRegion_(t,r))return!1;return!0},i.prototype.discardExterior_=function(t){for(var e,r=t.fHead.next;r!==t.fHead;r=e)e=r.next,r.inside||t.zapFace(r)},i.prototype.setWindingNumber_=function(t,e,r){for(var o,n=t.eHead.next;n!==t.eHead;n=o)o=n.next,n.Rface.inside!==n.Lface.inside?n.winding=n.Lface.inside?e:-e:r?t.delete(n):n.winding=0},i.prototype.getNeighbourFace_=function(t){return!t.Rface||!t.Rface.inside?-1:t.Rface.n},i.prototype.outputPolymesh_=function(t,e,r,o){var n,a=0,s=0,l;r>3&&t.mergeConvexFaces(r);for(var c=t.vHead.next;c!==t.vHead;c=c.next)c.n=-1;for(var u=t.fHead.next;u!==t.fHead;u=u.next)if(u.n=-1,!!u.inside){n=u.anEdge,l=0;do{var c=n.Org;c.n===-1&&(c.n=s,s++),l++,n=n.Lnext}while(n!==u.anEdge);if(l>r)throw"Face vertex greater that support polygon";u.n=a,++a}this.elementCount=a,e===St.CONNECTED_POLYGONS&&(a*=2),this.elements=[],this.elements.length=a*r,this.vertexCount=s,this.vertices=[],this.vertices.length=s*o,this.vertexIndices=[],this.vertexIndices.length=s;for(var c=t.vHead.next;c!==t.vHead;c=c.next)if(c.n!==-1){var p=c.n*o;this.vertices[p+0]=c.coords[0],this.vertices[p+1]=c.coords[1],o>2&&(this.vertices[p+2]=c.coords[2]),this.vertexIndices[c.n]=c.idx}for(var d=0,u=t.fHead.next;u!==t.fHead;u=u.next)if(!!u.inside){n=u.anEdge,l=0;do{var c=n.Org;this.elements[d++]=c.n,l++,n=n.Lnext}while(n!==u.anEdge);for(var f=l;f<r;++f)this.elements[d++]=-1;if(e===St.CONNECTED_POLYGONS){n=u.anEdge;do this.elements[d++]=this.getNeighbourFace_(n),n=n.Lnext;while(n!==u.anEdge);for(var h=l;h<r;++h)this.elements[d++]=-1}}},i.prototype.outputContours_=function(t,e){var r,o,n=0,a=0;this.vertexCount=0,this.elementCount=0;for(var s=t.fHead.next;s!==t.fHead;s=s.next)if(!!s.inside){o=r=s.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*e,this.vertexIndices=[],this.vertexIndices.length=this.vertexCount;var l=0,c=0,u=0;n=0;for(var s=t.fHead.next;s!==t.fHead;s=s.next)if(!!s.inside){a=0,o=r=s.anEdge;do this.vertices[l++]=r.Org.coords[0],this.vertices[l++]=r.Org.coords[1],e>2&&(this.vertices[l++]=r.Org.coords[2]),this.vertexIndices[c++]=this.vertexIdCallback?this.vertexIdCallback(r):r.Org.idx,a++,r=r.Lnext;while(r!==o);this.elements[u++]=n,this.elements[u++]=a,n+=a}},i.prototype.addContour=function(t,e){this.mesh===null&&(this.mesh=new Ex),t<2&&(t=2),t>3&&(t=3);for(var r=null,o=0;o<e.length;o+=t)r===null?(r=this.mesh.makeEdge(),this.mesh.splice(r,r.Sym)):(this.mesh.splitEdge(r),r=r.Lnext),r.Org.coords[0]=e[o+0],r.Org.coords[1]=e[o+1],t>2?r.Org.coords[2]=e[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(t,e,r,o,n,a){if(t===void 0&&(t=$e.ODD),e===void 0&&(e=St.POLYGONS),a===void 0&&(a=!0),this.vertices=[],this.elements=[],this.vertexIndices=[],this.vertexIndexCounter=0,n&&(this.normal[0]=n[0],this.normal[1]=n[1],this.normal[2]=n[2]),this.windingRule=t,o<2&&(o=2),o>3&&(o=3),!this.mesh)return!1;this.projectPolygon_(),WM.computeInterior(this,a);var s=this.mesh;return e===St.BOUNDARY_CONTOURS?this.setWindingNumber_(s,1,!0):this.tessellateInterior_(s),a&&s.check(),e===St.BOUNDARY_CONTOURS?this.outputContours_(s,o):this.outputPolymesh_(s,e,r,o),!0},i}();function co(i){var t=i.windingRule,e=t===void 0?$e.ODD:t,r=i.elementType,o=r===void 0?St.POLYGONS:r,n=i.polySize,a=n===void 0?3:n,s=i.vertexSize,l=s===void 0?2:s,c=i.normal,u=c===void 0?[0,0,1]:c,p=i.contours,d=p===void 0?[]:p,f=i.strict,h=f===void 0?!0:f,m=i.debug,y=m===void 0?!1:m;if(!d&&h)throw new Error("Contours can't be empty");if(!!d){var b=new qM;i.edgeCreateCallback&&(b.edgeCreateCallback=i.edgeCreateCallback),i.vertexIdCallback&&(b.vertexIdCallback=i.vertexIdCallback);for(var v=0;v<d.length;v++)b.addContour(l||2,d[v]);return b.tesselate(e,o,a,l,u,h),{vertices:b.vertices,vertexIndices:b.vertexIndices,vertexCount:b.vertexCount,elements:b.elements,elementCount:b.elementCount,mesh:y?b.mesh:void 0}}}var S5=$e.ODD,w5=$e.NONZERO,P5=$e.POSITIVE,O5=$e.NEGATIVE,T5=$e.ABS_GEQ_TWO,C5=St.POLYGONS,A5=St.CONNECTED_POLYGONS,M5=St.BOUNDARY_CONTOURS;var uo=require("three");var Fu=class{constructor(t=256,e=!1){this.capacity=t,this.size=0,this.debug=e,this.debug&&console.log(`allocating with cap ${t}`);let r=t*Fu.eSize;this.buffer=new ArrayBuffer(r);let o=Float32Array.BYTES_PER_ELEMENT,n=0;this.positions=new Float32Array(this.buffer,n*o,3*t),n+=3*t,this.normals=new Float32Array(this.buffer,n*o,3*t),n+=3*t,this.uvs=new Float32Array(this.buffer,n*o,2*t)}realloc(t,e=!1){if(t<this.size)throw Error("cannot shrink buffer");if(t<=this.capacity&&!e)return;this.debug&&console.log(`resizing from ${this.capacity} \u2192 ${t}`);let r=t*Fu.eSize,o=new ArrayBuffer(r),n=Float32Array.BYTES_PER_ELEMENT,a=0,s=new Float32Array(o,a*n,3*t);a+=3*t;let l=new Float32Array(o,a*n,3*t);a+=3*t;let c=new Float32Array(o,a*n,2*t);e?(s.set(this.positions.subarray(0,this.size*3)),l.set(this.normals.subarray(0,this.size*3)),c.set(this.uvs.subarray(0,this.size*2))):(s.set(this.positions),l.set(this.normals),c.set(this.uvs)),this.buffer=o,this.positions=s,this.normals=l,this.uvs=c,this.capacity=t}get(t=1){let e=this.size+t;if(e>this.capacity){let o=this.capacity;for(;e>o;)o*=2;this.realloc(o)}let r=this.size;return this.size=e,r}reserve(t){let e=this.size+t;e>this.capacity&&this.realloc(e)}shrink(){this.debug&&console.log(`shrinking ${this.capacity} \u2192 ${this.size}`),this.realloc(this.size,!0)}},Cl=Fu;Cl.eSize=(3+3+2)*Float32Array.BYTES_PER_ELEMENT;var Al=class{constructor(t=[],e=(r,o)=>r<o?-1:r>o?1:0){if(this.data=t,this.length=this.data.length,this.compare=e,this.length>0)for(let r=(this.length>>1)-1;r>=0;r--)this._down(r)}push(t){this.data.push(t),this._up(this.length++)}pop(){if(this.length===0)return;let t=this.data[0],e=this.data.pop();return--this.length>0&&(this.data[0]=e,this._down(0)),t}peek(){return this.data[0]}_up(t){let{data:e,compare:r}=this,o=e[t];for(;t>0;){let n=t-1>>1,a=e[n];if(r(o,a)>=0)break;e[t]=a,t=n}e[t]=o}_down(t){let{data:e,compare:r}=this,o=this.length>>1,n=e[t];for(;t<o;){let a=(t<<1)+1,s=a+1;if(s<this.length&&r(e[s],e[a])<0&&(a=s),r(e[a],n)>=0)break;e[t]=e[a],t=a}e[t]=n}};function If(i,t,e=1,r=!1){let o=1/0,n=1/0,a=-1/0,s=-1/0;for(let[v,w]of i[0])v<o&&(o=v),w<n&&(n=w),v>a&&(a=v),w>s&&(s=w);let l=a-o,c=s-n,u=Math.max(e,Math.min(l,c));if(u===e){let v=[o,n];return v.distance=0,v.distance}let p=new Al([],(v,w)=>w.max-v.max),d=XM(i),f=new ju(o+l/2,n+c/2,0,i);f.d>d.d&&(d=f);let h=2;function m(v,w,O){let S=new ju(v,w,O,i);if(h++,S.max>d.d+e&&p.push(S),S.d>d.d&&(d=S,r&&console.log(`found best ${Math.round(1e4*S.d)/1e4} after ${h} probes`),d.d>t))return t}let y=u/2;for(let v=o;v<a;v+=u)for(let w=n;w<s;w+=u)m(v+y,w+y,y);for(;p.length;){let{max:v,x:w,y:O,h:S}=p.pop();if(v-d.d<=e)break;y=S/2,m(w-y,O-y,y),m(w+y,O-y,y),m(w-y,O+y,y),m(w+y,O+y,y)}r&&console.log(`num probes: ${h}
3
- best distance: ${d.d}`);let b=[d.x,d.y];return b.distance=d.d,b.distance}function ju(i,t,e,r){this.x=i,this.y=t,this.h=e,this.d=$M(i,t,r),this.max=this.d+this.h*Math.SQRT2}function $M(i,t,e){let r=!1,o=1/0;for(let n of e)for(let a=0,s=n.length,l=s-1;a<s;l=a++){let c=n[a],u=n[l];c[1]>t!=u[1]>t&&i<(u[0]-c[0])*(t-c[1])/(u[1]-c[1])+c[0]&&(r=!r),o=Math.min(o,YM(i,t,c,u))}return o===0?0:(r?1:-1)*Math.sqrt(o)}function XM(i){let t=0,e=0,r=0,o=i[0];for(let a=0,s=o.length,l=s-1;a<s;l=a++){let c=o[a],u=o[l],p=c[0]*u[1]-u[0]*c[1];e+=(c[0]+u[0])*p,r+=(c[1]+u[1])*p,t+=p*3}let n=new ju(e/t,r/t,0,i);return t===0||n.d<0?new ju(o[0][0],o[0][1],0,i):n}function YM(i,t,e,r){let o=e[0],n=e[1],a=r[0]-o,s=r[1]-n;if(a!==0||s!==0){let l=((i-o)*a+(t-n)*s)/(a*a+s*s);l>1?(o=r[0],n=r[1]):l>0&&(o+=a*l,n+=s*l)}return a=i-o,s=t-n,a*a+s*s}var Ml={vertices:[160,160,-160,160,-160,-160,160,-160],vertexIndices:[1,0,3,2],vertexCount:4,elements:[0,4],elementCount:1,mesh:void 0},Nf={vertices:[],vertexIndices:[],vertexCount:0,elements:[],elementCount:0,mesh:void 0},Df={vertices:[-160,160,160,-160,160,160,-160,-160],vertexIndices:[1,3,0,2],vertexCount:4,elements:[0,1,2,1,0,3],elementCount:2,mesh:void 0},Ef=(i,t)=>([e,r])=>(r<e&&(r+=t),(i>=e?i:i+t)<=r),Ui=class extends uo.BufferGeometry{constructor(e,r,o=0,n=12,a=3,s=$e.ODD,l=!1){super();this.forPathBevel=l;this.type="ShapeGeometry";this.vertexCache={};this._shape=e,this._depth=r,this._curveSegments=n,this._bevelSegmentsInput=a;let c=this._shape.extractShapePointsToFlatArray([],n),u=this._shape.shapeHoles.map(I=>{let N=I.extractShapePointsToFlatArray([],n),_=[];for(let R=N.length-1;R>=1;R-=2){let V=N[R-1],U=N[R-0];_.push(V,U)}return _}),p=[],d=[];for(let I=0;I<c.length;I+=2)d.push([c[I],c[I+1]]);p.push(d);for(let I=0;I<u.length;I++){let N=u[I],_=[];for(let R=0;R<N.length;R+=2)_.push([N[R],N[R+1]]);p.push(_)}let f;e.isText?f=new uo.Box2().setFromPoints(e.points.map(N=>N.position)).getSize(new uo.Vector2).length()*.1:p[0].length===0?f=o:o>0?f=If(p,o):f=1e-5,o<=0?(this._bevel=0,this._bevelSegments=0):(this._bevel=Math.min(o,f,r/2),this._bevelSegments=Math.floor(a));let h;try{h=co({windingRule:s,elementType:St.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[c]})}catch{h=Ml}let m;try{m=co({windingRule:$e.ODD,elementType:St.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...u]})}catch{m=Nf}if(!h)throw new Error("error generating geometry");let y=h.elementCount;if(m){h.elementCount+=m.elementCount;for(let I=0;I<m.elements.length;I++){let N=m.elements[I],_=I%2===0?h.vertexCount:0;h.elements.push(N+_)}for(let I=0;I<m.vertexIndices.length;I++){let N=m.vertexIndices[I],_=h.vertexCount;h.vertexIndices.push(N+_)}for(let I=0;I<m.vertices.length;I++){let N=m.vertices[I];h.vertices.push(N)}}let b=1/0,v=-1/0,w=1/0,O=-1/0;for(let I=0,N=h.vertexCount;I<N;I++){let _=I*2,R=h.vertices[_+0],V=h.vertices[_+1];R<b&&(b=R),R>v&&(v=R),V<w&&(w=V),V>O&&(O=V)}this._minX=b,this._minY=w,this._width=v-b,this._height=O-w,this._buffer=new Cl(this._computeBufferEstimatedSize(h));let S=[],T=[];for(let I=h.elementCount-1;I>=0;I--){let N=I>=y,_=I*2,R=h.elements[_+0],V=h.elements[_+1],U=R+V,B={start:R,count:V,normals:[],continuous:[],concave:[]},q=R,j=U-1,F=R+1,H=this._shape.roundedCurves.length;do{let re=q-R,K=h.vertices[j*2+0],Z=h.vertices[j*2+1],Q=h.vertices[q*2+0],$=h.vertices[q*2+1],pe=h.vertices[F*2+0],le=h.vertices[F*2+1],ie=Q-K,ue=$-Z,ae=Math.sqrt(ie*ie+ue*ue);ie/=ae,ue/=ae;let ge=Q-pe,me=$-le,ye=Math.sqrt(ge*ge+me*me);ge/=ye,me/=ye,B.normals[re*2+0]=-me,B.normals[re*2+1]=ge,B.concave[re]=ie*me-ue*ge>0;let ve=h.vertexIndices[q];if(Array.isArray(ve))B.continuous[re]=!1;else{let[xe,C]=this._shape.getCurveIndexFromVertexId(ve-1,!0);if(C>0&&C<1)B.continuous[re]=!0;else{let ne=C===1?xe+1:xe-1;ne=(ne+H)%H;let Ve=C===1?0:1,ke=this._shape.roundedCurves[xe].getTangent(C),Ge=this._shape.roundedCurves[ne].getTangent(Ve);B.continuous[re]=ke.dot(Ge)>.95}}N&&(B.normals[re*2+0]*=-1,B.normals[re*2+1]*=-1),[j,q,F]=[q,F,F+1],F>=U&&(F-=V)}while(F!==R+1);let W=[];W.push({bevelI:0,angle:0,size:0,boundary:{vertices:h.vertices.slice(R*2,U*2),vertexCount:V,vertexIndices:new Array(V).fill(!0).map((re,K)=>[K,K]),elements:[0,V],elementCount:1,mesh:null},reverseMap:[],insetPoints:h.vertices.slice(R*2,U*2)});let ee=0;for(let re=1;re<=this._bevelSegments;re++){let K=re/this._bevelSegments*Math.PI/2,Z=(1-Math.cos(K))*this._bevel,Q=[],$=[],pe=[],le=[],ie=0;for(let ae=0;ae<V;ae++){let ge=ae*2,me=(ae-1+V)%V*2,ye=h.vertices[B.start*2+ge+0],ve=h.vertices[B.start*2+ge+1],xe=-B.normals[me+0]*Z,C=-B.normals[me+1]*Z,ne=-B.normals[ge+0]*Z,Ve=-B.normals[ge+1]*Z;if(B.concave[ae]||!B.concave[ae]&&N){let ke=Math.atan2(C,xe),Ge=Math.atan2(Ve,ne);Ge>ke&&(Ge-=Math.PI*2);let Ce=Ge-ke;if(B.continuous[ae]||N){let zt=ke+Ce/2,_e=Math.cos(zt)*Z,Bt=Math.sin(zt)*Z;Q[2*ie+0]=ye+_e*(N?-1:1),Q[2*ie+1]=ve+Bt*(N?-1:1),le[ie]=ae,ie++}else{let zt=Math.max(1,Math.floor(n/4*Math.abs(Ce)/Math.PI));for(let _e=0;_e<=zt;_e++){let Bt=ke+Ce*(_e/zt),Gt=Math.cos(Bt)*Z,pn=Math.sin(Bt)*Z;Q[2*ie+0]=ye+Gt,Q[2*ie+1]=ve+pn,le[ie]=ae,ie++}}}else Q[2*ie+0]=ye+xe,Q[2*ie+1]=ve+C,le[ie]=ae,$[ae]=ie,ie++,Q[2*ie+0]=ye,Q[2*ie+1]=ve,le[ie]=ae,ie++,Q[2*ie+0]=ye+ne,Q[2*ie+1]=ve+Ve,le[ie]=ae,pe[ae]=ie,ie++}let ue=co({windingRule:$e.POSITIVE,elementType:St.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[Q],edgeCreateCallback:ae=>{let me=ae.Org.idx,ye=le[me],ve=le[(me+1)%le.length];ae.idx=[ye,ve],ae.Sym.idx=[ve,ye]},vertexIdCallback:ae=>{let ge=ae.Lprev.idx;return[ge?ge[1]:0,ae.idx?ae.idx[0]:0]}});if(!ue)throw console.log("Error"),new Error(`error generating bevel geometry for ${re}'th loop`);if(!ue.vertexCount){let ae=(re-1)/this._bevelSegments*Math.PI/2;ee=(1-Math.sin(ae))*this._bevel;break}for(let ae=0;ae<ue.vertexIndices.length;ae++){let[ge,me]=ue.vertexIndices[ae];if(ge===me)continue;let ye=me;me<ge&&(ye+=V);for(let ve=ge;ve<ye;ve++){let xe=ve%V,C=(ve+1)%V;if(!B.continuous[xe]||!B.continuous[C]){ue.vertexIndices[ae]=[ge,xe],ue.vertexIndices.splice(ae+1,0,[C,me]),ue.vertices.splice((ae+1)*2,0,ue.vertices[ae*2],ue.vertices[ae*2+1]);break}}}W.push({bevelI:re,angle:K,size:Z,boundary:ue,reverseMap:le,insetPoints:Q})}let te=(re,K,Z)=>{let Q=0,$=re.boundary.vertexIndices.length;for(;Q<$&&Z(re.boundary.vertexIndices[K]);)K=(K+1)%$,Q++;return Q},Y=S.length;for(let re=1;re<W.length;re++){let K=W[re-1],Z=W[re],Q=K.boundary.vertexIndices.length,$=Z.boundary.vertexIndices.length;if(!Q||!$)break;let pe=B.concave.length,le=0,ie=Ef(le,V);for(;!K.boundary.vertexIndices.filter(ie).length||!Z.boundary.vertexIndices.filter(ie).length;)le++,ie=Ef(le,V);let ue=K.boundary.vertexIndices.findIndex(ie),ae=Z.boundary.vertexIndices.findIndex(ie);do ue=(ue+1)%Q;while(ie(K.boundary.vertexIndices[ue]));do ae=(ae+1)%$;while(ie(Z.boundary.vertexIndices[ae]));le=(le+1)%V;let ge=le,me=0,ye=this._buildBevelVert(B,K,(ue-1+Q)%Q,void 0,me),ve=this._buildBevelVert(B,Z,(ae-1+$)%$,void 0,me),xe=ye,C=ve,ne,Ve,ke=!1;do{me=(le||pe)/pe,ie=Ef(le,V);let Ge=te(K,ue,ie),Ce=te(Z,ae,ie),zt=ke;if(ke=!1,Ge&&!Ce){for(let _e=0;_e<Ge;_e++)ne=this._buildBevelVert(B,K,(ue+_e)%Q,_e/(Ge-1),me),S.push(xe.topN,ne.topP,C.topN),l===!1&&S.push(ne.bottomP,xe.bottomN,C.bottomN),xe=ne;ke=!0}else if(!Ge&&Ce)for(let _e=0;_e<Ce;_e++)Ve=this._buildBevelVert(B,Z,(ae+_e)%$,_e/(Ce-1),me),S.push(C.topN,xe.topP,Ve.topP),l===!1&&S.push(xe.bottomP,C.bottomN,Ve.bottomP),C=Ve;else if(Ge&&Ce)if(ne=this._buildBevelVert(B,K,ue,0,me),Ve=this._buildBevelVert(B,Z,ae,0,me),zt?(S.push(xe.topN,Ve.topP,C.topN),S.push(xe.topN,ne.topP,Ve.topP),l===!1&&(S.push(Ve.bottomP,xe.bottomN,C.bottomN),S.push(Ve.bottomP,ne.bottomP,xe.bottomN))):(S.push(C.topN,xe.topN,ne.topP),S.push(C.topN,ne.topP,Ve.topP),l===!1&&(S.push(ne.bottomP,xe.bottomN,C.bottomN),S.push(ne.bottomP,C.bottomN,Ve.bottomP))),xe=ne,C=Ve,Ge===Ce)for(let _e=1;_e<Ge;_e++)ne=this._buildBevelVert(B,K,(ue+_e)%Q,_e/(Ge-1),me),Ve=this._buildBevelVert(B,Z,(ae+_e)%$,_e/(Ce-1),me),S.push(xe.topN,ne.topP,C.topN),S.push(C.topN,ne.topP,Ve.topP),l===!1&&(S.push(ne.bottomP,xe.bottomN,C.bottomN),S.push(ne.bottomP,C.bottomN,Ve.bottomP)),xe=ne,C=Ve;else if(Ge>Ce){let _e=Ge/Ce,Bt=0;for(let Gt=1;Gt<Ge;Gt++)ne=this._buildBevelVert(B,K,(ue+Gt)%Q,Gt/(Ge-1),me),S.push(xe.topN,ne.topP,C.topN),l===!1&&S.push(ne.bottomP,xe.bottomN,C.bottomN),xe=ne,Gt>(Bt+1)*_e&&(Bt++,Ve=this._buildBevelVert(B,Z,(ae+Bt)%$,Bt/(Ce-1),me),S.push(C.topN,ne.topP,Ve.topP),l===!1&&S.push(ne.bottomP,C.bottomN,Ve.bottomP),C=Ve)}else{let _e=Ce/Ge,Bt=0;for(let Gt=1;Gt<Ce;Gt++)Ve=this._buildBevelVert(B,Z,(ae+Gt)%$,Gt/(Ce-1),me),S.push(C.topN,ne.topP,Ve.topP),l===!1&&S.push(ne.bottomP,C.bottomN,Ve.bottomP),C=Ve,Gt>(Bt+1)*_e&&(Bt++,ne=this._buildBevelVert(B,K,(ue+Bt)%Q,Bt/(Ge-1),me),S.push(xe.topN,ne.topP,C.topN),l===!1&&S.push(ne.bottomP,xe.bottomN,C.bottomN),xe=ne)}ue=(ue+Ge)%Q,ae=(ae+Ce)%$,le=(le+1)%pe}while(le!==ge)}if(l===!1&&this._depth>this._bevel*2&&this._buildWall(W,B,S),N){let re=[];for(let K=S.length-1;K>=Y+2;K-=3){let Z=S[K-2],Q=S[K-1],$=S[K-0];re.push($,Q,Z)}S.splice(Y,S.length-Y,...re)}if(N){let re=[];for(let K=W[W.length-1].boundary.vertices.length-1;K>=1;K-=2){let Z=W[W.length-1].boundary.vertices[K-1],Q=W[W.length-1].boundary.vertices[K-0];re.push(Z,Q)}T.push(re)}if(!N){let re=W[W.length-1],K;try{K=co({windingRule:W.length>1?$e.POSITIVE:$e.ODD,elementType:St.POLYGONS,vertexSize:2,strict:!0,contours:[re.insetPoints,...T]})}catch{K=Df}if(!K)throw new Error("Error generating geometry for surface");u.length===0&&this._bevel<f&&Object.assign(this,{useNgonForTopBottomFaceDuringBake:!0});for(let Z=0;Z<K.elementCount*3;Z+=3){let Q=this._buildSurfaceVert(K,K.elements[Z+0],ee),$=this._buildSurfaceVert(K,K.elements[Z+1],ee),pe=this._buildSurfaceVert(K,K.elements[Z+2],ee);S.push(Q.top,$.top,pe.top),l===!1&&S.push(pe.bottom,$.bottom,Q.bottom)}}this.vertexCache={}}this._buffer.shrink();let M=new uo.BufferAttribute(Uint32Array.from(S),1),g=new uo.BufferAttribute(this._buffer.positions,3),D=new uo.BufferAttribute(this._buffer.normals,3),E=new uo.BufferAttribute(this._buffer.uvs,2);g.needsUpdate=!0,D.needsUpdate=!0,E.needsUpdate=!0,M.needsUpdate=!0,this.setAttribute("position",g),this.setAttribute("normal",D),this.setAttribute("uv",E),this.setIndex(M)}_computeBufferEstimatedSize(e){return e.vertexCount*2*(2+this._bevelSegments)}_buildWall(e,r,o){let n=e[0];for(let a=0,s=n.boundary.vertexCount;a<s;a++){let l=this._buildBevelVert(r,n,a),c=this._buildBevelVert(r,n,(a+1)%s);o.push(c.topP,l.topN,l.bottomN),o.push(c.topP,l.bottomN,c.bottomP)}}_buildSurfaceVert(e,r,o){let n=r.toString();if(n in this.vertexCache)return this.vertexCache[n];let a=e.vertices[r*2+0],s=e.vertices[r*2+1],l=(a-this._minX)/this._width,c=(s-this._minY)/this._height;this.forPathBevel&&(c=1);let u=this._buffer.get(this.forPathBevel?1:2),p=u*3,d=u*2,f={top:u+0,bottom:u+1};return this._buffer.positions[p+0]=a,this._buffer.positions[p+1]=s,this._buffer.positions[p+2]=this.forPathBevel?this._bevel:this._depth-o,this._buffer.normals[p+0]=0,this._buffer.normals[p+1]=0,this._buffer.normals[p+2]=1,this._buffer.uvs[d+0]=l,this._buffer.uvs[d+1]=c,this.forPathBevel===!1&&(this._buffer.positions[p+3]=a,this._buffer.positions[p+4]=s,this._buffer.positions[p+5]=o,this._buffer.normals[p+3]=0,this._buffer.normals[p+4]=0,this._buffer.normals[p+5]=-1,this._buffer.uvs[d+2]=l,this._buffer.uvs[d+3]=c),this.vertexCache[n]=f,f}_buildBevelVert(e,r,o,n=1,a){let s=`${r.bevelI}:${o}`;if(s in this.vertexCache&&a!==0&&a!==1&&(!a||a===this.vertexCache[s].pathBevelUCoord))return this.vertexCache[s];let[l,c]=r.boundary.vertexIndices[o],u,p,d,f;l!==c?(p=l,u=c,f=!1,d=e.continuous[p]&&e.continuous[u]):(u=l,p=(u-1+e.count)%e.count,f=e.concave[u]&&r.bevelI>0,d=e.continuous[u]||f);let h=Math.cos(r.angle),m=Math.sin(r.angle),y=o*2,b=u*2,v=p*2,w=r.boundary.vertices[y+0],O=r.boundary.vertices[y+1],S=(1-m)*this._bevel,T=(w-this._minX)/this._width,M=(O-this._minY)/this._height;this.forPathBevel&&(a!==void 0&&(T=a),M=1);let g=e.normals[b+0],D=e.normals[b+1],E=e.normals[v+0],I=e.normals[v+1];if(f){let U=E-g,B=I-D;g=g+U*(1-n),D=D+B*(1-n);let q=Math.sqrt(g*g+D*D);g/=q,D/=q}let N=this.forPathBevel?this._buffer.get(d?1:2):this._buffer.get(d?2:4),_=N*3,R=N*2,V={i:o,fi:u,topP:N+0,topN:N+0,bottomP:N+1,bottomN:N+1,pathBevelUCoord:a};return this._buffer.positions[_+0]=w,this._buffer.positions[_+1]=O,this._buffer.positions[_+2]=(this.forPathBevel?this._bevel:this._depth)-S,this._buffer.normals[_+0]=g*h,this._buffer.normals[_+1]=D*h,this._buffer.normals[_+2]=m,this._buffer.uvs[R+0]=T,this._buffer.uvs[R+1]=M,this.forPathBevel===!1&&(this._buffer.positions[_+3]=w,this._buffer.positions[_+4]=O,this._buffer.positions[_+5]=S,this._buffer.normals[_+3]=g*h,this._buffer.normals[_+4]=D*h,this._buffer.normals[_+5]=-m,this._buffer.uvs[R+2]=M,this._buffer.uvs[R+3]=T),d||(this.forPathBevel?(N+=1,_+=3,R+=2):(N+=2,_+=6,R+=4),V.topP=N+0,V.bottomP=N+1,this._buffer.positions[_+0]=w,this._buffer.positions[_+1]=O,this._buffer.positions[_+2]=(this.forPathBevel?this._bevel:this._depth)-S,this._buffer.normals[_+0]=E*h,this._buffer.normals[_+1]=I*h,this._buffer.normals[_+2]=m,this._buffer.uvs[R+0]=T,this._buffer.uvs[R+1]=M,this.forPathBevel===!1&&(this._buffer.positions[_+3]=w,this._buffer.positions[_+4]=O,this._buffer.positions[_+5]=S,this._buffer.normals[_+3]=E*h,this._buffer.normals[_+4]=I*h,this._buffer.normals[_+5]=-m,this._buffer.uvs[R+2]=M,this._buffer.uvs[R+3]=T)),this.vertexCache[s]=V,V}clone(){let e=new Ui(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=Zo(this.userData),e}};var qa=class extends Mn.BufferGeometry{constructor(e,r=12,o={}){super();this.type="ShapeGeometry";this.windingRule=$e.ODD;this.elementType=St.POLYGONS;this.polySize=3;this.vertexSize=2;this.strict=!0;this._shape=e,this._curveSegments=r,this._triangulationOptions=Object.assign({windingRule:$e.ODD,elementType:St.POLYGONS,polySize:3,vertexSize:2,strict:!0},o);let n=this._shape.extractShapePointsToFlatArray([],this._curveSegments),a=this._shape.shapeHoles.map(h=>h.extractShapePointsToFlatArray([],this._curveSegments)),s,l=!0,c=!0,u,p;for(let h=0,m=n.length/2;h<m;h++){let y=h*2,b=n[y+0],v=n[y+1];if(u!==void 0&&b!==u&&(l=!1),p!==void 0&&v!==p&&(c=!1),u=b,p=v,!l&&!c)break}if(!l&&!c)try{s=co({contours:[n,...a],windingRule:this._triangulationOptions.windingRule,elementType:this._triangulationOptions.elementType,polySize:this._triangulationOptions.polySize,vertexSize:this._triangulationOptions.vertexSize,strict:this._triangulationOptions.strict})}catch{s=Ml}let d=s?.vertexCount??1,f=s?.elementCount??1;if(this._positionAttribute=new Mn.BufferAttribute(new Float32Array(d*3),3),this._normalAttribute=new Mn.BufferAttribute(new Float32Array(d*3),3),this._uvAttribute=new Mn.BufferAttribute(new Float32Array(d*2),2),this._indexAttribute=new Mn.BufferAttribute(new Uint32Array(f*3),1),s){let h=1/0,m=-1/0,y=1/0,b=-1/0;for(let O=0,S=d;O<S;O++){let T=O*2,M=s.vertices[T+0],g=s.vertices[T+1];M<h&&(h=M),M>m&&(m=M),g<y&&(y=g),g>b&&(b=g)}let v=m-h,w=b-y;for(let O=0,S=d;O<S;O++){let T=O*2,M=s.vertices[T+0],g=s.vertices[T+1],D=(M-h)/v,E=(g-y)/w;this._positionAttribute.setXYZ(O,M,g,0),this._normalAttribute.setXYZ(O,0,0,1),this._uvAttribute.setXY(O,D,E)}for(let O=0,S=f;O<S;O++){let T=O*3,M=s.elements[T+0],g=s.elements[T+1],D=s.elements[T+2];this._indexAttribute.setX(T+0,M),this._indexAttribute.setX(T+1,g),this._indexAttribute.setX(T+2,D)}}this.setAttribute("position",this._positionAttribute),this.setAttribute("normal",this._normalAttribute),this.setAttribute("uv",this._uvAttribute),this.setIndex(this._indexAttribute),this.setDrawRange(0,(s?.elementCount??1)*3)}clone(){let e=new qa(this._shape,this._curveSegments);return e.userData=Zo(this.userData),e}};var $a=class extends Ui{constructor(e,r,o=0,n=12,a=3,s=$e.ODD){super(e,r,o,n,a,s);this.type="ShapeGeometry"}_computeBufferEstimatedSize(e){return e.vertexCount*2*(2+this._bevelSegments)}_buildWall(e,r,o){let n=e[0];for(let a=0,s=n.boundary.vertexCount;a<s;a++){let l=this._buildBevelVert(r,n,a),c=this._buildBevelVert(r,n,(a+1)%s);o.push(c.topP,l.topN,l.bottomN),o.push(c.topP,l.bottomN,c.bottomP)}}clone(){let e=new $a(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=Zo(this.userData),e}};var wr=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,subdivisions:40,roundness:0,extrudeBevelSize:0,extrudeBevelSegments:3,windingRule:$e.ODD},i.parameters),r=Math.abs(e.width),o=Math.abs(e.height??e.width),n=Math.abs(e.depth??0),a=i.shape??t?.shape,s=a?.roundness??e.roundness;a!==void 0&&(a instanceof Xe?(a.width!==r||a.height!==o)&&a.applySize(r,o):a=new Xe(r,o).fromJSON(a),i.parameters?.roundness!==void 0&&i.parameters?.roundness>0&&a.update());let l=a??new Xe(r,o);return{parameters:Object.assign(e,{width:r,height:o,depth:n,roundness:s}),shape:l}}static build(i){let{depth:t,extrudeBevelSize:e,extrudeBevelSegments:r,subdivisions:o,roundness:n,windingRule:a}=i.parameters;i.shape.roundness=n;let s;return t<=0?s=new qa(i.shape,o,{windingRule:a}):s=new $a(i.shape,t,e,o,r,a),Object.assign(s,{userData:{...i,type:"VectorGeometry"}})}};var po=require("three"),Lx=Math.PI*2,Ya=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,spikes:64,angle:360,innerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1},i.parameters);return e.angle=po.MathUtils.clamp(e.angle,0,360),{shape:i.shape&&i.shape instanceof Xe?i.shape:new Xe,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)})}}static build(i){let{width:t,height:e,spikes:r,angle:o,innerRadius:n,depth:a,extrudeBevelSize:s,extrudeBevelSegments:l}=i.parameters,c=i.shape,u=t*.5,p=e*.5,d=KM(c,u,p,o*Math.PI/180,r,n);c.isClosed=!0,c.update();let f;return o===0?(f=new po.BufferGeometry,f.setAttribute("position",new po.Float32BufferAttribute([],3))):f=wr.create({shape:c,parameters:{subdivisions:d,depth:a,extrudeBevelSize:s,extrudeBevelSegments:l}}),Object.assign(f,{userData:{...i,type:"EllipseGeometry"}})}};function KM(i,t,e,r,o,n){if(r>=Lx)return o>30||o%4===0?(ZM(i,t,e,n),Math.round(o/4)):Rx(i,r,o,t,e,n);r=Math.max(r,.001);let a={x:0,y:e},s=r+Math.PI*.5,l={x:Math.cos(s)*t,y:Math.sin(s)*e},c=Ix({px:a.x,py:a.y,cx:l.x,cy:l.y,rx:t,ry:e,largeArcFlag:r>Math.PI,sweepFlag:!0});return o>30||o%c.length===0?QM(i,a.x,a.y,c,o,t,e,n):Rx(i,r,o,t,e,n)}function QM(i,t,e,r,o,n,a,s){let l=Math.round(o/r.length);i.addPoint(Xa(t,e));for(let c=0,u=r.length;c<u;c++){let p=r[c],d=i.points[c],f=Xa(p.x,p.y);d.controls[1].position.set(p.x1,p.y1),f.controls[0].position.set(p.x2,p.y2),i.addPoint(f)}return s>0?Bx(i,n,a,s):i.addPoint(Xa(0,0)),l}function Rx(i,t,e,r,o,n){let a=-t/e;for(let s=0;s<=e;s++){let l=a*s,c=Math.sin(l)*r,u=Math.cos(l)*o;i.addPoint(Xa(c,u))}return t<Lx?n>0?Bx(i,r,o,n):i.addPoint(Xa(0,0)):(i.removePoint(i.points[i.points.length-1]),n>0&&Vx(i,r,o,n)),1}function ZM(i,t,e,r=0,o=0,n=0){let a=.5522847498,s=t*a,l=e*a;i.addPoint(Uu(o-t,n,o-t,n-l,o-t,n+l)),i.addPoint(Uu(o,n+e,o-s,n+e,o+s,n+e)),i.addPoint(Uu(o+t,n,o+t,n+l,o+t,n-l)),i.addPoint(Uu(o,n-e,o+s,n-e,o-s,n-e)),r>0&&Vx(i,t,e,r)}function Xa(i,t){return new lo(po.MathUtils.generateUUID(),new po.Vector2(i,t))}function Uu(i,t,e,r,o,n){let a=Xa(i,t);return a.controls[0].position.set(e,r),a.controls[1].position.set(o,n),a}function Bx(i,t,e,r){zx(i,t,e,r).forEach(n=>i.addPoint(n))}function Vx(i,t,e,r){let o=zx(i,t,e,r),n=new Xe;o.forEach(a=>n.addPoint(a)),n.isClosed=!0,i.shapeHoles.push(n)}function zx(i,t,e,r){let o=r*t/100,n=o*(Math.abs(e)/Math.abs(t)),a=new po.Vector2(o/t,n/e),s=i.points.map(l=>{let c=l.clone();return c.uuid=po.MathUtils.generateUUID(),c}).reverse();return s.forEach(l=>{l.position.multiply(a);let c=l.controls[0].position.clone().multiply(a),u=l.controls[1].position.clone().multiply(a);l.controls[0].position.copy(u),l.controls[1].position.copy(c)}),s}var fo=require("three"),Gx=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,revolutions:2,segments:40,pathRadius:10,pathType:0,pathSegments:30,cornerRadius:30,cornerSegments:4},i.parameters),r=Math.abs(e.width),o=Math.abs(e.height??r),n=Math.abs(e.depth??r),a=Math.abs(Math.min(r,n))/2;return{parameters:Object.assign(e,{width:r,height:o,depth:n,radius:a,segments:Math.round(e.segments),pathSegments:Math.round(e.pathSegments),cornerSegments:Math.round(e.cornerSegments)})}}static build(i){let{width:t,height:e,depth:r,radius:o,revolutions:n,segments:a,pathRadius:s,pathType:l,pathSegments:c,cornerRadius:u,cornerSegments:p}=i.parameters,d=new Il(!1,t,e,r,o,n,a,s,l,c,u,p);return Object.assign(d,{userData:{...i,type:"HelixGeometry"}})}},_f=new fo.Uint32BufferAttribute([0,0,0],1),Il=class extends fo.BufferGeometry{constructor(t=!0,e=1,r=1,o=1,n=1,a=1,s=1,l=1,c=1,u=1,p=1,d=1){if(super(),a===0)return;let f=t&&a===1;f&&(d=0),p>100&&(p=100),p===0&&(d=0);let h=()=>new fo.Vector3,m=new fo.Vector3,y=h(),b=h(),v=h(),w,O,S,T,M,g,D,E,I=h(),N=h(),_=h(),R=h(),V=h(),U=h(),B=h(),q=h(),j=r-2*l+.001,F=j/a,H=Math.ceil(s*a),W=H+1,ee=j/H,te=-j/2,Y=u+1,re=2*Math.PI/u,K=Math.PI/2/d,Z=.01,Q=Math.min((1-p/100)*l,l-Z),$=l-Q,pe=0,le=2,ie=d*le+le,ue=Y*ie/le,ae=ue+Y*W,ge=Math.max(0,Y*(W+ie)),[me,ye,ve]=[3,3,2].map(xt=>Array(ge*xt).fill(0)),xe=[],C=n-l;function ne(xt,at){let to=Math.PI/2;g=at*ee,E=2*Math.PI*(g%F)/F+to,g+=te,D=Math.sin(E)*C,M=Math.cos(E)*C,t?xt.set(M,D,g):xt.set(M,g,D)}ne(m,-1e-10),ne(y,0),I.copy(m),ne(m,1);let Ve=m.distanceTo(y),ke=f?0:$+Q,Ge=Ve*H+2*ke,Ce=Q,zt=Ge-ke;for(let xt=0;xt<=H;xt++){ne(b,xt),q.subVectors(b,I).normalize(),I.copy(b),U.copy(b).setComponent(+t+1,0).normalize(),B.crossVectors(q,U).normalize();let at=xt===0,to=xt===H,cp=at?3*Math.PI/2:K,up=at?Ce:zt,hc=at?Y:ae,fn=at?0:ge-Y,Pt=q.clone().multiplyScalar(at?-$:$).add(b),dp=q.clone().multiplyScalar(at?-1:1).normalize();for(let zr=0;zr<Y;zr++){let Zs=zr*re;if(N.addVectors(m.copy(U).multiplyScalar(l*Math.cos(Zs)),y.copy(B).multiplyScalar(l*Math.sin(Zs))),_.copy(N).normalize(),at||to){f||(pe=fn+zr,[0,1,2].forEach(cr=>{me[pe*3+cr]=Pt.getComponent(cr),ye[pe*3+cr]=dp.getComponent(cr)}),ve[pe*2]=+to,ve[pe*2+1]=zr/u),y.copy(_).multiplyScalar(Q),v.addVectors(b,y);for(let cr=0;cr<d;cr++){let hn=cr*K+cp;R.addVectors(m.copy(q).multiplyScalar($*Math.sin(hn)),y.copy(_).multiplyScalar($*Math.cos(hn))),V.copy(R).normalize(),y.addVectors(v,R),R.normalize(),pe=hc+cr*Y+zr,[0,1,2].forEach(qn=>{me[pe*3+qn]=y.getComponent(qn),ye[pe*3+qn]=V.getComponent(qn)});let mc=+at+Math.sin(hn);ve[pe*2]=(up+$*mc)/Ge,ve[pe*2+1]=zr/u}}y.addVectors(b,N),pe=ue+xt*Y+zr,[0,1,2].forEach(cr=>{me[pe*3+cr]=y.getComponent(cr),ye[pe*3+cr]=_.getComponent(cr)}),ve[pe*2]=(ke+xt*Ve)/Ge,ve[pe*2+1]=zr/u}}let _e=W+2*d+le,Bt=1,[Gt,pn]=[+f,_e-1];for(let xt=Gt;xt<=pn-1;xt++){let at=f&&xt===pn-1;for(let to=0;to<Y-1;to++)w=xt*Y+to,O=w+1,S=(at?to:w)+Y,T=(at?to+1:O)+Y,xt===0?xe.push(O,T,S):xt===_e-2?xe.push(w,O,S):xe.push(w,O,S,O,T,S)}this.setIndex(xe),this.setAttribute("position",new fo.Float32BufferAttribute(me,3)),this.setAttribute("normal",new fo.Float32BufferAttribute(ye,3)),this.setAttribute("uv",new fo.Float32BufferAttribute(ve,2))}getClosedTorusIndicesForBooleanOrSubdiv(){let t=this.userData.parameters,e=Math.ceil(t.tubularSegments),r=t.radialSegments+1,o=Array.from(this.getIndex().array),n,a,s,l,c=6*(e-1)*t.radialSegments,u=e,p=u===e;for(let d=0;d<t.radialSegments;d++)n=u*r+d,a=n+1,s=(p?d:n)+r,l=(p?d+1:a)+r,o[c++]=n,o[c++]=a,o[c++]=s,o[c++]=a,o[c++]=l,o[c++]=s;return o.length=c,_f.array=o,_f.count=o.length,_f}};var Fx=require("three");var jx=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,detail:0,corner:0,cornerSides:4},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(i){let{width:t,height:e,depth:r,detail:o,corner:n,cornerSides:a}=i.parameters,s=o===0&&n!==0?new El(t*.5,n,a):new Fx.IcosahedronGeometry(t*.5,o);return s.scale(1,e/t,r/t),Object.assign(s,{userData:{...i,type:"IcosahedronGeometry"}})}},El=class extends Fi{constructor(t=1,e=.2,r=4){let o=(1+Math.sqrt(5))/2,n=[-1,o,0,1,o,0,-1,-o,0,1,-o,0,0,-1,o,0,1,o,0,-1,-o,0,1,-o,o,0,-1,o,0,1,-o,0,-1,-o,0,1],a=[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],s="IcosahedronGeometry";super(n,a,s,t,e,r),this.type=s}static fromJSON(t){return new El(t.radius,t.corner,t.cornerSides)}};var ku=require("three"),Ux=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){(i.parameters?.points??[]).forEach(r=>{Array.isArray(r)&&(r.x=r[0],r.y=r[1])});let e=Object.assign({},t?.parameters??{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(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(i){let{points:t,segments:e,verticalSegments:r}=i.parameters,o=new ku.Shape;o.moveTo(t[0].x,t[0].y),o.bezierCurveTo(t[1].x,t[1].y,t[2].x,t[2].y,t[3].x,t[3].y);let n=new ku.LatheGeometry(o.extractPoints(r).shape,e);return n.rotateZ(Math.PI),Object.assign(n,{userData:{...i,type:"LatheGeometry"}})}};var Ro=require("three");var li=require("three");var he=require("three"),_o=new he.Matrix4,Rf=new he.Object3D,Hu=new he.Vector3,ki=class extends he.EventDispatcher{constructor(){super(),this.uuid=he.MathUtils.generateUUID(),this.name="",this.type="Geometry",this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.elementsNeedUpdate=!1,this.verticesNeedUpdate=!1,this.uvsNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.lineDistancesNeedUpdate=!1,this.groupsNeedUpdate=!1}applyMatrix4(t){let e=new he.Matrix3().getNormalMatrix(t);for(let r=0,o=this.vertices.length;r<o;r++)this.vertices[r].applyMatrix4(t);for(let r=0,o=this.faces.length;r<o;r++){let n=this.faces[r];n.normal.applyMatrix3(e).normalize();for(let a=0,s=n.vertexNormals.length;a<s;a++)n.vertexNormals[a].applyMatrix3(e).normalize()}return this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this.verticesNeedUpdate=!0,this.normalsNeedUpdate=!0,this}rotateX(t){return _o.makeRotationX(t),this.applyMatrix4(_o),this}rotateY(t){return _o.makeRotationY(t),this.applyMatrix4(_o),this}rotateZ(t){return _o.makeRotationZ(t),this.applyMatrix4(_o),this}translate(t,e,r){return _o.makeTranslation(t,e,r),this.applyMatrix4(_o),this}scale(t,e,r){return _o.makeScale(t,e,r),this.applyMatrix4(_o),this}lookAt(t){return Rf.lookAt(t),Rf.updateMatrix(),this.applyMatrix4(Rf.matrix),this}fromBufferGeometry(t){let e=this,r=t.index!==null?t.index:void 0,o=t.attributes;if(o.position===void 0)return console.error("THREE.Geometry.fromBufferGeometry(): Position attribute required for conversion."),this;let n=o.position,a=o.normal,s=o.color,l=o.uv,c=o.uv2;c!==void 0&&(this.faceVertexUvs[1]=[]);for(let d=0;d<n.count;d++)e.vertices.push(new he.Vector3().fromBufferAttribute(n,d)),s!==void 0&&e.colors.push(new he.Color().fromBufferAttribute(s,d));function u(d,f,h,m){let y=s===void 0?[]:[e.colors[d].clone(),e.colors[f].clone(),e.colors[h].clone()],b=a===void 0?[]:[new he.Vector3().fromBufferAttribute(a,d),new he.Vector3().fromBufferAttribute(a,f),new he.Vector3().fromBufferAttribute(a,h)],v=new Ka(d,f,h,b,y,m);e.faces.push(v),l!==void 0&&e.faceVertexUvs[0].push([new he.Vector2().fromBufferAttribute(l,d),new he.Vector2().fromBufferAttribute(l,f),new he.Vector2().fromBufferAttribute(l,h)]),c!==void 0&&e.faceVertexUvs[1].push([new he.Vector2().fromBufferAttribute(c,d),new he.Vector2().fromBufferAttribute(c,f),new he.Vector2().fromBufferAttribute(c,h)])}let p=t.groups;if(p.length>0)for(let d=0;d<p.length;d++){let f=p[d],h=f.start,m=f.count;for(let y=h,b=h+m;y<b;y+=3)r!==void 0?u(r.getX(y),r.getX(y+1),r.getX(y+2),f.materialIndex):u(y,y+1,y+2,f.materialIndex)}else if(r!==void 0)for(let d=0;d<r.count;d+=3)u(r.getX(d),r.getX(d+1),r.getX(d+2));else for(let d=0;d<n.count;d+=3)u(d,d+1,d+2);return this.computeFaceNormals(),t.boundingBox!==null&&(this.boundingBox=t.boundingBox.clone()),t.boundingSphere!==null&&(this.boundingSphere=t.boundingSphere.clone()),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Hu).negate(),this.translate(Hu.x,Hu.y,Hu.z),this}normalize(){this.computeBoundingSphere();let t=this.boundingSphere.center,e=this.boundingSphere.radius,r=e===0?1:1/e,o=new he.Matrix4;return o.set(r,0,0,-r*t.x,0,r,0,-r*t.y,0,0,r,-r*t.z,0,0,0,1),this.applyMatrix4(o),this}computeFaceNormals(){let t=new he.Vector3,e=new he.Vector3;for(let r=0,o=this.faces.length;r<o;r++){let n=this.faces[r],a=this.vertices[n.a],s=this.vertices[n.b],l=this.vertices[n.c];t.subVectors(l,s),e.subVectors(a,s),t.cross(e),t.normalize(),n.normal.copy(t)}}computeVertexNormals(t=!0){let e=new Array(this.vertices.length);for(let r=0,o=this.vertices.length;r<o;r++)e[r]=new he.Vector3;if(t){let r=new he.Vector3,o=new he.Vector3;for(let n=0,a=this.faces.length;n<a;n++){let s=this.faces[n],l=this.vertices[s.a],c=this.vertices[s.b],u=this.vertices[s.c];r.subVectors(u,c),o.subVectors(l,c),r.cross(o),e[s.a].add(r),e[s.b].add(r),e[s.c].add(r)}}else{this.computeFaceNormals();for(let r=0,o=this.faces.length;r<o;r++){let n=this.faces[r];e[n.a].add(n.normal),e[n.b].add(n.normal),e[n.c].add(n.normal)}}for(let r=0,o=this.vertices.length;r<o;r++)e[r].normalize();for(let r=0,o=this.faces.length;r<o;r++){let n=this.faces[r],a=n.vertexNormals;a.length===3?(a[0].copy(e[n.a]),a[1].copy(e[n.b]),a[2].copy(e[n.c])):(a[0]=e[n.a].clone(),a[1]=e[n.b].clone(),a[2]=e[n.c].clone())}this.faces.length>0&&(this.normalsNeedUpdate=!0)}computeFlatVertexNormals(){this.computeFaceNormals();for(let t=0,e=this.faces.length;t<e;t++){let r=this.faces[t],o=r.vertexNormals;o.length===3?(o[0].copy(r.normal),o[1].copy(r.normal),o[2].copy(r.normal)):(o[0]=r.normal.clone(),o[1]=r.normal.clone(),o[2]=r.normal.clone())}this.faces.length>0&&(this.normalsNeedUpdate=!0)}computeMorphNormals(){for(let e=0,r=this.faces.length;e<r;e++){let o=this.faces[e];o.__originalFaceNormal?o.__originalFaceNormal.copy(o.normal):o.__originalFaceNormal=o.normal.clone(),o.__originalVertexNormals||(o.__originalVertexNormals=[]);for(let n=0,a=o.vertexNormals.length;n<a;n++)o.__originalVertexNormals[n]?o.__originalVertexNormals[n].copy(o.vertexNormals[n]):o.__originalVertexNormals[n]=o.vertexNormals[n].clone()}let t=new ki;t.faces=this.faces;for(let e=0,r=this.morphTargets.length;e<r;e++){if(!this.morphNormals[e]){this.morphNormals[e]={},this.morphNormals[e].faceNormals=[],this.morphNormals[e].vertexNormals=[];let n=this.morphNormals[e].faceNormals,a=this.morphNormals[e].vertexNormals;for(let s=0,l=this.faces.length;s<l;s++){let c=new he.Vector3,u={a:new he.Vector3,b:new he.Vector3,c:new he.Vector3};n.push(c),a.push(u)}}let o=this.morphNormals[e];t.vertices=this.morphTargets[e].vertices,t.computeFaceNormals(),t.computeVertexNormals();for(let n=0,a=this.faces.length;n<a;n++){let s=this.faces[n],l=o.faceNormals[n],c=o.vertexNormals[n];l.copy(s.normal),c.a.copy(s.vertexNormals[0]),c.b.copy(s.vertexNormals[1]),c.c.copy(s.vertexNormals[2])}}for(let e=0,r=this.faces.length;e<r;e++){let o=this.faces[e];o.normal=o.__originalFaceNormal,o.vertexNormals=o.__originalVertexNormals}}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new he.Box3),this.boundingBox.setFromPoints(this.vertices)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new he.Sphere),this.boundingSphere.setFromPoints(this.vertices)}merge(t,e,r=0){if(!(t&&t.isGeometry)){console.error("THREE.Geometry.merge(): geometry not an instance of THREE.Geometry.",t);return}let o,n=this.vertices.length,a=this.vertices,s=t.vertices,l=this.faces,c=t.faces,u=this.colors,p=t.colors;e!==void 0&&(o=new he.Matrix3().getNormalMatrix(e));for(let d=0,f=s.length;d<f;d++){let m=s[d].clone();e!==void 0&&m.applyMatrix4(e),a.push(m)}for(let d=0,f=p.length;d<f;d++)u.push(p[d].clone());for(let d=0,f=c.length;d<f;d++){let h=c[d],m,y,b=h.vertexNormals,v=h.vertexColors,w=new Ka(h.a+n,h.b+n,h.c+n);w.normal.copy(h.normal),o!==void 0&&w.normal.applyMatrix3(o).normalize();for(let O=0,S=b.length;O<S;O++)m=b[O].clone(),o!==void 0&&m.applyMatrix3(o).normalize(),w.vertexNormals.push(m);w.color.copy(h.color);for(let O=0,S=v.length;O<S;O++)y=v[O],w.vertexColors.push(y.clone());w.materialIndex=h.materialIndex+r,l.push(w)}for(let d=0,f=t.faceVertexUvs.length;d<f;d++){let h=t.faceVertexUvs[d];this.faceVertexUvs[d]===void 0&&(this.faceVertexUvs[d]=[]);for(let m=0,y=h.length;m<y;m++){let b=h[m],v=[];for(let w=0,O=b.length;w<O;w++)v.push(b[w].clone());this.faceVertexUvs[d].push(v)}}}mergeMesh(t){if(!(t&&t.isMesh)){console.error("THREE.Geometry.mergeMesh(): mesh not an instance of THREE.Mesh.",t);return}t.matrixAutoUpdate&&t.updateMatrix(),this.merge(t.geometry,t.matrix)}mergeVertices(t=4){let e={},r=[],o=[],n=Math.pow(10,t);for(let l=0,c=this.vertices.length;l<c;l++){let u=this.vertices[l],p=Math.round(u.x*n)+"_"+Math.round(u.y*n)+"_"+Math.round(u.z*n);e[p]===void 0?(e[p]=l,r.push(this.vertices[l]),o[l]=r.length-1):o[l]=o[e[p]]}let a=[];for(let l=0,c=this.faces.length;l<c;l++){let u=this.faces[l];u.a=o[u.a],u.b=o[u.b],u.c=o[u.c];let p=[u.a,u.b,u.c];for(let d=0;d<3;d++)if(p[d]===p[(d+1)%3]){a.push(l);break}}for(let l=a.length-1;l>=0;l--){let c=a[l];this.faces.splice(c,1);for(let u=0,p=this.faceVertexUvs.length;u<p;u++)this.faceVertexUvs[u].splice(c,1)}let s=this.vertices.length-r.length;return this.vertices=r,s}setFromPoints(t){this.vertices=[];for(let e=0,r=t.length;e<r;e++){let o=t[e];this.vertices.push(new he.Vector3(o.x,o.y,o.z||0))}return this}sortFacesByMaterialIndex(){let t=this.faces,e=t.length;for(let l=0;l<e;l++)t[l]._id=l;function r(l,c){return l.materialIndex-c.materialIndex}t.sort(r);let o=this.faceVertexUvs[0],n=this.faceVertexUvs[1],a,s;o&&o.length===e&&(a=[]),n&&n.length===e&&(s=[]);for(let l=0;l<e;l++){let c=t[l]._id;a&&a.push(o[c]),s&&s.push(n[c])}a&&(this.faceVertexUvs[0]=a),s&&(this.faceVertexUvs[1]=s)}toJSON(){let t={metadata:{version:4.5,type:"Geometry",generator:"Geometry.toJSON"}};if(t.uuid=this.uuid,t.type=this.type,this.name!==""&&(t.name=this.name),this.parameters!==void 0){let h=this.parameters;for(let m in h)h[m]!==void 0&&(t[m]=h[m]);return t}let e=[];for(let h=0;h<this.vertices.length;h++){let m=this.vertices[h];e.push(m.x,m.y,m.z)}let r=[],o=[],n={},a=[],s={},l=[],c={};for(let h=0;h<this.faces.length;h++){let m=this.faces[h],y=!0,b=!1,v=this.faceVertexUvs[0][h]!==void 0,w=m.normal.length()>0,O=m.vertexNormals.length>0,S=m.color.r!==1||m.color.g!==1||m.color.b!==1,T=m.vertexColors.length>0,M=0;if(M=u(M,0,0),M=u(M,1,y),M=u(M,2,b),M=u(M,3,v),M=u(M,4,w),M=u(M,5,O),M=u(M,6,S),M=u(M,7,T),r.push(M),r.push(m.a,m.b,m.c),r.push(m.materialIndex),v){let g=this.faceVertexUvs[0][h];r.push(f(g[0]),f(g[1]),f(g[2]))}if(w&&r.push(p(m.normal)),O){let g=m.vertexNormals;r.push(p(g[0]),p(g[1]),p(g[2]))}if(S&&r.push(d(m.color)),T){let g=m.vertexColors;r.push(d(g[0]),d(g[1]),d(g[2]))}}function u(h,m,y){return y?h|1<<m:h&~(1<<m)}function p(h){let m=h.x.toString()+h.y.toString()+h.z.toString();return n[m]!==void 0||(n[m]=o.length/3,o.push(h.x,h.y,h.z)),n[m]}function d(h){let m=h.r.toString()+h.g.toString()+h.b.toString();return s[m]!==void 0||(s[m]=a.length,a.push(h.getHex())),s[m]}function f(h){let m=h.x.toString()+h.y.toString();return c[m]!==void 0||(c[m]=l.length/2,l.push(h.x,h.y)),c[m]}return t.data={},t.data.vertices=e,t.data.normals=o,a.length>0&&(t.data.colors=a),l.length>0&&(t.data.uvs=[l]),t.data.faces=r,t}clone(){return new ki().copy(this)}copy(t){this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.name=t.name;let e=t.vertices;for(let d=0,f=e.length;d<f;d++)this.vertices.push(e[d].clone());let r=t.colors;for(let d=0,f=r.length;d<f;d++)this.colors.push(r[d].clone());let o=t.faces;for(let d=0,f=o.length;d<f;d++)this.faces.push(o[d].clone());for(let d=0,f=t.faceVertexUvs.length;d<f;d++){let h=t.faceVertexUvs[d];this.faceVertexUvs[d]===void 0&&(this.faceVertexUvs[d]=[]);for(let m=0,y=h.length;m<y;m++){let b=h[m],v=[];for(let w=0,O=b.length;w<O;w++){let S=b[w];v.push(S.clone())}this.faceVertexUvs[d].push(v)}}let n=t.morphTargets;for(let d=0,f=n.length;d<f;d++){let h={};if(h.name=n[d].name,n[d].vertices!==void 0){h.vertices=[];for(let m=0,y=n[d].vertices.length;m<y;m++)h.vertices.push(n[d].vertices[m].clone())}if(n[d].normals!==void 0){h.normals=[];for(let m=0,y=n[d].normals.length;m<y;m++)h.normals.push(n[d].normals[m].clone())}this.morphTargets.push(h)}let a=t.morphNormals;for(let d=0,f=a.length;d<f;d++){let h={};if(a[d].vertexNormals!==void 0){h.vertexNormals=[];for(let m=0,y=a[d].vertexNormals.length;m<y;m++){let b=a[d].vertexNormals[m],v={};v.a=b.a.clone(),v.b=b.b.clone(),v.c=b.c.clone(),h.vertexNormals.push(v)}}if(a[d].faceNormals!==void 0){h.faceNormals=[];for(let m=0,y=a[d].faceNormals.length;m<y;m++)h.faceNormals.push(a[d].faceNormals[m].clone())}this.morphNormals.push(h)}let s=t.skinWeights;for(let d=0,f=s.length;d<f;d++)this.skinWeights.push(s[d].clone());let l=t.skinIndices;for(let d=0,f=l.length;d<f;d++)this.skinIndices.push(l[d].clone());let c=t.lineDistances;for(let d=0,f=c.length;d<f;d++)this.lineDistances.push(c[d]);let u=t.boundingBox;u!==null&&(this.boundingBox=u.clone());let p=t.boundingSphere;return p!==null&&(this.boundingSphere=p.clone()),this.elementsNeedUpdate=t.elementsNeedUpdate,this.verticesNeedUpdate=t.verticesNeedUpdate,this.uvsNeedUpdate=t.uvsNeedUpdate,this.normalsNeedUpdate=t.normalsNeedUpdate,this.colorsNeedUpdate=t.colorsNeedUpdate,this.lineDistancesNeedUpdate=t.lineDistancesNeedUpdate,this.groupsNeedUpdate=t.groupsNeedUpdate,this}toBufferGeometry(){let t=new Lf().fromGeometry(this),e=new he.BufferGeometry,r=new Float32Array(t.vertices.length*3);if(e.setAttribute("position",Wu.call(new he.BufferAttribute(r,3),t.vertices)),t.normals.length>0){let o=new Float32Array(t.normals.length*3);e.setAttribute("normal",Wu.call(new he.BufferAttribute(o,3),t.normals))}if(t.colors.length>0){let o=new Float32Array(t.colors.length*3);e.setAttribute("color",kx.call(new he.BufferAttribute(o,3),t.colors))}if(t.uvs.length>0){let o=new Float32Array(t.uvs.length*2);e.setAttribute("uv",Hx.call(new he.BufferAttribute(o,2),t.uvs))}if(t.uvs2.length>0){let o=new Float32Array(t.uvs2.length*2);e.setAttribute("uv2",Hx.call(new he.BufferAttribute(o,2),t.uvs2))}e.groups=t.groups;for(let o in t.morphTargets){let n=[],a=t.morphTargets[o];for(let s=0,l=a.length;s<l;s++){let c=a[s],u=new he.Float32BufferAttribute(c.data.length*3,3);u.name=c.name,n.push(Wu.call(u,c.data))}e.morphAttributes[o]=n}if(t.skinIndices.length>0){let o=new he.Float32BufferAttribute(t.skinIndices.length*4,4);e.setAttribute("skinIndex",Wx.call(o,t.skinIndices))}if(t.skinWeights.length>0){let o=new he.Float32BufferAttribute(t.skinWeights.length*4,4);e.setAttribute("skinWeight",Wx.call(o,t.skinWeights))}return t.boundingSphere!==null&&(e.boundingSphere=t.boundingSphere.clone()),t.boundingBox!==null&&(e.boundingBox=t.boundingBox.clone()),e}computeTangents(){console.error("THREE.Geometry: .computeTangents() has been removed.")}computeLineDistances(){console.error("THREE.Geometry: .computeLineDistances() has been removed. Use THREE.Line.computeLineDistances() instead.")}applyMatrix(t){return console.warn("THREE.Geometry: .applyMatrix() has been renamed to .applyMatrix4()."),this.applyMatrix4(t)}dispose(){this.dispatchEvent({type:"dispose"})}static createBufferGeometryFromObject(t){let e=new he.BufferGeometry,r=t.geometry;if(t.isPoints||t.isLine){let o=new he.Float32BufferAttribute(r.vertices.length*3,3),n=new he.Float32BufferAttribute(r.colors.length*3,3);if(e.setAttribute("position",Wu.call(o,r.vertices)),e.setAttribute("color",kx.call(n,r.colors)),r.lineDistances&&r.lineDistances.length===r.vertices.length){let a=new he.Float32BufferAttribute(r.lineDistances.length,1);e.setAttribute("lineDistance",JM.call(a,r.lineDistances))}r.boundingSphere!==null&&(e.boundingSphere=r.boundingSphere.clone()),r.boundingBox!==null&&(e.boundingBox=r.boundingBox.clone())}else t.isMesh&&(e=r.toBufferGeometry());return e}};ki.prototype.isGeometry=!0;var Lf=class{constructor(){this.vertices=[],this.normals=[],this.colors=[],this.uvs=[],this.uvs2=[],this.groups=[],this.morphTargets={},this.skinWeights=[],this.skinIndices=[],this.boundingBox=null,this.boundingSphere=null,this.verticesNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.uvsNeedUpdate=!1,this.groupsNeedUpdate=!1}computeGroups(t){let e=[],r,o,n,a=t.faces;for(o=0;o<a.length;o++){let s=a[o];s.materialIndex!==n&&(n=s.materialIndex,r!==void 0&&(r.count=o*3-r.start,e.push(r)),r={start:o*3,materialIndex:n})}r!==void 0&&(r.count=o*3-r.start,e.push(r)),this.groups=e}fromGeometry(t){let e=t.faces,r=t.vertices,o=t.faceVertexUvs,n=o[0]&&o[0].length>0,a=o[1]&&o[1].length>0,s=t.morphTargets,l=s.length,c;if(l>0){c=[];for(let b=0;b<l;b++)c[b]={name:s[b].name,data:[]};this.morphTargets.position=c}let u=t.morphNormals,p=u.length,d;if(p>0){d=[];for(let b=0;b<p;b++)d[b]={name:u[b].name,data:[]};this.morphTargets.normal=d}let f=t.skinIndices,h=t.skinWeights,m=f.length===r.length,y=h.length===r.length;r.length>0&&e.length===0&&console.error("THREE.DirectGeometry: Faceless geometries are not supported.");for(let b=0;b<e.length;b++){let v=e[b];this.vertices.push(r[v.a],r[v.b],r[v.c]);let w=v.vertexNormals;if(w.length===3)this.normals.push(w[0],w[1],w[2]);else{let S=v.normal;this.normals.push(S,S,S)}let O=v.vertexColors;if(O.length===3)this.colors.push(O[0],O[1],O[2]);else{let S=v.color;this.colors.push(S,S,S)}if(n===!0){let S=o[0][b];S!==void 0?this.uvs.push(S[0],S[1],S[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv ",b),this.uvs.push(new he.Vector2,new he.Vector2,new he.Vector2))}if(a===!0){let S=o[1][b];S!==void 0?this.uvs2.push(S[0],S[1],S[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv2 ",b),this.uvs2.push(new he.Vector2,new he.Vector2,new he.Vector2))}for(let S=0;S<l;S++){let T=s[S].vertices;c[S].data.push(T[v.a],T[v.b],T[v.c])}for(let S=0;S<p;S++){let T=u[S].vertexNormals[b];d[S].data.push(T.a,T.b,T.c)}m&&this.skinIndices.push(f[v.a],f[v.b],f[v.c]),y&&this.skinWeights.push(h[v.a],h[v.b],h[v.c])}return this.computeGroups(t),this.verticesNeedUpdate=t.verticesNeedUpdate,this.normalsNeedUpdate=t.normalsNeedUpdate,this.colorsNeedUpdate=t.colorsNeedUpdate,this.uvsNeedUpdate=t.uvsNeedUpdate,this.groupsNeedUpdate=t.groupsNeedUpdate,t.boundingSphere!==null&&(this.boundingSphere=t.boundingSphere.clone()),t.boundingBox!==null&&(this.boundingBox=t.boundingBox.clone()),this}},Ka=class{constructor(t,e,r,o,n,a=0){this.a=t,this.b=e,this.c=r,this.normal=o&&o.isVector3?o:new he.Vector3,this.vertexNormals=Array.isArray(o)?o:[],this.color=n&&n.isColor?n:new he.Color,this.vertexColors=Array.isArray(n)?n:[],this.materialIndex=a}clone(){return new this.constructor().copy(this)}copy(t){this.a=t.a,this.b=t.b,this.c=t.c,this.normal.copy(t.normal),this.color.copy(t.color),this.materialIndex=t.materialIndex;for(let e=0,r=t.vertexNormals.length;e<r;e++)this.vertexNormals[e]=t.vertexNormals[e].clone();for(let e=0,r=t.vertexColors.length;e<r;e++)this.vertexColors[e]=t.vertexColors[e].clone();return this}};function JM(i){return this.array.set(i),this}function kx(i){let t=this.array,e=0;for(let r=0,o=i.length;r<o;r++){let n=i[r];n===void 0&&(console.warn("THREE.BufferAttribute.copyColorsArray(): color is undefined",r),n=new he.Color),t[e++]=n.r,t[e++]=n.g,t[e++]=n.b}return this}function Hx(i){let t=this.array,e=0;for(let r=0,o=i.length;r<o;r++){let n=i[r];n===void 0&&(console.warn("THREE.BufferAttribute.copyVector2sArray(): vector is undefined",r),n=new he.Vector2),t[e++]=n.x,t[e++]=n.y}return this}function Wu(i){let t=this.array,e=0;for(let r=0,o=i.length;r<o;r++){let n=i[r];n===void 0&&(console.warn("THREE.BufferAttribute.copyVector3sArray(): vector is undefined",r),n=new he.Vector3),t[e++]=n.x,t[e++]=n.y,t[e++]=n.z}return this}function Wx(i){let t=this.array,e=0;for(let r=0,o=i.length;r<o;r++){let n=i[r];n===void 0&&(console.warn("THREE.BufferAttribute.copyVector4sArray(): vector is undefined",r),n=new he.Vector4),t[e++]=n.x,t[e++]=n.y,t[e++]=n.z,t[e++]=n.w}return this}var eI=["a","b","c"];function tI(i,t){switch(t){case"c":return i.c;case"b":return i.b;case"a":default:return i.a}}function Bf(i,t,e){let r=Math.min(i,t),o=Math.max(i,t),n=r+"_"+o;return e.get(n)}function Vf(i,t,e,r,o,n){let a=Math.min(i,t),s=Math.max(i,t),l=a+"_"+s,c;if(r.has(l))c=r.get(l);else{let u=e[a],p=e[s];c={a:u,b:p,newEdge:null,faces:[]},r.set(l,c)}c.faces.push(o),n[i].edges.push(c),n[t].edges.push(c)}function rI(i,t,e,r){let o,n,a;for(o=0,n=i.length;o<n;o++)e[o]={edges:[]};for(o=0,n=t.length;o<n;o++)a=t[o],Vf(a.a,a.b,i,r,a,e),Vf(a.b,a.c,i,r,a,e),Vf(a.c,a.a,i,r,a,e)}function qu(i,t,e,r,o){i.push(new Ka(t,e,r,void 0,void 0,o))}function Qa(i,t){return Math.abs(t-i)/2+Math.min(i,t)}function $u(i,t,e,r){i.push([t.clone(),e.clone(),r.clone()])}var Xu=class{constructor(t=1){this.subdivisions=t}modify(t){t instanceof li.BufferGeometry?t=new ki().fromBufferGeometry(t):t=t.clone(),t.mergeVertices();let e=this.subdivisions;for(;e-- >0;)this._smooth(t);return t.computeFaceNormals(),t.computeVertexNormals(),t}_smooth(t){let e=new li.Vector3,r,o,n,a,s,l=t.vertices,c=t.faces,u=t.faceVertexUvs[0],p=u!==void 0&&u.length>0,d=[],f=new Map;rI(l,c,d,f);let h=[],m,y,b,v,w,O,S;for(let Z of Array.from(f.keys())){for(y=f.get(Z),b=new li.Vector3,w=3/8,O=1/8,S=y.faces.length,S!=2&&(w=.5,O=0,S!=1),b.addVectors(y.a,y.b).multiplyScalar(w),e.set(0,0,0),a=0;a<S;a++){for(v=y.faces[a],s=0;s<3&&(m=l[tI(v,eI[s])],!(m!==y.a&&m!==y.b));s++);m&&e.add(m)}e.multiplyScalar(O),b.add(e),y.newEdge=h.length,h.push(b)}let T,M,g,D,E,I,N,_=[];for(o=0,n=l.length;o<n;o++){for(I=l[o],E=d[o].edges,r=E.length,r==3?T=3/16:r>3&&(T=3/(8*r)),M=1-r*Number(T),g=T,r<=2&&(r==2?(M=3/4,g=1/8):r==1||r==0),N=I.clone().multiplyScalar(M),e.set(0,0,0),a=0;a<r;a++)D=E[a],m=D.a!==I?D.a:D.b,e.add(m);e.multiplyScalar(Number(g)),N.add(e),_.push(N)}let R=_.concat(h),V=_.length,U,B,q,j=[],F=[],H,W,ee,te,Y=new li.Vector2,re=new li.Vector2,K=new li.Vector2;for(o=0,n=c.length;o<n;o++)v=c[o],U=Number(Bf(v.a,v.b,f).newEdge)+V,B=Number(Bf(v.b,v.c,f).newEdge)+V,q=Number(Bf(v.c,v.a,f).newEdge)+V,qu(j,U,B,q,v.materialIndex),qu(j,v.a,U,q,v.materialIndex),qu(j,v.b,B,U,v.materialIndex),qu(j,v.c,q,B,v.materialIndex),p&&(H=u[o],W=H[0],ee=H[1],te=H[2],Y.set(Qa(W.x,ee.x),Qa(W.y,ee.y)),re.set(Qa(ee.x,te.x),Qa(ee.y,te.y)),K.set(Qa(W.x,te.x),Qa(W.y,te.y)),$u(F,Y,re,K),$u(F,W,Y,K),$u(F,ee,re,Y),$u(F,te,K,re));t.vertices=R,t.faces=j,p&&(t.faceVertexUvs[0]=F)}};var Ht=new Ro.Vector3,qx=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=i.geometry??t?.geometry??new Ro.BufferGeometry().copy(new Ro.BoxGeometry(100,100,100)),r;t===void 0?(e.computeBoundingBox(),e.boundingBox.getSize(Ht),r={width:Ht.x,height:Ht.y,depth:Ht.z,subdivisions:0}):r=t.parameters;let o={...r,...i.parameters};return{parameters:{width:Math.abs(o.width),height:Math.abs(o.height),depth:Math.abs(o.depth),subdivisions:Math.abs(o.subdivisions)},geometry:e}}static build(i){let{width:t,height:e,depth:r,subdivisions:o}=i.parameters,n=i.geometry??new Ro.BufferGeometry().copy(new Ro.BoxGeometry(100,100,100)),a=n.userData.parameters;a===void 0?(n.computeBoundingBox(),n.boundingBox.getSize(Ht)):Ht.set(a.width,a.height,a.depth),(t!==Ht.x||e!==Ht.y||r!==Ht.z)&&n.scale(Ht.x===0?1:t/Ht.x,Ht.y===0?1:e/Ht.y,Ht.z===0?1:r/Ht.z);let s=n.originalGeometry;try{o>0?(s===void 0||a?.subdivisions!==o)&&(s===void 0&&(s=n),n=new Xu(o).modify(s).toBufferGeometry()):(s!==void 0&&(n=s),s=void 0,n.getAttribute("normal")===void 0&&n.computeVertexNormals())}catch{s!==void 0&&(n=s),s=void 0,n.getAttribute("normal")===void 0&&n.computeVertexNormals()}return s!==void 0&&Object.assign(n,{originalGeometry:s}),delete i.geometry,Object.assign(n,{userData:{...i,type:"NonParametricGeometry"}})}static loadFromUrl(i,t,e){new Ro.BufferGeometryLoader(e).load(i,o=>{let n=this.normalizeInputs({geometry:o});o.boundingBox.getSize(Ht);let a=100/Ht.x;Object.assign(n.parameters,{width:100,height:Ht.y*a,depth:Ht.z*a}),t(this.build(n))})}};var Yu=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:3},i.parameters);return{shape:i.shape&&i.shape instanceof Xe?i.shape:new Xe,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)})}}static build(i){let{width:t,height:e,spikes:r,cornerRadius:o,depth:n,extrudeBevelSize:a,extrudeBevelSegments:s}=i.parameters,l=i.shape,c=t*.5,u=e*.5,p=0,d=0,f=2*Math.PI/r;for(let m=0;m<r;m++){let y=f*m,b=p+Math.sin(y)*c,v=d+Math.cos(y)*u;l.addPoint(l.createPoint(b,v))}l.isClosed=!0;for(let m=0,y=l.points.length;m<y;m++)l.points[m].roundness=o;l.roundness=o,l.update();let h=wr.create({shape:l,parameters:{roundness:o,depth:n,extrudeBevelSize:a,extrudeBevelSegments:s}});return Object.assign(h,{userData:{...i,type:"PolygonGeometry"}})}};var We=require("three"),$x=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,radialSegments:4,heightSegments:1,cornerRadius:0,cornerSegments:8,openEnded:!1},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(i){let{width:t,height:e,depth:r,radialSegments:o,heightSegments:n,openEnded:a,cornerRadius:s,cornerSegments:l}=i.parameters,c=new Gf(t*.5,e,o,n,a,s,l);return c.scale(1,1,r/t),Object.assign(c,{userData:{...i,type:"PyramidGeometry"}})}};function Nl(i,t,e){e.x=i.x*t.x,e.y=i.y,e.z=i.x*t.y}function zf(i,t,e,r,o,n){let a=t.clone().sub(i),s=e.clone().sub(i),l=a.angleTo(s);if(a.normalize(),s.normalize(),r===o){let c=a.add(s).normalize();n.copy(i).addScaledVector(c,r/Math.sin(l/2))}else{let c=a.angleTo(s);n.copy(i),n.addScaledVector(a,o/Math.sin(c)),n.addScaledVector(s,r/Math.sin(c))}}function oI(i,t,e){let r=i.clone().sub(t),o=e.clone().sub(t);return r.projectOnVector(o),r.add(t)}var Gf=class extends We.BufferGeometry{constructor(t=.5,e=1,r=4,o=1,n=!1,a=0,s=4){super(),r=Math.floor(Math.max(3,r)),o=Math.floor(o),s=Math.floor(s);let l=[],c=[],u=[],p=[],d=0,f=e/2,h=Math.PI/r,m=t*Math.cos(Math.PI/r),y=2*Math.PI/r,b=(r-2)*Math.PI/r,v=Math.PI-b,w=new We.Vector3(0,-f,0),O=new We.Vector3(0,f,0),S=new We.Vector2(t,-f),T=new We.Vector2(m,-f),M=new We.Vector2(0,O.y).sub(T),g=new We.Vector2(0,O.y).sub(S),D=new We.Vector2(M.y,-M.x).normalize(),E=new We.Vector2(g.y,-g.x).normalize(),N=t*Math.cos(Math.PI/r)*Math.tan((Math.PI-M.angle())/2)-1e-8;a=Math.min(a,N);let _;{let F=new We.Vector3(D.x,D.y,0),H=new We.Vector3(Math.cos(y)*F.x,F.y,Math.sin(y)*F.x);_=F.angleTo(H)}let R=a/Math.tan((Math.PI-M.angle())/2),V=a/Math.tan((Math.PI-_)/2),U=new We.Vector3;if(!n){c.push(w.x,w.y,w.z),u.push(0,-1,0),p.push(0,0);let F=d++,H=[],W=S.clone(),ee=R/Math.cos(Math.PI/r);W.x-=ee;for(let te=0;te<r;te++){let Y=te/r*Math.PI*2+h,re=new We.Vector2(Math.sin(Y),Math.cos(Y));Nl(W,re,U),c.push(U.x,U.y,U.z),u.push(0,-1,0),p.push(0,0),H.push(d++)}for(let te=0;te<H.length;te++)l.push(H[te],F,H[(te+1)%H.length])}let B=[];{let F=new We.Vector3,H=new We.Vector3,W=new We.Vector3,ee=new We.Vector3,te=new We.Vector3,Y=new We.Vector3;for(let re=0;re<r;re++){let K=re/r*Math.PI*2+h,Z=(re+.5)/r*Math.PI*2+h,Q=(re+1)/r*Math.PI*2+h,$=new We.Vector2(Math.sin(K),Math.cos(K)),pe=new We.Vector2(Math.sin(Z),Math.cos(Z)),le=new We.Vector2(Math.sin(Q),Math.cos(Q));Nl(S,$,H),Nl(S,le,W),Nl(D,pe,F),zf(O,H,W,V,V,ee),c.push(ee.x,ee.y,ee.z),zf(H,O,W,V,R,te),c.push(te.x,te.y,te.z),zf(W,H,O,R,V,Y),c.push(Y.x,Y.y,Y.z),u.push(F.x,F.y,F.z),u.push(F.x,F.y,F.z),u.push(F.x,F.y,F.z),p.push(0,0),p.push(0,0),p.push(0,0);let ie=d++,ue=d++,ae=d++;if(l.push(ie,ue,ae),a>0){{let ye=H.clone().add(W).multiplyScalar(.5),ve=O.clone().sub(ye).normalize(),C=w.clone().sub(ye).normalize().add(ve).normalize().multiplyScalar(-1),ne=Y.clone().sub(te);q(ye,ne,C,M.angle())}let ge,me;{let ye=new We.Vector3;Nl(E,le,ye);let ve=Y.clone().add(ee).multiplyScalar(.5);ve=oI(ve,W,O);let xe=Y.clone().sub(ee);[ge,me]=q(ve,xe,ye,_,ee.y)}{let ye=ge,ve=ye.clone().setY(0).normalize(),xe=new We.Vector3(0,-1,0),C=ve.clone().cross(xe);j(ye,ve,xe,C)}B.concat(me);{let ye=M.angle(),ve=Math.PI-ye,xe=O.clone();xe.y-=a/Math.sin(ye-Math.PI/2);let C=new We.Vector3,ne=[];for(let ke=0;ke<s;ke++){let Ge=[],Ce=Math.PI/2-ve*ke/s,zt=Math.cos(Ce),_e=Math.sin(Ce),Bt=Z;for(let Gt=0;Gt<=ke;Gt++){let pn=Math.cos(Bt),xt=Math.sin(Bt);F.x=zt*xt,F.y=_e,F.z=zt*pn,C.copy(xe).addScaledVector(F,a),c.push(C.x,C.y,C.z),u.push(F.x,F.y,F.z),p.push(0,0),Ge.push(d++),Bt+=Math.PI*2/ke/r}ne.push(Ge)}me.reverse(),ne.push(me);let Ve=ne.length-1;for(let ke=0;ke<Ve;ke++){let Ge=ne[ke],Ce=ne[ke+1],zt=Ge.length-1;l.push(Ce[1],Ge[0],Ce[0]);for(let _e=1;_e<=zt;_e++)l.push(Ge[_e],Ge[_e-1],Ce[_e]),l.push(Ce[_e+1],Ge[_e],Ce[_e])}}}}}this.setIndex(l),this.setAttribute("position",new We.Float32BufferAttribute(c,3)),this.setAttribute("normal",new We.Float32BufferAttribute(u,3)),this.setAttribute("uv",new We.Float32BufferAttribute(p,2));function q(F,H,W,ee,te){let Y=-ee/2,re=(Math.PI-ee)/2,K=H.clone().normalize().cross(W);F.addScaledVector(W,-a/Math.sin(re));let Z=new We.Vector3,Q=new We.Vector3,$=1,pe=d,le=[];for(let ie=0;ie<=s;ie++){let ue=Y+ie/s*ee;Q.set(0,0,0),Q.addScaledVector(K,Math.sin(ue)),Q.addScaledVector(W,Math.cos(ue));for(let ae=0;ae<=$;ae++){let ge=ae/$-.5;if(Z.copy(F),Z.addScaledVector(H,ge),Z.addScaledVector(Q,a),te!=null){let me=Math.max(0,Z.y-te);Z.addScaledVector(H,-me/H.y)}c.push(Z.x,Z.y,Z.z),u.push(Q.x,Q.y,Q.z),p.push(0,0),ae===0&&le.push(d),d++}}for(let ie=0;ie<s;ie++)for(let ue=0;ue<$;ue++){let ae=pe+ue+($+1)*ie,ge=ae+($+1),me=ge+1,ye=ae+1;l.push(ae,ge,ye),l.push(ge,me,ye)}return[F.clone().addScaledVector(H,.5),le]}function j(F,H,W,ee){let te=Math.PI/2,Y=g.angle()-te,re=[],K=new We.Vector3,Z=new We.Vector3;for(let $=0;$<=s;$++){let pe=[],le=$/s;for(let ie=0;ie<=$;ie++){let ae=(($?ie/$:0)-.5)*v,ge=Math.cos(ae),me=Math.sin(ae),ye=Math.atan(Math.tan(Y)*ge),ve=(te+ye)*le,xe=Math.cos(ve),C=Math.sin(ve);K.set(0,0,0),K.addScaledVector(H,C*ge),K.addScaledVector(W,xe),K.addScaledVector(ee,C*me),Z.copy(F).addScaledVector(K,a),c.push(Z.x,Z.y,Z.z),u.push(K.x,K.y,K.z),p.push(0,0),pe.push(d++)}re.push(pe)}let Q=re.length-1;for(let $=0;$<Q;$++){let pe=re[$],le=re[$+1],ie=pe.length-1;l.push(pe[0],le[1],le[0]);for(let ue=1;ue<=ie;ue++)l.push(pe[ue-1],pe[ue],le[ue]),l.push(pe[ue],le[ue+1],le[ue])}}}};var Za=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,cornerRadius:[0,0,0,0],cornerType:1,extrudeBevelSize:0,extrudeBevelSegments:1},i.parameters),r=Object.assign(t?.ui??{enabledIndieCorners:!1},i.ui);return{shape:i.shape&&i.shape instanceof Xe?i.shape:new Xe,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)}),ui:r}}static build(i){let t=i.shape,{width:e,height:r,cornerRadius:o,cornerType:n,depth:a,extrudeBevelSize:s,extrudeBevelSegments:l}=i.parameters,c={x:e*.5,y:r*.5},u={x:-c.x,y:-c.y},p={x:c.x,y:c.y};function d(O,S,T){return S>e&&T>r?Math.min(O*e/S,O*r/T):S>e?O*e/S:T>r?O*r/T:O}let f=[];f[0]=o[0]===0?0:d(o[0],o[0]+o[3],o[0]+o[1]),f[1]=o[1]===0?0:d(o[1],o[1]+o[2],o[1]+o[0]),f[2]=o[2]===0?0:d(o[2],o[2]+o[1],o[2]+o[3]),f[3]=o[3]===0?0:d(o[3],o[3]+o[0],o[3]+o[2]);let h=u.x,m=p.x,y=p.y,b=u.y;t.addPoint(t.createPoint(h,y)),t.addPoint(t.createPoint(m,y)),t.addPoint(t.createPoint(m,b)),t.addPoint(t.createPoint(h,b)),t.isClosed=!0;let v=!0;for(let O=0,S=t.points.length;O<S;O++)t.points[O].roundness=f[O],O>0&&f[O]!==f[O-1]&&(v=!1);v&&(t.roundness=f[0]),t.useCubicForRoundedCorners=n!==1,t.update();let w=wr.create({shape:t,parameters:{depth:a,extrudeBevelSize:s,extrudeBevelSegments:l}});return Object.assign(w,{userData:{...i,type:"RectangleGeometry"}})}};var ci=require("three"),Xx=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,widthSegments:64,heightSegments:64,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:180},i.parameters);return e.thetaLength=ci.MathUtils.clamp(e.thetaLength,0,180),{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(i){let{width:t=100,height:e=t,depth:r=t,widthSegments:o=64,heightSegments:n=64,phiStart:a,phiLength:s,thetaStart:l,thetaLength:c}=i.parameters,u;return c===0?(u=new ci.BufferGeometry,u.setAttribute("position",new ci.Float32BufferAttribute([],3))):u=new ci.SphereGeometry(.5*t,o,n,a,s,l,c*ci.MathUtils.DEG2RAD),u.scale(1,e/t,r/t),Object.assign(u,{userData:{...i,type:"SphereGeometry"}})}};var Yx=require("three"),Kx=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,widthSegments:8,heightSegments:8},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:0})}}static build(i){let{width:t=100,height:e=t,widthSegments:r=8,heightSegments:o=8}=i.parameters,n=new Yx.PlaneGeometry(t,e,r,o);return n.scale(1,1,1),Object.assign(n,{userData:{...i,type:"PlaneGeometry"}})}};var Hi=require("three"),Qx=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,angle:90,cornerRadius:24,cornerSegments:8},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(i){let{width:t,height:e,depth:r,angle:o,cornerRadius:n,cornerSegments:a}=i.parameters,s=new Ff(t,e,r,o,n,a);return Object.assign(s,{userData:{...i,type:"BackdropGeometry"}})}},Ff=class extends Hi.BufferGeometry{constructor(t=1,e=1,r=1,o=90,n=10,a=24){super(),this.type="BackdropGeometry";let s=[],l=[],c=[],u=.001;n==0&&(a=1),a=Math.max(1,Math.floor(a)),n=Math.min(n,100),o=Math.min(180-u,o),o*=Math.PI/180;let p=[],d=Math.PI/2,f=(Z=0,Q=0,$=0)=>new Hi.Vector3(Z,Q,$),h=f(),m=f(),[y,b,v]=[e/2,t/2,r/2],w=-b,O=+b,[S,T,M]=[f(w,-y,+v),f(w,-y,-v),f(w,+y,-v)],g=(Z,Q=!1)=>Math.sin(Z-Math.PI/(1+ +Q)),D=(Z,Q=!1)=>Math.cos(Z-Math.PI/(1+ +Q));M.y=Math.sin(o)*e-y;let E=Math.cos(o)*e-v,I=S.z-u;o<=d?(M.z=Math.min(E,I),M.z==I&&(M.y-=(E-I)/Math.tan(d-o))):T.z=Math.min(T.z-E-v,S.z-u),h.subVectors(S,T),m.subVectors(M,T);let N=Math.min(h.length(),m.length())*n/100,_=N*Math.tan(o/2),R=N/Math.cos(o/2),V=h.clone().normalize().add(m.normalize()).setLength(R).add(T);h.set(0,g(o,!0),D(o,!0)),p.push([M,h.clone()]);let U=(Math.PI-o)/a;for(let Z=0;Z<=a;Z++){let Q=d+o+Z*U;h.set(0,Math.sin(Q)*_,Math.cos(Q)*_),h.add(V),m.set(0,g(Q),D(Q)),p.push([h.clone(),m.clone()])}p.push([S,f(0,1,0)]);let B=Math.sin(U/2)*_*2,q=p.length-1,j=p[0][0].distanceTo(p[1][0]),F=p[q-1][0].distanceTo(p[q][0]),H=j+B*a+F;p[0].push(1);for(let Z=0;Z<=a;Z++)p[Z+1].push(1-(j+Z*B)/H);p[q].push(0);let[W,ee,te]=p[0],Y,re,K;for(let Z=1;Z<p.length;Z++)[Y,re,K]=p[Z],s.push(w,W.y,W.z,w,Y.y,Y.z,O,W.y,W.z,O,W.y,W.z,w,Y.y,Y.z,O,Y.y,Y.z),l.push(0,ee.y,ee.z,0,re.y,re.z,0,ee.y,ee.z,0,ee.y,ee.z,0,re.y,re.z,0,re.y,re.z),c.push(0,te,0,K,1,te,1,te,0,K,1,K),[W,ee,te]=[Y,re,K];this.setAttribute("position",new Hi.Float32BufferAttribute(s,3)),this.setAttribute("normal",new Hi.Float32BufferAttribute(l,3)),this.setAttribute("uv",new Hi.Float32BufferAttribute(c,2))}};var Ku=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,innerRadiusPercent:38.19,spikes:5,cornerRadius:0,angle:360,extrudeBevelSize:0,extrudeBevelSegments:1},i.parameters);return{shape:i.shape&&i.shape instanceof Xe?i.shape:new Xe,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)})}}static build(i){let{width:t,height:e,innerRadiusPercent:r,spikes:o,cornerRadius:n,angle:a,depth:s,extrudeBevelSize:l,extrudeBevelSegments:c}=i.parameters,u=i.shape,p=t*.5,d=e*.5,f=0,h=0,m=a*Math.PI/360/o,y=Math.PI/2*3*-1,b=p*r/100,v=d*r/100;if(o===3&&r===50){m=2*Math.PI/o;for(let O=0;O<o;O++){let S=m*O,T=f+Math.sin(S)*p,M=h+Math.cos(S)*d;u.addPoint(u.createPoint(T,M))}}else for(let O=0;O<o;O++){let S=f+Math.cos(y)*p,T=h+Math.sin(y)*d;u.addPoint(u.createPoint(S,T)),y+=m,S=f+Math.cos(y)*b,T=h+Math.sin(y)*v,O<=o,u.addPoint(u.createPoint(S,T)),y+=m}u.isClosed=!0;for(let O=0,S=u.points.length;O<S;O++)u.points[O].roundness=n;u.roundness=n,u.update();let w=wr.create({shape:u,parameters:{roundness:n,depth:s,extrudeBevelSize:l,extrudeBevelSegments:c}});return Object.assign(w,{userData:{...i,type:"StarGeometry"}})}};var Zx=require("three"),Jx=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,depth:0},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)})}}static build(i){let{width:t,height:e}=i.parameters,r=new Zx.PlaneGeometry(t,e);return Object.assign(r,{userData:{...i,type:"TextFrameGeometry"}})}};var Ja=require("three");var eb=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,radialSegments:32,tubularSegments:64,arc:360,cornerRadius:30,cornerSegments:8},i.parameters),r=Math.abs(e.width),o=Math.abs(e.height??e.width);e.shapeBlendNode&&(o=r);let n=Math.round(Math.abs(e.depth??e.width*.25));return{parameters:Object.assign(e,{width:r,height:o,depth:n})}}static build(i){let{width:t,height:e,depth:r,radialSegments:o,tubularSegments:n,arc:a,cornerRadius:s,cornerSegments:l}=i.parameters,c=iI(t,e,r,t*.5,a,n,0,0,o,s,l);return c.scale(1,e/t,1),Object.assign(c,{userData:{...i,type:"TorusGeometry"}})}};function iI(i,t,e,r,o,n,a,s,l,c,u){[t,e]=[e,t],a=t/2;let p=Ja.MathUtils.clamp(o/360,0,1);if(p===0){let d=new Ja.BufferGeometry;return d.setAttribute("position",new Ja.Float32BufferAttribute([],3)),d}return p===1&&(c=0),new Il(!0,i,t,e,r,p,n,a,s,l,c,u)}var tb=require("three"),rb=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,tubularSegments:64,radialSegments:32,p:2,q:3},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width),tube:e.tube??e.width*.125})}}static build(i){let{width:t,tube:e,tubularSegments:r,radialSegments:o,p:n,q:a}=i.parameters,s=t*.5;s!==e&&(s-=e);let l=new tb.TorusKnotGeometry(s,e,r,o,n,a);return Object.assign(l,{userData:{...i,type:"TorusKnotGeometry"}})}};var ob=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1,isRect:!1},i.parameters);return{shape:i.shape&&i.shape instanceof Xe?i.shape:new Xe,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width*(e.isRect?1:Math.sqrt(3)/2)),depth:Math.abs(e.depth??0)})}}static build(i){let{width:t=100,height:e,cornerRadius:r,depth:o,extrudeBevelSize:n,extrudeBevelSegments:a,isRect:s}=i.parameters,l=i.shape,c=t*.5,u=e*.5;s?(l.addPoint(l.createPoint(-c,u)),l.addPoint(l.createPoint(c,-u)),l.addPoint(l.createPoint(-c,-u))):(l.addPoint(l.createPoint(0,u)),l.addPoint(l.createPoint(c,-u)),l.addPoint(l.createPoint(-c,-u))),l.isClosed=!0;for(let d=0,f=l.points.length;d<f;d++)l.points[d].roundness=r;l.roundness=r,l.update();let p=wr.create({shape:l,parameters:{roundness:r,depth:o,extrudeBevelSize:n,extrudeBevelSegments:a}});return Object.assign(p,{userData:{...i,type:"TriangleGeometry"}})}};var Ie=require("three");function ib(i,t){let e=2*Math.PI;return(i%e+e)%e===(t%e+e)%e}function nI(i){return/^(rgba)?\(\s*(\d+),\s*(\d+),\s*(\d+)(?:,\s*(\d+(?:\.\d+)?))?\s*\)$/.exec(i.toLowerCase())}function aI(i,t,e){let r,o,n,a=Math.floor(i*6),s=i*6-a,l=e*(1-t),c=e*(1-s*t),u=e*(1-(1-s)*t);switch(a%6){case 0:r=e,o=u,n=l;break;case 1:r=c,o=e,n=l;break;case 2:r=l,o=e,n=u;break;case 3:r=l,o=c,n=e;break;case 4:r=u,o=l,n=e;break;case 5:default:r=e,o=l,n=c;break}return{r:r*255,g:o*255,b:n*255}}function sI(i,t,e){i/=255,t/=255,e/=255;let r=Math.max(i,t,e),o=Math.min(i,t,e),n=r,a=r-o,s=r==0?0:a/r,l;if(r==o)l=0;else{switch(r){case i:l=(t-e)/a+(t<e?6:0);break;case t:l=(e-i)/a+2;break;case e:default:l=(i-t)/a+4;break}l/=6}return{h:l,s,v:n}}function lI(i){return i=Math.floor(i),{r:i>>16&255,g:i>>8&255,b:i&255}}function cI(i,t,e){return(i<<16)+(t<<8)+e}function uI(i,t,e){return i=Math.round(i),t=Math.round(t),e=Math.round(e),"#"+[i,t,e].map(r=>r.toString(16).padStart(2,"0")).join("").toUpperCase()}function dI(i){let t=/^#?([a-f\d])([a-f\d])([a-f\d])$/i;i=i.replace(t,(r,o,n,a)=>String(o+o+n+n+a+a));let e=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(i);return e?{r:parseInt(e[1],16),g:parseInt(e[2],16),b:parseInt(e[3],16)}:null}var nb={parseRgba:nI,hsvToRgb:aI,rgbToHsv:sI,hexToRgb:lI,rgbToHex:cI,rgbToHexString:uI,hexStringToRgb:dI};function ui(i){return{all:i=i||new Map,on:function(t,e){var r=i.get(t);r?r.push(e):i.set(t,[e])},off:function(t,e){var r=i.get(t);r&&(e?r.splice(r.indexOf(e)>>>0,1):i.set(t,[]))},emit:function(t,e){var r=i.get(t);r&&r.slice().map(function(o){o(e)}),(r=i.get("*"))&&r.slice().map(function(o){o(t,e)})}}}var Qu=class{constructor(t,e,r){this.id=t;this.userAPI=e;this.result=void 0;this.error="null";this.isPrefetched=!1;this.isLoading=!1;this.isLoaded=!1;this.prefetchPromise=new Promise(t=>t());this.emitter=ui();this._innerCallUserAPI=async t=>{this.emitter.emit("start",{userAPIId:this.id}),this.isLoading=!0,this.isLoading=!1;try{this.result=await yI(this.userAPI,t),this.error="null",this.emitter.emit("success",{userAPIId:this.id})}catch(e){let r=e.message?.split("_:_")?.[0]?.replace("status:","")??"null";this.error=r,this.result=null,this.emitter.emit("error",{userAPIId:this.id})}this.isLoading=!1,this.isPrefetched=!0,this.isLoaded=!0};e?.integration?.type==="OpenAI"?this.result={content:""}:e.method==="GET"&&e.url!==""&&(this.prefetchPromise=this.prefetch(r)),this._debouncedCallUserAPI=this._innerCallUserAPI,this._updateDebouncedCallUserAPI(),this._debouncedPrefetch=$c(this.prefetch,1e3,{trailing:!0})}_updateDebouncedCallUserAPI(){this._debouncedCallUserAPI=this.userAPI.debounce!==void 0&&this.userAPI.debounce>0?$c(this._innerCallUserAPI,this.userAPI.debounce,{leading:!0,trailing:!0}):this._innerCallUserAPI}async prefetch(t){await this.callUserAPI(t)}async callUserAPI(t){await this._debouncedCallUserAPI(t)}update(t,e,r=!0){this.userAPI=t,this._updateDebouncedCallUserAPI(),this.userAPI.url!==""&&this.userAPI.method==="GET"&&r&&this._debouncedPrefetch(e)}retrieveValue(t){if(this.result)try{return ut.zoom(this.result,t)}catch(e){console.error(e)}}retrieveZoomedKeyValues(t){if(this.result){let e=t&&t.length?ut.zoom(this.result,t):this.result;if(mI(e))return Object.entries(e);if(hI(e))return e.map((r,o)=>[o.toString(),r]);throw fI(e)?new Error("This path points to a value, use retrieveValue() instead. "+t?.join(".")):new Error("Path error"+t?.join("."))}}dispose(){}on(t,e){this.emitter.on(t,e)}off(t,e){this.emitter.off(t,e)}get autostart(){return this.userAPI.autoStart}};function pI(i){let t=new Headers;return i.headers.forEach(e=>{e.data.key!==""&&t.append(e.data.key,e.data.value)}),t}function fI(i){return typeof i=="string"||typeof i=="number"||typeof i=="boolean"||i===null}function hI(i){return Array.isArray(i)}function mI(i){return typeof i=="object"&&i!==null}async function yI(i,t,e=new AbortController){let r,o=i.url,n=i.proxy?.enabled??!1,a;if(i.integration?.type==="OpenAI"){let l=Dl(i.integration.prompt===""?[]:JSON.parse(i.integration.prompt),t),c=i.integration.behavior===""?[]:Dl(JSON.parse(i.integration.behavior),t);a=`{
2
+ `,"\r"],!1,!1),C=0,ne=0,Ve=[{line:1,column:1}],ke=0,Ge=[],Ce=0,zt;if("startRule"in t){if(!(t.startRule in r))throw new Error(`Can't start parsing from rule "`+t.startRule+'".');o=r[t.startRule]}function _e(){return i.substring(ne,C)}function Bt(){return fn(ne,C)}function Gt(x,P){throw P=P!==void 0?P:fn(ne,C),zr([up(x)],i.substring(ne,C),P)}function pn(x,P){throw P=P!==void 0?P:fn(ne,C),dp(x,P)}function xt(x,P){return{type:"literal",text:x,ignoreCase:P}}function at(x,P,L){return{type:"class",parts:x,inverted:P,ignoreCase:L}}function to(){return{type:"any"}}function cp(){return{type:"end"}}function up(x){return{type:"other",description:x}}function hc(x){var P=Ve[x],L;if(P)return P;for(L=x-1;!Ve[L];)L--;for(P=Ve[L],P={line:P.line,column:P.column};L<x;)i.charCodeAt(L)===10?(P.line++,P.column=1):P.column++,L++;return Ve[x]=P,P}function fn(x,P){var L=hc(x),A=hc(P);return{start:{offset:x,line:L.line,column:L.column},end:{offset:P,line:A.line,column:A.column}}}function Ot(x){C<ke||(C>ke&&(ke=C,Ge=[]),Ge.push(x))}function dp(x,P){return new Un(x,null,null,P)}function zr(x,P,L){return new Un(Un.buildMessage(x,P),x,P,L)}function Zs(){var x,P,L,A,z;for(x=C,P=[],L=He();L!==e;)P.push(L),L=He();if(P!==e)if(L=cr(),L===e&&(L=null),L!==e){for(A=[],z=He();z!==e;)A.push(z),z=He();A!==e?(ne=x,P=n(L),x=P):(C=x,x=e)}else C=x,x=e;else C=x,x=e;return x}function cr(){var x,P,L,A,z,oe;if(x=C,P=hn(),P!==e){for(L=[],A=C,z=[],oe=He();oe!==e;)z.push(oe),oe=He();for(z!==e?(oe=hn(),oe!==e?(z=[z,oe],A=z):(C=A,A=e)):(C=A,A=e);A!==e;){for(L.push(A),A=C,z=[],oe=He();oe!==e;)z.push(oe),oe=He();z!==e?(oe=hn(),oe!==e?(z=[z,oe],A=z):(C=A,A=e)):(C=A,A=e)}L!==e?(ne=x,P=a(P,L),x=P):(C=x,x=e)}else C=x,x=e;return x}function hn(){var x,P,L,A,z,oe;if(x=C,P=qn(),P!==e){for(L=[],A=C,z=[],oe=He();oe!==e;)z.push(oe),oe=He();for(z!==e?(oe=mc(),oe!==e?(z=[z,oe],A=z):(C=A,A=e)):(C=A,A=e);A!==e;){for(L.push(A),A=C,z=[],oe=He();oe!==e;)z.push(oe),oe=He();z!==e?(oe=mc(),oe!==e?(z=[z,oe],A=z):(C=A,A=e)):(C=A,A=e)}L!==e?(ne=x,P=a(P,L),x=P):(C=x,x=e)}else C=x,x=e;return x}function mc(){var x;return x=mS(),x===e&&(x=yS(),x===e&&(x=gS(),x===e&&(x=xS(),x===e&&(x=bS(),x===e&&(x=SS(),x===e&&(x=PS(),x===e&&(x=TS(),x===e&&(x=AS())))))))),x}function qn(){var x,P,L,A,z,oe,Yn;if(x=C,s.test(i.charAt(C))?(P=i.charAt(C),C++):(P=e,Ce===0&&Ot(l)),P!==e){for(L=[],A=He();A!==e;)L.push(A),A=He();L!==e?(A=pr(),A!==e?(z=C,oe=ht(),oe===e&&(oe=null),oe!==e?(Yn=em(),Yn!==e?(oe=[oe,Yn],z=oe):(C=z,z=e)):(C=z,z=e),z===e&&(z=null),z!==e?(ne=x,P=c(P,A,z),x=P):(C=x,x=e)):(C=x,x=e)):(C=x,x=e)}else C=x,x=e;return x}function mS(){var x,P;return x=C,u.test(i.charAt(C))?(P=i.charAt(C),C++):(P=e,Ce===0&&Ot(p)),P!==e&&(ne=x,P=d()),x=P,x}function yS(){var x,P,L,A;if(x=C,f.test(i.charAt(C))?(P=i.charAt(C),C++):(P=e,Ce===0&&Ot(h)),P!==e){for(L=[],A=He();A!==e;)L.push(A),A=He();L!==e?(A=em(),A!==e?(ne=x,P=m(P,A),x=P):(C=x,x=e)):(C=x,x=e)}else C=x,x=e;return x}function em(){var x,P,L,A,z,oe;if(x=C,P=pr(),P!==e){for(L=[],A=C,z=ht(),z===e&&(z=null),z!==e?(oe=pr(),oe!==e?(z=[z,oe],A=z):(C=A,A=e)):(C=A,A=e);A!==e;)L.push(A),A=C,z=ht(),z===e&&(z=null),z!==e?(oe=pr(),oe!==e?(z=[z,oe],A=z):(C=A,A=e)):(C=A,A=e);L!==e?(ne=x,P=a(P,L),x=P):(C=x,x=e)}else C=x,x=e;return x}function gS(){var x,P,L,A;if(x=C,y.test(i.charAt(C))?(P=i.charAt(C),C++):(P=e,Ce===0&&Ot(b)),P!==e){for(L=[],A=He();A!==e;)L.push(A),A=He();L!==e?(A=tm(),A!==e?(ne=x,P=v(P,A),x=P):(C=x,x=e)):(C=x,x=e)}else C=x,x=e;return x}function tm(){var x,P,L,A,z,oe;if(x=C,P=$n(),P!==e){for(L=[],A=C,z=ht(),z===e&&(z=null),z!==e?(oe=$n(),oe!==e?(z=[z,oe],A=z):(C=A,A=e)):(C=A,A=e);A!==e;)L.push(A),A=C,z=ht(),z===e&&(z=null),z!==e?(oe=$n(),oe!==e?(z=[z,oe],A=z):(C=A,A=e)):(C=A,A=e);L!==e?(ne=x,P=a(P,L),x=P):(C=x,x=e)}else C=x,x=e;return x}function xS(){var x,P,L,A;if(x=C,w.test(i.charAt(C))?(P=i.charAt(C),C++):(P=e,Ce===0&&Ot(O)),P!==e){for(L=[],A=He();A!==e;)L.push(A),A=He();L!==e?(A=tm(),A!==e?(ne=x,P=S(P,A),x=P):(C=x,x=e)):(C=x,x=e)}else C=x,x=e;return x}function bS(){var x,P,L,A;if(x=C,T.test(i.charAt(C))?(P=i.charAt(C),C++):(P=e,Ce===0&&Ot(M)),P!==e){for(L=[],A=He();A!==e;)L.push(A),A=He();L!==e?(A=vS(),A!==e?(ne=x,P=m(P,A),x=P):(C=x,x=e)):(C=x,x=e)}else C=x,x=e;return x}function vS(){var x,P,L,A,z,oe;if(x=C,P=pp(),P!==e){for(L=[],A=C,z=ht(),z===e&&(z=null),z!==e?(oe=pp(),oe!==e?(z=[z,oe],A=z):(C=A,A=e)):(C=A,A=e);A!==e;)L.push(A),A=C,z=ht(),z===e&&(z=null),z!==e?(oe=pp(),oe!==e?(z=[z,oe],A=z):(C=A,A=e)):(C=A,A=e);L!==e?(ne=x,P=a(P,L),x=P):(C=x,x=e)}else C=x,x=e;return x}function pp(){var x,P,L,A,z,oe;return x=C,P=pr(),P!==e?(L=ht(),L===e&&(L=null),L!==e?(A=pr(),A!==e?(z=ht(),z===e&&(z=null),z!==e?(oe=pr(),oe!==e?(ne=x,P=g(P,A,oe),x=P):(C=x,x=e)):(C=x,x=e)):(C=x,x=e)):(C=x,x=e)):(C=x,x=e),x}function SS(){var x,P,L,A;if(x=C,D.test(i.charAt(C))?(P=i.charAt(C),C++):(P=e,Ce===0&&Ot(E)),P!==e){for(L=[],A=He();A!==e;)L.push(A),A=He();L!==e?(A=wS(),A!==e?(ne=x,P=m(P,A),x=P):(C=x,x=e)):(C=x,x=e)}else C=x,x=e;return x}function wS(){var x,P,L,A,z,oe;if(x=C,P=fp(),P!==e){for(L=[],A=C,z=ht(),z===e&&(z=null),z!==e?(oe=fp(),oe!==e?(z=[z,oe],A=z):(C=A,A=e)):(C=A,A=e);A!==e;)L.push(A),A=C,z=ht(),z===e&&(z=null),z!==e?(oe=fp(),oe!==e?(z=[z,oe],A=z):(C=A,A=e)):(C=A,A=e);L!==e?(ne=x,P=a(P,L),x=P):(C=x,x=e)}else C=x,x=e;return x}function fp(){var x,P,L,A;return x=C,P=pr(),P!==e?(L=ht(),L===e&&(L=null),L!==e?(A=pr(),A!==e?(ne=x,P=I(P,A),x=P):(C=x,x=e)):(C=x,x=e)):(C=x,x=e),x}function PS(){var x,P,L,A;if(x=C,N.test(i.charAt(C))?(P=i.charAt(C),C++):(P=e,Ce===0&&Ot(_)),P!==e){for(L=[],A=He();A!==e;)L.push(A),A=He();L!==e?(A=OS(),A!==e?(ne=x,P=m(P,A),x=P):(C=x,x=e)):(C=x,x=e)}else C=x,x=e;return x}function OS(){var x,P,L,A,z,oe;if(x=C,P=hp(),P!==e){for(L=[],A=C,z=ht(),z===e&&(z=null),z!==e?(oe=hp(),oe!==e?(z=[z,oe],A=z):(C=A,A=e)):(C=A,A=e);A!==e;)L.push(A),A=C,z=ht(),z===e&&(z=null),z!==e?(oe=hp(),oe!==e?(z=[z,oe],A=z):(C=A,A=e)):(C=A,A=e);L!==e?(ne=x,P=a(P,L),x=P):(C=x,x=e)}else C=x,x=e;return x}function hp(){var x,P,L,A;return x=C,P=pr(),P!==e?(L=ht(),L===e&&(L=null),L!==e?(A=pr(),A!==e?(ne=x,P=R(P,A),x=P):(C=x,x=e)):(C=x,x=e)):(C=x,x=e),x}function TS(){var x,P,L,A;if(x=C,V.test(i.charAt(C))?(P=i.charAt(C),C++):(P=e,Ce===0&&Ot(U)),P!==e){for(L=[],A=He();A!==e;)L.push(A),A=He();L!==e?(A=CS(),A!==e?(ne=x,P=m(P,A),x=P):(C=x,x=e)):(C=x,x=e)}else C=x,x=e;return x}function CS(){var x,P,L,A,z,oe;if(x=C,P=pr(),P!==e){for(L=[],A=C,z=ht(),z===e&&(z=null),z!==e?(oe=pr(),oe!==e?(z=[z,oe],A=z):(C=A,A=e)):(C=A,A=e);A!==e;)L.push(A),A=C,z=ht(),z===e&&(z=null),z!==e?(oe=pr(),oe!==e?(z=[z,oe],A=z):(C=A,A=e)):(C=A,A=e);L!==e?(ne=x,P=a(P,L),x=P):(C=x,x=e)}else C=x,x=e;return x}function AS(){var x,P,L,A;if(x=C,B.test(i.charAt(C))?(P=i.charAt(C),C++):(P=e,Ce===0&&Ot(q)),P!==e){for(L=[],A=He();A!==e;)L.push(A),A=He();L!==e?(A=MS(),A!==e?(ne=x,P=m(P,A),x=P):(C=x,x=e)):(C=x,x=e)}else C=x,x=e;return x}function MS(){var x,P,L,A,z,oe;if(x=C,P=mp(),P!==e){for(L=[],A=C,z=ht(),z===e&&(z=null),z!==e?(oe=mp(),oe!==e?(z=[z,oe],A=z):(C=A,A=e)):(C=A,A=e);A!==e;)L.push(A),A=C,z=ht(),z===e&&(z=null),z!==e?(oe=mp(),oe!==e?(z=[z,oe],A=z):(C=A,A=e)):(C=A,A=e);L!==e?(ne=x,P=a(P,L),x=P):(C=x,x=e)}else C=x,x=e;return x}function mp(){var x,P,L,A,z,oe,Yn,gp,gc,xp,xc,bp;return x=C,P=rm(),P!==e?(L=ht(),L===e&&(L=null),L!==e?(A=rm(),A!==e?(z=ht(),z===e&&(z=null),z!==e?(oe=$n(),oe!==e?(Yn=ht(),Yn!==e?(gp=om(),gp!==e?(gc=ht(),gc===e&&(gc=null),gc!==e?(xp=om(),xp!==e?(xc=ht(),xc===e&&(xc=null),xc!==e?(bp=pr(),bp!==e?(ne=x,P=j(P,A,oe,gp,xp,bp),x=P):(C=x,x=e)):(C=x,x=e)):(C=x,x=e)):(C=x,x=e)):(C=x,x=e)):(C=x,x=e)):(C=x,x=e)):(C=x,x=e)):(C=x,x=e)):(C=x,x=e)):(C=x,x=e),x}function pr(){var x,P,L,A;return x=C,P=$n(),P!==e?(L=ht(),L===e&&(L=null),L!==e?(A=$n(),A!==e?(ne=x,P=F(P,A),x=P):(C=x,x=e)):(C=x,x=e)):(C=x,x=e),x}function rm(){var x,P;return x=C,P=nm(),P===e&&(P=mn()),P!==e&&(ne=x,P=H(P)),x=P,x}function $n(){var x,P,L,A;return x=C,P=C,L=yp(),L===e&&(L=null),L!==e?(A=nm(),A!==e?(L=[L,A],P=L):(C=P,P=e)):(C=P,P=e),P===e&&(P=C,L=yp(),L===e&&(L=null),L!==e?(A=mn(),A!==e?(L=[L,A],P=L):(C=P,P=e)):(C=P,P=e)),P!==e&&(ne=x,P=W(P)),x=P,x}function om(){var x,P;return x=C,ee.test(i.charAt(C))?(P=i.charAt(C),C++):(P=e,Ce===0&&Ot(te)),P!==e&&(ne=x,P=Y(P)),x=P,x}function ht(){var x,P,L,A,z;if(x=C,P=[],L=He(),L!==e)for(;L!==e;)P.push(L),L=He();else P=e;if(P!==e)if(L=im(),L===e&&(L=null),L!==e){for(A=[],z=He();z!==e;)A.push(z),z=He();A!==e?(P=[P,L,A],x=P):(C=x,x=e)}else C=x,x=e;else C=x,x=e;if(x===e){if(x=C,P=C,L=im(),L!==e){for(A=[],z=He();z!==e;)A.push(z),z=He();A!==e?(L=[L,A],P=L):(C=P,P=e)}else C=P,P=e;P!==e&&(ne=x,P=re()),x=P}return x}function im(){var x;return i.charCodeAt(C)===44?(x=K,C++):(x=e,Ce===0&&Ot(Z)),x}function nm(){var x,P,L,A;return x=C,P=C,L=IS(),L!==e?(A=am(),A===e&&(A=null),A!==e?(L=[L,A],P=L):(C=P,P=e)):(C=P,P=e),P===e&&(P=C,L=mn(),L!==e?(A=am(),A!==e?(L=[L,A],P=L):(C=P,P=e)):(C=P,P=e)),P!==e&&(ne=x,P=Q(P)),x=P,x}function IS(){var x,P,L,A,z;return x=C,P=C,L=mn(),L===e&&(L=null),L!==e?(i.charCodeAt(C)===46?(A=$,C++):(A=e,Ce===0&&Ot(pe)),A!==e?(z=mn(),z!==e?(L=[L,A,z],P=L):(C=P,P=e)):(C=P,P=e)):(C=P,P=e),P===e&&(P=C,L=mn(),L!==e?(i.charCodeAt(C)===46?(A=$,C++):(A=e,Ce===0&&Ot(pe)),A!==e?(L=[L,A],P=L):(C=P,P=e)):(C=P,P=e)),P!==e&&(ne=x,P=Q(P)),x=P,x}function am(){var x,P,L,A,z;return x=C,P=C,le.test(i.charAt(C))?(L=i.charAt(C),C++):(L=e,Ce===0&&Ot(ie)),L!==e?(A=yp(),A===e&&(A=null),A!==e?(z=mn(),z!==e?(L=[L,A,z],P=L):(C=P,P=e)):(C=P,P=e)):(C=P,P=e),P!==e&&(ne=x,P=Q(P)),x=P,x}function yp(){var x;return ue.test(i.charAt(C))?(x=i.charAt(C),C++):(x=e,Ce===0&&Ot(ae)),x}function mn(){var x,P,L;if(x=C,P=[],ge.test(i.charAt(C))?(L=i.charAt(C),C++):(L=e,Ce===0&&Ot(me)),L!==e)for(;L!==e;)P.push(L),ge.test(i.charAt(C))?(L=i.charAt(C),C++):(L=e,Ce===0&&Ot(me));else P=e;return P!==e&&(ne=x,P=ye(P)),x=P,x}function He(){var x,P;return x=C,ve.test(i.charAt(C))?(P=i.charAt(C),C++):(P=e,Ce===0&&Ot(xe)),P!==e&&(ne=x,P=re()),x=P,x}function ES(x,P){if(!P)return[x];for(var L=[x],A=0,z=P.length;A<z;A++)L[A+1]=P[A][1];return L}var yc={m:"moveto",l:"lineto",h:"horizontal lineto",v:"vertical lineto",c:"curveto",s:"smooth curveto",q:"quadratic curveto",t:"smooth quadratic curveto",a:"elliptical arc",z:"closepath"};for(var sm in yc)yc[sm.toUpperCase()]=yc[sm];function Xn(x,P){P||(P=[{}]);for(var L=P.length;L--;){var A={code:x,command:yc[x]};x==x.toLowerCase()&&(A.relative=!0);for(var z in P[L])A[z]=P[L][z];P[L]=A}return P}if(zt=o(),zt!==e&&C===i.length)return zt;throw zt!==e&&C<i.length&&Ot(cp()),zr(Ge,ke<i.length?i.charAt(ke):null,ke<i.length?fn(ke,ke+1):fn(ke,ke))}Jv.exports={SyntaxError:Un,parse:K3}});var zh=el((Rre,t1)=>{var kd=e1().parse;kd.parseSVG=kd;kd.makeAbsolute=Q3;t1.exports=kd;function Q3(i){var t,e={x:0,y:0},r={x:"x0",y:"y0",x1:"x0",y1:"y0",x2:"x0",y2:"y0"};return i.forEach(function(o){o.command==="moveto"&&(t=o),o.x0=e.x,o.y0=e.y;for(var n in r)n in o&&(o[n]+=o.relative?o[r[n]]:0);"x"in o||(o.x=e.x),"y"in o||(o.y=e.y),o.relative=!1,o.code=o.code.toUpperCase(),o.command=="closepath"&&(o.x=t.x,o.y=t.y),e=o}),i}});var pS=el((Oce,dS)=>{dS.exports=function(t,e){for(var r=t.split("."),o=e.split("."),n=0;n<3;n++){var a=Number(r[n]),s=Number(o[n]);if(a>s)return 1;if(s>a)return-1;if(!isNaN(a)&&isNaN(s))return 1;if(isNaN(a)&&!isNaN(s))return-1}return 0}});var EE={};lm(EE,{default:()=>sp});module.exports=VS(EE);var lp=require("three");function bc(i){for(let t of Object.keys(i))i[t]===void 0&&delete i[t];return i}function Ft(i,t){return Object.setPrototypeOf(i,t),i}function vc(i){return Array.isArray(i)?i:[i]}function Sc(i,t){let e=0;for(;e<i.length&&e<t.length;){if(i[e]<t[e])return-1;if(i[e]>t[e])return 1;e+=1}return e!==t.length?-1:e!==i.length?1:0}var zS=typeof global=="object"&&global&&global.Object===Object&&global,wc=zS;var GS=typeof self=="object"&&self&&self.Object===Object&&self,FS=wc||GS||Function("return this")(),Tt=FS;var jS=Tt.Symbol,Yt=jS;var um=Object.prototype,US=um.hasOwnProperty,kS=um.toString,rl=Yt?Yt.toStringTag:void 0;function HS(i){var t=US.call(i,rl),e=i[rl];try{i[rl]=void 0;var r=!0}catch{}var o=kS.call(i);return r&&(t?i[rl]=e:delete i[rl]),o}var dm=HS;var WS=Object.prototype,qS=WS.toString;function $S(i){return qS.call(i)}var pm=$S;var XS="[object Null]",YS="[object Undefined]",fm=Yt?Yt.toStringTag:void 0;function KS(i){return i==null?i===void 0?YS:XS:fm&&fm in Object(i)?dm(i):pm(i)}var Nr=KS;function QS(i){return i!=null&&typeof i=="object"}var rr=QS;var ZS="[object Symbol]";function JS(i){return typeof i=="symbol"||rr(i)&&Nr(i)==ZS}var Si=JS;function ew(i,t){for(var e=-1,r=i==null?0:i.length,o=Array(r);++e<r;)o[e]=t(i[e],e,i);return o}var Pc=ew;var tw=Array.isArray,Ct=tw;var rw=1/0,hm=Yt?Yt.prototype:void 0,mm=hm?hm.toString:void 0;function ym(i){if(typeof i=="string")return i;if(Ct(i))return Pc(i,ym)+"";if(Si(i))return mm?mm.call(i):"";var t=i+"";return t=="0"&&1/i==-rw?"-0":t}var gm=ym;var ow=/\s/;function iw(i){for(var t=i.length;t--&&ow.test(i.charAt(t)););return t}var xm=iw;var nw=/^\s+/;function aw(i){return i&&i.slice(0,xm(i)+1).replace(nw,"")}var bm=aw;function sw(i){var t=typeof i;return i!=null&&(t=="object"||t=="function")}var At=sw;var vm=0/0,lw=/^[-+]0x[0-9a-f]+$/i,cw=/^0b[01]+$/i,uw=/^0o[0-7]+$/i,dw=parseInt;function pw(i){if(typeof i=="number")return i;if(Si(i))return vm;if(At(i)){var t=typeof i.valueOf=="function"?i.valueOf():i;i=At(t)?t+"":t}if(typeof i!="string")return i===0?i:+i;i=bm(i);var e=cw.test(i);return e||uw.test(i)?dw(i.slice(2),e?2:8):lw.test(i)?vm:+i}var vp=pw;function fw(i){return i}var Sm=fw;var hw="[object AsyncFunction]",mw="[object Function]",yw="[object GeneratorFunction]",gw="[object Proxy]";function xw(i){if(!At(i))return!1;var t=Nr(i);return t==mw||t==yw||t==hw||t==gw}var Oc=xw;var bw=Tt["__core-js_shared__"],Tc=bw;var wm=function(){var i=/[^.]+$/.exec(Tc&&Tc.keys&&Tc.keys.IE_PROTO||"");return i?"Symbol(src)_1."+i:""}();function vw(i){return!!wm&&wm in i}var Pm=vw;var Sw=Function.prototype,ww=Sw.toString;function Pw(i){if(i!=null){try{return ww.call(i)}catch{}try{return i+""}catch{}}return""}var Xo=Pw;var Ow=/[\\^$.*+?()[\]{}|]/g,Tw=/^\[object .+?Constructor\]$/,Cw=Function.prototype,Aw=Object.prototype,Mw=Cw.toString,Iw=Aw.hasOwnProperty,Ew=RegExp("^"+Mw.call(Iw).replace(Ow,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Nw(i){if(!At(i)||Pm(i))return!1;var t=Oc(i)?Ew:Tw;return t.test(Xo(i))}var Om=Nw;function Dw(i,t){return i?.[t]}var Tm=Dw;function _w(i,t){var e=Tm(i,t);return Om(e)?e:void 0}var br=_w;var Rw=br(Tt,"WeakMap"),Cc=Rw;var Cm=Object.create,Lw=function(){function i(){}return function(t){if(!At(t))return{};if(Cm)return Cm(t);i.prototype=t;var e=new i;return i.prototype=void 0,e}}(),Am=Lw;function Bw(i,t,e){switch(e.length){case 0:return i.call(t);case 1:return i.call(t,e[0]);case 2:return i.call(t,e[0],e[1]);case 3:return i.call(t,e[0],e[1],e[2])}return i.apply(t,e)}var Mm=Bw;function Vw(i,t){var e=-1,r=i.length;for(t||(t=Array(r));++e<r;)t[e]=i[e];return t}var Im=Vw;var zw=800,Gw=16,Fw=Date.now;function jw(i){var t=0,e=0;return function(){var r=Fw(),o=Gw-(r-e);if(e=r,o>0){if(++t>=zw)return arguments[0]}else t=0;return i.apply(void 0,arguments)}}var Em=jw;function Uw(i){return function(){return i}}var Nm=Uw;var kw=function(){try{var i=br(Object,"defineProperty");return i({},"",{}),i}catch{}}(),Kn=kw;var Hw=Kn?function(i,t){return Kn(i,"toString",{configurable:!0,enumerable:!1,value:Nm(t),writable:!0})}:Sm,Dm=Hw;var Ww=Em(Dm),_m=Ww;function qw(i,t){for(var e=-1,r=i==null?0:i.length;++e<r&&t(i[e],e,i)!==!1;);return i}var Rm=qw;var $w=9007199254740991,Xw=/^(?:0|[1-9]\d*)$/;function Yw(i,t){var e=typeof i;return t=t??$w,!!t&&(e=="number"||e!="symbol"&&Xw.test(i))&&i>-1&&i%1==0&&i<t}var Qn=Yw;function Kw(i,t,e){t=="__proto__"&&Kn?Kn(i,t,{configurable:!0,enumerable:!0,value:e,writable:!0}):i[t]=e}var Ac=Kw;function Qw(i,t){return i===t||i!==i&&t!==t}var Zn=Qw;var Zw=Object.prototype,Jw=Zw.hasOwnProperty;function e2(i,t,e){var r=i[t];(!(Jw.call(i,t)&&Zn(r,e))||e===void 0&&!(t in i))&&Ac(i,t,e)}var Jn=e2;function t2(i,t,e,r){var o=!e;e||(e={});for(var n=-1,a=t.length;++n<a;){var s=t[n],l=r?r(e[s],i[s],s,e,i):void 0;l===void 0&&(l=i[s]),o?Ac(e,s,l):Jn(e,s,l)}return e}var So=t2;var Lm=Math.max;function r2(i,t,e){return t=Lm(t===void 0?i.length-1:t,0),function(){for(var r=arguments,o=-1,n=Lm(r.length-t,0),a=Array(n);++o<n;)a[o]=r[t+o];o=-1;for(var s=Array(t+1);++o<t;)s[o]=r[o];return s[t]=e(a),Mm(i,this,s)}}var Bm=r2;var o2=9007199254740991;function i2(i){return typeof i=="number"&&i>-1&&i%1==0&&i<=o2}var ea=i2;function n2(i){return i!=null&&ea(i.length)&&!Oc(i)}var Mc=n2;var a2=Object.prototype;function s2(i){var t=i&&i.constructor,e=typeof t=="function"&&t.prototype||a2;return i===e}var ta=s2;function l2(i,t){for(var e=-1,r=Array(i);++e<i;)r[e]=t(e);return r}var Vm=l2;var c2="[object Arguments]";function u2(i){return rr(i)&&Nr(i)==c2}var Sp=u2;var zm=Object.prototype,d2=zm.hasOwnProperty,p2=zm.propertyIsEnumerable,f2=Sp(function(){return arguments}())?Sp:function(i){return rr(i)&&d2.call(i,"callee")&&!p2.call(i,"callee")},ra=f2;function h2(){return!1}var Gm=h2;var Um=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Fm=Um&&typeof module=="object"&&module&&!module.nodeType&&module,m2=Fm&&Fm.exports===Um,jm=m2?Tt.Buffer:void 0,y2=jm?jm.isBuffer:void 0,g2=y2||Gm,gn=g2;var x2="[object Arguments]",b2="[object Array]",v2="[object Boolean]",S2="[object Date]",w2="[object Error]",P2="[object Function]",O2="[object Map]",T2="[object Number]",C2="[object Object]",A2="[object RegExp]",M2="[object Set]",I2="[object String]",E2="[object WeakMap]",N2="[object ArrayBuffer]",D2="[object DataView]",_2="[object Float32Array]",R2="[object Float64Array]",L2="[object Int8Array]",B2="[object Int16Array]",V2="[object Int32Array]",z2="[object Uint8Array]",G2="[object Uint8ClampedArray]",F2="[object Uint16Array]",j2="[object Uint32Array]",mt={};mt[_2]=mt[R2]=mt[L2]=mt[B2]=mt[V2]=mt[z2]=mt[G2]=mt[F2]=mt[j2]=!0;mt[x2]=mt[b2]=mt[N2]=mt[v2]=mt[D2]=mt[S2]=mt[w2]=mt[P2]=mt[O2]=mt[T2]=mt[C2]=mt[A2]=mt[M2]=mt[I2]=mt[E2]=!1;function U2(i){return rr(i)&&ea(i.length)&&!!mt[Nr(i)]}var km=U2;function k2(i){return function(t){return i(t)}}var oa=k2;var Hm=typeof exports=="object"&&exports&&!exports.nodeType&&exports,ol=Hm&&typeof module=="object"&&module&&!module.nodeType&&module,H2=ol&&ol.exports===Hm,wp=H2&&wc.process,W2=function(){try{var i=ol&&ol.require&&ol.require("util").types;return i||wp&&wp.binding&&wp.binding("util")}catch{}}(),Yo=W2;var Wm=Yo&&Yo.isTypedArray,q2=Wm?oa(Wm):km,Ic=q2;var $2=Object.prototype,X2=$2.hasOwnProperty;function Y2(i,t){var e=Ct(i),r=!e&&ra(i),o=!e&&!r&&gn(i),n=!e&&!r&&!o&&Ic(i),a=e||r||o||n,s=a?Vm(i.length,String):[],l=s.length;for(var c in i)(t||X2.call(i,c))&&!(a&&(c=="length"||o&&(c=="offset"||c=="parent")||n&&(c=="buffer"||c=="byteLength"||c=="byteOffset")||Qn(c,l)))&&s.push(c);return s}var Ec=Y2;function K2(i,t){return function(e){return i(t(e))}}var Nc=K2;var Q2=Nc(Object.keys,Object),qm=Q2;var Z2=Object.prototype,J2=Z2.hasOwnProperty;function eP(i){if(!ta(i))return qm(i);var t=[];for(var e in Object(i))J2.call(i,e)&&e!="constructor"&&t.push(e);return t}var $m=eP;function tP(i){return Mc(i)?Ec(i):$m(i)}var ia=tP;function rP(i){var t=[];if(i!=null)for(var e in Object(i))t.push(e);return t}var Xm=rP;var oP=Object.prototype,iP=oP.hasOwnProperty;function nP(i){if(!At(i))return Xm(i);var t=ta(i),e=[];for(var r in i)r=="constructor"&&(t||!iP.call(i,r))||e.push(r);return e}var Ym=nP;function aP(i){return Mc(i)?Ec(i,!0):Ym(i)}var na=aP;var sP=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,lP=/^\w*$/;function cP(i,t){if(Ct(i))return!1;var e=typeof i;return e=="number"||e=="symbol"||e=="boolean"||i==null||Si(i)?!0:lP.test(i)||!sP.test(i)||t!=null&&i in Object(t)}var Km=cP;var uP=br(Object,"create"),Ko=uP;function dP(){this.__data__=Ko?Ko(null):{},this.size=0}var Qm=dP;function pP(i){var t=this.has(i)&&delete this.__data__[i];return this.size-=t?1:0,t}var Zm=pP;var fP="__lodash_hash_undefined__",hP=Object.prototype,mP=hP.hasOwnProperty;function yP(i){var t=this.__data__;if(Ko){var e=t[i];return e===fP?void 0:e}return mP.call(t,i)?t[i]:void 0}var Jm=yP;var gP=Object.prototype,xP=gP.hasOwnProperty;function bP(i){var t=this.__data__;return Ko?t[i]!==void 0:xP.call(t,i)}var ey=bP;var vP="__lodash_hash_undefined__";function SP(i,t){var e=this.__data__;return this.size+=this.has(i)?0:1,e[i]=Ko&&t===void 0?vP:t,this}var ty=SP;function aa(i){var t=-1,e=i==null?0:i.length;for(this.clear();++t<e;){var r=i[t];this.set(r[0],r[1])}}aa.prototype.clear=Qm;aa.prototype.delete=Zm;aa.prototype.get=Jm;aa.prototype.has=ey;aa.prototype.set=ty;var Pp=aa;function wP(){this.__data__=[],this.size=0}var ry=wP;function PP(i,t){for(var e=i.length;e--;)if(Zn(i[e][0],t))return e;return-1}var wi=PP;var OP=Array.prototype,TP=OP.splice;function CP(i){var t=this.__data__,e=wi(t,i);if(e<0)return!1;var r=t.length-1;return e==r?t.pop():TP.call(t,e,1),--this.size,!0}var oy=CP;function AP(i){var t=this.__data__,e=wi(t,i);return e<0?void 0:t[e][1]}var iy=AP;function MP(i){return wi(this.__data__,i)>-1}var ny=MP;function IP(i,t){var e=this.__data__,r=wi(e,i);return r<0?(++this.size,e.push([i,t])):e[r][1]=t,this}var ay=IP;function sa(i){var t=-1,e=i==null?0:i.length;for(this.clear();++t<e;){var r=i[t];this.set(r[0],r[1])}}sa.prototype.clear=ry;sa.prototype.delete=oy;sa.prototype.get=iy;sa.prototype.has=ny;sa.prototype.set=ay;var Pi=sa;var EP=br(Tt,"Map"),Oi=EP;function NP(){this.size=0,this.__data__={hash:new Pp,map:new(Oi||Pi),string:new Pp}}var sy=NP;function DP(i){var t=typeof i;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?i!=="__proto__":i===null}var ly=DP;function _P(i,t){var e=i.__data__;return ly(t)?e[typeof t=="string"?"string":"hash"]:e.map}var Ti=_P;function RP(i){var t=Ti(this,i).delete(i);return this.size-=t?1:0,t}var cy=RP;function LP(i){return Ti(this,i).get(i)}var uy=LP;function BP(i){return Ti(this,i).has(i)}var dy=BP;function VP(i,t){var e=Ti(this,i),r=e.size;return e.set(i,t),this.size+=e.size==r?0:1,this}var py=VP;function la(i){var t=-1,e=i==null?0:i.length;for(this.clear();++t<e;){var r=i[t];this.set(r[0],r[1])}}la.prototype.clear=sy;la.prototype.delete=cy;la.prototype.get=uy;la.prototype.has=dy;la.prototype.set=py;var xn=la;var zP="Expected a function";function Op(i,t){if(typeof i!="function"||t!=null&&typeof t!="function")throw new TypeError(zP);var e=function(){var r=arguments,o=t?t.apply(this,r):r[0],n=e.cache;if(n.has(o))return n.get(o);var a=i.apply(this,r);return e.cache=n.set(o,a)||n,a};return e.cache=new(Op.Cache||xn),e}Op.Cache=xn;var fy=Op;var GP=500;function FP(i){var t=fy(i,function(r){return e.size===GP&&e.clear(),r}),e=t.cache;return t}var hy=FP;var jP=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,UP=/\\(\\)?/g,kP=hy(function(i){var t=[];return i.charCodeAt(0)===46&&t.push(""),i.replace(jP,function(e,r,o,n){t.push(o?n.replace(UP,"$1"):r||e)}),t}),my=kP;function HP(i){return i==null?"":gm(i)}var yy=HP;function WP(i,t){return Ct(i)?i:Km(i,t)?[i]:my(yy(i))}var Gr=WP;var qP=1/0;function $P(i){if(typeof i=="string"||Si(i))return i;var t=i+"";return t=="0"&&1/i==-qP?"-0":t}var Ci=$P;function XP(i,t){t=Gr(t,i);for(var e=0,r=t.length;i!=null&&e<r;)i=i[Ci(t[e++])];return e&&e==r?i:void 0}var Dc=XP;function YP(i,t){for(var e=-1,r=t.length,o=i.length;++e<r;)i[o+e]=t[e];return i}var ca=YP;var gy=Yt?Yt.isConcatSpreadable:void 0;function KP(i){return Ct(i)||ra(i)||!!(gy&&i&&i[gy])}var xy=KP;function by(i,t,e,r,o){var n=-1,a=i.length;for(e||(e=xy),o||(o=[]);++n<a;){var s=i[n];t>0&&e(s)?t>1?by(s,t-1,e,r,o):ca(o,s):r||(o[o.length]=s)}return o}var vy=by;function QP(i){var t=i==null?0:i.length;return t?vy(i,1):[]}var Sy=QP;function ZP(i){return _m(Bm(i,void 0,Sy),i+"")}var _c=ZP;var JP=Nc(Object.getPrototypeOf,Object),ua=JP;var eO="[object Object]",tO=Function.prototype,rO=Object.prototype,wy=tO.toString,oO=rO.hasOwnProperty,iO=wy.call(Object);function nO(i){if(!rr(i)||Nr(i)!=eO)return!1;var t=ua(i);if(t===null)return!0;var e=oO.call(t,"constructor")&&t.constructor;return typeof e=="function"&&e instanceof e&&wy.call(e)==iO}var Py=nO;function aO(i,t,e){var r=-1,o=i.length;t<0&&(t=-t>o?0:o+t),e=e>o?o:e,e<0&&(e+=o),o=t>e?0:e-t>>>0,t>>>=0;for(var n=Array(o);++r<o;)n[r]=i[r+t];return n}var Oy=aO;function sO(){this.__data__=new Pi,this.size=0}var Ty=sO;function lO(i){var t=this.__data__,e=t.delete(i);return this.size=t.size,e}var Cy=lO;function cO(i){return this.__data__.get(i)}var Ay=cO;function uO(i){return this.__data__.has(i)}var My=uO;var dO=200;function pO(i,t){var e=this.__data__;if(e instanceof Pi){var r=e.__data__;if(!Oi||r.length<dO-1)return r.push([i,t]),this.size=++e.size,this;e=this.__data__=new xn(r)}return e.set(i,t),this.size=e.size,this}var Iy=pO;function da(i){var t=this.__data__=new Pi(i);this.size=t.size}da.prototype.clear=Ty;da.prototype.delete=Cy;da.prototype.get=Ay;da.prototype.has=My;da.prototype.set=Iy;var pa=da;function fO(i,t){return i&&So(t,ia(t),i)}var Ey=fO;function hO(i,t){return i&&So(t,na(t),i)}var Ny=hO;var Ly=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Dy=Ly&&typeof module=="object"&&module&&!module.nodeType&&module,mO=Dy&&Dy.exports===Ly,_y=mO?Tt.Buffer:void 0,Ry=_y?_y.allocUnsafe:void 0;function yO(i,t){if(t)return i.slice();var e=i.length,r=Ry?Ry(e):new i.constructor(e);return i.copy(r),r}var By=yO;function gO(i,t){for(var e=-1,r=i==null?0:i.length,o=0,n=[];++e<r;){var a=i[e];t(a,e,i)&&(n[o++]=a)}return n}var Vy=gO;function xO(){return[]}var Rc=xO;var bO=Object.prototype,vO=bO.propertyIsEnumerable,zy=Object.getOwnPropertySymbols,SO=zy?function(i){return i==null?[]:(i=Object(i),Vy(zy(i),function(t){return vO.call(i,t)}))}:Rc,fa=SO;function wO(i,t){return So(i,fa(i),t)}var Gy=wO;var PO=Object.getOwnPropertySymbols,OO=PO?function(i){for(var t=[];i;)ca(t,fa(i)),i=ua(i);return t}:Rc,Lc=OO;function TO(i,t){return So(i,Lc(i),t)}var Fy=TO;function CO(i,t,e){var r=t(i);return Ct(i)?r:ca(r,e(i))}var Bc=CO;function AO(i){return Bc(i,ia,fa)}var il=AO;function MO(i){return Bc(i,na,Lc)}var Vc=MO;var IO=br(Tt,"DataView"),zc=IO;var EO=br(Tt,"Promise"),Gc=EO;var NO=br(Tt,"Set"),Fc=NO;var jy="[object Map]",DO="[object Object]",Uy="[object Promise]",ky="[object Set]",Hy="[object WeakMap]",Wy="[object DataView]",_O=Xo(zc),RO=Xo(Oi),LO=Xo(Gc),BO=Xo(Fc),VO=Xo(Cc),bn=Nr;(zc&&bn(new zc(new ArrayBuffer(1)))!=Wy||Oi&&bn(new Oi)!=jy||Gc&&bn(Gc.resolve())!=Uy||Fc&&bn(new Fc)!=ky||Cc&&bn(new Cc)!=Hy)&&(bn=function(i){var t=Nr(i),e=t==DO?i.constructor:void 0,r=e?Xo(e):"";if(r)switch(r){case _O:return Wy;case RO:return jy;case LO:return Uy;case BO:return ky;case VO:return Hy}return t});var Qo=bn;var zO=Object.prototype,GO=zO.hasOwnProperty;function FO(i){var t=i.length,e=new i.constructor(t);return t&&typeof i[0]=="string"&&GO.call(i,"index")&&(e.index=i.index,e.input=i.input),e}var qy=FO;var jO=Tt.Uint8Array,ha=jO;function UO(i){var t=new i.constructor(i.byteLength);return new ha(t).set(new ha(i)),t}var ma=UO;function kO(i,t){var e=t?ma(i.buffer):i.buffer;return new i.constructor(e,i.byteOffset,i.byteLength)}var $y=kO;var HO=/\w*$/;function WO(i){var t=new i.constructor(i.source,HO.exec(i));return t.lastIndex=i.lastIndex,t}var Xy=WO;var Yy=Yt?Yt.prototype:void 0,Ky=Yy?Yy.valueOf:void 0;function qO(i){return Ky?Object(Ky.call(i)):{}}var Qy=qO;function $O(i,t){var e=t?ma(i.buffer):i.buffer;return new i.constructor(e,i.byteOffset,i.length)}var Zy=$O;var XO="[object Boolean]",YO="[object Date]",KO="[object Map]",QO="[object Number]",ZO="[object RegExp]",JO="[object Set]",eT="[object String]",tT="[object Symbol]",rT="[object ArrayBuffer]",oT="[object DataView]",iT="[object Float32Array]",nT="[object Float64Array]",aT="[object Int8Array]",sT="[object Int16Array]",lT="[object Int32Array]",cT="[object Uint8Array]",uT="[object Uint8ClampedArray]",dT="[object Uint16Array]",pT="[object Uint32Array]";function fT(i,t,e){var r=i.constructor;switch(t){case rT:return ma(i);case XO:case YO:return new r(+i);case oT:return $y(i,e);case iT:case nT:case aT:case sT:case lT:case cT:case uT:case dT:case pT:return Zy(i,e);case KO:return new r;case QO:case eT:return new r(i);case ZO:return Xy(i);case JO:return new r;case tT:return Qy(i)}}var Jy=fT;function hT(i){return typeof i.constructor=="function"&&!ta(i)?Am(ua(i)):{}}var eg=hT;var mT="[object Map]";function yT(i){return rr(i)&&Qo(i)==mT}var tg=yT;var rg=Yo&&Yo.isMap,gT=rg?oa(rg):tg,og=gT;var xT="[object Set]";function bT(i){return rr(i)&&Qo(i)==xT}var ig=bT;var ng=Yo&&Yo.isSet,vT=ng?oa(ng):ig,ag=vT;var ST=1,wT=2,PT=4,sg="[object Arguments]",OT="[object Array]",TT="[object Boolean]",CT="[object Date]",AT="[object Error]",lg="[object Function]",MT="[object GeneratorFunction]",IT="[object Map]",ET="[object Number]",cg="[object Object]",NT="[object RegExp]",DT="[object Set]",_T="[object String]",RT="[object Symbol]",LT="[object WeakMap]",BT="[object ArrayBuffer]",VT="[object DataView]",zT="[object Float32Array]",GT="[object Float64Array]",FT="[object Int8Array]",jT="[object Int16Array]",UT="[object Int32Array]",kT="[object Uint8Array]",HT="[object Uint8ClampedArray]",WT="[object Uint16Array]",qT="[object Uint32Array]",dt={};dt[sg]=dt[OT]=dt[BT]=dt[VT]=dt[TT]=dt[CT]=dt[zT]=dt[GT]=dt[FT]=dt[jT]=dt[UT]=dt[IT]=dt[ET]=dt[cg]=dt[NT]=dt[DT]=dt[_T]=dt[RT]=dt[kT]=dt[HT]=dt[WT]=dt[qT]=!0;dt[AT]=dt[lg]=dt[LT]=!1;function jc(i,t,e,r,o,n){var a,s=t&ST,l=t&wT,c=t&PT;if(e&&(a=o?e(i,r,o,n):e(i)),a!==void 0)return a;if(!At(i))return i;var u=Ct(i);if(u){if(a=qy(i),!s)return Im(i,a)}else{var p=Qo(i),d=p==lg||p==MT;if(gn(i))return By(i,s);if(p==cg||p==sg||d&&!o){if(a=l||d?{}:eg(i),!s)return l?Fy(i,Ny(a,i)):Gy(i,Ey(a,i))}else{if(!dt[p])return o?i:{};a=Jy(i,p,s)}}n||(n=new pa);var f=n.get(i);if(f)return f;n.set(i,a),ag(i)?i.forEach(function(y){a.add(jc(y,t,e,y,i,n))}):og(i)&&i.forEach(function(y,b){a.set(b,jc(y,t,e,b,i,n))});var h=c?l?Vc:il:l?na:ia,m=u?void 0:h(i);return Rm(m||i,function(y,b){m&&(b=y,y=i[b]),Jn(a,b,jc(y,t,e,b,i,n))}),a}var Uc=jc;var $T=1,XT=4;function YT(i){return Uc(i,$T|XT)}var Zo=YT;var KT="__lodash_hash_undefined__";function QT(i){return this.__data__.set(i,KT),this}var ug=QT;function ZT(i){return this.__data__.has(i)}var dg=ZT;function kc(i){var t=-1,e=i==null?0:i.length;for(this.__data__=new xn;++t<e;)this.add(i[t])}kc.prototype.add=kc.prototype.push=ug;kc.prototype.has=dg;var pg=kc;function JT(i,t){for(var e=-1,r=i==null?0:i.length;++e<r;)if(t(i[e],e,i))return!0;return!1}var fg=JT;function eC(i,t){return i.has(t)}var hg=eC;var tC=1,rC=2;function oC(i,t,e,r,o,n){var a=e&tC,s=i.length,l=t.length;if(s!=l&&!(a&&l>s))return!1;var c=n.get(i),u=n.get(t);if(c&&u)return c==t&&u==i;var p=-1,d=!0,f=e&rC?new pg:void 0;for(n.set(i,t),n.set(t,i);++p<s;){var h=i[p],m=t[p];if(r)var y=a?r(m,h,p,t,i,n):r(h,m,p,i,t,n);if(y!==void 0){if(y)continue;d=!1;break}if(f){if(!fg(t,function(b,v){if(!hg(f,v)&&(h===b||o(h,b,e,r,n)))return f.push(v)})){d=!1;break}}else if(!(h===m||o(h,m,e,r,n))){d=!1;break}}return n.delete(i),n.delete(t),d}var Hc=oC;function iC(i){var t=-1,e=Array(i.size);return i.forEach(function(r,o){e[++t]=[o,r]}),e}var mg=iC;function nC(i){var t=-1,e=Array(i.size);return i.forEach(function(r){e[++t]=r}),e}var yg=nC;var aC=1,sC=2,lC="[object Boolean]",cC="[object Date]",uC="[object Error]",dC="[object Map]",pC="[object Number]",fC="[object RegExp]",hC="[object Set]",mC="[object String]",yC="[object Symbol]",gC="[object ArrayBuffer]",xC="[object DataView]",gg=Yt?Yt.prototype:void 0,Tp=gg?gg.valueOf:void 0;function bC(i,t,e,r,o,n,a){switch(e){case xC:if(i.byteLength!=t.byteLength||i.byteOffset!=t.byteOffset)return!1;i=i.buffer,t=t.buffer;case gC:return!(i.byteLength!=t.byteLength||!n(new ha(i),new ha(t)));case lC:case cC:case pC:return Zn(+i,+t);case uC:return i.name==t.name&&i.message==t.message;case fC:case mC:return i==t+"";case dC:var s=mg;case hC:var l=r&aC;if(s||(s=yg),i.size!=t.size&&!l)return!1;var c=a.get(i);if(c)return c==t;r|=sC,a.set(i,t);var u=Hc(s(i),s(t),r,o,n,a);return a.delete(i),u;case yC:if(Tp)return Tp.call(i)==Tp.call(t)}return!1}var xg=bC;var vC=1,SC=Object.prototype,wC=SC.hasOwnProperty;function PC(i,t,e,r,o,n){var a=e&vC,s=il(i),l=s.length,c=il(t),u=c.length;if(l!=u&&!a)return!1;for(var p=l;p--;){var d=s[p];if(!(a?d in t:wC.call(t,d)))return!1}var f=n.get(i),h=n.get(t);if(f&&h)return f==t&&h==i;var m=!0;n.set(i,t),n.set(t,i);for(var y=a;++p<l;){d=s[p];var b=i[d],v=t[d];if(r)var w=a?r(v,b,d,t,i,n):r(b,v,d,i,t,n);if(!(w===void 0?b===v||o(b,v,e,r,n):w)){m=!1;break}y||(y=d=="constructor")}if(m&&!y){var O=i.constructor,S=t.constructor;O!=S&&"constructor"in i&&"constructor"in t&&!(typeof O=="function"&&O instanceof O&&typeof S=="function"&&S instanceof S)&&(m=!1)}return n.delete(i),n.delete(t),m}var bg=PC;var OC=1,vg="[object Arguments]",Sg="[object Array]",Wc="[object Object]",TC=Object.prototype,wg=TC.hasOwnProperty;function CC(i,t,e,r,o,n){var a=Ct(i),s=Ct(t),l=a?Sg:Qo(i),c=s?Sg:Qo(t);l=l==vg?Wc:l,c=c==vg?Wc:c;var u=l==Wc,p=c==Wc,d=l==c;if(d&&gn(i)){if(!gn(t))return!1;a=!0,u=!1}if(d&&!u)return n||(n=new pa),a||Ic(i)?Hc(i,t,e,r,o,n):xg(i,t,l,e,r,o,n);if(!(e&OC)){var f=u&&wg.call(i,"__wrapped__"),h=p&&wg.call(t,"__wrapped__");if(f||h){var m=f?i.value():i,y=h?t.value():t;return n||(n=new pa),o(m,y,e,r,n)}}return d?(n||(n=new pa),bg(i,t,e,r,o,n)):!1}var Pg=CC;function Og(i,t,e,r,o){return i===t?!0:i==null||t==null||!rr(i)&&!rr(t)?i!==i&&t!==t:Pg(i,t,e,r,Og,o)}var Tg=Og;function AC(i,t){return i!=null&&t in Object(i)}var Cg=AC;function MC(i,t,e){t=Gr(t,i);for(var r=-1,o=t.length,n=!1;++r<o;){var a=Ci(t[r]);if(!(n=i!=null&&e(i,a)))break;i=i[a]}return n||++r!=o?n:(o=i==null?0:i.length,!!o&&ea(o)&&Qn(a,o)&&(Ct(i)||ra(i)))}var Ag=MC;function IC(i,t){return i!=null&&Ag(i,t,Cg)}var Mg=IC;var EC=function(){return Tt.Date.now()},qc=EC;var NC="Expected a function",DC=Math.max,_C=Math.min;function RC(i,t,e){var r,o,n,a,s,l,c=0,u=!1,p=!1,d=!0;if(typeof i!="function")throw new TypeError(NC);t=vp(t)||0,At(e)&&(u=!!e.leading,p="maxWait"in e,n=p?DC(vp(e.maxWait)||0,t):n,d="trailing"in e?!!e.trailing:d);function f(T){var M=r,g=o;return r=o=void 0,c=T,a=i.apply(g,M),a}function h(T){return c=T,s=setTimeout(b,t),u?f(T):a}function m(T){var M=T-l,g=T-c,D=t-M;return p?_C(D,n-g):D}function y(T){var M=T-l,g=T-c;return l===void 0||M>=t||M<0||p&&g>=n}function b(){var T=qc();if(y(T))return v(T);s=setTimeout(b,m(T))}function v(T){return s=void 0,d&&r?f(T):(r=o=void 0,a)}function w(){s!==void 0&&clearTimeout(s),c=0,r=l=o=s=void 0}function O(){return s===void 0?a:v(qc())}function S(){var T=qc(),M=y(T);if(r=arguments,o=this,l=T,M){if(s===void 0)return h(l);if(p)return clearTimeout(s),s=setTimeout(b,t),f(l)}return s===void 0&&(s=setTimeout(b,t)),a}return S.cancel=w,S.flush=O,S}var $c=RC;function LC(i){var t=i==null?0:i.length;return t?i[t-1]:void 0}var Ig=LC;function BC(i,t){return t.length<2?i:Dc(i,Oy(t,0,-1))}var Eg=BC;function VC(i,t){return Tg(i,t)}var Cp=VC;function zC(i,t){return t=Gr(t,i),i=Eg(i,t),i==null||delete i[Ci(Ig(t))]}var Ng=zC;function GC(i){return Py(i)?void 0:i}var Dg=GC;var FC=1,jC=2,UC=4,kC=_c(function(i,t){var e={};if(i==null)return e;var r=!1;t=Pc(t,function(n){return n=Gr(n,i),r||(r=n.length>1),n}),So(i,Vc(i),e),r&&(e=Uc(e,FC|jC|UC,Dg));for(var o=t.length;o--;)Ng(e,t[o]);return e}),ya=kC;function HC(i,t,e,r){if(!At(i))return i;t=Gr(t,i);for(var o=-1,n=t.length,a=n-1,s=i;s!=null&&++o<n;){var l=Ci(t[o]),c=e;if(l==="__proto__"||l==="constructor"||l==="prototype")return i;if(o!=a){var u=s[l];c=r?r(u,l,s):void 0,c===void 0&&(c=At(u)?u:Qn(t[o+1])?[]:{})}Jn(s,l,c),s=s[l]}return i}var _g=HC;function WC(i,t,e){for(var r=-1,o=t.length,n={};++r<o;){var a=t[r],s=Dc(i,a);e(s,a)&&_g(n,Gr(a,i),s)}return n}var Rg=WC;function qC(i,t){return Rg(i,t,function(e,r){return Mg(i,r)})}var Lg=qC;var $C=_c(function(i,t){return i==null?{}:Lg(i,t)}),ro=$C;var de=class{modifyById(t,e){let r=this;if(r[t]===void 0)throw new Error("not expected");{let n={...r,[t]:e};return Object.setPrototypeOf(n,de.prototype),n}}add(t,e){return this.runOp({type:1,id:t,data:e})?.data??this}runOp(t){let e=this;if(t.type===1){let r=e[t.id],o;r===void 0?o={type:2,id:t.id}:o={type:1,id:t.id,data:r};let{id:n,data:a}=t,s={...e,[n]:a};return Object.setPrototypeOf(s,de.prototype),{data:s,actual:t,reverse:o}}else if(t.type===2){let{id:r}=t,o=e[r];if(o===void 0)return null;{let n={...e};return Object.setPrototypeOf(n,de.prototype),delete n[r],{data:n,actual:t,reverse:{type:1,id:r,data:o}}}}return null}};function nl(i){if(i.deepFreeze!==void 0){i.deepFreeze(i);return}let t=Object.getOwnPropertyNames(i);for(let e of t){let r=i[e];r&&typeof r=="object"&&nl(r)}return Object.freeze(i)}function Bg(i,t){let e=0;for(;e<i.length&&e<t.length;){if(i[e]<t[e])return-1;if(i[e]>t[e])return 1;e+=1}return e!==t.length?-1:e!==i.length?1:0}var ga=class extends Error{};function Xc(i){let t={...i};return Object.setPrototypeOf(t,Object.getPrototypeOf(i)),t}function wo(i,t,e){if(i===void 0?t===void 0?(i=0,t=10):i=t-10:t===void 0&&(t=i+10),i>t){let n=i;i=t,t=n}let r=[],o=1/(e+1);for(let n=0;n<e;n++){let a=i+(t-i)*(n+.75+Math.random()*.5)*o;r.push(a)}return r}function xa(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 Vg(){return typeof process<"u"}function zg(i,t){for(let e of i)t(e.id,e.data)!==!0&&zg(e.children,t)}function Gg(i,t){if(t(i.id,i.data)!==!0)for(let e of i.children)Gg(e,t)}var ct=class extends Array{constructor(...e){super(...e);Object.setPrototypeOf(this,ct.prototype)}deepFreeze(){let e=0;for(;e<this.length;)nl(this[e]),e++}fillCaches0(e,r){this.objCaches.set(e.id,e),this.parentCaches.set(e.id,r);for(let o of e.children)this.fillCaches0(o,e.id)}fillCaches(){if(this.objCaches===void 0){this.objCaches=new Map,this.parentCaches=new Map;for(let e of this)this.fillCaches0(e,null)}}randomId(){this.fillCaches();let e=Array.from(this.objCaches.keys());if(e.length!==0)return e[Math.max(0,Math.floor(Math.random()*e.length)-1)]}nonExistOrDescendantOf(e,r){if(!this.has(e))return!0;for(;e;){let o=this.parent(e);if(o===r)return!0;e=o}return!1}rootAcestor(e){for(;e;){let r=this.parent(e);if(r)e=r;else return e}return e}isDescendantOf(e,r){for(;e;){let o=this.parent(e);if(o===r)return!0;e=o}return!1}data(e){return this.get(e)?.data}has(e){return this.childrenOf(e)!==void 0}get(e){return this.fillCaches(),this.objCaches.get(e)}childrenOf(e){return e===null?this:this.get(e)?.children}traverseFrom(e,r){if(e===null)this.traverse(r);else{let o=this.get(e);o&&Gg(o,r)}}traverse(e){zg(this,e)}totalSize(){return this.fillCaches(),this.objCaches.size}parent(e){return this.fillCaches(),this.parentCaches.get(e)}childrenArray(e){return e===null?this:this.get(e).children}modifyById(e,r){if(this.get(e)===void 0)throw new Error("not expected");{let n=this.parent(e),a=this.childrenArray(n),s=a.findIndex(u=>u.id===e);if(s<0)throw new Error("not expected");let l=a[s];return a=[...a],a[s]={...l,data:r},this.modifyArrayBy(n,a)}}modifyArrayBy(e,r){let o=e,n=r;for(;o!==null;){let s=n,l=o;if(o=this.parent(o),o===void 0)throw new Error;n=this.childrenArray(o);let c=n.findIndex(u=>u.id===l);if(c<0)throw new Error;n=[...n],n[c]={...n[c],children:s}}Object.setPrototypeOf(n,ct.prototype);let a=n;return a.fillCaches(),a}runOp(e){switch(e.type){case 7:return this.addOp(e);case 8:return this.deleteOp(e);case 9:return this.moveOp(e)}return null}checkDuplicatedIdRec({id:e,children:r}){if(this.get(e)!==void 0)return!0;for(let o of r)if(this.checkDuplicatedIdRec(o))return!0;return!1}addOp(e){let{parent:r,fi:o,id:n,data:a,children:s}=e;if(r!==null&&this.get(r)===void 0)return null;if(this.checkDuplicatedIdRec(e))return null;{let l=r,c=this.childrenArray(l),u={fi:o,id:n,data:a,children:s};return c=[...c,u],c.sort((d,f)=>d.fi-f.fi),e.localIndex=c.indexOf(u),{data:this.modifyArrayBy(l,c),actual:e,reverse:{type:8,id:n}}}}deleteOp(e){let{id:r}=e;if(this.get(r)===null)return null;{let o=this.parent(r);if(o===void 0)return null;let n=this.childrenArray(o),a=n.findIndex(c=>c.id===r);e.localIndex=a,n=[...n];let s=n.splice(a,1)[0];return{data:this.modifyArrayBy(o,n),actual:e,reverse:{type:7,...s,parent:o}}}}moveOp(e){let{parent:r,fi:o,id:n}=e;if(r!==null&&this.get(r)===void 0)return this.deleteOp({type:8,id:n});if(r!==null){let f=r;for(;f!==null;){if(f===void 0)throw new Error;if(f===n)throw new ga("cyclic tree");f=this.parent(f)}}let a=this.parent(n);if(a===void 0)return null;let s=a,l=this.childrenArray(a),c=l.findIndex(f=>f.id===n);l=[...l];let u=l.splice(c,1)[0],p=this.modifyArrayBy(a,l);a=r,l=p.childrenArray(a);let d=u.fi;return u={...u,fi:o},l=[...l,u],l.sort((f,h)=>f.fi-h.fi),e.localIndex=l.indexOf(u),p=p.modifyArrayBy(a,l),{data:p,actual:e,reverse:{type:9,parent:s,fi:d,id:n}}}previous(e,r){if(r===null){let n=this.childrenArray(e);return n.length===0?null:n[n.length-1].id}let o=null;for(let n of this.childrenArray(e)){if(n.id===r)return o;o=n.id}return null}traverseSortNext(e){let r=this.parent(e);if(r!==void 0){let o=this.childrenArray(r),n=o.findIndex(a=>a.id===e)+1;if(n<o.length)return o[n].id;if(r)return this.traverseSortNext(r)}}sortNext(e){let r=this.childrenArray(e);return r.length>0?r[0].id:this.traverseSortNext(e)}traverseSortPrevious(e){let r=this.childrenArray(e);return r.length>0?this.traverseSortPrevious(r[r.length-1].id):e}sortPrevious(e){let r=this.parent(e);if(r!==void 0){let o=this.childrenArray(r),n=o.findIndex(a=>a.id===e)-1;return n>=0?this.traverseSortPrevious(o[n].id):r}}getAllSorted(e){let r=[];for(let o of e){let n=this.getWithSortKey(o.id);n!==void 0&&r.push({...o,...n})}r.sort((o,n)=>Bg(o.sortKey,n.sortKey));for(let o of r)delete o.sortKey;return r}getWithSortKey(e){var r=e;let o=[],n=this.get(r),a=n;if(n!==void 0){for(;r;)o.splice(0,0,n.fi),r=this.parent(r),r!==null&&(n=this.get(r));return{...a,sortKey:o}}}insertBeforeHelper(e,r,o){return this.insertAfterHelper(e,this.previous(e,r),o)}insertAfterHelper(e,r,o){let n=this.childrenArray(e);if(r===null){if(n.length===0)return wo(0,o,o);{let a=n[0].fi;return wo(a-o,a,o)}}else{let a=this.get(r);if(a===void 0||this.parent(r)!==e)throw new Error("illegal args");let s=n.find(l=>l.fi>a.fi);if(s===void 0){let l=n[n.length-1].fi;return wo(l,l+o,o)}else return wo(a.fi,s.fi,o)}}};var ba;(t=>{function i(e,r){if(r.type!==0)return null;if(Array.isArray(e)){let o=r.props,n={},a=[...e],s=!1;if(o)for(let l of Object.keys(o)){let c=parseInt(l);if(isNaN(c))throw new Error("wrong index");n[l]=a[c],a[c]=o[l],s=!0}return s?{data:a,actual:r,reverse:{type:0,props:n}}:null}else{let o=r.props,n={},a={...e},s=!1;if(o)for(let l of Object.keys(o)){n[l]=a[l];let c=o[l];c===void 0?delete a[l]:a[l]=c,s=!0}return s?{data:a,actual:r,reverse:{type:0,props:n}}:null}}t.runOp=i})(ba||(ba={}));var Se=class extends Array{constructor(...e){super(...e);Object.setPrototypeOf(this,Se.prototype)}deepFreeze(){let e=0;for(;e<this.length;)nl(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){return this.get(e)?.data}get(e){return this.fillCaches(),this.objCaches.get(e)}modifyById(e,r){if(this.get(e)===void 0)throw new Error("not expected");{let n=this,a=n.findIndex(c=>c.id===e);if(a<0)throw new Error("not expected");let s=n[a];return n=[...n],n[a]={...s,data:r},this.modifyArrayBy(n)}}modifyArrayBy(e){Object.setPrototypeOf(e,Se.prototype);let r=e;return Vg()||r.fillCaches(),r}runOp(e){switch(e.type){case 4:return this.addOp(e);case 5:return this.deleteOp(e);case 6:return this.moveOp(e)}return null}addOp(e){let{fi:r,id:o,data:n}=e,a=this,s={fi:r,id:o,data:n};return a=[...a,s],a.sort((c,u)=>c.fi-u.fi),e.localIndex=a.indexOf(s),{data:this.modifyArrayBy(a),actual:e,reverse:{type:5,id:o}}}deleteOp(e){let{id:r}=e,o=this,n=o.findIndex(l=>l.id===r);if(n===-1)return null;e.localIndex=n,o=[...o];let a=o.splice(n,1)[0];return{data:this.modifyArrayBy(o),actual:e,reverse:{type:4,...a}}}moveOp(e){let{fi:r,id:o}=e,n=this;n=[...n];let a=n.findIndex(u=>u.id===o);if(a===-1)return null;let s=n[a].fi,l={...n[a],fi:r};return n[a]=l,n.sort((u,p)=>u.fi-p.fi),e.localIndex=n.indexOf(l),{data:this.modifyArrayBy(n),actual:e,reverse:{type:6,fi:s,id:o}}}previous(e){if(e===null)return this.length===0?null:this[this.length-1].id;let r=null;for(let o of this){if(o.id===e)return r;r=o.id}return null}insertBeforeHelper(e,r){return this.insertAfterHelper(this.previous(e),r)}insertAfterHelper(e,r){let o=this;if(e===null){if(o.length===0)return wo(0,r,r);{let n=o[0].fi;return wo(n-r,n,r)}}else{let n=this.get(e);if(n===void 0)throw new Error("illegal args");let a=o.find(s=>s.fi>n.fi);if(a===void 0){let s=o[o.length-1].fi;return wo(s,s+r,r)}else return wo(n.fi,a.fi,r)}}};function va(i){return i&&typeof i=="object"&&i instanceof Je}var Je=class{unusedFunOverridesTable(t){}runOp(t){let e=[],r=this,o=0,n={};for(;o<t.path.length;){if(e.push(r),r=r===void 0?void 0:r[t.path[o]],r!==void 0&&!va(r))return null;o+=1}r=r?Xc(r):new Je;for(let[l,c]of Object.entries(t.props)){let u=r[l];n[l]=u,c===void 0?delete r[l]:r[l]=c}for(;o>0;){if(Object.keys(r).length===0){let l=e[o-1];l&&(r=Xc(l),delete r[t.path[o-1]])}else{let l=e[o-1];if(l){let c=Xc(l);c[t.path[o-1]]=r,r=c}else{let c=new Je;c[t.path[o-1]]=r,r=c}}o-=1}let a=Object.setPrototypeOf(r,Je.prototype),s={...t,props:n};return{data:a,actual:t,reverse:s}}},Po;(r=>{function i(o,n){return al(o,n)??o}r.apply=i;function t(o,n){return Mp(o,n)}r.merge=t;function e(o,n){let a=0,s=n.path,l=o;for(;a<s.length&&l!==void 0;){if(l=ut.zoomOnce(l,s[a]),l===void 0)return n;if(!va(l))return;a+=1}if(l===void 0)return n;if(!!va(l))if(n.type===0){let c={...n.props};for(let u of Object.keys(l))delete c[u];return{...n,props:c}}else if(n.type===1||n.type===4||n.type===7){let c=Ap([n],l);return c?c[0]:n}else return n}r.filterOp=e})(Po||(Po={}));function Ap(i,t){if(t===void 0)return;let e=!1,r=i.map(o=>{let n=o.id,a=al(o.data,t[n]);if(e=e||a!==void 0,a===void 0&&(a=o.data),o.children){let s=Ap(o.children,t);return s!==void 0?e=!0:s=o.children,{...o,id:n,data:a,children:s}}else return{...o,id:n,data:a}});if(e)return r}function XC(i,t){if(t===void 0)return;let e=!1,r=i.map(o=>{let n=o.id,a=al(o.data,t[n]);return e=e||a!==void 0,a===void 0&&(a=o.data),{...o,id:n,data:a}});if(e)return Object.setPrototypeOf(r,Object.getPrototypeOf(i)),r}function al(i,t){if(!va(t))return t;if(i instanceof ct){let e=Ap(i,t);return e!==void 0&&Object.setPrototypeOf(e,Object.getPrototypeOf(i)),e}else{if(i instanceof Se)return XC(i,t);if(Array.isArray(i)){let e=!1,r=i.map((o,n)=>{let a=al(o,t[n]);return e=e||a!==void 0,a===void 0&&(a=o),a});return e?(Object.setPrototypeOf(r,Object.getPrototypeOf(i)),r):void 0}else{if(i instanceof Je)return Mp(i,t);if(i&&typeof i=="object"){let e={},r=!1;for(let[o,n]of Object.entries(i)){let a=al(n,t[o]);r=r||a!==void 0,a===void 0&&(a=n),e[o]=a}return r?(Object.setPrototypeOf(e,Object.getPrototypeOf(i)),e):void 0}}}}function Mp(i,t){if(i===void 0)return t;if(t===void 0)return i;if(!va(t))return t;if(!va(i))return Po.apply(i,t);let e=new Set;for(let o of Object.keys(i))e.add(o);for(let o of Object.keys(t))e.add(o);let r=new Je;for(let o of e){let n=Mp(i===void 0?void 0:i[o],t===void 0?void 0:t[o]);r[o]=n}return r}function Fg(i,t){let e={cur:[],result:[],len:0};return i=sl(i,t,e)??i,[i,e.result]}function Yc(i,t){return i===null?null:(i.cur[i.len]=t,i.len+=1,i)}function Kc(i){i&&(i.len-=1)}function YC(i){if(i===null)return null;i.result.push(i.cur.slice(0,i.len))}function jg(i,t,e){let r=!1,o=i.map(n=>{let a=n.id,s=t[a];if(s!==void 0&&typeof s=="string"&&(r=!0,a=s,e!==null))throw new Error("not supported");let l=sl(n.data,t,Yc(e,a));Kc(e),r=r||l!==void 0,l===void 0&&(l=n.data);let c=jg(n.children,t,e);return c!==void 0?r=!0:c=n.children,{...n,id:a,data:l,children:c}});if(r)return o}function KC(i,t,e){let r=!1,o=i.map(n=>{let a=n.id,s=t[a];if(s!==void 0&&typeof s=="string"&&(r=!0,a=s,e!==null))throw new Error("not supported");let l=sl(n.data,t,Yc(e,a));return Kc(e),r=r||l!==void 0,l===void 0&&(l=n.data),{...n,id:a,data:l}});if(r)return Object.setPrototypeOf(o,Object.getPrototypeOf(i)),o}function sl(i,t,e){if(i instanceof ct){let r=jg(i,t,e);return r!==void 0&&Object.setPrototypeOf(r,Object.getPrototypeOf(i)),r}else{if(i instanceof Se)return KC(i,t,e);if(Array.isArray(i)){let r=!1,o=i.map((n,a)=>{let s=sl(n,t,Yc(e,a));return Kc(e),r=r||s!==void 0,s===void 0&&(s=n),s});return r?(Object.setPrototypeOf(o,Object.getPrototypeOf(i)),o):void 0}else if(i&&typeof i=="object"&&!xa(i)){let r={},o=!1;for(let[n,a]of Object.entries(i))if(n!=="name"&&n!=="variableId"){let s=t[n];if(typeof s=="string"){if(e!==null)throw new Error("not supported");o=!0,n=s}let l=sl(a,t,Yc(e,n));Kc(e),o=o||l!==void 0,l===void 0&&(l=a),r[n]=l}else r[n]=a;return o?(Object.setPrototypeOf(r,Object.getPrototypeOf(i)),r):void 0}else if(typeof i=="string"){let r=t[i];return r!==void 0&&YC(e),r}else return}}var Sa;(t=>{function i(e,r){let o=ut.zoom(r,e.path);if(typeof o=="object"){let n={};for(let a of Object.keys(e.props))n[a]=o[a];return{...e,props:n}}else return{...e,props:{}}}t.replaceProps=i})(Sa||(Sa={}));var bt;(s=>{function i(l,c){return{...l,path:l.path.slice(c)}}s.drop=i;function t(l,c){return e(l,c)?.data??l}s.applySimple=t;function e(l,c){let u=c.path;for(var p=[];;){let d;if(l instanceof Je&&c.type===0&&(d=l.runOp({...c,path:u.slice(p.length)}),d===null&&(d=void 0)),d===void 0&&p.length===u.length&&(l instanceof ct||l instanceof Se||l instanceof de?d=l.runOp(c):d=ba.runOp(l,c)),d!==void 0)if(d!==null){let m=d.data;for(let y=p.length-1;y>=0;y--){let b=u[y],v=p[y];if(v instanceof ct){if(typeof b=="number")throw new Error("illegal arg");m=v.modifyById(b,m)}else if(v instanceof Se){if(typeof b=="number")throw new Error("illegal arg");m=v.modifyById(b,m)}else if(v instanceof de){if(typeof b=="number")throw new Error("illegal arg");m=v.modifyById(b,m)}else if(v instanceof Je){let w={...v,[b]:m};m=Object.setPrototypeOf(w,Je.prototype)}else if(typeof v=="object")if(Array.isArray(v)){if(typeof b=="string"&&(b=parseInt(b),isNaN(b)))throw new Error("Invalid path");let w=m;m=[...v],m[b]=w}else m={...v,[b]:m};else return null}return{data:m,actual:{...d.actual,path:u},reverse:{...d.reverse,path:u}}}else return null;let f=u[p.length],h;if(l instanceof ct){if(typeof f=="number")throw new Error("");h=l.get(f)?.data}else if(l instanceof Se){if(typeof f=="number")throw new Error("");h=l.get(f)?.data}else l!==null&&(h=l[f]);if(h!==void 0)p.push(l),l=h;else return null}}s.apply=e;function r(l,c){for(let u=0;u<l.length&&u<c.length;u++)if(l[u]!==c[u])return!0;return!1}s.pathDisjoint=r;function o(l,c){if(l.length!==c.length)return!1;for(let u=0;u<l.length;u++)if(l[u]!==c[u])return!1;return!0}s.pathEq=o;function n(l,c){return r(l.path,c.path)}s.commutative=n;function a(l,c){return l.type===0&&c.type===0&&o(l.path,c.path)?Object.keys(l.props).every(u=>c.props[u]!==void 0):!1}s.subsumed=a})(bt||(bt={}));var ll;(l=>{function i(){return[]}l.empty=i;function t(c,u){let p=[];for(let d of c){let[f,...h]=d.path;f===u&&p.push({...d,path:h})}return p}l.removePrefix=t;function e(c,u){return c.map(p=>({...p,path:[u,...p.path]}))}l.addPrefix=e;function r(c,u){return[...c,...u]}l.concat=r;function o(c,u){return[...c.filter(d=>!u.some(f=>bt.subsumed(d,f))),...u]}l.compress=o;function n(c,u){return c.every(p=>u.every(d=>bt.commutative(p,d)))}l.commutative=n;function a(c,u){for(let p of u){let d=s(c,p);d!==null&&(c=d.data)}return c}l.applyAll=a;function s(c,u){var p=c;let d=[],f=[];for(let h of u)try{if(h.type===3||h.type===5&&h.path[h.path.length-1]==="variables"){let m,y,b;if(h.type===3?(m=ut.zoom(p,[...h.path,h.id]),b=bt.apply(p,{...h,type:2})):(m=ut.zoom(p,[...h.path,h.id,"value"]),b=bt.apply(p,h)),b!==null){p=b.data;let[v,w]=Fg(p,{[h.id]:m});p=v;for(let O=0;O<w.length;O++){let S=w[O],T=S.pop();if(typeof T=="number"){let M=[T];for(let D=O+1;D<w.length;D++){let E=w[D],I=E[E.length-1];if(typeof I=="number"&&ut.equal(S,E.slice(0,E.length-1)))M.push(I),w.splice(D,1);else break}let g=ut.zoom(p,S);y=g.map((D,E)=>M.includes(E)?h.id:D),m=g,T=S.pop()}else{if(T==="alphaOverride"||T==="alpha"){m/=100;let M=m,g=ut.zoom(p,S.slice(0,S.length-2)),D=g.layers.map(E=>E.id===S[S.length-1]?{...E,data:{...E.data,[T]:M}}:E);Object.setPrototypeOf(D,Object.getPrototypeOf(g.layers)),g.layers=D}y=h.id}d.push({type:0,path:S,props:{[T]:m}}),f.push({type:0,path:S,props:{[T]:y}})}f.push(b.reverse),d.push(b.actual)}}else{let m=bt.apply(p,h);m!==null&&(d.push(m.actual),p=m.data,f.push(m.reverse))}}catch(m){if(m instanceof ga)return null;throw m}return{data:p,actual:d,reverse:f.reverse()}}l.apply=s})(ll||(ll={}));var Ug=Symbol(),QC=Symbol(),Zc=Symbol(),vn=class{reportOp(t,e,r=[]){let o=this;if(e===null)return;o._current=e.data;let n=r;for(;!(o instanceof Qc);){let a=o._path,s=o._current;if(a!==""&&n.splice(0,0,a),o=o._parent,o===null)return;o.update(a,s)}o.push(n,t,e.actual,e.reverse)}deleteChildren(t){if(this._children){let e=this._children[t];if(e){let r=e[Zc];r&&r(),delete this._children[t]}}}},Ep=class extends vn{constructor(t,e,r){super(),this._parent=t,this._path=e,this._current=r}update(t,e){if(Array.isArray(this._current)){if(typeof t=="string"&&(t=parseInt(t),isNaN(t)))throw new Error("Invalid path");this._current=[...this._current],this._current[t]=e}else if(this._current instanceof Je){let r={...this._current,[t]:e};this._current=Object.setPrototypeOf(r,Je.prototype)}else this._current={...this._current,[t]:e}}runOp(t){this.reportOp(t,ba.runOp(this._current,t),t.path)}},Np=class extends vn{constructor(t,e,r){super(),this._parent=t,this._path=e,this._current=r}update(t,e){this._current={...this._current,[t]:e},Object.setPrototypeOf(this._current,de.prototype)}runOp(t){this.reportOp(t,this._current.runOp(t))}},kg={get(i,t){if(t===Zc)return()=>{i._parent=null};if(t===Ug)return i._current;if(t===QC)return i;let{_current:e,_children:r}=i;if(t==="push"&&Array.isArray(e))throw new Error("not supported to expand array");let o=r===void 0?void 0:r[t];if(o!==void 0)return o;let n=e[t],a=Jc(i,t,n);return a!==n?(r===void 0&&(r={},i._children=r),r[t]=a,a):n},has(i,t){return t 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,t){let e=i._current,r=Reflect.getOwnPropertyDescriptor(e,t);return r&&{writable:!0,configurable:!0,enumerable:r.enumerable,value:e[t]}}},ZC={...kg,set(i,t,e){let r={type:0,props:{[t]:vt(e)??e}};return i.deleteChildren(t),i.runOp(r),!0},deleteProperty(i,t){let e={type:0,props:{[t]:void 0}};return i.deleteChildren(t),i.runOp(e),!0}},JC={...kg,set(i,t,e){return e===void 0?this.deleteProperty(i,t):(i.deleteChildren(t),i.runOp({type:1,id:t,data:e})),!0},deleteProperty(i,t){return i.runOp({type:2,id:t}),!0}},wa=class extends vn{constructor(t,e,r){super(),this._children={},this._parent=t,this._path=e,this._current=r,this[Zc]=()=>{this._parent=null}}unproxy(){return this._current}update(t,e){this._current=this._current.modifyById(t,e)}runOp(t){this.reportOp(t,this._current.runOp(t))}randomId(){return this._current.randomId()}isDescendantOf(t,e){return this._current.isDescendantOf(t,e)}childrenOf(t){return this._current.childrenOf(t)}traverse(t){return this._current.traverse(t)}get(t){return this._current.get(t)}parent(t){return this._current.parent(t)}traverse(t){this._current.traverse((e,r)=>{t(e,this.data(e))})}data(t){let{_current:e,_children:r}=this,o=r===void 0?void 0:r[t];if(o!==void 0)return o;let n=e.get(t)?.data,a=Jc(this,t,n);return a!==n?(r===void 0&&(r={},this._children=r),r[t]=a,a):n}add(t,e,r,o,n){this.runOp({type:7,parent:t,fi:e,id:r,data:o,children:n})}move(t,e,r){this.runOp({type:9,parent:t,fi:e,id:r})}insertAfter(t,e,r){let o=this._current.insertAfterHelper(t,e,r.length);for(let n=0;n<r.length;n++){let a=r[n];this.add(t,o[n],a.id,a.data,a.children)}}insertBefore(t,e,r){let o=this._current.insertBeforeHelper(t,e,r.length);for(let n=0;n<r.length;n++){let a=r[n];this.add(t,o[n],a.id,a.data,a.children)}}moveAfter(t,e,r){let o=this._current.insertAfterHelper(t,e,r.length);for(let n=0;n<r.length;n++){let a=r[n];this.move(t,o[n],a)}}moveBefore(t,e,r){let o=this._current.insertBeforeHelper(t,e,r.length);for(let n=0;n<r.length;n++){let a=r[n];this.move(t,o[n],a)}}delete(t){this.deleteChildren(t),this.runOp({type:8,id:t})}sortNext(t){return this._current.sortNext(t)}sortPrevious(t){return this._current.sortPrevious(t)}getAllSorted(t){return this._current.getAllSorted(t)}},Pa=class extends vn{constructor(t,e,r){super(),this._children={},this._parent=t,this._path=e,this._current=r,this[Zc]=()=>{this._parent=null}}unproxy(){return this._current}get length(){return this._current.length}forEach(t){let e=this.length;for(let r=0;r<e;r++){let o=this._current[r].id,n=this._current[r].fi;t(this.data(this._current[r].id),o,n)}}find(t){let e=this.length;for(let r=0;r<e;r++){let o=this._current[r].id;if(t(this.data(o),o))return this.get(o)}}update(t,e){this._current=this._current.modifyById(t,e)}randomId(){return this._current.randomId()}get(t){return{...this._current.get(t),data:this.data(t)}}data(t){let{_current:e,_children:r}=this,o=r===void 0?void 0:r[t];if(o!==void 0)return o;let n=e.get(t)?.data,a=Jc(this,t,n);return a!==n?(r===void 0&&(r={},this._children=r),r[t]=a,a):n}runOp(t){this.reportOp(t,this._current.runOp(t))}add(t,e,r){this.runOp({type:4,fi:t,id:e,data:r})}move(t,e){this.runOp({type:6,fi:t,id:e})}insertAfter(t,e){let r=this._current.insertAfterHelper(t,e.length);for(let o=0;o<e.length;o++){let n=e[o];this.add(r[o],n.id,n.data)}}insertBefore(t,e){let r=this._current.insertBeforeHelper(t,e.length);for(let o=0;o<e.length;o++){let n=e[o];this.add(r[o],n.id,n.data)}}moveAfter(t,e){let r=this._current.insertAfterHelper(t,e.length);for(let o=0;o<e.length;o++){let n=e[o];this.move(r[o],n)}}moveBefore(t,e){let r=this._current.insertBeforeHelper(t,e.length);for(let o=0;o<e.length;o++){let n=e[o];this.move(r[o],n)}}delete(t){this.deleteChildren(t),this.runOp({type:5,id:t})}};function Ip(i,t,e){if(i.length>0){let r=i[i.length-1];if(r.type===0&&t.type===0&&ut.equal(r.path,e)){Object.assign(r.props,t.props);return}}i.push({...t,path:e})}var Qc=class extends vn{constructor(t){super(),this.ts=[],this.actual=[],this.reverse=[],this._current=t}update(t,e){if(t!=="")throw new Error("");this._current=e}push(t,e,r,o){Ip(this.ts,e,t),Ip(this.actual,r,t),Ip(this.reverse,o,t)}result(){return{data:this._current,ts:this.ts,actual:this.actual,reverse:this.reverse.reverse()}}};function Jc(i,t,e){return e instanceof ct?new wa(i,t,e):e instanceof Se?new Pa(i,t,e):e instanceof de?new Proxy(new Np(i,t,e),JC):e!==null&&typeof e=="object"?xa(e)?e:new Proxy(new Ep(i,t,e),ZC):e}function Dp(i){let t=new Qc(i);return[Jc(t,"",i),t]}function Ai(i,t){let[e,r]=Dp(i);return t(e),r.result()}function vt(i){return i instanceof wa||i instanceof Pa?i._current:i!==null&&typeof i=="object"?i[Ug]:i}var ut;(o=>{function i(n,a){if(a.length===n.length)for(var s=0;s<n.length;){if(n[s]!==a[s])return!1;s+=1}else return!1;return!0}o.equal=i;function t(n,a,s){let l=r(s,n);if(l!==void 0&&typeof l=="object"&&l!==null){let c={...a};return Object.keys(l).forEach(u=>{delete c[u]}),c}else return a}o.removeOverridden=t;function e(n,a){if((n instanceof ct||n instanceof wa)&&typeof a=="string")return n.data(a);if((n instanceof Se||n instanceof Pa)&&typeof a=="string")return n.data(a);if(typeof a=="number"&&Array.isArray(n))return n[a];if(typeof a=="string"&&typeof n=="object"&&n!==null)return n[a]}o.zoomOnce=e;function r(n,a,s=0){for(;s<a.length&&n!==void 0;)n=e(n,a[s]),s+=1;return n}o.zoom=r})(ut||(ut={}));function Hg(i,t){let e=[];if(t.length===i.length)for(var r=0;r<i.length;){if(t[r]==="*")e.push(i[r]);else if(i[r]!==t[r])return null;r+=1}else return null;return e}function je(i,t){let e=[];if(t.length<=i.length)for(var r=0;r<t.length;){if(t[r]==="*")e.push(i[r]);else if(i[r]!==t[r])return null;r+=1}else return null;return e}var eu=class{},cl=class extends eu{constructor(e){super();this.id=e}},ul=class extends eu{constructor(e){super();this.data=e}};var Rp;try{Rp=new TextDecoder}catch{}var fe,Ii,G=0;var Zg=[],Lp=Zg,Bp=0,vr={},Qe,Mi,Fr=0,Oo=0,Dr,Jo,fr=[],rt,Wg={useRecords:!1,mapsAsObjects:!0},dl=class{},zp=new dl;zp.name="MessagePack 0xC1";var Oa=!1,To=class{constructor(t){t&&(t.useRecords===!1&&t.mapsAsObjects===void 0&&(t.mapsAsObjects=!0),t.structures?t.structures.sharedLength=t.structures.length:t.getStructures&&((t.structures=[]).uninitialized=!0,t.structures.sharedLength=0)),Object.assign(this,t)}unpack(t,e){if(fe)return o0(()=>(ru(),this?this.unpack(t,e):To.prototype.unpack.call(Wg,t,e)));Ii=e>-1?e:t.length,G=0,Bp=0,Oo=0,Mi=null,Lp=Zg,Dr=null,fe=t;try{rt=t.dataView||(t.dataView=new DataView(t.buffer,t.byteOffset,t.byteLength))}catch(r){throw fe=null,t instanceof Uint8Array?r:new Error("Source must be a Uint8Array or Buffer but was a "+(t&&typeof t=="object"?t.constructor.name:typeof t))}if(this instanceof To){if(vr=this,this.structures)return Qe=this.structures,tu();(!Qe||Qe.length>0)&&(Qe=[])}else vr=Wg,(!Qe||Qe.length>0)&&(Qe=[]);return tu()}unpackMultiple(t,e){let r,o=0;try{Oa=!0;let n=t.length,a=this?this.unpack(t,n):nu.unpack(t,n);if(e){for(e(a);G<n;)if(o=G,e(tu())===!1)return}else{for(r=[a];G<n;)o=G,r.push(tu());return r}}catch(n){throw n.lastPosition=o,n.values=r,n}finally{Oa=!1,ru()}}_mergeStructures(t,e){t=t||[];for(let r=0,o=t.length;r<o;r++){let n=t[r];n&&(n.isShared=!0,r>=32&&(n.highByte=r-32>>5))}t.sharedLength=t.length;for(let r in e||[])if(r>=0){let o=t[r],n=e[r];n&&(o&&((t.restoreStructures||(t.restoreStructures=[]))[r]=o),t[r]=n)}return this.structures=t}decode(t,e){return this.unpack(t,e)}};function tu(){try{if(!vr.trusted&&!Oa){let t=Qe.sharedLength||0;t<Qe.length&&(Qe.length=t)}let i=Mt();if(G==Ii)Qe.restoreStructures&&qg(),Qe=null,fe=null,Jo&&(Jo=null);else if(G>Ii){let t=new Error("Unexpected end of MessagePack data");throw t.incomplete=!0,t}else if(!Oa)throw new Error("Data read, but end of buffer not reached");return i}catch(i){throw Qe.restoreStructures&&qg(),ru(),(i instanceof RangeError||i.message.startsWith("Unexpected end of buffer"))&&(i.incomplete=!0),i}}function qg(){for(let i in Qe.restoreStructures)Qe[i]=Qe.restoreStructures[i];Qe.restoreStructures=null}function Mt(){let i=fe[G++];if(i<160)if(i<128){if(i<64)return i;{let t=Qe[i&63]||vr.getStructures&&Jg()[i&63];return t?(t.read||(t.read=Gp(t,i&63)),t.read()):i}}else if(i<144)if(i-=128,vr.mapsAsObjects){let t={};for(let e=0;e<i;e++)t[t0()]=Mt();return t}else{let t=new Map;for(let e=0;e<i;e++)t.set(Mt(),Mt());return t}else{i-=144;let t=new Array(i);for(let e=0;e<i;e++)t[e]=Mt();return t}else if(i<192){let t=i-160;if(Oo>=G)return Mi.slice(G-Fr,(G+=t)-Fr);if(Oo==0&&Ii<140){let e=t<16?Fp(t):e0(t);if(e!=null)return e}return Vp(t)}else{let t;switch(i){case 192:return null;case 193:return Dr?(t=Mt(),t>0?Dr[1].slice(Dr.position1,Dr.position1+=t):Dr[0].slice(Dr.position0,Dr.position0-=t)):zp;case 194:return!1;case 195:return!0;case 196:return _p(fe[G++]);case 197:return t=rt.getUint16(G),G+=2,_p(t);case 198:return t=rt.getUint32(G),G+=4,_p(t);case 199:return Sn(fe[G++]);case 200:return t=rt.getUint16(G),G+=2,Sn(t);case 201:return t=rt.getUint32(G),G+=4,Sn(t);case 202:if(t=rt.getFloat32(G),vr.useFloat32>2){let e=iu[(fe[G]&127)<<1|fe[G+1]>>7];return G+=4,(e*t+(t>0?.5:-.5)>>0)/e}return G+=4,t;case 203:return t=rt.getFloat64(G),G+=8,t;case 204:return fe[G++];case 205:return t=rt.getUint16(G),G+=2,t;case 206:return t=rt.getUint32(G),G+=4,t;case 207:return vr.int64AsNumber?(t=rt.getUint32(G)*4294967296,t+=rt.getUint32(G+4)):t=rt.getBigUint64(G),G+=8,t;case 208:return rt.getInt8(G++);case 209:return t=rt.getInt16(G),G+=2,t;case 210:return t=rt.getInt32(G),G+=4,t;case 211:return vr.int64AsNumber?(t=rt.getInt32(G)*4294967296,t+=rt.getUint32(G+4)):t=rt.getBigInt64(G),G+=8,t;case 212:if(t=fe[G++],t==114)return Qg(fe[G++]&63);{let e=fr[t];if(e)return e.read?(G++,e.read(Mt())):e.noBuffer?(G++,e()):e(fe.subarray(G,++G));throw new Error("Unknown extension "+t)}case 213:return t=fe[G],t==114?(G++,Qg(fe[G++]&63,fe[G++])):Sn(2);case 214:return Sn(4);case 215:return Sn(8);case 216:return Sn(16);case 217:return t=fe[G++],Oo>=G?Mi.slice(G-Fr,(G+=t)-Fr):tA(t);case 218:return t=rt.getUint16(G),G+=2,Oo>=G?Mi.slice(G-Fr,(G+=t)-Fr):rA(t);case 219:return t=rt.getUint32(G),G+=4,Oo>=G?Mi.slice(G-Fr,(G+=t)-Fr):oA(t);case 220:return t=rt.getUint16(G),G+=2,Xg(t);case 221:return t=rt.getUint32(G),G+=4,Xg(t);case 222:return t=rt.getUint16(G),G+=2,Yg(t);case 223:return t=rt.getUint32(G),G+=4,Yg(t);default:if(i>=224)return i-256;if(i===void 0){let e=new Error("Unexpected end of MessagePack data");throw e.incomplete=!0,e}throw new Error("Unknown MessagePack token "+i)}}}var eA=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function Gp(i,t){function e(){if(e.count++>2){let o=i.read=new Function("r","return function(){return {"+i.map(n=>eA.test(n)?n+":r()":"["+JSON.stringify(n)+"]:r()").join(",")+"}}")(Mt);return i.highByte===0&&(i.read=$g(t,i.read)),o()}let r={};for(let o=0,n=i.length;o<n;o++){let a=i[o];r[a]=Mt()}return r}return e.count=0,i.highByte===0?$g(t,e):e}var $g=(i,t)=>function(){let e=fe[G++];if(e===0)return t();let r=i<32?-(i+(e<<5)):i+(e<<5),o=Qe[r]||Jg()[r];if(!o)throw new Error("Record id is not defined for "+r);return o.read||(o.read=Gp(o,i)),o.read()};function Jg(){let i=o0(()=>(fe=null,vr.getStructures()));return Qe=vr._mergeStructures(i,Qe)}var Vp=ou,tA=ou,rA=ou,oA=ou;function ou(i){let t;if(i<16&&(t=Fp(i)))return t;if(i>64&&Rp)return Rp.decode(fe.subarray(G,G+=i));let e=G+i,r=[];for(t="";G<e;){let o=fe[G++];if((o&128)===0)r.push(o);else if((o&224)===192){let n=fe[G++]&63;r.push((o&31)<<6|n)}else if((o&240)===224){let n=fe[G++]&63,a=fe[G++]&63;r.push((o&31)<<12|n<<6|a)}else if((o&248)===240){let n=fe[G++]&63,a=fe[G++]&63,s=fe[G++]&63,l=(o&7)<<18|n<<12|a<<6|s;l>65535&&(l-=65536,r.push(l>>>10&1023|55296),l=56320|l&1023),r.push(l)}else r.push(o);r.length>=4096&&(t+=Kt.apply(String,r),r.length=0)}return r.length>0&&(t+=Kt.apply(String,r)),t}function Xg(i){let t=new Array(i);for(let e=0;e<i;e++)t[e]=Mt();return t}function Yg(i){if(vr.mapsAsObjects){let t={};for(let e=0;e<i;e++)t[t0()]=Mt();return t}else{let t=new Map;for(let e=0;e<i;e++)t.set(Mt(),Mt());return t}}var Kt=String.fromCharCode;function e0(i){let t=G,e=new Array(i);for(let r=0;r<i;r++){let o=fe[G++];if((o&128)>0){G=t;return}e[r]=o}return Kt.apply(String,e)}function Fp(i){if(i<4)if(i<2){if(i===0)return"";{let t=fe[G++];if((t&128)>1){G-=1;return}return Kt(t)}}else{let t=fe[G++],e=fe[G++];if((t&128)>0||(e&128)>0){G-=2;return}if(i<3)return Kt(t,e);let r=fe[G++];if((r&128)>0){G-=3;return}return Kt(t,e,r)}else{let t=fe[G++],e=fe[G++],r=fe[G++],o=fe[G++];if((t&128)>0||(e&128)>0||(r&128)>0||(o&128)>0){G-=4;return}if(i<6){if(i===4)return Kt(t,e,r,o);{let n=fe[G++];if((n&128)>0){G-=5;return}return Kt(t,e,r,o,n)}}else if(i<8){let n=fe[G++],a=fe[G++];if((n&128)>0||(a&128)>0){G-=6;return}if(i<7)return Kt(t,e,r,o,n,a);let s=fe[G++];if((s&128)>0){G-=7;return}return Kt(t,e,r,o,n,a,s)}else{let n=fe[G++],a=fe[G++],s=fe[G++],l=fe[G++];if((n&128)>0||(a&128)>0||(s&128)>0||(l&128)>0){G-=8;return}if(i<10){if(i===8)return Kt(t,e,r,o,n,a,s,l);{let c=fe[G++];if((c&128)>0){G-=9;return}return Kt(t,e,r,o,n,a,s,l,c)}}else if(i<12){let c=fe[G++],u=fe[G++];if((c&128)>0||(u&128)>0){G-=10;return}if(i<11)return Kt(t,e,r,o,n,a,s,l,c,u);let p=fe[G++];if((p&128)>0){G-=11;return}return Kt(t,e,r,o,n,a,s,l,c,u,p)}else{let c=fe[G++],u=fe[G++],p=fe[G++],d=fe[G++];if((c&128)>0||(u&128)>0||(p&128)>0||(d&128)>0){G-=12;return}if(i<14){if(i===12)return Kt(t,e,r,o,n,a,s,l,c,u,p,d);{let f=fe[G++];if((f&128)>0){G-=13;return}return Kt(t,e,r,o,n,a,s,l,c,u,p,d,f)}}else{let f=fe[G++],h=fe[G++];if((f&128)>0||(h&128)>0){G-=14;return}if(i<15)return Kt(t,e,r,o,n,a,s,l,c,u,p,d,f,h);let m=fe[G++];if((m&128)>0){G-=15;return}return Kt(t,e,r,o,n,a,s,l,c,u,p,d,f,h,m)}}}}}function _p(i){return vr.copyBuffers?Uint8Array.prototype.slice.call(fe,G,G+=i):fe.subarray(G,G+=i)}function Sn(i){let t=fe[G++];if(fr[t])return fr[t](fe.subarray(G,G+=i));throw new Error("Unknown extension type "+t)}var Kg=new Array(4096);function t0(){let i=fe[G++];if(i>=160&&i<192){if(i=i-160,Oo>=G)return Mi.slice(G-Fr,(G+=i)-Fr);if(!(Oo==0&&Ii<180))return Vp(i)}else return G--,Mt();let t=(i<<5^(i>1?rt.getUint16(G):i>0?fe[G]:0))&4095,e=Kg[t],r=G,o=G+i-3,n,a=0;if(e&&e.bytes==i){for(;r<o;){if(n=rt.getUint32(r),n!=e[a++]){r=1879048192;break}r+=4}for(o+=3;r<o;)if(n=fe[r++],n!=e[a++]){r=1879048192;break}if(r===o)return G=r,e.string;o-=3,r=G}for(e=[],Kg[t]=e,e.bytes=i;r<o;)n=rt.getUint32(r),e.push(n),r+=4;for(o+=3;r<o;)n=fe[r++],e.push(n);let s=i<16?Fp(i):e0(i);return s!=null?e.string=s:e.string=Vp(i)}var Qg=(i,t)=>{var e=Mt();let r=i;t!==void 0&&(i=i<32?-((t<<5)+i):(t<<5)+i,e.highByte=t);let o=Qe[i];return o&&o.isShared&&((Qe.restoreStructures||(Qe.restoreStructures=[]))[i]=o),Qe[i]=e,e.read=Gp(e,r),e.read()},r0=typeof self=="object"?self:global;fr[0]=()=>{};fr[0].noBuffer=!0;fr[101]=()=>{let i=Mt();return(r0[i[0]]||Error)(i[1])};fr[105]=i=>{let t=rt.getUint32(G-4);Jo||(Jo=new Map);let e=fe[G],r;e>=144&&e<160||e==220||e==221?r=[]:r={};let o={target:r};Jo.set(t,o);let n=Mt();return o.used?Object.assign(r,n):(o.target=n,n)};fr[112]=i=>{let t=rt.getUint32(G-4),e=Jo.get(t);return e.used=!0,e.target};fr[115]=()=>new Set(Mt());var jp=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(i=>i+"Array");fr[116]=i=>{let t=i[0],e=jp[t];if(!e)throw new Error("Could not find typed array for code "+t);return new r0[e](Uint8Array.prototype.slice.call(i,1).buffer)};fr[120]=()=>{let i=Mt();return new RegExp(i[0],i[1])};fr[98]=i=>{let t=(i[0]<<24)+(i[1]<<16)+(i[2]<<8)+i[3],e=G;G+=t-4,Dr=[Mt(),Mt()],Dr.position0=0,Dr.position1=0;let r=G;G=e;try{return Mt()}finally{G=r}};fr[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 o0(i){let t=Ii,e=G,r=Bp,o=Fr,n=Oo,a=Mi,s=Lp,l=Jo,c=Dr,u=new Uint8Array(fe.slice(0,Ii)),p=Qe,d=Qe.slice(0,Qe.length),f=vr,h=Oa,m=i();return Ii=t,G=e,Bp=r,Fr=o,Oo=n,Mi=a,Lp=s,Jo=l,Dr=c,fe=u,Oa=h,Qe=p,Qe.splice(0,Qe.length,...d),vr=f,rt=new DataView(fe.buffer,fe.byteOffset,fe.byteLength),m}function ru(){fe=null,Jo=null,Qe=null}function i0(i){i.unpack?fr[i.type]=i.unpack:fr[i.type]=i}var iu=new Array(147);for(let i=0;i<256;i++)iu[i]=+("1e"+Math.floor(45.15-i*.30103));var nu=new To({useRecords:!1}),iA=nu.unpack,nA=nu.unpackMultiple,aA=nu.unpack,au={NEVER:0,ALWAYS:1,DECIMAL_ROUND:3,DECIMAL_FIT:4},sA=new Float32Array(1),dF=new Uint8Array(sA.buffer,0,4);var su;try{su=new TextEncoder}catch{}var lu,kp,cu=typeof Buffer<"u",Up=cu?Buffer.allocUnsafeSlow:Uint8Array,l0=cu?Buffer:Uint8Array,n0=cu?4294967296:2144337920,X,Nt,k=0,Co,Ao=null,lA=/[\u0080-\uFFFF]/,pl=Symbol("record-id"),wn=class extends To{constructor(t){super(t),this.offset=0;let e,r,o,n,a,s,l=0,c=l0.prototype.utf8Write?function(g,D,E){return X.utf8Write(g,D,E)}:su&&su.encodeInto?function(g,D){return su.encodeInto(g,X.subarray(D)).written}:!1,u=this;t||(t={});let p=t&&t.sequential,d=t.structures||t.saveStructures,f=t.maxSharedStructures;if(f==null&&(f=d?32:0),f>8160)throw new Error("Maximum maxSharedStructure is 8160");let h=t.maxOwnStructures;h==null&&(h=d?32:64),p&&!t.saveStructures&&(this.structures=[]);let m=f>32||h+f>64,y=f+64,b=f+h+64;if(b>8256)throw new Error("Maximum maxSharedStructure + maxOwnStructure is 8192");let v=[],w=0,O=0;this.pack=this.encode=function(g,D){if(X||(X=new Up(8192),Nt=new DataView(X.buffer,0,8192),k=0),Co=X.length-10,Co-k<2048?(X=new Up(X.length),Nt=new DataView(X.buffer,0,X.length),Co=X.length-10,k=0):k=k+7&2147483640,r=k,s=u.structuredClone?new Map:null,u.bundleStrings?(Ao=["",""],X[k++]=214,X[k++]=98,Ao.position=k-r,k+=4):Ao=null,o=u.structures,o){o.uninitialized&&(o=u._mergeStructures(u.getStructures()));let E=o.sharedLength||0;if(E>f)throw new Error("Shared structures is larger than maximum shared structures, try increasing maxSharedStructures to "+o.sharedLength);if(!o.transitions){o.transitions=Object.create(null);for(let I=0;I<E;I++){let N=o[I];if(!N)continue;let _,R=o.transitions;for(let V=0,U=N.length;V<U;V++){let B=N[V];_=R[B],_||(_=R[B]=Object.create(null)),R=_}R[pl]=I+64}l=E}p||(o.nextId=E+64)}n&&(n=!1),a=o||[];try{if(S(g),Ao){Nt.setUint32(Ao.position+r,k-Ao.position-r);let E=Ao;Ao=null,S(E[0]),S(E[1])}if(u.offset=k,s&&s.idsToInsert){k+=s.idsToInsert.length*6,k>Co&&M(k),u.offset=k;let E=uA(X.subarray(r,k),s.idsToInsert);return s=null,E}return D&u0?(X.start=r,X.end=k,X):X.subarray(r,k)}finally{if(o){if(O<10&&O++,w>1e4)o.transitions=null,O=0,w=0,v.length>0&&(v=[]);else if(v.length>0&&!p){for(let E=0,I=v.length;E<I;E++)v[E][pl]=0;v=[]}if(n&&u.saveStructures){let E=o.sharedLength||f;o.length>E&&(o=o.slice(0,E));let I=X.subarray(r,k);return u.saveStructures(o,l)===!1?(u._mergeStructures(u.getStructures()),u.pack(g)):(l=E,I)}}D&gA&&(k=r)}};let S=g=>{k>Co&&(X=M(k));var D=typeof g,E;if(D==="string"){let I=g.length;if(Ao&&I>=8&&I<4096){let R=lA.test(g);Ao[R?0:1]+=g,X[k++]=193,S(R?-I:I);return}let N;I<32?N=1:I<256?N=2:I<65536?N=3:N=5;let _=I*3;if(k+_>Co&&(X=M(k+_)),I<64||!c){let R,V,U,B=k+N;for(R=0;R<I;R++)V=g.charCodeAt(R),V<128?X[B++]=V:V<2048?(X[B++]=V>>6|192,X[B++]=V&63|128):(V&64512)===55296&&((U=g.charCodeAt(R+1))&64512)===56320?(V=65536+((V&1023)<<10)+(U&1023),R++,X[B++]=V>>18|240,X[B++]=V>>12&63|128,X[B++]=V>>6&63|128,X[B++]=V&63|128):(X[B++]=V>>12|224,X[B++]=V>>6&63|128,X[B++]=V&63|128);E=B-k-N}else E=c(g,k+N,_);E<32?X[k++]=160|E:E<256?(N<2&&X.copyWithin(k+2,k+1,k+1+E),X[k++]=217,X[k++]=E):E<65536?(N<3&&X.copyWithin(k+3,k+2,k+2+E),X[k++]=218,X[k++]=E>>8,X[k++]=E&255):(N<5&&X.copyWithin(k+5,k+3,k+3+E),X[k++]=219,Nt.setUint32(k,E),k+=4),k+=E}else if(D==="number")if(g>>>0===g)g<64?X[k++]=g:g<256?(X[k++]=204,X[k++]=g):g<65536?(X[k++]=205,X[k++]=g>>8,X[k++]=g&255):(X[k++]=206,Nt.setUint32(k,g),k+=4);else if(g>>0===g)g>=-32?X[k++]=256+g:g>=-128?(X[k++]=208,X[k++]=g+256):g>=-32768?(X[k++]=209,Nt.setInt16(k,g),k+=2):(X[k++]=210,Nt.setInt32(k,g),k+=4);else{let I;if((I=this.useFloat32)>0&&g<4294967296&&g>=-2147483648){X[k++]=202,Nt.setFloat32(k,g);let N;if(I<4||(N=g*iu[(X[k]&127)<<1|X[k+1]>>7])>>0===N){k+=4;return}else k--}X[k++]=203,Nt.setFloat64(k,g),k+=8}else if(D==="object")if(!g)X[k++]=192;else{if(s){let N=s.get(g);if(N){if(!N.id){let _=s.idsToInsert||(s.idsToInsert=[]);N.id=_.push(N)}X[k++]=214,X[k++]=112,Nt.setUint32(k,N.id),k+=4;return}else s.set(g,{offset:k-r})}let I=g.constructor;if(I===Object)T(g,!0);else if(I===Array){E=g.length,E<16?X[k++]=144|E:E<65536?(X[k++]=220,X[k++]=E>>8,X[k++]=E&255):(X[k++]=221,Nt.setUint32(k,E),k+=4);for(let N=0;N<E;N++)S(g[N])}else if(I===Map){E=g.size,E<16?X[k++]=128|E:E<65536?(X[k++]=222,X[k++]=E>>8,X[k++]=E&255):(X[k++]=223,Nt.setUint32(k,E),k+=4);for(let[N,_]of g)S(N),S(_)}else{for(let N=0,_=lu.length;N<_;N++){let R=kp[N];if(g instanceof R){let V=lu[N];if(V.write){V.type&&(X[k++]=212,X[k++]=V.type,X[k++]=0),S(V.write.call(this,g));return}let U=X,B=Nt,q=k;X=null;let j;try{j=V.pack.call(this,g,F=>(X=U,U=null,k+=F,k>Co&&M(k),{target:X,targetView:Nt,position:k-F}),S)}finally{U&&(X=U,Nt=B,k=q,Co=X.length-10)}j&&(j.length+k>Co&&M(j.length+k),k=cA(j,X,k,V.type));return}}T(g,!g.hasOwnProperty)}}else if(D==="boolean")X[k++]=g?195:194;else if(D==="bigint"){if(g<BigInt(1)<<BigInt(63)&&g>=-(BigInt(1)<<BigInt(63)))X[k++]=211,Nt.setBigInt64(k,g);else if(g<BigInt(1)<<BigInt(64)&&g>0)X[k++]=207,Nt.setBigUint64(k,g);else if(this.largeBigIntToFloat)X[k++]=203,Nt.setFloat64(k,Number(g));else throw new RangeError(g+" was too large to fit in MessagePack 64-bit integer format, set largeBigIntToFloat to convert to float-64");k+=8}else if(D==="undefined")this.encodeUndefinedAsNil?X[k++]=192:(X[k++]=212,X[k++]=0,X[k++]=0);else if(D==="function")S(this.writeFunction&&this.writeFunction());else throw new Error("Unknown type: "+D)},T=this.useRecords===!1?this.variableMapSize?g=>{let D=Object.keys(g),E=D.length;E<16?X[k++]=128|E:E<65536?(X[k++]=222,X[k++]=E>>8,X[k++]=E&255):(X[k++]=223,Nt.setUint32(k,E),k+=4);let I;for(let N=0;N<E;N++)S(I=D[N]),S(g[I])}:(g,D)=>{X[k++]=222;let E=k-r;k+=2;let I=0;for(let N in g)(D||g.hasOwnProperty(N))&&(S(N),S(g[N]),I++);X[E+++r]=I>>8,X[E+r]=I&255}:g=>{let D=Object.keys(g),E,I=a.transitions||(a.transitions=Object.create(null)),N=0;for(let R=0,V=D.length;R<V;R++){let U=D[R];E=I[U],E||(E=I[U]=Object.create(null),N++),I=E}let _=I[pl];if(_)_>=96&&m?(X[k++]=((_-=96)&31)+96,X[k++]=_>>5):X[k++]=_;else{_=a.nextId,_||(_=64),_<y&&this.shouldShareStructure&&!this.shouldShareStructure(D)?(_=a.nextOwnId,_<b||(_=y),a.nextOwnId=_+1):(_>=b&&(_=y),a.nextId=_+1);let R=D.highByte=_>=96&&m?_-96>>5:-1;I[pl]=_,a[_-64]=D,_<y?(D.isShared=!0,a.sharedLength=_-63,n=!0,R>=0?(X[k++]=(_&31)+96,X[k++]=R):X[k++]=_):(R>=0?(X[k++]=213,X[k++]=114,X[k++]=(_&31)+96,X[k++]=R):(X[k++]=212,X[k++]=114,X[k++]=_),N&&(w+=O*N),v.length>=h&&(v.shift()[pl]=0),v.push(I),S(D))}for(let R=0,V=D.length;R<V;R++)S(g[D[R]])},M=g=>{let D;if(g>16777216){if(g-r>n0)throw new Error("Packed buffer would be larger than maximum buffer size");D=Math.min(n0,Math.round(Math.max((g-r)*(g>67108864?1.25:2),4194304)/4096)*4096)}else D=(Math.max(g-r<<2,X.length-1)>>12)+1<<12;let E=new Up(D);return Nt=new DataView(E.buffer,0,D),X.copy?X.copy(E,0,r,g):E.set(X.slice(r,g)),k-=r,r=0,Co=E.length-10,X=E}}useBuffer(t){X=t,Nt=new DataView(X.buffer,X.byteOffset,X.byteLength),k=0}};kp=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,dl];lu=[{pack(i,t,e){let r=i.getTime()/1e3;if((this.useTimestamp32||i.getMilliseconds()===0)&&r>=0&&r<4294967296){let{target:o,targetView:n,position:a}=t(6);o[a++]=214,o[a++]=255,n.setUint32(a,r)}else if(r>0&&r<17179869184){let{target:o,targetView:n,position:a}=t(10);o[a++]=215,o[a++]=255,n.setUint32(a,i.getMilliseconds()*4e6+(r/1e3/4294967296>>0)),n.setUint32(a+4,r)}else if(isNaN(r)){if(this.onInvalidDate)return t(0),e(this.onInvalidDate());let{target:o,targetView:n,position:a}=t(3);o[a++]=212,o[a++]=255,o[a++]=255}else{let{target:o,targetView:n,position:a}=t(15);o[a++]=199,o[a++]=12,o[a++]=255,n.setUint32(a,i.getMilliseconds()*1e6),n.setBigInt64(a+4,BigInt(Math.floor(r)))}}},{pack(i,t,e){let r=Array.from(i),{target:o,position:n}=t(this.structuredClone?3:0);this.structuredClone&&(o[n++]=212,o[n++]=115,o[n++]=0),e(r)}},{pack(i,t,e){let{target:r,position:o}=t(this.structuredClone?3:0);this.structuredClone&&(r[o++]=212,r[o++]=101,r[o++]=0),e([i.name,i.message])}},{pack(i,t,e){let{target:r,position:o}=t(this.structuredClone?3:0);this.structuredClone&&(r[o++]=212,r[o++]=120,r[o++]=0),e([i.source,i.flags])}},{pack(i,t){this.structuredClone?a0(i,16,t):s0(cu?Buffer.from(i):new Uint8Array(i),t)}},{pack(i,t){let e=i.constructor;e!==l0&&this.structuredClone?a0(i,jp.indexOf(e.name),t):s0(i,t)}},{pack(i,t){let{target:e,position:r}=t(1);e[r]=193}}];function a0(i,t,e,r){let o=i.byteLength;if(o+1<256){var{target:n,position:a}=e(4+o);n[a++]=199,n[a++]=o+1}else if(o+1<65536){var{target:n,position:a}=e(5+o);n[a++]=200,n[a++]=o+1>>8,n[a++]=o+1&255}else{var{target:n,position:a,targetView:s}=e(7+o);n[a++]=201,s.setUint32(a,o+1),a+=4}n[a++]=116,n[a++]=t,n.set(new Uint8Array(i.buffer,i.byteOffset,i.byteLength),a)}function s0(i,t){let e=i.byteLength;var r,o;if(e<256){var{target:r,position:o}=t(e+2);r[o++]=196,r[o++]=e}else if(e<65536){var{target:r,position:o}=t(e+3);r[o++]=197,r[o++]=e>>8,r[o++]=e&255}else{var{target:r,position:o,targetView:n}=t(e+5);r[o++]=198,n.setUint32(o,e),o+=4}r.set(i,o)}function cA(i,t,e,r){let o=i.length;switch(o){case 1:t[e++]=212;break;case 2:t[e++]=213;break;case 4:t[e++]=214;break;case 8:t[e++]=215;break;case 16:t[e++]=216;break;default:o<256?(t[e++]=199,t[e++]=o):o<65536?(t[e++]=200,t[e++]=o>>8,t[e++]=o&255):(t[e++]=201,t[e++]=o>>24,t[e++]=o>>16&255,t[e++]=o>>8&255,t[e++]=o&255)}return t[e++]=r,t.set(i,e),e+=o,e}function uA(i,t){let e,r=t.length*6,o=i.length-r;for(t.sort((n,a)=>n.offset>a.offset?1:-1);e=t.pop();){let n=e.offset,a=e.id;i.copyWithin(n+r,n,o),r-=6;let s=n+r;i[s++]=214,i[s++]=105,i[s++]=a>>24,i[s++]=a>>16&255,i[s++]=a>>8&255,i[s++]=a&255,o=n}return i}function Ei(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)");kp.unshift(i.Class),lu.unshift(i)}i0(i)}var c0=new wn({useRecords:!1}),dA=c0.pack,pA=c0.pack;var{NEVER:fA,ALWAYS:hA,DECIMAL_ROUND:mA,DECIMAL_FIT:yA}=au,u0=512,gA=1024;var d0=new wn({structuredClone:!0});Ei({Class:de.prototype.constructor,type:1,write(i){return{...i}},read(i){return Object.setPrototypeOf(i,de.prototype),i}});Ei({Class:Se.prototype.constructor,type:2,write(i){return[...i]},read(i){return Object.setPrototypeOf(i,Se.prototype),i}});Ei({Class:ct.prototype.constructor,type:3,write(i){return[...i]},read(i){return Object.setPrototypeOf(i,ct.prototype),i}});Ei({Class:cl.prototype.constructor,type:4,write(i){return i.id},read(i){return new cl(i)}});Ei({Class:ul.prototype.constructor,type:5,write(i){return i.data},read(i){return new ul(i)}});Ei({Class:Je.prototype.constructor,type:6,write(i){return{...i}},read(i){return Object.setPrototypeOf(i,Je.prototype),i}});function xA(i){var t=0;if(i.length===0)return t;for(let e=0;e<i.length;e++){let r=i[e];t=(t<<5)-t+r,t=t&t}return t}function Hp(i){if(xa(i))return i;if(Array.isArray(i))return i.map(Hp);if(typeof i=="object"&&i!==null){let t={};for(let e of Object.keys(i).sort())t[e]=Hp(i[e]);return Object.setPrototypeOf(t,Object.getPrototypeOf(i)),t}else return i}var uu;(r=>{function i(o){return d0.pack(o)}r.serialize=i;function t(o){return d0.unpack(o)}r.deserialize=t;function e(o){return xA(i(Hp(o))).toString()}r.checksum=e})(uu||(uu={}));var _i="personal camera",Ri="a218fcc3-276b-49b9-b485-49037fd14f5f",g0=2960946,Dt=5526619;var Ta;(f=>{function i(h,m){return h[0]===m[0]&&h[1]===m[1]}f.isEqual=i;function t(h,m,y){return[h[0]+(m[0]-h[0])*y,h[1]+(m[1]-h[1])*y]}f.lerp=t;function e(h,m){return[h[0]+m[0],h[1]+m[1]]}f.add=e;function r(h,m){return[h[0]-m[0],h[1]-m[1]]}f.sub=r;function o(h,m){return[h[0]*m[0],h[1]*m[1]]}f.multiply=o;function n(h,m){return[h[0]/m[0],h[1]/m[1]]}f.divide=n;function a(h,m){return Math.pow(m[0]-h[0],2)+Math.pow(m[1]-h[1],2)}f.distanceSquared=a;function s(h,m){return Math.sqrt(a(h,m))}f.distance=s;function l(h,m){return h[0]*m[0]+h[1]*m[1]}f.dot=l;function c(h,m){return[h[0]*m,h[1]*m]}f.scalarMultiply=c;function u(h,m,y){let b=f.sub(m,h),v=f.sub(y,h),w=f.dot(b,v)/f.dot(b,b),O=f.scalarMultiply(b,w);return f.add(h,O)}f.projectionOnto=u;function p(h,m,y){return s(h,u(h,m,y))}f.projectionOntoDistance=p;function d(h,m){return[(h[0]+m[0])*.5,(h[1]+m[1])*.5]}f.center=d})(Ta||(Ta={}));var Ni;(s=>{function i(l,c){return l[0]===c[0]&&l[1]===c[1]&&l[2]===c[2]}s.isEqual=i;function t(l,c){return[l[0]+c[0],l[1]+c[1],l[2]+c[2]]}s.add=t;function e(l,c){return[l[0]-c[0],l[1]-c[1],l[2]-c[2]]}s.sub=e;function r(l,c){return[l[0]/c[0],l[1]/c[1],l[2]/c[2]]}s.div=r;function o(l,c){return[l[0]*c[0],l[1]*c[1],l[2]*c[2]]}s.mul=o;function n(l,c){return Math.hypot(l[0]-c[0],l[1]-c[1],l[2]-c[2])}s.dist=n;function a(l,c,u){return[l[0]+(c[0]-l[0])*u,l[1]+(c[1]-l[1])*u,l[2]+(c[2]-l[2])*u]}s.lerp=a})(Ni||(Ni={}));var p0;(e=>{function i(r,o){return r[0]===o[0]&&r[1]===o[1]&&r[2]===o[2]&&r[3]===o[3]}e.isEqual=i;function t(r,o,n){return[r[0]+(o[0]-r[0])*n,r[1]+(o[1]-r[1])*n,r[2]+(o[2]-r[2])*n,r[3]+(o[3]-r[3])*n]}e.lerp=t})(p0||(p0={}));var f0;(a=>{let i=180/Math.PI,t=Math.PI/180;function e(s){return typeof s=="number"?s*i:s}function r(s){return typeof s=="number"?s*t:s}function o(s){return[e(s[0]),e(s[1]),e(s[2])]}a.radToDeg=o;function n(s){return[r(s[0]),r(s[1]),r(s[2])]}a.degToRad=n})(f0||(f0={}));var Di;(o=>{o.identity=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];function t(n,a){for(let s=0;s<16;s++)if(n[s]!==a[s])return!1;return!0}o.isEqual=t;function e(n){return n??o.identity}o.simplify=e;function r(n,a){let s=a.slice(0);for(var l=0,c=a.length;l<c;l+=3){let u=n[3]*a[l]+n[7]*a[l+1]+n[11]*a[l+2]+n[15];s[l]=(n[0]*a[l]+n[4]*a[l+1]+n[8]*a[l+2]+n[12])/u,s[l+1]=(n[1]*a[l]+n[5]*a[l+1]+n[9]*a[l+2]+n[13])/u,s[l+2]=(n[2]*a[l]+n[6]*a[l+1]+n[10]*a[l+2]+n[14])/u}return s}o.applyMatrix4=r})(Di||(Di={}));var jt;(d=>{function i(f){return typeof f=="object"&&typeof f.r=="number"&&typeof f.g=="number"&&typeof f.b=="number"}d.isRGB=i,d.white={r:1,g:1,b:1},d.red={r:1,g:0,b:0},d.black={r:0,g:0,b:0};function o(f){return{r:Math.round(f.r*255),g:Math.round(f.g*255),b:Math.round(f.b*255),a:1}}d.toRgb255a1=o;function n(f){return{r:f.r,g:f.g,b:f.b}}d.clone=n;function a(f){return f=Math.floor(f),{r:(f>>16&255)/255,g:(f>>8&255)/255,b:(f&255)/255}}d.fromHex=a;function s(f){return Math.round(f.r*255)*65536+Math.round(f.g*255)*256+Math.round(f.b*255)}d.toHex=s;function l(f,h){return f.r===h.r&&f.g===h.g&&f.b===h.b}d.equals=l;function c(f,h){return f.r.toFixed(2)===h.r.toFixed(2)&&f.g.toFixed(2)===h.g.toFixed(2)&&f.b.toFixed(2)===h.b.toFixed(2)}d.equalsFixed=c;function u(f,h,m){return{r:f.r+(h.r-f.r)*m,g:f.g+(h.g-f.g)*m,b:f.b+(h.b-f.b)*m}}d.lerp=u;function p(f){return At(f)?"r"in f&&"g"in f&&"b"in f&&!("a"in f):!1}d.is=p})(jt||(jt={}));var Re;(u=>{u.white={...jt.white,a:1};function t(p){return At(p)?"r"in p&&"g"in p&&"b"in p&&"a"in p:!1}u.is=t,u.transparent={...jt.white,a:0};function r(p){return{r:p[0],g:p[1],b:p[2],a:p[3]}}u.from0to1=r;function o(p,d){return{...jt.fromHex(p),a:d}}u.fromHexAndA=o;function n(p){return{r:Math.round(p.r*255),g:Math.round(p.g*255),b:Math.round(p.b*255),a:p.a}}u.toRgb255a1=n;function a(p,d){return jt.equals(p,d)&&p.a===d.a}u.equals=a;function s(p,d){return jt.equalsFixed(p,d)&&p.a.toFixed(2)===d.a.toFixed(2)}u.equalsFixed=s;function l(p,d,f){return{r:p.r+(d.r-p.r)*f,g:p.g+(d.g-p.g)*f,b:p.b+(d.b-p.b)*f,a:p.a+(d.a-p.a)*f}}u.lerp=l;function c({r:p,g:d,b:f,a:h}=u.white){return`rgba(${p*255}, ${d*255}, ${f*255}, ${h})`}u.toStyle=c})(Re||(Re={}));var du;(t=>t.identity={position:[0,0,0],rotation:[0,0,0],scale:[1,1,1]})(du||(du={}));var h0;(t=>t.defaultData={mass:1,stiffness:80,damping:10,velocity:0})(h0||(h0={}));var m0;(t=>t.defaultData={control1:[.5,0],control2:[.5,1]})(m0||(m0={}));var y0;(n=>(n.linear=[0,0,1,1],n.ease=[.25,.1,.25,1],n.easeIn=[.42,0,1,1],n.easeOut=[0,0,.58,1],n.easeInOut=[.42,0,.58,1]))(y0||(y0={}));function Wp(i){return typeof i=="string"&&i.length===36?/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(i):!1}var oo;(e=>{e.all=["PerspectiveCamera","OrthographicCamera"];function t(r){return e.all.includes(r)}e.is=t})(oo||(oo={}));var Li;(o=>{o.DefaultUp=[0,1,0],o.DefaultTargetOffset=1e3,o.defaultData={far:1e5,type:"OrthographicCamera",perspective:{near:70,fov:45,zoom:1},orthographic:{near:-1e5,zoom:1},up:o.DefaultUp,isUpVectorFlipped:!1,targetOffset:o.DefaultTargetOffset};function r(n){return n.type==="PerspectiveCamera"?n.perspective?.zoom??1:n.orthographic?.zoom??1}o.getZoom=r})(Li||(Li={}));var Mo;(r=>{function i(o,n=.1){return{disabled:!1,type:"linear",hideBase:!1,count:3,radial:{radius:Math.max(o[0],o[1])*2,start:0,end:360,alignment:!1,axis:"y",scale:[1,1,1],rotation:[0,0,0],position:[0,0,0]},toObject:{object:"",spreadType:"random",scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],axis:"x",seed:0,count:99,align:"normal"},linear:{scale:[1,1,1],rotation:[0,0,0],position:[o[0]+o[0]*n,0,0]},grid:{count:[2,2,2],size:o.map(a=>a*(1+n)),useCenter:!0},randomness:!1,randomnessObject:{strength:100,scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],movement:1,seed:0,freqScale:10,noiseType:"perlin"}}}r.defaultData=i;function t(o,n){let a={...o};if(bA.forEach(s=>{Object.assign(a,{[s]:n[s]??o[s]})}),a.radial={...o.radial},n.radial){let s=o.radial,l=n.radial;vA.forEach(c=>{Object.assign(a.radial,{[c]:l[c]??s[c]})})}if(a.linear={...o.linear},n.linear){let s=o.linear,l=n.linear;SA.forEach(c=>{Object.assign(a.linear,{[c]:l[c]??s[c]})})}if(a.grid={...o.grid},n.grid){let s=o.grid,l=n.grid;wA.forEach(c=>{Object.assign(a.grid,{[c]:l[c]??s[c]})})}if(a.toObject={...o.toObject},n.toObject){let s=o.toObject,l=n.toObject;PA.forEach(c=>{Object.assign(a.toObject,{[c]:l[c]??s[c]})})}if(a.randomnessObject={...o.randomnessObject},n.randomnessObject){let s=o.randomnessObject,l=n.randomnessObject;OA.forEach(c=>{Object.assign(a.randomnessObject,{[c]:l[c]??s[c]})})}return a}r.merge=t;function e(o){return!!(o.randomnessObject||o.toObject)}r.isPartial=e})(Mo||(Mo={}));var pu;(r=>{r.defaultData={radial:{},linear:{},grid:{},toObject:{},randomnessObject:{}};let t=["radial","linear","grid","toObject","randomnessObject"];function e(o,n){let a=[];o.count!==void 0&&a.push({type:0,path:n,props:{count:o.count}});for(let s of t){let l=o[s];l&&Object.keys(l).length>0&&a.push({type:0,path:[...n,s],props:l})}return a}r.toOps=e})(pu||(pu={}));var bA=["count"],vA=["radius","start","end","position","scale","rotation"],SA=["position","scale","rotation"],wA=["count","size"],PA=["count","position","scale","rotation"],OA=["strength","scale","rotation","position","movement","seed","freqScale"];var fu;(e=>{e.all=["PointLight","SpotLight","DirectionalLight","HemisphereLight"];function t(r){return e.all.includes(r)}e.is=t})(fu||(fu={}));var hu;(e=>{function i(r){return t(r)}e.defaultData=i;function t(r){if(r==="PointLight")return{type:r,color:Re.white,intensity:1,distance:2e3,decay:1,shadows:!0,shadowResolution:1024,shadowRadius:1,penumbraSize:.5,depth:1e5};if(r==="SpotLight")return{type:r,color:Re.white,intensity:1,distance:2e3,decay:1,shadows:!0,penumbra:0,angle:30/180*Math.PI,depth:1e5,penumbraSize:.5,shadowResolution:1024,shadowRadius:1};if(r==="DirectionalLight")return{type:r,color:Re.white,intensity:1,shadows:!0,size:2e3,depth:1e5,penumbraSize:.5,shadowResolution:1024,shadowRadius:1};throw new Error("not implemented")}})(hu||(hu={}));var Ca;(r=>(r.defaultShapeData={type:"PlaneEmitterShape",size:[100,100,100]},r.defaultCollisionData={colliderEntityId:null,collisionBounce:.75},r.defaultData={renderMaterial:{type:"particleMaterial",color:{r:1,g:.2,b:.545,a:1},color2:{r:.945,g:.714,b:.184,a:1},coloring:"gradient",ease:"linearFadeOut",easeSize:"linearFadeOut",transparent:!0,size:[40,40],texture:"pt_default_particle",spriteRotation:[0,0]},birthRatePerSec:50,gravity:1,noiseStrength:0,noiseScale:0,noiseSeed:1,noiseType:"curl",randomRotation:0,randomScale:.2,randomMass:.5,rootObjectType:"instancedMesh",life:1,direction:[0,0,0],directionMode:"axis",speed:10,shape:r.defaultShapeData,autoPlay:!0,emitTimeDelay:0,emitTimeCycle:"infinity",emitTimeDuration:1,...r.defaultCollisionData}))(Ca||(Ca={}));var Bi;(t=>t.defaultData={enabled:"visibility",fusedBody:!0,rigidBody:"positioned",density:1,pointMass:0,gravityScale:1,friction:.5,damping:0,restitution:.2,colliderType:"convex",enabledRotation:[!0,!0,!0],enabledTranslation:[!0,!0,!0]})(Bi||(Bi={}));var qp;(e=>{e.defaultData={castShadow:!0,receiveShadow:!0};function t(r,o){return r.castShadow===o.castShadow&&r.receiveShadow===o.receiveShadow}e.equals=t})(qp||(qp={}));var $p;(e=>{e.defaultData={flatShading:!1,wireframe:!1,side:0};function t(r,o){return r.flatShading===o.flatShading&&r.side===o.side&&r.wireframe===o.wireframe}e.equals=t})($p||($p={}));var mu;(t=>t.defaultData={...$p.defaultData,...qp.defaultData})(mu||(mu={}));var x0;(t=>{function i(e,r){let o=[];if("material"in e){let n=typeof e.material=="string"?r.materials[e.material]??r.lib.materials[e.material]?.asset:e.material;n&&o.push(n)}else if("materials"in e)for(let n of e.materials){let a=typeof n=="string"?r.materials[n]??r.lib.materials[n]?.asset:n;a&&o.push(a)}return o}t.getMaterialData=i})(x0||(x0={}));var Aa;(e=>(e.defaultVideo={data:"",thumb:"/_assets/_videos/catThumb.png",type:"video",name:"Cat video"},e.maxSize=3e7))(Aa||(Aa={}));var b0;(t=>{function i(e){return e==="texture"||e==="video"||e==="color"||e==="depth"||e==="normal"||e==="gradient"||e==="noise"||e==="fresnel"||e==="rainbow"||e==="toon"||e==="outline"||e==="particle"||e==="transmission"||e==="matcap"||e==="displace"||e==="pattern"||e==="light"}t.is=i})(b0||(b0={}));function S0(i){return i.type!=="displace"}var v0;(t=>{function i(e){return e==="phong"||e==="toon"||e==="lambert"||e==="physical"}t.is=i})(v0||(v0={}));var w0=["mode","gradientType","noiseType","displacementType","projection","cnormal","crop","axis","side"],P0=["wrapping","image","video","name","minFilter","magFilter"],Vt;(o=>{function i(n,a){let{texture:s,...l}=a;if(Object.assign(n,l),s){let c=n.texture;c&&Object.assign(c,s)}}o.patch=i;function t(n,a){return n==="light"&&a?e(a):r(n)}o.defaultData=t;function e(n){let a={mode:0,isMask:!1,visible:!0,bumpMap:void 0,bumpMapIntensity:5,roughnessMap:void 0,alphaOverride:1};switch(n){case"phong":return{...a,category:"phong",specular:{r:.2,g:.2,b:.2},shininess:5,type:"light",visible:!0,mode:0,occlusion:!0,alpha:.6};case"toon":return{...a,category:"toon",specular:{r:.2,g:.2,b:.2},shininess:10,type:"light",alpha:1};case"lambert":return{...a,category:"lambert",emissive:{r:0,g:0,b:0},type:"light",alpha:1,visible:!0,mode:0,occlusion:!0};case"physical":return{...a,category:"physical",roughness:.2,metalness:.2,reflectivity:.2,type:"light",alpha:1,visible:!0,mode:0,occlusion:!0}}}function r(n){let a={alpha:1,mode:0,isMask:!1,visible:!0};switch(n){case"texture":return{...a,type:"texture",size:[128,128],blending:0,axis:"x",side:2,projection:0,texture:{image:"image_0",wrapping:1e3,repeat:[1,1],offset:[0,0],rotation:0,minFilter:1008,magFilter:1006},crop:!1};case"video":return{...a,type:"video",size:[128,128],blending:0,axis:"x",side:2,projection:0,texture:{video:Aa.defaultVideo,wrapping:1001,repeat:[1,1],offset:[0,0],rotation:0,minFilter:1008,magFilter:1006},crop:!1};case"color":return{...a,type:"color",color:jt.fromHex(Dt)};case"depth":return{...a,type:"depth",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]],steps:[0,1],near:50,far:200};case"normal":return{...a,type:"normal",cnormal:[1,1,1]};case"gradient":return{...a,type:"gradient",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{...a,type:"noise",size:[100,100,100],noiseType:0,scale:1,move:1,colorA:{...jt.fromHex(6710886),a:1},colorB:{...jt.fromHex(6710886),a:1},colorC:{...jt.fromHex(16777215),a:1},colorD:{...jt.fromHex(16777215),a:1},distortion:[1,1],fA:[1.7,9.2],fB:[8.3,2.8],voronoiStyle:0,highCut:1,lowCut:0,smoothness:.3,seed:0,quality:1};case"fresnel":return{...a,type:"fresnel",color:Re.fromHexAndA(16777215,1),bias:.1,scale:1,intensity:2,factor:1};case"rainbow":return{...a,type:"rainbow",filmThickness:30,movement:0,wavelengths:[0,0,0],noiseStrength:0,noiseScale:1,offset:[0,0,0]};case"toon":return{...a,type:"toon",positioning:2,colors:[[0,0,0,1],[.5,.5,.5,1],[.5,.5,.5,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,.475,.525,1,1,1,1,1,1,1],num:4,source:[0,1e3,0],isWorldSpace:!0,noiseStrength:0,noiseScale:1,shadowColor:Re.fromHexAndA(0,0),offset:[0,0,0]};case"outline":return{...a,type:"outline",outlineColor:Re.fromHexAndA(0,1),contourColor:Re.fromHexAndA(0,1),outlineWidth:2,contourWidth:5,outlineThreshold:.4,contourThreshold:0,outlineSmoothing:0,contourFrequency:10,contourDirection:[0,1,0],positionalLines:!1,compensation:!0};case"matcap":return{...a,type:"matcap",texture:{image:"matcap_0",wrapping:1001,repeat:[1,1],offset:[0,0],rotation:0,minFilter:1008,magFilter:1006}};case"transmission":return{...a,type:"transmission",thickness:10,ior:1.5,roughness:1};case"displace":return{visible:!0,type:"displace",displacementType:"noise",noiseType:0,scale:10,movement:1,offset:[0,0,0],intensity:8,voronoiStyle:0,smoothness:.3,seed:0,highCut:1,lowCut:0,quality:1};case"pattern":return{...a,type:"pattern",style:0,projection:0,axis:"y",blending:0,offset:[0,0],colorA:{...jt.fromHex(0),a:1},colorB:{...jt.fromHex(16777215),a:1},frequency:[10,10],size:.5,variation:0,smoothness:.5,zigzag:0,rotation:0,vertical:[0,1],horizontal:[0,1],sides:6}}}})(Vt||(Vt={}));var Ut;(c=>{function i(u){return!u.layers.some(d=>d.data.type==="texture"&&d.data.projection!==0||d.data.type==="depth"&&!d.data.isWorldSpace||d.data.type==="noise"||d.data.type==="displace")}c.isMergable=i;function t(u){let p="";return u.layers.forEach(d=>{Object.entries(d.data).forEach(([f,h])=>{p+=`${f}${h}`,Array.isArray(h)?h.forEach(m=>p+=`${m}`):typeof h=="object"?Object.values(h).forEach(m=>{typeof m=="number"?p+=`${m.toFixed(4)}`:p+=`${m}`}):p+=`${h}`})}),p}c.getHash=t;function e(){return{layers:new Se}}c.defaultEmptyData=e;function r(u="layer1",p="layer2"){return n("phong",u,p)}c.defaultData=r;function o(u,p){return{...u,name:p}}c.withName=o;function n(u,p="layer1",d="layer2"){let f=new Se;return f.push({fi:0,data:Vt.defaultData("light",u),id:p}),f.push({fi:1,data:Vt.defaultData("color"),id:d}),{layers:f}}c.defaultTwoLayerData=n;function a(u){let p=Vt.defaultData("texture");u&&Object.assign(p.texture,{image:u});let d=new Se;return d.push({fi:0,data:p,id:"layer1"}),d.push({fi:1,data:{...Vt.defaultData("transmission"),alpha:1},id:"layer2"}),d.push({fi:2,data:{...Vt.defaultData("light","lambert"),alpha:0},id:"layer3"}),{layers:d}}c.defaultUIObjectMaterial=a;function s(u,p="phong",d="layer1",f="layer2"){let h=Vt.defaultData("texture");Object.assign(h.texture,{image:u});let m=new Se;return m.push({fi:0,data:h,id:d}),m.push({fi:1,data:Vt.defaultData("light",p),id:f}),{layers:m}}c.defaultTwoLayerTextureData=s;function l(u,p="phong",d="layer1",f="layer2"){let h=Vt.defaultData("video");Object.assign(h.texture,{video:u});let m=new Se;return m.push({fi:0,data:h,id:d}),m.push({fi:1,data:Vt.defaultData("light",p),id:f}),{layers:m}}c.defaultTwoLayerVideoTextureData=l})(Ut||(Ut={}));var Ma;(t=>{function i(){return{points:new Se,roundness:0,shapeHoles:[],isClosed:!1}}t.defaultData=i})(Ma||(Ma={}));var Ia;(t=>{function i(){return{points:new Se,lastInsertionPlane:null,subdivisions:12,isClosed:!1}}t.defaultData=i})(Ia||(Ia={}));var Xp={type:"Ellipse",width:50,height:50,spikes:16,angle:360,innerRadius:0};var yu;(t=>{function i(e,r){let o={...e};return TA.forEach(n=>{Object.assign(o,{[n]:r[n]??e[n]})}),o}t.merge=i})(yu||(yu={}));var gu={shape:Xp,depth:1,offset:0,bevel:50,bevelSides:6,angle:0,twist:0,startScale:1,endScale:1,capType:"flat"},TA=["depth","offset","angle","twist","startScale","endScale"];var fl;(r=>{function i(o){return o==="PolygonGeometry"||o==="RectangleGeometry"||o==="StarGeometry"||o==="TriangleGeometry"||o==="EllipseGeometry"||o==="UIGeometry"}r.is2DParametricMesh=i;function t(o){return o==="PolygonGeometry"||o==="RectangleGeometry"||o==="StarGeometry"||o==="TriangleGeometry"||o==="EllipseGeometry"||o==="PathGeometry"||o==="VectorGeometry"||o==="ConeGeometry"||o==="CubeGeometry"||o==="CylinderGeometry"||o==="DodecahedronGeometry"||o==="HelixGeometry"||o==="IcosahedronGeometry"||o==="LatheGeometry"||o==="PyramidGeometry"||o==="SphereGeometry"||o==="PlaneGeometry"||o==="BackdropGeometry"||o==="TorusGeometry"||o==="TorusKnotGeometry"||o==="BooleanGeometry"||o==="TextGeometry"||o==="InputGeometry"}r.isParametricMesh=t;function e(o){return o==="PolygonGeometry"||o==="RectangleGeometry"||o==="StarGeometry"||o==="TriangleGeometry"||o==="EllipseGeometry"||o==="PathGeometry"||o==="VectorGeometry"||o==="ConeGeometry"||o==="CubeGeometry"||o==="CylinderGeometry"||o==="DodecahedronGeometry"||o==="HelixGeometry"||o==="IcosahedronGeometry"||o==="LatheGeometry"||o==="PyramidGeometry"||o==="SphereGeometry"||o==="PlaneGeometry"||o==="BackdropGeometry"||o==="TorusGeometry"||o==="TorusKnotGeometry"||o==="TextGeometry"||o==="SubdivGeometry"||o==="NonParametricGeometry"}r.isSwappableGeometry=e})(fl||(fl={}));var xu;(t=>{function i(e,r){let o={...e};return Object.assign(o,r),o.type==="PathGeometry"&&"extrusion"in r&&r.extrusion&&(o.extrusion={...e.extrusion},Object.assign(o.extrusion,yu.merge(o.extrusion,r.extrusion))),o}t.merge=i})(xu||(xu={}));var Io;(t=>{function i(e){if(e==="RectangleGeometry")return{width:320,height:320,type:e,cornerRadius:[0,0,0,0],cornerType:0,depth:0,extrudeBevelSize:0,extrudeBevelSegments:1};if(e==="UIGeometry")return{type:e,frame:"",cornerRadius:[0,0,0,0],cornerType:0,width:1,height:1};if(e==="PathGeometry")return{type:e,width:1,height:1,depth:1,path:Ia.defaultData(),extrusion:gu};if(e==="VectorGeometry")return{width:1,height:1,type:e,subdivisions:12,shape:Ma.defaultData(),depth:0,extrudeBevelSize:0,extrudeBevelSegments:1};if(e==="BooleanGeometry")return{type:e,operation:2,width:0,height:0,depth:0,phongAngle:35};if(e==="ShapeBlendGeometry")return{type:e,width:0,height:0,depth:0,resolutionLevel:6,blendRange:100,useChildrenColors:!1};if(e==="TextGeometry")return{type:e,width:100,height:100,depth:0,horizontalAlign:1,verticalAlign:1,fontSize:16,lineHeight:1.2,letterSpacing:0,text:{textValue:""},textTransform:1,font:"Roboto_regular",editable:!1,extrudeBevelSize:0,extrudeBevelSegments:1};if(e==="InputGeometry")return{...t.defaultData("TextGeometry"),type:e,editable:!0};if(e==="SphereGeometry")return{type:"SphereGeometry",width:100,height:100,depth:100,widthSegments:64,heightSegments:64,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:180};throw new Error("not implemented")}t.defaultData=i})(Io||(Io={}));var bu;(t=>t.defaultData={enabled:!1,useBackgroundColor:!1,color:jt.white,near:.1,far:2e3})(bu||(bu={}));var vu;(e=>{let i={opacity:1,blendFunction:13,enabled:!1};e.defaultData={enabled:!1,pixelation:{...i,blendFunction:16,granularity:15},bloom:{...i,blendFunction:16,intensity:1,blurScale:1,luminanceThreshold:.25,luminanceSmoothing:.025,kernelSize:3},chromaticAberration:{...i,offset:[2,2]},vignette:{...i,darkness:1,offset:0},hueSaturation:{...i,hue:3,saturation:0},brightnessContrast:{...i,brightness:.25,contrast:0},depthOfField:{...i,focusDistance:100,focalLength:20,bokehScale:5},noise:{...i,blendFunction:16}}})(vu||(vu={}));var Yp;(t=>t.defaultData={softShadowQuality:"low"})(Yp||(Yp={}));var Kp;(t=>t.defaultData={enabled:!0,color:{r:.8274509803921568,g:.8274509803921568,b:.8274509803921568},intensity:.75})(Kp||(Kp={}));var Qp;(t=>t.defaultData={occlusion:!1,aoFullRes:!1,radius:256,bias:.5,aoColor:{r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}})(Qp||(Qp={}));var hl;(t=>t.defaultData={usePhysics:!1,gravity:-10})(hl||(hl={}));var Zp;(t=>t.defaultData={playCamera:_i,gameControlObject:null})(Zp||(Zp={}));var Su;(t=>t.defaultData={backgroundColor:Re.fromHexAndA(g0,1),postprocessing:vu.defaultData,fog:bu.defaultData,globalPhysics:hl.defaultData,ambient:Kp.defaultData,ao:Qp.defaultData,shadow:Yp.defaultData,publish:Zp.defaultData})(Su||(Su={}));var wu;(t=>t.defaultData={colliderType:"box",size:[100,100,100],colliderHelperVisible:!0,forceType:"collider",forceRange:"global",forceIntensity:.5,forceDambing:.95})(wu||(wu={}));var O0;(e=>{function i(r){return r==="Component"||r==="Instance"}e.isComponentRelated=i;function t(r){return r==="Empty"||r==="Instance"}e.isEmptyOrComponent=t})(O0||(O0={}));var Ea;(o=>{o.identity={...du.identity,hiddenMatrix:Di.identity};function t(n){return{position:n.position,rotation:n.rotation,scale:n.scale,hiddenMatrix:n.hiddenMatrix}}o.fromObject=t;function e(n,a){return{position:a?.position||n.position,rotation:a?.rotation||n.rotation,scale:a?.scale||n.scale,hiddenMatrix:a?.hiddenMatrix||n.hiddenMatrix}}o.merge=e;function r(n,a){return bc({position:Ni.isEqual(n.position,a.position)?void 0:a.position,rotation:Ni.isEqual(n.rotation,a.rotation)?void 0:a.rotation,scale:Ni.isEqual(n.scale,a.scale)?null:a.scale,hiddenMatrix:Di.isEqual(n.hiddenMatrix,a.hiddenMatrix)?void 0:a.hiddenMatrix})}o.diff=r})(Ea||(Ea={}));var _t;(t=>t.defaultData={states:new Se,events:new Se,timelineAnimations:new de,visible:!0,raycastLock:!1,physics:Bi.defaultData,pathSnapping:{pathId:null,slide:0,offset:0,orientation:"tangential"},...Ea.identity,cloner:null})(_t||(_t={}));var Pu;(t=>t.defaultData={type:"Empty",..._t.defaultData})(Pu||(Pu={}));var T0;(t=>t.defaultData={type:"ParticleCollider",...wu.defaultData,..._t.defaultData})(T0||(T0={}));var C0;(t=>t.defaultData={type:"Component",..._t.defaultData})(C0||(C0={}));var A0;(t=>t.defaultData={type:"Particle",..._t.defaultData,...Ca.defaultData})(A0||(A0={}));var ei;(t=>t.defaultData={type:"Mesh",..._t.defaultData,...mu.defaultData})(ei||(ei={}));var Pn;(t=>t.defaultData={..._t.defaultData,...Ea.identity,position:[0,0,Li.DefaultTargetOffset],...Li.defaultData})(Pn||(Pn={}));var Ou;(e=>{function i(r){return{..._t.defaultData,...hu.defaultData(r)}}e.defaultData=i,e.defaultDirectionalLightData={...e.defaultData("DirectionalLight"),position:[200,300,300],name:"Directional Light",intensity:.7}})(Ou||(Ou={}));var Na;(e=>{function i(r,o,n=0){for(;n<o.length;){let a=r?r[o[n]]:void 0;if(o.length===n+1)return a;if(a)r=a.descendants,n+=1;else return}}e.resolveWithDes=i;function t(r,o,n=0){let a=i(r,o,n);if(a){let s=Object.keys(a);if(s.length===1&&s[0]==="descendants")return}return a}e.resolve=t})(Na||(Na={}));var Eo;(n=>{n.rootOverrideProps=["physics","events"],n.compositeNonOptionalOverrideProps=["geometry"],n.compositeEntireOverrideOverrideProps=["material"];function r(a,s){return{..._t.defaultData,...s,component:a,overrides:new Je,physics:void 0,events:void 0,type:"Instance"}}n.ofComponent=r;function o(a){let s=Ea.fromObject(a.data);return r(a.id,s)}n.fromComponentData=o})(Eo||(Eo={}));var ti;(e=>{e.defaultData={type:"Page",..._t.defaultData,physics:{...Bi.defaultData,fusedBody:!1},...Su.defaultData,camera:Pn.defaultData};function t(r){return r.uiScene!==void 0}e.isUIPage=t})(ti||(ti={}));var Tu;(s=>(s.defaultCamera={position:[0,0,1e3],scale:[1,1,1],rotation:[0,0,0],hiddenMatrix:Di.identity,name:"Play Camera",visible:!0,raycastLock:!1,physics:Bi.defaultData,states:new Se,events:new Se,timelineAnimations:new de,cloner:null,pathSnapping:{pathId:null,orientation:"tangential",slide:0,offset:0},...Li.defaultData},s.KeysByResetCategory={States:["states"],Events:["events"],Material:["material","materials"],Geometry:["geometry"],Position:["position"],Rotation:["rotation"],Scale:["scale"],Transform:["position","scale","rotation","hiddenMatrix"],Name:["name"],Visibility:["visible","raycastLock","flatShading","wireframe","side"],Shadows:["castShadow","receiveShadow"],Cloner:["cloner"],Physics:["physics"]},s.defaultMeshObject={name:"Rectangle",..._t.defaultData,...ei.defaultData,geometry:Io.defaultData("RectangleGeometry"),material:Ut.defaultTwoLayerData("phong","layer1","layer2")},s.defaultBooleanObject={name:"Boolean",..._t.defaultData,...ei.defaultData,geometry:Io.defaultData("BooleanGeometry"),material:Ut.defaultTwoLayerData("phong","layer1","layer2")},s.defaultShapeBlendObject={name:"Shape Blend",..._t.defaultData,...ei.defaultData,geometry:Io.defaultData("ShapeBlendGeometry"),material:Ut.defaultTwoLayerData("phong","layer1","layer2")},s.defaultTextObject={name:"Text",..._t.defaultData,...ei.defaultData,geometry:Io.defaultData("TextGeometry"),material:Ut.defaultTwoLayerData("phong","layer1","layer2")},s.defaultInputObject={name:"Input",..._t.defaultData,...ei.defaultData,geometry:Io.defaultData("InputGeometry"),material:Ut.defaultTwoLayerData("phong","layer1","layer2")}))(Tu||(Tu={}));var On;(o=>{function i(n,a){let s={name:a};return n.type==="Mesh"?(s.geometry={},"material"in n&&(s.material={layers:new Je}),"materials"in n&&(s.materials=n.materials.map(l=>({layers:new Je})))):oo.is(n.type)&&(s.perspective={},s.orthographic={}),s}o.newEmpty=i;function t(n,a){if(a===void 0)return n;let s={...n};return"material"in s&&"material"in a&&a.material&&(s.material=Ai(s.material,l=>{if(typeof l!="string")for(let[c,u]of Object.entries(a.material.layers)){let p=l.layers.data(c);p&&Vt.patch(p,u)}}).data),s.materials&&a.materials&&(s.materials=Ai(s.materials,l=>{for(let c=0;c<s.materials.length;c++){let u=a.materials[c];if(typeof u!="string")for(let[p,d]of Object.entries(u.layers)){let f=l[c]?.layers?.data(p);f&&Vt.patch(f,d)}}}).data),s}function e(n,a){let s,l=[],c={orthographic:0,perspective:0,geometry:0};function u(p,d){for(let[f,h]of Object.entries(d.layers)){let{texture:m,...y}=h;if(m!==void 0&&Object.keys(m).length>0){let b={path:[...p,"layers",f,"texture"],props:m,type:0};l.push(b)}if(Object.keys(y).length>0){let b={path:[...p,"layers",f],props:y,type:0};l.push(b)}}}for(let[p,d]of Object.entries(a))if(p!=="name")if(p==="cloner")l.push(...pu.toOps(d,["cloner"]));else if(p==="pathSnapping")l.push({path:[p],props:{slide:d.slide,offset:d.offset},type:0});else if(p==="material")u(["material"],d);else if(p==="materials")for(let[f,h]of Object.entries(d))u(["materials",f],h);else if(c[p]===0){if(p==="geometry"&&d.extrusion!==void 0){let f={path:[p,"extrusion"],props:d.extrusion,type:0};l.push(f),d={...d},delete d.extrusion}if(Object.keys(d).length>0){let f={path:[p],props:d,type:0};l.push(f)}}else s===void 0&&(s={path:[],props:{},type:0},l.push(s)),s.props[p]=d;return l}o.toOps=e;function r(n,a){if(a===void 0)return n;let s={...n};if(Object.assign(s,Ea.merge(s,a)),Object.assign(s,{pathSnapping:Object.assign({},s.pathSnapping,{slide:a.pathSnapping?.slide??s.pathSnapping?.slide??0,offset:a.pathSnapping?.offset??s.pathSnapping?.offset??0})}),oo.is(n.type)){s.orthographic={...s.orthographic},s.perspective={...s.perspective};let l=a;l.orthographic?.zoom!==void 0&&(s.orthographic.zoom=l.orthographic.zoom),l.perspective?.zoom!==void 0&&(s.perspective.zoom=l.perspective.zoom),l.isUpVectorFlipped!==void 0&&(s.isUpVectorFlipped=l.isUpVectorFlipped),l.targetOffset!==void 0&&(s.targetOffset=l.targetOffset)}else if(n.type==="Mesh")"geometry"in a&&Object.assign(s,{geometry:xu.merge(s.geometry,a.geometry)}),(a.material||a.materials)&&(s=t(s,a)),s.cloner&&"cloner"in a&&Object.assign(s,{cloner:Mo.merge(s.cloner,a.cloner)});else if(n.type==="Empty")s.cloner&&"cloner"in a&&Object.assign(s,{cloner:Mo.merge(s.cloner,a.cloner)});else if(fu.is(n.type)){let l=a;l.intensity!==void 0&&(s.intensity=l.intensity),l.color!==void 0&&(typeof l.color=="string"?s.color=l.color:s.color=jt.clone(l.color))}return s}o.patch=r})(On||(On={}));var Da;(t=>t.defaultData={enablePan:!0,enableZoom:!0,enableRotate:!0,enableDamping:!0,rotationLimitsMode:0,rotationVerticalOffset:{min:Math.PI/4,max:Math.PI/4},rotationHorizontalOffset:{min:Math.PI/4,max:Math.PI/4},rotationSoftLimit:2,panLimitsMode:0,panVerticalOffset:{min:250,max:250},panHorizontalOffset:{min:250,max:250},panSoftLimit:2,zoomLimitsEnabled:!1,zoomLimits:{min:.1,max:2},autoRotate:!1,autoRotateSpeed:2,autoRotateClockwise:!0,hoverRotatePanMode:0,hoverRotatePanStrength:20,hoverRotateDamping:.125,isTouchZoom:!0,orbitTouches:2,panTouches:3,resetHoverEffectOnPointerLeave:!0})(Da||(Da={}));var Ur;(t=>t.defaultData={orbitControls:Da.defaultData,playPage:Ri,withBackground:!0,preventScroll:!1,preventTouchScroll:!1,hideCursor:!1,mouseEventTarget:"canvas",joystickSizeAndXYOffset:Array(12).fill(0).map((e,r)=>{let o=0,n=0;return r<5?n=-30:r<10&&(n=30),r===0||r===10||r===5?o=30:(r===4||r===11||r===9)&&(o=-30),[120,[o,n],"show"]}),settings:{image:{format:"jpg",ratio:1},videoStatic:{fps:60,mbps:150,ratio:1,duration:1e3,activeTimeline:null},video:{format:"mp4",imageFormat:"jpg",fps:30,mbps:80,ratio:Math.max(1,typeof window<"u"?Math.floor(window.devicePixelRatio):1),stopMode:"manual",duration:5e3},web:{logo:!0,compress:!0,preset:1,preload:!0,hint:!1,imageQuality:70,pixelRatioMobile:0,pixelRatioDesktop:0}},stopRaycast:!0,hdTransmission:!1})(Ur||(Ur={}));var Jp;(t=>t.defaultData={id:"basic",label:"Basic",style:"None",prompt:""})(Jp||(Jp={}));var ef;(t=>t.defaultData={weather:0,shadows:0,lightOrigin:0,temperature:0,sun:0,camera:0,environment:0,particles:0,nature:0,floor:0})(ef||(ef={}));var ri;(e=>(e.defaultData=()=>({mode:"line-art-both",prompt:"",negativePrompt:"",style:{...Jp.defaultData},isRandomSeed:!0,seed:e.generateSeed(),guessMode:!1,advanced:!1,steps:20,guidanceScale:7.5,controlNetScale:1,modifiers:ef.defaultData}),e.generateSeed=()=>Math.round(Math.random()*1e5)))(ri||(ri={}));var M0;(e=>{function i(r){return r.find(o=>o.data.type==="Page"&&o.data.globalPhysics.usePhysics)!==void 0}e.physicsEnabled=i;function t(r,o,n){r.scene.objects.traverseFrom(o,(a,s)=>{if(s.type==="Instance"){let l=_a.getComponentData(r,s.component)?.data;l&&n(a,s,l.events)}else n(a,s,s.events)})}e.traverseModuleInstances=t})(M0||(M0={}));var oi;(c=>{c.TRASH_CAN_ID="830a2708-8ed9-49cf-a68e-085299892222",c.defaultLight={fi:-1,data:Ou.defaultDirectionalLightData,id:"830a2708-8ed9-49cf-a68e-085299899103",children:[]};function e(u=!0,p=[]){let d=[],f=Tu.defaultMeshObject;u&&(d.push({...c.defaultLight}),d.push({fi:1,id:"7ba78968-2a55-48f2-b14c-5191da3e075e",data:f,children:[]})),d.push(...p);let h=new ct;return h.push({fi:1,id:Ri,data:{...ti.defaultData,name:"Scene 1"},children:d}),h}c.createDefaultObjectTreeWithPage=e,c.defaultData={objects:e(),publish:Ur.defaultData,styles:ri.defaultData()},c.emptyDataWithoutPage=function(){return{objects:new ct,publish:Ur.defaultData,styles:ri.defaultData()}},c.emptyDataWithPage=function(u=!0){return{objects:e(u),publish:Ur.defaultData,styles:ri.defaultData()}},c.emptyData=function(){return{objects:new ct,publish:{...Ur.defaultData},styles:ri.defaultData()}};function s(u){return{...c.defaultData,objects:Ft(u,ct.prototype)}}c.withObjs=s;function l(u,p){return s([{id:u,data:p,children:[],fi:0}])}c.withObj=l})(oi||(oi={}));var Ra;(t=>t.defaultData={preset:"fullscreen",allowResponsive:!1,size:[512,512],coords:[0,0],sceneScale:1,color:{r:0,g:0,b:0,a:.5}})(Ra||(Ra={}));var Cu;(e=>(e.defaultData=r=>({url:r,name:"New Webhook",parametersSchemas:new Se}),e.defaultParameterValueByType=r=>r==="number"?0:r==="boolean"?!1:""))(Cu||(Cu={}));var I0;(t=>t.defaultData=(e,r="GET")=>({url:e,method:r,name:"New API",headers:new Se,queries:new Se,autoStart:!0}))(I0||(I0={}));var Vi;(n=>{function i(a){return a.textValue!==void 0}n.isTextValue=i;function t(a){return typeof a=="number"}n.isNumber=t;function e(a){return typeof a=="boolean"}n.isBoolean=e;function r(a){return i(a)?"string":e(a)?"boolean":"number"}n.typeOfVariable=r;function o(a){return n.isTextValue(a)?Array.isArray(a.textValue)?a.textValue.map(s=>s.toString().padStart(a.padding??2,"0")).join(a.deliminator??":")+(a.suffix!==void 0?" "+a.suffix:""):a.textValue.toString():n.isBoolean(a)?a?"True":"False":n.isNumber(a)?parseFloat(a.toFixed(3)).toString():a.toString()}n.getDisplayedValue=o})(Vi||(Vi={}));var tf;(t=>t.all=["images","videos","colors","audios","particles","fonts","materials","variables"])(tf||(tf={}));var E0;(t=>t.all=[...tf.all,"components"])(E0||(E0={}));var N0;(t=>{function i(){return{images:new de,videos:new de,colors:new de,audios:new de,particles:new de,fonts:new de,materials:new de,components:new de,variables:new de,userAPIs:new de,userWebhooks:new de,timelineAnimations:new de}}t.defaultData=i})(N0||(N0={}));var io;(t=>{function i(){return{images:new de,videos:new de,colors:new de,audios:new de,particles:new de,fonts:new de,materials:new de,components:new de,variables:new de,userAPIs:new de,userWebhooks:new de,timelineAnimations:new de}}t.defaultData=i})(io||(io={}));var kr;(n=>{function i(){let a={};return a["89b10010-844c-11ec-a8a3-0242ac120002"]={r:.5,g:.5,b:.5,a:1,name:"Default Color"},Ft(a,de.prototype)}n.defaultColors=i;function t(){return Ft({},de.prototype)}n.defaultImages=t;function e(){return{catelogs:new de,materials:new de,images:new de,videos:new de,colors:new de,timelineAnimations:new de,audios:new de,particles:new de,fonts:new de,variables:new Se,userAPIs:new de,userWebhooks:new de,lib:io.defaultData()}}n.emptyData=e;function r(a){switch(a){case"number":return{value:0,name:"Number"};case"boolean":return{value:!1,name:"Boolean"};case"string":return{value:{textValue:"String value"},name:"String"};case"time":let s=[0,0,0];return{name:"Time",value:{textValue:s,deliminator:":",padding:2,suffix:"AM"},dynamicVariableType:"time",format:"HH:mm:ss",format12h24h:"12ampm",timeZone:null,hasEnd:!1,endValue:{textValue:s,deliminator:":",padding:2,suffix:"AM"},autoStart:!0,repeat:!1};case"counter":return{name:"Counter",value:0,dynamicVariableType:"counter",updateInterval:1e3,increment:1,autoStart:!0,hasEnd:!0,endValue:60,repeat:!0,randomStart:!1,range:[0,100],decimals:0};case"random":return{name:"Random",value:0,dynamicVariableType:"random",updateInterval:1e3,increment:1,autoStart:!0,isStatic:!1,hasEnd:!0,endValue:60,repeat:!0,min:0,max:100,decimals:0};default:console.error("Unknown variable type",a)}}n.defaultVariables=r;function o(a,s){if(s.format==="HH:mm:ss"){let l=Math.floor(a/3600),c=Math.floor((a-l*3600)/60),u=Math.round(a-l*3600-c*60);return{textValue:[l,c,u]}}else if(s.format==="mm:ss"){let l=Math.floor(a/60),c=Math.round(a-l*60);return{textValue:[l,c]}}else return s.format==="number"?a=Math.round(a):a=Math.round(a*1e3)/1e3,a}n.getFormattedTimerTime=o})(kr||(kr={}));var ml=require("three");var Au;(t=>t.list=["idle","move","jump","run"])(Au||(Au={}));var Mu;(e=>(e.defaultColliderData={type:"capsule",height:200,radius:50,position:[0,0,0],rotation:[0,0,0]},e.defaultDataThirdPerson={moveMode:"walk",forwardDirection:"+z",speedTranslate:1e3,speedRotate:100,runMultiplier:2,rotationMode:"normal",rotBy:"keys",rotByTouch:"drag",delayPos:[.3,.3],delayRot:[.3,.3],keyAssignments:[["moveNegZ","W"],["moveNegX","A"],["movePosZ","S"],["movePosX","D"],["rotPosX","\u25B2"],["rotPosY","\u25C0"],["rotNegX","\u25BC"],["rotNegY","\u25B6"],["jump","Space"],["run","\u21E7"],["none","Ctrl"]],touchControl:!0,joystickPosLoc:5,joystickRotLoc:11,jumpTouchButtonLoc:9,collider:e.defaultColliderData,colliderHelperVisible:!0,collisionEnabled:!0,jumpPower:100,resetYPosition:3e3,alignToGround:!1,autoOrientMove:!0,orientWith:"camera",orientMode:"radial",delayPosCamera:.3,delayRotCamera:.3,camera:"",cameraXAxis:"Limit",cameraYAxis:"Free",cameraRotXLimits:[0,Math.PI/2],cameraRotYLimits:[-Math.PI/2,Math.PI/2],gameActions:{idle:new Se,move:new Se,jump:new Se,run:new Se},navmesh:{enabled:!1,ch:6,cs:6,walkableClimb:5,walkableHeight:1,walkableRadius:0,zones:"all",objects:[],helperVisible:!0,destinationHelperRadius:0,destinationHelperColor:Re.fromHexAndA(3728051,1)}}))(Mu||(Mu={}));function D0(i){i.layers.forEach(t=>{if(t.type==="depth"&&t.colorA!==void 0){let e=t.colorA,r=t.colorB,o=[[e.r,e.g,e.b,e.a],[r.r,r.g,r.b,r.a]],n=[0,1];for(let s=2;s<10;s++)o.push(o[1]),n.push(1);let a={...ro(vt(t),"type","visible","isVector","isWorldSpace","origin","alpha","mode"),near:Math.max(0,t.near),far:Math.max(0,t.far),colors:o,steps:n,num:2,direction:[1,0,0],smooth:!1,gradientType:1};Object.assign(t,a)}else if(t.type==="depth"&&t.gradientType===1&&(t.near<0||t.far<0)){let e={...vt(t),near:Math.max(t.near,0),far:Math.max(t.far,0)};Object.assign(t,e)}})}function ii(i,t){Object.values(i.shared.materials).forEach(e=>t(e))}function ni(i,t){i.scene.objects.traverse((e,r)=>{"materials"in r?r.materials.forEach((o,n)=>{o===void 0&&(r.materials[n]=Ut.defaultData(),o=r.materials[n]),typeof o!="string"&&t(o)}):"material"in r?typeof r.material!="string"&&(r.material===void 0&&(r.material=Ut.defaultData()),t(r.material)):r.type==="Mesh"&&(r.material===void 0&&(r.material=Ut.defaultData()),t(r.material)),"overrides"in r&&Object.values(r.overrides).forEach(o=>{o.material&&typeof o.material!="string"&&Object.getPrototypeOf(o.material)!==Je.prototype&&t(o.material)})})}function CA(i){Object.assign(i.scene.publish,{orbitControls:{...Da.defaultData,...vt(i.scene.publish.orbitControls)}})}function AA(i){Object.assign(i.scene.publish.settings,{video:{...Ur.defaultData.settings.video,...vt(i.scene.publish.settings.video)}})}function MA(i){function t(e){if(e.layers){for(let r of Object.values(e.layers))if(r){for(let[o,n]of Object.entries(r))if((w0.includes(o)||typeof n=="boolean")&&delete r[o],o==="texture")for(let[a,s]of Object.entries(n))(P0.includes(a)||typeof s=="boolean")&&delete n[a]}}}i.scene.objects.traverse((e,r)=>{r.states.forEach(o=>{let n=o;n.material?t(n.material):n.materials&&n.materials.forEach(a=>{t(a)})})})}function IA(i){i.scene.publish.withBackground=!0}function EA(i){i.scene.publish.settings.web={compress:!0,preload:!0,preset:1,logo:!0,hint:!1}}function NA(i){i.scene.objects.traverse((t,e)=>{let r=e.cloner;r&&(r.radial.scale=r.radial.scale.map(o=>o+1),r.linear.scale=r.linear.scale.map(o=>o+1))})}function DA(i){i.scene.objects.traverse((t,e)=>{let r=e.geometry;r&&(r.type==="DodecahedronGeometry"||r.type==="IcosahedronGeometry")&&(r.detail=Math.round(r.detail))})}function _A(i){i.scene.objects.traverse((t,e)=>{let r=i.scene.objects.unproxy().parent(t);if(r){let o=vt(i.scene.objects.data(r));o&&o.type==="Mesh"&&o.geometry.type==="BooleanGeometry"&&e.type==="Mesh"&&(e.visible=vt(e).booleanExclude!==!0)}})}function RA(i){i.scene.objects.traverse((t,e)=>{if(e.type==="Mesh"){let r=e;e.geometry.type==="NonParametricGeometry"?r.material!==void 0&&delete r.material:r.materials!==void 0&&delete r.materials}})}function LA(i){function t(r){Object.setPrototypeOf(r,Je.prototype),r.texture&&Object.setPrototypeOf(r.texture,Je.prototype)}function e(r){Object.setPrototypeOf(r,Je.prototype);for(let o in r)t(r[o])}i.scene.objects.traverse((r,o)=>{o.states.forEach(n=>{let a=n;if(a.material){let s=vt(a.material).layers;e(s),a.material.layers=s}if(a.materials)for(let s=0;s<a.materials.length;s++){let l=a.materials[s],c=vt(l).layers;e(c),l.layers=c}})})}function _0(i){i.layers===void 0&&Object.assign(i,Ut.defaultTwoLayerData("lambert"))}function rf(i){!i.layers||i.layers.forEach(t=>{if(t.type==="depth"&&t.colors.length===10){let e=[...t.colors];e.push(t.colors[9]);let r=[...t.steps];r.push(t.steps[9]);let o={...vt(t),colors:e,steps:r};Object.assign(t,o)}})}function BA(i){i.scene.objects.traverse((t,e)=>{e.type==="Mesh"&&(e.geometry.type==="BooleanGeometry"||e.geometry.type==="SubdivGeometry")&&(e.geometry.phongAngle=35)})}function R0(i){i.scene.objects.traverse((t,e)=>{"materials"in e?e.materials.forEach(r=>{typeof r!="string"&&rf(r)}):"material"in e&&typeof e.material!="string"&&rf(e.material)}),Object.values(i.shared.materials).forEach(t=>rf(t))}function VA(i){i.scene.environment.ambientLight.softShadows=!1,i.scene.environment.ambientLight.softShadowQuality="low",i.scene.objects.traverse((t,e)=>{(e.type==="DirectionalLight"||e.type==="SpotLight")&&(e.shadowResolution=1024,e.shadowRadius=1,e.depth=1e5)}),i.shared.penumbraSize=new Array(5).fill(.5)}function zA(i){i.shared.audios=Ft({},de.prototype)}function GA(i){i.shared.videos=Ft({},de.prototype)}function FA(i){let t=i.shared.materials;Object.entries(t).forEach(([e,r])=>{if(!r.layers){let o={name:"Untitled Material",layers:[{fi:0,data:{type:"light",category:"phong",alpha:.6,visible:!0,mode:0,specular:{r:.2,g:.2,b:.2},shininess:5},id:"layer1"},{fi:1,data:{type:"color",alpha:1,visible:!0,mode:0,color:{r:.2823529411764706,g:.2823529411764706,b:.30196078431372547}},id:"layer2"}]};Object.assign(t,{[e]:o})}})}function jA(i){Object.entries(vt(i.shared.images)).filter(r=>r[1].asset===!1).map(r=>r[0]).forEach(r=>{delete i.shared.images[r]}),Object.entries(vt(i.shared.audios)).filter(r=>r[1].asset===!1).map(r=>r[0]).forEach(r=>{delete i.shared.audios[r]})}function UA(i){i.scene.publish.settings.web.preload=!1}function L0(i){i.layers&&i.layers.forEach(t=>{t.type==="depth"&&t.num!==void 0&&(t.colors=t.colors.slice(0,t.num),t.steps=t.steps.slice(0,t.num),delete t.num)})}function B0(i){i.layers&&i.layers.forEach(t=>{S0(t)&&t.isMask===void 0&&(t.isMask=!1),(t.type==="texture"||t.type==="video")&&t.blending===void 0&&(t.blending=0),(t.type==="noise"||t.type==="displace"&&t.displacementType==="noise")&&(t.voronoiStyle===void 0&&(t.voronoiStyle=0),t.highCut===void 0&&(t.highCut=1),t.lowCut===void 0&&(t.lowCut=0),t.smoothness===void 0&&(t.smoothness=.3),t.seed===void 0&&(t.seed=0),t.quality===void 0&&(t.quality=1))})}function kA(i){i.shared.fonts=Ft({},de.prototype)}function HA(i){return i.replace(".typeface","").replace(/optimer/gi,"open sans").replace("space_mono","space mono").replace(/alma_mono/gi,"varela round").replace(/droid_sans_mono/gi,"noto sans mono").replace(/droid_sans|gentilis|gnomon_(simple|foreground)|helvetiker/gi,"roboto").replace(/droid_serif/gi,"roboto slab").replace("_sans"," sans").replace("crimson_text","crimson text").replace("medium_medium","medium").replace("fatface_fatface","fatface").replace("100hairline","thin").replace("200thin","extralight").replace("300light","light").replace("500medium","medium").replace("600semi","semibold").replace("800heavy","extrabold").replace("900black","black").replace(/bodoni_(11|16|24|36|48|72|96)([^_])/gi,"bodoni_$1_$2").replace(/bodoni_(11|16|24|36|48|72|96)/gi,"bodoni moda").replace(/(thin|hairline)(_regular)?/gi,"100").replace(/(extra|ultra)light(_regular)?/gi,"200").replace(/light(_regular)?/gi,"300").replace(/_book|_normal|_roman/gi,"_regular").replace(/medium(_regular)?/gi,"500").replace(/(semi|demi)bold(_regular)?/gi,"600").replace(/(extra|ultra)bold(_regular)?/gi,"800").replace(/bold(_regular)?/gi,"700").replace(/(black|heavy|fatface)(_regular)?/gi,"900").replace(/([1-9]00)_italic/gi,"$1italic").replace(/regularitalic/gi,"italic").replace(/regularitalic/gi,"italic").split(" ").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ")}function WA(i){let t=[];i.scene.objects.traverse((e,r)=>{let o=r;if(o.type==="TextFrame"){let n=Ut.defaultTwoLayerData("phong"),a=typeof o.color=="string"?i.shared.colors[o.color]:o.color;n.layers[1].data.color={r:a.r,g:a.g,b:a.b},n.layers[1].data.alpha=o.alpha;let s=HA(o.font);i.shared.fonts[s]===void 0&&(i.shared.fonts[s]={name:s});let l={name:o.name,..._t.defaultData,...ei.defaultData,flatShading:!1,wireframe:!1,geometry:{...Io.defaultData("TextGeometry"),width:o.width,height:o.height,font:s,depth:0,horizontalAlign:o.horizontalAlign,verticalAlign:o.verticalAlign,fontSize:o.fontSize*1.40625,lineHeight:o.lineHeight/1.40625,letterSpacing:o.letterSpacing-1,text:o.text,textTransform:o.textTransform,extrudeBevelSize:0,extrudeBevelSegments:1},material:n,states:vt(o.states),events:vt(o.events),visible:o.visible,raycastLock:o.raycastLock,position:o.position,rotation:o.rotation,scale:o.scale,hiddenMatrix:o.hiddenMatrix},c=vt(i.scene.objects).parent(e);i.scene.objects.insertAfter(c??null,e,[{id:e+"new",data:l,children:[]}]),t.push(e)}}),t.forEach(e=>{i.scene.objects.delete(e)})}function qA(i){let t={0:"MouseDown",1:"MouseUp",2:"MouseHover",5:"KeyDown",6:"KeyUp",7:"Start",9:"LookAt",10:"Follow",11:"Scroll",12:"Audio",13:"GameControl"};i.scene.objects.traverse((e,r)=>{r.events.forEach(o=>{if(!!t[Number(o.type)])if(Object.assign(o,{type:t[Number(o.type)]}),o.type==="Audio"&&"audioEvent"in o&&(Object.assign(o,{playAudio:o.audioEvent}),delete o.audioEvent),o.type==="GameControl")Object.assign(o,{gameActions:{idle:new Se,move:new Se,jump:new Se}});else{let n=new Se;Object.assign(o,{actions:n}),(o.type==="MouseDown"||o.type==="MouseUp"||o.type==="KeyDown"||o.type==="KeyUp")&&"url"in o&&n.push({fi:0,id:ml.MathUtils.generateUUID(),data:{type:"Link",url:o.url,delay:0}}),"targets"in o&&(o.targets.forEach((a,s,l)=>{let c={state:void 0,repeat:0,delay:0,delayDirection:void 0,direction:"normal",duration:0,easing:4},u={easing:a.easing,duration:a.duration};a.easing===6?Object.assign(u,ro(a,"mass","stiffness","damping","velocity")):a.easing===5&&Object.assign(u,{control1:{...a.control1},control2:{...a.control2}});let p={repeat:a.repeat?-1:0,delay:a.delay,delayDirection:a.delayDirection,direction:a.cycle&&a.rewind?"pingpong-rewind":a.cycle?"pingpong":"normal"},d={state:a.state,...p,...u},f={allowSlerp:!0,type:"Transition",object:a.object,repeat:0,delay:0,delayDirection:void 0,direction:"normal",tweens:new Se({fi:0,id:ml.MathUtils.generateUUID(),data:c},{fi:1,id:ml.MathUtils.generateUUID(),data:d})};n.push({fi:l,id:s,data:f})}),delete o.targets)}})})}function $A(i){i.scene.objects.traverse((t,e)=>{function r(o,n){let a=new Se,s=[];if(e.events.forEach((l,c,u)=>{if(l.type==="Audio"&&l.trigger===n){let p;s.push(c),l.interaction==="play"?p={...ro(l,"interaction","audio","delay","volume","loop"),triggerAfter:"after"in l?l.after:void 0,toggle:"after"in l?l.toggle:void 0,type:"Audio"}:(l.interaction==="pause"||l.interaction==="stop")&&(p={...ro(l,"interaction","delay","object","playAudio"),type:"Audio"}),p&&a.push({fi:u,id:c,data:p})}}),s.forEach(l=>e.events.delete(l)),a.length){let l=e.events.find(c=>c.type===o)?.data;l?"actions"in l&&l.actions.insertBefore(null,a):e.events.insertBefore(null,[{id:ml.MathUtils.generateUUID(),data:{type:o,actions:a}}])}}r("Start","start"),r("MouseDown","mouseDown"),r("MouseUp","mouseUp"),r("KeyDown","keyDown"),r("KeyUp","keyUp")})}function V0(i){let t=i.layers.find(e=>e.type==="light")?.data;if(t?.category==="basic"){let e=Vt.defaultData("light","phong"),r=t;Object.assign(r,e),r.visible=!1}}function z0(i){ii(i,V0),ni(i,V0)}function XA(i){i.scene.objects.traverse((t,e)=>{e.type==="Mesh"&&e.geometry.type==="SubdivGeometry"&&(e.geometry.scaleBaked||(e.geometry.scaleBaked=[1,1,1]))})}function YA(i){i.scene.objects.traverse((t,e)=>{(e.type==="Empty"||e.type==="Mesh")&&e.cloner&&!e.cloner.randomnessObject&&!e.cloner.toObject&&!e.cloner.randomness&&(e.cloner={...e.cloner,toObject:{object:"",spreadType:"random",scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],axis:"x",seed:0,count:99,align:"normal"},randomness:!1,randomnessObject:{strength:100,scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],movement:1,seed:0,freqScale:10,noiseType:"perlin"}})})}function KA(i){i.scene.objects.traverse((t,e)=>{e.type==="Mesh"&&e.geometry.type==="NonParametricGeometry"&&!("material"in e)&&!("materials"in e)&&(e.material=Ut.defaultTwoLayerData("phong"))})}function QA(i){i.scene.publish.orbitControls.autoZoom===void 0&&(i.scene.publish.orbitControls.autoZoom=!1),i.scene.objects.traverse((t,e)=>{(e.type==="OrthographicCamera"||e.type==="PerspectiveCamera")&&(e.orthographic.autoZoom===void 0&&(e.orthographic.autoZoom=!1),e.orthographic.autoZoomFrustumSize===void 0&&(e.orthographic.autoZoomFrustumSize=790))})}function ZA(i){i.scene.objects.traverse((t,e)=>{e.pathSnapping===void 0&&(e.pathSnapping={pathId:null,slide:0,offset:0,orientation:"tangential"}),e.pathSnapping.offset===void 0&&(e.pathSnapping.offset=0)})}function JA(i){i.scene.publish.mouseEventTarget===void 0&&(i.scene.publish.mouseEventTarget="canvas"),i.scene.publish.settings.web.hint===void 0&&(i.scene.publish.settings.web.hint=!1)}function eM(i){let{video:t}=i.scene.publish.settings;t.format==="gif"&&t.fps>48&&(t.fps=15)}function tM(i){i.scene.objects.traverse((t,e)=>{e.events.forEach(r=>{r.type==="GameControl"&&(r.resetYPosition=Math.abs(r.resetYPosition-e.position[1]))})})}function rM(i){let t=i.scene.environment.usePhysics;i.scene.objects.traverse((e,r)=>{t&&r.physics===null?r.collision=!1:r.collision="visibility"})}function oM(i){i.scene.objects.traverse((t,e)=>{e.events.forEach(r=>{r.type==="GameControl"&&(r.navmesh=Mu.defaultDataThirdPerson.navmesh)})})}function iM(i){i.scene.styles||(i.scene.styles=ri.defaultData())}function G0(i){i.layers.forEach(t=>{t.type==="light"&&t.category!=="toon"&&t.occlusion===void 0&&(t.occlusion=!0)})}function nM(i){i.scene.environment.ambientLight.occlusion===void 0&&(i.scene.environment.ambientLight.occlusion=!1),i.scene.environment.ambientLight.aoFullRes===void 0&&(i.scene.environment.ambientLight.aoFullRes=!1),i.scene.environment.ambientLight.radius===void 0&&(i.scene.environment.ambientLight.radius=256),i.scene.environment.ambientLight.bias===void 0&&(i.scene.environment.ambientLight.bias=.5),i.scene.environment.ambientLight.aoColor===void 0&&(i.scene.environment.ambientLight.aoColor={r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}),ni(i,G0),ii(i,G0)}function aM(i){i.scene.objects.traverse((t,e)=>{e.events.forEach(r=>{r.type==="GameControl"&&Object.assign(r.gameActions,{run:new Se})})})}function sM(i){i.scene.objects.traverse((t,e)=>{e.events.forEach(r=>{r.type==="GameControl"&&(r.keyAssignments=[...r.keyAssignments,["run","\u21E7"],["none","Ctrl"]])})})}function F0(i){i.layers&&i.layers.forEach(t=>{t.type==="light"&&t.bumpMapIntensity===void 0&&(t.bumpMapIntensity=5)})}function j0(i,t){if(t<1&&(ni(i,D0),ii(i,D0),i.schema=1),t<2&&(CA(i),i.schema=2),t<3&&(MA(i),i.schema=3),t<4&&(IA(i),i.schema=4),t<5&&(EA(i),i.schema=5),t<6&&(NA(i),i.schema=6),t<7&&(DA(i),i.schema=7),t<8&&(i.schema=8),t<9&&(R0(i),i.schema=9),t<10&&(BA(i),i.schema=10),t<11&&(VA(i),i.schema=11),t<12&&(R0(i),i.schema=12),t<13&&(zA(i),i.schema=13),t<14&&(FA(i),i.schema=14),t<15&&(jA(i),i.schema=15),t<16&&(UA(i),i.schema=16),t<17&&(ni(i,L0),ii(i,L0),i.schema=17),t<18&&(ni(i,_0),ii(i,_0),i.schema=18),t<19&&(AA(i),i.schema=19),t<20&&(kA(i),WA(i),i.schema=20),t<21&&(qA(i),$A(i),i.schema=21),t<22&&(z0(i),i.schema=22),t<23&&(XA(i),i.schema=23),t<24&&(YA(i),i.schema=24),(t<25||i.shared.videos===void 0)&&(GA(i),t<25&&(i.schema=25)),t<26&&(_A(i),i.schema=26),t<27&&(RA(i),i.schema=27),t<28&&(z0(i),i.schema=28),t<29&&(LA(i),i.schema=29),t<30&&(KA(i),i.schema=30),t<31&&(QA(i),i.schema=31),t<33&&(ZA(i),i.schema=33),t<34&&(JA(i),i.schema=34),t<35&&(eM(i),i.schema=35),t<36&&(tM(i),i.schema=36),t<37&&(rM(i),i.schema=37),t<38&&(ni(i,B0),ii(i,B0),i.schema=38),t<39&&(oM(i),i.schema=39),t<40&&(iM(i),i.schema=40),t<41&&(nM(i),i.schema=41),t<42&&(aM(i),i.schema=42),t<43&&(sM(i),i.schema=43),t<99){ni(i,F0),ii(i,F0),i.scene.publish.playCamera===null&&(i.scene.publish.playCamera=_i);let e=vt(i.scene.objects),r=i.scene.objects;i.scene.publish.playPage=Ri,r.insertBefore(null,null,[{id:Ri,data:{...ti.defaultData,backgroundColor:i.scene.backgroundColor,fog:i.scene.fog,postprocessing:i.scene.postprocessing,ao:ro(i.scene.environment.ambientLight,"occlusion","aoFullRes","radius","bias","aoColor"),publish:{playCamera:i.scene.publish.playCamera,gameControlObject:i.scene.publish.gameControlObject},shadow:ro(i.scene.environment.ambientLight,"softShadowQuality"),globalPhysics:{...hl.defaultData,...ro(i.scene.environment,"usePhysics","gravity")},camera:vt(i.scene.ownerCamera)??ti.defaultData.camera,name:"Scene"},children:[]}]);for(let a of e)a.id!==oi.TRASH_CAN_ID&&r.move(Ri,a.fi,a.id);let o=0,n=0;i.shared.penumbraSize&&i.scene.objects.traverse((a,s)=>{s.type==="DirectionalLight"?(s.penumbraSize=i.shared.penumbraSize[Math.min(o,2)],o+=1):s.type==="SpotLight"&&(s.penumbraSize=i.shared.penumbraSize[3+Math.min(n,1)],n+=1),(s.physics===void 0||s.physics===null)&&s.type!=="Instance"&&(s.physics={},Object.assign(s.physics,Bi.defaultData)),s.physics!==void 0&&s.physics!==null&&(s.physics.enabled=s.collision??"visibility",delete s.collision)}),i.schema=99}}function U0(i){i.layers&&i.layers.forEach(t=>{t.type==="light"&&t.alphaOverride===void 0&&(t.alphaOverride=1)})}function lM(i){i.scene.objects.traverse((t,e)=>{let r=e.geometry;r&&r.type==="PathGeometry"&&(r.extrusion.capType="flat",r.extrusion.bevel=50,r.extrusion.bevelSides=6,r.extrusion.shape.type==="Custom"&&(r.extrusion.shape.shapeQuality="low"))})}function cM(i){Array.isArray(vt(i.events))&&i.events?.forEach(t=>{"disabled"in t||(t.disabled=!1),(t.type==="MouseDown"||t.type==="MouseUp"||t.type==="MousePress")&&(t.mode=t.mode||"Object")})}var La=180/Math.PI;function k0(i){i.rotation=i.rotation.slice(0,3).map(t=>t*La)}function H0(i){k0(i),i.type==="Page"&&k0(i.camera),i.states?.forEach(e=>{e.rotation===void 0||e.rotation===null||(e.rotation=e.rotation.slice(0,3).map(r=>r*La))});let t=i.geometry;t&&t.type==="SphereGeometry"&&(t.thetaLength=(t.thetaLength??180)*La),t&&t.type==="TorusGeometry"&&(t.arc=t.arc*La),t&&t.type==="PathGeometry"&&(t.extrusion.angle*=La,t.extrusion.twist*=La),i.type==="Mesh"&&i.geometry.type==="TextGeometry"&&(i.geometry.text={textValue:i.geometry.text}),Array.isArray(vt(i.events))&&i.events?.forEach(e=>{(e.type==="MouseDown"||e.type==="MouseUp"||e.type==="MousePress"||e.type==="KeyDown"||e.type==="KeyUp"||e.type==="KeyPress"||e.type==="Collision"||e.type==="Trigger")&&(e.runMode=e.toggle?"Toggle":"Repeat")})}function uM(i){i.shared.variables=Ft({},de.prototype)}function dM(i){let t=vt(i.shared.variables);i.shared.variables=Ft(Object.entries(t??{}).map(([e,r],o)=>({fi:o,id:e,data:r})),Se.prototype)}var No=118;function of(i,t){t(i.data);for(let e of i.children)of(e,t)}function pM(i){let t=i.schema??104;t!==No&&(t<105&&(of(i.asset,H0),i.schema=105),t<118&&(of(i.asset,W0),i.schema=118))}function fM(i){i.shared.particles=Ft({},de.prototype),i.shared.lib&&(i.shared.lib.particles=io.defaultData().particles)}function hM(i){i.scene.objects.traverse((t,e)=>{e.type==="Particle"&&typeof e.renderMaterial.size=="number"&&Object.assign(e.renderMaterial,{size:[e.renderMaterial.size,e.renderMaterial.size]})})}function mM(i){i.scene.objects.traverse((t,e)=>{e.type==="Page"&&(e.postprocessing.depthOfField.focusDistance=100,e.postprocessing.depthOfField.focalLength=20,e.postprocessing.depthOfField.bokehScale=5)})}function yM(i){i.scene.objects.traverse((t,e)=>{Array.isArray(vt(e.events))!==!1&&e.events?.forEach(r=>{let o=r.runMode;r.type==="MouseDown"||r.type==="MouseUp"||r.type==="KeyDown"||r.type==="KeyUp"||r.type==="Collision"||r.type==="Trigger"?r.actions?.forEach(n=>{n.type==="Transition"&&(n.runMode=o??"Repeat"),(n.type==="Animation"||n.type==="SwitchCamera")&&(n.runMode=o==="Toggle"?"Toggle":"Normal")}):r.type==="MouseHover"||r.type==="MousePress"||r.type==="KeyPress"?r.actions?.forEach(n=>{(n.type==="Transition"||n.type==="Animation"||n.type==="SwitchCamera")&&(n.runMode="Toggle")}):r.type==="GameControl"?(delete r.actions,Object.keys(r.gameActions).forEach(a=>{r.gameActions[a]?.forEach(s=>{s.type==="Transition"&&(s.runMode="Repeat"),s.type==="Animation"&&(s.runMode="Normal")})})):r.type==="DragDrop"?(delete r.actions,r.dragDropActions?.drag?.forEach(n=>{(n.type==="Transition"||n.type==="Animation"||n.type==="SwitchCamera")&&(n.runMode="Toggle")}),r.dragDropActions?.drop?.forEach(n=>{(n.type==="Transition"||n.type==="Animation"||n.type==="SwitchCamera")&&(n.runMode="Toggle")})):r.type==="Resize"?(delete r.actions,r.breakpoints?.forEach(n=>{n.actions?.forEach(a=>{(a.type==="Transition"||a.type==="Animation"||a.type==="SwitchCamera")&&(a.runMode="Toggle")})})):r.type==="Start"?r.actions?.forEach(n=>{n.type==="Transition"&&(n.runMode="Once"),(n.type==="Animation"||n.type==="SwitchCamera")&&(n.runMode="Normal")}):r.type==="VariableChange"||r.type==="Scroll"?r.actions?.forEach(n=>{n.type==="Transition"&&(n.runMode="Repeat"),(n.type==="Animation"||n.type==="SwitchCamera")&&(n.runMode="Normal")}):r.type==="Conditional"&&(delete r.actions,r.inActions?.forEach(n=>{n.type==="Transition"&&(n.runMode="Repeat"),(n.type==="Animation"||n.type==="SwitchCamera")&&(n.runMode="Normal")}),r.outActions?.forEach(n=>{n.type==="Transition"&&(n.runMode="Repeat"),(n.type==="Animation"||n.type==="SwitchCamera")&&(n.runMode="Normal")}))})})}function gM(i){i.shared.userAPIs=Ft({},de.prototype),i.shared.userWebhooks=Ft({},de.prototype),i.shared.lib&&(i.shared.lib.userAPIs=io.defaultData().userAPIs,i.shared.lib.userWebhooks=io.defaultData().userWebhooks)}function xM(i){i.scene.publish.settings.videoStatic===void 0&&(i.scene.publish.settings.videoStatic=Ur.defaultData.settings.videoStatic)}function W0(i){i.timelineAnimations=Ft({},de.prototype)}function Iu(i){let t=i.schema??0;if(t!==No){console.warn("updating from ",t,"to ",No),j0(i,t),t<100&&(i.scene.publish.joystickSizeAndXYOffset===void 0&&(i.scene.publish.joystickSizeAndXYOffset=Ur.defaultData.joystickSizeAndXYOffset),i.schema=100),t<101&&(ni(i,U0),ii(i,U0),i.schema=101),t<102&&(lM(i),i.schema=102),t<104&&(i.shared.catelogs=new de,i.shared.lib=io.defaultData(),i.schema=104),t<105&&(uM(i),i.scene.objects.traverse((e,r)=>{H0(r)}),i.schema=105);for(let e of Object.values(i.shared.lib.components))pM(e);t<106&&(dM(i),i.schema=106),t<107&&(i.shared.lib.variables=io.defaultData().variables,i.schema=107),t<109&&(fM(i),i.schema=109),t<110&&(hM(i),i.schema=110),t<111&&(i.scene.objects.traverse((e,r)=>{cM(r)}),i.schema=111),t<112&&(mM(i),i.schema=112),t<113&&(yM(i),i.schema=113),t<114&&(i.scene.publish.settings.web.imageQuality===void 0&&(i.scene.publish.settings.web.imageQuality=70),i.schema=114),t<115&&(gM(i),i.schema=115),t<116&&(xM(i),i.schema=116),t<117&&(i.scene.publish.settings.web.pixelRatioMobile===void 0&&(i.scene.publish.settings.web.pixelRatioMobile=0),i.scene.publish.settings.web.pixelRatioDesktop===void 0&&(i.scene.publish.settings.web.pixelRatioDesktop=0),i.schema=117),t<118&&(i.shared.timelineAnimations=Ft({},de.prototype),i.scene.objects.traverse((e,r)=>{W0(r)}),i.schema=118)}}var _a;(c=>{c.defaultData={schema:No,scene:oi.defaultData,frames:new de().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",Ra.defaultData),shared:{...kr.emptyData(),colors:kr.defaultColors()}},c.emptyDataForImports=function(){let u=oi.emptyDataWithPage();return{schema:No,scene:u,frames:new de().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",Ra.defaultData),shared:{...kr.emptyData(),colors:kr.defaultColors(),images:kr.defaultImages()}}},c.emptyData=function(){return{schema:No,scene:oi.emptyDataWithPage(),frames:new de().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",Ra.defaultData),shared:kr.emptyData()}},c.clipboard2dData=function(){return{schema:No,scene:oi.emptyData(),frames:new de,shared:kr.emptyData()}},c.collabHelper={...ll,updateSchema(u){return(u.schema??0)<No?Ai(u,Iu):(u.schema??0)-No}};function n(u){let p=c.collabHelper.updateSchema(u);return typeof p=="number"?p===0?u:null:p.data}c.updateSchemaDirectly=n;function a(u){return{...u,shared:{...u.shared,lib:io.defaultData()}}}c.withoutLib=a;function s(u,p){let d=u.scene.objects.get(p);if(d&&d.data.type==="Component")return d;{let f=u.shared.lib.components[p];if(f)return f.asset}}c.getComponentData=s;function l(u){let p=Object.values(u.shared.userAPIs);for(let d of p){let f=d.headers;for(let h of f)if(h.data.key.toLowerCase()==="authorization"&&h.data.value!=="")return!0}return!1}c.hasSensitiveData=l})(_a||(_a={}));var Eu;(t=>t.emptyImage={data:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII=",name:"empty"})(Eu||(Eu={}));var q0;(t=>{function i(e){return!0}t.is=i})(q0||(q0={}));var Nu;(r=>{r.defaultData={position:[0,0],scale:[1,1],rotation:0,shear:[0,0]};function t(o,n){return{position:n?.position??o.position,rotation:n?.rotation??o.rotation,scale:n?.scale??o.scale,shear:n?.shear??o.shear}}r.merge=t;function e(o,n){return bc({position:Ta.isEqual(o.position,n.position)?void 0:n.position,rotation:o.rotation===n.rotation?void 0:n.rotation,scale:Ta.isEqual(o.scale,n.scale)?void 0:n.scale,shear:o.shear&&n.shear&&Ta.isEqual(o.shear,n.shear)?void 0:n.shear})}r.diff=e})(Nu||(Nu={}));var nf;(t=>t.defaultData={horizontalConstraint:0,verticalConstraint:0})(nf||(nf={}));var $0;(t=>t.defaultData={direction:"row",wrap:"unwrap",align:"top-left",gap:10,rowGap:10,autoGap:!1,autoRowGap:!1,leftPadding:8,rightPadding:8,topPadding:8,bottomPadding:8})($0||($0={}));var Du;(t=>t.defaultData={opacity:1,fill:{color:Re.fromHexAndA(Dt,1),enabled:!0},stroke:{color:Re.from0to1([0,0,0,1]),thickness:1,enabled:!1,mode:"inside"},layerBlur:{radius:2,enabled:!1},backgroundBlur:{radius:2,enabled:!1},dropShadow:{offset:[10,10],blurRadius:10,color:Re.from0to1([0,0,0,1]),enabled:!1,spread:0},innerShadow:{offset:[10,10],blurRadius:10,color:Re.from0to1([0,0,0,1]),enabled:!1,spread:0}})(Du||(Du={}));var Tn;(n=>{function i(a,s){return{name:s}}n.newEmpty=i;function t(a,s){if(s===void 0)return a;let l={...a},c=["width","height","cornerRadius"];for(let u of c)u in l&&u in s&&s[u]!==void 0&&Object.assign(l,{[u]:s[u]});return l}function e(a,s){if(s===void 0)return a;let l={...a};return"fill"in l&&"fill"in s&&s.fill!==void 0&&Object.assign(l,{fill:{...l.fill,...s.fill}}),"stroke"in l&&"stroke"in s&&s.stroke!==void 0&&Object.assign(l,{stroke:{...l.stroke,...s.stroke}}),"layerBlur"in l&&"layerBlur"in s&&s.layerBlur!==void 0&&Object.assign(l,{layerBlur:{...l.layerBlur,...s.layerBlur}}),"backgroundBlur"in l&&"backgroundBlur"in s&&s.backgroundBlur!==void 0&&Object.assign(l,{backgroundBlur:{...l.backgroundBlur,...s.backgroundBlur}}),"dropShadow"in l&&"dropShadow"in s&&s.dropShadow!==void 0&&Object.assign(l,{dropShadow:{...l.dropShadow,...s.dropShadow}}),"innerShadow"in l&&"innerShadow"in s&&s.innerShadow!==void 0&&Object.assign(l,{innerShadow:{...l.innerShadow,...s.innerShadow}}),l}function r(a,s){if(s===void 0)return a;let l={...a};return Object.assign(l,Nu.merge(l,s)),l=t(l,s),l=e(l,s),l}n.patch=r;function o(a,s){let l,c=[];for(let[u,p]of Object.entries(s))u!=="name"&&(l===void 0&&(l={path:[],props:{},type:0},c.push(l)),l.props[u]=p);return c}n.toOps=o})(Tn||(Tn={}));var yl;(t=>t.defaultData={...Nu.defaultData,...nf.defaultData,states:new Se,events:new Se,visible:!0,raycastLock:!1})(yl||(yl={}));var Ba;(t=>t.defaultData={...yl.defaultData,...Du.defaultData})(Ba||(Ba={}));var _u;(t=>t.defaultData={cornerRadius:[0,0,0,0]})(_u||(_u={}));var af;(t=>t.defaultData={...Ba.defaultData,type:"ellipse2d",width:100,height:100,name:"Ellipse"})(af||(af={}));var Va;(t=>t.defaultData={...Ba.defaultData,..._u.defaultData,type:"rectangle2d",width:100,height:100,name:"Rectangle"})(Va||(Va={}));var sf;(t=>t.defaultData={...Ba.defaultData,type:"text2d",width:100,height:100,fontSize:12,lineHeight:1.2,letterSpacing:0,text:{textValue:"Hello world"},horizontalAlign:1,verticalAlign:1,textTransform:1,font:"Roboto_regular",name:"Text"})(sf||(sf={}));var lf;(t=>t.defaultData={...Ba.defaultData,type:"path2d",path:"",name:"Path"})(lf||(lf={}));var X0;(t=>{function i(e){return e.type==="ellipse2d"||e.type==="rectangle2d"||e.type==="text2d"||e.type==="vector2d"||e.type==="path2d"}t.is=i})(X0||(X0={}));var gl;(t=>t.defaultData={...yl.defaultData,name:"Group",type:"group2d"})(gl||(gl={}));var cf;(t=>t.defaultData=()=>({...yl.defaultData,..._u.defaultData,...Du.defaultData,name:"Frame",type:"frame2d",clipped:!0,width:200,height:200,fill:{color:Re.fromHexAndA(4737101,1),enabled:!0},stroke:{color:Re.fromHexAndA(0,1),thickness:1,enabled:!1,mode:"inside"},backgroundBlur:{radius:2,enabled:!1},layerBlur:{radius:2,enabled:!1}}))(cf||(cf={}));var ai;(n=>{function i(a){switch(a){case"rectangle2d":return{...Va.defaultData};case"ellipse2d":return{...af.defaultData};case"text2d":return{...sf.defaultData};case"vector2d":return{...Va.defaultData};case"path2d":return{...lf.defaultData};case"frame2d":return{...cf.defaultData()};case"group2d":return{...gl.defaultData}}}n.defaultData=i;function t(a){return"width"in a&&"height"in a?[typeof a.width=="number"?a.width*.5:0,typeof a.height=="number"?a.height*.5:0]:[0,0]}n.getPivot=t;function e(a){return a.type==="rectangle2d"||a.type==="ellipse2d"||a.type==="text2d"||a.type==="frame2d"}n.isResizeable=e;function r(a){return a.type==="frame2d"&&a.autoLayout!==void 0}n.isAutoLayoutable=r;function o(a){return a.type==="rectangle2d"||a.type==="frame2d"}n.hasCorners=o})(ai||(ai={}));var Ru;(e=>(e.defaultData={name:"UI",type:"scene2d",objects:new ct},e.emptyData=function(){return{type:"scene2d",objects:new ct}}))(Ru||(Ru={}));var Y0=require("three"),kt=class extends Y0.Color{constructor(e,r,o,n){super(e,r,o);this.isColorA=!0;this.a=n}setRGBA(e,r,o,n){super.setRGB(e,r,o),this.a=n}copy(e){return super.copy(e),this.a="a"in e?e.a:1,this}clone(){return new this.constructor(this.r,this.g,this.b,this.a)}equals(e){return super.equals(e)&&this.a===e.a}setStyle(e,r="srgb"){let o;if(e==="transparent")return this.setRGBA(0,0,0,0),this;if(o=/^((?:rgb|hsl)a?)\(([^)]*)\)/.exec(e)){let n,a=o[1],s=o[2];switch(a){case"rgb":case"rgba":if(n=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))return this.a=a==="rgba"?parseFloat(n[4]):1,super.setStyle(e,r);break;case"hsl":case"hsla":if(n=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)%\s*,\s*(\d*\.?\d+)%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))return this.a=a==="hsla"?parseFloat(n[4]):1,super.setStyle(e,r);break}}return super.setStyle(e,r)}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}};var tt=require("three"),Id=tl(Q0());var bM=.5*(Math.sqrt(3)-1),xl=(3-Math.sqrt(3))/6,vM=1/3,Do=1/6,o4=(Math.sqrt(5)-1)/4,i4=(5-Math.sqrt(5))/20,bl=i=>Math.floor(i)|0,Z0=new Float64Array([1,1,-1,1,1,-1,-1,-1,1,0,-1,0,1,0,-1,0,0,1,0,-1,0,1,0,-1]),df=new Float64Array([1,1,0,-1,1,0,1,-1,0,-1,-1,0,1,0,1,-1,0,1,1,0,-1,-1,0,-1,0,1,1,0,-1,1,0,1,-1,0,-1,-1]);function J0(i=Math.random){let t=tx(i),e=new Float64Array(t).map(o=>Z0[o%12*2]),r=new Float64Array(t).map(o=>Z0[o%12*2+1]);return function(n,a){let s=0,l=0,c=0,u=(n+a)*bM,p=bl(n+u),d=bl(a+u),f=(p+d)*xl,h=p-f,m=d-f,y=n-h,b=a-m,v,w;y>b?(v=1,w=0):(v=0,w=1);let O=y-v+xl,S=b-w+xl,T=y-1+2*xl,M=b-1+2*xl,g=p&255,D=d&255,E=.5-y*y-b*b;if(E>=0){let _=g+t[D],R=e[_],V=r[_];E*=E,s=E*E*(R*y+V*b)}let I=.5-O*O-S*S;if(I>=0){let _=g+v+t[D+w],R=e[_],V=r[_];I*=I,l=I*I*(R*O+V*S)}let N=.5-T*T-M*M;if(N>=0){let _=g+1+t[D+1],R=e[_],V=r[_];N*=N,c=N*N*(R*T+V*M)}return 70*(s+l+c)}}function ex(i=Math.random){let t=tx(i),e=new Float64Array(t).map(n=>df[n%12*3]),r=new Float64Array(t).map(n=>df[n%12*3+1]),o=new Float64Array(t).map(n=>df[n%12*3+2]);return function(a,s,l){let c,u,p,d,f=(a+s+l)*vM,h=bl(a+f),m=bl(s+f),y=bl(l+f),b=(h+m+y)*Do,v=h-b,w=m-b,O=y-b,S=a-v,T=s-w,M=l-O,g,D,E,I,N,_;S>=T?T>=M?(g=1,D=0,E=0,I=1,N=1,_=0):S>=M?(g=1,D=0,E=0,I=1,N=0,_=1):(g=0,D=0,E=1,I=1,N=0,_=1):T<M?(g=0,D=0,E=1,I=0,N=1,_=1):S<M?(g=0,D=1,E=0,I=0,N=1,_=1):(g=0,D=1,E=0,I=1,N=1,_=0);let R=S-g+Do,V=T-D+Do,U=M-E+Do,B=S-I+2*Do,q=T-N+2*Do,j=M-_+2*Do,F=S-1+3*Do,H=T-1+3*Do,W=M-1+3*Do,ee=h&255,te=m&255,Y=y&255,re=.6-S*S-T*T-M*M;if(re<0)c=0;else{let $=ee+t[te+t[Y]];re*=re,c=re*re*(e[$]*S+r[$]*T+o[$]*M)}let K=.6-R*R-V*V-U*U;if(K<0)u=0;else{let $=ee+g+t[te+D+t[Y+E]];K*=K,u=K*K*(e[$]*R+r[$]*V+o[$]*U)}let Z=.6-B*B-q*q-j*j;if(Z<0)p=0;else{let $=ee+I+t[te+N+t[Y+_]];Z*=Z,p=Z*Z*(e[$]*B+r[$]*q+o[$]*j)}let Q=.6-F*F-H*H-W*W;if(Q<0)d=0;else{let $=ee+1+t[te+1+t[Y+1]];Q*=Q,d=Q*Q*(e[$]*F+r[$]*H+o[$]*W)}return 32*(c+u+p+d)}}function tx(i){let e=new Uint8Array(512);for(let r=0;r<512/2;r++)e[r]=r;for(let r=0;r<512/2-1;r++){let o=r+~~(i()*(256-r)),n=e[r];e[r]=e[o],e[o]=n}for(let r=256;r<512;r++)e[r]=e[r-256];return e}var rx=require("three"),no=new rx.Triangle,Lu=class{constructor(t){this.weightAttribute=null;let e=t.geometry;if(!e.isBufferGeometry||e.attributes.position.itemSize!==3)throw new Error("THREE.MeshSurfaceSampler: Requires BufferGeometry triangle mesh.");e.index&&(e=e.toNonIndexed()),this.geometry=e,this.randomFunction=Math.random,this.positionAttribute=this.geometry.getAttribute("position"),this.distribution=null}build(){let t=this.positionAttribute,e=new Float32Array(t.count/3);for(let o=0;o<t.count;o+=3){let n=1;no.a.fromBufferAttribute(t,o),no.b.fromBufferAttribute(t,o+1),no.c.fromBufferAttribute(t,o+2),n*=no.getArea(),e[o/3]=n}this.distribution=new Float32Array(t.count/3);let r=0;for(let o=0;o<e.length;o++)r+=e[o],this.distribution[o]=r;return this}setRandomGenerator(t){return this.randomFunction=t,this}sample(t,e){if(this.distribution){let r=this.distribution[this.distribution.length-1],o=this.binarySearch(this.randomFunction()*r);return this.sampleFace(o,t,e)}}binarySearch(t){if(!this.distribution)return 0;let e=this.distribution,r=0,o=e.length-1,n=-1;for(;r<=o;){let a=Math.ceil((r+o)/2);if(a===0||e[a-1]<=t&&e[a]>t){n=a;break}else t<e[a]?o=a-1:r=a+1}return n}sampleFace(t,e,r){let o=this.randomFunction(),n=this.randomFunction();return o+n>1&&(o=1-o,n=1-n),no.a.fromBufferAttribute(this.positionAttribute,t*3),no.b.fromBufferAttribute(this.positionAttribute,t*3+1),no.c.fromBufferAttribute(this.positionAttribute,t*3+2),e.set(0,0,0).addScaledVector(no.a,o).addScaledVector(no.b,n).addScaledVector(no.c,1-(o+n)),no.getNormal(r),this}};var ax=require("three");var _r=require("three"),nx=tl(ix()),SM=new _r.Matrix4,wM=new _r.Matrix4,PM=new _r.Matrix4,si;(t=>{function i(e){return e&&e.__isSPEObject}t.is=i})(si||(si={}));var za=i=>class extends i{constructor(){super(...arguments);this.previousModelViewMatrix=new _r.Matrix4;this.copyPreviousMatrix=!0;this.hiddenMatrix=new _r.Matrix4;this.matrixWorldRigid=new _r.Matrix4;this.shearScale=new _r.Matrix4;this.shearScaleInv=new _r.Matrix4}get __isSPEObject(){return!0}isDescendantOf(r){r instanceof _r.Object3D&&(r=r.uuid);let o=this;for(;o.parent;){if(o.parent.uuid===r)return!0;o=o.parent}return!1}updateMatrixWorld(r){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||r)&&(this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,r=!0);for(let o of this.children)o.updateMatrixWorld(r)}updateWorldMatrix(r,o){let n=this.parent;if(r&&n!==null&&n.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)),o)for(let a of this.children)a.updateWorldMatrix(!1,!0)}traverseChildren(r,o=0){for(let n of this.children)si.is(n)&&n.traverseObject(r,o+1)}traverseObject(r,o=0){if(r(this,o)!==!0)for(let a of this.children)si.is(a)&&a.traverseObject(r,o+1)}updateMatrixWorldSVD(){let r=this.matrixWorld.elements,o=[[r[0],r[4],r[8]],[r[1],r[5],r[9]],[r[2],r[6],r[10]]],{u:n,v:a,q:s}=(0,nx.SVD)(o),l=SM.set(n[0][0],n[0][1],n[0][2],0,n[1][0],n[1][1],n[1][2],0,n[2][0],n[2][1],n[2][2],0,0,0,0,1),c=wM.set(a[0][0],a[0][1],a[0][2],0,a[1][0],a[1][1],a[1][2],0,a[2][0],a[2][1],a[2][2],0,0,0,0,1),u=PM.copy(c).transpose();this.shearScale.makeScale(s[0],s[1],s[2]).multiply(u).premultiply(c),this.shearScaleInv.copy(this.shearScale).invert(),this.matrixWorldRigid.multiplyMatrices(l,u).copyPosition(this.matrixWorld),s.every(p=>Math.abs(s[0]-p)<.01)?this.hasNonUniformScale=!1:this.hasNonUniformScale=!0}attach(r,o){this.updateWorldMatrix(!0,!1);let n=new _r.Matrix4().copy(this.matrixWorld).invert();return r.parent!==null&&(r.parent.updateWorldMatrix(!0,!1),n.multiply(r.parent.matrixWorld)),"hiddenMatrix"in r&&r.hiddenMatrix instanceof _r.Matrix4?r.hiddenMatrix.premultiply(n):r.applyMatrix4(n),r.updateWorldMatrix(!1,!1),this.add(r),o!==void 0&&(this.children.pop(),this.children.splice(o,0,r)),this}copy(r,o=!1){return super.copy(r,o),this.hasNonUniformScale=r.hasNonUniformScale,this}onAfterRender(r,o,n,a,s,l){this.copyPreviousMatrix&&this.previousModelViewMatrix.copy(this.modelViewMatrix)}};var pf=class extends za(ax.Object3D){},OM=i=>i.type==="Mesh",ao=class extends pf{constructor(e){super();this.object=e;this.matrixAutoUpdate=!1,this.hasNonUniformScale=e.hasNonUniformScale}raycast(e,r){}expand(){let e=0,r=this.object.entityChildren(e);for(;r;){let o=this.children[e];o?.object!==r&&(o&&this.remove(o),o=new ao(r),this.add(o),this.children.splice(e,0,this.children.pop()),o.matrixWorldNeedsUpdate=!0,o.matrixAutoUpdate=!1,o.matrix=r.matrix,o.hiddenMatrix=r.hiddenMatrix),o.expand(),e+=1,r=this.object.entityChildren(e)}for(;this.children.length>e;)this.remove(this.children[e])}get visible(){return this.playModeVisible!==void 0?this.playModeVisible:this.object.visible||this.object.dataPatched.visible&&this.object.dataPatched.cloner?.hideBase===!0}set visible(e){}get castShadow(){return this.object.castShadow}set castShadow(e){}get receiveShadow(){return this.object.receiveShadow}set receiveShadow(e){}get isMesh(){return OM(this.object)}get isLight(){return this.object.isLight}get layers(){return this.object.layers}set layers(e){}get isCamera(){return!1}get geometry(){if(this.object.geometry)return this.object.geometry}get material(){if(this.object.material)return this.object.material}get morphTargetInfluences(){if(this.object.morphTargetInfluences)return this.object.morphTargetInfluences}set morphTargetInfluences(e){}};var is=require("three");var rd=require("three");var ur=require("three");var It=require("three"),Cn=new It.Vector3,An=new It.Vector3,Ga=new It.Matrix4,lx=[new It.Vector3(-1,1,1),new It.Vector3(-1,-1,1),new It.Vector3(1,-1,1),new It.Vector3(1,1,1),new It.Vector3(-1,1,-1),new It.Vector3(-1,-1,-1),new It.Vector3(1,-1,-1),new It.Vector3(1,1,-1)],TM=[[0,3],[1,2],[5,6],[4,7],[0,1],[3,2],[7,6],[4,5],[0,4],[1,5],[2,6],[3,7]],CM=[[0,2],[7,5],[4,1],[3,6],[4,3],[1,6]],sx=(i,t,e)=>{i.updateEntityBoxSize(Cn,An),Ga.copy(t).multiply(i.matrixWorld),An.x===0&&An.y===0&&An.z===0?e.push(new It.Vector3(Cn.x,Cn.y,Cn.z).applyMatrix4(Ga)):lx.forEach(r=>{e.push(r.clone().multiply(An).add(Cn).applyMatrix4(Ga))})},vl=class extends It.Box3{constructor(){super(...arguments);this.matrix=new It.Matrix4;this.vertices=[];this.faces=[];this.edges=[];this.centerEdges=[]}copy(e){return super.copy(e),this.matrix.copy(e.matrix),this.vertices=e.vertices.map(r=>r.clone()),this.faces=e.faces.map(r=>r.clone()),this.edges=e.edges.map(r=>r.clone()),this.centerEdges=e.centerEdges.map(r=>r.clone()),this}setFromObjectSize(e,r=!1){e.updateWorldMatrix(!1,r),this.makeEmpty(),this.matrix.copy(e.matrixWorld);let o=new It.Matrix4().copy(e.matrixWorld).invert();return this.expandByObjectSize(e,o,r)}expandByObjectSize(e,r,o=!1){let n=[];return o===!0?e.traverseEntity(a=>{if(a.visible||a.cloner&&a.data.visible){if(!("geometry"in a)){n.push(new It.Vector3);return}sx(a,r,n)}}):sx(e,r,n),this.setFromPoints(n)}getCenter(e){return e=super.getCenter(e),e.applyMatrix4(this.matrix),e}getPositionToCenter(e){return e=super.getCenter(e),e.applyMatrix4(Ga.copy(this.matrix).setPosition(0,0,0)),e}computeVertices(){this.getSize(An).multiplyScalar(.5),this.getCenter(Cn),Ga.copy(this.matrix).setPosition(Cn),this.vertices=lx.map(e=>e.clone().multiply(An).applyMatrix4(Ga))}computeEdges(){this.vertices.length>0&&this.computeVertices(),this.edges=TM.map(([e,r])=>new It.Line3(this.vertices[e],this.vertices[r])),this.centerEdges=this.edges.map(e=>e.getCenter(new It.Vector3))}computeFaces(){this.vertices.length>0&&this.computeVertices(),this.faces=CM.map(([e,r])=>this.vertices[e].clone().add(this.vertices[r]).multiplyScalar(.5))}};var so={Cloner:()=>{},changeEntityProptotype:()=>{},createEntity:()=>{}};var Qt=require("three"),hf=class extends Qt.CurvePath{constructor(){super()}getPoints(t=12){let e=[],r,o=this.getCurveLengths(),a=o[o.length-1]/o.length;for(let s=0,l=this.curves;s<l.length;s++){let c=l[s],u=s===0?o[s]:o[s]-o[s-1],p=Math.ceil(t*u/a),d=c.getPoints(p);for(let f=0;f<d.length;f++){let h=d[f];r&&r.equals(h)||(e.push(h),r=h)}}return this.autoClose&&e.length>1&&!e[e.length-1].equals(e[0])&&e.push(e[0]),e}};var mf=.001;function yf(i,t,e){return t.clone().sub(i).cross(t.clone().sub(e)).length()<=mf}function ff(i,t){let e=new Qt.Vector3(...i.position),r=new Qt.Vector3(...i.controlNext.position),o=new Qt.Vector3(...t.controlPrevious.position),n=new Qt.Vector3(...t.position);return yf(e,r,n)&&yf(e,o,n)}function Vu(i){let t=i.points.map(u=>new Qt.Vector3(...u.data.position)),e=[i.points[0]],r=new Qt.Vector3(...e[0].data.position);for(let u=0;u<i.points.length-1;u++)yf(r,t[u],t[u+1])||(e.push(i.points[u]),r=t[u]);e.push(i.points[i.points.length-1]);let o=i.isClosed,n=e.length-(o?0:1),a=e.length,s=[];for(let u=0;u<a;u++){let p=e[u].data,d=new Qt.Vector3(...p.position),f=new Qt.Vector3(...p.controlPrevious.position),h=new Qt.Vector3(...p.controlNext.position),m={position:d,baseRoundness:p.roundness,controlPrevious:f,controlNext:h};if(p.roundness===0||!i.isClosed&&(u===0||u===a-1)){s[u]={...m,removedLength:0};continue}let y=o&&u==0?a-1:u-1,b=o&&u==a-1?0:u+1,v=e[y].data,w=e[b].data,O=new Qt.Vector3(...v.position),S=new Qt.Vector3(...w.position),T=O.clone().sub(d).normalize(),M=S.clone().sub(d).normalize();Object.assign(m,{prevDir:T,nextDir:M});let g=ff(v,p),D=ff(p,w);if(!g||!D)s[u]={...m,removedLength:0};else{let E=T.clone().add(M).normalize(),I=E.clone().cross(T).length()/T.dot(E);s[u]={...m,tan:I,removedLength:p.roundness/I}}}for(let u=0;u<n;u++){let p=u,d=o&&u===a-1?0:u+1,f=s[p],h=s[d];if(f.removedLength!==0||h.removedLength!==0){let m=f.position.distanceTo(h.position);f.removedLength=Math.min(f.removedLength,m/2),h.removedLength=Math.min(h.removedLength,m/2)}}let l=[];for(let u=0;u<n;u++){let p=u,d=o&&u===a-1?0:u+1,f=s[p],h=s[d],m=null;if(!ff(e[p].data,e[d].data))f.position.distanceTo(h.position)>mf&&(m=new Qt.CubicBezierCurve3(f.position,f.controlNext,h.controlPrevious,h.position));else{let y=f.position.clone(),b=h.position.clone();(f.removedLength!==0||h.removedLength!==0)&&(f.nextDir&&y.add(f.nextDir.clone().setLength(f.removedLength)),h.prevDir&&b.add(h.prevDir.clone().setLength(h.removedLength))),y.distanceTo(b)>mf&&(m=new Qt.CubicBezierCurve3(y,y.clone().lerp(b,.3),b.clone().lerp(y,.3),b))}l[2*u+1]=m}for(let u=0;u<a;u++){let p=s[u];if(p.removedLength===0){l[2*u]=null;continue}let d=p.position,f=p.prevDir.clone().multiplyScalar(p.removedLength).add(d),h=p.nextDir.clone().multiplyScalar(p.removedLength).add(d),m=p.tan*p.removedLength,y=p.prevDir.clone().add(p.nextDir).normalize(),b=f.clone().lerp(h,.5),v=f.distanceTo(h)/2,w=y.clone().multiplyScalar(Math.sqrt(Math.pow(m,2)-Math.pow(v,2))).add(b),O=y.clone().multiplyScalar(-m).add(w),S=d.distanceTo(O)/d.distanceTo(b),T=p.prevDir.clone().multiplyScalar(S*d.distanceTo(f)).add(d),M=T.clone().lerp(O,2),g=f.clone().lerp(T,4/3),D=h.clone().lerp(M,4/3);l[2*u]=new Qt.CubicBezierCurve3(f,g,D,h)}let c=new hf;return l.forEach(u=>{u&&c.add(u)}),c}var ze;(t=>{function i(e){return e&&e.__isEntity}t.is=i})(ze||(ze={}));var Fa=i=>ze.is(i),AM={type:"completeState",isfromEntity:!0},MM=["x","y","z"],gf=new ur.Vector3,IM=new ur.Vector3().set(0,1,0),ja=i=>class extends za(i){constructor(){super(...arguments);this.raycastLock=!1;this.scaleLock=!1;this.disposed=!1;this.stateSelection=null;this.destroyedInAction=!1;this.instances=[];this.prevState=null;this.currentState=null;this.currentAnimationAction=null;this.reversibleToState=null;this.currentTransitionEvent=null;this.previousAction=null;this._singleBBox=new vl;this._recursiveBBox=new vl;this.singleBBoxNeedsUpdate=!0;this.recursiveBBoxNeedsUpdate=!0;this._needApplyPathSnapping=!0;this.attachedPaths=new Set}get __isEntity(){return!0}entityChildren(r){let o=this.children[r];if(ze.is(o))return o}entityChildrenCount(){let r=this.children.length;for(;r--;)if(ze.is(this.children[r]))return r+1;return 0}get isConcreteEntity(){return typeof this.identity=="string"}get isVirtualEntity(){return typeof this.identity!="string"}get isInstanceRoot(){return this.isConcreteEntity&&this.data.type==="Instance"}nearestInstanceSelfOrParent(){let r=this;for(;r.data.type!=="Instance";){let o=r.parent;if(ze.is(o))r=o;else return}return r}forInstancesRec(r){this.instances.forEach(o=>{o.disposed||r(o),o.forInstancesRec(r)})}super_Entity(r,o){typeof r=="string"&&(this.uuid=r),this.identity=r,this.data=o,this.matrixAutoUpdate=!1,this.dataPatched=this.data}changeSelectedState(r,o,n=!1){if(!(this.data.states.length===0&&!n)){for(let a of this.data.states)On.toOps(this.data,a.data).forEach(l=>{let c=Sa.replaceProps(l,this.data);this.dataPatched=this.data,this.updateByPatchedOp(c,this.data,o)});if(r!==null){let a=this.data.states.data(r);a&&(this.dataPatched=On.patch(this.data,a),On.toOps(this.data,a).forEach(l=>{this.updateByPatchedOp(l,this.dataPatched,o)}))}n&&this.updateTransformState(this.dataPatched,o),this.stateSelection=r,this.updatePathSnapping(this.dataPatched.pathSnapping)}}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}updateEntityBoxSize(r,o){r.setScalar(0),o.setScalar(0)}resetBBoxNeedsUpdateSelf(){this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0}resetBBoxNeedsUpdate(){this.resetBBoxNeedsUpdateSelf(),this.traverseAncestors(r=>{Fa(r)&&r.resetBBoxNeedsUpdateSelf()}),this.traverseEntity(r=>{r.resetBBoxNeedsUpdateSelf()})}find(r){let o;return this.traverseEntity(n=>{n.uuid===r&&(o=n)}),o}traverseSortNextHelper(){let r=this.parent;if(r){let o=r.children,n=o.indexOf(this)+1;if(ze.is(o[n]))return o[n];if(ze.is(r))return r.traverseSortNextHelper()}}sortNext(){let r=this.children;return this.children.length>0&&ze.is(this.children[0])?r[0]:this.traverseSortNextHelper()}goUp(r){let o=this;for(;r>0&&o!==null;)o=o.parent,r-=1;return o}hasAnccestorOrSelf(r){return this===r||this.hasAnccestor(r)}hasAnccestor(r){let o=this.parent;for(;o;){if(r===o)return!0;o=o.parent}return!1}countToAccestor(r){let o=0,n=this;for(;n!==r;){if(n===null)return-1;n=n.parent,o+=1}return o}forEachEntity(r){for(let o of this.children)Fa(o)&&r(o)}traverseEntityAncestors(r){this.traverseAncestors(o=>{ze.is(o)&&r(o)})}traverseConcreteEntity(r,o=0){if(r(this,o)!==!0)for(let a of this.children)Fa(a)&&a.isConcreteEntity&&a.traverseEntity(r,o+1)}traverseEntity(r,o=0){if(r(this,o)!==!0)for(let a of this.children)Fa(a)&&a.traverseEntity(r,o+1)}traverseVisibleEntity(r){r(this);for(let o of this.children)Fa(o)&&o.visible&&o.traverseVisibleEntity(r)}updateMatrix(){super.updateMatrix(),this.cloner&&this.cloner.onObjUpdateMatrix(),this.dispatchEvent({type:"updateMatrix"})}updateMatrixWorld(r){super.updateMatrixWorld(r),this.dispatchEvent({type:"updateMatrixWorld"})}copy(r,o=!1){return super.copy(r,o),this.dataPatched=r.dataPatched,this.raycastLock=r.raycastLock,this.scaleLock=r.scaleLock,this.hiddenMatrix.copy(r.hiddenMatrix),this}hasEntityChild(){return this.children.some(r=>Fa(r))}isAncestorOf(r){if(this.uuid===r)return!1;let o=!1;return this.traverseEntity(n=>{n.uuid===r&&(o=!0)}),o}toObjectTransformState(r=[]){this.updateWorldMatrix(!0,!1);let o={position:this.position.toArray(),rotation:[this.rotation.x*ur.MathUtils.RAD2DEG,this.rotation.y*ur.MathUtils.RAD2DEG,this.rotation.z*ur.MathUtils.RAD2DEG],scale:this.scale.toArray(),hiddenMatrix:this.hiddenMatrix.toArray()};return ya(o,r)}getTransformValues(r,o,n){return o[r].map((a,s)=>n?.shared.getVariable(a,[this.uuid,r,MM[s]])??a)}updateTransformState(r,o){let n=!1;return r.position&&(this.position.fromArray(this.getTransformValues("position",r,o)),n=!0),r.rotation&&(gf.fromArray(this.getTransformValues("rotation",r,o)).multiplyScalar(ur.MathUtils.DEG2RAD),this.rotation.setFromVector3(gf),n=!0),r.scale&&(this.scale.fromArray(this.getTransformValues("scale",r,o)),n=!0),r.hiddenMatrix!==void 0&&(n=!0,this.hiddenMatrix.fromArray(r.hiddenMatrix??Di.identity)),n&&(this.updateMatrix(),this.resetBBoxNeedsUpdate(),this.invalidateClonerTransform(this),this.traverseEntityAncestors(a=>{a.invalidateClonerTransform(this)})),r.position&&r.rotation&&r.scale&&r.hiddenMatrix!==void 0&&this.updateWorldMatrix(!1,!0),n}onVariableUpdate(r=!1){if(r){this.resetBBoxNeedsUpdate();return}this.updateMatrix(),this.resetBBoxNeedsUpdate(),this.invalidateClonerTransform(this),this.traverseEntityAncestors(o=>{o.invalidateClonerTransform(this)})}dispose(){this.disposed=!0,this.cloner&&(this.cloner.removeFromParent(),this.cloner=void 0)}disposeChildrenRecursively(){for(let r of this.children)ze.is(r)&&r.disposeRecursively()}disposeRecursively(){this.dispose(),this.children.forEach(r=>{ze.is(r)&&r.disposeRecursively()})}toState(r=[]){let o={name:this.name,visible:this.visible,raycastLock:this.raycastLock,...this.toObjectTransformState(r)};return ya(o,r)}updateByObjUpdateOp(r,o){r!==void 0&&this.updateByOp({type:0,props:r,path:[]},{...this.data,...r},o,!1)}updateByOp(r,o,n,a){let s=this.data;this.data=o;let l=r,c=je(r.path,["states","*"]);if(c!==null){if(r.type===0){let[u]=c;if(this?.stateSelection===u){let p={...r.props};if(delete p.name,Object.values(r.props).some(d=>d===void 0)){let d=this.data;if(d!==void 0){let f=ut.zoom(d,r.path.slice(2));if(f)for(let h in r.props)r.props[h]===void 0&&h in f&&(p[h]=f[h])}}l={...r,props:p,path:r.path.slice(2)}}}}else if(r.type===0){let u=this.stateSelection?this.data.states.data(this.stateSelection):void 0;if(u!==void 0){if(r.props.name!==void 0&&u.name){let{name:d,...f}=u;u=f}if(r.props.material!==void 0&&"material"in u){let{material:d,...f}=u;u=f}let p=ut.removeOverridden(r.path,r.props,u);l={...r,props:p}}}if(this.updateByPatchedOpBase(l,On.patch(this.data,this.stateSelection?this.data.states.data(this.stateSelection):void 0),n),je(r.path,["overrides"])){let u=[],p=[...r.path];for(u.push(p[1]),p.splice(0,2);p.length>0&&p[0]==="descendants";)u.push(p[1]),p.splice(0,2);if(u[u.length-1]===void 0){if(r.type===0)for(let d of Object.keys(r.props)){u[u.length-1]=d;let f=n.scene.findInstance([this.uuid,...u]);f&&(f.overrideData=r.props[d],f.updateState(Po.apply(f.component.data,f.overrideData),n))}}else{let d=n.scene.findInstance([this.uuid,...u]);if(d){let f=ut.zoom(d.component.data,p);if(r={...r,path:p},r.type===0){let h=r.props;if(f)for(let[m,y]of Object.entries(r.props))y===void 0&&(h===r.props&&(h={...r.props}),h[m]=f[m]);r={...r,props:h}}d.overrideData=Na.resolve(o.overrides,u),d.updateByOp(r,bt.applySimple(d.data,r),n,!1)}}}else if(this.instances.length>0){let u;if(r.path.length===0&&r.type===0){let p;for(let d of Eo.rootOverrideProps)d in r.props&&(p===void 0&&(p={}),p[d]=r.props[d]);p&&(u={...r,props:p})}else for(let p of Eo.rootOverrideProps)if(je(r.path,[p])){u=r;break}u!==void 0&&this.instances.forEach(p=>{if(p.isInstanceRoot){let d=Po.filterOp(p.overrideData,u);d&&p.updateByOp(d,bt.applySimple(p.data,d),n,!0)}}),this.instances.forEach(p=>{if(!p.isInstanceRoot){let d=Po.filterOp(p.overrideData,r);if(d){let f;s===p.data&&r===d?f=o:f=bt.applySimple(p.data,d),p.updateByOp(d,f,n,!0)}}})}}updateByPatchedOpBase(r,o,n){if(this.dataPatched=o,r.path.length===0&&r.type===0)r.props.type!==void 0&&!oo.is(r.props.type)&&so.changeEntityProptotype(this,o,n);else if(r.path.length===1&&r.path[0]==="geometry"&&r.type===0&&"type"in r.props){so.changeEntityProptotype(this,o,n);for(let a of this.children)ze.is(a)&&a.updateVisible(n.scene)}this.updateByPatchedOp(r,o,n)}updateByPatchedOp(r,o,n){if(r.path.length===0&&r.type===0?this.updateState(r.props,n):r.type===0&&("resolutionLevel"in r.props||"useChildrenColors"in r.props)&&this.updateState(o,n),r.path[0]==="morphTargetInfluences"&&r.type===0){let s=o.morphTargetInfluences.get(r.path[1])?.data.name;s&&this.updateMorphInfluences(s,n.shared.getVariable(r.props.value,[this.uuid,"morphTargetInfluences",s]))}if(je(r.path,["pathSnapping"])!==null&&this.updatePathSnapping(o.pathSnapping),je(r.path,["cloner"])!==null){let a=bt.drop(r,1);a.path.length===0&&a.type===0&&a.props.disabled===!0?this.setFromClonerState(null,n):this.cloner?this.cloner.updateState(o.cloner,n.scene):(this.setFromClonerState(o.cloner,n),this.expandCloner(n.scene)),this.updateVisible(n.scene)}}updatePathSnapping(r=this.dataPatched.pathSnapping){this._updatedPathSnapping=r,this._needApplyPathSnapping=!0}get updatedPathSnapping(){return this._updatedPathSnapping}applyPathSnapping(r){let o=this._updatedPathSnapping?.pathId??this.dataPatched.pathSnapping.pathId,n=this._updatedPathSnapping?.slide??this.dataPatched.pathSnapping.slide??0,a=this._updatedPathSnapping?.offset??this.dataPatched.pathSnapping.offset??0,s=this._updatedPathSnapping?.orientation??this.dataPatched.pathSnapping.orientation;if(o===null)return;let l=r.find(o);if(!l||this._needApplyPathSnapping===!1)return;this._needApplyPathSnapping=!1;let c=l.data;if(c.geometry.path.points.length<=1)return;let u=Vu(c.geometry.path),p=(n+a)%1;n+a===1&&p===0&&(p=1);let d=null;try{d=u.curves.length?u.getPointAt(p):null}catch(y){!1&&(console.warn(`The aligned path on ${this.name} is invalid. (${l.name})`),console.error(y))}if(d===null)return;let f=this.parent?this.parent?.matrixWorld:new ur.Matrix4;l.updateMatrixWorld();let h=new ur.Matrix4().multiplyMatrices(f.clone().invert(),l.matrixWorld);d.applyMatrix4(h);let m={position:d.toArray(),rotation:c.rotation};if(s==="tangential"){let y=new ur.Matrix4().extractRotation(l.matrixWorld),b=u.getTangentAt(p).applyMatrix4(y).add(d),v=new ur.Matrix4().lookAt(d,b,IM),w=gf.setFromEuler(new ur.Euler().setFromRotationMatrix(v)).multiplyScalar(ur.MathUtils.RAD2DEG);m={...m,rotation:w.toArray()}}this.updateTransformState(m),this.traverseEntity(y=>{y._cameraType&&y.dispatchEvent(AM)})}updateVisible(r){if(this.visible=this.dataPatched.visible&&(!this.dataPatched.cloner||(this.dataPatched.cloner.disabled??!1)||this.dataPatched.cloner?.hideBase!==!0),!r)return;let o=!1;this.traverseEntity(n=>{if(n.data.type==="Splat")return o=!0,!0}),o&&r.reloadSplats()}updateState_Entity(r,o){r.name!==void 0&&(this.name=r.name),r.raycastLock!==void 0&&(this.raycastLock=r.raycastLock),r.visible!==void 0&&(this.updateVisible(o?.scene),this.resetBBoxNeedsUpdate()),o&&"cloner"in r&&r.cloner!==void 0&&(this.setFromClonerState(r.cloner,o),this.updateVisible(o.scene)),this.updateTransformState(r,o)}get attachedSurfaceCloners(){return this.children.filter(r=>r instanceof so.Cloner&&r.parameters.type==="toObject")}setFromClonerState(r,o){this.disposed||(r===null||r.disabled?(this.cloner&&this.cloner.removeFromParent(),this.cloner=void 0):this.cloner===void 0?(this.cloner=new so.Cloner(this,r),o.scene.addPendingExpandCloner(this)):this.cloner.updateState(r,o.scene))}expandCloner(r){!this.disposed&&this.cloner&&this.cloner.expandClones(r)}invalidateClonerTransform(r){this.cloner&&this.cloner.invalidateTransform(r)}requestRender(){this.dispatchEvent({type:"requestRender"})}};var Gi=require("three");var st=require("three"),ux=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=i.parameters?.radiusTop,r=i.parameters?.radiusBottom,o=Object.assign({},t?.parameters??{width:100,radialSegments:64,heightSegments:1,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadius:8,cornerSegments:8,hollow:0},i.parameters);o.thetaLength=st.MathUtils.clamp(o.thetaLength,0,360);let n=o.width/2,a=o.radiusTop??n,s=o.radiusBottom??n;if(a===s?(a=n,s=n):a>s?(a=n,s=s*n/a):(a=a*n/s,s=n),o.shapeBlendNode){a=e??n,s=r??n;let l=Math.max(a,s)*2;o.width=l,o.depth=l}return{parameters:Object.assign(o,{width:Math.abs(o.width),height:Math.abs(o.height??o.width),depth:Math.abs(o.depth??o.width),radiusTop:a,radiusBottom:s})}}static build(i){let{width:t,depth:e,height:r,radialSegments:o,heightSegments:n,openEnded:a,thetaStart:s,thetaLength:l,radiusTop:c,radiusBottom:u,cornerRadius:p,cornerSegments:d,hollow:f}=i.parameters,h;return l===0?(h=new st.BufferGeometry,h.setAttribute("position",new st.Float32BufferAttribute([],3))):p||f?h=new Sl(c,u,r,o,n,a,s,l*Math.PI/180,p,p,d,f):h=new st.CylinderGeometry(c,u,r,o,n,a,s,l*Math.PI/180),h.scale(1,1,e/t),Object.assign(h,{userData:{...i,type:"CylinderGeometry"}})}};function zi(i,t,e){e.x=i.x*t.x,e.y=i.y,e.z=i.x*t.y}function cx(i){return new st.Vector2(i.y,-i.x)}var Sl=class extends st.BufferGeometry{constructor(t,e,r,o,n,a,s,l,c,u,p,d,f=!1){super(),this.type="RoundedCylinderBufferGeometry",t=t!==void 0?t:1,e=e!==void 0?e:1,r=r||1,o=Math.floor(o)||8,n=Math.floor(n)||1,a=a!==void 0?a:!1,s=s!==void 0?s:0,l=l!==void 0?l:Math.PI*2,a&&(c=0,u=0);let h=[],m=[],y=[],b=[],v=0,w=r/2,O=new st.Vector3,S=new st.Vector3;f&&t==0&&(t=c),f&&e==0&&(e=u);let T=new st.Vector2(t,w),M=new st.Vector2(e,-w),g=null,D=null,E=null,I=null,N=T.clone().sub(M),_=0,R=0,V=0;d>0&&(_=Math.min(t,e)*(1-d),R=t-_,V=e-_);let U=T.clone();U.x-=_;let B=Math.PI-N.angle(),q=N.angle(),j=Math.tan(q/2),F=Math.tan(B/2),H=j+F,W=d?H:F,ee=d?H:j;if(c=Math.min(c,(t-R)/W,N.length()/H),u=Math.min(u,(e-V)/ee,N.length()/H),c>0){let Q=c/j;g=T.clone().sub(new st.Vector2(Q,c)),d&&(E=g.clone(),E.x-=_-H*c),T.sub(N.clone().setLength(Q))}if(u>0){let Q=u/F;D=M.clone().sub(new st.Vector2(Q,-u)),M.add(N.clone().setLength(Q)),d&&(I=D.clone(),I.x-=_-H*u,U.sub(N.clone().setLength(Q)))}N=T.clone().sub(M);let te=N.length()<.5,Y=[];for(let Q=0;Q<=o;Q++){let $=[],pe=Q/o,le=pe*l+s,ie=new st.Vector2(Math.sin(le),Math.cos(le));I&&D?(re($,pe,ie,B,u,I,-1,!0),re($,pe,ie,q,u,D,-1,!1)):D?(K($,ie,D.x,0,-1),re($,pe,ie,q,u,D,-1,!1)):a||K($,ie,e,V,-1);let ue=cx(N).normalize();if(zi(ue,ie,O),!te)for(let ae=0;ae<=n;ae++){let ge=ae/n,me=N.clone().multiplyScalar(ge).add(M);zi(me,ie,S),m.push(S.x,S.y,S.z),y.push(O.x,O.y,O.z),b.push(pe,.5+S.y/r),$.push(v++)}if(E&&g?(re($,pe,ie,B,c,g,1,!1),re($,pe,ie,q,c,E,1,!0)):g?(re($,pe,ie,B,c,g,1,!1),K($,ie,g.x,0,1)):a||K($,ie,t,R,1),d&&!te){let ae=cx(N).multiplyScalar(-1).normalize();zi(ae,ie,O);for(let ge=0;ge<=n;ge++){let me=ge/n,ye=N.clone().multiplyScalar(-me).add(U);zi(ye,ie,S),m.push(S.x,S.y,S.z),y.push(O.x,O.y,O.z),b.push(pe,.5+S.y/r),$.push(v++)}}d&&!a&&$.push($[0]),Y.push($)}for(let Q=0;Q<Y.length-1;Q++)for(let $=0;$<Y[0].length-1;$++){if(a&&d&&$==n)continue;let pe=Y[Q][$],le=Y[Q+1][$],ie=Y[Q+1][$+1],ue=Y[Q][$+1],ae=m[ie*3+0],ge=m[ie*3+2];h.push(pe,le,ue),(ae!=0||ge!=0)&&h.push(le,ie,ue)}l<Math.PI*2&&(Z(-1,Y[0],s),Z(1,Y[Y.length-1],s+l)),this.setIndex(h),this.setAttribute("position",new st.Float32BufferAttribute(m,3)),this.setAttribute("normal",new st.Float32BufferAttribute(y,3)),this.setAttribute("uv",new st.Float32BufferAttribute(b,2));function re(Q,$,pe,le,ie,ue,ae,ge){for(let me=0;me<p+1;me++){let ye=me/p,ve=ae<0?ye:1-ye;ge&&(ve-=1),ve*=le;let xe=new st.Vector2(Math.sin(ve),Math.cos(ve)*ae),C=xe.clone().multiplyScalar(ie).add(ue);zi(C,pe,S),m.push(S.x,S.y,S.z),zi(xe,pe,O),y.push(O.x,O.y,O.z),b.push($,.5+S.y/r),Q.push(v++)}}function K(Q,$,pe,le,ie){let ue=new st.Vector3,ae=new st.Vector2,ge=[pe,le];ie<0&&ge.reverse();for(let me of ge)ae.set(me,w*ie),zi(ae,$,ue),m.push(ue.x,ue.y,ue.z),y.push(0,ie,0),b.push(.5,.5),Q.push(v++)}function Z(Q,$,pe){let le=new st.Vector2(Math.sin(pe),Math.cos(pe)),ie=new st.Vector2(-Math.cos(pe),Math.sin(pe)),ue=new st.Vector3,ae=Q<0?(ye,ve,xe)=>h.push(ye,ve,xe):(ye,ve,xe)=>h.push(ye,xe,ve),ge=new st.Vector2((t+e+R+V)/4,0);zi(ge,le,ue),m.push(ue.x,ue.y,ue.z),y.push(ie.x,0,ie.y),b.push(.5,.5);let me=v++;for(let ye of $){let ve=m.slice(ye*3,ye*3+3);m.push(...ve),y.push(ie.x,0,ie.y);let xe=b.slice(ye*2,ye*2+2);b.push(...xe),v++}for(let ye=me+1;ye<v-1;ye++)ae(me,ye,ye+1);ae(me,v-1,me+1)}}};var dx=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,radialSegments:32,heightSegments:8,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadiusTop:8,cornerRadiusBottom:8,cornerSegments:8},i.parameters);return e.thetaLength=Gi.MathUtils.clamp(e.thetaLength,0,360),{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(i){let{width:t,depth:e,height:r,radialSegments:o,heightSegments:n,openEnded:a,thetaStart:s,thetaLength:l,cornerRadiusTop:c,cornerRadiusBottom:u,cornerSegments:p}=i.parameters,d;return l===0?(d=new Gi.BufferGeometry,d.setAttribute("position",new Gi.Float32BufferAttribute([],3))):c>0||u>0||l<360?d=new Sl(0,t/2,r,o,n,a,s,l*Math.PI/180,c,u,p,0,!0):d=new Gi.ConeGeometry(t/2,r,o,n,a),d.scale(1,1,e/t),Object.assign(d,{userData:{...i,type:"ConeGeometry"}})}};var Sr=require("three"),px=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,widthSegments:1,heightSegments:1,depthSegments:1,cornerRadius:8,cornerSegments:8},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(i){let{width:t,height:e,depth:r,widthSegments:o,heightSegments:n,depthSegments:a,cornerRadius:s,cornerSegments:l}=i.parameters,c;return s===0?c=new Sr.BoxGeometry(t,e,r,o,n,a):c=new bf(t,e,r,o,n,a,s,l),Object.assign(c,{userData:{...i,type:"CubeGeometry"}})}},xf=Math.PI/2,bf=class extends Sr.BufferGeometry{constructor(t=1,e=1,r=1,o=1,n=1,a=1,s=0,l=4){super(),this.type="BoxGeometry",o=Math.floor(o),n=Math.floor(n),a=Math.floor(a),l=Math.floor(l),s=Math.min(s,t/2,e/2,r/2);let c=[],u=[],p=[],d=[],f=0;h("z","y","x",-1,-1,r,e,t,a,n),h("z","y","x",1,-1,r,e,-t,a,n),h("x","z","y",1,1,t,r,e,o,a),h("x","z","y",1,-1,t,r,-e,o,a),h("x","y","z",1,-1,t,e,r,o,n),h("x","y","z",-1,-1,t,e,-r,o,n),s>0&&(m("z","y","x",-1,-1,1,r,e,t,a),m("z","y","x",1,-1,-1,r,e,t,a),m("z","y","x",-1,1,-1,r,e,t,a),m("z","y","x",1,1,1,r,e,t,a),m("x","y","z",-1,-1,-1,t,e,r,o),m("x","y","z",1,-1,1,t,e,r,o),m("x","y","z",-1,1,1,t,e,r,o),m("x","y","z",1,1,-1,t,e,r,o),m("y","x","z",-1,-1,1,e,t,r,n),m("y","x","z",1,-1,-1,e,t,r,n),m("y","x","z",1,1,1,e,t,r,n),m("y","x","z",-1,1,-1,e,t,r,n),y(1,1,1),y(-1,1,1),y(1,-1,1),y(-1,-1,1),y(1,1,-1),y(-1,1,-1),y(1,-1,-1),y(-1,-1,-1)),this.setIndex(c),this.setAttribute("position",new Sr.Float32BufferAttribute(u,3)),this.setAttribute("normal",new Sr.Float32BufferAttribute(p,3)),this.setAttribute("uv",new Sr.Float32BufferAttribute(d,2));function h(b,v,w,O,S,T,M,g,D,E){let I=(T-2*s)/D,N=(M-2*s)/E,_=T/2-s,R=M/2-s,V=g/2,U=D+1,B=E+1,q=0,j=new Sr.Vector3;for(let F=0;F<B;F++){let H=F*N-R;for(let W=0;W<U;W++){let ee=W*I-_;j[b]=ee*O,j[v]=H*S,j[w]=V,u.push(j.x,j.y,j.z),j[b]=0,j[v]=0,j[w]=g>0?1:-1,p.push(j.x,j.y,j.z),d.push(W/D),d.push(1-F/E),q+=1}}for(let F=0;F<E;F++)for(let H=0;H<D;H++){let W=f+H+U*F,ee=f+H+U*(F+1),te=f+(H+1)+U*(F+1),Y=f+(H+1)+U*F;c.push(W,ee,Y),c.push(ee,te,Y)}f+=q}function m(b,v,w,O,S,T,M,g,D,E){let I=(M-2*s)/E,N=M/2-s,_=g/2-s,R=D/2,V=E+1,U=0,B=new Sr.Vector3,q=new Sr.Vector3;for(let j=0;j<l+1;j++){let F=j/l*xf,H=Math.sin(F)*s,W=(1-Math.cos(F))*s,ee=Math.sin(F),te=Math.cos(F);B[v]=(_+H)*S,B[w]=(R-W)*T,q[b]=0,q[v]=ee*Math.sign(B[v]),q[w]=te*Math.sign(B[w]);for(let Y=0;Y<V;Y++){let re=Y*I-N;B[b]=re*O,u.push(B.x,B.y,B.z),p.push(q.x,q.y,q.z),d.push(Y/E),d.push(0),U+=1}}for(let j=0;j<l;j++)for(let F=0;F<E;F++){let H=f+F+V*j,W=f+F+V*(j+1),ee=f+(F+1)+V*(j+1),te=f+(F+1)+V*j;c.push(H,W,te),c.push(W,ee,te)}f+=U}function y(b,v,w){let O=new Sr.Vector3,S=new Sr.Vector3(t/2,e/2,r/2);S.subScalar(s);let T=[],M=b*v*w>0?(D,E,I)=>c.push(D,E,I):(D,E,I)=>c.push(D,I,E);for(let D=0;D<=l;D++){let E=[],I=xf*(1-D/l),N=Math.cos(I),_=Math.sin(I),R=0;for(let V=0;V<=D;V++){let U=Math.cos(R),B=Math.sin(R);O.x=N*U,O.y=_,O.z=N*B;let q=S.clone().addScaledVector(O,s);u.push(b*q.x,v*q.y,w*q.z),p.push(b*O.x,v*O.y,w*O.z),d.push(0,0),E.push(f++),R+=xf/D}T.push(E)}let g=T.length-1;for(let D=0;D<g;D++){let E=T[D],I=T[D+1],N=E.length-1;M(E[0],I[1],I[0]);for(let _=1;_<=N;_++)M(E[_-1],E[_],I[_]),M(E[_],I[_+1],I[_])}}}};var Et=require("three"),Fi=class extends Et.BufferGeometry{constructor(t=[],e=[],r="",o=1,n=.2,a=4){super(),this.type="PolyhedronGeometryRound";let s=[],l=[],c=[];u(),p(),this.setAttribute("position",new Et.Float32BufferAttribute(s,3)),this.setAttribute("normal",new Et.Float32BufferAttribute(c,3)),this.setAttribute("uv",new Et.Float32BufferAttribute(l,2));return;function u(){n=Math.min(1-1e-5,n),n==0&&(a=0);let f={IcosahedronGeometry:5,DodecahedronGeometry:3,HexahedronGeometry:3,OctahedronGeometry:4,TetrahedronGeometry:3}[r],h=new Et.Vector3,m=h.clone(),y=new Et.Triangle,b=n*o,v=o-b,w=a+1,O=new Et.Vector3,S=(j,F)=>O.subVectors(j,F).normalize(),T=(j,F)=>Array(j).fill(void 0).map(F),M=T(t.length/3,(j,F)=>new Et.Vector3().fromArray(t,F*3).setLength(o)),g=[],D=1e6;for(let j=0;j<M.length;j++){let F=M[j],H=[],W,ee,te,Y=1e10,re=-1;for(;(re=e.indexOf(j,re+1))!=-1;){let $=re-re%3;W=e[$+(re+1)%3],ee=e[$+(re+2)%3],te=F.distanceToSquared(M[W]),Y=Math.min(Y,te),H.push([W,ee,te])}Y+=1e-6;let K=[],Z=0,Q=H.length;for(let $=0;$<Q;$++){[W,ee,te]=H[Z];let pe=g[W]?.includes(j)==!0;te<=Y&&K.push(W+ +pe*D),Z=H.findIndex(le=>le[0]==ee)}g.push(K)}let E=[];{let j=0,F=0,H,W,ee=f==3;for(let te=0;te<=a;te++){H=te*(te+1)/2,W=(te+1)*(te+2)/2;for(let Y=0;Y<a-te;Y++)[j,F]=[H+Y+te+2,W+Y+te+3],E.push(H,W,...ee?[F,H]:[j,W],F,j),[H,W]=[j,F];E.push(H,W,H+a+2)}}let I=h.clone(),N=h.clone(),_=h.clone(),R=h.clone(),V=h.clone(),U=[],B=T(M.length,()=>T(f,()=>h.clone()));for(let j=0;j<M.length;j++){h.copy(M[j]).normalize(),I.copy(h).multiplyScalar(v);let F=g[j];for(let K=0;K<F.length;K++){let Z=F[K],Q=F[(K+1)%f];y.setFromPointsAndIndices(M,j,Z%D,Q%D),y.b.sub(y.a).setLength(1e10).add(y.a),y.c.sub(y.a).setLength(1e10).add(y.a),y.closestPointToPoint(I,B[j][K])}let H=[],W=[],ee=[],te=new Et.Vector3;a==0&&[...B[j]].reduce((K,Z)=>K.add(Z),te).multiplyScalar(1/f);for(let K=0;K<f;K++){let Z=[],Q=(K-1+f)%f,$=B[j][Q],pe=B[j][K];h.copy($).sub(I),m.copy(pe).sub(I);let le=I.angleTo(h),ie=h.angleTo(m),ue=Math.cos(le)*b;a==0?N.copy(te):N.copy(I).setLength(v+ue),W.push(ue);let ae=[N,$,pe];for(let ge=0;ge<2;ge++){let me=ae[ge],ye=ae[ge+1];R.subVectors(me,I),V.subVectors(ye,I),_.crossVectors(R,V).normalize();for(let ve=0;ve<w;ve++){let xe=[le,ie][ge]*ve/w;h.copy(R).applyAxisAngle(_,xe).add(I),H.push(h.clone()),ge&&(S(h,I),Z.push([ve==0?me:h.clone(),O.clone()]))}ge&&(S(ye,I),Z.push([ye,O.clone()]))}ee.push(Z)}U.push(ee);let Y=2*w,re=2;for(let K=0;K<f;K++){let Z=Y*K,Q=Y*((K+1)%f),$=[H[Z]];for(let le=1;le<w;le++){R=H[Z+le],V=H[Q+le],$.push(R);for(let ie=1,ue=le-re+1;ie<=ue;ie++)h.lerpVectors(R,V,ie/(ue+1)),h.sub(I).setLength(W[K]).add(I),$.push(h.clone());$.push(V)}for(let le=0;le<w;le++)$.push(H[le+w+Z]);$.push(H[Q+w]);let pe=E.map(le=>$[le]);s.push(...pe.map(le=>[le.x,le.y,le.z]).flat()),c.push(...pe.map(le=>(S(le,I),[O.x,O.y,O.z])).flat())}}let q=[];for(let j=0;j<g.length;j++)for(let F=0;F<f;F++){let H=g[j][F];if(H<D){let W=g[H].findIndex(Y=>Y%D==j),ee=U[j][F],te=U[H][W];for(let Y=0;Y<w;Y++){let re=ee[Y],K=te[w-Y],Z=ee[Y+1],Q=te[w-(Y+1)];[re,K,Z,Z,K,Q].forEach($=>{s.push($[0].x,$[0].y,$[0].z),c.push($[1].x,$[1].y,$[1].z)})}q.push(ee[0][0],te[w][0],ee[w][0],te[0][0])}}for(;q.length;){let j,F,H,W;[j,F]=q.splice(0,2);let ee=[j];for(;j!=F;)ee.push(F),H=q.indexOf(F),W=H%2,F=q.splice(H-W,2)[1-W];O.subVectors(ee[0],ee[1]).cross(h.subVectors(ee[0],ee[2])).normalize();let te=O.dot(ee[0])<0;te&&O.negate();for(let Y=1;Y<=ee.length-2;Y++)[ee[Y+ +te],ee[Y+1-+te],ee[0]].forEach(re=>{s.push(re.x,re.y,re.z),c.push(O.x,O.y,O.z)})}}function p(){let d=new Et.Vector3;for(let M=0;M<s.length;M+=3){d.x=s[M+0],d.y=s[M+1],d.z=s[M+2];let g=S(d)/2/Math.PI+.5,D=T(d)/Math.PI+.5;l.push(g,1-D)}let f=new Et.Vector3,h=new Et.Vector3,m=new Et.Vector3,y=new Et.Vector3,b=new Et.Vector2,v=new Et.Vector2,w=new Et.Vector2,O=(M,g,D,E)=>{E<0&&M.x===1&&(l[g]=M.x-1),D.x===0&&D.z===0&&(l[g]=E/2/Math.PI+.5)};for(let M=0,g=0;M<s.length;M+=9,g+=6){f.set(s[M+0],s[M+1],s[M+2]),h.set(s[M+3],s[M+4],s[M+5]),m.set(s[M+6],s[M+7],s[M+8]),b.set(l[g+0],l[g+1]),v.set(l[g+2],l[g+3]),w.set(l[g+4],l[g+5]),y.copy(f).add(h).add(m).divideScalar(3);let D=S(y);O(b,g+0,f,D),O(v,g+2,h,D),O(w,g+4,m,D)}for(let M=0;M<l.length;M+=6){let g=l[M+0],D=l[M+2],E=l[M+4],I=Math.max(g,D,E),N=Math.min(g,D,E);I>.9&&N<.1&&(g<.2&&(l[M+0]+=1),D<.2&&(l[M+2]+=1),E<.2&&(l[M+4]+=1))}function S(M){return Math.atan2(M.z,-M.x)}function T(M){return Math.atan2(-M.y,Math.sqrt(M.x*M.x+M.z*M.z))}}}static fromJSON(t){return new Fi(t.vertices,t.indices,t.radius,t.corner,t.cornerSides)}};var fx=require("three"),hx=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,detail:0,corner:0,cornerSides:4},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(i){let{width:t,height:e,depth:r,detail:o,corner:n,cornerSides:a}=i.parameters,s=o===0&&n!==0?new wl(t*.5,n,a):new fx.DodecahedronGeometry(t*.5,o);return s.scale(1,e/t,r/t),Object.assign(s,{userData:{...i,type:"DodecahedronGeometry"}})}},wl=class extends Fi{constructor(t=1,e=.2,r=4){let o=(1+Math.sqrt(5))/2,n=1/o,a=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-n,-o,0,-n,o,0,n,-o,0,n,o,-n,-o,0,-n,o,0,n,-o,0,n,o,0,-o,0,-n,o,0,-n,-o,0,n,o,0,n],s=[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(a,s,l,t,e,r),this.type=l}static fromJSON(t){return new wl(t.radius,t.corner,t.cornerSides)}};var Ye=require("three");var Ne=require("three"),Pl=1e-12,Ua=class{constructor(t){this.position=new Ne.Vector2;this.startPosition=new Ne.Vector2;this.uuid=Ne.MathUtils.generateUUID();this.position=t.clone()}start(){this.reset()}reset(){this.startPosition.copy(this.position)}applyOffset(t){this.position.copy(this.startPosition).add(t)}copy(t){return this.position.copy(t.position),this.startPosition.copy(t.startPosition),this}clone(){return new Ua(this.position).copy(this)}toJSON(){return[this.position.x,this.position.y]}},ka=class extends Ua{constructor(e){super(e.position);this.parent=e}copy(e){return super.copy(e),this}clone(){return new ka(this.parent).copy(this)}},lo=class extends Ua{constructor(e,r){super(r);this.controls=[];this.roundness=0;this.areControlsDirectionsMirrored=!0;this.uuid=e,this.controls.push(new ka(this),new ka(this))}static create(e,r){let o=new lo(e,new Ne.Vector2(...r.position));return o.controls[0].position.set(...r.controlPrevious.position),o.controls[1].position.set(...r.controlNext.position),o.roundness=r.roundness,o.areControlsDirectionsMirrored=r.areControlsDirectionsMirrored,o}getOppositeControl(e){let r=this.controls.indexOf(e);return r===0?this.controls[1]:r===1?this.controls[0]:null}applyOffsetToControls(e,r=1){for(let o=0,n=this.controls.length;o<n;o++){let a=this.controls[o];this.position.distanceTo(a.position)<=r?a.position.copy(this.position):a.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 lo(this.uuid,this.position).copy(this)}toJSON(){return super.toJSON().concat(this.controls[0].toJSON(),this.controls[1].toJSON(),[this.roundness])}computeTangents(){let e=this.curveBefore?.getTangentAt(1),r=this.curveAfter?.getTangentAt(0);return[e,r]}computeNormals(e=new Ne.Vector2,r=new Ne.Vector2){let[o,n]=this.computeTangents();return o&&n&&(mx(o,e),mx(n,r)),[e,r]}computeTangent(e=new Ne.Vector2){let[r,o]=this.computeTangents();return r&&o&&e.copy(r).add(o).normalize(),e}computeNormal(e=new Ne.Vector2){let[r,o]=this.computeNormals();return e.copy(r).add(o).normalize(),e}};function mx(i,t=new Ne.Vector2){let e=i.length();return t.set(-i.y/e,i.x/e)}var Sf=i=>i,Ha=new Ne.Vector2,zu=new Ne.Vector2,EM=new Ne.Vector2,NM=new Ne.Vector2,DM=new Ne.Vector2,_M=new Ne.Vector2,gx=new Ne.Vector3,xx=new Ne.Vector3;function bx(i){let t=new Ne.Vector2;t.addVectors(i.v0,Ha.subVectors(i.v1,i.v0).multiplyScalar(2/3));let e=new Ne.Vector2;return e.addVectors(i.v2,zu.subVectors(i.v1,i.v2).multiplyScalar(2/3)),new Ne.CubicBezierCurve(i.v0,t,e,i.v2)}function Ol(i,t,e=Number.EPSILON){return Math.abs(i-t)<e}function RM(i,t,e=Number.EPSILON){return i.distanceTo(t)<e}function LM(i,t,e=Number.EPSILON){return i.distanceTo(t)<e}function wf(i,t,e){let r=Math.sqrt(Math.pow(t.x-i.x,2)+Math.pow(t.y-i.y,2)),o=Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2)),n=Math.sqrt(Math.pow(e.x-i.x,2)+Math.pow(e.y-i.y,2));return Math.acos((o*o+r*r-n*n)/(2*o*r))}function vx(i,t,e){return yx(i,t)&&yx(t,e)&&vf(i.position,t.position,e.position)}function vf(i,t,e){return Ha.copy(t).sub(i).cross(zu.copy(e).sub(i))===0}function Sx(i,t,e,r,o){let n=Math.sqrt(Math.pow(t.x-i.x,2)+Math.pow(t.y-i.y,2)),a=(i.y+t.y)/2,s=(i.x+t.x)/2,l=Math.sqrt(Math.pow(e,2)-Math.pow(n/2,2))*(i.y-t.y)/n,c=Math.sqrt(Math.pow(e,2)-Math.pow(n/2,2))*(t.x-i.x)/n;return r.set(s+l,a+c),o.set(s-l,a-c),[r,o]}function wx(i,t,e){let r=i.distanceTo(e),o=t.distanceTo(e);return r<o?t:i}function Px(i,t,e,r,o,n){let a=t.x-i.x,s=t.y-i.y,l=e.x-i.x,c=e.y-i.y,u=Math.sqrt((a+l)*(a+l)+(s+c)*(s+c)),p;return wf(t,i,e)>Math.PI&&(u*=-1),Ol(c,s)?p=(s+c)*(r/u-.5)*8/3/(a-l):p=(a+l)*(r/u-.5)*8/3/(c-s),o.set(t.x-p*s,t.y+p*a),n.set(e.x+p*c,e.y-p*l),[o,n]}function Pf(i,t){return i.position.equals(i.controls[1].position)&&t.position.equals(t.controls[0].position)}function yx(i,t){return vf(i.position,i.controls[1].position,t.position)&&vf(i.position,t.controls[0].position,t.position)}function Ox(i,t,e,r,o=.5){let n=Ha.subVectors(t,i).multiplyScalar(o).add(i),a=zu.subVectors(e,t).multiplyScalar(o).add(t),s=EM.subVectors(r,e).multiplyScalar(o).add(e),l=n,c=NM.subVectors(a,n).multiplyScalar(o).add(n),u=DM.subVectors(s,a).multiplyScalar(o).add(a),p=s,d=_M.subVectors(u,c).multiplyScalar(o).add(c);return[i.x,i.y,l.x,l.y,c.x,c.y,d.x,d.y,u.x,u.y,p.x,p.y,r.x,r.y]}function Tx(i,t,e=12,r=!0){let o=xx.set(0,0,0),n,a=0,s=[];for(let l=0;l<t.length;l++){let c=Sf(t[l]),u=Ha,p=ji(c,e);s.push(p);for(let d=0;d<=p;d++)if(c instanceof Ne.CubicBezierCurve||c instanceof Ne.QuadraticBezierCurve||c instanceof Ne.LineCurve){if(c.getPoint(d/p,u),o.set(u.x,u.y,0),n!==void 0&&LM(n,o))continue;n===void 0&&(n=gx),n.copy(o),i.setXYZ(a,o.x,o.y,o.z),a++}}return r&&a>1&&!(i.getX(a-1)===i.getX(0)&&i.getY(a-1)===i.getY(0)&&i.getZ(a-1)===i.getZ(0))&&(i.setXYZ(a,i.getX(0),i.getY(0),i.getZ(0)),a++),i}function Cx(i,t,e,r=12,o=!0){let n=xx.set(0,0,0),a=0,s=[];for(let l=0;l<t.length;l++){if(e[l]===!1)continue;let c,u=Sf(t[l]),p=Ha,d=ji(u,r);s.push(d);for(let f=0;f<=d;f++)if(u instanceof Ne.CubicBezierCurve||u instanceof Ne.QuadraticBezierCurve||u instanceof Ne.LineCurve){if(u.getPoint(f/d,p),n.set(p.x,p.y,0),c?.equals(n))continue;c===void 0?c=gx:(i.setXYZ(a,c.x,c.y,c.z),a++,i.setXYZ(a,n.x,n.y,n.z),a++),c.copy(n)}}return o&&a>1&&!(i.getX(a-1)===i.getX(0)&&i.getY(a-1)===i.getY(0)&&i.getZ(a-1)===i.getZ(0))&&(i.setXYZ(a,i.getX(0),i.getY(0),i.getZ(0)),a++),s}function Of(i,t=12,e=!1){let r=[];for(let o=0,n=i.length;o<n;o++){let a=i[o],s=0;if(e&&a.roundedCurveCorner!==void 0){let l=ji(a.roundedCurveCorner,t)*.5;o>0&&(r[o-1]+=l),s+=l}a.curveAfter!==void 0&&(s+=ji(a.curveAfter,t)),r.push(s)}return i.length>0&&e&&i[0].roundedCurveCorner!==void 0&&(r[i.length-1]+=ji(i[0].roundedCurveCorner,t)*.5),r}function ji(i,t=12){return i&&i instanceof Ne.EllipseCurve?t*2:i&&(i instanceof Ne.LineCurve||i instanceof Ne.LineCurve3)?1:i&&i instanceof Ne.SplineCurve?t*i.points.length:t}function Ax(i,t,e=12,r=!0){let o,n=0;for(let a=0;a<t.length;a++){let s=Sf(t[a]),l=ji(s,e),c=Ha;for(let u=0;u<=l;u++)if(s instanceof Ne.CubicBezierCurve||s instanceof Ne.QuadraticBezierCurve||s instanceof Ne.LineCurve){if(s.getPoint(u/l,c),o!==void 0&&RM(o,c,Pl))continue;o===void 0&&(o=zu),o.copy(c),i.push(c.x,c.y),n++}}return Ol(i[0],i[i.length-2],Pl)&&Ol(i[1],i[i.length-1],Pl)&&(i.pop(),i.pop()),r&&n>1&&!(Ol(i[n-1],i[1],Pl)&&Ol(i[n-2],i[0],Pl))&&(i.push(i[0],i[1]),n++),i}var Tf=new Ye.Vector2,BM=new Ye.Vector2,VM=new Ye.Vector2,zM=new Ye.Vector2,GM=new Ye.Vector2,FM=new Ye.Vector2,Xe=class extends Ye.Shape{constructor(e=100,r=100){super();this.points=[];this.shapeHoles=[];this.plane=new Ye.Plane(new Ye.Vector3(0,0,-1));this.subdivision=0;this.controlSnapDistance=4;this.pointIDs=0;this.isMesh2D=!1;this.isText=!1;this._roundness=0;this.isClosed=!1;this.useCubicForRoundedCorners=!0;this.uuid=Ye.MathUtils.generateUUID();this.needsUpdate=!1;this.roundedCurves=[];this._width=e,this._height=r}static createFromState(e,r,o){let n=new Xe;return n.isClosed=e.isClosed,n.points=e.points.map(a=>lo.create(a.id,a.data)),typeof e.roundness=="number"&&(n.roundness=e.roundness),n.shapeHoles=e.shapeHoles.map(a=>Xe.createFromState(a)),r!==void 0&&o!==void 0&&n.applySize(r,o),n.update(),n}get width(){return this._width}get height(){return this._height}get roundness(){return this._roundness}set roundness(e){if(this._roundness!==e){this._roundness=e;for(let r=0,o=this.points.length;r<o;r++)this.points[r].roundness=e;this.needsUpdate=!0}}getPointsIndexesByIds(e){return e.map(r=>this.getPointIndexById(r)).filter(r=>r>=0)}getPointIndexById(e){let r=this.points.length,o=this.points.findIndex(n=>n.uuid===e);if(o<0){let n=r;for(let a=0,s=this.shapeHoles.length;a<s;a++){let l=this.shapeHoles[a],c=l.points.length,u=l.getPointIndexById(e);if(u<0)n+=c;else return u+n}}return o}getLineIndexById(e){return this.getPointIndexById(e)}getBezierPoint(e){if(e<=this.points.length-1)return this.points[e];if(this.shapeHoles.length>0){let r=this.points.length;for(let o=0,n=this.shapeHoles.length;o<n;o++){let a=this.shapeHoles[o],s=e-r;if(s<=a.points.length-1)return a.points[s];r+=a.points.length}}throw new Error("This shape does not have a point for this index: "+e)}getBezierPointIndex(e){let r=this.points.indexOf(e);if(r>=0)return r;if(r=this.points.length,this.shapeHoles.length>0)for(let o=0,n=this.shapeHoles.length;o<n;o++){let a=this.shapeHoles[o],s=a.points.indexOf(e);if(s>=0)return r+s;r+=a.points.length}return-1}getAllPoints(){let e=[].concat(...this.shapeHoles.map(r=>r.points));return[...this.points,...e]}applySize(e,r){e===0&&(e=.001),r===0&&(r=.001),this._width=e,this._height=r}applyScale(e,r){let o=Tf.set(e,r);for(let n=0,a=this.points.length;n<a;n++){let s=this.points[n];s.position.multiply(o),s.controls[0].position.multiply(o),s.controls[1].position.multiply(o)}for(let n=0,a=this.shapeHoles.length;n<a;n++)this.shapeHoles[n].applyScale(e,r);this._update()}createPoint(e,r=0,o=Ye.MathUtils.generateUUID()){let n;e instanceof Ye.Vector2?n=e:n=new Ye.Vector2(e,r);let a=new lo(o,n);return a.roundness=this.roundness,a}addPoint(e){this.points.push(e),this.needsUpdate=!0}addPointAt(e,r){this.points.splice(r,0,e),this.needsUpdate=!0}getPointByUuid(e){for(let r=0,o=this.points.length;r<o;r++){let n=this.points[r];if(n.uuid===e)return n}for(let r=0,o=this.shapeHoles.length;r<o;r++){let a=this.shapeHoles[r].getPointByUuid(e);if(a)return a}}getFirstPoint(){return this.points[0]}getLastPoint(){return this.points[this.points.length-1]}removePoint(e){let r=this.points.indexOf(e);r>=0&&this.points.splice(r,1),this.needsUpdate=!0}removePointById(e){let r=this.points.find(o=>o.uuid===e);r&&this.removePoint(r)}update(){for(let e=0,r=this.shapeHoles.length;e<r;e++)this.shapeHoles[e].update();this._update()}extractShapePointsToBuffer(e,r=12,o=!1){this.subdivision=r,this.curveDivisions===void 0&&this.computeCurveDivisions(r);let n=o?this.roundedCurveDivisions:this.curveDivisions;return Tx(e,o?this.roundedCurves:this.curves,r,this.autoClose),n.reduce((a,s)=>a+s,0)+1}computeCurveDivisions(e=12){return this.curveDivisions=Of(this.points,e,!1),this.roundedCurveDivisions=Of(this.points,e,!0),this.curveDivisions}extractFilteredShapePointsToBuffer(e,r,o=12){return Cx(e,this.curves,r,o,this.autoClose).reduce((a,s)=>a+s,0)*2}extractShapePointsToFlatArray(e,r=12){return this.subdivision=r,this.curveDivisions===void 0&&this.computeCurveDivisions(r),Ax(e,this.roundedCurves,r,this.autoClose)}getCurveIndexFromVertexId(e,r=!1){let o=0;this.curveDivisions===void 0&&this.computeCurveDivisions(this.subdivision);let n=r?this.roundedCurveDivisions:this.curveDivisions,a=0;r&&this.points[0].roundedCurveCorner!==void 0&&(a=ji(this.points[0].roundedCurveCorner,this.subdivision)*.5);let s=e-a;s<0&&(s+=n.reduce((l,c)=>l+c,0));for(let l=0,c=n.length;l<c;l++){let u=n[l];if(s<o+u)return[l,(s-o+1)/u];o+=u}return[0,1]}getCurveT(e,r,o){let n=this.points[e],a=this.points[e>=this.points.length-1?0:e+1],s=this.curveDivisions,l=s[e];if(Pf(n,a)){let p=n.position.distanceTo(a.position);return n.position.distanceTo(Tf.set(o.x,o.y))/p}let c=0;for(let p=0;p<e;p++)c+=s[p];return(r-c)/l}dispose(){}_applyCurveForPoint(e,r){Pf(r,e)?this.lineTo(e.position.x,e.position.y):this.bezierCurveTo(r.controls[1].position.x,r.controls[1].position.y,e.controls[0].position.x,e.controls[0].position.y,e.position.x,e.position.y);let o=this.curves[this.curves.length-1];e.curveBefore=o,r.curveAfter=o;let n=o.clone();e.roundedCurveBefore=n,r.roundedCurveAfter=n,e.roundedCurveCorner=void 0,this.roundedCurves.push(n)}_update(){if(this.curves=[],this.roundedCurves=[],!this.points.length)return;for(let r=0,o=this.points.length;r<o;r++){let n=this.points[r];if(r===0)this.moveTo(n.position.x,n.position.y);else{let a=this.points[r-1];this._applyCurveForPoint(n,a)}}let e=this.getLastPoint();if(e?.curveAfter&&(e.curveAfter=void 0),this.isClosed){let r=this.points[0],o=this.points[this.points.length-1];this._applyCurveForPoint(r,o)}if(this.points.length>2){let r=0;for(let o=0,n=this.points.length;o<n;o++){let a=this.points[o],s=this.points[o-1]??this.points[this.points.length-1],l=this.points[o+1]??this.points[0],c=a.roundness,u=s&&l&&vx(s,a,l);if(!a.controlsMoved()&&c>0&&!u){let p=a.curveBefore,d=a.curveAfter;if(p===void 0||d===void 0)continue;let f=a.roundedCurveBefore,h=a.roundedCurveAfter,m=p.getLength(),y=d.getLength(),b=Math.min(c,m*.499),v=Math.min(c,y*.499),w=Math.min(b,v),O=1-w/m,S=w/y,T=p.getPointAt(O,Tf),M=d.getPointAt(S,BM);this._subSplitCurve(p,f,O,T,void 0),this._subSplitCurve(d,h,S,void 0,M);let g;if(this.useCubicForRoundedCorners){let D=wf(T,a.position,M)/2,E=Math.tan(D)*T.distanceTo(a.position),[I,N]=Sx(T,M,E,VM,zM),_=wx(I,N,a.position),[R,V]=Px(_,T,M,E,GM,FM);g=new Ye.CubicBezierCurve(T.clone(),R.clone(),V.clone(),M.clone())}else g=new Ye.QuadraticBezierCurve(T.clone(),a.position.clone(),M.clone());a.roundedCurveCorner=g,this.roundedCurves.splice(o+r,0,g),r++}}}}_subSplitCurve(e,r,o,n,a){if(e instanceof Ye.LineCurve)n!==void 0&&r.v2.copy(n),a!==void 0&&r.v1.copy(a);else{let s=e,l=r,c=s.getUtoTmapping(o,0),u=Ox(s.v0,s.v1,s.v2,s.v3,c);return n!==void 0&&(l.v0.set(u[0],u[1]),l.v1.set(u[2],u[3]),l.v2.set(u[4],u[5]),l.v3.set(u[6],u[7])),a!==void 0&&(l.v0.set(u[6],u[7]),l.v1.set(u[8],u[9]),l.v2.set(u[10],u[11]),l.v3.set(u[12],u[13])),l}return r}clone(){let e=new Xe(this._width,this._height);return e.points=this.points.map(r=>r.clone()),e.isClosed=this.isClosed,e.roundness=this.roundness,e.isMesh2D=this.isMesh2D,e.shapeHoles=this.shapeHoles.map(r=>r.clone()),e}toJSON(){return{points:this.points.reduce((e,r)=>e.concat(r.toJSON()),[]),shapeHoles:this.shapeHoles.map(e=>e.toJSON()),isClosed:this.isClosed,roundness:this.roundness}}fromJSON(e){this.points=[],this.pointIDs=0;let r=e.points.length/7;for(let o=0;o<r;o++){let n=o*7,a=e.points[n+0],s=e.points[n+1],l=e.points[n+2],c=e.points[n+3],u=e.points[n+4],p=e.points[n+5],d=e.points[n+6],f=new lo(Ye.MathUtils.generateUUID(),new Ye.Vector2(a,s));f.controls[0].position.set(l,c),f.controls[1].position.set(u,p),f.roundness=d,this.points.push(f)}return this.shapeHoles=e.shapeHoles?.length?e.shapeHoles.map(o=>{let n=new Xe;return n.fromJSON(o),n}):[],this.isClosed=e.isClosed,this._roundness=e.roundness,this._update(),this}fromShape(e,r=!1){this.isText=r;let o=(a,s)=>{s instanceof Ye.CubicBezierCurve&&s.v3.equals(a.position)&&a.controls[0].position.copy(s.v2)},n=a=>{let s=[],l,c;for(l=0,c=a.length;l<c;l++)a[l]instanceof Ye.QuadraticBezierCurve&&(a[l]=bx(a[l]));for(l=0,c=a.length;l<c;l++){let d=a[l],f=l>0?a[l-1]:null,h;d instanceof Ye.CubicBezierCurve?(h=this.createPoint(d.v0),h.controls[1].position.copy(d.v1)):d instanceof Ye.LineCurve&&(h=this.createPoint(d.v1)),h!==void 0&&(f!==null&&o(h,f),s.push(h))}let u=a[a.length-1],p=!1;return u instanceof Ye.CubicBezierCurve?u.v3.equals(s[0].position)&&(s[0].controls[0].position.copy(u.v2),p=!0):u instanceof Ye.LineCurve&&u.v2.equals(s[0].position)&&(p=!0),this.isClosed=p,s};return this.points=n(e.curves),e instanceof Ye.Shape&&(this.shapeHoles=e.holes.map(a=>{let s=new Xe;return s.fromShape(a),s})),this.update(),this}updatePoint(e,r){let o=this.getPointByUuid(e);o&&(r.position!==void 0&&o.position.fromArray(r.position),r.roundness!==void 0&&(o.roundness=r.roundness),r.areControlsDirectionsMirrored!==void 0&&(o.areControlsDirectionsMirrored=r.areControlsDirectionsMirrored),this.needsUpdate=!0)}updatePreviousControl(e,r){let n=this.getPointByUuid(e)?.controls[0];n&&(r.position&&n.position.fromArray(r.position),this.needsUpdate=!0)}updateNextControl(e,r){let n=this.getPointByUuid(e)?.controls[1];n&&(r.position&&n.position.fromArray(r.position),this.needsUpdate=!0)}};var Af=Math.PI*2;function Cf({x:i,y:t},e,r,o,n){return{x:i*e+o,y:t*r+n}}function jM(i,t){let e=t===1.5707963267948966?.551915024494:t===-1.5707963267948966?-.551915024494:1.3333333333333333*Math.tan(t/4),r=Math.cos(i),o=Math.sin(i),n=Math.cos(i+t),a=Math.sin(i+t);return[{x:r-o*e,y:o+r*e},{x:n+a*e,y:a-n*e},{x:n,y:a}]}function Mx(i,t,e,r){let o=i*r-t*e<0?-1:1,n=Math.min(1,Math.max(-1,i*e+t*r));return o*Math.acos(n)}function UM(i,t,e,r,o,n,a,s,l,c){let u=Math.pow(o,2),p=Math.pow(n,2),d=Math.pow(a,2),f=Math.pow(s,2),h=u*p-u*f-p*d;h<0&&(h=0),h/=u*f+p*d,h=Math.sqrt(h)*(l===c?-1:1);let m=h*o/n*s,y=h*-n/o*a,b=m+(i+e)/2,v=y+(t+r)/2,w=(a-m)/o,O=(s-y)/n,S=(-a-m)/o,T=(-s-y)/n,M=Mx(1,0,w,O),g=Mx(w,O,S,T);return!c&&g>0&&(g-=Af),c&&g<0&&(g+=Af),{centerx:b,centery:v,ang1:M,ang2:g}}function Ix({px:i,py:t,cx:e,cy:r,rx:o,ry:n,largeArcFlag:a,sweepFlag:s}){let l=[];if(o===0||n===0)return[];let c=(i-e)/2,u=(t-r)/2;if(c===0&&u===0)return[];o=Math.abs(o),n=Math.abs(n);let p=Math.pow(c,2)/Math.pow(o,2)+Math.pow(u,2)/Math.pow(n,2);p>1&&(o*=Math.sqrt(p),n*=Math.sqrt(p));let d=UM(i,t,e,r,o,n,c,u,a,s),{ang1:f,ang2:h}=d,{centerx:m,centery:y}=d,b=Math.abs(h)/(Af/4);Math.abs(1-b)<1e-7&&(b=1);let v=Math.max(Math.ceil(b),1);h/=v;for(let w=0;w<v;w++)l.push(jM(f,h)),f+=h;return l.map(w=>{let{x:O,y:S}=Cf(w[0],o,n,m,y),{x:T,y:M}=Cf(w[1],o,n,m,y),{x:g,y:D}=Cf(w[2],o,n,m,y);return{x1:O,y1:S,x2:T,y2:M,x:g,y:D}})}var Mn=require("three");var $e;(function(i){i[i.ODD=0]="ODD",i[i.NONZERO=1]="NONZERO",i[i.POSITIVE=2]="POSITIVE",i[i.NEGATIVE=3]="NEGATIVE",i[i.ABS_GEQ_TWO=4]="ABS_GEQ_TWO"})($e||($e={}));var St;(function(i){i[i.POLYGONS=0]="POLYGONS",i[i.CONNECTED_POLYGONS=1]="CONNECTED_POLYGONS",i[i.BOUNDARY_CONTOURS=2]="BOUNDARY_CONTOURS"})(St||(St={}));function Oe(i,t){if(!i)throw t||"Assertion Failed!"}var we=function(){function i(){}return i.vertEq=function(t,e){return t.s===e.s&&t.t===e.t},i.vertLeq=function(t,e){return t.s<e.s||t.s===e.s&&t.t<=e.t},i.transLeq=function(t,e){return t.t<e.t||t.t===e.t&&t.s<=e.s},i.edgeGoesLeft=function(t){return i.vertLeq(t.Dst,t.Org)},i.edgeGoesRight=function(t){return i.vertLeq(t.Org,t.Dst)},i.vertL1dist=function(t,e){return Math.abs(t.s-e.s)+Math.abs(t.t-e.t)},i.edgeEval=function(t,e,r){Oe(i.vertLeq(t,e)&&i.vertLeq(e,r));var o=e.s-t.s,n=r.s-e.s;return o+n>0?o<n?e.t-t.t+(t.t-r.t)*(o/(o+n)):e.t-r.t+(r.t-t.t)*(n/(o+n)):0},i.edgeSign=function(t,e,r){Oe(i.vertLeq(t,e)&&i.vertLeq(e,r));var o=e.s-t.s,n=r.s-e.s;return o+n>0?(e.t-r.t)*o+(e.t-t.t)*n:0},i.transEval=function(t,e,r){Oe(i.transLeq(t,e)&&i.transLeq(e,r));var o=e.t-t.t,n=r.t-e.t;return o+n>0?o<n?e.s-t.s+(t.s-r.s)*(o/(o+n)):e.s-r.s+(r.s-t.s)*(n/(o+n)):0},i.transSign=function(t,e,r){Oe(i.transLeq(t,e)&&i.transLeq(e,r));var o=e.t-t.t,n=r.t-e.t;return o+n>0?(e.s-r.s)*o+(e.s-t.s)*n:0},i.vertCCW=function(t,e,r){return t.s*(e.t-r.t)+e.s*(r.t-t.t)+r.s*(t.t-e.t)>=0},i.interpolate=function(t,e,r,o){return t=t<0?0:t,r=r<0?0:r,t<=r?r===0?(e+o)/2:e+(o-e)*(t/(t+r)):o+(e-o)*(r/(t+r))},i.intersect=function(t,e,r,o,n){var a,s,l;i.vertLeq(t,e)||(l=t,t=e,e=l),i.vertLeq(r,o)||(l=r,r=o,o=l),i.vertLeq(t,r)||(l=t,t=r,r=l,l=e,e=o,o=l),i.vertLeq(r,e)?i.vertLeq(e,o)?(a=i.edgeEval(t,r,e),s=i.edgeEval(r,e,o),a+s<0&&(a=-a,s=-s),n.s=i.interpolate(a,r.s,s,e.s)):(a=i.edgeSign(t,r,e),s=-i.edgeSign(t,o,e),a+s<0&&(a=-a,s=-s),n.s=i.interpolate(a,r.s,s,o.s)):n.s=(r.s+e.s)/2,i.transLeq(t,e)||(l=t,t=e,e=l),i.transLeq(r,o)||(l=r,r=o,o=l),i.transLeq(t,r)||(l=t,t=r,r=l,l=e,e=o,o=l),i.transLeq(r,e)?i.transLeq(e,o)?(a=i.transEval(t,r,e),s=i.transEval(r,e,o),a+s<0&&(a=-a,s=-s),n.t=i.interpolate(a,r.t,s,e.t)):(a=i.transSign(t,r,e),s=-i.transSign(t,o,e),a+s<0&&(a=-a,s=-s),n.t=i.interpolate(a,r.t,s,o.t)):n.t=(r.t+e.t)/2},i}(),Tl=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}(),Gu=function(){function i(t){this.side=t,this.next=null,this.Org=null,this.Sym=null,this.Onext=null,this.Lnext=null,this.Lface=null,this.activeRegion=null,this.winding=0}return Object.defineProperty(i.prototype,"Rface",{get:function(){return this.Sym.Lface},set:function(t){this.Sym.Lface=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Dst",{get:function(){return this.Sym.Org},set:function(t){this.Sym.Org=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Oprev",{get:function(){return this.Sym.Lnext},set:function(t){this.Sym.Lnext=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Lprev",{get:function(){return this.Onext.Sym},set:function(t){this.Onext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Dprev",{get:function(){return this.Lnext.Sym},set:function(t){this.Lnext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Rprev",{get:function(){return this.Sym.Onext},set:function(t){this.Sym.Onext=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Dnext",{get:function(){return this.Sym.Onext.Sym},set:function(t){this.Sym.Onext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Rnext",{get:function(){return this.Sym.Lnext.Sym},set:function(t){this.Sym.Lnext.Sym=t},enumerable:!0,configurable:!0}),i}(),Wa=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}(),Ex=function(){function i(){var t=new Wa,e=new Tl,r=new Gu(0),o=new Gu(1);t.next=t.prev=t,t.anEdge=null,e.next=e.prev=e,r.next=r,r.Sym=o,o.next=o,o.Sym=r,this.vHead=t,this.fHead=e,this.eHead=r,this.eHeadSym=o}return i.prototype.makeEdge_=function(t){var e=new Gu(0),r=new Gu(1);t.Sym.side<t.side&&(t=t.Sym);var o=t.Sym.next;return r.next=o,o.Sym.next=e,e.next=t,t.Sym.next=r,e.Sym=r,e.Onext=e,e.Lnext=r,e.Org=null,e.Lface=null,e.winding=0,e.activeRegion=null,r.Sym=e,r.Onext=r,r.Lnext=e,r.Org=null,r.Lface=null,r.winding=0,r.activeRegion=null,e},i.prototype.splice_=function(t,e){var r=t.Onext,o=e.Onext;r.Sym.Lnext=e,o.Sym.Lnext=t,t.Onext=o,e.Onext=r},i.prototype.makeVertex_=function(t,e,r){var o=t;Oe(o,"Vertex can't be null!");var n=r.prev;o.prev=n,n.next=o,o.next=r,r.prev=o,o.anEdge=e;var a=e;do a.Org=o,a=a.Onext;while(a!==e)},i.prototype.makeFace_=function(t,e,r){var o=t;Oe(o,"Face can't be null");var n=r.prev;o.prev=n,n.next=o,o.next=r,r.prev=o,o.anEdge=e,o.trail=null,o.marked=!1,o.inside=r.inside;var a=e;do a.Lface=o,a=a.Lnext;while(a!==e)},i.prototype.killEdge_=function(t){t.Sym.side<t.side&&(t=t.Sym);var e=t.next,r=t.Sym.next;e.Sym.next=r,r.Sym.next=e},i.prototype.killVertex_=function(t,e){var r=t.anEdge,o=r;do o.Org=e,o=o.Onext;while(o!==r);var n=t.prev,a=t.next;a.prev=n,n.next=a},i.prototype.killFace_=function(t,e){var r=t.anEdge,o=r;do o.Lface=e,o=o.Lnext;while(o!==r);var n=t.prev,a=t.next;a.prev=n,n.next=a},i.prototype.makeEdge=function(){var t=new Wa,e=new Wa,r=new Tl,o=this.makeEdge_(this.eHead);return this.makeVertex_(t,o,this.vHead),this.makeVertex_(e,o.Sym,this.vHead),this.makeFace_(r,o,this.fHead),o},i.prototype.splice=function(t,e){var r=!1,o=!1;if(t!==e){if(e.Org!==t.Org&&(o=!0,this.killVertex_(e.Org,t.Org)),e.Lface!==t.Lface&&(r=!0,this.killFace_(e.Lface,t.Lface)),this.splice_(e,t),!o){var n=new Wa;this.makeVertex_(n,e,t.Org),t.Org.anEdge=t}if(!r){var a=new Tl;this.makeFace_(a,e,t.Lface),t.Lface.anEdge=t}}},i.prototype.delete=function(t){var e=t.Sym,r=!1;if(t.Lface!==t.Rface&&(r=!0,this.killFace_(t.Lface,t.Rface)),t.Onext===t)this.killVertex_(t.Org,null);else if(t.Rface.anEdge=t.Oprev,t.Org.anEdge=t.Onext,this.splice_(t,t.Oprev),!r){var o=new Tl;this.makeFace_(o,t,t.Lface)}e.Onext===e?(this.killVertex_(e.Org,null),this.killFace_(e.Lface,null)):(t.Lface.anEdge=e.Oprev,e.Org.anEdge=e.Onext,this.splice_(e,e.Oprev)),this.killEdge_(t)},i.prototype.addEdgeVertex=function(t){var e=this.makeEdge_(t),r=e.Sym;this.splice_(e,t.Lnext),e.Org=t.Dst;var o=new Wa;return this.makeVertex_(o,r,e.Org),e.Lface=r.Lface=t.Lface,e},i.prototype.splitEdge=function(t){var e=this.addEdgeVertex(t),r=e.Sym;return this.splice_(t.Sym,t.Sym.Oprev),this.splice_(t.Sym,r),t.Dst=r.Org,r.Dst.anEdge=r.Sym,r.Rface=t.Rface,r.winding=t.winding,r.Sym.winding=t.Sym.winding,r.idx=t.idx,r.Sym.idx=t.Sym.idx,r},i.prototype.connect=function(t,e){var r=!1,o=this.makeEdge_(t),n=o.Sym;if(e.Lface!==t.Lface&&(r=!0,this.killFace_(e.Lface,t.Lface)),this.splice_(o,t.Lnext),this.splice_(n,e),o.Org=t.Dst,n.Org=e.Org,o.Lface=n.Lface=t.Lface,t.Lface.anEdge=n,!r){var a=new Tl;this.makeFace_(a,o,t.Lface)}return o},i.prototype.zapFace=function(t){var e=t.anEdge,r,o,n,a,s;o=e.Lnext;do r=o,o=r.Lnext,r.Lface=null,r.Rface===null&&(r.Onext===r?this.killVertex_(r.Org,null):(r.Org.anEdge=r.Onext,this.splice_(r,r.Oprev)),n=r.Sym,n.Onext===n?this.killVertex_(n.Org,null):(n.Org.anEdge=n.Onext,this.splice_(n,n.Oprev)),this.killEdge_(r));while(r!=e);a=t.prev,s=t.next,s.prev=a,a.next=s},i.prototype.countFaceVerts_=function(t){var e=t.anEdge,r=0;do r++,e=e.Lnext;while(e!==t.anEdge);return r},i.prototype.mergeConvexFaces=function(t){var e,r,o,n,a,s,l;for(e=this.fHead.next;e!==this.fHead;e=e.next)if(!!e.inside)for(r=e.anEdge,a=r.Org;o=r.Lnext,n=r.Sym,n&&n.Lface&&n.Lface.inside&&(s=this.countFaceVerts_(e),l=this.countFaceVerts_(n.Lface),s+l-2<=t&&we.vertCCW(r.Lprev.Org,r.Org,n.Lnext.Lnext.Org)&&we.vertCCW(n.Lprev.Org,n.Org,r.Lnext.Lnext.Org)&&(o=n.Lnext,this.delete(n),r=null,n=null)),!(r&&r.Lnext.Org===a);)r=o;return!0},i.prototype.check=function(){var t=this.fHead,e=this.vHead,r=this.eHead,o,n,a,s,l,c;for(n=t,n=t;(o=n.next)!==t;n=o){Oe(o.prev===n),l=o.anEdge;do Oe(l.Sym!==l),Oe(l.Sym.Sym===l),Oe(l.Lnext.Onext.Sym===l),Oe(l.Onext.Sym.Lnext===l),Oe(l.Lface===o),l=l.Lnext;while(l!==o.anEdge)}for(Oe(o.prev===n&&o.anEdge===null),s=e,s=e;(a=s.next)!==e;s=a){Oe(a.prev===s),l=a.anEdge;do Oe(l.Sym!==l),Oe(l.Sym.Sym===l),Oe(l.Lnext.Onext.Sym===l),Oe(l.Onext.Sym.Lnext===l),Oe(l.Org===a),l=l.Onext;while(l!==a.anEdge)}for(Oe(a.prev===s&&a.anEdge===null),c=r,c=r;(l=c.next)!==r;c=l)Oe(l.Sym.next===c.Sym),Oe(l.Sym!==l),Oe(l.Sym.Sym===l),Oe(l.Org!==null),Oe(l.Dst!==null),Oe(l.Lnext.Onext.Sym===l),Oe(l.Onext.Sym.Lnext===l);Oe(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}(),Nx=function(){function i(){this.handle=null}return i}(),Dx=function(){function i(){this.key=null,this.node=0}return i}(),kM=function(){function i(t,e){this.leq=e,this.max=0,this.nodes=[],this.handles=[],this.initialized=!1,this.freeList=0,this.size=0,this.max=t,this.nodes=[],this.handles=[];for(var r=0;r<t+1;r++)this.nodes[r]=new Nx,this.handles[r]=new Dx;this.initialized=!1,this.nodes[1].handle=1,this.handles[1].key=null}return i.prototype.floatDown_=function(t){var e=this.nodes,r=this.handles,o,n,a;for(o=e[t].handle;;){if(a=t<<1,a<this.size&&this.leq(r[e[a+1].handle].key,r[e[a].handle].key)&&++a,Oe(a<=this.max),n=e[a].handle,a>this.size||this.leq(r[o].key,r[n].key)){e[t].handle=o,r[o].node=t;break}e[t].handle=n,r[n].node=t,t=a}},i.prototype.floatUp_=function(t){var e=this.nodes,r=this.handles,o,n,a;for(o=e[t].handle;;){if(a=t>>1,n=e[a].handle,a===0||this.leq(r[n].key,r[o].key)){e[t].handle=o,r[o].node=t;break}e[t].handle=n,r[n].node=t,t=a}},i.prototype.init=function(){for(var t=this.size;t>=1;--t)this.floatDown_(t);this.initialized=!0},i.prototype.min=function(){return this.handles[this.nodes[1].handle].key},i.prototype.insert=function(t){var e,r;if(e=++this.size,e*2>this.max){this.max*=2;var o,n;for(n=this.nodes.length,this.nodes.length=this.max+1,o=n;o<this.nodes.length;o++)this.nodes[o]=new Nx;for(n=this.handles.length,this.handles.length=this.max+1,o=n;o<this.handles.length;o++)this.handles[o]=new Dx}return this.freeList===0?r=e:(r=this.freeList,this.freeList=this.handles[r].node),this.nodes[e].handle=r,this.handles[r].node=e,this.handles[r].key=t,this.initialized&&this.floatUp_(e),r},i.prototype.extractMin=function(){var t=this.nodes,e=this.handles,r=t[1].handle,o=e[r].key;return this.size>0&&(t[1].handle=t[this.size].handle,e[t[1].handle].node=1,e[r].key=null,e[r].node=this.freeList,this.freeList=r,--this.size,this.size>0&&this.floatDown_(1)),o},i.prototype.delete=function(t){var e=this.nodes,r=this.handles,o;Oe(t>=1&&t<=this.max&&r[t].key!==null),o=r[t].node,e[o].handle=e[this.size].handle,r[e[o].handle].node=o,--this.size,o<=this.size&&(o<=1||this.leq(r[e[o>>1].handle].key,r[e[o].handle].key)?this.floatDown_(o):this.floatUp_(o)),r[t].key=null,r[t].node=this.freeList,this.freeList=t},i}(),Mf=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}(),_x=function(){function i(){this.key=null,this.next=null,this.prev=null}return i}(),HM=function(){function i(t,e){this.frame=t,this.leq=e,this.head=new _x,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(t){return this.insertBefore(this.head,t)},i.prototype.search=function(t){var e=this.head;do e=e.next;while(e.key!==null&&!this.leq(this.frame,t,e.key));return e},i.prototype.insertBefore=function(t,e){do t=t.prev;while(t.key!==null&&!this.leq(this.frame,t.key,e));var r=new _x;return r.key=e,r.next=t.next,t.next.prev=r,r.prev=t,t.next=r,r},i.prototype.delete=function(t){t.next.prev=t.prev,t.prev.next=t.next},i}(),WM=function(){function i(){}return i.regionBelow=function(t){return t.nodeUp.prev.key},i.regionAbove=function(t){return t.nodeUp.next.key},i.debugEvent=function(t){},i.addWinding=function(t,e){t.winding+=e.winding,t.Sym.winding+=e.Sym.winding},i.edgeLeq=function(t,e,r){var o=t.event,n=e.eUp,a=r.eUp;if(n.Dst===o)return a.Dst===o?we.vertLeq(n.Org,a.Org)?we.edgeSign(a.Dst,n.Org,a.Org)<=0:we.edgeSign(n.Dst,a.Org,n.Org)>=0:we.edgeSign(a.Dst,o,a.Org)<=0;if(a.Dst===o)return we.edgeSign(n.Dst,o,n.Org)>=0;var s=we.edgeEval(n.Dst,o,n.Org),l=we.edgeEval(a.Dst,o,a.Org);return s>=l},i.deleteRegion=function(t,e){e.fixUpperEdge&&Oe(e.eUp.winding===0),e.eUp.activeRegion=null,t.dict.delete(e.nodeUp)},i.fixUpperEdge=function(t,e,r){Oe(e.fixUpperEdge),t.mesh.delete(e.eUp),e.fixUpperEdge=!1,e.eUp=r,r.activeRegion=e},i.topLeftRegion=function(t,e){var r=e.eUp.Org,o;do e=i.regionAbove(e);while(e.eUp.Org===r);if(e.fixUpperEdge){if(o=t.mesh.connect(i.regionBelow(e).eUp.Sym,e.eUp.Lnext),o===null)return null;i.fixUpperEdge(t,e,o),e=i.regionAbove(e)}return e},i.topRightRegion=function(t){var e=t.eUp.Dst;do t=i.regionAbove(t);while(t.eUp.Dst===e);return t},i.addRegionBelow=function(t,e,r){var o=new Mf;return o.eUp=r,o.nodeUp=t.dict.insertBefore(e.nodeUp,o),o.fixUpperEdge=!1,o.sentinel=!1,o.dirty=!1,r.activeRegion=o,o},i.isWindingInside=function(t,e){switch(t.windingRule){case $e.ODD:return(e&1)!==0;case $e.NONZERO:return e!==0;case $e.POSITIVE:return e>0;case $e.NEGATIVE:return e<0;case $e.ABS_GEQ_TWO:return e>=2||e<=-2}throw new Error("Invalid winding rulle")},i.computeWinding=function(t,e){e.windingNumber=i.regionAbove(e).windingNumber+e.eUp.winding,e.inside=i.isWindingInside(t,e.windingNumber)},i.finishRegion=function(t,e){var r=e.eUp,o=r.Lface;o.inside=e.inside,o.anEdge=r,i.deleteRegion(t,e)},i.finishLeftRegions=function(t,e,r){for(var o,n=null,a=e,s=e.eUp;a!==r;){if(a.fixUpperEdge=!1,n=i.regionBelow(a),o=n.eUp,o.Org!=s.Org){if(!n.fixUpperEdge){i.finishRegion(t,a);break}o=t.mesh.connect(s.Lprev,o.Sym),i.fixUpperEdge(t,n,o)}s.Onext!==o&&(t.mesh.splice(o.Oprev,o),t.mesh.splice(s,o)),i.finishRegion(t,a),s=n.eUp,a=n}return s},i.addRightEdges=function(t,e,r,o,n,a){var s,l,c,u,p=!0;c=r;do Oe(we.vertLeq(c.Org,c.Dst)),i.addRegionBelow(t,e,c.Sym),c=c.Onext;while(c!==o);for(n===null&&(n=i.regionBelow(e).eUp.Rprev),l=e,u=n;s=i.regionBelow(l),c=s.eUp.Sym,c.Org===u.Org;)c.Onext!==u&&(t.mesh.splice(c.Oprev,c),t.mesh.splice(u.Oprev,c)),s.windingNumber=l.windingNumber-c.winding,s.inside=i.isWindingInside(t,s.windingNumber),l.dirty=!0,!p&&i.checkForRightSplice(t,l)&&(i.addWinding(c,u),i.deleteRegion(t,l),t.mesh.delete(u)),p=!1,l=s,u=c;l.dirty=!0,Oe(l.windingNumber-c.winding===s.windingNumber),a&&i.walkDirtyRegions(t,l)},i.spliceMergeVertices=function(t,e,r){t.mesh.splice(e,r)},i.vertexWeights=function(t,e,r){var o=we.vertL1dist(e,t),n=we.vertL1dist(r,t),a=.5*n/(o+n),s=.5*o/(o+n);t.coords[0]+=a*e.coords[0]+s*r.coords[0],t.coords[1]+=a*e.coords[1]+s*r.coords[1],t.coords[2]+=a*e.coords[2]+s*r.coords[2]},i.getIntersectData=function(t,e,r,o,n,a){e.coords[0]=e.coords[1]=e.coords[2]=0,e.idx=-1,i.vertexWeights(e,r,o),i.vertexWeights(e,n,a)},i.checkForRightSplice=function(t,e){var r=i.regionBelow(e),o=e.eUp,n=r.eUp;if(we.vertLeq(o.Org,n.Org)){if(we.edgeSign(n.Dst,o.Org,n.Org)>0)return!1;we.vertEq(o.Org,n.Org)?o.Org!==n.Org&&(t.pq.delete(o.Org.pqHandle),i.spliceMergeVertices(t,n.Oprev,o)):(t.mesh.splitEdge(n.Sym),t.mesh.splice(o,n.Oprev),e.dirty=r.dirty=!0)}else{if(we.edgeSign(o.Dst,n.Org,o.Org)<0)return!1;i.regionAbove(e).dirty=e.dirty=!0,t.mesh.splitEdge(o.Sym),t.mesh.splice(n.Oprev,o)}return!0},i.checkForLeftSplice=function(t,e){var r=i.regionBelow(e),o=e.eUp,n=r.eUp,a;if(Oe(!we.vertEq(o.Dst,n.Dst)),we.vertLeq(o.Dst,n.Dst)){if(we.edgeSign(o.Dst,n.Dst,o.Org)<0)return!1;i.regionAbove(e).dirty=e.dirty=!0,a=t.mesh.splitEdge(o),t.mesh.splice(n.Sym,a),a.Lface.inside=e.inside}else{if(we.edgeSign(n.Dst,o.Dst,n.Org)>0)return!1;e.dirty=r.dirty=!0,a=t.mesh.splitEdge(n),t.mesh.splice(o.Lnext,n.Sym),a.Rface.inside=e.inside}return!0},i.checkForIntersect=function(t,e){var r=i.regionBelow(e),o=e.eUp,n=r.eUp,a=o.Org,s=n.Org,l=o.Dst,c=n.Dst,u,p,d=new Wa,f,h;if(Oe(!we.vertEq(c,l)),Oe(we.edgeSign(l,t.event,a)<=0),Oe(we.edgeSign(c,t.event,s)>=0),Oe(a!==t.event&&s!==t.event),Oe(!e.fixUpperEdge&&!r.fixUpperEdge),a===s||(u=Math.min(a.t,l.t),p=Math.max(s.t,c.t),u>p))return!1;if(we.vertLeq(a,s)){if(we.edgeSign(c,a,s)>0)return!1}else if(we.edgeSign(l,s,a)<0)return!1;return i.debugEvent(t),we.intersect(l,a,c,s,d),Oe(Math.min(a.t,l.t)<=d.t),Oe(d.t<=Math.max(s.t,c.t)),Oe(Math.min(c.s,l.s)<=d.s),Oe(d.s<=Math.max(s.s,a.s)),we.vertLeq(d,t.event)&&(d.s=t.event.s,d.t=t.event.t),f=we.vertLeq(a,s)?a:s,we.vertLeq(f,d)&&(d.s=f.s,d.t=f.t),we.vertEq(d,a)||we.vertEq(d,s)?(i.checkForRightSplice(t,e),!1):!we.vertEq(l,t.event)&&we.edgeSign(l,t.event,d)>=0||!we.vertEq(c,t.event)&&we.edgeSign(c,t.event,d)<=0?c===t.event?(t.mesh.splitEdge(o.Sym),t.mesh.splice(n.Sym,o),e=i.topLeftRegion(t,e),o=i.regionBelow(e).eUp,i.finishLeftRegions(t,i.regionBelow(e),r),i.addRightEdges(t,e,o.Oprev,o,o,!0),!0):l===t.event?(t.mesh.splitEdge(n.Sym),t.mesh.splice(o.Lnext,n.Oprev),r=e,e=i.topRightRegion(e),h=i.regionBelow(e).eUp.Rprev,r.eUp=n.Oprev,n=i.finishLeftRegions(t,r,null),i.addRightEdges(t,e,n.Onext,o.Rprev,h,!0),!0):(we.edgeSign(l,t.event,d)>=0&&(i.regionAbove(e).dirty=e.dirty=!0,t.mesh.splitEdge(o.Sym),o.Org.s=t.event.s,o.Org.t=t.event.t),we.edgeSign(c,t.event,d)<=0&&(e.dirty=r.dirty=!0,t.mesh.splitEdge(n.Sym),n.Org.s=t.event.s,n.Org.t=t.event.t),!1):(t.mesh.splitEdge(o.Sym),t.mesh.splitEdge(n.Sym),t.mesh.splice(n.Oprev,o),o.Org.s=d.s,o.Org.t=d.t,o.Org.pqHandle=t.pq.insert(o.Org),i.getIntersectData(t,o.Org,a,l,s,c),i.regionAbove(e).dirty=e.dirty=r.dirty=!0,!1)},i.walkDirtyRegions=function(t,e){for(var r=i.regionBelow(e),o,n;;){for(;r.dirty;)e=r,r=i.regionBelow(r);if(!e.dirty&&(r=e,e=i.regionAbove(e),e===null||!e.dirty))return;if(e.dirty=!1,o=e.eUp,n=r.eUp,o.Dst!==n.Dst&&i.checkForLeftSplice(t,e)&&(r.fixUpperEdge?(i.deleteRegion(t,r),t.mesh.delete(n),r=i.regionBelow(e),n=r.eUp):e.fixUpperEdge&&(i.deleteRegion(t,e),t.mesh.delete(o),e=i.regionAbove(r),o=e.eUp)),o.Org!==n.Org)if(o.Dst!==n.Dst&&!e.fixUpperEdge&&!r.fixUpperEdge&&(o.Dst===t.event||n.Dst===t.event)){if(i.checkForIntersect(t,e))return}else i.checkForRightSplice(t,e);o.Org===n.Org&&o.Dst===n.Dst&&(i.addWinding(n,o),i.deleteRegion(t,e),t.mesh.delete(o),e=i.regionAbove(r))}},i.connectRightVertex=function(t,e,r){var o,n=r.Onext,a=i.regionBelow(e),s=e.eUp,l=a.eUp,c=!1;if(s.Dst!==l.Dst&&i.checkForIntersect(t,e),we.vertEq(s.Org,t.event)&&(t.mesh.splice(n.Oprev,s),e=i.topLeftRegion(t,e),n=i.regionBelow(e).eUp,i.finishLeftRegions(t,i.regionBelow(e),a),c=!0),we.vertEq(l.Org,t.event)&&(t.mesh.splice(r,l.Oprev),r=i.finishLeftRegions(t,a,null),c=!0),c){i.addRightEdges(t,e,r.Onext,n,n,!0);return}we.vertLeq(l.Org,s.Org)?o=l.Oprev:o=s,o=t.mesh.connect(r.Lprev,o),i.addRightEdges(t,e,o,o.Onext,o.Onext,!1),o.Sym.activeRegion.fixUpperEdge=!0,i.walkDirtyRegions(t,e)},i.connectLeftDegenerate=function(t,e,r){var o,n,a,s,l;if(o=e.eUp,we.vertEq(o.Org,r)){Oe(!1),i.spliceMergeVertices(t,o,r.anEdge);return}if(!we.vertEq(o.Dst,r)){t.mesh.splitEdge(o.Sym),e.fixUpperEdge&&(t.mesh.delete(o.Onext),e.fixUpperEdge=!1),t.mesh.splice(r.anEdge,o),i.sweepEvent(t,r);return}Oe(!1),e=i.topRightRegion(e),l=i.regionBelow(e),a=l.eUp.Sym,n=s=a.Onext,l.fixUpperEdge&&(Oe(n!==a),i.deleteRegion(t,l),t.mesh.delete(a),a=n.Oprev),t.mesh.splice(r.anEdge,a),we.edgeGoesLeft(n)||(n=null),i.addRightEdges(t,e,a.Onext,s,n,!0)},i.connectLeftVertex=function(t,e){var r,o,n,a,s,l,c=new Mf;if(c.eUp=e.anEdge.Sym,r=t.dict.search(c).key,o=i.regionBelow(r),!!o){if(a=r.eUp,s=o.eUp,we.edgeSign(a.Dst,e,a.Org)===0){i.connectLeftDegenerate(t,r,e);return}if(n=we.vertLeq(s.Dst,a.Dst)?r:o,r.inside||n.fixUpperEdge){if(n===r)l=t.mesh.connect(e.anEdge.Sym,a.Lnext);else{var u=t.mesh.connect(s.Dnext,e.anEdge);l=u.Sym}n.fixUpperEdge?i.fixUpperEdge(t,n,l):i.computeWinding(t,i.addRegionBelow(t,r,l)),i.sweepEvent(t,e)}else i.addRightEdges(t,r,e.anEdge,e.anEdge,null,!0)}},i.sweepEvent=function(t,e){t.event=e,i.debugEvent(t);for(var r=e.anEdge;r.activeRegion===null;)if(r=r.Onext,r===e.anEdge){i.connectLeftVertex(t,e);return}var o=i.topLeftRegion(t,r.activeRegion);Oe(o!==null);var n=i.regionBelow(o),a=n.eUp,s=i.finishLeftRegions(t,n,null);s.Onext===a?i.connectRightVertex(t,o,s):i.addRightEdges(t,o,s.Onext,a,a,!0)},i.addSentinel=function(t,e,r,o){var n=new Mf,a=t.mesh.makeEdge();a.Org.s=r,a.Org.t=o,a.Dst.s=e,a.Dst.t=o,t.event=a.Dst,n.eUp=a,n.windingNumber=0,n.inside=!1,n.fixUpperEdge=!1,n.sentinel=!0,n.dirty=!1,n.nodeUp=t.dict.insert(n)},i.initEdgeDict=function(t){t.dict=new HM(t,i.edgeLeq);var e=t.bmax[0]-t.bmin[0],r=t.bmax[1]-t.bmin[1],o=t.bmin[0]-e,n=t.bmax[0]+e,a=t.bmin[1]-r,s=t.bmax[1]+r;i.addSentinel(t,o,n,a),i.addSentinel(t,o,n,s)},i.doneEdgeDict=function(t){for(var e,r=0;(e=t.dict.min().key)!==null;)e.sentinel||(Oe(e.fixUpperEdge),Oe(++r===1)),Oe(e.windingNumber===0),i.deleteRegion(t,e)},i.removeDegenerateEdges=function(t){var e,r,o,n=t.mesh.eHead;for(e=n.next;e!==n;e=r)r=e.next,o=e.Lnext,we.vertEq(e.Org,e.Dst)&&e.Lnext.Lnext!==e&&(i.spliceMergeVertices(t,o,e),t.mesh.delete(e),e=o,o=e.Lnext),o.Lnext===e&&(o!==e&&((o===r||o===r.Sym)&&(r=r.next),t.mesh.delete(o)),(e===r||e===r.Sym)&&(r=r.next),t.mesh.delete(e))},i.initPriorityQ=function(t){var e,r,o,n=0;for(o=t.mesh.vHead,r=o.next;r!==o;r=r.next)n++;for(n+=8,e=t.pq=new kM(n,we.vertLeq),o=t.mesh.vHead,r=o.next;r!==o;r=r.next)r.pqHandle=e.insert(r);return r!==o?!1:(e.init(),!0)},i.donePriorityQ=function(t){t.pq=null},i.removeDegenerateFaces=function(t,e){var r,o,n;for(r=e.fHead.next;r!==e.fHead;r=o)o=r.next,n=r.anEdge,Oe(n.Lnext!==n),n.Lnext.Lnext===n&&(i.addWinding(n.Onext,n),t.mesh.delete(n));return!0},i.computeInterior=function(t,e){e===void 0&&(e=!0);var r,o;if(i.removeDegenerateEdges(t),!i.initPriorityQ(t))return!1;for(i.initEdgeDict(t);(r=t.pq.extractMin())!==null;){for(;o=t.pq.min(),!(o===null||!we.vertEq(o,r));)o=t.pq.extractMin(),i.spliceMergeVertices(t,r.anEdge,o.anEdge);i.sweepEvent(t,r)}return t.event=t.dict.min().key.eUp.Org,i.debugEvent(t),i.doneEdgeDict(t),i.donePriorityQ(t),i.removeDegenerateFaces(t,t.mesh)?(e&&t.mesh.check(),!0):!1},i}(),qM=function(){function i(){this.mesh=new Ex,this.normal=[0,0,0],this.sUnit=[0,0,0],this.tUnit=[0,0,0],this.bmin=[0,0],this.bmax=[0,0],this.windingRule=$e.ODD,this.dict=null,this.pq=null,this.event=null,this.vertexIndexCounter=0,this.vertices=[],this.vertexIndices=[],this.vertexCount=0,this.elements=[],this.elementCount=0}return i.prototype.dot_=function(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]},i.prototype.normalize_=function(t){var e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2];if(!e)throw"Zero-size vector!";e=Math.sqrt(e),t[0]/=e,t[1]/=e,t[2]/=e},i.prototype.longAxis_=function(t){var e=0;return Math.abs(t[1])>Math.abs(t[0])&&(e=1),Math.abs(t[2])>Math.abs(t[e])&&(e=2),e},i.prototype.computeNormal_=function(t){var e,r,o,n,a,s,l=[0,0,0],c=[0,0,0],u=[0,0,0],p=[0,0,0],d=[0,0,0],f=[null,null,null],h=[null,null,null],m=this.mesh.vHead;e=m.next;for(var y=0;y<3;++y)n=e.coords[y],c[y]=n,h[y]=e,l[y]=n,f[y]=e;for(e=m.next;e!==m;e=e.next)for(var b=0;b<3;++b)n=e.coords[b],n<c[b]&&(c[b]=n,h[b]=e),n>l[b]&&(l[b]=n,f[b]=e);var v=0;if(l[1]-c[1]>l[0]-c[0]&&(v=1),l[2]-c[2]>l[v]-c[v]&&(v=2),c[v]>=l[v]){t[0]=0,t[1]=0,t[2]=1;return}for(s=0,r=h[v],o=f[v],u[0]=r.coords[0]-o.coords[0],u[1]=r.coords[1]-o.coords[1],u[2]=r.coords[2]-o.coords[2],e=m.next;e!==m;e=e.next)p[0]=e.coords[0]-o.coords[0],p[1]=e.coords[1]-o.coords[1],p[2]=e.coords[2]-o.coords[2],d[0]=u[1]*p[2]-u[2]*p[1],d[1]=u[2]*p[0]-u[0]*p[2],d[2]=u[0]*p[1]-u[1]*p[0],a=d[0]*d[0]+d[1]*d[1]+d[2]*d[2],a>s&&(s=a,t[0]=d[0],t[1]=d[1],t[2]=d[2]);s<=0&&(t[0]=t[1]=t[2]=0,t[this.longAxis_(u)]=1)},i.prototype.checkOrientation_=function(){for(var t=this.mesh.fHead,e,r=this.mesh.vHead,o,n=0,a=t.next;a!==t;a=a.next)if(o=a.anEdge,!(o.winding<=0))do n+=(o.Org.s-o.Dst.s)*(o.Org.t+o.Dst.t),o=o.Lnext;while(o!==a.anEdge);if(n<0){for(e=r.next;e!==r;e=e.next)e.t=-e.t;this.tUnit[0]=-this.tUnit[0],this.tUnit[1]=-this.tUnit[1],this.tUnit[2]=-this.tUnit[2]}},i.prototype.projectPolygon_=function(){var t=this.mesh.vHead,e=[0,0,0],r,o,n=!1;e[0]=this.normal[0],e[1]=this.normal[1],e[2]=this.normal[2],!e[0]&&!e[1]&&!e[2]&&(this.computeNormal_(e),n=!0),r=this.sUnit,o=this.tUnit;var a=this.longAxis_(e);r[a]=0,r[(a+1)%3]=1,r[(a+2)%3]=0,o[a]=0,o[(a+1)%3]=0,o[(a+2)%3]=e[a]>0?1:-1;for(var s=t.next;s!==t;s=s.next)s.s=this.dot_(s.coords,r),s.t=this.dot_(s.coords,o);n&&this.checkOrientation_();for(var l=!0,c=t.next;c!==t;c=c.next)l?(this.bmin[0]=this.bmax[0]=c.s,this.bmin[1]=this.bmax[1]=c.t,l=!1):(c.s<this.bmin[0]&&(this.bmin[0]=c.s),c.s>this.bmax[0]&&(this.bmax[0]=c.s),c.t<this.bmin[1]&&(this.bmin[1]=c.t),c.t>this.bmax[1]&&(this.bmax[1]=c.t))},i.prototype.addWinding_=function(t,e){t.winding+=e.winding,t.Sym.winding+=e.Sym.winding},i.prototype.tessellateMonoRegion_=function(t,e){var r,o;if(r=e.anEdge,!(r.Lnext!==r&&r.Lnext.Lnext!==r))throw"Mono region invalid";for(;we.vertLeq(r.Dst,r.Org);r=r.Lprev);for(;we.vertLeq(r.Org,r.Dst);r=r.Lnext);o=r.Lprev;for(var n=void 0;r.Lnext!==o;)if(we.vertLeq(r.Dst,o.Org)){for(;o.Lnext!==r&&(we.edgeGoesLeft(o.Lnext)||we.edgeSign(o.Org,o.Dst,o.Lnext.Dst)<=0);)n=t.connect(o.Lnext,o),o=n.Sym;o=o.Lprev}else{for(;o.Lnext!==r&&(we.edgeGoesRight(r.Lprev)||we.edgeSign(r.Dst,r.Org,r.Lprev.Org)>=0);)n=t.connect(r,r.Lprev),r=n.Sym;r=r.Lnext}if(o.Lnext===r)throw"Mono region invalid";for(;o.Lnext.Lnext!==r;)n=t.connect(o.Lnext,o),o=n.Sym;return!0},i.prototype.tessellateInterior_=function(t){for(var e,r=t.fHead.next;r!==t.fHead;r=e)if(e=r.next,r.inside&&!this.tessellateMonoRegion_(t,r))return!1;return!0},i.prototype.discardExterior_=function(t){for(var e,r=t.fHead.next;r!==t.fHead;r=e)e=r.next,r.inside||t.zapFace(r)},i.prototype.setWindingNumber_=function(t,e,r){for(var o,n=t.eHead.next;n!==t.eHead;n=o)o=n.next,n.Rface.inside!==n.Lface.inside?n.winding=n.Lface.inside?e:-e:r?t.delete(n):n.winding=0},i.prototype.getNeighbourFace_=function(t){return!t.Rface||!t.Rface.inside?-1:t.Rface.n},i.prototype.outputPolymesh_=function(t,e,r,o){var n,a=0,s=0,l;r>3&&t.mergeConvexFaces(r);for(var c=t.vHead.next;c!==t.vHead;c=c.next)c.n=-1;for(var u=t.fHead.next;u!==t.fHead;u=u.next)if(u.n=-1,!!u.inside){n=u.anEdge,l=0;do{var c=n.Org;c.n===-1&&(c.n=s,s++),l++,n=n.Lnext}while(n!==u.anEdge);if(l>r)throw"Face vertex greater that support polygon";u.n=a,++a}this.elementCount=a,e===St.CONNECTED_POLYGONS&&(a*=2),this.elements=[],this.elements.length=a*r,this.vertexCount=s,this.vertices=[],this.vertices.length=s*o,this.vertexIndices=[],this.vertexIndices.length=s;for(var c=t.vHead.next;c!==t.vHead;c=c.next)if(c.n!==-1){var p=c.n*o;this.vertices[p+0]=c.coords[0],this.vertices[p+1]=c.coords[1],o>2&&(this.vertices[p+2]=c.coords[2]),this.vertexIndices[c.n]=c.idx}for(var d=0,u=t.fHead.next;u!==t.fHead;u=u.next)if(!!u.inside){n=u.anEdge,l=0;do{var c=n.Org;this.elements[d++]=c.n,l++,n=n.Lnext}while(n!==u.anEdge);for(var f=l;f<r;++f)this.elements[d++]=-1;if(e===St.CONNECTED_POLYGONS){n=u.anEdge;do this.elements[d++]=this.getNeighbourFace_(n),n=n.Lnext;while(n!==u.anEdge);for(var h=l;h<r;++h)this.elements[d++]=-1}}},i.prototype.outputContours_=function(t,e){var r,o,n=0,a=0;this.vertexCount=0,this.elementCount=0;for(var s=t.fHead.next;s!==t.fHead;s=s.next)if(!!s.inside){o=r=s.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*e,this.vertexIndices=[],this.vertexIndices.length=this.vertexCount;var l=0,c=0,u=0;n=0;for(var s=t.fHead.next;s!==t.fHead;s=s.next)if(!!s.inside){a=0,o=r=s.anEdge;do this.vertices[l++]=r.Org.coords[0],this.vertices[l++]=r.Org.coords[1],e>2&&(this.vertices[l++]=r.Org.coords[2]),this.vertexIndices[c++]=this.vertexIdCallback?this.vertexIdCallback(r):r.Org.idx,a++,r=r.Lnext;while(r!==o);this.elements[u++]=n,this.elements[u++]=a,n+=a}},i.prototype.addContour=function(t,e){this.mesh===null&&(this.mesh=new Ex),t<2&&(t=2),t>3&&(t=3);for(var r=null,o=0;o<e.length;o+=t)r===null?(r=this.mesh.makeEdge(),this.mesh.splice(r,r.Sym)):(this.mesh.splitEdge(r),r=r.Lnext),r.Org.coords[0]=e[o+0],r.Org.coords[1]=e[o+1],t>2?r.Org.coords[2]=e[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(t,e,r,o,n,a){if(t===void 0&&(t=$e.ODD),e===void 0&&(e=St.POLYGONS),a===void 0&&(a=!0),this.vertices=[],this.elements=[],this.vertexIndices=[],this.vertexIndexCounter=0,n&&(this.normal[0]=n[0],this.normal[1]=n[1],this.normal[2]=n[2]),this.windingRule=t,o<2&&(o=2),o>3&&(o=3),!this.mesh)return!1;this.projectPolygon_(),WM.computeInterior(this,a);var s=this.mesh;return e===St.BOUNDARY_CONTOURS?this.setWindingNumber_(s,1,!0):this.tessellateInterior_(s),a&&s.check(),e===St.BOUNDARY_CONTOURS?this.outputContours_(s,o):this.outputPolymesh_(s,e,r,o),!0},i}();function co(i){var t=i.windingRule,e=t===void 0?$e.ODD:t,r=i.elementType,o=r===void 0?St.POLYGONS:r,n=i.polySize,a=n===void 0?3:n,s=i.vertexSize,l=s===void 0?2:s,c=i.normal,u=c===void 0?[0,0,1]:c,p=i.contours,d=p===void 0?[]:p,f=i.strict,h=f===void 0?!0:f,m=i.debug,y=m===void 0?!1:m;if(!d&&h)throw new Error("Contours can't be empty");if(!!d){var b=new qM;i.edgeCreateCallback&&(b.edgeCreateCallback=i.edgeCreateCallback),i.vertexIdCallback&&(b.vertexIdCallback=i.vertexIdCallback);for(var v=0;v<d.length;v++)b.addContour(l||2,d[v]);return b.tesselate(e,o,a,l,u,h),{vertices:b.vertices,vertexIndices:b.vertexIndices,vertexCount:b.vertexCount,elements:b.elements,elementCount:b.elementCount,mesh:y?b.mesh:void 0}}}var S5=$e.ODD,w5=$e.NONZERO,P5=$e.POSITIVE,O5=$e.NEGATIVE,T5=$e.ABS_GEQ_TWO,C5=St.POLYGONS,A5=St.CONNECTED_POLYGONS,M5=St.BOUNDARY_CONTOURS;var uo=require("three");var Fu=class{constructor(t=256,e=!1){this.capacity=t,this.size=0,this.debug=e,this.debug&&console.log(`allocating with cap ${t}`);let r=t*Fu.eSize;this.buffer=new ArrayBuffer(r);let o=Float32Array.BYTES_PER_ELEMENT,n=0;this.positions=new Float32Array(this.buffer,n*o,3*t),n+=3*t,this.normals=new Float32Array(this.buffer,n*o,3*t),n+=3*t,this.uvs=new Float32Array(this.buffer,n*o,2*t)}realloc(t,e=!1){if(t<this.size)throw Error("cannot shrink buffer");if(t<=this.capacity&&!e)return;this.debug&&console.log(`resizing from ${this.capacity} \u2192 ${t}`);let r=t*Fu.eSize,o=new ArrayBuffer(r),n=Float32Array.BYTES_PER_ELEMENT,a=0,s=new Float32Array(o,a*n,3*t);a+=3*t;let l=new Float32Array(o,a*n,3*t);a+=3*t;let c=new Float32Array(o,a*n,2*t);e?(s.set(this.positions.subarray(0,this.size*3)),l.set(this.normals.subarray(0,this.size*3)),c.set(this.uvs.subarray(0,this.size*2))):(s.set(this.positions),l.set(this.normals),c.set(this.uvs)),this.buffer=o,this.positions=s,this.normals=l,this.uvs=c,this.capacity=t}get(t=1){let e=this.size+t;if(e>this.capacity){let o=this.capacity;for(;e>o;)o*=2;this.realloc(o)}let r=this.size;return this.size=e,r}reserve(t){let e=this.size+t;e>this.capacity&&this.realloc(e)}shrink(){this.debug&&console.log(`shrinking ${this.capacity} \u2192 ${this.size}`),this.realloc(this.size,!0)}},Cl=Fu;Cl.eSize=(3+3+2)*Float32Array.BYTES_PER_ELEMENT;var Al=class{constructor(t=[],e=(r,o)=>r<o?-1:r>o?1:0){if(this.data=t,this.length=this.data.length,this.compare=e,this.length>0)for(let r=(this.length>>1)-1;r>=0;r--)this._down(r)}push(t){this.data.push(t),this._up(this.length++)}pop(){if(this.length===0)return;let t=this.data[0],e=this.data.pop();return--this.length>0&&(this.data[0]=e,this._down(0)),t}peek(){return this.data[0]}_up(t){let{data:e,compare:r}=this,o=e[t];for(;t>0;){let n=t-1>>1,a=e[n];if(r(o,a)>=0)break;e[t]=a,t=n}e[t]=o}_down(t){let{data:e,compare:r}=this,o=this.length>>1,n=e[t];for(;t<o;){let a=(t<<1)+1,s=a+1;if(s<this.length&&r(e[s],e[a])<0&&(a=s),r(e[a],n)>=0)break;e[t]=e[a],t=a}e[t]=n}};function If(i,t,e=1,r=!1){let o=1/0,n=1/0,a=-1/0,s=-1/0;for(let[v,w]of i[0])v<o&&(o=v),w<n&&(n=w),v>a&&(a=v),w>s&&(s=w);let l=a-o,c=s-n,u=Math.max(e,Math.min(l,c));if(u===e){let v=[o,n];return v.distance=0,v.distance}let p=new Al([],(v,w)=>w.max-v.max),d=XM(i),f=new ju(o+l/2,n+c/2,0,i);f.d>d.d&&(d=f);let h=2;function m(v,w,O){let S=new ju(v,w,O,i);if(h++,S.max>d.d+e&&p.push(S),S.d>d.d&&(d=S,r&&console.log(`found best ${Math.round(1e4*S.d)/1e4} after ${h} probes`),d.d>t))return t}let y=u/2;for(let v=o;v<a;v+=u)for(let w=n;w<s;w+=u)m(v+y,w+y,y);for(;p.length;){let{max:v,x:w,y:O,h:S}=p.pop();if(v-d.d<=e)break;y=S/2,m(w-y,O-y,y),m(w+y,O-y,y),m(w-y,O+y,y),m(w+y,O+y,y)}r&&console.log(`num probes: ${h}
3
+ best distance: ${d.d}`);let b=[d.x,d.y];return b.distance=d.d,b.distance}function ju(i,t,e,r){this.x=i,this.y=t,this.h=e,this.d=$M(i,t,r),this.max=this.d+this.h*Math.SQRT2}function $M(i,t,e){let r=!1,o=1/0;for(let n of e)for(let a=0,s=n.length,l=s-1;a<s;l=a++){let c=n[a],u=n[l];c[1]>t!=u[1]>t&&i<(u[0]-c[0])*(t-c[1])/(u[1]-c[1])+c[0]&&(r=!r),o=Math.min(o,YM(i,t,c,u))}return o===0?0:(r?1:-1)*Math.sqrt(o)}function XM(i){let t=0,e=0,r=0,o=i[0];for(let a=0,s=o.length,l=s-1;a<s;l=a++){let c=o[a],u=o[l],p=c[0]*u[1]-u[0]*c[1];e+=(c[0]+u[0])*p,r+=(c[1]+u[1])*p,t+=p*3}let n=new ju(e/t,r/t,0,i);return t===0||n.d<0?new ju(o[0][0],o[0][1],0,i):n}function YM(i,t,e,r){let o=e[0],n=e[1],a=r[0]-o,s=r[1]-n;if(a!==0||s!==0){let l=((i-o)*a+(t-n)*s)/(a*a+s*s);l>1?(o=r[0],n=r[1]):l>0&&(o+=a*l,n+=s*l)}return a=i-o,s=t-n,a*a+s*s}var Ml={vertices:[160,160,-160,160,-160,-160,160,-160],vertexIndices:[1,0,3,2],vertexCount:4,elements:[0,4],elementCount:1,mesh:void 0},Nf={vertices:[],vertexIndices:[],vertexCount:0,elements:[],elementCount:0,mesh:void 0},Df={vertices:[-160,160,160,-160,160,160,-160,-160],vertexIndices:[1,3,0,2],vertexCount:4,elements:[0,1,2,1,0,3],elementCount:2,mesh:void 0},Ef=(i,t)=>([e,r])=>(r<e&&(r+=t),(i>=e?i:i+t)<=r),Ui=class extends uo.BufferGeometry{constructor(e,r,o=0,n=12,a=3,s=$e.ODD,l=!1){super();this.forPathBevel=l;this.type="ShapeGeometry";this.vertexCache={};this._shape=e,this._depth=r,this._curveSegments=n,this._bevelSegmentsInput=a;let c=this._shape.extractShapePointsToFlatArray([],n),u=this._shape.shapeHoles.map(I=>{let N=I.extractShapePointsToFlatArray([],n),_=[];for(let R=N.length-1;R>=1;R-=2){let V=N[R-1],U=N[R-0];_.push(V,U)}return _}),p=[],d=[];for(let I=0;I<c.length;I+=2)d.push([c[I],c[I+1]]);p.push(d);for(let I=0;I<u.length;I++){let N=u[I],_=[];for(let R=0;R<N.length;R+=2)_.push([N[R],N[R+1]]);p.push(_)}let f;e.isText?f=new uo.Box2().setFromPoints(e.points.map(N=>N.position)).getSize(new uo.Vector2).length()*.1:p[0].length===0?f=o:o>0?f=If(p,o):f=1e-5,o<=0?(this._bevel=0,this._bevelSegments=0):(this._bevel=Math.min(o,f,r/2),this._bevelSegments=Math.floor(a));let h;try{h=co({windingRule:s,elementType:St.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[c]})}catch{h=Ml}let m;try{m=co({windingRule:$e.ODD,elementType:St.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...u]})}catch{m=Nf}if(!h)throw new Error("error generating geometry");let y=h.elementCount;if(m){h.elementCount+=m.elementCount;for(let I=0;I<m.elements.length;I++){let N=m.elements[I],_=I%2===0?h.vertexCount:0;h.elements.push(N+_)}for(let I=0;I<m.vertexIndices.length;I++){let N=m.vertexIndices[I],_=h.vertexCount;h.vertexIndices.push(N+_)}for(let I=0;I<m.vertices.length;I++){let N=m.vertices[I];h.vertices.push(N)}}let b=1/0,v=-1/0,w=1/0,O=-1/0;for(let I=0,N=h.vertexCount;I<N;I++){let _=I*2,R=h.vertices[_+0],V=h.vertices[_+1];R<b&&(b=R),R>v&&(v=R),V<w&&(w=V),V>O&&(O=V)}this._minX=b,this._minY=w,this._width=v-b,this._height=O-w,this._buffer=new Cl(this._computeBufferEstimatedSize(h));let S=[],T=[];for(let I=h.elementCount-1;I>=0;I--){let N=I>=y,_=I*2,R=h.elements[_+0],V=h.elements[_+1],U=R+V,B={start:R,count:V,normals:[],continuous:[],concave:[]},q=R,j=U-1,F=R+1,H=this._shape.roundedCurves.length;do{let re=q-R,K=h.vertices[j*2+0],Z=h.vertices[j*2+1],Q=h.vertices[q*2+0],$=h.vertices[q*2+1],pe=h.vertices[F*2+0],le=h.vertices[F*2+1],ie=Q-K,ue=$-Z,ae=Math.sqrt(ie*ie+ue*ue);ie/=ae,ue/=ae;let ge=Q-pe,me=$-le,ye=Math.sqrt(ge*ge+me*me);ge/=ye,me/=ye,B.normals[re*2+0]=-me,B.normals[re*2+1]=ge,B.concave[re]=ie*me-ue*ge>0;let ve=h.vertexIndices[q];if(Array.isArray(ve))B.continuous[re]=!1;else{let[xe,C]=this._shape.getCurveIndexFromVertexId(ve-1,!0);if(C>0&&C<1)B.continuous[re]=!0;else{let ne=C===1?xe+1:xe-1;ne=(ne+H)%H;let Ve=C===1?0:1,ke=this._shape.roundedCurves[xe].getTangent(C),Ge=this._shape.roundedCurves[ne].getTangent(Ve);B.continuous[re]=ke.dot(Ge)>.95}}N&&(B.normals[re*2+0]*=-1,B.normals[re*2+1]*=-1),[j,q,F]=[q,F,F+1],F>=U&&(F-=V)}while(F!==R+1);let W=[];W.push({bevelI:0,angle:0,size:0,boundary:{vertices:h.vertices.slice(R*2,U*2),vertexCount:V,vertexIndices:new Array(V).fill(!0).map((re,K)=>[K,K]),elements:[0,V],elementCount:1,mesh:null},reverseMap:[],insetPoints:h.vertices.slice(R*2,U*2)});let ee=0;for(let re=1;re<=this._bevelSegments;re++){let K=re/this._bevelSegments*Math.PI/2,Z=(1-Math.cos(K))*this._bevel,Q=[],$=[],pe=[],le=[],ie=0;for(let ae=0;ae<V;ae++){let ge=ae*2,me=(ae-1+V)%V*2,ye=h.vertices[B.start*2+ge+0],ve=h.vertices[B.start*2+ge+1],xe=-B.normals[me+0]*Z,C=-B.normals[me+1]*Z,ne=-B.normals[ge+0]*Z,Ve=-B.normals[ge+1]*Z;if(B.concave[ae]||!B.concave[ae]&&N){let ke=Math.atan2(C,xe),Ge=Math.atan2(Ve,ne);Ge>ke&&(Ge-=Math.PI*2);let Ce=Ge-ke;if(B.continuous[ae]||N){let zt=ke+Ce/2,_e=Math.cos(zt)*Z,Bt=Math.sin(zt)*Z;Q[2*ie+0]=ye+_e*(N?-1:1),Q[2*ie+1]=ve+Bt*(N?-1:1),le[ie]=ae,ie++}else{let zt=Math.max(1,Math.floor(n/4*Math.abs(Ce)/Math.PI));for(let _e=0;_e<=zt;_e++){let Bt=ke+Ce*(_e/zt),Gt=Math.cos(Bt)*Z,pn=Math.sin(Bt)*Z;Q[2*ie+0]=ye+Gt,Q[2*ie+1]=ve+pn,le[ie]=ae,ie++}}}else Q[2*ie+0]=ye+xe,Q[2*ie+1]=ve+C,le[ie]=ae,$[ae]=ie,ie++,Q[2*ie+0]=ye,Q[2*ie+1]=ve,le[ie]=ae,ie++,Q[2*ie+0]=ye+ne,Q[2*ie+1]=ve+Ve,le[ie]=ae,pe[ae]=ie,ie++}let ue=co({windingRule:$e.POSITIVE,elementType:St.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[Q],edgeCreateCallback:ae=>{let me=ae.Org.idx,ye=le[me],ve=le[(me+1)%le.length];ae.idx=[ye,ve],ae.Sym.idx=[ve,ye]},vertexIdCallback:ae=>{let ge=ae.Lprev.idx;return[ge?ge[1]:0,ae.idx?ae.idx[0]:0]}});if(!ue)throw console.log("Error"),new Error(`error generating bevel geometry for ${re}'th loop`);if(!ue.vertexCount){let ae=(re-1)/this._bevelSegments*Math.PI/2;ee=(1-Math.sin(ae))*this._bevel;break}for(let ae=0;ae<ue.vertexIndices.length;ae++){let[ge,me]=ue.vertexIndices[ae];if(ge===me)continue;let ye=me;me<ge&&(ye+=V);for(let ve=ge;ve<ye;ve++){let xe=ve%V,C=(ve+1)%V;if(!B.continuous[xe]||!B.continuous[C]){ue.vertexIndices[ae]=[ge,xe],ue.vertexIndices.splice(ae+1,0,[C,me]),ue.vertices.splice((ae+1)*2,0,ue.vertices[ae*2],ue.vertices[ae*2+1]);break}}}W.push({bevelI:re,angle:K,size:Z,boundary:ue,reverseMap:le,insetPoints:Q})}let te=(re,K,Z)=>{let Q=0,$=re.boundary.vertexIndices.length;for(;Q<$&&Z(re.boundary.vertexIndices[K]);)K=(K+1)%$,Q++;return Q},Y=S.length;for(let re=1;re<W.length;re++){let K=W[re-1],Z=W[re],Q=K.boundary.vertexIndices.length,$=Z.boundary.vertexIndices.length;if(!Q||!$)break;let pe=B.concave.length,le=0,ie=Ef(le,V);for(;!K.boundary.vertexIndices.filter(ie).length||!Z.boundary.vertexIndices.filter(ie).length;)le++,ie=Ef(le,V);let ue=K.boundary.vertexIndices.findIndex(ie),ae=Z.boundary.vertexIndices.findIndex(ie);do ue=(ue+1)%Q;while(ie(K.boundary.vertexIndices[ue]));do ae=(ae+1)%$;while(ie(Z.boundary.vertexIndices[ae]));le=(le+1)%V;let ge=le,me=0,ye=this._buildBevelVert(B,K,(ue-1+Q)%Q,void 0,me),ve=this._buildBevelVert(B,Z,(ae-1+$)%$,void 0,me),xe=ye,C=ve,ne,Ve,ke=!1;do{me=(le||pe)/pe,ie=Ef(le,V);let Ge=te(K,ue,ie),Ce=te(Z,ae,ie),zt=ke;if(ke=!1,Ge&&!Ce){for(let _e=0;_e<Ge;_e++)ne=this._buildBevelVert(B,K,(ue+_e)%Q,_e/(Ge-1),me),S.push(xe.topN,ne.topP,C.topN),l===!1&&S.push(ne.bottomP,xe.bottomN,C.bottomN),xe=ne;ke=!0}else if(!Ge&&Ce)for(let _e=0;_e<Ce;_e++)Ve=this._buildBevelVert(B,Z,(ae+_e)%$,_e/(Ce-1),me),S.push(C.topN,xe.topP,Ve.topP),l===!1&&S.push(xe.bottomP,C.bottomN,Ve.bottomP),C=Ve;else if(Ge&&Ce)if(ne=this._buildBevelVert(B,K,ue,0,me),Ve=this._buildBevelVert(B,Z,ae,0,me),zt?(S.push(xe.topN,Ve.topP,C.topN),S.push(xe.topN,ne.topP,Ve.topP),l===!1&&(S.push(Ve.bottomP,xe.bottomN,C.bottomN),S.push(Ve.bottomP,ne.bottomP,xe.bottomN))):(S.push(C.topN,xe.topN,ne.topP),S.push(C.topN,ne.topP,Ve.topP),l===!1&&(S.push(ne.bottomP,xe.bottomN,C.bottomN),S.push(ne.bottomP,C.bottomN,Ve.bottomP))),xe=ne,C=Ve,Ge===Ce)for(let _e=1;_e<Ge;_e++)ne=this._buildBevelVert(B,K,(ue+_e)%Q,_e/(Ge-1),me),Ve=this._buildBevelVert(B,Z,(ae+_e)%$,_e/(Ce-1),me),S.push(xe.topN,ne.topP,C.topN),S.push(C.topN,ne.topP,Ve.topP),l===!1&&(S.push(ne.bottomP,xe.bottomN,C.bottomN),S.push(ne.bottomP,C.bottomN,Ve.bottomP)),xe=ne,C=Ve;else if(Ge>Ce){let _e=Ge/Ce,Bt=0;for(let Gt=1;Gt<Ge;Gt++)ne=this._buildBevelVert(B,K,(ue+Gt)%Q,Gt/(Ge-1),me),S.push(xe.topN,ne.topP,C.topN),l===!1&&S.push(ne.bottomP,xe.bottomN,C.bottomN),xe=ne,Gt>(Bt+1)*_e&&(Bt++,Ve=this._buildBevelVert(B,Z,(ae+Bt)%$,Bt/(Ce-1),me),S.push(C.topN,ne.topP,Ve.topP),l===!1&&S.push(ne.bottomP,C.bottomN,Ve.bottomP),C=Ve)}else{let _e=Ce/Ge,Bt=0;for(let Gt=1;Gt<Ce;Gt++)Ve=this._buildBevelVert(B,Z,(ae+Gt)%$,Gt/(Ce-1),me),S.push(C.topN,ne.topP,Ve.topP),l===!1&&S.push(ne.bottomP,C.bottomN,Ve.bottomP),C=Ve,Gt>(Bt+1)*_e&&(Bt++,ne=this._buildBevelVert(B,K,(ue+Bt)%Q,Bt/(Ge-1),me),S.push(xe.topN,ne.topP,C.topN),l===!1&&S.push(ne.bottomP,xe.bottomN,C.bottomN),xe=ne)}ue=(ue+Ge)%Q,ae=(ae+Ce)%$,le=(le+1)%pe}while(le!==ge)}if(l===!1&&this._depth>this._bevel*2&&this._buildWall(W,B,S),N){let re=[];for(let K=S.length-1;K>=Y+2;K-=3){let Z=S[K-2],Q=S[K-1],$=S[K-0];re.push($,Q,Z)}S.splice(Y,S.length-Y,...re)}if(N){let re=[];for(let K=W[W.length-1].boundary.vertices.length-1;K>=1;K-=2){let Z=W[W.length-1].boundary.vertices[K-1],Q=W[W.length-1].boundary.vertices[K-0];re.push(Z,Q)}T.push(re)}if(!N){let re=W[W.length-1],K;try{K=co({windingRule:W.length>1?$e.POSITIVE:$e.ODD,elementType:St.POLYGONS,vertexSize:2,strict:!0,contours:[re.insetPoints,...T]})}catch{K=Df}if(!K)throw new Error("Error generating geometry for surface");u.length===0&&this._bevel<f&&Object.assign(this,{useNgonForTopBottomFaceDuringBake:!0});for(let Z=0;Z<K.elementCount*3;Z+=3){let Q=this._buildSurfaceVert(K,K.elements[Z+0],ee),$=this._buildSurfaceVert(K,K.elements[Z+1],ee),pe=this._buildSurfaceVert(K,K.elements[Z+2],ee);S.push(Q.top,$.top,pe.top),l===!1&&S.push(pe.bottom,$.bottom,Q.bottom)}}this.vertexCache={}}this._buffer.shrink();let M=new uo.BufferAttribute(Uint32Array.from(S),1),g=new uo.BufferAttribute(this._buffer.positions,3),D=new uo.BufferAttribute(this._buffer.normals,3),E=new uo.BufferAttribute(this._buffer.uvs,2);g.needsUpdate=!0,D.needsUpdate=!0,E.needsUpdate=!0,M.needsUpdate=!0,this.setAttribute("position",g),this.setAttribute("normal",D),this.setAttribute("uv",E),this.setIndex(M)}_computeBufferEstimatedSize(e){return e.vertexCount*2*(2+this._bevelSegments)}_buildWall(e,r,o){let n=e[0];for(let a=0,s=n.boundary.vertexCount;a<s;a++){let l=this._buildBevelVert(r,n,a),c=this._buildBevelVert(r,n,(a+1)%s);o.push(c.topP,l.topN,l.bottomN),o.push(c.topP,l.bottomN,c.bottomP)}}_buildSurfaceVert(e,r,o){let n=r.toString();if(n in this.vertexCache)return this.vertexCache[n];let a=e.vertices[r*2+0],s=e.vertices[r*2+1],l=(a-this._minX)/this._width,c=(s-this._minY)/this._height;this.forPathBevel&&(c=1);let u=this._buffer.get(this.forPathBevel?1:2),p=u*3,d=u*2,f={top:u+0,bottom:u+1};return this._buffer.positions[p+0]=a,this._buffer.positions[p+1]=s,this._buffer.positions[p+2]=this.forPathBevel?this._bevel:this._depth-o,this._buffer.normals[p+0]=0,this._buffer.normals[p+1]=0,this._buffer.normals[p+2]=1,this._buffer.uvs[d+0]=l,this._buffer.uvs[d+1]=c,this.forPathBevel===!1&&(this._buffer.positions[p+3]=a,this._buffer.positions[p+4]=s,this._buffer.positions[p+5]=o,this._buffer.normals[p+3]=0,this._buffer.normals[p+4]=0,this._buffer.normals[p+5]=-1,this._buffer.uvs[d+2]=l,this._buffer.uvs[d+3]=c),this.vertexCache[n]=f,f}_buildBevelVert(e,r,o,n=1,a){let s=`${r.bevelI}:${o}`;if(s in this.vertexCache&&a!==0&&a!==1&&(!a||a===this.vertexCache[s].pathBevelUCoord))return this.vertexCache[s];let[l,c]=r.boundary.vertexIndices[o],u,p,d,f;l!==c?(p=l,u=c,f=!1,d=e.continuous[p]&&e.continuous[u]):(u=l,p=(u-1+e.count)%e.count,f=e.concave[u]&&r.bevelI>0,d=e.continuous[u]||f);let h=Math.cos(r.angle),m=Math.sin(r.angle),y=o*2,b=u*2,v=p*2,w=r.boundary.vertices[y+0],O=r.boundary.vertices[y+1],S=(1-m)*this._bevel,T=(w-this._minX)/this._width,M=(O-this._minY)/this._height;this.forPathBevel&&(a!==void 0&&(T=a),M=1);let g=e.normals[b+0],D=e.normals[b+1],E=e.normals[v+0],I=e.normals[v+1];if(f){let U=E-g,B=I-D;g=g+U*(1-n),D=D+B*(1-n);let q=Math.sqrt(g*g+D*D);g/=q,D/=q}let N=this.forPathBevel?this._buffer.get(d?1:2):this._buffer.get(d?2:4),_=N*3,R=N*2,V={i:o,fi:u,topP:N+0,topN:N+0,bottomP:N+1,bottomN:N+1,pathBevelUCoord:a};return this._buffer.positions[_+0]=w,this._buffer.positions[_+1]=O,this._buffer.positions[_+2]=(this.forPathBevel?this._bevel:this._depth)-S,this._buffer.normals[_+0]=g*h,this._buffer.normals[_+1]=D*h,this._buffer.normals[_+2]=m,this._buffer.uvs[R+0]=T,this._buffer.uvs[R+1]=M,this.forPathBevel===!1&&(this._buffer.positions[_+3]=w,this._buffer.positions[_+4]=O,this._buffer.positions[_+5]=S,this._buffer.normals[_+3]=g*h,this._buffer.normals[_+4]=D*h,this._buffer.normals[_+5]=-m,this._buffer.uvs[R+2]=M,this._buffer.uvs[R+3]=T),d||(this.forPathBevel?(N+=1,_+=3,R+=2):(N+=2,_+=6,R+=4),V.topP=N+0,V.bottomP=N+1,this._buffer.positions[_+0]=w,this._buffer.positions[_+1]=O,this._buffer.positions[_+2]=(this.forPathBevel?this._bevel:this._depth)-S,this._buffer.normals[_+0]=E*h,this._buffer.normals[_+1]=I*h,this._buffer.normals[_+2]=m,this._buffer.uvs[R+0]=T,this._buffer.uvs[R+1]=M,this.forPathBevel===!1&&(this._buffer.positions[_+3]=w,this._buffer.positions[_+4]=O,this._buffer.positions[_+5]=S,this._buffer.normals[_+3]=E*h,this._buffer.normals[_+4]=I*h,this._buffer.normals[_+5]=-m,this._buffer.uvs[R+2]=M,this._buffer.uvs[R+3]=T)),this.vertexCache[s]=V,V}clone(){let e=new Ui(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=Zo(this.userData),e}};var qa=class extends Mn.BufferGeometry{constructor(e,r=12,o={}){super();this.type="ShapeGeometry";this.windingRule=$e.ODD;this.elementType=St.POLYGONS;this.polySize=3;this.vertexSize=2;this.strict=!0;this._shape=e,this._curveSegments=r,this._triangulationOptions=Object.assign({windingRule:$e.ODD,elementType:St.POLYGONS,polySize:3,vertexSize:2,strict:!0},o);let n=this._shape.extractShapePointsToFlatArray([],this._curveSegments),a=this._shape.shapeHoles.map(h=>h.extractShapePointsToFlatArray([],this._curveSegments)),s,l=!0,c=!0,u,p;for(let h=0,m=n.length/2;h<m;h++){let y=h*2,b=n[y+0],v=n[y+1];if(u!==void 0&&b!==u&&(l=!1),p!==void 0&&v!==p&&(c=!1),u=b,p=v,!l&&!c)break}if(!l&&!c)try{s=co({contours:[n,...a],windingRule:this._triangulationOptions.windingRule,elementType:this._triangulationOptions.elementType,polySize:this._triangulationOptions.polySize,vertexSize:this._triangulationOptions.vertexSize,strict:this._triangulationOptions.strict})}catch{s=Ml}let d=s?.vertexCount??1,f=s?.elementCount??1;if(this._positionAttribute=new Mn.BufferAttribute(new Float32Array(d*3),3),this._normalAttribute=new Mn.BufferAttribute(new Float32Array(d*3),3),this._uvAttribute=new Mn.BufferAttribute(new Float32Array(d*2),2),this._indexAttribute=new Mn.BufferAttribute(new Uint32Array(f*3),1),s){let h=1/0,m=-1/0,y=1/0,b=-1/0;for(let O=0,S=d;O<S;O++){let T=O*2,M=s.vertices[T+0],g=s.vertices[T+1];M<h&&(h=M),M>m&&(m=M),g<y&&(y=g),g>b&&(b=g)}let v=m-h,w=b-y;for(let O=0,S=d;O<S;O++){let T=O*2,M=s.vertices[T+0],g=s.vertices[T+1],D=(M-h)/v,E=(g-y)/w;this._positionAttribute.setXYZ(O,M,g,0),this._normalAttribute.setXYZ(O,0,0,1),this._uvAttribute.setXY(O,D,E)}for(let O=0,S=f;O<S;O++){let T=O*3,M=s.elements[T+0],g=s.elements[T+1],D=s.elements[T+2];this._indexAttribute.setX(T+0,M),this._indexAttribute.setX(T+1,g),this._indexAttribute.setX(T+2,D)}}this.setAttribute("position",this._positionAttribute),this.setAttribute("normal",this._normalAttribute),this.setAttribute("uv",this._uvAttribute),this.setIndex(this._indexAttribute),this.setDrawRange(0,(s?.elementCount??1)*3)}clone(){let e=new qa(this._shape,this._curveSegments);return e.userData=Zo(this.userData),e}};var $a=class extends Ui{constructor(e,r,o=0,n=12,a=3,s=$e.ODD){super(e,r,o,n,a,s);this.type="ShapeGeometry"}_computeBufferEstimatedSize(e){return e.vertexCount*2*(2+this._bevelSegments)}_buildWall(e,r,o){let n=e[0];for(let a=0,s=n.boundary.vertexCount;a<s;a++){let l=this._buildBevelVert(r,n,a),c=this._buildBevelVert(r,n,(a+1)%s);o.push(c.topP,l.topN,l.bottomN),o.push(c.topP,l.bottomN,c.bottomP)}}clone(){let e=new $a(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=Zo(this.userData),e}};var wr=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,subdivisions:40,roundness:0,extrudeBevelSize:0,extrudeBevelSegments:3,windingRule:$e.ODD},i.parameters),r=Math.abs(e.width),o=Math.abs(e.height??e.width),n=Math.abs(e.depth??0),a=i.shape??t?.shape,s=a?.roundness??e.roundness;a!==void 0&&(a instanceof Xe?(a.width!==r||a.height!==o)&&a.applySize(r,o):a=new Xe(r,o).fromJSON(a),i.parameters?.roundness!==void 0&&i.parameters?.roundness>0&&a.update());let l=a??new Xe(r,o);return{parameters:Object.assign(e,{width:r,height:o,depth:n,roundness:s}),shape:l}}static build(i){let{depth:t,extrudeBevelSize:e,extrudeBevelSegments:r,subdivisions:o,roundness:n,windingRule:a}=i.parameters;i.shape.roundness=n;let s;return t<=0?s=new qa(i.shape,o,{windingRule:a}):s=new $a(i.shape,t,e,o,r,a),Object.assign(s,{userData:{...i,type:"VectorGeometry"}})}};var po=require("three"),Lx=Math.PI*2,Ya=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,spikes:64,angle:360,innerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1},i.parameters);return e.angle=po.MathUtils.clamp(e.angle,0,360),{shape:i.shape&&i.shape instanceof Xe?i.shape:new Xe,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)})}}static build(i){let{width:t,height:e,spikes:r,angle:o,innerRadius:n,depth:a,extrudeBevelSize:s,extrudeBevelSegments:l}=i.parameters,c=i.shape,u=t*.5,p=e*.5,d=KM(c,u,p,o*Math.PI/180,r,n);c.isClosed=!0,c.update();let f;return o===0?(f=new po.BufferGeometry,f.setAttribute("position",new po.Float32BufferAttribute([],3))):f=wr.create({shape:c,parameters:{subdivisions:d,depth:a,extrudeBevelSize:s,extrudeBevelSegments:l}}),Object.assign(f,{userData:{...i,type:"EllipseGeometry"}})}};function KM(i,t,e,r,o,n){if(r>=Lx)return o>30||o%4===0?(ZM(i,t,e,n),Math.round(o/4)):Rx(i,r,o,t,e,n);r=Math.max(r,.001);let a={x:0,y:e},s=r+Math.PI*.5,l={x:Math.cos(s)*t,y:Math.sin(s)*e},c=Ix({px:a.x,py:a.y,cx:l.x,cy:l.y,rx:t,ry:e,largeArcFlag:r>Math.PI,sweepFlag:!0});return o>30||o%c.length===0?QM(i,a.x,a.y,c,o,t,e,n):Rx(i,r,o,t,e,n)}function QM(i,t,e,r,o,n,a,s){let l=Math.round(o/r.length);i.addPoint(Xa(t,e));for(let c=0,u=r.length;c<u;c++){let p=r[c],d=i.points[c],f=Xa(p.x,p.y);d.controls[1].position.set(p.x1,p.y1),f.controls[0].position.set(p.x2,p.y2),i.addPoint(f)}return s>0?Bx(i,n,a,s):i.addPoint(Xa(0,0)),l}function Rx(i,t,e,r,o,n){let a=-t/e;for(let s=0;s<=e;s++){let l=a*s,c=Math.sin(l)*r,u=Math.cos(l)*o;i.addPoint(Xa(c,u))}return t<Lx?n>0?Bx(i,r,o,n):i.addPoint(Xa(0,0)):(i.removePoint(i.points[i.points.length-1]),n>0&&Vx(i,r,o,n)),1}function ZM(i,t,e,r=0,o=0,n=0){let a=.5522847498,s=t*a,l=e*a;i.addPoint(Uu(o-t,n,o-t,n-l,o-t,n+l)),i.addPoint(Uu(o,n+e,o-s,n+e,o+s,n+e)),i.addPoint(Uu(o+t,n,o+t,n+l,o+t,n-l)),i.addPoint(Uu(o,n-e,o+s,n-e,o-s,n-e)),r>0&&Vx(i,t,e,r)}function Xa(i,t){return new lo(po.MathUtils.generateUUID(),new po.Vector2(i,t))}function Uu(i,t,e,r,o,n){let a=Xa(i,t);return a.controls[0].position.set(e,r),a.controls[1].position.set(o,n),a}function Bx(i,t,e,r){zx(i,t,e,r).forEach(n=>i.addPoint(n))}function Vx(i,t,e,r){let o=zx(i,t,e,r),n=new Xe;o.forEach(a=>n.addPoint(a)),n.isClosed=!0,i.shapeHoles.push(n)}function zx(i,t,e,r){let o=r*t/100,n=o*(Math.abs(e)/Math.abs(t)),a=new po.Vector2(o/t,n/e),s=i.points.map(l=>{let c=l.clone();return c.uuid=po.MathUtils.generateUUID(),c}).reverse();return s.forEach(l=>{l.position.multiply(a);let c=l.controls[0].position.clone().multiply(a),u=l.controls[1].position.clone().multiply(a);l.controls[0].position.copy(u),l.controls[1].position.copy(c)}),s}var fo=require("three"),Gx=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,revolutions:2,segments:40,pathRadius:10,pathType:0,pathSegments:30,cornerRadius:30,cornerSegments:4},i.parameters),r=Math.abs(e.width),o=Math.abs(e.height??r),n=Math.abs(e.depth??r),a=Math.abs(Math.min(r,n))/2;return{parameters:Object.assign(e,{width:r,height:o,depth:n,radius:a,segments:Math.round(e.segments),pathSegments:Math.round(e.pathSegments),cornerSegments:Math.round(e.cornerSegments)})}}static build(i){let{width:t,height:e,depth:r,radius:o,revolutions:n,segments:a,pathRadius:s,pathType:l,pathSegments:c,cornerRadius:u,cornerSegments:p}=i.parameters,d=new Il(!1,t,e,r,o,n,a,s,l,c,u,p);return Object.assign(d,{userData:{...i,type:"HelixGeometry"}})}},_f=new fo.Uint32BufferAttribute([0,0,0],1),Il=class extends fo.BufferGeometry{constructor(t=!0,e=1,r=1,o=1,n=1,a=1,s=1,l=1,c=1,u=1,p=1,d=1){if(super(),a===0)return;let f=t&&a===1;f&&(d=0),p>100&&(p=100),p===0&&(d=0);let h=()=>new fo.Vector3,m=new fo.Vector3,y=h(),b=h(),v=h(),w,O,S,T,M,g,D,E,I=h(),N=h(),_=h(),R=h(),V=h(),U=h(),B=h(),q=h(),j=r-2*l+.001,F=j/a,H=Math.ceil(s*a),W=H+1,ee=j/H,te=-j/2,Y=u+1,re=2*Math.PI/u,K=Math.PI/2/d,Z=.01,Q=Math.min((1-p/100)*l,l-Z),$=l-Q,pe=0,le=2,ie=d*le+le,ue=Y*ie/le,ae=ue+Y*W,ge=Math.max(0,Y*(W+ie)),[me,ye,ve]=[3,3,2].map(xt=>Array(ge*xt).fill(0)),xe=[],C=n-l;function ne(xt,at){let to=Math.PI/2;g=at*ee,E=2*Math.PI*(g%F)/F+to,g+=te,D=Math.sin(E)*C,M=Math.cos(E)*C,t?xt.set(M,D,g):xt.set(M,g,D)}ne(m,-1e-10),ne(y,0),I.copy(m),ne(m,1);let Ve=m.distanceTo(y),ke=f?0:$+Q,Ge=Ve*H+2*ke,Ce=Q,zt=Ge-ke;for(let xt=0;xt<=H;xt++){ne(b,xt),q.subVectors(b,I).normalize(),I.copy(b),U.copy(b).setComponent(+t+1,0).normalize(),B.crossVectors(q,U).normalize();let at=xt===0,to=xt===H,cp=at?3*Math.PI/2:K,up=at?Ce:zt,hc=at?Y:ae,fn=at?0:ge-Y,Ot=q.clone().multiplyScalar(at?-$:$).add(b),dp=q.clone().multiplyScalar(at?-1:1).normalize();for(let zr=0;zr<Y;zr++){let Zs=zr*re;if(N.addVectors(m.copy(U).multiplyScalar(l*Math.cos(Zs)),y.copy(B).multiplyScalar(l*Math.sin(Zs))),_.copy(N).normalize(),at||to){f||(pe=fn+zr,[0,1,2].forEach(cr=>{me[pe*3+cr]=Ot.getComponent(cr),ye[pe*3+cr]=dp.getComponent(cr)}),ve[pe*2]=+to,ve[pe*2+1]=zr/u),y.copy(_).multiplyScalar(Q),v.addVectors(b,y);for(let cr=0;cr<d;cr++){let hn=cr*K+cp;R.addVectors(m.copy(q).multiplyScalar($*Math.sin(hn)),y.copy(_).multiplyScalar($*Math.cos(hn))),V.copy(R).normalize(),y.addVectors(v,R),R.normalize(),pe=hc+cr*Y+zr,[0,1,2].forEach(qn=>{me[pe*3+qn]=y.getComponent(qn),ye[pe*3+qn]=V.getComponent(qn)});let mc=+at+Math.sin(hn);ve[pe*2]=(up+$*mc)/Ge,ve[pe*2+1]=zr/u}}y.addVectors(b,N),pe=ue+xt*Y+zr,[0,1,2].forEach(cr=>{me[pe*3+cr]=y.getComponent(cr),ye[pe*3+cr]=_.getComponent(cr)}),ve[pe*2]=(ke+xt*Ve)/Ge,ve[pe*2+1]=zr/u}}let _e=W+2*d+le,Bt=1,[Gt,pn]=[+f,_e-1];for(let xt=Gt;xt<=pn-1;xt++){let at=f&&xt===pn-1;for(let to=0;to<Y-1;to++)w=xt*Y+to,O=w+1,S=(at?to:w)+Y,T=(at?to+1:O)+Y,xt===0?xe.push(O,T,S):xt===_e-2?xe.push(w,O,S):xe.push(w,O,S,O,T,S)}this.setIndex(xe),this.setAttribute("position",new fo.Float32BufferAttribute(me,3)),this.setAttribute("normal",new fo.Float32BufferAttribute(ye,3)),this.setAttribute("uv",new fo.Float32BufferAttribute(ve,2))}getClosedTorusIndicesForBooleanOrSubdiv(){let t=this.userData.parameters,e=Math.ceil(t.tubularSegments),r=t.radialSegments+1,o=Array.from(this.getIndex().array),n,a,s,l,c=6*(e-1)*t.radialSegments,u=e,p=u===e;for(let d=0;d<t.radialSegments;d++)n=u*r+d,a=n+1,s=(p?d:n)+r,l=(p?d+1:a)+r,o[c++]=n,o[c++]=a,o[c++]=s,o[c++]=a,o[c++]=l,o[c++]=s;return o.length=c,_f.array=o,_f.count=o.length,_f}};var Fx=require("three");var jx=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,detail:0,corner:0,cornerSides:4},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(i){let{width:t,height:e,depth:r,detail:o,corner:n,cornerSides:a}=i.parameters,s=o===0&&n!==0?new El(t*.5,n,a):new Fx.IcosahedronGeometry(t*.5,o);return s.scale(1,e/t,r/t),Object.assign(s,{userData:{...i,type:"IcosahedronGeometry"}})}},El=class extends Fi{constructor(t=1,e=.2,r=4){let o=(1+Math.sqrt(5))/2,n=[-1,o,0,1,o,0,-1,-o,0,1,-o,0,0,-1,o,0,1,o,0,-1,-o,0,1,-o,o,0,-1,o,0,1,-o,0,-1,-o,0,1],a=[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],s="IcosahedronGeometry";super(n,a,s,t,e,r),this.type=s}static fromJSON(t){return new El(t.radius,t.corner,t.cornerSides)}};var ku=require("three"),Ux=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){(i.parameters?.points??[]).forEach(r=>{Array.isArray(r)&&(r.x=r[0],r.y=r[1])});let e=Object.assign({},t?.parameters??{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(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(i){let{points:t,segments:e,verticalSegments:r}=i.parameters,o=new ku.Shape;o.moveTo(t[0].x,t[0].y),o.bezierCurveTo(t[1].x,t[1].y,t[2].x,t[2].y,t[3].x,t[3].y);let n=new ku.LatheGeometry(o.extractPoints(r).shape,e);return n.rotateZ(Math.PI),Object.assign(n,{userData:{...i,type:"LatheGeometry"}})}};var Ro=require("three");var li=require("three");var he=require("three"),_o=new he.Matrix4,Rf=new he.Object3D,Hu=new he.Vector3,ki=class extends he.EventDispatcher{constructor(){super(),this.uuid=he.MathUtils.generateUUID(),this.name="",this.type="Geometry",this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.elementsNeedUpdate=!1,this.verticesNeedUpdate=!1,this.uvsNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.lineDistancesNeedUpdate=!1,this.groupsNeedUpdate=!1}applyMatrix4(t){let e=new he.Matrix3().getNormalMatrix(t);for(let r=0,o=this.vertices.length;r<o;r++)this.vertices[r].applyMatrix4(t);for(let r=0,o=this.faces.length;r<o;r++){let n=this.faces[r];n.normal.applyMatrix3(e).normalize();for(let a=0,s=n.vertexNormals.length;a<s;a++)n.vertexNormals[a].applyMatrix3(e).normalize()}return this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this.verticesNeedUpdate=!0,this.normalsNeedUpdate=!0,this}rotateX(t){return _o.makeRotationX(t),this.applyMatrix4(_o),this}rotateY(t){return _o.makeRotationY(t),this.applyMatrix4(_o),this}rotateZ(t){return _o.makeRotationZ(t),this.applyMatrix4(_o),this}translate(t,e,r){return _o.makeTranslation(t,e,r),this.applyMatrix4(_o),this}scale(t,e,r){return _o.makeScale(t,e,r),this.applyMatrix4(_o),this}lookAt(t){return Rf.lookAt(t),Rf.updateMatrix(),this.applyMatrix4(Rf.matrix),this}fromBufferGeometry(t){let e=this,r=t.index!==null?t.index:void 0,o=t.attributes;if(o.position===void 0)return console.error("THREE.Geometry.fromBufferGeometry(): Position attribute required for conversion."),this;let n=o.position,a=o.normal,s=o.color,l=o.uv,c=o.uv2;c!==void 0&&(this.faceVertexUvs[1]=[]);for(let d=0;d<n.count;d++)e.vertices.push(new he.Vector3().fromBufferAttribute(n,d)),s!==void 0&&e.colors.push(new he.Color().fromBufferAttribute(s,d));function u(d,f,h,m){let y=s===void 0?[]:[e.colors[d].clone(),e.colors[f].clone(),e.colors[h].clone()],b=a===void 0?[]:[new he.Vector3().fromBufferAttribute(a,d),new he.Vector3().fromBufferAttribute(a,f),new he.Vector3().fromBufferAttribute(a,h)],v=new Ka(d,f,h,b,y,m);e.faces.push(v),l!==void 0&&e.faceVertexUvs[0].push([new he.Vector2().fromBufferAttribute(l,d),new he.Vector2().fromBufferAttribute(l,f),new he.Vector2().fromBufferAttribute(l,h)]),c!==void 0&&e.faceVertexUvs[1].push([new he.Vector2().fromBufferAttribute(c,d),new he.Vector2().fromBufferAttribute(c,f),new he.Vector2().fromBufferAttribute(c,h)])}let p=t.groups;if(p.length>0)for(let d=0;d<p.length;d++){let f=p[d],h=f.start,m=f.count;for(let y=h,b=h+m;y<b;y+=3)r!==void 0?u(r.getX(y),r.getX(y+1),r.getX(y+2),f.materialIndex):u(y,y+1,y+2,f.materialIndex)}else if(r!==void 0)for(let d=0;d<r.count;d+=3)u(r.getX(d),r.getX(d+1),r.getX(d+2));else for(let d=0;d<n.count;d+=3)u(d,d+1,d+2);return this.computeFaceNormals(),t.boundingBox!==null&&(this.boundingBox=t.boundingBox.clone()),t.boundingSphere!==null&&(this.boundingSphere=t.boundingSphere.clone()),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Hu).negate(),this.translate(Hu.x,Hu.y,Hu.z),this}normalize(){this.computeBoundingSphere();let t=this.boundingSphere.center,e=this.boundingSphere.radius,r=e===0?1:1/e,o=new he.Matrix4;return o.set(r,0,0,-r*t.x,0,r,0,-r*t.y,0,0,r,-r*t.z,0,0,0,1),this.applyMatrix4(o),this}computeFaceNormals(){let t=new he.Vector3,e=new he.Vector3;for(let r=0,o=this.faces.length;r<o;r++){let n=this.faces[r],a=this.vertices[n.a],s=this.vertices[n.b],l=this.vertices[n.c];t.subVectors(l,s),e.subVectors(a,s),t.cross(e),t.normalize(),n.normal.copy(t)}}computeVertexNormals(t=!0){let e=new Array(this.vertices.length);for(let r=0,o=this.vertices.length;r<o;r++)e[r]=new he.Vector3;if(t){let r=new he.Vector3,o=new he.Vector3;for(let n=0,a=this.faces.length;n<a;n++){let s=this.faces[n],l=this.vertices[s.a],c=this.vertices[s.b],u=this.vertices[s.c];r.subVectors(u,c),o.subVectors(l,c),r.cross(o),e[s.a].add(r),e[s.b].add(r),e[s.c].add(r)}}else{this.computeFaceNormals();for(let r=0,o=this.faces.length;r<o;r++){let n=this.faces[r];e[n.a].add(n.normal),e[n.b].add(n.normal),e[n.c].add(n.normal)}}for(let r=0,o=this.vertices.length;r<o;r++)e[r].normalize();for(let r=0,o=this.faces.length;r<o;r++){let n=this.faces[r],a=n.vertexNormals;a.length===3?(a[0].copy(e[n.a]),a[1].copy(e[n.b]),a[2].copy(e[n.c])):(a[0]=e[n.a].clone(),a[1]=e[n.b].clone(),a[2]=e[n.c].clone())}this.faces.length>0&&(this.normalsNeedUpdate=!0)}computeFlatVertexNormals(){this.computeFaceNormals();for(let t=0,e=this.faces.length;t<e;t++){let r=this.faces[t],o=r.vertexNormals;o.length===3?(o[0].copy(r.normal),o[1].copy(r.normal),o[2].copy(r.normal)):(o[0]=r.normal.clone(),o[1]=r.normal.clone(),o[2]=r.normal.clone())}this.faces.length>0&&(this.normalsNeedUpdate=!0)}computeMorphNormals(){for(let e=0,r=this.faces.length;e<r;e++){let o=this.faces[e];o.__originalFaceNormal?o.__originalFaceNormal.copy(o.normal):o.__originalFaceNormal=o.normal.clone(),o.__originalVertexNormals||(o.__originalVertexNormals=[]);for(let n=0,a=o.vertexNormals.length;n<a;n++)o.__originalVertexNormals[n]?o.__originalVertexNormals[n].copy(o.vertexNormals[n]):o.__originalVertexNormals[n]=o.vertexNormals[n].clone()}let t=new ki;t.faces=this.faces;for(let e=0,r=this.morphTargets.length;e<r;e++){if(!this.morphNormals[e]){this.morphNormals[e]={},this.morphNormals[e].faceNormals=[],this.morphNormals[e].vertexNormals=[];let n=this.morphNormals[e].faceNormals,a=this.morphNormals[e].vertexNormals;for(let s=0,l=this.faces.length;s<l;s++){let c=new he.Vector3,u={a:new he.Vector3,b:new he.Vector3,c:new he.Vector3};n.push(c),a.push(u)}}let o=this.morphNormals[e];t.vertices=this.morphTargets[e].vertices,t.computeFaceNormals(),t.computeVertexNormals();for(let n=0,a=this.faces.length;n<a;n++){let s=this.faces[n],l=o.faceNormals[n],c=o.vertexNormals[n];l.copy(s.normal),c.a.copy(s.vertexNormals[0]),c.b.copy(s.vertexNormals[1]),c.c.copy(s.vertexNormals[2])}}for(let e=0,r=this.faces.length;e<r;e++){let o=this.faces[e];o.normal=o.__originalFaceNormal,o.vertexNormals=o.__originalVertexNormals}}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new he.Box3),this.boundingBox.setFromPoints(this.vertices)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new he.Sphere),this.boundingSphere.setFromPoints(this.vertices)}merge(t,e,r=0){if(!(t&&t.isGeometry)){console.error("THREE.Geometry.merge(): geometry not an instance of THREE.Geometry.",t);return}let o,n=this.vertices.length,a=this.vertices,s=t.vertices,l=this.faces,c=t.faces,u=this.colors,p=t.colors;e!==void 0&&(o=new he.Matrix3().getNormalMatrix(e));for(let d=0,f=s.length;d<f;d++){let m=s[d].clone();e!==void 0&&m.applyMatrix4(e),a.push(m)}for(let d=0,f=p.length;d<f;d++)u.push(p[d].clone());for(let d=0,f=c.length;d<f;d++){let h=c[d],m,y,b=h.vertexNormals,v=h.vertexColors,w=new Ka(h.a+n,h.b+n,h.c+n);w.normal.copy(h.normal),o!==void 0&&w.normal.applyMatrix3(o).normalize();for(let O=0,S=b.length;O<S;O++)m=b[O].clone(),o!==void 0&&m.applyMatrix3(o).normalize(),w.vertexNormals.push(m);w.color.copy(h.color);for(let O=0,S=v.length;O<S;O++)y=v[O],w.vertexColors.push(y.clone());w.materialIndex=h.materialIndex+r,l.push(w)}for(let d=0,f=t.faceVertexUvs.length;d<f;d++){let h=t.faceVertexUvs[d];this.faceVertexUvs[d]===void 0&&(this.faceVertexUvs[d]=[]);for(let m=0,y=h.length;m<y;m++){let b=h[m],v=[];for(let w=0,O=b.length;w<O;w++)v.push(b[w].clone());this.faceVertexUvs[d].push(v)}}}mergeMesh(t){if(!(t&&t.isMesh)){console.error("THREE.Geometry.mergeMesh(): mesh not an instance of THREE.Mesh.",t);return}t.matrixAutoUpdate&&t.updateMatrix(),this.merge(t.geometry,t.matrix)}mergeVertices(t=4){let e={},r=[],o=[],n=Math.pow(10,t);for(let l=0,c=this.vertices.length;l<c;l++){let u=this.vertices[l],p=Math.round(u.x*n)+"_"+Math.round(u.y*n)+"_"+Math.round(u.z*n);e[p]===void 0?(e[p]=l,r.push(this.vertices[l]),o[l]=r.length-1):o[l]=o[e[p]]}let a=[];for(let l=0,c=this.faces.length;l<c;l++){let u=this.faces[l];u.a=o[u.a],u.b=o[u.b],u.c=o[u.c];let p=[u.a,u.b,u.c];for(let d=0;d<3;d++)if(p[d]===p[(d+1)%3]){a.push(l);break}}for(let l=a.length-1;l>=0;l--){let c=a[l];this.faces.splice(c,1);for(let u=0,p=this.faceVertexUvs.length;u<p;u++)this.faceVertexUvs[u].splice(c,1)}let s=this.vertices.length-r.length;return this.vertices=r,s}setFromPoints(t){this.vertices=[];for(let e=0,r=t.length;e<r;e++){let o=t[e];this.vertices.push(new he.Vector3(o.x,o.y,o.z||0))}return this}sortFacesByMaterialIndex(){let t=this.faces,e=t.length;for(let l=0;l<e;l++)t[l]._id=l;function r(l,c){return l.materialIndex-c.materialIndex}t.sort(r);let o=this.faceVertexUvs[0],n=this.faceVertexUvs[1],a,s;o&&o.length===e&&(a=[]),n&&n.length===e&&(s=[]);for(let l=0;l<e;l++){let c=t[l]._id;a&&a.push(o[c]),s&&s.push(n[c])}a&&(this.faceVertexUvs[0]=a),s&&(this.faceVertexUvs[1]=s)}toJSON(){let t={metadata:{version:4.5,type:"Geometry",generator:"Geometry.toJSON"}};if(t.uuid=this.uuid,t.type=this.type,this.name!==""&&(t.name=this.name),this.parameters!==void 0){let h=this.parameters;for(let m in h)h[m]!==void 0&&(t[m]=h[m]);return t}let e=[];for(let h=0;h<this.vertices.length;h++){let m=this.vertices[h];e.push(m.x,m.y,m.z)}let r=[],o=[],n={},a=[],s={},l=[],c={};for(let h=0;h<this.faces.length;h++){let m=this.faces[h],y=!0,b=!1,v=this.faceVertexUvs[0][h]!==void 0,w=m.normal.length()>0,O=m.vertexNormals.length>0,S=m.color.r!==1||m.color.g!==1||m.color.b!==1,T=m.vertexColors.length>0,M=0;if(M=u(M,0,0),M=u(M,1,y),M=u(M,2,b),M=u(M,3,v),M=u(M,4,w),M=u(M,5,O),M=u(M,6,S),M=u(M,7,T),r.push(M),r.push(m.a,m.b,m.c),r.push(m.materialIndex),v){let g=this.faceVertexUvs[0][h];r.push(f(g[0]),f(g[1]),f(g[2]))}if(w&&r.push(p(m.normal)),O){let g=m.vertexNormals;r.push(p(g[0]),p(g[1]),p(g[2]))}if(S&&r.push(d(m.color)),T){let g=m.vertexColors;r.push(d(g[0]),d(g[1]),d(g[2]))}}function u(h,m,y){return y?h|1<<m:h&~(1<<m)}function p(h){let m=h.x.toString()+h.y.toString()+h.z.toString();return n[m]!==void 0||(n[m]=o.length/3,o.push(h.x,h.y,h.z)),n[m]}function d(h){let m=h.r.toString()+h.g.toString()+h.b.toString();return s[m]!==void 0||(s[m]=a.length,a.push(h.getHex())),s[m]}function f(h){let m=h.x.toString()+h.y.toString();return c[m]!==void 0||(c[m]=l.length/2,l.push(h.x,h.y)),c[m]}return t.data={},t.data.vertices=e,t.data.normals=o,a.length>0&&(t.data.colors=a),l.length>0&&(t.data.uvs=[l]),t.data.faces=r,t}clone(){return new ki().copy(this)}copy(t){this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.name=t.name;let e=t.vertices;for(let d=0,f=e.length;d<f;d++)this.vertices.push(e[d].clone());let r=t.colors;for(let d=0,f=r.length;d<f;d++)this.colors.push(r[d].clone());let o=t.faces;for(let d=0,f=o.length;d<f;d++)this.faces.push(o[d].clone());for(let d=0,f=t.faceVertexUvs.length;d<f;d++){let h=t.faceVertexUvs[d];this.faceVertexUvs[d]===void 0&&(this.faceVertexUvs[d]=[]);for(let m=0,y=h.length;m<y;m++){let b=h[m],v=[];for(let w=0,O=b.length;w<O;w++){let S=b[w];v.push(S.clone())}this.faceVertexUvs[d].push(v)}}let n=t.morphTargets;for(let d=0,f=n.length;d<f;d++){let h={};if(h.name=n[d].name,n[d].vertices!==void 0){h.vertices=[];for(let m=0,y=n[d].vertices.length;m<y;m++)h.vertices.push(n[d].vertices[m].clone())}if(n[d].normals!==void 0){h.normals=[];for(let m=0,y=n[d].normals.length;m<y;m++)h.normals.push(n[d].normals[m].clone())}this.morphTargets.push(h)}let a=t.morphNormals;for(let d=0,f=a.length;d<f;d++){let h={};if(a[d].vertexNormals!==void 0){h.vertexNormals=[];for(let m=0,y=a[d].vertexNormals.length;m<y;m++){let b=a[d].vertexNormals[m],v={};v.a=b.a.clone(),v.b=b.b.clone(),v.c=b.c.clone(),h.vertexNormals.push(v)}}if(a[d].faceNormals!==void 0){h.faceNormals=[];for(let m=0,y=a[d].faceNormals.length;m<y;m++)h.faceNormals.push(a[d].faceNormals[m].clone())}this.morphNormals.push(h)}let s=t.skinWeights;for(let d=0,f=s.length;d<f;d++)this.skinWeights.push(s[d].clone());let l=t.skinIndices;for(let d=0,f=l.length;d<f;d++)this.skinIndices.push(l[d].clone());let c=t.lineDistances;for(let d=0,f=c.length;d<f;d++)this.lineDistances.push(c[d]);let u=t.boundingBox;u!==null&&(this.boundingBox=u.clone());let p=t.boundingSphere;return p!==null&&(this.boundingSphere=p.clone()),this.elementsNeedUpdate=t.elementsNeedUpdate,this.verticesNeedUpdate=t.verticesNeedUpdate,this.uvsNeedUpdate=t.uvsNeedUpdate,this.normalsNeedUpdate=t.normalsNeedUpdate,this.colorsNeedUpdate=t.colorsNeedUpdate,this.lineDistancesNeedUpdate=t.lineDistancesNeedUpdate,this.groupsNeedUpdate=t.groupsNeedUpdate,this}toBufferGeometry(){let t=new Lf().fromGeometry(this),e=new he.BufferGeometry,r=new Float32Array(t.vertices.length*3);if(e.setAttribute("position",Wu.call(new he.BufferAttribute(r,3),t.vertices)),t.normals.length>0){let o=new Float32Array(t.normals.length*3);e.setAttribute("normal",Wu.call(new he.BufferAttribute(o,3),t.normals))}if(t.colors.length>0){let o=new Float32Array(t.colors.length*3);e.setAttribute("color",kx.call(new he.BufferAttribute(o,3),t.colors))}if(t.uvs.length>0){let o=new Float32Array(t.uvs.length*2);e.setAttribute("uv",Hx.call(new he.BufferAttribute(o,2),t.uvs))}if(t.uvs2.length>0){let o=new Float32Array(t.uvs2.length*2);e.setAttribute("uv2",Hx.call(new he.BufferAttribute(o,2),t.uvs2))}e.groups=t.groups;for(let o in t.morphTargets){let n=[],a=t.morphTargets[o];for(let s=0,l=a.length;s<l;s++){let c=a[s],u=new he.Float32BufferAttribute(c.data.length*3,3);u.name=c.name,n.push(Wu.call(u,c.data))}e.morphAttributes[o]=n}if(t.skinIndices.length>0){let o=new he.Float32BufferAttribute(t.skinIndices.length*4,4);e.setAttribute("skinIndex",Wx.call(o,t.skinIndices))}if(t.skinWeights.length>0){let o=new he.Float32BufferAttribute(t.skinWeights.length*4,4);e.setAttribute("skinWeight",Wx.call(o,t.skinWeights))}return t.boundingSphere!==null&&(e.boundingSphere=t.boundingSphere.clone()),t.boundingBox!==null&&(e.boundingBox=t.boundingBox.clone()),e}computeTangents(){console.error("THREE.Geometry: .computeTangents() has been removed.")}computeLineDistances(){console.error("THREE.Geometry: .computeLineDistances() has been removed. Use THREE.Line.computeLineDistances() instead.")}applyMatrix(t){return console.warn("THREE.Geometry: .applyMatrix() has been renamed to .applyMatrix4()."),this.applyMatrix4(t)}dispose(){this.dispatchEvent({type:"dispose"})}static createBufferGeometryFromObject(t){let e=new he.BufferGeometry,r=t.geometry;if(t.isPoints||t.isLine){let o=new he.Float32BufferAttribute(r.vertices.length*3,3),n=new he.Float32BufferAttribute(r.colors.length*3,3);if(e.setAttribute("position",Wu.call(o,r.vertices)),e.setAttribute("color",kx.call(n,r.colors)),r.lineDistances&&r.lineDistances.length===r.vertices.length){let a=new he.Float32BufferAttribute(r.lineDistances.length,1);e.setAttribute("lineDistance",JM.call(a,r.lineDistances))}r.boundingSphere!==null&&(e.boundingSphere=r.boundingSphere.clone()),r.boundingBox!==null&&(e.boundingBox=r.boundingBox.clone())}else t.isMesh&&(e=r.toBufferGeometry());return e}};ki.prototype.isGeometry=!0;var Lf=class{constructor(){this.vertices=[],this.normals=[],this.colors=[],this.uvs=[],this.uvs2=[],this.groups=[],this.morphTargets={},this.skinWeights=[],this.skinIndices=[],this.boundingBox=null,this.boundingSphere=null,this.verticesNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.uvsNeedUpdate=!1,this.groupsNeedUpdate=!1}computeGroups(t){let e=[],r,o,n,a=t.faces;for(o=0;o<a.length;o++){let s=a[o];s.materialIndex!==n&&(n=s.materialIndex,r!==void 0&&(r.count=o*3-r.start,e.push(r)),r={start:o*3,materialIndex:n})}r!==void 0&&(r.count=o*3-r.start,e.push(r)),this.groups=e}fromGeometry(t){let e=t.faces,r=t.vertices,o=t.faceVertexUvs,n=o[0]&&o[0].length>0,a=o[1]&&o[1].length>0,s=t.morphTargets,l=s.length,c;if(l>0){c=[];for(let b=0;b<l;b++)c[b]={name:s[b].name,data:[]};this.morphTargets.position=c}let u=t.morphNormals,p=u.length,d;if(p>0){d=[];for(let b=0;b<p;b++)d[b]={name:u[b].name,data:[]};this.morphTargets.normal=d}let f=t.skinIndices,h=t.skinWeights,m=f.length===r.length,y=h.length===r.length;r.length>0&&e.length===0&&console.error("THREE.DirectGeometry: Faceless geometries are not supported.");for(let b=0;b<e.length;b++){let v=e[b];this.vertices.push(r[v.a],r[v.b],r[v.c]);let w=v.vertexNormals;if(w.length===3)this.normals.push(w[0],w[1],w[2]);else{let S=v.normal;this.normals.push(S,S,S)}let O=v.vertexColors;if(O.length===3)this.colors.push(O[0],O[1],O[2]);else{let S=v.color;this.colors.push(S,S,S)}if(n===!0){let S=o[0][b];S!==void 0?this.uvs.push(S[0],S[1],S[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv ",b),this.uvs.push(new he.Vector2,new he.Vector2,new he.Vector2))}if(a===!0){let S=o[1][b];S!==void 0?this.uvs2.push(S[0],S[1],S[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv2 ",b),this.uvs2.push(new he.Vector2,new he.Vector2,new he.Vector2))}for(let S=0;S<l;S++){let T=s[S].vertices;c[S].data.push(T[v.a],T[v.b],T[v.c])}for(let S=0;S<p;S++){let T=u[S].vertexNormals[b];d[S].data.push(T.a,T.b,T.c)}m&&this.skinIndices.push(f[v.a],f[v.b],f[v.c]),y&&this.skinWeights.push(h[v.a],h[v.b],h[v.c])}return this.computeGroups(t),this.verticesNeedUpdate=t.verticesNeedUpdate,this.normalsNeedUpdate=t.normalsNeedUpdate,this.colorsNeedUpdate=t.colorsNeedUpdate,this.uvsNeedUpdate=t.uvsNeedUpdate,this.groupsNeedUpdate=t.groupsNeedUpdate,t.boundingSphere!==null&&(this.boundingSphere=t.boundingSphere.clone()),t.boundingBox!==null&&(this.boundingBox=t.boundingBox.clone()),this}},Ka=class{constructor(t,e,r,o,n,a=0){this.a=t,this.b=e,this.c=r,this.normal=o&&o.isVector3?o:new he.Vector3,this.vertexNormals=Array.isArray(o)?o:[],this.color=n&&n.isColor?n:new he.Color,this.vertexColors=Array.isArray(n)?n:[],this.materialIndex=a}clone(){return new this.constructor().copy(this)}copy(t){this.a=t.a,this.b=t.b,this.c=t.c,this.normal.copy(t.normal),this.color.copy(t.color),this.materialIndex=t.materialIndex;for(let e=0,r=t.vertexNormals.length;e<r;e++)this.vertexNormals[e]=t.vertexNormals[e].clone();for(let e=0,r=t.vertexColors.length;e<r;e++)this.vertexColors[e]=t.vertexColors[e].clone();return this}};function JM(i){return this.array.set(i),this}function kx(i){let t=this.array,e=0;for(let r=0,o=i.length;r<o;r++){let n=i[r];n===void 0&&(console.warn("THREE.BufferAttribute.copyColorsArray(): color is undefined",r),n=new he.Color),t[e++]=n.r,t[e++]=n.g,t[e++]=n.b}return this}function Hx(i){let t=this.array,e=0;for(let r=0,o=i.length;r<o;r++){let n=i[r];n===void 0&&(console.warn("THREE.BufferAttribute.copyVector2sArray(): vector is undefined",r),n=new he.Vector2),t[e++]=n.x,t[e++]=n.y}return this}function Wu(i){let t=this.array,e=0;for(let r=0,o=i.length;r<o;r++){let n=i[r];n===void 0&&(console.warn("THREE.BufferAttribute.copyVector3sArray(): vector is undefined",r),n=new he.Vector3),t[e++]=n.x,t[e++]=n.y,t[e++]=n.z}return this}function Wx(i){let t=this.array,e=0;for(let r=0,o=i.length;r<o;r++){let n=i[r];n===void 0&&(console.warn("THREE.BufferAttribute.copyVector4sArray(): vector is undefined",r),n=new he.Vector4),t[e++]=n.x,t[e++]=n.y,t[e++]=n.z,t[e++]=n.w}return this}var eI=["a","b","c"];function tI(i,t){switch(t){case"c":return i.c;case"b":return i.b;case"a":default:return i.a}}function Bf(i,t,e){let r=Math.min(i,t),o=Math.max(i,t),n=r+"_"+o;return e.get(n)}function Vf(i,t,e,r,o,n){let a=Math.min(i,t),s=Math.max(i,t),l=a+"_"+s,c;if(r.has(l))c=r.get(l);else{let u=e[a],p=e[s];c={a:u,b:p,newEdge:null,faces:[]},r.set(l,c)}c.faces.push(o),n[i].edges.push(c),n[t].edges.push(c)}function rI(i,t,e,r){let o,n,a;for(o=0,n=i.length;o<n;o++)e[o]={edges:[]};for(o=0,n=t.length;o<n;o++)a=t[o],Vf(a.a,a.b,i,r,a,e),Vf(a.b,a.c,i,r,a,e),Vf(a.c,a.a,i,r,a,e)}function qu(i,t,e,r,o){i.push(new Ka(t,e,r,void 0,void 0,o))}function Qa(i,t){return Math.abs(t-i)/2+Math.min(i,t)}function $u(i,t,e,r){i.push([t.clone(),e.clone(),r.clone()])}var Xu=class{constructor(t=1){this.subdivisions=t}modify(t){t instanceof li.BufferGeometry?t=new ki().fromBufferGeometry(t):t=t.clone(),t.mergeVertices();let e=this.subdivisions;for(;e-- >0;)this._smooth(t);return t.computeFaceNormals(),t.computeVertexNormals(),t}_smooth(t){let e=new li.Vector3,r,o,n,a,s,l=t.vertices,c=t.faces,u=t.faceVertexUvs[0],p=u!==void 0&&u.length>0,d=[],f=new Map;rI(l,c,d,f);let h=[],m,y,b,v,w,O,S;for(let Z of Array.from(f.keys())){for(y=f.get(Z),b=new li.Vector3,w=3/8,O=1/8,S=y.faces.length,S!=2&&(w=.5,O=0,S!=1),b.addVectors(y.a,y.b).multiplyScalar(w),e.set(0,0,0),a=0;a<S;a++){for(v=y.faces[a],s=0;s<3&&(m=l[tI(v,eI[s])],!(m!==y.a&&m!==y.b));s++);m&&e.add(m)}e.multiplyScalar(O),b.add(e),y.newEdge=h.length,h.push(b)}let T,M,g,D,E,I,N,_=[];for(o=0,n=l.length;o<n;o++){for(I=l[o],E=d[o].edges,r=E.length,r==3?T=3/16:r>3&&(T=3/(8*r)),M=1-r*Number(T),g=T,r<=2&&(r==2?(M=3/4,g=1/8):r==1||r==0),N=I.clone().multiplyScalar(M),e.set(0,0,0),a=0;a<r;a++)D=E[a],m=D.a!==I?D.a:D.b,e.add(m);e.multiplyScalar(Number(g)),N.add(e),_.push(N)}let R=_.concat(h),V=_.length,U,B,q,j=[],F=[],H,W,ee,te,Y=new li.Vector2,re=new li.Vector2,K=new li.Vector2;for(o=0,n=c.length;o<n;o++)v=c[o],U=Number(Bf(v.a,v.b,f).newEdge)+V,B=Number(Bf(v.b,v.c,f).newEdge)+V,q=Number(Bf(v.c,v.a,f).newEdge)+V,qu(j,U,B,q,v.materialIndex),qu(j,v.a,U,q,v.materialIndex),qu(j,v.b,B,U,v.materialIndex),qu(j,v.c,q,B,v.materialIndex),p&&(H=u[o],W=H[0],ee=H[1],te=H[2],Y.set(Qa(W.x,ee.x),Qa(W.y,ee.y)),re.set(Qa(ee.x,te.x),Qa(ee.y,te.y)),K.set(Qa(W.x,te.x),Qa(W.y,te.y)),$u(F,Y,re,K),$u(F,W,Y,K),$u(F,ee,re,Y),$u(F,te,K,re));t.vertices=R,t.faces=j,p&&(t.faceVertexUvs[0]=F)}};var Ht=new Ro.Vector3,qx=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=i.geometry??t?.geometry??new Ro.BufferGeometry().copy(new Ro.BoxGeometry(100,100,100)),r;t===void 0?(e.computeBoundingBox(),e.boundingBox.getSize(Ht),r={width:Ht.x,height:Ht.y,depth:Ht.z,subdivisions:0}):r=t.parameters;let o={...r,...i.parameters};return{parameters:{width:Math.abs(o.width),height:Math.abs(o.height),depth:Math.abs(o.depth),subdivisions:Math.abs(o.subdivisions)},geometry:e}}static build(i){let{width:t,height:e,depth:r,subdivisions:o}=i.parameters,n=i.geometry??new Ro.BufferGeometry().copy(new Ro.BoxGeometry(100,100,100)),a=n.userData.parameters;a===void 0?(n.computeBoundingBox(),n.boundingBox.getSize(Ht)):Ht.set(a.width,a.height,a.depth),(t!==Ht.x||e!==Ht.y||r!==Ht.z)&&n.scale(Ht.x===0?1:t/Ht.x,Ht.y===0?1:e/Ht.y,Ht.z===0?1:r/Ht.z);let s=n.originalGeometry;try{o>0?(s===void 0||a?.subdivisions!==o)&&(s===void 0&&(s=n),n=new Xu(o).modify(s).toBufferGeometry()):(s!==void 0&&(n=s),s=void 0,n.getAttribute("normal")===void 0&&n.computeVertexNormals())}catch{s!==void 0&&(n=s),s=void 0,n.getAttribute("normal")===void 0&&n.computeVertexNormals()}return s!==void 0&&Object.assign(n,{originalGeometry:s}),delete i.geometry,Object.assign(n,{userData:{...i,type:"NonParametricGeometry"}})}static loadFromUrl(i,t,e){new Ro.BufferGeometryLoader(e).load(i,o=>{let n=this.normalizeInputs({geometry:o});o.boundingBox.getSize(Ht);let a=100/Ht.x;Object.assign(n.parameters,{width:100,height:Ht.y*a,depth:Ht.z*a}),t(this.build(n))})}};var Yu=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:3},i.parameters);return{shape:i.shape&&i.shape instanceof Xe?i.shape:new Xe,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)})}}static build(i){let{width:t,height:e,spikes:r,cornerRadius:o,depth:n,extrudeBevelSize:a,extrudeBevelSegments:s}=i.parameters,l=i.shape,c=t*.5,u=e*.5,p=0,d=0,f=2*Math.PI/r;for(let m=0;m<r;m++){let y=f*m,b=p+Math.sin(y)*c,v=d+Math.cos(y)*u;l.addPoint(l.createPoint(b,v))}l.isClosed=!0;for(let m=0,y=l.points.length;m<y;m++)l.points[m].roundness=o;l.roundness=o,l.update();let h=wr.create({shape:l,parameters:{roundness:o,depth:n,extrudeBevelSize:a,extrudeBevelSegments:s}});return Object.assign(h,{userData:{...i,type:"PolygonGeometry"}})}};var We=require("three"),$x=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,radialSegments:4,heightSegments:1,cornerRadius:0,cornerSegments:8,openEnded:!1},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(i){let{width:t,height:e,depth:r,radialSegments:o,heightSegments:n,openEnded:a,cornerRadius:s,cornerSegments:l}=i.parameters,c=new Gf(t*.5,e,o,n,a,s,l);return c.scale(1,1,r/t),Object.assign(c,{userData:{...i,type:"PyramidGeometry"}})}};function Nl(i,t,e){e.x=i.x*t.x,e.y=i.y,e.z=i.x*t.y}function zf(i,t,e,r,o,n){let a=t.clone().sub(i),s=e.clone().sub(i),l=a.angleTo(s);if(a.normalize(),s.normalize(),r===o){let c=a.add(s).normalize();n.copy(i).addScaledVector(c,r/Math.sin(l/2))}else{let c=a.angleTo(s);n.copy(i),n.addScaledVector(a,o/Math.sin(c)),n.addScaledVector(s,r/Math.sin(c))}}function oI(i,t,e){let r=i.clone().sub(t),o=e.clone().sub(t);return r.projectOnVector(o),r.add(t)}var Gf=class extends We.BufferGeometry{constructor(t=.5,e=1,r=4,o=1,n=!1,a=0,s=4){super(),r=Math.floor(Math.max(3,r)),o=Math.floor(o),s=Math.floor(s);let l=[],c=[],u=[],p=[],d=0,f=e/2,h=Math.PI/r,m=t*Math.cos(Math.PI/r),y=2*Math.PI/r,b=(r-2)*Math.PI/r,v=Math.PI-b,w=new We.Vector3(0,-f,0),O=new We.Vector3(0,f,0),S=new We.Vector2(t,-f),T=new We.Vector2(m,-f),M=new We.Vector2(0,O.y).sub(T),g=new We.Vector2(0,O.y).sub(S),D=new We.Vector2(M.y,-M.x).normalize(),E=new We.Vector2(g.y,-g.x).normalize(),N=t*Math.cos(Math.PI/r)*Math.tan((Math.PI-M.angle())/2)-1e-8;a=Math.min(a,N);let _;{let F=new We.Vector3(D.x,D.y,0),H=new We.Vector3(Math.cos(y)*F.x,F.y,Math.sin(y)*F.x);_=F.angleTo(H)}let R=a/Math.tan((Math.PI-M.angle())/2),V=a/Math.tan((Math.PI-_)/2),U=new We.Vector3;if(!n){c.push(w.x,w.y,w.z),u.push(0,-1,0),p.push(0,0);let F=d++,H=[],W=S.clone(),ee=R/Math.cos(Math.PI/r);W.x-=ee;for(let te=0;te<r;te++){let Y=te/r*Math.PI*2+h,re=new We.Vector2(Math.sin(Y),Math.cos(Y));Nl(W,re,U),c.push(U.x,U.y,U.z),u.push(0,-1,0),p.push(0,0),H.push(d++)}for(let te=0;te<H.length;te++)l.push(H[te],F,H[(te+1)%H.length])}let B=[];{let F=new We.Vector3,H=new We.Vector3,W=new We.Vector3,ee=new We.Vector3,te=new We.Vector3,Y=new We.Vector3;for(let re=0;re<r;re++){let K=re/r*Math.PI*2+h,Z=(re+.5)/r*Math.PI*2+h,Q=(re+1)/r*Math.PI*2+h,$=new We.Vector2(Math.sin(K),Math.cos(K)),pe=new We.Vector2(Math.sin(Z),Math.cos(Z)),le=new We.Vector2(Math.sin(Q),Math.cos(Q));Nl(S,$,H),Nl(S,le,W),Nl(D,pe,F),zf(O,H,W,V,V,ee),c.push(ee.x,ee.y,ee.z),zf(H,O,W,V,R,te),c.push(te.x,te.y,te.z),zf(W,H,O,R,V,Y),c.push(Y.x,Y.y,Y.z),u.push(F.x,F.y,F.z),u.push(F.x,F.y,F.z),u.push(F.x,F.y,F.z),p.push(0,0),p.push(0,0),p.push(0,0);let ie=d++,ue=d++,ae=d++;if(l.push(ie,ue,ae),a>0){{let ye=H.clone().add(W).multiplyScalar(.5),ve=O.clone().sub(ye).normalize(),C=w.clone().sub(ye).normalize().add(ve).normalize().multiplyScalar(-1),ne=Y.clone().sub(te);q(ye,ne,C,M.angle())}let ge,me;{let ye=new We.Vector3;Nl(E,le,ye);let ve=Y.clone().add(ee).multiplyScalar(.5);ve=oI(ve,W,O);let xe=Y.clone().sub(ee);[ge,me]=q(ve,xe,ye,_,ee.y)}{let ye=ge,ve=ye.clone().setY(0).normalize(),xe=new We.Vector3(0,-1,0),C=ve.clone().cross(xe);j(ye,ve,xe,C)}B.concat(me);{let ye=M.angle(),ve=Math.PI-ye,xe=O.clone();xe.y-=a/Math.sin(ye-Math.PI/2);let C=new We.Vector3,ne=[];for(let ke=0;ke<s;ke++){let Ge=[],Ce=Math.PI/2-ve*ke/s,zt=Math.cos(Ce),_e=Math.sin(Ce),Bt=Z;for(let Gt=0;Gt<=ke;Gt++){let pn=Math.cos(Bt),xt=Math.sin(Bt);F.x=zt*xt,F.y=_e,F.z=zt*pn,C.copy(xe).addScaledVector(F,a),c.push(C.x,C.y,C.z),u.push(F.x,F.y,F.z),p.push(0,0),Ge.push(d++),Bt+=Math.PI*2/ke/r}ne.push(Ge)}me.reverse(),ne.push(me);let Ve=ne.length-1;for(let ke=0;ke<Ve;ke++){let Ge=ne[ke],Ce=ne[ke+1],zt=Ge.length-1;l.push(Ce[1],Ge[0],Ce[0]);for(let _e=1;_e<=zt;_e++)l.push(Ge[_e],Ge[_e-1],Ce[_e]),l.push(Ce[_e+1],Ge[_e],Ce[_e])}}}}}this.setIndex(l),this.setAttribute("position",new We.Float32BufferAttribute(c,3)),this.setAttribute("normal",new We.Float32BufferAttribute(u,3)),this.setAttribute("uv",new We.Float32BufferAttribute(p,2));function q(F,H,W,ee,te){let Y=-ee/2,re=(Math.PI-ee)/2,K=H.clone().normalize().cross(W);F.addScaledVector(W,-a/Math.sin(re));let Z=new We.Vector3,Q=new We.Vector3,$=1,pe=d,le=[];for(let ie=0;ie<=s;ie++){let ue=Y+ie/s*ee;Q.set(0,0,0),Q.addScaledVector(K,Math.sin(ue)),Q.addScaledVector(W,Math.cos(ue));for(let ae=0;ae<=$;ae++){let ge=ae/$-.5;if(Z.copy(F),Z.addScaledVector(H,ge),Z.addScaledVector(Q,a),te!=null){let me=Math.max(0,Z.y-te);Z.addScaledVector(H,-me/H.y)}c.push(Z.x,Z.y,Z.z),u.push(Q.x,Q.y,Q.z),p.push(0,0),ae===0&&le.push(d),d++}}for(let ie=0;ie<s;ie++)for(let ue=0;ue<$;ue++){let ae=pe+ue+($+1)*ie,ge=ae+($+1),me=ge+1,ye=ae+1;l.push(ae,ge,ye),l.push(ge,me,ye)}return[F.clone().addScaledVector(H,.5),le]}function j(F,H,W,ee){let te=Math.PI/2,Y=g.angle()-te,re=[],K=new We.Vector3,Z=new We.Vector3;for(let $=0;$<=s;$++){let pe=[],le=$/s;for(let ie=0;ie<=$;ie++){let ae=(($?ie/$:0)-.5)*v,ge=Math.cos(ae),me=Math.sin(ae),ye=Math.atan(Math.tan(Y)*ge),ve=(te+ye)*le,xe=Math.cos(ve),C=Math.sin(ve);K.set(0,0,0),K.addScaledVector(H,C*ge),K.addScaledVector(W,xe),K.addScaledVector(ee,C*me),Z.copy(F).addScaledVector(K,a),c.push(Z.x,Z.y,Z.z),u.push(K.x,K.y,K.z),p.push(0,0),pe.push(d++)}re.push(pe)}let Q=re.length-1;for(let $=0;$<Q;$++){let pe=re[$],le=re[$+1],ie=pe.length-1;l.push(pe[0],le[1],le[0]);for(let ue=1;ue<=ie;ue++)l.push(pe[ue-1],pe[ue],le[ue]),l.push(pe[ue],le[ue+1],le[ue])}}}};var Za=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,cornerRadius:[0,0,0,0],cornerType:1,extrudeBevelSize:0,extrudeBevelSegments:1},i.parameters),r=Object.assign(t?.ui??{enabledIndieCorners:!1},i.ui);return{shape:i.shape&&i.shape instanceof Xe?i.shape:new Xe,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)}),ui:r}}static build(i){let t=i.shape,{width:e,height:r,cornerRadius:o,cornerType:n,depth:a,extrudeBevelSize:s,extrudeBevelSegments:l}=i.parameters,c={x:e*.5,y:r*.5},u={x:-c.x,y:-c.y},p={x:c.x,y:c.y};function d(O,S,T){return S>e&&T>r?Math.min(O*e/S,O*r/T):S>e?O*e/S:T>r?O*r/T:O}let f=[];f[0]=o[0]===0?0:d(o[0],o[0]+o[3],o[0]+o[1]),f[1]=o[1]===0?0:d(o[1],o[1]+o[2],o[1]+o[0]),f[2]=o[2]===0?0:d(o[2],o[2]+o[1],o[2]+o[3]),f[3]=o[3]===0?0:d(o[3],o[3]+o[0],o[3]+o[2]);let h=u.x,m=p.x,y=p.y,b=u.y;t.addPoint(t.createPoint(h,y)),t.addPoint(t.createPoint(m,y)),t.addPoint(t.createPoint(m,b)),t.addPoint(t.createPoint(h,b)),t.isClosed=!0;let v=!0;for(let O=0,S=t.points.length;O<S;O++)t.points[O].roundness=f[O],O>0&&f[O]!==f[O-1]&&(v=!1);v&&(t.roundness=f[0]),t.useCubicForRoundedCorners=n!==1,t.update();let w=wr.create({shape:t,parameters:{depth:a,extrudeBevelSize:s,extrudeBevelSegments:l}});return Object.assign(w,{userData:{...i,type:"RectangleGeometry"}})}};var ci=require("three"),Xx=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,widthSegments:64,heightSegments:64,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:180},i.parameters);return e.thetaLength=ci.MathUtils.clamp(e.thetaLength,0,180),{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(i){let{width:t=100,height:e=t,depth:r=t,widthSegments:o=64,heightSegments:n=64,phiStart:a,phiLength:s,thetaStart:l,thetaLength:c}=i.parameters,u;return c===0?(u=new ci.BufferGeometry,u.setAttribute("position",new ci.Float32BufferAttribute([],3))):u=new ci.SphereGeometry(.5*t,o,n,a,s,l,c*ci.MathUtils.DEG2RAD),u.scale(1,e/t,r/t),Object.assign(u,{userData:{...i,type:"SphereGeometry"}})}};var Yx=require("three"),Kx=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,widthSegments:8,heightSegments:8},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:0})}}static build(i){let{width:t=100,height:e=t,widthSegments:r=8,heightSegments:o=8}=i.parameters,n=new Yx.PlaneGeometry(t,e,r,o);return n.scale(1,1,1),Object.assign(n,{userData:{...i,type:"PlaneGeometry"}})}};var Hi=require("three"),Qx=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,angle:90,cornerRadius:24,cornerSegments:8},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(i){let{width:t,height:e,depth:r,angle:o,cornerRadius:n,cornerSegments:a}=i.parameters,s=new Ff(t,e,r,o,n,a);return Object.assign(s,{userData:{...i,type:"BackdropGeometry"}})}},Ff=class extends Hi.BufferGeometry{constructor(t=1,e=1,r=1,o=90,n=10,a=24){super(),this.type="BackdropGeometry";let s=[],l=[],c=[],u=.001;n==0&&(a=1),a=Math.max(1,Math.floor(a)),n=Math.min(n,100),o=Math.min(180-u,o),o*=Math.PI/180;let p=[],d=Math.PI/2,f=(Z=0,Q=0,$=0)=>new Hi.Vector3(Z,Q,$),h=f(),m=f(),[y,b,v]=[e/2,t/2,r/2],w=-b,O=+b,[S,T,M]=[f(w,-y,+v),f(w,-y,-v),f(w,+y,-v)],g=(Z,Q=!1)=>Math.sin(Z-Math.PI/(1+ +Q)),D=(Z,Q=!1)=>Math.cos(Z-Math.PI/(1+ +Q));M.y=Math.sin(o)*e-y;let E=Math.cos(o)*e-v,I=S.z-u;o<=d?(M.z=Math.min(E,I),M.z==I&&(M.y-=(E-I)/Math.tan(d-o))):T.z=Math.min(T.z-E-v,S.z-u),h.subVectors(S,T),m.subVectors(M,T);let N=Math.min(h.length(),m.length())*n/100,_=N*Math.tan(o/2),R=N/Math.cos(o/2),V=h.clone().normalize().add(m.normalize()).setLength(R).add(T);h.set(0,g(o,!0),D(o,!0)),p.push([M,h.clone()]);let U=(Math.PI-o)/a;for(let Z=0;Z<=a;Z++){let Q=d+o+Z*U;h.set(0,Math.sin(Q)*_,Math.cos(Q)*_),h.add(V),m.set(0,g(Q),D(Q)),p.push([h.clone(),m.clone()])}p.push([S,f(0,1,0)]);let B=Math.sin(U/2)*_*2,q=p.length-1,j=p[0][0].distanceTo(p[1][0]),F=p[q-1][0].distanceTo(p[q][0]),H=j+B*a+F;p[0].push(1);for(let Z=0;Z<=a;Z++)p[Z+1].push(1-(j+Z*B)/H);p[q].push(0);let[W,ee,te]=p[0],Y,re,K;for(let Z=1;Z<p.length;Z++)[Y,re,K]=p[Z],s.push(w,W.y,W.z,w,Y.y,Y.z,O,W.y,W.z,O,W.y,W.z,w,Y.y,Y.z,O,Y.y,Y.z),l.push(0,ee.y,ee.z,0,re.y,re.z,0,ee.y,ee.z,0,ee.y,ee.z,0,re.y,re.z,0,re.y,re.z),c.push(0,te,0,K,1,te,1,te,0,K,1,K),[W,ee,te]=[Y,re,K];this.setAttribute("position",new Hi.Float32BufferAttribute(s,3)),this.setAttribute("normal",new Hi.Float32BufferAttribute(l,3)),this.setAttribute("uv",new Hi.Float32BufferAttribute(c,2))}};var Ku=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,innerRadiusPercent:38.19,spikes:5,cornerRadius:0,angle:360,extrudeBevelSize:0,extrudeBevelSegments:1},i.parameters);return{shape:i.shape&&i.shape instanceof Xe?i.shape:new Xe,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)})}}static build(i){let{width:t,height:e,innerRadiusPercent:r,spikes:o,cornerRadius:n,angle:a,depth:s,extrudeBevelSize:l,extrudeBevelSegments:c}=i.parameters,u=i.shape,p=t*.5,d=e*.5,f=0,h=0,m=a*Math.PI/360/o,y=Math.PI/2*3*-1,b=p*r/100,v=d*r/100;if(o===3&&r===50){m=2*Math.PI/o;for(let O=0;O<o;O++){let S=m*O,T=f+Math.sin(S)*p,M=h+Math.cos(S)*d;u.addPoint(u.createPoint(T,M))}}else for(let O=0;O<o;O++){let S=f+Math.cos(y)*p,T=h+Math.sin(y)*d;u.addPoint(u.createPoint(S,T)),y+=m,S=f+Math.cos(y)*b,T=h+Math.sin(y)*v,O<=o,u.addPoint(u.createPoint(S,T)),y+=m}u.isClosed=!0;for(let O=0,S=u.points.length;O<S;O++)u.points[O].roundness=n;u.roundness=n,u.update();let w=wr.create({shape:u,parameters:{roundness:n,depth:s,extrudeBevelSize:l,extrudeBevelSegments:c}});return Object.assign(w,{userData:{...i,type:"StarGeometry"}})}};var Zx=require("three"),Jx=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,depth:0},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)})}}static build(i){let{width:t,height:e}=i.parameters,r=new Zx.PlaneGeometry(t,e);return Object.assign(r,{userData:{...i,type:"TextFrameGeometry"}})}};var Ja=require("three");var eb=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,radialSegments:32,tubularSegments:64,arc:360,cornerRadius:30,cornerSegments:8},i.parameters),r=Math.abs(e.width),o=Math.abs(e.height??e.width);e.shapeBlendNode&&(o=r);let n=Math.round(Math.abs(e.depth??e.width*.25));return{parameters:Object.assign(e,{width:r,height:o,depth:n})}}static build(i){let{width:t,height:e,depth:r,radialSegments:o,tubularSegments:n,arc:a,cornerRadius:s,cornerSegments:l}=i.parameters,c=iI(t,e,r,t*.5,a,n,0,0,o,s,l);return c.scale(1,e/t,1),Object.assign(c,{userData:{...i,type:"TorusGeometry"}})}};function iI(i,t,e,r,o,n,a,s,l,c,u){[t,e]=[e,t],a=t/2;let p=Ja.MathUtils.clamp(o/360,0,1);if(p===0){let d=new Ja.BufferGeometry;return d.setAttribute("position",new Ja.Float32BufferAttribute([],3)),d}return p===1&&(c=0),new Il(!0,i,t,e,r,p,n,a,s,l,c,u)}var tb=require("three"),rb=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,tubularSegments:64,radialSegments:32,p:2,q:3},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width),tube:e.tube??e.width*.125})}}static build(i){let{width:t,tube:e,tubularSegments:r,radialSegments:o,p:n,q:a}=i.parameters,s=t*.5;s!==e&&(s-=e);let l=new tb.TorusKnotGeometry(s,e,r,o,n,a);return Object.assign(l,{userData:{...i,type:"TorusKnotGeometry"}})}};var ob=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1,isRect:!1},i.parameters);return{shape:i.shape&&i.shape instanceof Xe?i.shape:new Xe,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width*(e.isRect?1:Math.sqrt(3)/2)),depth:Math.abs(e.depth??0)})}}static build(i){let{width:t=100,height:e,cornerRadius:r,depth:o,extrudeBevelSize:n,extrudeBevelSegments:a,isRect:s}=i.parameters,l=i.shape,c=t*.5,u=e*.5;s?(l.addPoint(l.createPoint(-c,u)),l.addPoint(l.createPoint(c,-u)),l.addPoint(l.createPoint(-c,-u))):(l.addPoint(l.createPoint(0,u)),l.addPoint(l.createPoint(c,-u)),l.addPoint(l.createPoint(-c,-u))),l.isClosed=!0;for(let d=0,f=l.points.length;d<f;d++)l.points[d].roundness=r;l.roundness=r,l.update();let p=wr.create({shape:l,parameters:{roundness:r,depth:o,extrudeBevelSize:n,extrudeBevelSegments:a}});return Object.assign(p,{userData:{...i,type:"TriangleGeometry"}})}};var Ie=require("three");function ib(i,t){let e=2*Math.PI;return(i%e+e)%e===(t%e+e)%e}function nI(i){return/^(rgba)?\(\s*(\d+),\s*(\d+),\s*(\d+)(?:,\s*(\d+(?:\.\d+)?))?\s*\)$/.exec(i.toLowerCase())}function aI(i,t,e){let r,o,n,a=Math.floor(i*6),s=i*6-a,l=e*(1-t),c=e*(1-s*t),u=e*(1-(1-s)*t);switch(a%6){case 0:r=e,o=u,n=l;break;case 1:r=c,o=e,n=l;break;case 2:r=l,o=e,n=u;break;case 3:r=l,o=c,n=e;break;case 4:r=u,o=l,n=e;break;case 5:default:r=e,o=l,n=c;break}return{r:r*255,g:o*255,b:n*255}}function sI(i,t,e){i/=255,t/=255,e/=255;let r=Math.max(i,t,e),o=Math.min(i,t,e),n=r,a=r-o,s=r==0?0:a/r,l;if(r==o)l=0;else{switch(r){case i:l=(t-e)/a+(t<e?6:0);break;case t:l=(e-i)/a+2;break;case e:default:l=(i-t)/a+4;break}l/=6}return{h:l,s,v:n}}function lI(i){return i=Math.floor(i),{r:i>>16&255,g:i>>8&255,b:i&255}}function cI(i,t,e){return(i<<16)+(t<<8)+e}function uI(i,t,e){return i=Math.round(i),t=Math.round(t),e=Math.round(e),"#"+[i,t,e].map(r=>r.toString(16).padStart(2,"0")).join("").toUpperCase()}function dI(i){let t=/^#?([a-f\d])([a-f\d])([a-f\d])$/i;i=i.replace(t,(r,o,n,a)=>String(o+o+n+n+a+a));let e=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(i);return e?{r:parseInt(e[1],16),g:parseInt(e[2],16),b:parseInt(e[3],16)}:null}var nb={parseRgba:nI,hsvToRgb:aI,rgbToHsv:sI,hexToRgb:lI,rgbToHex:cI,rgbToHexString:uI,hexStringToRgb:dI};function ui(i){return{all:i=i||new Map,on:function(t,e){var r=i.get(t);r?r.push(e):i.set(t,[e])},off:function(t,e){var r=i.get(t);r&&(e?r.splice(r.indexOf(e)>>>0,1):i.set(t,[]))},emit:function(t,e){var r=i.get(t);r&&r.slice().map(function(o){o(e)}),(r=i.get("*"))&&r.slice().map(function(o){o(t,e)})}}}var Qu=class{constructor(t,e,r){this.id=t;this.userAPI=e;this.result=void 0;this.error="null";this.isPrefetched=!1;this.isLoading=!1;this.isLoaded=!1;this.prefetchPromise=new Promise(t=>t());this.emitter=ui();this._innerCallUserAPI=async t=>{this.emitter.emit("start",{userAPIId:this.id}),this.isLoading=!0,this.isLoading=!1;try{this.result=await yI(this.userAPI,t),this.error="null",this.emitter.emit("success",{userAPIId:this.id})}catch(e){let r=e.message?.split("_:_")?.[0]?.replace("status:","")??"null";this.error=r,this.result=null,this.emitter.emit("error",{userAPIId:this.id})}this.isLoading=!1,this.isPrefetched=!0,this.isLoaded=!0};e?.integration?.type==="OpenAI"?this.result={content:""}:e.method==="GET"&&e.url!==""&&(this.prefetchPromise=this.prefetch(r)),this._debouncedCallUserAPI=this._innerCallUserAPI,this._updateDebouncedCallUserAPI(),this._debouncedPrefetch=$c(this.prefetch,1e3,{trailing:!0})}_updateDebouncedCallUserAPI(){this._debouncedCallUserAPI=this.userAPI.debounce!==void 0&&this.userAPI.debounce>0?$c(this._innerCallUserAPI,this.userAPI.debounce,{leading:!0,trailing:!0}):this._innerCallUserAPI}async prefetch(t){await this.callUserAPI(t)}async callUserAPI(t){await this._debouncedCallUserAPI(t)}update(t,e,r=!0){this.userAPI=t,this._updateDebouncedCallUserAPI(),this.userAPI.url!==""&&this.userAPI.method==="GET"&&r&&this._debouncedPrefetch(e)}retrieveValue(t){if(this.result)try{return ut.zoom(this.result,t)}catch(e){console.error(e)}}retrieveZoomedKeyValues(t){if(this.result){let e=t&&t.length?ut.zoom(this.result,t):this.result;if(mI(e))return Object.entries(e);if(hI(e))return e.map((r,o)=>[o.toString(),r]);throw fI(e)?new Error("This path points to a value, use retrieveValue() instead. "+t?.join(".")):new Error("Path error"+t?.join("."))}}dispose(){}on(t,e){this.emitter.on(t,e)}off(t,e){this.emitter.off(t,e)}get autostart(){return this.userAPI.autoStart}};function pI(i){let t=new Headers;return i.headers.forEach(e=>{e.data.key!==""&&t.append(e.data.key,e.data.value)}),t}function fI(i){return typeof i=="string"||typeof i=="number"||typeof i=="boolean"||i===null}function hI(i){return Array.isArray(i)}function mI(i){return typeof i=="object"&&i!==null}async function yI(i,t,e=new AbortController){let r,o=i.url,n=i.proxy?.enabled??!1,a;if(i.integration?.type==="OpenAI"){let l=Dl(i.integration.prompt===""?[]:JSON.parse(i.integration.prompt),t),c=i.integration.behavior===""?[]:Dl(JSON.parse(i.integration.behavior),t);a=`{
4
4
  "model": "${i.integration.model}",
5
5
  "messages": [${i.integration.useBehavior?`
6
6
  {
@@ -15,7 +15,7 @@ best distance: ${d.d}`);let b=[d.x,d.y];return b.distance=d.d,b.distance}functio
15
15
  }`}if(n){o=`${!1&&window.location.search.includes("api-dev")?"https://api-dev.spline.design/":"https://apis.spline.design/"}file/${i.proxy.fileId}/external-api/request?uuidexternalapi=${i.proxy.proxyId}`;let u;a!==void 0?u=a:i.method==="POST"&&i.body&&(u=Dl(JSON.parse(i.body),t)),u!==void 0&&(o+=`&data=${encodeURIComponent(u.replace(/(\r\n|\n|\r|\t)/gm,""))}`)}else i.integration?.type==="OpenAI"?r=a:i.method==="POST"&&i.body&&(r=Dl(JSON.parse(i.body),t));let s=await fetch(o,{method:n?"GET":i.method,headers:n?void 0:pI(i),signal:e.signal,body:r});if(!s.ok)throw new Error("status:"+s.status+"_:_"+s.statusText);if(i.integration?.type==="OpenAI"){let l=await s.json();return n&&(l=l.response),{content:l.choices[0].message.content}}else{let l=await s.json();return n&&(l=l.response),l}}var ab=(i,t)=>{if(typeof i=="string"){let e=t.getVariable(i);if(e)return ab(e,t)}return Vi.isBoolean(i)?Vi.getDisplayedValue(i).toLowerCase():Vi.getDisplayedValue(i)},Dl=(i,t)=>i.map((e,r)=>{if("text"in e)return e.text;if("type"in e){if(e.type==="paragraph")return(r>0?`
16
16
  `:"")+Dl(e.children,t);if(e.type==="variable"){let o=t.getVariable(e.variableId);if(o!==void 0)return ab(o,t)}}return""}).join("");var gI=new Ie.Matrix4,xI=new Ie.Matrix4;function bI(i,t,e){let r=[new Ie.Vector3,new Ie.Vector3,new Ie.Vector3],o=[new Ie.Vector3,new Ie.Vector3,new Ie.Vector3];return i.extractBasis(r[0],r[1],r[2]),t.extractBasis(o[0],o[1],o[2]),r.forEach((n,a)=>{let s=o[a],l=Ie.MathUtils.lerp(n.length(),s.length(),e);n.lerp(s,e).setLength(l)}),new Ie.Matrix4().makeBasis(r[0],r[1],r[2])}var sb=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,height:100,depth:1,subdivisions:12,roundness:0,extrudeBevelSize:0,extrudeBevelSegments:3},i.parameters),r=Math.abs(e.width),o=Math.abs(e.height??e.width),n=Math.abs(e.depth??0),a=t?.shapeData??Ya.create({parameters:Xp}).userData.shape;return{path:i.path??Ia.defaultData(),parameters:Object.assign(e,{width:r,height:o,depth:n,extrusion:{...gu,...e.extrusion}}),shapeData:a}}static build(i){if(i.path.points.length>=2){let e=new jf(i);return Object.assign(e,{userData:{...i,type:"PathGeometry"}})}else return Object.assign(new Ie.BufferGeometry,{userData:{...i,type:"PathGeometry"}})}},jf=class extends Ie.BufferGeometry{constructor(e){super();this.type="PathExtrusionGeometry",this.inputs=e,this.build()}_isGeometryClosed(){return this.inputs.path.isClosed&&this.inputs.parameters.extrusion.depth===1}_isOpenEnded(){let e=this.inputs.parameters.extrusion;return!(this.inputs.path.isClosed&&e.depth===1)||!ib(e.twist,0)||e.startScale!==e.endScale}build(){let e=this._extractPathPoints();if(e.length<2)return;let r=this._computeBasisMatrices(e),{depth:o,offset:n}=this.inputs.parameters.extrusion;o=Math.max(0,Math.min(o,1)),n=Math.max(0,Math.min(n,1));let a=this.inputs.path.isClosed?e.length:e.length-1,s=Math.floor(n*a),l=this.inputs.path.isClosed?Math.ceil((o+n)*a):Math.ceil(Math.min(1,o+n)*a),c=Math.min(Math.max(2,l-s+1),a+2),u=[],p=[];for(let j=0;j<c;j++){let F=this.inputs.path.isClosed?(j+s)%e.length:Math.min(j+s,e.length-1);u.push(e[F].clone()),p.push(r[F].clone())}let d=(j,F,H)=>{u[j]=u[j].clone().lerp(u[F],H),p[j]=bI(p[j],p[F],H)},f=0,h=n*a%1;(!this.inputs.path.isClosed||o<=1)&&(h||n===0)&&(f=h,d(0,1,f));let m=0,y=(n+o)*a%1;if((this.inputs.path.isClosed&&o<=1||!this.inputs.path.isClosed&&n+o<1)&&y&&(m=y,d(u.length-1,u.length-2,1-m)),o===0){let j=u.length-1;u[j].copy(u[0]),p[j].copy(p[0])}this._applyPathModifiers(p,f,m);let{bevel:b,bevelSides:v}=this.inputs.parameters.extrusion,w=b>0?this.inputs.parameters.extrusion.capType:"flat",O=5;this.inputs.parameters.extrusion.shape.type==="Custom"&&(O=this.inputs.parameters.extrusion.shape.shapeQuality==="low"?5:12);let{regions:S,infos:T,vertices:M}=this._computeShapePoints(O),g=0,D;w==="round"&&(D=new Ui(this.inputs.shapeData,2*b,b,O,v,void 0,!0),g=D.getAttribute("position").count);let E=0,I=0;T.sort((j,F)=>j.start-F.start),T.forEach(j=>{j.verticesStart=E,j.verticesCount=j.continuous.reduce((F,H,W)=>F+(W===0||!H?2:1),0),I+=j.verticesCount,E=I});let N=I*c,_,R=0;if(this._isOpenEnded()&&w==="flat"){try{_=co({windingRule:$e.ODD,elementType:St.POLYGONS,polySize:3,vertexSize:2,strict:!0,contours:S})}catch{_=Df}R=_.vertexCount}let V=N+2*R+g*2,U=N+2*R,B={positions:new Float32Array(V*3),normals:new Float32Array(V*3),uvs:new Float32Array(V*2)},q=[];if(T.forEach(j=>{this._extrudeRegion(j,M,p,u,B,q,this._isGeometryClosed()&&!this._isOpenEnded())}),_&&(this._closeEnd(_,N,q,B,p[0],u[0],!1),this._closeEnd(_,N+R,q,B,p[p.length-1],u[u.length-1],!0)),D){B.positions.set(D.getAttribute("position").array,U*3),B.normals.set(D.getAttribute("normal").array,U*3),B.uvs.set(D.getAttribute("uv").array,U*2);for(let W=U;W<U+g;W++)B.uvs[W*2+1]=1e-4;let j=q.length;q.push(...D.getIndex().array.map(W=>W+U)),U+=g,B.positions.set(D.getAttribute("position").array,U*3),B.normals.set(D.getAttribute("normal").array,U*3),B.uvs.set(D.getAttribute("uv").array,U*2);let F=q.length;q.push(...D.getIndex().array.map(W=>W+U)),this.setAttribute("position",new Ie.BufferAttribute(B.positions,3)),this.setAttribute("normal",new Ie.BufferAttribute(B.normals,3)),this.setAttribute("uv",new Ie.BufferAttribute(B.uvs,2)),this.setIndex(q);let H=gI;H.copy(p[p.length-1]).setPosition(u[u.length-1]),this.applyMatrix4OnRange(H,U,V),H.copy(p[0]).setPosition(u[0]).multiply(xI.makeScale(1,1,-1)),this.applyMatrix4OnRange(H,U-g,U),this.reverseIndicesOnRange(j,F)}else this.setAttribute("position",new Ie.BufferAttribute(B.positions,3)),this.setAttribute("normal",new Ie.BufferAttribute(B.normals,3)),this.setAttribute("uv",new Ie.BufferAttribute(B.uvs,2)),this.setIndex(q)}_extractPathPoints(){let r=Vu(this.inputs.path).getPoints(this.inputs.path.subdivisions);if(r.length<2)return[];let o=[r[0]];return r.forEach(a=>{o[o.length-1].distanceToSquared(a)>.001&&o.push(a)}),this.inputs.path.isClosed&&o[o.length-1].distanceTo(o[0])<.001&&o.pop(),o}_computeBasisMatrices(e){let r=[],o=e.length,n=this.inputs.path.isClosed,a=new Ie.Vector3,s=new Ie.Vector3,l=new Ie.Vector3,c=new Ie.Vector3,u=new Ie.Vector3(0,1,0);for(let y=0;y<o;y++){let b=e[y],v;y===0?v=n?e[e.length-2]:b.clone().multiplyScalar(2).sub(e[1]):v=e[y-1];let w;y===o-1?w=n?e[1]:b.clone().multiplyScalar(2).sub(e[y-1]):w=e[y+1];let O=b.clone().sub(v).normalize(),S=w.clone().sub(b).normalize(),T=O.clone().add(S).normalize();l.copy(T),y===0&&(T.equals(u)||T.clone().negate().equals(u))&&u.set(0,0,1);let M=u.clone().cross(T).normalize(),g=T.clone().cross(M).normalize();u.copy(g),c.copy(M),y===0&&(a.copy(g),s.copy(T));let D=new Ie.Matrix4().makeBasis(M,g,T);r.push(D)}let p=n?s:l,d=n?a:new Ie.Vector3(0,1,0),f=p.clone().cross(c).normalize(),h=Math.acos(d.dot(f));if(isNaN(h))return r;let m=d.clone().cross(f);p.dot(m)>0&&(h*=-1);for(let y=1;y<r.length;y++){let b=new Ie.Matrix4().makeRotationZ(h*y/r.length);r[y].multiply(b)}return r}_applyPathModifiers(e,r,o){let n=e.length,{angle:a,twist:s,startScale:l,endScale:c}=this.inputs.parameters.extrusion,u=new Ie.Matrix4,p=new Ie.Matrix4;return e.forEach((d,f)=>{let h=f===0?0:f===n-1?1:(f-r)/(n-(o===0?0:1)-(r+(1-o)));u.makeRotationZ(Ie.MathUtils.lerp(a,a+s,h)*Ie.MathUtils.DEG2RAD);let m=Ie.MathUtils.lerp(l,c,h);p.makeScale(m,m,m),d.multiply(u).multiply(p)}),e}_computeShapePoints(e=12,r=$e.ODD){let o=this.inputs.shapeData,n=o.extractShapePointsToFlatArray([],e),a=o.shapeHoles.map(m=>{let y=m.extractShapePointsToFlatArray([],e),b=[];for(let v=y.length-1;v>=1;v-=2){let w=y[v-1],O=y[v-0];b.push(w,O)}return b}),s;try{s=co({windingRule:r,elementType:St.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[n]})}catch{s=Ml}let l;try{l=co({windingRule:$e.ODD,elementType:St.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...a]})}catch{l=Nf}if(!s)throw new Error("error generating geometry");let c=s.elementCount;if(l){s.elementCount+=l.elementCount;for(let m=0;m<l.elements.length;m++){let y=l.elements[m],b=m%2===0?s.vertexCount:0;s.elements.push(y+b)}for(let m=0;m<l.vertexIndices.length;m++){let y=l.vertexIndices[m],b=s.vertexCount;s.vertexIndices.push(y+b)}for(let m=0;m<l.vertices.length;m++){let y=l.vertices[m];s.vertices.push(y)}}let u=1/0,p=-1/0,d=1/0,f=-1/0;for(let m=0,y=s.vertexCount;m<y;m++){let b=m*2,v=s.vertices[b+0],w=s.vertices[b+1];v<u&&(u=v),v>p&&(p=v),w<d&&(d=w),w>f&&(f=w)}let h=[];for(let m=s.elementCount-1;m>=0;m--){let y=m>=c,b=m*2,v=s.elements[b+0],w=s.elements[b+1],O=v+w,S={start:v,count:w,normals:[],isHole:y,continuous:[],verticesStart:0,verticesCount:0};h.push(S);let T=v,M=O-1,g=v+1,D=o.roundedCurves.length;do{let E=T-v,I=s.vertices[M*2+0],N=s.vertices[M*2+1],_=s.vertices[T*2+0],R=s.vertices[T*2+1],V=s.vertices[g*2+0],U=s.vertices[g*2+1],B=_-I,q=R-N,j=Math.sqrt(B*B+q*q);B/=j,q/=j;let F=_-V,H=R-U,W=Math.sqrt(F*F+H*H);F/=W,H/=W,S.normals[E*2+0]=-H,S.normals[E*2+1]=F;let ee=s.vertexIndices[T];if(Array.isArray(ee))S.continuous[E]=!1;else{let[te,Y]=o.getCurveIndexFromVertexId(ee-1,!0);if(Y>0&&Y<1)S.continuous[E]=!0;else{let re=Y===1?te+1:te-1;re=(re+D)%D;let K=Y===1?0:1,Z=o.roundedCurves[te].getTangent(Y),Q=o.roundedCurves[re].getTangent(K);S.continuous[E]=Z.dot(Q)>.95}}y&&(S.normals[E*2+0]*=-1,S.normals[E*2+1]*=-1),[M,T,g]=[T,g,g+1],g>=O&&(g-=w)}while(g!==v+1)}return{regions:[n,...a],infos:h,vertices:s.vertices}}_insertVertex(e,r,o,n,a){let s=r*2,l=r*3;e.positions[l+0]=o.x,e.positions[l+1]=o.y,e.positions[l+2]=o.z,e.normals[l+0]=n.x,e.normals[l+1]=n.y,e.normals[l+2]=n.z,e.uvs[s+0]=a.x,e.uvs[s+1]=a.y}_extrudeRegion(e,r,o,n,a,s,l){let c=new Ie.Vector3,u=new Ie.Vector3,p=new Ie.Vector3,d=new Ie.Vector3,f=new Ie.Vector2;o.forEach((m,y)=>{let b=n[y],v=e.verticesStart*o.length+e.verticesCount*y;for(let w=0;w<e.count;w++){let O=(e.start+w)*2;if(c.set(r[O+0],r[O+1],0),p.copy(c).applyMatrix4(m).add(b),e.continuous[w])d.set(e.normals[w*2+0],e.normals[w*2+1],0);else{let S=w===0?(e.start+e.count-1)*2:O-2;u.set(r[S+0],r[S+1],0),d.copy(c).sub(u),d.set(-d.y,d.x,0),e.isHole||d.negate()}if(d.applyMatrix4(m).normalize(),f.set(w===0?1:w/e.count,y/(o.length-1)),this._insertVertex(a,v,p,d,f),v++,!e.continuous[w]||w===0){if(w===0)d.set(e.normals[w*2+0],e.normals[w*2+1],0),f.set(0,y/(o.length-1));else{let S=w===e.count-1?e.start*2:O+2;u.set(r[S+0],r[S+1],0),d.copy(u).sub(c),d.set(-d.y,d.x,0),e.isHole||d.negate()}d.applyMatrix4(m).normalize(),this._insertVertex(a,v,p,d,f),v++}}});let h=o.length-1;for(let m=0;m<h;m++){let y=e.verticesStart*o.length+e.verticesCount*m,b=e.verticesStart*o.length+e.verticesCount*(m+1),v=0;for(let w=0;w<e.count;w++){(!e.continuous[w]||w===0)&&v++;let O=w===e.count-1?0:v+1,S=y+v,T=y+O,M=b+O,g=b+v;e.isHole?s.push(S,M,T,S,g,M):s.push(S,T,M,S,M,g),v++}}}_closeEnd(e,r,o,n,a,s,l){let c=e.vertexCount,u=new Ie.Vector3(0,0,l?-1:1).applyMatrix4(a),p=new Ie.Vector3,d=new Ie.Vector2;for(let h=0;h<c;h++){let m=2*h;p.set(e.vertices[m+0],e.vertices[m+1],0).applyMatrix4(a).add(s),this._insertVertex(n,r+h,p,u,d)}let f=e.elements;for(let h=0;h<e.elementCount;h++){let m=3*h,y=f[m+0]+r,b=f[m+(l?1:2)]+r,v=f[m+(l?2:1)]+r;o.push(y,b,v)}}applyMatrix4OnRange(e,r,o){let n=e.elements,a=new Ie.Matrix3().getNormalMatrix(e).elements,s,l,c,u,p=this.attributes.position,d=this.attributes.normal;if(!p||!d)return;let f=p.array,h=d.array,m=p.itemSize;for(let y=r*m,b=o*m;y<b;y+=m){if(y===r)debugger;s=f[y+0],l=f[y+1],c=f[y+2],u=1/(n[3]*s+n[7]*l+n[11]*c+n[15]),f[y+0]=(n[0]*s+n[4]*l+n[8]*c+n[12])*u,f[y+1]=(n[1]*s+n[5]*l+n[9]*c+n[13])*u,f[y+2]=(n[2]*s+n[6]*l+n[10]*c+n[14])*u,s=h[y+0],l=h[y+1],c=h[y+2],h[y+0]=a[0]*s+a[3]*l+a[6]*c,h[y+1]=a[1]*s+a[4]*l+a[7]*c,h[y+2]=a[2]*s+a[5]*l+a[8]*c}p.needsUpdate=!0,d.needsUpdate=!0}reverseIndicesOnRange(e,r){let o=this.index;if(o){for(let n=e;n<r;n+=3){let a=o.getX(n),s=o.getX(n+1),l=o.getX(n+2);o.setXYZ(n,l,s,a)}o.needsUpdate=!0}}};var In=require("three"),lb=require("three/examples/jsm/utils/BufferGeometryUtils.js");function cb(){let i=new In.BufferGeometry;return i.setAttribute("position",new In.BufferAttribute(new Float32Array([]),3)),i.setIndex(new In.BufferAttribute(new Uint16Array([]),1)),i}var SI=cb().attributes,wI=12,PI=1,En=class extends In.BufferGeometry{constructor(e,r){super();this.charWidths=[];this.charCoords=[];this.wrappedText=[];this.isLowResolution=!1;this.vectorShapes=[];Object.assign(this.attributes,SI),this.userData={parameters:e,type:"TextGeometry"};let o=r.getFont(e.font);o?.isLoaded?(this.font=o,this.update(e,r)):this.updateFont(e.font,r).then(()=>{this.update(e,r),r?.requestRender()})}async updateFont(e,r){let o=r.getFont(e);o&&(this.font=o,await o.loadingPromise)}update(e,r){let o=this.font;if(this.userData={parameters:e,type:"TextGeometry"},!o?.isLoaded){console.warn("Cannot update text because its font is not loaded");return}let{width:n,height:a,depth:s,extrudeBevelSize:l,extrudeBevelSegments:c,text:u,textTransform:p}=e,d=Vi.getDisplayedValue(u),f=p===2?d.toUpperCase():p===3?d.toLowerCase():d,h=OI(e,o,f,r),{shapes:m,charWidths:y,charCoords:b}=o.generateShapes(h,e,r),v=(typeof n=="number"?n:Number(r.getVariable(n)))*.5,w=(typeof a=="number"?a:Number(r.getVariable(a)))*.5,O=m.map(M=>new Xe().fromShape(M,!0));this.vectorShapes=O;let S=O.map(M=>wr.create({shape:M,parameters:{depth:s,extrudeBevelSegments:c,extrudeBevelSize:l,windingRule:s<=0?$e.NONZERO:$e.ODD,subdivisions:this.isLowResolution&&s>0?PI:wI}})),T=S.length?(0,lb.mergeBufferGeometries)(S):cb();T.translate(-v,w,0),this.dispose(),this.wrappedText=h,this.charCoords=b,this.charWidths=y,this.deleteAttribute("extrudeNormal"),Object.entries(T.attributes).forEach(([M,g])=>{this.setAttribute(M,g)}),this.setIndex(T.index),this.computeBoundingSphere()}clone(){let e=Ft(new In.BufferGeometry,En.prototype);return e.copy(this),console.log("CloneGeometry",this,e),e}copy(e){return Object.entries(e.attributes).forEach(([r,o])=>{this.setAttribute(r,o)}),this.setIndex(e.index),this.userData={parameters:{...e.userData.parameters},type:"TextGeometry"},this}async setText(e,r){this.font&&await this.font.loadingPromise,await this.update({...this.userData.parameters,text:{textValue:e}},r)}get text(){return this.userData.parameters.text??""}};function OI(i,t,e,r){let o=typeof i.width=="string"?Number(r.getVariable(i.width)):i.width,n=[""],a="";for(let s of e)a+=s,s===" "||s===`
17
17
  `?(n[n.length-1]+=a,a="",s===`
18
- `&&n.push("")):t.getTextWidth(n[n.length-1]+a,i)>o&&(n[n.length-1].length&&n.push(""),t.getTextWidth(n[n.length-1]+a,i)>o&&(a.length===1?(n[n.length-1]+=a,a=""):(n[n.length-1]+=a.slice(0,-1),a=a[a.length-1],n.push(""))));return n[n.length-1]+=a,n}var lt=require("three");var db,Ju=new Promise(i=>{db=i}),ub=!1;var Zu;function pb(i){if(ub)return;if(Zu)return Zu;async function t(){let r=i??(!1?".":"https://unpkg.com/@splinetool/modelling-wasm@1.10.77/build"),n=import("./process.js"),[a,s]=await Promise.all([n,fetch(`${r}/process.wasm`).then(u=>u.arrayBuffer())]),l=a.default,c=await l({wasmBinary:s});db(c),ub=!0}return Zu=t(),Zu}var fb=require("three");var TI=["font"];function Lo(i,t,e,r){let o,n,a;i.type==="PathGeometry"?(n=JSON.parse(JSON.stringify(i)),a=[[],["extrusion"]]):(n={...i},a=[[]]);for(let c of a){let u=n;for(let p of c)u=u[p];for(o in u){let p=u[o];Wp(p)&&!TI.includes(o)&&(u[o]=t.getVariable(p,[r.uuid,"geometry",...c,o]),Wp(u[o])&&(u[o]=1))}}let s={parameters:n,type:n.type};if(n.type==="PathGeometry")s.path=n.path;else if(n.type==="VectorGeometry"){let c=Xe.createFromState(n.shape,n.width,n.height);s.shape=c}else if(n.type==="NonParametricGeometry"){if(n.data.groups&&n.data.groups?.forEach(c=>c.materialIndex=Math.max(c.materialIndex??0,0)),s.geometry=new fb.BufferGeometryLoader().parse(n),s.geometry.groups.length===0){let c=s.geometry;c.addGroup(0,Math.max(c.getIndex()?.count??0,c.getAttribute("position").count),0)}}else if(n.type==="SubdivGeometry"){let c=new Rt(n,e);return c.data=i,c}else{if(n.type==="TextGeometry")return new En(n,t);if(n.type==="InputGeometry")return new En(n,t);if(n.type==="UIGeometry")return Za.create({parameters:{width:n.width,height:n.height,cornerRadius:n.cornerRadius,cornerType:n.cornerType}})}let l;try{l=Uf(s)}catch(c){console.error(c)}if(!l){let c=Xe.createFromState(Ma.defaultData(),100,100);s.shape=c,l=Uf(s)}return l}var hb=require("three"),CI=new hb.Matrix4;function _l(i,t,e,r){let o=i.position.array,n=i.normal.array,a=CI.makeScale(t,e,r).invert().elements,s,l,c;for(var u=0,p=o.length;u<p;u+=3)o[u]*=t,o[u+1]*=e,o[u+2]*=r,s=n[u],l=n[u+1],c=n[u+2],n[u]=a[0]*s+a[4]*l+a[8]*c,n[u+1]=a[1]*s+a[5]*l+a[9]*c,n[u+2]=a[2]*s+a[6]*l+a[10]*c;i.position.needsUpdate=!0,i.normal.needsUpdate=!0}var ed=new lt.Box3,es=new lt.Vector3,Pe;Ju.then(i=>{Pe=i});var mb=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),yb=new Uint32Array([0,1,2,3]),gb=new Uint8Array([4]),Rt=class extends lt.BufferGeometry{constructor(e,r){super();this.data=e;this.flatShading=r;this.subdivPointer=0;this.rebuild(),this.freeSubdivPointer()}mutateDirectlyScaleBaked(e,r){this.freeSubdivPointer();let o=this.data.scaleBaked,n=Ni.div(r,o);if(n.every(l=>l===1))return;this.subdividedGeometry&&_l(this.subdividedGeometry.attributes,...n),this.originalGeometry&&_l(this.originalGeometry.attributes,...n),this.data=e;let a=this.userData.parameters;this.userData.parameters={width:a.width*n[0],height:a.height*n[1],depth:a.depth*n[2]},this.originalGeometry.boundingSphere.center.multiply(es.fromArray(n));let s=es.set(a.width,a.height,a.depth).length();this.originalGeometry.boundingSphere.radius=s/2}ensureSubdivPointer(){return this.subdivPointer===0&&this.rebuild(),this.subdivPointer}rebuild(){let e,r,o;try{({originalGeometry:e,subdividedGeometry:r,subdivPointer:o}=Rt.build(this.data,void 0,!this.flatShading,void 0))}catch{e=new lt.BoxGeometry(100,100,100),o=0}this.subdivPointer=o,this.originalGeometry=e,this.subdividedGeometry=r??void 0;let n=this.subdividedGeometry??this.originalGeometry;Object.assign(this,n),this.calcBoundingBox()}freeSubdivPointer(){this.subdivPointer&&(Rt.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0)}dispose(){super.dispose(),this.freeSubdivPointer()}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new lt.Sphere,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let r=e.attributes.position,o=e.boundingSphere.center;ed.setFromBufferAttribute(r),ed.getCenter(o),e.boundingSphere.radius=o.distanceTo(ed.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),ed.getSize(es);let n={width:es.x,height:es.y,depth:es.z};return this.userData.parameters=n,n}static build(e,r,o,n){let a,s,l,c=e?.phongAngle??35;o===!1&&(c=-1),r&&(Pe.free_bvh(r),Pe.free_subdivision_surface(r));try{a=Rt.allocate(e,n)}catch(u){console.error(u,e),a=Rt.allocate({positionWASM:mb,indexWASM:yb,verticesPerFaceWASM:gb},n)}if(Pe.set_destination_refinement_level(a,0),s=Rt.buildLevel(a,!0,c),e.subdivisions>0)try{Pe.set_destination_refinement_level(a,e.subdivisions),l=Rt.buildLevel(a,!1,c)}catch{try{Pe.set_destination_refinement_level(a,e.subdivisions-1),l=Rt.buildLevel(a,!1,c)}catch{l=null}}else l=null;return{subdivPointer:a,originalGeometry:s,subdividedGeometry:l}}static primitiveToQuads(e,r,o){e.widthSegments>16&&(e.widthSegments=16),e.heightSegments>16&&(e.heightSegments=16),e.depthSegments>16&&(e.depthSegments=16),e.radialSegments>16&&(e.radialSegments=16),e.type==="DodecahedronGeometry"&&(e.detail=0);let n=e.shape!==void 0||e.path!==void 0?r.geometry:Lo(e,o,!1,r),a;e.type==="TorusGeometry"&&e.arc===Math.PI*2?a=n.getClosedTorusIndicesForBooleanOrSubdiv():a=n.getIndex();let s,l,c,u;({positions:s,triIndices:u}=qf(n.getAttribute("position"),a));let p;if(e.type==="CylinderGeometry"&&e.cornerRadius===0&&e.hollow===0&&e.openEnded===!1){let d=e.radialSegments*e.heightSegments*3*2,f=d+e.radialSegments*3;p=[d,f]}return{indices:l,verticesPerFace:c}=$f(s,u,n,p),{positions:s,indices:l,verticesPerFace:c}}static allocate(e,r){let o,n,a,s=[],l=[];e.positionWASM&&e.positionWASM.length>0?(o=e.positionWASM,n=e.indexWASM,a=e.verticesPerFaceWASM):(o=mb,n=yb,a=gb);let c=o.length,u=n.length,p=a.length,d=o.length+s.length+l.length,f=n.length+a.length,h=d*Float32Array.BYTES_PER_ELEMENT+f*Uint32Array.BYTES_PER_ELEMENT,m=d*Float32Array.BYTES_PER_ELEMENT,y=f*Uint32Array.BYTES_PER_ELEMENT,b=Pe._malloc(h),v=new Float32Array(Pe.HEAPF32.buffer,b,d),w=new Uint32Array(Pe.HEAPU32.buffer,b+m,f);v.set(o,0),v.set(s,o.length),v.set(l,o.length+s.length),w.set(n,0),w.set(a,n.length);let O;e?.scaleBaked?.some(T=>T!==1)&&(O=new lt.Matrix4().makeScale(...e.scaleBaked)),r&&(O?O.premultiply(r):O=r);let S=O?Pe.alloc_subdivision_surface2(b,c,b+m,u,b+m+n.length*Uint32Array.BYTES_PER_ELEMENT,p,O.elements):Pe.alloc_subdivision_surface(b,c,b+m,u,b+m+n.length*Uint32Array.BYTES_PER_ELEMENT,p);return Pe._free(b),S}static buildLevel(e,r,o,n,a){let s=a?Pe.get_mesh_data2(e,r?Pe.Level.CONTROL:Pe.Level.REFINED,o,a.elements):Pe.get_mesh_data(e,r?Pe.Level.CONTROL:Pe.Level.REFINED,o),l=8,c=Pe.HEAPU32.subarray(s>>2,(s>>2)+l),u=c.subarray(4,4+4),p=0,d=Pe.HEAPU32[c[p]>>2],f=Pe.HEAPF32.subarray(d>>2,(d>>2)+u[p]);p++;let h=Pe.HEAPU32[c[p]>>2],m=Pe.HEAPF32.subarray(h>>2,(h>>2)+u[p]);p++;let y=Pe.HEAPU32[c[p]>>2],b=Pe.HEAPU32.subarray(y>>2,(y>>2)+u[p]);p++;let v=Pe.HEAPU32[c[p]>>2],w=Pe.HEAPU32.subarray(v>>2,(v>>2)+u[p]);if(p++,n===void 0){let O=new lt.BufferGeometry;if(O.setIndex(new lt.Uint32BufferAttribute(w,1)),O.setAttribute("position",new lt.Float32BufferAttribute(f,3)),O.setAttribute("normal",new lt.Float32BufferAttribute(m,3)),r){O.setAttribute("faceMap",new lt.Uint32BufferAttribute(b,1));let S=new Float32Array(m.length/3*4).fill(0);O.setAttribute("color",new lt.BufferAttribute(S,4))}return Pe.free_mesh_data(s),O.userData.type="SubdivGeometry",O}n.getAttribute("position").copyArray(f),n.getAttribute("normal").copyArray(m),n.attributes.position.needsUpdate=!0,n.attributes.normal.needsUpdate=!0,Pe.free_mesh_data(s)}static freeSubdivPointer(e){Pe.free_bvh(e),Pe.free_subdivision_surface(e)}static buildControlCageWireframe(e,r,o){let n=Pe.get_wireframe_data_for_base_level(e),a=4,s=Pe.HEAPU32.subarray(n>>2,(n>>2)+a),l=s.subarray(2,2+2),c=0,u=Pe.HEAPU32[s[c]>>2],p=Pe.HEAPF32.subarray(u>>2,(u>>2)+l[c]);c++;let d=Pe.HEAPU32[s[c]>>2],f=Pe.HEAPU32.subarray(d>>2,(d>>2)+l[c]);if(r===void 0){let h=new lt.BufferGeometry;h.setAttribute("position",new lt.Float32BufferAttribute(p,3));let m=new Float32Array(p.length);for(let y=0,b=p.length;y<b;)m[y++]=o.r,m[y++]=o.g,m[y++]=o.b;return h.setAttribute("color",new lt.BufferAttribute(m,3)),h.setIndex(new lt.Uint32BufferAttribute(f,1)),Pe.free_wireframe_data_for_base_level(n),h}r.getAttribute("position").copyArray(p),r.attributes.position.needsUpdate=!0,Pe.free_wireframe_data_for_base_level(n)}static updateCollabMesh(e,r,o){let n=r===0;n||Pe.set_destination_refinement_level(e,r);let a=o?Pe.get_topological_data2(e,n?Pe.Level.CONTROL:Pe.Level.REFINED,o.elements):Pe.get_topological_data(e,n?Pe.Level.CONTROL:Pe.Level.REFINED),s=6,l=Pe.HEAPU32.subarray(a>>2,(a>>2)+s),c=l.subarray(3,3+3),u=0,p=Pe.HEAPU32[l[u]>>2],d=new Float32Array(Pe.HEAPF32.subarray(p>>2,(p>>2)+c[u]));u++;let f=Pe.HEAPU32[l[u]>>2],h=new Uint32Array(Pe.HEAPU32.subarray(f>>2,(f>>2)+c[u]));u++;let m=Pe.HEAPU32[l[u]>>2],y=new Uint8Array(Pe.HEAPU32.subarray(m>>2,(m>>2)+c[u]));return Pe.free_topological_data(a),{positions:d,indices:h,verticesPerFace:y}}};var xb=["getX","getY","getZ"];function qf(i,t){let e={},r=t?t.count:i.count,o=0,n=[],a=[],s=1e4;for(let c=0;c<r;c++){let u=t?t.getX(c):c,p="";for(let d=0;d<3;d++)p+=`${~~(i[xb[d]](u)*s)},`;if(p in e)n.push(e[p]);else{for(let d=0;d<3;d++)a.push(i[xb[d]](u));e[p]=o,n.push(o),o++}}let l=[];for(let c=0;c<n.length;c+=3)n[c]===n[c+1]||n[c]===n[c+2]||n[c+1]===n[c+2]||l.push(n[c],n[c+1],n[c+2]);return{positions:a,triIndices:l}}var td=new lt.Vector3,kf=new lt.Vector3,Hf=new lt.Vector3,Wf=new lt.Vector3;function $f(i,t,e,r){let o=[],n=[];if(e.userData.shape!==void 0&&e.userData.parameters.depth===0&&e.userData.shape.shapeHoles.length===0){let l=e.userData.shape.extractShapePointsToFlatArray([]),c=e.userData.parameters.spikes;if(e.userData.type==="EllipseGeometry"&&c<=24&&c%4===0&&e.userData.parameters.angle>=360){let d=l.length/2/c;l=l.filter((f,h)=>Math.floor(h/2)%d===0)}let u=0;for(let d=0;d<l.length;d+=2)u+=(l[d]-l[(d===0?l.length:d)-2])*(l[d+1]+l[(d===0?l.length:d)-1]);i.length=0;let p=0;if(u<0)for(let d=0;d<l.length;d+=2)i.push(l[d],l[d+1],0),o.push(p++);else for(let d=l.length-2;d>=0;d-=2)i.push(l[d],l[d+1],0),o.push(p++);return n.push(p),{indices:o,verticesPerFace:n}}let a=new Float32Array([e.userData.parameters.depth])[0],s=0;for(;s<t.length;){if(e.useNgonForTopBottomFaceDuringBake){let l=0;if((i[t[s]*3+2]===a||i[t[s]*3+2]===0)&&l++,(i[t[s+1]*3+2]===a||i[t[s+1]*3+2]===0)&&l++,(i[t[s+2]*3+2]===a||i[t[s+2]*3+2]===0)&&l++,l===3)break}if(t[s+1]===t[s+3]&&t[s+2]===t[s+5]||t[s+0]===t[s+3]&&t[s+2]===t[s+4]){td.set(i[t[s]*3],i[t[s]*3+1],i[t[s]*3+2]),kf.set(i[t[s+1]*3],i[t[s+1]*3+1],i[t[s+1]*3+2]),Hf.set(i[t[s+4]*3],i[t[s+4]*3+1],i[t[s+4]*3+2]),Wf.set(i[t[s+5]*3],i[t[s+5]*3+1],i[t[s+5]*3+2]),kf.sub(td).normalize(),Hf.sub(td).normalize(),Wf.sub(td).normalize();let l=kf.cross(Hf).dot(Wf);Math.abs(l)>.005||r&&r.some((c,u)=>u%2===1?!1:s>=r[u]&&s<r[u+1])?(o.push(t[s],t[s+1],t[s+2]),n.push(3),s+=3):(o.push(t[s],t[s+1],t[s+4],t[s+5]),n.push(4),s+=6)}else o.push(t[s],t[s+1],t[s+2]),n.push(3),s+=3}if(e.useNgonForTopBottomFaceDuringBake){let l=[],c=[],u=0;for(let p=0,d=0;p<i.length;p+=3,d++)i[p+2]===0&&(l.push(d),u++),i[p+2]===a&&c.push(d);if(e.userData.parameters.extrudeBevelSize===0){let p=c[0];c[0]=c[1],c[1]=p}l.reverse(),o.push(...l,...c),n.push(u,u)}return{indices:o,verticesPerFace:n}}var Wr={};lm(Wr,{calcBoolean:()=>EI,calcBooleanTopological:()=>II,freeMeshSet:()=>RI,getMeshSet:()=>NI,hasOpenEdges:()=>DI,transformMeshSet:()=>_I});var AI,bb=new Promise(i=>{AI=i});var Rl=require("three");var Ue,ts;bb.then(i=>Ue=i);function MI(i,t,e){let r,o;i.userData.parameters.type==="TorusGeometry"&&i.userData.parameters.arc===Math.PI*2?o=i.getClosedTorusIndicesForBooleanOrSubdiv():o=i.getIndex();let{positions:n,triIndices:a}=qf(i.getAttribute("position"),o),s;if(t&&e){let{indices:l,verticesPerFace:c}=$f(n,a,i);s=c.length,r=[];for(let u=0,p=0;u<s;u++){r.push(c[u]);for(let d=0;d<c[u];d++)r.push(l[p++])}}else{let l=a.length;r=Array(l+l/3),s=0;for(let c=0,u=0;u<r.length;)r[u++]=3,s++,r[u++]=a[c++],r[u++]=a[c++],r[u++]=a[c++]}return{positions:n,faceIndices:r,nFaces:s}}function vb(i){let t=i.length,e=t*Uint32Array.BYTES_PER_ELEMENT,r=t*Float32Array.BYTES_PER_ELEMENT,o=Number.isInteger(i[0])?e:r,n=Ue._malloc(o);return(Number.isInteger(i[0])?new Uint32Array(Ue.HEAPU32.buffer,n,t):new Float32Array(Ue.HEAPF32.buffer,n,t)).set(i,0),n}function Sb(i){switch(i){case 0:return Ue.OP.UNION;case 1:return Ue.OP.INTERSECTION;case 2:return Ue.OP.A_MINUS_B;default:throw new Error("Unknown boolean operation "+i)}}function II(i,t){ts===void 0&&(ts=Ue.init_csg());let e=vb(i),r=Ue.csg_calc_topological(ts,e,i.length,Sb(t));Ue._free(e);let o=6,n=Ue.HEAPU32.subarray(r>>2,(r>>2)+o),a=n.subarray(3,3+3),s=0,l=Ue.HEAPU32[n[s]>>2],c=new Float32Array(Ue.HEAPF32.subarray(l>>2,(l>>2)+a[s]));s++;let u=Ue.HEAPU32[n[s]>>2],p=new Uint32Array(Ue.HEAPU32.subarray(u>>2,(u>>2)+a[s]));s++;let d=Ue.HEAPU32[n[s]>>2],f=new Uint8Array(Ue.HEAPU32.subarray(d>>2,(d>>2)+a[s]));return Ue.free_mesh_data(r),{positions:c,indices:p,verticesPerFace:f}}function EI(i,t,e,r){ts===void 0&&(ts=Ue.init_csg());let o=vb(i),n=Ue.csg_calc(ts,o,i.length,r,Sb(t));Ue._free(o);let a=5,s=Ue.HEAPU32.subarray(n>>2,(n>>2)+a),l=s.subarray(2,2+3),c=0,u=Ue.HEAPU32[s[c]>>2],p=Ue.HEAPF32.subarray(u>>2,(u>>2)+l[c]);c++;let d=Ue.HEAPU32[s[c]>>2],f=Ue.HEAPF32.subarray(d>>2,(d>>2)+l[c]);c++;let h=l[c];e.setAttribute("position",new Rl.Float32BufferAttribute(p,3)),e.setAttribute("normal",new Rl.Float32BufferAttribute(f,3));let m=Ue.HEAPF32.subarray((n>>2)+5,(n>>2)+5+6);return e.boundingSphere===null&&(e.boundingSphere=new Rl.Sphere),e.boundingSphere.center.set(m[0],m[1],m[2]),e.boundingSphere.radius=(m[3]**2+m[4]**2+m[5]**2)**.5,e.userData.parameters={width:m[3]*2,height:m[4]*2,depth:m[5]*2},Ue.free_mesh_data(n),h}function NI(i,t,e){if(Ue===void 0)return-1;let r,o,n;if(t&&i.userData.positions!==void 0){let b=i.userData;n=b.verticesPerFace.length,r=b.positions,o=Array(b.verticesPerFace.reduce((v,w)=>v+w,0)+n);for(let v=0,w=0,O=0;v<b.verticesPerFace.length;v++){o[O++]=b.verticesPerFace[v];for(let S=0;S<b.verticesPerFace[v];S++)o[O++]=b.indices[w++]}}else({positions:r,faceIndices:o,nFaces:n}=MI(i,t,e));let a=r.length,s=o.length,l=r.length,c=o.length,u=l*Float32Array.BYTES_PER_ELEMENT+c*Uint32Array.BYTES_PER_ELEMENT,p=l*Float32Array.BYTES_PER_ELEMENT,d=c*Uint32Array.BYTES_PER_ELEMENT,f=Ue._malloc(u),h=new Float32Array(Ue.HEAPF32.buffer,f,l),m=new Uint32Array(Ue.HEAPU32.buffer,f+p,c);h.set(r,0),m.set(o,0);let y=Ue.get_csg_mesh(f,a,f+p,s,n);return Ue._free(f),y}function DI(i){return Ue.has_open_edges(i)}function _I(i,t){Ue.transform_csg_mesh(i,t.elements)}function RI(i){Ue.free_csg_mesh(i)}var LI={ConeGeometry:dx,CubeGeometry:px,CylinderGeometry:ux,DodecahedronGeometry:hx,EllipseGeometry:Ya,HelixGeometry:Gx,IcosahedronGeometry:jx,LatheGeometry:Ux,NonParametricGeometry:qx,PolygonGeometry:Yu,PyramidGeometry:$x,RectangleGeometry:Za,SphereGeometry:Xx,PlaneGeometry:Kx,BackdropGeometry:Qx,StarGeometry:Ku,TextFrameGeometry:Jx,TorusGeometry:eb,TorusKnotGeometry:rb,TriangleGeometry:ob,PathGeometry:sb,VectorGeometry:wr},Uf=i=>LI[i.type].create(i);function rs(i){return i!==null&&"booleanOp"in i}var os=class extends ja(rd.Mesh){constructor(){super(...arguments);this.booleanMeshSetAddress=-1;this.booleanWasTransformed=!1;this.booleanMatrixInvOld=new rd.Matrix4}updateVisible(e){super.updateVisible(e),this.visible=!rs(this.parent)&&this.visible,rs(this.parent)&&this.parent.invalidateDownstreamBooleanData()}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(Wr.freeMeshSet(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}invalidateDownstreamBooleanData(e=!1){return e?this.booleanWasTransformed=!0:this.freeBooleanPointer(),rs(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let e of this.children)e instanceof os&&(e.freeBooleanPointer(),rs(e)&&e.invalidateUpstreamBooleanData())}updateTransformState(e,r){let o=super.updateTransformState(e,r);return o&&rs(this.parent)&&this.invalidateDownstreamBooleanData(!0),o}onVariableUpdate(e=!1){super.onVariableUpdate(e),rs(this.parent)&&this.invalidateDownstreamBooleanData(!0)}};var od=new is.Box3;function Ll(i,t=0,e=i.count,r,o){let n=1/0,a=1/0,s=1/0,l=-1/0,c=-1/0,u=-1/0;for(let p=t;p<e;p++){let d=i.getX(p),f=i.getY(p),h=i.getZ(p);d<n&&(n=d),f<a&&(a=f),h<s&&(s=h),d>l&&(l=d),f>c&&(c=f),h>u&&(u=h)}od.min.set(n,a,s),od.max.set(l,c,u),od.getCenter(r),od.getSize(o).multiplyScalar(.5)}var BI=new is.BufferGeometry,VI=new is.MeshBasicMaterial,Wt=class extends os{constructor(t,e){super(BI,VI),this.super_Entity(t,e)}updateState(t,e){this.updateState_Entity(t,e)}updateEntityBoxSize(t,e){let r=this.geometry.getAttribute("position");r!==void 0?Ll(r,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:r.count,t,e):super.updateEntityBoxSize(t,e)}};var mi=require("three");var Br=require("three");var kb=require("three");var di=class{constructor(t){this.hashProperties=void 0;this.isNode=!0;this.shortcuts={};if(di.uuidContext===null)throw new Error("plz startContext");di.uuidContext===di.globalContext?this.uuid="_gid"+di.uuidContext.nodeContextUuid++:this.uuid="_uid"+di.uuidContext.nodeContextUuid++,this.type=t,this.name=""}static startContext(t){this.uuidContext===null||this.uuidContext===di.globalContext?this.uuidContext=t:console.error("Can't start context twice")}static endContext(t){this.uuidContext!==t&&console.error("Can't end context twice"),this.uuidContext=null}analyze(t,e){e=e??{},t.analyzing=!0,this.build(t.addFlow(e.slot,e.cache,e.context),"v4"),t.clearVertexNodeCode(),t.clearFragmentNodeCode(),t.removeFlow(),t.analyzing=!1}analyzeAndFlow(t,e,r){return r=r??{},this.analyze(t,r),this.flow(t,e,r)}flow(t,e,r){r=r??{},t.addFlow(r.slot,r.cache,r.context);let o={result:this.build(t,e),code:t.clearNodeCode(),extra:t.context.extra};return t.removeFlow(),o}build(t,e,r){e=e??this.getType(t,e);let o=t.getNodeData(r??this);return t.analyzing&&this.appendDepsNode(t,o,e),t.nodes.indexOf(this)===-1&&t.nodes.push(this),this.updateFrame!==void 0&&t.updaters.indexOf(this)===-1&&t.updaters.push(this),this.generate(t,e,r)}updateFrame(t){}generateReadonly(t,e,r,o,n,a){return""}generate(t,e,r,o,n){return""}parse(t,e,r,o){}appendDepsNode(t,e,r){e.deps=(e.deps||0)+1;let o=t.getTypeLength(r);(o>(e.outputMax||0)||this.getType(t,r))&&(e.outputMax=o,e.output=r)}setName(t){this.name=t}getName(){return this.name}getType(t,e){return e==="sampler2D"||e==="samplerCube"?e:this.type}},ot=di;ot.globalContext={nodeContextUuid:0},ot.uuidContext=di.globalContext;var mo=require("three");var Bl=class{constructor(t){t=t??{},this.name=t.name,this.type=t.type,this.node=t.node,this.size=t.size,this.needsUpdate=t.needsUpdate}get value(){return this.node.value}set value(t){this.node.value=t}};var Xf=class{constructor(){this.nodes={};this.keywords={}}add(t){this.nodes[t.name]=t}addKeyword(t,e,r){r=r!==void 0?r:!0,this.keywords[t]={callback:e,cache:r}}remove(t){delete this.nodes[t.name]}removeKeyword(t){delete this.keywords[t]}get(t){return this.nodes[t]}getKeyword(t,e){return this.keywords[t].callback(e)}getKeywordData(t){return this.keywords[t]}contains(t){return this.nodes[t]!==void 0}containsKeyword(t){return this.keywords[t]!==void 0}},qt=new Xf;var Yf=require("three");var wb=require("three"),be=class extends ot{constructor(e,r){super(e);this.scope="";r=r??{},this.shared=r.shared!==void 0?r.shared:!0,this.unique=r.unique!==void 0?r.unique:!1}build(e,r,o,n){if(r=r??this.getType(e),this.getShared(e,r)){let a=this.getUnique(e,r);a&&this.uuid===void 0&&(this.uuid=wb.MathUtils.generateUUID()),o=e.getUUID(o??this.getUUID(),!a);let s=e.getNodeData(o),l=s.output||this.getType(e);if(e.analyzing)return(s.deps||0)>0||this.getLabel()?(this.appendDepsNode(e,s,r),this.generate(e,r,o)):super.build(e,r,o);if(a)return s.name=s.name||super.build(e,r,o),s.name;if(!this.getLabel()&&(!this.getShared(e,l)||e.context.ignoreCache||s.deps===1))return super.build(e,r,o);o=this.getUUID(!1);let c=this.getTemp(e,o);if(c)return e.format(c,l,r);{c=super.generate(e,r,o,s.output,n);let u=this.generate(e,l,o);return e.addNodeCode(c+" = "+u+";"),e.format(c,l,r)}}return super.build(e,r,o)}getShared(e,r){return r!=="sampler2D"&&r!=="samplerCube"&&this.shared}getUnique(e,r){return this.unique}setLabel(e){return this.label=e,this}getLabel(){return this.label}getUUID(e){let r=this.uuid;return typeof this.scope=="string"&&(r=this.scope+"-"+r),r}getTemp(e,r){r=r||this.uuid;let o=e.getVars()[r];return o?o.name:void 0}generate(e,r,o,n,a){return this.getShared(e,r)||console.error("TempNode is not shared"),o=o??this.uuid,e.getTempVar(o,n??this.getType(e),a,this.getLabel()).name}};var it=class extends be{constructor(e,r){r=r??{},r.shared=r.shared!==void 0?r.shared:!1;super(e,r);this.readonly=!1}setReadonly(e){return this.readonly=e,this.hashProperties=this.readonly?["value"]:void 0,this}getReadonly(){return this.readonly}generate(e,r,o,n,a,s){o=e.getUUID(o??this.getUUID()),n=n??this.getType(e);let l=e.getNodeData(o);return this.getReadonly()&&this.generateReadonly!==void 0?this.generateReadonly(e,r,o,n,a,s):e.isShader("vertex")?(l.vertex||(l.vertex=e.createVertexUniform(n,this,a,s,this.getLabel())),e.format(l.vertex.name,n,r)):(l.fragment||(l.fragment=e.createFragmentUniform(n,this,a,s,this.getLabel())),e.format(l.fragment.name,n,r))}};var wt=class extends it{constructor(e=0,r){super("v2");this.nodeType="Vector2";this.value=e instanceof Yf.Vector2?e:new Yf.Vector2(e,r)}get x(){return this.value.x}set x(e){this.value.x=e}get y(){return this.value.y}set y(e){this.value.y=e}generateReadonly(e,r,o,n,a,s){return e.format("vec2("+this.value.x+", "+this.value.y+")",n,r)}};var Kf=require("three");var or=class extends it{constructor(e=0,r,o){super("v3");this.nodeType="Vector3";this.value=e instanceof Kf.Vector3?e:new Kf.Vector3(e,r,o)}get x(){return this.value.x}set x(e){this.value.x=e}get y(){return this.value.y}set y(e){this.value.y=e}get z(){return this.value.z}set z(e){this.value.z=e}generateReadonly(e,r,o,n,a,s){return e.format("vec3("+this.value.x+", "+this.value.y+", "+this.value.z+")",n,r)}};var Pr=class extends it{constructor(e){super("v4");this.nodeType="Vector4";this.value=e instanceof kt?e:new kt(e.r,e.g,e.b,e.a)}generateReadonly(e,r,o,n,a,s){return e.format("vec4("+this.value.r+", "+this.value.g+", "+this.value.b+", "+this.value.a+")",n,r)}};var zI=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,Pb=/[a-z_0-9]+/gi,J=class extends be{constructor(e,r,o,n,a){super(a);this.src="";this.nodeType="Function";this.useKeywords=!0;this.includes=[];this.extensions={};this.keywords={};this.isMethod=a===void 0,this.isInterface=!1,this.parse(e,r,o,n)}getShared(e,r){return!this.isMethod}getType(e){return e.getTypeByFormat(this.type)}getInputByName(e){if(this.inputs){let r=this.inputs.length;for(;r--;)if(this.inputs[r].name===e)return this.inputs[r]}}getIncludeByName(e){if(this.includes){let r=this.includes.length;for(;r--;)if(this.includes[r].name===e)return this.includes[r]}}generate(e,r,o,n,a){let s,l=0,c=this.src;if(this.includes)for(let p=0;p<this.includes.length;p++)e.include(this.includes[p],this);for(let p in this.extensions)e.extensions[p]=!0;let u=[];for(;s=Pb.exec(this.src);)u.push(s);for(let p=0;p<u.length;p++){let d=u[p],f=d[0],h=this.isMethod?!this.getInputByName(f):!0,m=f;if(this.keywords[f]||this.useKeywords&&h&&qt.containsKeyword(f)){let y=this.keywords[f];if(!y){let b=qt.getKeywordData(f);b.cache&&(y=e.keywords[f]),y=y||qt.getKeyword(f,e),b.cache&&(e.keywords[f]=y)}m=y.build(e)}f!==m&&c[d.index+l-1]!=="."&&(c=c.substring(0,d.index+l)+m+c.substring(d.index+f.length+l),l+=m.length-f.length),this.getIncludeByName(m)===void 0&&qt.contains(m)&&e.include(qt.get(m))}return r==="source"?c:this.isMethod?(this.isInterface||e.include(this,void 0,c),this.name):e.format("( "+c+" )",this.getType(e),r)}parse(e,r,o,n){if(this.src=e||"",this.includes=r??[],this.extensions=o??{},this.keywords=n??{},this.isMethod){let a=zI.exec(this.src);if(this.inputs=[],a&&a.length==4){this.type=a[1],this.name=a[2];let s=a[3].match(Pb);if(s){let l=0;for(;l<s.length;){let c=s[l++],u;c==="in"||c==="out"||c==="inout"?u=s[l++]:(u=c,c="");let p=s[l++];this.inputs.push({name:p,type:u,qualifier:c})}}this.isInterface=this.src.indexOf("{")===-1}else this.type="",this.name=""}}};var GI=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=?\s?(.*?)(\;|$)/i,Qf=class extends be{constructor(e="",r){super();this.src="";this.useDefine=!1;this.nodeType="Const";this.parse(e||Qf.PI,void 0,void 0,void 0,r)}getType(e){return e.getTypeByFormat(this.type)}parse(e,r,o,n,a){this.src=e||"";let s,l,c="",u=GI.exec(e);this.useDefine=a??this.src.charAt(0)==="#",u&&u.length>1?(l=u[1],s=u[2],c=u[3]):(s=this.src,l="f"),this.name=s,this.type=l,this.value=c}build(e,r){if(r==="source"){if(this.value)return this.useDefine?"#define "+this.name+" "+this.value:"const "+this.type+" "+this.name+" = "+this.value+";";if(this.useDefine)return this.src}return e.include(this),e.format(this.name,this.getType(e),r)}generate(e,r,o,n,a){return e.format(this.name,this.getType(e),r)}},qe=Qf;qe.PI="PI",qe.PI2="PI2",qe.RECIPROCAL_PI="RECIPROCAL_PI",qe.RECIPROCAL_PI2="RECIPROCAL_PI2",qe.LOG2="LOG2",qe.EPSILON="EPSILON";var FI=new RegExp(`^structs*([a-z_0-9]+)s*{s*((.|
18
+ `&&n.push("")):t.getTextWidth(n[n.length-1]+a,i)>o&&(n[n.length-1].length&&n.push(""),t.getTextWidth(n[n.length-1]+a,i)>o&&(a.length===1?(n[n.length-1]+=a,a=""):(n[n.length-1]+=a.slice(0,-1),a=a[a.length-1],n.push(""))));return n[n.length-1]+=a,n}var lt=require("three");var db,Ju=new Promise(i=>{db=i}),ub=!1;var Zu;function pb(i){if(ub)return;if(Zu)return Zu;async function t(){let r=i??(!1?".":"https://unpkg.com/@splinetool/modelling-wasm@1.10.78/build"),n=import("./process.js"),[a,s]=await Promise.all([n,fetch(`${r}/process.wasm`).then(u=>u.arrayBuffer())]),l=a.default,c=await l({wasmBinary:s});db(c),ub=!0}return Zu=t(),Zu}var fb=require("three");var TI=["font"];function Lo(i,t,e,r){let o,n,a;i.type==="PathGeometry"?(n=JSON.parse(JSON.stringify(i)),a=[[],["extrusion"]]):(n={...i},a=[[]]);for(let c of a){let u=n;for(let p of c)u=u[p];for(o in u){let p=u[o];Wp(p)&&!TI.includes(o)&&(u[o]=t.getVariable(p,[r.uuid,"geometry",...c,o]),Wp(u[o])&&(u[o]=1))}}let s={parameters:n,type:n.type};if(n.type==="PathGeometry")s.path=n.path;else if(n.type==="VectorGeometry"){let c=Xe.createFromState(n.shape,n.width,n.height);s.shape=c}else if(n.type==="NonParametricGeometry"){if(n.data.groups&&n.data.groups?.forEach(c=>c.materialIndex=Math.max(c.materialIndex??0,0)),s.geometry=new fb.BufferGeometryLoader().parse(n),s.geometry.groups.length===0){let c=s.geometry;c.addGroup(0,Math.max(c.getIndex()?.count??0,c.getAttribute("position").count),0)}}else if(n.type==="SubdivGeometry"){let c=new Rt(n,e);return c.data=i,c}else{if(n.type==="TextGeometry")return new En(n,t);if(n.type==="InputGeometry")return new En(n,t);if(n.type==="UIGeometry")return Za.create({parameters:{width:n.width,height:n.height,cornerRadius:n.cornerRadius,cornerType:n.cornerType}})}let l;try{l=Uf(s)}catch(c){console.error(c)}if(!l){let c=Xe.createFromState(Ma.defaultData(),100,100);s.shape=c,l=Uf(s)}return l}var hb=require("three"),CI=new hb.Matrix4;function _l(i,t,e,r){let o=i.position.array,n=i.normal.array,a=CI.makeScale(t,e,r).invert().elements,s,l,c;for(var u=0,p=o.length;u<p;u+=3)o[u]*=t,o[u+1]*=e,o[u+2]*=r,s=n[u],l=n[u+1],c=n[u+2],n[u]=a[0]*s+a[4]*l+a[8]*c,n[u+1]=a[1]*s+a[5]*l+a[9]*c,n[u+2]=a[2]*s+a[6]*l+a[10]*c;i.position.needsUpdate=!0,i.normal.needsUpdate=!0}var ed=new lt.Box3,es=new lt.Vector3,Pe;Ju.then(i=>{Pe=i});var mb=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),yb=new Uint32Array([0,1,2,3]),gb=new Uint8Array([4]),Rt=class extends lt.BufferGeometry{constructor(e,r){super();this.data=e;this.flatShading=r;this.subdivPointer=0;this.rebuild(),this.freeSubdivPointer()}mutateDirectlyScaleBaked(e,r){this.freeSubdivPointer();let o=this.data.scaleBaked,n=Ni.div(r,o);if(n.every(l=>l===1))return;this.subdividedGeometry&&_l(this.subdividedGeometry.attributes,...n),this.originalGeometry&&_l(this.originalGeometry.attributes,...n),this.data=e;let a=this.userData.parameters;this.userData.parameters={width:a.width*n[0],height:a.height*n[1],depth:a.depth*n[2]},this.originalGeometry.boundingSphere.center.multiply(es.fromArray(n));let s=es.set(a.width,a.height,a.depth).length();this.originalGeometry.boundingSphere.radius=s/2}ensureSubdivPointer(){return this.subdivPointer===0&&this.rebuild(),this.subdivPointer}rebuild(){let e,r,o;try{({originalGeometry:e,subdividedGeometry:r,subdivPointer:o}=Rt.build(this.data,void 0,!this.flatShading,void 0))}catch{e=new lt.BoxGeometry(100,100,100),o=0}this.subdivPointer=o,this.originalGeometry=e,this.subdividedGeometry=r??void 0;let n=this.subdividedGeometry??this.originalGeometry;Object.assign(this,n),this.calcBoundingBox()}freeSubdivPointer(){this.subdivPointer&&(Rt.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0)}dispose(){super.dispose(),this.freeSubdivPointer()}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new lt.Sphere,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let r=e.attributes.position,o=e.boundingSphere.center;ed.setFromBufferAttribute(r),ed.getCenter(o),e.boundingSphere.radius=o.distanceTo(ed.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),ed.getSize(es);let n={width:es.x,height:es.y,depth:es.z};return this.userData.parameters=n,n}static build(e,r,o,n){let a,s,l,c=e?.phongAngle??35;o===!1&&(c=-1),r&&(Pe.free_bvh(r),Pe.free_subdivision_surface(r));try{a=Rt.allocate(e,n)}catch(u){console.error(u,e),a=Rt.allocate({positionWASM:mb,indexWASM:yb,verticesPerFaceWASM:gb},n)}if(Pe.set_destination_refinement_level(a,0),s=Rt.buildLevel(a,!0,c),e.subdivisions>0)try{Pe.set_destination_refinement_level(a,e.subdivisions),l=Rt.buildLevel(a,!1,c)}catch{try{Pe.set_destination_refinement_level(a,e.subdivisions-1),l=Rt.buildLevel(a,!1,c)}catch{l=null}}else l=null;return{subdivPointer:a,originalGeometry:s,subdividedGeometry:l}}static primitiveToQuads(e,r,o){e.widthSegments>16&&(e.widthSegments=16),e.heightSegments>16&&(e.heightSegments=16),e.depthSegments>16&&(e.depthSegments=16),e.radialSegments>16&&(e.radialSegments=16),e.type==="DodecahedronGeometry"&&(e.detail=0);let n=e.shape!==void 0||e.path!==void 0?r.geometry:Lo(e,o,!1,r),a;e.type==="TorusGeometry"&&e.arc===Math.PI*2?a=n.getClosedTorusIndicesForBooleanOrSubdiv():a=n.getIndex();let s,l,c,u;({positions:s,triIndices:u}=qf(n.getAttribute("position"),a));let p;if(e.type==="CylinderGeometry"&&e.cornerRadius===0&&e.hollow===0&&e.openEnded===!1){let d=e.radialSegments*e.heightSegments*3*2,f=d+e.radialSegments*3;p=[d,f]}return{indices:l,verticesPerFace:c}=$f(s,u,n,p),{positions:s,indices:l,verticesPerFace:c}}static allocate(e,r){let o,n,a,s=[],l=[];e.positionWASM&&e.positionWASM.length>0?(o=e.positionWASM,n=e.indexWASM,a=e.verticesPerFaceWASM):(o=mb,n=yb,a=gb);let c=o.length,u=n.length,p=a.length,d=o.length+s.length+l.length,f=n.length+a.length,h=d*Float32Array.BYTES_PER_ELEMENT+f*Uint32Array.BYTES_PER_ELEMENT,m=d*Float32Array.BYTES_PER_ELEMENT,y=f*Uint32Array.BYTES_PER_ELEMENT,b=Pe._malloc(h),v=new Float32Array(Pe.HEAPF32.buffer,b,d),w=new Uint32Array(Pe.HEAPU32.buffer,b+m,f);v.set(o,0),v.set(s,o.length),v.set(l,o.length+s.length),w.set(n,0),w.set(a,n.length);let O;e?.scaleBaked?.some(T=>T!==1)&&(O=new lt.Matrix4().makeScale(...e.scaleBaked)),r&&(O?O.premultiply(r):O=r);let S=O?Pe.alloc_subdivision_surface2(b,c,b+m,u,b+m+n.length*Uint32Array.BYTES_PER_ELEMENT,p,O.elements):Pe.alloc_subdivision_surface(b,c,b+m,u,b+m+n.length*Uint32Array.BYTES_PER_ELEMENT,p);return Pe._free(b),S}static buildLevel(e,r,o,n,a){let s=a?Pe.get_mesh_data2(e,r?Pe.Level.CONTROL:Pe.Level.REFINED,o,a.elements):Pe.get_mesh_data(e,r?Pe.Level.CONTROL:Pe.Level.REFINED,o),l=8,c=Pe.HEAPU32.subarray(s>>2,(s>>2)+l),u=c.subarray(4,4+4),p=0,d=Pe.HEAPU32[c[p]>>2],f=Pe.HEAPF32.subarray(d>>2,(d>>2)+u[p]);p++;let h=Pe.HEAPU32[c[p]>>2],m=Pe.HEAPF32.subarray(h>>2,(h>>2)+u[p]);p++;let y=Pe.HEAPU32[c[p]>>2],b=Pe.HEAPU32.subarray(y>>2,(y>>2)+u[p]);p++;let v=Pe.HEAPU32[c[p]>>2],w=Pe.HEAPU32.subarray(v>>2,(v>>2)+u[p]);if(p++,n===void 0){let O=new lt.BufferGeometry;if(O.setIndex(new lt.Uint32BufferAttribute(w,1)),O.setAttribute("position",new lt.Float32BufferAttribute(f,3)),O.setAttribute("normal",new lt.Float32BufferAttribute(m,3)),r){O.setAttribute("faceMap",new lt.Uint32BufferAttribute(b,1));let S=new Float32Array(m.length/3*4).fill(0);O.setAttribute("color",new lt.BufferAttribute(S,4))}return Pe.free_mesh_data(s),O.userData.type="SubdivGeometry",O}n.getAttribute("position").copyArray(f),n.getAttribute("normal").copyArray(m),n.attributes.position.needsUpdate=!0,n.attributes.normal.needsUpdate=!0,Pe.free_mesh_data(s)}static freeSubdivPointer(e){Pe.free_bvh(e),Pe.free_subdivision_surface(e)}static buildControlCageWireframe(e,r,o){let n=Pe.get_wireframe_data_for_base_level(e),a=4,s=Pe.HEAPU32.subarray(n>>2,(n>>2)+a),l=s.subarray(2,2+2),c=0,u=Pe.HEAPU32[s[c]>>2],p=Pe.HEAPF32.subarray(u>>2,(u>>2)+l[c]);c++;let d=Pe.HEAPU32[s[c]>>2],f=Pe.HEAPU32.subarray(d>>2,(d>>2)+l[c]);if(r===void 0){let h=new lt.BufferGeometry;h.setAttribute("position",new lt.Float32BufferAttribute(p,3));let m=new Float32Array(p.length);for(let y=0,b=p.length;y<b;)m[y++]=o.r,m[y++]=o.g,m[y++]=o.b;return h.setAttribute("color",new lt.BufferAttribute(m,3)),h.setIndex(new lt.Uint32BufferAttribute(f,1)),Pe.free_wireframe_data_for_base_level(n),h}r.getAttribute("position").copyArray(p),r.attributes.position.needsUpdate=!0,Pe.free_wireframe_data_for_base_level(n)}static updateCollabMesh(e,r,o){let n=r===0;n||Pe.set_destination_refinement_level(e,r);let a=o?Pe.get_topological_data2(e,n?Pe.Level.CONTROL:Pe.Level.REFINED,o.elements):Pe.get_topological_data(e,n?Pe.Level.CONTROL:Pe.Level.REFINED),s=6,l=Pe.HEAPU32.subarray(a>>2,(a>>2)+s),c=l.subarray(3,3+3),u=0,p=Pe.HEAPU32[l[u]>>2],d=new Float32Array(Pe.HEAPF32.subarray(p>>2,(p>>2)+c[u]));u++;let f=Pe.HEAPU32[l[u]>>2],h=new Uint32Array(Pe.HEAPU32.subarray(f>>2,(f>>2)+c[u]));u++;let m=Pe.HEAPU32[l[u]>>2],y=new Uint8Array(Pe.HEAPU32.subarray(m>>2,(m>>2)+c[u]));return Pe.free_topological_data(a),{positions:d,indices:h,verticesPerFace:y}}};var xb=["getX","getY","getZ"];function qf(i,t){let e={},r=t?t.count:i.count,o=0,n=[],a=[],s=1e4;for(let c=0;c<r;c++){let u=t?t.getX(c):c,p="";for(let d=0;d<3;d++)p+=`${~~(i[xb[d]](u)*s)},`;if(p in e)n.push(e[p]);else{for(let d=0;d<3;d++)a.push(i[xb[d]](u));e[p]=o,n.push(o),o++}}let l=[];for(let c=0;c<n.length;c+=3)n[c]===n[c+1]||n[c]===n[c+2]||n[c+1]===n[c+2]||l.push(n[c],n[c+1],n[c+2]);return{positions:a,triIndices:l}}var td=new lt.Vector3,kf=new lt.Vector3,Hf=new lt.Vector3,Wf=new lt.Vector3;function $f(i,t,e,r){let o=[],n=[];if(e.userData.shape!==void 0&&e.userData.parameters.depth===0&&e.userData.shape.shapeHoles.length===0){let l=e.userData.shape.extractShapePointsToFlatArray([]),c=e.userData.parameters.spikes;if(e.userData.type==="EllipseGeometry"&&c<=24&&c%4===0&&e.userData.parameters.angle>=360){let d=l.length/2/c;l=l.filter((f,h)=>Math.floor(h/2)%d===0)}let u=0;for(let d=0;d<l.length;d+=2)u+=(l[d]-l[(d===0?l.length:d)-2])*(l[d+1]+l[(d===0?l.length:d)-1]);i.length=0;let p=0;if(u<0)for(let d=0;d<l.length;d+=2)i.push(l[d],l[d+1],0),o.push(p++);else for(let d=l.length-2;d>=0;d-=2)i.push(l[d],l[d+1],0),o.push(p++);return n.push(p),{indices:o,verticesPerFace:n}}let a=new Float32Array([e.userData.parameters.depth])[0],s=0;for(;s<t.length;){if(e.useNgonForTopBottomFaceDuringBake){let l=0;if((i[t[s]*3+2]===a||i[t[s]*3+2]===0)&&l++,(i[t[s+1]*3+2]===a||i[t[s+1]*3+2]===0)&&l++,(i[t[s+2]*3+2]===a||i[t[s+2]*3+2]===0)&&l++,l===3)break}if(t[s+1]===t[s+3]&&t[s+2]===t[s+5]||t[s+0]===t[s+3]&&t[s+2]===t[s+4]){td.set(i[t[s]*3],i[t[s]*3+1],i[t[s]*3+2]),kf.set(i[t[s+1]*3],i[t[s+1]*3+1],i[t[s+1]*3+2]),Hf.set(i[t[s+4]*3],i[t[s+4]*3+1],i[t[s+4]*3+2]),Wf.set(i[t[s+5]*3],i[t[s+5]*3+1],i[t[s+5]*3+2]),kf.sub(td).normalize(),Hf.sub(td).normalize(),Wf.sub(td).normalize();let l=kf.cross(Hf).dot(Wf);Math.abs(l)>.005||r&&r.some((c,u)=>u%2===1?!1:s>=r[u]&&s<r[u+1])?(o.push(t[s],t[s+1],t[s+2]),n.push(3),s+=3):(o.push(t[s],t[s+1],t[s+4],t[s+5]),n.push(4),s+=6)}else o.push(t[s],t[s+1],t[s+2]),n.push(3),s+=3}if(e.useNgonForTopBottomFaceDuringBake){let l=[],c=[],u=0;for(let p=0,d=0;p<i.length;p+=3,d++)i[p+2]===0&&(l.push(d),u++),i[p+2]===a&&c.push(d);if(e.userData.parameters.extrudeBevelSize===0){let p=c[0];c[0]=c[1],c[1]=p}l.reverse(),o.push(...l,...c),n.push(u,u)}return{indices:o,verticesPerFace:n}}var Wr={};lm(Wr,{calcBoolean:()=>EI,calcBooleanTopological:()=>II,freeMeshSet:()=>RI,getMeshSet:()=>NI,hasOpenEdges:()=>DI,transformMeshSet:()=>_I});var AI,bb=new Promise(i=>{AI=i});var Rl=require("three");var Ue,ts;bb.then(i=>Ue=i);function MI(i,t,e){let r,o;i.userData.parameters.type==="TorusGeometry"&&i.userData.parameters.arc===Math.PI*2?o=i.getClosedTorusIndicesForBooleanOrSubdiv():o=i.getIndex();let{positions:n,triIndices:a}=qf(i.getAttribute("position"),o),s;if(t&&e){let{indices:l,verticesPerFace:c}=$f(n,a,i);s=c.length,r=[];for(let u=0,p=0;u<s;u++){r.push(c[u]);for(let d=0;d<c[u];d++)r.push(l[p++])}}else{let l=a.length;r=Array(l+l/3),s=0;for(let c=0,u=0;u<r.length;)r[u++]=3,s++,r[u++]=a[c++],r[u++]=a[c++],r[u++]=a[c++]}return{positions:n,faceIndices:r,nFaces:s}}function vb(i){let t=i.length,e=t*Uint32Array.BYTES_PER_ELEMENT,r=t*Float32Array.BYTES_PER_ELEMENT,o=Number.isInteger(i[0])?e:r,n=Ue._malloc(o);return(Number.isInteger(i[0])?new Uint32Array(Ue.HEAPU32.buffer,n,t):new Float32Array(Ue.HEAPF32.buffer,n,t)).set(i,0),n}function Sb(i){switch(i){case 0:return Ue.OP.UNION;case 1:return Ue.OP.INTERSECTION;case 2:return Ue.OP.A_MINUS_B;default:throw new Error("Unknown boolean operation "+i)}}function II(i,t){ts===void 0&&(ts=Ue.init_csg());let e=vb(i),r=Ue.csg_calc_topological(ts,e,i.length,Sb(t));Ue._free(e);let o=6,n=Ue.HEAPU32.subarray(r>>2,(r>>2)+o),a=n.subarray(3,3+3),s=0,l=Ue.HEAPU32[n[s]>>2],c=new Float32Array(Ue.HEAPF32.subarray(l>>2,(l>>2)+a[s]));s++;let u=Ue.HEAPU32[n[s]>>2],p=new Uint32Array(Ue.HEAPU32.subarray(u>>2,(u>>2)+a[s]));s++;let d=Ue.HEAPU32[n[s]>>2],f=new Uint8Array(Ue.HEAPU32.subarray(d>>2,(d>>2)+a[s]));return Ue.free_mesh_data(r),{positions:c,indices:p,verticesPerFace:f}}function EI(i,t,e,r){ts===void 0&&(ts=Ue.init_csg());let o=vb(i),n=Ue.csg_calc(ts,o,i.length,r,Sb(t));Ue._free(o);let a=5,s=Ue.HEAPU32.subarray(n>>2,(n>>2)+a),l=s.subarray(2,2+3),c=0,u=Ue.HEAPU32[s[c]>>2],p=Ue.HEAPF32.subarray(u>>2,(u>>2)+l[c]);c++;let d=Ue.HEAPU32[s[c]>>2],f=Ue.HEAPF32.subarray(d>>2,(d>>2)+l[c]);c++;let h=l[c];e.setAttribute("position",new Rl.Float32BufferAttribute(p,3)),e.setAttribute("normal",new Rl.Float32BufferAttribute(f,3));let m=Ue.HEAPF32.subarray((n>>2)+5,(n>>2)+5+6);return e.boundingSphere===null&&(e.boundingSphere=new Rl.Sphere),e.boundingSphere.center.set(m[0],m[1],m[2]),e.boundingSphere.radius=(m[3]**2+m[4]**2+m[5]**2)**.5,e.userData.parameters={width:m[3]*2,height:m[4]*2,depth:m[5]*2},Ue.free_mesh_data(n),h}function NI(i,t,e){if(Ue===void 0)return-1;let r,o,n;if(t&&i.userData.positions!==void 0){let b=i.userData;n=b.verticesPerFace.length,r=b.positions,o=Array(b.verticesPerFace.reduce((v,w)=>v+w,0)+n);for(let v=0,w=0,O=0;v<b.verticesPerFace.length;v++){o[O++]=b.verticesPerFace[v];for(let S=0;S<b.verticesPerFace[v];S++)o[O++]=b.indices[w++]}}else({positions:r,faceIndices:o,nFaces:n}=MI(i,t,e));let a=r.length,s=o.length,l=r.length,c=o.length,u=l*Float32Array.BYTES_PER_ELEMENT+c*Uint32Array.BYTES_PER_ELEMENT,p=l*Float32Array.BYTES_PER_ELEMENT,d=c*Uint32Array.BYTES_PER_ELEMENT,f=Ue._malloc(u),h=new Float32Array(Ue.HEAPF32.buffer,f,l),m=new Uint32Array(Ue.HEAPU32.buffer,f+p,c);h.set(r,0),m.set(o,0);let y=Ue.get_csg_mesh(f,a,f+p,s,n);return Ue._free(f),y}function DI(i){return Ue.has_open_edges(i)}function _I(i,t){Ue.transform_csg_mesh(i,t.elements)}function RI(i){Ue.free_csg_mesh(i)}var LI={ConeGeometry:dx,CubeGeometry:px,CylinderGeometry:ux,DodecahedronGeometry:hx,EllipseGeometry:Ya,HelixGeometry:Gx,IcosahedronGeometry:jx,LatheGeometry:Ux,NonParametricGeometry:qx,PolygonGeometry:Yu,PyramidGeometry:$x,RectangleGeometry:Za,SphereGeometry:Xx,PlaneGeometry:Kx,BackdropGeometry:Qx,StarGeometry:Ku,TextFrameGeometry:Jx,TorusGeometry:eb,TorusKnotGeometry:rb,TriangleGeometry:ob,PathGeometry:sb,VectorGeometry:wr},Uf=i=>LI[i.type].create(i);function rs(i){return i!==null&&"booleanOp"in i}var os=class extends ja(rd.Mesh){constructor(){super(...arguments);this.booleanMeshSetAddress=-1;this.booleanWasTransformed=!1;this.booleanMatrixInvOld=new rd.Matrix4}updateVisible(e){super.updateVisible(e),this.visible=!rs(this.parent)&&this.visible,rs(this.parent)&&this.parent.invalidateDownstreamBooleanData()}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(Wr.freeMeshSet(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}invalidateDownstreamBooleanData(e=!1){return e?this.booleanWasTransformed=!0:this.freeBooleanPointer(),rs(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let e of this.children)e instanceof os&&(e.freeBooleanPointer(),rs(e)&&e.invalidateUpstreamBooleanData())}updateTransformState(e,r){let o=super.updateTransformState(e,r);return o&&rs(this.parent)&&this.invalidateDownstreamBooleanData(!0),o}onVariableUpdate(e=!1){super.onVariableUpdate(e),rs(this.parent)&&this.invalidateDownstreamBooleanData(!0)}};var od=new is.Box3;function Ll(i,t=0,e=i.count,r,o){let n=1/0,a=1/0,s=1/0,l=-1/0,c=-1/0,u=-1/0;for(let p=t;p<e;p++){let d=i.getX(p),f=i.getY(p),h=i.getZ(p);d<n&&(n=d),f<a&&(a=f),h<s&&(s=h),d>l&&(l=d),f>c&&(c=f),h>u&&(u=h)}od.min.set(n,a,s),od.max.set(l,c,u),od.getCenter(r),od.getSize(o).multiplyScalar(.5)}var BI=new is.BufferGeometry,VI=new is.MeshBasicMaterial,Wt=class extends os{constructor(t,e){super(BI,VI),this.super_Entity(t,e)}updateState(t,e){this.updateState_Entity(t,e)}updateEntityBoxSize(t,e){let r=this.geometry.getAttribute("position");r!==void 0?Ll(r,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:r.count,t,e):super.updateEntityBoxSize(t,e)}};var mi=require("three");var Br=require("three");var kb=require("three");var di=class{constructor(t){this.hashProperties=void 0;this.isNode=!0;this.shortcuts={};if(di.uuidContext===null)throw new Error("plz startContext");di.uuidContext===di.globalContext?this.uuid="_gid"+di.uuidContext.nodeContextUuid++:this.uuid="_uid"+di.uuidContext.nodeContextUuid++,this.type=t,this.name=""}static startContext(t){this.uuidContext===null||this.uuidContext===di.globalContext?this.uuidContext=t:console.error("Can't start context twice")}static endContext(t){this.uuidContext!==t&&console.error("Can't end context twice"),this.uuidContext=null}analyze(t,e){e=e??{},t.analyzing=!0,this.build(t.addFlow(e.slot,e.cache,e.context),"v4"),t.clearVertexNodeCode(),t.clearFragmentNodeCode(),t.removeFlow(),t.analyzing=!1}analyzeAndFlow(t,e,r){return r=r??{},this.analyze(t,r),this.flow(t,e,r)}flow(t,e,r){r=r??{},t.addFlow(r.slot,r.cache,r.context);let o={result:this.build(t,e),code:t.clearNodeCode(),extra:t.context.extra};return t.removeFlow(),o}build(t,e,r){e=e??this.getType(t,e);let o=t.getNodeData(r??this);return t.analyzing&&this.appendDepsNode(t,o,e),t.nodes.indexOf(this)===-1&&t.nodes.push(this),this.updateFrame!==void 0&&t.updaters.indexOf(this)===-1&&t.updaters.push(this),this.generate(t,e,r)}updateFrame(t){}generateReadonly(t,e,r,o,n,a){return""}generate(t,e,r,o,n){return""}parse(t,e,r,o){}appendDepsNode(t,e,r){e.deps=(e.deps||0)+1;let o=t.getTypeLength(r);(o>(e.outputMax||0)||this.getType(t,r))&&(e.outputMax=o,e.output=r)}setName(t){this.name=t}getName(){return this.name}getType(t,e){return e==="sampler2D"||e==="samplerCube"?e:this.type}},ot=di;ot.globalContext={nodeContextUuid:0},ot.uuidContext=di.globalContext;var mo=require("three");var Bl=class{constructor(t){t=t??{},this.name=t.name,this.type=t.type,this.node=t.node,this.size=t.size,this.needsUpdate=t.needsUpdate}get value(){return this.node.value}set value(t){this.node.value=t}};var Xf=class{constructor(){this.nodes={};this.keywords={}}add(t){this.nodes[t.name]=t}addKeyword(t,e,r){r=r!==void 0?r:!0,this.keywords[t]={callback:e,cache:r}}remove(t){delete this.nodes[t.name]}removeKeyword(t){delete this.keywords[t]}get(t){return this.nodes[t]}getKeyword(t,e){return this.keywords[t].callback(e)}getKeywordData(t){return this.keywords[t]}contains(t){return this.nodes[t]!==void 0}containsKeyword(t){return this.keywords[t]!==void 0}},qt=new Xf;var Yf=require("three");var wb=require("three"),be=class extends ot{constructor(e,r){super(e);this.scope="";r=r??{},this.shared=r.shared!==void 0?r.shared:!0,this.unique=r.unique!==void 0?r.unique:!1}build(e,r,o,n){if(r=r??this.getType(e),this.getShared(e,r)){let a=this.getUnique(e,r);a&&this.uuid===void 0&&(this.uuid=wb.MathUtils.generateUUID()),o=e.getUUID(o??this.getUUID(),!a);let s=e.getNodeData(o),l=s.output||this.getType(e);if(e.analyzing)return(s.deps||0)>0||this.getLabel()?(this.appendDepsNode(e,s,r),this.generate(e,r,o)):super.build(e,r,o);if(a)return s.name=s.name||super.build(e,r,o),s.name;if(!this.getLabel()&&(!this.getShared(e,l)||e.context.ignoreCache||s.deps===1))return super.build(e,r,o);o=this.getUUID(!1);let c=this.getTemp(e,o);if(c)return e.format(c,l,r);{c=super.generate(e,r,o,s.output,n);let u=this.generate(e,l,o);return e.addNodeCode(c+" = "+u+";"),e.format(c,l,r)}}return super.build(e,r,o)}getShared(e,r){return r!=="sampler2D"&&r!=="samplerCube"&&this.shared}getUnique(e,r){return this.unique}setLabel(e){return this.label=e,this}getLabel(){return this.label}getUUID(e){let r=this.uuid;return typeof this.scope=="string"&&(r=this.scope+"-"+r),r}getTemp(e,r){r=r||this.uuid;let o=e.getVars()[r];return o?o.name:void 0}generate(e,r,o,n,a){return this.getShared(e,r)||console.error("TempNode is not shared"),o=o??this.uuid,e.getTempVar(o,n??this.getType(e),a,this.getLabel()).name}};var it=class extends be{constructor(e,r){r=r??{},r.shared=r.shared!==void 0?r.shared:!1;super(e,r);this.readonly=!1}setReadonly(e){return this.readonly=e,this.hashProperties=this.readonly?["value"]:void 0,this}getReadonly(){return this.readonly}generate(e,r,o,n,a,s){o=e.getUUID(o??this.getUUID()),n=n??this.getType(e);let l=e.getNodeData(o);return this.getReadonly()&&this.generateReadonly!==void 0?this.generateReadonly(e,r,o,n,a,s):e.isShader("vertex")?(l.vertex||(l.vertex=e.createVertexUniform(n,this,a,s,this.getLabel())),e.format(l.vertex.name,n,r)):(l.fragment||(l.fragment=e.createFragmentUniform(n,this,a,s,this.getLabel())),e.format(l.fragment.name,n,r))}};var wt=class extends it{constructor(e=0,r){super("v2");this.nodeType="Vector2";this.value=e instanceof Yf.Vector2?e:new Yf.Vector2(e,r)}get x(){return this.value.x}set x(e){this.value.x=e}get y(){return this.value.y}set y(e){this.value.y=e}generateReadonly(e,r,o,n,a,s){return e.format("vec2("+this.value.x+", "+this.value.y+")",n,r)}};var Kf=require("three");var or=class extends it{constructor(e=0,r,o){super("v3");this.nodeType="Vector3";this.value=e instanceof Kf.Vector3?e:new Kf.Vector3(e,r,o)}get x(){return this.value.x}set x(e){this.value.x=e}get y(){return this.value.y}set y(e){this.value.y=e}get z(){return this.value.z}set z(e){this.value.z=e}generateReadonly(e,r,o,n,a,s){return e.format("vec3("+this.value.x+", "+this.value.y+", "+this.value.z+")",n,r)}};var Pr=class extends it{constructor(e){super("v4");this.nodeType="Vector4";this.value=e instanceof kt?e:new kt(e.r,e.g,e.b,e.a)}generateReadonly(e,r,o,n,a,s){return e.format("vec4("+this.value.r+", "+this.value.g+", "+this.value.b+", "+this.value.a+")",n,r)}};var zI=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,Pb=/[a-z_0-9]+/gi,J=class extends be{constructor(e,r,o,n,a){super(a);this.src="";this.nodeType="Function";this.useKeywords=!0;this.includes=[];this.extensions={};this.keywords={};this.isMethod=a===void 0,this.isInterface=!1,this.parse(e,r,o,n)}getShared(e,r){return!this.isMethod}getType(e){return e.getTypeByFormat(this.type)}getInputByName(e){if(this.inputs){let r=this.inputs.length;for(;r--;)if(this.inputs[r].name===e)return this.inputs[r]}}getIncludeByName(e){if(this.includes){let r=this.includes.length;for(;r--;)if(this.includes[r].name===e)return this.includes[r]}}generate(e,r,o,n,a){let s,l=0,c=this.src;if(this.includes)for(let p=0;p<this.includes.length;p++)e.include(this.includes[p],this);for(let p in this.extensions)e.extensions[p]=!0;let u=[];for(;s=Pb.exec(this.src);)u.push(s);for(let p=0;p<u.length;p++){let d=u[p],f=d[0],h=this.isMethod?!this.getInputByName(f):!0,m=f;if(this.keywords[f]||this.useKeywords&&h&&qt.containsKeyword(f)){let y=this.keywords[f];if(!y){let b=qt.getKeywordData(f);b.cache&&(y=e.keywords[f]),y=y||qt.getKeyword(f,e),b.cache&&(e.keywords[f]=y)}m=y.build(e)}f!==m&&c[d.index+l-1]!=="."&&(c=c.substring(0,d.index+l)+m+c.substring(d.index+f.length+l),l+=m.length-f.length),this.getIncludeByName(m)===void 0&&qt.contains(m)&&e.include(qt.get(m))}return r==="source"?c:this.isMethod?(this.isInterface||e.include(this,void 0,c),this.name):e.format("( "+c+" )",this.getType(e),r)}parse(e,r,o,n){if(this.src=e||"",this.includes=r??[],this.extensions=o??{},this.keywords=n??{},this.isMethod){let a=zI.exec(this.src);if(this.inputs=[],a&&a.length==4){this.type=a[1],this.name=a[2];let s=a[3].match(Pb);if(s){let l=0;for(;l<s.length;){let c=s[l++],u;c==="in"||c==="out"||c==="inout"?u=s[l++]:(u=c,c="");let p=s[l++];this.inputs.push({name:p,type:u,qualifier:c})}}this.isInterface=this.src.indexOf("{")===-1}else this.type="",this.name=""}}};var GI=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=?\s?(.*?)(\;|$)/i,Qf=class extends be{constructor(e="",r){super();this.src="";this.useDefine=!1;this.nodeType="Const";this.parse(e||Qf.PI,void 0,void 0,void 0,r)}getType(e){return e.getTypeByFormat(this.type)}parse(e,r,o,n,a){this.src=e||"";let s,l,c="",u=GI.exec(e);this.useDefine=a??this.src.charAt(0)==="#",u&&u.length>1?(l=u[1],s=u[2],c=u[3]):(s=this.src,l="f"),this.name=s,this.type=l,this.value=c}build(e,r){if(r==="source"){if(this.value)return this.useDefine?"#define "+this.name+" "+this.value:"const "+this.type+" "+this.name+" = "+this.value+";";if(this.useDefine)return this.src}return e.include(this),e.format(this.name,this.getType(e),r)}generate(e,r,o,n,a){return e.format(this.name,this.getType(e),r)}},qe=Qf;qe.PI="PI",qe.PI2="PI2",qe.RECIPROCAL_PI="RECIPROCAL_PI",qe.RECIPROCAL_PI2="RECIPROCAL_PI2",qe.LOG2="LOG2",qe.EPSILON="EPSILON";var FI=new RegExp(`^structs*([a-z_0-9]+)s*{s*((.|
19
19
  )*?)}`,"gim"),jI=new RegExp("s*(w*?)s*(w*?)(=|;)","gim"),ns=class extends be{constructor(e=""){super();this.inputs=[];this.src="";this.nodeType="Struct";this.parse(e)}getType(e){return e.getTypeByFormat(this.name)}getInputByName(e){let r=this.inputs.length;for(;r--;)if(this.inputs[r].name===e)return this.inputs[r]}generate(e,r,o,n,a){return r==="source"?this.src+";":e.format("( "+this.src+" )",this.getType(e),r)}parse(e=""){this.src=e,this.inputs=[];let r=FI.exec(e);if(r){let o=r[2],n;for(;n=jI.exec(o);)this.inputs.push({type:n[1],name:n[2]});this.name=r[1]}else this.name="";this.type=this.name}};var as=class extends be{constructor(e){super("v2",{shared:!1});this.nodeType="UV";this.index=e??0}generate(e,r){e.requires.uv[this.index]=!0;let o=this.index>0?this.index+1:"",n=e.isShader("vertex")?"uv"+o:"vUv"+o;return e.format(n,this.getType(e),r)}};qt.addKeyword("uv",function(){return new as});qt.addKeyword("uv2",function(){return new as(1)});var id=require("three");var Nn=class extends be{constructor(e,r){super("v4");this.nodeType="ColorSpace";this.input=e,this.method=r??Nn.LINEAR_TO_LINEAR,this.hashProperties=["method"]}static getEncodingComponents(e){switch(e){case id.LinearEncoding:return["Linear"];case id.sRGBEncoding:return["sRGB"];default:return[]}}generate(e,r){let o=this.input.build(e,"v4"),n=this.getType(e),a=Nn.Nodes[this.method],s=e.include(a);if(s===Nn.LINEAR_TO_LINEAR)return e.format(o,n,r);if(a.inputs?.length===2){let l=this.factor.build(e,"f");return e.format(s+"( "+o+", "+l+" )",n,r)}else return e.format(s+"( "+o+" )",n,r)}fromEncoding(e){let r=Nn.getEncodingComponents(e);this.method="LinearTo"+r[0],this.factor=r[1]}fromDecoding(e){let r=Nn.getEncodingComponents(e);this.method=r[0]+"ToLinear",this.factor=r[1]}},hr=Nn;hr.Nodes={LinearToLinear:new J(["vec4 LinearToLinear( in vec4 value ) {"," return value;","}"].join(`
20
20
  `)),sRGBToLinear:new J(["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(`
21
21
  `)),LinearTosRGB:new J(["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(`
@@ -258,7 +258,7 @@ layout(location = 1) out vec4 gVelocity;
258
258
  `}addVaryCode(t){this.addVertexParsCode(t),this.addFragmentParsCode(t)}isCache(t){return this.caches.indexOf(t)!==-1}isSlot(t){return this.slots.indexOf(t)!==-1}define(t,e){this.defines[t]=e===void 0?1:e}require(t){this.requires[t]=!0}isDefined(t){return this.defines[t]!==void 0}getVar(t,e,r,o="varying",n="V",a=""){let s=this.getVars(o),l=s[t];if(!l){let c=s.length;l={name:r||"node"+n+c+(a?"_"+a:""),type:e},s.push(l),s[t]=l}return l}getTempVar(t,e,r,o){return this.getVar(t,e,r,this.shader,"T",o)}getAttribute(t,e){if(!this.attributes[t]){let r=this.getVar(t,e);this.addVertexParsCode("attribute "+e+" "+t+";"),this.addVertexFinalCode(r.name+" = "+t+";"),this.attributes[t]={varying:r,name:t,type:e}}return this.attributes[t]}getCode(t){return[this.prefixCode,this.parsCode[t],this.getVarListCode(this.getVars("varying"),"varying"),this.getVarListCode(this.inputs.uniforms[t],"uniform"),this.getVarListCode(this.inputs.arrayUniforms[t],"uniform"),this.getIncludesCode("consts",t),this.getIncludesCode("structs",t),this.getIncludesCode("functions",t),"void main() {",this.getVarListCode(this.getVars(t)),this.code[t],this.resultCode[t],this.finalCode[t],"}"].join(`
259
259
  `)}getVarListCode(t,e){e=e??"";let r="";for(let o=0,n=t.length;o<n;++o){let a=t[o],s=a.type,l=a.name,c=a.size,u=this.getFormatByType(s);if(u===void 0)throw new Error("Node pars "+u+" not found.");u.includes("[]")?r+=e+" "+u.substring(0,u.length-2)+" "+l+`[${c}];
260
260
  `:r+=e+" "+u+" "+l+`;
261
- `}return r}getVars(t){return this.inputs.vars[t??this.shader]}getNodeData(t){let e=t instanceof ot?t.uuid:t;return this.nodeData[e]=this.nodeData[e]||{}}createUniform(t,e,r,o,n,a){if(e.includes("[]")){let s=this.inputs.arrayUniforms,l=s.list.length,c=new Bl({type:e,size:r.size,name:o||"nodeUA"+l+(a?"_"+a:""),node:r,needsUpdate:n});return s.list.push(c),s[t].push(c),s[t][c.name]=c,this.uniforms[c.name]=c,c}else{let s=this.inputs.uniforms,l=s.list.length,c=new Bl({type:e,name:o||"nodeU"+l+(a?"_"+a:""),node:r,needsUpdate:n});return s.list.push(c),s[t].push(c),s[t][c.name]=c,this.uniforms[c.name]=c,c}}createVertexUniform(t,e,r,o,n){return this.createUniform("vertex",t,e,r,o,n)}createFragmentUniform(t,e,r,o,n){return this.createUniform("fragment",t,e,r,o,n)}include(t,e,r){let o;if(t=typeof t=="string"?qt.get(t):t,this.context.include===!1)return t.name;t instanceof J?o=this.includes.functions:t instanceof qe?o=this.includes.consts:t instanceof ns&&(o=this.includes.structs);let n=o[this.shader]=o[this.shader]||[];if(t){let a=n[t.name];if(a||(a=n[t.name]={node:t,deps:[]},n.push(a),a.src=t.build(this,"source")),t instanceof J&&e&&n[e.name]&&n[e.name].deps.indexOf(t)===-1&&(n[e.name].deps.push(t),t.includes?.length)){let s=0;do this.include(t.includes[s++],e);while(s<t.includes.length)}return r&&(a.src=r),t.name}else throw new Error("Include not found.")}colorToVectorProperties(t){return t.replace("r","x").replace("g","y").replace("b","z").replace("a","w")}colorToVector(t){return t.replace(/c/g,"v3")}getIncludes(t,e){return this.includes[t][e||this.shader]}getConstructorFromLength(t){return UI[t-1]}isTypeMatrix(t){return/^m/.test(t)}getTypeLength(t){return t==="f"?1:parseInt(this.colorToVector(t).substr(1))}getTypeFromLength(t){return t===1?"f":"v"+t}findNode(...t){for(let e=0;e<arguments.length;e++){let r=t[e];if(r?.isNode)return r}}resolve(...t){for(let e=0;e<arguments.length;e++){let r=t[e];if(r!==void 0){if(r.isNode)return r;if(r.isTexture)switch(r.mapping){case mo.CubeReflectionMapping:case mo.CubeRefractionMapping:return new ad(r);case mo.CubeUVReflectionMapping:return new nd(new mr(r));default:return new mr(r)}else{if(r.isVector2)return new wt(r);if(r.isVector3)return new or(r);if(r.isVector4)return new Pr(r)}}}}format(t,e,r){switch(this.colorToVector(r+" <- "+e)){case"f <- v2":return t+".x";case"f <- v3":return t+".x";case"f <- v4":return t+".x";case"f <- i":case"f <- b":return"float( "+t+" )";case"v2 <- f":return"vec2( "+t+" )";case"v2 <- v3":return t+".xy";case"v2 <- v4":return t+".xy";case"v2 <- i":case"v2 <- b":return"vec2( float( "+t+" ) )";case"v3 <- f":return"vec3( "+t+" )";case"v3 <- v2":return"vec3( "+t+", 0.0 )";case"v3 <- v4":return t+".xyz";case"v3 <- i":case"v3 <- b":return"vec2( float( "+t+" ) )";case"v4 <- f":return"vec4( "+t+" )";case"v4 <- v2":return"vec4( "+t+", 0.0, 1.0 )";case"v4 <- v3":return"vec4( "+t+", 1.0 )";case"v4 <- i":case"v4 <- b":return"vec4( float( "+t+" ) )";case"i <- f":case"i <- b":return"int( "+t+" )";case"i <- v2":return"int( "+t+".x )";case"i <- v3":return"int( "+t+".x )";case"i <- v4":return"int( "+t+".x )";case"b <- f":return"( "+t+" != 0.0 )";case"b <- v2":return"( "+t+" != vec2( 0.0 ) )";case"b <- v3":return"( "+t+" != vec3( 0.0 ) )";case"b <- v4":return"( "+t+" != vec4( 0.0 ) )";case"b <- i":return"( "+t+" != 0 )"}return t}getTypeByFormat(t){return kI[t]||t}getFormatByType(t){return HI[t]||t}getUUID(t,e){return e=e!==void 0?e:!0,e&&this.cache&&(t=this.cache+"-"+t),t}getElementByIndex(t){return Db[t]}getIndexByElement(t){return Db.indexOf(t)}isShader(t){return this.shader===t}setShader(t){return this.shader=t,this}mergeDefines(t){for(let e in t)this.defines[e]=t[e];return this.defines}mergeUniform(t){for(let e in t)this.uniforms[e]=t[e];return this.uniforms}getTextureEncodingFromMap(t){let e;return t?t.isTexture&&(e=t.encoding):e=mo.LinearEncoding,e===mo.LinearEncoding&&this.context.gamma&&(e=mo.sRGBEncoding),e}};var Ze=require("three");var et=class extends it{constructor(e=0,r,o,n){super("c");this.nodeType="Color";this.value=e instanceof kt?e:new kt(e||0,r,o,n)}setRGBA(e){this.value.setRGBA(e.r,e.g,e.b,e.a)}generate(e,r,o,n,a,s){o=e.getUUID(o??this.getUUID()),n=n??this.getType(e);let l=e.getNodeData(o),c=this.getReadonly()&&this.generateReadonly!==void 0;if(this.alpha){let u=this.alpha.build(e,"f");e.addFragmentNodeCode(`accumAlpha += ( 1.0 - accumAlpha ) * ${u};`)}return c?this.generateReadonly(e,r,o,n,a,s):e.isShader("vertex")?(l.vertex||(l.vertex=e.createVertexUniform(n,this,a,s,this.getLabel())),e.format(l.vertex.name,n,r)):(l.fragment||(l.fragment=e.createFragmentUniform(n,this,a,s,this.getLabel())),e.format(l.fragment.name,n,r))}generateReadonly(e,r,o,n,a,s){return e.format("vec3("+this.value.r+", "+this.value.g+", "+this.value.b+")",n,r)}};var Fe=class extends it{constructor(e){super("i");this.nodeType="Int";this.value=Math.floor(e??0)}generateReadonly(e,r,o,n,a,s){return e.format(this.value.toString(),n,r)}};var cd=require("three");var Et=class extends it{constructor(e){super("b");this.nodeType="Bool";this.value=e??!1}generateReadonly(e,r,o,n){return e.format(this.value?"true":"false",n,r)}};var yo=class extends it{constructor(e=1,r){super("f[]");this.nodeType="FloatArray";this.size=e,this.value=Array.isArray(r)?r:typeof r=="number"?new Array(e).fill(r):new Array(e).fill(0)}};var _b=require("three");var Wi=class extends it{};var sd=class extends Wi{constructor(e){super("v3");this.image=e;this._value=new _b.Vector3}get value(){return this._value.x=this.image.isVideo?this.image.img.videoWidth??0:this.image.img.width,this._value.y=this.image.isVideo?this.image.img.videoHeight??0:this.image.img.height,this._value}};var _n=class extends Wi{constructor(e,r,o=1008,n=1006){super("t");this.image=e;this.wrap=r;this.minFilter=o;this.magFilter=n}get value(){return this.image.getTexture(this.wrap,this.minFilter,this.magFilter)}};var Rb=require("three");var us=class extends it{constructor(e){super("m3");this.nodeType="Matrix3";this.value=e??new Rb.Matrix3}generateReadonly(e,r,o,n,a,s){return e.format("mat3("+this.value.elements.join(", ")+")",n,r)}get elements(){return this.value.elements}set elements(e){this.value.fromArray(e)}};var Lb=require("three");var ir=class extends it{constructor(e){super("m4");this.nodeType="Matrix4";this.value=e??new Lb.Matrix4}generateReadonly(e,r,o,n,a,s){return e.format("mat4("+this.value.elements.join(", ")+")",n,r)}get elements(){return this.value.elements}set elements(e){this.value.fromArray(e)}};var zl=require("three");function Bb(i,t,e,r=0){i.setUvTransform(e[0],e[1],t[0],t[1],0,0,0).premultiply(new zl.Matrix3().makeRotation(r*zl.MathUtils.DEG2RAD))}var ld=class extends us{constructor(e,r,o=0){super(new zl.Matrix3);this.repeat=e;this.offset=r;this.rotation=o;Bb(this.value,e,r,o)}updateMatrix(){Bb(this.value,this.repeat,this.offset,this.rotation)}};var Jf=require("three");var go=class extends it{constructor(e=1,r){super("v4[]");this.nodeType="Vector4Array";this.size=e,this.value=Array.isArray(r)?r:r instanceof Jf.Vector4?new Array(e).fill(r):new Array(e).fill(new Jf.Vector4(0))}};var ds=class extends be{constructor(e,r,o,n){super("v3");this.nodeType="Blend";this.a=e,this.b=r,this.alpha=o,this.mode=n}generate(e,r){if(e.isShader("fragment")){let o=[];return o.push(this.a.build(e,"c")),o.push(this.b.build(e,"c")),o.push(this.alpha.build(e,"f")),o.push(this.mode.build(e,"i")),e.format("spe_blend("+o.join(",")+")",this.getType(e),r)}else return console.warn("BlendNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),r)}};var eh=class extends be{constructor(e,r){super("v3");this.nodeType="CustomColor";this.color=e,this.alpha=r,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,r){if(e.isShader("fragment")){let o=e.include(eh.Nodes.customColor);e.addFragmentVariable(this.calpha,"float");let n=[];return n.push(this.color.build(e,"v3")),n.push(this.mask?`luminance(${this.mask.build(e,"v3")})`:"1.0"),n.push(this.alpha.build(e,"f")),n.push(this.calpha),e.format(o+"("+n.join(",")+")",this.getType(e),r)}else return console.warn("CustomColorNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),r)}},Rn=eh;Rn.Nodes=function(){return{customColor:new J(`vec3 customColor(vec3 color, float mask, float alpha, out float calpha) {
261
+ `}return r}getVars(t){return this.inputs.vars[t??this.shader]}getNodeData(t){let e=t instanceof ot?t.uuid:t;return this.nodeData[e]=this.nodeData[e]||{}}createUniform(t,e,r,o,n,a){if(e.includes("[]")){let s=this.inputs.arrayUniforms,l=s.list.length,c=new Bl({type:e,size:r.size,name:o||"nodeUA"+l+(a?"_"+a:""),node:r,needsUpdate:n});return s.list.push(c),s[t].push(c),s[t][c.name]=c,this.uniforms[c.name]=c,c}else{let s=this.inputs.uniforms,l=s.list.length,c=new Bl({type:e,name:o||"nodeU"+l+(a?"_"+a:""),node:r,needsUpdate:n});return s.list.push(c),s[t].push(c),s[t][c.name]=c,this.uniforms[c.name]=c,c}}createVertexUniform(t,e,r,o,n){return this.createUniform("vertex",t,e,r,o,n)}createFragmentUniform(t,e,r,o,n){return this.createUniform("fragment",t,e,r,o,n)}include(t,e,r){let o;if(t=typeof t=="string"?qt.get(t):t,this.context.include===!1)return t.name;t instanceof J?o=this.includes.functions:t instanceof qe?o=this.includes.consts:t instanceof ns&&(o=this.includes.structs);let n=o[this.shader]=o[this.shader]||[];if(t){let a=n[t.name];if(a||(a=n[t.name]={node:t,deps:[]},n.push(a),a.src=t.build(this,"source")),t instanceof J&&e&&n[e.name]&&n[e.name].deps.indexOf(t)===-1&&(n[e.name].deps.push(t),t.includes?.length)){let s=0;do this.include(t.includes[s++],e);while(s<t.includes.length)}return r&&(a.src=r),t.name}else throw new Error("Include not found.")}colorToVectorProperties(t){return t.replace("r","x").replace("g","y").replace("b","z").replace("a","w")}colorToVector(t){return t.replace(/c/g,"v3")}getIncludes(t,e){return this.includes[t][e||this.shader]}getConstructorFromLength(t){return UI[t-1]}isTypeMatrix(t){return/^m/.test(t)}getTypeLength(t){return t==="f"?1:parseInt(this.colorToVector(t).substr(1))}getTypeFromLength(t){return t===1?"f":"v"+t}findNode(...t){for(let e=0;e<arguments.length;e++){let r=t[e];if(r?.isNode)return r}}resolve(...t){for(let e=0;e<arguments.length;e++){let r=t[e];if(r!==void 0){if(r.isNode)return r;if(r.isTexture)switch(r.mapping){case mo.CubeReflectionMapping:case mo.CubeRefractionMapping:return new ad(r);case mo.CubeUVReflectionMapping:return new nd(new mr(r));default:return new mr(r)}else{if(r.isVector2)return new wt(r);if(r.isVector3)return new or(r);if(r.isVector4)return new Pr(r)}}}}format(t,e,r){switch(this.colorToVector(r+" <- "+e)){case"f <- v2":return t+".x";case"f <- v3":return t+".x";case"f <- v4":return t+".x";case"f <- i":case"f <- b":return"float( "+t+" )";case"v2 <- f":return"vec2( "+t+" )";case"v2 <- v3":return t+".xy";case"v2 <- v4":return t+".xy";case"v2 <- i":case"v2 <- b":return"vec2( float( "+t+" ) )";case"v3 <- f":return"vec3( "+t+" )";case"v3 <- v2":return"vec3( "+t+", 0.0 )";case"v3 <- v4":return t+".xyz";case"v3 <- i":case"v3 <- b":return"vec2( float( "+t+" ) )";case"v4 <- f":return"vec4( "+t+" )";case"v4 <- v2":return"vec4( "+t+", 0.0, 1.0 )";case"v4 <- v3":return"vec4( "+t+", 1.0 )";case"v4 <- i":case"v4 <- b":return"vec4( float( "+t+" ) )";case"i <- f":case"i <- b":return"int( "+t+" )";case"i <- v2":return"int( "+t+".x )";case"i <- v3":return"int( "+t+".x )";case"i <- v4":return"int( "+t+".x )";case"b <- f":return"( "+t+" != 0.0 )";case"b <- v2":return"( "+t+" != vec2( 0.0 ) )";case"b <- v3":return"( "+t+" != vec3( 0.0 ) )";case"b <- v4":return"( "+t+" != vec4( 0.0 ) )";case"b <- i":return"( "+t+" != 0 )"}return t}getTypeByFormat(t){return kI[t]||t}getFormatByType(t){return HI[t]||t}getUUID(t,e){return e=e!==void 0?e:!0,e&&this.cache&&(t=this.cache+"-"+t),t}getElementByIndex(t){return Db[t]}getIndexByElement(t){return Db.indexOf(t)}isShader(t){return this.shader===t}setShader(t){return this.shader=t,this}mergeDefines(t){for(let e in t)this.defines[e]=t[e];return this.defines}mergeUniform(t){for(let e in t)this.uniforms[e]=t[e];return this.uniforms}getTextureEncodingFromMap(t){let e;return t?t.isTexture&&(e=t.encoding):e=mo.LinearEncoding,e===mo.LinearEncoding&&this.context.gamma&&(e=mo.sRGBEncoding),e}};var Ze=require("three");var et=class extends it{constructor(e=0,r,o,n){super("c");this.nodeType="Color";this.value=e instanceof kt?e:new kt(e||0,r,o,n)}setRGBA(e){this.value.setRGBA(e.r,e.g,e.b,e.a)}generate(e,r,o,n,a,s){o=e.getUUID(o??this.getUUID()),n=n??this.getType(e);let l=e.getNodeData(o),c=this.getReadonly()&&this.generateReadonly!==void 0;if(this.alpha){let u=this.alpha.build(e,"f");e.addFragmentNodeCode(`accumAlpha += ( 1.0 - accumAlpha ) * ${u};`)}return c?this.generateReadonly(e,r,o,n,a,s):e.isShader("vertex")?(l.vertex||(l.vertex=e.createVertexUniform(n,this,a,s,this.getLabel())),e.format(l.vertex.name,n,r)):(l.fragment||(l.fragment=e.createFragmentUniform(n,this,a,s,this.getLabel())),e.format(l.fragment.name,n,r))}generateReadonly(e,r,o,n,a,s){return e.format("vec3("+this.value.r+", "+this.value.g+", "+this.value.b+")",n,r)}};var Fe=class extends it{constructor(e){super("i");this.nodeType="Int";this.value=Math.floor(e??0)}generateReadonly(e,r,o,n,a,s){return e.format(this.value.toString(),n,r)}};var cd=require("three");var Pt=class extends it{constructor(e){super("b");this.nodeType="Bool";this.value=e??!1}generateReadonly(e,r,o,n){return e.format(this.value?"true":"false",n,r)}};var yo=class extends it{constructor(e=1,r){super("f[]");this.nodeType="FloatArray";this.size=e,this.value=Array.isArray(r)?r:typeof r=="number"?new Array(e).fill(r):new Array(e).fill(0)}};var _b=require("three");var Wi=class extends it{};var sd=class extends Wi{constructor(e){super("v3");this.image=e;this._value=new _b.Vector3}get value(){return this._value.x=this.image.isVideo?this.image.img.videoWidth??0:this.image.img.width,this._value.y=this.image.isVideo?this.image.img.videoHeight??0:this.image.img.height,this._value}};var _n=class extends Wi{constructor(e,r,o=1008,n=1006){super("t");this.image=e;this.wrap=r;this.minFilter=o;this.magFilter=n}get value(){return this.image.getTexture(this.wrap,this.minFilter,this.magFilter)}};var Rb=require("three");var us=class extends it{constructor(e){super("m3");this.nodeType="Matrix3";this.value=e??new Rb.Matrix3}generateReadonly(e,r,o,n,a,s){return e.format("mat3("+this.value.elements.join(", ")+")",n,r)}get elements(){return this.value.elements}set elements(e){this.value.fromArray(e)}};var Lb=require("three");var ir=class extends it{constructor(e){super("m4");this.nodeType="Matrix4";this.value=e??new Lb.Matrix4}generateReadonly(e,r,o,n,a,s){return e.format("mat4("+this.value.elements.join(", ")+")",n,r)}get elements(){return this.value.elements}set elements(e){this.value.fromArray(e)}};var zl=require("three");function Bb(i,t,e,r=0){i.setUvTransform(e[0],e[1],t[0],t[1],0,0,0).premultiply(new zl.Matrix3().makeRotation(r*zl.MathUtils.DEG2RAD))}var ld=class extends us{constructor(e,r,o=0){super(new zl.Matrix3);this.repeat=e;this.offset=r;this.rotation=o;Bb(this.value,e,r,o)}updateMatrix(){Bb(this.value,this.repeat,this.offset,this.rotation)}};var Jf=require("three");var go=class extends it{constructor(e=1,r){super("v4[]");this.nodeType="Vector4Array";this.size=e,this.value=Array.isArray(r)?r:r instanceof Jf.Vector4?new Array(e).fill(r):new Array(e).fill(new Jf.Vector4(0))}};var ds=class extends be{constructor(e,r,o,n){super("v3");this.nodeType="Blend";this.a=e,this.b=r,this.alpha=o,this.mode=n}generate(e,r){if(e.isShader("fragment")){let o=[];return o.push(this.a.build(e,"c")),o.push(this.b.build(e,"c")),o.push(this.alpha.build(e,"f")),o.push(this.mode.build(e,"i")),e.format("spe_blend("+o.join(",")+")",this.getType(e),r)}else return console.warn("BlendNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),r)}};var eh=class extends be{constructor(e,r){super("v3");this.nodeType="CustomColor";this.color=e,this.alpha=r,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,r){if(e.isShader("fragment")){let o=e.include(eh.Nodes.customColor);e.addFragmentVariable(this.calpha,"float");let n=[];return n.push(this.color.build(e,"v3")),n.push(this.mask?`luminance(${this.mask.build(e,"v3")})`:"1.0"),n.push(this.alpha.build(e,"f")),n.push(this.calpha),e.format(o+"("+n.join(",")+")",this.getType(e),r)}else return console.warn("CustomColorNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),r)}},Rn=eh;Rn.Nodes=function(){return{customColor:new J(`vec3 customColor(vec3 color, float mask, float alpha, out float calpha) {
262
262
  float lalpha = alpha * mask;
263
263
  calpha = lalpha / clamp(lalpha + accumAlpha, 0.00001, 1.0);
264
264
  accumAlpha += (1.0 - accumAlpha) * lalpha;
@@ -1873,7 +1873,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
1873
1873
  vec3 distorted2 = nearby2 + normal * displacementMapTexture(tex, crop, uv, mat, vec2(neighbor_offset)) * intensity;
1874
1874
  displaced_normal = normalize(cross(distorted1 - displaced_position, distorted2 - displaced_position));
1875
1875
  return displaced_position;
1876
- }`,[e,r])}}();var De={normalRenderTarget:new mr,normalRenderTargetDepth:new mr,transmissionRenderTarget:new mr,aspectRatio:new wt,transmissionSize:new wt(2048,2048),transmissionRenderTargetDepth:new mr,aoRenderTarget:new mr,aoEnabled:new Et,pixelRatioNode:new se(1),resolution:new wt,penumbraSize:new yo(5,.5),frameIndex:new Fe(0),transmissionLod:new Fe(2)};for(let i of Object.values(De))i.isRenderGlobal=!0;var Gb={skiaWasmUrl:"https://unpkg.com/@splinetool/ui-wasm@1.10.77/build/ui.wasm"};var pi=class extends ot{constructor(){super("basic");this.nodeType="Basic";this.color=new et(Dt),this.shadingAlpha=new se(1),this.shadingBlend=new Fe(0),this.previousModelViewMatrix=new ir,this.previouseProjectionMatrix=new ir}get category(){return"phong"}generate(e){let r;if(e.isShader("vertex")){let o=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform({frameIndex:De.frameIndex}),e.mergeUniform({resolution:De.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(cd.UniformsUtils.merge([cd.UniformsLib.fog])),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","#include <fog_pars_vertex>","#include <skinning_pars_vertex>","#include <normal_pars_vertex>","#include <morphtarget_pars_vertex>"].join(`
1876
+ }`,[e,r])}}();var De={normalRenderTarget:new mr,normalRenderTargetDepth:new mr,transmissionRenderTarget:new mr,aspectRatio:new wt,transmissionSize:new wt(2048,2048),transmissionRenderTargetDepth:new mr,aoRenderTarget:new mr,aoEnabled:new Pt,pixelRatioNode:new se(1),resolution:new wt,penumbraSize:new yo(5,.5),frameIndex:new Fe(0),transmissionLod:new Fe(2),taaEnabled:new Pt(!0)};for(let i of Object.values(De))i.isRenderGlobal=!0;var Gb={skiaWasmUrl:"https://unpkg.com/@splinetool/ui-wasm@1.10.78/build/ui.wasm"};var pi=class extends ot{constructor(){super("basic");this.nodeType="Basic";this.color=new et(Dt),this.shadingAlpha=new se(1),this.shadingBlend=new Fe(0),this.previousModelViewMatrix=new ir,this.previouseProjectionMatrix=new ir}get category(){return"phong"}generate(e){let r;if(e.isShader("vertex")){let o=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform({frameIndex:De.frameIndex}),e.mergeUniform({resolution:De.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(cd.UniformsUtils.merge([cd.UniformsLib.fog])),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","#include <fog_pars_vertex>","#include <skinning_pars_vertex>","#include <normal_pars_vertex>","#include <morphtarget_pars_vertex>"].join(`
1877
1877
  `));let n=["#include <beginnormal_vertex>","#include <morphnormal_vertex>",`
1878
1878
  #include <skinbase_vertex>
1879
1879
  #include <skinnormal_vertex>
@@ -1895,7 +1895,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
1895
1895
  `];o&&n.push(o.code,o.result?"displaced_position = "+o.result+";":""),n.push("transformed = displaced_position;","#include <morphtarget_vertex>","#include <skinning_vertex>","transformedNormal = normalMatrix * displaced_normal;","#ifndef FLAT_SHADED"," vNormal = transformedNormal;","#endif"),n.push("#include <project_vertex>","#include <fog_vertex>","#include <clipping_planes_vertex>"," vViewPosition = - mvPosition.xyz;","#include <worldpos_vertex>"),n.push("vWPosition = ( modelMatrix * vec4( transformed, 1.0 ) ).xyz;"),r=n.join(`
1896
1896
  `)}else{this.color===void 0&&(this.color=new et(Dt)),this.color.analyze(e,{slot:"color"}),this.alpha&&this.alpha.analyze(e),this.afterColor&&this.afterColor.analyze(e,{slot:"afterColor"});let o=this.color.flow(e,"c",{slot:"color"}),n=this.alpha?this.alpha.flow(e,"f"):void 0,a=this.alphaOverride?this.alphaOverride.flow(e,"f"):void 0,s=this.afterColor?this.afterColor.flow(e,"c",{slot:"afterColor"}):void 0;e.requires.transparent=n!==void 0,e.addParsCode(["varying vec3 vWPosition;","#include <fog_pars_fragment>","#include <dithering_pars_fragment>","varying vec3 vViewPosition;","#include <normal_pars_fragment>"].join(`
1897
1897
  `));let l=["#include <normal_fragment_begin>",o.code];n&&l.push(n.code,"#ifdef ALPHATEST"," if ( "+n.result+" <= ALPHATEST ) discard;","#endif"),s?l.push(s.code,`vec3 outgoingLight = ${o.result};`,`vec3 finalColor = spe_blend(outgoingLight, ${s.result}, 1.0, SPE_BLENDING_NORMAL);`):l.push(`vec3 finalColor = ${o.result};`);let c="1.0";this.mask&&(this.mask.analyze(e),c=`luminance(${this.mask.flow(e,"v3").result})`),n?l.push(`gl_FragColor = vec4( finalColor, accumAlpha * ${n.result} * ${c} );`):l.push("gl_FragColor = vec4("+o.result+", 1.0 );"),a&&l.push(`gl_FragColor.a *= ${a.result};`),l.push("#include <fog_fragment>","#include <dithering_fragment>"),r=l.join(`
1898
- `)}return r}};var Fl=require("three");var jl=class extends ot{constructor(){super("lambert");this.nodeType="Lambert";this.color=new et(Dt),this.emissive=new et(0),this.emissiveIntensity=new se(1),this.previousModelViewMatrix=new ir,this.previouseProjectionMatrix=new ir,this.shadingAlpha=new se(1),this.shadingBlend=new Fe(0),this.occlusion=new Et(!0)}get category(){return"lambert"}build(e){let r;if(e.define("LAMBERT"),e.requires.lights=!0,e.extensions.derivatives=!0,e.isShader("vertex")){let o=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform({frameIndex:De.frameIndex}),e.mergeUniform({resolution:De.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(Fl.UniformsUtils.merge([Fl.UniformsLib.fog,Fl.UniformsLib.lights])),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","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 <skinning_pars_vertex>","#include <normal_pars_vertex>","#include <morphtarget_pars_vertex>","#include <shadowmap_pars_vertex>","#include <clipping_planes_pars_vertex>"].join(`
1898
+ `)}return r}};var Fl=require("three");var jl=class extends ot{constructor(){super("lambert");this.nodeType="Lambert";this.color=new et(Dt),this.emissive=new et(0),this.emissiveIntensity=new se(1),this.previousModelViewMatrix=new ir,this.previouseProjectionMatrix=new ir,this.shadingAlpha=new se(1),this.shadingBlend=new Fe(0),this.occlusion=new Pt(!0)}get category(){return"lambert"}build(e){let r;if(e.define("LAMBERT"),e.requires.lights=!0,e.extensions.derivatives=!0,e.isShader("vertex")){let o=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform({frameIndex:De.frameIndex}),e.mergeUniform({resolution:De.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(Fl.UniformsUtils.merge([Fl.UniformsLib.fog,Fl.UniformsLib.lights])),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","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 <skinning_pars_vertex>","#include <normal_pars_vertex>","#include <morphtarget_pars_vertex>","#include <shadowmap_pars_vertex>","#include <clipping_planes_pars_vertex>"].join(`
1899
1899
  `));let n=["#include <beginnormal_vertex>","#include <morphnormal_vertex>",`
1900
1900
  #include <skinbase_vertex>
1901
1901
  #include <skinnormal_vertex>
@@ -2037,7 +2037,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
2037
2037
 
2038
2038
  vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
2039
2039
  return normalize( abs( fDet ) * vN - vGrad );
2040
- }`);return{dHdxy:i,perturbNormalArb:t}}();var kl=class extends ot{constructor(){super("phong");this.nodeType="Phong";this.color=new et(Dt),this.specular=new et(1118481),this.shininess=new se(30),this.previousModelViewMatrix=new ir,this.previouseProjectionMatrix=new ir,this.shadingAlpha=new se(1),this.shadingBlend=new Fe(0),this.occlusion=new Et(!0)}get category(){return"phong"}build(e){let r;if(e.define("PHONG"),e.requires.lights=!0,e.extensions.derivatives=!0,e.isShader("vertex")){let o=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform({frameIndex:De.frameIndex}),e.mergeUniform({resolution:De.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(Ul.UniformsUtils.merge([Ul.UniformsLib.fog,Ul.UniformsLib.lights])),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","#include <fog_pars_vertex>","#include <skinning_pars_vertex>","#include <normal_pars_vertex>","#include <morphtarget_pars_vertex>","#include <shadowmap_pars_vertex>","#include <clipping_planes_pars_vertex>"].join(`
2040
+ }`);return{dHdxy:i,perturbNormalArb:t}}();var kl=class extends ot{constructor(){super("phong");this.nodeType="Phong";this.color=new et(Dt),this.specular=new et(1118481),this.shininess=new se(30),this.previousModelViewMatrix=new ir,this.previouseProjectionMatrix=new ir,this.shadingAlpha=new se(1),this.shadingBlend=new Fe(0),this.occlusion=new Pt(!0)}get category(){return"phong"}build(e){let r;if(e.define("PHONG"),e.requires.lights=!0,e.extensions.derivatives=!0,e.isShader("vertex")){let o=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform({frameIndex:De.frameIndex}),e.mergeUniform({resolution:De.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(Ul.UniformsUtils.merge([Ul.UniformsLib.fog,Ul.UniformsLib.lights])),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","#include <fog_pars_vertex>","#include <skinning_pars_vertex>","#include <normal_pars_vertex>","#include <morphtarget_pars_vertex>","#include <shadowmap_pars_vertex>","#include <clipping_planes_pars_vertex>"].join(`
2041
2041
  `));let n=["#include <beginnormal_vertex>","#include <morphnormal_vertex>",`
2042
2042
  #include <skinbase_vertex>
2043
2043
  #include <skinnormal_vertex>
@@ -2104,7 +2104,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
2104
2104
  outgoingLight *= ao;
2105
2105
  }
2106
2106
  `),u&&f.push(u.code,`outgoingLight = spe_blend(outgoingLight, ${u.result}, 1.0, SPE_BLENDING_NORMAL);`),p?f.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${p.result});`):f.push("gl_FragColor = vec4( outgoingLight, 1.0 );"),d&&f.push(`gl_FragColor.a *= ${d.result};`),f.push("#include <encodings_fragment>","#include <fog_fragment>","#include <dithering_fragment>"),r=f.join(`
2107
- `)}return r}};var Ts=require("three");var Hl=class extends ot{constructor(){super("standard");this.nodeType="Standard";this.color=new et(Dt),this.roughness=new se(.3),this.metalness=new se(0),this.reflectivity=new se(.5),this.previousModelViewMatrix=new ir,this.previouseProjectionMatrix=new ir,this.shadingAlpha=new se(1),this.shadingBlend=new Fe(0),this.occlusion=new Et(!0)}get category(){return"physical"}build(e){let r;if(e.define("STANDARD"),e.requires.lights=!0,e.extensions.derivatives=!0,e.extensions.shaderTextureLOD=!0,e.isShader("vertex")){let o=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform({frameIndex:De.frameIndex}),e.mergeUniform({resolution:De.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(Ts.UniformsUtils.merge([Ts.UniformsLib.fog,Ts.UniformsLib.lights])),Ts.UniformsLib.LTC_1&&(e.uniforms.ltc_1={value:void 0},e.uniforms.ltc_2={value:void 0}),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","#include <fog_pars_vertex>","#include <skinning_pars_vertex>","#include <normal_pars_vertex>","#include <morphtarget_pars_vertex>","#include <shadowmap_pars_vertex>","#include <clipping_planes_pars_vertex>"].join(`
2107
+ `)}return r}};var Ts=require("three");var Hl=class extends ot{constructor(){super("standard");this.nodeType="Standard";this.color=new et(Dt),this.roughness=new se(.3),this.metalness=new se(0),this.reflectivity=new se(.5),this.previousModelViewMatrix=new ir,this.previouseProjectionMatrix=new ir,this.shadingAlpha=new se(1),this.shadingBlend=new Fe(0),this.occlusion=new Pt(!0)}get category(){return"physical"}build(e){let r;if(e.define("STANDARD"),e.requires.lights=!0,e.extensions.derivatives=!0,e.extensions.shaderTextureLOD=!0,e.isShader("vertex")){let o=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform({frameIndex:De.frameIndex}),e.mergeUniform({resolution:De.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(Ts.UniformsUtils.merge([Ts.UniformsLib.fog,Ts.UniformsLib.lights])),Ts.UniformsLib.LTC_1&&(e.uniforms.ltc_1={value:void 0},e.uniforms.ltc_2={value:void 0}),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","#include <fog_pars_vertex>","#include <skinning_pars_vertex>","#include <normal_pars_vertex>","#include <morphtarget_pars_vertex>","#include <shadowmap_pars_vertex>","#include <clipping_planes_pars_vertex>"].join(`
2108
2108
  `));let n=["#include <beginnormal_vertex>","#include <morphnormal_vertex>",`
2109
2109
  #include <skinbase_vertex>
2110
2110
  #include <skinnormal_vertex>
@@ -2282,7 +2282,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
2282
2282
  outgoingLight = spe_blend( diffuseColor, outgoingLight, ${s.result} * ${f}, ${l.result} );
2283
2283
  }
2284
2284
  `),c&&d.push(c.code,`outgoingLight = spe_blend(outgoingLight, ${c.result}, 1.0, SPE_BLENDING_NORMAL);`),u?d.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${u.result} );`):d.push("gl_FragColor = vec4( outgoingLight, 1.0 );"),p&&d.push(`gl_FragColor.a *= ${p.result};`),d.push("#include <encodings_fragment>","#include <fog_fragment>","#include <dithering_fragment>"),r=d.join(`
2285
- `)}return r}};var fd=require("three");var ud=class{constructor(t=1e3*10){this.timeout=t;this.cache=new Map;this.head={data:null,time:0,src:null,next:null,prev:null};this.tail={data:null,time:1/0,src:null,next:null,prev:null};this.hasClean=!1;this.head.next=this.tail,this.tail.prev=this.head}log(...t){}remove(t){let e=this.cache.get(t);e&&(this.dispose(t,e.data),this.cache.delete(t),e.prev.next=e.next,e.next.prev=e.prev)}scheduleCleanup(){this.hasClean||(this.log("scheduled cleanup"),this.hasClean=!0,setTimeout(()=>{this.hasClean=!1,this.log("cleaning");let t=Date.now(),e=this.head.next;for(;e.time<t-this.timeout;)this.dispose(e.src,e.data),this.cache.delete(e.src),e=e.next,e.prev=this.head,this.head.next=e;this.head.next!==this.tail?this.scheduleCleanup():this.log("no more cleanup")},this.timeout+1e3))}has(t){return this.cache.get(t)?.data}load(t){let e=Date.now(),r=this.cache.get(t);return r===void 0?(r={data:this.create(t),src:t,time:e,next:null,prev:null},this.cache.set(t,r)):(r.time=e,r.prev.next=r.next,r.next.prev=r.prev),r.prev=this.tail.prev,r.next=this.tail,this.tail.prev.next=r,this.tail.prev=r,this.scheduleCleanup(),r.data}};var ph=class extends ud{create(t){return URL.createObjectURL(new Blob([t]))}dispose(t,e){URL.revokeObjectURL(e)}},dh;function Fb(i){return typeof i=="string"?i:(dh||(dh=new ph),dh.load(i))}var dd=class{constructor(t,e){this.data=t;this.cache=e;this.refCount=0}deref(){if(this.refCount===0&&!1)throw new Error("ref count -1?");this.refCount-=1,this.refCount===0&&(this.cache.remove(this),this.dispose())}dispose(){if(this.refCount!==0&&!1)throw new Error("ref count is not 0")}},pd=class{constructor(){this.cache=new Map}remove(t){if(this.cache.delete(t.data)===!1&&!1)throw new Error("ref count remove non-exists")}load(t){let e=this.cache.get(t);return e===void 0&&(e=this.create(t),this.cache.set(t,e)),e.refCount+=1,e}};var Cs=class extends dd{constructor(e,r){super(e,r.imageHolderCache);this.data=e;this.shared=r;this.loaded=!1;this.isVideo=!1;this.isBuffer=!1;this._cache={[1e3]:{},[1001]:{},[1002]:{}};this.isVideo=e.type==="video",this.isBuffer=e.isWebGLRenderTarget===!0,this.loadPromise=this.updateSrc(this.isBuffer?e:e.data)}async updateSrc(e){if(typeof document>"u")return;this.disposeTextures(),this.loaded=!1;let r=()=>{this.loaded=!0;for(let n of Object.values(this._cache))for(let a of Object.values(n))for(let s of Object.values(a))s&&(s.image=this.img,s.needsUpdate=!0);this.shared.requestRender()};if(this.isBuffer)this.img=e,this.loaded=!0;else if(this.isVideo){if(this.img=document.createElement("video"),this.img.preload="auto",this.img.playsInline=!0,this.img.currentTime=.01,typeof e!="string"){var o=new FileReader;o.readAsDataURL(new Blob([e],{type:"video/mp4"}));let n;await new Promise(a=>{o.onloadend=s=>{n=s.target?.result,a(null)}}),this.img.src=n}else this.img.src=e;this.img.onloadeddata=()=>{r()}}else this.img=new Image,this.img.src=Fb(e),this.img.onload=r,await new Promise(n=>{this.img.onload=()=>{r(),n(null)}})}getTexture(e,r=1008,o=1006){let n=this._cache[e]?.[r]?.[o];if(n)return n;{let a;return this.isBuffer?a=this.img.texture:this.isVideo?a=new fd.VideoTexture(this.img,void 0,e,e):a=new fd.Texture(this.img,void 0,e,e,o,r),this.loaded&&(a.needsUpdate=!0),this._cache[e]===void 0&&(this._cache[e]={}),this._cache[e][r]===void 0&&(this._cache[e][r]={}),this._cache[e][r][o]=a,a}}setNeedsUpdate(e){for(let r of Object.values(this._cache))for(let o of Object.values(r))for(let n of Object.values(o))n&&(n.needsUpdate=e)}disposeTextures(){for(let[e,r]of Object.entries(this._cache))for(let[o,n]of Object.entries(r))for(let[a,s]of Object.entries(n))s?.dispose(),this._cache[e]!==void 0&&this._cache[e][o]!==void 0&&(this._cache[e][o][a]=void 0)}dispose(){super.dispose(),this.disposeTextures()}};var Rr=class extends Cs{};var pt=require("three");function nr(i,t){return t.color(i)}function jb(i,t){switch(i.type){case"fresnel":return XI(i,t);case"gradient":return YI(i,t);case"depth":return KI(i,t);case"normal":return QI(i,t);case"noise":return ZI(i,t);case"rainbow":return JI(i,t);case"toon":return e3(i,t);case"outline":return t3(i,t);case"transmission":return r3(i,t);case"color":return $I(i,t);case"pattern":return o3(i,t)}}function qI(i){return{type:i.type}}function xo(i,t){let{alpha:e,mode:r,isMask:o}=i,n=typeof e=="string"?(Number(t.getVariable(e))??100)/100:e;return{...qI(i),alpha:n,mode:r,isMask:o}}function $I(i,t){return{...xo(i,t),color:nr(i.color,t)}}function XI(i,t){let{bias:e,scale:r,intensity:o,factor:n,color:a}=i;return{...xo(i,t),color:nr(a,t),bias:e,scale:r,intensity:o,factor:n}}function YI(i,t){let{gradientType:e,smooth:r,colors:o,steps:n,angle:a,offset:s,morph:l}=i;return{...xo(i,t),gradientType:e,smooth:r,colors:o.map(c=>new pt.Vector4(c[0],c[1],c[2],c[3])),num:o.length,steps:n,offset:new pt.Vector2(...s),morph:new pt.Vector2(...l),angle:a}}function KI(i,t){let{gradientType:e,near:r,far:o,isVector:n,isWorldSpace:a,origin:s,direction:l,colors:c,steps:u,smooth:p}=i;return{...xo(i,t),gradientType:e,near:r,far:o,isVector:n,isWorldSpace:a,origin:new pt.Vector3(...s),direction:l?new pt.Vector3(...l):new pt.Vector3(1,0,0),colors:c.map(d=>d!==void 0?new pt.Vector4(d[0],d[1],d[2],d[3]):new pt.Vector4(0,0,0,0)),steps:u.slice(0,c.length),smooth:p}}function QI(i,t){let{cnormal:e}=i;return{...xo(i,t),cnormal:new pt.Vector3(e[0],e[1],e[2])}}function ZI(i,t){return{...xo(i,t),scale:i.scale,move:i.move,fA:new pt.Vector2(...i.fA),fB:new pt.Vector2(...i.fB),size:new pt.Vector3(...i.size),distortion:new pt.Vector2(...i.distortion),colorA:nr(i.colorA,t),colorB:nr(i.colorB,t),colorC:nr(i.colorC,t),colorD:nr(i.colorD,t),noiseType:i.noiseType,voronoiStyle:i.voronoiStyle,highCut:i.highCut,lowCut:i.lowCut,smoothness:i.smoothness,seed:i.seed,quality:i.quality}}function JI(i,t){return{...xo(i,t),filmThickness:i.filmThickness,movement:i.movement,wavelengths:new pt.Vector3(...i.wavelengths),noiseStrength:i.noiseStrength,noiseScale:i.noiseScale,offset:new pt.Vector3(...i.offset)}}function e3(i,t){return{...xo(i,t),positioning:i.positioning,colors:i.colors.map(e=>new pt.Vector4(e[0],e[1],e[2],e[3])),num:i.colors.length,steps:i.steps,source:new pt.Vector3(...i.source),isWorldSpace:i.isWorldSpace,noiseStrength:i.noiseStrength,noiseScale:i.noiseScale,shadowColor:nr(i.shadowColor,t),offset:new pt.Vector3(...i.offset)}}function t3(i,t){return{...xo(i,t),outlineColor:nr(i.outlineColor,t),contourColor:nr(i.contourColor,t),outlineWidth:i.outlineWidth,contourWidth:i.contourWidth,outlineThreshold:i.outlineThreshold,contourThreshold:i.contourThreshold,outlineSmoothing:i.outlineSmoothing,contourFrequency:i.contourFrequency,contourDirection:new pt.Vector3(...i.contourDirection),positionalLines:i.positionalLines,compensation:i.compensation}}function r3(i,t){return{...xo(i,t),thickness:i.thickness,ior:i.ior,roughness:i.roughness}}function o3(i,t){return{...xo(i,t),style:i.style,projection:i.projection,axis:i.axis,blending:i.blending,offset:new pt.Vector2(...i.offset),colorA:nr(i.colorA,t),colorB:nr(i.colorB,t),frequency:new pt.Vector2(...i.frequency),size:i.size,variation:i.variation,smoothness:i.smoothness,zigzag:i.zigzag,rotation:i.rotation,vertical:new pt.Vector2(...i.vertical),horizontal:new pt.Vector2(...i.horizontal),sides:i.sides}}var $i=class extends kt{};var hd=require("three");var i3={noise:["noiseType"],texture:["projection","axis","side"],video:["projection","axis","side"],displace:["noiseType"],light:["roughnessMap","bumpMap"],depth:["smooth","isWorldSpace","gradientType","isVector"],pattern:["style","projection","axis"]},n3={depth:["colors"]};function a3(i,t,e){if(t==="isMask")return!0;let r=i3[i.type],o=n3[i.type];if(o!==void 0){let n=i.color;if(o.includes(t)){let a=n[t]?.value?.length;if(a!==void 0&&a!==e.length)return!0}}return r!==void 0?r.includes(t):!1}function fh(i,t,e){let r=e.uniforms[`f${e.id}_texture`];if(!r)return!1;let o=!1,n=i;if("image"in n){let a=n.image,s=t.image(a),l=r;l.image instanceof Rr||l.image.deref(),l.image=s}if("video"in n){let a=n.video,s=t.video(a),l=r;l.image instanceof Rr||l.image.deref(),l.image=s}if("wrapping"in n){let a=r;a.wrap=n.wrapping}if("minFilter"in n){let a=r;a.minFilter=n.minFilter}if("magFilter"in n){let a=r;a.magFilter=n.magFilter}if("rotation"in n&&e.uniforms[`f${e.id}_rotation`])return e.uniforms[`f${e.id}_rotation`].value=(n.rotation??0)*hd.MathUtils.DEG2RAD,o;if("repeat"in n||"offset"in n||"rotation"in n){let a="mat",s=e.uniforms[`f${e.id}_${a}`];"repeat"in n&&(s.repeat=n.repeat),"offset"in n&&(s.offset=n.offset),"rotation"in n&&(s.rotation=n.rotation??0),s.updateMatrix()}return o}function Ub(i,t,e,r){let o=!1;for(let[n,a]of Object.entries(i)){if(n==="bumpMap"||n==="roughnessMap"){o=!0;continue}if(!n||a===void 0)continue;if(hh(n,e,r,t)){n==="visible"&&e.type==="light"&&(o=!0);continue}e.visible=r.visible;let s=e.uniforms[`f${e.id}_${n}`];if(!!s&&!(s instanceof Wi))switch(o=o||a3(e,n,a),s.constructor){case et:if(typeof a=="string"){let l=t.getColor(a);l&&(s.value=l);break}else{let l=a;s.value instanceof $i?s.value=new kt(l.r,l.g,l.b,l.a):s.setRGBA(l);break}case Pr:if(typeof a=="string"){let l=t.getColor(a);l&&(s.value=l);break}else{let l=a;s.value instanceof $i?s.value=new kt(l.r,l.g,l.b,l.a):s.value.setRGBA(l.r,l.g,l.b,l.a);break}case wt:{let l=a;s.value.setX(l[0]),s.value.setY(l[1]);break}case or:{let l=a;s.value.setX(l[0]),s.value.setY(l[1]),s.value.setZ(l[2]);break}case mr:{fh(a,t,e);break}case go:{s.value=a.map(l=>new hd.Vector4(...l));break}default:{s.value=a;break}}}return o}var Xi=(i,t,e)=>Math.max(0,Math.min(1,Number(t.getVariable(typeof i=="number"?i*100:i,e)??100)/100))??1,Yi=class{constructor(t,e,r,o,n){this.id=t;this.uuid=e;this.data=r;this.uniforms={};for(let a in o)this.uniforms[`f${this.id}_${a}`]=o[a];for(let a in r)hh(a,this,r,n)}get type(){return this.data.type}static create(t,e,r,o){if(r.type==="light")return yr.createLightLayer(t,e,r,o);if(r.type==="texture"||r.type==="video"){let n=r.type==="texture"?o.uiBuffer(r.texture.image)??o.image(r.texture.image):o.video(r.texture.video),a=new _n(n,r.texture.wrapping,r.texture.minFilter??1008,r.texture.magFilter??1006),s=new sd(n),l=new ld(r.texture.repeat,r.texture.offset,r.texture.rotation??0),c=new se(r.crop?1:0),u=new Fe(r.projection??0),p=new Fe(["x","y","z"].indexOf(r.axis)??0),d=new Fe(r.side??0),f=new wt(r.size?new Ze.Vector2(r.size[0],r.size[1]):new Ze.Vector2(100,100)),h=new se(r.blending??0),m=new se(Xi(r.alpha,o)),y=new Fe(r.mode??0),b=new Et(r.isMask??!1),v=new qi(a,s,c,u,p,d,f,h,l,m,y,b),w=new Ke(v.calpha,"f");return new yt(t,e,r,{texture:a,textureSize:s,crop:c,projection:u,axis:p,side:d,size:f,blending:h,mat:l,alpha:m,mode:y,isMask:b},v,y,w,b,o)}else if(r.type==="matcap"){let n=o.image(r.texture.image),a=new _n(n,r.texture.wrapping,r.texture.minFilter??1008,r.texture.magFilter??1006),s=new se(Xi(r.alpha,o)),l=new Fe(r.mode??0),c=new Et(r.isMask??!1),u=new se((r.texture.rotation??0)*Ze.MathUtils.DEG2RAD),p=new gs(a,s,l,c,u),d=new Ke(p.calpha,"f");return new yt(t,e,r,{texture:a,alpha:s,mode:l,isMask:c,rotation:u},p,l,d,c,o)}else if(r.type==="displace")if(r.displacementType==="noise"){let n=new or(new Ze.Vector3(...r.offset)),a=new se(r.scale??10),s=new se(r.intensity??8),l=new se(r.movement??1),c=new Fe(r.noiseType??0),u=new Fe(r.voronoiStyle??0),p=new se(r.smoothness??.5),d=new se(r.seed??0),f=new se(r.highCut??1),h=new se(r.lowCut??0),m=new Fe(r.quality??1),y=new Os(s,l,n,u,p,d,f,h,m,a,c);return new $l(t,e,r,{offset:n,scale:a,intensity:s,movement:l,noiseType:c,voronoiStyle:u,smoothness:p,seed:d,highCut:f,lowCut:h,quality:m},y,o)}else throw new Error;else return c3(t,e,r,o)}updateByOp(t,e,r){let o=t;if(o.path[0]===void 0){if(o.type===0)return"type"in o.props||"category"in o.props||"visible"in o.props||"noiseType"in o.props?(r.scene.markNeedsUpdateRendererDirty(),!0):Ub(o.props,r.shared,this,e)}else if(o.path[0]==="texture")return"texture"in e||"video"in e?fh(o.props,r.shared,this):!0;return!1}dispose(){if(s3(this)){let t=this.uniforms[`f${this.id}_texture`];if(!t)return!1;let e=t;e.image instanceof Rr||e.image.deref()}}hasValueByKey(t){return this.uniforms[t]!==void 0}hasValue(t){return this.hasValueByKey(`f${this.id}_${t}`)}setValue(t,e){let r=`f${this.id}_${t}`;this.hasValueByKey(r)&&e!==void 0&&(this.uniforms[r].value=e)}getNode(t){let e=`f${this.id}_${t}`;if(this.hasValueByKey(e))return this.uniforms[e]}getValue(t){let e=`f${this.id}_${t}`;if(this.hasValueByKey(e))return this.uniforms[e].value}getName(t){let r=/f\d+_(.*)/.exec(t);if(r&&r.length>1)return r[1];console.log(`Layer.getName: error ${t}`)}getNames(){let t=[];for(let e in this.uniforms){let r=this.getName(e);r&&t.push(r)}return t}},yt=class extends Yi{constructor(e,r,o,n,a,s,l,c,u){super(e,r,o,n,u);this.params=n;this.color=a;this.mode=s;this.alpha=l;this.isMask=c}},$l=class extends Yi{constructor(e,r,o,n,a,s){super(e,r,o,n,s);this.position=a}},yr=class extends Yi{constructor(e,r,o,n,a,s){super(e,r,o,a,s);this.node=n}static createLightLayer(e,r,o,n){let a,s=new se(Xi(o.alpha,n)),l=new Fe(o.mode),c=new se(o.bumpMapIntensity),u=new se(Xi(o.alphaOverride,n)),p;if(!o.visible)a=new pi,p={};else if(o.category==="lambert"){a=new jl;let d=new et(n.color(o.emissive)??0),f=new Et(o.occlusion??!0);p={emissive:d,occlusion:f},a.emissive=d,a.occlusion=f}else if(o.category==="toon"){a=new ql;let d=new se(o.shininess??30),f=new et(n.color(o.specular)??1118481);p={shininess:d,specular:f},a.shininess=d,a.specular=f}else if(o.category==="physical"){a=new Hl;let d=new se(o.roughness??.3),f=new se(o.metalness??0),h=new se(o.reflectivity??.5),m=new Et(o.occlusion??!0);p={roughness:d,metalness:f,reflectivity:h,occlusion:m},a.roughness=d,a.metalness=f,a.reflectivity=h,a.occlusion=m}else{a=new kl;let d=new se(o.shininess??30),f=new et(o.specular!==void 0?n.color(o.specular)??1118481:1118481),h=new Et(o.occlusion??!0);p={shininess:d,specular:f,occlusion:h},a.shininess=d,a.specular=f,a.occlusion=h}return a.alpha=new se(1),a.shadingAlpha=s,a.shadingBlend=l,a.bumpMapIntensity=c,a.alphaOverride=u,p.alpha=a.shadingAlpha,p.mode=a.shadingBlend,p.bumpMapIntensity=a.bumpMapIntensity,p.alphaOverride=a.alphaOverride,new yr(e,r,o,a,p,n)}get category(){return this.node.category}};function s3(i){let t=i instanceof Yi?i.type:i;return t==="texture"||t==="video"||t==="displace_map"||t==="matcap"}function qr(i){return{alpha:new se(i.alpha??1),mode:new Fe(i.mode??0),isMask:new Et(i.isMask??!1)}}function l3(i,t,e,r,o){switch(i.type){case"color":{let n=new et(r.color??Dt),a=qr(r),s=new Rn(n,a.alpha),l=new Ke(s.calpha,"f");return new yt(t,e,i,{color:n,...a},s,a.mode,l,a.isMask,o)}case"fresnel":{let n=new et(r.color??16777215),a=new se(r.bias??.1),s=new se(r.scale??1),l=new se(r.intensity??2),c=new se(r.factor??1),u=qr(r),p=new Gl(n,a,s,l,c,u.alpha,u.mode,u.isMask),d=new Ke(p.calpha,"f");return new yt(t,e,i,{color:n,bias:a,scale:s,intensity:l,factor:c,...u},p,u.mode,d,u.isMask,o)}case"rainbow":{let n=new se(r.filmThickness??30),a=new se(r.movement??0),s=new or(r.wavelengths??new Ze.Vector3(0,0,0)),l=new se(r.noiseStrength??0),c=new se(r.noiseScale??1),u=new or(r.offset??new Ze.Vector3(0,0,0)),p=qr(r),d=new Ss(n,a,s,l,c,u,p.alpha,p.isMask),f=new Ke(d.calpha,"f");return new yt(t,e,i,{filmThickness:n,movement:a,wavelengths:s,noiseStrength:l,noiseScale:c,offset:u,...p},d,p.mode,f,p.isMask,o)}case"transmission":{let n=new se(r.thickness??10),a=new se(r.ior??1.5),s=new se(r.roughness??.5),l=De.transmissionSize,c=De.transmissionRenderTarget,u=De.transmissionRenderTargetDepth,p=window.innerWidth,d=window.innerHeight,f=p>=d?new wt(d/p,1):new wt(1,p/d),h=qr(r),m=new Ps(n,a,s,l,c,u,f,h.alpha),y=new Ke(m.calpha,"f");return new yt(t,e,i,{thickness:n,ior:a,roughness:s,aspectRatio:f,...h},m,h.mode,y,h.isMask,o)}case"toon":{let n=new Fe(r.positioning??0),a;r.colors?a=new go(r.colors.length,r.colors):(a=new go(10,new Ze.Vector4(0,0,0,1)),a.value[1]=new Ze.Vector4(1,1,1,1));let s;r.steps?s=new yo(r.steps.length,r.steps):(s=new yo(10,1),s.value[0]=0);let l=new or(r.source??new Ze.Vector3(0,0,0)),c=new Et(r.isWorldSpace??!0),u=new se(r.noiseStrength??0),p=new se(r.noiseScale??1),d=new Pr(r.shadowColor),f=new or(r.offset??new Ze.Vector3(0,0,0)),h=qr(r),m=new ws(n,a,s,l,c,u,p,d,f,h.alpha),y=new Ke(m.calpha,"f");return new yt(t,e,i,{positioning:n,colors:a,steps:s,source:l,isWorldSpace:c,noiseStrength:u,noiseScale:p,shadowColor:d,offset:f,...h},m,h.mode,y,h.isMask,o)}case"outline":{let n=new et(r.outlineColor??16777215),a=new et(r.contourColor??16777215),s=new se(r.outlineWidth??.1),l=new se(r.contourWidth??.1),c=new se(r.outlineThreshold??.1),u=new se(r.contourThreshold??.1),p=new se(r.outlineSmoothing??.1),d=new se(r.contourFrequency??.1),f=new or(r.contourDirection??new Ze.Vector3(0,1,0)),h=new Et(r.positionalLines??!1),m=new Et(r.compensation??!0),y=De.normalRenderTarget,b=De.normalRenderTargetDepth,v=De.pixelRatioNode,w=De.resolution,O=qr(r),S=new bs(n,a,s,l,c,u,p,d,f,h,m,w,y,b,v,O.alpha),T=new Ke(S.calpha,"f");return new yt(t,e,i,{outlineColor:n,contourColor:a,outlineWidth:s,contourWidth:l,outlineThreshold:c,contourThreshold:u,outlineSmoothing:p,contourFrequency:d,contourDirection:f,positionalLines:h,compensation:m,...O},S,O.mode,T,O.isMask,o)}case"depth":{let n=new Fe(r.gradientType??0),a=new Et(r.smooth??!1),s=new se(r.near??50),l=new se(r.far??200),c=new se(r.isVector??1),u=new se(r.isWorldSpace??0),p=new or(r.origin??new Ze.Vector3),d=new or(r.direction??new Ze.Vector3),f;r.colors?f=new go(r.colors.length,r.colors):(f=new go(2,new Ze.Vector4(0,0,0,1)),f.value[1]=new Ze.Vector4(1,1,1,1));let h;r.steps?h=new yo(r.steps.length,r.steps):(h=new yo(2,1),h.value[0]=0);let m=qr(r),y=new ms(n,a,s,l,c,u,p,d,f,h,m.alpha,m.isMask),b=new Ke(y.calpha,"f");return new yt(t,e,i,{gradientType:n,smooth:a,near:s,far:l,isVector:c,isWorldSpace:u,origin:p,direction:d,colors:f,steps:h,...m},y,m.mode,b,m.isMask,o)}case"noise":{let n=new se(r.scale??1),a=new or(r.size??new Ze.Vector3(100,100,100)),s=new se(r.move??1),l=new wt(r.fA??new Ze.Vector2(1.7,9.2)),c=new wt(r.fB??new Ze.Vector2(8.3,2.8)),u=new wt(r.distortion??new Ze.Vector2(1,1)),p=new Pr(r.colorA),d=new Pr(r.colorB),f=new Pr(r.colorC),h=new Pr(r.colorD),m=new Fe(r.noiseType??0),y=new Fe(r.voronoiStyle??0),b=new se(r.highCut??1),v=new se(r.lowCut??0),w=new se(r.smoothness??.5),O=new se(r.seed??.5),S=new Fe(r.quality??1),T=qr(r),M=new xs(n,a,s,l,c,u,p,d,f,h,T.alpha,m,T.isMask,y,b,v,w,O,S),g=new Ke(M.calpha,"f");return new yt(t,e,i,{scale:n,size:a,move:s,fA:l,fB:c,distortion:u,colorA:p,colorB:d,colorC:f,colorD:h,noiseType:m,...T,voronoiStyle:y,highCut:b,lowCut:v,smoothness:w,seed:O,quality:S},M,T.mode,g,T.isMask,o)}case"normal":{let n=new or(r.cnormal??new Ze.Vector3(1,1,1)),a=qr(r),s=new ps(n,a.alpha),l=new Ke(s.calpha,"f");return new yt(t,e,i,{cnormal:n,...a},s,a.mode,l,a.isMask,o)}case"gradient":{let n=new Fe(r.gradientType??0),a=new Et(r.smooth??!1),s;r.colors?s=new go(r.colors.length,r.colors):(s=new go(10,new Ze.Vector4(0,0,0,1)),s.value[1]=new Ze.Vector4(1,1,1,1));let l;r.steps?l=new yo(r.steps.length,r.steps):(l=new yo(10,1),l.value[0]=0);let c=new wt(r.offset??new Ze.Vector2(0,0)),u=new wt(r.morph??new Ze.Vector2(0,0)),p=new se(r.angle??0),d=qr(r),f=new ys(n,a,s,l,c,u,p,d.alpha,d.isMask),h=new Ke(f.calpha,"f");return new yt(t,e,i,{gradientType:n,smooth:a,colors:s,steps:l,offset:c,morph:u,angle:p,...d},f,d.mode,h,d.isMask,o)}case"pattern":{let n=new Fe(r.style??0),a=new Fe(r.projection??0),s=new Fe(["x","y","z"].indexOf(r.axis)??0),l=new se(r.blending??0),c=new wt(r.offset??new Ze.Vector2(0,0)),u=new Pr(r.colorA),p=new Pr(r.colorB),d=new wt(r.frequency??new Ze.Vector2(10,10)),f=new se(r.size??.5),h=new se(r.variation??0),m=new se(r.smoothness??.5),y=new se(r.zigzag??0),b=new se(r.rotation??0),v=new wt(r.vertical??new Ze.Vector2(0,1)),w=new wt(r.horizontal??new Ze.Vector2(0,1)),O=new Fe(r.sides??6),S=qr(r),T=new vs(n,a,s,l,c,u,p,d,f,h,m,y,b,v,w,O,S.alpha,S.isMask),M=new Ke(T.calpha,"f");return new yt(t,e,i,{style:n,projection:a,axis:s,blending:l,offset:c,colorA:u,colorB:p,frequency:d,size:f,variation:h,smoothness:m,zigzag:y,rotation:b,vertical:v,horizontal:w,sides:O,...S},T,S.mode,M,S.isMask,o)}default:{let n=new et(1,0,0,1),a=qr(r),s=new Rn(n,a.alpha),l=new Ke(s.calpha,"f");return new yt(t,e,i,{color:n,...a},s,a.mode,l,a.isMask,o)}}}function c3(i,t,e,r){let o=jb(e,r);return l3(e,i,t,o,r)}function hh(i,t,e,r){if(e.type==="displace"&&(i==="intensity"||i==="visible")){let o=t.uniforms[`f${t.id}_intensity`];return o?(o.value=e.intensity*(e.visible?1:0),o):void 0}if(e.type!=="displace"&&(i==="alpha"||i==="visible")){let o=t.uniforms[`f${t.id}_alpha`];if(!o)return;if(o.value=Xi(e.alpha,r)*(e.visible?1:0),e.type==="outline"&&i==="visible"){let n=t.uniforms[`f${t.id}_compensation`];n&&(n.value=e.compensation&&e.visible)}return o}}function md(i,t){let e=0,r=i.layers.find(o=>o.data.type==="light");if(r){let o=r.data,n=Number(t.getVariable(o.alphaOverride));if((typeof o.alphaOverride=="string"?n/100:o.alphaOverride)<1)return!0}for(let o of i.layers){if(o.data.type!=="displace"&&o.data.isMask)return!0;if(o.data.type!=="displace"&&"alpha"in o.data&&o.data.type!=="light"&&o.data.type!=="fresnel"&&o.data.type!=="texture"&&o.data.type!=="matcap"&&o.data.type!=="rainbow"&&o.data.type!=="outline"&&o.data.type!=="pattern"){let n=o.data.visible?o.data.alpha:0;if(typeof n=="string"&&(n=Math.max(0,Math.min(1,Number(t.getVariable(n)??100)/100))),n===1&&o.data.type==="depth"||o.data.type==="gradient"){for(let a of o.data.colors)if(a[3]<1){n=a[3];break}}else if(n===1&&o.data.type==="noise"){let a=t.color(o.data.colorA).a,s=t.color(o.data.colorB).a,l=t.color(o.data.colorC).a,c=t.color(o.data.colorD).a,u=Math.min(a,Math.min(s,Math.min(l,c)));u<1&&(n=u)}e+=(1-e)*n}}return e<1}var Tr=class extends kb.ShaderMaterial{constructor(){super(void 0);this.flatShading=!1;this.needsJitter=!0;this.shadersPatchedForShapeBlend=!1;this.nodeContextUuid=0;this.fog=!0,this.dithering=!0,this.vertexColors=!0,this.transparent=!0}customProgramCacheKey(){return""}},yd=class extends Tr{constructor(e,r,o,n){super();this.flatShading=e;this.side=r;this.wireframe=o;this.root=n}updateAfterBuild(){let e=this.root;this.lights=e.lights,this.vertexShader=e.vertexShader,this.fragmentShader=e.fragmentShader,Object.assign(this.defines,e.defines),Object.assign(this.uniforms,e.uniforms),this.extensions=e.extensions,this.transparent=e.transparent,this.cacheKey=e.customProgramCacheKey()+"flat"+this.flatShading+this.side}onBeforeCompile(e,r){this.root.onBeforeCompile(e)}get data(){return this.root.data}get category(){return this.root.category}get hasAO(){return this.root.hasAO}getFlavor(e,r,o,n){return this.root.getFlavor(e,r,o,n)}get layers(){return this.root.layers}get fragment(){return this.root.fragment}getLayersOfType(e){return this.root.getLayersOfType(e)}getLayerByUuid(e){return this.root.getLayerByUuid(e)}updateByOp(e,r,o){this.root.updateByOp(e,r,o)}nodeMaterialDispose(){this.root.nodeMaterialDispose()}},Bn=class extends Tr{constructor(e,r,o=!0){super();this.data=e;this.allowVariableSaves=o;this.layerIdGen=0;this.flavors=[];this.masks={};this.type="NodeMaterial";this.updaters=[],this.needsJitter=r.shared.needsJitter,ot.startContext(this),this.reset0(e,r),ot.endContext(this)}get nodeMaterial(){return this}getFlavor(e,r,o,n){let a=o?6:(e?3:0)+r;if(a+=((n?.resolutionLevel??0)-(n?.useChildrenColors?4:0))*7,a===0)return this;this.flavors===void 0&&(this.flavors=[]),a-=1;let s=this.flavors[a];return s===void 0&&(s=new yd(e,r,o,this),s.needsJitter=this.needsJitter,this.flavors[a]=s,s.flatShading=e,s.side=r,s.updateAfterBuild(),n&&(s.defines.SHAPEBLEND=n.resolutionLevel,s.defines.SHAPEBLEND_C=n.useChildrenColors?1:0)),s}get fragment(){return this.lightLayer.node}get category(){return this.lightLayer.category}get hasAO(){return this.lightLayer.getNode("occlusion")?.value??!1}reset(e,r,o=!1){ot.startContext(this),(this.data!==e||o)&&this.reset0(e,r),ot.endContext(this)}reset0(e,r){this.data=e;let o=e.layers??Ut.defaultTwoLayerData("phong").layers;try{this.layers=o.map(n=>Yi.create(this.layerIdGen++,n.id,n.data,r.shared))}catch{this.layers=[]}this.layers.reverse(),this.name=e.name??"Untitled Material",this.onUpdate(r.shared),this.transparent=md(e,r.shared),this.saveVariableLocations(r)}onVariableUpdate(e,r,o){if(e[0]==="alphaOverride")this.transparent=md(this.data,o.shared),this.lightLayer.setValue("alphaOverride",Math.max(0,Math.min(Number(r)/100,1)));else if(e[0]==="layer"){let n=e[1],a=e[2];if(n&&a){let s=this.layers.find(l=>l.uuid===n);s?.hasValue(a)&&(a==="alpha"?(this.transparent=md(this.data,o.shared),s.setValue(a,Math.max(0,Math.min(Number(r)/100,1)))):s.setValue(a,r))}}}saveVariableLocations(e){if(!this.allowVariableSaves)return;let r=this.data.layers.find(o=>o.data.type==="light");r&&e.shared.getVariable(r.data.alphaOverride,["material",this.uuid,"alphaOverride"]),this.data.layers.forEach(o=>{"alpha"in o.data&&typeof o.data.alpha=="string"&&e.shared.getVariable(o.data.alpha,["material",this.uuid,"layer",o.id,"alpha"])})}getLayersOfType(e){return this.layers.filter(r=>r.type===e)}getLayerByUuid(e){return this.layers.find(r=>r.uuid===e)}onUpdate(e){this.lightLayer=this.layers.find(r=>r instanceof yr),this.lightLayer===void 0&&(this.lightLayer=new yr(0,"",{...Vt.defaultData("light","phong"),visible:!1},new pi,{},e)),this.dispose();for(let r of this.flavors)r&&r.dispose();this.applyTextureMaps(),this.applyMasks(),this.blendColors(),this.blendAfterColors(),this.blendPositions(),this.build(),this.nodeContextUuid=0}applyTextureMaps(){let e=this.layers.find(a=>a instanceof yr);if(!e)return;let r=e.data,o=r.bumpMap,n=r.roughnessMap;e.node.bumpMap=void 0,e.node.roughnessMap=void 0;for(let a=0;a<this.layers.length;++a){let s=this.layers[a];s instanceof yt&&s.color instanceof qi&&(s.uuid===o&&(e.node.bumpMap=s.color),s.uuid===n&&(e.node.roughnessMap=s.color))}}updateByOp(e,r,o){if(ot.startContext(this),r!==void 0?this.data=r:r=this.data,this.transparent=md(r,o.shared),e.path[0]==="layers"){let n=o.shared,a=e.path[1];if(a===void 0)o.scene.markNeedsUpdateRendererDirty(),this.reset0(r,o);else{e.type===0&&e.props.occlusion!==void 0&&o.scene.markNeedsUpdateRendererDirty();let s=this.layers.find(l=>l.uuid===a);if(s){let l=r.layers.data(a),c;e.type===0&&("alpha"in e.props||"alphaOverride"in e.props)&&("alpha"in e.props?c={...e.props,alpha:Xi(e.props.alpha,n,["material",this.uuid,"layer",a,"alpha"])}:c={...e.props,alphaOverride:Xi(e.props.alphaOverride,n,["material",this.uuid,"alphaOverride"])}),s.updateByOp({...e,...c?{props:c}:{},path:e.path.slice(2)},l,o)&&this.reset0(r,o)}}}else this.reset0(r,o);ot.endContext(this)}applyMasks(){for(let e=0;e<this.layers.length;++e){let r=this.layers[e];r instanceof yt?r.color.mask=void 0:r instanceof yr&&(r.node.mask=void 0)}for(let e=0;e<this.layers.length;++e){let r=this.layers[e];if(r instanceof yt&&r.isMask.value&&r.data.visible&&e>0){let o=e-1,n=this.layers[o];n instanceof yr?n.node.mask=new Zt(r.color,r.alpha,Zt.MUL):n instanceof yt&&(n.isMask.value||(n.color.mask=new Zt(r.color,r.alpha,Zt.MUL)))}}}blendColors(){let e=this.layers.findIndex(o=>o instanceof yt),r=this.layers.findIndex(o=>o instanceof yr);if(e!==-1&&e<r){let o=this.layers[e].color;for(let n=e+1;n<r;++n){let a=this.layers[n];if(a instanceof yt){if(a.isMask.value)continue;o=new ds(o,a.color,a.alpha,a.mode)}}this.fragment.color=o}else this.fragment.color=void 0}blendAfterColors(){let e=new Ke("outgoingLight","f"),r=this.layers.findIndex(o=>o instanceof yr);if(this.layers.length>r+1){for(let o=r+1;o<this.layers.length;++o){let n=this.layers[o];if(n instanceof yt){if(n.isMask.value)continue;e=new ds(e,n.color,n.alpha,n.mode)}}this.fragment.afterColor=e}else this.fragment.afterColor=void 0}blendPositions(){let e=this.layers.filter(r=>r instanceof $l);if(e.length>0){let r=e[0].position;for(let o=1;o<e.length;++o)e[o]&&(r=new Zt(r,e[o].position,Zt.ADD),r=new Zt(r,new se(.5).setReadonly(!0),Zt.MUL));this.fragment.position=r}else this.fragment.position=void 0}getDefines(){return this.defines}getUniforms(){return this.uniforms}getVertexShader(){return this.vertexShader}getFragmentShader(){return this.fragmentShader}onBeforeCompile(e){this.shapeBlendhack&&this.shapeBlendhack(this),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}clampUniformsForPreview(e,r){let o=(n,a,s)=>Math.min(Math.max(n,a),s);for(let n of this.layers)if(n.type==="displace"){let a=o(n.uniforms[`f${n.id}_intensity`].value,e,r);n.uniforms[`f${n.id}_intensity`].value=a}}updateFrame(e){for(let r=0;r<this.updaters.length;++r)e.updateNode(this.updaters[r])}build(){let e=new cs;e.needsJitter=this.needsJitter,this.lights=this.lightLayer.data.visible,e.build(this.fragment,this.fragment),this.vertexShader=e.getCode("vertex"),this.fragmentShader=e.getCode("fragment"),this.defines=e.defines,this.uniforms=e.uniforms,this.extensions=e.extensions,this.updaters=e.updaters;for(let r of this.flavors)r&&r.updateAfterBuild();return this.shadersPatchedForShapeBlend=!1,this}nodeMaterialDispose(){this.layers.forEach(e=>e.dispose()),super.dispose();for(let e of this.flavors)e&&e.dispose()}assetsLoaded(){for(let e of this.layers)if(e instanceof yt){let r=e.params.texture;if(r instanceof _n&&!r.image.loaded)return!1}return!0}};Object.defineProperties(Tr.prototype,{properties:{get:function(){return this.fragment.properties}}});var Vn=class extends Bn{constructor(t,e,r){super(t,e,!1),this.uuid=r,this.allowVariableSaves=!0,this.saveVariableLocations(e)}};var Hb=new Map;function Wb(i){if(typeof i=="string")return i;let t=Hb.get(i);return t||(t={url:URL.createObjectURL(new Blob([i]))},Hb.set(i,t)),t.url}var u3,qb=new Promise(i=>{u3=i});var $b;qb.then(i=>$b=i);var zn=class{constructor({src:t,volume:e,delay:r,loop:o}){this._volume=1;this.delay=0;this._loop=1;this.loopsRemaining=0;this._status="stopped";this.onEnd=()=>{this.loopsRemaining===1/0?this.replay():this.loopsRemaining>1?(this.replay(),this.loopsRemaining--):(this._status="stopped",this.loopsRemaining=this._loop)};let n;typeof t=="string"?n={src:t}:n={src:Wb(t),format:"wav"},this.sound=new $b.Howl(n),this.sound.on("end",this.onEnd),this.src=t,e!==void 0&&(this.volume=e),r!==void 0&&(this.delay=r),o!==void 0&&(this.loop=o)}get status(){return this._status}get volume(){return this._volume}set volume(t){this._volume=t,this.sound.volume(t)}get loop(){return this._loop}set loop(t){this._loop=t,this.loopsRemaining=t}replay(){this.clearDelay(),this.delayTimerId=window.setTimeout(()=>{this.sound.play(),this.clearDelay()},this.delay)}fade(t,e=1e3){t?(this.sound.volume(this._volume),this.clearFade(),this.fadeTimerId=window.setTimeout(()=>{this.sound.fade(this._volume,0,e),this.clearFade()},t)):this.sound.fade(this._volume,0,e)}on(t,e,r){this.sound.on(t,e,r)}off(t,e,r){this.sound.off(t,e,r)}play(){this._status==="playing"||this.sound.playing()||(this._status==="paused"?(this.sound.seek()===0?this.replay():this.sound.play(),this._status="playing"):this._status==="stopped"&&(this.replay(),this._status="playing"))}pause(){this._status==="playing"&&(this.sound.pause(),this.clearFade(),this.clearDelay(),this._status="paused")}stop(){this.sound.stop(),this.loopsRemaining=this._loop,this.clearFade(),this.clearDelay(),this._status="stopped"}clearFade(){this.fadeTimerId&&(clearTimeout(this.fadeTimerId),delete this.fadeTimerId)}clearDelay(){this.delayTimerId&&(clearTimeout(this.delayTimerId),delete this.delayTimerId)}dispose(t=!1){this.off(),this.stop(),this.clearFade(),this.clearDelay()}};var $t=require("three"),gd=class{constructor(){this.type="ShapePath";this.color=new $t.Color;this.subPaths=[];this.currentPath=null}moveTo(t,e){return this.currentPath=new $t.Path,this.subPaths.push(this.currentPath),this.currentPath.moveTo(t,e),this}lineTo(t,e){return this.currentPath?.lineTo(t,e),this}quadraticCurveTo(t,e,r,o){return this.currentPath?.quadraticCurveTo(t,e,r,o),this}bezierCurveTo(t,e,r,o,n,a){return this.currentPath?.bezierCurveTo(t,e,r,o,n,a),this}splineThru(t){return this.currentPath?.splineThru(t),this}toShapes(){let e={ORIGIN:0,DESTINATION:1,BETWEEN:2,LEFT:3,RIGHT:4,BEHIND:5,BEYOND:6},r={loc:e.ORIGIN,t:0};function o(m,y,b,v){let w=m.x,O=y.x,S=b.x,T=v.x,M=m.y,g=y.y,D=b.y,E=v.y,I=(T-S)*(M-D)-(E-D)*(w-S),N=(O-w)*(M-D)-(g-M)*(w-S),_=(E-D)*(O-w)-(T-S)*(g-M),R=I/_,V=N/_;if(_===0&&I!==0||R<=0||R>=1||V<0||V>1)return null;if(I===0&&_===0){for(let U=0;U<2;U++)if(n(U===0?b:v,m,y),r.loc===e.ORIGIN){let B=U===0?b:v;return{x:B.x,y:B.y,t:r.t}}else if(r.loc===e.BETWEEN){let B=+(w+r.t*(O-w)).toPrecision(10),q=+(M+r.t*(g-M)).toPrecision(10);return{x:B,y:q,t:r.t}}return null}else{for(let q=0;q<2;q++)if(n(q===0?b:v,m,y),r.loc===e.ORIGIN){let j=q===0?b:v;return{x:j.x,y:j.y,t:r.t}}let U=+(w+R*(O-w)).toPrecision(10),B=+(M+R*(g-M)).toPrecision(10);return{x:U,y:B,t:R}}}function n(m,y,b){let v=b.x-y.x,w=b.y-y.y,O=m.x-y.x,S=m.y-y.y,T=v*S-O*w;if(m.x===y.x&&m.y===y.y){r.loc=e.ORIGIN,r.t=0;return}if(m.x===b.x&&m.y===b.y){r.loc=e.DESTINATION,r.t=1;return}if(T<-Number.EPSILON){r.loc=e.LEFT;return}if(T>Number.EPSILON){r.loc=e.RIGHT;return}if(v*O<0||w*S<0){r.loc=e.BEHIND;return}if(Math.sqrt(v*v+w*w)<Math.sqrt(O*O+S*S)){r.loc=e.BEYOND;return}let M;v!==0?M=O/v:M=S/w,r.loc=e.BETWEEN,r.t=M}function a(m,y){let b=[],v=[];for(let w=1;w<m.length;w++){let O=m[w-1],S=m[w];for(let T=1;T<y.length;T++){let M=y[T-1],g=y[T],D=o(O,S,M,g);D!==null&&b.find(E=>E.t<=D.t+Number.EPSILON&&E.t>=D.t-Number.EPSILON)===void 0&&(b.push(D),v.push(new $t.Vector2(D.x,D.y)))}}return v}function s(m,y,b){let v=new $t.Vector2;y.getCenter(v);let w=[];return b.forEach(O=>{O.boundingBox.containsPoint(v)&&a(m,O.points).forEach(T=>{w.push({identifier:O.identifier,isCW:O.isCW,point:T})})}),w.sort((O,S)=>O.point.x-S.point.x),w}function l(m,y,b,v,w){(w==null||w==="")&&(w="nonzero");let O=new $t.Vector2;m.boundingBox.getCenter(O);let S=[new $t.Vector2(b,O.y),new $t.Vector2(v,O.y)],T=s(S,m.boundingBox,y);T.sort((N,_)=>N.point.x-_.point.x);let M=[],g=[];T.forEach(N=>{N.identifier===m.identifier?M.push(N):g.push(N)});let D=M[0].point.x,E=[],I=0;for(;I<g.length&&g[I].point.x<D;)E.length>0&&E[E.length-1]===g[I].identifier?E.pop():E.push(g[I].identifier),I++;if(E.push(m.identifier),w==="evenodd"){let N=E.length%2===0,_=E[E.length-2];return{identifier:m.identifier,isHole:N,for:_}}else if(w==="nonzero"){let N=!0,_=null,R=null;for(let V=0;V<E.length;V++){let U=E[V];y[U]&&(N?(R=y[U].isCW,N=!1,_=U):R!==y[U].isCW&&(R=y[U].isCW,N=!0))}return{identifier:m.identifier,isHole:N,for:_}}else console.warn('fill-rule: "'+w+'" is currently not implemented.')}let c=0,u=999999999,p=-999999999,d=[];this.subPaths.forEach(m=>{let y=m.getPoints(),b=-999999999,v=999999999,w=-999999999,O=999999999;for(let S=0;S<y.length;S++){let T=y[S];T.y>b&&(b=T.y),T.y<v&&(v=T.y),T.x>w&&(w=T.x),T.x<O&&(O=T.x)}p<=w&&(p=w+1),u>=O&&(u=O-1),y.length&&d.push({curves:m.curves,points:y,isCW:$t.ShapeUtils.isClockWise(y),identifier:c++,boundingBox:new $t.Box2(new $t.Vector2(O,v),new $t.Vector2(w,b))})});let f=d.map(m=>l(m,d,u,p,this.userData?.style.fillRule)),h=[];return d.forEach(m=>{let y=f[m.identifier];if(y&&!y.isHole){let b=new $t.Shape;b.curves=m.curves,f.filter(w=>w?.isHole&&w.for===m.identifier).forEach(w=>{if(w){let O=d[w.identifier],S=new $t.Path;S.curves=O.curves,b.holes.push(S)}}),h.push(b)}}),h}};var mh=!1,Yb,yh=new Promise(i=>{Yb=i}),Xb=!1;var xd;function Kb(){if(mh=!0,Xb)return;if(xd)return xd;async function i(){let e=await import("./opentype.js");Yb(e),Xb=!0}return xd=i(),xd}var Xl=class{async load(t,e,r=()=>{}){let{load:o}=await yh;o(t,(n,a)=>{n||!a?r(n??"Something went wrong"):e(a)})}async parse(t){let{parse:e,Bidi:r}=await yh;try{let o=e(t),n=new r,a=s=>o.charToGlyphIndex(s.char);return n.registerModifier("glyphIndex",null,a),n.applyFeatures(o,o.defaultRenderOptions.features),{font:o,bidi:n}}catch(o){console.error(o)}}};async function d3(i){return await(await fetch(i)).arrayBuffer()}var p3=new Xl;async function gh(i){let t,e,r=!1;if(i.url?(t=await d3(i.url),e=i.url,r=i.url.startsWith("/")):i.data&&(t=i.data.buffer.slice(i.data.byteOffset,i.data.byteOffset+i.data.byteLength)),t)if(mh){let o=await p3.parse(t);if(o)return{font:o.font,url:e,intercepted:r,arr:t,bidi:o.bidi}}else return{font:void 0,url:e,intercepted:r,arr:t,bidi:null}}var As=require("three");function f3(i,t){return t.state.glyphIndex===i||t.state.fina===i||t.state.medi===i||t.state.init===i}var bd=class{constructor(t){this._arrayBuffer=new ArrayBuffer(1);this._isLoaded=!1;this._intercepted=!1;this._isUserFont=t.isUserFont??!1,this._loadingPromise=gh(t).then(e=>{e&&(this._arrayBuffer=e.arr,this._url=e.url,this.font=e.font,this._intercepted=e.intercepted,this._isLoaded=!0,this._bidi=e.bidi)})}update(t){this._isLoaded=!1,this._isUserFont=t.isUserFont??!1,this._loadingPromise=gh(t).then(e=>{e&&(this._arrayBuffer=e.arr,this._url=e.url,this.font=e.font,this._intercepted=e.intercepted,this._isLoaded=!0,this._bidi=e.bidi)})}get url(){return this._url}get intercepted(){return this._intercepted}get isLoaded(){return this._isLoaded}get loadingPromise(){return this._loadingPromise}reverseLigaturesTable(t,e,r){if(!this._bidi)return[];let o=this._bidi;o.getTextGlyphs(e);let n=o.tokenizer.tokens,a=[],s=0,l=r.length===n.length;for(let c=0;c<r.length;c++){let u=r[c].index,p=String.fromCharCode(r[c].unicode),d=n[s];if(f3(u,d)||l)a.push({char:p,index:u,replacements:[d.state.glyphIndex],replacementChars:[d.char]}),s++;else{let f=d.char,h="",m=[d.state.glyphIndex],y=[],b=!1;for(;!b;)s++,h=e.charAt(s),f+=h,m.push(t.charToGlyphIndex(h)),y=t.stringToGlyphs(f),y.length===1&&y[0].index===u&&(b=!0),s>e.length&&(b=!0);a.push({char:p,index:u,replacements:m,replacementChars:Array.from(f)}),s++}}return a}generateShapes(t,e,r){if(!this._isLoaded)return;let o=this.font,n=e.fontSize/this.unitsPerEm,a=e.fontSize*e.lineHeight,s=t.map(v=>this.getTextWidth(v,e)),l=typeof e.width=="string"?Number(r.getVariable(e.width)):e.width,c=typeof e.height=="string"?Number(r.getVariable(e.height)):e.height,u=this.getCharWidth(`
2285
+ `)}return r}};var fd=require("three");var ud=class{constructor(t=1e3*10){this.timeout=t;this.cache=new Map;this.head={data:null,time:0,src:null,next:null,prev:null};this.tail={data:null,time:1/0,src:null,next:null,prev:null};this.hasClean=!1;this.head.next=this.tail,this.tail.prev=this.head}log(...t){}remove(t){let e=this.cache.get(t);e&&(this.dispose(t,e.data),this.cache.delete(t),e.prev.next=e.next,e.next.prev=e.prev)}scheduleCleanup(){this.hasClean||(this.log("scheduled cleanup"),this.hasClean=!0,setTimeout(()=>{this.hasClean=!1,this.log("cleaning");let t=Date.now(),e=this.head.next;for(;e.time<t-this.timeout;)this.dispose(e.src,e.data),this.cache.delete(e.src),e=e.next,e.prev=this.head,this.head.next=e;this.head.next!==this.tail?this.scheduleCleanup():this.log("no more cleanup")},this.timeout+1e3))}has(t){return this.cache.get(t)?.data}load(t){let e=Date.now(),r=this.cache.get(t);return r===void 0?(r={data:this.create(t),src:t,time:e,next:null,prev:null},this.cache.set(t,r)):(r.time=e,r.prev.next=r.next,r.next.prev=r.prev),r.prev=this.tail.prev,r.next=this.tail,this.tail.prev.next=r,this.tail.prev=r,this.scheduleCleanup(),r.data}};var ph=class extends ud{create(t){return URL.createObjectURL(new Blob([t]))}dispose(t,e){URL.revokeObjectURL(e)}},dh;function Fb(i){return typeof i=="string"?i:(dh||(dh=new ph),dh.load(i))}var dd=class{constructor(t,e){this.data=t;this.cache=e;this.refCount=0}deref(){if(this.refCount===0&&!1)throw new Error("ref count -1?");this.refCount-=1,this.refCount===0&&(this.cache.remove(this),this.dispose())}dispose(){if(this.refCount!==0&&!1)throw new Error("ref count is not 0")}},pd=class{constructor(){this.cache=new Map}remove(t){if(this.cache.delete(t.data)===!1&&!1)throw new Error("ref count remove non-exists")}load(t){let e=this.cache.get(t);return e===void 0&&(e=this.create(t),this.cache.set(t,e)),e.refCount+=1,e}};var Cs=class extends dd{constructor(e,r){super(e,r.imageHolderCache);this.data=e;this.shared=r;this.loaded=!1;this.isVideo=!1;this.isBuffer=!1;this._cache={[1e3]:{},[1001]:{},[1002]:{}};this.isVideo=e.type==="video",this.isBuffer=e.isWebGLRenderTarget===!0,this.loadPromise=this.updateSrc(this.isBuffer?e:e.data)}async updateSrc(e){if(typeof document>"u")return;this.disposeTextures(),this.loaded=!1;let r=()=>{this.loaded=!0;for(let n of Object.values(this._cache))for(let a of Object.values(n))for(let s of Object.values(a))s&&(s.image=this.img,s.needsUpdate=!0);this.shared.requestRender()};if(this.isBuffer)this.img=e,this.loaded=!0;else if(this.isVideo){if(this.img=document.createElement("video"),this.img.preload="auto",this.img.playsInline=!0,this.img.currentTime=.01,typeof e!="string"){var o=new FileReader;o.readAsDataURL(new Blob([e],{type:"video/mp4"}));let n;await new Promise(a=>{o.onloadend=s=>{n=s.target?.result,a(null)}}),this.img.src=n}else this.img.src=e;this.img.onloadeddata=()=>{r()}}else this.img=new Image,this.img.src=Fb(e),this.img.onload=r,await new Promise(n=>{this.img.onload=()=>{r(),n(null)}})}getTexture(e,r=1008,o=1006){let n=this._cache[e]?.[r]?.[o];if(n)return n;{let a;return this.isBuffer?a=this.img.texture:this.isVideo?a=new fd.VideoTexture(this.img,void 0,e,e):a=new fd.Texture(this.img,void 0,e,e,o,r),this.loaded&&(a.needsUpdate=!0),this._cache[e]===void 0&&(this._cache[e]={}),this._cache[e][r]===void 0&&(this._cache[e][r]={}),this._cache[e][r][o]=a,a}}setNeedsUpdate(e){for(let r of Object.values(this._cache))for(let o of Object.values(r))for(let n of Object.values(o))n&&(n.needsUpdate=e)}disposeTextures(){for(let[e,r]of Object.entries(this._cache))for(let[o,n]of Object.entries(r))for(let[a,s]of Object.entries(n))s?.dispose(),this._cache[e]!==void 0&&this._cache[e][o]!==void 0&&(this._cache[e][o][a]=void 0)}dispose(){super.dispose(),this.disposeTextures()}};var Rr=class extends Cs{};var pt=require("three");function nr(i,t){return t.color(i)}function jb(i,t){switch(i.type){case"fresnel":return XI(i,t);case"gradient":return YI(i,t);case"depth":return KI(i,t);case"normal":return QI(i,t);case"noise":return ZI(i,t);case"rainbow":return JI(i,t);case"toon":return e3(i,t);case"outline":return t3(i,t);case"transmission":return r3(i,t);case"color":return $I(i,t);case"pattern":return o3(i,t)}}function qI(i){return{type:i.type}}function xo(i,t){let{alpha:e,mode:r,isMask:o}=i,n=typeof e=="string"?(Number(t.getVariable(e))??100)/100:e;return{...qI(i),alpha:n,mode:r,isMask:o}}function $I(i,t){return{...xo(i,t),color:nr(i.color,t)}}function XI(i,t){let{bias:e,scale:r,intensity:o,factor:n,color:a}=i;return{...xo(i,t),color:nr(a,t),bias:e,scale:r,intensity:o,factor:n}}function YI(i,t){let{gradientType:e,smooth:r,colors:o,steps:n,angle:a,offset:s,morph:l}=i;return{...xo(i,t),gradientType:e,smooth:r,colors:o.map(c=>new pt.Vector4(c[0],c[1],c[2],c[3])),num:o.length,steps:n,offset:new pt.Vector2(...s),morph:new pt.Vector2(...l),angle:a}}function KI(i,t){let{gradientType:e,near:r,far:o,isVector:n,isWorldSpace:a,origin:s,direction:l,colors:c,steps:u,smooth:p}=i;return{...xo(i,t),gradientType:e,near:r,far:o,isVector:n,isWorldSpace:a,origin:new pt.Vector3(...s),direction:l?new pt.Vector3(...l):new pt.Vector3(1,0,0),colors:c.map(d=>d!==void 0?new pt.Vector4(d[0],d[1],d[2],d[3]):new pt.Vector4(0,0,0,0)),steps:u.slice(0,c.length),smooth:p}}function QI(i,t){let{cnormal:e}=i;return{...xo(i,t),cnormal:new pt.Vector3(e[0],e[1],e[2])}}function ZI(i,t){return{...xo(i,t),scale:i.scale,move:i.move,fA:new pt.Vector2(...i.fA),fB:new pt.Vector2(...i.fB),size:new pt.Vector3(...i.size),distortion:new pt.Vector2(...i.distortion),colorA:nr(i.colorA,t),colorB:nr(i.colorB,t),colorC:nr(i.colorC,t),colorD:nr(i.colorD,t),noiseType:i.noiseType,voronoiStyle:i.voronoiStyle,highCut:i.highCut,lowCut:i.lowCut,smoothness:i.smoothness,seed:i.seed,quality:i.quality}}function JI(i,t){return{...xo(i,t),filmThickness:i.filmThickness,movement:i.movement,wavelengths:new pt.Vector3(...i.wavelengths),noiseStrength:i.noiseStrength,noiseScale:i.noiseScale,offset:new pt.Vector3(...i.offset)}}function e3(i,t){return{...xo(i,t),positioning:i.positioning,colors:i.colors.map(e=>new pt.Vector4(e[0],e[1],e[2],e[3])),num:i.colors.length,steps:i.steps,source:new pt.Vector3(...i.source),isWorldSpace:i.isWorldSpace,noiseStrength:i.noiseStrength,noiseScale:i.noiseScale,shadowColor:nr(i.shadowColor,t),offset:new pt.Vector3(...i.offset)}}function t3(i,t){return{...xo(i,t),outlineColor:nr(i.outlineColor,t),contourColor:nr(i.contourColor,t),outlineWidth:i.outlineWidth,contourWidth:i.contourWidth,outlineThreshold:i.outlineThreshold,contourThreshold:i.contourThreshold,outlineSmoothing:i.outlineSmoothing,contourFrequency:i.contourFrequency,contourDirection:new pt.Vector3(...i.contourDirection),positionalLines:i.positionalLines,compensation:i.compensation}}function r3(i,t){return{...xo(i,t),thickness:i.thickness,ior:i.ior,roughness:i.roughness}}function o3(i,t){return{...xo(i,t),style:i.style,projection:i.projection,axis:i.axis,blending:i.blending,offset:new pt.Vector2(...i.offset),colorA:nr(i.colorA,t),colorB:nr(i.colorB,t),frequency:new pt.Vector2(...i.frequency),size:i.size,variation:i.variation,smoothness:i.smoothness,zigzag:i.zigzag,rotation:i.rotation,vertical:new pt.Vector2(...i.vertical),horizontal:new pt.Vector2(...i.horizontal),sides:i.sides}}var $i=class extends kt{};var hd=require("three");var i3={noise:["noiseType"],texture:["projection","axis","side"],video:["projection","axis","side"],displace:["noiseType"],light:["roughnessMap","bumpMap"],depth:["smooth","isWorldSpace","gradientType","isVector"],pattern:["style","projection","axis"]},n3={depth:["colors"]};function a3(i,t,e){if(t==="isMask")return!0;let r=i3[i.type],o=n3[i.type];if(o!==void 0){let n=i.color;if(o.includes(t)){let a=n[t]?.value?.length;if(a!==void 0&&a!==e.length)return!0}}return r!==void 0?r.includes(t):!1}function fh(i,t,e){let r=e.uniforms[`f${e.id}_texture`];if(!r)return!1;let o=!1,n=i;if("image"in n){let a=n.image,s=t.image(a),l=r;l.image instanceof Rr||l.image.deref(),l.image=s}if("video"in n){let a=n.video,s=t.video(a),l=r;l.image instanceof Rr||l.image.deref(),l.image=s}if("wrapping"in n){let a=r;a.wrap=n.wrapping}if("minFilter"in n){let a=r;a.minFilter=n.minFilter}if("magFilter"in n){let a=r;a.magFilter=n.magFilter}if("rotation"in n&&e.uniforms[`f${e.id}_rotation`])return e.uniforms[`f${e.id}_rotation`].value=(n.rotation??0)*hd.MathUtils.DEG2RAD,o;if("repeat"in n||"offset"in n||"rotation"in n){let a="mat",s=e.uniforms[`f${e.id}_${a}`];"repeat"in n&&(s.repeat=n.repeat),"offset"in n&&(s.offset=n.offset),"rotation"in n&&(s.rotation=n.rotation??0),s.updateMatrix()}return o}function Ub(i,t,e,r){let o=!1;for(let[n,a]of Object.entries(i)){if(n==="bumpMap"||n==="roughnessMap"){o=!0;continue}if(!n||a===void 0)continue;if(hh(n,e,r,t)){n==="visible"&&e.type==="light"&&(o=!0);continue}e.visible=r.visible;let s=e.uniforms[`f${e.id}_${n}`];if(!!s&&!(s instanceof Wi))switch(o=o||a3(e,n,a),s.constructor){case et:if(typeof a=="string"){let l=t.getColor(a);l&&(s.value=l);break}else{let l=a;s.value instanceof $i?s.value=new kt(l.r,l.g,l.b,l.a):s.setRGBA(l);break}case Pr:if(typeof a=="string"){let l=t.getColor(a);l&&(s.value=l);break}else{let l=a;s.value instanceof $i?s.value=new kt(l.r,l.g,l.b,l.a):s.value.setRGBA(l.r,l.g,l.b,l.a);break}case wt:{let l=a;s.value.setX(l[0]),s.value.setY(l[1]);break}case or:{let l=a;s.value.setX(l[0]),s.value.setY(l[1]),s.value.setZ(l[2]);break}case mr:{fh(a,t,e);break}case go:{s.value=a.map(l=>new hd.Vector4(...l));break}default:{s.value=a;break}}}return o}var Xi=(i,t,e)=>Math.max(0,Math.min(1,Number(t.getVariable(typeof i=="number"?i*100:i,e)??100)/100))??1,Yi=class{constructor(t,e,r,o,n){this.id=t;this.uuid=e;this.data=r;this.uniforms={};for(let a in o)this.uniforms[`f${this.id}_${a}`]=o[a];for(let a in r)hh(a,this,r,n)}get type(){return this.data.type}static create(t,e,r,o){if(r.type==="light")return yr.createLightLayer(t,e,r,o);if(r.type==="texture"||r.type==="video"){let n=r.type==="texture"?o.uiBuffer(r.texture.image)??o.image(r.texture.image):o.video(r.texture.video),a=new _n(n,r.texture.wrapping,r.texture.minFilter??1008,r.texture.magFilter??1006),s=new sd(n),l=new ld(r.texture.repeat,r.texture.offset,r.texture.rotation??0),c=new se(r.crop?1:0),u=new Fe(r.projection??0),p=new Fe(["x","y","z"].indexOf(r.axis)??0),d=new Fe(r.side??0),f=new wt(r.size?new Ze.Vector2(r.size[0],r.size[1]):new Ze.Vector2(100,100)),h=new se(r.blending??0),m=new se(Xi(r.alpha,o)),y=new Fe(r.mode??0),b=new Pt(r.isMask??!1),v=new qi(a,s,c,u,p,d,f,h,l,m,y,b),w=new Ke(v.calpha,"f");return new yt(t,e,r,{texture:a,textureSize:s,crop:c,projection:u,axis:p,side:d,size:f,blending:h,mat:l,alpha:m,mode:y,isMask:b},v,y,w,b,o)}else if(r.type==="matcap"){let n=o.image(r.texture.image),a=new _n(n,r.texture.wrapping,r.texture.minFilter??1008,r.texture.magFilter??1006),s=new se(Xi(r.alpha,o)),l=new Fe(r.mode??0),c=new Pt(r.isMask??!1),u=new se((r.texture.rotation??0)*Ze.MathUtils.DEG2RAD),p=new gs(a,s,l,c,u),d=new Ke(p.calpha,"f");return new yt(t,e,r,{texture:a,alpha:s,mode:l,isMask:c,rotation:u},p,l,d,c,o)}else if(r.type==="displace")if(r.displacementType==="noise"){let n=new or(new Ze.Vector3(...r.offset)),a=new se(r.scale??10),s=new se(r.intensity??8),l=new se(r.movement??1),c=new Fe(r.noiseType??0),u=new Fe(r.voronoiStyle??0),p=new se(r.smoothness??.5),d=new se(r.seed??0),f=new se(r.highCut??1),h=new se(r.lowCut??0),m=new Fe(r.quality??1),y=new Os(s,l,n,u,p,d,f,h,m,a,c);return new $l(t,e,r,{offset:n,scale:a,intensity:s,movement:l,noiseType:c,voronoiStyle:u,smoothness:p,seed:d,highCut:f,lowCut:h,quality:m},y,o)}else throw new Error;else return c3(t,e,r,o)}updateByOp(t,e,r){let o=t;if(o.path[0]===void 0){if(o.type===0)return"type"in o.props||"category"in o.props||"visible"in o.props||"noiseType"in o.props?(r.scene.markNeedsUpdateRendererDirty(),!0):Ub(o.props,r.shared,this,e)}else if(o.path[0]==="texture")return"texture"in e||"video"in e?fh(o.props,r.shared,this):!0;return!1}dispose(){if(s3(this)){let t=this.uniforms[`f${this.id}_texture`];if(!t)return!1;let e=t;e.image instanceof Rr||e.image.deref()}}hasValueByKey(t){return this.uniforms[t]!==void 0}hasValue(t){return this.hasValueByKey(`f${this.id}_${t}`)}setValue(t,e){let r=`f${this.id}_${t}`;this.hasValueByKey(r)&&e!==void 0&&(this.uniforms[r].value=e)}getNode(t){let e=`f${this.id}_${t}`;if(this.hasValueByKey(e))return this.uniforms[e]}getValue(t){let e=`f${this.id}_${t}`;if(this.hasValueByKey(e))return this.uniforms[e].value}getName(t){let r=/f\d+_(.*)/.exec(t);if(r&&r.length>1)return r[1];console.log(`Layer.getName: error ${t}`)}getNames(){let t=[];for(let e in this.uniforms){let r=this.getName(e);r&&t.push(r)}return t}},yt=class extends Yi{constructor(e,r,o,n,a,s,l,c,u){super(e,r,o,n,u);this.params=n;this.color=a;this.mode=s;this.alpha=l;this.isMask=c}},$l=class extends Yi{constructor(e,r,o,n,a,s){super(e,r,o,n,s);this.position=a}},yr=class extends Yi{constructor(e,r,o,n,a,s){super(e,r,o,a,s);this.node=n}static createLightLayer(e,r,o,n){let a,s=new se(Xi(o.alpha,n)),l=new Fe(o.mode),c=new se(o.bumpMapIntensity),u=new se(Xi(o.alphaOverride,n)),p;if(!o.visible)a=new pi,p={};else if(o.category==="lambert"){a=new jl;let d=new et(n.color(o.emissive)??0),f=new Pt(o.occlusion??!0);p={emissive:d,occlusion:f},a.emissive=d,a.occlusion=f}else if(o.category==="toon"){a=new ql;let d=new se(o.shininess??30),f=new et(n.color(o.specular)??1118481);p={shininess:d,specular:f},a.shininess=d,a.specular=f}else if(o.category==="physical"){a=new Hl;let d=new se(o.roughness??.3),f=new se(o.metalness??0),h=new se(o.reflectivity??.5),m=new Pt(o.occlusion??!0);p={roughness:d,metalness:f,reflectivity:h,occlusion:m},a.roughness=d,a.metalness=f,a.reflectivity=h,a.occlusion=m}else{a=new kl;let d=new se(o.shininess??30),f=new et(o.specular!==void 0?n.color(o.specular)??1118481:1118481),h=new Pt(o.occlusion??!0);p={shininess:d,specular:f,occlusion:h},a.shininess=d,a.specular=f,a.occlusion=h}return a.alpha=new se(1),a.shadingAlpha=s,a.shadingBlend=l,a.bumpMapIntensity=c,a.alphaOverride=u,p.alpha=a.shadingAlpha,p.mode=a.shadingBlend,p.bumpMapIntensity=a.bumpMapIntensity,p.alphaOverride=a.alphaOverride,new yr(e,r,o,a,p,n)}get category(){return this.node.category}};function s3(i){let t=i instanceof Yi?i.type:i;return t==="texture"||t==="video"||t==="displace_map"||t==="matcap"}function qr(i){return{alpha:new se(i.alpha??1),mode:new Fe(i.mode??0),isMask:new Pt(i.isMask??!1)}}function l3(i,t,e,r,o){switch(i.type){case"color":{let n=new et(r.color??Dt),a=qr(r),s=new Rn(n,a.alpha),l=new Ke(s.calpha,"f");return new yt(t,e,i,{color:n,...a},s,a.mode,l,a.isMask,o)}case"fresnel":{let n=new et(r.color??16777215),a=new se(r.bias??.1),s=new se(r.scale??1),l=new se(r.intensity??2),c=new se(r.factor??1),u=qr(r),p=new Gl(n,a,s,l,c,u.alpha,u.mode,u.isMask),d=new Ke(p.calpha,"f");return new yt(t,e,i,{color:n,bias:a,scale:s,intensity:l,factor:c,...u},p,u.mode,d,u.isMask,o)}case"rainbow":{let n=new se(r.filmThickness??30),a=new se(r.movement??0),s=new or(r.wavelengths??new Ze.Vector3(0,0,0)),l=new se(r.noiseStrength??0),c=new se(r.noiseScale??1),u=new or(r.offset??new Ze.Vector3(0,0,0)),p=qr(r),d=new Ss(n,a,s,l,c,u,p.alpha,p.isMask),f=new Ke(d.calpha,"f");return new yt(t,e,i,{filmThickness:n,movement:a,wavelengths:s,noiseStrength:l,noiseScale:c,offset:u,...p},d,p.mode,f,p.isMask,o)}case"transmission":{let n=new se(r.thickness??10),a=new se(r.ior??1.5),s=new se(r.roughness??.5),l=De.transmissionSize,c=De.transmissionRenderTarget,u=De.transmissionRenderTargetDepth,p=window.innerWidth,d=window.innerHeight,f=p>=d?new wt(d/p,1):new wt(1,p/d),h=qr(r),m=new Ps(n,a,s,l,c,u,f,h.alpha),y=new Ke(m.calpha,"f");return new yt(t,e,i,{thickness:n,ior:a,roughness:s,aspectRatio:f,...h},m,h.mode,y,h.isMask,o)}case"toon":{let n=new Fe(r.positioning??0),a;r.colors?a=new go(r.colors.length,r.colors):(a=new go(10,new Ze.Vector4(0,0,0,1)),a.value[1]=new Ze.Vector4(1,1,1,1));let s;r.steps?s=new yo(r.steps.length,r.steps):(s=new yo(10,1),s.value[0]=0);let l=new or(r.source??new Ze.Vector3(0,0,0)),c=new Pt(r.isWorldSpace??!0),u=new se(r.noiseStrength??0),p=new se(r.noiseScale??1),d=new Pr(r.shadowColor),f=new or(r.offset??new Ze.Vector3(0,0,0)),h=qr(r),m=new ws(n,a,s,l,c,u,p,d,f,h.alpha),y=new Ke(m.calpha,"f");return new yt(t,e,i,{positioning:n,colors:a,steps:s,source:l,isWorldSpace:c,noiseStrength:u,noiseScale:p,shadowColor:d,offset:f,...h},m,h.mode,y,h.isMask,o)}case"outline":{let n=new et(r.outlineColor??16777215),a=new et(r.contourColor??16777215),s=new se(r.outlineWidth??.1),l=new se(r.contourWidth??.1),c=new se(r.outlineThreshold??.1),u=new se(r.contourThreshold??.1),p=new se(r.outlineSmoothing??.1),d=new se(r.contourFrequency??.1),f=new or(r.contourDirection??new Ze.Vector3(0,1,0)),h=new Pt(r.positionalLines??!1),m=new Pt(r.compensation??!0),y=De.normalRenderTarget,b=De.normalRenderTargetDepth,v=De.pixelRatioNode,w=De.resolution,O=qr(r),S=new bs(n,a,s,l,c,u,p,d,f,h,m,w,y,b,v,O.alpha),T=new Ke(S.calpha,"f");return new yt(t,e,i,{outlineColor:n,contourColor:a,outlineWidth:s,contourWidth:l,outlineThreshold:c,contourThreshold:u,outlineSmoothing:p,contourFrequency:d,contourDirection:f,positionalLines:h,compensation:m,...O},S,O.mode,T,O.isMask,o)}case"depth":{let n=new Fe(r.gradientType??0),a=new Pt(r.smooth??!1),s=new se(r.near??50),l=new se(r.far??200),c=new se(r.isVector??1),u=new se(r.isWorldSpace??0),p=new or(r.origin??new Ze.Vector3),d=new or(r.direction??new Ze.Vector3),f;r.colors?f=new go(r.colors.length,r.colors):(f=new go(2,new Ze.Vector4(0,0,0,1)),f.value[1]=new Ze.Vector4(1,1,1,1));let h;r.steps?h=new yo(r.steps.length,r.steps):(h=new yo(2,1),h.value[0]=0);let m=qr(r),y=new ms(n,a,s,l,c,u,p,d,f,h,m.alpha,m.isMask),b=new Ke(y.calpha,"f");return new yt(t,e,i,{gradientType:n,smooth:a,near:s,far:l,isVector:c,isWorldSpace:u,origin:p,direction:d,colors:f,steps:h,...m},y,m.mode,b,m.isMask,o)}case"noise":{let n=new se(r.scale??1),a=new or(r.size??new Ze.Vector3(100,100,100)),s=new se(r.move??1),l=new wt(r.fA??new Ze.Vector2(1.7,9.2)),c=new wt(r.fB??new Ze.Vector2(8.3,2.8)),u=new wt(r.distortion??new Ze.Vector2(1,1)),p=new Pr(r.colorA),d=new Pr(r.colorB),f=new Pr(r.colorC),h=new Pr(r.colorD),m=new Fe(r.noiseType??0),y=new Fe(r.voronoiStyle??0),b=new se(r.highCut??1),v=new se(r.lowCut??0),w=new se(r.smoothness??.5),O=new se(r.seed??.5),S=new Fe(r.quality??1),T=qr(r),M=new xs(n,a,s,l,c,u,p,d,f,h,T.alpha,m,T.isMask,y,b,v,w,O,S),g=new Ke(M.calpha,"f");return new yt(t,e,i,{scale:n,size:a,move:s,fA:l,fB:c,distortion:u,colorA:p,colorB:d,colorC:f,colorD:h,noiseType:m,...T,voronoiStyle:y,highCut:b,lowCut:v,smoothness:w,seed:O,quality:S},M,T.mode,g,T.isMask,o)}case"normal":{let n=new or(r.cnormal??new Ze.Vector3(1,1,1)),a=qr(r),s=new ps(n,a.alpha),l=new Ke(s.calpha,"f");return new yt(t,e,i,{cnormal:n,...a},s,a.mode,l,a.isMask,o)}case"gradient":{let n=new Fe(r.gradientType??0),a=new Pt(r.smooth??!1),s;r.colors?s=new go(r.colors.length,r.colors):(s=new go(10,new Ze.Vector4(0,0,0,1)),s.value[1]=new Ze.Vector4(1,1,1,1));let l;r.steps?l=new yo(r.steps.length,r.steps):(l=new yo(10,1),l.value[0]=0);let c=new wt(r.offset??new Ze.Vector2(0,0)),u=new wt(r.morph??new Ze.Vector2(0,0)),p=new se(r.angle??0),d=qr(r),f=new ys(n,a,s,l,c,u,p,d.alpha,d.isMask),h=new Ke(f.calpha,"f");return new yt(t,e,i,{gradientType:n,smooth:a,colors:s,steps:l,offset:c,morph:u,angle:p,...d},f,d.mode,h,d.isMask,o)}case"pattern":{let n=new Fe(r.style??0),a=new Fe(r.projection??0),s=new Fe(["x","y","z"].indexOf(r.axis)??0),l=new se(r.blending??0),c=new wt(r.offset??new Ze.Vector2(0,0)),u=new Pr(r.colorA),p=new Pr(r.colorB),d=new wt(r.frequency??new Ze.Vector2(10,10)),f=new se(r.size??.5),h=new se(r.variation??0),m=new se(r.smoothness??.5),y=new se(r.zigzag??0),b=new se(r.rotation??0),v=new wt(r.vertical??new Ze.Vector2(0,1)),w=new wt(r.horizontal??new Ze.Vector2(0,1)),O=new Fe(r.sides??6),S=qr(r),T=new vs(n,a,s,l,c,u,p,d,f,h,m,y,b,v,w,O,S.alpha,S.isMask),M=new Ke(T.calpha,"f");return new yt(t,e,i,{style:n,projection:a,axis:s,blending:l,offset:c,colorA:u,colorB:p,frequency:d,size:f,variation:h,smoothness:m,zigzag:y,rotation:b,vertical:v,horizontal:w,sides:O,...S},T,S.mode,M,S.isMask,o)}default:{let n=new et(1,0,0,1),a=qr(r),s=new Rn(n,a.alpha),l=new Ke(s.calpha,"f");return new yt(t,e,i,{color:n,...a},s,a.mode,l,a.isMask,o)}}}function c3(i,t,e,r){let o=jb(e,r);return l3(e,i,t,o,r)}function hh(i,t,e,r){if(e.type==="displace"&&(i==="intensity"||i==="visible")){let o=t.uniforms[`f${t.id}_intensity`];return o?(o.value=e.intensity*(e.visible?1:0),o):void 0}if(e.type!=="displace"&&(i==="alpha"||i==="visible")){let o=t.uniforms[`f${t.id}_alpha`];if(!o)return;if(o.value=Xi(e.alpha,r)*(e.visible?1:0),e.type==="outline"&&i==="visible"){let n=t.uniforms[`f${t.id}_compensation`];n&&(n.value=e.compensation&&e.visible)}return o}}function md(i,t){let e=0,r=i.layers.find(o=>o.data.type==="light");if(r){let o=r.data,n=Number(t.getVariable(o.alphaOverride));if((typeof o.alphaOverride=="string"?n/100:o.alphaOverride)<1)return!0}for(let o of i.layers){if(o.data.type!=="displace"&&o.data.isMask)return!0;if(o.data.type!=="displace"&&"alpha"in o.data&&o.data.type!=="light"&&o.data.type!=="fresnel"&&o.data.type!=="texture"&&o.data.type!=="matcap"&&o.data.type!=="rainbow"&&o.data.type!=="outline"&&o.data.type!=="pattern"){let n=o.data.visible?o.data.alpha:0;if(typeof n=="string"&&(n=Math.max(0,Math.min(1,Number(t.getVariable(n)??100)/100))),n===1&&o.data.type==="depth"||o.data.type==="gradient"){for(let a of o.data.colors)if(a[3]<1){n=a[3];break}}else if(n===1&&o.data.type==="noise"){let a=t.color(o.data.colorA).a,s=t.color(o.data.colorB).a,l=t.color(o.data.colorC).a,c=t.color(o.data.colorD).a,u=Math.min(a,Math.min(s,Math.min(l,c)));u<1&&(n=u)}e+=(1-e)*n}}return e<1}var Tr=class extends kb.ShaderMaterial{constructor(){super(void 0);this.flatShading=!1;this.needsJitter=!0;this.shadersPatchedForShapeBlend=!1;this.nodeContextUuid=0;this.fog=!0,this.dithering=!0,this.vertexColors=!0,this.transparent=!0}customProgramCacheKey(){return""}},yd=class extends Tr{constructor(e,r,o,n){super();this.flatShading=e;this.side=r;this.wireframe=o;this.root=n}updateAfterBuild(){let e=this.root;this.lights=e.lights,this.vertexShader=e.vertexShader,this.fragmentShader=e.fragmentShader,Object.assign(this.defines,e.defines),Object.assign(this.uniforms,e.uniforms),this.extensions=e.extensions,this.transparent=e.transparent,this.cacheKey=e.customProgramCacheKey()+"flat"+this.flatShading+this.side}onBeforeCompile(e,r){this.root.onBeforeCompile(e)}get data(){return this.root.data}get category(){return this.root.category}get hasAO(){return this.root.hasAO}getFlavor(e,r,o,n){return this.root.getFlavor(e,r,o,n)}get layers(){return this.root.layers}get fragment(){return this.root.fragment}getLayersOfType(e){return this.root.getLayersOfType(e)}getLayerByUuid(e){return this.root.getLayerByUuid(e)}updateByOp(e,r,o){this.root.updateByOp(e,r,o)}nodeMaterialDispose(){this.root.nodeMaterialDispose()}},Bn=class extends Tr{constructor(e,r,o=!0){super();this.data=e;this.allowVariableSaves=o;this.layerIdGen=0;this.flavors=[];this.masks={};this.type="NodeMaterial";this.updaters=[],this.needsJitter=r.shared.needsJitter,ot.startContext(this),this.reset0(e,r),ot.endContext(this)}get nodeMaterial(){return this}getFlavor(e,r,o,n){let a=o?6:(e?3:0)+r;if(a+=((n?.resolutionLevel??0)-(n?.useChildrenColors?4:0))*7,a===0)return this;this.flavors===void 0&&(this.flavors=[]),a-=1;let s=this.flavors[a];return s===void 0&&(s=new yd(e,r,o,this),s.needsJitter=this.needsJitter,this.flavors[a]=s,s.flatShading=e,s.side=r,s.updateAfterBuild(),n&&(s.defines.SHAPEBLEND=n.resolutionLevel,s.defines.SHAPEBLEND_C=n.useChildrenColors?1:0)),s}get fragment(){return this.lightLayer.node}get category(){return this.lightLayer.category}get hasAO(){return this.lightLayer.getNode("occlusion")?.value??!1}reset(e,r,o=!1){ot.startContext(this),(this.data!==e||o)&&this.reset0(e,r),ot.endContext(this)}reset0(e,r){this.data=e;let o=e.layers??Ut.defaultTwoLayerData("phong").layers;try{this.layers=o.map(n=>Yi.create(this.layerIdGen++,n.id,n.data,r.shared))}catch{this.layers=[]}this.layers.reverse(),this.name=e.name??"Untitled Material",this.onUpdate(r.shared),this.transparent=md(e,r.shared),this.saveVariableLocations(r)}onVariableUpdate(e,r,o){if(e[0]==="alphaOverride")this.transparent=md(this.data,o.shared),this.lightLayer.setValue("alphaOverride",Math.max(0,Math.min(Number(r)/100,1)));else if(e[0]==="layer"){let n=e[1],a=e[2];if(n&&a){let s=this.layers.find(l=>l.uuid===n);s?.hasValue(a)&&(a==="alpha"?(this.transparent=md(this.data,o.shared),s.setValue(a,Math.max(0,Math.min(Number(r)/100,1)))):s.setValue(a,r))}}}saveVariableLocations(e){if(!this.allowVariableSaves)return;let r=this.data.layers.find(o=>o.data.type==="light");r&&e.shared.getVariable(r.data.alphaOverride,["material",this.uuid,"alphaOverride"]),this.data.layers.forEach(o=>{"alpha"in o.data&&typeof o.data.alpha=="string"&&e.shared.getVariable(o.data.alpha,["material",this.uuid,"layer",o.id,"alpha"])})}getLayersOfType(e){return this.layers.filter(r=>r.type===e)}getLayerByUuid(e){return this.layers.find(r=>r.uuid===e)}onUpdate(e){this.lightLayer=this.layers.find(r=>r instanceof yr),this.lightLayer===void 0&&(this.lightLayer=new yr(0,"",{...Vt.defaultData("light","phong"),visible:!1},new pi,{},e)),this.dispose();for(let r of this.flavors)r&&r.dispose();this.applyTextureMaps(),this.applyMasks(),this.blendColors(),this.blendAfterColors(),this.blendPositions(),this.build(),this.nodeContextUuid=0}applyTextureMaps(){let e=this.layers.find(a=>a instanceof yr);if(!e)return;let r=e.data,o=r.bumpMap,n=r.roughnessMap;e.node.bumpMap=void 0,e.node.roughnessMap=void 0;for(let a=0;a<this.layers.length;++a){let s=this.layers[a];s instanceof yt&&s.color instanceof qi&&(s.uuid===o&&(e.node.bumpMap=s.color),s.uuid===n&&(e.node.roughnessMap=s.color))}}updateByOp(e,r,o){if(ot.startContext(this),r!==void 0?this.data=r:r=this.data,this.transparent=md(r,o.shared),e.path[0]==="layers"){let n=o.shared,a=e.path[1];if(a===void 0)o.scene.markNeedsUpdateRendererDirty(),this.reset0(r,o);else{e.type===0&&e.props.occlusion!==void 0&&o.scene.markNeedsUpdateRendererDirty();let s=this.layers.find(l=>l.uuid===a);if(s){let l=r.layers.data(a),c;e.type===0&&("alpha"in e.props||"alphaOverride"in e.props)&&("alpha"in e.props?c={...e.props,alpha:Xi(e.props.alpha,n,["material",this.uuid,"layer",a,"alpha"])}:c={...e.props,alphaOverride:Xi(e.props.alphaOverride,n,["material",this.uuid,"alphaOverride"])}),s.updateByOp({...e,...c?{props:c}:{},path:e.path.slice(2)},l,o)&&this.reset0(r,o)}}}else this.reset0(r,o);ot.endContext(this)}applyMasks(){for(let e=0;e<this.layers.length;++e){let r=this.layers[e];r instanceof yt?r.color.mask=void 0:r instanceof yr&&(r.node.mask=void 0)}for(let e=0;e<this.layers.length;++e){let r=this.layers[e];if(r instanceof yt&&r.isMask.value&&r.data.visible&&e>0){let o=e-1,n=this.layers[o];n instanceof yr?n.node.mask=new Zt(r.color,r.alpha,Zt.MUL):n instanceof yt&&(n.isMask.value||(n.color.mask=new Zt(r.color,r.alpha,Zt.MUL)))}}}blendColors(){let e=this.layers.findIndex(o=>o instanceof yt),r=this.layers.findIndex(o=>o instanceof yr);if(e!==-1&&e<r){let o=this.layers[e].color;for(let n=e+1;n<r;++n){let a=this.layers[n];if(a instanceof yt){if(a.isMask.value)continue;o=new ds(o,a.color,a.alpha,a.mode)}}this.fragment.color=o}else this.fragment.color=void 0}blendAfterColors(){let e=new Ke("outgoingLight","f"),r=this.layers.findIndex(o=>o instanceof yr);if(this.layers.length>r+1){for(let o=r+1;o<this.layers.length;++o){let n=this.layers[o];if(n instanceof yt){if(n.isMask.value)continue;e=new ds(e,n.color,n.alpha,n.mode)}}this.fragment.afterColor=e}else this.fragment.afterColor=void 0}blendPositions(){let e=this.layers.filter(r=>r instanceof $l);if(e.length>0){let r=e[0].position;for(let o=1;o<e.length;++o)e[o]&&(r=new Zt(r,e[o].position,Zt.ADD),r=new Zt(r,new se(.5).setReadonly(!0),Zt.MUL));this.fragment.position=r}else this.fragment.position=void 0}getDefines(){return this.defines}getUniforms(){return this.uniforms}getVertexShader(){return this.vertexShader}getFragmentShader(){return this.fragmentShader}onBeforeCompile(e){this.shapeBlendhack&&this.shapeBlendhack(this),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}clampUniformsForPreview(e,r){let o=(n,a,s)=>Math.min(Math.max(n,a),s);for(let n of this.layers)if(n.type==="displace"){let a=o(n.uniforms[`f${n.id}_intensity`].value,e,r);n.uniforms[`f${n.id}_intensity`].value=a}}updateFrame(e){for(let r=0;r<this.updaters.length;++r)e.updateNode(this.updaters[r])}build(){let e=new cs;e.needsJitter=this.needsJitter,this.lights=this.lightLayer.data.visible,e.build(this.fragment,this.fragment),this.vertexShader=e.getCode("vertex"),this.fragmentShader=e.getCode("fragment"),this.defines=e.defines,this.uniforms=e.uniforms,this.extensions=e.extensions,this.updaters=e.updaters;for(let r of this.flavors)r&&r.updateAfterBuild();return this.shadersPatchedForShapeBlend=!1,this}nodeMaterialDispose(){this.layers.forEach(e=>e.dispose()),super.dispose();for(let e of this.flavors)e&&e.dispose()}assetsLoaded(){for(let e of this.layers)if(e instanceof yt){let r=e.params.texture;if(r instanceof _n&&!r.image.loaded)return!1}return!0}};Object.defineProperties(Tr.prototype,{properties:{get:function(){return this.fragment.properties}}});var Vn=class extends Bn{constructor(t,e,r){super(t,e,!1),this.uuid=r,this.allowVariableSaves=!0,this.saveVariableLocations(e)}};var Hb=new Map;function Wb(i){if(typeof i=="string")return i;let t=Hb.get(i);return t||(t={url:URL.createObjectURL(new Blob([i]))},Hb.set(i,t)),t.url}var u3,qb=new Promise(i=>{u3=i});var $b;qb.then(i=>$b=i);var zn=class{constructor({src:t,volume:e,delay:r,loop:o}){this._volume=1;this.delay=0;this._loop=1;this.loopsRemaining=0;this._status="stopped";this.onEnd=()=>{this.loopsRemaining===1/0?this.replay():this.loopsRemaining>1?(this.replay(),this.loopsRemaining--):(this._status="stopped",this.loopsRemaining=this._loop)};let n;typeof t=="string"?n={src:t}:n={src:Wb(t),format:"wav"},this.sound=new $b.Howl(n),this.sound.on("end",this.onEnd),this.src=t,e!==void 0&&(this.volume=e),r!==void 0&&(this.delay=r),o!==void 0&&(this.loop=o)}get status(){return this._status}get volume(){return this._volume}set volume(t){this._volume=t,this.sound.volume(t)}get loop(){return this._loop}set loop(t){this._loop=t,this.loopsRemaining=t}replay(){this.clearDelay(),this.delayTimerId=window.setTimeout(()=>{this.sound.play(),this.clearDelay()},this.delay)}fade(t,e=1e3){t?(this.sound.volume(this._volume),this.clearFade(),this.fadeTimerId=window.setTimeout(()=>{this.sound.fade(this._volume,0,e),this.clearFade()},t)):this.sound.fade(this._volume,0,e)}on(t,e,r){this.sound.on(t,e,r)}off(t,e,r){this.sound.off(t,e,r)}play(){this._status==="playing"||this.sound.playing()||(this._status==="paused"?(this.sound.seek()===0?this.replay():this.sound.play(),this._status="playing"):this._status==="stopped"&&(this.replay(),this._status="playing"))}pause(){this._status==="playing"&&(this.sound.pause(),this.clearFade(),this.clearDelay(),this._status="paused")}stop(){this.sound.stop(),this.loopsRemaining=this._loop,this.clearFade(),this.clearDelay(),this._status="stopped"}clearFade(){this.fadeTimerId&&(clearTimeout(this.fadeTimerId),delete this.fadeTimerId)}clearDelay(){this.delayTimerId&&(clearTimeout(this.delayTimerId),delete this.delayTimerId)}dispose(t=!1){this.off(),this.stop(),this.clearFade(),this.clearDelay()}};var $t=require("three"),gd=class{constructor(){this.type="ShapePath";this.color=new $t.Color;this.subPaths=[];this.currentPath=null}moveTo(t,e){return this.currentPath=new $t.Path,this.subPaths.push(this.currentPath),this.currentPath.moveTo(t,e),this}lineTo(t,e){return this.currentPath?.lineTo(t,e),this}quadraticCurveTo(t,e,r,o){return this.currentPath?.quadraticCurveTo(t,e,r,o),this}bezierCurveTo(t,e,r,o,n,a){return this.currentPath?.bezierCurveTo(t,e,r,o,n,a),this}splineThru(t){return this.currentPath?.splineThru(t),this}toShapes(){let e={ORIGIN:0,DESTINATION:1,BETWEEN:2,LEFT:3,RIGHT:4,BEHIND:5,BEYOND:6},r={loc:e.ORIGIN,t:0};function o(m,y,b,v){let w=m.x,O=y.x,S=b.x,T=v.x,M=m.y,g=y.y,D=b.y,E=v.y,I=(T-S)*(M-D)-(E-D)*(w-S),N=(O-w)*(M-D)-(g-M)*(w-S),_=(E-D)*(O-w)-(T-S)*(g-M),R=I/_,V=N/_;if(_===0&&I!==0||R<=0||R>=1||V<0||V>1)return null;if(I===0&&_===0){for(let U=0;U<2;U++)if(n(U===0?b:v,m,y),r.loc===e.ORIGIN){let B=U===0?b:v;return{x:B.x,y:B.y,t:r.t}}else if(r.loc===e.BETWEEN){let B=+(w+r.t*(O-w)).toPrecision(10),q=+(M+r.t*(g-M)).toPrecision(10);return{x:B,y:q,t:r.t}}return null}else{for(let q=0;q<2;q++)if(n(q===0?b:v,m,y),r.loc===e.ORIGIN){let j=q===0?b:v;return{x:j.x,y:j.y,t:r.t}}let U=+(w+R*(O-w)).toPrecision(10),B=+(M+R*(g-M)).toPrecision(10);return{x:U,y:B,t:R}}}function n(m,y,b){let v=b.x-y.x,w=b.y-y.y,O=m.x-y.x,S=m.y-y.y,T=v*S-O*w;if(m.x===y.x&&m.y===y.y){r.loc=e.ORIGIN,r.t=0;return}if(m.x===b.x&&m.y===b.y){r.loc=e.DESTINATION,r.t=1;return}if(T<-Number.EPSILON){r.loc=e.LEFT;return}if(T>Number.EPSILON){r.loc=e.RIGHT;return}if(v*O<0||w*S<0){r.loc=e.BEHIND;return}if(Math.sqrt(v*v+w*w)<Math.sqrt(O*O+S*S)){r.loc=e.BEYOND;return}let M;v!==0?M=O/v:M=S/w,r.loc=e.BETWEEN,r.t=M}function a(m,y){let b=[],v=[];for(let w=1;w<m.length;w++){let O=m[w-1],S=m[w];for(let T=1;T<y.length;T++){let M=y[T-1],g=y[T],D=o(O,S,M,g);D!==null&&b.find(E=>E.t<=D.t+Number.EPSILON&&E.t>=D.t-Number.EPSILON)===void 0&&(b.push(D),v.push(new $t.Vector2(D.x,D.y)))}}return v}function s(m,y,b){let v=new $t.Vector2;y.getCenter(v);let w=[];return b.forEach(O=>{O.boundingBox.containsPoint(v)&&a(m,O.points).forEach(T=>{w.push({identifier:O.identifier,isCW:O.isCW,point:T})})}),w.sort((O,S)=>O.point.x-S.point.x),w}function l(m,y,b,v,w){(w==null||w==="")&&(w="nonzero");let O=new $t.Vector2;m.boundingBox.getCenter(O);let S=[new $t.Vector2(b,O.y),new $t.Vector2(v,O.y)],T=s(S,m.boundingBox,y);T.sort((N,_)=>N.point.x-_.point.x);let M=[],g=[];T.forEach(N=>{N.identifier===m.identifier?M.push(N):g.push(N)});let D=M[0].point.x,E=[],I=0;for(;I<g.length&&g[I].point.x<D;)E.length>0&&E[E.length-1]===g[I].identifier?E.pop():E.push(g[I].identifier),I++;if(E.push(m.identifier),w==="evenodd"){let N=E.length%2===0,_=E[E.length-2];return{identifier:m.identifier,isHole:N,for:_}}else if(w==="nonzero"){let N=!0,_=null,R=null;for(let V=0;V<E.length;V++){let U=E[V];y[U]&&(N?(R=y[U].isCW,N=!1,_=U):R!==y[U].isCW&&(R=y[U].isCW,N=!0))}return{identifier:m.identifier,isHole:N,for:_}}else console.warn('fill-rule: "'+w+'" is currently not implemented.')}let c=0,u=999999999,p=-999999999,d=[];this.subPaths.forEach(m=>{let y=m.getPoints(),b=-999999999,v=999999999,w=-999999999,O=999999999;for(let S=0;S<y.length;S++){let T=y[S];T.y>b&&(b=T.y),T.y<v&&(v=T.y),T.x>w&&(w=T.x),T.x<O&&(O=T.x)}p<=w&&(p=w+1),u>=O&&(u=O-1),y.length&&d.push({curves:m.curves,points:y,isCW:$t.ShapeUtils.isClockWise(y),identifier:c++,boundingBox:new $t.Box2(new $t.Vector2(O,v),new $t.Vector2(w,b))})});let f=d.map(m=>l(m,d,u,p,this.userData?.style.fillRule)),h=[];return d.forEach(m=>{let y=f[m.identifier];if(y&&!y.isHole){let b=new $t.Shape;b.curves=m.curves,f.filter(w=>w?.isHole&&w.for===m.identifier).forEach(w=>{if(w){let O=d[w.identifier],S=new $t.Path;S.curves=O.curves,b.holes.push(S)}}),h.push(b)}}),h}};var mh=!1,Yb,yh=new Promise(i=>{Yb=i}),Xb=!1;var xd;function Kb(){if(mh=!0,Xb)return;if(xd)return xd;async function i(){let e=await import("./opentype.js");Yb(e),Xb=!0}return xd=i(),xd}var Xl=class{async load(t,e,r=()=>{}){let{load:o}=await yh;o(t,(n,a)=>{n||!a?r(n??"Something went wrong"):e(a)})}async parse(t){let{parse:e,Bidi:r}=await yh;try{let o=e(t),n=new r,a=s=>o.charToGlyphIndex(s.char);return n.registerModifier("glyphIndex",null,a),n.applyFeatures(o,o.defaultRenderOptions.features),{font:o,bidi:n}}catch(o){console.error(o)}}};async function d3(i){return await(await fetch(i)).arrayBuffer()}var p3=new Xl;async function gh(i){let t,e,r=!1;if(i.url?(t=await d3(i.url),e=i.url,r=i.url.startsWith("/")):i.data&&(t=i.data.buffer.slice(i.data.byteOffset,i.data.byteOffset+i.data.byteLength)),t)if(mh){let o=await p3.parse(t);if(o)return{font:o.font,url:e,intercepted:r,arr:t,bidi:o.bidi}}else return{font:void 0,url:e,intercepted:r,arr:t,bidi:null}}var As=require("three");function f3(i,t){return t.state.glyphIndex===i||t.state.fina===i||t.state.medi===i||t.state.init===i}var bd=class{constructor(t){this._arrayBuffer=new ArrayBuffer(1);this._isLoaded=!1;this._intercepted=!1;this._isUserFont=t.isUserFont??!1,this._loadingPromise=gh(t).then(e=>{e&&(this._arrayBuffer=e.arr,this._url=e.url,this.font=e.font,this._intercepted=e.intercepted,this._isLoaded=!0,this._bidi=e.bidi)})}update(t){this._isLoaded=!1,this._isUserFont=t.isUserFont??!1,this._loadingPromise=gh(t).then(e=>{e&&(this._arrayBuffer=e.arr,this._url=e.url,this.font=e.font,this._intercepted=e.intercepted,this._isLoaded=!0,this._bidi=e.bidi)})}get url(){return this._url}get intercepted(){return this._intercepted}get isLoaded(){return this._isLoaded}get loadingPromise(){return this._loadingPromise}reverseLigaturesTable(t,e,r){if(!this._bidi)return[];let o=this._bidi;o.getTextGlyphs(e);let n=o.tokenizer.tokens,a=[],s=0,l=r.length===n.length;for(let c=0;c<r.length;c++){let u=r[c].index,p=String.fromCharCode(r[c].unicode),d=n[s];if(f3(u,d)||l)a.push({char:p,index:u,replacements:[d.state.glyphIndex],replacementChars:[d.char]}),s++;else{let f=d.char,h="",m=[d.state.glyphIndex],y=[],b=!1;for(;!b;)s++,h=e.charAt(s),f+=h,m.push(t.charToGlyphIndex(h)),y=t.stringToGlyphs(f),y.length===1&&y[0].index===u&&(b=!0),s>e.length&&(b=!0);a.push({char:p,index:u,replacements:m,replacementChars:Array.from(f)}),s++}}return a}generateShapes(t,e,r){if(!this._isLoaded)return;let o=this.font,n=e.fontSize/this.unitsPerEm,a=e.fontSize*e.lineHeight,s=t.map(v=>this.getTextWidth(v,e)),l=typeof e.width=="string"?Number(r.getVariable(e.width)):e.width,c=typeof e.height=="string"?Number(r.getVariable(e.height)):e.height,u=this.getCharWidth(`
2286
2286
  `,e),p=e.horizontalAlign===1?u:0,d=this.getLineInitialOffsetX(s[0],l,e.horizontalAlign,t[0],u),f=this.getLineInitialOffsetY(a,t.length,c,n,e.verticalAlign),h=[],m=t.map(v=>[]),y=t.map(v=>[]);for(let v=0;v<t.length;v++){let w=t[v],O={features:{liga:!0},letterSpacing:e.letterSpacing},S=[];try{S=o.stringToGlyphs(w,O)}catch(E){console.warn(E)}d=this.getLineInitialOffsetX(s[v],l,e.horizontalAlign,w,u);let T=[];try{T=this.reverseLigaturesTable(o,w,S)}catch(E){console.warn(E)}let M=this.computeSpaceWidthForLine(t,v,e,r),g=0,D=S[0];D&&e.horizontalAlign===2&&D.leftSideBearing!==void 0&&(d-=D.leftSideBearing*n),this.font?.forEachGlyph(w,d,f,e.fontSize,O,(E,I,N,_,R)=>{let V=E.index===0?`
2287
2287
  `:E.unicode?String.fromCharCode(E.unicode):void 0,U=T[g],B=0;if(V===`
2288
2288
  `)B=p;else if(V===" ")B=M;else{let q=this.createPath(E,n,I,N,e);q&&(B=q.offsetX,h.push(q.path))}if(U.replacements.length===1)y[v].push([I,N]),m[v].push(B);else{let q=U.replacements.map(W=>(o.glyphs.get(W).advanceWidth??0)*n),j=q.reduce((W,ee)=>W+=ee,0),F=q.map(W=>W/j),H=I;for(let W=0;W<F.length;W++){let ee=B*F[W];y[v].push([H,N]),m[v].push(ee),H+=ee}}g++}),f-=a}let b=[];for(let v=0,w=h.length;v<w;v++)b.push(...h[v].toShapes());return{shapes:b,charWidths:m,lineWidths:s,charCoords:y}}get isUserFont(){return this._isUserFont}get arrayBuffer(){return this._arrayBuffer}get ascender(){return this.font?.ascender??0}get descender(){return this.font?.descender??0}get familyName(){return this.font?.names.fontFamily??""}get subfamilyName(){return this.font?.names.fontSubfamily??""}get unitsPerEm(){return this.font?.unitsPerEm??1}getLineInitialOffsetX(t,e,r,o,n){return(r===3||r===2)&&o.indexOf(`
@@ -4376,4 +4376,4 @@ void main() {
4376
4376
  A = exp(A) * vColor.a;
4377
4377
  gl_FragColor = vec4(color.rgb, A);
4378
4378
  gVelocity = vec4(0.0); // so it is ignored by TAA
4379
- }`,n={covariancesTexture:{type:"t",value:null},centersColorsTexture:{type:"t",value:null},meshIndexIntervals:{value:e},meshMatrixWorldsTexture:{type:"t",value:null},focal:{type:"v2",value:new Te.Vector2},viewport:{type:"v2",value:new Te.Vector2},basisViewport:{type:"v2",value:new Te.Vector2},debugColor:{type:"v3",value:new Te.Color},covariancesTextureSize:{type:"v2",value:new Te.Vector2(1024,1024)},centersColorsTextureSize:{type:"v2",value:new Te.Vector2(1024,1024)},orthoZoom:{type:"f",value:-1}};return new Te.ShaderMaterial({uniforms:n,vertexShader:r,fragmentShader:o,transparent:!0,alphaTest:1,blending:Te.NormalBlending,depthTest:!0,depthWrite:!1,side:Te.DoubleSide})}static buildGeomtery(e){let r=new Te.BufferGeometry;r.setIndex([0,1,2,0,2,3]);let o=new Float32Array(4*3),n=new Te.BufferAttribute(o,3);r.setAttribute("position",n),n.setXYZ(0,-1,-1,0),n.setXYZ(1,-1,1,0),n.setXYZ(2,1,1,0),n.setXYZ(3,1,-1,0),n.needsUpdate=!0;let a=new Te.InstancedBufferGeometry().copy(r),s=new Uint32Array(e),l=new Te.InstancedBufferAttribute(s,1,!1);return l.setUsage(Te.DynamicDrawUsage),a.setAttribute("splatIndex",l),a.instanceCount=e,a}resetLocalSplatDataAndTexturesFromSplatBuffer(){this.updateLocalSplatDataFromSplatBuffer(),this.allocateAndStoreLocalSplatDataInTextures()}updateLocalSplatDataFromSplatBuffer(){this.splatBuffers.forEach(n=>n.buildPreComputedBuffers()),this.covariances=new Float32Array(this.splatCount*6),this.colors=new Uint8Array(this.splatCount*4),this.centers=new Float32Array(this.splatCount*3);let e=0,r=0,o=0;for(let n of this.splatBuffers){let a=n.nsplats;this.colors.subarray(e,e+a*4).set(n.colorsA),e+=a*4,this.centers.subarray(r,r+a*3).set(n.decoded.xyz.denormDequant().data),r+=a*3,this.covariances.subarray(o,o+a*6).set(new Float32Array(n.precomputedCovarianceBufferData)),o+=a*6}}allocateAndStoreLocalSplatDataInTextures(){let o=this.splatCount,n=new Te.Vector2(4096,1024);for(;n.x*n.y*2<o*6;)n.y*=2;let a=new Te.Vector2(4096,1024);for(;a.x*a.y*4<o*4;)a.y*=2;let s,l;if(this.halfPrecisionCovariancesOnGPU){l=new Uint16Array(n.x*n.y*2);for(let h=0;h<this.covariances.length;h++)l[h]=Te.DataUtils.toHalfFloat(this.covariances[h]);s=new Te.DataTexture(l,n.x,n.y,Te.RGFormat,Te.HalfFloatType)}else l=new Float32Array(n.x*n.y*2),l.set(this.covariances),s=new Te.DataTexture(l,n.x,n.y,Te.RGFormat,Te.FloatType);s.needsUpdate=!0,this.material.uniforms.covariancesTexture.value=s,this.material.uniforms.covariancesTextureSize.value.copy(n);let c=new Uint32Array(a.x*a.y*4);for(let h=0;h<o;h++){let m=h*4,y=h*3,b=h*4;c[b]=$1(this.colors[m],this.colors[m+1],this.colors[m+2],this.colors[m+3]),c[b+1]=rp(this.centers[y]),c[b+2]=rp(this.centers[y+1]),c[b+3]=rp(this.centers[y+2])}let u=new Te.DataTexture(c,a.x,a.y,Te.RGBAIntegerFormat,Te.UnsignedIntType);u.internalFormat="RGBA32UI",u.needsUpdate=!0,this.material.uniforms.centersColorsTexture.value=u,this.material.uniforms.centersColorsTextureSize.value.copy(a);let p=256*4,d=new Float32Array(256*16);for(let h=0;h<this.meshMatrixWorlds.length;h++)d.set(this.meshMatrixWorlds[h].elements,h*16);let f=new Te.DataTexture(d,p,1,Te.RGBAFormat,Te.FloatType);f.needsUpdate=!0,this.material.uniforms.meshMatrixWorldsTexture.value=f,this.material.uniformsNeedUpdate=!0,this.splatDataTextures={covariances:{data:l,texture:s,size:n},centerColors:{data:c,texture:u,size:a},meshMatrixWorlds:{data:d,texture:f}}}updateIndexes(e){let r=this.geometry;r.attributes.splatIndex.set(e),r.attributes.splatIndex.needsUpdate=!0,r.instanceCount=e.length}updateUniforms(e,r,o,n){this.splatCount>0&&(op.set(e.x*this.devicePixelRatio,e.y*this.devicePixelRatio),this.material.uniforms.viewport.value.copy(op),this.material.uniforms.basisViewport.value.set(2/op.x,2/op.y),this.material.uniforms.focal.value.set(r,o),this.material.uniforms.orthoZoom.value=n,this.material.uniformsNeedUpdate=!0)}getSplatDataTextures(){return this.splatDataTextures}getSplatCount(){return this.splatCount}getCenters(){return this.centers}getColors(){return this.colors}getCovariances(){return this.covariances}dispose(){this.geometry.dispose(),this.material.dispose(),this.splatDataTextures&&(this.splatDataTextures.covariances.texture.dispose(),this.splatDataTextures.centerColors.texture.dispose(),this.splatDataTextures.meshMatrixWorlds.texture.dispose()),this.removeFromParent()}};var Y1,Qh=new Promise(i=>{Y1=i}),X1=!1;var np;function Zh(){if(X1)return;if(np)return np;async function i(){let e=await import("./gaussian-splat-compression.js");Y1(e),X1=!0}return np=i(),np}var K1;Qh.then(i=>K1=i);var pc=class{constructor(t={}){yn(this,"updateView",function(){let t=new xr.Matrix4,e=[],r=new xr.Vector3(0,0,-1),o=new xr.Vector3(0,0,-1),n=new xr.Vector3,a=new xr.Vector3;return function(s=!1,l){let c=this.updateMatrixWorldsInWorkerIfNeeded(),u=this.cropsChanged();if(!s){o.set(0,0,-1).applyQuaternion(l.quaternion);let d=!1,f=!1;if(o.dot(r)<=.95&&(d=!0),a.copy(l.position).sub(n).length()>=1&&(f=!0),!d&&!f&&!c&&!u&&!this.needsInitialRender)return}this.needsInitialRender=!1,n.copy(l.position),r.copy(o),t.copy(l.matrixWorld).invert(),t.premultiply(this.dummyPerspectiveMatrix),e[0]=l.position.x,e[1]=l.position.y,e[2]=l.position.z;let p={sort:{view:t.elements,cameraPosition:e,splatRenderCount:this.splatRenderCount,splatSortCount:this.splatRenderCount},...c?{newMatrixWorlds:this.meshMatrixWorlds}:{},...u?{newCropsArray:this.cropsArray}:{}};this.sortRunning?this.queuedMessage=p:(this.queuedMessage=null,this.sortRunning=!0,this.sortWorker.postMessage(p))}}());this.scene=t.scene,this.currentPage=null,this.devicePixelRatio=window.devicePixelRatio,this.sortWorker=null,this.splatRenderCount=0,this.splatSortCount=0,this.splatMesh=null,this.sortRunning=!1,this.meshMatrixWorlds=null,this.meshMatrixWorldsOld=null,this.cropsArray=null,this.splatEntries=null,this.queuedMessage=null,this.needsInitialRender=!0,this.dummyPerspectiveMatrix=new xr.Matrix4().makePerspective(-1,1,-1,1,.1,1e3)}updateSplatMeshUniforms(t,e){let r=new xr.Vector2;if(this.splatMesh===null)return;this.splatMesh.getSplatCount()>0&&(t.getSize(r),this.cameraFocalLengthX=e.projectionMatrix.elements[0]*this.devicePixelRatio*r.x*.45,this.cameraFocalLengthY=e.projectionMatrix.elements[5]*this.devicePixelRatio*r.y*.45,this.splatMesh.updateUniforms(r,this.cameraFocalLengthX,this.cameraFocalLengthY,e.isPerspectiveCamera?-1:e.zoom*this.devicePixelRatio))}loadSplat(t={}){this.activePage=this.scene.activePage,t.position&&(t.position=new xr.Vector3().fromArray(t.position)),t.orientation&&(t.orientation=new xr.Quaternion().fromArray(t.orientation)),t.halfPrecisionCovariances=!!t.halfPrecisionCovariances;let e=[];if(this.splatEntries=e,this.activePage.traverseVisibleEntity(a=>{a.data.type==="Splat"&&e.push(a)}),this.splatMesh&&this.splatMesh.dispose(),e.length===0)return this.splatMesh=null,!1;this.meshMatrixWorlds=e.map(a=>a.matrixWorld),this.meshMatrixWorldsOld=e.map(a=>a.matrixWorld.clone()),this.cropsArray=e.map(a=>a.data.crops.map(s=>s.data));let r=e.map(a=>new K1.GSplineBuffer(new Uint8Array(a.data.buffer).buffer)),o=0,n=[0];for(let a of r)o+=a.getSplatCount(),n.push(o);return this.setupSplatMesh(r,o,t.position,t.orientation,t.halfPrecisionCovariances,this.devicePixelRatio,n,this.meshMatrixWorlds),this.setupSortWorker(o),!0}updateMatrixWorldsInWorkerIfNeeded(){let t=this.splatDataTextures.meshMatrixWorlds.data;for(let e=0;e<this.meshMatrixWorlds.length;e++)t.set(this.meshMatrixWorlds[e].elements,e*16);return this.splatDataTextures.meshMatrixWorlds.texture.needsUpdate=!0,this.meshMatrixWorlds.every((e,r)=>e.equals(this.meshMatrixWorldsOld[r]))?!1:(this.meshMatrixWorldsOld=this.meshMatrixWorlds.map(e=>e.clone()),!0)}cropsChanged(){let t=!1;return this.splatEntries.forEach((e,r)=>{e.data.crops.forEach((o,n)=>{this.cropsArray[r][n]===void 0?(t=!0,this.cropsArray[r][n]=o.data):Object.entries(o.data).forEach(([a,s])=>{Array.isArray(s)&&s.some((l,c)=>l!==this.cropsArray[r][n][a][c])?(t=!0,this.cropsArray[r][n][a]=s):s!==this.cropsArray[r][n]?.[a]&&(t=!0,this.cropsArray[r][n][a]=s)})}),e.data.crops.length!==this.cropsArray[r]?.length&&(this.cropsArray[r].length=e.data.crops.length,t=!0)}),t}setupSplatMesh(t,e,r=new xr.Vector3,o=new xr.Quaternion,n=!1,a=1,s,l){this.splatMesh=un.buildMesh(t,e,n,a,s,l),this.splatMesh.position.copy(r),this.splatMesh.quaternion.copy(o),this.splatMesh.frustumCulled=!1,this.splatMesh.renderOrder=99999,this.splatRenderCount=e,this.splatMesh.onBeforeRender=(c,u,p)=>this.update(c,p)}setupSortWorker(t){this.sortWorker=q1(t),this.sortWorker.onmessage=e=>{e.data.sortDone?(this.sortRunning=!1,this.splatMesh?.updateIndexes(new Uint32Array(e.data.indexesBuffer)),this.lastSortTime=e.data.sortTime,this.queuedMessage&&(this.sortWorker.postMessage(this.queuedMessage),this.queuedMessage=null)):e.data.sortCanceled?this.sortRunning=!1:e.data.sortSetupPhase1Complete?this.sortWorker.postMessage({positions:this.splatMesh.getCenters().buffer,meshMatrixWorlds:this.splatMesh.meshMatrixWorlds,meshIndexIntervals:this.splatMesh.meshIndexIntervals,cropsArray:this.cropsArray}):e.data.sortSetupComplete&&(this.splatDataTextures=this.splatMesh.getSplatDataTextures(),this.scene.activePage.add(this.splatMesh),this.needsInitialRender=!0)}}update(t,e){this.splatMesh!==null&&(this.updateSplatMeshUniforms(t,e),this.updateView(!1,e))}getSplatMesh(){return this.splatMesh}};var OE=new eo.MeshBasicMaterial;OE.wireframe=!0;var Q1=new eo.Vector3,ap=class extends eo.Scene{constructor(e,r){super();this.data=e;this.sharedAssets=r;this.enableHelpers=!1;this.wireframeState=!1;this.needsTransmissionDirty=!0;this.needsNormalDirty=!0;this._needsTransmission=!1;this._needsNormal=!1;this.geometryCacheChanged=!1;this.splatViewer=null;this.shapeBlendIntances=[];this.entityByUuid={};this.entityIdentityToEntity={};this.toExpandCloner=new Set;this.toUpdateCloner=new Set;this.pendingCommands=[];this.pathConstraints=new tp;this.invisibleObjects=new tn("jflkdsafjasdifjaslk",{...Pu.defaultData,visible:!1,name:"buildin invisible"});this.needsRecomputeInstances=!1;this.init(e,r),this.matrixAutoUpdate=!1,this.errorPage=new Zr("fdasfa",{...ti.defaultData,name:""},{shared:r,scene:this})}markGeometryCacheDirty(){this.geometryCacheChanged=!0}markNeedsUpdateRendererDirty(){this.needsTransmissionDirty=!0,this.needsNormalDirty=!0}needsTransmission(){return this.needsTransmissionDirty&&(this._needsTransmission=H1(this),this.needsTransmissionDirty=!1),this._needsTransmission}needsNormal(){return this.needsNormalDirty&&(this._needsNormal=k1(this),this.needsNormalDirty=!1),this._needsNormal}registerInstanceAndSetUuid(e){let r=e.identity.join("-"),o=this.entityIdentityToEntity[r];o&&(e.uuid=o.uuid),this.entityIdentityToEntity[r]=e,this.entityByUuid[e.uuid]=e}markPenumbraSizeDirty(){for(let e of this.children)e instanceof Zr&&(e.penumbraSizeArrayCache=null)}findInstance(e){return this.entityIdentityToEntity[e.join("-")]}get bgColor(){return this.activePage.bgColor}get postprocessing(){return this.activePage.data.postprocessing}getWithSortKey(e){let r=this.find(e);if(r===void 0)return;let o=[],n=r;for(;n!==this;){let a=n;n=n.parent;let s=n.children.indexOf(a);o.splice(0,0,s)}return{entity:r,sortKey:o}}getAllSorted(e){let r=[];for(let o of e){let n=this.getWithSortKey(o.id);n!==void 0&&r.push(n)}return r.sort((o,n)=>Sc(o.sortKey,n.sortKey)),r.map(o=>o.entity)}nonExistOrDescendantOf(e,r){let o=this.find(e);if(o===void 0)return!0;for(;o;){if(o.uuid===r)return!0;o=o.parent}return!1}find(e){if(this.activePage&&this.activePage.personalCamera.parent){if(e==="f23858d0-4a3b-4bd8-8173-66ed0af7f6fb-personalCamera")return this.activePage.personalCamera;if(e===_i)return this.activePage.personalCamera}if(e===""||e===void 0)return;let r=this.entityByUuid[e];return r===void 0?this.getObjectByProperty("uuid",e):r}find2D(e){for(let r of this.children)if(r instanceof Zr&&r.uiScene){let o=r.uiScene.find(e);if(o)return o}}findScene2DfromObject2D(e){for(let r of this.children)if(r instanceof Zr&&r.uiScene&&r.uiScene.find(e))return r.uiScene}find2DInUIObjects(e){let r;return this.traverseEntity(o=>{r===void 0&&o instanceof Hn&&(r=o.uiCanvas.find(e))}),r}traverse2D(e){for(let r of this.children)r instanceof Zr&&r.uiScene&&r.uiScene.traverse(e)}debugEnsureEntity(e){let r=this.find(e);if(r){if(Array.isArray(r.identity)&&this.findInstance(r.identity)===void 0){console.error("not found instance");debugger}}else{console.error("not found");debugger}}addPendingExpandCloner(e){this.toExpandCloner.add(e)}addPendingUpdateCloner(e){this.toUpdateCloner.add(e)}markToExpandCloner(e){this.toExpandCloner.add(e),e.traverseEntityAncestors(r=>{this.toExpandCloner.add(r)})}doPendingExpandCloner(){this.toExpandCloner.forEach(e=>{e.expandCloner(this)}),this.toExpandCloner.clear()}doPendingUpdateCloner(){this.toUpdateCloner.forEach(e=>{e.cloner?.update()}),this.toUpdateCloner.clear()}doPendingUpdates(){this.doPendingExpandCloner(),this.doPendingUpdateCloner(),this.applyPendingCommands()}addPendingCommand(e){this.pendingCommands.push(e)}applyPendingCommands(){this.pendingCommands.forEach(e=>e()),this.pendingCommands.length=0}updateByLibOp(e,r){e.path.length===1&&e.path[0]==="components"&&e.type===1&&this.createChildrenObjects([{...e.data.asset,id:e.id}],this.invisibleObjects,r)}updateTreeByOp(e,r){if(e.path.length===0&&e.type===7){let o=e.parent===null?this:this.find(e.parent);if(o===void 0)throw new Error("unexpected");let n=this.createObject(e.id,e.data,e.children,o,e.localIndex,r);n.updateVisible(this),n.resetBBoxNeedsUpdate(),en(n)&&rc(n.parent)&&(n.invalidateUpstreamBooleanData(),n.parent.invalidateDownstreamBooleanData().recomputeBoolean()),this.markNeedsRecomputeInstancesForAncessors(o),this.markNeedsRecomputeInstancesForChildren(n),this.markToExpandCloner(n),this.markPenumbraSizeDirty(),n.updatePathSnapping()}else if(e.path.length===0&&e.type===8){let o=this.find(e.id);if(o===void 0)throw new Error("unexpected");o.traverseEntity(a=>{a instanceof sn&&(this.shapeBlendIntances=this.shapeBlendIntances.filter(s=>s!==a))}),this.markToExpandCloner(o),o.resetBBoxNeedsUpdate(),this.unregisterObject(o);let n=o.parent;this.markNeedsRecomputeInstancesForAncessors(n),this.markNeedsRecomputeInstancesForChildren(o),this.markPenumbraSizeDirty(),o.parent.remove(o),rc(o.parent)&&(o.parent.invalidateUpstreamBooleanData(),o.parent.invalidateDownstreamBooleanData().recomputeBoolean()),en(o)&&(o.freeBooleanPointer(),n instanceof Ar&&n.invalidateDownstreamBooleanData().recomputeBoolean()),o instanceof Hs&&o.detachShape(),this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(o),this.pathConstraints.removeDependencies(o.uuid),o.updatePathSnapping()}else if(e.path.length===0&&e.type===9){let o=this.find(e.id);if(o===void 0)throw new Error("unexpected");this.markNeedsRecomputeInstancesForChildren(o);let n=o.parent;this.markNeedsRecomputeInstancesForAncessors(n),o.cloner?.resetOnMove(),this.markToExpandCloner(o);let a=e.parent===null?this:this.find(e.parent);if(a===void 0)throw new Error("unexpected");a.add(o),this.markNeedsRecomputeInstancesForAncessors(a),this.markToExpandCloner(o),o.invalidateClonerTransform(o),o.updateVisible(this),o.resetBBoxNeedsUpdate(),this.markPenumbraSizeDirty();let s=e.localIndex;a.children.splice(s,0,a.children.pop()),en(o)&&(o.invalidateUpstreamBooleanData(),rc(o.parent)?o.parent.invalidateDownstreamBooleanData().recomputeBoolean():n instanceof Ar&&n.invalidateDownstreamBooleanData().recomputeBoolean()),o.updatePathSnapping()}this.markNeedsUpdateRendererDirty(),this.markGeometryCacheDirty()}get playPage(){return this.find(this.data.publish.playPage)??this.errorPage}updatePage(e){this.activePage&&this.activePage.onDeactive(),this.activePage=this.errorPage;for(let r of this.children)r instanceof Zr&&(r.visible=r.uuid===e,r.visible&&(this.activePage=r,this.activePage.onActive(this)));this.activePage!==this.splatViewer?.activePage&&this.reloadSplats()}updateEntityByOp(e,r,o,n){if(r.type===0){if(("overrides"in r.props||"component"in r.props)&&this.markNeedsRecomputeInstances(),"visible"in r.props&&this.markPenumbraSizeDirty(),r.path.includes("overrides")&&"states"in r.props){let{rest:s}=r.props;r={...r,props:s},this.markNeedsRecomputeInstances()}r.path[0]==="pathSnapping"&&r.props.pathId!==void 0&&this.pathConstraints.setConstraint(e,r.props.pathId)}let a=this.find(e);if(a)try{V1(a,r,o,{scene:this,shared:n}),a instanceof ft&&a.updateGeometryGroupsIfNeeded()}catch(s){console.error(s)}}updateEntity2DByOp(e,r,o,n,a,s=[]){e.updateEntityByOp(r,o,n,a),this.traverseEntity(l=>{(l instanceof Hn||l instanceof Zr)&&(s.includes(l.frameId??"")||l.frameId===r)&&l.updateEntity2DByOp(r,o,n,a)})}get activeCamera(){return this.activePage.activeCamera}switchActiveCamera(e){this.activePage.switchActiveCamera(e)}isInvisibleObjects(e){return e===this.invisibleObjects||e.hasAnccestor(this.invisibleObjects)}init(e,r){let o=Object.entries(r.data.lib.components).map((n,a)=>({data:n[1].asset.data,children:n[1].asset.children,id:n[0],fi:a}));this.invisibleObjects.updateState(this.invisibleObjects.data,{scene:this,shared:r}),this.add(this.invisibleObjects),this.createChildrenObjects(o,this.invisibleObjects,r),this.createChildrenObjects(e.objects,this,r),this.updatePage(e.publish.playPage),this.activePage.switchToPlayCamera(),this.expandInstances(r,!0),this.traverseEntity(n=>{n instanceof yi&&n.updateUp()}),this.doPendingExpandCloner(),this.applyPendingCommands()}markNeedsRecomputeInstances(){this.needsRecomputeInstances=!0}markNeedsRecomputeInstancesForChildren(e){e.traverseEntity(r=>{(r.data.type==="Component"||r.data.type==="Instance")&&this.markNeedsRecomputeInstances()})}markNeedsRecomputeInstancesForAncessors(e){ze.is(e)&&(e.data.type==="Component"&&this.markNeedsRecomputeInstances(),e.traverseAncestors(r=>{ze.is(r)&&r.data.type==="Component"&&this.markNeedsRecomputeInstances()}))}relativeizeInner(e,r,o,n,a,s,l){if(e){let c=n.find(e);c&&c!==n&&a.forInstancesRec(u=>{u.data=Ai(u.data,p=>{let d=p.events.data(l.id),f=u.goUp(s);if(f){let h=[...vc(f.identity),e].join("-"),m=this.entityIdentityToEntity[h];if(m){let y=m.uuid,b=ut.zoom(d,r);b[o]=y}else{if(!1)debugger;console.warn("cannot find instance")}}}).data})}}rewriteActions(e,r,o,n,a,s){e.forEach(l=>{l.data.type==="Transition"?this.relativeizeInner(l.data.object,[...r,l.id],"object",o,n,a,s):l.data.type==="Animation"?this.relativeizeInner(l.data.object,[...r,l.id],"object",o,n,a,s):l.data.type==="Conditional"&&(this.rewriteActions(l.data.ifActions,[...r,l.id,"ifActions"],o,n,a,s),this.rewriteActions(l.data.elseActions,[...r,l.id,"elseActions"],o,n,a,s))})}rewriteEventsBeforeGoToPlayMode(){this.traverseEntity(e=>{if(e instanceof bi&&typeof e.identity=="string"&&e.data.type==="Component")return e.traverseEntity((r,o)=>{r.data.events.forEach(n=>{if(n.data.type==="GameControl"){let a=!1;if(r.forInstancesRec(s=>{s.data=Ai(s.data,l=>{s.isInstanceRoot||(l.events.delete(n.id),a=!0)}).data}),a===!1)for(let s of Au.list)this.rewriteActions(n.data.gameActions[s],["gameActions",s],e,r,o,n)}else n.data.type==="Conditional"?(n.data.condition.type==="Distance"?(this.relativeizeInner(n.data.condition.fromObject,["condition"],"fromObject",e,r,o,n),this.relativeizeInner(n.data.condition.toObject,["condition"],"toObject",e,r,o,n)):n.data.condition.type==="State"?this.relativeizeInner(n.data.condition.object,["condition"],"object",e,r,o,n):n.data.condition.type==="Comparison"&&(n.data.condition.lOperand.type==="Property"&&this.relativeizeInner(n.data.condition.lOperand.value[0],["condition","lOperand","value"],0,e,r,o,n),n.data.condition.rOperand.type==="Property"&&this.relativeizeInner(n.data.condition.rOperand.value[0],["condition","rOperand","value"],0,e,r,o,n)),this.rewriteActions(n.data.inActions,["inActions"],e,r,o,n),this.rewriteActions(n.data.outActions,["outActions"],e,r,o,n)):"actions"in n.data&&this.rewriteActions(n.data.actions,["actions"],e,r,o,n)})}),!0})}expandInstances(e,r,o){let n=new Set;this.traverseEntity(a=>{if(a instanceof bi&&a.isInstanceRoot)return a.expandInstanceChildren({scene:this,shared:e,pendingDeletes:n}),r||a.resetBBoxNeedsUpdate(),o&&a.traverseEntity(s=>{o.addClip(s)}),!0});for(let a of n)this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(a),Xd(a)}recomputeInstances(e,r){this.needsRecomputeInstances&&(this.needsRecomputeInstances=!1,this.traverseEntity(o=>{o instanceof bi&&o.isInstanceRoot&&(o.component=void 0)}),this.expandInstances(e,!1,r))}disposeAndUnregisterEntityRecursivelyIfNotReregistered(e){e.traverseEntity(r=>{let o=typeof r.identity=="string"?r.identity:r.identity.join("-");this.entityIdentityToEntity[o]===r&&(delete this.entityByUuid[r.uuid],delete this.entityIdentityToEntity[o]),r.dispose()})}clearScene(){for(let e of this.children)ze.is(e)&&e.disposeRecursively();this.children.length=0}resetAfterClear(e,r){this.init(e,r)}raycast(e){return this.raycast1(e,!1)}raycast1(e,r){let o=[],n=a=>{for(let s of a.children){let l=s.cloner;if(ze.is(s)&&!s.raycastLock&&(s.visible||l?.object.data.visible))if(r===!0&&s.isInstanceRoot){let c=[];if(e.intersectObject(s,!0,c),c.length){let u=c[0];u.object=s,u.point.applyMatrix4(u.object.matrixWorld);let p=s.matrixWorld.clone().invert();u.point.applyMatrix4(p),o.push(u)}}else(en(s)||oc(s)&&this.enableHelpers&&s.objectHelper.visible)&&(e.intersectObject(s,!1,o),uc(s,e,o)),n(s)}};return n(this.activePage),o}raycastWithClones(e){let r=[],o=n=>{for(let a of n.children){let s=a.cloner;ze.is(a)&&(a.visible||s?.object.data.visible)&&((en(a)||oc(a)&&this.enableHelpers&&a.objectHelper.visible)&&(e.intersectObject(a,!1,r),uc(a,e,r,!0)),o(a))}};return o(this),r}forEachEntity(e){for(let r of this.children)ze.is(r)&&e(r)}traverseConcreteEntity(e){for(let r of this.children)ze.is(r)&&r.isConcreteEntity&&r.traverseEntity(e)}traverseEntity(e){for(let r of this.children)ze.is(r)&&r.traverseEntity(e)}updateFont(e,r){this.traverseEntity(o=>{if(o instanceof ft&&o.data.type==="Mesh"&&(o.data.geometry.type==="TextGeometry"||o.data.geometry.type==="InputGeometry")&&o.data.geometry.font===e){let n=o.geometry,a=o.data.geometry;n.updateFont(e,r).then(()=>{n.update(a,r);let s=o.invalidateDownstreamBooleanData();rc(s)&&s.recomputeBoolean()})}})}traverseObject(e){for(let r of this.children)si.is(r)&&r.traverseObject(e)}traverseVisibleEntity(e){for(let r of this.children)ze.is(r)&&r.visible&&r.traverseVisibleEntity(e)}dispose(){this.clearScene()}createChildrenObjects(e,r,o){let n=0;for(let a of e)this.createObject(a.id,a.data,a.children,r,n,o),n+=1}registerObjectCreatedInLegacy(e){this.entityByUuid[e.uuid]=e}unregisterObject(e){delete this.entityByUuid[e.uuid];for(let r of e.children)this.unregisterObject(r)}createObject(e,r,o,n,a,s){let l={scene:this,shared:s},c=Zd(e,r,l);return c instanceof sn&&this.shapeBlendIntances.push(c),c&&(this.entityByUuid[e]=c,n.add(c),n.children.splice(a,0,n.children.pop()),o.length>0&&(c.isInstanceRoot?console.error("instance should not have children!"):this.createChildrenObjects(o,c,s)),c.updateState(r,l),c instanceof ft&&c.updateGeometryGroupsIfNeeded(),c.updateVisible(this),c.cloner&&this.toExpandCloner.add(c),r.pathSnapping?.pathId&&this.pathConstraints.setConstraint(e,r.pathSnapping.pathId)),r.type==="Empty"&&r.animations&&c.traverseEntity(u=>{let p=u.dataPatched;if(u instanceof ft&&p.bones&&p.boneInverses){let d=p.bones.map(m=>this.find(m)),f=p.boneInverses.map(m=>new eo.Matrix4().fromArray(m)),h=new eo.Skeleton(d,f);u.bind(h,u.bindMatrix)}else u.matrixAutoUpdate=!0}),c}getCenter(e){let r=[];for(let n=0,a=e.length;n<a;++n){let{id:s,recursive:l}=e[n],c=this.find(s),u=l?c.recursiveBBox:c.singleBBox;r.push(...u.vertices)}let o=new eo.Box3;return o.setFromPoints(r),o.getCenter(Q1),Q1}copyMatrixWorld(e,r){if(e===null){r.identity();return}let o=this.find(e);o?r.copy(o.matrixWorld):r.identity()}copyParentMatrixWorld(e,r){if(e===null){r.identity();return}let o=this.find(e)?.parent;o?r.copy(o.matrixWorld):r.identity()}traverseMaterial(e){this.traverseEntity(r=>{if(r instanceof Wt)if(Array.isArray(r.material))for(let o=0;o<r.material.length;o++)r.material[o]instanceof Tr&&e(r.material[o]);else r.material instanceof Tr&&e(r.material)})}updateViewPlaneSize(e,r,o=!1){this.traverseConcreteEntity(n=>{n instanceof yi&&n.setViewplaneSize(e,r,o)})}initializeSplatViewer(){this.splatViewer=new pc({scene:this}),this.reloadSplats()}reloadSplats(){this.splatViewer?.loadSplat()}};var Z1=require("three/examples/jsm/loaders/DRACOLoader.js");var dn;function J1(i){return dn||(dn=new Z1.DRACOLoader,dn.setDecoderPath(i?`${i}/`:"https://www.gstatic.com/draco/versioned/decoders/1.5.2/").preload()),dn.decoderPending}async function TE(i){if(dn){let t={attributeIDs:dn.defaultAttributeIDs,attributeTypes:dn.defaultAttributeTypes,useUniqueIDs:!1},e;try{e=await dn.decodeGeometry(new Int8Array(i).buffer,t)}catch(r){console.error(r)}if(e)return{index:e.index?{array:e.index.array}:void 0,attributes:Object.entries(e.attributes).map(([r,o])=>({name:r,itemSize:o.itemSize,array:o.array}))}}return null}async function eS(i,t){let[e,r]=Dp(uu.deserialize(new Uint8Array(i)));return Iu(e),t&&t(e),r.result().data}function tS(i){let t=[];return i.scene.objects.traverse((e,r)=>{r.type==="Mesh"&&r.geometry.type==="NonParametricGeometry"&&r.geometry.data.draco!==void 0&&t.push(r)}),t}async function rS(i){for(let t of i){let e=await TE(t.geometry.data.draco);if(e){let r=t.geometry.data;e.index&&(r.index={array:e.index.array,itemSize:1,normalized:!1,type:"Uint32Array"});let o={};e.attributes.forEach(({name:n,array:a,itemSize:s})=>{o[n]={array:a,itemSize:s,type:"Float32Array",normalized:!1}}),r.attributes=o,r.draco=void 0}}}var CE=require("three"),AE=require("three/examples/jsm/utils/BufferGeometryUtils.js");function oS(i){let t;if(!!i.index)for(let e=0;e<i.index.array.length;e+=3)t=i.index.array[e],i.index.array[e]=i.index.array[e+2],i.index.array[e+2]=t}var fc=require("three");function iS(i){let t=new Set;return i.traverse(e=>{if(e instanceof Cr)if(Tt(e.material))e.material.forEach(r=>{let o=r;t.has(o)||t.add(o)});else{let r=e.material;t.has(r)||t.add(r)}}),t.forEach(e=>{if(e instanceof Array)return;let r=e.onBeforeCompile.bind(e);if(ME(e)){Object.assign(e,{isMeshStandardMaterial:!0,isMeshPhysicalMaterial:!0,transmission:1,attenuationColor:new fc.Color,specularColor:new fc.Color});let o=0;e.onBeforeCompile=(n,a)=>{r&&r(n,a),n.uniforms=Object.assign({},fc.ShaderLib.physical.uniforms,n.uniforms),e.getLayersOfType("transmission").forEach(s=>{if(n.uniforms.transmissionSamplerMap.value){let l=s.color;l&&(l.transmissionSamplerMap.value=n.uniforms.transmissionSamplerMap.value,l.transmissionSamplerSize.value=n.uniforms.transmissionSamplerSize.value,l.aspectRatio.value=zb(window.innerWidth,window.innerHeight),e.defines.IS_THREEJS_EXPORT=!0)}else o++,o<2&&(e.needsUpdate=!0)})}}else IE(e)||(e.onBeforeCompile=(o,n)=>{r&&r(o,n),e.transparent=!1})}),i}function ME(i){return i.getLayersOfType("transmission").length>0}function IE(i){let t=0;for(let e of i.layers){if(e.data.type!=="displace"&&e.data.isMask)return!0;if(e.type!=="light"&&e.type!=="fresnel"){let o=e.uniforms["f"+e.id+"_alpha"];o&&(t+=(1-t)*o.value)}}return t<1}function nS(i){return i.traverse(t=>{if(t.type==="Camera"){let e=t;e.type=e.cameraType}}),i}function aS(i){let t=[],e=(r,o=0)=>{let n=o>0?r+o:r;return t.includes(n)?e(r,o+1):n};return i.traverse(r=>{if(t.includes(r.name)){let o=r.name,n=e(r.name);if(r.name=n,r.isMesh){let a=r;a.material instanceof Array?a.material.forEach(s=>{s.name=s.name.replace(o,n)}):a.material.isAsset||(a.material.name=a.material.name.replace(o,n))}}t.push(r.name)}),i}var sS=require("three/examples/jsm/utils/BufferGeometryUtils.js");function lS(i){let t=[];return i.traverse(e=>{e instanceof Zi&&t.push(e)}),t.forEach(e=>{let r=e.object,a=[...e.children.map(s=>{s.updateMatrix();let l;if(s.geometry!==void 0)try{l=s.geometry.clone().applyMatrix4(s.matrix)}catch(c){console.error(c)}return l!==void 0&&s.matrix.determinant()<0&&oS(l),l}).filter(s=>s!==void 0)];if(!e.parameters.hideBase&&r instanceof Wt&&a.unshift(r.geometry),a.length){let s=(0,sS.mergeBufferGeometries)(a);r instanceof Wt&&(r.geometry=s)}e.removeFromParent(),r.setFromClonerState(null,{scene:i,shared:ov})}),i}function cS(i){return i.traverse(t=>{t.matrixAutoUpdate=!0}),i}function uS(i){Object.values(i.shared.materials).forEach(t=>{Jh(t)}),i.scene.objects.traverse((t,e)=>{"material"in e?Jh(e.material):"materials"in e&&e.materials.forEach(r=>{Jh(r)})})}function Jh(i){if(typeof i=="string")return;let t=[];i.layers.forEach((e,r)=>{e.type==="outline"&&t.push(r)}),t.reverse().forEach(e=>{i.layers.delete(e)}),t.length&&console.warn("The Spline Loader currently does not support the outline layer.")}var hS=tl(pS(),1);var fS="The SplineLoader only accepts .splinecode files that are generated from Spline export panel.",sp=class extends lp.Loader{load(t,e,r,o=console.error){let n=new lp.FileLoader(this.manager);n.setPath(this.path),n.setResponseType("arraybuffer"),n.setRequestHeader(this.requestHeader),n.setWithCredentials(this.withCredentials),t.endsWith(".spline")?console.warn(fS+" The .spline files are only meant to be used by the Editor."):t.endsWith(".splinecode")||console.warn(fS),n.load(t,async a=>{try{if(typeof a=="string")throw new Error("The .spline file is not binary!");let s=await this.parse(a);e(s)}catch(s){o(s)}},r,o)}async parse(t){let e=await eS(t,uS),r=tS(e);e.version&&(0,hS.default)(e.version,"1.10.77")>0&&console.warn("Your .splinecode file is more recent than the library. Please upgrade @splinetool/loader to the latest version."),await Promise.allSettled([r.length&&J1(),lv(e)&&pb(),xv(e)&&Kb(),Zv(e)&&Yv(),ip(e)&&Zh()].filter(Boolean)),r.length&&await rS(r);let o=!1,n=new Gn(e.shared,{},o);Object.values(n.getMaterials()).forEach(l=>Object.assign(l,{isAsset:!0}));let a=new ap(e.scene,n);ip(e)&&a.initializeSplatViewer();let s=a.activeCamera;return s&&Object.assign(s,{makeDefault:!0}),a=lS(a),a=iS(a),a=nS(a),a=aS(a),a=cS(a),a}};
4379
+ }`,n={covariancesTexture:{type:"t",value:null},centersColorsTexture:{type:"t",value:null},meshIndexIntervals:{value:e},meshMatrixWorldsTexture:{type:"t",value:null},focal:{type:"v2",value:new Te.Vector2},viewport:{type:"v2",value:new Te.Vector2},basisViewport:{type:"v2",value:new Te.Vector2},debugColor:{type:"v3",value:new Te.Color},covariancesTextureSize:{type:"v2",value:new Te.Vector2(1024,1024)},centersColorsTextureSize:{type:"v2",value:new Te.Vector2(1024,1024)},orthoZoom:{type:"f",value:-1}};return new Te.ShaderMaterial({uniforms:n,vertexShader:r,fragmentShader:o,transparent:!0,alphaTest:1,blending:Te.NormalBlending,depthTest:!0,depthWrite:!1,side:Te.DoubleSide})}static buildGeomtery(e){let r=new Te.BufferGeometry;r.setIndex([0,1,2,0,2,3]);let o=new Float32Array(4*3),n=new Te.BufferAttribute(o,3);r.setAttribute("position",n),n.setXYZ(0,-1,-1,0),n.setXYZ(1,-1,1,0),n.setXYZ(2,1,1,0),n.setXYZ(3,1,-1,0),n.needsUpdate=!0;let a=new Te.InstancedBufferGeometry().copy(r),s=new Uint32Array(e),l=new Te.InstancedBufferAttribute(s,1,!1);return l.setUsage(Te.DynamicDrawUsage),a.setAttribute("splatIndex",l),a.instanceCount=e,a}resetLocalSplatDataAndTexturesFromSplatBuffer(){this.updateLocalSplatDataFromSplatBuffer(),this.allocateAndStoreLocalSplatDataInTextures()}updateLocalSplatDataFromSplatBuffer(){this.splatBuffers.forEach(n=>n.buildPreComputedBuffers()),this.covariances=new Float32Array(this.splatCount*6),this.colors=new Uint8Array(this.splatCount*4),this.centers=new Float32Array(this.splatCount*3);let e=0,r=0,o=0;for(let n of this.splatBuffers){let a=n.nsplats;this.colors.subarray(e,e+a*4).set(n.colorsA),e+=a*4,this.centers.subarray(r,r+a*3).set(n.decoded.xyz.denormDequant().data),r+=a*3,this.covariances.subarray(o,o+a*6).set(new Float32Array(n.precomputedCovarianceBufferData)),o+=a*6}}allocateAndStoreLocalSplatDataInTextures(){let o=this.splatCount,n=new Te.Vector2(4096,1024);for(;n.x*n.y*2<o*6;)n.y*=2;let a=new Te.Vector2(4096,1024);for(;a.x*a.y*4<o*4;)a.y*=2;let s,l;if(this.halfPrecisionCovariancesOnGPU){l=new Uint16Array(n.x*n.y*2);for(let h=0;h<this.covariances.length;h++)l[h]=Te.DataUtils.toHalfFloat(this.covariances[h]);s=new Te.DataTexture(l,n.x,n.y,Te.RGFormat,Te.HalfFloatType)}else l=new Float32Array(n.x*n.y*2),l.set(this.covariances),s=new Te.DataTexture(l,n.x,n.y,Te.RGFormat,Te.FloatType);s.needsUpdate=!0,this.material.uniforms.covariancesTexture.value=s,this.material.uniforms.covariancesTextureSize.value.copy(n);let c=new Uint32Array(a.x*a.y*4);for(let h=0;h<o;h++){let m=h*4,y=h*3,b=h*4;c[b]=$1(this.colors[m],this.colors[m+1],this.colors[m+2],this.colors[m+3]),c[b+1]=rp(this.centers[y]),c[b+2]=rp(this.centers[y+1]),c[b+3]=rp(this.centers[y+2])}let u=new Te.DataTexture(c,a.x,a.y,Te.RGBAIntegerFormat,Te.UnsignedIntType);u.internalFormat="RGBA32UI",u.needsUpdate=!0,this.material.uniforms.centersColorsTexture.value=u,this.material.uniforms.centersColorsTextureSize.value.copy(a);let p=256*4,d=new Float32Array(256*16);for(let h=0;h<this.meshMatrixWorlds.length;h++)d.set(this.meshMatrixWorlds[h].elements,h*16);let f=new Te.DataTexture(d,p,1,Te.RGBAFormat,Te.FloatType);f.needsUpdate=!0,this.material.uniforms.meshMatrixWorldsTexture.value=f,this.material.uniformsNeedUpdate=!0,this.splatDataTextures={covariances:{data:l,texture:s,size:n},centerColors:{data:c,texture:u,size:a},meshMatrixWorlds:{data:d,texture:f}}}updateIndexes(e){let r=this.geometry;r.attributes.splatIndex.set(e),r.attributes.splatIndex.needsUpdate=!0,r.instanceCount=e.length}updateUniforms(e,r,o,n){this.splatCount>0&&(op.set(e.x*this.devicePixelRatio,e.y*this.devicePixelRatio),this.material.uniforms.viewport.value.copy(op),this.material.uniforms.basisViewport.value.set(2/op.x,2/op.y),this.material.uniforms.focal.value.set(r,o),this.material.uniforms.orthoZoom.value=n,this.material.uniformsNeedUpdate=!0)}getSplatDataTextures(){return this.splatDataTextures}getSplatCount(){return this.splatCount}getCenters(){return this.centers}getColors(){return this.colors}getCovariances(){return this.covariances}dispose(){this.geometry.dispose(),this.material.dispose(),this.splatDataTextures&&(this.splatDataTextures.covariances.texture.dispose(),this.splatDataTextures.centerColors.texture.dispose(),this.splatDataTextures.meshMatrixWorlds.texture.dispose()),this.removeFromParent()}};var Y1,Qh=new Promise(i=>{Y1=i}),X1=!1;var np;function Zh(){if(X1)return;if(np)return np;async function i(){let e=await import("./gaussian-splat-compression.js");Y1(e),X1=!0}return np=i(),np}var K1;Qh.then(i=>K1=i);var pc=class{constructor(t={}){yn(this,"updateView",function(){let t=new xr.Matrix4,e=[],r=new xr.Vector3(0,0,-1),o=new xr.Vector3(0,0,-1),n=new xr.Vector3,a=new xr.Vector3;return function(s=!1,l){let c=this.updateMatrixWorldsInWorkerIfNeeded(),u=this.cropsChanged();if(!s){o.set(0,0,-1).applyQuaternion(l.quaternion);let d=!1,f=!1;if(o.dot(r)<=.95&&(d=!0),a.copy(l.position).sub(n).length()>=1&&(f=!0),!d&&!f&&!c&&!u&&!this.needsInitialRender)return}this.needsInitialRender=!1,n.copy(l.position),r.copy(o),t.copy(l.matrixWorld).invert(),t.premultiply(this.dummyPerspectiveMatrix),e[0]=l.position.x,e[1]=l.position.y,e[2]=l.position.z;let p={sort:{view:t.elements,cameraPosition:e,splatRenderCount:this.splatRenderCount,splatSortCount:this.splatRenderCount},...c?{newMatrixWorlds:this.meshMatrixWorlds}:{},...u?{newCropsArray:this.cropsArray}:{}};this.sortRunning?this.queuedMessage=p:(this.queuedMessage=null,this.sortRunning=!0,this.sortWorker.postMessage(p))}}());this.scene=t.scene,this.currentPage=null,this.devicePixelRatio=window.devicePixelRatio,this.sortWorker=null,this.splatRenderCount=0,this.splatSortCount=0,this.splatMesh=null,this.sortRunning=!1,this.meshMatrixWorlds=null,this.meshMatrixWorldsOld=null,this.cropsArray=null,this.splatEntries=null,this.queuedMessage=null,this.needsInitialRender=!0,this.dummyPerspectiveMatrix=new xr.Matrix4().makePerspective(-1,1,-1,1,.1,1e3)}updateSplatMeshUniforms(t,e){let r=new xr.Vector2;if(this.splatMesh===null)return;this.splatMesh.getSplatCount()>0&&(t.getSize(r),this.cameraFocalLengthX=e.projectionMatrix.elements[0]*this.devicePixelRatio*r.x*.45,this.cameraFocalLengthY=e.projectionMatrix.elements[5]*this.devicePixelRatio*r.y*.45,this.splatMesh.updateUniforms(r,this.cameraFocalLengthX,this.cameraFocalLengthY,e.isPerspectiveCamera?-1:e.zoom*this.devicePixelRatio))}loadSplat(t={}){this.activePage=this.scene.activePage,t.position&&(t.position=new xr.Vector3().fromArray(t.position)),t.orientation&&(t.orientation=new xr.Quaternion().fromArray(t.orientation)),t.halfPrecisionCovariances=!!t.halfPrecisionCovariances;let e=[];if(this.splatEntries=e,this.activePage.traverseVisibleEntity(a=>{a.data.type==="Splat"&&e.push(a)}),this.splatMesh&&this.splatMesh.dispose(),e.length===0)return this.splatMesh=null,!1;this.meshMatrixWorlds=e.map(a=>a.matrixWorld),this.meshMatrixWorldsOld=e.map(a=>a.matrixWorld.clone()),this.cropsArray=e.map(a=>a.data.crops.map(s=>s.data));let r=e.map(a=>new K1.GSplineBuffer(new Uint8Array(a.data.buffer).buffer)),o=0,n=[0];for(let a of r)o+=a.getSplatCount(),n.push(o);return this.setupSplatMesh(r,o,t.position,t.orientation,t.halfPrecisionCovariances,this.devicePixelRatio,n,this.meshMatrixWorlds),this.setupSortWorker(o),!0}updateMatrixWorldsInWorkerIfNeeded(){let t=this.splatDataTextures.meshMatrixWorlds.data;for(let e=0;e<this.meshMatrixWorlds.length;e++)t.set(this.meshMatrixWorlds[e].elements,e*16);return this.splatDataTextures.meshMatrixWorlds.texture.needsUpdate=!0,this.meshMatrixWorlds.every((e,r)=>e.equals(this.meshMatrixWorldsOld[r]))?!1:(this.meshMatrixWorldsOld=this.meshMatrixWorlds.map(e=>e.clone()),!0)}cropsChanged(){let t=!1;return this.splatEntries.forEach((e,r)=>{e.data.crops.forEach((o,n)=>{this.cropsArray[r][n]===void 0?(t=!0,this.cropsArray[r][n]=o.data):Object.entries(o.data).forEach(([a,s])=>{Array.isArray(s)&&s.some((l,c)=>l!==this.cropsArray[r][n][a][c])?(t=!0,this.cropsArray[r][n][a]=s):s!==this.cropsArray[r][n]?.[a]&&(t=!0,this.cropsArray[r][n][a]=s)})}),e.data.crops.length!==this.cropsArray[r]?.length&&(this.cropsArray[r].length=e.data.crops.length,t=!0)}),t}setupSplatMesh(t,e,r=new xr.Vector3,o=new xr.Quaternion,n=!1,a=1,s,l){this.splatMesh=un.buildMesh(t,e,n,a,s,l),this.splatMesh.position.copy(r),this.splatMesh.quaternion.copy(o),this.splatMesh.frustumCulled=!1,this.splatMesh.renderOrder=99999,this.splatRenderCount=e,this.splatMesh.onBeforeRender=(c,u,p)=>this.update(c,p)}setupSortWorker(t){this.sortWorker=q1(t),this.sortWorker.onmessage=e=>{e.data.sortDone?(this.sortRunning=!1,this.splatMesh?.updateIndexes(new Uint32Array(e.data.indexesBuffer)),this.lastSortTime=e.data.sortTime,this.queuedMessage&&(this.sortWorker.postMessage(this.queuedMessage),this.queuedMessage=null)):e.data.sortCanceled?this.sortRunning=!1:e.data.sortSetupPhase1Complete?this.sortWorker.postMessage({positions:this.splatMesh.getCenters().buffer,meshMatrixWorlds:this.splatMesh.meshMatrixWorlds,meshIndexIntervals:this.splatMesh.meshIndexIntervals,cropsArray:this.cropsArray}):e.data.sortSetupComplete&&(this.splatDataTextures=this.splatMesh.getSplatDataTextures(),this.scene.activePage.add(this.splatMesh),this.needsInitialRender=!0)}}update(t,e){this.splatMesh!==null&&(this.updateSplatMeshUniforms(t,e),this.updateView(!1,e))}getSplatMesh(){return this.splatMesh}};var OE=new eo.MeshBasicMaterial;OE.wireframe=!0;var Q1=new eo.Vector3,ap=class extends eo.Scene{constructor(e,r){super();this.data=e;this.sharedAssets=r;this.enableHelpers=!1;this.wireframeState=!1;this.needsTransmissionDirty=!0;this.needsNormalDirty=!0;this._needsTransmission=!1;this._needsNormal=!1;this.geometryCacheChanged=!1;this.splatViewer=null;this.shapeBlendIntances=[];this.entityByUuid={};this.entityIdentityToEntity={};this.toExpandCloner=new Set;this.toUpdateCloner=new Set;this.pendingCommands=[];this.pathConstraints=new tp;this.invisibleObjects=new tn("jflkdsafjasdifjaslk",{...Pu.defaultData,visible:!1,name:"buildin invisible"});this.needsRecomputeInstances=!1;this.init(e,r),this.matrixAutoUpdate=!1,this.errorPage=new Zr("fdasfa",{...ti.defaultData,name:""},{shared:r,scene:this})}markGeometryCacheDirty(){this.geometryCacheChanged=!0}markNeedsUpdateRendererDirty(){this.needsTransmissionDirty=!0,this.needsNormalDirty=!0}needsTransmission(){return this.needsTransmissionDirty&&(this._needsTransmission=H1(this),this.needsTransmissionDirty=!1),this._needsTransmission}needsNormal(){return this.needsNormalDirty&&(this._needsNormal=k1(this),this.needsNormalDirty=!1),this._needsNormal}registerInstanceAndSetUuid(e){let r=e.identity.join("-"),o=this.entityIdentityToEntity[r];o&&(e.uuid=o.uuid),this.entityIdentityToEntity[r]=e,this.entityByUuid[e.uuid]=e}markPenumbraSizeDirty(){for(let e of this.children)e instanceof Zr&&(e.penumbraSizeArrayCache=null)}findInstance(e){return this.entityIdentityToEntity[e.join("-")]}get bgColor(){return this.activePage.bgColor}get postprocessing(){return this.activePage.data.postprocessing}getWithSortKey(e){let r=this.find(e);if(r===void 0)return;let o=[],n=r;for(;n!==this;){let a=n;n=n.parent;let s=n.children.indexOf(a);o.splice(0,0,s)}return{entity:r,sortKey:o}}getAllSorted(e){let r=[];for(let o of e){let n=this.getWithSortKey(o.id);n!==void 0&&r.push(n)}return r.sort((o,n)=>Sc(o.sortKey,n.sortKey)),r.map(o=>o.entity)}nonExistOrDescendantOf(e,r){let o=this.find(e);if(o===void 0)return!0;for(;o;){if(o.uuid===r)return!0;o=o.parent}return!1}find(e){if(this.activePage&&this.activePage.personalCamera.parent){if(e==="f23858d0-4a3b-4bd8-8173-66ed0af7f6fb-personalCamera")return this.activePage.personalCamera;if(e===_i)return this.activePage.personalCamera}if(e===""||e===void 0)return;let r=this.entityByUuid[e];return r===void 0?this.getObjectByProperty("uuid",e):r}find2D(e){for(let r of this.children)if(r instanceof Zr&&r.uiScene){let o=r.uiScene.find(e);if(o)return o}}findScene2DfromObject2D(e){for(let r of this.children)if(r instanceof Zr&&r.uiScene&&r.uiScene.find(e))return r.uiScene}find2DInUIObjects(e){let r;return this.traverseEntity(o=>{r===void 0&&o instanceof Hn&&(r=o.uiCanvas.find(e))}),r}traverse2D(e){for(let r of this.children)r instanceof Zr&&r.uiScene&&r.uiScene.traverse(e)}debugEnsureEntity(e){let r=this.find(e);if(r){if(Array.isArray(r.identity)&&this.findInstance(r.identity)===void 0){console.error("not found instance");debugger}}else{console.error("not found");debugger}}addPendingExpandCloner(e){this.toExpandCloner.add(e)}addPendingUpdateCloner(e){this.toUpdateCloner.add(e)}markToExpandCloner(e){this.toExpandCloner.add(e),e.traverseEntityAncestors(r=>{this.toExpandCloner.add(r)})}doPendingExpandCloner(){this.toExpandCloner.forEach(e=>{e.expandCloner(this)}),this.toExpandCloner.clear()}doPendingUpdateCloner(){this.toUpdateCloner.forEach(e=>{e.cloner?.update()}),this.toUpdateCloner.clear()}doPendingUpdates(){this.doPendingExpandCloner(),this.doPendingUpdateCloner(),this.applyPendingCommands()}addPendingCommand(e){this.pendingCommands.push(e)}applyPendingCommands(){this.pendingCommands.forEach(e=>e()),this.pendingCommands.length=0}updateByLibOp(e,r){e.path.length===1&&e.path[0]==="components"&&e.type===1&&this.createChildrenObjects([{...e.data.asset,id:e.id}],this.invisibleObjects,r)}updateTreeByOp(e,r){if(e.path.length===0&&e.type===7){let o=e.parent===null?this:this.find(e.parent);if(o===void 0)throw new Error("unexpected");let n=this.createObject(e.id,e.data,e.children,o,e.localIndex,r);n.updateVisible(this),n.resetBBoxNeedsUpdate(),en(n)&&rc(n.parent)&&(n.invalidateUpstreamBooleanData(),n.parent.invalidateDownstreamBooleanData().recomputeBoolean()),this.markNeedsRecomputeInstancesForAncessors(o),this.markNeedsRecomputeInstancesForChildren(n),this.markToExpandCloner(n),this.markPenumbraSizeDirty(),n.updatePathSnapping()}else if(e.path.length===0&&e.type===8){let o=this.find(e.id);if(o===void 0)throw new Error("unexpected");o.traverseEntity(a=>{a instanceof sn&&(this.shapeBlendIntances=this.shapeBlendIntances.filter(s=>s!==a))}),this.markToExpandCloner(o),o.resetBBoxNeedsUpdate(),this.unregisterObject(o);let n=o.parent;this.markNeedsRecomputeInstancesForAncessors(n),this.markNeedsRecomputeInstancesForChildren(o),this.markPenumbraSizeDirty(),o.parent.remove(o),rc(o.parent)&&(o.parent.invalidateUpstreamBooleanData(),o.parent.invalidateDownstreamBooleanData().recomputeBoolean()),en(o)&&(o.freeBooleanPointer(),n instanceof Ar&&n.invalidateDownstreamBooleanData().recomputeBoolean()),o instanceof Hs&&o.detachShape(),this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(o),this.pathConstraints.removeDependencies(o.uuid),o.updatePathSnapping()}else if(e.path.length===0&&e.type===9){let o=this.find(e.id);if(o===void 0)throw new Error("unexpected");this.markNeedsRecomputeInstancesForChildren(o);let n=o.parent;this.markNeedsRecomputeInstancesForAncessors(n),o.cloner?.resetOnMove(),this.markToExpandCloner(o);let a=e.parent===null?this:this.find(e.parent);if(a===void 0)throw new Error("unexpected");a.add(o),this.markNeedsRecomputeInstancesForAncessors(a),this.markToExpandCloner(o),o.invalidateClonerTransform(o),o.updateVisible(this),o.resetBBoxNeedsUpdate(),this.markPenumbraSizeDirty();let s=e.localIndex;a.children.splice(s,0,a.children.pop()),en(o)&&(o.invalidateUpstreamBooleanData(),rc(o.parent)?o.parent.invalidateDownstreamBooleanData().recomputeBoolean():n instanceof Ar&&n.invalidateDownstreamBooleanData().recomputeBoolean()),o.updatePathSnapping()}this.markNeedsUpdateRendererDirty(),this.markGeometryCacheDirty()}get playPage(){return this.find(this.data.publish.playPage)??this.errorPage}updatePage(e){this.activePage&&this.activePage.onDeactive(),this.activePage=this.errorPage;for(let r of this.children)r instanceof Zr&&(r.visible=r.uuid===e,r.visible&&(this.activePage=r,this.activePage.onActive(this)));this.activePage!==this.splatViewer?.activePage&&this.reloadSplats()}updateEntityByOp(e,r,o,n){if(r.type===0){if(("overrides"in r.props||"component"in r.props)&&this.markNeedsRecomputeInstances(),"visible"in r.props&&this.markPenumbraSizeDirty(),r.path.includes("overrides")&&"states"in r.props){let{rest:s}=r.props;r={...r,props:s},this.markNeedsRecomputeInstances()}r.path[0]==="pathSnapping"&&r.props.pathId!==void 0&&this.pathConstraints.setConstraint(e,r.props.pathId)}let a=this.find(e);if(a)try{V1(a,r,o,{scene:this,shared:n}),a instanceof ft&&a.updateGeometryGroupsIfNeeded()}catch(s){console.error(s)}}updateEntity2DByOp(e,r,o,n,a,s=[]){e.updateEntityByOp(r,o,n,a),this.traverseEntity(l=>{(l instanceof Hn||l instanceof Zr)&&(s.includes(l.frameId??"")||l.frameId===r)&&l.updateEntity2DByOp(r,o,n,a)})}get activeCamera(){return this.activePage.activeCamera}switchActiveCamera(e){this.activePage.switchActiveCamera(e)}isInvisibleObjects(e){return e===this.invisibleObjects||e.hasAnccestor(this.invisibleObjects)}init(e,r){let o=Object.entries(r.data.lib.components).map((n,a)=>({data:n[1].asset.data,children:n[1].asset.children,id:n[0],fi:a}));this.invisibleObjects.updateState(this.invisibleObjects.data,{scene:this,shared:r}),this.add(this.invisibleObjects),this.createChildrenObjects(o,this.invisibleObjects,r),this.createChildrenObjects(e.objects,this,r),this.updatePage(e.publish.playPage),this.activePage.switchToPlayCamera(),this.expandInstances(r,!0),this.traverseEntity(n=>{n instanceof yi&&n.updateUp()}),this.doPendingExpandCloner(),this.applyPendingCommands()}markNeedsRecomputeInstances(){this.needsRecomputeInstances=!0}markNeedsRecomputeInstancesForChildren(e){e.traverseEntity(r=>{(r.data.type==="Component"||r.data.type==="Instance")&&this.markNeedsRecomputeInstances()})}markNeedsRecomputeInstancesForAncessors(e){ze.is(e)&&(e.data.type==="Component"&&this.markNeedsRecomputeInstances(),e.traverseAncestors(r=>{ze.is(r)&&r.data.type==="Component"&&this.markNeedsRecomputeInstances()}))}relativeizeInner(e,r,o,n,a,s,l){if(e){let c=n.find(e);c&&c!==n&&a.forInstancesRec(u=>{u.data=Ai(u.data,p=>{let d=p.events.data(l.id),f=u.goUp(s);if(f){let h=[...vc(f.identity),e].join("-"),m=this.entityIdentityToEntity[h];if(m){let y=m.uuid,b=ut.zoom(d,r);b[o]=y}else{if(!1)debugger;console.warn("cannot find instance")}}}).data})}}rewriteActions(e,r,o,n,a,s){e.forEach(l=>{l.data.type==="Transition"?this.relativeizeInner(l.data.object,[...r,l.id],"object",o,n,a,s):l.data.type==="Animation"?this.relativeizeInner(l.data.object,[...r,l.id],"object",o,n,a,s):l.data.type==="Conditional"&&(this.rewriteActions(l.data.ifActions,[...r,l.id,"ifActions"],o,n,a,s),this.rewriteActions(l.data.elseActions,[...r,l.id,"elseActions"],o,n,a,s))})}rewriteEventsBeforeGoToPlayMode(){this.traverseEntity(e=>{if(e instanceof bi&&typeof e.identity=="string"&&e.data.type==="Component")return e.traverseEntity((r,o)=>{r.data.events.forEach(n=>{if(n.data.type==="GameControl"){let a=!1;if(r.forInstancesRec(s=>{s.data=Ai(s.data,l=>{s.isInstanceRoot||(l.events.delete(n.id),a=!0)}).data}),a===!1)for(let s of Au.list)this.rewriteActions(n.data.gameActions[s],["gameActions",s],e,r,o,n)}else n.data.type==="Conditional"?(n.data.condition.type==="Distance"?(this.relativeizeInner(n.data.condition.fromObject,["condition"],"fromObject",e,r,o,n),this.relativeizeInner(n.data.condition.toObject,["condition"],"toObject",e,r,o,n)):n.data.condition.type==="State"?this.relativeizeInner(n.data.condition.object,["condition"],"object",e,r,o,n):n.data.condition.type==="Comparison"&&(n.data.condition.lOperand.type==="Property"&&this.relativeizeInner(n.data.condition.lOperand.value[0],["condition","lOperand","value"],0,e,r,o,n),n.data.condition.rOperand.type==="Property"&&this.relativeizeInner(n.data.condition.rOperand.value[0],["condition","rOperand","value"],0,e,r,o,n)),this.rewriteActions(n.data.inActions,["inActions"],e,r,o,n),this.rewriteActions(n.data.outActions,["outActions"],e,r,o,n)):"actions"in n.data&&this.rewriteActions(n.data.actions,["actions"],e,r,o,n)})}),!0})}expandInstances(e,r,o){let n=new Set;this.traverseEntity(a=>{if(a instanceof bi&&a.isInstanceRoot)return a.expandInstanceChildren({scene:this,shared:e,pendingDeletes:n}),r||a.resetBBoxNeedsUpdate(),o&&a.traverseEntity(s=>{o.addClip(s)}),!0});for(let a of n)this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(a),Xd(a)}recomputeInstances(e,r){this.needsRecomputeInstances&&(this.needsRecomputeInstances=!1,this.traverseEntity(o=>{o instanceof bi&&o.isInstanceRoot&&(o.component=void 0)}),this.expandInstances(e,!1,r))}disposeAndUnregisterEntityRecursivelyIfNotReregistered(e){e.traverseEntity(r=>{let o=typeof r.identity=="string"?r.identity:r.identity.join("-");this.entityIdentityToEntity[o]===r&&(delete this.entityByUuid[r.uuid],delete this.entityIdentityToEntity[o]),r.dispose()})}clearScene(){for(let e of this.children)ze.is(e)&&e.disposeRecursively();this.children.length=0}resetAfterClear(e,r){this.init(e,r)}raycast(e){return this.raycast1(e,!1)}raycast1(e,r){let o=[],n=a=>{for(let s of a.children){let l=s.cloner;if(ze.is(s)&&!s.raycastLock&&(s.visible||l?.object.data.visible))if(r===!0&&s.isInstanceRoot){let c=[];if(e.intersectObject(s,!0,c),c.length){let u=c[0];u.object=s,u.point.applyMatrix4(u.object.matrixWorld);let p=s.matrixWorld.clone().invert();u.point.applyMatrix4(p),o.push(u)}}else(en(s)||oc(s)&&this.enableHelpers&&s.objectHelper.visible)&&(e.intersectObject(s,!1,o),uc(s,e,o)),n(s)}};return n(this.activePage),o}raycastWithClones(e){let r=[],o=n=>{for(let a of n.children){let s=a.cloner;ze.is(a)&&(a.visible||s?.object.data.visible)&&((en(a)||oc(a)&&this.enableHelpers&&a.objectHelper.visible)&&(e.intersectObject(a,!1,r),uc(a,e,r,!0)),o(a))}};return o(this),r}forEachEntity(e){for(let r of this.children)ze.is(r)&&e(r)}traverseConcreteEntity(e){for(let r of this.children)ze.is(r)&&r.isConcreteEntity&&r.traverseEntity(e)}traverseEntity(e){for(let r of this.children)ze.is(r)&&r.traverseEntity(e)}updateFont(e,r){this.traverseEntity(o=>{if(o instanceof ft&&o.data.type==="Mesh"&&(o.data.geometry.type==="TextGeometry"||o.data.geometry.type==="InputGeometry")&&o.data.geometry.font===e){let n=o.geometry,a=o.data.geometry;n.updateFont(e,r).then(()=>{n.update(a,r);let s=o.invalidateDownstreamBooleanData();rc(s)&&s.recomputeBoolean()})}})}traverseObject(e){for(let r of this.children)si.is(r)&&r.traverseObject(e)}traverseVisibleEntity(e){for(let r of this.children)ze.is(r)&&r.visible&&r.traverseVisibleEntity(e)}dispose(){this.clearScene()}createChildrenObjects(e,r,o){let n=0;for(let a of e)this.createObject(a.id,a.data,a.children,r,n,o),n+=1}registerObjectCreatedInLegacy(e){this.entityByUuid[e.uuid]=e}unregisterObject(e){delete this.entityByUuid[e.uuid];for(let r of e.children)this.unregisterObject(r)}createObject(e,r,o,n,a,s){let l={scene:this,shared:s},c=Zd(e,r,l);return c instanceof sn&&this.shapeBlendIntances.push(c),c&&(this.entityByUuid[e]=c,n.add(c),n.children.splice(a,0,n.children.pop()),o.length>0&&(c.isInstanceRoot?console.error("instance should not have children!"):this.createChildrenObjects(o,c,s)),c.updateState(r,l),c instanceof ft&&c.updateGeometryGroupsIfNeeded(),c.updateVisible(this),c.cloner&&this.toExpandCloner.add(c),r.pathSnapping?.pathId&&this.pathConstraints.setConstraint(e,r.pathSnapping.pathId)),r.type==="Empty"&&r.animations&&c.traverseEntity(u=>{let p=u.dataPatched;if(u instanceof ft&&p.bones&&p.boneInverses){let d=p.bones.map(m=>this.find(m)),f=p.boneInverses.map(m=>new eo.Matrix4().fromArray(m)),h=new eo.Skeleton(d,f);u.bind(h,u.bindMatrix)}else u.matrixAutoUpdate=!0}),c}getCenter(e){let r=[];for(let n=0,a=e.length;n<a;++n){let{id:s,recursive:l}=e[n],c=this.find(s),u=l?c.recursiveBBox:c.singleBBox;r.push(...u.vertices)}let o=new eo.Box3;return o.setFromPoints(r),o.getCenter(Q1),Q1}copyMatrixWorld(e,r){if(e===null){r.identity();return}let o=this.find(e);o?r.copy(o.matrixWorld):r.identity()}copyParentMatrixWorld(e,r){if(e===null){r.identity();return}let o=this.find(e)?.parent;o?r.copy(o.matrixWorld):r.identity()}traverseMaterial(e){this.traverseEntity(r=>{if(r instanceof Wt)if(Array.isArray(r.material))for(let o=0;o<r.material.length;o++)r.material[o]instanceof Tr&&e(r.material[o]);else r.material instanceof Tr&&e(r.material)})}updateViewPlaneSize(e,r,o=!1){this.traverseConcreteEntity(n=>{n instanceof yi&&n.setViewplaneSize(e,r,o)})}initializeSplatViewer(){this.splatViewer=new pc({scene:this}),this.reloadSplats()}reloadSplats(){this.splatViewer?.loadSplat()}};var Z1=require("three/examples/jsm/loaders/DRACOLoader.js");var dn;function J1(i){return dn||(dn=new Z1.DRACOLoader,dn.setDecoderPath(i?`${i}/`:"https://www.gstatic.com/draco/versioned/decoders/1.5.2/").preload()),dn.decoderPending}async function TE(i){if(dn){let t={attributeIDs:dn.defaultAttributeIDs,attributeTypes:dn.defaultAttributeTypes,useUniqueIDs:!1},e;try{e=await dn.decodeGeometry(new Int8Array(i).buffer,t)}catch(r){console.error(r)}if(e)return{index:e.index?{array:e.index.array}:void 0,attributes:Object.entries(e.attributes).map(([r,o])=>({name:r,itemSize:o.itemSize,array:o.array}))}}return null}async function eS(i,t){let[e,r]=Dp(uu.deserialize(new Uint8Array(i)));return Iu(e),t&&t(e),r.result().data}function tS(i){let t=[];return i.scene.objects.traverse((e,r)=>{r.type==="Mesh"&&r.geometry.type==="NonParametricGeometry"&&r.geometry.data.draco!==void 0&&t.push(r)}),t}async function rS(i){for(let t of i){let e=await TE(t.geometry.data.draco);if(e){let r=t.geometry.data;e.index&&(r.index={array:e.index.array,itemSize:1,normalized:!1,type:"Uint32Array"});let o={};e.attributes.forEach(({name:n,array:a,itemSize:s})=>{o[n]={array:a,itemSize:s,type:"Float32Array",normalized:!1}}),r.attributes=o,r.draco=void 0}}}var CE=require("three"),AE=require("three/examples/jsm/utils/BufferGeometryUtils.js");function oS(i){let t;if(!!i.index)for(let e=0;e<i.index.array.length;e+=3)t=i.index.array[e],i.index.array[e]=i.index.array[e+2],i.index.array[e+2]=t}var fc=require("three");function iS(i){let t=new Set;return i.traverse(e=>{if(e instanceof Cr)if(Ct(e.material))e.material.forEach(r=>{let o=r;t.has(o)||t.add(o)});else{let r=e.material;t.has(r)||t.add(r)}}),t.forEach(e=>{if(e instanceof Array)return;let r=e.onBeforeCompile.bind(e);if(ME(e)){Object.assign(e,{isMeshStandardMaterial:!0,isMeshPhysicalMaterial:!0,transmission:1,attenuationColor:new fc.Color,specularColor:new fc.Color});let o=0;e.onBeforeCompile=(n,a)=>{r&&r(n,a),n.uniforms=Object.assign({},fc.ShaderLib.physical.uniforms,n.uniforms),e.getLayersOfType("transmission").forEach(s=>{if(n.uniforms.transmissionSamplerMap.value){let l=s.color;l&&(l.transmissionSamplerMap.value=n.uniforms.transmissionSamplerMap.value,l.transmissionSamplerSize.value=n.uniforms.transmissionSamplerSize.value,l.aspectRatio.value=zb(window.innerWidth,window.innerHeight),e.defines.IS_THREEJS_EXPORT=!0)}else o++,o<2&&(e.needsUpdate=!0)})}}else IE(e)||(e.onBeforeCompile=(o,n)=>{r&&r(o,n),e.transparent=!1})}),i}function ME(i){return i.getLayersOfType("transmission").length>0}function IE(i){let t=0;for(let e of i.layers){if(e.data.type!=="displace"&&e.data.isMask)return!0;if(e.type!=="light"&&e.type!=="fresnel"){let o=e.uniforms["f"+e.id+"_alpha"];o&&(t+=(1-t)*o.value)}}return t<1}function nS(i){return i.traverse(t=>{if(t.type==="Camera"){let e=t;e.type=e.cameraType}}),i}function aS(i){let t=[],e=(r,o=0)=>{let n=o>0?r+o:r;return t.includes(n)?e(r,o+1):n};return i.traverse(r=>{if(t.includes(r.name)){let o=r.name,n=e(r.name);if(r.name=n,r.isMesh){let a=r;a.material instanceof Array?a.material.forEach(s=>{s.name=s.name.replace(o,n)}):a.material.isAsset||(a.material.name=a.material.name.replace(o,n))}}t.push(r.name)}),i}var sS=require("three/examples/jsm/utils/BufferGeometryUtils.js");function lS(i){let t=[];return i.traverse(e=>{e instanceof Zi&&t.push(e)}),t.forEach(e=>{let r=e.object,a=[...e.children.map(s=>{s.updateMatrix();let l;if(s.geometry!==void 0)try{l=s.geometry.clone().applyMatrix4(s.matrix)}catch(c){console.error(c)}return l!==void 0&&s.matrix.determinant()<0&&oS(l),l}).filter(s=>s!==void 0)];if(!e.parameters.hideBase&&r instanceof Wt&&a.unshift(r.geometry),a.length){let s=(0,sS.mergeBufferGeometries)(a);r instanceof Wt&&(r.geometry=s)}e.removeFromParent(),r.setFromClonerState(null,{scene:i,shared:ov})}),i}function cS(i){return i.traverse(t=>{t.matrixAutoUpdate=!0}),i}function uS(i){Object.values(i.shared.materials).forEach(t=>{Jh(t)}),i.scene.objects.traverse((t,e)=>{"material"in e?Jh(e.material):"materials"in e&&e.materials.forEach(r=>{Jh(r)})})}function Jh(i){if(typeof i=="string")return;let t=[];i.layers.forEach((e,r)=>{e.type==="outline"&&t.push(r)}),t.reverse().forEach(e=>{i.layers.delete(e)}),t.length&&console.warn("The Spline Loader currently does not support the outline layer.")}var hS=tl(pS(),1);var fS="The SplineLoader only accepts .splinecode files that are generated from Spline export panel.",sp=class extends lp.Loader{load(t,e,r,o=console.error){let n=new lp.FileLoader(this.manager);n.setPath(this.path),n.setResponseType("arraybuffer"),n.setRequestHeader(this.requestHeader),n.setWithCredentials(this.withCredentials),t.endsWith(".spline")?console.warn(fS+" The .spline files are only meant to be used by the Editor."):t.endsWith(".splinecode")||console.warn(fS),n.load(t,async a=>{try{if(typeof a=="string")throw new Error("The .spline file is not binary!");let s=await this.parse(a);e(s)}catch(s){o(s)}},r,o)}async parse(t){let e=await eS(t,uS),r=tS(e);e.version&&(0,hS.default)(e.version,"1.10.78")>0&&console.warn("Your .splinecode file is more recent than the library. Please upgrade @splinetool/loader to the latest version."),await Promise.allSettled([r.length&&J1(),lv(e)&&pb(),xv(e)&&Kb(),Zv(e)&&Yv(),ip(e)&&Zh()].filter(Boolean)),r.length&&await rS(r);let o=!1,n=new Gn(e.shared,{},o);Object.values(n.getMaterials()).forEach(l=>Object.assign(l,{isAsset:!0}));let a=new ap(e.scene,n);ip(e)&&a.initializeSplatViewer();let s=a.activeCamera;return s&&Object.assign(s,{makeDefault:!0}),a=lS(a),a=iS(a),a=nS(a),a=aS(a),a=cS(a),a}};