@splinetool/loader 1.12.42 → 1.12.44

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
- "use strict";var jS=Object.create;var al=Object.defineProperty;var US=Object.getOwnPropertyDescriptor;var kS=Object.getOwnPropertyNames;var HS=Object.getPrototypeOf,WS=Object.prototype.hasOwnProperty;var qS=(i,t,e)=>t in i?al(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e;var sl=(i,t)=>()=>(t||i((t={exports:{}}).exports,t),t.exports),gm=(i,t)=>{for(var e in t)al(i,e,{get:t[e],enumerable:!0})},xm=(i,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of kS(t))!WS.call(i,o)&&o!==e&&al(i,o,{get:()=>t[o],enumerable:!(r=US(t,o))||r.enumerable});return i};var ll=(i,t,e)=>(e=i!=null?jS(HS(i)):{},xm(t||!i||!i.__esModule?al(e,"default",{value:i,enumerable:!0}):e,i)),$S=i=>xm(al({},"__esModule",{value:!0}),i);var wn=(i,t,e)=>(qS(i,typeof t!="symbol"?t+"":t,e),e);var ax=sl((bf,nx)=>{(function(i,t){typeof bf=="object"?nx.exports=t():typeof define=="function"&&define.amd?define(t):i.Alea=t()})(bf,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 fx=sl((Wu,px)=>{(function(i,t){typeof Wu=="object"&&typeof px<"u"?t(Wu):typeof define=="function"&&define.amd?define(["exports"],t):t((i=typeof globalThis<"u"?globalThis:i||self).SVDJS={})})(Wu,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,d,p,f,h,m,y,g,b=t[0].length,w=t.length;if(w<b)throw new TypeError("Invalid matrix: m < n");for(var P=[],S=[],T=[],A=e==="f"?w:b,x=m=p=0;x<w;x++)S[x]=new Array(A).fill(0);for(x=0;x<b;x++)T[x]=new Array(b).fill(0);var N,E=new Array(b).fill(0);for(x=0;x<w;x++)for(a=0;a<b;a++)S[x][a]=t[x][a];for(x=0;x<b;x++){for(P[x]=p,h=0,l=x+1,a=x;a<w;a++)h+=Math.pow(S[a][x],2);if(h<n)p=0;else for(f=(d=S[x][x])*(p=d<0?Math.sqrt(h):-Math.sqrt(h))-h,S[x][x]=d-p,a=l;a<b;a++){for(h=0,s=x;s<w;s++)h+=S[s][x]*S[s][a];for(d=h/f,s=x;s<w;s++)S[s][a]=S[s][a]+d*S[s][x]}for(E[x]=p,h=0,a=l;a<b;a++)h+=Math.pow(S[x][a],2);if(h<n)p=0;else{for(f=(d=S[x][x+1])*(p=d<0?Math.sqrt(h):-Math.sqrt(h))-h,S[x][x+1]=d-p,a=l;a<b;a++)P[a]=S[x][a]/f;for(a=l;a<w;a++){for(h=0,s=l;s<b;s++)h+=S[a][s]*S[x][s];for(s=l;s<b;s++)S[a][s]=S[a][s]+h*P[s]}}m<(y=Math.abs(E[x])+Math.abs(P[x]))&&(m=y)}if(r)for(x=b-1;0<=x;x--){if(p!==0){for(f=S[x][x+1]*p,a=l;a<b;a++)T[a][x]=S[x][a]/f;for(a=l;a<b;a++){for(h=0,s=l;s<b;s++)h+=S[x][s]*T[s][a];for(s=l;s<b;s++)T[s][a]=T[s][a]+h*T[s][x]}}for(a=l;a<b;a++)T[x][a]=0,T[a][x]=0;T[x][x]=1,p=P[x],l=x}if(e){if(e==="f")for(x=b;x<w;x++){for(a=b;a<w;a++)S[x][a]=0;S[x][x]=1}for(x=b-1;0<=x;x--){for(l=x+1,p=E[x],a=l;a<A;a++)S[x][a]=0;if(p!==0){for(f=S[x][x]*p,a=l;a<A;a++){for(h=0,s=l;s<w;s++)h+=S[s][x]*S[s][a];for(d=h/f,s=x;s<w;s++)S[s][a]=S[s][a]+d*S[s][x]}for(a=x;a<w;a++)S[a][x]=S[a][x]/p}else for(a=x;a<w;a++)S[a][x]=0;S[x][x]=S[x][x]+1}}for(o*=m,s=b-1;0<=s;s--)for(var M=0;M<50;M++){for(N=!1,l=s;0<=l;l--){if(Math.abs(P[l])<=o){N=!0;break}if(Math.abs(E[l-1])<=o)break}if(!N){for(u=0,c=l-(h=1),x=l;x<s+1&&(d=h*P[x],P[x]=u*P[x],!(Math.abs(d)<=o));x++)if(p=E[x],E[x]=Math.sqrt(d*d+p*p),u=p/(f=E[x]),h=-d/f,e)for(a=0;a<w;a++)y=S[a][c],g=S[a][x],S[a][c]=y*u+g*h,S[a][x]=-y*h+g*u}if(g=E[s],l===s){if(g<0&&(E[s]=-g,r))for(a=0;a<b;a++)T[a][s]=-T[a][s];break}for(m=E[l],d=(((y=E[s-1])-g)*(y+g)+((p=P[s-1])-(f=P[s]))*(p+f))/(2*f*y),p=Math.sqrt(d*d+1),d=((m-g)*(m+g)+f*(y/(d<0?d-p:d+p)-f))/m,x=l+(h=u=1);x<s+1;x++){if(p=P[x],y=E[x],f=h*p,p*=u,g=Math.sqrt(d*d+f*f),d=m*(u=d/(P[x-1]=g))+p*(h=f/g),p=-m*h+p*u,f=y*h,y*=u,r)for(a=0;a<b;a++)m=T[a][x-1],g=T[a][x],T[a][x-1]=m*u+g*h,T[a][x]=-m*h+g*u;if(g=Math.sqrt(d*d+f*f),d=(u=d/(E[x-1]=g))*p+(h=f/g)*y,m=-h*p+u*y,e)for(a=0;a<w;a++)y=S[a][x-1],g=S[a][x],S[a][x-1]=y*u+g*h,S[a][x]=-y*h+g*u}P[l]=0,P[s]=d,E[s]=m}for(x=0;x<b;x++)E[x]<o&&(E[x]=0);return{u:S,q:E,v:T}},i.VERSION="1.1.1",Object.defineProperty(i,"__esModule",{value:!0})})});var u1=sl((foe,c1)=>{"use strict";function aE(i,t){function e(){this.constructor=i}e.prototype=t.prototype,i.prototype=new e}function Yn(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,Yn)}aE(Yn,Error);Yn.buildMessage=function(i,t){var e={literal:function(c){return'"'+o(c.text)+'"'},class:function(c){var u="",d;for(d=0;d<c.parts.length;d++)u+=c.parts[d]instanceof Array?n(c.parts[d][0])+"-"+n(c.parts[d][1]):n(c.parts[d]);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),d,p;for(d=0;d<c.length;d++)u[d]=a(c[d]);if(u.sort(),u.length>0){for(d=1,p=1;d<u.length;d++)u[d-1]!==u[d]&&(u[p]=u[d],p++);u.length=p}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 sE(i,t){t=t!==void 0?t:{};var e={},r={svg_path:nl},o=nl,n=function(v){if(!v)return[];for(var O=[],L=0;L<v.length;L++)O=O.concat.apply(O,v[L]);var I=O[0];return I&&I.code=="m"&&(delete I.relative,I.code="M"),O},a=function(v,O){return FS(v,O)},s=/^[Mm]/,l=at(["M","m"],!1,!1),c=function(v,O,L){var I=ta(v,[O]);return L&&(I=I.concat(ta(v=="M"?"L":"l",L[1]))),I},u=/^[Zz]/,d=at(["Z","z"],!1,!1),p=function(){return ta("Z")},f=/^[Ll]/,h=at(["L","l"],!1,!1),m=function(v,O){return ta(v,O)},y=/^[Hh]/,g=at(["H","h"],!1,!1),b=function(v,O){return ta(v,O.map(function(L){return{x:L}}))},w=/^[Vv]/,P=at(["V","v"],!1,!1),S=function(v,O){return ta(v,O.map(function(L){return{y:L}}))},T=/^[Cc]/,A=at(["C","c"],!1,!1),x=function(v,O,L){return{x1:v.x,y1:v.y,x2:O.x,y2:O.y,x:L.x,y:L.y}},N=/^[Ss]/,E=at(["S","s"],!1,!1),M=function(v,O){return{x2:v.x,y2:v.y,x:O.x,y:O.y}},D=/^[Qq]/,_=at(["Q","q"],!1,!1),R=function(v,O){return{x1:v.x,y1:v.y,x:O.x,y:O.y}},V=/^[Tt]/,U=at(["T","t"],!1,!1),B=/^[Aa]/,q=at(["A","a"],!1,!1),j=function(v,O,L,I,z,oe){return{rx:v,ry:O,xAxisRotation:L,largeArc:I,sweep:z,x:oe.x,y:oe.y}},F=function(v,O){return{x:v,y:O}},H=function(v){return v*1},W=function(v){return v.join("")*1},ee=/^[01]/,te=at(["0","1"],!1,!1),Y=function(v){return v=="1"},re=function(){return""},K=",",Z=bt(",",!1),Q=function(v){return v.join("")},$=".",pe=bt(".",!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(v){return v.join("")},Se=/^[ \t\n\r]/,xe=at([" "," ",`
2
- `,"\r"],!1,!1),C=0,ne=0,ze=[{line:1,column:1}],He=0,Fe=[],Ae=0,Ut;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 Re(){return i.substring(ne,C)}function Ft(){return bn(ne,C)}function kt(v,O){throw O=O!==void 0?O:bn(ne,C),jr([vp(v)],i.substring(ne,C),O)}function xn(v,O){throw O=O!==void 0?O:bn(ne,C),Sp(v,O)}function bt(v,O){return{type:"literal",text:v,ignoreCase:O}}function at(v,O,L){return{type:"class",parts:v,inverted:O,ignoreCase:L}}function io(){return{type:"any"}}function bp(){return{type:"end"}}function vp(v){return{type:"other",description:v}}function Pc(v){var O=ze[v],L;if(O)return O;for(L=v-1;!ze[L];)L--;for(O=ze[L],O={line:O.line,column:O.column};L<v;)i.charCodeAt(L)===10?(O.line++,O.column=1):O.column++,L++;return ze[v]=O,O}function bn(v,O){var L=Pc(v),I=Pc(O);return{start:{offset:v,line:L.line,column:L.column},end:{offset:O,line:I.line,column:I.column}}}function Ct(v){C<He||(C>He&&(He=C,Fe=[]),Fe.push(v))}function Sp(v,O){return new Yn(v,null,null,O)}function jr(v,O,L){return new Yn(Yn.buildMessage(v,O),v,O,L)}function nl(){var v,O,L,I,z;for(v=C,O=[],L=We();L!==e;)O.push(L),L=We();if(O!==e)if(L=pr(),L===e&&(L=null),L!==e){for(I=[],z=We();z!==e;)I.push(z),z=We();I!==e?(ne=v,O=n(L),v=O):(C=v,v=e)}else C=v,v=e;else C=v,v=e;return v}function pr(){var v,O,L,I,z,oe;if(v=C,O=vn(),O!==e){for(L=[],I=C,z=[],oe=We();oe!==e;)z.push(oe),oe=We();for(z!==e?(oe=vn(),oe!==e?(z=[z,oe],I=z):(C=I,I=e)):(C=I,I=e);I!==e;){for(L.push(I),I=C,z=[],oe=We();oe!==e;)z.push(oe),oe=We();z!==e?(oe=vn(),oe!==e?(z=[z,oe],I=z):(C=I,I=e)):(C=I,I=e)}L!==e?(ne=v,O=a(O,L),v=O):(C=v,v=e)}else C=v,v=e;return v}function vn(){var v,O,L,I,z,oe;if(v=C,O=Jn(),O!==e){for(L=[],I=C,z=[],oe=We();oe!==e;)z.push(oe),oe=We();for(z!==e?(oe=Oc(),oe!==e?(z=[z,oe],I=z):(C=I,I=e)):(C=I,I=e);I!==e;){for(L.push(I),I=C,z=[],oe=We();oe!==e;)z.push(oe),oe=We();z!==e?(oe=Oc(),oe!==e?(z=[z,oe],I=z):(C=I,I=e)):(C=I,I=e)}L!==e?(ne=v,O=a(O,L),v=O):(C=v,v=e)}else C=v,v=e;return v}function Oc(){var v;return v=TS(),v===e&&(v=CS(),v===e&&(v=AS(),v===e&&(v=MS(),v===e&&(v=IS(),v===e&&(v=NS(),v===e&&(v=_S(),v===e&&(v=LS(),v===e&&(v=VS())))))))),v}function Jn(){var v,O,L,I,z,oe,ra;if(v=C,s.test(i.charAt(C))?(O=i.charAt(C),C++):(O=e,Ae===0&&Ct(l)),O!==e){for(L=[],I=We();I!==e;)L.push(I),I=We();L!==e?(I=hr(),I!==e?(z=C,oe=mt(),oe===e&&(oe=null),oe!==e?(ra=cm(),ra!==e?(oe=[oe,ra],z=oe):(C=z,z=e)):(C=z,z=e),z===e&&(z=null),z!==e?(ne=v,O=c(O,I,z),v=O):(C=v,v=e)):(C=v,v=e)):(C=v,v=e)}else C=v,v=e;return v}function TS(){var v,O;return v=C,u.test(i.charAt(C))?(O=i.charAt(C),C++):(O=e,Ae===0&&Ct(d)),O!==e&&(ne=v,O=p()),v=O,v}function CS(){var v,O,L,I;if(v=C,f.test(i.charAt(C))?(O=i.charAt(C),C++):(O=e,Ae===0&&Ct(h)),O!==e){for(L=[],I=We();I!==e;)L.push(I),I=We();L!==e?(I=cm(),I!==e?(ne=v,O=m(O,I),v=O):(C=v,v=e)):(C=v,v=e)}else C=v,v=e;return v}function cm(){var v,O,L,I,z,oe;if(v=C,O=hr(),O!==e){for(L=[],I=C,z=mt(),z===e&&(z=null),z!==e?(oe=hr(),oe!==e?(z=[z,oe],I=z):(C=I,I=e)):(C=I,I=e);I!==e;)L.push(I),I=C,z=mt(),z===e&&(z=null),z!==e?(oe=hr(),oe!==e?(z=[z,oe],I=z):(C=I,I=e)):(C=I,I=e);L!==e?(ne=v,O=a(O,L),v=O):(C=v,v=e)}else C=v,v=e;return v}function AS(){var v,O,L,I;if(v=C,y.test(i.charAt(C))?(O=i.charAt(C),C++):(O=e,Ae===0&&Ct(g)),O!==e){for(L=[],I=We();I!==e;)L.push(I),I=We();L!==e?(I=um(),I!==e?(ne=v,O=b(O,I),v=O):(C=v,v=e)):(C=v,v=e)}else C=v,v=e;return v}function um(){var v,O,L,I,z,oe;if(v=C,O=ea(),O!==e){for(L=[],I=C,z=mt(),z===e&&(z=null),z!==e?(oe=ea(),oe!==e?(z=[z,oe],I=z):(C=I,I=e)):(C=I,I=e);I!==e;)L.push(I),I=C,z=mt(),z===e&&(z=null),z!==e?(oe=ea(),oe!==e?(z=[z,oe],I=z):(C=I,I=e)):(C=I,I=e);L!==e?(ne=v,O=a(O,L),v=O):(C=v,v=e)}else C=v,v=e;return v}function MS(){var v,O,L,I;if(v=C,w.test(i.charAt(C))?(O=i.charAt(C),C++):(O=e,Ae===0&&Ct(P)),O!==e){for(L=[],I=We();I!==e;)L.push(I),I=We();L!==e?(I=um(),I!==e?(ne=v,O=S(O,I),v=O):(C=v,v=e)):(C=v,v=e)}else C=v,v=e;return v}function IS(){var v,O,L,I;if(v=C,T.test(i.charAt(C))?(O=i.charAt(C),C++):(O=e,Ae===0&&Ct(A)),O!==e){for(L=[],I=We();I!==e;)L.push(I),I=We();L!==e?(I=ES(),I!==e?(ne=v,O=m(O,I),v=O):(C=v,v=e)):(C=v,v=e)}else C=v,v=e;return v}function ES(){var v,O,L,I,z,oe;if(v=C,O=wp(),O!==e){for(L=[],I=C,z=mt(),z===e&&(z=null),z!==e?(oe=wp(),oe!==e?(z=[z,oe],I=z):(C=I,I=e)):(C=I,I=e);I!==e;)L.push(I),I=C,z=mt(),z===e&&(z=null),z!==e?(oe=wp(),oe!==e?(z=[z,oe],I=z):(C=I,I=e)):(C=I,I=e);L!==e?(ne=v,O=a(O,L),v=O):(C=v,v=e)}else C=v,v=e;return v}function wp(){var v,O,L,I,z,oe;return v=C,O=hr(),O!==e?(L=mt(),L===e&&(L=null),L!==e?(I=hr(),I!==e?(z=mt(),z===e&&(z=null),z!==e?(oe=hr(),oe!==e?(ne=v,O=x(O,I,oe),v=O):(C=v,v=e)):(C=v,v=e)):(C=v,v=e)):(C=v,v=e)):(C=v,v=e),v}function NS(){var v,O,L,I;if(v=C,N.test(i.charAt(C))?(O=i.charAt(C),C++):(O=e,Ae===0&&Ct(E)),O!==e){for(L=[],I=We();I!==e;)L.push(I),I=We();L!==e?(I=DS(),I!==e?(ne=v,O=m(O,I),v=O):(C=v,v=e)):(C=v,v=e)}else C=v,v=e;return v}function DS(){var v,O,L,I,z,oe;if(v=C,O=Pp(),O!==e){for(L=[],I=C,z=mt(),z===e&&(z=null),z!==e?(oe=Pp(),oe!==e?(z=[z,oe],I=z):(C=I,I=e)):(C=I,I=e);I!==e;)L.push(I),I=C,z=mt(),z===e&&(z=null),z!==e?(oe=Pp(),oe!==e?(z=[z,oe],I=z):(C=I,I=e)):(C=I,I=e);L!==e?(ne=v,O=a(O,L),v=O):(C=v,v=e)}else C=v,v=e;return v}function Pp(){var v,O,L,I;return v=C,O=hr(),O!==e?(L=mt(),L===e&&(L=null),L!==e?(I=hr(),I!==e?(ne=v,O=M(O,I),v=O):(C=v,v=e)):(C=v,v=e)):(C=v,v=e),v}function _S(){var v,O,L,I;if(v=C,D.test(i.charAt(C))?(O=i.charAt(C),C++):(O=e,Ae===0&&Ct(_)),O!==e){for(L=[],I=We();I!==e;)L.push(I),I=We();L!==e?(I=RS(),I!==e?(ne=v,O=m(O,I),v=O):(C=v,v=e)):(C=v,v=e)}else C=v,v=e;return v}function RS(){var v,O,L,I,z,oe;if(v=C,O=Op(),O!==e){for(L=[],I=C,z=mt(),z===e&&(z=null),z!==e?(oe=Op(),oe!==e?(z=[z,oe],I=z):(C=I,I=e)):(C=I,I=e);I!==e;)L.push(I),I=C,z=mt(),z===e&&(z=null),z!==e?(oe=Op(),oe!==e?(z=[z,oe],I=z):(C=I,I=e)):(C=I,I=e);L!==e?(ne=v,O=a(O,L),v=O):(C=v,v=e)}else C=v,v=e;return v}function Op(){var v,O,L,I;return v=C,O=hr(),O!==e?(L=mt(),L===e&&(L=null),L!==e?(I=hr(),I!==e?(ne=v,O=R(O,I),v=O):(C=v,v=e)):(C=v,v=e)):(C=v,v=e),v}function LS(){var v,O,L,I;if(v=C,V.test(i.charAt(C))?(O=i.charAt(C),C++):(O=e,Ae===0&&Ct(U)),O!==e){for(L=[],I=We();I!==e;)L.push(I),I=We();L!==e?(I=BS(),I!==e?(ne=v,O=m(O,I),v=O):(C=v,v=e)):(C=v,v=e)}else C=v,v=e;return v}function BS(){var v,O,L,I,z,oe;if(v=C,O=hr(),O!==e){for(L=[],I=C,z=mt(),z===e&&(z=null),z!==e?(oe=hr(),oe!==e?(z=[z,oe],I=z):(C=I,I=e)):(C=I,I=e);I!==e;)L.push(I),I=C,z=mt(),z===e&&(z=null),z!==e?(oe=hr(),oe!==e?(z=[z,oe],I=z):(C=I,I=e)):(C=I,I=e);L!==e?(ne=v,O=a(O,L),v=O):(C=v,v=e)}else C=v,v=e;return v}function VS(){var v,O,L,I;if(v=C,B.test(i.charAt(C))?(O=i.charAt(C),C++):(O=e,Ae===0&&Ct(q)),O!==e){for(L=[],I=We();I!==e;)L.push(I),I=We();L!==e?(I=zS(),I!==e?(ne=v,O=m(O,I),v=O):(C=v,v=e)):(C=v,v=e)}else C=v,v=e;return v}function zS(){var v,O,L,I,z,oe;if(v=C,O=Tp(),O!==e){for(L=[],I=C,z=mt(),z===e&&(z=null),z!==e?(oe=Tp(),oe!==e?(z=[z,oe],I=z):(C=I,I=e)):(C=I,I=e);I!==e;)L.push(I),I=C,z=mt(),z===e&&(z=null),z!==e?(oe=Tp(),oe!==e?(z=[z,oe],I=z):(C=I,I=e)):(C=I,I=e);L!==e?(ne=v,O=a(O,L),v=O):(C=v,v=e)}else C=v,v=e;return v}function Tp(){var v,O,L,I,z,oe,ra,Ap,Cc,Mp,Ac,Ip;return v=C,O=dm(),O!==e?(L=mt(),L===e&&(L=null),L!==e?(I=dm(),I!==e?(z=mt(),z===e&&(z=null),z!==e?(oe=ea(),oe!==e?(ra=mt(),ra!==e?(Ap=pm(),Ap!==e?(Cc=mt(),Cc===e&&(Cc=null),Cc!==e?(Mp=pm(),Mp!==e?(Ac=mt(),Ac===e&&(Ac=null),Ac!==e?(Ip=hr(),Ip!==e?(ne=v,O=j(O,I,oe,Ap,Mp,Ip),v=O):(C=v,v=e)):(C=v,v=e)):(C=v,v=e)):(C=v,v=e)):(C=v,v=e)):(C=v,v=e)):(C=v,v=e)):(C=v,v=e)):(C=v,v=e)):(C=v,v=e)):(C=v,v=e),v}function hr(){var v,O,L,I;return v=C,O=ea(),O!==e?(L=mt(),L===e&&(L=null),L!==e?(I=ea(),I!==e?(ne=v,O=F(O,I),v=O):(C=v,v=e)):(C=v,v=e)):(C=v,v=e),v}function dm(){var v,O;return v=C,O=hm(),O===e&&(O=Sn()),O!==e&&(ne=v,O=H(O)),v=O,v}function ea(){var v,O,L,I;return v=C,O=C,L=Cp(),L===e&&(L=null),L!==e?(I=hm(),I!==e?(L=[L,I],O=L):(C=O,O=e)):(C=O,O=e),O===e&&(O=C,L=Cp(),L===e&&(L=null),L!==e?(I=Sn(),I!==e?(L=[L,I],O=L):(C=O,O=e)):(C=O,O=e)),O!==e&&(ne=v,O=W(O)),v=O,v}function pm(){var v,O;return v=C,ee.test(i.charAt(C))?(O=i.charAt(C),C++):(O=e,Ae===0&&Ct(te)),O!==e&&(ne=v,O=Y(O)),v=O,v}function mt(){var v,O,L,I,z;if(v=C,O=[],L=We(),L!==e)for(;L!==e;)O.push(L),L=We();else O=e;if(O!==e)if(L=fm(),L===e&&(L=null),L!==e){for(I=[],z=We();z!==e;)I.push(z),z=We();I!==e?(O=[O,L,I],v=O):(C=v,v=e)}else C=v,v=e;else C=v,v=e;if(v===e){if(v=C,O=C,L=fm(),L!==e){for(I=[],z=We();z!==e;)I.push(z),z=We();I!==e?(L=[L,I],O=L):(C=O,O=e)}else C=O,O=e;O!==e&&(ne=v,O=re()),v=O}return v}function fm(){var v;return i.charCodeAt(C)===44?(v=K,C++):(v=e,Ae===0&&Ct(Z)),v}function hm(){var v,O,L,I;return v=C,O=C,L=GS(),L!==e?(I=mm(),I===e&&(I=null),I!==e?(L=[L,I],O=L):(C=O,O=e)):(C=O,O=e),O===e&&(O=C,L=Sn(),L!==e?(I=mm(),I!==e?(L=[L,I],O=L):(C=O,O=e)):(C=O,O=e)),O!==e&&(ne=v,O=Q(O)),v=O,v}function GS(){var v,O,L,I,z;return v=C,O=C,L=Sn(),L===e&&(L=null),L!==e?(i.charCodeAt(C)===46?(I=$,C++):(I=e,Ae===0&&Ct(pe)),I!==e?(z=Sn(),z!==e?(L=[L,I,z],O=L):(C=O,O=e)):(C=O,O=e)):(C=O,O=e),O===e&&(O=C,L=Sn(),L!==e?(i.charCodeAt(C)===46?(I=$,C++):(I=e,Ae===0&&Ct(pe)),I!==e?(L=[L,I],O=L):(C=O,O=e)):(C=O,O=e)),O!==e&&(ne=v,O=Q(O)),v=O,v}function mm(){var v,O,L,I,z;return v=C,O=C,le.test(i.charAt(C))?(L=i.charAt(C),C++):(L=e,Ae===0&&Ct(ie)),L!==e?(I=Cp(),I===e&&(I=null),I!==e?(z=Sn(),z!==e?(L=[L,I,z],O=L):(C=O,O=e)):(C=O,O=e)):(C=O,O=e),O!==e&&(ne=v,O=Q(O)),v=O,v}function Cp(){var v;return ue.test(i.charAt(C))?(v=i.charAt(C),C++):(v=e,Ae===0&&Ct(ae)),v}function Sn(){var v,O,L;if(v=C,O=[],ge.test(i.charAt(C))?(L=i.charAt(C),C++):(L=e,Ae===0&&Ct(me)),L!==e)for(;L!==e;)O.push(L),ge.test(i.charAt(C))?(L=i.charAt(C),C++):(L=e,Ae===0&&Ct(me));else O=e;return O!==e&&(ne=v,O=ye(O)),v=O,v}function We(){var v,O;return v=C,Se.test(i.charAt(C))?(O=i.charAt(C),C++):(O=e,Ae===0&&Ct(xe)),O!==e&&(ne=v,O=re()),v=O,v}function FS(v,O){if(!O)return[v];for(var L=[v],I=0,z=O.length;I<z;I++)L[I+1]=O[I][1];return L}var Tc={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 ym in Tc)Tc[ym.toUpperCase()]=Tc[ym];function ta(v,O){O||(O=[{}]);for(var L=O.length;L--;){var I={code:v,command:Tc[v]};v==v.toLowerCase()&&(I.relative=!0);for(var z in O[L])I[z]=O[L][z];O[L]=I}return O}if(Ut=o(),Ut!==e&&C===i.length)return Ut;throw Ut!==e&&C<i.length&&Ct(bp()),jr(Fe,He<i.length?i.charAt(He):null,He<i.length?bn(He,He+1):bn(He,He))}c1.exports={SyntaxError:Yn,parse:sE}});var $h=sl((hoe,d1)=>{var Jd=u1().parse;Jd.parseSVG=Jd;Jd.makeAbsolute=lE;d1.exports=Jd;function lE(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 wS=sl((oue,SS)=>{SS.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 jE={};gm(jE,{default:()=>gp});module.exports=$S(jE);var xp=require("three");function Mc(i){for(let t of Object.keys(i))i[t]===void 0&&delete i[t];return i}function Ht(i,t){return Object.setPrototypeOf(i,t),i}function Ic(i){return Array.isArray(i)?i:[i]}function Ec(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 XS=typeof global=="object"&&global&&global.Object===Object&&global,Nc=XS;var YS=typeof self=="object"&&self&&self.Object===Object&&self,KS=Nc||YS||Function("return this")(),At=KS;var QS=At.Symbol,Zt=QS;var bm=Object.prototype,ZS=bm.hasOwnProperty,JS=bm.toString,cl=Zt?Zt.toStringTag:void 0;function ew(i){var t=ZS.call(i,cl),e=i[cl];try{i[cl]=void 0;var r=!0}catch{}var o=JS.call(i);return r&&(t?i[cl]=e:delete i[cl]),o}var vm=ew;var tw=Object.prototype,rw=tw.toString;function ow(i){return rw.call(i)}var Sm=ow;var iw="[object Null]",nw="[object Undefined]",wm=Zt?Zt.toStringTag:void 0;function aw(i){return i==null?i===void 0?nw:iw:wm&&wm in Object(i)?vm(i):Sm(i)}var Lr=aw;function sw(i){return i!=null&&typeof i=="object"}var nr=sw;var lw="[object Symbol]";function cw(i){return typeof i=="symbol"||nr(i)&&Lr(i)==lw}var Ci=cw;function uw(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 Dc=uw;var dw=Array.isArray,Mt=dw;var pw=1/0,Pm=Zt?Zt.prototype:void 0,Om=Pm?Pm.toString:void 0;function Tm(i){if(typeof i=="string")return i;if(Mt(i))return Dc(i,Tm)+"";if(Ci(i))return Om?Om.call(i):"";var t=i+"";return t=="0"&&1/i==-pw?"-0":t}var Cm=Tm;var fw=/\s/;function hw(i){for(var t=i.length;t--&&fw.test(i.charAt(t)););return t}var Am=hw;var mw=/^\s+/;function yw(i){return i&&i.slice(0,Am(i)+1).replace(mw,"")}var Mm=yw;function gw(i){var t=typeof i;return i!=null&&(t=="object"||t=="function")}var It=gw;var Im=0/0,xw=/^[-+]0x[0-9a-f]+$/i,bw=/^0b[01]+$/i,vw=/^0o[0-7]+$/i,Sw=parseInt;function ww(i){if(typeof i=="number")return i;if(Ci(i))return Im;if(It(i)){var t=typeof i.valueOf=="function"?i.valueOf():i;i=It(t)?t+"":t}if(typeof i!="string")return i===0?i:+i;i=Mm(i);var e=bw.test(i);return e||vw.test(i)?Sw(i.slice(2),e?2:8):xw.test(i)?Im:+i}var Ep=ww;function Pw(i){return i}var Em=Pw;var Ow="[object AsyncFunction]",Tw="[object Function]",Cw="[object GeneratorFunction]",Aw="[object Proxy]";function Mw(i){if(!It(i))return!1;var t=Lr(i);return t==Tw||t==Cw||t==Ow||t==Aw}var _c=Mw;var Iw=At["__core-js_shared__"],Rc=Iw;var Nm=function(){var i=/[^.]+$/.exec(Rc&&Rc.keys&&Rc.keys.IE_PROTO||"");return i?"Symbol(src)_1."+i:""}();function Ew(i){return!!Nm&&Nm in i}var Dm=Ew;var Nw=Function.prototype,Dw=Nw.toString;function _w(i){if(i!=null){try{return Dw.call(i)}catch{}try{return i+""}catch{}}return""}var Qo=_w;var Rw=/[\\^$.*+?()[\]{}|]/g,Lw=/^\[object .+?Constructor\]$/,Bw=Function.prototype,Vw=Object.prototype,zw=Bw.toString,Gw=Vw.hasOwnProperty,Fw=RegExp("^"+zw.call(Gw).replace(Rw,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function jw(i){if(!It(i)||Dm(i))return!1;var t=_c(i)?Fw:Lw;return t.test(Qo(i))}var _m=jw;function Uw(i,t){return i?.[t]}var Rm=Uw;function kw(i,t){var e=Rm(i,t);return _m(e)?e:void 0}var Sr=kw;var Hw=Sr(At,"WeakMap"),Lc=Hw;var Lm=Object.create,Ww=function(){function i(){}return function(t){if(!It(t))return{};if(Lm)return Lm(t);i.prototype=t;var e=new i;return i.prototype=void 0,e}}(),Bm=Ww;function qw(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 Vm=qw;function $w(i,t){var e=-1,r=i.length;for(t||(t=Array(r));++e<r;)t[e]=i[e];return t}var zm=$w;var Xw=800,Yw=16,Kw=Date.now;function Qw(i){var t=0,e=0;return function(){var r=Kw(),o=Yw-(r-e);if(e=r,o>0){if(++t>=Xw)return arguments[0]}else t=0;return i.apply(void 0,arguments)}}var Gm=Qw;function Zw(i){return function(){return i}}var Fm=Zw;var Jw=function(){try{var i=Sr(Object,"defineProperty");return i({},"",{}),i}catch{}}(),oa=Jw;var e2=oa?function(i,t){return oa(i,"toString",{configurable:!0,enumerable:!1,value:Fm(t),writable:!0})}:Em,jm=e2;var t2=Gm(jm),Um=t2;function r2(i,t){for(var e=-1,r=i==null?0:i.length;++e<r&&t(i[e],e,i)!==!1;);return i}var km=r2;var o2=9007199254740991,i2=/^(?:0|[1-9]\d*)$/;function n2(i,t){var e=typeof i;return t=t??o2,!!t&&(e=="number"||e!="symbol"&&i2.test(i))&&i>-1&&i%1==0&&i<t}var ia=n2;function a2(i,t,e){t=="__proto__"&&oa?oa(i,t,{configurable:!0,enumerable:!0,value:e,writable:!0}):i[t]=e}var Bc=a2;function s2(i,t){return i===t||i!==i&&t!==t}var na=s2;var l2=Object.prototype,c2=l2.hasOwnProperty;function u2(i,t,e){var r=i[t];(!(c2.call(i,t)&&na(r,e))||e===void 0&&!(t in i))&&Bc(i,t,e)}var aa=u2;function d2(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?Bc(e,s,l):aa(e,s,l)}return e}var Oo=d2;var Hm=Math.max;function p2(i,t,e){return t=Hm(t===void 0?i.length-1:t,0),function(){for(var r=arguments,o=-1,n=Hm(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),Vm(i,this,s)}}var Wm=p2;var f2=9007199254740991;function h2(i){return typeof i=="number"&&i>-1&&i%1==0&&i<=f2}var sa=h2;function m2(i){return i!=null&&sa(i.length)&&!_c(i)}var Vc=m2;var y2=Object.prototype;function g2(i){var t=i&&i.constructor,e=typeof t=="function"&&t.prototype||y2;return i===e}var la=g2;function x2(i,t){for(var e=-1,r=Array(i);++e<i;)r[e]=t(e);return r}var qm=x2;var b2="[object Arguments]";function v2(i){return nr(i)&&Lr(i)==b2}var Np=v2;var $m=Object.prototype,S2=$m.hasOwnProperty,w2=$m.propertyIsEnumerable,P2=Np(function(){return arguments}())?Np:function(i){return nr(i)&&S2.call(i,"callee")&&!w2.call(i,"callee")},ca=P2;function O2(){return!1}var Xm=O2;var Qm=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Ym=Qm&&typeof module=="object"&&module&&!module.nodeType&&module,T2=Ym&&Ym.exports===Qm,Km=T2?At.Buffer:void 0,C2=Km?Km.isBuffer:void 0,A2=C2||Xm,Pn=A2;var M2="[object Arguments]",I2="[object Array]",E2="[object Boolean]",N2="[object Date]",D2="[object Error]",_2="[object Function]",R2="[object Map]",L2="[object Number]",B2="[object Object]",V2="[object RegExp]",z2="[object Set]",G2="[object String]",F2="[object WeakMap]",j2="[object ArrayBuffer]",U2="[object DataView]",k2="[object Float32Array]",H2="[object Float64Array]",W2="[object Int8Array]",q2="[object Int16Array]",$2="[object Int32Array]",X2="[object Uint8Array]",Y2="[object Uint8ClampedArray]",K2="[object Uint16Array]",Q2="[object Uint32Array]",yt={};yt[k2]=yt[H2]=yt[W2]=yt[q2]=yt[$2]=yt[X2]=yt[Y2]=yt[K2]=yt[Q2]=!0;yt[M2]=yt[I2]=yt[j2]=yt[E2]=yt[U2]=yt[N2]=yt[D2]=yt[_2]=yt[R2]=yt[L2]=yt[B2]=yt[V2]=yt[z2]=yt[G2]=yt[F2]=!1;function Z2(i){return nr(i)&&sa(i.length)&&!!yt[Lr(i)]}var Zm=Z2;function J2(i){return function(t){return i(t)}}var ua=J2;var Jm=typeof exports=="object"&&exports&&!exports.nodeType&&exports,ul=Jm&&typeof module=="object"&&module&&!module.nodeType&&module,eP=ul&&ul.exports===Jm,Dp=eP&&Nc.process,tP=function(){try{var i=ul&&ul.require&&ul.require("util").types;return i||Dp&&Dp.binding&&Dp.binding("util")}catch{}}(),Zo=tP;var ey=Zo&&Zo.isTypedArray,rP=ey?ua(ey):Zm,zc=rP;var oP=Object.prototype,iP=oP.hasOwnProperty;function nP(i,t){var e=Mt(i),r=!e&&ca(i),o=!e&&!r&&Pn(i),n=!e&&!r&&!o&&zc(i),a=e||r||o||n,s=a?qm(i.length,String):[],l=s.length;for(var c in i)(t||iP.call(i,c))&&!(a&&(c=="length"||o&&(c=="offset"||c=="parent")||n&&(c=="buffer"||c=="byteLength"||c=="byteOffset")||ia(c,l)))&&s.push(c);return s}var Gc=nP;function aP(i,t){return function(e){return i(t(e))}}var Fc=aP;var sP=Fc(Object.keys,Object),ty=sP;var lP=Object.prototype,cP=lP.hasOwnProperty;function uP(i){if(!la(i))return ty(i);var t=[];for(var e in Object(i))cP.call(i,e)&&e!="constructor"&&t.push(e);return t}var ry=uP;function dP(i){return Vc(i)?Gc(i):ry(i)}var da=dP;function pP(i){var t=[];if(i!=null)for(var e in Object(i))t.push(e);return t}var oy=pP;var fP=Object.prototype,hP=fP.hasOwnProperty;function mP(i){if(!It(i))return oy(i);var t=la(i),e=[];for(var r in i)r=="constructor"&&(t||!hP.call(i,r))||e.push(r);return e}var iy=mP;function yP(i){return Vc(i)?Gc(i,!0):iy(i)}var pa=yP;var gP=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,xP=/^\w*$/;function bP(i,t){if(Mt(i))return!1;var e=typeof i;return e=="number"||e=="symbol"||e=="boolean"||i==null||Ci(i)?!0:xP.test(i)||!gP.test(i)||t!=null&&i in Object(t)}var ny=bP;var vP=Sr(Object,"create"),Jo=vP;function SP(){this.__data__=Jo?Jo(null):{},this.size=0}var ay=SP;function wP(i){var t=this.has(i)&&delete this.__data__[i];return this.size-=t?1:0,t}var sy=wP;var PP="__lodash_hash_undefined__",OP=Object.prototype,TP=OP.hasOwnProperty;function CP(i){var t=this.__data__;if(Jo){var e=t[i];return e===PP?void 0:e}return TP.call(t,i)?t[i]:void 0}var ly=CP;var AP=Object.prototype,MP=AP.hasOwnProperty;function IP(i){var t=this.__data__;return Jo?t[i]!==void 0:MP.call(t,i)}var cy=IP;var EP="__lodash_hash_undefined__";function NP(i,t){var e=this.__data__;return this.size+=this.has(i)?0:1,e[i]=Jo&&t===void 0?EP:t,this}var uy=NP;function fa(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])}}fa.prototype.clear=ay;fa.prototype.delete=sy;fa.prototype.get=ly;fa.prototype.has=cy;fa.prototype.set=uy;var _p=fa;function DP(){this.__data__=[],this.size=0}var dy=DP;function _P(i,t){for(var e=i.length;e--;)if(na(i[e][0],t))return e;return-1}var Ai=_P;var RP=Array.prototype,LP=RP.splice;function BP(i){var t=this.__data__,e=Ai(t,i);if(e<0)return!1;var r=t.length-1;return e==r?t.pop():LP.call(t,e,1),--this.size,!0}var py=BP;function VP(i){var t=this.__data__,e=Ai(t,i);return e<0?void 0:t[e][1]}var fy=VP;function zP(i){return Ai(this.__data__,i)>-1}var hy=zP;function GP(i,t){var e=this.__data__,r=Ai(e,i);return r<0?(++this.size,e.push([i,t])):e[r][1]=t,this}var my=GP;function ha(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])}}ha.prototype.clear=dy;ha.prototype.delete=py;ha.prototype.get=fy;ha.prototype.has=hy;ha.prototype.set=my;var Mi=ha;var FP=Sr(At,"Map"),Ii=FP;function jP(){this.size=0,this.__data__={hash:new _p,map:new(Ii||Mi),string:new _p}}var yy=jP;function UP(i){var t=typeof i;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?i!=="__proto__":i===null}var gy=UP;function kP(i,t){var e=i.__data__;return gy(t)?e[typeof t=="string"?"string":"hash"]:e.map}var Ei=kP;function HP(i){var t=Ei(this,i).delete(i);return this.size-=t?1:0,t}var xy=HP;function WP(i){return Ei(this,i).get(i)}var by=WP;function qP(i){return Ei(this,i).has(i)}var vy=qP;function $P(i,t){var e=Ei(this,i),r=e.size;return e.set(i,t),this.size+=e.size==r?0:1,this}var Sy=$P;function ma(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])}}ma.prototype.clear=yy;ma.prototype.delete=xy;ma.prototype.get=by;ma.prototype.has=vy;ma.prototype.set=Sy;var On=ma;var XP="Expected a function";function Rp(i,t){if(typeof i!="function"||t!=null&&typeof t!="function")throw new TypeError(XP);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(Rp.Cache||On),e}Rp.Cache=On;var wy=Rp;var YP=500;function KP(i){var t=wy(i,function(r){return e.size===YP&&e.clear(),r}),e=t.cache;return t}var Py=KP;var QP=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,ZP=/\\(\\)?/g,JP=Py(function(i){var t=[];return i.charCodeAt(0)===46&&t.push(""),i.replace(QP,function(e,r,o,n){t.push(o?n.replace(ZP,"$1"):r||e)}),t}),Oy=JP;function eO(i){return i==null?"":Cm(i)}var Ty=eO;function tO(i,t){return Mt(i)?i:ny(i,t)?[i]:Oy(Ty(i))}var Ur=tO;var rO=1/0;function oO(i){if(typeof i=="string"||Ci(i))return i;var t=i+"";return t=="0"&&1/i==-rO?"-0":t}var Ni=oO;function iO(i,t){t=Ur(t,i);for(var e=0,r=t.length;i!=null&&e<r;)i=i[Ni(t[e++])];return e&&e==r?i:void 0}var jc=iO;function nO(i,t){for(var e=-1,r=t.length,o=i.length;++e<r;)i[o+e]=t[e];return i}var ya=nO;var Cy=Zt?Zt.isConcatSpreadable:void 0;function aO(i){return Mt(i)||ca(i)||!!(Cy&&i&&i[Cy])}var Ay=aO;function My(i,t,e,r,o){var n=-1,a=i.length;for(e||(e=Ay),o||(o=[]);++n<a;){var s=i[n];t>0&&e(s)?t>1?My(s,t-1,e,r,o):ya(o,s):r||(o[o.length]=s)}return o}var Iy=My;function sO(i){var t=i==null?0:i.length;return t?Iy(i,1):[]}var Ey=sO;function lO(i){return Um(Wm(i,void 0,Ey),i+"")}var Uc=lO;var cO=Fc(Object.getPrototypeOf,Object),ga=cO;var uO="[object Object]",dO=Function.prototype,pO=Object.prototype,Ny=dO.toString,fO=pO.hasOwnProperty,hO=Ny.call(Object);function mO(i){if(!nr(i)||Lr(i)!=uO)return!1;var t=ga(i);if(t===null)return!0;var e=fO.call(t,"constructor")&&t.constructor;return typeof e=="function"&&e instanceof e&&Ny.call(e)==hO}var Dy=mO;function yO(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 _y=yO;function gO(){this.__data__=new Mi,this.size=0}var Ry=gO;function xO(i){var t=this.__data__,e=t.delete(i);return this.size=t.size,e}var Ly=xO;function bO(i){return this.__data__.get(i)}var By=bO;function vO(i){return this.__data__.has(i)}var Vy=vO;var SO=200;function wO(i,t){var e=this.__data__;if(e instanceof Mi){var r=e.__data__;if(!Ii||r.length<SO-1)return r.push([i,t]),this.size=++e.size,this;e=this.__data__=new On(r)}return e.set(i,t),this.size=e.size,this}var zy=wO;function xa(i){var t=this.__data__=new Mi(i);this.size=t.size}xa.prototype.clear=Ry;xa.prototype.delete=Ly;xa.prototype.get=By;xa.prototype.has=Vy;xa.prototype.set=zy;var ba=xa;function PO(i,t){return i&&Oo(t,da(t),i)}var Gy=PO;function OO(i,t){return i&&Oo(t,pa(t),i)}var Fy=OO;var Hy=typeof exports=="object"&&exports&&!exports.nodeType&&exports,jy=Hy&&typeof module=="object"&&module&&!module.nodeType&&module,TO=jy&&jy.exports===Hy,Uy=TO?At.Buffer:void 0,ky=Uy?Uy.allocUnsafe:void 0;function CO(i,t){if(t)return i.slice();var e=i.length,r=ky?ky(e):new i.constructor(e);return i.copy(r),r}var Wy=CO;function AO(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 qy=AO;function MO(){return[]}var kc=MO;var IO=Object.prototype,EO=IO.propertyIsEnumerable,$y=Object.getOwnPropertySymbols,NO=$y?function(i){return i==null?[]:(i=Object(i),qy($y(i),function(t){return EO.call(i,t)}))}:kc,va=NO;function DO(i,t){return Oo(i,va(i),t)}var Xy=DO;var _O=Object.getOwnPropertySymbols,RO=_O?function(i){for(var t=[];i;)ya(t,va(i)),i=ga(i);return t}:kc,Hc=RO;function LO(i,t){return Oo(i,Hc(i),t)}var Yy=LO;function BO(i,t,e){var r=t(i);return Mt(i)?r:ya(r,e(i))}var Wc=BO;function VO(i){return Wc(i,da,va)}var dl=VO;function zO(i){return Wc(i,pa,Hc)}var qc=zO;var GO=Sr(At,"DataView"),$c=GO;var FO=Sr(At,"Promise"),Xc=FO;var jO=Sr(At,"Set"),Yc=jO;var Ky="[object Map]",UO="[object Object]",Qy="[object Promise]",Zy="[object Set]",Jy="[object WeakMap]",eg="[object DataView]",kO=Qo($c),HO=Qo(Ii),WO=Qo(Xc),qO=Qo(Yc),$O=Qo(Lc),Tn=Lr;($c&&Tn(new $c(new ArrayBuffer(1)))!=eg||Ii&&Tn(new Ii)!=Ky||Xc&&Tn(Xc.resolve())!=Qy||Yc&&Tn(new Yc)!=Zy||Lc&&Tn(new Lc)!=Jy)&&(Tn=function(i){var t=Lr(i),e=t==UO?i.constructor:void 0,r=e?Qo(e):"";if(r)switch(r){case kO:return eg;case HO:return Ky;case WO:return Qy;case qO:return Zy;case $O:return Jy}return t});var ei=Tn;var XO=Object.prototype,YO=XO.hasOwnProperty;function KO(i){var t=i.length,e=new i.constructor(t);return t&&typeof i[0]=="string"&&YO.call(i,"index")&&(e.index=i.index,e.input=i.input),e}var tg=KO;var QO=At.Uint8Array,Sa=QO;function ZO(i){var t=new i.constructor(i.byteLength);return new Sa(t).set(new Sa(i)),t}var wa=ZO;function JO(i,t){var e=t?wa(i.buffer):i.buffer;return new i.constructor(e,i.byteOffset,i.byteLength)}var rg=JO;var eT=/\w*$/;function tT(i){var t=new i.constructor(i.source,eT.exec(i));return t.lastIndex=i.lastIndex,t}var og=tT;var ig=Zt?Zt.prototype:void 0,ng=ig?ig.valueOf:void 0;function rT(i){return ng?Object(ng.call(i)):{}}var ag=rT;function oT(i,t){var e=t?wa(i.buffer):i.buffer;return new i.constructor(e,i.byteOffset,i.length)}var sg=oT;var iT="[object Boolean]",nT="[object Date]",aT="[object Map]",sT="[object Number]",lT="[object RegExp]",cT="[object Set]",uT="[object String]",dT="[object Symbol]",pT="[object ArrayBuffer]",fT="[object DataView]",hT="[object Float32Array]",mT="[object Float64Array]",yT="[object Int8Array]",gT="[object Int16Array]",xT="[object Int32Array]",bT="[object Uint8Array]",vT="[object Uint8ClampedArray]",ST="[object Uint16Array]",wT="[object Uint32Array]";function PT(i,t,e){var r=i.constructor;switch(t){case pT:return wa(i);case iT:case nT:return new r(+i);case fT:return rg(i,e);case hT:case mT:case yT:case gT:case xT:case bT:case vT:case ST:case wT:return sg(i,e);case aT:return new r;case sT:case uT:return new r(i);case lT:return og(i);case cT:return new r;case dT:return ag(i)}}var lg=PT;function OT(i){return typeof i.constructor=="function"&&!la(i)?Bm(ga(i)):{}}var cg=OT;var TT="[object Map]";function CT(i){return nr(i)&&ei(i)==TT}var ug=CT;var dg=Zo&&Zo.isMap,AT=dg?ua(dg):ug,pg=AT;var MT="[object Set]";function IT(i){return nr(i)&&ei(i)==MT}var fg=IT;var hg=Zo&&Zo.isSet,ET=hg?ua(hg):fg,mg=ET;var NT=1,DT=2,_T=4,yg="[object Arguments]",RT="[object Array]",LT="[object Boolean]",BT="[object Date]",VT="[object Error]",gg="[object Function]",zT="[object GeneratorFunction]",GT="[object Map]",FT="[object Number]",xg="[object Object]",jT="[object RegExp]",UT="[object Set]",kT="[object String]",HT="[object Symbol]",WT="[object WeakMap]",qT="[object ArrayBuffer]",$T="[object DataView]",XT="[object Float32Array]",YT="[object Float64Array]",KT="[object Int8Array]",QT="[object Int16Array]",ZT="[object Int32Array]",JT="[object Uint8Array]",eC="[object Uint8ClampedArray]",tC="[object Uint16Array]",rC="[object Uint32Array]",pt={};pt[yg]=pt[RT]=pt[qT]=pt[$T]=pt[LT]=pt[BT]=pt[XT]=pt[YT]=pt[KT]=pt[QT]=pt[ZT]=pt[GT]=pt[FT]=pt[xg]=pt[jT]=pt[UT]=pt[kT]=pt[HT]=pt[JT]=pt[eC]=pt[tC]=pt[rC]=!0;pt[VT]=pt[gg]=pt[WT]=!1;function Kc(i,t,e,r,o,n){var a,s=t&NT,l=t&DT,c=t&_T;if(e&&(a=o?e(i,r,o,n):e(i)),a!==void 0)return a;if(!It(i))return i;var u=Mt(i);if(u){if(a=tg(i),!s)return zm(i,a)}else{var d=ei(i),p=d==gg||d==zT;if(Pn(i))return Wy(i,s);if(d==xg||d==yg||p&&!o){if(a=l||p?{}:cg(i),!s)return l?Yy(i,Fy(a,i)):Xy(i,Gy(a,i))}else{if(!pt[d])return o?i:{};a=lg(i,d,s)}}n||(n=new ba);var f=n.get(i);if(f)return f;n.set(i,a),mg(i)?i.forEach(function(y){a.add(Kc(y,t,e,y,i,n))}):pg(i)&&i.forEach(function(y,g){a.set(g,Kc(y,t,e,g,i,n))});var h=c?l?qc:dl:l?pa:da,m=u?void 0:h(i);return km(m||i,function(y,g){m&&(g=y,y=i[g]),aa(a,g,Kc(y,t,e,g,i,n))}),a}var Qc=Kc;var oC=1,iC=4;function nC(i){return Qc(i,oC|iC)}var ti=nC;var aC="__lodash_hash_undefined__";function sC(i){return this.__data__.set(i,aC),this}var bg=sC;function lC(i){return this.__data__.has(i)}var vg=lC;function Zc(i){var t=-1,e=i==null?0:i.length;for(this.__data__=new On;++t<e;)this.add(i[t])}Zc.prototype.add=Zc.prototype.push=bg;Zc.prototype.has=vg;var Sg=Zc;function cC(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 wg=cC;function uC(i,t){return i.has(t)}var Pg=uC;var dC=1,pC=2;function fC(i,t,e,r,o,n){var a=e&dC,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 d=-1,p=!0,f=e&pC?new Sg:void 0;for(n.set(i,t),n.set(t,i);++d<s;){var h=i[d],m=t[d];if(r)var y=a?r(m,h,d,t,i,n):r(h,m,d,i,t,n);if(y!==void 0){if(y)continue;p=!1;break}if(f){if(!wg(t,function(g,b){if(!Pg(f,b)&&(h===g||o(h,g,e,r,n)))return f.push(b)})){p=!1;break}}else if(!(h===m||o(h,m,e,r,n))){p=!1;break}}return n.delete(i),n.delete(t),p}var Jc=fC;function hC(i){var t=-1,e=Array(i.size);return i.forEach(function(r,o){e[++t]=[o,r]}),e}var Og=hC;function mC(i){var t=-1,e=Array(i.size);return i.forEach(function(r){e[++t]=r}),e}var Tg=mC;var yC=1,gC=2,xC="[object Boolean]",bC="[object Date]",vC="[object Error]",SC="[object Map]",wC="[object Number]",PC="[object RegExp]",OC="[object Set]",TC="[object String]",CC="[object Symbol]",AC="[object ArrayBuffer]",MC="[object DataView]",Cg=Zt?Zt.prototype:void 0,Lp=Cg?Cg.valueOf:void 0;function IC(i,t,e,r,o,n,a){switch(e){case MC:if(i.byteLength!=t.byteLength||i.byteOffset!=t.byteOffset)return!1;i=i.buffer,t=t.buffer;case AC:return!(i.byteLength!=t.byteLength||!n(new Sa(i),new Sa(t)));case xC:case bC:case wC:return na(+i,+t);case vC:return i.name==t.name&&i.message==t.message;case PC:case TC:return i==t+"";case SC:var s=Og;case OC:var l=r&yC;if(s||(s=Tg),i.size!=t.size&&!l)return!1;var c=a.get(i);if(c)return c==t;r|=gC,a.set(i,t);var u=Jc(s(i),s(t),r,o,n,a);return a.delete(i),u;case CC:if(Lp)return Lp.call(i)==Lp.call(t)}return!1}var Ag=IC;var EC=1,NC=Object.prototype,DC=NC.hasOwnProperty;function _C(i,t,e,r,o,n){var a=e&EC,s=dl(i),l=s.length,c=dl(t),u=c.length;if(l!=u&&!a)return!1;for(var d=l;d--;){var p=s[d];if(!(a?p in t:DC.call(t,p)))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;++d<l;){p=s[d];var g=i[p],b=t[p];if(r)var w=a?r(b,g,p,t,i,n):r(g,b,p,i,t,n);if(!(w===void 0?g===b||o(g,b,e,r,n):w)){m=!1;break}y||(y=p=="constructor")}if(m&&!y){var P=i.constructor,S=t.constructor;P!=S&&"constructor"in i&&"constructor"in t&&!(typeof P=="function"&&P instanceof P&&typeof S=="function"&&S instanceof S)&&(m=!1)}return n.delete(i),n.delete(t),m}var Mg=_C;var RC=1,Ig="[object Arguments]",Eg="[object Array]",eu="[object Object]",LC=Object.prototype,Ng=LC.hasOwnProperty;function BC(i,t,e,r,o,n){var a=Mt(i),s=Mt(t),l=a?Eg:ei(i),c=s?Eg:ei(t);l=l==Ig?eu:l,c=c==Ig?eu:c;var u=l==eu,d=c==eu,p=l==c;if(p&&Pn(i)){if(!Pn(t))return!1;a=!0,u=!1}if(p&&!u)return n||(n=new ba),a||zc(i)?Jc(i,t,e,r,o,n):Ag(i,t,l,e,r,o,n);if(!(e&RC)){var f=u&&Ng.call(i,"__wrapped__"),h=d&&Ng.call(t,"__wrapped__");if(f||h){var m=f?i.value():i,y=h?t.value():t;return n||(n=new ba),o(m,y,e,r,n)}}return p?(n||(n=new ba),Mg(i,t,e,r,o,n)):!1}var Dg=BC;function _g(i,t,e,r,o){return i===t?!0:i==null||t==null||!nr(i)&&!nr(t)?i!==i&&t!==t:Dg(i,t,e,r,_g,o)}var Rg=_g;function VC(i,t){return i!=null&&t in Object(i)}var Lg=VC;function zC(i,t,e){t=Ur(t,i);for(var r=-1,o=t.length,n=!1;++r<o;){var a=Ni(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&&sa(o)&&ia(a,o)&&(Mt(i)||ca(i)))}var Bg=zC;function GC(i,t){return i!=null&&Bg(i,t,Lg)}var Vg=GC;var FC=function(){return At.Date.now()},tu=FC;var jC="Expected a function",UC=Math.max,kC=Math.min;function HC(i,t,e){var r,o,n,a,s,l,c=0,u=!1,d=!1,p=!0;if(typeof i!="function")throw new TypeError(jC);t=Ep(t)||0,It(e)&&(u=!!e.leading,d="maxWait"in e,n=d?UC(Ep(e.maxWait)||0,t):n,p="trailing"in e?!!e.trailing:p);function f(T){var A=r,x=o;return r=o=void 0,c=T,a=i.apply(x,A),a}function h(T){return c=T,s=setTimeout(g,t),u?f(T):a}function m(T){var A=T-l,x=T-c,N=t-A;return d?kC(N,n-x):N}function y(T){var A=T-l,x=T-c;return l===void 0||A>=t||A<0||d&&x>=n}function g(){var T=tu();if(y(T))return b(T);s=setTimeout(g,m(T))}function b(T){return s=void 0,p&&r?f(T):(r=o=void 0,a)}function w(){s!==void 0&&clearTimeout(s),c=0,r=l=o=s=void 0}function P(){return s===void 0?a:b(tu())}function S(){var T=tu(),A=y(T);if(r=arguments,o=this,l=T,A){if(s===void 0)return h(l);if(d)return clearTimeout(s),s=setTimeout(g,t),f(l)}return s===void 0&&(s=setTimeout(g,t)),a}return S.cancel=w,S.flush=P,S}var ru=HC;function WC(i){var t=i==null?0:i.length;return t?i[t-1]:void 0}var zg=WC;function qC(i,t){return t.length<2?i:jc(i,_y(t,0,-1))}var Gg=qC;function $C(i,t){return Rg(i,t)}var Bp=$C;function XC(i,t){return t=Ur(t,i),i=Gg(i,t),i==null||delete i[Ni(zg(t))]}var Fg=XC;function YC(i){return Dy(i)?void 0:i}var jg=YC;var KC=1,QC=2,ZC=4,JC=Uc(function(i,t){var e={};if(i==null)return e;var r=!1;t=Dc(t,function(n){return n=Ur(n,i),r||(r=n.length>1),n}),Oo(i,qc(i),e),r&&(e=Qc(e,KC|QC|ZC,jg));for(var o=t.length;o--;)Fg(e,t[o]);return e}),Pa=JC;function eA(i,t,e,r){if(!It(i))return i;t=Ur(t,i);for(var o=-1,n=t.length,a=n-1,s=i;s!=null&&++o<n;){var l=Ni(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=It(u)?u:ia(t[o+1])?[]:{})}aa(s,l,c),s=s[l]}return i}var Ug=eA;function tA(i,t,e){for(var r=-1,o=t.length,n={};++r<o;){var a=t[r],s=jc(i,a);e(s,a)&&Ug(n,Ur(a,i),s)}return n}var kg=tA;function rA(i,t){return kg(i,t,function(e,r){return Vg(i,r)})}var Hg=rA;var oA=Uc(function(i,t){return i==null?{}:Hg(i,t)}),no=oA;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 pl(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"&&pl(r)}return Object.freeze(i)}function Wg(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 Oa=class extends Error{};function ou(i){let t={...i};return Object.setPrototypeOf(t,Object.getPrototypeOf(i)),t}function To(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 Ta(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 qg(){return typeof process<"u"}function $g(i,t){for(let e of i)t(e.id,e.data)!==!0&&$g(e.children,t)}function Xg(i,t){if(t(i.id,i.data)!==!0)for(let e of i.children)Xg(e,t)}var ut=class extends Array{constructor(...e){super(...e);Object.setPrototypeOf(this,ut.prototype)}deepFreeze(){let e=0;for(;e<this.length;)pl(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&&Xg(o,r)}}traverse(e){$g(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,ut.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((p,f)=>p.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 Oa("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],d=this.modifyArrayBy(a,l);a=r,l=d.childrenArray(a);let p=u.fi;return u={...u,fi:o},l=[...l,u],l.sort((f,h)=>f.fi-h.fi),e.localIndex=l.indexOf(u),d=d.modifyArrayBy(a,l),{data:d,actual:e,reverse:{type:9,parent:s,fi:p,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)=>Wg(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 To(0,o,o);{let a=n[0].fi;return To(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 To(l,l+o,o)}else return To(a.fi,s.fi,o)}}};var Ca;(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})(Ca||(Ca={}));var ve=class extends Array{constructor(...e){super(...e);Object.setPrototypeOf(this,ve.prototype)}deepFreeze(){let e=0;for(;e<this.length;)pl(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,ve.prototype);let r=e;return qg()||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,d)=>u.fi-d.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 To(0,r,r);{let n=o[0].fi;return To(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 To(s,s+r,r)}else return To(n.fi,a.fi,r)}}};function Aa(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&&!Aa(r))return null;o+=1}r=r?ou(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=ou(l),delete r[t.path[o-1]])}else{let l=e[o-1];if(l){let c=ou(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}}},Co;(r=>{function i(o,n){return fl(o,n)??o}r.apply=i;function t(o,n){return zp(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=dt.zoomOnce(l,s[a]),l===void 0)return n;if(!Aa(l))return;a+=1}if(l===void 0)return n;if(!!Aa(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=Vp([n],l);return c?c[0]:n}else return n}r.filterOp=e})(Co||(Co={}));function Vp(i,t){if(t===void 0)return;let e=!1,r=i.map(o=>{let n=o.id,a=fl(o.data,t[n]);if(e=e||a!==void 0,a===void 0&&(a=o.data),o.children){let s=Vp(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 iA(i,t){if(t===void 0)return;let e=!1,r=i.map(o=>{let n=o.id,a=fl(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 fl(i,t){if(!Aa(t))return t;if(i instanceof ut){let e=Vp(i,t);return e!==void 0&&Object.setPrototypeOf(e,Object.getPrototypeOf(i)),e}else{if(i instanceof ve)return iA(i,t);if(Array.isArray(i)){let e=!1,r=i.map((o,n)=>{let a=fl(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 zp(i,t);if(i&&typeof i=="object"){let e={},r=!1;for(let[o,n]of Object.entries(i)){let a=fl(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 zp(i,t){if(i===void 0)return t;if(t===void 0)return i;if(!Aa(t))return t;if(!Aa(i))return Co.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=zp(i===void 0?void 0:i[o],t===void 0?void 0:t[o]);r[o]=n}return r}function Yg(i,t){let e={cur:[],result:[],len:0};return i=hl(i,t,e)??i,[i,e.result]}function iu(i,t){return i===null?null:(i.cur[i.len]=t,i.len+=1,i)}function nu(i){i&&(i.len-=1)}function nA(i){if(i===null)return null;i.result.push(i.cur.slice(0,i.len))}function Kg(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=hl(n.data,t,iu(e,a));nu(e),r=r||l!==void 0,l===void 0&&(l=n.data);let c=Kg(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 aA(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=hl(n.data,t,iu(e,a));return nu(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 hl(i,t,e){if(i instanceof ut){let r=Kg(i,t,e);return r!==void 0&&Object.setPrototypeOf(r,Object.getPrototypeOf(i)),r}else{if(i instanceof ve)return aA(i,t,e);if(Array.isArray(i)){let r=!1,o=i.map((n,a)=>{let s=hl(n,t,iu(e,a));return nu(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"&&!Ta(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=hl(a,t,iu(e,n));nu(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&&nA(e),r}else return}}var Ma;(t=>{function i(e,r){let o=dt.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})(Ma||(Ma={}));var vt;(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 d=[];;){let p;if(l instanceof Je&&c.type===0&&(p=l.runOp({...c,path:u.slice(d.length)}),p===null&&(p=void 0)),p===void 0&&d.length===u.length&&(l instanceof ut||l instanceof ve||l instanceof de?p=l.runOp(c):p=Ca.runOp(l,c)),p!==void 0)if(p!==null){let m=p.data;for(let y=d.length-1;y>=0;y--){let g=u[y],b=d[y];if(b instanceof ut){if(typeof g=="number")throw new Error("illegal arg");m=b.modifyById(g,m)}else if(b instanceof ve){if(typeof g=="number")throw new Error("illegal arg");m=b.modifyById(g,m)}else if(b instanceof de){if(typeof g=="number")throw new Error("illegal arg");m=b.modifyById(g,m)}else if(b instanceof Je){let w={...b,[g]:m};m=Object.setPrototypeOf(w,Je.prototype)}else if(typeof b=="object")if(Array.isArray(b)){if(typeof g=="string"&&(g=parseInt(g),isNaN(g)))throw new Error("Invalid path");let w=m;m=[...b],m[g]=w}else m={...b,[g]:m};else return null}return{data:m,actual:{...p.actual,path:u},reverse:{...p.reverse,path:u}}}else return null;let f=u[d.length],h;if(l instanceof ut){if(typeof f=="number")throw new Error("");h=l.get(f)?.data}else if(l instanceof ve){if(typeof f=="number")throw new Error("");h=l.get(f)?.data}else l!==null&&(h=l[f]);if(h!==void 0)d.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})(vt||(vt={}));var ml;(l=>{function i(){return[]}l.empty=i;function t(c,u){let d=[];for(let p of c){let[f,...h]=p.path;f===u&&d.push({...p,path:h})}return d}l.removePrefix=t;function e(c,u){return c.map(d=>({...d,path:[u,...d.path]}))}l.addPrefix=e;function r(c,u){return[...c,...u]}l.concat=r;function o(c,u){return[...c.filter(p=>!u.some(f=>vt.subsumed(p,f))),...u]}l.compress=o;function n(c,u){return c.every(d=>u.every(p=>vt.commutative(d,p)))}l.commutative=n;function a(c,u){for(let d of u){let p=s(c,d);p!==null&&(c=p.data)}return c}l.applyAll=a;function s(c,u){var d=c;let p=[],f=[];for(let h of u)try{if(h.type===3||h.type===5&&h.path[h.path.length-1]==="variables"){let m,y,g;if(h.type===3?(m=dt.zoom(d,[...h.path,h.id]),g=vt.apply(d,{...h,type:2})):(m=dt.zoom(d,[...h.path,h.id,"value"]),g=vt.apply(d,h)),g!==null){d=g.data;let[b,w]=Yg(d,{[h.id]:m});d=b;for(let P=0;P<w.length;P++){let S=w[P],T=S.pop();if(typeof T=="number"){let A=[T];for(let N=P+1;N<w.length;N++){let E=w[N],M=E[E.length-1];if(typeof M=="number"&&dt.equal(S,E.slice(0,E.length-1)))A.push(M),w.splice(N,1);else break}let x=dt.zoom(d,S);y=x.map((N,E)=>A.includes(E)?h.id:N),m=x,T=S.pop()}else{if(T==="alphaOverride"||T==="alpha"){m/=100;let A=m,x=dt.zoom(d,S.slice(0,S.length-2)),N=x.layers.map(E=>E.id===S[S.length-1]?{...E,data:{...E.data,[T]:A}}:E);Object.setPrototypeOf(N,Object.getPrototypeOf(x.layers)),x.layers=N}y=h.id}p.push({type:0,path:S,props:{[T]:m}}),f.push({type:0,path:S,props:{[T]:y}})}f.push(g.reverse),p.push(g.actual)}}else{let m=vt.apply(d,h);m!==null&&(p.push(m.actual),d=m.data,f.push(m.reverse))}}catch(m){if(m instanceof Oa)return null;throw m}return{data:d,actual:p,reverse:f.reverse()}}l.apply=s})(ml||(ml={}));var Qg=Symbol(),sA=Symbol(),su=Symbol(),Cn=class{reportOp(t,e,r=[]){let o=this;if(e===null)return;o._current=e.data;let n=r;for(;!(o instanceof au);){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[su];r&&r(),delete this._children[t]}}}},Fp=class extends Cn{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,Ca.runOp(this._current,t),t.path)}},jp=class extends Cn{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))}},Zg={get(i,t){if(t===su)return()=>{i._parent=null};if(t===Qg)return i._current;if(t===sA)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=lu(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]}}},lA={...Zg,set(i,t,e){let r={type:0,props:{[t]:wt(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}},cA={...Zg,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}},Ia=class extends Cn{constructor(t,e,r){super(),this._children={},this._parent=t,this._path=e,this._current=r,this[su]=()=>{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=lu(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)}},Ea=class extends Cn{constructor(t,e,r){super(),this._children={},this._parent=t,this._path=e,this._current=r,this[su]=()=>{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=lu(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 Gp(i,t,e){if(i.length>0){let r=i[i.length-1];if(r.type===0&&t.type===0&&dt.equal(r.path,e)){Object.assign(r.props,t.props);return}}i.push({...t,path:e})}var au=class extends Cn{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){Gp(this.ts,e,t),Gp(this.actual,r,t),Gp(this.reverse,o,t)}result(){return{data:this._current,ts:this.ts,actual:this.actual,reverse:this.reverse.reverse()}}};function lu(i,t,e){return e instanceof ut?new Ia(i,t,e):e instanceof ve?new Ea(i,t,e):e instanceof de?new Proxy(new jp(i,t,e),cA):e!==null&&typeof e=="object"?Ta(e)?e:new Proxy(new Fp(i,t,e),lA):e}function Up(i){let t=new au(i);return[lu(t,"",i),t]}function Di(i,t){let[e,r]=Up(i);return t(e),r.result()}function wt(i){return i instanceof Ia||i instanceof Ea?i._current:i!==null&&typeof i=="object"?i[Qg]:i}var dt;(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 ut||n instanceof Ia)&&typeof a=="string")return n.data(a);if((n instanceof ve||n instanceof Ea)&&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})(dt||(dt={}));function Jg(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 Ue(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 cu=class{},yl=class extends cu{constructor(e){super();this.id=e}},gl=class extends cu{constructor(e){super();this.data=e}};var Hp;try{Hp=new TextDecoder}catch{}var fe,Ri,G=0;var s0=[],Wp=s0,qp=0,wr={},Ze,_i,kr=0,Ao=0,Br,ri,mr=[],rt,e0={useRecords:!1,mapsAsObjects:!0},xl=class{},Xp=new xl;Xp.name="MessagePack 0xC1";var Na=!1,Mo=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 p0(()=>(du(),this?this.unpack(t,e):Mo.prototype.unpack.call(e0,t,e)));Ri=e>-1?e:t.length,G=0,qp=0,Ao=0,_i=null,Wp=s0,Br=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 Mo){if(wr=this,this.structures)return Ze=this.structures,uu();(!Ze||Ze.length>0)&&(Ze=[])}else wr=e0,(!Ze||Ze.length>0)&&(Ze=[]);return uu()}unpackMultiple(t,e){let r,o=0;try{Na=!0;let n=t.length,a=this?this.unpack(t,n):hu.unpack(t,n);if(e){for(e(a);G<n;)if(o=G,e(uu())===!1)return}else{for(r=[a];G<n;)o=G,r.push(uu());return r}}catch(n){throw n.lastPosition=o,n.values=r,n}finally{Na=!1,du()}}_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 uu(){try{if(!wr.trusted&&!Na){let t=Ze.sharedLength||0;t<Ze.length&&(Ze.length=t)}let i=Et();if(G==Ri)Ze.restoreStructures&&t0(),Ze=null,fe=null,ri&&(ri=null);else if(G>Ri){let t=new Error("Unexpected end of MessagePack data");throw t.incomplete=!0,t}else if(!Na)throw new Error("Data read, but end of buffer not reached");return i}catch(i){throw Ze.restoreStructures&&t0(),du(),(i instanceof RangeError||i.message.startsWith("Unexpected end of buffer"))&&(i.incomplete=!0),i}}function t0(){for(let i in Ze.restoreStructures)Ze[i]=Ze.restoreStructures[i];Ze.restoreStructures=null}function Et(){let i=fe[G++];if(i<160)if(i<128){if(i<64)return i;{let t=Ze[i&63]||wr.getStructures&&l0()[i&63];return t?(t.read||(t.read=Yp(t,i&63)),t.read()):i}}else if(i<144)if(i-=128,wr.mapsAsObjects){let t={};for(let e=0;e<i;e++)t[u0()]=Et();return t}else{let t=new Map;for(let e=0;e<i;e++)t.set(Et(),Et());return t}else{i-=144;let t=new Array(i);for(let e=0;e<i;e++)t[e]=Et();return t}else if(i<192){let t=i-160;if(Ao>=G)return _i.slice(G-kr,(G+=t)-kr);if(Ao==0&&Ri<140){let e=t<16?Kp(t):c0(t);if(e!=null)return e}return $p(t)}else{let t;switch(i){case 192:return null;case 193:return Br?(t=Et(),t>0?Br[1].slice(Br.position1,Br.position1+=t):Br[0].slice(Br.position0,Br.position0-=t)):Xp;case 194:return!1;case 195:return!0;case 196:return kp(fe[G++]);case 197:return t=rt.getUint16(G),G+=2,kp(t);case 198:return t=rt.getUint32(G),G+=4,kp(t);case 199:return An(fe[G++]);case 200:return t=rt.getUint16(G),G+=2,An(t);case 201:return t=rt.getUint32(G),G+=4,An(t);case 202:if(t=rt.getFloat32(G),wr.useFloat32>2){let e=fu[(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 wr.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 wr.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 a0(fe[G++]&63);{let e=mr[t];if(e)return e.read?(G++,e.read(Et())):e.noBuffer?(G++,e()):e(fe.subarray(G,++G));throw new Error("Unknown extension "+t)}case 213:return t=fe[G],t==114?(G++,a0(fe[G++]&63,fe[G++])):An(2);case 214:return An(4);case 215:return An(8);case 216:return An(16);case 217:return t=fe[G++],Ao>=G?_i.slice(G-kr,(G+=t)-kr):dA(t);case 218:return t=rt.getUint16(G),G+=2,Ao>=G?_i.slice(G-kr,(G+=t)-kr):pA(t);case 219:return t=rt.getUint32(G),G+=4,Ao>=G?_i.slice(G-kr,(G+=t)-kr):fA(t);case 220:return t=rt.getUint16(G),G+=2,o0(t);case 221:return t=rt.getUint32(G),G+=4,o0(t);case 222:return t=rt.getUint16(G),G+=2,i0(t);case 223:return t=rt.getUint32(G),G+=4,i0(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 uA=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function Yp(i,t){function e(){if(e.count++>2){let o=i.read=new Function("r","return function(){return {"+i.map(n=>uA.test(n)?n+":r()":"["+JSON.stringify(n)+"]:r()").join(",")+"}}")(Et);return i.highByte===0&&(i.read=r0(t,i.read)),o()}let r={};for(let o=0,n=i.length;o<n;o++){let a=i[o];r[a]=Et()}return r}return e.count=0,i.highByte===0?r0(t,e):e}var r0=(i,t)=>function(){let e=fe[G++];if(e===0)return t();let r=i<32?-(i+(e<<5)):i+(e<<5),o=Ze[r]||l0()[r];if(!o)throw new Error("Record id is not defined for "+r);return o.read||(o.read=Yp(o,i)),o.read()};function l0(){let i=p0(()=>(fe=null,wr.getStructures()));return Ze=wr._mergeStructures(i,Ze)}var $p=pu,dA=pu,pA=pu,fA=pu;function pu(i){let t;if(i<16&&(t=Kp(i)))return t;if(i>64&&Hp)return Hp.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+=Jt.apply(String,r),r.length=0)}return r.length>0&&(t+=Jt.apply(String,r)),t}function o0(i){let t=new Array(i);for(let e=0;e<i;e++)t[e]=Et();return t}function i0(i){if(wr.mapsAsObjects){let t={};for(let e=0;e<i;e++)t[u0()]=Et();return t}else{let t=new Map;for(let e=0;e<i;e++)t.set(Et(),Et());return t}}var Jt=String.fromCharCode;function c0(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 Jt.apply(String,e)}function Kp(i){if(i<4)if(i<2){if(i===0)return"";{let t=fe[G++];if((t&128)>1){G-=1;return}return Jt(t)}}else{let t=fe[G++],e=fe[G++];if((t&128)>0||(e&128)>0){G-=2;return}if(i<3)return Jt(t,e);let r=fe[G++];if((r&128)>0){G-=3;return}return Jt(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 Jt(t,e,r,o);{let n=fe[G++];if((n&128)>0){G-=5;return}return Jt(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 Jt(t,e,r,o,n,a);let s=fe[G++];if((s&128)>0){G-=7;return}return Jt(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 Jt(t,e,r,o,n,a,s,l);{let c=fe[G++];if((c&128)>0){G-=9;return}return Jt(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 Jt(t,e,r,o,n,a,s,l,c,u);let d=fe[G++];if((d&128)>0){G-=11;return}return Jt(t,e,r,o,n,a,s,l,c,u,d)}else{let c=fe[G++],u=fe[G++],d=fe[G++],p=fe[G++];if((c&128)>0||(u&128)>0||(d&128)>0||(p&128)>0){G-=12;return}if(i<14){if(i===12)return Jt(t,e,r,o,n,a,s,l,c,u,d,p);{let f=fe[G++];if((f&128)>0){G-=13;return}return Jt(t,e,r,o,n,a,s,l,c,u,d,p,f)}}else{let f=fe[G++],h=fe[G++];if((f&128)>0||(h&128)>0){G-=14;return}if(i<15)return Jt(t,e,r,o,n,a,s,l,c,u,d,p,f,h);let m=fe[G++];if((m&128)>0){G-=15;return}return Jt(t,e,r,o,n,a,s,l,c,u,d,p,f,h,m)}}}}}function kp(i){return wr.copyBuffers?Uint8Array.prototype.slice.call(fe,G,G+=i):fe.subarray(G,G+=i)}function An(i){let t=fe[G++];if(mr[t])return mr[t](fe.subarray(G,G+=i));throw new Error("Unknown extension type "+t)}var n0=new Array(4096);function u0(){let i=fe[G++];if(i>=160&&i<192){if(i=i-160,Ao>=G)return _i.slice(G-kr,(G+=i)-kr);if(!(Ao==0&&Ri<180))return $p(i)}else return G--,Et();let t=(i<<5^(i>1?rt.getUint16(G):i>0?fe[G]:0))&4095,e=n0[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=[],n0[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?Kp(i):c0(i);return s!=null?e.string=s:e.string=$p(i)}var a0=(i,t)=>{var e=Et();let r=i;t!==void 0&&(i=i<32?-((t<<5)+i):(t<<5)+i,e.highByte=t);let o=Ze[i];return o&&o.isShared&&((Ze.restoreStructures||(Ze.restoreStructures=[]))[i]=o),Ze[i]=e,e.read=Yp(e,r),e.read()},d0=typeof self=="object"?self:global;mr[0]=()=>{};mr[0].noBuffer=!0;mr[101]=()=>{let i=Et();return(d0[i[0]]||Error)(i[1])};mr[105]=i=>{let t=rt.getUint32(G-4);ri||(ri=new Map);let e=fe[G],r;e>=144&&e<160||e==220||e==221?r=[]:r={};let o={target:r};ri.set(t,o);let n=Et();return o.used?Object.assign(r,n):(o.target=n,n)};mr[112]=i=>{let t=rt.getUint32(G-4),e=ri.get(t);return e.used=!0,e.target};mr[115]=()=>new Set(Et());var Qp=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(i=>i+"Array");mr[116]=i=>{let t=i[0],e=Qp[t];if(!e)throw new Error("Could not find typed array for code "+t);return new d0[e](Uint8Array.prototype.slice.call(i,1).buffer)};mr[120]=()=>{let i=Et();return new RegExp(i[0],i[1])};mr[98]=i=>{let t=(i[0]<<24)+(i[1]<<16)+(i[2]<<8)+i[3],e=G;G+=t-4,Br=[Et(),Et()],Br.position0=0,Br.position1=0;let r=G;G=e;try{return Et()}finally{G=r}};mr[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 p0(i){let t=Ri,e=G,r=qp,o=kr,n=Ao,a=_i,s=Wp,l=ri,c=Br,u=new Uint8Array(fe.slice(0,Ri)),d=Ze,p=Ze.slice(0,Ze.length),f=wr,h=Na,m=i();return Ri=t,G=e,qp=r,kr=o,Ao=n,_i=a,Wp=s,ri=l,Br=c,fe=u,Na=h,Ze=d,Ze.splice(0,Ze.length,...p),wr=f,rt=new DataView(fe.buffer,fe.byteOffset,fe.byteLength),m}function du(){fe=null,ri=null,Ze=null}function f0(i){i.unpack?mr[i.type]=i.unpack:mr[i.type]=i}var fu=new Array(147);for(let i=0;i<256;i++)fu[i]=+("1e"+Math.floor(45.15-i*.30103));var hu=new Mo({useRecords:!1}),hA=hu.unpack,mA=hu.unpackMultiple,yA=hu.unpack,mu={NEVER:0,ALWAYS:1,DECIMAL_ROUND:3,DECIMAL_FIT:4},gA=new Float32Array(1),wF=new Uint8Array(gA.buffer,0,4);var yu;try{yu=new TextEncoder}catch{}var gu,Jp,xu=typeof Buffer<"u",Zp=xu?Buffer.allocUnsafeSlow:Uint8Array,g0=xu?Buffer:Uint8Array,h0=xu?4294967296:2144337920,X,Lt,k=0,Io,Eo=null,xA=/[\u0080-\uFFFF]/,bl=Symbol("record-id"),Mn=class extends Mo{constructor(t){super(t),this.offset=0;let e,r,o,n,a,s,l=0,c=g0.prototype.utf8Write?function(x,N,E){return X.utf8Write(x,N,E)}:yu&&yu.encodeInto?function(x,N){return yu.encodeInto(x,X.subarray(N)).written}:!1,u=this;t||(t={});let d=t&&t.sequential,p=t.structures||t.saveStructures,f=t.maxSharedStructures;if(f==null&&(f=p?32:0),f>8160)throw new Error("Maximum maxSharedStructure is 8160");let h=t.maxOwnStructures;h==null&&(h=p?32:64),d&&!t.saveStructures&&(this.structures=[]);let m=f>32||h+f>64,y=f+64,g=f+h+64;if(g>8256)throw new Error("Maximum maxSharedStructure + maxOwnStructure is 8192");let b=[],w=0,P=0;this.pack=this.encode=function(x,N){if(X||(X=new Zp(8192),Lt=new DataView(X.buffer,0,8192),k=0),Io=X.length-10,Io-k<2048?(X=new Zp(X.length),Lt=new DataView(X.buffer,0,X.length),Io=X.length-10,k=0):k=k+7&2147483640,r=k,s=u.structuredClone?new Map:null,u.bundleStrings?(Eo=["",""],X[k++]=214,X[k++]=98,Eo.position=k-r,k+=4):Eo=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 M=0;M<E;M++){let D=o[M];if(!D)continue;let _,R=o.transitions;for(let V=0,U=D.length;V<U;V++){let B=D[V];_=R[B],_||(_=R[B]=Object.create(null)),R=_}R[bl]=M+64}l=E}d||(o.nextId=E+64)}n&&(n=!1),a=o||[];try{if(S(x),Eo){Lt.setUint32(Eo.position+r,k-Eo.position-r);let E=Eo;Eo=null,S(E[0]),S(E[1])}if(u.offset=k,s&&s.idsToInsert){k+=s.idsToInsert.length*6,k>Io&&A(k),u.offset=k;let E=vA(X.subarray(r,k),s.idsToInsert);return s=null,E}return N&b0?(X.start=r,X.end=k,X):X.subarray(r,k)}finally{if(o){if(P<10&&P++,w>1e4)o.transitions=null,P=0,w=0,b.length>0&&(b=[]);else if(b.length>0&&!d){for(let E=0,M=b.length;E<M;E++)b[E][bl]=0;b=[]}if(n&&u.saveStructures){let E=o.sharedLength||f;o.length>E&&(o=o.slice(0,E));let M=X.subarray(r,k);return u.saveStructures(o,l)===!1?(u._mergeStructures(u.getStructures()),u.pack(x)):(l=E,M)}}N&AA&&(k=r)}};let S=x=>{k>Io&&(X=A(k));var N=typeof x,E;if(N==="string"){let M=x.length;if(Eo&&M>=8&&M<4096){let R=xA.test(x);Eo[R?0:1]+=x,X[k++]=193,S(R?-M:M);return}let D;M<32?D=1:M<256?D=2:M<65536?D=3:D=5;let _=M*3;if(k+_>Io&&(X=A(k+_)),M<64||!c){let R,V,U,B=k+D;for(R=0;R<M;R++)V=x.charCodeAt(R),V<128?X[B++]=V:V<2048?(X[B++]=V>>6|192,X[B++]=V&63|128):(V&64512)===55296&&((U=x.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-D}else E=c(x,k+D,_);E<32?X[k++]=160|E:E<256?(D<2&&X.copyWithin(k+2,k+1,k+1+E),X[k++]=217,X[k++]=E):E<65536?(D<3&&X.copyWithin(k+3,k+2,k+2+E),X[k++]=218,X[k++]=E>>8,X[k++]=E&255):(D<5&&X.copyWithin(k+5,k+3,k+3+E),X[k++]=219,Lt.setUint32(k,E),k+=4),k+=E}else if(N==="number")if(x>>>0===x)x<64?X[k++]=x:x<256?(X[k++]=204,X[k++]=x):x<65536?(X[k++]=205,X[k++]=x>>8,X[k++]=x&255):(X[k++]=206,Lt.setUint32(k,x),k+=4);else if(x>>0===x)x>=-32?X[k++]=256+x:x>=-128?(X[k++]=208,X[k++]=x+256):x>=-32768?(X[k++]=209,Lt.setInt16(k,x),k+=2):(X[k++]=210,Lt.setInt32(k,x),k+=4);else{let M;if((M=this.useFloat32)>0&&x<4294967296&&x>=-2147483648){X[k++]=202,Lt.setFloat32(k,x);let D;if(M<4||(D=x*fu[(X[k]&127)<<1|X[k+1]>>7])>>0===D){k+=4;return}else k--}X[k++]=203,Lt.setFloat64(k,x),k+=8}else if(N==="object")if(!x)X[k++]=192;else{if(s){let D=s.get(x);if(D){if(!D.id){let _=s.idsToInsert||(s.idsToInsert=[]);D.id=_.push(D)}X[k++]=214,X[k++]=112,Lt.setUint32(k,D.id),k+=4;return}else s.set(x,{offset:k-r})}let M=x.constructor;if(M===Object)T(x,!0);else if(M===Array){E=x.length,E<16?X[k++]=144|E:E<65536?(X[k++]=220,X[k++]=E>>8,X[k++]=E&255):(X[k++]=221,Lt.setUint32(k,E),k+=4);for(let D=0;D<E;D++)S(x[D])}else if(M===Map){E=x.size,E<16?X[k++]=128|E:E<65536?(X[k++]=222,X[k++]=E>>8,X[k++]=E&255):(X[k++]=223,Lt.setUint32(k,E),k+=4);for(let[D,_]of x)S(D),S(_)}else{for(let D=0,_=gu.length;D<_;D++){let R=Jp[D];if(x instanceof R){let V=gu[D];if(V.write){V.type&&(X[k++]=212,X[k++]=V.type,X[k++]=0),S(V.write.call(this,x));return}let U=X,B=Lt,q=k;X=null;let j;try{j=V.pack.call(this,x,F=>(X=U,U=null,k+=F,k>Io&&A(k),{target:X,targetView:Lt,position:k-F}),S)}finally{U&&(X=U,Lt=B,k=q,Io=X.length-10)}j&&(j.length+k>Io&&A(j.length+k),k=bA(j,X,k,V.type));return}}T(x,!x.hasOwnProperty)}}else if(N==="boolean")X[k++]=x?195:194;else if(N==="bigint"){if(x<BigInt(1)<<BigInt(63)&&x>=-(BigInt(1)<<BigInt(63)))X[k++]=211,Lt.setBigInt64(k,x);else if(x<BigInt(1)<<BigInt(64)&&x>0)X[k++]=207,Lt.setBigUint64(k,x);else if(this.largeBigIntToFloat)X[k++]=203,Lt.setFloat64(k,Number(x));else throw new RangeError(x+" was too large to fit in MessagePack 64-bit integer format, set largeBigIntToFloat to convert to float-64");k+=8}else if(N==="undefined")this.encodeUndefinedAsNil?X[k++]=192:(X[k++]=212,X[k++]=0,X[k++]=0);else if(N==="function")S(this.writeFunction&&this.writeFunction());else throw new Error("Unknown type: "+N)},T=this.useRecords===!1?this.variableMapSize?x=>{let N=Object.keys(x),E=N.length;E<16?X[k++]=128|E:E<65536?(X[k++]=222,X[k++]=E>>8,X[k++]=E&255):(X[k++]=223,Lt.setUint32(k,E),k+=4);let M;for(let D=0;D<E;D++)S(M=N[D]),S(x[M])}:(x,N)=>{X[k++]=222;let E=k-r;k+=2;let M=0;for(let D in x)(N||x.hasOwnProperty(D))&&(S(D),S(x[D]),M++);X[E+++r]=M>>8,X[E+r]=M&255}:x=>{let N=Object.keys(x),E,M=a.transitions||(a.transitions=Object.create(null)),D=0;for(let R=0,V=N.length;R<V;R++){let U=N[R];E=M[U],E||(E=M[U]=Object.create(null),D++),M=E}let _=M[bl];if(_)_>=96&&m?(X[k++]=((_-=96)&31)+96,X[k++]=_>>5):X[k++]=_;else{_=a.nextId,_||(_=64),_<y&&this.shouldShareStructure&&!this.shouldShareStructure(N)?(_=a.nextOwnId,_<g||(_=y),a.nextOwnId=_+1):(_>=g&&(_=y),a.nextId=_+1);let R=N.highByte=_>=96&&m?_-96>>5:-1;M[bl]=_,a[_-64]=N,_<y?(N.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++]=_),D&&(w+=P*D),b.length>=h&&(b.shift()[bl]=0),b.push(M),S(N))}for(let R=0,V=N.length;R<V;R++)S(x[N[R]])},A=x=>{let N;if(x>16777216){if(x-r>h0)throw new Error("Packed buffer would be larger than maximum buffer size");N=Math.min(h0,Math.round(Math.max((x-r)*(x>67108864?1.25:2),4194304)/4096)*4096)}else N=(Math.max(x-r<<2,X.length-1)>>12)+1<<12;let E=new Zp(N);return Lt=new DataView(E.buffer,0,N),X.copy?X.copy(E,0,r,x):E.set(X.slice(r,x)),k-=r,r=0,Io=E.length-10,X=E}}useBuffer(t){X=t,Lt=new DataView(X.buffer,X.byteOffset,X.byteLength),k=0}};Jp=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,xl];gu=[{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?m0(i,16,t):y0(xu?Buffer.from(i):new Uint8Array(i),t)}},{pack(i,t){let e=i.constructor;e!==g0&&this.structuredClone?m0(i,Qp.indexOf(e.name),t):y0(i,t)}},{pack(i,t){let{target:e,position:r}=t(1);e[r]=193}}];function m0(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 y0(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 bA(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 vA(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 Li(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)");Jp.unshift(i.Class),gu.unshift(i)}f0(i)}var x0=new Mn({useRecords:!1}),SA=x0.pack,wA=x0.pack;var{NEVER:PA,ALWAYS:OA,DECIMAL_ROUND:TA,DECIMAL_FIT:CA}=mu,b0=512,AA=1024;var v0=new Mn({structuredClone:!0});Li({Class:de.prototype.constructor,type:1,write(i){return{...i}},read(i){return Object.setPrototypeOf(i,de.prototype),i}});Li({Class:ve.prototype.constructor,type:2,write(i){return[...i]},read(i){return Object.setPrototypeOf(i,ve.prototype),i}});Li({Class:ut.prototype.constructor,type:3,write(i){return[...i]},read(i){return Object.setPrototypeOf(i,ut.prototype),i}});Li({Class:yl.prototype.constructor,type:4,write(i){return i.id},read(i){return new yl(i)}});Li({Class:gl.prototype.constructor,type:5,write(i){return i.data},read(i){return new gl(i)}});Li({Class:Je.prototype.constructor,type:6,write(i){return{...i}},read(i){return Object.setPrototypeOf(i,Je.prototype),i}});function MA(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 ef(i){if(Ta(i))return i;if(Array.isArray(i))return i.map(ef);if(typeof i=="object"&&i!==null){let t={};for(let e of Object.keys(i).sort())t[e]=ef(i[e]);return Object.setPrototypeOf(t,Object.getPrototypeOf(i)),t}else return i}var bu;(r=>{function i(o){return v0.pack(o)}r.serialize=i;function t(o){return v0.unpack(o)}r.deserialize=t;function e(o){return MA(i(ef(o))).toString()}r.checksum=e})(bu||(bu={}));var zi="personal camera",Gi="a218fcc3-276b-49b9-b485-49037fd14f5f",C0=2960946;var Bt=5526619;var Da;(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 g=f.sub(m,h),b=f.sub(y,h),w=f.dot(g,b)/f.dot(g,g),P=f.scalarMultiply(g,w);return f.add(h,P)}f.projectionOnto=u;function d(h,m,y){return s(h,u(h,m,y))}f.projectionOntoDistance=d;function p(h,m){return[(h[0]+m[0])*.5,(h[1]+m[1])*.5]}f.center=p})(Da||(Da={}));var Bi;(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})(Bi||(Bi={}));var S0;(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})(S0||(S0={}));var w0;(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})(w0||(w0={}));var Vi;(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})(Vi||(Vi={}));var jt;(p=>{function i(f){return typeof f=="object"&&typeof f.r=="number"&&typeof f.g=="number"&&typeof f.b=="number"}p.isRGB=i,p.white={r:1,g:1,b:1},p.red={r:1,g:0,b:0},p.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}}p.toRgb255a1=o;function n(f){return{r:f.r,g:f.g,b:f.b}}p.clone=n;function a(f){return f=Math.floor(f),{r:(f>>16&255)/255,g:(f>>8&255)/255,b:(f&255)/255}}p.fromHex=a;function s(f){return Math.round(f.r*255)*65536+Math.round(f.g*255)*256+Math.round(f.b*255)}p.toHex=s;function l(f,h){return f.r===h.r&&f.g===h.g&&f.b===h.b}p.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)}p.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}}p.lerp=u;function d(f){return It(f)?"r"in f&&"g"in f&&"b"in f&&!("a"in f):!1}p.is=d})(jt||(jt={}));var Le;(u=>{u.white={...jt.white,a:1};function t(d){return It(d)?"r"in d&&"g"in d&&"b"in d&&"a"in d:!1}u.is=t,u.transparent={...jt.white,a:0};function r(d){return{r:d[0],g:d[1],b:d[2],a:d[3]}}u.from0to1=r;function o(d,p){return{...jt.fromHex(d),a:p}}u.fromHexAndA=o;function n(d){return{r:Math.round(d.r*255),g:Math.round(d.g*255),b:Math.round(d.b*255),a:d.a}}u.toRgb255a1=n;function a(d,p){return jt.equals(d,p)&&d.a===p.a}u.equals=a;function s(d,p){return jt.equalsFixed(d,p)&&d.a.toFixed(2)===p.a.toFixed(2)}u.equalsFixed=s;function l(d,p,f){return{r:d.r+(p.r-d.r)*f,g:d.g+(p.g-d.g)*f,b:d.b+(p.b-d.b)*f,a:d.a+(p.a-d.a)*f}}u.lerp=l;function c({r:d,g:p,b:f,a:h}=u.white){return`rgba(${d*255}, ${p*255}, ${f*255}, ${h})`}u.toStyle=c})(Le||(Le={}));var vu;(t=>t.identity={position:[0,0,0],rotation:[0,0,0],scale:[1,1,1],pivot:[0,0,0],pivotRotation:[0,0,0]})(vu||(vu={}));var P0;(t=>t.defaultData={mass:1,stiffness:80,damping:10,velocity:0})(P0||(P0={}));var O0;(t=>t.defaultData={control1:[.5,0],control2:[.5,1]})(O0||(O0={}));var T0;(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]))(T0||(T0={}));function tf(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 ao;(e=>{e.all=["PerspectiveCamera","OrthographicCamera"];function t(r){return e.all.includes(r)}e.is=t})(ao||(ao={}));var Fi;(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})(Fi||(Fi={}));var No;(r=>{function i(o,n=.1){return{disabled:!1,type:"linear",hideBase:!1,count:3,radial:{radius:Math.max(typeof o[0]=="number"?o[0]:1,typeof o[1]=="number"?o[1]:1)*2,start:0,end:360,alignment:!1,axis:"y",scale:[1,1,1],rotation:[0,0,0],position:[0,0,0],pivot:[0,0,0],pivotRotation:[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",pivot:[0,0,0],pivotRotation:[0,0,0]},linear:{scale:[1,1,1],rotation:[0,0,0],position:[(typeof o[0]=="number"?o[0]+o[0]:1)*n,0,0],pivot:[0,0,0],pivotRotation:[0,0,0]},grid:{count:[2,2,2],size:o.map(a=>(typeof a=="number"?a:1)*(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(IA.forEach(s=>{Object.assign(a,{[s]:n[s]??o[s]})}),a.radial={...o.radial},n.radial){let s=o.radial,l=n.radial;EA.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;NA.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;DA.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;_A.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;RA.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})(No||(No={}));var Su;(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})(Su||(Su={}));var IA=["count"],EA=["radius","start","end","position","scale","rotation"],NA=["position","scale","rotation"],DA=["count","size"],_A=["count","position","scale","rotation"],RA=["strength","scale","rotation","position","movement","seed","freqScale"];var wu;(e=>{e.all=["PointLight","SpotLight","DirectionalLight","HemisphereLight"];function t(r){return e.all.includes(r)}e.is=t})(wu||(wu={}));var Pu;(e=>{function i(r){return t(r)}e.defaultData=i;function t(r){if(r==="PointLight")return{type:r,color:Le.white,intensity:1,distance:2e3,decay:1,shadows:!0,shadowResolution:1024,shadowRadius:1,penumbraSize:.5,depth:1e5};if(r==="SpotLight")return{type:r,color:Le.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:Le.white,intensity:1,shadows:!0,size:2e3,depth:1e5,penumbraSize:.5,shadowResolution:1024,shadowRadius:1};throw new Error("not implemented")}})(Pu||(Pu={}));var _a;(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}))(_a||(_a={}));var ji;(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]})(ji||(ji={}));var rf;(e=>{e.defaultData={castShadow:!0,receiveShadow:!0};function t(r,o){return r.castShadow===o.castShadow&&r.receiveShadow===o.receiveShadow}e.equals=t})(rf||(rf={}));var of;(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})(of||(of={}));var Ou;(t=>t.defaultData={...of.defaultData,...rf.defaultData})(Ou||(Ou={}));var A0;(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})(A0||(A0={}));var Ra;(e=>(e.defaultVideo={data:"",thumb:"/_assets/_videos/catThumb.png",type:"video",name:"Cat video"},e.maxSize=3e7))(Ra||(Ra={}));var M0;(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})(M0||(M0={}));function E0(i){return i.type!=="displace"}var I0;(t=>{function i(e){return e==="phong"||e==="toon"||e==="lambert"||e==="physical"}t.is=i})(I0||(I0={}));var N0=["mode","gradientType","noiseType","displacementType","projection","cnormal","crop","axis","side"],D0=["wrapping","image","video","name","minFilter","magFilter"],Nt;(n=>{function i(a,s){let{texture:l,...c}=s;if(Object.assign(a,c),l){let u=a.texture;u&&Object.assign(u,l)}}n.patch=i;function t(a){return{...n.defaultData("color"),color:a}}n.defaultColorLayer=t;function e(a,s){return a==="light"&&s?r(s):o(a)}n.defaultData=e;function r(a){let s={mode:0,isMask:!1,visible:!0,bumpMap:void 0,bumpMapIntensity:5,roughnessMap:void 0,alphaOverride:1};switch(a){case"phong":return{...s,category:"phong",specular:{r:.2,g:.2,b:.2},shininess:5,type:"light",visible:!0,mode:0,occlusion:!0,alpha:.6};case"toon":return{...s,category:"toon",specular:{r:.2,g:.2,b:.2},shininess:10,type:"light",alpha:1};case"lambert":return{...s,category:"lambert",emissive:{r:0,g:0,b:0},type:"light",alpha:1,visible:!0,mode:0,occlusion:!0};case"physical":return{...s,category:"physical",roughness:.2,metalness:.2,reflectivity:.2,type:"light",alpha:1,visible:!0,mode:0,occlusion:!0}}}function o(a){let s={alpha:1,mode:0,isMask:!1,visible:!0};switch(a){case"texture":return{...s,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{...s,type:"video",size:[128,128],blending:0,axis:"x",side:2,projection:0,texture:{video:Ra.defaultVideo,wrapping:1001,repeat:[1,1],offset:[0,0],rotation:0,minFilter:1008,magFilter:1006},crop:!1};case"color":return{...s,type:"color",color:jt.fromHex(Bt)};case"depth":return{...s,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{...s,type:"normal",cnormal:[1,1,1]};case"gradient":return{...s,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{...s,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{...s,type:"fresnel",color:Le.fromHexAndA(16777215,1),bias:.1,scale:1,intensity:2,factor:1};case"rainbow":return{...s,type:"rainbow",filmThickness:30,movement:0,wavelengths:[0,0,0],noiseStrength:0,noiseScale:1,offset:[0,0,0]};case"toon":return{...s,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:Le.fromHexAndA(0,0),offset:[0,0,0]};case"outline":return{...s,type:"outline",outlineColor:Le.fromHexAndA(0,1),contourColor:Le.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{...s,type:"matcap",texture:{image:"matcap_0",wrapping:1001,repeat:[1,1],offset:[0,0],rotation:0,minFilter:1008,magFilter:1006}};case"transmission":return{...s,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{...s,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}}}})(Nt||(Nt={}));var Wt;(u=>{function i(d){return!d.layers.some(f=>f.data.type==="texture"&&f.data.projection!==0||f.data.type==="depth"&&!f.data.isWorldSpace||f.data.type==="noise"||f.data.type==="displace")}u.isMergable=i;function t(d){let p="";return d.layers.forEach(f=>{Object.entries(f.data).forEach(([h,m])=>{p+=`${h}${m}`,Array.isArray(m)?m.forEach(y=>p+=`${y}`):typeof m=="object"?Object.values(m).forEach(y=>{typeof y=="number"?p+=`${y.toFixed(4)}`:p+=`${y}`}):p+=`${m}`})}),p}u.getHash=t;function e(){return{layers:new ve}}u.defaultEmptyData=e;function r(d="layer1",p="layer2"){return n("phong",d,p)}u.defaultData=r;function o(d,p){return{...d,name:p}}u.withName=o;function n(d,p="layer1",f="layer2",h=jt.fromHex(16777215)){let m=new ve;return m.push({fi:0,data:Nt.defaultData("light",d),id:p}),m.push({fi:1,data:Nt.defaultData("color"),id:f}),{layers:m}}u.defaultTwoLayerData=n;function a(d,p,f="layer1",h="layer2"){let m=new ve;return m.push({fi:0,data:Nt.defaultData("light",p),id:f}),m.push({fi:1,data:Nt.defaultColorLayer(d),id:h}),{layers:m}}u.defaultColorMaterial=a;function s(d){let p=Nt.defaultData("texture");d&&Object.assign(p.texture,{image:d});let f=new ve;return f.push({fi:0,data:p,id:"layer1"}),f.push({fi:1,data:{...Nt.defaultData("transmission"),alpha:1},id:"layer2"}),f.push({fi:2,data:{...Nt.defaultData("light","lambert"),alpha:0},id:"layer3"}),{layers:f}}u.defaultUIObjectMaterial=s;function l(d,p="phong",f="layer1",h="layer2"){let m=Nt.defaultData("texture");Object.assign(m.texture,{image:d});let y=new ve;return y.push({fi:0,data:m,id:f}),y.push({fi:1,data:Nt.defaultData("light",p),id:h}),{layers:y}}u.defaultTwoLayerTextureData=l;function c(d,p="phong",f="layer1",h="layer2"){let m=Nt.defaultData("video");Object.assign(m.texture,{video:d});let y=new ve;return y.push({fi:0,data:m,id:f}),y.push({fi:1,data:Nt.defaultData("light",p),id:h}),{layers:y}}u.defaultTwoLayerVideoTextureData=c})(Wt||(Wt={}));var La;(t=>{function i(){return{points:new ve,roundness:0,shapeHoles:[],isClosed:!1}}t.defaultData=i})(La||(La={}));var Ba;(t=>{function i(){return{points:new ve,lastInsertionPlane:null,subdivisions:12,isClosed:!1,subdivisionMode:"parametric"}}t.defaultData=i})(Ba||(Ba={}));var In={type:"Ellipse",width:50,height:50,spikes:16,angle:360,innerRadius:0};var Tu;(t=>{function i(e,r){let o={...e};return LA.forEach(n=>{Object.assign(o,{[n]:r[n]??e[n]})}),o}t.merge=i})(Tu||(Tu={}));var Cu={shape:In,depth:1,offset:0,bevel:50,bevelSides:6,angle:0,twist:0,startScale:1,endScale:1,capType:"flat"},LA=["depth","offset","angle","twist","startScale","endScale"];var vl;(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})(vl||(vl={}));var Au;(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,Tu.merge(o.extrusion,r.extrusion))),o}t.merge=i})(Au||(Au={}));var Do;(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:Ba.defaultData(),extrusion:Cu};if(e==="VectorGeometry")return{width:1,height:1,type:e,subdivisions:12,shape:La.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})(Do||(Do={}));var Mu;(t=>t.defaultData={enabled:!1,useBackgroundColor:!1,color:jt.white,near:.1,far:2e3})(Mu||(Mu={}));var Iu;(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}}})(Iu||(Iu={}));var nf;(t=>t.defaultData={softShadowQuality:"low"})(nf||(nf={}));var af;(t=>t.defaultData={enabled:!0,color:{r:.8274509803921568,g:.8274509803921568,b:.8274509803921568},intensity:.75})(af||(af={}));var sf;(t=>t.defaultData={occlusion:!1,aoFullRes:!1,radius:256,bias:.5,aoColor:{r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}})(sf||(sf={}));var Sl;(t=>t.defaultData={usePhysics:!1,gravity:-10})(Sl||(Sl={}));var lf;(t=>t.defaultData={playCamera:zi,gameControlObject:null})(lf||(lf={}));var Eu;(t=>t.defaultData={backgroundColor:Le.fromHexAndA(C0,1),postprocessing:Iu.defaultData,fog:Mu.defaultData,globalPhysics:Sl.defaultData,ambient:af.defaultData,ao:sf.defaultData,shadow:nf.defaultData,publish:lf.defaultData})(Eu||(Eu={}));var Nu;(t=>t.defaultData={colliderType:"box",size:[100,100,100],colliderHelperVisible:!0,forceType:"collider",forceRange:"global",forceIntensity:.5,forceDambing:.95})(Nu||(Nu={}));var _0;(e=>{function i(r){return r==="Component"||r==="Instance"}e.isComponentRelated=i;function t(r){return r==="Empty"||r==="Instance"}e.isEmptyOrComponent=t})(_0||(_0={}));var Va;(o=>{o.identity={...vu.identity,hiddenMatrix:Vi.identity};function t(n){return{position:n.position,rotation:n.rotation,scale:n.scale,pivot:n.pivot,pivotRotation:n.pivotRotation,hiddenMatrix:n.hiddenMatrix}}o.fromObject=t;function e(n,a){return{position:a?.position||n.position,rotation:a?.rotation||n.rotation,pivot:a?.pivot||n.pivot,pivotRotation:a?.pivotRotation||n.pivotRotation,scale:a?.scale||n.scale,hiddenMatrix:a?.hiddenMatrix||n.hiddenMatrix}}o.merge=e;function r(n,a){return Mc({position:Bi.isEqual(n.position,a.position)?void 0:a.position,rotation:Bi.isEqual(n.rotation,a.rotation)?void 0:a.rotation,scale:Bi.isEqual(n.scale,a.scale)?null:a.scale,hiddenMatrix:Vi.isEqual(n.hiddenMatrix,a.hiddenMatrix)?void 0:a.hiddenMatrix})}o.diff=r})(Va||(Va={}));var Vt;(t=>t.defaultData={states:new ve,events:new ve,timelineAnimations:new de,visible:!0,raycastLock:!1,physics:ji.defaultData,pathSnapping:{pathId:null,slide:0,offset:0,orientation:"tangential"},...Va.identity,cloner:null})(Vt||(Vt={}));var Du;(t=>t.defaultData={type:"Empty",...Vt.defaultData})(Du||(Du={}));var R0;(t=>t.defaultData={type:"ParticleCollider",...Nu.defaultData,...Vt.defaultData})(R0||(R0={}));var L0;(t=>t.defaultData={type:"Component",...Vt.defaultData})(L0||(L0={}));var B0;(t=>t.defaultData={type:"Particle",...Vt.defaultData,..._a.defaultData})(B0||(B0={}));var oi;(t=>t.defaultData={type:"Mesh",...Vt.defaultData,...Ou.defaultData})(oi||(oi={}));var En;(t=>t.defaultData={...Vt.defaultData,...Va.identity,position:[0,0,Fi.DefaultTargetOffset],...Fi.defaultData})(En||(En={}));var _u;(e=>{function i(r){return{...Vt.defaultData,...Pu.defaultData(r)}}e.defaultData=i,e.defaultDirectionalLightData={...e.defaultData("DirectionalLight"),position:[200,300,300],name:"Directional Light",intensity:.7}})(_u||(_u={}));var za;(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})(za||(za={}));var _o;(n=>{n.rootOverrideProps=["physics","events"],n.compositeNonOptionalOverrideProps=["geometry"],n.compositeEntireOverrideOverrideProps=["material"];function r(a,s){return{...Vt.defaultData,...s,component:a,overrides:new Je,physics:void 0,events:void 0,type:"Instance"}}n.ofComponent=r;function o(a){let s=Va.fromObject(a.data);return r(a.id,s)}n.fromComponentData=o})(_o||(_o={}));var ii;(e=>{e.defaultData={type:"Page",...Vt.defaultData,physics:{...ji.defaultData,fusedBody:!1},...Eu.defaultData,camera:En.defaultData};function t(r){return r.uiScene!==void 0}e.isUIPage=t})(ii||(ii={}));var Ru;(s=>(s.defaultCamera={position:[0,0,1e3],scale:[1,1,1],rotation:[0,0,0],pivot:[0,0,0],pivotRotation:[0,0,0],hiddenMatrix:Vi.identity,name:"Play Camera",visible:!0,raycastLock:!1,physics:ji.defaultData,states:new ve,events:new ve,timelineAnimations:new de,cloner:null,pathSnapping:{pathId:null,orientation:"tangential",slide:0,offset:0},...Fi.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",...Vt.defaultData,...oi.defaultData,geometry:Do.defaultData("RectangleGeometry"),material:Wt.defaultTwoLayerData("phong","layer1","layer2")},s.defaultBooleanObject={name:"Boolean",...Vt.defaultData,...oi.defaultData,geometry:Do.defaultData("BooleanGeometry"),material:Wt.defaultTwoLayerData("phong","layer1","layer2")},s.defaultShapeBlendObject={name:"Shape Blend",...Vt.defaultData,...oi.defaultData,geometry:Do.defaultData("ShapeBlendGeometry"),material:Wt.defaultTwoLayerData("phong","layer1","layer2")},s.defaultTextObject={name:"Text",...Vt.defaultData,...oi.defaultData,geometry:Do.defaultData("TextGeometry"),material:Wt.defaultTwoLayerData("phong","layer1","layer2")},s.defaultInputObject={name:"Input",...Vt.defaultData,...oi.defaultData,geometry:Do.defaultData("InputGeometry"),material:Wt.defaultTwoLayerData("phong","layer1","layer2")}))(Ru||(Ru={}));var Nn;(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})))):ao.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=Di(s.material,l=>{if(typeof l!="string")for(let[c,u]of Object.entries(a.material.layers)){let d=l.layers.data(c);d&&Nt.patch(d,u)}}).data),s.materials&&a.materials&&(s.materials=Di(s.materials,l=>{for(let c=0;c<s.materials.length;c++){let u=a.materials[c];if(typeof u!="string")for(let[d,p]of Object.entries(u.layers)){let f=l[c]?.layers?.data(d);f&&Nt.patch(f,p)}}}).data),s}function e(n,a){let s,l=[],c={orthographic:0,perspective:0,geometry:0};function u(d,p){for(let[f,h]of Object.entries(p.layers)){let{texture:m,...y}=h;if(m!==void 0&&Object.keys(m).length>0){let g={path:[...d,"layers",f,"texture"],props:m,type:0};l.push(g)}if(Object.keys(y).length>0){let g={path:[...d,"layers",f],props:y,type:0};l.push(g)}}}for(let[d,p]of Object.entries(a))if(d!=="name")if(d==="cloner")l.push(...Su.toOps(p,["cloner"]));else if(d==="pathSnapping")l.push({path:[d],props:{slide:p.slide,offset:p.offset},type:0});else if(d==="material")u(["material"],p);else if(d==="materials")for(let[f,h]of Object.entries(p))u(["materials",f],h);else if(c[d]===0){if(d==="geometry"&&p.extrusion!==void 0){let f={path:[d,"extrusion"],props:p.extrusion,type:0};l.push(f),p={...p},delete p.extrusion}if(Object.keys(p).length>0){let f={path:[d],props:p,type:0};l.push(f)}}else s===void 0&&(s={path:[],props:{},type:0},l.push(s)),s.props[d]=p;return l}o.toOps=e;function r(n,a){if(a===void 0)return n;let s={...n};if(Object.assign(s,Va.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})}),ao.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:Au.merge(s.geometry,a.geometry)}),(a.material||a.materials)&&(s=t(s,a)),s.cloner&&"cloner"in a&&Object.assign(s,{cloner:No.merge(s.cloner,a.cloner)});else if(n.type==="Empty")s.cloner&&"cloner"in a&&Object.assign(s,{cloner:No.merge(s.cloner,a.cloner)});else if(wu.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})(Nn||(Nn={}));var Ga;(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,rotationSpeed:1,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})(Ga||(Ga={}));var Wr;(t=>t.defaultData={orbitControls:Ga.defaultData,playPage:Gi,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,colorSpace:"display-p3"},videoStatic:{fps:60,mbps:150,ratio:1,duration:1e3,format:"mp4",imageFormat:"jpg",activeTimeline:null,colorSpace:"display-p3"},web:{logo:!0,compress:!0,preset:1,preload:!0,hint:!1,imageQuality:70,pixelRatioMobile:0,pixelRatioDesktop:0}},stopRaycast:!0,hdTransmission:!1})(Wr||(Wr={}));var cf;(t=>t.defaultData={id:"basic",label:"Basic",style:"None",prompt:""})(cf||(cf={}));var uf;(t=>t.defaultData={weather:0,shadows:0,lightOrigin:0,temperature:0,sun:0,camera:0,environment:0,particles:0,nature:0,floor:0})(uf||(uf={}));var ni;(e=>(e.defaultData=()=>({mode:"line-art-both",prompt:"",negativePrompt:"",style:{...cf.defaultData},isRandomSeed:!0,seed:e.generateSeed(),guessMode:!1,advanced:!1,steps:20,guidanceScale:7.5,controlNetScale:1,modifiers:uf.defaultData}),e.generateSeed=()=>Math.round(Math.random()*1e5)))(ni||(ni={}));var V0;(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=si.getComponentData(r,s.component)?.data;l&&n(a,s,l.events)}else n(a,s,s.events)})}e.traverseModuleInstances=t})(V0||(V0={}));var ai;(c=>{c.TRASH_CAN_ID="830a2708-8ed9-49cf-a68e-085299892222",c.defaultLight={fi:-1,data:_u.defaultDirectionalLightData,id:"830a2708-8ed9-49cf-a68e-085299899103",children:[]};function e(u=!0,d=[]){let p=[],f=Ru.defaultMeshObject;u&&(p.push({...c.defaultLight}),p.push({fi:1,id:"7ba78968-2a55-48f2-b14c-5191da3e075e",data:f,children:[]})),p.push(...d);let h=new ut;return h.push({fi:1,id:Gi,data:{...ii.defaultData,name:"Scene 1"},children:p}),h}c.createDefaultObjectTreeWithPage=e,c.defaultData={objects:e(),publish:Wr.defaultData,styles:ni.defaultData()},c.emptyDataWithoutPage=function(){return{objects:new ut,publish:Wr.defaultData,styles:ni.defaultData()}},c.emptyDataWithPage=function(u=!0){return{objects:e(u),publish:Wr.defaultData,styles:ni.defaultData()}},c.emptyData=function(){return{objects:new ut,publish:{...Wr.defaultData},styles:ni.defaultData()}};function s(u){return{...c.defaultData,objects:Ht(u,ut.prototype)}}c.withObjs=s;function l(u,d){return s([{id:u,data:d,children:[],fi:0}])}c.withObj=l})(ai||(ai={}));var Fa;(t=>t.defaultData={preset:"fullscreen",allowResponsive:!1,size:[512,512],coords:[0,0],sceneScale:1,color:{r:0,g:0,b:0,a:.5}})(Fa||(Fa={}));var Lu;(e=>(e.defaultData=r=>({url:r,name:"New Webhook",parametersSchemas:new ve}),e.defaultParameterValueByType=r=>r==="number"?0:r==="boolean"?!1:""))(Lu||(Lu={}));var z0;(t=>t.defaultData=(e,r="GET")=>({url:e,method:r,name:"New API",headers:new ve,queries:new ve,autoStart:!0}))(z0||(z0={}));var Ui;(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})(Ui||(Ui={}));var df;(t=>t.all=["images","videos","colors","audios","particles","fonts","materials","variables"])(df||(df={}));var G0;(t=>t.all=[...df.all,"components"])(G0||(G0={}));var F0;(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})(F0||(F0={}));var so;(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})(so||(so={}));var qr;(n=>{function i(){let a={};return a["89b10010-844c-11ec-a8a3-0242ac120002"]={r:.5,g:.5,b:.5,a:1,name:"Default Color"},Ht(a,de.prototype)}n.defaultColors=i;function t(){return Ht({},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 ve,userAPIs:new de,userWebhooks:new de,lib:so.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})(qr||(qr={}));var wl=require("three");var Bu;(t=>t.list=["idle","move","jump","run"])(Bu||(Bu={}));var Vu;(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 ve,move:new ve,jump:new ve,run:new ve},navmesh:{enabled:!1,ch:6,cs:6,walkableClimb:5,walkableHeight:1,walkableRadius:0,zones:"all",objects:[],helperVisible:!0,destinationHelperRadius:0,destinationHelperColor:Le.fromHexAndA(3728051,1)}}))(Vu||(Vu={}));function j0(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={...no(wt(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={...wt(t),near:Math.max(t.near,0),far:Math.max(t.far,0)};Object.assign(t,e)}})}function li(i,t){Object.values(i.shared.materials).forEach(e=>t(e))}function ci(i,t){i.scene.objects.traverse((e,r)=>{"materials"in r?r.materials.forEach((o,n)=>{o===void 0&&(r.materials[n]=Wt.defaultData(),o=r.materials[n]),typeof o!="string"&&t(o)}):"material"in r?typeof r.material!="string"&&(r.material===void 0&&(r.material=Wt.defaultData()),t(r.material)):r.type==="Mesh"&&(r.material===void 0&&(r.material=Wt.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 BA(i){Object.assign(i.scene.publish,{orbitControls:{...Ga.defaultData,...wt(i.scene.publish.orbitControls)}})}function VA(i){Object.assign(i.scene.publish.settings,{video:{...Wr.defaultData.settings.video,...wt(i.scene.publish.settings.video)}})}function zA(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((N0.includes(o)||typeof n=="boolean")&&delete r[o],o==="texture")for(let[a,s]of Object.entries(n))(D0.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 GA(i){i.scene.publish.withBackground=!0}function FA(i){i.scene.publish.settings.web={compress:!0,preload:!0,preset:1,logo:!0,hint:!1}}function jA(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 UA(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 kA(i){i.scene.objects.traverse((t,e)=>{let r=i.scene.objects.unproxy().parent(t);if(r){let o=wt(i.scene.objects.data(r));o&&o.type==="Mesh"&&o.geometry.type==="BooleanGeometry"&&e.type==="Mesh"&&(e.visible=wt(e).booleanExclude!==!0)}})}function HA(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 WA(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=wt(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=wt(l).layers;e(c),l.layers=c}})})}function U0(i){i.layers===void 0&&Object.assign(i,Wt.defaultTwoLayerData("lambert"))}function pf(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={...wt(t),colors:e,steps:r};Object.assign(t,o)}})}function qA(i){i.scene.objects.traverse((t,e)=>{e.type==="Mesh"&&(e.geometry.type==="BooleanGeometry"||e.geometry.type==="SubdivGeometry")&&(e.geometry.phongAngle=35)})}function k0(i){i.scene.objects.traverse((t,e)=>{"materials"in e?e.materials.forEach(r=>{typeof r!="string"&&pf(r)}):"material"in e&&typeof e.material!="string"&&pf(e.material)}),Object.values(i.shared.materials).forEach(t=>pf(t))}function $A(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 XA(i){i.shared.audios=Ht({},de.prototype)}function YA(i){i.shared.videos=Ht({},de.prototype)}function KA(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 QA(i){Object.entries(wt(i.shared.images)).filter(r=>r[1].asset===!1).map(r=>r[0]).forEach(r=>{delete i.shared.images[r]}),Object.entries(wt(i.shared.audios)).filter(r=>r[1].asset===!1).map(r=>r[0]).forEach(r=>{delete i.shared.audios[r]})}function ZA(i){i.scene.publish.settings.web.preload=!1}function H0(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 W0(i){i.layers&&i.layers.forEach(t=>{E0(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 JA(i){i.shared.fonts=Ht({},de.prototype)}function eM(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 tM(i){let t=[];i.scene.objects.traverse((e,r)=>{let o=r;if(o.type==="TextFrame"){let n=Wt.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=eM(o.font);i.shared.fonts[s]===void 0&&(i.shared.fonts[s]={name:s});let l={name:o.name,...Vt.defaultData,...oi.defaultData,flatShading:!1,wireframe:!1,geometry:{...Do.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:wt(o.states),events:wt(o.events),visible:o.visible,raycastLock:o.raycastLock,position:o.position,rotation:o.rotation,scale:o.scale,hiddenMatrix:o.hiddenMatrix},c=wt(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 rM(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 ve,move:new ve,jump:new ve}});else{let n=new ve;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:wl.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,no(a,"mass","stiffness","damping","velocity")):a.easing===5&&Object.assign(u,{control1:{...a.control1},control2:{...a.control2}});let d={repeat:a.repeat?-1:0,delay:a.delay,delayDirection:a.delayDirection,direction:a.cycle&&a.rewind?"pingpong-rewind":a.cycle?"pingpong":"normal"},p={state:a.state,...d,...u},f={allowSlerp:!0,type:"Transition",object:a.object,repeat:0,delay:0,delayDirection:void 0,direction:"normal",tweens:new ve({fi:0,id:wl.MathUtils.generateUUID(),data:c},{fi:1,id:wl.MathUtils.generateUUID(),data:p})};n.push({fi:l,id:s,data:f})}),delete o.targets)}})})}function oM(i){i.scene.objects.traverse((t,e)=>{function r(o,n){let a=new ve,s=[];if(e.events.forEach((l,c,u)=>{if(l.type==="Audio"&&l.trigger===n){let d;s.push(c),l.interaction==="play"?d={...no(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")&&(d={...no(l,"interaction","delay","object","playAudio"),type:"Audio"}),d&&a.push({fi:u,id:c,data:d})}}),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:wl.MathUtils.generateUUID(),data:{type:o,actions:a}}])}}r("Start","start"),r("MouseDown","mouseDown"),r("MouseUp","mouseUp"),r("KeyDown","keyDown"),r("KeyUp","keyUp")})}function q0(i){let t=i.layers.find(e=>e.type==="light")?.data;if(t?.category==="basic"){let e=Nt.defaultData("light","phong"),r=t;Object.assign(r,e),r.visible=!1}}function $0(i){li(i,q0),ci(i,q0)}function iM(i){i.scene.objects.traverse((t,e)=>{e.type==="Mesh"&&e.geometry.type==="SubdivGeometry"&&(e.geometry.scaleBaked||(e.geometry.scaleBaked=[1,1,1]))})}function nM(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 aM(i){i.scene.objects.traverse((t,e)=>{e.type==="Mesh"&&e.geometry.type==="NonParametricGeometry"&&!("material"in e)&&!("materials"in e)&&(e.material=Wt.defaultTwoLayerData("phong"))})}function sM(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 lM(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 cM(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 uM(i){let{video:t}=i.scene.publish.settings;t.format==="gif"&&t.fps>48&&(t.fps=15)}function dM(i){i.scene.objects.traverse((t,e)=>{e.events.forEach(r=>{r.type==="GameControl"&&(r.resetYPosition=Math.abs(r.resetYPosition-e.position[1]))})})}function pM(i){let t=i.scene.environment.usePhysics;i.scene.objects.traverse((e,r)=>{t&&r.physics===null?r.collision=!1:r.collision="visibility"})}function fM(i){i.scene.objects.traverse((t,e)=>{e.events.forEach(r=>{r.type==="GameControl"&&(r.navmesh=Vu.defaultDataThirdPerson.navmesh)})})}function hM(i){i.scene.styles||(i.scene.styles=ni.defaultData())}function X0(i){i.layers.forEach(t=>{t.type==="light"&&t.category!=="toon"&&t.occlusion===void 0&&(t.occlusion=!0)})}function mM(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}),ci(i,X0),li(i,X0)}function yM(i){i.scene.objects.traverse((t,e)=>{e.events.forEach(r=>{r.type==="GameControl"&&Object.assign(r.gameActions,{run:new ve})})})}function gM(i){i.scene.objects.traverse((t,e)=>{e.events.forEach(r=>{r.type==="GameControl"&&(r.keyAssignments=[...r.keyAssignments,["run","\u21E7"],["none","Ctrl"]])})})}function Y0(i){i.layers&&i.layers.forEach(t=>{t.type==="light"&&t.bumpMapIntensity===void 0&&(t.bumpMapIntensity=5)})}function K0(i,t){if(t<1&&(ci(i,j0),li(i,j0),i.schema=1),t<2&&(BA(i),i.schema=2),t<3&&(zA(i),i.schema=3),t<4&&(GA(i),i.schema=4),t<5&&(FA(i),i.schema=5),t<6&&(jA(i),i.schema=6),t<7&&(UA(i),i.schema=7),t<8&&(i.schema=8),t<9&&(k0(i),i.schema=9),t<10&&(qA(i),i.schema=10),t<11&&($A(i),i.schema=11),t<12&&(k0(i),i.schema=12),t<13&&(XA(i),i.schema=13),t<14&&(KA(i),i.schema=14),t<15&&(QA(i),i.schema=15),t<16&&(ZA(i),i.schema=16),t<17&&(ci(i,H0),li(i,H0),i.schema=17),t<18&&(ci(i,U0),li(i,U0),i.schema=18),t<19&&(VA(i),i.schema=19),t<20&&(JA(i),tM(i),i.schema=20),t<21&&(rM(i),oM(i),i.schema=21),t<22&&($0(i),i.schema=22),t<23&&(iM(i),i.schema=23),t<24&&(nM(i),i.schema=24),(t<25||i.shared.videos===void 0)&&(YA(i),t<25&&(i.schema=25)),t<26&&(kA(i),i.schema=26),t<27&&(HA(i),i.schema=27),t<28&&($0(i),i.schema=28),t<29&&(WA(i),i.schema=29),t<30&&(aM(i),i.schema=30),t<31&&(sM(i),i.schema=31),t<33&&(lM(i),i.schema=33),t<34&&(cM(i),i.schema=34),t<35&&(uM(i),i.schema=35),t<36&&(dM(i),i.schema=36),t<37&&(pM(i),i.schema=37),t<38&&(ci(i,W0),li(i,W0),i.schema=38),t<39&&(fM(i),i.schema=39),t<40&&(hM(i),i.schema=40),t<41&&(mM(i),i.schema=41),t<42&&(yM(i),i.schema=42),t<43&&(gM(i),i.schema=43),t<99){ci(i,Y0),li(i,Y0),i.scene.publish.playCamera===null&&(i.scene.publish.playCamera=zi);let e=wt(i.scene.objects),r=i.scene.objects;i.scene.publish.playPage=Gi,r.insertBefore(null,null,[{id:Gi,data:{...ii.defaultData,backgroundColor:i.scene.backgroundColor,fog:i.scene.fog,postprocessing:i.scene.postprocessing,ao:no(i.scene.environment.ambientLight,"occlusion","aoFullRes","radius","bias","aoColor"),publish:{playCamera:i.scene.publish.playCamera,gameControlObject:i.scene.publish.gameControlObject},shadow:no(i.scene.environment.ambientLight,"softShadowQuality"),globalPhysics:{...Sl.defaultData,...no(i.scene.environment,"usePhysics","gravity")},camera:wt(i.scene.ownerCamera)??ii.defaultData.camera,name:"Scene"},children:[]}]);for(let a of e)a.id!==ai.TRASH_CAN_ID&&r.move(Gi,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,ji.defaultData)),s.physics!==void 0&&s.physics!==null&&(s.physics.enabled=s.collision??"visibility",delete s.collision)}),i.schema=99}}function Q0(i){i.layers&&i.layers.forEach(t=>{t.type==="light"&&t.alphaOverride===void 0&&(t.alphaOverride=1)})}function xM(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 bM(i){Array.isArray(wt(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 ja=180/Math.PI;function Z0(i){i.rotation=i.rotation.slice(0,3).map(t=>t*ja)}function J0(i){Z0(i),i.type==="Page"&&Z0(i.camera),i.states?.forEach(e=>{e.rotation===void 0||e.rotation===null||(e.rotation=e.rotation.slice(0,3).map(r=>r*ja))});let t=i.geometry;t&&t.type==="SphereGeometry"&&(t.thetaLength=(t.thetaLength??180)*ja),t&&t.type==="TorusGeometry"&&(t.arc=t.arc*ja),t&&t.type==="PathGeometry"&&(t.extrusion.angle*=ja,t.extrusion.twist*=ja),i.type==="Mesh"&&i.geometry.type==="TextGeometry"&&(i.geometry.text={textValue:i.geometry.text}),Array.isArray(wt(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 vM(i){i.shared.variables=Ht({},de.prototype)}function SM(i){let t=wt(i.shared.variables);i.shared.variables=Ht(Object.entries(t??{}).map(([e,r],o)=>({fi:o,id:e,data:r})),ve.prototype)}var Ro=121;function ff(i,t){t(i.data);for(let e of i.children)ff(e,t)}function wM(i){let t=i.schema??104;t!==Ro&&(t<105&&(ff(i.asset,J0),i.schema=105),t<118&&(ff(i.asset,ex),i.schema=118))}function PM(i){i.shared.particles=Ht({},de.prototype),i.shared.lib&&(i.shared.lib.particles=so.defaultData().particles)}function OM(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 TM(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 CM(i){i.scene.objects.traverse((t,e)=>{Array.isArray(wt(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 AM(i){i.shared.userAPIs=Ht({},de.prototype),i.shared.userWebhooks=Ht({},de.prototype),i.shared.lib&&(i.shared.lib.userAPIs=so.defaultData().userAPIs,i.shared.lib.userWebhooks=so.defaultData().userWebhooks)}function MM(i){i.scene.publish.settings.videoStatic===void 0&&(i.scene.publish.settings.videoStatic=Wr.defaultData.settings.videoStatic)}function ex(i){i.timelineAnimations=Ht({},de.prototype)}function IM(i){i.scene.objects.traverse((t,e)=>{e.pivot=[0,0,0],e.pivotRotation=[0,0,0]})}function zu(i){let t=i.schema??0;if(t!==Ro){console.warn("updating from ",t,"to ",Ro),K0(i,t),t<100&&(i.scene.publish.joystickSizeAndXYOffset===void 0&&(i.scene.publish.joystickSizeAndXYOffset=Wr.defaultData.joystickSizeAndXYOffset),i.schema=100),t<101&&(ci(i,Q0),li(i,Q0),i.schema=101),t<102&&(xM(i),i.schema=102),t<104&&(i.shared.catelogs=new de,i.shared.lib=so.defaultData(),i.schema=104),t<105&&(vM(i),i.scene.objects.traverse((e,r)=>{J0(r)}),i.schema=105);for(let e of Object.values(i.shared.lib.components))wM(e);t<106&&(SM(i),i.schema=106),t<107&&(i.shared.lib.variables=so.defaultData().variables,i.schema=107),t<109&&(PM(i),i.schema=109),t<110&&(OM(i),i.schema=110),t<111&&(i.scene.objects.traverse((e,r)=>{bM(r)}),i.schema=111),t<112&&(TM(i),i.schema=112),t<113&&(CM(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&&(AM(i),i.schema=115),t<116&&(MM(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=Ht({},de.prototype),i.scene.objects.traverse((e,r)=>{ex(r)}),i.schema=118),t<119&&(i.scene.publish.settings.videoStatic.format=si.defaultData.scene.publish.settings.videoStatic.format,i.scene.publish.settings.videoStatic.imageFormat=si.defaultData.scene.publish.settings.videoStatic.imageFormat,i.schema=119),t<120&&(i.scene.publish.settings.image.colorSpace="display-p3",i.scene.publish.settings.videoStatic.colorSpace="display-p3",i.schema=120),t<121&&(IM(i),i.schema=121)}}var si;(c=>{c.defaultData={schema:Ro,scene:ai.defaultData,frames:new de().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",Fa.defaultData),shared:{...qr.emptyData(),colors:qr.defaultColors()}},c.emptyDataForImports=function(){let u=ai.emptyDataWithPage();return{schema:Ro,scene:u,frames:new de().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",Fa.defaultData),shared:{...qr.emptyData(),colors:qr.defaultColors(),images:qr.defaultImages()}}},c.emptyData=function(){return{schema:Ro,scene:ai.emptyDataWithPage(),frames:new de().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",Fa.defaultData),shared:qr.emptyData()}},c.clipboard2dData=function(){return{schema:Ro,scene:ai.emptyData(),frames:new de,shared:qr.emptyData()}},c.collabHelper={...ml,updateSchema(u){return(u.schema??0)<Ro?Di(u,zu):(u.schema??0)-Ro}};function n(u){let d=c.collabHelper.updateSchema(u);return typeof d=="number"?d===0?u:null:d.data}c.updateSchemaDirectly=n;function a(u){return{...u,shared:{...u.shared,lib:so.defaultData()}}}c.withoutLib=a;function s(u,d){let p=u.scene.objects.get(d);if(p&&p.data.type==="Component")return p;{let f=u.shared.lib.components[d];if(f)return{...f.asset,id:d}}}c.getComponentData=s;function l(u){let d=Object.values(u.shared.userAPIs);for(let p of d){let f=p.headers;for(let h of f)if(h.data.key.toLowerCase()==="authorization"&&h.data.value!=="")return!0}return!1}c.hasSensitiveData=l})(si||(si={}));var Gu;(t=>t.emptyImage={data:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII=",name:"empty"})(Gu||(Gu={}));var tx;(t=>{function i(e){return!0}t.is=i})(tx||(tx={}));var Fu;(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 Mc({position:Da.isEqual(o.position,n.position)?void 0:n.position,rotation:o.rotation===n.rotation?void 0:n.rotation,scale:Da.isEqual(o.scale,n.scale)?void 0:n.scale,shear:o.shear&&n.shear&&Da.isEqual(o.shear,n.shear)?void 0:n.shear})}r.diff=e})(Fu||(Fu={}));var hf;(t=>t.defaultData={horizontalConstraint:0,verticalConstraint:0})(hf||(hf={}));var rx;(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})(rx||(rx={}));var ju;(t=>t.defaultData={opacity:1,fill:{color:Le.fromHexAndA(Bt,1),enabled:!0},stroke:{color:Le.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:Le.from0to1([0,0,0,1]),enabled:!1,spread:0},innerShadow:{offset:[10,10],blurRadius:10,color:Le.from0to1([0,0,0,1]),enabled:!1,spread:0}})(ju||(ju={}));var Dn;(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,Fu.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,d]of Object.entries(s))u!=="name"&&(l===void 0&&(l={path:[],props:{},type:0},c.push(l)),l.props[u]=d);return c}n.toOps=o})(Dn||(Dn={}));var Pl;(t=>t.defaultData={...Fu.defaultData,...hf.defaultData,states:new ve,events:new ve,visible:!0,raycastLock:!1})(Pl||(Pl={}));var Ua;(t=>t.defaultData={...Pl.defaultData,...ju.defaultData})(Ua||(Ua={}));var Uu;(t=>t.defaultData={cornerRadius:[0,0,0,0]})(Uu||(Uu={}));var mf;(t=>t.defaultData={...Ua.defaultData,type:"ellipse2d",width:100,height:100,name:"Ellipse"})(mf||(mf={}));var ka;(t=>t.defaultData={...Ua.defaultData,...Uu.defaultData,type:"rectangle2d",width:100,height:100,name:"Rectangle"})(ka||(ka={}));var yf;(t=>t.defaultData={...Ua.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"})(yf||(yf={}));var gf;(t=>t.defaultData={...Ua.defaultData,type:"path2d",path:"",name:"Path"})(gf||(gf={}));var ox;(t=>{function i(e){return e.type==="ellipse2d"||e.type==="rectangle2d"||e.type==="text2d"||e.type==="vector2d"||e.type==="path2d"}t.is=i})(ox||(ox={}));var Ol;(t=>t.defaultData={...Pl.defaultData,name:"Group",type:"group2d"})(Ol||(Ol={}));var xf;(t=>t.defaultData=()=>({...Pl.defaultData,...Uu.defaultData,...ju.defaultData,name:"Frame",type:"frame2d",clipped:!0,width:200,height:200,fill:{color:Le.fromHexAndA(4737101,1),enabled:!0},stroke:{color:Le.fromHexAndA(0,1),thickness:1,enabled:!1,mode:"inside"},backgroundBlur:{radius:2,enabled:!1},layerBlur:{radius:2,enabled:!1}}))(xf||(xf={}));var ui;(n=>{function i(a){switch(a){case"rectangle2d":return{...ka.defaultData};case"ellipse2d":return{...mf.defaultData};case"text2d":return{...yf.defaultData};case"vector2d":return{...ka.defaultData};case"path2d":return{...gf.defaultData};case"frame2d":return{...xf.defaultData()};case"group2d":return{...Ol.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})(ui||(ui={}));var ku;(e=>(e.defaultData={name:"UI",type:"scene2d",objects:new ut},e.emptyData=function(){return{type:"scene2d",objects:new ut}}))(ku||(ku={}));var ix=require("three"),qt=class extends ix.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"),Gd=ll(ax());var EM=.5*(Math.sqrt(3)-1),Tl=(3-Math.sqrt(3))/6,NM=1/3,Lo=1/6,m4=(Math.sqrt(5)-1)/4,y4=(5-Math.sqrt(5))/20,Cl=i=>Math.floor(i)|0,sx=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]),vf=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 lx(i=Math.random){let t=ux(i),e=new Float64Array(t).map(o=>sx[o%12*2]),r=new Float64Array(t).map(o=>sx[o%12*2+1]);return function(n,a){let s=0,l=0,c=0,u=(n+a)*EM,d=Cl(n+u),p=Cl(a+u),f=(d+p)*Tl,h=d-f,m=p-f,y=n-h,g=a-m,b,w;y>g?(b=1,w=0):(b=0,w=1);let P=y-b+Tl,S=g-w+Tl,T=y-1+2*Tl,A=g-1+2*Tl,x=d&255,N=p&255,E=.5-y*y-g*g;if(E>=0){let _=x+t[N],R=e[_],V=r[_];E*=E,s=E*E*(R*y+V*g)}let M=.5-P*P-S*S;if(M>=0){let _=x+b+t[N+w],R=e[_],V=r[_];M*=M,l=M*M*(R*P+V*S)}let D=.5-T*T-A*A;if(D>=0){let _=x+1+t[N+1],R=e[_],V=r[_];D*=D,c=D*D*(R*T+V*A)}return 70*(s+l+c)}}function cx(i=Math.random){let t=ux(i),e=new Float64Array(t).map(n=>vf[n%12*3]),r=new Float64Array(t).map(n=>vf[n%12*3+1]),o=new Float64Array(t).map(n=>vf[n%12*3+2]);return function(a,s,l){let c,u,d,p,f=(a+s+l)*NM,h=Cl(a+f),m=Cl(s+f),y=Cl(l+f),g=(h+m+y)*Lo,b=h-g,w=m-g,P=y-g,S=a-b,T=s-w,A=l-P,x,N,E,M,D,_;S>=T?T>=A?(x=1,N=0,E=0,M=1,D=1,_=0):S>=A?(x=1,N=0,E=0,M=1,D=0,_=1):(x=0,N=0,E=1,M=1,D=0,_=1):T<A?(x=0,N=0,E=1,M=0,D=1,_=1):S<A?(x=0,N=1,E=0,M=0,D=1,_=1):(x=0,N=1,E=0,M=1,D=1,_=0);let R=S-x+Lo,V=T-N+Lo,U=A-E+Lo,B=S-M+2*Lo,q=T-D+2*Lo,j=A-_+2*Lo,F=S-1+3*Lo,H=T-1+3*Lo,W=A-1+3*Lo,ee=h&255,te=m&255,Y=y&255,re=.6-S*S-T*T-A*A;if(re<0)c=0;else{let $=ee+t[te+t[Y]];re*=re,c=re*re*(e[$]*S+r[$]*T+o[$]*A)}let K=.6-R*R-V*V-U*U;if(K<0)u=0;else{let $=ee+x+t[te+N+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)d=0;else{let $=ee+M+t[te+D+t[Y+_]];Z*=Z,d=Z*Z*(e[$]*B+r[$]*q+o[$]*j)}let Q=.6-F*F-H*H-W*W;if(Q<0)p=0;else{let $=ee+1+t[te+1+t[Y+1]];Q*=Q,p=Q*Q*(e[$]*F+r[$]*H+o[$]*W)}return 32*(c+u+d+p)}}function ux(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 dx=require("three"),lo=new dx.Triangle,Hu=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;lo.a.fromBufferAttribute(t,o),lo.b.fromBufferAttribute(t,o+1),lo.c.fromBufferAttribute(t,o+2),n*=lo.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),lo.a.fromBufferAttribute(this.positionAttribute,t*3),lo.b.fromBufferAttribute(this.positionAttribute,t*3+1),lo.c.fromBufferAttribute(this.positionAttribute,t*3+2),e.set(0,0,0).addScaledVector(lo.a,o).addScaledVector(lo.b,n).addScaledVector(lo.c,1-(o+n)),lo.getNormal(r),this}};var mx=require("three");var Pr=require("three"),hx=ll(fx()),DM=new Pr.Matrix4,_M=new Pr.Matrix4,RM=new Pr.Matrix4,di;(t=>{function i(e){return e&&e.__isSPEObject}t.is=i})(di||(di={}));var Ha=i=>class extends i{constructor(){super(...arguments);this.previousModelViewMatrix=new Pr.Matrix4;this.copyPreviousMatrix=!0;this.hiddenMatrix=new Pr.Matrix4;this.pivotMatrix=new Pr.Matrix4;this.matrixWorldRigid=new Pr.Matrix4;this.shearScale=new Pr.Matrix4;this.shearScaleInv=new Pr.Matrix4}get __isSPEObject(){return!0}isDescendantOf(r){r instanceof Pr.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.matrixWorld.multiply(this.pivotMatrix),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)),this.matrixWorld.multiply(this.pivotMatrix),o)for(let a of this.children)a.updateWorldMatrix(!1,!0)}traverseChildren(r,o=0){for(let n of this.children)di.is(n)&&n.traverseObject(r,o+1)}traverseObject(r,o=0){if(r(this,o)!==!0)for(let a of this.children)di.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,hx.SVD)(o),l=DM.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=_M.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=RM.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(d=>Math.abs(s[0]-d)<.01)?this.hasNonUniformScale=!1:this.hasNonUniformScale=!0}attach(r,o){this.updateWorldMatrix(!0,!1);let n=new Pr.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 Pr.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 Sf=class extends Ha(mx.Object3D){},LM=i=>i.type==="Mesh",co=class extends Sf{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 co(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.pivotMatrix=r.pivotMatrix),o.expand(),e+=1,r=this.object.entityChildren(e)}for(;this.children.length>e;)this.remove(this.children[e]);this.pivotMatrix=this.object.pivotMatrix}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 LM(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 us=require("three");var dd=require("three");var _t=require("three");var Dt=require("three"),_n=new Dt.Vector3,Rn=new Dt.Vector3,Wa=new Dt.Matrix4,gx=[new Dt.Vector3(-1,1,1),new Dt.Vector3(-1,-1,1),new Dt.Vector3(1,-1,1),new Dt.Vector3(1,1,1),new Dt.Vector3(-1,1,-1),new Dt.Vector3(-1,-1,-1),new Dt.Vector3(1,-1,-1),new Dt.Vector3(1,1,-1)],BM=[[0,3],[1,2],[5,6],[4,7],[0,1],[3,2],[7,6],[4,5],[0,4],[1,5],[2,6],[3,7]],VM=[[0,2],[7,5],[4,1],[3,6],[4,3],[1,6]],yx=(i,t,e)=>{i.updateEntityBoxSize(_n,Rn),Wa.copy(t).multiply(i.matrixWorld),Rn.x===0&&Rn.y===0&&Rn.z===0?e.push(new Dt.Vector3(_n.x,_n.y,_n.z).applyMatrix4(Wa)):gx.forEach(r=>{e.push(r.clone().multiply(Rn).add(_n).applyMatrix4(Wa))})},Al=class extends Dt.Box3{constructor(){super(...arguments);this.matrix=new Dt.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 Dt.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 Dt.Vector3);return}yx(a,r,n)}}):yx(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(Wa.copy(this.matrix).setPosition(0,0,0)),e}computeVertices(){this.getSize(Rn).multiplyScalar(.5),this.getCenter(_n),Wa.copy(this.matrix).setPosition(_n),this.vertices=gx.map(e=>e.clone().multiply(Rn).applyMatrix4(Wa))}computeEdges(){this.vertices.length>0&&this.computeVertices(),this.edges=BM.map(([e,r])=>new Dt.Line3(this.vertices[e],this.vertices[r])),this.centerEdges=this.edges.map(e=>e.getCenter(new Dt.Vector3))}computeFaces(){this.vertices.length>0&&this.computeVertices(),this.faces=VM.map(([e,r])=>this.vertices[e].clone().add(this.vertices[r]).multiplyScalar(.5))}};var uo={Cloner:()=>{},changeEntityProptotype:()=>{},createEntity:()=>{}};var er=require("three"),Pf=class extends er.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],d=Math.ceil(t*u/a),p=c.getPoints(d);for(let f=0;f<p.length;f++){let h=p[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 Of=.001;function Tf(i,t,e){return t.clone().sub(i).cross(t.clone().sub(e)).length()<=Of}function wf(i,t){let e=new er.Vector3(...i.position),r=new er.Vector3(...i.controlNext.position),o=new er.Vector3(...t.controlPrevious.position),n=new er.Vector3(...t.position);return Tf(e,r,n)&&Tf(e,o,n)}function qu(i){let t=i.points.map(u=>new er.Vector3(...u.data.position)),e=[i.points[0]],r=new er.Vector3(...e[0].data.position);for(let u=0;u<i.points.length-1;u++)Tf(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 d=e[u].data,p=new er.Vector3(...d.position),f=new er.Vector3(...d.controlPrevious.position),h=new er.Vector3(...d.controlNext.position),m={position:p,baseRoundness:d.roundness,controlPrevious:f,controlNext:h};if(d.roundness===0||!i.isClosed&&(u===0||u===a-1)){s[u]={...m,removedLength:0};continue}let y=o&&u==0?a-1:u-1,g=o&&u==a-1?0:u+1,b=e[y].data,w=e[g].data,P=new er.Vector3(...b.position),S=new er.Vector3(...w.position),T=P.clone().sub(p).normalize(),A=S.clone().sub(p).normalize();Object.assign(m,{prevDir:T,nextDir:A});let x=wf(b,d),N=wf(d,w);if(!x||!N)s[u]={...m,removedLength:0};else{let E=T.clone().add(A).normalize(),M=E.clone().cross(T).length()/T.dot(E);s[u]={...m,tan:M,removedLength:d.roundness/M}}}for(let u=0;u<n;u++){let d=u,p=o&&u===a-1?0:u+1,f=s[d],h=s[p];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 d=u,p=o&&u===a-1?0:u+1,f=s[d],h=s[p],m=null;if(!wf(e[d].data,e[p].data))f.position.distanceTo(h.position)>Of&&(m=new er.CubicBezierCurve3(f.position,f.controlNext,h.controlPrevious,h.position));else{let y=f.position.clone(),g=h.position.clone();(f.removedLength!==0||h.removedLength!==0)&&(f.nextDir&&y.add(f.nextDir.clone().setLength(f.removedLength)),h.prevDir&&g.add(h.prevDir.clone().setLength(h.removedLength))),y.distanceTo(g)>Of&&(m=new er.CubicBezierCurve3(y,y.clone().lerp(g,.3),g.clone().lerp(y,.3),g))}l[2*u+1]=m}for(let u=0;u<a;u++){let d=s[u];if(d.removedLength===0){l[2*u]=null;continue}let p=d.position,f=d.prevDir.clone().multiplyScalar(d.removedLength).add(p),h=d.nextDir.clone().multiplyScalar(d.removedLength).add(p),m=d.tan*d.removedLength,y=d.prevDir.clone().add(d.nextDir).normalize(),g=f.clone().lerp(h,.5),b=f.distanceTo(h)/2,w=y.clone().multiplyScalar(Math.sqrt(Math.pow(m,2)-Math.pow(b,2))).add(g),P=y.clone().multiplyScalar(-m).add(w),S=p.distanceTo(P)/p.distanceTo(g),T=d.prevDir.clone().multiplyScalar(S*p.distanceTo(f)).add(p),A=T.clone().lerp(P,2),x=f.clone().lerp(T,4/3),N=h.clone().lerp(A,4/3);l[2*u]=new er.CubicBezierCurve3(f,x,N,h)}let c=new Pf;return l.forEach(u=>{u&&c.add(u)}),c}var Ge;(t=>{function i(e){return e&&e.__isEntity}t.is=i})(Ge||(Ge={}));var qa=i=>Ge.is(i),zM={type:"completeState",isfromEntity:!0},GM=["x","y","z"],Ml=new _t.Vector3,xx=new _t.Vector3(1,1,1),Cf=new _t.Quaternion,bx=new _t.Euler,FM=new _t.Vector3().set(0,1,0),$a=i=>class extends Ha(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 Al;this._recursiveBBox=new Al;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(Ge.is(o))return o}entityChildrenCount(){let r=this.children.length;for(;r--;)if(Ge.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(Ge.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)Nn.toOps(this.data,a.data).forEach(l=>{let c=Ma.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=Nn.patch(this.data,a),Nn.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=>{qa(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(Ge.is(o[n]))return o[n];if(Ge.is(r))return r.traverseSortNextHelper()}}sortNext(){let r=this.children;return this.children.length>0&&Ge.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)qa(o)&&r(o)}traverseEntityAncestors(r){this.traverseAncestors(o=>{Ge.is(o)&&r(o)})}traverseConcreteEntity(r,o=0){if(r(this,o)!==!0)for(let a of this.children)qa(a)&&a.isConcreteEntity&&a.traverseEntity(r,o+1)}traverseEntity(r,o=0){if(r(this,o)!==!0)for(let a of this.children)qa(a)&&a.traverseEntity(r,o+1)}traverseVisibleEntity(r){r(this);for(let o of this.children)qa(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=>qa(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*_t.MathUtils.RAD2DEG,this.rotation.y*_t.MathUtils.RAD2DEG,this.rotation.z*_t.MathUtils.RAD2DEG],scale:this.scale.toArray(),hiddenMatrix:this.hiddenMatrix.toArray(),pivot:[0,0,0],pivotRotation:[0,0,0]};return Pa(o,r)}getTransformValues(r,o,n){return o[r].map((a,s)=>n?.shared.getVariable(a,[this.uuid,r,GM[s]])??a)}updateTransformState(r,o){let n=!1;if(r.position&&(this.position.fromArray(this.getTransformValues("position",r,o)),n=!0),r.rotation&&(Ml.fromArray(this.getTransformValues("rotation",r,o)).multiplyScalar(_t.MathUtils.DEG2RAD),this.rotation.setFromVector3(Ml),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??Vi.identity)),r.pivot!==void 0||r.pivotRotation!==void 0){if(n=!0,r.pivot!==void 0&&r.pivotRotation!==void 0)this.pivotMatrix.compose(Ml.fromArray(r.pivot).negate(),Cf.setFromEuler(bx.fromArray(r.pivotRotation.map(a=>a*_t.MathUtils.DEG2RAD))).invert(),xx);else if(r.pivot!==void 0)this.pivotMatrix.setPosition(-r.pivot[0],-r.pivot[1],-r.pivot[2]);else if(r.pivotRotation!==void 0){let a=Ml.setFromMatrixPosition(this.pivotMatrix);Cf.setFromEuler(bx.fromArray(r.pivotRotation.map(s=>s*_t.MathUtils.DEG2RAD))).invert(),this.pivotMatrix.compose(a,Cf,xx)}}return 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)}),this.requestRender()}dispose(){this.disposed=!0,this.cloner&&(this.cloner.removeFromParent(),this.cloner=void 0)}disposeChildrenRecursively(){for(let r of this.children)Ge.is(r)&&r.disposeRecursively()}disposeRecursively(){this.dispose(),this.children.forEach(r=>{Ge.is(r)&&r.disposeRecursively()})}toState(r=[]){let o={name:this.name,visible:this.visible,raycastLock:this.raycastLock,...this.toObjectTransformState(r)};return Pa(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=Ue(r.path,["states","*"]);if(c!==null){if(r.type===0){let[u]=c;if(this?.stateSelection===u){let d={...r.props};if(delete d.name,Object.values(r.props).some(p=>p===void 0)){let p=this.data;if(p!==void 0){let f=dt.zoom(p,r.path.slice(2));if(f)for(let h in r.props)r.props[h]===void 0&&h in f&&(d[h]=f[h])}}l={...r,props:d,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:p,...f}=u;u=f}if(r.props.material!==void 0&&"material"in u){let{material:p,...f}=u;u=f}let d=dt.removeOverridden(r.path,r.props,u);l={...r,props:d}}}if(this.updateByPatchedOpBase(l,Nn.patch(this.data,this.stateSelection?this.data.states.data(this.stateSelection):void 0),n),Ue(r.path,["overrides"])){let u=[],d=[...r.path];for(u.push(d[1]),d.splice(0,2);d.length>0&&d[0]==="descendants";)u.push(d[1]),d.splice(0,2);if(u[u.length-1]===void 0){if(r.type===0)for(let p of Object.keys(r.props)){u[u.length-1]=p;let f=n.scene.findInstance([this.uuid,...u]);f&&(f.overrideData=r.props[p],f.updateState(Co.apply(f.component.data,f.overrideData),n))}}else{let p=n.scene.findInstance([this.uuid,...u]);if(p){let f=dt.zoom(p.component.data,d);if(r={...r,path:d},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}}p.overrideData=za.resolve(o.overrides,u),p.updateByOp(r,vt.applySimple(p.data,r),n,!1)}}}else if(this.instances.length>0){let u;if(r.path.length===0&&r.type===0){let d;for(let p of _o.rootOverrideProps)p in r.props&&(d===void 0&&(d={}),d[p]=r.props[p]);d&&(u={...r,props:d})}else for(let d of _o.rootOverrideProps)if(Ue(r.path,[d])){u=r;break}u!==void 0&&this.instances.forEach(d=>{if(d.isInstanceRoot){let p=Co.filterOp(d.overrideData,u);p&&d.updateByOp(p,vt.applySimple(d.data,p),n,!0)}}),this.instances.forEach(d=>{if(!d.isInstanceRoot){let p=Co.filterOp(d.overrideData,r);if(p){let f;s===d.data&&r===p?f=o:f=vt.applySimple(d.data,p),d.updateByOp(p,f,n,!0)}}})}}updateByPatchedOpBase(r,o,n){if(this.dataPatched=o,r.path.length===0&&r.type===0)r.props.type!==void 0&&!ao.is(r.props.type)&&uo.changeEntityProptotype(this,o,n);else if(r.path.length===1&&r.path[0]==="geometry"&&r.type===0&&"type"in r.props){uo.changeEntityProptotype(this,o,n);for(let a of this.children)Ge.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(Ue(r.path,["pathSnapping"])!==null&&this.updatePathSnapping(o.pathSnapping),Ue(r.path,["cloner"])!==null){let a=vt.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):(this.setFromClonerState(o.cloner,n),this.expandCloner(n)),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=qu(c.geometry.path),d=(n+a)%1;n+a===1&&d===0&&(d=1);let p=null;try{p=u.curves.length?u.getPointAt(d):null}catch(y){!1&&(console.warn(`The aligned path on ${this.name} is invalid. (${l.name})`),console.error(y))}if(p===null)return;let f=this.parent?this.parent?.matrixWorld:new _t.Matrix4;l.updateMatrixWorld();let h=new _t.Matrix4().multiplyMatrices(f.clone().invert(),l.matrixWorld);p.applyMatrix4(h);let m={position:p.toArray(),rotation:c.rotation};if(s==="tangential"){let y=new _t.Matrix4().extractRotation(l.matrixWorld),g=u.getTangentAt(d).applyMatrix4(y).add(p),b=new _t.Matrix4().lookAt(p,g,FM),w=Ml.setFromEuler(new _t.Euler().setFromRotationMatrix(b)).multiplyScalar(_t.MathUtils.RAD2DEG);m={...m,rotation:w.toArray()}}this.updateTransformState(m),this.traverseEntity(y=>{y._cameraType&&y.dispatchEvent(zM)})}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 uo.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 uo.Cloner(this,r),o.scene.addPendingExpandCloner(this)):this.cloner.updateState(r,o))}expandCloner(r){!this.disposed&&this.cloner&&this.cloner.expandClones(r)}invalidateClonerTransform(r){this.cloner&&this.cloner.invalidateTransform(r)}requestRender(){this.dispatchEvent({type:"requestRender"})}};var Hi=require("three");var st=require("three"),Sx=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:d,cornerSegments:p,hollow:f}=i.parameters,h;return l===0?(h=new st.BufferGeometry,h.setAttribute("position",new st.Float32BufferAttribute([],3))):d||f?h=new Il(c,u,r,o,n,a,s,l*Math.PI/180,d,d,p,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 ki(i,t,e){e.x=i.x*t.x,e.y=i.y,e.z=i.x*t.y}function vx(i){return new st.Vector2(i.y,-i.x)}var Il=class extends st.BufferGeometry{constructor(t,e,r,o,n,a,s,l,c,u,d,p,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=[],g=[],b=0,w=r/2,P=new st.Vector3,S=new st.Vector3;f&&t==0&&(t=c),f&&e==0&&(e=u);let T=new st.Vector2(t,w),A=new st.Vector2(e,-w),x=null,N=null,E=null,M=null,D=T.clone().sub(A),_=0,R=0,V=0;p>0&&(_=Math.min(t,e)*(1-p),R=t-_,V=e-_);let U=T.clone();U.x-=_;let B=Math.PI-D.angle(),q=D.angle(),j=Math.tan(q/2),F=Math.tan(B/2),H=j+F,W=p?H:F,ee=p?H:j;if(c=Math.min(c,(t-R)/W,D.length()/H),u=Math.min(u,(e-V)/ee,D.length()/H),c>0){let Q=c/j;x=T.clone().sub(new st.Vector2(Q,c)),p&&(E=x.clone(),E.x-=_-H*c),T.sub(D.clone().setLength(Q))}if(u>0){let Q=u/F;N=A.clone().sub(new st.Vector2(Q,-u)),A.add(D.clone().setLength(Q)),p&&(M=N.clone(),M.x-=_-H*u,U.sub(D.clone().setLength(Q)))}D=T.clone().sub(A);let te=D.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));M&&N?(re($,pe,ie,B,u,M,-1,!0),re($,pe,ie,q,u,N,-1,!1)):N?(K($,ie,N.x,0,-1),re($,pe,ie,q,u,N,-1,!1)):a||K($,ie,e,V,-1);let ue=vx(D).normalize();if(ki(ue,ie,P),!te)for(let ae=0;ae<=n;ae++){let ge=ae/n,me=D.clone().multiplyScalar(ge).add(A);ki(me,ie,S),m.push(S.x,S.y,S.z),y.push(P.x,P.y,P.z),g.push(pe,.5+S.y/r),$.push(b++)}if(E&&x?(re($,pe,ie,B,c,x,1,!1),re($,pe,ie,q,c,E,1,!0)):x?(re($,pe,ie,B,c,x,1,!1),K($,ie,x.x,0,1)):a||K($,ie,t,R,1),p&&!te){let ae=vx(D).multiplyScalar(-1).normalize();ki(ae,ie,P);for(let ge=0;ge<=n;ge++){let me=ge/n,ye=D.clone().multiplyScalar(-me).add(U);ki(ye,ie,S),m.push(S.x,S.y,S.z),y.push(P.x,P.y,P.z),g.push(pe,.5+S.y/r),$.push(b++)}}p&&!a&&$.push($[0]),Y.push($)}for(let Q=0;Q<Y.length-1;Q++)for(let $=0;$<Y[0].length-1;$++){if(a&&p&&$==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(g,2));function re(Q,$,pe,le,ie,ue,ae,ge){for(let me=0;me<d+1;me++){let ye=me/d,Se=ae<0?ye:1-ye;ge&&(Se-=1),Se*=le;let xe=new st.Vector2(Math.sin(Se),Math.cos(Se)*ae),C=xe.clone().multiplyScalar(ie).add(ue);ki(C,pe,S),m.push(S.x,S.y,S.z),ki(xe,pe,P),y.push(P.x,P.y,P.z),g.push($,.5+S.y/r),Q.push(b++)}}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),ki(ae,$,ue),m.push(ue.x,ue.y,ue.z),y.push(0,ie,0),g.push(.5,.5),Q.push(b++)}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,Se,xe)=>h.push(ye,Se,xe):(ye,Se,xe)=>h.push(ye,xe,Se),ge=new st.Vector2((t+e+R+V)/4,0);ki(ge,le,ue),m.push(ue.x,ue.y,ue.z),y.push(ie.x,0,ie.y),g.push(.5,.5);let me=b++;for(let ye of $){let Se=m.slice(ye*3,ye*3+3);m.push(...Se),y.push(ie.x,0,ie.y);let xe=g.slice(ye*2,ye*2+2);g.push(...xe),b++}for(let ye=me+1;ye<b-1;ye++)ae(me,ye,ye+1);ae(me,b-1,me+1)}}};var wx=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=Hi.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:d}=i.parameters,p;return l===0?(p=new Hi.BufferGeometry,p.setAttribute("position",new Hi.Float32BufferAttribute([],3))):c>0||u>0||l<360?p=new Il(0,t/2,r,o,n,a,s,l*Math.PI/180,c,u,d,0,!0):p=new Hi.ConeGeometry(t/2,r,o,n,a),p.scale(1,1,e/t),Object.assign(p,{userData:{...i,type:"ConeGeometry"}})}};var Or=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 Or.BoxGeometry(t,e,r,o,n,a):c=new Mf(t,e,r,o,n,a,s,l),Object.assign(c,{userData:{...i,type:"CubeGeometry"}})}},Af=Math.PI/2,Mf=class extends Or.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=[],d=[],p=[],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 Or.Float32BufferAttribute(u,3)),this.setAttribute("normal",new Or.Float32BufferAttribute(d,3)),this.setAttribute("uv",new Or.Float32BufferAttribute(p,2));function h(g,b,w,P,S,T,A,x,N,E){let M=(T-2*s)/N,D=(A-2*s)/E,_=T/2-s,R=A/2-s,V=x/2,U=N+1,B=E+1,q=0,j=new Or.Vector3;for(let F=0;F<B;F++){let H=F*D-R;for(let W=0;W<U;W++){let ee=W*M-_;j[g]=ee*P,j[b]=H*S,j[w]=V,u.push(j.x,j.y,j.z),j[g]=0,j[b]=0,j[w]=x>0?1:-1,d.push(j.x,j.y,j.z),p.push(W/N),p.push(1-F/E),q+=1}}for(let F=0;F<E;F++)for(let H=0;H<N;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(g,b,w,P,S,T,A,x,N,E){let M=(A-2*s)/E,D=A/2-s,_=x/2-s,R=N/2,V=E+1,U=0,B=new Or.Vector3,q=new Or.Vector3;for(let j=0;j<l+1;j++){let F=j/l*Af,H=Math.sin(F)*s,W=(1-Math.cos(F))*s,ee=Math.sin(F),te=Math.cos(F);B[b]=(_+H)*S,B[w]=(R-W)*T,q[g]=0,q[b]=ee*Math.sign(B[b]),q[w]=te*Math.sign(B[w]);for(let Y=0;Y<V;Y++){let re=Y*M-D;B[g]=re*P,u.push(B.x,B.y,B.z),d.push(q.x,q.y,q.z),p.push(Y/E),p.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(g,b,w){let P=new Or.Vector3,S=new Or.Vector3(t/2,e/2,r/2);S.subScalar(s);let T=[],A=g*b*w>0?(N,E,M)=>c.push(N,E,M):(N,E,M)=>c.push(N,M,E);for(let N=0;N<=l;N++){let E=[],M=Af*(1-N/l),D=Math.cos(M),_=Math.sin(M),R=0;for(let V=0;V<=N;V++){let U=Math.cos(R),B=Math.sin(R);P.x=D*U,P.y=_,P.z=D*B;let q=S.clone().addScaledVector(P,s);u.push(g*q.x,b*q.y,w*q.z),d.push(g*P.x,b*P.y,w*P.z),p.push(0,0),E.push(f++),R+=Af/N}T.push(E)}let x=T.length-1;for(let N=0;N<x;N++){let E=T[N],M=T[N+1],D=E.length-1;A(E[0],M[1],M[0]);for(let _=1;_<=D;_++)A(E[_-1],E[_],M[_]),A(E[_],M[_+1],M[_])}}}};var Rt=require("three"),Wi=class extends Rt.BufferGeometry{constructor(t=[],e=[],r="",o=1,n=.2,a=4){super(),this.type="PolyhedronGeometryRound";let s=[],l=[],c=[];u(),d(),this.setAttribute("position",new Rt.Float32BufferAttribute(s,3)),this.setAttribute("normal",new Rt.Float32BufferAttribute(c,3)),this.setAttribute("uv",new Rt.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 Rt.Vector3,m=h.clone(),y=new Rt.Triangle,g=n*o,b=o-g,w=a+1,P=new Rt.Vector3,S=(j,F)=>P.subVectors(j,F).normalize(),T=(j,F)=>Array(j).fill(void 0).map(F),A=T(t.length/3,(j,F)=>new Rt.Vector3().fromArray(t,F*3).setLength(o)),x=[],N=1e6;for(let j=0;j<A.length;j++){let F=A[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(A[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=x[W]?.includes(j)==!0;te<=Y&&K.push(W+ +pe*N),Z=H.findIndex(le=>le[0]==ee)}x.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 M=h.clone(),D=h.clone(),_=h.clone(),R=h.clone(),V=h.clone(),U=[],B=T(A.length,()=>T(f,()=>h.clone()));for(let j=0;j<A.length;j++){h.copy(A[j]).normalize(),M.copy(h).multiplyScalar(b);let F=x[j];for(let K=0;K<F.length;K++){let Z=F[K],Q=F[(K+1)%f];y.setFromPointsAndIndices(A,j,Z%N,Q%N),y.b.sub(y.a).setLength(1e10).add(y.a),y.c.sub(y.a).setLength(1e10).add(y.a),y.closestPointToPoint(M,B[j][K])}let H=[],W=[],ee=[],te=new Rt.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(M),m.copy(pe).sub(M);let le=M.angleTo(h),ie=h.angleTo(m),ue=Math.cos(le)*g;a==0?D.copy(te):D.copy(M).setLength(b+ue),W.push(ue);let ae=[D,$,pe];for(let ge=0;ge<2;ge++){let me=ae[ge],ye=ae[ge+1];R.subVectors(me,M),V.subVectors(ye,M),_.crossVectors(R,V).normalize();for(let Se=0;Se<w;Se++){let xe=[le,ie][ge]*Se/w;h.copy(R).applyAxisAngle(_,xe).add(M),H.push(h.clone()),ge&&(S(h,M),Z.push([Se==0?me:h.clone(),P.clone()]))}ge&&(S(ye,M),Z.push([ye,P.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(M).setLength(W[K]).add(M),$.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,M),[P.x,P.y,P.z])).flat())}}let q=[];for(let j=0;j<x.length;j++)for(let F=0;F<f;F++){let H=x[j][F];if(H<N){let W=x[H].findIndex(Y=>Y%N==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];P.subVectors(ee[0],ee[1]).cross(h.subVectors(ee[0],ee[2])).normalize();let te=P.dot(ee[0])<0;te&&P.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(P.x,P.y,P.z)})}}function d(){let p=new Rt.Vector3;for(let A=0;A<s.length;A+=3){p.x=s[A+0],p.y=s[A+1],p.z=s[A+2];let x=S(p)/2/Math.PI+.5,N=T(p)/Math.PI+.5;l.push(x,1-N)}let f=new Rt.Vector3,h=new Rt.Vector3,m=new Rt.Vector3,y=new Rt.Vector3,g=new Rt.Vector2,b=new Rt.Vector2,w=new Rt.Vector2,P=(A,x,N,E)=>{E<0&&A.x===1&&(l[x]=A.x-1),N.x===0&&N.z===0&&(l[x]=E/2/Math.PI+.5)};for(let A=0,x=0;A<s.length;A+=9,x+=6){f.set(s[A+0],s[A+1],s[A+2]),h.set(s[A+3],s[A+4],s[A+5]),m.set(s[A+6],s[A+7],s[A+8]),g.set(l[x+0],l[x+1]),b.set(l[x+2],l[x+3]),w.set(l[x+4],l[x+5]),y.copy(f).add(h).add(m).divideScalar(3);let N=S(y);P(g,x+0,f,N),P(b,x+2,h,N),P(w,x+4,m,N)}for(let A=0;A<l.length;A+=6){let x=l[A+0],N=l[A+2],E=l[A+4],M=Math.max(x,N,E),D=Math.min(x,N,E);M>.9&&D<.1&&(x<.2&&(l[A+0]+=1),N<.2&&(l[A+2]+=1),E<.2&&(l[A+4]+=1))}function S(A){return Math.atan2(A.z,-A.x)}function T(A){return Math.atan2(-A.y,Math.sqrt(A.x*A.x+A.z*A.z))}}}static fromJSON(t){return new Wi(t.vertices,t.indices,t.radius,t.corner,t.cornerSides)}};var Ox=require("three"),Tx=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 Ox.DodecahedronGeometry(t*.5,o);return s.scale(1,e/t,r/t),Object.assign(s,{userData:{...i,type:"DodecahedronGeometry"}})}},El=class extends Wi{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 El(t.radius,t.corner,t.cornerSides)}};var Ke=require("three");var De=require("three"),Nl=1e-12,Xa=class{constructor(t){this.position=new De.Vector2;this.startPosition=new De.Vector2;this.uuid=De.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 Xa(this.position).copy(this)}toJSON(){return[this.position.x,this.position.y]}},Ya=class extends Xa{constructor(e){super(e.position);this.parent=e}copy(e){return super.copy(e),this}clone(){return new Ya(this.parent).copy(this)}},po=class extends Xa{constructor(e,r){super(r);this.controls=[];this.roundness=0;this.areControlsDirectionsMirrored=!0;this.uuid=e,this.controls.push(new Ya(this),new Ya(this))}static create(e,r){let o=new po(e,new De.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 po(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 De.Vector2,r=new De.Vector2){let[o,n]=this.computeTangents();return o&&n&&(Cx(o,e),Cx(n,r)),[e,r]}computeTangent(e=new De.Vector2){let[r,o]=this.computeTangents();return r&&o&&e.copy(r).add(o).normalize(),e}computeNormal(e=new De.Vector2){let[r,o]=this.computeNormals();return e.copy(r).add(o).normalize(),e}};function Cx(i,t=new De.Vector2){let e=i.length();return t.set(-i.y/e,i.x/e)}var Ef=i=>i,Ka=new De.Vector2,$u=new De.Vector2,jM=new De.Vector2,UM=new De.Vector2,kM=new De.Vector2,HM=new De.Vector2,Mx=new De.Vector3,Ix=new De.Vector3;function Ex(i){let t=new De.Vector2;t.addVectors(i.v0,Ka.subVectors(i.v1,i.v0).multiplyScalar(2/3));let e=new De.Vector2;return e.addVectors(i.v2,$u.subVectors(i.v1,i.v2).multiplyScalar(2/3)),new De.CubicBezierCurve(i.v0,t,e,i.v2)}function Dl(i,t,e=Number.EPSILON){return Math.abs(i-t)<e}function WM(i,t,e=Number.EPSILON){return i.distanceTo(t)<e}function qM(i,t,e=Number.EPSILON){return i.distanceTo(t)<e}function Nf(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 Nx(i,t,e){return Ax(i,t)&&Ax(t,e)&&If(i.position,t.position,e.position)}function If(i,t,e){return Ka.copy(t).sub(i).cross($u.copy(e).sub(i))===0}function Dx(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 _x(i,t,e){let r=i.distanceTo(e),o=t.distanceTo(e);return r<o?t:i}function Rx(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)),d;return Nf(t,i,e)>Math.PI&&(u*=-1),Dl(c,s)?d=(s+c)*(r/u-.5)*8/3/(a-l):d=(a+l)*(r/u-.5)*8/3/(c-s),o.set(t.x-d*s,t.y+d*a),n.set(e.x+d*c,e.y-d*l),[o,n]}function Df(i,t){return i.position.equals(i.controls[1].position)&&t.position.equals(t.controls[0].position)}function Ax(i,t){return If(i.position,i.controls[1].position,t.position)&&If(i.position,t.controls[0].position,t.position)}function Lx(i,t,e,r,o=.5){let n=Ka.subVectors(t,i).multiplyScalar(o).add(i),a=$u.subVectors(e,t).multiplyScalar(o).add(t),s=jM.subVectors(r,e).multiplyScalar(o).add(e),l=n,c=UM.subVectors(a,n).multiplyScalar(o).add(n),u=kM.subVectors(s,a).multiplyScalar(o).add(a),d=s,p=HM.subVectors(u,c).multiplyScalar(o).add(c);return[i.x,i.y,l.x,l.y,c.x,c.y,p.x,p.y,u.x,u.y,d.x,d.y,r.x,r.y]}function Bx(i,t,e=12,r=!0){let o=Ix.set(0,0,0),n,a=0,s=[];for(let l=0;l<t.length;l++){let c=Ef(t[l]),u=Ka,d=qi(c,e);s.push(d);for(let p=0;p<=d;p++)if(c instanceof De.CubicBezierCurve||c instanceof De.QuadraticBezierCurve||c instanceof De.LineCurve){if(c.getPoint(p/d,u),o.set(u.x,u.y,0),n!==void 0&&qM(n,o))continue;n===void 0&&(n=Mx),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 Vx(i,t,e,r=12,o=!0){let n=Ix.set(0,0,0),a=0,s=[];for(let l=0;l<t.length;l++){if(e[l]===!1)continue;let c,u=Ef(t[l]),d=Ka,p=qi(u,r);s.push(p);for(let f=0;f<=p;f++)if(u instanceof De.CubicBezierCurve||u instanceof De.QuadraticBezierCurve||u instanceof De.LineCurve){if(u.getPoint(f/p,d),n.set(d.x,d.y,0),c?.equals(n))continue;c===void 0?c=Mx:(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 _f(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=qi(a.roundedCurveCorner,t)*.5;o>0&&(r[o-1]+=l),s+=l}a.curveAfter!==void 0&&(s+=qi(a.curveAfter,t)),r.push(s)}return i.length>0&&e&&i[0].roundedCurveCorner!==void 0&&(r[i.length-1]+=qi(i[0].roundedCurveCorner,t)*.5),r}function qi(i,t=12){return i&&i instanceof De.EllipseCurve?t*2:i&&(i instanceof De.LineCurve||i instanceof De.LineCurve3)?1:i&&i instanceof De.SplineCurve?t*i.points.length:t}function zx(i,t,e=12,r=!0){let o,n=0;for(let a=0;a<t.length;a++){let s=Ef(t[a]),l=qi(s,e),c=Ka;for(let u=0;u<=l;u++)if(s instanceof De.CubicBezierCurve||s instanceof De.QuadraticBezierCurve||s instanceof De.LineCurve){if(s.getPoint(u/l,c),o!==void 0&&WM(o,c,Nl))continue;o===void 0&&(o=$u),o.copy(c),i.push(c.x,c.y),n++}}return Dl(i[0],i[i.length-2],Nl)&&Dl(i[1],i[i.length-1],Nl)&&(i.pop(),i.pop()),r&&n>1&&!(Dl(i[n-1],i[1],Nl)&&Dl(i[n-2],i[0],Nl))&&(i.push(i[0],i[1]),n++),i}var Rf=new Ke.Vector2,$M=new Ke.Vector2,XM=new Ke.Vector2,YM=new Ke.Vector2,KM=new Ke.Vector2,QM=new Ke.Vector2,Ye=class extends Ke.Shape{constructor(e=100,r=100){super();this.points=[];this.shapeHoles=[];this.plane=new Ke.Plane(new Ke.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=Ke.MathUtils.generateUUID();this.needsUpdate=!1;this.roundedCurves=[];this._width=e,this._height=r}static createFromState(e,r,o){let n=new Ye;return n.isClosed=e.isClosed,n.points=e.points.map(a=>po.create(a.id,a.data)),typeof e.roundness=="number"&&(n.roundness=e.roundness),n.shapeHoles=e.shapeHoles.map(a=>Ye.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=Rf.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=Ke.MathUtils.generateUUID()){let n;e instanceof Ke.Vector2?n=e:n=new Ke.Vector2(e,r);let a=new po(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 Bx(e,o?this.roundedCurves:this.curves,r,this.autoClose),n.reduce((a,s)=>a+s,0)+1}computeCurveDivisions(e=12){return this.curveDivisions=_f(this.points,e,!1),this.roundedCurveDivisions=_f(this.points,e,!0),this.curveDivisions}extractFilteredShapePointsToBuffer(e,r,o=12){return Vx(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),zx(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=qi(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(Df(n,a)){let d=n.position.distanceTo(a.position);return n.position.distanceTo(Rf.set(o.x,o.y))/d}let c=0;for(let d=0;d<e;d++)c+=s[d];return(r-c)/l}dispose(){}_applyCurveForPoint(e,r){Df(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&&Nx(s,a,l);if(!a.controlsMoved()&&c>0&&!u){let d=a.curveBefore,p=a.curveAfter;if(d===void 0||p===void 0)continue;let f=a.roundedCurveBefore,h=a.roundedCurveAfter,m=d.getLength(),y=p.getLength(),g=Math.min(c,m*.499),b=Math.min(c,y*.499),w=Math.min(g,b),P=1-w/m,S=w/y,T=d.getPointAt(P,Rf),A=p.getPointAt(S,$M);this._subSplitCurve(d,f,P,T,void 0),this._subSplitCurve(p,h,S,void 0,A);let x;if(this.useCubicForRoundedCorners){let N=Nf(T,a.position,A)/2,E=Math.tan(N)*T.distanceTo(a.position),[M,D]=Dx(T,A,E,XM,YM),_=_x(M,D,a.position),[R,V]=Rx(_,T,A,E,KM,QM);x=new Ke.CubicBezierCurve(T.clone(),R.clone(),V.clone(),A.clone())}else x=new Ke.QuadraticBezierCurve(T.clone(),a.position.clone(),A.clone());a.roundedCurveCorner=x,this.roundedCurves.splice(o+r,0,x),r++}}}}_subSplitCurve(e,r,o,n,a){if(e instanceof Ke.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=Lx(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 Ye(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],d=e.points[n+5],p=e.points[n+6],f=new po(Ke.MathUtils.generateUUID(),new Ke.Vector2(a,s));f.controls[0].position.set(l,c),f.controls[1].position.set(u,d),f.roundness=p,this.points.push(f)}return this.shapeHoles=e.shapeHoles?.length?e.shapeHoles.map(o=>{let n=new Ye;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 Ke.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 Ke.QuadraticBezierCurve&&(a[l]=Ex(a[l]));for(l=0,c=a.length;l<c;l++){let p=a[l],f=l>0?a[l-1]:null,h;p instanceof Ke.CubicBezierCurve?(h=this.createPoint(p.v0),h.controls[1].position.copy(p.v1)):p instanceof Ke.LineCurve&&(h=this.createPoint(p.v1)),h!==void 0&&(f!==null&&o(h,f),s.push(h))}let u=a[a.length-1],d=!1;return u instanceof Ke.CubicBezierCurve?u.v3.equals(s[0].position)&&(s[0].controls[0].position.copy(u.v2),d=!0):u instanceof Ke.LineCurve&&u.v2.equals(s[0].position)&&(d=!0),this.isClosed=d,s};return this.points=n(e.curves),e instanceof Ke.Shape&&(this.shapeHoles=e.holes.map(a=>{let s=new Ye;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 Bf=Math.PI*2;function Lf({x:i,y:t},e,r,o,n){return{x:i*e+o,y:t*r+n}}function ZM(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 Gx(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 JM(i,t,e,r,o,n,a,s,l,c){let u=Math.pow(o,2),d=Math.pow(n,2),p=Math.pow(a,2),f=Math.pow(s,2),h=u*d-u*f-d*p;h<0&&(h=0),h/=u*f+d*p,h=Math.sqrt(h)*(l===c?-1:1);let m=h*o/n*s,y=h*-n/o*a,g=m+(i+e)/2,b=y+(t+r)/2,w=(a-m)/o,P=(s-y)/n,S=(-a-m)/o,T=(-s-y)/n,A=Gx(1,0,w,P),x=Gx(w,P,S,T);return!c&&x>0&&(x-=Bf),c&&x<0&&(x+=Bf),{centerx:g,centery:b,ang1:A,ang2:x}}function Fx({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 d=Math.pow(c,2)/Math.pow(o,2)+Math.pow(u,2)/Math.pow(n,2);d>1&&(o*=Math.sqrt(d),n*=Math.sqrt(d));let p=JM(i,t,e,r,o,n,c,u,a,s),{ang1:f,ang2:h}=p,{centerx:m,centery:y}=p,g=Math.abs(h)/(Bf/4);Math.abs(1-g)<1e-7&&(g=1);let b=Math.max(Math.ceil(g),1);h/=b;for(let w=0;w<b;w++)l.push(ZM(f,h)),f+=h;return l.map(w=>{let{x:P,y:S}=Lf(w[0],o,n,m,y),{x:T,y:A}=Lf(w[1],o,n,m,y),{x,y:N}=Lf(w[2],o,n,m,y);return{x1:P,y1:S,x2:T,y2:A,x,y:N}})}var Ln=require("three");var Xe;(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"})(Xe||(Xe={}));var Pt;(function(i){i[i.POLYGONS=0]="POLYGONS",i[i.CONNECTED_POLYGONS=1]="CONNECTED_POLYGONS",i[i.BOUNDARY_CONTOURS=2]="BOUNDARY_CONTOURS"})(Pt||(Pt={}));function Te(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){Te(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){Te(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){Te(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){Te(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}(),_l=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}(),Xu=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}(),Qa=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}(),jx=function(){function i(){var t=new Qa,e=new _l,r=new Xu(0),o=new Xu(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 Xu(0),r=new Xu(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;Te(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;Te(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 Qa,e=new Qa,r=new _l,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 Qa;this.makeVertex_(n,e,t.Org),t.Org.anEdge=t}if(!r){var a=new _l;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 _l;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 Qa;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 _l;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){Te(o.prev===n),l=o.anEdge;do Te(l.Sym!==l),Te(l.Sym.Sym===l),Te(l.Lnext.Onext.Sym===l),Te(l.Onext.Sym.Lnext===l),Te(l.Lface===o),l=l.Lnext;while(l!==o.anEdge)}for(Te(o.prev===n&&o.anEdge===null),s=e,s=e;(a=s.next)!==e;s=a){Te(a.prev===s),l=a.anEdge;do Te(l.Sym!==l),Te(l.Sym.Sym===l),Te(l.Lnext.Onext.Sym===l),Te(l.Onext.Sym.Lnext===l),Te(l.Org===a),l=l.Onext;while(l!==a.anEdge)}for(Te(a.prev===s&&a.anEdge===null),c=r,c=r;(l=c.next)!==r;c=l)Te(l.Sym.next===c.Sym),Te(l.Sym!==l),Te(l.Sym.Sym===l),Te(l.Org!==null),Te(l.Dst!==null),Te(l.Lnext.Onext.Sym===l),Te(l.Onext.Sym.Lnext===l);Te(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}(),Ux=function(){function i(){this.handle=null}return i}(),kx=function(){function i(){this.key=null,this.node=0}return i}(),eI=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 Ux,this.handles[r]=new kx;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,Te(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 Ux;for(n=this.handles.length,this.handles.length=this.max+1,o=n;o<this.handles.length;o++)this.handles[o]=new kx}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;Te(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}(),Vf=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}(),Hx=function(){function i(){this.key=null,this.next=null,this.prev=null}return i}(),tI=function(){function i(t,e){this.frame=t,this.leq=e,this.head=new Hx,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 Hx;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}(),rI=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&&Te(e.eUp.winding===0),e.eUp.activeRegion=null,t.dict.delete(e.nodeUp)},i.fixUpperEdge=function(t,e,r){Te(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 Vf;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 Xe.ODD:return(e&1)!==0;case Xe.NONZERO:return e!==0;case Xe.POSITIVE:return e>0;case Xe.NEGATIVE:return e<0;case Xe.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,d=!0;c=r;do Te(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,!d&&i.checkForRightSplice(t,l)&&(i.addWinding(c,u),i.deleteRegion(t,l),t.mesh.delete(u)),d=!1,l=s,u=c;l.dirty=!0,Te(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(Te(!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,d,p=new Qa,f,h;if(Te(!we.vertEq(c,l)),Te(we.edgeSign(l,t.event,a)<=0),Te(we.edgeSign(c,t.event,s)>=0),Te(a!==t.event&&s!==t.event),Te(!e.fixUpperEdge&&!r.fixUpperEdge),a===s||(u=Math.min(a.t,l.t),d=Math.max(s.t,c.t),u>d))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,p),Te(Math.min(a.t,l.t)<=p.t),Te(p.t<=Math.max(s.t,c.t)),Te(Math.min(c.s,l.s)<=p.s),Te(p.s<=Math.max(s.s,a.s)),we.vertLeq(p,t.event)&&(p.s=t.event.s,p.t=t.event.t),f=we.vertLeq(a,s)?a:s,we.vertLeq(f,p)&&(p.s=f.s,p.t=f.t),we.vertEq(p,a)||we.vertEq(p,s)?(i.checkForRightSplice(t,e),!1):!we.vertEq(l,t.event)&&we.edgeSign(l,t.event,p)>=0||!we.vertEq(c,t.event)&&we.edgeSign(c,t.event,p)<=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,p)>=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,p)<=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=p.s,o.Org.t=p.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)){Te(!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}Te(!1),e=i.topRightRegion(e),l=i.regionBelow(e),a=l.eUp.Sym,n=s=a.Onext,l.fixUpperEdge&&(Te(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 Vf;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);Te(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 Vf,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 tI(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||(Te(e.fixUpperEdge),Te(++r===1)),Te(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 eI(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,Te(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}(),oI=function(){function i(){this.mesh=new jx,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=Xe.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],d=[0,0,0],p=[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 g=0;g<3;++g)n=e.coords[g],n<c[g]&&(c[g]=n,h[g]=e),n>l[g]&&(l[g]=n,f[g]=e);var b=0;if(l[1]-c[1]>l[0]-c[0]&&(b=1),l[2]-c[2]>l[b]-c[b]&&(b=2),c[b]>=l[b]){t[0]=0,t[1]=0,t[2]=1;return}for(s=0,r=h[b],o=f[b],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)d[0]=e.coords[0]-o.coords[0],d[1]=e.coords[1]-o.coords[1],d[2]=e.coords[2]-o.coords[2],p[0]=u[1]*d[2]-u[2]*d[1],p[1]=u[2]*d[0]-u[0]*d[2],p[2]=u[0]*d[1]-u[1]*d[0],a=p[0]*p[0]+p[1]*p[1]+p[2]*p[2],a>s&&(s=a,t[0]=p[0],t[1]=p[1],t[2]=p[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===Pt.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 d=c.n*o;this.vertices[d+0]=c.coords[0],this.vertices[d+1]=c.coords[1],o>2&&(this.vertices[d+2]=c.coords[2]),this.vertexIndices[c.n]=c.idx}for(var p=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[p++]=c.n,l++,n=n.Lnext}while(n!==u.anEdge);for(var f=l;f<r;++f)this.elements[p++]=-1;if(e===Pt.CONNECTED_POLYGONS){n=u.anEdge;do this.elements[p++]=this.getNeighbourFace_(n),n=n.Lnext;while(n!==u.anEdge);for(var h=l;h<r;++h)this.elements[p++]=-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 jx),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=Xe.ODD),e===void 0&&(e=Pt.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_(),rI.computeInterior(this,a);var s=this.mesh;return e===Pt.BOUNDARY_CONTOURS?this.setWindingNumber_(s,1,!0):this.tessellateInterior_(s),a&&s.check(),e===Pt.BOUNDARY_CONTOURS?this.outputContours_(s,o):this.outputPolymesh_(s,e,r,o),!0},i}();function fo(i){var t=i.windingRule,e=t===void 0?Xe.ODD:t,r=i.elementType,o=r===void 0?Pt.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,d=i.contours,p=d===void 0?[]:d,f=i.strict,h=f===void 0?!0:f,m=i.debug,y=m===void 0?!1:m;if(!p&&h)throw new Error("Contours can't be empty");if(!!p){var g=new oI;i.edgeCreateCallback&&(g.edgeCreateCallback=i.edgeCreateCallback),i.vertexIdCallback&&(g.vertexIdCallback=i.vertexIdCallback);for(var b=0;b<p.length;b++)g.addContour(l||2,p[b]);return g.tesselate(e,o,a,l,u,h),{vertices:g.vertices,vertexIndices:g.vertexIndices,vertexCount:g.vertexCount,elements:g.elements,elementCount:g.elementCount,mesh:y?g.mesh:void 0}}}var _5=Xe.ODD,R5=Xe.NONZERO,L5=Xe.POSITIVE,B5=Xe.NEGATIVE,V5=Xe.ABS_GEQ_TWO,z5=Pt.POLYGONS,G5=Pt.CONNECTED_POLYGONS,F5=Pt.BOUNDARY_CONTOURS;var ho=require("three");var Yu=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*Yu.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*Yu.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)}},Rl=Yu;Rl.eSize=(3+3+2)*Float32Array.BYTES_PER_ELEMENT;var Ll=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 zf(i,t,e=1,r=!1){let o=1/0,n=1/0,a=-1/0,s=-1/0;for(let[b,w]of i[0])b<o&&(o=b),w<n&&(n=w),b>a&&(a=b),w>s&&(s=w);let l=a-o,c=s-n,u=Math.max(e,Math.min(l,c));if(u===e){let b=[o,n];return b.distance=0,b.distance}let d=new Ll([],(b,w)=>w.max-b.max),p=nI(i),f=new Ku(o+l/2,n+c/2,0,i);f.d>p.d&&(p=f);let h=2;function m(b,w,P){let S=new Ku(b,w,P,i);if(h++,S.max>p.d+e&&d.push(S),S.d>p.d&&(p=S,r&&console.log(`found best ${Math.round(1e4*S.d)/1e4} after ${h} probes`),p.d>t))return t}let y=u/2;for(let b=o;b<a;b+=u)for(let w=n;w<s;w+=u)m(b+y,w+y,y);for(;d.length;){let{max:b,x:w,y:P,h:S}=d.pop();if(b-p.d<=e)break;y=S/2,m(w-y,P-y,y),m(w+y,P-y,y),m(w-y,P+y,y),m(w+y,P+y,y)}r&&console.log(`num probes: ${h}
3
- best distance: ${p.d}`);let g=[p.x,p.y];return g.distance=p.d,g.distance}function Ku(i,t,e,r){this.x=i,this.y=t,this.h=e,this.d=iI(i,t,r),this.max=this.d+this.h*Math.SQRT2}function iI(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,aI(i,t,c,u))}return o===0?0:(r?1:-1)*Math.sqrt(o)}function nI(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],d=c[0]*u[1]-u[0]*c[1];e+=(c[0]+u[0])*d,r+=(c[1]+u[1])*d,t+=d*3}let n=new Ku(e/t,r/t,0,i);return t===0||n.d<0?new Ku(o[0][0],o[0][1],0,i):n}function aI(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 Bl={vertices:[160,160,-160,160,-160,-160,160,-160],vertexIndices:[1,0,3,2],vertexCount:4,elements:[0,4],elementCount:1,mesh:void 0},Ff={vertices:[],vertexIndices:[],vertexCount:0,elements:[],elementCount:0,mesh:void 0},jf={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},Gf=(i,t)=>([e,r])=>(r<e&&(r+=t),(i>=e?i:i+t)<=r),$i=class extends ho.BufferGeometry{constructor(e,r,o=0,n=12,a=3,s=Xe.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(M=>{let D=M.extractShapePointsToFlatArray([],n),_=[];for(let R=D.length-1;R>=1;R-=2){let V=D[R-1],U=D[R-0];_.push(V,U)}return _}),d=[],p=[];for(let M=0;M<c.length;M+=2)p.push([c[M],c[M+1]]);d.push(p);for(let M=0;M<u.length;M++){let D=u[M],_=[];for(let R=0;R<D.length;R+=2)_.push([D[R],D[R+1]]);d.push(_)}let f;e.isText?f=new ho.Box2().setFromPoints(e.points.map(D=>D.position)).getSize(new ho.Vector2).length()*.1:d[0].length===0?f=o:o>0?f=zf(d,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=fo({windingRule:s,elementType:Pt.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[c]})}catch{h=Bl}let m;try{m=fo({windingRule:Xe.ODD,elementType:Pt.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...u]})}catch{m=Ff}if(!h)throw new Error("error generating geometry");let y=h.elementCount;if(m){h.elementCount+=m.elementCount;for(let M=0;M<m.elements.length;M++){let D=m.elements[M],_=M%2===0?h.vertexCount:0;h.elements.push(D+_)}for(let M=0;M<m.vertexIndices.length;M++){let D=m.vertexIndices[M],_=h.vertexCount;h.vertexIndices.push(D+_)}for(let M=0;M<m.vertices.length;M++){let D=m.vertices[M];h.vertices.push(D)}}let g=1/0,b=-1/0,w=1/0,P=-1/0;for(let M=0,D=h.vertexCount;M<D;M++){let _=M*2,R=h.vertices[_+0],V=h.vertices[_+1];R<g&&(g=R),R>b&&(b=R),V<w&&(w=V),V>P&&(P=V)}this._minX=g,this._minY=w,this._width=b-g,this._height=P-w,this._buffer=new Rl(this._computeBufferEstimatedSize(h));let S=[],T=[];for(let M=h.elementCount-1;M>=0;M--){let D=M>=y,_=M*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 Se=h.vertexIndices[q];if(Array.isArray(Se))B.continuous[re]=!1;else{let[xe,C]=this._shape.getCurveIndexFromVertexId(Se-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 ze=C===1?0:1,He=this._shape.roundedCurves[xe].getTangent(C),Fe=this._shape.roundedCurves[ne].getTangent(ze);B.continuous[re]=He.dot(Fe)>.95}}D&&(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],Se=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,ze=-B.normals[ge+1]*Z;if(B.concave[ae]||!B.concave[ae]&&D){let He=Math.atan2(C,xe),Fe=Math.atan2(ze,ne);Fe>He&&(Fe-=Math.PI*2);let Ae=Fe-He;if(B.continuous[ae]||D){let Ut=He+Ae/2,Re=Math.cos(Ut)*Z,Ft=Math.sin(Ut)*Z;Q[2*ie+0]=ye+Re*(D?-1:1),Q[2*ie+1]=Se+Ft*(D?-1:1),le[ie]=ae,ie++}else{let Ut=Math.max(1,Math.floor(n/4*Math.abs(Ae)/Math.PI));for(let Re=0;Re<=Ut;Re++){let Ft=He+Ae*(Re/Ut),kt=Math.cos(Ft)*Z,xn=Math.sin(Ft)*Z;Q[2*ie+0]=ye+kt,Q[2*ie+1]=Se+xn,le[ie]=ae,ie++}}}else Q[2*ie+0]=ye+xe,Q[2*ie+1]=Se+C,le[ie]=ae,$[ae]=ie,ie++,Q[2*ie+0]=ye,Q[2*ie+1]=Se,le[ie]=ae,ie++,Q[2*ie+0]=ye+ne,Q[2*ie+1]=Se+ze,le[ie]=ae,pe[ae]=ie,ie++}let ue=fo({windingRule:Xe.POSITIVE,elementType:Pt.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[Q],edgeCreateCallback:ae=>{let me=ae.Org.idx,ye=le[me],Se=le[(me+1)%le.length];ae.idx=[ye,Se],ae.Sym.idx=[Se,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 Se=ge;Se<ye;Se++){let xe=Se%V,C=(Se+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=Gf(le,V);for(;!K.boundary.vertexIndices.filter(ie).length||!Z.boundary.vertexIndices.filter(ie).length;)le++,ie=Gf(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),Se=this._buildBevelVert(B,Z,(ae-1+$)%$,void 0,me),xe=ye,C=Se,ne,ze,He=!1;do{me=(le||pe)/pe,ie=Gf(le,V);let Fe=te(K,ue,ie),Ae=te(Z,ae,ie),Ut=He;if(He=!1,Fe&&!Ae){for(let Re=0;Re<Fe;Re++)ne=this._buildBevelVert(B,K,(ue+Re)%Q,Re/(Fe-1),me),S.push(xe.topN,ne.topP,C.topN),l===!1&&S.push(ne.bottomP,xe.bottomN,C.bottomN),xe=ne;He=!0}else if(!Fe&&Ae)for(let Re=0;Re<Ae;Re++)ze=this._buildBevelVert(B,Z,(ae+Re)%$,Re/(Ae-1),me),S.push(C.topN,xe.topP,ze.topP),l===!1&&S.push(xe.bottomP,C.bottomN,ze.bottomP),C=ze;else if(Fe&&Ae)if(ne=this._buildBevelVert(B,K,ue,0,me),ze=this._buildBevelVert(B,Z,ae,0,me),Ut?(S.push(xe.topN,ze.topP,C.topN),S.push(xe.topN,ne.topP,ze.topP),l===!1&&(S.push(ze.bottomP,xe.bottomN,C.bottomN),S.push(ze.bottomP,ne.bottomP,xe.bottomN))):(S.push(C.topN,xe.topN,ne.topP),S.push(C.topN,ne.topP,ze.topP),l===!1&&(S.push(ne.bottomP,xe.bottomN,C.bottomN),S.push(ne.bottomP,C.bottomN,ze.bottomP))),xe=ne,C=ze,Fe===Ae)for(let Re=1;Re<Fe;Re++)ne=this._buildBevelVert(B,K,(ue+Re)%Q,Re/(Fe-1),me),ze=this._buildBevelVert(B,Z,(ae+Re)%$,Re/(Ae-1),me),S.push(xe.topN,ne.topP,C.topN),S.push(C.topN,ne.topP,ze.topP),l===!1&&(S.push(ne.bottomP,xe.bottomN,C.bottomN),S.push(ne.bottomP,C.bottomN,ze.bottomP)),xe=ne,C=ze;else if(Fe>Ae){let Re=Fe/Ae,Ft=0;for(let kt=1;kt<Fe;kt++)ne=this._buildBevelVert(B,K,(ue+kt)%Q,kt/(Fe-1),me),S.push(xe.topN,ne.topP,C.topN),l===!1&&S.push(ne.bottomP,xe.bottomN,C.bottomN),xe=ne,kt>(Ft+1)*Re&&(Ft++,ze=this._buildBevelVert(B,Z,(ae+Ft)%$,Ft/(Ae-1),me),S.push(C.topN,ne.topP,ze.topP),l===!1&&S.push(ne.bottomP,C.bottomN,ze.bottomP),C=ze)}else{let Re=Ae/Fe,Ft=0;for(let kt=1;kt<Ae;kt++)ze=this._buildBevelVert(B,Z,(ae+kt)%$,kt/(Ae-1),me),S.push(C.topN,ne.topP,ze.topP),l===!1&&S.push(ne.bottomP,C.bottomN,ze.bottomP),C=ze,kt>(Ft+1)*Re&&(Ft++,ne=this._buildBevelVert(B,K,(ue+Ft)%Q,Ft/(Fe-1),me),S.push(xe.topN,ne.topP,C.topN),l===!1&&S.push(ne.bottomP,xe.bottomN,C.bottomN),xe=ne)}ue=(ue+Fe)%Q,ae=(ae+Ae)%$,le=(le+1)%pe}while(le!==ge)}if(l===!1&&this._depth>this._bevel*2&&this._buildWall(W,B,S),D){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(D){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(!D){let re=W[W.length-1],K;try{K=fo({windingRule:W.length>1?Xe.POSITIVE:Xe.ODD,elementType:Pt.POLYGONS,vertexSize:2,strict:!0,contours:[re.insetPoints,...T]})}catch{K=jf}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 A=new ho.BufferAttribute(Uint32Array.from(S),1),x=new ho.BufferAttribute(this._buffer.positions,3),N=new ho.BufferAttribute(this._buffer.normals,3),E=new ho.BufferAttribute(this._buffer.uvs,2);x.needsUpdate=!0,N.needsUpdate=!0,E.needsUpdate=!0,A.needsUpdate=!0,this.setAttribute("position",x),this.setAttribute("normal",N),this.setAttribute("uv",E),this.setIndex(A)}_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),d=u*3,p=u*2,f={top:u+0,bottom:u+1};return this._buffer.positions[d+0]=a,this._buffer.positions[d+1]=s,this._buffer.positions[d+2]=this.forPathBevel?this._bevel:this._depth-o,this._buffer.normals[d+0]=0,this._buffer.normals[d+1]=0,this._buffer.normals[d+2]=1,this._buffer.uvs[p+0]=l,this._buffer.uvs[p+1]=c,this.forPathBevel===!1&&(this._buffer.positions[d+3]=a,this._buffer.positions[d+4]=s,this._buffer.positions[d+5]=o,this._buffer.normals[d+3]=0,this._buffer.normals[d+4]=0,this._buffer.normals[d+5]=-1,this._buffer.uvs[p+2]=l,this._buffer.uvs[p+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,d,p,f;l!==c?(d=l,u=c,f=!1,p=e.continuous[d]&&e.continuous[u]):(u=l,d=(u-1+e.count)%e.count,f=e.concave[u]&&r.bevelI>0,p=e.continuous[u]||f);let h=Math.cos(r.angle),m=Math.sin(r.angle),y=o*2,g=u*2,b=d*2,w=r.boundary.vertices[y+0],P=r.boundary.vertices[y+1],S=(1-m)*this._bevel,T=(w-this._minX)/this._width,A=(P-this._minY)/this._height;this.forPathBevel&&(a!==void 0&&(T=a),A=1);let x=e.normals[g+0],N=e.normals[g+1],E=e.normals[b+0],M=e.normals[b+1];if(f){let U=E-x,B=M-N;x=x+U*(1-n),N=N+B*(1-n);let q=Math.sqrt(x*x+N*N);x/=q,N/=q}let D=this.forPathBevel?this._buffer.get(p?1:2):this._buffer.get(p?2:4),_=D*3,R=D*2,V={i:o,fi:u,topP:D+0,topN:D+0,bottomP:D+1,bottomN:D+1,pathBevelUCoord:a};return this._buffer.positions[_+0]=w,this._buffer.positions[_+1]=P,this._buffer.positions[_+2]=(this.forPathBevel?this._bevel:this._depth)-S,this._buffer.normals[_+0]=x*h,this._buffer.normals[_+1]=N*h,this._buffer.normals[_+2]=m,this._buffer.uvs[R+0]=T,this._buffer.uvs[R+1]=A,this.forPathBevel===!1&&(this._buffer.positions[_+3]=w,this._buffer.positions[_+4]=P,this._buffer.positions[_+5]=S,this._buffer.normals[_+3]=x*h,this._buffer.normals[_+4]=N*h,this._buffer.normals[_+5]=-m,this._buffer.uvs[R+2]=A,this._buffer.uvs[R+3]=T),p||(this.forPathBevel?(D+=1,_+=3,R+=2):(D+=2,_+=6,R+=4),V.topP=D+0,V.bottomP=D+1,this._buffer.positions[_+0]=w,this._buffer.positions[_+1]=P,this._buffer.positions[_+2]=(this.forPathBevel?this._bevel:this._depth)-S,this._buffer.normals[_+0]=E*h,this._buffer.normals[_+1]=M*h,this._buffer.normals[_+2]=m,this._buffer.uvs[R+0]=T,this._buffer.uvs[R+1]=A,this.forPathBevel===!1&&(this._buffer.positions[_+3]=w,this._buffer.positions[_+4]=P,this._buffer.positions[_+5]=S,this._buffer.normals[_+3]=E*h,this._buffer.normals[_+4]=M*h,this._buffer.normals[_+5]=-m,this._buffer.uvs[R+2]=A,this._buffer.uvs[R+3]=T)),this.vertexCache[s]=V,V}clone(){let e=new $i(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=ti(this.userData),e}};var Za=class extends Ln.BufferGeometry{constructor(e,r=12,o={}){super();this.type="ShapeGeometry";this.windingRule=Xe.ODD;this.elementType=Pt.POLYGONS;this.polySize=3;this.vertexSize=2;this.strict=!0;this._shape=e,this._curveSegments=r,this._triangulationOptions=Object.assign({windingRule:Xe.ODD,elementType:Pt.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,d;for(let h=0,m=n.length/2;h<m;h++){let y=h*2,g=n[y+0],b=n[y+1];if(u!==void 0&&g!==u&&(l=!1),d!==void 0&&b!==d&&(c=!1),u=g,d=b,!l&&!c)break}if(!l&&!c)try{s=fo({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=Bl}let p=s?.vertexCount??1,f=s?.elementCount??1;if(this._positionAttribute=new Ln.BufferAttribute(new Float32Array(p*3),3),this._normalAttribute=new Ln.BufferAttribute(new Float32Array(p*3),3),this._uvAttribute=new Ln.BufferAttribute(new Float32Array(p*2),2),this._indexAttribute=new Ln.BufferAttribute(new Uint32Array(f*3),1),s){let h=1/0,m=-1/0,y=1/0,g=-1/0;for(let P=0,S=p;P<S;P++){let T=P*2,A=s.vertices[T+0],x=s.vertices[T+1];A<h&&(h=A),A>m&&(m=A),x<y&&(y=x),x>g&&(g=x)}let b=m-h,w=g-y;for(let P=0,S=p;P<S;P++){let T=P*2,A=s.vertices[T+0],x=s.vertices[T+1],N=(A-h)/b,E=(x-y)/w;this._positionAttribute.setXYZ(P,A,x,0),this._normalAttribute.setXYZ(P,0,0,1),this._uvAttribute.setXY(P,N,E)}for(let P=0,S=f;P<S;P++){let T=P*3,A=s.elements[T+0],x=s.elements[T+1],N=s.elements[T+2];this._indexAttribute.setX(T+0,A),this._indexAttribute.setX(T+1,x),this._indexAttribute.setX(T+2,N)}}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 Za(this._shape,this._curveSegments);return e.userData=ti(this.userData),e}};var Ja=class extends $i{constructor(e,r,o=0,n=12,a=3,s=Xe.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 Ja(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=ti(this.userData),e}};var Tr=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:Xe.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 Ye?(a.width!==r||a.height!==o)&&a.applySize(r,o):a=new Ye(r,o).fromJSON(a),i.parameters?.roundness!==void 0&&i.parameters?.roundness>0&&a.update());let l=a??new Ye(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 Za(i.shape,o,{windingRule:a}):s=new Ja(i.shape,t,e,o,r,a),Object.assign(s,{userData:{...i,type:"VectorGeometry"}})}};var mo=require("three"),qx=Math.PI*2,ts=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=mo.MathUtils.clamp(e.angle,0,360),{shape:i.shape&&i.shape instanceof Ye?i.shape:new Ye,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,d=e*.5,p=sI(c,u,d,o*Math.PI/180,r,n);c.isClosed=!0,c.update();let f;return o===0?(f=new mo.BufferGeometry,f.setAttribute("position",new mo.Float32BufferAttribute([],3))):f=Tr.create({shape:c,parameters:{subdivisions:p,depth:a,extrudeBevelSize:s,extrudeBevelSegments:l}}),Object.assign(f,{userData:{...i,type:"EllipseGeometry"}})}};function sI(i,t,e,r,o,n){if(r>=qx)return o>30||o%4===0?(cI(i,t,e,n),Math.round(o/4)):Wx(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=Fx({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?lI(i,a.x,a.y,c,o,t,e,n):Wx(i,r,o,t,e,n)}function lI(i,t,e,r,o,n,a,s){let l=Math.round(o/r.length);i.addPoint(es(t,e));for(let c=0,u=r.length;c<u;c++){let d=r[c],p=i.points[c],f=es(d.x,d.y);p.controls[1].position.set(d.x1,d.y1),f.controls[0].position.set(d.x2,d.y2),i.addPoint(f)}return s>0?$x(i,n,a,s):i.addPoint(es(0,0)),l}function Wx(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(es(c,u))}return t<qx?n>0?$x(i,r,o,n):i.addPoint(es(0,0)):(i.removePoint(i.points[i.points.length-1]),n>0&&Xx(i,r,o,n)),1}function cI(i,t,e,r=0,o=0,n=0){let a=.5522847498,s=t*a,l=e*a;i.addPoint(Qu(o-t,n,o-t,n-l,o-t,n+l)),i.addPoint(Qu(o,n+e,o-s,n+e,o+s,n+e)),i.addPoint(Qu(o+t,n,o+t,n+l,o+t,n-l)),i.addPoint(Qu(o,n-e,o+s,n-e,o-s,n-e)),r>0&&Xx(i,t,e,r)}function es(i,t){return new po(mo.MathUtils.generateUUID(),new mo.Vector2(i,t))}function Qu(i,t,e,r,o,n){let a=es(i,t);return a.controls[0].position.set(e,r),a.controls[1].position.set(o,n),a}function $x(i,t,e,r){Yx(i,t,e,r).forEach(n=>i.addPoint(n))}function Xx(i,t,e,r){let o=Yx(i,t,e,r),n=new Ye;o.forEach(a=>n.addPoint(a)),n.isClosed=!0,i.shapeHoles.push(n)}function Yx(i,t,e,r){let o=r*t/100,n=o*(Math.abs(e)/Math.abs(t)),a=new mo.Vector2(o/t,n/e),s=i.points.map(l=>{let c=l.clone();return c.uuid=mo.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 yo=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,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:d}=i.parameters,p=new Vl(!1,t,e,r,o,n,a,s,l,c,u,d);return Object.assign(p,{userData:{...i,type:"HelixGeometry"}})}},Uf=new yo.Uint32BufferAttribute([0,0,0],1),Vl=class extends yo.BufferGeometry{constructor(t=!0,e=1,r=1,o=1,n=1,a=1,s=1,l=1,c=1,u=1,d=1,p=1){if(super(),a===0)return;let f=t&&a===1;f&&(p=0),d>100&&(d=100),d===0&&(p=0);let h=()=>new yo.Vector3,m=new yo.Vector3,y=h(),g=h(),b=h(),w,P,S,T,A,x,N,E,M=h(),D=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/p,Z=.01,Q=Math.min((1-d/100)*l,l-Z),$=l-Q,pe=0,le=2,ie=p*le+le,ue=Y*ie/le,ae=ue+Y*W,ge=Math.max(0,Y*(W+ie)),[me,ye,Se]=[3,3,2].map(bt=>Array(ge*bt).fill(0)),xe=[],C=n-l;function ne(bt,at){let io=Math.PI/2;x=at*ee,E=2*Math.PI*(x%F)/F+io,x+=te,N=Math.sin(E)*C,A=Math.cos(E)*C,t?bt.set(A,N,x):bt.set(A,x,N)}ne(m,-1e-10),ne(y,0),M.copy(m),ne(m,1);let ze=m.distanceTo(y),He=f?0:$+Q,Fe=ze*H+2*He,Ae=Q,Ut=Fe-He;for(let bt=0;bt<=H;bt++){ne(g,bt),q.subVectors(g,M).normalize(),M.copy(g),U.copy(g).setComponent(+t+1,0).normalize(),B.crossVectors(q,U).normalize();let at=bt===0,io=bt===H,bp=at?3*Math.PI/2:K,vp=at?Ae:Ut,Pc=at?Y:ae,bn=at?0:ge-Y,Ct=q.clone().multiplyScalar(at?-$:$).add(g),Sp=q.clone().multiplyScalar(at?-1:1).normalize();for(let jr=0;jr<Y;jr++){let nl=jr*re;if(D.addVectors(m.copy(U).multiplyScalar(l*Math.cos(nl)),y.copy(B).multiplyScalar(l*Math.sin(nl))),_.copy(D).normalize(),at||io){f||(pe=bn+jr,[0,1,2].forEach(pr=>{me[pe*3+pr]=Ct.getComponent(pr),ye[pe*3+pr]=Sp.getComponent(pr)}),Se[pe*2]=+io,Se[pe*2+1]=jr/u),y.copy(_).multiplyScalar(Q),b.addVectors(g,y);for(let pr=0;pr<p;pr++){let vn=pr*K+bp;R.addVectors(m.copy(q).multiplyScalar($*Math.sin(vn)),y.copy(_).multiplyScalar($*Math.cos(vn))),V.copy(R).normalize(),y.addVectors(b,R),R.normalize(),pe=Pc+pr*Y+jr,[0,1,2].forEach(Jn=>{me[pe*3+Jn]=y.getComponent(Jn),ye[pe*3+Jn]=V.getComponent(Jn)});let Oc=+at+Math.sin(vn);Se[pe*2]=(vp+$*Oc)/Fe,Se[pe*2+1]=jr/u}}y.addVectors(g,D),pe=ue+bt*Y+jr,[0,1,2].forEach(pr=>{me[pe*3+pr]=y.getComponent(pr),ye[pe*3+pr]=_.getComponent(pr)}),Se[pe*2]=(He+bt*ze)/Fe,Se[pe*2+1]=jr/u}}let Re=W+2*p+le,Ft=1,[kt,xn]=[+f,Re-1];for(let bt=kt;bt<=xn-1;bt++){let at=f&&bt===xn-1;for(let io=0;io<Y-1;io++)w=bt*Y+io,P=w+1,S=(at?io:w)+Y,T=(at?io+1:P)+Y,bt===0?xe.push(P,T,S):bt===Re-2?xe.push(w,P,S):xe.push(w,P,S,P,T,S)}this.setIndex(xe),this.setAttribute("position",new yo.Float32BufferAttribute(me,3)),this.setAttribute("normal",new yo.Float32BufferAttribute(ye,3)),this.setAttribute("uv",new yo.Float32BufferAttribute(Se,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,d=u===e;for(let p=0;p<t.radialSegments;p++)n=u*r+p,a=n+1,s=(d?p:n)+r,l=(d?p+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,Uf.array=o,Uf.count=o.length,Uf}};var Qx=require("three");var Zx=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 zl(t*.5,n,a):new Qx.IcosahedronGeometry(t*.5,o);return s.scale(1,e/t,r/t),Object.assign(s,{userData:{...i,type:"IcosahedronGeometry"}})}},zl=class extends Wi{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 zl(t.radius,t.corner,t.cornerSides)}};var Zu=require("three"),Jx=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 Zu.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 Zu.LatheGeometry(o.extractPoints(r).shape,e);return n.rotateZ(Math.PI),Object.assign(n,{userData:{...i,type:"LatheGeometry"}})}};var Vo=require("three");var pi=require("three");var he=require("three"),Bo=new he.Matrix4,kf=new he.Object3D,Ju=new he.Vector3,Xi=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 Bo.makeRotationX(t),this.applyMatrix4(Bo),this}rotateY(t){return Bo.makeRotationY(t),this.applyMatrix4(Bo),this}rotateZ(t){return Bo.makeRotationZ(t),this.applyMatrix4(Bo),this}translate(t,e,r){return Bo.makeTranslation(t,e,r),this.applyMatrix4(Bo),this}scale(t,e,r){return Bo.makeScale(t,e,r),this.applyMatrix4(Bo),this}lookAt(t){return kf.lookAt(t),kf.updateMatrix(),this.applyMatrix4(kf.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 p=0;p<n.count;p++)e.vertices.push(new he.Vector3().fromBufferAttribute(n,p)),s!==void 0&&e.colors.push(new he.Color().fromBufferAttribute(s,p));function u(p,f,h,m){let y=s===void 0?[]:[e.colors[p].clone(),e.colors[f].clone(),e.colors[h].clone()],g=a===void 0?[]:[new he.Vector3().fromBufferAttribute(a,p),new he.Vector3().fromBufferAttribute(a,f),new he.Vector3().fromBufferAttribute(a,h)],b=new rs(p,f,h,g,y,m);e.faces.push(b),l!==void 0&&e.faceVertexUvs[0].push([new he.Vector2().fromBufferAttribute(l,p),new he.Vector2().fromBufferAttribute(l,f),new he.Vector2().fromBufferAttribute(l,h)]),c!==void 0&&e.faceVertexUvs[1].push([new he.Vector2().fromBufferAttribute(c,p),new he.Vector2().fromBufferAttribute(c,f),new he.Vector2().fromBufferAttribute(c,h)])}let d=t.groups;if(d.length>0)for(let p=0;p<d.length;p++){let f=d[p],h=f.start,m=f.count;for(let y=h,g=h+m;y<g;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 p=0;p<r.count;p+=3)u(r.getX(p),r.getX(p+1),r.getX(p+2));else for(let p=0;p<n.count;p+=3)u(p,p+1,p+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(Ju).negate(),this.translate(Ju.x,Ju.y,Ju.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 Xi;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,d=t.colors;e!==void 0&&(o=new he.Matrix3().getNormalMatrix(e));for(let p=0,f=s.length;p<f;p++){let m=s[p].clone();e!==void 0&&m.applyMatrix4(e),a.push(m)}for(let p=0,f=d.length;p<f;p++)u.push(d[p].clone());for(let p=0,f=c.length;p<f;p++){let h=c[p],m,y,g=h.vertexNormals,b=h.vertexColors,w=new rs(h.a+n,h.b+n,h.c+n);w.normal.copy(h.normal),o!==void 0&&w.normal.applyMatrix3(o).normalize();for(let P=0,S=g.length;P<S;P++)m=g[P].clone(),o!==void 0&&m.applyMatrix3(o).normalize(),w.vertexNormals.push(m);w.color.copy(h.color);for(let P=0,S=b.length;P<S;P++)y=b[P],w.vertexColors.push(y.clone());w.materialIndex=h.materialIndex+r,l.push(w)}for(let p=0,f=t.faceVertexUvs.length;p<f;p++){let h=t.faceVertexUvs[p];this.faceVertexUvs[p]===void 0&&(this.faceVertexUvs[p]=[]);for(let m=0,y=h.length;m<y;m++){let g=h[m],b=[];for(let w=0,P=g.length;w<P;w++)b.push(g[w].clone());this.faceVertexUvs[p].push(b)}}}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],d=Math.round(u.x*n)+"_"+Math.round(u.y*n)+"_"+Math.round(u.z*n);e[d]===void 0?(e[d]=l,r.push(this.vertices[l]),o[l]=r.length-1):o[l]=o[e[d]]}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 d=[u.a,u.b,u.c];for(let p=0;p<3;p++)if(d[p]===d[(p+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,d=this.faceVertexUvs.length;u<d;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,g=!1,b=this.faceVertexUvs[0][h]!==void 0,w=m.normal.length()>0,P=m.vertexNormals.length>0,S=m.color.r!==1||m.color.g!==1||m.color.b!==1,T=m.vertexColors.length>0,A=0;if(A=u(A,0,0),A=u(A,1,y),A=u(A,2,g),A=u(A,3,b),A=u(A,4,w),A=u(A,5,P),A=u(A,6,S),A=u(A,7,T),r.push(A),r.push(m.a,m.b,m.c),r.push(m.materialIndex),b){let x=this.faceVertexUvs[0][h];r.push(f(x[0]),f(x[1]),f(x[2]))}if(w&&r.push(d(m.normal)),P){let x=m.vertexNormals;r.push(d(x[0]),d(x[1]),d(x[2]))}if(S&&r.push(p(m.color)),T){let x=m.vertexColors;r.push(p(x[0]),p(x[1]),p(x[2]))}}function u(h,m,y){return y?h|1<<m:h&~(1<<m)}function d(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 p(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 Xi().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 p=0,f=e.length;p<f;p++)this.vertices.push(e[p].clone());let r=t.colors;for(let p=0,f=r.length;p<f;p++)this.colors.push(r[p].clone());let o=t.faces;for(let p=0,f=o.length;p<f;p++)this.faces.push(o[p].clone());for(let p=0,f=t.faceVertexUvs.length;p<f;p++){let h=t.faceVertexUvs[p];this.faceVertexUvs[p]===void 0&&(this.faceVertexUvs[p]=[]);for(let m=0,y=h.length;m<y;m++){let g=h[m],b=[];for(let w=0,P=g.length;w<P;w++){let S=g[w];b.push(S.clone())}this.faceVertexUvs[p].push(b)}}let n=t.morphTargets;for(let p=0,f=n.length;p<f;p++){let h={};if(h.name=n[p].name,n[p].vertices!==void 0){h.vertices=[];for(let m=0,y=n[p].vertices.length;m<y;m++)h.vertices.push(n[p].vertices[m].clone())}if(n[p].normals!==void 0){h.normals=[];for(let m=0,y=n[p].normals.length;m<y;m++)h.normals.push(n[p].normals[m].clone())}this.morphTargets.push(h)}let a=t.morphNormals;for(let p=0,f=a.length;p<f;p++){let h={};if(a[p].vertexNormals!==void 0){h.vertexNormals=[];for(let m=0,y=a[p].vertexNormals.length;m<y;m++){let g=a[p].vertexNormals[m],b={};b.a=g.a.clone(),b.b=g.b.clone(),b.c=g.c.clone(),h.vertexNormals.push(b)}}if(a[p].faceNormals!==void 0){h.faceNormals=[];for(let m=0,y=a[p].faceNormals.length;m<y;m++)h.faceNormals.push(a[p].faceNormals[m].clone())}this.morphNormals.push(h)}let s=t.skinWeights;for(let p=0,f=s.length;p<f;p++)this.skinWeights.push(s[p].clone());let l=t.skinIndices;for(let p=0,f=l.length;p<f;p++)this.skinIndices.push(l[p].clone());let c=t.lineDistances;for(let p=0,f=c.length;p<f;p++)this.lineDistances.push(c[p]);let u=t.boundingBox;u!==null&&(this.boundingBox=u.clone());let d=t.boundingSphere;return d!==null&&(this.boundingSphere=d.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 Hf().fromGeometry(this),e=new he.BufferGeometry,r=new Float32Array(t.vertices.length*3);if(e.setAttribute("position",ed.call(new he.BufferAttribute(r,3),t.vertices)),t.normals.length>0){let o=new Float32Array(t.normals.length*3);e.setAttribute("normal",ed.call(new he.BufferAttribute(o,3),t.normals))}if(t.colors.length>0){let o=new Float32Array(t.colors.length*3);e.setAttribute("color",eb.call(new he.BufferAttribute(o,3),t.colors))}if(t.uvs.length>0){let o=new Float32Array(t.uvs.length*2);e.setAttribute("uv",tb.call(new he.BufferAttribute(o,2),t.uvs))}if(t.uvs2.length>0){let o=new Float32Array(t.uvs2.length*2);e.setAttribute("uv2",tb.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(ed.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",rb.call(o,t.skinIndices))}if(t.skinWeights.length>0){let o=new he.Float32BufferAttribute(t.skinWeights.length*4,4);e.setAttribute("skinWeight",rb.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",ed.call(o,r.vertices)),e.setAttribute("color",eb.call(n,r.colors)),r.lineDistances&&r.lineDistances.length===r.vertices.length){let a=new he.Float32BufferAttribute(r.lineDistances.length,1);e.setAttribute("lineDistance",uI.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}};Xi.prototype.isGeometry=!0;var Hf=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 g=0;g<l;g++)c[g]={name:s[g].name,data:[]};this.morphTargets.position=c}let u=t.morphNormals,d=u.length,p;if(d>0){p=[];for(let g=0;g<d;g++)p[g]={name:u[g].name,data:[]};this.morphTargets.normal=p}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 g=0;g<e.length;g++){let b=e[g];this.vertices.push(r[b.a],r[b.b],r[b.c]);let w=b.vertexNormals;if(w.length===3)this.normals.push(w[0],w[1],w[2]);else{let S=b.normal;this.normals.push(S,S,S)}let P=b.vertexColors;if(P.length===3)this.colors.push(P[0],P[1],P[2]);else{let S=b.color;this.colors.push(S,S,S)}if(n===!0){let S=o[0][g];S!==void 0?this.uvs.push(S[0],S[1],S[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv ",g),this.uvs.push(new he.Vector2,new he.Vector2,new he.Vector2))}if(a===!0){let S=o[1][g];S!==void 0?this.uvs2.push(S[0],S[1],S[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv2 ",g),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[b.a],T[b.b],T[b.c])}for(let S=0;S<d;S++){let T=u[S].vertexNormals[g];p[S].data.push(T.a,T.b,T.c)}m&&this.skinIndices.push(f[b.a],f[b.b],f[b.c]),y&&this.skinWeights.push(h[b.a],h[b.b],h[b.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}},rs=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 uI(i){return this.array.set(i),this}function eb(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 tb(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 ed(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 rb(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 dI=["a","b","c"];function pI(i,t){switch(t){case"c":return i.c;case"b":return i.b;case"a":default:return i.a}}function Wf(i,t,e){let r=Math.min(i,t),o=Math.max(i,t),n=r+"_"+o;return e.get(n)}function qf(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],d=e[s];c={a:u,b:d,newEdge:null,faces:[]},r.set(l,c)}c.faces.push(o),n[i].edges.push(c),n[t].edges.push(c)}function fI(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],qf(a.a,a.b,i,r,a,e),qf(a.b,a.c,i,r,a,e),qf(a.c,a.a,i,r,a,e)}function td(i,t,e,r,o){i.push(new rs(t,e,r,void 0,void 0,o))}function os(i,t){return Math.abs(t-i)/2+Math.min(i,t)}function rd(i,t,e,r){i.push([t.clone(),e.clone(),r.clone()])}var od=class{constructor(t=1){this.subdivisions=t}modify(t){t instanceof pi.BufferGeometry?t=new Xi().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 pi.Vector3,r,o,n,a,s,l=t.vertices,c=t.faces,u=t.faceVertexUvs[0],d=u!==void 0&&u.length>0,p=[],f=new Map;fI(l,c,p,f);let h=[],m,y,g,b,w,P,S;for(let Z of Array.from(f.keys())){for(y=f.get(Z),g=new pi.Vector3,w=3/8,P=1/8,S=y.faces.length,S!=2&&(w=.5,P=0,S!=1),g.addVectors(y.a,y.b).multiplyScalar(w),e.set(0,0,0),a=0;a<S;a++){for(b=y.faces[a],s=0;s<3&&(m=l[pI(b,dI[s])],!(m!==y.a&&m!==y.b));s++);m&&e.add(m)}e.multiplyScalar(P),g.add(e),y.newEdge=h.length,h.push(g)}let T,A,x,N,E,M,D,_=[];for(o=0,n=l.length;o<n;o++){for(M=l[o],E=p[o].edges,r=E.length,r==3?T=3/16:r>3&&(T=3/(8*r)),A=1-r*Number(T),x=T,r<=2&&(r==2?(A=3/4,x=1/8):r==1||r==0),D=M.clone().multiplyScalar(A),e.set(0,0,0),a=0;a<r;a++)N=E[a],m=N.a!==M?N.a:N.b,e.add(m);e.multiplyScalar(Number(x)),D.add(e),_.push(D)}let R=_.concat(h),V=_.length,U,B,q,j=[],F=[],H,W,ee,te,Y=new pi.Vector2,re=new pi.Vector2,K=new pi.Vector2;for(o=0,n=c.length;o<n;o++)b=c[o],U=Number(Wf(b.a,b.b,f).newEdge)+V,B=Number(Wf(b.b,b.c,f).newEdge)+V,q=Number(Wf(b.c,b.a,f).newEdge)+V,td(j,U,B,q,b.materialIndex),td(j,b.a,U,q,b.materialIndex),td(j,b.b,B,U,b.materialIndex),td(j,b.c,q,B,b.materialIndex),d&&(H=u[o],W=H[0],ee=H[1],te=H[2],Y.set(os(W.x,ee.x),os(W.y,ee.y)),re.set(os(ee.x,te.x),os(ee.y,te.y)),K.set(os(W.x,te.x),os(W.y,te.y)),rd(F,Y,re,K),rd(F,W,Y,K),rd(F,ee,re,Y),rd(F,te,K,re));t.vertices=R,t.faces=j,d&&(t.faceVertexUvs[0]=F)}};var $t=new Vo.Vector3,ob=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=i.geometry??t?.geometry??new Vo.BufferGeometry().copy(new Vo.BoxGeometry(100,100,100)),r;t===void 0?(e.computeBoundingBox(),e.boundingBox.getSize($t),r={width:$t.x,height:$t.y,depth:$t.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 Vo.BufferGeometry().copy(new Vo.BoxGeometry(100,100,100)),a=n.userData.parameters;a===void 0?(n.computeBoundingBox(),n.boundingBox.getSize($t)):$t.set(a.width,a.height,a.depth),(t!==$t.x||e!==$t.y||r!==$t.z)&&n.scale($t.x===0?1:t/$t.x,$t.y===0?1:e/$t.y,$t.z===0?1:r/$t.z);let s=n.originalGeometry;try{o>0?(s===void 0||a?.subdivisions!==o)&&(s===void 0&&(s=n),n=new od(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 Vo.BufferGeometryLoader(e).load(i,o=>{let n=this.normalizeInputs({geometry:o});o.boundingBox.getSize($t);let a=100/$t.x;Object.assign(n.parameters,{width:100,height:$t.y*a,depth:$t.z*a}),t(this.build(n))})}};var id=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 Ye?i.shape:new Ye,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,d=0,p=0,f=2*Math.PI/r;for(let m=0;m<r;m++){let y=f*m,g=d+Math.sin(y)*c,b=p+Math.cos(y)*u;l.addPoint(l.createPoint(g,b))}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=Tr.create({shape:l,parameters:{roundness:o,depth:n,extrudeBevelSize:a,extrudeBevelSegments:s}});return Object.assign(h,{userData:{...i,type:"PolygonGeometry"}})}};var qe=require("three"),ib=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 Xf(t*.5,e,o,n,a,s,l);return c.scale(1,1,r/t),Object.assign(c,{userData:{...i,type:"PyramidGeometry"}})}};function Gl(i,t,e){e.x=i.x*t.x,e.y=i.y,e.z=i.x*t.y}function $f(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 hI(i,t,e){let r=i.clone().sub(t),o=e.clone().sub(t);return r.projectOnVector(o),r.add(t)}var Xf=class extends qe.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=[],d=[],p=0,f=e/2,h=Math.PI/r,m=t*Math.cos(Math.PI/r),y=2*Math.PI/r,g=(r-2)*Math.PI/r,b=Math.PI-g,w=new qe.Vector3(0,-f,0),P=new qe.Vector3(0,f,0),S=new qe.Vector2(t,-f),T=new qe.Vector2(m,-f),A=new qe.Vector2(0,P.y).sub(T),x=new qe.Vector2(0,P.y).sub(S),N=new qe.Vector2(A.y,-A.x).normalize(),E=new qe.Vector2(x.y,-x.x).normalize(),D=t*Math.cos(Math.PI/r)*Math.tan((Math.PI-A.angle())/2)-1e-8;a=Math.min(a,D);let _;{let F=new qe.Vector3(N.x,N.y,0),H=new qe.Vector3(Math.cos(y)*F.x,F.y,Math.sin(y)*F.x);_=F.angleTo(H)}let R=a/Math.tan((Math.PI-A.angle())/2),V=a/Math.tan((Math.PI-_)/2),U=new qe.Vector3;if(!n){c.push(w.x,w.y,w.z),u.push(0,-1,0),d.push(0,0);let F=p++,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 qe.Vector2(Math.sin(Y),Math.cos(Y));Gl(W,re,U),c.push(U.x,U.y,U.z),u.push(0,-1,0),d.push(0,0),H.push(p++)}for(let te=0;te<H.length;te++)l.push(H[te],F,H[(te+1)%H.length])}let B=[];{let F=new qe.Vector3,H=new qe.Vector3,W=new qe.Vector3,ee=new qe.Vector3,te=new qe.Vector3,Y=new qe.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 qe.Vector2(Math.sin(K),Math.cos(K)),pe=new qe.Vector2(Math.sin(Z),Math.cos(Z)),le=new qe.Vector2(Math.sin(Q),Math.cos(Q));Gl(S,$,H),Gl(S,le,W),Gl(N,pe,F),$f(P,H,W,V,V,ee),c.push(ee.x,ee.y,ee.z),$f(H,P,W,V,R,te),c.push(te.x,te.y,te.z),$f(W,H,P,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),d.push(0,0),d.push(0,0),d.push(0,0);let ie=p++,ue=p++,ae=p++;if(l.push(ie,ue,ae),a>0){{let ye=H.clone().add(W).multiplyScalar(.5),Se=P.clone().sub(ye).normalize(),C=w.clone().sub(ye).normalize().add(Se).normalize().multiplyScalar(-1),ne=Y.clone().sub(te);q(ye,ne,C,A.angle())}let ge,me;{let ye=new qe.Vector3;Gl(E,le,ye);let Se=Y.clone().add(ee).multiplyScalar(.5);Se=hI(Se,W,P);let xe=Y.clone().sub(ee);[ge,me]=q(Se,xe,ye,_,ee.y)}{let ye=ge,Se=ye.clone().setY(0).normalize(),xe=new qe.Vector3(0,-1,0),C=Se.clone().cross(xe);j(ye,Se,xe,C)}B.concat(me);{let ye=A.angle(),Se=Math.PI-ye,xe=P.clone();xe.y-=a/Math.sin(ye-Math.PI/2);let C=new qe.Vector3,ne=[];for(let He=0;He<s;He++){let Fe=[],Ae=Math.PI/2-Se*He/s,Ut=Math.cos(Ae),Re=Math.sin(Ae),Ft=Z;for(let kt=0;kt<=He;kt++){let xn=Math.cos(Ft),bt=Math.sin(Ft);F.x=Ut*bt,F.y=Re,F.z=Ut*xn,C.copy(xe).addScaledVector(F,a),c.push(C.x,C.y,C.z),u.push(F.x,F.y,F.z),d.push(0,0),Fe.push(p++),Ft+=Math.PI*2/He/r}ne.push(Fe)}me.reverse(),ne.push(me);let ze=ne.length-1;for(let He=0;He<ze;He++){let Fe=ne[He],Ae=ne[He+1],Ut=Fe.length-1;l.push(Ae[1],Fe[0],Ae[0]);for(let Re=1;Re<=Ut;Re++)l.push(Fe[Re],Fe[Re-1],Ae[Re]),l.push(Ae[Re+1],Fe[Re],Ae[Re])}}}}}this.setIndex(l),this.setAttribute("position",new qe.Float32BufferAttribute(c,3)),this.setAttribute("normal",new qe.Float32BufferAttribute(u,3)),this.setAttribute("uv",new qe.Float32BufferAttribute(d,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 qe.Vector3,Q=new qe.Vector3,$=1,pe=p,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),d.push(0,0),ae===0&&le.push(p),p++}}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=x.angle()-te,re=[],K=new qe.Vector3,Z=new qe.Vector3;for(let $=0;$<=s;$++){let pe=[],le=$/s;for(let ie=0;ie<=$;ie++){let ae=(($?ie/$:0)-.5)*b,ge=Math.cos(ae),me=Math.sin(ae),ye=Math.atan(Math.tan(Y)*ge),Se=(te+ye)*le,xe=Math.cos(Se),C=Math.sin(Se);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),d.push(0,0),pe.push(p++)}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 is=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 Ye?i.shape:new Ye,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},d={x:c.x,y:c.y};function p(P,S,T){return S>e&&T>r?Math.min(P*e/S,P*r/T):S>e?P*e/S:T>r?P*r/T:P}let f=[];f[0]=o[0]===0?0:p(o[0],o[0]+o[3],o[0]+o[1]),f[1]=o[1]===0?0:p(o[1],o[1]+o[2],o[1]+o[0]),f[2]=o[2]===0?0:p(o[2],o[2]+o[1],o[2]+o[3]),f[3]=o[3]===0?0:p(o[3],o[3]+o[0],o[3]+o[2]);let h=u.x,m=d.x,y=d.y,g=u.y;t.addPoint(t.createPoint(h,y)),t.addPoint(t.createPoint(m,y)),t.addPoint(t.createPoint(m,g)),t.addPoint(t.createPoint(h,g)),t.isClosed=!0;let b=!0;for(let P=0,S=t.points.length;P<S;P++)t.points[P].roundness=f[P],P>0&&f[P]!==f[P-1]&&(b=!1);b&&(t.roundness=f[0]),t.useCubicForRoundedCorners=n!==1,t.update();let w=Tr.create({shape:t,parameters:{depth:a,extrudeBevelSize:s,extrudeBevelSegments:l}});return Object.assign(w,{userData:{...i,type:"RectangleGeometry"}})}};var fi=require("three"),nb=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=fi.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 fi.BufferGeometry,u.setAttribute("position",new fi.Float32BufferAttribute([],3))):u=new fi.SphereGeometry(.5*t,o,n,a,s,l,c*fi.MathUtils.DEG2RAD),u.scale(1,e/t,r/t),Object.assign(u,{userData:{...i,type:"SphereGeometry"}})}};var ab=require("three"),sb=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 ab.PlaneGeometry(t,e,r,o);return n.scale(1,1,1),Object.assign(n,{userData:{...i,type:"PlaneGeometry"}})}};var Yi=require("three"),lb=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 Yf(t,e,r,o,n,a);return Object.assign(s,{userData:{...i,type:"BackdropGeometry"}})}},Yf=class extends Yi.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 d=[],p=Math.PI/2,f=(Z=0,Q=0,$=0)=>new Yi.Vector3(Z,Q,$),h=f(),m=f(),[y,g,b]=[e/2,t/2,r/2],w=-g,P=+g,[S,T,A]=[f(w,-y,+b),f(w,-y,-b),f(w,+y,-b)],x=(Z,Q=!1)=>Math.sin(Z-Math.PI/(1+ +Q)),N=(Z,Q=!1)=>Math.cos(Z-Math.PI/(1+ +Q));A.y=Math.sin(o)*e-y;let E=Math.cos(o)*e-b,M=S.z-u;o<=p?(A.z=Math.min(E,M),A.z==M&&(A.y-=(E-M)/Math.tan(p-o))):T.z=Math.min(T.z-E-b,S.z-u),h.subVectors(S,T),m.subVectors(A,T);let D=Math.min(h.length(),m.length())*n/100,_=D*Math.tan(o/2),R=D/Math.cos(o/2),V=h.clone().normalize().add(m.normalize()).setLength(R).add(T);h.set(0,x(o,!0),N(o,!0)),d.push([A,h.clone()]);let U=(Math.PI-o)/a;for(let Z=0;Z<=a;Z++){let Q=p+o+Z*U;h.set(0,Math.sin(Q)*_,Math.cos(Q)*_),h.add(V),m.set(0,x(Q),N(Q)),d.push([h.clone(),m.clone()])}d.push([S,f(0,1,0)]);let B=Math.sin(U/2)*_*2,q=d.length-1,j=d[0][0].distanceTo(d[1][0]),F=d[q-1][0].distanceTo(d[q][0]),H=j+B*a+F;d[0].push(1);for(let Z=0;Z<=a;Z++)d[Z+1].push(1-(j+Z*B)/H);d[q].push(0);let[W,ee,te]=d[0],Y,re,K;for(let Z=1;Z<d.length;Z++)[Y,re,K]=d[Z],s.push(w,W.y,W.z,w,Y.y,Y.z,P,W.y,W.z,P,W.y,W.z,w,Y.y,Y.z,P,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 Yi.Float32BufferAttribute(s,3)),this.setAttribute("normal",new Yi.Float32BufferAttribute(l,3)),this.setAttribute("uv",new Yi.Float32BufferAttribute(c,2))}};var nd=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 Ye?i.shape:new Ye,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,d=t*.5,p=e*.5,f=0,h=0,m=a*Math.PI/360/o,y=Math.PI/2*3*-1,g=d*r/100,b=p*r/100;if(o===3&&r===50){m=2*Math.PI/o;for(let P=0;P<o;P++){let S=m*P,T=f+Math.sin(S)*d,A=h+Math.cos(S)*p;u.addPoint(u.createPoint(T,A))}}else for(let P=0;P<o;P++){let S=f+Math.cos(y)*d,T=h+Math.sin(y)*p;u.addPoint(u.createPoint(S,T)),y+=m,S=f+Math.cos(y)*g,T=h+Math.sin(y)*b,P<=o,u.addPoint(u.createPoint(S,T)),y+=m}u.isClosed=!0;for(let P=0,S=u.points.length;P<S;P++)u.points[P].roundness=n;u.roundness=n,u.update();let w=Tr.create({shape:u,parameters:{roundness:n,depth:s,extrudeBevelSize:l,extrudeBevelSegments:c}});return Object.assign(w,{userData:{...i,type:"StarGeometry"}})}};var cb=require("three"),ub=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 cb.PlaneGeometry(t,e);return Object.assign(r,{userData:{...i,type:"TextFrameGeometry"}})}};var ns=require("three");var db=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=mI(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 mI(i,t,e,r,o,n,a,s,l,c,u){[t,e]=[e,t],a=t/2;let d=ns.MathUtils.clamp(o/360,0,1);if(d===0){let p=new ns.BufferGeometry;return p.setAttribute("position",new ns.Float32BufferAttribute([],3)),p}return d===1&&(c=0),new Vl(!0,i,t,e,r,d,n,a,s,l,c,u)}var pb=require("three"),fb=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 pb.TorusKnotGeometry(s,e,r,o,n,a);return Object.assign(l,{userData:{...i,type:"TorusKnotGeometry"}})}};var hb=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 Ye?i.shape:new Ye,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 p=0,f=l.points.length;p<f;p++)l.points[p].roundness=r;l.roundness=r,l.update();let d=Tr.create({shape:l,parameters:{roundness:r,depth:o,extrudeBevelSize:n,extrudeBevelSegments:a}});return Object.assign(d,{userData:{...i,type:"TriangleGeometry"}})}};var Ee=require("three");function mb(i,t){let e=2*Math.PI;return(i%e+e)%e===(t%e+e)%e}function yI(i){return/^(rgba)?\(\s*(\d+),\s*(\d+),\s*(\d+)(?:,\s*(\d+(?:\.\d+)?))?\s*\)$/.exec(i.toLowerCase())}function gI(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 xI(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 bI(i){return i=Math.floor(i),{r:i>>16&255,g:i>>8&255,b:i&255}}function vI(i,t,e){return(i<<16)+(t<<8)+e}function SI(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 wI(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 yb={parseRgba:yI,hsvToRgb:gI,rgbToHsv:xI,hexToRgb:bI,rgbToHex:vI,rgbToHexString:SI,hexStringToRgb:wI};function hi(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 ad=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=hi();this._innerCallUserAPI=async t=>{this.emitter.emit("start",{userAPIId:this.id}),this.isLoading=!0,this.isLoading=!1;try{this.result=await AI(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=ru(this.prefetch,1e3,{trailing:!0})}_updateDebouncedCallUserAPI(){this._debouncedCallUserAPI=this.userAPI.debounce!==void 0&&this.userAPI.debounce>0?ru(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 dt.zoom(this.result,t)}catch(e){console.error(e)}}retrieveZoomedKeyValues(t){if(this.result){let e=t&&t.length?dt.zoom(this.result,t):this.result;if(CI(e))return Object.entries(e);if(TI(e))return e.map((r,o)=>[o.toString(),r]);throw OI(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 OI(i){return typeof i=="string"||typeof i=="number"||typeof i=="boolean"||i===null}function TI(i){return Array.isArray(i)}function CI(i){return typeof i=="object"&&i!==null}async function AI(i,t,e=new AbortController){let r,o=i.url,n=i.proxy?.enabled??!1,a;if(i.integration?.type==="OpenAI"){let l=Fl(i.integration.prompt===""?[]:JSON.parse(i.integration.prompt),t),c=i.integration.behavior===""?[]:Fl(JSON.parse(i.integration.behavior),t);a=`{
1
+ "use strict";var US=Object.create;var al=Object.defineProperty;var kS=Object.getOwnPropertyDescriptor;var HS=Object.getOwnPropertyNames;var WS=Object.getPrototypeOf,qS=Object.prototype.hasOwnProperty;var $S=(i,t,e)=>t in i?al(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e;var sl=(i,t)=>()=>(t||i((t={exports:{}}).exports,t),t.exports),xm=(i,t)=>{for(var e in t)al(i,e,{get:t[e],enumerable:!0})},bm=(i,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of HS(t))!qS.call(i,o)&&o!==e&&al(i,o,{get:()=>t[o],enumerable:!(r=kS(t,o))||r.enumerable});return i};var ll=(i,t,e)=>(e=i!=null?US(WS(i)):{},bm(t||!i||!i.__esModule?al(e,"default",{value:i,enumerable:!0}):e,i)),XS=i=>bm(al({},"__esModule",{value:!0}),i);var wn=(i,t,e)=>($S(i,typeof t!="symbol"?t+"":t,e),e);var sx=sl((vf,ax)=>{(function(i,t){typeof vf=="object"?ax.exports=t():typeof define=="function"&&define.amd?define(t):i.Alea=t()})(vf,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 hx=sl((qu,fx)=>{(function(i,t){typeof qu=="object"&&typeof fx<"u"?t(qu):typeof define=="function"&&define.amd?define(["exports"],t):t((i=typeof globalThis<"u"?globalThis:i||self).SVDJS={})})(qu,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,d,p,f,h,m,y,g,b=t[0].length,w=t.length;if(w<b)throw new TypeError("Invalid matrix: m < n");for(var P=[],S=[],T=[],A=e==="f"?w:b,x=m=p=0;x<w;x++)S[x]=new Array(A).fill(0);for(x=0;x<b;x++)T[x]=new Array(b).fill(0);var N,E=new Array(b).fill(0);for(x=0;x<w;x++)for(a=0;a<b;a++)S[x][a]=t[x][a];for(x=0;x<b;x++){for(P[x]=p,h=0,l=x+1,a=x;a<w;a++)h+=Math.pow(S[a][x],2);if(h<n)p=0;else for(f=(d=S[x][x])*(p=d<0?Math.sqrt(h):-Math.sqrt(h))-h,S[x][x]=d-p,a=l;a<b;a++){for(h=0,s=x;s<w;s++)h+=S[s][x]*S[s][a];for(d=h/f,s=x;s<w;s++)S[s][a]=S[s][a]+d*S[s][x]}for(E[x]=p,h=0,a=l;a<b;a++)h+=Math.pow(S[x][a],2);if(h<n)p=0;else{for(f=(d=S[x][x+1])*(p=d<0?Math.sqrt(h):-Math.sqrt(h))-h,S[x][x+1]=d-p,a=l;a<b;a++)P[a]=S[x][a]/f;for(a=l;a<w;a++){for(h=0,s=l;s<b;s++)h+=S[a][s]*S[x][s];for(s=l;s<b;s++)S[a][s]=S[a][s]+h*P[s]}}m<(y=Math.abs(E[x])+Math.abs(P[x]))&&(m=y)}if(r)for(x=b-1;0<=x;x--){if(p!==0){for(f=S[x][x+1]*p,a=l;a<b;a++)T[a][x]=S[x][a]/f;for(a=l;a<b;a++){for(h=0,s=l;s<b;s++)h+=S[x][s]*T[s][a];for(s=l;s<b;s++)T[s][a]=T[s][a]+h*T[s][x]}}for(a=l;a<b;a++)T[x][a]=0,T[a][x]=0;T[x][x]=1,p=P[x],l=x}if(e){if(e==="f")for(x=b;x<w;x++){for(a=b;a<w;a++)S[x][a]=0;S[x][x]=1}for(x=b-1;0<=x;x--){for(l=x+1,p=E[x],a=l;a<A;a++)S[x][a]=0;if(p!==0){for(f=S[x][x]*p,a=l;a<A;a++){for(h=0,s=l;s<w;s++)h+=S[s][x]*S[s][a];for(d=h/f,s=x;s<w;s++)S[s][a]=S[s][a]+d*S[s][x]}for(a=x;a<w;a++)S[a][x]=S[a][x]/p}else for(a=x;a<w;a++)S[a][x]=0;S[x][x]=S[x][x]+1}}for(o*=m,s=b-1;0<=s;s--)for(var M=0;M<50;M++){for(N=!1,l=s;0<=l;l--){if(Math.abs(P[l])<=o){N=!0;break}if(Math.abs(E[l-1])<=o)break}if(!N){for(u=0,c=l-(h=1),x=l;x<s+1&&(d=h*P[x],P[x]=u*P[x],!(Math.abs(d)<=o));x++)if(p=E[x],E[x]=Math.sqrt(d*d+p*p),u=p/(f=E[x]),h=-d/f,e)for(a=0;a<w;a++)y=S[a][c],g=S[a][x],S[a][c]=y*u+g*h,S[a][x]=-y*h+g*u}if(g=E[s],l===s){if(g<0&&(E[s]=-g,r))for(a=0;a<b;a++)T[a][s]=-T[a][s];break}for(m=E[l],d=(((y=E[s-1])-g)*(y+g)+((p=P[s-1])-(f=P[s]))*(p+f))/(2*f*y),p=Math.sqrt(d*d+1),d=((m-g)*(m+g)+f*(y/(d<0?d-p:d+p)-f))/m,x=l+(h=u=1);x<s+1;x++){if(p=P[x],y=E[x],f=h*p,p*=u,g=Math.sqrt(d*d+f*f),d=m*(u=d/(P[x-1]=g))+p*(h=f/g),p=-m*h+p*u,f=y*h,y*=u,r)for(a=0;a<b;a++)m=T[a][x-1],g=T[a][x],T[a][x-1]=m*u+g*h,T[a][x]=-m*h+g*u;if(g=Math.sqrt(d*d+f*f),d=(u=d/(E[x-1]=g))*p+(h=f/g)*y,m=-h*p+u*y,e)for(a=0;a<w;a++)y=S[a][x-1],g=S[a][x],S[a][x-1]=y*u+g*h,S[a][x]=-y*h+g*u}P[l]=0,P[s]=d,E[s]=m}for(x=0;x<b;x++)E[x]<o&&(E[x]=0);return{u:S,q:E,v:T}},i.VERSION="1.1.1",Object.defineProperty(i,"__esModule",{value:!0})})});var d1=sl((foe,u1)=>{"use strict";function aE(i,t){function e(){this.constructor=i}e.prototype=t.prototype,i.prototype=new e}function Yn(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,Yn)}aE(Yn,Error);Yn.buildMessage=function(i,t){var e={literal:function(c){return'"'+o(c.text)+'"'},class:function(c){var u="",d;for(d=0;d<c.parts.length;d++)u+=c.parts[d]instanceof Array?n(c.parts[d][0])+"-"+n(c.parts[d][1]):n(c.parts[d]);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),d,p;for(d=0;d<c.length;d++)u[d]=a(c[d]);if(u.sort(),u.length>0){for(d=1,p=1;d<u.length;d++)u[d-1]!==u[d]&&(u[p]=u[d],p++);u.length=p}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 sE(i,t){t=t!==void 0?t:{};var e={},r={svg_path:nl},o=nl,n=function(v){if(!v)return[];for(var O=[],L=0;L<v.length;L++)O=O.concat.apply(O,v[L]);var I=O[0];return I&&I.code=="m"&&(delete I.relative,I.code="M"),O},a=function(v,O){return jS(v,O)},s=/^[Mm]/,l=at(["M","m"],!1,!1),c=function(v,O,L){var I=ta(v,[O]);return L&&(I=I.concat(ta(v=="M"?"L":"l",L[1]))),I},u=/^[Zz]/,d=at(["Z","z"],!1,!1),p=function(){return ta("Z")},f=/^[Ll]/,h=at(["L","l"],!1,!1),m=function(v,O){return ta(v,O)},y=/^[Hh]/,g=at(["H","h"],!1,!1),b=function(v,O){return ta(v,O.map(function(L){return{x:L}}))},w=/^[Vv]/,P=at(["V","v"],!1,!1),S=function(v,O){return ta(v,O.map(function(L){return{y:L}}))},T=/^[Cc]/,A=at(["C","c"],!1,!1),x=function(v,O,L){return{x1:v.x,y1:v.y,x2:O.x,y2:O.y,x:L.x,y:L.y}},N=/^[Ss]/,E=at(["S","s"],!1,!1),M=function(v,O){return{x2:v.x,y2:v.y,x:O.x,y:O.y}},D=/^[Qq]/,_=at(["Q","q"],!1,!1),R=function(v,O){return{x1:v.x,y1:v.y,x:O.x,y:O.y}},V=/^[Tt]/,U=at(["T","t"],!1,!1),B=/^[Aa]/,q=at(["A","a"],!1,!1),j=function(v,O,L,I,z,oe){return{rx:v,ry:O,xAxisRotation:L,largeArc:I,sweep:z,x:oe.x,y:oe.y}},F=function(v,O){return{x:v,y:O}},H=function(v){return v*1},W=function(v){return v.join("")*1},ee=/^[01]/,te=at(["0","1"],!1,!1),Y=function(v){return v=="1"},re=function(){return""},K=",",Z=bt(",",!1),Q=function(v){return v.join("")},$=".",pe=bt(".",!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(v){return v.join("")},Se=/^[ \t\n\r]/,xe=at([" "," ",`
2
+ `,"\r"],!1,!1),C=0,ne=0,ze=[{line:1,column:1}],He=0,Fe=[],Ae=0,Ut;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 Re(){return i.substring(ne,C)}function Ft(){return bn(ne,C)}function kt(v,O){throw O=O!==void 0?O:bn(ne,C),jr([Sp(v)],i.substring(ne,C),O)}function xn(v,O){throw O=O!==void 0?O:bn(ne,C),wp(v,O)}function bt(v,O){return{type:"literal",text:v,ignoreCase:O}}function at(v,O,L){return{type:"class",parts:v,inverted:O,ignoreCase:L}}function io(){return{type:"any"}}function vp(){return{type:"end"}}function Sp(v){return{type:"other",description:v}}function Pc(v){var O=ze[v],L;if(O)return O;for(L=v-1;!ze[L];)L--;for(O=ze[L],O={line:O.line,column:O.column};L<v;)i.charCodeAt(L)===10?(O.line++,O.column=1):O.column++,L++;return ze[v]=O,O}function bn(v,O){var L=Pc(v),I=Pc(O);return{start:{offset:v,line:L.line,column:L.column},end:{offset:O,line:I.line,column:I.column}}}function Ct(v){C<He||(C>He&&(He=C,Fe=[]),Fe.push(v))}function wp(v,O){return new Yn(v,null,null,O)}function jr(v,O,L){return new Yn(Yn.buildMessage(v,O),v,O,L)}function nl(){var v,O,L,I,z;for(v=C,O=[],L=We();L!==e;)O.push(L),L=We();if(O!==e)if(L=pr(),L===e&&(L=null),L!==e){for(I=[],z=We();z!==e;)I.push(z),z=We();I!==e?(ne=v,O=n(L),v=O):(C=v,v=e)}else C=v,v=e;else C=v,v=e;return v}function pr(){var v,O,L,I,z,oe;if(v=C,O=vn(),O!==e){for(L=[],I=C,z=[],oe=We();oe!==e;)z.push(oe),oe=We();for(z!==e?(oe=vn(),oe!==e?(z=[z,oe],I=z):(C=I,I=e)):(C=I,I=e);I!==e;){for(L.push(I),I=C,z=[],oe=We();oe!==e;)z.push(oe),oe=We();z!==e?(oe=vn(),oe!==e?(z=[z,oe],I=z):(C=I,I=e)):(C=I,I=e)}L!==e?(ne=v,O=a(O,L),v=O):(C=v,v=e)}else C=v,v=e;return v}function vn(){var v,O,L,I,z,oe;if(v=C,O=Jn(),O!==e){for(L=[],I=C,z=[],oe=We();oe!==e;)z.push(oe),oe=We();for(z!==e?(oe=Oc(),oe!==e?(z=[z,oe],I=z):(C=I,I=e)):(C=I,I=e);I!==e;){for(L.push(I),I=C,z=[],oe=We();oe!==e;)z.push(oe),oe=We();z!==e?(oe=Oc(),oe!==e?(z=[z,oe],I=z):(C=I,I=e)):(C=I,I=e)}L!==e?(ne=v,O=a(O,L),v=O):(C=v,v=e)}else C=v,v=e;return v}function Oc(){var v;return v=CS(),v===e&&(v=AS(),v===e&&(v=MS(),v===e&&(v=IS(),v===e&&(v=ES(),v===e&&(v=DS(),v===e&&(v=RS(),v===e&&(v=BS(),v===e&&(v=zS())))))))),v}function Jn(){var v,O,L,I,z,oe,ra;if(v=C,s.test(i.charAt(C))?(O=i.charAt(C),C++):(O=e,Ae===0&&Ct(l)),O!==e){for(L=[],I=We();I!==e;)L.push(I),I=We();L!==e?(I=hr(),I!==e?(z=C,oe=mt(),oe===e&&(oe=null),oe!==e?(ra=um(),ra!==e?(oe=[oe,ra],z=oe):(C=z,z=e)):(C=z,z=e),z===e&&(z=null),z!==e?(ne=v,O=c(O,I,z),v=O):(C=v,v=e)):(C=v,v=e)):(C=v,v=e)}else C=v,v=e;return v}function CS(){var v,O;return v=C,u.test(i.charAt(C))?(O=i.charAt(C),C++):(O=e,Ae===0&&Ct(d)),O!==e&&(ne=v,O=p()),v=O,v}function AS(){var v,O,L,I;if(v=C,f.test(i.charAt(C))?(O=i.charAt(C),C++):(O=e,Ae===0&&Ct(h)),O!==e){for(L=[],I=We();I!==e;)L.push(I),I=We();L!==e?(I=um(),I!==e?(ne=v,O=m(O,I),v=O):(C=v,v=e)):(C=v,v=e)}else C=v,v=e;return v}function um(){var v,O,L,I,z,oe;if(v=C,O=hr(),O!==e){for(L=[],I=C,z=mt(),z===e&&(z=null),z!==e?(oe=hr(),oe!==e?(z=[z,oe],I=z):(C=I,I=e)):(C=I,I=e);I!==e;)L.push(I),I=C,z=mt(),z===e&&(z=null),z!==e?(oe=hr(),oe!==e?(z=[z,oe],I=z):(C=I,I=e)):(C=I,I=e);L!==e?(ne=v,O=a(O,L),v=O):(C=v,v=e)}else C=v,v=e;return v}function MS(){var v,O,L,I;if(v=C,y.test(i.charAt(C))?(O=i.charAt(C),C++):(O=e,Ae===0&&Ct(g)),O!==e){for(L=[],I=We();I!==e;)L.push(I),I=We();L!==e?(I=dm(),I!==e?(ne=v,O=b(O,I),v=O):(C=v,v=e)):(C=v,v=e)}else C=v,v=e;return v}function dm(){var v,O,L,I,z,oe;if(v=C,O=ea(),O!==e){for(L=[],I=C,z=mt(),z===e&&(z=null),z!==e?(oe=ea(),oe!==e?(z=[z,oe],I=z):(C=I,I=e)):(C=I,I=e);I!==e;)L.push(I),I=C,z=mt(),z===e&&(z=null),z!==e?(oe=ea(),oe!==e?(z=[z,oe],I=z):(C=I,I=e)):(C=I,I=e);L!==e?(ne=v,O=a(O,L),v=O):(C=v,v=e)}else C=v,v=e;return v}function IS(){var v,O,L,I;if(v=C,w.test(i.charAt(C))?(O=i.charAt(C),C++):(O=e,Ae===0&&Ct(P)),O!==e){for(L=[],I=We();I!==e;)L.push(I),I=We();L!==e?(I=dm(),I!==e?(ne=v,O=S(O,I),v=O):(C=v,v=e)):(C=v,v=e)}else C=v,v=e;return v}function ES(){var v,O,L,I;if(v=C,T.test(i.charAt(C))?(O=i.charAt(C),C++):(O=e,Ae===0&&Ct(A)),O!==e){for(L=[],I=We();I!==e;)L.push(I),I=We();L!==e?(I=NS(),I!==e?(ne=v,O=m(O,I),v=O):(C=v,v=e)):(C=v,v=e)}else C=v,v=e;return v}function NS(){var v,O,L,I,z,oe;if(v=C,O=Pp(),O!==e){for(L=[],I=C,z=mt(),z===e&&(z=null),z!==e?(oe=Pp(),oe!==e?(z=[z,oe],I=z):(C=I,I=e)):(C=I,I=e);I!==e;)L.push(I),I=C,z=mt(),z===e&&(z=null),z!==e?(oe=Pp(),oe!==e?(z=[z,oe],I=z):(C=I,I=e)):(C=I,I=e);L!==e?(ne=v,O=a(O,L),v=O):(C=v,v=e)}else C=v,v=e;return v}function Pp(){var v,O,L,I,z,oe;return v=C,O=hr(),O!==e?(L=mt(),L===e&&(L=null),L!==e?(I=hr(),I!==e?(z=mt(),z===e&&(z=null),z!==e?(oe=hr(),oe!==e?(ne=v,O=x(O,I,oe),v=O):(C=v,v=e)):(C=v,v=e)):(C=v,v=e)):(C=v,v=e)):(C=v,v=e),v}function DS(){var v,O,L,I;if(v=C,N.test(i.charAt(C))?(O=i.charAt(C),C++):(O=e,Ae===0&&Ct(E)),O!==e){for(L=[],I=We();I!==e;)L.push(I),I=We();L!==e?(I=_S(),I!==e?(ne=v,O=m(O,I),v=O):(C=v,v=e)):(C=v,v=e)}else C=v,v=e;return v}function _S(){var v,O,L,I,z,oe;if(v=C,O=Op(),O!==e){for(L=[],I=C,z=mt(),z===e&&(z=null),z!==e?(oe=Op(),oe!==e?(z=[z,oe],I=z):(C=I,I=e)):(C=I,I=e);I!==e;)L.push(I),I=C,z=mt(),z===e&&(z=null),z!==e?(oe=Op(),oe!==e?(z=[z,oe],I=z):(C=I,I=e)):(C=I,I=e);L!==e?(ne=v,O=a(O,L),v=O):(C=v,v=e)}else C=v,v=e;return v}function Op(){var v,O,L,I;return v=C,O=hr(),O!==e?(L=mt(),L===e&&(L=null),L!==e?(I=hr(),I!==e?(ne=v,O=M(O,I),v=O):(C=v,v=e)):(C=v,v=e)):(C=v,v=e),v}function RS(){var v,O,L,I;if(v=C,D.test(i.charAt(C))?(O=i.charAt(C),C++):(O=e,Ae===0&&Ct(_)),O!==e){for(L=[],I=We();I!==e;)L.push(I),I=We();L!==e?(I=LS(),I!==e?(ne=v,O=m(O,I),v=O):(C=v,v=e)):(C=v,v=e)}else C=v,v=e;return v}function LS(){var v,O,L,I,z,oe;if(v=C,O=Tp(),O!==e){for(L=[],I=C,z=mt(),z===e&&(z=null),z!==e?(oe=Tp(),oe!==e?(z=[z,oe],I=z):(C=I,I=e)):(C=I,I=e);I!==e;)L.push(I),I=C,z=mt(),z===e&&(z=null),z!==e?(oe=Tp(),oe!==e?(z=[z,oe],I=z):(C=I,I=e)):(C=I,I=e);L!==e?(ne=v,O=a(O,L),v=O):(C=v,v=e)}else C=v,v=e;return v}function Tp(){var v,O,L,I;return v=C,O=hr(),O!==e?(L=mt(),L===e&&(L=null),L!==e?(I=hr(),I!==e?(ne=v,O=R(O,I),v=O):(C=v,v=e)):(C=v,v=e)):(C=v,v=e),v}function BS(){var v,O,L,I;if(v=C,V.test(i.charAt(C))?(O=i.charAt(C),C++):(O=e,Ae===0&&Ct(U)),O!==e){for(L=[],I=We();I!==e;)L.push(I),I=We();L!==e?(I=VS(),I!==e?(ne=v,O=m(O,I),v=O):(C=v,v=e)):(C=v,v=e)}else C=v,v=e;return v}function VS(){var v,O,L,I,z,oe;if(v=C,O=hr(),O!==e){for(L=[],I=C,z=mt(),z===e&&(z=null),z!==e?(oe=hr(),oe!==e?(z=[z,oe],I=z):(C=I,I=e)):(C=I,I=e);I!==e;)L.push(I),I=C,z=mt(),z===e&&(z=null),z!==e?(oe=hr(),oe!==e?(z=[z,oe],I=z):(C=I,I=e)):(C=I,I=e);L!==e?(ne=v,O=a(O,L),v=O):(C=v,v=e)}else C=v,v=e;return v}function zS(){var v,O,L,I;if(v=C,B.test(i.charAt(C))?(O=i.charAt(C),C++):(O=e,Ae===0&&Ct(q)),O!==e){for(L=[],I=We();I!==e;)L.push(I),I=We();L!==e?(I=GS(),I!==e?(ne=v,O=m(O,I),v=O):(C=v,v=e)):(C=v,v=e)}else C=v,v=e;return v}function GS(){var v,O,L,I,z,oe;if(v=C,O=Cp(),O!==e){for(L=[],I=C,z=mt(),z===e&&(z=null),z!==e?(oe=Cp(),oe!==e?(z=[z,oe],I=z):(C=I,I=e)):(C=I,I=e);I!==e;)L.push(I),I=C,z=mt(),z===e&&(z=null),z!==e?(oe=Cp(),oe!==e?(z=[z,oe],I=z):(C=I,I=e)):(C=I,I=e);L!==e?(ne=v,O=a(O,L),v=O):(C=v,v=e)}else C=v,v=e;return v}function Cp(){var v,O,L,I,z,oe,ra,Mp,Cc,Ip,Ac,Ep;return v=C,O=pm(),O!==e?(L=mt(),L===e&&(L=null),L!==e?(I=pm(),I!==e?(z=mt(),z===e&&(z=null),z!==e?(oe=ea(),oe!==e?(ra=mt(),ra!==e?(Mp=fm(),Mp!==e?(Cc=mt(),Cc===e&&(Cc=null),Cc!==e?(Ip=fm(),Ip!==e?(Ac=mt(),Ac===e&&(Ac=null),Ac!==e?(Ep=hr(),Ep!==e?(ne=v,O=j(O,I,oe,Mp,Ip,Ep),v=O):(C=v,v=e)):(C=v,v=e)):(C=v,v=e)):(C=v,v=e)):(C=v,v=e)):(C=v,v=e)):(C=v,v=e)):(C=v,v=e)):(C=v,v=e)):(C=v,v=e)):(C=v,v=e),v}function hr(){var v,O,L,I;return v=C,O=ea(),O!==e?(L=mt(),L===e&&(L=null),L!==e?(I=ea(),I!==e?(ne=v,O=F(O,I),v=O):(C=v,v=e)):(C=v,v=e)):(C=v,v=e),v}function pm(){var v,O;return v=C,O=mm(),O===e&&(O=Sn()),O!==e&&(ne=v,O=H(O)),v=O,v}function ea(){var v,O,L,I;return v=C,O=C,L=Ap(),L===e&&(L=null),L!==e?(I=mm(),I!==e?(L=[L,I],O=L):(C=O,O=e)):(C=O,O=e),O===e&&(O=C,L=Ap(),L===e&&(L=null),L!==e?(I=Sn(),I!==e?(L=[L,I],O=L):(C=O,O=e)):(C=O,O=e)),O!==e&&(ne=v,O=W(O)),v=O,v}function fm(){var v,O;return v=C,ee.test(i.charAt(C))?(O=i.charAt(C),C++):(O=e,Ae===0&&Ct(te)),O!==e&&(ne=v,O=Y(O)),v=O,v}function mt(){var v,O,L,I,z;if(v=C,O=[],L=We(),L!==e)for(;L!==e;)O.push(L),L=We();else O=e;if(O!==e)if(L=hm(),L===e&&(L=null),L!==e){for(I=[],z=We();z!==e;)I.push(z),z=We();I!==e?(O=[O,L,I],v=O):(C=v,v=e)}else C=v,v=e;else C=v,v=e;if(v===e){if(v=C,O=C,L=hm(),L!==e){for(I=[],z=We();z!==e;)I.push(z),z=We();I!==e?(L=[L,I],O=L):(C=O,O=e)}else C=O,O=e;O!==e&&(ne=v,O=re()),v=O}return v}function hm(){var v;return i.charCodeAt(C)===44?(v=K,C++):(v=e,Ae===0&&Ct(Z)),v}function mm(){var v,O,L,I;return v=C,O=C,L=FS(),L!==e?(I=ym(),I===e&&(I=null),I!==e?(L=[L,I],O=L):(C=O,O=e)):(C=O,O=e),O===e&&(O=C,L=Sn(),L!==e?(I=ym(),I!==e?(L=[L,I],O=L):(C=O,O=e)):(C=O,O=e)),O!==e&&(ne=v,O=Q(O)),v=O,v}function FS(){var v,O,L,I,z;return v=C,O=C,L=Sn(),L===e&&(L=null),L!==e?(i.charCodeAt(C)===46?(I=$,C++):(I=e,Ae===0&&Ct(pe)),I!==e?(z=Sn(),z!==e?(L=[L,I,z],O=L):(C=O,O=e)):(C=O,O=e)):(C=O,O=e),O===e&&(O=C,L=Sn(),L!==e?(i.charCodeAt(C)===46?(I=$,C++):(I=e,Ae===0&&Ct(pe)),I!==e?(L=[L,I],O=L):(C=O,O=e)):(C=O,O=e)),O!==e&&(ne=v,O=Q(O)),v=O,v}function ym(){var v,O,L,I,z;return v=C,O=C,le.test(i.charAt(C))?(L=i.charAt(C),C++):(L=e,Ae===0&&Ct(ie)),L!==e?(I=Ap(),I===e&&(I=null),I!==e?(z=Sn(),z!==e?(L=[L,I,z],O=L):(C=O,O=e)):(C=O,O=e)):(C=O,O=e),O!==e&&(ne=v,O=Q(O)),v=O,v}function Ap(){var v;return ue.test(i.charAt(C))?(v=i.charAt(C),C++):(v=e,Ae===0&&Ct(ae)),v}function Sn(){var v,O,L;if(v=C,O=[],ge.test(i.charAt(C))?(L=i.charAt(C),C++):(L=e,Ae===0&&Ct(me)),L!==e)for(;L!==e;)O.push(L),ge.test(i.charAt(C))?(L=i.charAt(C),C++):(L=e,Ae===0&&Ct(me));else O=e;return O!==e&&(ne=v,O=ye(O)),v=O,v}function We(){var v,O;return v=C,Se.test(i.charAt(C))?(O=i.charAt(C),C++):(O=e,Ae===0&&Ct(xe)),O!==e&&(ne=v,O=re()),v=O,v}function jS(v,O){if(!O)return[v];for(var L=[v],I=0,z=O.length;I<z;I++)L[I+1]=O[I][1];return L}var Tc={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 gm in Tc)Tc[gm.toUpperCase()]=Tc[gm];function ta(v,O){O||(O=[{}]);for(var L=O.length;L--;){var I={code:v,command:Tc[v]};v==v.toLowerCase()&&(I.relative=!0);for(var z in O[L])I[z]=O[L][z];O[L]=I}return O}if(Ut=o(),Ut!==e&&C===i.length)return Ut;throw Ut!==e&&C<i.length&&Ct(vp()),jr(Fe,He<i.length?i.charAt(He):null,He<i.length?bn(He,He+1):bn(He,He))}u1.exports={SyntaxError:Yn,parse:sE}});var Xh=sl((hoe,p1)=>{var ep=d1().parse;ep.parseSVG=ep;ep.makeAbsolute=lE;p1.exports=ep;function lE(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=sl((oue,wS)=>{wS.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 jE={};xm(jE,{default:()=>xp});module.exports=XS(jE);var bp=require("three");function Mc(i){for(let t of Object.keys(i))i[t]===void 0&&delete i[t];return i}function Ht(i,t){return Object.setPrototypeOf(i,t),i}function Ic(i){return Array.isArray(i)?i:[i]}function Ec(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 YS=typeof global=="object"&&global&&global.Object===Object&&global,Nc=YS;var KS=typeof self=="object"&&self&&self.Object===Object&&self,QS=Nc||KS||Function("return this")(),At=QS;var ZS=At.Symbol,Zt=ZS;var vm=Object.prototype,JS=vm.hasOwnProperty,ew=vm.toString,cl=Zt?Zt.toStringTag:void 0;function tw(i){var t=JS.call(i,cl),e=i[cl];try{i[cl]=void 0;var r=!0}catch{}var o=ew.call(i);return r&&(t?i[cl]=e:delete i[cl]),o}var Sm=tw;var rw=Object.prototype,ow=rw.toString;function iw(i){return ow.call(i)}var wm=iw;var nw="[object Null]",aw="[object Undefined]",Pm=Zt?Zt.toStringTag:void 0;function sw(i){return i==null?i===void 0?aw:nw:Pm&&Pm in Object(i)?Sm(i):wm(i)}var Lr=sw;function lw(i){return i!=null&&typeof i=="object"}var nr=lw;var cw="[object Symbol]";function uw(i){return typeof i=="symbol"||nr(i)&&Lr(i)==cw}var Ci=uw;function dw(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 Dc=dw;var pw=Array.isArray,Mt=pw;var fw=1/0,Om=Zt?Zt.prototype:void 0,Tm=Om?Om.toString:void 0;function Cm(i){if(typeof i=="string")return i;if(Mt(i))return Dc(i,Cm)+"";if(Ci(i))return Tm?Tm.call(i):"";var t=i+"";return t=="0"&&1/i==-fw?"-0":t}var Am=Cm;var hw=/\s/;function mw(i){for(var t=i.length;t--&&hw.test(i.charAt(t)););return t}var Mm=mw;var yw=/^\s+/;function gw(i){return i&&i.slice(0,Mm(i)+1).replace(yw,"")}var Im=gw;function xw(i){var t=typeof i;return i!=null&&(t=="object"||t=="function")}var It=xw;var Em=0/0,bw=/^[-+]0x[0-9a-f]+$/i,vw=/^0b[01]+$/i,Sw=/^0o[0-7]+$/i,ww=parseInt;function Pw(i){if(typeof i=="number")return i;if(Ci(i))return Em;if(It(i)){var t=typeof i.valueOf=="function"?i.valueOf():i;i=It(t)?t+"":t}if(typeof i!="string")return i===0?i:+i;i=Im(i);var e=vw.test(i);return e||Sw.test(i)?ww(i.slice(2),e?2:8):bw.test(i)?Em:+i}var Np=Pw;function Ow(i){return i}var Nm=Ow;var Tw="[object AsyncFunction]",Cw="[object Function]",Aw="[object GeneratorFunction]",Mw="[object Proxy]";function Iw(i){if(!It(i))return!1;var t=Lr(i);return t==Cw||t==Aw||t==Tw||t==Mw}var _c=Iw;var Ew=At["__core-js_shared__"],Rc=Ew;var Dm=function(){var i=/[^.]+$/.exec(Rc&&Rc.keys&&Rc.keys.IE_PROTO||"");return i?"Symbol(src)_1."+i:""}();function Nw(i){return!!Dm&&Dm in i}var _m=Nw;var Dw=Function.prototype,_w=Dw.toString;function Rw(i){if(i!=null){try{return _w.call(i)}catch{}try{return i+""}catch{}}return""}var Zo=Rw;var Lw=/[\\^$.*+?()[\]{}|]/g,Bw=/^\[object .+?Constructor\]$/,Vw=Function.prototype,zw=Object.prototype,Gw=Vw.toString,Fw=zw.hasOwnProperty,jw=RegExp("^"+Gw.call(Fw).replace(Lw,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Uw(i){if(!It(i)||_m(i))return!1;var t=_c(i)?jw:Bw;return t.test(Zo(i))}var Rm=Uw;function kw(i,t){return i?.[t]}var Lm=kw;function Hw(i,t){var e=Lm(i,t);return Rm(e)?e:void 0}var Sr=Hw;var Ww=Sr(At,"WeakMap"),Lc=Ww;var Bm=Object.create,qw=function(){function i(){}return function(t){if(!It(t))return{};if(Bm)return Bm(t);i.prototype=t;var e=new i;return i.prototype=void 0,e}}(),Vm=qw;function $w(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 zm=$w;function Xw(i,t){var e=-1,r=i.length;for(t||(t=Array(r));++e<r;)t[e]=i[e];return t}var Gm=Xw;var Yw=800,Kw=16,Qw=Date.now;function Zw(i){var t=0,e=0;return function(){var r=Qw(),o=Kw-(r-e);if(e=r,o>0){if(++t>=Yw)return arguments[0]}else t=0;return i.apply(void 0,arguments)}}var Fm=Zw;function Jw(i){return function(){return i}}var jm=Jw;var e2=function(){try{var i=Sr(Object,"defineProperty");return i({},"",{}),i}catch{}}(),oa=e2;var t2=oa?function(i,t){return oa(i,"toString",{configurable:!0,enumerable:!1,value:jm(t),writable:!0})}:Nm,Um=t2;var r2=Fm(Um),km=r2;function o2(i,t){for(var e=-1,r=i==null?0:i.length;++e<r&&t(i[e],e,i)!==!1;);return i}var Hm=o2;var i2=9007199254740991,n2=/^(?:0|[1-9]\d*)$/;function a2(i,t){var e=typeof i;return t=t??i2,!!t&&(e=="number"||e!="symbol"&&n2.test(i))&&i>-1&&i%1==0&&i<t}var ia=a2;function s2(i,t,e){t=="__proto__"&&oa?oa(i,t,{configurable:!0,enumerable:!0,value:e,writable:!0}):i[t]=e}var Bc=s2;function l2(i,t){return i===t||i!==i&&t!==t}var na=l2;var c2=Object.prototype,u2=c2.hasOwnProperty;function d2(i,t,e){var r=i[t];(!(u2.call(i,t)&&na(r,e))||e===void 0&&!(t in i))&&Bc(i,t,e)}var aa=d2;function p2(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?Bc(e,s,l):aa(e,s,l)}return e}var Oo=p2;var Wm=Math.max;function f2(i,t,e){return t=Wm(t===void 0?i.length-1:t,0),function(){for(var r=arguments,o=-1,n=Wm(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),zm(i,this,s)}}var qm=f2;var h2=9007199254740991;function m2(i){return typeof i=="number"&&i>-1&&i%1==0&&i<=h2}var sa=m2;function y2(i){return i!=null&&sa(i.length)&&!_c(i)}var Vc=y2;var g2=Object.prototype;function x2(i){var t=i&&i.constructor,e=typeof t=="function"&&t.prototype||g2;return i===e}var la=x2;function b2(i,t){for(var e=-1,r=Array(i);++e<i;)r[e]=t(e);return r}var $m=b2;var v2="[object Arguments]";function S2(i){return nr(i)&&Lr(i)==v2}var Dp=S2;var Xm=Object.prototype,w2=Xm.hasOwnProperty,P2=Xm.propertyIsEnumerable,O2=Dp(function(){return arguments}())?Dp:function(i){return nr(i)&&w2.call(i,"callee")&&!P2.call(i,"callee")},ca=O2;function T2(){return!1}var Ym=T2;var Zm=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Km=Zm&&typeof module=="object"&&module&&!module.nodeType&&module,C2=Km&&Km.exports===Zm,Qm=C2?At.Buffer:void 0,A2=Qm?Qm.isBuffer:void 0,M2=A2||Ym,Pn=M2;var I2="[object Arguments]",E2="[object Array]",N2="[object Boolean]",D2="[object Date]",_2="[object Error]",R2="[object Function]",L2="[object Map]",B2="[object Number]",V2="[object Object]",z2="[object RegExp]",G2="[object Set]",F2="[object String]",j2="[object WeakMap]",U2="[object ArrayBuffer]",k2="[object DataView]",H2="[object Float32Array]",W2="[object Float64Array]",q2="[object Int8Array]",$2="[object Int16Array]",X2="[object Int32Array]",Y2="[object Uint8Array]",K2="[object Uint8ClampedArray]",Q2="[object Uint16Array]",Z2="[object Uint32Array]",yt={};yt[H2]=yt[W2]=yt[q2]=yt[$2]=yt[X2]=yt[Y2]=yt[K2]=yt[Q2]=yt[Z2]=!0;yt[I2]=yt[E2]=yt[U2]=yt[N2]=yt[k2]=yt[D2]=yt[_2]=yt[R2]=yt[L2]=yt[B2]=yt[V2]=yt[z2]=yt[G2]=yt[F2]=yt[j2]=!1;function J2(i){return nr(i)&&sa(i.length)&&!!yt[Lr(i)]}var Jm=J2;function eP(i){return function(t){return i(t)}}var ua=eP;var ey=typeof exports=="object"&&exports&&!exports.nodeType&&exports,ul=ey&&typeof module=="object"&&module&&!module.nodeType&&module,tP=ul&&ul.exports===ey,_p=tP&&Nc.process,rP=function(){try{var i=ul&&ul.require&&ul.require("util").types;return i||_p&&_p.binding&&_p.binding("util")}catch{}}(),Jo=rP;var ty=Jo&&Jo.isTypedArray,oP=ty?ua(ty):Jm,zc=oP;var iP=Object.prototype,nP=iP.hasOwnProperty;function aP(i,t){var e=Mt(i),r=!e&&ca(i),o=!e&&!r&&Pn(i),n=!e&&!r&&!o&&zc(i),a=e||r||o||n,s=a?$m(i.length,String):[],l=s.length;for(var c in i)(t||nP.call(i,c))&&!(a&&(c=="length"||o&&(c=="offset"||c=="parent")||n&&(c=="buffer"||c=="byteLength"||c=="byteOffset")||ia(c,l)))&&s.push(c);return s}var Gc=aP;function sP(i,t){return function(e){return i(t(e))}}var Fc=sP;var lP=Fc(Object.keys,Object),ry=lP;var cP=Object.prototype,uP=cP.hasOwnProperty;function dP(i){if(!la(i))return ry(i);var t=[];for(var e in Object(i))uP.call(i,e)&&e!="constructor"&&t.push(e);return t}var oy=dP;function pP(i){return Vc(i)?Gc(i):oy(i)}var da=pP;function fP(i){var t=[];if(i!=null)for(var e in Object(i))t.push(e);return t}var iy=fP;var hP=Object.prototype,mP=hP.hasOwnProperty;function yP(i){if(!It(i))return iy(i);var t=la(i),e=[];for(var r in i)r=="constructor"&&(t||!mP.call(i,r))||e.push(r);return e}var ny=yP;function gP(i){return Vc(i)?Gc(i,!0):ny(i)}var pa=gP;var xP=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,bP=/^\w*$/;function vP(i,t){if(Mt(i))return!1;var e=typeof i;return e=="number"||e=="symbol"||e=="boolean"||i==null||Ci(i)?!0:bP.test(i)||!xP.test(i)||t!=null&&i in Object(t)}var ay=vP;var SP=Sr(Object,"create"),ei=SP;function wP(){this.__data__=ei?ei(null):{},this.size=0}var sy=wP;function PP(i){var t=this.has(i)&&delete this.__data__[i];return this.size-=t?1:0,t}var ly=PP;var OP="__lodash_hash_undefined__",TP=Object.prototype,CP=TP.hasOwnProperty;function AP(i){var t=this.__data__;if(ei){var e=t[i];return e===OP?void 0:e}return CP.call(t,i)?t[i]:void 0}var cy=AP;var MP=Object.prototype,IP=MP.hasOwnProperty;function EP(i){var t=this.__data__;return ei?t[i]!==void 0:IP.call(t,i)}var uy=EP;var NP="__lodash_hash_undefined__";function DP(i,t){var e=this.__data__;return this.size+=this.has(i)?0:1,e[i]=ei&&t===void 0?NP:t,this}var dy=DP;function fa(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])}}fa.prototype.clear=sy;fa.prototype.delete=ly;fa.prototype.get=cy;fa.prototype.has=uy;fa.prototype.set=dy;var Rp=fa;function _P(){this.__data__=[],this.size=0}var py=_P;function RP(i,t){for(var e=i.length;e--;)if(na(i[e][0],t))return e;return-1}var Ai=RP;var LP=Array.prototype,BP=LP.splice;function VP(i){var t=this.__data__,e=Ai(t,i);if(e<0)return!1;var r=t.length-1;return e==r?t.pop():BP.call(t,e,1),--this.size,!0}var fy=VP;function zP(i){var t=this.__data__,e=Ai(t,i);return e<0?void 0:t[e][1]}var hy=zP;function GP(i){return Ai(this.__data__,i)>-1}var my=GP;function FP(i,t){var e=this.__data__,r=Ai(e,i);return r<0?(++this.size,e.push([i,t])):e[r][1]=t,this}var yy=FP;function ha(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])}}ha.prototype.clear=py;ha.prototype.delete=fy;ha.prototype.get=hy;ha.prototype.has=my;ha.prototype.set=yy;var Mi=ha;var jP=Sr(At,"Map"),Ii=jP;function UP(){this.size=0,this.__data__={hash:new Rp,map:new(Ii||Mi),string:new Rp}}var gy=UP;function kP(i){var t=typeof i;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?i!=="__proto__":i===null}var xy=kP;function HP(i,t){var e=i.__data__;return xy(t)?e[typeof t=="string"?"string":"hash"]:e.map}var Ei=HP;function WP(i){var t=Ei(this,i).delete(i);return this.size-=t?1:0,t}var by=WP;function qP(i){return Ei(this,i).get(i)}var vy=qP;function $P(i){return Ei(this,i).has(i)}var Sy=$P;function XP(i,t){var e=Ei(this,i),r=e.size;return e.set(i,t),this.size+=e.size==r?0:1,this}var wy=XP;function ma(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])}}ma.prototype.clear=gy;ma.prototype.delete=by;ma.prototype.get=vy;ma.prototype.has=Sy;ma.prototype.set=wy;var On=ma;var YP="Expected a function";function Lp(i,t){if(typeof i!="function"||t!=null&&typeof t!="function")throw new TypeError(YP);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(Lp.Cache||On),e}Lp.Cache=On;var Py=Lp;var KP=500;function QP(i){var t=Py(i,function(r){return e.size===KP&&e.clear(),r}),e=t.cache;return t}var Oy=QP;var ZP=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,JP=/\\(\\)?/g,eO=Oy(function(i){var t=[];return i.charCodeAt(0)===46&&t.push(""),i.replace(ZP,function(e,r,o,n){t.push(o?n.replace(JP,"$1"):r||e)}),t}),Ty=eO;function tO(i){return i==null?"":Am(i)}var Cy=tO;function rO(i,t){return Mt(i)?i:ay(i,t)?[i]:Ty(Cy(i))}var Ur=rO;var oO=1/0;function iO(i){if(typeof i=="string"||Ci(i))return i;var t=i+"";return t=="0"&&1/i==-oO?"-0":t}var Ni=iO;function nO(i,t){t=Ur(t,i);for(var e=0,r=t.length;i!=null&&e<r;)i=i[Ni(t[e++])];return e&&e==r?i:void 0}var jc=nO;function aO(i,t){for(var e=-1,r=t.length,o=i.length;++e<r;)i[o+e]=t[e];return i}var ya=aO;var Ay=Zt?Zt.isConcatSpreadable:void 0;function sO(i){return Mt(i)||ca(i)||!!(Ay&&i&&i[Ay])}var My=sO;function Iy(i,t,e,r,o){var n=-1,a=i.length;for(e||(e=My),o||(o=[]);++n<a;){var s=i[n];t>0&&e(s)?t>1?Iy(s,t-1,e,r,o):ya(o,s):r||(o[o.length]=s)}return o}var Ey=Iy;function lO(i){var t=i==null?0:i.length;return t?Ey(i,1):[]}var Ny=lO;function cO(i){return km(qm(i,void 0,Ny),i+"")}var Uc=cO;var uO=Fc(Object.getPrototypeOf,Object),ga=uO;var dO="[object Object]",pO=Function.prototype,fO=Object.prototype,Dy=pO.toString,hO=fO.hasOwnProperty,mO=Dy.call(Object);function yO(i){if(!nr(i)||Lr(i)!=dO)return!1;var t=ga(i);if(t===null)return!0;var e=hO.call(t,"constructor")&&t.constructor;return typeof e=="function"&&e instanceof e&&Dy.call(e)==mO}var _y=yO;function gO(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 Ry=gO;function xO(){this.__data__=new Mi,this.size=0}var Ly=xO;function bO(i){var t=this.__data__,e=t.delete(i);return this.size=t.size,e}var By=bO;function vO(i){return this.__data__.get(i)}var Vy=vO;function SO(i){return this.__data__.has(i)}var zy=SO;var wO=200;function PO(i,t){var e=this.__data__;if(e instanceof Mi){var r=e.__data__;if(!Ii||r.length<wO-1)return r.push([i,t]),this.size=++e.size,this;e=this.__data__=new On(r)}return e.set(i,t),this.size=e.size,this}var Gy=PO;function xa(i){var t=this.__data__=new Mi(i);this.size=t.size}xa.prototype.clear=Ly;xa.prototype.delete=By;xa.prototype.get=Vy;xa.prototype.has=zy;xa.prototype.set=Gy;var ba=xa;function OO(i,t){return i&&Oo(t,da(t),i)}var Fy=OO;function TO(i,t){return i&&Oo(t,pa(t),i)}var jy=TO;var Wy=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Uy=Wy&&typeof module=="object"&&module&&!module.nodeType&&module,CO=Uy&&Uy.exports===Wy,ky=CO?At.Buffer:void 0,Hy=ky?ky.allocUnsafe:void 0;function AO(i,t){if(t)return i.slice();var e=i.length,r=Hy?Hy(e):new i.constructor(e);return i.copy(r),r}var qy=AO;function MO(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 $y=MO;function IO(){return[]}var kc=IO;var EO=Object.prototype,NO=EO.propertyIsEnumerable,Xy=Object.getOwnPropertySymbols,DO=Xy?function(i){return i==null?[]:(i=Object(i),$y(Xy(i),function(t){return NO.call(i,t)}))}:kc,va=DO;function _O(i,t){return Oo(i,va(i),t)}var Yy=_O;var RO=Object.getOwnPropertySymbols,LO=RO?function(i){for(var t=[];i;)ya(t,va(i)),i=ga(i);return t}:kc,Hc=LO;function BO(i,t){return Oo(i,Hc(i),t)}var Ky=BO;function VO(i,t,e){var r=t(i);return Mt(i)?r:ya(r,e(i))}var Wc=VO;function zO(i){return Wc(i,da,va)}var dl=zO;function GO(i){return Wc(i,pa,Hc)}var qc=GO;var FO=Sr(At,"DataView"),$c=FO;var jO=Sr(At,"Promise"),Xc=jO;var UO=Sr(At,"Set"),Yc=UO;var Qy="[object Map]",kO="[object Object]",Zy="[object Promise]",Jy="[object Set]",eg="[object WeakMap]",tg="[object DataView]",HO=Zo($c),WO=Zo(Ii),qO=Zo(Xc),$O=Zo(Yc),XO=Zo(Lc),Tn=Lr;($c&&Tn(new $c(new ArrayBuffer(1)))!=tg||Ii&&Tn(new Ii)!=Qy||Xc&&Tn(Xc.resolve())!=Zy||Yc&&Tn(new Yc)!=Jy||Lc&&Tn(new Lc)!=eg)&&(Tn=function(i){var t=Lr(i),e=t==kO?i.constructor:void 0,r=e?Zo(e):"";if(r)switch(r){case HO:return tg;case WO:return Qy;case qO:return Zy;case $O:return Jy;case XO:return eg}return t});var ti=Tn;var YO=Object.prototype,KO=YO.hasOwnProperty;function QO(i){var t=i.length,e=new i.constructor(t);return t&&typeof i[0]=="string"&&KO.call(i,"index")&&(e.index=i.index,e.input=i.input),e}var rg=QO;var ZO=At.Uint8Array,Sa=ZO;function JO(i){var t=new i.constructor(i.byteLength);return new Sa(t).set(new Sa(i)),t}var wa=JO;function eT(i,t){var e=t?wa(i.buffer):i.buffer;return new i.constructor(e,i.byteOffset,i.byteLength)}var og=eT;var tT=/\w*$/;function rT(i){var t=new i.constructor(i.source,tT.exec(i));return t.lastIndex=i.lastIndex,t}var ig=rT;var ng=Zt?Zt.prototype:void 0,ag=ng?ng.valueOf:void 0;function oT(i){return ag?Object(ag.call(i)):{}}var sg=oT;function iT(i,t){var e=t?wa(i.buffer):i.buffer;return new i.constructor(e,i.byteOffset,i.length)}var lg=iT;var nT="[object Boolean]",aT="[object Date]",sT="[object Map]",lT="[object Number]",cT="[object RegExp]",uT="[object Set]",dT="[object String]",pT="[object Symbol]",fT="[object ArrayBuffer]",hT="[object DataView]",mT="[object Float32Array]",yT="[object Float64Array]",gT="[object Int8Array]",xT="[object Int16Array]",bT="[object Int32Array]",vT="[object Uint8Array]",ST="[object Uint8ClampedArray]",wT="[object Uint16Array]",PT="[object Uint32Array]";function OT(i,t,e){var r=i.constructor;switch(t){case fT:return wa(i);case nT:case aT:return new r(+i);case hT:return og(i,e);case mT:case yT:case gT:case xT:case bT:case vT:case ST:case wT:case PT:return lg(i,e);case sT:return new r;case lT:case dT:return new r(i);case cT:return ig(i);case uT:return new r;case pT:return sg(i)}}var cg=OT;function TT(i){return typeof i.constructor=="function"&&!la(i)?Vm(ga(i)):{}}var ug=TT;var CT="[object Map]";function AT(i){return nr(i)&&ti(i)==CT}var dg=AT;var pg=Jo&&Jo.isMap,MT=pg?ua(pg):dg,fg=MT;var IT="[object Set]";function ET(i){return nr(i)&&ti(i)==IT}var hg=ET;var mg=Jo&&Jo.isSet,NT=mg?ua(mg):hg,yg=NT;var DT=1,_T=2,RT=4,gg="[object Arguments]",LT="[object Array]",BT="[object Boolean]",VT="[object Date]",zT="[object Error]",xg="[object Function]",GT="[object GeneratorFunction]",FT="[object Map]",jT="[object Number]",bg="[object Object]",UT="[object RegExp]",kT="[object Set]",HT="[object String]",WT="[object Symbol]",qT="[object WeakMap]",$T="[object ArrayBuffer]",XT="[object DataView]",YT="[object Float32Array]",KT="[object Float64Array]",QT="[object Int8Array]",ZT="[object Int16Array]",JT="[object Int32Array]",eC="[object Uint8Array]",tC="[object Uint8ClampedArray]",rC="[object Uint16Array]",oC="[object Uint32Array]",pt={};pt[gg]=pt[LT]=pt[$T]=pt[XT]=pt[BT]=pt[VT]=pt[YT]=pt[KT]=pt[QT]=pt[ZT]=pt[JT]=pt[FT]=pt[jT]=pt[bg]=pt[UT]=pt[kT]=pt[HT]=pt[WT]=pt[eC]=pt[tC]=pt[rC]=pt[oC]=!0;pt[zT]=pt[xg]=pt[qT]=!1;function Kc(i,t,e,r,o,n){var a,s=t&DT,l=t&_T,c=t&RT;if(e&&(a=o?e(i,r,o,n):e(i)),a!==void 0)return a;if(!It(i))return i;var u=Mt(i);if(u){if(a=rg(i),!s)return Gm(i,a)}else{var d=ti(i),p=d==xg||d==GT;if(Pn(i))return qy(i,s);if(d==bg||d==gg||p&&!o){if(a=l||p?{}:ug(i),!s)return l?Ky(i,jy(a,i)):Yy(i,Fy(a,i))}else{if(!pt[d])return o?i:{};a=cg(i,d,s)}}n||(n=new ba);var f=n.get(i);if(f)return f;n.set(i,a),yg(i)?i.forEach(function(y){a.add(Kc(y,t,e,y,i,n))}):fg(i)&&i.forEach(function(y,g){a.set(g,Kc(y,t,e,g,i,n))});var h=c?l?qc:dl:l?pa:da,m=u?void 0:h(i);return Hm(m||i,function(y,g){m&&(g=y,y=i[g]),aa(a,g,Kc(y,t,e,g,i,n))}),a}var Qc=Kc;var iC=1,nC=4;function aC(i){return Qc(i,iC|nC)}var ri=aC;var sC="__lodash_hash_undefined__";function lC(i){return this.__data__.set(i,sC),this}var vg=lC;function cC(i){return this.__data__.has(i)}var Sg=cC;function Zc(i){var t=-1,e=i==null?0:i.length;for(this.__data__=new On;++t<e;)this.add(i[t])}Zc.prototype.add=Zc.prototype.push=vg;Zc.prototype.has=Sg;var wg=Zc;function uC(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 Pg=uC;function dC(i,t){return i.has(t)}var Og=dC;var pC=1,fC=2;function hC(i,t,e,r,o,n){var a=e&pC,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 d=-1,p=!0,f=e&fC?new wg:void 0;for(n.set(i,t),n.set(t,i);++d<s;){var h=i[d],m=t[d];if(r)var y=a?r(m,h,d,t,i,n):r(h,m,d,i,t,n);if(y!==void 0){if(y)continue;p=!1;break}if(f){if(!Pg(t,function(g,b){if(!Og(f,b)&&(h===g||o(h,g,e,r,n)))return f.push(b)})){p=!1;break}}else if(!(h===m||o(h,m,e,r,n))){p=!1;break}}return n.delete(i),n.delete(t),p}var Jc=hC;function mC(i){var t=-1,e=Array(i.size);return i.forEach(function(r,o){e[++t]=[o,r]}),e}var Tg=mC;function yC(i){var t=-1,e=Array(i.size);return i.forEach(function(r){e[++t]=r}),e}var Cg=yC;var gC=1,xC=2,bC="[object Boolean]",vC="[object Date]",SC="[object Error]",wC="[object Map]",PC="[object Number]",OC="[object RegExp]",TC="[object Set]",CC="[object String]",AC="[object Symbol]",MC="[object ArrayBuffer]",IC="[object DataView]",Ag=Zt?Zt.prototype:void 0,Bp=Ag?Ag.valueOf:void 0;function EC(i,t,e,r,o,n,a){switch(e){case IC:if(i.byteLength!=t.byteLength||i.byteOffset!=t.byteOffset)return!1;i=i.buffer,t=t.buffer;case MC:return!(i.byteLength!=t.byteLength||!n(new Sa(i),new Sa(t)));case bC:case vC:case PC:return na(+i,+t);case SC:return i.name==t.name&&i.message==t.message;case OC:case CC:return i==t+"";case wC:var s=Tg;case TC:var l=r&gC;if(s||(s=Cg),i.size!=t.size&&!l)return!1;var c=a.get(i);if(c)return c==t;r|=xC,a.set(i,t);var u=Jc(s(i),s(t),r,o,n,a);return a.delete(i),u;case AC:if(Bp)return Bp.call(i)==Bp.call(t)}return!1}var Mg=EC;var NC=1,DC=Object.prototype,_C=DC.hasOwnProperty;function RC(i,t,e,r,o,n){var a=e&NC,s=dl(i),l=s.length,c=dl(t),u=c.length;if(l!=u&&!a)return!1;for(var d=l;d--;){var p=s[d];if(!(a?p in t:_C.call(t,p)))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;++d<l;){p=s[d];var g=i[p],b=t[p];if(r)var w=a?r(b,g,p,t,i,n):r(g,b,p,i,t,n);if(!(w===void 0?g===b||o(g,b,e,r,n):w)){m=!1;break}y||(y=p=="constructor")}if(m&&!y){var P=i.constructor,S=t.constructor;P!=S&&"constructor"in i&&"constructor"in t&&!(typeof P=="function"&&P instanceof P&&typeof S=="function"&&S instanceof S)&&(m=!1)}return n.delete(i),n.delete(t),m}var Ig=RC;var LC=1,Eg="[object Arguments]",Ng="[object Array]",eu="[object Object]",BC=Object.prototype,Dg=BC.hasOwnProperty;function VC(i,t,e,r,o,n){var a=Mt(i),s=Mt(t),l=a?Ng:ti(i),c=s?Ng:ti(t);l=l==Eg?eu:l,c=c==Eg?eu:c;var u=l==eu,d=c==eu,p=l==c;if(p&&Pn(i)){if(!Pn(t))return!1;a=!0,u=!1}if(p&&!u)return n||(n=new ba),a||zc(i)?Jc(i,t,e,r,o,n):Mg(i,t,l,e,r,o,n);if(!(e&LC)){var f=u&&Dg.call(i,"__wrapped__"),h=d&&Dg.call(t,"__wrapped__");if(f||h){var m=f?i.value():i,y=h?t.value():t;return n||(n=new ba),o(m,y,e,r,n)}}return p?(n||(n=new ba),Ig(i,t,e,r,o,n)):!1}var _g=VC;function Rg(i,t,e,r,o){return i===t?!0:i==null||t==null||!nr(i)&&!nr(t)?i!==i&&t!==t:_g(i,t,e,r,Rg,o)}var Lg=Rg;function zC(i,t){return i!=null&&t in Object(i)}var Bg=zC;function GC(i,t,e){t=Ur(t,i);for(var r=-1,o=t.length,n=!1;++r<o;){var a=Ni(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&&sa(o)&&ia(a,o)&&(Mt(i)||ca(i)))}var Vg=GC;function FC(i,t){return i!=null&&Vg(i,t,Bg)}var zg=FC;var jC=function(){return At.Date.now()},tu=jC;var UC="Expected a function",kC=Math.max,HC=Math.min;function WC(i,t,e){var r,o,n,a,s,l,c=0,u=!1,d=!1,p=!0;if(typeof i!="function")throw new TypeError(UC);t=Np(t)||0,It(e)&&(u=!!e.leading,d="maxWait"in e,n=d?kC(Np(e.maxWait)||0,t):n,p="trailing"in e?!!e.trailing:p);function f(T){var A=r,x=o;return r=o=void 0,c=T,a=i.apply(x,A),a}function h(T){return c=T,s=setTimeout(g,t),u?f(T):a}function m(T){var A=T-l,x=T-c,N=t-A;return d?HC(N,n-x):N}function y(T){var A=T-l,x=T-c;return l===void 0||A>=t||A<0||d&&x>=n}function g(){var T=tu();if(y(T))return b(T);s=setTimeout(g,m(T))}function b(T){return s=void 0,p&&r?f(T):(r=o=void 0,a)}function w(){s!==void 0&&clearTimeout(s),c=0,r=l=o=s=void 0}function P(){return s===void 0?a:b(tu())}function S(){var T=tu(),A=y(T);if(r=arguments,o=this,l=T,A){if(s===void 0)return h(l);if(d)return clearTimeout(s),s=setTimeout(g,t),f(l)}return s===void 0&&(s=setTimeout(g,t)),a}return S.cancel=w,S.flush=P,S}var ru=WC;function qC(i){var t=i==null?0:i.length;return t?i[t-1]:void 0}var Gg=qC;function $C(i,t){return t.length<2?i:jc(i,Ry(t,0,-1))}var Fg=$C;function XC(i,t){return Lg(i,t)}var Vp=XC;function YC(i,t){return t=Ur(t,i),i=Fg(i,t),i==null||delete i[Ni(Gg(t))]}var jg=YC;function KC(i){return _y(i)?void 0:i}var Ug=KC;var QC=1,ZC=2,JC=4,eA=Uc(function(i,t){var e={};if(i==null)return e;var r=!1;t=Dc(t,function(n){return n=Ur(n,i),r||(r=n.length>1),n}),Oo(i,qc(i),e),r&&(e=Qc(e,QC|ZC|JC,Ug));for(var o=t.length;o--;)jg(e,t[o]);return e}),Pa=eA;function tA(i,t,e,r){if(!It(i))return i;t=Ur(t,i);for(var o=-1,n=t.length,a=n-1,s=i;s!=null&&++o<n;){var l=Ni(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=It(u)?u:ia(t[o+1])?[]:{})}aa(s,l,c),s=s[l]}return i}var kg=tA;function rA(i,t,e){for(var r=-1,o=t.length,n={};++r<o;){var a=t[r],s=jc(i,a);e(s,a)&&kg(n,Ur(a,i),s)}return n}var Hg=rA;function oA(i,t){return Hg(i,t,function(e,r){return zg(i,r)})}var Wg=oA;var iA=Uc(function(i,t){return i==null?{}:Wg(i,t)}),no=iA;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 pl(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"&&pl(r)}return Object.freeze(i)}function qg(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 Oa=class extends Error{};function ou(i){let t={...i};return Object.setPrototypeOf(t,Object.getPrototypeOf(i)),t}function To(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 Ta(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 $g(){return typeof process<"u"}function Xg(i,t){for(let e of i)t(e.id,e.data)!==!0&&Xg(e.children,t)}function Yg(i,t){if(t(i.id,i.data)!==!0)for(let e of i.children)Yg(e,t)}var ut=class extends Array{constructor(...e){super(...e);Object.setPrototypeOf(this,ut.prototype)}deepFreeze(){let e=0;for(;e<this.length;)pl(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&&Yg(o,r)}}traverse(e){Xg(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,ut.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((p,f)=>p.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 Oa("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],d=this.modifyArrayBy(a,l);a=r,l=d.childrenArray(a);let p=u.fi;return u={...u,fi:o},l=[...l,u],l.sort((f,h)=>f.fi-h.fi),e.localIndex=l.indexOf(u),d=d.modifyArrayBy(a,l),{data:d,actual:e,reverse:{type:9,parent:s,fi:p,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)=>qg(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 To(0,o,o);{let a=n[0].fi;return To(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 To(l,l+o,o)}else return To(a.fi,s.fi,o)}}};var Ca;(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})(Ca||(Ca={}));var ve=class extends Array{constructor(...e){super(...e);Object.setPrototypeOf(this,ve.prototype)}deepFreeze(){let e=0;for(;e<this.length;)pl(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,ve.prototype);let r=e;return $g()||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,d)=>u.fi-d.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 To(0,r,r);{let n=o[0].fi;return To(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 To(s,s+r,r)}else return To(n.fi,a.fi,r)}}};function Aa(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&&!Aa(r))return null;o+=1}r=r?ou(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=ou(l),delete r[t.path[o-1]])}else{let l=e[o-1];if(l){let c=ou(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}}},Co;(r=>{function i(o,n){return fl(o,n)??o}r.apply=i;function t(o,n){return Gp(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=dt.zoomOnce(l,s[a]),l===void 0)return n;if(!Aa(l))return;a+=1}if(l===void 0)return n;if(!!Aa(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=zp([n],l);return c?c[0]:n}else return n}r.filterOp=e})(Co||(Co={}));function zp(i,t){if(t===void 0)return;let e=!1,r=i.map(o=>{let n=o.id,a=fl(o.data,t[n]);if(e=e||a!==void 0,a===void 0&&(a=o.data),o.children){let s=zp(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 nA(i,t){if(t===void 0)return;let e=!1,r=i.map(o=>{let n=o.id,a=fl(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 fl(i,t){if(!Aa(t))return t;if(i instanceof ut){let e=zp(i,t);return e!==void 0&&Object.setPrototypeOf(e,Object.getPrototypeOf(i)),e}else{if(i instanceof ve)return nA(i,t);if(Array.isArray(i)){let e=!1,r=i.map((o,n)=>{let a=fl(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 Gp(i,t);if(i&&typeof i=="object"){let e={},r=!1;for(let[o,n]of Object.entries(i)){let a=fl(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 Gp(i,t){if(i===void 0)return t;if(t===void 0)return i;if(!Aa(t))return t;if(!Aa(i))return Co.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=Gp(i===void 0?void 0:i[o],t===void 0?void 0:t[o]);r[o]=n}return r}function Kg(i,t){let e={cur:[],result:[],len:0};return i=hl(i,t,e)??i,[i,e.result]}function iu(i,t){return i===null?null:(i.cur[i.len]=t,i.len+=1,i)}function nu(i){i&&(i.len-=1)}function aA(i){if(i===null)return null;i.result.push(i.cur.slice(0,i.len))}function Qg(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=hl(n.data,t,iu(e,a));nu(e),r=r||l!==void 0,l===void 0&&(l=n.data);let c=Qg(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 sA(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=hl(n.data,t,iu(e,a));return nu(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 hl(i,t,e){if(i instanceof ut){let r=Qg(i,t,e);return r!==void 0&&Object.setPrototypeOf(r,Object.getPrototypeOf(i)),r}else{if(i instanceof ve)return sA(i,t,e);if(Array.isArray(i)){let r=!1,o=i.map((n,a)=>{let s=hl(n,t,iu(e,a));return nu(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"&&!Ta(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=hl(a,t,iu(e,n));nu(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&&aA(e),r}else return}}var Ma;(t=>{function i(e,r){let o=dt.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})(Ma||(Ma={}));var vt;(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 d=[];;){let p;if(l instanceof Je&&c.type===0&&(p=l.runOp({...c,path:u.slice(d.length)}),p===null&&(p=void 0)),p===void 0&&d.length===u.length&&(l instanceof ut||l instanceof ve||l instanceof de?p=l.runOp(c):p=Ca.runOp(l,c)),p!==void 0)if(p!==null){let m=p.data;for(let y=d.length-1;y>=0;y--){let g=u[y],b=d[y];if(b instanceof ut){if(typeof g=="number")throw new Error("illegal arg");m=b.modifyById(g,m)}else if(b instanceof ve){if(typeof g=="number")throw new Error("illegal arg");m=b.modifyById(g,m)}else if(b instanceof de){if(typeof g=="number")throw new Error("illegal arg");m=b.modifyById(g,m)}else if(b instanceof Je){let w={...b,[g]:m};m=Object.setPrototypeOf(w,Je.prototype)}else if(typeof b=="object")if(Array.isArray(b)){if(typeof g=="string"&&(g=parseInt(g),isNaN(g)))throw new Error("Invalid path");let w=m;m=[...b],m[g]=w}else m={...b,[g]:m};else return null}return{data:m,actual:{...p.actual,path:u},reverse:{...p.reverse,path:u}}}else return null;let f=u[d.length],h;if(l instanceof ut){if(typeof f=="number")throw new Error("");h=l.get(f)?.data}else if(l instanceof ve){if(typeof f=="number")throw new Error("");h=l.get(f)?.data}else l!==null&&(h=l[f]);if(h!==void 0)d.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})(vt||(vt={}));var ml;(l=>{function i(){return[]}l.empty=i;function t(c,u){let d=[];for(let p of c){let[f,...h]=p.path;f===u&&d.push({...p,path:h})}return d}l.removePrefix=t;function e(c,u){return c.map(d=>({...d,path:[u,...d.path]}))}l.addPrefix=e;function r(c,u){return[...c,...u]}l.concat=r;function o(c,u){return[...c.filter(p=>!u.some(f=>vt.subsumed(p,f))),...u]}l.compress=o;function n(c,u){return c.every(d=>u.every(p=>vt.commutative(d,p)))}l.commutative=n;function a(c,u){for(let d of u){let p=s(c,d);p!==null&&(c=p.data)}return c}l.applyAll=a;function s(c,u){var d=c;let p=[],f=[];for(let h of u)try{if(h.type===3||h.type===5&&h.path[h.path.length-1]==="variables"){let m,y,g;if(h.type===3?(m=dt.zoom(d,[...h.path,h.id]),g=vt.apply(d,{...h,type:2})):(m=dt.zoom(d,[...h.path,h.id,"value"]),g=vt.apply(d,h)),g!==null){d=g.data;let[b,w]=Kg(d,{[h.id]:m});d=b;for(let P=0;P<w.length;P++){let S=w[P],T=S.pop();if(typeof T=="number"){let A=[T];for(let N=P+1;N<w.length;N++){let E=w[N],M=E[E.length-1];if(typeof M=="number"&&dt.equal(S,E.slice(0,E.length-1)))A.push(M),w.splice(N,1);else break}let x=dt.zoom(d,S);y=x.map((N,E)=>A.includes(E)?h.id:N),m=x,T=S.pop()}else{if(T==="alphaOverride"||T==="alpha"){m/=100;let A=m,x=dt.zoom(d,S.slice(0,S.length-2)),N=x.layers.map(E=>E.id===S[S.length-1]?{...E,data:{...E.data,[T]:A}}:E);Object.setPrototypeOf(N,Object.getPrototypeOf(x.layers)),x.layers=N}y=h.id}p.push({type:0,path:S,props:{[T]:m}}),f.push({type:0,path:S,props:{[T]:y}})}f.push(g.reverse),p.push(g.actual)}}else{let m=vt.apply(d,h);m!==null&&(p.push(m.actual),d=m.data,f.push(m.reverse))}}catch(m){if(m instanceof Oa)return null;throw m}return{data:d,actual:p,reverse:f.reverse()}}l.apply=s})(ml||(ml={}));var Zg=Symbol(),lA=Symbol(),su=Symbol(),Cn=class{reportOp(t,e,r=[]){let o=this;if(e===null)return;o._current=e.data;let n=r;for(;!(o instanceof au);){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[su];r&&r(),delete this._children[t]}}}},jp=class extends Cn{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,Ca.runOp(this._current,t),t.path)}},Up=class extends Cn{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))}},Jg={get(i,t){if(t===su)return()=>{i._parent=null};if(t===Zg)return i._current;if(t===lA)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=lu(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]}}},cA={...Jg,set(i,t,e){let r={type:0,props:{[t]:wt(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}},uA={...Jg,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}},Ia=class extends Cn{constructor(t,e,r){super(),this._children={},this._parent=t,this._path=e,this._current=r,this[su]=()=>{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=lu(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)}},Ea=class extends Cn{constructor(t,e,r){super(),this._children={},this._parent=t,this._path=e,this._current=r,this[su]=()=>{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=lu(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 Fp(i,t,e){if(i.length>0){let r=i[i.length-1];if(r.type===0&&t.type===0&&dt.equal(r.path,e)){Object.assign(r.props,t.props);return}}i.push({...t,path:e})}var au=class extends Cn{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){Fp(this.ts,e,t),Fp(this.actual,r,t),Fp(this.reverse,o,t)}result(){return{data:this._current,ts:this.ts,actual:this.actual,reverse:this.reverse.reverse()}}};function lu(i,t,e){return e instanceof ut?new Ia(i,t,e):e instanceof ve?new Ea(i,t,e):e instanceof de?new Proxy(new Up(i,t,e),uA):e!==null&&typeof e=="object"?Ta(e)?e:new Proxy(new jp(i,t,e),cA):e}function kp(i){let t=new au(i);return[lu(t,"",i),t]}function Di(i,t){let[e,r]=kp(i);return t(e),r.result()}function wt(i){return i instanceof Ia||i instanceof Ea?i._current:i!==null&&typeof i=="object"?i[Zg]:i}var dt;(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 ut||n instanceof Ia)&&typeof a=="string")return n.data(a);if((n instanceof ve||n instanceof Ea)&&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})(dt||(dt={}));function e0(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 Ue(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 cu=class{},yl=class extends cu{constructor(e){super();this.id=e}},gl=class extends cu{constructor(e){super();this.data=e}};var Wp;try{Wp=new TextDecoder}catch{}var fe,Ri,G=0;var l0=[],qp=l0,$p=0,wr={},Ze,_i,kr=0,Ao=0,Br,oi,mr=[],rt,t0={useRecords:!1,mapsAsObjects:!0},xl=class{},Yp=new xl;Yp.name="MessagePack 0xC1";var Na=!1,Mo=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 f0(()=>(du(),this?this.unpack(t,e):Mo.prototype.unpack.call(t0,t,e)));Ri=e>-1?e:t.length,G=0,$p=0,Ao=0,_i=null,qp=l0,Br=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 Mo){if(wr=this,this.structures)return Ze=this.structures,uu();(!Ze||Ze.length>0)&&(Ze=[])}else wr=t0,(!Ze||Ze.length>0)&&(Ze=[]);return uu()}unpackMultiple(t,e){let r,o=0;try{Na=!0;let n=t.length,a=this?this.unpack(t,n):hu.unpack(t,n);if(e){for(e(a);G<n;)if(o=G,e(uu())===!1)return}else{for(r=[a];G<n;)o=G,r.push(uu());return r}}catch(n){throw n.lastPosition=o,n.values=r,n}finally{Na=!1,du()}}_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 uu(){try{if(!wr.trusted&&!Na){let t=Ze.sharedLength||0;t<Ze.length&&(Ze.length=t)}let i=Et();if(G==Ri)Ze.restoreStructures&&r0(),Ze=null,fe=null,oi&&(oi=null);else if(G>Ri){let t=new Error("Unexpected end of MessagePack data");throw t.incomplete=!0,t}else if(!Na)throw new Error("Data read, but end of buffer not reached");return i}catch(i){throw Ze.restoreStructures&&r0(),du(),(i instanceof RangeError||i.message.startsWith("Unexpected end of buffer"))&&(i.incomplete=!0),i}}function r0(){for(let i in Ze.restoreStructures)Ze[i]=Ze.restoreStructures[i];Ze.restoreStructures=null}function Et(){let i=fe[G++];if(i<160)if(i<128){if(i<64)return i;{let t=Ze[i&63]||wr.getStructures&&c0()[i&63];return t?(t.read||(t.read=Kp(t,i&63)),t.read()):i}}else if(i<144)if(i-=128,wr.mapsAsObjects){let t={};for(let e=0;e<i;e++)t[d0()]=Et();return t}else{let t=new Map;for(let e=0;e<i;e++)t.set(Et(),Et());return t}else{i-=144;let t=new Array(i);for(let e=0;e<i;e++)t[e]=Et();return t}else if(i<192){let t=i-160;if(Ao>=G)return _i.slice(G-kr,(G+=t)-kr);if(Ao==0&&Ri<140){let e=t<16?Qp(t):u0(t);if(e!=null)return e}return Xp(t)}else{let t;switch(i){case 192:return null;case 193:return Br?(t=Et(),t>0?Br[1].slice(Br.position1,Br.position1+=t):Br[0].slice(Br.position0,Br.position0-=t)):Yp;case 194:return!1;case 195:return!0;case 196:return Hp(fe[G++]);case 197:return t=rt.getUint16(G),G+=2,Hp(t);case 198:return t=rt.getUint32(G),G+=4,Hp(t);case 199:return An(fe[G++]);case 200:return t=rt.getUint16(G),G+=2,An(t);case 201:return t=rt.getUint32(G),G+=4,An(t);case 202:if(t=rt.getFloat32(G),wr.useFloat32>2){let e=fu[(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 wr.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 wr.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 s0(fe[G++]&63);{let e=mr[t];if(e)return e.read?(G++,e.read(Et())):e.noBuffer?(G++,e()):e(fe.subarray(G,++G));throw new Error("Unknown extension "+t)}case 213:return t=fe[G],t==114?(G++,s0(fe[G++]&63,fe[G++])):An(2);case 214:return An(4);case 215:return An(8);case 216:return An(16);case 217:return t=fe[G++],Ao>=G?_i.slice(G-kr,(G+=t)-kr):pA(t);case 218:return t=rt.getUint16(G),G+=2,Ao>=G?_i.slice(G-kr,(G+=t)-kr):fA(t);case 219:return t=rt.getUint32(G),G+=4,Ao>=G?_i.slice(G-kr,(G+=t)-kr):hA(t);case 220:return t=rt.getUint16(G),G+=2,i0(t);case 221:return t=rt.getUint32(G),G+=4,i0(t);case 222:return t=rt.getUint16(G),G+=2,n0(t);case 223:return t=rt.getUint32(G),G+=4,n0(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 dA=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function Kp(i,t){function e(){if(e.count++>2){let o=i.read=new Function("r","return function(){return {"+i.map(n=>dA.test(n)?n+":r()":"["+JSON.stringify(n)+"]:r()").join(",")+"}}")(Et);return i.highByte===0&&(i.read=o0(t,i.read)),o()}let r={};for(let o=0,n=i.length;o<n;o++){let a=i[o];r[a]=Et()}return r}return e.count=0,i.highByte===0?o0(t,e):e}var o0=(i,t)=>function(){let e=fe[G++];if(e===0)return t();let r=i<32?-(i+(e<<5)):i+(e<<5),o=Ze[r]||c0()[r];if(!o)throw new Error("Record id is not defined for "+r);return o.read||(o.read=Kp(o,i)),o.read()};function c0(){let i=f0(()=>(fe=null,wr.getStructures()));return Ze=wr._mergeStructures(i,Ze)}var Xp=pu,pA=pu,fA=pu,hA=pu;function pu(i){let t;if(i<16&&(t=Qp(i)))return t;if(i>64&&Wp)return Wp.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+=Jt.apply(String,r),r.length=0)}return r.length>0&&(t+=Jt.apply(String,r)),t}function i0(i){let t=new Array(i);for(let e=0;e<i;e++)t[e]=Et();return t}function n0(i){if(wr.mapsAsObjects){let t={};for(let e=0;e<i;e++)t[d0()]=Et();return t}else{let t=new Map;for(let e=0;e<i;e++)t.set(Et(),Et());return t}}var Jt=String.fromCharCode;function u0(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 Jt.apply(String,e)}function Qp(i){if(i<4)if(i<2){if(i===0)return"";{let t=fe[G++];if((t&128)>1){G-=1;return}return Jt(t)}}else{let t=fe[G++],e=fe[G++];if((t&128)>0||(e&128)>0){G-=2;return}if(i<3)return Jt(t,e);let r=fe[G++];if((r&128)>0){G-=3;return}return Jt(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 Jt(t,e,r,o);{let n=fe[G++];if((n&128)>0){G-=5;return}return Jt(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 Jt(t,e,r,o,n,a);let s=fe[G++];if((s&128)>0){G-=7;return}return Jt(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 Jt(t,e,r,o,n,a,s,l);{let c=fe[G++];if((c&128)>0){G-=9;return}return Jt(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 Jt(t,e,r,o,n,a,s,l,c,u);let d=fe[G++];if((d&128)>0){G-=11;return}return Jt(t,e,r,o,n,a,s,l,c,u,d)}else{let c=fe[G++],u=fe[G++],d=fe[G++],p=fe[G++];if((c&128)>0||(u&128)>0||(d&128)>0||(p&128)>0){G-=12;return}if(i<14){if(i===12)return Jt(t,e,r,o,n,a,s,l,c,u,d,p);{let f=fe[G++];if((f&128)>0){G-=13;return}return Jt(t,e,r,o,n,a,s,l,c,u,d,p,f)}}else{let f=fe[G++],h=fe[G++];if((f&128)>0||(h&128)>0){G-=14;return}if(i<15)return Jt(t,e,r,o,n,a,s,l,c,u,d,p,f,h);let m=fe[G++];if((m&128)>0){G-=15;return}return Jt(t,e,r,o,n,a,s,l,c,u,d,p,f,h,m)}}}}}function Hp(i){return wr.copyBuffers?Uint8Array.prototype.slice.call(fe,G,G+=i):fe.subarray(G,G+=i)}function An(i){let t=fe[G++];if(mr[t])return mr[t](fe.subarray(G,G+=i));throw new Error("Unknown extension type "+t)}var a0=new Array(4096);function d0(){let i=fe[G++];if(i>=160&&i<192){if(i=i-160,Ao>=G)return _i.slice(G-kr,(G+=i)-kr);if(!(Ao==0&&Ri<180))return Xp(i)}else return G--,Et();let t=(i<<5^(i>1?rt.getUint16(G):i>0?fe[G]:0))&4095,e=a0[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=[],a0[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?Qp(i):u0(i);return s!=null?e.string=s:e.string=Xp(i)}var s0=(i,t)=>{var e=Et();let r=i;t!==void 0&&(i=i<32?-((t<<5)+i):(t<<5)+i,e.highByte=t);let o=Ze[i];return o&&o.isShared&&((Ze.restoreStructures||(Ze.restoreStructures=[]))[i]=o),Ze[i]=e,e.read=Kp(e,r),e.read()},p0=typeof self=="object"?self:global;mr[0]=()=>{};mr[0].noBuffer=!0;mr[101]=()=>{let i=Et();return(p0[i[0]]||Error)(i[1])};mr[105]=i=>{let t=rt.getUint32(G-4);oi||(oi=new Map);let e=fe[G],r;e>=144&&e<160||e==220||e==221?r=[]:r={};let o={target:r};oi.set(t,o);let n=Et();return o.used?Object.assign(r,n):(o.target=n,n)};mr[112]=i=>{let t=rt.getUint32(G-4),e=oi.get(t);return e.used=!0,e.target};mr[115]=()=>new Set(Et());var Zp=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(i=>i+"Array");mr[116]=i=>{let t=i[0],e=Zp[t];if(!e)throw new Error("Could not find typed array for code "+t);return new p0[e](Uint8Array.prototype.slice.call(i,1).buffer)};mr[120]=()=>{let i=Et();return new RegExp(i[0],i[1])};mr[98]=i=>{let t=(i[0]<<24)+(i[1]<<16)+(i[2]<<8)+i[3],e=G;G+=t-4,Br=[Et(),Et()],Br.position0=0,Br.position1=0;let r=G;G=e;try{return Et()}finally{G=r}};mr[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 f0(i){let t=Ri,e=G,r=$p,o=kr,n=Ao,a=_i,s=qp,l=oi,c=Br,u=new Uint8Array(fe.slice(0,Ri)),d=Ze,p=Ze.slice(0,Ze.length),f=wr,h=Na,m=i();return Ri=t,G=e,$p=r,kr=o,Ao=n,_i=a,qp=s,oi=l,Br=c,fe=u,Na=h,Ze=d,Ze.splice(0,Ze.length,...p),wr=f,rt=new DataView(fe.buffer,fe.byteOffset,fe.byteLength),m}function du(){fe=null,oi=null,Ze=null}function h0(i){i.unpack?mr[i.type]=i.unpack:mr[i.type]=i}var fu=new Array(147);for(let i=0;i<256;i++)fu[i]=+("1e"+Math.floor(45.15-i*.30103));var hu=new Mo({useRecords:!1}),mA=hu.unpack,yA=hu.unpackMultiple,gA=hu.unpack,mu={NEVER:0,ALWAYS:1,DECIMAL_ROUND:3,DECIMAL_FIT:4},xA=new Float32Array(1),wF=new Uint8Array(xA.buffer,0,4);var yu;try{yu=new TextEncoder}catch{}var gu,ef,xu=typeof Buffer<"u",Jp=xu?Buffer.allocUnsafeSlow:Uint8Array,x0=xu?Buffer:Uint8Array,m0=xu?4294967296:2144337920,X,Lt,k=0,Io,Eo=null,bA=/[\u0080-\uFFFF]/,bl=Symbol("record-id"),Mn=class extends Mo{constructor(t){super(t),this.offset=0;let e,r,o,n,a,s,l=0,c=x0.prototype.utf8Write?function(x,N,E){return X.utf8Write(x,N,E)}:yu&&yu.encodeInto?function(x,N){return yu.encodeInto(x,X.subarray(N)).written}:!1,u=this;t||(t={});let d=t&&t.sequential,p=t.structures||t.saveStructures,f=t.maxSharedStructures;if(f==null&&(f=p?32:0),f>8160)throw new Error("Maximum maxSharedStructure is 8160");let h=t.maxOwnStructures;h==null&&(h=p?32:64),d&&!t.saveStructures&&(this.structures=[]);let m=f>32||h+f>64,y=f+64,g=f+h+64;if(g>8256)throw new Error("Maximum maxSharedStructure + maxOwnStructure is 8192");let b=[],w=0,P=0;this.pack=this.encode=function(x,N){if(X||(X=new Jp(8192),Lt=new DataView(X.buffer,0,8192),k=0),Io=X.length-10,Io-k<2048?(X=new Jp(X.length),Lt=new DataView(X.buffer,0,X.length),Io=X.length-10,k=0):k=k+7&2147483640,r=k,s=u.structuredClone?new Map:null,u.bundleStrings?(Eo=["",""],X[k++]=214,X[k++]=98,Eo.position=k-r,k+=4):Eo=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 M=0;M<E;M++){let D=o[M];if(!D)continue;let _,R=o.transitions;for(let V=0,U=D.length;V<U;V++){let B=D[V];_=R[B],_||(_=R[B]=Object.create(null)),R=_}R[bl]=M+64}l=E}d||(o.nextId=E+64)}n&&(n=!1),a=o||[];try{if(S(x),Eo){Lt.setUint32(Eo.position+r,k-Eo.position-r);let E=Eo;Eo=null,S(E[0]),S(E[1])}if(u.offset=k,s&&s.idsToInsert){k+=s.idsToInsert.length*6,k>Io&&A(k),u.offset=k;let E=SA(X.subarray(r,k),s.idsToInsert);return s=null,E}return N&v0?(X.start=r,X.end=k,X):X.subarray(r,k)}finally{if(o){if(P<10&&P++,w>1e4)o.transitions=null,P=0,w=0,b.length>0&&(b=[]);else if(b.length>0&&!d){for(let E=0,M=b.length;E<M;E++)b[E][bl]=0;b=[]}if(n&&u.saveStructures){let E=o.sharedLength||f;o.length>E&&(o=o.slice(0,E));let M=X.subarray(r,k);return u.saveStructures(o,l)===!1?(u._mergeStructures(u.getStructures()),u.pack(x)):(l=E,M)}}N&MA&&(k=r)}};let S=x=>{k>Io&&(X=A(k));var N=typeof x,E;if(N==="string"){let M=x.length;if(Eo&&M>=8&&M<4096){let R=bA.test(x);Eo[R?0:1]+=x,X[k++]=193,S(R?-M:M);return}let D;M<32?D=1:M<256?D=2:M<65536?D=3:D=5;let _=M*3;if(k+_>Io&&(X=A(k+_)),M<64||!c){let R,V,U,B=k+D;for(R=0;R<M;R++)V=x.charCodeAt(R),V<128?X[B++]=V:V<2048?(X[B++]=V>>6|192,X[B++]=V&63|128):(V&64512)===55296&&((U=x.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-D}else E=c(x,k+D,_);E<32?X[k++]=160|E:E<256?(D<2&&X.copyWithin(k+2,k+1,k+1+E),X[k++]=217,X[k++]=E):E<65536?(D<3&&X.copyWithin(k+3,k+2,k+2+E),X[k++]=218,X[k++]=E>>8,X[k++]=E&255):(D<5&&X.copyWithin(k+5,k+3,k+3+E),X[k++]=219,Lt.setUint32(k,E),k+=4),k+=E}else if(N==="number")if(x>>>0===x)x<64?X[k++]=x:x<256?(X[k++]=204,X[k++]=x):x<65536?(X[k++]=205,X[k++]=x>>8,X[k++]=x&255):(X[k++]=206,Lt.setUint32(k,x),k+=4);else if(x>>0===x)x>=-32?X[k++]=256+x:x>=-128?(X[k++]=208,X[k++]=x+256):x>=-32768?(X[k++]=209,Lt.setInt16(k,x),k+=2):(X[k++]=210,Lt.setInt32(k,x),k+=4);else{let M;if((M=this.useFloat32)>0&&x<4294967296&&x>=-2147483648){X[k++]=202,Lt.setFloat32(k,x);let D;if(M<4||(D=x*fu[(X[k]&127)<<1|X[k+1]>>7])>>0===D){k+=4;return}else k--}X[k++]=203,Lt.setFloat64(k,x),k+=8}else if(N==="object")if(!x)X[k++]=192;else{if(s){let D=s.get(x);if(D){if(!D.id){let _=s.idsToInsert||(s.idsToInsert=[]);D.id=_.push(D)}X[k++]=214,X[k++]=112,Lt.setUint32(k,D.id),k+=4;return}else s.set(x,{offset:k-r})}let M=x.constructor;if(M===Object)T(x,!0);else if(M===Array){E=x.length,E<16?X[k++]=144|E:E<65536?(X[k++]=220,X[k++]=E>>8,X[k++]=E&255):(X[k++]=221,Lt.setUint32(k,E),k+=4);for(let D=0;D<E;D++)S(x[D])}else if(M===Map){E=x.size,E<16?X[k++]=128|E:E<65536?(X[k++]=222,X[k++]=E>>8,X[k++]=E&255):(X[k++]=223,Lt.setUint32(k,E),k+=4);for(let[D,_]of x)S(D),S(_)}else{for(let D=0,_=gu.length;D<_;D++){let R=ef[D];if(x instanceof R){let V=gu[D];if(V.write){V.type&&(X[k++]=212,X[k++]=V.type,X[k++]=0),S(V.write.call(this,x));return}let U=X,B=Lt,q=k;X=null;let j;try{j=V.pack.call(this,x,F=>(X=U,U=null,k+=F,k>Io&&A(k),{target:X,targetView:Lt,position:k-F}),S)}finally{U&&(X=U,Lt=B,k=q,Io=X.length-10)}j&&(j.length+k>Io&&A(j.length+k),k=vA(j,X,k,V.type));return}}T(x,!x.hasOwnProperty)}}else if(N==="boolean")X[k++]=x?195:194;else if(N==="bigint"){if(x<BigInt(1)<<BigInt(63)&&x>=-(BigInt(1)<<BigInt(63)))X[k++]=211,Lt.setBigInt64(k,x);else if(x<BigInt(1)<<BigInt(64)&&x>0)X[k++]=207,Lt.setBigUint64(k,x);else if(this.largeBigIntToFloat)X[k++]=203,Lt.setFloat64(k,Number(x));else throw new RangeError(x+" was too large to fit in MessagePack 64-bit integer format, set largeBigIntToFloat to convert to float-64");k+=8}else if(N==="undefined")this.encodeUndefinedAsNil?X[k++]=192:(X[k++]=212,X[k++]=0,X[k++]=0);else if(N==="function")S(this.writeFunction&&this.writeFunction());else throw new Error("Unknown type: "+N)},T=this.useRecords===!1?this.variableMapSize?x=>{let N=Object.keys(x),E=N.length;E<16?X[k++]=128|E:E<65536?(X[k++]=222,X[k++]=E>>8,X[k++]=E&255):(X[k++]=223,Lt.setUint32(k,E),k+=4);let M;for(let D=0;D<E;D++)S(M=N[D]),S(x[M])}:(x,N)=>{X[k++]=222;let E=k-r;k+=2;let M=0;for(let D in x)(N||x.hasOwnProperty(D))&&(S(D),S(x[D]),M++);X[E+++r]=M>>8,X[E+r]=M&255}:x=>{let N=Object.keys(x),E,M=a.transitions||(a.transitions=Object.create(null)),D=0;for(let R=0,V=N.length;R<V;R++){let U=N[R];E=M[U],E||(E=M[U]=Object.create(null),D++),M=E}let _=M[bl];if(_)_>=96&&m?(X[k++]=((_-=96)&31)+96,X[k++]=_>>5):X[k++]=_;else{_=a.nextId,_||(_=64),_<y&&this.shouldShareStructure&&!this.shouldShareStructure(N)?(_=a.nextOwnId,_<g||(_=y),a.nextOwnId=_+1):(_>=g&&(_=y),a.nextId=_+1);let R=N.highByte=_>=96&&m?_-96>>5:-1;M[bl]=_,a[_-64]=N,_<y?(N.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++]=_),D&&(w+=P*D),b.length>=h&&(b.shift()[bl]=0),b.push(M),S(N))}for(let R=0,V=N.length;R<V;R++)S(x[N[R]])},A=x=>{let N;if(x>16777216){if(x-r>m0)throw new Error("Packed buffer would be larger than maximum buffer size");N=Math.min(m0,Math.round(Math.max((x-r)*(x>67108864?1.25:2),4194304)/4096)*4096)}else N=(Math.max(x-r<<2,X.length-1)>>12)+1<<12;let E=new Jp(N);return Lt=new DataView(E.buffer,0,N),X.copy?X.copy(E,0,r,x):E.set(X.slice(r,x)),k-=r,r=0,Io=E.length-10,X=E}}useBuffer(t){X=t,Lt=new DataView(X.buffer,X.byteOffset,X.byteLength),k=0}};ef=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,xl];gu=[{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?y0(i,16,t):g0(xu?Buffer.from(i):new Uint8Array(i),t)}},{pack(i,t){let e=i.constructor;e!==x0&&this.structuredClone?y0(i,Zp.indexOf(e.name),t):g0(i,t)}},{pack(i,t){let{target:e,position:r}=t(1);e[r]=193}}];function y0(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 g0(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 vA(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 SA(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 Li(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)");ef.unshift(i.Class),gu.unshift(i)}h0(i)}var b0=new Mn({useRecords:!1}),wA=b0.pack,PA=b0.pack;var{NEVER:OA,ALWAYS:TA,DECIMAL_ROUND:CA,DECIMAL_FIT:AA}=mu,v0=512,MA=1024;var S0=new Mn({structuredClone:!0});Li({Class:de.prototype.constructor,type:1,write(i){return{...i}},read(i){return Object.setPrototypeOf(i,de.prototype),i}});Li({Class:ve.prototype.constructor,type:2,write(i){return[...i]},read(i){return Object.setPrototypeOf(i,ve.prototype),i}});Li({Class:ut.prototype.constructor,type:3,write(i){return[...i]},read(i){return Object.setPrototypeOf(i,ut.prototype),i}});Li({Class:yl.prototype.constructor,type:4,write(i){return i.id},read(i){return new yl(i)}});Li({Class:gl.prototype.constructor,type:5,write(i){return i.data},read(i){return new gl(i)}});Li({Class:Je.prototype.constructor,type:6,write(i){return{...i}},read(i){return Object.setPrototypeOf(i,Je.prototype),i}});function IA(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 tf(i){if(Ta(i))return i;if(Array.isArray(i))return i.map(tf);if(typeof i=="object"&&i!==null){let t={};for(let e of Object.keys(i).sort())t[e]=tf(i[e]);return Object.setPrototypeOf(t,Object.getPrototypeOf(i)),t}else return i}var bu;(r=>{function i(o){return S0.pack(o)}r.serialize=i;function t(o){return S0.unpack(o)}r.deserialize=t;function e(o){return IA(i(tf(o))).toString()}r.checksum=e})(bu||(bu={}));var zi="personal camera",Gi="a218fcc3-276b-49b9-b485-49037fd14f5f",A0=2960946;var Bt=5526619;var Da;(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 g=f.sub(m,h),b=f.sub(y,h),w=f.dot(g,b)/f.dot(g,g),P=f.scalarMultiply(g,w);return f.add(h,P)}f.projectionOnto=u;function d(h,m,y){return s(h,u(h,m,y))}f.projectionOntoDistance=d;function p(h,m){return[(h[0]+m[0])*.5,(h[1]+m[1])*.5]}f.center=p})(Da||(Da={}));var Bi;(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})(Bi||(Bi={}));var w0;(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})(w0||(w0={}));var P0;(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})(P0||(P0={}));var Vi;(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})(Vi||(Vi={}));var jt;(p=>{function i(f){return typeof f=="object"&&typeof f.r=="number"&&typeof f.g=="number"&&typeof f.b=="number"}p.isRGB=i,p.white={r:1,g:1,b:1},p.red={r:1,g:0,b:0},p.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}}p.toRgb255a1=o;function n(f){return{r:f.r,g:f.g,b:f.b}}p.clone=n;function a(f){return f=Math.floor(f),{r:(f>>16&255)/255,g:(f>>8&255)/255,b:(f&255)/255}}p.fromHex=a;function s(f){return Math.round(f.r*255)*65536+Math.round(f.g*255)*256+Math.round(f.b*255)}p.toHex=s;function l(f,h){return f.r===h.r&&f.g===h.g&&f.b===h.b}p.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)}p.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}}p.lerp=u;function d(f){return It(f)?"r"in f&&"g"in f&&"b"in f&&!("a"in f):!1}p.is=d})(jt||(jt={}));var Le;(u=>{u.white={...jt.white,a:1};function t(d){return It(d)?"r"in d&&"g"in d&&"b"in d&&"a"in d:!1}u.is=t,u.transparent={...jt.white,a:0};function r(d){return{r:d[0],g:d[1],b:d[2],a:d[3]}}u.from0to1=r;function o(d,p){return{...jt.fromHex(d),a:p}}u.fromHexAndA=o;function n(d){return{r:Math.round(d.r*255),g:Math.round(d.g*255),b:Math.round(d.b*255),a:d.a}}u.toRgb255a1=n;function a(d,p){return jt.equals(d,p)&&d.a===p.a}u.equals=a;function s(d,p){return jt.equalsFixed(d,p)&&d.a.toFixed(2)===p.a.toFixed(2)}u.equalsFixed=s;function l(d,p,f){return{r:d.r+(p.r-d.r)*f,g:d.g+(p.g-d.g)*f,b:d.b+(p.b-d.b)*f,a:d.a+(p.a-d.a)*f}}u.lerp=l;function c({r:d,g:p,b:f,a:h}=u.white){return`rgba(${d*255}, ${p*255}, ${f*255}, ${h})`}u.toStyle=c})(Le||(Le={}));var vu;(t=>t.identity={position:[0,0,0],rotation:[0,0,0],scale:[1,1,1],pivot:[0,0,0],pivotRotation:[0,0,0]})(vu||(vu={}));var O0;(t=>t.defaultData={mass:1,stiffness:80,damping:10,velocity:0})(O0||(O0={}));var T0;(t=>t.defaultData={control1:[.5,0],control2:[.5,1]})(T0||(T0={}));var C0;(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]))(C0||(C0={}));function rf(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 ao;(e=>{e.all=["PerspectiveCamera","OrthographicCamera"];function t(r){return e.all.includes(r)}e.is=t})(ao||(ao={}));var Fi;(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})(Fi||(Fi={}));var No;(r=>{function i(o,n=.1){return{disabled:!1,type:"linear",hideBase:!1,count:3,radial:{radius:Math.max(typeof o[0]=="number"?o[0]:1,typeof o[1]=="number"?o[1]:1)*2,start:0,end:360,alignment:!1,axis:"y",scale:[1,1,1],rotation:[0,0,0],position:[0,0,0],pivot:[0,0,0],pivotRotation:[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",pivot:[0,0,0],pivotRotation:[0,0,0]},linear:{scale:[1,1,1],rotation:[0,0,0],position:[(typeof o[0]=="number"?o[0]+o[0]:1)*n,0,0],pivot:[0,0,0],pivotRotation:[0,0,0]},grid:{count:[2,2,2],size:o.map(a=>(typeof a=="number"?a:1)*(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(EA.forEach(s=>{Object.assign(a,{[s]:n[s]??o[s]})}),a.radial={...o.radial},n.radial){let s=o.radial,l=n.radial;NA.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;DA.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;_A.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;RA.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;LA.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})(No||(No={}));var Su;(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})(Su||(Su={}));var EA=["count"],NA=["radius","start","end","position","scale","rotation"],DA=["position","scale","rotation"],_A=["count","size"],RA=["count","position","scale","rotation"],LA=["strength","scale","rotation","position","movement","seed","freqScale"];var wu;(e=>{e.all=["PointLight","SpotLight","DirectionalLight","HemisphereLight"];function t(r){return e.all.includes(r)}e.is=t})(wu||(wu={}));var Pu;(e=>{function i(r){return t(r)}e.defaultData=i;function t(r){if(r==="PointLight")return{type:r,color:Le.white,intensity:1,distance:2e3,decay:1,shadows:!0,shadowResolution:1024,shadowRadius:1,penumbraSize:.5,depth:1e5};if(r==="SpotLight")return{type:r,color:Le.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:Le.white,intensity:1,shadows:!0,size:2e3,depth:1e5,penumbraSize:.5,shadowResolution:1024,shadowRadius:1};throw new Error("not implemented")}})(Pu||(Pu={}));var _a;(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}))(_a||(_a={}));var ji;(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]})(ji||(ji={}));var of;(e=>{e.defaultData={castShadow:!0,receiveShadow:!0};function t(r,o){return r.castShadow===o.castShadow&&r.receiveShadow===o.receiveShadow}e.equals=t})(of||(of={}));var nf;(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})(nf||(nf={}));var Ou;(t=>t.defaultData={...nf.defaultData,...of.defaultData})(Ou||(Ou={}));var M0;(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})(M0||(M0={}));var Ra;(e=>(e.defaultVideo={data:"",thumb:"/_assets/_videos/catThumb.png",type:"video",name:"Cat video"},e.maxSize=3e7))(Ra||(Ra={}));var I0;(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})(I0||(I0={}));function N0(i){return i.type!=="displace"}var E0;(t=>{function i(e){return e==="phong"||e==="toon"||e==="lambert"||e==="physical"}t.is=i})(E0||(E0={}));var D0=["mode","gradientType","noiseType","displacementType","projection","cnormal","crop","axis","side"],_0=["wrapping","image","video","name","minFilter","magFilter"],Nt;(n=>{function i(a,s){let{texture:l,...c}=s;if(Object.assign(a,c),l){let u=a.texture;u&&Object.assign(u,l)}}n.patch=i;function t(a){return{...n.defaultData("color"),color:a}}n.defaultColorLayer=t;function e(a,s){return a==="light"&&s?r(s):o(a)}n.defaultData=e;function r(a){let s={mode:0,isMask:!1,visible:!0,bumpMap:void 0,bumpMapIntensity:5,roughnessMap:void 0,alphaOverride:1};switch(a){case"phong":return{...s,category:"phong",specular:{r:.2,g:.2,b:.2},shininess:5,type:"light",visible:!0,mode:0,occlusion:!0,alpha:.6};case"toon":return{...s,category:"toon",specular:{r:.2,g:.2,b:.2},shininess:10,type:"light",alpha:1};case"lambert":return{...s,category:"lambert",emissive:{r:0,g:0,b:0},type:"light",alpha:1,visible:!0,mode:0,occlusion:!0};case"physical":return{...s,category:"physical",roughness:.2,metalness:.2,reflectivity:.2,type:"light",alpha:1,visible:!0,mode:0,occlusion:!0}}}function o(a){let s={alpha:1,mode:0,isMask:!1,visible:!0};switch(a){case"texture":return{...s,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{...s,type:"video",size:[128,128],blending:0,axis:"x",side:2,projection:0,texture:{video:Ra.defaultVideo,wrapping:1001,repeat:[1,1],offset:[0,0],rotation:0,minFilter:1008,magFilter:1006},crop:!1};case"color":return{...s,type:"color",color:jt.fromHex(Bt)};case"depth":return{...s,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{...s,type:"normal",cnormal:[1,1,1]};case"gradient":return{...s,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{...s,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{...s,type:"fresnel",color:Le.fromHexAndA(16777215,1),bias:.1,scale:1,intensity:2,factor:1};case"rainbow":return{...s,type:"rainbow",filmThickness:30,movement:0,wavelengths:[0,0,0],noiseStrength:0,noiseScale:1,offset:[0,0,0]};case"toon":return{...s,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:Le.fromHexAndA(0,0),offset:[0,0,0]};case"outline":return{...s,type:"outline",outlineColor:Le.fromHexAndA(0,1),contourColor:Le.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{...s,type:"matcap",texture:{image:"matcap_0",wrapping:1001,repeat:[1,1],offset:[0,0],rotation:0,minFilter:1008,magFilter:1006}};case"transmission":return{...s,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{...s,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}}}})(Nt||(Nt={}));var Wt;(u=>{function i(d){return!d.layers.some(f=>f.data.type==="texture"&&f.data.projection!==0||f.data.type==="depth"&&!f.data.isWorldSpace||f.data.type==="noise"||f.data.type==="displace")}u.isMergable=i;function t(d){let p="";return d.layers.forEach(f=>{Object.entries(f.data).forEach(([h,m])=>{p+=`${h}${m}`,Array.isArray(m)?m.forEach(y=>p+=`${y}`):typeof m=="object"?Object.values(m).forEach(y=>{typeof y=="number"?p+=`${y.toFixed(4)}`:p+=`${y}`}):p+=`${m}`})}),p}u.getHash=t;function e(){return{layers:new ve}}u.defaultEmptyData=e;function r(d="layer1",p="layer2"){return n("phong",d,p)}u.defaultData=r;function o(d,p){return{...d,name:p}}u.withName=o;function n(d,p="layer1",f="layer2",h=jt.fromHex(16777215)){let m=new ve;return m.push({fi:0,data:Nt.defaultData("light",d),id:p}),m.push({fi:1,data:Nt.defaultData("color"),id:f}),{layers:m}}u.defaultTwoLayerData=n;function a(d,p,f="layer1",h="layer2"){let m=new ve;return m.push({fi:0,data:Nt.defaultData("light",p),id:f}),m.push({fi:1,data:Nt.defaultColorLayer(d),id:h}),{layers:m}}u.defaultColorMaterial=a;function s(d){let p=Nt.defaultData("texture");d&&Object.assign(p.texture,{image:d});let f=new ve;return f.push({fi:0,data:p,id:"layer1"}),f.push({fi:1,data:{...Nt.defaultData("transmission"),alpha:1},id:"layer2"}),f.push({fi:2,data:{...Nt.defaultData("light","lambert"),alpha:0},id:"layer3"}),{layers:f}}u.defaultUIObjectMaterial=s;function l(d,p="phong",f="layer1",h="layer2"){let m=Nt.defaultData("texture");Object.assign(m.texture,{image:d});let y=new ve;return y.push({fi:0,data:m,id:f}),y.push({fi:1,data:Nt.defaultData("light",p),id:h}),{layers:y}}u.defaultTwoLayerTextureData=l;function c(d,p="phong",f="layer1",h="layer2"){let m=Nt.defaultData("video");Object.assign(m.texture,{video:d});let y=new ve;return y.push({fi:0,data:m,id:f}),y.push({fi:1,data:Nt.defaultData("light",p),id:h}),{layers:y}}u.defaultTwoLayerVideoTextureData=c})(Wt||(Wt={}));var La;(t=>{function i(){return{points:new ve,roundness:0,shapeHoles:[],isClosed:!1}}t.defaultData=i})(La||(La={}));var Ba;(t=>{function i(){return{points:new ve,lastInsertionPlane:null,subdivisions:12,isClosed:!1,subdivisionMode:"parametric"}}t.defaultData=i})(Ba||(Ba={}));var In={type:"Ellipse",width:50,height:50,spikes:16,angle:360,innerRadius:0};var Tu;(t=>{function i(e,r){let o={...e};return BA.forEach(n=>{Object.assign(o,{[n]:r[n]??e[n]})}),o}t.merge=i})(Tu||(Tu={}));var Cu={shape:In,depth:1,offset:0,bevel:50,bevelSides:6,angle:0,twist:0,startScale:1,endScale:1,capType:"flat"},BA=["depth","offset","angle","twist","startScale","endScale"];var vl;(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})(vl||(vl={}));var Au;(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,Tu.merge(o.extrusion,r.extrusion))),o}t.merge=i})(Au||(Au={}));var Do;(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:Ba.defaultData(),extrusion:Cu};if(e==="VectorGeometry")return{width:1,height:1,type:e,subdivisions:12,shape:La.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})(Do||(Do={}));var Mu;(t=>t.defaultData={enabled:!1,useBackgroundColor:!1,color:jt.white,near:.1,far:2e3})(Mu||(Mu={}));var Iu;(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}}})(Iu||(Iu={}));var af;(t=>t.defaultData={softShadowQuality:"low"})(af||(af={}));var sf;(t=>t.defaultData={enabled:!0,color:{r:.8274509803921568,g:.8274509803921568,b:.8274509803921568},intensity:.75})(sf||(sf={}));var lf;(t=>t.defaultData={occlusion:!1,aoFullRes:!1,radius:256,bias:.5,aoColor:{r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}})(lf||(lf={}));var Sl;(t=>t.defaultData={usePhysics:!1,gravity:-10})(Sl||(Sl={}));var cf;(t=>t.defaultData={playCamera:zi,gameControlObject:null})(cf||(cf={}));var Eu;(t=>t.defaultData={backgroundColor:Le.fromHexAndA(A0,1),postprocessing:Iu.defaultData,fog:Mu.defaultData,globalPhysics:Sl.defaultData,ambient:sf.defaultData,ao:lf.defaultData,shadow:af.defaultData,publish:cf.defaultData})(Eu||(Eu={}));var Nu;(t=>t.defaultData={colliderType:"box",size:[100,100,100],colliderHelperVisible:!0,forceType:"collider",forceRange:"global",forceIntensity:.5,forceDambing:.95})(Nu||(Nu={}));var R0;(e=>{function i(r){return r==="Component"||r==="Instance"}e.isComponentRelated=i;function t(r){return r==="Empty"||r==="Instance"}e.isEmptyOrComponent=t})(R0||(R0={}));var Va;(o=>{o.identity={...vu.identity,hiddenMatrix:Vi.identity};function t(n){return{position:n.position,rotation:n.rotation,scale:n.scale,pivot:n.pivot,pivotRotation:n.pivotRotation,hiddenMatrix:n.hiddenMatrix}}o.fromObject=t;function e(n,a){return{position:a?.position||n.position,rotation:a?.rotation||n.rotation,pivot:a?.pivot||n.pivot,pivotRotation:a?.pivotRotation||n.pivotRotation,scale:a?.scale||n.scale,hiddenMatrix:a?.hiddenMatrix||n.hiddenMatrix}}o.merge=e;function r(n,a){return Mc({position:Bi.isEqual(n.position,a.position)?void 0:a.position,rotation:Bi.isEqual(n.rotation,a.rotation)?void 0:a.rotation,scale:Bi.isEqual(n.scale,a.scale)?null:a.scale,hiddenMatrix:Vi.isEqual(n.hiddenMatrix,a.hiddenMatrix)?void 0:a.hiddenMatrix})}o.diff=r})(Va||(Va={}));var Vt;(t=>t.defaultData={states:new ve,events:new ve,timelineAnimations:new de,visible:!0,raycastLock:!1,physics:ji.defaultData,pathSnapping:{pathId:null,slide:0,offset:0,orientation:"tangential"},...Va.identity,cloner:null})(Vt||(Vt={}));var Du;(t=>t.defaultData={type:"Empty",...Vt.defaultData})(Du||(Du={}));var L0;(t=>t.defaultData={type:"ParticleCollider",...Nu.defaultData,...Vt.defaultData})(L0||(L0={}));var B0;(t=>t.defaultData={type:"Component",...Vt.defaultData})(B0||(B0={}));var V0;(t=>t.defaultData={type:"Particle",...Vt.defaultData,..._a.defaultData})(V0||(V0={}));var ii;(t=>t.defaultData={type:"Mesh",...Vt.defaultData,...Ou.defaultData})(ii||(ii={}));var En;(t=>t.defaultData={...Vt.defaultData,...Va.identity,position:[0,0,Fi.DefaultTargetOffset],...Fi.defaultData})(En||(En={}));var _u;(e=>{function i(r){return{...Vt.defaultData,...Pu.defaultData(r)}}e.defaultData=i,e.defaultDirectionalLightData={...e.defaultData("DirectionalLight"),position:[200,300,300],name:"Directional Light",intensity:.7}})(_u||(_u={}));var za;(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})(za||(za={}));var _o;(n=>{n.rootOverrideProps=["physics","events"],n.compositeNonOptionalOverrideProps=["geometry"],n.compositeEntireOverrideOverrideProps=["material"];function r(a,s){return{...Vt.defaultData,...s,component:a,overrides:new Je,physics:void 0,events:void 0,type:"Instance"}}n.ofComponent=r;function o(a){let s=Va.fromObject(a.data);return r(a.id,s)}n.fromComponentData=o})(_o||(_o={}));var ni;(e=>{e.defaultData={type:"Page",...Vt.defaultData,physics:{...ji.defaultData,fusedBody:!1},...Eu.defaultData,camera:En.defaultData};function t(r){return r.uiScene!==void 0}e.isUIPage=t})(ni||(ni={}));var Ru;(s=>(s.defaultCamera={position:[0,0,1e3],scale:[1,1,1],rotation:[0,0,0],pivot:[0,0,0],pivotRotation:[0,0,0],hiddenMatrix:Vi.identity,name:"Play Camera",visible:!0,raycastLock:!1,physics:ji.defaultData,states:new ve,events:new ve,timelineAnimations:new de,cloner:null,pathSnapping:{pathId:null,orientation:"tangential",slide:0,offset:0},...Fi.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",...Vt.defaultData,...ii.defaultData,geometry:Do.defaultData("RectangleGeometry"),material:Wt.defaultTwoLayerData("phong","layer1","layer2")},s.defaultBooleanObject={name:"Boolean",...Vt.defaultData,...ii.defaultData,geometry:Do.defaultData("BooleanGeometry"),material:Wt.defaultTwoLayerData("phong","layer1","layer2")},s.defaultShapeBlendObject={name:"Shape Blend",...Vt.defaultData,...ii.defaultData,geometry:Do.defaultData("ShapeBlendGeometry"),material:Wt.defaultTwoLayerData("phong","layer1","layer2")},s.defaultTextObject={name:"Text",...Vt.defaultData,...ii.defaultData,geometry:Do.defaultData("TextGeometry"),material:Wt.defaultTwoLayerData("phong","layer1","layer2")},s.defaultInputObject={name:"Input",...Vt.defaultData,...ii.defaultData,geometry:Do.defaultData("InputGeometry"),material:Wt.defaultTwoLayerData("phong","layer1","layer2")}))(Ru||(Ru={}));var Nn;(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})))):ao.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=Di(s.material,l=>{if(typeof l!="string")for(let[c,u]of Object.entries(a.material.layers)){let d=l.layers.data(c);d&&Nt.patch(d,u)}}).data),s.materials&&a.materials&&(s.materials=Di(s.materials,l=>{for(let c=0;c<s.materials.length;c++){let u=a.materials[c];if(typeof u!="string")for(let[d,p]of Object.entries(u.layers)){let f=l[c]?.layers?.data(d);f&&Nt.patch(f,p)}}}).data),s}function e(n,a){let s,l=[],c={orthographic:0,perspective:0,geometry:0};function u(d,p){for(let[f,h]of Object.entries(p.layers)){let{texture:m,...y}=h;if(m!==void 0&&Object.keys(m).length>0){let g={path:[...d,"layers",f,"texture"],props:m,type:0};l.push(g)}if(Object.keys(y).length>0){let g={path:[...d,"layers",f],props:y,type:0};l.push(g)}}}for(let[d,p]of Object.entries(a))if(d!=="name")if(d==="cloner")l.push(...Su.toOps(p,["cloner"]));else if(d==="pathSnapping")l.push({path:[d],props:{slide:p.slide,offset:p.offset},type:0});else if(d==="material")u(["material"],p);else if(d==="materials")for(let[f,h]of Object.entries(p))u(["materials",f],h);else if(c[d]===0){if(d==="geometry"&&p.extrusion!==void 0){let f={path:[d,"extrusion"],props:p.extrusion,type:0};l.push(f),p={...p},delete p.extrusion}if(Object.keys(p).length>0){let f={path:[d],props:p,type:0};l.push(f)}}else s===void 0&&(s={path:[],props:{},type:0},l.push(s)),s.props[d]=p;return l}o.toOps=e;function r(n,a){if(a===void 0)return n;let s={...n};if(Object.assign(s,Va.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})}),ao.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:Au.merge(s.geometry,a.geometry)}),(a.material||a.materials)&&(s=t(s,a)),s.cloner&&"cloner"in a&&Object.assign(s,{cloner:No.merge(s.cloner,a.cloner)});else if(n.type==="Empty")s.cloner&&"cloner"in a&&Object.assign(s,{cloner:No.merge(s.cloner,a.cloner)});else if(wu.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})(Nn||(Nn={}));var Ga;(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,rotationSpeed:1,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})(Ga||(Ga={}));var Wr;(t=>t.defaultData={orbitControls:Ga.defaultData,playPage:Gi,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,colorSpace:"display-p3"},videoStatic:{fps:60,mbps:150,ratio:1,duration:1e3,format:"mp4",imageFormat:"jpg",activeTimeline:null,colorSpace:"display-p3"},web:{logo:!0,compress:!0,preset:1,preload:!0,hint:!1,imageQuality:70,pixelRatioMobile:0,pixelRatioDesktop:0}},stopRaycast:!0,hdTransmission:!1})(Wr||(Wr={}));var uf;(t=>t.defaultData={id:"basic",label:"Basic",style:"None",prompt:""})(uf||(uf={}));var df;(t=>t.defaultData={weather:0,shadows:0,lightOrigin:0,temperature:0,sun:0,camera:0,environment:0,particles:0,nature:0,floor:0})(df||(df={}));var ai;(e=>(e.defaultData=()=>({mode:"line-art-both",prompt:"",negativePrompt:"",style:{...uf.defaultData},isRandomSeed:!0,seed:e.generateSeed(),guessMode:!1,advanced:!1,steps:20,guidanceScale:7.5,controlNetScale:1,modifiers:df.defaultData}),e.generateSeed=()=>Math.round(Math.random()*1e5)))(ai||(ai={}));var z0;(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=Ro.getComponentData(r,s.component)?.data;l&&n(a,s,l.events)}else n(a,s,s.events)})}e.traverseModuleInstances=t})(z0||(z0={}));var si;(c=>{c.TRASH_CAN_ID="830a2708-8ed9-49cf-a68e-085299892222",c.defaultLight={fi:-1,data:_u.defaultDirectionalLightData,id:"830a2708-8ed9-49cf-a68e-085299899103",children:[]};function e(u=!0,d=[]){let p=[],f=Ru.defaultMeshObject;u&&(p.push({...c.defaultLight}),p.push({fi:1,id:"7ba78968-2a55-48f2-b14c-5191da3e075e",data:f,children:[]})),p.push(...d);let h=new ut;return h.push({fi:1,id:Gi,data:{...ni.defaultData,name:"Scene 1"},children:p}),h}c.createDefaultObjectTreeWithPage=e,c.defaultData={objects:e(),publish:Wr.defaultData,styles:ai.defaultData()},c.emptyDataWithoutPage=function(){return{objects:new ut,publish:Wr.defaultData,styles:ai.defaultData()}},c.emptyDataWithPage=function(u=!0){return{objects:e(u),publish:Wr.defaultData,styles:ai.defaultData()}},c.emptyData=function(){return{objects:new ut,publish:{...Wr.defaultData},styles:ai.defaultData()}};function s(u){return{...c.defaultData,objects:Ht(u,ut.prototype)}}c.withObjs=s;function l(u,d){return s([{id:u,data:d,children:[],fi:0}])}c.withObj=l})(si||(si={}));var Fa;(t=>t.defaultData={preset:"fullscreen",allowResponsive:!1,size:[512,512],coords:[0,0],sceneScale:1,color:{r:0,g:0,b:0,a:.5}})(Fa||(Fa={}));var Lu;(e=>(e.defaultData=r=>({url:r,name:"New Webhook",parametersSchemas:new ve}),e.defaultParameterValueByType=r=>r==="number"?0:r==="boolean"?!1:""))(Lu||(Lu={}));var G0;(t=>t.defaultData=(e,r="GET")=>({url:e,method:r,name:"New API",headers:new ve,queries:new ve,autoStart:!0}))(G0||(G0={}));var Ui;(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})(Ui||(Ui={}));var pf;(t=>t.all=["images","videos","colors","audios","particles","fonts","materials","variables"])(pf||(pf={}));var F0;(t=>t.all=[...pf.all,"components"])(F0||(F0={}));var j0;(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})(j0||(j0={}));var so;(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})(so||(so={}));var qr;(n=>{function i(){let a={};return a["89b10010-844c-11ec-a8a3-0242ac120002"]={r:.5,g:.5,b:.5,a:1,name:"Default Color"},Ht(a,de.prototype)}n.defaultColors=i;function t(){return Ht({},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 ve,userAPIs:new de,userWebhooks:new de,lib:so.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})(qr||(qr={}));var wl=require("three");var Bu;(t=>t.list=["idle","move","jump","run"])(Bu||(Bu={}));var Vu;(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 ve,move:new ve,jump:new ve,run:new ve},navmesh:{enabled:!1,ch:6,cs:6,walkableClimb:5,walkableHeight:1,walkableRadius:0,zones:"all",objects:[],helperVisible:!0,destinationHelperRadius:0,destinationHelperColor:Le.fromHexAndA(3728051,1)}}))(Vu||(Vu={}));function U0(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={...no(wt(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={...wt(t),near:Math.max(t.near,0),far:Math.max(t.far,0)};Object.assign(t,e)}})}function li(i,t){Object.values(i.shared.materials).forEach(e=>t(e))}function ci(i,t){i.scene.objects.traverse((e,r)=>{"materials"in r?r.materials.forEach((o,n)=>{o===void 0&&(r.materials[n]=Wt.defaultData(),o=r.materials[n]),typeof o!="string"&&t(o)}):"material"in r?typeof r.material!="string"&&(r.material===void 0&&(r.material=Wt.defaultData()),t(r.material)):r.type==="Mesh"&&(r.material===void 0&&(r.material=Wt.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 VA(i){Object.assign(i.scene.publish,{orbitControls:{...Ga.defaultData,...wt(i.scene.publish.orbitControls)}})}function zA(i){Object.assign(i.scene.publish.settings,{video:{...Wr.defaultData.settings.video,...wt(i.scene.publish.settings.video)}})}function GA(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((D0.includes(o)||typeof n=="boolean")&&delete r[o],o==="texture")for(let[a,s]of Object.entries(n))(_0.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 FA(i){i.scene.publish.withBackground=!0}function jA(i){i.scene.publish.settings.web={compress:!0,preload:!0,preset:1,logo:!0,hint:!1}}function UA(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 kA(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 HA(i){i.scene.objects.traverse((t,e)=>{let r=i.scene.objects.unproxy().parent(t);if(r){let o=wt(i.scene.objects.data(r));o&&o.type==="Mesh"&&o.geometry.type==="BooleanGeometry"&&e.type==="Mesh"&&(e.visible=wt(e).booleanExclude!==!0)}})}function WA(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 qA(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=wt(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=wt(l).layers;e(c),l.layers=c}})})}function k0(i){i.layers===void 0&&Object.assign(i,Wt.defaultTwoLayerData("lambert"))}function ff(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={...wt(t),colors:e,steps:r};Object.assign(t,o)}})}function $A(i){i.scene.objects.traverse((t,e)=>{e.type==="Mesh"&&(e.geometry.type==="BooleanGeometry"||e.geometry.type==="SubdivGeometry")&&(e.geometry.phongAngle=35)})}function H0(i){i.scene.objects.traverse((t,e)=>{"materials"in e?e.materials.forEach(r=>{typeof r!="string"&&ff(r)}):"material"in e&&typeof e.material!="string"&&ff(e.material)}),Object.values(i.shared.materials).forEach(t=>ff(t))}function XA(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 YA(i){i.shared.audios=Ht({},de.prototype)}function KA(i){i.shared.videos=Ht({},de.prototype)}function QA(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 ZA(i){Object.entries(wt(i.shared.images)).filter(r=>r[1].asset===!1).map(r=>r[0]).forEach(r=>{delete i.shared.images[r]}),Object.entries(wt(i.shared.audios)).filter(r=>r[1].asset===!1).map(r=>r[0]).forEach(r=>{delete i.shared.audios[r]})}function JA(i){i.scene.publish.settings.web.preload=!1}function W0(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 q0(i){i.layers&&i.layers.forEach(t=>{N0(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 eM(i){i.shared.fonts=Ht({},de.prototype)}function tM(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 rM(i){let t=[];i.scene.objects.traverse((e,r)=>{let o=r;if(o.type==="TextFrame"){let n=Wt.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=tM(o.font);i.shared.fonts[s]===void 0&&(i.shared.fonts[s]={name:s});let l={name:o.name,...Vt.defaultData,...ii.defaultData,flatShading:!1,wireframe:!1,geometry:{...Do.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:wt(o.states),events:wt(o.events),visible:o.visible,raycastLock:o.raycastLock,position:o.position,rotation:o.rotation,scale:o.scale,hiddenMatrix:o.hiddenMatrix},c=wt(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 oM(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 ve,move:new ve,jump:new ve}});else{let n=new ve;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:wl.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,no(a,"mass","stiffness","damping","velocity")):a.easing===5&&Object.assign(u,{control1:{...a.control1},control2:{...a.control2}});let d={repeat:a.repeat?-1:0,delay:a.delay,delayDirection:a.delayDirection,direction:a.cycle&&a.rewind?"pingpong-rewind":a.cycle?"pingpong":"normal"},p={state:a.state,...d,...u},f={allowSlerp:!0,type:"Transition",object:a.object,repeat:0,delay:0,delayDirection:void 0,direction:"normal",tweens:new ve({fi:0,id:wl.MathUtils.generateUUID(),data:c},{fi:1,id:wl.MathUtils.generateUUID(),data:p})};n.push({fi:l,id:s,data:f})}),delete o.targets)}})})}function iM(i){i.scene.objects.traverse((t,e)=>{function r(o,n){let a=new ve,s=[];if(e.events.forEach((l,c,u)=>{if(l.type==="Audio"&&l.trigger===n){let d;s.push(c),l.interaction==="play"?d={...no(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")&&(d={...no(l,"interaction","delay","object","playAudio"),type:"Audio"}),d&&a.push({fi:u,id:c,data:d})}}),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:wl.MathUtils.generateUUID(),data:{type:o,actions:a}}])}}r("Start","start"),r("MouseDown","mouseDown"),r("MouseUp","mouseUp"),r("KeyDown","keyDown"),r("KeyUp","keyUp")})}function $0(i){let t=i.layers.find(e=>e.type==="light")?.data;if(t?.category==="basic"){let e=Nt.defaultData("light","phong"),r=t;Object.assign(r,e),r.visible=!1}}function X0(i){li(i,$0),ci(i,$0)}function nM(i){i.scene.objects.traverse((t,e)=>{e.type==="Mesh"&&e.geometry.type==="SubdivGeometry"&&(e.geometry.scaleBaked||(e.geometry.scaleBaked=[1,1,1]))})}function aM(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 sM(i){i.scene.objects.traverse((t,e)=>{e.type==="Mesh"&&e.geometry.type==="NonParametricGeometry"&&!("material"in e)&&!("materials"in e)&&(e.material=Wt.defaultTwoLayerData("phong"))})}function lM(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 cM(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 uM(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 dM(i){let{video:t}=i.scene.publish.settings;t.format==="gif"&&t.fps>48&&(t.fps=15)}function pM(i){i.scene.objects.traverse((t,e)=>{e.events.forEach(r=>{r.type==="GameControl"&&(r.resetYPosition=Math.abs(r.resetYPosition-e.position[1]))})})}function fM(i){let t=i.scene.environment.usePhysics;i.scene.objects.traverse((e,r)=>{t&&r.physics===null?r.collision=!1:r.collision="visibility"})}function hM(i){i.scene.objects.traverse((t,e)=>{e.events.forEach(r=>{r.type==="GameControl"&&(r.navmesh=Vu.defaultDataThirdPerson.navmesh)})})}function mM(i){i.scene.styles||(i.scene.styles=ai.defaultData())}function Y0(i){i.layers.forEach(t=>{t.type==="light"&&t.category!=="toon"&&t.occlusion===void 0&&(t.occlusion=!0)})}function yM(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}),ci(i,Y0),li(i,Y0)}function gM(i){i.scene.objects.traverse((t,e)=>{e.events.forEach(r=>{r.type==="GameControl"&&Object.assign(r.gameActions,{run:new ve})})})}function xM(i){i.scene.objects.traverse((t,e)=>{e.events.forEach(r=>{r.type==="GameControl"&&(r.keyAssignments=[...r.keyAssignments,["run","\u21E7"],["none","Ctrl"]])})})}function K0(i){i.layers&&i.layers.forEach(t=>{t.type==="light"&&t.bumpMapIntensity===void 0&&(t.bumpMapIntensity=5)})}function Q0(i,t){if(t<1&&(ci(i,U0),li(i,U0),i.schema=1),t<2&&(VA(i),i.schema=2),t<3&&(GA(i),i.schema=3),t<4&&(FA(i),i.schema=4),t<5&&(jA(i),i.schema=5),t<6&&(UA(i),i.schema=6),t<7&&(kA(i),i.schema=7),t<8&&(i.schema=8),t<9&&(H0(i),i.schema=9),t<10&&($A(i),i.schema=10),t<11&&(XA(i),i.schema=11),t<12&&(H0(i),i.schema=12),t<13&&(YA(i),i.schema=13),t<14&&(QA(i),i.schema=14),t<15&&(ZA(i),i.schema=15),t<16&&(JA(i),i.schema=16),t<17&&(ci(i,W0),li(i,W0),i.schema=17),t<18&&(ci(i,k0),li(i,k0),i.schema=18),t<19&&(zA(i),i.schema=19),t<20&&(eM(i),rM(i),i.schema=20),t<21&&(oM(i),iM(i),i.schema=21),t<22&&(X0(i),i.schema=22),t<23&&(nM(i),i.schema=23),t<24&&(aM(i),i.schema=24),(t<25||i.shared.videos===void 0)&&(KA(i),t<25&&(i.schema=25)),t<26&&(HA(i),i.schema=26),t<27&&(WA(i),i.schema=27),t<28&&(X0(i),i.schema=28),t<29&&(qA(i),i.schema=29),t<30&&(sM(i),i.schema=30),t<31&&(lM(i),i.schema=31),t<33&&(cM(i),i.schema=33),t<34&&(uM(i),i.schema=34),t<35&&(dM(i),i.schema=35),t<36&&(pM(i),i.schema=36),t<37&&(fM(i),i.schema=37),t<38&&(ci(i,q0),li(i,q0),i.schema=38),t<39&&(hM(i),i.schema=39),t<40&&(mM(i),i.schema=40),t<41&&(yM(i),i.schema=41),t<42&&(gM(i),i.schema=42),t<43&&(xM(i),i.schema=43),t<99){ci(i,K0),li(i,K0),i.scene.publish.playCamera===null&&(i.scene.publish.playCamera=zi);let e=wt(i.scene.objects),r=i.scene.objects;i.scene.publish.playPage=Gi,r.insertBefore(null,null,[{id:Gi,data:{...ni.defaultData,backgroundColor:i.scene.backgroundColor,fog:i.scene.fog,postprocessing:i.scene.postprocessing,ao:no(i.scene.environment.ambientLight,"occlusion","aoFullRes","radius","bias","aoColor"),publish:{playCamera:i.scene.publish.playCamera,gameControlObject:i.scene.publish.gameControlObject},shadow:no(i.scene.environment.ambientLight,"softShadowQuality"),globalPhysics:{...Sl.defaultData,...no(i.scene.environment,"usePhysics","gravity")},camera:wt(i.scene.ownerCamera)??ni.defaultData.camera,name:"Scene"},children:[]}]);for(let a of e)a.id!==si.TRASH_CAN_ID&&r.move(Gi,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,ji.defaultData)),s.physics!==void 0&&s.physics!==null&&(s.physics.enabled=s.collision??"visibility",delete s.collision)}),i.schema=99}}function Z0(i){i.layers&&i.layers.forEach(t=>{t.type==="light"&&t.alphaOverride===void 0&&(t.alphaOverride=1)})}function bM(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 vM(i){Array.isArray(wt(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 ja=180/Math.PI;function J0(i){i.rotation=i.rotation.slice(0,3).map(t=>t*ja)}function ex(i){J0(i),i.type==="Page"&&J0(i.camera),i.states?.forEach(e=>{e.rotation===void 0||e.rotation===null||(e.rotation=e.rotation.slice(0,3).map(r=>r*ja))});let t=i.geometry;t&&t.type==="SphereGeometry"&&(t.thetaLength=(t.thetaLength??180)*ja),t&&t.type==="TorusGeometry"&&(t.arc=t.arc*ja),t&&t.type==="PathGeometry"&&(t.extrusion.angle*=ja,t.extrusion.twist*=ja),i.type==="Mesh"&&i.geometry.type==="TextGeometry"&&(i.geometry.text={textValue:i.geometry.text}),Array.isArray(wt(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 SM(i){i.shared.variables=Ht({},de.prototype)}function wM(i){let t=wt(i.shared.variables);i.shared.variables=Ht(Object.entries(t??{}).map(([e,r],o)=>({fi:o,id:e,data:r})),ve.prototype)}var Lo=122;function zu(i,t){t(i.data);for(let e of i.children)zu(e,t)}function PM(i){let t=i.schema??104;t!==Lo&&(t<105&&(zu(i.asset,ex),i.schema=105),t<118&&(zu(i.asset,tx),i.schema=118),t<121&&(zu(i.asset,hf),i.schema=121))}function OM(i){i.shared.particles=Ht({},de.prototype),i.shared.lib&&(i.shared.lib.particles=so.defaultData().particles)}function TM(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 CM(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 AM(i){i.scene.objects.traverse((t,e)=>{Array.isArray(wt(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 MM(i){i.shared.userAPIs=Ht({},de.prototype),i.shared.userWebhooks=Ht({},de.prototype),i.shared.lib&&(i.shared.lib.userAPIs=so.defaultData().userAPIs,i.shared.lib.userWebhooks=so.defaultData().userWebhooks)}function IM(i){i.scene.publish.settings.videoStatic===void 0&&(i.scene.publish.settings.videoStatic=Wr.defaultData.settings.videoStatic)}function tx(i){i.timelineAnimations=Ht({},de.prototype)}function hf(i){console.log("Updating pivot for object:",i.name),i.pivot=[0,0,0],i.pivotRotation=[0,0,0]}function Gu(i){let t=i.schema??0;if(t!==Lo){console.warn("updating from ",t,"to ",Lo),Q0(i,t),t<100&&(i.scene.publish.joystickSizeAndXYOffset===void 0&&(i.scene.publish.joystickSizeAndXYOffset=Wr.defaultData.joystickSizeAndXYOffset),i.schema=100),t<101&&(ci(i,Z0),li(i,Z0),i.schema=101),t<102&&(bM(i),i.schema=102),t<104&&(i.shared.catelogs=new de,i.shared.lib=so.defaultData(),i.schema=104),t<105&&(SM(i),i.scene.objects.traverse((e,r)=>{ex(r)}),i.schema=105);for(let e of Object.values(i.shared.lib.components))PM(e);t<106&&(wM(i),i.schema=106),t<107&&(i.shared.lib.variables=so.defaultData().variables,i.schema=107),t<109&&(OM(i),i.schema=109),t<110&&(TM(i),i.schema=110),t<111&&(i.scene.objects.traverse((e,r)=>{vM(r)}),i.schema=111),t<112&&(CM(i),i.schema=112),t<113&&(AM(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&&(MM(i),i.schema=115),t<116&&(IM(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=Ht({},de.prototype),i.scene.objects.traverse((e,r)=>{tx(r)}),i.schema=118),t<119&&(i.scene.publish.settings.videoStatic.format=Ro.defaultData.scene.publish.settings.videoStatic.format,i.scene.publish.settings.videoStatic.imageFormat=Ro.defaultData.scene.publish.settings.videoStatic.imageFormat,i.schema=119),t<120&&(i.scene.publish.settings.image.colorSpace="display-p3",i.scene.publish.settings.videoStatic.colorSpace="display-p3",i.schema=120),t<121&&(i.scene.objects.traverse((e,r)=>{hf(r),r.type==="Page"&&hf(r.camera)}),i.schema=121),t<122&&(delete i.scene.publish.settings.video,i.scene.publish.orbitControls.rotationSpeed=Ro.defaultData.scene.publish.orbitControls.rotationSpeed,i.schema=122)}}var Ro;(c=>{c.defaultData={schema:Lo,scene:si.defaultData,frames:new de().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",Fa.defaultData),shared:{...qr.emptyData(),colors:qr.defaultColors()}},c.emptyDataForImports=function(){let u=si.emptyDataWithPage();return{schema:Lo,scene:u,frames:new de().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",Fa.defaultData),shared:{...qr.emptyData(),colors:qr.defaultColors(),images:qr.defaultImages()}}},c.emptyData=function(){return{schema:Lo,scene:si.emptyDataWithPage(),frames:new de().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",Fa.defaultData),shared:qr.emptyData()}},c.clipboard2dData=function(){return{schema:Lo,scene:si.emptyData(),frames:new de,shared:qr.emptyData()}},c.collabHelper={...ml,updateSchema(u){return(u.schema??0)<Lo?Di(u,Gu):(u.schema??0)-Lo}};function n(u){let d=c.collabHelper.updateSchema(u);return typeof d=="number"?d===0?u:null:d.data}c.updateSchemaDirectly=n;function a(u){return{...u,shared:{...u.shared,lib:so.defaultData()}}}c.withoutLib=a;function s(u,d){let p=u.scene.objects.get(d);if(p&&p.data.type==="Component")return p;{let f=u.shared.lib.components[d];if(f)return{...f.asset,id:d}}}c.getComponentData=s;function l(u){let d=Object.values(u.shared.userAPIs);for(let p of d){let f=p.headers;for(let h of f)if(h.data.key.toLowerCase()==="authorization"&&h.data.value!=="")return!0}return!1}c.hasSensitiveData=l})(Ro||(Ro={}));var Fu;(t=>t.emptyImage={data:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII=",name:"empty"})(Fu||(Fu={}));var rx;(t=>{function i(e){return!0}t.is=i})(rx||(rx={}));var ju;(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 Mc({position:Da.isEqual(o.position,n.position)?void 0:n.position,rotation:o.rotation===n.rotation?void 0:n.rotation,scale:Da.isEqual(o.scale,n.scale)?void 0:n.scale,shear:o.shear&&n.shear&&Da.isEqual(o.shear,n.shear)?void 0:n.shear})}r.diff=e})(ju||(ju={}));var mf;(t=>t.defaultData={horizontalConstraint:0,verticalConstraint:0})(mf||(mf={}));var ox;(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})(ox||(ox={}));var Uu;(t=>t.defaultData={opacity:1,fill:{color:Le.fromHexAndA(Bt,1),enabled:!0},stroke:{color:Le.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:Le.from0to1([0,0,0,1]),enabled:!1,spread:0},innerShadow:{offset:[10,10],blurRadius:10,color:Le.from0to1([0,0,0,1]),enabled:!1,spread:0}})(Uu||(Uu={}));var Dn;(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,ju.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,d]of Object.entries(s))u!=="name"&&(l===void 0&&(l={path:[],props:{},type:0},c.push(l)),l.props[u]=d);return c}n.toOps=o})(Dn||(Dn={}));var Pl;(t=>t.defaultData={...ju.defaultData,...mf.defaultData,states:new ve,events:new ve,visible:!0,raycastLock:!1})(Pl||(Pl={}));var Ua;(t=>t.defaultData={...Pl.defaultData,...Uu.defaultData})(Ua||(Ua={}));var ku;(t=>t.defaultData={cornerRadius:[0,0,0,0]})(ku||(ku={}));var yf;(t=>t.defaultData={...Ua.defaultData,type:"ellipse2d",width:100,height:100,name:"Ellipse"})(yf||(yf={}));var ka;(t=>t.defaultData={...Ua.defaultData,...ku.defaultData,type:"rectangle2d",width:100,height:100,name:"Rectangle"})(ka||(ka={}));var gf;(t=>t.defaultData={...Ua.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"})(gf||(gf={}));var xf;(t=>t.defaultData={...Ua.defaultData,type:"path2d",path:"",name:"Path"})(xf||(xf={}));var ix;(t=>{function i(e){return e.type==="ellipse2d"||e.type==="rectangle2d"||e.type==="text2d"||e.type==="vector2d"||e.type==="path2d"}t.is=i})(ix||(ix={}));var Ol;(t=>t.defaultData={...Pl.defaultData,name:"Group",type:"group2d"})(Ol||(Ol={}));var bf;(t=>t.defaultData=()=>({...Pl.defaultData,...ku.defaultData,...Uu.defaultData,name:"Frame",type:"frame2d",clipped:!0,width:200,height:200,fill:{color:Le.fromHexAndA(4737101,1),enabled:!0},stroke:{color:Le.fromHexAndA(0,1),thickness:1,enabled:!1,mode:"inside"},backgroundBlur:{radius:2,enabled:!1},layerBlur:{radius:2,enabled:!1}}))(bf||(bf={}));var ui;(n=>{function i(a){switch(a){case"rectangle2d":return{...ka.defaultData};case"ellipse2d":return{...yf.defaultData};case"text2d":return{...gf.defaultData};case"vector2d":return{...ka.defaultData};case"path2d":return{...xf.defaultData};case"frame2d":return{...bf.defaultData()};case"group2d":return{...Ol.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})(ui||(ui={}));var Hu;(e=>(e.defaultData={name:"UI",type:"scene2d",objects:new ut},e.emptyData=function(){return{type:"scene2d",objects:new ut}}))(Hu||(Hu={}));var nx=require("three"),qt=class extends nx.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"),Fd=ll(sx());var EM=.5*(Math.sqrt(3)-1),Tl=(3-Math.sqrt(3))/6,NM=1/3,Bo=1/6,m4=(Math.sqrt(5)-1)/4,y4=(5-Math.sqrt(5))/20,Cl=i=>Math.floor(i)|0,lx=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]),Sf=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 cx(i=Math.random){let t=dx(i),e=new Float64Array(t).map(o=>lx[o%12*2]),r=new Float64Array(t).map(o=>lx[o%12*2+1]);return function(n,a){let s=0,l=0,c=0,u=(n+a)*EM,d=Cl(n+u),p=Cl(a+u),f=(d+p)*Tl,h=d-f,m=p-f,y=n-h,g=a-m,b,w;y>g?(b=1,w=0):(b=0,w=1);let P=y-b+Tl,S=g-w+Tl,T=y-1+2*Tl,A=g-1+2*Tl,x=d&255,N=p&255,E=.5-y*y-g*g;if(E>=0){let _=x+t[N],R=e[_],V=r[_];E*=E,s=E*E*(R*y+V*g)}let M=.5-P*P-S*S;if(M>=0){let _=x+b+t[N+w],R=e[_],V=r[_];M*=M,l=M*M*(R*P+V*S)}let D=.5-T*T-A*A;if(D>=0){let _=x+1+t[N+1],R=e[_],V=r[_];D*=D,c=D*D*(R*T+V*A)}return 70*(s+l+c)}}function ux(i=Math.random){let t=dx(i),e=new Float64Array(t).map(n=>Sf[n%12*3]),r=new Float64Array(t).map(n=>Sf[n%12*3+1]),o=new Float64Array(t).map(n=>Sf[n%12*3+2]);return function(a,s,l){let c,u,d,p,f=(a+s+l)*NM,h=Cl(a+f),m=Cl(s+f),y=Cl(l+f),g=(h+m+y)*Bo,b=h-g,w=m-g,P=y-g,S=a-b,T=s-w,A=l-P,x,N,E,M,D,_;S>=T?T>=A?(x=1,N=0,E=0,M=1,D=1,_=0):S>=A?(x=1,N=0,E=0,M=1,D=0,_=1):(x=0,N=0,E=1,M=1,D=0,_=1):T<A?(x=0,N=0,E=1,M=0,D=1,_=1):S<A?(x=0,N=1,E=0,M=0,D=1,_=1):(x=0,N=1,E=0,M=1,D=1,_=0);let R=S-x+Bo,V=T-N+Bo,U=A-E+Bo,B=S-M+2*Bo,q=T-D+2*Bo,j=A-_+2*Bo,F=S-1+3*Bo,H=T-1+3*Bo,W=A-1+3*Bo,ee=h&255,te=m&255,Y=y&255,re=.6-S*S-T*T-A*A;if(re<0)c=0;else{let $=ee+t[te+t[Y]];re*=re,c=re*re*(e[$]*S+r[$]*T+o[$]*A)}let K=.6-R*R-V*V-U*U;if(K<0)u=0;else{let $=ee+x+t[te+N+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)d=0;else{let $=ee+M+t[te+D+t[Y+_]];Z*=Z,d=Z*Z*(e[$]*B+r[$]*q+o[$]*j)}let Q=.6-F*F-H*H-W*W;if(Q<0)p=0;else{let $=ee+1+t[te+1+t[Y+1]];Q*=Q,p=Q*Q*(e[$]*F+r[$]*H+o[$]*W)}return 32*(c+u+d+p)}}function dx(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 px=require("three"),lo=new px.Triangle,Wu=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;lo.a.fromBufferAttribute(t,o),lo.b.fromBufferAttribute(t,o+1),lo.c.fromBufferAttribute(t,o+2),n*=lo.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),lo.a.fromBufferAttribute(this.positionAttribute,t*3),lo.b.fromBufferAttribute(this.positionAttribute,t*3+1),lo.c.fromBufferAttribute(this.positionAttribute,t*3+2),e.set(0,0,0).addScaledVector(lo.a,o).addScaledVector(lo.b,n).addScaledVector(lo.c,1-(o+n)),lo.getNormal(r),this}};var yx=require("three");var Pr=require("three"),mx=ll(hx()),DM=new Pr.Matrix4,_M=new Pr.Matrix4,RM=new Pr.Matrix4,di;(t=>{function i(e){return e&&e.__isSPEObject}t.is=i})(di||(di={}));var Ha=i=>class extends i{constructor(){super(...arguments);this.previousModelViewMatrix=new Pr.Matrix4;this.copyPreviousMatrix=!0;this.hiddenMatrix=new Pr.Matrix4;this.pivotMatrix=new Pr.Matrix4;this.matrixWorldRigid=new Pr.Matrix4;this.shearScale=new Pr.Matrix4;this.shearScaleInv=new Pr.Matrix4}get __isSPEObject(){return!0}isDescendantOf(r){r instanceof Pr.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.matrixWorld.multiply(this.pivotMatrix),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)),this.matrixWorld.multiply(this.pivotMatrix),o)for(let a of this.children)a.updateWorldMatrix(!1,!0)}traverseChildren(r,o=0){for(let n of this.children)di.is(n)&&n.traverseObject(r,o+1)}traverseObject(r,o=0){if(r(this,o)!==!0)for(let a of this.children)di.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,mx.SVD)(o),l=DM.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=_M.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=RM.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(d=>Math.abs(s[0]-d)<.01)?this.hasNonUniformScale=!1:this.hasNonUniformScale=!0}attach(r,o){this.updateWorldMatrix(!0,!1);let n=new Pr.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 Pr.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 wf=class extends Ha(yx.Object3D){},LM=i=>i.type==="Mesh",co=class extends wf{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 co(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.pivotMatrix=r.pivotMatrix),o.expand(),e+=1,r=this.object.entityChildren(e)}for(;this.children.length>e;)this.remove(this.children[e]);this.pivotMatrix=this.object.pivotMatrix}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 LM(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 us=require("three");var pd=require("three");var _t=require("three");var Dt=require("three"),_n=new Dt.Vector3,Rn=new Dt.Vector3,Wa=new Dt.Matrix4,xx=[new Dt.Vector3(-1,1,1),new Dt.Vector3(-1,-1,1),new Dt.Vector3(1,-1,1),new Dt.Vector3(1,1,1),new Dt.Vector3(-1,1,-1),new Dt.Vector3(-1,-1,-1),new Dt.Vector3(1,-1,-1),new Dt.Vector3(1,1,-1)],BM=[[0,3],[1,2],[5,6],[4,7],[0,1],[3,2],[7,6],[4,5],[0,4],[1,5],[2,6],[3,7]],VM=[[0,2],[7,5],[4,1],[3,6],[4,3],[1,6]],gx=(i,t,e)=>{i.updateEntityBoxSize(_n,Rn),Wa.copy(t).multiply(i.matrixWorld),Rn.x===0&&Rn.y===0&&Rn.z===0?e.push(new Dt.Vector3(_n.x,_n.y,_n.z).applyMatrix4(Wa)):xx.forEach(r=>{e.push(r.clone().multiply(Rn).add(_n).applyMatrix4(Wa))})},Al=class extends Dt.Box3{constructor(){super(...arguments);this.matrix=new Dt.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 Dt.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 Dt.Vector3);return}gx(a,r,n)}}):gx(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(Wa.copy(this.matrix).setPosition(0,0,0)),e}computeVertices(){this.getSize(Rn).multiplyScalar(.5),this.getCenter(_n),Wa.copy(this.matrix).setPosition(_n),this.vertices=xx.map(e=>e.clone().multiply(Rn).applyMatrix4(Wa))}computeEdges(){this.vertices.length>0&&this.computeVertices(),this.edges=BM.map(([e,r])=>new Dt.Line3(this.vertices[e],this.vertices[r])),this.centerEdges=this.edges.map(e=>e.getCenter(new Dt.Vector3))}computeFaces(){this.vertices.length>0&&this.computeVertices(),this.faces=VM.map(([e,r])=>this.vertices[e].clone().add(this.vertices[r]).multiplyScalar(.5))}};var uo={Cloner:()=>{},changeEntityProptotype:()=>{},createEntity:()=>{}};var er=require("three"),Of=class extends er.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],d=Math.ceil(t*u/a),p=c.getPoints(d);for(let f=0;f<p.length;f++){let h=p[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 Tf=.001;function Cf(i,t,e){return t.clone().sub(i).cross(t.clone().sub(e)).length()<=Tf}function Pf(i,t){let e=new er.Vector3(...i.position),r=new er.Vector3(...i.controlNext.position),o=new er.Vector3(...t.controlPrevious.position),n=new er.Vector3(...t.position);return Cf(e,r,n)&&Cf(e,o,n)}function $u(i){let t=i.points.map(u=>new er.Vector3(...u.data.position)),e=[i.points[0]],r=new er.Vector3(...e[0].data.position);for(let u=0;u<i.points.length-1;u++)Cf(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 d=e[u].data,p=new er.Vector3(...d.position),f=new er.Vector3(...d.controlPrevious.position),h=new er.Vector3(...d.controlNext.position),m={position:p,baseRoundness:d.roundness,controlPrevious:f,controlNext:h};if(d.roundness===0||!i.isClosed&&(u===0||u===a-1)){s[u]={...m,removedLength:0};continue}let y=o&&u==0?a-1:u-1,g=o&&u==a-1?0:u+1,b=e[y].data,w=e[g].data,P=new er.Vector3(...b.position),S=new er.Vector3(...w.position),T=P.clone().sub(p).normalize(),A=S.clone().sub(p).normalize();Object.assign(m,{prevDir:T,nextDir:A});let x=Pf(b,d),N=Pf(d,w);if(!x||!N)s[u]={...m,removedLength:0};else{let E=T.clone().add(A).normalize(),M=E.clone().cross(T).length()/T.dot(E);s[u]={...m,tan:M,removedLength:d.roundness/M}}}for(let u=0;u<n;u++){let d=u,p=o&&u===a-1?0:u+1,f=s[d],h=s[p];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 d=u,p=o&&u===a-1?0:u+1,f=s[d],h=s[p],m=null;if(!Pf(e[d].data,e[p].data))f.position.distanceTo(h.position)>Tf&&(m=new er.CubicBezierCurve3(f.position,f.controlNext,h.controlPrevious,h.position));else{let y=f.position.clone(),g=h.position.clone();(f.removedLength!==0||h.removedLength!==0)&&(f.nextDir&&y.add(f.nextDir.clone().setLength(f.removedLength)),h.prevDir&&g.add(h.prevDir.clone().setLength(h.removedLength))),y.distanceTo(g)>Tf&&(m=new er.CubicBezierCurve3(y,y.clone().lerp(g,.3),g.clone().lerp(y,.3),g))}l[2*u+1]=m}for(let u=0;u<a;u++){let d=s[u];if(d.removedLength===0){l[2*u]=null;continue}let p=d.position,f=d.prevDir.clone().multiplyScalar(d.removedLength).add(p),h=d.nextDir.clone().multiplyScalar(d.removedLength).add(p),m=d.tan*d.removedLength,y=d.prevDir.clone().add(d.nextDir).normalize(),g=f.clone().lerp(h,.5),b=f.distanceTo(h)/2,w=y.clone().multiplyScalar(Math.sqrt(Math.pow(m,2)-Math.pow(b,2))).add(g),P=y.clone().multiplyScalar(-m).add(w),S=p.distanceTo(P)/p.distanceTo(g),T=d.prevDir.clone().multiplyScalar(S*p.distanceTo(f)).add(p),A=T.clone().lerp(P,2),x=f.clone().lerp(T,4/3),N=h.clone().lerp(A,4/3);l[2*u]=new er.CubicBezierCurve3(f,x,N,h)}let c=new Of;return l.forEach(u=>{u&&c.add(u)}),c}var Ge;(t=>{function i(e){return e&&e.__isEntity}t.is=i})(Ge||(Ge={}));var qa=i=>Ge.is(i),zM={type:"completeState",isfromEntity:!0},GM=["x","y","z"],Ml=new _t.Vector3,bx=new _t.Vector3(1,1,1),Af=new _t.Quaternion,vx=new _t.Euler,FM=new _t.Vector3().set(0,1,0),$a=i=>class extends Ha(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 Al;this._recursiveBBox=new Al;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(Ge.is(o))return o}entityChildrenCount(){let r=this.children.length;for(;r--;)if(Ge.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(Ge.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)Nn.toOps(this.data,a.data).forEach(l=>{let c=Ma.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=Nn.patch(this.data,a),Nn.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=>{qa(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(Ge.is(o[n]))return o[n];if(Ge.is(r))return r.traverseSortNextHelper()}}sortNext(){let r=this.children;return this.children.length>0&&Ge.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)qa(o)&&r(o)}traverseEntityAncestors(r){this.traverseAncestors(o=>{Ge.is(o)&&r(o)})}traverseConcreteEntity(r,o=0){if(r(this,o)!==!0)for(let a of this.children)qa(a)&&a.isConcreteEntity&&a.traverseEntity(r,o+1)}traverseEntity(r,o=0){if(r(this,o)!==!0)for(let a of this.children)qa(a)&&a.traverseEntity(r,o+1)}traverseVisibleEntity(r){r(this);for(let o of this.children)qa(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=>qa(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*_t.MathUtils.RAD2DEG,this.rotation.y*_t.MathUtils.RAD2DEG,this.rotation.z*_t.MathUtils.RAD2DEG],scale:this.scale.toArray(),hiddenMatrix:this.hiddenMatrix.toArray(),pivot:[0,0,0],pivotRotation:[0,0,0]};return Pa(o,r)}getTransformValues(r,o,n){return o[r].map((a,s)=>n?.shared.getVariable(a,[this.uuid,r,GM[s]])??a)}updateTransformState(r,o){let n=!1;if(r.position&&(this.position.fromArray(this.getTransformValues("position",r,o)),n=!0),r.rotation&&(Ml.fromArray(this.getTransformValues("rotation",r,o)).multiplyScalar(_t.MathUtils.DEG2RAD),this.rotation.setFromVector3(Ml),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??Vi.identity)),r.pivot!==void 0||r.pivotRotation!==void 0){if(n=!0,r.pivot!==void 0&&r.pivotRotation!==void 0)this.pivotMatrix.compose(Ml.fromArray(r.pivot).negate(),Af.setFromEuler(vx.fromArray(r.pivotRotation.map(a=>a*_t.MathUtils.DEG2RAD))).invert(),bx);else if(r.pivot!==void 0)this.pivotMatrix.setPosition(-r.pivot[0],-r.pivot[1],-r.pivot[2]);else if(r.pivotRotation!==void 0){let a=Ml.setFromMatrixPosition(this.pivotMatrix);Af.setFromEuler(vx.fromArray(r.pivotRotation.map(s=>s*_t.MathUtils.DEG2RAD))).invert(),this.pivotMatrix.compose(a,Af,bx)}}return 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)}),this.requestRender()}dispose(){this.disposed=!0,this.cloner&&(this.cloner.removeFromParent(),this.cloner=void 0)}disposeChildrenRecursively(){for(let r of this.children)Ge.is(r)&&r.disposeRecursively()}disposeRecursively(){this.dispose(),this.children.forEach(r=>{Ge.is(r)&&r.disposeRecursively()})}toState(r=[]){let o={name:this.name,visible:this.visible,raycastLock:this.raycastLock,...this.toObjectTransformState(r)};return Pa(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=Ue(r.path,["states","*"]);if(c!==null){if(r.type===0){let[u]=c;if(this?.stateSelection===u){let d={...r.props};if(delete d.name,Object.values(r.props).some(p=>p===void 0)){let p=this.data;if(p!==void 0){let f=dt.zoom(p,r.path.slice(2));if(f)for(let h in r.props)r.props[h]===void 0&&h in f&&(d[h]=f[h])}}l={...r,props:d,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:p,...f}=u;u=f}if(r.props.material!==void 0&&"material"in u){let{material:p,...f}=u;u=f}let d=dt.removeOverridden(r.path,r.props,u);l={...r,props:d}}}if(this.updateByPatchedOpBase(l,Nn.patch(this.data,this.stateSelection?this.data.states.data(this.stateSelection):void 0),n),Ue(r.path,["overrides"])){let u=[],d=[...r.path];for(u.push(d[1]),d.splice(0,2);d.length>0&&d[0]==="descendants";)u.push(d[1]),d.splice(0,2);if(u[u.length-1]===void 0){if(r.type===0)for(let p of Object.keys(r.props)){u[u.length-1]=p;let f=n.scene.findInstance([this.uuid,...u]);f&&(f.overrideData=r.props[p],f.updateState(Co.apply(f.component.data,f.overrideData),n))}}else{let p=n.scene.findInstance([this.uuid,...u]);if(p){let f=dt.zoom(p.component.data,d);if(r={...r,path:d},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}}p.overrideData=za.resolve(o.overrides,u),p.updateByOp(r,vt.applySimple(p.data,r),n,!1)}}}else if(this.instances.length>0){let u;if(r.path.length===0&&r.type===0){let d;for(let p of _o.rootOverrideProps)p in r.props&&(d===void 0&&(d={}),d[p]=r.props[p]);d&&(u={...r,props:d})}else for(let d of _o.rootOverrideProps)if(Ue(r.path,[d])){u=r;break}u!==void 0&&this.instances.forEach(d=>{if(d.isInstanceRoot){let p=Co.filterOp(d.overrideData,u);p&&d.updateByOp(p,vt.applySimple(d.data,p),n,!0)}}),this.instances.forEach(d=>{if(!d.isInstanceRoot){let p=Co.filterOp(d.overrideData,r);if(p){let f;s===d.data&&r===p?f=o:f=vt.applySimple(d.data,p),d.updateByOp(p,f,n,!0)}}})}}updateByPatchedOpBase(r,o,n){if(this.dataPatched=o,r.path.length===0&&r.type===0)r.props.type!==void 0&&!ao.is(r.props.type)&&uo.changeEntityProptotype(this,o,n);else if(r.path.length===1&&r.path[0]==="geometry"&&r.type===0&&"type"in r.props){uo.changeEntityProptotype(this,o,n);for(let a of this.children)Ge.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(Ue(r.path,["pathSnapping"])!==null&&this.updatePathSnapping(o.pathSnapping),Ue(r.path,["cloner"])!==null){let a=vt.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):(this.setFromClonerState(o.cloner,n),this.expandCloner(n)),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=$u(c.geometry.path),d=(n+a)%1;n+a===1&&d===0&&(d=1);let p=null;try{p=u.curves.length?u.getPointAt(d):null}catch(y){!1&&(console.warn(`The aligned path on ${this.name} is invalid. (${l.name})`),console.error(y))}if(p===null)return;let f=this.parent?this.parent?.matrixWorld:new _t.Matrix4;l.updateMatrixWorld();let h=new _t.Matrix4().multiplyMatrices(f.clone().invert(),l.matrixWorld);p.applyMatrix4(h);let m={position:p.toArray(),rotation:c.rotation};if(s==="tangential"){let y=new _t.Matrix4().extractRotation(l.matrixWorld),g=u.getTangentAt(d).applyMatrix4(y).add(p),b=new _t.Matrix4().lookAt(p,g,FM),w=Ml.setFromEuler(new _t.Euler().setFromRotationMatrix(b)).multiplyScalar(_t.MathUtils.RAD2DEG);m={...m,rotation:w.toArray()}}this.updateTransformState(m),this.traverseEntity(y=>{y._cameraType&&y.dispatchEvent(zM)})}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 uo.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 uo.Cloner(this,r),o.scene.addPendingExpandCloner(this)):this.cloner.updateState(r,o))}expandCloner(r){!this.disposed&&this.cloner&&this.cloner.expandClones(r)}invalidateClonerTransform(r){this.cloner&&this.cloner.invalidateTransform(r)}requestRender(){this.dispatchEvent({type:"requestRender"})}};var Hi=require("three");var st=require("three"),wx=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:d,cornerSegments:p,hollow:f}=i.parameters,h;return l===0?(h=new st.BufferGeometry,h.setAttribute("position",new st.Float32BufferAttribute([],3))):d||f?h=new Il(c,u,r,o,n,a,s,l*Math.PI/180,d,d,p,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 ki(i,t,e){e.x=i.x*t.x,e.y=i.y,e.z=i.x*t.y}function Sx(i){return new st.Vector2(i.y,-i.x)}var Il=class extends st.BufferGeometry{constructor(t,e,r,o,n,a,s,l,c,u,d,p,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=[],g=[],b=0,w=r/2,P=new st.Vector3,S=new st.Vector3;f&&t==0&&(t=c),f&&e==0&&(e=u);let T=new st.Vector2(t,w),A=new st.Vector2(e,-w),x=null,N=null,E=null,M=null,D=T.clone().sub(A),_=0,R=0,V=0;p>0&&(_=Math.min(t,e)*(1-p),R=t-_,V=e-_);let U=T.clone();U.x-=_;let B=Math.PI-D.angle(),q=D.angle(),j=Math.tan(q/2),F=Math.tan(B/2),H=j+F,W=p?H:F,ee=p?H:j;if(c=Math.min(c,(t-R)/W,D.length()/H),u=Math.min(u,(e-V)/ee,D.length()/H),c>0){let Q=c/j;x=T.clone().sub(new st.Vector2(Q,c)),p&&(E=x.clone(),E.x-=_-H*c),T.sub(D.clone().setLength(Q))}if(u>0){let Q=u/F;N=A.clone().sub(new st.Vector2(Q,-u)),A.add(D.clone().setLength(Q)),p&&(M=N.clone(),M.x-=_-H*u,U.sub(D.clone().setLength(Q)))}D=T.clone().sub(A);let te=D.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));M&&N?(re($,pe,ie,B,u,M,-1,!0),re($,pe,ie,q,u,N,-1,!1)):N?(K($,ie,N.x,0,-1),re($,pe,ie,q,u,N,-1,!1)):a||K($,ie,e,V,-1);let ue=Sx(D).normalize();if(ki(ue,ie,P),!te)for(let ae=0;ae<=n;ae++){let ge=ae/n,me=D.clone().multiplyScalar(ge).add(A);ki(me,ie,S),m.push(S.x,S.y,S.z),y.push(P.x,P.y,P.z),g.push(pe,.5+S.y/r),$.push(b++)}if(E&&x?(re($,pe,ie,B,c,x,1,!1),re($,pe,ie,q,c,E,1,!0)):x?(re($,pe,ie,B,c,x,1,!1),K($,ie,x.x,0,1)):a||K($,ie,t,R,1),p&&!te){let ae=Sx(D).multiplyScalar(-1).normalize();ki(ae,ie,P);for(let ge=0;ge<=n;ge++){let me=ge/n,ye=D.clone().multiplyScalar(-me).add(U);ki(ye,ie,S),m.push(S.x,S.y,S.z),y.push(P.x,P.y,P.z),g.push(pe,.5+S.y/r),$.push(b++)}}p&&!a&&$.push($[0]),Y.push($)}for(let Q=0;Q<Y.length-1;Q++)for(let $=0;$<Y[0].length-1;$++){if(a&&p&&$==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(g,2));function re(Q,$,pe,le,ie,ue,ae,ge){for(let me=0;me<d+1;me++){let ye=me/d,Se=ae<0?ye:1-ye;ge&&(Se-=1),Se*=le;let xe=new st.Vector2(Math.sin(Se),Math.cos(Se)*ae),C=xe.clone().multiplyScalar(ie).add(ue);ki(C,pe,S),m.push(S.x,S.y,S.z),ki(xe,pe,P),y.push(P.x,P.y,P.z),g.push($,.5+S.y/r),Q.push(b++)}}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),ki(ae,$,ue),m.push(ue.x,ue.y,ue.z),y.push(0,ie,0),g.push(.5,.5),Q.push(b++)}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,Se,xe)=>h.push(ye,Se,xe):(ye,Se,xe)=>h.push(ye,xe,Se),ge=new st.Vector2((t+e+R+V)/4,0);ki(ge,le,ue),m.push(ue.x,ue.y,ue.z),y.push(ie.x,0,ie.y),g.push(.5,.5);let me=b++;for(let ye of $){let Se=m.slice(ye*3,ye*3+3);m.push(...Se),y.push(ie.x,0,ie.y);let xe=g.slice(ye*2,ye*2+2);g.push(...xe),b++}for(let ye=me+1;ye<b-1;ye++)ae(me,ye,ye+1);ae(me,b-1,me+1)}}};var Px=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=Hi.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:d}=i.parameters,p;return l===0?(p=new Hi.BufferGeometry,p.setAttribute("position",new Hi.Float32BufferAttribute([],3))):c>0||u>0||l<360?p=new Il(0,t/2,r,o,n,a,s,l*Math.PI/180,c,u,d,0,!0):p=new Hi.ConeGeometry(t/2,r,o,n,a),p.scale(1,1,e/t),Object.assign(p,{userData:{...i,type:"ConeGeometry"}})}};var Or=require("three"),Ox=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 Or.BoxGeometry(t,e,r,o,n,a):c=new If(t,e,r,o,n,a,s,l),Object.assign(c,{userData:{...i,type:"CubeGeometry"}})}},Mf=Math.PI/2,If=class extends Or.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=[],d=[],p=[],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 Or.Float32BufferAttribute(u,3)),this.setAttribute("normal",new Or.Float32BufferAttribute(d,3)),this.setAttribute("uv",new Or.Float32BufferAttribute(p,2));function h(g,b,w,P,S,T,A,x,N,E){let M=(T-2*s)/N,D=(A-2*s)/E,_=T/2-s,R=A/2-s,V=x/2,U=N+1,B=E+1,q=0,j=new Or.Vector3;for(let F=0;F<B;F++){let H=F*D-R;for(let W=0;W<U;W++){let ee=W*M-_;j[g]=ee*P,j[b]=H*S,j[w]=V,u.push(j.x,j.y,j.z),j[g]=0,j[b]=0,j[w]=x>0?1:-1,d.push(j.x,j.y,j.z),p.push(W/N),p.push(1-F/E),q+=1}}for(let F=0;F<E;F++)for(let H=0;H<N;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(g,b,w,P,S,T,A,x,N,E){let M=(A-2*s)/E,D=A/2-s,_=x/2-s,R=N/2,V=E+1,U=0,B=new Or.Vector3,q=new Or.Vector3;for(let j=0;j<l+1;j++){let F=j/l*Mf,H=Math.sin(F)*s,W=(1-Math.cos(F))*s,ee=Math.sin(F),te=Math.cos(F);B[b]=(_+H)*S,B[w]=(R-W)*T,q[g]=0,q[b]=ee*Math.sign(B[b]),q[w]=te*Math.sign(B[w]);for(let Y=0;Y<V;Y++){let re=Y*M-D;B[g]=re*P,u.push(B.x,B.y,B.z),d.push(q.x,q.y,q.z),p.push(Y/E),p.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(g,b,w){let P=new Or.Vector3,S=new Or.Vector3(t/2,e/2,r/2);S.subScalar(s);let T=[],A=g*b*w>0?(N,E,M)=>c.push(N,E,M):(N,E,M)=>c.push(N,M,E);for(let N=0;N<=l;N++){let E=[],M=Mf*(1-N/l),D=Math.cos(M),_=Math.sin(M),R=0;for(let V=0;V<=N;V++){let U=Math.cos(R),B=Math.sin(R);P.x=D*U,P.y=_,P.z=D*B;let q=S.clone().addScaledVector(P,s);u.push(g*q.x,b*q.y,w*q.z),d.push(g*P.x,b*P.y,w*P.z),p.push(0,0),E.push(f++),R+=Mf/N}T.push(E)}let x=T.length-1;for(let N=0;N<x;N++){let E=T[N],M=T[N+1],D=E.length-1;A(E[0],M[1],M[0]);for(let _=1;_<=D;_++)A(E[_-1],E[_],M[_]),A(E[_],M[_+1],M[_])}}}};var Rt=require("three"),Wi=class extends Rt.BufferGeometry{constructor(t=[],e=[],r="",o=1,n=.2,a=4){super(),this.type="PolyhedronGeometryRound";let s=[],l=[],c=[];u(),d(),this.setAttribute("position",new Rt.Float32BufferAttribute(s,3)),this.setAttribute("normal",new Rt.Float32BufferAttribute(c,3)),this.setAttribute("uv",new Rt.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 Rt.Vector3,m=h.clone(),y=new Rt.Triangle,g=n*o,b=o-g,w=a+1,P=new Rt.Vector3,S=(j,F)=>P.subVectors(j,F).normalize(),T=(j,F)=>Array(j).fill(void 0).map(F),A=T(t.length/3,(j,F)=>new Rt.Vector3().fromArray(t,F*3).setLength(o)),x=[],N=1e6;for(let j=0;j<A.length;j++){let F=A[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(A[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=x[W]?.includes(j)==!0;te<=Y&&K.push(W+ +pe*N),Z=H.findIndex(le=>le[0]==ee)}x.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 M=h.clone(),D=h.clone(),_=h.clone(),R=h.clone(),V=h.clone(),U=[],B=T(A.length,()=>T(f,()=>h.clone()));for(let j=0;j<A.length;j++){h.copy(A[j]).normalize(),M.copy(h).multiplyScalar(b);let F=x[j];for(let K=0;K<F.length;K++){let Z=F[K],Q=F[(K+1)%f];y.setFromPointsAndIndices(A,j,Z%N,Q%N),y.b.sub(y.a).setLength(1e10).add(y.a),y.c.sub(y.a).setLength(1e10).add(y.a),y.closestPointToPoint(M,B[j][K])}let H=[],W=[],ee=[],te=new Rt.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(M),m.copy(pe).sub(M);let le=M.angleTo(h),ie=h.angleTo(m),ue=Math.cos(le)*g;a==0?D.copy(te):D.copy(M).setLength(b+ue),W.push(ue);let ae=[D,$,pe];for(let ge=0;ge<2;ge++){let me=ae[ge],ye=ae[ge+1];R.subVectors(me,M),V.subVectors(ye,M),_.crossVectors(R,V).normalize();for(let Se=0;Se<w;Se++){let xe=[le,ie][ge]*Se/w;h.copy(R).applyAxisAngle(_,xe).add(M),H.push(h.clone()),ge&&(S(h,M),Z.push([Se==0?me:h.clone(),P.clone()]))}ge&&(S(ye,M),Z.push([ye,P.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(M).setLength(W[K]).add(M),$.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,M),[P.x,P.y,P.z])).flat())}}let q=[];for(let j=0;j<x.length;j++)for(let F=0;F<f;F++){let H=x[j][F];if(H<N){let W=x[H].findIndex(Y=>Y%N==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];P.subVectors(ee[0],ee[1]).cross(h.subVectors(ee[0],ee[2])).normalize();let te=P.dot(ee[0])<0;te&&P.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(P.x,P.y,P.z)})}}function d(){let p=new Rt.Vector3;for(let A=0;A<s.length;A+=3){p.x=s[A+0],p.y=s[A+1],p.z=s[A+2];let x=S(p)/2/Math.PI+.5,N=T(p)/Math.PI+.5;l.push(x,1-N)}let f=new Rt.Vector3,h=new Rt.Vector3,m=new Rt.Vector3,y=new Rt.Vector3,g=new Rt.Vector2,b=new Rt.Vector2,w=new Rt.Vector2,P=(A,x,N,E)=>{E<0&&A.x===1&&(l[x]=A.x-1),N.x===0&&N.z===0&&(l[x]=E/2/Math.PI+.5)};for(let A=0,x=0;A<s.length;A+=9,x+=6){f.set(s[A+0],s[A+1],s[A+2]),h.set(s[A+3],s[A+4],s[A+5]),m.set(s[A+6],s[A+7],s[A+8]),g.set(l[x+0],l[x+1]),b.set(l[x+2],l[x+3]),w.set(l[x+4],l[x+5]),y.copy(f).add(h).add(m).divideScalar(3);let N=S(y);P(g,x+0,f,N),P(b,x+2,h,N),P(w,x+4,m,N)}for(let A=0;A<l.length;A+=6){let x=l[A+0],N=l[A+2],E=l[A+4],M=Math.max(x,N,E),D=Math.min(x,N,E);M>.9&&D<.1&&(x<.2&&(l[A+0]+=1),N<.2&&(l[A+2]+=1),E<.2&&(l[A+4]+=1))}function S(A){return Math.atan2(A.z,-A.x)}function T(A){return Math.atan2(-A.y,Math.sqrt(A.x*A.x+A.z*A.z))}}}static fromJSON(t){return new Wi(t.vertices,t.indices,t.radius,t.corner,t.cornerSides)}};var Tx=require("three"),Cx=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 Tx.DodecahedronGeometry(t*.5,o);return s.scale(1,e/t,r/t),Object.assign(s,{userData:{...i,type:"DodecahedronGeometry"}})}},El=class extends Wi{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 El(t.radius,t.corner,t.cornerSides)}};var Ke=require("three");var De=require("three"),Nl=1e-12,Xa=class{constructor(t){this.position=new De.Vector2;this.startPosition=new De.Vector2;this.uuid=De.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 Xa(this.position).copy(this)}toJSON(){return[this.position.x,this.position.y]}},Ya=class extends Xa{constructor(e){super(e.position);this.parent=e}copy(e){return super.copy(e),this}clone(){return new Ya(this.parent).copy(this)}},po=class extends Xa{constructor(e,r){super(r);this.controls=[];this.roundness=0;this.areControlsDirectionsMirrored=!0;this.uuid=e,this.controls.push(new Ya(this),new Ya(this))}static create(e,r){let o=new po(e,new De.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 po(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 De.Vector2,r=new De.Vector2){let[o,n]=this.computeTangents();return o&&n&&(Ax(o,e),Ax(n,r)),[e,r]}computeTangent(e=new De.Vector2){let[r,o]=this.computeTangents();return r&&o&&e.copy(r).add(o).normalize(),e}computeNormal(e=new De.Vector2){let[r,o]=this.computeNormals();return e.copy(r).add(o).normalize(),e}};function Ax(i,t=new De.Vector2){let e=i.length();return t.set(-i.y/e,i.x/e)}var Nf=i=>i,Ka=new De.Vector2,Xu=new De.Vector2,jM=new De.Vector2,UM=new De.Vector2,kM=new De.Vector2,HM=new De.Vector2,Ix=new De.Vector3,Ex=new De.Vector3;function Nx(i){let t=new De.Vector2;t.addVectors(i.v0,Ka.subVectors(i.v1,i.v0).multiplyScalar(2/3));let e=new De.Vector2;return e.addVectors(i.v2,Xu.subVectors(i.v1,i.v2).multiplyScalar(2/3)),new De.CubicBezierCurve(i.v0,t,e,i.v2)}function Dl(i,t,e=Number.EPSILON){return Math.abs(i-t)<e}function WM(i,t,e=Number.EPSILON){return i.distanceTo(t)<e}function qM(i,t,e=Number.EPSILON){return i.distanceTo(t)<e}function Df(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 Dx(i,t,e){return Mx(i,t)&&Mx(t,e)&&Ef(i.position,t.position,e.position)}function Ef(i,t,e){return Ka.copy(t).sub(i).cross(Xu.copy(e).sub(i))===0}function _x(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 Rx(i,t,e){let r=i.distanceTo(e),o=t.distanceTo(e);return r<o?t:i}function Lx(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)),d;return Df(t,i,e)>Math.PI&&(u*=-1),Dl(c,s)?d=(s+c)*(r/u-.5)*8/3/(a-l):d=(a+l)*(r/u-.5)*8/3/(c-s),o.set(t.x-d*s,t.y+d*a),n.set(e.x+d*c,e.y-d*l),[o,n]}function _f(i,t){return i.position.equals(i.controls[1].position)&&t.position.equals(t.controls[0].position)}function Mx(i,t){return Ef(i.position,i.controls[1].position,t.position)&&Ef(i.position,t.controls[0].position,t.position)}function Bx(i,t,e,r,o=.5){let n=Ka.subVectors(t,i).multiplyScalar(o).add(i),a=Xu.subVectors(e,t).multiplyScalar(o).add(t),s=jM.subVectors(r,e).multiplyScalar(o).add(e),l=n,c=UM.subVectors(a,n).multiplyScalar(o).add(n),u=kM.subVectors(s,a).multiplyScalar(o).add(a),d=s,p=HM.subVectors(u,c).multiplyScalar(o).add(c);return[i.x,i.y,l.x,l.y,c.x,c.y,p.x,p.y,u.x,u.y,d.x,d.y,r.x,r.y]}function Vx(i,t,e=12,r=!0){let o=Ex.set(0,0,0),n,a=0,s=[];for(let l=0;l<t.length;l++){let c=Nf(t[l]),u=Ka,d=qi(c,e);s.push(d);for(let p=0;p<=d;p++)if(c instanceof De.CubicBezierCurve||c instanceof De.QuadraticBezierCurve||c instanceof De.LineCurve){if(c.getPoint(p/d,u),o.set(u.x,u.y,0),n!==void 0&&qM(n,o))continue;n===void 0&&(n=Ix),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 zx(i,t,e,r=12,o=!0){let n=Ex.set(0,0,0),a=0,s=[];for(let l=0;l<t.length;l++){if(e[l]===!1)continue;let c,u=Nf(t[l]),d=Ka,p=qi(u,r);s.push(p);for(let f=0;f<=p;f++)if(u instanceof De.CubicBezierCurve||u instanceof De.QuadraticBezierCurve||u instanceof De.LineCurve){if(u.getPoint(f/p,d),n.set(d.x,d.y,0),c?.equals(n))continue;c===void 0?c=Ix:(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 Rf(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=qi(a.roundedCurveCorner,t)*.5;o>0&&(r[o-1]+=l),s+=l}a.curveAfter!==void 0&&(s+=qi(a.curveAfter,t)),r.push(s)}return i.length>0&&e&&i[0].roundedCurveCorner!==void 0&&(r[i.length-1]+=qi(i[0].roundedCurveCorner,t)*.5),r}function qi(i,t=12){return i&&i instanceof De.EllipseCurve?t*2:i&&(i instanceof De.LineCurve||i instanceof De.LineCurve3)?1:i&&i instanceof De.SplineCurve?t*i.points.length:t}function Gx(i,t,e=12,r=!0){let o,n=0;for(let a=0;a<t.length;a++){let s=Nf(t[a]),l=qi(s,e),c=Ka;for(let u=0;u<=l;u++)if(s instanceof De.CubicBezierCurve||s instanceof De.QuadraticBezierCurve||s instanceof De.LineCurve){if(s.getPoint(u/l,c),o!==void 0&&WM(o,c,Nl))continue;o===void 0&&(o=Xu),o.copy(c),i.push(c.x,c.y),n++}}return Dl(i[0],i[i.length-2],Nl)&&Dl(i[1],i[i.length-1],Nl)&&(i.pop(),i.pop()),r&&n>1&&!(Dl(i[n-1],i[1],Nl)&&Dl(i[n-2],i[0],Nl))&&(i.push(i[0],i[1]),n++),i}var Lf=new Ke.Vector2,$M=new Ke.Vector2,XM=new Ke.Vector2,YM=new Ke.Vector2,KM=new Ke.Vector2,QM=new Ke.Vector2,Ye=class extends Ke.Shape{constructor(e=100,r=100){super();this.points=[];this.shapeHoles=[];this.plane=new Ke.Plane(new Ke.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=Ke.MathUtils.generateUUID();this.needsUpdate=!1;this.roundedCurves=[];this._width=e,this._height=r}static createFromState(e,r,o){let n=new Ye;return n.isClosed=e.isClosed,n.points=e.points.map(a=>po.create(a.id,a.data)),typeof e.roundness=="number"&&(n.roundness=e.roundness),n.shapeHoles=e.shapeHoles.map(a=>Ye.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=Lf.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=Ke.MathUtils.generateUUID()){let n;e instanceof Ke.Vector2?n=e:n=new Ke.Vector2(e,r);let a=new po(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 Vx(e,o?this.roundedCurves:this.curves,r,this.autoClose),n.reduce((a,s)=>a+s,0)+1}computeCurveDivisions(e=12){return this.curveDivisions=Rf(this.points,e,!1),this.roundedCurveDivisions=Rf(this.points,e,!0),this.curveDivisions}extractFilteredShapePointsToBuffer(e,r,o=12){return zx(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),Gx(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=qi(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(_f(n,a)){let d=n.position.distanceTo(a.position);return n.position.distanceTo(Lf.set(o.x,o.y))/d}let c=0;for(let d=0;d<e;d++)c+=s[d];return(r-c)/l}dispose(){}_applyCurveForPoint(e,r){_f(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&&Dx(s,a,l);if(!a.controlsMoved()&&c>0&&!u){let d=a.curveBefore,p=a.curveAfter;if(d===void 0||p===void 0)continue;let f=a.roundedCurveBefore,h=a.roundedCurveAfter,m=d.getLength(),y=p.getLength(),g=Math.min(c,m*.499),b=Math.min(c,y*.499),w=Math.min(g,b),P=1-w/m,S=w/y,T=d.getPointAt(P,Lf),A=p.getPointAt(S,$M);this._subSplitCurve(d,f,P,T,void 0),this._subSplitCurve(p,h,S,void 0,A);let x;if(this.useCubicForRoundedCorners){let N=Df(T,a.position,A)/2,E=Math.tan(N)*T.distanceTo(a.position),[M,D]=_x(T,A,E,XM,YM),_=Rx(M,D,a.position),[R,V]=Lx(_,T,A,E,KM,QM);x=new Ke.CubicBezierCurve(T.clone(),R.clone(),V.clone(),A.clone())}else x=new Ke.QuadraticBezierCurve(T.clone(),a.position.clone(),A.clone());a.roundedCurveCorner=x,this.roundedCurves.splice(o+r,0,x),r++}}}}_subSplitCurve(e,r,o,n,a){if(e instanceof Ke.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=Bx(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 Ye(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],d=e.points[n+5],p=e.points[n+6],f=new po(Ke.MathUtils.generateUUID(),new Ke.Vector2(a,s));f.controls[0].position.set(l,c),f.controls[1].position.set(u,d),f.roundness=p,this.points.push(f)}return this.shapeHoles=e.shapeHoles?.length?e.shapeHoles.map(o=>{let n=new Ye;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 Ke.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 Ke.QuadraticBezierCurve&&(a[l]=Nx(a[l]));for(l=0,c=a.length;l<c;l++){let p=a[l],f=l>0?a[l-1]:null,h;p instanceof Ke.CubicBezierCurve?(h=this.createPoint(p.v0),h.controls[1].position.copy(p.v1)):p instanceof Ke.LineCurve&&(h=this.createPoint(p.v1)),h!==void 0&&(f!==null&&o(h,f),s.push(h))}let u=a[a.length-1],d=!1;return u instanceof Ke.CubicBezierCurve?u.v3.equals(s[0].position)&&(s[0].controls[0].position.copy(u.v2),d=!0):u instanceof Ke.LineCurve&&u.v2.equals(s[0].position)&&(d=!0),this.isClosed=d,s};return this.points=n(e.curves),e instanceof Ke.Shape&&(this.shapeHoles=e.holes.map(a=>{let s=new Ye;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 Vf=Math.PI*2;function Bf({x:i,y:t},e,r,o,n){return{x:i*e+o,y:t*r+n}}function ZM(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 Fx(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 JM(i,t,e,r,o,n,a,s,l,c){let u=Math.pow(o,2),d=Math.pow(n,2),p=Math.pow(a,2),f=Math.pow(s,2),h=u*d-u*f-d*p;h<0&&(h=0),h/=u*f+d*p,h=Math.sqrt(h)*(l===c?-1:1);let m=h*o/n*s,y=h*-n/o*a,g=m+(i+e)/2,b=y+(t+r)/2,w=(a-m)/o,P=(s-y)/n,S=(-a-m)/o,T=(-s-y)/n,A=Fx(1,0,w,P),x=Fx(w,P,S,T);return!c&&x>0&&(x-=Vf),c&&x<0&&(x+=Vf),{centerx:g,centery:b,ang1:A,ang2:x}}function jx({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 d=Math.pow(c,2)/Math.pow(o,2)+Math.pow(u,2)/Math.pow(n,2);d>1&&(o*=Math.sqrt(d),n*=Math.sqrt(d));let p=JM(i,t,e,r,o,n,c,u,a,s),{ang1:f,ang2:h}=p,{centerx:m,centery:y}=p,g=Math.abs(h)/(Vf/4);Math.abs(1-g)<1e-7&&(g=1);let b=Math.max(Math.ceil(g),1);h/=b;for(let w=0;w<b;w++)l.push(ZM(f,h)),f+=h;return l.map(w=>{let{x:P,y:S}=Bf(w[0],o,n,m,y),{x:T,y:A}=Bf(w[1],o,n,m,y),{x,y:N}=Bf(w[2],o,n,m,y);return{x1:P,y1:S,x2:T,y2:A,x,y:N}})}var Ln=require("three");var Xe;(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"})(Xe||(Xe={}));var Pt;(function(i){i[i.POLYGONS=0]="POLYGONS",i[i.CONNECTED_POLYGONS=1]="CONNECTED_POLYGONS",i[i.BOUNDARY_CONTOURS=2]="BOUNDARY_CONTOURS"})(Pt||(Pt={}));function Te(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){Te(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){Te(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){Te(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){Te(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}(),_l=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}(),Yu=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}(),Qa=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}(),Ux=function(){function i(){var t=new Qa,e=new _l,r=new Yu(0),o=new Yu(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 Yu(0),r=new Yu(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;Te(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;Te(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 Qa,e=new Qa,r=new _l,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 Qa;this.makeVertex_(n,e,t.Org),t.Org.anEdge=t}if(!r){var a=new _l;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 _l;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 Qa;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 _l;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){Te(o.prev===n),l=o.anEdge;do Te(l.Sym!==l),Te(l.Sym.Sym===l),Te(l.Lnext.Onext.Sym===l),Te(l.Onext.Sym.Lnext===l),Te(l.Lface===o),l=l.Lnext;while(l!==o.anEdge)}for(Te(o.prev===n&&o.anEdge===null),s=e,s=e;(a=s.next)!==e;s=a){Te(a.prev===s),l=a.anEdge;do Te(l.Sym!==l),Te(l.Sym.Sym===l),Te(l.Lnext.Onext.Sym===l),Te(l.Onext.Sym.Lnext===l),Te(l.Org===a),l=l.Onext;while(l!==a.anEdge)}for(Te(a.prev===s&&a.anEdge===null),c=r,c=r;(l=c.next)!==r;c=l)Te(l.Sym.next===c.Sym),Te(l.Sym!==l),Te(l.Sym.Sym===l),Te(l.Org!==null),Te(l.Dst!==null),Te(l.Lnext.Onext.Sym===l),Te(l.Onext.Sym.Lnext===l);Te(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}(),kx=function(){function i(){this.handle=null}return i}(),Hx=function(){function i(){this.key=null,this.node=0}return i}(),eI=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 kx,this.handles[r]=new Hx;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,Te(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 kx;for(n=this.handles.length,this.handles.length=this.max+1,o=n;o<this.handles.length;o++)this.handles[o]=new Hx}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;Te(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}(),zf=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}(),Wx=function(){function i(){this.key=null,this.next=null,this.prev=null}return i}(),tI=function(){function i(t,e){this.frame=t,this.leq=e,this.head=new Wx,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 Wx;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}(),rI=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&&Te(e.eUp.winding===0),e.eUp.activeRegion=null,t.dict.delete(e.nodeUp)},i.fixUpperEdge=function(t,e,r){Te(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 zf;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 Xe.ODD:return(e&1)!==0;case Xe.NONZERO:return e!==0;case Xe.POSITIVE:return e>0;case Xe.NEGATIVE:return e<0;case Xe.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,d=!0;c=r;do Te(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,!d&&i.checkForRightSplice(t,l)&&(i.addWinding(c,u),i.deleteRegion(t,l),t.mesh.delete(u)),d=!1,l=s,u=c;l.dirty=!0,Te(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(Te(!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,d,p=new Qa,f,h;if(Te(!we.vertEq(c,l)),Te(we.edgeSign(l,t.event,a)<=0),Te(we.edgeSign(c,t.event,s)>=0),Te(a!==t.event&&s!==t.event),Te(!e.fixUpperEdge&&!r.fixUpperEdge),a===s||(u=Math.min(a.t,l.t),d=Math.max(s.t,c.t),u>d))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,p),Te(Math.min(a.t,l.t)<=p.t),Te(p.t<=Math.max(s.t,c.t)),Te(Math.min(c.s,l.s)<=p.s),Te(p.s<=Math.max(s.s,a.s)),we.vertLeq(p,t.event)&&(p.s=t.event.s,p.t=t.event.t),f=we.vertLeq(a,s)?a:s,we.vertLeq(f,p)&&(p.s=f.s,p.t=f.t),we.vertEq(p,a)||we.vertEq(p,s)?(i.checkForRightSplice(t,e),!1):!we.vertEq(l,t.event)&&we.edgeSign(l,t.event,p)>=0||!we.vertEq(c,t.event)&&we.edgeSign(c,t.event,p)<=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,p)>=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,p)<=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=p.s,o.Org.t=p.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)){Te(!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}Te(!1),e=i.topRightRegion(e),l=i.regionBelow(e),a=l.eUp.Sym,n=s=a.Onext,l.fixUpperEdge&&(Te(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 zf;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);Te(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 zf,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 tI(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||(Te(e.fixUpperEdge),Te(++r===1)),Te(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 eI(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,Te(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}(),oI=function(){function i(){this.mesh=new Ux,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=Xe.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],d=[0,0,0],p=[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 g=0;g<3;++g)n=e.coords[g],n<c[g]&&(c[g]=n,h[g]=e),n>l[g]&&(l[g]=n,f[g]=e);var b=0;if(l[1]-c[1]>l[0]-c[0]&&(b=1),l[2]-c[2]>l[b]-c[b]&&(b=2),c[b]>=l[b]){t[0]=0,t[1]=0,t[2]=1;return}for(s=0,r=h[b],o=f[b],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)d[0]=e.coords[0]-o.coords[0],d[1]=e.coords[1]-o.coords[1],d[2]=e.coords[2]-o.coords[2],p[0]=u[1]*d[2]-u[2]*d[1],p[1]=u[2]*d[0]-u[0]*d[2],p[2]=u[0]*d[1]-u[1]*d[0],a=p[0]*p[0]+p[1]*p[1]+p[2]*p[2],a>s&&(s=a,t[0]=p[0],t[1]=p[1],t[2]=p[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===Pt.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 d=c.n*o;this.vertices[d+0]=c.coords[0],this.vertices[d+1]=c.coords[1],o>2&&(this.vertices[d+2]=c.coords[2]),this.vertexIndices[c.n]=c.idx}for(var p=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[p++]=c.n,l++,n=n.Lnext}while(n!==u.anEdge);for(var f=l;f<r;++f)this.elements[p++]=-1;if(e===Pt.CONNECTED_POLYGONS){n=u.anEdge;do this.elements[p++]=this.getNeighbourFace_(n),n=n.Lnext;while(n!==u.anEdge);for(var h=l;h<r;++h)this.elements[p++]=-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 Ux),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=Xe.ODD),e===void 0&&(e=Pt.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_(),rI.computeInterior(this,a);var s=this.mesh;return e===Pt.BOUNDARY_CONTOURS?this.setWindingNumber_(s,1,!0):this.tessellateInterior_(s),a&&s.check(),e===Pt.BOUNDARY_CONTOURS?this.outputContours_(s,o):this.outputPolymesh_(s,e,r,o),!0},i}();function fo(i){var t=i.windingRule,e=t===void 0?Xe.ODD:t,r=i.elementType,o=r===void 0?Pt.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,d=i.contours,p=d===void 0?[]:d,f=i.strict,h=f===void 0?!0:f,m=i.debug,y=m===void 0?!1:m;if(!p&&h)throw new Error("Contours can't be empty");if(!!p){var g=new oI;i.edgeCreateCallback&&(g.edgeCreateCallback=i.edgeCreateCallback),i.vertexIdCallback&&(g.vertexIdCallback=i.vertexIdCallback);for(var b=0;b<p.length;b++)g.addContour(l||2,p[b]);return g.tesselate(e,o,a,l,u,h),{vertices:g.vertices,vertexIndices:g.vertexIndices,vertexCount:g.vertexCount,elements:g.elements,elementCount:g.elementCount,mesh:y?g.mesh:void 0}}}var _5=Xe.ODD,R5=Xe.NONZERO,L5=Xe.POSITIVE,B5=Xe.NEGATIVE,V5=Xe.ABS_GEQ_TWO,z5=Pt.POLYGONS,G5=Pt.CONNECTED_POLYGONS,F5=Pt.BOUNDARY_CONTOURS;var ho=require("three");var Ku=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*Ku.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*Ku.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)}},Rl=Ku;Rl.eSize=(3+3+2)*Float32Array.BYTES_PER_ELEMENT;var Ll=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 Gf(i,t,e=1,r=!1){let o=1/0,n=1/0,a=-1/0,s=-1/0;for(let[b,w]of i[0])b<o&&(o=b),w<n&&(n=w),b>a&&(a=b),w>s&&(s=w);let l=a-o,c=s-n,u=Math.max(e,Math.min(l,c));if(u===e){let b=[o,n];return b.distance=0,b.distance}let d=new Ll([],(b,w)=>w.max-b.max),p=nI(i),f=new Qu(o+l/2,n+c/2,0,i);f.d>p.d&&(p=f);let h=2;function m(b,w,P){let S=new Qu(b,w,P,i);if(h++,S.max>p.d+e&&d.push(S),S.d>p.d&&(p=S,r&&console.log(`found best ${Math.round(1e4*S.d)/1e4} after ${h} probes`),p.d>t))return t}let y=u/2;for(let b=o;b<a;b+=u)for(let w=n;w<s;w+=u)m(b+y,w+y,y);for(;d.length;){let{max:b,x:w,y:P,h:S}=d.pop();if(b-p.d<=e)break;y=S/2,m(w-y,P-y,y),m(w+y,P-y,y),m(w-y,P+y,y),m(w+y,P+y,y)}r&&console.log(`num probes: ${h}
3
+ best distance: ${p.d}`);let g=[p.x,p.y];return g.distance=p.d,g.distance}function Qu(i,t,e,r){this.x=i,this.y=t,this.h=e,this.d=iI(i,t,r),this.max=this.d+this.h*Math.SQRT2}function iI(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,aI(i,t,c,u))}return o===0?0:(r?1:-1)*Math.sqrt(o)}function nI(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],d=c[0]*u[1]-u[0]*c[1];e+=(c[0]+u[0])*d,r+=(c[1]+u[1])*d,t+=d*3}let n=new Qu(e/t,r/t,0,i);return t===0||n.d<0?new Qu(o[0][0],o[0][1],0,i):n}function aI(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 Bl={vertices:[160,160,-160,160,-160,-160,160,-160],vertexIndices:[1,0,3,2],vertexCount:4,elements:[0,4],elementCount:1,mesh:void 0},jf={vertices:[],vertexIndices:[],vertexCount:0,elements:[],elementCount:0,mesh:void 0},Uf={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},Ff=(i,t)=>([e,r])=>(r<e&&(r+=t),(i>=e?i:i+t)<=r),$i=class extends ho.BufferGeometry{constructor(e,r,o=0,n=12,a=3,s=Xe.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(M=>{let D=M.extractShapePointsToFlatArray([],n),_=[];for(let R=D.length-1;R>=1;R-=2){let V=D[R-1],U=D[R-0];_.push(V,U)}return _}),d=[],p=[];for(let M=0;M<c.length;M+=2)p.push([c[M],c[M+1]]);d.push(p);for(let M=0;M<u.length;M++){let D=u[M],_=[];for(let R=0;R<D.length;R+=2)_.push([D[R],D[R+1]]);d.push(_)}let f;e.isText?f=new ho.Box2().setFromPoints(e.points.map(D=>D.position)).getSize(new ho.Vector2).length()*.1:d[0].length===0?f=o:o>0?f=Gf(d,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=fo({windingRule:s,elementType:Pt.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[c]})}catch{h=Bl}let m;try{m=fo({windingRule:Xe.ODD,elementType:Pt.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...u]})}catch{m=jf}if(!h)throw new Error("error generating geometry");let y=h.elementCount;if(m){h.elementCount+=m.elementCount;for(let M=0;M<m.elements.length;M++){let D=m.elements[M],_=M%2===0?h.vertexCount:0;h.elements.push(D+_)}for(let M=0;M<m.vertexIndices.length;M++){let D=m.vertexIndices[M],_=h.vertexCount;h.vertexIndices.push(D+_)}for(let M=0;M<m.vertices.length;M++){let D=m.vertices[M];h.vertices.push(D)}}let g=1/0,b=-1/0,w=1/0,P=-1/0;for(let M=0,D=h.vertexCount;M<D;M++){let _=M*2,R=h.vertices[_+0],V=h.vertices[_+1];R<g&&(g=R),R>b&&(b=R),V<w&&(w=V),V>P&&(P=V)}this._minX=g,this._minY=w,this._width=b-g,this._height=P-w,this._buffer=new Rl(this._computeBufferEstimatedSize(h));let S=[],T=[];for(let M=h.elementCount-1;M>=0;M--){let D=M>=y,_=M*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 Se=h.vertexIndices[q];if(Array.isArray(Se))B.continuous[re]=!1;else{let[xe,C]=this._shape.getCurveIndexFromVertexId(Se-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 ze=C===1?0:1,He=this._shape.roundedCurves[xe].getTangent(C),Fe=this._shape.roundedCurves[ne].getTangent(ze);B.continuous[re]=He.dot(Fe)>.95}}D&&(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],Se=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,ze=-B.normals[ge+1]*Z;if(B.concave[ae]||!B.concave[ae]&&D){let He=Math.atan2(C,xe),Fe=Math.atan2(ze,ne);Fe>He&&(Fe-=Math.PI*2);let Ae=Fe-He;if(B.continuous[ae]||D){let Ut=He+Ae/2,Re=Math.cos(Ut)*Z,Ft=Math.sin(Ut)*Z;Q[2*ie+0]=ye+Re*(D?-1:1),Q[2*ie+1]=Se+Ft*(D?-1:1),le[ie]=ae,ie++}else{let Ut=Math.max(1,Math.floor(n/4*Math.abs(Ae)/Math.PI));for(let Re=0;Re<=Ut;Re++){let Ft=He+Ae*(Re/Ut),kt=Math.cos(Ft)*Z,xn=Math.sin(Ft)*Z;Q[2*ie+0]=ye+kt,Q[2*ie+1]=Se+xn,le[ie]=ae,ie++}}}else Q[2*ie+0]=ye+xe,Q[2*ie+1]=Se+C,le[ie]=ae,$[ae]=ie,ie++,Q[2*ie+0]=ye,Q[2*ie+1]=Se,le[ie]=ae,ie++,Q[2*ie+0]=ye+ne,Q[2*ie+1]=Se+ze,le[ie]=ae,pe[ae]=ie,ie++}let ue=fo({windingRule:Xe.POSITIVE,elementType:Pt.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[Q],edgeCreateCallback:ae=>{let me=ae.Org.idx,ye=le[me],Se=le[(me+1)%le.length];ae.idx=[ye,Se],ae.Sym.idx=[Se,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 Se=ge;Se<ye;Se++){let xe=Se%V,C=(Se+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=Ff(le,V);for(;!K.boundary.vertexIndices.filter(ie).length||!Z.boundary.vertexIndices.filter(ie).length;)le++,ie=Ff(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),Se=this._buildBevelVert(B,Z,(ae-1+$)%$,void 0,me),xe=ye,C=Se,ne,ze,He=!1;do{me=(le||pe)/pe,ie=Ff(le,V);let Fe=te(K,ue,ie),Ae=te(Z,ae,ie),Ut=He;if(He=!1,Fe&&!Ae){for(let Re=0;Re<Fe;Re++)ne=this._buildBevelVert(B,K,(ue+Re)%Q,Re/(Fe-1),me),S.push(xe.topN,ne.topP,C.topN),l===!1&&S.push(ne.bottomP,xe.bottomN,C.bottomN),xe=ne;He=!0}else if(!Fe&&Ae)for(let Re=0;Re<Ae;Re++)ze=this._buildBevelVert(B,Z,(ae+Re)%$,Re/(Ae-1),me),S.push(C.topN,xe.topP,ze.topP),l===!1&&S.push(xe.bottomP,C.bottomN,ze.bottomP),C=ze;else if(Fe&&Ae)if(ne=this._buildBevelVert(B,K,ue,0,me),ze=this._buildBevelVert(B,Z,ae,0,me),Ut?(S.push(xe.topN,ze.topP,C.topN),S.push(xe.topN,ne.topP,ze.topP),l===!1&&(S.push(ze.bottomP,xe.bottomN,C.bottomN),S.push(ze.bottomP,ne.bottomP,xe.bottomN))):(S.push(C.topN,xe.topN,ne.topP),S.push(C.topN,ne.topP,ze.topP),l===!1&&(S.push(ne.bottomP,xe.bottomN,C.bottomN),S.push(ne.bottomP,C.bottomN,ze.bottomP))),xe=ne,C=ze,Fe===Ae)for(let Re=1;Re<Fe;Re++)ne=this._buildBevelVert(B,K,(ue+Re)%Q,Re/(Fe-1),me),ze=this._buildBevelVert(B,Z,(ae+Re)%$,Re/(Ae-1),me),S.push(xe.topN,ne.topP,C.topN),S.push(C.topN,ne.topP,ze.topP),l===!1&&(S.push(ne.bottomP,xe.bottomN,C.bottomN),S.push(ne.bottomP,C.bottomN,ze.bottomP)),xe=ne,C=ze;else if(Fe>Ae){let Re=Fe/Ae,Ft=0;for(let kt=1;kt<Fe;kt++)ne=this._buildBevelVert(B,K,(ue+kt)%Q,kt/(Fe-1),me),S.push(xe.topN,ne.topP,C.topN),l===!1&&S.push(ne.bottomP,xe.bottomN,C.bottomN),xe=ne,kt>(Ft+1)*Re&&(Ft++,ze=this._buildBevelVert(B,Z,(ae+Ft)%$,Ft/(Ae-1),me),S.push(C.topN,ne.topP,ze.topP),l===!1&&S.push(ne.bottomP,C.bottomN,ze.bottomP),C=ze)}else{let Re=Ae/Fe,Ft=0;for(let kt=1;kt<Ae;kt++)ze=this._buildBevelVert(B,Z,(ae+kt)%$,kt/(Ae-1),me),S.push(C.topN,ne.topP,ze.topP),l===!1&&S.push(ne.bottomP,C.bottomN,ze.bottomP),C=ze,kt>(Ft+1)*Re&&(Ft++,ne=this._buildBevelVert(B,K,(ue+Ft)%Q,Ft/(Fe-1),me),S.push(xe.topN,ne.topP,C.topN),l===!1&&S.push(ne.bottomP,xe.bottomN,C.bottomN),xe=ne)}ue=(ue+Fe)%Q,ae=(ae+Ae)%$,le=(le+1)%pe}while(le!==ge)}if(l===!1&&this._depth>this._bevel*2&&this._buildWall(W,B,S),D){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(D){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(!D){let re=W[W.length-1],K;try{K=fo({windingRule:W.length>1?Xe.POSITIVE:Xe.ODD,elementType:Pt.POLYGONS,vertexSize:2,strict:!0,contours:[re.insetPoints,...T]})}catch{K=Uf}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 A=new ho.BufferAttribute(Uint32Array.from(S),1),x=new ho.BufferAttribute(this._buffer.positions,3),N=new ho.BufferAttribute(this._buffer.normals,3),E=new ho.BufferAttribute(this._buffer.uvs,2);x.needsUpdate=!0,N.needsUpdate=!0,E.needsUpdate=!0,A.needsUpdate=!0,this.setAttribute("position",x),this.setAttribute("normal",N),this.setAttribute("uv",E),this.setIndex(A)}_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),d=u*3,p=u*2,f={top:u+0,bottom:u+1};return this._buffer.positions[d+0]=a,this._buffer.positions[d+1]=s,this._buffer.positions[d+2]=this.forPathBevel?this._bevel:this._depth-o,this._buffer.normals[d+0]=0,this._buffer.normals[d+1]=0,this._buffer.normals[d+2]=1,this._buffer.uvs[p+0]=l,this._buffer.uvs[p+1]=c,this.forPathBevel===!1&&(this._buffer.positions[d+3]=a,this._buffer.positions[d+4]=s,this._buffer.positions[d+5]=o,this._buffer.normals[d+3]=0,this._buffer.normals[d+4]=0,this._buffer.normals[d+5]=-1,this._buffer.uvs[p+2]=l,this._buffer.uvs[p+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,d,p,f;l!==c?(d=l,u=c,f=!1,p=e.continuous[d]&&e.continuous[u]):(u=l,d=(u-1+e.count)%e.count,f=e.concave[u]&&r.bevelI>0,p=e.continuous[u]||f);let h=Math.cos(r.angle),m=Math.sin(r.angle),y=o*2,g=u*2,b=d*2,w=r.boundary.vertices[y+0],P=r.boundary.vertices[y+1],S=(1-m)*this._bevel,T=(w-this._minX)/this._width,A=(P-this._minY)/this._height;this.forPathBevel&&(a!==void 0&&(T=a),A=1);let x=e.normals[g+0],N=e.normals[g+1],E=e.normals[b+0],M=e.normals[b+1];if(f){let U=E-x,B=M-N;x=x+U*(1-n),N=N+B*(1-n);let q=Math.sqrt(x*x+N*N);x/=q,N/=q}let D=this.forPathBevel?this._buffer.get(p?1:2):this._buffer.get(p?2:4),_=D*3,R=D*2,V={i:o,fi:u,topP:D+0,topN:D+0,bottomP:D+1,bottomN:D+1,pathBevelUCoord:a};return this._buffer.positions[_+0]=w,this._buffer.positions[_+1]=P,this._buffer.positions[_+2]=(this.forPathBevel?this._bevel:this._depth)-S,this._buffer.normals[_+0]=x*h,this._buffer.normals[_+1]=N*h,this._buffer.normals[_+2]=m,this._buffer.uvs[R+0]=T,this._buffer.uvs[R+1]=A,this.forPathBevel===!1&&(this._buffer.positions[_+3]=w,this._buffer.positions[_+4]=P,this._buffer.positions[_+5]=S,this._buffer.normals[_+3]=x*h,this._buffer.normals[_+4]=N*h,this._buffer.normals[_+5]=-m,this._buffer.uvs[R+2]=A,this._buffer.uvs[R+3]=T),p||(this.forPathBevel?(D+=1,_+=3,R+=2):(D+=2,_+=6,R+=4),V.topP=D+0,V.bottomP=D+1,this._buffer.positions[_+0]=w,this._buffer.positions[_+1]=P,this._buffer.positions[_+2]=(this.forPathBevel?this._bevel:this._depth)-S,this._buffer.normals[_+0]=E*h,this._buffer.normals[_+1]=M*h,this._buffer.normals[_+2]=m,this._buffer.uvs[R+0]=T,this._buffer.uvs[R+1]=A,this.forPathBevel===!1&&(this._buffer.positions[_+3]=w,this._buffer.positions[_+4]=P,this._buffer.positions[_+5]=S,this._buffer.normals[_+3]=E*h,this._buffer.normals[_+4]=M*h,this._buffer.normals[_+5]=-m,this._buffer.uvs[R+2]=A,this._buffer.uvs[R+3]=T)),this.vertexCache[s]=V,V}clone(){let e=new $i(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=ri(this.userData),e}};var Za=class extends Ln.BufferGeometry{constructor(e,r=12,o={}){super();this.type="ShapeGeometry";this.windingRule=Xe.ODD;this.elementType=Pt.POLYGONS;this.polySize=3;this.vertexSize=2;this.strict=!0;this._shape=e,this._curveSegments=r,this._triangulationOptions=Object.assign({windingRule:Xe.ODD,elementType:Pt.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,d;for(let h=0,m=n.length/2;h<m;h++){let y=h*2,g=n[y+0],b=n[y+1];if(u!==void 0&&g!==u&&(l=!1),d!==void 0&&b!==d&&(c=!1),u=g,d=b,!l&&!c)break}if(!l&&!c)try{s=fo({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=Bl}let p=s?.vertexCount??1,f=s?.elementCount??1;if(this._positionAttribute=new Ln.BufferAttribute(new Float32Array(p*3),3),this._normalAttribute=new Ln.BufferAttribute(new Float32Array(p*3),3),this._uvAttribute=new Ln.BufferAttribute(new Float32Array(p*2),2),this._indexAttribute=new Ln.BufferAttribute(new Uint32Array(f*3),1),s){let h=1/0,m=-1/0,y=1/0,g=-1/0;for(let P=0,S=p;P<S;P++){let T=P*2,A=s.vertices[T+0],x=s.vertices[T+1];A<h&&(h=A),A>m&&(m=A),x<y&&(y=x),x>g&&(g=x)}let b=m-h,w=g-y;for(let P=0,S=p;P<S;P++){let T=P*2,A=s.vertices[T+0],x=s.vertices[T+1],N=(A-h)/b,E=(x-y)/w;this._positionAttribute.setXYZ(P,A,x,0),this._normalAttribute.setXYZ(P,0,0,1),this._uvAttribute.setXY(P,N,E)}for(let P=0,S=f;P<S;P++){let T=P*3,A=s.elements[T+0],x=s.elements[T+1],N=s.elements[T+2];this._indexAttribute.setX(T+0,A),this._indexAttribute.setX(T+1,x),this._indexAttribute.setX(T+2,N)}}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 Za(this._shape,this._curveSegments);return e.userData=ri(this.userData),e}};var Ja=class extends $i{constructor(e,r,o=0,n=12,a=3,s=Xe.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 Ja(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=ri(this.userData),e}};var Tr=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:Xe.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 Ye?(a.width!==r||a.height!==o)&&a.applySize(r,o):a=new Ye(r,o).fromJSON(a),i.parameters?.roundness!==void 0&&i.parameters?.roundness>0&&a.update());let l=a??new Ye(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 Za(i.shape,o,{windingRule:a}):s=new Ja(i.shape,t,e,o,r,a),Object.assign(s,{userData:{...i,type:"VectorGeometry"}})}};var mo=require("three"),$x=Math.PI*2,ts=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=mo.MathUtils.clamp(e.angle,0,360),{shape:i.shape&&i.shape instanceof Ye?i.shape:new Ye,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,d=e*.5,p=sI(c,u,d,o*Math.PI/180,r,n);c.isClosed=!0,c.update();let f;return o===0?(f=new mo.BufferGeometry,f.setAttribute("position",new mo.Float32BufferAttribute([],3))):f=Tr.create({shape:c,parameters:{subdivisions:p,depth:a,extrudeBevelSize:s,extrudeBevelSegments:l}}),Object.assign(f,{userData:{...i,type:"EllipseGeometry"}})}};function sI(i,t,e,r,o,n){if(r>=$x)return o>30||o%4===0?(cI(i,t,e,n),Math.round(o/4)):qx(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=jx({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?lI(i,a.x,a.y,c,o,t,e,n):qx(i,r,o,t,e,n)}function lI(i,t,e,r,o,n,a,s){let l=Math.round(o/r.length);i.addPoint(es(t,e));for(let c=0,u=r.length;c<u;c++){let d=r[c],p=i.points[c],f=es(d.x,d.y);p.controls[1].position.set(d.x1,d.y1),f.controls[0].position.set(d.x2,d.y2),i.addPoint(f)}return s>0?Xx(i,n,a,s):i.addPoint(es(0,0)),l}function qx(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(es(c,u))}return t<$x?n>0?Xx(i,r,o,n):i.addPoint(es(0,0)):(i.removePoint(i.points[i.points.length-1]),n>0&&Yx(i,r,o,n)),1}function cI(i,t,e,r=0,o=0,n=0){let a=.5522847498,s=t*a,l=e*a;i.addPoint(Zu(o-t,n,o-t,n-l,o-t,n+l)),i.addPoint(Zu(o,n+e,o-s,n+e,o+s,n+e)),i.addPoint(Zu(o+t,n,o+t,n+l,o+t,n-l)),i.addPoint(Zu(o,n-e,o+s,n-e,o-s,n-e)),r>0&&Yx(i,t,e,r)}function es(i,t){return new po(mo.MathUtils.generateUUID(),new mo.Vector2(i,t))}function Zu(i,t,e,r,o,n){let a=es(i,t);return a.controls[0].position.set(e,r),a.controls[1].position.set(o,n),a}function Xx(i,t,e,r){Kx(i,t,e,r).forEach(n=>i.addPoint(n))}function Yx(i,t,e,r){let o=Kx(i,t,e,r),n=new Ye;o.forEach(a=>n.addPoint(a)),n.isClosed=!0,i.shapeHoles.push(n)}function Kx(i,t,e,r){let o=r*t/100,n=o*(Math.abs(e)/Math.abs(t)),a=new mo.Vector2(o/t,n/e),s=i.points.map(l=>{let c=l.clone();return c.uuid=mo.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 yo=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,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:d}=i.parameters,p=new Vl(!1,t,e,r,o,n,a,s,l,c,u,d);return Object.assign(p,{userData:{...i,type:"HelixGeometry"}})}},kf=new yo.Uint32BufferAttribute([0,0,0],1),Vl=class extends yo.BufferGeometry{constructor(t=!0,e=1,r=1,o=1,n=1,a=1,s=1,l=1,c=1,u=1,d=1,p=1){if(super(),a===0)return;let f=t&&a===1;f&&(p=0),d>100&&(d=100),d===0&&(p=0);let h=()=>new yo.Vector3,m=new yo.Vector3,y=h(),g=h(),b=h(),w,P,S,T,A,x,N,E,M=h(),D=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/p,Z=.01,Q=Math.min((1-d/100)*l,l-Z),$=l-Q,pe=0,le=2,ie=p*le+le,ue=Y*ie/le,ae=ue+Y*W,ge=Math.max(0,Y*(W+ie)),[me,ye,Se]=[3,3,2].map(bt=>Array(ge*bt).fill(0)),xe=[],C=n-l;function ne(bt,at){let io=Math.PI/2;x=at*ee,E=2*Math.PI*(x%F)/F+io,x+=te,N=Math.sin(E)*C,A=Math.cos(E)*C,t?bt.set(A,N,x):bt.set(A,x,N)}ne(m,-1e-10),ne(y,0),M.copy(m),ne(m,1);let ze=m.distanceTo(y),He=f?0:$+Q,Fe=ze*H+2*He,Ae=Q,Ut=Fe-He;for(let bt=0;bt<=H;bt++){ne(g,bt),q.subVectors(g,M).normalize(),M.copy(g),U.copy(g).setComponent(+t+1,0).normalize(),B.crossVectors(q,U).normalize();let at=bt===0,io=bt===H,vp=at?3*Math.PI/2:K,Sp=at?Ae:Ut,Pc=at?Y:ae,bn=at?0:ge-Y,Ct=q.clone().multiplyScalar(at?-$:$).add(g),wp=q.clone().multiplyScalar(at?-1:1).normalize();for(let jr=0;jr<Y;jr++){let nl=jr*re;if(D.addVectors(m.copy(U).multiplyScalar(l*Math.cos(nl)),y.copy(B).multiplyScalar(l*Math.sin(nl))),_.copy(D).normalize(),at||io){f||(pe=bn+jr,[0,1,2].forEach(pr=>{me[pe*3+pr]=Ct.getComponent(pr),ye[pe*3+pr]=wp.getComponent(pr)}),Se[pe*2]=+io,Se[pe*2+1]=jr/u),y.copy(_).multiplyScalar(Q),b.addVectors(g,y);for(let pr=0;pr<p;pr++){let vn=pr*K+vp;R.addVectors(m.copy(q).multiplyScalar($*Math.sin(vn)),y.copy(_).multiplyScalar($*Math.cos(vn))),V.copy(R).normalize(),y.addVectors(b,R),R.normalize(),pe=Pc+pr*Y+jr,[0,1,2].forEach(Jn=>{me[pe*3+Jn]=y.getComponent(Jn),ye[pe*3+Jn]=V.getComponent(Jn)});let Oc=+at+Math.sin(vn);Se[pe*2]=(Sp+$*Oc)/Fe,Se[pe*2+1]=jr/u}}y.addVectors(g,D),pe=ue+bt*Y+jr,[0,1,2].forEach(pr=>{me[pe*3+pr]=y.getComponent(pr),ye[pe*3+pr]=_.getComponent(pr)}),Se[pe*2]=(He+bt*ze)/Fe,Se[pe*2+1]=jr/u}}let Re=W+2*p+le,Ft=1,[kt,xn]=[+f,Re-1];for(let bt=kt;bt<=xn-1;bt++){let at=f&&bt===xn-1;for(let io=0;io<Y-1;io++)w=bt*Y+io,P=w+1,S=(at?io:w)+Y,T=(at?io+1:P)+Y,bt===0?xe.push(P,T,S):bt===Re-2?xe.push(w,P,S):xe.push(w,P,S,P,T,S)}this.setIndex(xe),this.setAttribute("position",new yo.Float32BufferAttribute(me,3)),this.setAttribute("normal",new yo.Float32BufferAttribute(ye,3)),this.setAttribute("uv",new yo.Float32BufferAttribute(Se,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,d=u===e;for(let p=0;p<t.radialSegments;p++)n=u*r+p,a=n+1,s=(d?p:n)+r,l=(d?p+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,kf.array=o,kf.count=o.length,kf}};var Zx=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 zl(t*.5,n,a):new Zx.IcosahedronGeometry(t*.5,o);return s.scale(1,e/t,r/t),Object.assign(s,{userData:{...i,type:"IcosahedronGeometry"}})}},zl=class extends Wi{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 zl(t.radius,t.corner,t.cornerSides)}};var Ju=require("three"),eb=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 Ju.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 Ju.LatheGeometry(o.extractPoints(r).shape,e);return n.rotateZ(Math.PI),Object.assign(n,{userData:{...i,type:"LatheGeometry"}})}};var zo=require("three");var pi=require("three");var he=require("three"),Vo=new he.Matrix4,Hf=new he.Object3D,ed=new he.Vector3,Xi=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 Vo.makeRotationX(t),this.applyMatrix4(Vo),this}rotateY(t){return Vo.makeRotationY(t),this.applyMatrix4(Vo),this}rotateZ(t){return Vo.makeRotationZ(t),this.applyMatrix4(Vo),this}translate(t,e,r){return Vo.makeTranslation(t,e,r),this.applyMatrix4(Vo),this}scale(t,e,r){return Vo.makeScale(t,e,r),this.applyMatrix4(Vo),this}lookAt(t){return Hf.lookAt(t),Hf.updateMatrix(),this.applyMatrix4(Hf.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 p=0;p<n.count;p++)e.vertices.push(new he.Vector3().fromBufferAttribute(n,p)),s!==void 0&&e.colors.push(new he.Color().fromBufferAttribute(s,p));function u(p,f,h,m){let y=s===void 0?[]:[e.colors[p].clone(),e.colors[f].clone(),e.colors[h].clone()],g=a===void 0?[]:[new he.Vector3().fromBufferAttribute(a,p),new he.Vector3().fromBufferAttribute(a,f),new he.Vector3().fromBufferAttribute(a,h)],b=new rs(p,f,h,g,y,m);e.faces.push(b),l!==void 0&&e.faceVertexUvs[0].push([new he.Vector2().fromBufferAttribute(l,p),new he.Vector2().fromBufferAttribute(l,f),new he.Vector2().fromBufferAttribute(l,h)]),c!==void 0&&e.faceVertexUvs[1].push([new he.Vector2().fromBufferAttribute(c,p),new he.Vector2().fromBufferAttribute(c,f),new he.Vector2().fromBufferAttribute(c,h)])}let d=t.groups;if(d.length>0)for(let p=0;p<d.length;p++){let f=d[p],h=f.start,m=f.count;for(let y=h,g=h+m;y<g;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 p=0;p<r.count;p+=3)u(r.getX(p),r.getX(p+1),r.getX(p+2));else for(let p=0;p<n.count;p+=3)u(p,p+1,p+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(ed).negate(),this.translate(ed.x,ed.y,ed.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 Xi;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,d=t.colors;e!==void 0&&(o=new he.Matrix3().getNormalMatrix(e));for(let p=0,f=s.length;p<f;p++){let m=s[p].clone();e!==void 0&&m.applyMatrix4(e),a.push(m)}for(let p=0,f=d.length;p<f;p++)u.push(d[p].clone());for(let p=0,f=c.length;p<f;p++){let h=c[p],m,y,g=h.vertexNormals,b=h.vertexColors,w=new rs(h.a+n,h.b+n,h.c+n);w.normal.copy(h.normal),o!==void 0&&w.normal.applyMatrix3(o).normalize();for(let P=0,S=g.length;P<S;P++)m=g[P].clone(),o!==void 0&&m.applyMatrix3(o).normalize(),w.vertexNormals.push(m);w.color.copy(h.color);for(let P=0,S=b.length;P<S;P++)y=b[P],w.vertexColors.push(y.clone());w.materialIndex=h.materialIndex+r,l.push(w)}for(let p=0,f=t.faceVertexUvs.length;p<f;p++){let h=t.faceVertexUvs[p];this.faceVertexUvs[p]===void 0&&(this.faceVertexUvs[p]=[]);for(let m=0,y=h.length;m<y;m++){let g=h[m],b=[];for(let w=0,P=g.length;w<P;w++)b.push(g[w].clone());this.faceVertexUvs[p].push(b)}}}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],d=Math.round(u.x*n)+"_"+Math.round(u.y*n)+"_"+Math.round(u.z*n);e[d]===void 0?(e[d]=l,r.push(this.vertices[l]),o[l]=r.length-1):o[l]=o[e[d]]}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 d=[u.a,u.b,u.c];for(let p=0;p<3;p++)if(d[p]===d[(p+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,d=this.faceVertexUvs.length;u<d;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,g=!1,b=this.faceVertexUvs[0][h]!==void 0,w=m.normal.length()>0,P=m.vertexNormals.length>0,S=m.color.r!==1||m.color.g!==1||m.color.b!==1,T=m.vertexColors.length>0,A=0;if(A=u(A,0,0),A=u(A,1,y),A=u(A,2,g),A=u(A,3,b),A=u(A,4,w),A=u(A,5,P),A=u(A,6,S),A=u(A,7,T),r.push(A),r.push(m.a,m.b,m.c),r.push(m.materialIndex),b){let x=this.faceVertexUvs[0][h];r.push(f(x[0]),f(x[1]),f(x[2]))}if(w&&r.push(d(m.normal)),P){let x=m.vertexNormals;r.push(d(x[0]),d(x[1]),d(x[2]))}if(S&&r.push(p(m.color)),T){let x=m.vertexColors;r.push(p(x[0]),p(x[1]),p(x[2]))}}function u(h,m,y){return y?h|1<<m:h&~(1<<m)}function d(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 p(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 Xi().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 p=0,f=e.length;p<f;p++)this.vertices.push(e[p].clone());let r=t.colors;for(let p=0,f=r.length;p<f;p++)this.colors.push(r[p].clone());let o=t.faces;for(let p=0,f=o.length;p<f;p++)this.faces.push(o[p].clone());for(let p=0,f=t.faceVertexUvs.length;p<f;p++){let h=t.faceVertexUvs[p];this.faceVertexUvs[p]===void 0&&(this.faceVertexUvs[p]=[]);for(let m=0,y=h.length;m<y;m++){let g=h[m],b=[];for(let w=0,P=g.length;w<P;w++){let S=g[w];b.push(S.clone())}this.faceVertexUvs[p].push(b)}}let n=t.morphTargets;for(let p=0,f=n.length;p<f;p++){let h={};if(h.name=n[p].name,n[p].vertices!==void 0){h.vertices=[];for(let m=0,y=n[p].vertices.length;m<y;m++)h.vertices.push(n[p].vertices[m].clone())}if(n[p].normals!==void 0){h.normals=[];for(let m=0,y=n[p].normals.length;m<y;m++)h.normals.push(n[p].normals[m].clone())}this.morphTargets.push(h)}let a=t.morphNormals;for(let p=0,f=a.length;p<f;p++){let h={};if(a[p].vertexNormals!==void 0){h.vertexNormals=[];for(let m=0,y=a[p].vertexNormals.length;m<y;m++){let g=a[p].vertexNormals[m],b={};b.a=g.a.clone(),b.b=g.b.clone(),b.c=g.c.clone(),h.vertexNormals.push(b)}}if(a[p].faceNormals!==void 0){h.faceNormals=[];for(let m=0,y=a[p].faceNormals.length;m<y;m++)h.faceNormals.push(a[p].faceNormals[m].clone())}this.morphNormals.push(h)}let s=t.skinWeights;for(let p=0,f=s.length;p<f;p++)this.skinWeights.push(s[p].clone());let l=t.skinIndices;for(let p=0,f=l.length;p<f;p++)this.skinIndices.push(l[p].clone());let c=t.lineDistances;for(let p=0,f=c.length;p<f;p++)this.lineDistances.push(c[p]);let u=t.boundingBox;u!==null&&(this.boundingBox=u.clone());let d=t.boundingSphere;return d!==null&&(this.boundingSphere=d.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 Wf().fromGeometry(this),e=new he.BufferGeometry,r=new Float32Array(t.vertices.length*3);if(e.setAttribute("position",td.call(new he.BufferAttribute(r,3),t.vertices)),t.normals.length>0){let o=new Float32Array(t.normals.length*3);e.setAttribute("normal",td.call(new he.BufferAttribute(o,3),t.normals))}if(t.colors.length>0){let o=new Float32Array(t.colors.length*3);e.setAttribute("color",tb.call(new he.BufferAttribute(o,3),t.colors))}if(t.uvs.length>0){let o=new Float32Array(t.uvs.length*2);e.setAttribute("uv",rb.call(new he.BufferAttribute(o,2),t.uvs))}if(t.uvs2.length>0){let o=new Float32Array(t.uvs2.length*2);e.setAttribute("uv2",rb.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(td.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",ob.call(o,t.skinIndices))}if(t.skinWeights.length>0){let o=new he.Float32BufferAttribute(t.skinWeights.length*4,4);e.setAttribute("skinWeight",ob.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",td.call(o,r.vertices)),e.setAttribute("color",tb.call(n,r.colors)),r.lineDistances&&r.lineDistances.length===r.vertices.length){let a=new he.Float32BufferAttribute(r.lineDistances.length,1);e.setAttribute("lineDistance",uI.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}};Xi.prototype.isGeometry=!0;var Wf=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 g=0;g<l;g++)c[g]={name:s[g].name,data:[]};this.morphTargets.position=c}let u=t.morphNormals,d=u.length,p;if(d>0){p=[];for(let g=0;g<d;g++)p[g]={name:u[g].name,data:[]};this.morphTargets.normal=p}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 g=0;g<e.length;g++){let b=e[g];this.vertices.push(r[b.a],r[b.b],r[b.c]);let w=b.vertexNormals;if(w.length===3)this.normals.push(w[0],w[1],w[2]);else{let S=b.normal;this.normals.push(S,S,S)}let P=b.vertexColors;if(P.length===3)this.colors.push(P[0],P[1],P[2]);else{let S=b.color;this.colors.push(S,S,S)}if(n===!0){let S=o[0][g];S!==void 0?this.uvs.push(S[0],S[1],S[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv ",g),this.uvs.push(new he.Vector2,new he.Vector2,new he.Vector2))}if(a===!0){let S=o[1][g];S!==void 0?this.uvs2.push(S[0],S[1],S[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv2 ",g),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[b.a],T[b.b],T[b.c])}for(let S=0;S<d;S++){let T=u[S].vertexNormals[g];p[S].data.push(T.a,T.b,T.c)}m&&this.skinIndices.push(f[b.a],f[b.b],f[b.c]),y&&this.skinWeights.push(h[b.a],h[b.b],h[b.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}},rs=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 uI(i){return this.array.set(i),this}function tb(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 rb(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 td(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 ob(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 dI=["a","b","c"];function pI(i,t){switch(t){case"c":return i.c;case"b":return i.b;case"a":default:return i.a}}function qf(i,t,e){let r=Math.min(i,t),o=Math.max(i,t),n=r+"_"+o;return e.get(n)}function $f(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],d=e[s];c={a:u,b:d,newEdge:null,faces:[]},r.set(l,c)}c.faces.push(o),n[i].edges.push(c),n[t].edges.push(c)}function fI(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],$f(a.a,a.b,i,r,a,e),$f(a.b,a.c,i,r,a,e),$f(a.c,a.a,i,r,a,e)}function rd(i,t,e,r,o){i.push(new rs(t,e,r,void 0,void 0,o))}function os(i,t){return Math.abs(t-i)/2+Math.min(i,t)}function od(i,t,e,r){i.push([t.clone(),e.clone(),r.clone()])}var id=class{constructor(t=1){this.subdivisions=t}modify(t){t instanceof pi.BufferGeometry?t=new Xi().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 pi.Vector3,r,o,n,a,s,l=t.vertices,c=t.faces,u=t.faceVertexUvs[0],d=u!==void 0&&u.length>0,p=[],f=new Map;fI(l,c,p,f);let h=[],m,y,g,b,w,P,S;for(let Z of Array.from(f.keys())){for(y=f.get(Z),g=new pi.Vector3,w=3/8,P=1/8,S=y.faces.length,S!=2&&(w=.5,P=0,S!=1),g.addVectors(y.a,y.b).multiplyScalar(w),e.set(0,0,0),a=0;a<S;a++){for(b=y.faces[a],s=0;s<3&&(m=l[pI(b,dI[s])],!(m!==y.a&&m!==y.b));s++);m&&e.add(m)}e.multiplyScalar(P),g.add(e),y.newEdge=h.length,h.push(g)}let T,A,x,N,E,M,D,_=[];for(o=0,n=l.length;o<n;o++){for(M=l[o],E=p[o].edges,r=E.length,r==3?T=3/16:r>3&&(T=3/(8*r)),A=1-r*Number(T),x=T,r<=2&&(r==2?(A=3/4,x=1/8):r==1||r==0),D=M.clone().multiplyScalar(A),e.set(0,0,0),a=0;a<r;a++)N=E[a],m=N.a!==M?N.a:N.b,e.add(m);e.multiplyScalar(Number(x)),D.add(e),_.push(D)}let R=_.concat(h),V=_.length,U,B,q,j=[],F=[],H,W,ee,te,Y=new pi.Vector2,re=new pi.Vector2,K=new pi.Vector2;for(o=0,n=c.length;o<n;o++)b=c[o],U=Number(qf(b.a,b.b,f).newEdge)+V,B=Number(qf(b.b,b.c,f).newEdge)+V,q=Number(qf(b.c,b.a,f).newEdge)+V,rd(j,U,B,q,b.materialIndex),rd(j,b.a,U,q,b.materialIndex),rd(j,b.b,B,U,b.materialIndex),rd(j,b.c,q,B,b.materialIndex),d&&(H=u[o],W=H[0],ee=H[1],te=H[2],Y.set(os(W.x,ee.x),os(W.y,ee.y)),re.set(os(ee.x,te.x),os(ee.y,te.y)),K.set(os(W.x,te.x),os(W.y,te.y)),od(F,Y,re,K),od(F,W,Y,K),od(F,ee,re,Y),od(F,te,K,re));t.vertices=R,t.faces=j,d&&(t.faceVertexUvs[0]=F)}};var $t=new zo.Vector3,ib=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=i.geometry??t?.geometry??new zo.BufferGeometry().copy(new zo.BoxGeometry(100,100,100)),r;t===void 0?(e.computeBoundingBox(),e.boundingBox.getSize($t),r={width:$t.x,height:$t.y,depth:$t.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 zo.BufferGeometry().copy(new zo.BoxGeometry(100,100,100)),a=n.userData.parameters;a===void 0?(n.computeBoundingBox(),n.boundingBox.getSize($t)):$t.set(a.width,a.height,a.depth),(t!==$t.x||e!==$t.y||r!==$t.z)&&n.scale($t.x===0?1:t/$t.x,$t.y===0?1:e/$t.y,$t.z===0?1:r/$t.z);let s=n.originalGeometry;try{o>0?(s===void 0||a?.subdivisions!==o)&&(s===void 0&&(s=n),n=new id(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 zo.BufferGeometryLoader(e).load(i,o=>{let n=this.normalizeInputs({geometry:o});o.boundingBox.getSize($t);let a=100/$t.x;Object.assign(n.parameters,{width:100,height:$t.y*a,depth:$t.z*a}),t(this.build(n))})}};var nd=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 Ye?i.shape:new Ye,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,d=0,p=0,f=2*Math.PI/r;for(let m=0;m<r;m++){let y=f*m,g=d+Math.sin(y)*c,b=p+Math.cos(y)*u;l.addPoint(l.createPoint(g,b))}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=Tr.create({shape:l,parameters:{roundness:o,depth:n,extrudeBevelSize:a,extrudeBevelSegments:s}});return Object.assign(h,{userData:{...i,type:"PolygonGeometry"}})}};var qe=require("three"),nb=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 Yf(t*.5,e,o,n,a,s,l);return c.scale(1,1,r/t),Object.assign(c,{userData:{...i,type:"PyramidGeometry"}})}};function Gl(i,t,e){e.x=i.x*t.x,e.y=i.y,e.z=i.x*t.y}function Xf(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 hI(i,t,e){let r=i.clone().sub(t),o=e.clone().sub(t);return r.projectOnVector(o),r.add(t)}var Yf=class extends qe.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=[],d=[],p=0,f=e/2,h=Math.PI/r,m=t*Math.cos(Math.PI/r),y=2*Math.PI/r,g=(r-2)*Math.PI/r,b=Math.PI-g,w=new qe.Vector3(0,-f,0),P=new qe.Vector3(0,f,0),S=new qe.Vector2(t,-f),T=new qe.Vector2(m,-f),A=new qe.Vector2(0,P.y).sub(T),x=new qe.Vector2(0,P.y).sub(S),N=new qe.Vector2(A.y,-A.x).normalize(),E=new qe.Vector2(x.y,-x.x).normalize(),D=t*Math.cos(Math.PI/r)*Math.tan((Math.PI-A.angle())/2)-1e-8;a=Math.min(a,D);let _;{let F=new qe.Vector3(N.x,N.y,0),H=new qe.Vector3(Math.cos(y)*F.x,F.y,Math.sin(y)*F.x);_=F.angleTo(H)}let R=a/Math.tan((Math.PI-A.angle())/2),V=a/Math.tan((Math.PI-_)/2),U=new qe.Vector3;if(!n){c.push(w.x,w.y,w.z),u.push(0,-1,0),d.push(0,0);let F=p++,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 qe.Vector2(Math.sin(Y),Math.cos(Y));Gl(W,re,U),c.push(U.x,U.y,U.z),u.push(0,-1,0),d.push(0,0),H.push(p++)}for(let te=0;te<H.length;te++)l.push(H[te],F,H[(te+1)%H.length])}let B=[];{let F=new qe.Vector3,H=new qe.Vector3,W=new qe.Vector3,ee=new qe.Vector3,te=new qe.Vector3,Y=new qe.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 qe.Vector2(Math.sin(K),Math.cos(K)),pe=new qe.Vector2(Math.sin(Z),Math.cos(Z)),le=new qe.Vector2(Math.sin(Q),Math.cos(Q));Gl(S,$,H),Gl(S,le,W),Gl(N,pe,F),Xf(P,H,W,V,V,ee),c.push(ee.x,ee.y,ee.z),Xf(H,P,W,V,R,te),c.push(te.x,te.y,te.z),Xf(W,H,P,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),d.push(0,0),d.push(0,0),d.push(0,0);let ie=p++,ue=p++,ae=p++;if(l.push(ie,ue,ae),a>0){{let ye=H.clone().add(W).multiplyScalar(.5),Se=P.clone().sub(ye).normalize(),C=w.clone().sub(ye).normalize().add(Se).normalize().multiplyScalar(-1),ne=Y.clone().sub(te);q(ye,ne,C,A.angle())}let ge,me;{let ye=new qe.Vector3;Gl(E,le,ye);let Se=Y.clone().add(ee).multiplyScalar(.5);Se=hI(Se,W,P);let xe=Y.clone().sub(ee);[ge,me]=q(Se,xe,ye,_,ee.y)}{let ye=ge,Se=ye.clone().setY(0).normalize(),xe=new qe.Vector3(0,-1,0),C=Se.clone().cross(xe);j(ye,Se,xe,C)}B.concat(me);{let ye=A.angle(),Se=Math.PI-ye,xe=P.clone();xe.y-=a/Math.sin(ye-Math.PI/2);let C=new qe.Vector3,ne=[];for(let He=0;He<s;He++){let Fe=[],Ae=Math.PI/2-Se*He/s,Ut=Math.cos(Ae),Re=Math.sin(Ae),Ft=Z;for(let kt=0;kt<=He;kt++){let xn=Math.cos(Ft),bt=Math.sin(Ft);F.x=Ut*bt,F.y=Re,F.z=Ut*xn,C.copy(xe).addScaledVector(F,a),c.push(C.x,C.y,C.z),u.push(F.x,F.y,F.z),d.push(0,0),Fe.push(p++),Ft+=Math.PI*2/He/r}ne.push(Fe)}me.reverse(),ne.push(me);let ze=ne.length-1;for(let He=0;He<ze;He++){let Fe=ne[He],Ae=ne[He+1],Ut=Fe.length-1;l.push(Ae[1],Fe[0],Ae[0]);for(let Re=1;Re<=Ut;Re++)l.push(Fe[Re],Fe[Re-1],Ae[Re]),l.push(Ae[Re+1],Fe[Re],Ae[Re])}}}}}this.setIndex(l),this.setAttribute("position",new qe.Float32BufferAttribute(c,3)),this.setAttribute("normal",new qe.Float32BufferAttribute(u,3)),this.setAttribute("uv",new qe.Float32BufferAttribute(d,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 qe.Vector3,Q=new qe.Vector3,$=1,pe=p,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),d.push(0,0),ae===0&&le.push(p),p++}}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=x.angle()-te,re=[],K=new qe.Vector3,Z=new qe.Vector3;for(let $=0;$<=s;$++){let pe=[],le=$/s;for(let ie=0;ie<=$;ie++){let ae=(($?ie/$:0)-.5)*b,ge=Math.cos(ae),me=Math.sin(ae),ye=Math.atan(Math.tan(Y)*ge),Se=(te+ye)*le,xe=Math.cos(Se),C=Math.sin(Se);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),d.push(0,0),pe.push(p++)}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 is=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 Ye?i.shape:new Ye,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},d={x:c.x,y:c.y};function p(P,S,T){return S>e&&T>r?Math.min(P*e/S,P*r/T):S>e?P*e/S:T>r?P*r/T:P}let f=[];f[0]=o[0]===0?0:p(o[0],o[0]+o[3],o[0]+o[1]),f[1]=o[1]===0?0:p(o[1],o[1]+o[2],o[1]+o[0]),f[2]=o[2]===0?0:p(o[2],o[2]+o[1],o[2]+o[3]),f[3]=o[3]===0?0:p(o[3],o[3]+o[0],o[3]+o[2]);let h=u.x,m=d.x,y=d.y,g=u.y;t.addPoint(t.createPoint(h,y)),t.addPoint(t.createPoint(m,y)),t.addPoint(t.createPoint(m,g)),t.addPoint(t.createPoint(h,g)),t.isClosed=!0;let b=!0;for(let P=0,S=t.points.length;P<S;P++)t.points[P].roundness=f[P],P>0&&f[P]!==f[P-1]&&(b=!1);b&&(t.roundness=f[0]),t.useCubicForRoundedCorners=n!==1,t.update();let w=Tr.create({shape:t,parameters:{depth:a,extrudeBevelSize:s,extrudeBevelSegments:l}});return Object.assign(w,{userData:{...i,type:"RectangleGeometry"}})}};var fi=require("three"),ab=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=fi.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 fi.BufferGeometry,u.setAttribute("position",new fi.Float32BufferAttribute([],3))):u=new fi.SphereGeometry(.5*t,o,n,a,s,l,c*fi.MathUtils.DEG2RAD),u.scale(1,e/t,r/t),Object.assign(u,{userData:{...i,type:"SphereGeometry"}})}};var sb=require("three"),lb=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 sb.PlaneGeometry(t,e,r,o);return n.scale(1,1,1),Object.assign(n,{userData:{...i,type:"PlaneGeometry"}})}};var Yi=require("three"),cb=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 Kf(t,e,r,o,n,a);return Object.assign(s,{userData:{...i,type:"BackdropGeometry"}})}},Kf=class extends Yi.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 d=[],p=Math.PI/2,f=(Z=0,Q=0,$=0)=>new Yi.Vector3(Z,Q,$),h=f(),m=f(),[y,g,b]=[e/2,t/2,r/2],w=-g,P=+g,[S,T,A]=[f(w,-y,+b),f(w,-y,-b),f(w,+y,-b)],x=(Z,Q=!1)=>Math.sin(Z-Math.PI/(1+ +Q)),N=(Z,Q=!1)=>Math.cos(Z-Math.PI/(1+ +Q));A.y=Math.sin(o)*e-y;let E=Math.cos(o)*e-b,M=S.z-u;o<=p?(A.z=Math.min(E,M),A.z==M&&(A.y-=(E-M)/Math.tan(p-o))):T.z=Math.min(T.z-E-b,S.z-u),h.subVectors(S,T),m.subVectors(A,T);let D=Math.min(h.length(),m.length())*n/100,_=D*Math.tan(o/2),R=D/Math.cos(o/2),V=h.clone().normalize().add(m.normalize()).setLength(R).add(T);h.set(0,x(o,!0),N(o,!0)),d.push([A,h.clone()]);let U=(Math.PI-o)/a;for(let Z=0;Z<=a;Z++){let Q=p+o+Z*U;h.set(0,Math.sin(Q)*_,Math.cos(Q)*_),h.add(V),m.set(0,x(Q),N(Q)),d.push([h.clone(),m.clone()])}d.push([S,f(0,1,0)]);let B=Math.sin(U/2)*_*2,q=d.length-1,j=d[0][0].distanceTo(d[1][0]),F=d[q-1][0].distanceTo(d[q][0]),H=j+B*a+F;d[0].push(1);for(let Z=0;Z<=a;Z++)d[Z+1].push(1-(j+Z*B)/H);d[q].push(0);let[W,ee,te]=d[0],Y,re,K;for(let Z=1;Z<d.length;Z++)[Y,re,K]=d[Z],s.push(w,W.y,W.z,w,Y.y,Y.z,P,W.y,W.z,P,W.y,W.z,w,Y.y,Y.z,P,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 Yi.Float32BufferAttribute(s,3)),this.setAttribute("normal",new Yi.Float32BufferAttribute(l,3)),this.setAttribute("uv",new Yi.Float32BufferAttribute(c,2))}};var ad=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 Ye?i.shape:new Ye,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,d=t*.5,p=e*.5,f=0,h=0,m=a*Math.PI/360/o,y=Math.PI/2*3*-1,g=d*r/100,b=p*r/100;if(o===3&&r===50){m=2*Math.PI/o;for(let P=0;P<o;P++){let S=m*P,T=f+Math.sin(S)*d,A=h+Math.cos(S)*p;u.addPoint(u.createPoint(T,A))}}else for(let P=0;P<o;P++){let S=f+Math.cos(y)*d,T=h+Math.sin(y)*p;u.addPoint(u.createPoint(S,T)),y+=m,S=f+Math.cos(y)*g,T=h+Math.sin(y)*b,P<=o,u.addPoint(u.createPoint(S,T)),y+=m}u.isClosed=!0;for(let P=0,S=u.points.length;P<S;P++)u.points[P].roundness=n;u.roundness=n,u.update();let w=Tr.create({shape:u,parameters:{roundness:n,depth:s,extrudeBevelSize:l,extrudeBevelSegments:c}});return Object.assign(w,{userData:{...i,type:"StarGeometry"}})}};var ub=require("three"),db=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 ub.PlaneGeometry(t,e);return Object.assign(r,{userData:{...i,type:"TextFrameGeometry"}})}};var ns=require("three");var pb=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=mI(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 mI(i,t,e,r,o,n,a,s,l,c,u){[t,e]=[e,t],a=t/2;let d=ns.MathUtils.clamp(o/360,0,1);if(d===0){let p=new ns.BufferGeometry;return p.setAttribute("position",new ns.Float32BufferAttribute([],3)),p}return d===1&&(c=0),new Vl(!0,i,t,e,r,d,n,a,s,l,c,u)}var fb=require("three"),hb=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 fb.TorusKnotGeometry(s,e,r,o,n,a);return Object.assign(l,{userData:{...i,type:"TorusKnotGeometry"}})}};var mb=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 Ye?i.shape:new Ye,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 p=0,f=l.points.length;p<f;p++)l.points[p].roundness=r;l.roundness=r,l.update();let d=Tr.create({shape:l,parameters:{roundness:r,depth:o,extrudeBevelSize:n,extrudeBevelSegments:a}});return Object.assign(d,{userData:{...i,type:"TriangleGeometry"}})}};var Ee=require("three");function yb(i,t){let e=2*Math.PI;return(i%e+e)%e===(t%e+e)%e}function yI(i){return/^(rgba)?\(\s*(\d+),\s*(\d+),\s*(\d+)(?:,\s*(\d+(?:\.\d+)?))?\s*\)$/.exec(i.toLowerCase())}function gI(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 xI(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 bI(i){return i=Math.floor(i),{r:i>>16&255,g:i>>8&255,b:i&255}}function vI(i,t,e){return(i<<16)+(t<<8)+e}function SI(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 wI(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 gb={parseRgba:yI,hsvToRgb:gI,rgbToHsv:xI,hexToRgb:bI,rgbToHex:vI,rgbToHexString:SI,hexStringToRgb:wI};function hi(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 sd=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=hi();this._innerCallUserAPI=async t=>{this.emitter.emit("start",{userAPIId:this.id}),this.isLoading=!0,this.isLoading=!1;try{this.result=await AI(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=ru(this.prefetch,1e3,{trailing:!0})}_updateDebouncedCallUserAPI(){this._debouncedCallUserAPI=this.userAPI.debounce!==void 0&&this.userAPI.debounce>0?ru(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 dt.zoom(this.result,t)}catch(e){console.error(e)}}retrieveZoomedKeyValues(t){if(this.result){let e=t&&t.length?dt.zoom(this.result,t):this.result;if(CI(e))return Object.entries(e);if(TI(e))return e.map((r,o)=>[o.toString(),r]);throw OI(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 OI(i){return typeof i=="string"||typeof i=="number"||typeof i=="boolean"||i===null}function TI(i){return Array.isArray(i)}function CI(i){return typeof i=="object"&&i!==null}async function AI(i,t,e=new AbortController){let r,o=i.url,n=i.proxy?.enabled??!1,a;if(i.integration?.type==="OpenAI"){let l=Fl(i.integration.prompt===""?[]:JSON.parse(i.integration.prompt),t),c=i.integration.behavior===""?[]:Fl(JSON.parse(i.integration.behavior),t);a=`{
4
4
  "model": "${i.integration.model}",
5
5
  "messages": [${i.integration.useBehavior?`
6
6
  {
@@ -12,14 +12,14 @@ best distance: ${p.d}`);let g=[p.x,p.y];return g.distance=p.d,g.distance}functio
12
12
  "content": "${l}"
13
13
  }
14
14
  ]
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=Fl(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=Fl(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 gb=(i,t)=>{if(typeof i=="string"){let e=t.getVariable(i);if(e)return gb(e,t)}return Ui.isBoolean(i)?Ui.getDisplayedValue(i).toLowerCase():Ui.getDisplayedValue(i)},Fl=(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
- `:"")+Fl(e.children,t);if(e.type==="variable"){let o=t.getVariable(e.variableId);if(o!==void 0)return gb(o,t)}}return""}).join("");var MI=new Ee.Matrix4,II=new Ee.Matrix4;function EI(i,t,e){let r=[new Ee.Vector3,new Ee.Vector3,new Ee.Vector3],o=[new Ee.Vector3,new Ee.Vector3,new Ee.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=Ee.MathUtils.lerp(n.length(),s.length(),e);n.lerp(s,e).setLength(l)}),new Ee.Matrix4().makeBasis(r[0],r[1],r[2])}var xb=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??ts.create({parameters:{...In,width:typeof In.width=="number"?In.width:100,height:typeof In.height=="number"?In.height:100}}).userData.shape;return{path:i.path??Ba.defaultData(),parameters:Object.assign(e,{width:r,height:o,depth:n,extrusion:{...Cu,...e.extrusion}}),shapeData:a}}static build(i){if(i.path.points.length>=2){let e=new Kf(i);return Object.assign(e,{userData:{...i,type:"PathGeometry"}})}else return Object.assign(new Ee.BufferGeometry,{userData:{...i,type:"PathGeometry"}})}},Kf=class extends Ee.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)||!mb(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=[],d=[];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()),d.push(r[F].clone())}let p=(j,F,H)=>{u[j]=u[j].clone().lerp(u[F],H),d[j]=EI(d[j],d[F],H)},f=0,h=n*a%1;(!this.inputs.path.isClosed||o<=1)&&(h||n===0)&&(f=h,p(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,p(u.length-1,u.length-2,1-m)),o===0){let j=u.length-1;u[j].copy(u[0]),d[j].copy(d[0])}this._applyPathModifiers(d,f,m);let{bevel:g,bevelSides:b}=this.inputs.parameters.extrusion,w=g>0?this.inputs.parameters.extrusion.capType:"flat",P=5;this.inputs.parameters.extrusion.shape.type==="Custom"&&(P=this.inputs.parameters.extrusion.shape.shapeQuality==="low"?5:12);let{regions:S,infos:T,vertices:A}=this._computeShapePoints(P),x=0,N;w==="round"&&(N=new $i(this.inputs.shapeData,2*g,g,P,b,void 0,!0),x=N.getAttribute("position").count);let E=0,M=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),M+=j.verticesCount,E=M});let D=M*c,_,R=0;if(this._isOpenEnded()&&w==="flat"){try{_=fo({windingRule:Xe.ODD,elementType:Pt.POLYGONS,polySize:3,vertexSize:2,strict:!0,contours:S})}catch{_=jf}R=_.vertexCount}let V=D+2*R+x*2,U=D+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,A,d,u,B,q,this._isGeometryClosed()&&!this._isOpenEnded())}),_&&(this._closeEnd(_,D,q,B,d[0],u[0],!1),this._closeEnd(_,D+R,q,B,d[d.length-1],u[u.length-1],!0)),N){B.positions.set(N.getAttribute("position").array,U*3),B.normals.set(N.getAttribute("normal").array,U*3),B.uvs.set(N.getAttribute("uv").array,U*2);for(let W=U;W<U+x;W++)B.uvs[W*2+1]=1e-4;let j=q.length;q.push(...N.getIndex().array.map(W=>W+U)),U+=x,B.positions.set(N.getAttribute("position").array,U*3),B.normals.set(N.getAttribute("normal").array,U*3),B.uvs.set(N.getAttribute("uv").array,U*2);let F=q.length;q.push(...N.getIndex().array.map(W=>W+U)),this.setAttribute("position",new Ee.BufferAttribute(B.positions,3)),this.setAttribute("normal",new Ee.BufferAttribute(B.normals,3)),this.setAttribute("uv",new Ee.BufferAttribute(B.uvs,2)),this.setIndex(q);let H=MI;H.copy(d[d.length-1]).setPosition(u[u.length-1]),this.applyMatrix4OnRange(H,U,V),H.copy(d[0]).setPosition(u[0]).multiply(II.makeScale(1,1,-1)),this.applyMatrix4OnRange(H,U-x,U),this.reverseIndicesOnRange(j,F)}else this.setAttribute("position",new Ee.BufferAttribute(B.positions,3)),this.setAttribute("normal",new Ee.BufferAttribute(B.normals,3)),this.setAttribute("uv",new Ee.BufferAttribute(B.uvs,2)),this.setIndex(q)}_extractPathPoints(){let e=qu(this.inputs.path),r=this.inputs.path.subdivisions,o=this.inputs.path.subdivisionMode==="uniform"?e.getSpacedPoints(r*4):e.getPoints(r);if(o.length<2)return[];let n=[o[0]];return o.forEach(s=>{n[n.length-1].distanceToSquared(s)>.001&&n.push(s)}),this.inputs.path.isClosed&&n[n.length-1].distanceTo(n[0])<.001&&n.pop(),n}_computeBasisMatrices(e){let r=[],o=e.length,n=this.inputs.path.isClosed,a=new Ee.Vector3,s=new Ee.Vector3,l=new Ee.Vector3,c=new Ee.Vector3,u=new Ee.Vector3(0,1,0);for(let y=0;y<o;y++){let g=e[y],b;y===0?b=n?e[e.length-2]:g.clone().multiplyScalar(2).sub(e[1]):b=e[y-1];let w;y===o-1?w=n?e[1]:g.clone().multiplyScalar(2).sub(e[y-1]):w=e[y+1];let P=g.clone().sub(b).normalize(),S=w.clone().sub(g).normalize(),T=P.clone().add(S).normalize();l.copy(T),y===0&&(T.equals(u)||T.clone().negate().equals(u))&&u.set(0,0,1);let A=u.clone().cross(T).normalize(),x=T.clone().cross(A).normalize();u.copy(x),c.copy(A),y===0&&(a.copy(x),s.copy(T));let N=new Ee.Matrix4().makeBasis(A,x,T);r.push(N)}let d=n?s:l,p=n?a:new Ee.Vector3(0,1,0),f=d.clone().cross(c).normalize(),h=Math.acos(p.dot(f));if(isNaN(h))return r;let m=p.clone().cross(f);d.dot(m)>0&&(h*=-1);for(let y=1;y<r.length;y++){let g=new Ee.Matrix4().makeRotationZ(h*y/r.length);r[y].multiply(g)}return r}_applyPathModifiers(e,r,o){let n=e.length,{angle:a,twist:s,startScale:l,endScale:c}=this.inputs.parameters.extrusion,u=new Ee.Matrix4,d=new Ee.Matrix4;return e.forEach((p,f)=>{let h=f===0?0:f===n-1?1:(f-r)/(n-(o===0?0:1)-(r+(1-o)));u.makeRotationZ(Ee.MathUtils.lerp(a,a+s,h)*Ee.MathUtils.DEG2RAD);let m=Ee.MathUtils.lerp(l,c,h);d.makeScale(m,m,m),p.multiply(u).multiply(d)}),e}_computeShapePoints(e=12,r=Xe.ODD){let o=this.inputs.shapeData,n=o.extractShapePointsToFlatArray([],e),a=o.shapeHoles.map(m=>{let y=m.extractShapePointsToFlatArray([],e),g=[];for(let b=y.length-1;b>=1;b-=2){let w=y[b-1],P=y[b-0];g.push(w,P)}return g}),s;try{s=fo({windingRule:r,elementType:Pt.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[n]})}catch{s=Bl}let l;try{l=fo({windingRule:Xe.ODD,elementType:Pt.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...a]})}catch{l=Ff}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],g=m%2===0?s.vertexCount:0;s.elements.push(y+g)}for(let m=0;m<l.vertexIndices.length;m++){let y=l.vertexIndices[m],g=s.vertexCount;s.vertexIndices.push(y+g)}for(let m=0;m<l.vertices.length;m++){let y=l.vertices[m];s.vertices.push(y)}}let u=1/0,d=-1/0,p=1/0,f=-1/0;for(let m=0,y=s.vertexCount;m<y;m++){let g=m*2,b=s.vertices[g+0],w=s.vertices[g+1];b<u&&(u=b),b>d&&(d=b),w<p&&(p=w),w>f&&(f=w)}let h=[];for(let m=s.elementCount-1;m>=0;m--){let y=m>=c,g=m*2,b=s.elements[g+0],w=s.elements[g+1],P=b+w,S={start:b,count:w,normals:[],isHole:y,continuous:[],verticesStart:0,verticesCount:0};h.push(S);let T=b,A=P-1,x=b+1,N=o.roundedCurves.length;do{let E=T-b,M=s.vertices[A*2+0],D=s.vertices[A*2+1],_=s.vertices[T*2+0],R=s.vertices[T*2+1],V=s.vertices[x*2+0],U=s.vertices[x*2+1],B=_-M,q=R-D,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+N)%N;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),[A,T,x]=[T,x,x+1],x>=P&&(x-=w)}while(x!==b+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 Ee.Vector3,u=new Ee.Vector3,d=new Ee.Vector3,p=new Ee.Vector3,f=new Ee.Vector2;o.forEach((m,y)=>{let g=n[y],b=e.verticesStart*o.length+e.verticesCount*y;for(let w=0;w<e.count;w++){let P=(e.start+w)*2;if(c.set(r[P+0],r[P+1],0),d.copy(c).applyMatrix4(m).add(g),e.continuous[w])p.set(e.normals[w*2+0],e.normals[w*2+1],0);else{let S=w===0?(e.start+e.count-1)*2:P-2;u.set(r[S+0],r[S+1],0),p.copy(c).sub(u),p.set(-p.y,p.x,0),e.isHole||p.negate()}if(p.applyMatrix4(m).normalize(),f.set(w===0?1:w/e.count,y/(o.length-1)),this._insertVertex(a,b,d,p,f),b++,!e.continuous[w]||w===0){if(w===0)p.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:P+2;u.set(r[S+0],r[S+1],0),p.copy(u).sub(c),p.set(-p.y,p.x,0),e.isHole||p.negate()}p.applyMatrix4(m).normalize(),this._insertVertex(a,b,d,p,f),b++}}});let h=o.length-1;for(let m=0;m<h;m++){let y=e.verticesStart*o.length+e.verticesCount*m,g=e.verticesStart*o.length+e.verticesCount*(m+1),b=0;for(let w=0;w<e.count;w++){(!e.continuous[w]||w===0)&&b++;let P=w===e.count-1?0:b+1,S=y+b,T=y+P,A=g+P,x=g+b;e.isHole?s.push(S,A,T,S,x,A):s.push(S,T,A,S,A,x),b++}}}_closeEnd(e,r,o,n,a,s,l){let c=e.vertexCount,u=new Ee.Vector3(0,0,l?-1:1).applyMatrix4(a),d=new Ee.Vector3,p=new Ee.Vector2;for(let h=0;h<c;h++){let m=2*h;d.set(e.vertices[m+0],e.vertices[m+1],0).applyMatrix4(a).add(s),this._insertVertex(n,r+h,d,u,p)}let f=e.elements;for(let h=0;h<e.elementCount;h++){let m=3*h,y=f[m+0]+r,g=f[m+(l?1:2)]+r,b=f[m+(l?2:1)]+r;o.push(y,g,b)}}applyMatrix4OnRange(e,r,o){let n=e.elements,a=new Ee.Matrix3().getNormalMatrix(e).elements,s,l,c,u,d=this.attributes.position,p=this.attributes.normal;if(!d||!p)return;let f=d.array,h=p.array,m=d.itemSize;for(let y=r*m,g=o*m;y<g;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}d.needsUpdate=!0,p.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 Bn=require("three"),bb=require("three/examples/jsm/utils/BufferGeometryUtils.js");function vb(){let i=new Bn.BufferGeometry;return i.setAttribute("position",new Bn.BufferAttribute(new Float32Array([]),3)),i.setIndex(new Bn.BufferAttribute(new Uint16Array([]),1)),i}var DI=vb().attributes,_I=12,RI=1,Vn=class extends Bn.BufferGeometry{constructor(e,r){super();this.charWidths=[];this.charCoords=[];this.wrappedText=[];this.isLowResolution=!1;this.vectorShapes=[];Object.assign(this.attributes,DI),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:d}=e,p=Ui.getDisplayedValue(u),f=d===2?p.toUpperCase():d===3?p.toLowerCase():p,h=LI(e,o,f,r),{shapes:m,charWidths:y,charCoords:g}=o.generateShapes(h,e,r),b=(typeof n=="number"?n:Number(r.getVariable(n)))*.5,w=(typeof a=="number"?a:Number(r.getVariable(a)))*.5,P=m.map(A=>new Ye().fromShape(A,!0));this.vectorShapes=P;let S=P.map(A=>Tr.create({shape:A,parameters:{depth:s,extrudeBevelSegments:c,extrudeBevelSize:l,windingRule:s<=0?Xe.NONZERO:Xe.ODD,subdivisions:this.isLowResolution&&s>0?RI:_I}})),T=S.length?(0,bb.mergeBufferGeometries)(S):vb();T.translate(-b,w,0),this.dispose(),this.wrappedText=h,this.charCoords=g,this.charWidths=y,this.deleteAttribute("extrudeNormal"),Object.entries(T.attributes).forEach(([A,x])=>{this.setAttribute(A,x)}),this.setIndex(T.index),this.computeBoundingSphere()}clone(){let e=Ht(new Bn.BufferGeometry,Vn.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 LI(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===`
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=Fl(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=Fl(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 xb=(i,t)=>{if(typeof i=="string"){let e=t.getVariable(i);if(e)return xb(e,t)}return Ui.isBoolean(i)?Ui.getDisplayedValue(i).toLowerCase():Ui.getDisplayedValue(i)},Fl=(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
+ `:"")+Fl(e.children,t);if(e.type==="variable"){let o=t.getVariable(e.variableId);if(o!==void 0)return xb(o,t)}}return""}).join("");var MI=new Ee.Matrix4,II=new Ee.Matrix4;function EI(i,t,e){let r=[new Ee.Vector3,new Ee.Vector3,new Ee.Vector3],o=[new Ee.Vector3,new Ee.Vector3,new Ee.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=Ee.MathUtils.lerp(n.length(),s.length(),e);n.lerp(s,e).setLength(l)}),new Ee.Matrix4().makeBasis(r[0],r[1],r[2])}var bb=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??ts.create({parameters:{...In,width:typeof In.width=="number"?In.width:100,height:typeof In.height=="number"?In.height:100}}).userData.shape;return{path:i.path??Ba.defaultData(),parameters:Object.assign(e,{width:r,height:o,depth:n,extrusion:{...Cu,...e.extrusion}}),shapeData:a}}static build(i){if(i.path.points.length>=2){let e=new Qf(i);return Object.assign(e,{userData:{...i,type:"PathGeometry"}})}else return Object.assign(new Ee.BufferGeometry,{userData:{...i,type:"PathGeometry"}})}},Qf=class extends Ee.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)||!yb(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=[],d=[];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()),d.push(r[F].clone())}let p=(j,F,H)=>{u[j]=u[j].clone().lerp(u[F],H),d[j]=EI(d[j],d[F],H)},f=0,h=n*a%1;(!this.inputs.path.isClosed||o<=1)&&(h||n===0)&&(f=h,p(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,p(u.length-1,u.length-2,1-m)),o===0){let j=u.length-1;u[j].copy(u[0]),d[j].copy(d[0])}this._applyPathModifiers(d,f,m);let{bevel:g,bevelSides:b}=this.inputs.parameters.extrusion,w=g>0?this.inputs.parameters.extrusion.capType:"flat",P=5;this.inputs.parameters.extrusion.shape.type==="Custom"&&(P=this.inputs.parameters.extrusion.shape.shapeQuality==="low"?5:12);let{regions:S,infos:T,vertices:A}=this._computeShapePoints(P),x=0,N;w==="round"&&(N=new $i(this.inputs.shapeData,2*g,g,P,b,void 0,!0),x=N.getAttribute("position").count);let E=0,M=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),M+=j.verticesCount,E=M});let D=M*c,_,R=0;if(this._isOpenEnded()&&w==="flat"){try{_=fo({windingRule:Xe.ODD,elementType:Pt.POLYGONS,polySize:3,vertexSize:2,strict:!0,contours:S})}catch{_=Uf}R=_.vertexCount}let V=D+2*R+x*2,U=D+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,A,d,u,B,q,this._isGeometryClosed()&&!this._isOpenEnded())}),_&&(this._closeEnd(_,D,q,B,d[0],u[0],!1),this._closeEnd(_,D+R,q,B,d[d.length-1],u[u.length-1],!0)),N){B.positions.set(N.getAttribute("position").array,U*3),B.normals.set(N.getAttribute("normal").array,U*3),B.uvs.set(N.getAttribute("uv").array,U*2);for(let W=U;W<U+x;W++)B.uvs[W*2+1]=1e-4;let j=q.length;q.push(...N.getIndex().array.map(W=>W+U)),U+=x,B.positions.set(N.getAttribute("position").array,U*3),B.normals.set(N.getAttribute("normal").array,U*3),B.uvs.set(N.getAttribute("uv").array,U*2);let F=q.length;q.push(...N.getIndex().array.map(W=>W+U)),this.setAttribute("position",new Ee.BufferAttribute(B.positions,3)),this.setAttribute("normal",new Ee.BufferAttribute(B.normals,3)),this.setAttribute("uv",new Ee.BufferAttribute(B.uvs,2)),this.setIndex(q);let H=MI;H.copy(d[d.length-1]).setPosition(u[u.length-1]),this.applyMatrix4OnRange(H,U,V),H.copy(d[0]).setPosition(u[0]).multiply(II.makeScale(1,1,-1)),this.applyMatrix4OnRange(H,U-x,U),this.reverseIndicesOnRange(j,F)}else this.setAttribute("position",new Ee.BufferAttribute(B.positions,3)),this.setAttribute("normal",new Ee.BufferAttribute(B.normals,3)),this.setAttribute("uv",new Ee.BufferAttribute(B.uvs,2)),this.setIndex(q)}_extractPathPoints(){let e=$u(this.inputs.path),r=this.inputs.path.subdivisions,o=this.inputs.path.subdivisionMode==="uniform"?e.getSpacedPoints(r*4):e.getPoints(r);if(o.length<2)return[];let n=[o[0]];return o.forEach(s=>{n[n.length-1].distanceToSquared(s)>.001&&n.push(s)}),this.inputs.path.isClosed&&n[n.length-1].distanceTo(n[0])<.001&&n.pop(),n}_computeBasisMatrices(e){let r=[],o=e.length,n=this.inputs.path.isClosed,a=new Ee.Vector3,s=new Ee.Vector3,l=new Ee.Vector3,c=new Ee.Vector3,u=new Ee.Vector3(0,1,0);for(let y=0;y<o;y++){let g=e[y],b;y===0?b=n?e[e.length-2]:g.clone().multiplyScalar(2).sub(e[1]):b=e[y-1];let w;y===o-1?w=n?e[1]:g.clone().multiplyScalar(2).sub(e[y-1]):w=e[y+1];let P=g.clone().sub(b).normalize(),S=w.clone().sub(g).normalize(),T=P.clone().add(S).normalize();l.copy(T),y===0&&(T.equals(u)||T.clone().negate().equals(u))&&u.set(0,0,1);let A=u.clone().cross(T).normalize(),x=T.clone().cross(A).normalize();u.copy(x),c.copy(A),y===0&&(a.copy(x),s.copy(T));let N=new Ee.Matrix4().makeBasis(A,x,T);r.push(N)}let d=n?s:l,p=n?a:new Ee.Vector3(0,1,0),f=d.clone().cross(c).normalize(),h=Math.acos(p.dot(f));if(isNaN(h))return r;let m=p.clone().cross(f);d.dot(m)>0&&(h*=-1);for(let y=1;y<r.length;y++){let g=new Ee.Matrix4().makeRotationZ(h*y/r.length);r[y].multiply(g)}return r}_applyPathModifiers(e,r,o){let n=e.length,{angle:a,twist:s,startScale:l,endScale:c}=this.inputs.parameters.extrusion,u=new Ee.Matrix4,d=new Ee.Matrix4;return e.forEach((p,f)=>{let h=f===0?0:f===n-1?1:(f-r)/(n-(o===0?0:1)-(r+(1-o)));u.makeRotationZ(Ee.MathUtils.lerp(a,a+s,h)*Ee.MathUtils.DEG2RAD);let m=Ee.MathUtils.lerp(l,c,h);d.makeScale(m,m,m),p.multiply(u).multiply(d)}),e}_computeShapePoints(e=12,r=Xe.ODD){let o=this.inputs.shapeData,n=o.extractShapePointsToFlatArray([],e),a=o.shapeHoles.map(m=>{let y=m.extractShapePointsToFlatArray([],e),g=[];for(let b=y.length-1;b>=1;b-=2){let w=y[b-1],P=y[b-0];g.push(w,P)}return g}),s;try{s=fo({windingRule:r,elementType:Pt.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[n]})}catch{s=Bl}let l;try{l=fo({windingRule:Xe.ODD,elementType:Pt.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...a]})}catch{l=jf}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],g=m%2===0?s.vertexCount:0;s.elements.push(y+g)}for(let m=0;m<l.vertexIndices.length;m++){let y=l.vertexIndices[m],g=s.vertexCount;s.vertexIndices.push(y+g)}for(let m=0;m<l.vertices.length;m++){let y=l.vertices[m];s.vertices.push(y)}}let u=1/0,d=-1/0,p=1/0,f=-1/0;for(let m=0,y=s.vertexCount;m<y;m++){let g=m*2,b=s.vertices[g+0],w=s.vertices[g+1];b<u&&(u=b),b>d&&(d=b),w<p&&(p=w),w>f&&(f=w)}let h=[];for(let m=s.elementCount-1;m>=0;m--){let y=m>=c,g=m*2,b=s.elements[g+0],w=s.elements[g+1],P=b+w,S={start:b,count:w,normals:[],isHole:y,continuous:[],verticesStart:0,verticesCount:0};h.push(S);let T=b,A=P-1,x=b+1,N=o.roundedCurves.length;do{let E=T-b,M=s.vertices[A*2+0],D=s.vertices[A*2+1],_=s.vertices[T*2+0],R=s.vertices[T*2+1],V=s.vertices[x*2+0],U=s.vertices[x*2+1],B=_-M,q=R-D,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+N)%N;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),[A,T,x]=[T,x,x+1],x>=P&&(x-=w)}while(x!==b+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 Ee.Vector3,u=new Ee.Vector3,d=new Ee.Vector3,p=new Ee.Vector3,f=new Ee.Vector2;o.forEach((m,y)=>{let g=n[y],b=e.verticesStart*o.length+e.verticesCount*y;for(let w=0;w<e.count;w++){let P=(e.start+w)*2;if(c.set(r[P+0],r[P+1],0),d.copy(c).applyMatrix4(m).add(g),e.continuous[w])p.set(e.normals[w*2+0],e.normals[w*2+1],0);else{let S=w===0?(e.start+e.count-1)*2:P-2;u.set(r[S+0],r[S+1],0),p.copy(c).sub(u),p.set(-p.y,p.x,0),e.isHole||p.negate()}if(p.applyMatrix4(m).normalize(),f.set(w===0?1:w/e.count,y/(o.length-1)),this._insertVertex(a,b,d,p,f),b++,!e.continuous[w]||w===0){if(w===0)p.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:P+2;u.set(r[S+0],r[S+1],0),p.copy(u).sub(c),p.set(-p.y,p.x,0),e.isHole||p.negate()}p.applyMatrix4(m).normalize(),this._insertVertex(a,b,d,p,f),b++}}});let h=o.length-1;for(let m=0;m<h;m++){let y=e.verticesStart*o.length+e.verticesCount*m,g=e.verticesStart*o.length+e.verticesCount*(m+1),b=0;for(let w=0;w<e.count;w++){(!e.continuous[w]||w===0)&&b++;let P=w===e.count-1?0:b+1,S=y+b,T=y+P,A=g+P,x=g+b;e.isHole?s.push(S,A,T,S,x,A):s.push(S,T,A,S,A,x),b++}}}_closeEnd(e,r,o,n,a,s,l){let c=e.vertexCount,u=new Ee.Vector3(0,0,l?-1:1).applyMatrix4(a),d=new Ee.Vector3,p=new Ee.Vector2;for(let h=0;h<c;h++){let m=2*h;d.set(e.vertices[m+0],e.vertices[m+1],0).applyMatrix4(a).add(s),this._insertVertex(n,r+h,d,u,p)}let f=e.elements;for(let h=0;h<e.elementCount;h++){let m=3*h,y=f[m+0]+r,g=f[m+(l?1:2)]+r,b=f[m+(l?2:1)]+r;o.push(y,g,b)}}applyMatrix4OnRange(e,r,o){let n=e.elements,a=new Ee.Matrix3().getNormalMatrix(e).elements,s,l,c,u,d=this.attributes.position,p=this.attributes.normal;if(!d||!p)return;let f=d.array,h=p.array,m=d.itemSize;for(let y=r*m,g=o*m;y<g;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}d.needsUpdate=!0,p.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 Bn=require("three"),vb=require("three/examples/jsm/utils/BufferGeometryUtils.js");function Sb(){let i=new Bn.BufferGeometry;return i.setAttribute("position",new Bn.BufferAttribute(new Float32Array([]),3)),i.setIndex(new Bn.BufferAttribute(new Uint16Array([]),1)),i}var DI=Sb().attributes,_I=12,RI=1,Vn=class extends Bn.BufferGeometry{constructor(e,r){super();this.charWidths=[];this.charCoords=[];this.wrappedText=[];this.isLowResolution=!1;this.vectorShapes=[];Object.assign(this.attributes,DI),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:d}=e,p=Ui.getDisplayedValue(u),f=d===2?p.toUpperCase():d===3?p.toLowerCase():p,h=LI(e,o,f,r),{shapes:m,charWidths:y,charCoords:g}=o.generateShapes(h,e,r),b=(typeof n=="number"?n:Number(r.getVariable(n)))*.5,w=(typeof a=="number"?a:Number(r.getVariable(a)))*.5,P=m.map(A=>new Ye().fromShape(A,!0));this.vectorShapes=P;let S=P.map(A=>Tr.create({shape:A,parameters:{depth:s,extrudeBevelSegments:c,extrudeBevelSize:l,windingRule:s<=0?Xe.NONZERO:Xe.ODD,subdivisions:this.isLowResolution&&s>0?RI:_I}})),T=S.length?(0,vb.mergeBufferGeometries)(S):Sb();T.translate(-b,w,0),this.dispose(),this.wrappedText=h,this.charCoords=g,this.charWidths=y,this.deleteAttribute("extrudeNormal"),Object.entries(T.attributes).forEach(([A,x])=>{this.setAttribute(A,x)}),this.setIndex(T.index),this.computeBoundingSphere()}clone(){let e=Ht(new Bn.BufferGeometry,Vn.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 LI(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 wb,ld=new Promise(i=>{wb=i}),Sb=!1;var sd;function Pb(i){if(Sb)return;if(sd)return sd;async function t(){let r=i??(!1?".":"https://unpkg.com/@splinetool/modelling-wasm@1.12.42/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});wb(c),Sb=!0}return sd=t(),sd}var Ob=require("three");var BI=["font"];function zo(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 d of c)u=u[d];for(o in u){let d=u[o];tf(d)&&!BI.includes(o)&&(u[o]=t.getVariable(d,[r.uuid,"geometry",...c,o]),tf(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=Ye.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 Ob.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 zt(n,e);return c.data=i,c}else{if(n.type==="TextGeometry")return new Vn(n,t);if(n.type==="InputGeometry")return new Vn(n,t);if(n.type==="UIGeometry")return is.create({parameters:{width:n.width,height:n.height,cornerRadius:n.cornerRadius,cornerType:n.cornerType}})}let l;try{l=Qf(s)}catch(c){console.error(c),console.error(`Error generating geometry with inputs: ${s}`);let u=Ye.createFromState(La.defaultData(),100,100);s.shape=u,s.type="VectorGeometry",l=Qf(s)}return l}var Tb=require("three"),VI=new Tb.Matrix4;function jl(i,t,e,r){let o=i.position.array,n=i.normal.array,a=VI.makeScale(t,e,r).invert().elements,s,l,c;for(var u=0,d=o.length;u<d;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 cd=new lt.Box3,as=new lt.Vector3,Oe;ld.then(i=>{Oe=i});var Cb=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),Ab=new Uint32Array([0,1,2,3]),Mb=new Uint8Array([4]),zt=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.map(l=>typeof l=="number"?l:1),n=Bi.div(r.map(l=>typeof l=="number"?l:0),o);if(n.every(l=>l===1))return;this.subdividedGeometry&&jl(this.subdividedGeometry.attributes,...n),this.originalGeometry&&jl(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(as.fromArray(n));let s=as.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}=zt.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&&(zt.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;cd.setFromBufferAttribute(r),cd.getCenter(o),e.boundingSphere.radius=o.distanceTo(cd.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),cd.getSize(as);let n={width:as.x,height:as.y,depth:as.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&&(Oe.free_bvh(r),Oe.free_subdivision_surface(r));try{a=zt.allocate(e,n)}catch(u){console.error(u,e),a=zt.allocate({positionWASM:Cb,indexWASM:Ab,verticesPerFaceWASM:Mb},n)}if(Oe.set_destination_refinement_level(a,0),s=zt.buildLevel(a,!0,c),e.subdivisions>0)try{Oe.set_destination_refinement_level(a,e.subdivisions),l=zt.buildLevel(a,!1,c)}catch{try{Oe.set_destination_refinement_level(a,e.subdivisions-1),l=zt.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:zo(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}=th(n.getAttribute("position"),a));let d;if(e.type==="CylinderGeometry"&&e.cornerRadius===0&&e.hollow===0&&e.openEnded===!1){let p=e.radialSegments*e.heightSegments*3*2,f=p+e.radialSegments*3;d=[p,f]}return{indices:l,verticesPerFace:c}=rh(s,u,n,d),{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=Cb,n=Ab,a=Mb);let c=o.length,u=n.length,d=a.length,p=o.length+s.length+l.length,f=n.length+a.length,h=p*Float32Array.BYTES_PER_ELEMENT+f*Uint32Array.BYTES_PER_ELEMENT,m=p*Float32Array.BYTES_PER_ELEMENT,y=Oe._malloc(h),g=new Float32Array(Oe.HEAPF32.buffer,y,p),b=new Uint32Array(Oe.HEAPU32.buffer,y+m,f);g.set(o,0),g.set(s,o.length),g.set(l,o.length+s.length),b.set(n,0),b.set(a,n.length);let w;e?.scaleBaked?.some(S=>S!==1)&&(w=new lt.Matrix4().makeScale(...e.scaleBaked.map(S=>typeof S=="number"?S:1))),r&&(w?w.premultiply(r):w=r);let P=w?Oe.alloc_subdivision_surface2(y,c,y+m,u,y+m+n.length*Uint32Array.BYTES_PER_ELEMENT,d,w.elements):Oe.alloc_subdivision_surface(y,c,y+m,u,y+m+n.length*Uint32Array.BYTES_PER_ELEMENT,d);return Oe._free(y),P}static buildLevel(e,r,o,n,a){let s=a?Oe.get_mesh_data2(e,r?Oe.Level.CONTROL:Oe.Level.REFINED,o,a.elements):Oe.get_mesh_data(e,r?Oe.Level.CONTROL:Oe.Level.REFINED,o),l=8,c=Oe.HEAPU32.subarray(s>>2,(s>>2)+l),u=c.subarray(4,4+4),d=0,p=Oe.HEAPU32[c[d]>>2],f=Oe.HEAPF32.subarray(p>>2,(p>>2)+u[d]);d++;let h=Oe.HEAPU32[c[d]>>2],m=Oe.HEAPF32.subarray(h>>2,(h>>2)+u[d]);d++;let y=Oe.HEAPU32[c[d]>>2],g=Oe.HEAPU32.subarray(y>>2,(y>>2)+u[d]);d++;let b=Oe.HEAPU32[c[d]>>2],w=Oe.HEAPU32.subarray(b>>2,(b>>2)+u[d]);if(d++,n===void 0){let P=new lt.BufferGeometry;if(P.setIndex(new lt.Uint32BufferAttribute(w,1)),P.setAttribute("position",new lt.Float32BufferAttribute(f,3)),P.setAttribute("normal",new lt.Float32BufferAttribute(m,3)),r){P.setAttribute("faceMap",new lt.Uint32BufferAttribute(g,1));let S=new Float32Array(m.length/3*4).fill(0);P.setAttribute("color",new lt.BufferAttribute(S,4))}return Oe.free_mesh_data(s),P.userData.type="SubdivGeometry",P}n.getAttribute("position").copyArray(f),n.getAttribute("normal").copyArray(m),n.attributes.position.needsUpdate=!0,n.attributes.normal.needsUpdate=!0,Oe.free_mesh_data(s)}static freeSubdivPointer(e){Oe.free_bvh(e),Oe.free_subdivision_surface(e)}static buildControlCageWireframe(e,r,o){let n=Oe.get_wireframe_data_for_base_level(e),a=4,s=Oe.HEAPU32.subarray(n>>2,(n>>2)+a),l=s.subarray(2,2+2),c=0,u=Oe.HEAPU32[s[c]>>2],d=Oe.HEAPF32.subarray(u>>2,(u>>2)+l[c]);c++;let p=Oe.HEAPU32[s[c]>>2],f=Oe.HEAPU32.subarray(p>>2,(p>>2)+l[c]);if(r===void 0){let h=new lt.BufferGeometry;h.setAttribute("position",new lt.Float32BufferAttribute(d,3));let m=new Float32Array(d.length);for(let y=0,g=d.length;y<g;)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)),Oe.free_wireframe_data_for_base_level(n),h}r.getAttribute("position").copyArray(d),r.attributes.position.needsUpdate=!0,Oe.free_wireframe_data_for_base_level(n)}static updateCollabMesh(e,r,o){let n=r===0;n||Oe.set_destination_refinement_level(e,r);let a=o?Oe.get_topological_data2(e,n?Oe.Level.CONTROL:Oe.Level.REFINED,o.elements):Oe.get_topological_data(e,n?Oe.Level.CONTROL:Oe.Level.REFINED),s=6,l=Oe.HEAPU32.subarray(a>>2,(a>>2)+s),c=l.subarray(3,3+3),u=0,d=Oe.HEAPU32[l[u]>>2],p=new Float32Array(Oe.HEAPF32.subarray(d>>2,(d>>2)+c[u]));u++;let f=Oe.HEAPU32[l[u]>>2],h=new Uint32Array(Oe.HEAPU32.subarray(f>>2,(f>>2)+c[u]));u++;let m=Oe.HEAPU32[l[u]>>2],y=new Uint8Array(Oe.HEAPU32.subarray(m>>2,(m>>2)+c[u]));return Oe.free_topological_data(a),{positions:p,indices:h,verticesPerFace:y}}};var Ib=["getX","getY","getZ"];function th(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,d="";for(let p=0;p<3;p++)d+=`${~~(i[Ib[p]](u)*s)},`;if(d in e)n.push(e[d]);else{for(let p=0;p<3;p++)a.push(i[Ib[p]](u));e[d]=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 ud=new lt.Vector3,Zf=new lt.Vector3,Jf=new lt.Vector3,eh=new lt.Vector3;function rh(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 p=l.length/2/c;l=l.filter((f,h)=>Math.floor(h/2)%p===0)}let u=0;for(let p=0;p<l.length;p+=2)u+=(l[p]-l[(p===0?l.length:p)-2])*(l[p+1]+l[(p===0?l.length:p)-1]);i.length=0;let d=0;if(u<0)for(let p=0;p<l.length;p+=2)i.push(l[p],l[p+1],0),o.push(d++);else for(let p=l.length-2;p>=0;p-=2)i.push(l[p],l[p+1],0),o.push(d++);return n.push(d),{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]){ud.set(i[t[s]*3],i[t[s]*3+1],i[t[s]*3+2]),Zf.set(i[t[s+1]*3],i[t[s+1]*3+1],i[t[s+1]*3+2]),Jf.set(i[t[s+4]*3],i[t[s+4]*3+1],i[t[s+4]*3+2]),eh.set(i[t[s+5]*3],i[t[s+5]*3+1],i[t[s+5]*3+2]),Zf.sub(ud).normalize(),Jf.sub(ud).normalize(),eh.sub(ud).normalize();let l=Zf.cross(Jf).dot(eh),c=s;Math.abs(l)>.005||r&&r.some((u,d)=>d%2===1?!1:c>=r[d]&&c<r[d+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 d=0,p=0;d<i.length;d+=3,p++)i[d+2]===0&&(l.push(p),u++),i[d+2]===a&&c.push(p);if(e.userData.parameters.extrudeBevelSize===0){let d=c[0];c[0]=c[1],c[1]=d}l.reverse(),o.push(...l,...c),n.push(u,u)}return{indices:o,verticesPerFace:n}}var Xr={};gm(Xr,{calcBoolean:()=>jI,calcBooleanTopological:()=>FI,freeMeshSet:()=>WI,getMeshSet:()=>UI,hasOpenEdges:()=>kI,transformMeshSet:()=>HI});var zI,Eb=new Promise(i=>{zI=i});var Ul=require("three");var ke,ss;Eb.then(i=>ke=i);function GI(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}=th(i.getAttribute("position"),o),s;if(t&&e){let{indices:l,verticesPerFace:c}=rh(n,a,i);s=c.length,r=[];for(let u=0,d=0;u<s;u++){r.push(c[u]);for(let p=0;p<c[u];p++)r.push(l[d++])}}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 Nb(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=ke._malloc(o);return(Number.isInteger(i[0])?new Uint32Array(ke.HEAPU32.buffer,n,t):new Float32Array(ke.HEAPF32.buffer,n,t)).set(i,0),n}function Db(i){switch(i){case 0:return ke.OP.UNION;case 1:return ke.OP.INTERSECTION;case 2:return ke.OP.A_MINUS_B;default:throw new Error("Unknown boolean operation "+i)}}function FI(i,t){ss===void 0&&(ss=ke.init_csg());let e=Nb(i),r=ke.csg_calc_topological(ss,e,i.length,Db(t));ke._free(e);let o=6,n=ke.HEAPU32.subarray(r>>2,(r>>2)+o),a=n.subarray(3,3+3),s=0,l=ke.HEAPU32[n[s]>>2],c=new Float32Array(ke.HEAPF32.subarray(l>>2,(l>>2)+a[s]));s++;let u=ke.HEAPU32[n[s]>>2],d=new Uint32Array(ke.HEAPU32.subarray(u>>2,(u>>2)+a[s]));s++;let p=ke.HEAPU32[n[s]>>2],f=new Uint8Array(ke.HEAPU32.subarray(p>>2,(p>>2)+a[s]));return ke.free_mesh_data(r),{positions:c,indices:d,verticesPerFace:f}}function jI(i,t,e,r){ss===void 0&&(ss=ke.init_csg());let o=Nb(i),n=ke.csg_calc(ss,o,i.length,r,Db(t));ke._free(o);let a=5,s=ke.HEAPU32.subarray(n>>2,(n>>2)+a),l=s.subarray(2,2+3),c=0,u=ke.HEAPU32[s[c]>>2],d=ke.HEAPF32.subarray(u>>2,(u>>2)+l[c]);c++;let p=ke.HEAPU32[s[c]>>2],f=ke.HEAPF32.subarray(p>>2,(p>>2)+l[c]);c++;let h=l[c];e.setAttribute("position",new Ul.Float32BufferAttribute(d,3)),e.setAttribute("normal",new Ul.Float32BufferAttribute(f,3));let m=ke.HEAPF32.subarray((n>>2)+5,(n>>2)+5+6);return e.boundingSphere===null&&(e.boundingSphere=new Ul.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},ke.free_mesh_data(n),h}function UI(i,t,e){if(ke===void 0)return-1;let r,o,n;if(t&&i.userData.positions!==void 0){let g=i.userData;n=g.verticesPerFace.length,r=g.positions,o=Array(g.verticesPerFace.reduce((b,w)=>b+w,0)+n);for(let b=0,w=0,P=0;b<g.verticesPerFace.length;b++){o[P++]=g.verticesPerFace[b];for(let S=0;S<g.verticesPerFace[b];S++)o[P++]=g.indices[w++]}}else({positions:r,faceIndices:o,nFaces:n}=GI(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,d=l*Float32Array.BYTES_PER_ELEMENT,p=c*Uint32Array.BYTES_PER_ELEMENT,f=ke._malloc(u),h=new Float32Array(ke.HEAPF32.buffer,f,l),m=new Uint32Array(ke.HEAPU32.buffer,f+d,c);h.set(r,0),m.set(o,0);let y=ke.get_csg_mesh(f,a,f+d,s,n);return ke._free(f),y}function kI(i){return ke.has_open_edges(i)}function HI(i,t){ke.transform_csg_mesh(i,t.elements)}function WI(i){ke.free_csg_mesh(i)}var qI={ConeGeometry:wx,CubeGeometry:Px,CylinderGeometry:Sx,DodecahedronGeometry:Tx,EllipseGeometry:ts,HelixGeometry:Kx,IcosahedronGeometry:Zx,LatheGeometry:Jx,NonParametricGeometry:ob,PolygonGeometry:id,PyramidGeometry:ib,RectangleGeometry:is,SphereGeometry:nb,PlaneGeometry:sb,BackdropGeometry:lb,StarGeometry:nd,TextFrameGeometry:ub,TorusGeometry:db,TorusKnotGeometry:fb,TriangleGeometry:hb,PathGeometry:xb,VectorGeometry:Tr},Qf=i=>qI[i.type].create(i);function ls(i){return i!==null&&"booleanOp"in i}var cs=class extends $a(dd.Mesh){constructor(){super(...arguments);this.booleanMeshSetAddress=-1;this.booleanWasTransformed=!1;this.booleanMatrixInvOld=new dd.Matrix4}updateVisible(e){super.updateVisible(e),this.visible=!ls(this.parent)&&this.visible,ls(this.parent)&&this.parent.invalidateDownstreamBooleanData()}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(Xr.freeMeshSet(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}invalidateDownstreamBooleanData(e=!1){return e?this.booleanWasTransformed=!0:this.freeBooleanPointer(),ls(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let e of this.children)e instanceof cs&&(e.freeBooleanPointer(),ls(e)&&e.invalidateUpstreamBooleanData())}updateTransformState(e,r){let o=super.updateTransformState(e,r);return o&&ls(this.parent)&&this.invalidateDownstreamBooleanData(!0),o}onVariableUpdate(e=!1){super.onVariableUpdate(e),ls(this.parent)&&this.invalidateDownstreamBooleanData(!0)}};var pd=new us.Box3;function kl(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 d=t;d<e;d++){let p=i.getX(d),f=i.getY(d),h=i.getZ(d);p<n&&(n=p),f<a&&(a=f),h<s&&(s=h),p>l&&(l=p),f>c&&(c=f),h>u&&(u=h)}pd.min.set(n,a,s),pd.max.set(l,c,u),pd.getCenter(r),pd.getSize(o).multiplyScalar(.5)}var $I=new us.BufferGeometry,XI=new us.MeshBasicMaterial,Xt=class extends cs{constructor(t,e){super($I,XI),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?kl(r,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:r.count,t,e):super.updateEntityBoxSize(t,e)}};var vi=require("three");var Gr=require("three");var Cd=require("three");var mi=class{constructor(t){this.hashProperties=void 0;this.isNode=!0;this.shortcuts={};if(mi.uuidContext===null)throw new Error("plz startContext");mi.uuidContext===mi.globalContext?this.uuid="_gid"+mi.uuidContext.nodeContextUuid++:this.uuid="_uid"+mi.uuidContext.nodeContextUuid++,this.type=t,this.name=""}static startContext(t){this.uuidContext===null||this.uuidContext===mi.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=mi;ot.globalContext={nodeContextUuid:0},ot.uuidContext=mi.globalContext;var xo=require("three");var Hl=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 oh=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}},Yt=new oh;var ih=require("three");var _b=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=_b.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 Ot=class extends it{constructor(e=0,r){super("v2");this.nodeType="Vector2";this.value=e instanceof ih.Vector2?e:new ih.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 nh=require("three");var ar=class extends it{constructor(e=0,r,o){super("v3");this.nodeType="Vector3";this.value=e instanceof nh.Vector3?e:new nh.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 Cr=class extends it{constructor(e){super("v4");this.nodeType="Vector4";this.value=e instanceof qt?e:new qt(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 YI=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,Rb=/[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 d=0;d<this.includes.length;d++)e.include(this.includes[d],this);for(let d in this.extensions)e.extensions[d]=!0;let u=[];for(;s=Rb.exec(this.src);)u.push(s);for(let d=0;d<u.length;d++){let p=u[d],f=p[0],h=this.isMethod?!this.getInputByName(f):!0,m=f;if(this.keywords[f]||this.useKeywords&&h&&Yt.containsKeyword(f)){let y=this.keywords[f];if(!y){let g=Yt.getKeywordData(f);g.cache&&(y=e.keywords[f]),y=y||Yt.getKeyword(f,e),g.cache&&(e.keywords[f]=y)}m=y.build(e)}f!==m&&c[p.index+l-1]!=="."&&(c=c.substring(0,p.index+l)+m+c.substring(p.index+f.length+l),l+=m.length-f.length),this.getIncludeByName(m)===void 0&&Yt.contains(m)&&e.include(Yt.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=YI.exec(this.src);if(this.inputs=[],a&&a.length==4){this.type=a[1],this.name=a[2];let s=a[3].match(Rb);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 d=s[l++];this.inputs.push({name:d,type:u,qualifier:c})}}this.isInterface=this.src.indexOf("{")===-1}else this.type="",this.name=""}}};var KI=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=?\s?(.*?)(\;|$)/i,ah=class extends be{constructor(e="",r){super();this.src="";this.useDefine=!1;this.nodeType="Const";this.parse(e||ah.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=KI.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)}},$e=ah;$e.PI="PI",$e.PI2="PI2",$e.RECIPROCAL_PI="RECIPROCAL_PI",$e.RECIPROCAL_PI2="RECIPROCAL_PI2",$e.LOG2="LOG2",$e.EPSILON="EPSILON";var QI=new RegExp(`^structs*([a-z_0-9]+)s*{s*((.|
19
- )*?)}`,"gim"),ZI=new RegExp("s*(w*?)s*(w*?)(=|;)","gim"),ds=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=QI.exec(e);if(r){let o=r[2],n;for(;n=ZI.exec(o);)this.inputs.push({type:n[1],name:n[2]});this.name=r[1]}else this.name="";this.type=this.name}};var ps=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)}};Yt.addKeyword("uv",function(){return new ps});Yt.addKeyword("uv2",function(){return new ps(1)});var fd=require("three");var zn=class extends be{constructor(e,r){super("v4");this.nodeType="ColorSpace";this.input=e,this.method=r??zn.LINEAR_TO_LINEAR,this.hashProperties=["method"]}static getEncodingComponents(e){switch(e){case fd.LinearEncoding:return["Linear"];case fd.sRGBEncoding:return["sRGB"];default:return[]}}generate(e,r){let o=this.input.build(e,"v4"),n=this.getType(e),a=zn.Nodes[this.method],s=e.include(a);if(s===zn.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=zn.getEncodingComponents(e);this.method="LinearTo"+r[0],this.factor=r[1]}fromDecoding(e){let r=zn.getEncodingComponents(e);this.method=r[0]+"ToLinear",this.factor=r[1]}},yr=zn;yr.Nodes={LinearToLinear:new J(["vec4 LinearToLinear( in vec4 value ) {"," return value;","}"].join(`
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 Pb,cd=new Promise(i=>{Pb=i}),wb=!1;var ld;function Ob(i){if(wb)return;if(ld)return ld;async function t(){let r=i??(!1?".":"https://unpkg.com/@splinetool/modelling-wasm@1.12.44/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});Pb(c),wb=!0}return ld=t(),ld}var Tb=require("three");var BI=["font"];function Go(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 d of c)u=u[d];for(o in u){let d=u[o];rf(d)&&!BI.includes(o)&&(u[o]=t.getVariable(d,[r.uuid,"geometry",...c,o]),rf(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=Ye.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 Tb.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 zt(n,e);return c.data=i,c}else{if(n.type==="TextGeometry")return new Vn(n,t);if(n.type==="InputGeometry")return new Vn(n,t);if(n.type==="UIGeometry")return is.create({parameters:{width:n.width,height:n.height,cornerRadius:n.cornerRadius,cornerType:n.cornerType}})}let l;try{l=Zf(s)}catch(c){console.error(c),console.error(`Error generating geometry with inputs: ${s}`);let u=Ye.createFromState(La.defaultData(),100,100);s.shape=u,s.type="VectorGeometry",l=Zf(s)}return l}var Cb=require("three"),VI=new Cb.Matrix4;function jl(i,t,e,r){let o=i.position.array,n=i.normal.array,a=VI.makeScale(t,e,r).invert().elements,s,l,c;for(var u=0,d=o.length;u<d;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 ud=new lt.Box3,as=new lt.Vector3,Oe;cd.then(i=>{Oe=i});var Ab=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),Mb=new Uint32Array([0,1,2,3]),Ib=new Uint8Array([4]),zt=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.map(l=>typeof l=="number"?l:1),n=Bi.div(r.map(l=>typeof l=="number"?l:0),o);if(n.every(l=>l===1))return;this.subdividedGeometry&&jl(this.subdividedGeometry.attributes,...n),this.originalGeometry&&jl(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(as.fromArray(n));let s=as.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}=zt.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&&(zt.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;ud.setFromBufferAttribute(r),ud.getCenter(o),e.boundingSphere.radius=o.distanceTo(ud.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),ud.getSize(as);let n={width:as.x,height:as.y,depth:as.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&&(Oe.free_bvh(r),Oe.free_subdivision_surface(r));try{a=zt.allocate(e,n)}catch(u){console.error(u,e),a=zt.allocate({positionWASM:Ab,indexWASM:Mb,verticesPerFaceWASM:Ib},n)}if(Oe.set_destination_refinement_level(a,0),s=zt.buildLevel(a,!0,c),e.subdivisions>0)try{Oe.set_destination_refinement_level(a,e.subdivisions),l=zt.buildLevel(a,!1,c)}catch{try{Oe.set_destination_refinement_level(a,e.subdivisions-1),l=zt.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:Go(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}=rh(n.getAttribute("position"),a));let d;if(e.type==="CylinderGeometry"&&e.cornerRadius===0&&e.hollow===0&&e.openEnded===!1){let p=e.radialSegments*e.heightSegments*3*2,f=p+e.radialSegments*3;d=[p,f]}return{indices:l,verticesPerFace:c}=oh(s,u,n,d),{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=Ab,n=Mb,a=Ib);let c=o.length,u=n.length,d=a.length,p=o.length+s.length+l.length,f=n.length+a.length,h=p*Float32Array.BYTES_PER_ELEMENT+f*Uint32Array.BYTES_PER_ELEMENT,m=p*Float32Array.BYTES_PER_ELEMENT,y=Oe._malloc(h),g=new Float32Array(Oe.HEAPF32.buffer,y,p),b=new Uint32Array(Oe.HEAPU32.buffer,y+m,f);g.set(o,0),g.set(s,o.length),g.set(l,o.length+s.length),b.set(n,0),b.set(a,n.length);let w;e?.scaleBaked?.some(S=>S!==1)&&(w=new lt.Matrix4().makeScale(...e.scaleBaked.map(S=>typeof S=="number"?S:1))),r&&(w?w.premultiply(r):w=r);let P=w?Oe.alloc_subdivision_surface2(y,c,y+m,u,y+m+n.length*Uint32Array.BYTES_PER_ELEMENT,d,w.elements):Oe.alloc_subdivision_surface(y,c,y+m,u,y+m+n.length*Uint32Array.BYTES_PER_ELEMENT,d);return Oe._free(y),P}static buildLevel(e,r,o,n,a){let s=a?Oe.get_mesh_data2(e,r?Oe.Level.CONTROL:Oe.Level.REFINED,o,a.elements):Oe.get_mesh_data(e,r?Oe.Level.CONTROL:Oe.Level.REFINED,o),l=8,c=Oe.HEAPU32.subarray(s>>2,(s>>2)+l),u=c.subarray(4,4+4),d=0,p=Oe.HEAPU32[c[d]>>2],f=Oe.HEAPF32.subarray(p>>2,(p>>2)+u[d]);d++;let h=Oe.HEAPU32[c[d]>>2],m=Oe.HEAPF32.subarray(h>>2,(h>>2)+u[d]);d++;let y=Oe.HEAPU32[c[d]>>2],g=Oe.HEAPU32.subarray(y>>2,(y>>2)+u[d]);d++;let b=Oe.HEAPU32[c[d]>>2],w=Oe.HEAPU32.subarray(b>>2,(b>>2)+u[d]);if(d++,n===void 0){let P=new lt.BufferGeometry;if(P.setIndex(new lt.Uint32BufferAttribute(w,1)),P.setAttribute("position",new lt.Float32BufferAttribute(f,3)),P.setAttribute("normal",new lt.Float32BufferAttribute(m,3)),r){P.setAttribute("faceMap",new lt.Uint32BufferAttribute(g,1));let S=new Float32Array(m.length/3*4).fill(0);P.setAttribute("color",new lt.BufferAttribute(S,4))}return Oe.free_mesh_data(s),P.userData.type="SubdivGeometry",P}n.getAttribute("position").copyArray(f),n.getAttribute("normal").copyArray(m),n.attributes.position.needsUpdate=!0,n.attributes.normal.needsUpdate=!0,Oe.free_mesh_data(s)}static freeSubdivPointer(e){Oe.free_bvh(e),Oe.free_subdivision_surface(e)}static buildControlCageWireframe(e,r,o){let n=Oe.get_wireframe_data_for_base_level(e),a=4,s=Oe.HEAPU32.subarray(n>>2,(n>>2)+a),l=s.subarray(2,2+2),c=0,u=Oe.HEAPU32[s[c]>>2],d=Oe.HEAPF32.subarray(u>>2,(u>>2)+l[c]);c++;let p=Oe.HEAPU32[s[c]>>2],f=Oe.HEAPU32.subarray(p>>2,(p>>2)+l[c]);if(r===void 0){let h=new lt.BufferGeometry;h.setAttribute("position",new lt.Float32BufferAttribute(d,3));let m=new Float32Array(d.length);for(let y=0,g=d.length;y<g;)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)),Oe.free_wireframe_data_for_base_level(n),h}r.getAttribute("position").copyArray(d),r.attributes.position.needsUpdate=!0,Oe.free_wireframe_data_for_base_level(n)}static updateCollabMesh(e,r,o){let n=r===0;n||Oe.set_destination_refinement_level(e,r);let a=o?Oe.get_topological_data2(e,n?Oe.Level.CONTROL:Oe.Level.REFINED,o.elements):Oe.get_topological_data(e,n?Oe.Level.CONTROL:Oe.Level.REFINED),s=6,l=Oe.HEAPU32.subarray(a>>2,(a>>2)+s),c=l.subarray(3,3+3),u=0,d=Oe.HEAPU32[l[u]>>2],p=new Float32Array(Oe.HEAPF32.subarray(d>>2,(d>>2)+c[u]));u++;let f=Oe.HEAPU32[l[u]>>2],h=new Uint32Array(Oe.HEAPU32.subarray(f>>2,(f>>2)+c[u]));u++;let m=Oe.HEAPU32[l[u]>>2],y=new Uint8Array(Oe.HEAPU32.subarray(m>>2,(m>>2)+c[u]));return Oe.free_topological_data(a),{positions:p,indices:h,verticesPerFace:y}}};var Eb=["getX","getY","getZ"];function rh(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,d="";for(let p=0;p<3;p++)d+=`${~~(i[Eb[p]](u)*s)},`;if(d in e)n.push(e[d]);else{for(let p=0;p<3;p++)a.push(i[Eb[p]](u));e[d]=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 dd=new lt.Vector3,Jf=new lt.Vector3,eh=new lt.Vector3,th=new lt.Vector3;function oh(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 p=l.length/2/c;l=l.filter((f,h)=>Math.floor(h/2)%p===0)}let u=0;for(let p=0;p<l.length;p+=2)u+=(l[p]-l[(p===0?l.length:p)-2])*(l[p+1]+l[(p===0?l.length:p)-1]);i.length=0;let d=0;if(u<0)for(let p=0;p<l.length;p+=2)i.push(l[p],l[p+1],0),o.push(d++);else for(let p=l.length-2;p>=0;p-=2)i.push(l[p],l[p+1],0),o.push(d++);return n.push(d),{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]){dd.set(i[t[s]*3],i[t[s]*3+1],i[t[s]*3+2]),Jf.set(i[t[s+1]*3],i[t[s+1]*3+1],i[t[s+1]*3+2]),eh.set(i[t[s+4]*3],i[t[s+4]*3+1],i[t[s+4]*3+2]),th.set(i[t[s+5]*3],i[t[s+5]*3+1],i[t[s+5]*3+2]),Jf.sub(dd).normalize(),eh.sub(dd).normalize(),th.sub(dd).normalize();let l=Jf.cross(eh).dot(th),c=s;Math.abs(l)>.005||r&&r.some((u,d)=>d%2===1?!1:c>=r[d]&&c<r[d+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 d=0,p=0;d<i.length;d+=3,p++)i[d+2]===0&&(l.push(p),u++),i[d+2]===a&&c.push(p);if(e.userData.parameters.extrudeBevelSize===0){let d=c[0];c[0]=c[1],c[1]=d}l.reverse(),o.push(...l,...c),n.push(u,u)}return{indices:o,verticesPerFace:n}}var Xr={};xm(Xr,{calcBoolean:()=>jI,calcBooleanTopological:()=>FI,freeMeshSet:()=>WI,getMeshSet:()=>UI,hasOpenEdges:()=>kI,transformMeshSet:()=>HI});var zI,Nb=new Promise(i=>{zI=i});var Ul=require("three");var ke,ss;Nb.then(i=>ke=i);function GI(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}=rh(i.getAttribute("position"),o),s;if(t&&e){let{indices:l,verticesPerFace:c}=oh(n,a,i);s=c.length,r=[];for(let u=0,d=0;u<s;u++){r.push(c[u]);for(let p=0;p<c[u];p++)r.push(l[d++])}}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 Db(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=ke._malloc(o);return(Number.isInteger(i[0])?new Uint32Array(ke.HEAPU32.buffer,n,t):new Float32Array(ke.HEAPF32.buffer,n,t)).set(i,0),n}function _b(i){switch(i){case 0:return ke.OP.UNION;case 1:return ke.OP.INTERSECTION;case 2:return ke.OP.A_MINUS_B;default:throw new Error("Unknown boolean operation "+i)}}function FI(i,t){ss===void 0&&(ss=ke.init_csg());let e=Db(i),r=ke.csg_calc_topological(ss,e,i.length,_b(t));ke._free(e);let o=6,n=ke.HEAPU32.subarray(r>>2,(r>>2)+o),a=n.subarray(3,3+3),s=0,l=ke.HEAPU32[n[s]>>2],c=new Float32Array(ke.HEAPF32.subarray(l>>2,(l>>2)+a[s]));s++;let u=ke.HEAPU32[n[s]>>2],d=new Uint32Array(ke.HEAPU32.subarray(u>>2,(u>>2)+a[s]));s++;let p=ke.HEAPU32[n[s]>>2],f=new Uint8Array(ke.HEAPU32.subarray(p>>2,(p>>2)+a[s]));return ke.free_mesh_data(r),{positions:c,indices:d,verticesPerFace:f}}function jI(i,t,e,r){ss===void 0&&(ss=ke.init_csg());let o=Db(i),n=ke.csg_calc(ss,o,i.length,r,_b(t));ke._free(o);let a=5,s=ke.HEAPU32.subarray(n>>2,(n>>2)+a),l=s.subarray(2,2+3),c=0,u=ke.HEAPU32[s[c]>>2],d=ke.HEAPF32.subarray(u>>2,(u>>2)+l[c]);c++;let p=ke.HEAPU32[s[c]>>2],f=ke.HEAPF32.subarray(p>>2,(p>>2)+l[c]);c++;let h=l[c];e.setAttribute("position",new Ul.Float32BufferAttribute(d,3)),e.setAttribute("normal",new Ul.Float32BufferAttribute(f,3));let m=ke.HEAPF32.subarray((n>>2)+5,(n>>2)+5+6);return e.boundingSphere===null&&(e.boundingSphere=new Ul.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},ke.free_mesh_data(n),h}function UI(i,t,e){if(ke===void 0)return-1;let r,o,n;if(t&&i.userData.positions!==void 0){let g=i.userData;n=g.verticesPerFace.length,r=g.positions,o=Array(g.verticesPerFace.reduce((b,w)=>b+w,0)+n);for(let b=0,w=0,P=0;b<g.verticesPerFace.length;b++){o[P++]=g.verticesPerFace[b];for(let S=0;S<g.verticesPerFace[b];S++)o[P++]=g.indices[w++]}}else({positions:r,faceIndices:o,nFaces:n}=GI(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,d=l*Float32Array.BYTES_PER_ELEMENT,p=c*Uint32Array.BYTES_PER_ELEMENT,f=ke._malloc(u),h=new Float32Array(ke.HEAPF32.buffer,f,l),m=new Uint32Array(ke.HEAPU32.buffer,f+d,c);h.set(r,0),m.set(o,0);let y=ke.get_csg_mesh(f,a,f+d,s,n);return ke._free(f),y}function kI(i){return ke.has_open_edges(i)}function HI(i,t){ke.transform_csg_mesh(i,t.elements)}function WI(i){ke.free_csg_mesh(i)}var qI={ConeGeometry:Px,CubeGeometry:Ox,CylinderGeometry:wx,DodecahedronGeometry:Cx,EllipseGeometry:ts,HelixGeometry:Qx,IcosahedronGeometry:Jx,LatheGeometry:eb,NonParametricGeometry:ib,PolygonGeometry:nd,PyramidGeometry:nb,RectangleGeometry:is,SphereGeometry:ab,PlaneGeometry:lb,BackdropGeometry:cb,StarGeometry:ad,TextFrameGeometry:db,TorusGeometry:pb,TorusKnotGeometry:hb,TriangleGeometry:mb,PathGeometry:bb,VectorGeometry:Tr},Zf=i=>qI[i.type].create(i);function ls(i){return i!==null&&"booleanOp"in i}var cs=class extends $a(pd.Mesh){constructor(){super(...arguments);this.booleanMeshSetAddress=-1;this.booleanWasTransformed=!1;this.booleanMatrixInvOld=new pd.Matrix4}updateVisible(e){super.updateVisible(e),this.visible=!ls(this.parent)&&this.visible,ls(this.parent)&&this.parent.invalidateDownstreamBooleanData()}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(Xr.freeMeshSet(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}invalidateDownstreamBooleanData(e=!1){return e?this.booleanWasTransformed=!0:this.freeBooleanPointer(),ls(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let e of this.children)e instanceof cs&&(e.freeBooleanPointer(),ls(e)&&e.invalidateUpstreamBooleanData())}updateTransformState(e,r){let o=super.updateTransformState(e,r);return o&&ls(this.parent)&&this.invalidateDownstreamBooleanData(!0),o}onVariableUpdate(e=!1){super.onVariableUpdate(e),ls(this.parent)&&this.invalidateDownstreamBooleanData(!0)}};var fd=new us.Box3;function kl(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 d=t;d<e;d++){let p=i.getX(d),f=i.getY(d),h=i.getZ(d);p<n&&(n=p),f<a&&(a=f),h<s&&(s=h),p>l&&(l=p),f>c&&(c=f),h>u&&(u=h)}fd.min.set(n,a,s),fd.max.set(l,c,u),fd.getCenter(r),fd.getSize(o).multiplyScalar(.5)}var $I=new us.BufferGeometry,XI=new us.MeshBasicMaterial,Xt=class extends cs{constructor(t,e){super($I,XI),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?kl(r,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:r.count,t,e):super.updateEntityBoxSize(t,e)}};var vi=require("three");var Gr=require("three");var Ad=require("three");var mi=class{constructor(t){this.hashProperties=void 0;this.isNode=!0;this.shortcuts={};if(mi.uuidContext===null)throw new Error("plz startContext");mi.uuidContext===mi.globalContext?this.uuid="_gid"+mi.uuidContext.nodeContextUuid++:this.uuid="_uid"+mi.uuidContext.nodeContextUuid++,this.type=t,this.name=""}static startContext(t){this.uuidContext===null||this.uuidContext===mi.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=mi;ot.globalContext={nodeContextUuid:0},ot.uuidContext=mi.globalContext;var xo=require("three");var Hl=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 ih=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}},Yt=new ih;var nh=require("three");var Rb=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=Rb.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 Ot=class extends it{constructor(e=0,r){super("v2");this.nodeType="Vector2";this.value=e instanceof nh.Vector2?e:new nh.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 ah=require("three");var ar=class extends it{constructor(e=0,r,o){super("v3");this.nodeType="Vector3";this.value=e instanceof ah.Vector3?e:new ah.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 Cr=class extends it{constructor(e){super("v4");this.nodeType="Vector4";this.value=e instanceof qt?e:new qt(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 YI=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,Lb=/[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 d=0;d<this.includes.length;d++)e.include(this.includes[d],this);for(let d in this.extensions)e.extensions[d]=!0;let u=[];for(;s=Lb.exec(this.src);)u.push(s);for(let d=0;d<u.length;d++){let p=u[d],f=p[0],h=this.isMethod?!this.getInputByName(f):!0,m=f;if(this.keywords[f]||this.useKeywords&&h&&Yt.containsKeyword(f)){let y=this.keywords[f];if(!y){let g=Yt.getKeywordData(f);g.cache&&(y=e.keywords[f]),y=y||Yt.getKeyword(f,e),g.cache&&(e.keywords[f]=y)}m=y.build(e)}f!==m&&c[p.index+l-1]!=="."&&(c=c.substring(0,p.index+l)+m+c.substring(p.index+f.length+l),l+=m.length-f.length),this.getIncludeByName(m)===void 0&&Yt.contains(m)&&e.include(Yt.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=YI.exec(this.src);if(this.inputs=[],a&&a.length==4){this.type=a[1],this.name=a[2];let s=a[3].match(Lb);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 d=s[l++];this.inputs.push({name:d,type:u,qualifier:c})}}this.isInterface=this.src.indexOf("{")===-1}else this.type="",this.name=""}}};var KI=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=?\s?(.*?)(\;|$)/i,sh=class extends be{constructor(e="",r){super();this.src="";this.useDefine=!1;this.nodeType="Const";this.parse(e||sh.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=KI.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)}},$e=sh;$e.PI="PI",$e.PI2="PI2",$e.RECIPROCAL_PI="RECIPROCAL_PI",$e.RECIPROCAL_PI2="RECIPROCAL_PI2",$e.LOG2="LOG2",$e.EPSILON="EPSILON";var QI=new RegExp(`^structs*([a-z_0-9]+)s*{s*((.|
19
+ )*?)}`,"gim"),ZI=new RegExp("s*(w*?)s*(w*?)(=|;)","gim"),ds=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=QI.exec(e);if(r){let o=r[2],n;for(;n=ZI.exec(o);)this.inputs.push({type:n[1],name:n[2]});this.name=r[1]}else this.name="";this.type=this.name}};var ps=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)}};Yt.addKeyword("uv",function(){return new ps});Yt.addKeyword("uv2",function(){return new ps(1)});var hd=require("three");var zn=class extends be{constructor(e,r){super("v4");this.nodeType="ColorSpace";this.input=e,this.method=r??zn.LINEAR_TO_LINEAR,this.hashProperties=["method"]}static getEncodingComponents(e){switch(e){case hd.LinearEncoding:return["Linear"];case hd.sRGBEncoding:return["sRGB"];default:return[]}}generate(e,r){let o=this.input.build(e,"v4"),n=this.getType(e),a=zn.Nodes[this.method],s=e.include(a);if(s===zn.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=zn.getEncodingComponents(e);this.method="LinearTo"+r[0],this.factor=r[1]}fromDecoding(e){let r=zn.getEncodingComponents(e);this.method=r[0]+"ToLinear",this.factor=r[1]}},yr=zn;yr.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(`
22
- `))},yr.LINEAR_TO_LINEAR="LinearToLinear",yr.SRGB_TO_LINEAR="sRGBToLinear",yr.LINEAR_TO_SRGB="LinearTosRGB";var Qe=class extends J{constructor(e="",r,o,n,a){super(e,a,n,o,r);this.nodeType="Expression"}};var Lb=require("three"),gr=class extends it{constructor(e=new Lb.Texture,r,o,n){super("v4",{shared:!0});this.nodeType="Texture";this.value=e,this.uv=r??new ps,this.bias=o,this.project=n!==void 0?n:!1}getTexture(e,r){return super.generate(e,r,this.value.uuid,"t")}generate(e,r){if(r==="sampler2D")return this.getTexture(e,r);let o=this.getTexture(e,r),n=this.uv.build(e,this.project?"v4":"v2"),a=this.bias?this.bias.build(e,"f"):void 0;a===void 0&&e.context.bias&&(a=e.context.bias.setTexture(this).build(e,"f"));let s,l;this.project?s="texture2DProj":s=a?"tex2DBias":"tex2D",a?l=s+"( "+o+", "+n+", "+a+" )":l=s+"( "+o+", "+n+" )";let c={include:e.isShader("vertex"),ignoreCache:!0},u=this.getType(e);return e.addContext(c),this.colorSpace=this.colorSpace??new yr(new Qe("",u)),this.colorSpace.fromDecoding(e.getTextureEncodingFromMap(this.value)),this.colorSpace.input.parse(l),l=this.colorSpace.build(e,u),e.removeContext(),e.format(l,u,r)}};var se=class extends it{constructor(e){super("f");this.nodeType="Float";this.value=e??0}generateReadonly(e,r,o,n,a,s){return e.format(this.value+(this.value%1?"":".0"),n,r)}};var Wl=class extends be{constructor(e,r){super();this.inputs=[];this.nodeType="FunctionCall";this.value=e,this.inputs=r??[]}getFunction(){return this.value}getType(e){return this.value.getType(e)}generate(e,r,o,n,a){n=this.getType(e);let s=this.value,l=s.build(e,r)+"( ",c=[];if(s.inputs){for(let u=0;u<s.inputs.length;u++){let d=s.inputs[u],p=this.inputs[u]||this.inputs[d.name];c.push(p.build(e,e.getTypeByFormat(d.type)))}l+=c.join(", ")+" )"}return e.format(l,n,r)}};var sh=class extends be{constructor(e,r,o=sh.ADD){super();this.nodeType="Operator";this.type=e.type,this.a=e,this.b=r,this.op=o}getType(e){let r=this.a.getType(e),o=this.b.getType(e);return e.isTypeMatrix(r)?"v4":e.getTypeLength(o)>e.getTypeLength(r)?o:r}generate(e,r){let o=this.getType(e);this.type=o;let n=this.a.build(e,o),a=this.b.build(e,o);return e.format("( "+n+" "+this.op+" "+a+" )",o,r)}},tr=sh;tr.ADD="+",tr.SUB="-",tr.MUL="*",tr.DIV="/";var nt=class extends be{constructor(e,r=nt.ABS,o,n){super();this.nodeType="Math";this.a=e,typeof r!="string"?this.b=r:n=r,typeof o!="string"?this.c=o:n=o,this.method=n,this.hashProperties=["method"]}getNumInputs(e){switch(this.method){case nt.MIX:case nt.CLAMP:case nt.REFRACT:case nt.SMOOTHSTEP:case nt.FACEFORWARD:return 3;case nt.MIN:case nt.MAX:case nt.MOD:case nt.STEP:case nt.REFLECT:case nt.DISTANCE:case nt.DOT:case nt.CROSS:case nt.POW:return 2;default:return 1}}getInputType(e){let r=e.getTypeLength(this.a.getType(e)),o=this.b?e.getTypeLength(this.b.getType(e)):0,n=this.c?e.getTypeLength(this.c.getType(e)):0;return r>o&&r>n?this.a.getType(e):o>n?this.b.getType(e):this.c.getType(e)}getType(e){switch(this.method){case nt.LENGTH:case nt.DISTANCE:case nt.DOT:return"f";case nt.CROSS:return"v3"}return this.getInputType(e)}generate(e,r){let o,n,a,s=this.a?e.getTypeLength(this.a.getType(e)):0,l=this.b?e.getTypeLength(this.b.getType(e)):0,c=this.c?e.getTypeLength(this.c.getType(e)):0,u=this.getInputType(e),d=this.getType(e);switch(this.type=d,this.method){case nt.NEGATE:return e.format("( -"+this.a.build(e,u)+" )",u,r);case nt.INVERT:return e.format("( 1.0 - "+this.a.build(e,u)+" )",u,r);case nt.CROSS:o=this.a.build(e,"v3"),n=this.b.build(e,"v3");break;case nt.STEP:o=this.a.build(e,s===1?"f":u),n=this.b.build(e,u);break;case nt.MIN:case nt.MAX:case nt.MOD:o=this.a.build(e,u),n=this.b.build(e,l===1?"f":u);break;case nt.REFRACT:o=this.a.build(e,u),n=this.b.build(e,u),a=this.c.build(e,"f");break;case nt.MIX:o=this.a.build(e,u),n=this.b.build(e,u),a=this.c.build(e,c===1?"f":u);break;default:o=this.a.build(e,u),this.b&&(n=this.b.build(e,u)),this.c&&(a=this.c.build(e,u));break}let p=[];p.push(o),n&&p.push(n),a&&p.push(a);let f=this.getNumInputs(e);if(p.length!==f)throw Error(`Arguments not match used in "${this.method}". Require ${f}, currently ${p.length}.`);return e.format(this.method+"( "+p.join(", ")+" )",d,r)}},Me=nt;Me.RAD="radians",Me.DEG="degrees",Me.EXP="exp",Me.EXP2="exp2",Me.LOG="log",Me.LOG2="log2",Me.SQRT="sqrt",Me.INV_SQRT="inversesqrt",Me.FLOOR="floor",Me.CEIL="ceil",Me.NORMALIZE="normalize",Me.FRACT="fract",Me.SATURATE="saturate",Me.SIN="sin",Me.COS="cos",Me.TAN="tan",Me.ASIN="asin",Me.ACOS="acos",Me.ARCTAN="atan",Me.ABS="abs",Me.SIGN="sign",Me.LENGTH="length",Me.NEGATE="negate",Me.INVERT="invert",Me.MIN="min",Me.MAX="max",Me.MOD="mod",Me.STEP="step",Me.REFLECT="reflect",Me.DISTANCE="distance",Me.DOT="dot",Me.CROSS="cross",Me.POW="pow",Me.MIX="mix",Me.CLAMP="clamp",Me.REFRACT="refract",Me.SMOOTHSTEP="smoothstep",Me.FACEFORWARD="faceforward";var fs=class extends be{constructor(e,r,o){super("v4");this.nodeType="TextureCubeUV";this.value=e,this.uv=r,this.bias=o}bilinearCubeUV(e,r,o,n){let a=new Wl(fs.Nodes.bilinearCubeUV,[r,o,n]);this.colorSpaceTL=this.colorSpaceTL??new yr(new Qe("","v4")),this.colorSpaceTL.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceTL.input.parse(a.build(e)+".tl"),this.colorSpaceTR=this.colorSpaceTR??new yr(new Qe("","v4")),this.colorSpaceTR.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceTR.input.parse(a.build(e)+".tr"),this.colorSpaceBL=this.colorSpaceBL??new yr(new Qe("","v4")),this.colorSpaceBL.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceBL.input.parse(a.build(e)+".bl"),this.colorSpaceBR=this.colorSpaceBR??new yr(new Qe("","v4")),this.colorSpaceBR.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceBR.input.parse(a.build(e)+".br");let s={include:e.isShader("vertex"),ignoreCache:!0};e.addContext(s),this.colorSpaceTLExp=new Qe(this.colorSpaceTL.build(e,"v4"),"v4"),this.colorSpaceTRExp=new Qe(this.colorSpaceTR.build(e,"v4"),"v4"),this.colorSpaceBLExp=new Qe(this.colorSpaceBL.build(e,"v4"),"v4"),this.colorSpaceBRExp=new Qe(this.colorSpaceBR.build(e,"v4"),"v4"),e.removeContext();let l=new Qe("mix( mix( cubeUV_TL, cubeUV_TR, cubeUV.f.x ), mix( cubeUV_BL, cubeUV_BR, cubeUV.f.x ), cubeUV.f.y )","v4");return l.keywords.cubeUV_TL=this.colorSpaceTLExp,l.keywords.cubeUV_TR=this.colorSpaceTRExp,l.keywords.cubeUV_BL=this.colorSpaceBLExp,l.keywords.cubeUV_BR=this.colorSpaceBRExp,l.keywords.cubeUV=a,l}generate(e,r){if(e.isShader("fragment")){let o=this.uv,n=this.bias||e.context.roughness,a=new Wl(fs.Nodes.roughnessToMip,[n]),s=new Me(a,fs.Nodes.m0,fs.Nodes.cubeUV_maxMipLevel,Me.CLAMP),l=new Me(s,Me.FLOOR),c=new Me(s,Me.FRACT),u=this.bilinearCubeUV(e,this.value,o,l),d=this.bilinearCubeUV(e,this.value,o,new tr(l,new se(1).setReadonly(!0),tr.ADD)),p=new Me(u,d,c,Me.MIX);return e.format(p.build(e),"v4",r)}else return console.warn("TextureCubeUVNode is not compatible with "+e.shader+" shader."),e.format("vec4( 0.0 )",this.getType(e),r)}},hs=fs;hs.Nodes=function(){let e=new ds(`struct TextureCubeUVData {
22
+ `))},yr.LINEAR_TO_LINEAR="LinearToLinear",yr.SRGB_TO_LINEAR="sRGBToLinear",yr.LINEAR_TO_SRGB="LinearTosRGB";var Qe=class extends J{constructor(e="",r,o,n,a){super(e,a,n,o,r);this.nodeType="Expression"}};var Bb=require("three"),gr=class extends it{constructor(e=new Bb.Texture,r,o,n){super("v4",{shared:!0});this.nodeType="Texture";this.value=e,this.uv=r??new ps,this.bias=o,this.project=n!==void 0?n:!1}getTexture(e,r){return super.generate(e,r,this.value.uuid,"t")}generate(e,r){if(r==="sampler2D")return this.getTexture(e,r);let o=this.getTexture(e,r),n=this.uv.build(e,this.project?"v4":"v2"),a=this.bias?this.bias.build(e,"f"):void 0;a===void 0&&e.context.bias&&(a=e.context.bias.setTexture(this).build(e,"f"));let s,l;this.project?s="texture2DProj":s=a?"tex2DBias":"tex2D",a?l=s+"( "+o+", "+n+", "+a+" )":l=s+"( "+o+", "+n+" )";let c={include:e.isShader("vertex"),ignoreCache:!0},u=this.getType(e);return e.addContext(c),this.colorSpace=this.colorSpace??new yr(new Qe("",u)),this.colorSpace.fromDecoding(e.getTextureEncodingFromMap(this.value)),this.colorSpace.input.parse(l),l=this.colorSpace.build(e,u),e.removeContext(),e.format(l,u,r)}};var se=class extends it{constructor(e){super("f");this.nodeType="Float";this.value=e??0}generateReadonly(e,r,o,n,a,s){return e.format(this.value+(this.value%1?"":".0"),n,r)}};var Wl=class extends be{constructor(e,r){super();this.inputs=[];this.nodeType="FunctionCall";this.value=e,this.inputs=r??[]}getFunction(){return this.value}getType(e){return this.value.getType(e)}generate(e,r,o,n,a){n=this.getType(e);let s=this.value,l=s.build(e,r)+"( ",c=[];if(s.inputs){for(let u=0;u<s.inputs.length;u++){let d=s.inputs[u],p=this.inputs[u]||this.inputs[d.name];c.push(p.build(e,e.getTypeByFormat(d.type)))}l+=c.join(", ")+" )"}return e.format(l,n,r)}};var lh=class extends be{constructor(e,r,o=lh.ADD){super();this.nodeType="Operator";this.type=e.type,this.a=e,this.b=r,this.op=o}getType(e){let r=this.a.getType(e),o=this.b.getType(e);return e.isTypeMatrix(r)?"v4":e.getTypeLength(o)>e.getTypeLength(r)?o:r}generate(e,r){let o=this.getType(e);this.type=o;let n=this.a.build(e,o),a=this.b.build(e,o);return e.format("( "+n+" "+this.op+" "+a+" )",o,r)}},tr=lh;tr.ADD="+",tr.SUB="-",tr.MUL="*",tr.DIV="/";var nt=class extends be{constructor(e,r=nt.ABS,o,n){super();this.nodeType="Math";this.a=e,typeof r!="string"?this.b=r:n=r,typeof o!="string"?this.c=o:n=o,this.method=n,this.hashProperties=["method"]}getNumInputs(e){switch(this.method){case nt.MIX:case nt.CLAMP:case nt.REFRACT:case nt.SMOOTHSTEP:case nt.FACEFORWARD:return 3;case nt.MIN:case nt.MAX:case nt.MOD:case nt.STEP:case nt.REFLECT:case nt.DISTANCE:case nt.DOT:case nt.CROSS:case nt.POW:return 2;default:return 1}}getInputType(e){let r=e.getTypeLength(this.a.getType(e)),o=this.b?e.getTypeLength(this.b.getType(e)):0,n=this.c?e.getTypeLength(this.c.getType(e)):0;return r>o&&r>n?this.a.getType(e):o>n?this.b.getType(e):this.c.getType(e)}getType(e){switch(this.method){case nt.LENGTH:case nt.DISTANCE:case nt.DOT:return"f";case nt.CROSS:return"v3"}return this.getInputType(e)}generate(e,r){let o,n,a,s=this.a?e.getTypeLength(this.a.getType(e)):0,l=this.b?e.getTypeLength(this.b.getType(e)):0,c=this.c?e.getTypeLength(this.c.getType(e)):0,u=this.getInputType(e),d=this.getType(e);switch(this.type=d,this.method){case nt.NEGATE:return e.format("( -"+this.a.build(e,u)+" )",u,r);case nt.INVERT:return e.format("( 1.0 - "+this.a.build(e,u)+" )",u,r);case nt.CROSS:o=this.a.build(e,"v3"),n=this.b.build(e,"v3");break;case nt.STEP:o=this.a.build(e,s===1?"f":u),n=this.b.build(e,u);break;case nt.MIN:case nt.MAX:case nt.MOD:o=this.a.build(e,u),n=this.b.build(e,l===1?"f":u);break;case nt.REFRACT:o=this.a.build(e,u),n=this.b.build(e,u),a=this.c.build(e,"f");break;case nt.MIX:o=this.a.build(e,u),n=this.b.build(e,u),a=this.c.build(e,c===1?"f":u);break;default:o=this.a.build(e,u),this.b&&(n=this.b.build(e,u)),this.c&&(a=this.c.build(e,u));break}let p=[];p.push(o),n&&p.push(n),a&&p.push(a);let f=this.getNumInputs(e);if(p.length!==f)throw Error(`Arguments not match used in "${this.method}". Require ${f}, currently ${p.length}.`);return e.format(this.method+"( "+p.join(", ")+" )",d,r)}},Me=nt;Me.RAD="radians",Me.DEG="degrees",Me.EXP="exp",Me.EXP2="exp2",Me.LOG="log",Me.LOG2="log2",Me.SQRT="sqrt",Me.INV_SQRT="inversesqrt",Me.FLOOR="floor",Me.CEIL="ceil",Me.NORMALIZE="normalize",Me.FRACT="fract",Me.SATURATE="saturate",Me.SIN="sin",Me.COS="cos",Me.TAN="tan",Me.ASIN="asin",Me.ACOS="acos",Me.ARCTAN="atan",Me.ABS="abs",Me.SIGN="sign",Me.LENGTH="length",Me.NEGATE="negate",Me.INVERT="invert",Me.MIN="min",Me.MAX="max",Me.MOD="mod",Me.STEP="step",Me.REFLECT="reflect",Me.DISTANCE="distance",Me.DOT="dot",Me.CROSS="cross",Me.POW="pow",Me.MIX="mix",Me.CLAMP="clamp",Me.REFRACT="refract",Me.SMOOTHSTEP="smoothstep",Me.FACEFORWARD="faceforward";var fs=class extends be{constructor(e,r,o){super("v4");this.nodeType="TextureCubeUV";this.value=e,this.uv=r,this.bias=o}bilinearCubeUV(e,r,o,n){let a=new Wl(fs.Nodes.bilinearCubeUV,[r,o,n]);this.colorSpaceTL=this.colorSpaceTL??new yr(new Qe("","v4")),this.colorSpaceTL.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceTL.input.parse(a.build(e)+".tl"),this.colorSpaceTR=this.colorSpaceTR??new yr(new Qe("","v4")),this.colorSpaceTR.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceTR.input.parse(a.build(e)+".tr"),this.colorSpaceBL=this.colorSpaceBL??new yr(new Qe("","v4")),this.colorSpaceBL.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceBL.input.parse(a.build(e)+".bl"),this.colorSpaceBR=this.colorSpaceBR??new yr(new Qe("","v4")),this.colorSpaceBR.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceBR.input.parse(a.build(e)+".br");let s={include:e.isShader("vertex"),ignoreCache:!0};e.addContext(s),this.colorSpaceTLExp=new Qe(this.colorSpaceTL.build(e,"v4"),"v4"),this.colorSpaceTRExp=new Qe(this.colorSpaceTR.build(e,"v4"),"v4"),this.colorSpaceBLExp=new Qe(this.colorSpaceBL.build(e,"v4"),"v4"),this.colorSpaceBRExp=new Qe(this.colorSpaceBR.build(e,"v4"),"v4"),e.removeContext();let l=new Qe("mix( mix( cubeUV_TL, cubeUV_TR, cubeUV.f.x ), mix( cubeUV_BL, cubeUV_BR, cubeUV.f.x ), cubeUV.f.y )","v4");return l.keywords.cubeUV_TL=this.colorSpaceTLExp,l.keywords.cubeUV_TR=this.colorSpaceTRExp,l.keywords.cubeUV_BL=this.colorSpaceBLExp,l.keywords.cubeUV_BR=this.colorSpaceBRExp,l.keywords.cubeUV=a,l}generate(e,r){if(e.isShader("fragment")){let o=this.uv,n=this.bias||e.context.roughness,a=new Wl(fs.Nodes.roughnessToMip,[n]),s=new Me(a,fs.Nodes.m0,fs.Nodes.cubeUV_maxMipLevel,Me.CLAMP),l=new Me(s,Me.FLOOR),c=new Me(s,Me.FRACT),u=this.bilinearCubeUV(e,this.value,o,l),d=this.bilinearCubeUV(e,this.value,o,new tr(l,new se(1).setReadonly(!0),tr.ADD)),p=new Me(u,d,c,Me.MIX);return e.format(p.build(e),"v4",r)}else return console.warn("TextureCubeUVNode is not compatible with "+e.shader+" shader."),e.format("vec4( 0.0 )",this.getType(e),r)}},hs=fs;hs.Nodes=function(){let e=new ds(`struct TextureCubeUVData {
23
23
  vec4 tl;
24
24
  vec4 tr;
25
25
  vec4 br;
@@ -98,7 +98,7 @@ best distance: ${p.d}`);let g=[p.x,p.y];return g.distance=p.d,g.distance}functio
98
98
  mip = -2.0 * log2(1.16 * roughness);// 1.16 = 1.79^0.25
99
99
  }
100
100
  return mip;
101
- }`,N);return{bilinearCubeUV:c,roughnessToMip:E,m0:p,cubeUV_maxMipLevel:r}}();var Gn=class extends be{constructor(e){super("v3");this.nodeType="Normal";this.scope=e??Gn.VIEW}getShared(){return this.scope===Gn.WORLD}build(e,r,o,n){let a=e.context[this.scope+"Normal"];return a?a.build(e,r,o,n):super.build(e,r,o)}generate(e,r,o,n,a){let s;switch(this.scope){case Gn.VIEW:e.isShader("vertex")?s="transformedNormal":s="geometryNormal";break;case Gn.LOCAL:e.isShader("vertex")?s="objectNormal":(e.requires.normal=!0,s="vObjectNormal");break;case Gn.WORLD:e.isShader("vertex")?s="inverseTransformDirection( transformedNormal, viewMatrix ).xyz":(e.requires.worldNormal=!0,s="vWNormal");break}return e.format(s,this.getType(e),r)}},rr=Gn;rr.LOCAL="local",rr.WORLD="world",rr.VIEW="view",rr.NORMAL="normal";Yt.addKeyword("viewNormal",function(){return new rr(rr.VIEW)});Yt.addKeyword("localNormal",function(){return new rr(rr.NORMAL)});Yt.addKeyword("worldNormal",function(){return new rr(rr.WORLD)});var Go=class extends be{constructor(e){super("v3");this.nodeType="Position";this.scope=e??Go.LOCAL}getType(){switch(this.scope){case Go.PROJECTION:return"v4"}return this.type}getShader(){switch(this.scope){case Go.LOCAL:case Go.WORLD:return!1}return!0}generate(e,r,o,n,a){let s;switch(this.scope){case Go.LOCAL:e.isShader("vertex")?s="transformed":(e.requires.position=!0,s="vPosition");break;case Go.WORLD:if(e.isShader("vertex"))return"( modelMatrix * vec4( transformed, 1.0 ) ).xyz";e.requires.worldPosition=!0,s="vWPosition";break;case Go.VIEW:s=e.isShader("vertex")?"-mvPosition.xyz":"vViewPosition";break;case Go.PROJECTION:s=e.isShader("vertex")?"( projectionMatrix * modelViewMatrix * vec4( position, 1.0 ) )":"vec4( 0.0 )";break}return e.format(s,this.getType(),r)}},Ar=Go;Ar.LOCAL="local",Ar.WORLD="world",Ar.VIEW="view",Ar.PROJECTION="projection";Yt.addKeyword("position",function(){return new Ar});Yt.addKeyword("worldPosition",function(){return new Ar(Ar.WORLD)});Yt.addKeyword("viewPosition",function(){return new Ar(Ar.VIEW)});var go=class extends be{constructor(e){super("v3");this.nodeType="Reflect";this.scope=e??go.CUBE}getUnique(e){return!e.context.viewNormal}getType(){switch(this.scope){case go.SPHERE:return"v2"}return this.type}generate(e,r){let o=this.getUnique(e);if(e.isShader("fragment")){let n;switch(this.scope){case go.VECTOR:{let a=new rr(rr.VIEW),s=e.context.roughness,l=a.build(e,"v3"),c=new Ar(Ar.VIEW).build(e,"v3"),u=s?s.build(e,"f"):void 0,d=`reflect( -normalize( ${c} ), ${l} )`;u&&(d=`normalize( mix( ${d}, ${l}, ${u} * ${u} ) )`);let p=`inverseTransformDirection( ${d}, viewMatrix )`;o?(e.addNodeCode(`vec3 reflectVec = ${p};`),n="reflectVec"):n=p;break}case go.CUBE:{let a=new go(go.VECTOR).build(e,"v3"),s="vec3( -"+a+".x, "+a+".yz )";o?(e.addNodeCode(`vec3 reflectCubeVec = ${s};`),n="reflectCubeVec"):n=s;break}case go.SPHERE:{let s="normalize( ( viewMatrix * vec4( "+new go(go.VECTOR).build(e,"v3")+", 0.0 ) ).xyz + vec3( 0.0, 0.0, 1.0 ) ).xy * 0.5 + 0.5";o?(e.addNodeCode(`vec2 reflectSphereVec = ${s};`),n="reflectSphereVec"):n=s;break}}return e.format(n,this.getType(),r)}else return console.warn("ReflectNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.type,r)}},Fo=go;Fo.CUBE="cube",Fo.SPHERE="sphere",Fo.VECTOR="vector";var hd=class extends be{constructor(e=new gr,r,o){super("v4");this.nodeType="TextureCube";this.value=e,this.radianceNode=new hs(this.value,r??new Fo(Fo.VECTOR),o),this.irradianceNode=new hs(this.value,new rr(rr.WORLD),new se(1).setReadonly(!0))}generate(e,r){return e.isShader("fragment")?(e.require("irradiance"),e.context.bias&&e.context.bias.setTexture(this.value),(e.slot==="irradiance"?this.irradianceNode:this.radianceNode).build(e,r)):(console.warn("TextureCubeNode is not compatible with "+e.shader+" shader."),e.format("vec4( 0.0 )",this.getType(e),r))}};var Bb=require("three");var md=class extends it{constructor(e=new Bb.CubeTexture,r,o){super("v4",{shared:!0});this.nodeType="CubeTexture";this.value=e,this.uv=r??new Fo,this.bias=o}getTexture(e,r){return super.generate(e,r,this.value.uuid,"tc")}generate(e,r){if(r==="samplerCube")return this.getTexture(e,r);let o=this.getTexture(e,r),n=this.uv?.build(e,"v3"),a=this.bias?this.bias.build(e,"f"):void 0;a===void 0&&e.context.bias&&(a=e.context.bias.setTexture(this).build(e,"f"));let s;a?s="texCubeBias( "+o+", "+n+", "+a+" )":s="texCube( "+o+", "+n+" )";let l={include:e.isShader("vertex"),ignoreCache:!0},c=this.getType(e);return e.addContext(l),this.colorSpace=this.colorSpace??new yr(new Qe("",c)),this.colorSpace.fromDecoding(e.getTextureEncodingFromMap(this.value)),this.colorSpace.input.parse(s),s=this.colorSpace.build(e,c),e.removeContext(),e.format(s,c,r)}};var Vb=`
101
+ }`,N);return{bilinearCubeUV:c,roughnessToMip:E,m0:p,cubeUV_maxMipLevel:r}}();var Gn=class extends be{constructor(e){super("v3");this.nodeType="Normal";this.scope=e??Gn.VIEW}getShared(){return this.scope===Gn.WORLD}build(e,r,o,n){let a=e.context[this.scope+"Normal"];return a?a.build(e,r,o,n):super.build(e,r,o)}generate(e,r,o,n,a){let s;switch(this.scope){case Gn.VIEW:e.isShader("vertex")?s="transformedNormal":s="geometryNormal";break;case Gn.LOCAL:e.isShader("vertex")?s="objectNormal":(e.requires.normal=!0,s="vObjectNormal");break;case Gn.WORLD:e.isShader("vertex")?s="inverseTransformDirection( transformedNormal, viewMatrix ).xyz":(e.requires.worldNormal=!0,s="vWNormal");break}return e.format(s,this.getType(e),r)}},rr=Gn;rr.LOCAL="local",rr.WORLD="world",rr.VIEW="view",rr.NORMAL="normal";Yt.addKeyword("viewNormal",function(){return new rr(rr.VIEW)});Yt.addKeyword("localNormal",function(){return new rr(rr.NORMAL)});Yt.addKeyword("worldNormal",function(){return new rr(rr.WORLD)});var Fo=class extends be{constructor(e){super("v3");this.nodeType="Position";this.scope=e??Fo.LOCAL}getType(){switch(this.scope){case Fo.PROJECTION:return"v4"}return this.type}getShader(){switch(this.scope){case Fo.LOCAL:case Fo.WORLD:return!1}return!0}generate(e,r,o,n,a){let s;switch(this.scope){case Fo.LOCAL:e.isShader("vertex")?s="transformed":(e.requires.position=!0,s="vPosition");break;case Fo.WORLD:if(e.isShader("vertex"))return"( modelMatrix * vec4( transformed, 1.0 ) ).xyz";e.requires.worldPosition=!0,s="vWPosition";break;case Fo.VIEW:s=e.isShader("vertex")?"-mvPosition.xyz":"vViewPosition";break;case Fo.PROJECTION:s=e.isShader("vertex")?"( projectionMatrix * modelViewMatrix * vec4( position, 1.0 ) )":"vec4( 0.0 )";break}return e.format(s,this.getType(),r)}},Ar=Fo;Ar.LOCAL="local",Ar.WORLD="world",Ar.VIEW="view",Ar.PROJECTION="projection";Yt.addKeyword("position",function(){return new Ar});Yt.addKeyword("worldPosition",function(){return new Ar(Ar.WORLD)});Yt.addKeyword("viewPosition",function(){return new Ar(Ar.VIEW)});var go=class extends be{constructor(e){super("v3");this.nodeType="Reflect";this.scope=e??go.CUBE}getUnique(e){return!e.context.viewNormal}getType(){switch(this.scope){case go.SPHERE:return"v2"}return this.type}generate(e,r){let o=this.getUnique(e);if(e.isShader("fragment")){let n;switch(this.scope){case go.VECTOR:{let a=new rr(rr.VIEW),s=e.context.roughness,l=a.build(e,"v3"),c=new Ar(Ar.VIEW).build(e,"v3"),u=s?s.build(e,"f"):void 0,d=`reflect( -normalize( ${c} ), ${l} )`;u&&(d=`normalize( mix( ${d}, ${l}, ${u} * ${u} ) )`);let p=`inverseTransformDirection( ${d}, viewMatrix )`;o?(e.addNodeCode(`vec3 reflectVec = ${p};`),n="reflectVec"):n=p;break}case go.CUBE:{let a=new go(go.VECTOR).build(e,"v3"),s="vec3( -"+a+".x, "+a+".yz )";o?(e.addNodeCode(`vec3 reflectCubeVec = ${s};`),n="reflectCubeVec"):n=s;break}case go.SPHERE:{let s="normalize( ( viewMatrix * vec4( "+new go(go.VECTOR).build(e,"v3")+", 0.0 ) ).xyz + vec3( 0.0, 0.0, 1.0 ) ).xy * 0.5 + 0.5";o?(e.addNodeCode(`vec2 reflectSphereVec = ${s};`),n="reflectSphereVec"):n=s;break}}return e.format(n,this.getType(),r)}else return console.warn("ReflectNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.type,r)}},jo=go;jo.CUBE="cube",jo.SPHERE="sphere",jo.VECTOR="vector";var md=class extends be{constructor(e=new gr,r,o){super("v4");this.nodeType="TextureCube";this.value=e,this.radianceNode=new hs(this.value,r??new jo(jo.VECTOR),o),this.irradianceNode=new hs(this.value,new rr(rr.WORLD),new se(1).setReadonly(!0))}generate(e,r){return e.isShader("fragment")?(e.require("irradiance"),e.context.bias&&e.context.bias.setTexture(this.value),(e.slot==="irradiance"?this.irradianceNode:this.radianceNode).build(e,r)):(console.warn("TextureCubeNode is not compatible with "+e.shader+" shader."),e.format("vec4( 0.0 )",this.getType(e),r))}};var Vb=require("three");var yd=class extends it{constructor(e=new Vb.CubeTexture,r,o){super("v4",{shared:!0});this.nodeType="CubeTexture";this.value=e,this.uv=r??new jo,this.bias=o}getTexture(e,r){return super.generate(e,r,this.value.uuid,"tc")}generate(e,r){if(r==="samplerCube")return this.getTexture(e,r);let o=this.getTexture(e,r),n=this.uv?.build(e,"v3"),a=this.bias?this.bias.build(e,"f"):void 0;a===void 0&&e.context.bias&&(a=e.context.bias.setTexture(this).build(e,"f"));let s;a?s="texCubeBias( "+o+", "+n+", "+a+" )":s="texCube( "+o+", "+n+" )";let l={include:e.isShader("vertex"),ignoreCache:!0},c=this.getType(e);return e.addContext(l),this.colorSpace=this.colorSpace??new yr(new Qe("",c)),this.colorSpace.fromDecoding(e.getTextureEncodingFromMap(this.value)),this.colorSpace.input.parse(s),s=this.colorSpace.build(e,c),e.removeContext(),e.format(s,c,r)}};var zb=`
102
102
  uniform int frameIndex;
103
103
  uniform vec2 resolution;
104
104
  uniform mat4 previousModelViewMatrix;
@@ -106,7 +106,7 @@ uniform mat4 previousProjectionMatrix;
106
106
 
107
107
  varying vec4 vCurrentPosition;
108
108
  varying vec4 vPreviousPosition;
109
- `,zb=`
109
+ `,Gb=`
110
110
  layout(location = 1) out vec4 gVelocity;
111
111
 
112
112
  uniform int frameIndex;
@@ -148,7 +148,7 @@ float getNoiseInterleavedGradient(vec2 screenPos) {
148
148
  return fract(magic.z * fract(dot(screenPos, magic.xy)));
149
149
  }
150
150
 
151
- `,Gb=`
151
+ `,Fb=`
152
152
  // TODO: This could be generated CPU side and passed to the shader every frame
153
153
  const vec2 haltonSequence[16] = vec2[16](
154
154
  vec2( 0.000000,-0.333334),
@@ -185,7 +185,7 @@ vPreviousPosition.xy += OUTLINE_COMPENSATION;
185
185
  #endif
186
186
  gl_Position = currentPositionJittered;
187
187
 
188
- `,Fb=`
188
+ `,jb=`
189
189
  vec2 oldPos = vPreviousPosition.xy;
190
190
  oldPos /= vPreviousPosition.w;
191
191
  oldPos.xy = (oldPos.xy+1.)/2.0;
@@ -200,14 +200,14 @@ vec2 velocity = (newPos - oldPos);
200
200
  if (gl_FragColor.a <= 0.0) discard;
201
201
 
202
202
  gVelocity = vec4(velocity, 0.0, 1.0);
203
- `,jb=`
204
- layout(location = 1) out vec4 gVelocity;
205
203
  `,Ub=`
204
+ layout(location = 1) out vec4 gVelocity;
205
+ `,kb=`
206
206
  // Discard fully transparent pixels
207
207
  if (gl_FragColor.a <= 0.0) discard;
208
208
 
209
209
  gVelocity = vec4(0.0, 0.0, 0.0, 1.0);
210
- `;var kb=["x","y","z","w"],JI=["float","vec2","vec3","vec4"],e3={float:"f",vec2:"v2",vec3:"v3",vec4:"v4",mat4:"v4",int:"i",bool:"b","float[]":"f[]","vec4[]":"v4[]"},t3={t:"sampler2D",tc:"samplerCube",b:"bool",i:"int",f:"float",c:"vec3",v2:"vec2",v3:"vec3",v4:"vec4",m3:"mat3",m4:"mat4","f[]":"float[]","v4[]":"vec4[]"},ms=class{constructor(){this.includes={consts:{},functions:{},structs:{}};this.cache="";this.slot="";this.shader="";this.context={};this.needsJitter=!0;this.getIncludesCode=function(){function t(e,r){return e.deps.length-r.deps.length}return function(r,o){let n=this.getIncludes(r,o);if(!n)return"";let a="";n=n.sort(t);for(let s=0;s<n.length;s++)n[s].src&&(a+=n[s].src+`
210
+ `;var Hb=["x","y","z","w"],JI=["float","vec2","vec3","vec4"],e3={float:"f",vec2:"v2",vec3:"v3",vec4:"v4",mat4:"v4",int:"i",bool:"b","float[]":"f[]","vec4[]":"v4[]"},t3={t:"sampler2D",tc:"samplerCube",b:"bool",i:"int",f:"float",c:"vec3",v2:"vec2",v3:"vec3",v4:"vec4",m3:"mat3",m4:"mat4","f[]":"float[]","v4[]":"vec4[]"},ms=class{constructor(){this.includes={consts:{},functions:{},structs:{}};this.cache="";this.slot="";this.shader="";this.context={};this.needsJitter=!0;this.getIncludesCode=function(){function t(e,r){return e.deps.length-r.deps.length}return function(r,o){let n=this.getIncludes(r,o);if(!n)return"";let a="";n=n.sort(t);for(let s=0;s<n.length;s++)n[s].src&&(a+=n[s].src+`
211
211
  `);return a}}();this.slots=[],this.caches=[],this.contexts=[],this.keywords={},this.nodeData={},this.fragmentVariables={},this.fragmentParsVariables={},this.vertexParsVariables={},this.requires={uv:[],color:[],transparent:!1,irradiance:!1,position:!1,worldPosition:!1,normal:!1,worldNormal:!1,vWorldViewDir:!1,modelMatrix:!1,viewMatrix:!1,projectionMatrix:!1},this.includes={consts:[],functions:[],structs:[]},this.attributes={},this.prefixCode=["#ifdef TEXTURE_LOD_EXT"," #define texCube(a, b) textureCube(a, b)"," #define texCubeBias(a, b, c) textureCubeLodEXT(a, b, c)"," #define tex2D(a, b) texture2D(a, b)"," #define tex2DBias(a, b, c) texture2DLodEXT(a, b, c)","#else"," #define texCube(a, b) textureCube(a, b)"," #define texCubeBias(a, b, c) textureCube(a, b, c)"," #define tex2D(a, b) texture2D(a, b)"," #define tex2DBias(a, b, c) texture2D(a, b, c)","#endif",`
212
212
  // NOTE: Include Spline's blending modes. This could be part of BlendNode
213
213
  #define SPE_BLENDING_NORMAL 0
@@ -245,26 +245,26 @@ layout(location = 1) out vec4 gVelocity;
245
245
  `),fragment:["float accumAlpha = 0.0;",`void accumulateAlpha(float alpha) {
246
246
  accumAlpha += (1.0 - accumAlpha) * alpha;
247
247
  }`,""].join(`
248
- `)},this.code={vertex:"",fragment:""},this.nodeCode={vertex:"",fragment:""},this.resultCode={vertex:"",fragment:""},this.finalCode={vertex:"",fragment:""},this.inputs={uniforms:{list:[],vertex:[],fragment:[]},arrayUniforms:{list:[],vertex:[],fragment:[]},vars:{varying:[],vertex:[],fragment:[]}},this.defines={},this.uniforms={},this.extensions={derivatives:!1,fragDepth:!1,drawBuffers:!1,shaderTextureLOD:!1},this.updaters=[],this.nodes=[],this.analyzing=!1}build(t,e){this.addVertexParsCode(Vb),this.addFragmentParsCode(zb),this.buildShader("vertex",t),this.buildShader("fragment",e);for(let r=0;r<this.requires.uv.length;r++)if(this.requires.uv[r]){let o=r>0?r+1:"";this.addVaryCode("varying vec2 vUv"+o+";"),r>0&&this.addVertexParsCode("attribute vec2 uv"+o+";"),this.addVertexFinalCode("vUv"+o+" = uv"+o+";")}return this.requires.color[0]&&(this.addVaryCode("varying vec4 vColor;"),this.addVertexParsCode("attribute vec4 color;"),this.addVertexFinalCode("vColor = color;")),this.requires.color[1]&&(this.addVaryCode("varying vec4 vColor2;"),this.addVertexParsCode("attribute vec4 color2;"),this.addVertexFinalCode("vColor2 = color2;")),this.requires.position&&(this.addVaryCode("varying vec3 vPosition;"),this.addVertexFinalCode("vPosition = transformed;")),this.requires.worldPosition,this.requires.normal&&(this.addVaryCode("varying vec3 vObjectNormal;"),this.addVertexFinalCode(`
248
+ `)},this.code={vertex:"",fragment:""},this.nodeCode={vertex:"",fragment:""},this.resultCode={vertex:"",fragment:""},this.finalCode={vertex:"",fragment:""},this.inputs={uniforms:{list:[],vertex:[],fragment:[]},arrayUniforms:{list:[],vertex:[],fragment:[]},vars:{varying:[],vertex:[],fragment:[]}},this.defines={},this.uniforms={},this.extensions={derivatives:!1,fragDepth:!1,drawBuffers:!1,shaderTextureLOD:!1},this.updaters=[],this.nodes=[],this.analyzing=!1}build(t,e){this.addVertexParsCode(zb),this.addFragmentParsCode(Gb),this.buildShader("vertex",t),this.buildShader("fragment",e);for(let r=0;r<this.requires.uv.length;r++)if(this.requires.uv[r]){let o=r>0?r+1:"";this.addVaryCode("varying vec2 vUv"+o+";"),r>0&&this.addVertexParsCode("attribute vec2 uv"+o+";"),this.addVertexFinalCode("vUv"+o+" = uv"+o+";")}return this.requires.color[0]&&(this.addVaryCode("varying vec4 vColor;"),this.addVertexParsCode("attribute vec4 color;"),this.addVertexFinalCode("vColor = color;")),this.requires.color[1]&&(this.addVaryCode("varying vec4 vColor2;"),this.addVertexParsCode("attribute vec4 color2;"),this.addVertexFinalCode("vColor2 = color2;")),this.requires.position&&(this.addVaryCode("varying vec3 vPosition;"),this.addVertexFinalCode("vPosition = transformed;")),this.requires.worldPosition,this.requires.normal&&(this.addVaryCode("varying vec3 vObjectNormal;"),this.addVertexFinalCode(`
249
249
  #ifndef SHAPEBLEND
250
250
  vObjectNormal = normal;
251
251
  #else
252
252
  vObjectNormal = objectNormal;
253
253
  #endif
254
- `)),this.requires.modelMatrix&&this.addFragmentParsCode("uniform mat4 modelMatrix;"),this.requires.viewMatrix&&this.addFragmentParsCode("uniform mat4 viewMatrix;"),this.requires.projectionMatrix&&this.addFragmentParsCode("uniform mat4 projectionMatrix;"),this.requires.worldNormal&&(this.addVaryCode("varying vec3 vWNormal;"),this.addVertexFinalCode("vWNormal = inverseTransformDirection( transformedNormal, viewMatrix ).xyz;")),this.requires.vWorldViewDir&&(this.addVaryCode("varying vec3 vWorldViewDir;"),this.addVertexFinalCode("vWorldViewDir = isPerspectiveMatrix( projectionMatrix ) ? ( (modelMatrix * vec4(position, 1.0)).xyz - cameraPosition ) : vec3( -viewMatrix[0][2], -viewMatrix[1][2], -viewMatrix[2][2] );")),this.needsJitter&&(this.addVertexFinalCode(Gb),this.addFragmentFinalCode(Fb)),this}buildShader(t,e){this.resultCode[t]=e.build(this.setShader(t),"v4")}setMaterial(t,e){return this.defines={},this}addFlow(t,e,r){return this.addSlot(t).addCache(e).addContext(r)}removeFlow(){return this.removeSlot().removeCache().removeContext()}addCache(t){return this.cache=t??"",this.caches.push(this.cache),this}removeCache(){return this.caches.pop(),this.cache=this.caches[this.caches.length-1]||"",this}addContext(t){return this.context=Object.assign({},this.context,t),this.context.extra=this.context.extra||{},this.contexts.push(this.context),this}removeContext(){return this.contexts.pop(),this.context=this.contexts[this.contexts.length-1]||{},this}addSlot(t){return this.slot=t||"",this.slots.push(this.slot),this}removeSlot(){return this.slots.pop(),this.slot=this.slots[this.slots.length-1]||"",this}addFragmentVariable(t,e){this.fragmentVariables[t]===void 0&&(this.addFragmentCode(`${e} ${t};`),this.fragmentVariables[t]="")}addFragmentParsVariable(t,e){this.fragmentParsVariables[t]===void 0&&(this.addFragmentParsCode(`${e} ${t};`),this.fragmentParsVariables[t]="")}addVertexParsVariable(t,e){this.vertexParsVariables[t]===void 0&&(this.addVertexParsCode(`${e} ${t};`),this.vertexParsVariables[t]="")}addVertexCode(t){this.addCode(t,"vertex")}addFragmentCode(t){this.addCode(t,"fragment")}addCode(t,e){this.code[e??this.shader]+=t+`
254
+ `)),this.requires.modelMatrix&&this.addFragmentParsCode("uniform mat4 modelMatrix;"),this.requires.viewMatrix&&this.addFragmentParsCode("uniform mat4 viewMatrix;"),this.requires.projectionMatrix&&this.addFragmentParsCode("uniform mat4 projectionMatrix;"),this.requires.worldNormal&&(this.addVaryCode("varying vec3 vWNormal;"),this.addVertexFinalCode("vWNormal = inverseTransformDirection( transformedNormal, viewMatrix ).xyz;")),this.requires.vWorldViewDir&&(this.addVaryCode("varying vec3 vWorldViewDir;"),this.addVertexFinalCode("vWorldViewDir = isPerspectiveMatrix( projectionMatrix ) ? ( (modelMatrix * vec4(position, 1.0)).xyz - cameraPosition ) : vec3( -viewMatrix[0][2], -viewMatrix[1][2], -viewMatrix[2][2] );")),this.needsJitter&&(this.addVertexFinalCode(Fb),this.addFragmentFinalCode(jb)),this}buildShader(t,e){this.resultCode[t]=e.build(this.setShader(t),"v4")}setMaterial(t,e){return this.defines={},this}addFlow(t,e,r){return this.addSlot(t).addCache(e).addContext(r)}removeFlow(){return this.removeSlot().removeCache().removeContext()}addCache(t){return this.cache=t??"",this.caches.push(this.cache),this}removeCache(){return this.caches.pop(),this.cache=this.caches[this.caches.length-1]||"",this}addContext(t){return this.context=Object.assign({},this.context,t),this.context.extra=this.context.extra||{},this.contexts.push(this.context),this}removeContext(){return this.contexts.pop(),this.context=this.contexts[this.contexts.length-1]||{},this}addSlot(t){return this.slot=t||"",this.slots.push(this.slot),this}removeSlot(){return this.slots.pop(),this.slot=this.slots[this.slots.length-1]||"",this}addFragmentVariable(t,e){this.fragmentVariables[t]===void 0&&(this.addFragmentCode(`${e} ${t};`),this.fragmentVariables[t]="")}addFragmentParsVariable(t,e){this.fragmentParsVariables[t]===void 0&&(this.addFragmentParsCode(`${e} ${t};`),this.fragmentParsVariables[t]="")}addVertexParsVariable(t,e){this.vertexParsVariables[t]===void 0&&(this.addVertexParsCode(`${e} ${t};`),this.vertexParsVariables[t]="")}addVertexCode(t){this.addCode(t,"vertex")}addFragmentCode(t){this.addCode(t,"fragment")}addCode(t,e){this.code[e??this.shader]+=t+`
255
255
  `}addVertexNodeCode(t){this.addNodeCode(t,"vertex")}addFragmentNodeCode(t){this.addNodeCode(t,"fragment")}addNodeCode(t,e){this.nodeCode[e??this.shader]+=t+`
256
256
  `}clearNodeCode(t){t=t??this.shader;let e=this.nodeCode[t];return this.nodeCode[t]="",e}clearVertexNodeCode(){return this.clearNodeCode("vertex")}clearFragmentNodeCode(){return this.clearNodeCode("fragment")}addVertexFinalCode(t){this.addFinalCode(t,"vertex")}addFragmentFinalCode(t){this.addFinalCode(t,"fragment")}addFinalCode(t,e){this.finalCode[e??this.shader]+=t+`
257
257
  `}addVertexParsCode(t){this.addParsCode(t,"vertex")}addFragmentParsCode(t){this.addParsCode(t,"fragment")}addParsCode(t,e){this.parsCode[e??this.shader]+=t+`
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 Hl({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 Hl({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"?Yt.get(t):t,this.context.include===!1)return t.name;t instanceof J?o=this.includes.functions:t instanceof $e?o=this.includes.consts:t instanceof ds&&(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 JI[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 xo.CubeReflectionMapping:case xo.CubeRefractionMapping:return new md(r);case xo.CubeUVReflectionMapping:return new hd(new gr(r));default:return new gr(r)}else{if(r.isVector2)return new Ot(r);if(r.isVector3)return new ar(r);if(r.isVector4)return new Cr(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 e3[t]||t}getFormatByType(t){return t3[t]||t}getUUID(t,e){return e=e!==void 0?e:!0,e&&this.cache&&(t=this.cache+"-"+t),t}getElementByIndex(t){return kb[t]}getIndexByElement(t){return kb.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=xo.LinearEncoding,e===xo.LinearEncoding&&this.context.gamma&&(e=xo.sRGBEncoding),e}};var ct=require("three");var et=class extends it{constructor(e=0,r,o,n){super("c");this.nodeType="Color";this.value=e instanceof qt?e:new qt(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 je=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 xd=require("three");var Tt=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 bo=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 Hb=require("three");var Ki=class extends it{};var yd=class extends Ki{constructor(e){super("v3");this.image=e;this._value=new Hb.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 Fn=class extends Ki{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 Wb=require("three");var ys=class extends it{constructor(e){super("m3");this.nodeType="Matrix3";this.value=e??new Wb.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 qb=require("three");var sr=class extends it{constructor(e){super("m4");this.nodeType="Matrix4";this.value=e??new qb.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 ql=require("three");function $b(i,t,e,r=0){i.setUvTransform(e[0],e[1],t[0],t[1],0,0,0).premultiply(new ql.Matrix3().makeRotation(r*ql.MathUtils.DEG2RAD))}var gd=class extends ys{constructor(e,r,o=0){super(new ql.Matrix3);this.repeat=e;this.offset=r;this.rotation=o;$b(this.value,e,r,o)}updateMatrix(){$b(this.value,this.repeat,this.offset,this.rotation)}};var lh=require("three");var vo=class extends it{constructor(e=1,r){super("v4[]");this.nodeType="Vector4Array";this.size=e,this.value=Array.isArray(r)?r:r instanceof lh.Vector4?new Array(e).fill(r):new Array(e).fill(new lh.Vector4(0))}};var gs=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 ch=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(ch.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)}},jn=ch;jn.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 Hl({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 Hl({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"?Yt.get(t):t,this.context.include===!1)return t.name;t instanceof J?o=this.includes.functions:t instanceof $e?o=this.includes.consts:t instanceof ds&&(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 JI[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 xo.CubeReflectionMapping:case xo.CubeRefractionMapping:return new yd(r);case xo.CubeUVReflectionMapping:return new md(new gr(r));default:return new gr(r)}else{if(r.isVector2)return new Ot(r);if(r.isVector3)return new ar(r);if(r.isVector4)return new Cr(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 e3[t]||t}getFormatByType(t){return t3[t]||t}getUUID(t,e){return e=e!==void 0?e:!0,e&&this.cache&&(t=this.cache+"-"+t),t}getElementByIndex(t){return Hb[t]}getIndexByElement(t){return Hb.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=xo.LinearEncoding,e===xo.LinearEncoding&&this.context.gamma&&(e=xo.sRGBEncoding),e}};var ct=require("three");var et=class extends it{constructor(e=0,r,o,n){super("c");this.nodeType="Color";this.value=e instanceof qt?e:new qt(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 je=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 bd=require("three");var Tt=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 bo=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 Wb=require("three");var Ki=class extends it{};var gd=class extends Ki{constructor(e){super("v3");this.image=e;this._value=new Wb.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 Fn=class extends Ki{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 qb=require("three");var ys=class extends it{constructor(e){super("m3");this.nodeType="Matrix3";this.value=e??new qb.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 $b=require("three");var sr=class extends it{constructor(e){super("m4");this.nodeType="Matrix4";this.value=e??new $b.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 ql=require("three");function Xb(i,t,e,r=0){i.setUvTransform(e[0],e[1],t[0],t[1],0,0,0).premultiply(new ql.Matrix3().makeRotation(r*ql.MathUtils.DEG2RAD))}var xd=class extends ys{constructor(e,r,o=0){super(new ql.Matrix3);this.repeat=e;this.offset=r;this.rotation=o;Xb(this.value,e,r,o)}updateMatrix(){Xb(this.value,this.repeat,this.offset,this.rotation)}};var ch=require("three");var vo=class extends it{constructor(e=1,r){super("v4[]");this.nodeType="Vector4Array";this.size=e,this.value=Array.isArray(r)?r:r instanceof ch.Vector4?new Array(e).fill(r):new Array(e).fill(new ch.Vector4(0))}};var gs=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 uh=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(uh.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)}},jn=uh;jn.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;
265
265
 
266
266
  return color;
267
- }`)}}();var uh=class extends be{constructor(e,r){super("v3");this.nodeType="CustomNormal";this.cnormal=e,this.alpha=r,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,r){if(e.isShader("fragment")){let o=e.include(uh.Nodes.customNormal);e.addFragmentVariable(this.calpha,"float");let n=[];return n.push(this.cnormal.build(e,"v3")),n.push("normal"),n.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"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("CustomNormalNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),r)}},xs=uh;xs.Nodes=function(){return{customNormal:new J(`vec3 customNormal(vec3 cnormal, vec3 norm, float mask, float alpha, out float calpha) {
267
+ }`)}}();var dh=class extends be{constructor(e,r){super("v3");this.nodeType="CustomNormal";this.cnormal=e,this.alpha=r,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,r){if(e.isShader("fragment")){let o=e.include(dh.Nodes.customNormal);e.addFragmentVariable(this.calpha,"float");let n=[];return n.push(this.cnormal.build(e,"v3")),n.push("normal"),n.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"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("CustomNormalNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),r)}},xs=dh;xs.Nodes=function(){return{customNormal:new J(`vec3 customNormal(vec3 cnormal, vec3 norm, float mask, float alpha, out float calpha) {
268
268
  vec3 normal = packNormalToRGB( norm ).rgb;
269
269
  normal *= step( vec3(0.5), cnormal );
270
270
 
@@ -514,7 +514,7 @@ vec3 sphericalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop,
514
514
  accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));
515
515
 
516
516
  return color;
517
- }`),n=e.include(o),a=[];return a.push(this.color.build(e,"c")),a.push(this.bias.build(e,"f")),a.push(this.scale.build(e,"f")),a.push(this.intensity.build(e,"f")),a.push(this.factor.build(e,"f")),a.push(this.isMask.build(e,"b")),a.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),a.push(this.alpha.build(e,"f")),a.push(this.mode.build(e,"i")),a.push(this.calpha),e.format(n+"("+a.join(",")+")",this.getType(e),r)}else return console.warn("FresnelNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),r)}};var dh=class extends be{constructor(e,r,o,n,a,s,l,c,u){super("v3");this.nodeType="Gradient";this.gradientType=e,this.smooth=r,this.colors=o,this.steps=n,this.offset=a,this.morph=s,this.angle=l,this.isMask=u,this.alpha=c,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,r){if(e.isShader("fragment")){e.define("GRAD_MAX",10),e.require("uv"),e.requires.uv=[!0],e.addFragmentVariable(this.calpha,"float");let o=e.include(dh.Nodes.gradient),n=[];return n.push(this.gradientType.build(e,"i")),n.push(this.smooth.build(e,"b")),n.push(this.colors.build(e,"v4[]")),n.push(this.steps.build(e,"f[]")),n.push(this.offset.build(e,"v2")),n.push(this.morph.build(e,"v2")),n.push(this.angle.build(e,"f")),n.push(this.isMask.build(e,"b")),n.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"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("GradientNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),r)}},ws=dh;ws.Nodes=function(){return{gradient:new J(`vec3 gradient(int gradientType, bool smoothed, vec4 colors[GRAD_MAX], float steps[GRAD_MAX], vec2 offset, vec2 morph, float angle, bool isMask, float mask, float alpha, out float calpha) {
517
+ }`),n=e.include(o),a=[];return a.push(this.color.build(e,"c")),a.push(this.bias.build(e,"f")),a.push(this.scale.build(e,"f")),a.push(this.intensity.build(e,"f")),a.push(this.factor.build(e,"f")),a.push(this.isMask.build(e,"b")),a.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),a.push(this.alpha.build(e,"f")),a.push(this.mode.build(e,"i")),a.push(this.calpha),e.format(n+"("+a.join(",")+")",this.getType(e),r)}else return console.warn("FresnelNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),r)}};var ph=class extends be{constructor(e,r,o,n,a,s,l,c,u){super("v3");this.nodeType="Gradient";this.gradientType=e,this.smooth=r,this.colors=o,this.steps=n,this.offset=a,this.morph=s,this.angle=l,this.isMask=u,this.alpha=c,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,r){if(e.isShader("fragment")){e.define("GRAD_MAX",10),e.require("uv"),e.requires.uv=[!0],e.addFragmentVariable(this.calpha,"float");let o=e.include(ph.Nodes.gradient),n=[];return n.push(this.gradientType.build(e,"i")),n.push(this.smooth.build(e,"b")),n.push(this.colors.build(e,"v4[]")),n.push(this.steps.build(e,"f[]")),n.push(this.offset.build(e,"v2")),n.push(this.morph.build(e,"v2")),n.push(this.angle.build(e,"f")),n.push(this.isMask.build(e,"b")),n.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"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("GradientNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),r)}},ws=ph;ws.Nodes=function(){return{gradient:new J(`vec3 gradient(int gradientType, bool smoothed, vec4 colors[GRAD_MAX], float steps[GRAD_MAX], vec2 offset, vec2 morph, float angle, bool isMask, float mask, float alpha, out float calpha) {
518
518
  vec4 color = colors[0];
519
519
  vec2 m = morph / vUv.xy;
520
520
  vec2 rot = vec2( 0.5 + m.x, m.y );
@@ -556,7 +556,7 @@ vec3 sphericalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop,
556
556
  accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));
557
557
 
558
558
  return color.xyz;
559
- }`)}}();var ph=class extends be{constructor(e,r,o,n,a){super("v3");this.nodeType="Matcap";this.texture=e,this.isMask=n,this.alpha=r,this.mode=o,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`,this.rotation=a}generate(e,r){if(e.isShader("fragment")){e.addFragmentVariable(this.calpha,"float");let o=e.include(ph.Nodes.matcap);e.require("normal"),e.requires.normal=!0;let n=[];return n.push(this.texture.generate(e,"t")),n.push("normal"),n.push(this.isMask.build(e,"b")),n.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),n.push(this.alpha.build(e,"f")),n.push(this.mode.build(e,"i")),n.push(this.calpha),n.push(this.rotation.build(e,"f")),e.format(o+"("+n.join(",")+")",this.getType(e),r)}else return console.warn("MatcapNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),r)}},Ps=ph;Ps.Nodes=function(){return{matcap:new J(`vec3 matcap(sampler2D matcapTex, vec3 normal, bool isMask, float mask, float alpha, int mode, out float calpha, float rotation) {
559
+ }`)}}();var fh=class extends be{constructor(e,r,o,n,a){super("v3");this.nodeType="Matcap";this.texture=e,this.isMask=n,this.alpha=r,this.mode=o,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`,this.rotation=a}generate(e,r){if(e.isShader("fragment")){e.addFragmentVariable(this.calpha,"float");let o=e.include(fh.Nodes.matcap);e.require("normal"),e.requires.normal=!0;let n=[];return n.push(this.texture.generate(e,"t")),n.push("normal"),n.push(this.isMask.build(e,"b")),n.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),n.push(this.alpha.build(e,"f")),n.push(this.mode.build(e,"i")),n.push(this.calpha),n.push(this.rotation.build(e,"f")),e.format(o+"("+n.join(",")+")",this.getType(e),r)}else return console.warn("MatcapNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),r)}},Ps=fh;Ps.Nodes=function(){return{matcap:new J(`vec3 matcap(sampler2D matcapTex, vec3 normal, bool isMask, float mask, float alpha, int mode, out float calpha, float rotation) {
560
560
  vec3 viewDir = normalize( vViewPosition );
561
561
  vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );
562
562
  vec3 y = cross( viewDir, x );
@@ -992,7 +992,7 @@ vec3 sphericalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop,
992
992
  accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));
993
993
 
994
994
  return clamp(color, 0.0, 1.0).rgb;
995
- }`,[or.simplexFast,or.simplexFractal,or.simplexAshima,or.fbm,or.perlin,or.voronoi]),d=e.include(u),p=[];return p.push(this.scale.build(e,"f")),p.push(this.size.build(e,"v3")),p.push(this.move.build(e,"f")),p.push(this.fA.build(e,"v2")),p.push(this.fB.build(e,"v2")),p.push(this.distortion.build(e,"v2")),p.push(this.colorA.build(e,"v4")),p.push(this.colorB.build(e,"v4")),p.push(this.colorC.build(e,"v4")),p.push(this.colorD.build(e,"v4")),p.push(this.voronoiStyle.build(e,"i")),p.push(this.highCut.build(e,"f")),p.push(this.lowCut.build(e,"f")),p.push(this.smoothness.build(e,"f")),p.push(this.seed.build(e,"f")),p.push(this.quality.build(e,"i")),p.push(this.isMask.build(e,"b")),p.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),p.push(this.alpha.build(e,"f")),p.push(this.calpha),e.format(d+"("+p.join(",")+")",this.getType(e),r)}};Os.numOctaves=5;var fh=class extends be{constructor(e,r,o,n,a,s,l,c,u,d,p,f,h,m,y,g){super("v3");this.nodeType="Outline";this.firstTime=!0,this.outlineColor=e,this.contourColor=r,this.outlineWidth=o,this.contourWidth=n,this.contourThreshold=a,this.outlineThreshold=s,this.contourFrequency=l,this.outlineSmoothing=c,this.contourDirection=u,this.positionalLines=d,this.compensation=p,this.resolution=f,this.normalMap=h,this.depthMap=m,this.pixelRatio=y,this.alpha=g,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,r){let o=`g${this.uuid.toString().replace(/-/g,"")}`;if(e.require("vWorldViewDir"),e.require("worldNormal"),e.extensions.derivatives=!0,this.compensation.value&&e.define("OUTLINE_COMPENSATION",`${o}_offset`),this.firstTime){let n=this.outlineWidth.build(e,"f"),a=this.resolution.build(e,"v2"),s=this.compensation.build(e,"b"),l=this.pixelRatio.build(e,"f");e.addVertexParsVariable("randomColor","attribute vec3"),e.addVertexParsVariable("extrudeNormal","attribute vec3"),e.addVertexParsVariable(n,"uniform float"),e.addVertexParsVariable(a,"uniform vec2"),e.addVertexParsVariable(s,"uniform bool"),e.addVertexParsVariable(l,"uniform float"),e.addVertexParsVariable("vID","flat out float"),e.addFragmentParsVariable("vID","flat in float"),e.addVertexFinalCode(`
995
+ }`,[or.simplexFast,or.simplexFractal,or.simplexAshima,or.fbm,or.perlin,or.voronoi]),d=e.include(u),p=[];return p.push(this.scale.build(e,"f")),p.push(this.size.build(e,"v3")),p.push(this.move.build(e,"f")),p.push(this.fA.build(e,"v2")),p.push(this.fB.build(e,"v2")),p.push(this.distortion.build(e,"v2")),p.push(this.colorA.build(e,"v4")),p.push(this.colorB.build(e,"v4")),p.push(this.colorC.build(e,"v4")),p.push(this.colorD.build(e,"v4")),p.push(this.voronoiStyle.build(e,"i")),p.push(this.highCut.build(e,"f")),p.push(this.lowCut.build(e,"f")),p.push(this.smoothness.build(e,"f")),p.push(this.seed.build(e,"f")),p.push(this.quality.build(e,"i")),p.push(this.isMask.build(e,"b")),p.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),p.push(this.alpha.build(e,"f")),p.push(this.calpha),e.format(d+"("+p.join(",")+")",this.getType(e),r)}};Os.numOctaves=5;var hh=class extends be{constructor(e,r,o,n,a,s,l,c,u,d,p,f,h,m,y,g){super("v3");this.nodeType="Outline";this.firstTime=!0,this.outlineColor=e,this.contourColor=r,this.outlineWidth=o,this.contourWidth=n,this.contourThreshold=a,this.outlineThreshold=s,this.contourFrequency=l,this.outlineSmoothing=c,this.contourDirection=u,this.positionalLines=d,this.compensation=p,this.resolution=f,this.normalMap=h,this.depthMap=m,this.pixelRatio=y,this.alpha=g,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,r){let o=`g${this.uuid.toString().replace(/-/g,"")}`;if(e.require("vWorldViewDir"),e.require("worldNormal"),e.extensions.derivatives=!0,this.compensation.value&&e.define("OUTLINE_COMPENSATION",`${o}_offset`),this.firstTime){let n=this.outlineWidth.build(e,"f"),a=this.resolution.build(e,"v2"),s=this.compensation.build(e,"b"),l=this.pixelRatio.build(e,"f");e.addVertexParsVariable("randomColor","attribute vec3"),e.addVertexParsVariable("extrudeNormal","attribute vec3"),e.addVertexParsVariable(n,"uniform float"),e.addVertexParsVariable(a,"uniform vec2"),e.addVertexParsVariable(s,"uniform bool"),e.addVertexParsVariable(l,"uniform float"),e.addVertexParsVariable("vID","flat out float"),e.addFragmentParsVariable("vID","flat in float"),e.addVertexFinalCode(`
996
996
  vID = randomColor.r;
997
997
  vec2 ${o}_offset = vec2(0.0);
998
998
  if (${s}) {
@@ -1007,7 +1007,7 @@ vec3 sphericalTexture(vec3 normal, sampler2D tex, vec2 textureSize, float crop,
1007
1007
  // if this offset is the biggest of all the potential offsets
1008
1008
  gl_Position = ${o}_clipPosition;
1009
1009
  }
1010
- `)}if(e.isShader("fragment")){e.require("uv"),e.requires.uv=[!0],e.addFragmentVariable(this.calpha,"float");let n=e.include(fh.Nodes.outline),a=[];return a.push(this.outlineColor.build(e,"c")),a.push(this.contourColor.build(e,"c")),a.push(this.outlineWidth.build(e,"f")),a.push(this.contourWidth.build(e,"f")),a.push(this.contourThreshold.build(e,"f")),a.push(this.outlineThreshold.build(e,"f")),a.push(this.contourFrequency.build(e,"f")),a.push(this.outlineSmoothing.build(e,"f")),a.push(this.contourDirection.build(e,"v3")),a.push(this.positionalLines.build(e,"b")),a.push(this.resolution.build(e,"v2")),a.push(this.normalMap.getTexture(e,"t")),a.push(this.depthMap.getTexture(e,"t")),a.push(this.pixelRatio.build(e,"f")),a.push(this.compensation.build(e,"b")),a.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),a.push(this.alpha.build(e,"f")),a.push(this.calpha),this.firstTime=!this.firstTime,e.format(n+"("+a.join(",")+")",this.getType(e),r)}else return console.warn("OutlineNode is not compatible with "+e.shader+" shader."),""}},Ts=fh;Ts.Nodes=function(){let e=new J(`
1010
+ `)}if(e.isShader("fragment")){e.require("uv"),e.requires.uv=[!0],e.addFragmentVariable(this.calpha,"float");let n=e.include(hh.Nodes.outline),a=[];return a.push(this.outlineColor.build(e,"c")),a.push(this.contourColor.build(e,"c")),a.push(this.outlineWidth.build(e,"f")),a.push(this.contourWidth.build(e,"f")),a.push(this.contourThreshold.build(e,"f")),a.push(this.outlineThreshold.build(e,"f")),a.push(this.contourFrequency.build(e,"f")),a.push(this.outlineSmoothing.build(e,"f")),a.push(this.contourDirection.build(e,"v3")),a.push(this.positionalLines.build(e,"b")),a.push(this.resolution.build(e,"v2")),a.push(this.normalMap.getTexture(e,"t")),a.push(this.depthMap.getTexture(e,"t")),a.push(this.pixelRatio.build(e,"f")),a.push(this.compensation.build(e,"b")),a.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),a.push(this.alpha.build(e,"f")),a.push(this.calpha),this.firstTime=!this.firstTime,e.format(n+"("+a.join(",")+")",this.getType(e),r)}else return console.warn("OutlineNode is not compatible with "+e.shader+" shader."),""}},Ts=hh;Ts.Nodes=function(){let e=new J(`
1011
1011
  float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outlineWidth, float pixelRatio)
1012
1012
  {
1013
1013
  vec2 halton = haltonSequence[frameIndex];
@@ -1156,7 +1156,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
1156
1156
  accumAlpha += ( 1.0 - accumAlpha ) * lalpha;
1157
1157
 
1158
1158
  return result;
1159
- }`,[e])}}();var jo=class extends be{constructor(e,r,o,n,a,s,l,c,u,d,p,f,h,m,y,g,b,w){super("v3");this.nodeType="Pattern";this.style=e,this.projection=r,this.axis=o,this.blending=n,this.offset=a,this.colorA=s,this.colorB=l,this.frequency=c,this.size=u,this.variation=d,this.smoothness=p,this.zigzag=f,this.rotation=h,this.vertical=m,this.horizontal=y,this.sides=g,this.isMask=w,this.alpha=b,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,r){if(e.isShader("fragment")){e.require("position"),e.require("uv"),e.requires.uv=[!0],e.require("normal"),e.requires.normal=!0,e.addFragmentVariable(this.calpha,"float");let o;switch(this.style.value){case 0:o="circle";break;case 1:o="ring";break;case 2:o="polygon";break;case 3:o="xcross";break;case 4:o="diamond";break;case 5:o="checkerboard";break;case 6:o="line";break;case 7:o="wave";break;default:o="circle";break}let n=`g${this.uuid.toString().replace(/-/g,"")}`,a=new J(`float hashwithoutsine12(vec2 p)
1159
+ }`,[e])}}();var Uo=class extends be{constructor(e,r,o,n,a,s,l,c,u,d,p,f,h,m,y,g,b,w){super("v3");this.nodeType="Pattern";this.style=e,this.projection=r,this.axis=o,this.blending=n,this.offset=a,this.colorA=s,this.colorB=l,this.frequency=c,this.size=u,this.variation=d,this.smoothness=p,this.zigzag=f,this.rotation=h,this.vertical=m,this.horizontal=y,this.sides=g,this.isMask=w,this.alpha=b,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,r){if(e.isShader("fragment")){e.require("position"),e.require("uv"),e.requires.uv=[!0],e.require("normal"),e.requires.normal=!0,e.addFragmentVariable(this.calpha,"float");let o;switch(this.style.value){case 0:o="circle";break;case 1:o="ring";break;case 2:o="polygon";break;case 3:o="xcross";break;case 4:o="diamond";break;case 5:o="checkerboard";break;case 6:o="line";break;case 7:o="wave";break;default:o="circle";break}let n=`g${this.uuid.toString().replace(/-/g,"")}`,a=new J(`float hashwithoutsine12(vec2 p)
1160
1160
  {
1161
1161
  vec3 p3 = fract(vec3(p.xyx) * .1031);
1162
1162
  p3 += dot(p3, p3.yzx + 33.33);
@@ -1242,7 +1242,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
1242
1242
  accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));
1243
1243
 
1244
1244
  return clamp(color, 0.0, 1.0).rgb;
1245
- }`,[s,a,jo.DrawFunctions.circle,jo.DrawFunctions.ring,jo.DrawFunctions.polygon,jo.DrawFunctions.cross,jo.DrawFunctions.diamond,jo.DrawFunctions.checkerboard,jo.DrawFunctions.line,jo.DrawFunctions.wave]),u=e.include(c),d=[];return d.push("normal"),d.push(this.blending.build(e,"f")),d.push(this.style.build(e,"i")),d.push(this.offset.build(e,"v2")),d.push(this.colorA.build(e,"v4")),d.push(this.colorB.build(e,"v4")),d.push(this.frequency.build(e,"v2")),d.push(this.size.build(e,"f")),d.push(this.variation.build(e,"f")),d.push(this.smoothness.build(e,"f")),d.push(this.zigzag.build(e,"f")),d.push(this.rotation.build(e,"f")),d.push(this.vertical.build(e,"v2")),d.push(this.horizontal.build(e,"v2")),d.push(this.sides.build(e,"i")),d.push(this.isMask.build(e,"b")),d.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),d.push(this.alpha.build(e,"f")),d.push(this.calpha),e.format(u+"("+d.join(",")+")",this.getType(e),r)}else return console.warn("PatterNode is not compatible with "+e.shader+" shader."),e.format("vec3(0.0)",this.getType(e),r)}},Cs=jo;Cs.DrawFunctions=function(){let e=new J(`float hashwithoutsine12(vec2 p) {
1245
+ }`,[s,a,Uo.DrawFunctions.circle,Uo.DrawFunctions.ring,Uo.DrawFunctions.polygon,Uo.DrawFunctions.cross,Uo.DrawFunctions.diamond,Uo.DrawFunctions.checkerboard,Uo.DrawFunctions.line,Uo.DrawFunctions.wave]),u=e.include(c),d=[];return d.push("normal"),d.push(this.blending.build(e,"f")),d.push(this.style.build(e,"i")),d.push(this.offset.build(e,"v2")),d.push(this.colorA.build(e,"v4")),d.push(this.colorB.build(e,"v4")),d.push(this.frequency.build(e,"v2")),d.push(this.size.build(e,"f")),d.push(this.variation.build(e,"f")),d.push(this.smoothness.build(e,"f")),d.push(this.zigzag.build(e,"f")),d.push(this.rotation.build(e,"f")),d.push(this.vertical.build(e,"v2")),d.push(this.horizontal.build(e,"v2")),d.push(this.sides.build(e,"i")),d.push(this.isMask.build(e,"b")),d.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"1.0"),d.push(this.alpha.build(e,"f")),d.push(this.calpha),e.format(u+"("+d.join(",")+")",this.getType(e),r)}else return console.warn("PatterNode is not compatible with "+e.shader+" shader."),e.format("vec3(0.0)",this.getType(e),r)}},Cs=Uo;Cs.DrawFunctions=function(){let e=new J(`float hashwithoutsine12(vec2 p) {
1246
1246
  vec3 p3 = fract(vec3(p.xyx) * 0.1031);
1247
1247
  p3 += dot(p3, p3.yzx + 33.33);
1248
1248
  return fract((p3.x + p3.y) * p3.z);
@@ -1407,7 +1407,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
1407
1407
  float s = mix(size, size * rand, variation);
1408
1408
 
1409
1409
  return smoothstep(-smoothness, smoothness, distance_estimate - s * 0.5);
1410
- }`);return{tileAndCenter:r,circle:o,ring:n,polygon:a,cross:s,diamond:l,checkerboard:c,line:u,wave:d}}();var hh=class extends be{constructor(e,r,o,n,a,s,l,c){super("v3");this.nodeType="Rainbow";this.filmThickness=e,this.movement=r,this.wavelengths=o,this.noiseStrength=n,this.noiseScale=a,this.offset=s,this.isMask=c,this.alpha=l,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,r){if(e.require("vWorldViewDir"),e.require("worldNormal"),e.isShader("fragment")){e.require("uv"),e.requires.uv=[!0],e.addFragmentVariable(this.calpha,"float");let o=e.include(hh.Nodes.rainbow),n=[];return n.push(this.filmThickness.build(e,"f")),n.push(this.movement.build(e,"f")),n.push(this.wavelengths.build(e,"v3")),n.push(this.noiseStrength.build(e,"f")),n.push(this.noiseScale.build(e,"f")),n.push(this.offset.build(e,"v3")),n.push(this.isMask.build(e,"b")),n.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"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("RainbowNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),r)}},As=hh;As.Nodes=function(){let e=new J(`vec3 attenuation(vec3 wavelengths, float filmThickness, float movement, float noiseStrength, float noiseScale, vec3 offset) {
1410
+ }`);return{tileAndCenter:r,circle:o,ring:n,polygon:a,cross:s,diamond:l,checkerboard:c,line:u,wave:d}}();var mh=class extends be{constructor(e,r,o,n,a,s,l,c){super("v3");this.nodeType="Rainbow";this.filmThickness=e,this.movement=r,this.wavelengths=o,this.noiseStrength=n,this.noiseScale=a,this.offset=s,this.isMask=c,this.alpha=l,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,r){if(e.require("vWorldViewDir"),e.require("worldNormal"),e.isShader("fragment")){e.require("uv"),e.requires.uv=[!0],e.addFragmentVariable(this.calpha,"float");let o=e.include(mh.Nodes.rainbow),n=[];return n.push(this.filmThickness.build(e,"f")),n.push(this.movement.build(e,"f")),n.push(this.wavelengths.build(e,"v3")),n.push(this.noiseStrength.build(e,"f")),n.push(this.noiseScale.build(e,"f")),n.push(this.offset.build(e,"v3")),n.push(this.isMask.build(e,"b")),n.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"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("RainbowNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),r)}},As=mh;As.Nodes=function(){let e=new J(`vec3 attenuation(vec3 wavelengths, float filmThickness, float movement, float noiseStrength, float noiseScale, vec3 offset) {
1411
1411
  float f = 0.0;
1412
1412
 
1413
1413
  if (noiseStrength != 0.0) {
@@ -1431,7 +1431,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
1431
1431
  accumAlpha += (1.0 - accumAlpha) * lalpha * (1.0 - float(isMask));
1432
1432
 
1433
1433
  return res;
1434
- }`,[e])}}();var mh=class extends be{constructor(e,r,o,n,a,s,l,c,u,d){super("v3");this.nodeType="Toon";this.positioning=e,this.colors=r,this.steps=o,this.source=n,this.isWorldSpace=a,this.noiseStrength=s,this.noiseScale=l,this.shadowColor=c,this.offset=u,this.alpha=d,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,r){if(e.require("worldNormal"),e.require("worldPosition"),e.isShader("fragment")){e.define("COLORS_MAX",10),e.addFragmentVariable(this.calpha,"float");let o=e.include(mh.Nodes.toon),n=[];return n.push(this.positioning.build(e,"i")),n.push(this.colors.build(e,"v4[]")),n.push(this.steps.build(e,"f[]")),n.push(this.source.build(e,"v3")),n.push(this.isWorldSpace.build(e,"b")),n.push(this.noiseStrength.build(e,"f")),n.push(this.noiseScale.build(e,"f")),n.push(this.shadowColor.build(e,"v4")),n.push(this.offset.build(e,"v3")),n.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"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("ToonNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),r)}},Ms=mh;Ms.Nodes=function(){let e=new J(`float rand(float n) {
1434
+ }`,[e])}}();var yh=class extends be{constructor(e,r,o,n,a,s,l,c,u,d){super("v3");this.nodeType="Toon";this.positioning=e,this.colors=r,this.steps=o,this.source=n,this.isWorldSpace=a,this.noiseStrength=s,this.noiseScale=l,this.shadowColor=c,this.offset=u,this.alpha=d,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,r){if(e.require("worldNormal"),e.require("worldPosition"),e.isShader("fragment")){e.define("COLORS_MAX",10),e.addFragmentVariable(this.calpha,"float");let o=e.include(yh.Nodes.toon),n=[];return n.push(this.positioning.build(e,"i")),n.push(this.colors.build(e,"v4[]")),n.push(this.steps.build(e,"f[]")),n.push(this.source.build(e,"v3")),n.push(this.isWorldSpace.build(e,"b")),n.push(this.noiseStrength.build(e,"f")),n.push(this.noiseScale.build(e,"f")),n.push(this.shadowColor.build(e,"v4")),n.push(this.offset.build(e,"v3")),n.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"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("ToonNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),r)}},Ms=yh;Ms.Nodes=function(){let e=new J(`float rand(float n) {
1435
1435
  return fract(sin(n) * 43758.5453123);
1436
1436
  }`),r=new J(`float hash1(float p) {
1437
1437
  p = fract(p * 0.011);
@@ -1667,7 +1667,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
1667
1667
 
1668
1668
  return color.xyz;
1669
1669
 
1670
- }`,[or.simplexFast,e,o,a])}}();var yh=require("three");var Xb=function(){return{textureBicubic:new J(`float w0( float a ) {
1670
+ }`,[or.simplexFast,e,o,a])}}();var gh=require("three");var Yb=function(){return{textureBicubic:new J(`float w0( float a ) {
1671
1671
  return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );
1672
1672
  }
1673
1673
 
@@ -1731,7 +1731,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
1731
1731
  vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );
1732
1732
  vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );
1733
1733
  return mix( fSample, cSample, fract( lod ) );
1734
- }`)}}();function Yb(i,t){return i>=t?new yh.Vector2(t/i,1):new yh.Vector2(1,i/t)}var gh=class extends be{constructor(e,r,o,n,a,s,l,c){super("v3");this.nodeType="Transmission";this.thickness=e,this.ior=r,this.roughness=o,this.transmissionSamplerSize=n,this.transmissionSamplerMap=a,this.transmissionDepthMap=s,this.aspectRatio=l,this.alpha=c,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,r){if(e.extensions.shaderTextureLOD=!0,e.extensions.derivatives=!0,e.isShader("fragment")){e.define("NUM_SAMPLES",6),e.define("BLUR_SLOD",Math.pow(2,_e.transmissionLod.value)),e.require("worldPosition"),e.requires.worldNormal=!0,e.requires.modelMatrix=!0,e.requires.projectionMatrix=!0,e.addFragmentVariable(this.calpha,"float");let o=e.include(gh.Nodes.transmission),n=[];return n.push(this.thickness.build(e,"f")),n.push(this.ior.build(e,"f")),n.push(this.roughness.build(e,"f")),n.push(this.transmissionSamplerSize.build(e,"v2")),n.push(this.transmissionSamplerMap.getTexture(e,"t")),n.push(this.transmissionDepthMap.getTexture(e,"t")),n.push(this.aspectRatio.build(e,"v2")),n.push("normal"),n.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"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("TransmissionNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),r)}},Is=gh;Is.Nodes=function(){let e=new J(`vec3 blur(sampler2D sp, vec2 U, vec2 scale, float lod, sampler2D dm, vec2 unrefractedU, vec2 aspectRatio) {
1734
+ }`)}}();function Kb(i,t){return i>=t?new gh.Vector2(t/i,1):new gh.Vector2(1,i/t)}var xh=class extends be{constructor(e,r,o,n,a,s,l,c){super("v3");this.nodeType="Transmission";this.thickness=e,this.ior=r,this.roughness=o,this.transmissionSamplerSize=n,this.transmissionSamplerMap=a,this.transmissionDepthMap=s,this.aspectRatio=l,this.alpha=c,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,r){if(e.extensions.shaderTextureLOD=!0,e.extensions.derivatives=!0,e.isShader("fragment")){e.define("NUM_SAMPLES",6),e.define("BLUR_SLOD",Math.pow(2,_e.transmissionLod.value)),e.require("worldPosition"),e.requires.worldNormal=!0,e.requires.modelMatrix=!0,e.requires.projectionMatrix=!0,e.addFragmentVariable(this.calpha,"float");let o=e.include(xh.Nodes.transmission),n=[];return n.push(this.thickness.build(e,"f")),n.push(this.ior.build(e,"f")),n.push(this.roughness.build(e,"f")),n.push(this.transmissionSamplerSize.build(e,"v2")),n.push(this.transmissionSamplerMap.getTexture(e,"t")),n.push(this.transmissionDepthMap.getTexture(e,"t")),n.push(this.aspectRatio.build(e,"v2")),n.push("normal"),n.push(this.mask?`luminance(${this.mask.flow(e,"v3").result})`:"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("TransmissionNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),r)}},Is=xh;Is.Nodes=function(){let e=new J(`vec3 blur(sampler2D sp, vec2 U, vec2 scale, float lod, sampler2D dm, vec2 unrefractedU, vec2 aspectRatio) {
1735
1735
  // Slightly modified version of this:
1736
1736
  // https://www.shadertoy.com/view/ltScRG
1737
1737
 
@@ -1791,7 +1791,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
1791
1791
  float lod = applyIorToRoughness(roughness, ior);
1792
1792
  return blur(transmissionSamplerMap, fragCoord, vec2(lod), min(framebufferLod / 5.5, 8.5), transmissionDepthMap, unrefractedCoords, aspectRatio);
1793
1793
  #endif
1794
- }`,[Xb.textureBicubic,o,e]),a=new J(`vec3 getIBLVolumeRefraction( vec3 n, vec3 v, float roughness, vec3 position, mat4 modelMatrix, mat4 viewMatrix, mat4 projMatrix, float ior, float thickness, vec2 transmissionSamplerSize, sampler2D transmissionSamplerMap, sampler2D transmissionDepthMap, vec2 aspectRatio ) {
1794
+ }`,[Yb.textureBicubic,o,e]),a=new J(`vec3 getIBLVolumeRefraction( vec3 n, vec3 v, float roughness, vec3 position, mat4 modelMatrix, mat4 viewMatrix, mat4 projMatrix, float ior, float thickness, vec2 transmissionSamplerSize, sampler2D transmissionSamplerMap, sampler2D transmissionDepthMap, vec2 aspectRatio ) {
1795
1795
  vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );
1796
1796
  vec3 refractedRayExit = position + transmissionRay;
1797
1797
 
@@ -1822,7 +1822,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
1822
1822
  accumAlpha += ( 1.0 - accumAlpha ) * alpha;
1823
1823
 
1824
1824
  return transmission;
1825
- }`,[a])}}();var xh=(e=>(e.NOISE="noise",e.MAP="map",e))(xh||{}),bh=class extends be{constructor(e,r,o,n,a,s,l,c,u,d,p){super("v3");this.displacementTypeIndex=new je(0);this.nodeType="VertexDisplacement";this.intensity=e,this.movementOrTexture=r,Object.values(xh)[this.displacementTypeIndex.value]==="map"&&(this.mat=new ys(this.movementOrTexture.value.matrix)),this.cropOrOffset=o,this.scale=d,this.noiseFunctionIndex=p,this.voronoiStyle=n,this.smoothness=a,this.seed=s,this.highCut=l,this.lowCut=c,this.quality=u}generate(e,r){if(e.isShader("vertex")){e.define("USE_LAYER_DISPLACE");let o,n=[];switch(n.push("displaced_position"),n.push("displaced_normal"),Object.values(xh)[this.displacementTypeIndex.value]){case"map":{o=e.include(bh.Nodes.map),n.push(this.movementOrTexture.getTexture(e,"t")),n.push("uv"),n.push(this.cropOrOffset.build(e,"f")),this.mat&&n.push(this.mat.build(e,"mat3"));break}case"noise":{let l=["simplexPrecise","simplexFractal","simplexAshima","fbm","perlin","voronoi"][this.noiseFunctionIndex.value],c=new J(`vec3 orthogonal(vec3 v) {
1825
+ }`,[a])}}();var bh=(e=>(e.NOISE="noise",e.MAP="map",e))(bh||{}),vh=class extends be{constructor(e,r,o,n,a,s,l,c,u,d,p){super("v3");this.displacementTypeIndex=new je(0);this.nodeType="VertexDisplacement";this.intensity=e,this.movementOrTexture=r,Object.values(bh)[this.displacementTypeIndex.value]==="map"&&(this.mat=new ys(this.movementOrTexture.value.matrix)),this.cropOrOffset=o,this.scale=d,this.noiseFunctionIndex=p,this.voronoiStyle=n,this.smoothness=a,this.seed=s,this.highCut=l,this.lowCut=c,this.quality=u}generate(e,r){if(e.isShader("vertex")){e.define("USE_LAYER_DISPLACE");let o,n=[];switch(n.push("displaced_position"),n.push("displaced_normal"),Object.values(bh)[this.displacementTypeIndex.value]){case"map":{o=e.include(vh.Nodes.map),n.push(this.movementOrTexture.getTexture(e,"t")),n.push("uv"),n.push(this.cropOrOffset.build(e,"f")),this.mat&&n.push(this.mat.build(e,"mat3"));break}case"noise":{let l=["simplexPrecise","simplexFractal","simplexAshima","fbm","perlin","voronoi"][this.noiseFunctionIndex.value],c=new J(`vec3 orthogonal(vec3 v) {
1826
1826
  return normalize(abs(v.x) > abs(v.z) ? vec3(-v.y, v.x, 0.0) : vec3(0.0, -v.z, v.y));
1827
1827
  }`),u=l=="voronoi"?`
1828
1828
  float v = ${l}((p + offset) * scale * 0.001 + neighbour_offset + (movement * 0.1), voronoiStyle, smoothness, seed, quality);
@@ -1851,7 +1851,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
1851
1851
  vec3 distorted2 = distorted(nearby2, normal, scale, intensity, offset, neighbor_offset, movement, voronoiStyle, smoothness, seed, highCut, lowCut, quality);
1852
1852
  displaced_normal = normalize(cross(distorted1 - displaced_position, distorted2 - displaced_position));
1853
1853
  return displaced_position;
1854
- }`,[d,c]);o=e.include(p),n.push(this.scale.build(e,"f")),n.push(this.cropOrOffset.build(e,"v3")),n.push(this.movementOrTexture.build(e,"f")),n.push(this.voronoiStyle.build(e,"i")),n.push(this.smoothness.build(e,"f")),n.push(this.seed.build(e,"f")),n.push(this.highCut.build(e,"f")),n.push(this.lowCut.build(e,"f")),n.push(this.quality.build(e,"i"));break}}return n.push(this.intensity.build(e,"f")),n.push("displaced_normal"),e.format(o+"("+n.join(",")+")",this.getType(e),r)}else return console.warn("VertexDisplacementNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),r)}},Es=bh;Es.Nodes=function(){let e=new J(`vec3 orthogonal(vec3 v) {
1854
+ }`,[d,c]);o=e.include(p),n.push(this.scale.build(e,"f")),n.push(this.cropOrOffset.build(e,"v3")),n.push(this.movementOrTexture.build(e,"f")),n.push(this.voronoiStyle.build(e,"i")),n.push(this.smoothness.build(e,"f")),n.push(this.seed.build(e,"f")),n.push(this.highCut.build(e,"f")),n.push(this.lowCut.build(e,"f")),n.push(this.quality.build(e,"i"));break}}return n.push(this.intensity.build(e,"f")),n.push("displaced_normal"),e.format(o+"("+n.join(",")+")",this.getType(e),r)}else return console.warn("VertexDisplacementNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),r)}},Es=vh;Es.Nodes=function(){let e=new J(`vec3 orthogonal(vec3 v) {
1855
1855
  return normalize(abs(v.x) > abs(v.z) ? vec3(-v.y, v.x, 0.0) : vec3(0.0, -v.z, v.y));
1856
1856
  }`),r=new J(`float displacementMapTexture(sampler2D tex, float crop, vec2 uv, mat3 mat, vec2 offset) {
1857
1857
  vec2 uvs = (mat * vec3(uv * 2.0 - 1.0, 1.0) / 2.0 + 0.5).xy + offset;
@@ -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 _e={normalRenderTarget:new gr,normalRenderTargetDepth:new gr,transmissionRenderTarget:new gr,aspectRatio:new Ot,transmissionSize:new Ot(2048,2048),transmissionRenderTargetDepth:new gr,aoRenderTarget:new gr,aoEnabled:new Tt,pixelRatioNode:new se(1),resolution:new Ot,penumbraSize:new bo(5,.5),frameIndex:new je(0),transmissionLod:new je(2),taaEnabled:new Tt(!0)};for(let i of Object.values(_e))i.isRenderGlobal=!0;var Kb={skiaWasmUrl:"https://unpkg.com/@splinetool/ui-wasm@1.12.42/build/ui.wasm"};var yi=class extends ot{constructor(){super("basic");this.nodeType="Basic";this.color=new et(Bt),this.shadingAlpha=new se(1),this.shadingBlend=new je(0),this.previousModelViewMatrix=new sr,this.previouseProjectionMatrix=new sr}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:_e.frameIndex}),e.mergeUniform({resolution:_e.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(xd.UniformsUtils.merge([xd.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 _e={normalRenderTarget:new gr,normalRenderTargetDepth:new gr,transmissionRenderTarget:new gr,aspectRatio:new Ot,transmissionSize:new Ot(2048,2048),transmissionRenderTargetDepth:new gr,aoRenderTarget:new gr,aoEnabled:new Tt,pixelRatioNode:new se(1),resolution:new Ot,penumbraSize:new bo(5,.5),frameIndex:new je(0),transmissionLod:new je(2),taaEnabled:new Tt(!0)};for(let i of Object.values(_e))i.isRenderGlobal=!0;var Qb={skiaWasmUrl:"https://unpkg.com/@splinetool/ui-wasm@1.12.44/build/ui.wasm"};var yi=class extends ot{constructor(){super("basic");this.nodeType="Basic";this.color=new et(Bt),this.shadingAlpha=new se(1),this.shadingBlend=new je(0),this.previousModelViewMatrix=new sr,this.previouseProjectionMatrix=new sr}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:_e.frameIndex}),e.mergeUniform({resolution:_e.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(bd.UniformsUtils.merge([bd.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>
@@ -2282,11 +2282,11 @@ 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&&p.push(c.code,`outgoingLight = spe_blend(outgoingLight, ${c.result}, 1.0, SPE_BLENDING_NORMAL);`),u?p.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${u.result} );`):p.push("gl_FragColor = vec4( outgoingLight, 1.0 );"),d&&p.push(`gl_FragColor.a *= ${d.result};`),p.push("#include <encodings_fragment>","#include <fog_fragment>","#include <dithering_fragment>"),r=p.join(`
2285
- `)}return r}};var wd=require("three");var bd=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 Sh=class extends bd{create(t){return URL.createObjectURL(new Blob([t]))}dispose(t,e){URL.revokeObjectURL(e)}},vh;function Qb(i){return typeof i=="string"?i:(vh||(vh=new Sh),vh.load(i))}var vd=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")}},Sd=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 Ds=class extends vd{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=Qb(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 wd.VideoTexture(this.img,void 0,e,e):a=new wd.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 Vr=class extends Ds{};var ft=require("three");function lr(i,t){return t.color(i)}function Zb(i,t){switch(i.type){case"fresnel":return n3(i,t);case"gradient":return a3(i,t);case"depth":return s3(i,t);case"normal":return l3(i,t);case"noise":return c3(i,t);case"rainbow":return u3(i,t);case"toon":return d3(i,t);case"outline":return p3(i,t);case"transmission":return f3(i,t);case"pattern":return h3(i,t);case"color":default:return i3(i,t)}}function o3(i){return{type:i.type}}function So(i,t){let{alpha:e,mode:r,isMask:o}=i,n=typeof e=="string"?(Number(t.getVariable(e))??100)/100:e;return{...o3(i),alpha:n,mode:r,isMask:o}}function i3(i,t){return{...So(i,t),color:lr(i.color,t)}}function n3(i,t){let{bias:e,scale:r,intensity:o,factor:n,color:a}=i;return{...So(i,t),color:lr(a,t),bias:e,scale:r,intensity:o,factor:n}}function a3(i,t){let{gradientType:e,smooth:r,colors:o,steps:n,angle:a,offset:s,morph:l}=i;return{...So(i,t),gradientType:e,smooth:r,colors:o.map(c=>new ft.Vector4(c[0],c[1],c[2],c[3])),num:o.length,steps:n,offset:new ft.Vector2(...s.map(c=>typeof c=="number"?c:0)),morph:new ft.Vector2(...l.map(c=>typeof c=="number"?c:0)),angle:a}}function s3(i,t){let{gradientType:e,near:r,far:o,isVector:n,isWorldSpace:a,origin:s,direction:l,colors:c,steps:u,smooth:d}=i;return{...So(i,t),gradientType:e,near:r,far:o,isVector:n,isWorldSpace:a,origin:new ft.Vector3(...s),direction:l?new ft.Vector3(...l):new ft.Vector3(1,0,0),colors:c.map(p=>p!==void 0?new ft.Vector4(p[0],p[1],p[2],p[3]):new ft.Vector4(0,0,0,0)),steps:u.slice(0,c.length),smooth:d}}function l3(i,t){let{cnormal:e}=i;return{...So(i,t),cnormal:new ft.Vector3(e[0],e[1],e[2])}}function c3(i,t){return{...So(i,t),scale:i.scale,move:i.move,fA:new ft.Vector2(...i.fA.map(e=>typeof e=="number"?e:0)),fB:new ft.Vector2(...i.fB.map(e=>typeof e=="number"?e:0)),size:new ft.Vector3(...i.size),distortion:new ft.Vector2(...i.distortion.map(e=>typeof e=="number"?e:0)),colorA:lr(i.colorA,t),colorB:lr(i.colorB,t),colorC:lr(i.colorC,t),colorD:lr(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 u3(i,t){return{...So(i,t),filmThickness:i.filmThickness,movement:i.movement,wavelengths:new ft.Vector3(...i.wavelengths),noiseStrength:i.noiseStrength,noiseScale:i.noiseScale,offset:new ft.Vector3(...i.offset)}}function d3(i,t){return{...So(i,t),positioning:i.positioning,colors:i.colors.map(e=>new ft.Vector4(e[0],e[1],e[2],e[3])),num:i.colors.length,steps:i.steps,source:new ft.Vector3(...i.source),isWorldSpace:i.isWorldSpace,noiseStrength:i.noiseStrength,noiseScale:i.noiseScale,shadowColor:lr(i.shadowColor,t),offset:new ft.Vector3(...i.offset)}}function p3(i,t){return{...So(i,t),outlineColor:lr(i.outlineColor,t),contourColor:lr(i.contourColor,t),outlineWidth:i.outlineWidth,contourWidth:i.contourWidth,outlineThreshold:i.outlineThreshold,contourThreshold:i.contourThreshold,outlineSmoothing:i.outlineSmoothing,contourFrequency:i.contourFrequency,contourDirection:new ft.Vector3(...i.contourDirection),positionalLines:i.positionalLines,compensation:i.compensation}}function f3(i,t){return{...So(i,t),thickness:i.thickness,ior:i.ior,roughness:i.roughness}}function h3(i,t){return{...So(i,t),style:i.style,projection:i.projection,axis:i.axis,blending:i.blending,offset:new ft.Vector2(...i.offset.map(e=>typeof e=="number"?e:0)),colorA:lr(i.colorA,t),colorB:lr(i.colorB,t),frequency:new ft.Vector2(...i.frequency.map(e=>typeof e=="number"?e:0)),size:i.size,variation:i.variation,smoothness:i.smoothness,zigzag:i.zigzag,rotation:i.rotation,vertical:new ft.Vector2(...i.vertical.map(e=>typeof e=="number"?e:0)),horizontal:new ft.Vector2(...i.horizontal.map(e=>typeof e=="number"?e:0)),sides:i.sides}}var Zi=class extends qt{};var Pd=require("three");var m3={noise:["noiseType"],texture:["projection","axis","side"],video:["projection","axis","side"],displace:["noiseType"],light:["roughnessMap","bumpMap"],depth:["smooth","isWorldSpace","gradientType","isVector"],pattern:["style","projection","axis"]},y3={depth:["colors"]};function g3(i,t,e){if(t==="isMask")return!0;let r=m3[i.type],o=y3[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 wh(i,t){if(Array.isArray(t)){if(!Array.isArray(i)||i.length!==t.length)return!1;for(let[o,n]of t.entries()){let a=i[o];if(typeof n=="string"||typeof n=="number"&&typeof a=="string")return!0}return!1}let e=typeof i=="string",r=typeof t=="string";return e!==r||e&&r}function tc(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 Vr||l.image.deref(),l.image=s}if("video"in n){let a=n.video,s=t.video(a),l=r;l.image instanceof Vr||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=(Pe(n.rotation??0,t)??0)*Pd.MathUtils.DEG2RAD,o;if("repeat"in n||"offset"in n||"rotation"in n){let a="mat",s=e.uniforms[`f${e.id}_${a}`];if(!s)return o;if("repeat"in n){let l=n.repeat;wh(e.data.texture.repeat,l)&&(o=!0),s.repeat=_s(l,t).map((c,u)=>typeof l[u]=="string"?1/c:c)}if("offset"in n){let l=n.offset;wh(e.data.texture.offset,l)&&(o=!0),s.offset=_s(l,t).map((c,u)=>typeof l[u]=="string"?-c:c)}if("rotation"in n){let l=e.data.texture.rotation,c=n.rotation??0;(l===void 0||wh(l,c))&&(o=!0),s.rotation=Pe(c,t)??0}s.updateMatrix()}return o}function Jb(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(Ph(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 Ki))switch(o=o||g3(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 Zi?s.value=new qt(l.r,l.g,l.b,l.a):s.setRGBA(l);break}case Cr:if(typeof a=="string"){let l=t.getColor(a);l&&(s.value=l);break}else{let l=a;s.value instanceof Zi?s.value=new qt(l.r,l.g,l.b,l.a):s.value.setRGBA(l.r,l.g,l.b,l.a);break}case Ot:{let l=a;s.value.setX(l[0]),s.value.setY(l[1]);break}case ar:{let l=a;s.value.setX(l[0]),s.value.setY(l[1]),s.value.setZ(l[2]);break}case gr:{tc(a,t,e);break}case vo:{s.value=a.map(l=>new Pd.Vector4(...l));break}default:{s.value=a;break}}}return o}var en=(i,t,e)=>Math.max(0,Math.min(1,Number(t.getVariable(typeof i=="number"?i*100:i,e)??100)/100))??1,Pe=(i,t,e)=>typeof i=="number"?i:t.getVariable(i,e),Ji=(i,t)=>(i||(i=new ct.Vector3),i.x=Pe(i.x,t)??0,i.y=Pe(i.y,t)??0,i.z=Pe(i.z,t)??0,i),xi=(i,t)=>(i||(i=new ct.Vector2),i.x=Pe(i.x,t)??0,i.y=Pe(i.y,t)??0,i),_s=(i,t)=>{let e=i.map(r=>Pe(r,t)??0);return[e[0],e[1]]},tn=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)Ph(a,this,r,n)}get type(){return this.data.type}static create(t,e,r,o){if(r.type==="light")return xr.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 Fn(n,r.texture.wrapping,r.texture.minFilter??1008,r.texture.magFilter??1006),s=new yd(n),l=new gd(_s(r.texture.repeat,o),_s(r.texture.offset,o),Pe(r.texture.rotation??0,o)),c=new se(r.crop?1:0),u=new je(r.projection??0),d=new je(["x","y","z"].indexOf(r.axis)??0),p=new je(r.side??0),f=new Ot(r.size?new ct.Vector2(..._s(r.size,o)):new ct.Vector2(100,100)),h=new se(r.blending??0),m=new se(en(r.alpha,o)),y=new je(r.mode??0),g=new Tt(r.isMask??!1),b=new Qi(a,s,c,u,d,p,f,h,l,m,y,g),w=new Qe(b.calpha,"f");return new gt(t,e,r,{texture:a,textureSize:s,crop:c,projection:u,axis:d,side:p,size:f,blending:h,mat:l,alpha:m,mode:y,isMask:g},b,y,w,g,o)}else if(r.type==="matcap"){let n=o.image(r.texture.image),a=new Fn(n,r.texture.wrapping,r.texture.minFilter??1008,r.texture.magFilter??1006),s=new se(en(r.alpha,o)),l=new je(r.mode??0),c=new Tt(r.isMask??!1),u=new se((Pe(r.texture.rotation??0,o)??0)*ct.MathUtils.DEG2RAD),d=new Ps(a,s,l,c,u),p=new Qe(d.calpha,"f");return new gt(t,e,r,{texture:a,alpha:s,mode:l,isMask:c,rotation:u},d,l,p,c,o)}else if(r.type==="displace")if(r.displacementType==="noise"){let n=new ar(new ct.Vector3(...r.offset.map(g=>Pe(g,o)??0))),a=new se(Pe(r.scale,o)??10),s=new se(Pe(r.intensity,o)??8),l=new se(Pe(r.movement,o)??1),c=new je(r.noiseType??0),u=new je(r.voronoiStyle??0),d=new se(Pe(r.smoothness,o)??.5),p=new se(Pe(r.seed,o)??0),f=new se(Pe(r.highCut,o)??1),h=new se(Pe(r.lowCut,o)??0),m=new je(Pe(r.quality,o)??1),y=new Es(s,l,n,u,d,p,f,h,m,a,c);return new rc(t,e,r,{offset:n,scale:a,intensity:s,movement:l,noiseType:c,voronoiStyle:u,smoothness:d,seed:p,highCut:f,lowCut:h,quality:m},y,o)}else throw new Error;else return v3(t,e,r,o)}updateByOp(t,e,r){let o=t,n=!1;if(o.path[0]===void 0){for(let a of Object.keys(o.props))try{let s=this.data[a],l=e[a];if(Array.isArray(s)&&Array.isArray(l)){for(let[c,u]of l.entries()){let d=s[c];if(typeof u=="string"||typeof u=="number"&&typeof d=="string"){n=!0;break}}if(n)break}else if(typeof l=="string"&&typeof s=="number"||typeof l=="number"&&typeof s=="string"||typeof l=="string"&&typeof s=="string"&&l!==s){n=!0;break}}catch(s){console.error(s)}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):Jb(o.props,r.shared,this,e)||n}else if(o.path[0]==="texture")return"texture"in e||"video"in e?tc(o.props,r.shared,this)||n:!0;return n}dispose(){if(x3(this)){let t=this.uniforms[`f${this.id}_texture`];if(!t)return!1;let e=t;e.image instanceof Vr||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}},gt=class extends tn{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}},rc=class extends tn{constructor(e,r,o,n,a,s){super(e,r,o,n,s);this.position=a}},xr=class extends tn{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(en(o.alpha,n)),l=new je(o.mode),c=new se(o.bumpMapIntensity),u=new se(en(o.alphaOverride,n)),d;if(!o.visible)a=new yi,d={};else if(o.category==="lambert"){a=new Yl;let p=new et(n.color(o.emissive)??0),f=new Tt(o.occlusion??!0);d={emissive:p,occlusion:f},a.emissive=p,a.occlusion=f}else if(o.category==="toon"){a=new ec;let p=new se(o.shininess??30),f=new et(n.color(o.specular)??1118481);d={shininess:p,specular:f},a.shininess=p,a.specular=f}else if(o.category==="physical"){a=new Zl;let p=new se(o.roughness??.3),f=new se(o.metalness??0),h=new se(o.reflectivity??.5),m=new Tt(o.occlusion??!0);d={roughness:p,metalness:f,reflectivity:h,occlusion:m},a.roughness=p,a.metalness=f,a.reflectivity=h,a.occlusion=m}else{a=new Ql;let p=new se(o.shininess??30),f=new et(o.specular!==void 0?n.color(o.specular)??1118481:1118481),h=new Tt(o.occlusion??!0);d={shininess:p,specular:f,occlusion:h},a.shininess=p,a.specular=f,a.occlusion=h}return a.alpha=new se(1),a.shadingAlpha=s,a.shadingBlend=l,a.bumpMapIntensity=c,a.alphaOverride=u,d.alpha=a.shadingAlpha,d.mode=a.shadingBlend,d.bumpMapIntensity=a.bumpMapIntensity,d.alphaOverride=a.alphaOverride,new xr(e,r,o,a,d,n)}get category(){return this.node.category}};function x3(i){let t=i instanceof tn?i.type:i;return t==="texture"||t==="video"||t==="displace_map"||t==="matcap"}function Yr(i){return{alpha:new se(i.alpha??1),mode:new je(i.mode??0),isMask:new Tt(i.isMask??!1)}}function b3(i,t,e,r,o){switch(i.type){case"color":{let n=new et(r.color??Bt),a=Yr(r),s=new jn(n,a.alpha),l=new Qe(s.calpha,"f");return new gt(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(Pe(r.bias,o)??.1),s=new se(Pe(r.scale,o)??1),l=new se(Pe(r.intensity,o)??2),c=new se(Pe(r.factor,o)??1),u=Yr(r),d=new $l(n,a,s,l,c,u.alpha,u.mode,u.isMask),p=new Qe(d.calpha,"f");return new gt(t,e,i,{color:n,bias:a,scale:s,intensity:l,factor:c,...u},d,u.mode,p,u.isMask,o)}case"rainbow":{let n=new se(Pe(r.filmThickness,o)??30),a=new se(Pe(r.movement,o)??0),s=new ar(Ji(r.wavelengths,o)),l=new se(Pe(r.noiseStrength,o)??0),c=new se(Pe(r.noiseScale,o)??1),u=new ar(Ji(r.offset,o)),d=Yr(r),p=new As(n,a,s,l,c,u,d.alpha,d.isMask),f=new Qe(p.calpha,"f");return new gt(t,e,i,{filmThickness:n,movement:a,wavelengths:s,noiseStrength:l,noiseScale:c,offset:u,...d},p,d.mode,f,d.isMask,o)}case"transmission":{let n=new se(Pe(r.thickness??10,o)),a=new se(Pe(r.ior??1.5,o)),s=new se(Pe(r.roughness??.5,o)),l=_e.transmissionSize,c=_e.transmissionRenderTarget,u=_e.transmissionRenderTargetDepth,d=window.innerWidth,p=window.innerHeight,f=d>=p?new Ot(p/d,1):new Ot(1,d/p),h=Yr(r),m=new Is(n,a,s,l,c,u,f,h.alpha),y=new Qe(m.calpha,"f");return new gt(t,e,i,{thickness:n,ior:a,roughness:s,aspectRatio:f,...h},m,h.mode,y,h.isMask,o)}case"toon":{let n=new je(r.positioning??0),a;r.colors?a=new vo(r.colors.length,r.colors):(a=new vo(10,new ct.Vector4(0,0,0,1)),a.value[1]=new ct.Vector4(1,1,1,1));let s;r.steps?s=new bo(r.steps.length,r.steps):(s=new bo(10,1),s.value[0]=0);let l=new ar(Ji(r.source??new ct.Vector3(0,0,0),o)),c=new Tt(r.isWorldSpace??!0),u=new se(Pe(r.noiseStrength??0,o)),d=new se(Pe(r.noiseScale??1,o)),p=new Cr(r.shadowColor),f=new ar(Ji(r.offset??new ct.Vector3(0,0,0),o)),h=Yr(r),m=new Ms(n,a,s,l,c,u,d,p,f,h.alpha),y=new Qe(m.calpha,"f");return new gt(t,e,i,{positioning:n,colors:a,steps:s,source:l,isWorldSpace:c,noiseStrength:u,noiseScale:d,shadowColor:p,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(Pe(r.outlineWidth??.1,o)),l=new se(Pe(r.contourWidth??.1,o)),c=new se(Pe(r.outlineThreshold??.1,o)),u=new se(Pe(r.contourThreshold??.1,o)),d=new se(Pe(r.outlineSmoothing??.1,o)),p=new se(Pe(r.contourFrequency??.1,o)),f=new ar(Ji(r.contourDirection??new ct.Vector3(0,1,0),o)),h=new Tt(r.positionalLines??!1),m=new Tt(r.compensation??!0),y=_e.normalRenderTarget,g=_e.normalRenderTargetDepth,b=_e.pixelRatioNode,w=_e.resolution,P=Yr(r),S=new Ts(n,a,s,l,c,u,d,p,f,h,m,w,y,g,b,P.alpha),T=new Qe(S.calpha,"f");return new gt(t,e,i,{outlineColor:n,contourColor:a,outlineWidth:s,contourWidth:l,outlineThreshold:c,contourThreshold:u,outlineSmoothing:d,contourFrequency:p,contourDirection:f,positionalLines:h,compensation:m,...P},S,P.mode,T,P.isMask,o)}case"depth":{let n=new je(r.gradientType??0),a=new Tt(r.smooth??!1),s=new se(Pe(r.near,o)??50),l=new se(Pe(r.far,o)??200),c=new se(r.isVector??1),u=new se(r.isWorldSpace??0),d=new ar(Ji(r.origin,o)),p=new ar(Ji(r.direction,o)),f;r.colors?f=new vo(r.colors.length,r.colors):(f=new vo(2,new ct.Vector4(0,0,0,1)),f.value[1]=new ct.Vector4(1,1,1,1));let h;r.steps?h=new bo(r.steps.length,r.steps):(h=new bo(2,1),h.value[0]=0);let m=Yr(r),y=new Ss(n,a,s,l,c,u,d,p,f,h,m.alpha,m.isMask),g=new Qe(y.calpha,"f");return new gt(t,e,i,{gradientType:n,smooth:a,near:s,far:l,isVector:c,isWorldSpace:u,origin:d,direction:p,colors:f,steps:h,...m},y,m.mode,g,m.isMask,o)}case"noise":{let n=new se(Pe(r.scale,o)??1),a=new ar(Ji(r.size??new ct.Vector3(100,100,100),o)),s=new se(Pe(r.move,o)??1),l=new Ot(xi(r.fA??new ct.Vector2(1.7,9.2),o)),c=new Ot(xi(r.fB??new ct.Vector2(8.3,2.8),o)),u=new Ot(xi(r.distortion??new ct.Vector2(1,1),o)),d=new Cr(r.colorA),p=new Cr(r.colorB),f=new Cr(r.colorC),h=new Cr(r.colorD),m=new je(r.noiseType??0),y=new je(r.voronoiStyle??0),g=new se(Pe(r.highCut,o)??1),b=new se(Pe(r.lowCut,o)??0),w=new se(Pe(r.smoothness,o)??.5),P=new se(Pe(r.seed,o)??.5),S=new je(r.quality??1),T=Yr(r),A=new Os(n,a,s,l,c,u,d,p,f,h,T.alpha,m,T.isMask,y,g,b,w,P,S),x=new Qe(A.calpha,"f");return new gt(t,e,i,{scale:n,size:a,move:s,fA:l,fB:c,distortion:u,colorA:d,colorB:p,colorC:f,colorD:h,noiseType:m,...T,voronoiStyle:y,highCut:g,lowCut:b,smoothness:w,seed:P,quality:S},A,T.mode,x,T.isMask,o)}case"normal":{let n=new ar(r.cnormal??new ct.Vector3(1,1,1)),a=Yr(r),s=new xs(n,a.alpha),l=new Qe(s.calpha,"f");return new gt(t,e,i,{cnormal:n,...a},s,a.mode,l,a.isMask,o)}case"gradient":{let n=new je(r.gradientType??0),a=new Tt(r.smooth??!1),s;r.colors?s=new vo(r.colors.length,r.colors):(s=new vo(10,new ct.Vector4(0,0,0,1)),s.value[1]=new ct.Vector4(1,1,1,1));let l;r.steps?l=new bo(r.steps.length,r.steps):(l=new bo(10,1),l.value[0]=0);let c=new Ot(xi(r.offset??new ct.Vector2(0,0),o)),u=new Ot(xi(r.morph??new ct.Vector2(0,0),o)),d=new se(Pe(r.angle??0,o)),p=Yr(r),f=new ws(n,a,s,l,c,u,d,p.alpha,p.isMask),h=new Qe(f.calpha,"f");return new gt(t,e,i,{gradientType:n,smooth:a,colors:s,steps:l,offset:c,morph:u,angle:d,...p},f,p.mode,h,p.isMask,o)}case"pattern":{let n=new je(r.style??0),a=new je(r.projection??0),s=new je(["x","y","z"].indexOf(r.axis)??0),l=new se(Pe(r.blending??0,o)),c=new Ot(xi(r.offset,o)),u=new Cr(r.colorA),d=new Cr(r.colorB),p=new Ot(xi(r.frequency??new ct.Vector2(10,10),o)),f=new se(Pe(r.size??.5,o)),h=new se(Pe(r.variation??0,o)),m=new se(Pe(r.smoothness??.5,o)),y=new se(Pe(r.zigzag??0,o)),g=new se(Pe(r.rotation??0,o)),b=new Ot(xi(r.vertical??new ct.Vector2(0,1),o)),w=new Ot(xi(r.horizontal??new ct.Vector2(0,1),o)),P=new je(r.sides??6),S=Yr(r),T=new Cs(n,a,s,l,c,u,d,p,f,h,m,y,g,b,w,P,S.alpha,S.isMask),A=new Qe(T.calpha,"f");return new gt(t,e,i,{style:n,projection:a,axis:s,blending:l,offset:c,colorA:u,colorB:d,frequency:p,size:f,variation:h,smoothness:m,zigzag:y,rotation:g,vertical:b,horizontal:w,sides:P,...S},T,S.mode,A,S.isMask,o)}default:{let n=new et(1,0,0,1),a=Yr(r),s=new jn(n,a.alpha),l=new Qe(s.calpha,"f");return new gt(t,e,i,{color:n,...a},s,a.mode,l,a.isMask,o)}}}function v3(i,t,e,r){let o=Zb(e,r);return b3(e,i,t,o,r)}function Ph(i,t,e,r){if(e.type==="displace"&&(i==="intensity"||i==="visible")){let o=t.uniforms[`f${t.id}_intensity`];return o?(o.value=(Pe(e.intensity,r)??1)*(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=en(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 Mr(i,t,e,r,o,n,a=[]){let s=e;for(let l of a)l in s&&(s=s[l]);for(let l of i)l in s&&o.getVariable(s[l],["material",n,"layer",r,...a,String(l)]);for(let l of t)l in s&&s[l].forEach((c,u)=>{o.getVariable(c,["material",n,"layer",r,...a,String(l),u===0?"x":u===1?"y":"z"])})}function Od(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 Ir=class extends Cd.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""}},Td=class extends Ir{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()}},kn=class extends Ir{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 Td(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??Wt.defaultTwoLayerData("phong").layers;try{this.layers=o.map(n=>tn.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=Od(e,r.shared),this.saveVariableLocations(r)}onVariableUpdate(e,r,o){if(e[0]==="alphaOverride")this.transparent=Od(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);if(s?.hasValue(a))if(a==="alpha")this.transparent=Od(this.data,o.shared),s.setValue(a,Math.max(0,Math.min(Number(r)/100,1)));else{let l=s.getValue(a),c=e[3],u=e[4];if(l instanceof Cd.Texture){let d=l[c],p;typeof d=="number"?p=Number(r):d.isVector2&&(p=d.toArray(),u==="x"?p[0]=Number(r):u==="y"&&(p[1]=Number(r))),tc({[c]:p},o.shared,s);return}(c==="x"||c==="y"||c==="z")&&l.isVector3||(c==="x"||c==="y")&&l.isVector2?l[c]=Number(r):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"]),o.data.type==="displace"?o.data.displacementType==="noise"?Mr(["intensity","scale","movement","smoothness","seed","highCut","lowCut"],["offset"],o.data,o.id,e.shared,this.uuid):Mr(["intensity"],[],o.data,o.id,e.shared,this.uuid):o.data.type==="depth"?Mr(["near","far"],["origin","direction"],o.data,o.id,e.shared,this.uuid):o.data.type==="fresnel"?Mr(["bias","scale","intensity","factor"],[],o.data,o.id,e.shared,this.uuid):o.data.type==="rainbow"?Mr(["filmThickness","movement","noiseStrength","noiseScale"],["offset","wavelengths"],o.data,o.id,e.shared,this.uuid):o.data.type==="noise"?Mr(["scale","move","seed","highCut","lowCut","smoothness"],["size","distortion","fA","fB"],o.data,o.id,e.shared,this.uuid):o.data.type==="pattern"?Mr(["blending","size","variation","smoothness","zigzag","rotation"],["offset","frequency","vertical","horizontal"],o.data,o.id,e.shared,this.uuid):o.data.type==="outline"?Mr(["outlineWidth","contourWidth","outlineThreshold","contourThreshold","outlineSmoothing","contourFrequency"],["contourDirection"],o.data,o.id,e.shared,this.uuid):o.data.type==="toon"?Mr(["noiseStrength","noiseScale"],["offset","source"],o.data,o.id,e.shared,this.uuid):o.data.type==="transmission"?Mr(["roughness","thickness","ior"],[],o.data,o.id,e.shared,this.uuid):o.data.type==="texture"||o.data.type==="video"?(Mr([],["size"],o.data,o.id,e.shared,this.uuid),Mr(["rotation"],["repeat","offset"],o.data,o.id,e.shared,this.uuid,["texture"])):o.data.type==="gradient"?Mr(["angle"],["offset","morph"],o.data,o.id,e.shared,this.uuid):o.data.type==="matcap"&&Mr(["rotation"],[],o.data,o.id,e.shared,this.uuid,["texture"])})}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 xr),this.lightLayer===void 0&&(this.lightLayer=new xr(0,"",{...Nt.defaultData("light","phong"),visible:!1},new yi,{},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 xr);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 gt&&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=Od(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:en(e.props.alpha,n,["material",this.uuid,"layer",a,"alpha"])}:c={...e.props,alphaOverride:en(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 gt?r.color.mask=void 0:r instanceof xr&&(r.node.mask=void 0)}for(let e=0;e<this.layers.length;++e){let r=this.layers[e];if(r instanceof gt&&r.isMask.value&&r.data.visible&&e>0){let o=e-1,n=this.layers[o];n instanceof xr?n.node.mask=new tr(r.color,r.alpha,tr.MUL):n instanceof gt&&(n.isMask.value||(n.color.mask=new tr(r.color,r.alpha,tr.MUL)))}}}blendColors(){let e=this.layers.findIndex(o=>o instanceof gt),r=this.layers.findIndex(o=>o instanceof xr);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 gt){if(a.isMask.value)continue;o=new gs(o,a.color,a.alpha,a.mode)}}this.fragment.color=o}else this.fragment.color=void 0}blendAfterColors(){let e=new Qe("outgoingLight","f"),r=this.layers.findIndex(o=>o instanceof xr);if(this.layers.length>r+1){for(let o=r+1;o<this.layers.length;++o){let n=this.layers[o];if(n instanceof gt){if(n.isMask.value)continue;e=new gs(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 rc);if(e.length>0){let r=e[0].position;for(let o=1;o<e.length;++o)e[o]&&(r=new tr(r,e[o].position,tr.ADD),r=new tr(r,new se(.5).setReadonly(!0),tr.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 ms;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 gt){let r=e.params.texture;if(r instanceof Fn&&!r.image.loaded)return!1}return!0}};Object.defineProperties(Ir.prototype,{properties:{get:function(){return this.fragment.properties}}});var Hn=class extends kn{constructor(t,e,r){super(t,e,!1),this.uuid=r,this.allowVariableSaves=!0,this.saveVariableLocations(e)}};var ev=new Map;function tv(i){if(typeof i=="string")return i;let t=ev.get(i);return t||(t={url:URL.createObjectURL(new Blob([i]))},ev.set(i,t)),t.url}var S3,rv=new Promise(i=>{S3=i});var ov;rv.then(i=>ov=i);var Wn=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:tv(t),format:"wav"},this.sound=new ov.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 Kt=require("three"),Ad=class{constructor(){this.type="ShapePath";this.color=new Kt.Color;this.subPaths=[];this.currentPath=null}moveTo(t,e){return this.currentPath=new Kt.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,g,b){let w=m.x,P=y.x,S=g.x,T=b.x,A=m.y,x=y.y,N=g.y,E=b.y,M=(T-S)*(A-N)-(E-N)*(w-S),D=(P-w)*(A-N)-(x-A)*(w-S),_=(E-N)*(P-w)-(T-S)*(x-A),R=M/_,V=D/_;if(_===0&&M!==0||R<=0||R>=1||V<0||V>1)return null;if(M===0&&_===0){for(let U=0;U<2;U++)if(n(U===0?g:b,m,y),r.loc===e.ORIGIN){let B=U===0?g:b;return{x:B.x,y:B.y,t:r.t}}else if(r.loc===e.BETWEEN){let B=+(w+r.t*(P-w)).toPrecision(10),q=+(A+r.t*(x-A)).toPrecision(10);return{x:B,y:q,t:r.t}}return null}else{for(let q=0;q<2;q++)if(n(q===0?g:b,m,y),r.loc===e.ORIGIN){let j=q===0?g:b;return{x:j.x,y:j.y,t:r.t}}let U=+(w+R*(P-w)).toPrecision(10),B=+(A+R*(x-A)).toPrecision(10);return{x:U,y:B,t:R}}}function n(m,y,g){let b=g.x-y.x,w=g.y-y.y,P=m.x-y.x,S=m.y-y.y,T=b*S-P*w;if(m.x===y.x&&m.y===y.y){r.loc=e.ORIGIN,r.t=0;return}if(m.x===g.x&&m.y===g.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(b*P<0||w*S<0){r.loc=e.BEHIND;return}if(Math.sqrt(b*b+w*w)<Math.sqrt(P*P+S*S)){r.loc=e.BEYOND;return}let A;b!==0?A=P/b:A=S/w,r.loc=e.BETWEEN,r.t=A}function a(m,y){let g=[],b=[];for(let w=1;w<m.length;w++){let P=m[w-1],S=m[w];for(let T=1;T<y.length;T++){let A=y[T-1],x=y[T],N=o(P,S,A,x);N!==null&&g.find(E=>E.t<=N.t+Number.EPSILON&&E.t>=N.t-Number.EPSILON)===void 0&&(g.push(N),b.push(new Kt.Vector2(N.x,N.y)))}}return b}function s(m,y,g){let b=new Kt.Vector2;y.getCenter(b);let w=[];return g.forEach(P=>{P.boundingBox.containsPoint(b)&&a(m,P.points).forEach(T=>{w.push({identifier:P.identifier,isCW:P.isCW,point:T})})}),w.sort((P,S)=>P.point.x-S.point.x),w}function l(m,y,g,b,w){(w==null||w==="")&&(w="nonzero");let P=new Kt.Vector2;m.boundingBox.getCenter(P);let S=[new Kt.Vector2(g,P.y),new Kt.Vector2(b,P.y)],T=s(S,m.boundingBox,y);T.sort((D,_)=>D.point.x-_.point.x);let A=[],x=[];T.forEach(D=>{D.identifier===m.identifier?A.push(D):x.push(D)});let N=A[0].point.x,E=[],M=0;for(;M<x.length&&x[M].point.x<N;)E.length>0&&E[E.length-1]===x[M].identifier?E.pop():E.push(x[M].identifier),M++;if(E.push(m.identifier),w==="evenodd"){let D=E.length%2===0,_=E[E.length-2];return{identifier:m.identifier,isHole:D,for:_}}else if(w==="nonzero"){let D=!0,_=null,R=null;for(let V=0;V<E.length;V++){let U=E[V];y[U]&&(D?(R=y[U].isCW,D=!1,_=U):R!==y[U].isCW&&(R=y[U].isCW,D=!0))}return{identifier:m.identifier,isHole:D,for:_}}else console.warn('fill-rule: "'+w+'" is currently not implemented.')}let c=0,u=999999999,d=-999999999,p=[];this.subPaths.forEach(m=>{let y=m.getPoints(),g=-999999999,b=999999999,w=-999999999,P=999999999;for(let S=0;S<y.length;S++){let T=y[S];T.y>g&&(g=T.y),T.y<b&&(b=T.y),T.x>w&&(w=T.x),T.x<P&&(P=T.x)}d<=w&&(d=w+1),u>=P&&(u=P-1),y.length&&p.push({curves:m.curves,points:y,isCW:Kt.ShapeUtils.isClockWise(y),identifier:c++,boundingBox:new Kt.Box2(new Kt.Vector2(P,b),new Kt.Vector2(w,g))})});let f=p.map(m=>l(m,p,u,d,this.userData?.style.fillRule)),h=[];return p.forEach(m=>{let y=f[m.identifier];if(y&&!y.isHole){let g=new Kt.Shape;g.curves=m.curves,f.filter(w=>w?.isHole&&w.for===m.identifier).forEach(w=>{if(w){let P=p[w.identifier],S=new Kt.Path;S.curves=P.curves,g.holes.push(S)}}),h.push(g)}}),h}};var Oh=!1,nv,Th=new Promise(i=>{nv=i}),iv=!1;var Md;function av(){if(Oh=!0,iv)return;if(Md)return Md;async function i(){let e=await import("./opentype.js");nv(e),iv=!0}return Md=i(),Md}var oc=class{async load(t,e,r=()=>{}){let{load:o}=await Th;o(t,(n,a)=>{n||!a?r(n??"Something went wrong"):e(a)})}async parse(t){let{parse:e,Bidi:r}=await Th;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 w3(i){return await(await fetch(i)).arrayBuffer()}var P3=new oc;async function Ch(i){let t,e,r=!1;if(i.url?(t=await w3(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(Oh){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 Rs=require("three");function O3(i,t){return t.state.glyphIndex===i||t.state.fina===i||t.state.medi===i||t.state.init===i}var Id=class{constructor(t){this._arrayBuffer=new ArrayBuffer(1);this._isLoaded=!1;this._intercepted=!1;this._isUserFont=t.isUserFont??!1,this._loadingPromise=Ch(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=Ch(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,d=String.fromCharCode(r[c].unicode),p=n[s];if(O3(u,p)||l)a.push({char:d,index:u,replacements:[p.state.glyphIndex],replacementChars:[p.char]}),s++;else{let f=p.char,h="",m=[p.state.glyphIndex],y=[],g=!1;for(;!g;)s++,h=e.charAt(s),f+=h,m.push(t.charToGlyphIndex(h)),y=t.stringToGlyphs(f),y.length===1&&y[0].index===u&&(g=!0),s>e.length&&(g=!0);a.push({char:d,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(b=>this.getTextWidth(b,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 Pd=require("three");var vd=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 wh=class extends vd{create(t){return URL.createObjectURL(new Blob([t]))}dispose(t,e){URL.revokeObjectURL(e)}},Sh;function Zb(i){return typeof i=="string"?i:(Sh||(Sh=new wh),Sh.load(i))}var Sd=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")}},wd=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 Ds=class extends Sd{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=Zb(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 Pd.VideoTexture(this.img,void 0,e,e):a=new Pd.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 Vr=class extends Ds{};var ft=require("three");function lr(i,t){return t.color(i)}function Jb(i,t){switch(i.type){case"fresnel":return n3(i,t);case"gradient":return a3(i,t);case"depth":return s3(i,t);case"normal":return l3(i,t);case"noise":return c3(i,t);case"rainbow":return u3(i,t);case"toon":return d3(i,t);case"outline":return p3(i,t);case"transmission":return f3(i,t);case"pattern":return h3(i,t);case"color":default:return i3(i,t)}}function o3(i){return{type:i.type}}function So(i,t){let{alpha:e,mode:r,isMask:o}=i,n=typeof e=="string"?(Number(t.getVariable(e))??100)/100:e;return{...o3(i),alpha:n,mode:r,isMask:o}}function i3(i,t){return{...So(i,t),color:lr(i.color,t)}}function n3(i,t){let{bias:e,scale:r,intensity:o,factor:n,color:a}=i;return{...So(i,t),color:lr(a,t),bias:e,scale:r,intensity:o,factor:n}}function a3(i,t){let{gradientType:e,smooth:r,colors:o,steps:n,angle:a,offset:s,morph:l}=i;return{...So(i,t),gradientType:e,smooth:r,colors:o.map(c=>new ft.Vector4(c[0],c[1],c[2],c[3])),num:o.length,steps:n,offset:new ft.Vector2(...s.map(c=>typeof c=="number"?c:0)),morph:new ft.Vector2(...l.map(c=>typeof c=="number"?c:0)),angle:a}}function s3(i,t){let{gradientType:e,near:r,far:o,isVector:n,isWorldSpace:a,origin:s,direction:l,colors:c,steps:u,smooth:d}=i;return{...So(i,t),gradientType:e,near:r,far:o,isVector:n,isWorldSpace:a,origin:new ft.Vector3(...s),direction:l?new ft.Vector3(...l):new ft.Vector3(1,0,0),colors:c.map(p=>p!==void 0?new ft.Vector4(p[0],p[1],p[2],p[3]):new ft.Vector4(0,0,0,0)),steps:u.slice(0,c.length),smooth:d}}function l3(i,t){let{cnormal:e}=i;return{...So(i,t),cnormal:new ft.Vector3(e[0],e[1],e[2])}}function c3(i,t){return{...So(i,t),scale:i.scale,move:i.move,fA:new ft.Vector2(...i.fA.map(e=>typeof e=="number"?e:0)),fB:new ft.Vector2(...i.fB.map(e=>typeof e=="number"?e:0)),size:new ft.Vector3(...i.size),distortion:new ft.Vector2(...i.distortion.map(e=>typeof e=="number"?e:0)),colorA:lr(i.colorA,t),colorB:lr(i.colorB,t),colorC:lr(i.colorC,t),colorD:lr(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 u3(i,t){return{...So(i,t),filmThickness:i.filmThickness,movement:i.movement,wavelengths:new ft.Vector3(...i.wavelengths),noiseStrength:i.noiseStrength,noiseScale:i.noiseScale,offset:new ft.Vector3(...i.offset)}}function d3(i,t){return{...So(i,t),positioning:i.positioning,colors:i.colors.map(e=>new ft.Vector4(e[0],e[1],e[2],e[3])),num:i.colors.length,steps:i.steps,source:new ft.Vector3(...i.source),isWorldSpace:i.isWorldSpace,noiseStrength:i.noiseStrength,noiseScale:i.noiseScale,shadowColor:lr(i.shadowColor,t),offset:new ft.Vector3(...i.offset)}}function p3(i,t){return{...So(i,t),outlineColor:lr(i.outlineColor,t),contourColor:lr(i.contourColor,t),outlineWidth:i.outlineWidth,contourWidth:i.contourWidth,outlineThreshold:i.outlineThreshold,contourThreshold:i.contourThreshold,outlineSmoothing:i.outlineSmoothing,contourFrequency:i.contourFrequency,contourDirection:new ft.Vector3(...i.contourDirection),positionalLines:i.positionalLines,compensation:i.compensation}}function f3(i,t){return{...So(i,t),thickness:i.thickness,ior:i.ior,roughness:i.roughness}}function h3(i,t){return{...So(i,t),style:i.style,projection:i.projection,axis:i.axis,blending:i.blending,offset:new ft.Vector2(...i.offset.map(e=>typeof e=="number"?e:0)),colorA:lr(i.colorA,t),colorB:lr(i.colorB,t),frequency:new ft.Vector2(...i.frequency.map(e=>typeof e=="number"?e:0)),size:i.size,variation:i.variation,smoothness:i.smoothness,zigzag:i.zigzag,rotation:i.rotation,vertical:new ft.Vector2(...i.vertical.map(e=>typeof e=="number"?e:0)),horizontal:new ft.Vector2(...i.horizontal.map(e=>typeof e=="number"?e:0)),sides:i.sides}}var Zi=class extends qt{};var Od=require("three");var m3={noise:["noiseType"],texture:["projection","axis","side"],video:["projection","axis","side"],displace:["noiseType"],light:["roughnessMap","bumpMap"],depth:["smooth","isWorldSpace","gradientType","isVector"],pattern:["style","projection","axis"]},y3={depth:["colors"]};function g3(i,t,e){if(t==="isMask")return!0;let r=m3[i.type],o=y3[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 Ph(i,t){if(Array.isArray(t)){if(!Array.isArray(i)||i.length!==t.length)return!1;for(let[o,n]of t.entries()){let a=i[o];if(typeof n=="string"||typeof n=="number"&&typeof a=="string")return!0}return!1}let e=typeof i=="string",r=typeof t=="string";return e!==r||e&&r}function tc(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 Vr||l.image.deref(),l.image=s}if("video"in n){let a=n.video,s=t.video(a),l=r;l.image instanceof Vr||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=(Pe(n.rotation??0,t)??0)*Od.MathUtils.DEG2RAD,o;if("repeat"in n||"offset"in n||"rotation"in n){let a="mat",s=e.uniforms[`f${e.id}_${a}`];if(!s)return o;if("repeat"in n){let l=n.repeat;Ph(e.data.texture.repeat,l)&&(o=!0),s.repeat=_s(l,t).map((c,u)=>typeof l[u]=="string"?1/c:c)}if("offset"in n){let l=n.offset;Ph(e.data.texture.offset,l)&&(o=!0),s.offset=_s(l,t).map((c,u)=>typeof l[u]=="string"?-c:c)}if("rotation"in n){let l=e.data.texture.rotation,c=n.rotation??0;(l===void 0||Ph(l,c))&&(o=!0),s.rotation=Pe(c,t)??0}s.updateMatrix()}return o}function ev(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(Oh(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 Ki))switch(o=o||g3(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 Zi?s.value=new qt(l.r,l.g,l.b,l.a):s.setRGBA(l);break}case Cr:if(typeof a=="string"){let l=t.getColor(a);l&&(s.value=l);break}else{let l=a;s.value instanceof Zi?s.value=new qt(l.r,l.g,l.b,l.a):s.value.setRGBA(l.r,l.g,l.b,l.a);break}case Ot:{let l=a;s.value.setX(l[0]),s.value.setY(l[1]);break}case ar:{let l=a;s.value.setX(l[0]),s.value.setY(l[1]),s.value.setZ(l[2]);break}case gr:{tc(a,t,e);break}case vo:{s.value=a.map(l=>new Od.Vector4(...l));break}default:{s.value=a;break}}}return o}var en=(i,t,e)=>Math.max(0,Math.min(1,Number(t.getVariable(typeof i=="number"?i*100:i,e)??100)/100))??1,Pe=(i,t,e)=>typeof i=="number"?i:t.getVariable(i,e),Ji=(i,t)=>(i||(i=new ct.Vector3),i.x=Pe(i.x,t)??0,i.y=Pe(i.y,t)??0,i.z=Pe(i.z,t)??0,i),xi=(i,t)=>(i||(i=new ct.Vector2),i.x=Pe(i.x,t)??0,i.y=Pe(i.y,t)??0,i),_s=(i,t)=>{let e=i.map(r=>Pe(r,t)??0);return[e[0],e[1]]},tn=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)Oh(a,this,r,n)}get type(){return this.data.type}static create(t,e,r,o){if(r.type==="light")return xr.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 Fn(n,r.texture.wrapping,r.texture.minFilter??1008,r.texture.magFilter??1006),s=new gd(n),l=new xd(_s(r.texture.repeat,o),_s(r.texture.offset,o),Pe(r.texture.rotation??0,o)),c=new se(r.crop?1:0),u=new je(r.projection??0),d=new je(["x","y","z"].indexOf(r.axis)??0),p=new je(r.side??0),f=new Ot(r.size?new ct.Vector2(..._s(r.size,o)):new ct.Vector2(100,100)),h=new se(r.blending??0),m=new se(en(r.alpha,o)),y=new je(r.mode??0),g=new Tt(r.isMask??!1),b=new Qi(a,s,c,u,d,p,f,h,l,m,y,g),w=new Qe(b.calpha,"f");return new gt(t,e,r,{texture:a,textureSize:s,crop:c,projection:u,axis:d,side:p,size:f,blending:h,mat:l,alpha:m,mode:y,isMask:g},b,y,w,g,o)}else if(r.type==="matcap"){let n=o.image(r.texture.image),a=new Fn(n,r.texture.wrapping,r.texture.minFilter??1008,r.texture.magFilter??1006),s=new se(en(r.alpha,o)),l=new je(r.mode??0),c=new Tt(r.isMask??!1),u=new se((Pe(r.texture.rotation??0,o)??0)*ct.MathUtils.DEG2RAD),d=new Ps(a,s,l,c,u),p=new Qe(d.calpha,"f");return new gt(t,e,r,{texture:a,alpha:s,mode:l,isMask:c,rotation:u},d,l,p,c,o)}else if(r.type==="displace")if(r.displacementType==="noise"){let n=new ar(new ct.Vector3(...r.offset.map(g=>Pe(g,o)??0))),a=new se(Pe(r.scale,o)??10),s=new se(Pe(r.intensity,o)??8),l=new se(Pe(r.movement,o)??1),c=new je(r.noiseType??0),u=new je(r.voronoiStyle??0),d=new se(Pe(r.smoothness,o)??.5),p=new se(Pe(r.seed,o)??0),f=new se(Pe(r.highCut,o)??1),h=new se(Pe(r.lowCut,o)??0),m=new je(Pe(r.quality,o)??1),y=new Es(s,l,n,u,d,p,f,h,m,a,c);return new rc(t,e,r,{offset:n,scale:a,intensity:s,movement:l,noiseType:c,voronoiStyle:u,smoothness:d,seed:p,highCut:f,lowCut:h,quality:m},y,o)}else throw new Error;else return v3(t,e,r,o)}updateByOp(t,e,r){let o=t,n=!1;if(o.path[0]===void 0){for(let a of Object.keys(o.props))try{let s=this.data[a],l=e[a];if(Array.isArray(s)&&Array.isArray(l)){for(let[c,u]of l.entries()){let d=s[c];if(typeof u=="string"||typeof u=="number"&&typeof d=="string"){n=!0;break}}if(n)break}else if(typeof l=="string"&&typeof s=="number"||typeof l=="number"&&typeof s=="string"||typeof l=="string"&&typeof s=="string"&&l!==s){n=!0;break}}catch(s){console.error(s)}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):ev(o.props,r.shared,this,e)||n}else if(o.path[0]==="texture")return"texture"in e||"video"in e?tc(o.props,r.shared,this)||n:!0;return n}dispose(){if(x3(this)){let t=this.uniforms[`f${this.id}_texture`];if(!t)return!1;let e=t;e.image instanceof Vr||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}},gt=class extends tn{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}},rc=class extends tn{constructor(e,r,o,n,a,s){super(e,r,o,n,s);this.position=a}},xr=class extends tn{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(en(o.alpha,n)),l=new je(o.mode),c=new se(o.bumpMapIntensity),u=new se(en(o.alphaOverride,n)),d;if(!o.visible)a=new yi,d={};else if(o.category==="lambert"){a=new Yl;let p=new et(n.color(o.emissive)??0),f=new Tt(o.occlusion??!0);d={emissive:p,occlusion:f},a.emissive=p,a.occlusion=f}else if(o.category==="toon"){a=new ec;let p=new se(o.shininess??30),f=new et(n.color(o.specular)??1118481);d={shininess:p,specular:f},a.shininess=p,a.specular=f}else if(o.category==="physical"){a=new Zl;let p=new se(o.roughness??.3),f=new se(o.metalness??0),h=new se(o.reflectivity??.5),m=new Tt(o.occlusion??!0);d={roughness:p,metalness:f,reflectivity:h,occlusion:m},a.roughness=p,a.metalness=f,a.reflectivity=h,a.occlusion=m}else{a=new Ql;let p=new se(o.shininess??30),f=new et(o.specular!==void 0?n.color(o.specular)??1118481:1118481),h=new Tt(o.occlusion??!0);d={shininess:p,specular:f,occlusion:h},a.shininess=p,a.specular=f,a.occlusion=h}return a.alpha=new se(1),a.shadingAlpha=s,a.shadingBlend=l,a.bumpMapIntensity=c,a.alphaOverride=u,d.alpha=a.shadingAlpha,d.mode=a.shadingBlend,d.bumpMapIntensity=a.bumpMapIntensity,d.alphaOverride=a.alphaOverride,new xr(e,r,o,a,d,n)}get category(){return this.node.category}};function x3(i){let t=i instanceof tn?i.type:i;return t==="texture"||t==="video"||t==="displace_map"||t==="matcap"}function Yr(i){return{alpha:new se(i.alpha??1),mode:new je(i.mode??0),isMask:new Tt(i.isMask??!1)}}function b3(i,t,e,r,o){switch(i.type){case"color":{let n=new et(r.color??Bt),a=Yr(r),s=new jn(n,a.alpha),l=new Qe(s.calpha,"f");return new gt(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(Pe(r.bias,o)??.1),s=new se(Pe(r.scale,o)??1),l=new se(Pe(r.intensity,o)??2),c=new se(Pe(r.factor,o)??1),u=Yr(r),d=new $l(n,a,s,l,c,u.alpha,u.mode,u.isMask),p=new Qe(d.calpha,"f");return new gt(t,e,i,{color:n,bias:a,scale:s,intensity:l,factor:c,...u},d,u.mode,p,u.isMask,o)}case"rainbow":{let n=new se(Pe(r.filmThickness,o)??30),a=new se(Pe(r.movement,o)??0),s=new ar(Ji(r.wavelengths,o)),l=new se(Pe(r.noiseStrength,o)??0),c=new se(Pe(r.noiseScale,o)??1),u=new ar(Ji(r.offset,o)),d=Yr(r),p=new As(n,a,s,l,c,u,d.alpha,d.isMask),f=new Qe(p.calpha,"f");return new gt(t,e,i,{filmThickness:n,movement:a,wavelengths:s,noiseStrength:l,noiseScale:c,offset:u,...d},p,d.mode,f,d.isMask,o)}case"transmission":{let n=new se(Pe(r.thickness??10,o)),a=new se(Pe(r.ior??1.5,o)),s=new se(Pe(r.roughness??.5,o)),l=_e.transmissionSize,c=_e.transmissionRenderTarget,u=_e.transmissionRenderTargetDepth,d=window.innerWidth,p=window.innerHeight,f=d>=p?new Ot(p/d,1):new Ot(1,d/p),h=Yr(r),m=new Is(n,a,s,l,c,u,f,h.alpha),y=new Qe(m.calpha,"f");return new gt(t,e,i,{thickness:n,ior:a,roughness:s,aspectRatio:f,...h},m,h.mode,y,h.isMask,o)}case"toon":{let n=new je(r.positioning??0),a;r.colors?a=new vo(r.colors.length,r.colors):(a=new vo(10,new ct.Vector4(0,0,0,1)),a.value[1]=new ct.Vector4(1,1,1,1));let s;r.steps?s=new bo(r.steps.length,r.steps):(s=new bo(10,1),s.value[0]=0);let l=new ar(Ji(r.source??new ct.Vector3(0,0,0),o)),c=new Tt(r.isWorldSpace??!0),u=new se(Pe(r.noiseStrength??0,o)),d=new se(Pe(r.noiseScale??1,o)),p=new Cr(r.shadowColor),f=new ar(Ji(r.offset??new ct.Vector3(0,0,0),o)),h=Yr(r),m=new Ms(n,a,s,l,c,u,d,p,f,h.alpha),y=new Qe(m.calpha,"f");return new gt(t,e,i,{positioning:n,colors:a,steps:s,source:l,isWorldSpace:c,noiseStrength:u,noiseScale:d,shadowColor:p,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(Pe(r.outlineWidth??.1,o)),l=new se(Pe(r.contourWidth??.1,o)),c=new se(Pe(r.outlineThreshold??.1,o)),u=new se(Pe(r.contourThreshold??.1,o)),d=new se(Pe(r.outlineSmoothing??.1,o)),p=new se(Pe(r.contourFrequency??.1,o)),f=new ar(Ji(r.contourDirection??new ct.Vector3(0,1,0),o)),h=new Tt(r.positionalLines??!1),m=new Tt(r.compensation??!0),y=_e.normalRenderTarget,g=_e.normalRenderTargetDepth,b=_e.pixelRatioNode,w=_e.resolution,P=Yr(r),S=new Ts(n,a,s,l,c,u,d,p,f,h,m,w,y,g,b,P.alpha),T=new Qe(S.calpha,"f");return new gt(t,e,i,{outlineColor:n,contourColor:a,outlineWidth:s,contourWidth:l,outlineThreshold:c,contourThreshold:u,outlineSmoothing:d,contourFrequency:p,contourDirection:f,positionalLines:h,compensation:m,...P},S,P.mode,T,P.isMask,o)}case"depth":{let n=new je(r.gradientType??0),a=new Tt(r.smooth??!1),s=new se(Pe(r.near,o)??50),l=new se(Pe(r.far,o)??200),c=new se(r.isVector??1),u=new se(r.isWorldSpace??0),d=new ar(Ji(r.origin,o)),p=new ar(Ji(r.direction,o)),f;r.colors?f=new vo(r.colors.length,r.colors):(f=new vo(2,new ct.Vector4(0,0,0,1)),f.value[1]=new ct.Vector4(1,1,1,1));let h;r.steps?h=new bo(r.steps.length,r.steps):(h=new bo(2,1),h.value[0]=0);let m=Yr(r),y=new Ss(n,a,s,l,c,u,d,p,f,h,m.alpha,m.isMask),g=new Qe(y.calpha,"f");return new gt(t,e,i,{gradientType:n,smooth:a,near:s,far:l,isVector:c,isWorldSpace:u,origin:d,direction:p,colors:f,steps:h,...m},y,m.mode,g,m.isMask,o)}case"noise":{let n=new se(Pe(r.scale,o)??1),a=new ar(Ji(r.size??new ct.Vector3(100,100,100),o)),s=new se(Pe(r.move,o)??1),l=new Ot(xi(r.fA??new ct.Vector2(1.7,9.2),o)),c=new Ot(xi(r.fB??new ct.Vector2(8.3,2.8),o)),u=new Ot(xi(r.distortion??new ct.Vector2(1,1),o)),d=new Cr(r.colorA),p=new Cr(r.colorB),f=new Cr(r.colorC),h=new Cr(r.colorD),m=new je(r.noiseType??0),y=new je(r.voronoiStyle??0),g=new se(Pe(r.highCut,o)??1),b=new se(Pe(r.lowCut,o)??0),w=new se(Pe(r.smoothness,o)??.5),P=new se(Pe(r.seed,o)??.5),S=new je(r.quality??1),T=Yr(r),A=new Os(n,a,s,l,c,u,d,p,f,h,T.alpha,m,T.isMask,y,g,b,w,P,S),x=new Qe(A.calpha,"f");return new gt(t,e,i,{scale:n,size:a,move:s,fA:l,fB:c,distortion:u,colorA:d,colorB:p,colorC:f,colorD:h,noiseType:m,...T,voronoiStyle:y,highCut:g,lowCut:b,smoothness:w,seed:P,quality:S},A,T.mode,x,T.isMask,o)}case"normal":{let n=new ar(r.cnormal??new ct.Vector3(1,1,1)),a=Yr(r),s=new xs(n,a.alpha),l=new Qe(s.calpha,"f");return new gt(t,e,i,{cnormal:n,...a},s,a.mode,l,a.isMask,o)}case"gradient":{let n=new je(r.gradientType??0),a=new Tt(r.smooth??!1),s;r.colors?s=new vo(r.colors.length,r.colors):(s=new vo(10,new ct.Vector4(0,0,0,1)),s.value[1]=new ct.Vector4(1,1,1,1));let l;r.steps?l=new bo(r.steps.length,r.steps):(l=new bo(10,1),l.value[0]=0);let c=new Ot(xi(r.offset??new ct.Vector2(0,0),o)),u=new Ot(xi(r.morph??new ct.Vector2(0,0),o)),d=new se(Pe(r.angle??0,o)),p=Yr(r),f=new ws(n,a,s,l,c,u,d,p.alpha,p.isMask),h=new Qe(f.calpha,"f");return new gt(t,e,i,{gradientType:n,smooth:a,colors:s,steps:l,offset:c,morph:u,angle:d,...p},f,p.mode,h,p.isMask,o)}case"pattern":{let n=new je(r.style??0),a=new je(r.projection??0),s=new je(["x","y","z"].indexOf(r.axis)??0),l=new se(Pe(r.blending??0,o)),c=new Ot(xi(r.offset,o)),u=new Cr(r.colorA),d=new Cr(r.colorB),p=new Ot(xi(r.frequency??new ct.Vector2(10,10),o)),f=new se(Pe(r.size??.5,o)),h=new se(Pe(r.variation??0,o)),m=new se(Pe(r.smoothness??.5,o)),y=new se(Pe(r.zigzag??0,o)),g=new se(Pe(r.rotation??0,o)),b=new Ot(xi(r.vertical??new ct.Vector2(0,1),o)),w=new Ot(xi(r.horizontal??new ct.Vector2(0,1),o)),P=new je(r.sides??6),S=Yr(r),T=new Cs(n,a,s,l,c,u,d,p,f,h,m,y,g,b,w,P,S.alpha,S.isMask),A=new Qe(T.calpha,"f");return new gt(t,e,i,{style:n,projection:a,axis:s,blending:l,offset:c,colorA:u,colorB:d,frequency:p,size:f,variation:h,smoothness:m,zigzag:y,rotation:g,vertical:b,horizontal:w,sides:P,...S},T,S.mode,A,S.isMask,o)}default:{let n=new et(1,0,0,1),a=Yr(r),s=new jn(n,a.alpha),l=new Qe(s.calpha,"f");return new gt(t,e,i,{color:n,...a},s,a.mode,l,a.isMask,o)}}}function v3(i,t,e,r){let o=Jb(e,r);return b3(e,i,t,o,r)}function Oh(i,t,e,r){if(e.type==="displace"&&(i==="intensity"||i==="visible")){let o=t.uniforms[`f${t.id}_intensity`];return o?(o.value=(Pe(e.intensity,r)??1)*(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=en(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 Mr(i,t,e,r,o,n,a=[]){let s=e;for(let l of a)l in s&&(s=s[l]);for(let l of i)l in s&&o.getVariable(s[l],["material",n,"layer",r,...a,String(l)]);for(let l of t)l in s&&s[l].forEach((c,u)=>{o.getVariable(c,["material",n,"layer",r,...a,String(l),u===0?"x":u===1?"y":"z"])})}function Td(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 Ir=class extends Ad.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""}},Cd=class extends Ir{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()}},kn=class extends Ir{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 Cd(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??Wt.defaultTwoLayerData("phong").layers;try{this.layers=o.map(n=>tn.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=Td(e,r.shared),this.saveVariableLocations(r)}onVariableUpdate(e,r,o){if(e[0]==="alphaOverride")this.transparent=Td(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);if(s?.hasValue(a))if(a==="alpha")this.transparent=Td(this.data,o.shared),s.setValue(a,Math.max(0,Math.min(Number(r)/100,1)));else{let l=s.getValue(a),c=e[3],u=e[4];if(l instanceof Ad.Texture){let d=l[c],p;typeof d=="number"?p=Number(r):d.isVector2&&(p=d.toArray(),u==="x"?p[0]=Number(r):u==="y"&&(p[1]=Number(r))),tc({[c]:p},o.shared,s);return}(c==="x"||c==="y"||c==="z")&&l.isVector3||(c==="x"||c==="y")&&l.isVector2?l[c]=Number(r):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"]),o.data.type==="displace"?o.data.displacementType==="noise"?Mr(["intensity","scale","movement","smoothness","seed","highCut","lowCut"],["offset"],o.data,o.id,e.shared,this.uuid):Mr(["intensity"],[],o.data,o.id,e.shared,this.uuid):o.data.type==="depth"?Mr(["near","far"],["origin","direction"],o.data,o.id,e.shared,this.uuid):o.data.type==="fresnel"?Mr(["bias","scale","intensity","factor"],[],o.data,o.id,e.shared,this.uuid):o.data.type==="rainbow"?Mr(["filmThickness","movement","noiseStrength","noiseScale"],["offset","wavelengths"],o.data,o.id,e.shared,this.uuid):o.data.type==="noise"?Mr(["scale","move","seed","highCut","lowCut","smoothness"],["size","distortion","fA","fB"],o.data,o.id,e.shared,this.uuid):o.data.type==="pattern"?Mr(["blending","size","variation","smoothness","zigzag","rotation"],["offset","frequency","vertical","horizontal"],o.data,o.id,e.shared,this.uuid):o.data.type==="outline"?Mr(["outlineWidth","contourWidth","outlineThreshold","contourThreshold","outlineSmoothing","contourFrequency"],["contourDirection"],o.data,o.id,e.shared,this.uuid):o.data.type==="toon"?Mr(["noiseStrength","noiseScale"],["offset","source"],o.data,o.id,e.shared,this.uuid):o.data.type==="transmission"?Mr(["roughness","thickness","ior"],[],o.data,o.id,e.shared,this.uuid):o.data.type==="texture"||o.data.type==="video"?(Mr([],["size"],o.data,o.id,e.shared,this.uuid),Mr(["rotation"],["repeat","offset"],o.data,o.id,e.shared,this.uuid,["texture"])):o.data.type==="gradient"?Mr(["angle"],["offset","morph"],o.data,o.id,e.shared,this.uuid):o.data.type==="matcap"&&Mr(["rotation"],[],o.data,o.id,e.shared,this.uuid,["texture"])})}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 xr),this.lightLayer===void 0&&(this.lightLayer=new xr(0,"",{...Nt.defaultData("light","phong"),visible:!1},new yi,{},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 xr);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 gt&&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=Td(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:en(e.props.alpha,n,["material",this.uuid,"layer",a,"alpha"])}:c={...e.props,alphaOverride:en(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 gt?r.color.mask=void 0:r instanceof xr&&(r.node.mask=void 0)}for(let e=0;e<this.layers.length;++e){let r=this.layers[e];if(r instanceof gt&&r.isMask.value&&r.data.visible&&e>0){let o=e-1,n=this.layers[o];n instanceof xr?n.node.mask=new tr(r.color,r.alpha,tr.MUL):n instanceof gt&&(n.isMask.value||(n.color.mask=new tr(r.color,r.alpha,tr.MUL)))}}}blendColors(){let e=this.layers.findIndex(o=>o instanceof gt),r=this.layers.findIndex(o=>o instanceof xr);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 gt){if(a.isMask.value)continue;o=new gs(o,a.color,a.alpha,a.mode)}}this.fragment.color=o}else this.fragment.color=void 0}blendAfterColors(){let e=new Qe("outgoingLight","f"),r=this.layers.findIndex(o=>o instanceof xr);if(this.layers.length>r+1){for(let o=r+1;o<this.layers.length;++o){let n=this.layers[o];if(n instanceof gt){if(n.isMask.value)continue;e=new gs(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 rc);if(e.length>0){let r=e[0].position;for(let o=1;o<e.length;++o)e[o]&&(r=new tr(r,e[o].position,tr.ADD),r=new tr(r,new se(.5).setReadonly(!0),tr.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 ms;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 gt){let r=e.params.texture;if(r instanceof Fn&&!r.image.loaded)return!1}return!0}};Object.defineProperties(Ir.prototype,{properties:{get:function(){return this.fragment.properties}}});var Hn=class extends kn{constructor(t,e,r){super(t,e,!1),this.uuid=r,this.allowVariableSaves=!0,this.saveVariableLocations(e)}};var tv=new Map;function rv(i){if(typeof i=="string")return i;let t=tv.get(i);return t||(t={url:URL.createObjectURL(new Blob([i]))},tv.set(i,t)),t.url}var S3,ov=new Promise(i=>{S3=i});var iv;ov.then(i=>iv=i);var Wn=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:rv(t),format:"wav"},this.sound=new iv.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 Kt=require("three"),Md=class{constructor(){this.type="ShapePath";this.color=new Kt.Color;this.subPaths=[];this.currentPath=null}moveTo(t,e){return this.currentPath=new Kt.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,g,b){let w=m.x,P=y.x,S=g.x,T=b.x,A=m.y,x=y.y,N=g.y,E=b.y,M=(T-S)*(A-N)-(E-N)*(w-S),D=(P-w)*(A-N)-(x-A)*(w-S),_=(E-N)*(P-w)-(T-S)*(x-A),R=M/_,V=D/_;if(_===0&&M!==0||R<=0||R>=1||V<0||V>1)return null;if(M===0&&_===0){for(let U=0;U<2;U++)if(n(U===0?g:b,m,y),r.loc===e.ORIGIN){let B=U===0?g:b;return{x:B.x,y:B.y,t:r.t}}else if(r.loc===e.BETWEEN){let B=+(w+r.t*(P-w)).toPrecision(10),q=+(A+r.t*(x-A)).toPrecision(10);return{x:B,y:q,t:r.t}}return null}else{for(let q=0;q<2;q++)if(n(q===0?g:b,m,y),r.loc===e.ORIGIN){let j=q===0?g:b;return{x:j.x,y:j.y,t:r.t}}let U=+(w+R*(P-w)).toPrecision(10),B=+(A+R*(x-A)).toPrecision(10);return{x:U,y:B,t:R}}}function n(m,y,g){let b=g.x-y.x,w=g.y-y.y,P=m.x-y.x,S=m.y-y.y,T=b*S-P*w;if(m.x===y.x&&m.y===y.y){r.loc=e.ORIGIN,r.t=0;return}if(m.x===g.x&&m.y===g.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(b*P<0||w*S<0){r.loc=e.BEHIND;return}if(Math.sqrt(b*b+w*w)<Math.sqrt(P*P+S*S)){r.loc=e.BEYOND;return}let A;b!==0?A=P/b:A=S/w,r.loc=e.BETWEEN,r.t=A}function a(m,y){let g=[],b=[];for(let w=1;w<m.length;w++){let P=m[w-1],S=m[w];for(let T=1;T<y.length;T++){let A=y[T-1],x=y[T],N=o(P,S,A,x);N!==null&&g.find(E=>E.t<=N.t+Number.EPSILON&&E.t>=N.t-Number.EPSILON)===void 0&&(g.push(N),b.push(new Kt.Vector2(N.x,N.y)))}}return b}function s(m,y,g){let b=new Kt.Vector2;y.getCenter(b);let w=[];return g.forEach(P=>{P.boundingBox.containsPoint(b)&&a(m,P.points).forEach(T=>{w.push({identifier:P.identifier,isCW:P.isCW,point:T})})}),w.sort((P,S)=>P.point.x-S.point.x),w}function l(m,y,g,b,w){(w==null||w==="")&&(w="nonzero");let P=new Kt.Vector2;m.boundingBox.getCenter(P);let S=[new Kt.Vector2(g,P.y),new Kt.Vector2(b,P.y)],T=s(S,m.boundingBox,y);T.sort((D,_)=>D.point.x-_.point.x);let A=[],x=[];T.forEach(D=>{D.identifier===m.identifier?A.push(D):x.push(D)});let N=A[0].point.x,E=[],M=0;for(;M<x.length&&x[M].point.x<N;)E.length>0&&E[E.length-1]===x[M].identifier?E.pop():E.push(x[M].identifier),M++;if(E.push(m.identifier),w==="evenodd"){let D=E.length%2===0,_=E[E.length-2];return{identifier:m.identifier,isHole:D,for:_}}else if(w==="nonzero"){let D=!0,_=null,R=null;for(let V=0;V<E.length;V++){let U=E[V];y[U]&&(D?(R=y[U].isCW,D=!1,_=U):R!==y[U].isCW&&(R=y[U].isCW,D=!0))}return{identifier:m.identifier,isHole:D,for:_}}else console.warn('fill-rule: "'+w+'" is currently not implemented.')}let c=0,u=999999999,d=-999999999,p=[];this.subPaths.forEach(m=>{let y=m.getPoints(),g=-999999999,b=999999999,w=-999999999,P=999999999;for(let S=0;S<y.length;S++){let T=y[S];T.y>g&&(g=T.y),T.y<b&&(b=T.y),T.x>w&&(w=T.x),T.x<P&&(P=T.x)}d<=w&&(d=w+1),u>=P&&(u=P-1),y.length&&p.push({curves:m.curves,points:y,isCW:Kt.ShapeUtils.isClockWise(y),identifier:c++,boundingBox:new Kt.Box2(new Kt.Vector2(P,b),new Kt.Vector2(w,g))})});let f=p.map(m=>l(m,p,u,d,this.userData?.style.fillRule)),h=[];return p.forEach(m=>{let y=f[m.identifier];if(y&&!y.isHole){let g=new Kt.Shape;g.curves=m.curves,f.filter(w=>w?.isHole&&w.for===m.identifier).forEach(w=>{if(w){let P=p[w.identifier],S=new Kt.Path;S.curves=P.curves,g.holes.push(S)}}),h.push(g)}}),h}};var Th=!1,av,Ch=new Promise(i=>{av=i}),nv=!1;var Id;function sv(){if(Th=!0,nv)return;if(Id)return Id;async function i(){let e=await import("./opentype.js");av(e),nv=!0}return Id=i(),Id}var oc=class{async load(t,e,r=()=>{}){let{load:o}=await Ch;o(t,(n,a)=>{n||!a?r(n??"Something went wrong"):e(a)})}async parse(t){let{parse:e,Bidi:r}=await Ch;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 w3(i){return await(await fetch(i)).arrayBuffer()}var P3=new oc;async function Ah(i){let t,e,r=!1;if(i.url?(t=await w3(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(Th){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 Rs=require("three");function O3(i,t){return t.state.glyphIndex===i||t.state.fina===i||t.state.medi===i||t.state.init===i}var Ed=class{constructor(t){this._arrayBuffer=new ArrayBuffer(1);this._isLoaded=!1;this._intercepted=!1;this._isUserFont=t.isUserFont??!1,this._loadingPromise=Ah(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=Ah(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,d=String.fromCharCode(r[c].unicode),p=n[s];if(O3(u,p)||l)a.push({char:d,index:u,replacements:[p.state.glyphIndex],replacementChars:[p.char]}),s++;else{let f=p.char,h="",m=[p.state.glyphIndex],y=[],g=!1;for(;!g;)s++,h=e.charAt(s),f+=h,m.push(t.charToGlyphIndex(h)),y=t.stringToGlyphs(f),y.length===1&&y[0].index===u&&(g=!0),s>e.length&&(g=!0);a.push({char:d,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(b=>this.getTextWidth(b,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),d=e.horizontalAlign===1?u:0,p=this.getLineInitialOffsetX(s[0],l,e.horizontalAlign,t[0],u),f=this.getLineInitialOffsetY(a,t.length,c,n,e.verticalAlign),h=[],m=t.map(b=>[]),y=t.map(b=>[]);for(let b=0;b<t.length;b++){let w=t[b],P={features:{liga:!0},letterSpacing:e.letterSpacing},S=[];try{S=o.stringToGlyphs(w,P)}catch(E){console.warn(E)}p=this.getLineInitialOffsetX(s[b],l,e.horizontalAlign,w,u);let T=[];try{T=this.reverseLigaturesTable(o,w,S)}catch(E){console.warn(E)}let A=this.computeSpaceWidthForLine(t,b,e,r),x=0,N=S[0];N&&e.horizontalAlign===2&&N.leftSideBearing!==void 0&&(p-=N.leftSideBearing*n),this.font?.forEachGlyph(w,p,f,e.fontSize,P,(E,M,D,_,R)=>{let V=E.index===0?`
2287
2287
  `:E.unicode?String.fromCharCode(E.unicode):void 0,U=T[x],B=0;if(V===`
2288
2288
  `)B=d;else if(V===" ")B=A;else{let q=this.createPath(E,n,M,D,e);q&&(B=q.offsetX,h.push(q.path))}if(U.replacements.length===1)y[b].push([M,D]),m[b].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=M;for(let W=0;W<F.length;W++){let ee=B*F[W];y[b].push([H,D]),m[b].push(ee),H+=ee}}x++}),f-=a}let g=[];for(let b=0,w=h.length;b<w;b++)g.push(...h[b].toShapes());return{shapes:g,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(`
2289
- `)>=0&&(t-=n),r===3?e*.5-t*.5:r===2?e-t:0}getLineInitialOffsetY(t,e,r,o,n){let a=e*t,s=Math.abs(this.ascender-this.descender)*o,l=t-s,c=-this.ascender*o-l/2;return n===3?-(r-a-c):n===2?-(r*.5-a*.5-c):c}createPath(t,e,r,o,n){let a=t.getPath(r,-o,n.fontSize,{kerning:!1,letterSpacing:n.letterSpacing});if(!a){console.error('THREE.Font: character "'+t+'" does not exists in font family '+this.familyName+".");return}let s=new Ad,l=(t.advanceWidth??1)*e;if(t)for(let c of a.commands){let u=s.currentPath?.currentPoint;if(!(u&&c.type!=="Z"&&u.x===c.x&&-u.y===c.y))switch(c.type){case"M":s.moveTo(c.x,-c.y);break;case"L":s.lineTo(c.x,-c.y);break;case"Q":s.quadraticCurveTo(c.x1,-c.y1,c.x,-c.y);break;case"C":s.bezierCurveTo(c.x1,-c.y1,c.x2,-c.y2,c.x,-c.y);break}}return s.subPaths.forEach(c=>{let u=T3(c.curves);u!==void 0&&c.currentPoint.distanceTo(u)>0&&c.lineTo(u.x,u.y)}),{offsetX:l,path:s}}getCharWidth(t,e){return this.font?.getAdvanceWidth(t,e.fontSize,{kerning:!0,letterSpacing:e.letterSpacing})??0}getTextWidth(t,e){return this.font?.getAdvanceWidth(t,e.fontSize,{kerning:!0,letterSpacing:e.letterSpacing})??0}computeSpaceWidthForLine(t,e,r,o){let n=this.getCharWidth(" ",r),a=t[e];if(a){let s=this.countSpaces(a.trimEnd());if(r.horizontalAlign===4&&e<t.length-1&&s){let l=typeof r.width=="string"?Number(o.getVariable(r.width)):r.width,c=this.getTextWidth(a,r);return(l-(c-s*n))/s}}return n}countSpaces(t){return(t.match(/ /g)||[]).length}};function T3(i){if(i.length){let t=i[0];if(t instanceof Rs.LineCurve)return t.v1;if(t instanceof Rs.CubicBezierCurve||t instanceof Rs.QuadraticBezierCurve)return t.v0}}var Ah=class{constructor(){this.objects=new Map;this.unreachable=new Set}getCached(t){return this.objects.get(t)}get size(){return this.objects.size}get(t,e,r){let o=this.objects.get(t);return o===void 0?(o=this.createObject(t,e,r),this.objects.set(t,o)):o.isShared=!0,o}forceDelete(t){let e=this.objects.get(t);e&&(this.disposeObject(e),this.objects.delete(t))}mutateIfUnique(t,e){let r=this.objects.get(t);if(r&&r.isShared!==!0)return this.objects.delete(t),this.objects.set(e,r),r}startGc(){this.unreachable=new Set(this.objects.keys())}markAsReachable(t,e){let r=this.objects.get(t);e===r?this.unreachable.delete(t):!1&&console.warn("Reachable but deleted",t)}endGc(){this.unreachable.forEach(t=>{this.disposeObject(this.objects.get(t)),this.objects.delete(t)}),this.unreachable.clear()}dispose(){this.objects.forEach(t=>{this.disposeObject(t)}),this.objects.clear()}},ic=class extends Ah{constructor(e){super();this.flatShading=e}disposeObject(e){e.dispose()}createObject(e,r,o){let n=zo(e,r,this.flatShading,o);return n.computeBoundingSphere(),n}};var sv={markNeedsUpdateRendererDirty:()=>{}};var Eh=require("three");var Ed=1e3,lv=512*Ed;function C3(i,t){let e=typeof i;return!!((t==="string"||t==="number")&&e===t||t==="boolean"&&(i==="true"||i==="false"||i===!0||i===!1)||t==="image"&&e==="string"&&i.startsWith("http"))}var cv="https://hooks.spline.design",A3=`${cv}/events?hashFile=`,AQ=`${cv}/`,Nd=class{constructor(t,e){this.id=t;this.userWebhook=e;this.result=void 0;this._connected=!1;this.emitter=hi();this.reconnectWaitFor=Ed;this._onError=t=>{this.eventSource?.removeEventListener("message",this._onMessage),this.eventSource?.removeEventListener("error",this._onError),this.eventSource?.removeEventListener("open",this._onConnected),this._scheduleReconnect()};this._onConnected=t=>{clearTimeout(this.scheduledReconnectHandle),this.reconnectWaitFor=Ed,this._connected=!0};this._onDisconnected=()=>{clearTimeout(this.scheduledReconnectHandle),this.reconnectWaitFor=Ed,this._connected=!1};this._onMessage=t=>{let e=t.data,r;try{r=JSON.parse(e)}catch(o){console.error("Error parsing webhook message",o)}if(r){let o=!1;this.userWebhook.parametersSchemas.forEach(({data:n})=>{r[n.name]!==void 0&&C3(r[n.name],n.type)&&(this.result===void 0&&(this.result={}),this.result[n.name]=r[n.name],o=!0)}),o&&this.emitter.emit("message",{userWebhookId:this.id})}}}connect(){clearTimeout(this.scheduledReconnectHandle),this.userWebhook.url&&(this.eventSource=new EventSource(A3+this.userWebhook.url),this.eventSource.addEventListener("message",this._onMessage),this.eventSource.addEventListener("error",this._onError),this.eventSource.addEventListener("open",this._onConnected))}disconnect(){this.eventSource?.removeEventListener("message",this._onMessage),this.eventSource?.removeEventListener("error",this._onError),this.eventSource?.removeEventListener("open",this._onConnected),this.eventSource?.close(),this._onDisconnected(),clearTimeout(this.scheduledReconnectHandle)}_scheduleReconnect(){this.reconnectWaitFor*=2,this.reconnectWaitFor>lv&&(this.reconnectWaitFor=lv),clearTimeout(this.scheduledReconnectHandle),this.scheduledReconnectHandle=setTimeout(()=>{this.scheduledReconnectHandle=void 0,this.connect()},this.reconnectWaitFor)}update(t){this.userWebhook=t}dispose(){this._connected&&this.disconnect()}get connected(){return this._connected}on(t,e){this.emitter.on(t,e)}off(t,e){this.emitter.off(t,e)}getParametersKeys(){return this.userWebhook.parametersSchemas.map(t=>t.data.name)}getParameterValue(t){if(this.getParametersKeys().includes(t)){if(this.result)return this.result?.[t];for(let r of this.userWebhook.parametersSchemas)if(r.data.name===t)return Lu.defaultParameterValueByType(r.data.type)}}};var uv=[4186.01,4434.92,4698.63,4978.03,5274.04,5587.65,5919.91,6271.93,6644.88,7040,7458.62,7902.13],M3=["C","C#","D","D#","E","F","F#","G","G#","A","A#","B"],bi=[],_d=[];for(let i=1;i<=8;i++)for(let t=0;t<uv.length;t++){let e=uv[t];bi.push(e/Math.pow(2,8-i)),_d.push(M3[t]+i)}var Dd=[32,2e3],Mh=bi.filter((i,t)=>bi[t]>Dd[0]&&bi[t]<Dd[1]),dv=_d.filter((i,t)=>bi[t]>Dd[0]&&bi[t]<Dd[1]);var Rd=class{static getFrequencies(t,e,r,o="frequency",n=-100,a=-30){r||(r=new Float32Array(t.frequencyBinCount),t.getFloatFrequencyData(r));let s=e/2,l=1/r.length*s,c,u,d;if(o==="music"||o==="voice"){let h=o==="voice"?Mh:bi,m=Array(h.length).fill(n);for(let y=0;y<r.length;y++){let g=y*l,b=r[y];for(let w=h.length-1;w>=0;w--)if(g>h[w]){m[w]=Math.max(m[w],b);break}}c=m,u=o==="voice"?Mh:bi,d=o==="voice"?dv:_d}else c=Array.from(r),u=c.map((h,m)=>l*m),d=u.map(h=>`${h.toFixed(2)} Hz`);let p=c.map(h=>Math.max(0,Math.min((h-n)/(a-n),1)));return{values:new Float32Array(p),frequencies:u,labels:d}}};var I3="gpt-4o-realtime-preview-2024-12-17",E3=()=>!1&&window.location.search.includes("api-dev")?"https://relayserver-dev.spline.design/":"https://relayserver.spline.design/";async function N3(i){try{return(await(await fetch(E3()+"session?uuidfile="+i)).json()).token}catch(t){console.error("Token generation error:",t)}}var Ih=class{constructor(t){this.value=0;this.frequencies=new Float32Array(0);let e=new AudioContext;this.source=e.createMediaStreamSource(t),this.analyser=e.createAnalyser(),this.source.connect(this.analyser),this.analyser.fftSize=8192,this.analyser.smoothingTimeConstant=.1}getFrequencies(t=-100,e=-30){if(!this.analyser)throw new Error("Not connected, please call .connect() first");return Rd.getFrequencies(this.analyser,44100,void 0,"voice",t,e)}update(){let t=this.getFrequencies(),e=t.values.reduce((r,o)=>r+o,0)/t.values.length;this.value=e,this.frequencies=t.values}disconnect(){this.source.disconnect(),this.analyser.disconnect()}},nc=class{constructor(t,e,r){this.data=t;this.id=e;this.shared=r;this.emitter=hi();this.rafId=0;this.voice=0;this.frequencies=new Float32Array([0]);this.events=[];this.isConnected=!1;this.isToolsAdded=!1;this.tools=[];this.onMessage=t=>{let e=JSON.parse(t.data);if(this.appendEvent(e),e.type==="session.created"&&this.onSessionCreated(),e.type==="response.done"&&e.response?.output){for(let r of e.response.output)if(r.type==="function_call")for(let[o,n]of this.tools)r.name===o.name&&(n(JSON.parse(r.arguments)),setTimeout(()=>{this.sendClientEvent({type:"response.create",response:{instructions:"notice the user about what you just did"}})}))}};this.onSessionCreated=()=>{this.isToolsAdded||this.registerTools()};this.onOpen=()=>{this.events=[],this.isConnected=!0,this.sendClientEvent({type:"response.create",response:{instructions:"Say hi"}})};this.animate=()=>{if(this.rafId=requestAnimationFrame(this.animate),this.isConnected&&this.analyser){this.analyser.update();let t=this.analyser.value,e=this.analyser.frequencies;this.voice=t,this.frequencies=e,this.emitter.emit("voice",{value:t,frequencies:e})}}}update(t){this.data=t}setColorByName(t,e){let r=this.shared.getColorByName(t);if(r){let{id:o}=r,{r:n,g:a,b:s}=yb.hexStringToRgb(e)??{r:0,g:0,b:0};this.shared.updateColor(o,{r:n/255,g:a/255,b:s/255})}}async connect(){if(this.isConnected)return;let t=await N3(this.data.integration.hash);this.pc=new RTCPeerConnection,this.audioElement=document.createElement("audio"),this.audioElement.autoplay=!0,this.pc.ontrack=l=>{let c=l.streams[0];this.audioElement.srcObject=c,this.analyser=new Ih(c)};let e=await navigator.mediaDevices.getUserMedia({audio:!0});this.pc.addTrack(e.getTracks()[0]),this.dc=this.pc.createDataChannel("oai-events"),this.dc.addEventListener("message",this.onMessage),this.dc.addEventListener("open",this.onOpen);let r=await this.pc.createOffer();await this.pc.setLocalDescription(r);let s={type:"answer",sdp:await(await fetch(`https://api.openai.com/v1/realtime?model=${I3}`,{method:"POST",body:r.sdp,headers:{Authorization:`Bearer ${t}`,"Content-Type":"application/sdp"}})).text()};await this.pc.setRemoteDescription(s),this.animate()}appendEvent(t){this.events=[t,...this.events]}sendClientEvent(t){this.dc?(t.event_id=t.event_id||crypto.randomUUID(),this.dc.send(JSON.stringify(t)),this.appendEvent(t)):console.error("Failed to send message - no data channel available",t)}registerTools(){this.isToolsAdded=!0,this.registerTool({type:"function",name:"set_personality_color",description:"returns a color based on the voice personality of the ai assistant. This should be called by the voice assistant each time it is asks to speak differently. If a color cannot be associated to the personality, the color should be a neutral color.",parameters:{type:"object",properties:{color:{type:"string",description:"css hex color string, reflecting the personality"},personality:{type:"string",description:"the personality of the voice assistant"}},required:["color","personality"]}},({color:n})=>{this.setColorByName("Voice Assistant Color",n)});let t=this.shared.getVariablesNames().join(", ");this.registerTool({type:"function",name:"set_variable",description:"Sets a Spline variable value when asked by the user.",parameters:{type:"object",properties:{name:{type:"string",description:`The name of the variable that needs to be set. Here's a list of available variables: ${t}. It the variable does not exist, don't call the function and warn the user about it.`},value:{type:"string",description:"The new value for this variable, should always be a string even for number and boolean variables, assume that the value will be cast to the proper type afterwards."}},required:["name","value","type"]}},({name:n,value:a})=>{let s=this.shared.getVariableByName(n);if(s){let l=this.shared.getVariable(s.id),c;typeof l=="number"?c=parseFloat(a):typeof l=="boolean"?c=a.toLowerCase()==="true":c={textValue:a},this.shared.updateVariable(s.id,c)}});let e=this.shared.getColorNames().join(", ");this.registerTool({type:"function",name:"set_color",description:"Sets a Spline color asset value when asked by the user.",parameters:{type:"object",properties:{name:{type:"string",description:`The name of the color asset that needs to be set. Here's a list of available color assets: ${e}. It the color asset does not exist, don't call the function and warn the user about it.`},value:{type:"string",description:"css hex color string"}},required:["name","value"]}},({name:n,value:a})=>{this.setColorByName(n,a)});let r=this.shared.scene,o=[];r.traverseEntity(n=>{n.data.events.forEach(a=>{if(a.data.type==="AIAssistantTrigger"){let{description:s}=a.data;o.push(s)}})}),this.registerTool({type:"function",name:"trigger_event",description:"Trigger an event by name, here are the available events, please match what the user is asking for to one of these if it applies, otherwise don't call the function and warn the user.",parameters:{type:"object",properties:{description:{type:"string",description:`The name of the event that needs to be triggered. Here's a list of available events: ${JSON.stringify(o)}.`},direction:{type:"string",description:"default is forward, but can be forward or backward. Always set to forward unless the user ask to reverse or cancel the event, then set to backward."}},required:["description","direction"]}},({description:n,direction:a})=>{this.emitter.emit("trigger_event",{description:n,direction:a})}),this.sendClientEvent({type:"session.update",session:{tools:this.tools.map(([n])=>n)}})}registerTool(t,e){this.tools.push([t,e])}disconnect(){cancelAnimationFrame(this.rafId),this.analyser?.disconnect(),this.voice=0,this.isConnected=!1,this.isToolsAdded=!1,this.dc?.removeEventListener("message",this.onMessage),this.dc?.removeEventListener("open",this.onOpen),this.dc?.close(),this.pc?.getSenders().forEach(t=>{t.track&&t.track.stop()}),this.pc?.close(),this.pc=void 0}computeAnalysisForListenerEvent(t){if(t.analysis==="range"){let e=this.frequencies.slice(...t.analysisRange);return e.reduce((r,o)=>r+o,0)/e.length}return t.analysis==="single"?this.frequencies[t.analysisSingle]:this.voice}on(t,e){this.emitter.on(t,e)}off(t,e){this.emitter.off(t,e)}};function pv(i){return"variable_"+i}var Nh=class extends Sd{constructor(e){super();this.shared=e}create(e){return new Ds(e,this.shared)}},qn=class{constructor(t,e={},r=!0,o=!1){this.data=t;this.needsJitter=r;this.enableLocalStorageForPersistentVariables=o;this.geometryCache=new ic(!0);this.geometryCache2=new ic(!1);this.imageHolderCache=new Nh(this);this.thisContext={scene:sv,shared:this};this.deletedMaterial=new Hn(Wt.defaultTwoLayerData("phong"),this.thisContext,"");this.deletedImage=new Vr(Gu.emptyImage,this);this.deletedVideo=new Vr(Ra.defaultVideo,this);this.materials={};this.images={};this.uiBuffers={};this.videos={};this.colors={};this.audios={};this.particles={};this.fonts={};this.timelineAnimations={};this.variables={};this.userAPIs={};this.userWebhooks={};this.mouseProperty=null;this.raycastProperty=null;this.requestRender=()=>{this._requestRender&&this._requestRender()};if(e.images)for(let[n,a]of Object.entries(e.images))this.addImage(n,a);if(e.videos)for(let[n,a]of Object.entries(e.videos))this.addVideo(n,a);if(e.audios)for(let[n,a]of Object.entries(e.audios))this.addAudio(n,a);if(e.particles)for(let[n,a]of Object.entries(e.particles))this.addParticle(n,a);this.reset(t)}setRequestRender(t){this._requestRender=t}getImageLoadPromises(){return Object.values(this.images).map(t=>t.loadPromise)}setEntityOpContext(t){this.entityOpContext=t}reset(t,e=!1,r=!1){this.data=t,this.resetLib(t.lib);for(let{id:o,data:n}of t.variables)this.addVariableHolder(o,n),e&&this.updateVariableHolder(o,n);for(let[o,n]of Object.entries(t.userAPIs??{}))this.addUserAPI(o,n);for(let[o,n]of Object.entries(t.userWebhooks??{}))this.addUserWebhook(o,n);if(!r){for(let[o,n]of Object.entries(t.images))this.addImage(o,n);for(let[o,n]of Object.entries(t.videos))this.addVideo(o,n)}for(let[o,n]of Object.entries(t.colors))this.addColor(o,n);for(let[o,n]of Object.entries(t.materials))this.addMaterial(o,n);for(let[o,n]of Object.entries(t.audios))this.addAudio(o,n);for(let[o,n]of Object.entries(t.particles))this.addParticle(o,n);for(let[o,n]of Object.entries(t.fonts))this.addFont(o,n);for(let[o,n]of Object.entries(t.timelineAnimations??{}))this.addAnimation(o,n)}addMaterial(t,e){if(this.materials[t]){let r=this.materials[t];r.reset(e,this.thisContext),r.dispose()}else{let r=new Hn(e,this.thisContext,t);this.materials[t]=r}}deleteMaterial(t){this.materials[t]&&(this.materials[t].nodeMaterialDispose(),delete this.materials[t])}getMaterial(t){let e=this.materials[t];return e}getMaterialOrDeletedPlaceholder(t){return this.materials[t]??this.deletedMaterial}material(t){return typeof t=="string"?this.getMaterialOrDeletedPlaceholder(t):t==null?(console.error("material is undefined or null"),this.deletedMaterial):new kn(t,this.thisContext)}getMaterials(){return this.materials}addImage(t,e){return this.images[t]?(this.onColorOrImageUpdate&&this.onColorOrImageUpdate(),this.images[t].updateSrc(e.data),!0):(this.images[t]=new Vr(e,this),!1)}deleteImage(t){let e=this.images[t];e&&(e.dispose(),delete this.images[t])}getDefaultImage(){return this.images.image_0}getImage(t){return this.images[t]??this.deletedImage}image(t){return typeof t=="string"?this.getImage(t):this.imageHolderCache.load(t)}addUIBuffer(t,e){return this.uiBuffers[t]?(this.onColorOrImageUpdate&&this.onColorOrImageUpdate(),this.uiBuffers[t].updateSrc(e),!0):(this.uiBuffers[t]=new Vr(e,this),!1)}uiBuffer(t){return this.uiBuffers[t]}addVideo(t,e){return this.videos[t]?(this.videos[t].updateSrc(e.data),!0):(this.videos[t]=new Vr(e,this),!1)}deleteVideo(t){let e=this.videos[t];e&&(e.dispose(),delete this.videos[t])}getVideo(t){return this.videos[t]??this.deletedVideo}video(t){return typeof t=="string"?this.getVideo(t):this.imageHolderCache.load(t)}addColor(t,e){return this.colors[t]?(this.onColorOrImageUpdate&&this.onColorOrImageUpdate(),"a"in e?this.colors[t].setRGBA(e.r,e.g,e.b,e.a):this.colors[t].setRGBA(e.r,e.g,e.b,1),!0):("a"in e?this.colors[t]=new Zi(e.r,e.g,e.b,e.a):this.colors[t]=new Zi(e.r,e.g,e.b,1),!1)}updateColor(t,e){if(this.colors[t]){this.onColorOrImageUpdate&&this.onColorOrImageUpdate();let r=this.colors[t];return this.colors[t].r=e.r??r.r,this.colors[t].g=e.g??r.g,this.colors[t].b=e.b??r.b,this.colors[t].a=e.a??r.a,!0}return!1}deleteColor(t){this.colors[t]&&delete this.colors[t]}getColor(t){return this.colors[t]}getColorNames(){return Object.values(this.data.colors).map(t=>t.name)}getColorByName(t){for(let e in this.data.colors)if(this.data.colors[e].name===t)return{color:this.colors[e],id:e}}color(t){let e;if(typeof t=="string"){let r=this.getColor(t);r?e=r:(console.warn("Tried to create color layer params with a color key that does not exist in the assets manager"),e=new qt(0,0,0,0))}else return"a"in t?new qt(t.r,t.g,t.b,t.a):new qt(t.r,t.g,t.b,1);return e}addAudio(t,e){this.audios[t]=e}getAudio(t){let e=this.audios[t];if(e instanceof Wn)return e;{let r=new Wn({src:e.data});return this.audios[t]=r,r}}addParticle(t,e){this.particles[t]=e}getParticle(t){return this.particles[t]}deleteParticle(t){this.particles[t]&&delete this.particles[t]}deleteAudio(t){let e=this.audios[t];e&&(e instanceof Wn&&e.dispose(),delete this.audios[t])}addFont(t,e){this.fonts[t]=new Id(e),this.fonts[t].loadingPromise.then(()=>this.requestRender())}getFont(t){return this.fonts[t]}deleteFont(t){this.fonts[t]&&delete this.fonts[t]}addAnimation(t,e){this.timelineAnimations[t]=e}getAnimation(t){return this.timelineAnimations[t]}deleteAniamtion(t){this.timelineAnimations[t]&&delete this.timelineAnimations[t]}dispose(){Object.keys(this.materials).forEach(e=>this.deleteMaterial(e)),this._requestRender=void 0,Object.values(this.audios).forEach(e=>{e instanceof Wn&&e.dispose()}),this.audios={},this.particles={},this.geometryCache.dispose(),this.geometryCache2.dispose()}addVariableHolder(t,e){if(this.variables[t]===void 0){let r=e.value;if(this.enableLocalStorageForPersistentVariables&&e.persistent){let o=localStorage.getItem(pv(t));r=o!==null?JSON.parse(o):e.value}return this.variables[t]={value:r,locations:[],persistent:e.persistent},"dynamicVariableType"in e&&(this.variables[t].dynamicVariablePlayState="Playing",this.variables[t].dynamicVariableToggleIsForward=void 0),!0}return this.variables[t].value=e.value,!1}resetDynamicVariablePlayState(){for(let t in this.variables)this.variables[t].dynamicVariablePlayState!==void 0&&(this.variables[t].dynamicVariablePlayState="Playing",this.variables[t].dynamicVariableToggleIsForward=void 0)}updateVariableHolder(t,e){this.updateVariable(t,e.value)}updateVariable(t,e){if(this.variables[t]===void 0)return!1;this.variables[t].value=e,this.enableLocalStorageForPersistentVariables&&this.variables[t].persistent&&localStorage.setItem(pv(t),JSON.stringify(e));let r=e;for(;typeof r=="string";)r=this.variables[r].value;let o=this.entityOpContext.scene;for(let n=this.variables[t].locations.length-1;n>=0;n--){let a=this.variables[t].locations[n];if(a[0]==="material"){let s=a[1],l=r,c={scene:o,shared:this},u=a.slice(2);o.traverseMaterial(p=>{let f=p.root??p;f.uuid===s&&f.onVariableUpdate(u,l,c)});let d=this.materials[s];d&&d.onVariableUpdate(u,l,c)}else{let s=o.find(a[0]);if(s===void 0){this.variables[t].locations.splice(n,1);continue}if(a[1]!=="geometry"&&a[1]!=="particles"){for(let l=1;l<a.length-1;l++)s=s[a[l]];a[1]==="rotation"?s[a[a.length-1]]=r*Eh.MathUtils.DEG2RAD:s[a[a.length-1]]=r}if(s=o.find(a[0]),s.type==="ParticleEmitter"&&s.updateVariableState(r,a),Ge.is(s))if(a[1]==="position"||a[1]==="rotation"||a[1]==="scale")s.onVariableUpdate();else if(a[1]==="geometry"){let l=s;s.component&&(l=s.component);let c=l.dataPatched;l.chooseGeoemtryCache(this).forceDelete(c.geometry),l.createGeometryDelayed(this.entityOpContext),l.onVariableUpdate(!0),l.invalidateDownstreamBooleanData(),l.instances.forEach(u=>{let d=u.dataPatched;u.chooseGeoemtryCache(this).forceDelete(d.geometry),u.createGeometryDelayed(this.entityOpContext),u.onVariableUpdate(!0),u.invalidateDownstreamBooleanData()})}else a[1]==="morphTargetInfluences"&&s.updateMorphInfluences(a[2],r)}}return this.requestRender(),!0}deleteVariable(t){this.variables[t]&&delete this.variables[t]}getVariable(t,e){if(Array.isArray(t)){if(t[0]==="mouse")return this.mouseProperty?.[t[1]]??0;if(t[0]==="raycast")return this.raycastProperty?.[t[1]]??0;let r=this.entityOpContext.scene.find(t[0]);if(t[1]==="width"||t[1]==="height"||t[1]==="depth")return r.geometry.userData.parameters[t[1]];for(let o=1;o<t.length;o++)r=r[t[o]];return t[1]==="rotation"&&(r*=Eh.MathUtils.RAD2DEG),r}for(let r in this.variables){if(e===void 0)break;let o=this.variables[r],n=o.locations?.findIndex(a=>dt.equal(a,e));n!==void 0&&n!==-1&&o.locations.splice(n,1)}if(typeof t=="string"){let r=t,o=t;do{if(o=r,this.variables[r]===void 0)break;let n=this.variables[r].value;e&&this.variables[o]!==void 0&&this.variables[o].locations.push(e),r=n}while(typeof r=="string");return r}else return t}getVariables(){return this.variables}getVariablesNames(){return this.data.variables.map(t=>t.data.name)}getVariableByName(t){for(let e of this.data.variables)if(e.data.name===t)return{variable:e.data,id:e.id}}getDynamicVariablePlayState(t){return this.variables[t]?.dynamicVariablePlayState}setDynamicVariablePlayState(t,e){this.variables[t]!==void 0&&(this.variables[t].dynamicVariablePlayState=e)}getDynamicVariableToggleIsForward(t){return this.variables[t]?.dynamicVariableToggleIsForward}setDynamicVariableToggleIsForward(t,e){this.variables[t]!==void 0&&(this.variables[t].dynamicVariableToggleIsForward=e)}resetLib(t){for(let[e,r]of Object.entries(t.images))this.addImage(e,r.asset);for(let[e,r]of Object.entries(t.audios))this.addAudio(e,r.asset);for(let[e,r]of Object.entries(t.particles))this.addParticle(e,r.asset);for(let[e,r]of Object.entries(t.colors))this.addColor(e,r.asset);for(let[e,r]of Object.entries(t.fonts))this.addFont(e,r.asset);for(let[e,r]of Object.entries(t.materials))this.addMaterial(e,r.asset);for(let[e,r]of Object.entries(t.videos))this.addVideo(e,r.asset);for(let[e,r]of Object.entries(t.variables))this.addVariableHolder(e,r.asset)}updateLibByOp(t,e){t.path[0]==="images"?t.path.length===1&&t.type===1?this.addImage(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteImage(t.id):t.path[0]==="videos"?t.path.length===1&&t.type===1?this.addVideo(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteVideo(t.id):t.path[0]==="audios"?t.path.length===1&&t.type===1?this.addAudio(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteAudio(t.id):t.path[0]==="particles"?t.path.length===1&&t.type===1?this.addParticle(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteParticle(t.id):t.path[0]==="colors"?t.path.length===1&&t.type===1?this.addColor(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteColor(t.id):t.path[0]==="materials"?t.path.length===1&&t.type===1?this.addMaterial(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteMaterial(t.id):t.path[0]==="fonts"?t.path.length===1&&t.type===1?this.addFont(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteFont(t.id):t.path[0]==="variables"?t.path.length===1&&t.type===1?this.addVariableHolder(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteVariable(t.id):t.path[0]==="components"&&e.updateByLibOp(t,this)}updateByOp(t,e,r){if(this.data=e,t.path[0]==="images")t.path.length===2&&t.type===0?t.props.data&&this.getImage(t.path[1]).updateSrc(t.props.data):t.path.length===1&&t.type===1?this.addImage(t.id,t.data):t.path.length===1&&t.type===2&&this.deleteImage(t.id);else if(t.path[0]==="videos")t.path.length===2&&t.type===0?t.props.data&&this.getVideo(t.path[1]).updateSrc(t.props.data):t.path.length===1&&t.type===1?this.addVideo(t.id,t.data):t.path.length===1&&t.type===2&&this.deleteVideo(t.id);else if(t.path[0]==="audios")t.path.length===2&&t.type===0?t.props.data&&this.addAudio(t.path[1],e.audios[t.path[1]]):t.path.length===1&&t.type===1?this.addAudio(t.id,t.data):t.path.length===1&&t.type===2&&this.deleteAudio(t.id);else if(t.path[0]==="particles")t.path.length===2&&t.type===0?t.props.data&&this.addParticle(t.path[1],e.particles[t.path[1]]):t.path.length===1&&t.type===1?this.addParticle(t.id,t.data):t.path.length===1&&t.type===2&&this.deleteParticle(t.id);else if(t.path[0]==="colors")t.path.length===2&&t.type===0?this.updateColor(t.path[1],t.props):t.path.length===1&&t.type===1?this.addColor(t.id,t.data):t.path.length===1&&t.type===2&&this.deleteColor(t.id);else if(t.path[0]==="materials")t.path.length===1&&t.type===1?this.addMaterial(t.id,t.data):t.path.length===1&&t.type===2?this.deleteMaterial(t.id):t.path.length>1&&this.getMaterial(t.path[1]).updateByOp(vt.drop(t,2),e.materials[t.path[1]],{shared:this,scene:r});else if(t.path[0]==="fonts")t.path.length===2&&t.type===0?this.updateFont(t.path[1],t,r):t.path.length===1&&t.type===1?this.addFont(t.id,t.data):t.path.length===1&&t.type===2&&this.deleteFont(t.id);else if(t.path[0]==="variables")t.path.length===2&&t.type===0?"value"in t.props?this.updateVariable(t.path[1],t.props.value):"persistent"in t.props&&(this.variables[t.path[1]].persistent=t.props.persistent):t.path.length===1&&t.type===4?this.addVariableHolder(t.id,t.data):t.path.length===1&&t.type===5&&this.deleteVariable(t.id);else if(t.path[0]==="userAPIs"){if(t.path.length===1&&t.type===1)this.addUserAPI(t.id,t.data);else if(t.path.length===1&&t.type===2)this.deleteUserAPI(t.id);else if(typeof t.path[1]=="string"){let o=e.userAPIs[t.path[1]];if(o){let n=t.type===0&&t.props.debounce===void 0,a=this.getUserAPI(t.path[1]);a instanceof nc?a.update(o):a?.update(o,this,n)}}}else if(t.path[0]==="userWebhooks"){if(t.path.length===1&&t.type===1)this.addUserWebhook(t.id,t.data);else if(t.path.length===1&&t.type===2)this.deleteUserWebhook(t.id);else if(typeof t.path[1]=="string"){let o=e.userWebhooks[t.path[1]];o&&this.getUserWebhook(t.path[1])?.update(o)}}else t.path[0]==="lib"&&this.updateLibByOp(vt.drop(t,1),r)}updateFont(t,e,r){if(e.props.url){let o=this.getFont(t),n={...this.data.fonts[t],url:e.props.url};o.update(n),o.loadingPromise.then(()=>this.requestRender()),r.updateFont(t,this)}}addUserAPI(t,e){return this.userAPIs[t]?(this.userAPIs[t].update(e,this),!0):this.openAIRealtime?.id===t?(this.openAIRealtime.update(e),!0):e.integration?.type==="VoiceAssistant"?(this.openAIRealtime=new nc(e,t,this),!1):(this.userAPIs[t]=new ad(t,e,this),!1)}getUserAPI(t){return this.openAIRealtime?.id===t?this.openAIRealtime:this.userAPIs[t]}getUserAPIs(){return this.userAPIs}deleteUserAPI(t){let e=this.userAPIs[t];e&&(e.dispose(),delete this.userAPIs[t])}addUserWebhook(t,e){return this.userWebhooks[t]?(this.userWebhooks[t].update(e),!0):(this.userWebhooks[t]=new Nd(t,e),!1)}getUserWebhook(t){return this.userWebhooks[t]}getUserWebhooks(){return this.userWebhooks}deleteUserWebhook(t){let e=this.userWebhooks[t];e&&(e.dispose(),delete this.userWebhooks[t])}get scene(){return this.entityOpContext.scene}},fv=new qn(qr.emptyData());var Er=class extends Xt{updateByPatchedOp(e,r,o){if(super.updateByPatchedOp(e,r,o),Jg(e.path,["materials"])!==null&&e.type===0&&Array.isArray(this.material))for(let[n,a]of Object.entries(e.props)){let s=o.shared.material(a);this.material[Number(n)]=s}else if(Ue(e.path,["material"])&&this.material instanceof Ir)"material"in r&&typeof r.material!="string"&&this.material.updateByOp(vt.drop(e,1),r.material,o);else if(Ue(e.path,["materials","*"])&&Array.isArray(this.material)){let n=e.path[1];if("materials"in r&&n<this.material.length){let a=r.materials[n];typeof a!="string"&&this.material[n].updateByOp(vt.drop(e,2),a,o)}}}get needsAO(){return this.material!==void 0?(Array.isArray(this.material)?this.material[0]:this.material).hasAO:!1}updateState(e,r){super.updateState(e,r),e.castShadow!==void 0&&(this.castShadow=e.castShadow),e.receiveShadow!==void 0&&(this.receiveShadow=e.receiveShadow);let o=this.dataPatched;this.dataPatched.type==="Mesh"&&!!this.dataPatched.geometry.shapeBlendNode&&this.layers.set(9);let a;this.dataPatched.type==="Mesh"&&this.dataPatched.geometry.type==="ShapeBlendGeometry"&&(a={resolutionLevel:this.dataPatched.geometry.resolutionLevel,useChildrenColors:this.dataPatched.geometry.useChildrenColors}),e.geometry?.type!=="NonParametricGeometry"&&"material"in e&&e.material!==void 0&&(this.disposeMaterial(),this.material=r.shared.material(e.material).getFlavor(o.flatShading,o.side,o.wireframe,a),r.scene.markNeedsUpdateRendererDirty()),(e.geometry?.type==="NonParametricGeometry"||"materials"in e)&&("materials"in e&&e.materials!==void 0?(this.disposeMaterial(),this.material=e.materials.map(l=>r.shared.material(l).getFlavor(o.flatShading,o.side,o.wireframe)),r.scene.markNeedsUpdateRendererDirty()):"material"in e&&e.material!==void 0&&(this.disposeMaterial(),this.material=[r.shared.material(e.material).getFlavor(o.flatShading,o.side,o.wireframe)],r.scene.markNeedsUpdateRendererDirty()));let s=this.data;if(s.geometry?.type!=="NonParametricGeometry"&&"materials"in s&&s.materials!==void 0&&(this.disposeMaterial(),this.material=r.shared.material(s.materials[0]).getFlavor(o.flatShading,o.side,o.wireframe)),e.flatShading!==void 0||e.wireframe!==void 0||e.side!==void 0)if(Array.isArray(this.material))for(let l=0;l<this.material.length;l++)this.material[l]=this.material[l].getFlavor(o.flatShading,o.side,o.wireframe);else this.material=this.material.getFlavor(o.flatShading,o.side,o.wireframe,a)}disposeMaterial(){this.material&&Ic(this.material).forEach(e=>{e instanceof Ir&&(e instanceof Hn||e.nodeMaterialDispose())})}dispose(){this.disposeMaterial(),super.dispose()}};var zr=require("three");var hv=new zr.Vector3,mv=new zr.Vector4,yv=new zr.Vector4,_3=new zr.Vector3,gv=new zr.Matrix4,ht=class extends Er{constructor(e,r,o){super(e,r);this.data=r;this.isSkinnedMesh=!1;this.localGeometry=void 0,r.bindMode&&r.bindMatrix&&(this.bindMode=r.bindMode,this.bindMatrix=new zr.Matrix4().fromArray(r.bindMatrix),this.bindMatrixInverse=new zr.Matrix4)}chooseGeoemtryCache(e){return e.geometryCache}markGeometryAsReachable(e){this.geometryCreateDeleyed instanceof zr.BufferGeometry&&this.chooseGeoemtryCache(e).markAsReachable(this.dataPatched.geometry,this.geometryCreateDeleyed)}get geometry(){if(this.localGeometry!==void 0)return this.localGeometry;if(this.geometryCreateDeleyed instanceof qn){let e=this.geometryCreateDeleyed,r=this.chooseGeoemtryCache(e);this.geometryCreateDeleyed=r.get(this.dataPatched.geometry,e,this)}return this.geometryCreateDeleyed}set geometry(e){this.localGeometry=e}get is2DAndNoDepth(){let e=this.dataPatched.geometry;return vl.is2DParametricMesh(e.type)&&e.depth===0}get is2DType(){return vl.is2DParametricMesh(this.geometry.userData.type)}get isNonParametric(){return this.geometry.userData.type==="NonParametricGeometry"}updateByPatchedOp(e,r,o){super.updateByPatchedOp(e,r,o),Ue(e.path,["geometry"])&&this.updateByPatchedOpGeometry(vt.drop(e,1),r.geometry,o)}removeInteractionGeometry(e){this.localGeometry?.dispose(),this.localGeometry=void 0}updateGeometryInteractions(e,r){this.invalidateDownstreamBooleanData();let o=this.data.geometry.type;if(o==="NonParametricGeometry"||o==="SubdivGeometry"){let n=e;if(this.localGeometry===void 0){let f={...this.data.geometry,...n};this.localGeometry=zo(f,r,this.data.flatShading,this)}let a,s,l;n.scaleBaked?[a,s,l]=n.scaleBaked:{width:a,height:s,depth:l}=n;let c=this.localGeometry.userData,u=typeof a=="number"?a:1,d=typeof s=="number"?s:1,p=typeof l=="number"?l:1;c.sxPrev!==void 0&&jl(this.localGeometry.attributes,u/c.sxPrev,d/c.syPrev,p/c.szPrev),c.sxPrev=u,c.syPrev=d,c.szPrev=p}else{let n={...this.data.geometry,...e};this.localGeometry?.dispose(),this.localGeometry=zo(n,r,this.data.flatShading,this)}}refreshAttachedClonersInteractions(e){for(let r of this.attachedSurfaceCloners)r.update(e)}refreshAttachedCloners(e){for(let r of this.attachedSurfaceCloners)e.scene.addPendingUpdateCloner(r.object)}refreshAttachedPaths(e){for(let r of this.attachedPaths)e.scene.addPendingCommand(()=>r.updateShape())}createGeometryDelayed(e){this.geometryCreateDeleyed=e.shared,this.refreshAttachedCloners(e),this.refreshAttachedPaths(e)}updateByPatchedOpGeometry(e,r,o){let n=!1;e.type===0&&e.path.length===0&&Object.keys(e.props).includes("scaleBaked")&&this.geometryCreateDeleyed instanceof zt&&this.chooseGeoemtryCache(o.shared).mutateIfUnique(this.geometryCreateDeleyed.data,r)===this.geometryCreateDeleyed&&(n=!0,this.geometryCreateDeleyed.mutateDirectlyScaleBaked(r,e.props.scaleBaked),this.refreshAttachedCloners(o),this.refreshAttachedPaths(o)),n||(o.scene?.markGeometryCacheDirty(),this.createGeometryDelayed(o)),this.resetBBoxNeedsUpdate(),this.invalidateDownstreamBooleanData()}updateGeometryOnStateUpdate(e,r){this.createGeometryDelayed(r)}updateState(e,r){e.geometry!==void 0&&this.updateGeometryOnStateUpdate(e.geometry,r);let o=e.morphTargetInfluences;if(o){this.updateMorphTargets(),this.geometry.morphTargetsRelative=!0;for(let{data:{name:n,value:a}}of o)this.updateMorphInfluences(n,r.shared.getVariable(a,[this.uuid,"morphTargetInfluences",n]))}super.updateState(e,r)}updateMorphInfluences(e,r){if(this.morphTargetDictionary===void 0)return;let o=this.morphTargetDictionary[e];o!==void 0&&(this.morphTargetInfluences[o]=r)}updateGeometryGroupsIfNeeded(){Array.isArray(this.material)&&this.geometry.groups.length===0&&this.geometry.addGroup(0,Math.max(this.geometry.getIndex()?.count??0,this.geometry.getAttribute("position").count),0)}updateEntityBoxSize(e,r){let o=this.geometry.userData.parameters;this.is2DType?e.set(0,0,o.depth*.5):this.isNonParametric?(e.setScalar(0),this.geometry.boundingSphere&&e.copy(this.geometry.boundingSphere.center),r.set(o.width,o.height,o.depth??0).multiplyScalar(.5)):o.centerOffset?e.fromArray(o.centerOffset):e.setScalar(0),r.set(o.width,o.height,o.depth??0).multiplyScalar(.5)}updateMatrixWorld(e){super.updateMatrixWorld(e),this.bindMode==="attached"?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode==="detached"&&this.bindMatrixInverse.copy(this.bindMatrix).invert()}bind(e,r){this.skeleton=e,this.isSkinnedMesh=!0,r===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),r=this.matrixWorld),this.bindMatrix.copy(r),this.bindMatrixInverse.copy(r).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(e){let r=new zr.Vector4,o=this.geometry.attributes.skinWeight;for(let n=0,a=o.count;n<a;n++){r.fromBufferAttribute(o,n);let s=1/r.manhattanLength();s!==1/0?r.multiplyScalar(s):r.set(1,0,0,0),o.setXYZW(n,r.x,r.y,r.z,r.w)}}boneTransform(e,r){let o=this.skeleton;if(o===void 0)return;let n=this.geometry;mv.fromBufferAttribute(n.attributes.skinIndex,e),yv.fromBufferAttribute(n.attributes.skinWeight,e),hv.copy(r).applyMatrix4(this.bindMatrix),r.set(0,0,0);for(let a=0;a<4;a++){let s=yv.getComponent(a);if(s!==0){let l=mv.getComponent(a);gv.multiplyMatrices(o.bones[l].matrixWorld,o.boneInverses[l]),r.addScaledVector(_3.copy(hv).applyMatrix4(gv),s)}}return r.applyMatrix4(this.bindMatrixInverse)}};function R3(i){if(i.geometry.attributes.extrudeNormal||!i.geometry.attributes.position||!i.geometry.attributes.normal)return;let t=new Map,e=i.geometry.attributes,r=e.position.array,o=e.normal.array,n=new Float32Array(r.length);for(let a=0;a<r.length;a+=3){let s=`${r[a]}_${r[a+1]}_${r[a+2]}`,l=new Gr.Vector3(o[a],o[a+1],o[a+2]);t.has(s)?t.get(s)?.normals.push(l):t.set(s,{normals:[l],result:new Gr.Vector3})}t.forEach((a,s)=>{for(let l of a.normals)a.result.add(l);a.result.divideScalar(a.normals.length)});for(let a=0;a<r.length;a+=3){let s=`${r[a]}_${r[a+1]}_${r[a+2]}`,l=t.get(s)?.result;l&&(n[a]=l.x,n[a+1]=l.y,n[a+2]=l.z)}i.geometry.setAttribute("extrudeNormal",new Gr.Float32BufferAttribute(n,3))}function L3(i){if(i.geometry.attributes.extrudeNormals||!i.geometry.attributes.position)return;let e=i.geometry.attributes.position.array,r=new Float32Array(e.length),o=new Gr.Vector3;for(let n=0;n<e.length;n+=3)o.set(e[n],e[n+1],e[n+2]).normalize(),r[n]=o.x,r[n+1]=o.y,r[n+2]=o.z;i.geometry.setAttribute("extrudeNormal",new Gr.Float32BufferAttribute(r,3))}function Ls(i){if(Array.isArray(i.material)){for(let t of i.material)if(t.getLayersOfType("outline").length===0)return}else if(!(i.material instanceof Ir)||i.material.getLayersOfType("outline").length===0)return;i instanceof ht&&i.is2DAndNoDepth?L3(i):R3(i)}function Bs(i){if(!i.geometry.attributes.position)return;let e=i.geometry.attributes.position.array,r=new Float32Array(e.length),o=parseInt(i.uuid.replace(/\D/g,"")),n=[Gr.MathUtils.seededRandom(o),Gr.MathUtils.seededRandom(o+1e4),Gr.MathUtils.seededRandom(o+2e4)];for(let a=0;a<e.length;a++)r[a]=n[a%3];i.geometry.setAttribute("randomColor",new Gr.BufferAttribute(r,3))}var Uo=new vi.Box3,ac=new vi.Vector3;function xv(i){let t=!1;return i.scene.objects.traverse((e,r)=>{r.type==="Mesh"&&r.geometry.type==="SubdivGeometry"&&(t=!0)}),t}var $n=class extends ht{constructor(e,r,o){super(e,r,o);this.data=r;this.hiddenMatrixOld=new vi.Matrix4;this.smoothShading=!0;this.skipReactionUpdate=!1}chooseGeoemtryCache(e){return this.dataPatched.flatShading?e.geometryCache:e.geometryCache2}get subdivPointerNew(){return this.localGeometry!==void 0?this.subdivPointer:this.geometry.ensureSubdivPointer()}get originalGeometryNew(){return this.localGeometry!==void 0?this.originalGeometry:this.geometry.originalGeometry}get phongAngle(){return this.data.geometry.phongAngle??45}updateEntityBoxSize(e,r){let o=this.geometry.userData.parameters;e.copy(this.originalGeometryNew.boundingSphere.center),r.set(o.width,o.height,o.depth??0).multiplyScalar(.5)}createGeometryByControls(e){if(this.skipReactionUpdate===!0)return;let r=this.localGeometry?.uuid,{originalGeometry:o,subdividedGeometry:n,subdivPointer:a}=zt.build(e,this.subdivPointer,this.smoothShading,this.hasNonUniformScale?this.shearScale:void 0);this.subdivPointer=a,o!==void 0&&(this.originalGeometry?.dispose(),this.originalGeometry=o),n!==void 0&&(this.subdividedGeometry?.dispose(),this.subdividedGeometry=n??void 0),this.localGeometry=this.subdividedGeometry??this.originalGeometry,Ls(this),Bs(this),this.calcBoundingBox(),r&&(this.localGeometry.uuid=r)}updateState(e,r){if(super.updateState(e,r),e.flatShading!==void 0){let o=this.material;this.material=Array.isArray(o)?o.map(n=>n.getFlavor(!1,n.side,n.wireframe)):o.getFlavor(!1,o.side,o.wireframe),this.smoothShading=!e.flatShading,this.createGeometryDelayed(r)}}updateMesh(e=!1){zt.buildLevel(this.subdivPointer,!0,this.smoothShading?this.phongAngle:-1,this.originalGeometry,e&&this.hasNonUniformScale?this.shearScaleInv:void 0),this.subdividedGeometry&&zt.buildLevel(this.subdivPointer,!1,this.smoothShading?this.phongAngle:-1,this.subdividedGeometry,e&&this.hasNonUniformScale?this.shearScaleInv:void 0)}updateTopology(){this.originalGeometry.dispose(),this.originalGeometry=zt.buildLevel(this.subdivPointer,!0,this.smoothShading?this.phongAngle:-1),this.subdividedGeometry&&(this.subdividedGeometry.dispose(),this.subdividedGeometry=zt.buildLevel(this.subdivPointer,!1,this.smoothShading?this.phongAngle:-1)),this.localGeometry=this.subdividedGeometry??this.originalGeometry}raycast(e,r){let o=this.localGeometry;this.localGeometry=this.originalGeometryNew,Xt.prototype.raycast.call(this,e,r),this.localGeometry=o}activateSVDCompensation(){!this.hasNonUniformScale||(this.matrix.copy(this.matrixWorldRigid),this.hiddenMatrixOld.copy(this.hiddenMatrix),this.hiddenMatrix.copy(this.parent.matrixWorld).invert())}deactivateSVDCompensation(){!this.hasNonUniformScale||(this.updateMatrix(),this.hasNonUniformScale=void 0,this.hiddenMatrix.copy(this.hiddenMatrixOld))}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new vi.Sphere,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let r=e.attributes.position,o=e.boundingSphere.center;Uo.setFromBufferAttribute(r),Uo.getCenter(o),e.boundingSphere.radius=o.distanceTo(Uo.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),Uo.getSize(ac),this.hasNonUniformScale&&ac.divide(this.scale);let n={width:ac.x,height:ac.y,depth:ac.z};return this.geometry.userData.parameters=n,n}updateBoundingSphere(e){let r=this.originalGeometry;Uo.min.set(e[0],e[2],e[4]),Uo.max.set(e[1],e[3],e[5]),this.hasNonUniformScale&&(Uo.min.applyMatrix4(this.shearScaleInv),Uo.max.applyMatrix4(this.shearScaleInv)),r.boundingSphere===null&&(r.boundingSphere=new vi.Sphere);let o=r.boundingSphere.center;Uo.getCenter(o),r.boundingSphere.radius=o.distanceTo(Uo.max)}freeSubdivPointer(){this.subdivPointer&&(zt.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0),this.localGeometry=void 0,this.originalGeometry?.dispose(),this.subdividedGeometry?.dispose()}dispose(){super.dispose(),this.freeSubdivPointer()}updateByPatchedOpGeometry(e,r,o){super.updateByPatchedOpGeometry(e,r,o),this.localGeometry&&this.createGeometryByControls(r)}};var ko=require("three"),bv=-1,B3=1,vv={x:[1,0,0],"-x":[-1,0,0],y:[0,1,0],"-y":[0,-1,0],z:[0,0,1],"-z":[0,0,-1]},Sv={polygon_center:0,edge:1,vertex:2},sc=(i,t)=>(e,r)=>!t||e===0||i===0?0:i*r/100,Ne=(i,t)=>{let e=Math.abs(t),r=e*-1;return(i-bv)*(e-r)/(B3-bv)+r},V3=new ko.Vector3,Ld=new ko.Vector3,z3=new ko.Vector3,G3=new ko.Vector3;function Vs(i,t){let e=z3.fromArray(i),r=G3.fromArray(t);Ld.copy(r).sub(e);let o=Ld.length();return Ld.normalize().multiplyScalar(o*.5),V3.copy(e).add(Ld).toArray()}var Kr=new ko.Triangle,Bd=new ko.Vector3,Vd=new ko.Vector3,Xn=new ko.Vector3;function wv(i){let t=[];for(let e=0;e<=i.index.count;e++)if(Bd.fromArray(i.index.array,e*3),Kr.setFromAttributeAndIndices(i.attributes.position,Bd.x,Bd.y,Bd.z),Kr.getNormal(Vd),Kr.getMidpoint(Xn),!(isNaN(Xn.x)||isNaN(Xn.y)||isNaN(Xn.z))){let{a:r,b:o,c:n}=Kr,a=r.toArray(),s=o.toArray(),l=n.toArray(),c=r.distanceTo(o),u=o.distanceTo(n),d=n.distanceTo(r),p=Vs(a,s),f=Vs(s,l),h=Vs(l,a),m=[c,u,d],y=Math.max(...m),g=m.filter(P=>Math.round(P)===Math.round(y)).length>1,b=[],w=Kr.getMidpoint(Xn).toArray();y===c&&!g&&(b=[f,h,h],w=p),y===u&&!g&&(b=[p,h,h],w=f),y===d&&!g&&(b=[p,f,f],w=h),g&&(b=[p,f,h]),t.push({vertices:[a,s,l],faceCenters:b,midpoint:w,norm:Kr.getNormal(Vd).toArray()})}return t}function Pv(i){let t=[],{position:e}=i.attributes;for(let r=0;r<e.count;r++){Kr.setFromAttributeAndIndices(e,r*3,r*3+1,r*3+2),Kr.getNormal(Vd),Kr.getMidpoint(Xn);let o=Kr.a.toArray(),n=Kr.b.toArray(),a=Kr.c.toArray();t.push({vertices:[o,n,a],faceCenters:[Vs(o,n),Vs(n,a),Vs(a,o)],midpoint:Xn.toArray(),norm:Vd.toArray()})}return t}var F3=4,j3=.5,_h=i=>.5*(1-Math.cos(i*Math.PI)),Rh=class{constructor(){this.perlin=new Array(4095+1)}noise(t,e=0,r=0){if(this.perlin==null){this.perlin=new Array(4095+1);for(let g=0;g<4095+1;g++)this.perlin[g]=Math.random()}t<0&&(t=-t),e<0&&(e=-e),r<0&&(r=-r);let o=Math.floor(t),n=Math.floor(e),a=Math.floor(r),s=t-o,l=e-n,c=r-a,u,d,p=0,f=.5,h,m,y;for(let g=0;g<F3;g++){let b=o+(n<<4)+(a<<8);u=_h(s),d=_h(l),h=this.perlin[b&4095],h+=u*(this.perlin[b+1&4095]-h),m=this.perlin[b+16&4095],m+=u*(this.perlin[b+16+1&4095]-m),h+=d*(m-h),b+=256,m=this.perlin[b&4095],m+=u*(this.perlin[b+1&4095]-m),y=this.perlin[b+16&4095],y+=u*(this.perlin[b+16+1&4095]-y),m+=d*(y-m),h+=_h(c)*(m-h),p+=h*f,f*=j3,o<<=1,s*=2,n<<=1,l*=2,a<<=1,c*=2,s>=1&&(o++,s--),l>=1&&(n++,l--),c>=1&&(a++,c--)}return p}noiseSeed(t){let e=(()=>{let a,s;return{setSeed(l){s=a=(l??Math.random()*4294967296)>>>0},getSeed(){return a},rand(){return s=(1664525*s+1013904223)%4294967296,s/4294967296}}})();e.setSeed(t),this.perlin=new Array(4095+1);for(let r=0;r<4095+1;r++)this.perlin[r]=e.rand()}},Ov=Rh;var zs=require("three");var Tv=new zs.Vector3,Cv=new zs.Matrix4,Av=new zs.Ray;function Mv(i){let t=!1;return i.scene.objects.traverse((e,r)=>{r.type==="Mesh"&&(r.geometry.type==="TextGeometry"||r.geometry.type==="InputGeometry")&&(t=!0)}),t}var rn=class extends ht{constructor(e,r,o){super(e,r,o);this.data=r}get textGeometry(){return this.geometry}get charWidths(){return this.textGeometry.charWidths}get charCoords(){return this.textGeometry.charCoords}get wrappedText(){return this.textGeometry.wrappedText}get font(){return this.textGeometry.font}get initialOffsetY(){let e=this.dataPatched;return this.font?.getLineInitialOffsetY(this.lineHeight,this.wrappedText.length,typeof e.geometry.height=="number"?e.geometry.height:1,this.fontScale,e.geometry.verticalAlign)??0}get fontScale(){let e=this.dataPatched;return this.font?e.geometry.fontSize/this.font.unitsPerEm:1}get AD(){return Math.abs(this.ascender-this.descender)}get ascender(){return(this.font?.ascender??1)*this.fontScale}get descender(){return(this.font?.descender??1)*this.fontScale}get lineHeight(){let e=this.dataPatched;return e.geometry.fontSize*e.geometry.lineHeight}raycast(e,r){let{matrixWorld:o}=this;if(!(isNaN(e.ray.origin.x)||this.scale.x===0||this.scale.y===0||this.scale.z===0)&&(Cv.copy(o).invert(),Av.copy(e.ray).applyMatrix4(Cv),Av.intersectBox(this.singleBBox,Tv))){let n=Tv.applyMatrix4(o),a=e.ray.origin.distanceTo(n);r.push({distance:a,point:n.clone(),object:this})}}};var br=1e-4,Ho,Nv,Dv,_v,Iv=new tt.Vector3,Ev=new tt.Vector3;ld.then(i=>{Ho=i,Nv=[Ho.get_face_center,Ho.get_edge_midpoint,Ho.get_vertex_position],Dv=[Ho.get_face_normal,Ho.get_edge_normal,Ho.get_vertex_normal],_v=[Ho.face_count,Ho.edge_count,Ho.vertex_count]});var U3=new tt.Matrix4,k3=new tt.Matrix4,on=new tt.Vector3,zd=new tt.Vector3,lc=new tt.Vector3,Lh=new tt.Vector3,H3=new tt.Vector3,W3=new tt.Vector3;function St(i,t){return[typeof i?.[0]=="number"?i[0]:typeof i?.[0]=="string"&&t?parseFloat(String(t.shared.getVariable(i[0])??"0")):0,typeof i?.[1]=="number"?i[1]:typeof i?.[1]=="string"&&t?parseFloat(String(t.shared.getVariable(i[1])??"0")):0,typeof i?.[2]=="number"?i[2]:typeof i?.[2]=="string"&&t?parseFloat(String(t.shared.getVariable(i[2])??"0")):0]}var Bh=class{constructor(t,e){this.data=t;this.is3D=e;this.perlin=new Ov;t.noiseType==="perlin"?(this.perlin.noiseSeed(t.seed),e?this.noise=(o,n,a)=>this.perlin.noise(o,n,a):this.noise=o=>this.perlin.noise(o)):e?this.noise=cx((0,Gd.default)(t.seed)):this.noise=lx((0,Gd.default)(t.seed??""))}},nn=class extends Ha(tt.Object3D){constructor(e,r){super();this.parameters=r;this.objectForSample=void 0;this._pendingMediaLoad=!1;this.random=null;this.object=e}resetOnMove(){this.removeFromParent(),this.parent=null}expandClones(e){if(this.parent===null)this.updateState(this.parameters,e);else for(let r of this.children)r instanceof co&&r.expand()}invalidateTransform(e){this.matrixWorldNeedsUpdate=!0,this.traverse(r=>{r instanceof co&&r.object===e&&(r.matrixWorldNeedsUpdate=!0)})}onObjUpdateMatrix(){this.parameters.type!=="toObject"&&(this.matrixWorldNeedsUpdate=!0)}update(e){switch(this._updateCount(e),this.parameters.type){case"radial":this._updateRadial(this.parameters,e);break;case"linear":this._updateLinear(this.parameters,e);break;case"grid":this._updateGrid(this.parameters,e);break;case"toObject":this._updateToObject(this.parameters,e)}for(let r of this.children)r.updateMatrix(),r.hasNonUniformScale&&(r.updateMatrixWorld(),r.updateMatrixWorldSVD())}_updateCount(e,r){let o;if(r!==void 0)o=r;else{let n=St(this.parameters.grid.count,e);o=this.parameters.type==="grid"?Math.round(n[0])*Math.round(n[1])*Math.round(n[2]):this.parameters.count}if(this.parameters.type==="toObject"){if(!this.parameters.toObject.object)o=0;else if(r===void 0&&this.parameters.toObject.spreadType!=="random")return}if(this.parameters.type==="toObject"&&this.objectForSample){let n=this.children;if(n.length===o)return;if(n.length<o)for(let a=0,s=o-n.length;a<s;++a){let l=new co(this.object);l.expand(),this.add(l)}else for(let a=0,s=n.length-o;a<s;++a)this.remove(n[a])}else{if(this.children.length===o)return;if(this.children.length<o)for(let n=0,a=o-this.children.length;n<a;++n){let s=new co(this.object);s.expand(),this.add(s)}else for(let n=0,a=this.children.length-o;n<a;++n)this.remove(this.children[n])}}getRandom(e,r=!1){return(this.random===null||this.random.data.seed!==e.seed||this.random.is3D!==r)&&(this.random=new Bh(e,r)),this.random}_updateRadial(e,r){let o=e.radial,n=o.start*tt.MathUtils.DEG2RAD,a=o.end*tt.MathUtils.DEG2RAD,s=n-a,l=St(o.rotation,r),c=new tt.Euler(l[0],l[1],l[2]),u;switch(o.axis){case"z":u=new tt.Vector3(0,0,1);break;case"y":u=new tt.Vector3(0,1,0);break;default:case"x":u=new tt.Vector3(1,0,0);break}let d=e.randomnessObject??No.defaultData([1,1,1]).randomnessObject,p=this.getRandom(d),f=sc(d.strength,this.parameters.randomness);for(let[h,m]of this.children.entries()){let y=h*(d.freqScale/10)+d.movement,g=p.noise(y,y,y),b=h+1,w=St(o.scale,r),P=St(d.scale,r);m.scale.x=w[0]+f(b,Ne(g,P[0]))||br,m.scale.y=w[1]+f(b,Ne(g,P[1]))||br,m.scale.z=w[2]+f(b,Ne(g,P[2]))||br,m.position.setScalar(0);let S=s/e.count*h-n;switch(o.axis){case"x":m.rotation.set(0,S,0);break;case"y":m.rotation.set(0,0,S);break;case"z":m.rotation.set(S,0,0);break}m.translateOnAxis(u,o.radius);let T=St(o.position,r),A=St(d.position,r);m.position.x+=T[0]+f(b,Ne(g,A[0])),m.position.y+=T[1]+f(b,Ne(g,A[1])),m.position.z+=T[2]+f(b,Ne(g,A[2]));let x=St(d.rotation,r),N=f(b,Ne(g,x[0])),E=f(b,Ne(g,x[1])),M=f(b,Ne(g,x[2]));o.alignment===!0?(m.rotation.x+=c.x+N,m.rotation.y+=c.y+E,m.rotation.z+=c.z+M):m.rotation.set(c.x+N,c.y+E,c.z+M)}}_updateLinear(e,r){if(e.type!=="linear")throw new Error;let o=e.linear,n=St(o.rotation,r),a=St(o.scale,r),s=St(o.position,r),l=new tt.Euler(n[0]??0,n[1]??0,n[2]??0),c=e.randomnessObject??No.defaultData([1,1,1]).randomnessObject,u=St(c.rotation,r),d=St(c.scale,r),p=St(c.position,r),f=this.getRandom(c),h=sc(c.strength,this.parameters.randomness);for(let[m,y]of this.children.entries()){let g=m*(c.freqScale/10)+c.movement,b=f.noise(g,g,g),w=m+1,P=h(w,Ne(b,u[0])),S=h(w,Ne(b,u[1])),T=h(w,Ne(b,u[2]));y.scale.x=1+(a[0]-1)*m+h(w,Ne(b,d[0]))||br,y.scale.y=1+(a[1]-1)*m+h(w,Ne(b,d[1]))||br,y.scale.z=1+(a[2]-1)*m+h(w,Ne(b,d[2]))||br,y.rotation.x=l.x*m+P,y.rotation.y=l.y*m+S,y.rotation.z=l.z*m+T,y.position.x=s[0]*m+h(w,Ne(b,p[0])),y.position.y=s[1]*m+h(w,Ne(b,p[1])),y.position.z=s[2]*m+h(w,Ne(b,p[2]))}}_updateGrid(e,r){let o=0,n=e.grid,a=e.randomnessObject??No.defaultData([1,1,1]).randomnessObject,s=St(a.scale,r),l=St(a.rotation,r),c=St(a.position,r),u=this.getRandom(a,!0),d=sc(a.strength,this.parameters.randomness),p=St(n.count,r),f=St(n.size,r);if(n.useCenter===!0){let h={x:p[0]%2===0?2:1,y:p[1]%2===0?2:1,z:p[2]%2===0?2:1},m=new tt.Vector3(f[0]*(p[0]-h.x)*.5,f[1]*(p[1]-h.y)*.5,f[2]*(p[2]-h.z)*.5);for(let y=0;y<p[0];y++)for(let g=0;g<p[1];g++)for(let b=0;b<p[2];b++){let w=u.noise((y+1)*(a.freqScale/10)+a.movement,(g+1)*(a.freqScale/10)+a.movement,(b+1)*(a.freqScale/10)+a.movement),P=this.children[o++];if(!P)continue;P.scale.x=1+d(o,Ne(w,s[0]))||br,P.scale.y=1+d(o,Ne(w,s[1]))||br,P.scale.z=1+d(o,Ne(w,s[2]))||br;let S=d(o,Ne(w,l[0])),T=d(o,Ne(w,l[1])),A=d(o,Ne(w,l[2]));P.rotation.set(S,T,A),P.position.x=f[0]*y-m.x+d(o,Ne(w,c[0])),P.position.y=f[1]*g-m.y+d(o,Ne(w,c[1])),P.position.z=f[2]*b-m.z+d(o,Ne(w,c[2]))}}else for(let h=0;h<p[0];h++)for(let m=0;m<p[1];m++)for(let y=0;y<p[2];y++){let g=u.noise((h+1)*(a.freqScale/10)+a.movement,(m+1)*(a.freqScale/10)+a.movement,(y+1)*(a.freqScale/10)+a.movement),b=this.children[o++];if(!b)continue;b.scale.x=1+d(o,Ne(g,s[0]))||br,b.scale.y=1+d(o,Ne(g,s[1]))||br,b.scale.z=1+d(o,Ne(g,s[2]))||br;let w=d(o,Ne(g,l[0])),P=d(o,Ne(g,l[1])),S=d(o,Ne(g,l[2]));b.rotation.set(w,P,S),b.position.x=f[0]*h+d(o,Ne(g,c[0])),b.position.y=-f[1]*m+d(o,Ne(g,c[1])),b.position.z=-f[2]*y+d(o,Ne(g,c[2]))}}_updateToObject(e,r){if(e.type!=="toObject")throw new Error;let{toObject:o}=e,n=St(o.rotation,r),a=St(o.position,r),s=St(o.scale,r),l=new tt.Euler(n[0],n[1],n[2]),c=e.randomnessObject??No.defaultData([1,1,1]).randomnessObject,u=St(c.rotation,r),d=St(c.position,r),p=St(c.scale,r),f=this.getRandom(c),h=sc(c.strength,this.parameters.randomness);if(!o.object){for(let[,w]of this.children.entries())w.position.set(0,0,0),w.scale.setScalar(1),w.rotation.set(0,0,0);this.objectForSample=void 0;return}if(!this.objectForSample)return;if(this.objectForSample instanceof rn)if(!this.objectForSample.font?.isLoaded||this.objectForSample.geometry.attributes.position===void 0){this._pendingMediaLoad=!0;return}else this._pendingMediaLoad=!1;if(this.objectForSample.geometry===void 0&&this.objectForSample.isAncestorOf(this.object.uuid)){console.warn(`Oh no! The object "${this.object.name}" (${this.object.uuid}) seem to be a child/descendant of the object it's being cloned to. Please re-parent it so that they are siblings instead.`);return}let m=this.getSubdivData();if(m.length>0){let w=Math.round(m.length*o.count/100);this._updateCount(r,w)}else{let w=this.objectForSample.geometry.getAttribute("position");if(!w||isNaN(w.count)||w.count===0){console.warn(`Oh no! The object "${this.object.name}" (${this.object.uuid}) cannot be cloned on the surface of "${this.objectForSample.name}" (${this.objectForSample.uuid}) because the latter does not have a valid geometry.`);return}}this.objectForSample.updateMatrixWorld();let y=new Hu(this.objectForSample).build(),g=vv[o.axis],b=this.children;y.setRandomGenerator((0,Gd.default)(this.object.uuid+o.seed));for(let[w,P]of b.entries()){let S=w*(c.freqScale/10)+c.movement,T=f.noise(S,S,S),A=w+1,x=h(A,Ne(T,u[0])),N=h(A,Ne(T,u[1])),E=h(A,Ne(T,u[2]));o.spreadType==="random"?y.sample(lc,Lh):(m.length&&(lc.fromArray(m[w].pos),Lh.fromArray(m[w].norm)),this.objectForSample instanceof $n&&lc.applyMatrix4(U3.copy(this.objectForSample.matrixWorld).invert())),lc.applyMatrix4(this.object.hiddenMatrix.clone().invert()),P.position.copy(lc),on.fromArray(g);let M=o.align==="normal"?Lh:this.object.getWorldDirection(W3),D=zd.fromArray(a);zd.x+=h(A,Ne(T,d[0])),zd.y+=h(A,Ne(T,d[1])),zd.z+=h(A,Ne(T,d[2]));let _=Math.acos(M.dot(on)),R=H3.crossVectors(on,M).normalize(),V=k3.makeRotationAxis(R,_),U=M.clone().cross(this.object.up).normalize(),B=U.clone().cross(M).normalize(),q=new tt.Matrix4().makeBasis(U,M,B),j=new tt.Vector3(on.y,on.z,on.x).normalize(),F=j.clone().cross(on).normalize(),H=new tt.Matrix4().makeBasis(j,on,F).invert(),W=new tt.Matrix4().multiplyMatrices(q,H);P.rotation.setFromRotationMatrix(W),D.applyMatrix4(V),P.position.add(D),P.rotation.x=P.rotation.x+l.x+x,P.rotation.y=P.rotation.y+l.y+N,P.rotation.z=P.rotation.z+l.z+E,P.scale.setScalar(1),P.scale.x=P.scale.x+s[0]+h(A,Ne(T,p[0]))||br,P.scale.y=P.scale.y+s[1]+h(A,Ne(T,p[1]))||br,P.scale.z=P.scale.z+s[2]+h(A,Ne(T,p[2]))||br,P.scale.multiply(this.object.scale),P.hiddenMatrix=this.object.hiddenMatrix}}getSubdivData(){if(!this.objectForSample)return[];let e=this.parameters.toObject.spreadType,r=new Map,o=(a,s)=>{let l=Math.round(a[0]*1e4)+"_"+Math.round(a[1]*1e4)+"_"+Math.round(a[2]*1e4),c=r.get(l);c?(c.pos[0]+=a[0],c.pos[1]+=a[1],c.pos[2]+=a[2],c.norm[0]+=s[0],c.norm[1]+=s[1],c.norm[2]+=s[2],c.count+=1):r.set(l,{pos:[...a],norm:[...s],count:1})};if(e==="random")return[];if(this.objectForSample instanceof $n){let a=this.objectForSample,s=Sv[e],l=_v[s],c=Nv[s],u=Dv[s],d=l(a.subdivPointerNew);for(let p=0;p<=d-1;p++){let f=c(a.subdivPointerNew,p),h=u(a.subdivPointerNew,p);Iv.fromArray(f).applyMatrix4(a.matrixWorld),Ev.fromArray(h),o(Iv.toArray(),Ev.toArray())}}else(this.objectForSample.geometry.index?wv(this.objectForSample.geometry):Pv(this.objectForSample.geometry)).forEach((s,l)=>{e==="polygon_center"&&o(s.midpoint,s.norm),e==="vertex"&&(o(s.vertices[0],s.norm),o(s.vertices[1],s.norm),o(s.vertices[2],s.norm)),e==="edge"&&(o(s.faceCenters[0],s.norm),o(s.faceCenters[1],s.norm),o(s.faceCenters[2],s.norm))});let n=Array.from(r.values());for(let a of n)a.pos[0]/=a.count,a.pos[1]/=a.count,a.pos[2]/=a.count,a.norm[0]/=a.count,a.norm[1]/=a.count,a.norm[2]/=a.count;return n}updateState(e,r){if(this.parameters=ti(e),this.parameters.type!=="toObject")(this.parent===null||this.parent!==this.object)&&(this.removeFromParent(),this.object.parent?.add(this),this.matrix=this.object.matrix,this.hiddenMatrix=this.object.hiddenMatrix,this.matrixWorldNeedsUpdate=!0,this.matrixAutoUpdate=!1);else if(this.parent===null||this.parent.uuid!==this.parameters.toObject.object){this.removeFromParent();let o=r.scene.find(this.parameters.toObject.object);o instanceof Xt?this.objectForSample=o:this.objectForSample=void 0,this.matrix=new tt.Matrix4,this.hiddenMatrix=new tt.Matrix4,this.matrixWorldNeedsUpdate=!0,this.matrixAutoUpdate=!1,o&&o.add(this)}this.update(r)}get pendingMediaLoad(){return this._pendingMediaLoad}};var oo=require("three");var xt=require("three");var cr=require("three");var Rv=require("three"),Wo=i=>{var t;return t=class extends i{},t.geometryHelper=new Rv.BoxGeometry(30,30,30),t};var fr=require("three"),Fd=new fr.Ray,Vh=new fr.Sphere,Lv=new fr.Matrix4,qo=(i,t,e,r,o=!1,n=i)=>{let a=t,s=n.matrixWorld;if(a.boundingSphere===null&&a.computeBoundingSphere(),Vh.copy(a.boundingSphere),Vh.applyMatrix4(s),e.ray.intersectsSphere(Vh)===!1||(Lv.copy(s).invert(),Fd.copy(e.ray).applyMatrix4(Lv),a.boundingBox!==null&&Fd.intersectsBox(a.boundingBox)===!1))return;let l,c,u,d,p=a.index,f=a.attributes.position,h=a.drawRange,m,y;if(o===!1){let b=Math.max(0,h.start),w=Math.min(p.count,h.start+h.count);for(m=b,y=w;m<y;m+=3)if(c=p.getX(m),u=p.getX(m+1),d=p.getX(m+2),l=g(i,e,Fd,f,c,u,d),l){l.faceIndex=Math.floor(m/3),r.push(l);return}}else{let w=a.attributes.position,P=new fr.Vector3,S=new fr.Vector3,T=new fr.Vector3,A=new fr.Vector3,x=2,E=1/((n.scale.x+n.scale.y+n.scale.z)/3),M=E*E,D=Math.max(0,h.start),_=Math.min(w.count,h.start+h.count);for(let R=D,V=_-1;R<V;R+=x){if(P.fromBufferAttribute(w,R),S.fromBufferAttribute(w,R+1),Fd.distanceSqToSegment(P,S,A,T)>M)continue;A.applyMatrix4(n.matrixWorld);let B=e.ray.origin.distanceTo(A);B<e.near||B>e.far||r.push({distance:B,point:T.clone().applyMatrix4(n.matrixWorld),object:i})}}function g(b,w,P,S,T,A,x){let N=new fr.Vector3,E=new fr.Vector3,M=new fr.Vector3,D=new fr.Vector3,_=new fr.Vector3;if(N.fromBufferAttribute(S,T),E.fromBufferAttribute(S,A),M.fromBufferAttribute(S,x),P.intersectTriangle(N,E,M,!1,D)===null)return null;_.copy(D),_.applyMatrix4(b.matrixWorld);let V=w.ray.origin.distanceTo(_);return V<w.near||V>w.far?null:{faceIndex:1,distance:V,point:_.clone(),object:b}}};var jd=new cr.Vector3,Qr=new cr.Camera,zh=class extends cr.LineSegments{constructor(e){let r=new cr.BufferGeometry,o=new cr.LineBasicMaterial({color:16777215,vertexColors:!0,toneMapped:!1}),n=[],a=[],s={},l=new cr.Color(15711266),c=new cr.Color(15711266),u=new cr.Color(2857471);d("n1","n2",l),d("n2","n4",l),d("n4","n3",l),d("n3","n1",l),d("f1","f2",l),d("f2","f4",l),d("f4","f3",l),d("f3","f1",l),d("n1","f1",l),d("n2","f2",l),d("n3","f3",l),d("n4","f4",l),d("p","n1",c),d("p","n2",c),d("p","n3",c),d("p","n4",c),d("u1","u2",u),d("u2","u3",u),d("u3","u1",u);function d(f,h,m){p(f,m),p(h,m)}function p(f,h){n.push(0,0,0),a.push(h.r,h.g,h.b),s[f]===void 0&&(s[f]=[]),s[f].push(n.length/3-1)}r.setAttribute("position",new cr.Float32BufferAttribute(n,3)),r.setAttribute("color",new cr.Float32BufferAttribute(a,3));super(r,o);this.type="CameraHelper",this.camera=e,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=s,this.update()}update(){let e=this.geometry,r=this.pointMap,o=!0;Qr.projectionMatrixInverse.elements=[.5112609807824982,-0,-0,-0,-0,.41421356237309503,-0,-0,-0,-0,-0,-.099999,-0,-0,-1.0000000000000002,.100001];let n=1,a=1,s=o?.8:1e-4;wo("n1",r,e,Qr,-n,-a,s),wo("n2",r,e,Qr,n,-a,s),wo("n3",r,e,Qr,-n,a,s),wo("n4",r,e,Qr,n,a,s);let l=s;wo("f1",r,e,Qr,-n,-a,l),wo("f2",r,e,Qr,n,-a,l),wo("f3",r,e,Qr,-n,a,l),wo("f4",r,e,Qr,n,a,l);let c=l,u=.5;wo("u1",r,e,Qr,n*.7*u,a*1.1,c),wo("u2",r,e,Qr,-n*.7*u,a*1.1,c),wo("u3",r,e,Qr,0,a*(1.1+.9*u),c),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};function wo(i,t,e,r,o,n,a){jd.set(o,n,a).unproject(r);let s=t[i];if(s!==void 0){let l=e.getAttribute("position");for(let c=0,u=s.length;c<u;c++)l.setXYZ(s[c],jd.x,jd.y,jd.z)}}var Ud=class extends Wo(zh){constructor(e){super(e);this.object=e;this.object=e,this.name=`CombinedCameraHelper: ${e.uuid}`}updateMatrixWorld(e){super.updateMatrixWorld(e),this.updateTarget()}updateTarget(){let e=this.object.getTarget();this.updateWorldMatrix(!0,!1),this.worldToLocal(e)}raycast(e,r){qo(this.object,this.geometry,e,r,!0)}};var cc=require("three");var kd;(t=>t.is=e=>"objectHelper"in e)(kd||(kd={}));var Zr=(i,t)=>class extends $a(i){constructor(){super(...arguments);this.objectHelper=new t(this);this.gizmos={}}get geometryHelper(){return t.geometryHelper}raycast(o,n){this.objectHelper.raycast(o,n)}showGizmos(){for(let o in this.gizmos){let n=this.gizmos[o];n instanceof cc.Box3Helper&&(n.visible=!0)}}updateEntityBoxSize(o,n){this.objectHelper.visible&&this.geometryHelper instanceof cc.BoxGeometry?(o.setScalar(0),n.set(this.geometryHelper.parameters.width,this.geometryHelper.parameters.height,this.geometryHelper.parameters.height).multiplyScalar(.5)):super.updateEntityBoxSize(o,n)}hideGizmos(){for(let o in this.gizmos){let n=this.gizmos[o];n instanceof cc.Box3Helper&&(n.visible=!1)}}};var Hd=790,Gs=new xt.Vector3,Gh=new xt.Vector3,Fh=new xt.Quaternion,jh=new xt.Vector3,uc=new xt.Vector3,Uh=new xt.Vector3,Si=class extends Zr(xt.Camera,Ud){constructor(e="",r={...En.defaultData,name:""}){super();this._cameraType="OrthographicCamera";this.targetOffset=Fi.DefaultTargetOffset;this.isUpVectorFlipped=!1;this.angleOffsetFromUp=0;this.wasMovedByUser=!1;this.wasMovedBySwitchCameraAction=!1;this.super_Entity(e,r),this.previousProjectionMatrix=new xt.Matrix4,this.matrixAutoUpdate=!0,this.width=window.innerWidth,this.height=window.innerHeight;let o=this.width,n=this.height;this.orthoCamera=new xt.OrthographicCamera(o*-.5,o*.5,n*.5,n*-.5,-5e4,1e4),this.perspCamera=new xt.PerspectiveCamera(45,o/n,50,1e4),this.left=this.orthoCamera.left,this.right=this.orthoCamera.right,this.top=this.orthoCamera.top,this.bottom=this.orthoCamera.bottom,this.far=this.orthoCamera.far,this.view=this.orthoCamera.view,this.aspect=this.perspCamera.aspect,this.focus=this.perspCamera.focus,this.filmGauge=this.perspCamera.filmGauge,this.filmOffset=this.perspCamera.filmOffset,this.objectHelper.update()}get isPerspectiveCamera(){return this.cameraType==="PerspectiveCamera"}get isOrthographicCamera(){return!this.isPerspectiveCamera}get cameraType(){return this._cameraType}set fov(e){this.perspCamera.fov=e}get fov(){return this.perspCamera.fov}setNear(e,r){e==="PerspectiveCamera"?this.perspCamera.near=r:this.orthoCamera.near=r}setZoom(e,r){r>=0&&(e==="PerspectiveCamera"?this.perspCamera.zoom=r:this.orthoCamera.zoom=r)}set cameraType(e){e==="PerspectiveCamera"?this.toPerspective():e==="OrthographicCamera"&&this.toOrthographic()}get near(){return this._cameraType==="PerspectiveCamera"?this.perspCamera.near:this.orthoCamera.near}set near(e){this._cameraType==="PerspectiveCamera"?this.perspCamera.near=e:this.orthoCamera.near=e}get zoom(){return this._cameraType==="PerspectiveCamera"?this.perspCamera.zoom:this.orthoCamera.zoom}set zoom(e){e>=0&&(this._cameraType==="PerspectiveCamera"?this.perspCamera.zoom=e:this.orthoCamera.zoom=e)}lookAt(e,r,o){typeof e=="number"&&(e=new xt.Vector3(e,r,o)),super.lookAt(e),this.getWorldPosition(Gs),this.targetOffset=Gs.distanceTo(e)}getTarget(e=new xt.Vector3){return this.getWorldDirection(Gh),this.getWorldPosition(Gs),Gh.multiplyScalar(this.targetOffset),e.copy(Gs).add(Gh),e}getDistanceToTarget(){let e=this.getTarget();return this.getWorldPosition(Gs),Gs.distanceTo(e)}updateUp(){this.getWorldQuaternion(Fh),jh.set(0,0,1).applyQuaternion(Fh),uc.copy(xt.Object3D.DEFAULT_UP),this.isUpVectorFlipped&&uc.negate(),uc.applyQuaternion(Fh),Uh.copy(xt.Object3D.DEFAULT_UP).projectOnPlane(jh),this.angleOffsetFromUp=Uh.angleTo(uc),this.angleOffsetFromUp*=Uh.cross(uc).dot(jh)>=0?1:-1}updateTransformState(e,r){let o=super.updateTransformState(e,r);return e.isUpVectorFlipped!==void 0&&(this.isUpVectorFlipped=e.isUpVectorFlipped),this.updateUp(),o}getViewFrontToObject(e){let r=e.getWorldPosition(new xt.Vector3),n=e.getWorldDirection(new xt.Vector3).multiplyScalar(this.targetOffset);return{position:r.clone().add(n),target:r}}getViewToTarget(e){let o=this.getWorldDirection(new xt.Vector3).multiplyScalar(this.targetOffset);return{position:e.clone().sub(o),target:e}}getViewToObject(e){let r=new xt.Vector3;return e.getWorldPosition(r),this.getViewToTarget(r)}setViewplaneSize(e,r,o=!1){if(this.aspect=e/r,o){let n=e>r?this.aspect:1,a=e>r?1:this.aspect;this.left=-Hd*.5*n,this.right=Hd*.5*n,this.top=Hd*.5*(1/a),this.bottom=-Hd*.5*(1/a)}else this.left=-e*.5,this.right=e*.5,this.top=r*.5,this.bottom=-r*.5;this.updateProjectionMatrix()}copyViewPlaneSize(e){this.aspect=e.aspect,this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.updateProjectionMatrix()}toOrthographic(){this.orthoCamera.left=this.left,this.orthoCamera.right=this.right,this.orthoCamera.top=this.top,this.orthoCamera.bottom=this.bottom,this.orthoCamera.view=this.view,this.orthoCamera.far=this.far,this.orthoCamera.updateProjectionMatrix(),this.projectionMatrix=this.orthoCamera.projectionMatrix,this.projectionMatrixInverse=this.orthoCamera.projectionMatrixInverse,this._cameraType="OrthographicCamera",this.objectHelper&&this.objectHelper.update()}toPerspective(){this.perspCamera.aspect=this.aspect,this.perspCamera.fov=this.fov,this.perspCamera.view=this.view,this.perspCamera.far=this.far,this.perspCamera.updateProjectionMatrix(),this.projectionMatrix=this.perspCamera.projectionMatrix,this.projectionMatrixInverse=this.perspCamera.projectionMatrixInverse,this._cameraType="PerspectiveCamera",this.objectHelper&&this.objectHelper.update()}setFocalLength(e){this.perspCamera.setFocalLength(e),this.toPerspective()}getFocalLength(){return this.perspCamera.getFocalLength()}getEffectiveFOV(){return this.perspCamera.getEffectiveFOV()}getFilmWidth(){return this.perspCamera.getFilmWidth()}getFilmHeight(){return this.perspCamera.getFilmHeight()}setViewOffset(e,r,o,n,a,s){this._cameraType==="PerspectiveCamera"?this.perspCamera.setViewOffset(e,r,o,n,a,s):this.orthoCamera.setViewOffset(e,r,o,n,a,s)}clearViewOffset(){this._cameraType==="PerspectiveCamera"?(this.perspCamera.clearViewOffset(),this.toPerspective()):(this.orthoCamera.clearViewOffset(),this.toOrthographic())}copyHistory(){this.previousProjectionMatrix&&this.previousProjectionMatrix.copy(this.projectionMatrix)}updateProjectionMatrix(){this._cameraType==="PerspectiveCamera"?this.toPerspective():this._cameraType==="OrthographicCamera"&&this.toOrthographic()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,r){super.updateWorldMatrix(e,r),this.matrixWorldInverse.copy(this.matrixWorld).invert()}copy(e,r){return super.copy(e,r),this.parent=e.parent,this.orthoCamera.copy(e.orthoCamera),this.perspCamera.copy(e.perspCamera),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.far=e.far,this.view=e.view===null?null:Object.assign({},e.view),this._cameraType=e._cameraType,this.aspect=e.aspect,this.fov=e.fov,this.focus=e.focus,this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this.targetOffset=e.targetOffset,this.updateProjectionMatrix(),this}toCameraState(e=[]){let r={type:this.cameraType,far:this.far,orthographic:{near:this.orthoCamera.near,zoom:this.orthoCamera.zoom},perspective:{near:this.perspCamera.near,fov:this.perspCamera.fov,zoom:this.perspCamera.zoom},up:this.up.toArray(),targetOffset:this.targetOffset,isUpVectorFlipped:this.isUpVectorFlipped};return Pa(r,e)}updateCameraSubtype(e,r){let o=e==="perspective"?"PerspectiveCamera":"OrthographicCamera";r.zoom!==void 0&&this.setZoom(o,r.zoom),r.near!==void 0&&this.setNear(o,r.near),r.fov!==void 0&&o==="PerspectiveCamera"&&(this.fov=r.fov)}updateState(e,r){this.updateCameraState(e,r)}updateCameraState(e,r){this.updateState_Entity(e,r),e.far!==void 0&&(this.far=e.far),e.orthographic!==void 0&&this.updateCameraSubtype("orthographic",e.orthographic),e.perspective!==void 0&&this.updateCameraSubtype("perspective",e.perspective),e.type!==void 0&&(this.cameraType=e.type),e.up!==void 0&&this.up.fromArray(e.up.map(o=>typeof o=="number"?o:0)),e.targetOffset!==void 0&&(this.targetOffset=e.targetOffset),e.isUpVectorFlipped!==void 0&&(this.isUpVectorFlipped=e.isUpVectorFlipped),this.updateProjectionMatrix()}updateByPatchedOp(e,r,o){super.updateByPatchedOp(e,r,o),e.path.length===1&&e.type===0&&this.updateCameraSubtype(e.path[0],e.props)}toState(e){return{...super.toState(e),...this.toCameraState(e),type:this.cameraType}}};var X3=require("three");var an=require("three");var Fs=new an.Matrix4,$3=new an.Matrix4;var Nr=class extends Er{constructor(e,r,o){super(e,r);this.data=r;this.meshSetAddresses=[];this.needsTransformForDownstream=!1;this.geometry=new an.BufferGeometry;this.onAfterRender=(e,r,o,n,a,s)=>{super.onAfterRender(e,r,o,n,a,s),this.recomputeBoolean()};this.geometry.userData.parameters={width:0,height:0,depth:0}}get booleanOp(){return this.data.geometry.operation}get phongAngle(){return this.data.geometry.phongAngle??45}get isLOD(){return this.recomputeBoolean(),!1}updateByPatchedOp(e,r,o){super.updateByPatchedOp(e,r,o),e.path.length===1&&e.path[0]==="geometry"&&e.type===0&&e.props.operation!==void 0&&(this.freeBooleanPointer(),this.resetBBoxNeedsUpdate())}freeBooleanPointer(){super.freeBooleanPointer(),this.geometry.dispose()}recomputeBoolean(e,r=!0){if(this.booleanMeshSetAddress!==-1&&!e)return;for(let n=0;n<this.children.length;n++){let a=this.children[n];a instanceof Nr&&a.dataPatched.visible===!0&&a.recomputeBoolean(e===!0,r)}this.meshSetAddresses=[];for(let n=0;n<this.children.length;n++){let a=this.children[n];if(a instanceof Xt&&a.dataPatched.visible===!0&&a.geometry.attributes.position?.count>0&&a.geometry.drawRange.count>0&&a.booleanMeshSetAddress!==0){Fs.multiplyMatrices(a.hiddenMatrix,a.matrix).multiply(a.pivotMatrix);try{if(a.booleanMeshSetAddress===-1){if((a.geometry.index??a.geometry.getAttribute("position")).count/3<15e5&&(a.booleanMeshSetAddress=Xr.getMeshSet(a.geometry,e===!0,r)),a.booleanMeshSetAddress===-1)return;Xr.transformMeshSet(a.booleanMeshSetAddress,Fs),a.booleanMatrixInvOld.copy(Fs).invert(),a.booleanWasTransformed=!1}else a instanceof Nr&&a.needsTransformForDownstream===!0?(Xr.transformMeshSet(a.booleanMeshSetAddress,Fs),a.needsTransformForDownstream=!1):a.booleanWasTransformed===!0&&(Xr.transformMeshSet(a.booleanMeshSetAddress,$3.multiplyMatrices(Fs,a.booleanMatrixInvOld)),a.booleanMatrixInvOld.copy(Fs).invert(),a.booleanWasTransformed=!1)}catch(s){console.error(s),a.booleanMeshSetAddress=0,a.geometry.userData.booleanOperationDidFail=!0;continue}Xr.hasOpenEdges(a.booleanMeshSetAddress)===!1||n===this.children.length-1&&this.booleanOp===2?(this.meshSetAddresses.push(a.booleanMeshSetAddress),a.geometry.userData.booleanOperationDidFail=!1):a.geometry.userData.booleanOperationDidFail="openEdges"}}if(this.meshSetAddresses.length===0){this.geometry.setAttribute("position",new an.Float32BufferAttribute([],0)),this.geometry.setDrawRange(0,0);return}if(e===!0)return Xr.calcBooleanTopological(this.meshSetAddresses,this.booleanOp);let o=this.geometry;o.dispose(),this.geometry=new an.BufferGeometry,this.geometry.userData=o.userData,this.geometry.boundingSphere=o.boundingSphere;try{this.booleanMeshSetAddress=Xr.calcBoolean(this.meshSetAddresses,this.booleanOp,this.geometry,this.phongAngle)}catch(n){this.booleanMeshSetAddress=0,this.geometry.userData.booleanOperationDidFail=!0,console.error(n)}this.booleanMatrixInvOld.copy(this.matrix).invert(),this.needsTransformForDownstream=!0,Ls(this),Bs(this)}dispose(){super.dispose(),this.geometry.dispose()}};var Vv=require("three");var Bv;(t=>{function i(e){return Ge.is(e)&&e instanceof Vv.Light}t.is=i})(Bv||(Bv={}));var js=(i,t)=>class extends Zr(i,t){updateState_Light(r,o){this.updateState_Entity(r,o),r.color!==void 0&&(this.color=o.shared.color(r.color)),r.intensity!==void 0&&(this.intensity=r.intensity),r.depth!==void 0&&(this.shadow.camera.far=r.depth,this.shadow.needsUpdate=!0),r.shadows!==void 0&&(this.castShadow=r.shadows)}};var sn=i=>i instanceof Xt,dc=i=>i!==null&&i instanceof Nr;var pc=i=>kd.is(i);var Fv=require("three");var $o=require("three");var Y3=new $o.Vector3(1,1,1),zv=new $o.Vector3,K3=new $o.Vector3,Gv=new $o.Quaternion,Jr=class extends Wo($o.AxesHelper){constructor(e,r=15){super(r);this.object=e;this.dummy=new $o.Group;this.object.updateMatrixWorld(),this.name=`EmptyObjectHelper: ${e.uuid}`,this.matrix=this.dummy.matrixWorld,this.matrixAutoUpdate=!1,this.object.isBone&&(this.visible=!1)}raycast(e,r){qo(this.object,Jr.geometryHelper,e,r,!1,this.dummy)}update(){}updateMatrix(){}updateMatrixWorld(e){this.object.matrixWorld.decompose(zv,Gv,K3),this.matrix.compose(zv,Gv,Y3),super.updateMatrixWorld(e)}updateWorldMatrix(e,r){}};var ln=class extends Zr(Fv.Group,Jr){constructor(t,e){super(),this.super_Entity(t,e),this.objectHelper.update()}updateState(t,e){this.updateState_Entity(t,e),"buffer"in t&&Object.keys(t).length===1&&e.scene.reloadSplats()}};var jv=require("three");var Us=class extends Zr(jv.Group,Jr){constructor(e,r,o){super();this.super_Entity(e,r),this.context=o,this.objectHelper.update()}updateState(e,r){this.updateState_Entity(e,r)}};var Ks=require("three");var ks=require("three"),Q3=i=>`
2289
+ `)>=0&&(t-=n),r===3?e*.5-t*.5:r===2?e-t:0}getLineInitialOffsetY(t,e,r,o,n){let a=e*t,s=Math.abs(this.ascender-this.descender)*o,l=t-s,c=-this.ascender*o-l/2;return n===3?-(r-a-c):n===2?-(r*.5-a*.5-c):c}createPath(t,e,r,o,n){let a=t.getPath(r,-o,n.fontSize,{kerning:!1,letterSpacing:n.letterSpacing});if(!a){console.error('THREE.Font: character "'+t+'" does not exists in font family '+this.familyName+".");return}let s=new Md,l=(t.advanceWidth??1)*e;if(t)for(let c of a.commands){let u=s.currentPath?.currentPoint;if(!(u&&c.type!=="Z"&&u.x===c.x&&-u.y===c.y))switch(c.type){case"M":s.moveTo(c.x,-c.y);break;case"L":s.lineTo(c.x,-c.y);break;case"Q":s.quadraticCurveTo(c.x1,-c.y1,c.x,-c.y);break;case"C":s.bezierCurveTo(c.x1,-c.y1,c.x2,-c.y2,c.x,-c.y);break}}return s.subPaths.forEach(c=>{let u=T3(c.curves);u!==void 0&&c.currentPoint.distanceTo(u)>0&&c.lineTo(u.x,u.y)}),{offsetX:l,path:s}}getCharWidth(t,e){return this.font?.getAdvanceWidth(t,e.fontSize,{kerning:!0,letterSpacing:e.letterSpacing})??0}getTextWidth(t,e){return this.font?.getAdvanceWidth(t,e.fontSize,{kerning:!0,letterSpacing:e.letterSpacing})??0}computeSpaceWidthForLine(t,e,r,o){let n=this.getCharWidth(" ",r),a=t[e];if(a){let s=this.countSpaces(a.trimEnd());if(r.horizontalAlign===4&&e<t.length-1&&s){let l=typeof r.width=="string"?Number(o.getVariable(r.width)):r.width,c=this.getTextWidth(a,r);return(l-(c-s*n))/s}}return n}countSpaces(t){return(t.match(/ /g)||[]).length}};function T3(i){if(i.length){let t=i[0];if(t instanceof Rs.LineCurve)return t.v1;if(t instanceof Rs.CubicBezierCurve||t instanceof Rs.QuadraticBezierCurve)return t.v0}}var Mh=class{constructor(){this.objects=new Map;this.unreachable=new Set}getCached(t){return this.objects.get(t)}get size(){return this.objects.size}get(t,e,r){let o=this.objects.get(t);return o===void 0?(o=this.createObject(t,e,r),this.objects.set(t,o)):o.isShared=!0,o}forceDelete(t){let e=this.objects.get(t);e&&(this.disposeObject(e),this.objects.delete(t))}mutateIfUnique(t,e){let r=this.objects.get(t);if(r&&r.isShared!==!0)return this.objects.delete(t),this.objects.set(e,r),r}startGc(){this.unreachable=new Set(this.objects.keys())}markAsReachable(t,e){let r=this.objects.get(t);e===r?this.unreachable.delete(t):!1&&console.warn("Reachable but deleted",t)}endGc(){this.unreachable.forEach(t=>{this.disposeObject(this.objects.get(t)),this.objects.delete(t)}),this.unreachable.clear()}dispose(){this.objects.forEach(t=>{this.disposeObject(t)}),this.objects.clear()}},ic=class extends Mh{constructor(e){super();this.flatShading=e}disposeObject(e){e.dispose()}createObject(e,r,o){let n=Go(e,r,this.flatShading,o);return n.computeBoundingSphere(),n}};var lv={markNeedsUpdateRendererDirty:()=>{}};var Nh=require("three");var Nd=1e3,cv=512*Nd;function C3(i,t){let e=typeof i;return!!((t==="string"||t==="number")&&e===t||t==="boolean"&&(i==="true"||i==="false"||i===!0||i===!1)||t==="image"&&e==="string"&&i.startsWith("http"))}var uv="https://hooks.spline.design",A3=`${uv}/events?hashFile=`,AQ=`${uv}/`,Dd=class{constructor(t,e){this.id=t;this.userWebhook=e;this.result=void 0;this._connected=!1;this.emitter=hi();this.reconnectWaitFor=Nd;this._onError=t=>{this.eventSource?.removeEventListener("message",this._onMessage),this.eventSource?.removeEventListener("error",this._onError),this.eventSource?.removeEventListener("open",this._onConnected),this._scheduleReconnect()};this._onConnected=t=>{clearTimeout(this.scheduledReconnectHandle),this.reconnectWaitFor=Nd,this._connected=!0};this._onDisconnected=()=>{clearTimeout(this.scheduledReconnectHandle),this.reconnectWaitFor=Nd,this._connected=!1};this._onMessage=t=>{let e=t.data,r;try{r=JSON.parse(e)}catch(o){console.error("Error parsing webhook message",o)}if(r){let o=!1;this.userWebhook.parametersSchemas.forEach(({data:n})=>{r[n.name]!==void 0&&C3(r[n.name],n.type)&&(this.result===void 0&&(this.result={}),this.result[n.name]=r[n.name],o=!0)}),o&&this.emitter.emit("message",{userWebhookId:this.id})}}}connect(){clearTimeout(this.scheduledReconnectHandle),this.userWebhook.url&&(this.eventSource=new EventSource(A3+this.userWebhook.url),this.eventSource.addEventListener("message",this._onMessage),this.eventSource.addEventListener("error",this._onError),this.eventSource.addEventListener("open",this._onConnected))}disconnect(){this.eventSource?.removeEventListener("message",this._onMessage),this.eventSource?.removeEventListener("error",this._onError),this.eventSource?.removeEventListener("open",this._onConnected),this.eventSource?.close(),this._onDisconnected(),clearTimeout(this.scheduledReconnectHandle)}_scheduleReconnect(){this.reconnectWaitFor*=2,this.reconnectWaitFor>cv&&(this.reconnectWaitFor=cv),clearTimeout(this.scheduledReconnectHandle),this.scheduledReconnectHandle=setTimeout(()=>{this.scheduledReconnectHandle=void 0,this.connect()},this.reconnectWaitFor)}update(t){this.userWebhook=t}dispose(){this._connected&&this.disconnect()}get connected(){return this._connected}on(t,e){this.emitter.on(t,e)}off(t,e){this.emitter.off(t,e)}getParametersKeys(){return this.userWebhook.parametersSchemas.map(t=>t.data.name)}getParameterValue(t){if(this.getParametersKeys().includes(t)){if(this.result)return this.result?.[t];for(let r of this.userWebhook.parametersSchemas)if(r.data.name===t)return Lu.defaultParameterValueByType(r.data.type)}}};var dv=[4186.01,4434.92,4698.63,4978.03,5274.04,5587.65,5919.91,6271.93,6644.88,7040,7458.62,7902.13],M3=["C","C#","D","D#","E","F","F#","G","G#","A","A#","B"],bi=[],Rd=[];for(let i=1;i<=8;i++)for(let t=0;t<dv.length;t++){let e=dv[t];bi.push(e/Math.pow(2,8-i)),Rd.push(M3[t]+i)}var _d=[32,2e3],Ih=bi.filter((i,t)=>bi[t]>_d[0]&&bi[t]<_d[1]),pv=Rd.filter((i,t)=>bi[t]>_d[0]&&bi[t]<_d[1]);var Ld=class{static getFrequencies(t,e,r,o="frequency",n=-100,a=-30){r||(r=new Float32Array(t.frequencyBinCount),t.getFloatFrequencyData(r));let s=e/2,l=1/r.length*s,c,u,d;if(o==="music"||o==="voice"){let h=o==="voice"?Ih:bi,m=Array(h.length).fill(n);for(let y=0;y<r.length;y++){let g=y*l,b=r[y];for(let w=h.length-1;w>=0;w--)if(g>h[w]){m[w]=Math.max(m[w],b);break}}c=m,u=o==="voice"?Ih:bi,d=o==="voice"?pv:Rd}else c=Array.from(r),u=c.map((h,m)=>l*m),d=u.map(h=>`${h.toFixed(2)} Hz`);let p=c.map(h=>Math.max(0,Math.min((h-n)/(a-n),1)));return{values:new Float32Array(p),frequencies:u,labels:d}}};var I3="gpt-4o-realtime-preview-2024-12-17",E3=()=>!1&&window.location.search.includes("api-dev")?"https://relayserver-dev.spline.design/":"https://relayserver.spline.design/";async function N3(i){try{return(await(await fetch(E3()+"session?uuidfile="+i)).json()).token}catch(t){console.error("Token generation error:",t)}}var Eh=class{constructor(t){this.value=0;this.frequencies=new Float32Array(0);let e=new AudioContext;this.source=e.createMediaStreamSource(t),this.analyser=e.createAnalyser(),this.source.connect(this.analyser),this.analyser.fftSize=8192,this.analyser.smoothingTimeConstant=.1}getFrequencies(t=-100,e=-30){if(!this.analyser)throw new Error("Not connected, please call .connect() first");return Ld.getFrequencies(this.analyser,44100,void 0,"voice",t,e)}update(){let t=this.getFrequencies(),e=t.values.reduce((r,o)=>r+o,0)/t.values.length;this.value=e,this.frequencies=t.values}disconnect(){this.source.disconnect(),this.analyser.disconnect()}},nc=class{constructor(t,e,r){this.data=t;this.id=e;this.shared=r;this.emitter=hi();this.rafId=0;this.voice=0;this.frequencies=new Float32Array([0]);this.events=[];this.isConnected=!1;this.isToolsAdded=!1;this.tools=[];this.onMessage=t=>{let e=JSON.parse(t.data);if(this.appendEvent(e),e.type==="session.created"&&this.onSessionCreated(),e.type==="response.done"&&e.response?.output){for(let r of e.response.output)if(r.type==="function_call")for(let[o,n]of this.tools)r.name===o.name&&(n(JSON.parse(r.arguments)),setTimeout(()=>{this.sendClientEvent({type:"response.create",response:{instructions:"notice the user about what you just did"}})}))}};this.onSessionCreated=()=>{this.isToolsAdded||this.registerTools()};this.onOpen=()=>{this.events=[],this.isConnected=!0,this.sendClientEvent({type:"response.create",response:{instructions:"Say hi"}})};this.animate=()=>{if(this.rafId=requestAnimationFrame(this.animate),this.isConnected&&this.analyser){this.analyser.update();let t=this.analyser.value,e=this.analyser.frequencies;this.voice=t,this.frequencies=e,this.emitter.emit("voice",{value:t,frequencies:e})}}}update(t){this.data=t}setColorByName(t,e){let r=this.shared.getColorByName(t);if(r){let{id:o}=r,{r:n,g:a,b:s}=gb.hexStringToRgb(e)??{r:0,g:0,b:0};this.shared.updateColor(o,{r:n/255,g:a/255,b:s/255})}}async connect(){if(this.isConnected)return;let t=await N3(this.data.integration.hash);this.pc=new RTCPeerConnection,this.audioElement=document.createElement("audio"),this.audioElement.autoplay=!0,this.pc.ontrack=l=>{let c=l.streams[0];this.audioElement.srcObject=c,this.analyser=new Eh(c)};let e=await navigator.mediaDevices.getUserMedia({audio:!0});this.pc.addTrack(e.getTracks()[0]),this.dc=this.pc.createDataChannel("oai-events"),this.dc.addEventListener("message",this.onMessage),this.dc.addEventListener("open",this.onOpen);let r=await this.pc.createOffer();await this.pc.setLocalDescription(r);let s={type:"answer",sdp:await(await fetch(`https://api.openai.com/v1/realtime?model=${I3}`,{method:"POST",body:r.sdp,headers:{Authorization:`Bearer ${t}`,"Content-Type":"application/sdp"}})).text()};await this.pc.setRemoteDescription(s),this.animate()}appendEvent(t){this.events=[t,...this.events]}sendClientEvent(t){this.dc?(t.event_id=t.event_id||crypto.randomUUID(),this.dc.send(JSON.stringify(t)),this.appendEvent(t)):console.error("Failed to send message - no data channel available",t)}registerTools(){this.isToolsAdded=!0,this.registerTool({type:"function",name:"set_personality_color",description:"returns a color based on the voice personality of the ai assistant. This should be called by the voice assistant each time it is asks to speak differently. If a color cannot be associated to the personality, the color should be a neutral color.",parameters:{type:"object",properties:{color:{type:"string",description:"css hex color string, reflecting the personality"},personality:{type:"string",description:"the personality of the voice assistant"}},required:["color","personality"]}},({color:n})=>{this.setColorByName("Voice Assistant Color",n)});let t=this.shared.getVariablesNames().join(", ");this.registerTool({type:"function",name:"set_variable",description:"Sets a Spline variable value when asked by the user.",parameters:{type:"object",properties:{name:{type:"string",description:`The name of the variable that needs to be set. Here's a list of available variables: ${t}. It the variable does not exist, don't call the function and warn the user about it.`},value:{type:"string",description:"The new value for this variable, should always be a string even for number and boolean variables, assume that the value will be cast to the proper type afterwards."}},required:["name","value","type"]}},({name:n,value:a})=>{let s=this.shared.getVariableByName(n);if(s){let l=this.shared.getVariable(s.id),c;typeof l=="number"?c=parseFloat(a):typeof l=="boolean"?c=a.toLowerCase()==="true":c={textValue:a},this.shared.updateVariable(s.id,c)}});let e=this.shared.getColorNames().join(", ");this.registerTool({type:"function",name:"set_color",description:"Sets a Spline color asset value when asked by the user.",parameters:{type:"object",properties:{name:{type:"string",description:`The name of the color asset that needs to be set. Here's a list of available color assets: ${e}. It the color asset does not exist, don't call the function and warn the user about it.`},value:{type:"string",description:"css hex color string"}},required:["name","value"]}},({name:n,value:a})=>{this.setColorByName(n,a)});let r=this.shared.scene,o=[];r.traverseEntity(n=>{n.data.events.forEach(a=>{if(a.data.type==="AIAssistantTrigger"){let{description:s}=a.data;o.push(s)}})}),this.registerTool({type:"function",name:"trigger_event",description:"Trigger an event by name, here are the available events, please match what the user is asking for to one of these if it applies, otherwise don't call the function and warn the user.",parameters:{type:"object",properties:{description:{type:"string",description:`The name of the event that needs to be triggered. Here's a list of available events: ${JSON.stringify(o)}.`},direction:{type:"string",description:"default is forward, but can be forward or backward. Always set to forward unless the user ask to reverse or cancel the event, then set to backward."}},required:["description","direction"]}},({description:n,direction:a})=>{this.emitter.emit("trigger_event",{description:n,direction:a})}),this.sendClientEvent({type:"session.update",session:{tools:this.tools.map(([n])=>n)}})}registerTool(t,e){this.tools.push([t,e])}disconnect(){cancelAnimationFrame(this.rafId),this.analyser?.disconnect(),this.voice=0,this.isConnected=!1,this.isToolsAdded=!1,this.dc?.removeEventListener("message",this.onMessage),this.dc?.removeEventListener("open",this.onOpen),this.dc?.close(),this.pc?.getSenders().forEach(t=>{t.track&&t.track.stop()}),this.pc?.close(),this.pc=void 0}computeAnalysisForListenerEvent(t){if(t.analysis==="range"){let e=this.frequencies.slice(...t.analysisRange);return e.reduce((r,o)=>r+o,0)/e.length}return t.analysis==="single"?this.frequencies[t.analysisSingle]:this.voice}on(t,e){this.emitter.on(t,e)}off(t,e){this.emitter.off(t,e)}};function fv(i){return"variable_"+i}var Dh=class extends wd{constructor(e){super();this.shared=e}create(e){return new Ds(e,this.shared)}},qn=class{constructor(t,e={},r=!0,o=!1){this.data=t;this.needsJitter=r;this.enableLocalStorageForPersistentVariables=o;this.geometryCache=new ic(!0);this.geometryCache2=new ic(!1);this.imageHolderCache=new Dh(this);this.thisContext={scene:lv,shared:this};this.deletedMaterial=new Hn(Wt.defaultTwoLayerData("phong"),this.thisContext,"");this.deletedImage=new Vr(Fu.emptyImage,this);this.deletedVideo=new Vr(Ra.defaultVideo,this);this.materials={};this.images={};this.uiBuffers={};this.videos={};this.colors={};this.audios={};this.particles={};this.fonts={};this.timelineAnimations={};this.variables={};this.userAPIs={};this.userWebhooks={};this.mouseProperty=null;this.raycastProperty=null;this.requestRender=()=>{this._requestRender&&this._requestRender()};if(e.images)for(let[n,a]of Object.entries(e.images))this.addImage(n,a);if(e.videos)for(let[n,a]of Object.entries(e.videos))this.addVideo(n,a);if(e.audios)for(let[n,a]of Object.entries(e.audios))this.addAudio(n,a);if(e.particles)for(let[n,a]of Object.entries(e.particles))this.addParticle(n,a);this.reset(t)}setRequestRender(t){this._requestRender=t}getImageLoadPromises(){return Object.values(this.images).map(t=>t.loadPromise)}setEntityOpContext(t){this.entityOpContext=t}reset(t,e=!1,r=!1){this.data=t,this.resetLib(t.lib);for(let{id:o,data:n}of t.variables)this.addVariableHolder(o,n),e&&this.updateVariableHolder(o,n);for(let[o,n]of Object.entries(t.userAPIs??{}))this.addUserAPI(o,n);for(let[o,n]of Object.entries(t.userWebhooks??{}))this.addUserWebhook(o,n);if(!r){for(let[o,n]of Object.entries(t.images))this.addImage(o,n);for(let[o,n]of Object.entries(t.videos))this.addVideo(o,n)}for(let[o,n]of Object.entries(t.colors))this.addColor(o,n);for(let[o,n]of Object.entries(t.materials))this.addMaterial(o,n);for(let[o,n]of Object.entries(t.audios))this.addAudio(o,n);for(let[o,n]of Object.entries(t.particles))this.addParticle(o,n);for(let[o,n]of Object.entries(t.fonts))this.addFont(o,n);for(let[o,n]of Object.entries(t.timelineAnimations??{}))this.addAnimation(o,n)}addMaterial(t,e){if(this.materials[t]){let r=this.materials[t];r.reset(e,this.thisContext),r.dispose()}else{let r=new Hn(e,this.thisContext,t);this.materials[t]=r}}deleteMaterial(t){this.materials[t]&&(this.materials[t].nodeMaterialDispose(),delete this.materials[t])}getMaterial(t){let e=this.materials[t];return e}getMaterialOrDeletedPlaceholder(t){return this.materials[t]??this.deletedMaterial}material(t){return typeof t=="string"?this.getMaterialOrDeletedPlaceholder(t):t==null?(console.error("material is undefined or null"),this.deletedMaterial):new kn(t,this.thisContext)}getMaterials(){return this.materials}addImage(t,e){return this.images[t]?(this.onColorOrImageUpdate&&this.onColorOrImageUpdate(),this.images[t].updateSrc(e.data),!0):(this.images[t]=new Vr(e,this),!1)}deleteImage(t){let e=this.images[t];e&&(e.dispose(),delete this.images[t])}getDefaultImage(){return this.images.image_0}getImage(t){return this.images[t]??this.deletedImage}image(t){return typeof t=="string"?this.getImage(t):this.imageHolderCache.load(t)}addUIBuffer(t,e){return this.uiBuffers[t]?(this.onColorOrImageUpdate&&this.onColorOrImageUpdate(),this.uiBuffers[t].updateSrc(e),!0):(this.uiBuffers[t]=new Vr(e,this),!1)}uiBuffer(t){return this.uiBuffers[t]}addVideo(t,e){return this.videos[t]?(this.videos[t].updateSrc(e.data),!0):(this.videos[t]=new Vr(e,this),!1)}deleteVideo(t){let e=this.videos[t];e&&(e.dispose(),delete this.videos[t])}getVideo(t){return this.videos[t]??this.deletedVideo}video(t){return typeof t=="string"?this.getVideo(t):this.imageHolderCache.load(t)}addColor(t,e){return this.colors[t]?(this.onColorOrImageUpdate&&this.onColorOrImageUpdate(),"a"in e?this.colors[t].setRGBA(e.r,e.g,e.b,e.a):this.colors[t].setRGBA(e.r,e.g,e.b,1),!0):("a"in e?this.colors[t]=new Zi(e.r,e.g,e.b,e.a):this.colors[t]=new Zi(e.r,e.g,e.b,1),!1)}updateColor(t,e){if(this.colors[t]){this.onColorOrImageUpdate&&this.onColorOrImageUpdate();let r=this.colors[t];return this.colors[t].r=e.r??r.r,this.colors[t].g=e.g??r.g,this.colors[t].b=e.b??r.b,this.colors[t].a=e.a??r.a,!0}return!1}deleteColor(t){this.colors[t]&&delete this.colors[t]}getColor(t){return this.colors[t]}getColorNames(){return Object.values(this.data.colors).map(t=>t.name)}getColorByName(t){for(let e in this.data.colors)if(this.data.colors[e].name===t)return{color:this.colors[e],id:e}}color(t){let e;if(typeof t=="string"){let r=this.getColor(t);r?e=r:(console.warn("Tried to create color layer params with a color key that does not exist in the assets manager"),e=new qt(0,0,0,0))}else return"a"in t?new qt(t.r,t.g,t.b,t.a):new qt(t.r,t.g,t.b,1);return e}addAudio(t,e){this.audios[t]=e}getAudio(t){let e=this.audios[t];if(e instanceof Wn)return e;{let r=new Wn({src:e.data});return this.audios[t]=r,r}}addParticle(t,e){this.particles[t]=e}getParticle(t){return this.particles[t]}deleteParticle(t){this.particles[t]&&delete this.particles[t]}deleteAudio(t){let e=this.audios[t];e&&(e instanceof Wn&&e.dispose(),delete this.audios[t])}addFont(t,e){this.fonts[t]=new Ed(e),this.fonts[t].loadingPromise.then(()=>this.requestRender())}getFont(t){return this.fonts[t]}deleteFont(t){this.fonts[t]&&delete this.fonts[t]}addAnimation(t,e){this.timelineAnimations[t]=e}getAnimation(t){return this.timelineAnimations[t]}deleteAniamtion(t){this.timelineAnimations[t]&&delete this.timelineAnimations[t]}dispose(){Object.keys(this.materials).forEach(e=>this.deleteMaterial(e)),this._requestRender=void 0,Object.values(this.audios).forEach(e=>{e instanceof Wn&&e.dispose()}),this.audios={},this.particles={},this.geometryCache.dispose(),this.geometryCache2.dispose()}addVariableHolder(t,e){if(this.variables[t]===void 0){let r=e.value;if(this.enableLocalStorageForPersistentVariables&&e.persistent){let o=localStorage.getItem(fv(t));r=o!==null?JSON.parse(o):e.value}return this.variables[t]={value:r,locations:[],persistent:e.persistent},"dynamicVariableType"in e&&(this.variables[t].dynamicVariablePlayState="Playing",this.variables[t].dynamicVariableToggleIsForward=void 0),!0}return this.variables[t].value=e.value,!1}resetDynamicVariablePlayState(){for(let t in this.variables)this.variables[t].dynamicVariablePlayState!==void 0&&(this.variables[t].dynamicVariablePlayState="Playing",this.variables[t].dynamicVariableToggleIsForward=void 0)}updateVariableHolder(t,e){this.updateVariable(t,e.value)}updateVariable(t,e){if(this.variables[t]===void 0)return!1;this.variables[t].value=e,this.enableLocalStorageForPersistentVariables&&this.variables[t].persistent&&localStorage.setItem(fv(t),JSON.stringify(e));let r=e;for(;typeof r=="string";)r=this.variables[r].value;let o=this.entityOpContext.scene;for(let n=this.variables[t].locations.length-1;n>=0;n--){let a=this.variables[t].locations[n];if(a[0]==="material"){let s=a[1],l=r,c={scene:o,shared:this},u=a.slice(2);o.traverseMaterial(p=>{let f=p.root??p;f.uuid===s&&f.onVariableUpdate(u,l,c)});let d=this.materials[s];d&&d.onVariableUpdate(u,l,c)}else{let s=o.find(a[0]);if(s===void 0){this.variables[t].locations.splice(n,1);continue}if(a[1]!=="geometry"&&a[1]!=="particles"){for(let l=1;l<a.length-1;l++)s=s[a[l]];a[1]==="rotation"?s[a[a.length-1]]=r*Nh.MathUtils.DEG2RAD:s[a[a.length-1]]=r}if(s=o.find(a[0]),s.type==="ParticleEmitter"&&s.updateVariableState(r,a),Ge.is(s))if(a[1]==="position"||a[1]==="rotation"||a[1]==="scale")s.onVariableUpdate();else if(a[1]==="geometry"){let l=s;s.component&&(l=s.component);let c=l.dataPatched;l.chooseGeoemtryCache(this).forceDelete(c.geometry),l.createGeometryDelayed(this.entityOpContext),l.onVariableUpdate(!0),l.invalidateDownstreamBooleanData(),l.instances.forEach(u=>{let d=u.dataPatched;u.chooseGeoemtryCache(this).forceDelete(d.geometry),u.createGeometryDelayed(this.entityOpContext),u.onVariableUpdate(!0),u.invalidateDownstreamBooleanData()})}else a[1]==="morphTargetInfluences"&&s.updateMorphInfluences(a[2],r)}}return this.requestRender(),!0}deleteVariable(t){this.variables[t]&&delete this.variables[t]}getVariable(t,e){if(Array.isArray(t)){if(t[0]==="mouse")return this.mouseProperty?.[t[1]]??0;if(t[0]==="raycast")return this.raycastProperty?.[t[1]]??0;let r=this.entityOpContext.scene.find(t[0]);if(t[1]==="width"||t[1]==="height"||t[1]==="depth")return r.geometry.userData.parameters[t[1]];for(let o=1;o<t.length;o++)r=r[t[o]];return t[1]==="rotation"&&(r*=Nh.MathUtils.RAD2DEG),r}for(let r in this.variables){if(e===void 0)break;let o=this.variables[r],n=o.locations?.findIndex(a=>dt.equal(a,e));n!==void 0&&n!==-1&&o.locations.splice(n,1)}if(typeof t=="string"){let r=t,o=t;do{if(o=r,this.variables[r]===void 0)break;let n=this.variables[r].value;e&&this.variables[o]!==void 0&&this.variables[o].locations.push(e),r=n}while(typeof r=="string");return r}else return t}getVariables(){return this.variables}getVariablesNames(){return this.data.variables.map(t=>t.data.name)}getVariableByName(t){for(let e of this.data.variables)if(e.data.name===t)return{variable:e.data,id:e.id}}getDynamicVariablePlayState(t){return this.variables[t]?.dynamicVariablePlayState}setDynamicVariablePlayState(t,e){this.variables[t]!==void 0&&(this.variables[t].dynamicVariablePlayState=e)}getDynamicVariableToggleIsForward(t){return this.variables[t]?.dynamicVariableToggleIsForward}setDynamicVariableToggleIsForward(t,e){this.variables[t]!==void 0&&(this.variables[t].dynamicVariableToggleIsForward=e)}resetLib(t){for(let[e,r]of Object.entries(t.images))this.addImage(e,r.asset);for(let[e,r]of Object.entries(t.audios))this.addAudio(e,r.asset);for(let[e,r]of Object.entries(t.particles))this.addParticle(e,r.asset);for(let[e,r]of Object.entries(t.colors))this.addColor(e,r.asset);for(let[e,r]of Object.entries(t.fonts))this.addFont(e,r.asset);for(let[e,r]of Object.entries(t.materials))this.addMaterial(e,r.asset);for(let[e,r]of Object.entries(t.videos))this.addVideo(e,r.asset);for(let[e,r]of Object.entries(t.variables))this.addVariableHolder(e,r.asset)}updateLibByOp(t,e){t.path[0]==="images"?t.path.length===1&&t.type===1?this.addImage(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteImage(t.id):t.path[0]==="videos"?t.path.length===1&&t.type===1?this.addVideo(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteVideo(t.id):t.path[0]==="audios"?t.path.length===1&&t.type===1?this.addAudio(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteAudio(t.id):t.path[0]==="particles"?t.path.length===1&&t.type===1?this.addParticle(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteParticle(t.id):t.path[0]==="colors"?t.path.length===1&&t.type===1?this.addColor(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteColor(t.id):t.path[0]==="materials"?t.path.length===1&&t.type===1?this.addMaterial(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteMaterial(t.id):t.path[0]==="fonts"?t.path.length===1&&t.type===1?this.addFont(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteFont(t.id):t.path[0]==="variables"?t.path.length===1&&t.type===1?this.addVariableHolder(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteVariable(t.id):t.path[0]==="components"&&e.updateByLibOp(t,this)}updateByOp(t,e,r){if(this.data=e,t.path[0]==="images")t.path.length===2&&t.type===0?t.props.data&&this.getImage(t.path[1]).updateSrc(t.props.data):t.path.length===1&&t.type===1?this.addImage(t.id,t.data):t.path.length===1&&t.type===2&&this.deleteImage(t.id);else if(t.path[0]==="videos")t.path.length===2&&t.type===0?t.props.data&&this.getVideo(t.path[1]).updateSrc(t.props.data):t.path.length===1&&t.type===1?this.addVideo(t.id,t.data):t.path.length===1&&t.type===2&&this.deleteVideo(t.id);else if(t.path[0]==="audios")t.path.length===2&&t.type===0?t.props.data&&this.addAudio(t.path[1],e.audios[t.path[1]]):t.path.length===1&&t.type===1?this.addAudio(t.id,t.data):t.path.length===1&&t.type===2&&this.deleteAudio(t.id);else if(t.path[0]==="particles")t.path.length===2&&t.type===0?t.props.data&&this.addParticle(t.path[1],e.particles[t.path[1]]):t.path.length===1&&t.type===1?this.addParticle(t.id,t.data):t.path.length===1&&t.type===2&&this.deleteParticle(t.id);else if(t.path[0]==="colors")t.path.length===2&&t.type===0?this.updateColor(t.path[1],t.props):t.path.length===1&&t.type===1?this.addColor(t.id,t.data):t.path.length===1&&t.type===2&&this.deleteColor(t.id);else if(t.path[0]==="materials")t.path.length===1&&t.type===1?this.addMaterial(t.id,t.data):t.path.length===1&&t.type===2?this.deleteMaterial(t.id):t.path.length>1&&this.getMaterial(t.path[1]).updateByOp(vt.drop(t,2),e.materials[t.path[1]],{shared:this,scene:r});else if(t.path[0]==="fonts")t.path.length===2&&t.type===0?this.updateFont(t.path[1],t,r):t.path.length===1&&t.type===1?this.addFont(t.id,t.data):t.path.length===1&&t.type===2&&this.deleteFont(t.id);else if(t.path[0]==="variables")t.path.length===2&&t.type===0?"value"in t.props?this.updateVariable(t.path[1],t.props.value):"persistent"in t.props&&(this.variables[t.path[1]].persistent=t.props.persistent):t.path.length===1&&t.type===4?this.addVariableHolder(t.id,t.data):t.path.length===1&&t.type===5&&this.deleteVariable(t.id);else if(t.path[0]==="userAPIs"){if(t.path.length===1&&t.type===1)this.addUserAPI(t.id,t.data);else if(t.path.length===1&&t.type===2)this.deleteUserAPI(t.id);else if(typeof t.path[1]=="string"){let o=e.userAPIs[t.path[1]];if(o){let n=t.type===0&&t.props.debounce===void 0,a=this.getUserAPI(t.path[1]);a instanceof nc?a.update(o):a?.update(o,this,n)}}}else if(t.path[0]==="userWebhooks"){if(t.path.length===1&&t.type===1)this.addUserWebhook(t.id,t.data);else if(t.path.length===1&&t.type===2)this.deleteUserWebhook(t.id);else if(typeof t.path[1]=="string"){let o=e.userWebhooks[t.path[1]];o&&this.getUserWebhook(t.path[1])?.update(o)}}else t.path[0]==="lib"&&this.updateLibByOp(vt.drop(t,1),r)}updateFont(t,e,r){if(e.props.url){let o=this.getFont(t),n={...this.data.fonts[t],url:e.props.url};o.update(n),o.loadingPromise.then(()=>this.requestRender()),r.updateFont(t,this)}}addUserAPI(t,e){return this.userAPIs[t]?(this.userAPIs[t].update(e,this),!0):this.openAIRealtime?.id===t?(this.openAIRealtime.update(e),!0):e.integration?.type==="VoiceAssistant"?(this.openAIRealtime=new nc(e,t,this),!1):(this.userAPIs[t]=new sd(t,e,this),!1)}getUserAPI(t){return this.openAIRealtime?.id===t?this.openAIRealtime:this.userAPIs[t]}getUserAPIs(){return this.userAPIs}deleteUserAPI(t){let e=this.userAPIs[t];e&&(e.dispose(),delete this.userAPIs[t])}addUserWebhook(t,e){return this.userWebhooks[t]?(this.userWebhooks[t].update(e),!0):(this.userWebhooks[t]=new Dd(t,e),!1)}getUserWebhook(t){return this.userWebhooks[t]}getUserWebhooks(){return this.userWebhooks}deleteUserWebhook(t){let e=this.userWebhooks[t];e&&(e.dispose(),delete this.userWebhooks[t])}get scene(){return this.entityOpContext.scene}},hv=new qn(qr.emptyData());var Er=class extends Xt{updateByPatchedOp(e,r,o){if(super.updateByPatchedOp(e,r,o),e0(e.path,["materials"])!==null&&e.type===0&&Array.isArray(this.material))for(let[n,a]of Object.entries(e.props)){let s=o.shared.material(a);this.material[Number(n)]=s}else if(Ue(e.path,["material"])&&this.material instanceof Ir)"material"in r&&typeof r.material!="string"&&this.material.updateByOp(vt.drop(e,1),r.material,o);else if(Ue(e.path,["materials","*"])&&Array.isArray(this.material)){let n=e.path[1];if("materials"in r&&n<this.material.length){let a=r.materials[n];typeof a!="string"&&this.material[n].updateByOp(vt.drop(e,2),a,o)}}}get needsAO(){return this.material!==void 0?(Array.isArray(this.material)?this.material[0]:this.material).hasAO:!1}updateState(e,r){super.updateState(e,r),e.castShadow!==void 0&&(this.castShadow=e.castShadow),e.receiveShadow!==void 0&&(this.receiveShadow=e.receiveShadow);let o=this.dataPatched;this.dataPatched.type==="Mesh"&&!!this.dataPatched.geometry.shapeBlendNode&&this.layers.set(9);let a;this.dataPatched.type==="Mesh"&&this.dataPatched.geometry.type==="ShapeBlendGeometry"&&(a={resolutionLevel:this.dataPatched.geometry.resolutionLevel,useChildrenColors:this.dataPatched.geometry.useChildrenColors}),e.geometry?.type!=="NonParametricGeometry"&&"material"in e&&e.material!==void 0&&(this.disposeMaterial(),this.material=r.shared.material(e.material).getFlavor(o.flatShading,o.side,o.wireframe,a),r.scene.markNeedsUpdateRendererDirty()),(e.geometry?.type==="NonParametricGeometry"||"materials"in e)&&("materials"in e&&e.materials!==void 0?(this.disposeMaterial(),this.material=e.materials.map(l=>r.shared.material(l).getFlavor(o.flatShading,o.side,o.wireframe)),r.scene.markNeedsUpdateRendererDirty()):"material"in e&&e.material!==void 0&&(this.disposeMaterial(),this.material=[r.shared.material(e.material).getFlavor(o.flatShading,o.side,o.wireframe)],r.scene.markNeedsUpdateRendererDirty()));let s=this.data;if(s.geometry?.type!=="NonParametricGeometry"&&"materials"in s&&s.materials!==void 0&&(this.disposeMaterial(),this.material=r.shared.material(s.materials[0]).getFlavor(o.flatShading,o.side,o.wireframe)),e.flatShading!==void 0||e.wireframe!==void 0||e.side!==void 0)if(Array.isArray(this.material))for(let l=0;l<this.material.length;l++)this.material[l]=this.material[l].getFlavor(o.flatShading,o.side,o.wireframe);else this.material=this.material.getFlavor(o.flatShading,o.side,o.wireframe,a)}disposeMaterial(){this.material&&Ic(this.material).forEach(e=>{e instanceof Ir&&(e instanceof Hn||e.nodeMaterialDispose())})}dispose(){this.disposeMaterial(),super.dispose()}};var zr=require("three");var mv=new zr.Vector3,yv=new zr.Vector4,gv=new zr.Vector4,_3=new zr.Vector3,xv=new zr.Matrix4,ht=class extends Er{constructor(e,r,o){super(e,r);this.data=r;this.isSkinnedMesh=!1;this.localGeometry=void 0,r.bindMode&&r.bindMatrix&&(this.bindMode=r.bindMode,this.bindMatrix=new zr.Matrix4().fromArray(r.bindMatrix),this.bindMatrixInverse=new zr.Matrix4)}chooseGeoemtryCache(e){return e.geometryCache}markGeometryAsReachable(e){this.geometryCreateDeleyed instanceof zr.BufferGeometry&&this.chooseGeoemtryCache(e).markAsReachable(this.dataPatched.geometry,this.geometryCreateDeleyed)}get geometry(){if(this.localGeometry!==void 0)return this.localGeometry;if(this.geometryCreateDeleyed instanceof qn){let e=this.geometryCreateDeleyed,r=this.chooseGeoemtryCache(e);this.geometryCreateDeleyed=r.get(this.dataPatched.geometry,e,this)}return this.geometryCreateDeleyed}set geometry(e){this.localGeometry=e}get is2DAndNoDepth(){let e=this.dataPatched.geometry;return vl.is2DParametricMesh(e.type)&&e.depth===0}get is2DType(){return vl.is2DParametricMesh(this.geometry.userData.type)}get isNonParametric(){return this.geometry.userData.type==="NonParametricGeometry"}updateByPatchedOp(e,r,o){super.updateByPatchedOp(e,r,o),Ue(e.path,["geometry"])&&this.updateByPatchedOpGeometry(vt.drop(e,1),r.geometry,o)}removeInteractionGeometry(e){this.localGeometry?.dispose(),this.localGeometry=void 0}updateGeometryInteractions(e,r){this.invalidateDownstreamBooleanData();let o=this.data.geometry.type;if(o==="NonParametricGeometry"||o==="SubdivGeometry"){let n=e;if(this.localGeometry===void 0){let f={...this.data.geometry,...n};this.localGeometry=Go(f,r,this.data.flatShading,this)}let a,s,l;n.scaleBaked?[a,s,l]=n.scaleBaked:{width:a,height:s,depth:l}=n;let c=this.localGeometry.userData,u=typeof a=="number"?a:1,d=typeof s=="number"?s:1,p=typeof l=="number"?l:1;c.sxPrev!==void 0&&jl(this.localGeometry.attributes,u/c.sxPrev,d/c.syPrev,p/c.szPrev),c.sxPrev=u,c.syPrev=d,c.szPrev=p}else{let n={...this.data.geometry,...e};this.localGeometry?.dispose(),this.localGeometry=Go(n,r,this.data.flatShading,this)}}refreshAttachedClonersInteractions(e){for(let r of this.attachedSurfaceCloners)r.update(e)}refreshAttachedCloners(e){for(let r of this.attachedSurfaceCloners)e.scene.addPendingUpdateCloner(r.object)}refreshAttachedPaths(e){for(let r of this.attachedPaths)e.scene.addPendingCommand(()=>r.updateShape())}createGeometryDelayed(e){this.geometryCreateDeleyed=e.shared,this.refreshAttachedCloners(e),this.refreshAttachedPaths(e)}updateByPatchedOpGeometry(e,r,o){let n=!1;e.type===0&&e.path.length===0&&Object.keys(e.props).includes("scaleBaked")&&this.geometryCreateDeleyed instanceof zt&&this.chooseGeoemtryCache(o.shared).mutateIfUnique(this.geometryCreateDeleyed.data,r)===this.geometryCreateDeleyed&&(n=!0,this.geometryCreateDeleyed.mutateDirectlyScaleBaked(r,e.props.scaleBaked),this.refreshAttachedCloners(o),this.refreshAttachedPaths(o)),n||(o.scene?.markGeometryCacheDirty(),this.createGeometryDelayed(o)),this.resetBBoxNeedsUpdate(),this.invalidateDownstreamBooleanData()}updateGeometryOnStateUpdate(e,r){this.createGeometryDelayed(r)}updateState(e,r){e.geometry!==void 0&&this.updateGeometryOnStateUpdate(e.geometry,r);let o=e.morphTargetInfluences;if(o){this.updateMorphTargets(),this.geometry.morphTargetsRelative=!0;for(let{data:{name:n,value:a}}of o)this.updateMorphInfluences(n,r.shared.getVariable(a,[this.uuid,"morphTargetInfluences",n]))}super.updateState(e,r)}updateMorphInfluences(e,r){if(this.morphTargetDictionary===void 0)return;let o=this.morphTargetDictionary[e];o!==void 0&&(this.morphTargetInfluences[o]=r)}updateGeometryGroupsIfNeeded(){Array.isArray(this.material)&&this.geometry.groups.length===0&&this.geometry.addGroup(0,Math.max(this.geometry.getIndex()?.count??0,this.geometry.getAttribute("position").count),0)}updateEntityBoxSize(e,r){let o=this.geometry.userData.parameters;this.is2DType?e.set(0,0,o.depth*.5):this.isNonParametric?(e.setScalar(0),this.geometry.boundingSphere&&e.copy(this.geometry.boundingSphere.center),r.set(o.width,o.height,o.depth??0).multiplyScalar(.5)):o.centerOffset?e.fromArray(o.centerOffset):e.setScalar(0),r.set(o.width,o.height,o.depth??0).multiplyScalar(.5)}updateMatrixWorld(e){super.updateMatrixWorld(e),this.bindMode==="attached"?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode==="detached"&&this.bindMatrixInverse.copy(this.bindMatrix).invert()}bind(e,r){this.skeleton=e,this.isSkinnedMesh=!0,r===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),r=this.matrixWorld),this.bindMatrix.copy(r),this.bindMatrixInverse.copy(r).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(e){let r=new zr.Vector4,o=this.geometry.attributes.skinWeight;for(let n=0,a=o.count;n<a;n++){r.fromBufferAttribute(o,n);let s=1/r.manhattanLength();s!==1/0?r.multiplyScalar(s):r.set(1,0,0,0),o.setXYZW(n,r.x,r.y,r.z,r.w)}}boneTransform(e,r){let o=this.skeleton;if(o===void 0)return;let n=this.geometry;yv.fromBufferAttribute(n.attributes.skinIndex,e),gv.fromBufferAttribute(n.attributes.skinWeight,e),mv.copy(r).applyMatrix4(this.bindMatrix),r.set(0,0,0);for(let a=0;a<4;a++){let s=gv.getComponent(a);if(s!==0){let l=yv.getComponent(a);xv.multiplyMatrices(o.bones[l].matrixWorld,o.boneInverses[l]),r.addScaledVector(_3.copy(mv).applyMatrix4(xv),s)}}return r.applyMatrix4(this.bindMatrixInverse)}};function R3(i){if(i.geometry.attributes.extrudeNormal||!i.geometry.attributes.position||!i.geometry.attributes.normal)return;let t=new Map,e=i.geometry.attributes,r=e.position.array,o=e.normal.array,n=new Float32Array(r.length);for(let a=0;a<r.length;a+=3){let s=`${r[a]}_${r[a+1]}_${r[a+2]}`,l=new Gr.Vector3(o[a],o[a+1],o[a+2]);t.has(s)?t.get(s)?.normals.push(l):t.set(s,{normals:[l],result:new Gr.Vector3})}t.forEach((a,s)=>{for(let l of a.normals)a.result.add(l);a.result.divideScalar(a.normals.length)});for(let a=0;a<r.length;a+=3){let s=`${r[a]}_${r[a+1]}_${r[a+2]}`,l=t.get(s)?.result;l&&(n[a]=l.x,n[a+1]=l.y,n[a+2]=l.z)}i.geometry.setAttribute("extrudeNormal",new Gr.Float32BufferAttribute(n,3))}function L3(i){if(i.geometry.attributes.extrudeNormals||!i.geometry.attributes.position)return;let e=i.geometry.attributes.position.array,r=new Float32Array(e.length),o=new Gr.Vector3;for(let n=0;n<e.length;n+=3)o.set(e[n],e[n+1],e[n+2]).normalize(),r[n]=o.x,r[n+1]=o.y,r[n+2]=o.z;i.geometry.setAttribute("extrudeNormal",new Gr.Float32BufferAttribute(r,3))}function Ls(i){if(Array.isArray(i.material)){for(let t of i.material)if(t.getLayersOfType("outline").length===0)return}else if(!(i.material instanceof Ir)||i.material.getLayersOfType("outline").length===0)return;i instanceof ht&&i.is2DAndNoDepth?L3(i):R3(i)}function Bs(i){if(!i.geometry.attributes.position)return;let e=i.geometry.attributes.position.array,r=new Float32Array(e.length),o=parseInt(i.uuid.replace(/\D/g,"")),n=[Gr.MathUtils.seededRandom(o),Gr.MathUtils.seededRandom(o+1e4),Gr.MathUtils.seededRandom(o+2e4)];for(let a=0;a<e.length;a++)r[a]=n[a%3];i.geometry.setAttribute("randomColor",new Gr.BufferAttribute(r,3))}var ko=new vi.Box3,ac=new vi.Vector3;function bv(i){let t=!1;return i.scene.objects.traverse((e,r)=>{r.type==="Mesh"&&r.geometry.type==="SubdivGeometry"&&(t=!0)}),t}var $n=class extends ht{constructor(e,r,o){super(e,r,o);this.data=r;this.hiddenMatrixOld=new vi.Matrix4;this.smoothShading=!0;this.skipReactionUpdate=!1}chooseGeoemtryCache(e){return this.dataPatched.flatShading?e.geometryCache:e.geometryCache2}get subdivPointerNew(){return this.localGeometry!==void 0?this.subdivPointer:this.geometry.ensureSubdivPointer()}get originalGeometryNew(){return this.localGeometry!==void 0?this.originalGeometry:this.geometry.originalGeometry}get phongAngle(){return this.data.geometry.phongAngle??45}updateEntityBoxSize(e,r){let o=this.geometry.userData.parameters;e.copy(this.originalGeometryNew.boundingSphere.center),r.set(o.width,o.height,o.depth??0).multiplyScalar(.5)}createGeometryByControls(e){if(this.skipReactionUpdate===!0)return;let r=this.localGeometry?.uuid,{originalGeometry:o,subdividedGeometry:n,subdivPointer:a}=zt.build(e,this.subdivPointer,this.smoothShading,this.hasNonUniformScale?this.shearScale:void 0);this.subdivPointer=a,o!==void 0&&(this.originalGeometry?.dispose(),this.originalGeometry=o),n!==void 0&&(this.subdividedGeometry?.dispose(),this.subdividedGeometry=n??void 0),this.localGeometry=this.subdividedGeometry??this.originalGeometry,Ls(this),Bs(this),this.calcBoundingBox(),r&&(this.localGeometry.uuid=r)}updateState(e,r){if(super.updateState(e,r),e.flatShading!==void 0){let o=this.material;this.material=Array.isArray(o)?o.map(n=>n.getFlavor(!1,n.side,n.wireframe)):o.getFlavor(!1,o.side,o.wireframe),this.smoothShading=!e.flatShading,this.createGeometryDelayed(r)}}updateMesh(e=!1){zt.buildLevel(this.subdivPointer,!0,this.smoothShading?this.phongAngle:-1,this.originalGeometry,e&&this.hasNonUniformScale?this.shearScaleInv:void 0),this.subdividedGeometry&&zt.buildLevel(this.subdivPointer,!1,this.smoothShading?this.phongAngle:-1,this.subdividedGeometry,e&&this.hasNonUniformScale?this.shearScaleInv:void 0)}updateTopology(){this.originalGeometry.dispose(),this.originalGeometry=zt.buildLevel(this.subdivPointer,!0,this.smoothShading?this.phongAngle:-1),this.subdividedGeometry&&(this.subdividedGeometry.dispose(),this.subdividedGeometry=zt.buildLevel(this.subdivPointer,!1,this.smoothShading?this.phongAngle:-1)),this.localGeometry=this.subdividedGeometry??this.originalGeometry}raycast(e,r){let o=this.localGeometry;this.localGeometry=this.originalGeometryNew,Xt.prototype.raycast.call(this,e,r),this.localGeometry=o}activateSVDCompensation(){!this.hasNonUniformScale||(this.matrix.copy(this.matrixWorldRigid),this.hiddenMatrixOld.copy(this.hiddenMatrix),this.hiddenMatrix.copy(this.parent.matrixWorld).invert())}deactivateSVDCompensation(){!this.hasNonUniformScale||(this.updateMatrix(),this.hasNonUniformScale=void 0,this.hiddenMatrix.copy(this.hiddenMatrixOld))}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new vi.Sphere,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let r=e.attributes.position,o=e.boundingSphere.center;ko.setFromBufferAttribute(r),ko.getCenter(o),e.boundingSphere.radius=o.distanceTo(ko.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),ko.getSize(ac),this.hasNonUniformScale&&ac.divide(this.scale);let n={width:ac.x,height:ac.y,depth:ac.z};return this.geometry.userData.parameters=n,n}updateBoundingSphere(e){let r=this.originalGeometry;ko.min.set(e[0],e[2],e[4]),ko.max.set(e[1],e[3],e[5]),this.hasNonUniformScale&&(ko.min.applyMatrix4(this.shearScaleInv),ko.max.applyMatrix4(this.shearScaleInv)),r.boundingSphere===null&&(r.boundingSphere=new vi.Sphere);let o=r.boundingSphere.center;ko.getCenter(o),r.boundingSphere.radius=o.distanceTo(ko.max)}freeSubdivPointer(){this.subdivPointer&&(zt.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0),this.localGeometry=void 0,this.originalGeometry?.dispose(),this.subdividedGeometry?.dispose()}dispose(){super.dispose(),this.freeSubdivPointer()}updateByPatchedOpGeometry(e,r,o){super.updateByPatchedOpGeometry(e,r,o),this.localGeometry&&this.createGeometryByControls(r)}};var Ho=require("three"),vv=-1,B3=1,Sv={x:[1,0,0],"-x":[-1,0,0],y:[0,1,0],"-y":[0,-1,0],z:[0,0,1],"-z":[0,0,-1]},wv={polygon_center:0,edge:1,vertex:2},sc=(i,t)=>(e,r)=>!t||e===0||i===0?0:i*r/100,Ne=(i,t)=>{let e=Math.abs(t),r=e*-1;return(i-vv)*(e-r)/(B3-vv)+r},V3=new Ho.Vector3,Bd=new Ho.Vector3,z3=new Ho.Vector3,G3=new Ho.Vector3;function Vs(i,t){let e=z3.fromArray(i),r=G3.fromArray(t);Bd.copy(r).sub(e);let o=Bd.length();return Bd.normalize().multiplyScalar(o*.5),V3.copy(e).add(Bd).toArray()}var Kr=new Ho.Triangle,Vd=new Ho.Vector3,zd=new Ho.Vector3,Xn=new Ho.Vector3;function Pv(i){let t=[];for(let e=0;e<=i.index.count;e++)if(Vd.fromArray(i.index.array,e*3),Kr.setFromAttributeAndIndices(i.attributes.position,Vd.x,Vd.y,Vd.z),Kr.getNormal(zd),Kr.getMidpoint(Xn),!(isNaN(Xn.x)||isNaN(Xn.y)||isNaN(Xn.z))){let{a:r,b:o,c:n}=Kr,a=r.toArray(),s=o.toArray(),l=n.toArray(),c=r.distanceTo(o),u=o.distanceTo(n),d=n.distanceTo(r),p=Vs(a,s),f=Vs(s,l),h=Vs(l,a),m=[c,u,d],y=Math.max(...m),g=m.filter(P=>Math.round(P)===Math.round(y)).length>1,b=[],w=Kr.getMidpoint(Xn).toArray();y===c&&!g&&(b=[f,h,h],w=p),y===u&&!g&&(b=[p,h,h],w=f),y===d&&!g&&(b=[p,f,f],w=h),g&&(b=[p,f,h]),t.push({vertices:[a,s,l],faceCenters:b,midpoint:w,norm:Kr.getNormal(zd).toArray()})}return t}function Ov(i){let t=[],{position:e}=i.attributes;for(let r=0;r<e.count;r++){Kr.setFromAttributeAndIndices(e,r*3,r*3+1,r*3+2),Kr.getNormal(zd),Kr.getMidpoint(Xn);let o=Kr.a.toArray(),n=Kr.b.toArray(),a=Kr.c.toArray();t.push({vertices:[o,n,a],faceCenters:[Vs(o,n),Vs(n,a),Vs(a,o)],midpoint:Xn.toArray(),norm:zd.toArray()})}return t}var F3=4,j3=.5,Rh=i=>.5*(1-Math.cos(i*Math.PI)),Lh=class{constructor(){this.perlin=new Array(4095+1)}noise(t,e=0,r=0){if(this.perlin==null){this.perlin=new Array(4095+1);for(let g=0;g<4095+1;g++)this.perlin[g]=Math.random()}t<0&&(t=-t),e<0&&(e=-e),r<0&&(r=-r);let o=Math.floor(t),n=Math.floor(e),a=Math.floor(r),s=t-o,l=e-n,c=r-a,u,d,p=0,f=.5,h,m,y;for(let g=0;g<F3;g++){let b=o+(n<<4)+(a<<8);u=Rh(s),d=Rh(l),h=this.perlin[b&4095],h+=u*(this.perlin[b+1&4095]-h),m=this.perlin[b+16&4095],m+=u*(this.perlin[b+16+1&4095]-m),h+=d*(m-h),b+=256,m=this.perlin[b&4095],m+=u*(this.perlin[b+1&4095]-m),y=this.perlin[b+16&4095],y+=u*(this.perlin[b+16+1&4095]-y),m+=d*(y-m),h+=Rh(c)*(m-h),p+=h*f,f*=j3,o<<=1,s*=2,n<<=1,l*=2,a<<=1,c*=2,s>=1&&(o++,s--),l>=1&&(n++,l--),c>=1&&(a++,c--)}return p}noiseSeed(t){let e=(()=>{let a,s;return{setSeed(l){s=a=(l??Math.random()*4294967296)>>>0},getSeed(){return a},rand(){return s=(1664525*s+1013904223)%4294967296,s/4294967296}}})();e.setSeed(t),this.perlin=new Array(4095+1);for(let r=0;r<4095+1;r++)this.perlin[r]=e.rand()}},Tv=Lh;var zs=require("three");var Cv=new zs.Vector3,Av=new zs.Matrix4,Mv=new zs.Ray;function Iv(i){let t=!1;return i.scene.objects.traverse((e,r)=>{r.type==="Mesh"&&(r.geometry.type==="TextGeometry"||r.geometry.type==="InputGeometry")&&(t=!0)}),t}var rn=class extends ht{constructor(e,r,o){super(e,r,o);this.data=r}get textGeometry(){return this.geometry}get charWidths(){return this.textGeometry.charWidths}get charCoords(){return this.textGeometry.charCoords}get wrappedText(){return this.textGeometry.wrappedText}get font(){return this.textGeometry.font}get initialOffsetY(){let e=this.dataPatched;return this.font?.getLineInitialOffsetY(this.lineHeight,this.wrappedText.length,typeof e.geometry.height=="number"?e.geometry.height:1,this.fontScale,e.geometry.verticalAlign)??0}get fontScale(){let e=this.dataPatched;return this.font?e.geometry.fontSize/this.font.unitsPerEm:1}get AD(){return Math.abs(this.ascender-this.descender)}get ascender(){return(this.font?.ascender??1)*this.fontScale}get descender(){return(this.font?.descender??1)*this.fontScale}get lineHeight(){let e=this.dataPatched;return e.geometry.fontSize*e.geometry.lineHeight}raycast(e,r){let{matrixWorld:o}=this;if(!(isNaN(e.ray.origin.x)||this.scale.x===0||this.scale.y===0||this.scale.z===0)&&(Av.copy(o).invert(),Mv.copy(e.ray).applyMatrix4(Av),Mv.intersectBox(this.singleBBox,Cv))){let n=Cv.applyMatrix4(o),a=e.ray.origin.distanceTo(n);r.push({distance:a,point:n.clone(),object:this})}}};var br=1e-4,Wo,Dv,_v,Rv,Ev=new tt.Vector3,Nv=new tt.Vector3;cd.then(i=>{Wo=i,Dv=[Wo.get_face_center,Wo.get_edge_midpoint,Wo.get_vertex_position],_v=[Wo.get_face_normal,Wo.get_edge_normal,Wo.get_vertex_normal],Rv=[Wo.face_count,Wo.edge_count,Wo.vertex_count]});var U3=new tt.Matrix4,k3=new tt.Matrix4,on=new tt.Vector3,Gd=new tt.Vector3,lc=new tt.Vector3,Bh=new tt.Vector3,H3=new tt.Vector3,W3=new tt.Vector3;function St(i,t){return[typeof i?.[0]=="number"?i[0]:typeof i?.[0]=="string"&&t?parseFloat(String(t.shared.getVariable(i[0])??"0")):0,typeof i?.[1]=="number"?i[1]:typeof i?.[1]=="string"&&t?parseFloat(String(t.shared.getVariable(i[1])??"0")):0,typeof i?.[2]=="number"?i[2]:typeof i?.[2]=="string"&&t?parseFloat(String(t.shared.getVariable(i[2])??"0")):0]}var Vh=class{constructor(t,e){this.data=t;this.is3D=e;this.perlin=new Tv;t.noiseType==="perlin"?(this.perlin.noiseSeed(t.seed),e?this.noise=(o,n,a)=>this.perlin.noise(o,n,a):this.noise=o=>this.perlin.noise(o)):e?this.noise=ux((0,Fd.default)(t.seed)):this.noise=cx((0,Fd.default)(t.seed??""))}},nn=class extends Ha(tt.Object3D){constructor(e,r){super();this.parameters=r;this.objectForSample=void 0;this._pendingMediaLoad=!1;this.random=null;this.object=e}resetOnMove(){this.removeFromParent(),this.parent=null}expandClones(e){if(this.parent===null)this.updateState(this.parameters,e);else for(let r of this.children)r instanceof co&&r.expand()}invalidateTransform(e){this.matrixWorldNeedsUpdate=!0,this.traverse(r=>{r instanceof co&&r.object===e&&(r.matrixWorldNeedsUpdate=!0)})}onObjUpdateMatrix(){this.parameters.type!=="toObject"&&(this.matrixWorldNeedsUpdate=!0)}update(e){switch(this._updateCount(e),this.parameters.type){case"radial":this._updateRadial(this.parameters,e);break;case"linear":this._updateLinear(this.parameters,e);break;case"grid":this._updateGrid(this.parameters,e);break;case"toObject":this._updateToObject(this.parameters,e)}for(let r of this.children)r.updateMatrix(),r.hasNonUniformScale&&(r.updateMatrixWorld(),r.updateMatrixWorldSVD())}_updateCount(e,r){let o;if(r!==void 0)o=r;else{let n=St(this.parameters.grid.count,e);o=this.parameters.type==="grid"?Math.round(n[0])*Math.round(n[1])*Math.round(n[2]):this.parameters.count}if(this.parameters.type==="toObject"){if(!this.parameters.toObject.object)o=0;else if(r===void 0&&this.parameters.toObject.spreadType!=="random")return}if(this.parameters.type==="toObject"&&this.objectForSample){let n=this.children;if(n.length===o)return;if(n.length<o)for(let a=0,s=o-n.length;a<s;++a){let l=new co(this.object);l.expand(),this.add(l)}else for(let a=0,s=n.length-o;a<s;++a)this.remove(n[a])}else{if(this.children.length===o)return;if(this.children.length<o)for(let n=0,a=o-this.children.length;n<a;++n){let s=new co(this.object);s.expand(),this.add(s)}else for(let n=0,a=this.children.length-o;n<a;++n)this.remove(this.children[n])}}getRandom(e,r=!1){return(this.random===null||this.random.data.seed!==e.seed||this.random.is3D!==r)&&(this.random=new Vh(e,r)),this.random}_updateRadial(e,r){let o=e.radial,n=o.start*tt.MathUtils.DEG2RAD,a=o.end*tt.MathUtils.DEG2RAD,s=n-a,l=St(o.rotation,r),c=new tt.Euler(l[0],l[1],l[2]),u;switch(o.axis){case"z":u=new tt.Vector3(0,0,1);break;case"y":u=new tt.Vector3(0,1,0);break;default:case"x":u=new tt.Vector3(1,0,0);break}let d=e.randomnessObject??No.defaultData([1,1,1]).randomnessObject,p=this.getRandom(d),f=sc(d.strength,this.parameters.randomness);for(let[h,m]of this.children.entries()){let y=h*(d.freqScale/10)+d.movement,g=p.noise(y,y,y),b=h+1,w=St(o.scale,r),P=St(d.scale,r);m.scale.x=w[0]+f(b,Ne(g,P[0]))||br,m.scale.y=w[1]+f(b,Ne(g,P[1]))||br,m.scale.z=w[2]+f(b,Ne(g,P[2]))||br,m.position.setScalar(0);let S=s/e.count*h-n;switch(o.axis){case"x":m.rotation.set(0,S,0);break;case"y":m.rotation.set(0,0,S);break;case"z":m.rotation.set(S,0,0);break}m.translateOnAxis(u,o.radius);let T=St(o.position,r),A=St(d.position,r);m.position.x+=T[0]+f(b,Ne(g,A[0])),m.position.y+=T[1]+f(b,Ne(g,A[1])),m.position.z+=T[2]+f(b,Ne(g,A[2]));let x=St(d.rotation,r),N=f(b,Ne(g,x[0])),E=f(b,Ne(g,x[1])),M=f(b,Ne(g,x[2]));o.alignment===!0?(m.rotation.x+=c.x+N,m.rotation.y+=c.y+E,m.rotation.z+=c.z+M):m.rotation.set(c.x+N,c.y+E,c.z+M)}}_updateLinear(e,r){if(e.type!=="linear")throw new Error;let o=e.linear,n=St(o.rotation,r),a=St(o.scale,r),s=St(o.position,r),l=new tt.Euler(n[0]??0,n[1]??0,n[2]??0),c=e.randomnessObject??No.defaultData([1,1,1]).randomnessObject,u=St(c.rotation,r),d=St(c.scale,r),p=St(c.position,r),f=this.getRandom(c),h=sc(c.strength,this.parameters.randomness);for(let[m,y]of this.children.entries()){let g=m*(c.freqScale/10)+c.movement,b=f.noise(g,g,g),w=m+1,P=h(w,Ne(b,u[0])),S=h(w,Ne(b,u[1])),T=h(w,Ne(b,u[2]));y.scale.x=1+(a[0]-1)*m+h(w,Ne(b,d[0]))||br,y.scale.y=1+(a[1]-1)*m+h(w,Ne(b,d[1]))||br,y.scale.z=1+(a[2]-1)*m+h(w,Ne(b,d[2]))||br,y.rotation.x=l.x*m+P,y.rotation.y=l.y*m+S,y.rotation.z=l.z*m+T,y.position.x=s[0]*m+h(w,Ne(b,p[0])),y.position.y=s[1]*m+h(w,Ne(b,p[1])),y.position.z=s[2]*m+h(w,Ne(b,p[2]))}}_updateGrid(e,r){let o=0,n=e.grid,a=e.randomnessObject??No.defaultData([1,1,1]).randomnessObject,s=St(a.scale,r),l=St(a.rotation,r),c=St(a.position,r),u=this.getRandom(a,!0),d=sc(a.strength,this.parameters.randomness),p=St(n.count,r),f=St(n.size,r);if(n.useCenter===!0){let h={x:p[0]%2===0?2:1,y:p[1]%2===0?2:1,z:p[2]%2===0?2:1},m=new tt.Vector3(f[0]*(p[0]-h.x)*.5,f[1]*(p[1]-h.y)*.5,f[2]*(p[2]-h.z)*.5);for(let y=0;y<p[0];y++)for(let g=0;g<p[1];g++)for(let b=0;b<p[2];b++){let w=u.noise((y+1)*(a.freqScale/10)+a.movement,(g+1)*(a.freqScale/10)+a.movement,(b+1)*(a.freqScale/10)+a.movement),P=this.children[o++];if(!P)continue;P.scale.x=1+d(o,Ne(w,s[0]))||br,P.scale.y=1+d(o,Ne(w,s[1]))||br,P.scale.z=1+d(o,Ne(w,s[2]))||br;let S=d(o,Ne(w,l[0])),T=d(o,Ne(w,l[1])),A=d(o,Ne(w,l[2]));P.rotation.set(S,T,A),P.position.x=f[0]*y-m.x+d(o,Ne(w,c[0])),P.position.y=f[1]*g-m.y+d(o,Ne(w,c[1])),P.position.z=f[2]*b-m.z+d(o,Ne(w,c[2]))}}else for(let h=0;h<p[0];h++)for(let m=0;m<p[1];m++)for(let y=0;y<p[2];y++){let g=u.noise((h+1)*(a.freqScale/10)+a.movement,(m+1)*(a.freqScale/10)+a.movement,(y+1)*(a.freqScale/10)+a.movement),b=this.children[o++];if(!b)continue;b.scale.x=1+d(o,Ne(g,s[0]))||br,b.scale.y=1+d(o,Ne(g,s[1]))||br,b.scale.z=1+d(o,Ne(g,s[2]))||br;let w=d(o,Ne(g,l[0])),P=d(o,Ne(g,l[1])),S=d(o,Ne(g,l[2]));b.rotation.set(w,P,S),b.position.x=f[0]*h+d(o,Ne(g,c[0])),b.position.y=-f[1]*m+d(o,Ne(g,c[1])),b.position.z=-f[2]*y+d(o,Ne(g,c[2]))}}_updateToObject(e,r){if(e.type!=="toObject")throw new Error;let{toObject:o}=e,n=St(o.rotation,r),a=St(o.position,r),s=St(o.scale,r),l=new tt.Euler(n[0],n[1],n[2]),c=e.randomnessObject??No.defaultData([1,1,1]).randomnessObject,u=St(c.rotation,r),d=St(c.position,r),p=St(c.scale,r),f=this.getRandom(c),h=sc(c.strength,this.parameters.randomness);if(!o.object){for(let[,w]of this.children.entries())w.position.set(0,0,0),w.scale.setScalar(1),w.rotation.set(0,0,0);this.objectForSample=void 0;return}if(!this.objectForSample)return;if(this.objectForSample instanceof rn)if(!this.objectForSample.font?.isLoaded||this.objectForSample.geometry.attributes.position===void 0){this._pendingMediaLoad=!0;return}else this._pendingMediaLoad=!1;if(this.objectForSample.geometry===void 0&&this.objectForSample.isAncestorOf(this.object.uuid)){console.warn(`Oh no! The object "${this.object.name}" (${this.object.uuid}) seem to be a child/descendant of the object it's being cloned to. Please re-parent it so that they are siblings instead.`);return}let m=this.getSubdivData();if(m.length>0){let w=Math.round(m.length*o.count/100);this._updateCount(r,w)}else{let w=this.objectForSample.geometry.getAttribute("position");if(!w||isNaN(w.count)||w.count===0){console.warn(`Oh no! The object "${this.object.name}" (${this.object.uuid}) cannot be cloned on the surface of "${this.objectForSample.name}" (${this.objectForSample.uuid}) because the latter does not have a valid geometry.`);return}}this.objectForSample.updateMatrixWorld();let y=new Wu(this.objectForSample).build(),g=Sv[o.axis],b=this.children;y.setRandomGenerator((0,Fd.default)(this.object.uuid+o.seed));for(let[w,P]of b.entries()){let S=w*(c.freqScale/10)+c.movement,T=f.noise(S,S,S),A=w+1,x=h(A,Ne(T,u[0])),N=h(A,Ne(T,u[1])),E=h(A,Ne(T,u[2]));o.spreadType==="random"?y.sample(lc,Bh):(m.length&&(lc.fromArray(m[w].pos),Bh.fromArray(m[w].norm)),this.objectForSample instanceof $n&&lc.applyMatrix4(U3.copy(this.objectForSample.matrixWorld).invert())),lc.applyMatrix4(this.object.hiddenMatrix.clone().invert()),P.position.copy(lc),on.fromArray(g);let M=o.align==="normal"?Bh:this.object.getWorldDirection(W3),D=Gd.fromArray(a);Gd.x+=h(A,Ne(T,d[0])),Gd.y+=h(A,Ne(T,d[1])),Gd.z+=h(A,Ne(T,d[2]));let _=Math.acos(M.dot(on)),R=H3.crossVectors(on,M).normalize(),V=k3.makeRotationAxis(R,_),U=M.clone().cross(this.object.up).normalize(),B=U.clone().cross(M).normalize(),q=new tt.Matrix4().makeBasis(U,M,B),j=new tt.Vector3(on.y,on.z,on.x).normalize(),F=j.clone().cross(on).normalize(),H=new tt.Matrix4().makeBasis(j,on,F).invert(),W=new tt.Matrix4().multiplyMatrices(q,H);P.rotation.setFromRotationMatrix(W),D.applyMatrix4(V),P.position.add(D),P.rotation.x=P.rotation.x+l.x+x,P.rotation.y=P.rotation.y+l.y+N,P.rotation.z=P.rotation.z+l.z+E,P.scale.setScalar(1),P.scale.x=P.scale.x+s[0]+h(A,Ne(T,p[0]))||br,P.scale.y=P.scale.y+s[1]+h(A,Ne(T,p[1]))||br,P.scale.z=P.scale.z+s[2]+h(A,Ne(T,p[2]))||br,P.scale.multiply(this.object.scale),P.hiddenMatrix=this.object.hiddenMatrix}}getSubdivData(){if(!this.objectForSample)return[];let e=this.parameters.toObject.spreadType,r=new Map,o=(a,s)=>{let l=Math.round(a[0]*1e4)+"_"+Math.round(a[1]*1e4)+"_"+Math.round(a[2]*1e4),c=r.get(l);c?(c.pos[0]+=a[0],c.pos[1]+=a[1],c.pos[2]+=a[2],c.norm[0]+=s[0],c.norm[1]+=s[1],c.norm[2]+=s[2],c.count+=1):r.set(l,{pos:[...a],norm:[...s],count:1})};if(e==="random")return[];if(this.objectForSample instanceof $n){let a=this.objectForSample,s=wv[e],l=Rv[s],c=Dv[s],u=_v[s],d=l(a.subdivPointerNew);for(let p=0;p<=d-1;p++){let f=c(a.subdivPointerNew,p),h=u(a.subdivPointerNew,p);Ev.fromArray(f).applyMatrix4(a.matrixWorld),Nv.fromArray(h),o(Ev.toArray(),Nv.toArray())}}else(this.objectForSample.geometry.index?Pv(this.objectForSample.geometry):Ov(this.objectForSample.geometry)).forEach((s,l)=>{e==="polygon_center"&&o(s.midpoint,s.norm),e==="vertex"&&(o(s.vertices[0],s.norm),o(s.vertices[1],s.norm),o(s.vertices[2],s.norm)),e==="edge"&&(o(s.faceCenters[0],s.norm),o(s.faceCenters[1],s.norm),o(s.faceCenters[2],s.norm))});let n=Array.from(r.values());for(let a of n)a.pos[0]/=a.count,a.pos[1]/=a.count,a.pos[2]/=a.count,a.norm[0]/=a.count,a.norm[1]/=a.count,a.norm[2]/=a.count;return n}updateState(e,r){if(this.parameters=ri(e),this.parameters.type!=="toObject")(this.parent===null||this.parent!==this.object)&&(this.removeFromParent(),this.object.parent?.add(this),this.matrix=this.object.matrix,this.hiddenMatrix=this.object.hiddenMatrix,this.matrixWorldNeedsUpdate=!0,this.matrixAutoUpdate=!1);else if(this.parent===null||this.parent.uuid!==this.parameters.toObject.object){this.removeFromParent();let o=r.scene.find(this.parameters.toObject.object);o instanceof Xt?this.objectForSample=o:this.objectForSample=void 0,this.matrix=new tt.Matrix4,this.hiddenMatrix=new tt.Matrix4,this.matrixWorldNeedsUpdate=!0,this.matrixAutoUpdate=!1,o&&o.add(this)}this.update(r)}get pendingMediaLoad(){return this._pendingMediaLoad}};var oo=require("three");var xt=require("three");var cr=require("three");var Lv=require("three"),qo=i=>{var t;return t=class extends i{},t.geometryHelper=new Lv.BoxGeometry(30,30,30),t};var fr=require("three"),jd=new fr.Ray,zh=new fr.Sphere,Bv=new fr.Matrix4,$o=(i,t,e,r,o=!1,n=i)=>{let a=t,s=n.matrixWorld;if(a.boundingSphere===null&&a.computeBoundingSphere(),zh.copy(a.boundingSphere),zh.applyMatrix4(s),e.ray.intersectsSphere(zh)===!1||(Bv.copy(s).invert(),jd.copy(e.ray).applyMatrix4(Bv),a.boundingBox!==null&&jd.intersectsBox(a.boundingBox)===!1))return;let l,c,u,d,p=a.index,f=a.attributes.position,h=a.drawRange,m,y;if(o===!1){let b=Math.max(0,h.start),w=Math.min(p.count,h.start+h.count);for(m=b,y=w;m<y;m+=3)if(c=p.getX(m),u=p.getX(m+1),d=p.getX(m+2),l=g(i,e,jd,f,c,u,d),l){l.faceIndex=Math.floor(m/3),r.push(l);return}}else{let w=a.attributes.position,P=new fr.Vector3,S=new fr.Vector3,T=new fr.Vector3,A=new fr.Vector3,x=2,E=1/((n.scale.x+n.scale.y+n.scale.z)/3),M=E*E,D=Math.max(0,h.start),_=Math.min(w.count,h.start+h.count);for(let R=D,V=_-1;R<V;R+=x){if(P.fromBufferAttribute(w,R),S.fromBufferAttribute(w,R+1),jd.distanceSqToSegment(P,S,A,T)>M)continue;A.applyMatrix4(n.matrixWorld);let B=e.ray.origin.distanceTo(A);B<e.near||B>e.far||r.push({distance:B,point:T.clone().applyMatrix4(n.matrixWorld),object:i})}}function g(b,w,P,S,T,A,x){let N=new fr.Vector3,E=new fr.Vector3,M=new fr.Vector3,D=new fr.Vector3,_=new fr.Vector3;if(N.fromBufferAttribute(S,T),E.fromBufferAttribute(S,A),M.fromBufferAttribute(S,x),P.intersectTriangle(N,E,M,!1,D)===null)return null;_.copy(D),_.applyMatrix4(b.matrixWorld);let V=w.ray.origin.distanceTo(_);return V<w.near||V>w.far?null:{faceIndex:1,distance:V,point:_.clone(),object:b}}};var Ud=new cr.Vector3,Qr=new cr.Camera,Gh=class extends cr.LineSegments{constructor(e){let r=new cr.BufferGeometry,o=new cr.LineBasicMaterial({color:16777215,vertexColors:!0,toneMapped:!1}),n=[],a=[],s={},l=new cr.Color(15711266),c=new cr.Color(15711266),u=new cr.Color(2857471);d("n1","n2",l),d("n2","n4",l),d("n4","n3",l),d("n3","n1",l),d("f1","f2",l),d("f2","f4",l),d("f4","f3",l),d("f3","f1",l),d("n1","f1",l),d("n2","f2",l),d("n3","f3",l),d("n4","f4",l),d("p","n1",c),d("p","n2",c),d("p","n3",c),d("p","n4",c),d("u1","u2",u),d("u2","u3",u),d("u3","u1",u);function d(f,h,m){p(f,m),p(h,m)}function p(f,h){n.push(0,0,0),a.push(h.r,h.g,h.b),s[f]===void 0&&(s[f]=[]),s[f].push(n.length/3-1)}r.setAttribute("position",new cr.Float32BufferAttribute(n,3)),r.setAttribute("color",new cr.Float32BufferAttribute(a,3));super(r,o);this.type="CameraHelper",this.camera=e,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=s,this.update()}update(){let e=this.geometry,r=this.pointMap,o=!0;Qr.projectionMatrixInverse.elements=[.5112609807824982,-0,-0,-0,-0,.41421356237309503,-0,-0,-0,-0,-0,-.099999,-0,-0,-1.0000000000000002,.100001];let n=1,a=1,s=o?.8:1e-4;wo("n1",r,e,Qr,-n,-a,s),wo("n2",r,e,Qr,n,-a,s),wo("n3",r,e,Qr,-n,a,s),wo("n4",r,e,Qr,n,a,s);let l=s;wo("f1",r,e,Qr,-n,-a,l),wo("f2",r,e,Qr,n,-a,l),wo("f3",r,e,Qr,-n,a,l),wo("f4",r,e,Qr,n,a,l);let c=l,u=.5;wo("u1",r,e,Qr,n*.7*u,a*1.1,c),wo("u2",r,e,Qr,-n*.7*u,a*1.1,c),wo("u3",r,e,Qr,0,a*(1.1+.9*u),c),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};function wo(i,t,e,r,o,n,a){Ud.set(o,n,a).unproject(r);let s=t[i];if(s!==void 0){let l=e.getAttribute("position");for(let c=0,u=s.length;c<u;c++)l.setXYZ(s[c],Ud.x,Ud.y,Ud.z)}}var kd=class extends qo(Gh){constructor(e){super(e);this.object=e;this.object=e,this.name=`CombinedCameraHelper: ${e.uuid}`}updateMatrixWorld(e){super.updateMatrixWorld(e),this.updateTarget()}updateTarget(){let e=this.object.getTarget();this.updateWorldMatrix(!0,!1),this.worldToLocal(e)}raycast(e,r){$o(this.object,this.geometry,e,r,!0)}};var cc=require("three");var Hd;(t=>t.is=e=>"objectHelper"in e)(Hd||(Hd={}));var Zr=(i,t)=>class extends $a(i){constructor(){super(...arguments);this.objectHelper=new t(this);this.gizmos={}}get geometryHelper(){return t.geometryHelper}raycast(o,n){this.objectHelper.raycast(o,n)}showGizmos(){for(let o in this.gizmos){let n=this.gizmos[o];n instanceof cc.Box3Helper&&(n.visible=!0)}}updateEntityBoxSize(o,n){this.objectHelper.visible&&this.geometryHelper instanceof cc.BoxGeometry?(o.setScalar(0),n.set(this.geometryHelper.parameters.width,this.geometryHelper.parameters.height,this.geometryHelper.parameters.height).multiplyScalar(.5)):super.updateEntityBoxSize(o,n)}hideGizmos(){for(let o in this.gizmos){let n=this.gizmos[o];n instanceof cc.Box3Helper&&(n.visible=!1)}}};var Wd=790,Gs=new xt.Vector3,Fh=new xt.Vector3,jh=new xt.Quaternion,Uh=new xt.Vector3,uc=new xt.Vector3,kh=new xt.Vector3,Si=class extends Zr(xt.Camera,kd){constructor(e="",r={...En.defaultData,name:""}){super();this._cameraType="OrthographicCamera";this.targetOffset=Fi.DefaultTargetOffset;this.isUpVectorFlipped=!1;this.angleOffsetFromUp=0;this.wasMovedByUser=!1;this.wasMovedBySwitchCameraAction=!1;this.super_Entity(e,r),this.previousProjectionMatrix=new xt.Matrix4,this.matrixAutoUpdate=!0,this.width=window.innerWidth,this.height=window.innerHeight;let o=this.width,n=this.height;this.orthoCamera=new xt.OrthographicCamera(o*-.5,o*.5,n*.5,n*-.5,-5e4,1e4),this.perspCamera=new xt.PerspectiveCamera(45,o/n,50,1e4),this.left=this.orthoCamera.left,this.right=this.orthoCamera.right,this.top=this.orthoCamera.top,this.bottom=this.orthoCamera.bottom,this.far=this.orthoCamera.far,this.view=this.orthoCamera.view,this.aspect=this.perspCamera.aspect,this.focus=this.perspCamera.focus,this.filmGauge=this.perspCamera.filmGauge,this.filmOffset=this.perspCamera.filmOffset,this.objectHelper.update()}get isPerspectiveCamera(){return this.cameraType==="PerspectiveCamera"}get isOrthographicCamera(){return!this.isPerspectiveCamera}get cameraType(){return this._cameraType}set fov(e){this.perspCamera.fov=e}get fov(){return this.perspCamera.fov}setNear(e,r){e==="PerspectiveCamera"?this.perspCamera.near=r:this.orthoCamera.near=r}setZoom(e,r){r>=0&&(e==="PerspectiveCamera"?this.perspCamera.zoom=r:this.orthoCamera.zoom=r)}set cameraType(e){e==="PerspectiveCamera"?this.toPerspective():e==="OrthographicCamera"&&this.toOrthographic()}get near(){return this._cameraType==="PerspectiveCamera"?this.perspCamera.near:this.orthoCamera.near}set near(e){this._cameraType==="PerspectiveCamera"?this.perspCamera.near=e:this.orthoCamera.near=e}get zoom(){return this._cameraType==="PerspectiveCamera"?this.perspCamera.zoom:this.orthoCamera.zoom}set zoom(e){e>=0&&(this._cameraType==="PerspectiveCamera"?this.perspCamera.zoom=e:this.orthoCamera.zoom=e)}lookAt(e,r,o){typeof e=="number"&&(e=new xt.Vector3(e,r,o)),super.lookAt(e),this.getWorldPosition(Gs),this.targetOffset=Gs.distanceTo(e)}getTarget(e=new xt.Vector3){return this.getWorldDirection(Fh),this.getWorldPosition(Gs),Fh.multiplyScalar(this.targetOffset),e.copy(Gs).add(Fh),e}getDistanceToTarget(){let e=this.getTarget();return this.getWorldPosition(Gs),Gs.distanceTo(e)}updateUp(){this.getWorldQuaternion(jh),Uh.set(0,0,1).applyQuaternion(jh),uc.copy(xt.Object3D.DEFAULT_UP),this.isUpVectorFlipped&&uc.negate(),uc.applyQuaternion(jh),kh.copy(xt.Object3D.DEFAULT_UP).projectOnPlane(Uh),this.angleOffsetFromUp=kh.angleTo(uc),this.angleOffsetFromUp*=kh.cross(uc).dot(Uh)>=0?1:-1}updateTransformState(e,r){let o=super.updateTransformState(e,r);return e.isUpVectorFlipped!==void 0&&(this.isUpVectorFlipped=e.isUpVectorFlipped),this.updateUp(),o}getViewFrontToObject(e){let r=e.getWorldPosition(new xt.Vector3),n=e.getWorldDirection(new xt.Vector3).multiplyScalar(this.targetOffset);return{position:r.clone().add(n),target:r}}getViewToTarget(e){let o=this.getWorldDirection(new xt.Vector3).multiplyScalar(this.targetOffset);return{position:e.clone().sub(o),target:e}}getViewToObject(e){let r=new xt.Vector3;return e.getWorldPosition(r),this.getViewToTarget(r)}setViewplaneSize(e,r,o=!1){if(this.aspect=e/r,o){let n=e>r?this.aspect:1,a=e>r?1:this.aspect;this.left=-Wd*.5*n,this.right=Wd*.5*n,this.top=Wd*.5*(1/a),this.bottom=-Wd*.5*(1/a)}else this.left=-e*.5,this.right=e*.5,this.top=r*.5,this.bottom=-r*.5;this.updateProjectionMatrix()}copyViewPlaneSize(e){this.aspect=e.aspect,this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.updateProjectionMatrix()}toOrthographic(){this.orthoCamera.left=this.left,this.orthoCamera.right=this.right,this.orthoCamera.top=this.top,this.orthoCamera.bottom=this.bottom,this.orthoCamera.view=this.view,this.orthoCamera.far=this.far,this.orthoCamera.updateProjectionMatrix(),this.projectionMatrix=this.orthoCamera.projectionMatrix,this.projectionMatrixInverse=this.orthoCamera.projectionMatrixInverse,this._cameraType="OrthographicCamera",this.objectHelper&&this.objectHelper.update()}toPerspective(){this.perspCamera.aspect=this.aspect,this.perspCamera.fov=this.fov,this.perspCamera.view=this.view,this.perspCamera.far=this.far,this.perspCamera.updateProjectionMatrix(),this.projectionMatrix=this.perspCamera.projectionMatrix,this.projectionMatrixInverse=this.perspCamera.projectionMatrixInverse,this._cameraType="PerspectiveCamera",this.objectHelper&&this.objectHelper.update()}setFocalLength(e){this.perspCamera.setFocalLength(e),this.toPerspective()}getFocalLength(){return this.perspCamera.getFocalLength()}getEffectiveFOV(){return this.perspCamera.getEffectiveFOV()}getFilmWidth(){return this.perspCamera.getFilmWidth()}getFilmHeight(){return this.perspCamera.getFilmHeight()}setViewOffset(e,r,o,n,a,s){this._cameraType==="PerspectiveCamera"?this.perspCamera.setViewOffset(e,r,o,n,a,s):this.orthoCamera.setViewOffset(e,r,o,n,a,s)}clearViewOffset(){this._cameraType==="PerspectiveCamera"?(this.perspCamera.clearViewOffset(),this.toPerspective()):(this.orthoCamera.clearViewOffset(),this.toOrthographic())}copyHistory(){this.previousProjectionMatrix&&this.previousProjectionMatrix.copy(this.projectionMatrix)}updateProjectionMatrix(){this._cameraType==="PerspectiveCamera"?this.toPerspective():this._cameraType==="OrthographicCamera"&&this.toOrthographic()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,r){super.updateWorldMatrix(e,r),this.matrixWorldInverse.copy(this.matrixWorld).invert()}copy(e,r){return super.copy(e,r),this.parent=e.parent,this.orthoCamera.copy(e.orthoCamera),this.perspCamera.copy(e.perspCamera),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.far=e.far,this.view=e.view===null?null:Object.assign({},e.view),this._cameraType=e._cameraType,this.aspect=e.aspect,this.fov=e.fov,this.focus=e.focus,this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this.targetOffset=e.targetOffset,this.updateProjectionMatrix(),this}toCameraState(e=[]){let r={type:this.cameraType,far:this.far,orthographic:{near:this.orthoCamera.near,zoom:this.orthoCamera.zoom},perspective:{near:this.perspCamera.near,fov:this.perspCamera.fov,zoom:this.perspCamera.zoom},up:this.up.toArray(),targetOffset:this.targetOffset,isUpVectorFlipped:this.isUpVectorFlipped};return Pa(r,e)}updateCameraSubtype(e,r){let o=e==="perspective"?"PerspectiveCamera":"OrthographicCamera";r.zoom!==void 0&&this.setZoom(o,r.zoom),r.near!==void 0&&this.setNear(o,r.near),r.fov!==void 0&&o==="PerspectiveCamera"&&(this.fov=r.fov)}updateState(e,r){this.updateCameraState(e,r)}updateCameraState(e,r){this.updateState_Entity(e,r),e.far!==void 0&&(this.far=e.far),e.orthographic!==void 0&&this.updateCameraSubtype("orthographic",e.orthographic),e.perspective!==void 0&&this.updateCameraSubtype("perspective",e.perspective),e.type!==void 0&&(this.cameraType=e.type),e.up!==void 0&&this.up.fromArray(e.up.map(o=>typeof o=="number"?o:0)),e.targetOffset!==void 0&&(this.targetOffset=e.targetOffset),e.isUpVectorFlipped!==void 0&&(this.isUpVectorFlipped=e.isUpVectorFlipped),this.updateProjectionMatrix()}updateByPatchedOp(e,r,o){super.updateByPatchedOp(e,r,o),e.path.length===1&&e.type===0&&this.updateCameraSubtype(e.path[0],e.props)}toState(e){return{...super.toState(e),...this.toCameraState(e),type:this.cameraType}}};var X3=require("three");var an=require("three");var Fs=new an.Matrix4,$3=new an.Matrix4;var Nr=class extends Er{constructor(e,r,o){super(e,r);this.data=r;this.meshSetAddresses=[];this.needsTransformForDownstream=!1;this.geometry=new an.BufferGeometry;this.onAfterRender=(e,r,o,n,a,s)=>{super.onAfterRender(e,r,o,n,a,s),this.recomputeBoolean()};this.geometry.userData.parameters={width:0,height:0,depth:0}}get booleanOp(){return this.data.geometry.operation}get phongAngle(){return this.data.geometry.phongAngle??45}get isLOD(){return this.recomputeBoolean(),!1}updateByPatchedOp(e,r,o){super.updateByPatchedOp(e,r,o),e.path.length===1&&e.path[0]==="geometry"&&e.type===0&&e.props.operation!==void 0&&(this.freeBooleanPointer(),this.resetBBoxNeedsUpdate())}freeBooleanPointer(){super.freeBooleanPointer(),this.geometry.dispose()}recomputeBoolean(e,r=!0){if(this.booleanMeshSetAddress!==-1&&!e)return;for(let n=0;n<this.children.length;n++){let a=this.children[n];a instanceof Nr&&a.dataPatched.visible===!0&&a.recomputeBoolean(e===!0,r)}this.meshSetAddresses=[];for(let n=0;n<this.children.length;n++){let a=this.children[n];if(a instanceof Xt&&a.dataPatched.visible===!0&&a.geometry.attributes.position?.count>0&&a.geometry.drawRange.count>0&&a.booleanMeshSetAddress!==0){Fs.multiplyMatrices(a.hiddenMatrix,a.matrix).multiply(a.pivotMatrix);try{if(a.booleanMeshSetAddress===-1){if((a.geometry.index??a.geometry.getAttribute("position")).count/3<15e5&&(a.booleanMeshSetAddress=Xr.getMeshSet(a.geometry,e===!0,r)),a.booleanMeshSetAddress===-1)return;Xr.transformMeshSet(a.booleanMeshSetAddress,Fs),a.booleanMatrixInvOld.copy(Fs).invert(),a.booleanWasTransformed=!1}else a instanceof Nr&&a.needsTransformForDownstream===!0?(Xr.transformMeshSet(a.booleanMeshSetAddress,Fs),a.needsTransformForDownstream=!1):a.booleanWasTransformed===!0&&(Xr.transformMeshSet(a.booleanMeshSetAddress,$3.multiplyMatrices(Fs,a.booleanMatrixInvOld)),a.booleanMatrixInvOld.copy(Fs).invert(),a.booleanWasTransformed=!1)}catch(s){console.error(s),a.booleanMeshSetAddress=0,a.geometry.userData.booleanOperationDidFail=!0;continue}Xr.hasOpenEdges(a.booleanMeshSetAddress)===!1||n===this.children.length-1&&this.booleanOp===2?(this.meshSetAddresses.push(a.booleanMeshSetAddress),a.geometry.userData.booleanOperationDidFail=!1):a.geometry.userData.booleanOperationDidFail="openEdges"}}if(this.meshSetAddresses.length===0){this.geometry.setAttribute("position",new an.Float32BufferAttribute([],0)),this.geometry.setDrawRange(0,0);return}if(e===!0)return Xr.calcBooleanTopological(this.meshSetAddresses,this.booleanOp);let o=this.geometry;o.dispose(),this.geometry=new an.BufferGeometry,this.geometry.userData=o.userData,this.geometry.boundingSphere=o.boundingSphere;try{this.booleanMeshSetAddress=Xr.calcBoolean(this.meshSetAddresses,this.booleanOp,this.geometry,this.phongAngle)}catch(n){this.booleanMeshSetAddress=0,this.geometry.userData.booleanOperationDidFail=!0,console.error(n)}this.booleanMatrixInvOld.copy(this.matrix).invert(),this.needsTransformForDownstream=!0,Ls(this),Bs(this)}dispose(){super.dispose(),this.geometry.dispose()}};var zv=require("three");var Vv;(t=>{function i(e){return Ge.is(e)&&e instanceof zv.Light}t.is=i})(Vv||(Vv={}));var js=(i,t)=>class extends Zr(i,t){updateState_Light(r,o){this.updateState_Entity(r,o),r.color!==void 0&&(this.color=o.shared.color(r.color)),r.intensity!==void 0&&(this.intensity=r.intensity),r.depth!==void 0&&(this.shadow.camera.far=r.depth,this.shadow.needsUpdate=!0),r.shadows!==void 0&&(this.castShadow=r.shadows)}};var sn=i=>i instanceof Xt,dc=i=>i!==null&&i instanceof Nr;var pc=i=>Hd.is(i);var jv=require("three");var Xo=require("three");var Y3=new Xo.Vector3(1,1,1),Gv=new Xo.Vector3,K3=new Xo.Vector3,Fv=new Xo.Quaternion,Jr=class extends qo(Xo.AxesHelper){constructor(e,r=15){super(r);this.object=e;this.dummy=new Xo.Group;this.object.updateMatrixWorld(),this.name=`EmptyObjectHelper: ${e.uuid}`,this.matrix=this.dummy.matrixWorld,this.matrixAutoUpdate=!1,this.object.isBone&&(this.visible=!1)}raycast(e,r){$o(this.object,Jr.geometryHelper,e,r,!1,this.dummy)}update(){}updateMatrix(){}updateMatrixWorld(e){this.object.matrixWorld.decompose(Gv,Fv,K3),this.matrix.compose(Gv,Fv,Y3),super.updateMatrixWorld(e)}updateWorldMatrix(e,r){}};var ln=class extends Zr(jv.Group,Jr){constructor(t,e){super(),this.super_Entity(t,e),this.objectHelper.update()}updateState(t,e){this.updateState_Entity(t,e),"buffer"in t&&Object.keys(t).length===1&&e.scene.reloadSplats()}};var Uv=require("three");var Us=class extends Zr(Uv.Group,Jr){constructor(e,r,o){super();this.super_Entity(e,r),this.context=o,this.objectHelper.update()}updateState(e,r){this.updateState_Entity(e,r)}};var Ks=require("three");var ks=require("three"),Q3=i=>`
2290
2290
 
2291
2291
  // PCSS implementation based on:
2292
2292
  // https://www.gamedev.net/articles/programming/graphics/contact-hardening-soft-shadows-made-fast-r4906/
@@ -2660,7 +2660,7 @@ float vogelShadow(int index, sampler2D shadowMap, vec2 uv, float texelSize, floa
2660
2660
  }
2661
2661
 
2662
2662
  #endif
2663
- `,Z3=ks.ShaderChunk.lights_fragment_begin,J3=ks.ShaderChunk.shadowmask_pars_fragment,Uv=null,eE=i=>{switch(i){case"low":return 8;case"medium":return 16;case"high":return 32;default:return 16}},kv=(i="medium")=>{if(Uv===i)return!1;Uv=i;let t=eE(i);ks.ShaderChunk.shadowmap_pars_fragment=Q3(t);let e=Z3.slice();e=e.replace("getShadow( spotShadowMap[ i ]",`getShadow( UNROLLED_LOOP_INDEX + ${3}, spotShadowMap[ i ]`),e=e.replace("getShadow( directionalShadowMap[ i ]","getShadow( UNROLLED_LOOP_INDEX, directionalShadowMap[ i ]"),ks.ShaderChunk.lights_fragment_begin=e;let r=J3.slice();return r=r.replaceAll("getShadow(","getShadow( UNROLLED_LOOP_INDEX, "),ks.ShaderChunk.shadowmask_pars_fragment=r,!0};var hc=require("three");var Hv=require("three");var Hs=class extends Wo(Hv.DirectionalLightHelper){constructor(e,r=15,o=10066329){super(e,r,o);this.object=e;this.added=!1;this.name=`DirectionalLightHelper: ${e.uuid}`}raycast(e,r){qo(this.object,Hs.geometryHelper,e,r)}};var Wv=require("three");var Ws=class extends Wo(Wv.PointLightHelper){constructor(e,r=15,o=6710886){super(e,r,o);this.object=e;this.name=`PointLightHelper: ${e.uuid}`}raycast(e,r){qo(this.object,Ws.geometryHelper,e,r)}};var qd=require("three");var Wd=class extends Wo(qd.SpotLightHelper){constructor(e,r=6710886){super(e,r);this.object=e;this.name=`SpotLightHelper: ${e.uuid}`}raycast(e,r){qo(this.object,Wd.geometryHelper,e,r)}update(){if(this.object!==void 0){let e=Wd._vector,r=this.object.distance?this.object.distance:1e3,o=r*Math.tan(this.object.angle);this.cone.scale.set(o,o,r),e.setFromMatrixPosition(this.object.target.matrixWorld),this.cone.lookAt(e);let n=this.color!==void 0?this.color:this.light.color;if(this.cone.material instanceof Array)for(let a=0,s=this.cone.material.length;a<s;a++)this.cone.material[a].color.set(n);else this.cone.material.color.set(n)}}},fc=Wd;fc._vector=new qd.Vector3;function tE(i,t){i.shadow.camera.right=t/2,i.shadow.camera.left=-t/2,i.shadow.camera.top=t/2,i.shadow.camera.bottom=-t/2,i.shadow.needsUpdate=!0}var qs=class extends js(hc.DirectionalLight,Hs){constructor(t,e,r){super(),this.super_Entity(t,e),this.castShadow=!0,this.shadow.mapSize.width=2048,this.shadow.mapSize.height=2048,this.shadow.normalBias=1,this.layers.enable(3);let n=this.shadow.camera;n.top=1250,n.bottom=-1250,n.right=1250,n.left=-1250,n.near=-1e4,n.far=2500;let a=new hc.CameraHelper(this.shadow.camera);a.visible=!1,this.gizmos.shadowmap=a}update(){this.shadow.camera.updateProjectionMatrix();for(let t in this.gizmos){let e=this.gizmos[t];e instanceof hc.CameraHelper&&e.update()}}updateMatrixWorld(t){super.updateMatrixWorld(t),this.objectHelper&&this.objectHelper.update()}updateState(t,e){this.updateState_Light(t,e);let r=t.depth!==void 0&&t.depth!==this.shadow.camera.far||t.size!==void 0&&t.size/2!==this.shadow.camera.right;t.size!==void 0&&tE(this,t.size),t.shadowRadius!==void 0&&(this.shadow.radius=t.shadowRadius),t.shadowResolution!==void 0&&(this.shadow.mapSize.set(t.shadowResolution,t.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null)),t.penumbraSize!==void 0&&e.scene.markPenumbraSizeDirty(),r&&this.update()}};var x1=require("three");var eo=require("three");var qv=new eo.Vector3,$v=new eo.Vector3,Xv=new eo.Quaternion,$s=class extends js(eo.SpotLight,fc){constructor(t,e,r){super(),this.super_Entity(t,e),this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024,this.shadow.normalBias=1,this.layers.enable(3);let n=this.shadow.camera;n.fov=eo.MathUtils.RAD2DEG*2*this.angle,n.aspect=1,n.near=100,n.far=2500;let a=new eo.CameraHelper(this.shadow.camera);a.visible=!1,this.gizmos.shadowmap=a,this.update()}update(){this.shadow.camera.updateProjectionMatrix();for(let t in this.gizmos){let e=this.gizmos[t];e instanceof eo.CameraHelper&&e.update()}}updateMatrixWorld(t){super.updateMatrixWorld(t),$v.setFromMatrixPosition(this.matrixWorld),Xv.setFromRotationMatrix(this.matrixWorld),qv.copy(this.up).applyQuaternion(Xv).negate().multiplyScalar(this.distance),this.target.position.copy($v).add(qv),this.target.updateMatrixWorld(),this.objectHelper&&this.objectHelper.update()}updateState(t,e){this.updateState_Light(t,e),t.distance!==void 0&&(this.distance=t.distance),t.decay!==void 0&&(this.decay=t.decay),t.angle!==void 0&&(this.angle=t.angle),t.penumbra!==void 0&&(this.penumbra=t.penumbra),t.shadowRadius!==void 0&&(this.shadow.radius=t.shadowRadius),t.penumbraSize!==void 0&&e.scene.markPenumbraSizeDirty(),t.shadowResolution!==void 0&&(this.shadow.mapSize.set(t.shadowResolution,t.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null))}};function rE(i){let t=(i[0][0]+i[1][1])/2,e=(i[0][0]-i[1][1])/2,r=(i[1][0]+i[0][1])/2,o=(i[1][0]-i[0][1])/2,n=Math.sqrt(t*t+o*o),a=Math.sqrt(e*e+r*r),s=n+a,l=n-a,c=Math.atan2(r,e),u=Math.atan2(o,t),d=(u-c)/2,p=(u+c)/2,f=[[Math.cos(p),Math.sin(p)],[-Math.sin(p),Math.cos(p)]],h=[[s,0],[0,l]],m=[[Math.cos(d),Math.sin(d)],[-Math.sin(d),Math.cos(d)]];return f[0][0]*=-1,f[0][1]*=-1,m[0][0]*=-1,m[1][0]*=-1,[f,h,m]}function $d(i,t){return[[i[0][0]*t[0][0]+i[0][1]*t[1][0],i[0][0]*t[0][1]+i[0][1]*t[1][1]],[i[1][0]*t[0][0]+i[1][1]*t[1][0],i[1][0]*t[0][1]+i[1][1]*t[1][1]]]}function Yv(i){return[[i[0][0],i[1][0]],[i[0][1],i[1][1]]]}function Kv(i){let[t,e,r]=rE(i),o=$d(t,Yv(r)),n=$d($d(r,e),Yv(r)),a=Math.atan2(o[1][0],o[0][0]),s=[n[0][0],n[1][1]],l=[n[0][1]/n[1][1],n[1][0]/n[0][0]];return{rotation:a,scale:s,shear:l}}function Qv({rotation:i,scale:t,shear:e}){let r=Math.cos(i),o=Math.sin(i),n=[[r,-o],[o,r]],a=[[t[0],e[0]*t[1]],[e[1]*t[0],t[1]]],s=$d(n,a);return[s[0][0],s[1][0],s[0][1],s[1][1]]}var Be;(S=>{function i(){return[1,0,0,0,1,0,0,0,1]}S.identity=i;function t(T,A=S.identity()){for(let x=0,N=T.length;x<N;x++)A[x]=T[x];return A}S.copy=t;function e(T,A,x,N,E,M){return S.setAbcdef(S.identity(),T,A,x,N,E,M)}S.create=e;function r(T,A,x,N,E,M,D){return T[0]=A,T[1]=N,T[2]=M,T[3]=x,T[4]=E,T[5]=D,T}S.setAbcdef=r;function o(T,A){let[x,N,E,M,D,_]=a(T),[R,V,U,B,q,j]=a(A),F=R*x+V*E,H=R*N+V*M,W=U*x+B*E,ee=U*N+B*M,te=q*x+j*E+D,Y=q*N+j*M+_;return S.create(F,H,W,ee,te,Y)}S.append=o;function n(T,A){let[x,N,E,M,D,_]=a(T),[R,V,U,B,q,j]=a(A),F=x,H=N,W=E,ee=M;(R!==1||V!==0||U!==0||B!==1)&&(F=x*R+N*U,H=x*V+N*B,W=E*R+M*U,ee=E*V+M*B);let te=D*R+_*U+q,Y=D*V+_*B+j;return S.create(F,H,W,ee,te,Y)}S.prepend=n;function a(T){return[T[0],T[3],T[1],T[4],T[2],T[5]]}S.getAbcdef=a;function s(T){let[A,x,N,E,M,D]=S.getAbcdef(T),_=A*E-x*N,R=E/_,V=-x/_,U=-N/_,B=A/_,q=(N*D-E*M)/_,j=-(A*D-x*M)/_;return S.create(R,V,U,B,q,j)}S.invert=s;function l([T,A],x){let[N,E,M,D,_,R]=S.getAbcdef(x);return[N*T+M*A+_,E*T+D*A+R]}S.apply=l;function c(T,A){let[x,N,E,M,D,_]=S.getAbcdef(A),R=1/(x*M+E*-N),[V,U]=T;return[M*R*V+-E*R*U+(_*E-D*M)*R,x*R*U+-N*R*V+(-_*x+D*N)*R]}S.applyInverse=c;function u(T,A,x=A){let[N,E,M,D,_,R]=S.getAbcdef(T);return S.setAbcdef(T,N*A,E*x,M*A,D*x,_*A,R*x),T}S.scale=u;function d(T,A){let x=Math.cos(A),N=Math.sin(A),[E,M,D,_,R,V]=S.getAbcdef(T);return S.setAbcdef(T,E*x-M*N,E*N+M*x,D*x-_*N,D*N+_*x,R*x-V*N,R*N+V*x),T}S.rotate=d;function p(T,A,x){let[N,E]=x,M=S.translate(T,-N,-E);return M=S.rotate(M,A),M=S.translate(M,N,E),M}S.rotateAround=p;function f(T,A,x){let[N,E,M,D,_,R]=S.getAbcdef(T);return S.setAbcdef(T,N,E,M,D,_+A,R+x),T}S.translate=f;function h(T,A,x){let[N,E,M,D]=S.getAbcdef(T);return S.setAbcdef(T,N,E,M,D,A,x),T}S.setTranslate=h;function m(T,A,x){let[N,E,M,D]=S.getAbcdef(T);return S.setAbcdef(T,N,E,M,D,A,x),T}S.setPosition=m;function y(T){let[A,x,N,E]=S.getAbcdef(T),M=Math.sqrt(A*A+x*x),D=Math.sqrt(N*N+E*E);return[M,D]}S.getScale=y;function g(T){let[,,,,A,x]=S.getAbcdef(T);return[A,x]}S.getPosition=g;function b(T,A){return S.decompose(T,A).rotation}S.getRotation=b;function w(T,A){let[x,N,E,M,D,_]=S.getAbcdef(T),{rotation:R,scale:V,shear:U}=Kv([[x,E],[N,M]]);return{position:[D+(A[0]*x+A[1]*E)-A[0],_+(A[0]*N+A[1]*M)-A[1]],scale:V,rotation:R,shear:U,pivot:A}}S.decompose=w;function P(T,A,x,N,E=[0,0]){let[M,D]=T,[_,R]=N,[V,U,B,q]=Qv({rotation:x,scale:A,shear:E}),j=M-(_*V+R*B)+_,F=D-(_*U+R*q)+R;return S.create(V,U,B,q,j,F)}S.compose=P})(Be||(Be={}));var oE=Math.PI/180,Dte=180/Math.PI;function Zv(i,t,e,r,o,n){let a=i-e,s=t-r;return a*a/(o*o)+s*s/(n*n)<=1}function Jv(i){return i*oE}var wi=class{constructor(t,e,r){this.uuid=t;this.data=e;this.localMatrix=Be.identity();this.worldMatrix=Be.identity();this.ignoreCameraZoom=!1;this.visible=!0;this._singleBBox=new cn;this._recursiveBBox=new cn;this.singleBBoxNeedsUpdate=!0;this.recursiveBBoxNeedsUpdate=!0;this.stateSelection=null;this.prevState=null;this.currentState=null;this.reversibleToState=null;this.currentTransitionEvent=null;this.previousAction=null;this.name="";this.position=[0,0];this.scale=[1,1];this.rotation=0;this.shear=[0,0];this.emitter=hi();this.dpr=r.dpr??1,this.dataPatched=e}project(t,e){let r=this.worldMatrix;return e&&(r=Be.append(e.worldMatrix,r)),Be.applyInverse(t,r)}intersects(t,e,r,o=!1){return this.visible&&!this.data.raycastLock&&this.intersectsInLocalSpace(...this.project([t,e],r),o)}intersectsInLocalSpace(t,e,r=!1){let{min:o,max:n}=r?this.recursiveBBox:this.singleBBox;return t>=o[0]&&t<=n[0]&&e>=o[1]&&e<=n[1]}applyTransforms(t){t.setTransform(this.worldMatrix,this.ignoreCameraZoom)}get singleBBox(){return this.singleBBoxNeedsUpdate&&(this.singleBBoxNeedsUpdate=!1,this._singleBBox.setFromObjectSize(this,!1),this._singleBBox.computeVertices(),this._singleBBox.computeEdges()),this._singleBBox}get recursiveBBox(){return this.recursiveBBoxNeedsUpdate&&(this.recursiveBBoxNeedsUpdate=!1,this._recursiveBBox.setFromObjectSize(this,!0),this._recursiveBBox.computeVertices(),this._recursiveBBox.computeEdges()),this._recursiveBBox}updateLocalMatrix(){this.localMatrix=Be.compose(this.position,this.scale,Jv(this.rotation),ui.getPivot(this.dataPatched),this.shear)}updateWorldMatrix(t,e,r){let o=this.parent;e&&o!==null&&o!==void 0&&o.updateWorldMatrix(t,!0,!1),t&&this.updateLocalMatrix(),this.parent?this.worldMatrix=Be.append(this.parent.worldMatrix,this.localMatrix):this.worldMatrix=Be.copy(this.localMatrix),this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0}get pivot(){return ui.getPivot(this.data)}getCenter(){return[0,0]}getHalfSize(){return[0,0]}get id(){return this.uuid}resetBBoxNeedsUpdateSelf(){this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0}resetBBoxNeedsUpdate(){this.resetBBoxNeedsUpdateSelf(),this.traverseAncestors(t=>{t.resetBBoxNeedsUpdateSelf()})}updateTransformState(t){let e=!1;t.position!==void 0&&(e=!0,this.position=t.position),t.rotation!==void 0&&(e=!0,this.rotation=t.rotation),t.scale!==void 0&&(e=!0,this.scale=t.scale),t.shear!==void 0&&(e=!0,this.shear=t.shear),e&&(this.updateWorldMatrix(!0,!1,!0),this.resetBBoxNeedsUpdate())}updateByOp(t,e,r){t.type===0&&t.props.visible!==void 0&&(this.visible=t.props.visible),this.data=e,this.data=e;let o=t,n=Ue(t.path,["states","*"]);if(n!==null){if(t.type===0){let[a]=n;if(this?.stateSelection===a){let s={...t.props};if(delete s.name,Object.values(t.props).some(l=>l===void 0)){let l=this.data;if(l!==void 0){let c=dt.zoom(l,t.path.slice(2));if(c)for(let u in t.props)t.props[u]===void 0&&u in c&&(s[u]=c[u])}}o={...t,props:s,path:t.path.slice(2)}}}}else if(t.type===0){let a=this.stateSelection?this.data.states.data(this.stateSelection):void 0;if(a!==void 0){if(t.props.name!==void 0&&a.name){let{name:l,...c}=a;a=c}let s=dt.removeOverridden(t.path,t.props,a);o={...t,props:s}}}this.updateByPatchedOpBase(o,Dn.patch(this.data,this.stateSelection?this.data.states.data(this.stateSelection):void 0),r)}changeSelectedState(t,e,r=!1){if(!(this.data.states.length===0&&!r)){for(let o of this.data.states)Dn.toOps(this.data,o.data).forEach(a=>{let s=Ma.replaceProps(a,this.data);this.dataPatched=this.data,this.updateByPatchedOp(s,this.data,e)});if(t!==null){let o=this.data.states.data(t);o&&(this.dataPatched=Dn.patch(this.data,o),Dn.toOps(this.data,o).forEach(a=>{this.updateByPatchedOp(a,this.dataPatched,e)}))}r&&this.updateTransformState(this.dataPatched),this.stateSelection=t}}updateState(t,e){t.name!==void 0&&(this.name=t.name),t.visible!==void 0&&(this.visible=t.visible),this.updateTransformState(t)}updateByPatchedOpBase(t,e,r){this.dataPatched=e,this.updateByPatchedOp(t,e,r)}updateByPatchedOp(t,e,r){t.path.length===0&&t.type===0&&this.updateState(t.props,r),this.requestRender()}traverseFrameAncestors(t){this.traverseAncestors(e=>{e.data.type==="frame2d"&&t(e)})}traverseAncestors(t){let e=this.parent;for(;e;)t(e),e=e.parent}requestRender(){this.traverseFrameAncestors(t=>{t.requestRender()})}clone(t){let e=new wi(this.uuid,this.data,t);return e.parent=void 0,e}addEventListener(t,e){this.emitter.on(t,e)}removeEventListener(t,e){this.emitter.off(t,e)}dispatchEvent(t){this.emitter.emit(t.type,{...t,target:t.target??this})}traverseSortNextHelper(){let t=this.parent;if(t){let e=t.children;if(e){let r=e.indexOf(this)+1;return e[r]?e[r]:t.traverseSortNextHelper()}}}sortNext(){let t=this.children;return t&&t.length>0&&t[0]?t[0]:this.traverseSortNextHelper()}isDescendantOf(t){t instanceof wi&&(t=t.uuid);let e=this;for(;e.parent;){if(e.parent.uuid===t)return!0;e=e.parent}return!1}};var ur=class extends wi{constructor(e,r,o){super(e,r,o);this.uuid=e;this.data=r;this.context=o;this.children=[]}add(e){e.parent&&e.parent instanceof ur&&e.parent.remove(e),this.children.push(e),e.parent=this}remove(e){let r=this.children.indexOf(e);r>=0&&(this.children.splice(r,1),e.parent=void 0)}traverse(e){let r=e(this);if(r!==!0)for(let o of this.children)o instanceof ur?o.traverse(e):r=e(o)}intersectsChildrenHelper(e,r,o,n,a){for(let s of this.children)if(s.intersects(e,r,o,!1)&&(a.push(s),n)||s instanceof ur&&s.intersectsChildrenHelper(e,r,o,n,a))return!0;return!1}intersectsChildren(e,r,o,n=!1,a=[],s=!1){return this.intersectsChildrenHelper(e,r,o,n,a),a}intersectsChildrenHelperReverse(e,r,o,n,a){for(let s of this.children)if(s instanceof ur&&s.intersectsChildrenHelperReverse(e,r,o,n,a)||s.intersects(e,r,o,!1)&&(a.push(s),n))return!0;return!1}intersectsChildrenReverse(e,r,o,n=!1,a=[],s=!1){return this.intersectsChildrenHelperReverse(e,r,o,n,a),a}updateWorldMatrix(e,r,o){if(super.updateWorldMatrix(e,r,o),o&&this.children)for(let n of this.children)n.updateWorldMatrix(e,!1,!0)}find(e){let r;return this.traverse(o=>{o.uuid===e&&(r=o)}),r}innerDrawChildren(e){for(let r=this.children.length-1;r>=0;r--)this.children[r].draw(e)}resetBBoxNeedsUpdate(){super.resetBBoxNeedsUpdate(),this.traverse(e=>{e.resetBBoxNeedsUpdateSelf()})}clone(e){let r=new ur(this.uuid,this.data,e);r.parent=void 0;for(let o of this.children)r.add(o.clone(e));return r}},Dr=class extends ur{constructor(e,r,o){super(e,r,o);this.uuid=e;this.data=r;this.updateState(r,o)}draw(e){!this.visible||(e.save(),this.applyTransforms(e),this.innerDrawChildren(e),e.restore())}clone(e){let r=new Dr(this.uuid,this.data,e);r.parent=void 0;for(let o of this.children)r.add(o.clone(e));return r}};function iE(i,t){let[[e,r],[o,n]]=i,[[a,s],[l,c]]=t,u=(e-o)*(s-c)-(r-n)*(a-l);if(u===0)return!1;let d=((e-a)*(s-c)-(r-s)*(a-l))/u,p=-((e-o)*(r-s)-(r-n)*(e-a))/u;return d>=0&&d<=1&&p>=0&&p<=1}var t1=[[-1,1],[-1,-1],[1,-1],[1,1]],e1=(i,t,e)=>{let r=i.getCenter(),o=i.getHalfSize(),n=Be.append(t,i.worldMatrix);o[0]===0&&o[1]===0?e.push(Be.apply(r,n)):t1.forEach(a=>{let s=[a[0]*o[0]+r[0],a[1]*o[1]+r[1]];e.push(Be.apply(s,n))})},cn=class{constructor(){this.matrix=Be.identity();this.min=[1/0,1/0];this.max=[-1/0,-1/0];this.vertices=[];this.edges=[]}setFromObjectSize(t,e=!1){t.updateWorldMatrix(),this.makeEmpty(),Be.copy(t.worldMatrix,this.matrix);let r=Be.invert(t.worldMatrix);this.expandByObjectSize(t,r,e)}expandByObjectSize(t,e,r=!1){let o=[];r===!0&&t instanceof ur?t.traverse(n=>{n.visible&&e1(n,e,o)}):e1(t,e,o),this.setFromPoints(o)}setFromSize(t,e,r){this.makeEmpty(),Be.copy(r,this.matrix),this.expandBySize(t,e,r)}expandBySize(t,e,r){[Be.apply([0,0],r),Be.apply([0,e],r),Be.apply([t,e],r),Be.apply([t,0],r)].forEach(n=>this.expandByPoint(n))}getCenter(){let[t,e]=this.min,[r,o]=this.getHalfSize();return Be.apply([t+r,e+o],this.matrix)}getSize(){return[this.max[0]-this.min[0],this.max[1]-this.min[1]]}getHalfSize(){return[(this.max[0]-this.min[0])*.5,(this.max[1]-this.min[1])*.5]}makeEmpty(){this.min=[1/0,1/0],this.max=[-1/0,-1/0]}setFromPoints(t){this.makeEmpty();for(let e of t)this.expandByPoint(e)}expandByPoint(t){this.min=[Math.min(this.min[0],t[0]),Math.min(this.min[1],t[1])],this.max=[Math.max(this.max[0],t[0]),Math.max(this.max[1],t[1])]}computeVertices(){let[t,e]=this.getHalfSize(),r=this.getCenter(),[o,n,a,s]=Be.getAbcdef(this.matrix),l=Be.create(o,n,a,s,r[0],r[1]);this.vertices=t1.map(([c,u])=>Be.apply([c*t,u*e],l))}computeEdges(){this.edges=[];for(let t=0,e=this.vertices.length;t<e;++t)this.edges.push([this.vertices[t],this.vertices[(t+1)%e]])}project(t,e){let r=this.matrix;return e&&(r=Be.append(e.worldMatrix,r)),Be.applyInverse(t,r)}intersects(t,e,r){return this.intersectsInLocalSpace(...this.project([t,e],r))}intersectsInLocalSpace(t,e){let{min:r,max:o}=this;return t>=r[0]&&t<=o[0]&&e>=r[1]&&e<=o[1]}containsPoint(t){let[e,r]=t,[o,n]=this.min,[a,s]=this.max;return e>=o&&e<=a&&r>=n&&r<=s}intersectsBBox2D(t){for(let e=0,r=this.edges.length;e<r;e++){let o=this.edges[e];for(let n=0,a=t.edges.length;n<a;n++){let s=t.edges[n];if(iE(o,s))return!0}}for(let e=0,r=t.vertices.length;e<r;e++){let o=t.vertices[e];if(this.containsPoint(o))return!0}return!1}ensureMinMax(){let t=this.min,e=this.max;this.min=[Math.min(t[0],e[0]),Math.min(t[1],e[1])],this.max=[Math.max(t[0],e[0]),Math.max(t[1],e[1])]}copy(t){this.min=[...t.min],this.max=[...t.max],Be.copy(t.matrix,this.matrix),this.computeVertices(),this.computeEdges()}clone(){let t=new cn;return t.copy(this),t}};var o1,i1=new Promise(i=>{o1=i}),r1=!1;var Xd;function n1(){if(r1)return;if(Xd)return Xd;async function i(){let e=await import("./ui.js");o1(e.default??e),r1=!0}return Xd=i(),Xd}function l1(i){let t=!1;return i.scene.objects.traverse((e,r)=>{(r.type==="Mesh"&&r.geometry.type==="UIGeometry"||r.type==="Page"&&r.uiFrame!==void 0)&&(t=!0)}),t}var Ie,Hh;async function nE(i){let t=await i1;Ie||(Hh||(Hh=t({locateFile:()=>i})),Ie=await Hh)}var a1=Be.identity(),yc=class{constructor(t,e=1){this.canvas=t;this._dpr=e;this._width=0;this._height=0;this._strokeMode="inside";this._layerBlur=0;this._backgroundBlur=0;this._dropShadowBlur=0;this._dropShadowOffsetX=0;this._dropShadowOffsetY=0;this._dropShadowColor=Le.transparent;this._innerShadowBlur=0;this._innerShadowOffsetX=0;this._innerShadowOffsetY=0;this._innerShadowSpread=0;this._innerShadowColor=Le.transparent;this._fonts=new Map;this._isSizeDirty=!1;try{let r=t.getBoundingClientRect();t.width=r.width*e,t.height=r.height*e}catch{console.log(t.width,e)}this._currentM3Transform=a1,this._currentTransform=new Float32Array(a1)}get dpr(){return this._dpr}set dpr(t){this._dpr=t,this._isSizeDirty=!0}async init(){if(!this.wasmURL)throw Error("Your must set the wasm binary url with renderer.wasmURL = ... before you can call renderer.init");await nE(this.wasmURL),this._surface=Ie.MakeWebGLCanvasSurface(this.canvas),this.ctx=this._surface?.getCanvas(),this._paint=new Ie.Paint,this._paint.setAntiAlias(!0),this._paintFill=this._paint.copy(),this._paintFill.setStyle(Ie.PaintStyle.Fill),this._paintStroke=this._paint.copy(),this._paintStroke.setStyle(Ie.PaintStyle.Stroke),this.ctx?.scale(this.dpr,this.dpr)}get currentTransform(){return this._currentM3Transform}get currentTransformBuffer(){return this._currentTransform}set currentTransform(t){this._currentM3Transform=t,this._currentTransform.set(t)}async loadFont(t,e){let r=await(await fetch(t)).arrayBuffer();this.registerFont(r,e)}registerFont(t,e){if(this._fonts.has(e))return;let r=Ie.FontMgr.FromData(t);if(r)this._fonts.set(e,r);else throw new Error("Invalid font data for "+e)}get width(){return this._width}get height(){return this._height}set strokeColor(t){this._paintStroke&&this._paintStroke.setColor(Yd(t),Ie.ColorSpace.DISPLAY_P3)}set fillColor(t){this._paintFill&&this._paintFill.setColor(Yd(t),Ie.ColorSpace.DISPLAY_P3)}set lineWidth(t){this._paintStroke&&this._paintStroke.setStrokeWidth(this._strokeMode==="center"?t:t*2)}set strokeMode(t){this._strokeMode=t}set dropShadowBlur(t){this._dropShadowBlur=t}set dropShadowColor(t){this._dropShadowColor=t}set dropShadowOffsetX(t){this._dropShadowOffsetX=t}set dropShadowOffsetY(t){this._dropShadowOffsetY=t}set innerShadowBlur(t){this._innerShadowBlur=t}set innerShadowColor(t){this._innerShadowColor=t}set innerShadowOffsetX(t){this._innerShadowOffsetX=t}set innerShadowOffsetY(t){this._innerShadowOffsetY=t}set innerShadowSpread(t){this._innerShadowSpread=t}set layerBlur(t){this._layerBlur=t}set backgroundBlur(t){this._backgroundBlur=t}clear(){this.ctx?.clear(Ie.TRANSPARENT)}save(){this.ctx?.save()}restore(){this.ctx?.restore()}beginPath(){this._currentPath?.delete(),this._currentPath=new Ie.Path}closePath(){let t=this._currentPath;if(t){if(t.isEmpty())return;let e=t.getBounds();(e[3]-e[1]||e[2]-e[0])&&t.close()}}fill(){this._paintInner(this._paintFill,!0)}stroke(){this._paintInner(this._paintStroke,!1)}clipRect(t,e,r,o,n=0,a=0,s=0,l=0){let c=Ie.XYWHRect(t,e,r,o);if(n===0&&a===0&&l===0&&s===0)this.ctx?.clipRect(c,Ie.ClipOp.Intersect,!0);else{let u=Ie.RRectXY(c,n,n);u[4]=u[5]=n,u[6]=u[7]=a,u[8]=u[9]=s,u[10]=u[11]=l,this.ctx?.clipRRect(u,Ie.ClipOp.Intersect,!0)}}_applyShadowOffsetMatrix(){if(this.ctx){let t=Be.invert(this.currentTransform);this.ctx.concat(t);let e=Be.translate(Be.identity(),this._dropShadowOffsetX,this._dropShadowOffsetY);this.ctx.concat(e),this.ctx.concat(this._currentTransform)}}_applyEffectsToPaint(t,e,r=!0){if(this.ctx&&this._currentPath){let o,n=!1;if(r&&this._hasDropShadow()){let a=t.copy();a.setColor(Yd(this._dropShadowColor));let s;this._dropShadowBlur>0&&(s=Ie.MaskFilter.MakeBlur(Ie.BlurStyle.Normal,this._dropShadowBlur*this.dpr*(this.camera?.scale??1),!1),a.setMaskFilter(s)),this.ctx.save(),this.ctx.clipPath(this._currentPath,Ie.ClipOp.Difference,!0),this._applyShadowOffsetMatrix(),e(a),this.ctx.restore(),a.delete(),s?.delete()}if(this._backgroundBlur>0&&r){this.ctx.save(),this.ctx.clipPath(this._currentPath,Ie.ClipOp.Intersect,!0);let a=Ie.ImageFilter.MakeBlur(this._backgroundBlur,this._backgroundBlur,Ie.TileMode.Clamp,null),s=t.copy();s.setImageFilter(a),s.setAlphaf(1);let l=this._currentPath.computeTightBounds();this.ctx.saveLayer(s,l,null,Ie.SaveLayerInitWithPrevious),this.ctx.drawColor(t.getColor()),this.ctx.restore(),this.ctx.restore(),s.delete(),a.delete(),n=!0}if(this._layerBlur>0){let a=t.copy();o=Ie.MaskFilter.MakeBlur(Ie.BlurStyle.Normal,this._layerBlur*this.dpr*(this.camera?.scale??1),!1),a.setMaskFilter(o),e(a),a.delete(),o.delete(),n=!0}if(n||e(t),r&&this._hasInnerShadow()){let a=new Ie.Paint;a.setAntiAlias(!0),a.setStyle(Ie.PaintStyle.Fill),a.setColor(Yd(this._innerShadowColor));let s;this._innerShadowBlur>0&&(s=Ie.MaskFilter.MakeBlur(Ie.BlurStyle.Normal,this._innerShadowBlur*this.dpr*(this.camera?.scale??1),!1),a.setMaskFilter(s));let l=this._currentPath.computeTightBounds(),[c,u,d,p]=l,f=d-c,h=p-u;this.ctx.save(),this.ctx.clipPath(this._currentPath,Ie.ClipOp.Intersect,!0),this.ctx.saveLayer(a,l,null,Ie.SaveLayerInitWithPrevious),this.ctx?.translate(this._innerShadowOffsetX,this._innerShadowOffsetY),this.ctx.drawRect(Ie.XYWHRect(-1e3-this._innerShadowOffsetX,-1e3-this._innerShadowOffsetY,2e3+f+Math.abs(this._innerShadowOffsetX*2),2e3+h+Math.abs(this._innerShadowOffsetY*2)),a),a.setBlendMode(Ie.BlendMode.Clear),this.ctx.drawPath(this._currentPath,a),this.ctx.restore(),this.ctx.restore(),a.delete(),s?.delete()}}}_paintInner(t,e=!0){if(this.ctx&&this._currentPath&&t){let r=this.ctx,o=this._currentPath;this._applyEffectsToPaint(t,n=>{let a=!1;!e&&this._strokeMode!=="center"&&(r.save(),r.clipPath(o,this._strokeMode==="outside"?Ie.ClipOp.Difference:Ie.ClipOp.Intersect,!0),a=!0),r.drawPath(o,n),a&&r.restore()},e)}}_hasDropShadow(){return this._dropShadowColor?.a>0}_hasInnerShadow(){return this._innerShadowColor?.a>0}path(t){this._currentPath?.addPath(Ie.Path.MakeFromSVGString(t))}ellipse(t,e,r,o,n,a,s,l){if(!s1([t,e,r,o])||!this._currentPath)return;if(r<0||o<0)throw Error("radii cannot be negative");let c=Ie.XYWHRect(t-r,e-o,r*2,o*2);this._currentPath?.addOval(c)}rect(t,e,r,o,n=0,a=0,s=0,l=0){let c=Ie.XYWHRect(t,e,r,o);if(!!s1(c))if(n===0&&a===0&&l===0&&s===0)this._currentPath?.addRect(c);else{let u=Ie.RRectXY(c,n,n);u[4]=u[5]=n,u[6]=u[7]=a,u[8]=u[9]=s,u[10]=u[11]=l,this._currentPath?.addRRect(u)}}getHorizontalAlign(t){switch(t){case 2:return Ie.TextAlign.Right;case 3:return Ie.TextAlign.Center;case 4:return Ie.TextAlign.Justify;case 1:default:return Ie.TextAlign.Left}}drawTextInner(t,e,r,[o,n,a,s],l,c,u=!0){let d=0,{ctx:p}=this;if(!p)return d;let f=c.copy(),h=c.copy();return h.setAlphaf(0),this._applyEffectsToPaint(f,m=>{e.pushPaintStyle(r,m,h),e.addText(t);let y=e.build();y.layout(a);let g=n;l===2?g+=(s-y.getHeight())/2:l===3&&(g+=s-y.getHeight()),p.drawParagraph(y,o,g),d=y.getHeight(),e.reset(),y.delete()},u),f.delete(),h.delete(),d}drawText(t,e){let r=0,o=this._fonts.get(e.font),{ctx:n,_paintFill:a,_paintStroke:s}=this;if(o&&n){let l=new Ie.TextStyle({fontFamilies:[e.font],fontSize:e.fontSize,heightMultiplier:e.lineHeight,letterSpacing:e.letterSpacing}),c=new Ie.ParagraphStyle({textStyle:l,textAlign:this.getHorizontalAlign(e.horizontalAlign)}),u=Ie.XYWHRect(e.x,e.y,e.width,e.height),d=Ie.ParagraphBuilder.Make(c,o);a&&(r=this.drawTextInner(t,d,l,u,e.verticalAlign,a,!0)),s&&(r=this.drawTextInner(t,d,l,u,e.verticalAlign,s,!1)),d.delete()}return{height:r}}render(){this._surface?.flush()}moveTo(t,e){this._currentPath?.moveTo(t,e)}lineTo(t,e){this._currentPath?.lineTo(t,e)}bezierCurveTo(t,e,r,o,n,a){this._currentPath?.cubicTo(t,e,r,o,n,a)}quadraticCurveTo(t,e,r,o){this._currentPath?.quadTo(t,e,r,o)}setTransform(t,e=!1){if(!this.ctx)return;let r=this.ctx.getTotalMatrix(),o=Be.invert(r);if(o&&this.ctx.concat(o),this.ctx?.scale(this.dpr,this.dpr),this.camera?.enabled&&(this.ctx?.concat(this.camera.worldMatrix),e)){let n=Be.getScale(this.camera.worldMatrix);this.ctx?.scale(1/n[0],1/n[1])}this.ctx?.concat(t),this.currentTransform=t}transform(t){this.ctx?.concat(t)}setSize(t,e){!this._isSizeDirty&&t===this._width&&e===this._height||(this._isSizeDirty=!1,this._width=t,this._height=e,this.canvas.style.width=t+"px",this.canvas.style.height=e+"px",this.canvas.width=t*this.dpr,this.canvas.height=e*this.dpr,this._surface&&(this._surface=Ie.MakeWebGLCanvasSurface(this.canvas),this.ctx=this._surface?.getCanvas()))}};function s1(i){for(let t=0;t<i.length;t++)if(i[t]!==void 0&&!Number.isFinite(i[t]))return!1;return!0}function Yd({r:i,g:t,b:e,a:r}){return Ie.Color4f(i,t,e,r)}var gc=class{constructor(t,e,r){this.uuid=t;this.data=e;this.enabled=!1;this.color=Le.transparent;this.blurRadius=0;this.offset=[0,0];this.spread=0;this.update(e)}update(t){t.color!==void 0&&(this.color=t.color),t.enabled!==void 0&&(this.enabled=t.enabled),t.blurRadius!==void 0&&(this.blurRadius=t.blurRadius),t.offset!==void 0&&(this.offset=t.offset),t.spread!==void 0&&(this.spread=t.spread)}};var xc=class{constructor(t,e,r){this.uuid=t;this.data=e;this.enabled=!1;this.radius=0;this.update(e)}update(t){t.enabled!==void 0&&(this.enabled=t.enabled),t.radius!==void 0&&(this.radius=t.radius)}};var Kd=class{constructor(t,e,r){this.uuid=t;this.data=e;this.enabled=!1;this.color=Le.transparent;this.update(e)}update(t){t.enabled!==void 0&&(this.enabled=t.enabled),t.color!==void 0&&(this.color=t.color)}};var Qd=class{constructor(t,e,r){this.uuid=t;this.data=e;this.enabled=!1;this.color=Le.transparent;this.thickness=0;this.mode="inside";this.update(e)}update(t){t.enabled!==void 0&&(this.enabled=t.enabled),t.color!==void 0&&(this.color=t.color),t.thickness!==void 0&&(this.thickness=t.thickness),t.mode!==void 0&&(this.mode=t.mode)}};var _r=class extends wi{constructor(e,r,o){super(e,r,o);this.uuid=e;this.data=r;this.autoClose=!0;this.fill=new Kd(e+"-fill",r.fill,o),this.stroke=new Qd(e+"-stroke",r.stroke,o),this.dropShadow=new gc(e+"-dropShadow",r.dropShadow,o),this.innerShadow=new gc(e+"-innerShadow",r.innerShadow,o),this.backgroundBlur=new xc(e+"-backgroundBlur",r.backgroundBlur,o),this.layerBlur=new xc(e+"-layerBlur",r.layerBlur,o)}applyFillStroke(e){e.fillColor=this.fill.enabled?this.fill.color:Le.transparent,e.strokeColor=this.stroke.enabled&&this.stroke.thickness>0?this.stroke.color:Le.transparent,e.strokeMode=this.stroke.mode,e.lineWidth=this.stroke.thickness}applyFilters(e){this.layerBlur.enabled?e.layerBlur=this.layerBlur.radius*5:e.layerBlur=0,this.backgroundBlur.enabled?e.backgroundBlur=this.backgroundBlur.radius*5:e.backgroundBlur=0,this.dropShadow.enabled?(e.dropShadowBlur=this.dropShadow.blurRadius*5,e.dropShadowColor=this.dropShadow.color,e.dropShadowOffsetX=this.dropShadow.offset[0],e.dropShadowOffsetY=this.dropShadow.offset[1]):e.dropShadowColor=Le.transparent,this.innerShadow.enabled?(e.innerShadowSpread=this.innerShadow.spread,e.innerShadowBlur=this.innerShadow.blurRadius*5,e.innerShadowColor=this.innerShadow.color,e.innerShadowOffsetX=this.innerShadow.offset[0],e.innerShadowOffsetY=this.innerShadow.offset[1]):e.innerShadowColor=Le.transparent}innerDraw(e){}draw(e){!this.visible||(e.save(),this.applyTransforms(e),this.applyFilters(e),this.applyFillStroke(e),e.beginPath(),this.innerDraw(e),this.autoClose&&e.closePath(),this.fill.enabled&&e.fill(),this.stroke.enabled&&e.stroke(),e.restore())}updateByPatchedOp(e,r,o){super.updateByPatchedOp(e,r,o),e.type===0&&(Ue(e.path,["fill"])?this.fill.update(e.props):Ue(e.path,["stroke"])?this.stroke.update(e.props):Ue(e.path,["dropShadow"])?this.dropShadow.update(e.props):Ue(e.path,["innerShadow"])?this.innerShadow.update(e.props):Ue(e.path,["layerBlur"])?this.layerBlur.update(e.props):Ue(e.path,["backgroundBlur"])?this.backgroundBlur.update(e.props):this.resetBBoxNeedsUpdate())}updateState(e,r){super.updateState(e,r),e.fill!==void 0&&this.fill.update(e.fill),e.stroke!==void 0&&this.stroke.update(e.stroke),e.dropShadow!==void 0&&this.dropShadow.update(e.dropShadow),e.innerShadow!==void 0&&this.innerShadow.update(e.innerShadow),e.layerBlur!==void 0&&this.layerBlur.update(e.layerBlur),e.backgroundBlur!==void 0&&this.backgroundBlur.update(e.backgroundBlur)}clone(e){let r=new _r(this.uuid,this.data,e);return r.parent=void 0,r}};var un=class extends _r{constructor(e,r,o){super(e,r,o);this.uuid=e;this.data=r;this.width=0;this.height=0;this.updateState(r,o)}innerDraw(e){e.ellipse(this.width*.5,this.height*.5,this.width*.5,this.height*.5,0,0,Math.PI*2)}intersectsInLocalSpace(e,r){return Zv(e,r,this.width*.5,this.height*.5,this.width*.5,this.height*.5)}getCenter(){return[this.width*.5,this.height*.5]}getHalfSize(){return[this.width*.5,this.height*.5]}updateSizeState(e){let r=!1;e.width!==void 0&&(this.width=typeof e.width=="number"?e.width:this.width,r=!0),e.height!==void 0&&(this.height=typeof e.height=="number"?e.height:this.height,r=!0),r&&this.updateWorldMatrix(!0,!1,!0)}updateState(e,r){super.updateState(e,r),this.updateSizeState(e)}clone(e){let r=new un(this.uuid,this.data,e);return r.parent=void 0,r}};var Xo=class extends _r{constructor(e,r,o){super(e,r,o);this.uuid=e;this.data=r;this.width=0;this.height=0;this.cornerRadius=[0,0,0,0];this.updateState(r,o)}innerDraw(e){e.rect(0,0,this.width,this.height,...this.cornerRadius)}getCenter(){return[this.width*.5,this.height*.5]}getHalfSize(){return[this.width*.5,this.height*.5]}updateCornerState(e){e.cornerRadius!==void 0&&(this.cornerRadius=e.cornerRadius)}updateSizeState(e){let r=!1;e.width!==void 0&&(this.width=typeof e.width=="number"?e.width:this.width,r=!0),e.height!==void 0&&(this.height=typeof e.height=="number"?e.height:this.height,r=!0),r&&this.updateWorldMatrix(!0,!1,!0)}updateState(e,r){super.updateState(e,r),this.updateSizeState(e),this.updateCornerState(e)}clone(e){let r=new Xo(this.uuid,this.data,e);return r.parent=void 0,r}};var dn=class extends _r{constructor(e,r,o){super(e,r,o);this.uuid=e;this.data=r;this._textHeight=0;this._textHeightDirty=!0;this.width=0;this.height=0;this.updateState(r,o)}get textHeight(){return this._textHeight}applyFillStroke(e){e.fillColor=this.fill.enabled?this.fill.color:Le.transparent,e.strokeColor=this.stroke.enabled&&this.stroke.thickness>0?this.stroke.color:Le.transparent,e.strokeMode="center",e.lineWidth=this.stroke.thickness}innerDraw(e){this._fontHolder?.arrayBuffer&&this._fontHolder.arrayBuffer.byteLength>1&&this.data.font&&e.registerFont(this._fontHolder.arrayBuffer,this.data.font);let r=this.data.textTransform,o=this.data.text.textValue.toString(),n=r===2?o.toUpperCase():r===3?o.toLowerCase():o,{height:a}=e.drawText(n,{x:0,y:0,width:this.width,height:this.height,fontSize:this.data.fontSize,lineHeight:this.data.lineHeight??1,letterSpacing:this.data.letterSpacing??0,horizontalAlign:this.data.horizontalAlign,verticalAlign:this.data.verticalAlign,font:this.data.font});this._textHeight=a}getCenter(){return[this.width*.5,this.height*.5]}getHalfSize(){return[this.width*.5,this.height*.5]}updateSizeState(e){let r=!1;e.width!==void 0&&(this.width=typeof e.width=="number"?e.width:this.width,r=!0),e.height!==void 0&&(this.height=typeof e.height=="number"?e.height:this.height,r=!0),r&&this.updateWorldMatrix(!0,!1,!0)}updateFontState(e,{shared:r}){e.font!==void 0&&(this._fontHolder=r.getFont(e.font),this._fontHolder&&!this._fontHolder.isLoaded&&this._fontHolder.loadingPromise.then(()=>{this.requestRender()}))}updateState(e,r){super.updateState(e,r),this.updateSizeState(e),this.updateFontState(e,r)}clone(e){let r=new dn(this.uuid,this.data,e);return r.parent=void 0,r}};var Xs=class extends _r{constructor(e,r,o){super(e,r,o);this.uuid=e;this.data=r;this.curves=[];this.extremasBBox={min:[0,0],max:[0,0]};this.updateState(r,o)}computeExtremas(){this.curves.length===0&&this.computeCurves();let e=this.curves.map(n=>Zd.extremas(n)),r=[1/0,1/0],o=[-1/0,-1/0];for(let n=0,a=e.length;n<a;n++){let s=e[n];s[0][0]<r[0]&&(r[0]=s[0][0]),s[0][1]<r[1]&&(r[1]=s[0][1]),s[1][0]>o[0]&&(o[0]=s[1][0]),s[1][1]>o[1]&&(o[1]=s[1][1])}return this.extremasBBox.min=[r[0],r[1]],this.extremasBBox.max=[o[0],o[1]],this.extremasBBox}computeCurves(){this.curves=[];for(let o=1,n=this.data.points.length;o<n;o++){let a=this.data.points[o].data,s=this.data.points[o-1].data,l={start:s.position,cp1:s.controlNext.position,cp2:a.controlPrevious.position,end:a.position};this.curves.push(l)}let e=this.data.points[0].data,r=this.data.points[this.data.points.length-1].data;if(this.data.isClosed){let o={start:r.position,cp1:r.controlNext.position,cp2:e.controlPrevious.position,end:e.position};this.curves.push(o)}}getCenter(){let[e,r]=this.extremasBBox.min,[o,n]=this.getHalfSize();return[e+o,r+n]}getHalfSize(){let{min:e,max:r}=this.extremasBBox;return[(r[0]-e[0])*.5,(r[1]-e[1])*.5]}innerDraw(e){for(let n=0,a=this.data.points.length;n<a;n++){let s=this.data.points[n].data;if(n===0){let[l,c]=s.position;e.moveTo(l,c)}else{let l=this.data.points[n-1].data,[c,u]=l.controlNext.position,[d,p]=s.controlPrevious.position,[f,h]=s.position,m={start:l.position,cp1:l.controlNext.position,cp2:s.controlPrevious.position,end:s.position};Zd.derive(m),e.bezierCurveTo(c,u,d,p,f,h)}}let r=this.data.points[0].data,o=this.data.points[this.data.points.length-1].data;if(this.data.isClosed){let[n,a]=o.controlNext.position,[s,l]=r.controlPrevious.position,[c,u]=r.position;e.bezierCurveTo(n,a,s,l,c,u)}}updateState(e,r){super.updateState(e,r),this.computeExtremas()}clone(e){let r=new Xs(this.uuid,this.data,e);return r.parent=void 0,r}},Zd;(n=>{function i(a){let s=a.start,l=a.cp1,c=a.cp2,u=a.end,d=[3*(l[0]-s[0]),3*(l[1]-s[1])],p=[3*(c[0]-l[0]),3*(c[1]-l[1])],f=[3*(u[0]-c[0]),3*(u[1]-c[1])],h={start:d,cp:p,end:f};return a.derivative=h,h.derivative=Wh.derive(h),h}n.derive=i;function t(a,s,l,c=!1){let u=a-2*s+l;if(u!==0){let d=-Math.sqrt(Math.abs(s*s-a*l)),p=-a+s,f=-(d+p)/u,h=-(-d+p)/u;return[f,h]}else if(s!==l&&u===0)return[(2*s-l)/(2*(s-l))];return[]}function e(a){let s=a.derivative??n.derive(a),l=s.start,c=s.cp,u=s.end;return[t(l[0],c[0],u[0]),t(l[1],c[1],u[1])]}n.droot=e;function r(a){let[s,l]=n.droot(a),c=[a.start[0],a.end[0]],u=[a.start[1],a.end[1]];for(let d of s)c.push(n.compute(a,Math.min(1,Math.max(0,d)))[0]);for(let d of l)u.push(n.compute(a,Math.min(1,Math.max(0,d)))[1]);return c.sort((d,p)=>d-p),u.sort((d,p)=>d-p),[[c[0],u[0]],[c[c.length-1],u[u.length-1]]]}n.extremas=r;function o(a,s){if(s===0)return[...a.start];if(s===1)return[...a.end];let l=1-s,c=l*l,u=s*s,d=c*l,p=c*s*3,f=l*u*3,h=s*u;return[d*a.start[0]+p*a.cp1[0]+f*a.cp2[0]+h*a.end[0],d*a.start[1]+p*a.cp1[1]+f*a.cp2[1]+h*a.end[1]]}n.compute=o})(Zd||(Zd={}));var Wh;(r=>{function i(o){let n=o.start,a=o.cp,s=o.end,l=[2*(a[0]-n[0]),2*(a[1]-n[1])],c=[2*(s[0]-a[0]),2*(s[1]-a[1])],u={start:l,end:c};return u.derivative=qh.derive(u),o.derivative=u,u}r.derive=i;function t(o){let n=o.derivative??r.derive(o),a=n.start,s=n.end;return[a[0]!==s[0]?a[0]/(a[0]-s[0]):0,a[1]!==s[1]?a[1]/(a[1]-s[1]):0]}r.droot=t;function e(o,n){if(n===0)return[...o.start];if(n===1)return[...o.end];let a=1-n,s=a*a,l=n*n,c=s,u=a*n*2,d=l;return[c*o.start[0]+u*o.cp[0]+d*o.end[0],c*o.start[1]+u*o.cp[1]+d*o.end[1]]}r.compute=e})(Wh||(Wh={}));var qh;(e=>{function i(r){let o=r.start,n=r.end,a=[n[0]-o[0],n[1]-o[1]];return r.derivative=a,r.derivative}e.derive=i;function t(r,o){if(o===0)return[...r.start];if(o===1)return[...r.end];let n=r.start,a=r.end;return[n[0]+(a[0]-n[0])*o,n[1]+(a[1]-n[1])*o]}e.compute=t})(qh||(qh={}));var Fr=class extends ur{constructor(e,r,o){super(e,r,o);this.uuid=e;this.width=0;this.height=0;this.clipped=!0;this.background=new Xo(e+"-background",ka.defaultData,o),this.background.parent=this,this.updateState(r,o)}get fill(){return this.background.fill}get stroke(){return this.background.stroke}get backgroundBlur(){return this.background.backgroundBlur}get layerBlur(){return this.background.layerBlur}get dropShadow(){return this.background.dropShadow}get innerShadow(){return this.background.innerShadow}get cornerRadius(){return this.background.cornerRadius}set cornerRadius(e){this.background.cornerRadius=e}updateLocalMatrix(){super.updateLocalMatrix(),this.background?.updateLocalMatrix()}updateWorldMatrix(e,r,o){super.updateWorldMatrix(e,r,o),this.background?.updateWorldMatrix(e,r,o)}draw(e){if(!this.visible)return;e.save();let r=this.width,o=this.height;this.applyTransforms(e),this.background.width=r,this.background.height=o,this.background.draw(e),this.clipped&&e.clipRect(0,0,r,o,...this.cornerRadius),this.innerDrawChildren(e),e.restore()}getCenter(){return[this.width*.5,this.height*.5]}getHalfSize(){return[this.width*.5,this.height*.5]}updateCornerState(e){e.cornerRadius!==void 0&&(this.cornerRadius=e.cornerRadius)}updateSizeState(e){let r=!1;e.width!==void 0&&(this.width=typeof e.width=="number"?e.width:this.width,r=!0),e.height!==void 0&&(this.height=typeof e.height=="number"?e.height:this.height,r=!0),r&&this.updateWorldMatrix(!0,!1,!0)}updateState(e,r){super.updateState(e,r),this.updateSizeState(e),this.updateCornerState(e),e.fill!==void 0&&this.fill.update(e.fill),e.stroke!==void 0&&this.stroke.update(e.stroke),e.dropShadow!==void 0&&this.dropShadow.update(e.dropShadow),e.innerShadow!==void 0&&this.innerShadow.update(e.innerShadow),e.layerBlur!==void 0&&this.layerBlur.update(e.layerBlur),e.backgroundBlur!==void 0&&this.backgroundBlur.update(e.backgroundBlur),e.clipped!==void 0&&(this.clipped=e.clipped)}requestRender(){super.requestRender(),this.dispatchEvent({type:"render"})}dispose(){this.removeEventListener("render")}updateByPatchedOp(e,r,o){super.updateByPatchedOp(e,r,o),e.type===0&&(Ue(e.path,["fill"])?this.fill.update(e.props):Ue(e.path,["stroke"])?this.stroke.update(e.props):Ue(e.path,["dropShadow"])?this.dropShadow.update(e.props):Ue(e.path,["innerShadow"])?this.innerShadow.update(e.props):Ue(e.path,["layerBlur"])?this.layerBlur.update(e.props):Ue(e.path,["backgroundBlur"])?this.backgroundBlur.update(e.props):this.resetBBoxNeedsUpdate())}clone(e){let r=new Fr(this.uuid,this.data,e);r.parent=void 0;for(let o of this.children)r.add(o.clone(e));return r}};var p1=ll($h(),1),Pi=class extends _r{constructor(e,r,o){super(e,r,o);this.uuid=e;this.data=r;this._pathBBox=new DOMRect;this.path="";this.updateState(r,o),this.autoClose=!1,this.computeSVGBBox()}computeSVGBBox(){let e=this.path;f1(this.path)&&(console.warn("Invalid SVG path",this.uuid),e="");let r=document.createElementNS("http://www.w3.org/2000/svg","svg"),o=document.createElementNS("http://www.w3.org/2000/svg","path");document.body.appendChild(r),o.setAttribute("d",e),r.appendChild(o),this._pathBBox=o.getBBox(),r.remove()}innerDraw(e){e.path(this.path)}intersectsInLocalSpace(e,r){return e>=this._pathBBox.x&&e<=this._pathBBox.x+this._pathBBox.width&&r>=this._pathBBox.y&&r<=this._pathBBox.y+this._pathBBox.height}getCenter(){return[(this._pathBBox.x+this._pathBBox.width)/2,(this._pathBBox.y+this._pathBBox.height)/2]}getHalfSize(){return[(this._pathBBox.x+this._pathBBox.width)/2,(this._pathBBox.y+this._pathBBox.height)/2]}updateState(e,r){super.updateState(e,r),e.path!==void 0&&(this.path=e.path,this.computeSVGBBox())}clone(e){let r=new Pi(this.uuid,this.data,e);return r.parent=void 0,r}};function f1(i){return/NaN/.test(i)}function h1(i,t=1,e=1){if(t<=0||e<=0)return i;if(f1(i))return console.warn("Cannot scale invalid path",i),ep([]);try{let o=(0,p1.parseSVG)(i).map(n=>{let a={...n};return"x"in a&&(a.x=a.x*t),"y"in a&&(a.y=a.y*e),"x1"in a&&(a.x1=a.x1*t),"x2"in a&&(a.x2=a.x2*t),"y1"in a&&(a.y1=a.y1*e),"y2"in a&&(a.y2=a.y2*e),"rx"in a&&(a.rx=a.rx*t),"ry"in a&&(a.ry=a.ry*e),a});return ep(o)}catch(r){return console.warn("Error parsing SVG path",r),ep([])}}function ep(i){let t=["rx","ry","xAxisRotation","largeArc","sweep","x1","y1","x2","y2","x","y"],e;return i.map(r=>{let o=[];t.forEach(a=>{if(a in r){let s=r[a]*1;o.length&&s>=0&&o.push(","),o.push(s)}});let n=(e===r.code?o[0]<0?"":",":r.code)+o.join("");return e=r.code,n}).join("")}function m1(i,t,e){switch(t.type){case"ellipse2d":return new un(i,t,e);case"rectangle2d":return new Xo(i,t,e);case"text2d":return new dn(i,t,e);case"vector2d":return new Xs(i,t,e);case"path2d":return new Pi(i,t,e);case"frame2d":return new Fr(i,t,e);case"group2d":default:return new Dr(i,t,e)}}var Xh=class{constructor(t,e,r){this.uuid=t;this.data=e;this.group=new Dr(Xh.GROUP_ID,{...Ol.defaultData},r),this.createChildrenObjects(e.objects,this.group,r)}createObject(t,e,r,o,n,a){let s=m1(t,e,a);s&&(o.add(s),o.children.splice(n,0,o.children.pop()),s.updateWorldMatrix(),r.length>0&&(s instanceof Dr||s instanceof Fr)&&this.createChildrenObjects(r,s,a))}createChildrenObjects(t,e,r){let o=0;for(let n of t)this.createObject(n.id,n.data,n.children,e,o,r),o+=1}draw(t){this.group.draw(t)}updateEntityByOp(t,e,r,o){let n=this.find(t);if(n)try{n.updateByOp(e,r,{shared:o})}catch(a){console.error(a)}}updateTreeByOp(t,e){if(t.path.length===0&&t.type===7){let r=t.parent===null?this.group:this.find(t.parent);r!==void 0&&r instanceof ur&&(this.createObject(t.id,t.data,t.children,r,t.localIndex,e),r.requestRender())}else if(t.path.length===0&&t.type===8){let r=this.find(t.id);if(r!==void 0&&r.parent!==void 0&&r.parent instanceof ur){let o=r.parent;r.resetBBoxNeedsUpdate(),o?.remove(r),o?.requestRender()}}else if(t.path.length===0&&t.type===9){let r=this.find(t.id);if(r!==void 0){let o=r.parent,n=t.parent===null?this:this.find(t.parent);if(n===void 0&&!1&&console.error("unexpected",n,t),n instanceof ur||n===this){n.add(r);let a=t.localIndex;n.children.splice(a,0,n.children.pop()),r.updateWorldMatrix(!0,!1,!0),o?.requestRender(),r.requestRender()}r.resetBBoxNeedsUpdate()}}}add(t){this.group.add(t)}remove(t){this.group.remove(t)}traverse(t){this.group.traverse(e=>{e!==this.group&&t(e)})}intersectsChildren(t,e,r,o=!1,n=[]){return this.group.intersectsChildren(t,e,r,o,n,!0)}intersectsChildrenReverse(t,e,r,o=!1,n=[]){return this.group.intersectsChildrenReverse(t,e,r,o,n,!0)}find(t){return this.group.find(t)}get children(){return this.group.children}project(t,e){return this.group.project(t,e)}getWithSortKey(t){let e=this.find(t);if(e===void 0)return;let r=[],o=e;for(;o!==this.group;){let n=o;o=o.parent;let a=o.children.indexOf(n);r.splice(0,0,a)}return{entity:e,sortKey:r}}getAllSorted(t){let e=[];for(let r of t){let o=this.getWithSortKey(r.id);o!==void 0&&e.push(o)}return e.sort((r,o)=>Ec(r.sortKey,o.sortKey)),e.map(r=>r.entity)}},Kn=Xh;Kn.GROUP_ID="scene2d";function Yh({constraints:i,newParentWidth:t,newParentHeight:e,initialParentWidth:r,initialParentHeight:o,objectInitialWidth:n,objectInitialHeight:a,objectInitialPosition:s}){let{horizontalConstraint:l,verticalConstraint:c}=i,u=t-r,d=e-o,p=n,f=a,h=s[0],m=s[1];if(l!==0){if(l===1)h+=u;else if(l===3)h+=u/2;else if(l===2)p=Math.max(1,p+u);else if(l===4){let y=t/r;p*=y,h*=y}}if(c!==0){if(c===1)m+=d;else if(c===3)m+=d/2;else if(c===2)f=Math.max(1,f+d);else if(c===4){let y=e/o;f*=y,m*=y}}return{width:p,height:f,position:[h,m]}}var cE=ll($h(),1);var sie={mm:{mm:1,cm:.1,in:1/25.4,pt:72/25.4,pc:6/25.4,px:-1},cm:{mm:10,cm:1,in:1/2.54,pt:72/2.54,pc:6/2.54,px:-1},in:{mm:25.4,cm:2.54,in:1,pt:72,pc:6,px:-1},pt:{mm:25.4/72,cm:2.54/72,in:1/72,pt:1,pc:6/72,px:-1},pc:{mm:25.4/6,cm:2.54/6,in:1/6,pt:72/6,pc:1,px:-1},px:{mm:1,px:1,cm:1,in:1,pt:1,pc:1}};var Gt=require("three");var uE=`
2663
+ `,Z3=ks.ShaderChunk.lights_fragment_begin,J3=ks.ShaderChunk.shadowmask_pars_fragment,kv=null,eE=i=>{switch(i){case"low":return 8;case"medium":return 16;case"high":return 32;default:return 16}},Hv=(i="medium")=>{if(kv===i)return!1;kv=i;let t=eE(i);ks.ShaderChunk.shadowmap_pars_fragment=Q3(t);let e=Z3.slice();e=e.replace("getShadow( spotShadowMap[ i ]",`getShadow( UNROLLED_LOOP_INDEX + ${3}, spotShadowMap[ i ]`),e=e.replace("getShadow( directionalShadowMap[ i ]","getShadow( UNROLLED_LOOP_INDEX, directionalShadowMap[ i ]"),ks.ShaderChunk.lights_fragment_begin=e;let r=J3.slice();return r=r.replaceAll("getShadow(","getShadow( UNROLLED_LOOP_INDEX, "),ks.ShaderChunk.shadowmask_pars_fragment=r,!0};var hc=require("three");var Wv=require("three");var Hs=class extends qo(Wv.DirectionalLightHelper){constructor(e,r=15,o=10066329){super(e,r,o);this.object=e;this.added=!1;this.name=`DirectionalLightHelper: ${e.uuid}`}raycast(e,r){$o(this.object,Hs.geometryHelper,e,r)}};var qv=require("three");var Ws=class extends qo(qv.PointLightHelper){constructor(e,r=15,o=6710886){super(e,r,o);this.object=e;this.name=`PointLightHelper: ${e.uuid}`}raycast(e,r){$o(this.object,Ws.geometryHelper,e,r)}};var $d=require("three");var qd=class extends qo($d.SpotLightHelper){constructor(e,r=6710886){super(e,r);this.object=e;this.name=`SpotLightHelper: ${e.uuid}`}raycast(e,r){$o(this.object,qd.geometryHelper,e,r)}update(){if(this.object!==void 0){let e=qd._vector,r=this.object.distance?this.object.distance:1e3,o=r*Math.tan(this.object.angle);this.cone.scale.set(o,o,r),e.setFromMatrixPosition(this.object.target.matrixWorld),this.cone.lookAt(e);let n=this.color!==void 0?this.color:this.light.color;if(this.cone.material instanceof Array)for(let a=0,s=this.cone.material.length;a<s;a++)this.cone.material[a].color.set(n);else this.cone.material.color.set(n)}}},fc=qd;fc._vector=new $d.Vector3;function tE(i,t){i.shadow.camera.right=t/2,i.shadow.camera.left=-t/2,i.shadow.camera.top=t/2,i.shadow.camera.bottom=-t/2,i.shadow.needsUpdate=!0}var qs=class extends js(hc.DirectionalLight,Hs){constructor(t,e,r){super(),this.super_Entity(t,e),this.castShadow=!0,this.shadow.mapSize.width=2048,this.shadow.mapSize.height=2048,this.shadow.normalBias=1,this.layers.enable(3);let n=this.shadow.camera;n.top=1250,n.bottom=-1250,n.right=1250,n.left=-1250,n.near=-1e4,n.far=2500;let a=new hc.CameraHelper(this.shadow.camera);a.visible=!1,this.gizmos.shadowmap=a}update(){this.shadow.camera.updateProjectionMatrix();for(let t in this.gizmos){let e=this.gizmos[t];e instanceof hc.CameraHelper&&e.update()}}updateMatrixWorld(t){super.updateMatrixWorld(t),this.objectHelper&&this.objectHelper.update()}updateState(t,e){this.updateState_Light(t,e);let r=t.depth!==void 0&&t.depth!==this.shadow.camera.far||t.size!==void 0&&t.size/2!==this.shadow.camera.right;t.size!==void 0&&tE(this,t.size),t.shadowRadius!==void 0&&(this.shadow.radius=t.shadowRadius),t.shadowResolution!==void 0&&(this.shadow.mapSize.set(t.shadowResolution,t.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null)),t.penumbraSize!==void 0&&e.scene.markPenumbraSizeDirty(),r&&this.update()}};var b1=require("three");var eo=require("three");var $v=new eo.Vector3,Xv=new eo.Vector3,Yv=new eo.Quaternion,$s=class extends js(eo.SpotLight,fc){constructor(t,e,r){super(),this.super_Entity(t,e),this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024,this.shadow.normalBias=1,this.layers.enable(3);let n=this.shadow.camera;n.fov=eo.MathUtils.RAD2DEG*2*this.angle,n.aspect=1,n.near=100,n.far=2500;let a=new eo.CameraHelper(this.shadow.camera);a.visible=!1,this.gizmos.shadowmap=a,this.update()}update(){this.shadow.camera.updateProjectionMatrix();for(let t in this.gizmos){let e=this.gizmos[t];e instanceof eo.CameraHelper&&e.update()}}updateMatrixWorld(t){super.updateMatrixWorld(t),Xv.setFromMatrixPosition(this.matrixWorld),Yv.setFromRotationMatrix(this.matrixWorld),$v.copy(this.up).applyQuaternion(Yv).negate().multiplyScalar(this.distance),this.target.position.copy(Xv).add($v),this.target.updateMatrixWorld(),this.objectHelper&&this.objectHelper.update()}updateState(t,e){this.updateState_Light(t,e),t.distance!==void 0&&(this.distance=t.distance),t.decay!==void 0&&(this.decay=t.decay),t.angle!==void 0&&(this.angle=t.angle),t.penumbra!==void 0&&(this.penumbra=t.penumbra),t.shadowRadius!==void 0&&(this.shadow.radius=t.shadowRadius),t.penumbraSize!==void 0&&e.scene.markPenumbraSizeDirty(),t.shadowResolution!==void 0&&(this.shadow.mapSize.set(t.shadowResolution,t.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null))}};function rE(i){let t=(i[0][0]+i[1][1])/2,e=(i[0][0]-i[1][1])/2,r=(i[1][0]+i[0][1])/2,o=(i[1][0]-i[0][1])/2,n=Math.sqrt(t*t+o*o),a=Math.sqrt(e*e+r*r),s=n+a,l=n-a,c=Math.atan2(r,e),u=Math.atan2(o,t),d=(u-c)/2,p=(u+c)/2,f=[[Math.cos(p),Math.sin(p)],[-Math.sin(p),Math.cos(p)]],h=[[s,0],[0,l]],m=[[Math.cos(d),Math.sin(d)],[-Math.sin(d),Math.cos(d)]];return f[0][0]*=-1,f[0][1]*=-1,m[0][0]*=-1,m[1][0]*=-1,[f,h,m]}function Xd(i,t){return[[i[0][0]*t[0][0]+i[0][1]*t[1][0],i[0][0]*t[0][1]+i[0][1]*t[1][1]],[i[1][0]*t[0][0]+i[1][1]*t[1][0],i[1][0]*t[0][1]+i[1][1]*t[1][1]]]}function Kv(i){return[[i[0][0],i[1][0]],[i[0][1],i[1][1]]]}function Qv(i){let[t,e,r]=rE(i),o=Xd(t,Kv(r)),n=Xd(Xd(r,e),Kv(r)),a=Math.atan2(o[1][0],o[0][0]),s=[n[0][0],n[1][1]],l=[n[0][1]/n[1][1],n[1][0]/n[0][0]];return{rotation:a,scale:s,shear:l}}function Zv({rotation:i,scale:t,shear:e}){let r=Math.cos(i),o=Math.sin(i),n=[[r,-o],[o,r]],a=[[t[0],e[0]*t[1]],[e[1]*t[0],t[1]]],s=Xd(n,a);return[s[0][0],s[1][0],s[0][1],s[1][1]]}var Be;(S=>{function i(){return[1,0,0,0,1,0,0,0,1]}S.identity=i;function t(T,A=S.identity()){for(let x=0,N=T.length;x<N;x++)A[x]=T[x];return A}S.copy=t;function e(T,A,x,N,E,M){return S.setAbcdef(S.identity(),T,A,x,N,E,M)}S.create=e;function r(T,A,x,N,E,M,D){return T[0]=A,T[1]=N,T[2]=M,T[3]=x,T[4]=E,T[5]=D,T}S.setAbcdef=r;function o(T,A){let[x,N,E,M,D,_]=a(T),[R,V,U,B,q,j]=a(A),F=R*x+V*E,H=R*N+V*M,W=U*x+B*E,ee=U*N+B*M,te=q*x+j*E+D,Y=q*N+j*M+_;return S.create(F,H,W,ee,te,Y)}S.append=o;function n(T,A){let[x,N,E,M,D,_]=a(T),[R,V,U,B,q,j]=a(A),F=x,H=N,W=E,ee=M;(R!==1||V!==0||U!==0||B!==1)&&(F=x*R+N*U,H=x*V+N*B,W=E*R+M*U,ee=E*V+M*B);let te=D*R+_*U+q,Y=D*V+_*B+j;return S.create(F,H,W,ee,te,Y)}S.prepend=n;function a(T){return[T[0],T[3],T[1],T[4],T[2],T[5]]}S.getAbcdef=a;function s(T){let[A,x,N,E,M,D]=S.getAbcdef(T),_=A*E-x*N,R=E/_,V=-x/_,U=-N/_,B=A/_,q=(N*D-E*M)/_,j=-(A*D-x*M)/_;return S.create(R,V,U,B,q,j)}S.invert=s;function l([T,A],x){let[N,E,M,D,_,R]=S.getAbcdef(x);return[N*T+M*A+_,E*T+D*A+R]}S.apply=l;function c(T,A){let[x,N,E,M,D,_]=S.getAbcdef(A),R=1/(x*M+E*-N),[V,U]=T;return[M*R*V+-E*R*U+(_*E-D*M)*R,x*R*U+-N*R*V+(-_*x+D*N)*R]}S.applyInverse=c;function u(T,A,x=A){let[N,E,M,D,_,R]=S.getAbcdef(T);return S.setAbcdef(T,N*A,E*x,M*A,D*x,_*A,R*x),T}S.scale=u;function d(T,A){let x=Math.cos(A),N=Math.sin(A),[E,M,D,_,R,V]=S.getAbcdef(T);return S.setAbcdef(T,E*x-M*N,E*N+M*x,D*x-_*N,D*N+_*x,R*x-V*N,R*N+V*x),T}S.rotate=d;function p(T,A,x){let[N,E]=x,M=S.translate(T,-N,-E);return M=S.rotate(M,A),M=S.translate(M,N,E),M}S.rotateAround=p;function f(T,A,x){let[N,E,M,D,_,R]=S.getAbcdef(T);return S.setAbcdef(T,N,E,M,D,_+A,R+x),T}S.translate=f;function h(T,A,x){let[N,E,M,D]=S.getAbcdef(T);return S.setAbcdef(T,N,E,M,D,A,x),T}S.setTranslate=h;function m(T,A,x){let[N,E,M,D]=S.getAbcdef(T);return S.setAbcdef(T,N,E,M,D,A,x),T}S.setPosition=m;function y(T){let[A,x,N,E]=S.getAbcdef(T),M=Math.sqrt(A*A+x*x),D=Math.sqrt(N*N+E*E);return[M,D]}S.getScale=y;function g(T){let[,,,,A,x]=S.getAbcdef(T);return[A,x]}S.getPosition=g;function b(T,A){return S.decompose(T,A).rotation}S.getRotation=b;function w(T,A){let[x,N,E,M,D,_]=S.getAbcdef(T),{rotation:R,scale:V,shear:U}=Qv([[x,E],[N,M]]);return{position:[D+(A[0]*x+A[1]*E)-A[0],_+(A[0]*N+A[1]*M)-A[1]],scale:V,rotation:R,shear:U,pivot:A}}S.decompose=w;function P(T,A,x,N,E=[0,0]){let[M,D]=T,[_,R]=N,[V,U,B,q]=Zv({rotation:x,scale:A,shear:E}),j=M-(_*V+R*B)+_,F=D-(_*U+R*q)+R;return S.create(V,U,B,q,j,F)}S.compose=P})(Be||(Be={}));var oE=Math.PI/180,Dte=180/Math.PI;function Jv(i,t,e,r,o,n){let a=i-e,s=t-r;return a*a/(o*o)+s*s/(n*n)<=1}function e1(i){return i*oE}var wi=class{constructor(t,e,r){this.uuid=t;this.data=e;this.localMatrix=Be.identity();this.worldMatrix=Be.identity();this.ignoreCameraZoom=!1;this.visible=!0;this._singleBBox=new cn;this._recursiveBBox=new cn;this.singleBBoxNeedsUpdate=!0;this.recursiveBBoxNeedsUpdate=!0;this.stateSelection=null;this.prevState=null;this.currentState=null;this.reversibleToState=null;this.currentTransitionEvent=null;this.previousAction=null;this.name="";this.position=[0,0];this.scale=[1,1];this.rotation=0;this.shear=[0,0];this.emitter=hi();this.dpr=r.dpr??1,this.dataPatched=e}project(t,e){let r=this.worldMatrix;return e&&(r=Be.append(e.worldMatrix,r)),Be.applyInverse(t,r)}intersects(t,e,r,o=!1){return this.visible&&!this.data.raycastLock&&this.intersectsInLocalSpace(...this.project([t,e],r),o)}intersectsInLocalSpace(t,e,r=!1){let{min:o,max:n}=r?this.recursiveBBox:this.singleBBox;return t>=o[0]&&t<=n[0]&&e>=o[1]&&e<=n[1]}applyTransforms(t){t.setTransform(this.worldMatrix,this.ignoreCameraZoom)}get singleBBox(){return this.singleBBoxNeedsUpdate&&(this.singleBBoxNeedsUpdate=!1,this._singleBBox.setFromObjectSize(this,!1),this._singleBBox.computeVertices(),this._singleBBox.computeEdges()),this._singleBBox}get recursiveBBox(){return this.recursiveBBoxNeedsUpdate&&(this.recursiveBBoxNeedsUpdate=!1,this._recursiveBBox.setFromObjectSize(this,!0),this._recursiveBBox.computeVertices(),this._recursiveBBox.computeEdges()),this._recursiveBBox}updateLocalMatrix(){this.localMatrix=Be.compose(this.position,this.scale,e1(this.rotation),ui.getPivot(this.dataPatched),this.shear)}updateWorldMatrix(t,e,r){let o=this.parent;e&&o!==null&&o!==void 0&&o.updateWorldMatrix(t,!0,!1),t&&this.updateLocalMatrix(),this.parent?this.worldMatrix=Be.append(this.parent.worldMatrix,this.localMatrix):this.worldMatrix=Be.copy(this.localMatrix),this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0}get pivot(){return ui.getPivot(this.data)}getCenter(){return[0,0]}getHalfSize(){return[0,0]}get id(){return this.uuid}resetBBoxNeedsUpdateSelf(){this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0}resetBBoxNeedsUpdate(){this.resetBBoxNeedsUpdateSelf(),this.traverseAncestors(t=>{t.resetBBoxNeedsUpdateSelf()})}updateTransformState(t){let e=!1;t.position!==void 0&&(e=!0,this.position=t.position),t.rotation!==void 0&&(e=!0,this.rotation=t.rotation),t.scale!==void 0&&(e=!0,this.scale=t.scale),t.shear!==void 0&&(e=!0,this.shear=t.shear),e&&(this.updateWorldMatrix(!0,!1,!0),this.resetBBoxNeedsUpdate())}updateByOp(t,e,r){t.type===0&&t.props.visible!==void 0&&(this.visible=t.props.visible),this.data=e,this.data=e;let o=t,n=Ue(t.path,["states","*"]);if(n!==null){if(t.type===0){let[a]=n;if(this?.stateSelection===a){let s={...t.props};if(delete s.name,Object.values(t.props).some(l=>l===void 0)){let l=this.data;if(l!==void 0){let c=dt.zoom(l,t.path.slice(2));if(c)for(let u in t.props)t.props[u]===void 0&&u in c&&(s[u]=c[u])}}o={...t,props:s,path:t.path.slice(2)}}}}else if(t.type===0){let a=this.stateSelection?this.data.states.data(this.stateSelection):void 0;if(a!==void 0){if(t.props.name!==void 0&&a.name){let{name:l,...c}=a;a=c}let s=dt.removeOverridden(t.path,t.props,a);o={...t,props:s}}}this.updateByPatchedOpBase(o,Dn.patch(this.data,this.stateSelection?this.data.states.data(this.stateSelection):void 0),r)}changeSelectedState(t,e,r=!1){if(!(this.data.states.length===0&&!r)){for(let o of this.data.states)Dn.toOps(this.data,o.data).forEach(a=>{let s=Ma.replaceProps(a,this.data);this.dataPatched=this.data,this.updateByPatchedOp(s,this.data,e)});if(t!==null){let o=this.data.states.data(t);o&&(this.dataPatched=Dn.patch(this.data,o),Dn.toOps(this.data,o).forEach(a=>{this.updateByPatchedOp(a,this.dataPatched,e)}))}r&&this.updateTransformState(this.dataPatched),this.stateSelection=t}}updateState(t,e){t.name!==void 0&&(this.name=t.name),t.visible!==void 0&&(this.visible=t.visible),this.updateTransformState(t)}updateByPatchedOpBase(t,e,r){this.dataPatched=e,this.updateByPatchedOp(t,e,r)}updateByPatchedOp(t,e,r){t.path.length===0&&t.type===0&&this.updateState(t.props,r),this.requestRender()}traverseFrameAncestors(t){this.traverseAncestors(e=>{e.data.type==="frame2d"&&t(e)})}traverseAncestors(t){let e=this.parent;for(;e;)t(e),e=e.parent}requestRender(){this.traverseFrameAncestors(t=>{t.requestRender()})}clone(t){let e=new wi(this.uuid,this.data,t);return e.parent=void 0,e}addEventListener(t,e){this.emitter.on(t,e)}removeEventListener(t,e){this.emitter.off(t,e)}dispatchEvent(t){this.emitter.emit(t.type,{...t,target:t.target??this})}traverseSortNextHelper(){let t=this.parent;if(t){let e=t.children;if(e){let r=e.indexOf(this)+1;return e[r]?e[r]:t.traverseSortNextHelper()}}}sortNext(){let t=this.children;return t&&t.length>0&&t[0]?t[0]:this.traverseSortNextHelper()}isDescendantOf(t){t instanceof wi&&(t=t.uuid);let e=this;for(;e.parent;){if(e.parent.uuid===t)return!0;e=e.parent}return!1}};var ur=class extends wi{constructor(e,r,o){super(e,r,o);this.uuid=e;this.data=r;this.context=o;this.children=[]}add(e){e.parent&&e.parent instanceof ur&&e.parent.remove(e),this.children.push(e),e.parent=this}remove(e){let r=this.children.indexOf(e);r>=0&&(this.children.splice(r,1),e.parent=void 0)}traverse(e){let r=e(this);if(r!==!0)for(let o of this.children)o instanceof ur?o.traverse(e):r=e(o)}intersectsChildrenHelper(e,r,o,n,a){for(let s of this.children)if(s.intersects(e,r,o,!1)&&(a.push(s),n)||s instanceof ur&&s.intersectsChildrenHelper(e,r,o,n,a))return!0;return!1}intersectsChildren(e,r,o,n=!1,a=[],s=!1){return this.intersectsChildrenHelper(e,r,o,n,a),a}intersectsChildrenHelperReverse(e,r,o,n,a){for(let s of this.children)if(s instanceof ur&&s.intersectsChildrenHelperReverse(e,r,o,n,a)||s.intersects(e,r,o,!1)&&(a.push(s),n))return!0;return!1}intersectsChildrenReverse(e,r,o,n=!1,a=[],s=!1){return this.intersectsChildrenHelperReverse(e,r,o,n,a),a}updateWorldMatrix(e,r,o){if(super.updateWorldMatrix(e,r,o),o&&this.children)for(let n of this.children)n.updateWorldMatrix(e,!1,!0)}find(e){let r;return this.traverse(o=>{o.uuid===e&&(r=o)}),r}innerDrawChildren(e){for(let r=this.children.length-1;r>=0;r--)this.children[r].draw(e)}resetBBoxNeedsUpdate(){super.resetBBoxNeedsUpdate(),this.traverse(e=>{e.resetBBoxNeedsUpdateSelf()})}clone(e){let r=new ur(this.uuid,this.data,e);r.parent=void 0;for(let o of this.children)r.add(o.clone(e));return r}},Dr=class extends ur{constructor(e,r,o){super(e,r,o);this.uuid=e;this.data=r;this.updateState(r,o)}draw(e){!this.visible||(e.save(),this.applyTransforms(e),this.innerDrawChildren(e),e.restore())}clone(e){let r=new Dr(this.uuid,this.data,e);r.parent=void 0;for(let o of this.children)r.add(o.clone(e));return r}};function iE(i,t){let[[e,r],[o,n]]=i,[[a,s],[l,c]]=t,u=(e-o)*(s-c)-(r-n)*(a-l);if(u===0)return!1;let d=((e-a)*(s-c)-(r-s)*(a-l))/u,p=-((e-o)*(r-s)-(r-n)*(e-a))/u;return d>=0&&d<=1&&p>=0&&p<=1}var r1=[[-1,1],[-1,-1],[1,-1],[1,1]],t1=(i,t,e)=>{let r=i.getCenter(),o=i.getHalfSize(),n=Be.append(t,i.worldMatrix);o[0]===0&&o[1]===0?e.push(Be.apply(r,n)):r1.forEach(a=>{let s=[a[0]*o[0]+r[0],a[1]*o[1]+r[1]];e.push(Be.apply(s,n))})},cn=class{constructor(){this.matrix=Be.identity();this.min=[1/0,1/0];this.max=[-1/0,-1/0];this.vertices=[];this.edges=[]}setFromObjectSize(t,e=!1){t.updateWorldMatrix(),this.makeEmpty(),Be.copy(t.worldMatrix,this.matrix);let r=Be.invert(t.worldMatrix);this.expandByObjectSize(t,r,e)}expandByObjectSize(t,e,r=!1){let o=[];r===!0&&t instanceof ur?t.traverse(n=>{n.visible&&t1(n,e,o)}):t1(t,e,o),this.setFromPoints(o)}setFromSize(t,e,r){this.makeEmpty(),Be.copy(r,this.matrix),this.expandBySize(t,e,r)}expandBySize(t,e,r){[Be.apply([0,0],r),Be.apply([0,e],r),Be.apply([t,e],r),Be.apply([t,0],r)].forEach(n=>this.expandByPoint(n))}getCenter(){let[t,e]=this.min,[r,o]=this.getHalfSize();return Be.apply([t+r,e+o],this.matrix)}getSize(){return[this.max[0]-this.min[0],this.max[1]-this.min[1]]}getHalfSize(){return[(this.max[0]-this.min[0])*.5,(this.max[1]-this.min[1])*.5]}makeEmpty(){this.min=[1/0,1/0],this.max=[-1/0,-1/0]}setFromPoints(t){this.makeEmpty();for(let e of t)this.expandByPoint(e)}expandByPoint(t){this.min=[Math.min(this.min[0],t[0]),Math.min(this.min[1],t[1])],this.max=[Math.max(this.max[0],t[0]),Math.max(this.max[1],t[1])]}computeVertices(){let[t,e]=this.getHalfSize(),r=this.getCenter(),[o,n,a,s]=Be.getAbcdef(this.matrix),l=Be.create(o,n,a,s,r[0],r[1]);this.vertices=r1.map(([c,u])=>Be.apply([c*t,u*e],l))}computeEdges(){this.edges=[];for(let t=0,e=this.vertices.length;t<e;++t)this.edges.push([this.vertices[t],this.vertices[(t+1)%e]])}project(t,e){let r=this.matrix;return e&&(r=Be.append(e.worldMatrix,r)),Be.applyInverse(t,r)}intersects(t,e,r){return this.intersectsInLocalSpace(...this.project([t,e],r))}intersectsInLocalSpace(t,e){let{min:r,max:o}=this;return t>=r[0]&&t<=o[0]&&e>=r[1]&&e<=o[1]}containsPoint(t){let[e,r]=t,[o,n]=this.min,[a,s]=this.max;return e>=o&&e<=a&&r>=n&&r<=s}intersectsBBox2D(t){for(let e=0,r=this.edges.length;e<r;e++){let o=this.edges[e];for(let n=0,a=t.edges.length;n<a;n++){let s=t.edges[n];if(iE(o,s))return!0}}for(let e=0,r=t.vertices.length;e<r;e++){let o=t.vertices[e];if(this.containsPoint(o))return!0}return!1}ensureMinMax(){let t=this.min,e=this.max;this.min=[Math.min(t[0],e[0]),Math.min(t[1],e[1])],this.max=[Math.max(t[0],e[0]),Math.max(t[1],e[1])]}copy(t){this.min=[...t.min],this.max=[...t.max],Be.copy(t.matrix,this.matrix),this.computeVertices(),this.computeEdges()}clone(){let t=new cn;return t.copy(this),t}};var i1,n1=new Promise(i=>{i1=i}),o1=!1;var Yd;function a1(){if(o1)return;if(Yd)return Yd;async function i(){let e=await import("./ui.js");i1(e.default??e),o1=!0}return Yd=i(),Yd}function c1(i){let t=!1;return i.scene.objects.traverse((e,r)=>{(r.type==="Mesh"&&r.geometry.type==="UIGeometry"||r.type==="Page"&&r.uiFrame!==void 0)&&(t=!0)}),t}var Ie,Wh;async function nE(i){let t=await n1;Ie||(Wh||(Wh=t({locateFile:()=>i})),Ie=await Wh)}var s1=Be.identity(),yc=class{constructor(t,e=1){this.canvas=t;this._dpr=e;this._width=0;this._height=0;this._strokeMode="inside";this._layerBlur=0;this._backgroundBlur=0;this._dropShadowBlur=0;this._dropShadowOffsetX=0;this._dropShadowOffsetY=0;this._dropShadowColor=Le.transparent;this._innerShadowBlur=0;this._innerShadowOffsetX=0;this._innerShadowOffsetY=0;this._innerShadowSpread=0;this._innerShadowColor=Le.transparent;this._fonts=new Map;this._isSizeDirty=!1;try{let r=t.getBoundingClientRect();t.width=r.width*e,t.height=r.height*e}catch{console.log(t.width,e)}this._currentM3Transform=s1,this._currentTransform=new Float32Array(s1)}get dpr(){return this._dpr}set dpr(t){this._dpr=t,this._isSizeDirty=!0}async init(){if(!this.wasmURL)throw Error("Your must set the wasm binary url with renderer.wasmURL = ... before you can call renderer.init");await nE(this.wasmURL),this._surface=Ie.MakeWebGLCanvasSurface(this.canvas),this.ctx=this._surface?.getCanvas(),this._paint=new Ie.Paint,this._paint.setAntiAlias(!0),this._paintFill=this._paint.copy(),this._paintFill.setStyle(Ie.PaintStyle.Fill),this._paintStroke=this._paint.copy(),this._paintStroke.setStyle(Ie.PaintStyle.Stroke),this.ctx?.scale(this.dpr,this.dpr)}get currentTransform(){return this._currentM3Transform}get currentTransformBuffer(){return this._currentTransform}set currentTransform(t){this._currentM3Transform=t,this._currentTransform.set(t)}async loadFont(t,e){let r=await(await fetch(t)).arrayBuffer();this.registerFont(r,e)}registerFont(t,e){if(this._fonts.has(e))return;let r=Ie.FontMgr.FromData(t);if(r)this._fonts.set(e,r);else throw new Error("Invalid font data for "+e)}get width(){return this._width}get height(){return this._height}set strokeColor(t){this._paintStroke&&this._paintStroke.setColor(Kd(t),Ie.ColorSpace.DISPLAY_P3)}set fillColor(t){this._paintFill&&this._paintFill.setColor(Kd(t),Ie.ColorSpace.DISPLAY_P3)}set lineWidth(t){this._paintStroke&&this._paintStroke.setStrokeWidth(this._strokeMode==="center"?t:t*2)}set strokeMode(t){this._strokeMode=t}set dropShadowBlur(t){this._dropShadowBlur=t}set dropShadowColor(t){this._dropShadowColor=t}set dropShadowOffsetX(t){this._dropShadowOffsetX=t}set dropShadowOffsetY(t){this._dropShadowOffsetY=t}set innerShadowBlur(t){this._innerShadowBlur=t}set innerShadowColor(t){this._innerShadowColor=t}set innerShadowOffsetX(t){this._innerShadowOffsetX=t}set innerShadowOffsetY(t){this._innerShadowOffsetY=t}set innerShadowSpread(t){this._innerShadowSpread=t}set layerBlur(t){this._layerBlur=t}set backgroundBlur(t){this._backgroundBlur=t}clear(){this.ctx?.clear(Ie.TRANSPARENT)}save(){this.ctx?.save()}restore(){this.ctx?.restore()}beginPath(){this._currentPath?.delete(),this._currentPath=new Ie.Path}closePath(){let t=this._currentPath;if(t){if(t.isEmpty())return;let e=t.getBounds();(e[3]-e[1]||e[2]-e[0])&&t.close()}}fill(){this._paintInner(this._paintFill,!0)}stroke(){this._paintInner(this._paintStroke,!1)}clipRect(t,e,r,o,n=0,a=0,s=0,l=0){let c=Ie.XYWHRect(t,e,r,o);if(n===0&&a===0&&l===0&&s===0)this.ctx?.clipRect(c,Ie.ClipOp.Intersect,!0);else{let u=Ie.RRectXY(c,n,n);u[4]=u[5]=n,u[6]=u[7]=a,u[8]=u[9]=s,u[10]=u[11]=l,this.ctx?.clipRRect(u,Ie.ClipOp.Intersect,!0)}}_applyShadowOffsetMatrix(){if(this.ctx){let t=Be.invert(this.currentTransform);this.ctx.concat(t);let e=Be.translate(Be.identity(),this._dropShadowOffsetX,this._dropShadowOffsetY);this.ctx.concat(e),this.ctx.concat(this._currentTransform)}}_applyEffectsToPaint(t,e,r=!0){if(this.ctx&&this._currentPath){let o,n=!1;if(r&&this._hasDropShadow()){let a=t.copy();a.setColor(Kd(this._dropShadowColor));let s;this._dropShadowBlur>0&&(s=Ie.MaskFilter.MakeBlur(Ie.BlurStyle.Normal,this._dropShadowBlur*this.dpr*(this.camera?.scale??1),!1),a.setMaskFilter(s)),this.ctx.save(),this.ctx.clipPath(this._currentPath,Ie.ClipOp.Difference,!0),this._applyShadowOffsetMatrix(),e(a),this.ctx.restore(),a.delete(),s?.delete()}if(this._backgroundBlur>0&&r){this.ctx.save(),this.ctx.clipPath(this._currentPath,Ie.ClipOp.Intersect,!0);let a=Ie.ImageFilter.MakeBlur(this._backgroundBlur,this._backgroundBlur,Ie.TileMode.Clamp,null),s=t.copy();s.setImageFilter(a),s.setAlphaf(1);let l=this._currentPath.computeTightBounds();this.ctx.saveLayer(s,l,null,Ie.SaveLayerInitWithPrevious),this.ctx.drawColor(t.getColor()),this.ctx.restore(),this.ctx.restore(),s.delete(),a.delete(),n=!0}if(this._layerBlur>0){let a=t.copy();o=Ie.MaskFilter.MakeBlur(Ie.BlurStyle.Normal,this._layerBlur*this.dpr*(this.camera?.scale??1),!1),a.setMaskFilter(o),e(a),a.delete(),o.delete(),n=!0}if(n||e(t),r&&this._hasInnerShadow()){let a=new Ie.Paint;a.setAntiAlias(!0),a.setStyle(Ie.PaintStyle.Fill),a.setColor(Kd(this._innerShadowColor));let s;this._innerShadowBlur>0&&(s=Ie.MaskFilter.MakeBlur(Ie.BlurStyle.Normal,this._innerShadowBlur*this.dpr*(this.camera?.scale??1),!1),a.setMaskFilter(s));let l=this._currentPath.computeTightBounds(),[c,u,d,p]=l,f=d-c,h=p-u;this.ctx.save(),this.ctx.clipPath(this._currentPath,Ie.ClipOp.Intersect,!0),this.ctx.saveLayer(a,l,null,Ie.SaveLayerInitWithPrevious),this.ctx?.translate(this._innerShadowOffsetX,this._innerShadowOffsetY),this.ctx.drawRect(Ie.XYWHRect(-1e3-this._innerShadowOffsetX,-1e3-this._innerShadowOffsetY,2e3+f+Math.abs(this._innerShadowOffsetX*2),2e3+h+Math.abs(this._innerShadowOffsetY*2)),a),a.setBlendMode(Ie.BlendMode.Clear),this.ctx.drawPath(this._currentPath,a),this.ctx.restore(),this.ctx.restore(),a.delete(),s?.delete()}}}_paintInner(t,e=!0){if(this.ctx&&this._currentPath&&t){let r=this.ctx,o=this._currentPath;this._applyEffectsToPaint(t,n=>{let a=!1;!e&&this._strokeMode!=="center"&&(r.save(),r.clipPath(o,this._strokeMode==="outside"?Ie.ClipOp.Difference:Ie.ClipOp.Intersect,!0),a=!0),r.drawPath(o,n),a&&r.restore()},e)}}_hasDropShadow(){return this._dropShadowColor?.a>0}_hasInnerShadow(){return this._innerShadowColor?.a>0}path(t){this._currentPath?.addPath(Ie.Path.MakeFromSVGString(t))}ellipse(t,e,r,o,n,a,s,l){if(!l1([t,e,r,o])||!this._currentPath)return;if(r<0||o<0)throw Error("radii cannot be negative");let c=Ie.XYWHRect(t-r,e-o,r*2,o*2);this._currentPath?.addOval(c)}rect(t,e,r,o,n=0,a=0,s=0,l=0){let c=Ie.XYWHRect(t,e,r,o);if(!!l1(c))if(n===0&&a===0&&l===0&&s===0)this._currentPath?.addRect(c);else{let u=Ie.RRectXY(c,n,n);u[4]=u[5]=n,u[6]=u[7]=a,u[8]=u[9]=s,u[10]=u[11]=l,this._currentPath?.addRRect(u)}}getHorizontalAlign(t){switch(t){case 2:return Ie.TextAlign.Right;case 3:return Ie.TextAlign.Center;case 4:return Ie.TextAlign.Justify;case 1:default:return Ie.TextAlign.Left}}drawTextInner(t,e,r,[o,n,a,s],l,c,u=!0){let d=0,{ctx:p}=this;if(!p)return d;let f=c.copy(),h=c.copy();return h.setAlphaf(0),this._applyEffectsToPaint(f,m=>{e.pushPaintStyle(r,m,h),e.addText(t);let y=e.build();y.layout(a);let g=n;l===2?g+=(s-y.getHeight())/2:l===3&&(g+=s-y.getHeight()),p.drawParagraph(y,o,g),d=y.getHeight(),e.reset(),y.delete()},u),f.delete(),h.delete(),d}drawText(t,e){let r=0,o=this._fonts.get(e.font),{ctx:n,_paintFill:a,_paintStroke:s}=this;if(o&&n){let l=new Ie.TextStyle({fontFamilies:[e.font],fontSize:e.fontSize,heightMultiplier:e.lineHeight,letterSpacing:e.letterSpacing}),c=new Ie.ParagraphStyle({textStyle:l,textAlign:this.getHorizontalAlign(e.horizontalAlign)}),u=Ie.XYWHRect(e.x,e.y,e.width,e.height),d=Ie.ParagraphBuilder.Make(c,o);a&&(r=this.drawTextInner(t,d,l,u,e.verticalAlign,a,!0)),s&&(r=this.drawTextInner(t,d,l,u,e.verticalAlign,s,!1)),d.delete()}return{height:r}}render(){this._surface?.flush()}moveTo(t,e){this._currentPath?.moveTo(t,e)}lineTo(t,e){this._currentPath?.lineTo(t,e)}bezierCurveTo(t,e,r,o,n,a){this._currentPath?.cubicTo(t,e,r,o,n,a)}quadraticCurveTo(t,e,r,o){this._currentPath?.quadTo(t,e,r,o)}setTransform(t,e=!1){if(!this.ctx)return;let r=this.ctx.getTotalMatrix(),o=Be.invert(r);if(o&&this.ctx.concat(o),this.ctx?.scale(this.dpr,this.dpr),this.camera?.enabled&&(this.ctx?.concat(this.camera.worldMatrix),e)){let n=Be.getScale(this.camera.worldMatrix);this.ctx?.scale(1/n[0],1/n[1])}this.ctx?.concat(t),this.currentTransform=t}transform(t){this.ctx?.concat(t)}setSize(t,e){!this._isSizeDirty&&t===this._width&&e===this._height||(this._isSizeDirty=!1,this._width=t,this._height=e,this.canvas.style.width=t+"px",this.canvas.style.height=e+"px",this.canvas.width=t*this.dpr,this.canvas.height=e*this.dpr,this._surface&&(this._surface=Ie.MakeWebGLCanvasSurface(this.canvas),this.ctx=this._surface?.getCanvas()))}};function l1(i){for(let t=0;t<i.length;t++)if(i[t]!==void 0&&!Number.isFinite(i[t]))return!1;return!0}function Kd({r:i,g:t,b:e,a:r}){return Ie.Color4f(i,t,e,r)}var gc=class{constructor(t,e,r){this.uuid=t;this.data=e;this.enabled=!1;this.color=Le.transparent;this.blurRadius=0;this.offset=[0,0];this.spread=0;this.update(e)}update(t){t.color!==void 0&&(this.color=t.color),t.enabled!==void 0&&(this.enabled=t.enabled),t.blurRadius!==void 0&&(this.blurRadius=t.blurRadius),t.offset!==void 0&&(this.offset=t.offset),t.spread!==void 0&&(this.spread=t.spread)}};var xc=class{constructor(t,e,r){this.uuid=t;this.data=e;this.enabled=!1;this.radius=0;this.update(e)}update(t){t.enabled!==void 0&&(this.enabled=t.enabled),t.radius!==void 0&&(this.radius=t.radius)}};var Qd=class{constructor(t,e,r){this.uuid=t;this.data=e;this.enabled=!1;this.color=Le.transparent;this.update(e)}update(t){t.enabled!==void 0&&(this.enabled=t.enabled),t.color!==void 0&&(this.color=t.color)}};var Zd=class{constructor(t,e,r){this.uuid=t;this.data=e;this.enabled=!1;this.color=Le.transparent;this.thickness=0;this.mode="inside";this.update(e)}update(t){t.enabled!==void 0&&(this.enabled=t.enabled),t.color!==void 0&&(this.color=t.color),t.thickness!==void 0&&(this.thickness=t.thickness),t.mode!==void 0&&(this.mode=t.mode)}};var _r=class extends wi{constructor(e,r,o){super(e,r,o);this.uuid=e;this.data=r;this.autoClose=!0;this.fill=new Qd(e+"-fill",r.fill,o),this.stroke=new Zd(e+"-stroke",r.stroke,o),this.dropShadow=new gc(e+"-dropShadow",r.dropShadow,o),this.innerShadow=new gc(e+"-innerShadow",r.innerShadow,o),this.backgroundBlur=new xc(e+"-backgroundBlur",r.backgroundBlur,o),this.layerBlur=new xc(e+"-layerBlur",r.layerBlur,o)}applyFillStroke(e){e.fillColor=this.fill.enabled?this.fill.color:Le.transparent,e.strokeColor=this.stroke.enabled&&this.stroke.thickness>0?this.stroke.color:Le.transparent,e.strokeMode=this.stroke.mode,e.lineWidth=this.stroke.thickness}applyFilters(e){this.layerBlur.enabled?e.layerBlur=this.layerBlur.radius*5:e.layerBlur=0,this.backgroundBlur.enabled?e.backgroundBlur=this.backgroundBlur.radius*5:e.backgroundBlur=0,this.dropShadow.enabled?(e.dropShadowBlur=this.dropShadow.blurRadius*5,e.dropShadowColor=this.dropShadow.color,e.dropShadowOffsetX=this.dropShadow.offset[0],e.dropShadowOffsetY=this.dropShadow.offset[1]):e.dropShadowColor=Le.transparent,this.innerShadow.enabled?(e.innerShadowSpread=this.innerShadow.spread,e.innerShadowBlur=this.innerShadow.blurRadius*5,e.innerShadowColor=this.innerShadow.color,e.innerShadowOffsetX=this.innerShadow.offset[0],e.innerShadowOffsetY=this.innerShadow.offset[1]):e.innerShadowColor=Le.transparent}innerDraw(e){}draw(e){!this.visible||(e.save(),this.applyTransforms(e),this.applyFilters(e),this.applyFillStroke(e),e.beginPath(),this.innerDraw(e),this.autoClose&&e.closePath(),this.fill.enabled&&e.fill(),this.stroke.enabled&&e.stroke(),e.restore())}updateByPatchedOp(e,r,o){super.updateByPatchedOp(e,r,o),e.type===0&&(Ue(e.path,["fill"])?this.fill.update(e.props):Ue(e.path,["stroke"])?this.stroke.update(e.props):Ue(e.path,["dropShadow"])?this.dropShadow.update(e.props):Ue(e.path,["innerShadow"])?this.innerShadow.update(e.props):Ue(e.path,["layerBlur"])?this.layerBlur.update(e.props):Ue(e.path,["backgroundBlur"])?this.backgroundBlur.update(e.props):this.resetBBoxNeedsUpdate())}updateState(e,r){super.updateState(e,r),e.fill!==void 0&&this.fill.update(e.fill),e.stroke!==void 0&&this.stroke.update(e.stroke),e.dropShadow!==void 0&&this.dropShadow.update(e.dropShadow),e.innerShadow!==void 0&&this.innerShadow.update(e.innerShadow),e.layerBlur!==void 0&&this.layerBlur.update(e.layerBlur),e.backgroundBlur!==void 0&&this.backgroundBlur.update(e.backgroundBlur)}clone(e){let r=new _r(this.uuid,this.data,e);return r.parent=void 0,r}};var un=class extends _r{constructor(e,r,o){super(e,r,o);this.uuid=e;this.data=r;this.width=0;this.height=0;this.updateState(r,o)}innerDraw(e){e.ellipse(this.width*.5,this.height*.5,this.width*.5,this.height*.5,0,0,Math.PI*2)}intersectsInLocalSpace(e,r){return Jv(e,r,this.width*.5,this.height*.5,this.width*.5,this.height*.5)}getCenter(){return[this.width*.5,this.height*.5]}getHalfSize(){return[this.width*.5,this.height*.5]}updateSizeState(e){let r=!1;e.width!==void 0&&(this.width=typeof e.width=="number"?e.width:this.width,r=!0),e.height!==void 0&&(this.height=typeof e.height=="number"?e.height:this.height,r=!0),r&&this.updateWorldMatrix(!0,!1,!0)}updateState(e,r){super.updateState(e,r),this.updateSizeState(e)}clone(e){let r=new un(this.uuid,this.data,e);return r.parent=void 0,r}};var Yo=class extends _r{constructor(e,r,o){super(e,r,o);this.uuid=e;this.data=r;this.width=0;this.height=0;this.cornerRadius=[0,0,0,0];this.updateState(r,o)}innerDraw(e){e.rect(0,0,this.width,this.height,...this.cornerRadius)}getCenter(){return[this.width*.5,this.height*.5]}getHalfSize(){return[this.width*.5,this.height*.5]}updateCornerState(e){e.cornerRadius!==void 0&&(this.cornerRadius=e.cornerRadius)}updateSizeState(e){let r=!1;e.width!==void 0&&(this.width=typeof e.width=="number"?e.width:this.width,r=!0),e.height!==void 0&&(this.height=typeof e.height=="number"?e.height:this.height,r=!0),r&&this.updateWorldMatrix(!0,!1,!0)}updateState(e,r){super.updateState(e,r),this.updateSizeState(e),this.updateCornerState(e)}clone(e){let r=new Yo(this.uuid,this.data,e);return r.parent=void 0,r}};var dn=class extends _r{constructor(e,r,o){super(e,r,o);this.uuid=e;this.data=r;this._textHeight=0;this._textHeightDirty=!0;this.width=0;this.height=0;this.updateState(r,o)}get textHeight(){return this._textHeight}applyFillStroke(e){e.fillColor=this.fill.enabled?this.fill.color:Le.transparent,e.strokeColor=this.stroke.enabled&&this.stroke.thickness>0?this.stroke.color:Le.transparent,e.strokeMode="center",e.lineWidth=this.stroke.thickness}innerDraw(e){this._fontHolder?.arrayBuffer&&this._fontHolder.arrayBuffer.byteLength>1&&this.data.font&&e.registerFont(this._fontHolder.arrayBuffer,this.data.font);let r=this.data.textTransform,o=this.data.text.textValue.toString(),n=r===2?o.toUpperCase():r===3?o.toLowerCase():o,{height:a}=e.drawText(n,{x:0,y:0,width:this.width,height:this.height,fontSize:this.data.fontSize,lineHeight:this.data.lineHeight??1,letterSpacing:this.data.letterSpacing??0,horizontalAlign:this.data.horizontalAlign,verticalAlign:this.data.verticalAlign,font:this.data.font});this._textHeight=a}getCenter(){return[this.width*.5,this.height*.5]}getHalfSize(){return[this.width*.5,this.height*.5]}updateSizeState(e){let r=!1;e.width!==void 0&&(this.width=typeof e.width=="number"?e.width:this.width,r=!0),e.height!==void 0&&(this.height=typeof e.height=="number"?e.height:this.height,r=!0),r&&this.updateWorldMatrix(!0,!1,!0)}updateFontState(e,{shared:r}){e.font!==void 0&&(this._fontHolder=r.getFont(e.font),this._fontHolder&&!this._fontHolder.isLoaded&&this._fontHolder.loadingPromise.then(()=>{this.requestRender()}))}updateState(e,r){super.updateState(e,r),this.updateSizeState(e),this.updateFontState(e,r)}clone(e){let r=new dn(this.uuid,this.data,e);return r.parent=void 0,r}};var Xs=class extends _r{constructor(e,r,o){super(e,r,o);this.uuid=e;this.data=r;this.curves=[];this.extremasBBox={min:[0,0],max:[0,0]};this.updateState(r,o)}computeExtremas(){this.curves.length===0&&this.computeCurves();let e=this.curves.map(n=>Jd.extremas(n)),r=[1/0,1/0],o=[-1/0,-1/0];for(let n=0,a=e.length;n<a;n++){let s=e[n];s[0][0]<r[0]&&(r[0]=s[0][0]),s[0][1]<r[1]&&(r[1]=s[0][1]),s[1][0]>o[0]&&(o[0]=s[1][0]),s[1][1]>o[1]&&(o[1]=s[1][1])}return this.extremasBBox.min=[r[0],r[1]],this.extremasBBox.max=[o[0],o[1]],this.extremasBBox}computeCurves(){this.curves=[];for(let o=1,n=this.data.points.length;o<n;o++){let a=this.data.points[o].data,s=this.data.points[o-1].data,l={start:s.position,cp1:s.controlNext.position,cp2:a.controlPrevious.position,end:a.position};this.curves.push(l)}let e=this.data.points[0].data,r=this.data.points[this.data.points.length-1].data;if(this.data.isClosed){let o={start:r.position,cp1:r.controlNext.position,cp2:e.controlPrevious.position,end:e.position};this.curves.push(o)}}getCenter(){let[e,r]=this.extremasBBox.min,[o,n]=this.getHalfSize();return[e+o,r+n]}getHalfSize(){let{min:e,max:r}=this.extremasBBox;return[(r[0]-e[0])*.5,(r[1]-e[1])*.5]}innerDraw(e){for(let n=0,a=this.data.points.length;n<a;n++){let s=this.data.points[n].data;if(n===0){let[l,c]=s.position;e.moveTo(l,c)}else{let l=this.data.points[n-1].data,[c,u]=l.controlNext.position,[d,p]=s.controlPrevious.position,[f,h]=s.position,m={start:l.position,cp1:l.controlNext.position,cp2:s.controlPrevious.position,end:s.position};Jd.derive(m),e.bezierCurveTo(c,u,d,p,f,h)}}let r=this.data.points[0].data,o=this.data.points[this.data.points.length-1].data;if(this.data.isClosed){let[n,a]=o.controlNext.position,[s,l]=r.controlPrevious.position,[c,u]=r.position;e.bezierCurveTo(n,a,s,l,c,u)}}updateState(e,r){super.updateState(e,r),this.computeExtremas()}clone(e){let r=new Xs(this.uuid,this.data,e);return r.parent=void 0,r}},Jd;(n=>{function i(a){let s=a.start,l=a.cp1,c=a.cp2,u=a.end,d=[3*(l[0]-s[0]),3*(l[1]-s[1])],p=[3*(c[0]-l[0]),3*(c[1]-l[1])],f=[3*(u[0]-c[0]),3*(u[1]-c[1])],h={start:d,cp:p,end:f};return a.derivative=h,h.derivative=qh.derive(h),h}n.derive=i;function t(a,s,l,c=!1){let u=a-2*s+l;if(u!==0){let d=-Math.sqrt(Math.abs(s*s-a*l)),p=-a+s,f=-(d+p)/u,h=-(-d+p)/u;return[f,h]}else if(s!==l&&u===0)return[(2*s-l)/(2*(s-l))];return[]}function e(a){let s=a.derivative??n.derive(a),l=s.start,c=s.cp,u=s.end;return[t(l[0],c[0],u[0]),t(l[1],c[1],u[1])]}n.droot=e;function r(a){let[s,l]=n.droot(a),c=[a.start[0],a.end[0]],u=[a.start[1],a.end[1]];for(let d of s)c.push(n.compute(a,Math.min(1,Math.max(0,d)))[0]);for(let d of l)u.push(n.compute(a,Math.min(1,Math.max(0,d)))[1]);return c.sort((d,p)=>d-p),u.sort((d,p)=>d-p),[[c[0],u[0]],[c[c.length-1],u[u.length-1]]]}n.extremas=r;function o(a,s){if(s===0)return[...a.start];if(s===1)return[...a.end];let l=1-s,c=l*l,u=s*s,d=c*l,p=c*s*3,f=l*u*3,h=s*u;return[d*a.start[0]+p*a.cp1[0]+f*a.cp2[0]+h*a.end[0],d*a.start[1]+p*a.cp1[1]+f*a.cp2[1]+h*a.end[1]]}n.compute=o})(Jd||(Jd={}));var qh;(r=>{function i(o){let n=o.start,a=o.cp,s=o.end,l=[2*(a[0]-n[0]),2*(a[1]-n[1])],c=[2*(s[0]-a[0]),2*(s[1]-a[1])],u={start:l,end:c};return u.derivative=$h.derive(u),o.derivative=u,u}r.derive=i;function t(o){let n=o.derivative??r.derive(o),a=n.start,s=n.end;return[a[0]!==s[0]?a[0]/(a[0]-s[0]):0,a[1]!==s[1]?a[1]/(a[1]-s[1]):0]}r.droot=t;function e(o,n){if(n===0)return[...o.start];if(n===1)return[...o.end];let a=1-n,s=a*a,l=n*n,c=s,u=a*n*2,d=l;return[c*o.start[0]+u*o.cp[0]+d*o.end[0],c*o.start[1]+u*o.cp[1]+d*o.end[1]]}r.compute=e})(qh||(qh={}));var $h;(e=>{function i(r){let o=r.start,n=r.end,a=[n[0]-o[0],n[1]-o[1]];return r.derivative=a,r.derivative}e.derive=i;function t(r,o){if(o===0)return[...r.start];if(o===1)return[...r.end];let n=r.start,a=r.end;return[n[0]+(a[0]-n[0])*o,n[1]+(a[1]-n[1])*o]}e.compute=t})($h||($h={}));var Fr=class extends ur{constructor(e,r,o){super(e,r,o);this.uuid=e;this.width=0;this.height=0;this.clipped=!0;this.background=new Yo(e+"-background",ka.defaultData,o),this.background.parent=this,this.updateState(r,o)}get fill(){return this.background.fill}get stroke(){return this.background.stroke}get backgroundBlur(){return this.background.backgroundBlur}get layerBlur(){return this.background.layerBlur}get dropShadow(){return this.background.dropShadow}get innerShadow(){return this.background.innerShadow}get cornerRadius(){return this.background.cornerRadius}set cornerRadius(e){this.background.cornerRadius=e}updateLocalMatrix(){super.updateLocalMatrix(),this.background?.updateLocalMatrix()}updateWorldMatrix(e,r,o){super.updateWorldMatrix(e,r,o),this.background?.updateWorldMatrix(e,r,o)}draw(e){if(!this.visible)return;e.save();let r=this.width,o=this.height;this.applyTransforms(e),this.background.width=r,this.background.height=o,this.background.draw(e),this.clipped&&e.clipRect(0,0,r,o,...this.cornerRadius),this.innerDrawChildren(e),e.restore()}getCenter(){return[this.width*.5,this.height*.5]}getHalfSize(){return[this.width*.5,this.height*.5]}updateCornerState(e){e.cornerRadius!==void 0&&(this.cornerRadius=e.cornerRadius)}updateSizeState(e){let r=!1;e.width!==void 0&&(this.width=typeof e.width=="number"?e.width:this.width,r=!0),e.height!==void 0&&(this.height=typeof e.height=="number"?e.height:this.height,r=!0),r&&this.updateWorldMatrix(!0,!1,!0)}updateState(e,r){super.updateState(e,r),this.updateSizeState(e),this.updateCornerState(e),e.fill!==void 0&&this.fill.update(e.fill),e.stroke!==void 0&&this.stroke.update(e.stroke),e.dropShadow!==void 0&&this.dropShadow.update(e.dropShadow),e.innerShadow!==void 0&&this.innerShadow.update(e.innerShadow),e.layerBlur!==void 0&&this.layerBlur.update(e.layerBlur),e.backgroundBlur!==void 0&&this.backgroundBlur.update(e.backgroundBlur),e.clipped!==void 0&&(this.clipped=e.clipped)}requestRender(){super.requestRender(),this.dispatchEvent({type:"render"})}dispose(){this.removeEventListener("render")}updateByPatchedOp(e,r,o){super.updateByPatchedOp(e,r,o),e.type===0&&(Ue(e.path,["fill"])?this.fill.update(e.props):Ue(e.path,["stroke"])?this.stroke.update(e.props):Ue(e.path,["dropShadow"])?this.dropShadow.update(e.props):Ue(e.path,["innerShadow"])?this.innerShadow.update(e.props):Ue(e.path,["layerBlur"])?this.layerBlur.update(e.props):Ue(e.path,["backgroundBlur"])?this.backgroundBlur.update(e.props):this.resetBBoxNeedsUpdate())}clone(e){let r=new Fr(this.uuid,this.data,e);r.parent=void 0;for(let o of this.children)r.add(o.clone(e));return r}};var f1=ll(Xh(),1),Pi=class extends _r{constructor(e,r,o){super(e,r,o);this.uuid=e;this.data=r;this._pathBBox=new DOMRect;this.path="";this.updateState(r,o),this.autoClose=!1,this.computeSVGBBox()}computeSVGBBox(){let e=this.path;h1(this.path)&&(console.warn("Invalid SVG path",this.uuid),e="");let r=document.createElementNS("http://www.w3.org/2000/svg","svg"),o=document.createElementNS("http://www.w3.org/2000/svg","path");document.body.appendChild(r),o.setAttribute("d",e),r.appendChild(o),this._pathBBox=o.getBBox(),r.remove()}innerDraw(e){e.path(this.path)}intersectsInLocalSpace(e,r){return e>=this._pathBBox.x&&e<=this._pathBBox.x+this._pathBBox.width&&r>=this._pathBBox.y&&r<=this._pathBBox.y+this._pathBBox.height}getCenter(){return[(this._pathBBox.x+this._pathBBox.width)/2,(this._pathBBox.y+this._pathBBox.height)/2]}getHalfSize(){return[(this._pathBBox.x+this._pathBBox.width)/2,(this._pathBBox.y+this._pathBBox.height)/2]}updateState(e,r){super.updateState(e,r),e.path!==void 0&&(this.path=e.path,this.computeSVGBBox())}clone(e){let r=new Pi(this.uuid,this.data,e);return r.parent=void 0,r}};function h1(i){return/NaN/.test(i)}function m1(i,t=1,e=1){if(t<=0||e<=0)return i;if(h1(i))return console.warn("Cannot scale invalid path",i),tp([]);try{let o=(0,f1.parseSVG)(i).map(n=>{let a={...n};return"x"in a&&(a.x=a.x*t),"y"in a&&(a.y=a.y*e),"x1"in a&&(a.x1=a.x1*t),"x2"in a&&(a.x2=a.x2*t),"y1"in a&&(a.y1=a.y1*e),"y2"in a&&(a.y2=a.y2*e),"rx"in a&&(a.rx=a.rx*t),"ry"in a&&(a.ry=a.ry*e),a});return tp(o)}catch(r){return console.warn("Error parsing SVG path",r),tp([])}}function tp(i){let t=["rx","ry","xAxisRotation","largeArc","sweep","x1","y1","x2","y2","x","y"],e;return i.map(r=>{let o=[];t.forEach(a=>{if(a in r){let s=r[a]*1;o.length&&s>=0&&o.push(","),o.push(s)}});let n=(e===r.code?o[0]<0?"":",":r.code)+o.join("");return e=r.code,n}).join("")}function y1(i,t,e){switch(t.type){case"ellipse2d":return new un(i,t,e);case"rectangle2d":return new Yo(i,t,e);case"text2d":return new dn(i,t,e);case"vector2d":return new Xs(i,t,e);case"path2d":return new Pi(i,t,e);case"frame2d":return new Fr(i,t,e);case"group2d":default:return new Dr(i,t,e)}}var Yh=class{constructor(t,e,r){this.uuid=t;this.data=e;this.group=new Dr(Yh.GROUP_ID,{...Ol.defaultData},r),this.createChildrenObjects(e.objects,this.group,r)}createObject(t,e,r,o,n,a){let s=y1(t,e,a);s&&(o.add(s),o.children.splice(n,0,o.children.pop()),s.updateWorldMatrix(),r.length>0&&(s instanceof Dr||s instanceof Fr)&&this.createChildrenObjects(r,s,a))}createChildrenObjects(t,e,r){let o=0;for(let n of t)this.createObject(n.id,n.data,n.children,e,o,r),o+=1}draw(t){this.group.draw(t)}updateEntityByOp(t,e,r,o){let n=this.find(t);if(n)try{n.updateByOp(e,r,{shared:o})}catch(a){console.error(a)}}updateTreeByOp(t,e){if(t.path.length===0&&t.type===7){let r=t.parent===null?this.group:this.find(t.parent);r!==void 0&&r instanceof ur&&(this.createObject(t.id,t.data,t.children,r,t.localIndex,e),r.requestRender())}else if(t.path.length===0&&t.type===8){let r=this.find(t.id);if(r!==void 0&&r.parent!==void 0&&r.parent instanceof ur){let o=r.parent;r.resetBBoxNeedsUpdate(),o?.remove(r),o?.requestRender()}}else if(t.path.length===0&&t.type===9){let r=this.find(t.id);if(r!==void 0){let o=r.parent,n=t.parent===null?this:this.find(t.parent);if(n===void 0&&!1&&console.error("unexpected",n,t),n instanceof ur||n===this){n.add(r);let a=t.localIndex;n.children.splice(a,0,n.children.pop()),r.updateWorldMatrix(!0,!1,!0),o?.requestRender(),r.requestRender()}r.resetBBoxNeedsUpdate()}}}add(t){this.group.add(t)}remove(t){this.group.remove(t)}traverse(t){this.group.traverse(e=>{e!==this.group&&t(e)})}intersectsChildren(t,e,r,o=!1,n=[]){return this.group.intersectsChildren(t,e,r,o,n,!0)}intersectsChildrenReverse(t,e,r,o=!1,n=[]){return this.group.intersectsChildrenReverse(t,e,r,o,n,!0)}find(t){return this.group.find(t)}get children(){return this.group.children}project(t,e){return this.group.project(t,e)}getWithSortKey(t){let e=this.find(t);if(e===void 0)return;let r=[],o=e;for(;o!==this.group;){let n=o;o=o.parent;let a=o.children.indexOf(n);r.splice(0,0,a)}return{entity:e,sortKey:r}}getAllSorted(t){let e=[];for(let r of t){let o=this.getWithSortKey(r.id);o!==void 0&&e.push(o)}return e.sort((r,o)=>Ec(r.sortKey,o.sortKey)),e.map(r=>r.entity)}},Kn=Yh;Kn.GROUP_ID="scene2d";function Kh({constraints:i,newParentWidth:t,newParentHeight:e,initialParentWidth:r,initialParentHeight:o,objectInitialWidth:n,objectInitialHeight:a,objectInitialPosition:s}){let{horizontalConstraint:l,verticalConstraint:c}=i,u=t-r,d=e-o,p=n,f=a,h=s[0],m=s[1];if(l!==0){if(l===1)h+=u;else if(l===3)h+=u/2;else if(l===2)p=Math.max(1,p+u);else if(l===4){let y=t/r;p*=y,h*=y}}if(c!==0){if(c===1)m+=d;else if(c===3)m+=d/2;else if(c===2)f=Math.max(1,f+d);else if(c===4){let y=e/o;f*=y,m*=y}}return{width:p,height:f,position:[h,m]}}var cE=ll(Xh(),1);var sie={mm:{mm:1,cm:.1,in:1/25.4,pt:72/25.4,pc:6/25.4,px:-1},cm:{mm:10,cm:1,in:1/2.54,pt:72/2.54,pc:6/2.54,px:-1},in:{mm:25.4,cm:2.54,in:1,pt:72,pc:6,px:-1},pt:{mm:25.4/72,cm:2.54/72,in:1/72,pt:1,pc:6/72,px:-1},pc:{mm:25.4/6,cm:2.54/6,in:1/6,pt:72/6,pc:1,px:-1},px:{mm:1,px:1,cm:1,in:1,pt:1,pc:1}};var Gt=require("three");var uE=`
2664
2664
  varying vec2 vUv;
2665
2665
  void main() {
2666
2666
  vUv = uv;
@@ -2671,7 +2671,7 @@ float vogelShadow(int index, sampler2D shadowMap, vec2 uv, float texelSize, floa
2671
2671
  void main() {
2672
2672
  vec4 texel = texture2D( tDiffuse, vUv );
2673
2673
  gl_FragColor = texel;
2674
- }`,pE=new Gt.OrthographicCamera(-1,1,1,-1,0,1),Zh=class extends Gt.BufferGeometry{constructor(){super(),this.setAttribute("position",new Gt.Float32BufferAttribute([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute("uv",new Gt.Float32BufferAttribute([0,2,0,0,2,0],2))}},fE=new Zh,Jh=class{constructor(t){this._mesh=new Gt.Mesh(fE,t)}dispose(){this._mesh.geometry.dispose()}render(t){t.render(this._mesh,pE)}get material(){return this._mesh.material}set material(t){this._mesh.material=t}},y1=new Gt.ShaderMaterial({defines:{},uniforms:{tDiffuse:new Gt.Uniform(null)},vertexShader:uE,fragmentShader:dE}),hE=new Jh(y1),Kh=null,Qh=null,mE=()=>(Kh===null&&(Kh=document.createElement("canvas")),Kh),yE=i=>(Qh===null&&(Qh=new yc(i)),Qh),gE=Be.identity(),Ys=class{constructor(t,e,r,o){this.uuid=t;this.width=e;this.height=r;this.context=o;this.enabled=!0;this.isScreenSpace=!1;this.dpr=window.devicePixelRatio;this.isFrameDirty=!1;this.onRenderRequestedDownstream=()=>{this.isFrameDirty=!0,this.context.shared.requestRender()};this._innerApplySize=()=>{let t=this.width,e=this.height,r=this.dpr;this.renderer.dpr=this.isScreenSpace?r:Math.floor(2048/Math.max(t,e)),this.renderer.setSize(t,e)};this.onFrameOverrideObjectEvent=t=>{if(t.target?.uuid!==void 0){let e=this.frameRoot?.find(t.target.uuid);e&&e.dispatchEvent({...t,target:e})}};this.scene2d=new Kn(Gt.MathUtils.generateUUID(),ku.defaultData,{dpr:window.devicePixelRatio,shared:o.shared}),this.canvas=mE(),this.renderer=yE(this.canvas),this.promise=this.init(),this.renderTarget=new Gt.WebGLRenderTarget(1,1,{type:Gt.HalfFloatType,stencilBuffer:!1,depthBuffer:!1}),o.shared.addUIBuffer(this.uuid,this.renderTarget),this.textureHolder=o.shared.uiBuffer(this.uuid)}get canvasTexture(){return this._canvasTexture||(this._canvasTexture=new Gt.CanvasTexture(this.canvas)),this._canvasTexture}async init(){this.renderer instanceof yc&&(this.renderer.wasmURL=Kb.skiaWasmUrl),await this.renderer.init()}render(t){if(this.isFrameDirty){this.isFrameDirty=!1,this._innerApplySize(),this.renderer.clear(),this.frameOverride?.draw(this.renderer),this.renderer.render(),y1.uniforms.tDiffuse.value=this.canvasTexture,this.canvasTexture.needsUpdate=!0;let e=t.getRenderTarget();t.setRenderTarget(this.renderTarget),t.clear(),hE.render(t),t.setRenderTarget(e),this.textureHolder?.setNeedsUpdate(!0)}}updateEntity2DByOp(t,e,r,o){this.scene2d.updateEntityByOp(t,e,r,o),this.applySize()}updateTreeByOp(t,e){this.scene2d.updateTreeByOp(t,e),this.applySize()}applyOverrides(t){if(this.frameOverride&&this.frameRoot){this.frameOverride.position=[0,0],this.frameOverride.rotation=0;let e=t?.width??this.width,r=t?.height??this.height;this.frameOverride.width=e,this.frameOverride.height=r,this.frameOverride.localMatrix=gE,this.isScreenSpace&&(this.frameOverride.fill.color=Le.from0to1([0,0,0,0])),this.frameOverride.data={...this.frameOverride.data,width:e,height:r},g1({objectOverride:this.frameOverride,objectRoot:this.frameRoot,newParentWidth:this.frameOverride.width,newParentHeight:this.frameOverride.height,initialParentWidth:this.frameRoot.width,initialParentHeight:this.frameRoot.height}),this.frameOverride.updateWorldMatrix(!0,!1,!0)}}applySize(t,e=window.devicePixelRatio){let r=Math.max(1,t?.width??this.width),o=Math.max(1,t?.height??this.height);this.dpr=e,this.width=r,this.height=o,this._innerApplySize();let n=1,a=512,s=512;(r*e<a||o*e<s)&&(n=Math.max(a/(r*e),s/(o*e))),this.renderTarget.setSize(r*e*n,o*e*n),this._canvasTexture?.dispose(),this._canvasTexture=void 0,this.applyOverrides(t),this.frameOverride?.requestRender()}applyFrame(t){let e=this.context.scene.find2D(t);if(!(!e||!(e instanceof Fr)))return this.disposeFrameOverride(),this.frameRoot=e,this.frameOverride=e.clone({dpr:this.renderer.dpr,shared:this.context.shared}),this.scene2d.add(this.frameOverride),this.applySize(),this.frame?.addEventListener("render",this.onRenderRequestedDownstream),this.frameOverride.traverse(r=>{r.addEventListener("beginState",this.onFrameOverrideObjectEvent)}),this.frameOverride.traverse(r=>{r.addEventListener("completeState",this.onFrameOverrideObjectEvent)}),this.frame?.requestRender(),e}get frame(){return this.frameOverride}get frameId(){return this.frame?.uuid}find(t){return this.scene2d.find(t)}get texture(){return this.textureHolder?.getTexture(1001)}disposeFrameOverride(){this.frameOverride?.removeEventListener("render",this.onRenderRequestedDownstream),this.frameOverride?.traverse(t=>{t.removeEventListener("beginStateChange",this.onFrameOverrideObjectEvent)}),this.frameOverride?.traverse(t=>{t.removeEventListener("completeState",this.onFrameOverrideObjectEvent)}),this.frameOverride&&this.scene2d.remove(this.frameOverride)}};function g1({objectOverride:i,objectRoot:t,newParentWidth:e,newParentHeight:r,initialParentWidth:o,initialParentHeight:n}){if(i instanceof Fr&&t instanceof Fr||i instanceof Dr&&t instanceof Dr)for(let a=0,s=i.children.length;a<s;a++){let l=i.children[a],c=t.children[a];l&&c&&l.uuid===c.uuid&&bE({objectOverride:l,objectRoot:c,newParentWidth:e,newParentHeight:r,initialParentWidth:o,initialParentHeight:n})}}function xE(i){if(em(i))return[i.width,i.height];if(i instanceof Pi){let[t,e]=i.getHalfSize();return[t*2,e*2]}else if(i instanceof Dr){let[t,e]=i.recursiveBBox.getHalfSize();return[t*2,e*2]}return[0,0]}function bE({objectOverride:i,objectRoot:t,newParentWidth:e,newParentHeight:r,initialParentWidth:o,initialParentHeight:n}){let[a,s]=xE(t),{width:l,height:c,position:u}=Yh({constraints:i.data,newParentWidth:e,newParentHeight:r,initialParentWidth:o,initialParentHeight:n,objectInitialWidth:a,objectInitialHeight:s,objectInitialPosition:t.position});if(i.position=u,i.data={...i.data,position:u},i.states)for(let d in i.states)vE({stateId:d,objectOverride:i,objectRoot:t,newParentWidth:e,newParentHeight:r,initialParentWidth:o,initialParentHeight:n});if(em(i)||i instanceof Dr)em(i)&&(i.width=l,i.height=c,i.data={...i.data,width:l,height:c}),g1({objectOverride:i,objectRoot:t,newParentWidth:l,newParentHeight:c,initialParentWidth:a,initialParentHeight:s});else if(i instanceof Pi){let d=t,p=a!==0?l/a:1,f=s!==0?c/s:1;i.path=h1(d.path,p,f),i.data={...i.data,path:i.path}}}function vE({stateId:i,objectOverride:t,objectRoot:e,newParentWidth:r,newParentHeight:o,initialParentWidth:n,initialParentHeight:a}){let s=t.states?.[i],l=e.states?.[i];if(s&&l){let{width:c,height:u,position:d}=Yh({constraints:t.data,newParentWidth:r,newParentHeight:o,initialParentWidth:n,initialParentHeight:a,objectInitialWidth:ui.isResizeable(l)?l.width:0,objectInitialHeight:ui.isResizeable(l)?l.height:0,objectInitialPosition:l.position});Object.assign(t.states[i],{position:d}),ui.isResizeable(s)&&Object.assign(t.states[i],{width:c,height:u})}}function em(i){return i instanceof Xo||i instanceof Fr||i instanceof un||i instanceof dn}var to=class extends $a(x1.Scene){constructor(e,r,o){super();this.data=r;this.bgColor=new qt(1,1,1,1);this.fog=null;this.backupFog=new Ks.Fog(16777215,.1,2e3);this.fogUseBGColor=!1;this.isActive=!1;this.aoColor=new Ks.Color;this.penumbraSizeArrayCache=null;this.super_Entity(e,r),this.personalCamera=new Si(zi,{...En.defaultData,...r.camera,name:"Personal Camera"}),this.personalCamera.objectHelper.visible=!1,this.add(this.personalCamera),this.activeCamera=this.personalCamera,this.ambientLight=new Ks.HemisphereLight(13882323,8553090,.75),this.ambientLight.name="Default Ambient Light",this.ambientLight.layers.enable(3),this.ambientLight.removeFromParent(),this.add(this.ambientLight),r.uiScene?this.uiScene=new Kn((Array.isArray(e)?e[0]:e)+"-ui",r.uiScene,{dpr:window.devicePixelRatio,shared:o.shared}):r.uiFrame&&this.createUICanvas(r.uiFrame,o)}get scene(){return this.parent}get postprocessing(){return this.data.postprocessing}get frameId(){return this.data.uiFrame}get frame(){return this.uiCanvas?.frame}createUICanvas(e,r){this.uiCanvas=new Ys(this.uuid+"-uiscreen",window.innerWidth,window.innerHeight,r),this.uiCanvas.isScreenSpace=!0,this.uiCanvas.promise.then(()=>{this.uiCanvas?.applyFrame(e),this.uiCanvas?.applySize()})}updateVisible(){}setBackgroundColor(e){this.bgColor=e,this.fogUseBGColor===!0&&(this.backupFog.color=e)}entityChildrenCount(){return this.uiScene?this.uiScene.children.length:super.entityChildrenCount()}updateAmbientLight(e,r){e.color!==void 0&&(this.ambientLight.color=lr(e.color,r)),e.intensity!==void 0&&(this.ambientLight.intensity=e.intensity),e.enabled!==void 0&&(e.enabled?this.add(this.ambientLight):this.remove(this.ambientLight))}onDeactive(){this.isActive=!1}onActive(e){this.isActive=!0,e.fog=this.fog,this.traverseEntity(r=>{r instanceof Nr&&r.recomputeBoolean()}),this.updateShadow(this.data.shadow)}forceMaterialsUpdate(){this.traverseEntity(e=>{if(e instanceof Er)if(Array.isArray(e.material))for(let r of e.material)r.needsUpdate=!0;else e.material.needsUpdate=!0,e.material.dispose()})}updateShadow(e){e.softShadowQuality!==void 0&&this.isActive&&kv(e.softShadowQuality)&&this.forceMaterialsUpdate()}updateFog(e,r){if(e.enabled?this.fog=this.backupFog:this.fog=null,this.isActive){let o=this.scene;o.fog=this.fog}this.fogUseBGColor=e.useBackgroundColor,e.useBackgroundColor?this.backupFog.color.set(this.bgColor):this.backupFog.color=lr(e.color,r),this.backupFog.near=e.near,this.backupFog.far=e.far}updateAo(e,r){e.aoColor!==void 0&&(this.aoColor=lr(e.aoColor,r))}updateByOp(e,r,o,n){let a=this.data.uiFrame;super.updateByOp(e,r,o,n);let s=r;Ue(e.path,["fog"])?this.updateFog(s.fog,o.shared):Ue(e.path,["ao"])?this.updateAo(s.ao,o.shared):Ue(e.path,["ambient"])?this.updateAmbientLight(s.ambient,o.shared):Ue(e.path,["shadow"])?this.updateShadow(s.shadow):e.type===0&&e.path.length===0&&(e.props.uiFrame!==void 0||a!==s.uiFrame)&&this.updateUIFrame(e.props.uiFrame,o)}updateUIFrame(e,r){e?(this.uiCanvas||this.createUICanvas(e,r),this.uiCanvas.enabled=!0,this.uiCanvas.applyFrame(e)):this.uiCanvas&&(this.uiCanvas.enabled=!1)}updateState(e,r){this.updateState_Entity(e,r),e.backgroundColor!==void 0&&this.setBackgroundColor(lr(e.backgroundColor,r.shared)),e.fog!==void 0&&this.updateFog(e.fog,r.shared),e.ambient!==void 0&&this.updateAmbientLight(e.ambient,r.shared),e.ao!==void 0&&this.updateAo(e.ao,r.shared),e.shadow!==void 0&&this.updateShadow(e.shadow)}createFrame(e,r){}raycast(e,r){super.raycast(e,r)}switchActiveCamera(e){e&&e.isDescendantOf(this)&&(this.activeCamera!==this.personalCamera&&(this.activeCamera.objectHelper.visible=!0),this.activeCamera=e,e.objectHelper.visible=!1)}get playCamera(){return this.scene?.find(this.data.publish.playCamera)??this.personalCamera}switchToPlayCamera(){this.switchActiveCamera(this.playCamera)}get penumbraSizeArray(){return this.penumbraSizeArrayCache===null&&this.updatePenumbraSizeArray(),this.penumbraSizeArrayCache}updatePenumbraSizeArray(){this.penumbraSizeArrayCache=new Array(5).fill(.5);let e=0,r=0;this.traverseEntity(o=>{if(!o.visible)return!0;o instanceof qs&&o.visible&&e<3&&(this.penumbraSizeArrayCache[e]=o.data.penumbraSize??.5,e+=1),o instanceof $s&&o.visible&&e<5-3&&(this.penumbraSizeArrayCache[3+r]=o.data.penumbraSize??.5,r+=1)})}raycastWithClones(e){let r=[],o=n=>{for(let a of n.children){let s=a.cloner;Ge.is(a)&&(a.visible||s?.object.data.visible)&&((sn(a)||pc(a)&&this.scene.enableHelpers&&a.objectHelper.visible)&&(e.intersectObject(a,!1,r),bc(a,e,r,!0)),o(a))}};return o(this),r}updateEntity2DByOp(e,r,o,n){this.uiCanvas?.updateEntity2DByOp(e,r,o,n)}};var Rr=require("three");var tp=class extends js(Rr.PointLight,Ws){constructor(t,e,r){super(),this.super_Entity(t,e),this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024,this.shadow.normalBias=1,this.layers.enable(3);let n=this.shadow.camera;n.fov=90,n.aspect=1,n.near=100,n.far=2500;let a=new Rr.Vector3(-n.far+this.position.x,-n.far+this.position.y,-n.far+this.position.z),s=new Rr.Vector3(n.far+this.position.x,n.far+this.position.y,n.far+this.position.z),l=new Rr.Box3(a,s),c=new Rr.Box3Helper(l,new Rr.Color(16755200));c.visible=!1,this.gizmos.shadowmap=c,this.update()}update(){if(this.shadow&&(this.shadow.camera.updateProjectionMatrix(),this.gizmos))for(let t in this.gizmos){let e=this.gizmos[t];if(e instanceof Rr.Box3Helper){let r=this.shadow.camera,o=new Rr.Vector3(-r.far+this.position.x,-r.far+this.position.y,-r.far+this.position.z),n=new Rr.Vector3(r.far+this.position.x,r.far+this.position.y,r.far+this.position.z);e.box.set(o,n),e.updateMatrixWorld(!0)}}}updateMatrixWorld(t){super.updateMatrixWorld(t),this.objectHelper&&this.objectHelper.update()}updateState(t,e){this.updateState_Light(t,e),t.distance!==void 0&&(this.distance=t.distance),t.decay!==void 0&&(this.decay=t.decay),t.shadowRadius!==void 0&&(this.shadow.radius=t.shadowRadius),t.shadowResolution!==void 0&&(this.shadow.mapSize.set(t.shadowResolution,t.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null))}};var rp=class extends ht{get forceComputeSize(){return!0}get shape(){return this.geometry.userData.shape}updateEntityBoxSize(t,e){let r=this.geometry.getAttribute("position");r!==void 0?kl(r,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:r.count,t,e):super.updateEntityBoxSize(t,e)}};var Qs=class extends ht{constructor(e,r,o){super(e,r,o);this._shapeId=null;this._context=o}updateState(e,r){super.updateState(e,r),this.updateShape(),this.refreshAttachedCloners(r)}updateShape(){let e={...this.data.geometry.extrusion.shape};for(let n in e)typeof e[n]=="string"&&(e[n]=this._context.shared.getVariable(e[n],[this.uuid,"geometry","extrusion","shape",n]));let r;if(e.type==="Custom"){let n=e.shapeId;if(n!==this._shapeId&&this.detachShape(),n){this._shapeId=n;let a=this._context.scene.find(n);a?.data&&(a.attachedPaths.add(this),r=a.geometry.userData?.shape),r||this._context.scene.addPendingCommand(()=>this.updateShape())}}else{let n;switch(e.type){case"Rectangle":n=is;break;case"Ellipse":n=ts;break;case"Polygon":n=id;break;case"Star":n=nd;break;default:throw new Error(`Unknown shape type: ${e.type}`)}r=n.create({parameters:e}).userData.shape}let o=this.geometry;r&&o.inputs&&(o.inputs.shapeData=r,o.build())}detachShape(){this._shapeId!==null&&this._context.scene.find(this._shapeId)?.attachedPaths.delete(this)}createGeometryDelayed(e){this.geometryCreateDeleyed=e.shared,this.updateShape(),this.refreshAttachedPaths(e)}updateTransformState(e,r){return super.updateTransformState(e,r)}updateGeometryInteractions(e,r){super.updateGeometryInteractions(e,r),this.updateShape()}updateEntityBoxSize(e,r){let o=this.geometry.getAttribute("position");o!==void 0?kl(o,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:o.count,e,r):super.updateEntityBoxSize(e,r)}};var op=class extends rn{constructor(e,r,o){super(e,r,o);this.data=r}};var Zs=require("three");var Oi=class extends Zr(Zs.Group,Jr){constructor(e,r,o){super();r.type==="Instance"&&typeof e=="string"&&(r=this.transformAssignData(r,o)),this.super_Entity(e,r),this.objectHelper.update()}get isComponentRoot(){return this.data.type==="Component"&&typeof this.identity=="string"}get isInstanceRoot(){return this.data.type==="Instance"&&typeof this.identity=="string"}transformAssignData(e,r){let o=si.getComponentData({scene:r.scene.data,shared:r.shared.data},e.component);if(o){let n,a;for(let s of _o.rootOverrideProps)e[s]===void 0?(n===void 0&&(n={...e}),n[s]=o.data[s]):(a===void 0&&(a={}),a[s]=e[s],n===void 0&&(n={...e}),n[s]=Co.apply(o.data[s],e[s]));return this.overrideData=a,n}else return{...Vt.defaultData,...e,...no(Vt.defaultData,_o.rootOverrideProps)}}updateByOp(e,r,o,n){let a;if(this.isInstanceRoot&&!n){if(r=this.transformAssignData(r,o),e.type===0&&e.path.length===0&&this.component)for(let s of _o.rootOverrideProps)s in e.props&&e.props[s]===void 0&&(a===void 0&&(a={...e,props:{...e.props}}),a.props[s]=this.component.data[s]);else if(e.type===0&&e.path.length>0&&_o.rootOverrideProps.includes(e.path[0])){let s=e.path[0];a===void 0&&(a={...e,path:[],props:{[s]:r[s]}})}}super.updateByOp(a??e,r,o,n)}updateState(e,r){this.updateState_Entity(e,r)}expandInstanceChildren(e){let r=this.data;if(this.component===void 0){let o=e.scene.find(r.component)??null,n=!1;if(o!==this.oldComponent){if(this.oldComponent){let a=0;for(let s of this.children)if(Ge.is(s))e.scene.disposeAndUnregisterEntityRecursivelyIfNotReregistered(s),ip(s),a+=1;else break;this.children.splice(0,a)}n=!0}if(o){let a={};v1(e,[this.uuid],r.overrides,this,o,o,0,n,a);for(let s of this.children)if(Ge.is(s)){let l=s.data;l.type==="Empty"&&l.animations&&s.traverseEntity(c=>{let u=c.dataPatched;if(c instanceof ht&&u.bones&&u.boneInverses){let d=c.dataPatched;if(d.bones&&d.boneInverses){let p=d.bones.map(m=>e.scene.find(a[m])),f=d.boneInverses.map(m=>new Zs.Matrix4().fromArray(m)),h=new Zs.Skeleton(p,f);c.bind(h,c.bindMatrix)}}else c.matrixAutoUpdate=!0})}}this.oldComponent=this.component}}};function ip(i){if(i.component){let t=i.component.instances.indexOf(i);t>=0&&i.component.instances.splice(t,1);for(let e of i.children)Ge.is(e)&&ip(e)}}function b1(i,t,e,r){return i.component===t&&Bp(i.identity,r)?i.overrideData===e?2:1:0}function v1(i,t,e,r,o,n,a,s,l){if(a>50)return!1;if(r.component!==o){if(r.component){let u=r.component.instances.indexOf(r);u>=0&&r.component.instances.splice(u,1)}o.instances.find(u=>u===r)||o.instances.push(r),r.component=o}o instanceof Oi&&o.isInstanceRoot&&o.expandInstanceChildren(i);let c=0;for(let u of o.children)if(Ge.is(u)){let d=[...t,...typeof u.identity=="string"?[u.identity]:u.identity],p=za.resolve(e,d,1);if(p!=null&&!(p instanceof Je)){if(!1)debugger;Object.setPrototypeOf(p,Je.prototype),console.error("wrong prototype")}let f=null,h;if(!s){let m=r.children[c];if(f=Ge.is(m)?m:null,f!==null){let y=b1(f,u,p,d);h=y>=1?f.stateSelection:void 0,y!==2&&(f=null)}if(f===null&&(f=i.scene.findInstance(d)??null,f!==null)){let y=b1(f,u,p,d);if(h=y>=1?f.stateSelection:void 0,y!==2)f=null;else{let g=f.parent.children.indexOf(f);f.parent.children.splice(g,1),r.children.splice(c,0,f),f.parent===r?(g<=c&&console.error("not possible"),void 0):(f.parent=r,f.matrixWorldNeedsUpdate=!0,f.resetBBoxNeedsUpdate(),f.updateVisible(),i.pendingDeletes.delete(f),void 0)}}}if(f===null){let m=p?Co.apply(u.data,p):u.data;ao.is(m.type)&&(m={...m,type:"Empty"}),f=uo.createEntity(d,m,i),f.overrideData=p,r.add(f),r.children.splice(r.children.length-1,1),r.children.splice(c,0,f),f.updateState(f.data,i),h&&f.changeSelectedState(h,i),i.scene.registerInstanceAndSetUuid(f)}if(f.isBone){let m=f.identity[f.identity.length-1];l[m]=f.uuid}c+=1,v1(i,t,e,f,u,n,a+1,s,l)}if(!s){let u=c;for(;;){let d=r.children[c];if(Ge.is(d))i.pendingDeletes.add(d);else break;c+=1}r.children.splice(u,c-u)}return!0}var S1=require("three");var np=class extends Zr(S1.Bone,Jr){constructor(t,e){super(),this.super_Entity(t,e),this.objectHelper.update(),this.matrixAutoUpdate=!0}updateState(t,e){this.updateState_Entity(t,e)}};var Qn=class extends ht{constructor(e,r,o){super(e,r,o);this.onBeforeRender=e=>{this.uiCanvas.render(e)};this.uiCanvas=new Ys(e+"-canvas",r.geometry.width,r.geometry.height,o),this.uiCanvas.promise.then(()=>{this.applyFrame(this.dataPatched.geometry.frame,o.shared)})}updateByPatchedOpGeometry(e,r,o){super.updateByPatchedOpGeometry(e,r,o),e.type===0&&(e.props.frame!==void 0&&this.applyFrame(e.props.frame,o.shared),(e.props.width!==void 0||e.props.height!==void 0)&&this.applySize(e.props,o.shared))}applySize(e,r){let o=e?.width??this.dataPatched.geometry.width,n=e?.height??this.dataPatched.geometry.height;this.uiCanvas.applySize({width:o,height:n}),this.applyGeometryParametersFromFrame(r)}applyFrame(e,r){this.uiCanvas.applyFrame(e),this.applyGeometryParametersFromFrame(r),this.applyMaterialParametersFromFrame({shared:r})}applyGeometryParametersFromFrame(e){let r=this.frame;r&&(Object.assign(this.data,{geometry:Object.assign(this.data.geometry,{cornerRadius:r.cornerRadius,cornerType:0})}),Object.assign(this.dataPatched,{geometry:Object.assign(this.dataPatched.geometry,{cornerRadius:r.cornerRadius,cornerType:0})}),this.localGeometry?.dispose(),this.localGeometry=zo(this.dataPatched.geometry,e,this.data.flatShading,this))}applyMaterialParametersFromFrame(e){let r=this.frame;if(r){let o=r.data.backgroundBlur;Object.assign(this.data.material.layers[0].data.texture,{image:this.uiCanvas.uuid}),Object.assign(this.data.material.layers[1].data,{roughness:o.radius,alpha:o.enabled?1:0}),Object.assign(this.dataPatched.material.layers[0].data.texture,{image:this.uiCanvas.uuid}),Object.assign(this.dataPatched.material.layers[1].data,{roughness:o.radius,alpha:o.enabled?1:0}),this.material.reset?.(this.dataPatched.material,e,!0)}}updateEntity2DByOp(e,r,o,n){this.uiCanvas.updateEntity2DByOp(e,r,o,n),e===this.frameId&&r.type===0&&(r.props.cornerRadius!==void 0?this.applyGeometryParametersFromFrame(n):Ue(r.path,["backgroundBlur"])&&this.applyMaterialParametersFromFrame({shared:n}))}get frame(){return this.uiCanvas.frame}get frameId(){return this.frame?.uuid}removeInteractionGeometry(e){super.removeInteractionGeometry(e),this.applySize({},e)}updateGeometryInteractions(e,r){super.updateGeometryInteractions(e,r),this.applySize({width:e.width,height:e.height},r);let o={...this.data.geometry,...e};this.localGeometry?.dispose(),this.localGeometry=zo(o,r,this.data.flatShading,this)}};var Ve=require("three"),q1=require("three/examples/jsm/misc/GPUComputationRenderer.js");var Qt=require("three"),w1=require("three/examples/jsm/math/MeshSurfaceSampler.js");function P1(i){let t=new Float32Array(i*i*2);for(let e=0;e<i;e++)for(let r=0;r<i;r++){let o=e*i+r;t[o*2+0]=e/(i-1),t[o*2+1]=r/(i-1)}return t}function O1(i){let t=Math.ceil(Math.sqrt(i));return Math.max(t,1)}function T1(i,t){let e=new Qt.Mesh(i.geometry,i.material),r=[],o=[],n=new Qt.Vector3,a=new Qt.Vector3;e.geometry.index!==null&&(e.geometry=e.geometry.toNonIndexed());let s=new w1.MeshSurfaceSampler(e).build();for(let u=0;u<t;u++)s.sample(n,a),r.push(n.x,n.y,n.z),o.push(a.x,a.y,a.z);let l=new Float32Array(r),c=new Float32Array(o);return{positions:l,normals:c}}function tm(i,t){let e=i,r=new Float32Array(4*t*t);for(let n=0;n<t*t;n++)r[4*n]=e[3*n],r[4*n+1]=e[3*n+1],r[4*n+2]=e[3*n+2],r[4*n+3]=0;let o=new Qt.DataTexture(r,t,t,Qt.RGBAFormat,Qt.FloatType);return o.needsUpdate=!0,o}function C1({size:i}){let t=new Float32Array(4*i*i);for(let r=0;r<i*i;r++)t[4*r]=r,t[4*r+1]=0,t[4*r+2]=0,t[4*r+3]=0;let e=new Qt.DataTexture(t,i,i,Qt.RGBAFormat,Qt.FloatType);return e.needsUpdate=!0,e}function A1(i){let t=new Float32Array(4*i*i);for(let r=0;r<i*i;r++)t[4*r]=0,t[4*r+1]=0,t[4*r+2]=0,t[4*r+3]=0;let e=new Qt.DataTexture(t,i,i,Qt.RGBAFormat,Qt.FloatType);return e.needsUpdate=!0,e}var M1=`
2674
+ }`,pE=new Gt.OrthographicCamera(-1,1,1,-1,0,1),Jh=class extends Gt.BufferGeometry{constructor(){super(),this.setAttribute("position",new Gt.Float32BufferAttribute([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute("uv",new Gt.Float32BufferAttribute([0,2,0,0,2,0],2))}},fE=new Jh,em=class{constructor(t){this._mesh=new Gt.Mesh(fE,t)}dispose(){this._mesh.geometry.dispose()}render(t){t.render(this._mesh,pE)}get material(){return this._mesh.material}set material(t){this._mesh.material=t}},g1=new Gt.ShaderMaterial({defines:{},uniforms:{tDiffuse:new Gt.Uniform(null)},vertexShader:uE,fragmentShader:dE}),hE=new em(g1),Qh=null,Zh=null,mE=()=>(Qh===null&&(Qh=document.createElement("canvas")),Qh),yE=i=>(Zh===null&&(Zh=new yc(i)),Zh),gE=Be.identity(),Ys=class{constructor(t,e,r,o){this.uuid=t;this.width=e;this.height=r;this.context=o;this.enabled=!0;this.isScreenSpace=!1;this.dpr=window.devicePixelRatio;this.isFrameDirty=!1;this.onRenderRequestedDownstream=()=>{this.isFrameDirty=!0,this.context.shared.requestRender()};this._innerApplySize=()=>{let t=this.width,e=this.height,r=this.dpr;this.renderer.dpr=this.isScreenSpace?r:Math.floor(2048/Math.max(t,e)),this.renderer.setSize(t,e)};this.onFrameOverrideObjectEvent=t=>{if(t.target?.uuid!==void 0){let e=this.frameRoot?.find(t.target.uuid);e&&e.dispatchEvent({...t,target:e})}};this.scene2d=new Kn(Gt.MathUtils.generateUUID(),Hu.defaultData,{dpr:window.devicePixelRatio,shared:o.shared}),this.canvas=mE(),this.renderer=yE(this.canvas),this.promise=this.init(),this.renderTarget=new Gt.WebGLRenderTarget(1,1,{type:Gt.HalfFloatType,stencilBuffer:!1,depthBuffer:!1}),o.shared.addUIBuffer(this.uuid,this.renderTarget),this.textureHolder=o.shared.uiBuffer(this.uuid)}get canvasTexture(){return this._canvasTexture||(this._canvasTexture=new Gt.CanvasTexture(this.canvas)),this._canvasTexture}async init(){this.renderer instanceof yc&&(this.renderer.wasmURL=Qb.skiaWasmUrl),await this.renderer.init()}render(t){if(this.isFrameDirty){this.isFrameDirty=!1,this._innerApplySize(),this.renderer.clear(),this.frameOverride?.draw(this.renderer),this.renderer.render(),g1.uniforms.tDiffuse.value=this.canvasTexture,this.canvasTexture.needsUpdate=!0;let e=t.getRenderTarget();t.setRenderTarget(this.renderTarget),t.clear(),hE.render(t),t.setRenderTarget(e),this.textureHolder?.setNeedsUpdate(!0)}}updateEntity2DByOp(t,e,r,o){this.scene2d.updateEntityByOp(t,e,r,o),this.applySize()}updateTreeByOp(t,e){this.scene2d.updateTreeByOp(t,e),this.applySize()}applyOverrides(t){if(this.frameOverride&&this.frameRoot){this.frameOverride.position=[0,0],this.frameOverride.rotation=0;let e=t?.width??this.width,r=t?.height??this.height;this.frameOverride.width=e,this.frameOverride.height=r,this.frameOverride.localMatrix=gE,this.isScreenSpace&&(this.frameOverride.fill.color=Le.from0to1([0,0,0,0])),this.frameOverride.data={...this.frameOverride.data,width:e,height:r},x1({objectOverride:this.frameOverride,objectRoot:this.frameRoot,newParentWidth:this.frameOverride.width,newParentHeight:this.frameOverride.height,initialParentWidth:this.frameRoot.width,initialParentHeight:this.frameRoot.height}),this.frameOverride.updateWorldMatrix(!0,!1,!0)}}applySize(t,e=window.devicePixelRatio){let r=Math.max(1,t?.width??this.width),o=Math.max(1,t?.height??this.height);this.dpr=e,this.width=r,this.height=o,this._innerApplySize();let n=1,a=512,s=512;(r*e<a||o*e<s)&&(n=Math.max(a/(r*e),s/(o*e))),this.renderTarget.setSize(r*e*n,o*e*n),this._canvasTexture?.dispose(),this._canvasTexture=void 0,this.applyOverrides(t),this.frameOverride?.requestRender()}applyFrame(t){let e=this.context.scene.find2D(t);if(!(!e||!(e instanceof Fr)))return this.disposeFrameOverride(),this.frameRoot=e,this.frameOverride=e.clone({dpr:this.renderer.dpr,shared:this.context.shared}),this.scene2d.add(this.frameOverride),this.applySize(),this.frame?.addEventListener("render",this.onRenderRequestedDownstream),this.frameOverride.traverse(r=>{r.addEventListener("beginState",this.onFrameOverrideObjectEvent)}),this.frameOverride.traverse(r=>{r.addEventListener("completeState",this.onFrameOverrideObjectEvent)}),this.frame?.requestRender(),e}get frame(){return this.frameOverride}get frameId(){return this.frame?.uuid}find(t){return this.scene2d.find(t)}get texture(){return this.textureHolder?.getTexture(1001)}disposeFrameOverride(){this.frameOverride?.removeEventListener("render",this.onRenderRequestedDownstream),this.frameOverride?.traverse(t=>{t.removeEventListener("beginStateChange",this.onFrameOverrideObjectEvent)}),this.frameOverride?.traverse(t=>{t.removeEventListener("completeState",this.onFrameOverrideObjectEvent)}),this.frameOverride&&this.scene2d.remove(this.frameOverride)}};function x1({objectOverride:i,objectRoot:t,newParentWidth:e,newParentHeight:r,initialParentWidth:o,initialParentHeight:n}){if(i instanceof Fr&&t instanceof Fr||i instanceof Dr&&t instanceof Dr)for(let a=0,s=i.children.length;a<s;a++){let l=i.children[a],c=t.children[a];l&&c&&l.uuid===c.uuid&&bE({objectOverride:l,objectRoot:c,newParentWidth:e,newParentHeight:r,initialParentWidth:o,initialParentHeight:n})}}function xE(i){if(tm(i))return[i.width,i.height];if(i instanceof Pi){let[t,e]=i.getHalfSize();return[t*2,e*2]}else if(i instanceof Dr){let[t,e]=i.recursiveBBox.getHalfSize();return[t*2,e*2]}return[0,0]}function bE({objectOverride:i,objectRoot:t,newParentWidth:e,newParentHeight:r,initialParentWidth:o,initialParentHeight:n}){let[a,s]=xE(t),{width:l,height:c,position:u}=Kh({constraints:i.data,newParentWidth:e,newParentHeight:r,initialParentWidth:o,initialParentHeight:n,objectInitialWidth:a,objectInitialHeight:s,objectInitialPosition:t.position});if(i.position=u,i.data={...i.data,position:u},i.states)for(let d in i.states)vE({stateId:d,objectOverride:i,objectRoot:t,newParentWidth:e,newParentHeight:r,initialParentWidth:o,initialParentHeight:n});if(tm(i)||i instanceof Dr)tm(i)&&(i.width=l,i.height=c,i.data={...i.data,width:l,height:c}),x1({objectOverride:i,objectRoot:t,newParentWidth:l,newParentHeight:c,initialParentWidth:a,initialParentHeight:s});else if(i instanceof Pi){let d=t,p=a!==0?l/a:1,f=s!==0?c/s:1;i.path=m1(d.path,p,f),i.data={...i.data,path:i.path}}}function vE({stateId:i,objectOverride:t,objectRoot:e,newParentWidth:r,newParentHeight:o,initialParentWidth:n,initialParentHeight:a}){let s=t.states?.[i],l=e.states?.[i];if(s&&l){let{width:c,height:u,position:d}=Kh({constraints:t.data,newParentWidth:r,newParentHeight:o,initialParentWidth:n,initialParentHeight:a,objectInitialWidth:ui.isResizeable(l)?l.width:0,objectInitialHeight:ui.isResizeable(l)?l.height:0,objectInitialPosition:l.position});Object.assign(t.states[i],{position:d}),ui.isResizeable(s)&&Object.assign(t.states[i],{width:c,height:u})}}function tm(i){return i instanceof Yo||i instanceof Fr||i instanceof un||i instanceof dn}var to=class extends $a(b1.Scene){constructor(e,r,o){super();this.data=r;this.bgColor=new qt(1,1,1,1);this.fog=null;this.backupFog=new Ks.Fog(16777215,.1,2e3);this.fogUseBGColor=!1;this.isActive=!1;this.aoColor=new Ks.Color;this.penumbraSizeArrayCache=null;this.super_Entity(e,r),this.personalCamera=new Si(zi,{...En.defaultData,...r.camera,name:"Personal Camera"}),this.personalCamera.objectHelper.visible=!1,this.add(this.personalCamera),this.activeCamera=this.personalCamera,this.ambientLight=new Ks.HemisphereLight(13882323,8553090,.75),this.ambientLight.name="Default Ambient Light",this.ambientLight.layers.enable(3),this.ambientLight.removeFromParent(),this.add(this.ambientLight),r.uiScene?this.uiScene=new Kn((Array.isArray(e)?e[0]:e)+"-ui",r.uiScene,{dpr:window.devicePixelRatio,shared:o.shared}):r.uiFrame&&this.createUICanvas(r.uiFrame,o)}get scene(){return this.parent}get postprocessing(){return this.data.postprocessing}get frameId(){return this.data.uiFrame}get frame(){return this.uiCanvas?.frame}createUICanvas(e,r){this.uiCanvas=new Ys(this.uuid+"-uiscreen",window.innerWidth,window.innerHeight,r),this.uiCanvas.isScreenSpace=!0,this.uiCanvas.promise.then(()=>{this.uiCanvas?.applyFrame(e),this.uiCanvas?.applySize()})}updateVisible(){}setBackgroundColor(e){this.bgColor=e,this.fogUseBGColor===!0&&(this.backupFog.color=e)}entityChildrenCount(){return this.uiScene?this.uiScene.children.length:super.entityChildrenCount()}updateAmbientLight(e,r){e.color!==void 0&&(this.ambientLight.color=lr(e.color,r)),e.intensity!==void 0&&(this.ambientLight.intensity=e.intensity),e.enabled!==void 0&&(e.enabled?this.add(this.ambientLight):this.remove(this.ambientLight))}onDeactive(){this.isActive=!1}onActive(e){this.isActive=!0,e.fog=this.fog,this.traverseEntity(r=>{r instanceof Nr&&r.recomputeBoolean()}),this.updateShadow(this.data.shadow)}forceMaterialsUpdate(){this.traverseEntity(e=>{if(e instanceof Er)if(Array.isArray(e.material))for(let r of e.material)r.needsUpdate=!0;else e.material.needsUpdate=!0,e.material.dispose()})}updateShadow(e){e.softShadowQuality!==void 0&&this.isActive&&Hv(e.softShadowQuality)&&this.forceMaterialsUpdate()}updateFog(e,r){if(e.enabled?this.fog=this.backupFog:this.fog=null,this.isActive){let o=this.scene;o.fog=this.fog}this.fogUseBGColor=e.useBackgroundColor,e.useBackgroundColor?this.backupFog.color.set(this.bgColor):this.backupFog.color=lr(e.color,r),this.backupFog.near=e.near,this.backupFog.far=e.far}updateAo(e,r){e.aoColor!==void 0&&(this.aoColor=lr(e.aoColor,r))}updateByOp(e,r,o,n){let a=this.data.uiFrame;super.updateByOp(e,r,o,n);let s=r;Ue(e.path,["fog"])?this.updateFog(s.fog,o.shared):Ue(e.path,["ao"])?this.updateAo(s.ao,o.shared):Ue(e.path,["ambient"])?this.updateAmbientLight(s.ambient,o.shared):Ue(e.path,["shadow"])?this.updateShadow(s.shadow):e.type===0&&e.path.length===0&&(e.props.uiFrame!==void 0||a!==s.uiFrame)&&this.updateUIFrame(e.props.uiFrame,o)}updateUIFrame(e,r){e?(this.uiCanvas||this.createUICanvas(e,r),this.uiCanvas.enabled=!0,this.uiCanvas.applyFrame(e)):this.uiCanvas&&(this.uiCanvas.enabled=!1)}updateState(e,r){this.updateState_Entity(e,r),e.backgroundColor!==void 0&&this.setBackgroundColor(lr(e.backgroundColor,r.shared)),e.fog!==void 0&&this.updateFog(e.fog,r.shared),e.ambient!==void 0&&this.updateAmbientLight(e.ambient,r.shared),e.ao!==void 0&&this.updateAo(e.ao,r.shared),e.shadow!==void 0&&this.updateShadow(e.shadow)}createFrame(e,r){}raycast(e,r){super.raycast(e,r)}switchActiveCamera(e){e&&e.isDescendantOf(this)&&(this.activeCamera!==this.personalCamera&&(this.activeCamera.objectHelper.visible=!0),this.activeCamera=e,e.objectHelper.visible=!1)}get playCamera(){return this.scene?.find(this.data.publish.playCamera)??this.personalCamera}switchToPlayCamera(){this.switchActiveCamera(this.playCamera)}get penumbraSizeArray(){return this.penumbraSizeArrayCache===null&&this.updatePenumbraSizeArray(),this.penumbraSizeArrayCache}updatePenumbraSizeArray(){this.penumbraSizeArrayCache=new Array(5).fill(.5);let e=0,r=0;this.traverseEntity(o=>{if(!o.visible)return!0;o instanceof qs&&o.visible&&e<3&&(this.penumbraSizeArrayCache[e]=o.data.penumbraSize??.5,e+=1),o instanceof $s&&o.visible&&e<5-3&&(this.penumbraSizeArrayCache[3+r]=o.data.penumbraSize??.5,r+=1)})}raycastWithClones(e){let r=[],o=n=>{for(let a of n.children){let s=a.cloner;Ge.is(a)&&(a.visible||s?.object.data.visible)&&((sn(a)||pc(a)&&this.scene.enableHelpers&&a.objectHelper.visible)&&(e.intersectObject(a,!1,r),bc(a,e,r,!0)),o(a))}};return o(this),r}updateEntity2DByOp(e,r,o,n){this.uiCanvas?.updateEntity2DByOp(e,r,o,n)}};var Rr=require("three");var rp=class extends js(Rr.PointLight,Ws){constructor(t,e,r){super(),this.super_Entity(t,e),this.castShadow=!0,this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024,this.shadow.normalBias=1,this.layers.enable(3);let n=this.shadow.camera;n.fov=90,n.aspect=1,n.near=100,n.far=2500;let a=new Rr.Vector3(-n.far+this.position.x,-n.far+this.position.y,-n.far+this.position.z),s=new Rr.Vector3(n.far+this.position.x,n.far+this.position.y,n.far+this.position.z),l=new Rr.Box3(a,s),c=new Rr.Box3Helper(l,new Rr.Color(16755200));c.visible=!1,this.gizmos.shadowmap=c,this.update()}update(){if(this.shadow&&(this.shadow.camera.updateProjectionMatrix(),this.gizmos))for(let t in this.gizmos){let e=this.gizmos[t];if(e instanceof Rr.Box3Helper){let r=this.shadow.camera,o=new Rr.Vector3(-r.far+this.position.x,-r.far+this.position.y,-r.far+this.position.z),n=new Rr.Vector3(r.far+this.position.x,r.far+this.position.y,r.far+this.position.z);e.box.set(o,n),e.updateMatrixWorld(!0)}}}updateMatrixWorld(t){super.updateMatrixWorld(t),this.objectHelper&&this.objectHelper.update()}updateState(t,e){this.updateState_Light(t,e),t.distance!==void 0&&(this.distance=t.distance),t.decay!==void 0&&(this.decay=t.decay),t.shadowRadius!==void 0&&(this.shadow.radius=t.shadowRadius),t.shadowResolution!==void 0&&(this.shadow.mapSize.set(t.shadowResolution,t.shadowResolution),this.shadow.map&&(this.shadow.map.dispose(),this.shadow.map=null))}};var op=class extends ht{get forceComputeSize(){return!0}get shape(){return this.geometry.userData.shape}updateEntityBoxSize(t,e){let r=this.geometry.getAttribute("position");r!==void 0?kl(r,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:r.count,t,e):super.updateEntityBoxSize(t,e)}};var Qs=class extends ht{constructor(e,r,o){super(e,r,o);this._shapeId=null;this._context=o}updateState(e,r){super.updateState(e,r),this.updateShape(),this.refreshAttachedCloners(r)}updateShape(){let e={...this.data.geometry.extrusion.shape};for(let n in e)typeof e[n]=="string"&&(e[n]=this._context.shared.getVariable(e[n],[this.uuid,"geometry","extrusion","shape",n]));let r;if(e.type==="Custom"){let n=e.shapeId;if(n!==this._shapeId&&this.detachShape(),n){this._shapeId=n;let a=this._context.scene.find(n);a?.data&&(a.attachedPaths.add(this),r=a.geometry.userData?.shape),r||this._context.scene.addPendingCommand(()=>this.updateShape())}}else{let n;switch(e.type){case"Rectangle":n=is;break;case"Ellipse":n=ts;break;case"Polygon":n=nd;break;case"Star":n=ad;break;default:throw new Error(`Unknown shape type: ${e.type}`)}r=n.create({parameters:e}).userData.shape}let o=this.geometry;r&&o.inputs&&(o.inputs.shapeData=r,o.build())}detachShape(){this._shapeId!==null&&this._context.scene.find(this._shapeId)?.attachedPaths.delete(this)}createGeometryDelayed(e){this.geometryCreateDeleyed=e.shared,this.updateShape(),this.refreshAttachedPaths(e)}updateTransformState(e,r){return super.updateTransformState(e,r)}updateGeometryInteractions(e,r){super.updateGeometryInteractions(e,r),this.updateShape()}updateEntityBoxSize(e,r){let o=this.geometry.getAttribute("position");o!==void 0?kl(o,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:o.count,e,r):super.updateEntityBoxSize(e,r)}};var ip=class extends rn{constructor(e,r,o){super(e,r,o);this.data=r}};var Zs=require("three");var Oi=class extends Zr(Zs.Group,Jr){constructor(e,r,o){super();r.type==="Instance"&&typeof e=="string"&&(r=this.transformAssignData(r,o)),this.super_Entity(e,r),this.objectHelper.update()}get isComponentRoot(){return this.data.type==="Component"&&typeof this.identity=="string"}get isInstanceRoot(){return this.data.type==="Instance"&&typeof this.identity=="string"}transformAssignData(e,r){let o=Ro.getComponentData({scene:r.scene.data,shared:r.shared.data},e.component);if(o){let n,a;for(let s of _o.rootOverrideProps)e[s]===void 0?(n===void 0&&(n={...e}),n[s]=o.data[s]):(a===void 0&&(a={}),a[s]=e[s],n===void 0&&(n={...e}),n[s]=Co.apply(o.data[s],e[s]));return this.overrideData=a,n}else return{...Vt.defaultData,...e,...no(Vt.defaultData,_o.rootOverrideProps)}}updateByOp(e,r,o,n){let a;if(this.isInstanceRoot&&!n){if(r=this.transformAssignData(r,o),e.type===0&&e.path.length===0&&this.component)for(let s of _o.rootOverrideProps)s in e.props&&e.props[s]===void 0&&(a===void 0&&(a={...e,props:{...e.props}}),a.props[s]=this.component.data[s]);else if(e.type===0&&e.path.length>0&&_o.rootOverrideProps.includes(e.path[0])){let s=e.path[0];a===void 0&&(a={...e,path:[],props:{[s]:r[s]}})}}super.updateByOp(a??e,r,o,n)}updateState(e,r){this.updateState_Entity(e,r)}expandInstanceChildren(e){let r=this.data;if(this.component===void 0){let o=e.scene.find(r.component)??null,n=!1;if(o!==this.oldComponent){if(this.oldComponent){let a=0;for(let s of this.children)if(Ge.is(s))e.scene.disposeAndUnregisterEntityRecursivelyIfNotReregistered(s),np(s),a+=1;else break;this.children.splice(0,a)}n=!0}if(o){let a={};S1(e,[this.uuid],r.overrides,this,o,o,0,n,a);for(let s of this.children)if(Ge.is(s)){let l=s.data;l.type==="Empty"&&l.animations&&s.traverseEntity(c=>{let u=c.dataPatched;if(c instanceof ht&&u.bones&&u.boneInverses){let d=c.dataPatched;if(d.bones&&d.boneInverses){let p=d.bones.map(m=>e.scene.find(a[m])),f=d.boneInverses.map(m=>new Zs.Matrix4().fromArray(m)),h=new Zs.Skeleton(p,f);c.bind(h,c.bindMatrix)}}else c.matrixAutoUpdate=!0})}}this.oldComponent=this.component}}};function np(i){if(i.component){let t=i.component.instances.indexOf(i);t>=0&&i.component.instances.splice(t,1);for(let e of i.children)Ge.is(e)&&np(e)}}function v1(i,t,e,r){return i.component===t&&Vp(i.identity,r)?i.overrideData===e?2:1:0}function S1(i,t,e,r,o,n,a,s,l){if(a>50)return!1;if(r.component!==o){if(r.component){let u=r.component.instances.indexOf(r);u>=0&&r.component.instances.splice(u,1)}o.instances.find(u=>u===r)||o.instances.push(r),r.component=o}o instanceof Oi&&o.isInstanceRoot&&o.expandInstanceChildren(i);let c=0;for(let u of o.children)if(Ge.is(u)){let d=[...t,...typeof u.identity=="string"?[u.identity]:u.identity],p=za.resolve(e,d,1);if(p!=null&&!(p instanceof Je)){if(!1)debugger;Object.setPrototypeOf(p,Je.prototype),console.error("wrong prototype")}let f=null,h;if(!s){let m=r.children[c];if(f=Ge.is(m)?m:null,f!==null){let y=v1(f,u,p,d);h=y>=1?f.stateSelection:void 0,y!==2&&(f=null)}if(f===null&&(f=i.scene.findInstance(d)??null,f!==null)){let y=v1(f,u,p,d);if(h=y>=1?f.stateSelection:void 0,y!==2)f=null;else{let g=f.parent.children.indexOf(f);f.parent.children.splice(g,1),r.children.splice(c,0,f),f.parent===r?(g<=c&&console.error("not possible"),void 0):(f.parent=r,f.matrixWorldNeedsUpdate=!0,f.resetBBoxNeedsUpdate(),f.updateVisible(),i.pendingDeletes.delete(f),void 0)}}}if(f===null){let m=p?Co.apply(u.data,p):u.data;ao.is(m.type)&&(m={...m,type:"Empty"}),f=uo.createEntity(d,m,i),f.overrideData=p,r.add(f),r.children.splice(r.children.length-1,1),r.children.splice(c,0,f),f.updateState(f.data,i),h&&f.changeSelectedState(h,i),i.scene.registerInstanceAndSetUuid(f)}if(f.isBone){let m=f.identity[f.identity.length-1];l[m]=f.uuid}c+=1,S1(i,t,e,f,u,n,a+1,s,l)}if(!s){let u=c;for(;;){let d=r.children[c];if(Ge.is(d))i.pendingDeletes.add(d);else break;c+=1}r.children.splice(u,c-u)}return!0}var w1=require("three");var ap=class extends Zr(w1.Bone,Jr){constructor(t,e){super(),this.super_Entity(t,e),this.objectHelper.update(),this.matrixAutoUpdate=!0}updateState(t,e){this.updateState_Entity(t,e)}};var Qn=class extends ht{constructor(e,r,o){super(e,r,o);this.onBeforeRender=e=>{this.uiCanvas.render(e)};this.uiCanvas=new Ys(e+"-canvas",r.geometry.width,r.geometry.height,o),this.uiCanvas.promise.then(()=>{this.applyFrame(this.dataPatched.geometry.frame,o.shared)})}updateByPatchedOpGeometry(e,r,o){super.updateByPatchedOpGeometry(e,r,o),e.type===0&&(e.props.frame!==void 0&&this.applyFrame(e.props.frame,o.shared),(e.props.width!==void 0||e.props.height!==void 0)&&this.applySize(e.props,o.shared))}applySize(e,r){let o=e?.width??this.dataPatched.geometry.width,n=e?.height??this.dataPatched.geometry.height;this.uiCanvas.applySize({width:o,height:n}),this.applyGeometryParametersFromFrame(r)}applyFrame(e,r){this.uiCanvas.applyFrame(e),this.applyGeometryParametersFromFrame(r),this.applyMaterialParametersFromFrame({shared:r})}applyGeometryParametersFromFrame(e){let r=this.frame;r&&(Object.assign(this.data,{geometry:Object.assign(this.data.geometry,{cornerRadius:r.cornerRadius,cornerType:0})}),Object.assign(this.dataPatched,{geometry:Object.assign(this.dataPatched.geometry,{cornerRadius:r.cornerRadius,cornerType:0})}),this.localGeometry?.dispose(),this.localGeometry=Go(this.dataPatched.geometry,e,this.data.flatShading,this))}applyMaterialParametersFromFrame(e){let r=this.frame;if(r){let o=r.data.backgroundBlur;Object.assign(this.data.material.layers[0].data.texture,{image:this.uiCanvas.uuid}),Object.assign(this.data.material.layers[1].data,{roughness:o.radius,alpha:o.enabled?1:0}),Object.assign(this.dataPatched.material.layers[0].data.texture,{image:this.uiCanvas.uuid}),Object.assign(this.dataPatched.material.layers[1].data,{roughness:o.radius,alpha:o.enabled?1:0}),this.material.reset?.(this.dataPatched.material,e,!0)}}updateEntity2DByOp(e,r,o,n){this.uiCanvas.updateEntity2DByOp(e,r,o,n),e===this.frameId&&r.type===0&&(r.props.cornerRadius!==void 0?this.applyGeometryParametersFromFrame(n):Ue(r.path,["backgroundBlur"])&&this.applyMaterialParametersFromFrame({shared:n}))}get frame(){return this.uiCanvas.frame}get frameId(){return this.frame?.uuid}removeInteractionGeometry(e){super.removeInteractionGeometry(e),this.applySize({},e)}updateGeometryInteractions(e,r){super.updateGeometryInteractions(e,r),this.applySize({width:e.width,height:e.height},r);let o={...this.data.geometry,...e};this.localGeometry?.dispose(),this.localGeometry=Go(o,r,this.data.flatShading,this)}};var Ve=require("three"),$1=require("three/examples/jsm/misc/GPUComputationRenderer.js");var Qt=require("three"),P1=require("three/examples/jsm/math/MeshSurfaceSampler.js");function O1(i){let t=new Float32Array(i*i*2);for(let e=0;e<i;e++)for(let r=0;r<i;r++){let o=e*i+r;t[o*2+0]=e/(i-1),t[o*2+1]=r/(i-1)}return t}function T1(i){let t=Math.ceil(Math.sqrt(i));return Math.max(t,1)}function C1(i,t){let e=new Qt.Mesh(i.geometry,i.material),r=[],o=[],n=new Qt.Vector3,a=new Qt.Vector3;e.geometry.index!==null&&(e.geometry=e.geometry.toNonIndexed());let s=new P1.MeshSurfaceSampler(e).build();for(let u=0;u<t;u++)s.sample(n,a),r.push(n.x,n.y,n.z),o.push(a.x,a.y,a.z);let l=new Float32Array(r),c=new Float32Array(o);return{positions:l,normals:c}}function rm(i,t){let e=i,r=new Float32Array(4*t*t);for(let n=0;n<t*t;n++)r[4*n]=e[3*n],r[4*n+1]=e[3*n+1],r[4*n+2]=e[3*n+2],r[4*n+3]=0;let o=new Qt.DataTexture(r,t,t,Qt.RGBAFormat,Qt.FloatType);return o.needsUpdate=!0,o}function A1({size:i}){let t=new Float32Array(4*i*i);for(let r=0;r<i*i;r++)t[4*r]=r,t[4*r+1]=0,t[4*r+2]=0,t[4*r+3]=0;let e=new Qt.DataTexture(t,i,i,Qt.RGBAFormat,Qt.FloatType);return e.needsUpdate=!0,e}function M1(i){let t=new Float32Array(4*i*i);for(let r=0;r<i*i;r++)t[4*r]=0,t[4*r+1]=0,t[4*r+2]=0,t[4*r+3]=0;let e=new Qt.DataTexture(t,i,i,Qt.RGBAFormat,Qt.FloatType);return e.needsUpdate=!0,e}var I1=`
2675
2675
  // uniform sampler2D uCurrentPosition; // Pass in the variable from GPGPU
2676
2676
  // uniform sampler2D uCurrentVelocity; // Pass in the variable from GPGPU
2677
2677
  // uniform sampler2D uCurrentEmissionRate; // Pass in the variable from GPGPU
@@ -2740,7 +2740,7 @@ void main() {
2740
2740
  gl_FragColor = mix(vec4(0.0), activeColor, isActive);
2741
2741
 
2742
2742
  }
2743
- `;var I1=`
2743
+ `;var E1=`
2744
2744
 
2745
2745
  vec3 mod289(vec3 x) {
2746
2746
  return x - floor(x * (1.0 / 289.0)) * 289.0;
@@ -2942,7 +2942,7 @@ vec3 fbm_vec3(vec3 p, float frequency, float offset)
2942
2942
  );
2943
2943
  }
2944
2944
 
2945
- `;var E1=`
2945
+ `;var N1=`
2946
2946
  #ifdef USE_COLLIDER
2947
2947
  float restitution = max(uBounce * 2., .01); // Energy Loss
2948
2948
  // SPHERE COLLIDER
@@ -3010,7 +3010,7 @@ vec3 fbm_vec3(vec3 p, float frequency, float offset)
3010
3010
  #endif
3011
3011
  #endif
3012
3012
  // END COLLIDER
3013
- `;var N1=`
3013
+ `;var D1=`
3014
3014
  #ifdef USE_ATTRACTOR
3015
3015
 
3016
3016
  #ifdef USE_SPHERE_COLLIDER
@@ -3084,7 +3084,7 @@ vec3 fbm_vec3(vec3 p, float frequency, float offset)
3084
3084
  velocity *= uForceDamping;
3085
3085
  #endif
3086
3086
  #endif
3087
- `;var D1=`
3087
+ `;var _1=`
3088
3088
  #ifdef USE_VORTEX
3089
3089
  // Box dimensions
3090
3090
  vec3 boxHalfSize = uColliderSize / 2.0;
@@ -3123,7 +3123,7 @@ vec3 fbm_vec3(vec3 p, float frequency, float offset)
3123
3123
  velocity += applyForce( originDirection * uSpeed * (1. - uForceDamping) , mass * .5);
3124
3124
  }
3125
3125
  #endif
3126
- `;var _1=`
3126
+ `;var R1=`
3127
3127
  // uniform sampler2D uCurrentPosition; // Pass in the variable from GPGPU
3128
3128
  // uniform sampler2D uCurrentVelocity; // Pass in the variable from GPGPU
3129
3129
  // uniform sampler2D uCurrentEmissionRate; // Pass in the variable from GPGPU
@@ -3149,7 +3149,7 @@ uniform float uForceDamping;
3149
3149
  uniform float uForceIntensity;
3150
3150
 
3151
3151
 
3152
- `+I1+`
3152
+ `+E1+`
3153
3153
  float rand(vec2 co){
3154
3154
  return fract(sin(dot(co, vec2(12.9898, 78.233))) * 43758.5453);
3155
3155
  }
@@ -3225,11 +3225,11 @@ void main() {
3225
3225
  #endif
3226
3226
 
3227
3227
  // COLLIDER
3228
- ${E1}
3228
+ ${N1}
3229
3229
  // ATTRACTION
3230
- ${N1}
3230
+ ${D1}
3231
3231
  // VORTEX
3232
- ${D1}
3232
+ ${_1}
3233
3233
  }
3234
3234
  // End isActive
3235
3235
 
@@ -3247,7 +3247,7 @@ void main() {
3247
3247
 
3248
3248
  gl_FragColor = vec4(velocity, collisionFlag);
3249
3249
  }
3250
- `;var F1=require("three");var rm=`
3250
+ `;var j1=require("three");var om=`
3251
3251
 
3252
3252
  // Linear Fade In
3253
3253
  float linearFadeIn(float t) {
@@ -3280,7 +3280,7 @@ void main() {
3280
3280
  float constant(float t) {
3281
3281
  return 1.0;
3282
3282
  }
3283
- `;var R1=`
3283
+ `;var L1=`
3284
3284
 
3285
3285
  float rand(vec3 co){
3286
3286
  return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453);
@@ -3295,7 +3295,7 @@ vec3 applyForce(vec3 force, float mass) {
3295
3295
 
3296
3296
  return acceleration;
3297
3297
  }
3298
- `;var L1=`
3298
+ `;var B1=`
3299
3299
  vec3 rgb2xyz (in vec3 rgb) {
3300
3300
  float r = rgb.r;
3301
3301
  float g = rgb.g;
@@ -3386,7 +3386,7 @@ vec3 lab2rgb (in vec3 lab) {
3386
3386
  return(rgb);
3387
3387
  }
3388
3388
 
3389
- `;var B1=`
3389
+ `;var V1=`
3390
3390
  uniform sampler2D uPosition;
3391
3391
  uniform float uSize;
3392
3392
  uniform float uSizeEnd;
@@ -3407,9 +3407,9 @@ vec3 lab2rgb (in vec3 lab) {
3407
3407
  varying vec2 vUv;
3408
3408
  varying vec2 vRef;
3409
3409
 
3410
- ${R1}
3411
- ${rm}
3412
- `,V1=({easeSize:i="linearFadeOut"})=>`
3410
+ ${L1}
3411
+ ${om}
3412
+ `,z1=({easeSize:i="linearFadeOut"})=>`
3413
3413
  vUv = uv;
3414
3414
  vRef = ref;
3415
3415
  // Normalized LifeTime 1 to 0
@@ -3461,7 +3461,7 @@ vec3 lab2rgb (in vec3 lab) {
3461
3461
  mvPosition = modelViewMatrix * instanceMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );
3462
3462
  mvPosition.xy += rotatedPosition;
3463
3463
  gl_Position = projectionMatrix * mvPosition;
3464
- `,z1=`
3464
+ `,G1=`
3465
3465
  uniform vec4 uColor; // start color
3466
3466
  uniform vec4 uColor2; // end color
3467
3467
  uniform sampler2D uTexture; // texture
@@ -3472,10 +3472,10 @@ vec3 lab2rgb (in vec3 lab) {
3472
3472
  float random(vec2 co) {
3473
3473
  return fract(sin(dot(co.xy, vec2(12.9898, 78.233))) * 43758.5453);
3474
3474
  }
3475
- `+rm+`
3476
- ${L1}
3475
+ `+om+`
3476
+ ${B1}
3477
3477
 
3478
- `,G1=({easeOpacity:i="linearFadeOut"})=>`
3478
+ `,F1=({easeOpacity:i="linearFadeOut"})=>`
3479
3479
  // if Particle is dead, hide it
3480
3480
  if (v_LifeLeft <= 0.005 ) {
3481
3481
  discard;
@@ -3496,7 +3496,7 @@ vec3 lab2rgb (in vec3 lab) {
3496
3496
 
3497
3497
  gl_FragColor = vec4(finalColor, finalAlpha);
3498
3498
 
3499
- `;var ap=class extends F1.ShaderMaterial{constructor(e,r){super();this.needsJitter=!0;this.type="ParticleMaterial";this.easeOpacity="linearFadeIn";this.easeSize="linearFadeIn";this.useSizeEnd=!1;this.isColoringRandom=!1;this.init(e,r),this.context=r}reset(){}init(e,r){this.transparent=!0,this.depthTest=!0,this.depthWrite=!1,this.easeOpacity=e.ease,this.easeSize=e.easeSize,this.layers=[],ot.startContext(ot.globalContext),this.lightLayer=new xr(0,"",{...Nt.defaultData("light","phong"),visible:!1},new yi,{},r.shared),ot.endContext(ot.globalContext),this.build()}updateState(e){e.coloring!==void 0&&(this.isColoringRandom=e.coloring==="random"),e.color!==void 0&&(e.color instanceof Array?this.uniforms.uColor.value=e.color:this.uniforms.uColor.value=this.context.shared.color(e.color)),e.color2!==void 0&&(e.color2 instanceof Array?this.uniforms.uColor2.value=e.color2:this.uniforms.uColor2.value=this.context.shared.color(e.color2)),e.size!==void 0&&(this.uniforms.uSize.value=e.size[0],this.uniforms.uSizeEnd.value=e.size[1],e.size[0]!==e.size[1]?this.useSizeEnd=!0:this.useSizeEnd=!1),e.ease!==void 0&&(this.easeOpacity=e.ease,this.build()),e.easeSize!==void 0&&(this.easeSize=e.easeSize,this.build()),this.needsUpdate=!0}onBeforeCompile(e){this.build(),e.defines=this.defines,e.uniforms=this.uniforms,e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader}build(){let e=new ms;return e.needsJitter=this.needsJitter,e.addFragmentParsCode(jb),e.buildShader("vertex",this.fragment),e.buildShader("fragment",this.fragment),e.addFragmentFinalCode(Ub),this.isColoringRandom&&e.define("USE_RANDOM_COLORING"),this.useSizeEnd&&e.define("USE_SIZE_END"),e.addVertexParsCode(B1),e.addFragmentParsCode(z1),e.addVertexFinalCode(V1({easeSize:this.easeSize})),e.addFragmentFinalCode(G1({easeOpacity:this.easeOpacity})),this.vertexShader=e.getCode("vertex"),this.fragmentShader=e.getCode("fragment"),this.defines=e.defines,this.uniforms={...e.uniforms,...this.uniforms},this.extensions=e.extensions,this}get nodeMaterial(){return this}get fragment(){return this.lightLayer.node}getDefines(){return this.defines}nodeMaterialDispose(){this.layers.forEach(e=>e.dispose()),super.dispose()}};var ro=require("three");var j1=require("three"),U1=require("three"),k1=require("three"),Js=class{constructor(t,e,r,o){this.type="SphereEmitterShape";this.targetMesh=void 0;this.size=t,this.type=r,this.textureSize=O1(e);let n=1;this.targetMesh=o?.geometry.type==="BufferGeometry"||o?.type==="Mesh"&&o&&o.geometry.hasAttribute("position")&&o.geometry.hasAttribute("normal")?o:this.getMesh(r,n);let{positions:a,dataTexture:s,dataTextureNormals:l}=this.createPositions(this.textureSize,this.targetMesh??this.getMesh(r,n));this.positionsTexture=s,this.positionsAttribute=a,this.directionsTexture=l}createPositions(t,e){let{positions:r,normals:o}=T1(e,t*t),n=tm(r,t),a=tm(o,t);return{dataTexture:n,positions:r,dataTextureNormals:a}}getMesh(t,e){let r=null;switch(t){case"SphereEmitterShape":{r=new ro.SphereGeometry(e*.5,32,32);break}case"TorusEmitterShape":{r=new U1.TorusGeometry(e*.5,.3,15,40);break}case"ConeEmitterShape":{r=new ro.ConeGeometry(e,e,15);break}case"BoxEmitterShape":{r=new ro.BoxGeometry(e,e,e);break}case"PlaneEmitterShape":{r=new k1.PlaneGeometry(e,e),r.rotateX(-Math.PI/2);break}case"MeshEmitterShape":{r=new ro.SphereGeometry(e,32,32);break}default:{r=new ro.SphereGeometry(e,32,32);break}}return new j1.Mesh(r,new ro.MeshBasicMaterial({color:16711680}))}applyToShader(t,e){this.size=new ro.Vector3().fromArray(e.size.map(r=>typeof r=="number"?r:1)),t.uEmitterSize.value=this.size}dispose(){this.positionsTexture.dispose(),this.directionsTexture.dispose(),this.positionsAttribute=new Float32Array}};function pn(i){let t={...i},e=_a.defaultData;t.forceFieldObjectId&&(t.colliderEntityId=t.forceFieldObjectId);let r={...e.shape,...t.shape},o={...e.renderMaterial,...t.renderMaterial};return{...e,...t,shape:r,renderMaterial:o}}var H1=`
3499
+ `;var sp=class extends j1.ShaderMaterial{constructor(e,r){super();this.needsJitter=!0;this.type="ParticleMaterial";this.easeOpacity="linearFadeIn";this.easeSize="linearFadeIn";this.useSizeEnd=!1;this.isColoringRandom=!1;this.init(e,r),this.context=r}reset(){}init(e,r){this.transparent=!0,this.depthTest=!0,this.depthWrite=!1,this.easeOpacity=e.ease,this.easeSize=e.easeSize,this.layers=[],ot.startContext(ot.globalContext),this.lightLayer=new xr(0,"",{...Nt.defaultData("light","phong"),visible:!1},new yi,{},r.shared),ot.endContext(ot.globalContext),this.build()}updateState(e){e.coloring!==void 0&&(this.isColoringRandom=e.coloring==="random"),e.color!==void 0&&(e.color instanceof Array?this.uniforms.uColor.value=e.color:this.uniforms.uColor.value=this.context.shared.color(e.color)),e.color2!==void 0&&(e.color2 instanceof Array?this.uniforms.uColor2.value=e.color2:this.uniforms.uColor2.value=this.context.shared.color(e.color2)),e.size!==void 0&&(this.uniforms.uSize.value=e.size[0],this.uniforms.uSizeEnd.value=e.size[1],e.size[0]!==e.size[1]?this.useSizeEnd=!0:this.useSizeEnd=!1),e.ease!==void 0&&(this.easeOpacity=e.ease,this.build()),e.easeSize!==void 0&&(this.easeSize=e.easeSize,this.build()),this.needsUpdate=!0}onBeforeCompile(e){this.build(),e.defines=this.defines,e.uniforms=this.uniforms,e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader}build(){let e=new ms;return e.needsJitter=this.needsJitter,e.addFragmentParsCode(Ub),e.buildShader("vertex",this.fragment),e.buildShader("fragment",this.fragment),e.addFragmentFinalCode(kb),this.isColoringRandom&&e.define("USE_RANDOM_COLORING"),this.useSizeEnd&&e.define("USE_SIZE_END"),e.addVertexParsCode(V1),e.addFragmentParsCode(G1),e.addVertexFinalCode(z1({easeSize:this.easeSize})),e.addFragmentFinalCode(F1({easeOpacity:this.easeOpacity})),this.vertexShader=e.getCode("vertex"),this.fragmentShader=e.getCode("fragment"),this.defines=e.defines,this.uniforms={...e.uniforms,...this.uniforms},this.extensions=e.extensions,this}get nodeMaterial(){return this}get fragment(){return this.lightLayer.node}getDefines(){return this.defines}nodeMaterialDispose(){this.layers.forEach(e=>e.dispose()),super.dispose()}};var ro=require("three");var U1=require("three"),k1=require("three"),H1=require("three"),Js=class{constructor(t,e,r,o){this.type="SphereEmitterShape";this.targetMesh=void 0;this.size=t,this.type=r,this.textureSize=T1(e);let n=1;this.targetMesh=o?.geometry.type==="BufferGeometry"||o?.type==="Mesh"&&o&&o.geometry.hasAttribute("position")&&o.geometry.hasAttribute("normal")?o:this.getMesh(r,n);let{positions:a,dataTexture:s,dataTextureNormals:l}=this.createPositions(this.textureSize,this.targetMesh??this.getMesh(r,n));this.positionsTexture=s,this.positionsAttribute=a,this.directionsTexture=l}createPositions(t,e){let{positions:r,normals:o}=C1(e,t*t),n=rm(r,t),a=rm(o,t);return{dataTexture:n,positions:r,dataTextureNormals:a}}getMesh(t,e){let r=null;switch(t){case"SphereEmitterShape":{r=new ro.SphereGeometry(e*.5,32,32);break}case"TorusEmitterShape":{r=new k1.TorusGeometry(e*.5,.3,15,40);break}case"ConeEmitterShape":{r=new ro.ConeGeometry(e,e,15);break}case"BoxEmitterShape":{r=new ro.BoxGeometry(e,e,e);break}case"PlaneEmitterShape":{r=new H1.PlaneGeometry(e,e),r.rotateX(-Math.PI/2);break}case"MeshEmitterShape":{r=new ro.SphereGeometry(e,32,32);break}default:{r=new ro.SphereGeometry(e,32,32);break}}return new U1.Mesh(r,new ro.MeshBasicMaterial({color:16711680}))}applyToShader(t,e){this.size=new ro.Vector3().fromArray(e.size.map(r=>typeof r=="number"?r:1)),t.uEmitterSize.value=this.size}dispose(){this.positionsTexture.dispose(),this.directionsTexture.dispose(),this.positionsAttribute=new Float32Array}};function pn(i){let t={...i},e=_a.defaultData;t.forceFieldObjectId&&(t.colliderEntityId=t.forceFieldObjectId);let r={...e.shape,...t.shape},o={...e.renderMaterial,...t.renderMaterial};return{...e,...t,shape:r,renderMaterial:o}}var W1=`
3500
3500
  // uniform sampler2D uCurrentPosition; // Pass in the variable from GPGPU
3501
3501
  // uniform sampler2D uCurrentVelocity; // Pass in the variable from GPGPU
3502
3502
  // uniform sampler2D uCurrentEmissionRate; // Pass in the variable from GPGPU
@@ -3543,14 +3543,14 @@ void main() {
3543
3543
 
3544
3544
 
3545
3545
  }
3546
- `;var om=10,sp=class extends Ve.Object3D{constructor(e,r){super();this.type="ParticleEmitter";this.debugMode=!1;this.worldSpace=!0;this.rootObject=null;this.gpuCompute=null;this.positionSimRT=null;this.velocitySimRT=null;this.emissionRateSimRT=null;this.emitterShape=void 0;this.isEmitting=!1;this.hasBeenReset=!1;this.emittedParticlesAmount=0;this.lastEmitTime=0;this.globalTime=0;this.targetFPS=60;this.previousRatio=1;this.lerpFactor=.4;this.particlesAmount=0;this.noiseStrength=0;this.noiseScale=0;this.isBillboardBased=!0;this.simFeaturesDefinition={USE_COLLIDER:!1,USE_ATTRACTOR:!1,USE_VORTEX:!1,USE_SPHERE_COLLIDER:!1,USE_BOX_COLLIDER:!1,USE_FORCE_LOCAL_SPACE:!1,USE_NORMALS:!1,USE_CURL_NOISE:!0,USE_SIMPLEX_NOISE:!1,USE_FBM_NOISE:!1};this.textureLoader=new Ve.TextureLoader;this.currentWorldPosition=new Ve.Vector3;this.systemQuaternion=new Ve.Quaternion;this.worldGravity=new Ve.Vector3(0,0,0);this.directionAxis=new Ve.Vector3(0,0,0);this.colliderV3=new Ve.Vector3(0,0,0);this.colliderQuaternion=new Ve.Quaternion(0,0,0,1);this.matrixAutoUpdate=!0,this.renderer=e,this.system=r,this.shared=r.context.shared;let o=r.data;this.material=new ap(o.renderMaterial,r.context),this.material.uniforms={uSize:{value:0},uSizeEnd:{value:0},uColor:{value:o.renderMaterial.color},uColor2:{value:o.renderMaterial.color2},uPosition:{value:new Ve.Vector3(0,0,0)},uEmissionData:{value:new Ve.Vector3(0,0,0)},uTexture:{value:this.defaultTexture},uWorldOffset:{value:new Ve.Vector3(0,0,0)},uWorldQuaternion:{value:new Ve.Vector4(0,0,0,1)},uRandScaleFactor:{value:o.randomScale??0},uRandRotationFactor:{value:o.randomRotation??0},uRotation:{value:o.renderMaterial.spriteRotation[0]??0},uRotationEnd:{value:o.renderMaterial.spriteRotation[1]??0}},this.setTexture(this.material.uniforms,o.renderMaterial.texture),this.init(o)}setTexture(e,r){let o=r.data;if(typeof r=="string"){let n=this.shared.image(r),a=new Ve.Texture(n.img);a.needsUpdate=!0,e.uTexture.value=a;return}if(typeof o!="string"){let n=new Image;n.onload=()=>{let l=new Ve.Texture(n);l.needsUpdate=!0,e.uTexture.value=l};let a=new Blob([o],{type:"image/*"}),s=URL.createObjectURL(a);n.src=s}}updateGeometryAttributes(e,r){let o=P1(r);!this.emitterShape?.positionsAttribute||e.geometry.setAttribute("ref",new Ve.InstancedBufferAttribute(o,2))}applyWorldSpace(){if(!this.system.started||!this.worldSpace||!this.positionSimRT||!this.velocitySimRT)return;let e=this.system;e.getWorldQuaternion(this.systemQuaternion),this.systemQuaternion.invert(),e.getWorldPosition(this.currentWorldPosition),this.material.uniforms.uWorldOffset.value=this.currentWorldPosition,this.material.uniforms.uWorldQuaternion.value.copy(this.systemQuaternion.normalize()),this.positionSimRT.material.uniforms.uWorldOffset.value=this.currentWorldPosition,this.systemQuaternion.invert(),this.positionSimRT.material.uniforms.uWorldQuaternion.value.copy(this.systemQuaternion.normalize()),this.velocitySimRT.material.uniforms.uWorldQuaternion.value.copy(this.systemQuaternion.normalize())}update(e,r){if(!this.gpuCompute||!this.positionSimRT||!this.velocitySimRT||!this.emissionRateSimRT||this.hasBeenReset)return;if(this.checkIfAllParticlesAreDead()&&!this.hasBeenReset){this.reset();return}this.applyWorldSpace(),this.globalTime=e,this.positionSimRT.material.uniforms.uTime.value=e,this.emissionRateSimRT.material.uniforms.uTime.value=e;let o=1e3/r,n=this.targetFPS/o,a=this.previousRatio+(n-this.previousRatio)*this.lerpFactor;this.positionSimRT.material.uniforms.uFPSRatio.value=a,this.previousRatio=a;let s=this.isEmitting?this.GoEmitSomeParticles(e,this.system.data.birthRatePerSec):0;this.emissionRateSimRT.material.uniforms.uLastIndexEmitted.value=this.emittedParticlesAmount,this.emissionRateSimRT.material.uniforms.uParticlesToEmit.value=s,this.material.uniforms.uPosition.value=this.gpuCompute.getCurrentRenderTarget(this.positionSimRT)?.texture,this.system.colliderEntities.length>0&&this.renderColliders(),this.gpuCompute.compute()}renderColliders(){if(!this.velocitySimRT)return;let e=this.system.colliderEntities[0],r=this.simFeaturesDefinition.USE_COLLIDER||this.simFeaturesDefinition.USE_ATTRACTOR||this.simFeaturesDefinition.USE_VORTEX;if(e.destroyedInAction&&r&&this.init(pn({...this.system.data,colliderEntityId:null})),!e||e.destroyedInAction)return;e.getWorldPosition(this.colliderV3),this.colliderV3.y===0&&(this.colliderV3.y=1e-4),this.velocitySimRT.material.uniforms.uColliderPos.value.copy(this.colliderV3);let o=e.data.size;this.colliderV3.fromArray(o),this.velocitySimRT.material.uniforms.uColliderSize.value.copy(this.simFeaturesDefinition.USE_SPHERE_COLLIDER?this.colliderV3.multiplyScalar(.5):this.colliderV3),e.getWorldQuaternion(this.colliderQuaternion),this.velocitySimRT.material.uniforms.uColliderQuaternion.value.copy(this.colliderQuaternion.normalize()),this.velocitySimRT.material.uniforms.uColliderQuaternionInvert.value.copy(this.colliderQuaternion.normalize().invert())}updateState(e){!this.velocitySimRT||!this.positionSimRT||(e.renderMaterial&&this.updateMaterialState(e.renderMaterial),this.updateParticleState(e))}updateVariableState(e,r){if(!this.velocitySimRT||!this.positionSimRT)return;r[2]==="size"&&this.material.updateState({size:[e,this.material.uniforms.uSizeEnd.value]}),r[2]==="sizeEnd"&&this.material.updateState({size:[this.material.uniforms.uSize.value,e]});let o=(n,a)=>{let s=[...this.system.data.shape.size];s[n]=a,this.updateParticleState({shape:{...this.system.data.shape,size:s}})};r[2]==="shape_size_0"&&o(0,e),r[2]==="shape_size_1"&&o(1,e),r[2]==="shape_size_2"&&o(2,e),r[2]==="speed"&&(this.velocitySimRT.material.uniforms.uSpeed.value=e/om),r[2]==="gravity"&&this.worldGravity.set(0,e/100,0),r[2]==="noiseStrength"&&(this.noiseStrength=e,this.velocitySimRT.material.uniforms.uNoiseStrength.value=this.noiseStrength),r[2]==="noiseScale"&&(this.noiseScale=e,this.velocitySimRT.material.uniforms.uNoiseScale.value=this.noiseScale),r[2]==="direction_x"&&(this.directionAxis=this.getDirectionAxis([Number(e),this.system.data.direction[1],this.system.data.direction[2]])),r[2]==="direction_y"&&(this.directionAxis=this.getDirectionAxis([this.system.data.direction[0],Number(e),this.system.data.direction[2]])),r[2]==="direction_z"&&(this.directionAxis=this.getDirectionAxis([this.system.data.direction[0],this.system.data.direction[1],Number(e)]))}updateMaterialState(e){this.material.updateState({...e,size:e.size?[Number(this.shared.getVariable(e.size[0],[this.uuid,"particles","size"])),Number(this.shared.getVariable(e.size[1],[this.uuid,"particles","sizeEnd"]))]:[0,0]}),e.texture&&(this.setTexture(this.material.uniforms,e.texture),this.material.needsUpdate=!0)}updateParticleState(e){if(!(!this.positionSimRT||!this.velocitySimRT)){if(this.shouldReInitGPUCompute(e)&&this.init(pn(this.system.data)),e.life!==void 0&&(this.positionSimRT.material.uniforms.uMaxLifeTime.value=e.life),e.speed!==void 0&&(this.velocitySimRT.material.uniforms.uSpeed.value=Number(this.shared.getVariable(e.speed,[this.uuid,"particles","speed"]))/om),e.collisionBounce!==void 0&&(this.velocitySimRT.material.uniforms.uBounce.value=e.collisionBounce),e.noiseStrength!==void 0&&(this.noiseStrength=Number(this.shared.getVariable(e.noiseStrength,[this.uuid,"particles","noiseStrength"])),this.velocitySimRT.material.uniforms.uNoiseStrength.value=this.noiseStrength),e.noiseScale!==void 0&&(this.noiseScale=Number(this.shared.getVariable(e.noiseScale,[this.uuid,"particles","noiseScale"])),this.velocitySimRT.material.uniforms.uNoiseScale.value=this.noiseScale),e.noiseSeed!==void 0&&(this.velocitySimRT.material.uniforms.uNoiseSeed.value=e.noiseSeed),e.randomMass!==void 0&&(this.velocitySimRT.material.uniforms.uRandomMassFactor.value=e.randomMass),e.renderMaterial?.size!==void 0){let r=this.shared.getVariable(e.renderMaterial.size[0],[this.uuid,"particles","size"]);this.velocitySimRT.material.uniforms.particleSize.value=Number(r)}if(e.renderMaterial?.spriteRotation!==void 0&&(this.material.uniforms.uRotation.value=e.renderMaterial.spriteRotation[0],this.material.uniforms.uRotationEnd.value=e.renderMaterial.spriteRotation[1]),e.shape!==void 0){let r=e.shape.size??this.system.data.shape.size,o=[Number(this.shared.getVariable(r[0],[this.uuid,"particles","shape_size_0"])),Number(this.shared.getVariable(r[1],[this.uuid,"particles","shape_size_1"])),Number(this.shared.getVariable(r[2],[this.uuid,"particles","shape_size_2"]))],n={...pn(this.system.data).shape,size:o};this.emitterShape?.applyToShader(this.positionSimRT.material.uniforms,n)}if(e.gravity!==void 0&&(this.worldGravity.set(0,Number(this.shared.getVariable(this.system.data.gravity,[this.uuid,"particles","gravity"]))/100,0),this.velocitySimRT.material.uniforms.uGravity={value:this.worldGravity}),e.direction!==void 0){let r=this.getDirectionFromVariable(e.direction);this.directionAxis=this.getDirectionAxis(r),this.velocitySimRT.material.uniforms.uDirectionsAxis.value=this.directionAxis}e.randomRotation!==void 0&&(this.material.uniforms.uRandRotationFactor.value=e.randomRotation),e.randomScale!==void 0&&(this.material.uniforms.uRandScaleFactor.value=e.randomScale)}}updateForceFieldParameters(e){!this.velocitySimRT||(e.forceIntensity!==void 0&&(this.velocitySimRT.material.uniforms.uForceIntensity.value=e.forceIntensity),e.forceDambing!==void 0&&(this.velocitySimRT.material.uniforms.uForceDamping.value=e.forceDambing))}getDirectionAxis(e){let r=[Number(e[0])*Ve.MathUtils.DEG2RAD,Number(e[1])*Ve.MathUtils.DEG2RAD,Number(e[2])*Ve.MathUtils.DEG2RAD],o=new Ve.Euler(r[0],r[1],r[2],"XYZ");return this.directionAxis.set(0,1,0).applyEuler(o).normalize(),this.velocitySimRT&&(this.velocitySimRT.material.uniforms.uDirectionsAxis.value=this.directionAxis),this.directionAxis}shouldReInitGPUCompute(e){let{birthRatePerSec:r,rootObjectType:o,colliderEntityId:n,shape:a,emitTimeDuration:s,emitTimeCycle:l,life:c,directionMode:u,noiseType:d}=e;return r!==void 0||o!==void 0||(n||n===null)||l!==void 0||a!==void 0||c!==void 0||s!==void 0||u!==void 0||d!==void 0}init(e){this.dispose(),this.particlesAmount=this.getMaxParticlesAmount({birthRatePerSecond:e.birthRatePerSec,particleMaxLifeTime:e.life,loopDuration:e.emitTimeCycle==="infinity"?0:e.emitTimeDuration}),this.particlesAmount>1e5&&(console.warn(`The maximum number of particles is limited to ${1e5}.`),this.particlesAmount=1e5),this.emitterShape=this.createShape(e.shape,this.particlesAmount);let r=setInterval(()=>{if(!!this.emitterShape)if(isNaN(this.emitterShape.positionsTexture.source.data.data[0])){this.init(e);return}else clearInterval(r)},100);if(!this.emitterShape)return;let o=new q1.GPUComputationRenderer(this.emitterShape.textureSize,this.emitterShape.textureSize,this.renderer),n=this.updateSimulationDefinition(e),a=o.addVariable("uCurrentPosition",n+M1,this.emitterShape.positionsTexture),s=o.addVariable("uCurrentVelocity",n+_1,this.emitterShape.directionsTexture),l=o.addVariable("uCurrentEmissionRate",H1,A1(this.emitterShape.textureSize));o.setVariableDependencies(a,[a,s,l]),o.setVariableDependencies(s,[a,s,l]),o.setVariableDependencies(l,[a,s,l]);let c=C1({size:this.emitterShape.textureSize}),u={uOriginalPosition:{value:this.emitterShape.positionsTexture},uWorldOffset:{value:new Ve.Vector3(0,0,0)},uWorldQuaternion:{value:new Ve.Vector4(0,0,0,1)},uTime:{value:0},uFPSRatio:{value:1},uMaxLifeTime:{value:e.life},uEmitterSize:{value:new Ve.Vector3(Number(this.shared.getVariable(e.shape.size[0],[this.uuid,"particles","shape_size_0"])),Number(this.shared.getVariable(e.shape.size[1],[this.uuid,"particles","shape_size_1"])),Number(this.shared.getVariable(e.shape.size[2],[this.uuid,"particles","shape_size_2"])))},particleSize:{value:0}};a.material.uniforms=u;let d=this.getDirectionFromVariable(e.direction);this.directionAxis=this.getDirectionAxis(d),this.worldGravity.set(0,Number(this.shared.getVariable(this.system.data.gravity,[this.uuid,"particles","gravity"]))/100,0),this.noiseStrength=Number(this.shared.getVariable(e.noiseStrength,[this.uuid,"particles","noiseStrength"])),this.noiseScale=Number(this.shared.getVariable(e.noiseScale,[this.uuid,"particles","noiseScale"]));let p=e.colliderEntityId&&this.system.getColliderData(e.colliderEntityId),f={uOriginalPosition:{value:this.emitterShape.positionsTexture},uDirections:{value:this.emitterShape.directionsTexture},uDirectionsAxis:{value:this.directionAxis},uWorldQuaternion:{value:new Ve.Vector4(0,0,0,1)},uColliderPos:{value:new Ve.Vector3(0,0,0)},uColliderSize:{value:new Ve.Vector3(0,0,0)},uForceIntensity:{value:p?p.forceIntensity:0},uForceDamping:{value:p?p.forceDambing:0},uColliderQuaternion:{value:new Ve.Vector4(0,0,0,1)},uColliderQuaternionInvert:{value:new Ve.Vector4(0,0,0,1)},particleSize:{value:0},uGravity:{value:this.worldGravity},uNoiseStrength:{value:this.noiseStrength},uNoiseScale:{value:this.noiseScale},uNoiseSeed:{value:e.noiseSeed},uRandomMassFactor:{value:e.randomMass},uBounce:{value:e.collisionBounce},uSpeed:{value:Number(this.shared.getVariable(e.speed,[this.uuid,"particles","speed"]))/om}};s.material.uniforms=f;let h={uIndex:{value:c},uTime:{value:0},uLastIndexEmitted:{value:0},uParticlesToEmit:{value:0}};l.material.uniforms=h;let m=[Number(this.shared.getVariable(e.shape.size[0],[this.uuid,"particles","shape_size_0"])),Number(this.shared.getVariable(e.shape.size[1],[this.uuid,"particles","shape_size_1"])),Number(this.shared.getVariable(e.shape.size[2],[this.uuid,"particles","shape_size_2"]))],y={...pn(this.system.data).shape,size:m};this.emitterShape.applyToShader(a.material.uniforms,y),o.init(),this.gpuCompute=o,this.positionSimRT=a,this.velocitySimRT=s,this.emissionRateSimRT=l,this.rootObject=this.createPrimaryEmitter(this.emitterShape.textureSize),this.add(this.rootObject),this.material.needsUpdate=!0}getDirectionFromVariable(e){let r=Number(this.shared.getVariable(e[0],[this.uuid,"particles","direction_x"])),o=Number(this.shared.getVariable(e[1],[this.uuid,"particles","direction_y"])),n=Number(this.shared.getVariable(e[2],[this.uuid,"particles","direction_z"]));return[r,o,n]}updateSimulationDefinition(e){if(this.simFeaturesDefinition.USE_COLLIDER=!1,this.simFeaturesDefinition.USE_ATTRACTOR=!1,this.simFeaturesDefinition.USE_VORTEX=!1,this.simFeaturesDefinition.USE_SPHERE_COLLIDER=!1,this.simFeaturesDefinition.USE_BOX_COLLIDER=!1,this.simFeaturesDefinition.USE_FORCE_LOCAL_SPACE=!1,this.simFeaturesDefinition.USE_NORMALS=!1,this.simFeaturesDefinition.USE_CURL_NOISE=!1,this.simFeaturesDefinition.USE_SIMPLEX_NOISE=!1,this.simFeaturesDefinition.USE_FBM_NOISE=!1,e.colliderEntityId&&this.system.colliderEntities.length>0){let o=this.system.getColliderData(e.colliderEntityId);switch(o?.forceType){case"attractor":this.simFeaturesDefinition.USE_ATTRACTOR=!0;break;case"collider":this.simFeaturesDefinition.USE_COLLIDER=!0;break;case"vortex":this.simFeaturesDefinition.USE_VORTEX=!0;break}let n=o?.colliderType;n==="sphere"&&(this.simFeaturesDefinition.USE_SPHERE_COLLIDER=!0),n==="box"&&(this.simFeaturesDefinition.USE_BOX_COLLIDER=!0),o?.forceRange==="helper"&&(this.simFeaturesDefinition.USE_FORCE_LOCAL_SPACE=!0)}e.directionMode==="normals"&&(this.simFeaturesDefinition.USE_NORMALS=!0),e.noiseType==="curl"&&(this.simFeaturesDefinition.USE_CURL_NOISE=!0),e.noiseType==="simplex"&&(this.simFeaturesDefinition.USE_SIMPLEX_NOISE=!0),e.noiseType==="fbm"&&(this.simFeaturesDefinition.USE_FBM_NOISE=!0);let r="";for(let[o,n]of Object.entries(this.simFeaturesDefinition))n&&(r+=`#define ${o}
3547
- `);return r}createShape(e,r){this.emitterShape&&this.emitterShape.dispose();let o=new Ve.Vector3(Number(this.shared.getVariable(e.size[0],[this.uuid,"particles","shape_size_0"])),Number(this.shared.getVariable(e.size[1],[this.uuid,"particles","shape_size_1"])),Number(this.shared.getVariable(e.size[2],[this.uuid,"particles","shape_size_2"])));if(e.type==="MeshEmitterShape"){let n=null;return this.system.context.scene.traverseEntity(a=>{a.uuid===e.fromMeshId&&(n=a)}),n?new Js(o,r,e.type,n):new Js(o,r,"SphereEmitterShape")}else return new Js(o,r,e.type)}createPrimaryEmitter(e){let r,o=e*e;return r=new Ve.InstancedMesh(new Ve.PlaneGeometry(1,1,1),this.material,o),this.updateGeometryAttributes(r,e),this.material.needsUpdate=!0,r.onBeforeRender=()=>{this.applyWorldSpace()},r}getMaxParticlesAmount({birthRatePerSecond:e,particleMaxLifeTime:r,loopDuration:o=0}){return Math.ceil(e*(r+o))}dispose(){!this.gpuCompute||(this.rootObject?.parent?.remove(this.rootObject),this.gpuCompute.dispose(),this.material.nodeMaterialDispose(),this.emitterShape?.dispose())}GoEmitSomeParticles(e,r){let o=e-this.lastEmitTime,n=1/r;if(o>=n){let a=Math.max(1,Math.floor(o/n));return this.lastEmitTime=e,this.emittedParticlesAmount+a>this.particlesAmount&&(this.emittedParticlesAmount=0),this.emittedParticlesAmount+=a,a}return 0}checkIfAllParticlesAreDead(){return this.lastEmitTime+this.system.data.life+1<this.globalTime}reset(){this.hasBeenReset=!0,this.lastEmitTime=0,this.emittedParticlesAmount=0,this.gpuCompute&&this.init(pn(this.system.data))}startEmitting(e){this.isEmitting=!0,this.hasBeenReset=!1,this.lastEmitTime=e}stopEmitting(){this.isEmitting=!1}};var tl=require("three");var el=class extends Xt{constructor(e,r,o){super(e,r);this.type="ParticleSystem";this.geometry=new tl.BufferGeometry;this.actualTime=0;this.currentLoopTime=0;this.started=!1;this.stopped=!1;this.timeoutId=void 0;this.isFrozen=!1;this.isIdle=!0;this.emitter=null;this.colliderEntities=[];this.renderer=null;this.isPreWarm=!1;this._hasOnAfterRenderBeenCalled=!1;this.onAfterRender=e=>{this._hasOnAfterRenderBeenCalled||(this._hasOnAfterRenderBeenCalled=!0,this.init(e))};this.context=o,this.data={...r,...pn(r)},this.geometry.setAttribute("position",new tl.Float32BufferAttribute([],3)),this.material=new tl.MeshBasicMaterial({colorWrite:!1}),this.frustumCulled=!1}init(e){this.renderer=e,this.emitter=new sp(e,this),this.add(this.emitter),this.updateParticleState(this.data)}update(e){if(!this.isReady||!this.started||this.isFrozen||this.isIdle)return;this.actualTime+=e,this.stopped||(this.currentLoopTime+=e);let r=this.data.emitTimeCycle==="one_time";if((this.data.emitTimeCycle==="loop"||r)&&this.currentLoopTime>this.data.emitTimeDuration*1e3&&(this.stopped||(this.stop(),r||this.start(this.data.emitTimeDelay*1e3))),this.emitter&&this.started){let n=this.actualTime/1e3;this.emitter.update(n,e)}this.scale.set(1,1,1),this.updateMatrix()}isReady(){return!!this.emitter}hasCollider(e){return this.colliderEntities.some(r=>r.identity===e)}getColliderData(e){let r=this.colliderEntities.find(o=>o.identity===e);return r?r.data:null}updateByPatchedOp(e,r,o){super.updateByPatchedOp(e,r,o),Ue(e.path,["renderMaterial"])&&this.updateParticleState({renderMaterial:{...this.data.renderMaterial,...vt.drop(e,1).props}}),Ue(e.path,["shape"])&&this.updateParticleState({shape:{...this.data.shape,...vt.drop(e,1).props}})}updateState(e,r){super.updateState(e,r),this.updateParticleState(e)}updateParticleState(e){if(!!this.emitter){if(e.colliderEntityId!==void 0&&e.colliderEntityId!==null){let r=this.context.scene.find(e.colliderEntityId);this.colliderEntities=r?[r]:[]}e.colliderEntityId===null&&(this.colliderEntities=[]),this.emitter.updateState(e),e.emitTimeCycle&&this.started&&this.start()}}updateFromColliderEntity(e){!this.emitter||(this.emitter.updateForceFieldParameters(e),this.stop(),this.start())}start(e=0){if(this.currentLoopTime=0,e){this.timeoutId=window.setTimeout(()=>{this.start(0)},e);return}this.started=!0,this.stopped=!1,this.isFrozen=!1,this.emitter?.startEmitting(this.actualTime/1e3)}froze(){this.isFrozen=!0}unFroze(){this.isFrozen=!1}stop(){this.stopped=!0,this.currentLoopTime=0,this.emitter?.stopEmitting(),clearTimeout(this.timeoutId)}reset(){this.started=!1,this.stopped=!1,this.emitter?.reset()}wakeUp(){this.isIdle=!1}sleep(){this.isIdle=!0,this.reset()}};function SE(){try{let i=window.location.href;if(i.includes("reducesubdiv=")){let t=i.indexOf("reducesubdiv=")+13;return parseInt(i.slice(t,t+1))}}catch{}}var im=SE();function wE(i,t,e){im!==void 0&&t?.geometry&&"subdivisions"in t.geometry&&(t.geometry.subdivisions??0)>im&&Object.assign(t.geometry,{subdivisions:im});let r;return t.geometry.type==="TextGeometry"?new rn(i,t,e):t.geometry.type==="InputGeometry"?new op(i,t,e):(t.geometry.type==="SubdivGeometry"?r=new $n(i,t,e):t.geometry.type==="PathGeometry"?r=new Qs(i,t,e):t.geometry.type==="VectorGeometry"?r=new rp(i,t,e):t.geometry.type==="BooleanGeometry"?r=new Nr(i,t,e):t.geometry.type==="ShapeBlendGeometry"?r=new fn(i,t,e):t.geometry.type==="UIGeometry"?r=new Qn(i,t,e):r=new ht(i,t,e),r)}function lp(i,t,e){return console.assert(t.type!==void 0),t.type==="Mesh"?wE(i,t,e):t.type==="Empty"?new ln(i,t):t.type==="Particle"?new el(i,t,e):t.type==="ParticleCollider"?new Us(i,t,e):t.type==="Splat"?new ln(i,t):t.type==="Bone"?new np(i,t):t.type==="Page"?new to(i,t,e):t.type==="PointLight"?new tp(i,t,e):t.type==="SpotLight"?new $s(i,t,e):t.type==="DirectionalLight"?new qs(i,t,e):t.type==="Component"||t.type==="Instance"?new Oi(i,t,e):ao.is(t.type)?new Si(i,t):(console.error(t),new ln(i,t))}uo.createEntity=lp;function PE(i,t,e){let r=lp(i.identity,t,e),o=i.children,n=i.attachedPaths,a=i.parent,s=i.component,l=i.instances,c=i.overrideData,u=i.uuid,d=i.stateSelection;i.dispose();for(let p of Object.keys(i))delete i[p];Object.setPrototypeOf(i,Object.getPrototypeOf(r));for(let p of Object.keys(r))i[p]=r[p];i.children=[...i.children,...o],i.attachedPaths=n,i.parent=a,i.component=s,i.instances=l,i.uuid=u,i.overrideData=c,i.updateState(i.data,e),d&&i.changeSelectedState(d,e),i.resetBBoxNeedsUpdate()}uo.changeEntityProptotype=PE;uo.Cloner=nn;function $1(i,t,e,r){i.updateByOp(t,e,r,!1)}var ce=require("three");var ir=require("three"),hn=5,rl=new ir.BufferGeometry;rl.setAttribute("position",new ir.BufferAttribute(new Float32Array([-1,-1,0,3,-1,0,-1,3,0]),3));var Zn=class extends ir.RawShaderMaterial{constructor(t){super({...t,depthTest:!1,depthWrite:!1,glslVersion:ir.GLSL3,vertexShader:`
3546
+ `;var im=10,lp=class extends Ve.Object3D{constructor(e,r){super();this.type="ParticleEmitter";this.debugMode=!1;this.worldSpace=!0;this.rootObject=null;this.gpuCompute=null;this.positionSimRT=null;this.velocitySimRT=null;this.emissionRateSimRT=null;this.emitterShape=void 0;this.isEmitting=!1;this.hasBeenReset=!1;this.emittedParticlesAmount=0;this.lastEmitTime=0;this.globalTime=0;this.targetFPS=60;this.previousRatio=1;this.lerpFactor=.4;this.particlesAmount=0;this.noiseStrength=0;this.noiseScale=0;this.isBillboardBased=!0;this.simFeaturesDefinition={USE_COLLIDER:!1,USE_ATTRACTOR:!1,USE_VORTEX:!1,USE_SPHERE_COLLIDER:!1,USE_BOX_COLLIDER:!1,USE_FORCE_LOCAL_SPACE:!1,USE_NORMALS:!1,USE_CURL_NOISE:!0,USE_SIMPLEX_NOISE:!1,USE_FBM_NOISE:!1};this.textureLoader=new Ve.TextureLoader;this.currentWorldPosition=new Ve.Vector3;this.systemQuaternion=new Ve.Quaternion;this.worldGravity=new Ve.Vector3(0,0,0);this.directionAxis=new Ve.Vector3(0,0,0);this.colliderV3=new Ve.Vector3(0,0,0);this.colliderQuaternion=new Ve.Quaternion(0,0,0,1);this.matrixAutoUpdate=!0,this.renderer=e,this.system=r,this.shared=r.context.shared;let o=r.data;this.material=new sp(o.renderMaterial,r.context),this.material.uniforms={uSize:{value:0},uSizeEnd:{value:0},uColor:{value:o.renderMaterial.color},uColor2:{value:o.renderMaterial.color2},uPosition:{value:new Ve.Vector3(0,0,0)},uEmissionData:{value:new Ve.Vector3(0,0,0)},uTexture:{value:this.defaultTexture},uWorldOffset:{value:new Ve.Vector3(0,0,0)},uWorldQuaternion:{value:new Ve.Vector4(0,0,0,1)},uRandScaleFactor:{value:o.randomScale??0},uRandRotationFactor:{value:o.randomRotation??0},uRotation:{value:o.renderMaterial.spriteRotation[0]??0},uRotationEnd:{value:o.renderMaterial.spriteRotation[1]??0}},this.setTexture(this.material.uniforms,o.renderMaterial.texture),this.init(o)}setTexture(e,r){let o=r.data;if(typeof r=="string"){let n=this.shared.image(r),a=new Ve.Texture(n.img);a.needsUpdate=!0,e.uTexture.value=a;return}if(typeof o!="string"){let n=new Image;n.onload=()=>{let l=new Ve.Texture(n);l.needsUpdate=!0,e.uTexture.value=l};let a=new Blob([o],{type:"image/*"}),s=URL.createObjectURL(a);n.src=s}}updateGeometryAttributes(e,r){let o=O1(r);!this.emitterShape?.positionsAttribute||e.geometry.setAttribute("ref",new Ve.InstancedBufferAttribute(o,2))}applyWorldSpace(){if(!this.system.started||!this.worldSpace||!this.positionSimRT||!this.velocitySimRT)return;let e=this.system;e.getWorldQuaternion(this.systemQuaternion),this.systemQuaternion.invert(),e.getWorldPosition(this.currentWorldPosition),this.material.uniforms.uWorldOffset.value=this.currentWorldPosition,this.material.uniforms.uWorldQuaternion.value.copy(this.systemQuaternion.normalize()),this.positionSimRT.material.uniforms.uWorldOffset.value=this.currentWorldPosition,this.systemQuaternion.invert(),this.positionSimRT.material.uniforms.uWorldQuaternion.value.copy(this.systemQuaternion.normalize()),this.velocitySimRT.material.uniforms.uWorldQuaternion.value.copy(this.systemQuaternion.normalize())}update(e,r){if(!this.gpuCompute||!this.positionSimRT||!this.velocitySimRT||!this.emissionRateSimRT||this.hasBeenReset)return;if(this.checkIfAllParticlesAreDead()&&!this.hasBeenReset){this.reset();return}this.applyWorldSpace(),this.globalTime=e,this.positionSimRT.material.uniforms.uTime.value=e,this.emissionRateSimRT.material.uniforms.uTime.value=e;let o=1e3/r,n=this.targetFPS/o,a=this.previousRatio+(n-this.previousRatio)*this.lerpFactor;this.positionSimRT.material.uniforms.uFPSRatio.value=a,this.previousRatio=a;let s=this.isEmitting?this.GoEmitSomeParticles(e,this.system.data.birthRatePerSec):0;this.emissionRateSimRT.material.uniforms.uLastIndexEmitted.value=this.emittedParticlesAmount,this.emissionRateSimRT.material.uniforms.uParticlesToEmit.value=s,this.material.uniforms.uPosition.value=this.gpuCompute.getCurrentRenderTarget(this.positionSimRT)?.texture,this.system.colliderEntities.length>0&&this.renderColliders(),this.gpuCompute.compute()}renderColliders(){if(!this.velocitySimRT)return;let e=this.system.colliderEntities[0],r=this.simFeaturesDefinition.USE_COLLIDER||this.simFeaturesDefinition.USE_ATTRACTOR||this.simFeaturesDefinition.USE_VORTEX;if(e.destroyedInAction&&r&&this.init(pn({...this.system.data,colliderEntityId:null})),!e||e.destroyedInAction)return;e.getWorldPosition(this.colliderV3),this.colliderV3.y===0&&(this.colliderV3.y=1e-4),this.velocitySimRT.material.uniforms.uColliderPos.value.copy(this.colliderV3);let o=e.data.size;this.colliderV3.fromArray(o),this.velocitySimRT.material.uniforms.uColliderSize.value.copy(this.simFeaturesDefinition.USE_SPHERE_COLLIDER?this.colliderV3.multiplyScalar(.5):this.colliderV3),e.getWorldQuaternion(this.colliderQuaternion),this.velocitySimRT.material.uniforms.uColliderQuaternion.value.copy(this.colliderQuaternion.normalize()),this.velocitySimRT.material.uniforms.uColliderQuaternionInvert.value.copy(this.colliderQuaternion.normalize().invert())}updateState(e){!this.velocitySimRT||!this.positionSimRT||(e.renderMaterial&&this.updateMaterialState(e.renderMaterial),this.updateParticleState(e))}updateVariableState(e,r){if(!this.velocitySimRT||!this.positionSimRT)return;r[2]==="size"&&this.material.updateState({size:[e,this.material.uniforms.uSizeEnd.value]}),r[2]==="sizeEnd"&&this.material.updateState({size:[this.material.uniforms.uSize.value,e]});let o=(n,a)=>{let s=[...this.system.data.shape.size];s[n]=a,this.updateParticleState({shape:{...this.system.data.shape,size:s}})};r[2]==="shape_size_0"&&o(0,e),r[2]==="shape_size_1"&&o(1,e),r[2]==="shape_size_2"&&o(2,e),r[2]==="speed"&&(this.velocitySimRT.material.uniforms.uSpeed.value=e/im),r[2]==="gravity"&&this.worldGravity.set(0,e/100,0),r[2]==="noiseStrength"&&(this.noiseStrength=e,this.velocitySimRT.material.uniforms.uNoiseStrength.value=this.noiseStrength),r[2]==="noiseScale"&&(this.noiseScale=e,this.velocitySimRT.material.uniforms.uNoiseScale.value=this.noiseScale),r[2]==="direction_x"&&(this.directionAxis=this.getDirectionAxis([Number(e),this.system.data.direction[1],this.system.data.direction[2]])),r[2]==="direction_y"&&(this.directionAxis=this.getDirectionAxis([this.system.data.direction[0],Number(e),this.system.data.direction[2]])),r[2]==="direction_z"&&(this.directionAxis=this.getDirectionAxis([this.system.data.direction[0],this.system.data.direction[1],Number(e)]))}updateMaterialState(e){this.material.updateState({...e,size:e.size?[Number(this.shared.getVariable(e.size[0],[this.uuid,"particles","size"])),Number(this.shared.getVariable(e.size[1],[this.uuid,"particles","sizeEnd"]))]:[0,0]}),e.texture&&(this.setTexture(this.material.uniforms,e.texture),this.material.needsUpdate=!0)}updateParticleState(e){if(!(!this.positionSimRT||!this.velocitySimRT)){if(this.shouldReInitGPUCompute(e)&&this.init(pn(this.system.data)),e.life!==void 0&&(this.positionSimRT.material.uniforms.uMaxLifeTime.value=e.life),e.speed!==void 0&&(this.velocitySimRT.material.uniforms.uSpeed.value=Number(this.shared.getVariable(e.speed,[this.uuid,"particles","speed"]))/im),e.collisionBounce!==void 0&&(this.velocitySimRT.material.uniforms.uBounce.value=e.collisionBounce),e.noiseStrength!==void 0&&(this.noiseStrength=Number(this.shared.getVariable(e.noiseStrength,[this.uuid,"particles","noiseStrength"])),this.velocitySimRT.material.uniforms.uNoiseStrength.value=this.noiseStrength),e.noiseScale!==void 0&&(this.noiseScale=Number(this.shared.getVariable(e.noiseScale,[this.uuid,"particles","noiseScale"])),this.velocitySimRT.material.uniforms.uNoiseScale.value=this.noiseScale),e.noiseSeed!==void 0&&(this.velocitySimRT.material.uniforms.uNoiseSeed.value=e.noiseSeed),e.randomMass!==void 0&&(this.velocitySimRT.material.uniforms.uRandomMassFactor.value=e.randomMass),e.renderMaterial?.size!==void 0){let r=this.shared.getVariable(e.renderMaterial.size[0],[this.uuid,"particles","size"]);this.velocitySimRT.material.uniforms.particleSize.value=Number(r)}if(e.renderMaterial?.spriteRotation!==void 0&&(this.material.uniforms.uRotation.value=e.renderMaterial.spriteRotation[0],this.material.uniforms.uRotationEnd.value=e.renderMaterial.spriteRotation[1]),e.shape!==void 0){let r=e.shape.size??this.system.data.shape.size,o=[Number(this.shared.getVariable(r[0],[this.uuid,"particles","shape_size_0"])),Number(this.shared.getVariable(r[1],[this.uuid,"particles","shape_size_1"])),Number(this.shared.getVariable(r[2],[this.uuid,"particles","shape_size_2"]))],n={...pn(this.system.data).shape,size:o};this.emitterShape?.applyToShader(this.positionSimRT.material.uniforms,n)}if(e.gravity!==void 0&&(this.worldGravity.set(0,Number(this.shared.getVariable(this.system.data.gravity,[this.uuid,"particles","gravity"]))/100,0),this.velocitySimRT.material.uniforms.uGravity={value:this.worldGravity}),e.direction!==void 0){let r=this.getDirectionFromVariable(e.direction);this.directionAxis=this.getDirectionAxis(r),this.velocitySimRT.material.uniforms.uDirectionsAxis.value=this.directionAxis}e.randomRotation!==void 0&&(this.material.uniforms.uRandRotationFactor.value=e.randomRotation),e.randomScale!==void 0&&(this.material.uniforms.uRandScaleFactor.value=e.randomScale)}}updateForceFieldParameters(e){!this.velocitySimRT||(e.forceIntensity!==void 0&&(this.velocitySimRT.material.uniforms.uForceIntensity.value=e.forceIntensity),e.forceDambing!==void 0&&(this.velocitySimRT.material.uniforms.uForceDamping.value=e.forceDambing))}getDirectionAxis(e){let r=[Number(e[0])*Ve.MathUtils.DEG2RAD,Number(e[1])*Ve.MathUtils.DEG2RAD,Number(e[2])*Ve.MathUtils.DEG2RAD],o=new Ve.Euler(r[0],r[1],r[2],"XYZ");return this.directionAxis.set(0,1,0).applyEuler(o).normalize(),this.velocitySimRT&&(this.velocitySimRT.material.uniforms.uDirectionsAxis.value=this.directionAxis),this.directionAxis}shouldReInitGPUCompute(e){let{birthRatePerSec:r,rootObjectType:o,colliderEntityId:n,shape:a,emitTimeDuration:s,emitTimeCycle:l,life:c,directionMode:u,noiseType:d}=e;return r!==void 0||o!==void 0||(n||n===null)||l!==void 0||a!==void 0||c!==void 0||s!==void 0||u!==void 0||d!==void 0}init(e){this.dispose(),this.particlesAmount=this.getMaxParticlesAmount({birthRatePerSecond:e.birthRatePerSec,particleMaxLifeTime:e.life,loopDuration:e.emitTimeCycle==="infinity"?0:e.emitTimeDuration}),this.particlesAmount>1e5&&(console.warn(`The maximum number of particles is limited to ${1e5}.`),this.particlesAmount=1e5),this.emitterShape=this.createShape(e.shape,this.particlesAmount);let r=setInterval(()=>{if(!!this.emitterShape)if(isNaN(this.emitterShape.positionsTexture.source.data.data[0])){this.init(e);return}else clearInterval(r)},100);if(!this.emitterShape)return;let o=new $1.GPUComputationRenderer(this.emitterShape.textureSize,this.emitterShape.textureSize,this.renderer),n=this.updateSimulationDefinition(e),a=o.addVariable("uCurrentPosition",n+I1,this.emitterShape.positionsTexture),s=o.addVariable("uCurrentVelocity",n+R1,this.emitterShape.directionsTexture),l=o.addVariable("uCurrentEmissionRate",W1,M1(this.emitterShape.textureSize));o.setVariableDependencies(a,[a,s,l]),o.setVariableDependencies(s,[a,s,l]),o.setVariableDependencies(l,[a,s,l]);let c=A1({size:this.emitterShape.textureSize}),u={uOriginalPosition:{value:this.emitterShape.positionsTexture},uWorldOffset:{value:new Ve.Vector3(0,0,0)},uWorldQuaternion:{value:new Ve.Vector4(0,0,0,1)},uTime:{value:0},uFPSRatio:{value:1},uMaxLifeTime:{value:e.life},uEmitterSize:{value:new Ve.Vector3(Number(this.shared.getVariable(e.shape.size[0],[this.uuid,"particles","shape_size_0"])),Number(this.shared.getVariable(e.shape.size[1],[this.uuid,"particles","shape_size_1"])),Number(this.shared.getVariable(e.shape.size[2],[this.uuid,"particles","shape_size_2"])))},particleSize:{value:0}};a.material.uniforms=u;let d=this.getDirectionFromVariable(e.direction);this.directionAxis=this.getDirectionAxis(d),this.worldGravity.set(0,Number(this.shared.getVariable(this.system.data.gravity,[this.uuid,"particles","gravity"]))/100,0),this.noiseStrength=Number(this.shared.getVariable(e.noiseStrength,[this.uuid,"particles","noiseStrength"])),this.noiseScale=Number(this.shared.getVariable(e.noiseScale,[this.uuid,"particles","noiseScale"]));let p=e.colliderEntityId&&this.system.getColliderData(e.colliderEntityId),f={uOriginalPosition:{value:this.emitterShape.positionsTexture},uDirections:{value:this.emitterShape.directionsTexture},uDirectionsAxis:{value:this.directionAxis},uWorldQuaternion:{value:new Ve.Vector4(0,0,0,1)},uColliderPos:{value:new Ve.Vector3(0,0,0)},uColliderSize:{value:new Ve.Vector3(0,0,0)},uForceIntensity:{value:p?p.forceIntensity:0},uForceDamping:{value:p?p.forceDambing:0},uColliderQuaternion:{value:new Ve.Vector4(0,0,0,1)},uColliderQuaternionInvert:{value:new Ve.Vector4(0,0,0,1)},particleSize:{value:0},uGravity:{value:this.worldGravity},uNoiseStrength:{value:this.noiseStrength},uNoiseScale:{value:this.noiseScale},uNoiseSeed:{value:e.noiseSeed},uRandomMassFactor:{value:e.randomMass},uBounce:{value:e.collisionBounce},uSpeed:{value:Number(this.shared.getVariable(e.speed,[this.uuid,"particles","speed"]))/im}};s.material.uniforms=f;let h={uIndex:{value:c},uTime:{value:0},uLastIndexEmitted:{value:0},uParticlesToEmit:{value:0}};l.material.uniforms=h;let m=[Number(this.shared.getVariable(e.shape.size[0],[this.uuid,"particles","shape_size_0"])),Number(this.shared.getVariable(e.shape.size[1],[this.uuid,"particles","shape_size_1"])),Number(this.shared.getVariable(e.shape.size[2],[this.uuid,"particles","shape_size_2"]))],y={...pn(this.system.data).shape,size:m};this.emitterShape.applyToShader(a.material.uniforms,y),o.init(),this.gpuCompute=o,this.positionSimRT=a,this.velocitySimRT=s,this.emissionRateSimRT=l,this.rootObject=this.createPrimaryEmitter(this.emitterShape.textureSize),this.add(this.rootObject),this.material.needsUpdate=!0}getDirectionFromVariable(e){let r=Number(this.shared.getVariable(e[0],[this.uuid,"particles","direction_x"])),o=Number(this.shared.getVariable(e[1],[this.uuid,"particles","direction_y"])),n=Number(this.shared.getVariable(e[2],[this.uuid,"particles","direction_z"]));return[r,o,n]}updateSimulationDefinition(e){if(this.simFeaturesDefinition.USE_COLLIDER=!1,this.simFeaturesDefinition.USE_ATTRACTOR=!1,this.simFeaturesDefinition.USE_VORTEX=!1,this.simFeaturesDefinition.USE_SPHERE_COLLIDER=!1,this.simFeaturesDefinition.USE_BOX_COLLIDER=!1,this.simFeaturesDefinition.USE_FORCE_LOCAL_SPACE=!1,this.simFeaturesDefinition.USE_NORMALS=!1,this.simFeaturesDefinition.USE_CURL_NOISE=!1,this.simFeaturesDefinition.USE_SIMPLEX_NOISE=!1,this.simFeaturesDefinition.USE_FBM_NOISE=!1,e.colliderEntityId&&this.system.colliderEntities.length>0){let o=this.system.getColliderData(e.colliderEntityId);switch(o?.forceType){case"attractor":this.simFeaturesDefinition.USE_ATTRACTOR=!0;break;case"collider":this.simFeaturesDefinition.USE_COLLIDER=!0;break;case"vortex":this.simFeaturesDefinition.USE_VORTEX=!0;break}let n=o?.colliderType;n==="sphere"&&(this.simFeaturesDefinition.USE_SPHERE_COLLIDER=!0),n==="box"&&(this.simFeaturesDefinition.USE_BOX_COLLIDER=!0),o?.forceRange==="helper"&&(this.simFeaturesDefinition.USE_FORCE_LOCAL_SPACE=!0)}e.directionMode==="normals"&&(this.simFeaturesDefinition.USE_NORMALS=!0),e.noiseType==="curl"&&(this.simFeaturesDefinition.USE_CURL_NOISE=!0),e.noiseType==="simplex"&&(this.simFeaturesDefinition.USE_SIMPLEX_NOISE=!0),e.noiseType==="fbm"&&(this.simFeaturesDefinition.USE_FBM_NOISE=!0);let r="";for(let[o,n]of Object.entries(this.simFeaturesDefinition))n&&(r+=`#define ${o}
3547
+ `);return r}createShape(e,r){this.emitterShape&&this.emitterShape.dispose();let o=new Ve.Vector3(Number(this.shared.getVariable(e.size[0],[this.uuid,"particles","shape_size_0"])),Number(this.shared.getVariable(e.size[1],[this.uuid,"particles","shape_size_1"])),Number(this.shared.getVariable(e.size[2],[this.uuid,"particles","shape_size_2"])));if(e.type==="MeshEmitterShape"){let n=null;return this.system.context.scene.traverseEntity(a=>{a.uuid===e.fromMeshId&&(n=a)}),n?new Js(o,r,e.type,n):new Js(o,r,"SphereEmitterShape")}else return new Js(o,r,e.type)}createPrimaryEmitter(e){let r,o=e*e;return r=new Ve.InstancedMesh(new Ve.PlaneGeometry(1,1,1),this.material,o),this.updateGeometryAttributes(r,e),this.material.needsUpdate=!0,r.onBeforeRender=()=>{this.applyWorldSpace()},r}getMaxParticlesAmount({birthRatePerSecond:e,particleMaxLifeTime:r,loopDuration:o=0}){return Math.ceil(e*(r+o))}dispose(){!this.gpuCompute||(this.rootObject?.parent?.remove(this.rootObject),this.gpuCompute.dispose(),this.material.nodeMaterialDispose(),this.emitterShape?.dispose())}GoEmitSomeParticles(e,r){let o=e-this.lastEmitTime,n=1/r;if(o>=n){let a=Math.max(1,Math.floor(o/n));return this.lastEmitTime=e,this.emittedParticlesAmount+a>this.particlesAmount&&(this.emittedParticlesAmount=0),this.emittedParticlesAmount+=a,a}return 0}checkIfAllParticlesAreDead(){return this.lastEmitTime+this.system.data.life+1<this.globalTime}reset(){this.hasBeenReset=!0,this.lastEmitTime=0,this.emittedParticlesAmount=0,this.gpuCompute&&this.init(pn(this.system.data))}startEmitting(e){this.isEmitting=!0,this.hasBeenReset=!1,this.lastEmitTime=e}stopEmitting(){this.isEmitting=!1}};var tl=require("three");var el=class extends Xt{constructor(e,r,o){super(e,r);this.type="ParticleSystem";this.geometry=new tl.BufferGeometry;this.actualTime=0;this.currentLoopTime=0;this.started=!1;this.stopped=!1;this.timeoutId=void 0;this.isFrozen=!1;this.isIdle=!0;this.emitter=null;this.colliderEntities=[];this.renderer=null;this.isPreWarm=!1;this._hasOnAfterRenderBeenCalled=!1;this.onAfterRender=e=>{this._hasOnAfterRenderBeenCalled||(this._hasOnAfterRenderBeenCalled=!0,this.init(e))};this.context=o,this.data={...r,...pn(r)},this.geometry.setAttribute("position",new tl.Float32BufferAttribute([],3)),this.material=new tl.MeshBasicMaterial({colorWrite:!1}),this.frustumCulled=!1}init(e){this.renderer=e,this.emitter=new lp(e,this),this.add(this.emitter),this.updateParticleState(this.data)}update(e){if(!this.isReady||!this.started||this.isFrozen||this.isIdle)return;this.actualTime+=e,this.stopped||(this.currentLoopTime+=e);let r=this.data.emitTimeCycle==="one_time";if((this.data.emitTimeCycle==="loop"||r)&&this.currentLoopTime>this.data.emitTimeDuration*1e3&&(this.stopped||(this.stop(),r||this.start(this.data.emitTimeDelay*1e3))),this.emitter&&this.started){let n=this.actualTime/1e3;this.emitter.update(n,e)}this.scale.set(1,1,1),this.updateMatrix()}isReady(){return!!this.emitter}hasCollider(e){return this.colliderEntities.some(r=>r.identity===e)}getColliderData(e){let r=this.colliderEntities.find(o=>o.identity===e);return r?r.data:null}updateByPatchedOp(e,r,o){super.updateByPatchedOp(e,r,o),Ue(e.path,["renderMaterial"])&&this.updateParticleState({renderMaterial:{...this.data.renderMaterial,...vt.drop(e,1).props}}),Ue(e.path,["shape"])&&this.updateParticleState({shape:{...this.data.shape,...vt.drop(e,1).props}})}updateState(e,r){super.updateState(e,r),this.updateParticleState(e)}updateParticleState(e){if(!!this.emitter){if(e.colliderEntityId!==void 0&&e.colliderEntityId!==null){let r=this.context.scene.find(e.colliderEntityId);this.colliderEntities=r?[r]:[]}e.colliderEntityId===null&&(this.colliderEntities=[]),this.emitter.updateState(e),e.emitTimeCycle&&this.started&&this.start()}}updateFromColliderEntity(e){!this.emitter||(this.emitter.updateForceFieldParameters(e),this.stop(),this.start())}start(e=0){if(this.currentLoopTime=0,e){this.timeoutId=window.setTimeout(()=>{this.start(0)},e);return}this.started=!0,this.stopped=!1,this.isFrozen=!1,this.emitter?.startEmitting(this.actualTime/1e3)}froze(){this.isFrozen=!0}unFroze(){this.isFrozen=!1}stop(){this.stopped=!0,this.currentLoopTime=0,this.emitter?.stopEmitting(),clearTimeout(this.timeoutId)}reset(){this.started=!1,this.stopped=!1,this.emitter?.reset()}wakeUp(){this.isIdle=!1}sleep(){this.isIdle=!0,this.reset()}};function SE(){try{let i=window.location.href;if(i.includes("reducesubdiv=")){let t=i.indexOf("reducesubdiv=")+13;return parseInt(i.slice(t,t+1))}}catch{}}var nm=SE();function wE(i,t,e){nm!==void 0&&t?.geometry&&"subdivisions"in t.geometry&&(t.geometry.subdivisions??0)>nm&&Object.assign(t.geometry,{subdivisions:nm});let r;return t.geometry.type==="TextGeometry"?new rn(i,t,e):t.geometry.type==="InputGeometry"?new ip(i,t,e):(t.geometry.type==="SubdivGeometry"?r=new $n(i,t,e):t.geometry.type==="PathGeometry"?r=new Qs(i,t,e):t.geometry.type==="VectorGeometry"?r=new op(i,t,e):t.geometry.type==="BooleanGeometry"?r=new Nr(i,t,e):t.geometry.type==="ShapeBlendGeometry"?r=new fn(i,t,e):t.geometry.type==="UIGeometry"?r=new Qn(i,t,e):r=new ht(i,t,e),r)}function cp(i,t,e){return console.assert(t.type!==void 0),t.type==="Mesh"?wE(i,t,e):t.type==="Empty"?new ln(i,t):t.type==="Particle"?new el(i,t,e):t.type==="ParticleCollider"?new Us(i,t,e):t.type==="Splat"?new ln(i,t):t.type==="Bone"?new ap(i,t):t.type==="Page"?new to(i,t,e):t.type==="PointLight"?new rp(i,t,e):t.type==="SpotLight"?new $s(i,t,e):t.type==="DirectionalLight"?new qs(i,t,e):t.type==="Component"||t.type==="Instance"?new Oi(i,t,e):ao.is(t.type)?new Si(i,t):(console.error(t),new ln(i,t))}uo.createEntity=cp;function PE(i,t,e){let r=cp(i.identity,t,e),o=i.children,n=i.attachedPaths,a=i.parent,s=i.component,l=i.instances,c=i.overrideData,u=i.uuid,d=i.stateSelection;i.dispose();for(let p of Object.keys(i))delete i[p];Object.setPrototypeOf(i,Object.getPrototypeOf(r));for(let p of Object.keys(r))i[p]=r[p];i.children=[...i.children,...o],i.attachedPaths=n,i.parent=a,i.component=s,i.instances=l,i.uuid=u,i.overrideData=c,i.updateState(i.data,e),d&&i.changeSelectedState(d,e),i.resetBBoxNeedsUpdate()}uo.changeEntityProptotype=PE;uo.Cloner=nn;function X1(i,t,e,r){i.updateByOp(t,e,r,!1)}var ce=require("three");var ir=require("three"),hn=5,rl=new ir.BufferGeometry;rl.setAttribute("position",new ir.BufferAttribute(new Float32Array([-1,-1,0,3,-1,0,-1,3,0]),3));var Zn=class extends ir.RawShaderMaterial{constructor(t){super({...t,depthTest:!1,depthWrite:!1,glslVersion:ir.GLSL3,vertexShader:`
3548
3548
  precision highp float;
3549
3549
  in vec3 position;
3550
3550
  void main() {
3551
3551
  gl_Position = vec4(position, 1);
3552
3552
  }
3553
- `})}customProgramCacheKey(){return""}};function X1(){return{shapeInput:()=>`
3553
+ `})}customProgramCacheKey(){return""}};function Y1(){return{shapeInput:()=>`
3554
3554
  const float posRowCoord = ${.5/hn}; // vec4: px py pz opType
3555
3555
  const float quatRowCoord = ${1.5/hn}; // vec4: qx qy qz qw
3556
3556
  const float param1RowCoord = ${2.5/hn};// vec4: type param1 param2 param3
@@ -3603,7 +3603,7 @@ void main() {
3603
3603
  a = t;
3604
3604
  return r;
3605
3605
  }
3606
- `,triTable:new Float32Array([-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,8,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,1,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,8,1,1,8,9,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,10,2,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,8,0,10,2,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,10,2,9,9,2,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,8,2,8,10,2,8,9,10,-1,-1,-1,-1,-1,-1,-1,2,11,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,11,0,0,11,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,9,1,11,3,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,11,1,11,9,1,11,8,9,-1,-1,-1,-1,-1,-1,-1,1,10,3,3,10,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,10,0,10,8,0,10,11,8,-1,-1,-1,-1,-1,-1,-1,0,9,3,9,11,3,9,10,11,-1,-1,-1,-1,-1,-1,-1,10,8,9,11,8,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,7,4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,3,4,4,3,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,1,0,7,4,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,1,4,1,7,4,1,3,7,-1,-1,-1,-1,-1,-1,-1,10,2,1,7,4,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7,4,3,4,0,3,10,2,1,-1,-1,-1,-1,-1,-1,-1,10,2,9,2,0,9,7,4,8,-1,-1,-1,-1,-1,-1,-1,9,10,2,7,9,2,3,7,2,4,9,7,-1,-1,-1,-1,7,4,8,2,11,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7,4,11,4,2,11,4,0,2,-1,-1,-1,-1,-1,-1,-1,1,0,9,7,4,8,11,3,2,-1,-1,-1,-1,-1,-1,-1,11,7,4,11,4,9,2,11,9,1,2,9,-1,-1,-1,-1,1,10,3,10,11,3,4,8,7,-1,-1,-1,-1,-1,-1,-1,10,11,1,11,4,1,4,0,1,4,11,7,-1,-1,-1,-1,8,7,4,11,0,9,10,11,9,3,0,11,-1,-1,-1,-1,11,7,4,9,11,4,10,11,9,-1,-1,-1,-1,-1,-1,-1,4,5,9,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,5,9,3,8,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,5,0,0,5,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,5,8,5,3,8,5,1,3,-1,-1,-1,-1,-1,-1,-1,10,2,1,4,5,9,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,0,3,10,2,1,5,9,4,-1,-1,-1,-1,-1,-1,-1,10,2,5,2,4,5,2,0,4,-1,-1,-1,-1,-1,-1,-1,5,10,2,5,2,3,4,5,3,8,4,3,-1,-1,-1,-1,4,5,9,11,3,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,11,0,11,8,0,5,9,4,-1,-1,-1,-1,-1,-1,-1,4,5,0,5,1,0,11,3,2,-1,-1,-1,-1,-1,-1,-1,5,1,2,8,5,2,11,8,2,5,8,4,-1,-1,-1,-1,11,3,10,3,1,10,4,5,9,-1,-1,-1,-1,-1,-1,-1,5,9,4,1,8,0,1,10,8,10,11,8,-1,-1,-1,-1,0,4,5,11,0,5,10,11,5,3,0,11,-1,-1,-1,-1,8,4,5,10,8,5,11,8,10,-1,-1,-1,-1,-1,-1,-1,8,7,9,9,7,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,3,9,3,5,9,3,7,5,-1,-1,-1,-1,-1,-1,-1,8,7,0,7,1,0,7,5,1,-1,-1,-1,-1,-1,-1,-1,3,5,1,7,5,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,7,9,7,5,9,2,1,10,-1,-1,-1,-1,-1,-1,-1,2,1,10,0,5,9,0,3,5,3,7,5,-1,-1,-1,-1,2,0,8,5,2,8,7,5,8,2,5,10,-1,-1,-1,-1,5,10,2,3,5,2,7,5,3,-1,-1,-1,-1,-1,-1,-1,5,9,7,9,8,7,2,11,3,-1,-1,-1,-1,-1,-1,-1,7,5,9,2,7,9,0,2,9,11,7,2,-1,-1,-1,-1,11,3,2,8,1,0,8,7,1,7,5,1,-1,-1,-1,-1,1,2,11,7,1,11,5,1,7,-1,-1,-1,-1,-1,-1,-1,8,5,9,7,5,8,3,1,10,11,3,10,-1,-1,-1,-1,0,7,5,9,0,5,0,11,7,10,0,1,0,10,11,-1,0,10,11,3,0,11,0,5,10,7,0,8,0,7,5,-1,5,10,11,5,11,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,5,6,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,8,0,6,10,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,0,9,6,10,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,8,1,8,9,1,6,10,5,-1,-1,-1,-1,-1,-1,-1,5,6,1,1,6,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,5,6,1,6,2,1,8,0,3,-1,-1,-1,-1,-1,-1,-1,5,6,9,6,0,9,6,2,0,-1,-1,-1,-1,-1,-1,-1,8,9,5,2,8,5,6,2,5,8,2,3,-1,-1,-1,-1,11,3,2,5,6,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,0,11,0,2,11,5,6,10,-1,-1,-1,-1,-1,-1,-1,9,1,0,11,3,2,6,10,5,-1,-1,-1,-1,-1,-1,-1,6,10,5,2,9,1,2,11,9,11,8,9,-1,-1,-1,-1,11,3,6,3,5,6,3,1,5,-1,-1,-1,-1,-1,-1,-1,11,8,0,5,11,0,1,5,0,6,11,5,-1,-1,-1,-1,6,11,3,6,3,0,5,6,0,9,5,0,-1,-1,-1,-1,9,5,6,11,9,6,8,9,11,-1,-1,-1,-1,-1,-1,-1,6,10,5,8,7,4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,3,4,3,7,4,10,5,6,-1,-1,-1,-1,-1,-1,-1,0,9,1,6,10,5,7,4,8,-1,-1,-1,-1,-1,-1,-1,5,6,10,7,9,1,3,7,1,4,9,7,-1,-1,-1,-1,2,1,6,1,5,6,8,7,4,-1,-1,-1,-1,-1,-1,-1,5,2,1,6,2,5,4,0,3,7,4,3,-1,-1,-1,-1,7,4,8,5,0,9,5,6,0,6,2,0,-1,-1,-1,-1,9,3,7,4,9,7,9,2,3,6,9,5,9,6,2,-1,2,11,3,4,8,7,5,6,10,-1,-1,-1,-1,-1,-1,-1,6,10,5,2,7,4,0,2,4,11,7,2,-1,-1,-1,-1,9,1,0,8,7,4,11,3,2,6,10,5,-1,-1,-1,-1,1,2,9,2,11,9,11,4,9,4,11,7,6,10,5,-1,7,4,8,5,11,3,1,5,3,6,11,5,-1,-1,-1,-1,11,1,5,6,11,5,11,0,1,4,11,7,11,4,0,-1,9,5,0,5,6,0,6,3,0,3,6,11,7,4,8,-1,9,5,6,11,9,6,9,7,4,9,11,7,-1,-1,-1,-1,9,4,10,10,4,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,6,10,4,10,9,4,3,8,0,-1,-1,-1,-1,-1,-1,-1,1,0,10,0,6,10,0,4,6,-1,-1,-1,-1,-1,-1,-1,1,3,8,6,1,8,4,6,8,10,1,6,-1,-1,-1,-1,9,4,1,4,2,1,4,6,2,-1,-1,-1,-1,-1,-1,-1,8,0,3,9,2,1,9,4,2,4,6,2,-1,-1,-1,-1,4,2,0,6,2,4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,3,8,4,2,8,6,2,4,-1,-1,-1,-1,-1,-1,-1,9,4,10,4,6,10,3,2,11,-1,-1,-1,-1,-1,-1,-1,2,8,0,11,8,2,10,9,4,6,10,4,-1,-1,-1,-1,2,11,3,6,1,0,4,6,0,10,1,6,-1,-1,-1,-1,1,4,6,10,1,6,1,8,4,11,1,2,1,11,8,-1,4,6,9,6,3,9,3,1,9,3,6,11,-1,-1,-1,-1,1,11,8,0,1,8,1,6,11,4,1,9,1,4,6,-1,6,11,3,0,6,3,4,6,0,-1,-1,-1,-1,-1,-1,-1,8,4,6,8,6,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,6,10,7,10,8,7,10,9,8,-1,-1,-1,-1,-1,-1,-1,3,7,0,7,10,0,10,9,0,10,7,6,-1,-1,-1,-1,7,6,10,7,10,1,8,7,1,0,8,1,-1,-1,-1,-1,7,6,10,1,7,10,3,7,1,-1,-1,-1,-1,-1,-1,-1,6,2,1,8,6,1,9,8,1,7,6,8,-1,-1,-1,-1,9,6,2,1,9,2,9,7,6,3,9,0,9,3,7,-1,0,8,7,6,0,7,2,0,6,-1,-1,-1,-1,-1,-1,-1,2,3,7,2,7,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,11,3,2,8,6,10,9,8,10,7,6,8,-1,-1,-1,-1,7,0,2,11,7,2,7,9,0,10,7,6,7,10,9,-1,0,8,1,8,7,1,7,10,1,10,7,6,11,3,2,-1,1,2,11,7,1,11,1,6,10,1,7,6,-1,-1,-1,-1,6,9,8,7,6,8,6,1,9,3,6,11,6,3,1,-1,1,9,0,7,6,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,8,7,6,0,7,0,11,3,0,6,11,-1,-1,-1,-1,6,11,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,11,6,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,0,3,6,7,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,1,0,6,7,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,1,8,1,3,8,6,7,11,-1,-1,-1,-1,-1,-1,-1,2,1,10,7,11,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,10,2,1,8,0,3,7,11,6,-1,-1,-1,-1,-1,-1,-1,0,9,2,9,10,2,7,11,6,-1,-1,-1,-1,-1,-1,-1,7,11,6,3,10,2,3,8,10,8,9,10,-1,-1,-1,-1,3,2,7,7,2,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,0,7,0,6,7,0,2,6,-1,-1,-1,-1,-1,-1,-1,6,7,2,7,3,2,9,1,0,-1,-1,-1,-1,-1,-1,-1,2,6,1,6,8,1,8,9,1,6,7,8,-1,-1,-1,-1,6,7,10,7,1,10,7,3,1,-1,-1,-1,-1,-1,-1,-1,6,7,10,10,7,1,7,8,1,8,0,1,-1,-1,-1,-1,7,3,0,10,7,0,9,10,0,7,10,6,-1,-1,-1,-1,10,6,7,8,10,7,9,10,8,-1,-1,-1,-1,-1,-1,-1,4,8,6,6,8,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,11,6,3,6,0,3,6,4,0,-1,-1,-1,-1,-1,-1,-1,11,6,8,6,4,8,1,0,9,-1,-1,-1,-1,-1,-1,-1,6,4,9,3,6,9,1,3,9,6,3,11,-1,-1,-1,-1,4,8,6,8,11,6,1,10,2,-1,-1,-1,-1,-1,-1,-1,10,2,1,11,0,3,11,6,0,6,4,0,-1,-1,-1,-1,8,11,4,11,6,4,9,2,0,9,10,2,-1,-1,-1,-1,3,9,10,2,3,10,3,4,9,6,3,11,3,6,4,-1,3,2,8,2,4,8,2,6,4,-1,-1,-1,-1,-1,-1,-1,2,4,0,2,6,4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,9,1,4,3,2,6,4,2,8,3,4,-1,-1,-1,-1,4,9,1,2,4,1,6,4,2,-1,-1,-1,-1,-1,-1,-1,3,1,8,1,6,8,6,4,8,1,10,6,-1,-1,-1,-1,0,1,10,6,0,10,4,0,6,-1,-1,-1,-1,-1,-1,-1,3,6,4,8,3,4,3,10,6,9,3,0,3,9,10,-1,4,9,10,4,10,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,5,9,4,11,6,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,8,0,5,9,4,6,7,11,-1,-1,-1,-1,-1,-1,-1,1,0,5,0,4,5,11,6,7,-1,-1,-1,-1,-1,-1,-1,6,7,11,4,3,8,4,5,3,5,1,3,-1,-1,-1,-1,4,5,9,2,1,10,11,6,7,-1,-1,-1,-1,-1,-1,-1,7,11,6,10,2,1,3,8,0,5,9,4,-1,-1,-1,-1,11,6,7,10,4,5,10,2,4,2,0,4,-1,-1,-1,-1,8,4,3,4,5,3,5,2,3,2,5,10,6,7,11,-1,3,2,7,2,6,7,9,4,5,-1,-1,-1,-1,-1,-1,-1,4,5,9,6,8,0,2,6,0,7,8,6,-1,-1,-1,-1,2,6,3,6,7,3,0,5,1,0,4,5,-1,-1,-1,-1,8,2,6,7,8,6,8,1,2,5,8,4,8,5,1,-1,4,5,9,6,1,10,6,7,1,7,3,1,-1,-1,-1,-1,10,6,1,6,7,1,7,0,1,0,7,8,4,5,9,-1,10,0,4,5,10,4,10,3,0,7,10,6,10,7,3,-1,10,6,7,8,10,7,10,4,5,10,8,4,-1,-1,-1,-1,5,9,6,9,11,6,9,8,11,-1,-1,-1,-1,-1,-1,-1,11,6,3,3,6,0,6,5,0,5,9,0,-1,-1,-1,-1,8,11,0,11,5,0,5,1,0,11,6,5,-1,-1,-1,-1,3,11,6,5,3,6,1,3,5,-1,-1,-1,-1,-1,-1,-1,10,2,1,11,5,9,8,11,9,6,5,11,-1,-1,-1,-1,3,11,0,11,6,0,6,9,0,9,6,5,10,2,1,-1,5,8,11,6,5,11,5,0,8,2,5,10,5,2,0,-1,3,11,6,5,3,6,3,10,2,3,5,10,-1,-1,-1,-1,9,8,5,8,2,5,2,6,5,2,8,3,-1,-1,-1,-1,6,5,9,0,6,9,2,6,0,-1,-1,-1,-1,-1,-1,-1,8,5,1,0,8,1,8,6,5,2,8,3,8,2,6,-1,6,5,1,6,1,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,6,3,1,10,6,1,6,8,3,9,6,5,6,9,8,-1,0,1,10,6,0,10,0,5,9,0,6,5,-1,-1,-1,-1,8,3,0,10,6,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,6,5,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,10,5,11,11,5,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,10,5,11,5,7,11,0,3,8,-1,-1,-1,-1,-1,-1,-1,7,11,5,11,10,5,0,9,1,-1,-1,-1,-1,-1,-1,-1,5,7,10,7,11,10,1,8,9,1,3,8,-1,-1,-1,-1,2,1,11,1,7,11,1,5,7,-1,-1,-1,-1,-1,-1,-1,3,8,0,7,2,1,5,7,1,11,2,7,-1,-1,-1,-1,5,7,9,7,2,9,2,0,9,7,11,2,-1,-1,-1,-1,2,5,7,11,2,7,2,9,5,8,2,3,2,8,9,-1,10,5,2,5,3,2,5,7,3,-1,-1,-1,-1,-1,-1,-1,0,2,8,2,5,8,5,7,8,5,2,10,-1,-1,-1,-1,1,0,9,3,10,5,7,3,5,2,10,3,-1,-1,-1,-1,2,8,9,1,2,9,2,7,8,5,2,10,2,5,7,-1,5,3,1,5,7,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7,8,0,1,7,0,5,7,1,-1,-1,-1,-1,-1,-1,-1,3,0,9,5,3,9,7,3,5,-1,-1,-1,-1,-1,-1,-1,7,8,9,7,9,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,8,5,8,10,5,8,11,10,-1,-1,-1,-1,-1,-1,-1,4,0,5,0,11,5,11,10,5,0,3,11,-1,-1,-1,-1,9,1,0,10,4,8,11,10,8,5,4,10,-1,-1,-1,-1,4,11,10,5,4,10,4,3,11,1,4,9,4,1,3,-1,1,5,2,5,8,2,8,11,2,8,5,4,-1,-1,-1,-1,11,4,0,3,11,0,11,5,4,1,11,2,11,1,5,-1,5,2,0,9,5,0,5,11,2,8,5,4,5,8,11,-1,5,4,9,3,11,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,10,5,2,2,5,3,5,4,3,4,8,3,-1,-1,-1,-1,2,10,5,4,2,5,0,2,4,-1,-1,-1,-1,-1,-1,-1,2,10,3,10,5,3,5,8,3,8,5,4,9,1,0,-1,2,10,5,4,2,5,2,9,1,2,4,9,-1,-1,-1,-1,5,4,8,3,5,8,1,5,3,-1,-1,-1,-1,-1,-1,-1,5,4,0,5,0,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,5,4,8,3,5,8,5,0,9,5,3,0,-1,-1,-1,-1,5,4,9,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7,11,4,11,9,4,11,10,9,-1,-1,-1,-1,-1,-1,-1,3,8,0,7,9,4,7,11,9,11,10,9,-1,-1,-1,-1,11,10,1,4,11,1,0,4,1,11,4,7,-1,-1,-1,-1,4,1,3,8,4,3,4,10,1,11,4,7,4,11,10,-1,7,11,4,4,11,9,11,2,9,2,1,9,-1,-1,-1,-1,4,7,9,7,11,9,11,1,9,1,11,2,3,8,0,-1,4,7,11,2,4,11,0,4,2,-1,-1,-1,-1,-1,-1,-1,4,7,11,2,4,11,4,3,8,4,2,3,-1,-1,-1,-1,10,9,2,9,7,2,7,3,2,9,4,7,-1,-1,-1,-1,7,10,9,4,7,9,7,2,10,0,7,8,7,0,2,-1,10,7,3,2,10,3,10,4,7,0,10,1,10,0,4,-1,2,10,1,4,7,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,9,4,7,1,4,3,1,7,-1,-1,-1,-1,-1,-1,-1,1,9,4,7,1,4,1,8,0,1,7,8,-1,-1,-1,-1,3,0,4,3,4,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7,8,4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,10,9,8,11,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,0,3,11,9,3,10,9,11,-1,-1,-1,-1,-1,-1,-1,10,1,0,8,10,0,11,10,8,-1,-1,-1,-1,-1,-1,-1,10,1,3,10,3,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,11,2,1,9,11,1,8,11,9,-1,-1,-1,-1,-1,-1,-1,9,0,3,11,9,3,9,2,1,9,11,2,-1,-1,-1,-1,11,2,0,11,0,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,11,2,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,3,2,10,8,2,9,8,10,-1,-1,-1,-1,-1,-1,-1,2,10,9,2,9,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,3,2,10,8,2,8,1,0,8,10,1,-1,-1,-1,-1,2,10,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,3,1,8,1,9,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,9,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,3,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]),numTrisTable:new Float32Array([0,1,1,2,1,2,2,3,1,2,2,3,2,3,3,2,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,3,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,3,2,3,3,2,3,4,4,3,3,4,4,3,4,5,5,2,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,3,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,4,2,3,3,4,3,4,2,3,3,4,4,5,4,5,3,2,3,4,4,3,4,5,3,2,4,5,5,4,5,2,4,1,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,3,2,3,3,4,3,4,4,5,3,2,4,3,4,3,5,2,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,4,3,4,4,3,4,5,5,4,4,3,5,2,5,4,2,1,2,3,3,4,3,4,4,5,3,4,4,5,2,3,3,2,3,4,4,5,4,5,5,2,4,3,5,4,3,2,4,1,3,4,4,5,4,5,3,4,4,5,5,2,3,4,2,1,2,3,3,2,3,4,2,1,3,2,4,1,2,1,1,0])}}var vc=new ir.Camera,cp=class{constructor(){this.pyramidPassScene=new ir.Scene;this.pyramidPassMaterial=new Zn({name:"PyramidPass"});this.pyramidPassUniforms={inputTexture:{value:void 0},inputWidth:{value:0},inputHeight:{value:0},inputShiftX:{value:0},outputShiftX:{value:0}};this.pyramidTopLevelReadPixelBuffer=new Float32Array(4);let t=`
3606
+ `,triTable:new Float32Array([-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,8,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,1,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,8,1,1,8,9,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,10,2,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,8,0,10,2,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,10,2,9,9,2,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,8,2,8,10,2,8,9,10,-1,-1,-1,-1,-1,-1,-1,2,11,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,11,0,0,11,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,9,1,11,3,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,11,1,11,9,1,11,8,9,-1,-1,-1,-1,-1,-1,-1,1,10,3,3,10,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,10,0,10,8,0,10,11,8,-1,-1,-1,-1,-1,-1,-1,0,9,3,9,11,3,9,10,11,-1,-1,-1,-1,-1,-1,-1,10,8,9,11,8,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,7,4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,3,4,4,3,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,1,0,7,4,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,1,4,1,7,4,1,3,7,-1,-1,-1,-1,-1,-1,-1,10,2,1,7,4,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7,4,3,4,0,3,10,2,1,-1,-1,-1,-1,-1,-1,-1,10,2,9,2,0,9,7,4,8,-1,-1,-1,-1,-1,-1,-1,9,10,2,7,9,2,3,7,2,4,9,7,-1,-1,-1,-1,7,4,8,2,11,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7,4,11,4,2,11,4,0,2,-1,-1,-1,-1,-1,-1,-1,1,0,9,7,4,8,11,3,2,-1,-1,-1,-1,-1,-1,-1,11,7,4,11,4,9,2,11,9,1,2,9,-1,-1,-1,-1,1,10,3,10,11,3,4,8,7,-1,-1,-1,-1,-1,-1,-1,10,11,1,11,4,1,4,0,1,4,11,7,-1,-1,-1,-1,8,7,4,11,0,9,10,11,9,3,0,11,-1,-1,-1,-1,11,7,4,9,11,4,10,11,9,-1,-1,-1,-1,-1,-1,-1,4,5,9,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,5,9,3,8,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,5,0,0,5,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,5,8,5,3,8,5,1,3,-1,-1,-1,-1,-1,-1,-1,10,2,1,4,5,9,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,0,3,10,2,1,5,9,4,-1,-1,-1,-1,-1,-1,-1,10,2,5,2,4,5,2,0,4,-1,-1,-1,-1,-1,-1,-1,5,10,2,5,2,3,4,5,3,8,4,3,-1,-1,-1,-1,4,5,9,11,3,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,11,0,11,8,0,5,9,4,-1,-1,-1,-1,-1,-1,-1,4,5,0,5,1,0,11,3,2,-1,-1,-1,-1,-1,-1,-1,5,1,2,8,5,2,11,8,2,5,8,4,-1,-1,-1,-1,11,3,10,3,1,10,4,5,9,-1,-1,-1,-1,-1,-1,-1,5,9,4,1,8,0,1,10,8,10,11,8,-1,-1,-1,-1,0,4,5,11,0,5,10,11,5,3,0,11,-1,-1,-1,-1,8,4,5,10,8,5,11,8,10,-1,-1,-1,-1,-1,-1,-1,8,7,9,9,7,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,3,9,3,5,9,3,7,5,-1,-1,-1,-1,-1,-1,-1,8,7,0,7,1,0,7,5,1,-1,-1,-1,-1,-1,-1,-1,3,5,1,7,5,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,7,9,7,5,9,2,1,10,-1,-1,-1,-1,-1,-1,-1,2,1,10,0,5,9,0,3,5,3,7,5,-1,-1,-1,-1,2,0,8,5,2,8,7,5,8,2,5,10,-1,-1,-1,-1,5,10,2,3,5,2,7,5,3,-1,-1,-1,-1,-1,-1,-1,5,9,7,9,8,7,2,11,3,-1,-1,-1,-1,-1,-1,-1,7,5,9,2,7,9,0,2,9,11,7,2,-1,-1,-1,-1,11,3,2,8,1,0,8,7,1,7,5,1,-1,-1,-1,-1,1,2,11,7,1,11,5,1,7,-1,-1,-1,-1,-1,-1,-1,8,5,9,7,5,8,3,1,10,11,3,10,-1,-1,-1,-1,0,7,5,9,0,5,0,11,7,10,0,1,0,10,11,-1,0,10,11,3,0,11,0,5,10,7,0,8,0,7,5,-1,5,10,11,5,11,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,5,6,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,8,0,6,10,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,0,9,6,10,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,8,1,8,9,1,6,10,5,-1,-1,-1,-1,-1,-1,-1,5,6,1,1,6,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,5,6,1,6,2,1,8,0,3,-1,-1,-1,-1,-1,-1,-1,5,6,9,6,0,9,6,2,0,-1,-1,-1,-1,-1,-1,-1,8,9,5,2,8,5,6,2,5,8,2,3,-1,-1,-1,-1,11,3,2,5,6,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,0,11,0,2,11,5,6,10,-1,-1,-1,-1,-1,-1,-1,9,1,0,11,3,2,6,10,5,-1,-1,-1,-1,-1,-1,-1,6,10,5,2,9,1,2,11,9,11,8,9,-1,-1,-1,-1,11,3,6,3,5,6,3,1,5,-1,-1,-1,-1,-1,-1,-1,11,8,0,5,11,0,1,5,0,6,11,5,-1,-1,-1,-1,6,11,3,6,3,0,5,6,0,9,5,0,-1,-1,-1,-1,9,5,6,11,9,6,8,9,11,-1,-1,-1,-1,-1,-1,-1,6,10,5,8,7,4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,3,4,3,7,4,10,5,6,-1,-1,-1,-1,-1,-1,-1,0,9,1,6,10,5,7,4,8,-1,-1,-1,-1,-1,-1,-1,5,6,10,7,9,1,3,7,1,4,9,7,-1,-1,-1,-1,2,1,6,1,5,6,8,7,4,-1,-1,-1,-1,-1,-1,-1,5,2,1,6,2,5,4,0,3,7,4,3,-1,-1,-1,-1,7,4,8,5,0,9,5,6,0,6,2,0,-1,-1,-1,-1,9,3,7,4,9,7,9,2,3,6,9,5,9,6,2,-1,2,11,3,4,8,7,5,6,10,-1,-1,-1,-1,-1,-1,-1,6,10,5,2,7,4,0,2,4,11,7,2,-1,-1,-1,-1,9,1,0,8,7,4,11,3,2,6,10,5,-1,-1,-1,-1,1,2,9,2,11,9,11,4,9,4,11,7,6,10,5,-1,7,4,8,5,11,3,1,5,3,6,11,5,-1,-1,-1,-1,11,1,5,6,11,5,11,0,1,4,11,7,11,4,0,-1,9,5,0,5,6,0,6,3,0,3,6,11,7,4,8,-1,9,5,6,11,9,6,9,7,4,9,11,7,-1,-1,-1,-1,9,4,10,10,4,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,6,10,4,10,9,4,3,8,0,-1,-1,-1,-1,-1,-1,-1,1,0,10,0,6,10,0,4,6,-1,-1,-1,-1,-1,-1,-1,1,3,8,6,1,8,4,6,8,10,1,6,-1,-1,-1,-1,9,4,1,4,2,1,4,6,2,-1,-1,-1,-1,-1,-1,-1,8,0,3,9,2,1,9,4,2,4,6,2,-1,-1,-1,-1,4,2,0,6,2,4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,3,8,4,2,8,6,2,4,-1,-1,-1,-1,-1,-1,-1,9,4,10,4,6,10,3,2,11,-1,-1,-1,-1,-1,-1,-1,2,8,0,11,8,2,10,9,4,6,10,4,-1,-1,-1,-1,2,11,3,6,1,0,4,6,0,10,1,6,-1,-1,-1,-1,1,4,6,10,1,6,1,8,4,11,1,2,1,11,8,-1,4,6,9,6,3,9,3,1,9,3,6,11,-1,-1,-1,-1,1,11,8,0,1,8,1,6,11,4,1,9,1,4,6,-1,6,11,3,0,6,3,4,6,0,-1,-1,-1,-1,-1,-1,-1,8,4,6,8,6,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,6,10,7,10,8,7,10,9,8,-1,-1,-1,-1,-1,-1,-1,3,7,0,7,10,0,10,9,0,10,7,6,-1,-1,-1,-1,7,6,10,7,10,1,8,7,1,0,8,1,-1,-1,-1,-1,7,6,10,1,7,10,3,7,1,-1,-1,-1,-1,-1,-1,-1,6,2,1,8,6,1,9,8,1,7,6,8,-1,-1,-1,-1,9,6,2,1,9,2,9,7,6,3,9,0,9,3,7,-1,0,8,7,6,0,7,2,0,6,-1,-1,-1,-1,-1,-1,-1,2,3,7,2,7,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,11,3,2,8,6,10,9,8,10,7,6,8,-1,-1,-1,-1,7,0,2,11,7,2,7,9,0,10,7,6,7,10,9,-1,0,8,1,8,7,1,7,10,1,10,7,6,11,3,2,-1,1,2,11,7,1,11,1,6,10,1,7,6,-1,-1,-1,-1,6,9,8,7,6,8,6,1,9,3,6,11,6,3,1,-1,1,9,0,7,6,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,8,7,6,0,7,0,11,3,0,6,11,-1,-1,-1,-1,6,11,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,11,6,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,0,3,6,7,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,1,0,6,7,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,1,8,1,3,8,6,7,11,-1,-1,-1,-1,-1,-1,-1,2,1,10,7,11,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,10,2,1,8,0,3,7,11,6,-1,-1,-1,-1,-1,-1,-1,0,9,2,9,10,2,7,11,6,-1,-1,-1,-1,-1,-1,-1,7,11,6,3,10,2,3,8,10,8,9,10,-1,-1,-1,-1,3,2,7,7,2,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,0,7,0,6,7,0,2,6,-1,-1,-1,-1,-1,-1,-1,6,7,2,7,3,2,9,1,0,-1,-1,-1,-1,-1,-1,-1,2,6,1,6,8,1,8,9,1,6,7,8,-1,-1,-1,-1,6,7,10,7,1,10,7,3,1,-1,-1,-1,-1,-1,-1,-1,6,7,10,10,7,1,7,8,1,8,0,1,-1,-1,-1,-1,7,3,0,10,7,0,9,10,0,7,10,6,-1,-1,-1,-1,10,6,7,8,10,7,9,10,8,-1,-1,-1,-1,-1,-1,-1,4,8,6,6,8,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,11,6,3,6,0,3,6,4,0,-1,-1,-1,-1,-1,-1,-1,11,6,8,6,4,8,1,0,9,-1,-1,-1,-1,-1,-1,-1,6,4,9,3,6,9,1,3,9,6,3,11,-1,-1,-1,-1,4,8,6,8,11,6,1,10,2,-1,-1,-1,-1,-1,-1,-1,10,2,1,11,0,3,11,6,0,6,4,0,-1,-1,-1,-1,8,11,4,11,6,4,9,2,0,9,10,2,-1,-1,-1,-1,3,9,10,2,3,10,3,4,9,6,3,11,3,6,4,-1,3,2,8,2,4,8,2,6,4,-1,-1,-1,-1,-1,-1,-1,2,4,0,2,6,4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,9,1,4,3,2,6,4,2,8,3,4,-1,-1,-1,-1,4,9,1,2,4,1,6,4,2,-1,-1,-1,-1,-1,-1,-1,3,1,8,1,6,8,6,4,8,1,10,6,-1,-1,-1,-1,0,1,10,6,0,10,4,0,6,-1,-1,-1,-1,-1,-1,-1,3,6,4,8,3,4,3,10,6,9,3,0,3,9,10,-1,4,9,10,4,10,6,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,5,9,4,11,6,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,8,0,5,9,4,6,7,11,-1,-1,-1,-1,-1,-1,-1,1,0,5,0,4,5,11,6,7,-1,-1,-1,-1,-1,-1,-1,6,7,11,4,3,8,4,5,3,5,1,3,-1,-1,-1,-1,4,5,9,2,1,10,11,6,7,-1,-1,-1,-1,-1,-1,-1,7,11,6,10,2,1,3,8,0,5,9,4,-1,-1,-1,-1,11,6,7,10,4,5,10,2,4,2,0,4,-1,-1,-1,-1,8,4,3,4,5,3,5,2,3,2,5,10,6,7,11,-1,3,2,7,2,6,7,9,4,5,-1,-1,-1,-1,-1,-1,-1,4,5,9,6,8,0,2,6,0,7,8,6,-1,-1,-1,-1,2,6,3,6,7,3,0,5,1,0,4,5,-1,-1,-1,-1,8,2,6,7,8,6,8,1,2,5,8,4,8,5,1,-1,4,5,9,6,1,10,6,7,1,7,3,1,-1,-1,-1,-1,10,6,1,6,7,1,7,0,1,0,7,8,4,5,9,-1,10,0,4,5,10,4,10,3,0,7,10,6,10,7,3,-1,10,6,7,8,10,7,10,4,5,10,8,4,-1,-1,-1,-1,5,9,6,9,11,6,9,8,11,-1,-1,-1,-1,-1,-1,-1,11,6,3,3,6,0,6,5,0,5,9,0,-1,-1,-1,-1,8,11,0,11,5,0,5,1,0,11,6,5,-1,-1,-1,-1,3,11,6,5,3,6,1,3,5,-1,-1,-1,-1,-1,-1,-1,10,2,1,11,5,9,8,11,9,6,5,11,-1,-1,-1,-1,3,11,0,11,6,0,6,9,0,9,6,5,10,2,1,-1,5,8,11,6,5,11,5,0,8,2,5,10,5,2,0,-1,3,11,6,5,3,6,3,10,2,3,5,10,-1,-1,-1,-1,9,8,5,8,2,5,2,6,5,2,8,3,-1,-1,-1,-1,6,5,9,0,6,9,2,6,0,-1,-1,-1,-1,-1,-1,-1,8,5,1,0,8,1,8,6,5,2,8,3,8,2,6,-1,6,5,1,6,1,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,6,3,1,10,6,1,6,8,3,9,6,5,6,9,8,-1,0,1,10,6,0,10,0,5,9,0,6,5,-1,-1,-1,-1,8,3,0,10,6,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,6,5,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,10,5,11,11,5,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,10,5,11,5,7,11,0,3,8,-1,-1,-1,-1,-1,-1,-1,7,11,5,11,10,5,0,9,1,-1,-1,-1,-1,-1,-1,-1,5,7,10,7,11,10,1,8,9,1,3,8,-1,-1,-1,-1,2,1,11,1,7,11,1,5,7,-1,-1,-1,-1,-1,-1,-1,3,8,0,7,2,1,5,7,1,11,2,7,-1,-1,-1,-1,5,7,9,7,2,9,2,0,9,7,11,2,-1,-1,-1,-1,2,5,7,11,2,7,2,9,5,8,2,3,2,8,9,-1,10,5,2,5,3,2,5,7,3,-1,-1,-1,-1,-1,-1,-1,0,2,8,2,5,8,5,7,8,5,2,10,-1,-1,-1,-1,1,0,9,3,10,5,7,3,5,2,10,3,-1,-1,-1,-1,2,8,9,1,2,9,2,7,8,5,2,10,2,5,7,-1,5,3,1,5,7,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7,8,0,1,7,0,5,7,1,-1,-1,-1,-1,-1,-1,-1,3,0,9,5,3,9,7,3,5,-1,-1,-1,-1,-1,-1,-1,7,8,9,7,9,5,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,8,5,8,10,5,8,11,10,-1,-1,-1,-1,-1,-1,-1,4,0,5,0,11,5,11,10,5,0,3,11,-1,-1,-1,-1,9,1,0,10,4,8,11,10,8,5,4,10,-1,-1,-1,-1,4,11,10,5,4,10,4,3,11,1,4,9,4,1,3,-1,1,5,2,5,8,2,8,11,2,8,5,4,-1,-1,-1,-1,11,4,0,3,11,0,11,5,4,1,11,2,11,1,5,-1,5,2,0,9,5,0,5,11,2,8,5,4,5,8,11,-1,5,4,9,3,11,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,10,5,2,2,5,3,5,4,3,4,8,3,-1,-1,-1,-1,2,10,5,4,2,5,0,2,4,-1,-1,-1,-1,-1,-1,-1,2,10,3,10,5,3,5,8,3,8,5,4,9,1,0,-1,2,10,5,4,2,5,2,9,1,2,4,9,-1,-1,-1,-1,5,4,8,3,5,8,1,5,3,-1,-1,-1,-1,-1,-1,-1,5,4,0,5,0,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,5,4,8,3,5,8,5,0,9,5,3,0,-1,-1,-1,-1,5,4,9,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7,11,4,11,9,4,11,10,9,-1,-1,-1,-1,-1,-1,-1,3,8,0,7,9,4,7,11,9,11,10,9,-1,-1,-1,-1,11,10,1,4,11,1,0,4,1,11,4,7,-1,-1,-1,-1,4,1,3,8,4,3,4,10,1,11,4,7,4,11,10,-1,7,11,4,4,11,9,11,2,9,2,1,9,-1,-1,-1,-1,4,7,9,7,11,9,11,1,9,1,11,2,3,8,0,-1,4,7,11,2,4,11,0,4,2,-1,-1,-1,-1,-1,-1,-1,4,7,11,2,4,11,4,3,8,4,2,3,-1,-1,-1,-1,10,9,2,9,7,2,7,3,2,9,4,7,-1,-1,-1,-1,7,10,9,4,7,9,7,2,10,0,7,8,7,0,2,-1,10,7,3,2,10,3,10,4,7,0,10,1,10,0,4,-1,2,10,1,4,7,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,9,4,7,1,4,3,1,7,-1,-1,-1,-1,-1,-1,-1,1,9,4,7,1,4,1,8,0,1,7,8,-1,-1,-1,-1,3,0,4,3,4,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,7,8,4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,10,9,8,11,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,0,3,11,9,3,10,9,11,-1,-1,-1,-1,-1,-1,-1,10,1,0,8,10,0,11,10,8,-1,-1,-1,-1,-1,-1,-1,10,1,3,10,3,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,11,2,1,9,11,1,8,11,9,-1,-1,-1,-1,-1,-1,-1,9,0,3,11,9,3,9,2,1,9,11,2,-1,-1,-1,-1,11,2,0,11,0,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,11,2,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,3,2,10,8,2,9,8,10,-1,-1,-1,-1,-1,-1,-1,2,10,9,2,9,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,3,2,10,8,2,8,1,0,8,10,1,-1,-1,-1,-1,2,10,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,3,1,8,1,9,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,9,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,3,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]),numTrisTable:new Float32Array([0,1,1,2,1,2,2,3,1,2,2,3,2,3,3,2,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,3,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,3,2,3,3,2,3,4,4,3,3,4,4,3,4,5,5,2,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,3,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,4,2,3,3,4,3,4,2,3,3,4,4,5,4,5,3,2,3,4,4,3,4,5,3,2,4,5,5,4,5,2,4,1,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,3,2,3,3,4,3,4,4,5,3,2,4,3,4,3,5,2,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,4,3,4,4,3,4,5,5,4,4,3,5,2,5,4,2,1,2,3,3,4,3,4,4,5,3,4,4,5,2,3,3,2,3,4,4,5,4,5,5,2,4,3,5,4,3,2,4,1,3,4,4,5,4,5,3,4,4,5,5,2,3,4,2,1,2,3,3,2,3,4,2,1,3,2,4,1,2,1,1,0])}}var vc=new ir.Camera,up=class{constructor(){this.pyramidPassScene=new ir.Scene;this.pyramidPassMaterial=new Zn({name:"PyramidPass"});this.pyramidPassUniforms={inputTexture:{value:void 0},inputWidth:{value:0},inputHeight:{value:0},inputShiftX:{value:0},outputShiftX:{value:0}};this.pyramidTopLevelReadPixelBuffer=new Float32Array(4);let t=`
3607
3607
  precision highp float;
3608
3608
  precision highp sampler2D;
3609
3609
  layout(location = 0) out vec4 pc_FragColor;
@@ -3643,7 +3643,7 @@ void main() {
3643
3643
  pc_FragColor.g = pc_FragColor.b + tr;
3644
3644
  pc_FragColor.r = pc_FragColor.g + tl;
3645
3645
  }
3646
- `;this.pyramidPassMaterial.fragmentShader=t,this.pyramidPassMaterial.uniforms=this.pyramidPassUniforms,this.pyramidPassMaterial.depthTest=!1,this.pyramidPassMaterial.depthWrite=!1;let e=new ir.Mesh(rl,this.pyramidPassMaterial);e.frustumCulled=!1,this.pyramidPassScene.add(e)}renderPyramid(t,e,r,o,n){new ir.Box2().min.setScalar(0);let s=e.length-1,l=new ir.Vector4;r.getViewport(l),this.pyramidPassUniforms.inputShiftX.value=0,this.pyramidPassUniforms.outputShiftX.value=0;let c=s-1;for(let d=c;d>=0;d--){let p=d%2===c%2?n[0]:n[1],f=d===c?o:d%2===c%2?n[1]:n[0];this.pyramidPassUniforms.inputTexture.value=Array.isArray(f.texture)?f.texture[1]:f.texture,this.pyramidPassUniforms.inputWidth.value="width"in f?f.width:1,this.pyramidPassUniforms.inputHeight.value="height"in f?f.height:1,r.setRenderTarget(p);let h=e[d],m=r.getPixelRatio();r.setViewport(this.pyramidPassUniforms.outputShiftX.value/m,0,h/m,h/m),d===2&&t%2!==0&&r.setViewport(this.pyramidPassUniforms.outputShiftX.value/m,0,3/m,3/m),r.render(this.pyramidPassScene,vc);let y=this.pyramidPassUniforms.inputShiftX.value;this.pyramidPassUniforms.inputShiftX.value=this.pyramidPassUniforms.outputShiftX.value,this.pyramidPassUniforms.outputShiftX.value=y,d<c&&(this.pyramidPassUniforms.outputShiftX.value+=e[d+1])}r.setViewport(l);let u=e.length%2===0?0:1;return r.readRenderTargetPixelsAsync(n[u],n[u].width-1,0,1,1,this.pyramidTopLevelReadPixelBuffer).then(()=>this.pyramidTopLevelReadPixelBuffer[0])}};var Po=24,dr=96,Yo=X1(),Ti=2,nm=class extends ht{constructor(e,r,o){super(e,r,o);this.data=r;this.needsRebuild=!0;this.customDepthMaterialNeedsUpdate=!1;this._npart=-1;this.spatialn=1;this.drawRangeNeedsForceUpdate=!0;this._resolutionLevel=-1;this.resolution=64;this.spatialDivisions=25;this.zLayersPerRow=8;this.basePyramidSize=512;this.pyramidTexture1Width=341;this.pyramidTexture1Height=256;this.pyramidTexture2Width=170;this.pyramidTexture2Height=128;this.numLevels=9;this.pyramidLevelSizes=[1,2,4,8,16,32,64,128,256,512];this.bboxSize=0;this.bboxOffset=0;this.shapesDataTexture={value:void 0};this.spatialscene=new ce.Scene;this.potentialPassScene=new ce.Scene;this.voxelPassScene=new ce.Scene;this._spatialPassRenderTargets=[];this._potentialPassRenderTargets=[];this._voxelPassRenderTargets=[];this._pyramidRenderTargets=[];this.geometry=new ce.BufferGeometry,this.geometry.drawRange.count=0,this.spatialPassUniforms={span:{value:-1},shapesDataTexture:this.shapesDataTexture,npart:{value:this.npart},spatialn:{value:this.spatialn}},this.spatialMesh=new ce.Mesh(rl,this.spatialPassMaterial()),this.spatialMesh.frustumCulled=!1,this.spatialscene.add(this.spatialMesh);let n=new ce.DataTexture(Yo.triTable,16,256,ce.RedFormat,ce.FloatType);n.needsUpdate=!0;let a=new ce.DataTexture(Yo.numTrisTable,256,1,ce.RedFormat,ce.FloatType);a.needsUpdate=!0,this.voxelPassUniforms={potentialPassTexture:{value:void 0},numTrisTable:{value:a}},this.voxelMesh=new ce.Mesh(rl,this.voxelPassMaterial()),this.voxelMesh.frustumCulled=!1,this.voxelPassScene.add(this.voxelMesh),this.potentialPassUniforms={shapesDataTexture:this.shapesDataTexture,spatialPassTexture:{value:void 0},npart:{value:this.npart},spatialn:{value:this.spatialn}},this.potentialMesh=new ce.Mesh(rl,this.potentialPassMaterial()),this.potentialMesh.frustumCulled=!1,this.potentialPassScene.add(this.potentialMesh),this.marchPassUniforms={triTable:{value:n},potentialPassTexture:{value:void 0},voxelPassTexture:{value:void 0},pyramidTexture1:{value:void 0},pyramidTexture1Size:{value:void 0},pyramidTexture2:{value:void 0},pyramidTexture2Size:{value:void 0}},this.frustumCulled=!1,this.onBeforeShadowPass=s=>{if(ME.call(this),this.npart===0){this.geometry.drawRange.count=0;return}let l=this.material.root;if(!l.shadersPatchedForShapeBlend)this.patchVertexShaderForShapeBlend(l),l.shadersPatchedForShapeBlend=!0,this.customDepthMaterialNeedsUpdate=!0;else if(this.customDepthMaterialNeedsUpdate){this.customDepthMaterialNeedsUpdate=!1,this.customDepthMaterial=new ce.ShaderMaterial({vertexShader:l.vertexShader,fragmentShader:`
3646
+ `;this.pyramidPassMaterial.fragmentShader=t,this.pyramidPassMaterial.uniforms=this.pyramidPassUniforms,this.pyramidPassMaterial.depthTest=!1,this.pyramidPassMaterial.depthWrite=!1;let e=new ir.Mesh(rl,this.pyramidPassMaterial);e.frustumCulled=!1,this.pyramidPassScene.add(e)}renderPyramid(t,e,r,o,n){new ir.Box2().min.setScalar(0);let s=e.length-1,l=new ir.Vector4;r.getViewport(l),this.pyramidPassUniforms.inputShiftX.value=0,this.pyramidPassUniforms.outputShiftX.value=0;let c=s-1;for(let d=c;d>=0;d--){let p=d%2===c%2?n[0]:n[1],f=d===c?o:d%2===c%2?n[1]:n[0];this.pyramidPassUniforms.inputTexture.value=Array.isArray(f.texture)?f.texture[1]:f.texture,this.pyramidPassUniforms.inputWidth.value="width"in f?f.width:1,this.pyramidPassUniforms.inputHeight.value="height"in f?f.height:1,r.setRenderTarget(p);let h=e[d],m=r.getPixelRatio();r.setViewport(this.pyramidPassUniforms.outputShiftX.value/m,0,h/m,h/m),d===2&&t%2!==0&&r.setViewport(this.pyramidPassUniforms.outputShiftX.value/m,0,3/m,3/m),r.render(this.pyramidPassScene,vc);let y=this.pyramidPassUniforms.inputShiftX.value;this.pyramidPassUniforms.inputShiftX.value=this.pyramidPassUniforms.outputShiftX.value,this.pyramidPassUniforms.outputShiftX.value=y,d<c&&(this.pyramidPassUniforms.outputShiftX.value+=e[d+1])}r.setViewport(l);let u=e.length%2===0?0:1;return r.readRenderTargetPixelsAsync(n[u],n[u].width-1,0,1,1,this.pyramidTopLevelReadPixelBuffer).then(()=>this.pyramidTopLevelReadPixelBuffer[0])}};var Po=24,dr=96,Ko=Y1(),Ti=2,am=class extends ht{constructor(e,r,o){super(e,r,o);this.data=r;this.needsRebuild=!0;this.customDepthMaterialNeedsUpdate=!1;this._npart=-1;this.spatialn=1;this.drawRangeNeedsForceUpdate=!0;this._resolutionLevel=-1;this.resolution=64;this.spatialDivisions=25;this.zLayersPerRow=8;this.basePyramidSize=512;this.pyramidTexture1Width=341;this.pyramidTexture1Height=256;this.pyramidTexture2Width=170;this.pyramidTexture2Height=128;this.numLevels=9;this.pyramidLevelSizes=[1,2,4,8,16,32,64,128,256,512];this.bboxSize=0;this.bboxOffset=0;this.shapesDataTexture={value:void 0};this.spatialscene=new ce.Scene;this.potentialPassScene=new ce.Scene;this.voxelPassScene=new ce.Scene;this._spatialPassRenderTargets=[];this._potentialPassRenderTargets=[];this._voxelPassRenderTargets=[];this._pyramidRenderTargets=[];this.geometry=new ce.BufferGeometry,this.geometry.drawRange.count=0,this.spatialPassUniforms={span:{value:-1},shapesDataTexture:this.shapesDataTexture,npart:{value:this.npart},spatialn:{value:this.spatialn}},this.spatialMesh=new ce.Mesh(rl,this.spatialPassMaterial()),this.spatialMesh.frustumCulled=!1,this.spatialscene.add(this.spatialMesh);let n=new ce.DataTexture(Ko.triTable,16,256,ce.RedFormat,ce.FloatType);n.needsUpdate=!0;let a=new ce.DataTexture(Ko.numTrisTable,256,1,ce.RedFormat,ce.FloatType);a.needsUpdate=!0,this.voxelPassUniforms={potentialPassTexture:{value:void 0},numTrisTable:{value:a}},this.voxelMesh=new ce.Mesh(rl,this.voxelPassMaterial()),this.voxelMesh.frustumCulled=!1,this.voxelPassScene.add(this.voxelMesh),this.potentialPassUniforms={shapesDataTexture:this.shapesDataTexture,spatialPassTexture:{value:void 0},npart:{value:this.npart},spatialn:{value:this.spatialn}},this.potentialMesh=new ce.Mesh(rl,this.potentialPassMaterial()),this.potentialMesh.frustumCulled=!1,this.potentialPassScene.add(this.potentialMesh),this.marchPassUniforms={triTable:{value:n},potentialPassTexture:{value:void 0},voxelPassTexture:{value:void 0},pyramidTexture1:{value:void 0},pyramidTexture1Size:{value:void 0},pyramidTexture2:{value:void 0},pyramidTexture2Size:{value:void 0}},this.frustumCulled=!1,this.onBeforeShadowPass=s=>{if(ME.call(this),this.npart===0){this.geometry.drawRange.count=0;return}let l=this.material.root;if(!l.shadersPatchedForShapeBlend)this.patchVertexShaderForShapeBlend(l),l.shadersPatchedForShapeBlend=!0,this.customDepthMaterialNeedsUpdate=!0;else if(this.customDepthMaterialNeedsUpdate){this.customDepthMaterialNeedsUpdate=!1,this.customDepthMaterial=new ce.ShaderMaterial({vertexShader:l.vertexShader,fragmentShader:`
3647
3647
  #include <packing>
3648
3648
  void main()
3649
3649
  {
@@ -3664,14 +3664,14 @@ void main() {
3664
3664
  dist = saturate(dist);
3665
3665
  // Required by Three.js for this to work
3666
3666
  gl_FragColor = packDepthToRGBA( dist );
3667
- }`,uniforms:{nearDistance:{value:0},farDistance:{value:0},referencePosition:{value:new ce.Vector3},opacity:{value:0},...l.uniforms},defines:this.material.defines});let d=this.customDistanceMaterial;d.referencePosition=new ce.Vector3,d.nearDistance=0,d.farDistance=0,d.opacity=1,d.isMeshDistanceMaterial=!0}if(this.spatialPassUniforms.npart.value=this.npart,this.spatialPassUniforms.spatialn.value=this.spatialn,this.potentialPassUniforms.npart.value=this.npart,this.potentialPassUniforms.spatialn.value=this.spatialn,this.needsRebuild){this.needsRebuild=!1,this.spatialMesh.material.defines.RES=this.resolutionLevel,this.spatialMesh.material.needsUpdate=!0,this.potentialMesh.material.defines.RES=this.resolutionLevel,this.potentialPassUniforms.spatialPassTexture.value=this.spatialPassRenderTarget.texture,this.potentialMesh.material.needsUpdate=!0,this.voxelMesh.material.defines.RES=this.resolutionLevel,this.voxelMesh.material.needsUpdate=!0,this.voxelPassUniforms.potentialPassTexture.value=this.potentialPassRenderTarget.texture,this.marchPassUniforms.potentialPassTexture.value=this.potentialPassRenderTarget.texture,this.marchPassUniforms.voxelPassTexture.value=this.voxelPassRenderTarget.texture[0],this.material.defines.RES=this.resolutionLevel,this.material.defines.LEVELS=this.pyramidLevelSizes.length,this.material.defines.LOOP=this.pyramidLevelSizes.length%2===0?this.pyramidLevelSizes.length-3:this.pyramidLevelSizes.length-2,this.material.defines.HALF=this.pyramidLevelSizes.length%2===0?1:0,this.material.needsUpdate=!0;let d=this.pyramidLevelSizes.length%2===0?0:1,p=this.pyramidLevelSizes.length%2===0?1:0;this.marchPassUniforms.pyramidTexture2.value=this.pyramidRenderTarget[d].texture,this.marchPassUniforms.pyramidTexture2Size.value=new ce.Vector2(this.pyramidRenderTarget[d].width,this.pyramidRenderTarget[d].height),this.marchPassUniforms.pyramidTexture1.value=this.pyramidRenderTarget[p].texture,this.marchPassUniforms.pyramidTexture1Size.value=new ce.Vector2(this.pyramidRenderTarget[p].width,this.pyramidRenderTarget[p].height),Object.assign(this.material.uniforms,this.marchPassUniforms)}let c=s.shadowMap.enabled;s.shadowMap.enabled=!1;let u=s.getRenderTarget();s.setRenderTarget(this.spatialPassRenderTarget),s.render(this.spatialscene,vc),s.setRenderTarget(this.potentialPassRenderTarget),s.render(this.potentialPassScene,vc),s.setRenderTarget(this.voxelPassRenderTarget),s.render(this.voxelPassScene,vc),nm.streamCompaction.renderPyramid(this.resolutionLevel,this.pyramidLevelSizes,s,this.voxelPassRenderTarget,this.pyramidRenderTarget).then(d=>{this.material.wireframe&&(d*3>this.geometry.attributes.position.count||this.drawRangeNeedsForceUpdate)&&(this.geometry.dispose(),this.geometry=new ce.BufferGeometry,this.geometry.userData.parameters={width:this.bboxSize,height:this.bboxSize,depth:this.bboxSize,centerOffset:[this.bboxOffset,this.bboxOffset,this.bboxOffset]},this.geometry.attributes.position=new ce.BufferAttribute(new Float32Array(d*3*2),3)),(d*3>this.geometry.drawRange.count||this.drawRangeNeedsForceUpdate)&&(this.geometry.drawRange.count=Math.floor(d*1.2)*3),this.drawRangeNeedsForceUpdate=!1}),s.shadowMap.enabled=c,s.setRenderTarget(u)}}set npart(e){e!==this._npart&&(this.drawRangeNeedsForceUpdate=!0,this._npart=e,this.spatialn=Math.ceil(e/(4*Po)))}get npart(){return this._npart}set resolutionLevel(e){let r=Math.min(8,Math.max(5,e));if(r!==this._resolutionLevel){switch(this._resolutionLevel=r,this.resolution=Math.pow(2,r),this.resolutionLevel){case 5:this.pyramidLevelSizes=[1,2,4,6,12,24,48,96,192],this.bboxSize=31*8*Ti,this.bboxOffset=8*Ti*-1/2;break;case 6:this.pyramidLevelSizes=[1,2,4,8,16,32,64,128,256,512],this.bboxSize=63*4*Ti,this.bboxOffset=4*Ti*-1/2;break;case 7:this.pyramidLevelSizes=[1,2,4,6,12,24,48,96,192,384,768,1536],this.bboxSize=127*2*Ti,this.bboxOffset=2*Ti*-1/2;break;case 8:this.pyramidLevelSizes=[1,2,4,8,16,32,64,128,256,512,1024,2048,4096],this.bboxSize=255*Ti,this.bboxOffset=Ti*-1/2;break}this.pyramidTexture1Width=0,this.pyramidTexture2Width=0,this.pyramidTexture1Height=this.pyramidLevelSizes[this.pyramidLevelSizes.length-2],this.pyramidTexture2Height=this.pyramidLevelSizes[this.pyramidLevelSizes.length-3];for(let o=this.pyramidLevelSizes.length-2;o>=0;o--)(this.pyramidLevelSizes.length-2)%2===o%2?this.pyramidTexture1Width+=this.pyramidLevelSizes[o]:this.pyramidTexture2Width+=this.pyramidLevelSizes[o];this.basePyramidSize=this.pyramidLevelSizes[this.pyramidLevelSizes.length-1],this.zLayersPerRow=this.basePyramidSize/this.resolution,this.numLevels=this.pyramidLevelSizes.length-1,this.geometry.userData.parameters={width:this.bboxSize,height:this.bboxSize,depth:this.bboxSize,centerOffset:[this.bboxOffset,this.bboxOffset,this.bboxOffset]},this.needsRebuild=!0,this.customDepthMaterialNeedsUpdate=!0}}get resolutionLevel(){return this._resolutionLevel}get spatialPassRenderTarget(){let e=this._spatialPassRenderTargets[this.resolutionLevel];return e||(e=new ce.WebGLRenderTarget(this.spatialDivisions*this.spatialn,this.spatialDivisions**2,{format:ce.RGBAFormat,type:ce.FloatType,stencilBuffer:!1,depthBuffer:!1,generateMipmaps:!1,minFilter:ce.NearestFilter,magFilter:ce.NearestFilter}),this._spatialPassRenderTargets[this.resolutionLevel]=e),e}get potentialPassRenderTarget(){let e=this._potentialPassRenderTargets[this.resolutionLevel];return e||(e=new ce.WebGLRenderTarget(this.basePyramidSize,this.basePyramidSize,{format:ce.RGBAFormat,type:ce.FloatType,stencilBuffer:!1,depthBuffer:!1,generateMipmaps:!1,minFilter:ce.NearestFilter,magFilter:ce.NearestFilter}),this._potentialPassRenderTargets[this.resolutionLevel]=e),e}get voxelPassRenderTarget(){let e=this._voxelPassRenderTargets[this.resolutionLevel];return e||(e=new ce.WebGLMultipleRenderTargets(this.basePyramidSize,this.basePyramidSize,2,{stencilBuffer:!1,depthBuffer:!1,generateMipmaps:!1,minFilter:ce.NearestFilter,magFilter:ce.NearestFilter}),e.texture[0].format=ce.RGBAFormat,e.texture[0].type=ce.FloatType,e.texture[1].format=ce.RedFormat,e.texture[1].type=ce.FloatType,this._voxelPassRenderTargets[this.resolutionLevel]=e),e}get pyramidRenderTarget(){let e=this._pyramidRenderTargets[this.resolutionLevel];if(!e){let r=new ce.WebGLRenderTarget(this.pyramidTexture1Width,this.pyramidTexture1Height,{format:ce.RGBAFormat,type:ce.FloatType,stencilBuffer:!1,depthBuffer:!1,magFilter:ce.NearestFilter,minFilter:ce.NearestFilter}),o=new ce.WebGLRenderTarget(this.pyramidTexture2Width,this.pyramidTexture2Height,{format:ce.RGBAFormat,type:ce.FloatType,stencilBuffer:!1,depthBuffer:!1,magFilter:ce.NearestFilter,minFilter:ce.NearestFilter});e=[r,o],this._pyramidRenderTargets[this.resolutionLevel]=e}return e}updateState(e,r){let o=this.material;super.updateState(e,r),o!==this.material&&(this.needsRebuild=!0),e.geometry&&(this.resolutionLevel=e.geometry.resolutionLevel,this.geometry.userData.parameters={width:this.bboxSize,height:this.bboxSize,depth:this.bboxSize,centerOffset:[this.bboxOffset,this.bboxOffset,this.bboxOffset]}),e.wireframe&&!this.geometry.getAttribute("position")?this.geometry.setAttribute("position",new ce.BufferAttribute(new Float32Array(this.geometry.drawRange.count*3),3)):!e.wireframe&&this.geometry.getAttribute("position")&&this.geometry.deleteAttribute("position")}spatialPassMaterial(){let e=`
3667
+ }`,uniforms:{nearDistance:{value:0},farDistance:{value:0},referencePosition:{value:new ce.Vector3},opacity:{value:0},...l.uniforms},defines:this.material.defines});let d=this.customDistanceMaterial;d.referencePosition=new ce.Vector3,d.nearDistance=0,d.farDistance=0,d.opacity=1,d.isMeshDistanceMaterial=!0}if(this.spatialPassUniforms.npart.value=this.npart,this.spatialPassUniforms.spatialn.value=this.spatialn,this.potentialPassUniforms.npart.value=this.npart,this.potentialPassUniforms.spatialn.value=this.spatialn,this.needsRebuild){this.needsRebuild=!1,this.spatialMesh.material.defines.RES=this.resolutionLevel,this.spatialMesh.material.needsUpdate=!0,this.potentialMesh.material.defines.RES=this.resolutionLevel,this.potentialPassUniforms.spatialPassTexture.value=this.spatialPassRenderTarget.texture,this.potentialMesh.material.needsUpdate=!0,this.voxelMesh.material.defines.RES=this.resolutionLevel,this.voxelMesh.material.needsUpdate=!0,this.voxelPassUniforms.potentialPassTexture.value=this.potentialPassRenderTarget.texture,this.marchPassUniforms.potentialPassTexture.value=this.potentialPassRenderTarget.texture,this.marchPassUniforms.voxelPassTexture.value=this.voxelPassRenderTarget.texture[0],this.material.defines.RES=this.resolutionLevel,this.material.defines.LEVELS=this.pyramidLevelSizes.length,this.material.defines.LOOP=this.pyramidLevelSizes.length%2===0?this.pyramidLevelSizes.length-3:this.pyramidLevelSizes.length-2,this.material.defines.HALF=this.pyramidLevelSizes.length%2===0?1:0,this.material.needsUpdate=!0;let d=this.pyramidLevelSizes.length%2===0?0:1,p=this.pyramidLevelSizes.length%2===0?1:0;this.marchPassUniforms.pyramidTexture2.value=this.pyramidRenderTarget[d].texture,this.marchPassUniforms.pyramidTexture2Size.value=new ce.Vector2(this.pyramidRenderTarget[d].width,this.pyramidRenderTarget[d].height),this.marchPassUniforms.pyramidTexture1.value=this.pyramidRenderTarget[p].texture,this.marchPassUniforms.pyramidTexture1Size.value=new ce.Vector2(this.pyramidRenderTarget[p].width,this.pyramidRenderTarget[p].height),Object.assign(this.material.uniforms,this.marchPassUniforms)}let c=s.shadowMap.enabled;s.shadowMap.enabled=!1;let u=s.getRenderTarget();s.setRenderTarget(this.spatialPassRenderTarget),s.render(this.spatialscene,vc),s.setRenderTarget(this.potentialPassRenderTarget),s.render(this.potentialPassScene,vc),s.setRenderTarget(this.voxelPassRenderTarget),s.render(this.voxelPassScene,vc),am.streamCompaction.renderPyramid(this.resolutionLevel,this.pyramidLevelSizes,s,this.voxelPassRenderTarget,this.pyramidRenderTarget).then(d=>{this.material.wireframe&&(d*3>this.geometry.attributes.position.count||this.drawRangeNeedsForceUpdate)&&(this.geometry.dispose(),this.geometry=new ce.BufferGeometry,this.geometry.userData.parameters={width:this.bboxSize,height:this.bboxSize,depth:this.bboxSize,centerOffset:[this.bboxOffset,this.bboxOffset,this.bboxOffset]},this.geometry.attributes.position=new ce.BufferAttribute(new Float32Array(d*3*2),3)),(d*3>this.geometry.drawRange.count||this.drawRangeNeedsForceUpdate)&&(this.geometry.drawRange.count=Math.floor(d*1.2)*3),this.drawRangeNeedsForceUpdate=!1}),s.shadowMap.enabled=c,s.setRenderTarget(u)}}set npart(e){e!==this._npart&&(this.drawRangeNeedsForceUpdate=!0,this._npart=e,this.spatialn=Math.ceil(e/(4*Po)))}get npart(){return this._npart}set resolutionLevel(e){let r=Math.min(8,Math.max(5,e));if(r!==this._resolutionLevel){switch(this._resolutionLevel=r,this.resolution=Math.pow(2,r),this.resolutionLevel){case 5:this.pyramidLevelSizes=[1,2,4,6,12,24,48,96,192],this.bboxSize=31*8*Ti,this.bboxOffset=8*Ti*-1/2;break;case 6:this.pyramidLevelSizes=[1,2,4,8,16,32,64,128,256,512],this.bboxSize=63*4*Ti,this.bboxOffset=4*Ti*-1/2;break;case 7:this.pyramidLevelSizes=[1,2,4,6,12,24,48,96,192,384,768,1536],this.bboxSize=127*2*Ti,this.bboxOffset=2*Ti*-1/2;break;case 8:this.pyramidLevelSizes=[1,2,4,8,16,32,64,128,256,512,1024,2048,4096],this.bboxSize=255*Ti,this.bboxOffset=Ti*-1/2;break}this.pyramidTexture1Width=0,this.pyramidTexture2Width=0,this.pyramidTexture1Height=this.pyramidLevelSizes[this.pyramidLevelSizes.length-2],this.pyramidTexture2Height=this.pyramidLevelSizes[this.pyramidLevelSizes.length-3];for(let o=this.pyramidLevelSizes.length-2;o>=0;o--)(this.pyramidLevelSizes.length-2)%2===o%2?this.pyramidTexture1Width+=this.pyramidLevelSizes[o]:this.pyramidTexture2Width+=this.pyramidLevelSizes[o];this.basePyramidSize=this.pyramidLevelSizes[this.pyramidLevelSizes.length-1],this.zLayersPerRow=this.basePyramidSize/this.resolution,this.numLevels=this.pyramidLevelSizes.length-1,this.geometry.userData.parameters={width:this.bboxSize,height:this.bboxSize,depth:this.bboxSize,centerOffset:[this.bboxOffset,this.bboxOffset,this.bboxOffset]},this.needsRebuild=!0,this.customDepthMaterialNeedsUpdate=!0}}get resolutionLevel(){return this._resolutionLevel}get spatialPassRenderTarget(){let e=this._spatialPassRenderTargets[this.resolutionLevel];return e||(e=new ce.WebGLRenderTarget(this.spatialDivisions*this.spatialn,this.spatialDivisions**2,{format:ce.RGBAFormat,type:ce.FloatType,stencilBuffer:!1,depthBuffer:!1,generateMipmaps:!1,minFilter:ce.NearestFilter,magFilter:ce.NearestFilter}),this._spatialPassRenderTargets[this.resolutionLevel]=e),e}get potentialPassRenderTarget(){let e=this._potentialPassRenderTargets[this.resolutionLevel];return e||(e=new ce.WebGLRenderTarget(this.basePyramidSize,this.basePyramidSize,{format:ce.RGBAFormat,type:ce.FloatType,stencilBuffer:!1,depthBuffer:!1,generateMipmaps:!1,minFilter:ce.NearestFilter,magFilter:ce.NearestFilter}),this._potentialPassRenderTargets[this.resolutionLevel]=e),e}get voxelPassRenderTarget(){let e=this._voxelPassRenderTargets[this.resolutionLevel];return e||(e=new ce.WebGLMultipleRenderTargets(this.basePyramidSize,this.basePyramidSize,2,{stencilBuffer:!1,depthBuffer:!1,generateMipmaps:!1,minFilter:ce.NearestFilter,magFilter:ce.NearestFilter}),e.texture[0].format=ce.RGBAFormat,e.texture[0].type=ce.FloatType,e.texture[1].format=ce.RedFormat,e.texture[1].type=ce.FloatType,this._voxelPassRenderTargets[this.resolutionLevel]=e),e}get pyramidRenderTarget(){let e=this._pyramidRenderTargets[this.resolutionLevel];if(!e){let r=new ce.WebGLRenderTarget(this.pyramidTexture1Width,this.pyramidTexture1Height,{format:ce.RGBAFormat,type:ce.FloatType,stencilBuffer:!1,depthBuffer:!1,magFilter:ce.NearestFilter,minFilter:ce.NearestFilter}),o=new ce.WebGLRenderTarget(this.pyramidTexture2Width,this.pyramidTexture2Height,{format:ce.RGBAFormat,type:ce.FloatType,stencilBuffer:!1,depthBuffer:!1,magFilter:ce.NearestFilter,minFilter:ce.NearestFilter});e=[r,o],this._pyramidRenderTargets[this.resolutionLevel]=e}return e}updateState(e,r){let o=this.material;super.updateState(e,r),o!==this.material&&(this.needsRebuild=!0),e.geometry&&(this.resolutionLevel=e.geometry.resolutionLevel,this.geometry.userData.parameters={width:this.bboxSize,height:this.bboxSize,depth:this.bboxSize,centerOffset:[this.bboxOffset,this.bboxOffset,this.bboxOffset]}),e.wireframe&&!this.geometry.getAttribute("position")?this.geometry.setAttribute("position",new ce.BufferAttribute(new Float32Array(this.geometry.drawRange.count*3),3)):!e.wireframe&&this.geometry.getAttribute("position")&&this.geometry.deleteAttribute("position")}spatialPassMaterial(){let e=`
3668
3668
  precision highp float;
3669
3669
  out vec4 pc_FragColor;
3670
3670
  const float spatialDivisions = ${this.spatialDivisions}.;
3671
3671
  uniform float span;
3672
3672
  uniform float npart;
3673
3673
  uniform float spatialn;
3674
- ${Yo.shapeInput()}
3674
+ ${Ko.shapeInput()}
3675
3675
 
3676
3676
  vec3 low, high; // range of current div; subset of -1 .. 1 with span border
3677
3677
 
@@ -3698,7 +3698,7 @@ void main() {
3698
3698
  return t;
3699
3699
  }
3700
3700
 
3701
- ${Yo.getpart}
3701
+ ${Ko.getpart}
3702
3702
 
3703
3703
  void main() { // spatialial fragment shader
3704
3704
  // find active div
@@ -3725,7 +3725,7 @@ void main() {
3725
3725
  precision highp float;
3726
3726
  out vec4 pc_FragColor;
3727
3727
 
3728
- ${Yo.shapeInput()}
3728
+ ${Ko.shapeInput()}
3729
3729
  uniform sampler2D spatialPassTexture;
3730
3730
 
3731
3731
  const float res = float(RES);
@@ -3740,7 +3740,7 @@ void main() {
3740
3740
  const float spatialDivisions2 = spatialDivisions * spatialDivisions;
3741
3741
  const float spatialDivisionsSub1 = spatialDivisions - 1.;
3742
3742
 
3743
- ${Yo.getpart}
3743
+ ${Ko.getpart}
3744
3744
 
3745
3745
  vec3 packRGBAToVec3(vec4 color) {
3746
3746
  uint r = uint(color.r * 255.);
@@ -3911,7 +3911,7 @@ void main() {
3911
3911
  }
3912
3912
 
3913
3913
  void main() {
3914
- ${Yo.getxyzi} // get xi yi zi from 2d position
3914
+ ${Ko.getxyzi} // get xi yi zi from 2d position
3915
3915
 
3916
3916
  vec3 xyzi = vec3(xi,yi,zi);
3917
3917
  vec3 corner = xyzi / VOXEL_RESOLUTION_SUB1 * 2. - 1.; // -1..1 coords
@@ -3946,7 +3946,7 @@ void main() {
3946
3946
  (float(f111 < 0.) * 64.);
3947
3947
  }
3948
3948
 
3949
- ${Yo.lookup}
3949
+ ${Ko.lookup}
3950
3950
 
3951
3951
  vec3 compNormi(float xi, float yi, float zi) {
3952
3952
  float dx = look(xi + 1., yi, zi, potentialPassTexture).r - look(xi - 1., yi, zi, potentialPassTexture).r;
@@ -3961,7 +3961,7 @@ void main() {
3961
3961
  }
3962
3962
 
3963
3963
  void main() {
3964
- ${Yo.getxyzi} // get xi yi zi from 2d
3964
+ ${Ko.getxyzi} // get xi yi zi from 2d
3965
3965
 
3966
3966
  vec3 normal = compNormi(xi, yi, zi); // even if our key is -1 this may be needed by a neighbouring voxel
3967
3967
 
@@ -4029,7 +4029,7 @@ void main() {
4029
4029
  const vec3 originOffset = vec3(32.);
4030
4030
  #endif
4031
4031
 
4032
- ${Yo.lookup}
4032
+ ${Ko.lookup}
4033
4033
 
4034
4034
  const vec3 offsets[24] = vec3[](
4035
4035
  vec3(0., 0., 0.), vec3(1., 0., 0.),
@@ -4222,7 +4222,7 @@ void main() {
4222
4222
  gl_FragColor = texture(inputTexture, vUv);
4223
4223
  gVelocity = vec4(0.0);
4224
4224
  }
4225
- `,r.pyramidTextureSize.value=new ce.Vector2(this.pyramidRenderTarget[0].width,this.pyramidRenderTarget[0].height),Object.assign(n.uniforms,r)};this.material.shapeBlendhack=o,this.material.root.shapeBlendhack=o}},fn=nm;fn.streamCompaction=new cp;var OE=new ce.Matrix4,TE=new ce.Matrix4,ol=new ce.Quaternion,mn=new ce.Vector3,up=new ce.Vector3,CE=new ce.Quaternion;function AE(i,t=0){let e=this.children.length;for(;e--;){let r=this.children[e];di.is(r)&&Y1.call(r,i,t+1)}}function Y1(i,t=0){if(i(this,t)!==!0){let r=this.children.length;for(;r--;){let o=this.children[r];di.is(o)&&Y1.call(o,i,t+1)}}}function ME(){if(this.shapesDataTexture.value===void 0){let a=new ce.DataTexture(new Float32Array(4*dr*hn),dr,hn,ce.RGBAFormat,ce.FloatType);this.shapesDataTexture.value=a}let i=this.shapesDataTexture.value,t=i.image.data;i.needsUpdate=!0;let e=0,r=this.data.geometry.blendRange,o=OE.copy(this.matrixWorld).invert(),n=0;AE.call(this,a=>{if(a.visible===!1)return!0;let s;if(a instanceof nn)return;if(a instanceof Us||a instanceof el)return;a instanceof co?s=a.object:s=a;let l=a.data?.cloner;if(Ge.is(a)&&l&&!l.hideBase&&l.type!=="radial"&&l.disabled!==!0||!(s instanceof ht))return;let c=s.geometry.userData.parameters,u=c.shapeBlendNode;if(u===void 0)return;if(TE.multiplyMatrices(o,a.matrixWorld).decompose(up,ol,mn),c.type==="TorusGeometry"&&c.arc!==360){let b=c.arc*Math.PI/180;b=b/4,ol.multiply(CE.set(0,0,Math.sin(b),Math.cos(b)))}let p=u.overrideGlobalBlend?u.blendRange:r;p=p/this.bboxSize*2,t[n*4]=(up.x-this.bboxOffset)/this.bboxSize*2,t[n*4+1]=(up.y-this.bboxOffset)/this.bboxSize*2,t[n*4+2]=(up.z-this.bboxOffset)/this.bboxSize*2,t[n*4+3]=u.operation===0?1:u.operation===2?-1:-2,t[dr*4+n*4]=-ol.x,t[dr*4+n*4+1]=-ol.y,t[dr*4+n*4+2]=-ol.z,t[dr*4+n*4+3]=ol.w;let f=new Float32Array(4),h=0;if(c.type==="SphereGeometry")c.width===c.height&&c.width===c.depth?f[0]=0:f[0]=1,f[1]=c.width/this.bboxSize,f[2]=c.height/this.bboxSize,f[3]=c.depth/this.bboxSize,e=Math.max(e,f[1]*mn.x+p,f[2]*mn.x+p,f[3]*mn.x+p);else if(c.type==="CubeGeometry"){h=c.cornerRadius;let b=c.width,w=c.height,P=c.depth;f[0]=2,f[1]=(b-2*h)/this.bboxSize,f[2]=(w-2*h)/this.bboxSize,f[3]=(P-2*h)/this.bboxSize,e=Math.max(e,Math.sqrt(b**2+w**2+P**2)/this.bboxSize*mn.x+p)}else if(c.type==="CylinderGeometry"){h=c.cornerRadius;let b=c.height,w=c.radiusBottom,P=c.radiusTop;if(P>=w){let S=Math.atan2(P-w,b),T=(Math.PI/2-S)/2;P-=h/Math.tan(T),w-=h*Math.tan(T)}else if(w>P){let S=Math.atan2(w-P,b),T=(Math.PI/2-S)/2;P-=h*Math.tan(T),w-=h/Math.tan(T)}f[1]=(c.height-2*h)/this.bboxSize,w===P?(f[0]=3,f[2]=w/this.bboxSize*2):(f[0]=4,f[2]=w/this.bboxSize*2,f[3]=P/this.bboxSize*2),e=Math.max(e,f[1]*4*mn.x+p)}else if(c.type==="TorusGeometry"){if(f[0]=5,f[1]=(c.width-c.depth)/this.bboxSize,f[2]=c.depth/this.bboxSize,c.arc!==360){f[0]=6,f[3]=f[1],t[dr*12+n*4+3]=f[2];let b=2*Math.atan2(f[2]/2,f[1]),w=c.arc*Math.PI/180/2-b;f[1]=Math.sin(w),f[2]=Math.cos(w)}e=Math.max(e,c.width*mn.x/this.bboxSize+p)}t.set(f,dr*8+n*4),t[dr*12+n*4]=p,t[dr*12+n*4+1]=h/this.bboxSize*2,t[dr*12+n*4+2]=mn.x;let m=s.material,y=m.uniforms.nodeU0.node.value,g=m.uniforms.nodeU1.value;u.operation!==0&&!u.useColor&&(g=-1),t[dr*16+n*4]=y.r,t[dr*16+n*4+1]=y.g,t[dr*16+n*4+2]=y.b,t[dr*16+n*4+3]=g,g<1&&this.material.defines.SHAPEBLEND_C===1&&(this.material.transparent=!0),n++}),this.npart=n,this.spatialPassUniforms.span.value=e*1.4}var il=require("three");var Z1=1<<9;function K1(i,t){let e=!1,r=i.layers.mask&Z1,o=t.getLayersOfType("transmission"),n=t.getLayersOfType("outline");return n.length>0&&(i.layers.set(8),o.length>0&&i.layers.enable(3),e=!0,Bs(i),Ls(i)),o.length===0&&n.length===0&&i.layers.set(0),r&&i.layers.set(9),i instanceof Er&&i.needsAO&&i.layers.enable(5),e}function Q1(i,t){if(!t.layers)return!1;let e=i.layers.mask&Z1,r=!1,o=t.getLayersOfType("transmission").filter(a=>a.data.visible),n=t.getLayersOfType("outline").filter(a=>a.data.visible);return o.length>0&&(i.layers.set(3),n.length>0&&i.layers.enable(8),r=!0),o.length===0&&n.length===0&&i.layers.set(0),e&&i.layers.set(9),i.needsAO&&i.layers.enable(5),r}function J1(i){let t=!1;return i.traverseEntity(e=>{if(e instanceof Er)if(Array.isArray(e.material))for(let r=0;r<e.material.length;r++)K1(e,e.material[r])&&(t=!0);else K1(e,e.material)&&(t=!0)}),t}function eS(i){let t=!1;return i.traverseEntity(e=>{if(e instanceof Er)if(Array.isArray(e.material))for(let r=0;r<e.material.length;r++)Q1(e,e.material[r])&&(t=!0);else Q1(e,e.material)&&(t=!0)}),t}var NE=new il.Raycaster,DE=new il.Matrix4,_E=new il.Ray;function bc(i,t,e,r=!1){let o=i.cloner;if(o)for(let n of o.children){let a=DE.copy(n.matrixWorld).invert(),s=_E.copy(t.ray).applyMatrix4(a),l=i.matrixWorld;s.applyMatrix4(l);let c=NE;c.set(s.origin,s.direction),c.near=t.near,c.far=t.far;let u=c.intersectObject(i,!1);u.length>0&&e.push({...u[0],object:r?n:i})}}var dp=class{constructor(){this._constraints=new Map}setConstraint(t,e){e===null?this._constraints.delete(t):this._constraints.set(t,e)}removeDependencies(t){this._constraints.delete(t)}applyConstraints(t){let e=new Set;this._constraints.forEach((r,o)=>{let n=[o,r],a=r;for(;this._constraints.has(a);){if(a=this._constraints.get(a),n.includes(a)){console.warn(`circular dependency detected: ${n.join(" -> ")}`);break}e.has(a)||n.push(a)}for(let s=n.length-2;s>=0;s--)if(!e.has(n[s])){let l=t.find(n[s]);l?l.applyPathSnapping(t):console.warn(`missing entity ${n[s]}`),e.add(n[s])}})}findDependency(t,e){let r=t;for(;this._constraints.has(r);)if(r=this._constraints.get(r),r===e)return!0;return!1}};var tS="AGFzbQEAAAAADwhkeWxpbmsuMAEEAAAAAAETA2AAAGAIf39/f39/f38AYAABfwISAQNlbnYGbWVtb3J5AgMAgIAEAwQDAAECBzkDEV9fd2FzbV9jYWxsX2N0b3JzAAALc29ydEluZGV4ZXMAARNlbXNjcmlwdGVuX3Rsc19pbml0AAIK3gMDAwABC9IDAwF/BnwBfgJAIAdFDQAgAysDUCEMIAMrAzAhDSADKwMQIQ5BACEDRP///////+9/IQtEAAAAAAAAEAAhCgNAIAIgA0ECdGoCfyAOIAEgA0EMbGoiCCoCALuiIA0gCCoCBLuioCAMIAgqAgi7oqBEAAAAAAAAsECiIgmZRAAAAAAAAOBBYwRAIAmqDAELQYCAgIB4CzYCACAJIAsgCSALYxshCyAJIAogCSAKZBshCiADQQFqIgMgB0cNAAsgB0UNACAGuCAKIAuhoyEJQQAhAwNAAn8gCSACIANBAnRqIgEoAgC3IAuhoiIKmUQAAAAAAADgQWMEQCAKqgwBC0GAgICAeAshCCABIAg2AgAgBCAIQQJ0aiIBIAEoAgBBAWo2AgAgA0EBaiIDIAdHDQALCyAGQQJPBEAgBCgCACEIQQEhAwNAIAQgA0ECdGoiASABKAIAIAhqIgg2AgAgA0EBaiIDIAZHDQALCyAHQQFrIgGtIQ8DQCAEIAIgD6dBAnQiA2ooAgBBAnRqIgcgBygCAEEBayIHNgIAIAUgASAHa0ECdGogACADaigCADYCACAPUCEDIA9CAX0hDyADRQ0ACyAGBEAgBEEAIAZBAnT8CwALCwQAQQAL";var Ko=class{};wn(Ko,"DepthMapRange",1<<16),wn(Ko,"MemoryPageSize",65536),wn(Ko,"BytesPerFloat",4),wn(Ko,"BytesPerInt",4);function RE(i){let t,e,r,o,n,a,s,l,c,u,d,p,f,h,m,y;function g(M){let D=new Float64Array(u,a,16);for(let R=0;R<16;R++)D[R]=M[R];let _;if(r>1){t.exports.sortIndexes(o,n,c,a,s,l,p.DepthMapRange,r);let R=new Uint32Array(r);_=R.buffer,R.set(new Uint32Array(u,l,r))}else if(r===1){let R=new Uint32Array(r);R[0]=new Uint32Array(u,o,e)[0],_=R.buffer}else _=new ArrayBuffer(0);i.postMessage({sortDone:!0,indexesBuffer:_},[_])}function b(M,D,_){let R=new Float32Array(u,n,e*3);r=0;let V=new Uint32Array(u,o,e);for(let U=0;U<_.length-1;U++){let B=D[U],q=M[U].elements,j=B.filter(H=>H.enabled&&H.mode==="Include").map(H=>H.type==="Box"?T(H):N(H)),F=B.filter(H=>H.enabled&&H.mode==="Exclude").map(H=>H.type==="Box"?T(H):N(H));for(let H=_[U];H<_[U+1];H++){let W=f[H*3],ee=f[H*3+1],te=f[H*3+2];if((j.length===0||P(W,ee,te,j))&&(F.length===0||!P(W,ee,te,F))){let Y=1/(q[3]*W+q[7]*ee+q[11]*te+q[15]);R[r*3]=(q[0]*W+q[4]*ee+q[8]*te+q[12])*Y,R[r*3+1]=(q[1]*W+q[5]*ee+q[9]*te+q[13])*Y,R[r*3+2]=(q[2]*W+q[6]*ee+q[10]*te+q[14])*Y,V[r]=H,r++}}}}function w(M,D){let _=[],R=D.filter(B=>B.enabled&&B.mode==="Include").map(B=>B.type==="Box"?T(B):N(B)),V=D.filter(B=>B.enabled&&B.mode==="Exclude").map(B=>B.type==="Box"?T(B):N(B)),U=M.length;for(let B=0;B<U;B+=3){let q=M[B],j=M[B+1],F=M[B+2];(R.length===0||P(q,j,F,R))&&(V.length===0||!P(q,j,F,V))||_.push(B/3)}return _}function P(M,D,_,R,V){return R[V==="Intersect"?"every":"some"](U=>{let B=S(M,D,_,U.invRotationMatrix,U.cropCenter);return Array.isArray(U)?x(B.x,B.y,B.z,U):E(B.x,B.y,B.z,U)})}function S(M,D,_,R,V){let U=M-V[0],B=D-V[1],q=_-V[2],j=1/(R[3]*U+R[7]*B+R[11]*q+R[15]);return{x:(R[0]*U+R[4]*B+R[8]*q+R[12])*j+V[0],y:(R[1]*U+R[5]*B+R[9]*q+R[13])*j+V[1],z:(R[2]*U+R[6]*B+R[10]*q+R[14])*j+V[2]}}function T(M){let D=M.cropSize[0]/2,_=M.cropSize[1]/2,R=M.cropSize[2]/2,V=[M.cropCenter[0]-D,M.cropCenter[1]-_,M.cropCenter[2]-R,M.cropCenter[0]+D,M.cropCenter[1]+_,M.cropCenter[2]+R],U=A(M.cropRotation);return Object.assign(V,{invRotationMatrix:U,cropCenter:M.cropCenter})}function A(M){let D=[],_=M[0]*Math.PI/180,R=M[1]*Math.PI/180,V=M[2]*Math.PI/180,U=Math.cos(_),B=Math.sin(_),q=Math.cos(R),j=Math.sin(R),F=Math.cos(V),H=Math.sin(V),W=U*F,ee=U*H,te=B*F,Y=B*H;return D[0]=q*F,D[1]=-q*H,D[2]=j,D[4]=ee+te*j,D[5]=W-Y*j,D[6]=-B*q,D[8]=Y-W*j,D[9]=te+ee*j,D[10]=U*q,D[12]=0,D[13]=0,D[14]=0,D[3]=0,D[7]=0,D[11]=0,D[15]=1,D}function x(M,D,_,R){return M>=R[0]&&M<=R[3]&&D>=R[1]&&D<=R[4]&&_>=R[2]&&_<=R[5]}function N(M){let D=2/M.cropSize[0],_=2/M.cropSize[1],R=2/M.cropSize[2],V=A(M.cropRotation);return{invRadiusX:D,invRadiusY:_,invRadiusZ:R,cropCenter:M.cropCenter,invRotationMatrix:V}}function E(M,D,_,R){let V=(M-R.cropCenter[0])*R.invRadiusX,U=(D-R.cropCenter[1])*R.invRadiusY,B=(_-R.cropCenter[2])*R.invRadiusZ;return V*V+U*U+B*B<=1}i.onmessage=M=>{if(M.data.getCroppedIndexes){let D=new Uint32Array(w(new Float32Array(M.data.positions),M.data.crops)).buffer;i.postMessage({outOfBoundsIndexes:D},[D])}else if(M.data.positions)d=M.data.positions,f=new Float32Array(d),m=M.data.meshMatrixWorlds,y=M.data.cropsArray,h=M.data.meshIndexIntervals,b(m,y,h),i.postMessage({sortSetupComplete:!0});else if(M.data.sort||M.data.newMatrixWorlds||M.data.newCropsArray)(M.data.newMatrixWorlds||M.data.newCropsArray)&&(y=M.data.newCropsArray||y,m=M.data.newMatrixWorlds||m,b(m,y,h)),g(M.data.sort.view,M.data.sort.cameraPosition);else if(M.data.init){p=M.data.init.Constants,e=M.data.init.splatCount;let D=p.BytesPerInt,_=p.BytesPerFloat*3,R=new Uint8Array(M.data.init.sorterWasmBytes),V=D+_,U=e*V,B=e*p.BytesPerInt*2+p.DepthMapRange*p.BytesPerInt*2,q=p.MemoryPageSize*32,j=U+B+q,F=Math.floor(j/p.MemoryPageSize)+1,H={module:{},env:{memory:new WebAssembly.Memory({initial:F*2,maximum:F*3,shared:!0})}};WebAssembly.compile(R).then(W=>WebAssembly.instantiate(W,H)).then(W=>{t=W,o=0,n=e*D,a=n+e*_,c=a+16*p.BytesPerFloat*2,s=c+e*p.BytesPerInt,l=s+p.DepthMapRange*p.BytesPerInt,u=H.env.memory.buffer,i.postMessage({sortSetupPhase1Complete:!0})})}}}function rS(i){let t=new Worker(URL.createObjectURL(new Blob(["(",RE.toString(),")(self)"],{type:"application/javascript"}))),e=atob(tS),r=new Uint8Array(e.length);for(let o=0;o<e.length;o++)r[o]=e.charCodeAt(o);return t.postMessage({init:{sorterWasmBytes:r.buffer,splatCount:i,Constants:{BytesPerFloat:Ko.BytesPerFloat,BytesPerInt:Ko.BytesPerInt,DepthMapRange:Ko.DepthMapRange,MemoryPageSize:Ko.MemoryPageSize}}}),t}var vr=require("three");var Ce=require("three");var pp=function(){let i=new Float32Array(1),t=new Int32Array(i.buffer);return function(e){return i[0]=e,t[0]}}(),oS=function(i,t,e,r){return i+(t<<8)+(e<<16)+(r<<24)};var fp=new Ce.Vector2;function hp(i){let t=!1;return i.scene.objects.traverse((e,r)=>{if(r.visible===!1)return!0;r.type==="Splat"&&(t=!0)}),t}var yn=class extends Ce.Mesh{constructor(e,r,o,n,a=!1,s=1,l,c){super(o,n);this.splatCount=r,this.meshIndexIntervals=l,this.meshMatrixWorlds=c,this.splatBuffers=e,this.geometry=o,this.material=n,this.splatDataTextures=null,this.halfPrecisionCovariancesOnGPU=a,this.devicePixelRatio=s,this.resetLocalSplatDataAndTexturesFromSplatBuffer()}static buildMesh(e,r,o=!1,n=1,a,s){let l=yn.buildGeomtery(r),c=yn.buildMaterial(a);return new yn(e,r,l,c,o,n,a,s)}static buildMaterial(e){let r=`
4225
+ `,r.pyramidTextureSize.value=new ce.Vector2(this.pyramidRenderTarget[0].width,this.pyramidRenderTarget[0].height),Object.assign(n.uniforms,r)};this.material.shapeBlendhack=o,this.material.root.shapeBlendhack=o}},fn=am;fn.streamCompaction=new up;var OE=new ce.Matrix4,TE=new ce.Matrix4,ol=new ce.Quaternion,mn=new ce.Vector3,dp=new ce.Vector3,CE=new ce.Quaternion;function AE(i,t=0){let e=this.children.length;for(;e--;){let r=this.children[e];di.is(r)&&K1.call(r,i,t+1)}}function K1(i,t=0){if(i(this,t)!==!0){let r=this.children.length;for(;r--;){let o=this.children[r];di.is(o)&&K1.call(o,i,t+1)}}}function ME(){if(this.shapesDataTexture.value===void 0){let a=new ce.DataTexture(new Float32Array(4*dr*hn),dr,hn,ce.RGBAFormat,ce.FloatType);this.shapesDataTexture.value=a}let i=this.shapesDataTexture.value,t=i.image.data;i.needsUpdate=!0;let e=0,r=this.data.geometry.blendRange,o=OE.copy(this.matrixWorld).invert(),n=0;AE.call(this,a=>{if(a.visible===!1)return!0;let s;if(a instanceof nn)return;if(a instanceof Us||a instanceof el)return;a instanceof co?s=a.object:s=a;let l=a.data?.cloner;if(Ge.is(a)&&l&&!l.hideBase&&l.type!=="radial"&&l.disabled!==!0||!(s instanceof ht))return;let c=s.geometry.userData.parameters,u=c.shapeBlendNode;if(u===void 0)return;if(TE.multiplyMatrices(o,a.matrixWorld).decompose(dp,ol,mn),c.type==="TorusGeometry"&&c.arc!==360){let b=c.arc*Math.PI/180;b=b/4,ol.multiply(CE.set(0,0,Math.sin(b),Math.cos(b)))}let p=u.overrideGlobalBlend?u.blendRange:r;p=p/this.bboxSize*2,t[n*4]=(dp.x-this.bboxOffset)/this.bboxSize*2,t[n*4+1]=(dp.y-this.bboxOffset)/this.bboxSize*2,t[n*4+2]=(dp.z-this.bboxOffset)/this.bboxSize*2,t[n*4+3]=u.operation===0?1:u.operation===2?-1:-2,t[dr*4+n*4]=-ol.x,t[dr*4+n*4+1]=-ol.y,t[dr*4+n*4+2]=-ol.z,t[dr*4+n*4+3]=ol.w;let f=new Float32Array(4),h=0;if(c.type==="SphereGeometry")c.width===c.height&&c.width===c.depth?f[0]=0:f[0]=1,f[1]=c.width/this.bboxSize,f[2]=c.height/this.bboxSize,f[3]=c.depth/this.bboxSize,e=Math.max(e,f[1]*mn.x+p,f[2]*mn.x+p,f[3]*mn.x+p);else if(c.type==="CubeGeometry"){h=c.cornerRadius;let b=c.width,w=c.height,P=c.depth;f[0]=2,f[1]=(b-2*h)/this.bboxSize,f[2]=(w-2*h)/this.bboxSize,f[3]=(P-2*h)/this.bboxSize,e=Math.max(e,Math.sqrt(b**2+w**2+P**2)/this.bboxSize*mn.x+p)}else if(c.type==="CylinderGeometry"){h=c.cornerRadius;let b=c.height,w=c.radiusBottom,P=c.radiusTop;if(P>=w){let S=Math.atan2(P-w,b),T=(Math.PI/2-S)/2;P-=h/Math.tan(T),w-=h*Math.tan(T)}else if(w>P){let S=Math.atan2(w-P,b),T=(Math.PI/2-S)/2;P-=h*Math.tan(T),w-=h/Math.tan(T)}f[1]=(c.height-2*h)/this.bboxSize,w===P?(f[0]=3,f[2]=w/this.bboxSize*2):(f[0]=4,f[2]=w/this.bboxSize*2,f[3]=P/this.bboxSize*2),e=Math.max(e,f[1]*4*mn.x+p)}else if(c.type==="TorusGeometry"){if(f[0]=5,f[1]=(c.width-c.depth)/this.bboxSize,f[2]=c.depth/this.bboxSize,c.arc!==360){f[0]=6,f[3]=f[1],t[dr*12+n*4+3]=f[2];let b=2*Math.atan2(f[2]/2,f[1]),w=c.arc*Math.PI/180/2-b;f[1]=Math.sin(w),f[2]=Math.cos(w)}e=Math.max(e,c.width*mn.x/this.bboxSize+p)}t.set(f,dr*8+n*4),t[dr*12+n*4]=p,t[dr*12+n*4+1]=h/this.bboxSize*2,t[dr*12+n*4+2]=mn.x;let m=s.material,y=m.uniforms.nodeU0.node.value,g=m.uniforms.nodeU1.value;u.operation!==0&&!u.useColor&&(g=-1),t[dr*16+n*4]=y.r,t[dr*16+n*4+1]=y.g,t[dr*16+n*4+2]=y.b,t[dr*16+n*4+3]=g,g<1&&this.material.defines.SHAPEBLEND_C===1&&(this.material.transparent=!0),n++}),this.npart=n,this.spatialPassUniforms.span.value=e*1.4}var il=require("three");var J1=1<<9;function Q1(i,t){let e=!1,r=i.layers.mask&J1,o=t.getLayersOfType("transmission"),n=t.getLayersOfType("outline");return n.length>0&&(i.layers.set(8),o.length>0&&i.layers.enable(3),e=!0,Bs(i),Ls(i)),o.length===0&&n.length===0&&i.layers.set(0),r&&i.layers.set(9),i instanceof Er&&i.needsAO&&i.layers.enable(5),e}function Z1(i,t){if(!t.layers)return!1;let e=i.layers.mask&J1,r=!1,o=t.getLayersOfType("transmission").filter(a=>a.data.visible),n=t.getLayersOfType("outline").filter(a=>a.data.visible);return o.length>0&&(i.layers.set(3),n.length>0&&i.layers.enable(8),r=!0),o.length===0&&n.length===0&&i.layers.set(0),e&&i.layers.set(9),i.needsAO&&i.layers.enable(5),r}function eS(i){let t=!1;return i.traverseEntity(e=>{if(e instanceof Er)if(Array.isArray(e.material))for(let r=0;r<e.material.length;r++)Q1(e,e.material[r])&&(t=!0);else Q1(e,e.material)&&(t=!0)}),t}function tS(i){let t=!1;return i.traverseEntity(e=>{if(e instanceof Er)if(Array.isArray(e.material))for(let r=0;r<e.material.length;r++)Z1(e,e.material[r])&&(t=!0);else Z1(e,e.material)&&(t=!0)}),t}var NE=new il.Raycaster,DE=new il.Matrix4,_E=new il.Ray;function bc(i,t,e,r=!1){let o=i.cloner;if(o)for(let n of o.children){let a=DE.copy(n.matrixWorld).invert(),s=_E.copy(t.ray).applyMatrix4(a),l=i.matrixWorld;s.applyMatrix4(l);let c=NE;c.set(s.origin,s.direction),c.near=t.near,c.far=t.far;let u=c.intersectObject(i,!1);u.length>0&&e.push({...u[0],object:r?n:i})}}var pp=class{constructor(){this._constraints=new Map}setConstraint(t,e){e===null?this._constraints.delete(t):this._constraints.set(t,e)}removeDependencies(t){this._constraints.delete(t)}applyConstraints(t){let e=new Set;this._constraints.forEach((r,o)=>{let n=[o,r],a=r;for(;this._constraints.has(a);){if(a=this._constraints.get(a),n.includes(a)){console.warn(`circular dependency detected: ${n.join(" -> ")}`);break}e.has(a)||n.push(a)}for(let s=n.length-2;s>=0;s--)if(!e.has(n[s])){let l=t.find(n[s]);l?l.applyPathSnapping(t):console.warn(`missing entity ${n[s]}`),e.add(n[s])}})}findDependency(t,e){let r=t;for(;this._constraints.has(r);)if(r=this._constraints.get(r),r===e)return!0;return!1}};var rS="AGFzbQEAAAAADwhkeWxpbmsuMAEEAAAAAAETA2AAAGAIf39/f39/f38AYAABfwISAQNlbnYGbWVtb3J5AgMAgIAEAwQDAAECBzkDEV9fd2FzbV9jYWxsX2N0b3JzAAALc29ydEluZGV4ZXMAARNlbXNjcmlwdGVuX3Rsc19pbml0AAIK3gMDAwABC9IDAwF/BnwBfgJAIAdFDQAgAysDUCEMIAMrAzAhDSADKwMQIQ5BACEDRP///////+9/IQtEAAAAAAAAEAAhCgNAIAIgA0ECdGoCfyAOIAEgA0EMbGoiCCoCALuiIA0gCCoCBLuioCAMIAgqAgi7oqBEAAAAAAAAsECiIgmZRAAAAAAAAOBBYwRAIAmqDAELQYCAgIB4CzYCACAJIAsgCSALYxshCyAJIAogCSAKZBshCiADQQFqIgMgB0cNAAsgB0UNACAGuCAKIAuhoyEJQQAhAwNAAn8gCSACIANBAnRqIgEoAgC3IAuhoiIKmUQAAAAAAADgQWMEQCAKqgwBC0GAgICAeAshCCABIAg2AgAgBCAIQQJ0aiIBIAEoAgBBAWo2AgAgA0EBaiIDIAdHDQALCyAGQQJPBEAgBCgCACEIQQEhAwNAIAQgA0ECdGoiASABKAIAIAhqIgg2AgAgA0EBaiIDIAZHDQALCyAHQQFrIgGtIQ8DQCAEIAIgD6dBAnQiA2ooAgBBAnRqIgcgBygCAEEBayIHNgIAIAUgASAHa0ECdGogACADaigCADYCACAPUCEDIA9CAX0hDyADRQ0ACyAGBEAgBEEAIAZBAnT8CwALCwQAQQAL";var Qo=class{};wn(Qo,"DepthMapRange",1<<16),wn(Qo,"MemoryPageSize",65536),wn(Qo,"BytesPerFloat",4),wn(Qo,"BytesPerInt",4);function RE(i){let t,e,r,o,n,a,s,l,c,u,d,p,f,h,m,y;function g(M){let D=new Float64Array(u,a,16);for(let R=0;R<16;R++)D[R]=M[R];let _;if(r>1){t.exports.sortIndexes(o,n,c,a,s,l,p.DepthMapRange,r);let R=new Uint32Array(r);_=R.buffer,R.set(new Uint32Array(u,l,r))}else if(r===1){let R=new Uint32Array(r);R[0]=new Uint32Array(u,o,e)[0],_=R.buffer}else _=new ArrayBuffer(0);i.postMessage({sortDone:!0,indexesBuffer:_},[_])}function b(M,D,_){let R=new Float32Array(u,n,e*3);r=0;let V=new Uint32Array(u,o,e);for(let U=0;U<_.length-1;U++){let B=D[U],q=M[U].elements,j=B.filter(H=>H.enabled&&H.mode==="Include").map(H=>H.type==="Box"?T(H):N(H)),F=B.filter(H=>H.enabled&&H.mode==="Exclude").map(H=>H.type==="Box"?T(H):N(H));for(let H=_[U];H<_[U+1];H++){let W=f[H*3],ee=f[H*3+1],te=f[H*3+2];if((j.length===0||P(W,ee,te,j))&&(F.length===0||!P(W,ee,te,F))){let Y=1/(q[3]*W+q[7]*ee+q[11]*te+q[15]);R[r*3]=(q[0]*W+q[4]*ee+q[8]*te+q[12])*Y,R[r*3+1]=(q[1]*W+q[5]*ee+q[9]*te+q[13])*Y,R[r*3+2]=(q[2]*W+q[6]*ee+q[10]*te+q[14])*Y,V[r]=H,r++}}}}function w(M,D){let _=[],R=D.filter(B=>B.enabled&&B.mode==="Include").map(B=>B.type==="Box"?T(B):N(B)),V=D.filter(B=>B.enabled&&B.mode==="Exclude").map(B=>B.type==="Box"?T(B):N(B)),U=M.length;for(let B=0;B<U;B+=3){let q=M[B],j=M[B+1],F=M[B+2];(R.length===0||P(q,j,F,R))&&(V.length===0||!P(q,j,F,V))||_.push(B/3)}return _}function P(M,D,_,R,V){return R[V==="Intersect"?"every":"some"](U=>{let B=S(M,D,_,U.invRotationMatrix,U.cropCenter);return Array.isArray(U)?x(B.x,B.y,B.z,U):E(B.x,B.y,B.z,U)})}function S(M,D,_,R,V){let U=M-V[0],B=D-V[1],q=_-V[2],j=1/(R[3]*U+R[7]*B+R[11]*q+R[15]);return{x:(R[0]*U+R[4]*B+R[8]*q+R[12])*j+V[0],y:(R[1]*U+R[5]*B+R[9]*q+R[13])*j+V[1],z:(R[2]*U+R[6]*B+R[10]*q+R[14])*j+V[2]}}function T(M){let D=M.cropSize[0]/2,_=M.cropSize[1]/2,R=M.cropSize[2]/2,V=[M.cropCenter[0]-D,M.cropCenter[1]-_,M.cropCenter[2]-R,M.cropCenter[0]+D,M.cropCenter[1]+_,M.cropCenter[2]+R],U=A(M.cropRotation);return Object.assign(V,{invRotationMatrix:U,cropCenter:M.cropCenter})}function A(M){let D=[],_=M[0]*Math.PI/180,R=M[1]*Math.PI/180,V=M[2]*Math.PI/180,U=Math.cos(_),B=Math.sin(_),q=Math.cos(R),j=Math.sin(R),F=Math.cos(V),H=Math.sin(V),W=U*F,ee=U*H,te=B*F,Y=B*H;return D[0]=q*F,D[1]=-q*H,D[2]=j,D[4]=ee+te*j,D[5]=W-Y*j,D[6]=-B*q,D[8]=Y-W*j,D[9]=te+ee*j,D[10]=U*q,D[12]=0,D[13]=0,D[14]=0,D[3]=0,D[7]=0,D[11]=0,D[15]=1,D}function x(M,D,_,R){return M>=R[0]&&M<=R[3]&&D>=R[1]&&D<=R[4]&&_>=R[2]&&_<=R[5]}function N(M){let D=2/M.cropSize[0],_=2/M.cropSize[1],R=2/M.cropSize[2],V=A(M.cropRotation);return{invRadiusX:D,invRadiusY:_,invRadiusZ:R,cropCenter:M.cropCenter,invRotationMatrix:V}}function E(M,D,_,R){let V=(M-R.cropCenter[0])*R.invRadiusX,U=(D-R.cropCenter[1])*R.invRadiusY,B=(_-R.cropCenter[2])*R.invRadiusZ;return V*V+U*U+B*B<=1}i.onmessage=M=>{if(M.data.getCroppedIndexes){let D=new Uint32Array(w(new Float32Array(M.data.positions),M.data.crops)).buffer;i.postMessage({outOfBoundsIndexes:D},[D])}else if(M.data.positions)d=M.data.positions,f=new Float32Array(d),m=M.data.meshMatrixWorlds,y=M.data.cropsArray,h=M.data.meshIndexIntervals,b(m,y,h),i.postMessage({sortSetupComplete:!0});else if(M.data.sort||M.data.newMatrixWorlds||M.data.newCropsArray)(M.data.newMatrixWorlds||M.data.newCropsArray)&&(y=M.data.newCropsArray||y,m=M.data.newMatrixWorlds||m,b(m,y,h)),g(M.data.sort.view,M.data.sort.cameraPosition);else if(M.data.init){p=M.data.init.Constants,e=M.data.init.splatCount;let D=p.BytesPerInt,_=p.BytesPerFloat*3,R=new Uint8Array(M.data.init.sorterWasmBytes),V=D+_,U=e*V,B=e*p.BytesPerInt*2+p.DepthMapRange*p.BytesPerInt*2,q=p.MemoryPageSize*32,j=U+B+q,F=Math.floor(j/p.MemoryPageSize)+1,H={module:{},env:{memory:new WebAssembly.Memory({initial:F*2,maximum:F*3,shared:!0})}};WebAssembly.compile(R).then(W=>WebAssembly.instantiate(W,H)).then(W=>{t=W,o=0,n=e*D,a=n+e*_,c=a+16*p.BytesPerFloat*2,s=c+e*p.BytesPerInt,l=s+p.DepthMapRange*p.BytesPerInt,u=H.env.memory.buffer,i.postMessage({sortSetupPhase1Complete:!0})})}}}function oS(i){let t=new Worker(URL.createObjectURL(new Blob(["(",RE.toString(),")(self)"],{type:"application/javascript"}))),e=atob(rS),r=new Uint8Array(e.length);for(let o=0;o<e.length;o++)r[o]=e.charCodeAt(o);return t.postMessage({init:{sorterWasmBytes:r.buffer,splatCount:i,Constants:{BytesPerFloat:Qo.BytesPerFloat,BytesPerInt:Qo.BytesPerInt,DepthMapRange:Qo.DepthMapRange,MemoryPageSize:Qo.MemoryPageSize}}}),t}var vr=require("three");var Ce=require("three");var fp=function(){let i=new Float32Array(1),t=new Int32Array(i.buffer);return function(e){return i[0]=e,t[0]}}(),iS=function(i,t,e,r){return i+(t<<8)+(e<<16)+(r<<24)};var hp=new Ce.Vector2;function mp(i){let t=!1;return i.scene.objects.traverse((e,r)=>{if(r.visible===!1)return!0;r.type==="Splat"&&(t=!0)}),t}var yn=class extends Ce.Mesh{constructor(e,r,o,n,a=!1,s=1,l,c){super(o,n);this.splatCount=r,this.meshIndexIntervals=l,this.meshMatrixWorlds=c,this.splatBuffers=e,this.geometry=o,this.material=n,this.splatDataTextures=null,this.halfPrecisionCovariancesOnGPU=a,this.devicePixelRatio=s,this.resetLocalSplatDataAndTexturesFromSplatBuffer()}static buildMesh(e,r,o=!1,n=1,a,s){let l=yn.buildGeomtery(r),c=yn.buildMaterial(a);return new yn(e,r,l,c,o,n,a,s)}static buildMaterial(e){let r=`
4226
4226
  precision highp float;
4227
4227
  #include <common>
4228
4228
 
@@ -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 Ce.Vector2},viewport:{type:"v2",value:new Ce.Vector2},basisViewport:{type:"v2",value:new Ce.Vector2},debugColor:{type:"v3",value:new Ce.Color},covariancesTextureSize:{type:"v2",value:new Ce.Vector2(1024,1024)},centersColorsTextureSize:{type:"v2",value:new Ce.Vector2(1024,1024)},orthoZoom:{type:"f",value:-1}};return new Ce.ShaderMaterial({uniforms:n,vertexShader:r,fragmentShader:o,transparent:!0,alphaTest:1,blending:Ce.NormalBlending,depthTest:!0,depthWrite:!1,side:Ce.DoubleSide})}static buildGeomtery(e){let r=new Ce.BufferGeometry;r.setIndex([0,1,2,0,2,3]);let o=new Float32Array(4*3),n=new Ce.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 Ce.InstancedBufferGeometry().copy(r),s=new Uint32Array(e),l=new Ce.InstancedBufferAttribute(s,1,!1);return l.setUsage(Ce.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 Ce.Vector2(4096,1024);for(;n.x*n.y*2<o*6;)n.y*=2;let a=new Ce.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]=Ce.DataUtils.toHalfFloat(this.covariances[h]);s=new Ce.DataTexture(l,n.x,n.y,Ce.RGFormat,Ce.HalfFloatType)}else l=new Float32Array(n.x*n.y*2),l.set(this.covariances),s=new Ce.DataTexture(l,n.x,n.y,Ce.RGFormat,Ce.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,g=h*4;c[g]=oS(this.colors[m],this.colors[m+1],this.colors[m+2],this.colors[m+3]),c[g+1]=pp(this.centers[y]),c[g+2]=pp(this.centers[y+1]),c[g+3]=pp(this.centers[y+2])}let u=new Ce.DataTexture(c,a.x,a.y,Ce.RGBAIntegerFormat,Ce.UnsignedIntType);u.internalFormat="RGBA32UI",u.needsUpdate=!0,this.material.uniforms.centersColorsTexture.value=u,this.material.uniforms.centersColorsTextureSize.value.copy(a);let d=256*4,p=new Float32Array(256*16);for(let h=0;h<this.meshMatrixWorlds.length;h++)p.set(this.meshMatrixWorlds[h].elements,h*16);let f=new Ce.DataTexture(p,d,1,Ce.RGBAFormat,Ce.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:p,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&&(fp.set(e.x*this.devicePixelRatio,e.y*this.devicePixelRatio),this.material.uniforms.viewport.value.copy(fp),this.material.uniforms.basisViewport.value.set(2/fp.x,2/fp.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 nS,am=new Promise(i=>{nS=i}),iS=!1;var mp;function sm(){if(iS)return;if(mp)return mp;async function i(){let e=await import("./gaussian-splat-compression.js");nS(e),iS=!0}return mp=i(),mp}var aS;am.then(i=>aS=i);var Sc=class{constructor(t={}){wn(this,"updateView",function(){let t=new vr.Matrix4,e=[],r=new vr.Vector3(0,0,-1),o=new vr.Vector3(0,0,-1),n=new vr.Vector3,a=new vr.Vector3;return function(s=!1,l){let c=this.updateMatrixWorldsInWorkerIfNeeded(),u=this.cropsChanged();if(!s){o.set(0,0,-1).applyQuaternion(l.quaternion);let p=!1,f=!1;if(o.dot(r)<=.95&&(p=!0),a.copy(l.position).sub(n).length()>=1&&(f=!0),!p&&!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 d={sort:{view:t.elements,cameraPosition:e,splatRenderCount:this.splatRenderCount,splatSortCount:this.splatRenderCount},...c?{newMatrixWorlds:this.meshMatrixWorlds}:{},...u?{newCropsArray:this.cropsArray}:{}};this.sortRunning?this.queuedMessage=d:(this.queuedMessage=null,this.sortRunning=!0,this.sortWorker.postMessage(d))}}());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 vr.Matrix4().makePerspective(-1,1,-1,1,.1,1e3)}updateSplatMeshUniforms(t,e){let r=new vr.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 vr.Vector3().fromArray(t.position)),t.orientation&&(t.orientation=new vr.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 aS.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 vr.Vector3,o=new vr.Quaternion,n=!1,a=1,s,l){this.splatMesh=yn.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,d)=>this.update(c,d)}setupSortWorker(t){this.sortWorker=rS(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 LE=new oo.MeshBasicMaterial;LE.wireframe=!0;var sS=new oo.Vector3,yp=class extends oo.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 dp;this.invisibleObjects=new ln("jflkdsafjasdifjaslk",{...Du.defaultData,visible:!1,name:"buildin invisible"});this.needsRecomputeInstances=!1;this.init(e,r),this.matrixAutoUpdate=!1,this.errorPage=new to("fdasfa",{...ii.defaultData,name:""},{shared:r,scene:this})}markGeometryCacheDirty(){this.geometryCacheChanged=!0}markNeedsUpdateRendererDirty(){this.needsTransmissionDirty=!0,this.needsNormalDirty=!0}needsTransmission(){return this.needsTransmissionDirty&&(this._needsTransmission=eS(this),this.needsTransmissionDirty=!1),this._needsTransmission}needsNormal(){return this.needsNormalDirty&&(this._needsNormal=J1(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 to&&(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)=>Ec(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===zi)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 to&&r.uiScene){let o=r.uiScene.find(e);if(o)return o}}findScene2DfromObject2D(e){for(let r of this.children)if(r instanceof to&&r.uiScene&&r.uiScene.find(e))return r.uiScene}find2DInUIObjects(e){let r;return this.traverseEntity(o=>{r===void 0&&o instanceof Qn&&(r=o.uiCanvas.find(e))}),r}traverse2D(e){for(let r of this.children)r instanceof to&&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(e){this.toExpandCloner.forEach(r=>{r.expandCloner(e)}),this.toExpandCloner.clear()}doPendingUpdateCloner(e){this.toUpdateCloner.forEach(r=>{r.cloner?.update(e)}),this.toUpdateCloner.clear()}doPendingUpdates(e){this.doPendingExpandCloner(e),this.doPendingUpdateCloner(e),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(),sn(n)&&dc(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 fn&&(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),dc(o.parent)&&(o.parent.invalidateUpstreamBooleanData(),o.parent.invalidateDownstreamBooleanData().recomputeBoolean()),sn(o)&&(o.freeBooleanPointer(),n instanceof Nr&&n.invalidateDownstreamBooleanData().recomputeBoolean()),o instanceof Qs&&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()),sn(o)&&(o.invalidateUpstreamBooleanData(),dc(o.parent)?o.parent.invalidateDownstreamBooleanData().recomputeBoolean():n instanceof Nr&&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 to&&(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{$1(a,r,o,{scene:this,shared:n}),a instanceof ht&&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 Qn||l instanceof to)&&(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 Si&&n.updateUp()}),this.doPendingExpandCloner({scene:this,shared:r}),this.applyPendingCommands()}markNeedsRecomputeInstances(){this.needsRecomputeInstances=!0}markNeedsRecomputeInstancesForChildren(e){e.traverseEntity(r=>{(r.data.type==="Component"||r.data.type==="Instance")&&this.markNeedsRecomputeInstances()})}markNeedsRecomputeInstancesForAncessors(e){Ge.is(e)&&(e.data.type==="Component"&&this.markNeedsRecomputeInstances(),e.traverseAncestors(r=>{Ge.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=Di(u.data,d=>{let p=d.events.data(l.id),f=u.goUp(s);if(f){let h=[...Ic(f.identity),e].join("-"),m=this.entityIdentityToEntity[h];if(m){let y=m.uuid,g=dt.zoom(p,r);g[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 Oi&&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=Di(s.data,l=>{s.isInstanceRoot||(l.events.delete(n.id),a=!0)}).data}),a===!1)for(let s of Bu.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 Oi&&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),ip(a)}recomputeInstances(e,r){this.needsRecomputeInstances&&(this.needsRecomputeInstances=!1,this.traverseEntity(o=>{o instanceof Oi&&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)Ge.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(Ge.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 d=s.matrixWorld.clone().invert();u.point.applyMatrix4(d),o.push(u)}}else(sn(s)||pc(s)&&this.enableHelpers&&s.objectHelper.visible)&&(e.intersectObject(s,!1,o),bc(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;Ge.is(a)&&(a.visible||s?.object.data.visible)&&((sn(a)||pc(a)&&this.enableHelpers&&a.objectHelper.visible)&&(e.intersectObject(a,!1,r),bc(a,e,r,!0)),o(a))}};return o(this),r}forEachEntity(e){for(let r of this.children)Ge.is(r)&&e(r)}traverseConcreteEntity(e){for(let r of this.children)Ge.is(r)&&r.isConcreteEntity&&r.traverseEntity(e)}traverseEntity(e){for(let r of this.children)Ge.is(r)&&r.traverseEntity(e)}updateFont(e,r){this.traverseEntity(o=>{if(o instanceof ht&&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();dc(s)&&s.recomputeBoolean()})}})}traverseObject(e){for(let r of this.children)di.is(r)&&r.traverseObject(e)}traverseVisibleEntity(e){for(let r of this.children)Ge.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=lp(e,r,l);return c instanceof fn&&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 ht&&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 d=u.dataPatched;if(u instanceof ht&&d.bones&&d.boneInverses){let p=d.bones.map(m=>this.find(m)),f=d.boneInverses.map(m=>new oo.Matrix4().fromArray(m)),h=new oo.Skeleton(p,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 oo.Box3;return o.setFromPoints(r),o.getCenter(sS),sS}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 Xt)if(Array.isArray(r.material))for(let o=0;o<r.material.length;o++)r.material[o]instanceof Ir&&e(r.material[o]);else r.material instanceof Ir&&e(r.material)})}updateViewPlaneSize(e,r,o=!1){this.traverseConcreteEntity(n=>{n instanceof Si&&n.setViewplaneSize(e,r,o)})}initializeSplatViewer(){this.splatViewer=new Sc({scene:this}),this.reloadSplats()}reloadSplats(){this.splatViewer?.loadSplat()}};var lS=require("three/examples/jsm/loaders/DRACOLoader.js");var gn;function cS(i){return gn||(gn=new lS.DRACOLoader,gn.setDecoderPath(i?`${i}/`:"https://www.gstatic.com/draco/versioned/decoders/1.5.2/").preload()),gn.decoderPending}async function BE(i){if(gn){let t={attributeIDs:gn.defaultAttributeIDs,attributeTypes:gn.defaultAttributeTypes,useUniqueIDs:!1},e;try{e=await gn.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 uS(i,t){let[e,r]=Up(bu.deserialize(new Uint8Array(i)));return zu(e),t&&t(e),r.result().data}function dS(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 pS(i){for(let t of i){let e=await BE(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 VE=require("three"),zE=require("three/examples/jsm/utils/BufferGeometryUtils.js");function fS(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 wc=require("three");function hS(i){let t=new Set;return i.traverse(e=>{if(e instanceof Er)if(Mt(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(GE(e)){Object.assign(e,{isMeshStandardMaterial:!0,isMeshPhysicalMaterial:!0,transmission:1,attenuationColor:new wc.Color,specularColor:new wc.Color});let o=0;e.onBeforeCompile=(n,a)=>{r&&r(n,a),n.uniforms=Object.assign({},wc.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=Yb(window.innerWidth,window.innerHeight),e.defines.IS_THREEJS_EXPORT=!0)}else o++,o<2&&(e.needsUpdate=!0)})}}else FE(e)||(e.onBeforeCompile=(o,n)=>{r&&r(o,n),e.transparent=!1})}),i}function GE(i){return i.getLayersOfType("transmission").length>0}function FE(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 mS(i){return i.traverse(t=>{if(t.type==="Camera"){let e=t;e.type=e.cameraType}}),i}function yS(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 gS=require("three/examples/jsm/utils/BufferGeometryUtils.js");function xS(i){let t=[];return i.traverse(e=>{e instanceof nn&&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&&fS(l),l}).filter(s=>s!==void 0)];if(!e.parameters.hideBase&&r instanceof Xt&&a.unshift(r.geometry),a.length){let s=(0,gS.mergeBufferGeometries)(a);r instanceof Xt&&(r.geometry=s)}e.removeFromParent(),r.setFromClonerState(null,{scene:i,shared:fv})}),i}function bS(i){return i.traverse(t=>{t.matrixAutoUpdate=!0}),i}function vS(i){Object.values(i.shared.materials).forEach(t=>{lm(t)}),i.scene.objects.traverse((t,e)=>{"material"in e?lm(e.material):"materials"in e&&e.materials.forEach(r=>{lm(r)})})}function lm(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 OS=ll(wS(),1);var PS="The SplineLoader only accepts .splinecode files that are generated from Spline export panel.",gp=class extends xp.Loader{load(t,e,r,o=console.error){let n=new xp.FileLoader(this.manager);n.setPath(this.path),n.setResponseType("arraybuffer"),n.setRequestHeader(this.requestHeader),n.setWithCredentials(this.withCredentials),t.endsWith(".spline")?console.warn(PS+" The .spline files are only meant to be used by the Editor."):t.endsWith(".splinecode")||console.warn(PS),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 uS(t,vS),r=dS(e);e.version&&(0,OS.default)(e.version,"1.12.42")>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&&cS(),xv(e)&&Pb(),Mv(e)&&av(),l1(e)&&n1(),hp(e)&&sm()].filter(Boolean)),r.length&&await pS(r);let o=!1,n=new qn(e.shared,{},o);Object.values(n.getMaterials()).forEach(l=>Object.assign(l,{isAsset:!0}));let a=new yp(e.scene,n);hp(e)&&a.initializeSplatViewer();let s=a.activeCamera;return s&&Object.assign(s,{makeDefault:!0}),a=xS(a),a=hS(a),a=mS(a),a=yS(a),a=bS(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 Ce.Vector2},viewport:{type:"v2",value:new Ce.Vector2},basisViewport:{type:"v2",value:new Ce.Vector2},debugColor:{type:"v3",value:new Ce.Color},covariancesTextureSize:{type:"v2",value:new Ce.Vector2(1024,1024)},centersColorsTextureSize:{type:"v2",value:new Ce.Vector2(1024,1024)},orthoZoom:{type:"f",value:-1}};return new Ce.ShaderMaterial({uniforms:n,vertexShader:r,fragmentShader:o,transparent:!0,alphaTest:1,blending:Ce.NormalBlending,depthTest:!0,depthWrite:!1,side:Ce.DoubleSide})}static buildGeomtery(e){let r=new Ce.BufferGeometry;r.setIndex([0,1,2,0,2,3]);let o=new Float32Array(4*3),n=new Ce.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 Ce.InstancedBufferGeometry().copy(r),s=new Uint32Array(e),l=new Ce.InstancedBufferAttribute(s,1,!1);return l.setUsage(Ce.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 Ce.Vector2(4096,1024);for(;n.x*n.y*2<o*6;)n.y*=2;let a=new Ce.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]=Ce.DataUtils.toHalfFloat(this.covariances[h]);s=new Ce.DataTexture(l,n.x,n.y,Ce.RGFormat,Ce.HalfFloatType)}else l=new Float32Array(n.x*n.y*2),l.set(this.covariances),s=new Ce.DataTexture(l,n.x,n.y,Ce.RGFormat,Ce.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,g=h*4;c[g]=iS(this.colors[m],this.colors[m+1],this.colors[m+2],this.colors[m+3]),c[g+1]=fp(this.centers[y]),c[g+2]=fp(this.centers[y+1]),c[g+3]=fp(this.centers[y+2])}let u=new Ce.DataTexture(c,a.x,a.y,Ce.RGBAIntegerFormat,Ce.UnsignedIntType);u.internalFormat="RGBA32UI",u.needsUpdate=!0,this.material.uniforms.centersColorsTexture.value=u,this.material.uniforms.centersColorsTextureSize.value.copy(a);let d=256*4,p=new Float32Array(256*16);for(let h=0;h<this.meshMatrixWorlds.length;h++)p.set(this.meshMatrixWorlds[h].elements,h*16);let f=new Ce.DataTexture(p,d,1,Ce.RGBAFormat,Ce.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:p,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&&(hp.set(e.x*this.devicePixelRatio,e.y*this.devicePixelRatio),this.material.uniforms.viewport.value.copy(hp),this.material.uniforms.basisViewport.value.set(2/hp.x,2/hp.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 aS,sm=new Promise(i=>{aS=i}),nS=!1;var yp;function lm(){if(nS)return;if(yp)return yp;async function i(){let e=await import("./gaussian-splat-compression.js");aS(e),nS=!0}return yp=i(),yp}var sS;sm.then(i=>sS=i);var Sc=class{constructor(t={}){wn(this,"updateView",function(){let t=new vr.Matrix4,e=[],r=new vr.Vector3(0,0,-1),o=new vr.Vector3(0,0,-1),n=new vr.Vector3,a=new vr.Vector3;return function(s=!1,l){let c=this.updateMatrixWorldsInWorkerIfNeeded(),u=this.cropsChanged();if(!s){o.set(0,0,-1).applyQuaternion(l.quaternion);let p=!1,f=!1;if(o.dot(r)<=.95&&(p=!0),a.copy(l.position).sub(n).length()>=1&&(f=!0),!p&&!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 d={sort:{view:t.elements,cameraPosition:e,splatRenderCount:this.splatRenderCount,splatSortCount:this.splatRenderCount},...c?{newMatrixWorlds:this.meshMatrixWorlds}:{},...u?{newCropsArray:this.cropsArray}:{}};this.sortRunning?this.queuedMessage=d:(this.queuedMessage=null,this.sortRunning=!0,this.sortWorker.postMessage(d))}}());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 vr.Matrix4().makePerspective(-1,1,-1,1,.1,1e3)}updateSplatMeshUniforms(t,e){let r=new vr.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 vr.Vector3().fromArray(t.position)),t.orientation&&(t.orientation=new vr.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 sS.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 vr.Vector3,o=new vr.Quaternion,n=!1,a=1,s,l){this.splatMesh=yn.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,d)=>this.update(c,d)}setupSortWorker(t){this.sortWorker=oS(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 LE=new oo.MeshBasicMaterial;LE.wireframe=!0;var lS=new oo.Vector3,gp=class extends oo.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 pp;this.invisibleObjects=new ln("jflkdsafjasdifjaslk",{...Du.defaultData,visible:!1,name:"buildin invisible"});this.needsRecomputeInstances=!1;this.init(e,r),this.matrixAutoUpdate=!1,this.errorPage=new to("fdasfa",{...ni.defaultData,name:""},{shared:r,scene:this})}markGeometryCacheDirty(){this.geometryCacheChanged=!0}markNeedsUpdateRendererDirty(){this.needsTransmissionDirty=!0,this.needsNormalDirty=!0}needsTransmission(){return this.needsTransmissionDirty&&(this._needsTransmission=tS(this),this.needsTransmissionDirty=!1),this._needsTransmission}needsNormal(){return this.needsNormalDirty&&(this._needsNormal=eS(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 to&&(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)=>Ec(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===zi)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 to&&r.uiScene){let o=r.uiScene.find(e);if(o)return o}}findScene2DfromObject2D(e){for(let r of this.children)if(r instanceof to&&r.uiScene&&r.uiScene.find(e))return r.uiScene}find2DInUIObjects(e){let r;return this.traverseEntity(o=>{r===void 0&&o instanceof Qn&&(r=o.uiCanvas.find(e))}),r}traverse2D(e){for(let r of this.children)r instanceof to&&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(e){this.toExpandCloner.forEach(r=>{r.expandCloner(e)}),this.toExpandCloner.clear()}doPendingUpdateCloner(e){this.toUpdateCloner.forEach(r=>{r.cloner?.update(e)}),this.toUpdateCloner.clear()}doPendingUpdates(e){this.doPendingExpandCloner(e),this.doPendingUpdateCloner(e),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(),sn(n)&&dc(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 fn&&(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),dc(o.parent)&&(o.parent.invalidateUpstreamBooleanData(),o.parent.invalidateDownstreamBooleanData().recomputeBoolean()),sn(o)&&(o.freeBooleanPointer(),n instanceof Nr&&n.invalidateDownstreamBooleanData().recomputeBoolean()),o instanceof Qs&&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()),sn(o)&&(o.invalidateUpstreamBooleanData(),dc(o.parent)?o.parent.invalidateDownstreamBooleanData().recomputeBoolean():n instanceof Nr&&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 to&&(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{X1(a,r,o,{scene:this,shared:n}),a instanceof ht&&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 Qn||l instanceof to)&&(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 Si&&n.updateUp()}),this.doPendingExpandCloner({scene:this,shared:r}),this.applyPendingCommands()}markNeedsRecomputeInstances(){this.needsRecomputeInstances=!0}markNeedsRecomputeInstancesForChildren(e){e.traverseEntity(r=>{(r.data.type==="Component"||r.data.type==="Instance")&&this.markNeedsRecomputeInstances()})}markNeedsRecomputeInstancesForAncessors(e){Ge.is(e)&&(e.data.type==="Component"&&this.markNeedsRecomputeInstances(),e.traverseAncestors(r=>{Ge.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=Di(u.data,d=>{let p=d.events.data(l.id),f=u.goUp(s);if(f){let h=[...Ic(f.identity),e].join("-"),m=this.entityIdentityToEntity[h];if(m){let y=m.uuid,g=dt.zoom(p,r);g[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 Oi&&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=Di(s.data,l=>{s.isInstanceRoot||(l.events.delete(n.id),a=!0)}).data}),a===!1)for(let s of Bu.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 Oi&&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),np(a)}recomputeInstances(e,r){this.needsRecomputeInstances&&(this.needsRecomputeInstances=!1,this.traverseEntity(o=>{o instanceof Oi&&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)Ge.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(Ge.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 d=s.matrixWorld.clone().invert();u.point.applyMatrix4(d),o.push(u)}}else(sn(s)||pc(s)&&this.enableHelpers&&s.objectHelper.visible)&&(e.intersectObject(s,!1,o),bc(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;Ge.is(a)&&(a.visible||s?.object.data.visible)&&((sn(a)||pc(a)&&this.enableHelpers&&a.objectHelper.visible)&&(e.intersectObject(a,!1,r),bc(a,e,r,!0)),o(a))}};return o(this),r}forEachEntity(e){for(let r of this.children)Ge.is(r)&&e(r)}traverseConcreteEntity(e){for(let r of this.children)Ge.is(r)&&r.isConcreteEntity&&r.traverseEntity(e)}traverseEntity(e){for(let r of this.children)Ge.is(r)&&r.traverseEntity(e)}updateFont(e,r){this.traverseEntity(o=>{if(o instanceof ht&&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();dc(s)&&s.recomputeBoolean()})}})}traverseObject(e){for(let r of this.children)di.is(r)&&r.traverseObject(e)}traverseVisibleEntity(e){for(let r of this.children)Ge.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=cp(e,r,l);return c instanceof fn&&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 ht&&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 d=u.dataPatched;if(u instanceof ht&&d.bones&&d.boneInverses){let p=d.bones.map(m=>this.find(m)),f=d.boneInverses.map(m=>new oo.Matrix4().fromArray(m)),h=new oo.Skeleton(p,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 oo.Box3;return o.setFromPoints(r),o.getCenter(lS),lS}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 Xt)if(Array.isArray(r.material))for(let o=0;o<r.material.length;o++)r.material[o]instanceof Ir&&e(r.material[o]);else r.material instanceof Ir&&e(r.material)})}updateViewPlaneSize(e,r,o=!1){this.traverseConcreteEntity(n=>{n instanceof Si&&n.setViewplaneSize(e,r,o)})}initializeSplatViewer(){this.splatViewer=new Sc({scene:this}),this.reloadSplats()}reloadSplats(){this.splatViewer?.loadSplat()}};var cS=require("three/examples/jsm/loaders/DRACOLoader.js");var gn;function uS(i){return gn||(gn=new cS.DRACOLoader,gn.setDecoderPath(i?`${i}/`:"https://www.gstatic.com/draco/versioned/decoders/1.5.2/").preload()),gn.decoderPending}async function BE(i){if(gn){let t={attributeIDs:gn.defaultAttributeIDs,attributeTypes:gn.defaultAttributeTypes,useUniqueIDs:!1},e;try{e=await gn.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 dS(i,t){let[e,r]=kp(bu.deserialize(new Uint8Array(i)));return Gu(e),t&&t(e),r.result().data}function pS(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 fS(i){for(let t of i){let e=await BE(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 VE=require("three"),zE=require("three/examples/jsm/utils/BufferGeometryUtils.js");function hS(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 wc=require("three");function mS(i){let t=new Set;return i.traverse(e=>{if(e instanceof Er)if(Mt(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(GE(e)){Object.assign(e,{isMeshStandardMaterial:!0,isMeshPhysicalMaterial:!0,transmission:1,attenuationColor:new wc.Color,specularColor:new wc.Color});let o=0;e.onBeforeCompile=(n,a)=>{r&&r(n,a),n.uniforms=Object.assign({},wc.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=Kb(window.innerWidth,window.innerHeight),e.defines.IS_THREEJS_EXPORT=!0)}else o++,o<2&&(e.needsUpdate=!0)})}}else FE(e)||(e.onBeforeCompile=(o,n)=>{r&&r(o,n),e.transparent=!1})}),i}function GE(i){return i.getLayersOfType("transmission").length>0}function FE(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 yS(i){return i.traverse(t=>{if(t.type==="Camera"){let e=t;e.type=e.cameraType}}),i}function gS(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 xS=require("three/examples/jsm/utils/BufferGeometryUtils.js");function bS(i){let t=[];return i.traverse(e=>{e instanceof nn&&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&&hS(l),l}).filter(s=>s!==void 0)];if(!e.parameters.hideBase&&r instanceof Xt&&a.unshift(r.geometry),a.length){let s=(0,xS.mergeBufferGeometries)(a);r instanceof Xt&&(r.geometry=s)}e.removeFromParent(),r.setFromClonerState(null,{scene:i,shared:hv})}),i}function vS(i){return i.traverse(t=>{t.matrixAutoUpdate=!0}),i}function SS(i){Object.values(i.shared.materials).forEach(t=>{cm(t)}),i.scene.objects.traverse((t,e)=>{"material"in e?cm(e.material):"materials"in e&&e.materials.forEach(r=>{cm(r)})})}function cm(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 TS=ll(PS(),1);var OS="The SplineLoader only accepts .splinecode files that are generated from Spline export panel.",xp=class extends bp.Loader{load(t,e,r,o=console.error){let n=new bp.FileLoader(this.manager);n.setPath(this.path),n.setResponseType("arraybuffer"),n.setRequestHeader(this.requestHeader),n.setWithCredentials(this.withCredentials),t.endsWith(".spline")?console.warn(OS+" The .spline files are only meant to be used by the Editor."):t.endsWith(".splinecode")||console.warn(OS),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 dS(t,SS),r=pS(e);e.version&&(0,TS.default)(e.version,"1.12.44")>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&&uS(),bv(e)&&Ob(),Iv(e)&&sv(),c1(e)&&a1(),mp(e)&&lm()].filter(Boolean)),r.length&&await fS(r);let o=!1,n=new qn(e.shared,{},o);Object.values(n.getMaterials()).forEach(l=>Object.assign(l,{isAsset:!0}));let a=new gp(e.scene,n);mp(e)&&a.initializeSplatViewer();let s=a.activeCamera;return s&&Object.assign(s,{makeDefault:!0}),a=bS(a),a=mS(a),a=yS(a),a=gS(a),a=vS(a),a}};