@splinetool/loader 1.0.57 → 1.0.59

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.
@@ -15,7 +15,7 @@ var Y1=Object.create;var $l=Object.defineProperty;var X1=Object.getOwnPropertyDe
15
15
  ----------`);var d=new Function("compile",t.join(`
16
16
  `));return d(bE.bind(void 0,n))}$S.exports=vE});var QS=Zt((Dde,XS)=>{"use strict";var SE=YS();function wE(){this.argTypes=[],this.shimArgs=[],this.arrayArgs=[],this.arrayBlockIndices=[],this.scalarArgs=[],this.offsetArgs=[],this.offsetArgIndex=[],this.indexArgs=[],this.shapeArgs=[],this.funcName="",this.pre=null,this.body=null,this.post=null,this.debug=!1}function AE(n){var t=new wE;t.pre=n.pre,t.body=n.body,t.post=n.post;var e=n.args.slice(0);t.argTypes=e;for(var r=0;r<e.length;++r){var o=e[r];if(o==="array"||typeof o=="object"&&o.blockIndices){if(t.argTypes[r]="array",t.arrayArgs.push(r),t.arrayBlockIndices.push(o.blockIndices?o.blockIndices:0),t.shimArgs.push("array"+r),r<t.pre.args.length&&t.pre.args[r].count>0)throw new Error("cwise: pre() block may not reference array args");if(r<t.post.args.length&&t.post.args[r].count>0)throw new Error("cwise: post() block may not reference array args")}else if(o==="scalar")t.scalarArgs.push(r),t.shimArgs.push("scalar"+r);else if(o==="index"){if(t.indexArgs.push(r),r<t.pre.args.length&&t.pre.args[r].count>0)throw new Error("cwise: pre() block may not reference array index");if(r<t.body.args.length&&t.body.args[r].lvalue)throw new Error("cwise: body() block may not write to array index");if(r<t.post.args.length&&t.post.args[r].count>0)throw new Error("cwise: post() block may not reference array index")}else if(o==="shape"){if(t.shapeArgs.push(r),r<t.pre.args.length&&t.pre.args[r].lvalue)throw new Error("cwise: pre() block may not write to array shape");if(r<t.body.args.length&&t.body.args[r].lvalue)throw new Error("cwise: body() block may not write to array shape");if(r<t.post.args.length&&t.post.args[r].lvalue)throw new Error("cwise: post() block may not write to array shape")}else if(typeof o=="object"&&o.offset)t.argTypes[r]="offset",t.offsetArgs.push({array:o.array,offset:o.offset}),t.offsetArgIndex.push(r);else throw new Error("cwise: Unknown argument type "+e[r])}if(t.arrayArgs.length<=0)throw new Error("cwise: No array arguments specified");if(t.pre.args.length>e.length)throw new Error("cwise: Too many arguments in pre() block");if(t.body.args.length>e.length)throw new Error("cwise: Too many arguments in body() block");if(t.post.args.length>e.length)throw new Error("cwise: Too many arguments in post() block");return t.debug=!!n.printCode||!!n.debug,t.funcName=n.funcName||"cwise",t.blockSize=n.blockSize||64,SE(t)}XS.exports=AE});var Es=Zt(Ve=>{"use strict";var xr=QS(),Cd={body:"",args:[],thisVars:[],localVars:[]};function Gh(n){if(!n)return Cd;for(var t=0;t<n.args.length;++t){var e=n.args[t];t===0?n.args[t]={name:e,lvalue:!0,rvalue:!!n.rvalue,count:n.count||1}:n.args[t]={name:e,lvalue:!1,rvalue:!0,count:1}}return n.thisVars||(n.thisVars=[]),n.localVars||(n.localVars=[]),n}function _E(n){return xr({args:n.args,pre:Gh(n.pre),body:Gh(n.body),post:Gh(n.proc),funcName:n.funcName})}function ht(n){for(var t=[],e=0;e<n.args.length;++e)t.push("a"+e);var r=new Function("P",["return function ",n.funcName,"_ndarrayops(",t.join(","),") {P(",t.join(","),");return a0}"].join(""));return r(_E(n))}var KS={add:"+",sub:"-",mul:"*",div:"/",mod:"%",band:"&",bor:"|",bxor:"^",lshift:"<<",rshift:">>",rrshift:">>>"};(function(){for(var n in KS){var t=KS[n];Ve[n]=ht({args:["array","array","array"],body:{args:["a","b","c"],body:"a=b"+t+"c"},funcName:n}),Ve[n+"eq"]=ht({args:["array","array"],body:{args:["a","b"],body:"a"+t+"=b"},rvalue:!0,funcName:n+"eq"}),Ve[n+"s"]=ht({args:["array","array","scalar"],body:{args:["a","b","s"],body:"a=b"+t+"s"},funcName:n+"s"}),Ve[n+"seq"]=ht({args:["array","scalar"],body:{args:["a","s"],body:"a"+t+"=s"},rvalue:!0,funcName:n+"seq"})}})();var ZS={not:"!",bnot:"~",neg:"-",recip:"1.0/"};(function(){for(var n in ZS){var t=ZS[n];Ve[n]=ht({args:["array","array"],body:{args:["a","b"],body:"a="+t+"b"},funcName:n}),Ve[n+"eq"]=ht({args:["array"],body:{args:["a"],body:"a="+t+"a"},rvalue:!0,count:2,funcName:n+"eq"})}})();var JS={and:"&&",or:"||",eq:"===",neq:"!==",lt:"<",gt:">",leq:"<=",geq:">="};(function(){for(var n in JS){var t=JS[n];Ve[n]=ht({args:["array","array","array"],body:{args:["a","b","c"],body:"a=b"+t+"c"},funcName:n}),Ve[n+"s"]=ht({args:["array","array","scalar"],body:{args:["a","b","s"],body:"a=b"+t+"s"},funcName:n+"s"}),Ve[n+"eq"]=ht({args:["array","array"],body:{args:["a","b"],body:"a=a"+t+"b"},rvalue:!0,count:2,funcName:n+"eq"}),Ve[n+"seq"]=ht({args:["array","scalar"],body:{args:["a","s"],body:"a=a"+t+"s"},rvalue:!0,count:2,funcName:n+"seq"})}})();var e1=["abs","acos","asin","atan","ceil","cos","exp","floor","log","round","sin","sqrt","tan"];(function(){for(var n=0;n<e1.length;++n){var t=e1[n];Ve[t]=ht({args:["array","array"],pre:{args:[],body:"this_f=Math."+t,thisVars:["this_f"]},body:{args:["a","b"],body:"a=this_f(b)",thisVars:["this_f"]},funcName:t}),Ve[t+"eq"]=ht({args:["array"],pre:{args:[],body:"this_f=Math."+t,thisVars:["this_f"]},body:{args:["a"],body:"a=this_f(a)",thisVars:["this_f"]},rvalue:!0,count:2,funcName:t+"eq"})}})();var t1=["max","min","atan2","pow"];(function(){for(var n=0;n<t1.length;++n){var t=t1[n];Ve[t]=ht({args:["array","array","array"],pre:{args:[],body:"this_f=Math."+t,thisVars:["this_f"]},body:{args:["a","b","c"],body:"a=this_f(b,c)",thisVars:["this_f"]},funcName:t}),Ve[t+"s"]=ht({args:["array","array","scalar"],pre:{args:[],body:"this_f=Math."+t,thisVars:["this_f"]},body:{args:["a","b","c"],body:"a=this_f(b,c)",thisVars:["this_f"]},funcName:t+"s"}),Ve[t+"eq"]=ht({args:["array","array"],pre:{args:[],body:"this_f=Math."+t,thisVars:["this_f"]},body:{args:["a","b"],body:"a=this_f(a,b)",thisVars:["this_f"]},rvalue:!0,count:2,funcName:t+"eq"}),Ve[t+"seq"]=ht({args:["array","scalar"],pre:{args:[],body:"this_f=Math."+t,thisVars:["this_f"]},body:{args:["a","b"],body:"a=this_f(a,b)",thisVars:["this_f"]},rvalue:!0,count:2,funcName:t+"seq"})}})();var r1=["atan2","pow"];(function(){for(var n=0;n<r1.length;++n){var t=r1[n];Ve[t+"op"]=ht({args:["array","array","array"],pre:{args:[],body:"this_f=Math."+t,thisVars:["this_f"]},body:{args:["a","b","c"],body:"a=this_f(c,b)",thisVars:["this_f"]},funcName:t+"op"}),Ve[t+"ops"]=ht({args:["array","array","scalar"],pre:{args:[],body:"this_f=Math."+t,thisVars:["this_f"]},body:{args:["a","b","c"],body:"a=this_f(c,b)",thisVars:["this_f"]},funcName:t+"ops"}),Ve[t+"opeq"]=ht({args:["array","array"],pre:{args:[],body:"this_f=Math."+t,thisVars:["this_f"]},body:{args:["a","b"],body:"a=this_f(b,a)",thisVars:["this_f"]},rvalue:!0,count:2,funcName:t+"opeq"}),Ve[t+"opseq"]=ht({args:["array","scalar"],pre:{args:[],body:"this_f=Math."+t,thisVars:["this_f"]},body:{args:["a","b"],body:"a=this_f(b,a)",thisVars:["this_f"]},rvalue:!0,count:2,funcName:t+"opseq"})}})();Ve.any=xr({args:["array"],pre:Cd,body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:1}],body:"if(a){return true}",localVars:[],thisVars:[]},post:{args:[],localVars:[],thisVars:[],body:"return false"},funcName:"any"});Ve.all=xr({args:["array"],pre:Cd,body:{args:[{name:"x",lvalue:!1,rvalue:!0,count:1}],body:"if(!x){return false}",localVars:[],thisVars:[]},post:{args:[],localVars:[],thisVars:[],body:"return true"},funcName:"all"});Ve.sum=xr({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:1}],body:"this_s+=a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"sum"});Ve.prod=xr({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=1"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:1}],body:"this_s*=a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"prod"});Ve.norm2squared=xr({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:2}],body:"this_s+=a*a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"norm2squared"});Ve.norm2=xr({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:2}],body:"this_s+=a*a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return Math.sqrt(this_s)"},funcName:"norm2"});Ve.norminf=xr({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:4}],body:"if(-a>this_s){this_s=-a}else if(a>this_s){this_s=a}",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"norminf"});Ve.norm1=xr({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:3}],body:"this_s+=a<0?-a:a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"norm1"});Ve.sup=xr({args:["array"],pre:{body:"this_h=-Infinity",args:[],thisVars:["this_h"],localVars:[]},body:{body:"if(_inline_1_arg0_>this_h)this_h=_inline_1_arg0_",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:2}],thisVars:["this_h"],localVars:[]},post:{body:"return this_h",args:[],thisVars:["this_h"],localVars:[]}});Ve.inf=xr({args:["array"],pre:{body:"this_h=Infinity",args:[],thisVars:["this_h"],localVars:[]},body:{body:"if(_inline_1_arg0_<this_h)this_h=_inline_1_arg0_",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:2}],thisVars:["this_h"],localVars:[]},post:{body:"return this_h",args:[],thisVars:["this_h"],localVars:[]}});Ve.argmin=xr({args:["index","array","shape"],pre:{body:"{this_v=Infinity;this_i=_inline_0_arg2_.slice(0)}",args:[{name:"_inline_0_arg0_",lvalue:!1,rvalue:!1,count:0},{name:"_inline_0_arg1_",lvalue:!1,rvalue:!1,count:0},{name:"_inline_0_arg2_",lvalue:!1,rvalue:!0,count:1}],thisVars:["this_i","this_v"],localVars:[]},body:{body:"{if(_inline_1_arg1_<this_v){this_v=_inline_1_arg1_;for(var _inline_1_k=0;_inline_1_k<_inline_1_arg0_.length;++_inline_1_k){this_i[_inline_1_k]=_inline_1_arg0_[_inline_1_k]}}}",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:2},{name:"_inline_1_arg1_",lvalue:!1,rvalue:!0,count:2}],thisVars:["this_i","this_v"],localVars:["_inline_1_k"]},post:{body:"{return this_i}",args:[],thisVars:["this_i"],localVars:[]}});Ve.argmax=xr({args:["index","array","shape"],pre:{body:"{this_v=-Infinity;this_i=_inline_0_arg2_.slice(0)}",args:[{name:"_inline_0_arg0_",lvalue:!1,rvalue:!1,count:0},{name:"_inline_0_arg1_",lvalue:!1,rvalue:!1,count:0},{name:"_inline_0_arg2_",lvalue:!1,rvalue:!0,count:1}],thisVars:["this_i","this_v"],localVars:[]},body:{body:"{if(_inline_1_arg1_>this_v){this_v=_inline_1_arg1_;for(var _inline_1_k=0;_inline_1_k<_inline_1_arg0_.length;++_inline_1_k){this_i[_inline_1_k]=_inline_1_arg0_[_inline_1_k]}}}",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:2},{name:"_inline_1_arg1_",lvalue:!1,rvalue:!0,count:2}],thisVars:["this_i","this_v"],localVars:["_inline_1_k"]},post:{body:"{return this_i}",args:[],thisVars:["this_i"],localVars:[]}});Ve.random=ht({args:["array"],pre:{args:[],body:"this_f=Math.random",thisVars:["this_f"]},body:{args:["a"],body:"a=this_f()",thisVars:["this_f"]},funcName:"random"});Ve.assign=ht({args:["array","array"],body:{args:["a","b"],body:"a=b"},funcName:"assign"});Ve.assigns=ht({args:["array","scalar"],body:{args:["a","b"],body:"a=b"},funcName:"assigns"});Ve.equals=xr({args:["array","array"],pre:Cd,body:{args:[{name:"x",lvalue:!1,rvalue:!0,count:1},{name:"y",lvalue:!1,rvalue:!0,count:1}],body:"if(x!==y){return false}",localVars:[],thisVars:[]},post:{args:[],localVars:[],thisVars:[],body:"return true"},funcName:"equals"})});var T1=Zt((bhe,C1)=>{C1.exports=function(t,e){for(var r=t.split("."),o=e.split("."),i=0;i<3;i++){var a=Number(r[i]),s=Number(o[i]);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}});import{FileLoader as lB,Loader as cB}from"three";function Yl(n){for(let t of Object.keys(n))n[t]===void 0&&delete n[t];return n}function rr(n,t){return Object.setPrototypeOf(n,t),n}function Xl(n){return Array.isArray(n)?n:[n]}function Ql(n,t){let e=0;for(;e<n.length&&e<t.length;){if(n[e]<t[e])return-1;if(n[e]>t[e])return 1;e+=1}return e!==t.length?-1:e!==n.length?1:0}var rw=typeof global=="object"&&global&&global.Object===Object&&global,Kl=rw;var ow=typeof self=="object"&&self&&self.Object===Object&&self,nw=Kl||ow||Function("return this")(),_t=nw;var iw=_t.Symbol,Rt=iw;var rm=Object.prototype,aw=rm.hasOwnProperty,sw=rm.toString,Rs=Rt?Rt.toStringTag:void 0;function lw(n){var t=aw.call(n,Rs),e=n[Rs];try{n[Rs]=void 0;var r=!0}catch{}var o=sw.call(n);return r&&(t?n[Rs]=e:delete n[Rs]),o}var om=lw;var cw=Object.prototype,uw=cw.toString;function dw(n){return uw.call(n)}var nm=dw;var pw="[object Null]",fw="[object Undefined]",im=Rt?Rt.toStringTag:void 0;function hw(n){return n==null?n===void 0?fw:pw:im&&im in Object(n)?om(n):nm(n)}var br=hw;function mw(n){return n!=null&&typeof n=="object"}var qt=mw;var yw="[object Symbol]";function gw(n){return typeof n=="symbol"||qt(n)&&br(n)==yw}var Bi=gw;function xw(n,t){for(var e=-1,r=n==null?0:n.length,o=Array(r);++e<r;)o[e]=t(n[e],e,n);return o}var Zl=xw;var bw=Array.isArray,yt=bw;var vw=1/0,am=Rt?Rt.prototype:void 0,sm=am?am.toString:void 0;function lm(n){if(typeof n=="string")return n;if(yt(n))return Zl(n,lm)+"";if(Bi(n))return sm?sm.call(n):"";var t=n+"";return t=="0"&&1/n==-vw?"-0":t}var cm=lm;function Sw(n){var t=typeof n;return n!=null&&(t=="object"||t=="function")}var vr=Sw;function ww(n){return n}var um=ww;var Aw="[object AsyncFunction]",_w="[object Function]",Pw="[object GeneratorFunction]",Ow="[object Proxy]";function Cw(n){if(!vr(n))return!1;var t=br(n);return t==_w||t==Pw||t==Aw||t==Ow}var Jl=Cw;var Tw=_t["__core-js_shared__"],ec=Tw;var dm=function(){var n=/[^.]+$/.exec(ec&&ec.keys&&ec.keys.IE_PROTO||"");return n?"Symbol(src)_1."+n:""}();function Mw(n){return!!dm&&dm in n}var pm=Mw;var Iw=Function.prototype,Nw=Iw.toString;function Dw(n){if(n!=null){try{return Nw.call(n)}catch{}try{return n+""}catch{}}return""}var Eo=Dw;var Ew=/[\\^$.*+?()[\]{}|]/g,Bw=/^\[object .+?Constructor\]$/,Lw=Function.prototype,Rw=Object.prototype,Vw=Lw.toString,zw=Rw.hasOwnProperty,Gw=RegExp("^"+Vw.call(zw).replace(Ew,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Fw(n){if(!vr(n)||pm(n))return!1;var t=Jl(n)?Gw:Bw;return t.test(Eo(n))}var fm=Fw;function kw(n,t){return n?.[t]}var hm=kw;function jw(n,t){var e=hm(n,t);return fm(e)?e:void 0}var cr=jw;var Uw=cr(_t,"WeakMap"),tc=Uw;var mm=Object.create,Hw=function(){function n(){}return function(t){if(!vr(t))return{};if(mm)return mm(t);n.prototype=t;var e=new n;return n.prototype=void 0,e}}(),ym=Hw;function qw(n,t,e){switch(e.length){case 0:return n.call(t);case 1:return n.call(t,e[0]);case 2:return n.call(t,e[0],e[1]);case 3:return n.call(t,e[0],e[1],e[2])}return n.apply(t,e)}var gm=qw;function Ww(n,t){var e=-1,r=n.length;for(t||(t=Array(r));++e<r;)t[e]=n[e];return t}var xm=Ww;var $w=800,Yw=16,Xw=Date.now;function Qw(n){var t=0,e=0;return function(){var r=Xw(),o=Yw-(r-e);if(e=r,o>0){if(++t>=$w)return arguments[0]}else t=0;return n.apply(void 0,arguments)}}var bm=Qw;function Kw(n){return function(){return n}}var vm=Kw;var Zw=function(){try{var n=cr(Object,"defineProperty");return n({},"",{}),n}catch{}}(),Li=Zw;var Jw=Li?function(n,t){return Li(n,"toString",{configurable:!0,enumerable:!1,value:vm(t),writable:!0})}:um,Sm=Jw;var e2=bm(Sm),wm=e2;function t2(n,t){for(var e=-1,r=n==null?0:n.length;++e<r&&t(n[e],e,n)!==!1;);return n}var Am=t2;var r2=9007199254740991,o2=/^(?:0|[1-9]\d*)$/;function n2(n,t){var e=typeof n;return t=t??r2,!!t&&(e=="number"||e!="symbol"&&o2.test(n))&&n>-1&&n%1==0&&n<t}var Ri=n2;function i2(n,t,e){t=="__proto__"&&Li?Li(n,t,{configurable:!0,enumerable:!0,value:e,writable:!0}):n[t]=e}var rc=i2;function a2(n,t){return n===t||n!==n&&t!==t}var Vi=a2;var s2=Object.prototype,l2=s2.hasOwnProperty;function c2(n,t,e){var r=n[t];(!(l2.call(n,t)&&Vi(r,e))||e===void 0&&!(t in n))&&rc(n,t,e)}var zi=c2;function u2(n,t,e,r){var o=!e;e||(e={});for(var i=-1,a=t.length;++i<a;){var s=t[i],l=r?r(e[s],n[s],s,e,n):void 0;l===void 0&&(l=n[s]),o?rc(e,s,l):zi(e,s,l)}return e}var io=u2;var _m=Math.max;function d2(n,t,e){return t=_m(t===void 0?n.length-1:t,0),function(){for(var r=arguments,o=-1,i=_m(r.length-t,0),a=Array(i);++o<i;)a[o]=r[t+o];o=-1;for(var s=Array(t+1);++o<t;)s[o]=r[o];return s[t]=e(a),gm(n,this,s)}}var Pm=d2;var p2=9007199254740991;function f2(n){return typeof n=="number"&&n>-1&&n%1==0&&n<=p2}var Gi=f2;function h2(n){return n!=null&&Gi(n.length)&&!Jl(n)}var oc=h2;var m2=Object.prototype;function y2(n){var t=n&&n.constructor,e=typeof t=="function"&&t.prototype||m2;return n===e}var Fi=y2;function g2(n,t){for(var e=-1,r=Array(n);++e<n;)r[e]=t(e);return r}var Om=g2;var x2="[object Arguments]";function b2(n){return qt(n)&&br(n)==x2}var Ud=b2;var Cm=Object.prototype,v2=Cm.hasOwnProperty,S2=Cm.propertyIsEnumerable,w2=Ud(function(){return arguments}())?Ud:function(n){return qt(n)&&v2.call(n,"callee")&&!S2.call(n,"callee")},ki=w2;function A2(){return!1}var Tm=A2;var Nm=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Mm=Nm&&typeof module=="object"&&module&&!module.nodeType&&module,_2=Mm&&Mm.exports===Nm,Im=_2?_t.Buffer:void 0,P2=Im?Im.isBuffer:void 0,O2=P2||Tm,Qn=O2;var C2="[object Arguments]",T2="[object Array]",M2="[object Boolean]",I2="[object Date]",N2="[object Error]",D2="[object Function]",E2="[object Map]",B2="[object Number]",L2="[object Object]",R2="[object RegExp]",V2="[object Set]",z2="[object String]",G2="[object WeakMap]",F2="[object ArrayBuffer]",k2="[object DataView]",j2="[object Float32Array]",U2="[object Float64Array]",H2="[object Int8Array]",q2="[object Int16Array]",W2="[object Int32Array]",$2="[object Uint8Array]",Y2="[object Uint8ClampedArray]",X2="[object Uint16Array]",Q2="[object Uint32Array]",it={};it[j2]=it[U2]=it[H2]=it[q2]=it[W2]=it[$2]=it[Y2]=it[X2]=it[Q2]=!0;it[C2]=it[T2]=it[F2]=it[M2]=it[k2]=it[I2]=it[N2]=it[D2]=it[E2]=it[B2]=it[L2]=it[R2]=it[V2]=it[z2]=it[G2]=!1;function K2(n){return qt(n)&&Gi(n.length)&&!!it[br(n)]}var Dm=K2;function Z2(n){return function(t){return n(t)}}var ji=Z2;var Em=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Vs=Em&&typeof module=="object"&&module&&!module.nodeType&&module,J2=Vs&&Vs.exports===Em,Hd=J2&&Kl.process,eA=function(){try{var n=Vs&&Vs.require&&Vs.require("util").types;return n||Hd&&Hd.binding&&Hd.binding("util")}catch{}}(),Bo=eA;var Bm=Bo&&Bo.isTypedArray,tA=Bm?ji(Bm):Dm,nc=tA;var rA=Object.prototype,oA=rA.hasOwnProperty;function nA(n,t){var e=yt(n),r=!e&&ki(n),o=!e&&!r&&Qn(n),i=!e&&!r&&!o&&nc(n),a=e||r||o||i,s=a?Om(n.length,String):[],l=s.length;for(var u in n)(t||oA.call(n,u))&&!(a&&(u=="length"||o&&(u=="offset"||u=="parent")||i&&(u=="buffer"||u=="byteLength"||u=="byteOffset")||Ri(u,l)))&&s.push(u);return s}var ic=nA;function iA(n,t){return function(e){return n(t(e))}}var ac=iA;var aA=ac(Object.keys,Object),Lm=aA;var sA=Object.prototype,lA=sA.hasOwnProperty;function cA(n){if(!Fi(n))return Lm(n);var t=[];for(var e in Object(n))lA.call(n,e)&&e!="constructor"&&t.push(e);return t}var Rm=cA;function uA(n){return oc(n)?ic(n):Rm(n)}var Ui=uA;function dA(n){var t=[];if(n!=null)for(var e in Object(n))t.push(e);return t}var Vm=dA;var pA=Object.prototype,fA=pA.hasOwnProperty;function hA(n){if(!vr(n))return Vm(n);var t=Fi(n),e=[];for(var r in n)r=="constructor"&&(t||!fA.call(n,r))||e.push(r);return e}var zm=hA;function mA(n){return oc(n)?ic(n,!0):zm(n)}var Hi=mA;var yA=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,gA=/^\w*$/;function xA(n,t){if(yt(n))return!1;var e=typeof n;return e=="number"||e=="symbol"||e=="boolean"||n==null||Bi(n)?!0:gA.test(n)||!yA.test(n)||t!=null&&n in Object(t)}var Gm=xA;var bA=cr(Object,"create"),Lo=bA;function vA(){this.__data__=Lo?Lo(null):{},this.size=0}var Fm=vA;function SA(n){var t=this.has(n)&&delete this.__data__[n];return this.size-=t?1:0,t}var km=SA;var wA="__lodash_hash_undefined__",AA=Object.prototype,_A=AA.hasOwnProperty;function PA(n){var t=this.__data__;if(Lo){var e=t[n];return e===wA?void 0:e}return _A.call(t,n)?t[n]:void 0}var jm=PA;var OA=Object.prototype,CA=OA.hasOwnProperty;function TA(n){var t=this.__data__;return Lo?t[n]!==void 0:CA.call(t,n)}var Um=TA;var MA="__lodash_hash_undefined__";function IA(n,t){var e=this.__data__;return this.size+=this.has(n)?0:1,e[n]=Lo&&t===void 0?MA:t,this}var Hm=IA;function qi(n){var t=-1,e=n==null?0:n.length;for(this.clear();++t<e;){var r=n[t];this.set(r[0],r[1])}}qi.prototype.clear=Fm;qi.prototype.delete=km;qi.prototype.get=jm;qi.prototype.has=Um;qi.prototype.set=Hm;var qd=qi;function NA(){this.__data__=[],this.size=0}var qm=NA;function DA(n,t){for(var e=n.length;e--;)if(Vi(n[e][0],t))return e;return-1}var ln=DA;var EA=Array.prototype,BA=EA.splice;function LA(n){var t=this.__data__,e=ln(t,n);if(e<0)return!1;var r=t.length-1;return e==r?t.pop():BA.call(t,e,1),--this.size,!0}var Wm=LA;function RA(n){var t=this.__data__,e=ln(t,n);return e<0?void 0:t[e][1]}var $m=RA;function VA(n){return ln(this.__data__,n)>-1}var Ym=VA;function zA(n,t){var e=this.__data__,r=ln(e,n);return r<0?(++this.size,e.push([n,t])):e[r][1]=t,this}var Xm=zA;function Wi(n){var t=-1,e=n==null?0:n.length;for(this.clear();++t<e;){var r=n[t];this.set(r[0],r[1])}}Wi.prototype.clear=qm;Wi.prototype.delete=Wm;Wi.prototype.get=$m;Wi.prototype.has=Ym;Wi.prototype.set=Xm;var cn=Wi;var GA=cr(_t,"Map"),un=GA;function FA(){this.size=0,this.__data__={hash:new qd,map:new(un||cn),string:new qd}}var Qm=FA;function kA(n){var t=typeof n;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?n!=="__proto__":n===null}var Km=kA;function jA(n,t){var e=n.__data__;return Km(t)?e[typeof t=="string"?"string":"hash"]:e.map}var dn=jA;function UA(n){var t=dn(this,n).delete(n);return this.size-=t?1:0,t}var Zm=UA;function HA(n){return dn(this,n).get(n)}var Jm=HA;function qA(n){return dn(this,n).has(n)}var ey=qA;function WA(n,t){var e=dn(this,n),r=e.size;return e.set(n,t),this.size+=e.size==r?0:1,this}var ty=WA;function $i(n){var t=-1,e=n==null?0:n.length;for(this.clear();++t<e;){var r=n[t];this.set(r[0],r[1])}}$i.prototype.clear=Qm;$i.prototype.delete=Zm;$i.prototype.get=Jm;$i.prototype.has=ey;$i.prototype.set=ty;var Kn=$i;var $A="Expected a function";function Wd(n,t){if(typeof n!="function"||t!=null&&typeof t!="function")throw new TypeError($A);var e=function(){var r=arguments,o=t?t.apply(this,r):r[0],i=e.cache;if(i.has(o))return i.get(o);var a=n.apply(this,r);return e.cache=i.set(o,a)||i,a};return e.cache=new(Wd.Cache||Kn),e}Wd.Cache=Kn;var ry=Wd;var YA=500;function XA(n){var t=ry(n,function(r){return e.size===YA&&e.clear(),r}),e=t.cache;return t}var oy=XA;var QA=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,KA=/\\(\\)?/g,ZA=oy(function(n){var t=[];return n.charCodeAt(0)===46&&t.push(""),n.replace(QA,function(e,r,o,i){t.push(o?i.replace(KA,"$1"):r||e)}),t}),ny=ZA;function JA(n){return n==null?"":cm(n)}var iy=JA;function e_(n,t){return yt(n)?n:Gm(n,t)?[n]:ny(iy(n))}var Tr=e_;var t_=1/0;function r_(n){if(typeof n=="string"||Bi(n))return n;var t=n+"";return t=="0"&&1/n==-t_?"-0":t}var pn=r_;function o_(n,t){t=Tr(t,n);for(var e=0,r=t.length;n!=null&&e<r;)n=n[pn(t[e++])];return e&&e==r?n:void 0}var sc=o_;function n_(n,t){for(var e=-1,r=t.length,o=n.length;++e<r;)n[o+e]=t[e];return n}var Yi=n_;var ay=Rt?Rt.isConcatSpreadable:void 0;function i_(n){return yt(n)||ki(n)||!!(ay&&n&&n[ay])}var sy=i_;function ly(n,t,e,r,o){var i=-1,a=n.length;for(e||(e=sy),o||(o=[]);++i<a;){var s=n[i];t>0&&e(s)?t>1?ly(s,t-1,e,r,o):Yi(o,s):r||(o[o.length]=s)}return o}var cy=ly;function a_(n){var t=n==null?0:n.length;return t?cy(n,1):[]}var uy=a_;function s_(n){return wm(Pm(n,void 0,uy),n+"")}var lc=s_;var l_=ac(Object.getPrototypeOf,Object),Xi=l_;var c_="[object Object]",u_=Function.prototype,d_=Object.prototype,dy=u_.toString,p_=d_.hasOwnProperty,f_=dy.call(Object);function h_(n){if(!qt(n)||br(n)!=c_)return!1;var t=Xi(n);if(t===null)return!0;var e=p_.call(t,"constructor")&&t.constructor;return typeof e=="function"&&e instanceof e&&dy.call(e)==f_}var py=h_;function m_(n,t,e){var r=-1,o=n.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 i=Array(o);++r<o;)i[r]=n[r+t];return i}var fy=m_;function y_(){this.__data__=new cn,this.size=0}var hy=y_;function g_(n){var t=this.__data__,e=t.delete(n);return this.size=t.size,e}var my=g_;function x_(n){return this.__data__.get(n)}var yy=x_;function b_(n){return this.__data__.has(n)}var gy=b_;var v_=200;function S_(n,t){var e=this.__data__;if(e instanceof cn){var r=e.__data__;if(!un||r.length<v_-1)return r.push([n,t]),this.size=++e.size,this;e=this.__data__=new Kn(r)}return e.set(n,t),this.size=e.size,this}var xy=S_;function Qi(n){var t=this.__data__=new cn(n);this.size=t.size}Qi.prototype.clear=hy;Qi.prototype.delete=my;Qi.prototype.get=yy;Qi.prototype.has=gy;Qi.prototype.set=xy;var Ki=Qi;function w_(n,t){return n&&io(t,Ui(t),n)}var by=w_;function A_(n,t){return n&&io(t,Hi(t),n)}var vy=A_;var _y=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Sy=_y&&typeof module=="object"&&module&&!module.nodeType&&module,__=Sy&&Sy.exports===_y,wy=__?_t.Buffer:void 0,Ay=wy?wy.allocUnsafe:void 0;function P_(n,t){if(t)return n.slice();var e=n.length,r=Ay?Ay(e):new n.constructor(e);return n.copy(r),r}var Py=P_;function O_(n,t){for(var e=-1,r=n==null?0:n.length,o=0,i=[];++e<r;){var a=n[e];t(a,e,n)&&(i[o++]=a)}return i}var Oy=O_;function C_(){return[]}var cc=C_;var T_=Object.prototype,M_=T_.propertyIsEnumerable,Cy=Object.getOwnPropertySymbols,I_=Cy?function(n){return n==null?[]:(n=Object(n),Oy(Cy(n),function(t){return M_.call(n,t)}))}:cc,Zi=I_;function N_(n,t){return io(n,Zi(n),t)}var Ty=N_;var D_=Object.getOwnPropertySymbols,E_=D_?function(n){for(var t=[];n;)Yi(t,Zi(n)),n=Xi(n);return t}:cc,uc=E_;function B_(n,t){return io(n,uc(n),t)}var My=B_;function L_(n,t,e){var r=t(n);return yt(n)?r:Yi(r,e(n))}var dc=L_;function R_(n){return dc(n,Ui,Zi)}var zs=R_;function V_(n){return dc(n,Hi,uc)}var pc=V_;var z_=cr(_t,"DataView"),fc=z_;var G_=cr(_t,"Promise"),hc=G_;var F_=cr(_t,"Set"),mc=F_;var Iy="[object Map]",k_="[object Object]",Ny="[object Promise]",Dy="[object Set]",Ey="[object WeakMap]",By="[object DataView]",j_=Eo(fc),U_=Eo(un),H_=Eo(hc),q_=Eo(mc),W_=Eo(tc),Zn=br;(fc&&Zn(new fc(new ArrayBuffer(1)))!=By||un&&Zn(new un)!=Iy||hc&&Zn(hc.resolve())!=Ny||mc&&Zn(new mc)!=Dy||tc&&Zn(new tc)!=Ey)&&(Zn=function(n){var t=br(n),e=t==k_?n.constructor:void 0,r=e?Eo(e):"";if(r)switch(r){case j_:return By;case U_:return Iy;case H_:return Ny;case q_:return Dy;case W_:return Ey}return t});var Ro=Zn;var $_=Object.prototype,Y_=$_.hasOwnProperty;function X_(n){var t=n.length,e=new n.constructor(t);return t&&typeof n[0]=="string"&&Y_.call(n,"index")&&(e.index=n.index,e.input=n.input),e}var Ly=X_;var Q_=_t.Uint8Array,Ji=Q_;function K_(n){var t=new n.constructor(n.byteLength);return new Ji(t).set(new Ji(n)),t}var ea=K_;function Z_(n,t){var e=t?ea(n.buffer):n.buffer;return new n.constructor(e,n.byteOffset,n.byteLength)}var Ry=Z_;var J_=/\w*$/;function eP(n){var t=new n.constructor(n.source,J_.exec(n));return t.lastIndex=n.lastIndex,t}var Vy=eP;var zy=Rt?Rt.prototype:void 0,Gy=zy?zy.valueOf:void 0;function tP(n){return Gy?Object(Gy.call(n)):{}}var Fy=tP;function rP(n,t){var e=t?ea(n.buffer):n.buffer;return new n.constructor(e,n.byteOffset,n.length)}var ky=rP;var oP="[object Boolean]",nP="[object Date]",iP="[object Map]",aP="[object Number]",sP="[object RegExp]",lP="[object Set]",cP="[object String]",uP="[object Symbol]",dP="[object ArrayBuffer]",pP="[object DataView]",fP="[object Float32Array]",hP="[object Float64Array]",mP="[object Int8Array]",yP="[object Int16Array]",gP="[object Int32Array]",xP="[object Uint8Array]",bP="[object Uint8ClampedArray]",vP="[object Uint16Array]",SP="[object Uint32Array]";function wP(n,t,e){var r=n.constructor;switch(t){case dP:return ea(n);case oP:case nP:return new r(+n);case pP:return Ry(n,e);case fP:case hP:case mP:case yP:case gP:case xP:case bP:case vP:case SP:return ky(n,e);case iP:return new r;case aP:case cP:return new r(n);case sP:return Vy(n);case lP:return new r;case uP:return Fy(n)}}var jy=wP;function AP(n){return typeof n.constructor=="function"&&!Fi(n)?ym(Xi(n)):{}}var Uy=AP;var _P="[object Map]";function PP(n){return qt(n)&&Ro(n)==_P}var Hy=PP;var qy=Bo&&Bo.isMap,OP=qy?ji(qy):Hy,Wy=OP;var CP="[object Set]";function TP(n){return qt(n)&&Ro(n)==CP}var $y=TP;var Yy=Bo&&Bo.isSet,MP=Yy?ji(Yy):$y,Xy=MP;var IP=1,NP=2,DP=4,Qy="[object Arguments]",EP="[object Array]",BP="[object Boolean]",LP="[object Date]",RP="[object Error]",Ky="[object Function]",VP="[object GeneratorFunction]",zP="[object Map]",GP="[object Number]",Zy="[object Object]",FP="[object RegExp]",kP="[object Set]",jP="[object String]",UP="[object Symbol]",HP="[object WeakMap]",qP="[object ArrayBuffer]",WP="[object DataView]",$P="[object Float32Array]",YP="[object Float64Array]",XP="[object Int8Array]",QP="[object Int16Array]",KP="[object Int32Array]",ZP="[object Uint8Array]",JP="[object Uint8ClampedArray]",eO="[object Uint16Array]",tO="[object Uint32Array]",ot={};ot[Qy]=ot[EP]=ot[qP]=ot[WP]=ot[BP]=ot[LP]=ot[$P]=ot[YP]=ot[XP]=ot[QP]=ot[KP]=ot[zP]=ot[GP]=ot[Zy]=ot[FP]=ot[kP]=ot[jP]=ot[UP]=ot[ZP]=ot[JP]=ot[eO]=ot[tO]=!0;ot[RP]=ot[Ky]=ot[HP]=!1;function yc(n,t,e,r,o,i){var a,s=t&IP,l=t&NP,u=t&DP;if(e&&(a=o?e(n,r,o,i):e(n)),a!==void 0)return a;if(!vr(n))return n;var c=yt(n);if(c){if(a=Ly(n),!s)return xm(n,a)}else{var d=Ro(n),p=d==Ky||d==VP;if(Qn(n))return Py(n,s);if(d==Zy||d==Qy||p&&!o){if(a=l||p?{}:Uy(n),!s)return l?My(n,vy(a,n)):Ty(n,by(a,n))}else{if(!ot[d])return o?n:{};a=jy(n,d,s)}}i||(i=new Ki);var f=i.get(n);if(f)return f;i.set(n,a),Xy(n)?n.forEach(function(y){a.add(yc(y,t,e,y,n,i))}):Wy(n)&&n.forEach(function(y,g){a.set(g,yc(y,t,e,g,n,i))});var h=u?l?pc:zs:l?Hi:Ui,m=c?void 0:h(n);return Am(m||n,function(y,g){m&&(g=y,y=n[g]),zi(a,g,yc(y,t,e,g,n,i))}),a}var gc=yc;var rO=1,oO=4;function nO(n){return gc(n,rO|oO)}var Vo=nO;var iO="__lodash_hash_undefined__";function aO(n){return this.__data__.set(n,iO),this}var Jy=aO;function sO(n){return this.__data__.has(n)}var eg=sO;function xc(n){var t=-1,e=n==null?0:n.length;for(this.__data__=new Kn;++t<e;)this.add(n[t])}xc.prototype.add=xc.prototype.push=Jy;xc.prototype.has=eg;var tg=xc;function lO(n,t){for(var e=-1,r=n==null?0:n.length;++e<r;)if(t(n[e],e,n))return!0;return!1}var rg=lO;function cO(n,t){return n.has(t)}var og=cO;var uO=1,dO=2;function pO(n,t,e,r,o,i){var a=e&uO,s=n.length,l=t.length;if(s!=l&&!(a&&l>s))return!1;var u=i.get(n),c=i.get(t);if(u&&c)return u==t&&c==n;var d=-1,p=!0,f=e&dO?new tg:void 0;for(i.set(n,t),i.set(t,n);++d<s;){var h=n[d],m=t[d];if(r)var y=a?r(m,h,d,t,n,i):r(h,m,d,n,t,i);if(y!==void 0){if(y)continue;p=!1;break}if(f){if(!rg(t,function(g,b){if(!og(f,b)&&(h===g||o(h,g,e,r,i)))return f.push(b)})){p=!1;break}}else if(!(h===m||o(h,m,e,r,i))){p=!1;break}}return i.delete(n),i.delete(t),p}var bc=pO;function fO(n){var t=-1,e=Array(n.size);return n.forEach(function(r,o){e[++t]=[o,r]}),e}var ng=fO;function hO(n){var t=-1,e=Array(n.size);return n.forEach(function(r){e[++t]=r}),e}var ig=hO;var mO=1,yO=2,gO="[object Boolean]",xO="[object Date]",bO="[object Error]",vO="[object Map]",SO="[object Number]",wO="[object RegExp]",AO="[object Set]",_O="[object String]",PO="[object Symbol]",OO="[object ArrayBuffer]",CO="[object DataView]",ag=Rt?Rt.prototype:void 0,$d=ag?ag.valueOf:void 0;function TO(n,t,e,r,o,i,a){switch(e){case CO:if(n.byteLength!=t.byteLength||n.byteOffset!=t.byteOffset)return!1;n=n.buffer,t=t.buffer;case OO:return!(n.byteLength!=t.byteLength||!i(new Ji(n),new Ji(t)));case gO:case xO:case SO:return Vi(+n,+t);case bO:return n.name==t.name&&n.message==t.message;case wO:case _O:return n==t+"";case vO:var s=ng;case AO:var l=r&mO;if(s||(s=ig),n.size!=t.size&&!l)return!1;var u=a.get(n);if(u)return u==t;r|=yO,a.set(n,t);var c=bc(s(n),s(t),r,o,i,a);return a.delete(n),c;case PO:if($d)return $d.call(n)==$d.call(t)}return!1}var sg=TO;var MO=1,IO=Object.prototype,NO=IO.hasOwnProperty;function DO(n,t,e,r,o,i){var a=e&MO,s=zs(n),l=s.length,u=zs(t),c=u.length;if(l!=c&&!a)return!1;for(var d=l;d--;){var p=s[d];if(!(a?p in t:NO.call(t,p)))return!1}var f=i.get(n),h=i.get(t);if(f&&h)return f==t&&h==n;var m=!0;i.set(n,t),i.set(t,n);for(var y=a;++d<l;){p=s[d];var g=n[p],b=t[p];if(r)var w=a?r(b,g,p,t,n,i):r(g,b,p,n,t,i);if(!(w===void 0?g===b||o(g,b,e,r,i):w)){m=!1;break}y||(y=p=="constructor")}if(m&&!y){var A=n.constructor,S=t.constructor;A!=S&&"constructor"in n&&"constructor"in t&&!(typeof A=="function"&&A instanceof A&&typeof S=="function"&&S instanceof S)&&(m=!1)}return i.delete(n),i.delete(t),m}var lg=DO;var EO=1,cg="[object Arguments]",ug="[object Array]",vc="[object Object]",BO=Object.prototype,dg=BO.hasOwnProperty;function LO(n,t,e,r,o,i){var a=yt(n),s=yt(t),l=a?ug:Ro(n),u=s?ug:Ro(t);l=l==cg?vc:l,u=u==cg?vc:u;var c=l==vc,d=u==vc,p=l==u;if(p&&Qn(n)){if(!Qn(t))return!1;a=!0,c=!1}if(p&&!c)return i||(i=new Ki),a||nc(n)?bc(n,t,e,r,o,i):sg(n,t,l,e,r,o,i);if(!(e&EO)){var f=c&&dg.call(n,"__wrapped__"),h=d&&dg.call(t,"__wrapped__");if(f||h){var m=f?n.value():n,y=h?t.value():t;return i||(i=new Ki),o(m,y,e,r,i)}}return p?(i||(i=new Ki),lg(n,t,e,r,o,i)):!1}var pg=LO;function fg(n,t,e,r,o){return n===t?!0:n==null||t==null||!qt(n)&&!qt(t)?n!==n&&t!==t:pg(n,t,e,r,fg,o)}var hg=fg;function RO(n,t){return n!=null&&t in Object(n)}var mg=RO;function VO(n,t,e){t=Tr(t,n);for(var r=-1,o=t.length,i=!1;++r<o;){var a=pn(t[r]);if(!(i=n!=null&&e(n,a)))break;n=n[a]}return i||++r!=o?i:(o=n==null?0:n.length,!!o&&Gi(o)&&Ri(a,o)&&(yt(n)||ki(n)))}var yg=VO;function zO(n,t){return n!=null&&yg(n,t,mg)}var gg=zO;function GO(n){var t=n==null?0:n.length;return t?n[t-1]:void 0}var xg=GO;function FO(n,t){return t.length<2?n:sc(n,fy(t,0,-1))}var bg=FO;function kO(n,t){return hg(n,t)}var Yd=kO;function jO(n,t){return t=Tr(t,n),n=bg(n,t),n==null||delete n[pn(xg(t))]}var vg=jO;function UO(n){return py(n)?void 0:n}var Sg=UO;var HO=1,qO=2,WO=4,$O=lc(function(n,t){var e={};if(n==null)return e;var r=!1;t=Zl(t,function(i){return i=Tr(i,n),r||(r=i.length>1),i}),io(n,pc(n),e),r&&(e=gc(e,HO|qO|WO,Sg));for(var o=t.length;o--;)vg(e,t[o]);return e}),ta=$O;function YO(n,t,e,r){if(!vr(n))return n;t=Tr(t,n);for(var o=-1,i=t.length,a=i-1,s=n;s!=null&&++o<i;){var l=pn(t[o]),u=e;if(l==="__proto__"||l==="constructor"||l==="prototype")return n;if(o!=a){var c=s[l];u=r?r(c,l,s):void 0,u===void 0&&(u=vr(c)?c:Ri(t[o+1])?[]:{})}zi(s,l,u),s=s[l]}return n}var wg=YO;function XO(n,t,e){for(var r=-1,o=t.length,i={};++r<o;){var a=t[r],s=sc(n,a);e(s,a)&&wg(i,Tr(a,n),s)}return i}var Ag=XO;function QO(n,t){return Ag(n,t,function(e,r){return gg(n,r)})}var _g=QO;var KO=lc(function(n,t){return n==null?{}:_g(n,t)}),jr=KO;var xe=class{modifyById(t,e){let r=this;if(r[t]===void 0)throw new Error("not expected");{let i={...r,[t]:e};return Object.setPrototypeOf(i,xe.prototype),i}}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:i,data:a}=t,s={...e,[i]:a};return Object.setPrototypeOf(s,xe.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 i={...e};return Object.setPrototypeOf(i,xe.prototype),delete i[r],{data:i,actual:t,reverse:{type:1,id:r,data:o}}}}return null}};function Gs(n){if(n.deepFreeze!==void 0){n.deepFreeze(n);return}let t=Object.getOwnPropertyNames(n);for(let e of t){let r=n[e];r&&typeof r=="object"&&Gs(r)}return Object.freeze(n)}function Pg(n,t){let e=0;for(;e<n.length&&e<t.length;){if(n[e]<t[e])return-1;if(n[e]>t[e])return 1;e+=1}return e!==t.length?-1:e!==n.length?1:0}var ra=class extends Error{};function Sc(n){let t={...n};return Object.setPrototypeOf(t,Object.getPrototypeOf(n)),t}function ao(n,t,e){if(n===void 0?t===void 0?(n=0,t=10):n=t-10:t===void 0&&(t=n+10),n>t){let i=n;n=t,t=i}let r=[],o=1/(e+1);for(let i=0;i<e;i++){let a=n+(t-n)*(i+.75+Math.random()*.5)*o;r.push(a)}return r}function oa(n){return n instanceof Uint8Array||n instanceof Uint16Array||n instanceof Uint32Array||n instanceof Int8Array||n instanceof Int16Array||n instanceof Int32Array||n instanceof Float32Array||n instanceof Float64Array}function Og(){return typeof process<"u"}function Cg(n,t){for(let e of n)t(e.id,e.data)!==!0&&Cg(e.children,t)}function Tg(n,t){if(t(n.id,n.data)!==!0)for(let e of n.children)Tg(e,t)}var Je=class extends Array{constructor(...e){super(...e);Object.setPrototypeOf(this,Je.prototype)}deepFreeze(){let e=0;for(;e<this.length;)Gs(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&&Tg(o,r)}}traverse(e){Cg(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 i=this.parent(e),a=this.childrenArray(i),s=a.findIndex(c=>c.id===e);if(s<0)throw new Error("not expected");let l=a[s];return a=[...a],a[s]={...l,data:r},this.modifyArrayBy(i,a)}}modifyArrayBy(e,r){let o=e,i=r;for(;o!==null;){let s=i,l=o;if(o=this.parent(o),o===void 0)throw new Error;i=this.childrenArray(o);let u=i.findIndex(c=>c.id===l);if(u<0)throw new Error;i=[...i],i[u]={...i[u],children:s}}Object.setPrototypeOf(i,Je.prototype);let a=i;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:i,data:a,children:s}=e;if(r!==null&&this.get(r)===void 0)return null;if(this.checkDuplicatedIdRec(e))return null;{let l=r,u=this.childrenArray(l),c={fi:o,id:i,data:a,children:s};return u=[...u,c],u.sort((p,f)=>p.fi-f.fi),e.localIndex=u.indexOf(c),{data:this.modifyArrayBy(l,u),actual:e,reverse:{type:8,id:i}}}}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 i=this.childrenArray(o),a=i.findIndex(u=>u.id===r);e.localIndex=a,i=[...i];let s=i.splice(a,1)[0];return{data:this.modifyArrayBy(o,i),actual:e,reverse:{type:7,...s,parent:o}}}}moveOp(e){let{parent:r,fi:o,id:i}=e;if(r!==null&&this.get(r)===void 0)return this.deleteOp({type:8,id:i});if(r!==null){let f=r;for(;f!==null;){if(f===void 0)throw new Error;if(f===i)throw new ra("cyclic tree");f=this.parent(f)}}let a=this.parent(i);if(a===void 0)return null;let s=a,l=this.childrenArray(a),u=l.findIndex(f=>f.id===i);l=[...l];let c=l.splice(u,1)[0],d=this.modifyArrayBy(a,l);a=r,l=d.childrenArray(a);let p=c.fi;return c={...c,fi:o},l=[...l,c],l.sort((f,h)=>f.fi-h.fi),e.localIndex=l.indexOf(c),d=d.modifyArrayBy(a,l),{data:d,actual:e,reverse:{type:9,parent:s,fi:p,id:i}}}previous(e,r){if(r===null){let i=this.childrenArray(e);return i.length===0?null:i[i.length-1].id}let o=null;for(let i of this.childrenArray(e)){if(i.id===r)return o;o=i.id}return null}traverseSortNext(e){let r=this.parent(e);if(r!==void 0){let o=this.childrenArray(r),i=o.findIndex(a=>a.id===e)+1;if(i<o.length)return o[i].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),i=o.findIndex(a=>a.id===e)-1;return i>=0?this.traverseSortPrevious(o[i].id):r}}getAllSorted(e){let r=[];for(let o of e){let i=this.getWithSortKey(o.id);i!==void 0&&r.push({...o,...i})}r.sort((o,i)=>Pg(o.sortKey,i.sortKey));for(let o of r)delete o.sortKey;return r}getWithSortKey(e){var r=e;let o=[],i=this.get(r),a=i;if(i!==void 0){for(;r;)o.splice(0,0,i.fi),r=this.parent(r),r!==null&&(i=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 i=this.childrenArray(e);if(r===null){if(i.length===0)return ao(0,o,o);{let a=i[0].fi;return ao(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=i.find(l=>l.fi>a.fi);if(s===void 0){let l=i[i.length-1].fi;return ao(l,l+o,o)}else return ao(a.fi,s.fi,o)}}};var na;(t=>{function n(e,r){if(r.type!==0)return null;if(Array.isArray(e)){let o=r.props,i={},a=[...e],s=!1;if(o)for(let l of Object.keys(o)){let u=parseInt(l);if(isNaN(u))throw new Error("wrong index");i[l]=a[u],a[u]=o[l],s=!0}return s?{data:a,actual:r,reverse:{type:0,props:i}}:null}else{let o=r.props,i={},a={...e},s=!1;if(o)for(let l of Object.keys(o)){i[l]=a[l];let u=o[l];u===void 0?delete a[l]:a[l]=u,s=!0}return s?{data:a,actual:r,reverse:{type:0,props:i}}:null}}t.runOp=n})(na||(na={}));var Se=class extends Array{constructor(...e){super(...e);Object.setPrototypeOf(this,Se.prototype)}deepFreeze(){let e=0;for(;e<this.length;)Gs(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 i=this,a=i.findIndex(u=>u.id===e);if(a<0)throw new Error("not expected");let s=i[a];return i=[...i],i[a]={...s,data:r},this.modifyArrayBy(i)}}modifyArrayBy(e){Object.setPrototypeOf(e,Se.prototype);let r=e;return Og()||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:i}=e,a=this,s={fi:r,id:o,data:i};return a=[...a,s],a.sort((u,c)=>u.fi-c.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,i=o.findIndex(l=>l.id===r);if(i===-1)return null;e.localIndex=i,o=[...o];let a=o.splice(i,1)[0];return{data:this.modifyArrayBy(o),actual:e,reverse:{type:4,...a}}}moveOp(e){let{fi:r,id:o}=e,i=this;i=[...i];let a=i.findIndex(c=>c.id===o);if(a===-1)return null;let s=i[a].fi,l={...i[a],fi:r};return i[a]=l,i.sort((c,d)=>c.fi-d.fi),e.localIndex=i.indexOf(l),{data:this.modifyArrayBy(i),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 ao(0,r,r);{let i=o[0].fi;return ao(i-r,i,r)}}else{let i=this.get(e);if(i===void 0)throw new Error("illegal args");let a=o.find(s=>s.fi>i.fi);if(a===void 0){let s=o[o.length-1].fi;return ao(s,s+r,r)}else return ao(i.fi,a.fi,r)}}};function ia(n){return n&&typeof n=="object"&&n instanceof et}var et=class{unusedFunOverridesTable(t){}runOp(t){let e=[],r=this,o=0,i={};for(;o<t.path.length;){if(e.push(r),r=r===void 0?void 0:r[t.path[o]],r!==void 0&&!ia(r))return null;o+=1}r=r?Sc(r):new et;for(let[l,u]of Object.entries(t.props)){let c=r[l];i[l]=c,u===void 0?delete r[l]:r[l]=u}for(;o>0;){if(Object.keys(r).length===0){let l=e[o-1];l&&(r=Sc(l),delete r[t.path[o-1]])}else{let l=e[o-1];if(l){let u=Sc(l);u[t.path[o-1]]=r,r=u}else{let u=new et;u[t.path[o-1]]=r,r=u}}o-=1}let a=Object.setPrototypeOf(r,et.prototype),s={...t,props:i};return{data:a,actual:t,reverse:s}}},so;(r=>{function n(o,i){return Fs(o,i)??o}r.apply=n;function t(o,i){return Qd(o,i)}r.merge=t;function e(o,i){let a=0,s=i.path,l=o;for(;a<s.length&&l!==void 0;){if(l=lt.zoomOnce(l,s[a]),l===void 0)return i;if(!ia(l))return;a+=1}if(l===void 0)return i;if(!!ia(l))if(i.type===0){let u={...i.props};for(let c of Object.keys(l))delete u[c];return{...i,props:u}}else if(i.type===1||i.type===4||i.type===7){let u=Xd([i],l);return u?(console.log(u),u):i}else return i}r.filterOp=e})(so||(so={}));function Xd(n,t){if(t===void 0)return;let e=!1,r=n.map(o=>{let i=o.id,a=Fs(o.data,t[i]);if(e=e||a!==void 0,a===void 0&&(a=o.data),o.children){let s=Xd(o.children,t);return s!==void 0?e=!0:s=o.children,{...o,id:i,data:a,children:s}}else return{...o,id:i,data:a}});if(e)return r}function ZO(n,t){if(t===void 0)return;let e=!1,r=n.map(o=>{let i=o.id,a=Fs(o.data,t[i]);return e=e||a!==void 0,a===void 0&&(a=o.data),{...o,id:i,data:a}});if(e)return Object.setPrototypeOf(r,Object.getPrototypeOf(n)),r}function Fs(n,t){if(!ia(t))return t;if(n instanceof Je){let e=Xd(n,t);return e!==void 0&&Object.setPrototypeOf(e,Object.getPrototypeOf(n)),e}else{if(n instanceof Se)return ZO(n,t);if(Array.isArray(n)){let e=!1,r=n.map((o,i)=>{let a=Fs(o,t[i]);return e=e||a!==void 0,a===void 0&&(a=o),a});return e?(Object.setPrototypeOf(r,Object.getPrototypeOf(n)),r):void 0}else{if(n instanceof et)return Qd(n,t);if(n&&typeof n=="object"){let e={},r=!1;for(let[o,i]of Object.entries(n)){let a=Fs(i,t[o]);r=r||a!==void 0,a===void 0&&(a=i),e[o]=a}return r?(Object.setPrototypeOf(e,Object.getPrototypeOf(n)),e):void 0}}}}function Qd(n,t){if(n===void 0)return t;if(t===void 0)return n;if(!ia(t))return t;if(!ia(n))return so.apply(n,t);let e=new Set;for(let o of Object.keys(n))e.add(o);for(let o of Object.keys(t))e.add(o);let r=new et;for(let o of e){let i=Qd(n===void 0?void 0:n[o],t===void 0?void 0:t[o]);r[o]=i}return r}function Mg(n,t){let e={cur:[],result:[],len:0};return n=ks(n,t,e)??n,[n,e.result]}function wc(n,t){return n===null?null:(n.cur[n.len]=t,n.len+=1,n)}function Ac(n){n&&(n.len-=1)}function JO(n){if(n===null)return null;n.result.push(n.cur.slice(0,n.len))}function Ig(n,t,e){let r=!1,o=n.map(i=>{let a=i.id,s=t[a];if(s!==void 0&&typeof s=="string"&&(r=!0,a=s,e!==null))throw new Error("not supported");let l=ks(i.data,t,wc(e,a));Ac(e),r=r||l!==void 0,l===void 0&&(l=i.data);let u=Ig(i.children,t,e);return u!==void 0?r=!0:u=i.children,{...i,id:a,data:l,children:u}});if(r)return o}function eC(n,t,e){let r=!1,o=n.map(i=>{let a=i.id,s=t[a];if(s!==void 0&&typeof s=="string"&&(r=!0,a=s,e!==null))throw new Error("not supported");let l=ks(i.data,t,wc(e,a));return Ac(e),r=r||l!==void 0,l===void 0&&(l=i.data),{...i,id:a,data:l}});if(r)return Object.setPrototypeOf(o,Object.getPrototypeOf(n)),o}function ks(n,t,e){if(n instanceof Je){let r=Ig(n,t,e);return r!==void 0&&Object.setPrototypeOf(r,Object.getPrototypeOf(n)),r}else{if(n instanceof Se)return eC(n,t,e);if(Array.isArray(n)){let r=!1,o=n.map((i,a)=>{let s=ks(i,t,wc(e,a));return Ac(e),r=r||s!==void 0,s===void 0&&(s=i),s});return r?(Object.setPrototypeOf(o,Object.getPrototypeOf(n)),o):void 0}else if(n&&typeof n=="object"&&!oa(n)){let r={},o=!1;for(let[i,a]of Object.entries(n))if(i!=="name"){let s=t[i];if(typeof s=="string"){if(e!==null)throw new Error("not supported");o=!0,i=s}let l=ks(a,t,wc(e,i));Ac(e),o=o||l!==void 0,l===void 0&&(l=a),r[i]=l}else r[i]=a;return o?(Object.setPrototypeOf(r,Object.getPrototypeOf(n)),r):void 0}else if(typeof n=="string"){let r=t[n];return r!==void 0&&JO(e),r}else return}}var aa;(t=>{function n(e,r){let o=lt.zoom(r,e.path);if(typeof o=="object"){let i={};for(let a of Object.keys(e.props))i[a]=o[a];return{...e,props:i}}else return{...e,props:{}}}t.replaceProps=n})(aa||(aa={}));var ct;(s=>{function n(l,u){return{...l,path:l.path.slice(u)}}s.drop=n;function t(l,u){return e(l,u)?.data??l}s.applySimple=t;function e(l,u){let c=u.path;for(var d=[];;){let p;if(l instanceof et&&u.type===0&&(p=l.runOp({...u,path:c.slice(d.length)}),p===null&&(p=void 0)),p===void 0&&d.length===c.length&&(l instanceof Je||l instanceof Se||l instanceof xe?p=l.runOp(u):p=na.runOp(l,u)),p!==void 0)if(p!==null){let m=p.data;for(let y=d.length-1;y>=0;y--){let g=c[y],b=d[y];if(b instanceof Je){if(typeof g=="number")throw new Error("illegal arg");m=b.modifyById(g,m)}else if(b instanceof Se){if(typeof g=="number")throw new Error("illegal arg");m=b.modifyById(g,m)}else if(b instanceof xe){if(typeof g=="number")throw new Error("illegal arg");m=b.modifyById(g,m)}else if(b instanceof et){let w={...b,[g]:m};m=Object.setPrototypeOf(w,et.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:c},reverse:{...p.reverse,path:c}}}else return null;let f=c[d.length],h;if(l instanceof Je){if(typeof f=="number")throw new Error("");h=l.get(f)?.data}else if(l instanceof Se){if(typeof f=="number")throw new Error("");h=l.get(f)?.data}else l!==null&&(h=l[f]);if(h!==void 0)d.push(l),l=h;else return null}}s.apply=e;function r(l,u){for(let c=0;c<l.length&&c<u.length;c++)if(l[c]!==u[c])return!0;return!1}s.pathDisjoint=r;function o(l,u){if(l.length!==u.length)return!1;for(let c=0;c<l.length;c++)if(l[c]!==u[c])return!1;return!0}s.pathEq=o;function i(l,u){return r(l.path,u.path)}s.commutative=i;function a(l,u){return l.type===0&&u.type===0&&o(l.path,u.path)?Object.keys(l.props).every(c=>u.props[c]!==void 0):!1}s.subsumed=a})(ct||(ct={}));var js;(l=>{function n(){return[]}l.empty=n;function t(u,c){let d=[];for(let p of u){let[f,...h]=p.path;f===c&&d.push({...p,path:h})}return d}l.removePrefix=t;function e(u,c){return u.map(d=>({...d,path:[c,...d.path]}))}l.addPrefix=e;function r(u,c){return[...u,...c]}l.concat=r;function o(u,c){return[...u.filter(p=>!c.some(f=>ct.subsumed(p,f))),...c]}l.compress=o;function i(u,c){return u.every(d=>c.every(p=>ct.commutative(d,p)))}l.commutative=i;function a(u,c){for(let d of c){let p=s(u,d);p!==null&&(u=p.data)}return u}l.applyAll=a;function s(u,c){var d=u;let p=[],f=[];for(let h of c)try{if(h.type===3||h.type===5&&h.path[h.path.length-1]==="variables"){let m,y,g;if(h.type===3?(m=lt.zoom(d,[...h.path,h.id]),g=ct.apply(d,{...h,type:2})):(m=lt.zoom(d,[...h.path,h.id,"value"]),g=ct.apply(d,h)),g!==null){d=g.data;let[b,w]=Mg(d,{[h.id]:m});d=b;for(let A=0;A<w.length;A++){let S=w[A],P=S.pop();if(typeof P=="number"){let O=[P];for(let D=A+1;D<w.length;D++){let N=w[D],T=N[N.length-1];if(typeof T=="number"&&lt.equal(S,N.slice(0,N.length-1)))O.push(T),w.splice(D,1);else break}let x=lt.zoom(d,S);y=x.map((D,N)=>O.includes(N)?h.id:D),m=x,P=S.pop()}else{if(P==="alphaOverride"||P==="alpha"){m/=100;let O=m,x=lt.zoom(d,S.slice(0,S.length-2)),D=x.layers.map(N=>N.id===S[S.length-1]?{...N,data:{...N.data,[P]:O}}:N);Object.setPrototypeOf(D,Object.getPrototypeOf(x.layers)),x.layers=D}y=h.id}p.push({type:0,path:S,props:{[P]:m}}),f.push({type:0,path:S,props:{[P]:y}})}f.push(g.reverse),p.push(g.actual)}}else{let m=ct.apply(d,h);m!==null&&(p.push(m.actual),d=m.data,f.push(m.reverse))}}catch(m){if(m instanceof ra)return null;throw m}return{data:d,actual:p,reverse:f.reverse()}}l.apply=s})(js||(js={}));var Ng=Symbol(),tC=Symbol(),Pc=Symbol(),Jn=class{reportOp(t,e,r=[]){let o=this;if(e===null)return;o._current=e.data;let i=r;for(;!(o instanceof _c);){let a=o._path,s=o._current;if(a!==""&&i.splice(0,0,a),o=o._parent,o===null)return;o.update(a,s)}o.push(i,t,e.actual,e.reverse)}deleteChildren(t){if(this._children){let e=this._children[t];if(e){let r=e[Pc];r&&r(),delete this._children[t]}}}},Zd=class extends Jn{constructor(t,e,r){super(),this._parent=t,this._path=e,this._current=r}update(t,e){if(Array.isArray(this._current)){if(typeof t=="string"&&(t=parseInt(t),isNaN(t)))throw new Error("Invalid path");this._current=[...this._current],this._current[t]=e}else this._current={...this._current,[t]:e}}runOp(t){this.reportOp(t,na.runOp(this._current,t),t.path)}},Jd=class extends Jn{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,xe.prototype)}runOp(t){this.reportOp(t,this._current.runOp(t))}},Dg={get(n,t){if(t===Pc)return()=>{n._parent=null};if(t===Ng)return n._current;if(t===tC)return n;let{_current:e,_children:r}=n;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 i=e[t],a=Oc(n,t,i);return a!==i?(r===void 0&&(r={},n._children=r),r[t]=a,a):i},has(n,t){return t in n._current},ownKeys(n){return Reflect.ownKeys(n._current)},defineProperty(){throw Error("not supported")},getPrototypeOf(n){return Object.getPrototypeOf(n._current)},setPrototypeOf(){throw Error("not supported")},getOwnPropertyDescriptor(n,t){let e=n._current,r=Reflect.getOwnPropertyDescriptor(e,t);return r&&{writable:!0,configurable:!0,enumerable:r.enumerable,value:e[t]}}},rC={...Dg,set(n,t,e){let r={type:0,props:{[t]:ut(e)??e}};return n.deleteChildren(t),n.runOp(r),!0},deleteProperty(n,t){let e={type:0,props:{[t]:void 0}};return n.deleteChildren(t),n.runOp(e),!0}},oC={...Dg,set(n,t,e){return e===void 0?this.deleteProperty(n,t):(n.deleteChildren(t),n.runOp({type:1,id:t,data:e})),!0},deleteProperty(n,t){return n.runOp({type:2,id:t}),!0}},sa=class extends Jn{constructor(t,e,r){super(),this._children={},this._parent=t,this._path=e,this._current=r,this[Pc]=()=>{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 i=e.get(t)?.data,a=Oc(this,t,i);return a!==i?(r===void 0&&(r={},this._children=r),r[t]=a,a):i}add(t,e,r,o,i){this.runOp({type:7,parent:t,fi:e,id:r,data:o,children:i})}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 i=0;i<r.length;i++){let a=r[i];this.add(t,o[i],a.id,a.data,a.children)}}insertBefore(t,e,r){let o=this._current.insertBeforeHelper(t,e,r.length);for(let i=0;i<r.length;i++){let a=r[i];this.add(t,o[i],a.id,a.data,a.children)}}moveAfter(t,e,r){let o=this._current.insertAfterHelper(t,e,r.length);for(let i=0;i<r.length;i++){let a=r[i];this.move(t,o[i],a)}}moveBefore(t,e,r){let o=this._current.insertBeforeHelper(t,e,r.length);for(let i=0;i<r.length;i++){let a=r[i];this.move(t,o[i],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)}},la=class extends Jn{constructor(t,e,r){super(),this._children={},this._parent=t,this._path=e,this._current=r,this[Pc]=()=>{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,i=this._current[r].fi;t(this.data(this._current[r].id),o,i)}}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 i=e.get(t)?.data,a=Oc(this,t,i);return a!==i?(r===void 0&&(r={},this._children=r),r[t]=a,a):i}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 i=e[o];this.add(r[o],i.id,i.data)}}insertBefore(t,e){let r=this._current.insertBeforeHelper(t,e.length);for(let o=0;o<e.length;o++){let i=e[o];this.add(r[o],i.id,i.data)}}moveAfter(t,e){let r=this._current.insertAfterHelper(t,e.length);for(let o=0;o<e.length;o++){let i=e[o];this.move(r[o],i)}}moveBefore(t,e){let r=this._current.insertBeforeHelper(t,e.length);for(let o=0;o<e.length;o++){let i=e[o];this.move(r[o],i)}}delete(t){this.deleteChildren(t),this.runOp({type:5,id:t})}};function Kd(n,t,e){if(n.length>0){let r=n[n.length-1];if(r.type===0&&t.type===0&&lt.equal(r.path,e)){Object.assign(r.props,t.props);return}}n.push({...t,path:e})}var _c=class extends Jn{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){Kd(this.ts,e,t),Kd(this.actual,r,t),Kd(this.reverse,o,t)}result(){return{data:this._current,ts:this.ts,actual:this.actual,reverse:this.reverse.reverse()}}};function Oc(n,t,e){return e instanceof Je?new sa(n,t,e):e instanceof Se?new la(n,t,e):e instanceof xe?new Proxy(new Jd(n,t,e),oC):e!==null&&typeof e=="object"?oa(e)?e:new Proxy(new Zd(n,t,e),rC):e}function ep(n){let t=new _c(n);return[Oc(t,"",n),t]}function fn(n,t){let[e,r]=ep(n);return t(e),r.result()}function ut(n){return n instanceof sa||n instanceof la?n._current:n!==null&&typeof n=="object"?n[Ng]:n}var lt;(o=>{function n(i,a){if(a.length===i.length)for(var s=0;s<i.length;){if(i[s]!==a[s])return!1;s+=1}else return!1;return!0}o.equal=n;function t(i,a,s){let l=r(s,i);if(l!==void 0&&typeof l=="object"&&l!==null){let u={...a};return Object.keys(l).forEach(c=>{delete u[c]}),u}else return a}o.removeOverridden=t;function e(i,a){if((i instanceof Je||i instanceof sa)&&typeof a=="string")return i.data(a);if((i instanceof Se||i instanceof la)&&typeof a=="string")return i.data(a);if(typeof a=="number"&&Array.isArray(i))return i[a];if(typeof a=="string"&&typeof i=="object"&&i!==null)return i[a]}o.zoomOnce=e;function r(i,a,s=0){for(;s<a.length&&i!==void 0;)i=e(i,a[s]),s+=1;return i}o.zoom=r})(lt||(lt={}));function Eg(n,t){let e=[];if(t.length===n.length)for(var r=0;r<n.length;){if(t[r]==="*")e.push(n[r]);else if(n[r]!==t[r])return null;r+=1}else return null;return e}function Le(n,t){let e=[];if(t.length<=n.length)for(var r=0;r<t.length;){if(t[r]==="*")e.push(n[r]);else if(n[r]!==t[r])return null;r+=1}else return null;return e}var Cc=class{},Us=class extends Cc{constructor(e){super();this.id=e}},Hs=class extends Cc{constructor(e){super();this.data=e}};var rp;try{rp=new TextDecoder}catch{}var de,mn,G=0;var kg=[],op=kg,np=0,ur={},We,hn,Mr=0,lo=0,Sr,zo,or=[],Ye,Bg={useRecords:!1,mapsAsObjects:!0},qs=class{},ap=new qs;ap.name="MessagePack 0xC1";var ca=!1,co=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(de)return Wg(()=>(Mc(),this?this.unpack(t,e):co.prototype.unpack.call(Bg,t,e)));mn=e>-1?e:t.length,G=0,np=0,lo=0,hn=null,op=kg,Sr=null,de=t;try{Ye=t.dataView||(t.dataView=new DataView(t.buffer,t.byteOffset,t.byteLength))}catch(r){throw de=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 co){if(ur=this,this.structures)return We=this.structures,Tc();(!We||We.length>0)&&(We=[])}else ur=Bg,(!We||We.length>0)&&(We=[]);return Tc()}unpackMultiple(t,e){let r,o=0;try{ca=!0;let i=t.length,a=this?this.unpack(t,i):Dc.unpack(t,i);if(e){for(e(a);G<i;)if(o=G,e(Tc())===!1)return}else{for(r=[a];G<i;)o=G,r.push(Tc());return r}}catch(i){throw i.lastPosition=o,i.values=r,i}finally{ca=!1,Mc()}}_mergeStructures(t,e){t=t||[];for(let r=0,o=t.length;r<o;r++){let i=t[r];i&&(i.isShared=!0,r>=32&&(i.highByte=r-32>>5))}t.sharedLength=t.length;for(let r in e||[])if(r>=0){let o=t[r],i=e[r];i&&(o&&((t.restoreStructures||(t.restoreStructures=[]))[r]=o),t[r]=i)}return this.structures=t}decode(t,e){return this.unpack(t,e)}};function Tc(){try{if(!ur.trusted&&!ca){let t=We.sharedLength||0;t<We.length&&(We.length=t)}let n=gt();if(G==mn)We.restoreStructures&&Lg(),We=null,de=null,zo&&(zo=null);else if(G>mn){let t=new Error("Unexpected end of MessagePack data");throw t.incomplete=!0,t}else if(!ca)throw new Error("Data read, but end of buffer not reached");return n}catch(n){throw We.restoreStructures&&Lg(),Mc(),(n instanceof RangeError||n.message.startsWith("Unexpected end of buffer"))&&(n.incomplete=!0),n}}function Lg(){for(let n in We.restoreStructures)We[n]=We.restoreStructures[n];We.restoreStructures=null}function gt(){let n=de[G++];if(n<160)if(n<128){if(n<64)return n;{let t=We[n&63]||ur.getStructures&&jg()[n&63];return t?(t.read||(t.read=sp(t,n&63)),t.read()):n}}else if(n<144)if(n-=128,ur.mapsAsObjects){let t={};for(let e=0;e<n;e++)t[Hg()]=gt();return t}else{let t=new Map;for(let e=0;e<n;e++)t.set(gt(),gt());return t}else{n-=144;let t=new Array(n);for(let e=0;e<n;e++)t[e]=gt();return t}else if(n<192){let t=n-160;if(lo>=G)return hn.slice(G-Mr,(G+=t)-Mr);if(lo==0&&mn<140){let e=t<16?lp(t):Ug(t);if(e!=null)return e}return ip(t)}else{let t;switch(n){case 192:return null;case 193:return Sr?(t=gt(),t>0?Sr[1].slice(Sr.position1,Sr.position1+=t):Sr[0].slice(Sr.position0,Sr.position0-=t)):ap;case 194:return!1;case 195:return!0;case 196:return tp(de[G++]);case 197:return t=Ye.getUint16(G),G+=2,tp(t);case 198:return t=Ye.getUint32(G),G+=4,tp(t);case 199:return ei(de[G++]);case 200:return t=Ye.getUint16(G),G+=2,ei(t);case 201:return t=Ye.getUint32(G),G+=4,ei(t);case 202:if(t=Ye.getFloat32(G),ur.useFloat32>2){let e=Nc[(de[G]&127)<<1|de[G+1]>>7];return G+=4,(e*t+(t>0?.5:-.5)>>0)/e}return G+=4,t;case 203:return t=Ye.getFloat64(G),G+=8,t;case 204:return de[G++];case 205:return t=Ye.getUint16(G),G+=2,t;case 206:return t=Ye.getUint32(G),G+=4,t;case 207:return ur.int64AsNumber?(t=Ye.getUint32(G)*4294967296,t+=Ye.getUint32(G+4)):t=Ye.getBigUint64(G),G+=8,t;case 208:return Ye.getInt8(G++);case 209:return t=Ye.getInt16(G),G+=2,t;case 210:return t=Ye.getInt32(G),G+=4,t;case 211:return ur.int64AsNumber?(t=Ye.getInt32(G)*4294967296,t+=Ye.getUint32(G+4)):t=Ye.getBigInt64(G),G+=8,t;case 212:if(t=de[G++],t==114)return Fg(de[G++]&63);{let e=or[t];if(e)return e.read?(G++,e.read(gt())):e.noBuffer?(G++,e()):e(de.subarray(G,++G));throw new Error("Unknown extension "+t)}case 213:return t=de[G],t==114?(G++,Fg(de[G++]&63,de[G++])):ei(2);case 214:return ei(4);case 215:return ei(8);case 216:return ei(16);case 217:return t=de[G++],lo>=G?hn.slice(G-Mr,(G+=t)-Mr):iC(t);case 218:return t=Ye.getUint16(G),G+=2,lo>=G?hn.slice(G-Mr,(G+=t)-Mr):aC(t);case 219:return t=Ye.getUint32(G),G+=4,lo>=G?hn.slice(G-Mr,(G+=t)-Mr):sC(t);case 220:return t=Ye.getUint16(G),G+=2,Vg(t);case 221:return t=Ye.getUint32(G),G+=4,Vg(t);case 222:return t=Ye.getUint16(G),G+=2,zg(t);case 223:return t=Ye.getUint32(G),G+=4,zg(t);default:if(n>=224)return n-256;if(n===void 0){let e=new Error("Unexpected end of MessagePack data");throw e.incomplete=!0,e}throw new Error("Unknown MessagePack token "+n)}}}var nC=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function sp(n,t){function e(){if(e.count++>2){let o=n.read=new Function("r","return function(){return {"+n.map(i=>nC.test(i)?i+":r()":"["+JSON.stringify(i)+"]:r()").join(",")+"}}")(gt);return n.highByte===0&&(n.read=Rg(t,n.read)),o()}let r={};for(let o=0,i=n.length;o<i;o++){let a=n[o];r[a]=gt()}return r}return e.count=0,n.highByte===0?Rg(t,e):e}var Rg=(n,t)=>function(){let e=de[G++];if(e===0)return t();let r=n<32?-(n+(e<<5)):n+(e<<5),o=We[r]||jg()[r];if(!o)throw new Error("Record id is not defined for "+r);return o.read||(o.read=sp(o,n)),o.read()};function jg(){let n=Wg(()=>(de=null,ur.getStructures()));return We=ur._mergeStructures(n,We)}var ip=Ic,iC=Ic,aC=Ic,sC=Ic;function Ic(n){let t;if(n<16&&(t=lp(n)))return t;if(n>64&&rp)return rp.decode(de.subarray(G,G+=n));let e=G+n,r=[];for(t="";G<e;){let o=de[G++];if((o&128)===0)r.push(o);else if((o&224)===192){let i=de[G++]&63;r.push((o&31)<<6|i)}else if((o&240)===224){let i=de[G++]&63,a=de[G++]&63;r.push((o&31)<<12|i<<6|a)}else if((o&248)===240){let i=de[G++]&63,a=de[G++]&63,s=de[G++]&63,l=(o&7)<<18|i<<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+=Vt.apply(String,r),r.length=0)}return r.length>0&&(t+=Vt.apply(String,r)),t}function Vg(n){let t=new Array(n);for(let e=0;e<n;e++)t[e]=gt();return t}function zg(n){if(ur.mapsAsObjects){let t={};for(let e=0;e<n;e++)t[Hg()]=gt();return t}else{let t=new Map;for(let e=0;e<n;e++)t.set(gt(),gt());return t}}var Vt=String.fromCharCode;function Ug(n){let t=G,e=new Array(n);for(let r=0;r<n;r++){let o=de[G++];if((o&128)>0){G=t;return}e[r]=o}return Vt.apply(String,e)}function lp(n){if(n<4)if(n<2){if(n===0)return"";{let t=de[G++];if((t&128)>1){G-=1;return}return Vt(t)}}else{let t=de[G++],e=de[G++];if((t&128)>0||(e&128)>0){G-=2;return}if(n<3)return Vt(t,e);let r=de[G++];if((r&128)>0){G-=3;return}return Vt(t,e,r)}else{let t=de[G++],e=de[G++],r=de[G++],o=de[G++];if((t&128)>0||(e&128)>0||(r&128)>0||(o&128)>0){G-=4;return}if(n<6){if(n===4)return Vt(t,e,r,o);{let i=de[G++];if((i&128)>0){G-=5;return}return Vt(t,e,r,o,i)}}else if(n<8){let i=de[G++],a=de[G++];if((i&128)>0||(a&128)>0){G-=6;return}if(n<7)return Vt(t,e,r,o,i,a);let s=de[G++];if((s&128)>0){G-=7;return}return Vt(t,e,r,o,i,a,s)}else{let i=de[G++],a=de[G++],s=de[G++],l=de[G++];if((i&128)>0||(a&128)>0||(s&128)>0||(l&128)>0){G-=8;return}if(n<10){if(n===8)return Vt(t,e,r,o,i,a,s,l);{let u=de[G++];if((u&128)>0){G-=9;return}return Vt(t,e,r,o,i,a,s,l,u)}}else if(n<12){let u=de[G++],c=de[G++];if((u&128)>0||(c&128)>0){G-=10;return}if(n<11)return Vt(t,e,r,o,i,a,s,l,u,c);let d=de[G++];if((d&128)>0){G-=11;return}return Vt(t,e,r,o,i,a,s,l,u,c,d)}else{let u=de[G++],c=de[G++],d=de[G++],p=de[G++];if((u&128)>0||(c&128)>0||(d&128)>0||(p&128)>0){G-=12;return}if(n<14){if(n===12)return Vt(t,e,r,o,i,a,s,l,u,c,d,p);{let f=de[G++];if((f&128)>0){G-=13;return}return Vt(t,e,r,o,i,a,s,l,u,c,d,p,f)}}else{let f=de[G++],h=de[G++];if((f&128)>0||(h&128)>0){G-=14;return}if(n<15)return Vt(t,e,r,o,i,a,s,l,u,c,d,p,f,h);let m=de[G++];if((m&128)>0){G-=15;return}return Vt(t,e,r,o,i,a,s,l,u,c,d,p,f,h,m)}}}}}function tp(n){return ur.copyBuffers?Uint8Array.prototype.slice.call(de,G,G+=n):de.subarray(G,G+=n)}function ei(n){let t=de[G++];if(or[t])return or[t](de.subarray(G,G+=n));throw new Error("Unknown extension type "+t)}var Gg=new Array(4096);function Hg(){let n=de[G++];if(n>=160&&n<192){if(n=n-160,lo>=G)return hn.slice(G-Mr,(G+=n)-Mr);if(!(lo==0&&mn<180))return ip(n)}else return G--,gt();let t=(n<<5^(n>1?Ye.getUint16(G):n>0?de[G]:0))&4095,e=Gg[t],r=G,o=G+n-3,i,a=0;if(e&&e.bytes==n){for(;r<o;){if(i=Ye.getUint32(r),i!=e[a++]){r=1879048192;break}r+=4}for(o+=3;r<o;)if(i=de[r++],i!=e[a++]){r=1879048192;break}if(r===o)return G=r,e.string;o-=3,r=G}for(e=[],Gg[t]=e,e.bytes=n;r<o;)i=Ye.getUint32(r),e.push(i),r+=4;for(o+=3;r<o;)i=de[r++],e.push(i);let s=n<16?lp(n):Ug(n);return s!=null?e.string=s:e.string=ip(n)}var Fg=(n,t)=>{var e=gt();let r=n;t!==void 0&&(n=n<32?-((t<<5)+n):(t<<5)+n,e.highByte=t);let o=We[n];return o&&o.isShared&&((We.restoreStructures||(We.restoreStructures=[]))[n]=o),We[n]=e,e.read=sp(e,r),e.read()},qg=typeof self=="object"?self:global;or[0]=()=>{};or[0].noBuffer=!0;or[101]=()=>{let n=gt();return(qg[n[0]]||Error)(n[1])};or[105]=n=>{let t=Ye.getUint32(G-4);zo||(zo=new Map);let e=de[G],r;e>=144&&e<160||e==220||e==221?r=[]:r={};let o={target:r};zo.set(t,o);let i=gt();return o.used?Object.assign(r,i):(o.target=i,i)};or[112]=n=>{let t=Ye.getUint32(G-4),e=zo.get(t);return e.used=!0,e.target};or[115]=()=>new Set(gt());var cp=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(n=>n+"Array");or[116]=n=>{let t=n[0],e=cp[t];if(!e)throw new Error("Could not find typed array for code "+t);return new qg[e](Uint8Array.prototype.slice.call(n,1).buffer)};or[120]=()=>{let n=gt();return new RegExp(n[0],n[1])};or[98]=n=>{let t=(n[0]<<24)+(n[1]<<16)+(n[2]<<8)+n[3],e=G;G+=t-4,Sr=[gt(),gt()],Sr.position0=0,Sr.position1=0;let r=G;G=e;try{return gt()}finally{G=r}};or[255]=n=>n.length==4?new Date((n[0]*16777216+(n[1]<<16)+(n[2]<<8)+n[3])*1e3):n.length==8?new Date(((n[0]<<22)+(n[1]<<14)+(n[2]<<6)+(n[3]>>2))/1e6+((n[3]&3)*4294967296+n[4]*16777216+(n[5]<<16)+(n[6]<<8)+n[7])*1e3):n.length==12?new Date(((n[0]<<24)+(n[1]<<16)+(n[2]<<8)+n[3])/1e6+((n[4]&128?-281474976710656:0)+n[6]*1099511627776+n[7]*4294967296+n[8]*16777216+(n[9]<<16)+(n[10]<<8)+n[11])*1e3):new Date("invalid");function Wg(n){let t=mn,e=G,r=np,o=Mr,i=lo,a=hn,s=op,l=zo,u=Sr,c=new Uint8Array(de.slice(0,mn)),d=We,p=We.slice(0,We.length),f=ur,h=ca,m=n();return mn=t,G=e,np=r,Mr=o,lo=i,hn=a,op=s,zo=l,Sr=u,de=c,ca=h,We=d,We.splice(0,We.length,...p),ur=f,Ye=new DataView(de.buffer,de.byteOffset,de.byteLength),m}function Mc(){de=null,zo=null,We=null}function $g(n){n.unpack?or[n.type]=n.unpack:or[n.type]=n}var Nc=new Array(147);for(let n=0;n<256;n++)Nc[n]=+("1e"+Math.floor(45.15-n*.30103));var Dc=new co({useRecords:!1}),lC=Dc.unpack,cC=Dc.unpackMultiple,uC=Dc.unpack,Ec={NEVER:0,ALWAYS:1,DECIMAL_ROUND:3,DECIMAL_FIT:4},dC=new Float32Array(1),TU=new Uint8Array(dC.buffer,0,4);var Bc;try{Bc=new TextEncoder}catch{}var Lc,dp,Rc=typeof Buffer<"u",up=Rc?Buffer.allocUnsafeSlow:Uint8Array,Kg=Rc?Buffer:Uint8Array,Yg=Rc?4294967296:2144337920,K,vt,j=0,uo,po=null,pC=/[\u0080-\uFFFF]/,Ws=Symbol("record-id"),ti=class extends co{constructor(t){super(t),this.offset=0;let e,r,o,i,a,s,l=0,u=Kg.prototype.utf8Write?function(x,D,N){return K.utf8Write(x,D,N)}:Bc&&Bc.encodeInto?function(x,D){return Bc.encodeInto(x,K.subarray(D)).written}:!1,c=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,A=0;this.pack=this.encode=function(x,D){if(K||(K=new up(8192),vt=new DataView(K.buffer,0,8192),j=0),uo=K.length-10,uo-j<2048?(K=new up(K.length),vt=new DataView(K.buffer,0,K.length),uo=K.length-10,j=0):j=j+7&2147483640,r=j,s=c.structuredClone?new Map:null,c.bundleStrings?(po=["",""],K[j++]=214,K[j++]=98,po.position=j-r,j+=4):po=null,o=c.structures,o){o.uninitialized&&(o=c._mergeStructures(c.getStructures()));let N=o.sharedLength||0;if(N>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 T=0;T<N;T++){let I=o[T];if(!I)continue;let E,B=o.transitions;for(let R=0,F=I.length;R<F;R++){let V=I[R];E=B[V],E||(E=B[V]=Object.create(null)),B=E}B[Ws]=T+64}l=N}d||(o.nextId=N+64)}i&&(i=!1),a=o||[];try{if(S(x),po){vt.setUint32(po.position+r,j-po.position-r);let N=po;po=null,S(N[0]),S(N[1])}if(c.offset=j,s&&s.idsToInsert){j+=s.idsToInsert.length*6,j>uo&&O(j),c.offset=j;let N=hC(K.subarray(r,j),s.idsToInsert);return s=null,N}return D&Jg?(K.start=r,K.end=j,K):K.subarray(r,j)}finally{if(o){if(A<10&&A++,w>1e4)o.transitions=null,A=0,w=0,b.length>0&&(b=[]);else if(b.length>0&&!d){for(let N=0,T=b.length;N<T;N++)b[N][Ws]=0;b=[]}if(i&&c.saveStructures){let N=o.sharedLength||f;o.length>N&&(o=o.slice(0,N));let T=K.subarray(r,j);return c.saveStructures(o,l)===!1?(c._mergeStructures(c.getStructures()),c.pack(x)):(l=N,T)}}D&SC&&(j=r)}};let S=x=>{j>uo&&(K=O(j));var D=typeof x,N;if(D==="string"){let T=x.length;if(po&&T>=8&&T<4096){let B=pC.test(x);po[B?0:1]+=x,K[j++]=193,S(B?-T:T);return}let I;T<32?I=1:T<256?I=2:T<65536?I=3:I=5;let E=T*3;if(j+E>uo&&(K=O(j+E)),T<64||!u){let B,R,F,V=j+I;for(B=0;B<T;B++)R=x.charCodeAt(B),R<128?K[V++]=R:R<2048?(K[V++]=R>>6|192,K[V++]=R&63|128):(R&64512)===55296&&((F=x.charCodeAt(B+1))&64512)===56320?(R=65536+((R&1023)<<10)+(F&1023),B++,K[V++]=R>>18|240,K[V++]=R>>12&63|128,K[V++]=R>>6&63|128,K[V++]=R&63|128):(K[V++]=R>>12|224,K[V++]=R>>6&63|128,K[V++]=R&63|128);N=V-j-I}else N=u(x,j+I,E);N<32?K[j++]=160|N:N<256?(I<2&&K.copyWithin(j+2,j+1,j+1+N),K[j++]=217,K[j++]=N):N<65536?(I<3&&K.copyWithin(j+3,j+2,j+2+N),K[j++]=218,K[j++]=N>>8,K[j++]=N&255):(I<5&&K.copyWithin(j+5,j+3,j+3+N),K[j++]=219,vt.setUint32(j,N),j+=4),j+=N}else if(D==="number")if(x>>>0===x)x<64?K[j++]=x:x<256?(K[j++]=204,K[j++]=x):x<65536?(K[j++]=205,K[j++]=x>>8,K[j++]=x&255):(K[j++]=206,vt.setUint32(j,x),j+=4);else if(x>>0===x)x>=-32?K[j++]=256+x:x>=-128?(K[j++]=208,K[j++]=x+256):x>=-32768?(K[j++]=209,vt.setInt16(j,x),j+=2):(K[j++]=210,vt.setInt32(j,x),j+=4);else{let T;if((T=this.useFloat32)>0&&x<4294967296&&x>=-2147483648){K[j++]=202,vt.setFloat32(j,x);let I;if(T<4||(I=x*Nc[(K[j]&127)<<1|K[j+1]>>7])>>0===I){j+=4;return}else j--}K[j++]=203,vt.setFloat64(j,x),j+=8}else if(D==="object")if(!x)K[j++]=192;else{if(s){let I=s.get(x);if(I){if(!I.id){let E=s.idsToInsert||(s.idsToInsert=[]);I.id=E.push(I)}K[j++]=214,K[j++]=112,vt.setUint32(j,I.id),j+=4;return}else s.set(x,{offset:j-r})}let T=x.constructor;if(T===Object)P(x,!0);else if(T===Array){N=x.length,N<16?K[j++]=144|N:N<65536?(K[j++]=220,K[j++]=N>>8,K[j++]=N&255):(K[j++]=221,vt.setUint32(j,N),j+=4);for(let I=0;I<N;I++)S(x[I])}else if(T===Map){N=x.size,N<16?K[j++]=128|N:N<65536?(K[j++]=222,K[j++]=N>>8,K[j++]=N&255):(K[j++]=223,vt.setUint32(j,N),j+=4);for(let[I,E]of x)S(I),S(E)}else{for(let I=0,E=Lc.length;I<E;I++){let B=dp[I];if(x instanceof B){let R=Lc[I];if(R.write){R.type&&(K[j++]=212,K[j++]=R.type,K[j++]=0),S(R.write.call(this,x));return}let F=K,V=vt,q=j;K=null;let k;try{k=R.pack.call(this,x,U=>(K=F,F=null,j+=U,j>uo&&O(j),{target:K,targetView:vt,position:j-U}),S)}finally{F&&(K=F,vt=V,j=q,uo=K.length-10)}k&&(k.length+j>uo&&O(k.length+j),j=fC(k,K,j,R.type));return}}P(x,!x.hasOwnProperty)}}else if(D==="boolean")K[j++]=x?195:194;else if(D==="bigint"){if(x<BigInt(1)<<BigInt(63)&&x>=-(BigInt(1)<<BigInt(63)))K[j++]=211,vt.setBigInt64(j,x);else if(x<BigInt(1)<<BigInt(64)&&x>0)K[j++]=207,vt.setBigUint64(j,x);else if(this.largeBigIntToFloat)K[j++]=203,vt.setFloat64(j,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");j+=8}else if(D==="undefined")this.encodeUndefinedAsNil?K[j++]=192:(K[j++]=212,K[j++]=0,K[j++]=0);else if(D==="function")S(this.writeFunction&&this.writeFunction());else throw new Error("Unknown type: "+D)},P=this.useRecords===!1?this.variableMapSize?x=>{let D=Object.keys(x),N=D.length;N<16?K[j++]=128|N:N<65536?(K[j++]=222,K[j++]=N>>8,K[j++]=N&255):(K[j++]=223,vt.setUint32(j,N),j+=4);let T;for(let I=0;I<N;I++)S(T=D[I]),S(x[T])}:(x,D)=>{K[j++]=222;let N=j-r;j+=2;let T=0;for(let I in x)(D||x.hasOwnProperty(I))&&(S(I),S(x[I]),T++);K[N+++r]=T>>8,K[N+r]=T&255}:x=>{let D=Object.keys(x),N,T=a.transitions||(a.transitions=Object.create(null)),I=0;for(let B=0,R=D.length;B<R;B++){let F=D[B];N=T[F],N||(N=T[F]=Object.create(null),I++),T=N}let E=T[Ws];if(E)E>=96&&m?(K[j++]=((E-=96)&31)+96,K[j++]=E>>5):K[j++]=E;else{E=a.nextId,E||(E=64),E<y&&this.shouldShareStructure&&!this.shouldShareStructure(D)?(E=a.nextOwnId,E<g||(E=y),a.nextOwnId=E+1):(E>=g&&(E=y),a.nextId=E+1);let B=D.highByte=E>=96&&m?E-96>>5:-1;T[Ws]=E,a[E-64]=D,E<y?(D.isShared=!0,a.sharedLength=E-63,i=!0,B>=0?(K[j++]=(E&31)+96,K[j++]=B):K[j++]=E):(B>=0?(K[j++]=213,K[j++]=114,K[j++]=(E&31)+96,K[j++]=B):(K[j++]=212,K[j++]=114,K[j++]=E),I&&(w+=A*I),b.length>=h&&(b.shift()[Ws]=0),b.push(T),S(D))}for(let B=0,R=D.length;B<R;B++)S(x[D[B]])},O=x=>{let D;if(x>16777216){if(x-r>Yg)throw new Error("Packed buffer would be larger than maximum buffer size");D=Math.min(Yg,Math.round(Math.max((x-r)*(x>67108864?1.25:2),4194304)/4096)*4096)}else D=(Math.max(x-r<<2,K.length-1)>>12)+1<<12;let N=new up(D);return vt=new DataView(N.buffer,0,D),K.copy?K.copy(N,0,r,x):N.set(K.slice(r,x)),j-=r,r=0,uo=N.length-10,K=N}}useBuffer(t){K=t,vt=new DataView(K.buffer,K.byteOffset,K.byteLength),j=0}};dp=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,qs];Lc=[{pack(n,t,e){let r=n.getTime()/1e3;if((this.useTimestamp32||n.getMilliseconds()===0)&&r>=0&&r<4294967296){let{target:o,targetView:i,position:a}=t(6);o[a++]=214,o[a++]=255,i.setUint32(a,r)}else if(r>0&&r<17179869184){let{target:o,targetView:i,position:a}=t(10);o[a++]=215,o[a++]=255,i.setUint32(a,n.getMilliseconds()*4e6+(r/1e3/4294967296>>0)),i.setUint32(a+4,r)}else if(isNaN(r)){if(this.onInvalidDate)return t(0),e(this.onInvalidDate());let{target:o,targetView:i,position:a}=t(3);o[a++]=212,o[a++]=255,o[a++]=255}else{let{target:o,targetView:i,position:a}=t(15);o[a++]=199,o[a++]=12,o[a++]=255,i.setUint32(a,n.getMilliseconds()*1e6),i.setBigInt64(a+4,BigInt(Math.floor(r)))}}},{pack(n,t,e){let r=Array.from(n),{target:o,position:i}=t(this.structuredClone?3:0);this.structuredClone&&(o[i++]=212,o[i++]=115,o[i++]=0),e(r)}},{pack(n,t,e){let{target:r,position:o}=t(this.structuredClone?3:0);this.structuredClone&&(r[o++]=212,r[o++]=101,r[o++]=0),e([n.name,n.message])}},{pack(n,t,e){let{target:r,position:o}=t(this.structuredClone?3:0);this.structuredClone&&(r[o++]=212,r[o++]=120,r[o++]=0),e([n.source,n.flags])}},{pack(n,t){this.structuredClone?Xg(n,16,t):Qg(Rc?Buffer.from(n):new Uint8Array(n),t)}},{pack(n,t){let e=n.constructor;e!==Kg&&this.structuredClone?Xg(n,cp.indexOf(e.name),t):Qg(n,t)}},{pack(n,t){let{target:e,position:r}=t(1);e[r]=193}}];function Xg(n,t,e,r){let o=n.byteLength;if(o+1<256){var{target:i,position:a}=e(4+o);i[a++]=199,i[a++]=o+1}else if(o+1<65536){var{target:i,position:a}=e(5+o);i[a++]=200,i[a++]=o+1>>8,i[a++]=o+1&255}else{var{target:i,position:a,targetView:s}=e(7+o);i[a++]=201,s.setUint32(a,o+1),a+=4}i[a++]=116,i[a++]=t,i.set(new Uint8Array(n.buffer,n.byteOffset,n.byteLength),a)}function Qg(n,t){let e=n.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:i}=t(e+5);r[o++]=198,i.setUint32(o,e),o+=4}r.set(n,o)}function fC(n,t,e,r){let o=n.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(n,e),e+=o,e}function hC(n,t){let e,r=t.length*6,o=n.length-r;for(t.sort((i,a)=>i.offset>a.offset?1:-1);e=t.pop();){let i=e.offset,a=e.id;n.copyWithin(i+r,i,o),r-=6;let s=i+r;n[s++]=214,n[s++]=105,n[s++]=a>>24,n[s++]=a>>16&255,n[s++]=a>>8&255,n[s++]=a&255,o=i}return n}function yn(n){if(n.Class){if(!n.pack&&!n.write)throw new Error("Extension has no pack or write function");if(n.pack&&!n.type)throw new Error("Extension has no type (numeric code to identify the extension)");dp.unshift(n.Class),Lc.unshift(n)}$g(n)}var Zg=new ti({useRecords:!1}),mC=Zg.pack,yC=Zg.pack;var{NEVER:gC,ALWAYS:xC,DECIMAL_ROUND:bC,DECIMAL_FIT:vC}=Ec,Jg=512,SC=1024;var e0=new ti({structuredClone:!0});yn({Class:xe.prototype.constructor,type:1,write(n){return{...n}},read(n){return Object.setPrototypeOf(n,xe.prototype),n}});yn({Class:Se.prototype.constructor,type:2,write(n){return[...n]},read(n){return Object.setPrototypeOf(n,Se.prototype),n}});yn({Class:Je.prototype.constructor,type:3,write(n){return[...n]},read(n){return Object.setPrototypeOf(n,Je.prototype),n}});yn({Class:Us.prototype.constructor,type:4,write(n){return n.id},read(n){return new Us(n)}});yn({Class:Hs.prototype.constructor,type:5,write(n){return n.data},read(n){return new Hs(n)}});yn({Class:et.prototype.constructor,type:6,write(n){return{...n}},read(n){return Object.setPrototypeOf(n,et.prototype),n}});function wC(n){var t=0;if(n.length===0)return t;for(let e=0;e<n.length;e++){let r=n[e];t=(t<<5)-t+r,t=t&t}return t}function pp(n){if(oa(n))return n;if(Array.isArray(n))return n.map(pp);if(typeof n=="object"&&n!==null){let t={};for(let e of Object.keys(n).sort())t[e]=pp(n[e]);return Object.setPrototypeOf(t,Object.getPrototypeOf(n)),t}else return n}var Vc;(r=>{function n(o){return e0.pack(o)}r.serialize=n;function t(o){return e0.unpack(o)}r.deserialize=t;function e(o){return wC(n(pp(o))).toString()}r.checksum=e})(Vc||(Vc={}));var bn="personal camera",vn="a218fcc3-276b-49b9-b485-49037fd14f5f",i0=2960946,St=5526619;var ua;(f=>{function n(h,m){return h[0]===m[0]&&h[1]===m[1]}f.isEqual=n;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 i(h,m){return[h[0]/m[0],h[1]/m[1]]}f.divide=i;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 u(h,m){return[h[0]*m,h[1]*m]}f.scalarMultiply=u;function c(h,m,y){let g=f.sub(m,h),b=f.sub(y,h),w=f.dot(g,b)/f.dot(g,g),A=f.scalarMultiply(g,w);return f.add(h,A)}f.projectionOnto=c;function d(h,m,y){return s(h,c(h,m,y))}f.projectionOntoDistance=d;function p(h,m){return[(h[0]+m[0])*.5,(h[1]+m[1])*.5]}f.center=p})(ua||(ua={}));var gn;(s=>{function n(l,u){return l[0]===u[0]&&l[1]===u[1]&&l[2]===u[2]}s.isEqual=n;function t(l,u){return[l[0]+u[0],l[1]+u[1],l[2]+u[2]]}s.add=t;function e(l,u){return[l[0]-u[0],l[1]-u[1],l[2]-u[2]]}s.sub=e;function r(l,u){return[l[0]/u[0],l[1]/u[1],l[2]/u[2]]}s.div=r;function o(l,u){return[l[0]*u[0],l[1]*u[1],l[2]*u[2]]}s.mul=o;function i(l,u){return Math.hypot(l[0]-u[0],l[1]-u[1],l[2]-u[2])}s.dist=i;function a(l,u,c){return[l[0]+(u[0]-l[0])*c,l[1]+(u[1]-l[1])*c,l[2]+(u[2]-l[2])*c]}s.lerp=a})(gn||(gn={}));var t0;(e=>{function n(r,o){return r[0]===o[0]&&r[1]===o[1]&&r[2]===o[2]&&r[3]===o[3]}e.isEqual=n;function t(r,o,i){return[r[0]+(o[0]-r[0])*i,r[1]+(o[1]-r[1])*i,r[2]+(o[2]-r[2])*i,r[3]+(o[3]-r[3])*i]}e.lerp=t})(t0||(t0={}));var xn;(o=>{o.identity=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];function t(i,a){for(let s=0;s<16;s++)if(i[s]!==a[s])return!1;return!0}o.isEqual=t;function e(i){return i??o.identity}o.simplify=e;function r(i,a){let s=a.slice(0);for(var l=0,u=a.length;l<u;l+=3){let c=i[3]*a[l]+i[7]*a[l+1]+i[11]*a[l+2]+i[15];s[l]=(i[0]*a[l]+i[4]*a[l+1]+i[8]*a[l+2]+i[12])/c,s[l+1]=(i[1]*a[l]+i[5]*a[l+1]+i[9]*a[l+2]+i[13])/c,s[l+2]=(i[2]*a[l]+i[6]*a[l+1]+i[10]*a[l+2]+i[14])/c}return s}o.applyMatrix4=r})(xn||(xn={}));var Mt;(d=>{function n(p){return typeof p=="object"&&typeof p.r=="number"&&typeof p.g=="number"&&typeof p.b=="number"}d.isRGB=n,d.white={r:1,g:1,b:1},d.red={r:1,g:0,b:0},d.black={r:0,g:0,b:0};function o(p){return{r:Math.round(p.r*255),g:Math.round(p.g*255),b:Math.round(p.b*255),a:1}}d.toRgb255a1=o;function i(p){return{r:p.r,g:p.g,b:p.b}}d.clone=i;function a(p){return p=Math.floor(p),{r:(p>>16&255)/255,g:(p>>8&255)/255,b:(p&255)/255}}d.fromHex=a;function s(p){return Math.round(p.r*255)*65536+Math.round(p.g*255)*256+Math.round(p.b*255)}d.toHex=s;function l(p,f){return p.r===f.r&&p.g===f.g&&p.b===f.b}d.equals=l;function u(p,f){return p.r.toFixed(2)===f.r.toFixed(2)&&p.g.toFixed(2)===f.g.toFixed(2)&&p.b.toFixed(2)===f.b.toFixed(2)}d.equalsFixed=u;function c(p,f,h){return{r:p.r+(f.r-p.r)*h,g:p.g+(f.g-p.g)*h,b:p.b+(f.b-p.b)*h}}d.lerp=c})(Mt||(Mt={}));var Ie;(u=>{u.white={...Mt.white,a:1},u.transparent={...Mt.white,a:0};function e(c){return{r:c[0],g:c[1],b:c[2],a:c[3]}}u.from0to1=e;function r(c,d){return{...Mt.fromHex(c),a:d}}u.fromHexAndA=r;function o(c){return{r:Math.round(c.r*255),g:Math.round(c.g*255),b:Math.round(c.b*255),a:c.a}}u.toRgb255a1=o;function i(c,d){return Mt.equals(c,d)&&c.a===d.a}u.equals=i;function a(c,d){return Mt.equalsFixed(c,d)&&c.a.toFixed(2)===d.a.toFixed(2)}u.equalsFixed=a;function s(c,d,p){return{r:c.r+(d.r-c.r)*p,g:c.g+(d.g-c.g)*p,b:c.b+(d.b-c.b)*p,a:c.a+(d.a-c.a)*p}}u.lerp=s;function l({r:c,g:d,b:p,a:f}=u.white){return`rgba(${c*255}, ${d*255}, ${p*255}, ${f})`}u.toStyle=l})(Ie||(Ie={}));var zc;(t=>t.identity={position:[0,0,0],rotation:[0,0,0],scale:[1,1,1]})(zc||(zc={}));var r0;(t=>t.defaultData={mass:1,stiffness:80,damping:10,velocity:0})(r0||(r0={}));var o0;(t=>t.defaultData={control1:[.5,0],control2:[.5,1]})(o0||(o0={}));var n0;(i=>(i.linear=[0,0,1,1],i.ease=[.25,.1,.25,1],i.easeIn=[.42,0,1,1],i.easeOut=[0,0,.58,1],i.easeInOut=[.42,0,.58,1]))(n0||(n0={}));function fp(n){return typeof n=="string"&&n.length===36?/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(n):!1}var Ur;(e=>{e.all=["PerspectiveCamera","OrthographicCamera"];function t(r){return e.all.includes(r)}e.is=t})(Ur||(Ur={}));var Sn;(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(i){return i.type==="PerspectiveCamera"?i.perspective?.zoom??1:i.orthographic?.zoom??1}o.getZoom=r})(Sn||(Sn={}));var fo;(e=>{function n(r,o=.1){return{disabled:!1,type:"linear",hideBase:!1,count:3,radial:{radius:Math.max(r[0],r[1])*2,start:0,end:360,alignment:!1,axis:"y",scale:[1,1,1],rotation:[0,0,0],position:[0,0,0]},toObject:{object:"",spreadType:"random",scale:[0,0,0],rotation:[0,0,0],position:[0,0,0],axis:"x",seed:0,count:99,align:"normal"},linear:{scale:[1,1,1],rotation:[0,0,0],position:[r[0]+r[0]*o,0,0]},grid:{count:[2,2,2],size:r.map(i=>i*(1+o)),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"}}}e.defaultData=n;function t(r,o){let i={...r};if(AC.forEach(a=>{Object.assign(i,{[a]:o[a]??r[a]})}),i.radial={...r.radial},o.radial){let a=r.radial,s=o.radial;_C.forEach(l=>{Object.assign(i.radial,{[l]:s[l]??a[l]})})}if(i.linear={...r.linear},o.linear){let a=r.linear,s=o.linear;PC.forEach(l=>{Object.assign(i.linear,{[l]:s[l]??a[l]})})}if(i.grid={...r.grid},o.grid){let a=r.grid,s=o.grid;OC.forEach(l=>{Object.assign(i.grid,{[l]:s[l]??a[l]})})}if(i.toObject={...r.toObject},o.toObject){let a=r.toObject,s=o.toObject;CC.forEach(l=>{Object.assign(i.toObject,{[l]:s[l]??a[l]})})}if(i.randomnessObject={...r.randomnessObject},o.randomnessObject){let a=r.randomnessObject,s=o.randomnessObject;TC.forEach(l=>{Object.assign(i.randomnessObject,{[l]:s[l]??a[l]})})}return i}e.merge=t})(fo||(fo={}));var Gc;(r=>{r.defaultData={radial:{},linear:{},grid:{},toObject:{},randomnessObject:{}};let t=["radial","linear","grid","toObject","randomnessObject"];function e(o,i){let a=[];o.count!==void 0&&a.push({type:0,path:i,props:{count:o.count}});for(let s of t){let l=o[s];l&&Object.keys(l).length>0&&a.push({type:0,path:[...i,s],props:l})}return a}r.toOps=e})(Gc||(Gc={}));var AC=["count"],_C=["radius","start","end","position","scale","rotation"],PC=["position","scale","rotation"],OC=["count","size"],CC=["count","position","scale","rotation"],TC=["strength","scale","rotation","position","movement","seed","freqScale"];var Fc;(e=>{e.all=["PointLight","SpotLight","DirectionalLight","HemisphereLight"];function t(r){return e.all.includes(r)}e.is=t})(Fc||(Fc={}));var kc;(e=>{function n(r){return t(r)}e.defaultData=n;function t(r){if(r==="PointLight")return{type:r,color:Ie.white,intensity:1,distance:2e3,decay:1,shadows:!0,shadowResolution:1024,shadowRadius:1,penumbraSize:.5,depth:1e5};if(r==="SpotLight")return{type:r,color:Ie.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:Ie.white,intensity:1,shadows:!0,size:2e3,depth:1e5,penumbraSize:.5,shadowResolution:1024,shadowRadius:1};throw new Error("not implemented")}})(kc||(kc={}));var da;(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",emitTimeLoopDelayStart:"end",emitTimeDuration:1,...r.defaultCollisionData}))(da||(da={}));var wn;(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]})(wn||(wn={}));var hp;(e=>{e.defaultData={castShadow:!0,receiveShadow:!0};function t(r,o){return r.castShadow===o.castShadow&&r.receiveShadow===o.receiveShadow}e.equals=t})(hp||(hp={}));var mp;(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})(mp||(mp={}));var jc;(t=>t.defaultData={...mp.defaultData,...hp.defaultData})(jc||(jc={}));var a0;(t=>{function n(e,r){let o=[];if("material"in e){let i=typeof e.material=="string"?r.materials[e.material]??r.lib.materials[e.material]?.asset:e.material;i&&o.push(i)}else if("materials"in e)for(let i of e.materials){let a=typeof i=="string"?r.materials[i]??r.lib.materials[i]?.asset:i;a&&o.push(a)}return o}t.getMaterialData=n})(a0||(a0={}));var pa;(e=>(e.defaultVideo={data:"",thumb:"/_assets/_videos/catThumb.png",type:"video",name:"Cat video"},e.maxSize=3e7))(pa||(pa={}));var s0;(t=>{function n(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=n})(s0||(s0={}));function c0(n){return n.type!=="displace"}var l0;(t=>{function n(e){return e==="phong"||e==="toon"||e==="lambert"||e==="physical"}t.is=n})(l0||(l0={}));var u0=["mode","gradientType","noiseType","displacementType","projection","cnormal","crop","axis","side"],d0=["wrapping","image","video","name","minFilter"],Pt;(o=>{function n(i,a){let{texture:s,...l}=a;if(Object.assign(i,l),s){let u=i.texture;u&&Object.assign(u,s)}}o.patch=n;function t(i,a){return i==="light"&&a?e(a):r(i)}o.defaultData=t;function e(i){let a={mode:0,isMask:!1,visible:!0,bumpMap:void 0,bumpMapIntensity:5,roughnessMap:void 0,alphaOverride:1};switch(i){case"phong":return{...a,category:"phong",specular:{r:.2,g:.2,b:.2},shininess:5,type:"light",visible:!0,mode:0,occlusion:!0,alpha:.6};case"toon":return{...a,category:"toon",specular:{r:.2,g:.2,b:.2},shininess:10,type:"light",alpha:1};case"lambert":return{...a,category:"lambert",emissive:{r:0,g:0,b:0},type:"light",alpha:1,visible:!0,mode:0,occlusion:!0};case"physical":return{...a,category:"physical",roughness:.2,metalness:.2,reflectivity:.2,type:"light",alpha:1,visible:!0,mode:0,occlusion:!0}}}function r(i){let a={alpha:1,mode:0,isMask:!1,visible:!0};switch(i){case"texture":return{...a,type:"texture",size:[128,128],blending:0,axis:"x",side:2,projection:0,texture:{image:"image_0",wrapping:1e3,repeat:[1,1],offset:[0,0],rotation:0,minFilter:1008},crop:!1};case"video":return{...a,type:"video",size:[128,128],blending:0,axis:"x",side:2,projection:0,texture:{video:pa.defaultVideo,wrapping:1001,repeat:[1,1],offset:[0,0],rotation:0,minFilter:1008},crop:!1};case"color":return{...a,type:"color",color:Mt.fromHex(St)};case"depth":return{...a,type:"depth",gradientType:1,smooth:!1,isVector:!0,isWorldSpace:!1,origin:[0,0,0],direction:[1,0,0],colors:[[1,1,1,1],[0,0,0,1]],steps:[0,1],near:50,far:200};case"normal":return{...a,type:"normal",cnormal:[1,1,1]};case"gradient":return{...a,type:"gradient",gradientType:0,smooth:!1,colors:[[0,0,0,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1]],steps:[0,1,1,1,1,1,1,1,1,1],num:2,angle:0,offset:[0,0],morph:[0,0]};case"noise":return{...a,type:"noise",size:[100,100,100],noiseType:0,scale:1,move:1,colorA:{...Mt.fromHex(6710886),a:1},colorB:{...Mt.fromHex(6710886),a:1},colorC:{...Mt.fromHex(16777215),a:1},colorD:{...Mt.fromHex(16777215),a:1},distortion:[1,1],fA:[1.7,9.2],fB:[8.3,2.8],voronoiStyle:0,highCut:1,lowCut:0,smoothness:.3,seed:0,quality:1};case"fresnel":return{...a,type:"fresnel",color:Ie.fromHexAndA(16777215,1),bias:.1,scale:1,intensity:2,factor:1};case"rainbow":return{...a,type:"rainbow",filmThickness:30,movement:0,wavelengths:[0,0,0],noiseStrength:0,noiseScale:1,offset:[0,0,0]};case"toon":return{...a,type:"toon",positioning:2,colors:[[0,0,0,1],[.5,.5,.5,1],[.5,.5,.5,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1],[1,1,1,1]],steps:[0,.475,.525,1,1,1,1,1,1,1],num:4,source:[0,1e3,0],isWorldSpace:!0,noiseStrength:0,noiseScale:1,shadowColor:Ie.fromHexAndA(0,0),offset:[0,0,0]};case"outline":return{...a,type:"outline",outlineColor:Ie.fromHexAndA(0,1),contourColor:Ie.fromHexAndA(0,1),outlineWidth:2,contourWidth:5,outlineThreshold:.4,contourThreshold:0,outlineSmoothing:0,contourFrequency:10,contourDirection:[0,1,0],positionalLines:!1,compensation:!0};case"matcap":return{...a,type:"matcap",texture:{image:"matcap_0",wrapping:1001,repeat:[1,1],offset:[0,0],rotation:0,minFilter:1008}};case"transmission":return{...a,type:"transmission",thickness:10,ior:1.5,roughness:1};case"displace":return{visible:!0,type:"displace",displacementType:"noise",noiseType:0,scale:10,movement:1,offset:[0,0,0],intensity:8,voronoiStyle:0,smoothness:.3,seed:0,highCut:1,lowCut:0,quality:1};case"pattern":return{...a,type:"pattern",style:0,projection:0,axis:"y",blending:0,offset:[0,0],colorA:{...Mt.fromHex(0),a:1},colorB:{...Mt.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}}}})(Pt||(Pt={}));var Wt;(u=>{function n(c){return!c.layers.some(p=>p.data.type==="texture"&&p.data.projection!==0||p.data.type==="depth"&&!p.data.isWorldSpace||p.data.type==="noise"||p.data.type==="displace")}u.isMergable=n;function t(c){let d="";return c.layers.forEach(p=>{Object.entries(p.data).forEach(([f,h])=>{d+=`${f}${h}`,Array.isArray(h)?h.forEach(m=>d+=`${m}`):typeof h=="object"?Object.values(h).forEach(m=>{typeof m=="number"?d+=`${m.toFixed(4)}`:d+=`${m}`}):d+=`${h}`})}),d}u.getHash=t;function e(){return{layers:new Se}}u.defaultEmptyData=e;function r(c="layer1",d="layer2"){return i("phong",c,d)}u.defaultData=r;function o(c,d){return{...c,name:d}}u.withName=o;function i(c,d="layer1",p="layer2"){let f=new Se;return f.push({fi:0,data:Pt.defaultData("light",c),id:d}),f.push({fi:1,data:Pt.defaultData("color"),id:p}),{layers:f}}u.defaultTwoLayerData=i;function a(c){let d=Pt.defaultData("texture");c&&Object.assign(d.texture,{image:c});let p=new Se;return p.push({fi:0,data:d,id:"layer1"}),p.push({fi:1,data:{...Pt.defaultData("transmission"),alpha:1},id:"layer2"}),p.push({fi:2,data:{...Pt.defaultData("light","lambert"),alpha:0},id:"layer3"}),{layers:p}}u.defaultUIObjectMaterial=a;function s(c,d="phong",p="layer1",f="layer2"){let h=Pt.defaultData("texture");Object.assign(h.texture,{image:c});let m=new Se;return m.push({fi:0,data:h,id:p}),m.push({fi:1,data:Pt.defaultData("light",d),id:f}),{layers:m}}u.defaultTwoLayerTextureData=s;function l(c,d="phong",p="layer1",f="layer2"){let h=Pt.defaultData("video");Object.assign(h.texture,{video:c});let m=new Se;return m.push({fi:0,data:h,id:p}),m.push({fi:1,data:Pt.defaultData("light",d),id:f}),{layers:m}}u.defaultTwoLayerVideoTextureData=l})(Wt||(Wt={}));var fa;(t=>{function n(){return{points:new Se,roundness:0,shapeHoles:[],isClosed:!1}}t.defaultData=n})(fa||(fa={}));var ha;(t=>{function n(){return{points:new Se,lastInsertionPlane:null,subdivisions:12,isClosed:!1}}t.defaultData=n})(ha||(ha={}));var yp={type:"Ellipse",width:50,height:50,spikes:16,angle:360,innerRadius:0};var Uc;(t=>{function n(e,r){let o={...e};return MC.forEach(i=>{Object.assign(o,{[i]:r[i]??e[i]})}),o}t.merge=n})(Uc||(Uc={}));var Hc={shape:yp,depth:1,offset:0,bevel:50,bevelSides:6,angle:0,twist:0,startScale:1,endScale:1,capType:"flat"},MC=["depth","offset","angle","twist","startScale","endScale"];var $s;(e=>{function n(r){return r==="PolygonGeometry"||r==="RectangleGeometry"||r==="StarGeometry"||r==="TriangleGeometry"||r==="EllipseGeometry"||r==="UIGeometry"}e.is2DParametricMesh=n;function t(r){return r==="PolygonGeometry"||r==="PolygonGeometry"||r==="RectangleGeometry"||r==="StarGeometry"||r==="TriangleGeometry"||r==="EllipseGeometry"||r==="PathGeometry"||r==="VectorGeometry"||r==="ConeGeometry"||r==="CubeGeometry"||r==="CylinderGeometry"||r==="DodecahedronGeometry"||r==="HelixGeometry"||r==="IcosahedronGeometry"||r==="LatheGeometry"||r==="PyramidGeometry"||r==="SphereGeometry"||r==="PlaneGeometry"||r==="BackdropGeometry"||r==="TorusGeometry"||r==="TorusKnotGeometry"||r==="BooleanGeometry"||r==="TextGeometry"}e.isParametricMesh=t})($s||($s={}));var qc;(t=>{function n(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,Uc.merge(o.extrusion,r.extrusion))),o}t.merge=n})(qc||(qc={}));var An;(t=>{function n(e){if(e==="RectangleGeometry")return{width:320,height:320,type:e,cornerRadius:[0,0,0,0],cornerType:0,depth:0,extrudeBevelSize:0,extrudeBevelSegments:1};if(e==="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:ha.defaultData(),extrusion:Hc};if(e==="VectorGeometry")return{width:1,height:1,type:e,subdivisions:12,shape:fa.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==="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",extrudeBevelSize:0,extrudeBevelSegments:1};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=n})(An||(An={}));var Wc;(t=>t.defaultData={enabled:!1,useBackgroundColor:!1,color:Mt.white,near:.1,far:2e3})(Wc||(Wc={}));var $c;(e=>{let n={opacity:1,blendFunction:13,enabled:!1};e.defaultData={enabled:!1,pixelation:{...n,blendFunction:16,granularity:15},bloom:{...n,blendFunction:16,intensity:1,blurScale:1,luminanceThreshold:.25,luminanceSmoothing:.025,kernelSize:3},chromaticAberration:{...n,offset:[2,2]},vignette:{...n,darkness:1,offset:0},hueSaturation:{...n,hue:3,saturation:0},brightnessContrast:{...n,brightness:.25,contrast:0},depthOfField:{...n,focalLength:2,focusDistance:2,bokehScale:2},noise:{...n,blendFunction:16}}})($c||($c={}));var gp;(t=>t.defaultData={softShadowQuality:"low"})(gp||(gp={}));var xp;(t=>t.defaultData={enabled:!0,color:{r:.8274509803921568,g:.8274509803921568,b:.8274509803921568},intensity:.75})(xp||(xp={}));var bp;(t=>t.defaultData={occlusion:!1,aoFullRes:!1,radius:256,bias:.5,aoColor:{r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}})(bp||(bp={}));var Ys;(t=>t.defaultData={usePhysics:!1,gravity:-10})(Ys||(Ys={}));var vp;(t=>t.defaultData={playCamera:bn,gameControlObject:null})(vp||(vp={}));var Yc;(t=>t.defaultData={backgroundColor:Ie.fromHexAndA(i0,1),postprocessing:$c.defaultData,fog:Wc.defaultData,globalPhysics:Ys.defaultData,ambient:xp.defaultData,ao:bp.defaultData,shadow:gp.defaultData,publish:vp.defaultData})(Yc||(Yc={}));var Xc;(t=>t.defaultData={colliderType:"box",size:[100,100,100],colliderHelperVisible:!0,forceType:"collider",forceRange:"global",forceIntensity:.5,forceDambing:.95})(Xc||(Xc={}));var p0;(e=>{function n(r){return r==="Component"||r==="Instance"}e.isComponentRelated=n;function t(r){return r==="Empty"||r==="Instance"}e.isEmptyOrComponent=t})(p0||(p0={}));var ma;(o=>{o.identity={...zc.identity,hiddenMatrix:xn.identity};function t(i){return{position:i.position,rotation:i.rotation,scale:i.scale,hiddenMatrix:i.hiddenMatrix}}o.fromObject=t;function e(i,a){return{position:a?.position||i.position,rotation:a?.rotation||i.rotation,scale:a?.scale||i.scale,hiddenMatrix:a?.hiddenMatrix||i.hiddenMatrix}}o.merge=e;function r(i,a){return Yl({position:gn.isEqual(i.position,a.position)?void 0:a.position,rotation:gn.isEqual(i.rotation,a.rotation)?void 0:a.rotation,scale:gn.isEqual(i.scale,a.scale)?null:a.scale,hiddenMatrix:xn.isEqual(i.hiddenMatrix,a.hiddenMatrix)?void 0:a.hiddenMatrix})}o.diff=r})(ma||(ma={}));var It;(t=>t.defaultData={states:new Se,events:new Se,visible:!0,raycastLock:!1,physics:wn.defaultData,pathSnapping:{pathId:null,slide:0,offset:0,orientation:"tangential"},...ma.identity,cloner:null})(It||(It={}));var Qc;(t=>t.defaultData={type:"Empty",...It.defaultData})(Qc||(Qc={}));var f0;(t=>t.defaultData={type:"ParticleCollider",...Xc.defaultData,...It.defaultData})(f0||(f0={}));var h0;(t=>t.defaultData={type:"Component",...It.defaultData})(h0||(h0={}));var m0;(t=>t.defaultData={type:"Particle",...It.defaultData,...da.defaultData})(m0||(m0={}));var ri;(t=>t.defaultData={type:"Mesh",...It.defaultData,...jc.defaultData})(ri||(ri={}));var oi;(t=>t.defaultData={...It.defaultData,...ma.identity,position:[0,0,Sn.DefaultTargetOffset],...Sn.defaultData})(oi||(oi={}));var Kc;(e=>{function n(r){return{...It.defaultData,...kc.defaultData(r)}}e.defaultData=n,e.defaultDirectionalLightData={...e.defaultData("DirectionalLight"),position:[200,300,300],name:"Directional Light",intensity:.7}})(Kc||(Kc={}));var ya;(e=>{function n(r,o,i=0){for(;i<o.length;){let a=r?r[o[i]]:void 0;if(o.length===i+1)return a;if(a)r=a.descendants,i+=1;else return}}e.resolveWithDes=n;function t(r,o,i=0){let a=n(r,o,i);if(a){let s=Object.keys(a);if(s.length===1&&s[0]==="descendants")return}return a}e.resolve=t})(ya||(ya={}));var ho;(i=>{i.rootOverrideProps=["physics","events"],i.compositeNonOptionalOverrideProps=["geometry"],i.compositeEntireOverrideOverrideProps=["material"];function r(a,s){return{...It.defaultData,...s,component:a,overrides:new et,physics:void 0,events:void 0,type:"Instance"}}i.ofComponent=r;function o(a){let s=ma.fromObject(a.data);return r(a.id,s)}i.fromComponentData=o})(ho||(ho={}));var Go;(e=>{e.defaultData={type:"Page",...It.defaultData,physics:{...wn.defaultData,fusedBody:!1},...Yc.defaultData,camera:oi.defaultData};function t(r){return r.uiScene!==void 0}e.isUIPage=t})(Go||(Go={}));var Zc;(i=>(i.defaultCamera={position:[0,0,1e3],scale:[1,1,1],rotation:[0,0,0],hiddenMatrix:xn.identity,name:"Play Camera",visible:!0,raycastLock:!1,physics:wn.defaultData,states:new Se,events:new Se,cloner:null,pathSnapping:{pathId:null,orientation:"tangential",slide:0,offset:0},...Sn.defaultData},i.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"]},i.defaultMeshObject={name:"Rectangle",...It.defaultData,...ri.defaultData,geometry:An.defaultData("RectangleGeometry"),material:Wt.defaultTwoLayerData("phong","layer1","layer2")},i.defaultBooleanObject={name:"Boolean",...It.defaultData,...ri.defaultData,geometry:An.defaultData("BooleanGeometry"),material:Wt.defaultTwoLayerData("phong","layer1","layer2")},i.defaultTextObject={name:"Text",...It.defaultData,...ri.defaultData,geometry:An.defaultData("TextGeometry"),material:Wt.defaultTwoLayerData("phong","layer1","layer2")}))(Zc||(Zc={}));var ni;(o=>{function n(i,a){let s={name:a};return i.type==="Mesh"?(s.geometry={},"material"in i&&(s.material={layers:new et}),"materials"in i&&(s.materials=i.materials.map(l=>({layers:new et})))):Ur.is(i.type)&&(s.perspective={},s.orthographic={}),s}o.newEmpty=n;function t(i,a){if(a===void 0)return i;let s={...i};return"material"in s&&"material"in a&&a.material&&(s.material=fn(s.material,l=>{if(typeof l!="string")for(let[u,c]of Object.entries(a.material.layers)){let d=l.layers.data(u);d&&Pt.patch(d,c)}}).data),s.materials&&a.materials&&(s.materials=fn(s.materials,l=>{for(let u=0;u<s.materials.length;u++){let c=a.materials[u];if(typeof c!="string")for(let[d,p]of Object.entries(c.layers)){let f=l[u]?.layers?.data(d);f&&Pt.patch(f,p)}}}).data),s}function e(i,a){let s,l=[],u={orthographic:0,perspective:0,geometry:0};function c(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(...Gc.toOps(p,["cloner"]));else if(d==="pathSnapping")l.push({path:[d],props:{slide:p.slide,offset:p.offset},type:0});else if(d==="material")c(["material"],p);else if(d==="materials")for(let[f,h]of Object.entries(p))c(["materials",f],h);else if(u[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(i,a){if(a===void 0)return i;let s={...i};if(Object.assign(s,ma.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})}),Ur.is(i.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(i.type==="Mesh")"geometry"in a&&Object.assign(s,{geometry:qc.merge(s.geometry,a.geometry)}),(a.material||a.materials)&&(s=t(s,a)),s.cloner&&"cloner"in a&&Object.assign(s,{cloner:fo.merge(s.cloner,a.cloner)});else if(i.type==="Empty")s.cloner&&"cloner"in a&&Object.assign(s,{cloner:fo.merge(s.cloner,a.cloner)});else if(Fc.is(i.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=Mt.clone(l.color))}return s}o.patch=r})(ni||(ni={}));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,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 Hr;(t=>t.defaultData={orbitControls:ga.defaultData,playPage:vn,withBackground:!0,preventScroll:!1,preventTouchScroll:!1,hideCursor:!1,mouseEventTarget:"canvas",joystickSizeAndXYOffset:Array(12).fill(0).map((e,r)=>{let o=0,i=0;return r<5?i=-30:r<10&&(i=30),r===0||r===10||r===5?o=30:(r===4||r===11||r===9)&&(o=-30),[120,[o,i],"show"]}),settings:{image:{format:"jpg",ratio:1},video:{format:"mp4",imageFormat:"jpg",fps:30,mbps:80,ratio:Math.max(1,typeof window<"u"?Math.floor(window.devicePixelRatio):1),stopMode:"manual",duration:5e3},web:{logo:!0,compress:!0,preset:1,preload:!0,hint:!1}},stopRaycast:!0,hdTransmission:!1})(Hr||(Hr={}));var Sp;(t=>t.defaultData={id:"basic",label:"Basic",style:"None",prompt:""})(Sp||(Sp={}));var wp;(t=>t.defaultData={weather:0,shadows:0,lightOrigin:0,temperature:0,sun:0,camera:0,environment:0,particles:0,nature:0,floor:0})(wp||(wp={}));var Fo;(e=>(e.defaultData=()=>({mode:"line-art-both",prompt:"",negativePrompt:"",style:{...Sp.defaultData},isRandomSeed:!0,seed:e.generateSeed(),guessMode:!1,advanced:!1,steps:20,guidanceScale:7.5,controlNetScale:1,modifiers:wp.defaultData}),e.generateSeed=()=>Math.round(Math.random()*1e5)))(Fo||(Fo={}));var y0;(e=>{function n(r){return r.find(o=>o.data.type==="Page"&&o.data.globalPhysics.usePhysics)!==void 0}e.physicsEnabled=n;function t(r,o,i){r.scene.objects.traverseFrom(o,(a,s)=>{if(s.type==="Instance"){let l=xa.getComponentData(r,s.component)?.data;l&&i(a,s,l.events)}else i(a,s,s.events)})}e.traverseModuleInstances=t})(y0||(y0={}));var ko;(l=>{l.TRASH_CAN_ID="830a2708-8ed9-49cf-a68e-085299892222";function t(u={withLight:!0,withSquare:!0}){let c=[],d=Zc.defaultMeshObject;u.withLight===!0&&c.push({fi:-1,data:Kc.defaultDirectionalLightData,id:"830a2708-8ed9-49cf-a68e-085299899103",children:[]}),u.withSquare===!0&&c.push({fi:1,id:"7ba78968-2a55-48f2-b14c-5191da3e075e",data:d,children:[]});let p=new Je;return p.push({fi:1,id:vn,data:{...Go.defaultData,name:"Scene 1"},children:c}),p}l.defaultData={objects:t(),publish:Hr.defaultData,styles:Fo.defaultData()},l.emptyDataWithoutPage=function(){return{objects:new Je,publish:Hr.defaultData,styles:Fo.defaultData()}},l.emptyDataWithPage=function(u){return{objects:t(u),publish:Hr.defaultData,styles:Fo.defaultData()}},l.emptyData=function(){return{objects:new Je,publish:{...Hr.defaultData},styles:Fo.defaultData()}};function a(u){return{...l.defaultData,objects:rr(u,Je.prototype)}}l.withObjs=a;function s(u,c){return a([{id:u,data:c,children:[],fi:0}])}l.withObj=s})(ko||(ko={}));var ba;(t=>t.defaultData={preset:"fullscreen",allowResponsive:!1,size:[512,512],coords:[0,0],sceneScale:1,color:{r:0,g:0,b:0,a:.5}})(ba||(ba={}));var va;(t=>t.emptyImage={data:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII=",name:"empty"})(va||(va={}));var Jc;(i=>{function n(a){return a.textValue!==void 0}i.isTextValue=n;function t(a){return typeof a=="number"}i.isNumber=t;function e(a){return typeof a=="boolean"}i.isBoolean=e;function r(a){return n(a)?"string":e(a)?"boolean":"number"}i.typeOfVariable=r;function o(a){return i.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():i.isBoolean(a)?a?"True":"False":i.isNumber(a)?parseFloat(a.toFixed(3)).toString():a.toString()}i.getDisplayedValue=o})(Jc||(Jc={}));var Ap;(t=>t.all=["images","videos","colors","audios","particles","fonts","materials","variables"])(Ap||(Ap={}));var g0;(t=>t.all=[...Ap.all,"components"])(g0||(g0={}));var x0;(t=>{function n(){return{images:new xe,videos:new xe,colors:new xe,audios:new xe,particles:new xe,fonts:new xe,materials:new xe,components:new xe,variables:new xe}}t.defaultData=n})(x0||(x0={}));var jo;(t=>{function n(){return{images:new xe,videos:new xe,colors:new xe,audios:new xe,particles:new xe,fonts:new xe,materials:new xe,components:new xe,variables:new xe}}t.defaultData=n})(jo||(jo={}));var Nr;(i=>{function n(){let a={};return a["89b10010-844c-11ec-a8a3-0242ac120002"]={r:.5,g:.5,b:.5,a:1,name:"Default Color"},rr(a,xe.prototype)}i.defaultColors=n;function t(a){let s={};return a?.withAITexture&&(s["a1b10010-844c-a8a3-11ec-0242ac2011ec"]={...va.emptyImage,name:"AI generated image"}),rr(s,xe.prototype)}i.defaultImages=t;function e(){return{catelogs:new xe,materials:new xe,images:new xe,videos:new xe,colors:new xe,audios:new xe,particles:new xe,fonts:new xe,variables:new Se,lib:jo.defaultData()}}i.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)}}i.defaultVariables=r;function o(a,s){if(s.format==="HH:mm:ss"){let l=Math.floor(a/3600),u=Math.floor((a-l*3600)/60),c=Math.round(a-l*3600-u*60);return{textValue:[l,u,c]}}else if(s.format==="mm:ss"){let l=Math.floor(a/60),u=Math.round(a-l*60);return{textValue:[l,u]}}else return s.format==="number"?a=Math.round(a):a=Math.round(a*1e3)/1e3,a}i.getFormattedTimerTime=o})(Nr||(Nr={}));import{MathUtils as ru}from"three";var eu;(t=>t.list=["idle","move","jump","run"])(eu||(eu={}));var tu;(e=>(e.defaultColliderData={type:"capsule",height:200,radius:50,position:[0,0,0],rotation:[0,0,0]},e.defaultDataThirdPerson={moveMode:"walk",forwardDirection:"+z",speedTranslate:1e3,speedRotate:100,runMultiplier:2,rotationMode:"normal",rotBy:"keys",rotByTouch:"drag",delayPos:[.3,.3],delayRot:[.3,.3],keyAssignments:[["moveNegZ","W"],["moveNegX","A"],["movePosZ","S"],["movePosX","D"],["rotPosX","\u25B2"],["rotPosY","\u25C0"],["rotNegX","\u25BC"],["rotNegY","\u25B6"],["jump","Space"],["run","\u21E7"],["none","Ctrl"]],touchControl:!0,joystickPosLoc:5,joystickRotLoc:11,jumpTouchButtonLoc:9,collider:e.defaultColliderData,colliderHelperVisible:!0,collisionEnabled:!0,jumpPower:100,resetYPosition:3e3,alignToGround:!1,autoOrientMove:!0,orientWith:"camera",orientMode:"radial",delayPosCamera:.3,delayRotCamera:.3,camera:"",cameraXAxis:"Limit",cameraYAxis:"Free",cameraRotXLimits:[0,Math.PI/2],cameraRotYLimits:[-Math.PI/2,Math.PI/2],gameActions:{idle:new Se,move:new Se,jump:new Se,run:new Se},navmesh:{enabled:!1,ch:6,cs:6,walkableClimb:5,walkableHeight:1,walkableRadius:0,zones:"all",objects:[],helperVisible:!0,destinationHelperRadius:0,destinationHelperColor:Ie.fromHexAndA(3728051,1)}}))(tu||(tu={}));function b0(n){n.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]],i=[0,1];for(let s=2;s<10;s++)o.push(o[1]),i.push(1);let a={...jr(ut(t),"type","visible","isVector","isWorldSpace","origin","alpha","mode"),near:Math.max(0,t.near),far:Math.max(0,t.far),colors:o,steps:i,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={...ut(t),near:Math.max(t.near,0),far:Math.max(t.far,0)};Object.assign(t,e)}})}function Uo(n,t){Object.values(n.shared.materials).forEach(e=>t(e))}function Ho(n,t){n.scene.objects.traverse((e,r)=>{"materials"in r?r.materials.forEach((o,i)=>{o===void 0&&(r.materials[i]=Wt.defaultData(),o=r.materials[i]),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)!==et.prototype&&t(o.material)})})}function IC(n){Object.assign(n.scene.publish,{orbitControls:{...ga.defaultData,...ut(n.scene.publish.orbitControls)}})}function NC(n){Object.assign(n.scene.publish.settings,{video:{...Hr.defaultData.settings.video,...ut(n.scene.publish.settings.video)}})}function DC(n){function t(e){if(e.layers){for(let r of Object.values(e.layers))if(r){for(let[o,i]of Object.entries(r))if((u0.includes(o)||typeof i=="boolean")&&delete r[o],o==="texture")for(let[a,s]of Object.entries(i))(d0.includes(a)||typeof s=="boolean")&&delete i[a]}}}n.scene.objects.traverse((e,r)=>{r.states.forEach(o=>{let i=o;i.material?t(i.material):i.materials&&i.materials.forEach(a=>{t(a)})})})}function EC(n){n.scene.publish.withBackground=!0}function BC(n){n.scene.publish.settings.web={compress:!0,preload:!0,preset:1,logo:!0,hint:!1}}function LC(n){n.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 RC(n){n.scene.objects.traverse((t,e)=>{let r=e.geometry;r&&(r.type==="DodecahedronGeometry"||r.type==="IcosahedronGeometry")&&(r.detail=Math.round(r.detail))})}function VC(n){n.scene.objects.traverse((t,e)=>{let r=n.scene.objects.unproxy().parent(t);if(r){let o=ut(n.scene.objects.data(r));o&&o.type==="Mesh"&&o.geometry.type==="BooleanGeometry"&&e.type==="Mesh"&&(e.visible=ut(e).booleanExclude!==!0)}})}function zC(n){n.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 GC(n){function t(r){Object.setPrototypeOf(r,et.prototype),r.texture&&Object.setPrototypeOf(r.texture,et.prototype)}function e(r){Object.setPrototypeOf(r,et.prototype);for(let o in r)t(r[o])}n.scene.objects.traverse((r,o)=>{o.states.forEach(i=>{let a=i;if(a.material){let s=ut(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],u=ut(l).layers;e(u),l.layers=u}})})}function v0(n){n.layers===void 0&&Object.assign(n,Wt.defaultTwoLayerData("lambert"))}function _p(n){!n.layers||n.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={...ut(t),colors:e,steps:r};Object.assign(t,o)}})}function FC(n){n.scene.objects.traverse((t,e)=>{e.type==="Mesh"&&(e.geometry.type==="BooleanGeometry"||e.geometry.type==="SubdivGeometry")&&(e.geometry.phongAngle=35)})}function S0(n){n.scene.objects.traverse((t,e)=>{"materials"in e?e.materials.forEach(r=>{typeof r!="string"&&_p(r)}):"material"in e&&typeof e.material!="string"&&_p(e.material)}),Object.values(n.shared.materials).forEach(t=>_p(t))}function kC(n){n.scene.environment.ambientLight.softShadows=!1,n.scene.environment.ambientLight.softShadowQuality="low",n.scene.objects.traverse((t,e)=>{(e.type==="DirectionalLight"||e.type==="SpotLight")&&(e.shadowResolution=1024,e.shadowRadius=1,e.depth=1e5)}),n.shared.penumbraSize=new Array(5).fill(.5)}function jC(n){n.shared.audios=rr({},xe.prototype)}function UC(n){n.shared.videos=rr({},xe.prototype)}function HC(n){let t=n.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 qC(n){Object.entries(ut(n.shared.images)).filter(r=>r[1].asset===!1).map(r=>r[0]).forEach(r=>{delete n.shared.images[r]}),Object.entries(ut(n.shared.audios)).filter(r=>r[1].asset===!1).map(r=>r[0]).forEach(r=>{delete n.shared.audios[r]})}function WC(n){n.scene.publish.settings.web.preload=!1}function w0(n){n.layers&&n.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 A0(n){n.layers&&n.layers.forEach(t=>{c0(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 $C(n){n.shared.fonts=rr({},xe.prototype)}function YC(n){return n.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 XC(n){let t=[];n.scene.objects.traverse((e,r)=>{let o=r;if(o.type==="TextFrame"){let i=Wt.defaultTwoLayerData("phong"),a=typeof o.color=="string"?n.shared.colors[o.color]:o.color;i.layers[1].data.color={r:a.r,g:a.g,b:a.b},i.layers[1].data.alpha=o.alpha;let s=YC(o.font);n.shared.fonts[s]===void 0&&(n.shared.fonts[s]={name:s});let l={name:o.name,...It.defaultData,...ri.defaultData,flatShading:!1,wireframe:!1,geometry:{...An.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:i,states:ut(o.states),events:ut(o.events),visible:o.visible,raycastLock:o.raycastLock,position:o.position,rotation:o.rotation,scale:o.scale,hiddenMatrix:o.hiddenMatrix},u=ut(n.scene.objects).parent(e);n.scene.objects.insertAfter(u??null,e,[{id:e+"new",data:l,children:[]}]),t.push(e)}}),t.forEach(e=>{n.scene.objects.delete(e)})}function QC(n){let t={0:"MouseDown",1:"MouseUp",2:"MouseHover",5:"KeyDown",6:"KeyUp",7:"Start",9:"LookAt",10:"Follow",11:"Scroll",12:"Audio",13:"GameControl"};n.scene.objects.traverse((e,r)=>{r.events.forEach(o=>{if(!!t[Number(o.type)])if(Object.assign(o,{type:t[Number(o.type)]}),o.type==="Audio"&&"audioEvent"in o&&(Object.assign(o,{playAudio:o.audioEvent}),delete o.audioEvent),o.type==="GameControl")Object.assign(o,{gameActions:{idle:new Se,move:new Se,jump:new Se}});else{let i=new Se;Object.assign(o,{actions:i}),(o.type==="MouseDown"||o.type==="MouseUp"||o.type==="KeyDown"||o.type==="KeyUp")&&"url"in o&&i.push({fi:0,id:ru.generateUUID(),data:{type:"Link",url:o.url,delay:0}}),"targets"in o&&(o.targets.forEach((a,s,l)=>{let u={state:void 0,repeat:0,delay:0,delayDirection:void 0,direction:"normal",duration:0,easing:4},c={easing:a.easing,duration:a.duration};a.easing===6?Object.assign(c,jr(a,"mass","stiffness","damping","velocity")):a.easing===5&&Object.assign(c,{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,...c},f={allowSlerp:!0,type:"Transition",object:a.object,repeat:0,delay:0,delayDirection:void 0,direction:"normal",tweens:new Se({fi:0,id:ru.generateUUID(),data:u},{fi:1,id:ru.generateUUID(),data:p})};i.push({fi:l,id:s,data:f})}),delete o.targets)}})})}function KC(n){n.scene.objects.traverse((t,e)=>{function r(o,i){let a=new Se,s=[];if(e.events.forEach((l,u,c)=>{if(l.type==="Audio"&&l.trigger===i){let d;s.push(u),l.interaction==="play"?d={...jr(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={...jr(l,"interaction","delay","object","playAudio"),type:"Audio"}),d&&a.push({fi:c,id:u,data:d})}}),s.forEach(l=>e.events.delete(l)),a.length){let l=e.events.find(u=>u.type===o)?.data;l?"actions"in l&&l.actions.insertBefore(null,a):e.events.insertBefore(null,[{id:ru.generateUUID(),data:{type:o,actions:a}}])}}r("Start","start"),r("MouseDown","mouseDown"),r("MouseUp","mouseUp"),r("KeyDown","keyDown"),r("KeyUp","keyUp")})}function _0(n){let t=n.layers.find(e=>e.type==="light")?.data;if(t?.category==="basic"){let e=Pt.defaultData("light","phong"),r=t;Object.assign(r,e),r.visible=!1}}function P0(n){Uo(n,_0),Ho(n,_0)}function ZC(n){n.scene.objects.traverse((t,e)=>{e.type==="Mesh"&&e.geometry.type==="SubdivGeometry"&&(e.geometry.scaleBaked||(e.geometry.scaleBaked=[1,1,1]))})}function JC(n){n.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 eT(n){n.scene.objects.traverse((t,e)=>{e.type==="Mesh"&&e.geometry.type==="NonParametricGeometry"&&!("material"in e)&&!("materials"in e)&&(e.material=Wt.defaultTwoLayerData("phong"))})}function tT(n){n.scene.publish.orbitControls.autoZoom===void 0&&(n.scene.publish.orbitControls.autoZoom=!1),n.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 rT(n){n.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 oT(n){n.scene.publish.mouseEventTarget===void 0&&(n.scene.publish.mouseEventTarget="canvas"),n.scene.publish.settings.web.hint===void 0&&(n.scene.publish.settings.web.hint=!1)}function nT(n){let{video:t}=n.scene.publish.settings;t.format==="gif"&&t.fps>48&&(t.fps=15)}function iT(n){n.scene.objects.traverse((t,e)=>{e.events.forEach(r=>{r.type==="GameControl"&&(r.resetYPosition=Math.abs(r.resetYPosition-e.position[1]))})})}function aT(n){let t=n.scene.environment.usePhysics;n.scene.objects.traverse((e,r)=>{t&&r.physics===null?r.collision=!1:r.collision="visibility"})}function sT(n){n.scene.objects.traverse((t,e)=>{e.events.forEach(r=>{r.type==="GameControl"&&(r.navmesh=tu.defaultDataThirdPerson.navmesh)})})}function lT(n){n.scene.styles||(n.scene.styles=Fo.defaultData())}function O0(n){n.layers.forEach(t=>{t.type==="light"&&t.category!=="toon"&&t.occlusion===void 0&&(t.occlusion=!0)})}function cT(n){n.scene.environment.ambientLight.occlusion===void 0&&(n.scene.environment.ambientLight.occlusion=!1),n.scene.environment.ambientLight.aoFullRes===void 0&&(n.scene.environment.ambientLight.aoFullRes=!1),n.scene.environment.ambientLight.radius===void 0&&(n.scene.environment.ambientLight.radius=256),n.scene.environment.ambientLight.bias===void 0&&(n.scene.environment.ambientLight.bias=.5),n.scene.environment.ambientLight.aoColor===void 0&&(n.scene.environment.ambientLight.aoColor={r:.19607843137254902,g:.19607843137254902,b:.19607843137254902}),Ho(n,O0),Uo(n,O0)}function uT(n){n.scene.objects.traverse((t,e)=>{e.events.forEach(r=>{r.type==="GameControl"&&Object.assign(r.gameActions,{run:new Se})})})}function dT(n){n.scene.objects.traverse((t,e)=>{e.events.forEach(r=>{r.type==="GameControl"&&(r.keyAssignments=[...r.keyAssignments,["run","\u21E7"],["none","Ctrl"]])})})}function C0(n){n.layers&&n.layers.forEach(t=>{t.type==="light"&&t.bumpMapIntensity===void 0&&(t.bumpMapIntensity=5)})}function T0(n,t){if(t<1&&(Ho(n,b0),Uo(n,b0),n.schema=1),t<2&&(IC(n),n.schema=2),t<3&&(DC(n),n.schema=3),t<4&&(EC(n),n.schema=4),t<5&&(BC(n),n.schema=5),t<6&&(LC(n),n.schema=6),t<7&&(RC(n),n.schema=7),t<8&&(n.schema=8),t<9&&(S0(n),n.schema=9),t<10&&(FC(n),n.schema=10),t<11&&(kC(n),n.schema=11),t<12&&(S0(n),n.schema=12),t<13&&(jC(n),n.schema=13),t<14&&(HC(n),n.schema=14),t<15&&(qC(n),n.schema=15),t<16&&(WC(n),n.schema=16),t<17&&(Ho(n,w0),Uo(n,w0),n.schema=17),t<18&&(Ho(n,v0),Uo(n,v0),n.schema=18),t<19&&(NC(n),n.schema=19),t<20&&($C(n),XC(n),n.schema=20),t<21&&(QC(n),KC(n),n.schema=21),t<22&&(P0(n),n.schema=22),t<23&&(ZC(n),n.schema=23),t<24&&(JC(n),n.schema=24),(t<25||n.shared.videos===void 0)&&(UC(n),t<25&&(n.schema=25)),t<26&&(VC(n),n.schema=26),t<27&&(zC(n),n.schema=27),t<28&&(P0(n),n.schema=28),t<29&&(GC(n),n.schema=29),t<30&&(eT(n),n.schema=30),t<31&&(tT(n),n.schema=31),t<33&&(rT(n),n.schema=33),t<34&&(oT(n),n.schema=34),t<35&&(nT(n),n.schema=35),t<36&&(iT(n),n.schema=36),t<37&&(aT(n),n.schema=37),t<38&&(Ho(n,A0),Uo(n,A0),n.schema=38),t<39&&(sT(n),n.schema=39),t<40&&(lT(n),n.schema=40),t<41&&(cT(n),n.schema=41),t<42&&(uT(n),n.schema=42),t<43&&(dT(n),n.schema=43),t<99){Ho(n,C0),Uo(n,C0),n.scene.publish.playCamera===null&&(n.scene.publish.playCamera=bn);let e=ut(n.scene.objects),r=n.scene.objects;n.scene.publish.playPage=vn,r.insertBefore(null,null,[{id:vn,data:{...Go.defaultData,backgroundColor:n.scene.backgroundColor,fog:n.scene.fog,postprocessing:n.scene.postprocessing,ao:jr(n.scene.environment.ambientLight,"occlusion","aoFullRes","radius","bias","aoColor"),publish:{playCamera:n.scene.publish.playCamera,gameControlObject:n.scene.publish.gameControlObject},shadow:jr(n.scene.environment.ambientLight,"softShadowQuality"),globalPhysics:{...Ys.defaultData,...jr(n.scene.environment,"usePhysics","gravity")},camera:ut(n.scene.ownerCamera)??Go.defaultData.camera,name:"Scene"},children:[]}]);for(let a of e)a.id!==ko.TRASH_CAN_ID&&r.move(vn,a.fi,a.id);let o=0,i=0;n.shared.penumbraSize&&n.scene.objects.traverse((a,s)=>{s.type==="DirectionalLight"?(s.penumbraSize=n.shared.penumbraSize[Math.min(o,2)],o+=1):s.type==="SpotLight"&&(s.penumbraSize=n.shared.penumbraSize[3+Math.min(i,1)],i+=1),(s.physics===void 0||s.physics===null)&&s.type!=="Instance"&&(s.physics={},Object.assign(s.physics,wn.defaultData)),s.physics!==void 0&&s.physics!==null&&(s.physics.enabled=s.collision??"visibility",delete s.collision)}),n.schema=99}}function M0(n){n.layers&&n.layers.forEach(t=>{t.type==="light"&&t.alphaOverride===void 0&&(t.alphaOverride=1)})}function pT(n){n.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 fT(n){Array.isArray(ut(n.events))&&n.events?.forEach(t=>{"disabled"in t||(t.disabled=!1),(t.type==="MouseDown"||t.type==="MouseUp"||t.type==="MousePress")&&(t.mode=t.mode||"Object")})}var Sa=180/Math.PI;function I0(n){n.rotation=n.rotation.slice(0,3).map(t=>t*Sa)}function N0(n){I0(n),n.type==="Page"&&I0(n.camera),n.states?.forEach(e=>{e.rotation===void 0||e.rotation===null||(e.rotation=e.rotation.slice(0,3).map(r=>r*Sa))});let t=n.geometry;t&&t.type==="SphereGeometry"&&(t.thetaLength=(t.thetaLength??180)*Sa),t&&t.type==="TorusGeometry"&&(t.arc=t.arc*Sa),t&&t.type==="PathGeometry"&&(t.extrusion.angle*=Sa,t.extrusion.twist*=Sa),n.type==="Mesh"&&n.geometry.type==="TextGeometry"&&(n.geometry.text={textValue:n.geometry.text}),Array.isArray(ut(n.events))&&n.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 hT(n){n.shared.variables=rr({},xe.prototype)}function mT(n){let t=ut(n.shared.variables);n.shared.variables=rr(Object.entries(t??{}).map(([e,r],o)=>({fi:o,id:e,data:r})),Se.prototype)}var mo=111;function D0(n,t){t(n.data);for(let e of n.children)D0(e,t)}function yT(n){let t=n.schema??104;t!==mo&&t<105&&(D0(n.asset,N0),n.schema=105)}function gT(n){n.shared.particles=rr({},xe.prototype),n.shared.lib&&(n.shared.lib.particles=jo.defaultData().particles)}function xT(n){n.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 ou(n){let t=n.schema??0;if(t!==mo){console.warn("updating from ",t,"to ",mo),T0(n,t),t<100&&(n.scene.publish.joystickSizeAndXYOffset===void 0&&(n.scene.publish.joystickSizeAndXYOffset=Hr.defaultData.joystickSizeAndXYOffset),n.schema=100),t<101&&(Ho(n,M0),Uo(n,M0),n.schema=101),t<102&&(pT(n),n.schema=102),t<104&&(n.shared.catelogs=new xe,n.shared.lib=jo.defaultData(),n.schema=104),t<105&&(hT(n),n.scene.objects.traverse((e,r)=>{N0(r)}),n.schema=105);for(let e of Object.values(n.shared.lib.components))yT(e);t<106&&(mT(n),n.schema=106),t<107&&(n.shared.lib.variables=jo.defaultData().variables,n.schema=107),t<109&&(gT(n),n.schema=109),t<110&&(xT(n),n.schema=110),t<111&&(n.scene.objects.traverse((e,r)=>{fT(r)}),n.schema=111)}}var xa;(l=>{l.defaultData={schema:mo,scene:ko.defaultData,frames:new xe().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",ba.defaultData),shared:{...Nr.emptyData(),colors:Nr.defaultColors()}},l.emptyDataForImports=function(u){let c=ko.emptyDataWithPage(u);return{schema:mo,scene:c,frames:new xe().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",ba.defaultData),shared:{...Nr.emptyData(),colors:Nr.defaultColors(),images:Nr.defaultImages(u)}}},l.emptyData=function(){return{schema:mo,scene:ko.emptyDataWithPage(),frames:new xe().add("72fc2993-2da3-4b6b-96ac-2879db3a28bd",ba.defaultData),shared:Nr.emptyData()}},l.clipboard2dData=function(){return{schema:mo,scene:ko.emptyData(),frames:new xe,shared:Nr.emptyData()}},l.collabHelper={...js,updateSchema(u){return(u.schema??0)<mo?fn(u,ou):(u.schema??0)-mo}};function i(u){let c=l.collabHelper.updateSchema(u);return typeof c=="number"?c===0?u:null:c.data}l.updateSchemaDirectly=i;function a(u){return{...u,shared:{...u.shared,lib:jo.defaultData()}}}l.withoutLib=a;function s(u,c){let d=u.scene.objects.get(c);if(d&&d.data.type==="Component")return d;{let p=u.shared.lib.components[c];if(p)return p.asset}}l.getComponentData=s})(xa||(xa={}));var E0;(t=>{function n(e){return!0}t.is=n})(E0||(E0={}));var nu;(r=>{r.defaultData={position:[0,0],scale:[1,1],rotation:0,shear:[0,0]};function t(o,i){return{position:i?.position??o.position,rotation:i?.rotation??o.rotation,scale:i?.scale??o.scale,shear:i?.shear??o.shear}}r.merge=t;function e(o,i){return Yl({position:ua.isEqual(o.position,i.position)?void 0:i.position,rotation:o.rotation===i.rotation?void 0:i.rotation,scale:ua.isEqual(o.scale,i.scale)?void 0:i.scale,shear:o.shear&&i.shear&&ua.isEqual(o.shear,i.shear)?void 0:i.shear})}r.diff=e})(nu||(nu={}));var Pp;(t=>t.defaultData={horizontalConstraint:0,verticalConstraint:0})(Pp||(Pp={}));var iu;(t=>t.defaultData={opacity:1,fill:{color:Ie.fromHexAndA(St,1),enabled:!0},stroke:{color:Ie.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:Ie.from0to1([0,0,0,1]),enabled:!1,spread:0},innerShadow:{offset:[10,10],blurRadius:10,color:Ie.from0to1([0,0,0,1]),enabled:!1,spread:0}})(iu||(iu={}));var ii;(i=>{function n(a,s){return{name:s}}i.newEmpty=n;function t(a,s){if(s===void 0)return a;let l={...a},u=["width","height","cornerRadius"];for(let c of u)c in l&&c in s&&s[c]!==void 0&&Object.assign(l,{[c]:s[c]});return l}function e(a,s){if(s===void 0)return a;let l={...a};return"fill"in l&&"fill"in s&&s.fill!==void 0&&Object.assign(l,{fill:{...l.fill,...s.fill}}),"stroke"in l&&"stroke"in s&&s.stroke!==void 0&&Object.assign(l,{stroke:{...l.stroke,...s.stroke}}),"layerBlur"in l&&"layerBlur"in s&&s.layerBlur!==void 0&&Object.assign(l,{layerBlur:{...l.layerBlur,...s.layerBlur}}),"backgroundBlur"in l&&"backgroundBlur"in s&&s.backgroundBlur!==void 0&&Object.assign(l,{backgroundBlur:{...l.backgroundBlur,...s.backgroundBlur}}),"dropShadow"in l&&"dropShadow"in s&&s.dropShadow!==void 0&&Object.assign(l,{dropShadow:{...l.dropShadow,...s.dropShadow}}),"innerShadow"in l&&"innerShadow"in s&&s.innerShadow!==void 0&&Object.assign(l,{innerShadow:{...l.innerShadow,...s.innerShadow}}),l}function r(a,s){if(s===void 0)return a;let l={...a};return Object.assign(l,nu.merge(l,s)),l=t(l,s),l=e(l,s),l}i.patch=r;function o(a,s){let l,u=[];for(let[c,d]of Object.entries(s))c!=="name"&&(l===void 0&&(l={path:[],props:{},type:0},u.push(l)),l.props[c]=d);return u}i.toOps=o})(ii||(ii={}));var Xs;(t=>t.defaultData={...nu.defaultData,...Pp.defaultData,states:new Se,events:new Se,visible:!0,raycastLock:!1})(Xs||(Xs={}));var wa;(t=>t.defaultData={...Xs.defaultData,...iu.defaultData})(wa||(wa={}));var au;(t=>t.defaultData={cornerRadius:[0,0,0,0]})(au||(au={}));var Op;(t=>t.defaultData={...wa.defaultData,type:"ellipse2d",width:100,height:100,name:"Ellipse"})(Op||(Op={}));var Aa;(t=>t.defaultData={...wa.defaultData,...au.defaultData,type:"rectangle2d",width:100,height:100,name:"Rectangle"})(Aa||(Aa={}));var Cp;(t=>t.defaultData={...wa.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"})(Cp||(Cp={}));var Tp;(t=>t.defaultData={...wa.defaultData,type:"path2d",path:"",name:"Path"})(Tp||(Tp={}));var B0;(t=>{function n(e){return e.type==="ellipse2d"||e.type==="rectangle2d"||e.type==="text2d"||e.type==="vector2d"||e.type==="path2d"}t.is=n})(B0||(B0={}));var Qs;(t=>t.defaultData={...Xs.defaultData,name:"Group",type:"group2d"})(Qs||(Qs={}));var Mp;(t=>t.defaultData={...Xs.defaultData,...au.defaultData,...iu.defaultData,name:"Frame",type:"frame2d",clipped:!0,width:200,height:200,fill:{color:Ie.fromHexAndA(4737101,1),enabled:!0},stroke:{color:Ie.fromHexAndA(0,1),thickness:1,enabled:!1,mode:"inside"},backgroundBlur:{radius:2,enabled:!1},layerBlur:{radius:2,enabled:!1}})(Mp||(Mp={}));var qo;(o=>{function n(i){switch(i){case"rectangle2d":return{...Aa.defaultData};case"ellipse2d":return{...Op.defaultData};case"text2d":return{...Cp.defaultData};case"vector2d":return{...Aa.defaultData};case"path2d":return{...Tp.defaultData};case"frame2d":return{...Mp.defaultData};case"group2d":return{...Qs.defaultData}}}o.defaultData=n;function t(i){return"width"in i&&"height"in i?[typeof i.width=="number"?i.width*.5:0,typeof i.height=="number"?i.height*.5:0]:[0,0]}o.getPivot=t;function e(i){return i.type==="rectangle2d"||i.type==="ellipse2d"||i.type==="text2d"||i.type==="frame2d"}o.isResizeable=e;function r(i){return i.type==="rectangle2d"||i.type==="frame2d"}o.hasCorners=r})(qo||(qo={}));var su;(e=>(e.defaultData={name:"UI",type:"scene2d",objects:new Je},e.emptyData=function(){return{type:"scene2d",objects:new Je}}))(su||(su={}));var bs=Ht(R0());import{Object3D as mN,Vector3 as Pr,Euler as ph,MathUtils as gv,Matrix4 as wi}from"three";var bT=.5*(Math.sqrt(3)-1),Ks=(3-Math.sqrt(3))/6,vT=1/3,yo=1/6,Sq=(Math.sqrt(5)-1)/4,wq=(5-Math.sqrt(5))/20,Zs=n=>Math.floor(n)|0,V0=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]),Np=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 lu(n=Math.random){let t=G0(n),e=new Float64Array(t).map(o=>V0[o%12*2]),r=new Float64Array(t).map(o=>V0[o%12*2+1]);return function(i,a){let s=0,l=0,u=0,c=(i+a)*bT,d=Zs(i+c),p=Zs(a+c),f=(d+p)*Ks,h=d-f,m=p-f,y=i-h,g=a-m,b,w;y>g?(b=1,w=0):(b=0,w=1);let A=y-b+Ks,S=g-w+Ks,P=y-1+2*Ks,O=g-1+2*Ks,x=d&255,D=p&255,N=.5-y*y-g*g;if(N>=0){let E=x+t[D],B=e[E],R=r[E];N*=N,s=N*N*(B*y+R*g)}let T=.5-A*A-S*S;if(T>=0){let E=x+b+t[D+w],B=e[E],R=r[E];T*=T,l=T*T*(B*A+R*S)}let I=.5-P*P-O*O;if(I>=0){let E=x+1+t[D+1],B=e[E],R=r[E];I*=I,u=I*I*(B*P+R*O)}return 70*(s+l+u)}}function z0(n=Math.random){let t=G0(n),e=new Float64Array(t).map(i=>Np[i%12*3]),r=new Float64Array(t).map(i=>Np[i%12*3+1]),o=new Float64Array(t).map(i=>Np[i%12*3+2]);return function(a,s,l){let u,c,d,p,f=(a+s+l)*vT,h=Zs(a+f),m=Zs(s+f),y=Zs(l+f),g=(h+m+y)*yo,b=h-g,w=m-g,A=y-g,S=a-b,P=s-w,O=l-A,x,D,N,T,I,E;S>=P?P>=O?(x=1,D=0,N=0,T=1,I=1,E=0):S>=O?(x=1,D=0,N=0,T=1,I=0,E=1):(x=0,D=0,N=1,T=1,I=0,E=1):P<O?(x=0,D=0,N=1,T=0,I=1,E=1):S<O?(x=0,D=1,N=0,T=0,I=1,E=1):(x=0,D=1,N=0,T=1,I=1,E=0);let B=S-x+yo,R=P-D+yo,F=O-N+yo,V=S-T+2*yo,q=P-I+2*yo,k=O-E+2*yo,U=S-1+3*yo,H=P-1+3*yo,Y=O-1+3*yo,J=h&255,Z=m&255,X=y&255,te=.6-S*S-P*P-O*O;if(te<0)u=0;else{let W=J+t[Z+t[X]];te*=te,u=te*te*(e[W]*S+r[W]*P+o[W]*O)}let $=.6-B*B-R*R-F*F;if($<0)c=0;else{let W=J+x+t[Z+D+t[X+N]];$*=$,c=$*$*(e[W]*B+r[W]*R+o[W]*F)}let ee=.6-V*V-q*q-k*k;if(ee<0)d=0;else{let W=J+T+t[Z+I+t[X+E]];ee*=ee,d=ee*ee*(e[W]*V+r[W]*q+o[W]*k)}let Q=.6-U*U-H*H-Y*Y;if(Q<0)p=0;else{let W=J+1+t[Z+1+t[X+1]];Q*=Q,p=Q*Q*(e[W]*U+r[W]*H+o[W]*Y)}return 32*(u+c+d+p)}}function G0(n){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+~~(n()*(256-r)),i=e[r];e[r]=e[o],e[o]=i}for(let r=256;r<512;r++)e[r]=e[r-256];return e}import{Triangle as ST}from"three";var qr=new ST,cu=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 i=1;qr.a.fromBufferAttribute(t,o),qr.b.fromBufferAttribute(t,o+1),qr.c.fromBufferAttribute(t,o+2),i*=qr.getArea(),e[o/3]=i}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,i=-1;for(;r<=o;){let a=Math.ceil((r+o)/2);if(a===0||e[a-1]<=t&&e[a]>t){i=a;break}else t<e[a]?o=a-1:r=a+1}return i}sampleFace(t,e,r){let o=this.randomFunction(),i=this.randomFunction();return o+i>1&&(o=1-o,i=1-i),qr.a.fromBufferAttribute(this.positionAttribute,t*3),qr.b.fromBufferAttribute(this.positionAttribute,t*3+1),qr.c.fromBufferAttribute(this.positionAttribute,t*3+2),e.set(0,0,0).addScaledVector(qr.a,o).addScaledVector(qr.b,i).addScaledVector(qr.c,1-(o+i)),qr.getNormal(r),this}};import{Object3D as OT}from"three";var j0=Ht(k0());import{Object3D as wT,Matrix4 as go}from"three";var AT=new go,_T=new go,PT=new go,_a;(t=>{function n(e){return e&&e.__isSPEObject}t.is=n})(_a||(_a={}));var Pa=n=>class extends n{constructor(){super(...arguments);this.previousModelViewMatrix=new go;this.copyPreviousMatrix=!0;this.hiddenMatrix=new go;this.matrixWorldRigid=new go;this.shearScale=new go;this.shearScaleInv=new go}get __isSPEObject(){return!0}isDescendantOf(r){r instanceof wT&&(r=r.uuid);let o=this;for(;o.parent;){if(o.parent.uuid===r)return!0;o=o.parent}return!1}updateMatrixWorld(r){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||r)&&(this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,r=!0);for(let o of this.children)o.updateMatrixWorld(r)}updateWorldMatrix(r,o){let i=this.parent;if(r&&i!==null&&i.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),o)for(let a of this.children)a.updateWorldMatrix(!1,!0)}traverseChildren(r,o=0){for(let i of this.children)_a.is(i)&&i.traverseObject(r,o+1)}traverseObject(r,o=0){if(r(this,o)!==!0)for(let a of this.children)_a.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:i,v:a,q:s}=(0,j0.SVD)(o),l=AT.set(i[0][0],i[0][1],i[0][2],0,i[1][0],i[1][1],i[1][2],0,i[2][0],i[2][1],i[2][2],0,0,0,0,1),u=_T.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),c=PT.copy(u).transpose();this.shearScale.makeScale(s[0],s[1],s[2]).multiply(c).premultiply(u),this.shearScaleInv.copy(this.shearScale).invert(),this.matrixWorldRigid.multiplyMatrices(l,c).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 i=new go().copy(this.matrixWorld).invert();return r.parent!==null&&(r.parent.updateWorldMatrix(!0,!1),i.multiply(r.parent.matrixWorld)),"hiddenMatrix"in r&&r.hiddenMatrix instanceof go?r.hiddenMatrix.premultiply(i):r.applyMatrix4(i),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,i,a,s,l){this.copyPreviousMatrix&&this.previousModelViewMatrix.copy(this.modelViewMatrix)}};var Dp=class extends Pa(OT){},CT=n=>n.type==="Mesh",Wo=class extends Dp{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 Wo(r),this.add(o),this.children.splice(e,0,this.children.pop()),o.matrixWorldNeedsUpdate=!0,o.matrixAutoUpdate=!1,o.matrix=r.matrix,o.hiddenMatrix=r.hiddenMatrix),o.expand(),e+=1,r=this.object.entityChildren(e)}for(;this.children.length>e;)this.remove(this.children[e])}get visible(){return this.playModeVisible!==void 0?this.playModeVisible:this.object.visible||this.object.dataPatched.visible&&this.object.dataPatched.cloner?.hideBase===!0}set visible(e){}get castShadow(){return this.object.castShadow}set castShadow(e){}get receiveShadow(){return this.object.receiveShadow}set receiveShadow(e){}get isMesh(){return CT(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}};import{Box3 as zI,BufferGeometry as GI,MeshBasicMaterial as FI}from"three";import{Matrix4 as RI,Mesh as VI}from"three";import{Matrix4 as pu,Vector3 as q0,Euler as ET,MathUtils as el}from"three";import{Box3 as TT,Line3 as MT,Matrix4 as Ep,Vector3 as wr}from"three";var ai=new wr,si=new wr,Oa=new Ep,H0=[new wr(-1,1,1),new wr(-1,-1,1),new wr(1,-1,1),new wr(1,1,1),new wr(-1,1,-1),new wr(-1,-1,-1),new wr(1,-1,-1),new wr(1,1,-1)],IT=[[0,3],[1,2],[5,6],[4,7],[0,1],[3,2],[7,6],[4,5],[0,4],[1,5],[2,6],[3,7]],NT=[[0,2],[7,5],[4,1],[3,6],[4,3],[1,6]],U0=(n,t,e)=>{n.updateEntityBoxSize(ai,si),Oa.copy(t).multiply(n.matrixWorld),si.x===0&&si.y===0&&si.z===0?e.push(new wr(ai.x,ai.y,ai.z).applyMatrix4(Oa)):H0.forEach(r=>{e.push(r.clone().multiply(si).add(ai).applyMatrix4(Oa))})},Js=class extends TT{constructor(){super(...arguments);this.matrix=new Ep;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 Ep().copy(e.matrixWorld).invert();return this.expandByObjectSize(e,o,r)}expandByObjectSize(e,r,o=!1){let i=[];return o===!0?e.traverseEntity(a=>{if(a.visible||a.cloner&&a.data.visible){if(!("geometry"in a)){i.push(new wr);return}U0(a,r,i)}}):U0(e,r,i),this.setFromPoints(i)}getCenter(e){return e=super.getCenter(e),e.applyMatrix4(this.matrix),e}getPositionToCenter(e){return e=super.getCenter(e),e.applyMatrix4(Oa.copy(this.matrix).setPosition(0,0,0)),e}computeVertices(){this.getSize(si).multiplyScalar(.5),this.getCenter(ai),Oa.copy(this.matrix).setPosition(ai),this.vertices=H0.map(e=>e.clone().multiply(si).applyMatrix4(Oa))}computeEdges(){this.vertices.length>0&&this.computeVertices(),this.edges=IT.map(([e,r])=>new MT(this.vertices[e],this.vertices[r])),this.centerEdges=this.edges.map(e=>e.getCenter(new wr))}computeFaces(){this.vertices.length>0&&this.computeVertices(),this.faces=NT.map(([e,r])=>this.vertices[e].clone().add(this.vertices[r]).multiplyScalar(.5))}};var Wr={Cloner:()=>{},changeEntityProptotype:()=>{},createEntity:()=>{}};import{CurvePath as DT,CubicBezierCurve3 as Bp,Vector3 as $r}from"three";var Rp=class extends DT{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 u=l[s],c=s===0?o[s]:o[s]-o[s-1],d=Math.ceil(t*c/a),p=u.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 Vp=.001;function zp(n,t,e){return t.clone().sub(n).cross(t.clone().sub(e)).length()<=Vp}function Lp(n,t){let e=new $r(...n.position),r=new $r(...n.controlNext.position),o=new $r(...t.controlPrevious.position),i=new $r(...t.position);return zp(e,r,i)&&zp(e,o,i)}function du(n){let t=n.points.map(c=>new $r(...c.data.position)),e=[n.points[0]],r=new $r(...e[0].data.position);for(let c=0;c<n.points.length-1;c++)zp(r,t[c],t[c+1])||(e.push(n.points[c]),r=t[c]);e.push(n.points[n.points.length-1]);let o=n.isClosed,i=e.length-(o?0:1),a=e.length,s=[];for(let c=0;c<a;c++){let d=e[c].data,p=new $r(...d.position),f=new $r(...d.controlPrevious.position),h=new $r(...d.controlNext.position),m={position:p,baseRoundness:d.roundness,controlPrevious:f,controlNext:h};if(d.roundness===0||!n.isClosed&&(c===0||c===a-1)){s[c]={...m,removedLength:0};continue}let y=o&&c==0?a-1:c-1,g=o&&c==a-1?0:c+1,b=e[y].data,w=e[g].data,A=new $r(...b.position),S=new $r(...w.position),P=A.clone().sub(p).normalize(),O=S.clone().sub(p).normalize();Object.assign(m,{prevDir:P,nextDir:O});let x=Lp(b,d),D=Lp(d,w);if(!x||!D)s[c]={...m,removedLength:0};else{let N=P.clone().add(O).normalize(),T=N.clone().cross(P).length()/P.dot(N);s[c]={...m,tan:T,removedLength:d.roundness/T}}}for(let c=0;c<i;c++){let d=c,p=o&&c===a-1?0:c+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 c=0;c<i;c++){let d=c,p=o&&c===a-1?0:c+1,f=s[d],h=s[p],m=null;if(!Lp(e[d].data,e[p].data))f.position.distanceTo(h.position)>Vp&&(m=new Bp(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)>Vp&&(m=new Bp(y,y.clone().lerp(g,.3),g.clone().lerp(y,.3),g))}l[2*c+1]=m}for(let c=0;c<a;c++){let d=s[c];if(d.removedLength===0){l[2*c]=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),A=y.clone().multiplyScalar(-m).add(w),S=p.distanceTo(A)/p.distanceTo(g),P=d.prevDir.clone().multiplyScalar(S*p.distanceTo(f)).add(p),O=P.clone().lerp(A,2),x=f.clone().lerp(P,4/3),D=h.clone().lerp(O,4/3);l[2*c]=new Bp(f,x,D,h)}let u=new Rp;return l.forEach(c=>{c&&u.add(c)}),u}var Re;(t=>{function n(e){return e&&e.__isEntity}t.is=n})(Re||(Re={}));var Ca=n=>Re.is(n),BT={type:"completeState",isfromEntity:!0},LT=["x","y","z"],Gp=new q0,RT=new q0().set(0,1,0),Ta=n=>class extends Pa(n){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.reversibleToState=null;this.currentTransitionEvent=null;this.previousAction=null;this._singleBBox=new Js;this._recursiveBBox=new Js;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(Re.is(o))return o}entityChildrenCount(){let r=this.children.length;for(;r--;)if(Re.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(Re.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,i=!1){if(!(this.data.states.length===0&&!i)){for(let a of this.data.states)ni.toOps(this.data,a.data).forEach(l=>{let u=aa.replaceProps(l,this.data);this.dataPatched=this.data,this.updateByPatchedOp(u,this.data,o)});if(r!==null){let a=this.data.states.data(r);a&&(this.dataPatched=ni.patch(this.data,a),ni.toOps(this.data,a).forEach(l=>{this.updateByPatchedOp(l,this.dataPatched,o)}))}i&&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=>{Ca(r)&&r.resetBBoxNeedsUpdateSelf()}),this.traverseEntity(r=>{r.resetBBoxNeedsUpdateSelf()})}find(r){let o;return this.traverseEntity(i=>{i.uuid===r&&(o=i)}),o}traverseSortNextHelper(){let r=this.parent;if(r){let o=r.children,i=o.indexOf(this)+1;if(Re.is(o[i]))return o[i];if(Re.is(r))return r.traverseSortNextHelper()}}sortNext(){let r=this.children;return this.children.length>0&&Re.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,i=this;for(;i!==r;){if(i===null)return-1;i=i.parent,o+=1}return o}forEachEntity(r){for(let o of this.children)Ca(o)&&r(o)}traverseEntityAncestors(r){this.traverseAncestors(o=>{Re.is(o)&&r(o)})}traverseConcreteEntity(r,o=0){if(r(this,o)!==!0)for(let a of this.children)Ca(a)&&a.isConcreteEntity&&a.traverseEntity(r,o+1)}traverseEntity(r,o=0){if(r(this,o)!==!0)for(let a of this.children)Ca(a)&&a.traverseEntity(r,o+1)}traverseVisibleEntity(r){r(this);for(let o of this.children)Ca(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=>Ca(r))}isAncestorOf(r){if(this.uuid===r)return!1;let o=!1;return this.traverseEntity(i=>{i.uuid===r&&(o=!0)}),o}toObjectTransformState(r=[]){this.updateWorldMatrix(!0,!1);let o={position:this.position.toArray(),rotation:[this.rotation.x*el.RAD2DEG,this.rotation.y*el.RAD2DEG,this.rotation.z*el.RAD2DEG],scale:this.scale.toArray(),hiddenMatrix:this.hiddenMatrix.toArray()};return ta(o,r)}getTransformValues(r,o,i){return o[r].map((a,s)=>i?.shared.getVariable(a,[this.uuid,r,LT[s]])??a)}updateTransformState(r,o){let i=!1;return r.position&&(this.position.fromArray(this.getTransformValues("position",r,o)),i=!0),r.rotation&&(Gp.fromArray(this.getTransformValues("rotation",r,o)).multiplyScalar(el.DEG2RAD),this.rotation.setFromVector3(Gp),i=!0),r.scale&&(this.scale.fromArray(this.getTransformValues("scale",r,o)),i=!0),r.hiddenMatrix!==void 0&&(i=!0,this.hiddenMatrix.fromArray(r.hiddenMatrix??xn.identity)),i&&(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),i}onVariableUpdate(r=!1){if(r){this.resetBBoxNeedsUpdate();return}this.updateMatrix(),this.resetBBoxNeedsUpdate(),this.invalidateClonerTransform(this),this.traverseEntityAncestors(o=>{o.invalidateClonerTransform(this)})}dispose(){this.disposed=!0,this.cloner&&(this.cloner.removeFromParent(),this.cloner=void 0)}disposeChildrenRecursively(){for(let r of this.children)Re.is(r)&&r.disposeRecursively()}disposeRecursively(){this.dispose(),this.children.forEach(r=>{Re.is(r)&&r.disposeRecursively()})}toState(r=[]){let o={name:this.name,visible:this.visible,raycastLock:this.raycastLock,...this.toObjectTransformState(r)};return ta(o,r)}updateByObjUpdateOp(r,o){r!==void 0&&this.updateByOp({type:0,props:r,path:[]},{...this.data,...r},o,!1)}updateByOp(r,o,i,a){let s=this.data;this.data=o;let l=r,u=Le(r.path,["states","*"]);if(u!==null){if(r.type===0){let[c]=u;if(this?.stateSelection===c){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=lt.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 c=this.stateSelection?this.data.states.data(this.stateSelection):void 0;if(c!==void 0){if(r.props.name!==void 0&&c.name){let{name:p,...f}=c;c=f}if(r.props.material!==void 0&&"material"in c){let{material:p,...f}=c;c=f}let d=lt.removeOverridden(r.path,r.props,c);l={...r,props:d}}}if(this.updateByPatchedOpBase(l,ni.patch(this.data,this.stateSelection?this.data.states.data(this.stateSelection):void 0),i),Le(r.path,["overrides"])){let c=[],d=[...r.path];for(c.push(d[1]),d.splice(0,2);d.length>0&&d[0]==="descendants";)c.push(d[1]),d.splice(0,2);if(c[c.length-1]===void 0){if(r.type===0)for(let p of Object.keys(r.props)){c[c.length-1]=p;let f=i.scene.findInstance([this.uuid,...c]);f&&(f.overrideData=r.props[p],f.updateState(so.apply(f.component.data,f.overrideData),i))}}else{let p=i.scene.findInstance([this.uuid,...c]);if(p){let f=lt.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=ya.resolve(o.overrides,c),p.updateByOp(r,ct.applySimple(p.data,r),i,!1)}}}else if(this.instances.length>0){let c;if(r.path.length===0&&r.type===0){let d;for(let p of ho.rootOverrideProps)p in r.props&&(d===void 0&&(d={}),d[p]=r.props[p]);d&&(c={...r,props:d})}else for(let d of ho.rootOverrideProps)if(Le(r.path,[d])){c=r;break}c!==void 0&&this.instances.forEach(d=>{if(d.isInstanceRoot){let p=so.filterOp(d.overrideData,c);p&&d.updateByOp(p,ct.applySimple(d.data,p),i,!0)}}),this.instances.forEach(d=>{if(!d.isInstanceRoot){let p=so.filterOp(d.overrideData,r);if(p){let f;s===d.data&&r===p?f=o:f=ct.applySimple(d.data,p),d.updateByOp(p,f,i,!0)}}})}}updateByPatchedOpBase(r,o,i){if(this.dataPatched=o,r.path.length===0&&r.type===0)r.props.type!==void 0&&!Ur.is(r.props.type)&&Wr.changeEntityProptotype(this,o,i);else if(r.path.length===1&&r.path[0]==="geometry"&&r.type===0&&"type"in r.props){Wr.changeEntityProptotype(this,o,i);for(let a of this.children)Re.is(a)&&a.updateVisible(i.scene)}this.updateByPatchedOp(r,o,i)}updateByPatchedOp(r,o,i){if(r.path.length===0&&r.type===0&&this.updateState(r.props,i),Le(r.path,["pathSnapping"])!==null&&this.updatePathSnapping(o.pathSnapping),Le(r.path,["cloner"])!==null){let a=ct.drop(r,1);a.path.length===0&&a.type===0&&a.props.disabled===!0?this.setFromClonerState(null,i):this.cloner?this.cloner.updateState(o.cloner,i.scene):(this.setFromClonerState(o.cloner,i),this.expandCloner(i.scene)),this.updateVisible(i.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,i=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 u=l.data;if(u.geometry.path.points.length<=1)return;let c=du(u.geometry.path),d=(i+a)%1;i+a===1&&d===0&&(d=1);let p=c.getPointAt(d);if(p===null)return;let f=this.parent?this.parent?.matrixWorld:new pu;l.updateMatrixWorld();let h=new pu().multiplyMatrices(f.clone().invert(),l.matrixWorld);p.applyMatrix4(h);let m={position:p.toArray(),rotation:u.rotation};if(s==="tangential"){let y=new pu().extractRotation(l.matrixWorld),g=c.getTangentAt(d).applyMatrix4(y).add(p),b=new pu().lookAt(p,g,RT),w=Gp.setFromEuler(new ET().setFromRotationMatrix(b)).multiplyScalar(el.RAD2DEG);m={...m,rotation:w.toArray()}}this.updateTransformState(m),this.traverseEntity(y=>{y._cameraType&&y.dispatchEvent(BT)})}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(i=>{if(i.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 Wr.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 Wr.Cloner(this,r),o.scene.addPendingExpandCloner(this)):this.cloner.updateState(r,o.scene))}expandCloner(r){!this.disposed&&this.cloner&&this.cloner.expandClones(r)}invalidateClonerTransform(r){this.cloner&&this.cloner.invalidateTransform(r)}requestRender(){this.dispatchEvent({type:"requestRender"})}};import{BufferGeometry as GT,ConeGeometry as FT,Float32BufferAttribute as kT,MathUtils as jT}from"three";import{BufferGeometry as $0,CylinderGeometry as VT,Float32BufferAttribute as hu,MathUtils as zT,Vector2 as Yr,Vector3 as fu}from"three";var Y0=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,radialSegments:64,heightSegments:1,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadius:8,cornerSegments:8,hollow:0},n.parameters);e.thetaLength=zT.clamp(e.thetaLength,0,360);let r=e.width/2,o=e.radiusTop??r,i=e.radiusBottom??r;return o===i?(o=r,i=r):o>i?(o=r,i=i*r/o):(o=o*r/i,i=r),{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width),radiusTop:o,radiusBottom:i})}}static build(n){let{width:t,depth:e,height:r,radialSegments:o,heightSegments:i,openEnded:a,thetaStart:s,thetaLength:l,radiusTop:u,radiusBottom:c,cornerRadius:d,cornerSegments:p,hollow:f}=n.parameters,h;return l===0?(h=new $0,h.setAttribute("position",new hu([],3))):d||f?h=new tl(u,c,r,o,i,a,s,l*Math.PI/180,d,d,p,f):h=new VT(u,c,r,o,i,a,s,l*Math.PI/180),h.scale(1,1,e/t),Object.assign(h,{userData:{...n,type:"CylinderGeometry"}})}};function _n(n,t,e){e.x=n.x*t.x,e.y=n.y,e.z=n.x*t.y}function W0(n){return new Yr(n.y,-n.x)}var tl=class extends $0{constructor(t,e,r,o,i,a,s,l,u,c,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,i=Math.floor(i)||1,a=a!==void 0?a:!1,s=s!==void 0?s:0,l=l!==void 0?l:Math.PI*2,a&&(u=0,c=0);let h=[],m=[],y=[],g=[],b=0,w=r/2,A=new fu,S=new fu;f&&t==0&&(t=u),f&&e==0&&(e=c);let P=new Yr(t,w),O=new Yr(e,-w),x=null,D=null,N=null,T=null,I=P.clone().sub(O),E=0,B=0,R=0;p>0&&(E=Math.min(t,e)*(1-p),B=t-E,R=e-E);let F=P.clone();F.x-=E;let V=Math.PI-I.angle(),q=I.angle(),k=Math.tan(q/2),U=Math.tan(V/2),H=k+U,Y=p?H:U,J=p?H:k;if(u=Math.min(u,(t-B)/Y,I.length()/H),c=Math.min(c,(e-R)/J,I.length()/H),u>0){let Q=u/k;x=P.clone().sub(new Yr(Q,u)),p&&(N=x.clone(),N.x-=E-H*u),P.sub(I.clone().setLength(Q))}if(c>0){let Q=c/U;D=O.clone().sub(new Yr(Q,-c)),O.add(I.clone().setLength(Q)),p&&(T=D.clone(),T.x-=E-H*c,F.sub(I.clone().setLength(Q)))}I=P.clone().sub(O);let Z=I.length()<.5,X=[];for(let Q=0;Q<=o;Q++){let W=[],ue=Q/o,le=ue*l+s,ne=new Yr(Math.sin(le),Math.cos(le));T&&D?(te(W,ue,ne,V,c,T,-1,!0),te(W,ue,ne,q,c,D,-1,!1)):D?($(W,ne,D.x,0,-1),te(W,ue,ne,q,c,D,-1,!1)):a||$(W,ne,e,R,-1);let ce=W0(I).normalize();if(_n(ce,ne,A),!Z)for(let ae=0;ae<=i;ae++){let he=ae/i,pe=I.clone().multiplyScalar(he).add(O);_n(pe,ne,S),m.push(S.x,S.y,S.z),y.push(A.x,A.y,A.z),g.push(ue,.5+S.y/r),W.push(b++)}if(N&&x?(te(W,ue,ne,V,u,x,1,!1),te(W,ue,ne,q,u,N,1,!0)):x?(te(W,ue,ne,V,u,x,1,!1),$(W,ne,x.x,0,1)):a||$(W,ne,t,B,1),p&&!Z){let ae=W0(I).multiplyScalar(-1).normalize();_n(ae,ne,A);for(let he=0;he<=i;he++){let pe=he/i,fe=I.clone().multiplyScalar(-pe).add(F);_n(fe,ne,S),m.push(S.x,S.y,S.z),y.push(A.x,A.y,A.z),g.push(ue,.5+S.y/r),W.push(b++)}}p&&!a&&W.push(W[0]),X.push(W)}for(let Q=0;Q<X.length-1;Q++)for(let W=0;W<X[0].length-1;W++){if(a&&p&&W==i)continue;let ue=X[Q][W],le=X[Q+1][W],ne=X[Q+1][W+1],ce=X[Q][W+1],ae=m[ne*3+0],he=m[ne*3+2];h.push(ue,le,ce),(ae!=0||he!=0)&&h.push(le,ne,ce)}l<Math.PI*2&&(ee(-1,X[0],s),ee(1,X[X.length-1],s+l)),this.setIndex(h),this.setAttribute("position",new hu(m,3)),this.setAttribute("normal",new hu(y,3)),this.setAttribute("uv",new hu(g,2));function te(Q,W,ue,le,ne,ce,ae,he){for(let pe=0;pe<d+1;pe++){let fe=pe/d,ge=ae<0?fe:1-fe;he&&(ge-=1),ge*=le;let me=new Yr(Math.sin(ge),Math.cos(ge)*ae),C=me.clone().multiplyScalar(ne).add(ce);_n(C,ue,S),m.push(S.x,S.y,S.z),_n(me,ue,A),y.push(A.x,A.y,A.z),g.push(W,.5+S.y/r),Q.push(b++)}}function $(Q,W,ue,le,ne){let ce=new fu,ae=new Yr,he=[ue,le];ne<0&&he.reverse();for(let pe of he)ae.set(pe,w*ne),_n(ae,W,ce),m.push(ce.x,ce.y,ce.z),y.push(0,ne,0),g.push(.5,.5),Q.push(b++)}function ee(Q,W,ue){let le=new Yr(Math.sin(ue),Math.cos(ue)),ne=new Yr(-Math.cos(ue),Math.sin(ue)),ce=new fu,ae=Q<0?(fe,ge,me)=>h.push(fe,ge,me):(fe,ge,me)=>h.push(fe,me,ge),he=new Yr((t+e+B+R)/4,0);_n(he,le,ce),m.push(ce.x,ce.y,ce.z),y.push(ne.x,0,ne.y),g.push(.5,.5);let pe=b++;for(let fe of W){let ge=m.slice(fe*3,fe*3+3);m.push(...ge),y.push(ne.x,0,ne.y);let me=g.slice(fe*2,fe*2+2);g.push(...me),b++}for(let fe=pe+1;fe<b-1;fe++)ae(pe,fe,fe+1);ae(pe,b-1,pe+1)}}};var X0=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,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},n.parameters);return e.thetaLength=jT.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(n){let{width:t,depth:e,height:r,radialSegments:o,heightSegments:i,openEnded:a,thetaStart:s,thetaLength:l,cornerRadiusTop:u,cornerRadiusBottom:c,cornerSegments:d}=n.parameters,p;return l===0?(p=new GT,p.setAttribute("position",new kT([],3))):u>0||c>0||l<360?p=new tl(0,t/2,r,o,i,a,s,l*Math.PI/180,u,c,d,0,!0):p=new FT(t/2,r,o,i,a),p.scale(1,1,e/t),Object.assign(p,{userData:{...n,type:"ConeGeometry"}})}};import{BoxGeometry as UT,BufferGeometry as HT,Float32BufferAttribute as Fp,Vector3 as rl}from"three";var Q0=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,widthSegments:1,heightSegments:1,depthSegments:1,cornerRadius:8,cornerSegments:8},n.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(n){let{width:t,height:e,depth:r,widthSegments:o,heightSegments:i,depthSegments:a,cornerRadius:s,cornerSegments:l}=n.parameters,u;return s==0?u=new UT(t,e,r,o,i,a):u=new jp(t,e,r,o,i,a,s,l),Object.assign(u,{userData:{...n,type:"CubeGeometry"}})}},kp=Math.PI/2,jp=class extends HT{constructor(t=1,e=1,r=1,o=1,i=1,a=1,s=0,l=4){super(),this.type="BoxGeometry";let u=this;o=Math.floor(o),i=Math.floor(i),a=Math.floor(a),l=Math.floor(l),s=Math.min(s,t/2,e/2,r/2);let c=[],d=[],p=[],f=[],h=0,m=0;y("z","y","x",-1,-1,r,e,t,a,i,0),y("z","y","x",1,-1,r,e,-t,a,i,1),y("x","z","y",1,1,t,r,e,o,a,2),y("x","z","y",1,-1,t,r,-e,o,a,3),y("x","y","z",1,-1,t,e,r,o,i,4),y("x","y","z",-1,-1,t,e,-r,o,i,5),s>0&&(g("z","y","x",-1,-1,1,r,e,t,a,0),g("z","y","x",1,-1,-1,r,e,t,a,1),g("z","y","x",-1,1,-1,r,e,t,a,1),g("z","y","x",1,1,1,r,e,t,a,0),g("x","y","z",-1,-1,-1,t,e,r,o,0),g("x","y","z",1,-1,1,t,e,r,o,1),g("x","y","z",-1,1,1,t,e,r,o,0),g("x","y","z",1,1,-1,t,e,r,o,1),g("y","x","z",-1,-1,1,e,t,r,i,0),g("y","x","z",1,-1,-1,e,t,r,i,1),g("y","x","z",1,1,1,e,t,r,i,1),g("y","x","z",-1,1,-1,e,t,r,i,0),b(1,1,1),b(-1,1,1),b(1,-1,1),b(-1,-1,1),b(1,1,-1),b(-1,1,-1),b(1,-1,-1),b(-1,-1,-1)),this.setIndex(c),this.setAttribute("position",new Fp(d,3)),this.setAttribute("normal",new Fp(p,3)),this.setAttribute("uv",new Fp(f,2));function y(w,A,S,P,O,x,D,N,T,I,E){let B=(x-2*s)/T,R=(D-2*s)/I,F=x/2-s,V=D/2-s,q=N/2,k=T+1,U=I+1,H=0,Y=0,J=new rl;for(let Z=0;Z<U;Z++){let X=Z*R-V;for(let te=0;te<k;te++){let $=te*B-F;J[w]=$*P,J[A]=X*O,J[S]=q,d.push(J.x,J.y,J.z),J[w]=0,J[A]=0,J[S]=N>0?1:-1,p.push(J.x,J.y,J.z),f.push(te/T),f.push(1-Z/I),H+=1}}for(let Z=0;Z<I;Z++)for(let X=0;X<T;X++){let te=h+X+k*Z,$=h+X+k*(Z+1),ee=h+(X+1)+k*(Z+1),Q=h+(X+1)+k*Z;c.push(te,$,Q),c.push($,ee,Q),Y+=6}u.addGroup(m,Y,E),m+=Y,h+=H}function g(w,A,S,P,O,x,D,N,T,I,E){let B=(D-2*s)/I,R=D/2-s,F=N/2-s,V=T/2,q=I+1,k=0,U=0,H=new rl,Y=new rl;for(let J=0;J<l+1;J++){let Z=J/l*kp,X=Math.sin(Z)*s,te=(1-Math.cos(Z))*s,$=Math.sin(Z),ee=Math.cos(Z);H[A]=(F+X)*O,H[S]=(V-te)*x,Y[w]=0,Y[A]=$*Math.sign(H[A]),Y[S]=ee*Math.sign(H[S]);for(let Q=0;Q<q;Q++){let W=Q*B-R;H[w]=W*P,d.push(H.x,H.y,H.z),p.push(Y.x,Y.y,Y.z),f.push(Q/I),f.push(0),k+=1}}for(let J=0;J<l;J++)for(let Z=0;Z<I;Z++){let X=h+Z+q*J,te=h+Z+q*(J+1),$=h+(Z+1)+q*(J+1),ee=h+(Z+1)+q*J;c.push(X,te,ee),c.push(te,$,ee),U+=6}u.addGroup(m,U,E),m+=U,h+=k}function b(w,A,S){let P=new rl,O=new rl(t/2,e/2,r/2);O.subScalar(s);let x=[],D=w*A*S>0?(T,I,E)=>c.push(T,I,E):(T,I,E)=>c.push(T,E,I);for(let T=0;T<=l;T++){let I=[],E=kp*(1-T/l),B=Math.cos(E),R=Math.sin(E),F=0;for(let V=0;V<=T;V++){let q=Math.cos(F),k=Math.sin(F);P.x=B*q,P.y=R,P.z=B*k;let U=O.clone().addScaledVector(P,s);d.push(w*U.x,A*U.y,S*U.z),p.push(w*P.x,A*P.y,S*P.z),f.push(0,0),I.push(h++),F+=kp/T}x.push(I)}let N=x.length-1;for(let T=0;T<N;T++){let I=x[T],E=x[T+1],B=I.length-1;D(I[0],E[1],E[0]);for(let R=1;R<=B;R++)D(I[R-1],I[R],E[R]),D(I[R],E[R+1],E[R])}}}};import{BufferGeometry as qT,Float32BufferAttribute as Up,Triangle as WT,Vector3 as $o,Vector2 as Hp}from"three";var Pn=class extends qT{constructor(t=[],e=[],r="",o=1,i=.2,a=4){super(),this.type="PolyhedronGeometryRound";let s=[],l=[],u=[];c(),d(),this.setAttribute("position",new Up(s,3)),this.setAttribute("normal",new Up(u,3)),this.setAttribute("uv",new Up(l,2));return;function c(){i=Math.min(1-1e-5,i),i==0&&(a=0);let f={IcosahedronGeometry:5,DodecahedronGeometry:3,HexahedronGeometry:3,OctahedronGeometry:4,TetrahedronGeometry:3}[r],h=new $o,m=h.clone(),y=new WT,g=i*o,b=o-g,w=a+1,A=new $o,S=(k,U)=>A.subVectors(k,U).normalize(),P=(k,U)=>Array(k).fill(void 0).map(U),O=P(t.length/3,(k,U)=>new $o().fromArray(t,U*3).setLength(o)),x=[],D=1e6;for(let k=0;k<O.length;k++){let U=O[k],H=[],Y,J,Z,X=1e10,te=-1;for(;(te=e.indexOf(k,te+1))!=-1;){let W=te-te%3;Y=e[W+(te+1)%3],J=e[W+(te+2)%3],Z=U.distanceToSquared(O[Y]),X=Math.min(X,Z),H.push([Y,J,Z])}X+=1e-6;let $=[],ee=0,Q=H.length;for(let W=0;W<Q;W++){[Y,J,Z]=H[ee];let ue=x[Y]?.includes(k)==!0;Z<=X&&$.push(Y+ +ue*D),ee=H.findIndex(le=>le[0]==J)}x.push($)}let N=[];{let k=0,U=0,H,Y,J=f==3;for(let Z=0;Z<=a;Z++){H=Z*(Z+1)/2,Y=(Z+1)*(Z+2)/2;for(let X=0;X<a-Z;X++)[k,U]=[H+X+Z+2,Y+X+Z+3],N.push(H,Y,...J?[U,H]:[k,Y],U,k),[H,Y]=[k,U];N.push(H,Y,H+a+2)}}let T=h.clone(),I=h.clone(),E=h.clone(),B=h.clone(),R=h.clone(),F=[],V=P(O.length,()=>P(f,()=>h.clone()));for(let k=0;k<O.length;k++){h.copy(O[k]).normalize(),T.copy(h).multiplyScalar(b);let U=x[k];for(let $=0;$<U.length;$++){let ee=U[$],Q=U[($+1)%f];y.setFromPointsAndIndices(O,k,ee%D,Q%D),y.b.sub(y.a).setLength(1e10).add(y.a),y.c.sub(y.a).setLength(1e10).add(y.a),y.closestPointToPoint(T,V[k][$])}let H=[],Y=[],J=[],Z=new $o;a==0&&[...V[k]].reduce(($,ee)=>$.add(ee),Z).multiplyScalar(1/f);for(let $=0;$<f;$++){let ee=[],Q=($-1+f)%f,W=V[k][Q],ue=V[k][$];h.copy(W).sub(T),m.copy(ue).sub(T);let le=T.angleTo(h),ne=h.angleTo(m),ce=Math.cos(le)*g;a==0?I.copy(Z):I.copy(T).setLength(b+ce),Y.push(ce);let ae=[I,W,ue];for(let he=0;he<2;he++){let pe=ae[he],fe=ae[he+1];B.subVectors(pe,T),R.subVectors(fe,T),E.crossVectors(B,R).normalize();for(let ge=0;ge<w;ge++){let me=[le,ne][he]*ge/w;h.copy(B).applyAxisAngle(E,me).add(T),H.push(h.clone()),he&&(S(h,T),ee.push([ge==0?pe:h.clone(),A.clone()]))}he&&(S(fe,T),ee.push([fe,A.clone()]))}J.push(ee)}F.push(J);let X=2*w,te=2;for(let $=0;$<f;$++){let ee=X*$,Q=X*(($+1)%f),W=[H[ee]];for(let le=1;le<w;le++){B=H[ee+le],R=H[Q+le],W.push(B);for(let ne=1,ce=le-te+1;ne<=ce;ne++)h.lerpVectors(B,R,ne/(ce+1)),h.sub(T).setLength(Y[$]).add(T),W.push(h.clone());W.push(R)}for(let le=0;le<w;le++)W.push(H[le+w+ee]);W.push(H[Q+w]);let ue=N.map(le=>W[le]);s.push(...ue.map(le=>[le.x,le.y,le.z]).flat()),u.push(...ue.map(le=>(S(le,T),[A.x,A.y,A.z])).flat())}}let q=[];for(let k=0;k<x.length;k++)for(let U=0;U<f;U++){let H=x[k][U];if(H<D){let Y=x[H].findIndex(X=>X%D==k),J=F[k][U],Z=F[H][Y];for(let X=0;X<w;X++){let te=J[X],$=Z[w-X],ee=J[X+1],Q=Z[w-(X+1)];[te,$,ee,ee,$,Q].forEach(W=>{s.push(W[0].x,W[0].y,W[0].z),u.push(W[1].x,W[1].y,W[1].z)})}q.push(J[0][0],Z[w][0],J[w][0],Z[0][0])}}for(;q.length;){let k,U,H,Y;[k,U]=q.splice(0,2);let J=[k];for(;k!=U;)J.push(U),H=q.indexOf(U),Y=H%2,U=q.splice(H-Y,2)[1-Y];A.subVectors(J[0],J[1]).cross(h.subVectors(J[0],J[2])).normalize();let Z=A.dot(J[0])<0;Z&&A.negate();for(let X=1;X<=J.length-2;X++)[J[X+ +Z],J[X+1-+Z],J[0]].forEach(te=>{s.push(te.x,te.y,te.z),u.push(A.x,A.y,A.z)})}}function d(){let p=new $o;for(let O=0;O<s.length;O+=3){p.x=s[O+0],p.y=s[O+1],p.z=s[O+2];let x=S(p)/2/Math.PI+.5,D=P(p)/Math.PI+.5;l.push(x,1-D)}let f=new $o,h=new $o,m=new $o,y=new $o,g=new Hp,b=new Hp,w=new Hp,A=(O,x,D,N)=>{N<0&&O.x===1&&(l[x]=O.x-1),D.x===0&&D.z===0&&(l[x]=N/2/Math.PI+.5)};for(let O=0,x=0;O<s.length;O+=9,x+=6){f.set(s[O+0],s[O+1],s[O+2]),h.set(s[O+3],s[O+4],s[O+5]),m.set(s[O+6],s[O+7],s[O+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 D=S(y);A(g,x+0,f,D),A(b,x+2,h,D),A(w,x+4,m,D)}for(let O=0;O<l.length;O+=6){let x=l[O+0],D=l[O+2],N=l[O+4],T=Math.max(x,D,N),I=Math.min(x,D,N);T>.9&&I<.1&&(x<.2&&(l[O+0]+=1),D<.2&&(l[O+2]+=1),N<.2&&(l[O+4]+=1))}function S(O){return Math.atan2(O.z,-O.x)}function P(O){return Math.atan2(-O.y,Math.sqrt(O.x*O.x+O.z*O.z))}}}static fromJSON(t){return new Pn(t.vertices,t.indices,t.radius,t.corner,t.cornerSides)}};import{DodecahedronGeometry as $T}from"three";var K0=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,detail:0,corner:0,cornerSides:4},n.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(n){let{width:t,height:e,depth:r,detail:o,corner:i,cornerSides:a}=n.parameters,s=o===0&&i!==0?new ol(t*.5,i,a):new $T(t*.5,o);return s.scale(1,e/t,r/t),Object.assign(s,{userData:{...n,type:"DodecahedronGeometry"}})}},ol=class extends Pn{constructor(t=1,e=.2,r=4){let o=(1+Math.sqrt(5))/2,i=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,-i,-o,0,-i,o,0,i,-o,0,i,o,-i,-o,0,-i,o,0,i,-o,0,i,o,0,-o,0,-i,o,0,-i,-o,0,i,o,0,i],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 ol(t.radius,t.corner,t.cornerSides)}};import{Plane as nM,Shape as px,Vector2 as Yo,Vector3 as iM,MathUtils as Kp,LineCurve as Zp,QuadraticBezierCurve as fx,CubicBezierCurve as xu}from"three";import{CubicBezierCurve as mu,EllipseCurve as YT,LineCurve as yu,LineCurve3 as XT,MathUtils as QT,QuadraticBezierCurve as Wp,SplineCurve as KT,Vector2 as Jt,Vector3 as ex}from"three";var nl=1e-12,Ma=class{constructor(t){this.position=new Jt;this.startPosition=new Jt;this.uuid=QT.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 Ma(this.position).copy(this)}toJSON(){return[this.position.x,this.position.y]}},Ia=class extends Ma{constructor(e){super(e.position);this.parent=e}copy(e){return super.copy(e),this}clone(){return new Ia(this.parent).copy(this)}},Xr=class extends Ma{constructor(e,r){super(r);this.controls=[];this.roundness=0;this.areControlsDirectionsMirrored=!0;this.uuid=e,this.controls.push(new Ia(this),new Ia(this))}static create(e,r){let o=new Xr(e,new Jt(...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,i=this.controls.length;o<i;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 Xr(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 Jt,r=new Jt){let[o,i]=this.computeTangents();return o&&i&&(Z0(o,e),Z0(i,r)),[e,r]}computeTangent(e=new Jt){let[r,o]=this.computeTangents();return r&&o&&e.copy(r).add(o).normalize(),e}computeNormal(e=new Jt){let[r,o]=this.computeNormals();return e.copy(r).add(o).normalize(),e}};function Z0(n,t=new Jt){let e=n.length();return t.set(-n.y/e,n.x/e)}var $p=n=>n,Na=new Jt,gu=new Jt,ZT=new Jt,JT=new Jt,eM=new Jt,tM=new Jt,tx=new ex,rx=new ex;function ox(n){let t=new Jt;t.addVectors(n.v0,Na.subVectors(n.v1,n.v0).multiplyScalar(2/3));let e=new Jt;return e.addVectors(n.v2,gu.subVectors(n.v1,n.v2).multiplyScalar(2/3)),new mu(n.v0,t,e,n.v2)}function il(n,t,e=Number.EPSILON){return Math.abs(n-t)<e}function rM(n,t,e=Number.EPSILON){return n.distanceTo(t)<e}function oM(n,t,e=Number.EPSILON){return n.distanceTo(t)<e}function Yp(n,t,e){let r=Math.sqrt(Math.pow(t.x-n.x,2)+Math.pow(t.y-n.y,2)),o=Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2)),i=Math.sqrt(Math.pow(e.x-n.x,2)+Math.pow(e.y-n.y,2));return Math.acos((o*o+r*r-i*i)/(2*o*r))}function nx(n,t,e){return J0(n,t)&&J0(t,e)&&qp(n.position,t.position,e.position)}function qp(n,t,e){return Na.copy(t).sub(n).cross(gu.copy(e).sub(n))===0}function ix(n,t,e,r,o){let i=Math.sqrt(Math.pow(t.x-n.x,2)+Math.pow(t.y-n.y,2)),a=(n.y+t.y)/2,s=(n.x+t.x)/2,l=Math.sqrt(Math.pow(e,2)-Math.pow(i/2,2))*(n.y-t.y)/i,u=Math.sqrt(Math.pow(e,2)-Math.pow(i/2,2))*(t.x-n.x)/i;return r.set(s+l,a+u),o.set(s-l,a-u),[r,o]}function ax(n,t,e){let r=n.distanceTo(e),o=t.distanceTo(e);return r<o?t:n}function sx(n,t,e,r,o,i){let a=t.x-n.x,s=t.y-n.y,l=e.x-n.x,u=e.y-n.y,c=Math.sqrt((a+l)*(a+l)+(s+u)*(s+u)),d;return Yp(t,n,e)>Math.PI&&(c*=-1),il(u,s)?d=(s+u)*(r/c-.5)*8/3/(a-l):d=(a+l)*(r/c-.5)*8/3/(u-s),o.set(t.x-d*s,t.y+d*a),i.set(e.x+d*u,e.y-d*l),[o,i]}function Xp(n,t){return n.position.equals(n.controls[1].position)&&t.position.equals(t.controls[0].position)}function J0(n,t){return qp(n.position,n.controls[1].position,t.position)&&qp(n.position,t.controls[0].position,t.position)}function lx(n,t,e,r,o=.5){let i=Na.subVectors(t,n).multiplyScalar(o).add(n),a=gu.subVectors(e,t).multiplyScalar(o).add(t),s=ZT.subVectors(r,e).multiplyScalar(o).add(e),l=i,u=JT.subVectors(a,i).multiplyScalar(o).add(i),c=eM.subVectors(s,a).multiplyScalar(o).add(a),d=s,p=tM.subVectors(c,u).multiplyScalar(o).add(u);return[n.x,n.y,l.x,l.y,u.x,u.y,p.x,p.y,c.x,c.y,d.x,d.y,r.x,r.y]}function cx(n,t,e=12,r=!0){let o=rx.set(0,0,0),i,a=0,s=[];for(let l=0;l<t.length;l++){let u=$p(t[l]),c=Na,d=On(u,e);s.push(d);for(let p=0;p<=d;p++)if(u instanceof mu||u instanceof Wp||u instanceof yu){if(u.getPoint(p/d,c),o.set(c.x,c.y,0),i!==void 0&&oM(i,o))continue;i===void 0&&(i=tx),i.copy(o),n.setXYZ(a,o.x,o.y,o.z),a++}}return r&&a>1&&!(n.getX(a-1)===n.getX(0)&&n.getY(a-1)===n.getY(0)&&n.getZ(a-1)===n.getZ(0))&&(n.setXYZ(a,n.getX(0),n.getY(0),n.getZ(0)),a++),n}function ux(n,t,e,r=12,o=!0){let i=rx.set(0,0,0),a=0,s=[];for(let l=0;l<t.length;l++){if(e[l]===!1)continue;let u,c=$p(t[l]),d=Na,p=On(c,r);s.push(p);for(let f=0;f<=p;f++)if(c instanceof mu||c instanceof Wp||c instanceof yu){if(c.getPoint(f/p,d),i.set(d.x,d.y,0),u?.equals(i))continue;u===void 0?u=tx:(n.setXYZ(a,u.x,u.y,u.z),a++,n.setXYZ(a,i.x,i.y,i.z),a++),u.copy(i)}}return o&&a>1&&!(n.getX(a-1)===n.getX(0)&&n.getY(a-1)===n.getY(0)&&n.getZ(a-1)===n.getZ(0))&&(n.setXYZ(a,n.getX(0),n.getY(0),n.getZ(0)),a++),s}function Qp(n,t=12,e=!1){let r=[];for(let o=0,i=n.length;o<i;o++){let a=n[o],s=0;if(e&&a.roundedCurveCorner!==void 0){let l=On(a.roundedCurveCorner,t)*.5;o>0&&(r[o-1]+=l),s+=l}a.curveAfter!==void 0&&(s+=On(a.curveAfter,t)),r.push(s)}return n.length>0&&e&&n[0].roundedCurveCorner!==void 0&&(r[n.length-1]+=On(n[0].roundedCurveCorner,t)*.5),r}function On(n,t=12){return n&&n instanceof YT?t*2:n&&(n instanceof yu||n instanceof XT)?1:n&&n instanceof KT?t*n.points.length:t}function dx(n,t,e=12,r=!0){let o,i=0;for(let a=0;a<t.length;a++){let s=$p(t[a]),l=On(s,e),u=Na;for(let c=0;c<=l;c++)if(s instanceof mu||s instanceof Wp||s instanceof yu){if(s.getPoint(c/l,u),o!==void 0&&rM(o,u,nl))continue;o===void 0&&(o=gu),o.copy(u),n.push(u.x,u.y),i++}}return il(n[0],n[n.length-2],nl)&&il(n[1],n[n.length-1],nl)&&(n.pop(),n.pop()),r&&i>1&&!(il(n[i-1],n[1],nl)&&il(n[i-2],n[0],nl))&&(n.push(n[0],n[1]),i++),n}var Jp=new Yo,aM=new Yo,sM=new Yo,lM=new Yo,cM=new Yo,uM=new Yo,He=class extends px{constructor(e=100,r=100){super();this.points=[];this.shapeHoles=[];this.plane=new nM(new iM(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=Kp.generateUUID();this.needsUpdate=!1;this.roundedCurves=[];this._width=e,this._height=r}static createFromState(e,r,o){let i=new He;return i.isClosed=e.isClosed,i.points=e.points.map(a=>Xr.create(a.id,a.data)),typeof e.roundness=="number"&&(i.roundness=e.roundness),i.shapeHoles=e.shapeHoles.map(a=>He.createFromState(a)),r!==void 0&&o!==void 0&&i.applySize(r,o),i.update(),i}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(i=>i.uuid===e);if(o<0){let i=r;for(let a=0,s=this.shapeHoles.length;a<s;a++){let l=this.shapeHoles[a],u=l.points.length,c=l.getPointIndexById(e);if(c<0)i+=u;else return c+i}}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,i=this.shapeHoles.length;o<i;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,i=this.shapeHoles.length;o<i;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=Jp.set(e,r);for(let i=0,a=this.points.length;i<a;i++){let s=this.points[i];s.position.multiply(o),s.controls[0].position.multiply(o),s.controls[1].position.multiply(o)}for(let i=0,a=this.shapeHoles.length;i<a;i++)this.shapeHoles[i].applyScale(e,r);this._update()}createPoint(e,r=0,o=Kp.generateUUID()){let i;e instanceof Yo?i=e:i=new Yo(e,r);let a=new Xr(o,i);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 i=this.points[r];if(i.uuid===e)return i}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 i=o?this.roundedCurveDivisions:this.curveDivisions;return cx(e,o?this.roundedCurves:this.curves,r,this.autoClose),i.reduce((a,s)=>a+s,0)+1}computeCurveDivisions(e=12){return this.curveDivisions=Qp(this.points,e,!1),this.roundedCurveDivisions=Qp(this.points,e,!0),this.curveDivisions}extractFilteredShapePointsToBuffer(e,r,o=12){return ux(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),dx(e,this.roundedCurves,r,this.autoClose)}getCurveIndexFromVertexId(e,r=!1){let o=0;this.curveDivisions===void 0&&this.computeCurveDivisions(this.subdivision);let i=r?this.roundedCurveDivisions:this.curveDivisions,a=0;r&&this.points[0].roundedCurveCorner!==void 0&&(a=On(this.points[0].roundedCurveCorner,this.subdivision)*.5);let s=e-a;s<0&&(s+=i.reduce((l,u)=>l+u,0));for(let l=0,u=i.length;l<u;l++){let c=i[l];if(s<o+c)return[l,(s-o+1)/c];o+=c}return[0,1]}getCurveT(e,r,o){let i=this.points[e],a=this.points[e>=this.points.length-1?0:e+1],s=this.curveDivisions,l=s[e];if(Xp(i,a)){let d=i.position.distanceTo(a.position);return i.position.distanceTo(Jp.set(o.x,o.y))/d}let u=0;for(let d=0;d<e;d++)u+=s[d];return(r-u)/l}dispose(){}_applyCurveForPoint(e,r){Xp(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 i=o.clone();e.roundedCurveBefore=i,r.roundedCurveAfter=i,e.roundedCurveCorner=void 0,this.roundedCurves.push(i)}_update(){if(this.curves=[],this.roundedCurves=[],!this.points.length)return;for(let r=0,o=this.points.length;r<o;r++){let i=this.points[r];if(r===0)this.moveTo(i.position.x,i.position.y);else{let a=this.points[r-1];this._applyCurveForPoint(i,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,i=this.points.length;o<i;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],u=a.roundness,c=s&&l&&nx(s,a,l);if(!a.controlsMoved()&&u>0&&!c){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(u,m*.499),b=Math.min(u,y*.499),w=Math.min(g,b),A=1-w/m,S=w/y,P=d.getPointAt(A,Jp),O=p.getPointAt(S,aM);this._subSplitCurve(d,f,A,P,void 0),this._subSplitCurve(p,h,S,void 0,O);let x;if(this.useCubicForRoundedCorners){let D=Yp(P,a.position,O)/2,N=Math.tan(D)*P.distanceTo(a.position),[T,I]=ix(P,O,N,sM,lM),E=ax(T,I,a.position),[B,R]=sx(E,P,O,N,cM,uM);x=new xu(P.clone(),B.clone(),R.clone(),O.clone())}else x=new fx(P.clone(),a.position.clone(),O.clone());a.roundedCurveCorner=x,this.roundedCurves.splice(o+r,0,x),r++}}}}_subSplitCurve(e,r,o,i,a){if(e instanceof Zp)i!==void 0&&r.v2.copy(i),a!==void 0&&r.v1.copy(a);else{let s=e,l=r,u=s.getUtoTmapping(o,0),c=lx(s.v0,s.v1,s.v2,s.v3,u);return i!==void 0&&(l.v0.set(c[0],c[1]),l.v1.set(c[2],c[3]),l.v2.set(c[4],c[5]),l.v3.set(c[6],c[7])),a!==void 0&&(l.v0.set(c[6],c[7]),l.v1.set(c[8],c[9]),l.v2.set(c[10],c[11]),l.v3.set(c[12],c[13])),l}return r}clone(){let e=new He(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 i=o*7,a=e.points[i+0],s=e.points[i+1],l=e.points[i+2],u=e.points[i+3],c=e.points[i+4],d=e.points[i+5],p=e.points[i+6],f=new Xr(Kp.generateUUID(),new Yo(a,s));f.controls[0].position.set(l,u),f.controls[1].position.set(c,d),f.roundness=p,this.points.push(f)}return this.shapeHoles=e.shapeHoles?.length?e.shapeHoles.map(o=>{let i=new He;return i.fromJSON(o),i}):[],this.isClosed=e.isClosed,this._roundness=e.roundness,this._update(),this}fromShape(e,r=!1){this.isText=r;let o=(a,s)=>{s instanceof xu&&s.v3.equals(a.position)&&a.controls[0].position.copy(s.v2)},i=a=>{let s=[],l,u;for(l=0,u=a.length;l<u;l++)a[l]instanceof fx&&(a[l]=ox(a[l]));for(l=0,u=a.length;l<u;l++){let p=a[l],f=l>0?a[l-1]:null,h;p instanceof xu?(h=this.createPoint(p.v0),h.controls[1].position.copy(p.v1)):p instanceof Zp&&(h=this.createPoint(p.v1)),h!==void 0&&(f!==null&&o(h,f),s.push(h))}let c=a[a.length-1],d=!1;return c instanceof xu?c.v3.equals(s[0].position)&&(s[0].controls[0].position.copy(c.v2),d=!0):c instanceof Zp&&c.v2.equals(s[0].position)&&(d=!0),this.isClosed=d,s};return this.points=i(e.curves),e instanceof px&&(this.shapeHoles=e.holes.map(a=>{let s=new He;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 i=this.getPointByUuid(e)?.controls[0];i&&(r.position&&i.position.fromArray(r.position),this.needsUpdate=!0)}updateNextControl(e,r){let i=this.getPointByUuid(e)?.controls[1];i&&(r.position&&i.position.fromArray(r.position),this.needsUpdate=!0)}};var tf=Math.PI*2;function ef({x:n,y:t},e,r,o,i){return{x:n*e+o,y:t*r+i}}function dM(n,t){let e=t===1.5707963267948966?.551915024494:t===-1.5707963267948966?-.551915024494:1.3333333333333333*Math.tan(t/4),r=Math.cos(n),o=Math.sin(n),i=Math.cos(n+t),a=Math.sin(n+t);return[{x:r-o*e,y:o+r*e},{x:i+a*e,y:a-i*e},{x:i,y:a}]}function hx(n,t,e,r){let o=n*r-t*e<0?-1:1,i=Math.min(1,Math.max(-1,n*e+t*r));return o*Math.acos(i)}function pM(n,t,e,r,o,i,a,s,l,u){let c=Math.pow(o,2),d=Math.pow(i,2),p=Math.pow(a,2),f=Math.pow(s,2),h=c*d-c*f-d*p;h<0&&(h=0),h/=c*f+d*p,h=Math.sqrt(h)*(l===u?-1:1);let m=h*o/i*s,y=h*-i/o*a,g=m+(n+e)/2,b=y+(t+r)/2,w=(a-m)/o,A=(s-y)/i,S=(-a-m)/o,P=(-s-y)/i,O=hx(1,0,w,A),x=hx(w,A,S,P);return!u&&x>0&&(x-=tf),u&&x<0&&(x+=tf),{centerx:g,centery:b,ang1:O,ang2:x}}function mx({px:n,py:t,cx:e,cy:r,rx:o,ry:i,largeArcFlag:a,sweepFlag:s}){let l=[];if(o===0||i===0)return[];let u=(n-e)/2,c=(t-r)/2;if(u===0&&c===0)return[];o=Math.abs(o),i=Math.abs(i);let d=Math.pow(u,2)/Math.pow(o,2)+Math.pow(c,2)/Math.pow(i,2);d>1&&(o*=Math.sqrt(d),i*=Math.sqrt(d));let p=pM(n,t,e,r,o,i,u,c,a,s),{ang1:f,ang2:h}=p,{centerx:m,centery:y}=p,g=Math.abs(h)/(tf/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(dM(f,h)),f+=h;return l.map(w=>{let{x:A,y:S}=ef(w[0],o,i,m,y),{x:P,y:O}=ef(w[1],o,i,m,y),{x,y:D}=ef(w[2],o,i,m,y);return{x1:A,y1:S,x2:P,y2:O,x,y:D}})}import{BufferAttribute as Au,BufferGeometry as _M}from"three";var je;(function(n){n[n.ODD=0]="ODD",n[n.NONZERO=1]="NONZERO",n[n.POSITIVE=2]="POSITIVE",n[n.NEGATIVE=3]="NEGATIVE",n[n.ABS_GEQ_TWO=4]="ABS_GEQ_TWO"})(je||(je={}));var dt;(function(n){n[n.POLYGONS=0]="POLYGONS",n[n.CONNECTED_POLYGONS=1]="CONNECTED_POLYGONS",n[n.BOUNDARY_CONTOURS=2]="BOUNDARY_CONTOURS"})(dt||(dt={}));function Ae(n,t){if(!n)throw t||"Assertion Failed!"}var ve=function(){function n(){}return n.vertEq=function(t,e){return t.s===e.s&&t.t===e.t},n.vertLeq=function(t,e){return t.s<e.s||t.s===e.s&&t.t<=e.t},n.transLeq=function(t,e){return t.t<e.t||t.t===e.t&&t.s<=e.s},n.edgeGoesLeft=function(t){return n.vertLeq(t.Dst,t.Org)},n.edgeGoesRight=function(t){return n.vertLeq(t.Org,t.Dst)},n.vertL1dist=function(t,e){return Math.abs(t.s-e.s)+Math.abs(t.t-e.t)},n.edgeEval=function(t,e,r){Ae(n.vertLeq(t,e)&&n.vertLeq(e,r));var o=e.s-t.s,i=r.s-e.s;return o+i>0?o<i?e.t-t.t+(t.t-r.t)*(o/(o+i)):e.t-r.t+(r.t-t.t)*(i/(o+i)):0},n.edgeSign=function(t,e,r){Ae(n.vertLeq(t,e)&&n.vertLeq(e,r));var o=e.s-t.s,i=r.s-e.s;return o+i>0?(e.t-r.t)*o+(e.t-t.t)*i:0},n.transEval=function(t,e,r){Ae(n.transLeq(t,e)&&n.transLeq(e,r));var o=e.t-t.t,i=r.t-e.t;return o+i>0?o<i?e.s-t.s+(t.s-r.s)*(o/(o+i)):e.s-r.s+(r.s-t.s)*(i/(o+i)):0},n.transSign=function(t,e,r){Ae(n.transLeq(t,e)&&n.transLeq(e,r));var o=e.t-t.t,i=r.t-e.t;return o+i>0?(e.s-r.s)*o+(e.s-t.s)*i:0},n.vertCCW=function(t,e,r){return t.s*(e.t-r.t)+e.s*(r.t-t.t)+r.s*(t.t-e.t)>=0},n.interpolate=function(t,e,r,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))},n.intersect=function(t,e,r,o,i){var a,s,l;n.vertLeq(t,e)||(l=t,t=e,e=l),n.vertLeq(r,o)||(l=r,r=o,o=l),n.vertLeq(t,r)||(l=t,t=r,r=l,l=e,e=o,o=l),n.vertLeq(r,e)?n.vertLeq(e,o)?(a=n.edgeEval(t,r,e),s=n.edgeEval(r,e,o),a+s<0&&(a=-a,s=-s),i.s=n.interpolate(a,r.s,s,e.s)):(a=n.edgeSign(t,r,e),s=-n.edgeSign(t,o,e),a+s<0&&(a=-a,s=-s),i.s=n.interpolate(a,r.s,s,o.s)):i.s=(r.s+e.s)/2,n.transLeq(t,e)||(l=t,t=e,e=l),n.transLeq(r,o)||(l=r,r=o,o=l),n.transLeq(t,r)||(l=t,t=r,r=l,l=e,e=o,o=l),n.transLeq(r,e)?n.transLeq(e,o)?(a=n.transEval(t,r,e),s=n.transEval(r,e,o),a+s<0&&(a=-a,s=-s),i.t=n.interpolate(a,r.t,s,e.t)):(a=n.transSign(t,r,e),s=-n.transSign(t,o,e),a+s<0&&(a=-a,s=-s),i.t=n.interpolate(a,r.t,s,o.t)):i.t=(r.t+e.t)/2},n}(),al=function(){function n(){this.next=null,this.prev=null,this.anEdge=null,this.trail=null,this.n=0,this.marked=!1,this.inside=!1}return n}(),bu=function(){function n(t){this.side=t,this.next=null,this.Org=null,this.Sym=null,this.Onext=null,this.Lnext=null,this.Lface=null,this.activeRegion=null,this.winding=0}return Object.defineProperty(n.prototype,"Rface",{get:function(){return this.Sym.Lface},set:function(t){this.Sym.Lface=t},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Dst",{get:function(){return this.Sym.Org},set:function(t){this.Sym.Org=t},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Oprev",{get:function(){return this.Sym.Lnext},set:function(t){this.Sym.Lnext=t},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Lprev",{get:function(){return this.Onext.Sym},set:function(t){this.Onext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Dprev",{get:function(){return this.Lnext.Sym},set:function(t){this.Lnext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Rprev",{get:function(){return this.Sym.Onext},set:function(t){this.Sym.Onext=t},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Dnext",{get:function(){return this.Sym.Onext.Sym},set:function(t){this.Sym.Onext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"Rnext",{get:function(){return this.Sym.Lnext.Sym},set:function(t){this.Sym.Lnext.Sym=t},enumerable:!0,configurable:!0}),n}(),Da=function(){function n(){this.next=null,this.prev=null,this.anEdge=null,this.coords=[0,0,0],this.s=0,this.t=0,this.pqHandle=0,this.n=0,this.idx=0}return n}(),yx=function(){function n(){var t=new Da,e=new al,r=new bu(0),o=new bu(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 n.prototype.makeEdge_=function(t){var e=new bu(0),r=new bu(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},n.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},n.prototype.makeVertex_=function(t,e,r){var o=t;Ae(o,"Vertex can't be null!");var i=r.prev;o.prev=i,i.next=o,o.next=r,r.prev=o,o.anEdge=e;var a=e;do a.Org=o,a=a.Onext;while(a!==e)},n.prototype.makeFace_=function(t,e,r){var o=t;Ae(o,"Face can't be null");var i=r.prev;o.prev=i,i.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)},n.prototype.killEdge_=function(t){t.Sym.side<t.side&&(t=t.Sym);var e=t.next,r=t.Sym.next;e.Sym.next=r,r.Sym.next=e},n.prototype.killVertex_=function(t,e){var r=t.anEdge,o=r;do o.Org=e,o=o.Onext;while(o!==r);var i=t.prev,a=t.next;a.prev=i,i.next=a},n.prototype.killFace_=function(t,e){var r=t.anEdge,o=r;do o.Lface=e,o=o.Lnext;while(o!==r);var i=t.prev,a=t.next;a.prev=i,i.next=a},n.prototype.makeEdge=function(){var t=new Da,e=new Da,r=new al,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},n.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 i=new Da;this.makeVertex_(i,e,t.Org),t.Org.anEdge=t}if(!r){var a=new al;this.makeFace_(a,e,t.Lface),t.Lface.anEdge=t}}},n.prototype.delete=function(t){var e=t.Sym,r=!1;if(t.Lface!==t.Rface&&(r=!0,this.killFace_(t.Lface,t.Rface)),t.Onext===t)this.killVertex_(t.Org,null);else if(t.Rface.anEdge=t.Oprev,t.Org.anEdge=t.Onext,this.splice_(t,t.Oprev),!r){var o=new al;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)},n.prototype.addEdgeVertex=function(t){var e=this.makeEdge_(t),r=e.Sym;this.splice_(e,t.Lnext),e.Org=t.Dst;var o=new Da;return this.makeVertex_(o,r,e.Org),e.Lface=r.Lface=t.Lface,e},n.prototype.splitEdge=function(t){var e=this.addEdgeVertex(t),r=e.Sym;return this.splice_(t.Sym,t.Sym.Oprev),this.splice_(t.Sym,r),t.Dst=r.Org,r.Dst.anEdge=r.Sym,r.Rface=t.Rface,r.winding=t.winding,r.Sym.winding=t.Sym.winding,r.idx=t.idx,r.Sym.idx=t.Sym.idx,r},n.prototype.connect=function(t,e){var r=!1,o=this.makeEdge_(t),i=o.Sym;if(e.Lface!==t.Lface&&(r=!0,this.killFace_(e.Lface,t.Lface)),this.splice_(o,t.Lnext),this.splice_(i,e),o.Org=t.Dst,i.Org=e.Org,o.Lface=i.Lface=t.Lface,t.Lface.anEdge=i,!r){var a=new al;this.makeFace_(a,o,t.Lface)}return o},n.prototype.zapFace=function(t){var e=t.anEdge,r,o,i,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)),i=r.Sym,i.Onext===i?this.killVertex_(i.Org,null):(i.Org.anEdge=i.Onext,this.splice_(i,i.Oprev)),this.killEdge_(r));while(r!=e);a=t.prev,s=t.next,s.prev=a,a.next=s},n.prototype.countFaceVerts_=function(t){var e=t.anEdge,r=0;do r++,e=e.Lnext;while(e!==t.anEdge);return r},n.prototype.mergeConvexFaces=function(t){var e,r,o,i,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,i=r.Sym,i&&i.Lface&&i.Lface.inside&&(s=this.countFaceVerts_(e),l=this.countFaceVerts_(i.Lface),s+l-2<=t&&ve.vertCCW(r.Lprev.Org,r.Org,i.Lnext.Lnext.Org)&&ve.vertCCW(i.Lprev.Org,i.Org,r.Lnext.Lnext.Org)&&(o=i.Lnext,this.delete(i),r=null,i=null)),!(r&&r.Lnext.Org===a);)r=o;return!0},n.prototype.check=function(){var t=this.fHead,e=this.vHead,r=this.eHead,o,i,a,s,l,u;for(i=t,i=t;(o=i.next)!==t;i=o){Ae(o.prev===i),l=o.anEdge;do Ae(l.Sym!==l),Ae(l.Sym.Sym===l),Ae(l.Lnext.Onext.Sym===l),Ae(l.Onext.Sym.Lnext===l),Ae(l.Lface===o),l=l.Lnext;while(l!==o.anEdge)}for(Ae(o.prev===i&&o.anEdge===null),s=e,s=e;(a=s.next)!==e;s=a){Ae(a.prev===s),l=a.anEdge;do Ae(l.Sym!==l),Ae(l.Sym.Sym===l),Ae(l.Lnext.Onext.Sym===l),Ae(l.Onext.Sym.Lnext===l),Ae(l.Org===a),l=l.Onext;while(l!==a.anEdge)}for(Ae(a.prev===s&&a.anEdge===null),u=r,u=r;(l=u.next)!==r;u=l)Ae(l.Sym.next===u.Sym),Ae(l.Sym!==l),Ae(l.Sym.Sym===l),Ae(l.Org!==null),Ae(l.Dst!==null),Ae(l.Lnext.Onext.Sym===l),Ae(l.Onext.Sym.Lnext===l);Ae(l.Sym.next===u.Sym&&l.Sym===this.eHeadSym&&l.Sym.Sym===l&&l.Org===null&&l.Dst===null&&l.Lface===null&&l.Rface===null)},n}(),gx=function(){function n(){this.handle=null}return n}(),xx=function(){function n(){this.key=null,this.node=0}return n}(),fM=function(){function n(t,e){this.leq=e,this.max=0,this.nodes=[],this.handles=[],this.initialized=!1,this.freeList=0,this.size=0,this.max=t,this.nodes=[],this.handles=[];for(var r=0;r<t+1;r++)this.nodes[r]=new gx,this.handles[r]=new xx;this.initialized=!1,this.nodes[1].handle=1,this.handles[1].key=null}return n.prototype.floatDown_=function(t){var e=this.nodes,r=this.handles,o,i,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,Ae(a<=this.max),i=e[a].handle,a>this.size||this.leq(r[o].key,r[i].key)){e[t].handle=o,r[o].node=t;break}e[t].handle=i,r[i].node=t,t=a}},n.prototype.floatUp_=function(t){var e=this.nodes,r=this.handles,o,i,a;for(o=e[t].handle;;){if(a=t>>1,i=e[a].handle,a===0||this.leq(r[i].key,r[o].key)){e[t].handle=o,r[o].node=t;break}e[t].handle=i,r[i].node=t,t=a}},n.prototype.init=function(){for(var t=this.size;t>=1;--t)this.floatDown_(t);this.initialized=!0},n.prototype.min=function(){return this.handles[this.nodes[1].handle].key},n.prototype.insert=function(t){var e,r;if(e=++this.size,e*2>this.max){this.max*=2;var o,i;for(i=this.nodes.length,this.nodes.length=this.max+1,o=i;o<this.nodes.length;o++)this.nodes[o]=new gx;for(i=this.handles.length,this.handles.length=this.max+1,o=i;o<this.handles.length;o++)this.handles[o]=new xx}return this.freeList===0?r=e:(r=this.freeList,this.freeList=this.handles[r].node),this.nodes[e].handle=r,this.handles[r].node=e,this.handles[r].key=t,this.initialized&&this.floatUp_(e),r},n.prototype.extractMin=function(){var t=this.nodes,e=this.handles,r=t[1].handle,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},n.prototype.delete=function(t){var e=this.nodes,r=this.handles,o;Ae(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},n}(),rf=function(){function n(){this.eUp=null,this.nodeUp=null,this.windingNumber=0,this.inside=!1,this.sentinel=!1,this.dirty=!1,this.fixUpperEdge=!1}return n}(),bx=function(){function n(){this.key=null,this.next=null,this.prev=null}return n}(),hM=function(){function n(t,e){this.frame=t,this.leq=e,this.head=new bx,this.head.next=this.head,this.head.prev=this.head}return n.prototype.min=function(){return this.head.next},n.prototype.max=function(){return this.head.prev},n.prototype.insert=function(t){return this.insertBefore(this.head,t)},n.prototype.search=function(t){var e=this.head;do e=e.next;while(e.key!==null&&!this.leq(this.frame,t,e.key));return e},n.prototype.insertBefore=function(t,e){do t=t.prev;while(t.key!==null&&!this.leq(this.frame,t.key,e));var r=new bx;return r.key=e,r.next=t.next,t.next.prev=r,r.prev=t,t.next=r,r},n.prototype.delete=function(t){t.next.prev=t.prev,t.prev.next=t.next},n}(),mM=function(){function n(){}return n.regionBelow=function(t){return t.nodeUp.prev.key},n.regionAbove=function(t){return t.nodeUp.next.key},n.debugEvent=function(t){},n.addWinding=function(t,e){t.winding+=e.winding,t.Sym.winding+=e.Sym.winding},n.edgeLeq=function(t,e,r){var o=t.event,i=e.eUp,a=r.eUp;if(i.Dst===o)return a.Dst===o?ve.vertLeq(i.Org,a.Org)?ve.edgeSign(a.Dst,i.Org,a.Org)<=0:ve.edgeSign(i.Dst,a.Org,i.Org)>=0:ve.edgeSign(a.Dst,o,a.Org)<=0;if(a.Dst===o)return ve.edgeSign(i.Dst,o,i.Org)>=0;var s=ve.edgeEval(i.Dst,o,i.Org),l=ve.edgeEval(a.Dst,o,a.Org);return s>=l},n.deleteRegion=function(t,e){e.fixUpperEdge&&Ae(e.eUp.winding===0),e.eUp.activeRegion=null,t.dict.delete(e.nodeUp)},n.fixUpperEdge=function(t,e,r){Ae(e.fixUpperEdge),t.mesh.delete(e.eUp),e.fixUpperEdge=!1,e.eUp=r,r.activeRegion=e},n.topLeftRegion=function(t,e){var r=e.eUp.Org,o;do e=n.regionAbove(e);while(e.eUp.Org===r);if(e.fixUpperEdge){if(o=t.mesh.connect(n.regionBelow(e).eUp.Sym,e.eUp.Lnext),o===null)return null;n.fixUpperEdge(t,e,o),e=n.regionAbove(e)}return e},n.topRightRegion=function(t){var e=t.eUp.Dst;do t=n.regionAbove(t);while(t.eUp.Dst===e);return t},n.addRegionBelow=function(t,e,r){var o=new rf;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},n.isWindingInside=function(t,e){switch(t.windingRule){case je.ODD:return(e&1)!==0;case je.NONZERO:return e!==0;case je.POSITIVE:return e>0;case je.NEGATIVE:return e<0;case je.ABS_GEQ_TWO:return e>=2||e<=-2}throw new Error("Invalid winding rulle")},n.computeWinding=function(t,e){e.windingNumber=n.regionAbove(e).windingNumber+e.eUp.winding,e.inside=n.isWindingInside(t,e.windingNumber)},n.finishRegion=function(t,e){var r=e.eUp,o=r.Lface;o.inside=e.inside,o.anEdge=r,n.deleteRegion(t,e)},n.finishLeftRegions=function(t,e,r){for(var o,i=null,a=e,s=e.eUp;a!==r;){if(a.fixUpperEdge=!1,i=n.regionBelow(a),o=i.eUp,o.Org!=s.Org){if(!i.fixUpperEdge){n.finishRegion(t,a);break}o=t.mesh.connect(s.Lprev,o.Sym),n.fixUpperEdge(t,i,o)}s.Onext!==o&&(t.mesh.splice(o.Oprev,o),t.mesh.splice(s,o)),n.finishRegion(t,a),s=i.eUp,a=i}return s},n.addRightEdges=function(t,e,r,o,i,a){var s,l,u,c,d=!0;u=r;do Ae(ve.vertLeq(u.Org,u.Dst)),n.addRegionBelow(t,e,u.Sym),u=u.Onext;while(u!==o);for(i===null&&(i=n.regionBelow(e).eUp.Rprev),l=e,c=i;s=n.regionBelow(l),u=s.eUp.Sym,u.Org===c.Org;)u.Onext!==c&&(t.mesh.splice(u.Oprev,u),t.mesh.splice(c.Oprev,u)),s.windingNumber=l.windingNumber-u.winding,s.inside=n.isWindingInside(t,s.windingNumber),l.dirty=!0,!d&&n.checkForRightSplice(t,l)&&(n.addWinding(u,c),n.deleteRegion(t,l),t.mesh.delete(c)),d=!1,l=s,c=u;l.dirty=!0,Ae(l.windingNumber-u.winding===s.windingNumber),a&&n.walkDirtyRegions(t,l)},n.spliceMergeVertices=function(t,e,r){t.mesh.splice(e,r)},n.vertexWeights=function(t,e,r){var o=ve.vertL1dist(e,t),i=ve.vertL1dist(r,t),a=.5*i/(o+i),s=.5*o/(o+i);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]},n.getIntersectData=function(t,e,r,o,i,a){e.coords[0]=e.coords[1]=e.coords[2]=0,e.idx=-1,n.vertexWeights(e,r,o),n.vertexWeights(e,i,a)},n.checkForRightSplice=function(t,e){var r=n.regionBelow(e),o=e.eUp,i=r.eUp;if(ve.vertLeq(o.Org,i.Org)){if(ve.edgeSign(i.Dst,o.Org,i.Org)>0)return!1;ve.vertEq(o.Org,i.Org)?o.Org!==i.Org&&(t.pq.delete(o.Org.pqHandle),n.spliceMergeVertices(t,i.Oprev,o)):(t.mesh.splitEdge(i.Sym),t.mesh.splice(o,i.Oprev),e.dirty=r.dirty=!0)}else{if(ve.edgeSign(o.Dst,i.Org,o.Org)<0)return!1;n.regionAbove(e).dirty=e.dirty=!0,t.mesh.splitEdge(o.Sym),t.mesh.splice(i.Oprev,o)}return!0},n.checkForLeftSplice=function(t,e){var r=n.regionBelow(e),o=e.eUp,i=r.eUp,a;if(Ae(!ve.vertEq(o.Dst,i.Dst)),ve.vertLeq(o.Dst,i.Dst)){if(ve.edgeSign(o.Dst,i.Dst,o.Org)<0)return!1;n.regionAbove(e).dirty=e.dirty=!0,a=t.mesh.splitEdge(o),t.mesh.splice(i.Sym,a),a.Lface.inside=e.inside}else{if(ve.edgeSign(i.Dst,o.Dst,i.Org)>0)return!1;e.dirty=r.dirty=!0,a=t.mesh.splitEdge(i),t.mesh.splice(o.Lnext,i.Sym),a.Rface.inside=e.inside}return!0},n.checkForIntersect=function(t,e){var r=n.regionBelow(e),o=e.eUp,i=r.eUp,a=o.Org,s=i.Org,l=o.Dst,u=i.Dst,c,d,p=new Da,f,h;if(Ae(!ve.vertEq(u,l)),Ae(ve.edgeSign(l,t.event,a)<=0),Ae(ve.edgeSign(u,t.event,s)>=0),Ae(a!==t.event&&s!==t.event),Ae(!e.fixUpperEdge&&!r.fixUpperEdge),a===s||(c=Math.min(a.t,l.t),d=Math.max(s.t,u.t),c>d))return!1;if(ve.vertLeq(a,s)){if(ve.edgeSign(u,a,s)>0)return!1}else if(ve.edgeSign(l,s,a)<0)return!1;return n.debugEvent(t),ve.intersect(l,a,u,s,p),Ae(Math.min(a.t,l.t)<=p.t),Ae(p.t<=Math.max(s.t,u.t)),Ae(Math.min(u.s,l.s)<=p.s),Ae(p.s<=Math.max(s.s,a.s)),ve.vertLeq(p,t.event)&&(p.s=t.event.s,p.t=t.event.t),f=ve.vertLeq(a,s)?a:s,ve.vertLeq(f,p)&&(p.s=f.s,p.t=f.t),ve.vertEq(p,a)||ve.vertEq(p,s)?(n.checkForRightSplice(t,e),!1):!ve.vertEq(l,t.event)&&ve.edgeSign(l,t.event,p)>=0||!ve.vertEq(u,t.event)&&ve.edgeSign(u,t.event,p)<=0?u===t.event?(t.mesh.splitEdge(o.Sym),t.mesh.splice(i.Sym,o),e=n.topLeftRegion(t,e),o=n.regionBelow(e).eUp,n.finishLeftRegions(t,n.regionBelow(e),r),n.addRightEdges(t,e,o.Oprev,o,o,!0),!0):l===t.event?(t.mesh.splitEdge(i.Sym),t.mesh.splice(o.Lnext,i.Oprev),r=e,e=n.topRightRegion(e),h=n.regionBelow(e).eUp.Rprev,r.eUp=i.Oprev,i=n.finishLeftRegions(t,r,null),n.addRightEdges(t,e,i.Onext,o.Rprev,h,!0),!0):(ve.edgeSign(l,t.event,p)>=0&&(n.regionAbove(e).dirty=e.dirty=!0,t.mesh.splitEdge(o.Sym),o.Org.s=t.event.s,o.Org.t=t.event.t),ve.edgeSign(u,t.event,p)<=0&&(e.dirty=r.dirty=!0,t.mesh.splitEdge(i.Sym),i.Org.s=t.event.s,i.Org.t=t.event.t),!1):(t.mesh.splitEdge(o.Sym),t.mesh.splitEdge(i.Sym),t.mesh.splice(i.Oprev,o),o.Org.s=p.s,o.Org.t=p.t,o.Org.pqHandle=t.pq.insert(o.Org),n.getIntersectData(t,o.Org,a,l,s,u),n.regionAbove(e).dirty=e.dirty=r.dirty=!0,!1)},n.walkDirtyRegions=function(t,e){for(var r=n.regionBelow(e),o,i;;){for(;r.dirty;)e=r,r=n.regionBelow(r);if(!e.dirty&&(r=e,e=n.regionAbove(e),e===null||!e.dirty))return;if(e.dirty=!1,o=e.eUp,i=r.eUp,o.Dst!==i.Dst&&n.checkForLeftSplice(t,e)&&(r.fixUpperEdge?(n.deleteRegion(t,r),t.mesh.delete(i),r=n.regionBelow(e),i=r.eUp):e.fixUpperEdge&&(n.deleteRegion(t,e),t.mesh.delete(o),e=n.regionAbove(r),o=e.eUp)),o.Org!==i.Org)if(o.Dst!==i.Dst&&!e.fixUpperEdge&&!r.fixUpperEdge&&(o.Dst===t.event||i.Dst===t.event)){if(n.checkForIntersect(t,e))return}else n.checkForRightSplice(t,e);o.Org===i.Org&&o.Dst===i.Dst&&(n.addWinding(i,o),n.deleteRegion(t,e),t.mesh.delete(o),e=n.regionAbove(r))}},n.connectRightVertex=function(t,e,r){var o,i=r.Onext,a=n.regionBelow(e),s=e.eUp,l=a.eUp,u=!1;if(s.Dst!==l.Dst&&n.checkForIntersect(t,e),ve.vertEq(s.Org,t.event)&&(t.mesh.splice(i.Oprev,s),e=n.topLeftRegion(t,e),i=n.regionBelow(e).eUp,n.finishLeftRegions(t,n.regionBelow(e),a),u=!0),ve.vertEq(l.Org,t.event)&&(t.mesh.splice(r,l.Oprev),r=n.finishLeftRegions(t,a,null),u=!0),u){n.addRightEdges(t,e,r.Onext,i,i,!0);return}ve.vertLeq(l.Org,s.Org)?o=l.Oprev:o=s,o=t.mesh.connect(r.Lprev,o),n.addRightEdges(t,e,o,o.Onext,o.Onext,!1),o.Sym.activeRegion.fixUpperEdge=!0,n.walkDirtyRegions(t,e)},n.connectLeftDegenerate=function(t,e,r){var o,i,a,s,l;if(o=e.eUp,ve.vertEq(o.Org,r)){Ae(!1),n.spliceMergeVertices(t,o,r.anEdge);return}if(!ve.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),n.sweepEvent(t,r);return}Ae(!1),e=n.topRightRegion(e),l=n.regionBelow(e),a=l.eUp.Sym,i=s=a.Onext,l.fixUpperEdge&&(Ae(i!==a),n.deleteRegion(t,l),t.mesh.delete(a),a=i.Oprev),t.mesh.splice(r.anEdge,a),ve.edgeGoesLeft(i)||(i=null),n.addRightEdges(t,e,a.Onext,s,i,!0)},n.connectLeftVertex=function(t,e){var r,o,i,a,s,l,u=new rf;if(u.eUp=e.anEdge.Sym,r=t.dict.search(u).key,o=n.regionBelow(r),!!o){if(a=r.eUp,s=o.eUp,ve.edgeSign(a.Dst,e,a.Org)===0){n.connectLeftDegenerate(t,r,e);return}if(i=ve.vertLeq(s.Dst,a.Dst)?r:o,r.inside||i.fixUpperEdge){if(i===r)l=t.mesh.connect(e.anEdge.Sym,a.Lnext);else{var c=t.mesh.connect(s.Dnext,e.anEdge);l=c.Sym}i.fixUpperEdge?n.fixUpperEdge(t,i,l):n.computeWinding(t,n.addRegionBelow(t,r,l)),n.sweepEvent(t,e)}else n.addRightEdges(t,r,e.anEdge,e.anEdge,null,!0)}},n.sweepEvent=function(t,e){t.event=e,n.debugEvent(t);for(var r=e.anEdge;r.activeRegion===null;)if(r=r.Onext,r===e.anEdge){n.connectLeftVertex(t,e);return}var o=n.topLeftRegion(t,r.activeRegion);Ae(o!==null);var i=n.regionBelow(o),a=i.eUp,s=n.finishLeftRegions(t,i,null);s.Onext===a?n.connectRightVertex(t,o,s):n.addRightEdges(t,o,s.Onext,a,a,!0)},n.addSentinel=function(t,e,r,o){var i=new rf,a=t.mesh.makeEdge();a.Org.s=r,a.Org.t=o,a.Dst.s=e,a.Dst.t=o,t.event=a.Dst,i.eUp=a,i.windingNumber=0,i.inside=!1,i.fixUpperEdge=!1,i.sentinel=!0,i.dirty=!1,i.nodeUp=t.dict.insert(i)},n.initEdgeDict=function(t){t.dict=new hM(t,n.edgeLeq);var e=t.bmax[0]-t.bmin[0],r=t.bmax[1]-t.bmin[1],o=t.bmin[0]-e,i=t.bmax[0]+e,a=t.bmin[1]-r,s=t.bmax[1]+r;n.addSentinel(t,o,i,a),n.addSentinel(t,o,i,s)},n.doneEdgeDict=function(t){for(var e,r=0;(e=t.dict.min().key)!==null;)e.sentinel||(Ae(e.fixUpperEdge),Ae(++r===1)),Ae(e.windingNumber===0),n.deleteRegion(t,e)},n.removeDegenerateEdges=function(t){var e,r,o,i=t.mesh.eHead;for(e=i.next;e!==i;e=r)r=e.next,o=e.Lnext,ve.vertEq(e.Org,e.Dst)&&e.Lnext.Lnext!==e&&(n.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))},n.initPriorityQ=function(t){var e,r,o,i=0;for(o=t.mesh.vHead,r=o.next;r!==o;r=r.next)i++;for(i+=8,e=t.pq=new fM(i,ve.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)},n.donePriorityQ=function(t){t.pq=null},n.removeDegenerateFaces=function(t,e){var r,o,i;for(r=e.fHead.next;r!==e.fHead;r=o)o=r.next,i=r.anEdge,Ae(i.Lnext!==i),i.Lnext.Lnext===i&&(n.addWinding(i.Onext,i),t.mesh.delete(i));return!0},n.computeInterior=function(t,e){e===void 0&&(e=!0);var r,o;if(n.removeDegenerateEdges(t),!n.initPriorityQ(t))return!1;for(n.initEdgeDict(t);(r=t.pq.extractMin())!==null;){for(;o=t.pq.min(),!(o===null||!ve.vertEq(o,r));)o=t.pq.extractMin(),n.spliceMergeVertices(t,r.anEdge,o.anEdge);n.sweepEvent(t,r)}return t.event=t.dict.min().key.eUp.Org,n.debugEvent(t),n.doneEdgeDict(t),n.donePriorityQ(t),n.removeDegenerateFaces(t,t.mesh)?(e&&t.mesh.check(),!0):!1},n}(),yM=function(){function n(){this.mesh=new yx,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=je.ODD,this.dict=null,this.pq=null,this.event=null,this.vertexIndexCounter=0,this.vertices=[],this.vertexIndices=[],this.vertexCount=0,this.elements=[],this.elementCount=0}return n.prototype.dot_=function(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]},n.prototype.normalize_=function(t){var e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2];if(!e)throw"Zero-size vector!";e=Math.sqrt(e),t[0]/=e,t[1]/=e,t[2]/=e},n.prototype.longAxis_=function(t){var e=0;return Math.abs(t[1])>Math.abs(t[0])&&(e=1),Math.abs(t[2])>Math.abs(t[e])&&(e=2),e},n.prototype.computeNormal_=function(t){var e,r,o,i,a,s,l=[0,0,0],u=[0,0,0],c=[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)i=e.coords[y],u[y]=i,h[y]=e,l[y]=i,f[y]=e;for(e=m.next;e!==m;e=e.next)for(var g=0;g<3;++g)i=e.coords[g],i<u[g]&&(u[g]=i,h[g]=e),i>l[g]&&(l[g]=i,f[g]=e);var b=0;if(l[1]-u[1]>l[0]-u[0]&&(b=1),l[2]-u[2]>l[b]-u[b]&&(b=2),u[b]>=l[b]){t[0]=0,t[1]=0,t[2]=1;return}for(s=0,r=h[b],o=f[b],c[0]=r.coords[0]-o.coords[0],c[1]=r.coords[1]-o.coords[1],c[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]=c[1]*d[2]-c[2]*d[1],p[1]=c[2]*d[0]-c[0]*d[2],p[2]=c[0]*d[1]-c[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_(c)]=1)},n.prototype.checkOrientation_=function(){for(var t=this.mesh.fHead,e,r=this.mesh.vHead,o,i=0,a=t.next;a!==t;a=a.next)if(o=a.anEdge,!(o.winding<=0))do i+=(o.Org.s-o.Dst.s)*(o.Org.t+o.Dst.t),o=o.Lnext;while(o!==a.anEdge);if(i<0){for(e=r.next;e!==r;e=e.next)e.t=-e.t;this.tUnit[0]=-this.tUnit[0],this.tUnit[1]=-this.tUnit[1],this.tUnit[2]=-this.tUnit[2]}},n.prototype.projectPolygon_=function(){var t=this.mesh.vHead,e=[0,0,0],r,o,i=!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),i=!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);i&&this.checkOrientation_();for(var l=!0,u=t.next;u!==t;u=u.next)l?(this.bmin[0]=this.bmax[0]=u.s,this.bmin[1]=this.bmax[1]=u.t,l=!1):(u.s<this.bmin[0]&&(this.bmin[0]=u.s),u.s>this.bmax[0]&&(this.bmax[0]=u.s),u.t<this.bmin[1]&&(this.bmin[1]=u.t),u.t>this.bmax[1]&&(this.bmax[1]=u.t))},n.prototype.addWinding_=function(t,e){t.winding+=e.winding,t.Sym.winding+=e.Sym.winding},n.prototype.tessellateMonoRegion_=function(t,e){var r,o;if(r=e.anEdge,!(r.Lnext!==r&&r.Lnext.Lnext!==r))throw"Mono region invalid";for(;ve.vertLeq(r.Dst,r.Org);r=r.Lprev);for(;ve.vertLeq(r.Org,r.Dst);r=r.Lnext);o=r.Lprev;for(var i=void 0;r.Lnext!==o;)if(ve.vertLeq(r.Dst,o.Org)){for(;o.Lnext!==r&&(ve.edgeGoesLeft(o.Lnext)||ve.edgeSign(o.Org,o.Dst,o.Lnext.Dst)<=0);)i=t.connect(o.Lnext,o),o=i.Sym;o=o.Lprev}else{for(;o.Lnext!==r&&(ve.edgeGoesRight(r.Lprev)||ve.edgeSign(r.Dst,r.Org,r.Lprev.Org)>=0);)i=t.connect(r,r.Lprev),r=i.Sym;r=r.Lnext}if(o.Lnext===r)throw"Mono region invalid";for(;o.Lnext.Lnext!==r;)i=t.connect(o.Lnext,o),o=i.Sym;return!0},n.prototype.tessellateInterior_=function(t){for(var e,r=t.fHead.next;r!==t.fHead;r=e)if(e=r.next,r.inside&&!this.tessellateMonoRegion_(t,r))return!1;return!0},n.prototype.discardExterior_=function(t){for(var e,r=t.fHead.next;r!==t.fHead;r=e)e=r.next,r.inside||t.zapFace(r)},n.prototype.setWindingNumber_=function(t,e,r){for(var o,i=t.eHead.next;i!==t.eHead;i=o)o=i.next,i.Rface.inside!==i.Lface.inside?i.winding=i.Lface.inside?e:-e:r?t.delete(i):i.winding=0},n.prototype.getNeighbourFace_=function(t){return!t.Rface||!t.Rface.inside?-1:t.Rface.n},n.prototype.outputPolymesh_=function(t,e,r,o){var i,a=0,s=0,l;r>3&&t.mergeConvexFaces(r);for(var u=t.vHead.next;u!==t.vHead;u=u.next)u.n=-1;for(var c=t.fHead.next;c!==t.fHead;c=c.next)if(c.n=-1,!!c.inside){i=c.anEdge,l=0;do{var u=i.Org;u.n===-1&&(u.n=s,s++),l++,i=i.Lnext}while(i!==c.anEdge);if(l>r)throw"Face vertex greater that support polygon";c.n=a,++a}this.elementCount=a,e===dt.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 u=t.vHead.next;u!==t.vHead;u=u.next)if(u.n!==-1){var d=u.n*o;this.vertices[d+0]=u.coords[0],this.vertices[d+1]=u.coords[1],o>2&&(this.vertices[d+2]=u.coords[2]),this.vertexIndices[u.n]=u.idx}for(var p=0,c=t.fHead.next;c!==t.fHead;c=c.next)if(!!c.inside){i=c.anEdge,l=0;do{var u=i.Org;this.elements[p++]=u.n,l++,i=i.Lnext}while(i!==c.anEdge);for(var f=l;f<r;++f)this.elements[p++]=-1;if(e===dt.CONNECTED_POLYGONS){i=c.anEdge;do this.elements[p++]=this.getNeighbourFace_(i),i=i.Lnext;while(i!==c.anEdge);for(var h=l;h<r;++h)this.elements[p++]=-1}}},n.prototype.outputContours_=function(t,e){var r,o,i=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,u=0,c=0;i=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[u++]=this.vertexIdCallback?this.vertexIdCallback(r):r.Org.idx,a++,r=r.Lnext;while(r!==o);this.elements[c++]=i,this.elements[c++]=a,i+=a}},n.prototype.addContour=function(t,e){this.mesh===null&&(this.mesh=new yx),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},n.prototype.tesselate=function(t,e,r,o,i,a){if(t===void 0&&(t=je.ODD),e===void 0&&(e=dt.POLYGONS),a===void 0&&(a=!0),this.vertices=[],this.elements=[],this.vertexIndices=[],this.vertexIndexCounter=0,i&&(this.normal[0]=i[0],this.normal[1]=i[1],this.normal[2]=i[2]),this.windingRule=t,o<2&&(o=2),o>3&&(o=3),!this.mesh)return!1;this.projectPolygon_(),mM.computeInterior(this,a);var s=this.mesh;return e===dt.BOUNDARY_CONTOURS?this.setWindingNumber_(s,1,!0):this.tessellateInterior_(s),a&&s.check(),e===dt.BOUNDARY_CONTOURS?this.outputContours_(s,o):this.outputPolymesh_(s,e,r,o),!0},n}();function Qr(n){var t=n.windingRule,e=t===void 0?je.ODD:t,r=n.elementType,o=r===void 0?dt.POLYGONS:r,i=n.polySize,a=i===void 0?3:i,s=n.vertexSize,l=s===void 0?2:s,u=n.normal,c=u===void 0?[0,0,1]:u,d=n.contours,p=d===void 0?[]:d,f=n.strict,h=f===void 0?!0:f,m=n.debug,y=m===void 0?!1:m;if(!p&&h)throw new Error("Contours can't be empty");if(!!p){var g=new yM;n.edgeCreateCallback&&(g.edgeCreateCallback=n.edgeCreateCallback),n.vertexIdCallback&&(g.vertexIdCallback=n.vertexIdCallback);for(var b=0;b<p.length;b++)g.addContour(l||2,p[b]);return g.tesselate(e,o,a,l,c,h),{vertices:g.vertices,vertexIndices:g.vertexIndices,vertexCount:g.vertexCount,elements:g.elements,elementCount:g.elementCount,mesh:y?g.mesh:void 0}}}var QW=je.ODD,KW=je.NONZERO,ZW=je.POSITIVE,JW=je.NEGATIVE,e6=je.ABS_GEQ_TWO,t6=dt.POLYGONS,r6=dt.CONNECTED_POLYGONS,o6=dt.BOUNDARY_CONTOURS;import{Box2 as SM,BufferAttribute as wu,BufferGeometry as wM,Vector2 as AM}from"three";var vu=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*vu.eSize;this.buffer=new ArrayBuffer(r);let o=Float32Array.BYTES_PER_ELEMENT,i=0;this.positions=new Float32Array(this.buffer,i*o,3*t),i+=3*t,this.normals=new Float32Array(this.buffer,i*o,3*t),i+=3*t,this.uvs=new Float32Array(this.buffer,i*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*vu.eSize,o=new ArrayBuffer(r),i=Float32Array.BYTES_PER_ELEMENT,a=0,s=new Float32Array(o,a*i,3*t);a+=3*t;let l=new Float32Array(o,a*i,3*t);a+=3*t;let u=new Float32Array(o,a*i,2*t);e?(s.set(this.positions.subarray(0,this.size*3)),l.set(this.normals.subarray(0,this.size*3)),u.set(this.uvs.subarray(0,this.size*2))):(s.set(this.positions),l.set(this.normals),u.set(this.uvs)),this.buffer=o,this.positions=s,this.normals=l,this.uvs=u,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)}},sl=vu;sl.eSize=(3+3+2)*Float32Array.BYTES_PER_ELEMENT;var Ax=Ht(wx()),ll={vertices:[160,160,-160,160,-160,-160,160,-160],vertexIndices:[1,0,3,2],vertexCount:4,elements:[0,4],elementCount:1,mesh:void 0},lf={vertices:[],vertexIndices:[],vertexCount:0,elements:[],elementCount:0,mesh:void 0},cf={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},sf=(n,t)=>([e,r])=>(r<e&&(r+=t),(n>=e?n:n+t)<=r),Tn=class extends wM{constructor(e,r,o=0,i=12,a=3,s=je.ODD,l=!1){super();this.forPathBevel=l;this.type="ShapeGeometry";this.vertexCache={};this._shape=e,this._depth=r,this._curveSegments=i,this._bevelSegmentsInput=a;let u=this._shape.extractShapePointsToFlatArray([],i),c=this._shape.shapeHoles.map(T=>{let I=T.extractShapePointsToFlatArray([],i),E=[];for(let B=I.length-1;B>=1;B-=2){let R=I[B-1],F=I[B-0];E.push(R,F)}return E}),d=[],p=[];for(let T=0;T<u.length;T+=2)p.push([u[T],u[T+1]]);d.push(p);for(let T=0;T<c.length;T++){let I=c[T],E=[];for(let B=0;B<I.length;B+=2)E.push([I[B],I[B+1]]);d.push(E)}let f;e.isText?f=new SM().setFromPoints(e.points.map(I=>I.position)).getSize(new AM).length()*.1:d[0].length===0?f=o:f=(0,Ax.default)(d).distance,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=Qr({windingRule:s,elementType:dt.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[u]})}catch{h=ll}let m;try{m=Qr({windingRule:je.ODD,elementType:dt.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...c]})}catch{m=lf}if(!h)throw new Error("error generating geometry");let y=h.elementCount;if(m){h.elementCount+=m.elementCount;for(let T=0;T<m.elements.length;T++){let I=m.elements[T],E=T%2===0?h.vertexCount:0;h.elements.push(I+E)}for(let T=0;T<m.vertexIndices.length;T++){let I=m.vertexIndices[T],E=h.vertexCount;h.vertexIndices.push(I+E)}for(let T=0;T<m.vertices.length;T++){let I=m.vertices[T];h.vertices.push(I)}}let g=1/0,b=-1/0,w=1/0,A=-1/0;for(let T=0,I=h.vertexCount;T<I;T++){let E=T*2,B=h.vertices[E+0],R=h.vertices[E+1];B<g&&(g=B),B>b&&(b=B),R<w&&(w=R),R>A&&(A=R)}this._minX=g,this._minY=w,this._width=b-g,this._height=A-w,this._buffer=new sl(this._computeBufferEstimatedSize(h));let S=[],P=[];for(let T=h.elementCount-1;T>=0;T--){let I=T>=y,E=T*2,B=h.elements[E+0],R=h.elements[E+1],F=B+R,V={start:B,count:R,normals:[],continuous:[],concave:[]},q=B,k=F-1,U=B+1,H=this._shape.roundedCurves.length;do{let te=q-B,$=h.vertices[k*2+0],ee=h.vertices[k*2+1],Q=h.vertices[q*2+0],W=h.vertices[q*2+1],ue=h.vertices[U*2+0],le=h.vertices[U*2+1],ne=Q-$,ce=W-ee,ae=Math.sqrt(ne*ne+ce*ce);ne/=ae,ce/=ae;let he=Q-ue,pe=W-le,fe=Math.sqrt(he*he+pe*pe);he/=fe,pe/=fe,V.normals[te*2+0]=-pe,V.normals[te*2+1]=he,V.concave[te]=ne*pe-ce*he>0;let ge=h.vertexIndices[q];if(Array.isArray(ge))V.continuous[te]=!1;else{let[me,C]=this._shape.getCurveIndexFromVertexId(ge-1,!0);if(C>0&&C<1)V.continuous[te]=!0;else{let ie=C===1?me+1:me-1;ie=(ie+H)%H;let De=C===1?0:1,Ge=this._shape.roundedCurves[me].getTangent(C),Ee=this._shape.roundedCurves[ie].getTangent(De);V.continuous[te]=Ge.dot(Ee)>.95}}I&&(V.normals[te*2+0]*=-1,V.normals[te*2+1]*=-1),[k,q,U]=[q,U,U+1],U>=F&&(U-=R)}while(U!==B+1);let Y=[];Y.push({bevelI:0,angle:0,size:0,boundary:{vertices:h.vertices.slice(B*2,F*2),vertexCount:R,vertexIndices:new Array(R).fill(!0).map((te,$)=>[$,$]),elements:[0,R],elementCount:1,mesh:null},reverseMap:[],insetPoints:h.vertices.slice(B*2,F*2)});let J=0;for(let te=1;te<=this._bevelSegments;te++){let $=te/this._bevelSegments*Math.PI/2,ee=(1-Math.cos($))*this._bevel,Q=[],W=[],ue=[],le=[],ne=0;for(let ae=0;ae<R;ae++){let he=ae*2,pe=(ae-1+R)%R*2,fe=h.vertices[V.start*2+he+0],ge=h.vertices[V.start*2+he+1],me=-V.normals[pe+0]*ee,C=-V.normals[pe+1]*ee,ie=-V.normals[he+0]*ee,De=-V.normals[he+1]*ee;if(V.concave[ae]||!V.concave[ae]&&I){let Ge=Math.atan2(C,me),Ee=Math.atan2(De,ie);Ee>Ge&&(Ee-=Math.PI*2);let _e=Ee-Ge;if(V.continuous[ae]||I){let Ct=Ge+_e/2,Me=Math.cos(Ct)*ee,At=Math.sin(Ct)*ee;Q[2*ne+0]=fe+Me*(I?-1:1),Q[2*ne+1]=ge+At*(I?-1:1),le[ne]=ae,ne++}else{let Ct=Math.max(1,Math.floor(i/4*Math.abs(_e)/Math.PI));for(let Me=0;Me<=Ct;Me++){let At=Ge+_e*(Me/Ct),Tt=Math.cos(At)*ee,Wn=Math.sin(At)*ee;Q[2*ne+0]=fe+Tt,Q[2*ne+1]=ge+Wn,le[ne]=ae,ne++}}}else Q[2*ne+0]=fe+me,Q[2*ne+1]=ge+C,le[ne]=ae,W[ae]=ne,ne++,Q[2*ne+0]=fe,Q[2*ne+1]=ge,le[ne]=ae,ne++,Q[2*ne+0]=fe+ie,Q[2*ne+1]=ge+De,le[ne]=ae,ue[ae]=ne,ne++}let ce=Qr({windingRule:je.POSITIVE,elementType:dt.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[Q],edgeCreateCallback:ae=>{let pe=ae.Org.idx,fe=le[pe],ge=le[(pe+1)%le.length];ae.idx=[fe,ge],ae.Sym.idx=[ge,fe]},vertexIdCallback:ae=>{let he=ae.Lprev.idx;return[he?he[1]:0,ae.idx?ae.idx[0]:0]}});if(!ce)throw console.log("Error"),new Error(`error generating bevel geometry for ${te}'th loop`);if(!ce.vertexCount){let ae=(te-1)/this._bevelSegments*Math.PI/2;J=(1-Math.sin(ae))*this._bevel;break}for(let ae=0;ae<ce.vertexIndices.length;ae++){let[he,pe]=ce.vertexIndices[ae];if(he===pe)continue;let fe=pe;pe<he&&(fe+=R);for(let ge=he;ge<fe;ge++){let me=ge%R,C=(ge+1)%R;if(!V.continuous[me]||!V.continuous[C]){ce.vertexIndices[ae]=[he,me],ce.vertexIndices.splice(ae+1,0,[C,pe]),ce.vertices.splice((ae+1)*2,0,ce.vertices[ae*2],ce.vertices[ae*2+1]);break}}}Y.push({bevelI:te,angle:$,size:ee,boundary:ce,reverseMap:le,insetPoints:Q})}let Z=(te,$,ee)=>{let Q=0,W=te.boundary.vertexIndices.length;for(;Q<W&&ee(te.boundary.vertexIndices[$]);)$=($+1)%W,Q++;return Q},X=S.length;for(let te=1;te<Y.length;te++){let $=Y[te-1],ee=Y[te],Q=$.boundary.vertexIndices.length,W=ee.boundary.vertexIndices.length;if(!Q||!W)break;let ue=V.concave.length,le=0,ne=sf(le,R);for(;!$.boundary.vertexIndices.filter(ne).length||!ee.boundary.vertexIndices.filter(ne).length;)le++,ne=sf(le,R);let ce=$.boundary.vertexIndices.findIndex(ne),ae=ee.boundary.vertexIndices.findIndex(ne);do ce=(ce+1)%Q;while(ne($.boundary.vertexIndices[ce]));do ae=(ae+1)%W;while(ne(ee.boundary.vertexIndices[ae]));le=(le+1)%R;let he=le,pe=0,fe=this._buildBevelVert(V,$,(ce-1+Q)%Q,void 0,pe),ge=this._buildBevelVert(V,ee,(ae-1+W)%W,void 0,pe),me=fe,C=ge,ie,De,Ge=!1;do{pe=(le||ue)/ue,ne=sf(le,R);let Ee=Z($,ce,ne),_e=Z(ee,ae,ne),Ct=Ge;if(Ge=!1,Ee&&!_e){for(let Me=0;Me<Ee;Me++)ie=this._buildBevelVert(V,$,(ce+Me)%Q,Me/(Ee-1),pe),S.push(me.topN,ie.topP,C.topN),l===!1&&S.push(ie.bottomP,me.bottomN,C.bottomN),me=ie;Ge=!0}else if(!Ee&&_e)for(let Me=0;Me<_e;Me++)De=this._buildBevelVert(V,ee,(ae+Me)%W,Me/(_e-1),pe),S.push(C.topN,me.topP,De.topP),l===!1&&S.push(me.bottomP,C.bottomN,De.bottomP),C=De;else if(Ee&&_e)if(ie=this._buildBevelVert(V,$,ce,0,pe),De=this._buildBevelVert(V,ee,ae,0,pe),Ct?(S.push(me.topN,De.topP,C.topN),S.push(me.topN,ie.topP,De.topP),l===!1&&(S.push(De.bottomP,me.bottomN,C.bottomN),S.push(De.bottomP,ie.bottomP,me.bottomN))):(S.push(C.topN,me.topN,ie.topP),S.push(C.topN,ie.topP,De.topP),l===!1&&(S.push(ie.bottomP,me.bottomN,C.bottomN),S.push(ie.bottomP,C.bottomN,De.bottomP))),me=ie,C=De,Ee===_e)for(let Me=1;Me<Ee;Me++)ie=this._buildBevelVert(V,$,(ce+Me)%Q,Me/(Ee-1),pe),De=this._buildBevelVert(V,ee,(ae+Me)%W,Me/(_e-1),pe),S.push(me.topN,ie.topP,C.topN),S.push(C.topN,ie.topP,De.topP),l===!1&&(S.push(ie.bottomP,me.bottomN,C.bottomN),S.push(ie.bottomP,C.bottomN,De.bottomP)),me=ie,C=De;else if(Ee>_e){let Me=Ee/_e,At=0;for(let Tt=1;Tt<Ee;Tt++)ie=this._buildBevelVert(V,$,(ce+Tt)%Q,Tt/(Ee-1),pe),S.push(me.topN,ie.topP,C.topN),l===!1&&S.push(ie.bottomP,me.bottomN,C.bottomN),me=ie,Tt>(At+1)*Me&&(At++,De=this._buildBevelVert(V,ee,(ae+At)%W,At/(_e-1),pe),S.push(C.topN,ie.topP,De.topP),l===!1&&S.push(ie.bottomP,C.bottomN,De.bottomP),C=De)}else{let Me=_e/Ee,At=0;for(let Tt=1;Tt<_e;Tt++)De=this._buildBevelVert(V,ee,(ae+Tt)%W,Tt/(_e-1),pe),S.push(C.topN,ie.topP,De.topP),l===!1&&S.push(ie.bottomP,C.bottomN,De.bottomP),C=De,Tt>(At+1)*Me&&(At++,ie=this._buildBevelVert(V,$,(ce+At)%Q,At/(Ee-1),pe),S.push(me.topN,ie.topP,C.topN),l===!1&&S.push(ie.bottomP,me.bottomN,C.bottomN),me=ie)}ce=(ce+Ee)%Q,ae=(ae+_e)%W,le=(le+1)%ue}while(le!==he)}if(l===!1&&this._depth>this._bevel*2&&this._buildWall(Y,V,S),I){let te=[];for(let $=S.length-1;$>=X+2;$-=3){let ee=S[$-2],Q=S[$-1],W=S[$-0];te.push(W,Q,ee)}S.splice(X,S.length-X,...te)}if(I){let te=[];for(let $=Y[Y.length-1].boundary.vertices.length-1;$>=1;$-=2){let ee=Y[Y.length-1].boundary.vertices[$-1],Q=Y[Y.length-1].boundary.vertices[$-0];te.push(ee,Q)}P.push(te)}if(!I){let te=Y[Y.length-1],$;try{$=Qr({windingRule:Y.length>1?je.POSITIVE:je.ODD,elementType:dt.POLYGONS,vertexSize:2,strict:!0,contours:[te.insetPoints,...P]})}catch{$=cf}if(!$)throw new Error("Error generating geometry for surface");c.length===0&&this._bevel<f&&Object.assign(this,{useNgonForTopBottomFaceDuringBake:!0});for(let ee=0;ee<$.elementCount*3;ee+=3){let Q=this._buildSurfaceVert($,$.elements[ee+0],J),W=this._buildSurfaceVert($,$.elements[ee+1],J),ue=this._buildSurfaceVert($,$.elements[ee+2],J);S.push(Q.top,W.top,ue.top),l===!1&&S.push(ue.bottom,W.bottom,Q.bottom)}}this.vertexCache={}}this._buffer.shrink();let O=new wu(Uint32Array.from(S),1),x=new wu(this._buffer.positions,3),D=new wu(this._buffer.normals,3),N=new wu(this._buffer.uvs,2);x.needsUpdate=!0,D.needsUpdate=!0,N.needsUpdate=!0,O.needsUpdate=!0,this.setAttribute("position",x),this.setAttribute("normal",D),this.setAttribute("uv",N),this.setIndex(O)}_computeBufferEstimatedSize(e){return e.vertexCount*2*(2+this._bevelSegments)}_buildWall(e,r,o){let i=e[0];for(let a=0,s=i.boundary.vertexCount;a<s;a++){let l=this._buildBevelVert(r,i,a),u=this._buildBevelVert(r,i,(a+1)%s);o.push(u.topP,l.topN,l.bottomN),o.push(u.topP,l.bottomN,u.bottomP)}}_buildSurfaceVert(e,r,o){let i=r.toString();if(i in this.vertexCache)return this.vertexCache[i];let a=e.vertices[r*2+0],s=e.vertices[r*2+1],l=(a-this._minX)/this._width,u=(s-this._minY)/this._height;this.forPathBevel&&(u=1);let c=this._buffer.get(this.forPathBevel?1:2),d=c*3,p=c*2,f={top:c+0,bottom:c+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]=u,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]=u),this.vertexCache[i]=f,f}_buildBevelVert(e,r,o,i=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,u]=r.boundary.vertexIndices[o],c,d,p,f;l!==u?(d=l,c=u,f=!1,p=e.continuous[d]&&e.continuous[c]):(c=l,d=(c-1+e.count)%e.count,f=e.concave[c]&&r.bevelI>0,p=e.continuous[c]||f);let h=Math.cos(r.angle),m=Math.sin(r.angle),y=o*2,g=c*2,b=d*2,w=r.boundary.vertices[y+0],A=r.boundary.vertices[y+1],S=(1-m)*this._bevel,P=(w-this._minX)/this._width,O=(A-this._minY)/this._height;this.forPathBevel&&(a!==void 0&&(P=a),O=1);let x=e.normals[g+0],D=e.normals[g+1],N=e.normals[b+0],T=e.normals[b+1];if(f){let F=N-x,V=T-D;x=x+F*(1-i),D=D+V*(1-i);let q=Math.sqrt(x*x+D*D);x/=q,D/=q}let I=this.forPathBevel?this._buffer.get(p?1:2):this._buffer.get(p?2:4),E=I*3,B=I*2,R={i:o,fi:c,topP:I+0,topN:I+0,bottomP:I+1,bottomN:I+1,pathBevelUCoord:a};return this._buffer.positions[E+0]=w,this._buffer.positions[E+1]=A,this._buffer.positions[E+2]=(this.forPathBevel?this._bevel:this._depth)-S,this._buffer.normals[E+0]=x*h,this._buffer.normals[E+1]=D*h,this._buffer.normals[E+2]=m,this._buffer.uvs[B+0]=P,this._buffer.uvs[B+1]=O,this.forPathBevel===!1&&(this._buffer.positions[E+3]=w,this._buffer.positions[E+4]=A,this._buffer.positions[E+5]=S,this._buffer.normals[E+3]=x*h,this._buffer.normals[E+4]=D*h,this._buffer.normals[E+5]=-m,this._buffer.uvs[B+2]=O,this._buffer.uvs[B+3]=P),p||(this.forPathBevel?(I+=1,E+=3,B+=2):(I+=2,E+=6,B+=4),R.topP=I+0,R.bottomP=I+1,this._buffer.positions[E+0]=w,this._buffer.positions[E+1]=A,this._buffer.positions[E+2]=(this.forPathBevel?this._bevel:this._depth)-S,this._buffer.normals[E+0]=N*h,this._buffer.normals[E+1]=T*h,this._buffer.normals[E+2]=m,this._buffer.uvs[B+0]=P,this._buffer.uvs[B+1]=O,this.forPathBevel===!1&&(this._buffer.positions[E+3]=w,this._buffer.positions[E+4]=A,this._buffer.positions[E+5]=S,this._buffer.normals[E+3]=N*h,this._buffer.normals[E+4]=T*h,this._buffer.normals[E+5]=-m,this._buffer.uvs[B+2]=O,this._buffer.uvs[B+3]=P)),this.vertexCache[s]=R,R}clone(){let e=new Tn(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=Vo(this.userData),e}};var Ea=class extends _M{constructor(e,r=12,o={}){super();this.type="ShapeGeometry";this.windingRule=je.ODD;this.elementType=dt.POLYGONS;this.polySize=3;this.vertexSize=2;this.strict=!0;this._shape=e,this._curveSegments=r,this._triangulationOptions=Object.assign({windingRule:je.ODD,elementType:dt.POLYGONS,polySize:3,vertexSize:2,strict:!0},o);let i=this._shape.extractShapePointsToFlatArray([],this._curveSegments),a=this._shape.shapeHoles.map(h=>h.extractShapePointsToFlatArray([],this._curveSegments)),s,l=!0,u=!0,c,d;for(let h=0,m=i.length/2;h<m;h++){let y=h*2,g=i[y+0],b=i[y+1];if(c!==void 0&&g!==c&&(l=!1),d!==void 0&&b!==d&&(u=!1),c=g,d=b,!l&&!u)break}if(!l&&!u)try{s=Qr({contours:[i,...a],windingRule:this._triangulationOptions.windingRule,elementType:this._triangulationOptions.elementType,polySize:this._triangulationOptions.polySize,vertexSize:this._triangulationOptions.vertexSize,strict:this._triangulationOptions.strict})}catch{s=ll}let p=s?.vertexCount??1,f=s?.elementCount??1;if(this._positionAttribute=new Au(new Float32Array(p*3),3),this._normalAttribute=new Au(new Float32Array(p*3),3),this._uvAttribute=new Au(new Float32Array(p*2),2),this._indexAttribute=new Au(new Uint32Array(f*3),1),s){let h=1/0,m=-1/0,y=1/0,g=-1/0;for(let A=0,S=p;A<S;A++){let P=A*2,O=s.vertices[P+0],x=s.vertices[P+1];O<h&&(h=O),O>m&&(m=O),x<y&&(y=x),x>g&&(g=x)}let b=m-h,w=g-y;for(let A=0,S=p;A<S;A++){let P=A*2,O=s.vertices[P+0],x=s.vertices[P+1],D=(O-h)/b,N=(x-y)/w;this._positionAttribute.setXYZ(A,O,x,0),this._normalAttribute.setXYZ(A,0,0,1),this._uvAttribute.setXY(A,D,N)}for(let A=0,S=f;A<S;A++){let P=A*3,O=s.elements[P+0],x=s.elements[P+1],D=s.elements[P+2];this._indexAttribute.setX(P+0,O),this._indexAttribute.setX(P+1,x),this._indexAttribute.setX(P+2,D)}}this.setAttribute("position",this._positionAttribute),this.setAttribute("normal",this._normalAttribute),this.setAttribute("uv",this._uvAttribute),this.setIndex(this._indexAttribute),this.setDrawRange(0,(s?.elementCount??1)*3)}clone(){let e=new Ea(this._shape,this._curveSegments);return e.userData=Vo(this.userData),e}};var Ba=class extends Tn{constructor(e,r,o=0,i=12,a=3,s=je.ODD){super(e,r,o,i,a,s);this.type="ShapeGeometry"}_computeBufferEstimatedSize(e){return e.vertexCount*2*(2+this._bevelSegments)}_buildWall(e,r,o){let i=e[0];for(let a=0,s=i.boundary.vertexCount;a<s;a++){let l=this._buildBevelVert(r,i,a),u=this._buildBevelVert(r,i,(a+1)%s);o.push(u.topP,l.topN,l.bottomN),o.push(u.topP,l.bottomN,u.bottomP)}}clone(){let e=new Ba(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegmentsInput);return e.userData=Vo(this.userData),e}};var dr=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,subdivisions:40,roundness:0,extrudeBevelSize:0,extrudeBevelSegments:3,windingRule:je.ODD},n.parameters),r=Math.abs(e.width),o=Math.abs(e.height??e.width),i=Math.abs(e.depth??0),a=n.shape??t?.shape,s=a?.roundness??e.roundness;a!==void 0&&(a instanceof He?(a.width!==r||a.height!==o)&&a.applySize(r,o):a=new He(r,o).fromJSON(a),n.parameters?.roundness!==void 0&&n.parameters?.roundness>0&&a.update());let l=a??new He(r,o);return{parameters:Object.assign(e,{width:r,height:o,depth:i,roundness:s}),shape:l}}static build(n){let{depth:t,extrudeBevelSize:e,extrudeBevelSegments:r,subdivisions:o,roundness:i,windingRule:a}=n.parameters;n.shape.roundness=i;let s;return t<=0?s=new Ea(n.shape,o,{windingRule:a}):s=new Ba(n.shape,t,e,o,r,a),Object.assign(s,{userData:{...n,type:"VectorGeometry"}})}};import{BufferGeometry as PM,Float32BufferAttribute as OM,MathUtils as uf,Vector2 as Px}from"three";var Ox=Math.PI*2,Ra=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,spikes:64,angle:360,innerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1},n.parameters);return e.angle=uf.clamp(e.angle,0,360),{shape:n.shape&&n.shape instanceof He?n.shape:new He,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)})}}static build(n){let{width:t,height:e,spikes:r,angle:o,innerRadius:i,depth:a,extrudeBevelSize:s,extrudeBevelSegments:l}=n.parameters,u=n.shape,c=t*.5,d=e*.5,p=CM(u,c,d,o*Math.PI/180,r,i);u.isClosed=!0,u.update();let f;return o===0?(f=new PM,f.setAttribute("position",new OM([],3))):f=dr.create({shape:u,parameters:{subdivisions:p,depth:a,extrudeBevelSize:s,extrudeBevelSegments:l}}),Object.assign(f,{userData:{...n,type:"EllipseGeometry"}})}};function CM(n,t,e,r,o,i){if(r>=Ox)return o>30||o%4===0?(MM(n,t,e,i),Math.round(o/4)):_x(n,r,o,t,e,i);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},u=mx({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%u.length===0?TM(n,a.x,a.y,u,o,t,e,i):_x(n,r,o,t,e,i)}function TM(n,t,e,r,o,i,a,s){let l=Math.round(o/r.length);n.addPoint(La(t,e));for(let u=0,c=r.length;u<c;u++){let d=r[u],p=n.points[u],f=La(d.x,d.y);p.controls[1].position.set(d.x1,d.y1),f.controls[0].position.set(d.x2,d.y2),n.addPoint(f)}return s>0?Cx(n,i,a,s):n.addPoint(La(0,0)),l}function _x(n,t,e,r,o,i){let a=-t/e;for(let s=0;s<=e;s++){let l=a*s,u=Math.sin(l)*r,c=Math.cos(l)*o;n.addPoint(La(u,c))}return t<Ox?i>0?Cx(n,r,o,i):n.addPoint(La(0,0)):(n.removePoint(n.points[n.points.length-1]),i>0&&Tx(n,r,o,i)),1}function MM(n,t,e,r=0,o=0,i=0){let a=.5522847498,s=t*a,l=e*a;n.addPoint(_u(o-t,i,o-t,i-l,o-t,i+l)),n.addPoint(_u(o,i+e,o-s,i+e,o+s,i+e)),n.addPoint(_u(o+t,i,o+t,i+l,o+t,i-l)),n.addPoint(_u(o,i-e,o+s,i-e,o-s,i-e)),r>0&&Tx(n,t,e,r)}function La(n,t){return new Xr(uf.generateUUID(),new Px(n,t))}function _u(n,t,e,r,o,i){let a=La(n,t);return a.controls[0].position.set(e,r),a.controls[1].position.set(o,i),a}function Cx(n,t,e,r){Mx(n,t,e,r).forEach(i=>n.addPoint(i))}function Tx(n,t,e,r){let o=Mx(n,t,e,r),i=new He;o.forEach(a=>i.addPoint(a)),i.isClosed=!0,n.shapeHoles.push(i)}function Mx(n,t,e,r){let o=r*t/100,i=o*(Math.abs(e)/Math.abs(t)),a=new Px(o/t,i/e),s=n.points.map(l=>{let u=l.clone();return u.uuid=uf.generateUUID(),u}).reverse();return s.forEach(l=>{l.position.multiply(a);let u=l.controls[0].position.clone().multiply(a),c=l.controls[1].position.clone().multiply(a);l.controls[0].position.copy(c),l.controls[1].position.copy(u)}),s}import{BufferGeometry as IM,Float32BufferAttribute as df,Uint32BufferAttribute as NM,Vector3 as Ix}from"three";var Nx=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,revolutions:2,segments:40,pathRadius:10,pathType:0,pathSegments:30,cornerRadius:30,cornerSegments:4},n.parameters),r=Math.abs(e.width),o=Math.abs(e.height??r),i=Math.abs(e.depth??r),a=Math.abs(Math.min(r,i))/2;return{parameters:Object.assign(e,{width:r,height:o,depth:i,radius:a,segments:Math.round(e.segments),pathSegments:Math.round(e.pathSegments),cornerSegments:Math.round(e.cornerSegments)})}}static build(n){let{width:t,height:e,depth:r,radius:o,revolutions:i,segments:a,pathRadius:s,pathType:l,pathSegments:u,cornerRadius:c,cornerSegments:d}=n.parameters,p=new cl(!1,t,e,r,o,i,a,s,l,u,c,d);return Object.assign(p,{userData:{...n,type:"HelixGeometry"}})}},pf=new NM([0,0,0],1),cl=class extends IM{constructor(t=!0,e=1,r=1,o=1,i=1,a=1,s=1,l=1,u=1,c=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 Ix,m=new Ix,y=h(),g=h(),b=h(),w,A,S,P,O,x,D,N,T=h(),I=h(),E=h(),B=h(),R=h(),F=h(),V=h(),q=h(),k=r-2*l+.001,U=k/a,H=Math.ceil(s*a),Y=H+1,J=k/H,Z=-k/2,X=c+1,te=2*Math.PI/c,$=Math.PI/2/p,ee=.01,Q=Math.min((1-d/100)*l,l-ee),W=l-Q,ue=0,le=2,ne=p*le+le,ce=X*ne/le,ae=ce+X*Y,he=Math.max(0,X*(Y+ne)),[pe,fe,ge]=[3,3,2].map(st=>Array(he*st).fill(0)),me=[],C=i-l;function ie(st,Ke){let kr=Math.PI/2;x=Ke*J,N=2*Math.PI*(x%U)/U+kr,x+=Z,D=Math.sin(N)*C,O=Math.cos(N)*C,t?st.set(O,D,x):st.set(O,x,D)}ie(m,-1e-10),ie(y,0),T.copy(m),ie(m,1);let De=m.distanceTo(y),Ge=f?0:W+Q,Ee=De*H+2*Ge,_e=Q,Ct=Ee-Ge;for(let st=0;st<=H;st++){ie(g,st),q.subVectors(g,T).normalize(),T.copy(g),F.copy(g).setComponent(+t+1,0).normalize(),V.crossVectors(q,F).normalize();let Ke=st===0,kr=st===H,Dd=Ke?3*Math.PI/2:$,Ed=Ke?_e:Ct,jl=Ke?X:ae,$n=Ke?0:he-X,mt=q.clone().multiplyScalar(Ke?-W:W).add(g),Bd=q.clone().multiplyScalar(Ke?-1:1).normalize();for(let Cr=0;Cr<X;Cr++){let Ls=Cr*te;if(I.addVectors(m.copy(F).multiplyScalar(l*Math.cos(Ls)),y.copy(V).multiplyScalar(l*Math.sin(Ls))),E.copy(I).normalize(),Ke||kr){f||(ue=$n+Cr,[0,1,2].forEach(Kt=>{pe[ue*3+Kt]=mt.getComponent(Kt),fe[ue*3+Kt]=Bd.getComponent(Kt)}),ge[ue*2]=+kr,ge[ue*2+1]=Cr/c),y.copy(E).multiplyScalar(Q),b.addVectors(g,y);for(let Kt=0;Kt<p;Kt++){let Yn=Kt*$+Dd;B.addVectors(m.copy(q).multiplyScalar(W*Math.sin(Yn)),y.copy(E).multiplyScalar(W*Math.cos(Yn))),R.copy(B).normalize(),y.addVectors(b,B),B.normalize(),ue=jl+Kt*X+Cr,[0,1,2].forEach(Ii=>{pe[ue*3+Ii]=y.getComponent(Ii),fe[ue*3+Ii]=R.getComponent(Ii)});let Ul=+Ke+Math.sin(Yn);ge[ue*2]=(Ed+W*Ul)/Ee,ge[ue*2+1]=Cr/c}}y.addVectors(g,I),ue=ce+st*X+Cr,[0,1,2].forEach(Kt=>{pe[ue*3+Kt]=y.getComponent(Kt),fe[ue*3+Kt]=E.getComponent(Kt)}),ge[ue*2]=(Ge+st*De)/Ee,ge[ue*2+1]=Cr/c}}let Me=Y+2*p+le,At=1,[Tt,Wn]=[+f,Me-1];for(let st=Tt;st<=Wn-1;st++){let Ke=f&&st===Wn-1;for(let kr=0;kr<X-1;kr++)w=st*X+kr,A=w+1,S=(Ke?kr:w)+X,P=(Ke?kr+1:A)+X,st===0?me.push(A,P,S):st===Me-2?me.push(w,A,S):me.push(w,A,S,A,P,S)}this.setIndex(me),this.setAttribute("position",new df(pe,3)),this.setAttribute("normal",new df(fe,3)),this.setAttribute("uv",new df(ge,2))}getClosedTorusIndicesForBooleanOrSubdiv(){let t=this.userData.parameters,e=Math.ceil(t.tubularSegments),r=t.radialSegments+1,o=Array.from(this.getIndex().array),i,a,s,l,u=6*(e-1)*t.radialSegments,c=e,d=c===e;for(let p=0;p<t.radialSegments;p++)i=c*r+p,a=i+1,s=(d?p:i)+r,l=(d?p+1:a)+r,o[u++]=i,o[u++]=a,o[u++]=s,o[u++]=a,o[u++]=l,o[u++]=s;return o.length=u,pf.array=o,pf.count=o.length,pf}};import{IcosahedronGeometry as DM}from"three";var Dx=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,detail:0,corner:0,cornerSides:4},n.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(n){let{width:t,height:e,depth:r,detail:o,corner:i,cornerSides:a}=n.parameters,s=o===0&&i!==0?new ul(t*.5,i,a):new DM(t*.5,o);return s.scale(1,e/t,r/t),Object.assign(s,{userData:{...n,type:"IcosahedronGeometry"}})}},ul=class extends Pn{constructor(t=1,e=.2,r=4){let o=(1+Math.sqrt(5))/2,i=[-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(i,a,s,t,e,r),this.type=s}static fromJSON(t){return new ul(t.radius,t.corner,t.cornerSides)}};import{LatheGeometry as EM,Shape as BM}from"three";var Ex=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){(n.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}]},n.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(n){let{points:t,segments:e,verticalSegments:r}=n.parameters,o=new BM;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 i=new EM(o.extractPoints(r).shape,e);return i.rotateZ(Math.PI),Object.assign(i,{userData:{...n,type:"LatheGeometry"}})}};import{BufferGeometry as kx,BufferGeometryLoader as WM,Vector3 as $M,BoxGeometry as jx}from"three";import{BufferGeometry as jM,Vector2 as yf,Vector3 as Fx}from"three";import{Box3 as LM,BufferAttribute as dl,BufferGeometry as Bx,Color as mf,EventDispatcher as RM,Float32BufferAttribute as Va,Matrix3 as Lx,Matrix4 as Gx,MathUtils as VM,Object3D as zM,Sphere as GM,Vector2 as Ar,Vector3 as $t,Vector4 as FM}from"three";var xo=new Gx,ff=new zM,Pu=new $t,Mn=class extends RM{constructor(){super(),this.uuid=VM.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 Lx().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 i=this.faces[r];i.normal.applyMatrix3(e).normalize();for(let a=0,s=i.vertexNormals.length;a<s;a++)i.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 xo.makeRotationX(t),this.applyMatrix4(xo),this}rotateY(t){return xo.makeRotationY(t),this.applyMatrix4(xo),this}rotateZ(t){return xo.makeRotationZ(t),this.applyMatrix4(xo),this}translate(t,e,r){return xo.makeTranslation(t,e,r),this.applyMatrix4(xo),this}scale(t,e,r){return xo.makeScale(t,e,r),this.applyMatrix4(xo),this}lookAt(t){return ff.lookAt(t),ff.updateMatrix(),this.applyMatrix4(ff.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 i=o.position,a=o.normal,s=o.color,l=o.uv,u=o.uv2;u!==void 0&&(this.faceVertexUvs[1]=[]);for(let p=0;p<i.count;p++)e.vertices.push(new $t().fromBufferAttribute(i,p)),s!==void 0&&e.colors.push(new mf().fromBufferAttribute(s,p));function c(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 $t().fromBufferAttribute(a,p),new $t().fromBufferAttribute(a,f),new $t().fromBufferAttribute(a,h)],b=new za(p,f,h,g,y,m);e.faces.push(b),l!==void 0&&e.faceVertexUvs[0].push([new Ar().fromBufferAttribute(l,p),new Ar().fromBufferAttribute(l,f),new Ar().fromBufferAttribute(l,h)]),u!==void 0&&e.faceVertexUvs[1].push([new Ar().fromBufferAttribute(u,p),new Ar().fromBufferAttribute(u,f),new Ar().fromBufferAttribute(u,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?c(r.getX(y),r.getX(y+1),r.getX(y+2),f.materialIndex):c(y,y+1,y+2,f.materialIndex)}else if(r!==void 0)for(let p=0;p<r.count;p+=3)c(r.getX(p),r.getX(p+1),r.getX(p+2));else for(let p=0;p<i.count;p+=3)c(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(Pu).negate(),this.translate(Pu.x,Pu.y,Pu.z),this}normalize(){this.computeBoundingSphere();let t=this.boundingSphere.center,e=this.boundingSphere.radius,r=e===0?1:1/e,o=new Gx;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 $t,e=new $t;for(let r=0,o=this.faces.length;r<o;r++){let i=this.faces[r],a=this.vertices[i.a],s=this.vertices[i.b],l=this.vertices[i.c];t.subVectors(l,s),e.subVectors(a,s),t.cross(e),t.normalize(),i.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 $t;if(t){let r=new $t,o=new $t;for(let i=0,a=this.faces.length;i<a;i++){let s=this.faces[i],l=this.vertices[s.a],u=this.vertices[s.b],c=this.vertices[s.c];r.subVectors(c,u),o.subVectors(l,u),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 i=this.faces[r];e[i.a].add(i.normal),e[i.b].add(i.normal),e[i.c].add(i.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 i=this.faces[r],a=i.vertexNormals;a.length===3?(a[0].copy(e[i.a]),a[1].copy(e[i.b]),a[2].copy(e[i.c])):(a[0]=e[i.a].clone(),a[1]=e[i.b].clone(),a[2]=e[i.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 i=0,a=o.vertexNormals.length;i<a;i++)o.__originalVertexNormals[i]?o.__originalVertexNormals[i].copy(o.vertexNormals[i]):o.__originalVertexNormals[i]=o.vertexNormals[i].clone()}let t=new Mn;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 i=this.morphNormals[e].faceNormals,a=this.morphNormals[e].vertexNormals;for(let s=0,l=this.faces.length;s<l;s++){let u=new $t,c={a:new $t,b:new $t,c:new $t};i.push(u),a.push(c)}}let o=this.morphNormals[e];t.vertices=this.morphTargets[e].vertices,t.computeFaceNormals(),t.computeVertexNormals();for(let i=0,a=this.faces.length;i<a;i++){let s=this.faces[i],l=o.faceNormals[i],u=o.vertexNormals[i];l.copy(s.normal),u.a.copy(s.vertexNormals[0]),u.b.copy(s.vertexNormals[1]),u.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 LM),this.boundingBox.setFromPoints(this.vertices)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new GM),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,i=this.vertices.length,a=this.vertices,s=t.vertices,l=this.faces,u=t.faces,c=this.colors,d=t.colors;e!==void 0&&(o=new Lx().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++)c.push(d[p].clone());for(let p=0,f=u.length;p<f;p++){let h=u[p],m,y,g=h.vertexNormals,b=h.vertexColors,w=new za(h.a+i,h.b+i,h.c+i);w.normal.copy(h.normal),o!==void 0&&w.normal.applyMatrix3(o).normalize();for(let A=0,S=g.length;A<S;A++)m=g[A].clone(),o!==void 0&&m.applyMatrix3(o).normalize(),w.vertexNormals.push(m);w.color.copy(h.color);for(let A=0,S=b.length;A<S;A++)y=b[A],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,A=g.length;w<A;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=[],i=Math.pow(10,t);for(let l=0,u=this.vertices.length;l<u;l++){let c=this.vertices[l],d=Math.round(c.x*i)+"_"+Math.round(c.y*i)+"_"+Math.round(c.z*i);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,u=this.faces.length;l<u;l++){let c=this.faces[l];c.a=o[c.a],c.b=o[c.b],c.c=o[c.c];let d=[c.a,c.b,c.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 u=a[l];this.faces.splice(u,1);for(let c=0,d=this.faceVertexUvs.length;c<d;c++)this.faceVertexUvs[c].splice(u,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 $t(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,u){return l.materialIndex-u.materialIndex}t.sort(r);let o=this.faceVertexUvs[0],i=this.faceVertexUvs[1],a,s;o&&o.length===e&&(a=[]),i&&i.length===e&&(s=[]);for(let l=0;l<e;l++){let u=t[l]._id;a&&a.push(o[u]),s&&s.push(i[u])}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=[],i={},a=[],s={},l=[],u={};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,A=m.vertexNormals.length>0,S=m.color.r!==1||m.color.g!==1||m.color.b!==1,P=m.vertexColors.length>0,O=0;if(O=c(O,0,0),O=c(O,1,y),O=c(O,2,g),O=c(O,3,b),O=c(O,4,w),O=c(O,5,A),O=c(O,6,S),O=c(O,7,P),r.push(O),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)),A){let x=m.vertexNormals;r.push(d(x[0]),d(x[1]),d(x[2]))}if(S&&r.push(p(m.color)),P){let x=m.vertexColors;r.push(p(x[0]),p(x[1]),p(x[2]))}}function c(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 i[m]!==void 0||(i[m]=o.length/3,o.push(h.x,h.y,h.z)),i[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 u[m]!==void 0||(u[m]=l.length/2,l.push(h.x,h.y)),u[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 Mn().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,A=g.length;w<A;w++){let S=g[w];b.push(S.clone())}this.faceVertexUvs[p].push(b)}}let i=t.morphTargets;for(let p=0,f=i.length;p<f;p++){let h={};if(h.name=i[p].name,i[p].vertices!==void 0){h.vertices=[];for(let m=0,y=i[p].vertices.length;m<y;m++)h.vertices.push(i[p].vertices[m].clone())}if(i[p].normals!==void 0){h.normals=[];for(let m=0,y=i[p].normals.length;m<y;m++)h.normals.push(i[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 u=t.lineDistances;for(let p=0,f=u.length;p<f;p++)this.lineDistances.push(u[p]);let c=t.boundingBox;c!==null&&(this.boundingBox=c.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 Bx,r=new Float32Array(t.vertices.length*3);if(e.setAttribute("position",Ou.call(new dl(r,3),t.vertices)),t.normals.length>0){let o=new Float32Array(t.normals.length*3);e.setAttribute("normal",Ou.call(new dl(o,3),t.normals))}if(t.colors.length>0){let o=new Float32Array(t.colors.length*3);e.setAttribute("color",Rx.call(new dl(o,3),t.colors))}if(t.uvs.length>0){let o=new Float32Array(t.uvs.length*2);e.setAttribute("uv",Vx.call(new dl(o,2),t.uvs))}if(t.uvs2.length>0){let o=new Float32Array(t.uvs2.length*2);e.setAttribute("uv2",Vx.call(new dl(o,2),t.uvs2))}e.groups=t.groups;for(let o in t.morphTargets){let i=[],a=t.morphTargets[o];for(let s=0,l=a.length;s<l;s++){let u=a[s],c=new Va(u.data.length*3,3);c.name=u.name,i.push(Ou.call(c,u.data))}e.morphAttributes[o]=i}if(t.skinIndices.length>0){let o=new Va(t.skinIndices.length*4,4);e.setAttribute("skinIndex",zx.call(o,t.skinIndices))}if(t.skinWeights.length>0){let o=new Va(t.skinWeights.length*4,4);e.setAttribute("skinWeight",zx.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 Bx,r=t.geometry;if(t.isPoints||t.isLine){let o=new Va(r.vertices.length*3,3),i=new Va(r.colors.length*3,3);if(e.setAttribute("position",Ou.call(o,r.vertices)),e.setAttribute("color",Rx.call(i,r.colors)),r.lineDistances&&r.lineDistances.length===r.vertices.length){let a=new Va(r.lineDistances.length,1);e.setAttribute("lineDistance",kM.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}};Mn.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,i,a=t.faces;for(o=0;o<a.length;o++){let s=a[o];s.materialIndex!==i&&(i=s.materialIndex,r!==void 0&&(r.count=o*3-r.start,e.push(r)),r={start:o*3,materialIndex:i})}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,i=o[0]&&o[0].length>0,a=o[1]&&o[1].length>0,s=t.morphTargets,l=s.length,u;if(l>0){u=[];for(let g=0;g<l;g++)u[g]={name:s[g].name,data:[]};this.morphTargets.position=u}let c=t.morphNormals,d=c.length,p;if(d>0){p=[];for(let g=0;g<d;g++)p[g]={name:c[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 A=b.vertexColors;if(A.length===3)this.colors.push(A[0],A[1],A[2]);else{let S=b.color;this.colors.push(S,S,S)}if(i===!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 Ar,new Ar,new Ar))}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 Ar,new Ar,new Ar))}for(let S=0;S<l;S++){let P=s[S].vertices;u[S].data.push(P[b.a],P[b.b],P[b.c])}for(let S=0;S<d;S++){let P=c[S].vertexNormals[g];p[S].data.push(P.a,P.b,P.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}},za=class{constructor(t,e,r,o,i,a=0){this.a=t,this.b=e,this.c=r,this.normal=o&&o.isVector3?o:new $t,this.vertexNormals=Array.isArray(o)?o:[],this.color=i&&i.isColor?i:new mf,this.vertexColors=Array.isArray(i)?i:[],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 kM(n){return this.array.set(n),this}function Rx(n){let t=this.array,e=0;for(let r=0,o=n.length;r<o;r++){let i=n[r];i===void 0&&(console.warn("THREE.BufferAttribute.copyColorsArray(): color is undefined",r),i=new mf),t[e++]=i.r,t[e++]=i.g,t[e++]=i.b}return this}function Vx(n){let t=this.array,e=0;for(let r=0,o=n.length;r<o;r++){let i=n[r];i===void 0&&(console.warn("THREE.BufferAttribute.copyVector2sArray(): vector is undefined",r),i=new Ar),t[e++]=i.x,t[e++]=i.y}return this}function Ou(n){let t=this.array,e=0;for(let r=0,o=n.length;r<o;r++){let i=n[r];i===void 0&&(console.warn("THREE.BufferAttribute.copyVector3sArray(): vector is undefined",r),i=new $t),t[e++]=i.x,t[e++]=i.y,t[e++]=i.z}return this}function zx(n){let t=this.array,e=0;for(let r=0,o=n.length;r<o;r++){let i=n[r];i===void 0&&(console.warn("THREE.BufferAttribute.copyVector4sArray(): vector is undefined",r),i=new FM),t[e++]=i.x,t[e++]=i.y,t[e++]=i.z,t[e++]=i.w}return this}var UM=["a","b","c"];function HM(n,t){switch(t){case"c":return n.c;case"b":return n.b;case"a":default:return n.a}}function gf(n,t,e){let r=Math.min(n,t),o=Math.max(n,t),i=r+"_"+o;return e.get(i)}function xf(n,t,e,r,o,i){let a=Math.min(n,t),s=Math.max(n,t),l=a+"_"+s,u;if(r.has(l))u=r.get(l);else{let c=e[a],d=e[s];u={a:c,b:d,newEdge:null,faces:[]},r.set(l,u)}u.faces.push(o),i[n].edges.push(u),i[t].edges.push(u)}function qM(n,t,e,r){let o,i,a;for(o=0,i=n.length;o<i;o++)e[o]={edges:[]};for(o=0,i=t.length;o<i;o++)a=t[o],xf(a.a,a.b,n,r,a,e),xf(a.b,a.c,n,r,a,e),xf(a.c,a.a,n,r,a,e)}function Cu(n,t,e,r,o){n.push(new za(t,e,r,void 0,void 0,o))}function Ga(n,t){return Math.abs(t-n)/2+Math.min(n,t)}function Tu(n,t,e,r){n.push([t.clone(),e.clone(),r.clone()])}var Mu=class{constructor(t=1){this.subdivisions=t}modify(t){t instanceof jM?t=new Mn().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 Fx,r,o,i,a,s,l=t.vertices,u=t.faces,c=t.faceVertexUvs[0],d=c!==void 0&&c.length>0,p=[],f=new Map;qM(l,u,p,f);let h=[],m,y,g,b,w,A,S;for(let ee of Array.from(f.keys())){for(y=f.get(ee),g=new Fx,w=3/8,A=1/8,S=y.faces.length,S!=2&&(w=.5,A=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[HM(b,UM[s])],!(m!==y.a&&m!==y.b));s++);m&&e.add(m)}e.multiplyScalar(A),g.add(e),y.newEdge=h.length,h.push(g)}let P,O,x,D,N,T,I,E=[];for(o=0,i=l.length;o<i;o++){for(T=l[o],N=p[o].edges,r=N.length,r==3?P=3/16:r>3&&(P=3/(8*r)),O=1-r*Number(P),x=P,r<=2&&(r==2?(O=3/4,x=1/8):r==1||r==0),I=T.clone().multiplyScalar(O),e.set(0,0,0),a=0;a<r;a++)D=N[a],m=D.a!==T?D.a:D.b,e.add(m);e.multiplyScalar(Number(x)),I.add(e),E.push(I)}let B=E.concat(h),R=E.length,F,V,q,k=[],U=[],H,Y,J,Z,X=new yf,te=new yf,$=new yf;for(o=0,i=u.length;o<i;o++)b=u[o],F=Number(gf(b.a,b.b,f).newEdge)+R,V=Number(gf(b.b,b.c,f).newEdge)+R,q=Number(gf(b.c,b.a,f).newEdge)+R,Cu(k,F,V,q,b.materialIndex),Cu(k,b.a,F,q,b.materialIndex),Cu(k,b.b,V,F,b.materialIndex),Cu(k,b.c,q,V,b.materialIndex),d&&(H=c[o],Y=H[0],J=H[1],Z=H[2],X.set(Ga(Y.x,J.x),Ga(Y.y,J.y)),te.set(Ga(J.x,Z.x),Ga(J.y,Z.y)),$.set(Ga(Y.x,Z.x),Ga(Y.y,Z.y)),Tu(U,X,te,$),Tu(U,Y,X,$),Tu(U,J,te,X),Tu(U,Z,$,te));t.vertices=B,t.faces=k,d&&(t.faceVertexUvs[0]=U)}};var Nt=new $M,Ux=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=n.geometry??t?.geometry??new kx().copy(new jx(100,100,100)),r;t===void 0?(e.computeBoundingBox(),e.boundingBox.getSize(Nt),r={width:Nt.x,height:Nt.y,depth:Nt.z,subdivisions:0}):r=t.parameters;let o={...r,...n.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(n){let{width:t,height:e,depth:r,subdivisions:o}=n.parameters,i=n.geometry??new kx().copy(new jx(100,100,100)),a=i.userData.parameters;a===void 0?(i.computeBoundingBox(),i.boundingBox.getSize(Nt)):Nt.set(a.width,a.height,a.depth),(t!==Nt.x||e!==Nt.y||r!==Nt.z)&&i.scale(Nt.x===0?1:t/Nt.x,Nt.y===0?1:e/Nt.y,Nt.z===0?1:r/Nt.z);let s=i.originalGeometry;try{o>0?(s===void 0||a?.subdivisions!==o)&&(s===void 0&&(s=i),i=new Mu(o).modify(s).toBufferGeometry()):(s!==void 0&&(i=s),s=void 0,i.getAttribute("normal")===void 0&&i.computeVertexNormals())}catch{s!==void 0&&(i=s),s=void 0,i.getAttribute("normal")===void 0&&i.computeVertexNormals()}return s!==void 0&&Object.assign(i,{originalGeometry:s}),delete n.geometry,Object.assign(i,{userData:{...n,type:"NonParametricGeometry"}})}static loadFromUrl(n,t,e){new WM(e).load(n,o=>{let i=this.normalizeInputs({geometry:o});o.boundingBox.getSize(Nt);let a=100/Nt.x;Object.assign(i.parameters,{width:100,height:Nt.y*a,depth:Nt.z*a}),t(this.build(i))})}};var Iu=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:3},n.parameters);return{shape:n.shape&&n.shape instanceof He?n.shape:new He,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)})}}static build(n){let{width:t,height:e,spikes:r,cornerRadius:o,depth:i,extrudeBevelSize:a,extrudeBevelSegments:s}=n.parameters,l=n.shape,u=t*.5,c=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)*u,b=p+Math.cos(y)*c;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=dr.create({shape:l,parameters:{roundness:o,depth:i,extrudeBevelSize:a,extrudeBevelSegments:s}});return Object.assign(h,{userData:{...n,type:"PolygonGeometry"}})}};import{BufferGeometry as YM,Float32BufferAttribute as bf,Vector2 as bo,Vector3 as zt}from"three";var Hx=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,radialSegments:4,heightSegments:1,cornerRadius:0,cornerSegments:8,openEnded:!1},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(n){let{width:t,height:e,depth:r,radialSegments:o,heightSegments:i,openEnded:a,cornerRadius:s,cornerSegments:l}=n.parameters,u=new Sf(t*.5,e,o,i,a,s,l);return u.scale(1,1,r/t),Object.assign(u,{userData:{...n,type:"PyramidGeometry"}})}};function pl(n,t,e){e.x=n.x*t.x,e.y=n.y,e.z=n.x*t.y}function vf(n,t,e,r,o,i){let a=t.clone().sub(n),s=e.clone().sub(n),l=a.angleTo(s);if(a.normalize(),s.normalize(),r===o){let u=a.add(s).normalize();i.copy(n).addScaledVector(u,r/Math.sin(l/2))}else{let u=a.angleTo(s);i.copy(n),i.addScaledVector(a,o/Math.sin(u)),i.addScaledVector(s,r/Math.sin(u))}}function XM(n,t,e){let r=n.clone().sub(t),o=e.clone().sub(t);return r.projectOnVector(o),r.add(t)}var Sf=class extends YM{constructor(t=.5,e=1,r=4,o=1,i=!1,a=0,s=4){super(),r=Math.floor(Math.max(3,r)),o=Math.floor(o),s=Math.floor(s);let l=[],u=[],c=[],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 zt(0,-f,0),A=new zt(0,f,0),S=new bo(t,-f),P=new bo(m,-f),O=new bo(0,A.y).sub(P),x=new bo(0,A.y).sub(S),D=new bo(O.y,-O.x).normalize(),N=new bo(x.y,-x.x).normalize(),I=t*Math.cos(Math.PI/r)*Math.tan((Math.PI-O.angle())/2)-1e-8;a=Math.min(a,I);let E;{let U=new zt(D.x,D.y,0),H=new zt(Math.cos(y)*U.x,U.y,Math.sin(y)*U.x);E=U.angleTo(H)}let B=a/Math.tan((Math.PI-O.angle())/2),R=a/Math.tan((Math.PI-E)/2),F=new zt;if(!i){u.push(w.x,w.y,w.z),c.push(0,-1,0),d.push(0,0);let U=p++,H=[],Y=S.clone(),J=B/Math.cos(Math.PI/r);Y.x-=J;for(let Z=0;Z<r;Z++){let X=Z/r*Math.PI*2+h,te=new bo(Math.sin(X),Math.cos(X));pl(Y,te,F),u.push(F.x,F.y,F.z),c.push(0,-1,0),d.push(0,0),H.push(p++)}for(let Z=0;Z<H.length;Z++)l.push(H[Z],U,H[(Z+1)%H.length])}let V=[];{let U=new zt,H=new zt,Y=new zt,J=new zt,Z=new zt,X=new zt;for(let te=0;te<r;te++){let $=te/r*Math.PI*2+h,ee=(te+.5)/r*Math.PI*2+h,Q=(te+1)/r*Math.PI*2+h,W=new bo(Math.sin($),Math.cos($)),ue=new bo(Math.sin(ee),Math.cos(ee)),le=new bo(Math.sin(Q),Math.cos(Q));pl(S,W,H),pl(S,le,Y),pl(D,ue,U),vf(A,H,Y,R,R,J),u.push(J.x,J.y,J.z),vf(H,A,Y,R,B,Z),u.push(Z.x,Z.y,Z.z),vf(Y,H,A,B,R,X),u.push(X.x,X.y,X.z),c.push(U.x,U.y,U.z),c.push(U.x,U.y,U.z),c.push(U.x,U.y,U.z),d.push(0,0),d.push(0,0),d.push(0,0);let ne=p++,ce=p++,ae=p++;if(l.push(ne,ce,ae),a>0){{let fe=H.clone().add(Y).multiplyScalar(.5),ge=A.clone().sub(fe).normalize(),C=w.clone().sub(fe).normalize().add(ge).normalize().multiplyScalar(-1),ie=X.clone().sub(Z);q(fe,ie,C,O.angle())}let he,pe;{let fe=new zt;pl(N,le,fe);let ge=X.clone().add(J).multiplyScalar(.5);ge=XM(ge,Y,A);let me=X.clone().sub(J);[he,pe]=q(ge,me,fe,E,J.y)}{let fe=he,ge=fe.clone().setY(0).normalize(),me=new zt(0,-1,0),C=ge.clone().cross(me);k(fe,ge,me,C)}V.concat(pe);{let fe=O.angle(),ge=Math.PI-fe,me=A.clone();me.y-=a/Math.sin(fe-Math.PI/2);let C=new zt,ie=[];for(let Ge=0;Ge<s;Ge++){let Ee=[],_e=Math.PI/2-ge*Ge/s,Ct=Math.cos(_e),Me=Math.sin(_e),At=ee;for(let Tt=0;Tt<=Ge;Tt++){let Wn=Math.cos(At),st=Math.sin(At);U.x=Ct*st,U.y=Me,U.z=Ct*Wn,C.copy(me).addScaledVector(U,a),u.push(C.x,C.y,C.z),c.push(U.x,U.y,U.z),d.push(0,0),Ee.push(p++),At+=Math.PI*2/Ge/r}ie.push(Ee)}pe.reverse(),ie.push(pe);let De=ie.length-1;for(let Ge=0;Ge<De;Ge++){let Ee=ie[Ge],_e=ie[Ge+1],Ct=Ee.length-1;l.push(_e[1],Ee[0],_e[0]);for(let Me=1;Me<=Ct;Me++)l.push(Ee[Me],Ee[Me-1],_e[Me]),l.push(_e[Me+1],Ee[Me],_e[Me])}}}}}this.setIndex(l),this.setAttribute("position",new bf(u,3)),this.setAttribute("normal",new bf(c,3)),this.setAttribute("uv",new bf(d,2));function q(U,H,Y,J,Z){let X=-J/2,te=(Math.PI-J)/2,$=H.clone().normalize().cross(Y);U.addScaledVector(Y,-a/Math.sin(te));let ee=new zt,Q=new zt,W=1,ue=p,le=[];for(let ne=0;ne<=s;ne++){let ce=X+ne/s*J;Q.set(0,0,0),Q.addScaledVector($,Math.sin(ce)),Q.addScaledVector(Y,Math.cos(ce));for(let ae=0;ae<=W;ae++){let he=ae/W-.5;if(ee.copy(U),ee.addScaledVector(H,he),ee.addScaledVector(Q,a),Z!=null){let pe=Math.max(0,ee.y-Z);ee.addScaledVector(H,-pe/H.y)}u.push(ee.x,ee.y,ee.z),c.push(Q.x,Q.y,Q.z),d.push(0,0),ae===0&&le.push(p),p++}}for(let ne=0;ne<s;ne++)for(let ce=0;ce<W;ce++){let ae=ue+ce+(W+1)*ne,he=ae+(W+1),pe=he+1,fe=ae+1;l.push(ae,he,fe),l.push(he,pe,fe)}return[U.clone().addScaledVector(H,.5),le]}function k(U,H,Y,J){let Z=Math.PI/2,X=x.angle()-Z,te=[],$=new zt,ee=new zt;for(let W=0;W<=s;W++){let ue=[],le=W/s;for(let ne=0;ne<=W;ne++){let ae=((W?ne/W:0)-.5)*b,he=Math.cos(ae),pe=Math.sin(ae),fe=Math.atan(Math.tan(X)*he),ge=(Z+fe)*le,me=Math.cos(ge),C=Math.sin(ge);$.set(0,0,0),$.addScaledVector(H,C*he),$.addScaledVector(Y,me),$.addScaledVector(J,C*pe),ee.copy(U).addScaledVector($,a),u.push(ee.x,ee.y,ee.z),c.push($.x,$.y,$.z),d.push(0,0),ue.push(p++)}te.push(ue)}let Q=te.length-1;for(let W=0;W<Q;W++){let ue=te[W],le=te[W+1],ne=ue.length-1;l.push(ue[0],le[1],le[0]);for(let ce=1;ce<=ne;ce++)l.push(ue[ce-1],ue[ce],le[ce]),l.push(ue[ce],le[ce+1],le[ce])}}}};var Fa=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,cornerRadius:[0,0,0,0],cornerType:1,extrudeBevelSize:0,extrudeBevelSegments:1},n.parameters),r=Object.assign(t?.ui??{enabledIndieCorners:!1},n.ui);return{shape:n.shape&&n.shape instanceof He?n.shape:new He,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(n){let t=n.shape,{width:e,height:r,cornerRadius:o,cornerType:i,depth:a,extrudeBevelSize:s,extrudeBevelSegments:l}=n.parameters,u={x:e*.5,y:r*.5},c={x:-u.x,y:-u.y},d={x:u.x,y:u.y};function p(A,S,P){return S>e&&P>r?Math.min(A*e/S,A*r/P):S>e?A*e/S:P>r?A*r/P:A}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=c.x,m=d.x,y=d.y,g=c.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 A=0,S=t.points.length;A<S;A++)t.points[A].roundness=f[A],A>0&&f[A]!==f[A-1]&&(b=!1);b&&(t.roundness=f[0]),t.useCubicForRoundedCorners=i!==1,t.update();let w=dr.create({shape:t,parameters:{depth:a,extrudeBevelSize:s,extrudeBevelSegments:l}});return Object.assign(w,{userData:{...n,type:"RectangleGeometry"}})}};import{BufferGeometry as QM,Float32BufferAttribute as KM,MathUtils as qx,SphereGeometry as ZM}from"three";var Wx=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,widthSegments:64,heightSegments:64,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:180},n.parameters);return e.thetaLength=qx.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(n){let{width:t=100,height:e=t,depth:r=t,widthSegments:o=64,heightSegments:i=64,phiStart:a,phiLength:s,thetaStart:l,thetaLength:u}=n.parameters,c;return u===0?(c=new QM,c.setAttribute("position",new KM([],3))):c=new ZM(.5*t,o,i,a,s,l,u*qx.DEG2RAD),c.scale(1,e/t,r/t),Object.assign(c,{userData:{...n,type:"SphereGeometry"}})}};import{PlaneGeometry as JM}from"three";var $x=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,widthSegments:8,heightSegments:8},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:0})}}static build(n){let{width:t=100,height:e=t,widthSegments:r=8,heightSegments:o=8}=n.parameters,i=new JM(t,e,r,o);return i.scale(1,1,1),Object.assign(i,{userData:{...n,type:"PlaneGeometry"}})}};import{BufferGeometry as eI,Float32BufferAttribute as wf,Vector3 as tI}from"three";var Yx=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,angle:90,cornerRadius:24,cornerSegments:8},n.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(n){let{width:t,height:e,depth:r,angle:o,cornerRadius:i,cornerSegments:a}=n.parameters,s=new Af(t,e,r,o,i,a);return Object.assign(s,{userData:{...n,type:"BackdropGeometry"}})}},Af=class extends eI{constructor(t=1,e=1,r=1,o=90,i=10,a=24){super(),this.type="BackdropGeometry";let s=[],l=[],u=[],c=.001;i==0&&(a=1),a=Math.max(1,Math.floor(a)),i=Math.min(i,100),o=Math.min(180-c,o),o*=Math.PI/180;let d=[],p=Math.PI/2,f=(ee=0,Q=0,W=0)=>new tI(ee,Q,W),h=f(),m=f(),[y,g,b]=[e/2,t/2,r/2],w=-g,A=+g,[S,P,O]=[f(w,-y,+b),f(w,-y,-b),f(w,+y,-b)],x=(ee,Q=!1)=>Math.sin(ee-Math.PI/(1+ +Q)),D=(ee,Q=!1)=>Math.cos(ee-Math.PI/(1+ +Q));O.y=Math.sin(o)*e-y;let N=Math.cos(o)*e-b,T=S.z-c;o<=p?(O.z=Math.min(N,T),O.z==T&&(O.y-=(N-T)/Math.tan(p-o))):P.z=Math.min(P.z-N-b,S.z-c),h.subVectors(S,P),m.subVectors(O,P);let I=Math.min(h.length(),m.length())*i/100,E=I*Math.tan(o/2),B=I/Math.cos(o/2),R=h.clone().normalize().add(m.normalize()).setLength(B).add(P);h.set(0,x(o,!0),D(o,!0)),d.push([O,h.clone()]);let F=(Math.PI-o)/a;for(let ee=0;ee<=a;ee++){let Q=p+o+ee*F;h.set(0,Math.sin(Q)*E,Math.cos(Q)*E),h.add(R),m.set(0,x(Q),D(Q)),d.push([h.clone(),m.clone()])}d.push([S,f(0,1,0)]);let V=Math.sin(F/2)*E*2,q=d.length-1,k=d[0][0].distanceTo(d[1][0]),U=d[q-1][0].distanceTo(d[q][0]),H=k+V*a+U;d[0].push(1);for(let ee=0;ee<=a;ee++)d[ee+1].push(1-(k+ee*V)/H);d[q].push(0);let[Y,J,Z]=d[0],X,te,$;for(let ee=1;ee<d.length;ee++)[X,te,$]=d[ee],s.push(w,Y.y,Y.z,w,X.y,X.z,A,Y.y,Y.z,A,Y.y,Y.z,w,X.y,X.z,A,X.y,X.z),l.push(0,J.y,J.z,0,te.y,te.z,0,J.y,J.z,0,J.y,J.z,0,te.y,te.z,0,te.y,te.z),u.push(0,Z,0,$,1,Z,1,Z,0,$,1,$),[Y,J,Z]=[X,te,$];this.setAttribute("position",new wf(s,3)),this.setAttribute("normal",new wf(l,3)),this.setAttribute("uv",new wf(u,2))}};var Nu=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,innerRadiusPercent:38.19,spikes:5,cornerRadius:0,angle:360,extrudeBevelSize:0,extrudeBevelSegments:1},n.parameters);return{shape:n.shape&&n.shape instanceof He?n.shape:new He,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)})}}static build(n){let{width:t,height:e,innerRadiusPercent:r,spikes:o,cornerRadius:i,angle:a,depth:s,extrudeBevelSize:l,extrudeBevelSegments:u}=n.parameters,c=n.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 A=0;A<o;A++){let S=m*A,P=f+Math.sin(S)*d,O=h+Math.cos(S)*p;c.addPoint(c.createPoint(P,O))}}else for(let A=0;A<o;A++){let S=f+Math.cos(y)*d,P=h+Math.sin(y)*p;c.addPoint(c.createPoint(S,P)),y+=m,S=f+Math.cos(y)*g,P=h+Math.sin(y)*b,A<=o,c.addPoint(c.createPoint(S,P)),y+=m}c.isClosed=!0;for(let A=0,S=c.points.length;A<S;A++)c.points[A].roundness=i;c.roundness=i,c.update();let w=dr.create({shape:c,parameters:{roundness:i,depth:s,extrudeBevelSize:l,extrudeBevelSegments:u}});return Object.assign(w,{userData:{...n,type:"StarGeometry"}})}};import{PlaneGeometry as rI}from"three";var Xx=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,depth:0},n.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(n){let{width:t,height:e}=n.parameters,r=new rI(t,e);return Object.assign(r,{userData:{...n,type:"TextFrameGeometry"}})}};import{BufferGeometry as oI,Float32BufferAttribute as nI,MathUtils as iI}from"three";var Qx=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,radialSegments:32,tubularSegments:64,arc:360,cornerRadius:30,cornerSegments:8},n.parameters),r=Math.abs(e.width),o=Math.abs(e.height??e.width),i=Math.round(Math.abs(e.depth??e.width*.25));return{parameters:Object.assign(e,{width:r,height:o,depth:i})}}static build(n){let{width:t,height:e,depth:r,radialSegments:o,tubularSegments:i,arc:a,cornerRadius:s,cornerSegments:l}=n.parameters,u=aI(t,e,r,t*.5,a,i,0,0,o,s,l);return u.scale(1,e/t,1),Object.assign(u,{userData:{...n,type:"TorusGeometry"}})}};function aI(n,t,e,r,o,i,a,s,l,u,c){[t,e]=[e,t],a=t/2;let d=iI.clamp(o/360,0,1);if(d===0){let p=new oI;return p.setAttribute("position",new nI([],3)),p}return d===1&&(u=0),new cl(!0,n,t,e,r,d,i,a,s,l,u,c)}import{TorusKnotGeometry as sI}from"three";var Kx=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,tubularSegments:64,radialSegments:32,p:2,q:3},n.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width),tube:e.tube??e.width*.125})}}static build(n){let{width:t,tube:e,tubularSegments:r,radialSegments:o,p:i,q:a}=n.parameters,s=t*.5;s!==e&&(s-=e);let l=new sI(s,e,r,o,i,a);return Object.assign(l,{userData:{...n,type:"TorusKnotGeometry"}})}};var Zx=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1,isRect:!1},n.parameters);return{shape:n.shape&&n.shape instanceof He?n.shape:new He,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(n){let{width:t=100,height:e,cornerRadius:r,depth:o,extrudeBevelSize:i,extrudeBevelSegments:a,isRect:s}=n.parameters,l=n.shape,u=t*.5,c=e*.5;s?(l.addPoint(l.createPoint(-u,c)),l.addPoint(l.createPoint(u,-c)),l.addPoint(l.createPoint(-u,-c))):(l.addPoint(l.createPoint(0,c)),l.addPoint(l.createPoint(u,-c)),l.addPoint(l.createPoint(-u,-c))),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=dr.create({shape:l,parameters:{roundness:r,depth:o,extrudeBevelSize:i,extrudeBevelSegments:a}});return Object.assign(d,{userData:{...n,type:"TriangleGeometry"}})}};import{Vector2 as eb,Vector3 as Gt,Matrix3 as lI,Matrix4 as li,BufferGeometry as tb,BufferAttribute as ka,MathUtils as Du}from"three";function Jx(n,t){let e=2*Math.PI;return(n%e+e)%e===(t%e+e)%e}var cI=new li,uI=new li;function dI(n,t,e){let r=[new Gt,new Gt,new Gt],o=[new Gt,new Gt,new Gt];return n.extractBasis(r[0],r[1],r[2]),t.extractBasis(o[0],o[1],o[2]),r.forEach((i,a)=>{let s=o[a],l=Du.lerp(i.length(),s.length(),e);i.lerp(s,e).setLength(l)}),new li().makeBasis(r[0],r[1],r[2])}var rb=class{static create(n){return this.build(this.normalizeInputs(n))}static normalizeInputs(n,t){let e=Object.assign({},t?.parameters??{width:100,height:100,depth:1,subdivisions:12,roundness:0,extrudeBevelSize:0,extrudeBevelSegments:3},n.parameters),r=Math.abs(e.width),o=Math.abs(e.height??e.width),i=Math.abs(e.depth??0),a=t?.shapeData??Ra.create({parameters:yp}).userData.shape;return{path:n.path??ha.defaultData(),parameters:Object.assign(e,{width:r,height:o,depth:i,extrusion:{...Hc,...e.extrusion}}),shapeData:a}}static build(n){if(n.path.points.length>=2){let e=new _f(n);return Object.assign(e,{userData:{...n,type:"PathGeometry"}})}else return Object.assign(new tb,{userData:{...n,type:"PathGeometry"}})}},_f=class extends tb{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)||!Jx(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:i}=this.inputs.parameters.extrusion;o=Math.max(0,Math.min(o,1)),i=Math.max(0,Math.min(i,1));let a=this.inputs.path.isClosed?e.length:e.length-1,s=Math.floor(i*a),l=this.inputs.path.isClosed?Math.ceil((o+i)*a):Math.ceil(Math.min(1,o+i)*a),u=Math.min(Math.max(2,l-s+1),a+2),c=[],d=[];for(let k=0;k<u;k++){let U=this.inputs.path.isClosed?(k+s)%e.length:Math.min(k+s,e.length-1);c.push(e[U].clone()),d.push(r[U].clone())}let p=(k,U,H)=>{c[k]=c[k].clone().lerp(c[U],H),d[k]=dI(d[k],d[U],H)},f=0,h=i*a%1;(!this.inputs.path.isClosed||o<=1)&&(h||i===0)&&(f=h,p(0,1,f));let m=0,y=(i+o)*a%1;if((this.inputs.path.isClosed&&o<=1||!this.inputs.path.isClosed&&i+o<1)&&y&&(m=y,p(c.length-1,c.length-2,1-m)),o===0){let k=c.length-1;c[k].copy(c[0]),d[k].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",A=5;this.inputs.parameters.extrusion.shape.type==="Custom"&&(A=this.inputs.parameters.extrusion.shape.shapeQuality==="low"?5:12);let{regions:S,infos:P,vertices:O}=this._computeShapePoints(A),x=0,D;w==="round"&&(D=new Tn(this.inputs.shapeData,2*g,g,A,b,void 0,!0),x=D.getAttribute("position").count);let N=0,T=0;P.sort((k,U)=>k.start-U.start),P.forEach(k=>{k.verticesStart=N,k.verticesCount=k.continuous.reduce((U,H,Y)=>U+(Y===0||!H?2:1),0),T+=k.verticesCount,N=T});let I=T*u,E,B=0;if(this._isOpenEnded()&&w==="flat"){try{E=Qr({windingRule:je.ODD,elementType:dt.POLYGONS,polySize:3,vertexSize:2,strict:!0,contours:S})}catch{E=cf}B=E.vertexCount}let R=I+2*B+x*2,F=I+2*B,V={positions:new Float32Array(R*3),normals:new Float32Array(R*3),uvs:new Float32Array(R*2)},q=[];if(P.forEach(k=>{this._extrudeRegion(k,O,d,c,V,q,this._isGeometryClosed()&&!this._isOpenEnded())}),E&&(this._closeEnd(E,I,q,V,d[0],c[0],!1),this._closeEnd(E,I+B,q,V,d[d.length-1],c[c.length-1],!0)),D){V.positions.set(D.getAttribute("position").array,F*3),V.normals.set(D.getAttribute("normal").array,F*3),V.uvs.set(D.getAttribute("uv").array,F*2);let k=q.length;q.push(...D.getIndex().array.map(Y=>Y+F)),F+=x,V.positions.set(D.getAttribute("position").array,F*3),V.normals.set(D.getAttribute("normal").array,F*3),V.uvs.set(D.getAttribute("uv").array,F*2);let U=q.length;q.push(...D.getIndex().array.map(Y=>Y+F)),this.setAttribute("position",new ka(V.positions,3)),this.setAttribute("normal",new ka(V.normals,3)),this.setAttribute("uv",new ka(V.uvs,2)),this.setIndex(q);let H=cI;H.copy(d[d.length-1]).setPosition(c[c.length-1]),this.applyMatrix4OnRange(H,F,R),H.copy(d[0]).setPosition(c[0]).multiply(uI.makeScale(1,1,-1)),this.applyMatrix4OnRange(H,F-x,F),this.reverseIndicesOnRange(k,U)}else this.setAttribute("position",new ka(V.positions,3)),this.setAttribute("normal",new ka(V.normals,3)),this.setAttribute("uv",new ka(V.uvs,2)),this.setIndex(q)}_extractPathPoints(){let r=du(this.inputs.path).getPoints(this.inputs.path.subdivisions);if(r.length<2)return[];let o=[r[0]];return r.forEach(a=>{o[o.length-1].distanceToSquared(a)>.001&&o.push(a)}),this.inputs.path.isClosed&&o[o.length-1].distanceTo(o[0])<.001&&o.pop(),o}_computeBasisMatrices(e){let r=[],o=e.length,i=this.inputs.path.isClosed,a=new Gt,s=new Gt,l=new Gt,u=new Gt,c=new Gt(0,1,0);for(let y=0;y<o;y++){let g=e[y],b;y===0?b=i?e[e.length-2]:g.clone().multiplyScalar(2).sub(e[1]):b=e[y-1];let w;y===o-1?w=i?e[1]:g.clone().multiplyScalar(2).sub(e[y-1]):w=e[y+1];let A=g.clone().sub(b).normalize(),S=w.clone().sub(g).normalize(),P=A.clone().add(S).normalize();l.copy(P),y===0&&(P.equals(c)||P.clone().negate().equals(c))&&c.set(0,0,1);let O=c.clone().cross(P).normalize(),x=P.clone().cross(O).normalize();c.copy(x),u.copy(O),y===0&&(a.copy(x),s.copy(P));let D=new li().makeBasis(O,x,P);r.push(D)}let d=i?s:l,p=i?a:new Gt(0,1,0),f=d.clone().cross(u).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 li().makeRotationZ(h*y/r.length);r[y].multiply(g)}return r}_applyPathModifiers(e,r,o){let i=e.length,{angle:a,twist:s,startScale:l,endScale:u}=this.inputs.parameters.extrusion,c=new li,d=new li;return e.forEach((p,f)=>{let h=f===0?0:f===i-1?1:(f-r)/(i-(o===0?0:1)-(r+(1-o)));c.makeRotationZ(Du.lerp(a,a+s,h)*Du.DEG2RAD);let m=Du.lerp(l,u,h);d.makeScale(m,m,m),p.multiply(c).multiply(d)}),e}_computeShapePoints(e=12,r=je.ODD){let o=this.inputs.shapeData,i=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],A=y[b-0];g.push(w,A)}return g}),s;try{s=Qr({windingRule:r,elementType:dt.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[i]})}catch{s=ll}let l;try{l=Qr({windingRule:je.ODD,elementType:dt.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...a]})}catch{l=lf}if(!s)throw new Error("error generating geometry");let u=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 c=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<c&&(c=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>=u,g=m*2,b=s.elements[g+0],w=s.elements[g+1],A=b+w,S={start:b,count:w,normals:[],isHole:y,continuous:[],verticesStart:0,verticesCount:0};h.push(S);let P=b,O=A-1,x=b+1,D=o.roundedCurves.length;do{let N=P-b,T=s.vertices[O*2+0],I=s.vertices[O*2+1],E=s.vertices[P*2+0],B=s.vertices[P*2+1],R=s.vertices[x*2+0],F=s.vertices[x*2+1],V=E-T,q=B-I,k=Math.sqrt(V*V+q*q);V/=k,q/=k;let U=E-R,H=B-F,Y=Math.sqrt(U*U+H*H);U/=Y,H/=Y,S.normals[N*2+0]=-H,S.normals[N*2+1]=U;let J=s.vertexIndices[P];if(Array.isArray(J))S.continuous[N]=!1;else{let[Z,X]=o.getCurveIndexFromVertexId(J-1,!0);if(X>0&&X<1)S.continuous[N]=!0;else{let te=X===1?Z+1:Z-1;te=(te+D)%D;let $=X===1?0:1,ee=o.roundedCurves[Z].getTangent(X),Q=o.roundedCurves[te].getTangent($);S.continuous[N]=ee.dot(Q)>.95}}y&&(S.normals[N*2+0]*=-1,S.normals[N*2+1]*=-1),[O,P,x]=[P,x,x+1],x>=A&&(x-=w)}while(x!==b+1)}return{regions:[i,...a],infos:h,vertices:s.vertices}}_insertVertex(e,r,o,i,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]=i.x,e.normals[l+1]=i.y,e.normals[l+2]=i.z,e.uvs[s+0]=a.x,e.uvs[s+1]=a.y}_extrudeRegion(e,r,o,i,a,s,l){let u=new Gt,c=new Gt,d=new Gt,p=new Gt,f=new eb;o.forEach((m,y)=>{let g=i[y],b=e.verticesStart*o.length+e.verticesCount*y;for(let w=0;w<e.count;w++){let A=(e.start+w)*2;if(u.set(r[A+0],r[A+1],0),d.copy(u).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:A-2;c.set(r[S+0],r[S+1],0),p.copy(u).sub(c),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:A+2;c.set(r[S+0],r[S+1],0),p.copy(c).sub(u),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 A=w===e.count-1?0:b+1,S=y+b,P=y+A,O=g+A,x=g+b;e.isHole?s.push(S,O,P,S,x,O):s.push(S,P,O,S,O,x),b++}}}_closeEnd(e,r,o,i,a,s,l){let u=e.vertexCount,c=new Gt(0,0,l?-1:1).applyMatrix4(a),d=new Gt,p=new eb;for(let h=0;h<u;h++){let m=2*h;d.set(e.vertices[m+0],e.vertices[m+1],0).applyMatrix4(a).add(s),this._insertVertex(i,r+h,d,c,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 i=e.elements,a=new lI().getNormalMatrix(e).elements,s,l,u,c,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],u=f[y+2],c=1/(i[3]*s+i[7]*l+i[11]*u+i[15]),f[y+0]=(i[0]*s+i[4]*l+i[8]*u+i[12])*c,f[y+1]=(i[1]*s+i[5]*l+i[9]*u+i[13])*c,f[y+2]=(i[2]*s+i[6]*l+i[10]*u+i[14])*c,s=h[y+0],l=h[y+1],u=h[y+2],h[y+0]=a[0]*s+a[3]*l+a[6]*u,h[y+1]=a[1]*s+a[4]*l+a[7]*u,h[y+2]=a[2]*s+a[5]*l+a[8]*u}d.needsUpdate=!0,p.needsUpdate=!0}reverseIndicesOnRange(e,r){let o=this.index;if(o){for(let i=e;i<r;i+=3){let a=o.getX(i),s=o.getX(i+1),l=o.getX(i+2);o.setXYZ(i,l,s,a)}o.needsUpdate=!0}}};import{BufferAttribute as ob,BufferGeometry as Pf}from"three";import{mergeBufferGeometries as fI}from"three/examples/jsm/utils/BufferGeometryUtils.js";function nb(){let n=new Pf;return n.setAttribute("position",new ob(new Float32Array([]),3)),n.setIndex(new ob(new Uint16Array([]),1)),n}var hI=nb().attributes,mI=12,yI=1,ja=class extends Pf{constructor(e,r){super();this.charWidths=[];this.charCoords=[];this.wrappedText=[];this.isLowResolution=!1;this.vectorShapes=[];Object.assign(this.attributes,hI),this.userData={parameters:e,type:"TextGeometry"};let o=r.getFont(e.font);o?.isLoaded?(this.font=o,this.update(e)):this.updateFont(e.font,r).then(()=>{this.update(e),r?.requestRender()})}async updateFont(e,r){let o=r.getFont(e);o&&(this.font=o,await o.loadingPromise)}update(e){let r=this.font;if(this.userData={parameters:e,type:"TextGeometry"},!r?.isLoaded){console.warn("Cannot update text because its font is not loaded");return}let{width:o,height:i,depth:a,extrudeBevelSize:s,extrudeBevelSegments:l,text:u,textTransform:c}=e,d=Jc.getDisplayedValue(u),p=c===2?d.toUpperCase():c===3?d.toLowerCase():d,f=gI(e,r,p),{shapes:h,charWidths:m,charCoords:y}=r.generateShapes(f,e),g=(typeof o=="number"?o:1)*.5,b=(typeof i=="number"?i:1)*.5,w=h.map(P=>new He().fromShape(P,!0));this.vectorShapes=w;let A=w.map(P=>dr.create({shape:P,parameters:{depth:a,extrudeBevelSegments:l,extrudeBevelSize:s,windingRule:a<=0?je.NONZERO:je.ODD,subdivisions:this.isLowResolution&&a>0?yI:mI}})),S=A.length?fI(A):nb();S.translate(-g,b,0),this.dispose(),this.wrappedText=f,this.charCoords=y,this.charWidths=m,this.deleteAttribute("extrudeNormal"),Object.entries(S.attributes).forEach(([P,O])=>{this.setAttribute(P,O)}),this.setIndex(S.index),this.computeBoundingSphere()}clone(){let e=rr(new Pf,ja.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){this.font&&await this.font.loadingPromise,await this.update({...this.userData.parameters,text:e})}get text(){return this.userData.parameters.text??""}};function gI(n,t,e){let r=[""],o="";for(let i of e)o+=i,i===" "||i===`
17
17
  `?(r[r.length-1]+=o,o="",i===`
18
- `&&r.push("")):t.getTextWidth(r[r.length-1]+o,n)>n.width&&(r[r.length-1].length&&r.push(""),t.getTextWidth(r[r.length-1]+o,n)>n.width&&(o.length===1?(r[r.length-1]+=o,o=""):(r[r.length-1]+=o.slice(0,-1),o=o[o.length-1],r.push(""))));return r[r.length-1]+=o,r}import{BufferGeometry as Cf,BufferAttribute as lb,Uint32BufferAttribute as Tf,Float32BufferAttribute as Mf,Matrix4 as wI,Vector3 as hl,Sphere as AI,Box3 as _I,BoxGeometry as PI}from"three";var ab,Bu=new Promise(n=>{ab=n}),ib=!1;var Eu;function sb(){if(ib)return;if(Eu)return Eu;async function n(){let e=!1?".":"https://unpkg.com/@splinetool/modelling-wasm@1.0.57/build",o=import("./process.js"),[i,a]=await Promise.all([o,fetch(`${e}/process.wasm`).then(u=>u.arrayBuffer())]),s=i.default,l=await s({wasmBinary:a});ab(l),ib=!0}return Eu=n(),Eu}import{BufferGeometryLoader as xI}from"three";var bI=["font"];function Qo(n,t,e,r){let o,i,a;n.type==="PathGeometry"?(i=JSON.parse(JSON.stringify(n)),a=[[],["extrusion"]]):(i={...n},a=[[]]);for(let u of a){let c=i;for(let d of u)c=c[d];for(o in c){let d=c[o];fp(d)&&!bI.includes(o)&&(c[o]=t.getVariable(d,[r.uuid,"geometry",...u,o]),fp(c[o])&&(c[o]=1))}}let s={parameters:i,type:i.type};if(i.type==="PathGeometry")s.path=i.path;else if(i.type==="VectorGeometry"){let u=He.createFromState(i.shape,i.width,i.height);s.shape=u}else if(i.type==="NonParametricGeometry")i.data.groups&&i.data.groups?.forEach(u=>u.materialIndex=Math.max(u.materialIndex??0,0)),s.geometry=new xI().parse(i);else if(i.type==="SubdivGeometry"){let u=new wt(i,e);return u.data=n,u}else{if(i.type==="TextGeometry")return new ja(i,t);if(i.type==="UIGeometry")return Fa.create({parameters:{width:i.width,height:i.height,cornerRadius:i.cornerRadius,cornerType:i.cornerType}})}let l;try{l=Of(s)}catch(u){console.error(u)}if(!l){let u=He.createFromState(fa.defaultData(),100,100);s.shape=u,l=Of(s)}return l}import{Matrix4 as vI}from"three";var SI=new vI;function fl(n,t,e,r){let o=n.position.array,i=n.normal.array,a=SI.makeScale(t,e,r).invert().elements,s,l,u;for(var c=0,d=o.length;c<d;c+=3)o[c]*=t,o[c+1]*=e,o[c+2]*=r,s=i[c],l=i[c+1],u=i[c+2],i[c]=a[0]*s+a[4]*l+a[8]*u,i[c+1]=a[1]*s+a[5]*l+a[9]*u,i[c+2]=a[2]*s+a[6]*l+a[10]*u;n.position.needsUpdate=!0,n.normal.needsUpdate=!0}var Lu=new _I,Ua=new hl,we;Bu.then(n=>{we=n});var cb=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),ub=new Uint32Array([0,1,2,3]),db=new Uint8Array([4]),wt=class extends Cf{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,i=gn.div(r,o);this.subdividedGeometry&&fl(this.subdividedGeometry.attributes,...i),this.originalGeometry&&fl(this.originalGeometry.attributes,...i),this.data=e;let a=this.userData.parameters;this.userData.parameters={width:a.width*i[0],height:a.height*i[1],depth:a.depth*i[2]},this.originalGeometry.boundingSphere.center.multiply(Ua.fromArray(i));let s=Ua.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}=wt.build(this.data,void 0,!this.flatShading,void 0))}catch{e=new PI(100,100,100),o=0}this.subdivPointer=o,this.originalGeometry=e,this.subdividedGeometry=r??void 0;let i=this.subdividedGeometry??this.originalGeometry;Object.assign(this,i),this.calcBoundingBox()}freeSubdivPointer(){this.subdivPointer&&(wt.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0)}dispose(){super.dispose(),this.freeSubdivPointer()}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new AI,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let r=e.attributes.position,o=e.boundingSphere.center;Lu.setFromBufferAttribute(r),Lu.getCenter(o),e.boundingSphere.radius=o.distanceTo(Lu.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),Lu.getSize(Ua);let i={width:Ua.x,height:Ua.y,depth:Ua.z};return this.userData.parameters=i,i}static build(e,r,o,i){let a,s,l,u=e?.phongAngle??35;o===!1&&(u=-1),r&&(we.free_bvh(r),we.free_subdivision_surface(r));try{a=wt.allocate(e,i)}catch(c){console.error(c,e),a=wt.allocate({positionWASM:cb,indexWASM:ub,verticesPerFaceWASM:db},i)}if(we.set_destination_refinement_level(a,0),s=wt.buildLevel(a,!0,u),e.subdivisions>0)try{we.set_destination_refinement_level(a,e.subdivisions),l=wt.buildLevel(a,!1,u)}catch{try{we.set_destination_refinement_level(a,e.subdivisions-1),l=wt.buildLevel(a,!1,u)}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 i=e.shape!==void 0||e.path!==void 0?r.geometry:Qo(e,o,!1),a;e.type==="TorusGeometry"&&e.arc===Math.PI*2?a=i.getClosedTorusIndicesForBooleanOrSubdiv():a=i.getIndex();let s,l,u,c;({positions:s,triIndices:c}=Ef(i.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:u}=Bf(s,c,i,d),{positions:s,indices:l,verticesPerFace:u}}static allocate(e,r){let o,i,a,s=[],l=[];e.positionWASM&&e.positionWASM.length>0?(o=e.positionWASM,i=e.indexWASM,a=e.verticesPerFaceWASM):(o=cb,i=ub,a=db);let u=o.length,c=i.length,d=a.length,p=o.length+s.length+l.length,f=i.length+a.length,h=p*Float32Array.BYTES_PER_ELEMENT+f*Uint32Array.BYTES_PER_ELEMENT,m=p*Float32Array.BYTES_PER_ELEMENT,y=f*Uint32Array.BYTES_PER_ELEMENT,g=we._malloc(h),b=new Float32Array(we.HEAPF32.buffer,g,p),w=new Uint32Array(we.HEAPU32.buffer,g+m,f);b.set(o,0),b.set(s,o.length),b.set(l,o.length+s.length),w.set(i,0),w.set(a,i.length);let A;e?.scaleBaked?.some(P=>P!==1)&&(A=new wI().makeScale(...e.scaleBaked)),r&&(A?A.premultiply(r):A=r);let S=A?we.alloc_subdivision_surface2(g,u,g+m,c,g+m+i.length*Uint32Array.BYTES_PER_ELEMENT,d,A.elements):we.alloc_subdivision_surface(g,u,g+m,c,g+m+i.length*Uint32Array.BYTES_PER_ELEMENT,d);return we._free(g),S}static buildLevel(e,r,o,i,a){let s=a?we.get_mesh_data2(e,r?we.Level.CONTROL:we.Level.REFINED,o,a.elements):we.get_mesh_data(e,r?we.Level.CONTROL:we.Level.REFINED,o),l=8,u=we.HEAPU32.subarray(s>>2,(s>>2)+l),c=u.subarray(4,4+4),d=0,p=we.HEAPU32[u[d]>>2],f=we.HEAPF32.subarray(p>>2,(p>>2)+c[d]);d++;let h=we.HEAPU32[u[d]>>2],m=we.HEAPF32.subarray(h>>2,(h>>2)+c[d]);d++;let y=we.HEAPU32[u[d]>>2],g=we.HEAPU32.subarray(y>>2,(y>>2)+c[d]);d++;let b=we.HEAPU32[u[d]>>2],w=we.HEAPU32.subarray(b>>2,(b>>2)+c[d]);if(d++,i===void 0){let A=new Cf;if(A.setIndex(new Tf(w,1)),A.setAttribute("position",new Mf(f,3)),A.setAttribute("normal",new Mf(m,3)),r){A.setAttribute("faceMap",new Tf(g,1));let S=new Float32Array(m.length/3*4).fill(0);A.setAttribute("color",new lb(S,4))}return we.free_mesh_data(s),A.userData.type="SubdivGeometry",A}i.getAttribute("position").copyArray(f),i.getAttribute("normal").copyArray(m),i.attributes.position.needsUpdate=!0,i.attributes.normal.needsUpdate=!0,we.free_mesh_data(s)}static freeSubdivPointer(e){we.free_bvh(e),we.free_subdivision_surface(e)}static buildControlCageWireframe(e,r,o){let i=we.get_wireframe_data_for_base_level(e),a=4,s=we.HEAPU32.subarray(i>>2,(i>>2)+a),l=s.subarray(2,2+2),u=0,c=we.HEAPU32[s[u]>>2],d=we.HEAPF32.subarray(c>>2,(c>>2)+l[u]);u++;let p=we.HEAPU32[s[u]>>2],f=we.HEAPU32.subarray(p>>2,(p>>2)+l[u]);if(r===void 0){let h=new Cf;h.setAttribute("position",new Mf(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 lb(m,3)),h.setIndex(new Tf(f,1)),we.free_wireframe_data_for_base_level(i),h}r.getAttribute("position").copyArray(d),r.attributes.position.needsUpdate=!0,we.free_wireframe_data_for_base_level(i)}static updateCollabMesh(e,r,o){let i=r===0;i||we.set_destination_refinement_level(e,r);let a=o?we.get_topological_data2(e,i?we.Level.CONTROL:we.Level.REFINED,o.elements):we.get_topological_data(e,i?we.Level.CONTROL:we.Level.REFINED),s=6,l=we.HEAPU32.subarray(a>>2,(a>>2)+s),u=l.subarray(3,3+3),c=0,d=we.HEAPU32[l[c]>>2],p=new Float32Array(we.HEAPF32.subarray(d>>2,(d>>2)+u[c]));c++;let f=we.HEAPU32[l[c]>>2],h=new Uint32Array(we.HEAPU32.subarray(f>>2,(f>>2)+u[c]));c++;let m=we.HEAPU32[l[c]>>2],y=new Uint8Array(we.HEAPU32.subarray(m>>2,(m>>2)+u[c]));return we.free_topological_data(a),{positions:p,indices:h,verticesPerFace:y}}};var pb=["getX","getY","getZ"];function Ef(n,t){let e={},r=t?t.count:n.count,o=0,i=[],a=[],s=1e4;for(let u=0;u<r;u++){let c=t?t.getX(u):u,d="";for(let p=0;p<3;p++)d+=`${~~(n[pb[p]](c)*s)},`;if(d in e)i.push(e[d]);else{for(let p=0;p<3;p++)a.push(n[pb[p]](c));e[d]=o,i.push(o),o++}}let l=[];for(let u=0;u<i.length;u+=3)i[u]===i[u+1]||i[u]===i[u+2]||i[u+1]===i[u+2]||l.push(i[u],i[u+1],i[u+2]);return{positions:a,triIndices:l}}var Ru=new hl,If=new hl,Nf=new hl,Df=new hl;function Bf(n,t,e,r){let o=[],i=[];if(e.userData.shape!==void 0&&e.userData.parameters.depth===0&&e.userData.shape.shapeHoles.length===0){let l=e.userData.shape.extractShapePointsToFlatArray([]),u=e.userData.parameters.spikes;if(e.userData.type==="EllipseGeometry"&&u<=24&&u%4===0&&e.userData.parameters.angle>=360){let p=l.length/2/u;l=l.filter((f,h)=>Math.floor(h/2)%p===0)}let c=0;for(let p=0;p<l.length;p+=2)c+=(l[p]-l[(p===0?l.length:p)-2])*(l[p+1]+l[(p===0?l.length:p)-1]);n.length=0;let d=0;if(c<0)for(let p=0;p<l.length;p+=2)n.push(l[p],l[p+1],0),o.push(d++);else for(let p=l.length-2;p>=0;p-=2)n.push(l[p],l[p+1],0),o.push(d++);return i.push(d),{indices:o,verticesPerFace:i}}let a=new Float32Array([e.userData.parameters.depth])[0],s=0;for(;s<t.length;){if(e.useNgonForTopBottomFaceDuringBake){let l=0;if((n[t[s]*3+2]===a||n[t[s]*3+2]===0)&&l++,(n[t[s+1]*3+2]===a||n[t[s+1]*3+2]===0)&&l++,(n[t[s+2]*3+2]===a||n[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]){Ru.set(n[t[s]*3],n[t[s]*3+1],n[t[s]*3+2]),If.set(n[t[s+1]*3],n[t[s+1]*3+1],n[t[s+1]*3+2]),Nf.set(n[t[s+4]*3],n[t[s+4]*3+1],n[t[s+4]*3+2]),Df.set(n[t[s+5]*3],n[t[s+5]*3+1],n[t[s+5]*3+2]),If.sub(Ru).normalize(),Nf.sub(Ru).normalize(),Df.sub(Ru).normalize();let l=If.cross(Nf).dot(Df);Math.abs(l)>.005||r&&r.some((u,c)=>c%2===1?!1:s>=r[c]&&s<r[c+1])?(o.push(t[s],t[s+1],t[s+2]),i.push(3),s+=3):(o.push(t[s],t[s+1],t[s+4],t[s+5]),i.push(4),s+=6)}else o.push(t[s],t[s+1],t[s+2]),i.push(3),s+=3}if(e.useNgonForTopBottomFaceDuringBake){let l=[],u=[],c=0;for(let d=0,p=0;d<n.length;d+=3,p++)n[d+2]===0&&(l.push(p),c++),n[d+2]===a&&u.push(p);if(e.userData.parameters.extrudeBevelSize===0){let d=u[0];u[0]=u[1],u[1]=d}l.reverse(),o.push(...l,...u),i.push(c,c)}return{indices:o,verticesPerFace:i}}var Dr={};ew(Dr,{calcBoolean:()=>II,calcBooleanTopological:()=>MI,freeMeshSet:()=>BI,getMeshSet:()=>NI,hasOpenEdges:()=>DI,transformMeshSet:()=>EI});var OI,fb=new Promise(n=>{OI=n});import{Float32BufferAttribute as hb,Sphere as CI}from"three";var Ne,Ha;fb.then(n=>Ne=n);function TI(n,t,e){let r,o;n.userData.parameters.type==="TorusGeometry"&&n.userData.parameters.arc===Math.PI*2?o=n.getClosedTorusIndicesForBooleanOrSubdiv():o=n.getIndex();let{positions:i,triIndices:a}=Ef(n.getAttribute("position"),o),s;if(t&&e){let{indices:l,verticesPerFace:u}=Bf(i,a,n);s=u.length,r=[];for(let c=0,d=0;c<s;c++){r.push(u[c]);for(let p=0;p<u[c];p++)r.push(l[d++])}}else{let l=a.length;r=Array(l+l/3),s=0;for(let u=0,c=0;c<r.length;)r[c++]=3,s++,r[c++]=a[u++],r[c++]=a[u++],r[c++]=a[u++]}return{positions:i,faceIndices:r,nFaces:s}}function mb(n){let t=n.length,e=t*Uint32Array.BYTES_PER_ELEMENT,r=t*Float32Array.BYTES_PER_ELEMENT,o=Number.isInteger(n[0])?e:r,i=Ne._malloc(o);return(Number.isInteger(n[0])?new Uint32Array(Ne.HEAPU32.buffer,i,t):new Float32Array(Ne.HEAPF32.buffer,i,t)).set(n,0),i}function yb(n){switch(n){case 0:return Ne.OP.UNION;case 1:return Ne.OP.INTERSECTION;case 2:return Ne.OP.A_MINUS_B;case 3:return Ne.OP.B_MINUS_A;case 4:return Ne.OP.SYMMETRIC_DIFFERENCE;case 5:return Ne.OP.ALL;default:throw new Error("Unknown boolean operation "+n)}}function MI(n,t){Ha===void 0&&(Ha=Ne.init_csg());let e=mb(n),r=Ne.csg_calc_topological(Ha,e,n.length,yb(t));Ne._free(e);let o=6,i=Ne.HEAPU32.subarray(r>>2,(r>>2)+o),a=i.subarray(3,3+3),s=0,l=Ne.HEAPU32[i[s]>>2],u=new Float32Array(Ne.HEAPF32.subarray(l>>2,(l>>2)+a[s]));s++;let c=Ne.HEAPU32[i[s]>>2],d=new Uint32Array(Ne.HEAPU32.subarray(c>>2,(c>>2)+a[s]));s++;let p=Ne.HEAPU32[i[s]>>2],f=new Uint8Array(Ne.HEAPU32.subarray(p>>2,(p>>2)+a[s]));return Ne.free_mesh_data(r),{positions:u,indices:d,verticesPerFace:f}}function II(n,t,e,r){Ha===void 0&&(Ha=Ne.init_csg());let o=mb(n),i=Ne.csg_calc(Ha,o,n.length,r,yb(t));Ne._free(o);let a=5,s=Ne.HEAPU32.subarray(i>>2,(i>>2)+a),l=s.subarray(2,2+3),u=0,c=Ne.HEAPU32[s[u]>>2],d=Ne.HEAPF32.subarray(c>>2,(c>>2)+l[u]);u++;let p=Ne.HEAPU32[s[u]>>2],f=Ne.HEAPF32.subarray(p>>2,(p>>2)+l[u]);u++;let h=l[u];e.setAttribute("position",new hb(d,3)),e.setAttribute("normal",new hb(f,3));let m=Ne.HEAPF32.subarray((i>>2)+5,(i>>2)+5+6);return e.boundingSphere===null&&(e.boundingSphere=new CI),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},Ne.free_mesh_data(i),h}function NI(n,t,e){if(Ne===void 0)return-1;let r,o,i;if(t&&n.userData.positions!==void 0){let g=n.userData;i=g.verticesPerFace.length,r=g.positions,o=Array(g.verticesPerFace.reduce((b,w)=>b+w,0)+i);for(let b=0,w=0,A=0;b<g.verticesPerFace.length;b++){o[A++]=g.verticesPerFace[b];for(let S=0;S<g.verticesPerFace[b];S++)o[A++]=g.indices[w++]}}else({positions:r,faceIndices:o,nFaces:i}=TI(n,t,e));let a=r.length,s=o.length,l=r.length,u=o.length,c=l*Float32Array.BYTES_PER_ELEMENT+u*Uint32Array.BYTES_PER_ELEMENT,d=l*Float32Array.BYTES_PER_ELEMENT,p=u*Uint32Array.BYTES_PER_ELEMENT,f=Ne._malloc(c),h=new Float32Array(Ne.HEAPF32.buffer,f,l),m=new Uint32Array(Ne.HEAPU32.buffer,f+d,u);h.set(r,0),m.set(o,0);let y=Ne.get_csg_mesh(f,a,f+d,s,i);return Ne._free(f),y}function DI(n){return Ne.has_open_edges(n)}function EI(n,t){Ne.transform_csg_mesh(n,t.elements)}function BI(n){Ne.free_csg_mesh(n)}var LI={ConeGeometry:X0,CubeGeometry:Q0,CylinderGeometry:Y0,DodecahedronGeometry:K0,EllipseGeometry:Ra,HelixGeometry:Nx,IcosahedronGeometry:Dx,LatheGeometry:Ex,NonParametricGeometry:Ux,PolygonGeometry:Iu,PyramidGeometry:Hx,RectangleGeometry:Fa,SphereGeometry:Wx,PlaneGeometry:$x,BackdropGeometry:Yx,StarGeometry:Nu,TextFrameGeometry:Xx,TorusGeometry:Qx,TorusKnotGeometry:Kx,TriangleGeometry:Zx,PathGeometry:rb,VectorGeometry:dr},Of=n=>LI[n.type].create(n);function qa(n){return n!==null&&"booleanOp"in n}var Wa=class extends Ta(VI){constructor(){super(...arguments);this.booleanMeshSetAddress=-1;this.booleanWasTransformed=!1;this.booleanMatrixInvOld=new RI}updateVisible(e){super.updateVisible(e),this.visible=!qa(this.parent)&&this.visible,qa(this.parent)&&this.parent.invalidateDownstreamBooleanData()}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(Dr.freeMeshSet(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}invalidateDownstreamBooleanData(e=!1){return e?this.booleanWasTransformed=!0:this.freeBooleanPointer(),qa(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let e of this.children)e instanceof Wa&&(e.freeBooleanPointer(),qa(e)&&e.invalidateUpstreamBooleanData())}updateTransformState(e,r){let o=super.updateTransformState(e,r);return o&&qa(this.parent)&&this.invalidateDownstreamBooleanData(!0),o}onVariableUpdate(e=!1){super.onVariableUpdate(e),qa(this.parent)&&this.invalidateDownstreamBooleanData(!0)}};var Vu=new zI;function ml(n,t=0,e=n.count,r,o){let i=1/0,a=1/0,s=1/0,l=-1/0,u=-1/0,c=-1/0;for(let d=t;d<e;d++){let p=n.getX(d),f=n.getY(d),h=n.getZ(d);p<i&&(i=p),f<a&&(a=f),h<s&&(s=h),p>l&&(l=p),f>u&&(u=f),h>c&&(c=h)}Vu.min.set(i,a,s),Vu.max.set(l,u,c),Vu.getCenter(r),Vu.getSize(o).multiplyScalar(.5)}var kI=new GI,jI=new FI,Dt=class extends Wa{constructor(t,e){super(kI,jI),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?ml(r,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:r.count,t,e):super.updateEntityBoxSize(t,e)}};import{Box3 as rN,Matrix4 as oN,Sphere as nv,Vector3 as nN}from"three";import{BufferAttribute as J3,Float32BufferAttribute as ov,MathUtils as lh,Vector3 as ch}from"three";import{ShaderMaterial as z3}from"three";import{CubeReflectionMapping as e3,CubeRefractionMapping as t3,CubeUVReflectionMapping as r3,LinearEncoding as Ob,sRGBEncoding as o3}from"three";var yl=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}};import{MathUtils as UI}from"three";var Ft=class{constructor(t){this.hashProperties=void 0;this.isNode=!0;this.shortcuts={};this.uuid=UI.generateUUID(),this.type=t,this.name=""}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,i,a){return""}generate(t,e,r,o,i){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}getHash(){let t="{",e,r;for(e in this)r=this[e],r instanceof Ft&&(t+='"'+e+'":'+r.getHash()+",");if(this.hashProperties)for(let o=0;o<this.hashProperties.length;o++)e=this.hashProperties[o],r=this[e],t+='"'+e+'":"'+String(r)+'",';return t+='"id":"'+this.uuid+'"}',t}};var Lf=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}},Et=new Lf;import{Vector2 as gb}from"three";import{MathUtils as HI}from"three";var ye=class extends Ft{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,i){if(r=r??this.getType(e),this.getShared(e,r)){let a=this.getUnique(e,r);a&&this.uuid===void 0&&(this.uuid=HI.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 u=this.getTemp(e,o);if(u)return e.format(u,l,r);{u=super.generate(e,r,o,s.output,i);let c=this.generate(e,l,o);return e.addNodeCode(u+" = "+c+";"),e.format(u,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,i,a){return this.getShared(e,r)||console.error("TempNode is not shared"),o=o??this.uuid,e.getTempVar(o,i??this.getType(e),a,this.getLabel()).name}};var Xe=class extends ye{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,i,a,s){o=e.getUUID(o??this.getUUID()),i=i??this.getType(e);let l=e.getNodeData(o);return this.getReadonly()&&this.generateReadonly!==void 0?this.generateReadonly(e,r,o,i,a,s):e.isShader("vertex")?(l.vertex||(l.vertex=e.createVertexUniform(i,this,a,s,this.getLabel())),e.format(l.vertex.name,i,r)):(l.fragment||(l.fragment=e.createFragmentUniform(i,this,a,s,this.getLabel())),e.format(l.fragment.name,i,r))}};var pt=class extends Xe{constructor(e=0,r){super("v2");this.nodeType="Vector2";this.value=e instanceof gb?e:new gb(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,i,a,s){return e.format("vec2("+this.value.x+", "+this.value.y+")",i,r)}};import{Vector3 as xb}from"three";var Yt=class extends Xe{constructor(e=0,r,o){super("v3");this.nodeType="Vector3";this.value=e instanceof xb?e:new xb(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,i,a,s){return e.format("vec3("+this.value.x+", "+this.value.y+", "+this.value.z+")",i,r)}};import{Color as qI}from"three";var Bt=class extends qI{constructor(e,r,o,i){super(e,r,o);this.isColorA=!0;this.a=i}setRGBA(e,r,o,i){super.setRGB(e,r,o),this.a=i}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 i,a=o[1],s=o[2];switch(a){case"rgb":case"rgba":if(i=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))return this.a=a==="rgba"?parseFloat(i[4]):1,super.setStyle(e,r);break;case"hsl":case"hsla":if(i=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)%\s*,\s*(\d*\.?\d+)%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))return this.a=a==="hsla"?parseFloat(i[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 pr=class extends Xe{constructor(e){super("v4");this.nodeType="Vector4";this.value=e instanceof Bt?e:new Bt(e.r,e.g,e.b,e.a)}generateReadonly(e,r,o,i,a,s){return e.format("vec4("+this.value.r+", "+this.value.g+", "+this.value.b+", "+this.value.a+")",i,r)}};var WI=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,bb=/[a-z_0-9]+/gi,re=class extends ye{constructor(e,r,o,i,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,i)}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,i,a){let s,l=0,u=this.src;if(this.includes)for(let d=0;d<this.includes.length;d++)e.include(this.includes[d],this);for(let d in this.extensions)e.extensions[d]=!0;let c=[];for(;s=bb.exec(this.src);)c.push(s);for(let d=0;d<c.length;d++){let p=c[d],f=p[0],h=this.isMethod?!this.getInputByName(f):!0,m=f;if(this.keywords[f]||this.useKeywords&&h&&Et.containsKeyword(f)){let y=this.keywords[f];if(!y){let g=Et.getKeywordData(f);g.cache&&(y=e.keywords[f]),y=y||Et.getKeyword(f,e),g.cache&&(e.keywords[f]=y)}m=y.build(e)}f!==m&&u[p.index+l-1]!=="."&&(u=u.substring(0,p.index+l)+m+u.substring(p.index+f.length+l),l+=m.length-f.length),this.getIncludeByName(m)===void 0&&Et.contains(m)&&e.include(Et.get(m))}return r==="source"?u:this.isMethod?(this.isInterface||e.include(this,void 0,u),this.name):e.format("( "+u+" )",this.getType(e),r)}parse(e,r,o,i){if(this.src=e||"",this.includes=r??[],this.extensions=o??{},this.keywords=i??{},this.isMethod){let a=WI.exec(this.src);if(this.inputs=[],a&&a.length==4){this.type=a[1],this.name=a[2];let s=a[3].match(bb);if(s){let l=0;for(;l<s.length;){let u=s[l++],c;u==="in"||u==="out"||u==="inout"?c=s[l++]:(c=u,u="");let d=s[l++];this.inputs.push({name:d,type:c,qualifier:u})}}this.isInterface=this.src.indexOf("{")===-1}else this.type="",this.name=""}}};var $I=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=?\s?(.*?)(\;|$)/i,Rf=class extends ye{constructor(e="",r){super();this.src="";this.useDefine=!1;this.nodeType="Const";this.parse(e||Rf.PI,void 0,void 0,void 0,r)}getType(e){return e.getTypeByFormat(this.type)}parse(e,r,o,i,a){this.src=e||"";let s,l,u="",c=$I.exec(e);this.useDefine=a??this.src.charAt(0)==="#",c&&c.length>1?(l=c[1],s=c[2],u=c[3]):(s=this.src,l="f"),this.name=s,this.type=l,this.value=u}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,i,a){return e.format(this.name,this.getType(e),r)}},Ue=Rf;Ue.PI="PI",Ue.PI2="PI2",Ue.RECIPROCAL_PI="RECIPROCAL_PI",Ue.RECIPROCAL_PI2="RECIPROCAL_PI2",Ue.LOG2="LOG2",Ue.EPSILON="EPSILON";var YI=new RegExp(`^structs*([a-z_0-9]+)s*{s*((.|
18
+ `&&r.push("")):t.getTextWidth(r[r.length-1]+o,n)>n.width&&(r[r.length-1].length&&r.push(""),t.getTextWidth(r[r.length-1]+o,n)>n.width&&(o.length===1?(r[r.length-1]+=o,o=""):(r[r.length-1]+=o.slice(0,-1),o=o[o.length-1],r.push(""))));return r[r.length-1]+=o,r}import{BufferGeometry as Cf,BufferAttribute as lb,Uint32BufferAttribute as Tf,Float32BufferAttribute as Mf,Matrix4 as wI,Vector3 as hl,Sphere as AI,Box3 as _I,BoxGeometry as PI}from"three";var ab,Bu=new Promise(n=>{ab=n}),ib=!1;var Eu;function sb(){if(ib)return;if(Eu)return Eu;async function n(){let e=!1?".":"https://unpkg.com/@splinetool/modelling-wasm@1.0.59/build",o=import("./process.js"),[i,a]=await Promise.all([o,fetch(`${e}/process.wasm`).then(u=>u.arrayBuffer())]),s=i.default,l=await s({wasmBinary:a});ab(l),ib=!0}return Eu=n(),Eu}import{BufferGeometryLoader as xI}from"three";var bI=["font"];function Qo(n,t,e,r){let o,i,a;n.type==="PathGeometry"?(i=JSON.parse(JSON.stringify(n)),a=[[],["extrusion"]]):(i={...n},a=[[]]);for(let u of a){let c=i;for(let d of u)c=c[d];for(o in c){let d=c[o];fp(d)&&!bI.includes(o)&&(c[o]=t.getVariable(d,[r.uuid,"geometry",...u,o]),fp(c[o])&&(c[o]=1))}}let s={parameters:i,type:i.type};if(i.type==="PathGeometry")s.path=i.path;else if(i.type==="VectorGeometry"){let u=He.createFromState(i.shape,i.width,i.height);s.shape=u}else if(i.type==="NonParametricGeometry")i.data.groups&&i.data.groups?.forEach(u=>u.materialIndex=Math.max(u.materialIndex??0,0)),s.geometry=new xI().parse(i);else if(i.type==="SubdivGeometry"){let u=new wt(i,e);return u.data=n,u}else{if(i.type==="TextGeometry")return new ja(i,t);if(i.type==="UIGeometry")return Fa.create({parameters:{width:i.width,height:i.height,cornerRadius:i.cornerRadius,cornerType:i.cornerType}})}let l;try{l=Of(s)}catch(u){console.error(u)}if(!l){let u=He.createFromState(fa.defaultData(),100,100);s.shape=u,l=Of(s)}return l}import{Matrix4 as vI}from"three";var SI=new vI;function fl(n,t,e,r){let o=n.position.array,i=n.normal.array,a=SI.makeScale(t,e,r).invert().elements,s,l,u;for(var c=0,d=o.length;c<d;c+=3)o[c]*=t,o[c+1]*=e,o[c+2]*=r,s=i[c],l=i[c+1],u=i[c+2],i[c]=a[0]*s+a[4]*l+a[8]*u,i[c+1]=a[1]*s+a[5]*l+a[9]*u,i[c+2]=a[2]*s+a[6]*l+a[10]*u;n.position.needsUpdate=!0,n.normal.needsUpdate=!0}var Lu=new _I,Ua=new hl,we;Bu.then(n=>{we=n});var cb=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),ub=new Uint32Array([0,1,2,3]),db=new Uint8Array([4]),wt=class extends Cf{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,i=gn.div(r,o);this.subdividedGeometry&&fl(this.subdividedGeometry.attributes,...i),this.originalGeometry&&fl(this.originalGeometry.attributes,...i),this.data=e;let a=this.userData.parameters;this.userData.parameters={width:a.width*i[0],height:a.height*i[1],depth:a.depth*i[2]},this.originalGeometry.boundingSphere.center.multiply(Ua.fromArray(i));let s=Ua.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}=wt.build(this.data,void 0,!this.flatShading,void 0))}catch{e=new PI(100,100,100),o=0}this.subdivPointer=o,this.originalGeometry=e,this.subdividedGeometry=r??void 0;let i=this.subdividedGeometry??this.originalGeometry;Object.assign(this,i),this.calcBoundingBox()}freeSubdivPointer(){this.subdivPointer&&(wt.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0)}dispose(){super.dispose(),this.freeSubdivPointer()}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new AI,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let r=e.attributes.position,o=e.boundingSphere.center;Lu.setFromBufferAttribute(r),Lu.getCenter(o),e.boundingSphere.radius=o.distanceTo(Lu.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),Lu.getSize(Ua);let i={width:Ua.x,height:Ua.y,depth:Ua.z};return this.userData.parameters=i,i}static build(e,r,o,i){let a,s,l,u=e?.phongAngle??35;o===!1&&(u=-1),r&&(we.free_bvh(r),we.free_subdivision_surface(r));try{a=wt.allocate(e,i)}catch(c){console.error(c,e),a=wt.allocate({positionWASM:cb,indexWASM:ub,verticesPerFaceWASM:db},i)}if(we.set_destination_refinement_level(a,0),s=wt.buildLevel(a,!0,u),e.subdivisions>0)try{we.set_destination_refinement_level(a,e.subdivisions),l=wt.buildLevel(a,!1,u)}catch{try{we.set_destination_refinement_level(a,e.subdivisions-1),l=wt.buildLevel(a,!1,u)}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 i=e.shape!==void 0||e.path!==void 0?r.geometry:Qo(e,o,!1),a;e.type==="TorusGeometry"&&e.arc===Math.PI*2?a=i.getClosedTorusIndicesForBooleanOrSubdiv():a=i.getIndex();let s,l,u,c;({positions:s,triIndices:c}=Ef(i.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:u}=Bf(s,c,i,d),{positions:s,indices:l,verticesPerFace:u}}static allocate(e,r){let o,i,a,s=[],l=[];e.positionWASM&&e.positionWASM.length>0?(o=e.positionWASM,i=e.indexWASM,a=e.verticesPerFaceWASM):(o=cb,i=ub,a=db);let u=o.length,c=i.length,d=a.length,p=o.length+s.length+l.length,f=i.length+a.length,h=p*Float32Array.BYTES_PER_ELEMENT+f*Uint32Array.BYTES_PER_ELEMENT,m=p*Float32Array.BYTES_PER_ELEMENT,y=f*Uint32Array.BYTES_PER_ELEMENT,g=we._malloc(h),b=new Float32Array(we.HEAPF32.buffer,g,p),w=new Uint32Array(we.HEAPU32.buffer,g+m,f);b.set(o,0),b.set(s,o.length),b.set(l,o.length+s.length),w.set(i,0),w.set(a,i.length);let A;e?.scaleBaked?.some(P=>P!==1)&&(A=new wI().makeScale(...e.scaleBaked)),r&&(A?A.premultiply(r):A=r);let S=A?we.alloc_subdivision_surface2(g,u,g+m,c,g+m+i.length*Uint32Array.BYTES_PER_ELEMENT,d,A.elements):we.alloc_subdivision_surface(g,u,g+m,c,g+m+i.length*Uint32Array.BYTES_PER_ELEMENT,d);return we._free(g),S}static buildLevel(e,r,o,i,a){let s=a?we.get_mesh_data2(e,r?we.Level.CONTROL:we.Level.REFINED,o,a.elements):we.get_mesh_data(e,r?we.Level.CONTROL:we.Level.REFINED,o),l=8,u=we.HEAPU32.subarray(s>>2,(s>>2)+l),c=u.subarray(4,4+4),d=0,p=we.HEAPU32[u[d]>>2],f=we.HEAPF32.subarray(p>>2,(p>>2)+c[d]);d++;let h=we.HEAPU32[u[d]>>2],m=we.HEAPF32.subarray(h>>2,(h>>2)+c[d]);d++;let y=we.HEAPU32[u[d]>>2],g=we.HEAPU32.subarray(y>>2,(y>>2)+c[d]);d++;let b=we.HEAPU32[u[d]>>2],w=we.HEAPU32.subarray(b>>2,(b>>2)+c[d]);if(d++,i===void 0){let A=new Cf;if(A.setIndex(new Tf(w,1)),A.setAttribute("position",new Mf(f,3)),A.setAttribute("normal",new Mf(m,3)),r){A.setAttribute("faceMap",new Tf(g,1));let S=new Float32Array(m.length/3*4).fill(0);A.setAttribute("color",new lb(S,4))}return we.free_mesh_data(s),A.userData.type="SubdivGeometry",A}i.getAttribute("position").copyArray(f),i.getAttribute("normal").copyArray(m),i.attributes.position.needsUpdate=!0,i.attributes.normal.needsUpdate=!0,we.free_mesh_data(s)}static freeSubdivPointer(e){we.free_bvh(e),we.free_subdivision_surface(e)}static buildControlCageWireframe(e,r,o){let i=we.get_wireframe_data_for_base_level(e),a=4,s=we.HEAPU32.subarray(i>>2,(i>>2)+a),l=s.subarray(2,2+2),u=0,c=we.HEAPU32[s[u]>>2],d=we.HEAPF32.subarray(c>>2,(c>>2)+l[u]);u++;let p=we.HEAPU32[s[u]>>2],f=we.HEAPU32.subarray(p>>2,(p>>2)+l[u]);if(r===void 0){let h=new Cf;h.setAttribute("position",new Mf(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 lb(m,3)),h.setIndex(new Tf(f,1)),we.free_wireframe_data_for_base_level(i),h}r.getAttribute("position").copyArray(d),r.attributes.position.needsUpdate=!0,we.free_wireframe_data_for_base_level(i)}static updateCollabMesh(e,r,o){let i=r===0;i||we.set_destination_refinement_level(e,r);let a=o?we.get_topological_data2(e,i?we.Level.CONTROL:we.Level.REFINED,o.elements):we.get_topological_data(e,i?we.Level.CONTROL:we.Level.REFINED),s=6,l=we.HEAPU32.subarray(a>>2,(a>>2)+s),u=l.subarray(3,3+3),c=0,d=we.HEAPU32[l[c]>>2],p=new Float32Array(we.HEAPF32.subarray(d>>2,(d>>2)+u[c]));c++;let f=we.HEAPU32[l[c]>>2],h=new Uint32Array(we.HEAPU32.subarray(f>>2,(f>>2)+u[c]));c++;let m=we.HEAPU32[l[c]>>2],y=new Uint8Array(we.HEAPU32.subarray(m>>2,(m>>2)+u[c]));return we.free_topological_data(a),{positions:p,indices:h,verticesPerFace:y}}};var pb=["getX","getY","getZ"];function Ef(n,t){let e={},r=t?t.count:n.count,o=0,i=[],a=[],s=1e4;for(let u=0;u<r;u++){let c=t?t.getX(u):u,d="";for(let p=0;p<3;p++)d+=`${~~(n[pb[p]](c)*s)},`;if(d in e)i.push(e[d]);else{for(let p=0;p<3;p++)a.push(n[pb[p]](c));e[d]=o,i.push(o),o++}}let l=[];for(let u=0;u<i.length;u+=3)i[u]===i[u+1]||i[u]===i[u+2]||i[u+1]===i[u+2]||l.push(i[u],i[u+1],i[u+2]);return{positions:a,triIndices:l}}var Ru=new hl,If=new hl,Nf=new hl,Df=new hl;function Bf(n,t,e,r){let o=[],i=[];if(e.userData.shape!==void 0&&e.userData.parameters.depth===0&&e.userData.shape.shapeHoles.length===0){let l=e.userData.shape.extractShapePointsToFlatArray([]),u=e.userData.parameters.spikes;if(e.userData.type==="EllipseGeometry"&&u<=24&&u%4===0&&e.userData.parameters.angle>=360){let p=l.length/2/u;l=l.filter((f,h)=>Math.floor(h/2)%p===0)}let c=0;for(let p=0;p<l.length;p+=2)c+=(l[p]-l[(p===0?l.length:p)-2])*(l[p+1]+l[(p===0?l.length:p)-1]);n.length=0;let d=0;if(c<0)for(let p=0;p<l.length;p+=2)n.push(l[p],l[p+1],0),o.push(d++);else for(let p=l.length-2;p>=0;p-=2)n.push(l[p],l[p+1],0),o.push(d++);return i.push(d),{indices:o,verticesPerFace:i}}let a=new Float32Array([e.userData.parameters.depth])[0],s=0;for(;s<t.length;){if(e.useNgonForTopBottomFaceDuringBake){let l=0;if((n[t[s]*3+2]===a||n[t[s]*3+2]===0)&&l++,(n[t[s+1]*3+2]===a||n[t[s+1]*3+2]===0)&&l++,(n[t[s+2]*3+2]===a||n[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]){Ru.set(n[t[s]*3],n[t[s]*3+1],n[t[s]*3+2]),If.set(n[t[s+1]*3],n[t[s+1]*3+1],n[t[s+1]*3+2]),Nf.set(n[t[s+4]*3],n[t[s+4]*3+1],n[t[s+4]*3+2]),Df.set(n[t[s+5]*3],n[t[s+5]*3+1],n[t[s+5]*3+2]),If.sub(Ru).normalize(),Nf.sub(Ru).normalize(),Df.sub(Ru).normalize();let l=If.cross(Nf).dot(Df);Math.abs(l)>.005||r&&r.some((u,c)=>c%2===1?!1:s>=r[c]&&s<r[c+1])?(o.push(t[s],t[s+1],t[s+2]),i.push(3),s+=3):(o.push(t[s],t[s+1],t[s+4],t[s+5]),i.push(4),s+=6)}else o.push(t[s],t[s+1],t[s+2]),i.push(3),s+=3}if(e.useNgonForTopBottomFaceDuringBake){let l=[],u=[],c=0;for(let d=0,p=0;d<n.length;d+=3,p++)n[d+2]===0&&(l.push(p),c++),n[d+2]===a&&u.push(p);if(e.userData.parameters.extrudeBevelSize===0){let d=u[0];u[0]=u[1],u[1]=d}l.reverse(),o.push(...l,...u),i.push(c,c)}return{indices:o,verticesPerFace:i}}var Dr={};ew(Dr,{calcBoolean:()=>II,calcBooleanTopological:()=>MI,freeMeshSet:()=>BI,getMeshSet:()=>NI,hasOpenEdges:()=>DI,transformMeshSet:()=>EI});var OI,fb=new Promise(n=>{OI=n});import{Float32BufferAttribute as hb,Sphere as CI}from"three";var Ne,Ha;fb.then(n=>Ne=n);function TI(n,t,e){let r,o;n.userData.parameters.type==="TorusGeometry"&&n.userData.parameters.arc===Math.PI*2?o=n.getClosedTorusIndicesForBooleanOrSubdiv():o=n.getIndex();let{positions:i,triIndices:a}=Ef(n.getAttribute("position"),o),s;if(t&&e){let{indices:l,verticesPerFace:u}=Bf(i,a,n);s=u.length,r=[];for(let c=0,d=0;c<s;c++){r.push(u[c]);for(let p=0;p<u[c];p++)r.push(l[d++])}}else{let l=a.length;r=Array(l+l/3),s=0;for(let u=0,c=0;c<r.length;)r[c++]=3,s++,r[c++]=a[u++],r[c++]=a[u++],r[c++]=a[u++]}return{positions:i,faceIndices:r,nFaces:s}}function mb(n){let t=n.length,e=t*Uint32Array.BYTES_PER_ELEMENT,r=t*Float32Array.BYTES_PER_ELEMENT,o=Number.isInteger(n[0])?e:r,i=Ne._malloc(o);return(Number.isInteger(n[0])?new Uint32Array(Ne.HEAPU32.buffer,i,t):new Float32Array(Ne.HEAPF32.buffer,i,t)).set(n,0),i}function yb(n){switch(n){case 0:return Ne.OP.UNION;case 1:return Ne.OP.INTERSECTION;case 2:return Ne.OP.A_MINUS_B;case 3:return Ne.OP.B_MINUS_A;case 4:return Ne.OP.SYMMETRIC_DIFFERENCE;case 5:return Ne.OP.ALL;default:throw new Error("Unknown boolean operation "+n)}}function MI(n,t){Ha===void 0&&(Ha=Ne.init_csg());let e=mb(n),r=Ne.csg_calc_topological(Ha,e,n.length,yb(t));Ne._free(e);let o=6,i=Ne.HEAPU32.subarray(r>>2,(r>>2)+o),a=i.subarray(3,3+3),s=0,l=Ne.HEAPU32[i[s]>>2],u=new Float32Array(Ne.HEAPF32.subarray(l>>2,(l>>2)+a[s]));s++;let c=Ne.HEAPU32[i[s]>>2],d=new Uint32Array(Ne.HEAPU32.subarray(c>>2,(c>>2)+a[s]));s++;let p=Ne.HEAPU32[i[s]>>2],f=new Uint8Array(Ne.HEAPU32.subarray(p>>2,(p>>2)+a[s]));return Ne.free_mesh_data(r),{positions:u,indices:d,verticesPerFace:f}}function II(n,t,e,r){Ha===void 0&&(Ha=Ne.init_csg());let o=mb(n),i=Ne.csg_calc(Ha,o,n.length,r,yb(t));Ne._free(o);let a=5,s=Ne.HEAPU32.subarray(i>>2,(i>>2)+a),l=s.subarray(2,2+3),u=0,c=Ne.HEAPU32[s[u]>>2],d=Ne.HEAPF32.subarray(c>>2,(c>>2)+l[u]);u++;let p=Ne.HEAPU32[s[u]>>2],f=Ne.HEAPF32.subarray(p>>2,(p>>2)+l[u]);u++;let h=l[u];e.setAttribute("position",new hb(d,3)),e.setAttribute("normal",new hb(f,3));let m=Ne.HEAPF32.subarray((i>>2)+5,(i>>2)+5+6);return e.boundingSphere===null&&(e.boundingSphere=new CI),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},Ne.free_mesh_data(i),h}function NI(n,t,e){if(Ne===void 0)return-1;let r,o,i;if(t&&n.userData.positions!==void 0){let g=n.userData;i=g.verticesPerFace.length,r=g.positions,o=Array(g.verticesPerFace.reduce((b,w)=>b+w,0)+i);for(let b=0,w=0,A=0;b<g.verticesPerFace.length;b++){o[A++]=g.verticesPerFace[b];for(let S=0;S<g.verticesPerFace[b];S++)o[A++]=g.indices[w++]}}else({positions:r,faceIndices:o,nFaces:i}=TI(n,t,e));let a=r.length,s=o.length,l=r.length,u=o.length,c=l*Float32Array.BYTES_PER_ELEMENT+u*Uint32Array.BYTES_PER_ELEMENT,d=l*Float32Array.BYTES_PER_ELEMENT,p=u*Uint32Array.BYTES_PER_ELEMENT,f=Ne._malloc(c),h=new Float32Array(Ne.HEAPF32.buffer,f,l),m=new Uint32Array(Ne.HEAPU32.buffer,f+d,u);h.set(r,0),m.set(o,0);let y=Ne.get_csg_mesh(f,a,f+d,s,i);return Ne._free(f),y}function DI(n){return Ne.has_open_edges(n)}function EI(n,t){Ne.transform_csg_mesh(n,t.elements)}function BI(n){Ne.free_csg_mesh(n)}var LI={ConeGeometry:X0,CubeGeometry:Q0,CylinderGeometry:Y0,DodecahedronGeometry:K0,EllipseGeometry:Ra,HelixGeometry:Nx,IcosahedronGeometry:Dx,LatheGeometry:Ex,NonParametricGeometry:Ux,PolygonGeometry:Iu,PyramidGeometry:Hx,RectangleGeometry:Fa,SphereGeometry:Wx,PlaneGeometry:$x,BackdropGeometry:Yx,StarGeometry:Nu,TextFrameGeometry:Xx,TorusGeometry:Qx,TorusKnotGeometry:Kx,TriangleGeometry:Zx,PathGeometry:rb,VectorGeometry:dr},Of=n=>LI[n.type].create(n);function qa(n){return n!==null&&"booleanOp"in n}var Wa=class extends Ta(VI){constructor(){super(...arguments);this.booleanMeshSetAddress=-1;this.booleanWasTransformed=!1;this.booleanMatrixInvOld=new RI}updateVisible(e){super.updateVisible(e),this.visible=!qa(this.parent)&&this.visible,qa(this.parent)&&this.parent.invalidateDownstreamBooleanData()}freeBooleanPointer(){this.booleanMeshSetAddress!==-1&&(Dr.freeMeshSet(this.booleanMeshSetAddress),this.booleanMeshSetAddress=-1)}invalidateDownstreamBooleanData(e=!1){return e?this.booleanWasTransformed=!0:this.freeBooleanPointer(),qa(this.parent)?this.parent.invalidateDownstreamBooleanData():this}invalidateUpstreamBooleanData(){this.freeBooleanPointer();for(let e of this.children)e instanceof Wa&&(e.freeBooleanPointer(),qa(e)&&e.invalidateUpstreamBooleanData())}updateTransformState(e,r){let o=super.updateTransformState(e,r);return o&&qa(this.parent)&&this.invalidateDownstreamBooleanData(!0),o}onVariableUpdate(e=!1){super.onVariableUpdate(e),qa(this.parent)&&this.invalidateDownstreamBooleanData(!0)}};var Vu=new zI;function ml(n,t=0,e=n.count,r,o){let i=1/0,a=1/0,s=1/0,l=-1/0,u=-1/0,c=-1/0;for(let d=t;d<e;d++){let p=n.getX(d),f=n.getY(d),h=n.getZ(d);p<i&&(i=p),f<a&&(a=f),h<s&&(s=h),p>l&&(l=p),f>u&&(u=f),h>c&&(c=h)}Vu.min.set(i,a,s),Vu.max.set(l,u,c),Vu.getCenter(r),Vu.getSize(o).multiplyScalar(.5)}var kI=new GI,jI=new FI,Dt=class extends Wa{constructor(t,e){super(kI,jI),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?ml(r,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:r.count,t,e):super.updateEntityBoxSize(t,e)}};import{Box3 as rN,Matrix4 as oN,Sphere as nv,Vector3 as nN}from"three";import{BufferAttribute as J3,Float32BufferAttribute as ov,MathUtils as lh,Vector3 as ch}from"three";import{ShaderMaterial as z3}from"three";import{CubeReflectionMapping as e3,CubeRefractionMapping as t3,CubeUVReflectionMapping as r3,LinearEncoding as Ob,sRGBEncoding as o3}from"three";var yl=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}};import{MathUtils as UI}from"three";var Ft=class{constructor(t){this.hashProperties=void 0;this.isNode=!0;this.shortcuts={};this.uuid=UI.generateUUID(),this.type=t,this.name=""}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,i,a){return""}generate(t,e,r,o,i){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}getHash(){let t="{",e,r;for(e in this)r=this[e],r instanceof Ft&&(t+='"'+e+'":'+r.getHash()+",");if(this.hashProperties)for(let o=0;o<this.hashProperties.length;o++)e=this.hashProperties[o],r=this[e],t+='"'+e+'":"'+String(r)+'",';return t+='"id":"'+this.uuid+'"}',t}};var Lf=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}},Et=new Lf;import{Vector2 as gb}from"three";import{MathUtils as HI}from"three";var ye=class extends Ft{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,i){if(r=r??this.getType(e),this.getShared(e,r)){let a=this.getUnique(e,r);a&&this.uuid===void 0&&(this.uuid=HI.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 u=this.getTemp(e,o);if(u)return e.format(u,l,r);{u=super.generate(e,r,o,s.output,i);let c=this.generate(e,l,o);return e.addNodeCode(u+" = "+c+";"),e.format(u,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,i,a){return this.getShared(e,r)||console.error("TempNode is not shared"),o=o??this.uuid,e.getTempVar(o,i??this.getType(e),a,this.getLabel()).name}};var Xe=class extends ye{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,i,a,s){o=e.getUUID(o??this.getUUID()),i=i??this.getType(e);let l=e.getNodeData(o);return this.getReadonly()&&this.generateReadonly!==void 0?this.generateReadonly(e,r,o,i,a,s):e.isShader("vertex")?(l.vertex||(l.vertex=e.createVertexUniform(i,this,a,s,this.getLabel())),e.format(l.vertex.name,i,r)):(l.fragment||(l.fragment=e.createFragmentUniform(i,this,a,s,this.getLabel())),e.format(l.fragment.name,i,r))}};var pt=class extends Xe{constructor(e=0,r){super("v2");this.nodeType="Vector2";this.value=e instanceof gb?e:new gb(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,i,a,s){return e.format("vec2("+this.value.x+", "+this.value.y+")",i,r)}};import{Vector3 as xb}from"three";var Yt=class extends Xe{constructor(e=0,r,o){super("v3");this.nodeType="Vector3";this.value=e instanceof xb?e:new xb(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,i,a,s){return e.format("vec3("+this.value.x+", "+this.value.y+", "+this.value.z+")",i,r)}};import{Color as qI}from"three";var Bt=class extends qI{constructor(e,r,o,i){super(e,r,o);this.isColorA=!0;this.a=i}setRGBA(e,r,o,i){super.setRGB(e,r,o),this.a=i}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 i,a=o[1],s=o[2];switch(a){case"rgb":case"rgba":if(i=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))return this.a=a==="rgba"?parseFloat(i[4]):1,super.setStyle(e,r);break;case"hsl":case"hsla":if(i=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)%\s*,\s*(\d*\.?\d+)%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))return this.a=a==="hsla"?parseFloat(i[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 pr=class extends Xe{constructor(e){super("v4");this.nodeType="Vector4";this.value=e instanceof Bt?e:new Bt(e.r,e.g,e.b,e.a)}generateReadonly(e,r,o,i,a,s){return e.format("vec4("+this.value.r+", "+this.value.g+", "+this.value.b+", "+this.value.a+")",i,r)}};var WI=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,bb=/[a-z_0-9]+/gi,re=class extends ye{constructor(e,r,o,i,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,i)}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,i,a){let s,l=0,u=this.src;if(this.includes)for(let d=0;d<this.includes.length;d++)e.include(this.includes[d],this);for(let d in this.extensions)e.extensions[d]=!0;let c=[];for(;s=bb.exec(this.src);)c.push(s);for(let d=0;d<c.length;d++){let p=c[d],f=p[0],h=this.isMethod?!this.getInputByName(f):!0,m=f;if(this.keywords[f]||this.useKeywords&&h&&Et.containsKeyword(f)){let y=this.keywords[f];if(!y){let g=Et.getKeywordData(f);g.cache&&(y=e.keywords[f]),y=y||Et.getKeyword(f,e),g.cache&&(e.keywords[f]=y)}m=y.build(e)}f!==m&&u[p.index+l-1]!=="."&&(u=u.substring(0,p.index+l)+m+u.substring(p.index+f.length+l),l+=m.length-f.length),this.getIncludeByName(m)===void 0&&Et.contains(m)&&e.include(Et.get(m))}return r==="source"?u:this.isMethod?(this.isInterface||e.include(this,void 0,u),this.name):e.format("( "+u+" )",this.getType(e),r)}parse(e,r,o,i){if(this.src=e||"",this.includes=r??[],this.extensions=o??{},this.keywords=i??{},this.isMethod){let a=WI.exec(this.src);if(this.inputs=[],a&&a.length==4){this.type=a[1],this.name=a[2];let s=a[3].match(bb);if(s){let l=0;for(;l<s.length;){let u=s[l++],c;u==="in"||u==="out"||u==="inout"?c=s[l++]:(c=u,u="");let d=s[l++];this.inputs.push({name:d,type:c,qualifier:u})}}this.isInterface=this.src.indexOf("{")===-1}else this.type="",this.name=""}}};var $I=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=?\s?(.*?)(\;|$)/i,Rf=class extends ye{constructor(e="",r){super();this.src="";this.useDefine=!1;this.nodeType="Const";this.parse(e||Rf.PI,void 0,void 0,void 0,r)}getType(e){return e.getTypeByFormat(this.type)}parse(e,r,o,i,a){this.src=e||"";let s,l,u="",c=$I.exec(e);this.useDefine=a??this.src.charAt(0)==="#",c&&c.length>1?(l=c[1],s=c[2],u=c[3]):(s=this.src,l="f"),this.name=s,this.type=l,this.value=u}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,i,a){return e.format(this.name,this.getType(e),r)}},Ue=Rf;Ue.PI="PI",Ue.PI2="PI2",Ue.RECIPROCAL_PI="RECIPROCAL_PI",Ue.RECIPROCAL_PI2="RECIPROCAL_PI2",Ue.LOG2="LOG2",Ue.EPSILON="EPSILON";var YI=new RegExp(`^structs*([a-z_0-9]+)s*{s*((.|
19
19
  )*?)}`,"gim"),XI=new RegExp("s*(w*?)s*(w*?)(=|;)","gim"),$a=class extends ye{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,i,a){return r==="source"?this.src+";":e.format("( "+this.src+" )",this.getType(e),r)}parse(e=""){this.src=e,this.inputs=[];let r=YI.exec(e);if(r){let o=r[2],i;for(;i=XI.exec(o);)this.inputs.push({type:i[1],name:i[2]});this.name=r[1]}else this.name="";this.type=this.name}};var Ya=class extends ye{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:"",i=e.isShader("vertex")?"uv"+o:"vUv"+o;return e.format(i,this.getType(e),r)}};Et.addKeyword("uv",function(){return new Ya});Et.addKeyword("uv2",function(){return new Ya(1)});import{LinearEncoding as QI,sRGBEncoding as KI}from"three";var ci=class extends ye{constructor(e,r){super("v4");this.nodeType="ColorSpace";this.input=e,this.method=r??ci.LINEAR_TO_LINEAR,this.hashProperties=["method"]}static getEncodingComponents(e){switch(e){case QI:return["Linear"];case KI:return["sRGB"];default:return[]}}generate(e,r){let o=this.input.build(e,"v4"),i=this.getType(e),a=ci.Nodes[this.method],s=e.include(a);if(s===ci.LINEAR_TO_LINEAR)return e.format(o,i,r);if(a.inputs?.length===2){let l=this.factor.build(e,"f");return e.format(s+"( "+o+", "+l+" )",i,r)}else return e.format(s+"( "+o+" )",i,r)}fromEncoding(e){let r=ci.getEncodingComponents(e);this.method="LinearTo"+r[0],this.factor=r[1]}fromDecoding(e){let r=ci.getEncodingComponents(e);this.method=r[0]+"ToLinear",this.factor=r[1]}},nr=ci;nr.Nodes={LinearToLinear:new re(["vec4 LinearToLinear( in vec4 value ) {"," return value;","}"].join(`
20
20
  `)),sRGBToLinear:new re(["vec4 sRGBToLinear( in vec4 value ) {"," return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.w );","}"].join(`
21
21
  `)),LinearTosRGB:new re(["vec4 LinearTosRGB( in vec4 value ) {"," return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.w );","}"].join(`
@@ -1834,7 +1834,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
1834
1834
  vec3 distorted2 = nearby2 + normal * displacementMapTexture(tex, crop, uv, mat, vec2(neighbor_offset)) * intensity;
1835
1835
  displaced_normal = normalize(cross(distorted1 - displaced_position, distorted2 - displaced_position));
1836
1836
  return displaced_position;
1837
- }`,[e,r])}}();var Te={normalRenderTarget:new ir,normalRenderTargetDepth:new ir,transmissionRenderTarget:new ir,aspectRatio:new pt,transmissionSize:new pt(2048,2048),transmissionRenderTargetDepth:new ir,aoRenderTarget:new ir,aoEnabled:new xt,pixelRatioNode:new se(1),resolution:new pt,penumbraSize:new Zr(5,.5),frameIndex:new Be(0),transmissionLod:new Be(2)};for(let n of Object.values(Te))n.isRenderGlobal=!0;var Bb={skiaWasmUrl:"https://unpkg.com/@splinetool/ui-wasm@1.0.57/build/ui.wasm"};var Ko=class extends Ft{constructor(){super("basic");this.nodeType="Basic";this.color=new $e(St),this.shadingAlpha=new se(1),this.shadingBlend=new Be(0),this.previousModelViewMatrix=new Xt,this.previouseProjectionMatrix=new Xt}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:Te.frameIndex}),e.mergeUniform({resolution:Te.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(p3.merge([d3.fog])),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","#include <fog_pars_vertex>","#include <normal_pars_vertex>"].join(`
1837
+ }`,[e,r])}}();var Te={normalRenderTarget:new ir,normalRenderTargetDepth:new ir,transmissionRenderTarget:new ir,aspectRatio:new pt,transmissionSize:new pt(2048,2048),transmissionRenderTargetDepth:new ir,aoRenderTarget:new ir,aoEnabled:new xt,pixelRatioNode:new se(1),resolution:new pt,penumbraSize:new Zr(5,.5),frameIndex:new Be(0),transmissionLod:new Be(2)};for(let n of Object.values(Te))n.isRenderGlobal=!0;var Bb={skiaWasmUrl:"https://unpkg.com/@splinetool/ui-wasm@1.0.59/build/ui.wasm"};var Ko=class extends Ft{constructor(){super("basic");this.nodeType="Basic";this.color=new $e(St),this.shadingAlpha=new se(1),this.shadingBlend=new Be(0),this.previousModelViewMatrix=new Xt,this.previouseProjectionMatrix=new Xt}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:Te.frameIndex}),e.mergeUniform({resolution:Te.resolution}),e.mergeUniform({previousModelViewMatrix:this.previousModelViewMatrix}),e.mergeUniform({previousProjectionMatrix:this.previouseProjectionMatrix}),e.mergeUniform(p3.merge([d3.fog])),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vWPosition;","#include <fog_pars_vertex>","#include <normal_pars_vertex>"].join(`
1838
1838
  `));let i=["#include <beginnormal_vertex>",`
1839
1839
  #if !defined( USE_LAYER_DISPLACE )
1840
1840
  #include <defaultnormal_vertex>
@@ -2236,7 +2236,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
2236
2236
  outgoingLight = spe_blend( diffuseColor, outgoingLight, ${s.result} * ${f}, ${l.result} );
2237
2237
  }
2238
2238
  `),u&&p.push(u.code,`outgoingLight = spe_blend(outgoingLight, ${u.result}, 1.0, SPE_BLENDING_NORMAL);`),c?p.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${c.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(`
2239
- `)}return r}};import{VideoTexture as g3,Texture as x3,CanvasTexture as b3}from"three";var ju=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 Qf=class extends ju{create(t){return URL.createObjectURL(new Blob([t]))}dispose(t,e){URL.revokeObjectURL(e)}},Xf;function zb(n){return typeof n=="string"?n:(Xf||(Xf=new Qf),Xf.load(n))}var Uu=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")}},Hu=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 fs=class extends Uu{constructor(e,r){super(e,r.imageHolderCache);this.data=e;this.shared=r;this.loaded=!1;this.isVideo=!1;this.isCanvas=!1;this._cache={[1e3]:{},[1001]:{},[1002]:{}};this.isVideo=e.type==="video",this.isCanvas=e.nodeName==="CANVAS",this.updateSrc(this.isCanvas?e:e.data)}async updateSrc(e){if(typeof document>"u")return;this.disposeTextures(),this.loaded=!1;let r=()=>{this.loaded=!0;for(let i of Object.values(this._cache))for(let a of Object.values(i))a&&(a.image=this.img,a.needsUpdate=!0);this.shared.requestRender()};if(this.isCanvas)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 i;await new Promise(a=>{o.onloadend=s=>{i=s.target?.result,a(null)}}),this.img.src=i}else this.img.src=e;this.img.onloadeddata=()=>{r()}}else this.img=new Image,this.img.src=zb(e),this.img.onload=r}getTexture(e,r=1008){let o=this._cache[e]?.[r];if(o)return o;{let i;return this.isCanvas&&(i=new b3(this.img,void 0,e,e,void 0,r)),this.isVideo?i=new g3(this.img,void 0,e,e):i=new x3(this.img,void 0,e,e,void 0,r),this.loaded&&(i.needsUpdate=!0),this._cache[e]===void 0&&(this._cache[e]={}),this._cache[e][r]=i,i}}setNeedsUpdate(e){for(let r of Object.values(this._cache))for(let o of Object.values(r))o&&(o.needsUpdate=e)}disposeTextures(){for(let[e,r]of Object.entries(this._cache))for(let[o,i]of Object.entries(r))i?.dispose(),this._cache[e][o]=void 0}dispose(){super.dispose(),this.disposeTextures()}};var _r=class extends fs{};import{Vector2 as Jo,Vector3 as Ao,Vector4 as qu}from"three";function Qt(n,t){return t.color(n)}function Gb(n,t){switch(n.type){case"fresnel":return w3(n,t);case"gradient":return A3(n,t);case"depth":return _3(n,t);case"normal":return P3(n,t);case"noise":return O3(n,t);case"rainbow":return C3(n,t);case"toon":return T3(n,t);case"outline":return M3(n,t);case"transmission":return I3(n,t);case"color":return S3(n,t);case"pattern":return N3(n,t)}}function v3(n){return{type:n.type}}function eo(n,t){let{alpha:e,mode:r,isMask:o}=n,i=typeof e=="string"?(Number(t.getVariable(e))??100)/100:e;return{...v3(n),alpha:i,mode:r,isMask:o}}function S3(n,t){return{...eo(n,t),color:Qt(n.color,t)}}function w3(n,t){let{bias:e,scale:r,intensity:o,factor:i,color:a}=n;return{...eo(n,t),color:Qt(a,t),bias:e,scale:r,intensity:o,factor:i}}function A3(n,t){let{gradientType:e,smooth:r,colors:o,steps:i,angle:a,offset:s,morph:l}=n;return{...eo(n,t),gradientType:e,smooth:r,colors:o.map(u=>new qu(u[0],u[1],u[2],u[3])),num:o.length,steps:i,offset:new Jo(...s),morph:new Jo(...l),angle:a}}function _3(n,t){let{gradientType:e,near:r,far:o,isVector:i,isWorldSpace:a,origin:s,direction:l,colors:u,steps:c,smooth:d}=n;return{...eo(n,t),gradientType:e,near:r,far:o,isVector:i,isWorldSpace:a,origin:new Ao(...s),direction:l?new Ao(...l):new Ao(1,0,0),colors:u.map(p=>p!==void 0?new qu(p[0],p[1],p[2],p[3]):new qu(0,0,0,0)),steps:c.slice(0,u.length),smooth:d}}function P3(n,t){let{cnormal:e}=n;return{...eo(n,t),cnormal:new Ao(e[0],e[1],e[2])}}function O3(n,t){return{...eo(n,t),scale:n.scale,move:n.move,fA:new Jo(...n.fA),fB:new Jo(...n.fB),size:new Ao(...n.size),distortion:new Jo(...n.distortion),colorA:Qt(n.colorA,t),colorB:Qt(n.colorB,t),colorC:Qt(n.colorC,t),colorD:Qt(n.colorD,t),noiseType:n.noiseType,voronoiStyle:n.voronoiStyle,highCut:n.highCut,lowCut:n.lowCut,smoothness:n.smoothness,seed:n.seed,quality:n.quality}}function C3(n,t){return{...eo(n,t),filmThickness:n.filmThickness,movement:n.movement,wavelengths:new Ao(...n.wavelengths),noiseStrength:n.noiseStrength,noiseScale:n.noiseScale,offset:new Ao(...n.offset)}}function T3(n,t){return{...eo(n,t),positioning:n.positioning,colors:n.colors.map(e=>new qu(e[0],e[1],e[2],e[3])),num:n.colors.length,steps:n.steps,source:new Ao(...n.source),isWorldSpace:n.isWorldSpace,noiseStrength:n.noiseStrength,noiseScale:n.noiseScale,shadowColor:Qt(n.shadowColor,t),offset:new Ao(...n.offset)}}function M3(n,t){return{...eo(n,t),outlineColor:Qt(n.outlineColor,t),contourColor:Qt(n.contourColor,t),outlineWidth:n.outlineWidth,contourWidth:n.contourWidth,outlineThreshold:n.outlineThreshold,contourThreshold:n.contourThreshold,outlineSmoothing:n.outlineSmoothing,contourFrequency:n.contourFrequency,contourDirection:new Ao(...n.contourDirection),positionalLines:n.positionalLines,compensation:n.compensation}}function I3(n,t){return{...eo(n,t),thickness:n.thickness,ior:n.ior,roughness:n.roughness}}function N3(n,t){return{...eo(n,t),style:n.style,projection:n.projection,axis:n.axis,blending:n.blending,offset:new Jo(...n.offset),colorA:Qt(n.colorA,t),colorB:Qt(n.colorB,t),frequency:new Jo(...n.frequency),size:n.size,variation:n.variation,smoothness:n.smoothness,zigzag:n.zigzag,rotation:n.rotation,vertical:new Jo(...n.vertical),horizontal:new Jo(...n.horizontal),sides:n.sides}}var Dn=class extends Bt{};import{MathUtils as D3,Vector4 as E3}from"three";var Kf={noise:["noiseType"],texture:["projection","axis","side"],video:["projection","axis","side"],displace:["noiseType"],light:["roughnessMap","bumpMap"],depth:["smooth","isWorldSpace","gradientType","isVector"],pattern:["style","projection","axis"]},Zf={depth:["colors"]};function B3(n,t,e){if(t==="isMask")return!0;let r=Kf[n.type],o=Zf[n.type];if(o!==void 0){let i=n.color;if(o.includes(t)){let a=i[t]?.value?.length;if(a!==void 0&&a!==e.length)return!0}}return r!==void 0?r.includes(t):!1}function Jf(n,t,e){let r=e.uniforms[`f${e.id}_texture`];if(!r)return!1;let o=!1,i=n;if("image"in i){let a=i.image,s=t.image(a),l=r;l.image instanceof _r||l.image.deref(),l.image=s}if("video"in i){let a=i.video,s=t.video(a),l=r;l.image instanceof _r||l.image.deref(),l.image=s}if("wrapping"in i){let a=r;a.wrap=i.wrapping}if("minFilter"in i){let a=r;a.minFilter=i.minFilter}if("rotation"in i&&e.uniforms[`f${e.id}_rotation`])return e.uniforms[`f${e.id}_rotation`].value=i.rotation*D3.DEG2RAD,o;if("repeat"in i||"offset"in i||"rotation"in i){let a="mat",s=e.uniforms[`f${e.id}_${a}`];"repeat"in i&&(s.repeat=i.repeat),"offset"in i&&(s.offset=i.offset),"rotation"in i&&(s.rotation=i.rotation),s.updateMatrix()}return o}function Fb(n,t,e,r){let o=!1;for(let[i,a]of Object.entries(n)){if(i==="bumpMap"||i==="roughnessMap"){o=!0;continue}if(!i||a===void 0)continue;if(eh(i,e,r,t)){i==="visible"&&e.type==="light"&&(o=!0);continue}e.visible=r.visible;let s=e.uniforms[`f${e.id}_${i}`];if(!!s&&!(s instanceof In))switch(o=o||B3(e,i,a),s.constructor){case $e:if(typeof a=="string"){let l=t.getColor(a);l&&(s.value=l);break}else{let l=a;s.value instanceof Dn?s.value=new Bt(l.r,l.g,l.b,l.a):s.setRGBA(l);break}case pr:if(typeof a=="string"){let l=t.getColor(a);l&&(s.value=l);break}else{let l=a;s.value instanceof Dn?s.value=new Bt(l.r,l.g,l.b,l.a):s.value.setRGBA(l.r,l.g,l.b,l.a);break}case pt:{let l=a;s.value.setX(l[0]),s.value.setY(l[1]);break}case Yt:{let l=a;s.value.setX(l[0]),s.value.setY(l[1]),s.value.setZ(l[2]);break}case ir:{Jf(a,t,e);break}case Jr:{s.value=a.map(l=>new E3(...l));break}default:{s.value=a;break}}}return o}var En=(n,t,e)=>Math.max(0,Math.min(1,Number(t.getVariable(typeof n=="number"?n*100:n,e)??100)/100))??1,Po=class{constructor(t,e,r,o,i){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)eh(a,this,r,i)}get type(){return this.data.type}static create(t,e,r,o){if(r.type==="light")return ar.createLigherLayer(t,e,r,o);if(r.type==="texture"||r.type==="video"){let i=r.type==="texture"?o.canvas(r.texture.image)??o.image(r.texture.image):o.video(r.texture.video),a=new di(i,r.texture.wrapping,r.texture.minFilter??1008),s=new Fu(i),l=new ku(r.texture.repeat,r.texture.offset,r.texture.rotation),u=new se(r.crop?1:0),c=new Be(r.projection??0),d=new Be(["x","y","z"].indexOf(r.axis)??0),p=new Be(r.side??0),f=new pt(r.size?new to(r.size[0],r.size[1]):new to(100,100)),h=new se(r.blending??0),m=new se(En(r.alpha,o)),y=new Be(r.mode??0),g=new xt(r.isMask??!1),b=new Nn(a,s,u,c,d,p,f,h,l,m,y,g),w=new qe(b.calpha,"f");return new at(t,e,r,{texture:a,textureSize:s,crop:u,projection:c,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 i=o.image(r.texture.image),a=new di(i,r.texture.wrapping,r.texture.minFilter??1008),s=new se(En(r.alpha,o)),l=new Be(r.mode??0),u=new xt(r.isMask??!1),c=new se(r.texture.rotation??0),d=new is(a,s,l,u,c),p=new qe(d.calpha,"f");return new at(t,e,r,{texture:a,alpha:s,mode:l,isMask:u,rotation:c},d,l,p,u,o)}else if(r.type==="displace")if(r.displacementType==="noise"){let i=new Yt(new _o(...r.offset)),a=new se(r.scale??10),s=new se(r.intensity??8),l=new se(r.movement??1),u=new Be(r.noiseType??0),c=new Be(r.voronoiStyle??0),d=new se(r.smoothness??.5),p=new se(r.seed??0),f=new se(r.highCut??1),h=new se(r.lowCut??0),m=new Be(r.quality??1),y=new ps(s,l,i,c,d,p,f,h,m,a,u);return new _l(t,e,r,{offset:i,scale:a,intensity:s,movement:l,noiseType:u,voronoiStyle:c,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;if(o.path[0]===void 0){if(o.type===0)return"type"in o.props||"category"in o.props||"visible"in o.props?(r.scene.markNeedsUpdateRendererDirty(),!0):Fb(o.props,r.shared,this,e)}else if(o.path[0]==="texture")return"texture"in e||"video"in e?Jf(o.props,r.shared,this):!0;return!1}dispose(){if(L3(this)){let t=this.uniforms[`f${this.id}_texture`];if(!t)return!1;let e=t;e.image instanceof _r||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}},at=class extends Po{constructor(e,r,o,i,a,s,l,u,c){super(e,r,o,i,c);this.params=i;this.color=a;this.mode=s;this.alpha=l;this.isMask=u}},_l=class extends Po{constructor(e,r,o,i,a,s){super(e,r,o,i,s);this.position=a}},ar=class extends Po{constructor(e,r,o,i,a,s){super(e,r,o,a,s);this.node=i}static createLigherLayer(e,r,o,i){let a,s=new se(En(o.alpha,i)),l=new Be(o.mode),u=new se(o.bumpMapIntensity),c=new se(En(o.alphaOverride,i)),d;if(!o.visible)a=new Ko,d={};else if(o.category==="lambert"){a=new vl;let p=new $e(i.color(o.emissive)??0),f=new xt(o.occlusion??!0);d={emissive:p,occlusion:f},a.emissive=p,a.occlusion=f}else if(o.category==="toon"){a=new Al;let p=new se(o.shininess??30),f=new $e(i.color(o.specular)??1118481);d={shininess:p,specular:f},a.shininess=p,a.specular=f}else if(o.category==="physical"){a=new wl;let p=new se(o.roughness??.3),f=new se(o.metalness??0),h=new se(o.reflectivity??.5),m=new xt(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 Sl;let p=new se(o.shininess??30),f=new $e(o.specular!==void 0?i.color(o.specular)??1118481:1118481),h=new xt(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=u,a.alphaOverride=c,d.alpha=a.shadingAlpha,d.mode=a.shadingBlend,d.bumpMapIntensity=a.bumpMapIntensity,d.alphaOverride=a.alphaOverride,new ar(e,r,o,a,d,i)}get category(){return this.node.category}};function L3(n){let t=n instanceof Po?n.type:n;return t==="texture"||t==="video"||t==="displace_map"||t==="matcap"}function Er(n){return{alpha:new se(n.alpha??1),mode:new Be(n.mode??0),isMask:new xt(n.isMask??!1)}}function R3(n,t,e,r,o){switch(n.type){case"color":{let i=new $e(r.color??St),a=Er(r),s=new pi(i,a.alpha),l=new qe(s.calpha,"f");return new at(t,e,n,{color:i,...a},s,a.mode,l,a.isMask,o)}case"fresnel":{let i=new $e(r.color??16777215),a=new se(r.bias??.1),s=new se(r.scale??1),l=new se(r.intensity??2),u=new se(r.factor??1),c=Er(r),d=new xl(i,a,s,l,u,c.alpha,c.mode,c.isMask),p=new qe(d.calpha,"f");return new at(t,e,n,{color:i,bias:a,scale:s,intensity:l,factor:u,...c},d,c.mode,p,c.isMask,o)}case"rainbow":{let i=new se(r.filmThickness??30),a=new se(r.movement??0),s=new Yt(r.wavelengths??new _o(0,0,0)),l=new se(r.noiseStrength??0),u=new se(r.noiseScale??1),c=new Yt(r.offset??new _o(0,0,0)),d=Er(r),p=new cs(i,a,s,l,u,c,d.alpha,d.isMask),f=new qe(p.calpha,"f");return new at(t,e,n,{filmThickness:i,movement:a,wavelengths:s,noiseStrength:l,noiseScale:u,offset:c,...d},p,d.mode,f,d.isMask,o)}case"transmission":{let i=new se(r.thickness??10),a=new se(r.ior??1.5),s=new se(r.roughness??.5),l=Te.transmissionSize,u=Te.transmissionRenderTarget,c=Te.transmissionRenderTargetDepth,d=window.innerWidth,p=window.innerHeight,f=d>=p?new pt(p/d,1):new pt(1,d/p),h=Er(r),m=new ds(i,a,s,l,u,c,f,h.alpha),y=new qe(m.calpha,"f");return new at(t,e,n,{thickness:i,ior:a,roughness:s,aspectRatio:f,...h},m,h.mode,y,h.isMask,o)}case"toon":{let i=new Be(r.positioning??0),a;r.colors?a=new Jr(r.colors.length,r.colors):(a=new Jr(10,new hs(0,0,0,1)),a.value[1]=new hs(1,1,1,1));let s;r.steps?s=new Zr(r.steps.length,r.steps):(s=new Zr(10,1),s.value[0]=0);let l=new Yt(r.source??new _o(0,0,0)),u=new xt(r.isWorldSpace??!0),c=new se(r.noiseStrength??0),d=new se(r.noiseScale??1),p=new pr(r.shadowColor),f=new Yt(r.offset??new _o(0,0,0)),h=Er(r),m=new us(i,a,s,l,u,c,d,p,f,h.alpha),y=new qe(m.calpha,"f");return new at(t,e,n,{positioning:i,colors:a,steps:s,source:l,isWorldSpace:u,noiseStrength:c,noiseScale:d,shadowColor:p,offset:f,...h},m,h.mode,y,h.isMask,o)}case"outline":{let i=new $e(r.outlineColor??16777215),a=new $e(r.contourColor??16777215),s=new se(r.outlineWidth??.1),l=new se(r.contourWidth??.1),u=new se(r.outlineThreshold??.1),c=new se(r.contourThreshold??.1),d=new se(r.outlineSmoothing??.1),p=new se(r.contourFrequency??.1),f=new Yt(r.contourDirection??new _o(0,1,0)),h=new xt(r.positionalLines??!1),m=new xt(r.compensation??!0),y=Te.normalRenderTarget,g=Te.normalRenderTargetDepth,b=Te.pixelRatioNode,w=Te.resolution,A=Er(r),S=new ss(i,a,s,l,u,c,d,p,f,h,m,w,y,g,b,A.alpha),P=new qe(S.calpha,"f");return new at(t,e,n,{outlineColor:i,contourColor:a,outlineWidth:s,contourWidth:l,outlineThreshold:u,contourThreshold:c,outlineSmoothing:d,contourFrequency:p,contourDirection:f,positionalLines:h,compensation:m,...A},S,A.mode,P,A.isMask,o)}case"depth":{let i=new Be(r.gradientType??0),a=new xt(r.smooth??!1),s=new se(r.near??50),l=new se(r.far??200),u=new se(r.isVector??1),c=new se(r.isWorldSpace??0),d=new Yt(r.origin??new _o),p=new Yt(r.direction??new _o),f;r.colors?f=new Jr(r.colors.length,r.colors):(f=new Jr(2,new hs(0,0,0,1)),f.value[1]=new hs(1,1,1,1));let h;r.steps?h=new Zr(r.steps.length,r.steps):(h=new Zr(2,1),h.value[0]=0);let m=Er(r),y=new os(i,a,s,l,u,c,d,p,f,h,m.alpha,m.isMask),g=new qe(y.calpha,"f");return new at(t,e,n,{gradientType:i,smooth:a,near:s,far:l,isVector:u,isWorldSpace:c,origin:d,direction:p,colors:f,steps:h,...m},y,m.mode,g,m.isMask,o)}case"noise":{let i=new se(r.scale??1),a=new Yt(r.size??new _o(100,100,100)),s=new se(r.move??1),l=new pt(r.fA??new to(1.7,9.2)),u=new pt(r.fB??new to(8.3,2.8)),c=new pt(r.distortion??new to(1,1)),d=new pr(r.colorA),p=new pr(r.colorB),f=new pr(r.colorC),h=new pr(r.colorD),m=new Be(r.noiseType??0),y=new Be(r.voronoiStyle??0),g=new se(r.highCut??1),b=new se(r.lowCut??0),w=new se(r.smoothness??.5),A=new se(r.seed??.5),S=new Be(r.quality??1),P=Er(r),O=new as(i,a,s,l,u,c,d,p,f,h,P.alpha,m,P.isMask,y,g,b,w,A,S),x=new qe(O.calpha,"f");return new at(t,e,n,{scale:i,size:a,move:s,fA:l,fB:u,distortion:c,colorA:d,colorB:p,colorC:f,colorD:h,noiseType:m,...P,voronoiStyle:y,highCut:g,lowCut:b,smoothness:w,seed:A,quality:S},O,P.mode,x,P.isMask,o)}case"normal":{let i=new Yt(r.cnormal??new _o(1,1,1)),a=Er(r),s=new es(i,a.alpha),l=new qe(s.calpha,"f");return new at(t,e,n,{cnormal:i,...a},s,a.mode,l,a.isMask,o)}case"gradient":{let i=new Be(r.gradientType??0),a=new xt(r.smooth??!1),s;r.colors?s=new Jr(r.colors.length,r.colors):(s=new Jr(10,new hs(0,0,0,1)),s.value[1]=new hs(1,1,1,1));let l;r.steps?l=new Zr(r.steps.length,r.steps):(l=new Zr(10,1),l.value[0]=0);let u=new pt(r.offset??new to(0,0)),c=new pt(r.morph??new to(0,0)),d=new se(r.angle??0),p=Er(r),f=new ns(i,a,s,l,u,c,d,p.alpha,p.isMask),h=new qe(f.calpha,"f");return new at(t,e,n,{gradientType:i,smooth:a,colors:s,steps:l,offset:u,morph:c,angle:d,...p},f,p.mode,h,p.isMask,o)}case"pattern":{let i=new Be(r.style??0),a=new Be(r.projection??0),s=new Be(["x","y","z"].indexOf(r.axis)??0),l=new se(r.blending??0),u=new pt(r.offset??new to(0,0)),c=new pr(r.colorA),d=new pr(r.colorB),p=new pt(r.frequency??new to(10,10)),f=new se(r.size??.5),h=new se(r.variation??0),m=new se(r.smoothness??.5),y=new se(r.zigzag??0),g=new se(r.rotation??0),b=new pt(r.vertical??new to(0,1)),w=new pt(r.horizontal??new to(0,1)),A=new Be(r.sides??6),S=Er(r),P=new ls(i,a,s,l,u,c,d,p,f,h,m,y,g,b,w,A,S.alpha,S.isMask),O=new qe(P.calpha,"f");return new at(t,e,n,{style:i,projection:a,axis:s,blending:l,offset:u,colorA:c,colorB:d,frequency:p,size:f,variation:h,smoothness:m,zigzag:y,rotation:g,vertical:b,horizontal:w,sides:A,...S},P,S.mode,O,S.isMask,o)}default:{let i=new $e(1,0,0,1),a=Er(r),s=new pi(i,a.alpha),l=new qe(s.calpha,"f");return new at(t,e,n,{color:i,...a},s,a.mode,l,a.isMask,o)}}}function V3(n,t,e,r){let o=Gb(e,r);return R3(e,n,t,o,r)}function eh(n,t,e,r){if(e.type==="displace"&&(n==="intensity"||n==="visible")){let o=t.uniforms[`f${t.id}_intensity`];return o?(o.value=e.intensity*(e.visible?1:0),o):void 0}if(e.type!=="displace"&&(n==="alpha"||n==="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"&&n==="visible"){let i=t.uniforms[`f${t.id}_compensation`];i&&(i.value=e.compensation&&e.visible)}return o}}function Wu(n,t){let e=0,r=n.layers.find(o=>o.data.type==="light");if(r){let o=r.data,i=Number(t.getVariable(o.alphaOverride));if((typeof o.alphaOverride=="string"?i/100:o.alphaOverride)<1)return!0}for(let o of n.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 i=o.data.visible?o.data.alpha:0;if(typeof i=="string"&&(i=Math.max(0,Math.min(1,Number(t.getVariable(i)??100)/100))),i===1&&o.data.type==="depth"||o.data.type==="gradient"){for(let a of o.data.colors)if(a[3]<1){i=a[3];break}}else if(i===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,u=t.color(o.data.colorD).a,c=Math.min(a,Math.min(s,Math.min(l,u)));c<1&&(i=c)}e+=(1-e)*i}}return e<1}var hr=class extends z3{constructor(){super(void 0);this.flatShading=!1;this.needsJitter=!0;this.cacheKey="";this.fog=!0,this.dithering=!0,this.vertexColors=!0,this.transparent=!0}customProgramCacheKey(){return this.cacheKey}},$u=class extends hr{constructor(e,r,o,i){super();this.flatShading=e;this.side=r;this.wireframe=o;this.root=i}updateAfterBuild(){let e=this.root;this.lights=e.lights,this.vertexShader=e.vertexShader,this.fragmentShader=e.fragmentShader,this.defines=e.defines,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){return this.root.getFlavor(e,r,o)}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()}},hi=class extends hr{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.reset0(e,r)}get nodeMaterial(){return this}getFlavor(e,r,o){let i=o?6:(e?3:0)+r;if(i===0)return this;this.flavors===void 0&&(this.flavors=[]),i-=1;let a=this.flavors[i];return a===void 0&&(a=new $u(e,r,o,this),this.flavors[i]=a,a.flatShading=e,a.side=r,a.updateAfterBuild()),a}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){(this.data!==e||o)&&this.reset0(e,r)}reset0(e,r){this.data=e;let o=e.layers??Wt.defaultTwoLayerData("phong").layers;try{this.layers=o.map(i=>Po.create(this.layerIdGen++,i.id,i.data,r.shared))}catch{this.layers=[]}this.layers.reverse(),this.name=e.name??"Untitled Material",this.onUpdate(r.shared),this.transparent=Wu(e,r.shared),this.saveVariableLocations(r)}onVariableUpdate(e,r,o){if(e[0]==="alphaOverride")this.transparent=Wu(this.data,o.shared),this.lightLayer.setValue("alphaOverride",Math.max(0,Math.min(Number(r)/100,1)));else if(e[0]==="layer"){let i=e[1],a=e[2];if(i&&a){let s=this.layers.find(l=>l.uuid===i);s?.hasValue(a)&&(a==="alpha"?(this.transparent=Wu(this.data,o.shared),s.setValue(a,Math.max(0,Math.min(Number(r)/100,1)))):s.setValue(a,r))}}}saveVariableLocations(e){if(!this.allowVariableSaves)return;let r=this.data.layers.find(o=>o.data.type==="light");r&&e.shared.getVariable(r.data.alphaOverride,["material",this.uuid,"alphaOverride"]),this.data.layers.forEach(o=>{"alpha"in o.data&&typeof o.data.alpha=="string"&&e.shared.getVariable(o.data.alpha,["material",this.uuid,"layer",o.id,"alpha"])})}getLayersOfType(e){return this.layers.filter(r=>r.type===e)}getLayerByUuid(e){return this.layers.find(r=>r.uuid===e)}onUpdate(e){this.cacheKey=this.computeCacheKey(),this.lightLayer=this.layers.find(r=>r instanceof ar),this.lightLayer===void 0&&(this.lightLayer=new ar(0,"",{...Pt.defaultData("light","phong"),visible:!1},new Ko,{},e)),this.dispose();for(let r of this.flavors)r&&r.dispose();this.applyTextureMaps(),this.applyMasks(),this.blendColors(),this.blendAfterColors(),this.blendPositions()}applyTextureMaps(){let e=this.layers.find(a=>a instanceof ar);if(!e)return;let r=e.data,o=r.bumpMap,i=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 at&&s.color instanceof Nn&&(s.uuid===o&&(e.node.bumpMap=s.color),s.uuid===i&&(e.node.roughnessMap=s.color))}}updateByOp(e,r,o){if(r!==void 0?this.data=r:r=this.data,this.transparent=Wu(r,o.shared),e.path[0]==="layers"){this.data=r;let i=o.shared,a=e.path[1];if(a===void 0){if(this.layers.reverse(),e.type===4){let s=Po.create(this.layerIdGen++,e.id,e.data,o.shared);this.layers.splice(e.localIndex,0,s),o.scene.markNeedsUpdateRendererDirty()}else if(e.type===5)this.layers.splice(e.localIndex,1)[0].dispose(),o.scene.markNeedsUpdateRendererDirty();else if(e.type===6){let s=this.layers.findIndex(u=>u.uuid===e.id),l=this.layers[s];this.layers.splice(s,1),this.layers.splice(e.localIndex,0,l),o.scene.markNeedsUpdateRendererDirty()}this.layers.reverse(),this.onUpdate(o.shared)}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),u;if(e.type===0&&("alpha"in e.props||"alphaOverride"in e.props)&&("alpha"in e.props?u={...e.props,alpha:En(e.props.alpha,i,["material",this.uuid,"layer",a,"alpha"])}:u={...e.props,alphaOverride:En(e.props.alphaOverride,i,["material",this.uuid,"alphaOverride"])}),s.updateByOp({...e,...u?{props:u}:{},path:e.path.slice(2)},l,o)){let d=Po.create(this.layerIdGen++,a,l,i);this.layers.splice(this.layers.findIndex(p=>p.uuid===a),1,d),this.onUpdate(o.shared)}}}}else this.reset(r,o)}applyMasks(){for(let e=0;e<this.layers.length;++e){let r=this.layers[e];r instanceof at?r.color.mask=void 0:r instanceof ar&&(r.node.mask=void 0)}for(let e=0;e<this.layers.length;++e){let r=this.layers[e];if(r instanceof at&&r.isMask.value&&r.data.visible&&e>0){let o=e-1,i=this.layers[o];i instanceof ar?i.node.mask=new kt(r.color,r.alpha,kt.MUL):i instanceof at&&(i.isMask.value||(i.color.mask=new kt(r.color,r.alpha,kt.MUL)))}}}blendColors(){let e=this.layers.findIndex(o=>o instanceof at),r=this.layers.findIndex(o=>o instanceof ar);if(e!==-1&&e<r){let o=this.layers[e].color;for(let i=e+1;i<r;++i){let a=this.layers[i];if(a instanceof at){if(a.isMask.value)continue;o=new Ja(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 ar);if(this.layers.length>r+1){for(let o=r+1;o<this.layers.length;++o){let i=this.layers[o];if(i instanceof at){if(i.isMask.value)continue;e=new Ja(e,i.color,i.alpha,i.mode)}}this.fragment.afterColor=e}else this.fragment.afterColor=void 0}blendPositions(){let e=this.layers.filter(r=>r instanceof _l);if(e.length>0){let r=e[0].position;for(let o=1;o<e.length;++o)e[o]&&(r=new kt(r,e[o].position,kt.ADD),r=new kt(r,new se(.5).setReadonly(!0),kt.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.build(),e.defines=this.defines,e.uniforms=this.uniforms,e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader,e.extensionDerivatives=this.extensions.derivatives===!0,e.extensionFragDepth=this.extensions.fragDepth===!0,e.extensionDrawBuffers=this.extensions.drawBuffers===!0,e.extensionShaderTextureLOD=this.extensions.shaderTextureLOD===!0}clampUniformsForPreview(e,r){let o=(i,a,s)=>Math.min(Math.max(i,a),s);for(let i of this.layers)if(i.type==="displace"){let a=o(i.uniforms[`f${i.id}_intensity`].value,e,r);i.uniforms[`f${i.id}_intensity`].value=a}}computeCacheKey(){let e="[";for(let{data:r}of this.data.layers)if(r.type==="light")e+=`"${r.visible?r.category.toUpperCase():"Basic"}"`;else{let o=(Kf[r.type]??[]).map(u=>r[u]),i=(Zf[r.type]??[]).map(u=>r[u]?.length??0),a=[...o,...i],s="isMask"in r&&r.isMask,l=`"${r.type}-${r.visible}-${s}"`;a.length?e+=`[${l}, "${a.join('","')}"],`:e+=l}return e=e.slice(0,-1)+"]",e}updateFrame(e){for(let r=0;r<this.updaters.length;++r)e.updateNode(this.updaters[r])}build(){let e=new Ka;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}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 at){let r=e.params.texture;if(r instanceof di&&!r.image.loaded)return!1}return!0}getHash(){let e="{";return e+='"fragment":'+this.fragment.getHash(),e+="}",e}};Object.defineProperties(hr.prototype,{properties:{get:function(){return this.fragment.properties}}});var mi=class extends hi{constructor(t,e,r){super(t,e,!1),this.uuid=r,this.allowVariableSaves=!0,this.saveVariableLocations(e)}};var Hb=Ht(kb());var jb=new Map;function Ub(n){if(typeof n=="string")return n;let t=jb.get(n);return t||(t={url:URL.createObjectURL(new Blob([n]))},jb.set(n,t)),t.url}var yi=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 i;typeof t=="string"?i={src:t}:i={src:Ub(t),format:"wav"},this.sound=new Hb.Howl(i),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()}};import{Box2 as G3,Vector2 as gi,Path as qb,Shape as F3,ShapeUtils as k3,Color as j3}from"three";var Xu=class{constructor(){this.type="ShapePath";this.color=new j3;this.subPaths=[];this.currentPath=null}moveTo(t,e){return this.currentPath=new qb,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,i,a){return this.currentPath?.bezierCurveTo(t,e,r,o,i,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,A=y.x,S=g.x,P=b.x,O=m.y,x=y.y,D=g.y,N=b.y,T=(P-S)*(O-D)-(N-D)*(w-S),I=(A-w)*(O-D)-(x-O)*(w-S),E=(N-D)*(A-w)-(P-S)*(x-O),B=T/E,R=I/E;if(E===0&&T!==0||B<=0||B>=1||R<0||R>1)return null;if(T===0&&E===0){for(let F=0;F<2;F++)if(i(F===0?g:b,m,y),r.loc===e.ORIGIN){let V=F===0?g:b;return{x:V.x,y:V.y,t:r.t}}else if(r.loc===e.BETWEEN){let V=+(w+r.t*(A-w)).toPrecision(10),q=+(O+r.t*(x-O)).toPrecision(10);return{x:V,y:q,t:r.t}}return null}else{for(let q=0;q<2;q++)if(i(q===0?g:b,m,y),r.loc===e.ORIGIN){let k=q===0?g:b;return{x:k.x,y:k.y,t:r.t}}let F=+(w+B*(A-w)).toPrecision(10),V=+(O+B*(x-O)).toPrecision(10);return{x:F,y:V,t:B}}}function i(m,y,g){let b=g.x-y.x,w=g.y-y.y,A=m.x-y.x,S=m.y-y.y,P=b*S-A*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(P<-Number.EPSILON){r.loc=e.LEFT;return}if(P>Number.EPSILON){r.loc=e.RIGHT;return}if(b*A<0||w*S<0){r.loc=e.BEHIND;return}if(Math.sqrt(b*b+w*w)<Math.sqrt(A*A+S*S)){r.loc=e.BEYOND;return}let O;b!==0?O=A/b:O=S/w,r.loc=e.BETWEEN,r.t=O}function a(m,y){let g=[],b=[];for(let w=1;w<m.length;w++){let A=m[w-1],S=m[w];for(let P=1;P<y.length;P++){let O=y[P-1],x=y[P],D=o(A,S,O,x);D!==null&&g.find(N=>N.t<=D.t+Number.EPSILON&&N.t>=D.t-Number.EPSILON)===void 0&&(g.push(D),b.push(new gi(D.x,D.y)))}}return b}function s(m,y,g){let b=new gi;y.getCenter(b);let w=[];return g.forEach(A=>{A.boundingBox.containsPoint(b)&&a(m,A.points).forEach(P=>{w.push({identifier:A.identifier,isCW:A.isCW,point:P})})}),w.sort((A,S)=>A.point.x-S.point.x),w}function l(m,y,g,b,w){(w==null||w==="")&&(w="nonzero");let A=new gi;m.boundingBox.getCenter(A);let S=[new gi(g,A.y),new gi(b,A.y)],P=s(S,m.boundingBox,y);P.sort((I,E)=>I.point.x-E.point.x);let O=[],x=[];P.forEach(I=>{I.identifier===m.identifier?O.push(I):x.push(I)});let D=O[0].point.x,N=[],T=0;for(;T<x.length&&x[T].point.x<D;)N.length>0&&N[N.length-1]===x[T].identifier?N.pop():N.push(x[T].identifier),T++;if(N.push(m.identifier),w==="evenodd"){let I=N.length%2===0,E=N[N.length-2];return{identifier:m.identifier,isHole:I,for:E}}else if(w==="nonzero"){let I=!0,E=null,B=null;for(let R=0;R<N.length;R++){let F=N[R];y[F]&&(I?(B=y[F].isCW,I=!1,E=F):B!==y[F].isCW&&(B=y[F].isCW,I=!0))}return{identifier:m.identifier,isHole:I,for:E}}else console.warn('fill-rule: "'+w+'" is currently not implemented.')}let u=0,c=999999999,d=-999999999,p=[];this.subPaths.forEach(m=>{let y=m.getPoints(),g=-999999999,b=999999999,w=-999999999,A=999999999;for(let S=0;S<y.length;S++){let P=y[S];P.y>g&&(g=P.y),P.y<b&&(b=P.y),P.x>w&&(w=P.x),P.x<A&&(A=P.x)}d<=w&&(d=w+1),c>=A&&(c=A-1),y.length&&p.push({curves:m.curves,points:y,isCW:k3.isClockWise(y),identifier:u++,boundingBox:new G3(new gi(A,b),new gi(w,g))})});let f=p.map(m=>l(m,p,c,d,this.userData?.style.fillRule)),h=[];return p.forEach(m=>{let y=f[m.identifier];if(y&&!y.isHole){let g=new F3;g.curves=m.curves,f.filter(w=>w?.isHole&&w.for===m.identifier).forEach(w=>{if(w){let A=p[w.identifier],S=new qb;S.curves=A.curves,g.holes.push(S)}}),h.push(g)}}),h}};var th=!1,$b,rh=new Promise(n=>{$b=n}),Wb=!1;var Qu;function Yb(){if(th=!0,Wb)return;if(Qu)return Qu;async function n(){let e=await import("./opentype.js");$b(e),Wb=!0}return Qu=n(),Qu}var Pl=class{async load(t,e,r=()=>{}){let{load:o}=await rh;o(t,(i,a)=>{i||!a?r(i??"Something went wrong"):e(a)})}async parse(t){let{parse:e,Bidi:r}=await rh;try{let o=e(t),i=new r,a=s=>o.charToGlyphIndex(s.char);return i.registerModifier("glyphIndex",null,a),i.applyFeatures(o,o.defaultRenderOptions.features),{font:o,bidi:i}}catch(o){console.error(o)}}};async function U3(n){return await(await fetch(n)).arrayBuffer()}var H3=new Pl;async function oh(n){let t,e,r=!1;if(n.url?(t=await U3(n.url),e=n.url,r=n.url.startsWith("/")):n.data&&(t=n.data.buffer.slice(n.data.byteOffset,n.data.byteOffset+n.data.byteLength)),t)if(th){let o=await H3.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}}import{CubicBezierCurve as q3,LineCurve as W3,QuadraticBezierCurve as $3}from"three";function Y3(n,t){return t.state.glyphIndex===n||t.state.fina===n||t.state.medi===n||t.state.init===n}var Ku=class{constructor(t){this._arrayBuffer=new ArrayBuffer(1);this._isLoaded=!1;this._intercepted=!1;this._isUserFont=t.isUserFont??!1,this._loadingPromise=oh(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=oh(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 i=o.tokenizer.tokens,a=[],s=0,l=r.length===i.length;for(let u=0;u<r.length;u++){let c=r[u].index,d=String.fromCharCode(r[u].unicode),p=i[s];if(Y3(c,p)||l)a.push({char:d,index:c,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===c&&(g=!0),s>e.length&&(g=!0);a.push({char:d,index:c,replacements:m,replacementChars:Array.from(f)}),s++}}return a}generateShapes(t,e){if(!this._isLoaded)return;let r=this.font,o=e.fontSize/this.unitsPerEm,i=e.fontSize*e.lineHeight,a=t.map(b=>this.getTextWidth(b,e)),s=e.width,l=this.getCharWidth(`
2239
+ `)}return r}};import{VideoTexture as g3,Texture as x3,CanvasTexture as b3}from"three";var ju=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 Qf=class extends ju{create(t){return URL.createObjectURL(new Blob([t]))}dispose(t,e){URL.revokeObjectURL(e)}},Xf;function zb(n){return typeof n=="string"?n:(Xf||(Xf=new Qf),Xf.load(n))}var Uu=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")}},Hu=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 fs=class extends Uu{constructor(e,r){super(e,r.imageHolderCache);this.data=e;this.shared=r;this.loaded=!1;this.isVideo=!1;this.isCanvas=!1;this._cache={[1e3]:{},[1001]:{},[1002]:{}};this.isVideo=e.type==="video",this.isCanvas=e.nodeName==="CANVAS",this.updateSrc(this.isCanvas?e:e.data)}async updateSrc(e){if(typeof document>"u")return;this.disposeTextures(),this.loaded=!1;let r=()=>{this.loaded=!0;for(let i of Object.values(this._cache))for(let a of Object.values(i))a&&(a.image=this.img,a.needsUpdate=!0);this.shared.requestRender()};if(this.isCanvas)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 i;await new Promise(a=>{o.onloadend=s=>{i=s.target?.result,a(null)}}),this.img.src=i}else this.img.src=e;this.img.onloadeddata=()=>{r()}}else this.img=new Image,this.img.src=zb(e),this.img.onload=r}getTexture(e,r=1008){let o=this._cache[e]?.[r];if(o)return o;{let i;return this.isCanvas&&(i=new b3(this.img,void 0,e,e,void 0,r)),this.isVideo?i=new g3(this.img,void 0,e,e):i=new x3(this.img,void 0,e,e,void 0,r),this.loaded&&(i.needsUpdate=!0),this._cache[e]===void 0&&(this._cache[e]={}),this._cache[e][r]=i,i}}setNeedsUpdate(e){for(let r of Object.values(this._cache))for(let o of Object.values(r))o&&(o.needsUpdate=e)}disposeTextures(){for(let[e,r]of Object.entries(this._cache))for(let[o,i]of Object.entries(r))i?.dispose(),this._cache[e][o]=void 0}dispose(){super.dispose(),this.disposeTextures()}};var _r=class extends fs{};import{Vector2 as Jo,Vector3 as Ao,Vector4 as qu}from"three";function Qt(n,t){return t.color(n)}function Gb(n,t){switch(n.type){case"fresnel":return w3(n,t);case"gradient":return A3(n,t);case"depth":return _3(n,t);case"normal":return P3(n,t);case"noise":return O3(n,t);case"rainbow":return C3(n,t);case"toon":return T3(n,t);case"outline":return M3(n,t);case"transmission":return I3(n,t);case"color":return S3(n,t);case"pattern":return N3(n,t)}}function v3(n){return{type:n.type}}function eo(n,t){let{alpha:e,mode:r,isMask:o}=n,i=typeof e=="string"?(Number(t.getVariable(e))??100)/100:e;return{...v3(n),alpha:i,mode:r,isMask:o}}function S3(n,t){return{...eo(n,t),color:Qt(n.color,t)}}function w3(n,t){let{bias:e,scale:r,intensity:o,factor:i,color:a}=n;return{...eo(n,t),color:Qt(a,t),bias:e,scale:r,intensity:o,factor:i}}function A3(n,t){let{gradientType:e,smooth:r,colors:o,steps:i,angle:a,offset:s,morph:l}=n;return{...eo(n,t),gradientType:e,smooth:r,colors:o.map(u=>new qu(u[0],u[1],u[2],u[3])),num:o.length,steps:i,offset:new Jo(...s),morph:new Jo(...l),angle:a}}function _3(n,t){let{gradientType:e,near:r,far:o,isVector:i,isWorldSpace:a,origin:s,direction:l,colors:u,steps:c,smooth:d}=n;return{...eo(n,t),gradientType:e,near:r,far:o,isVector:i,isWorldSpace:a,origin:new Ao(...s),direction:l?new Ao(...l):new Ao(1,0,0),colors:u.map(p=>p!==void 0?new qu(p[0],p[1],p[2],p[3]):new qu(0,0,0,0)),steps:c.slice(0,u.length),smooth:d}}function P3(n,t){let{cnormal:e}=n;return{...eo(n,t),cnormal:new Ao(e[0],e[1],e[2])}}function O3(n,t){return{...eo(n,t),scale:n.scale,move:n.move,fA:new Jo(...n.fA),fB:new Jo(...n.fB),size:new Ao(...n.size),distortion:new Jo(...n.distortion),colorA:Qt(n.colorA,t),colorB:Qt(n.colorB,t),colorC:Qt(n.colorC,t),colorD:Qt(n.colorD,t),noiseType:n.noiseType,voronoiStyle:n.voronoiStyle,highCut:n.highCut,lowCut:n.lowCut,smoothness:n.smoothness,seed:n.seed,quality:n.quality}}function C3(n,t){return{...eo(n,t),filmThickness:n.filmThickness,movement:n.movement,wavelengths:new Ao(...n.wavelengths),noiseStrength:n.noiseStrength,noiseScale:n.noiseScale,offset:new Ao(...n.offset)}}function T3(n,t){return{...eo(n,t),positioning:n.positioning,colors:n.colors.map(e=>new qu(e[0],e[1],e[2],e[3])),num:n.colors.length,steps:n.steps,source:new Ao(...n.source),isWorldSpace:n.isWorldSpace,noiseStrength:n.noiseStrength,noiseScale:n.noiseScale,shadowColor:Qt(n.shadowColor,t),offset:new Ao(...n.offset)}}function M3(n,t){return{...eo(n,t),outlineColor:Qt(n.outlineColor,t),contourColor:Qt(n.contourColor,t),outlineWidth:n.outlineWidth,contourWidth:n.contourWidth,outlineThreshold:n.outlineThreshold,contourThreshold:n.contourThreshold,outlineSmoothing:n.outlineSmoothing,contourFrequency:n.contourFrequency,contourDirection:new Ao(...n.contourDirection),positionalLines:n.positionalLines,compensation:n.compensation}}function I3(n,t){return{...eo(n,t),thickness:n.thickness,ior:n.ior,roughness:n.roughness}}function N3(n,t){return{...eo(n,t),style:n.style,projection:n.projection,axis:n.axis,blending:n.blending,offset:new Jo(...n.offset),colorA:Qt(n.colorA,t),colorB:Qt(n.colorB,t),frequency:new Jo(...n.frequency),size:n.size,variation:n.variation,smoothness:n.smoothness,zigzag:n.zigzag,rotation:n.rotation,vertical:new Jo(...n.vertical),horizontal:new Jo(...n.horizontal),sides:n.sides}}var Dn=class extends Bt{};import{MathUtils as D3,Vector4 as E3}from"three";var Kf={noise:["noiseType"],texture:["projection","axis","side"],video:["projection","axis","side"],displace:["noiseType"],light:["roughnessMap","bumpMap"],depth:["smooth","isWorldSpace","gradientType","isVector"],pattern:["style","projection","axis"]},Zf={depth:["colors"]};function B3(n,t,e){if(t==="isMask")return!0;let r=Kf[n.type],o=Zf[n.type];if(o!==void 0){let i=n.color;if(o.includes(t)){let a=i[t]?.value?.length;if(a!==void 0&&a!==e.length)return!0}}return r!==void 0?r.includes(t):!1}function Jf(n,t,e){let r=e.uniforms[`f${e.id}_texture`];if(!r)return!1;let o=!1,i=n;if("image"in i){let a=i.image,s=t.image(a),l=r;l.image instanceof _r||l.image.deref(),l.image=s}if("video"in i){let a=i.video,s=t.video(a),l=r;l.image instanceof _r||l.image.deref(),l.image=s}if("wrapping"in i){let a=r;a.wrap=i.wrapping}if("minFilter"in i){let a=r;a.minFilter=i.minFilter}if("rotation"in i&&e.uniforms[`f${e.id}_rotation`])return e.uniforms[`f${e.id}_rotation`].value=(i.rotation??0)*D3.DEG2RAD,o;if("repeat"in i||"offset"in i||"rotation"in i){let a="mat",s=e.uniforms[`f${e.id}_${a}`];"repeat"in i&&(s.repeat=i.repeat),"offset"in i&&(s.offset=i.offset),"rotation"in i&&(s.rotation=i.rotation??0),s.updateMatrix()}return o}function Fb(n,t,e,r){let o=!1;for(let[i,a]of Object.entries(n)){if(i==="bumpMap"||i==="roughnessMap"){o=!0;continue}if(!i||a===void 0)continue;if(eh(i,e,r,t)){i==="visible"&&e.type==="light"&&(o=!0);continue}e.visible=r.visible;let s=e.uniforms[`f${e.id}_${i}`];if(!!s&&!(s instanceof In))switch(o=o||B3(e,i,a),s.constructor){case $e:if(typeof a=="string"){let l=t.getColor(a);l&&(s.value=l);break}else{let l=a;s.value instanceof Dn?s.value=new Bt(l.r,l.g,l.b,l.a):s.setRGBA(l);break}case pr:if(typeof a=="string"){let l=t.getColor(a);l&&(s.value=l);break}else{let l=a;s.value instanceof Dn?s.value=new Bt(l.r,l.g,l.b,l.a):s.value.setRGBA(l.r,l.g,l.b,l.a);break}case pt:{let l=a;s.value.setX(l[0]),s.value.setY(l[1]);break}case Yt:{let l=a;s.value.setX(l[0]),s.value.setY(l[1]),s.value.setZ(l[2]);break}case ir:{Jf(a,t,e);break}case Jr:{s.value=a.map(l=>new E3(...l));break}default:{s.value=a;break}}}return o}var En=(n,t,e)=>Math.max(0,Math.min(1,Number(t.getVariable(typeof n=="number"?n*100:n,e)??100)/100))??1,Po=class{constructor(t,e,r,o,i){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)eh(a,this,r,i)}get type(){return this.data.type}static create(t,e,r,o){if(r.type==="light")return ar.createLigherLayer(t,e,r,o);if(r.type==="texture"||r.type==="video"){let i=r.type==="texture"?o.canvas(r.texture.image)??o.image(r.texture.image):o.video(r.texture.video),a=new di(i,r.texture.wrapping,r.texture.minFilter??1008),s=new Fu(i),l=new ku(r.texture.repeat,r.texture.offset,r.texture.rotation??0),u=new se(r.crop?1:0),c=new Be(r.projection??0),d=new Be(["x","y","z"].indexOf(r.axis)??0),p=new Be(r.side??0),f=new pt(r.size?new to(r.size[0],r.size[1]):new to(100,100)),h=new se(r.blending??0),m=new se(En(r.alpha,o)),y=new Be(r.mode??0),g=new xt(r.isMask??!1),b=new Nn(a,s,u,c,d,p,f,h,l,m,y,g),w=new qe(b.calpha,"f");return new at(t,e,r,{texture:a,textureSize:s,crop:u,projection:c,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 i=o.image(r.texture.image),a=new di(i,r.texture.wrapping,r.texture.minFilter??1008),s=new se(En(r.alpha,o)),l=new Be(r.mode??0),u=new xt(r.isMask??!1),c=new se(r.texture.rotation??0),d=new is(a,s,l,u,c),p=new qe(d.calpha,"f");return new at(t,e,r,{texture:a,alpha:s,mode:l,isMask:u,rotation:c},d,l,p,u,o)}else if(r.type==="displace")if(r.displacementType==="noise"){let i=new Yt(new _o(...r.offset)),a=new se(r.scale??10),s=new se(r.intensity??8),l=new se(r.movement??1),u=new Be(r.noiseType??0),c=new Be(r.voronoiStyle??0),d=new se(r.smoothness??.5),p=new se(r.seed??0),f=new se(r.highCut??1),h=new se(r.lowCut??0),m=new Be(r.quality??1),y=new ps(s,l,i,c,d,p,f,h,m,a,u);return new _l(t,e,r,{offset:i,scale:a,intensity:s,movement:l,noiseType:u,voronoiStyle:c,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;if(o.path[0]===void 0){if(o.type===0)return"type"in o.props||"category"in o.props||"visible"in o.props?(r.scene.markNeedsUpdateRendererDirty(),!0):Fb(o.props,r.shared,this,e)}else if(o.path[0]==="texture")return"texture"in e||"video"in e?Jf(o.props,r.shared,this):!0;return!1}dispose(){if(L3(this)){let t=this.uniforms[`f${this.id}_texture`];if(!t)return!1;let e=t;e.image instanceof _r||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}},at=class extends Po{constructor(e,r,o,i,a,s,l,u,c){super(e,r,o,i,c);this.params=i;this.color=a;this.mode=s;this.alpha=l;this.isMask=u}},_l=class extends Po{constructor(e,r,o,i,a,s){super(e,r,o,i,s);this.position=a}},ar=class extends Po{constructor(e,r,o,i,a,s){super(e,r,o,a,s);this.node=i}static createLigherLayer(e,r,o,i){let a,s=new se(En(o.alpha,i)),l=new Be(o.mode),u=new se(o.bumpMapIntensity),c=new se(En(o.alphaOverride,i)),d;if(!o.visible)a=new Ko,d={};else if(o.category==="lambert"){a=new vl;let p=new $e(i.color(o.emissive)??0),f=new xt(o.occlusion??!0);d={emissive:p,occlusion:f},a.emissive=p,a.occlusion=f}else if(o.category==="toon"){a=new Al;let p=new se(o.shininess??30),f=new $e(i.color(o.specular)??1118481);d={shininess:p,specular:f},a.shininess=p,a.specular=f}else if(o.category==="physical"){a=new wl;let p=new se(o.roughness??.3),f=new se(o.metalness??0),h=new se(o.reflectivity??.5),m=new xt(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 Sl;let p=new se(o.shininess??30),f=new $e(o.specular!==void 0?i.color(o.specular)??1118481:1118481),h=new xt(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=u,a.alphaOverride=c,d.alpha=a.shadingAlpha,d.mode=a.shadingBlend,d.bumpMapIntensity=a.bumpMapIntensity,d.alphaOverride=a.alphaOverride,new ar(e,r,o,a,d,i)}get category(){return this.node.category}};function L3(n){let t=n instanceof Po?n.type:n;return t==="texture"||t==="video"||t==="displace_map"||t==="matcap"}function Er(n){return{alpha:new se(n.alpha??1),mode:new Be(n.mode??0),isMask:new xt(n.isMask??!1)}}function R3(n,t,e,r,o){switch(n.type){case"color":{let i=new $e(r.color??St),a=Er(r),s=new pi(i,a.alpha),l=new qe(s.calpha,"f");return new at(t,e,n,{color:i,...a},s,a.mode,l,a.isMask,o)}case"fresnel":{let i=new $e(r.color??16777215),a=new se(r.bias??.1),s=new se(r.scale??1),l=new se(r.intensity??2),u=new se(r.factor??1),c=Er(r),d=new xl(i,a,s,l,u,c.alpha,c.mode,c.isMask),p=new qe(d.calpha,"f");return new at(t,e,n,{color:i,bias:a,scale:s,intensity:l,factor:u,...c},d,c.mode,p,c.isMask,o)}case"rainbow":{let i=new se(r.filmThickness??30),a=new se(r.movement??0),s=new Yt(r.wavelengths??new _o(0,0,0)),l=new se(r.noiseStrength??0),u=new se(r.noiseScale??1),c=new Yt(r.offset??new _o(0,0,0)),d=Er(r),p=new cs(i,a,s,l,u,c,d.alpha,d.isMask),f=new qe(p.calpha,"f");return new at(t,e,n,{filmThickness:i,movement:a,wavelengths:s,noiseStrength:l,noiseScale:u,offset:c,...d},p,d.mode,f,d.isMask,o)}case"transmission":{let i=new se(r.thickness??10),a=new se(r.ior??1.5),s=new se(r.roughness??.5),l=Te.transmissionSize,u=Te.transmissionRenderTarget,c=Te.transmissionRenderTargetDepth,d=window.innerWidth,p=window.innerHeight,f=d>=p?new pt(p/d,1):new pt(1,d/p),h=Er(r),m=new ds(i,a,s,l,u,c,f,h.alpha),y=new qe(m.calpha,"f");return new at(t,e,n,{thickness:i,ior:a,roughness:s,aspectRatio:f,...h},m,h.mode,y,h.isMask,o)}case"toon":{let i=new Be(r.positioning??0),a;r.colors?a=new Jr(r.colors.length,r.colors):(a=new Jr(10,new hs(0,0,0,1)),a.value[1]=new hs(1,1,1,1));let s;r.steps?s=new Zr(r.steps.length,r.steps):(s=new Zr(10,1),s.value[0]=0);let l=new Yt(r.source??new _o(0,0,0)),u=new xt(r.isWorldSpace??!0),c=new se(r.noiseStrength??0),d=new se(r.noiseScale??1),p=new pr(r.shadowColor),f=new Yt(r.offset??new _o(0,0,0)),h=Er(r),m=new us(i,a,s,l,u,c,d,p,f,h.alpha),y=new qe(m.calpha,"f");return new at(t,e,n,{positioning:i,colors:a,steps:s,source:l,isWorldSpace:u,noiseStrength:c,noiseScale:d,shadowColor:p,offset:f,...h},m,h.mode,y,h.isMask,o)}case"outline":{let i=new $e(r.outlineColor??16777215),a=new $e(r.contourColor??16777215),s=new se(r.outlineWidth??.1),l=new se(r.contourWidth??.1),u=new se(r.outlineThreshold??.1),c=new se(r.contourThreshold??.1),d=new se(r.outlineSmoothing??.1),p=new se(r.contourFrequency??.1),f=new Yt(r.contourDirection??new _o(0,1,0)),h=new xt(r.positionalLines??!1),m=new xt(r.compensation??!0),y=Te.normalRenderTarget,g=Te.normalRenderTargetDepth,b=Te.pixelRatioNode,w=Te.resolution,A=Er(r),S=new ss(i,a,s,l,u,c,d,p,f,h,m,w,y,g,b,A.alpha),P=new qe(S.calpha,"f");return new at(t,e,n,{outlineColor:i,contourColor:a,outlineWidth:s,contourWidth:l,outlineThreshold:u,contourThreshold:c,outlineSmoothing:d,contourFrequency:p,contourDirection:f,positionalLines:h,compensation:m,...A},S,A.mode,P,A.isMask,o)}case"depth":{let i=new Be(r.gradientType??0),a=new xt(r.smooth??!1),s=new se(r.near??50),l=new se(r.far??200),u=new se(r.isVector??1),c=new se(r.isWorldSpace??0),d=new Yt(r.origin??new _o),p=new Yt(r.direction??new _o),f;r.colors?f=new Jr(r.colors.length,r.colors):(f=new Jr(2,new hs(0,0,0,1)),f.value[1]=new hs(1,1,1,1));let h;r.steps?h=new Zr(r.steps.length,r.steps):(h=new Zr(2,1),h.value[0]=0);let m=Er(r),y=new os(i,a,s,l,u,c,d,p,f,h,m.alpha,m.isMask),g=new qe(y.calpha,"f");return new at(t,e,n,{gradientType:i,smooth:a,near:s,far:l,isVector:u,isWorldSpace:c,origin:d,direction:p,colors:f,steps:h,...m},y,m.mode,g,m.isMask,o)}case"noise":{let i=new se(r.scale??1),a=new Yt(r.size??new _o(100,100,100)),s=new se(r.move??1),l=new pt(r.fA??new to(1.7,9.2)),u=new pt(r.fB??new to(8.3,2.8)),c=new pt(r.distortion??new to(1,1)),d=new pr(r.colorA),p=new pr(r.colorB),f=new pr(r.colorC),h=new pr(r.colorD),m=new Be(r.noiseType??0),y=new Be(r.voronoiStyle??0),g=new se(r.highCut??1),b=new se(r.lowCut??0),w=new se(r.smoothness??.5),A=new se(r.seed??.5),S=new Be(r.quality??1),P=Er(r),O=new as(i,a,s,l,u,c,d,p,f,h,P.alpha,m,P.isMask,y,g,b,w,A,S),x=new qe(O.calpha,"f");return new at(t,e,n,{scale:i,size:a,move:s,fA:l,fB:u,distortion:c,colorA:d,colorB:p,colorC:f,colorD:h,noiseType:m,...P,voronoiStyle:y,highCut:g,lowCut:b,smoothness:w,seed:A,quality:S},O,P.mode,x,P.isMask,o)}case"normal":{let i=new Yt(r.cnormal??new _o(1,1,1)),a=Er(r),s=new es(i,a.alpha),l=new qe(s.calpha,"f");return new at(t,e,n,{cnormal:i,...a},s,a.mode,l,a.isMask,o)}case"gradient":{let i=new Be(r.gradientType??0),a=new xt(r.smooth??!1),s;r.colors?s=new Jr(r.colors.length,r.colors):(s=new Jr(10,new hs(0,0,0,1)),s.value[1]=new hs(1,1,1,1));let l;r.steps?l=new Zr(r.steps.length,r.steps):(l=new Zr(10,1),l.value[0]=0);let u=new pt(r.offset??new to(0,0)),c=new pt(r.morph??new to(0,0)),d=new se(r.angle??0),p=Er(r),f=new ns(i,a,s,l,u,c,d,p.alpha,p.isMask),h=new qe(f.calpha,"f");return new at(t,e,n,{gradientType:i,smooth:a,colors:s,steps:l,offset:u,morph:c,angle:d,...p},f,p.mode,h,p.isMask,o)}case"pattern":{let i=new Be(r.style??0),a=new Be(r.projection??0),s=new Be(["x","y","z"].indexOf(r.axis)??0),l=new se(r.blending??0),u=new pt(r.offset??new to(0,0)),c=new pr(r.colorA),d=new pr(r.colorB),p=new pt(r.frequency??new to(10,10)),f=new se(r.size??.5),h=new se(r.variation??0),m=new se(r.smoothness??.5),y=new se(r.zigzag??0),g=new se(r.rotation??0),b=new pt(r.vertical??new to(0,1)),w=new pt(r.horizontal??new to(0,1)),A=new Be(r.sides??6),S=Er(r),P=new ls(i,a,s,l,u,c,d,p,f,h,m,y,g,b,w,A,S.alpha,S.isMask),O=new qe(P.calpha,"f");return new at(t,e,n,{style:i,projection:a,axis:s,blending:l,offset:u,colorA:c,colorB:d,frequency:p,size:f,variation:h,smoothness:m,zigzag:y,rotation:g,vertical:b,horizontal:w,sides:A,...S},P,S.mode,O,S.isMask,o)}default:{let i=new $e(1,0,0,1),a=Er(r),s=new pi(i,a.alpha),l=new qe(s.calpha,"f");return new at(t,e,n,{color:i,...a},s,a.mode,l,a.isMask,o)}}}function V3(n,t,e,r){let o=Gb(e,r);return R3(e,n,t,o,r)}function eh(n,t,e,r){if(e.type==="displace"&&(n==="intensity"||n==="visible")){let o=t.uniforms[`f${t.id}_intensity`];return o?(o.value=e.intensity*(e.visible?1:0),o):void 0}if(e.type!=="displace"&&(n==="alpha"||n==="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"&&n==="visible"){let i=t.uniforms[`f${t.id}_compensation`];i&&(i.value=e.compensation&&e.visible)}return o}}function Wu(n,t){let e=0,r=n.layers.find(o=>o.data.type==="light");if(r){let o=r.data,i=Number(t.getVariable(o.alphaOverride));if((typeof o.alphaOverride=="string"?i/100:o.alphaOverride)<1)return!0}for(let o of n.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 i=o.data.visible?o.data.alpha:0;if(typeof i=="string"&&(i=Math.max(0,Math.min(1,Number(t.getVariable(i)??100)/100))),i===1&&o.data.type==="depth"||o.data.type==="gradient"){for(let a of o.data.colors)if(a[3]<1){i=a[3];break}}else if(i===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,u=t.color(o.data.colorD).a,c=Math.min(a,Math.min(s,Math.min(l,u)));c<1&&(i=c)}e+=(1-e)*i}}return e<1}var hr=class extends z3{constructor(){super(void 0);this.flatShading=!1;this.needsJitter=!0;this.cacheKey="";this.fog=!0,this.dithering=!0,this.vertexColors=!0,this.transparent=!0}customProgramCacheKey(){return this.cacheKey}},$u=class extends hr{constructor(e,r,o,i){super();this.flatShading=e;this.side=r;this.wireframe=o;this.root=i}updateAfterBuild(){let e=this.root;this.lights=e.lights,this.vertexShader=e.vertexShader,this.fragmentShader=e.fragmentShader,this.defines=e.defines,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){return this.root.getFlavor(e,r,o)}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()}},hi=class extends hr{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.reset0(e,r)}get nodeMaterial(){return this}getFlavor(e,r,o){let i=o?6:(e?3:0)+r;if(i===0)return this;this.flavors===void 0&&(this.flavors=[]),i-=1;let a=this.flavors[i];return a===void 0&&(a=new $u(e,r,o,this),this.flavors[i]=a,a.flatShading=e,a.side=r,a.updateAfterBuild()),a}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){(this.data!==e||o)&&this.reset0(e,r)}reset0(e,r){this.data=e;let o=e.layers??Wt.defaultTwoLayerData("phong").layers;try{this.layers=o.map(i=>Po.create(this.layerIdGen++,i.id,i.data,r.shared))}catch{this.layers=[]}this.layers.reverse(),this.name=e.name??"Untitled Material",this.onUpdate(r.shared),this.transparent=Wu(e,r.shared),this.saveVariableLocations(r)}onVariableUpdate(e,r,o){if(e[0]==="alphaOverride")this.transparent=Wu(this.data,o.shared),this.lightLayer.setValue("alphaOverride",Math.max(0,Math.min(Number(r)/100,1)));else if(e[0]==="layer"){let i=e[1],a=e[2];if(i&&a){let s=this.layers.find(l=>l.uuid===i);s?.hasValue(a)&&(a==="alpha"?(this.transparent=Wu(this.data,o.shared),s.setValue(a,Math.max(0,Math.min(Number(r)/100,1)))):s.setValue(a,r))}}}saveVariableLocations(e){if(!this.allowVariableSaves)return;let r=this.data.layers.find(o=>o.data.type==="light");r&&e.shared.getVariable(r.data.alphaOverride,["material",this.uuid,"alphaOverride"]),this.data.layers.forEach(o=>{"alpha"in o.data&&typeof o.data.alpha=="string"&&e.shared.getVariable(o.data.alpha,["material",this.uuid,"layer",o.id,"alpha"])})}getLayersOfType(e){return this.layers.filter(r=>r.type===e)}getLayerByUuid(e){return this.layers.find(r=>r.uuid===e)}onUpdate(e){this.cacheKey=this.computeCacheKey(),this.lightLayer=this.layers.find(r=>r instanceof ar),this.lightLayer===void 0&&(this.lightLayer=new ar(0,"",{...Pt.defaultData("light","phong"),visible:!1},new Ko,{},e)),this.dispose();for(let r of this.flavors)r&&r.dispose();this.applyTextureMaps(),this.applyMasks(),this.blendColors(),this.blendAfterColors(),this.blendPositions()}applyTextureMaps(){let e=this.layers.find(a=>a instanceof ar);if(!e)return;let r=e.data,o=r.bumpMap,i=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 at&&s.color instanceof Nn&&(s.uuid===o&&(e.node.bumpMap=s.color),s.uuid===i&&(e.node.roughnessMap=s.color))}}updateByOp(e,r,o){if(r!==void 0?this.data=r:r=this.data,this.transparent=Wu(r,o.shared),e.path[0]==="layers"){this.data=r;let i=o.shared,a=e.path[1];if(a===void 0){if(this.layers.reverse(),e.type===4){let s=Po.create(this.layerIdGen++,e.id,e.data,o.shared);this.layers.splice(e.localIndex,0,s),o.scene.markNeedsUpdateRendererDirty()}else if(e.type===5)this.layers.splice(e.localIndex,1)[0].dispose(),o.scene.markNeedsUpdateRendererDirty();else if(e.type===6){let s=this.layers.findIndex(u=>u.uuid===e.id),l=this.layers[s];this.layers.splice(s,1),this.layers.splice(e.localIndex,0,l),o.scene.markNeedsUpdateRendererDirty()}this.layers.reverse(),this.onUpdate(o.shared)}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),u;if(e.type===0&&("alpha"in e.props||"alphaOverride"in e.props)&&("alpha"in e.props?u={...e.props,alpha:En(e.props.alpha,i,["material",this.uuid,"layer",a,"alpha"])}:u={...e.props,alphaOverride:En(e.props.alphaOverride,i,["material",this.uuid,"alphaOverride"])}),s.updateByOp({...e,...u?{props:u}:{},path:e.path.slice(2)},l,o)){let d=Po.create(this.layerIdGen++,a,l,i);this.layers.splice(this.layers.findIndex(p=>p.uuid===a),1,d),this.onUpdate(o.shared)}}}}else this.reset(r,o)}applyMasks(){for(let e=0;e<this.layers.length;++e){let r=this.layers[e];r instanceof at?r.color.mask=void 0:r instanceof ar&&(r.node.mask=void 0)}for(let e=0;e<this.layers.length;++e){let r=this.layers[e];if(r instanceof at&&r.isMask.value&&r.data.visible&&e>0){let o=e-1,i=this.layers[o];i instanceof ar?i.node.mask=new kt(r.color,r.alpha,kt.MUL):i instanceof at&&(i.isMask.value||(i.color.mask=new kt(r.color,r.alpha,kt.MUL)))}}}blendColors(){let e=this.layers.findIndex(o=>o instanceof at),r=this.layers.findIndex(o=>o instanceof ar);if(e!==-1&&e<r){let o=this.layers[e].color;for(let i=e+1;i<r;++i){let a=this.layers[i];if(a instanceof at){if(a.isMask.value)continue;o=new Ja(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 ar);if(this.layers.length>r+1){for(let o=r+1;o<this.layers.length;++o){let i=this.layers[o];if(i instanceof at){if(i.isMask.value)continue;e=new Ja(e,i.color,i.alpha,i.mode)}}this.fragment.afterColor=e}else this.fragment.afterColor=void 0}blendPositions(){let e=this.layers.filter(r=>r instanceof _l);if(e.length>0){let r=e[0].position;for(let o=1;o<e.length;++o)e[o]&&(r=new kt(r,e[o].position,kt.ADD),r=new kt(r,new se(.5).setReadonly(!0),kt.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.build(),e.defines=this.defines,e.uniforms=this.uniforms,e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader,e.extensionDerivatives=this.extensions.derivatives===!0,e.extensionFragDepth=this.extensions.fragDepth===!0,e.extensionDrawBuffers=this.extensions.drawBuffers===!0,e.extensionShaderTextureLOD=this.extensions.shaderTextureLOD===!0}clampUniformsForPreview(e,r){let o=(i,a,s)=>Math.min(Math.max(i,a),s);for(let i of this.layers)if(i.type==="displace"){let a=o(i.uniforms[`f${i.id}_intensity`].value,e,r);i.uniforms[`f${i.id}_intensity`].value=a}}computeCacheKey(){let e="[";for(let{data:r}of this.data.layers)if(r.type==="light")e+=`"${r.visible?r.category.toUpperCase():"Basic"}"`;else{let o=(Kf[r.type]??[]).map(u=>r[u]),i=(Zf[r.type]??[]).map(u=>r[u]?.length??0),a=[...o,...i],s="isMask"in r&&r.isMask,l=`"${r.type}-${r.visible}-${s}"`;a.length?e+=`[${l}, "${a.join('","')}"],`:e+=l}return e=e.slice(0,-1)+"]",e}updateFrame(e){for(let r=0;r<this.updaters.length;++r)e.updateNode(this.updaters[r])}build(){let e=new Ka;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}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 at){let r=e.params.texture;if(r instanceof di&&!r.image.loaded)return!1}return!0}getHash(){let e="{";return e+='"fragment":'+this.fragment.getHash(),e+="}",e}};Object.defineProperties(hr.prototype,{properties:{get:function(){return this.fragment.properties}}});var mi=class extends hi{constructor(t,e,r){super(t,e,!1),this.uuid=r,this.allowVariableSaves=!0,this.saveVariableLocations(e)}};var Hb=Ht(kb());var jb=new Map;function Ub(n){if(typeof n=="string")return n;let t=jb.get(n);return t||(t={url:URL.createObjectURL(new Blob([n]))},jb.set(n,t)),t.url}var yi=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 i;typeof t=="string"?i={src:t}:i={src:Ub(t),format:"wav"},this.sound=new Hb.Howl(i),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()}};import{Box2 as G3,Vector2 as gi,Path as qb,Shape as F3,ShapeUtils as k3,Color as j3}from"three";var Xu=class{constructor(){this.type="ShapePath";this.color=new j3;this.subPaths=[];this.currentPath=null}moveTo(t,e){return this.currentPath=new qb,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,i,a){return this.currentPath?.bezierCurveTo(t,e,r,o,i,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,A=y.x,S=g.x,P=b.x,O=m.y,x=y.y,D=g.y,N=b.y,T=(P-S)*(O-D)-(N-D)*(w-S),I=(A-w)*(O-D)-(x-O)*(w-S),E=(N-D)*(A-w)-(P-S)*(x-O),B=T/E,R=I/E;if(E===0&&T!==0||B<=0||B>=1||R<0||R>1)return null;if(T===0&&E===0){for(let F=0;F<2;F++)if(i(F===0?g:b,m,y),r.loc===e.ORIGIN){let V=F===0?g:b;return{x:V.x,y:V.y,t:r.t}}else if(r.loc===e.BETWEEN){let V=+(w+r.t*(A-w)).toPrecision(10),q=+(O+r.t*(x-O)).toPrecision(10);return{x:V,y:q,t:r.t}}return null}else{for(let q=0;q<2;q++)if(i(q===0?g:b,m,y),r.loc===e.ORIGIN){let k=q===0?g:b;return{x:k.x,y:k.y,t:r.t}}let F=+(w+B*(A-w)).toPrecision(10),V=+(O+B*(x-O)).toPrecision(10);return{x:F,y:V,t:B}}}function i(m,y,g){let b=g.x-y.x,w=g.y-y.y,A=m.x-y.x,S=m.y-y.y,P=b*S-A*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(P<-Number.EPSILON){r.loc=e.LEFT;return}if(P>Number.EPSILON){r.loc=e.RIGHT;return}if(b*A<0||w*S<0){r.loc=e.BEHIND;return}if(Math.sqrt(b*b+w*w)<Math.sqrt(A*A+S*S)){r.loc=e.BEYOND;return}let O;b!==0?O=A/b:O=S/w,r.loc=e.BETWEEN,r.t=O}function a(m,y){let g=[],b=[];for(let w=1;w<m.length;w++){let A=m[w-1],S=m[w];for(let P=1;P<y.length;P++){let O=y[P-1],x=y[P],D=o(A,S,O,x);D!==null&&g.find(N=>N.t<=D.t+Number.EPSILON&&N.t>=D.t-Number.EPSILON)===void 0&&(g.push(D),b.push(new gi(D.x,D.y)))}}return b}function s(m,y,g){let b=new gi;y.getCenter(b);let w=[];return g.forEach(A=>{A.boundingBox.containsPoint(b)&&a(m,A.points).forEach(P=>{w.push({identifier:A.identifier,isCW:A.isCW,point:P})})}),w.sort((A,S)=>A.point.x-S.point.x),w}function l(m,y,g,b,w){(w==null||w==="")&&(w="nonzero");let A=new gi;m.boundingBox.getCenter(A);let S=[new gi(g,A.y),new gi(b,A.y)],P=s(S,m.boundingBox,y);P.sort((I,E)=>I.point.x-E.point.x);let O=[],x=[];P.forEach(I=>{I.identifier===m.identifier?O.push(I):x.push(I)});let D=O[0].point.x,N=[],T=0;for(;T<x.length&&x[T].point.x<D;)N.length>0&&N[N.length-1]===x[T].identifier?N.pop():N.push(x[T].identifier),T++;if(N.push(m.identifier),w==="evenodd"){let I=N.length%2===0,E=N[N.length-2];return{identifier:m.identifier,isHole:I,for:E}}else if(w==="nonzero"){let I=!0,E=null,B=null;for(let R=0;R<N.length;R++){let F=N[R];y[F]&&(I?(B=y[F].isCW,I=!1,E=F):B!==y[F].isCW&&(B=y[F].isCW,I=!0))}return{identifier:m.identifier,isHole:I,for:E}}else console.warn('fill-rule: "'+w+'" is currently not implemented.')}let u=0,c=999999999,d=-999999999,p=[];this.subPaths.forEach(m=>{let y=m.getPoints(),g=-999999999,b=999999999,w=-999999999,A=999999999;for(let S=0;S<y.length;S++){let P=y[S];P.y>g&&(g=P.y),P.y<b&&(b=P.y),P.x>w&&(w=P.x),P.x<A&&(A=P.x)}d<=w&&(d=w+1),c>=A&&(c=A-1),y.length&&p.push({curves:m.curves,points:y,isCW:k3.isClockWise(y),identifier:u++,boundingBox:new G3(new gi(A,b),new gi(w,g))})});let f=p.map(m=>l(m,p,c,d,this.userData?.style.fillRule)),h=[];return p.forEach(m=>{let y=f[m.identifier];if(y&&!y.isHole){let g=new F3;g.curves=m.curves,f.filter(w=>w?.isHole&&w.for===m.identifier).forEach(w=>{if(w){let A=p[w.identifier],S=new qb;S.curves=A.curves,g.holes.push(S)}}),h.push(g)}}),h}};var th=!1,$b,rh=new Promise(n=>{$b=n}),Wb=!1;var Qu;function Yb(){if(th=!0,Wb)return;if(Qu)return Qu;async function n(){let e=await import("./opentype.js");$b(e),Wb=!0}return Qu=n(),Qu}var Pl=class{async load(t,e,r=()=>{}){let{load:o}=await rh;o(t,(i,a)=>{i||!a?r(i??"Something went wrong"):e(a)})}async parse(t){let{parse:e,Bidi:r}=await rh;try{let o=e(t),i=new r,a=s=>o.charToGlyphIndex(s.char);return i.registerModifier("glyphIndex",null,a),i.applyFeatures(o,o.defaultRenderOptions.features),{font:o,bidi:i}}catch(o){console.error(o)}}};async function U3(n){return await(await fetch(n)).arrayBuffer()}var H3=new Pl;async function oh(n){let t,e,r=!1;if(n.url?(t=await U3(n.url),e=n.url,r=n.url.startsWith("/")):n.data&&(t=n.data.buffer.slice(n.data.byteOffset,n.data.byteOffset+n.data.byteLength)),t)if(th){let o=await H3.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}}import{CubicBezierCurve as q3,LineCurve as W3,QuadraticBezierCurve as $3}from"three";function Y3(n,t){return t.state.glyphIndex===n||t.state.fina===n||t.state.medi===n||t.state.init===n}var Ku=class{constructor(t){this._arrayBuffer=new ArrayBuffer(1);this._isLoaded=!1;this._intercepted=!1;this._isUserFont=t.isUserFont??!1,this._loadingPromise=oh(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=oh(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 i=o.tokenizer.tokens,a=[],s=0,l=r.length===i.length;for(let u=0;u<r.length;u++){let c=r[u].index,d=String.fromCharCode(r[u].unicode),p=i[s];if(Y3(c,p)||l)a.push({char:d,index:c,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===c&&(g=!0),s>e.length&&(g=!0);a.push({char:d,index:c,replacements:m,replacementChars:Array.from(f)}),s++}}return a}generateShapes(t,e){if(!this._isLoaded)return;let r=this.font,o=e.fontSize/this.unitsPerEm,i=e.fontSize*e.lineHeight,a=t.map(b=>this.getTextWidth(b,e)),s=e.width,l=this.getCharWidth(`
2240
2240
  `,e),u=e.horizontalAlign===1?l:0,c=this.computeSpaceWidthForLine(t,0,e),d=this.getLineInitialOffsetX(a[0],s,e.horizontalAlign,t[0],l),p=this.getLineInitialOffsetY(i,t.length,e.height,o,e.verticalAlign),f=[],h=t.map(b=>[]),m=t.map(b=>[]),y;for(let b=0;b<t.length;b++){let w=t[b],A={features:{liga:!0}},S=[];try{S=r.stringToGlyphs(w,A)}catch(O){console.warn(O)}d=this.getLineInitialOffsetX(a[b],s,e.horizontalAlign,w,l);let P=[];try{P=this.reverseLigaturesTable(r,w,S)}catch(O){console.warn(O)}c=this.computeSpaceWidthForLine(t,b,e);for(let O=0;O<S.length;O++){let x=S[O],D=x.index===0?`
2241
2241
  `:x.unicode?String.fromCharCode(x.unicode):void 0,N=P[O],T=0,I=0;O===0&&e.horizontalAlign===2&&x.leftSideBearing!==void 0&&(I=-x.leftSideBearing*o),y&&(T=r.getKerningValue(x,y)*o),d+=I+T;let E=0;if(D===`
2242
2242
  `)E=u;else if(D===" ")E=c;else{let B=this.createPath(x,o,d,p,e);B&&(E=B.offsetX-(T+I),f.push(B.path))}if(N.replacements.length===1)m[b].push([d,p]),h[b].push(E);else{let B=N.replacements.map(q=>(r.glyphs.get(q).advanceWidth??0)*o),R=B.reduce((q,k)=>q+=k,0),F=B.map(q=>q/R),V=d;for(let q=0;q<F.length;q++){let k=E*F[q];m[b].push([V,p]),h[b].push(k),V+=k}}d+=E,y=x}p-=i}let g=[];for(let b=0,w=f.length;b<w;b++)g.push(...f[b].toShapes());return{shapes:g,charWidths:h,lineWidths:a,charCoords:m}}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,i){return(r===3||r===2)&&o.indexOf(`
@@ -3662,4 +3662,4 @@ end_header
3662
3662
  A = exp(A) * vColor.a;
3663
3663
  gl_FragColor = vec4(color.rgb, A);
3664
3664
  gVelocity = vec4(0.0); // so it is ignored by TAA
3665
- }`,i={covariancesTexture:{type:"t",value:null},centersColorsTexture:{type:"t",value:null},meshIndexIntervals:{value:e},meshMatrixWorldsTexture:{type:"t",value:null},focal:{type:"v2",value:new Un},viewport:{type:"v2",value:new Un},basisViewport:{type:"v2",value:new Un},debugColor:{type:"v3",value:new EE},covariancesTextureSize:{type:"v2",value:new Un(1024,1024)},centersColorsTextureSize:{type:"v2",value:new Un(1024,1024)},orthoZoom:{type:"f",value:-1}};return new HE({uniforms:i,vertexShader:r,fragmentShader:o,transparent:!0,alphaTest:1,blending:kE,depthTest:!0,depthWrite:!1,side:LE})}static buildGeomtery(e){let r=new DE;r.setIndex([0,1,2,0,2,3]);let o=new Float32Array(4*3),i=new NE(o,3);r.setAttribute("position",i),i.setXYZ(0,-1,-1,0),i.setXYZ(1,-1,1,0),i.setXYZ(2,1,1,0),i.setXYZ(3,1,-1,0),i.needsUpdate=!0;let a=new GE().copy(r),s=new Uint32Array(e),l=new zE(s,1,!1);return l.setUsage(RE),a.setAttribute("splatIndex",l),a.instanceCount=e,a}resetLocalSplatDataAndTexturesFromSplatBuffer(){this.updateLocalSplatDataFromSplatBuffer(),this.allocateAndStoreLocalSplatDataInTextures()}updateLocalSplatDataFromSplatBuffer(){this.splatBuffers.forEach(i=>i.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 i of this.splatBuffers){let a=i.nsplats;this.colors.subarray(e,e+a*4).set(i.colorsA),e+=a*4,this.centers.subarray(r,r+a*3).set(i.decoded.xyz.denormDequant().data),r+=a*3,this.covariances.subarray(o,o+a*6).set(new Float32Array(i.precomputedCovarianceBufferData)),o+=a*6}}allocateAndStoreLocalSplatDataInTextures(){let o=this.splatCount,i=new Un(4096,1024);for(;i.x*i.y*2<o*6;)i.y*=2;let a=new Un(4096,1024);for(;a.x*a.y*4<o*4;)a.y*=2;let s,l;if(this.halfPrecisionCovariancesOnGPU){l=new Uint16Array(i.x*i.y*2);for(let h=0;h<this.covariances.length;h++)l[h]=BE.toHalfFloat(this.covariances[h]);s=new Md(l,i.x,i.y,m1,VE)}else l=new Float32Array(i.x*i.y*2),l.set(this.covariances),s=new Md(l,i.x,i.y,m1,h1);s.needsUpdate=!0,this.material.uniforms.covariancesTexture.value=s,this.material.uniforms.covariancesTextureSize.value.copy(i);let u=new Uint32Array(a.x*a.y*4);for(let h=0;h<o;h++){let m=h*4,y=h*3,g=h*4;u[g]=f1(this.colors[m],this.colors[m+1],this.colors[m+2],this.colors[m+3]),u[g+1]=Td(this.centers[y]),u[g+2]=Td(this.centers[y+1]),u[g+3]=Td(this.centers[y+2])}let c=new Md(u,a.x,a.y,UE,qE);c.internalFormat="RGBA32UI",c.needsUpdate=!0,this.material.uniforms.centersColorsTexture.value=c,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 Md(p,d,1,jE,h1);f.needsUpdate=!0,this.material.uniforms.meshMatrixWorldsTexture.value=f,this.material.uniformsNeedUpdate=!0,this.splatDataTextures={covariances:{data:l,texture:s,size:i},centerColors:{data:u,texture:c,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,i){this.splatCount>0&&(Id.set(e.x*this.devicePixelRatio,e.y*this.devicePixelRatio),this.material.uniforms.viewport.value.copy(Id),this.material.uniforms.basisViewport.value.set(2/Id.x,2/Id.y),this.material.uniforms.focal.value.set(r,o),this.material.uniforms.orthoZoom.value=i,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())}};var kl=class{constructor(t={}){Lt(this,"updateSplatMeshUniforms",function(){let t=new $E;return function(){if(this.splatMesh===null)return;this.splatMesh.getSplatCount()>0&&(this.renderer.getSize(t),this.cameraFocalLengthX=this.camera.projectionMatrix.elements[0]*this.devicePixelRatio*t.x*.45,this.cameraFocalLengthY=this.camera.projectionMatrix.elements[5]*this.devicePixelRatio*t.y*.45,this.splatMesh.updateUniforms(t,this.cameraFocalLengthX,this.cameraFocalLengthY,this.camera.isPerspectiveCamera?-1:this.camera.zoom*this.devicePixelRatio))}}());Lt(this,"updateView",function(){let t=new WE,e=[],r=new Bs(0,0,-1),o=new Bs(0,0,-1),i=new Bs,a=new Bs;return function(s=!1){let l=this.updateMatrixWorldsInWorkerIfNeeded(),u=this.cropsChanged();if(!s){o.set(0,0,-1).applyQuaternion(this.camera.quaternion);let d=!1,p=!1;if(o.dot(r)<=.95&&(d=!0),a.copy(this.camera.position).sub(i).length()>=1&&(p=!0),!d&&!p&&!l&&!u)return}i.copy(this.camera.position),r.copy(o),t.copy(this.camera.matrixWorld).invert(),t.premultiply(this.camera.perspCamera.projectionMatrix),e[0]=this.camera.position.x,e[1]=this.camera.position.y,e[2]=this.camera.position.z;let c={sort:{view:t.elements,cameraPosition:e,splatRenderCount:this.splatRenderCount,splatSortCount:this.splatRenderCount},...l?{newMatrixWorlds:this.meshMatrixWorlds}:{},...u?{newCropsArray:this.cropsArray}:{}};this.sortRunning?this.queuedMessage=c:(this.queuedMessage=null,this.sortRunning=!0,this.sortWorker.postMessage(c))}}());this.scene=t.scene,this.currentPage=null,this.renderer=t.renderer,this.devicePixelRatio=window.devicePixelRatio,this.sortWorker=null,this.splatRenderCount=0,this.splatSortCount=0,this.splatMesh=null,this.sortRunning=!1,this.splatRenderingInitialized=!1,this.meshMatrixWorlds=null,this.meshMatrixWorldsOld=null,this.cropsArray=null,this.splatEntries=null,this.queuedMessage=null}get camera(){return this.scene.activeCamera}reloadSplats(){this.splatRenderingInitialized=!1;let t=this.loadSplat();this.renderer.pipeline.opaquePass.splatViewer=t?this:null}loadSplat(t={}){this.activePage=this.scene.activePage,t.position&&(t.position=new Bs().fromArray(t.position)),t.orientation&&(t.orientation=new y1().fromArray(t.orientation)),t.halfPrecisionCovariances=!!t.halfPrecisionCovariances;let e=[];if(this.splatEntries=e,this.activePage.traverseEntity(a=>{if(a.data.type==="Splat"){let s=a.visible;a.traverseAncestors(l=>{s&&(s=l.visible)}),s&&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 jn(new Uint8Array(a.data.buffer).buffer)),o=0,i=[0];for(let a of r)o+=a.getSplatCount(),i.push(o);return this.setupSplatMesh(r,o,t.position,t.orientation,t.halfPrecisionCovariances,this.devicePixelRatio,i,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,i)=>{this.cropsArray[r][i]===void 0?(t=!0,this.cropsArray[r][i]=o.data):Object.entries(o.data).forEach(([a,s])=>{Array.isArray(s)&&s.some((l,u)=>l!==this.cropsArray[r][i][a][u])?(t=!0,this.cropsArray[r][i][a]=s):s!==this.cropsArray[r][i]?.[a]&&(t=!0,this.cropsArray[r][i][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 Bs,o=new y1,i=!1,a=1,s,l){this.splatMesh=Hn.buildMesh(t,e,i,a,s,l),this.splatMesh.position.copy(r),this.splatMesh.quaternion.copy(o),this.splatMesh.frustumCulled=!1,this.splatMesh.renderOrder=10,this.updateSplatMeshUniforms(),this.splatRenderCount=e}setupSortWorker(t){this.sortWorker=p1(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.updateView(!0,!0),this.splatRenderingInitialized=!0)}}update(){this.splatRenderingInitialized!==!1&&(this.updateSplatMeshUniforms(),this.updateView())}getSplatMesh(){return this.splatMesh}};var eB=new ZE;eB.wireframe=!0;var g1=new XE,Nd=class extends YE{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.entityByUuid={};this.entityIdentityToEntity={};this.toExpandCloner=new Set;this.toUpdateCloner=new Set;this.pendingCommands=[];this.pathConstraints=new Pd;this.invisibleObjects=new Rn("jflkdsafjasdifjaslk",{...Qc.defaultData,visible:!1,name:"buildin invisible"});this.needsRecomputeInstances=!1;this.init(e,r),this.matrixAutoUpdate=!1,this.errorPage=new zr("fdasfa",{...Go.defaultData,name:""},{shared:r,scene:this})}markGeometryCacheDirty(){this.geometryCacheChanged=!0}markNeedsUpdateRendererDirty(){this.needsTransmissionDirty=!0,this.needsNormalDirty=!0}needsTransmission(){return this.needsTransmissionDirty&&(this._needsTransmission=LS(this),this.needsTransmissionDirty=!1),this._needsTransmission}needsNormal(){return this.needsNormalDirty&&(this._needsNormal=BS(this),this.needsNormalDirty=!1),this._needsNormal}registerInstanceAndSetUuid(e){let r=e.identity.join("-"),o=this.entityIdentityToEntity[r];o&&(e.uuid=o.uuid),this.entityIdentityToEntity[r]=e,this.entityByUuid[e.uuid]=e}markPenumbraSizeDirty(){for(let e of this.children)e instanceof zr&&(e.penumbraSizeArrayCache=null)}findInstance(e){return this.entityIdentityToEntity[e.join("-")]}get bgColor(){return this.activePage.bgColor}get postprocessing(){return this.activePage.data.postprocessing}getWithSortKey(e){let r=this.find(e);if(r===void 0)return;let o=[],i=r;for(;i!==this;){let a=i;i=i.parent;let s=i.children.indexOf(a);o.splice(0,0,s)}return{entity:r,sortKey:o}}getAllSorted(e){let r=[];for(let o of e){let i=this.getWithSortKey(o.id);i!==void 0&&r.push(i)}return r.sort((o,i)=>Ql(o.sortKey,i.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===bn)return this.activePage.personalCamera}if(e===""||e===void 0)return;let r=this.entityByUuid[e];return r===void 0?this.getObjectByProperty("uuid",e):r}find2D(e){for(let r of this.children)if(r instanceof zr&&r.uiScene){let o=r.uiScene.find(e);if(o)return o}}findScene2DfromObject2D(e){for(let r of this.children)if(r instanceof zr&&r.uiScene&&r.uiScene.find(e))return r.uiScene}find2DInUIObjects(e){let r;return this.traverseEntity(o=>{r===void 0&&o instanceof Pi&&(r=o.uiCanvas.find(e))}),r}traverse2D(e){for(let r of this.children)r instanceof zr&&r.uiScene&&r.uiScene.traverse(e)}debugEnsureEntity(e){let r=this.find(e);if(r){if(Array.isArray(r.identity)&&this.findInstance(r.identity)===void 0){console.error("not found instance");debugger}}else{console.error("not found");debugger}}addPendingExpandCloner(e){this.toExpandCloner.add(e)}addPendingUpdateCloner(e){this.toUpdateCloner.add(e)}markToExpandCloner(e){this.toExpandCloner.add(e),e.traverseEntityAncestors(r=>{this.toExpandCloner.add(r)})}doPendingExpandCloner(){this.toExpandCloner.forEach(e=>{e.expandCloner(this)}),this.toExpandCloner.clear()}doPendingUpdateCloner(){this.toUpdateCloner.forEach(e=>{e.cloner?.update()}),this.toUpdateCloner.clear()}doPendingUpdates(){this.doPendingExpandCloner(),this.doPendingUpdateCloner(),this.applyPendingCommands()}addPendingCommand(e){this.pendingCommands.push(e)}applyPendingCommands(){this.pendingCommands.forEach(e=>e()),this.pendingCommands.length=0}updateByLibOp(e,r){e.path.length===1&&e.path[0]==="components"&&e.type===1&&this.createChildrenObjects([{...e.data.asset,id:e.id}],this.invisibleObjects,r)}updateTreeByOp(e,r){if(e.path.length===0&&e.type===7){let o=e.parent===null?this:this.find(e.parent);if(o===void 0)throw new Error("unexpected");let i=this.createObject(e.id,e.data,e.children,o,e.localIndex,r);i.updateVisible(this),i.resetBBoxNeedsUpdate(),Ln(i)&&Nl(i.parent)&&(i.invalidateUpstreamBooleanData(),i.parent.invalidateDownstreamBooleanData().recomputeBoolean()),this.markNeedsRecomputeInstancesForAncessors(o),this.markNeedsRecomputeInstancesForChildren(i),this.markToExpandCloner(i),this.markPenumbraSizeDirty(),i.updatePathSnapping()}else if(e.path.length===0&&e.type===8){let o=this.find(e.id);if(o===void 0)throw new Error("unexpected");this.markToExpandCloner(o),o.resetBBoxNeedsUpdate(),this.unregisterObject(o);let i=o.parent;this.markNeedsRecomputeInstancesForAncessors(i),this.markNeedsRecomputeInstancesForChildren(o),this.markPenumbraSizeDirty(),o.parent.remove(o),Nl(o.parent)&&(o.parent.invalidateUpstreamBooleanData(),o.parent.invalidateDownstreamBooleanData().recomputeBoolean()),Ln(o)&&(o.freeBooleanPointer(),i instanceof yr&&i.invalidateDownstreamBooleanData().recomputeBoolean()),o instanceof Is&&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 i=o.parent;this.markNeedsRecomputeInstancesForAncessors(i),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()),Ln(o)&&(o.invalidateUpstreamBooleanData(),Nl(o.parent)?o.parent.invalidateDownstreamBooleanData().recomputeBoolean():i instanceof yr&&i.invalidateDownstreamBooleanData().recomputeBoolean()),o.updatePathSnapping()}this.markNeedsUpdateRendererDirty(),this.markGeometryCacheDirty()}get playPage(){return this.find(this.data.publish.playPage)??this.errorPage}updatePage(e){this.activePage&&this.activePage.onDeactive(),this.activePage=this.errorPage;for(let r of this.children)r instanceof zr&&(r.visible=r.uuid===e,r.visible&&(this.activePage=r,this.activePage.onActive(this)));this.activePage!==this.splatViewer?.activePage&&this.reloadSplats()}updateEntityByOp(e,r,o,i){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{NS(a,r,o,{scene:this,shared:i}),a instanceof ft&&a.updateGeometryGroupsIfNeeded()}catch(s){console.error(s)}}updateEntity2DByOp(e,r,o,i,a,s=[]){e.updateEntityByOp(r,o,i,a),this.traverseEntity(l=>{(l instanceof Pi||l instanceof zr)&&(s.includes(l.frameId??"")||l.frameId===r)&&l.updateEntity2DByOp(r,o,i,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((i,a)=>({data:i[1].asset.data,children:i[1].asset.children,id:i[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(i=>{i instanceof rn&&i.updateUp()}),this.doPendingExpandCloner(),this.applyPendingCommands()}markNeedsRecomputeInstances(){this.needsRecomputeInstances=!0}markNeedsRecomputeInstancesForChildren(e){e.traverseEntity(r=>{(r.data.type==="Component"||r.data.type==="Instance")&&this.markNeedsRecomputeInstances()})}markNeedsRecomputeInstancesForAncessors(e){Re.is(e)&&(e.data.type==="Component"&&this.markNeedsRecomputeInstances(),e.traverseAncestors(r=>{Re.is(r)&&r.data.type==="Component"&&this.markNeedsRecomputeInstances()}))}relativeizeInner(e,r,o,i,a,s,l){if(e){let u=i.find(e);u&&u!==i&&a.forInstancesRec(c=>{c.data=fn(c.data,d=>{let p=d.events.data(l.id),f=c.goUp(s);if(f){let h=[...Xl(f.identity),e].join("-"),m=this.entityIdentityToEntity[h];if(m){let y=m.uuid,g=lt.zoom(p,r);g[o]=y}else{if(!1)debugger;console.warn("cannot find instance")}}}).data})}}rewriteActions(e,r,o,i,a,s){e.forEach(l=>{l.data.type==="Transition"?this.relativeizeInner(l.data.object,[...r,l.id],"object",o,i,a,s):l.data.type==="Animation"&&this.relativeizeInner(l.data.object,[...r,l.id],"object",o,i,a,s)})}rewriteEventsBeforeGoToPlayMode(){this.traverseEntity(e=>{if(e instanceof an&&typeof e.identity=="string"&&e.data.type==="Component")return e.traverseEntity((r,o)=>{r.data.events.forEach(i=>{if(i.data.type==="GameControl"){let a=!1;if(r.forInstancesRec(s=>{s.data=fn(s.data,l=>{s.isInstanceRoot||(l.events.delete(i.id),a=!0)}).data}),a===!1)for(let s of eu.list)this.rewriteActions(i.data.gameActions[s],["gameActions",s],e,r,o,i)}else i.data.type==="Conditional"?(i.data.condition.type==="Distance"?(this.relativeizeInner(i.data.condition.fromObject,["condition"],"fromObject",e,r,o,i),this.relativeizeInner(i.data.condition.toObject,["condition"],"toObject",e,r,o,i)):i.data.condition.type==="State"?this.relativeizeInner(i.data.condition.object,["condition"],"object",e,r,o,i):i.data.condition.type==="Comparison"&&(i.data.condition.lOperand.type==="Property"&&this.relativeizeInner(i.data.condition.lOperand.value[0],["condition","lOperand","value"],0,e,r,o,i),i.data.condition.rOperand.type==="Property"&&this.relativeizeInner(i.data.condition.rOperand.value[0],["condition","rOperand","value"],0,e,r,o,i)),this.rewriteActions(i.data.inActions,["inActions"],e,r,o,i),this.rewriteActions(i.data.outActions,["outActions"],e,r,o,i)):"actions"in i.data&&this.rewriteActions(i.data.actions,["actions"],e,r,o,i)})}),!0})}expandInstances(e,r,o){let i=new Set;this.traverseEntity(a=>{if(a instanceof an&&a.isInstanceRoot)return a.expandInstanceChildren({scene:this,shared:e,pendingDeletes:i}),r||a.resetBBoxNeedsUpdate(),o&&a.traverseEntity(s=>{o.addClip(s)}),!0});for(let a of i)this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(a),bd(a)}recomputeInstances(e,r){this.needsRecomputeInstances&&(this.needsRecomputeInstances=!1,this.traverseEntity(o=>{o instanceof an&&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)Re.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=[],i=a=>{for(let s of a.children){let l=s.cloner;if(Re.is(s)&&!s.raycastLock&&(s.visible||l?.object.data.visible))if(r===!0&&s.isInstanceRoot){let u=[];if(e.intersectObject(s,!0,u),u.length){let c=u[0];c.object=s,c.point.applyMatrix4(c.object.matrixWorld);let d=s.matrixWorld.clone().invert();c.point.applyMatrix4(d),o.push(c)}}else(Ln(s)||Dl(s)&&this.enableHelpers&&s.objectHelper.visible)&&(e.intersectObject(s,!1,o),Gl(s,e,o)),i(s)}};return i(this.activePage),o}raycastWithClones(e){let r=[],o=i=>{for(let a of i.children){let s=a.cloner;Re.is(a)&&(a.visible||s?.object.data.visible)&&((Ln(a)||Dl(a)&&this.enableHelpers&&a.objectHelper.visible)&&(e.intersectObject(a,!1,r),Gl(a,e,r,!0)),o(a))}};return o(this),r}forEachEntity(e){for(let r of this.children)Re.is(r)&&e(r)}traverseConcreteEntity(e){for(let r of this.children)Re.is(r)&&r.isConcreteEntity&&r.traverseEntity(e)}traverseEntity(e){for(let r of this.children)Re.is(r)&&r.traverseEntity(e)}updateFont(e,r){this.traverseEntity(o=>{if(o instanceof ft&&o.data.type==="Mesh"&&o.data.geometry.type==="TextGeometry"&&o.data.geometry.font===e){let i=o.geometry,a=o.data.geometry;i.updateFont(e,r).then(()=>{i.update(a);let s=o.invalidateDownstreamBooleanData();Nl(s)&&s.recomputeBoolean()})}})}traverseObject(e){for(let r of this.children)_a.is(r)&&r.traverseObject(e)}traverseVisibleEntity(e){for(let r of this.children)Re.is(r)&&r.visible&&r.traverseVisibleEntity(e)}dispose(){this.clearScene()}createChildrenObjects(e,r,o){let i=0;for(let a of e)this.createObject(a.id,a.data,a.children,r,i,o),i+=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,i,a,s){let l={scene:this,shared:s},u=_d(e,r,l);return u&&(this.entityByUuid[e]=u,i.add(u),i.children.splice(a,0,i.children.pop()),o.length>0&&(u.isInstanceRoot?console.error("instance should not have children!"):this.createChildrenObjects(o,u,s)),u.updateState(r,l),u instanceof ft&&u.updateGeometryGroupsIfNeeded(),u.updateVisible(this),u.cloner&&this.toExpandCloner.add(u),r.pathSnapping?.pathId&&this.pathConstraints.setConstraint(e,r.pathSnapping.pathId)),r.type==="Empty"&&r.animations&&u.traverseEntity(c=>{let d=c.dataPatched;if(c instanceof ft&&d.bones&&d.boneInverses){let p=d.bones.map(m=>this.find(m)),f=d.boneInverses.map(m=>new QE().fromArray(m)),h=new JE(p,f);c.bind(h,c.bindMatrix)}else c.matrixAutoUpdate=!0}),u}getCenter(e){let r=[];for(let i=0,a=e.length;i<a;++i){let{id:s,recursive:l}=e[i],u=this.find(s),c=l?u.recursiveBBox:u.singleBBox;r.push(...c.vertices)}let o=new KE;return o.setFromPoints(r),o.getCenter(g1),g1}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 Dt)if(Array.isArray(r.material))for(let o=0;o<r.material.length;o++)r.material[o]instanceof hr&&e(r.material[o]);else r.material instanceof hr&&e(r.material)})}updateViewPlaneSize(e,r,o=!1){this.traverseConcreteEntity(i=>{i instanceof rn&&i.setViewplaneSize(e,r,o)})}initializeSplatViewer(e){this.splatViewer=new kl({scene:this,renderer:e}),this.reloadSplats()}reloadSplats(){this.splatViewer?.reloadSplats()}};import{DRACOLoader as tB}from"three/examples/jsm/loaders/DRACOLoader.js";var qn;function rB(){return qn||(qn=new tB,qn.setDecoderPath("https://www.gstatic.com/draco/versioned/decoders/1.5.2/").preload()),qn.decoderPending}async function oB(n){if(qn){let t={attributeIDs:qn.defaultAttributeIDs,attributeTypes:qn.defaultAttributeTypes,useUniqueIDs:!1},e;try{e=await qn.decodeGeometry(new Int8Array(n).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 x1(n,t){let[e,r]=ep(Vc.deserialize(new Uint8Array(n)));ou(e);let o=[];e.scene.objects.traverse((i,a)=>{a.type==="Mesh"&&a.geometry.type==="NonParametricGeometry"&&a.geometry.data.draco!==void 0&&o.push(a)}),o.length&&await rB();for(let i of o){let a=await oB(ut(i.geometry.data.draco));if(a){a.index&&(i.geometry.data.index={array:a.index.array,itemSize:1,normalized:!1,type:"Uint32Array"});let s={};a.attributes.forEach(({name:l,array:u,itemSize:c})=>{s[l]={array:u,itemSize:c,type:"Float32Array",normalized:!1}}),i.geometry.data.attributes=s,i.geometry.data.draco=void 0}}return t&&t(e),r.result().data}import{Mesh as bfe}from"three";import{mergeBufferGeometries as wfe}from"three/examples/jsm/utils/BufferGeometryUtils.js";function b1(n){let t;if(!!n.index)for(let e=0;e<n.index.array.length;e+=3)t=n.index.array[e],n.index.array[e]=n.index.array[e+2],n.index.array[e+2]=t}import{Color as v1,ShaderLib as nB}from"three";function S1(n){let t=new Set;return n.traverse(e=>{if(e instanceof mr)if(yt(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(iB(e)){Object.assign(e,{isMeshStandardMaterial:!0,isMeshPhysicalMaterial:!0,transmission:1,attenuationColor:new v1,specularColor:new v1});let o=0;e.onBeforeCompile=(i,a)=>{r&&r(i,a),i.uniforms=Object.assign({},nB.physical.uniforms,i.uniforms),e.getLayersOfType("transmission").forEach(s=>{if(i.uniforms.transmissionSamplerMap.value){let l=s.color;l&&(l.transmissionSamplerMap.value=i.uniforms.transmissionSamplerMap.value,l.transmissionSamplerSize.value=i.uniforms.transmissionSamplerSize.value,l.aspectRatio.value=Eb(window.innerWidth,window.innerHeight),e.defines.IS_THREEJS_EXPORT=!0)}else o++,o<2&&(e.needsUpdate=!0)})}}else aB(e)||(e.onBeforeCompile=(o,i)=>{r&&r(o,i),e.transparent=!1})}),n}function iB(n){return n.getLayersOfType("transmission").length>0}function aB(n){let t=0;for(let e of n.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 w1(n){return n.traverse(t=>{if(t.type==="Camera"){let e=t;e.type=e.cameraType}}),n}function A1(n){let t=[],e=(r,o=0)=>{let i=o>0?r+o:r;return t.includes(i)?e(r,o+1):i};return n.traverse(r=>{if(t.includes(r.name)){let o=r.name,i=e(r.name);if(r.name=i,r.isMesh){let a=r;a.material instanceof Array?a.material.forEach(s=>{s.name=s.name.replace(o,i)}):a.material.isAsset||(a.material.name=a.material.name.replace(o,i))}}t.push(r.name)}),n}import{mergeBufferGeometries as sB}from"three/examples/jsm/utils/BufferGeometryUtils.js";function _1(n){let t=[];return n.traverse(e=>{e instanceof vs&&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(u){console.error(u)}return l!==void 0&&s.matrix.determinant()<0&&b1(l),l}).filter(s=>s!==void 0)];if(!e.parameters.hideBase&&r instanceof Dt&&a.unshift(r.geometry),a.length){let s=sB(a);r instanceof Dt&&(r.geometry=s)}e.removeFromParent(),r.setFromClonerState(null,{scene:n,shared:Kb})}),n}function P1(n){return n.traverse(t=>{t.matrixAutoUpdate=!0}),n}function O1(n){Object.values(n.shared.materials).forEach(t=>{Wh(t)}),n.scene.objects.traverse((t,e)=>{"material"in e?Wh(e.material):"materials"in e&&e.materials.forEach(r=>{Wh(r)})})}function Wh(n){if(typeof n=="string")return;let t=[];n.layers.forEach((e,r)=>{e.type==="outline"&&t.push(r)}),t.reverse().forEach(e=>{n.layers.delete(e)}),t.length&&console.warn("The Spline Loader currently does not support the outline layer.")}var N1=Ht(T1(),1);function M1(n){return n.traverseMaterial(t=>{t.needsJitter=!1}),n}var I1="The SplineLoader only accepts .splinecode files that are generated from Spline export panel.",$h=class extends cB{load(t,e,r,o=console.error){let i=new lB(this.manager);i.setPath(this.path),i.setResponseType("arraybuffer"),i.setRequestHeader(this.requestHeader),i.setWithCredentials(this.withCredentials),t.endsWith(".spline")?console.warn(I1+" The .spline files are only meant to be used by the Editor."):t.endsWith(".splinecode")||console.warn(I1),i.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 x1(t,O1);e.version&&(0,N1.default)(e.version,"1.0.57")>0&&console.warn("Your .splinecode file is more recent than the library. Please upgrade @splinetool/loader to the latest version."),await Promise.allSettled([iv(e)&&sb(),yv(e)&&Yb(),Kv(e)&&Yv()].filter(Boolean));let r=new xi(e.shared);Object.values(r.getMaterials()).forEach(a=>Object.assign(a,{isAsset:!0}));let o=new Nd(e.scene,r),i=o.activeCamera;return i&&Object.assign(i,{makeDefault:!0}),o=_1(o),o=S1(o),o=w1(o),o=A1(o),o=P1(o),o=M1(o),o}};export{$h as default};
3665
+ }`,i={covariancesTexture:{type:"t",value:null},centersColorsTexture:{type:"t",value:null},meshIndexIntervals:{value:e},meshMatrixWorldsTexture:{type:"t",value:null},focal:{type:"v2",value:new Un},viewport:{type:"v2",value:new Un},basisViewport:{type:"v2",value:new Un},debugColor:{type:"v3",value:new EE},covariancesTextureSize:{type:"v2",value:new Un(1024,1024)},centersColorsTextureSize:{type:"v2",value:new Un(1024,1024)},orthoZoom:{type:"f",value:-1}};return new HE({uniforms:i,vertexShader:r,fragmentShader:o,transparent:!0,alphaTest:1,blending:kE,depthTest:!0,depthWrite:!1,side:LE})}static buildGeomtery(e){let r=new DE;r.setIndex([0,1,2,0,2,3]);let o=new Float32Array(4*3),i=new NE(o,3);r.setAttribute("position",i),i.setXYZ(0,-1,-1,0),i.setXYZ(1,-1,1,0),i.setXYZ(2,1,1,0),i.setXYZ(3,1,-1,0),i.needsUpdate=!0;let a=new GE().copy(r),s=new Uint32Array(e),l=new zE(s,1,!1);return l.setUsage(RE),a.setAttribute("splatIndex",l),a.instanceCount=e,a}resetLocalSplatDataAndTexturesFromSplatBuffer(){this.updateLocalSplatDataFromSplatBuffer(),this.allocateAndStoreLocalSplatDataInTextures()}updateLocalSplatDataFromSplatBuffer(){this.splatBuffers.forEach(i=>i.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 i of this.splatBuffers){let a=i.nsplats;this.colors.subarray(e,e+a*4).set(i.colorsA),e+=a*4,this.centers.subarray(r,r+a*3).set(i.decoded.xyz.denormDequant().data),r+=a*3,this.covariances.subarray(o,o+a*6).set(new Float32Array(i.precomputedCovarianceBufferData)),o+=a*6}}allocateAndStoreLocalSplatDataInTextures(){let o=this.splatCount,i=new Un(4096,1024);for(;i.x*i.y*2<o*6;)i.y*=2;let a=new Un(4096,1024);for(;a.x*a.y*4<o*4;)a.y*=2;let s,l;if(this.halfPrecisionCovariancesOnGPU){l=new Uint16Array(i.x*i.y*2);for(let h=0;h<this.covariances.length;h++)l[h]=BE.toHalfFloat(this.covariances[h]);s=new Md(l,i.x,i.y,m1,VE)}else l=new Float32Array(i.x*i.y*2),l.set(this.covariances),s=new Md(l,i.x,i.y,m1,h1);s.needsUpdate=!0,this.material.uniforms.covariancesTexture.value=s,this.material.uniforms.covariancesTextureSize.value.copy(i);let u=new Uint32Array(a.x*a.y*4);for(let h=0;h<o;h++){let m=h*4,y=h*3,g=h*4;u[g]=f1(this.colors[m],this.colors[m+1],this.colors[m+2],this.colors[m+3]),u[g+1]=Td(this.centers[y]),u[g+2]=Td(this.centers[y+1]),u[g+3]=Td(this.centers[y+2])}let c=new Md(u,a.x,a.y,UE,qE);c.internalFormat="RGBA32UI",c.needsUpdate=!0,this.material.uniforms.centersColorsTexture.value=c,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 Md(p,d,1,jE,h1);f.needsUpdate=!0,this.material.uniforms.meshMatrixWorldsTexture.value=f,this.material.uniformsNeedUpdate=!0,this.splatDataTextures={covariances:{data:l,texture:s,size:i},centerColors:{data:u,texture:c,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,i){this.splatCount>0&&(Id.set(e.x*this.devicePixelRatio,e.y*this.devicePixelRatio),this.material.uniforms.viewport.value.copy(Id),this.material.uniforms.basisViewport.value.set(2/Id.x,2/Id.y),this.material.uniforms.focal.value.set(r,o),this.material.uniforms.orthoZoom.value=i,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())}};var kl=class{constructor(t={}){Lt(this,"updateSplatMeshUniforms",function(){let t=new $E;return function(){if(this.splatMesh===null)return;this.splatMesh.getSplatCount()>0&&(this.renderer.getSize(t),this.cameraFocalLengthX=this.camera.projectionMatrix.elements[0]*this.devicePixelRatio*t.x*.45,this.cameraFocalLengthY=this.camera.projectionMatrix.elements[5]*this.devicePixelRatio*t.y*.45,this.splatMesh.updateUniforms(t,this.cameraFocalLengthX,this.cameraFocalLengthY,this.camera.isPerspectiveCamera?-1:this.camera.zoom*this.devicePixelRatio))}}());Lt(this,"updateView",function(){let t=new WE,e=[],r=new Bs(0,0,-1),o=new Bs(0,0,-1),i=new Bs,a=new Bs;return function(s=!1){let l=this.updateMatrixWorldsInWorkerIfNeeded(),u=this.cropsChanged();if(!s){o.set(0,0,-1).applyQuaternion(this.camera.quaternion);let d=!1,p=!1;if(o.dot(r)<=.95&&(d=!0),a.copy(this.camera.position).sub(i).length()>=1&&(p=!0),!d&&!p&&!l&&!u)return}i.copy(this.camera.position),r.copy(o),t.copy(this.camera.matrixWorld).invert(),t.premultiply(this.camera.perspCamera.projectionMatrix),e[0]=this.camera.position.x,e[1]=this.camera.position.y,e[2]=this.camera.position.z;let c={sort:{view:t.elements,cameraPosition:e,splatRenderCount:this.splatRenderCount,splatSortCount:this.splatRenderCount},...l?{newMatrixWorlds:this.meshMatrixWorlds}:{},...u?{newCropsArray:this.cropsArray}:{}};this.sortRunning?this.queuedMessage=c:(this.queuedMessage=null,this.sortRunning=!0,this.sortWorker.postMessage(c))}}());this.scene=t.scene,this.currentPage=null,this.renderer=t.renderer,this.devicePixelRatio=window.devicePixelRatio,this.sortWorker=null,this.splatRenderCount=0,this.splatSortCount=0,this.splatMesh=null,this.sortRunning=!1,this.splatRenderingInitialized=!1,this.meshMatrixWorlds=null,this.meshMatrixWorldsOld=null,this.cropsArray=null,this.splatEntries=null,this.queuedMessage=null}get camera(){return this.scene.activeCamera}reloadSplats(){this.splatRenderingInitialized=!1;let t=this.loadSplat();this.renderer.pipeline.opaquePass.splatViewer=t?this:null}loadSplat(t={}){this.activePage=this.scene.activePage,t.position&&(t.position=new Bs().fromArray(t.position)),t.orientation&&(t.orientation=new y1().fromArray(t.orientation)),t.halfPrecisionCovariances=!!t.halfPrecisionCovariances;let e=[];if(this.splatEntries=e,this.activePage.traverseEntity(a=>{if(a.data.type==="Splat"){let s=a.visible;a.traverseAncestors(l=>{s&&(s=l.visible)}),s&&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 jn(new Uint8Array(a.data.buffer).buffer)),o=0,i=[0];for(let a of r)o+=a.getSplatCount(),i.push(o);return this.setupSplatMesh(r,o,t.position,t.orientation,t.halfPrecisionCovariances,this.devicePixelRatio,i,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,i)=>{this.cropsArray[r][i]===void 0?(t=!0,this.cropsArray[r][i]=o.data):Object.entries(o.data).forEach(([a,s])=>{Array.isArray(s)&&s.some((l,u)=>l!==this.cropsArray[r][i][a][u])?(t=!0,this.cropsArray[r][i][a]=s):s!==this.cropsArray[r][i]?.[a]&&(t=!0,this.cropsArray[r][i][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 Bs,o=new y1,i=!1,a=1,s,l){this.splatMesh=Hn.buildMesh(t,e,i,a,s,l),this.splatMesh.position.copy(r),this.splatMesh.quaternion.copy(o),this.splatMesh.frustumCulled=!1,this.splatMesh.renderOrder=10,this.updateSplatMeshUniforms(),this.splatRenderCount=e}setupSortWorker(t){this.sortWorker=p1(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.updateView(!0,!0),this.splatRenderingInitialized=!0)}}update(){this.splatRenderingInitialized!==!1&&(this.updateSplatMeshUniforms(),this.updateView())}getSplatMesh(){return this.splatMesh}};var eB=new ZE;eB.wireframe=!0;var g1=new XE,Nd=class extends YE{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.entityByUuid={};this.entityIdentityToEntity={};this.toExpandCloner=new Set;this.toUpdateCloner=new Set;this.pendingCommands=[];this.pathConstraints=new Pd;this.invisibleObjects=new Rn("jflkdsafjasdifjaslk",{...Qc.defaultData,visible:!1,name:"buildin invisible"});this.needsRecomputeInstances=!1;this.init(e,r),this.matrixAutoUpdate=!1,this.errorPage=new zr("fdasfa",{...Go.defaultData,name:""},{shared:r,scene:this})}markGeometryCacheDirty(){this.geometryCacheChanged=!0}markNeedsUpdateRendererDirty(){this.needsTransmissionDirty=!0,this.needsNormalDirty=!0}needsTransmission(){return this.needsTransmissionDirty&&(this._needsTransmission=LS(this),this.needsTransmissionDirty=!1),this._needsTransmission}needsNormal(){return this.needsNormalDirty&&(this._needsNormal=BS(this),this.needsNormalDirty=!1),this._needsNormal}registerInstanceAndSetUuid(e){let r=e.identity.join("-"),o=this.entityIdentityToEntity[r];o&&(e.uuid=o.uuid),this.entityIdentityToEntity[r]=e,this.entityByUuid[e.uuid]=e}markPenumbraSizeDirty(){for(let e of this.children)e instanceof zr&&(e.penumbraSizeArrayCache=null)}findInstance(e){return this.entityIdentityToEntity[e.join("-")]}get bgColor(){return this.activePage.bgColor}get postprocessing(){return this.activePage.data.postprocessing}getWithSortKey(e){let r=this.find(e);if(r===void 0)return;let o=[],i=r;for(;i!==this;){let a=i;i=i.parent;let s=i.children.indexOf(a);o.splice(0,0,s)}return{entity:r,sortKey:o}}getAllSorted(e){let r=[];for(let o of e){let i=this.getWithSortKey(o.id);i!==void 0&&r.push(i)}return r.sort((o,i)=>Ql(o.sortKey,i.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===bn)return this.activePage.personalCamera}if(e===""||e===void 0)return;let r=this.entityByUuid[e];return r===void 0?this.getObjectByProperty("uuid",e):r}find2D(e){for(let r of this.children)if(r instanceof zr&&r.uiScene){let o=r.uiScene.find(e);if(o)return o}}findScene2DfromObject2D(e){for(let r of this.children)if(r instanceof zr&&r.uiScene&&r.uiScene.find(e))return r.uiScene}find2DInUIObjects(e){let r;return this.traverseEntity(o=>{r===void 0&&o instanceof Pi&&(r=o.uiCanvas.find(e))}),r}traverse2D(e){for(let r of this.children)r instanceof zr&&r.uiScene&&r.uiScene.traverse(e)}debugEnsureEntity(e){let r=this.find(e);if(r){if(Array.isArray(r.identity)&&this.findInstance(r.identity)===void 0){console.error("not found instance");debugger}}else{console.error("not found");debugger}}addPendingExpandCloner(e){this.toExpandCloner.add(e)}addPendingUpdateCloner(e){this.toUpdateCloner.add(e)}markToExpandCloner(e){this.toExpandCloner.add(e),e.traverseEntityAncestors(r=>{this.toExpandCloner.add(r)})}doPendingExpandCloner(){this.toExpandCloner.forEach(e=>{e.expandCloner(this)}),this.toExpandCloner.clear()}doPendingUpdateCloner(){this.toUpdateCloner.forEach(e=>{e.cloner?.update()}),this.toUpdateCloner.clear()}doPendingUpdates(){this.doPendingExpandCloner(),this.doPendingUpdateCloner(),this.applyPendingCommands()}addPendingCommand(e){this.pendingCommands.push(e)}applyPendingCommands(){this.pendingCommands.forEach(e=>e()),this.pendingCommands.length=0}updateByLibOp(e,r){e.path.length===1&&e.path[0]==="components"&&e.type===1&&this.createChildrenObjects([{...e.data.asset,id:e.id}],this.invisibleObjects,r)}updateTreeByOp(e,r){if(e.path.length===0&&e.type===7){let o=e.parent===null?this:this.find(e.parent);if(o===void 0)throw new Error("unexpected");let i=this.createObject(e.id,e.data,e.children,o,e.localIndex,r);i.updateVisible(this),i.resetBBoxNeedsUpdate(),Ln(i)&&Nl(i.parent)&&(i.invalidateUpstreamBooleanData(),i.parent.invalidateDownstreamBooleanData().recomputeBoolean()),this.markNeedsRecomputeInstancesForAncessors(o),this.markNeedsRecomputeInstancesForChildren(i),this.markToExpandCloner(i),this.markPenumbraSizeDirty(),i.updatePathSnapping()}else if(e.path.length===0&&e.type===8){let o=this.find(e.id);if(o===void 0)throw new Error("unexpected");this.markToExpandCloner(o),o.resetBBoxNeedsUpdate(),this.unregisterObject(o);let i=o.parent;this.markNeedsRecomputeInstancesForAncessors(i),this.markNeedsRecomputeInstancesForChildren(o),this.markPenumbraSizeDirty(),o.parent.remove(o),Nl(o.parent)&&(o.parent.invalidateUpstreamBooleanData(),o.parent.invalidateDownstreamBooleanData().recomputeBoolean()),Ln(o)&&(o.freeBooleanPointer(),i instanceof yr&&i.invalidateDownstreamBooleanData().recomputeBoolean()),o instanceof Is&&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 i=o.parent;this.markNeedsRecomputeInstancesForAncessors(i),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()),Ln(o)&&(o.invalidateUpstreamBooleanData(),Nl(o.parent)?o.parent.invalidateDownstreamBooleanData().recomputeBoolean():i instanceof yr&&i.invalidateDownstreamBooleanData().recomputeBoolean()),o.updatePathSnapping()}this.markNeedsUpdateRendererDirty(),this.markGeometryCacheDirty()}get playPage(){return this.find(this.data.publish.playPage)??this.errorPage}updatePage(e){this.activePage&&this.activePage.onDeactive(),this.activePage=this.errorPage;for(let r of this.children)r instanceof zr&&(r.visible=r.uuid===e,r.visible&&(this.activePage=r,this.activePage.onActive(this)));this.activePage!==this.splatViewer?.activePage&&this.reloadSplats()}updateEntityByOp(e,r,o,i){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{NS(a,r,o,{scene:this,shared:i}),a instanceof ft&&a.updateGeometryGroupsIfNeeded()}catch(s){console.error(s)}}updateEntity2DByOp(e,r,o,i,a,s=[]){e.updateEntityByOp(r,o,i,a),this.traverseEntity(l=>{(l instanceof Pi||l instanceof zr)&&(s.includes(l.frameId??"")||l.frameId===r)&&l.updateEntity2DByOp(r,o,i,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((i,a)=>({data:i[1].asset.data,children:i[1].asset.children,id:i[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(i=>{i instanceof rn&&i.updateUp()}),this.doPendingExpandCloner(),this.applyPendingCommands()}markNeedsRecomputeInstances(){this.needsRecomputeInstances=!0}markNeedsRecomputeInstancesForChildren(e){e.traverseEntity(r=>{(r.data.type==="Component"||r.data.type==="Instance")&&this.markNeedsRecomputeInstances()})}markNeedsRecomputeInstancesForAncessors(e){Re.is(e)&&(e.data.type==="Component"&&this.markNeedsRecomputeInstances(),e.traverseAncestors(r=>{Re.is(r)&&r.data.type==="Component"&&this.markNeedsRecomputeInstances()}))}relativeizeInner(e,r,o,i,a,s,l){if(e){let u=i.find(e);u&&u!==i&&a.forInstancesRec(c=>{c.data=fn(c.data,d=>{let p=d.events.data(l.id),f=c.goUp(s);if(f){let h=[...Xl(f.identity),e].join("-"),m=this.entityIdentityToEntity[h];if(m){let y=m.uuid,g=lt.zoom(p,r);g[o]=y}else{if(!1)debugger;console.warn("cannot find instance")}}}).data})}}rewriteActions(e,r,o,i,a,s){e.forEach(l=>{l.data.type==="Transition"?this.relativeizeInner(l.data.object,[...r,l.id],"object",o,i,a,s):l.data.type==="Animation"&&this.relativeizeInner(l.data.object,[...r,l.id],"object",o,i,a,s)})}rewriteEventsBeforeGoToPlayMode(){this.traverseEntity(e=>{if(e instanceof an&&typeof e.identity=="string"&&e.data.type==="Component")return e.traverseEntity((r,o)=>{r.data.events.forEach(i=>{if(i.data.type==="GameControl"){let a=!1;if(r.forInstancesRec(s=>{s.data=fn(s.data,l=>{s.isInstanceRoot||(l.events.delete(i.id),a=!0)}).data}),a===!1)for(let s of eu.list)this.rewriteActions(i.data.gameActions[s],["gameActions",s],e,r,o,i)}else i.data.type==="Conditional"?(i.data.condition.type==="Distance"?(this.relativeizeInner(i.data.condition.fromObject,["condition"],"fromObject",e,r,o,i),this.relativeizeInner(i.data.condition.toObject,["condition"],"toObject",e,r,o,i)):i.data.condition.type==="State"?this.relativeizeInner(i.data.condition.object,["condition"],"object",e,r,o,i):i.data.condition.type==="Comparison"&&(i.data.condition.lOperand.type==="Property"&&this.relativeizeInner(i.data.condition.lOperand.value[0],["condition","lOperand","value"],0,e,r,o,i),i.data.condition.rOperand.type==="Property"&&this.relativeizeInner(i.data.condition.rOperand.value[0],["condition","rOperand","value"],0,e,r,o,i)),this.rewriteActions(i.data.inActions,["inActions"],e,r,o,i),this.rewriteActions(i.data.outActions,["outActions"],e,r,o,i)):"actions"in i.data&&this.rewriteActions(i.data.actions,["actions"],e,r,o,i)})}),!0})}expandInstances(e,r,o){let i=new Set;this.traverseEntity(a=>{if(a instanceof an&&a.isInstanceRoot)return a.expandInstanceChildren({scene:this,shared:e,pendingDeletes:i}),r||a.resetBBoxNeedsUpdate(),o&&a.traverseEntity(s=>{o.addClip(s)}),!0});for(let a of i)this.disposeAndUnregisterEntityRecursivelyIfNotReregistered(a),bd(a)}recomputeInstances(e,r){this.needsRecomputeInstances&&(this.needsRecomputeInstances=!1,this.traverseEntity(o=>{o instanceof an&&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)Re.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=[],i=a=>{for(let s of a.children){let l=s.cloner;if(Re.is(s)&&!s.raycastLock&&(s.visible||l?.object.data.visible))if(r===!0&&s.isInstanceRoot){let u=[];if(e.intersectObject(s,!0,u),u.length){let c=u[0];c.object=s,c.point.applyMatrix4(c.object.matrixWorld);let d=s.matrixWorld.clone().invert();c.point.applyMatrix4(d),o.push(c)}}else(Ln(s)||Dl(s)&&this.enableHelpers&&s.objectHelper.visible)&&(e.intersectObject(s,!1,o),Gl(s,e,o)),i(s)}};return i(this.activePage),o}raycastWithClones(e){let r=[],o=i=>{for(let a of i.children){let s=a.cloner;Re.is(a)&&(a.visible||s?.object.data.visible)&&((Ln(a)||Dl(a)&&this.enableHelpers&&a.objectHelper.visible)&&(e.intersectObject(a,!1,r),Gl(a,e,r,!0)),o(a))}};return o(this),r}forEachEntity(e){for(let r of this.children)Re.is(r)&&e(r)}traverseConcreteEntity(e){for(let r of this.children)Re.is(r)&&r.isConcreteEntity&&r.traverseEntity(e)}traverseEntity(e){for(let r of this.children)Re.is(r)&&r.traverseEntity(e)}updateFont(e,r){this.traverseEntity(o=>{if(o instanceof ft&&o.data.type==="Mesh"&&o.data.geometry.type==="TextGeometry"&&o.data.geometry.font===e){let i=o.geometry,a=o.data.geometry;i.updateFont(e,r).then(()=>{i.update(a);let s=o.invalidateDownstreamBooleanData();Nl(s)&&s.recomputeBoolean()})}})}traverseObject(e){for(let r of this.children)_a.is(r)&&r.traverseObject(e)}traverseVisibleEntity(e){for(let r of this.children)Re.is(r)&&r.visible&&r.traverseVisibleEntity(e)}dispose(){this.clearScene()}createChildrenObjects(e,r,o){let i=0;for(let a of e)this.createObject(a.id,a.data,a.children,r,i,o),i+=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,i,a,s){let l={scene:this,shared:s},u=_d(e,r,l);return u&&(this.entityByUuid[e]=u,i.add(u),i.children.splice(a,0,i.children.pop()),o.length>0&&(u.isInstanceRoot?console.error("instance should not have children!"):this.createChildrenObjects(o,u,s)),u.updateState(r,l),u instanceof ft&&u.updateGeometryGroupsIfNeeded(),u.updateVisible(this),u.cloner&&this.toExpandCloner.add(u),r.pathSnapping?.pathId&&this.pathConstraints.setConstraint(e,r.pathSnapping.pathId)),r.type==="Empty"&&r.animations&&u.traverseEntity(c=>{let d=c.dataPatched;if(c instanceof ft&&d.bones&&d.boneInverses){let p=d.bones.map(m=>this.find(m)),f=d.boneInverses.map(m=>new QE().fromArray(m)),h=new JE(p,f);c.bind(h,c.bindMatrix)}else c.matrixAutoUpdate=!0}),u}getCenter(e){let r=[];for(let i=0,a=e.length;i<a;++i){let{id:s,recursive:l}=e[i],u=this.find(s),c=l?u.recursiveBBox:u.singleBBox;r.push(...c.vertices)}let o=new KE;return o.setFromPoints(r),o.getCenter(g1),g1}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 Dt)if(Array.isArray(r.material))for(let o=0;o<r.material.length;o++)r.material[o]instanceof hr&&e(r.material[o]);else r.material instanceof hr&&e(r.material)})}updateViewPlaneSize(e,r,o=!1){this.traverseConcreteEntity(i=>{i instanceof rn&&i.setViewplaneSize(e,r,o)})}initializeSplatViewer(e){this.splatViewer=new kl({scene:this,renderer:e}),this.reloadSplats()}reloadSplats(){this.splatViewer?.reloadSplats()}};import{DRACOLoader as tB}from"three/examples/jsm/loaders/DRACOLoader.js";var qn;function rB(){return qn||(qn=new tB,qn.setDecoderPath("https://www.gstatic.com/draco/versioned/decoders/1.5.2/").preload()),qn.decoderPending}async function oB(n){if(qn){let t={attributeIDs:qn.defaultAttributeIDs,attributeTypes:qn.defaultAttributeTypes,useUniqueIDs:!1},e;try{e=await qn.decodeGeometry(new Int8Array(n).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 x1(n,t){let[e,r]=ep(Vc.deserialize(new Uint8Array(n)));ou(e);let o=[];e.scene.objects.traverse((i,a)=>{a.type==="Mesh"&&a.geometry.type==="NonParametricGeometry"&&a.geometry.data.draco!==void 0&&o.push(a)}),o.length&&await rB();for(let i of o){let a=await oB(ut(i.geometry.data.draco));if(a){a.index&&(i.geometry.data.index={array:a.index.array,itemSize:1,normalized:!1,type:"Uint32Array"});let s={};a.attributes.forEach(({name:l,array:u,itemSize:c})=>{s[l]={array:u,itemSize:c,type:"Float32Array",normalized:!1}}),i.geometry.data.attributes=s,i.geometry.data.draco=void 0}}return t&&t(e),r.result().data}import{Mesh as bfe}from"three";import{mergeBufferGeometries as wfe}from"three/examples/jsm/utils/BufferGeometryUtils.js";function b1(n){let t;if(!!n.index)for(let e=0;e<n.index.array.length;e+=3)t=n.index.array[e],n.index.array[e]=n.index.array[e+2],n.index.array[e+2]=t}import{Color as v1,ShaderLib as nB}from"three";function S1(n){let t=new Set;return n.traverse(e=>{if(e instanceof mr)if(yt(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(iB(e)){Object.assign(e,{isMeshStandardMaterial:!0,isMeshPhysicalMaterial:!0,transmission:1,attenuationColor:new v1,specularColor:new v1});let o=0;e.onBeforeCompile=(i,a)=>{r&&r(i,a),i.uniforms=Object.assign({},nB.physical.uniforms,i.uniforms),e.getLayersOfType("transmission").forEach(s=>{if(i.uniforms.transmissionSamplerMap.value){let l=s.color;l&&(l.transmissionSamplerMap.value=i.uniforms.transmissionSamplerMap.value,l.transmissionSamplerSize.value=i.uniforms.transmissionSamplerSize.value,l.aspectRatio.value=Eb(window.innerWidth,window.innerHeight),e.defines.IS_THREEJS_EXPORT=!0)}else o++,o<2&&(e.needsUpdate=!0)})}}else aB(e)||(e.onBeforeCompile=(o,i)=>{r&&r(o,i),e.transparent=!1})}),n}function iB(n){return n.getLayersOfType("transmission").length>0}function aB(n){let t=0;for(let e of n.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 w1(n){return n.traverse(t=>{if(t.type==="Camera"){let e=t;e.type=e.cameraType}}),n}function A1(n){let t=[],e=(r,o=0)=>{let i=o>0?r+o:r;return t.includes(i)?e(r,o+1):i};return n.traverse(r=>{if(t.includes(r.name)){let o=r.name,i=e(r.name);if(r.name=i,r.isMesh){let a=r;a.material instanceof Array?a.material.forEach(s=>{s.name=s.name.replace(o,i)}):a.material.isAsset||(a.material.name=a.material.name.replace(o,i))}}t.push(r.name)}),n}import{mergeBufferGeometries as sB}from"three/examples/jsm/utils/BufferGeometryUtils.js";function _1(n){let t=[];return n.traverse(e=>{e instanceof vs&&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(u){console.error(u)}return l!==void 0&&s.matrix.determinant()<0&&b1(l),l}).filter(s=>s!==void 0)];if(!e.parameters.hideBase&&r instanceof Dt&&a.unshift(r.geometry),a.length){let s=sB(a);r instanceof Dt&&(r.geometry=s)}e.removeFromParent(),r.setFromClonerState(null,{scene:n,shared:Kb})}),n}function P1(n){return n.traverse(t=>{t.matrixAutoUpdate=!0}),n}function O1(n){Object.values(n.shared.materials).forEach(t=>{Wh(t)}),n.scene.objects.traverse((t,e)=>{"material"in e?Wh(e.material):"materials"in e&&e.materials.forEach(r=>{Wh(r)})})}function Wh(n){if(typeof n=="string")return;let t=[];n.layers.forEach((e,r)=>{e.type==="outline"&&t.push(r)}),t.reverse().forEach(e=>{n.layers.delete(e)}),t.length&&console.warn("The Spline Loader currently does not support the outline layer.")}var N1=Ht(T1(),1);function M1(n){return n.traverseMaterial(t=>{t.needsJitter=!1}),n}var I1="The SplineLoader only accepts .splinecode files that are generated from Spline export panel.",$h=class extends cB{load(t,e,r,o=console.error){let i=new lB(this.manager);i.setPath(this.path),i.setResponseType("arraybuffer"),i.setRequestHeader(this.requestHeader),i.setWithCredentials(this.withCredentials),t.endsWith(".spline")?console.warn(I1+" The .spline files are only meant to be used by the Editor."):t.endsWith(".splinecode")||console.warn(I1),i.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 x1(t,O1);e.version&&(0,N1.default)(e.version,"1.0.59")>0&&console.warn("Your .splinecode file is more recent than the library. Please upgrade @splinetool/loader to the latest version."),await Promise.allSettled([iv(e)&&sb(),yv(e)&&Yb(),Kv(e)&&Yv()].filter(Boolean));let r=new xi(e.shared);Object.values(r.getMaterials()).forEach(a=>Object.assign(a,{isAsset:!0}));let o=new Nd(e.scene,r),i=o.activeCamera;return i&&Object.assign(i,{makeDefault:!0}),o=_1(o),o=S1(o),o=w1(o),o=A1(o),o=P1(o),o=M1(o),o}};export{$h as default};