@splinetool/loader 2.0.84 → 2.0.86
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.
- package/build/SplineLoader.cjs +4 -4
- package/build/SplineLoader.js +4 -4
- package/package.json +1 -1
package/build/SplineLoader.cjs
CHANGED
|
@@ -725,7 +725,7 @@ void main() {
|
|
|
725
725
|
}
|
|
726
726
|
`;this.pyramidPassMaterial.fragmentShader=t,this.pyramidPassMaterial.uniforms=this.pyramidPassUniforms,this.pyramidPassMaterial.depthTest=!1,this.pyramidPassMaterial.depthWrite=!1;let e=new tn.Mesh(ed,this.pyramidPassMaterial);e.frustumCulled=!1,this.pyramidPassScene.add(e)}renderPyramid(t,e,r,n,o){new tn.Box2().min.setScalar(0);let s=e.length-1,l=new tn.Vector4;r.getViewport(l),this.pyramidPassUniforms.inputShiftX.value=0,this.pyramidPassUniforms.outputShiftX.value=0;let c=s-1;for(let u=c;u>=0;u--){let p=u%2===c%2?o[0]:o[1],h=u===c?n:u%2===c%2?o[1]:o[0];this.pyramidPassUniforms.inputTexture.value=h.textures.length>1?h.textures[1]:h.texture,this.pyramidPassUniforms.inputWidth.value="width"in h?h.width:1,this.pyramidPassUniforms.inputHeight.value="height"in h?h.height:1,r.setRenderTarget(p);let f=e[u],m=r.getPixelRatio();r.setViewport(this.pyramidPassUniforms.outputShiftX.value/m,0,f/m,f/m),u===2&&t%2!==0&&r.setViewport(this.pyramidPassUniforms.outputShiftX.value/m,0,3/m,3/m),r.render(this.pyramidPassScene,Np);let y=this.pyramidPassUniforms.inputShiftX.value;this.pyramidPassUniforms.inputShiftX.value=this.pyramidPassUniforms.outputShiftX.value,this.pyramidPassUniforms.outputShiftX.value=y,u<c&&(this.pyramidPassUniforms.outputShiftX.value+=e[u+1])}r.setViewport(l);let d=e.length%2===0?0:1;return r.readRenderTargetPixelsAsync(o[d],o[d].width-1,0,1,1,this.pyramidTopLevelReadPixelBuffer).then(()=>this.pyramidTopLevelReadPixelBuffer[0])}};gt();var _P=require("three"),Ut=class extends _P.Color{constructor(e,r,n,o){super(e,r,n);this.isColorA=!0;this.a=o}setRGBA(e,r,n,o){super.setRGB(e,r,n),this.a=o}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 n;if(e==="transparent")return this.setRGBA(0,0,0,0),this;if(n=/^((?:rgb|hsl)a?)\(([^)]*)\)/.exec(e)){let o,a=n[1],s=n[2];switch(a){case"rgb":case"rgba":if(o=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))return this.a=a==="rgba"?parseFloat(o[4]):1,super.setStyle(e,r);break;case"hsl":case"hsla":if(o=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)%\s*,\s*(\d*\.?\d+)%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))return this.a=a==="hsla"?parseFloat(o[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 Oa=class extends Ut{};var py=require("three");var cy=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.cleanupTimer=null;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,e.next=null,e.prev=null,e.data=null)}scheduleCleanup(){this.hasClean||(this.log("scheduled cleanup"),this.hasClean=!0,this.cleanupTimer=setTimeout(()=>{this.hasClean=!1,this.cleanupTimer=null,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);let r=e;e=e.next,e.prev=this.head,this.head.next=e,r.next=null,r.prev=null,r.data=null}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}disposeAll(){this.cleanupTimer!==null&&(clearTimeout(this.cleanupTimer),this.cleanupTimer=null),this.hasClean=!1,this.cache.forEach((t,e)=>{this.dispose(e,t.data),t.next=null,t.prev=null,t.data=null}),this.cache.clear(),this.head.next=this.tail,this.tail.prev=this.head}destroy(){this.disposeAll(),this.head=null,this.tail=null}};var H0=class extends cy{create(t){return URL.createObjectURL(new Blob([t]))}dispose(t,e){URL.revokeObjectURL(e)}},j0;function FP(i){return typeof i=="string"?i:(j0||(j0=new H0),j0.load(i))}var dy=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")}},uy=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 Ia=require("three"),kP=require("three/examples/jsm/loaders/HDRLoader.js");function W0(i){return i.length>2&&i[0]===35&&i[1]===63}function VP(i){try{let t=new kP.HDRLoader().parse(i.buffer.slice(i.byteOffset,i.byteOffset+i.byteLength));if(!t||!t.width||!t.height)return null;let{width:e,height:r}=t,n=t.data,o=new Uint16Array(n.length),a=e*4,s=d=>Ia.DataUtils.toHalfFloat(Math.pow(Math.max(Ia.DataUtils.fromHalfFloat(d),0),1/2.2)),l=new Map,c=d=>{let u=l.get(d);return u===void 0&&(u=s(d),l.set(d,u)),u};for(let d=0;d<r;d++){let u=d*a,p=(r-1-d)*a;for(let h=0;h<a;h+=4)o[p+h]=c(n[u+h]),o[p+h+1]=c(n[u+h+1]),o[p+h+2]=c(n[u+h+2]),o[p+h+3]=n[u+h+3]}return{isSplineHdr:!0,data:o,width:e,height:r}}catch{return null}}function GP(i){let t=new Ia.DataTexture(i.data,i.width,i.height,Ia.RGBAFormat,Ia.HalfFloatType);return t.flipY=!1,t.image.isSplineHdr=!0,t.needsUpdate=!0,t}var JF=0,td=class extends dy{constructor(e,r){super(e,r.imageHolderCache);this.data=e;this.shared=r;this.instanceId=++JF;this.loaded=!1;this.isVideo=!1;this.isBuffer=!1;this.isHdr=!1;this._cache={[1e3]:{},[1001]:{},[1002]:{}};this.isVideo=e.type==="video",this.isBuffer=e.isWebGLRenderTarget===!0,this.loadPromise=this.updateSrc(this.isBuffer?e:e.data)}async updateSrc(e){if(typeof document>"u")return;this.disposeTextures(),this.loaded=!1,this.isHdr=!1;let r=()=>{this.loaded=!0;for(let n of Object.values(this._cache))for(let o of Object.values(n))for(let a of Object.values(o))a&&(a.image=this.img,a.needsUpdate=!0);this.shared.requestRender()};if(this.isBuffer)this.img=e,this.loaded=!0;else if(this.isVideo){if(this.img=document.createElement("video"),this.img.preload="auto",this.img.playsInline=!0,this.img.currentTime=.01,typeof e!="string"){let n=new FileReader;n.readAsDataURL(new Blob([e],{type:"video/mp4"}));let o;await new Promise(a=>{n.onloadend=s=>{o=s.target?.result,a(null)}}),this.img.src=o}else this.img.src=e;this.img.onloadeddata=()=>{r()}}else if(e instanceof Uint8Array?W0(e):typeof e=="string"&&/\.hdr($|[?#])/i.test(e)){let n=e instanceof Uint8Array?e:null;if(n===null)try{n=new Uint8Array(await(await fetch(e)).arrayBuffer())}catch{n=null}let o=n!==null&&W0(n)?VP(n):null;o!==null&&(this.isHdr=!0,this.img=o,r())}else this.img=new Image,this.img.src=FP(e),this.img.onload=r,await new Promise(n=>{this.img.onload=()=>{r(),n(null)}})}getTexture(e,r=1008,n=1006){let o=this._cache[e]?.[r]?.[n];if(o)return o;{let a;return this.isBuffer?a=this.img.texture:this.isVideo?a=new py.VideoTexture(this.img,void 0,e,e):this.isHdr?(a=GP(this.img),a.wrapS=e,a.wrapT=e,a.magFilter=n,a.minFilter=r):a=new py.Texture(this.img,void 0,e,e,n,r),this.isBuffer||(a.anisotropy=8,a.generateMipmaps=r===1008),this.loaded&&(a.needsUpdate=!0),this._cache[e]===void 0&&(this._cache[e]={}),this._cache[e][r]===void 0&&(this._cache[e][r]={}),this._cache[e][r][n]=a,a}}setNeedsUpdate(e){if(!this.isBuffer)for(let r of Object.values(this._cache))for(let n of Object.values(r))for(let o of Object.values(n))o&&(o.needsUpdate=e)}disposeTextures(){for(let[e,r]of Object.entries(this._cache))for(let[n,o]of Object.entries(r))for(let[a,s]of Object.entries(o))s?.dispose(),this._cache[e]!==void 0&&this._cache[e][n]!==void 0&&(this._cache[e][n][a]=void 0)}dispose(){super.dispose(),this.disposeTextures()}};var di=class extends td{};var UP=new Map;function zP(i){if(typeof i=="string")return i;let t=UP.get(i);return t||(t={url:URL.createObjectURL(new Blob([i]))},UP.set(i,t)),t.url}var $F,jP=new Promise(i=>{$F=i});var HP;jP.then(i=>HP=i);var Da=class{constructor({src:t,volume:e,delay:r,loop:n}){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 o;typeof t=="string"?o={src:t}:o={src:zP(t),format:"wav"},this.sound=new HP.Howl(o),this.sound.on("end",this.onEnd),this.src=t,e!==void 0&&(this.volume=e),r!==void 0&&(this.delay=r),n!==void 0&&(this.loop=n)}get status(){return this._status}get volume(){return this._volume}set volume(t){this._volume=t,this.sound.volume(t)}get loop(){return this._loop}set loop(t){this._loop=t,this.loopsRemaining=t}replay(){this.clearDelay(),this.delayTimerId=window.setTimeout(()=>{this.sound.play(),this.clearDelay()},this.delay)}fade(t,e=1e3){t?(this.sound.volume(this._volume),this.clearFade(),this.fadeTimerId=window.setTimeout(()=>{this.sound.fade(this._volume,0,e),this.clearFade()},t)):this.sound.fade(this._volume,0,e)}on(t,e,r){this.sound.on(t,e,r)}off(t,e,r){this.sound.off(t,e,r)}play(){this._status==="playing"||this.sound.playing()||(this._status==="paused"?(this.sound.seek()===0?this.replay():this.sound.play(),this._status="playing"):this._status==="stopped"&&(this.replay(),this._status="playing"))}pause(){this._status==="playing"&&(this.sound.pause(),this.clearFade(),this.clearDelay(),this._status="paused")}stop(){this.sound.stop(),this.loopsRemaining=this._loop,this.clearFade(),this.clearDelay(),this._status="stopped"}clearFade(){this.fadeTimerId&&(clearTimeout(this.fadeTimerId),delete this.fadeTimerId)}clearDelay(){this.delayTimerId&&(clearTimeout(this.delayTimerId),delete this.delayTimerId)}dispose(t=!1){this.off(),this.stop(),this.clearFade(),this.clearDelay()}};var WP=null;function qP(i){WP=i}function XP(){return WP}function q0(i){let t=!1;return i.scene.objects.traverse((e,r)=>{r.type==="Mesh"&&(r.geometry.type==="TextGeometry"||r.geometry.type==="InputGeometry")&&(t=!0)}),t}var r2=require("three");var vs=require("three");var Dr=require("three"),hy=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=i.parameters?.radiusTop,r=i.parameters?.radiusBottom,n=Object.assign({},t?.parameters??{width:100,radialSegments:64,heightSegments:1,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadius:8,cornerSegments:8,hollow:0},i.parameters);n.thetaLength=Dr.MathUtils.clamp(n.thetaLength,0,360),n.hollow=Dr.MathUtils.clamp(n.hollow??0,0,1);let o=n.width/2,a=n.radiusTop??o,s=n.radiusBottom??o;if(a===s?(a=o,s=o):a>s?(a=o,s=s*o/a):(a=a*o/s,s=o),n.shapeBlendNode){a=e??o,s=r??o;let l=Math.max(a,s)*2;n.width=l,n.depth=l}return{parameters:Object.assign(n,{width:Math.abs(n.width),height:Math.abs(n.height??n.width),depth:Math.abs(n.depth??n.width),radiusTop:a,radiusBottom:s})}}static build(i){let{width:t,depth:e,height:r,radialSegments:n,heightSegments:o,openEnded:a,thetaStart:s,thetaLength:l,radiusTop:c,radiusBottom:d,cornerRadius:u,cornerSegments:p,hollow:h}=i.parameters,f;l===0?(f=new Dr.BufferGeometry,f.setAttribute("position",new Dr.Float32BufferAttribute([],3))):u||h?f=new Lp(c,d,r,n,o,a,s,l*Math.PI/180,u,u,p,h):f=new Dr.CylinderGeometry(c,d,r,n,o,a,s,l*Math.PI/180);let m=e/t;return m!==1&&f.scale(1,1,m),Object.assign(f,{userData:{...i,type:"CylinderGeometry"}})}};function YP(i){return new Dr.Vector2(i.y,-i.x)}var Lp=class extends Dr.BufferGeometry{constructor(t,e,r,n,o,a,s,l,c,d,u,p,h=!1){super(),this.type="RoundedCylinderBufferGeometry",t=t!==void 0?t:1,e=e!==void 0?e:1,r=r||1,n=Math.floor(n)||8,o=Math.floor(o)||1,a=a!==void 0?a:!1,s=s!==void 0?s:0,l=l!==void 0?l:Math.PI*2,a&&(c=0,d=0);let f=r/2;h&&t==0&&(t=c),h&&e==0&&(e=d);let m=new Dr.Vector2(t,f),y=new Dr.Vector2(e,-f),g=null,v=null,b=null,S=null,x=m.clone().sub(y),w=0,A=0,C=0;p>0&&(w=Math.min(t,e)*(1-p),A=t-w,C=e-w);let P=m.clone();P.x-=w;let M=Math.PI-x.angle(),B=x.angle(),I=Math.tan(B/2),_=Math.tan(M/2),E=I+_,R=p?E:_,L=p?E:I;if(c=Math.min(c,(t-A)/R,x.length()/E),d=Math.min(d,(e-C)/L,x.length()/E),c>0){let ae=c/I;g=m.clone().sub(new Dr.Vector2(ae,c)),p&&(b=g.clone(),b.x-=w-E*c),m.sub(x.clone().setLength(ae))}if(d>0){let ae=d/_;v=y.clone().sub(new Dr.Vector2(ae,-d)),y.add(x.clone().setLength(ae)),p&&(S=v.clone(),S.x-=w-E*d,P.sub(x.clone().setLength(ae)))}x=m.clone().sub(y);let F=x.length()<.5,k=[],W=[],U=[],G=[],q=[],X=[],Y=(ae,be,D,ie,Ke)=>{for(let Ie=0;Ie<u+1;Ie++){let Xe=Ie/u,Ee=ie<0?Xe:1-Xe;Ke&&(Ee-=1),Ee*=ae;let Ue=Math.sin(Ee),qe=Math.cos(Ee)*ie,$e=qe*be+D.y;k.push(Ue*be+D.x),W.push($e),U.push(Ue),G.push(qe),q.push(.5+$e/r),X.push(!1)}},K=(ae,be,D)=>{let ie=[ae,be];D<0&&ie.reverse();for(let Ke of ie)k.push(Ke),W.push(f*D),U.push(0),G.push(D),q.push(.5),X.push(!0)};if(S&&v?(Y(M,d,S,-1,!0),Y(B,d,v,-1,!1)):v?(K(v.x,0,-1),Y(B,d,v,-1,!1)):a||K(e,C,-1),!F){let ae=YP(x).normalize();for(let be=0;be<=o;be++){let D=be/o,ie=x.y*D+y.y;k.push(x.x*D+y.x),W.push(ie),U.push(ae.x),G.push(ae.y),q.push(.5+ie/r),X.push(!1)}}if(b&&g?(Y(M,c,g,1,!1),Y(B,c,b,1,!0)):g?(Y(M,c,g,1,!1),K(g.x,0,1)):a||K(t,A,1),p&&!F){let ae=YP(x).multiplyScalar(-1).normalize();for(let be=0;be<=o;be++){let D=be/o,ie=x.y*-D+P.y;k.push(x.x*-D+P.x),W.push(ie),U.push(ae.x),G.push(ae.y),q.push(.5+ie/r),X.push(!1)}}let te=k.length,se=te+(p&&!a?1:0),ce=(ae,be)=>ae*te+(be===te?0:be),de=l<Math.PI*2,ge=(n+1)*te+(de?2*(1+se):0),xe=new Float32Array(ge*3),ye=new Float32Array(ge*3),Z=new Float32Array(ge*2),pe=ge-1>65535?new Uint32Array(n*Math.max(0,se-1)*6+(de?2*(se+1)*3:0)):new Uint16Array(n*Math.max(0,se-1)*6+(de?2*(se+1)*3:0)),re=0,Se=0;for(let ae=0;ae<=n;ae++){let be=ae/n,D=be*l+s,ie=Math.sin(D),Ke=Math.cos(D);for(let Ie=0;Ie<te;Ie++){let Xe=Se*3,Ee=Se*2,Ue=k[Ie],qe=U[Ie];xe[Xe]=Ue*ie,xe[Xe+1]=W[Ie],xe[Xe+2]=Ue*Ke,ye[Xe]=qe*ie,ye[Xe+1]=G[Ie],ye[Xe+2]=qe*Ke,X[Ie]?(Z[Ee]=.5,Z[Ee+1]=.5):(Z[Ee]=be,Z[Ee+1]=q[Ie]),Se++}}for(let ae=0;ae<n;ae++)for(let be=0;be<se-1;be++){if(a&&p&&be==o)continue;let D=ce(ae,be),ie=ce(ae+1,be),Ke=ce(ae+1,be+1),Ie=ce(ae,be+1),Xe=xe[Ke*3+0],Ee=xe[Ke*3+2];pe[re++]=D,pe[re++]=ie,pe[re++]=Ie,(Xe!=0||Ee!=0)&&(pe[re++]=ie,pe[re++]=Ke,pe[re++]=Ie)}de&&(Ce(-1,0,s),Ce(1,n*te,s+l)),this.setIndex(new Dr.BufferAttribute(pe.slice(0,re),1)),this.setAttribute("position",new Dr.BufferAttribute(xe,3)),this.setAttribute("normal",new Dr.BufferAttribute(ye,3)),this.setAttribute("uv",new Dr.BufferAttribute(Z,2));function Ce(ae,be,D){let ie=Math.sin(D),Ke=Math.cos(D),Ie=-Ke,Xe=ie,Ee=ae<0?(De,Et,nt)=>{pe[re++]=De,pe[re++]=Et,pe[re++]=nt}:(De,Et,nt)=>{pe[re++]=De,pe[re++]=nt,pe[re++]=Et},Ue=(t+e+A+C)/4,qe=Se*3,$e=Se*2;xe[qe]=Ue*ie,xe[qe+1]=0,xe[qe+2]=Ue*Ke,ye[qe]=Ie,ye[qe+1]=0,ye[qe+2]=Xe,Z[$e]=.5,Z[$e+1]=.5;let Vt=Se++;for(let De=0;De<se;De++){let Et=(be+(De===te?0:De))*3;qe=Se*3,$e=Se*2,xe[qe]=xe[Et],xe[qe+1]=xe[Et+1],xe[qe+2]=xe[Et+2],ye[qe]=Ie,ye[qe+1]=0,ye[qe+2]=Xe;let nt=Et/3*2|0;Z[$e]=Z[nt],Z[$e+1]=Z[nt+1],Se++}for(let De=Vt+1;De<Se-1;De++)Ee(Vt,De,De+1);Ee(Vt,Se-1,Vt+1)}}};var QP=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,radialSegments:32,heightSegments:8,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadiusTop:8,cornerRadiusBottom:8,cornerSegments:8},i.parameters);return e.thetaLength=vs.MathUtils.clamp(e.thetaLength,0,360),{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(i){let{width:t,depth:e,height:r,radialSegments:n,heightSegments:o,openEnded:a,thetaStart:s,thetaLength:l,cornerRadiusTop:c,cornerRadiusBottom:d,cornerSegments:u}=i.parameters,p;l===0?(p=new vs.BufferGeometry,p.setAttribute("position",new vs.Float32BufferAttribute([],3))):c>0||d>0||l<360?p=new Lp(0,t/2,r,n,o,a,s,l*Math.PI/180,c,d,u,0,!0):p=new vs.ConeGeometry(t/2,r,n,o,a);let h=e/t;return h!==1&&p.scale(1,1,h),Object.assign(p,{userData:{...i,type:"ConeGeometry"}})}};var Yn=require("three"),KP=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,widthSegments:1,heightSegments:1,depthSegments:1,cornerRadius:8,cornerSegments:8},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(i){let{width:t,height:e,depth:r,widthSegments:n,heightSegments:o,depthSegments:a,cornerRadius:s,cornerSegments:l}=i.parameters,c;return s===0?c=new Yn.BoxGeometry(t,e,r,n,o,a):c=new Y0(t,e,r,n,o,a,s,l),Object.assign(c,{userData:{...i,type:"CubeGeometry"}})}},X0=Math.PI/2,Y0=class extends Yn.BufferGeometry{constructor(t=1,e=1,r=1,n=1,o=1,a=1,s=0,l=4){super(),this.type="BoxGeometry",n=Math.floor(n),o=Math.floor(o),a=Math.floor(a),l=Math.floor(l),s=Math.min(s,t/2,e/2,r/2);let c=s>0,d=l+1,p=2*((a+1)*(o+1)+(n+1)*(a+1)+(n+1)*(o+1))+(c?d*4*(a+1+(n+1)+(o+1))+8*(d*(d+1)/2):0),h=2*(a*o+n*a+n*o)+(c?l*4*(a+n+o):0),f=c?8*l*l:0,m=new Float32Array(p*3),y=new Float32Array(p*3),g=new Float32Array(p*2),v=p-1>65535?new Uint32Array(h*6+f*3):new Uint16Array(h*6+f*3),b=0,S=0,x=new Float64Array(d),w=new Float64Array(d),A=new Float64Array(d),C=new Float64Array(d);for(let R=0;R<d;R++){let L=R/l*X0;x[R]=Math.sin(L)*s,w[R]=(1-Math.cos(L))*s,A[R]=Math.sin(L),C[R]=Math.cos(L)}let P=d*(d+1)/2,M=new Float64Array(P*3),B=new Float64Array(P*3);{let R=new Yn.Vector3(t/2,e/2,r/2);R.subScalar(s);let L=0;for(let F=0;F<=l;F++){let k=X0*(1-F/l),W=Math.cos(k),U=Math.sin(k),G=0;for(let q=0;q<=F;q++){let X=Math.cos(G),Y=Math.sin(G),K=W*X,te=U,ue=W*Y;M[L*3]=K,M[L*3+1]=te,M[L*3+2]=ue,B[L*3]=R.x+K*s,B[L*3+1]=R.y+te*s,B[L*3+2]=R.z+ue*s,L++,G+=X0/F}}}I("z","y","x",-1,-1,r,e,t,a,o),I("z","y","x",1,-1,r,e,-t,a,o),I("x","z","y",1,1,t,r,e,n,a),I("x","z","y",1,-1,t,r,-e,n,a),I("x","y","z",1,-1,t,e,r,n,o),I("x","y","z",-1,-1,t,e,-r,n,o),s>0&&(_("z","y","x",-1,-1,1,r,e,t,a),_("z","y","x",1,-1,-1,r,e,t,a),_("z","y","x",-1,1,-1,r,e,t,a),_("z","y","x",1,1,1,r,e,t,a),_("x","y","z",-1,-1,-1,t,e,r,n),_("x","y","z",1,-1,1,t,e,r,n),_("x","y","z",-1,1,1,t,e,r,n),_("x","y","z",1,1,-1,t,e,r,n),_("y","x","z",-1,-1,1,e,t,r,o),_("y","x","z",1,-1,-1,e,t,r,o),_("y","x","z",1,1,1,e,t,r,o),_("y","x","z",-1,1,-1,e,t,r,o),E(1,1,1),E(-1,1,1),E(1,-1,1),E(-1,-1,1),E(1,1,-1),E(-1,1,-1),E(1,-1,-1),E(-1,-1,-1)),this.setIndex(new Yn.BufferAttribute(v,1)),this.setAttribute("position",new Yn.BufferAttribute(m,3)),this.setAttribute("normal",new Yn.BufferAttribute(y,3)),this.setAttribute("uv",new Yn.BufferAttribute(g,2));function I(R,L,F,k,W,U,G,q,X,Y){let K=(U-2*s)/X,te=(G-2*s)/Y,ue=U/2-s,se=G/2-s,ce=q/2,de=X+1,ge=Y+1,xe=0,ye=new Yn.Vector3;for(let Z=0;Z<ge;Z++){let pe=Z*te-se;for(let re=0;re<de;re++){let Se=re*K-ue,Ce=(b+xe)*3,ae=(b+xe)*2;ye[R]=Se*k,ye[L]=pe*W,ye[F]=ce,m[Ce]=ye.x,m[Ce+1]=ye.y,m[Ce+2]=ye.z,ye[R]=0,ye[L]=0,ye[F]=q>0?1:-1,y[Ce]=ye.x,y[Ce+1]=ye.y,y[Ce+2]=ye.z,g[ae]=re/X,g[ae+1]=1-Z/Y,xe+=1}}for(let Z=0;Z<Y;Z++)for(let pe=0;pe<X;pe++){let re=b+pe+de*Z,Se=b+pe+de*(Z+1),Ce=b+(pe+1)+de*(Z+1),ae=b+(pe+1)+de*Z;v[S++]=re,v[S++]=Se,v[S++]=ae,v[S++]=Se,v[S++]=Ce,v[S++]=ae}b+=xe}function _(R,L,F,k,W,U,G,q,X,Y){let K=(G-2*s)/Y,te=G/2-s,ue=q/2-s,se=X/2,ce=Y+1,de=0,ge=new Yn.Vector3,xe=new Yn.Vector3;for(let ye=0;ye<l+1;ye++){ge[L]=(ue+x[ye])*W,ge[F]=(se-w[ye])*U,xe[R]=0,xe[L]=A[ye]*Math.sign(ge[L]),xe[F]=C[ye]*Math.sign(ge[F]);for(let Z=0;Z<ce;Z++){let pe=Z*K-te;ge[R]=pe*k;let re=(b+de)*3,Se=(b+de)*2;m[re]=ge.x,m[re+1]=ge.y,m[re+2]=ge.z,y[re]=xe.x,y[re+1]=xe.y,y[re+2]=xe.z,g[Se]=Z/Y,g[Se+1]=0,de+=1}}for(let ye=0;ye<l;ye++)for(let Z=0;Z<Y;Z++){let pe=b+Z+ce*ye,re=b+Z+ce*(ye+1),Se=b+(Z+1)+ce*(ye+1),Ce=b+(Z+1)+ce*ye;v[S++]=pe,v[S++]=re,v[S++]=Ce,v[S++]=re,v[S++]=Se,v[S++]=Ce}b+=de}function E(R,L,F){let W=R*L*F>0?(G,q,X)=>{v[S++]=G,v[S++]=q,v[S++]=X}:(G,q,X)=>{v[S++]=G,v[S++]=X,v[S++]=q},U=b;for(let G=0;G<P;G++){let q=G*3,X=b*3,Y=b*2;m[X]=R*B[q],m[X+1]=L*B[q+1],m[X+2]=F*B[q+2],y[X]=R*M[q],y[X+1]=L*M[q+1],y[X+2]=F*M[q+2],g[Y]=0,g[Y+1]=0,b++}for(let G=0;G<l;G++){let q=U+G*(G+1)/2,X=U+(G+1)*(G+2)/2;W(q,X+1,X);for(let Y=1;Y<=G;Y++)W(q+Y-1,q+Y,X+Y),W(q+Y,X+Y+1,X+Y)}}}};var ur=require("three"),bs=class extends ur.BufferGeometry{constructor(t=[],e=[],r="",n=1,o=.2,a=4){super(),this.type="PolyhedronGeometryRound";let s,l,c,d=0;u(),p(),this.setAttribute("position",new ur.BufferAttribute(new Float32Array(s.subarray(0,d)),3)),this.setAttribute("normal",new ur.BufferAttribute(new Float32Array(l.subarray(0,d)),3)),this.setAttribute("uv",new ur.BufferAttribute(new Float32Array(c.subarray(0,d/3*2)),2));return;function u(){o=Math.min(1-1e-5,o),o==0&&(a=0);let f={IcosahedronGeometry:5,DodecahedronGeometry:3,HexahedronGeometry:3,OctahedronGeometry:4,TetrahedronGeometry:3}[r],m=new ur.Vector3,y=m.clone(),g=new ur.Triangle,v=o*n,b=n-v,S=a+1,x=new ur.Vector3,w=(Z,pe)=>x.subVectors(Z,pe).normalize(),A=(Z,pe)=>Array(Z).fill(void 0).map(pe),C=A(t.length/3,(Z,pe)=>new ur.Vector3().fromArray(t,pe*3).setLength(n)),P=[],M=1e6;for(let Z=0;Z<C.length;Z++){let pe=C[Z],re=[],Se,Ce,ae,be=1e10,D=-1;for(;(D=e.indexOf(Z,D+1))!=-1;){let Xe=D-D%3;Se=e[Xe+(D+1)%3],Ce=e[Xe+(D+2)%3],ae=pe.distanceToSquared(C[Se]),be=Math.min(be,ae),re.push([Se,Ce,ae])}be+=1e-6;let ie=[],Ke=0,Ie=re.length;for(let Xe=0;Xe<Ie;Xe++){[Se,Ce,ae]=re[Ke];let Ee=P[Se]?.includes(Z)==!0;ae<=be&&ie.push(Se+ +Ee*M),Ke=re.findIndex(Ue=>Ue[0]==Ce)}P.push(ie)}let B=[];{let Z=0,pe=0,re,Se,Ce=f==3;for(let ae=0;ae<=a;ae++){re=ae*(ae+1)/2,Se=(ae+1)*(ae+2)/2;for(let be=0;be<a-ae;be++)[Z,pe]=[re+be+ae+2,Se+be+ae+3],B.push(re,Se,...Ce?[pe,re]:[Z,Se],pe,Z),[re,Se]=[Z,pe];B.push(re,Se,re+a+2)}}let I=0;for(let Z=0;Z<P.length;Z++)for(let pe=0;pe<f;pe++)P[Z][pe]<M&&I++;let _=C.length*f*B.length*3,E=I*S*6*3,R=I*2*3*3,L=_+E+R;s=new Float64Array(L),l=new Float64Array(L),c=new Float64Array(L/3*2);let F=(Z,pe,re)=>{let Se=d/3*2;c[Se]=Math.atan2(re,-Z)/2/Math.PI+.5,c[Se+1]=1-(Math.atan2(-pe,Math.sqrt(Z*Z+re*re))/Math.PI+.5)},k=Z=>{s[d]=Z.x,s[d+1]=Z.y,s[d+2]=Z.z,l[d]=x.x,l[d+1]=x.y,l[d+2]=x.z,F(Z.x,Z.y,Z.z),d+=3},W=Z=>{s[d]=Z[0].x,s[d+1]=Z[0].y,s[d+2]=Z[0].z,l[d]=Z[1].x,l[d+1]=Z[1].y,l[d+2]=Z[1].z,F(Z[0].x,Z[0].y,Z[0].z),d+=3},U=(a+2)*(a+3)/2,G=new Float64Array(U*3),q=new Float64Array(U*3),X=new Float64Array(U*2),Y=A(f*2*S,()=>new ur.Vector3),K=A(a*Math.max(0,a-1)/2,()=>new ur.Vector3),te=m.clone(),ue=m.clone(),se=m.clone(),ce=m.clone(),de=m.clone(),ge=[],xe=A(C.length,()=>A(f,()=>m.clone()));for(let Z=0;Z<C.length;Z++){m.copy(C[Z]).normalize(),te.copy(m).multiplyScalar(b);let pe=P[Z];for(let ie=0;ie<pe.length;ie++){let Ke=pe[ie],Ie=pe[(ie+1)%f];g.setFromPointsAndIndices(C,Z,Ke%M,Ie%M),g.b.sub(g.a).setLength(1e10).add(g.a),g.c.sub(g.a).setLength(1e10).add(g.a),g.closestPointToPoint(te,xe[Z][ie])}let re=0,Se=[],Ce=[],ae=new ur.Vector3;a==0&&[...xe[Z]].reduce((ie,Ke)=>ie.add(Ke),ae).multiplyScalar(1/f);for(let ie=0;ie<f;ie++){let Ke=[],Ie=(ie-1+f)%f,Xe=xe[Z][Ie],Ee=xe[Z][ie];m.copy(Xe).sub(te),y.copy(Ee).sub(te);let Ue=te.angleTo(m),qe=m.angleTo(y),$e=Math.cos(Ue)*v;a==0?ue.copy(ae):ue.copy(te).setLength(b+$e),Se.push($e);let Vt=[ue,Xe,Ee];for(let De=0;De<2;De++){let Et=Vt[De],nt=Vt[De+1];ce.subVectors(Et,te),de.subVectors(nt,te),se.crossVectors(ce,de).normalize();for(let $s=0;$s<S;$s++){let Ku=[Ue,qe][De]*$s/S;m.copy(ce).applyAxisAngle(se,Ku).add(te),Y[re++].copy(m),De&&(w(m,te),Ke.push([$s==0?Et:m.clone(),x.clone()]))}De&&(w(nt,te),Ke.push([nt,x.clone()]))}Ce.push(Ke)}ge.push(Ce);let be=2*S,D=2;for(let ie=0;ie<f;ie++){let Ke=be*ie,Ie=be*((ie+1)%f),Xe=0,Ee=[Y[Ke]];for(let Ue=1;Ue<S;Ue++){let qe=Y[Ke+Ue],$e=Y[Ie+Ue];Ee.push(qe);for(let Vt=1,De=Ue-D+1;Vt<=De;Vt++)m.lerpVectors(qe,$e,Vt/(De+1)),m.sub(te).setLength(Se[ie]).add(te),Ee.push(K[Xe++].copy(m));Ee.push($e)}for(let Ue=0;Ue<S;Ue++)Ee.push(Y[Ue+S+Ke]);Ee.push(Y[Ie+S]);for(let Ue=0,qe=Ee.length;Ue<qe;Ue++){let $e=Ee[Ue],Vt=Ue*3,De=Ue*2;G[Vt]=$e.x,G[Vt+1]=$e.y,G[Vt+2]=$e.z,w($e,te),q[Vt]=x.x,q[Vt+1]=x.y,q[Vt+2]=x.z,X[De]=Math.atan2($e.z,-$e.x)/2/Math.PI+.5,X[De+1]=1-(Math.atan2(-$e.y,Math.sqrt($e.x*$e.x+$e.z*$e.z))/Math.PI+.5)}for(let Ue=0,qe=B.length;Ue<qe;Ue++){let $e=B[Ue]*3,Vt=B[Ue]*2,De=d/3*2;s[d]=G[$e],s[d+1]=G[$e+1],s[d+2]=G[$e+2],l[d]=q[$e],l[d+1]=q[$e+1],l[d+2]=q[$e+2],c[De]=X[Vt],c[De+1]=X[Vt+1],d+=3}}}let ye=[];for(let Z=0;Z<P.length;Z++)for(let pe=0;pe<f;pe++){let re=P[Z][pe];if(re<M){let Se=P[re].findIndex(be=>be%M==Z),Ce=ge[Z][pe],ae=ge[re][Se];for(let be=0;be<S;be++){let D=Ce[be],ie=ae[S-be],Ke=Ce[be+1],Ie=ae[S-(be+1)];W(D),W(ie),W(Ke),W(Ke),W(ie),W(Ie)}ye.push(Ce[0][0],ae[S][0],Ce[S][0],ae[0][0])}}for(;ye.length;){let Z,pe,re,[Se,Ce]=ye.splice(0,2);Z=Ce;let ae=[Se];for(;Se!=Z;)ae.push(Z),pe=ye.indexOf(Z),re=pe%2,Z=ye.splice(pe-re,2)[1-re];x.subVectors(ae[0],ae[1]).cross(m.subVectors(ae[0],ae[2])).normalize();let be=x.dot(ae[0])<0;be&&x.negate();for(let D=1;D<=ae.length-2;D++)k(ae[D+ +be]),k(ae[D+1-+be]),k(ae[0])}}function p(){let h=new ur.Vector3,f=new ur.Vector3,m=new ur.Vector3,y=new ur.Vector3,g=new ur.Vector2,v=new ur.Vector2,b=new ur.Vector2,S=(A,C,P,M)=>{M<0&&A.x===1&&(c[C]=A.x-1),P.x===0&&P.z===0&&(c[C]=M/2/Math.PI+.5)};for(let A=0,C=0;A<d;A+=9,C+=6){h.set(s[A+0],s[A+1],s[A+2]),f.set(s[A+3],s[A+4],s[A+5]),m.set(s[A+6],s[A+7],s[A+8]),g.set(c[C+0],c[C+1]),v.set(c[C+2],c[C+3]),b.set(c[C+4],c[C+5]),y.copy(h).add(f).add(m).divideScalar(3);let P=w(y);S(g,C+0,h,P),S(v,C+2,f,P),S(b,C+4,m,P)}let x=d/3*2;for(let A=0;A<x;A+=6){let C=c[A+0],P=c[A+2],M=c[A+4],B=Math.max(C,P,M),I=Math.min(C,P,M);B>.9&&I<.1&&(C<.2&&(c[A+0]+=1),P<.2&&(c[A+2]+=1),M<.2&&(c[A+4]+=1))}function w(A){return Math.atan2(A.z,-A.x)}}}static fromJSON(t){return new bs(t.vertices,t.indices,t.radius,t.corner,t.cornerSides)}};var ZP=require("three"),JP=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,detail:0,corner:0,cornerSides:4},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(i){let{width:t,height:e,depth:r,detail:n,corner:o,cornerSides:a}=i.parameters,s=n===0&&o!==0?new _p(t*.5,o,a):new ZP.DodecahedronGeometry(t*.5,n),l=e/t,c=r/t;return(l!==1||c!==1)&&s.scale(1,l,c),Object.assign(s,{userData:{...i,type:"DodecahedronGeometry"}})}},_p=class extends bs{constructor(t=1,e=.2,r=4){let n=(1+Math.sqrt(5))/2,o=1/n,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,-o,-n,0,-o,n,0,o,-n,0,o,n,-o,-n,0,-o,n,0,o,-n,0,o,n,0,-n,0,-o,n,0,-o,-n,0,o,n,0,o],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 _p(t.radius,t.corner,t.cornerSides)}};var dt=require("three");var Qe=require("three"),Fp=1e-12,rd=class{constructor(t){this.position=new Qe.Vector2;this.startPosition=new Qe.Vector2;this.uuid=Qe.MathUtils.generateUUID();this.position=t.clone()}start(){this.reset()}reset(){this.startPosition.copy(this.position)}applyOffset(t){this.position.copy(this.startPosition).add(t)}copy(t){return this.position.copy(t.position),this.startPosition.copy(t.startPosition),this}clone(){return new rd(this.position).copy(this)}toJSON(){return[this.position.x,this.position.y]}},nd=class extends rd{constructor(e){super(e.position);this.parent=e}copy(e){return super.copy(e),this}clone(){return new nd(this.parent).copy(this)}},co=class extends rd{constructor(e,r){super(r);this.controls=[];this.roundness=0;this.areControlsDirectionsMirrored=!0;this.uuid=e,this.controls.push(new nd(this),new nd(this))}static create(e,r){let n=new co(e,new Qe.Vector2(...r.position));return n.controls[0].position.set(...r.controlPrevious.position),n.controls[1].position.set(...r.controlNext.position),n.roundness=r.roundness,n.areControlsDirectionsMirrored=r.areControlsDirectionsMirrored,n}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 n=0,o=this.controls.length;n<o;n++){let a=this.controls[n];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 co(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 Qe.Vector2,r=new Qe.Vector2){let[n,o]=this.computeTangents();return n&&o&&($P(n,e),$P(o,r)),[e,r]}computeTangent(e=new Qe.Vector2){let[r,n]=this.computeTangents();return r&&n&&e.copy(r).add(n).normalize(),e}computeNormal(e=new Qe.Vector2){let[r,n]=this.computeNormals();return e.copy(r).add(n).normalize(),e}};function $P(i,t=new Qe.Vector2){let e=i.length();return t.set(-i.y/e,i.x/e)}var K0=i=>i,id=new Qe.Vector2,fy=new Qe.Vector2,ek=new Qe.Vector2,tk=new Qe.Vector2,rk=new Qe.Vector2,nk=new Qe.Vector2,tM=new Qe.Vector3,rM=new Qe.Vector3;function nM(i){let t=new Qe.Vector2;t.addVectors(i.v0,id.subVectors(i.v1,i.v0).multiplyScalar(2/3));let e=new Qe.Vector2;return e.addVectors(i.v2,fy.subVectors(i.v1,i.v2).multiplyScalar(2/3)),new Qe.CubicBezierCurve(i.v0,t,e,i.v2)}function kp(i,t,e=Number.EPSILON){return Math.abs(i-t)<e}function ik(i,t,e=Number.EPSILON){return i.distanceTo(t)<e}function ok(i,t,e=Number.EPSILON){return i.distanceTo(t)<e}function Z0(i,t,e){let r=Math.sqrt(Math.pow(t.x-i.x,2)+Math.pow(t.y-i.y,2)),n=Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2)),o=Math.sqrt(Math.pow(e.x-i.x,2)+Math.pow(e.y-i.y,2));return Math.acos((n*n+r*r-o*o)/(2*n*r))}function iM(i,t,e){return eM(i,t)&&eM(t,e)&&Q0(i.position,t.position,e.position)}function Q0(i,t,e){return id.copy(t).sub(i).cross(fy.copy(e).sub(i))===0}function oM(i,t,e,r,n){let o=Math.sqrt(Math.pow(t.x-i.x,2)+Math.pow(t.y-i.y,2)),a=(i.y+t.y)/2,s=(i.x+t.x)/2,l=Math.sqrt(Math.pow(e,2)-Math.pow(o/2,2))*(i.y-t.y)/o,c=Math.sqrt(Math.pow(e,2)-Math.pow(o/2,2))*(t.x-i.x)/o;return r.set(s+l,a+c),n.set(s-l,a-c),[r,n]}function aM(i,t,e){let r=i.distanceTo(e),n=t.distanceTo(e);return r<n?t:i}function sM(i,t,e,r,n,o){let a=t.x-i.x,s=t.y-i.y,l=e.x-i.x,c=e.y-i.y,d=Math.sqrt((a+l)*(a+l)+(s+c)*(s+c)),u;return Z0(t,i,e)>Math.PI&&(d*=-1),kp(c,s)?u=(s+c)*(r/d-.5)*8/3/(a-l):u=(a+l)*(r/d-.5)*8/3/(c-s),n.set(t.x-u*s,t.y+u*a),o.set(e.x+u*c,e.y-u*l),[n,o]}function J0(i,t){return i.position.equals(i.controls[1].position)&&t.position.equals(t.controls[0].position)}function eM(i,t){return Q0(i.position,i.controls[1].position,t.position)&&Q0(i.position,t.controls[0].position,t.position)}function lM(i,t,e,r,n=.5){let o=id.subVectors(t,i).multiplyScalar(n).add(i),a=fy.subVectors(e,t).multiplyScalar(n).add(t),s=ek.subVectors(r,e).multiplyScalar(n).add(e),l=o,c=tk.subVectors(a,o).multiplyScalar(n).add(o),d=rk.subVectors(s,a).multiplyScalar(n).add(a),u=s,p=nk.subVectors(d,c).multiplyScalar(n).add(c);return[i.x,i.y,l.x,l.y,c.x,c.y,p.x,p.y,d.x,d.y,u.x,u.y,r.x,r.y]}function cM(i,t,e=12,r=!0){let n=rM.set(0,0,0),o,a=0,s=[];for(let l=0;l<t.length;l++){let c=K0(t[l]),d=id,u=xs(c,e);s.push(u);for(let p=0;p<=u;p++)if(c instanceof Qe.CubicBezierCurve||c instanceof Qe.QuadraticBezierCurve||c instanceof Qe.LineCurve){if(c.getPoint(p/u,d),n.set(d.x,d.y,0),o!==void 0&&ok(o,n))continue;o===void 0&&(o=tM),o.copy(n),i.setXYZ(a,n.x,n.y,n.z),a++}}return r&&a>1&&!(i.getX(a-1)===i.getX(0)&&i.getY(a-1)===i.getY(0)&&i.getZ(a-1)===i.getZ(0))&&(i.setXYZ(a,i.getX(0),i.getY(0),i.getZ(0)),a++),i}function dM(i,t,e,r=12,n=!0){let o=rM.set(0,0,0),a=0,s=[];for(let l=0;l<t.length;l++){if(e[l]===!1)continue;let c,d=K0(t[l]),u=id,p=xs(d,r);s.push(p);for(let h=0;h<=p;h++)if(d instanceof Qe.CubicBezierCurve||d instanceof Qe.QuadraticBezierCurve||d instanceof Qe.LineCurve){if(d.getPoint(h/p,u),o.set(u.x,u.y,0),c?.equals(o))continue;c===void 0?c=tM:(i.setXYZ(a,c.x,c.y,c.z),a++,i.setXYZ(a,o.x,o.y,o.z),a++),c.copy(o)}}return n&&a>1&&!(i.getX(a-1)===i.getX(0)&&i.getY(a-1)===i.getY(0)&&i.getZ(a-1)===i.getZ(0))&&(i.setXYZ(a,i.getX(0),i.getY(0),i.getZ(0)),a++),s}function $0(i,t=12,e=!1){let r=[];for(let n=0,o=i.length;n<o;n++){let a=i[n],s=0;if(e&&a.roundedCurveCorner!==void 0){let l=xs(a.roundedCurveCorner,t)*.5;n>0&&(r[n-1]+=l),s+=l}a.curveAfter!==void 0&&(s+=xs(a.curveAfter,t)),r.push(s)}return i.length>0&&e&&i[0].roundedCurveCorner!==void 0&&(r[i.length-1]+=xs(i[0].roundedCurveCorner,t)*.5),r}function xs(i,t=12){return i&&i instanceof Qe.EllipseCurve?t*2:i&&(i instanceof Qe.LineCurve||i instanceof Qe.LineCurve3)?1:i&&i instanceof Qe.SplineCurve?t*i.points.length:t}function uM(i,t,e=12,r=!0){let n,o=0;for(let a=0;a<t.length;a++){let s=K0(t[a]),l=xs(s,e),c=id;for(let d=0;d<=l;d++)if(s instanceof Qe.CubicBezierCurve||s instanceof Qe.QuadraticBezierCurve||s instanceof Qe.LineCurve){if(s.getPoint(d/l,c),n!==void 0&&ik(n,c,Fp))continue;n===void 0&&(n=fy),n.copy(c),i.push(c.x,c.y),o++}}return kp(i[0],i[i.length-2],Fp)&&kp(i[1],i[i.length-1],Fp)&&(i.pop(),i.pop()),r&&o>1&&!(kp(i[o-1],i[1],Fp)&&kp(i[o-2],i[0],Fp))&&(i.push(i[0],i[1]),o++),i}var eS=new dt.Vector2,ak=new dt.Vector2,sk=new dt.Vector2,lk=new dt.Vector2,ck=new dt.Vector2,dk=new dt.Vector2,ht=class extends dt.Shape{constructor(e=100,r=100){super();this.points=[];this.shapeHoles=[];this.plane=new dt.Plane(new dt.Vector3(0,0,-1));this.subdivision=0;this.controlSnapDistance=4;this.pointIDs=0;this.isMesh2D=!1;this.isText=!1;this._roundness=0;this.isClosed=!1;this.useCubicForRoundedCorners=!0;this.uuid=dt.MathUtils.generateUUID();this.needsUpdate=!1;this.roundedCurves=[];this._width=e,this._height=r}static createFromState(e,r,n){let o=new ht;return o.isClosed=e.isClosed,o.points=e.points.map(a=>co.create(a.id,a.data)),typeof e.roundness=="number"&&(o.roundness=e.roundness),o.shapeHoles=e.shapeHoles.map(a=>ht.createFromState(a)),r!==void 0&&n!==void 0&&o.applySize(r,n),o.update(),o}get width(){return this._width}get height(){return this._height}get roundness(){return this._roundness}set roundness(e){if(this._roundness!==e){this._roundness=e;for(let r=0,n=this.points.length;r<n;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,n=this.points.findIndex(o=>o.uuid===e);if(n<0){let o=r;for(let a=0,s=this.shapeHoles.length;a<s;a++){let l=this.shapeHoles[a],c=l.points.length,d=l.getPointIndexById(e);if(d<0)o+=c;else return d+o}}return n}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 n=0,o=this.shapeHoles.length;n<o;n++){let a=this.shapeHoles[n],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 n=0,o=this.shapeHoles.length;n<o;n++){let a=this.shapeHoles[n],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 n=eS.set(e,r);for(let o=0,a=this.points.length;o<a;o++){let s=this.points[o];s.position.multiply(n),s.controls[0].position.multiply(n),s.controls[1].position.multiply(n)}for(let o=0,a=this.shapeHoles.length;o<a;o++)this.shapeHoles[o].applyScale(e,r);this._update()}createPoint(e,r=0,n=dt.MathUtils.generateUUID()){let o;e instanceof dt.Vector2?o=e:o=new dt.Vector2(e,r);let a=new co(n,o);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,n=this.points.length;r<n;r++){let o=this.points[r];if(o.uuid===e)return o}for(let r=0,n=this.shapeHoles.length;r<n;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(n=>n.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,n=!1){this.subdivision=r,this.curveDivisions===void 0&&this.computeCurveDivisions(r);let o=n?this.roundedCurveDivisions:this.curveDivisions;return cM(e,n?this.roundedCurves:this.curves,r,this.autoClose),o.reduce((a,s)=>a+s,0)+1}computeCurveDivisions(e=12){return this.curveDivisions=$0(this.points,e,!1),this.roundedCurveDivisions=$0(this.points,e,!0),this.curveDivisions}extractFilteredShapePointsToBuffer(e,r,n=12){return dM(e,this.curves,r,n,this.autoClose).reduce((a,s)=>a+s,0)*2}extractShapePointsToFlatArray(e,r=12){return this.subdivision=r,this.curveDivisions===void 0&&this.computeCurveDivisions(r),uM(e,this.roundedCurves,r,this.autoClose)}getCurveIndexFromVertexId(e,r=!1){let n=0;this.curveDivisions===void 0&&this.computeCurveDivisions(this.subdivision);let o=r?this.roundedCurveDivisions:this.curveDivisions,a=0;r&&this.points[0].roundedCurveCorner!==void 0&&(a=xs(this.points[0].roundedCurveCorner,this.subdivision)*.5);let s=e-a;s<0&&(s+=o.reduce((l,c)=>l+c,0));for(let l=0,c=o.length;l<c;l++){let d=o[l];if(s<n+d)return[l,(s-n+1)/d];n+=d}return[0,1]}getCurveT(e,r,n){let o=this.points[e],a=this.points[e>=this.points.length-1?0:e+1],s=this.curveDivisions,l=s[e];if(J0(o,a)){let u=o.position.distanceTo(a.position);return o.position.distanceTo(eS.set(n.x,n.y))/u}let c=0;for(let u=0;u<e;u++)c+=s[u];return(r-c)/l}dispose(){}_applyCurveForPoint(e,r){J0(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 n=this.curves[this.curves.length-1];e.curveBefore=n,r.curveAfter=n;let o=n.clone();e.roundedCurveBefore=o,r.roundedCurveAfter=o,e.roundedCurveCorner=void 0,this.roundedCurves.push(o)}_update(){if(this.curves=[],this.roundedCurves=[],!this.points.length)return;for(let r=0,n=this.points.length;r<n;r++){let o=this.points[r];if(r===0)this.moveTo(o.position.x,o.position.y);else{let a=this.points[r-1];this._applyCurveForPoint(o,a)}}let e=this.getLastPoint();if(e?.curveAfter&&(e.curveAfter=void 0),this.isClosed){let r=this.points[0],n=this.points[this.points.length-1];this._applyCurveForPoint(r,n)}if(this.points.length>2){let r=0;for(let n=0,o=this.points.length;n<o;n++){let a=this.points[n],s=this.points[n-1]??this.points[this.points.length-1],l=this.points[n+1]??this.points[0],c=a.roundness,d=s&&l&&iM(s,a,l);if(!a.controlsMoved()&&c>0&&!d){let u=a.curveBefore,p=a.curveAfter;if(u===void 0||p===void 0)continue;let h=a.roundedCurveBefore,f=a.roundedCurveAfter,m=u instanceof dt.LineCurve?u.v1.distanceTo(u.v2):u.getLength(),y=p instanceof dt.LineCurve?p.v1.distanceTo(p.v2):p.getLength(),g=Math.min(c,m*.499),v=Math.min(c,y*.499),b=Math.min(g,v),S=1-b/m,x=b/y,w=u.getPointAt(S,eS),A=p.getPointAt(x,ak);this._subSplitCurve(u,h,S,w,void 0),this._subSplitCurve(p,f,x,void 0,A);let C;if(this.useCubicForRoundedCorners){let P=Z0(w,a.position,A)/2,M=Math.tan(P)*w.distanceTo(a.position),[B,I]=oM(w,A,M,sk,lk),_=aM(B,I,a.position),[E,R]=sM(_,w,A,M,ck,dk);C=new dt.CubicBezierCurve(w.clone(),E.clone(),R.clone(),A.clone())}else C=new dt.QuadraticBezierCurve(w.clone(),a.position.clone(),A.clone());a.roundedCurveCorner=C,this.roundedCurves.splice(n+r,0,C),r++}}}}_subSplitCurve(e,r,n,o,a){if(e instanceof dt.LineCurve)o!==void 0&&r.v2.copy(o),a!==void 0&&r.v1.copy(a);else{let s=e,l=r,c=s.getUtoTmapping(n,0),d=lM(s.v0,s.v1,s.v2,s.v3,c);return o!==void 0&&(l.v0.set(d[0],d[1]),l.v1.set(d[2],d[3]),l.v2.set(d[4],d[5]),l.v3.set(d[6],d[7])),a!==void 0&&(l.v0.set(d[6],d[7]),l.v1.set(d[8],d[9]),l.v2.set(d[10],d[11]),l.v3.set(d[12],d[13])),l}return r}clone(){let e=new ht(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 n=0;n<r;n++){let o=n*7,a=e.points[o+0],s=e.points[o+1],l=e.points[o+2],c=e.points[o+3],d=e.points[o+4],u=e.points[o+5],p=e.points[o+6],h=new co(dt.MathUtils.generateUUID(),new dt.Vector2(a,s));h.controls[0].position.set(l,c),h.controls[1].position.set(d,u),h.roundness=p,this.points.push(h)}return this.shapeHoles=e.shapeHoles?.length?e.shapeHoles.map(n=>{let o=new ht;return o.fromJSON(n),o}):[],this.isClosed=e.isClosed,this._roundness=e.roundness,this._update(),this}fromShape(e,r=!1){this.isText=r;let n=(a,s)=>{s instanceof dt.CubicBezierCurve&&s.v3.equals(a.position)&&a.controls[0].position.copy(s.v2)},o=a=>{let s=[],l,c;for(l=0,c=a.length;l<c;l++)a[l]instanceof dt.QuadraticBezierCurve&&(a[l]=nM(a[l]));for(l=0,c=a.length;l<c;l++){let p=a[l],h=l>0?a[l-1]:null,f;p instanceof dt.CubicBezierCurve?(f=this.createPoint(p.v0),f.controls[1].position.copy(p.v1)):p instanceof dt.LineCurve&&(f=this.createPoint(p.v1)),f!==void 0&&(h!==null&&n(f,h),s.push(f))}let d=a[a.length-1],u=!1;return d instanceof dt.CubicBezierCurve?d.v3.equals(s[0].position)&&(s[0].controls[0].position.copy(d.v2),u=!0):d instanceof dt.LineCurve&&d.v2.equals(s[0].position)&&(u=!0),this.isClosed=u,s};return this.points=o(e.curves),e instanceof dt.Shape&&(this.shapeHoles=e.holes.map(a=>{let s=new ht;return s.fromShape(a),s})),this.update(),this}updatePoint(e,r){let n=this.getPointByUuid(e);n&&(r.position!==void 0&&n.position.fromArray(r.position),r.roundness!==void 0&&(n.roundness=r.roundness),r.areControlsDirectionsMirrored!==void 0&&(n.areControlsDirectionsMirrored=r.areControlsDirectionsMirrored),this.needsUpdate=!0)}updatePreviousControl(e,r){let o=this.getPointByUuid(e)?.controls[0];o&&(r.position&&o.position.fromArray(r.position),this.needsUpdate=!0)}updateNextControl(e,r){let o=this.getPointByUuid(e)?.controls[1];o&&(r.position&&o.position.fromArray(r.position),this.needsUpdate=!0)}};var rS=Math.PI*2;function tS({x:i,y:t},e,r,n,o){return{x:i*e+n,y:t*r+o}}function uk(i,t){let e=t===1.5707963267948966?.551915024494:t===-1.5707963267948966?-.551915024494:1.3333333333333333*Math.tan(t/4),r=Math.cos(i),n=Math.sin(i),o=Math.cos(i+t),a=Math.sin(i+t);return[{x:r-n*e,y:n+r*e},{x:o+a*e,y:a-o*e},{x:o,y:a}]}function pM(i,t,e,r){let n=i*r-t*e<0?-1:1,o=Math.min(1,Math.max(-1,i*e+t*r));return n*Math.acos(o)}function pk(i,t,e,r,n,o,a,s,l,c){let d=Math.pow(n,2),u=Math.pow(o,2),p=Math.pow(a,2),h=Math.pow(s,2),f=d*u-d*h-u*p;f<0&&(f=0),f/=d*h+u*p,f=Math.sqrt(f)*(l===c?-1:1);let m=f*n/o*s,y=f*-o/n*a,g=m+(i+e)/2,v=y+(t+r)/2,b=(a-m)/n,S=(s-y)/o,x=(-a-m)/n,w=(-s-y)/o,A=pM(1,0,b,S),C=pM(b,S,x,w);return!c&&C>0&&(C-=rS),c&&C<0&&(C+=rS),{centerx:g,centery:v,ang1:A,ang2:C}}function hM({px:i,py:t,cx:e,cy:r,rx:n,ry:o,largeArcFlag:a,sweepFlag:s}){let l=[];if(n===0||o===0)return[];let c=(i-e)/2,d=(t-r)/2;if(c===0&&d===0)return[];n=Math.abs(n),o=Math.abs(o);let u=Math.pow(c,2)/Math.pow(n,2)+Math.pow(d,2)/Math.pow(o,2);u>1&&(n*=Math.sqrt(u),o*=Math.sqrt(u));let p=pk(i,t,e,r,n,o,c,d,a,s),{ang1:h,ang2:f}=p,{centerx:m,centery:y}=p,g=Math.abs(f)/(rS/4);Math.abs(1-g)<1e-7&&(g=1);let v=Math.max(Math.ceil(g),1);f/=v;for(let b=0;b<v;b++)l.push(uk(h,f)),h+=f;return l.map(b=>{let{x:S,y:x}=tS(b[0],n,o,m,y),{x:w,y:A}=tS(b[1],n,o,m,y),{x:C,y:P}=tS(b[2],n,o,m,y);return{x1:S,y1:x,x2:w,y2:A,x:C,y:P}})}var Ol=require("three");var Tt;(function(i){i[i.ODD=0]="ODD",i[i.NONZERO=1]="NONZERO",i[i.POSITIVE=2]="POSITIVE",i[i.NEGATIVE=3]="NEGATIVE",i[i.ABS_GEQ_TWO=4]="ABS_GEQ_TWO"})(Tt||(Tt={}));var kr;(function(i){i[i.POLYGONS=0]="POLYGONS",i[i.CONNECTED_POLYGONS=1]="CONNECTED_POLYGONS",i[i.BOUNDARY_CONTOURS=2]="BOUNDARY_CONTOURS"})(kr||(kr={}));function Be(i,t){if(!i)throw t||"Assertion Failed!"}var Me=function(){function i(){}return i.vertEq=function(t,e){return t.s===e.s&&t.t===e.t},i.vertLeq=function(t,e){return t.s<e.s||t.s===e.s&&t.t<=e.t},i.transLeq=function(t,e){return t.t<e.t||t.t===e.t&&t.s<=e.s},i.edgeGoesLeft=function(t){return i.vertLeq(t.Dst,t.Org)},i.edgeGoesRight=function(t){return i.vertLeq(t.Org,t.Dst)},i.vertL1dist=function(t,e){return Math.abs(t.s-e.s)+Math.abs(t.t-e.t)},i.edgeEval=function(t,e,r){Be(i.vertLeq(t,e)&&i.vertLeq(e,r));var n=e.s-t.s,o=r.s-e.s;return n+o>0?n<o?e.t-t.t+(t.t-r.t)*(n/(n+o)):e.t-r.t+(r.t-t.t)*(o/(n+o)):0},i.edgeSign=function(t,e,r){Be(i.vertLeq(t,e)&&i.vertLeq(e,r));var n=e.s-t.s,o=r.s-e.s;return n+o>0?(e.t-r.t)*n+(e.t-t.t)*o:0},i.transEval=function(t,e,r){Be(i.transLeq(t,e)&&i.transLeq(e,r));var n=e.t-t.t,o=r.t-e.t;return n+o>0?n<o?e.s-t.s+(t.s-r.s)*(n/(n+o)):e.s-r.s+(r.s-t.s)*(o/(n+o)):0},i.transSign=function(t,e,r){Be(i.transLeq(t,e)&&i.transLeq(e,r));var n=e.t-t.t,o=r.t-e.t;return n+o>0?(e.s-r.s)*n+(e.s-t.s)*o:0},i.vertCCW=function(t,e,r){return t.s*(e.t-r.t)+e.s*(r.t-t.t)+r.s*(t.t-e.t)>=0},i.interpolate=function(t,e,r,n){return t=t<0?0:t,r=r<0?0:r,t<=r?r===0?(e+n)/2:e+(n-e)*(t/(t+r)):n+(e-n)*(r/(t+r))},i.intersect=function(t,e,r,n,o){var a,s,l;i.vertLeq(t,e)||(l=t,t=e,e=l),i.vertLeq(r,n)||(l=r,r=n,n=l),i.vertLeq(t,r)||(l=t,t=r,r=l,l=e,e=n,n=l),i.vertLeq(r,e)?i.vertLeq(e,n)?(a=i.edgeEval(t,r,e),s=i.edgeEval(r,e,n),a+s<0&&(a=-a,s=-s),o.s=i.interpolate(a,r.s,s,e.s)):(a=i.edgeSign(t,r,e),s=-i.edgeSign(t,n,e),a+s<0&&(a=-a,s=-s),o.s=i.interpolate(a,r.s,s,n.s)):o.s=(r.s+e.s)/2,i.transLeq(t,e)||(l=t,t=e,e=l),i.transLeq(r,n)||(l=r,r=n,n=l),i.transLeq(t,r)||(l=t,t=r,r=l,l=e,e=n,n=l),i.transLeq(r,e)?i.transLeq(e,n)?(a=i.transEval(t,r,e),s=i.transEval(r,e,n),a+s<0&&(a=-a,s=-s),o.t=i.interpolate(a,r.t,s,e.t)):(a=i.transSign(t,r,e),s=-i.transSign(t,n,e),a+s<0&&(a=-a,s=-s),o.t=i.interpolate(a,r.t,s,n.t)):o.t=(r.t+e.t)/2},i}(),Vp=function(){function i(){this.next=null,this.prev=null,this.anEdge=null,this.trail=null,this.n=0,this.marked=!1,this.inside=!1}return i}(),my=function(){function i(t){this.side=t,this.next=null,this.Org=null,this.Sym=null,this.Onext=null,this.Lnext=null,this.Lface=null,this.activeRegion=null,this.winding=0}return Object.defineProperty(i.prototype,"Rface",{get:function(){return this.Sym.Lface},set:function(t){this.Sym.Lface=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Dst",{get:function(){return this.Sym.Org},set:function(t){this.Sym.Org=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Oprev",{get:function(){return this.Sym.Lnext},set:function(t){this.Sym.Lnext=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Lprev",{get:function(){return this.Onext.Sym},set:function(t){this.Onext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Dprev",{get:function(){return this.Lnext.Sym},set:function(t){this.Lnext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Rprev",{get:function(){return this.Sym.Onext},set:function(t){this.Sym.Onext=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Dnext",{get:function(){return this.Sym.Onext.Sym},set:function(t){this.Sym.Onext.Sym=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"Rnext",{get:function(){return this.Sym.Lnext.Sym},set:function(t){this.Sym.Lnext.Sym=t},enumerable:!0,configurable:!0}),i}(),od=function(){function i(){this.next=null,this.prev=null,this.anEdge=null,this.coords=[0,0,0],this.s=0,this.t=0,this.pqHandle=0,this.n=0,this.idx=0}return i}(),fM=function(){function i(){var t=new od,e=new Vp,r=new my(0),n=new my(1);t.next=t.prev=t,t.anEdge=null,e.next=e.prev=e,r.next=r,r.Sym=n,n.next=n,n.Sym=r,this.vHead=t,this.fHead=e,this.eHead=r,this.eHeadSym=n}return i.prototype.makeEdge_=function(t){var e=new my(0),r=new my(1);t.Sym.side<t.side&&(t=t.Sym);var n=t.Sym.next;return r.next=n,n.Sym.next=e,e.next=t,t.Sym.next=r,e.Sym=r,e.Onext=e,e.Lnext=r,e.Org=null,e.Lface=null,e.winding=0,e.activeRegion=null,r.Sym=e,r.Onext=r,r.Lnext=e,r.Org=null,r.Lface=null,r.winding=0,r.activeRegion=null,e},i.prototype.splice_=function(t,e){var r=t.Onext,n=e.Onext;r.Sym.Lnext=e,n.Sym.Lnext=t,t.Onext=n,e.Onext=r},i.prototype.makeVertex_=function(t,e,r){var n=t;Be(n,"Vertex can't be null!");var o=r.prev;n.prev=o,o.next=n,n.next=r,r.prev=n,n.anEdge=e;var a=e;do a.Org=n,a=a.Onext;while(a!==e)},i.prototype.makeFace_=function(t,e,r){var n=t;Be(n,"Face can't be null");var o=r.prev;n.prev=o,o.next=n,n.next=r,r.prev=n,n.anEdge=e,n.trail=null,n.marked=!1,n.inside=r.inside;var a=e;do a.Lface=n,a=a.Lnext;while(a!==e)},i.prototype.killEdge_=function(t){t.Sym.side<t.side&&(t=t.Sym);var e=t.next,r=t.Sym.next;e.Sym.next=r,r.Sym.next=e},i.prototype.killVertex_=function(t,e){var r=t.anEdge,n=r;do n.Org=e,n=n.Onext;while(n!==r);var o=t.prev,a=t.next;a.prev=o,o.next=a},i.prototype.killFace_=function(t,e){var r=t.anEdge,n=r;do n.Lface=e,n=n.Lnext;while(n!==r);var o=t.prev,a=t.next;a.prev=o,o.next=a},i.prototype.makeEdge=function(){var t=new od,e=new od,r=new Vp,n=this.makeEdge_(this.eHead);return this.makeVertex_(t,n,this.vHead),this.makeVertex_(e,n.Sym,this.vHead),this.makeFace_(r,n,this.fHead),n},i.prototype.splice=function(t,e){var r=!1,n=!1;if(t!==e){if(e.Org!==t.Org&&(n=!0,this.killVertex_(e.Org,t.Org)),e.Lface!==t.Lface&&(r=!0,this.killFace_(e.Lface,t.Lface)),this.splice_(e,t),!n){var o=new od;this.makeVertex_(o,e,t.Org),t.Org.anEdge=t}if(!r){var a=new Vp;this.makeFace_(a,e,t.Lface),t.Lface.anEdge=t}}},i.prototype.delete=function(t){var e=t.Sym,r=!1;if(t.Lface!==t.Rface&&(r=!0,this.killFace_(t.Lface,t.Rface)),t.Onext===t)this.killVertex_(t.Org,null);else if(t.Rface.anEdge=t.Oprev,t.Org.anEdge=t.Onext,this.splice_(t,t.Oprev),!r){var n=new Vp;this.makeFace_(n,t,t.Lface)}e.Onext===e?(this.killVertex_(e.Org,null),this.killFace_(e.Lface,null)):(t.Lface.anEdge=e.Oprev,e.Org.anEdge=e.Onext,this.splice_(e,e.Oprev)),this.killEdge_(t)},i.prototype.addEdgeVertex=function(t){var e=this.makeEdge_(t),r=e.Sym;this.splice_(e,t.Lnext),e.Org=t.Dst;var n=new od;return this.makeVertex_(n,r,e.Org),e.Lface=r.Lface=t.Lface,e},i.prototype.splitEdge=function(t){var e=this.addEdgeVertex(t),r=e.Sym;return this.splice_(t.Sym,t.Sym.Oprev),this.splice_(t.Sym,r),t.Dst=r.Org,r.Dst.anEdge=r.Sym,r.Rface=t.Rface,r.winding=t.winding,r.Sym.winding=t.Sym.winding,r.idx=t.idx,r.Sym.idx=t.Sym.idx,r},i.prototype.connect=function(t,e){var r=!1,n=this.makeEdge_(t),o=n.Sym;if(e.Lface!==t.Lface&&(r=!0,this.killFace_(e.Lface,t.Lface)),this.splice_(n,t.Lnext),this.splice_(o,e),n.Org=t.Dst,o.Org=e.Org,n.Lface=o.Lface=t.Lface,t.Lface.anEdge=o,!r){var a=new Vp;this.makeFace_(a,n,t.Lface)}return n},i.prototype.zapFace=function(t){var e=t.anEdge,r,n,o,a,s;n=e.Lnext;do r=n,n=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)),o=r.Sym,o.Onext===o?this.killVertex_(o.Org,null):(o.Org.anEdge=o.Onext,this.splice_(o,o.Oprev)),this.killEdge_(r));while(r!=e);a=t.prev,s=t.next,s.prev=a,a.next=s},i.prototype.countFaceVerts_=function(t){var e=t.anEdge,r=0;do r++,e=e.Lnext;while(e!==t.anEdge);return r},i.prototype.mergeConvexFaces=function(t){var e,r,n,o,a,s,l;for(e=this.fHead.next;e!==this.fHead;e=e.next)if(!!e.inside)for(r=e.anEdge,a=r.Org;n=r.Lnext,o=r.Sym,o&&o.Lface&&o.Lface.inside&&(s=this.countFaceVerts_(e),l=this.countFaceVerts_(o.Lface),s+l-2<=t&&Me.vertCCW(r.Lprev.Org,r.Org,o.Lnext.Lnext.Org)&&Me.vertCCW(o.Lprev.Org,o.Org,r.Lnext.Lnext.Org)&&(n=o.Lnext,this.delete(o),r=null,o=null)),!(r&&r.Lnext.Org===a);)r=n;return!0},i.prototype.check=function(){var t=this.fHead,e=this.vHead,r=this.eHead,n,o,a,s,l,c;for(o=t,o=t;(n=o.next)!==t;o=n){Be(n.prev===o),l=n.anEdge;do Be(l.Sym!==l),Be(l.Sym.Sym===l),Be(l.Lnext.Onext.Sym===l),Be(l.Onext.Sym.Lnext===l),Be(l.Lface===n),l=l.Lnext;while(l!==n.anEdge)}for(Be(n.prev===o&&n.anEdge===null),s=e,s=e;(a=s.next)!==e;s=a){Be(a.prev===s),l=a.anEdge;do Be(l.Sym!==l),Be(l.Sym.Sym===l),Be(l.Lnext.Onext.Sym===l),Be(l.Onext.Sym.Lnext===l),Be(l.Org===a),l=l.Onext;while(l!==a.anEdge)}for(Be(a.prev===s&&a.anEdge===null),c=r,c=r;(l=c.next)!==r;c=l)Be(l.Sym.next===c.Sym),Be(l.Sym!==l),Be(l.Sym.Sym===l),Be(l.Org!==null),Be(l.Dst!==null),Be(l.Lnext.Onext.Sym===l),Be(l.Onext.Sym.Lnext===l);Be(l.Sym.next===c.Sym&&l.Sym===this.eHeadSym&&l.Sym.Sym===l&&l.Org===null&&l.Dst===null&&l.Lface===null&&l.Rface===null)},i}(),mM=function(){function i(){this.handle=null}return i}(),yM=function(){function i(){this.key=null,this.node=0}return i}(),hk=function(){function i(t,e){this.leq=e,this.max=0,this.nodes=[],this.handles=[],this.initialized=!1,this.freeList=0,this.size=0,this.max=t,this.nodes=[],this.handles=[];for(var r=0;r<t+1;r++)this.nodes[r]=new mM,this.handles[r]=new yM;this.initialized=!1,this.nodes[1].handle=1,this.handles[1].key=null}return i.prototype.floatDown_=function(t){var e=this.nodes,r=this.handles,n,o,a;for(n=e[t].handle;;){if(a=t<<1,a<this.size&&this.leq(r[e[a+1].handle].key,r[e[a].handle].key)&&++a,Be(a<=this.max),o=e[a].handle,a>this.size||this.leq(r[n].key,r[o].key)){e[t].handle=n,r[n].node=t;break}e[t].handle=o,r[o].node=t,t=a}},i.prototype.floatUp_=function(t){var e=this.nodes,r=this.handles,n,o,a;for(n=e[t].handle;;){if(a=t>>1,o=e[a].handle,a===0||this.leq(r[o].key,r[n].key)){e[t].handle=n,r[n].node=t;break}e[t].handle=o,r[o].node=t,t=a}},i.prototype.init=function(){for(var t=this.size;t>=1;--t)this.floatDown_(t);this.initialized=!0},i.prototype.min=function(){return this.handles[this.nodes[1].handle].key},i.prototype.insert=function(t){var e,r;if(e=++this.size,e*2>this.max){this.max*=2;var n,o;for(o=this.nodes.length,this.nodes.length=this.max+1,n=o;n<this.nodes.length;n++)this.nodes[n]=new mM;for(o=this.handles.length,this.handles.length=this.max+1,n=o;n<this.handles.length;n++)this.handles[n]=new yM}return this.freeList===0?r=e:(r=this.freeList,this.freeList=this.handles[r].node),this.nodes[e].handle=r,this.handles[r].node=e,this.handles[r].key=t,this.initialized&&this.floatUp_(e),r},i.prototype.extractMin=function(){var t=this.nodes,e=this.handles,r=t[1].handle,n=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)),n},i.prototype.delete=function(t){var e=this.nodes,r=this.handles,n;Be(t>=1&&t<=this.max&&r[t].key!==null),n=r[t].node,e[n].handle=e[this.size].handle,r[e[n].handle].node=n,--this.size,n<=this.size&&(n<=1||this.leq(r[e[n>>1].handle].key,r[e[n].handle].key)?this.floatDown_(n):this.floatUp_(n)),r[t].key=null,r[t].node=this.freeList,this.freeList=t},i}(),nS=function(){function i(){this.eUp=null,this.nodeUp=null,this.windingNumber=0,this.inside=!1,this.sentinel=!1,this.dirty=!1,this.fixUpperEdge=!1}return i}(),gM=function(){function i(){this.key=null,this.next=null,this.prev=null}return i}(),fk=function(){function i(t,e){this.frame=t,this.leq=e,this.head=new gM,this.head.next=this.head,this.head.prev=this.head}return i.prototype.min=function(){return this.head.next},i.prototype.max=function(){return this.head.prev},i.prototype.insert=function(t){return this.insertBefore(this.head,t)},i.prototype.search=function(t){var e=this.head;do e=e.next;while(e.key!==null&&!this.leq(this.frame,t,e.key));return e},i.prototype.insertBefore=function(t,e){do t=t.prev;while(t.key!==null&&!this.leq(this.frame,t.key,e));var r=new gM;return r.key=e,r.next=t.next,t.next.prev=r,r.prev=t,t.next=r,r},i.prototype.delete=function(t){t.next.prev=t.prev,t.prev.next=t.next},i}(),mk=function(){function i(){}return i.regionBelow=function(t){return t.nodeUp.prev.key},i.regionAbove=function(t){return t.nodeUp.next.key},i.debugEvent=function(t){},i.addWinding=function(t,e){t.winding+=e.winding,t.Sym.winding+=e.Sym.winding},i.edgeLeq=function(t,e,r){var n=t.event,o=e.eUp,a=r.eUp;if(o.Dst===n)return a.Dst===n?Me.vertLeq(o.Org,a.Org)?Me.edgeSign(a.Dst,o.Org,a.Org)<=0:Me.edgeSign(o.Dst,a.Org,o.Org)>=0:Me.edgeSign(a.Dst,n,a.Org)<=0;if(a.Dst===n)return Me.edgeSign(o.Dst,n,o.Org)>=0;var s=Me.edgeEval(o.Dst,n,o.Org),l=Me.edgeEval(a.Dst,n,a.Org);return s>=l},i.deleteRegion=function(t,e){e.fixUpperEdge&&Be(e.eUp.winding===0),e.eUp.activeRegion=null,t.dict.delete(e.nodeUp)},i.fixUpperEdge=function(t,e,r){Be(e.fixUpperEdge),t.mesh.delete(e.eUp),e.fixUpperEdge=!1,e.eUp=r,r.activeRegion=e},i.topLeftRegion=function(t,e){var r=e.eUp.Org,n;do e=i.regionAbove(e);while(e.eUp.Org===r);if(e.fixUpperEdge){if(n=t.mesh.connect(i.regionBelow(e).eUp.Sym,e.eUp.Lnext),n===null)return null;i.fixUpperEdge(t,e,n),e=i.regionAbove(e)}return e},i.topRightRegion=function(t){var e=t.eUp.Dst;do t=i.regionAbove(t);while(t.eUp.Dst===e);return t},i.addRegionBelow=function(t,e,r){var n=new nS;return n.eUp=r,n.nodeUp=t.dict.insertBefore(e.nodeUp,n),n.fixUpperEdge=!1,n.sentinel=!1,n.dirty=!1,r.activeRegion=n,n},i.isWindingInside=function(t,e){switch(t.windingRule){case Tt.ODD:return(e&1)!==0;case Tt.NONZERO:return e!==0;case Tt.POSITIVE:return e>0;case Tt.NEGATIVE:return e<0;case Tt.ABS_GEQ_TWO:return e>=2||e<=-2}throw new Error("Invalid winding rulle")},i.computeWinding=function(t,e){e.windingNumber=i.regionAbove(e).windingNumber+e.eUp.winding,e.inside=i.isWindingInside(t,e.windingNumber)},i.finishRegion=function(t,e){var r=e.eUp,n=r.Lface;n.inside=e.inside,n.anEdge=r,i.deleteRegion(t,e)},i.finishLeftRegions=function(t,e,r){for(var n,o=null,a=e,s=e.eUp;a!==r;){if(a.fixUpperEdge=!1,o=i.regionBelow(a),n=o.eUp,n.Org!=s.Org){if(!o.fixUpperEdge){i.finishRegion(t,a);break}n=t.mesh.connect(s.Lprev,n.Sym),i.fixUpperEdge(t,o,n)}s.Onext!==n&&(t.mesh.splice(n.Oprev,n),t.mesh.splice(s,n)),i.finishRegion(t,a),s=o.eUp,a=o}return s},i.addRightEdges=function(t,e,r,n,o,a){var s,l,c,d,u=!0;c=r;do Be(Me.vertLeq(c.Org,c.Dst)),i.addRegionBelow(t,e,c.Sym),c=c.Onext;while(c!==n);for(o===null&&(o=i.regionBelow(e).eUp.Rprev),l=e,d=o;s=i.regionBelow(l),c=s.eUp.Sym,c.Org===d.Org;)c.Onext!==d&&(t.mesh.splice(c.Oprev,c),t.mesh.splice(d.Oprev,c)),s.windingNumber=l.windingNumber-c.winding,s.inside=i.isWindingInside(t,s.windingNumber),l.dirty=!0,!u&&i.checkForRightSplice(t,l)&&(i.addWinding(c,d),i.deleteRegion(t,l),t.mesh.delete(d)),u=!1,l=s,d=c;l.dirty=!0,Be(l.windingNumber-c.winding===s.windingNumber),a&&i.walkDirtyRegions(t,l)},i.spliceMergeVertices=function(t,e,r){t.mesh.splice(e,r)},i.vertexWeights=function(t,e,r){var n=Me.vertL1dist(e,t),o=Me.vertL1dist(r,t),a=.5*o/(n+o),s=.5*n/(n+o);t.coords[0]+=a*e.coords[0]+s*r.coords[0],t.coords[1]+=a*e.coords[1]+s*r.coords[1],t.coords[2]+=a*e.coords[2]+s*r.coords[2]},i.getIntersectData=function(t,e,r,n,o,a){e.coords[0]=e.coords[1]=e.coords[2]=0,e.idx=-1,i.vertexWeights(e,r,n),i.vertexWeights(e,o,a)},i.checkForRightSplice=function(t,e){var r=i.regionBelow(e),n=e.eUp,o=r.eUp;if(Me.vertLeq(n.Org,o.Org)){if(Me.edgeSign(o.Dst,n.Org,o.Org)>0)return!1;Me.vertEq(n.Org,o.Org)?n.Org!==o.Org&&(t.pq.delete(n.Org.pqHandle),i.spliceMergeVertices(t,o.Oprev,n)):(t.mesh.splitEdge(o.Sym),t.mesh.splice(n,o.Oprev),e.dirty=r.dirty=!0)}else{if(Me.edgeSign(n.Dst,o.Org,n.Org)<0)return!1;i.regionAbove(e).dirty=e.dirty=!0,t.mesh.splitEdge(n.Sym),t.mesh.splice(o.Oprev,n)}return!0},i.checkForLeftSplice=function(t,e){var r=i.regionBelow(e),n=e.eUp,o=r.eUp,a;if(Be(!Me.vertEq(n.Dst,o.Dst)),Me.vertLeq(n.Dst,o.Dst)){if(Me.edgeSign(n.Dst,o.Dst,n.Org)<0)return!1;i.regionAbove(e).dirty=e.dirty=!0,a=t.mesh.splitEdge(n),t.mesh.splice(o.Sym,a),a.Lface.inside=e.inside}else{if(Me.edgeSign(o.Dst,n.Dst,o.Org)>0)return!1;e.dirty=r.dirty=!0,a=t.mesh.splitEdge(o),t.mesh.splice(n.Lnext,o.Sym),a.Rface.inside=e.inside}return!0},i.checkForIntersect=function(t,e){var r=i.regionBelow(e),n=e.eUp,o=r.eUp,a=n.Org,s=o.Org,l=n.Dst,c=o.Dst,d,u,p=new od,h,f;if(Be(!Me.vertEq(c,l)),Be(Me.edgeSign(l,t.event,a)<=0),Be(Me.edgeSign(c,t.event,s)>=0),Be(a!==t.event&&s!==t.event),Be(!e.fixUpperEdge&&!r.fixUpperEdge),a===s||(d=Math.min(a.t,l.t),u=Math.max(s.t,c.t),d>u))return!1;if(Me.vertLeq(a,s)){if(Me.edgeSign(c,a,s)>0)return!1}else if(Me.edgeSign(l,s,a)<0)return!1;return i.debugEvent(t),Me.intersect(l,a,c,s,p),Be(Math.min(a.t,l.t)<=p.t),Be(p.t<=Math.max(s.t,c.t)),Be(Math.min(c.s,l.s)<=p.s),Be(p.s<=Math.max(s.s,a.s)),Me.vertLeq(p,t.event)&&(p.s=t.event.s,p.t=t.event.t),h=Me.vertLeq(a,s)?a:s,Me.vertLeq(h,p)&&(p.s=h.s,p.t=h.t),Me.vertEq(p,a)||Me.vertEq(p,s)?(i.checkForRightSplice(t,e),!1):!Me.vertEq(l,t.event)&&Me.edgeSign(l,t.event,p)>=0||!Me.vertEq(c,t.event)&&Me.edgeSign(c,t.event,p)<=0?c===t.event?(t.mesh.splitEdge(n.Sym),t.mesh.splice(o.Sym,n),e=i.topLeftRegion(t,e),n=i.regionBelow(e).eUp,i.finishLeftRegions(t,i.regionBelow(e),r),i.addRightEdges(t,e,n.Oprev,n,n,!0),!0):l===t.event?(t.mesh.splitEdge(o.Sym),t.mesh.splice(n.Lnext,o.Oprev),r=e,e=i.topRightRegion(e),f=i.regionBelow(e).eUp.Rprev,r.eUp=o.Oprev,o=i.finishLeftRegions(t,r,null),i.addRightEdges(t,e,o.Onext,n.Rprev,f,!0),!0):(Me.edgeSign(l,t.event,p)>=0&&(i.regionAbove(e).dirty=e.dirty=!0,t.mesh.splitEdge(n.Sym),n.Org.s=t.event.s,n.Org.t=t.event.t),Me.edgeSign(c,t.event,p)<=0&&(e.dirty=r.dirty=!0,t.mesh.splitEdge(o.Sym),o.Org.s=t.event.s,o.Org.t=t.event.t),!1):(t.mesh.splitEdge(n.Sym),t.mesh.splitEdge(o.Sym),t.mesh.splice(o.Oprev,n),n.Org.s=p.s,n.Org.t=p.t,n.Org.pqHandle=t.pq.insert(n.Org),i.getIntersectData(t,n.Org,a,l,s,c),i.regionAbove(e).dirty=e.dirty=r.dirty=!0,!1)},i.walkDirtyRegions=function(t,e){for(var r=i.regionBelow(e),n,o;;){for(;r.dirty;)e=r,r=i.regionBelow(r);if(!e.dirty&&(r=e,e=i.regionAbove(e),e===null||!e.dirty))return;if(e.dirty=!1,n=e.eUp,o=r.eUp,n.Dst!==o.Dst&&i.checkForLeftSplice(t,e)&&(r.fixUpperEdge?(i.deleteRegion(t,r),t.mesh.delete(o),r=i.regionBelow(e),o=r.eUp):e.fixUpperEdge&&(i.deleteRegion(t,e),t.mesh.delete(n),e=i.regionAbove(r),n=e.eUp)),n.Org!==o.Org)if(n.Dst!==o.Dst&&!e.fixUpperEdge&&!r.fixUpperEdge&&(n.Dst===t.event||o.Dst===t.event)){if(i.checkForIntersect(t,e))return}else i.checkForRightSplice(t,e);n.Org===o.Org&&n.Dst===o.Dst&&(i.addWinding(o,n),i.deleteRegion(t,e),t.mesh.delete(n),e=i.regionAbove(r))}},i.connectRightVertex=function(t,e,r){var n,o=r.Onext,a=i.regionBelow(e),s=e.eUp,l=a.eUp,c=!1;if(s.Dst!==l.Dst&&i.checkForIntersect(t,e),Me.vertEq(s.Org,t.event)&&(t.mesh.splice(o.Oprev,s),e=i.topLeftRegion(t,e),o=i.regionBelow(e).eUp,i.finishLeftRegions(t,i.regionBelow(e),a),c=!0),Me.vertEq(l.Org,t.event)&&(t.mesh.splice(r,l.Oprev),r=i.finishLeftRegions(t,a,null),c=!0),c){i.addRightEdges(t,e,r.Onext,o,o,!0);return}Me.vertLeq(l.Org,s.Org)?n=l.Oprev:n=s,n=t.mesh.connect(r.Lprev,n),i.addRightEdges(t,e,n,n.Onext,n.Onext,!1),n.Sym.activeRegion.fixUpperEdge=!0,i.walkDirtyRegions(t,e)},i.connectLeftDegenerate=function(t,e,r){var n,o,a,s,l;if(n=e.eUp,Me.vertEq(n.Org,r)){Be(!1),i.spliceMergeVertices(t,n,r.anEdge);return}if(!Me.vertEq(n.Dst,r)){t.mesh.splitEdge(n.Sym),e.fixUpperEdge&&(t.mesh.delete(n.Onext),e.fixUpperEdge=!1),t.mesh.splice(r.anEdge,n),i.sweepEvent(t,r);return}Be(!1),e=i.topRightRegion(e),l=i.regionBelow(e),a=l.eUp.Sym,o=s=a.Onext,l.fixUpperEdge&&(Be(o!==a),i.deleteRegion(t,l),t.mesh.delete(a),a=o.Oprev),t.mesh.splice(r.anEdge,a),Me.edgeGoesLeft(o)||(o=null),i.addRightEdges(t,e,a.Onext,s,o,!0)},i.connectLeftVertex=function(t,e){var r,n,o,a,s,l,c=new nS;if(c.eUp=e.anEdge.Sym,r=t.dict.search(c).key,n=i.regionBelow(r),!!n){if(a=r.eUp,s=n.eUp,Me.edgeSign(a.Dst,e,a.Org)===0){i.connectLeftDegenerate(t,r,e);return}if(o=Me.vertLeq(s.Dst,a.Dst)?r:n,r.inside||o.fixUpperEdge){if(o===r)l=t.mesh.connect(e.anEdge.Sym,a.Lnext);else{var d=t.mesh.connect(s.Dnext,e.anEdge);l=d.Sym}o.fixUpperEdge?i.fixUpperEdge(t,o,l):i.computeWinding(t,i.addRegionBelow(t,r,l)),i.sweepEvent(t,e)}else i.addRightEdges(t,r,e.anEdge,e.anEdge,null,!0)}},i.sweepEvent=function(t,e){t.event=e,i.debugEvent(t);for(var r=e.anEdge;r.activeRegion===null;)if(r=r.Onext,r===e.anEdge){i.connectLeftVertex(t,e);return}var n=i.topLeftRegion(t,r.activeRegion);Be(n!==null);var o=i.regionBelow(n),a=o.eUp,s=i.finishLeftRegions(t,o,null);s.Onext===a?i.connectRightVertex(t,n,s):i.addRightEdges(t,n,s.Onext,a,a,!0)},i.addSentinel=function(t,e,r,n){var o=new nS,a=t.mesh.makeEdge();a.Org.s=r,a.Org.t=n,a.Dst.s=e,a.Dst.t=n,t.event=a.Dst,o.eUp=a,o.windingNumber=0,o.inside=!1,o.fixUpperEdge=!1,o.sentinel=!0,o.dirty=!1,o.nodeUp=t.dict.insert(o)},i.initEdgeDict=function(t){t.dict=new fk(t,i.edgeLeq);var e=t.bmax[0]-t.bmin[0],r=t.bmax[1]-t.bmin[1],n=t.bmin[0]-e,o=t.bmax[0]+e,a=t.bmin[1]-r,s=t.bmax[1]+r;i.addSentinel(t,n,o,a),i.addSentinel(t,n,o,s)},i.doneEdgeDict=function(t){for(var e,r=0;(e=t.dict.min().key)!==null;)e.sentinel||(Be(e.fixUpperEdge),Be(++r===1)),Be(e.windingNumber===0),i.deleteRegion(t,e)},i.removeDegenerateEdges=function(t){var e,r,n,o=t.mesh.eHead;for(e=o.next;e!==o;e=r)r=e.next,n=e.Lnext,Me.vertEq(e.Org,e.Dst)&&e.Lnext.Lnext!==e&&(i.spliceMergeVertices(t,n,e),t.mesh.delete(e),e=n,n=e.Lnext),n.Lnext===e&&(n!==e&&((n===r||n===r.Sym)&&(r=r.next),t.mesh.delete(n)),(e===r||e===r.Sym)&&(r=r.next),t.mesh.delete(e))},i.initPriorityQ=function(t){var e,r,n,o=0;for(n=t.mesh.vHead,r=n.next;r!==n;r=r.next)o++;for(o+=8,e=t.pq=new hk(o,Me.vertLeq),n=t.mesh.vHead,r=n.next;r!==n;r=r.next)r.pqHandle=e.insert(r);return r!==n?!1:(e.init(),!0)},i.donePriorityQ=function(t){t.pq=null},i.removeDegenerateFaces=function(t,e){var r,n,o;for(r=e.fHead.next;r!==e.fHead;r=n)n=r.next,o=r.anEdge,Be(o.Lnext!==o),o.Lnext.Lnext===o&&(i.addWinding(o.Onext,o),t.mesh.delete(o));return!0},i.computeInterior=function(t,e){e===void 0&&(e=!0);var r,n;if(i.removeDegenerateEdges(t),!i.initPriorityQ(t))return!1;for(i.initEdgeDict(t);(r=t.pq.extractMin())!==null;){for(;n=t.pq.min(),!(n===null||!Me.vertEq(n,r));)n=t.pq.extractMin(),i.spliceMergeVertices(t,r.anEdge,n.anEdge);i.sweepEvent(t,r)}return t.event=t.dict.min().key.eUp.Org,i.debugEvent(t),i.doneEdgeDict(t),i.donePriorityQ(t),i.removeDegenerateFaces(t,t.mesh)?(e&&t.mesh.check(),!0):!1},i}(),yk=function(){function i(){this.mesh=new fM,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=Tt.ODD,this.dict=null,this.pq=null,this.event=null,this.vertexIndexCounter=0,this.vertices=[],this.vertexIndices=[],this.vertexCount=0,this.elements=[],this.elementCount=0}return i.prototype.dot_=function(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]},i.prototype.normalize_=function(t){var e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2];if(!e)throw"Zero-size vector!";e=Math.sqrt(e),t[0]/=e,t[1]/=e,t[2]/=e},i.prototype.longAxis_=function(t){var e=0;return Math.abs(t[1])>Math.abs(t[0])&&(e=1),Math.abs(t[2])>Math.abs(t[e])&&(e=2),e},i.prototype.computeNormal_=function(t){var e,r,n,o,a,s,l=[0,0,0],c=[0,0,0],d=[0,0,0],u=[0,0,0],p=[0,0,0],h=[null,null,null],f=[null,null,null],m=this.mesh.vHead;e=m.next;for(var y=0;y<3;++y)o=e.coords[y],c[y]=o,f[y]=e,l[y]=o,h[y]=e;for(e=m.next;e!==m;e=e.next)for(var g=0;g<3;++g)o=e.coords[g],o<c[g]&&(c[g]=o,f[g]=e),o>l[g]&&(l[g]=o,h[g]=e);var v=0;if(l[1]-c[1]>l[0]-c[0]&&(v=1),l[2]-c[2]>l[v]-c[v]&&(v=2),c[v]>=l[v]){t[0]=0,t[1]=0,t[2]=1;return}for(s=0,r=f[v],n=h[v],d[0]=r.coords[0]-n.coords[0],d[1]=r.coords[1]-n.coords[1],d[2]=r.coords[2]-n.coords[2],e=m.next;e!==m;e=e.next)u[0]=e.coords[0]-n.coords[0],u[1]=e.coords[1]-n.coords[1],u[2]=e.coords[2]-n.coords[2],p[0]=d[1]*u[2]-d[2]*u[1],p[1]=d[2]*u[0]-d[0]*u[2],p[2]=d[0]*u[1]-d[1]*u[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_(d)]=1)},i.prototype.checkOrientation_=function(){for(var t=this.mesh.fHead,e,r=this.mesh.vHead,n,o=0,a=t.next;a!==t;a=a.next)if(n=a.anEdge,!(n.winding<=0))do o+=(n.Org.s-n.Dst.s)*(n.Org.t+n.Dst.t),n=n.Lnext;while(n!==a.anEdge);if(o<0){for(e=r.next;e!==r;e=e.next)e.t=-e.t;this.tUnit[0]=-this.tUnit[0],this.tUnit[1]=-this.tUnit[1],this.tUnit[2]=-this.tUnit[2]}},i.prototype.projectPolygon_=function(){var t=this.mesh.vHead,e=[0,0,0],r,n,o=!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),o=!0),r=this.sUnit,n=this.tUnit;var a=this.longAxis_(e);r[a]=0,r[(a+1)%3]=1,r[(a+2)%3]=0,n[a]=0,n[(a+1)%3]=0,n[(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,n);o&&this.checkOrientation_();for(var l=!0,c=t.next;c!==t;c=c.next)l?(this.bmin[0]=this.bmax[0]=c.s,this.bmin[1]=this.bmax[1]=c.t,l=!1):(c.s<this.bmin[0]&&(this.bmin[0]=c.s),c.s>this.bmax[0]&&(this.bmax[0]=c.s),c.t<this.bmin[1]&&(this.bmin[1]=c.t),c.t>this.bmax[1]&&(this.bmax[1]=c.t))},i.prototype.addWinding_=function(t,e){t.winding+=e.winding,t.Sym.winding+=e.Sym.winding},i.prototype.tessellateMonoRegion_=function(t,e){var r,n;if(r=e.anEdge,!(r.Lnext!==r&&r.Lnext.Lnext!==r))throw"Mono region invalid";for(;Me.vertLeq(r.Dst,r.Org);r=r.Lprev);for(;Me.vertLeq(r.Org,r.Dst);r=r.Lnext);n=r.Lprev;for(var o=void 0;r.Lnext!==n;)if(Me.vertLeq(r.Dst,n.Org)){for(;n.Lnext!==r&&(Me.edgeGoesLeft(n.Lnext)||Me.edgeSign(n.Org,n.Dst,n.Lnext.Dst)<=0);)o=t.connect(n.Lnext,n),n=o.Sym;n=n.Lprev}else{for(;n.Lnext!==r&&(Me.edgeGoesRight(r.Lprev)||Me.edgeSign(r.Dst,r.Org,r.Lprev.Org)>=0);)o=t.connect(r,r.Lprev),r=o.Sym;r=r.Lnext}if(n.Lnext===r)throw"Mono region invalid";for(;n.Lnext.Lnext!==r;)o=t.connect(n.Lnext,n),n=o.Sym;return!0},i.prototype.tessellateInterior_=function(t){for(var e,r=t.fHead.next;r!==t.fHead;r=e)if(e=r.next,r.inside&&!this.tessellateMonoRegion_(t,r))return!1;return!0},i.prototype.discardExterior_=function(t){for(var e,r=t.fHead.next;r!==t.fHead;r=e)e=r.next,r.inside||t.zapFace(r)},i.prototype.setWindingNumber_=function(t,e,r){for(var n,o=t.eHead.next;o!==t.eHead;o=n)n=o.next,o.Rface.inside!==o.Lface.inside?o.winding=o.Lface.inside?e:-e:r?t.delete(o):o.winding=0},i.prototype.getNeighbourFace_=function(t){return!t.Rface||!t.Rface.inside?-1:t.Rface.n},i.prototype.outputPolymesh_=function(t,e,r,n){var o,a=0,s=0,l;r>3&&t.mergeConvexFaces(r);for(var c=t.vHead.next;c!==t.vHead;c=c.next)c.n=-1;for(var d=t.fHead.next;d!==t.fHead;d=d.next)if(d.n=-1,!!d.inside){o=d.anEdge,l=0;do{var c=o.Org;c.n===-1&&(c.n=s,s++),l++,o=o.Lnext}while(o!==d.anEdge);if(l>r)throw"Face vertex greater that support polygon";d.n=a,++a}this.elementCount=a,e===kr.CONNECTED_POLYGONS&&(a*=2),this.elements=[],this.elements.length=a*r,this.vertexCount=s,this.vertices=[],this.vertices.length=s*n,this.vertexIndices=[],this.vertexIndices.length=s;for(var c=t.vHead.next;c!==t.vHead;c=c.next)if(c.n!==-1){var u=c.n*n;this.vertices[u+0]=c.coords[0],this.vertices[u+1]=c.coords[1],n>2&&(this.vertices[u+2]=c.coords[2]),this.vertexIndices[c.n]=c.idx}for(var p=0,d=t.fHead.next;d!==t.fHead;d=d.next)if(!!d.inside){o=d.anEdge,l=0;do{var c=o.Org;this.elements[p++]=c.n,l++,o=o.Lnext}while(o!==d.anEdge);for(var h=l;h<r;++h)this.elements[p++]=-1;if(e===kr.CONNECTED_POLYGONS){o=d.anEdge;do this.elements[p++]=this.getNeighbourFace_(o),o=o.Lnext;while(o!==d.anEdge);for(var f=l;f<r;++f)this.elements[p++]=-1}}},i.prototype.outputContours_=function(t,e){var r,n,o=0,a=0;this.vertexCount=0,this.elementCount=0;for(var s=t.fHead.next;s!==t.fHead;s=s.next)if(!!s.inside){n=r=s.anEdge;do this.vertexCount++,r=r.Lnext;while(r!==n);this.elementCount++}this.elements=[],this.elements.length=this.elementCount*2,this.vertices=[],this.vertices.length=this.vertexCount*e,this.vertexIndices=[],this.vertexIndices.length=this.vertexCount;var l=0,c=0,d=0;o=0;for(var s=t.fHead.next;s!==t.fHead;s=s.next)if(!!s.inside){a=0,n=r=s.anEdge;do this.vertices[l++]=r.Org.coords[0],this.vertices[l++]=r.Org.coords[1],e>2&&(this.vertices[l++]=r.Org.coords[2]),this.vertexIndices[c++]=this.vertexIdCallback?this.vertexIdCallback(r):r.Org.idx,a++,r=r.Lnext;while(r!==n);this.elements[d++]=o,this.elements[d++]=a,o+=a}},i.prototype.addContour=function(t,e){this.mesh===null&&(this.mesh=new fM),t<2&&(t=2),t>3&&(t=3);for(var r=null,n=0;n<e.length;n+=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[n+0],r.Org.coords[1]=e[n+1],t>2?r.Org.coords[2]=e[n+2]:r.Org.coords[2]=0,r.Org.idx=this.vertexIndexCounter++,this.edgeCreateCallback&&this.edgeCreateCallback(r),r.winding=1,r.Sym.winding=-1},i.prototype.tesselate=function(t,e,r,n,o,a){if(t===void 0&&(t=Tt.ODD),e===void 0&&(e=kr.POLYGONS),a===void 0&&(a=!0),this.vertices=[],this.elements=[],this.vertexIndices=[],this.vertexIndexCounter=0,o&&(this.normal[0]=o[0],this.normal[1]=o[1],this.normal[2]=o[2]),this.windingRule=t,n<2&&(n=2),n>3&&(n=3),!this.mesh)return!1;this.projectPolygon_(),mk.computeInterior(this,a);var s=this.mesh;return e===kr.BOUNDARY_CONTOURS?this.setWindingNumber_(s,1,!0):this.tessellateInterior_(s),a&&s.check(),e===kr.BOUNDARY_CONTOURS?this.outputContours_(s,n):this.outputPolymesh_(s,e,r,n),!0},i}();function Ss(i){var t=i.windingRule,e=t===void 0?Tt.ODD:t,r=i.elementType,n=r===void 0?kr.POLYGONS:r,o=i.polySize,a=o===void 0?3:o,s=i.vertexSize,l=s===void 0?2:s,c=i.normal,d=c===void 0?[0,0,1]:c,u=i.contours,p=u===void 0?[]:u,h=i.strict,f=h===void 0?!0:h,m=i.debug,y=m===void 0?!1:m;if(!p&&f)throw new Error("Contours can't be empty");if(!!p){var g=new yk;i.edgeCreateCallback&&(g.edgeCreateCallback=i.edgeCreateCallback),i.vertexIdCallback&&(g.vertexIdCallback=i.vertexIdCallback);for(var v=0;v<p.length;v++)g.addContour(l||2,p[v]);return g.tesselate(e,n,a,l,d,f),{vertices:g.vertices,vertexIndices:g.vertexIndices,vertexCount:g.vertexCount,elements:g.elements,elementCount:g.elementCount,mesh:y?g.mesh:void 0}}}var sQ=Tt.ODD,lQ=Tt.NONZERO,cQ=Tt.POSITIVE,dQ=Tt.NEGATIVE,uQ=Tt.ABS_GEQ_TWO,pQ=kr.POLYGONS,hQ=kr.CONNECTED_POLYGONS,fQ=kr.BOUNDARY_CONTOURS;function yy(i,t){let e=i.length/2;if(e<2)return[];let r=0;for(let l=0;l<e;l++){let c=(l+1)%e;r+=i[l*2]*i[c*2+1]-i[c*2]*i[l*2+1]}let n=r>0!==t?1:-1,o=[];for(let l=0;l<e;l++){let c=(l+1)%e,d=i[c*2]-i[l*2],u=i[c*2+1]-i[l*2+1],p=Math.hypot(d,u);o.push(p>0?[n*u/p,-n*d/p]:[0,0])}let a=Math.cos(40*Math.PI/180),s=(l,c)=>{if(l[0]*c[0]+l[1]*c[1]<=a)return l;let[d,u]=[l[0]+c[0],l[1]+c[1]],p=Math.hypot(d,u);return p>0?[d/p,u/p]:l};return o.map((l,c)=>[s(l,o[(c+e-1)%e]),s(l,o[(c+1)%e])])}function gy(i,t,e){let r=i.length/2,n=new Float32Array(r+1);if(!(t>0)||!(e>0)||r<2)return{u:n,vScale:0};let o=0;for(let a=0;a<r;a++){let s=(a+1)%r;o+=Math.hypot((i[s*2]-i[a*2])/t,(i[s*2+1]-i[a*2+1])/e),n[a+1]=o}return{u:n,vScale:Math.sqrt(t*e)}}function vy(i,t,e){for(let r=0;r<e.length;r+=3){let n=e[r]*3,o=e[r+1]*3,a=e[r+2]*3,s=i[o]-i[n],l=i[o+1]-i[n+1],c=i[o+2]-i[n+2],d=i[a]-i[n],u=i[a+1]-i[n+1],p=i[a+2]-i[n+2],h=l*p-c*u,f=c*d-s*p,m=s*u-l*d,y=t[n]+t[o]+t[a],g=t[n+1]+t[o+1]+t[a+1],v=t[n+2]+t[o+2]+t[a+2];if(h*y+f*g+m*v<0){let b=e[r+1];e[r+1]=e[r+2],e[r+2]=b}}}var by={vertices:[160,160,-160,160,-160,-160,160,-160],vertexIndices:[1,0,3,2],vertexCount:4,elements:[0,4],elementCount:1,mesh:void 0},vM={vertices:[],vertexIndices:[],vertexCount:0,elements:[],elementCount:0,mesh:void 0},xy={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};function iS(i,t){return i.normals[t*3+2]<.9999}var bM=new WeakMap;function Sy(i){let t=bM.get(i);if(t!==void 0)return t;if(!(i.rise>0))return i;let e=new Float32Array(i.normals),r=i.positions.length/3;for(let o=0;o<r;o++){if(!iS(i,o))continue;let a=e[o*3],s=e[o*3+1],l=Math.hypot(a,s);if(l===0)continue;let c=i.rise-i.positions[o*3+2],d=Math.min(1,Math.max(0,1-c/i.rise)),u=Math.sqrt(1-d*d);e[o*3]=a/l*u,e[o*3+1]=s/l*u,e[o*3+2]=d}let n={...i,normals:e};return bM.set(i,n),n}function wy(i,t,e,r){let n=(t-i.minX)/i.spanX,o=(e-i.minY)/i.spanY;return r?[o,n]:[n,o]}var xM=2,Il=class extends Ol.BufferGeometry{constructor(e,r,n=12,o=Tt.ODD,a,s=!1){super();this.type="FlatExtrusionGeometry";this._nearSide=new Uint8Array(0);this._vScale=0;this._shape=e,this._depth=r,this._curveSegments=n,this._windingRule=o,this._uvPitch=s?void 0:a,this._legacy=s;let l=[e.extractShapePointsToFlatArray([],n),...e.shapeHoles.map(W=>W.extractShapePointsToFlatArray([],n))],c;try{c=Ss({contours:l,windingRule:o,elementType:kr.POLYGONS,polySize:3,vertexSize:2,strict:!0})}catch{c=xy}let d=c?.vertexCount??0,u=c?.elementCount??0,p=1/0,h=1/0,f=-1/0,m=-1/0;for(let W of l)for(let U=0;U<W.length;U+=2)W[U]<p&&(p=W[U]),W[U]>f&&(f=W[U]),W[U+1]<h&&(h=W[U+1]),W[U+1]>m&&(m=W[U+1]);let y=this._uvPitch,g=y??(f-p||1),v=y??(m-h||1),b=y===void 0?p:0,S=y===void 0?h:0,x=l.map((W,U)=>yy(W,U>0)),w=0;for(let W of x)w+=W.length;let A=d*2+w*4,C=u*3*2+w*6,P=new Float32Array(A*3),M=new Float32Array(A*3),B=new Float32Array(A*2),I=new Uint32Array(C),_=new Uint8Array(A),E=0,R=0,L=0,F=!1,k=(W,U,G,q,X,Y,K=(W-b)/g,te=(U-S)/v)=>{let ue=R*3;P[ue]=W,P[ue+1]=U,P[ue+2]=G,M[ue]=q,M[ue+1]=X,M[ue+2]=Y,_[R]=G===r?F?xM:1:0,B[R*2]=K,B[R*2+1]=te,R++};if(c!==void 0)for(let[W,U]of[[r,1],[0,-1]]){let G=R;for(let q=0;q<d;q++)k(c.vertices[q*2],c.vertices[q*2+1],W,0,0,U);for(let q=0;q<u;q++){let[X,Y,K]=[c.elements[q*3],c.elements[q*3+1],c.elements[q*3+2]];I[L++]=G+X,I[L++]=G+(U>0?Y:K),I[L++]=G+(U>0?K:Y)}}F=!0;for(let W=0;W<l.length;W++){let U=l[W],G=x[W],q=U.length/2,{u:X,vScale:Y}=s?{u:new Float32Array(q+1),vScale:0}:gy(U,g,v);E=Y;let K=Y===0?0:r/Y,te={minX:b,minY:S,spanX:g,spanY:v},ue=(se,[ce,de],ge,xe)=>{let ye=U[se*2],Z=U[se*2+1],[pe,re]=s?wy(te,ye,Z,ge):[xe,ge?0:K];k(ye,Z,ge?0:r,ce,de,0,pe,re)};for(let se=0;se<G.length;se++){let ce=(se+1)%q,[de,ge]=G[se],[xe,ye]=[X[se],X[se+1]],Z=R;ue(se,de,!1,xe),ue(se,de,!0,xe),ue(ce,ge,!1,ye),ue(ce,ge,!0,ye),I[L++]=Z,I[L++]=Z+1,I[L++]=Z+2,I[L++]=Z+3,I[L++]=Z+2,I[L++]=Z+1}}vy(P,M,I),this.setAttribute("position",new Ol.BufferAttribute(P,3)),this.setAttribute("normal",new Ol.BufferAttribute(M,3)),this.setAttribute("uv",new Ol.BufferAttribute(B,2)),this.setIndex(new Ol.BufferAttribute(I,1)),this._nearSide=_,this._vScale=E}takeDepthStateFrom(e){let r=e;r._nearSide!==void 0&&(this._depth=r._depth??this._depth,this._nearSide=r._nearSide,this._vScale=r._vScale??this._vScale)}canShiftDepthTo(e){return this._nearSide.length>0&&this._depth>0&&e>0}shiftDepthTo(e){if(!this.canShiftDepthTo(e))return!1;let r=e-this._depth;if(this._depth=e,r===0)return!0;let n=this.getAttribute("position");if(n===void 0)return!1;let o=n.array,a=this.getAttribute("uv"),s=a?.array,l=this._vScale>0?r/this._vScale:0,c=this._nearSide;for(let d=0;d<c.length;d++){let u=c[d];u!==0&&(o[d*3+2]+=r,u===xM&&s!==void 0&&(s[d*2+1]+=l))}return n.needsUpdate=!0,a!==void 0&&l!==0&&(a.needsUpdate=!0),this.refreshDepthBounds(e),!0}refreshDepthBounds(e){if(this.boundingBox===null&&this.boundingSphere===null)return;this.boundingBox===null&&this.computeBoundingBox();let r=this.boundingBox;r.min.z=Math.min(0,e),r.max.z=Math.max(0,e),this.boundingSphere!==null&&r.getBoundingSphere(this.boundingSphere)}clone(){let e=new Il(this._shape,this._depth,this._curveSegments,this._windingRule,this._uvPitch,this._legacy);return e.userData=ys(this.userData),e}};var Dl=require("three");var ad=class extends Dl.BufferGeometry{constructor(e,r=12,n={}){super();this.type="ShapeGeometry";this.windingRule=Tt.ODD;this.elementType=kr.POLYGONS;this.polySize=3;this.vertexSize=2;this.strict=!0;this._shape=e,this._curveSegments=r,this._triangulationOptions=Object.assign({windingRule:Tt.ODD,elementType:kr.POLYGONS,polySize:3,vertexSize:2,strict:!0},n);let o=this._shape.extractShapePointsToFlatArray([],this._curveSegments),a=this._shape.shapeHoles.map(f=>f.extractShapePointsToFlatArray([],this._curveSegments)),s,l=!0,c=!0,d,u;for(let f=0,m=o.length/2;f<m;f++){let y=f*2,g=o[y+0],v=o[y+1];if(d!==void 0&&g!==d&&(l=!1),u!==void 0&&v!==u&&(c=!1),d=g,u=v,!l&&!c)break}if(!l&&!c)try{s=Ss({contours:[o,...a],windingRule:this._triangulationOptions.windingRule,elementType:this._triangulationOptions.elementType,polySize:this._triangulationOptions.polySize,vertexSize:this._triangulationOptions.vertexSize,strict:this._triangulationOptions.strict})}catch{s=by}let p=s?.vertexCount??1,h=s?.elementCount??1;if(this._positionAttribute=new Dl.BufferAttribute(new Float32Array(p*3),3),this._normalAttribute=new Dl.BufferAttribute(new Float32Array(p*3),3),this._uvAttribute=new Dl.BufferAttribute(new Float32Array(p*2),2),this._indexAttribute=new Dl.BufferAttribute(new Uint32Array(h*3),1),s){let f=1/0,m=-1/0,y=1/0,g=-1/0;for(let S=0,x=p;S<x;S++){let w=S*2,A=s.vertices[w+0],C=s.vertices[w+1];A<f&&(f=A),A>m&&(m=A),C<y&&(y=C),C>g&&(g=C)}let v=m-f,b=g-y;for(let S=0,x=p;S<x;S++){let w=S*2,A=s.vertices[w+0],C=s.vertices[w+1],P=(A-f)/v,M=(C-y)/b;this._positionAttribute.setXYZ(S,A,C,0),this._normalAttribute.setXYZ(S,0,0,1),this._uvAttribute.setXY(S,P,M)}for(let S=0,x=h;S<x;S++){let w=S*3,A=s.elements[w+0],C=s.elements[w+1],P=s.elements[w+2];this._indexAttribute.setX(w+0,A),this._indexAttribute.setX(w+1,C),this._indexAttribute.setX(w+2,P)}}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 ad(this._shape,this._curveSegments);return e.userData=ys(this.userData),e}};var ui=require("three");var Ay;var vk=.4;function wM(){return Ay!==void 0}function AM(i,t){let r=[i.extractShapePointsToFlatArray([],t)];for(let l of i.shapeHoles)r.push(l.extractShapePointsToFlatArray([],t));let n=0;for(let l of r)n+=l.length>>1;let o=new Float64Array(n*2),a=new Uint32Array(r.length),s=0;for(let l=0;l<r.length;l++)o.set(r[l],s*2),s+=r[l].length>>1,a[l]=s;return{points:o,ends:a}}function bk(i){let t=2166136261;for(let e=0;e<i.length;e++)t^=i[e],t=Math.imul(t,16777619)>>>0;return t}function xk(i,t){let e=[t],r=n=>{e.push(n.points.length,n.isClosed?1:0,n.roundness??0);for(let o of n.points){e.push(o.roundness??0,o.position.x,o.position.y);for(let a of o.controls)e.push(a.position.x,a.position.y)}e.push(n.shapeHoles.length);for(let o of n.shapeHoles)r(o)};return r(i),bk(new Uint8Array(new Float64Array(e).buffer))}var Sk=new ui.Matrix3;function wk(i,t,e,r,n){let o=1/0;for(let a=2;a<i.length;a+=3)i[a]<o&&(o=i[a]);if(o===1/0&&(o=0),o!==0)for(let a=2;a<i.length;a+=3)i[a]-=o;return{positions:i,normals:t,uvs:e,indices:r,rise:n-o}}function Gp(i,t,e,r,n,o){let a=i.positions.length/3,s=n.elements,l=Sk.getNormalMatrix(n).elements;for(let d=0;d<a;d++){let u=d*3,p=(e+d)*3,h=i.positions[u],f=i.positions[u+1],m=i.positions[u+2];t.positions[p]=s[0]*h+s[4]*f+s[8]*m+s[12],t.positions[p+1]=s[1]*h+s[5]*f+s[9]*m+s[13],t.positions[p+2]=s[2]*h+s[6]*f+s[10]*m+s[14];let y=i.normals[u],g=i.normals[u+1],v=i.normals[u+2];t.normals[p]=l[0]*y+l[3]*g+l[6]*v,t.normals[p+1]=l[1]*y+l[4]*g+l[7]*v,t.normals[p+2]=l[2]*y+l[5]*g+l[8]*v;let b=(e+d)*2;if(o===void 0)t.uvs[b]=i.uvs[d*2],t.uvs[b+1]=i.uvs[d*2+1];else{let[S,x]=o(h,f,i.uvs[d*2],i.uvs[d*2+1],d);t.uvs[b]=S,t.uvs[b+1]=x}}let c=n.determinant()<0;for(let d=0;d<i.indices.length;d+=3)t.indices[r+d]=i.indices[d]+e,t.indices[r+d+1]=i.indices[d+(c?2:1)]+e,t.indices[r+d+2]=i.indices[d+(c?1:2)]+e}var Ak=new ui.Matrix4,Ck=new ui.Matrix4,Ek=new ui.Matrix4().makeScale(1,1,-1);function Tk(i,t,e,r,n,o=!1){let a=r.positions.length/3,s=e-r.rise,l=r.rise,{points:c,ends:d}=AM(i,t),u=1/0,p=1/0,h=-1/0,f=-1/0;for(let k=0;k<c.length;k+=2)c[k]<u&&(u=c[k]),c[k]>h&&(h=c[k]),c[k+1]<p&&(p=c[k+1]),c[k+1]>f&&(f=c[k+1]);o&&(n=void 0);let m=n??h-u,y=n??f-p,g={minX:u,minY:p,spanX:h-u||1,spanY:f-p||1},v=[],b=0;for(let k of d)v.push({at:b,count:k-b}),b=k;let S=0;for(let k of v)S+=k.count;let x=a*2+S*4,w=new Float32Array(x*3),A=new Float32Array(x*3),C=new Float32Array(x*2),P=new Uint32Array(r.indices.length*2+S*6),M=new Uint8Array(x),B=0,I=n===void 0?void 0:(k,W)=>[k/n,W/n],_=o?(k,W,U,G,q)=>iS(r,q)?[G,U]:[U,G]:I,E=o?Sy(r):r,R={positions:w,normals:A,uvs:C,indices:P};Gp(E,R,0,0,Ak.makeTranslation(0,0,s),I),Gp(E,R,a,r.indices.length,Ck.makeTranslation(0,0,l).multiply(Ek),_),M.fill(1,0,a);let L=a*2,F=r.indices.length*2;for(let k=0;k<v.length;k++){let{at:W,count:U}=v[k],G=c.subarray(W*2,(W+U)*2),q=yy(G,k>0),X=o?{u:new Float32Array(U+1),vScale:0}:gy(G,m,y),Y=X.u;B=X.vScale;for(let K=0;K<U;K++){let te=(K+1)%U,[ue,se]=q[K],ce=L;for(let[de,ge,xe,ye,Z,pe]of[[G[K*2],G[K*2+1],ue,s,Y[K],oS],[G[te*2],G[te*2+1],se,s,Y[K+1],oS],[G[te*2],G[te*2+1],se,l,Y[K+1],0],[G[K*2],G[K*2+1],ue,l,Y[K],0]]){let re=L*3;if(w[re]=de,w[re+1]=ge,w[re+2]=ye,A[re]=xe[0],A[re+1]=xe[1],A[re+2]=0,o){let[Se,Ce]=wy(g,de,ge,pe===0);C[L*2]=Se,C[L*2+1]=Ce}else C[L*2]=Z,C[L*2+1]=B===0?0:(ye-l)/B;M[L]=pe,L++}P[F++]=ce,P[F++]=ce+1,P[F++]=ce+2,P[F++]=ce,P[F++]=ce+2,P[F++]=ce+3}}return vy(w,A,P),{positions:w,normals:A,uvs:C,indices:P,nearSide:M,vScale:B}}var oS=2,aS=new Map,SM={assemblies:0,placements:0};function CM(i){let{owner:t,shape:e,curveSegments:r,assembledAt:n,bevel:o,bevelSegments:a}=i,s=xk(e,r),l=t??`outline:${s}`,c=`${o}/${a}`,d=aS.get(l);if(d!==void 0&&d.outlineVersion===s&&d.capKey===c&&(i.stillServes?.(d)??!0))return SM.placements++,d.cap;let u=Pk(e,r,n,o,a);SM.assemblies++;try{let p=Mk(u,n);return aS.set(l,{outlineVersion:s,capKey:c,assembledAt:n,cap:p}),p}finally{u.free()}}function EM(i){aS.delete(i)}var sd=class extends ui.BufferGeometry{constructor(e,r,n=0,o=12,a=3,s,l,c=!1){super();this.type="ShapeGeometry";this._nearSide=new Uint8Array(0);this._effectiveBevel=0;this._vScale=0;if(Ay===void 0)throw new Error("bevel-wasm is not loaded");this._shape=e,this._uvPitch=l,this._legacy=c,this._depth=r,this._bevel=n,this._curveSegments=o,this._bevelSegments=a,this._ownerId=s,this.rebuild()}takeDepthStateFrom(e){let r=e;r._nearSide!==void 0&&(this._depth=r._depth??this._depth,this._nearSide=r._nearSide,this._vScale=r._vScale??this._vScale,this._effectiveBevel=r._effectiveBevel??this._effectiveBevel)}canShiftDepthTo(e){return this._nearSide.length>0&&Rl(this._effectiveBevel,e)&&Rl(this._effectiveBevel,this._depth)}shiftDepthTo(e){if(!this.canShiftDepthTo(e))return!1;let r=e-this._depth;if(this._depth=e,r===0)return!0;let n=this.getAttribute("position");if(n===void 0)return!1;let o=n.array,a=this.getAttribute("uv"),s=a?.array,l=this._vScale>0?r/this._vScale:0,c=this._nearSide;for(let d=0;d<c.length;d++){let u=c[d];u!==0&&(o[d*3+2]+=r,u===oS&&s!==void 0&&(s[d*2+1]+=l))}return n.needsUpdate=!0,a!==void 0&&l!==0&&(a.needsUpdate=!0),this.refreshDepthBounds(e),!0}refreshDepthBounds(e){if(this.boundingBox===null&&this.boundingSphere===null)return;this.boundingBox===null&&this.computeBoundingBox();let r=this.boundingBox;r.min.z=Math.min(0,e),r.max.z=Math.max(0,e),this.boundingSphere!==null&&r.getBoundingSphere(this.boundingSphere)}setDepth(e){e!==this._depth&&(this._depth=e,this.rebuild(),this.computeBoundingSphere(),this.computeBoundingBox())}rebuild(){let e=CM({owner:this._ownerId,shape:this._shape,curveSegments:this._curveSegments,assembledAt:this._depth,bevel:this._bevel,bevelSegments:this._bevelSegments,stillServes:l=>Rl(l.cap.rise,this._depth)&&Rl(l.cap.rise,l.assembledAt)}),r=Tk(this._shape,this._curveSegments,this._depth,e,this._uvPitch,this._legacy);this._nearSide=r.nearSide,this._vScale=r.vScale,this._effectiveBevel=e.rise;let n=this.getAttribute("position"),o=this.getAttribute("normal"),a=this.getAttribute("uv"),s=this.getIndex();if(n!==void 0&&o!==void 0&&a!==void 0&&s!==null&&n.array.length===r.positions.length&&o.array.length===r.normals.length&&a.array.length===r.uvs.length&&s.array.length===r.indices.length){n.array.set(r.positions),o.array.set(r.normals),a.array.set(r.uvs),s.array.set(r.indices),n.needsUpdate=!0,o.needsUpdate=!0,a.needsUpdate=!0,s.needsUpdate=!0;return}this.setAttribute("position",new ui.BufferAttribute(r.positions,3)),this.setAttribute("normal",new ui.BufferAttribute(r.normals,3)),this.setAttribute("uv",new ui.BufferAttribute(r.uvs,2)),this.setIndex(new ui.BufferAttribute(r.indices,1))}clone(){let e=new sd(this._shape,this._depth,this._bevel,this._curveSegments,this._bevelSegments,this._ownerId,this._uvPitch,this._legacy);return e.userData=ys(this.userData),e}};function Pk(i,t,e,r,n){let{points:o,ends:a}=AM(i,t);return Ay.assemble_cap(o,a,e,r,0,Math.max(1,Math.floor(n)),vk,40)}function TM(i,t,e,r,n){if(!(Ay===void 0||!(t>0)))return CM({owner:n,shape:i,curveSegments:r,assembledAt:2*t,bevel:t,bevelSegments:e})}function Mk(i,t){return wk(i.positions(),i.normals(),i.uvs(),i.indices(),t)}function Rl(i,t){return t*.5>i*(1+.001)}var Qn=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,subdivisions:40,roundness:0,extrudeBevelSize:0,extrudeBevelSegments:3,windingRule:Tt.ODD},i.parameters),r=Math.abs(e.width),n=Math.abs(e.height??e.width),o=Math.abs(e.depth??0),a=i.shape??t?.shape,s=a?.roundness??e.roundness,l;a!==void 0&&(a instanceof ht?(l=a,(l.width!==r||l.height!==n)&&l.applySize(r,n)):l=new ht(r,n).fromJSON(a),i.parameters?.roundness!==void 0&&i.parameters?.roundness>0&&l.update());let c=l??new ht(r,n);return{parameters:Object.assign(e,{width:r,height:n,depth:o,roundness:s}),shape:c,ownerId:i.ownerId??t?.ownerId}}static build(i){let{depth:t,extrudeBevelSize:e,extrudeBevelSegments:r,subdivisions:n,roundness:o,windingRule:a,uvPitch:s,extrusionVersion:l}=i.parameters,c=l===1;i.shape.roundness=o;let d;return t<=0?d=new ad(i.shape,n,{windingRule:a}):e<=0?d=new Il(i.shape,t,n,a,s,c):wM()?d=new sd(i.shape,t,e,n,r,i.ownerId,s,c):(console.error("[extrude] engine not loaded \u2014 extruding without a bevel"),d=new Il(i.shape,t,n,a,s,c)),Object.assign(d,{userData:{...i,type:"VectorGeometry"}})}};var uo=require("three"),MM=Math.PI*2,cd=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,spikes:64,angle:360,innerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1},i.parameters);return e.angle=uo.MathUtils.clamp(e.angle,0,360),{shape:i.shape&&i.shape instanceof ht?i.shape:new ht,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)})}}static build(i){let{width:t,height:e,spikes:r,angle:n,innerRadius:o,depth:a,extrudeBevelSize:s,extrudeBevelSegments:l,extrusionVersion:c}=i.parameters,d=i.shape,u=t*.5,p=e*.5,h=Ok(d,u,p,n*Math.PI/180,r,o);d.isClosed=!0,d.update();let f;return n===0?(f=new uo.BufferGeometry,f.setAttribute("position",new uo.Float32BufferAttribute([],3))):f=Qn.create({shape:d,parameters:{subdivisions:h,depth:a,extrudeBevelSize:s,extrudeBevelSegments:l,extrusionVersion:c}}),Object.assign(f,{userData:{...i,type:"EllipseGeometry"}})}};function Ok(i,t,e,r,n,o){if(r>=MM)return n>30||n%4===0?(Dk(i,t,e,o),Math.round(n/4)):PM(i,r,n,t,e,o);r=Math.max(r,.001);let a={x:0,y:e},s=r+Math.PI*.5,l={x:Math.cos(s)*t,y:Math.sin(s)*e},c=hM({px:a.x,py:a.y,cx:l.x,cy:l.y,rx:t,ry:e,largeArcFlag:r>Math.PI,sweepFlag:!0});return n>30||n%c.length===0?Ik(i,a.x,a.y,c,n,t,e,o):PM(i,r,n,t,e,o)}function Ik(i,t,e,r,n,o,a,s){let l=Math.round(n/r.length);i.addPoint(ld(t,e));for(let c=0,d=r.length;c<d;c++){let u=r[c],p=i.points[c],h=ld(u.x,u.y);p.controls[1].position.set(u.x1,u.y1),h.controls[0].position.set(u.x2,u.y2),i.addPoint(h)}return s>0?OM(i,o,a,s):i.addPoint(ld(0,0)),l}function PM(i,t,e,r,n,o){let a=-t/e;for(let s=0;s<=e;s++){let l=a*s,c=Math.sin(l)*r,d=Math.cos(l)*n;i.addPoint(ld(c,d))}return t<MM?o>0?OM(i,r,n,o):i.addPoint(ld(0,0)):(i.removePoint(i.points[i.points.length-1]),o>0&&IM(i,r,n,o)),1}function Dk(i,t,e,r=0,n=0,o=0){let a=.5522847498,s=t*a,l=e*a;i.addPoint(Cy(n-t,o,n-t,o-l,n-t,o+l)),i.addPoint(Cy(n,o+e,n-s,o+e,n+s,o+e)),i.addPoint(Cy(n+t,o,n+t,o+l,n+t,o-l)),i.addPoint(Cy(n,o-e,n+s,o-e,n-s,o-e)),r>0&&IM(i,t,e,r)}function ld(i,t){return new co(uo.MathUtils.generateUUID(),new uo.Vector2(i,t))}function Cy(i,t,e,r,n,o){let a=ld(i,t);return a.controls[0].position.set(e,r),a.controls[1].position.set(n,o),a}function OM(i,t,e,r){DM(i,t,e,r).forEach(o=>i.addPoint(o))}function IM(i,t,e,r){let n=DM(i,t,e,r),o=new ht;n.forEach(a=>o.addPoint(a)),o.isClosed=!0,i.shapeHoles.push(o)}function DM(i,t,e,r){let n=r*t/100,o=n*(Math.abs(e)/Math.abs(t)),a=new uo.Vector2(n/t,o/e),s=i.points.map(l=>{let c=l.clone();return c.uuid=uo.MathUtils.generateUUID(),c}).reverse();return s.forEach(l=>{l.position.multiply(a);let c=l.controls[0].position.clone().multiply(a),d=l.controls[1].position.clone().multiply(a);l.controls[0].position.copy(d),l.controls[1].position.copy(c)}),s}var RM=require("three");var BM=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,detail:0,corner:0,cornerSides:4},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(i){let{width:t,height:e,depth:r,detail:n,corner:o,cornerSides:a}=i.parameters,s=n===0&&o!==0?new Up(t*.5,o,a):new RM.IcosahedronGeometry(t*.5,n),l=e/t,c=r/t;return(l!==1||c!==1)&&s.scale(1,l,c),Object.assign(s,{userData:{...i,type:"IcosahedronGeometry"}})}},Up=class extends bs{constructor(t=1,e=.2,r=4){let n=(1+Math.sqrt(5))/2,o=[-1,n,0,1,n,0,-1,-n,0,1,-n,0,0,-1,n,0,1,n,0,-1,-n,0,1,-n,n,0,-1,n,0,1,-n,0,-1,-n,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(o,a,s,t,e,r),this.type=s}static fromJSON(t){return new Up(t.radius,t.corner,t.cornerSides)}};var Ey=require("three"),NM=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){(i.parameters?.points??[]).forEach(r=>{Array.isArray(r)&&(r.x=r[0],r.y=r[1])});let e=Object.assign({},t?.parameters??{width:100,segments:64,verticalSegments:64,points:[{x:0,y:-50,id:0},{x:50,y:-50,id:1},{x:50,y:50,id:2},{x:0,y:50,id:3}]},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(i){let{points:t,segments:e,verticalSegments:r}=i.parameters,n=new Ey.Shape;n.moveTo(t[0].x,t[0].y),n.bezierCurveTo(t[1].x,t[1].y,t[2].x,t[2].y,t[3].x,t[3].y);let o=new Ey.LatheGeometry(n.extractPoints(r).shape,e);return o.rotateZ(Math.PI),Object.assign(o,{userData:{...i,type:"LatheGeometry"}})}};var Ni=require("three");var Bl=require("three"),sS=1e4;function dd(i,t){return Math.abs(t-i)/2+Math.min(i,t)}var Ty=class{constructor(t=1){this.subdivisions=t}modify(t){let e=Rk(t),r=this.subdivisions;for(;r-- >0;)e=Bk(e);return Nk(e,t)}};function Rk(i){let t=i.getAttribute("position");if(t===void 0)return console.error("SubdivisionModifier: Position attribute required for subdivision."),{positions:new Float64Array(0),faces:new Uint32Array(0),materialIndices:[],uvs:null};let e=i.getAttribute("uv"),r=i.getIndex(),n=t.count,o=new Map,a=new Uint32Array(n),s=[],l=0;for(let m=0;m<n;m++){let y=t.getX(m),g=t.getY(m),v=t.getZ(m),b=Math.round(y*sS),S=Math.round(g*sS),x=Math.round(v*sS),w=o.get(b);w===void 0&&(w=new Map,o.set(b,w));let A=w.get(S);A===void 0&&(A=new Map,w.set(S,A));let C=A.get(x);C===void 0&&(C=l++,A.set(x,C),s.push(y,g,v)),a[m]=C}let c=[],d=[],u=e===void 0?null:[],p=r!==null?r.count:n,h=(m,y)=>{let g=r!==null?r.getX(m):m,v=r!==null?r.getX(m+1):m+1,b=r!==null?r.getX(m+2):m+2;if(!(g<n&&v<n&&b<n))return;let S=a[g],x=a[v],w=a[b];S===x||x===w||w===S||(c.push(S,x,w),d.push(y),u!==null&&u.push(e.getX(g),e.getY(g),e.getX(v),e.getY(v),e.getX(b),e.getY(b)))},f=i.groups;if(f.length>0)for(let m=0;m<f.length;m++){let y=f[m],g=y.materialIndex===void 0?0:y.materialIndex,v=Math.max(y.start,0),b=Math.min(y.start+y.count,p);for(let S=v;S<b&&S+2<p;S+=3)h(S,g)}else for(let m=0;m+2<p;m+=3)h(m,0);return{positions:Float64Array.from(s),faces:Uint32Array.from(c),materialIndices:d,uvs:u===null?null:Float64Array.from(u)}}function Bk(i){let{positions:t,faces:e,materialIndices:r,uvs:n}=i,o=t.length/3,a=e.length/3,s=n!==null&&a>0,l=a*3,c=new Uint32Array(l),d=new Uint32Array(l),u=new Uint32Array(l),p=new Uint32Array(l),h=new Uint32Array(l),f=0,m=8;for(;m<l*2;)m*=2;let y=m-1,g=new Int32Array(m).fill(-1),v=(E,R)=>{let L=(Math.imul(E,2654435761)^R)&y;for(;;){let F=g[L];if(F===-1)return g[L]=f,c[f]=E,d[f]=R,f++;if(c[F]===E&&d[F]===R)return F;L=L+1&y}},b=(E,R)=>{let L=E<R?E:R,F=E<R?R:E,k=(Math.imul(L,2654435761)^F)&y;for(;;){let W=g[k];if(c[W]===L&&d[W]===F)return W;k=k+1&y}},S=new Uint32Array(o),x=new Float64Array(o*3),w=(E,R,L)=>{let F=E<R?v(E,R):v(R,E),k=++u[F];k===1?p[F]=L:k===2&&(h[F]=L),S[E]++,S[R]++,x[E*3]+=t[R*3],x[E*3+1]+=t[R*3+1],x[E*3+2]+=t[R*3+2],x[R*3]+=t[E*3],x[R*3+1]+=t[E*3+1],x[R*3+2]+=t[E*3+2]};for(let E=0;E<a;E++){let R=e[E*3],L=e[E*3+1],F=e[E*3+2];w(R,L,F),w(L,F,R),w(F,R,L)}let A=new Float64Array(f*3);for(let E=0;E<f;E++){let R=c[E]*3,L=d[E]*3;if(u[E]===2){let W=p[E]*3,U=h[E]*3;A[E*3]=(t[R]+t[L])*.375+(t[W]+t[U])*.125,A[E*3+1]=(t[R+1]+t[L+1])*.375+(t[W+1]+t[U+1])*.125,A[E*3+2]=(t[R+2]+t[L+2])*.375+(t[W+2]+t[U+2])*.125}else A[E*3]=(t[R]+t[L])*.5,A[E*3+1]=(t[R+1]+t[L+1])*.5,A[E*3+2]=(t[R+2]+t[L+2])*.5}let C=new Float64Array(o*3),P;for(let E=0;E<o;E++){let R=S[E];R===3?P=3/16:R>3&&(P=3/(8*R));let L=1-R*Number(P),F=Number(P);R===2&&(L=3/4,F=1/8),C[E*3]=t[E*3]*L+x[E*3]*F,C[E*3+1]=t[E*3+1]*L+x[E*3+1]*F,C[E*3+2]=t[E*3+2]*L+x[E*3+2]*F}let M=new Float64Array((o+f)*3);M.set(C),M.set(A,o*3);let B=new Uint32Array(a*12),I=new Array(a*4),_=s?new Float64Array(a*24):null;for(let E=0;E<a;E++){let R=e[E*3],L=e[E*3+1],F=e[E*3+2],k=b(R,L)+o,W=b(L,F)+o,U=b(F,R)+o,G=E*12;B[G++]=k,B[G++]=W,B[G++]=U,B[G++]=R,B[G++]=k,B[G++]=U,B[G++]=L,B[G++]=W,B[G++]=k,B[G++]=F,B[G++]=U,B[G++]=W;let q=r[E];if(I[E*4]=q,I[E*4+1]=q,I[E*4+2]=q,I[E*4+3]=q,_!==null){let X=E*6,Y=n[X],K=n[X+1],te=n[X+2],ue=n[X+3],se=n[X+4],ce=n[X+5],de=dd(Y,te),ge=dd(K,ue),xe=dd(te,se),ye=dd(ue,ce),Z=dd(Y,se),pe=dd(K,ce),re=E*24;_[re++]=de,_[re++]=ge,_[re++]=xe,_[re++]=ye,_[re++]=Z,_[re++]=pe,_[re++]=Y,_[re++]=K,_[re++]=de,_[re++]=ge,_[re++]=Z,_[re++]=pe,_[re++]=te,_[re++]=ue,_[re++]=xe,_[re++]=ye,_[re++]=de,_[re++]=ge,_[re++]=se,_[re++]=ce,_[re++]=Z,_[re++]=pe,_[re++]=xe,_[re++]=ye}}return{positions:M,faces:B,materialIndices:I,uvs:_}}function Nk(i,t){let{positions:e,faces:r,materialIndices:n,uvs:o}=i,a=e.length/3,s=r.length/3,l=new Float64Array(a*3);for(let f=0;f<s;f++){let m=r[f*3]*3,y=r[f*3+1]*3,g=r[f*3+2]*3,v=e[g]-e[y],b=e[g+1]-e[y+1],S=e[g+2]-e[y+2],x=e[m]-e[y],w=e[m+1]-e[y+1],A=e[m+2]-e[y+2],C=b*A-S*w,P=S*x-v*A,M=v*w-b*x;l[m]+=C,l[m+1]+=P,l[m+2]+=M,l[y]+=C,l[y+1]+=P,l[y+2]+=M,l[g]+=C,l[g+1]+=P,l[g+2]+=M}for(let f=0;f<a;f++){let m=l[f*3],y=l[f*3+1],g=l[f*3+2],v=Math.sqrt(m*m+y*y+g*g)||1;l[f*3]=m/v,l[f*3+1]=y/v,l[f*3+2]=g/v}let c=s*3,d=new Float32Array(c*3),u=new Float32Array(c*3),p=o!==null&&o.length>0?new Float32Array(c*2):null;for(let f=0;f<c;f++){let m=r[f]*3;d[f*3]=e[m],d[f*3+1]=e[m+1],d[f*3+2]=e[m+2],u[f*3]=l[m],u[f*3+1]=l[m+1],u[f*3+2]=l[m+2]}p!==null&&p.set(o.subarray(0,c*2));let h=new Bl.BufferGeometry;h.setAttribute("position",new Bl.BufferAttribute(d,3)),c>0&&(h.setAttribute("normal",new Bl.BufferAttribute(u,3)),h.setAttribute("color",new Bl.BufferAttribute(new Float32Array(c*3).fill(1),3))),p!==null&&h.setAttribute("uv",new Bl.BufferAttribute(p,2));for(let f=0;f<s;){let m=n[f],y=f;do f++;while(f<s&&n[f]===m);h.addGroup(y*3,(f-y)*3,m)}return t.boundingBox!==null&&(h.boundingBox=t.boundingBox.clone()),t.boundingSphere!==null&&(h.boundingSphere=t.boundingSphere.clone()),h}var Hr=new Ni.Vector3,LM=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=i.geometry??t?.geometry??new Ni.BufferGeometry().copy(new Ni.BoxGeometry(100,100,100)),r;t===void 0?(e.computeBoundingBox(),e.boundingBox.getSize(Hr),r={width:Hr.x,height:Hr.y,depth:Hr.z,subdivisions:0}):r=t.parameters;let n={...r,...i.parameters};return{parameters:{width:Math.abs(n.width),height:Math.abs(n.height),depth:Math.abs(n.depth),subdivisions:Math.abs(n.subdivisions)},geometry:e}}static build(i){let{width:t,height:e,depth:r,subdivisions:n}=i.parameters,o=i.geometry??new Ni.BufferGeometry().copy(new Ni.BoxGeometry(100,100,100)),a=o.userData.parameters;a===void 0?(o.boundingBox=Lk(o),o.boundingBox.getSize(Hr)):Hr.set(a.width,a.height,a.depth),(t!==Hr.x||e!==Hr.y||r!==Hr.z)&&o.scale(Hr.x===0?1:t/Hr.x,Hr.y===0?1:e/Hr.y,Hr.z===0?1:r/Hr.z);let s=o.originalGeometry;try{n>0?(s===void 0||a?.subdivisions!==n)&&(s===void 0&&(s=o),o=new Ty(n).modify(s)):(s!==void 0&&(o=s),s=void 0,o.getAttribute("normal")===void 0&&o.computeVertexNormals())}catch{s!==void 0&&(o=s),s=void 0,o.getAttribute("normal")===void 0&&o.computeVertexNormals()}return s!==void 0&&Object.assign(o,{originalGeometry:s}),delete i.geometry,Object.assign(o,{userData:{...i,type:"NonParametricGeometry"}})}static loadFromUrl(i,t,e){new Ni.BufferGeometryLoader(e).load(i,n=>{let o=this.normalizeInputs({geometry:n});n.boundingBox.getSize(Hr);let a=100/Hr.x;Object.assign(o.parameters,{width:100,height:Hr.y*a,depth:Hr.z*a}),t(this.build(o))})}};function Lk(i){let t=new Ni.Box3,e=i.attributes.position;return e?(t.setFromBufferAttribute(e),t):(t.makeEmpty(),t)}var Py=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:3},i.parameters);return{shape:i.shape&&i.shape instanceof ht?i.shape:new ht,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)})}}static build(i){let{width:t,height:e,spikes:r,cornerRadius:n,depth:o,extrudeBevelSize:a,extrudeBevelSegments:s,extrusionVersion:l}=i.parameters,c=i.shape,d=t*.5,u=e*.5,p=0,h=0,f=2*Math.PI/r;for(let y=0;y<r;y++){let g=f*y,v=p+Math.sin(g)*d,b=h+Math.cos(g)*u;c.addPoint(c.createPoint(v,b))}c.isClosed=!0;for(let y=0,g=c.points.length;y<g;y++)c.points[y].roundness=n;c.roundness=n,c.update();let m=Qn.create({shape:c,parameters:{roundness:n,depth:o,extrudeBevelSize:a,extrudeBevelSegments:s,extrusionVersion:l}});return Object.assign(m,{userData:{...i,type:"PolygonGeometry"}})}};var et=require("three"),_M=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,radialSegments:4,heightSegments:1,cornerRadius:0,cornerSegments:8,openEnded:!1},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(i){let{width:t,height:e,depth:r,radialSegments:n,heightSegments:o,openEnded:a,cornerRadius:s,cornerSegments:l}=i.parameters,c=new cS(t*.5,e,n,o,a,s,l),d=r/t;return d!==1&&c.scale(1,1,d),Object.assign(c,{userData:{...i,type:"PyramidGeometry"}})}};function zp(i,t,e){e.x=i.x*t.x,e.y=i.y,e.z=i.x*t.y}var _k=new et.Vector3,Fk=new et.Vector3;function lS(i,t,e,r,n,o){let a=_k.copy(t).sub(i),s=Fk.copy(e).sub(i),l=a.angleTo(s);if(a.normalize(),s.normalize(),r===n){let c=a.add(s).normalize();o.copy(i).addScaledVector(c,r/Math.sin(l/2))}else{let c=a.angleTo(s);o.copy(i),o.addScaledVector(a,n/Math.sin(c)),o.addScaledVector(s,r/Math.sin(c))}}function kk(i,t,e){let r=i.clone().sub(t),n=e.clone().sub(t);return r.projectOnVector(n),r.add(t)}var cS=class extends et.BufferGeometry{constructor(t=.5,e=1,r=4,n=1,o=!1,a=0,s=4){super(),r=Math.floor(Math.max(3,r)),n=Math.floor(n),s=Math.floor(s);let l=[],c=[],d=[],u=[],p=0,h=e/2,f=Math.PI/r,m=t*Math.cos(Math.PI/r),y=2*Math.PI/r,g=(r-2)*Math.PI/r,v=Math.PI-g,b=new et.Vector3(0,-h,0),S=new et.Vector3(0,h,0),x=new et.Vector2(t,-h),w=new et.Vector2(m,-h),A=new et.Vector2(0,S.y).sub(w),C=new et.Vector2(0,S.y).sub(x),P=new et.Vector2(A.y,-A.x).normalize(),M=new et.Vector2(C.y,-C.x).normalize(),I=t*Math.cos(Math.PI/r)*Math.tan((Math.PI-A.angle())/2)-1e-8;a=Math.min(a,I);let _;{let U=new et.Vector3(P.x,P.y,0),G=new et.Vector3(Math.cos(y)*U.x,U.y,Math.sin(y)*U.x);_=U.angleTo(G)}let E=a/Math.tan((Math.PI-A.angle())/2),R=a/Math.tan((Math.PI-_)/2),L=new et.Vector3;if(!o){c.push(b.x,b.y,b.z),d.push(0,-1,0),u.push(0,0);let U=p++,G=[],q=x.clone(),X=E/Math.cos(Math.PI/r);q.x-=X;for(let Y=0;Y<r;Y++){let K=Y/r*Math.PI*2+f,te=new et.Vector2(Math.sin(K),Math.cos(K));zp(q,te,L),c.push(L.x,L.y,L.z),d.push(0,-1,0),u.push(0,0),G.push(p++)}for(let Y=0;Y<G.length;Y++)l.push(G[Y],U,G[(Y+1)%G.length])}let F=[];{let U=new et.Vector3,G=new et.Vector3,q=new et.Vector3,X=new et.Vector3,Y=new et.Vector3,K=new et.Vector3;for(let te=0;te<r;te++){let ue=te/r*Math.PI*2+f,se=(te+.5)/r*Math.PI*2+f,ce=(te+1)/r*Math.PI*2+f,de=new et.Vector2(Math.sin(ue),Math.cos(ue)),ge=new et.Vector2(Math.sin(se),Math.cos(se)),xe=new et.Vector2(Math.sin(ce),Math.cos(ce));zp(x,de,G),zp(x,xe,q),zp(P,ge,U),lS(S,G,q,R,R,X),c.push(X.x,X.y,X.z),lS(G,S,q,R,E,Y),c.push(Y.x,Y.y,Y.z),lS(q,G,S,E,R,K),c.push(K.x,K.y,K.z),d.push(U.x,U.y,U.z),d.push(U.x,U.y,U.z),d.push(U.x,U.y,U.z),u.push(0,0),u.push(0,0),u.push(0,0);let ye=p++,Z=p++,pe=p++;if(l.push(ye,Z,pe),a>0){{let Ce=G.clone().add(q).multiplyScalar(.5),ae=S.clone().sub(Ce).normalize(),D=b.clone().sub(Ce).normalize().add(ae).normalize().multiplyScalar(-1),ie=K.clone().sub(Y);k(Ce,ie,D,A.angle())}let re,Se;{let Ce=new et.Vector3;zp(M,xe,Ce);let ae=K.clone().add(X).multiplyScalar(.5);ae=kk(ae,q,S);let be=K.clone().sub(X);[re,Se]=k(ae,be,Ce,_,X.y)}{let Ce=re,ae=Ce.clone().setY(0).normalize(),be=new et.Vector3(0,-1,0),D=ae.clone().cross(be);W(Ce,ae,be,D)}F.concat(Se);{let Ce=A.angle(),ae=Math.PI-Ce,be=S.clone();be.y-=a/Math.sin(Ce-Math.PI/2);let D=new et.Vector3,ie=[];for(let Ie=0;Ie<s;Ie++){let Xe=[],Ee=Math.PI/2-ae*Ie/s,Ue=Math.cos(Ee),qe=Math.sin(Ee),$e=se;for(let Vt=0;Vt<=Ie;Vt++){let De=Math.cos($e),Et=Math.sin($e);U.x=Ue*Et,U.y=qe,U.z=Ue*De,D.copy(be).addScaledVector(U,a),c.push(D.x,D.y,D.z),d.push(U.x,U.y,U.z),u.push(0,0),Xe.push(p++),$e+=Math.PI*2/Ie/r}ie.push(Xe)}Se.reverse(),ie.push(Se);let Ke=ie.length-1;for(let Ie=0;Ie<Ke;Ie++){let Xe=ie[Ie],Ee=ie[Ie+1],Ue=Xe.length-1;l.push(Ee[1],Xe[0],Ee[0]);for(let qe=1;qe<=Ue;qe++)l.push(Xe[qe],Xe[qe-1],Ee[qe]),l.push(Ee[qe+1],Xe[qe],Ee[qe])}}}}}this.setIndex(l),this.setAttribute("position",new et.Float32BufferAttribute(c,3)),this.setAttribute("normal",new et.Float32BufferAttribute(d,3)),this.setAttribute("uv",new et.Float32BufferAttribute(u,2));function k(U,G,q,X,Y){let K=-X/2,te=(Math.PI-X)/2,ue=G.clone().normalize().cross(q);U.addScaledVector(q,-a/Math.sin(te));let se=new et.Vector3,ce=new et.Vector3,de=1,ge=p,xe=[];for(let ye=0;ye<=s;ye++){let Z=K+ye/s*X;ce.set(0,0,0),ce.addScaledVector(ue,Math.sin(Z)),ce.addScaledVector(q,Math.cos(Z));for(let pe=0;pe<=de;pe++){let re=pe/de-.5;if(se.copy(U),se.addScaledVector(G,re),se.addScaledVector(ce,a),Y!=null){let Se=Math.max(0,se.y-Y);se.addScaledVector(G,-Se/G.y)}c.push(se.x,se.y,se.z),d.push(ce.x,ce.y,ce.z),u.push(0,0),pe===0&&xe.push(p),p++}}for(let ye=0;ye<s;ye++)for(let Z=0;Z<de;Z++){let pe=ge+Z+(de+1)*ye,re=pe+(de+1),Se=re+1,Ce=pe+1;l.push(pe,re,Ce),l.push(re,Se,Ce)}return[U.clone().addScaledVector(G,.5),xe]}function W(U,G,q,X){let Y=Math.PI/2,K=C.angle()-Y,te=[],ue=new et.Vector3,se=new et.Vector3;for(let de=0;de<=s;de++){let ge=[],xe=de/s;for(let ye=0;ye<=de;ye++){let pe=((de?ye/de:0)-.5)*v,re=Math.cos(pe),Se=Math.sin(pe),Ce=Math.atan(Math.tan(K)*re),ae=(Y+Ce)*xe,be=Math.cos(ae),D=Math.sin(ae);ue.set(0,0,0),ue.addScaledVector(G,D*re),ue.addScaledVector(q,be),ue.addScaledVector(X,D*Se),se.copy(U).addScaledVector(ue,a),c.push(se.x,se.y,se.z),d.push(ue.x,ue.y,ue.z),u.push(0,0),ge.push(p++)}te.push(ge)}let ce=te.length-1;for(let de=0;de<ce;de++){let ge=te[de],xe=te[de+1],ye=ge.length-1;l.push(ge[0],xe[1],xe[0]);for(let Z=1;Z<=ye;Z++)l.push(ge[Z-1],ge[Z],xe[Z]),l.push(ge[Z],xe[Z+1],xe[Z])}}}};var ud=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,cornerRadius:[0,0,0,0],cornerType:1,extrudeBevelSize:0,extrudeBevelSegments:1},i.parameters),r=Object.assign(t?.ui??{enabledIndieCorners:!1},i.ui);return{shape:i.shape&&i.shape instanceof ht?i.shape:new ht,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)}),ui:r}}static build(i){let t=i.shape,{width:e,height:r,cornerRadius:n,cornerType:o,depth:a,extrudeBevelSize:s,extrudeBevelSegments:l,extrusionVersion:c}=i.parameters,d={x:e*.5,y:r*.5},u={x:-d.x,y:-d.y},p={x:d.x,y:d.y};function h(x,w,A){return w>e&&A>r?Math.min(x*e/w,x*r/A):w>e?x*e/w:A>r?x*r/A:x}let f=[];f[0]=n[0]===0?0:h(n[0],n[0]+n[3],n[0]+n[1]),f[1]=n[1]===0?0:h(n[1],n[1]+n[2],n[1]+n[0]),f[2]=n[2]===0?0:h(n[2],n[2]+n[1],n[2]+n[3]),f[3]=n[3]===0?0:h(n[3],n[3]+n[0],n[3]+n[2]);let m=u.x,y=p.x,g=p.y,v=u.y;t.addPoint(t.createPoint(m,g)),t.addPoint(t.createPoint(y,g)),t.addPoint(t.createPoint(y,v)),t.addPoint(t.createPoint(m,v)),t.isClosed=!0;let b=!0;for(let x=0,w=t.points.length;x<w;x++)t.points[x].roundness=f[x],x>0&&f[x]!==f[x-1]&&(b=!1);b&&(t.roundness=f[0]),t.useCubicForRoundedCorners=o!==1,t.update();let S=Qn.create({shape:t,parameters:{depth:a,extrudeBevelSize:s,extrudeBevelSegments:l,extrusionVersion:c}});return Object.assign(S,{userData:{...i,type:"RectangleGeometry"}})}};var Ra=require("three"),FM=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,widthSegments:64,heightSegments:64,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:180},i.parameters);return e.thetaLength=Ra.MathUtils.clamp(e.thetaLength,0,180),{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(i){let{width:t=100,height:e=t,depth:r=t,widthSegments:n=64,heightSegments:o=64,phiStart:a,phiLength:s,thetaStart:l,thetaLength:c}=i.parameters,d;return c===0?(d=new Ra.BufferGeometry,d.setAttribute("position",new Ra.Float32BufferAttribute([],3))):d=new Ra.SphereGeometry(.5*t,n,o,a,s,l,c*Ra.MathUtils.DEG2RAD),d.scale(1,e/t,r/t),Object.assign(d,{userData:{...i,type:"SphereGeometry"}})}};var kM=require("three"),VM=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,widthSegments:8,heightSegments:8},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:0})}}static build(i){let{width:t=100,height:e=t,widthSegments:r=8,heightSegments:n=8}=i.parameters,o=new kM.PlaneGeometry(t,e,r,n);return o.scale(1,1,1),Object.assign(o,{userData:{...i,type:"PlaneGeometry"}})}};var ws=require("three"),GM=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,angle:90,cornerRadius:24,cornerSegments:8},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width)})}}static build(i){let{width:t,height:e,depth:r,angle:n,cornerRadius:o,cornerSegments:a}=i.parameters,s=new dS(t,e,r,n,o,a);return Object.assign(s,{userData:{...i,type:"BackdropGeometry"}})}},dS=class extends ws.BufferGeometry{constructor(t=1,e=1,r=1,n=90,o=10,a=24){super(),this.type="BackdropGeometry";let s=[],l=[],c=[],d=.001;o==0&&(a=1),a=Math.max(1,Math.floor(a)),o=Math.min(o,100),n=Math.min(180-d,n),n*=Math.PI/180;let u=[],p=Math.PI/2,h=(se=0,ce=0,de=0)=>new ws.Vector3(se,ce,de),f=h(),m=h(),[y,g,v]=[e/2,t/2,r/2],b=-g,S=+g,[x,w,A]=[h(b,-y,+v),h(b,-y,-v),h(b,+y,-v)],C=(se,ce=!1)=>Math.sin(se-Math.PI/(1+ +ce)),P=(se,ce=!1)=>Math.cos(se-Math.PI/(1+ +ce));A.y=Math.sin(n)*e-y;let M=Math.cos(n)*e-v,B=x.z-d;n<=p?(A.z=Math.min(M,B),A.z==B&&(A.y-=(M-B)/Math.tan(p-n))):w.z=Math.min(w.z-M-v,x.z-d),f.subVectors(x,w),m.subVectors(A,w);let I=Math.min(f.length(),m.length())*o/100,_=I*Math.tan(n/2),E=I/Math.cos(n/2),R=f.clone().normalize().add(m.normalize()).setLength(E).add(w);f.set(0,C(n,!0),P(n,!0)),u.push([A,f.clone()]);let L=(Math.PI-n)/a;for(let se=0;se<=a;se++){let ce=p+n+se*L;f.set(0,Math.sin(ce)*_,Math.cos(ce)*_),f.add(R),m.set(0,C(ce),P(ce)),u.push([f.clone(),m.clone()])}u.push([x,h(0,1,0)]);let F=Math.sin(L/2)*_*2,k=u.length-1,W=u[0][0].distanceTo(u[1][0]),U=u[k-1][0].distanceTo(u[k][0]),G=W+F*a+U;u[0].push(1);for(let se=0;se<=a;se++)u[se+1].push(1-(W+se*F)/G);u[k].push(0);let[q,X,Y]=u[0],K,te,ue;for(let se=1;se<u.length;se++)[K,te,ue]=u[se],s.push(b,q.y,q.z,b,K.y,K.z,S,q.y,q.z,S,q.y,q.z,b,K.y,K.z,S,K.y,K.z),l.push(0,X.y,X.z,0,te.y,te.z,0,X.y,X.z,0,X.y,X.z,0,te.y,te.z,0,te.y,te.z),c.push(0,Y,0,ue,1,Y,1,Y,0,ue,1,ue),[q,X,Y]=[K,te,ue];this.setAttribute("position",new ws.Float32BufferAttribute(s,3)),this.setAttribute("normal",new ws.Float32BufferAttribute(l,3)),this.setAttribute("uv",new ws.Float32BufferAttribute(c,2))}};var My=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,innerRadiusPercent:38.19,spikes:5,cornerRadius:0,angle:360,extrudeBevelSize:0,extrudeBevelSegments:1},i.parameters);return{shape:i.shape&&i.shape instanceof ht?i.shape:new ht,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)})}}static build(i){let{width:t,height:e,innerRadiusPercent:r,spikes:n,cornerRadius:o,angle:a,depth:s,extrudeBevelSize:l,extrudeBevelSegments:c,extrusionVersion:d}=i.parameters,u=i.shape,p=t*.5,h=e*.5,f=0,m=0,y=a*Math.PI/360/n,g=Math.PI/2*3*-1,v=p*r/100,b=h*r/100;if(n===3&&r===50){y=2*Math.PI/n;for(let x=0;x<n;x++){let w=y*x,A=f+Math.sin(w)*p,C=m+Math.cos(w)*h;u.addPoint(u.createPoint(A,C))}}else for(let x=0;x<n;x++){let w=f+Math.cos(g)*p,A=m+Math.sin(g)*h;u.addPoint(u.createPoint(w,A)),g+=y,w=f+Math.cos(g)*v,A=m+Math.sin(g)*b,u.addPoint(u.createPoint(w,A)),g+=y}u.isClosed=!0;for(let x=0,w=u.points.length;x<w;x++)u.points[x].roundness=o;u.roundness=o,u.update();let S=Qn.create({shape:u,parameters:{roundness:o,depth:s,extrudeBevelSize:l,extrudeBevelSegments:c,extrusionVersion:d}});return Object.assign(S,{userData:{...i,type:"StarGeometry"}})}};var UM=require("three"),zM=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,depth:0},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??0)})}}static build(i){let{width:t,height:e}=i.parameters,r=new UM.PlaneGeometry(t,e);return Object.assign(r,{userData:{...i,type:"TextFrameGeometry"}})}};var pd=require("three");var jM=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,radialSegments:32,tubularSegments:64,arc:360,cornerRadius:30,cornerSegments:8},i.parameters),r=Math.abs(e.width),n=Math.abs(e.height??e.width);e.shapeBlendNode&&(n=r);let o=Math.round(Math.abs(e.depth??e.width*.25));return{parameters:Object.assign(e,{width:r,height:n,depth:o})}}static build(i){let{width:t,height:e,depth:r,radialSegments:n,tubularSegments:o,arc:a,cornerRadius:s,cornerSegments:l}=i.parameters,c=Vk(t,e,r,t*.5,a,o,0,0,n,s,l);return c.scale(1,e/t,1),Object.assign(c,{userData:{...i,type:"TorusGeometry"}})}};function Vk(i,t,e,r,n,o,a,s,l,c,d){[t,e]=[e,t],a=t/2;let u=pd.MathUtils.clamp(n/360,0,1);if(u===0){let p=new pd.BufferGeometry;return p.setAttribute("position",new pd.Float32BufferAttribute([],3)),p}return u===1&&(c=0),new Op(!0,i,t,e,r,u,o,a,s,l,c,d)}var HM=require("three"),WM=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,tubularSegments:64,radialSegments:32,p:2,q:3},i.parameters);return{parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width),depth:Math.abs(e.depth??e.width),tube:e.tube??e.width*.125})}}static build(i){let{width:t,tube:e,tubularSegments:r,radialSegments:n,p:o,q:a}=i.parameters,s=t*.5;s!==e&&(s-=e);let l=new HM.TorusKnotGeometry(s,e,r,n,o,a);return Object.assign(l,{userData:{...i,type:"TorusKnotGeometry"}})}};var qM=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,depth:0,spikes:5,cornerRadius:0,extrudeBevelSize:0,extrudeBevelSegments:1,isRect:!1},i.parameters);return{shape:i.shape&&i.shape instanceof ht?i.shape:new ht,parameters:Object.assign(e,{width:Math.abs(e.width),height:Math.abs(e.height??e.width*(e.isRect?1:Math.sqrt(3)/2)),depth:Math.abs(e.depth??0)})}}static build(i){let{width:t=100,height:e,cornerRadius:r,depth:n,extrudeBevelSize:o,extrudeBevelSegments:a,isRect:s,extrusionVersion:l}=i.parameters,c=i.shape,d=t*.5,u=e*.5;s?(c.addPoint(c.createPoint(-d,u)),c.addPoint(c.createPoint(d,-u)),c.addPoint(c.createPoint(-d,-u))):(c.addPoint(c.createPoint(0,u)),c.addPoint(c.createPoint(d,-u)),c.addPoint(c.createPoint(-d,-u))),c.isClosed=!0;for(let h=0,f=c.points.length;h<f;h++)c.points[h].roundness=r;c.roundness=r,c.update();let p=Qn.create({shape:c,parameters:{roundness:r,depth:n,extrudeBevelSize:o,extrudeBevelSegments:a,extrusionVersion:l}});return Object.assign(p,{userData:{...i,type:"TriangleGeometry"}})}};mr();var Nl=require("three"),XM=require("three/examples/jsm/utils/BufferGeometryUtils.js");function YM(){let i=new Nl.BufferGeometry;return i.setAttribute("position",new Nl.BufferAttribute(new Float32Array([]),3)),i.setIndex(new Nl.BufferAttribute(new Uint16Array([]),1)),i}var Uk=YM().attributes,zk=12,jk=1,hd=class extends Nl.BufferGeometry{constructor(e,r){super();this.isTextGeometry=!0;this.charWidths=[];this.charCoords=[];this.wrappedText=[];this.isLowResolution=!1;this.vectorShapes=[];this._nearSide=new Uint8Array(0);this._depth=0;this._effectiveBevel=0;this._vScale=0;Object.assign(this.attributes,Uk),this.userData={parameters:e,type:"TextGeometry"};let n=r.getFont(e.font);n?.isLoaded?(this.font=n,this.update(e,r)):this.updateFont(e.font,r).then(()=>{this.update(e,r),r?.requestRender()})}async updateFont(e,r){let n=r.getFont(e);n&&(this.font=n,await n.loadingPromise)}update(e,r){let n=this.font;if(this.userData={parameters:e,type:"TextGeometry"},!n?.isLoaded){console.warn("Cannot update text because its font is not loaded");return}let{width:o,height:a,depth:s,extrudeBevelSize:l,extrudeBevelSegments:c,text:d,textTransform:u,fontSize:p,extrusionVersion:h}=e,f=Or.getDisplayedValue(d),m=u===2?f.toUpperCase():u===3?f.toLowerCase():f,y=Hk(e,n,m,r),{shapes:g,charWidths:v,charCoords:b}=n.generateShapes(y,e,r),S=(typeof o=="number"?o:Number(r.getVariable(o)))*.5,x=(typeof a=="number"?a:Number(r.getVariable(a)))*.5,w=g.map(P=>new ht().fromShape(P,!0));this.vectorShapes=w;let A=w.map(P=>Qn.create({shape:P,parameters:{depth:s,extrudeBevelSegments:c,extrudeBevelSize:l,uvPitch:h===1?void 0:p,extrusionVersion:h,windingRule:s<=0?Tt.NONZERO:Tt.ODD,subdivisions:this.isLowResolution&&s>0?jk:zk}})),C=A.length?(0,XM.mergeGeometries)(A):YM();C.translate(-S,x,0),this.dispose(),this.wrappedText=y,this.charCoords=b,this.charWidths=v,this.deleteAttribute("extrudeNormal"),Object.entries(C.attributes).forEach(([P,M])=>{this.setAttribute(P,M)}),this.setIndex(C.index),this.adoptNearSide(A,s),this.computeBoundingSphere()}adoptNearSide(e,r){this._depth=r;let n=0,o=0,a=0;for(let c of e){let d=c,u=d._nearSide;if(u===void 0||u.length===0){this._nearSide=new Uint8Array(0),this._effectiveBevel=0,this._vScale=0;return}n+=u.length,o=Math.max(o,d._effectiveBevel??0),a=d._vScale??a}this._effectiveBevel=o,this._vScale=a;let s=new Uint8Array(n),l=0;for(let c of e){let d=c._nearSide;s.set(d,l),l+=d.length}this._nearSide=s}takeDepthStateFrom(e){let r=e;r._nearSide!==void 0&&(this._depth=r._depth??this._depth,this._nearSide=r._nearSide,this._vScale=r._vScale??this._vScale,this._effectiveBevel=r._effectiveBevel??this._effectiveBevel)}canShiftDepthTo(e){return this._nearSide.length!==this.getAttribute("position")?.count?!1:Rl(this._effectiveBevel,e)&&Rl(this._effectiveBevel,this._depth)}shiftDepthTo(e){if(!this.canShiftDepthTo(e))return!1;let r=e-this._depth;if(this._depth=e,r===0)return!0;let n=this.getAttribute("position"),o=n.array,a=this.getAttribute("uv"),s=a?.array,l=this._vScale>0?r/this._vScale:0,c=this._nearSide;for(let d=0;d<c.length;d++){let u=c[d];u!==0&&(o[d*3+2]+=r,u===2&&s!==void 0&&(s[d*2+1]+=l))}return n.needsUpdate=!0,a!==void 0&&l!==0&&(a.needsUpdate=!0),this.refreshDepthBounds(e),!0}refreshDepthBounds(e){if(this.boundingBox===null&&this.boundingSphere===null)return;this.boundingBox===null&&this.computeBoundingBox();let r=this.boundingBox;r.min.z=Math.min(0,e),r.max.z=Math.max(0,e),this.boundingSphere!==null&&r.getBoundingSphere(this.boundingSphere)}clone(){let e=Tr(new Nl.BufferGeometry,hd.prototype);return e.copy(this),console.log("CloneGeometry",this,e),e}copy(e){return Object.entries(e.attributes).forEach(([r,n])=>{this.setAttribute(r,n)}),this.setIndex(e.index),this.userData={parameters:{...e.userData.parameters},type:"TextGeometry"},this}async setText(e,r){this.font&&await this.font.loadingPromise,await this.update({...this.userData.parameters,text:{textValue:e}},r)}get text(){return this.userData.parameters.text??""}};function Hk(i,t,e,r){let n=typeof i.width=="string"?Number(r.getVariable(i.width)):i.width,o=[""],a="";for(let s of e)a+=s,s===" "||s===`
|
|
727
727
|
`?(o[o.length-1]+=a,a="",s===`
|
|
728
|
-
`&&o.push("")):t.getTextWidth(o[o.length-1]+a,i)>n&&(o[o.length-1].length&&o.push(""),t.getTextWidth(o[o.length-1]+a,i)>n&&(a.length===1?(o[o.length-1]+=a,a=""):(o[o.length-1]+=a.slice(0,-1),a=a[a.length-1],o.push(""))));return o[o.length-1]+=a,o}var Pt=require("three");var KM,Iy=new Promise(i=>{KM=i}),QM=!1;var Oy;function ZM(i){if(QM)return;if(Oy)return Oy;async function t(){let r=i??(!1?".":"https://cdn.spline.design/@splinetool/runtime@2.0.84/build"),o=import("./process.js"),[a,s]=await Promise.all([o,fetch(`${r}/process.wasm`).then(d=>d.arrayBuffer())]),l=a.default,c=await l({wasmBinary:s});KM(c),QM=!0}return Oy=t(),Oy}var JM=require("three"),Wk=new JM.Matrix4;function Dy(i,t){if(Object.keys(i.morphAttributes).length>0||Object.keys(t.morphAttributes).length>0)return!1;let e=Object.keys(i.attributes),r=Object.keys(t.attributes);if(e.length!==r.length)return!1;for(let l of r){let c=i.attributes[l],d=t.attributes[l];if(c===void 0||c.isInterleavedBufferAttribute===!0||d.isInterleavedBufferAttribute===!0||c.itemSize!==d.itemSize||c.normalized!==d.normalized||c.array.constructor!==d.array.constructor||c.array.length!==d.array.length)return!1}let n=i.index,o=t.index;if(n===null!=(o===null))return!1;let a=!1;if(n!==null&&o!==null){if(n.array.length!==o.array.length)return!1;let l=n.array.constructor,c=o.array.constructor;if(l!==c){if(l!==Uint32Array||c!==Uint16Array)return!1;a=!0}}if(i.groups.length!==t.groups.length)return!1;for(let l=0;l<t.groups.length;l++){let c=i.groups[l],d=t.groups[l];if(c.start!==d.start||c.count!==d.count||c.materialIndex!==d.materialIndex)return!1}for(let l of r){let c=i.attributes[l],d=t.attributes[l];c.array.set(d.array),c.needsUpdate=!0}let s=i.takeDepthStateFrom;if(typeof s=="function"&&s.call(i,t),n!==null&&o!==null){if(a){let l=n.array,c=o.array;for(let d=0,u=c.length;d<u;d++){let p=c[d];l[d]=p===65535?4294967295:p}}else n.array.set(o.array);n.needsUpdate=!0}return i.drawRange.start=t.drawRange.start,i.drawRange.count=t.drawRange.count,i.userData=t.userData,i.boundingBox=null,i.boundingSphere=null,!0}function jp(i,t,e,r){let n=i.position.array,o=i.normal.array,a=Wk.makeScale(t,e,r).invert().elements,s,l,c;for(let d=0,u=n.length;d<u;d+=3)n[d]*=t,n[d+1]*=e,n[d+2]*=r,s=o[d],l=o[d+1],c=o[d+2],o[d]=a[0]*s+a[4]*l+a[8]*c,o[d+1]=a[1]*s+a[5]*l+a[9]*c,o[d+2]=a[2]*s+a[6]*l+a[10]*c;i.position.needsUpdate=!0,i.normal.needsUpdate=!0}var Ry=new Pt.Box3,fd=new Pt.Vector3,Ae;Iy.then(i=>{Ae=i});var $M=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),e2=new Uint32Array([0,1,2,3]),t2=new Uint8Array([4]);function mS(i){let t=Number(i);return Number.isInteger(t)&&t>=0&&String(t)===i?t:-1}function qk(i){let t=Object.keys(i),e=0;for(let n of t){let o=mS(n);o>=e&&(e=o+1)}if(e===0||e>t.length)return;let r=new Array(e);for(let n=0;n<e;n++){let o=i[n];if(typeof o!="number")return;r[n]=o}return r}function By(i){if(i!=null){if(Array.isArray(i)||ArrayBuffer.isView(i)&&!(i instanceof DataView))return i;if(typeof i=="object")return qk(i)}}function uS(i){if(i==null)return"missing";if(Array.isArray(i))return`Array(${i.length})`;if(ArrayBuffer.isView(i)){let l=i;return`${i.constructor.name}(${l.length})`}if(typeof i!="object")return typeof i;let t=Object.keys(i),e=t.filter(l=>mS(l)===-1),r=0;for(let l of t){let c=mS(l);c>=r&&(r=c+1)}let n=i,o=-1,a=-1;for(let l=0;l<r;l++)l in n?typeof n[l]!="number"&&a===-1&&(a=l):o===-1&&(o=l);let s=[`${t.length} keys`,`max index ${r-1}`];return o!==-1&&s.push(`first missing index ${o}`),a!==-1&&s.push(`non-number at ${a} (${typeof n[a]})`),e.length&&s.push(`stray keys ${e.slice(0,3).join(",")}`),`Object{${s.join(", ")}}`}var Lt=class extends Pt.BufferGeometry{constructor(e,r){super();this.data=e;this.flatShading=r;this.subdivPointer=0;this.rebuild(),this.freeSubdivPointer()}mutateDirectlyScaleBaked(e,r){this.freeSubdivPointer();let n=this.data.scaleBaked.map(l=>typeof l=="number"?l:1),o=Ci.div(r.map(l=>typeof l=="number"?l:0),n);if(o.every(l=>l===1))return;this.subdividedGeometry&&jp(this.subdividedGeometry.attributes,...o),this.originalGeometry&&jp(this.originalGeometry.attributes,...o),this.data=e;let a=this.userData.parameters;this.userData.parameters={width:a.width*o[0],height:a.height*o[1],depth:a.depth*o[2]},this.originalGeometry.boundingSphere.center.multiply(fd.fromArray(o));let s=fd.set(a.width,a.height,a.depth).length();this.originalGeometry.boundingSphere.radius=s/2}ensureSubdivPointer(){return this.subdivPointer===0&&this.rebuild(),this.subdivPointer}mutateDirectlySubdivisions(e){this.freeSubdivPointer(),this.data=e;let r=e.phongAngle??35;this.flatShading&&(r=-1);let n=null;if(e.subdivisions>0){let a=0;try{a=Lt.allocate(e),n=Lt.buildRefined(a,e.subdivisions,r)}catch(s){console.error(s,e)}finally{a&&Lt.freeSubdivPointer(a)}}this.subdividedGeometry?.dispose(),this.subdividedGeometry=n??void 0,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=this.originalGeometry.boundingSphere);let o=this.userData.parameters;Object.assign(this,this.subdividedGeometry??this.originalGeometry),this.userData.parameters=o}rebuild(){let e,r,n;try{({originalGeometry:e,subdividedGeometry:r,subdivPointer:n}=Lt.build(this.data,void 0,!this.flatShading,void 0))}catch{e=new Pt.BoxGeometry(100,100,100),n=0}this.subdivPointer=n,this.originalGeometry=e,this.subdividedGeometry=r??void 0;let o=this.subdividedGeometry??this.originalGeometry;Object.assign(this,o),this.calcBoundingBox()}freeSubdivPointer(){this.subdivPointer&&(Lt.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0)}dispose(){super.dispose(),this.freeSubdivPointer()}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new Pt.Sphere,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let r=e.attributes.position,n=e.boundingSphere.center;Ry.setFromBufferAttribute(r),Ry.getCenter(n),e.boundingSphere.radius=n.distanceTo(Ry.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),Ry.getSize(fd);let o={width:fd.x,height:fd.y,depth:fd.z};return this.userData.parameters=o,o}static build(e,r,n,o){let a,s,l=e?.phongAngle??35;n===!1&&(l=-1),r&&(Ae.free_bvh(r),Ae.free_subdivision_surface(r));try{a=Lt.allocate(e,o)}catch(d){console.error(d,e),a=Lt.allocate({positionWASM:$M,indexWASM:e2,verticesPerFaceWASM:t2},o)}Ae.set_destination_refinement_level(a,0);let c=Lt.buildLevel(a,!0,l);return e.subdivisions>0?s=Lt.buildRefined(a,e.subdivisions,l):s=null,{subdivPointer:a,originalGeometry:c,subdividedGeometry:s}}static buildRefined(e,r,n){try{return Ae.set_destination_refinement_level(e,r),Lt.buildLevel(e,!1,n)??null}catch{try{return Ae.set_destination_refinement_level(e,r-1),Lt.buildLevel(e,!1,n)??null}catch{return null}}}static primitiveToQuads(e,r,n){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 o=e.shape!==void 0||e.path!==void 0?r.geometry:Li(e,n,!1,r),a;Hm(e)?a=o.getClosedTorusIndicesForBooleanOrSubdiv():a=o.getIndex();let{positions:s,triIndices:l,triOriginals:c}=Hp(o.getAttribute("position"),a),d;if(e.type==="CylinderGeometry"&&e.cornerRadius===0&&e.hollow===0&&e.openEnded===!1){let f=e.radialSegments*e.heightSegments*3*2,m=f+e.radialSegments*3;d=[f,m]}let{indices:u,verticesPerFace:p,uvs:h}=Xk(s,l,o,d,c);return{positions:s,indices:u,verticesPerFace:p,uvs:h}}static allocate(e,r){let n,o,a,s=[],l=[],c=By(e.positionWASM),d=By(e.indexWASM),u=By(e.verticesPerFaceWASM);if(c&&c.length>0){if(!d?.length||!u?.length)throw new Error(`SubdivGeometry.allocate: unusable cage topology \u2014 positionWASM ${uS(e.positionWASM)}, indexWASM ${uS(e.indexWASM)}, verticesPerFaceWASM ${uS(e.verticesPerFaceWASM)}`);n=c,o=d,a=u;let P=By(e.uvWASM);Ae.alloc_subdivision_surface_uvs&&P&&P.length===o.length*2&&(l=P)}else n=$M,o=e2,a=t2;let p=n.length,h=o.length,f=a.length,m=n.length+s.length+l.length,y=o.length+a.length,g=m*Float32Array.BYTES_PER_ELEMENT+y*Uint32Array.BYTES_PER_ELEMENT,v=m*Float32Array.BYTES_PER_ELEMENT,b=Ae._malloc(g);if(!b)throw new Error(`SubdivGeometry.allocate: wasm _malloc(${g}) failed`);let S=new Float32Array(Ae.HEAPF32.buffer,b,m),x=new Uint32Array(Ae.HEAPU32.buffer,b+v,y);S.set(n,0),S.set(s,n.length),S.set(l,n.length+s.length),x.set(o,0),x.set(a,o.length);let w;e?.scaleBaked?.some(P=>P!==1)&&(w=new Pt.Matrix4().makeScale(...e.scaleBaked.map(P=>typeof P=="number"?P:1))),r&&(w?w.premultiply(r):w=r);let A=b+(n.length+s.length)*Float32Array.BYTES_PER_ELEMENT,C=l.length?w?Ae.alloc_subdivision_surface_uvs2(b,p,b+v,h,b+v+o.length*Uint32Array.BYTES_PER_ELEMENT,f,A,l.length,w.elements):Ae.alloc_subdivision_surface_uvs(b,p,b+v,h,b+v+o.length*Uint32Array.BYTES_PER_ELEMENT,f,A,l.length):w?Ae.alloc_subdivision_surface2(b,p,b+v,h,b+v+o.length*Uint32Array.BYTES_PER_ELEMENT,f,w.elements):Ae.alloc_subdivision_surface(b,p,b+v,h,b+v+o.length*Uint32Array.BYTES_PER_ELEMENT,f);return Ae._free(b),C}static buildLevel(e,r,n,o,a,s=!1){let l=a?Ae.get_mesh_data2(e,r?Ae.Level.CONTROL:Ae.Level.REFINED,n,a.elements):Ae.get_mesh_data(e,r?Ae.Level.CONTROL:Ae.Level.REFINED,n),c=10,d=Ae.HEAPU32.subarray(l>>2,(l>>2)+c),u=d.subarray(4,4+4),p=0,h=Ae.HEAPU32[d[p]>>2],f=Ae.HEAPF32.subarray(h>>2,(h>>2)+u[p]);p++;let m=Ae.HEAPU32[d[p]>>2],y=Ae.HEAPF32.subarray(m>>2,(m>>2)+u[p]);p++;let g=Ae.HEAPU32[d[p]>>2],v=Ae.HEAPU32.subarray(g>>2,(g>>2)+u[p]);p++;let b=Ae.HEAPU32[d[p]>>2],S=Ae.HEAPU32.subarray(b>>2,(b>>2)+u[p]);p++;let x;if(Ae.alloc_subdivision_surface_uvs){let A=d[9];if(A>0){let C=Ae.HEAPU32[d[8]>>2];x=Ae.HEAPF32.subarray(C>>2,(C>>2)+A)}}if(o===void 0){let A=new Pt.BufferGeometry;if(A.setIndex(new Pt.Uint32BufferAttribute(S,1)),A.setAttribute("position",new Pt.Float32BufferAttribute(f,3)),A.setAttribute("normal",new Pt.Float32BufferAttribute(y,3)),x&&A.setAttribute("uv",new Pt.Float32BufferAttribute(x,2)),r){A.setAttribute("faceMap",new Pt.Uint32BufferAttribute(v,1));let C=new Float32Array(y.length/3*4).fill(0);A.setAttribute("color",new Pt.BufferAttribute(C,4))}return Ae.free_mesh_data(l),A.userData.type="SubdivGeometry",A}if(o.getAttribute("position").copyArray(f),o.getAttribute("normal").copyArray(y),o.attributes.position.needsUpdate=!0,o.attributes.normal.needsUpdate=!0,s){let A=o.getIndex();A!==null&&A.array.length===S.length&&(A.copyArray(S),A.needsUpdate=!0)}let w=o.getAttribute("uv");x&&w&&w.array.length===x.length&&(w.copyArray(x),w.needsUpdate=!0),Ae.free_mesh_data(l)}static freeSubdivPointer(e){Ae.free_bvh(e),Ae.free_subdivision_surface(e)}static buildControlCageWireframe(e,r,n){let o=Ae.get_wireframe_data_for_base_level(e),a=4,s=Ae.HEAPU32.subarray(o>>2,(o>>2)+a),l=s.subarray(2,2+2),c=0,d=Ae.HEAPU32[s[c]>>2],u=Ae.HEAPF32.subarray(d>>2,(d>>2)+l[c]);c++;let p=Ae.HEAPU32[s[c]>>2],h=Ae.HEAPU32.subarray(p>>2,(p>>2)+l[c]);if(r===void 0){let f=new Pt.BufferGeometry;f.setAttribute("position",new Pt.Float32BufferAttribute(u,3));let m=new Float32Array(u.length);for(let y=0,g=u.length;y<g;)m[y++]=n.r,m[y++]=n.g,m[y++]=n.b;return f.setAttribute("color",new Pt.BufferAttribute(m,3)),f.setIndex(new Pt.Uint32BufferAttribute(h,1)),Ae.free_wireframe_data_for_base_level(o),f}r.getAttribute("position").copyArray(u),r.attributes.position.needsUpdate=!0,Ae.free_wireframe_data_for_base_level(o)}static updateCollabMesh(e,r,n){let o=r===0;o||Ae.set_destination_refinement_level(e,r);let a=n?Ae.get_topological_data2(e,o?Ae.Level.CONTROL:Ae.Level.REFINED,n.elements):Ae.get_topological_data(e,o?Ae.Level.CONTROL:Ae.Level.REFINED),s=8,l=Ae.HEAPU32.subarray(a>>2,(a>>2)+s),c=l.subarray(3,3+3),d=0,u=Ae.HEAPU32[l[d]>>2],p=new Float32Array(Ae.HEAPF32.subarray(u>>2,(u>>2)+c[d]));d++;let h=Ae.HEAPU32[l[d]>>2],f=new Uint32Array(Ae.HEAPU32.subarray(h>>2,(h>>2)+c[d]));d++;let m=Ae.HEAPU32[l[d]>>2],y=new Uint8Array(Ae.HEAPU32.subarray(m>>2,(m>>2)+c[d])),g;if(Ae.alloc_subdivision_surface_uvs){let v=l[7];if(v>0){let b=Ae.HEAPU32[l[6]>>2];g=new Float32Array(Ae.HEAPF32.subarray(b>>2,(b>>2)+v))}}return Ae.free_topological_data(a),{positions:p,indices:f,verticesPerFace:y,uvs:g}}};function Ly(i){let t=Object.keys(i);return t.length===1&&t[0]==="subdivisions"}function Hp(i,t){let e=t?t.count:i.count,r=0,n=1e4,o=new Map,a=new Uint32Array(e),s=[];for(let d=0;d<e;d++){let u=t?t.getX(d):d,p=i.getX(u),h=i.getY(u),f=i.getZ(u),m=Math.round(p*n),y=Math.round(h*n),g=Math.round(f*n),v=o.get(m);v===void 0&&(v=new Map,o.set(m,v));let b=v.get(y);b===void 0&&(b=new Map,v.set(y,b));let S=b.get(g);S===void 0&&(S=r++,b.set(g,S),s.push(p,h,f)),a[d]=S}let l=[],c=[];for(let d=0;d<a.length;d+=3)a[d]===a[d+1]||a[d]===a[d+2]||a[d+1]===a[d+2]||(l.push(a[d],a[d+1],a[d+2]),c.push(t?t.getX(d):d,t?t.getX(d+1):d+1,t?t.getX(d+2):d+2));return{positions:s,triIndices:l,triOriginals:c}}var Ny=new Pt.Vector3,pS=new Pt.Vector3,hS=new Pt.Vector3,fS=new Pt.Vector3;function Xk(i,t,e,r,n){let o=[],a=[],s=n?e.getAttribute("uv"):void 0,l=s&&s.itemSize===2?[]:void 0,c=p=>{if(l){let h=n[p];l.push(s.getX(h),s.getY(h))}};if(e.userData.shape!==void 0&&e.userData.parameters.depth===0&&e.userData.shape.shapeHoles.length===0){let p=e.userData.shape.extractShapePointsToFlatArray([]),h=e.userData.parameters.spikes;if(e.userData.type==="EllipseGeometry"&&h<=24&&h%4===0&&e.userData.parameters.angle>=360){let y=p.length/2/h;p=p.filter((g,v)=>Math.floor(v/2)%y===0)}let f=0;for(let y=0;y<p.length;y+=2)f+=(p[y]-p[(y===0?p.length:y)-2])*(p[y+1]+p[(y===0?p.length:y)-1]);i.length=0;let m=0;if(f<0)for(let y=0;y<p.length;y+=2)i.push(p[y],p[y+1],0),o.push(m++);else for(let y=p.length-2;y>=0;y-=2)i.push(p[y],p[y+1],0),o.push(m++);return a.push(m),{indices:o,verticesPerFace:a}}let d=new Float32Array([e.userData.parameters.depth])[0],u=0;for(;u<t.length;){if(e.useNgonForTopBottomFaceDuringBake){let p=0;if((i[t[u]*3+2]===d||i[t[u]*3+2]===0)&&p++,(i[t[u+1]*3+2]===d||i[t[u+1]*3+2]===0)&&p++,(i[t[u+2]*3+2]===d||i[t[u+2]*3+2]===0)&&p++,p===3)break}if(t[u+1]===t[u+3]&&t[u+2]===t[u+5]||t[u+0]===t[u+3]&&t[u+2]===t[u+4]){Ny.set(i[t[u]*3],i[t[u]*3+1],i[t[u]*3+2]),pS.set(i[t[u+1]*3],i[t[u+1]*3+1],i[t[u+1]*3+2]),hS.set(i[t[u+4]*3],i[t[u+4]*3+1],i[t[u+4]*3+2]),fS.set(i[t[u+5]*3],i[t[u+5]*3+1],i[t[u+5]*3+2]),pS.sub(Ny).normalize(),hS.sub(Ny).normalize(),fS.sub(Ny).normalize();let p=pS.cross(hS).dot(fS),h=u;Math.abs(p)>.005||r&&r.some((f,m)=>m%2===1?!1:h>=r[m]&&h<r[m+1])?(o.push(t[u],t[u+1],t[u+2]),c(u),c(u+1),c(u+2),a.push(3),u+=3):(o.push(t[u],t[u+1],t[u+4],t[u+5]),c(u),c(u+1),c(u+4),c(u+5),a.push(4),u+=6)}else o.push(t[u],t[u+1],t[u+2]),c(u),c(u+1),c(u+2),a.push(3),u+=3}if(e.useNgonForTopBottomFaceDuringBake){let p=[],h=[],f=0;for(let m=0,y=0;m<i.length;m+=3,y++)i[m+2]===0&&(p.push(y),f++),i[m+2]===d&&h.push(y);if(e.userData.parameters.extrudeBevelSize===0){let m=h[0];h[0]=h[1],h[1]=m}p.reverse(),o.push(...p,...h),a.push(f,f),l=void 0}return{indices:o,verticesPerFace:a,uvs:l}}var Yk={ConeGeometry:QP,CubeGeometry:KP,CylinderGeometry:hy,DodecahedronGeometry:JP,EllipseGeometry:cd,HelixGeometry:$T,IcosahedronGeometry:BM,LatheGeometry:NM,NonParametricGeometry:LM,PolygonGeometry:Py,PyramidGeometry:_M,RectangleGeometry:ud,SphereGeometry:FM,PlaneGeometry:VM,BackdropGeometry:GM,StarGeometry:My,TextFrameGeometry:zM,TorusGeometry:jM,TorusKnotGeometry:WM,TriangleGeometry:qM,VectorGeometry:Qn},_y=i=>{let t=Yk[i.type]??Fm(i.type);if(t===void 0)throw new Error(`No geometry factory registered for "${i.type}" \u2014 was its feature compiled out of this runtime build?`);return t.create(i)};var Qk=["font"];function Li(i,t,e,r){let n,o,a;i.type==="PathGeometry"?(o={...i,extrusion:{...i.extrusion}},a=[[],["extrusion"]]):(o={...i},a=[[]]);for(let c of a){let d=o;for(let u of c)d=d[u];for(n in d){let u=d[n];Fx(u)&&!Qk.includes(n)&&(d[n]=t.getVariable(u,[r.uuid,"geometry",...c,n]),Fx(d[n])&&(d[n]=1))}}let s={parameters:o,type:o.type};if(o.type==="PathGeometry"){s.path=o.path;let c=r.profileShape;c!==void 0&&(s.shapeData=c),s.ownerId=r.uuid}else if(o.type==="VectorGeometry"){let c=ht.createFromState(o.shape,o.width,o.height);s.shape=c,s.ownerId=r.uuid}else if(o.type==="NonParametricGeometry"){if(o.data.groups&&o.data.groups?.forEach(c=>c.materialIndex=Math.max(c.materialIndex??0,0)),s.geometry=new r2.BufferGeometryLoader().parse(o),s.geometry.groups.length===0){let c=s.geometry;c.addGroup(0,Math.max(c.getIndex()?.count??0,c.getAttribute("position").count),0)}}else if(o.type==="SubdivGeometry"){let c=new Lt(o,e);return c.data=i,c}else if(o.type==="TextGeometry"||o.type==="InputGeometry"){let c=Fm(o.type);if(c)return c.create(o,t);vr("text",`a ${o.type}`);let d=ht.createFromState(hl.defaultData(),100,100);return _y({...o,shape:d,type:"VectorGeometry"})}else if(o.type==="UIGeometry")return ud.create({parameters:{width:o.width,height:o.height,cornerRadius:o.cornerRadius,cornerType:o.cornerType}});let l;try{l=_y(s)}catch(c){console.error(c),console.error(`Error generating geometry with inputs: ${s}`);let d=ht.createFromState(hl.defaultData(),100,100);s.shape=d,s.type="VectorGeometry",l=_y(s)}return l}var yS=class{constructor(){this.objects=new Map;this.unreachable=new Set}getCached(t){return this.objects.get(t)}get size(){return this.objects.size}get(t,e,r){let n=this.objects.get(t);return n===void 0?(n=this.createObject(t,e,r),this.objects.set(t,n)):n.isShared=!0,n}forceDelete(t){let e=this.objects.get(t);e&&(this.disposeObject(e),this.objects.delete(t))}adopt(t,e){this.objects.set(t,e)}mutateIfUnique(t,e){let r=this.objects.get(t);if(r&&r.isShared!==!0)return this.objects.delete(t),this.objects.set(e,r),r}startGc(){this.unreachable=new Set(this.objects.keys())}markAsReachable(t,e){let r=this.objects.get(t);e===r?this.unreachable.delete(t):!1&&console.warn("Reachable but deleted",t)}endGc(){this.unreachable.forEach(t=>{this.disposeObject(this.objects.get(t)),this.objects.delete(t)}),this.unreachable.clear()}dispose(){this.objects.forEach(t=>{this.disposeObject(t)}),this.objects.clear()}},Wp=class extends yS{constructor(e){super();this.flatShading=e}disposeObject(e){e.dispose()}createObject(e,r,n){let o=Li(e,r,this.flatShading,n);return o.computeBoundingSphere(),o}};var bS="webgl",n2,gS,i2=!1;function xS(){return bS}function a2(i){gS=i}function s2(){if(bS==="webgpu"){if(n2!==void 0)return n2;i2||(i2=!0,console.warn('[spe] Material backend is "webgpu" but no TSL material factory is registered \u2014 import spe/src/renderer/webgpu before creating materials. Falling back to WebGL materials.'))}if(gS===void 0)throw new Error('[spe] Classic (WebGL) materials are not available in this build \u2014 it was compiled WebGPU-only. Re-export the scene with renderer "Both" or "WebGL 2", or load the full runtime.');return gS}function Fy(i,t){return s2().createRootMaterial(i,t)}function SS(i,t,e){return s2().createSharedMaterial(i,t,e)}function wS(i){return i.getLayersOfType===void 0&&Object.assign(i,{layers:[],getLayersOfType:()=>[],hasAO:!1,assetsLoaded:()=>!0}),i}var o2,l2;function c2(i){l2=i}function d2(){let i=bS==="webgpu"&&o2!==void 0?o2:l2;return i===void 0?null:wS(i())}var vS;function u2(i){vS=i}function p2(i,t){return vS===void 0?!1:vS(i,t)}var h2={markNeedsUpdateRendererDirty:()=>{}};function zo(i,t){let e=0;if(!i.layers||i.layers.length===0)return!1;let r=i.layers?.find(n=>n.data.type==="light");if(r){let n=r.data,o=Number(t.getVariable(n.alphaOverride));if((typeof n.alphaOverride=="string"?o/100:n.alphaOverride)<1)return!0}for(let n of i.layers){if(n.data.type!=="displace"&&n.data.isMask)return!0;if(n.data.type!=="displace"&&"alpha"in n.data&&n.data.type!=="light"&&n.data.type!=="fresnel"&&n.data.type!=="cavity"&&n.data.type!=="dust"&&n.data.type!=="texture"&&n.data.type!=="matcap"&&n.data.type!=="rainbow"&&n.data.type!=="outline"&&n.data.type!=="pattern"){let o=n.data.visible?n.data.alpha:0;if(typeof o=="string"&&(o=Math.max(0,Math.min(1,Number(t.getVariable(o)??100)/100))),o===1&&n.data.type==="depth"||n.data.type==="gradient"){for(let a of n.data.colors)if(a[3]<1){o=a[3];break}}else if(o===1&&n.data.type==="noise"){let a=t.color(n.data.colorA).a,s=t.color(n.data.colorB).a,l=t.color(n.data.colorC).a,c=t.color(n.data.colorD).a,d=Math.min(a,Math.min(s,Math.min(l,c)));d<1&&(o=d)}e+=(1-e)*o}}return e<1}var _i=(i,t,e)=>Math.max(0,Math.min(1,Number(t.getVariable(typeof i=="number"?i*100:i,e)??100)/100))??1,he=(i,t,e)=>typeof i=="number"?i:t.getVariable(i,e);function AS(i){let t=typeof i=="string"?i:i.type;return t==="texture"||t==="video"||t==="displace_map"||t==="matcap"}function po(i){return typeof i=="string"||typeof i=="number"&&i!==0}var md={noise:["noiseType"],texture:["projection","axis","projectionAxis","side"],video:["projection","axis","projectionAxis","side"],displace:["noiseType"],light:["roughnessMap","bumpMap","roughnessMapChannel","metalnessMap","metalnessMapChannel","normalMap","aoMap","aoMapChannel","emissiveMap"],depth:["smooth","isWorldSpace","gradientType","isVector"],pattern:["style","projection","axis"],reflection:["tracingMode","mirror"]},f2={depth:["colors"],gradient:["colors","steps"],toon:["colors","steps"]};var m2=require("three");var CS=class extends Wc(m2.Object3D){},Kk=i=>i.type==="Mesh",Rr=class extends CS{constructor(e){super();this.object=e;this.isClone=!0;this.matrixAutoUpdate=!1,this.hasNonUniformScale=e.hasNonUniformScale}raycast(e,r){}expand(){let e=0,r=this.object.entityChildren(e);for(;r;){let n=this.children[e];n?.object!==r&&(n&&this.remove(n),n=new Rr(r),this.add(n),this.children.splice(e,0,this.children.pop()),n.matrixWorldNeedsUpdate=!0,n.matrixAutoUpdate=!1,n.matrix=r.matrix,n.hiddenMatrix=r.hiddenMatrix,n.pivotMatrix=r.pivotMatrix),n.expand(),e+=1,r=this.object.entityChildren(e)}for(;this.children.length>e;)this.remove(this.children[e]);this.pivotMatrix=this.object.pivotMatrix}get visible(){let e=this.object.cloner;return e!==void 0&&this.parent===e&&(e.instancingActive||e.insideBoolean)?!1: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 Kk(this.object)}get isLight(){return this.object.isLight}get layers(){return this.object.layers}set layers(e){}get isCamera(){return!1}get geometry(){if(this.object.geometry)return this.object.geometry}get material(){if(this.object.material)return this.object.material}get morphTargetInfluences(){if(this.object.morphTargetInfluences)return this.object.morphTargetInfluences}set morphTargetInfluences(e){}};gt();var pi=require("three");var y2=null,g2=null;function v2(i){y2=i}function ES(){return y2}function b2(i){g2=i}function x2(){return g2}function ky(i){return"variable_"+i}var S2=new pi.Matrix4,w2=new pi.Vector3,A2=new pi.Quaternion,$k=new pi.Vector3,C2=new pi.Euler,TS=class extends uy{constructor(e){super();this.shared=e}create(e){return new td(e,this.shared)}},E2=new Set;function eV(i,t){let e=`${i}/${t}`;E2.has(e)||(E2.add(e),console.warn(`[spline] updateObject: ignoring a geometry update of ${i} vertices for a mesh that holds ${t}. Without \`indices\` the write is taken as a morph of the mesh's own vertices, which only means anything at the same count \u2014 send \`indices\` alongside \`vertices\` to replace the topology too.`))}var PS=class{constructor(t,e={},r=!0,n=!1){this.data=t;this.needsJitter=r;this.enableLocalStorageForPersistentVariables=n;this.geometryCache=new Wp(!0);this.geometryCache2=new Wp(!1);this.imageHolderCache=new TS(this);this.thisContext={scene:h2,shared:this};this.deletedImage=new di(Mm.emptyImage,this);this.deletedVideo=new di(Mc.defaultVideo,this);this.materials={};this.images={};this.uiBuffers={};this.videos={};this.colors={};this.audios={};this.particles={};this.fonts={};this.variables={};this.userAPIs={};this.userWebhooks={};this.mouseProperty=null;this.raycastProperty=null;this.requestRender=()=>{this._requestRender&&this._requestRender()};this.transientGeometryKeys=new WeakSet;if(e.images)for(let[o,a]of Object.entries(e.images))this.addImage(o,a);if(e.videos)for(let[o,a]of Object.entries(e.videos))this.addVideo(o,a);if(e.audios)for(let[o,a]of Object.entries(e.audios))this.addAudio(o,a);if(e.particles)for(let[o,a]of Object.entries(e.particles))this.addParticle(o,a);this.reset(t)}get deletedMaterial(){return this._deletedMaterial??(this._deletedMaterial=SS(cr.defaultTwoLayerData("phong"),this.thisContext,"")),this._deletedMaterial}setRequestRender(t){this._requestRender=t}getImageLoadPromises(){return Object.values(this.images).map(t=>t.loadPromise)}setEntityOpContext(t){this.entityOpContext=t}reset(t,e=!1,r=!1){this.data=t,this.resetLib(t.lib);for(let{id:n,data:o}of t.variables)this.addVariableHolder(n,o),e&&this.updateVariableHolder(n,o);for(let[n,o]of Object.entries(t.userAPIs??{}))this.addUserAPI(n,o);for(let[n,o]of Object.entries(t.userWebhooks??{}))this.addUserWebhook(n,o);if(!r){for(let[n,o]of Object.entries(t.images))this.addImage(n,o);for(let[n,o]of Object.entries(t.videos))this.addVideo(n,o)}for(let[n,o]of Object.entries(t.colors))this.addColor(n,o);for(let[n,o]of Object.entries(t.lib.materials))this.addMaterial(n,o.asset);for(let[n,o]of Object.entries(t.materials))this.addMaterial(n,o);for(let[n,o]of Object.entries(t.audios))this.addAudio(n,o);for(let[n,o]of Object.entries(t.particles))this.addParticle(n,o);for(let[n,o]of Object.entries(t.fonts))this.addFont(n,o)}addMaterial(t,e){if(e.layers===void 0&&(e={...e,layers:cr.defaultTwoLayerData("phong").layers}),this.materials[t]){let r=this.materials[t];r.reset(e,this.thisContext),r.dispose()}else{let r=SS(e,this.thisContext,t);this.materials[t]=r}}deleteMaterial(t){this.materials[t]&&(this.materials[t].nodeMaterialDispose(),delete this.materials[t])}getMaterial(t){let e=this.materials[t];return e}getMaterialOrDeletedPlaceholder(t){return this.materials[t]??this.deletedMaterial}material(t){return typeof t=="string"?this.getMaterialOrDeletedPlaceholder(t):t==null?(console.error("material is undefined or null"),this.deletedMaterial):(t.layers===void 0&&(t={...t,layers:cr.defaultTwoLayerData("phong").layers}),Fy(t,this.thisContext))}getMaterials(){return this.materials}addImage(t,e){return this.images[t]?(this.onColorOrImageUpdate&&this.onColorOrImageUpdate(),this.images[t].updateSrc(e.data),!0):(this.images[t]=new di(e,this),!1)}deleteImage(t){let e=this.images[t];e&&(e.dispose(),delete this.images[t])}getDefaultImage(){return this.images.image_0}getImage(t){return this.images[t]??this.deletedImage}image(t){return typeof t=="string"?this.getImage(t):this.imageHolderCache.load(t)}addUIBuffer(t,e){return this.uiBuffers[t]?(this.onColorOrImageUpdate&&this.onColorOrImageUpdate(),this.uiBuffers[t].updateSrc(e),!0):(this.uiBuffers[t]=new di(e,this),!1)}uiBuffer(t){return this.uiBuffers[t]}getEntityTexture(t,e={}){let r=t.material;if(!r)return null;for(let n of Array.isArray(r)?r:[r]){let o=n.root??n;for(let a of o?.data?.layers??[]){let s=a?.data;if(s?.type!=="texture"&&s?.type!=="matcap"||e.layer!==void 0&&a.id!==e.layer&&s.type!==e.layer)continue;let l=s.texture?.image;if(l==null)continue;let c=(typeof l=="string"?this.uiBuffer(l):void 0)??this.image(l);if(!c)continue;let d=c.getTexture(s.texture.wrapping??(s.type==="texture"?1e3:1001),s.texture.minFilter??1008,s.texture.magFilter??1006),u=c.img;return{texture:d,width:u?.width??0,height:u?.height??0,layerId:a.id,layerType:s.type}}}return null}addVideo(t,e){return this.videos[t]?(this.videos[t].updateSrc(e.data),!0):(this.videos[t]=new di(e,this),!1)}deleteVideo(t){let e=this.videos[t];e&&(e.dispose(),delete this.videos[t])}getVideo(t){return this.videos[t]??this.deletedVideo}video(t){return typeof t=="string"?this.getVideo(t):this.imageHolderCache.load(t)}addColor(t,e){return this.colors[t]?(this.onColorOrImageUpdate&&this.onColorOrImageUpdate(),"a"in e?this.colors[t].setRGBA(e.r,e.g,e.b,e.a):this.colors[t].setRGBA(e.r,e.g,e.b,1),!0):("a"in e?this.colors[t]=new Oa(e.r,e.g,e.b,e.a):this.colors[t]=new Oa(e.r,e.g,e.b,1),!1)}updateColor(t,e){if(this.colors[t]){this.onColorOrImageUpdate&&this.onColorOrImageUpdate();let r=this.colors[t];return this.colors[t].r=e.r??r.r,this.colors[t].g=e.g??r.g,this.colors[t].b=e.b??r.b,this.colors[t].a=e.a??r.a,!0}return!1}deleteColor(t){this.colors[t]&&delete this.colors[t]}getColor(t){return this.colors[t]}getColorNames(){return Object.values(this.data.colors).map(t=>t.name)}getColorByName(t){for(let e in this.data.colors)if(this.data.colors[e].name===t)return{color:this.colors[e],id:e}}color(t){let e;if(typeof t=="string"){let r=this.getColor(t);r?e=r:(console.warn("Tried to create color layer params with a color key that does not exist in the assets manager"),e=new Ut(0,0,0,0))}else return"a"in t?new Ut(t.r,t.g,t.b,t.a):new Ut(t.r,t.g,t.b,1);return e}addAudio(t,e){this.audios[t]=e}getAudio(t){let e=this.audios[t];if(e instanceof Da)return e;{let r=new Da({src:e.data});return this.audios[t]=r,r}}addParticle(t,e){this.particles[t]=e}getParticle(t){return this.particles[t]}deleteParticle(t){this.particles[t]&&delete this.particles[t]}deleteAudio(t){let e=this.audios[t];e&&(e instanceof Da&&e.dispose(),delete this.audios[t])}addFont(t,e){let r=XP();if(r===null){vr("text","a font asset");return}this.fonts[t]=new r(e),this.fonts[t].loadingPromise.then(()=>this.requestRender())}getFont(t){return this.fonts[t]}deleteFont(t){this.fonts[t]&&delete this.fonts[t]}dispose(){Object.keys(this.materials).forEach(e=>this.deleteMaterial(e)),this._requestRender=void 0,Object.values(this.audios).forEach(e=>{e instanceof Da&&e.dispose()}),this.audios={},this.particles={},this.geometryCache.dispose(),this.geometryCache2.dispose()}addVariableHolder(t,e){if(this.variables[t]===void 0){let r=e.value;if(this.enableLocalStorageForPersistentVariables&&e.persistent){let n=localStorage.getItem(ky(t));r=n!==null?JSON.parse(n):e.value}return this.variables[t]={value:r,locations:[],persistent:e.persistent},"dynamicVariableType"in e&&(this.variables[t].dynamicVariablePlayState="Playing",this.variables[t].dynamicVariableToggleIsForward=void 0),!0}return this.variables[t].value=e.value,!1}resetDynamicVariablePlayState(){for(let t in this.variables)this.variables[t].dynamicVariablePlayState!==void 0&&(this.variables[t].dynamicVariablePlayState="Playing",this.variables[t].dynamicVariableToggleIsForward=void 0)}updateVariableHolder(t,e){this.updateVariable(t,e.value)}updateVariable(t,e){if(this.variables[t]===void 0)return!1;this.variables[t].value=e,this.enableLocalStorageForPersistentVariables&&this.variables[t].persistent&&localStorage.setItem(ky(t),JSON.stringify(e));let r=e;for(;typeof r=="string";)r=this.variables[r].value;let n=this.entityOpContext.scene,o=!1;for(let a=this.variables[t].locations.length-1;a>=0;a--){let s=this.variables[t].locations[a];if(s[0]==="material"){let l=s[1],c=r,d={scene:n,shared:this},u=s.slice(2);n.traverseMaterial(h=>{let f=h.root??h;f.uuid===l&&f.onVariableUpdate(u,c,d)});let p=this.materials[l];p&&p.onVariableUpdate(u,c,d)}else{let l=n.find(s[0]);if(l===void 0){this.variables[t].locations.splice(a,1);continue}if(o=!0,s[1]!=="geometry"&&s[1]!=="particles"){for(let c=1;c<s.length-1;c++)l=l[s[c]];s[1]==="rotation"?l[s[s.length-1]]=r*pi.MathUtils.DEG2RAD:l[s[s.length-1]]=r}if(l=n.find(s[0]),l.type==="ParticleEmitter"&&l.updateVariableState(r,s),Le.is(l))if(s[1]==="position"||s[1]==="rotation"||s[1]==="scale")l.onVariableUpdate();else if(s[1]==="geometry"){let c=l;l.component&&(c=l.component);let d=c.dataPatched;c.chooseGeoemtryCache(this).forceDelete(d.geometry),c.createGeometryDelayed(this.entityOpContext),c.onVariableUpdate(!0),c.invalidateDownstreamBooleanData(),c.instances.forEach(u=>{let p=u.dataPatched;u.chooseGeoemtryCache(this).forceDelete(p.geometry),u.createGeometryDelayed(this.entityOpContext),u.onVariableUpdate(!0),u.invalidateDownstreamBooleanData()})}else s[1]==="morphTargetInfluences"&&l.updateMorphInfluences(s[2],r)}}return o&&n.markShadowsDirty(),this.requestRender(),!0}updateEntityGeometryParams(t,e){let r=t;if(r.component&&(r=r.component),typeof r.chooseGeoemtryCache!="function")return!1;let n=r.dataPatched,o=n?.geometry;if(!o||typeof o.type!="string"||o.type==="VectorGeometry"||o.type==="PathGeometry")return!1;let a=d=>d.toLowerCase().replace(/[\s_.-]+/g,""),s=new Map;for(let d of Object.keys(o))s.set(a(d),d);let l={};for(let[d,u]of Object.entries(e??{})){let p=s.get(a(d));if(p===void 0||p==="type"||p==="font"||p==="shape"||p==="path"||p==="data")continue;if(p==="text"){(typeof u=="string"||typeof u=="number")&&(l[p]={textValue:String(u)});continue}let h=o[p];typeof u=="number"&&isFinite(u)&&(typeof h=="number"||typeof h=="string")&&(l[p]=u)}if(Object.keys(l).length===0)return!1;let c={...o,...l};return r.dataPatched={...n,geometry:c},this.transientGeometryKeys.has(o)&&r.chooseGeoemtryCache(this).forceDelete(n.geometry),this.transientGeometryKeys.add(c),r.createGeometryDelayed(this.entityOpContext),r.onVariableUpdate(!0),r.invalidateDownstreamBooleanData(),this.entityOpContext.scene.markShadowsDirty(),this.requestRender(),!0}resetEntityGeometryParams(t){let e=t;if(e.component&&(e=e.component),typeof e.chooseGeoemtryCache!="function")return!1;let n=e.dataPatched?.geometry;return!n||!this.transientGeometryKeys.has(n)?!1:(e.dataPatched=e.data,e.chooseGeoemtryCache(this).forceDelete(n),e.createGeometryDelayed(this.entityOpContext),e.onVariableUpdate(!0),e.invalidateDownstreamBooleanData(),this.entityOpContext.scene.markShadowsDirty(),this.requestRender(),!0)}updateEntityGeometryVertices(t,e){let r=t;if(r.component&&(r=r.component),typeof r.chooseGeoemtryCache!="function")return!1;let n=r.dataPatched,o=n?.geometry;if(!o||o.type!=="NonParametricGeometry")return!1;let a=e?.vertices;if(a===void 0||typeof a.length!="number"||a.length<9||a.length%3!==0||a.length/3>PS.MAX_TRANSIENT_VERTICES)return!1;let s=a instanceof Float32Array?a:Float32Array.from(a),l=s.length/3,c;if(e.normals!==void 0){if(e.normals.length!==s.length)return!1;c=e.normals instanceof Float32Array?e.normals:Float32Array.from(e.normals)}let d;if(e.uvs!==void 0){if(e.uvs.length!==l*2)return!1;d=e.uvs instanceof Float32Array?e.uvs:Float32Array.from(e.uvs)}let u;if(e.indices!==void 0){let w=l>65535?Uint32Array.from(e.indices):Uint16Array.from(e.indices);if(w.length===0||w.length%3!==0)return!1;for(let A=0;A<w.length;A++)if(w[A]>=l)return!1;u={array:w,itemSize:1,type:w.constructor.name,normalized:!1}}else{let w=o.data,A=w?.index;if(A?.array?.length){let C=(w?.attributes?.position?.array?.length??0)/3;if(l!==C)return eV(l,C),!1;u=A}}let p=1/0,h=1/0,f=1/0,m=-1/0,y=-1/0,g=-1/0;for(let w=0;w<s.length;w+=3){let A=s[w],C=s[w+1],P=s[w+2];A<p&&(p=A),A>m&&(m=A),C<h&&(h=C),C>y&&(y=C),P<f&&(f=P),P>g&&(g=P)}let v=(w,A)=>({array:w,itemSize:A,type:"Float32Array",normalized:!1}),b={position:v(s,3)};c&&(b.normal=v(c,3)),d&&(b.uv=v(d,2));let S={...o,width:m-p,height:y-h,depth:g-f,data:{attributes:b,...u?{index:u}:{}}},x=this.transientGeometryKeys.has(o);return r.dataPatched={...n,geometry:S},this.transientGeometryKeys.add(S),r.applyTransientGeometryData(this.entityOpContext,x),r.onVariableUpdate(!0),r.invalidateDownstreamBooleanData(),this.entityOpContext.scene.markShadowsDirty(),this.requestRender(),!0}setEntityInstanceTransforms(t,e){let r=t;r.component&&(r=r.component);let n=r.cloner;if(n===void 0)return-1;let o=n.children,a=Math.PI/180,s=!1;if(e===null)for(let l of o)l.transformOverride!==void 0&&(l.transformOverride=void 0,s=!0);else if(Array.isArray(e)){let l=Math.min(e.length,o.length);for(let c=0;c<l;c++){let d=e[c],u=o[c];if(d==null){u.transformOverride!==void 0&&(u.transformOverride=void 0,s=!0);continue}let p=u.transformOverride??{position:[u.position.x,u.position.y,u.position.z],rotation:[u.rotation.x,u.rotation.y,u.rotation.z],scale:[u.scale.x,u.scale.y,u.scale.z]};d.position&&(typeof d.position.x=="number"&&(p.position[0]=d.position.x),typeof d.position.y=="number"&&(p.position[1]=d.position.y),typeof d.position.z=="number"&&(p.position[2]=d.position.z)),d.rotation&&(typeof d.rotation.x=="number"&&(p.rotation[0]=d.rotation.x*a),typeof d.rotation.y=="number"&&(p.rotation[1]=d.rotation.y*a),typeof d.rotation.z=="number"&&(p.rotation[2]=d.rotation.z*a)),d.scale&&(typeof d.scale.x=="number"&&(p.scale[0]=d.scale.x),typeof d.scale.y=="number"&&(p.scale[1]=d.scale.y),typeof d.scale.z=="number"&&(p.scale[2]=d.scale.z)),u.transformOverride=p,u.position.fromArray(p.position),u.rotation.fromArray(p.rotation),u.scale.fromArray(p.scale),u.updateMatrix(),u.hasNonUniformScale&&(u.updateMatrixWorld(),u.updateMatrixWorldRigid())}}else return o.length;return s?n.update(this.entityOpContext):n.syncInstanceMatrices(),n.invalidateTransform(r),this.entityOpContext.scene.markShadowsDirty(),this.requestRender(),o.length}spawnRuntimeClone(t,e={}){if(typeof t.entityChildren!="function")return;let r=t.parent;if(r===null)return;let n=new Rr(t);n.playModeVisible=e.visible!==!1,n.expand(),typeof e.name=="string"&&(n.name=e.name);let o=Math.PI/180;return n.position.copy(t.position),n.rotation.copy(t.rotation),n.scale.copy(t.scale),n.hiddenMatrix.copy(t.hiddenMatrix),e.position&&(typeof e.position.x=="number"&&(n.position.x=e.position.x),typeof e.position.y=="number"&&(n.position.y=e.position.y),typeof e.position.z=="number"&&(n.position.z=e.position.z)),e.rotation&&(typeof e.rotation.x=="number"&&(n.rotation.x=e.rotation.x*o),typeof e.rotation.y=="number"&&(n.rotation.y=e.rotation.y*o),typeof e.rotation.z=="number"&&(n.rotation.z=e.rotation.z*o)),e.scale&&(typeof e.scale.x=="number"&&(n.scale.x=e.scale.x),typeof e.scale.y=="number"&&(n.scale.y=e.scale.y),typeof e.scale.z=="number"&&(n.scale.z=e.scale.z)),n.updateMatrix(),r.add(n),n.updateWorldMatrix(!0,!0),this.entityOpContext.scene.markShadowsDirty(),this.requestRender(),n}destroyRuntimeClone(t){t.removeFromParent(),this.entityOpContext.scene.markShadowsDirty(),this.requestRender()}updateEntityMaterialParams(t,e){let r=t.material;if(!r)return!1;let n=[];for(let d of Array.isArray(r)?r:[r]){let u=d.root??d;u&&Array.isArray(u.layers)&&u.data&&!n.includes(u)&&n.push(u)}if(n.length===0)return!1;let o={scene:this.entityOpContext.scene,shared:this},a=d=>d.toLowerCase().replace(/[\s_.-]+/g,""),s=d=>{if(typeof d=="string"){let u=new Ut(1,1,1,1);try{u.set(d)}catch{return null}return{r:u.r,g:u.g,b:u.b,a:void 0}}if(d&&typeof d=="object"&&"r"in d){let u=d;if([u.r,u.g,u.b].some(h=>typeof h!="number"||!isFinite(h)))return null;let p=Math.max(u.r,u.g,u.b)>1?1/255:1;return{r:u.r*p,g:u.g*p,b:u.b*p,a:typeof u.a=="number"?Math.max(0,Math.min(u.a,1)):void 0}}return null},l=(d,u,p)=>{if(!d.hasValue(u))return!1;let h=d.getValue(u);if(!h||typeof h!="object"||!h.isColor)return!1;let f=p.a??(typeof h.a=="number"?h.a:1);return h instanceof Oa?d.setValue(u,new Ut(p.r,p.g,p.b,f)):typeof h.setRGBA=="function"?h.setRGBA(p.r,p.g,p.b,f):h.setRGB(p.r,p.g,p.b),!0},c=!1;for(let d of n){let u=d.data.layers??[],p=h=>d.layers.find(f=>f.uuid===h);if(e.color!==void 0){let h=s(e.color),f=u.find(y=>y.data.type==="color"),m=f&&p(f.id);if(h&&m&&l(m,"color",h)&&(c=!0,h.a!==void 0)){let y=h.a<1?!0:zo(d.data,this);d.setTransparent?d.setTransparent(y,o.scene):d.transparent=y}}typeof e.alpha=="number"&&isFinite(e.alpha)&&(d.onVariableUpdate?.(["alphaOverride"],Math.max(0,Math.min(e.alpha,100)),o),c=!0);for(let h of e.layers??[]){if(!h||typeof h!="object")continue;let f=typeof h.id=="string"?u.find(v=>v.id===h.id):typeof h.index=="number"?u[h.index]:typeof h.type=="string"?u.find(v=>v.data.type===h.type):void 0,m=f&&p(f.id);if(!f||!m)continue;let y=md[f.data.type]??[],g=Object.keys(f.data);for(let[v,b]of Object.entries(h)){if(v==="id"||v==="index"||v==="type")continue;let S=g.find(w=>w===v)??g.find(w=>a(w)===a(v))??v;if(y.includes(S))continue;let x=s(b);if(x&&l(m,S,x)){c=!0;continue}if(typeof b=="number"&&isFinite(b))d.onVariableUpdate?.(["layer",f.id,S],b,o),c=!0;else if(Array.isArray(b)&&b.length<=3&&b.every(w=>typeof w=="number"&&isFinite(w))){let w=["x","y","z"];b.forEach((A,C)=>{d.onVariableUpdate?.(["layer",f.id,S,w[C]],A,o)}),c=!0}}}}return c&&this.requestRender(),c}deleteVariable(t){this.variables[t]&&delete this.variables[t]}getVariable(t,e){if(Array.isArray(t)){if(t[0]==="mouse")return this.mouseProperty?.[t[1]]??0;if(t[0]==="raycast")return this.raycastProperty?.[t[1]]??0;let r=this.entityOpContext.scene.find(t[0]);if(t[1]==="width"||t[1]==="height"||t[1]==="depth")return r.geometry.userData.parameters[t[1]];if((t[1]==="position"||t[1]==="rotation")&&t.length>2&&r?.getPhysicsLocalMatrix?.(S2))return S2.decompose(w2,A2,$k),t[1]==="position"?w2[t[2]]:(C2.setFromQuaternion(A2,r.rotation.order),C2[t[2]]*pi.MathUtils.RAD2DEG);for(let n=1;n<t.length;n++)r=r[t[n]];return t[1]==="rotation"&&(r*=pi.MathUtils.RAD2DEG),r}for(let r in this.variables){if(e===void 0)break;let n=this.variables[r],o=n.locations?.findIndex(a=>jt.equal(a,e));o!==void 0&&o!==-1&&n.locations.splice(o,1)}if(typeof t=="string"){let r=t,n=t;do{if(n=r,this.variables[r]===void 0)break;let o=this.variables[r].value;e&&this.variables[n]!==void 0&&this.variables[n].locations.push(e),r=o}while(typeof r=="string");return r}else return t}getVariables(){return this.variables}getVariablesNames(){return this.data.variables.map(t=>t.data.name)}getVariableByName(t){for(let e of this.data.variables)if(e.data.name===t)return{variable:e.data,id:e.id}}getDynamicVariablePlayState(t){return this.variables[t]?.dynamicVariablePlayState}setDynamicVariablePlayState(t,e){this.variables[t]!==void 0&&(this.variables[t].dynamicVariablePlayState=e)}getDynamicVariableToggleIsForward(t){return this.variables[t]?.dynamicVariableToggleIsForward}setDynamicVariableToggleIsForward(t,e){this.variables[t]!==void 0&&(this.variables[t].dynamicVariableToggleIsForward=e)}resetLib(t){for(let[e,r]of Object.entries(t.images))this.addImage(e,r.asset);for(let[e,r]of Object.entries(t.audios))this.addAudio(e,r.asset);for(let[e,r]of Object.entries(t.particles))this.addParticle(e,r.asset);for(let[e,r]of Object.entries(t.colors))this.addColor(e,r.asset);for(let[e,r]of Object.entries(t.fonts))this.addFont(e,r.asset);for(let[e,r]of Object.entries(t.videos))this.addVideo(e,r.asset);for(let[e,r]of Object.entries(t.variables))this.addVariableHolder(e,r.asset)}updateLibByOp(t,e){t.path[0]==="images"?t.path.length===1&&t.type===1?this.addImage(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteImage(t.id):t.path[0]==="videos"?t.path.length===1&&t.type===1?this.addVideo(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteVideo(t.id):t.path[0]==="audios"?t.path.length===1&&t.type===1?this.addAudio(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteAudio(t.id):t.path[0]==="particles"?t.path.length===1&&t.type===1?this.addParticle(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteParticle(t.id):t.path[0]==="colors"?t.path.length===1&&t.type===1?this.addColor(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteColor(t.id):t.path[0]==="materials"?t.path.length===1&&t.type===1?this.addMaterial(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteMaterial(t.id):t.path[0]==="fonts"?t.path.length===1&&t.type===1?this.addFont(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteFont(t.id):t.path[0]==="variables"?t.path.length===1&&t.type===1?this.addVariableHolder(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteVariable(t.id):t.path[0]==="components"&&e.updateByLibOp(t,this)}updateByOp(t,e,r){if(this.data=e,t.path[0]==="images")t.path.length===2&&t.type===0?t.props.data&&this.getImage(t.path[1]).updateSrc(t.props.data):t.path.length===1&&t.type===1?this.addImage(t.id,t.data):t.path.length===1&&t.type===2&&this.deleteImage(t.id);else if(t.path[0]==="videos")t.path.length===2&&t.type===0?t.props.data&&this.getVideo(t.path[1]).updateSrc(t.props.data):t.path.length===1&&t.type===1?this.addVideo(t.id,t.data):t.path.length===1&&t.type===2&&this.deleteVideo(t.id);else if(t.path[0]==="audios")t.path.length===2&&t.type===0?t.props.data&&this.addAudio(t.path[1],e.audios[t.path[1]]):t.path.length===1&&t.type===1?this.addAudio(t.id,t.data):t.path.length===1&&t.type===2&&this.deleteAudio(t.id);else if(t.path[0]==="particles")t.path.length===2&&t.type===0?t.props.data&&this.addParticle(t.path[1],e.particles[t.path[1]]):t.path.length===1&&t.type===1?this.addParticle(t.id,t.data):t.path.length===1&&t.type===2&&this.deleteParticle(t.id);else if(t.path[0]==="colors")t.path.length===2&&t.type===0?this.updateColor(t.path[1],t.props):t.path.length===1&&t.type===1?this.addColor(t.id,t.data):t.path.length===1&&t.type===2&&this.deleteColor(t.id);else if(t.path[0]==="materials")t.path.length===1&&t.type===1?this.addMaterial(t.id,t.data):t.path.length===1&&t.type===2?this.deleteMaterial(t.id):t.path.length>1&&this.getMaterial(t.path[1]).updateByOp(or.drop(t,2),e.materials[t.path[1]],{shared:this,scene:r});else if(t.path[0]==="fonts")t.path.length===2&&t.type===0?this.updateFont(t.path[1],t,r):t.path.length===1&&t.type===1?this.addFont(t.id,t.data):t.path.length===1&&t.type===2&&this.deleteFont(t.id);else if(t.path[0]==="variables")t.path.length===2&&t.type===0?"value"in t.props?this.updateVariable(t.path[1],t.props.value):"persistent"in t.props&&(this.variables[t.path[1]].persistent=t.props.persistent):t.path.length===1&&t.type===4?this.addVariableHolder(t.id,t.data):t.path.length===1&&t.type===5&&this.deleteVariable(t.id);else if(t.path[0]==="userAPIs"){if(t.path.length===1&&t.type===1)this.addUserAPI(t.id,t.data);else if(t.path.length===1&&t.type===2)this.deleteUserAPI(t.id);else if(typeof t.path[1]=="string"){let n=e.userAPIs[t.path[1]];if(n){let o=t.type===0&&t.props.debounce===void 0,a=this.getUserAPI(t.path[1]);a!==void 0&&a===this.openAIRealtime?a.update(n):a?.update(n,this,o)}}}else if(t.path[0]==="userWebhooks"){if(t.path.length===1&&t.type===1)this.addUserWebhook(t.id,t.data);else if(t.path.length===1&&t.type===2)this.deleteUserWebhook(t.id);else if(typeof t.path[1]=="string"){let n=e.userWebhooks[t.path[1]];n&&this.getUserWebhook(t.path[1])?.update(n)}}else t.path[0]==="lib"&&this.updateLibByOp(or.drop(t,1),r)}updateFont(t,e,r){if(e.props.url){let n=this.getFont(t),o={...this.data.fonts[t],url:e.props.url};n.update(o),n.loadingPromise.then(()=>this.requestRender()),r.updateFont(t,this)}}addUserAPI(t,e){if(this.userAPIs[t])return this.userAPIs[t].update(e,this),!0;if(this.openAIRealtime?.id===t)return this.openAIRealtime.update(e),!0;if(e.integration?.type==="VoiceAssistant"){let r=x2();return r===null?(vr("ai-assistant","a voice-assistant integration"),!1):(this.openAIRealtime=r(e,t,this),!1)}else{let r=ES();return r===null?(vr("api-services","a user API integration"),!1):(this.userAPIs[t]=r.createUserAPI(t,e,this),!1)}}getUserAPI(t){return this.openAIRealtime?.id===t?this.openAIRealtime:this.userAPIs[t]}getUserAPIs(){return this.userAPIs}deleteUserAPI(t){let e=this.userAPIs[t];e&&(e.dispose(),delete this.userAPIs[t])}addUserWebhook(t,e){if(this.userWebhooks[t])return this.userWebhooks[t].update(e),!0;{let r=ES();return r===null?(vr("api-services","a user webhook"),!1):(this.userWebhooks[t]=r.createUserWebhook(t,e),!1)}}getUserWebhook(t){return this.userWebhooks[t]}getUserWebhooks(){return this.userWebhooks}deleteUserWebhook(t){let e=this.userWebhooks[t];e&&(e.dispose(),delete this.userWebhooks[t])}get scene(){return this.entityOpContext.scene}},As=PS;As.MAX_TRANSIENT_VERTICES=6e4;var P2=new As(Bn.emptyData());function Ll(i){return i?.isClassicNodeMaterial===!0}function M2(i){return i?.isClassicSharedMaterial===!0}function Vy(i){return Ll(i)||i?.isTSLNodeMaterial===!0}function O2(i){return M2(i)||i?.isTSLSharedMaterial===!0}gt();mr();var Ln=5,yd=3;var I2=.98;var xr=class extends it{setMaterialOverride(e,r){this.materialOverride=wS(e),this.material!==this.shadowCatcherMaterial&&(this.disposeMaterial(),this.material=this.materialOverride,this.layers.set(0),this.syncShapeBlendNodeLayer(),r.scene.markNeedsUpdateRendererDirty())}updateByPatchedOp(e,r,n){if(super.updateByPatchedOp(e,r,n),Ye(e.path,["geometry"])&&this.syncShadowCatcher(n),iC(e.path,["materials"])!==null&&e.type===0&&Array.isArray(this.material))for(let[o,a]of Object.entries(e.props)){let s=this.material[Number(o)],l=n.shared.material(a);l!==s&&xr.disposeOneMaterial(s),this.material[Number(o)]=l}else if(Ye(e.path,["material"])){let o=this.material;!Array.isArray(o)&&typeof o?.updateByOp=="function"&&"material"in r&&typeof r.material!="string"&&o.updateByOp(or.drop(e,1),r.material,n)}else if(Ye(e.path,["materials","*"])&&Array.isArray(this.material)){let o=e.path[1];if("materials"in r&&o<this.material.length){let a=r.materials[o];typeof a!="string"&&this.material[o].updateByOp(or.drop(e,2),a,n)}}}get needsAO(){return this.material!==void 0?(Array.isArray(this.material)?this.material[0]:this.material).hasAO:!1}syncShapeBlendNodeLayer(){this.dataPatched.type==="Mesh"&&!!this.dataPatched.geometry.shapeBlendNode?this.layers.set(9):(this.layers.mask&1<<9)!==0&&this.layers.set(0)}updateState(e,r){super.updateState(e,r),e.castShadow!==void 0&&(this.castShadow=e.castShadow),e.receiveShadow!==void 0&&(this.receiveShadow=e.receiveShadow);let n=this.dataPatched;this.syncShapeBlendNodeLayer();let o;this.dataPatched.type==="Mesh"&&this.dataPatched.geometry.type==="ShapeBlendGeometry"&&(o={resolutionLevel:Math.min(8,this.dataPatched.geometry.resolutionLevel),useChildrenColors:this.dataPatched.geometry.useChildrenColors});let a=this.materialOverride!==void 0;!a&&e.geometry?.type!=="NonParametricGeometry"&&"material"in e&&e.material!==void 0&&(this.disposeMaterial(),this.material=r.shared.material(e.material).getFlavor(n.flatShading,n.side,n.wireframe,o),r.scene.markNeedsUpdateRendererDirty()),!a&&(e.geometry?.type==="NonParametricGeometry"||"materials"in e)&&("materials"in e&&e.materials!==void 0?(this.disposeMaterial(),this.material=e.materials.map(l=>r.shared.material(l).getFlavor(n.flatShading,n.side,n.wireframe)),r.scene.markNeedsUpdateRendererDirty()):"material"in e&&e.material!==void 0&&(this.disposeMaterial(),this.material=[r.shared.material(e.material).getFlavor(n.flatShading,n.side,n.wireframe)],r.scene.markNeedsUpdateRendererDirty()));let s=this.data;if(!a&&s.geometry?.type!=="NonParametricGeometry"&&"materials"in s&&s.materials!==void 0&&(this.disposeMaterial(),this.material=r.shared.material(s.materials[0]).getFlavor(n.flatShading,n.side,n.wireframe)),!a&&(e.flatShading!==void 0||e.wireframe!==void 0||e.side!==void 0))if(Array.isArray(this.material))for(let l=0;l<this.material.length;l++)this.material[l]=this.material[l].getFlavor(n.flatShading,n.side,n.wireframe);else this.material=this.material.getFlavor(n.flatShading,n.side,n.wireframe,o);this.syncShadowCatcher(r)}shadowCatcherActive(){let e=this.dataPatched,r=e.geometry?.type;return e.shadowCatcher===!0&&(r==="RectangleGeometry"||r==="PlaneGeometry")}syncShadowCatcher(e){let r=this.dataPatched;if(this.shadowCatcherActive()){if(this.shadowCatcherMaterial===void 0){let n=d2();if(n===null)return;this.shadowCatcherMaterial=n}this.shadowCatcherMaterial.side=r.side,this.material!==this.shadowCatcherMaterial&&(this.disposeMaterial(),this.material=this.shadowCatcherMaterial,e.scene.markNeedsUpdateRendererDirty()),this.castShadow=!1,this.receiveShadow=!0,this.layers.set(0)}else this.shadowCatcherMaterial!==void 0&&this.material===this.shadowCatcherMaterial&&(this.materialOverride!==void 0?(this.material=this.materialOverride,e.scene.markNeedsUpdateRendererDirty()):"material"in r&&r.material!==void 0&&(this.material=e.shared.material(r.material).getFlavor(r.flatShading,r.side,r.wireframe),e.scene.markNeedsUpdateRendererDirty(),this.needsAO&&this.layers.enable(5)),this.castShadow=r.castShadow,this.receiveShadow=r.receiveShadow)}static disposeOneMaterial(e){Vy(e)&&!O2(e)&&e.nodeMaterialDispose()}disposeMaterial(){this.material&&Pf(this.material).forEach(e=>{xr.disposeOneMaterial(e)})}dispose(){this.disposeMaterial(),this.shadowCatcherMaterial?.dispose(),super.dispose()}};var Sr=require("three");var D2=new Sr.Vector3,R2=new Sr.Vector4,B2=new Sr.Vector4,tV=new Sr.Vector3,N2=new Sr.Matrix4,Cs=new Sr.Mesh,rV=Cs.geometry,nV=Cs.material,Gy=new Sr.Vector3,tt=class extends xr{constructor(e,r,n){super(e,r);this.data=r;this.isSkinnedMesh=!1;this.localGeometry=void 0,r.bindMode&&r.bindMatrix&&(this.bindMode=r.bindMode,this.bindMatrix=new Sr.Matrix4().fromArray(r.bindMatrix),this.bindMatrixInverse=new Sr.Matrix4)}chooseGeoemtryCache(e){return e.geometryCache}supportsInPlaceGeometryUpdate(e){return e.isTextGeometry!==!0}markGeometryAsReachable(e){this.geometryCreateDeleyed instanceof Sr.BufferGeometry&&this.chooseGeoemtryCache(e).markAsReachable(this.dataPatched.geometry,this.geometryCreateDeleyed)}get builtSharedGeometry(){if(this.localGeometry===void 0)return this.geometryCreateDeleyed instanceof Sr.BufferGeometry?this.geometryCreateDeleyed:void 0}get geometry(){if(this.localGeometry!==void 0)return this.localGeometry;if(this.geometryCreateDeleyed instanceof As){let e=this.geometryCreateDeleyed,r=this.chooseGeoemtryCache(e),n=this.dataPatched.geometry;this.geometryCreateDeleyed=r.get(n,e,this),this._geometryCacheKey=n}return this.geometryCreateDeleyed}set geometry(e){this.localGeometry=e}get is2DAndNoDepth(){let e=this.dataPatched.geometry;return fp.is2DParametricMesh(e.type)&&e.depth===0}get is2DType(){return fp.is2DParametricMesh(this.geometry.userData.type)}get isTextType(){return this.geometry.isTextGeometry===!0}get isNonParametric(){return this.geometry.userData.type==="NonParametricGeometry"}updateByPatchedOp(e,r,n){super.updateByPatchedOp(e,r,n),Ye(e.path,["geometry"])&&this.updateByPatchedOpGeometry(or.drop(e,1),r.geometry,n)}removeInteractionGeometry(e){this.localGeometry?.dispose(),this.localGeometry=void 0}dispose(){super.dispose(),EM(this.uuid),this._posed=void 0}get appliedGeometrySize(){let e=this.localGeometry?.userData;if(!(e===void 0||e.sxPrev===void 0))return[e.sxPrev,e.syPrev,e.szPrev]}updateGeometryInteractions(e,r){this.invalidateDownstreamBooleanData();let n=this.data.geometry.type;if(n==="NonParametricGeometry"||n==="SubdivGeometry"){let o=e;if(this.localGeometry===void 0){let h={...this.data.geometry,...o};this.localGeometry=Li(h,r,this.data.flatShading,this)}let a,s,l;o.scaleBaked?[a,s,l]=o.scaleBaked:{width:a,height:s,depth:l}=o;let c=this.localGeometry.userData,d=typeof a=="number"?a:1,u=typeof s=="number"?s:1,p=typeof l=="number"?l:1;c.sxPrev!==void 0&&jp(this.localGeometry.attributes,d/c.sxPrev,u/c.syPrev,p/c.szPrev),c.sxPrev=d,c.syPrev=u,c.szPrev=p}else if(!this.absorbDepthInteraction(e)){let o={...this.data.geometry,...e},a=Li(o,r,this.data.flatShading,this);this.localGeometry!==void 0&&this.supportsInPlaceGeometryUpdate(this.localGeometry)&&Dy(this.localGeometry,a)?a.dispose():(this.localGeometry?.dispose(),this.localGeometry=a)}}absorbDepthInteraction(e){let r=this.localGeometry;if(r?.shiftDepthTo===void 0)return!1;let n=e;if(typeof n.depth!="number")return!1;let o=r.userData?.parameters;if(o===void 0)return!1;for(let a of Object.keys(n))if(a!=="depth"&&n[a]!==o[a])return!1;return r.shiftDepthTo(n.depth)?(o.depth=n.depth,!0):!1}refreshAttachedClonersInteractions(e){for(let r of this.attachedSurfaceCloners)r.update(e)}refreshAttachedCloners(e){for(let r of this.attachedSurfaceCloners)e.scene.addPendingUpdateCloner(r.object)}refreshAttachedPaths(e){for(let r of this.attachedPaths)e.scene.addPendingCommand(()=>r.updateShape())}createGeometryDelayed(e){this.geometryCreateDeleyed=e.shared,this.refreshAttachedCloners(e),this.refreshAttachedPaths(e)}updateByPatchedOpGeometry(e,r,n){let o=!1;if(e.type===0&&e.path.length===0&&Object.keys(e.props).includes("scaleBaked")&&this.geometryCreateDeleyed instanceof Lt&&this.chooseGeoemtryCache(n.shared).mutateIfUnique(this.geometryCreateDeleyed.data,r)===this.geometryCreateDeleyed&&(o=!0,this.geometryCreateDeleyed.mutateDirectlyScaleBaked(r,e.props.scaleBaked),this.refreshAttachedCloners(n),this.refreshAttachedPaths(n)),!o&&e.type===0&&e.path.length===0&&Ly(e.props)&&this.geometryCreateDeleyed instanceof Lt&&this.chooseGeoemtryCache(n.shared).mutateIfUnique(this.geometryCreateDeleyed.data,r)===this.geometryCreateDeleyed&&(o=!0,this.geometryCreateDeleyed.mutateDirectlySubdivisions(r),this.refreshAttachedCloners(n),this.refreshAttachedPaths(n)),!o&&e.type===0&&e.path.length===0&&this.geometryCreateDeleyed instanceof Sr.BufferGeometry&&!(this.geometryCreateDeleyed instanceof Lt)&&this.supportsInPlaceGeometryUpdate(this.geometryCreateDeleyed)&&this._geometryCacheKey!==void 0){let a=n.shared,s=this.chooseGeoemtryCache(a),l=this.geometryCreateDeleyed;if(s.getCached(this._geometryCacheKey)===l&&l.isShared!==!0){let d=this.dataPatched.geometry,u=Li(d,a,this.data.flatShading,this);Dy(l,u)?(u.dispose(),l.computeBoundingSphere(),s.mutateIfUnique(this._geometryCacheKey,d)):(u.computeBoundingSphere(),s.forceDelete(this._geometryCacheKey),s.adopt(d,u),this.geometryCreateDeleyed=u),this._geometryCacheKey=d,o=!0,this.refreshAttachedCloners(n),this.refreshAttachedPaths(n)}}o||(n.scene?.markGeometryCacheDirty(),this.createGeometryDelayed(n)),this.syncShapeBlendNodeLayer(),this.resetBBoxNeedsUpdate(),this.invalidateDownstreamBooleanData()}updateGeometryOnStateUpdate(e,r){this.createGeometryDelayed(r)}applyTransientGeometryData(e,r){let n=e.shared,o=this.dataPatched.geometry;if(this.geometryCreateDeleyed instanceof Sr.BufferGeometry&&!(this.geometryCreateDeleyed instanceof Lt)&&this.supportsInPlaceGeometryUpdate(this.geometryCreateDeleyed)&&this._geometryCacheKey!==void 0){let a=this.chooseGeoemtryCache(n),s=this.geometryCreateDeleyed;if(a.getCached(this._geometryCacheKey)===s&&s.isShared!==!0){let c=Li(o,n,this.data.flatShading,this);Dy(s,c)?(c.dispose(),s.computeBoundingSphere(),a.mutateIfUnique(this._geometryCacheKey,o)):(c.computeBoundingSphere(),a.forceDelete(this._geometryCacheKey),a.adopt(o,c),this.geometryCreateDeleyed=c),this._geometryCacheKey=o,this.refreshAttachedCloners(e),this.refreshAttachedPaths(e);return}}r&&this._geometryCacheKey!==void 0&&this.chooseGeoemtryCache(n).forceDelete(this._geometryCacheKey),e.scene?.markGeometryCacheDirty(),this.createGeometryDelayed(e)}updateState(e,r){e.geometry!==void 0&&this.updateGeometryOnStateUpdate(e.geometry,r);let n=e.morphTargetInfluences;if(n){this.updateMorphTargets(),this.geometry.morphTargetsRelative=!0;for(let{data:{name:o,value:a}}of n)this.updateMorphInfluences(o,r.shared.getVariable(a,[this.uuid,"morphTargetInfluences",o]))}super.updateState(e,r)}updateMorphInfluences(e,r){if(this.morphTargetDictionary===void 0)return;let n=this.morphTargetDictionary[e];n!==void 0&&(this.morphTargetInfluences[n]=r)}updateGeometryGroupsIfNeeded(){Array.isArray(this.material)&&this.geometry.groups.length===0&&this.geometry.addGroup(0,Math.max(this.geometry.getIndex()?.count??0,this.geometry.getAttribute("position").count),0)}updateEntityBoxSize(e,r){let n=this.posedGeometry()?.boundingBox;if(n){n.getCenter(e),n.getSize(r).multiplyScalar(.5);return}let o=this.geometry.userData.parameters;this.is2DType||this.isTextType?e.set(0,0,o.depth*.5):this.isNonParametric?(e.setScalar(0),this.geometry.boundingSphere&&e.copy(this.geometry.boundingSphere.center),r.set(o.width,o.height,o.depth??0).multiplyScalar(.5)):o.centerOffset?e.fromArray(o.centerOffset):e.setScalar(0),r.set(o.width,o.height,o.depth??0).multiplyScalar(.5)}updateMatrixWorld(e){super.updateMatrixWorld(e),this.bindMode==="attached"?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode==="detached"&&this.bindMatrixInverse.copy(this.bindMatrix).invert()}bind(e,r){this.skeleton=e,this.isSkinnedMesh=!0,r===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),r=this.matrixWorld),this.bindMatrix.copy(r),this.bindMatrixInverse.copy(r).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(e){let r=new Sr.Vector4,n=this.geometry.attributes.skinWeight;for(let o=0,a=n.count;o<a;o++){r.fromBufferAttribute(n,o);let s=1/r.manhattanLength();s!==1/0?r.multiplyScalar(s):r.set(1,0,0,0),n.setXYZW(o,r.x,r.y,r.z,r.w)}}boneTransform(e,r){let n=this.skeleton;if(n===void 0)return;let o=this.geometry;R2.fromBufferAttribute(o.attributes.skinIndex,e),B2.fromBufferAttribute(o.attributes.skinWeight,e),D2.copy(r).applyMatrix4(this.bindMatrix),r.set(0,0,0);for(let a=0;a<4;a++){let s=B2.getComponent(a);if(s!==0){let l=R2.getComponent(a);N2.multiplyMatrices(n.bones[l].matrixWorld,n.boneInverses[l]),r.addScaledVector(tV.copy(D2).applyMatrix4(N2),s)}}return r.applyMatrix4(this.bindMatrixInverse)}raycastDeformed(e,r){let n=this.posedGeometry();if(n===void 0)return!1;Cs.geometry=n,Cs.material=this.material,Cs.matrixWorld.copy(this.matrixWorld);let o=r.length;Cs.raycast(e,r);for(let a=o;a<r.length;a++)r[a].object=this;return Cs.geometry=rV,Cs.material=nV,!0}posedGeometry(){let e=this.skeleton;if(!this.isSkinnedMesh||e===void 0)return;let r=this.geometry,{position:n,skinIndex:o,skinWeight:a}=r.attributes;if(!n||!o||!a)return;let s=[...this.bindMatrix.elements,...this.bindMatrixInverse.elements,...this.morphTargetInfluences??[]];for(let h=0;h<e.bones.length;h++){let f=e.bones[h];if(!f||!e.boneInverses[h])return;s.push(...f.matrixWorld.elements)}let l=this._posed;if(l?.source===r&&l.version===n.version&&l.pose.length===s.length&&l.pose.every((h,f)=>h===s[f]))return l.geometry;let c=n.count,d=l?.geometry.attributes.position,u=d?.count===c?d:new Sr.BufferAttribute(new Float32Array(c*3),3);for(let h=0;h<c;h++)this.boneTransform(h,this.getVertexPosition(h,Gy)),u.setXYZ(h,Gy.x,Gy.y,Gy.z);let p=new Sr.BufferGeometry;p.setAttribute("position",u);for(let h of["normal","uv","uv1"]){let f=r.attributes[h];f&&p.setAttribute(h,f)}return p.setIndex(r.index),p.groups=r.groups,p.drawRange=r.drawRange,p.computeBoundingSphere(),p.computeBoundingBox(),this._posed={source:r,version:n.version,pose:s,geometry:p},p}};var V2=require("three");var Wo=require("three");var L2=require("three"),jo=i=>{var t;return t=class extends i{},t.geometryHelper=new L2.BoxGeometry(30,30,30),t};var Cn=require("three"),Uy=new Cn.Ray,OS=new Cn.Sphere,_2=new Cn.Matrix4,Ho=(i,t,e,r,n=!1,o=i)=>{let a=t,s=o.matrixWorld;if(a.boundingSphere===null&&a.computeBoundingSphere(),OS.copy(a.boundingSphere),OS.applyMatrix4(s),e.ray.intersectsSphere(OS)===!1||(_2.copy(s).invert(),Uy.copy(e.ray).applyMatrix4(_2),a.boundingBox!==null&&Uy.intersectsBox(a.boundingBox)===!1))return;let l,c,d,u,p=a.index,h=a.attributes.position,f=a.drawRange,m,y;if(n===!1){let v=Math.max(0,f.start),b=Math.min(p.count,f.start+f.count);for(m=v,y=b;m<y;m+=3)if(c=p.getX(m),d=p.getX(m+1),u=p.getX(m+2),l=g(i,e,Uy,h,c,d,u),l){l.faceIndex=Math.floor(m/3),r.push(l);return}}else{let b=a.attributes.position,S=new Cn.Vector3,x=new Cn.Vector3,w=new Cn.Vector3,A=new Cn.Vector3,C=2,M=1/((o.scale.x+o.scale.y+o.scale.z)/3),B=M*M,I=Math.max(0,f.start),_=Math.min(b.count,f.start+f.count);for(let E=I,R=_-1;E<R;E+=C){if(S.fromBufferAttribute(b,E),x.fromBufferAttribute(b,E+1),Uy.distanceSqToSegment(S,x,A,w)>B)continue;A.applyMatrix4(o.matrixWorld);let F=e.ray.origin.distanceTo(A);F<e.near||F>e.far||r.push({distance:F,point:w.clone().applyMatrix4(o.matrixWorld),object:i})}}function g(v,b,S,x,w,A,C){let P=new Cn.Vector3,M=new Cn.Vector3,B=new Cn.Vector3,I=new Cn.Vector3,_=new Cn.Vector3;if(P.fromBufferAttribute(x,w),M.fromBufferAttribute(x,A),B.fromBufferAttribute(x,C),S.intersectTriangle(P,M,B,!1,I)===null)return null;_.copy(I),_.applyMatrix4(v.matrixWorld);let R=b.ray.origin.distanceTo(_);return R<b.near||R>b.far?null:{faceIndex:1,distance:R,point:_.clone(),object:v}}};var iV=new Wo.Vector3(1,1,1),F2=new Wo.Vector3,oV=new Wo.Vector3,k2=new Wo.Quaternion,Fi=class extends jo(Wo.AxesHelper){constructor(e,r=15){super(r);this.object=e;this.dummy=new Wo.Group;this.object.updateMatrixWorld(),this.name=`EmptyObjectHelper: ${e.uuid}`,this.matrix=this.dummy.matrixWorld,this.matrixAutoUpdate=!1,this.object.isBone&&(this.visible=!1)}raycast(e,r){Ho(this.object,Fi.geometryHelper,e,r,!1,this.dummy)}update(){}updateMatrix(){}updateMatrixWorld(e){this.object.matrixWorld.decompose(F2,k2,oV),this.matrix.compose(F2,k2,iV),super.updateMatrixWorld(e)}updateWorldMatrix(e,r){}};var qp=require("three");var zy;(t=>t.is=e=>"objectHelper"in e)(zy||(zy={}));var ki=(i,t)=>class extends Yc(i){constructor(){super(...arguments);this.objectHelper=new t(this);this.gizmos={}}get geometryHelper(){return t.geometryHelper}raycast(n,o){this.objectHelper.raycast(n,o)}showGizmos(){for(let n in this.gizmos){let o=this.gizmos[n];o instanceof qp.Box3Helper&&(o.visible=!0)}}updateEntityBoxSize(n,o){this.objectHelper.visible&&this.geometryHelper instanceof qp.BoxGeometry?(n.setScalar(0),o.set(this.geometryHelper.parameters.width,this.geometryHelper.parameters.height,this.geometryHelper.parameters.height).multiplyScalar(.5)):super.updateEntityBoxSize(n,o)}hideGizmos(){for(let n in this.gizmos){let o=this.gizmos[n];o instanceof qp.Box3Helper&&(o.visible=!1)}}};var vd=class extends ki(V2.Group,Fi){constructor(e,r,n){super();this.super_Entity(e,r),this.context=n,this.objectHelper.update()}updateState(e,r){this.updateState_Entity(e,r)}};var aV=null;function G2(){return aV}var Je=require("three"),Zy=gc(z2());var sV=.5*(Math.sqrt(3)-1),Xp=(3-Math.sqrt(3))/6,lV=1/3,qo=1/6,Oee=(Math.sqrt(5)-1)/4,Iee=(5-Math.sqrt(5))/20,Yp=i=>Math.floor(i)|0,j2=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]),DS=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 H2(i=Math.random){let t=q2(i),e=new Float64Array(t).map(n=>j2[n%12*2]),r=new Float64Array(t).map(n=>j2[n%12*2+1]);return function(o,a){let s=0,l=0,c=0,d=(o+a)*sV,u=Yp(o+d),p=Yp(a+d),h=(u+p)*Xp,f=u-h,m=p-h,y=o-f,g=a-m,v,b;y>g?(v=1,b=0):(v=0,b=1);let S=y-v+Xp,x=g-b+Xp,w=y-1+2*Xp,A=g-1+2*Xp,C=u&255,P=p&255,M=.5-y*y-g*g;if(M>=0){let _=C+t[P],E=e[_],R=r[_];M*=M,s=M*M*(E*y+R*g)}let B=.5-S*S-x*x;if(B>=0){let _=C+v+t[P+b],E=e[_],R=r[_];B*=B,l=B*B*(E*S+R*x)}let I=.5-w*w-A*A;if(I>=0){let _=C+1+t[P+1],E=e[_],R=r[_];I*=I,c=I*I*(E*w+R*A)}return 70*(s+l+c)}}function W2(i=Math.random){let t=q2(i),e=new Float64Array(t).map(o=>DS[o%12*3]),r=new Float64Array(t).map(o=>DS[o%12*3+1]),n=new Float64Array(t).map(o=>DS[o%12*3+2]);return function(a,s,l){let c,d,u,p,h=(a+s+l)*lV,f=Yp(a+h),m=Yp(s+h),y=Yp(l+h),g=(f+m+y)*qo,v=f-g,b=m-g,S=y-g,x=a-v,w=s-b,A=l-S,C,P,M,B,I,_;x>=w?w>=A?(C=1,P=0,M=0,B=1,I=1,_=0):x>=A?(C=1,P=0,M=0,B=1,I=0,_=1):(C=0,P=0,M=1,B=1,I=0,_=1):w<A?(C=0,P=0,M=1,B=0,I=1,_=1):x<A?(C=0,P=1,M=0,B=0,I=1,_=1):(C=0,P=1,M=0,B=1,I=1,_=0);let E=x-C+qo,R=w-P+qo,L=A-M+qo,F=x-B+2*qo,k=w-I+2*qo,W=A-_+2*qo,U=x-1+3*qo,G=w-1+3*qo,q=A-1+3*qo,X=f&255,Y=m&255,K=y&255,te=.6-x*x-w*w-A*A;if(te<0)c=0;else{let de=X+t[Y+t[K]];te*=te,c=te*te*(e[de]*x+r[de]*w+n[de]*A)}let ue=.6-E*E-R*R-L*L;if(ue<0)d=0;else{let de=X+C+t[Y+P+t[K+M]];ue*=ue,d=ue*ue*(e[de]*E+r[de]*R+n[de]*L)}let se=.6-F*F-k*k-W*W;if(se<0)u=0;else{let de=X+B+t[Y+I+t[K+_]];se*=se,u=se*se*(e[de]*F+r[de]*k+n[de]*W)}let ce=.6-U*U-G*G-q*q;if(ce<0)p=0;else{let de=X+1+t[Y+1+t[K+1]];ce*=ce,p=ce*ce*(e[de]*U+r[de]*G+n[de]*q)}return 32*(c+d+u+p)}}function q2(i){let e=new Uint8Array(512);for(let r=0;r<512/2;r++)e[r]=r;for(let r=0;r<512/2-1;r++){let n=r+~~(i()*(256-r)),o=e[r];e[r]=e[n],e[n]=o}for(let r=256;r<512;r++)e[r]=e[r-256];return e}var X2=require("three"),ho=new X2.Triangle,jy=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 n=0;n<t.count;n+=3){let o=1;ho.a.fromBufferAttribute(t,n),ho.b.fromBufferAttribute(t,n+1),ho.c.fromBufferAttribute(t,n+2),o*=ho.getArea(),e[n/3]=o}this.distribution=new Float32Array(t.count/3);let r=0;for(let n=0;n<e.length;n++)r+=e[n],this.distribution[n]=r;return this}setRandomGenerator(t){return this.randomFunction=t,this}sample(t,e){if(this.distribution){let r=this.distribution[this.distribution.length-1],n=this.binarySearch(this.randomFunction()*r);return this.sampleFace(n,t,e)}}binarySearch(t){if(!this.distribution)return 0;let e=this.distribution,r=0,n=e.length-1,o=-1;for(;r<=n;){let a=Math.ceil((r+n)/2);if(a===0||e[a-1]<=t&&e[a]>t){o=a;break}else t<e[a]?n=a-1:r=a+1}return o}sampleFace(t,e,r){let n=this.randomFunction(),o=this.randomFunction();return n+o>1&&(n=1-n,o=1-o),ho.a.fromBufferAttribute(this.positionAttribute,t*3),ho.b.fromBufferAttribute(this.positionAttribute,t*3+1),ho.c.fromBufferAttribute(this.positionAttribute,t*3+2),e.set(0,0,0).addScaledVector(ho.a,n).addScaledVector(ho.b,o).addScaledVector(ho.c,1-(n+o)),ho.getNormal(r),this}};var Ba=require("three");var hi=require("three");function cV(i){if(i.geometry.attributes.extrudeNormal||!i.geometry.attributes.position||!i.geometry.attributes.normal)return;let t=new Map,e=i.geometry.attributes,r=e.position.array,n=e.normal.array,o=new Float32Array(r.length);for(let a=0;a<r.length;a+=3){let s=`${r[a]}_${r[a+1]}_${r[a+2]}`,l=new hi.Vector3(n[a],n[a+1],n[a+2]);t.has(s)?t.get(s)?.normals.push(l):t.set(s,{normals:[l],result:new hi.Vector3})}t.forEach((a,s)=>{for(let l of a.normals)a.result.add(l);a.result.divideScalar(a.normals.length)});for(let a=0;a<r.length;a+=3){let s=`${r[a]}_${r[a+1]}_${r[a+2]}`,l=t.get(s)?.result;l&&(o[a]=l.x,o[a+1]=l.y,o[a+2]=l.z)}i.geometry.setAttribute("extrudeNormal",new hi.Float32BufferAttribute(o,3))}function dV(i){if(i.geometry.attributes.extrudeNormals||!i.geometry.attributes.position)return;let e=i.geometry.attributes.position.array,r=new Float32Array(e.length),n=new hi.Vector3;for(let o=0;o<e.length;o+=3)n.set(e[o],e[o+1],e[o+2]).normalize(),r[o]=n.x,r[o+1]=n.y,r[o+2]=n.z;i.geometry.setAttribute("extrudeNormal",new hi.Float32BufferAttribute(r,3))}function Xo(i){if(Array.isArray(i.material)){for(let t of i.material)if(t.getLayersOfType("outline").length===0)return}else if(!Ll(i.material)||i.material.getLayersOfType("outline").length===0)return;i instanceof tt&&i.is2DAndNoDepth?dV(i):cV(i)}function RS(i){return Math.min(2047,Math.max(1,Math.round(i*2048)))/2048}function Yo(i){if(!i.geometry.attributes.position)return;let t=i.geometry.attributes,e=t.position.array,r=t.randomColor;if(r!==void 0&&r.count*3===e.length)return;let n=new Float32Array(e.length),o=parseInt(i.uuid.replace(/\D/g,"")),a=[RS(hi.MathUtils.seededRandom(o)),RS(hi.MathUtils.seededRandom(o+1e4)),RS(hi.MathUtils.seededRandom(o+2e4))];for(let s=0;s<e.length;s++)n[s]=a[s%3];i.geometry.setAttribute("randomColor",new hi.BufferAttribute(n,3))}var Qo=new Ba.Box3,Qp=new Ba.Vector3;function Y2(i){let t=!1;return i.scene.objects.traverse((e,r)=>{r.type==="Mesh"&&r.geometry.type==="SubdivGeometry"&&(t=!0)}),t}var Na=class extends tt{constructor(e,r,n){super(e,r,n);this.data=r;this.hiddenMatrixOld=new Ba.Matrix4;this.smoothShading=!0;this.skipReactionUpdate=!1}chooseGeoemtryCache(e){return this.dataPatched.flatShading?e.geometryCache:e.geometryCache2}get subdivPointerNew(){return this.localGeometry!==void 0?this.subdivPointer:this.geometry.ensureSubdivPointer()}get originalGeometryNew(){return this.localGeometry!==void 0?this.originalGeometry:this.geometry.originalGeometry}get phongAngle(){return this.data.geometry.phongAngle??45}updateEntityBoxSize(e,r){let n=this.geometry.userData.parameters;e.copy(this.originalGeometryNew.boundingSphere.center),r.set(n.width,n.height,n.depth??0).multiplyScalar(.5)}createGeometryByControls(e){if(this.skipReactionUpdate===!0)return;let r=this.localGeometry?.uuid,{originalGeometry:n,subdividedGeometry:o,subdivPointer:a}=Lt.build(e,this.subdivPointer,this.smoothShading,this.hasNonUniformScale?this.shearScale:void 0);this.subdivPointer=a,n!==void 0&&(this.originalGeometry?.dispose(),this.originalGeometry=n),o!==void 0&&(this.subdividedGeometry?.dispose(),this.subdividedGeometry=o??void 0),this.localGeometry=this.subdividedGeometry??this.originalGeometry,Xo(this),Yo(this),this.calcBoundingBox(),r&&(this.localGeometry.uuid=r)}updateState(e,r){if(super.updateState(e,r),e.flatShading!==void 0){let n=this.material;this.material=Array.isArray(n)?n.map(o=>o.getFlavor(!1,o.side,o.wireframe)):n.getFlavor(!1,n.side,n.wireframe),this.smoothShading=!e.flatShading,this.createGeometryDelayed(r)}}updateMesh(e=!1,r=!1,n=!1){r&&this.subdividedGeometry||Lt.buildLevel(this.subdivPointer,!0,this.smoothShading?this.phongAngle:-1,this.originalGeometry,e&&this.hasNonUniformScale?this.shearScaleInv:void 0,n),this.subdividedGeometry&&Lt.buildLevel(this.subdivPointer,!1,this.smoothShading?this.phongAngle:-1,this.subdividedGeometry,e&&this.hasNonUniformScale?this.shearScaleInv:void 0)}updateTopology(){let e=this.localGeometry?.uuid;this.originalGeometry.dispose(),this.originalGeometry=Lt.buildLevel(this.subdivPointer,!0,this.smoothShading?this.phongAngle:-1),this.subdividedGeometry&&(this.subdividedGeometry.dispose(),this.subdividedGeometry=Lt.buildLevel(this.subdivPointer,!1,this.smoothShading?this.phongAngle:-1)),this.localGeometry=this.subdividedGeometry??this.originalGeometry,Xo(this),Yo(this),this.calcBoundingBox(),e&&(this.localGeometry.uuid=e)}raycast(e,r){let n=this.localGeometry;this.localGeometry=this.originalGeometryNew,it.prototype.raycast.call(this,e,r),this.localGeometry=n}activateShearCompensation(){!this.hasNonUniformScale||(this.matrix.copy(this.matrixWorldRigid),this.hiddenMatrixOld.copy(this.hiddenMatrix),this.hiddenMatrix.copy(this.parent.matrixWorld).invert())}deactivateShearCompensation(){!this.hasNonUniformScale||(this.updateMatrix(),this.hasNonUniformScale=void 0,this.hiddenMatrix.copy(this.hiddenMatrixOld))}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new Ba.Sphere,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let r=e.attributes.position,n=e.boundingSphere.center;Qo.setFromBufferAttribute(r),Qo.getCenter(n),e.boundingSphere.radius=n.distanceTo(Qo.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),Qo.getSize(Qp),this.hasNonUniformScale&&Qp.divide(this.scale);let o={width:Qp.x,height:Qp.y,depth:Qp.z};return this.geometry.userData.parameters=o,o}updateBoundingSphere(e){let r=this.originalGeometry;Qo.min.set(e[0],e[2],e[4]),Qo.max.set(e[1],e[3],e[5]),this.hasNonUniformScale&&(Qo.min.applyMatrix4(this.shearScaleInv),Qo.max.applyMatrix4(this.shearScaleInv)),r.boundingSphere===null&&(r.boundingSphere=new Ba.Sphere);let n=r.boundingSphere.center;Qo.getCenter(n),r.boundingSphere.radius=n.distanceTo(Qo.max)}freeSubdivPointer(){this.subdivPointer&&(Lt.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0),this.localGeometry=void 0,this.originalGeometry?.dispose(),this.subdividedGeometry?.dispose()}dispose(){super.dispose(),this.freeSubdivPointer()}updateSubdivisionLevel(e){if(this.skipReactionUpdate===!0)return;let r=this.localGeometry,n=r?.uuid,o=r?.userData.parameters,a=e.subdivisions>0?Lt.buildRefined(this.subdivPointer,e.subdivisions,this.smoothShading?e.phongAngle??35:-1):null;this.subdividedGeometry?.dispose(),this.subdividedGeometry=a??void 0,this.subdividedGeometry&&this.originalGeometry.boundingSphere&&(this.subdividedGeometry.boundingSphere=this.originalGeometry.boundingSphere),this.localGeometry=this.subdividedGeometry??this.originalGeometry,Xo(this),Yo(this),o!==void 0&&(this.localGeometry.userData.parameters=o),n&&(this.localGeometry.uuid=n)}updateByPatchedOpGeometry(e,r,n){super.updateByPatchedOpGeometry(e,r,n),this.localGeometry&&(e.type===0&&e.path.length===0&&Ly(e.props)&&this.subdivPointer?this.updateSubdivisionLevel(r):this.createGeometryByControls(r))}};var Ko=require("three"),Q2=-1,uV=1,K2={x:[1,0,0],"-x":[-1,0,0],y:[0,1,0],"-y":[0,-1,0],z:[0,0,1],"-z":[0,0,-1]},Z2={polygon_center:0,edge:1,vertex:2},Kp=(i,t)=>(e,r)=>!t||e===0||i===0?0:i*r/100,ze=(i,t)=>{let e=Math.abs(t),r=e*-1;return(i-Q2)*(e-r)/(uV-Q2)+r},pV=new Ko.Vector3,Hy=new Ko.Vector3,hV=new Ko.Vector3,fV=new Ko.Vector3;function bd(i,t){let e=hV.fromArray(i),r=fV.fromArray(t);Hy.copy(r).sub(e);let n=Hy.length();return Hy.normalize().multiplyScalar(n*.5),pV.copy(e).add(Hy).toArray()}var Vi=new Ko.Triangle,Wy=new Ko.Vector3,qy=new Ko.Vector3,_l=new Ko.Vector3;function J2(i){let t=[],e=Math.floor(i.index.count/3);for(let r=0;r<e;r++)if(Wy.fromArray(i.index.array,r*3),Vi.setFromAttributeAndIndices(i.attributes.position,Wy.x,Wy.y,Wy.z),Vi.getNormal(qy),Vi.getMidpoint(_l),!(isNaN(_l.x)||isNaN(_l.y)||isNaN(_l.z))){let{a:n,b:o,c:a}=Vi,s=n.toArray(),l=o.toArray(),c=a.toArray(),d=n.distanceTo(o),u=o.distanceTo(a),p=a.distanceTo(n),h=bd(s,l),f=bd(l,c),m=bd(c,s),y=[d,u,p],g=Math.max(...y),v=y.filter(x=>Math.round(x)===Math.round(g)).length>1,b=[],S=Vi.getMidpoint(_l).toArray();g===d&&!v&&(b=[f,m,m],S=h),g===u&&!v&&(b=[h,m,m],S=f),g===p&&!v&&(b=[h,f,f],S=m),v&&(b=[h,f,m]),t.push({vertices:[s,l,c],faceCenters:b,midpoint:S,norm:Vi.getNormal(qy).toArray()})}return t}function $2(i){let t=[],{position:e}=i.attributes;for(let r=0;r<e.count;r++){Vi.setFromAttributeAndIndices(e,r*3,r*3+1,r*3+2),Vi.getNormal(qy),Vi.getMidpoint(_l);let n=Vi.a.toArray(),o=Vi.b.toArray(),a=Vi.c.toArray();t.push({vertices:[n,o,a],faceCenters:[bd(n,o),bd(o,a),bd(a,n)],midpoint:_l.toArray(),norm:qy.toArray()})}return t}var xd=require("three"),BS=class extends xd.InstancedMesh{},Xy=class extends BS{constructor(e,r){super(void 0,void 0,r);this.source=e;this.isClonerInstancedMesh=!0;this.hiddenMatrix=new xd.Matrix4;this.pivotMatrix=new xd.Matrix4;this.previousModelViewMatrix=new xd.Matrix4;this.copyPreviousMatrix=!0;this.capacity=r,this.count=0,this.matrixAutoUpdate=!1}raycast(e,r){}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),this.matrixWorld.multiply(this.pivotMatrix),this.matrixWorldNeedsUpdate=!1,e=!0);for(let r of this.children)r.updateMatrixWorld(e)}updateWorldMatrix(e,r){let n=this.parent;if(e&&n!==null&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),this.matrixWorld.multiply(this.pivotMatrix),r)for(let o of this.children)o.updateWorldMatrix(!1,!0)}onAfterRender(e,r,n,o,a,s){this.copyPreviousMatrix&&this.previousModelViewMatrix.copy(this.modelViewMatrix)}get visible(){return this.source.cloner?.insideBoolean===!0?!1:this.source.visible||this.source.dataPatched.visible&&this.source.dataPatched.cloner?.hideBase===!0}set visible(e){}get castShadow(){return this.source.castShadow}set castShadow(e){}get receiveShadow(){return this.source.receiveShadow}set receiveShadow(e){}get layers(){return this.source.layers}set layers(e){}get geometry(){return this.source.geometry}set geometry(e){}get material(){return this.source.material}set material(e){}get morphTargetInfluences(){return this.source.morphTargetInfluences}set morphTargetInfluences(e){}};var NS=i=>.5*(1-Math.cos(i*Math.PI)),LS=class{constructor(){this.perlin=new Array(4095+1)}noise(t,e=0,r=0){if(this.perlin==null){this.perlin=new Array(4095+1);for(let g=0;g<4095+1;g++)this.perlin[g]=Math.random()}t<0&&(t=-t),e<0&&(e=-e),r<0&&(r=-r);let n=Math.floor(t),o=Math.floor(e),a=Math.floor(r),s=t-n,l=e-o,c=r-a,d,u,p=0,h=.5,f,m,y;for(let g=0;g<4;g++){let v=n+(o<<4)+(a<<8);d=NS(s),u=NS(l),f=this.perlin[v&4095],f+=d*(this.perlin[v+1&4095]-f),m=this.perlin[v+16&4095],m+=d*(this.perlin[v+16+1&4095]-m),f+=u*(m-f),v+=256,m=this.perlin[v&4095],m+=d*(this.perlin[v+1&4095]-m),y=this.perlin[v+16&4095],y+=d*(this.perlin[v+16+1&4095]-y),m+=u*(y-m),f+=NS(c)*(m-f),p+=f*h,h*=.5,n<<=1,s*=2,o<<=1,l*=2,a<<=1,c*=2,s>=1&&(n++,s--),l>=1&&(o++,l--),c>=1&&(a++,c--)}return p}noiseSeed(t){let e=(()=>{let a,s;return{setSeed(l){s=a=(l??Math.random()*4294967296)>>>0},getSeed(){return a},rand(){return s=(1664525*s+1013904223)%4294967296,s/4294967296}}})();e.setSeed(t),this.perlin=new Array(4095+1);for(let r=0;r<4095+1;r++)this.perlin[r]=e.rand()}},eO=LS;var Sd=require("three");var tO=new Sd.Vector3,rO=new Sd.Matrix4,nO=new Sd.Ray,Es=class extends tt{constructor(e,r,n){super(e,r,n);this.data=r}get textGeometry(){return this.geometry}get charWidths(){return this.textGeometry.charWidths}get charCoords(){return this.textGeometry.charCoords}get wrappedText(){return this.textGeometry.wrappedText}get font(){return this.textGeometry.font}get initialOffsetY(){let e=this.dataPatched;return this.font?.getLineInitialOffsetY(this.lineHeight,this.wrappedText.length,typeof e.geometry.height=="number"?e.geometry.height:1,this.fontScale,e.geometry.verticalAlign)??0}get fontScale(){let e=this.dataPatched;return this.font?e.geometry.fontSize/this.font.unitsPerEm:1}get AD(){return Math.abs(this.ascender-this.descender)}get ascender(){return(this.font?.ascender??1)*this.fontScale}get descender(){return(this.font?.descender??1)*this.fontScale}get lineHeight(){let e=this.dataPatched;return e.geometry.fontSize*e.geometry.lineHeight}raycast(e,r){let{matrixWorld:n}=this;if(!(isNaN(e.ray.origin.x)||this.scale.x===0||this.scale.y===0||this.scale.z===0)&&(rO.copy(n).invert(),nO.copy(e.ray).applyMatrix4(rO),nO.intersectBox(this.singleBBox,tO))){let o=tO.applyMatrix4(n),a=e.ray.origin.distanceTo(o);r.push({distance:a,point:o.clone(),object:this})}}};var _n=1e-4,Zo,mO,yO,gO,iO=new Je.Vector3,oO=new Je.Vector3;Iy.then(i=>{Zo=i,mO=[Zo.get_face_center,Zo.get_edge_midpoint,Zo.get_vertex_position],yO=[Zo.get_face_normal,Zo.get_edge_normal,Zo.get_vertex_normal],gO=[Zo.face_count,Zo.edge_count,Zo.vertex_count]});var _te=new Je.Matrix4,mV=new Je.Matrix4,aO=new Je.Matrix4,sO=new Je.Matrix4,lO=new Je.Matrix4,cO=new Je.Matrix4,dO=new Je.Matrix4,uO=new Je.Matrix4,Ts=new Je.Vector3,Yy=new Je.Vector3,Zp=new Je.Vector3,_S=new Je.Vector3,yV=new Je.Vector3,pO=new Je.Vector3,Qy=new Je.Vector3,FS=new Je.Vector3,hO=new Je.Vector3,kS=new Je.Vector3,fO=new Je.Vector3,fo=new Je.Euler,gV=new Je.Quaternion;function Ky(i){return i?i.version??i.data?.version??0:-1}function ar(i,t){return[typeof i?.[0]=="number"?i[0]:typeof i?.[0]=="string"&&t?parseFloat(String(t.shared.getVariable(i[0])??"0")):0,typeof i?.[1]=="number"?i[1]:typeof i?.[1]=="string"&&t?parseFloat(String(t.shared.getVariable(i[1])??"0")):0,typeof i?.[2]=="number"?i[2]:typeof i?.[2]=="string"&&t?parseFloat(String(t.shared.getVariable(i[2])??"0")):0]}var VS=class{constructor(t,e){this.data=t;this.is3D=e;this.perlin=new eO;t.noiseType==="perlin"?(this.perlin.noiseSeed(t.seed),e?this.noise=(n,o,a)=>this.perlin.noise(n,o,a):this.noise=n=>this.perlin.noise(n)):e?this.noise=W2((0,Zy.default)(t.seed)):this.noise=H2((0,Zy.default)(t.seed??""))}},Fn=class extends Wc(Je.Object3D){constructor(e,r){super();this.parameters=r;this.isCloner=!0;this.objectForSample=void 0;this._pendingMediaLoad=!1;this.random=null;this.surfaceSamplerCache=null;this.surfacePointsCache=null;this.object=e}resetOnMove(){this.removeFromParent(),this.parent=null}removeFromParent(){return super.removeFromParent(),this.instancedMesh?.removeFromParent(),this}dispose(){this.removeFromParent(),this._disposeInstancedMesh(),this._invalidateBoolean()}_invalidateBoolean(){this.object instanceof it&&this.object.onClonerLayoutUpdated()}expandClones(e){if(this.parent===null)this.updateState(this.parameters,e);else{for(let r of this.children)r instanceof Rr&&r.expand();this._syncInstancedMesh()}}invalidateTransform(e){this.matrixWorldNeedsUpdate=!0}onObjUpdateMatrix(){this.parameters.type!=="toObject"&&(this.matrixWorldNeedsUpdate=!0)}update(e){switch(this._updateCount(e),this.parameters.type){case"radial":this._updateRadial(this.parameters,e);break;case"linear":this._updateLinear(this.parameters,e);break;case"grid":this._updateGrid(this.parameters,e);break;case"toObject":this._updateToObject(this.parameters,e)}for(let r of this.children){let n=r.transformOverride;n!==void 0&&(r.position.fromArray(n.position),r.rotation.fromArray(n.rotation),r.scale.fromArray(n.scale)),r.updateMatrix(),r.hasNonUniformScale&&(r.updateMatrixWorld(),r.updateMatrixWorldRigid())}this._syncInstancedMesh(),this._invalidateBoolean()}get instancingActive(){return this.instancedMesh!==void 0}get insideBoolean(){return this.parent!==null&&"booleanOp"in this.parent}_instancingEligible(){if(this.parameters.instanced!==!0)return!1;let e=this.object;return!(e.entityChildrenCount()>0||e.isMesh!==!0||li(e)||e.isDecalObject===!0)}_syncInstancedMesh(){if(!this._instancingEligible()){this._disposeInstancedMesh();return}let e=this.instancedMesh;if(e!==void 0&&e.capacity<this.children.length&&(this._disposeInstancedMesh(),e=void 0),e===void 0){let r=Math.max(8,Math.ceil(this.children.length*1.5));e=this.instancedMesh=new Xy(this.object,r)}e.matrix=this.matrix,e.hiddenMatrix=this.hiddenMatrix,e.matrixWorldNeedsUpdate=!0,e.parent!==this.parent&&(e.removeFromParent(),this.parent?.add(e)),this.syncInstanceMatrices()}syncInstanceMatrices(){this._invalidateBoolean();let e=this.instancedMesh;if(e===void 0)return;let r=0;for(let n of this.children)n.playModeVisible!==!1&&(aO.multiplyMatrices(n.hiddenMatrix,n.matrix).multiply(n.pivotMatrix),e.setMatrixAt(r++,aO));e.count=r,e.instanceMatrix.needsUpdate=!0,e.boundingSphere=null}_disposeInstancedMesh(){let e=this.instancedMesh;e!==void 0&&(this.instancedMesh=void 0,e.removeFromParent(),e.dispose())}_updateCount(e,r){let n;if(r!==void 0)n=r;else{let o=ar(this.parameters.grid.count,e);n=this.parameters.type==="grid"?Math.round(o[0])*Math.round(o[1])*Math.round(o[2]):this.parameters.count}if(this.parameters.type==="toObject"){if(!this.parameters.toObject.object)n=0;else if(r===void 0&&this.parameters.toObject.spreadType!=="random")return}if(this.children.length!==n)if(this.children.length<n)for(let o=0,a=n-this.children.length;o<a;++o){let s=new Rr(this.object);s.expand(),this.add(s)}else for(;this.children.length>n;){let o=this.children.pop();o.parent=null,o.dispatchEvent({type:"removed"}),this.dispatchEvent({type:"childremoved",child:o})}}getRandom(e,r=!1){return(this.random===null||this.random.data.seed!==e.seed||this.random.data.noiseType!==e.noiseType||this.random.is3D!==r)&&(this.random=new VS(e,r)),this.random}_updateRadial(e,r){let n=e.radial,o=n.start*Je.MathUtils.DEG2RAD,a=n.end*Je.MathUtils.DEG2RAD,s=o-a,l=ar(n.rotation,r),c=new Je.Euler(l[0],l[1],l[2]),d;switch(n.axis){case"z":d=new Je.Vector3(0,0,1);break;case"y":d=new Je.Vector3(0,1,0);break;default:case"x":d=new Je.Vector3(1,0,0);break}let u=e.randomnessObject??Do.defaultData([1,1,1]).randomnessObject,h=this.parameters.randomness===!0&&u.strength!==0?this.getRandom(u):null,f=ar(n.scale,r),m=ar(n.position,r),y=ar(u.scale,r),g=ar(u.position,r),v=ar(u.rotation,r),b=s/e.count,S=Kp(u.strength,this.parameters.randomness);for(let[x,w]of this.children.entries()){let A=x*(u.freqScale/10)+u.movement,C=h===null?0:h.noise(A,A,A),P=x+1;w.scale.x=f[0]+S(P,ze(C,y[0]))||_n,w.scale.y=f[1]+S(P,ze(C,y[1]))||_n,w.scale.z=f[2]+S(P,ze(C,y[2]))||_n;let M=b*x-o;switch(n.axis){default:case"x":fo.set(0,M,0);break;case"y":fo.set(0,0,M);break;case"z":fo.set(M,0,0);break}Qy.copy(d).applyQuaternion(gV.setFromEuler(fo)).multiplyScalar(n.radius),w.position.set(Qy.x+(m[0]+S(P,ze(C,g[0]))),Qy.y+(m[1]+S(P,ze(C,g[1]))),Qy.z+(m[2]+S(P,ze(C,g[2]))));let B=S(P,ze(C,v[0])),I=S(P,ze(C,v[1])),_=S(P,ze(C,v[2]));n.alignment===!0?w.rotation.set(fo.x+(c.x+B),fo.y+(c.y+I),fo.z+(c.z+_)):w.rotation.set(c.x+B,c.y+I,c.z+_)}}_updateLinear(e,r){if(e.type!=="linear")throw new Error;let n=e.linear,o=ar(n.rotation,r),a=ar(n.scale,r),s=ar(n.position,r),l=new Je.Euler(o[0]??0,o[1]??0,o[2]??0),c=e.randomnessObject??Do.defaultData([1,1,1]).randomnessObject,d=ar(c.rotation,r),u=ar(c.scale,r),p=ar(c.position,r),f=this.parameters.randomness===!0&&c.strength!==0?this.getRandom(c):null,m=Kp(c.strength,this.parameters.randomness);for(let[y,g]of this.children.entries()){let v=y*(c.freqScale/10)+c.movement,b=f===null?0:f.noise(v,v,v),S=y+1,x=m(S,ze(b,d[0])),w=m(S,ze(b,d[1])),A=m(S,ze(b,d[2]));g.scale.x=1+(a[0]-1)*y+m(S,ze(b,u[0]))||_n,g.scale.y=1+(a[1]-1)*y+m(S,ze(b,u[1]))||_n,g.scale.z=1+(a[2]-1)*y+m(S,ze(b,u[2]))||_n,g.rotation.set(l.x*y+x,l.y*y+w,l.z*y+A),g.position.x=s[0]*y+m(S,ze(b,p[0])),g.position.y=s[1]*y+m(S,ze(b,p[1])),g.position.z=s[2]*y+m(S,ze(b,p[2]))}}_updateGrid(e,r){let n=0,o=e.grid,a=e.randomnessObject??Do.defaultData([1,1,1]).randomnessObject,s=ar(a.scale,r),l=ar(a.rotation,r),c=ar(a.position,r),u=this.parameters.randomness===!0&&a.strength!==0?this.getRandom(a,!0):null,p=Kp(a.strength,this.parameters.randomness),h=ar(o.count,r),f=ar(o.size,r);if(o.useCenter===!0){let m={x:h[0]%2===0?2:1,y:h[1]%2===0?2:1,z:h[2]%2===0?2:1},y=new Je.Vector3(f[0]*(h[0]-m.x)*.5,f[1]*(h[1]-m.y)*.5,f[2]*(h[2]-m.z)*.5);for(let g=0;g<h[0];g++)for(let v=0;v<h[1];v++)for(let b=0;b<h[2];b++){let S=this.children[n++];if(!S)continue;let x=u===null?0:u.noise((g+1)*(a.freqScale/10)+a.movement,(v+1)*(a.freqScale/10)+a.movement,(b+1)*(a.freqScale/10)+a.movement);S.scale.x=1+p(n,ze(x,s[0]))||_n,S.scale.y=1+p(n,ze(x,s[1]))||_n,S.scale.z=1+p(n,ze(x,s[2]))||_n;let w=p(n,ze(x,l[0])),A=p(n,ze(x,l[1])),C=p(n,ze(x,l[2]));S.rotation.set(w,A,C),S.position.x=f[0]*g-y.x+p(n,ze(x,c[0])),S.position.y=f[1]*v-y.y+p(n,ze(x,c[1])),S.position.z=f[2]*b-y.z+p(n,ze(x,c[2]))}}else for(let m=0;m<h[0];m++)for(let y=0;y<h[1];y++)for(let g=0;g<h[2];g++){let v=this.children[n++];if(!v)continue;let b=u===null?0:u.noise((m+1)*(a.freqScale/10)+a.movement,(y+1)*(a.freqScale/10)+a.movement,(g+1)*(a.freqScale/10)+a.movement);v.scale.x=1+p(n,ze(b,s[0]))||_n,v.scale.y=1+p(n,ze(b,s[1]))||_n,v.scale.z=1+p(n,ze(b,s[2]))||_n;let S=p(n,ze(b,l[0])),x=p(n,ze(b,l[1])),w=p(n,ze(b,l[2]));v.rotation.set(S,x,w),v.position.x=f[0]*m+p(n,ze(b,c[0])),v.position.y=-f[1]*y+p(n,ze(b,c[1])),v.position.z=-f[2]*g+p(n,ze(b,c[2]))}}_updateToObject(e,r){if(e.type!=="toObject")throw new Error;let{toObject:n}=e,o=ar(n.rotation,r),a=ar(n.position,r),s=ar(n.scale,r),l=new Je.Euler(o[0],o[1],o[2]),c=e.randomnessObject??Do.defaultData([1,1,1]).randomnessObject,d=ar(c.rotation,r),u=ar(c.position,r),p=ar(c.scale,r),f=this.parameters.randomness===!0&&c.strength!==0?this.getRandom(c):null,m=Kp(c.strength,this.parameters.randomness);if(!n.object){for(let[,w]of this.children.entries())w.position.set(0,0,0),w.scale.setScalar(1),w.rotation.set(0,0,0);this.objectForSample=void 0,this.invalidateSurfaceCaches();return}if(!this.objectForSample)return;if(this.objectForSample instanceof Es)if(!this.objectForSample.font?.isLoaded||this.objectForSample.geometry.attributes.position===void 0){this._pendingMediaLoad=!0;return}else this._pendingMediaLoad=!1;if(this.objectForSample.geometry===void 0&&this.objectForSample.isAncestorOf(this.object.uuid)){console.warn(`Oh no! The object "${this.object.name}" (${this.object.uuid}) seem to be a child/descendant of the object it's being cloned to. Please re-parent it so that they are siblings instead.`);return}let y=this.getSubdivData();if(y.length>0){let w=Math.round(y.length*n.count/100);this._updateCount(r,w)}else{let w=this.objectForSample.geometry.getAttribute("position");if(!w||isNaN(w.count)||w.count===0){console.warn(`Oh no! The object "${this.object.name}" (${this.object.uuid}) cannot be cloned on the surface of "${this.objectForSample.name}" (${this.objectForSample.uuid}) because the latter does not have a valid geometry.`);return}}this.objectForSample.updateMatrixWorld();let g=n.spreadType==="random",v=null;g&&(v=this.getSurfaceSampler(),v.setRandomGenerator((0,Zy.default)(this.object.uuid+n.seed)));let b=K2[n.axis],S=this.children;Ts.fromArray(b),sO.copy(this.object.hiddenMatrix).invert();let x=this.objectForSample instanceof Na;x&&lO.copy(this.objectForSample.matrixWorld).invert(),n.align!=="normal"&&this.object.getWorldDirection(pO),kS.set(Ts.y,Ts.z,Ts.x).normalize(),fO.copy(kS).cross(Ts).normalize(),dO.makeBasis(kS,Ts,fO).invert();for(let[w,A]of S.entries()){let C=w*(c.freqScale/10)+c.movement,P=f===null?0:f.noise(C,C,C),M=w+1,B=m(M,ze(P,d[0])),I=m(M,ze(P,d[1])),_=m(M,ze(P,d[2]));g?v.sample(Zp,_S):(y.length&&(Zp.fromArray(y[w].pos),_S.fromArray(y[w].norm)),x&&Zp.applyMatrix4(lO)),Zp.applyMatrix4(sO),A.position.copy(Zp);let E=n.align==="normal"?_S:pO,R=Yy.fromArray(a);Yy.x+=m(M,ze(P,u[0])),Yy.y+=m(M,ze(P,u[1])),Yy.z+=m(M,ze(P,u[2]));let L=Math.acos(E.dot(Ts)),F=yV.crossVectors(Ts,E).normalize(),k=mV.makeRotationAxis(F,L);FS.copy(E).cross(this.object.up).normalize(),hO.copy(FS).cross(E).normalize(),cO.makeBasis(FS,E,hO),uO.multiplyMatrices(cO,dO),fo.setFromRotationMatrix(uO),R.applyMatrix4(k),A.position.add(R),A.rotation.set(fo.x+l.x+B,fo.y+l.y+I,fo.z+l.z+_),A.scale.set(1+s[0]+m(M,ze(P,p[0]))||_n,1+s[1]+m(M,ze(P,p[1]))||_n,1+s[2]+m(M,ze(P,p[2]))||_n),A.scale.multiply(this.object.scale),A.hiddenMatrix=this.object.hiddenMatrix}}getSurfaceSampler(){let e=this.objectForSample,r=e.geometry,n=r.getAttribute("position"),o=r.index,a=this.surfaceSamplerCache;if(a!==null&&a.geometry===r&&a.position===n&&a.positionVersion===Ky(n)&&a.index===o&&a.indexVersion===(o===null?-1:o.version))return a.sampler;let s=new jy(e).build();return this.surfaceSamplerCache={geometry:r,position:n,positionVersion:Ky(n),index:o,indexVersion:o===null?-1:o.version,sampler:s},s}invalidateSurfaceCaches(){this.surfaceSamplerCache=null,this.surfacePointsCache=null}getSubdivData(){if(!this.objectForSample)return[];let e=this.parameters.toObject.spreadType;if(e==="random")return[];let r=this.objectForSample instanceof Na,n=this.objectForSample.geometry;if(!r&&n){let l=this.surfacePointsCache,c=n.getAttribute("position");if(l!==null&&l.spreadType===e&&l.geometry===n&&l.position===c&&l.positionVersion===Ky(c)&&l.index===n.index&&l.indexVersion===(n.index===null?-1:n.index.version))return l.points}let o=new Map,a=(l,c)=>{let d=Math.round(l[0]*1e4)+"_"+Math.round(l[1]*1e4)+"_"+Math.round(l[2]*1e4),u=o.get(d);u?(u.pos[0]+=l[0],u.pos[1]+=l[1],u.pos[2]+=l[2],u.norm[0]+=c[0],u.norm[1]+=c[1],u.norm[2]+=c[2],u.count+=1):o.set(d,{pos:[...l],norm:[...c],count:1})};if(r){let l=this.objectForSample,c=Z2[e],d=gO[c],u=mO[c],p=yO[c],h=d(l.subdivPointerNew);for(let f=0;f<=h-1;f++){let m=u(l.subdivPointerNew,f),y=p(l.subdivPointerNew,f);iO.fromArray(m).applyMatrix4(l.matrixWorld),oO.fromArray(y),a(iO.toArray(),oO.toArray())}}else(n.index?J2(n):$2(n)).forEach((c,d)=>{e==="polygon_center"&&a(c.midpoint,c.norm),e==="vertex"&&(a(c.vertices[0],c.norm),a(c.vertices[1],c.norm),a(c.vertices[2],c.norm)),e==="edge"&&(a(c.faceCenters[0],c.norm),a(c.faceCenters[1],c.norm),a(c.faceCenters[2],c.norm))});let s=Array.from(o.values());for(let l of s)l.pos[0]/=l.count,l.pos[1]/=l.count,l.pos[2]/=l.count,l.norm[0]/=l.count,l.norm[1]/=l.count,l.norm[2]/=l.count;if(!r&&n){let l=n.getAttribute("position");this.surfacePointsCache={spreadType:e,geometry:n,position:l,positionVersion:Ky(l),index:n.index,indexVersion:n.index===null?-1:n.index.version,points:s}}return s}updateState(e,r){if(this.parameters=ys(e),this.parameters.type!=="toObject")this.invalidateSurfaceCaches(),(this.parent===null||this.parent!==this.object)&&(this.removeFromParent(),this.object.parent?.add(this),this.matrix=this.object.matrix,this.hiddenMatrix=this.object.hiddenMatrix,this.matrixWorldNeedsUpdate=!0,this.matrixAutoUpdate=!1);else if(this.parent===null||this.parent.uuid!==this.parameters.toObject.object){this.removeFromParent(),this.invalidateSurfaceCaches();let n=r.scene.find(this.parameters.toObject.object);n instanceof it?this.objectForSample=n:this.objectForSample=void 0,this.matrix=new Je.Matrix4,this.hiddenMatrix=new Je.Matrix4,this.matrixWorldNeedsUpdate=!0,this.matrixAutoUpdate=!1,n&&n.add(this)}this.update(r)}get pendingMediaLoad(){return this._pendingMediaLoad}};var mo=24,Br=96,Jo=LP(),La=2;var GS=!1,vO=!0;try{let i=new URLSearchParams(window.location.search);GS=i.get("dbgsbstatic")==="0",vO=i.get("sb512")!=="0"}catch{}function vV(i){let t=i.getAttribute("position");return t===void 0?-1:(t.version??t.data?.version??0)*1048576+(t.count??0)%1048576}var US=class extends tt{constructor(e,r,n){super(e,r,n);this.data=r;this.isShapeBlendEntity=!0;this.needsRebuild=!0;this.customDepthMaterialNeedsUpdate=!1;this._prevShapeData=null;this._prevSpan=-1;this._reach=new Float32Array(Br);this._prevReach=new Float32Array(Br);this._fieldDirtyFull=!0;this._fieldDirtyMin=new me.Vector3;this._fieldDirtyMax=new me.Vector3;this._maxBlendK=0;this._meshSdfBaked=new Map;this._meshSdfWanted=new Map;this._passesRenderer=null;this._npart=-1;this.spatialn=1;this.drawRangeNeedsForceUpdate=!0;this._resolutionLevel=-1;this._authoredResolutionLevel=-1;this.ultraFieldResolution=0;this.resolution=64;this.spatialDivisions=25;this.zLayersPerRow=8;this.basePyramidSize=512;this.pyramidTexture1Width=341;this.pyramidTexture1Height=256;this.pyramidTexture2Width=170;this.pyramidTexture2Height=128;this.numLevels=9;this.pyramidLevelSizes=[1,2,4,8,16,32,64,128,256,512];this.bboxSize=0;this.bboxOffset=0;this.shapesDataTexture={value:void 0};this.spatialscene=new me.Scene;this.potentialPassScene=new me.Scene;this.voxelPassScene=new me.Scene;this._spatialPassRenderTargets=[];this._potentialPassRenderTargets=[];this._voxelPassRenderTargets=[];this._pyramidRenderTargets=[];this.geometry=new me.BufferGeometry,this.geometry.drawRange.count=0,this.spatialPassUniforms={span:{value:-1},shapesDataTexture:this.shapesDataTexture,npart:{value:this.npart},spatialn:{value:this.spatialn}},this.spatialMesh=new me.Mesh(ed,this.spatialPassMaterial()),this.spatialMesh.frustumCulled=!1,this.spatialscene.add(this.spatialMesh);let o=new me.DataTexture(Jo.triTable,16,256,me.RedFormat,me.FloatType);o.needsUpdate=!0;let a=new me.DataTexture(Jo.numTrisTable,256,1,me.RedFormat,me.FloatType);a.needsUpdate=!0,this.voxelPassUniforms={potentialPassTexture:{value:void 0},numTrisTable:{value:a}},this.voxelMesh=new me.Mesh(ed,this.voxelPassMaterial()),this.voxelMesh.frustumCulled=!1,this.voxelPassScene.add(this.voxelMesh),this.potentialPassUniforms={shapesDataTexture:this.shapesDataTexture,spatialPassTexture:{value:void 0},npart:{value:this.npart},spatialn:{value:this.spatialn}},this.potentialMesh=new me.Mesh(ed,this.potentialPassMaterial()),this.potentialMesh.frustumCulled=!1,this.potentialPassScene.add(this.potentialMesh),this.marchPassUniforms={triTable:{value:o},potentialPassTexture:{value:void 0},voxelPassTexture:{value:void 0},pyramidTexture1:{value:void 0},pyramidTexture1Size:{value:void 0},pyramidTexture2:{value:void 0},pyramidTexture2Size:{value:void 0}},this.frustumCulled=!1,this.onBeforeShadowPass=s=>{let l=AV.call(this);if(this.npart===0){this.geometry.drawRange.count=0;return}let c=this.material.root;if(!c.shadersPatchedForShapeBlend)this.patchVertexShaderForShapeBlend(c),c.shadersPatchedForShapeBlend=!0,this.customDepthMaterialNeedsUpdate=!0;else if(this.customDepthMaterialNeedsUpdate){this.customDepthMaterialNeedsUpdate=!1,this.customDepthMaterial=new me.ShaderMaterial({vertexShader:c.vertexShader,fragmentShader:`
|
|
728
|
+
`&&o.push("")):t.getTextWidth(o[o.length-1]+a,i)>n&&(o[o.length-1].length&&o.push(""),t.getTextWidth(o[o.length-1]+a,i)>n&&(a.length===1?(o[o.length-1]+=a,a=""):(o[o.length-1]+=a.slice(0,-1),a=a[a.length-1],o.push(""))));return o[o.length-1]+=a,o}var Pt=require("three");var KM,Iy=new Promise(i=>{KM=i}),QM=!1;var Oy;function ZM(i){if(QM)return;if(Oy)return Oy;async function t(){let r=i??(!1?".":"https://cdn.spline.design/@splinetool/runtime@2.0.86/build"),o=import("./process.js"),[a,s]=await Promise.all([o,fetch(`${r}/process.wasm`).then(d=>d.arrayBuffer())]),l=a.default,c=await l({wasmBinary:s});KM(c),QM=!0}return Oy=t(),Oy}var JM=require("three"),Wk=new JM.Matrix4;function Dy(i,t){if(Object.keys(i.morphAttributes).length>0||Object.keys(t.morphAttributes).length>0)return!1;let e=Object.keys(i.attributes),r=Object.keys(t.attributes);if(e.length!==r.length)return!1;for(let l of r){let c=i.attributes[l],d=t.attributes[l];if(c===void 0||c.isInterleavedBufferAttribute===!0||d.isInterleavedBufferAttribute===!0||c.itemSize!==d.itemSize||c.normalized!==d.normalized||c.array.constructor!==d.array.constructor||c.array.length!==d.array.length)return!1}let n=i.index,o=t.index;if(n===null!=(o===null))return!1;let a=!1;if(n!==null&&o!==null){if(n.array.length!==o.array.length)return!1;let l=n.array.constructor,c=o.array.constructor;if(l!==c){if(l!==Uint32Array||c!==Uint16Array)return!1;a=!0}}if(i.groups.length!==t.groups.length)return!1;for(let l=0;l<t.groups.length;l++){let c=i.groups[l],d=t.groups[l];if(c.start!==d.start||c.count!==d.count||c.materialIndex!==d.materialIndex)return!1}for(let l of r){let c=i.attributes[l],d=t.attributes[l];c.array.set(d.array),c.needsUpdate=!0}let s=i.takeDepthStateFrom;if(typeof s=="function"&&s.call(i,t),n!==null&&o!==null){if(a){let l=n.array,c=o.array;for(let d=0,u=c.length;d<u;d++){let p=c[d];l[d]=p===65535?4294967295:p}}else n.array.set(o.array);n.needsUpdate=!0}return i.drawRange.start=t.drawRange.start,i.drawRange.count=t.drawRange.count,i.userData=t.userData,i.boundingBox=null,i.boundingSphere=null,!0}function jp(i,t,e,r){let n=i.position.array,o=i.normal.array,a=Wk.makeScale(t,e,r).invert().elements,s,l,c;for(let d=0,u=n.length;d<u;d+=3)n[d]*=t,n[d+1]*=e,n[d+2]*=r,s=o[d],l=o[d+1],c=o[d+2],o[d]=a[0]*s+a[4]*l+a[8]*c,o[d+1]=a[1]*s+a[5]*l+a[9]*c,o[d+2]=a[2]*s+a[6]*l+a[10]*c;i.position.needsUpdate=!0,i.normal.needsUpdate=!0}var Ry=new Pt.Box3,fd=new Pt.Vector3,Ae;Iy.then(i=>{Ae=i});var $M=new Float32Array([10,10,0,-10,10,0,-10,-10,0,10,-10,0]),e2=new Uint32Array([0,1,2,3]),t2=new Uint8Array([4]);function mS(i){let t=Number(i);return Number.isInteger(t)&&t>=0&&String(t)===i?t:-1}function qk(i){let t=Object.keys(i),e=0;for(let n of t){let o=mS(n);o>=e&&(e=o+1)}if(e===0||e>t.length)return;let r=new Array(e);for(let n=0;n<e;n++){let o=i[n];if(typeof o!="number")return;r[n]=o}return r}function By(i){if(i!=null){if(Array.isArray(i)||ArrayBuffer.isView(i)&&!(i instanceof DataView))return i;if(typeof i=="object")return qk(i)}}function uS(i){if(i==null)return"missing";if(Array.isArray(i))return`Array(${i.length})`;if(ArrayBuffer.isView(i)){let l=i;return`${i.constructor.name}(${l.length})`}if(typeof i!="object")return typeof i;let t=Object.keys(i),e=t.filter(l=>mS(l)===-1),r=0;for(let l of t){let c=mS(l);c>=r&&(r=c+1)}let n=i,o=-1,a=-1;for(let l=0;l<r;l++)l in n?typeof n[l]!="number"&&a===-1&&(a=l):o===-1&&(o=l);let s=[`${t.length} keys`,`max index ${r-1}`];return o!==-1&&s.push(`first missing index ${o}`),a!==-1&&s.push(`non-number at ${a} (${typeof n[a]})`),e.length&&s.push(`stray keys ${e.slice(0,3).join(",")}`),`Object{${s.join(", ")}}`}var Lt=class extends Pt.BufferGeometry{constructor(e,r){super();this.data=e;this.flatShading=r;this.subdivPointer=0;this.rebuild(),this.freeSubdivPointer()}mutateDirectlyScaleBaked(e,r){this.freeSubdivPointer();let n=this.data.scaleBaked.map(l=>typeof l=="number"?l:1),o=Ci.div(r.map(l=>typeof l=="number"?l:0),n);if(o.every(l=>l===1))return;this.subdividedGeometry&&jp(this.subdividedGeometry.attributes,...o),this.originalGeometry&&jp(this.originalGeometry.attributes,...o),this.data=e;let a=this.userData.parameters;this.userData.parameters={width:a.width*o[0],height:a.height*o[1],depth:a.depth*o[2]},this.originalGeometry.boundingSphere.center.multiply(fd.fromArray(o));let s=fd.set(a.width,a.height,a.depth).length();this.originalGeometry.boundingSphere.radius=s/2}ensureSubdivPointer(){return this.subdivPointer===0&&this.rebuild(),this.subdivPointer}mutateDirectlySubdivisions(e){this.freeSubdivPointer(),this.data=e;let r=e.phongAngle??35;this.flatShading&&(r=-1);let n=null;if(e.subdivisions>0){let a=0;try{a=Lt.allocate(e),n=Lt.buildRefined(a,e.subdivisions,r)}catch(s){console.error(s,e)}finally{a&&Lt.freeSubdivPointer(a)}}this.subdividedGeometry?.dispose(),this.subdividedGeometry=n??void 0,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=this.originalGeometry.boundingSphere);let o=this.userData.parameters;Object.assign(this,this.subdividedGeometry??this.originalGeometry),this.userData.parameters=o}rebuild(){let e,r,n;try{({originalGeometry:e,subdividedGeometry:r,subdivPointer:n}=Lt.build(this.data,void 0,!this.flatShading,void 0))}catch{e=new Pt.BoxGeometry(100,100,100),n=0}this.subdivPointer=n,this.originalGeometry=e,this.subdividedGeometry=r??void 0;let o=this.subdividedGeometry??this.originalGeometry;Object.assign(this,o),this.calcBoundingBox()}freeSubdivPointer(){this.subdivPointer&&(Lt.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0)}dispose(){super.dispose(),this.freeSubdivPointer()}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new Pt.Sphere,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let r=e.attributes.position,n=e.boundingSphere.center;Ry.setFromBufferAttribute(r),Ry.getCenter(n),e.boundingSphere.radius=n.distanceTo(Ry.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),Ry.getSize(fd);let o={width:fd.x,height:fd.y,depth:fd.z};return this.userData.parameters=o,o}static build(e,r,n,o){let a,s,l=e?.phongAngle??35;n===!1&&(l=-1),r&&(Ae.free_bvh(r),Ae.free_subdivision_surface(r));try{a=Lt.allocate(e,o)}catch(d){console.error(d,e),a=Lt.allocate({positionWASM:$M,indexWASM:e2,verticesPerFaceWASM:t2},o)}Ae.set_destination_refinement_level(a,0);let c=Lt.buildLevel(a,!0,l);return e.subdivisions>0?s=Lt.buildRefined(a,e.subdivisions,l):s=null,{subdivPointer:a,originalGeometry:c,subdividedGeometry:s}}static buildRefined(e,r,n){try{return Ae.set_destination_refinement_level(e,r),Lt.buildLevel(e,!1,n)??null}catch{try{return Ae.set_destination_refinement_level(e,r-1),Lt.buildLevel(e,!1,n)??null}catch{return null}}}static primitiveToQuads(e,r,n){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 o=e.shape!==void 0||e.path!==void 0?r.geometry:Li(e,n,!1,r),a;Hm(e)?a=o.getClosedTorusIndicesForBooleanOrSubdiv():a=o.getIndex();let{positions:s,triIndices:l,triOriginals:c}=Hp(o.getAttribute("position"),a),d;if(e.type==="CylinderGeometry"&&e.cornerRadius===0&&e.hollow===0&&e.openEnded===!1){let f=e.radialSegments*e.heightSegments*3*2,m=f+e.radialSegments*3;d=[f,m]}let{indices:u,verticesPerFace:p,uvs:h}=Xk(s,l,o,d,c);return{positions:s,indices:u,verticesPerFace:p,uvs:h}}static allocate(e,r){let n,o,a,s=[],l=[],c=By(e.positionWASM),d=By(e.indexWASM),u=By(e.verticesPerFaceWASM);if(c&&c.length>0){if(!d?.length||!u?.length)throw new Error(`SubdivGeometry.allocate: unusable cage topology \u2014 positionWASM ${uS(e.positionWASM)}, indexWASM ${uS(e.indexWASM)}, verticesPerFaceWASM ${uS(e.verticesPerFaceWASM)}`);n=c,o=d,a=u;let P=By(e.uvWASM);Ae.alloc_subdivision_surface_uvs&&P&&P.length===o.length*2&&(l=P)}else n=$M,o=e2,a=t2;let p=n.length,h=o.length,f=a.length,m=n.length+s.length+l.length,y=o.length+a.length,g=m*Float32Array.BYTES_PER_ELEMENT+y*Uint32Array.BYTES_PER_ELEMENT,v=m*Float32Array.BYTES_PER_ELEMENT,b=Ae._malloc(g);if(!b)throw new Error(`SubdivGeometry.allocate: wasm _malloc(${g}) failed`);let S=new Float32Array(Ae.HEAPF32.buffer,b,m),x=new Uint32Array(Ae.HEAPU32.buffer,b+v,y);S.set(n,0),S.set(s,n.length),S.set(l,n.length+s.length),x.set(o,0),x.set(a,o.length);let w;e?.scaleBaked?.some(P=>P!==1)&&(w=new Pt.Matrix4().makeScale(...e.scaleBaked.map(P=>typeof P=="number"?P:1))),r&&(w?w.premultiply(r):w=r);let A=b+(n.length+s.length)*Float32Array.BYTES_PER_ELEMENT,C=l.length?w?Ae.alloc_subdivision_surface_uvs2(b,p,b+v,h,b+v+o.length*Uint32Array.BYTES_PER_ELEMENT,f,A,l.length,w.elements):Ae.alloc_subdivision_surface_uvs(b,p,b+v,h,b+v+o.length*Uint32Array.BYTES_PER_ELEMENT,f,A,l.length):w?Ae.alloc_subdivision_surface2(b,p,b+v,h,b+v+o.length*Uint32Array.BYTES_PER_ELEMENT,f,w.elements):Ae.alloc_subdivision_surface(b,p,b+v,h,b+v+o.length*Uint32Array.BYTES_PER_ELEMENT,f);return Ae._free(b),C}static buildLevel(e,r,n,o,a,s=!1){let l=a?Ae.get_mesh_data2(e,r?Ae.Level.CONTROL:Ae.Level.REFINED,n,a.elements):Ae.get_mesh_data(e,r?Ae.Level.CONTROL:Ae.Level.REFINED,n),c=10,d=Ae.HEAPU32.subarray(l>>2,(l>>2)+c),u=d.subarray(4,4+4),p=0,h=Ae.HEAPU32[d[p]>>2],f=Ae.HEAPF32.subarray(h>>2,(h>>2)+u[p]);p++;let m=Ae.HEAPU32[d[p]>>2],y=Ae.HEAPF32.subarray(m>>2,(m>>2)+u[p]);p++;let g=Ae.HEAPU32[d[p]>>2],v=Ae.HEAPU32.subarray(g>>2,(g>>2)+u[p]);p++;let b=Ae.HEAPU32[d[p]>>2],S=Ae.HEAPU32.subarray(b>>2,(b>>2)+u[p]);p++;let x;if(Ae.alloc_subdivision_surface_uvs){let A=d[9];if(A>0){let C=Ae.HEAPU32[d[8]>>2];x=Ae.HEAPF32.subarray(C>>2,(C>>2)+A)}}if(o===void 0){let A=new Pt.BufferGeometry;if(A.setIndex(new Pt.Uint32BufferAttribute(S,1)),A.setAttribute("position",new Pt.Float32BufferAttribute(f,3)),A.setAttribute("normal",new Pt.Float32BufferAttribute(y,3)),x&&A.setAttribute("uv",new Pt.Float32BufferAttribute(x,2)),r){A.setAttribute("faceMap",new Pt.Uint32BufferAttribute(v,1));let C=new Float32Array(y.length/3*4).fill(0);A.setAttribute("color",new Pt.BufferAttribute(C,4))}return Ae.free_mesh_data(l),A.userData.type="SubdivGeometry",A}if(o.getAttribute("position").copyArray(f),o.getAttribute("normal").copyArray(y),o.attributes.position.needsUpdate=!0,o.attributes.normal.needsUpdate=!0,s){let A=o.getIndex();A!==null&&A.array.length===S.length&&(A.copyArray(S),A.needsUpdate=!0)}let w=o.getAttribute("uv");x&&w&&w.array.length===x.length&&(w.copyArray(x),w.needsUpdate=!0),Ae.free_mesh_data(l)}static freeSubdivPointer(e){Ae.free_bvh(e),Ae.free_subdivision_surface(e)}static buildControlCageWireframe(e,r,n){let o=Ae.get_wireframe_data_for_base_level(e),a=4,s=Ae.HEAPU32.subarray(o>>2,(o>>2)+a),l=s.subarray(2,2+2),c=0,d=Ae.HEAPU32[s[c]>>2],u=Ae.HEAPF32.subarray(d>>2,(d>>2)+l[c]);c++;let p=Ae.HEAPU32[s[c]>>2],h=Ae.HEAPU32.subarray(p>>2,(p>>2)+l[c]);if(r===void 0){let f=new Pt.BufferGeometry;f.setAttribute("position",new Pt.Float32BufferAttribute(u,3));let m=new Float32Array(u.length);for(let y=0,g=u.length;y<g;)m[y++]=n.r,m[y++]=n.g,m[y++]=n.b;return f.setAttribute("color",new Pt.BufferAttribute(m,3)),f.setIndex(new Pt.Uint32BufferAttribute(h,1)),Ae.free_wireframe_data_for_base_level(o),f}r.getAttribute("position").copyArray(u),r.attributes.position.needsUpdate=!0,Ae.free_wireframe_data_for_base_level(o)}static updateCollabMesh(e,r,n){let o=r===0;o||Ae.set_destination_refinement_level(e,r);let a=n?Ae.get_topological_data2(e,o?Ae.Level.CONTROL:Ae.Level.REFINED,n.elements):Ae.get_topological_data(e,o?Ae.Level.CONTROL:Ae.Level.REFINED),s=8,l=Ae.HEAPU32.subarray(a>>2,(a>>2)+s),c=l.subarray(3,3+3),d=0,u=Ae.HEAPU32[l[d]>>2],p=new Float32Array(Ae.HEAPF32.subarray(u>>2,(u>>2)+c[d]));d++;let h=Ae.HEAPU32[l[d]>>2],f=new Uint32Array(Ae.HEAPU32.subarray(h>>2,(h>>2)+c[d]));d++;let m=Ae.HEAPU32[l[d]>>2],y=new Uint8Array(Ae.HEAPU32.subarray(m>>2,(m>>2)+c[d])),g;if(Ae.alloc_subdivision_surface_uvs){let v=l[7];if(v>0){let b=Ae.HEAPU32[l[6]>>2];g=new Float32Array(Ae.HEAPF32.subarray(b>>2,(b>>2)+v))}}return Ae.free_topological_data(a),{positions:p,indices:f,verticesPerFace:y,uvs:g}}};function Ly(i){let t=Object.keys(i);return t.length===1&&t[0]==="subdivisions"}function Hp(i,t){let e=t?t.count:i.count,r=0,n=1e4,o=new Map,a=new Uint32Array(e),s=[];for(let d=0;d<e;d++){let u=t?t.getX(d):d,p=i.getX(u),h=i.getY(u),f=i.getZ(u),m=Math.round(p*n),y=Math.round(h*n),g=Math.round(f*n),v=o.get(m);v===void 0&&(v=new Map,o.set(m,v));let b=v.get(y);b===void 0&&(b=new Map,v.set(y,b));let S=b.get(g);S===void 0&&(S=r++,b.set(g,S),s.push(p,h,f)),a[d]=S}let l=[],c=[];for(let d=0;d<a.length;d+=3)a[d]===a[d+1]||a[d]===a[d+2]||a[d+1]===a[d+2]||(l.push(a[d],a[d+1],a[d+2]),c.push(t?t.getX(d):d,t?t.getX(d+1):d+1,t?t.getX(d+2):d+2));return{positions:s,triIndices:l,triOriginals:c}}var Ny=new Pt.Vector3,pS=new Pt.Vector3,hS=new Pt.Vector3,fS=new Pt.Vector3;function Xk(i,t,e,r,n){let o=[],a=[],s=n?e.getAttribute("uv"):void 0,l=s&&s.itemSize===2?[]:void 0,c=p=>{if(l){let h=n[p];l.push(s.getX(h),s.getY(h))}};if(e.userData.shape!==void 0&&e.userData.parameters.depth===0&&e.userData.shape.shapeHoles.length===0){let p=e.userData.shape.extractShapePointsToFlatArray([]),h=e.userData.parameters.spikes;if(e.userData.type==="EllipseGeometry"&&h<=24&&h%4===0&&e.userData.parameters.angle>=360){let y=p.length/2/h;p=p.filter((g,v)=>Math.floor(v/2)%y===0)}let f=0;for(let y=0;y<p.length;y+=2)f+=(p[y]-p[(y===0?p.length:y)-2])*(p[y+1]+p[(y===0?p.length:y)-1]);i.length=0;let m=0;if(f<0)for(let y=0;y<p.length;y+=2)i.push(p[y],p[y+1],0),o.push(m++);else for(let y=p.length-2;y>=0;y-=2)i.push(p[y],p[y+1],0),o.push(m++);return a.push(m),{indices:o,verticesPerFace:a}}let d=new Float32Array([e.userData.parameters.depth])[0],u=0;for(;u<t.length;){if(e.useNgonForTopBottomFaceDuringBake){let p=0;if((i[t[u]*3+2]===d||i[t[u]*3+2]===0)&&p++,(i[t[u+1]*3+2]===d||i[t[u+1]*3+2]===0)&&p++,(i[t[u+2]*3+2]===d||i[t[u+2]*3+2]===0)&&p++,p===3)break}if(t[u+1]===t[u+3]&&t[u+2]===t[u+5]||t[u+0]===t[u+3]&&t[u+2]===t[u+4]){Ny.set(i[t[u]*3],i[t[u]*3+1],i[t[u]*3+2]),pS.set(i[t[u+1]*3],i[t[u+1]*3+1],i[t[u+1]*3+2]),hS.set(i[t[u+4]*3],i[t[u+4]*3+1],i[t[u+4]*3+2]),fS.set(i[t[u+5]*3],i[t[u+5]*3+1],i[t[u+5]*3+2]),pS.sub(Ny).normalize(),hS.sub(Ny).normalize(),fS.sub(Ny).normalize();let p=pS.cross(hS).dot(fS),h=u;Math.abs(p)>.005||r&&r.some((f,m)=>m%2===1?!1:h>=r[m]&&h<r[m+1])?(o.push(t[u],t[u+1],t[u+2]),c(u),c(u+1),c(u+2),a.push(3),u+=3):(o.push(t[u],t[u+1],t[u+4],t[u+5]),c(u),c(u+1),c(u+4),c(u+5),a.push(4),u+=6)}else o.push(t[u],t[u+1],t[u+2]),c(u),c(u+1),c(u+2),a.push(3),u+=3}if(e.useNgonForTopBottomFaceDuringBake){let p=[],h=[],f=0;for(let m=0,y=0;m<i.length;m+=3,y++)i[m+2]===0&&(p.push(y),f++),i[m+2]===d&&h.push(y);if(e.userData.parameters.extrudeBevelSize===0){let m=h[0];h[0]=h[1],h[1]=m}p.reverse(),o.push(...p,...h),a.push(f,f),l=void 0}return{indices:o,verticesPerFace:a,uvs:l}}var Yk={ConeGeometry:QP,CubeGeometry:KP,CylinderGeometry:hy,DodecahedronGeometry:JP,EllipseGeometry:cd,HelixGeometry:$T,IcosahedronGeometry:BM,LatheGeometry:NM,NonParametricGeometry:LM,PolygonGeometry:Py,PyramidGeometry:_M,RectangleGeometry:ud,SphereGeometry:FM,PlaneGeometry:VM,BackdropGeometry:GM,StarGeometry:My,TextFrameGeometry:zM,TorusGeometry:jM,TorusKnotGeometry:WM,TriangleGeometry:qM,VectorGeometry:Qn},_y=i=>{let t=Yk[i.type]??Fm(i.type);if(t===void 0)throw new Error(`No geometry factory registered for "${i.type}" \u2014 was its feature compiled out of this runtime build?`);return t.create(i)};var Qk=["font"];function Li(i,t,e,r){let n,o,a;i.type==="PathGeometry"?(o={...i,extrusion:{...i.extrusion}},a=[[],["extrusion"]]):(o={...i},a=[[]]);for(let c of a){let d=o;for(let u of c)d=d[u];for(n in d){let u=d[n];Fx(u)&&!Qk.includes(n)&&(d[n]=t.getVariable(u,[r.uuid,"geometry",...c,n]),Fx(d[n])&&(d[n]=1))}}let s={parameters:o,type:o.type};if(o.type==="PathGeometry"){s.path=o.path;let c=r.profileShape;c!==void 0&&(s.shapeData=c),s.ownerId=r.uuid}else if(o.type==="VectorGeometry"){let c=ht.createFromState(o.shape,o.width,o.height);s.shape=c,s.ownerId=r.uuid}else if(o.type==="NonParametricGeometry"){if(o.data.groups&&o.data.groups?.forEach(c=>c.materialIndex=Math.max(c.materialIndex??0,0)),s.geometry=new r2.BufferGeometryLoader().parse(o),s.geometry.groups.length===0){let c=s.geometry;c.addGroup(0,Math.max(c.getIndex()?.count??0,c.getAttribute("position").count),0)}}else if(o.type==="SubdivGeometry"){let c=new Lt(o,e);return c.data=i,c}else if(o.type==="TextGeometry"||o.type==="InputGeometry"){let c=Fm(o.type);if(c)return c.create(o,t);vr("text",`a ${o.type}`);let d=ht.createFromState(hl.defaultData(),100,100);return _y({...o,shape:d,type:"VectorGeometry"})}else if(o.type==="UIGeometry")return ud.create({parameters:{width:o.width,height:o.height,cornerRadius:o.cornerRadius,cornerType:o.cornerType}});let l;try{l=_y(s)}catch(c){console.error(c),console.error(`Error generating geometry with inputs: ${s}`);let d=ht.createFromState(hl.defaultData(),100,100);s.shape=d,s.type="VectorGeometry",l=_y(s)}return l}var yS=class{constructor(){this.objects=new Map;this.unreachable=new Set}getCached(t){return this.objects.get(t)}get size(){return this.objects.size}get(t,e,r){let n=this.objects.get(t);return n===void 0?(n=this.createObject(t,e,r),this.objects.set(t,n)):n.isShared=!0,n}forceDelete(t){let e=this.objects.get(t);e&&(this.disposeObject(e),this.objects.delete(t))}adopt(t,e){this.objects.set(t,e)}mutateIfUnique(t,e){let r=this.objects.get(t);if(r&&r.isShared!==!0)return this.objects.delete(t),this.objects.set(e,r),r}startGc(){this.unreachable=new Set(this.objects.keys())}markAsReachable(t,e){let r=this.objects.get(t);e===r?this.unreachable.delete(t):!1&&console.warn("Reachable but deleted",t)}endGc(){this.unreachable.forEach(t=>{this.disposeObject(this.objects.get(t)),this.objects.delete(t)}),this.unreachable.clear()}dispose(){this.objects.forEach(t=>{this.disposeObject(t)}),this.objects.clear()}},Wp=class extends yS{constructor(e){super();this.flatShading=e}disposeObject(e){e.dispose()}createObject(e,r,n){let o=Li(e,r,this.flatShading,n);return o.computeBoundingSphere(),o}};var bS="webgl",n2,gS,i2=!1;function xS(){return bS}function a2(i){gS=i}function s2(){if(bS==="webgpu"){if(n2!==void 0)return n2;i2||(i2=!0,console.warn('[spe] Material backend is "webgpu" but no TSL material factory is registered \u2014 import spe/src/renderer/webgpu before creating materials. Falling back to WebGL materials.'))}if(gS===void 0)throw new Error('[spe] Classic (WebGL) materials are not available in this build \u2014 it was compiled WebGPU-only. Re-export the scene with renderer "Both" or "WebGL 2", or load the full runtime.');return gS}function Fy(i,t){return s2().createRootMaterial(i,t)}function SS(i,t,e){return s2().createSharedMaterial(i,t,e)}function wS(i){return i.getLayersOfType===void 0&&Object.assign(i,{layers:[],getLayersOfType:()=>[],hasAO:!1,assetsLoaded:()=>!0}),i}var o2,l2;function c2(i){l2=i}function d2(){let i=bS==="webgpu"&&o2!==void 0?o2:l2;return i===void 0?null:wS(i())}var vS;function u2(i){vS=i}function p2(i,t){return vS===void 0?!1:vS(i,t)}var h2={markNeedsUpdateRendererDirty:()=>{}};function zo(i,t){let e=0;if(!i.layers||i.layers.length===0)return!1;let r=i.layers?.find(n=>n.data.type==="light");if(r){let n=r.data,o=Number(t.getVariable(n.alphaOverride));if((typeof n.alphaOverride=="string"?o/100:n.alphaOverride)<1)return!0}for(let n of i.layers){if(n.data.type!=="displace"&&n.data.isMask)return!0;if(n.data.type!=="displace"&&"alpha"in n.data&&n.data.type!=="light"&&n.data.type!=="fresnel"&&n.data.type!=="cavity"&&n.data.type!=="dust"&&n.data.type!=="texture"&&n.data.type!=="matcap"&&n.data.type!=="rainbow"&&n.data.type!=="outline"&&n.data.type!=="pattern"){let o=n.data.visible?n.data.alpha:0;if(typeof o=="string"&&(o=Math.max(0,Math.min(1,Number(t.getVariable(o)??100)/100))),o===1&&n.data.type==="depth"||n.data.type==="gradient"){for(let a of n.data.colors)if(a[3]<1){o=a[3];break}}else if(o===1&&n.data.type==="noise"){let a=t.color(n.data.colorA).a,s=t.color(n.data.colorB).a,l=t.color(n.data.colorC).a,c=t.color(n.data.colorD).a,d=Math.min(a,Math.min(s,Math.min(l,c)));d<1&&(o=d)}e+=(1-e)*o}}return e<1}var _i=(i,t,e)=>Math.max(0,Math.min(1,Number(t.getVariable(typeof i=="number"?i*100:i,e)??100)/100))??1,he=(i,t,e)=>typeof i=="number"?i:t.getVariable(i,e);function AS(i){let t=typeof i=="string"?i:i.type;return t==="texture"||t==="video"||t==="displace_map"||t==="matcap"}function po(i){return typeof i=="string"||typeof i=="number"&&i!==0}var md={noise:["noiseType"],texture:["projection","axis","projectionAxis","side"],video:["projection","axis","projectionAxis","side"],displace:["noiseType"],light:["roughnessMap","bumpMap","roughnessMapChannel","metalnessMap","metalnessMapChannel","normalMap","aoMap","aoMapChannel","emissiveMap"],depth:["smooth","isWorldSpace","gradientType","isVector"],pattern:["style","projection","axis"],reflection:["tracingMode","mirror"]},f2={depth:["colors"],gradient:["colors","steps"],toon:["colors","steps"]};var m2=require("three");var CS=class extends Wc(m2.Object3D){},Kk=i=>i.type==="Mesh",Rr=class extends CS{constructor(e){super();this.object=e;this.isClone=!0;this.matrixAutoUpdate=!1,this.hasNonUniformScale=e.hasNonUniformScale}raycast(e,r){}expand(){let e=0,r=this.object.entityChildren(e);for(;r;){let n=this.children[e];n?.object!==r&&(n&&this.remove(n),n=new Rr(r),this.add(n),this.children.splice(e,0,this.children.pop()),n.matrixWorldNeedsUpdate=!0,n.matrixAutoUpdate=!1,n.matrix=r.matrix,n.hiddenMatrix=r.hiddenMatrix,n.pivotMatrix=r.pivotMatrix),n.expand(),e+=1,r=this.object.entityChildren(e)}for(;this.children.length>e;)this.remove(this.children[e]);this.pivotMatrix=this.object.pivotMatrix}get visible(){let e=this.object.cloner;return e!==void 0&&this.parent===e&&(e.instancingActive||e.insideBoolean)?!1: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 Kk(this.object)}get isLight(){return this.object.isLight}get layers(){return this.object.layers}set layers(e){}get isCamera(){return!1}get geometry(){if(this.object.geometry)return this.object.geometry}get material(){if(this.object.material)return this.object.material}get morphTargetInfluences(){if(this.object.morphTargetInfluences)return this.object.morphTargetInfluences}set morphTargetInfluences(e){}};gt();var pi=require("three");var y2=null,g2=null;function v2(i){y2=i}function ES(){return y2}function b2(i){g2=i}function x2(){return g2}function ky(i){return"variable_"+i}var S2=new pi.Matrix4,w2=new pi.Vector3,A2=new pi.Quaternion,$k=new pi.Vector3,C2=new pi.Euler,TS=class extends uy{constructor(e){super();this.shared=e}create(e){return new td(e,this.shared)}},E2=new Set;function eV(i,t){let e=`${i}/${t}`;E2.has(e)||(E2.add(e),console.warn(`[spline] updateObject: ignoring a geometry update of ${i} vertices for a mesh that holds ${t}. Without \`indices\` the write is taken as a morph of the mesh's own vertices, which only means anything at the same count \u2014 send \`indices\` alongside \`vertices\` to replace the topology too.`))}var PS=class{constructor(t,e={},r=!0,n=!1){this.data=t;this.needsJitter=r;this.enableLocalStorageForPersistentVariables=n;this.geometryCache=new Wp(!0);this.geometryCache2=new Wp(!1);this.imageHolderCache=new TS(this);this.thisContext={scene:h2,shared:this};this.deletedImage=new di(Mm.emptyImage,this);this.deletedVideo=new di(Mc.defaultVideo,this);this.materials={};this.images={};this.uiBuffers={};this.videos={};this.colors={};this.audios={};this.particles={};this.fonts={};this.variables={};this.userAPIs={};this.userWebhooks={};this.mouseProperty=null;this.raycastProperty=null;this.requestRender=()=>{this._requestRender&&this._requestRender()};this.transientGeometryKeys=new WeakSet;if(e.images)for(let[o,a]of Object.entries(e.images))this.addImage(o,a);if(e.videos)for(let[o,a]of Object.entries(e.videos))this.addVideo(o,a);if(e.audios)for(let[o,a]of Object.entries(e.audios))this.addAudio(o,a);if(e.particles)for(let[o,a]of Object.entries(e.particles))this.addParticle(o,a);this.reset(t)}get deletedMaterial(){return this._deletedMaterial??(this._deletedMaterial=SS(cr.defaultTwoLayerData("phong"),this.thisContext,"")),this._deletedMaterial}setRequestRender(t){this._requestRender=t}getImageLoadPromises(){return Object.values(this.images).map(t=>t.loadPromise)}setEntityOpContext(t){this.entityOpContext=t}reset(t,e=!1,r=!1){this.data=t,this.resetLib(t.lib);for(let{id:n,data:o}of t.variables)this.addVariableHolder(n,o),e&&this.updateVariableHolder(n,o);for(let[n,o]of Object.entries(t.userAPIs??{}))this.addUserAPI(n,o);for(let[n,o]of Object.entries(t.userWebhooks??{}))this.addUserWebhook(n,o);if(!r){for(let[n,o]of Object.entries(t.images))this.addImage(n,o);for(let[n,o]of Object.entries(t.videos))this.addVideo(n,o)}for(let[n,o]of Object.entries(t.colors))this.addColor(n,o);for(let[n,o]of Object.entries(t.lib.materials))this.addMaterial(n,o.asset);for(let[n,o]of Object.entries(t.materials))this.addMaterial(n,o);for(let[n,o]of Object.entries(t.audios))this.addAudio(n,o);for(let[n,o]of Object.entries(t.particles))this.addParticle(n,o);for(let[n,o]of Object.entries(t.fonts))this.addFont(n,o)}addMaterial(t,e){if(e.layers===void 0&&(e={...e,layers:cr.defaultTwoLayerData("phong").layers}),this.materials[t]){let r=this.materials[t];r.reset(e,this.thisContext),r.dispose()}else{let r=SS(e,this.thisContext,t);this.materials[t]=r}}deleteMaterial(t){this.materials[t]&&(this.materials[t].nodeMaterialDispose(),delete this.materials[t])}getMaterial(t){let e=this.materials[t];return e}getMaterialOrDeletedPlaceholder(t){return this.materials[t]??this.deletedMaterial}material(t){return typeof t=="string"?this.getMaterialOrDeletedPlaceholder(t):t==null?(console.error("material is undefined or null"),this.deletedMaterial):(t.layers===void 0&&(t={...t,layers:cr.defaultTwoLayerData("phong").layers}),Fy(t,this.thisContext))}getMaterials(){return this.materials}addImage(t,e){return this.images[t]?(this.onColorOrImageUpdate&&this.onColorOrImageUpdate(),this.images[t].updateSrc(e.data),!0):(this.images[t]=new di(e,this),!1)}deleteImage(t){let e=this.images[t];e&&(e.dispose(),delete this.images[t])}getDefaultImage(){return this.images.image_0}getImage(t){return this.images[t]??this.deletedImage}image(t){return typeof t=="string"?this.getImage(t):this.imageHolderCache.load(t)}addUIBuffer(t,e){return this.uiBuffers[t]?(this.onColorOrImageUpdate&&this.onColorOrImageUpdate(),this.uiBuffers[t].updateSrc(e),!0):(this.uiBuffers[t]=new di(e,this),!1)}uiBuffer(t){return this.uiBuffers[t]}getEntityTexture(t,e={}){let r=t.material;if(!r)return null;for(let n of Array.isArray(r)?r:[r]){let o=n.root??n;for(let a of o?.data?.layers??[]){let s=a?.data;if(s?.type!=="texture"&&s?.type!=="matcap"||e.layer!==void 0&&a.id!==e.layer&&s.type!==e.layer)continue;let l=s.texture?.image;if(l==null)continue;let c=(typeof l=="string"?this.uiBuffer(l):void 0)??this.image(l);if(!c)continue;let d=c.getTexture(s.texture.wrapping??(s.type==="texture"?1e3:1001),s.texture.minFilter??1008,s.texture.magFilter??1006),u=c.img;return{texture:d,width:u?.width??0,height:u?.height??0,layerId:a.id,layerType:s.type}}}return null}addVideo(t,e){return this.videos[t]?(this.videos[t].updateSrc(e.data),!0):(this.videos[t]=new di(e,this),!1)}deleteVideo(t){let e=this.videos[t];e&&(e.dispose(),delete this.videos[t])}getVideo(t){return this.videos[t]??this.deletedVideo}video(t){return typeof t=="string"?this.getVideo(t):this.imageHolderCache.load(t)}addColor(t,e){return this.colors[t]?(this.onColorOrImageUpdate&&this.onColorOrImageUpdate(),"a"in e?this.colors[t].setRGBA(e.r,e.g,e.b,e.a):this.colors[t].setRGBA(e.r,e.g,e.b,1),!0):("a"in e?this.colors[t]=new Oa(e.r,e.g,e.b,e.a):this.colors[t]=new Oa(e.r,e.g,e.b,1),!1)}updateColor(t,e){if(this.colors[t]){this.onColorOrImageUpdate&&this.onColorOrImageUpdate();let r=this.colors[t];return this.colors[t].r=e.r??r.r,this.colors[t].g=e.g??r.g,this.colors[t].b=e.b??r.b,this.colors[t].a=e.a??r.a,!0}return!1}deleteColor(t){this.colors[t]&&delete this.colors[t]}getColor(t){return this.colors[t]}getColorNames(){return Object.values(this.data.colors).map(t=>t.name)}getColorByName(t){for(let e in this.data.colors)if(this.data.colors[e].name===t)return{color:this.colors[e],id:e}}color(t){let e;if(typeof t=="string"){let r=this.getColor(t);r?e=r:(console.warn("Tried to create color layer params with a color key that does not exist in the assets manager"),e=new Ut(0,0,0,0))}else return"a"in t?new Ut(t.r,t.g,t.b,t.a):new Ut(t.r,t.g,t.b,1);return e}addAudio(t,e){this.audios[t]=e}getAudio(t){let e=this.audios[t];if(e instanceof Da)return e;{let r=new Da({src:e.data});return this.audios[t]=r,r}}addParticle(t,e){this.particles[t]=e}getParticle(t){return this.particles[t]}deleteParticle(t){this.particles[t]&&delete this.particles[t]}deleteAudio(t){let e=this.audios[t];e&&(e instanceof Da&&e.dispose(),delete this.audios[t])}addFont(t,e){let r=XP();if(r===null){vr("text","a font asset");return}this.fonts[t]=new r(e),this.fonts[t].loadingPromise.then(()=>this.requestRender())}getFont(t){return this.fonts[t]}deleteFont(t){this.fonts[t]&&delete this.fonts[t]}dispose(){Object.keys(this.materials).forEach(e=>this.deleteMaterial(e)),this._requestRender=void 0,Object.values(this.audios).forEach(e=>{e instanceof Da&&e.dispose()}),this.audios={},this.particles={},this.geometryCache.dispose(),this.geometryCache2.dispose()}addVariableHolder(t,e){if(this.variables[t]===void 0){let r=e.value;if(this.enableLocalStorageForPersistentVariables&&e.persistent){let n=localStorage.getItem(ky(t));r=n!==null?JSON.parse(n):e.value}return this.variables[t]={value:r,locations:[],persistent:e.persistent},"dynamicVariableType"in e&&(this.variables[t].dynamicVariablePlayState="Playing",this.variables[t].dynamicVariableToggleIsForward=void 0),!0}return this.variables[t].value=e.value,!1}resetDynamicVariablePlayState(){for(let t in this.variables)this.variables[t].dynamicVariablePlayState!==void 0&&(this.variables[t].dynamicVariablePlayState="Playing",this.variables[t].dynamicVariableToggleIsForward=void 0)}updateVariableHolder(t,e){this.updateVariable(t,e.value)}updateVariable(t,e){if(this.variables[t]===void 0)return!1;this.variables[t].value=e,this.enableLocalStorageForPersistentVariables&&this.variables[t].persistent&&localStorage.setItem(ky(t),JSON.stringify(e));let r=e;for(;typeof r=="string";)r=this.variables[r].value;let n=this.entityOpContext.scene,o=!1;for(let a=this.variables[t].locations.length-1;a>=0;a--){let s=this.variables[t].locations[a];if(s[0]==="material"){let l=s[1],c=r,d={scene:n,shared:this},u=s.slice(2);n.traverseMaterial(h=>{let f=h.root??h;f.uuid===l&&f.onVariableUpdate(u,c,d)});let p=this.materials[l];p&&p.onVariableUpdate(u,c,d)}else{let l=n.find(s[0]);if(l===void 0){this.variables[t].locations.splice(a,1);continue}if(o=!0,s[1]!=="geometry"&&s[1]!=="particles"){for(let c=1;c<s.length-1;c++)l=l[s[c]];s[1]==="rotation"?l[s[s.length-1]]=r*pi.MathUtils.DEG2RAD:l[s[s.length-1]]=r}if(l=n.find(s[0]),l.type==="ParticleEmitter"&&l.updateVariableState(r,s),Le.is(l))if(s[1]==="position"||s[1]==="rotation"||s[1]==="scale")l.onVariableUpdate();else if(s[1]==="geometry"){let c=l;l.component&&(c=l.component);let d=c.dataPatched;c.chooseGeoemtryCache(this).forceDelete(d.geometry),c.createGeometryDelayed(this.entityOpContext),c.onVariableUpdate(!0),c.invalidateDownstreamBooleanData(),c.instances.forEach(u=>{let p=u.dataPatched;u.chooseGeoemtryCache(this).forceDelete(p.geometry),u.createGeometryDelayed(this.entityOpContext),u.onVariableUpdate(!0),u.invalidateDownstreamBooleanData()})}else s[1]==="morphTargetInfluences"&&l.updateMorphInfluences(s[2],r)}}return o&&n.markShadowsDirty(),this.requestRender(),!0}updateEntityGeometryParams(t,e){let r=t;if(r.component&&(r=r.component),typeof r.chooseGeoemtryCache!="function")return!1;let n=r.dataPatched,o=n?.geometry;if(!o||typeof o.type!="string"||o.type==="VectorGeometry"||o.type==="PathGeometry")return!1;let a=d=>d.toLowerCase().replace(/[\s_.-]+/g,""),s=new Map;for(let d of Object.keys(o))s.set(a(d),d);let l={};for(let[d,u]of Object.entries(e??{})){let p=s.get(a(d));if(p===void 0||p==="type"||p==="font"||p==="shape"||p==="path"||p==="data")continue;if(p==="text"){(typeof u=="string"||typeof u=="number")&&(l[p]={textValue:String(u)});continue}let h=o[p];typeof u=="number"&&isFinite(u)&&(typeof h=="number"||typeof h=="string")&&(l[p]=u)}if(Object.keys(l).length===0)return!1;let c={...o,...l};return r.dataPatched={...n,geometry:c},this.transientGeometryKeys.has(o)&&r.chooseGeoemtryCache(this).forceDelete(n.geometry),this.transientGeometryKeys.add(c),r.createGeometryDelayed(this.entityOpContext),r.onVariableUpdate(!0),r.invalidateDownstreamBooleanData(),this.entityOpContext.scene.markShadowsDirty(),this.requestRender(),!0}resetEntityGeometryParams(t){let e=t;if(e.component&&(e=e.component),typeof e.chooseGeoemtryCache!="function")return!1;let n=e.dataPatched?.geometry;return!n||!this.transientGeometryKeys.has(n)?!1:(e.dataPatched=e.data,e.chooseGeoemtryCache(this).forceDelete(n),e.createGeometryDelayed(this.entityOpContext),e.onVariableUpdate(!0),e.invalidateDownstreamBooleanData(),this.entityOpContext.scene.markShadowsDirty(),this.requestRender(),!0)}updateEntityGeometryVertices(t,e){let r=t;if(r.component&&(r=r.component),typeof r.chooseGeoemtryCache!="function")return!1;let n=r.dataPatched,o=n?.geometry;if(!o||o.type!=="NonParametricGeometry")return!1;let a=e?.vertices;if(a===void 0||typeof a.length!="number"||a.length<9||a.length%3!==0||a.length/3>PS.MAX_TRANSIENT_VERTICES)return!1;let s=a instanceof Float32Array?a:Float32Array.from(a),l=s.length/3,c;if(e.normals!==void 0){if(e.normals.length!==s.length)return!1;c=e.normals instanceof Float32Array?e.normals:Float32Array.from(e.normals)}let d;if(e.uvs!==void 0){if(e.uvs.length!==l*2)return!1;d=e.uvs instanceof Float32Array?e.uvs:Float32Array.from(e.uvs)}let u;if(e.indices!==void 0){let w=l>65535?Uint32Array.from(e.indices):Uint16Array.from(e.indices);if(w.length===0||w.length%3!==0)return!1;for(let A=0;A<w.length;A++)if(w[A]>=l)return!1;u={array:w,itemSize:1,type:w.constructor.name,normalized:!1}}else{let w=o.data,A=w?.index;if(A?.array?.length){let C=(w?.attributes?.position?.array?.length??0)/3;if(l!==C)return eV(l,C),!1;u=A}}let p=1/0,h=1/0,f=1/0,m=-1/0,y=-1/0,g=-1/0;for(let w=0;w<s.length;w+=3){let A=s[w],C=s[w+1],P=s[w+2];A<p&&(p=A),A>m&&(m=A),C<h&&(h=C),C>y&&(y=C),P<f&&(f=P),P>g&&(g=P)}let v=(w,A)=>({array:w,itemSize:A,type:"Float32Array",normalized:!1}),b={position:v(s,3)};c&&(b.normal=v(c,3)),d&&(b.uv=v(d,2));let S={...o,width:m-p,height:y-h,depth:g-f,data:{attributes:b,...u?{index:u}:{}}},x=this.transientGeometryKeys.has(o);return r.dataPatched={...n,geometry:S},this.transientGeometryKeys.add(S),r.applyTransientGeometryData(this.entityOpContext,x),r.onVariableUpdate(!0),r.invalidateDownstreamBooleanData(),this.entityOpContext.scene.markShadowsDirty(),this.requestRender(),!0}setEntityInstanceTransforms(t,e){let r=t;r.component&&(r=r.component);let n=r.cloner;if(n===void 0)return-1;let o=n.children,a=Math.PI/180,s=!1;if(e===null)for(let l of o)l.transformOverride!==void 0&&(l.transformOverride=void 0,s=!0);else if(Array.isArray(e)){let l=Math.min(e.length,o.length);for(let c=0;c<l;c++){let d=e[c],u=o[c];if(d==null){u.transformOverride!==void 0&&(u.transformOverride=void 0,s=!0);continue}let p=u.transformOverride??{position:[u.position.x,u.position.y,u.position.z],rotation:[u.rotation.x,u.rotation.y,u.rotation.z],scale:[u.scale.x,u.scale.y,u.scale.z]};d.position&&(typeof d.position.x=="number"&&(p.position[0]=d.position.x),typeof d.position.y=="number"&&(p.position[1]=d.position.y),typeof d.position.z=="number"&&(p.position[2]=d.position.z)),d.rotation&&(typeof d.rotation.x=="number"&&(p.rotation[0]=d.rotation.x*a),typeof d.rotation.y=="number"&&(p.rotation[1]=d.rotation.y*a),typeof d.rotation.z=="number"&&(p.rotation[2]=d.rotation.z*a)),d.scale&&(typeof d.scale.x=="number"&&(p.scale[0]=d.scale.x),typeof d.scale.y=="number"&&(p.scale[1]=d.scale.y),typeof d.scale.z=="number"&&(p.scale[2]=d.scale.z)),u.transformOverride=p,u.position.fromArray(p.position),u.rotation.fromArray(p.rotation),u.scale.fromArray(p.scale),u.updateMatrix(),u.hasNonUniformScale&&(u.updateMatrixWorld(),u.updateMatrixWorldRigid())}}else return o.length;return s?n.update(this.entityOpContext):n.syncInstanceMatrices(),n.invalidateTransform(r),this.entityOpContext.scene.markShadowsDirty(),this.requestRender(),o.length}spawnRuntimeClone(t,e={}){if(typeof t.entityChildren!="function")return;let r=t.parent;if(r===null)return;let n=new Rr(t);n.playModeVisible=e.visible!==!1,n.expand(),typeof e.name=="string"&&(n.name=e.name);let o=Math.PI/180;return n.position.copy(t.position),n.rotation.copy(t.rotation),n.scale.copy(t.scale),n.hiddenMatrix.copy(t.hiddenMatrix),e.position&&(typeof e.position.x=="number"&&(n.position.x=e.position.x),typeof e.position.y=="number"&&(n.position.y=e.position.y),typeof e.position.z=="number"&&(n.position.z=e.position.z)),e.rotation&&(typeof e.rotation.x=="number"&&(n.rotation.x=e.rotation.x*o),typeof e.rotation.y=="number"&&(n.rotation.y=e.rotation.y*o),typeof e.rotation.z=="number"&&(n.rotation.z=e.rotation.z*o)),e.scale&&(typeof e.scale.x=="number"&&(n.scale.x=e.scale.x),typeof e.scale.y=="number"&&(n.scale.y=e.scale.y),typeof e.scale.z=="number"&&(n.scale.z=e.scale.z)),n.updateMatrix(),r.add(n),n.updateWorldMatrix(!0,!0),this.entityOpContext.scene.markShadowsDirty(),this.requestRender(),n}destroyRuntimeClone(t){t.removeFromParent(),this.entityOpContext.scene.markShadowsDirty(),this.requestRender()}updateEntityMaterialParams(t,e){let r=t.material;if(!r)return!1;let n=[];for(let d of Array.isArray(r)?r:[r]){let u=d.root??d;u&&Array.isArray(u.layers)&&u.data&&!n.includes(u)&&n.push(u)}if(n.length===0)return!1;let o={scene:this.entityOpContext.scene,shared:this},a=d=>d.toLowerCase().replace(/[\s_.-]+/g,""),s=d=>{if(typeof d=="string"){let u=new Ut(1,1,1,1);try{u.set(d)}catch{return null}return{r:u.r,g:u.g,b:u.b,a:void 0}}if(d&&typeof d=="object"&&"r"in d){let u=d;if([u.r,u.g,u.b].some(h=>typeof h!="number"||!isFinite(h)))return null;let p=Math.max(u.r,u.g,u.b)>1?1/255:1;return{r:u.r*p,g:u.g*p,b:u.b*p,a:typeof u.a=="number"?Math.max(0,Math.min(u.a,1)):void 0}}return null},l=(d,u,p)=>{if(!d.hasValue(u))return!1;let h=d.getValue(u);if(!h||typeof h!="object"||!h.isColor)return!1;let f=p.a??(typeof h.a=="number"?h.a:1);return h instanceof Oa?d.setValue(u,new Ut(p.r,p.g,p.b,f)):typeof h.setRGBA=="function"?h.setRGBA(p.r,p.g,p.b,f):h.setRGB(p.r,p.g,p.b),!0},c=!1;for(let d of n){let u=d.data.layers??[],p=h=>d.layers.find(f=>f.uuid===h);if(e.color!==void 0){let h=s(e.color),f=u.find(y=>y.data.type==="color"),m=f&&p(f.id);if(h&&m&&l(m,"color",h)&&(c=!0,h.a!==void 0)){let y=h.a<1?!0:zo(d.data,this);d.setTransparent?d.setTransparent(y,o.scene):d.transparent=y}}typeof e.alpha=="number"&&isFinite(e.alpha)&&(d.onVariableUpdate?.(["alphaOverride"],Math.max(0,Math.min(e.alpha,100)),o),c=!0);for(let h of e.layers??[]){if(!h||typeof h!="object")continue;let f=typeof h.id=="string"?u.find(v=>v.id===h.id):typeof h.index=="number"?u[h.index]:typeof h.type=="string"?u.find(v=>v.data.type===h.type):void 0,m=f&&p(f.id);if(!f||!m)continue;let y=md[f.data.type]??[],g=Object.keys(f.data);for(let[v,b]of Object.entries(h)){if(v==="id"||v==="index"||v==="type")continue;let S=g.find(w=>w===v)??g.find(w=>a(w)===a(v))??v;if(y.includes(S))continue;let x=s(b);if(x&&l(m,S,x)){c=!0;continue}if(typeof b=="number"&&isFinite(b))d.onVariableUpdate?.(["layer",f.id,S],b,o),c=!0;else if(Array.isArray(b)&&b.length<=3&&b.every(w=>typeof w=="number"&&isFinite(w))){let w=["x","y","z"];b.forEach((A,C)=>{d.onVariableUpdate?.(["layer",f.id,S,w[C]],A,o)}),c=!0}}}}return c&&this.requestRender(),c}deleteVariable(t){this.variables[t]&&delete this.variables[t]}getVariable(t,e){if(Array.isArray(t)){if(t[0]==="mouse")return this.mouseProperty?.[t[1]]??0;if(t[0]==="raycast")return this.raycastProperty?.[t[1]]??0;let r=this.entityOpContext.scene.find(t[0]);if(t[1]==="width"||t[1]==="height"||t[1]==="depth")return r.geometry.userData.parameters[t[1]];if((t[1]==="position"||t[1]==="rotation")&&t.length>2&&r?.getPhysicsLocalMatrix?.(S2))return S2.decompose(w2,A2,$k),t[1]==="position"?w2[t[2]]:(C2.setFromQuaternion(A2,r.rotation.order),C2[t[2]]*pi.MathUtils.RAD2DEG);for(let n=1;n<t.length;n++)r=r[t[n]];return t[1]==="rotation"&&(r*=pi.MathUtils.RAD2DEG),r}for(let r in this.variables){if(e===void 0)break;let n=this.variables[r],o=n.locations?.findIndex(a=>jt.equal(a,e));o!==void 0&&o!==-1&&n.locations.splice(o,1)}if(typeof t=="string"){let r=t,n=t;do{if(n=r,this.variables[r]===void 0)break;let o=this.variables[r].value;e&&this.variables[n]!==void 0&&this.variables[n].locations.push(e),r=o}while(typeof r=="string");return r}else return t}getVariables(){return this.variables}getVariablesNames(){return this.data.variables.map(t=>t.data.name)}getVariableByName(t){for(let e of this.data.variables)if(e.data.name===t)return{variable:e.data,id:e.id}}getDynamicVariablePlayState(t){return this.variables[t]?.dynamicVariablePlayState}setDynamicVariablePlayState(t,e){this.variables[t]!==void 0&&(this.variables[t].dynamicVariablePlayState=e)}getDynamicVariableToggleIsForward(t){return this.variables[t]?.dynamicVariableToggleIsForward}setDynamicVariableToggleIsForward(t,e){this.variables[t]!==void 0&&(this.variables[t].dynamicVariableToggleIsForward=e)}resetLib(t){for(let[e,r]of Object.entries(t.images))this.addImage(e,r.asset);for(let[e,r]of Object.entries(t.audios))this.addAudio(e,r.asset);for(let[e,r]of Object.entries(t.particles))this.addParticle(e,r.asset);for(let[e,r]of Object.entries(t.colors))this.addColor(e,r.asset);for(let[e,r]of Object.entries(t.fonts))this.addFont(e,r.asset);for(let[e,r]of Object.entries(t.videos))this.addVideo(e,r.asset);for(let[e,r]of Object.entries(t.variables))this.addVariableHolder(e,r.asset)}updateLibByOp(t,e){t.path[0]==="images"?t.path.length===1&&t.type===1?this.addImage(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteImage(t.id):t.path[0]==="videos"?t.path.length===1&&t.type===1?this.addVideo(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteVideo(t.id):t.path[0]==="audios"?t.path.length===1&&t.type===1?this.addAudio(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteAudio(t.id):t.path[0]==="particles"?t.path.length===1&&t.type===1?this.addParticle(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteParticle(t.id):t.path[0]==="colors"?t.path.length===1&&t.type===1?this.addColor(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteColor(t.id):t.path[0]==="materials"?t.path.length===1&&t.type===1?this.addMaterial(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteMaterial(t.id):t.path[0]==="fonts"?t.path.length===1&&t.type===1?this.addFont(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteFont(t.id):t.path[0]==="variables"?t.path.length===1&&t.type===1?this.addVariableHolder(t.id,t.data.asset):t.path.length===1&&t.type===2&&this.deleteVariable(t.id):t.path[0]==="components"&&e.updateByLibOp(t,this)}updateByOp(t,e,r){if(this.data=e,t.path[0]==="images")t.path.length===2&&t.type===0?t.props.data&&this.getImage(t.path[1]).updateSrc(t.props.data):t.path.length===1&&t.type===1?this.addImage(t.id,t.data):t.path.length===1&&t.type===2&&this.deleteImage(t.id);else if(t.path[0]==="videos")t.path.length===2&&t.type===0?t.props.data&&this.getVideo(t.path[1]).updateSrc(t.props.data):t.path.length===1&&t.type===1?this.addVideo(t.id,t.data):t.path.length===1&&t.type===2&&this.deleteVideo(t.id);else if(t.path[0]==="audios")t.path.length===2&&t.type===0?t.props.data&&this.addAudio(t.path[1],e.audios[t.path[1]]):t.path.length===1&&t.type===1?this.addAudio(t.id,t.data):t.path.length===1&&t.type===2&&this.deleteAudio(t.id);else if(t.path[0]==="particles")t.path.length===2&&t.type===0?t.props.data&&this.addParticle(t.path[1],e.particles[t.path[1]]):t.path.length===1&&t.type===1?this.addParticle(t.id,t.data):t.path.length===1&&t.type===2&&this.deleteParticle(t.id);else if(t.path[0]==="colors")t.path.length===2&&t.type===0?this.updateColor(t.path[1],t.props):t.path.length===1&&t.type===1?this.addColor(t.id,t.data):t.path.length===1&&t.type===2&&this.deleteColor(t.id);else if(t.path[0]==="materials")t.path.length===1&&t.type===1?this.addMaterial(t.id,t.data):t.path.length===1&&t.type===2?this.deleteMaterial(t.id):t.path.length>1&&this.getMaterial(t.path[1]).updateByOp(or.drop(t,2),e.materials[t.path[1]],{shared:this,scene:r});else if(t.path[0]==="fonts")t.path.length===2&&t.type===0?this.updateFont(t.path[1],t,r):t.path.length===1&&t.type===1?this.addFont(t.id,t.data):t.path.length===1&&t.type===2&&this.deleteFont(t.id);else if(t.path[0]==="variables")t.path.length===2&&t.type===0?"value"in t.props?this.updateVariable(t.path[1],t.props.value):"persistent"in t.props&&(this.variables[t.path[1]].persistent=t.props.persistent):t.path.length===1&&t.type===4?this.addVariableHolder(t.id,t.data):t.path.length===1&&t.type===5&&this.deleteVariable(t.id);else if(t.path[0]==="userAPIs"){if(t.path.length===1&&t.type===1)this.addUserAPI(t.id,t.data);else if(t.path.length===1&&t.type===2)this.deleteUserAPI(t.id);else if(typeof t.path[1]=="string"){let n=e.userAPIs[t.path[1]];if(n){let o=t.type===0&&t.props.debounce===void 0,a=this.getUserAPI(t.path[1]);a!==void 0&&a===this.openAIRealtime?a.update(n):a?.update(n,this,o)}}}else if(t.path[0]==="userWebhooks"){if(t.path.length===1&&t.type===1)this.addUserWebhook(t.id,t.data);else if(t.path.length===1&&t.type===2)this.deleteUserWebhook(t.id);else if(typeof t.path[1]=="string"){let n=e.userWebhooks[t.path[1]];n&&this.getUserWebhook(t.path[1])?.update(n)}}else t.path[0]==="lib"&&this.updateLibByOp(or.drop(t,1),r)}updateFont(t,e,r){if(e.props.url){let n=this.getFont(t),o={...this.data.fonts[t],url:e.props.url};n.update(o),n.loadingPromise.then(()=>this.requestRender()),r.updateFont(t,this)}}addUserAPI(t,e){if(this.userAPIs[t])return this.userAPIs[t].update(e,this),!0;if(this.openAIRealtime?.id===t)return this.openAIRealtime.update(e),!0;if(e.integration?.type==="VoiceAssistant"){let r=x2();return r===null?(vr("ai-assistant","a voice-assistant integration"),!1):(this.openAIRealtime=r(e,t,this),!1)}else{let r=ES();return r===null?(vr("api-services","a user API integration"),!1):(this.userAPIs[t]=r.createUserAPI(t,e,this),!1)}}getUserAPI(t){return this.openAIRealtime?.id===t?this.openAIRealtime:this.userAPIs[t]}getUserAPIs(){return this.userAPIs}deleteUserAPI(t){let e=this.userAPIs[t];e&&(e.dispose(),delete this.userAPIs[t])}addUserWebhook(t,e){if(this.userWebhooks[t])return this.userWebhooks[t].update(e),!0;{let r=ES();return r===null?(vr("api-services","a user webhook"),!1):(this.userWebhooks[t]=r.createUserWebhook(t,e),!1)}}getUserWebhook(t){return this.userWebhooks[t]}getUserWebhooks(){return this.userWebhooks}deleteUserWebhook(t){let e=this.userWebhooks[t];e&&(e.dispose(),delete this.userWebhooks[t])}get scene(){return this.entityOpContext.scene}},As=PS;As.MAX_TRANSIENT_VERTICES=6e4;var P2=new As(Bn.emptyData());function Ll(i){return i?.isClassicNodeMaterial===!0}function M2(i){return i?.isClassicSharedMaterial===!0}function Vy(i){return Ll(i)||i?.isTSLNodeMaterial===!0}function O2(i){return M2(i)||i?.isTSLSharedMaterial===!0}gt();mr();var Ln=5,yd=3;var I2=.98;var xr=class extends it{setMaterialOverride(e,r){this.materialOverride=wS(e),this.material!==this.shadowCatcherMaterial&&(this.disposeMaterial(),this.material=this.materialOverride,this.layers.set(0),this.syncShapeBlendNodeLayer(),r.scene.markNeedsUpdateRendererDirty())}updateByPatchedOp(e,r,n){if(super.updateByPatchedOp(e,r,n),Ye(e.path,["geometry"])&&this.syncShadowCatcher(n),iC(e.path,["materials"])!==null&&e.type===0&&Array.isArray(this.material))for(let[o,a]of Object.entries(e.props)){let s=this.material[Number(o)],l=n.shared.material(a);l!==s&&xr.disposeOneMaterial(s),this.material[Number(o)]=l}else if(Ye(e.path,["material"])){let o=this.material;!Array.isArray(o)&&typeof o?.updateByOp=="function"&&"material"in r&&typeof r.material!="string"&&o.updateByOp(or.drop(e,1),r.material,n)}else if(Ye(e.path,["materials","*"])&&Array.isArray(this.material)){let o=e.path[1];if("materials"in r&&o<this.material.length){let a=r.materials[o];typeof a!="string"&&this.material[o].updateByOp(or.drop(e,2),a,n)}}}get needsAO(){return this.material!==void 0?(Array.isArray(this.material)?this.material[0]:this.material).hasAO:!1}syncShapeBlendNodeLayer(){this.dataPatched.type==="Mesh"&&!!this.dataPatched.geometry.shapeBlendNode?this.layers.set(9):(this.layers.mask&1<<9)!==0&&this.layers.set(0)}updateState(e,r){super.updateState(e,r),e.castShadow!==void 0&&(this.castShadow=e.castShadow),e.receiveShadow!==void 0&&(this.receiveShadow=e.receiveShadow);let n=this.dataPatched;this.syncShapeBlendNodeLayer();let o;this.dataPatched.type==="Mesh"&&this.dataPatched.geometry.type==="ShapeBlendGeometry"&&(o={resolutionLevel:Math.min(8,this.dataPatched.geometry.resolutionLevel),useChildrenColors:this.dataPatched.geometry.useChildrenColors});let a=this.materialOverride!==void 0;!a&&e.geometry?.type!=="NonParametricGeometry"&&"material"in e&&e.material!==void 0&&(this.disposeMaterial(),this.material=r.shared.material(e.material).getFlavor(n.flatShading,n.side,n.wireframe,o),r.scene.markNeedsUpdateRendererDirty()),!a&&(e.geometry?.type==="NonParametricGeometry"||"materials"in e)&&("materials"in e&&e.materials!==void 0?(this.disposeMaterial(),this.material=e.materials.map(l=>r.shared.material(l).getFlavor(n.flatShading,n.side,n.wireframe)),r.scene.markNeedsUpdateRendererDirty()):"material"in e&&e.material!==void 0&&(this.disposeMaterial(),this.material=[r.shared.material(e.material).getFlavor(n.flatShading,n.side,n.wireframe)],r.scene.markNeedsUpdateRendererDirty()));let s=this.data;if(!a&&s.geometry?.type!=="NonParametricGeometry"&&"materials"in s&&s.materials!==void 0&&(this.disposeMaterial(),this.material=r.shared.material(s.materials[0]).getFlavor(n.flatShading,n.side,n.wireframe)),!a&&(e.flatShading!==void 0||e.wireframe!==void 0||e.side!==void 0))if(Array.isArray(this.material))for(let l=0;l<this.material.length;l++)this.material[l]=this.material[l].getFlavor(n.flatShading,n.side,n.wireframe);else this.material=this.material.getFlavor(n.flatShading,n.side,n.wireframe,o);this.syncShadowCatcher(r)}shadowCatcherActive(){let e=this.dataPatched,r=e.geometry?.type;return e.shadowCatcher===!0&&(r==="RectangleGeometry"||r==="PlaneGeometry")}syncShadowCatcher(e){let r=this.dataPatched;if(this.shadowCatcherActive()){if(this.shadowCatcherMaterial===void 0){let n=d2();if(n===null)return;this.shadowCatcherMaterial=n}this.shadowCatcherMaterial.side=r.side,this.material!==this.shadowCatcherMaterial&&(this.disposeMaterial(),this.material=this.shadowCatcherMaterial,e.scene.markNeedsUpdateRendererDirty()),this.castShadow=!1,this.receiveShadow=!0,this.layers.set(0)}else this.shadowCatcherMaterial!==void 0&&this.material===this.shadowCatcherMaterial&&(this.materialOverride!==void 0?(this.material=this.materialOverride,e.scene.markNeedsUpdateRendererDirty()):"material"in r&&r.material!==void 0&&(this.material=e.shared.material(r.material).getFlavor(r.flatShading,r.side,r.wireframe),e.scene.markNeedsUpdateRendererDirty(),this.needsAO&&this.layers.enable(5)),this.castShadow=r.castShadow,this.receiveShadow=r.receiveShadow)}static disposeOneMaterial(e){Vy(e)&&!O2(e)&&e.nodeMaterialDispose()}disposeMaterial(){this.material&&Pf(this.material).forEach(e=>{xr.disposeOneMaterial(e)})}dispose(){this.disposeMaterial(),this.shadowCatcherMaterial?.dispose(),super.dispose()}};var Sr=require("three");var D2=new Sr.Vector3,R2=new Sr.Vector4,B2=new Sr.Vector4,tV=new Sr.Vector3,N2=new Sr.Matrix4,Cs=new Sr.Mesh,rV=Cs.geometry,nV=Cs.material,Gy=new Sr.Vector3,tt=class extends xr{constructor(e,r,n){super(e,r);this.data=r;this.isSkinnedMesh=!1;this.localGeometry=void 0,r.bindMode&&r.bindMatrix&&(this.bindMode=r.bindMode,this.bindMatrix=new Sr.Matrix4().fromArray(r.bindMatrix),this.bindMatrixInverse=new Sr.Matrix4)}chooseGeoemtryCache(e){return e.geometryCache}supportsInPlaceGeometryUpdate(e){return e.isTextGeometry!==!0}markGeometryAsReachable(e){this.geometryCreateDeleyed instanceof Sr.BufferGeometry&&this.chooseGeoemtryCache(e).markAsReachable(this.dataPatched.geometry,this.geometryCreateDeleyed)}get builtSharedGeometry(){if(this.localGeometry===void 0)return this.geometryCreateDeleyed instanceof Sr.BufferGeometry?this.geometryCreateDeleyed:void 0}get geometry(){if(this.localGeometry!==void 0)return this.localGeometry;if(this.geometryCreateDeleyed instanceof As){let e=this.geometryCreateDeleyed,r=this.chooseGeoemtryCache(e),n=this.dataPatched.geometry;this.geometryCreateDeleyed=r.get(n,e,this),this._geometryCacheKey=n}return this.geometryCreateDeleyed}set geometry(e){this.localGeometry=e}get is2DAndNoDepth(){let e=this.dataPatched.geometry;return fp.is2DParametricMesh(e.type)&&e.depth===0}get is2DType(){return fp.is2DParametricMesh(this.geometry.userData.type)}get isTextType(){return this.geometry.isTextGeometry===!0}get isNonParametric(){return this.geometry.userData.type==="NonParametricGeometry"}updateByPatchedOp(e,r,n){super.updateByPatchedOp(e,r,n),Ye(e.path,["geometry"])&&this.updateByPatchedOpGeometry(or.drop(e,1),r.geometry,n)}removeInteractionGeometry(e){this.localGeometry?.dispose(),this.localGeometry=void 0}dispose(){super.dispose(),EM(this.uuid),this._posed=void 0}get appliedGeometrySize(){let e=this.localGeometry?.userData;if(!(e===void 0||e.sxPrev===void 0))return[e.sxPrev,e.syPrev,e.szPrev]}updateGeometryInteractions(e,r){this.invalidateDownstreamBooleanData();let n=this.data.geometry.type;if(n==="NonParametricGeometry"||n==="SubdivGeometry"){let o=e;if(this.localGeometry===void 0){let h={...this.data.geometry,...o};this.localGeometry=Li(h,r,this.data.flatShading,this)}let a,s,l;o.scaleBaked?[a,s,l]=o.scaleBaked:{width:a,height:s,depth:l}=o;let c=this.localGeometry.userData,d=typeof a=="number"?a:1,u=typeof s=="number"?s:1,p=typeof l=="number"?l:1;c.sxPrev!==void 0&&jp(this.localGeometry.attributes,d/c.sxPrev,u/c.syPrev,p/c.szPrev),c.sxPrev=d,c.syPrev=u,c.szPrev=p}else if(!this.absorbDepthInteraction(e)){let o={...this.data.geometry,...e},a=Li(o,r,this.data.flatShading,this);this.localGeometry!==void 0&&this.supportsInPlaceGeometryUpdate(this.localGeometry)&&Dy(this.localGeometry,a)?a.dispose():(this.localGeometry?.dispose(),this.localGeometry=a)}}absorbDepthInteraction(e){let r=this.localGeometry;if(r?.shiftDepthTo===void 0)return!1;let n=e;if(typeof n.depth!="number")return!1;let o=r.userData?.parameters;if(o===void 0)return!1;for(let a of Object.keys(n))if(a!=="depth"&&n[a]!==o[a])return!1;return r.shiftDepthTo(n.depth)?(o.depth=n.depth,!0):!1}refreshAttachedClonersInteractions(e){for(let r of this.attachedSurfaceCloners)r.update(e)}refreshAttachedCloners(e){for(let r of this.attachedSurfaceCloners)e.scene.addPendingUpdateCloner(r.object)}refreshAttachedPaths(e){for(let r of this.attachedPaths)e.scene.addPendingCommand(()=>r.updateShape())}createGeometryDelayed(e){this.geometryCreateDeleyed=e.shared,this.refreshAttachedCloners(e),this.refreshAttachedPaths(e)}updateByPatchedOpGeometry(e,r,n){let o=!1;if(e.type===0&&e.path.length===0&&Object.keys(e.props).includes("scaleBaked")&&this.geometryCreateDeleyed instanceof Lt&&this.chooseGeoemtryCache(n.shared).mutateIfUnique(this.geometryCreateDeleyed.data,r)===this.geometryCreateDeleyed&&(o=!0,this.geometryCreateDeleyed.mutateDirectlyScaleBaked(r,e.props.scaleBaked),this.refreshAttachedCloners(n),this.refreshAttachedPaths(n)),!o&&e.type===0&&e.path.length===0&&Ly(e.props)&&this.geometryCreateDeleyed instanceof Lt&&this.chooseGeoemtryCache(n.shared).mutateIfUnique(this.geometryCreateDeleyed.data,r)===this.geometryCreateDeleyed&&(o=!0,this.geometryCreateDeleyed.mutateDirectlySubdivisions(r),this.refreshAttachedCloners(n),this.refreshAttachedPaths(n)),!o&&e.type===0&&e.path.length===0&&this.geometryCreateDeleyed instanceof Sr.BufferGeometry&&!(this.geometryCreateDeleyed instanceof Lt)&&this.supportsInPlaceGeometryUpdate(this.geometryCreateDeleyed)&&this._geometryCacheKey!==void 0){let a=n.shared,s=this.chooseGeoemtryCache(a),l=this.geometryCreateDeleyed;if(s.getCached(this._geometryCacheKey)===l&&l.isShared!==!0){let d=this.dataPatched.geometry,u=Li(d,a,this.data.flatShading,this);Dy(l,u)?(u.dispose(),l.computeBoundingSphere(),s.mutateIfUnique(this._geometryCacheKey,d)):(u.computeBoundingSphere(),s.forceDelete(this._geometryCacheKey),s.adopt(d,u),this.geometryCreateDeleyed=u),this._geometryCacheKey=d,o=!0,this.refreshAttachedCloners(n),this.refreshAttachedPaths(n)}}o||(n.scene?.markGeometryCacheDirty(),this.createGeometryDelayed(n)),this.syncShapeBlendNodeLayer(),this.resetBBoxNeedsUpdate(),this.invalidateDownstreamBooleanData()}updateGeometryOnStateUpdate(e,r){this.createGeometryDelayed(r)}applyTransientGeometryData(e,r){let n=e.shared,o=this.dataPatched.geometry;if(this.geometryCreateDeleyed instanceof Sr.BufferGeometry&&!(this.geometryCreateDeleyed instanceof Lt)&&this.supportsInPlaceGeometryUpdate(this.geometryCreateDeleyed)&&this._geometryCacheKey!==void 0){let a=this.chooseGeoemtryCache(n),s=this.geometryCreateDeleyed;if(a.getCached(this._geometryCacheKey)===s&&s.isShared!==!0){let c=Li(o,n,this.data.flatShading,this);Dy(s,c)?(c.dispose(),s.computeBoundingSphere(),a.mutateIfUnique(this._geometryCacheKey,o)):(c.computeBoundingSphere(),a.forceDelete(this._geometryCacheKey),a.adopt(o,c),this.geometryCreateDeleyed=c),this._geometryCacheKey=o,this.refreshAttachedCloners(e),this.refreshAttachedPaths(e);return}}r&&this._geometryCacheKey!==void 0&&this.chooseGeoemtryCache(n).forceDelete(this._geometryCacheKey),e.scene?.markGeometryCacheDirty(),this.createGeometryDelayed(e)}updateState(e,r){e.geometry!==void 0&&this.updateGeometryOnStateUpdate(e.geometry,r);let n=e.morphTargetInfluences;if(n){this.updateMorphTargets(),this.geometry.morphTargetsRelative=!0;for(let{data:{name:o,value:a}}of n)this.updateMorphInfluences(o,r.shared.getVariable(a,[this.uuid,"morphTargetInfluences",o]))}super.updateState(e,r)}updateMorphInfluences(e,r){if(this.morphTargetDictionary===void 0)return;let n=this.morphTargetDictionary[e];n!==void 0&&(this.morphTargetInfluences[n]=r)}updateGeometryGroupsIfNeeded(){Array.isArray(this.material)&&this.geometry.groups.length===0&&this.geometry.addGroup(0,Math.max(this.geometry.getIndex()?.count??0,this.geometry.getAttribute("position").count),0)}updateEntityBoxSize(e,r){let n=this.posedGeometry()?.boundingBox;if(n){n.getCenter(e),n.getSize(r).multiplyScalar(.5);return}let o=this.geometry.userData.parameters;this.is2DType||this.isTextType?e.set(0,0,o.depth*.5):this.isNonParametric?(e.setScalar(0),this.geometry.boundingSphere&&e.copy(this.geometry.boundingSphere.center),r.set(o.width,o.height,o.depth??0).multiplyScalar(.5)):o.centerOffset?e.fromArray(o.centerOffset):e.setScalar(0),r.set(o.width,o.height,o.depth??0).multiplyScalar(.5)}updateMatrixWorld(e){super.updateMatrixWorld(e),this.bindMode==="attached"?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode==="detached"&&this.bindMatrixInverse.copy(this.bindMatrix).invert()}bind(e,r){this.skeleton=e,this.isSkinnedMesh=!0,r===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),r=this.matrixWorld),this.bindMatrix.copy(r),this.bindMatrixInverse.copy(r).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(e){let r=new Sr.Vector4,n=this.geometry.attributes.skinWeight;for(let o=0,a=n.count;o<a;o++){r.fromBufferAttribute(n,o);let s=1/r.manhattanLength();s!==1/0?r.multiplyScalar(s):r.set(1,0,0,0),n.setXYZW(o,r.x,r.y,r.z,r.w)}}boneTransform(e,r){let n=this.skeleton;if(n===void 0)return;let o=this.geometry;R2.fromBufferAttribute(o.attributes.skinIndex,e),B2.fromBufferAttribute(o.attributes.skinWeight,e),D2.copy(r).applyMatrix4(this.bindMatrix),r.set(0,0,0);for(let a=0;a<4;a++){let s=B2.getComponent(a);if(s!==0){let l=R2.getComponent(a);N2.multiplyMatrices(n.bones[l].matrixWorld,n.boneInverses[l]),r.addScaledVector(tV.copy(D2).applyMatrix4(N2),s)}}return r.applyMatrix4(this.bindMatrixInverse)}raycastDeformed(e,r){let n=this.posedGeometry();if(n===void 0)return!1;Cs.geometry=n,Cs.material=this.material,Cs.matrixWorld.copy(this.matrixWorld);let o=r.length;Cs.raycast(e,r);for(let a=o;a<r.length;a++)r[a].object=this;return Cs.geometry=rV,Cs.material=nV,!0}posedGeometry(){let e=this.skeleton;if(!this.isSkinnedMesh||e===void 0)return;let r=this.geometry,{position:n,skinIndex:o,skinWeight:a}=r.attributes;if(!n||!o||!a)return;let s=[...this.bindMatrix.elements,...this.bindMatrixInverse.elements,...this.morphTargetInfluences??[]];for(let h=0;h<e.bones.length;h++){let f=e.bones[h];if(!f||!e.boneInverses[h])return;s.push(...f.matrixWorld.elements)}let l=this._posed;if(l?.source===r&&l.version===n.version&&l.pose.length===s.length&&l.pose.every((h,f)=>h===s[f]))return l.geometry;let c=n.count,d=l?.geometry.attributes.position,u=d?.count===c?d:new Sr.BufferAttribute(new Float32Array(c*3),3);for(let h=0;h<c;h++)this.boneTransform(h,this.getVertexPosition(h,Gy)),u.setXYZ(h,Gy.x,Gy.y,Gy.z);let p=new Sr.BufferGeometry;p.setAttribute("position",u);for(let h of["normal","uv","uv1"]){let f=r.attributes[h];f&&p.setAttribute(h,f)}return p.setIndex(r.index),p.groups=r.groups,p.drawRange=r.drawRange,p.computeBoundingSphere(),p.computeBoundingBox(),this._posed={source:r,version:n.version,pose:s,geometry:p},p}};var V2=require("three");var Wo=require("three");var L2=require("three"),jo=i=>{var t;return t=class extends i{},t.geometryHelper=new L2.BoxGeometry(30,30,30),t};var Cn=require("three"),Uy=new Cn.Ray,OS=new Cn.Sphere,_2=new Cn.Matrix4,Ho=(i,t,e,r,n=!1,o=i)=>{let a=t,s=o.matrixWorld;if(a.boundingSphere===null&&a.computeBoundingSphere(),OS.copy(a.boundingSphere),OS.applyMatrix4(s),e.ray.intersectsSphere(OS)===!1||(_2.copy(s).invert(),Uy.copy(e.ray).applyMatrix4(_2),a.boundingBox!==null&&Uy.intersectsBox(a.boundingBox)===!1))return;let l,c,d,u,p=a.index,h=a.attributes.position,f=a.drawRange,m,y;if(n===!1){let v=Math.max(0,f.start),b=Math.min(p.count,f.start+f.count);for(m=v,y=b;m<y;m+=3)if(c=p.getX(m),d=p.getX(m+1),u=p.getX(m+2),l=g(i,e,Uy,h,c,d,u),l){l.faceIndex=Math.floor(m/3),r.push(l);return}}else{let b=a.attributes.position,S=new Cn.Vector3,x=new Cn.Vector3,w=new Cn.Vector3,A=new Cn.Vector3,C=2,M=1/((o.scale.x+o.scale.y+o.scale.z)/3),B=M*M,I=Math.max(0,f.start),_=Math.min(b.count,f.start+f.count);for(let E=I,R=_-1;E<R;E+=C){if(S.fromBufferAttribute(b,E),x.fromBufferAttribute(b,E+1),Uy.distanceSqToSegment(S,x,A,w)>B)continue;A.applyMatrix4(o.matrixWorld);let F=e.ray.origin.distanceTo(A);F<e.near||F>e.far||r.push({distance:F,point:w.clone().applyMatrix4(o.matrixWorld),object:i})}}function g(v,b,S,x,w,A,C){let P=new Cn.Vector3,M=new Cn.Vector3,B=new Cn.Vector3,I=new Cn.Vector3,_=new Cn.Vector3;if(P.fromBufferAttribute(x,w),M.fromBufferAttribute(x,A),B.fromBufferAttribute(x,C),S.intersectTriangle(P,M,B,!1,I)===null)return null;_.copy(I),_.applyMatrix4(v.matrixWorld);let R=b.ray.origin.distanceTo(_);return R<b.near||R>b.far?null:{faceIndex:1,distance:R,point:_.clone(),object:v}}};var iV=new Wo.Vector3(1,1,1),F2=new Wo.Vector3,oV=new Wo.Vector3,k2=new Wo.Quaternion,Fi=class extends jo(Wo.AxesHelper){constructor(e,r=15){super(r);this.object=e;this.dummy=new Wo.Group;this.object.updateMatrixWorld(),this.name=`EmptyObjectHelper: ${e.uuid}`,this.matrix=this.dummy.matrixWorld,this.matrixAutoUpdate=!1,this.object.isBone&&(this.visible=!1)}raycast(e,r){Ho(this.object,Fi.geometryHelper,e,r,!1,this.dummy)}update(){}updateMatrix(){}updateMatrixWorld(e){this.object.matrixWorld.decompose(F2,k2,oV),this.matrix.compose(F2,k2,iV),super.updateMatrixWorld(e)}updateWorldMatrix(e,r){}};var qp=require("three");var zy;(t=>t.is=e=>"objectHelper"in e)(zy||(zy={}));var ki=(i,t)=>class extends Yc(i){constructor(){super(...arguments);this.objectHelper=new t(this);this.gizmos={}}get geometryHelper(){return t.geometryHelper}raycast(n,o){this.objectHelper.raycast(n,o)}showGizmos(){for(let n in this.gizmos){let o=this.gizmos[n];o instanceof qp.Box3Helper&&(o.visible=!0)}}updateEntityBoxSize(n,o){this.objectHelper.visible&&this.geometryHelper instanceof qp.BoxGeometry?(n.setScalar(0),o.set(this.geometryHelper.parameters.width,this.geometryHelper.parameters.height,this.geometryHelper.parameters.height).multiplyScalar(.5)):super.updateEntityBoxSize(n,o)}hideGizmos(){for(let n in this.gizmos){let o=this.gizmos[n];o instanceof qp.Box3Helper&&(o.visible=!1)}}};var vd=class extends ki(V2.Group,Fi){constructor(e,r,n){super();this.super_Entity(e,r),this.context=n,this.objectHelper.update()}updateState(e,r){this.updateState_Entity(e,r)}};var aV=null;function G2(){return aV}var Je=require("three"),Zy=gc(z2());var sV=.5*(Math.sqrt(3)-1),Xp=(3-Math.sqrt(3))/6,lV=1/3,qo=1/6,Oee=(Math.sqrt(5)-1)/4,Iee=(5-Math.sqrt(5))/20,Yp=i=>Math.floor(i)|0,j2=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]),DS=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 H2(i=Math.random){let t=q2(i),e=new Float64Array(t).map(n=>j2[n%12*2]),r=new Float64Array(t).map(n=>j2[n%12*2+1]);return function(o,a){let s=0,l=0,c=0,d=(o+a)*sV,u=Yp(o+d),p=Yp(a+d),h=(u+p)*Xp,f=u-h,m=p-h,y=o-f,g=a-m,v,b;y>g?(v=1,b=0):(v=0,b=1);let S=y-v+Xp,x=g-b+Xp,w=y-1+2*Xp,A=g-1+2*Xp,C=u&255,P=p&255,M=.5-y*y-g*g;if(M>=0){let _=C+t[P],E=e[_],R=r[_];M*=M,s=M*M*(E*y+R*g)}let B=.5-S*S-x*x;if(B>=0){let _=C+v+t[P+b],E=e[_],R=r[_];B*=B,l=B*B*(E*S+R*x)}let I=.5-w*w-A*A;if(I>=0){let _=C+1+t[P+1],E=e[_],R=r[_];I*=I,c=I*I*(E*w+R*A)}return 70*(s+l+c)}}function W2(i=Math.random){let t=q2(i),e=new Float64Array(t).map(o=>DS[o%12*3]),r=new Float64Array(t).map(o=>DS[o%12*3+1]),n=new Float64Array(t).map(o=>DS[o%12*3+2]);return function(a,s,l){let c,d,u,p,h=(a+s+l)*lV,f=Yp(a+h),m=Yp(s+h),y=Yp(l+h),g=(f+m+y)*qo,v=f-g,b=m-g,S=y-g,x=a-v,w=s-b,A=l-S,C,P,M,B,I,_;x>=w?w>=A?(C=1,P=0,M=0,B=1,I=1,_=0):x>=A?(C=1,P=0,M=0,B=1,I=0,_=1):(C=0,P=0,M=1,B=1,I=0,_=1):w<A?(C=0,P=0,M=1,B=0,I=1,_=1):x<A?(C=0,P=1,M=0,B=0,I=1,_=1):(C=0,P=1,M=0,B=1,I=1,_=0);let E=x-C+qo,R=w-P+qo,L=A-M+qo,F=x-B+2*qo,k=w-I+2*qo,W=A-_+2*qo,U=x-1+3*qo,G=w-1+3*qo,q=A-1+3*qo,X=f&255,Y=m&255,K=y&255,te=.6-x*x-w*w-A*A;if(te<0)c=0;else{let de=X+t[Y+t[K]];te*=te,c=te*te*(e[de]*x+r[de]*w+n[de]*A)}let ue=.6-E*E-R*R-L*L;if(ue<0)d=0;else{let de=X+C+t[Y+P+t[K+M]];ue*=ue,d=ue*ue*(e[de]*E+r[de]*R+n[de]*L)}let se=.6-F*F-k*k-W*W;if(se<0)u=0;else{let de=X+B+t[Y+I+t[K+_]];se*=se,u=se*se*(e[de]*F+r[de]*k+n[de]*W)}let ce=.6-U*U-G*G-q*q;if(ce<0)p=0;else{let de=X+1+t[Y+1+t[K+1]];ce*=ce,p=ce*ce*(e[de]*U+r[de]*G+n[de]*q)}return 32*(c+d+u+p)}}function q2(i){let e=new Uint8Array(512);for(let r=0;r<512/2;r++)e[r]=r;for(let r=0;r<512/2-1;r++){let n=r+~~(i()*(256-r)),o=e[r];e[r]=e[n],e[n]=o}for(let r=256;r<512;r++)e[r]=e[r-256];return e}var X2=require("three"),ho=new X2.Triangle,jy=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 n=0;n<t.count;n+=3){let o=1;ho.a.fromBufferAttribute(t,n),ho.b.fromBufferAttribute(t,n+1),ho.c.fromBufferAttribute(t,n+2),o*=ho.getArea(),e[n/3]=o}this.distribution=new Float32Array(t.count/3);let r=0;for(let n=0;n<e.length;n++)r+=e[n],this.distribution[n]=r;return this}setRandomGenerator(t){return this.randomFunction=t,this}sample(t,e){if(this.distribution){let r=this.distribution[this.distribution.length-1],n=this.binarySearch(this.randomFunction()*r);return this.sampleFace(n,t,e)}}binarySearch(t){if(!this.distribution)return 0;let e=this.distribution,r=0,n=e.length-1,o=-1;for(;r<=n;){let a=Math.ceil((r+n)/2);if(a===0||e[a-1]<=t&&e[a]>t){o=a;break}else t<e[a]?n=a-1:r=a+1}return o}sampleFace(t,e,r){let n=this.randomFunction(),o=this.randomFunction();return n+o>1&&(n=1-n,o=1-o),ho.a.fromBufferAttribute(this.positionAttribute,t*3),ho.b.fromBufferAttribute(this.positionAttribute,t*3+1),ho.c.fromBufferAttribute(this.positionAttribute,t*3+2),e.set(0,0,0).addScaledVector(ho.a,n).addScaledVector(ho.b,o).addScaledVector(ho.c,1-(n+o)),ho.getNormal(r),this}};var Ba=require("three");var hi=require("three");function cV(i){if(i.geometry.attributes.extrudeNormal||!i.geometry.attributes.position||!i.geometry.attributes.normal)return;let t=new Map,e=i.geometry.attributes,r=e.position.array,n=e.normal.array,o=new Float32Array(r.length);for(let a=0;a<r.length;a+=3){let s=`${r[a]}_${r[a+1]}_${r[a+2]}`,l=new hi.Vector3(n[a],n[a+1],n[a+2]);t.has(s)?t.get(s)?.normals.push(l):t.set(s,{normals:[l],result:new hi.Vector3})}t.forEach((a,s)=>{for(let l of a.normals)a.result.add(l);a.result.divideScalar(a.normals.length)});for(let a=0;a<r.length;a+=3){let s=`${r[a]}_${r[a+1]}_${r[a+2]}`,l=t.get(s)?.result;l&&(o[a]=l.x,o[a+1]=l.y,o[a+2]=l.z)}i.geometry.setAttribute("extrudeNormal",new hi.Float32BufferAttribute(o,3))}function dV(i){if(i.geometry.attributes.extrudeNormals||!i.geometry.attributes.position)return;let e=i.geometry.attributes.position.array,r=new Float32Array(e.length),n=new hi.Vector3;for(let o=0;o<e.length;o+=3)n.set(e[o],e[o+1],e[o+2]).normalize(),r[o]=n.x,r[o+1]=n.y,r[o+2]=n.z;i.geometry.setAttribute("extrudeNormal",new hi.Float32BufferAttribute(r,3))}function Xo(i){if(Array.isArray(i.material)){for(let t of i.material)if(t.getLayersOfType("outline").length===0)return}else if(!Ll(i.material)||i.material.getLayersOfType("outline").length===0)return;i instanceof tt&&i.is2DAndNoDepth?dV(i):cV(i)}function RS(i){return Math.min(2047,Math.max(1,Math.round(i*2048)))/2048}function Yo(i){if(!i.geometry.attributes.position)return;let t=i.geometry.attributes,e=t.position.array,r=t.randomColor;if(r!==void 0&&r.count*3===e.length)return;let n=new Float32Array(e.length),o=parseInt(i.uuid.replace(/\D/g,"")),a=[RS(hi.MathUtils.seededRandom(o)),RS(hi.MathUtils.seededRandom(o+1e4)),RS(hi.MathUtils.seededRandom(o+2e4))];for(let s=0;s<e.length;s++)n[s]=a[s%3];i.geometry.setAttribute("randomColor",new hi.BufferAttribute(n,3))}var Qo=new Ba.Box3,Qp=new Ba.Vector3;function Y2(i){let t=!1;return i.scene.objects.traverse((e,r)=>{r.type==="Mesh"&&r.geometry.type==="SubdivGeometry"&&(t=!0)}),t}var Na=class extends tt{constructor(e,r,n){super(e,r,n);this.data=r;this.hiddenMatrixOld=new Ba.Matrix4;this.smoothShading=!0;this.skipReactionUpdate=!1}chooseGeoemtryCache(e){return this.dataPatched.flatShading?e.geometryCache:e.geometryCache2}get subdivPointerNew(){return this.localGeometry!==void 0?this.subdivPointer:this.geometry.ensureSubdivPointer()}get originalGeometryNew(){return this.localGeometry!==void 0?this.originalGeometry:this.geometry.originalGeometry}get phongAngle(){return this.data.geometry.phongAngle??45}updateEntityBoxSize(e,r){let n=this.geometry.userData.parameters;e.copy(this.originalGeometryNew.boundingSphere.center),r.set(n.width,n.height,n.depth??0).multiplyScalar(.5)}createGeometryByControls(e){if(this.skipReactionUpdate===!0)return;let r=this.localGeometry?.uuid,{originalGeometry:n,subdividedGeometry:o,subdivPointer:a}=Lt.build(e,this.subdivPointer,this.smoothShading,this.hasNonUniformScale?this.shearScale:void 0);this.subdivPointer=a,n!==void 0&&(this.originalGeometry?.dispose(),this.originalGeometry=n),o!==void 0&&(this.subdividedGeometry?.dispose(),this.subdividedGeometry=o??void 0),this.localGeometry=this.subdividedGeometry??this.originalGeometry,Xo(this),Yo(this),this.calcBoundingBox(),r&&(this.localGeometry.uuid=r)}updateState(e,r){if(super.updateState(e,r),e.flatShading!==void 0){let n=this.material;this.material=Array.isArray(n)?n.map(o=>o.getFlavor(!1,o.side,o.wireframe)):n.getFlavor(!1,n.side,n.wireframe),this.smoothShading=!e.flatShading,this.createGeometryDelayed(r)}}updateMesh(e=!1,r=!1,n=!1){r&&this.subdividedGeometry||Lt.buildLevel(this.subdivPointer,!0,this.smoothShading?this.phongAngle:-1,this.originalGeometry,e&&this.hasNonUniformScale?this.shearScaleInv:void 0,n),this.subdividedGeometry&&Lt.buildLevel(this.subdivPointer,!1,this.smoothShading?this.phongAngle:-1,this.subdividedGeometry,e&&this.hasNonUniformScale?this.shearScaleInv:void 0)}updateTopology(){let e=this.localGeometry?.uuid;this.originalGeometry.dispose(),this.originalGeometry=Lt.buildLevel(this.subdivPointer,!0,this.smoothShading?this.phongAngle:-1),this.subdividedGeometry&&(this.subdividedGeometry.dispose(),this.subdividedGeometry=Lt.buildLevel(this.subdivPointer,!1,this.smoothShading?this.phongAngle:-1)),this.localGeometry=this.subdividedGeometry??this.originalGeometry,Xo(this),Yo(this),this.calcBoundingBox(),e&&(this.localGeometry.uuid=e)}raycast(e,r){let n=this.localGeometry;this.localGeometry=this.originalGeometryNew,it.prototype.raycast.call(this,e,r),this.localGeometry=n}activateShearCompensation(){!this.hasNonUniformScale||(this.matrix.copy(this.matrixWorldRigid),this.hiddenMatrixOld.copy(this.hiddenMatrix),this.hiddenMatrix.copy(this.parent.matrixWorld).invert())}deactivateShearCompensation(){!this.hasNonUniformScale||(this.updateMatrix(),this.hasNonUniformScale=void 0,this.hiddenMatrix.copy(this.hiddenMatrixOld))}calcBoundingBox(){let e=this.originalGeometry;e.boundingSphere===null&&(e.boundingSphere=new Ba.Sphere,this.subdividedGeometry&&(this.subdividedGeometry.boundingSphere=e.boundingSphere));let r=e.attributes.position,n=e.boundingSphere.center;Qo.setFromBufferAttribute(r),Qo.getCenter(n),e.boundingSphere.radius=n.distanceTo(Qo.max),isNaN(e.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this),Qo.getSize(Qp),this.hasNonUniformScale&&Qp.divide(this.scale);let o={width:Qp.x,height:Qp.y,depth:Qp.z};return this.geometry.userData.parameters=o,o}updateBoundingSphere(e){let r=this.originalGeometry;Qo.min.set(e[0],e[2],e[4]),Qo.max.set(e[1],e[3],e[5]),this.hasNonUniformScale&&(Qo.min.applyMatrix4(this.shearScaleInv),Qo.max.applyMatrix4(this.shearScaleInv)),r.boundingSphere===null&&(r.boundingSphere=new Ba.Sphere);let n=r.boundingSphere.center;Qo.getCenter(n),r.boundingSphere.radius=n.distanceTo(Qo.max)}freeSubdivPointer(){this.subdivPointer&&(Lt.freeSubdivPointer(this.subdivPointer),this.subdivPointer=0),this.localGeometry=void 0,this.originalGeometry?.dispose(),this.subdividedGeometry?.dispose()}dispose(){super.dispose(),this.freeSubdivPointer()}updateSubdivisionLevel(e){if(this.skipReactionUpdate===!0)return;let r=this.localGeometry,n=r?.uuid,o=r?.userData.parameters,a=e.subdivisions>0?Lt.buildRefined(this.subdivPointer,e.subdivisions,this.smoothShading?e.phongAngle??35:-1):null;this.subdividedGeometry?.dispose(),this.subdividedGeometry=a??void 0,this.subdividedGeometry&&this.originalGeometry.boundingSphere&&(this.subdividedGeometry.boundingSphere=this.originalGeometry.boundingSphere),this.localGeometry=this.subdividedGeometry??this.originalGeometry,Xo(this),Yo(this),o!==void 0&&(this.localGeometry.userData.parameters=o),n&&(this.localGeometry.uuid=n)}updateByPatchedOpGeometry(e,r,n){super.updateByPatchedOpGeometry(e,r,n),this.localGeometry&&(e.type===0&&e.path.length===0&&Ly(e.props)&&this.subdivPointer?this.updateSubdivisionLevel(r):this.createGeometryByControls(r))}};var Ko=require("three"),Q2=-1,uV=1,K2={x:[1,0,0],"-x":[-1,0,0],y:[0,1,0],"-y":[0,-1,0],z:[0,0,1],"-z":[0,0,-1]},Z2={polygon_center:0,edge:1,vertex:2},Kp=(i,t)=>(e,r)=>!t||e===0||i===0?0:i*r/100,ze=(i,t)=>{let e=Math.abs(t),r=e*-1;return(i-Q2)*(e-r)/(uV-Q2)+r},pV=new Ko.Vector3,Hy=new Ko.Vector3,hV=new Ko.Vector3,fV=new Ko.Vector3;function bd(i,t){let e=hV.fromArray(i),r=fV.fromArray(t);Hy.copy(r).sub(e);let n=Hy.length();return Hy.normalize().multiplyScalar(n*.5),pV.copy(e).add(Hy).toArray()}var Vi=new Ko.Triangle,Wy=new Ko.Vector3,qy=new Ko.Vector3,_l=new Ko.Vector3;function J2(i){let t=[],e=Math.floor(i.index.count/3);for(let r=0;r<e;r++)if(Wy.fromArray(i.index.array,r*3),Vi.setFromAttributeAndIndices(i.attributes.position,Wy.x,Wy.y,Wy.z),Vi.getNormal(qy),Vi.getMidpoint(_l),!(isNaN(_l.x)||isNaN(_l.y)||isNaN(_l.z))){let{a:n,b:o,c:a}=Vi,s=n.toArray(),l=o.toArray(),c=a.toArray(),d=n.distanceTo(o),u=o.distanceTo(a),p=a.distanceTo(n),h=bd(s,l),f=bd(l,c),m=bd(c,s),y=[d,u,p],g=Math.max(...y),v=y.filter(x=>Math.round(x)===Math.round(g)).length>1,b=[],S=Vi.getMidpoint(_l).toArray();g===d&&!v&&(b=[f,m,m],S=h),g===u&&!v&&(b=[h,m,m],S=f),g===p&&!v&&(b=[h,f,f],S=m),v&&(b=[h,f,m]),t.push({vertices:[s,l,c],faceCenters:b,midpoint:S,norm:Vi.getNormal(qy).toArray()})}return t}function $2(i){let t=[],{position:e}=i.attributes;for(let r=0;r<e.count;r++){Vi.setFromAttributeAndIndices(e,r*3,r*3+1,r*3+2),Vi.getNormal(qy),Vi.getMidpoint(_l);let n=Vi.a.toArray(),o=Vi.b.toArray(),a=Vi.c.toArray();t.push({vertices:[n,o,a],faceCenters:[bd(n,o),bd(o,a),bd(a,n)],midpoint:_l.toArray(),norm:qy.toArray()})}return t}var xd=require("three"),BS=class extends xd.InstancedMesh{},Xy=class extends BS{constructor(e,r){super(void 0,void 0,r);this.source=e;this.isClonerInstancedMesh=!0;this.hiddenMatrix=new xd.Matrix4;this.pivotMatrix=new xd.Matrix4;this.previousModelViewMatrix=new xd.Matrix4;this.copyPreviousMatrix=!0;this.capacity=r,this.count=0,this.matrixAutoUpdate=!1}raycast(e,r){}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),this.matrixWorld.multiply(this.pivotMatrix),this.matrixWorldNeedsUpdate=!1,e=!0);for(let r of this.children)r.updateMatrixWorld(e)}updateWorldMatrix(e,r){let n=this.parent;if(e&&n!==null&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.parent===null?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),this.matrixWorld.multiply(this.pivotMatrix),r)for(let o of this.children)o.updateWorldMatrix(!1,!0)}onAfterRender(e,r,n,o,a,s){this.copyPreviousMatrix&&this.previousModelViewMatrix.copy(this.modelViewMatrix)}get visible(){return this.source.cloner?.insideBoolean===!0?!1:this.source.visible||this.source.dataPatched.visible&&this.source.dataPatched.cloner?.hideBase===!0}set visible(e){}get castShadow(){return this.source.castShadow}set castShadow(e){}get receiveShadow(){return this.source.receiveShadow}set receiveShadow(e){}get layers(){return this.source.layers}set layers(e){}get geometry(){return this.source.geometry}set geometry(e){}get material(){return this.source.material}set material(e){}get morphTargetInfluences(){return this.source.morphTargetInfluences}set morphTargetInfluences(e){}};var NS=i=>.5*(1-Math.cos(i*Math.PI)),LS=class{constructor(){this.perlin=new Array(4095+1)}noise(t,e=0,r=0){if(this.perlin==null){this.perlin=new Array(4095+1);for(let g=0;g<4095+1;g++)this.perlin[g]=Math.random()}t<0&&(t=-t),e<0&&(e=-e),r<0&&(r=-r);let n=Math.floor(t),o=Math.floor(e),a=Math.floor(r),s=t-n,l=e-o,c=r-a,d,u,p=0,h=.5,f,m,y;for(let g=0;g<4;g++){let v=n+(o<<4)+(a<<8);d=NS(s),u=NS(l),f=this.perlin[v&4095],f+=d*(this.perlin[v+1&4095]-f),m=this.perlin[v+16&4095],m+=d*(this.perlin[v+16+1&4095]-m),f+=u*(m-f),v+=256,m=this.perlin[v&4095],m+=d*(this.perlin[v+1&4095]-m),y=this.perlin[v+16&4095],y+=d*(this.perlin[v+16+1&4095]-y),m+=u*(y-m),f+=NS(c)*(m-f),p+=f*h,h*=.5,n<<=1,s*=2,o<<=1,l*=2,a<<=1,c*=2,s>=1&&(n++,s--),l>=1&&(o++,l--),c>=1&&(a++,c--)}return p}noiseSeed(t){let e=(()=>{let a,s;return{setSeed(l){s=a=(l??Math.random()*4294967296)>>>0},getSeed(){return a},rand(){return s=(1664525*s+1013904223)%4294967296,s/4294967296}}})();e.setSeed(t),this.perlin=new Array(4095+1);for(let r=0;r<4095+1;r++)this.perlin[r]=e.rand()}},eO=LS;var Sd=require("three");var tO=new Sd.Vector3,rO=new Sd.Matrix4,nO=new Sd.Ray,Es=class extends tt{constructor(e,r,n){super(e,r,n);this.data=r}get textGeometry(){return this.geometry}get charWidths(){return this.textGeometry.charWidths}get charCoords(){return this.textGeometry.charCoords}get wrappedText(){return this.textGeometry.wrappedText}get font(){return this.textGeometry.font}get initialOffsetY(){let e=this.dataPatched;return this.font?.getLineInitialOffsetY(this.lineHeight,this.wrappedText.length,typeof e.geometry.height=="number"?e.geometry.height:1,this.fontScale,e.geometry.verticalAlign)??0}get fontScale(){let e=this.dataPatched;return this.font?e.geometry.fontSize/this.font.unitsPerEm:1}get AD(){return Math.abs(this.ascender-this.descender)}get ascender(){return(this.font?.ascender??1)*this.fontScale}get descender(){return(this.font?.descender??1)*this.fontScale}get lineHeight(){let e=this.dataPatched;return e.geometry.fontSize*e.geometry.lineHeight}raycast(e,r){let{matrixWorld:n}=this;if(!(isNaN(e.ray.origin.x)||this.scale.x===0||this.scale.y===0||this.scale.z===0)&&(rO.copy(n).invert(),nO.copy(e.ray).applyMatrix4(rO),nO.intersectBox(this.singleBBox,tO))){let o=tO.applyMatrix4(n),a=e.ray.origin.distanceTo(o);r.push({distance:a,point:o.clone(),object:this})}}};var _n=1e-4,Zo,mO,yO,gO,iO=new Je.Vector3,oO=new Je.Vector3;Iy.then(i=>{Zo=i,mO=[Zo.get_face_center,Zo.get_edge_midpoint,Zo.get_vertex_position],yO=[Zo.get_face_normal,Zo.get_edge_normal,Zo.get_vertex_normal],gO=[Zo.face_count,Zo.edge_count,Zo.vertex_count]});var _te=new Je.Matrix4,mV=new Je.Matrix4,aO=new Je.Matrix4,sO=new Je.Matrix4,lO=new Je.Matrix4,cO=new Je.Matrix4,dO=new Je.Matrix4,uO=new Je.Matrix4,Ts=new Je.Vector3,Yy=new Je.Vector3,Zp=new Je.Vector3,_S=new Je.Vector3,yV=new Je.Vector3,pO=new Je.Vector3,Qy=new Je.Vector3,FS=new Je.Vector3,hO=new Je.Vector3,kS=new Je.Vector3,fO=new Je.Vector3,fo=new Je.Euler,gV=new Je.Quaternion;function Ky(i){return i?i.version??i.data?.version??0:-1}function ar(i,t){return[typeof i?.[0]=="number"?i[0]:typeof i?.[0]=="string"&&t?parseFloat(String(t.shared.getVariable(i[0])??"0")):0,typeof i?.[1]=="number"?i[1]:typeof i?.[1]=="string"&&t?parseFloat(String(t.shared.getVariable(i[1])??"0")):0,typeof i?.[2]=="number"?i[2]:typeof i?.[2]=="string"&&t?parseFloat(String(t.shared.getVariable(i[2])??"0")):0]}var VS=class{constructor(t,e){this.data=t;this.is3D=e;this.perlin=new eO;t.noiseType==="perlin"?(this.perlin.noiseSeed(t.seed),e?this.noise=(n,o,a)=>this.perlin.noise(n,o,a):this.noise=n=>this.perlin.noise(n)):e?this.noise=W2((0,Zy.default)(t.seed)):this.noise=H2((0,Zy.default)(t.seed??""))}},Fn=class extends Wc(Je.Object3D){constructor(e,r){super();this.parameters=r;this.isCloner=!0;this.objectForSample=void 0;this._pendingMediaLoad=!1;this.random=null;this.surfaceSamplerCache=null;this.surfacePointsCache=null;this.object=e}resetOnMove(){this.removeFromParent(),this.parent=null}removeFromParent(){return super.removeFromParent(),this.instancedMesh?.removeFromParent(),this}dispose(){this.removeFromParent(),this._disposeInstancedMesh(),this._invalidateBoolean()}_invalidateBoolean(){this.object instanceof it&&this.object.onClonerLayoutUpdated()}expandClones(e){if(this.parent===null)this.updateState(this.parameters,e);else{for(let r of this.children)r instanceof Rr&&r.expand();this._syncInstancedMesh()}}invalidateTransform(e){this.matrixWorldNeedsUpdate=!0}onObjUpdateMatrix(){this.parameters.type!=="toObject"&&(this.matrixWorldNeedsUpdate=!0)}update(e){switch(this._updateCount(e),this.parameters.type){case"radial":this._updateRadial(this.parameters,e);break;case"linear":this._updateLinear(this.parameters,e);break;case"grid":this._updateGrid(this.parameters,e);break;case"toObject":this._updateToObject(this.parameters,e)}for(let r of this.children){let n=r.transformOverride;n!==void 0&&(r.position.fromArray(n.position),r.rotation.fromArray(n.rotation),r.scale.fromArray(n.scale)),r.updateMatrix(),r.hasNonUniformScale&&(r.updateMatrixWorld(),r.updateMatrixWorldRigid())}this._syncInstancedMesh(),this._invalidateBoolean()}get instancingActive(){return this.instancedMesh!==void 0}get insideBoolean(){return this.parent!==null&&"booleanOp"in this.parent}_instancingEligible(){if(this.parameters.instanced!==!0)return!1;let e=this.object;return!(e.entityChildrenCount()>0||e.isMesh!==!0||li(e)||e.isDecalObject===!0)}_syncInstancedMesh(){if(!this._instancingEligible()){this._disposeInstancedMesh();return}let e=this.instancedMesh;if(e!==void 0&&e.capacity<this.children.length&&(this._disposeInstancedMesh(),e=void 0),e===void 0){let r=Math.max(8,Math.ceil(this.children.length*1.5));e=this.instancedMesh=new Xy(this.object,r)}e.matrix=this.matrix,e.hiddenMatrix=this.hiddenMatrix,e.matrixWorldNeedsUpdate=!0,e.parent!==this.parent&&(e.removeFromParent(),this.parent?.add(e)),this.syncInstanceMatrices()}syncInstanceMatrices(){this._invalidateBoolean();let e=this.instancedMesh;if(e===void 0)return;let r=0;for(let n of this.children)n.playModeVisible!==!1&&(aO.multiplyMatrices(n.hiddenMatrix,n.matrix).multiply(n.pivotMatrix),e.setMatrixAt(r++,aO));e.count=r,e.instanceMatrix.needsUpdate=!0,e.boundingSphere=null}_disposeInstancedMesh(){let e=this.instancedMesh;e!==void 0&&(this.instancedMesh=void 0,e.removeFromParent(),e.dispose())}_updateCount(e,r){let n;if(r!==void 0)n=r;else{let o=ar(this.parameters.grid.count,e);n=this.parameters.type==="grid"?Math.round(o[0])*Math.round(o[1])*Math.round(o[2]):this.parameters.count}if(this.parameters.type==="toObject"){if(!this.parameters.toObject.object)n=0;else if(r===void 0&&this.parameters.toObject.spreadType!=="random")return}if(this.children.length!==n)if(this.children.length<n)for(let o=0,a=n-this.children.length;o<a;++o){let s=new Rr(this.object);s.expand(),this.add(s)}else for(;this.children.length>n;){let o=this.children.pop();o.parent=null,o.dispatchEvent({type:"removed"}),this.dispatchEvent({type:"childremoved",child:o})}}getRandom(e,r=!1){return(this.random===null||this.random.data.seed!==e.seed||this.random.data.noiseType!==e.noiseType||this.random.is3D!==r)&&(this.random=new VS(e,r)),this.random}_updateRadial(e,r){let n=e.radial,o=n.start*Je.MathUtils.DEG2RAD,a=n.end*Je.MathUtils.DEG2RAD,s=o-a,l=ar(n.rotation,r),c=new Je.Euler(l[0],l[1],l[2]),d;switch(n.axis){case"z":d=new Je.Vector3(0,0,1);break;case"y":d=new Je.Vector3(0,1,0);break;default:case"x":d=new Je.Vector3(1,0,0);break}let u=e.randomnessObject??Do.defaultData([1,1,1]).randomnessObject,h=this.parameters.randomness===!0&&u.strength!==0?this.getRandom(u):null,f=ar(n.scale,r),m=ar(n.position,r),y=ar(u.scale,r),g=ar(u.position,r),v=ar(u.rotation,r),b=s/e.count,S=Kp(u.strength,this.parameters.randomness);for(let[x,w]of this.children.entries()){let A=x*(u.freqScale/10)+u.movement,C=h===null?0:h.noise(A,A,A),P=x+1;w.scale.x=f[0]+S(P,ze(C,y[0]))||_n,w.scale.y=f[1]+S(P,ze(C,y[1]))||_n,w.scale.z=f[2]+S(P,ze(C,y[2]))||_n;let M=b*x-o;switch(n.axis){default:case"x":fo.set(0,M,0);break;case"y":fo.set(0,0,M);break;case"z":fo.set(M,0,0);break}Qy.copy(d).applyQuaternion(gV.setFromEuler(fo)).multiplyScalar(n.radius),w.position.set(Qy.x+(m[0]+S(P,ze(C,g[0]))),Qy.y+(m[1]+S(P,ze(C,g[1]))),Qy.z+(m[2]+S(P,ze(C,g[2]))));let B=S(P,ze(C,v[0])),I=S(P,ze(C,v[1])),_=S(P,ze(C,v[2]));n.alignment===!0?w.rotation.set(fo.x+(c.x+B),fo.y+(c.y+I),fo.z+(c.z+_)):w.rotation.set(c.x+B,c.y+I,c.z+_)}}_updateLinear(e,r){if(e.type!=="linear")throw new Error;let n=e.linear,o=ar(n.rotation,r),a=ar(n.scale,r),s=ar(n.position,r),l=new Je.Euler(o[0]??0,o[1]??0,o[2]??0),c=e.randomnessObject??Do.defaultData([1,1,1]).randomnessObject,d=ar(c.rotation,r),u=ar(c.scale,r),p=ar(c.position,r),f=this.parameters.randomness===!0&&c.strength!==0?this.getRandom(c):null,m=Kp(c.strength,this.parameters.randomness);for(let[y,g]of this.children.entries()){let v=y*(c.freqScale/10)+c.movement,b=f===null?0:f.noise(v,v,v),S=y+1,x=m(S,ze(b,d[0])),w=m(S,ze(b,d[1])),A=m(S,ze(b,d[2]));g.scale.x=1+(a[0]-1)*y+m(S,ze(b,u[0]))||_n,g.scale.y=1+(a[1]-1)*y+m(S,ze(b,u[1]))||_n,g.scale.z=1+(a[2]-1)*y+m(S,ze(b,u[2]))||_n,g.rotation.set(l.x*y+x,l.y*y+w,l.z*y+A),g.position.x=s[0]*y+m(S,ze(b,p[0])),g.position.y=s[1]*y+m(S,ze(b,p[1])),g.position.z=s[2]*y+m(S,ze(b,p[2]))}}_updateGrid(e,r){let n=0,o=e.grid,a=e.randomnessObject??Do.defaultData([1,1,1]).randomnessObject,s=ar(a.scale,r),l=ar(a.rotation,r),c=ar(a.position,r),u=this.parameters.randomness===!0&&a.strength!==0?this.getRandom(a,!0):null,p=Kp(a.strength,this.parameters.randomness),h=ar(o.count,r),f=ar(o.size,r);if(o.useCenter===!0){let m={x:h[0]%2===0?2:1,y:h[1]%2===0?2:1,z:h[2]%2===0?2:1},y=new Je.Vector3(f[0]*(h[0]-m.x)*.5,f[1]*(h[1]-m.y)*.5,f[2]*(h[2]-m.z)*.5);for(let g=0;g<h[0];g++)for(let v=0;v<h[1];v++)for(let b=0;b<h[2];b++){let S=this.children[n++];if(!S)continue;let x=u===null?0:u.noise((g+1)*(a.freqScale/10)+a.movement,(v+1)*(a.freqScale/10)+a.movement,(b+1)*(a.freqScale/10)+a.movement);S.scale.x=1+p(n,ze(x,s[0]))||_n,S.scale.y=1+p(n,ze(x,s[1]))||_n,S.scale.z=1+p(n,ze(x,s[2]))||_n;let w=p(n,ze(x,l[0])),A=p(n,ze(x,l[1])),C=p(n,ze(x,l[2]));S.rotation.set(w,A,C),S.position.x=f[0]*g-y.x+p(n,ze(x,c[0])),S.position.y=f[1]*v-y.y+p(n,ze(x,c[1])),S.position.z=f[2]*b-y.z+p(n,ze(x,c[2]))}}else for(let m=0;m<h[0];m++)for(let y=0;y<h[1];y++)for(let g=0;g<h[2];g++){let v=this.children[n++];if(!v)continue;let b=u===null?0:u.noise((m+1)*(a.freqScale/10)+a.movement,(y+1)*(a.freqScale/10)+a.movement,(g+1)*(a.freqScale/10)+a.movement);v.scale.x=1+p(n,ze(b,s[0]))||_n,v.scale.y=1+p(n,ze(b,s[1]))||_n,v.scale.z=1+p(n,ze(b,s[2]))||_n;let S=p(n,ze(b,l[0])),x=p(n,ze(b,l[1])),w=p(n,ze(b,l[2]));v.rotation.set(S,x,w),v.position.x=f[0]*m+p(n,ze(b,c[0])),v.position.y=-f[1]*y+p(n,ze(b,c[1])),v.position.z=-f[2]*g+p(n,ze(b,c[2]))}}_updateToObject(e,r){if(e.type!=="toObject")throw new Error;let{toObject:n}=e,o=ar(n.rotation,r),a=ar(n.position,r),s=ar(n.scale,r),l=new Je.Euler(o[0],o[1],o[2]),c=e.randomnessObject??Do.defaultData([1,1,1]).randomnessObject,d=ar(c.rotation,r),u=ar(c.position,r),p=ar(c.scale,r),f=this.parameters.randomness===!0&&c.strength!==0?this.getRandom(c):null,m=Kp(c.strength,this.parameters.randomness);if(!n.object){for(let[,w]of this.children.entries())w.position.set(0,0,0),w.scale.setScalar(1),w.rotation.set(0,0,0);this.objectForSample=void 0,this.invalidateSurfaceCaches();return}if(!this.objectForSample)return;if(this.objectForSample instanceof Es)if(!this.objectForSample.font?.isLoaded||this.objectForSample.geometry.attributes.position===void 0){this._pendingMediaLoad=!0;return}else this._pendingMediaLoad=!1;if(this.objectForSample.geometry===void 0&&this.objectForSample.isAncestorOf(this.object.uuid)){console.warn(`Oh no! The object "${this.object.name}" (${this.object.uuid}) seem to be a child/descendant of the object it's being cloned to. Please re-parent it so that they are siblings instead.`);return}let y=this.getSubdivData();if(y.length>0){let w=Math.round(y.length*n.count/100);this._updateCount(r,w)}else{let w=this.objectForSample.geometry.getAttribute("position");if(!w||isNaN(w.count)||w.count===0){console.warn(`Oh no! The object "${this.object.name}" (${this.object.uuid}) cannot be cloned on the surface of "${this.objectForSample.name}" (${this.objectForSample.uuid}) because the latter does not have a valid geometry.`);return}}this.objectForSample.updateMatrixWorld();let g=n.spreadType==="random",v=null;g&&(v=this.getSurfaceSampler(),v.setRandomGenerator((0,Zy.default)(this.object.uuid+n.seed)));let b=K2[n.axis],S=this.children;Ts.fromArray(b),sO.copy(this.object.hiddenMatrix).invert();let x=this.objectForSample instanceof Na;x&&lO.copy(this.objectForSample.matrixWorld).invert(),n.align!=="normal"&&this.object.getWorldDirection(pO),kS.set(Ts.y,Ts.z,Ts.x).normalize(),fO.copy(kS).cross(Ts).normalize(),dO.makeBasis(kS,Ts,fO).invert();for(let[w,A]of S.entries()){let C=w*(c.freqScale/10)+c.movement,P=f===null?0:f.noise(C,C,C),M=w+1,B=m(M,ze(P,d[0])),I=m(M,ze(P,d[1])),_=m(M,ze(P,d[2]));g?v.sample(Zp,_S):(y.length&&(Zp.fromArray(y[w].pos),_S.fromArray(y[w].norm)),x&&Zp.applyMatrix4(lO)),Zp.applyMatrix4(sO),A.position.copy(Zp);let E=n.align==="normal"?_S:pO,R=Yy.fromArray(a);Yy.x+=m(M,ze(P,u[0])),Yy.y+=m(M,ze(P,u[1])),Yy.z+=m(M,ze(P,u[2]));let L=Math.acos(E.dot(Ts)),F=yV.crossVectors(Ts,E).normalize(),k=mV.makeRotationAxis(F,L);FS.copy(E).cross(this.object.up).normalize(),hO.copy(FS).cross(E).normalize(),cO.makeBasis(FS,E,hO),uO.multiplyMatrices(cO,dO),fo.setFromRotationMatrix(uO),R.applyMatrix4(k),A.position.add(R),A.rotation.set(fo.x+l.x+B,fo.y+l.y+I,fo.z+l.z+_),A.scale.set(1+s[0]+m(M,ze(P,p[0]))||_n,1+s[1]+m(M,ze(P,p[1]))||_n,1+s[2]+m(M,ze(P,p[2]))||_n),A.scale.multiply(this.object.scale),A.hiddenMatrix=this.object.hiddenMatrix}}getSurfaceSampler(){let e=this.objectForSample,r=e.geometry,n=r.getAttribute("position"),o=r.index,a=this.surfaceSamplerCache;if(a!==null&&a.geometry===r&&a.position===n&&a.positionVersion===Ky(n)&&a.index===o&&a.indexVersion===(o===null?-1:o.version))return a.sampler;let s=new jy(e).build();return this.surfaceSamplerCache={geometry:r,position:n,positionVersion:Ky(n),index:o,indexVersion:o===null?-1:o.version,sampler:s},s}invalidateSurfaceCaches(){this.surfaceSamplerCache=null,this.surfacePointsCache=null}getSubdivData(){if(!this.objectForSample)return[];let e=this.parameters.toObject.spreadType;if(e==="random")return[];let r=this.objectForSample instanceof Na,n=this.objectForSample.geometry;if(!r&&n){let l=this.surfacePointsCache,c=n.getAttribute("position");if(l!==null&&l.spreadType===e&&l.geometry===n&&l.position===c&&l.positionVersion===Ky(c)&&l.index===n.index&&l.indexVersion===(n.index===null?-1:n.index.version))return l.points}let o=new Map,a=(l,c)=>{let d=Math.round(l[0]*1e4)+"_"+Math.round(l[1]*1e4)+"_"+Math.round(l[2]*1e4),u=o.get(d);u?(u.pos[0]+=l[0],u.pos[1]+=l[1],u.pos[2]+=l[2],u.norm[0]+=c[0],u.norm[1]+=c[1],u.norm[2]+=c[2],u.count+=1):o.set(d,{pos:[...l],norm:[...c],count:1})};if(r){let l=this.objectForSample,c=Z2[e],d=gO[c],u=mO[c],p=yO[c],h=d(l.subdivPointerNew);for(let f=0;f<=h-1;f++){let m=u(l.subdivPointerNew,f),y=p(l.subdivPointerNew,f);iO.fromArray(m).applyMatrix4(l.matrixWorld),oO.fromArray(y),a(iO.toArray(),oO.toArray())}}else(n.index?J2(n):$2(n)).forEach((c,d)=>{e==="polygon_center"&&a(c.midpoint,c.norm),e==="vertex"&&(a(c.vertices[0],c.norm),a(c.vertices[1],c.norm),a(c.vertices[2],c.norm)),e==="edge"&&(a(c.faceCenters[0],c.norm),a(c.faceCenters[1],c.norm),a(c.faceCenters[2],c.norm))});let s=Array.from(o.values());for(let l of s)l.pos[0]/=l.count,l.pos[1]/=l.count,l.pos[2]/=l.count,l.norm[0]/=l.count,l.norm[1]/=l.count,l.norm[2]/=l.count;if(!r&&n){let l=n.getAttribute("position");this.surfacePointsCache={spreadType:e,geometry:n,position:l,positionVersion:Ky(l),index:n.index,indexVersion:n.index===null?-1:n.index.version,points:s}}return s}updateState(e,r){if(this.parameters=ys(e),this.parameters.type!=="toObject")this.invalidateSurfaceCaches(),(this.parent===null||this.parent!==this.object)&&(this.removeFromParent(),this.object.parent?.add(this),this.matrix=this.object.matrix,this.hiddenMatrix=this.object.hiddenMatrix,this.matrixWorldNeedsUpdate=!0,this.matrixAutoUpdate=!1);else if(this.parent===null||this.parent.uuid!==this.parameters.toObject.object){this.removeFromParent(),this.invalidateSurfaceCaches();let n=r.scene.find(this.parameters.toObject.object);n instanceof it?this.objectForSample=n:this.objectForSample=void 0,this.matrix=new Je.Matrix4,this.hiddenMatrix=new Je.Matrix4,this.matrixWorldNeedsUpdate=!0,this.matrixAutoUpdate=!1,n&&n.add(this)}this.update(r)}get pendingMediaLoad(){return this._pendingMediaLoad}};var mo=24,Br=96,Jo=LP(),La=2;var GS=!1,vO=!0;try{let i=new URLSearchParams(window.location.search);GS=i.get("dbgsbstatic")==="0",vO=i.get("sb512")!=="0"}catch{}function vV(i){let t=i.getAttribute("position");return t===void 0?-1:(t.version??t.data?.version??0)*1048576+(t.count??0)%1048576}var US=class extends tt{constructor(e,r,n){super(e,r,n);this.data=r;this.isShapeBlendEntity=!0;this.needsRebuild=!0;this.customDepthMaterialNeedsUpdate=!1;this._prevShapeData=null;this._prevSpan=-1;this._reach=new Float32Array(Br);this._prevReach=new Float32Array(Br);this._fieldDirtyFull=!0;this._fieldDirtyMin=new me.Vector3;this._fieldDirtyMax=new me.Vector3;this._maxBlendK=0;this._meshSdfBaked=new Map;this._meshSdfWanted=new Map;this._passesRenderer=null;this._npart=-1;this.spatialn=1;this.drawRangeNeedsForceUpdate=!0;this._resolutionLevel=-1;this._authoredResolutionLevel=-1;this.ultraFieldResolution=0;this.resolution=64;this.spatialDivisions=25;this.zLayersPerRow=8;this.basePyramidSize=512;this.pyramidTexture1Width=341;this.pyramidTexture1Height=256;this.pyramidTexture2Width=170;this.pyramidTexture2Height=128;this.numLevels=9;this.pyramidLevelSizes=[1,2,4,8,16,32,64,128,256,512];this.bboxSize=0;this.bboxOffset=0;this.shapesDataTexture={value:void 0};this.spatialscene=new me.Scene;this.potentialPassScene=new me.Scene;this.voxelPassScene=new me.Scene;this._spatialPassRenderTargets=[];this._potentialPassRenderTargets=[];this._voxelPassRenderTargets=[];this._pyramidRenderTargets=[];this.geometry=new me.BufferGeometry,this.geometry.drawRange.count=0,this.spatialPassUniforms={span:{value:-1},shapesDataTexture:this.shapesDataTexture,npart:{value:this.npart},spatialn:{value:this.spatialn}},this.spatialMesh=new me.Mesh(ed,this.spatialPassMaterial()),this.spatialMesh.frustumCulled=!1,this.spatialscene.add(this.spatialMesh);let o=new me.DataTexture(Jo.triTable,16,256,me.RedFormat,me.FloatType);o.needsUpdate=!0;let a=new me.DataTexture(Jo.numTrisTable,256,1,me.RedFormat,me.FloatType);a.needsUpdate=!0,this.voxelPassUniforms={potentialPassTexture:{value:void 0},numTrisTable:{value:a}},this.voxelMesh=new me.Mesh(ed,this.voxelPassMaterial()),this.voxelMesh.frustumCulled=!1,this.voxelPassScene.add(this.voxelMesh),this.potentialPassUniforms={shapesDataTexture:this.shapesDataTexture,spatialPassTexture:{value:void 0},npart:{value:this.npart},spatialn:{value:this.spatialn}},this.potentialMesh=new me.Mesh(ed,this.potentialPassMaterial()),this.potentialMesh.frustumCulled=!1,this.potentialPassScene.add(this.potentialMesh),this.marchPassUniforms={triTable:{value:o},potentialPassTexture:{value:void 0},voxelPassTexture:{value:void 0},pyramidTexture1:{value:void 0},pyramidTexture1Size:{value:void 0},pyramidTexture2:{value:void 0},pyramidTexture2Size:{value:void 0}},this.frustumCulled=!1,this.onBeforeShadowPass=s=>{let l=AV.call(this);if(this.npart===0){this.geometry.drawRange.count=0;return}let c=this.material.root;if(!c.shadersPatchedForShapeBlend)this.patchVertexShaderForShapeBlend(c),c.shadersPatchedForShapeBlend=!0,this.customDepthMaterialNeedsUpdate=!0;else if(this.customDepthMaterialNeedsUpdate){this.customDepthMaterialNeedsUpdate=!1,this.customDepthMaterial=new me.ShaderMaterial({vertexShader:c.vertexShader,fragmentShader:`
|
|
729
729
|
#include <packing>
|
|
730
730
|
void main()
|
|
731
731
|
{
|
|
@@ -1308,7 +1308,7 @@ void main() {
|
|
|
1308
1308
|
gl_FragColor = texture(inputTexture, vUv);
|
|
1309
1309
|
gVelocity = vec4(0.0);
|
|
1310
1310
|
}
|
|
1311
|
-
`,r.pyramidTextureSize.value=new me.Vector2(this.pyramidRenderTarget[0].width,this.pyramidRenderTarget[0].height),Object.assign(o.uniforms,r)};this.material.shapeBlendhack=n,this.material.root.shapeBlendhack=n}dispose(){super.dispose(),G2()?.release(this)}},Jp=US;Jp.streamCompaction=new ly;var bV=new me.Matrix4,xV=new me.Matrix4,wd=new me.Quaternion,Fl=new me.Vector3,Jy=new me.Vector3,SV=new me.Quaternion;function wV(i,t=0){let e=this.children.length;for(;e--;){let r=this.children[e];Pa.is(r)&&bO.call(r,i,t+1)}}function bO(i,t=0){if(i(this,t)!==!0){let r=this.children.length;for(;r--;){let n=this.children[r];Pa.is(n)&&bO.call(n,i,t+1)}}}function AV(){if(this.shapesDataTexture.value===void 0){let y=new me.DataTexture(new Float32Array(4*Br*Ma),Br,Ma,me.RGBAFormat,me.FloatType);this.shapesDataTexture.value=y}let i=this.shapesDataTexture.value,t=i.image.data,e=0,r=0,n=this.data.geometry.blendRange,o=bV.copy(this.matrixWorld).invert(),a=this._npart,s=0;this._meshSdfWanted.clear();let l=null;if(wV.call(this,y=>{if(y.visible===!1)return!0;let g;if(y instanceof Fn)return;if(y instanceof vd||Ap(y))return;y instanceof Rr?g=y.object:g=y;let v=y.data?.cloner;if(Le.is(y)&&v&&!v.hideBase&&v.type!=="radial"&&v.disabled!==!0||!(g instanceof tt))return;let b=g.geometry.userData.parameters,S=b?.shapeBlendNode??g.dataPatched?.geometry?.shapeBlendNode;if(S===void 0)return;if(xV.multiplyMatrices(o,y.matrixWorld).decompose(Jy,wd,Fl),b?.type==="TorusGeometry"&&b.arc!==360){let E=b.arc*Math.PI/180;E=E/4,wd.multiply(SV.set(0,0,Math.sin(E),Math.cos(E)))}let w=S.overrideGlobalBlend?S.blendRange:n;w=w/this.bboxSize*2,t[s*4]=(Jy.x-this.bboxOffset)/this.bboxSize*2,t[s*4+1]=(Jy.y-this.bboxOffset)/this.bboxSize*2,t[s*4+2]=(Jy.z-this.bboxOffset)/this.bboxSize*2,t[s*4+3]=S.operation===0?1:S.operation===2?-1:-2,t[Br*4+s*4]=-wd.x,t[Br*4+s*4+1]=-wd.y,t[Br*4+s*4+2]=-wd.z,t[Br*4+s*4+3]=wd.w;let A=new Float32Array(4),C=0,P=w;if(b?.type==="SphereGeometry")b.width===b.height&&b.width===b.depth?A[0]=0:A[0]=1,A[1]=b.width/this.bboxSize,A[2]=b.height/this.bboxSize,A[3]=b.depth/this.bboxSize,P=Math.max(A[1],A[2],A[3])*Fl.x+w;else if(b?.type==="CubeGeometry"){C=b.cornerRadius;let E=b.width,R=b.height,L=b.depth;A[0]=2,A[1]=(E-2*C)/this.bboxSize,A[2]=(R-2*C)/this.bboxSize,A[3]=(L-2*C)/this.bboxSize,P=Math.sqrt(E**2+R**2+L**2)/this.bboxSize*Fl.x+w}else if(b?.type==="CylinderGeometry"){C=b.cornerRadius;let E=b.height,R=b.radiusBottom,L=b.radiusTop;if(L>=R){let F=Math.atan2(L-R,E),k=(Math.PI/2-F)/2;L-=C/Math.tan(k),R-=C*Math.tan(k)}else if(R>L){let F=Math.atan2(R-L,E),k=(Math.PI/2-F)/2;L-=C*Math.tan(k),R-=C/Math.tan(k)}A[1]=(b.height-2*C)/this.bboxSize,R===L?(A[0]=3,A[2]=R/this.bboxSize*2):(A[0]=4,A[2]=R/this.bboxSize*2,A[3]=L/this.bboxSize*2),P=(Math.hypot(A[1],Math.max(Math.abs(A[2]),Math.abs(A[3])))+C/this.bboxSize*2)*Fl.x+w}else if(b?.type==="TorusGeometry"){if(A[0]=5,A[1]=(b.width-b.depth)/this.bboxSize,A[2]=b.depth/this.bboxSize,b.arc!==360){A[0]=6,A[3]=A[1],t[Br*12+s*4+3]=A[2];let E=2*Math.atan2(A[2]/2,A[1]),R=b.arc*Math.PI/180/2-E;A[1]=Math.sin(R),A[2]=Math.cos(R)}P=b.width*Fl.x/this.bboxSize+w}else{let E=g.geometry;(l??(l=new Set)).add(E.uuid);let R=this._meshSdfBaked.get(E.uuid),L=vV(E);if((R===void 0||R.posVersion!==L)&&this._meshSdfWanted.set(E.uuid,E),R===void 0)return;A[0]=7,A[1]=R.slot,A[2]=R.boxHalf.x/this.bboxSize*2,A[3]=R.boxHalf.y/this.bboxSize*2,t[Br*12+s*4+3]=R.boxHalf.z/this.bboxSize*2,P=Math.hypot(R.boxHalf.x,R.boxHalf.y,R.boxHalf.z)/this.bboxSize*2*Fl.x+w}t.set(A,Br*8+s*4),e=Math.max(e,P),r=Math.max(r,w),this._reach[s]=P,t[Br*12+s*4]=w,t[Br*12+s*4+1]=C/this.bboxSize*2,t[Br*12+s*4+2]=Fl.x;let M=Array.isArray(g.material)?g.material[0]:g.material,B=M,I,_;if(B?.getShapeBlendBaseColor){let E=B.getShapeBlendBaseColor();I=E,_=E.a}else M?.uniforms?.nodeU0!==void 0?(I=M.uniforms.nodeU0.node.value,_=M.uniforms.nodeU1?.value??1):(I={r:1,g:1,b:1},_=1);S.operation!==0&&!S.useColor&&(_=-1),t[Br*16+s*4]=I.r,t[Br*16+s*4+1]=I.g,t[Br*16+s*4+2]=I.b,t[Br*16+s*4+3]=_,_<1&&this.material.defines?.SHAPEBLEND_C===1&&this.material.setTransparent(!0),s++}),this._meshSdfBaked.size>0){let y=l??new Set;for(let g of this._meshSdfBaked.keys())y.has(g)||this._meshSdfBaked.delete(g)}this.npart=s,this._maxBlendK=r;let c=e*1.1+2/(this.spatialDivisions-1)+4/(this.resolution-1);this.spatialPassUniforms.span.value=c;let d=this._prevShapeData,u=a!==s,p=d===null||this._prevSpan!==c||u,h=p||GS,f=this._fieldDirtyMin.set(1/0,1/0,1/0),m=this._fieldDirtyMax.set(-1/0,-1/0,-1/0);if(d!==null){let y=Math.max(s,a);for(let g=0;g<y;g++){let v=!1;for(let B=0;B<Ma;B++){let I=Br*4*B+g*4;if(t[I]!==d[I]||t[I+1]!==d[I+1]||t[I+2]!==d[I+2]||t[I+3]!==d[I+3]){v=!0;break}}if(!v)continue;if(p=!0,h)break;let b=t[g*4],S=t[g*4+1],x=t[g*4+2],w=d[g*4],A=d[g*4+1],C=d[g*4+2],P=this._reach[g],M=this._prevReach[g];if(!Number.isFinite(b+S+x+P)||!Number.isFinite(w+A+C+M)){h=!0;continue}f.x=Math.min(f.x,b-P,w-M),f.y=Math.min(f.y,S-P,A-M),f.z=Math.min(f.z,x-P,C-M),m.x=Math.max(m.x,b+P,w+M),m.y=Math.max(m.y,S+P,A+M),m.z=Math.max(m.z,x+P,C+M)}}return GS&&(p=!0),this._fieldDirtyFull=h||f.x===1/0,p&&(d===null?this._prevShapeData=new Float32Array(t):d.set(t),this._prevReach.set(this._reach),this._prevSpan=c,i.needsUpdate=!0),p}Oi("ShapeBlendGeometry",(i,t,e)=>new Jp(i,t,e));Pe("shape-blends");var $y=class extends tt{get forceComputeSize(){return!0}get shape(){return this.geometry.userData.shape}updateEntityBoxSize(t,e){let r=this.geometry.getAttribute("position");r!==void 0?Dp(r,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:r.count,t,e):super.updateEntityBoxSize(t,e)}};Oi("VectorGeometry",(i,t,e)=>new $y(i,t,e));Pe("vector-shapes");var eg=class extends tt{constructor(e,r,n){super(e,r,n);this.isPathObject=!0;this._shapeId=null;this._lastShapeParams=null;this._lastShape=null;this._context=n}get profileShape(){return this._lastShape??void 0}updateState(e,r){super.updateState(e,r),this.updateShape(),this.refreshAttachedCloners(r)}updateShape(){let e={...this.data.geometry.extrusion.shape};for(let o in e)typeof e[o]=="string"&&(e[o]=this._context.shared.getVariable(e[o],[this.uuid,"geometry","extrusion","shape",o]));let r;if(e.type==="Custom"){let o=e.shapeId;if(o!==this._shapeId&&this.detachShape(),o){this._shapeId=o;let a=this._context.scene.find(o);a?.data&&(a.attachedPaths.add(this),r=a.geometry.userData?.shape),r||this._context.scene.addPendingCommand(()=>this.updateShape())}}else if(this._lastShape!==null&&this._sameShapeParams(e))r=this._lastShape;else{let o;switch(e.type){case"Rectangle":o=ud;break;case"Ellipse":o=cd;break;case"Polygon":o=Py;break;case"Star":o=My;break;default:throw new Error(`Unknown shape type: ${e.type}`)}r=o.create({parameters:e}).userData.shape,this._lastShapeParams=e,this._lastShape=r??null}let n=this.geometry;if(r&&n.inputs){if(this._lastShape=r,e.type==="Custom"&&(this._lastShapeParams=null),n.inputs.shapeData===r)return;n.inputs.shapeData=r,n.build()}}_sameShapeParams(e){let r=this._lastShapeParams;if(r===null)return!1;for(let n in e)if(!Object.is(e[n],r[n]))return!1;for(let n in r)if(!(n in e))return!1;return!0}detachShape(){this._shapeId!==null&&this._context.scene.find(this._shapeId)?.attachedPaths.delete(this)}supportsInPlaceGeometryUpdate(){return!1}createGeometryDelayed(e){this.geometryCreateDeleyed=e.shared,this.updateShape(),this.refreshAttachedPaths(e)}updateTransformState(e,r){return super.updateTransformState(e,r)}updateGeometryInteractions(e,r){super.updateGeometryInteractions(e,r),this.updateShape()}updateEntityBoxSize(e,r){let n=this.geometry.getAttribute("position");n!==void 0&&n.count>0?Dp(n,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:n.count,e,r):super.updateEntityBoxSize(e,r)}};var ke=require("three");function xO(i,t){let e=2*Math.PI;return(i%e+e)%e===(t%e+e)%e}var SO=new ke.Matrix4,CV=new ke.Matrix4,EV=new ke.Matrix4().makeScale(1,1,-1),wO=new ke.Vector3,AO=new ke.Vector3,zS=new ke.Vector3,TV=new ke.Vector3,PV=new ke.Vector3,MV=new ke.Vector3,OV=new ke.Vector3,CO=new WeakMap,jS=new WeakMap;function IV(i,t,e){let r=[new ke.Vector3,new ke.Vector3,new ke.Vector3],n=[new ke.Vector3,new ke.Vector3,new ke.Vector3];return i.extractBasis(r[0],r[1],r[2]),t.extractBasis(n[0],n[1],n[2]),r.forEach((o,a)=>{let s=n[a],l=ke.MathUtils.lerp(o.length(),s.length(),e);o.lerp(s,e).setLength(l)}),new ke.Matrix4().makeBasis(r[0],r[1],r[2])}function EO(i){i.setIndex(null),i.setAttribute("position",new ke.BufferAttribute(new Float32Array(0),3)),i.setAttribute("normal",new ke.BufferAttribute(new Float32Array(0),3)),i.setAttribute("uv",new ke.BufferAttribute(new Float32Array(0),2)),i.setDrawRange(0,0)}var TO=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,height:100,depth:1,subdivisions:12,roundness:0,extrudeBevelSize:0,extrudeBevelSegments:3},i.parameters),r=Math.abs(e.width),n=Math.abs(e.height??e.width),o=Math.abs(e.depth??0),a=i.shapeData??t?.shapeData??cd.create({parameters:{...fl,width:typeof fl.width=="number"?fl.width:100,height:typeof fl.height=="number"?fl.height:100}}).userData.shape;return{ownerId:i.ownerId??t?.ownerId,path:i.path??Oc.defaultData(),parameters:Object.assign(e,{width:r,height:n,depth:o,extrusion:{...gm,...e.extrusion}}),shapeData:a}}static build(i){if(i.path.points.length>=2){let e=new HS(i);return Object.assign(e,{userData:{...i,type:"PathGeometry"}})}else{let e=new ke.BufferGeometry;return EO(e),Object.assign(e,{userData:{...i,type:"PathGeometry"}})}}},HS=class extends ke.BufferGeometry{constructor(e){super();this.type="PathExtrusionGeometry",this.inputs=e,this.build()}_isGeometryClosed(){return this.inputs.path.isClosed&&this.inputs.parameters.extrusion.depth===1}_isOpenEnded(){let e=this.inputs.parameters.extrusion;return!(this.inputs.path.isClosed&&e.depth===1)||!xO(e.twist,0)||e.startScale!==e.endScale}build(){let{points:e,matrices:r}=this._getSampledPath();if(e.length<2){EO(this);return}let{depth:n,offset:o}=this.inputs.parameters.extrusion;n=Math.max(0,Math.min(n,1)),o=Math.max(0,Math.min(o,1));let a=this.inputs.path.isClosed?e.length:e.length-1,s=Math.floor(o*a),l=this.inputs.path.isClosed?Math.ceil((n+o)*a):Math.ceil(Math.min(1,n+o)*a),c=Math.min(Math.max(2,l-s+1),a+2),d=[],u=[];for(let Y=0;Y<c;Y++){let K=this.inputs.path.isClosed?(Y+s)%e.length:Math.min(Y+s,e.length-1);d.push(e[K].clone()),u.push(r[K].clone())}let p=(Y,K,te)=>{d[Y]=d[Y].clone().lerp(d[K],te),u[Y]=IV(u[Y],u[K],te)},h=0,f=o*a%1;(!this.inputs.path.isClosed||n<=1)&&(f||o===0)&&(h=f,p(0,1,h));let m=0,y=(o+n)*a%1;if((this.inputs.path.isClosed&&n<=1||!this.inputs.path.isClosed&&o+n<1)&&y&&(m=y,p(d.length-1,d.length-2,1-m)),n===0){let Y=d.length-1;d[Y].copy(d[0]),u[Y].copy(u[0])}this._applyPathModifiers(u,h,m);let{bevel:g,bevelSides:v}=this.inputs.parameters.extrusion,b=5;this.inputs.parameters.extrusion.shape.type==="Custom"&&(b=this.inputs.parameters.extrusion.shape.shapeQuality==="low"?5:12);let{regions:S,infos:x,vertices:w}=this._getShapePoints(b),A=g>0?this.inputs.parameters.extrusion.capType:"flat",C=A==="round"?TM(this.inputs.shapeData,g,v,b,this.inputs.ownerId):void 0,P=C!==void 0&&this.inputs.parameters.extrusionVersion===1?Sy(C):C,M=A==="round"&&P===void 0?"flat":A,B=P!==void 0?P.positions.length/3:0,I=0,_=0;x.sort((Y,K)=>Y.start-K.start),x.forEach(Y=>{Y.verticesStart=I,Y.verticesCount=Y.continuous.reduce((K,te,ue)=>K+(ue===0||!te?2:1),0),_+=Y.verticesCount,I=_});let E=_*c,R,L=0;this._isOpenEnded()&&M==="flat"&&(R=this._getSurfaceTesselation(S),L=R.vertexCount);let F=E+2*L+B*2,k=E+2*L,W={positions:new Float32Array(F*3),normals:new Float32Array(F*3),uvs:new Float32Array(F*2)},U=0;x.forEach(Y=>{U+=Y.count});let G=U*(c-1)*6+(R?2*R.elementCount*3:0)+(P!==void 0?2*P.indices.length:0),q=new Uint32Array(G),X=0;if(x.forEach(Y=>{X=this._extrudeRegion(Y,w,u,d,W,q,X,this._isGeometryClosed()&&!this._isOpenEnded())}),R&&(X=this._closeEnd(R,E,q,X,W,u[0],d[0],!1),X=this._closeEnd(R,E+L,q,X,W,u[u.length-1],d[d.length-1],!0)),P!==void 0){let Y={positions:W.positions,normals:W.normals,uvs:W.uvs,indices:q};Gp(P,Y,k,X,SO.copy(u[0]).setPosition(d[0]).multiply(EV),(K,te,ue)=>[ue,1e-4]),X+=P.indices.length,k+=B,Gp(P,Y,k,X,SO.copy(u[u.length-1]).setPosition(d[d.length-1]),(K,te,ue)=>[ue,1]),X+=P.indices.length}this.setAttribute("position",new ke.BufferAttribute(W.positions,3)),this.setAttribute("normal",new ke.BufferAttribute(W.normals,3)),this.setAttribute("uv",new ke.BufferAttribute(W.uvs,2)),this._setIndexFromUint32(q)}_setIndexFromUint32(e){let r=!1;for(let n=e.length-1;n>=0;--n)if(e[n]>=65535){r=!0;break}this.setIndex(new ke.BufferAttribute(r?e:new Uint16Array(e),1))}_getSampledPath(){let e=this.inputs.path,r=zm(e),n=CO.get(r);if(n===void 0||n.subdivisions!==e.subdivisions||n.subdivisionMode!==e.subdivisionMode){let o=this._extractPathPoints(r),a=o.length<2?[]:this._computeBasisMatrices(o);n={subdivisions:e.subdivisions,subdivisionMode:e.subdivisionMode,points:o,matrices:a},CO.set(r,n)}return n}_extractPathPoints(e){let r=this.inputs.path.subdivisions,n=this.inputs.path.subdivisionMode==="uniform"?e.getSpacedPoints(r*4):e.getPoints(r);if(n.length<2)return[];let o=[n[0]];return n.forEach(s=>{o[o.length-1].distanceToSquared(s)>.001&&o.push(s)}),this.inputs.path.isClosed&&o[o.length-1].distanceTo(o[0])<.001&&o.pop(),o}_computeBasisMatrices(e){let r=[],n=e.length,o=this.inputs.path.isClosed,a=new ke.Vector3,s=new ke.Vector3,l=new ke.Vector3,c=new ke.Vector3,d=new ke.Vector3(0,1,0);for(let y=0;y<n;y++){let g=e[y],v;y===0?v=o?e[n-1]:wO.copy(g).multiplyScalar(2).sub(e[1]):v=e[y-1];let b;y===n-1?b=o?e[0]:wO.copy(g).multiplyScalar(2).sub(e[y-1]):b=e[y+1],AO.subVectors(g,v).normalize(),zS.subVectors(b,g).normalize();let S=TV.addVectors(AO,zS);S.lengthSq()<1e-10&&(S.copy(zS),S.dot(l)<0&&S.negate()),S.normalize(),l.copy(S),y===0&&(S.equals(d)||PV.copy(S).negate().equals(d))&&d.set(0,0,1);let x=MV.crossVectors(d,S).normalize(),w=OV.crossVectors(S,x).normalize();d.copy(w),c.copy(x),y===0&&(a.copy(w),s.copy(S));let A=new ke.Matrix4().makeBasis(x,w,S);r.push(A)}let u=o?s:l,p=o?a:new ke.Vector3(0,1,0),h=u.clone().cross(c).normalize(),f=Math.acos(p.dot(h));if(isNaN(f))return r;let m=p.clone().cross(h);u.dot(m)>0&&(f*=-1);for(let y=1;y<r.length;y++)r[y].multiply(CV.makeRotationZ(f*y/r.length));return r}_applyPathModifiers(e,r,n){let o=e.length,{angle:a,twist:s,startScale:l,endScale:c}=this.inputs.parameters.extrusion,d=new ke.Matrix4,u=new ke.Matrix4;return e.forEach((p,h)=>{let f=h===0?0:h===o-1?1:(h-r)/(o-(n===0?0:1)-(r+(1-n)));d.makeRotationZ(ke.MathUtils.lerp(a,a+s,f)*ke.MathUtils.DEG2RAD);let m=ke.MathUtils.lerp(l,c,f);u.makeScale(m,m,m),p.multiply(d).multiply(u)}),e}_getShapePoints(e,r=Tt.ODD){let n=this.inputs.shapeData,o=jS.get(n);return(o===void 0||o.curveSegments!==e||o.windingRule!==r)&&(o={curveSegments:e,windingRule:r,shapePoints:this._computeShapePoints(e,r)},jS.set(n,o)),o.shapePoints}_getSurfaceTesselation(e){let r=jS.get(this.inputs.shapeData);if(r?.surfaceTesselation!==void 0)return r.surfaceTesselation;let n;try{n=Ss({windingRule:Tt.ODD,elementType:kr.POLYGONS,polySize:3,vertexSize:2,strict:!0,contours:e})}catch{n=xy}return r!==void 0&&(r.surfaceTesselation=n),n}_computeShapePoints(e=12,r=Tt.ODD){let n=this.inputs.shapeData,o=n.extractShapePointsToFlatArray([],e),a=n.shapeHoles.map(m=>{let y=m.extractShapePointsToFlatArray([],e),g=[];for(let v=y.length-1;v>=1;v-=2){let b=y[v-1],S=y[v-0];g.push(b,S)}return g}),s;try{s=Ss({windingRule:r,elementType:kr.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[o]})}catch{s=by}let l;try{l=Ss({windingRule:Tt.ODD,elementType:kr.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...a]})}catch{l=vM}if(!s)throw new Error("error generating geometry");let c=s.elementCount;if(l){s.elementCount+=l.elementCount;for(let m=0;m<l.elements.length;m++){let y=l.elements[m],g=m%2===0?s.vertexCount:0;s.elements.push(y+g)}for(let m=0;m<l.vertexIndices.length;m++){let y=l.vertexIndices[m],g=s.vertexCount;s.vertexIndices.push(y+g)}for(let m=0;m<l.vertices.length;m++){let y=l.vertices[m];s.vertices.push(y)}}let d=1/0,u=-1/0,p=1/0,h=-1/0;for(let m=0,y=s.vertexCount;m<y;m++){let g=m*2,v=s.vertices[g+0],b=s.vertices[g+1];v<d&&(d=v),v>u&&(u=v),b<p&&(p=b),b>h&&(h=b)}let f=[];for(let m=s.elementCount-1;m>=0;m--){let y=m>=c,g=m*2,v=s.elements[g+0],b=s.elements[g+1],S=v+b,x={start:v,count:b,normals:[],isHole:y,continuous:[],verticesStart:0,verticesCount:0};f.push(x);let w=v,A=S-1,C=v+1,P=n.roundedCurves.length;do{let M=w-v,B=s.vertices[A*2+0],I=s.vertices[A*2+1],_=s.vertices[w*2+0],E=s.vertices[w*2+1],R=s.vertices[C*2+0],L=s.vertices[C*2+1],F=_-B,k=E-I,W=Math.sqrt(F*F+k*k);F/=W,k/=W;let U=_-R,G=E-L,q=Math.sqrt(U*U+G*G);U/=q,G/=q,x.normals[M*2+0]=-G,x.normals[M*2+1]=U;let X=s.vertexIndices[w];if(Array.isArray(X))x.continuous[M]=!1;else{let[Y,K]=n.getCurveIndexFromVertexId(X-1,!0);if(K>0&&K<1)x.continuous[M]=!0;else{let te=K===1?Y+1:Y-1;te=(te+P)%P;let ue=K===1?0:1,se=n.roundedCurves[Y].getTangent(K),ce=n.roundedCurves[te].getTangent(ue);x.continuous[M]=se.dot(ce)>.95}}y&&(x.normals[M*2+0]*=-1,x.normals[M*2+1]*=-1),[A,w,C]=[w,C,C+1],C>=S&&(C-=b)}while(C!==v+1)}return{regions:[o,...a],infos:f,vertices:s.vertices}}_insertVertex(e,r,n,o,a){let s=r*2,l=r*3;e.positions[l+0]=n.x,e.positions[l+1]=n.y,e.positions[l+2]=n.z,e.normals[l+0]=o.x,e.normals[l+1]=o.y,e.normals[l+2]=o.z,e.uvs[s+0]=a.x,e.uvs[s+1]=a.y}_extrudeRegion(e,r,n,o,a,s,l,c){let d=e.wallTemplate;if(d===void 0){d=[];for(let S=0;S<e.count;S++){let x=(e.start+S)*2,w=r[x+0],A=r[x+1],C,P;if(e.continuous[S])C=e.normals[S*2+0],P=e.normals[S*2+1];else{let B=S===0?(e.start+e.count-1)*2:x-2,I=w-r[B+0];C=-(A-r[B+1]),P=I,e.isHole||(C=-C,P=-P)}let M=S===0?1:S/e.count;if(d.push(w,A,C,P,M,0),!e.continuous[S]||S===0)if(S===0)d.push(w,A,e.normals[0],e.normals[1],0,1);else{let B=S===e.count-1?e.start*2:x+2,I=r[B+0]-w;C=-(r[B+1]-A),P=I,e.isHole||(C=-C,P=-P),d.push(w,A,C,P,M,1)}}e.wallTemplate=d}let u=n.length,p=d.length,h=a.positions,f=a.normals,m=a.uvs;for(let S=0;S<u;S++){let x=n[S].elements,w=x[0],A=x[1],C=x[2],P=x[4],M=x[5],B=x[6],I=x[12],_=x[13],E=x[14],R=o[S],L=S/(u-1),F=0,k=0,W=0,U=e.verticesStart*u+e.verticesCount*S;for(let G=0;G<p;G+=6){if(d[G+5]===0){let de=d[G+0],ge=d[G+1];F=w*de+P*ge+I+R.x,k=A*de+M*ge+_+R.y,W=C*de+B*ge+E+R.z}let q=d[G+2],X=d[G+3],Y=w*q+P*X+I,K=A*q+M*X+_,te=C*q+B*X+E,ue=1/(Math.sqrt(Y*Y+K*K+te*te)||1);Y*=ue,K*=ue,te*=ue;let se=U*2,ce=U*3;h[ce+0]=F,h[ce+1]=k,h[ce+2]=W,f[ce+0]=Y,f[ce+1]=K,f[ce+2]=te,m[se+0]=d[G+4],m[se+1]=L,U++}}let y=e.wallQuadPattern;if(y===void 0){y=[];let S=0;for(let x=0;x<e.count;x++)(!e.continuous[x]||x===0)&&S++,y.push(S,x===e.count-1?0:S+1),S++;e.wallQuadPattern=y}let g=u-1,v=y.length,b=e.isHole;for(let S=0;S<g;S++){let x=e.verticesStart*u+e.verticesCount*S,w=x+e.verticesCount;for(let A=0;A<v;A+=2){let C=x+y[A],P=x+y[A+1],M=w+y[A+1],B=w+y[A];b?(s[l++]=C,s[l++]=M,s[l++]=P,s[l++]=C,s[l++]=B,s[l++]=M):(s[l++]=C,s[l++]=P,s[l++]=M,s[l++]=C,s[l++]=M,s[l++]=B)}}return l}_closeEnd(e,r,n,o,a,s,l,c){let d=e.vertexCount,u=new ke.Vector3(0,0,c?-1:1).applyMatrix4(s),p=new ke.Vector3,h=new ke.Vector2;for(let m=0;m<d;m++){let y=2*m;p.set(e.vertices[y+0],e.vertices[y+1],0).applyMatrix4(s).add(l),this._insertVertex(a,r+m,p,u,h)}let f=e.elements;for(let m=0;m<e.elementCount;m++){let y=3*m;n[o++]=f[y+0]+r,n[o++]=f[y+(c?1:2)]+r,n[o++]=f[y+(c?2:1)]+r}return o}};Oi("PathGeometry",(i,t,e)=>new eg(i,t,e));Ep("PathGeometry",TO);Pe("3d-paths");Mi.Cloner=Fn;Pe("cloners");gt();var Ad=require("three");function $p(i){if(i.component){let t=i.component.instances.indexOf(i);t>=0&&i.component.instances.splice(t,1);for(let e of i.children)Le.is(e)&&$p(e)}}var eh=class extends ki(Ad.Group,Fi){constructor(e,r,n){super();this.isComponentObject=!0;r.type==="Instance"&&typeof e=="string"&&(r=this.transformAssignData(r,n)),this.super_Entity(e,r),this.objectHelper.update()}get isComponentRoot(){return this.data.type==="Component"&&typeof this.identity=="string"}get isInstanceRoot(){return this.data.type==="Instance"&&typeof this.identity=="string"}transformAssignData(e,r){let n=fs.getComponentData({scene:r.scene.data,shared:r.shared.data},e.component);if(n){let o,a;for(let s of No.rootOverrideProps)e[s]===void 0?(o===void 0&&(o={...e}),o[s]=n.data[s]):(a===void 0&&(a={}),a[s]=e[s],o===void 0&&(o={...e}),o[s]=Mo.apply(n.data[s],e[s]));return this.overrideData=a,o}else return{...yr.defaultData,...e,...Sp(yr.defaultData,No.rootOverrideProps)}}updateByOp(e,r,n,o){let a;if(this.isInstanceRoot&&!o){if(r=this.transformAssignData(r,n),e.type===0&&e.path.length===0&&this.component)for(let s of No.rootOverrideProps)s in e.props&&e.props[s]===void 0&&(a===void 0&&(a={...e,props:{...e.props}}),a.props[s]=this.component.data[s]);else if(e.type===0&&e.path.length>0&&No.rootOverrideProps.includes(e.path[0])){let s=e.path[0];a===void 0&&(a={...e,path:[],props:{[s]:r[s]}})}}super.updateByOp(a??e,r,n,o)}updateState(e,r){this.updateState_Entity(e,r)}expandInstanceChildren(e){let r=this.data;if(this.component===void 0){let n=e.scene.find(r.component)??null,o=!1;if(n!==this.oldComponent){if(this.oldComponent){let a=0;for(let s of this.children)if(Le.is(s))e.scene.disposeAndUnregisterEntityRecursivelyIfNotReregistered(s),$p(s),a+=1;else break;this.children.splice(0,a)}o=!0}if(n){let a={};MO(e,[this.uuid],r.overrides,this,n,n,0,o,a);for(let s of this.children)if(Le.is(s)){let l=s.data;l.type==="Empty"&&l.animations&&s.traverseEntity(c=>{let d=c.dataPatched;if(c instanceof tt&&d.bones&&d.boneInverses){let u=c.dataPatched;if(u.bones&&u.boneInverses){let p=u.bones.map(m=>e.scene.find(a[m])),h=u.boneInverses.map(m=>new Ad.Matrix4().fromArray(m)),f=new Ad.Skeleton(p,h);c.bind(f,c.bindMatrix)}}else c.matrixAutoUpdate=!0})}}this.oldComponent=this.component}}};function PO(i,t,e,r){return i.component===t&&so(i.identity,r)?i.overrideData===e?2:1:0}function MO(i,t,e,r,n,o,a,s,l){if(a>50)return!1;if(r.component!==n){if(r.component){let d=r.component.instances.indexOf(r);d>=0&&r.component.instances.splice(d,1)}n.instances.find(d=>d===r)||n.instances.push(r),r.component=n}n instanceof eh&&n.isInstanceRoot&&n.expandInstanceChildren(i);let c=0;for(let d of n.children)if(Le.is(d)){let u=[...t,...typeof d.identity=="string"?[d.identity]:d.identity],p=Dc.resolve(e,u,1);p!=null&&!(p instanceof bt)&&(Object.setPrototypeOf(p,bt.prototype),console.error("wrong prototype"));let h=null,f;if(!s){let m=r.children[c];if(h=Le.is(m)?m:null,h!==null){let y=PO(h,d,p,u);f=y>=1?h.stateSelection:void 0,y!==2&&(h=null)}if(h===null&&(h=i.scene.findInstance(u)??null,h!==null)){let y=PO(h,d,p,u);if(f=y>=1?h.stateSelection:void 0,y!==2)h=null;else{let g=h.parent.children.indexOf(h);h.parent.children.splice(g,1),r.children.splice(c,0,h),h.parent===r?(g<=c&&console.error("not possible"),void 0):(h.parent=r,h.matrixWorldNeedsUpdate=!0,h.resetBBoxNeedsUpdate(),h.updateVisible(),i.pendingDeletes.delete(h),void 0)}}}if(h===null){let m=p?Mo.apply(d.data,p):d.data;no.is(m.type)&&(m={...m,type:"Empty"}),h=Mi.createEntity(u,m,i),h.overrideData=p,r.add(h),r.children.splice(r.children.length-1,1),r.children.splice(c,0,h),h.updateState(h.data,i),f&&h.changeSelectedState(f,i),i.scene.registerInstanceAndSetUuid(h)}if(h.isBone){let m=h.identity[h.identity.length-1];l[m]=h.uuid}c+=1,MO(i,t,e,h,d,o,a+1,s,l)}if(!s){let d=c;for(;;){let u=r.children[c];if(Le.is(u))i.pendingDeletes.add(u);else break;c+=1}r.children.splice(d,c-d)}return!0}var OO=(i,t,e)=>new eh(i,t,e);wl("Component",OO);wl("Instance",OO);Pe("components");var WS=1e-10;function IO(i){let t=i[0][0],e=i[1][0],r=i[0][1],n=i[1][1],o=Math.sqrt(t*t+e*e),a=o>WS?t/o:1,s=o>WS?e/o:0,l=a*t+s*e,c=a*n-s*r,d=a*r+s*n;return{rotation:Math.atan2(s,a),scale:[l,c],shear:[Math.abs(c)>WS?d/c:0,0]}}function DO({rotation:i,scale:t,shear:e}){let r=Math.cos(i),n=Math.sin(i),o=e[0]*t[1],a=e[1]*t[0];return[r*t[0]-n*a,n*t[0]+r*a,r*o-n*t[1],n*o+r*t[1]]}var Oe;(x=>{function i(){return[1,0,0,0,1,0,0,0,1]}x.identity=i;function t(w,A=x.identity()){for(let C=0,P=w.length;C<P;C++)A[C]=w[C];return A}x.copy=t;function e(w,A,C,P,M,B){return x.setAbcdef(x.identity(),w,A,C,P,M,B)}x.create=e;function r(w,A,C,P,M,B,I){return w[0]=A,w[1]=P,w[2]=B,w[3]=C,w[4]=M,w[5]=I,w}x.setAbcdef=r;function n(w,A){let[C,P,M,B,I,_]=a(w),[E,R,L,F,k,W]=a(A),U=E*C+R*M,G=E*P+R*B,q=L*C+F*M,X=L*P+F*B,Y=k*C+W*M+I,K=k*P+W*B+_;return x.create(U,G,q,X,Y,K)}x.append=n;function o(w,A){let[C,P,M,B,I,_]=a(w),[E,R,L,F,k,W]=a(A),U=C,G=P,q=M,X=B;(E!==1||R!==0||L!==0||F!==1)&&(U=C*E+P*L,G=C*R+P*F,q=M*E+B*L,X=M*R+B*F);let Y=I*E+_*L+k,K=I*R+_*F+W;return x.create(U,G,q,X,Y,K)}x.prepend=o;function a(w){return[w[0],w[3],w[1],w[4],w[2],w[5]]}x.getAbcdef=a;function s(w){let[A,C,P,M,B,I]=x.getAbcdef(w),_=A*M-C*P,E=M/_,R=-C/_,L=-P/_,F=A/_,k=(P*I-M*B)/_,W=-(A*I-C*B)/_;return x.create(E,R,L,F,k,W)}x.invert=s;function l([w,A],C){let[P,M,B,I,_,E]=x.getAbcdef(C);return[P*w+B*A+_,M*w+I*A+E]}x.apply=l;function c(w,A){let[C,P,M,B,I,_]=x.getAbcdef(A),E=1/(C*B+M*-P),[R,L]=w;return[B*E*R+-M*E*L+(_*M-I*B)*E,C*E*L+-P*E*R+(-_*C+I*P)*E]}x.applyInverse=c;function d(w,A,C=A){let[P,M,B,I,_,E]=x.getAbcdef(w);return x.setAbcdef(w,P*A,M*C,B*A,I*C,_*A,E*C),w}x.scale=d;function u(w,A){let C=Math.cos(A),P=Math.sin(A),[M,B,I,_,E,R]=x.getAbcdef(w);return x.setAbcdef(w,M*C-B*P,M*P+B*C,I*C-_*P,I*P+_*C,E*C-R*P,E*P+R*C),w}x.rotate=u;function p(w,A,C){let[P,M]=C,B=x.translate(w,-P,-M);return B=x.rotate(B,A),B=x.translate(B,P,M),B}x.rotateAround=p;function h(w,A,C){let[P,M,B,I,_,E]=x.getAbcdef(w);return x.setAbcdef(w,P,M,B,I,_+A,E+C),w}x.translate=h;function f(w,A,C){let[P,M,B,I]=x.getAbcdef(w);return x.setAbcdef(w,P,M,B,I,A,C),w}x.setTranslate=f;function m(w,A,C){let[P,M,B,I]=x.getAbcdef(w);return x.setAbcdef(w,P,M,B,I,A,C),w}x.setPosition=m;function y(w){let[A,C,P,M]=x.getAbcdef(w),B=Math.sqrt(A*A+C*C),I=Math.sqrt(P*P+M*M);return[B,I]}x.getScale=y;function g(w){let[,,,,A,C]=x.getAbcdef(w);return[A,C]}x.getPosition=g;function v(w,A){return x.decompose(w,A).rotation}x.getRotation=v;function b(w,A){let[C,P,M,B,I,_]=x.getAbcdef(w),{rotation:E,scale:R,shear:L}=IO([[C,M],[P,B]]);return{position:[I+(A[0]*C+A[1]*M)-A[0],_+(A[0]*P+A[1]*B)-A[1]],scale:R,rotation:E,shear:L,pivot:A}}x.decompose=b;function S(w,A,C,P,M=[0,0]){let[B,I]=w,[_,E]=P,[R,L,F,k]=DO({rotation:C,scale:A,shear:M}),W=B-(_*R+E*F)+_,U=I-(_*L+E*k)+E;return x.create(R,L,F,k,W,U)}x.compose=S})(Oe||(Oe={}));function DV(i,t){let[[e,r],[n,o]]=i,[[a,s],[l,c]]=t,d=(e-n)*(s-c)-(r-o)*(a-l);if(d===0)return!1;let u=((e-a)*(s-c)-(r-s)*(a-l))/d,p=-((e-n)*(r-s)-(r-o)*(e-a))/d;return u>=0&&u<=1&&p>=0&&p<=1}var BO=[[-1,1],[-1,-1],[1,-1],[1,1]],RO=(i,t,e)=>{let r=i.getCenter(),n=i.getHalfSize(),o=Oe.append(t,i.worldMatrix);n[0]===0&&n[1]===0?e.push(Oe.apply(r,o)):BO.forEach(a=>{let s=[a[0]*n[0]+r[0],a[1]*n[1]+r[1]];e.push(Oe.apply(s,o))})},Ps=class{constructor(){this.matrix=Oe.identity();this.min=[1/0,1/0];this.max=[-1/0,-1/0];this.vertices=[];this.edges=[]}setFromObjectSize(t,e=!1){t.updateWorldMatrix(),this.makeEmpty(),Oe.copy(t.worldMatrix,this.matrix);let r=Oe.invert(t.worldMatrix);this.expandByObjectSize(t,r,e)}expandByObjectSize(t,e,r=!1){let n=[],o=t.isBaseGroup===!0?t:void 0;r===!0&&o!==void 0?o.traverse(a=>{a.visible&&RO(a,e,n)}):RO(t,e,n),this.setFromPoints(n)}setFromSize(t,e,r){this.makeEmpty(),Oe.copy(r,this.matrix),this.expandBySize(t,e,r)}expandBySize(t,e,r){[Oe.apply([0,0],r),Oe.apply([0,e],r),Oe.apply([t,e],r),Oe.apply([t,0],r)].forEach(o=>this.expandByPoint(o))}getCenter(){let[t,e]=this.min,[r,n]=this.getHalfSize();return Oe.apply([t+r,e+n],this.matrix)}getSize(){return[this.max[0]-this.min[0],this.max[1]-this.min[1]]}getHalfSize(){return[(this.max[0]-this.min[0])*.5,(this.max[1]-this.min[1])*.5]}makeEmpty(){this.min=[1/0,1/0],this.max=[-1/0,-1/0]}setFromPoints(t){this.makeEmpty();for(let e of t)this.expandByPoint(e)}expandByPoint(t){this.min=[Math.min(this.min[0],t[0]),Math.min(this.min[1],t[1])],this.max=[Math.max(this.max[0],t[0]),Math.max(this.max[1],t[1])]}computeVertices(){let[t,e]=this.getHalfSize(),r=this.getCenter(),[n,o,a,s]=Oe.getAbcdef(this.matrix),l=Oe.create(n,o,a,s,r[0],r[1]);this.vertices=BO.map(([c,d])=>Oe.apply([c*t,d*e],l))}computeEdges(){this.edges=[];for(let t=0,e=this.vertices.length;t<e;++t)this.edges.push([this.vertices[t],this.vertices[(t+1)%e]])}project(t,e){let r=this.matrix;return e&&(r=Oe.append(e.worldMatrix,r)),Oe.applyInverse(t,r)}intersects(t,e,r){return this.intersectsInLocalSpace(...this.project([t,e],r))}intersectsInLocalSpace(t,e){let{min:r,max:n}=this;return t>=r[0]&&t<=n[0]&&e>=r[1]&&e<=n[1]}containsPoint(t){let[e,r]=t,[n,o]=this.min,[a,s]=this.max;return e>=n&&e<=a&&r>=o&&r<=s}intersectsBBox2D(t){for(let e=0,r=this.edges.length;e<r;e++){let n=this.edges[e];for(let o=0,a=t.edges.length;o<a;o++){let s=t.edges[o];if(DV(n,s))return!0}}for(let e=0,r=t.vertices.length;e<r;e++){let n=t.vertices[e];if(this.containsPoint(n))return!0}return!1}ensureMinMax(){let t=this.min,e=this.max;this.min=[Math.min(t[0],e[0]),Math.min(t[1],e[1])],this.max=[Math.max(t[0],e[0]),Math.max(t[1],e[1])]}copy(t){this.min=[...t.min],this.max=[...t.max],Oe.copy(t.matrix,this.matrix),this.computeVertices(),this.computeEdges()}clone(){let t=new Ps;return t.copy(this),t}};var RV='{"schema":13,"scenes":[{"fi":0,"id":"32603ebf4-bd9a-54ba-c1e9-6645c3ee7a53","data":{"name":"Page","backgroundColor":[0,0,0,0],"objects":[]}}],"assets":{"images":{},"videos":{},"colors":{},"audios":{},"numbers":{},"booleans":{},"strings":{},"dynamicVariables":{"counters":{},"randoms":{},"timers":{},"times":{}},"fonts":{},"animations":{},"geometries":{},"emojiArt":{}},"publish":{"logo":true,"presentationSizing":"Contain","allowPageScroll":true,"showBackground":true},"framePublish":{},"components":{}}',NO=()=>JSON.parse(RV);async function BV(i,t){return await i.default(t?{module_or_path:t}:void 0),Object.getOwnPropertyDescriptor(i.Engine.prototype,"scene")||Object.defineProperty(i.Engine.prototype,"scene",{get:function(){let e=Object.create(i.SceneController.prototype);return e.__wbg_ptr=this.__wbg_ptr,e}}),{createEngine:e=>i.Engine.create(e,NO(),!0)}}var tg,th;function NV(i){tg=i}function qS(){if(!th){if(!tg)return Promise.reject(new Error("HanaRenderer: no Hana UI loader registered. Call setHanaUILoader() from the host app before initializing a HanaRenderer."));th=tg(),th.catch(()=>{th=void 0})}return th}var LO;function LV(){let i=typeof process<"u"?"2.0.84":void 0;return`https://cdn.spline.design/@splinetool/runtime${i?`@${i}`:""}/build/hana-ui.wasm`}function _O(i){LO=i}function rg(){return tg||NV(async()=>{let t=await import("./hana-ui.js");return BV(t,LO??LV())}),qS().then(()=>{})}var og=gc(ig(),1);function GO(i){let t=[],e;try{e=(0,og.makeAbsolute)((0,og.parseSVG)(i))}catch(c){return console.error("[HanaRenderer] Failed to parse SVG path:",c),t}let r=0,n=0,o=0,a=0,s=null,l=null;for(let c of e){let d=null,u=null;switch(c.code){case"M":r=o=c.x,n=a=c.y,t.push({MoveTo:{x:r,y:n}});break;case"L":r=c.x,n=c.y,t.push({LineTo:{x:r,y:n}});break;case"H":r=c.x,t.push({LineTo:{x:r,y:n}});break;case"V":n=c.y,t.push({LineTo:{x:r,y:n}});break;case"C":{let p={x:c.x1,y:c.y1},h={x:c.x2,y:c.y2};r=c.x,n=c.y,t.push({CurveTo:[p,h,{x:r,y:n}]}),d=h;break}case"S":{let p=s?{x:2*r-s.x,y:2*n-s.y}:{x:r,y:n},h={x:c.x2,y:c.y2};r=c.x,n=c.y,t.push({CurveTo:[p,h,{x:r,y:n}]}),d=h;break}case"Q":{let p={x:c.x1,y:c.y1};r=c.x,n=c.y,t.push({QuadTo:[p,{x:r,y:n}]}),u=p;break}case"T":{let p=l?{x:2*r-l.x,y:2*n-l.y}:{x:r,y:n};r=c.x,n=c.y,t.push({QuadTo:[p,{x:r,y:n}]}),u=p;break}case"A":{let p=r,h=n;r=c.x,n=c.y,VV(t,p,h,c.rx,c.ry,c.xAxisRotation,c.largeArc,c.sweep,r,n);break}case"Z":r=o,n=a,t.push("ClosePath");break}s=d,l=u}return t}function VV(i,t,e,r,n,o,a,s,l,c){if(t===l&&e===c)return;if(r=Math.abs(r),n=Math.abs(n),r===0||n===0){i.push({LineTo:{x:l,y:c}});return}let d=o*Math.PI/180,u=Math.cos(d),p=Math.sin(d),h=(t-l)/2,f=(e-c)/2,m=u*h+p*f,y=-p*h+u*f,g=m*m/(r*r)+y*y/(n*n);if(g>1){let U=Math.sqrt(g);r*=U,n*=U}let v=r*r,b=n*n,S=v*b-v*y*y-b*m*m,x=v*y*y+b*m*m,w=(a!==s?1:-1)*Math.sqrt(Math.max(0,S/x)),A=w*(r*y)/n,C=w*(-n*m)/r,P=u*A-p*C+(t+l)/2,M=p*A+u*C+(e+c)/2,B=Math.atan2((y-C)/n,(m-A)/r),_=Math.atan2((-y-C)/n,(-m-A)/r)-B;!s&&_>0?_-=2*Math.PI:s&&_<0&&(_+=2*Math.PI);let E=Math.max(1,Math.ceil(Math.abs(_)/(Math.PI/2))),R=_/E,L=4/3*Math.tan(R/4),F=B,k=t,W=e;for(let U=0;U<E;U++){let G=F+R,q=Math.cos(F),X=Math.sin(F),Y=Math.cos(G),K=Math.sin(G),te=P+r*Y*u-n*K*p,ue=M+r*Y*p+n*K*u,se=-r*X*u-n*q*p,ce=-r*X*p+n*q*u,de=-r*K*u-n*Y*p,ge=-r*K*p+n*Y*u;i.push({CurveTo:[{x:k+L*se,y:W+L*ce},{x:te-L*de,y:ue-L*ge},{x:te,y:ue}]}),F=G,k=te,W=ue}}var sg=.5522847498307936,zV=150,jV=5*60*1e3,HV=1536/2816;function XO(i){let t=i.getUint32(0);if(t===65536||t===1330926671||t===1953658213)return 0;if(t===1953784678)return i.getUint32(8)>0?i.getUint32(12):void 0}function WV(i){try{return XO(new DataView(i))!==void 0}catch{return!1}}function qV(i){try{let t=new DataView(i),e=XO(t);if(e===void 0)return;let r=t.getUint16(e+4),n=-1,o=-1;for(let c=0;c<r;c++){let d=e+12+c*16,u=t.getUint32(d);u===1751474532&&(n=t.getUint32(d+8)),u===1330851634&&(o=t.getUint32(d+8))}if(n<0||o<0)return;let a=t.getUint16(n+18),s=t.getUint16(o);if(a===0||s<2)return;let l=t.getInt16(o+86);return l>0?l/a:void 0}catch{return}}var UO=!1;function zO(){UO||(UO=!0,console.warn("[HanaRenderer] clipRect: precise clipping of rotated/complex content is not supported by the Hana UI overlay yet; drawing unclipped. (Axis-aligned rectangles are clipped geometrically.)"))}var lg=class{constructor(t,e=1){this.canvas=t;this._dpr=e;this._width=0;this._height=0;this._isSizeDirty=!1;this._crashed=!1;this._shapes=[];this._lastPushedJSON="";this._ctm=Oe.identity();this._stack=[];this._clips=[];this._pathEls=[];this._simpleShape=null;this._pathPrimitives=0;this._fillColor=Ve.transparent;this._strokeColor=Ve.transparent;this._lineWidth=1;this._strokeMode="inside";this._layerBlur=0;this._backgroundBlur=0;this._dropShadowBlur=0;this._dropShadowOffsetX=0;this._dropShadowOffsetY=0;this._dropShadowColor=Ve.transparent;this._innerShadowBlur=0;this._innerShadowOffsetX=0;this._innerShadowOffsetY=0;this._innerShadowSpread=0;this._innerShadowColor=Ve.transparent;this._fonts=new Map;this._fontsFlushed=new Set;this._engineFonts=new Set;this._fontXPerEm=new Map;this._measureCache=new Map;try{let r=t.getBoundingClientRect();t.width=r.width*e,t.height=r.height*e}catch{console.log(t.width,e)}}get dpr(){return this._dpr}set dpr(t){this._dpr=t,this._isSizeDirty=!0}get width(){return this._width}get height(){return this._height}async init(){if(!(this._engine||this._crashed)){try{this._context=await qS(),this._engine=await this._context.createEngine(this.canvas)}catch(t){this._crashed=!0,console.error("[HanaRenderer] Failed to load the Hana UI engine; UI scenes will not render.",t);return}if(this._width>0&&this._height>0)this._syncViewport();else{let t=this.canvas.getBoundingClientRect();t.width>0&&t.height>0&&(this._width=t.width,this._height=t.height,this._syncViewport())}this._flushFonts(),this.uiFontReady=this._watchUiFont()}}_watchUiFont(){return new Promise(t=>{let e=this._engine;if(!e||typeof e.scene.isUiFontLoaded!="function"){t();return}let r=()=>{let a=!1;return this._guard(()=>{a=e.scene.isUiFontLoaded()}),a};if(r()){t();return}let n=Date.now(),o=setInterval(()=>{if(this._crashed||Date.now()-n>jV){clearInterval(o);return}r()&&(clearInterval(o),t())},zV)})}_syncViewport(){let t=this._engine;if(!t||this._crashed)return;let e=this._width,r=this._height;this.canvas.style.width=e+"px",this.canvas.style.height=r+"px",this.canvas.width=Math.max(1,Math.ceil(e*this._dpr)),this.canvas.height=Math.max(1,Math.ceil(r*this._dpr)),this._guard(()=>{t.resize([e,r],this._dpr),t.scene.updateCamera({position:[e/2,r/2],zoom:1})})}setSize(t,e){!this._isSizeDirty&&t===this._width&&e===this._height||(this._isSizeDirty=!1,this._width=t,this._height=e,this._engine?this._syncViewport():(this.canvas.style.width=t+"px",this.canvas.style.height=e+"px",this.canvas.width=Math.max(1,Math.ceil(t*this._dpr)),this.canvas.height=Math.max(1,Math.ceil(e*this._dpr))))}_guard(t){if(!this._crashed)try{t()}catch(e){this._crashed=!0,console.error("[HanaRenderer] Hana engine call failed; disabling this renderer instance.",e)}}async loadFont(t,e){try{let r=await fetch(t);if(!r.ok){console.error(`[HanaRenderer] loadFont: ${t} returned HTTP ${r.status}; skipping "${e}"`);return}let n=await r.arrayBuffer();if(n.byteLength===0){console.error(`[HanaRenderer] loadFont: ${t} was empty; skipping "${e}"`);return}this.registerFont(n,e)}catch(r){console.error(`[HanaRenderer] loadFont failed for "${e}" (${t}):`,r)}}registerFont(t,e){if(this._fonts.has(e))return;this._fonts.set(e,t),WV(t)&&this._engineFonts.add(e);let r=qV(t);r!==void 0&&this._fontXPerEm.set(e,r),this._flushFonts()}_flushFonts(){let t=this._engine;if(!!t)for(let[e,r]of this._fonts)this._fontsFlushed.has(e)||(this._fontsFlushed.add(e),this._guard(()=>{t.scene.addLocalFont(e,new Uint8Array(r))===!1&&this._engineFonts.delete(e)}))}set strokeColor(t){this._strokeColor=t}set fillColor(t){this._fillColor=t}set lineWidth(t){this._lineWidth=t}set strokeMode(t){this._strokeMode=t}set dropShadowBlur(t){this._dropShadowBlur=t}set dropShadowColor(t){this._dropShadowColor=t}set dropShadowOffsetX(t){this._dropShadowOffsetX=t}set dropShadowOffsetY(t){this._dropShadowOffsetY=t}set innerShadowBlur(t){this._innerShadowBlur=t}set innerShadowColor(t){this._innerShadowColor=t}set innerShadowOffsetX(t){this._innerShadowOffsetX=t}set innerShadowOffsetY(t){this._innerShadowOffsetY=t}set innerShadowSpread(t){this._innerShadowSpread=t}set layerBlur(t){this._layerBlur=t}set backgroundBlur(t){this._backgroundBlur=t}save(){this._stack.push({ctm:Oe.copy(this._ctm),clipLen:this._clips.length})}restore(){let t=this._stack.pop();!t||(this._ctm=t.ctm,this._clips.length=t.clipLen)}setTransform(t,e=!1){let r=Oe.identity();if(this.camera?.enabled&&(r=Oe.append(r,this.camera.worldMatrix),e)){let n=Oe.getScale(this.camera.worldMatrix);r=Oe.scale(r,1/n[0],1/n[1])}this._ctm=Oe.append(r,t)}transform(t){this._ctm=Oe.append(this._ctm,t)}beginPath(){this._pathEls=[],this._simpleShape=null,this._pathPrimitives=0}closePath(){this._pathEls.length!==0&&this._pathEls[this._pathEls.length-1]!=="ClosePath"&&this._pathEls.push("ClosePath")}_startFreeform(){this._simpleShape=null,this._pathPrimitives++}moveTo(t,e){this._startFreeform(),this._pathEls.push({MoveTo:{x:t,y:e}})}lineTo(t,e){this._startFreeform(),this._pathEls.push({LineTo:{x:t,y:e}})}bezierCurveTo(t,e,r,n,o,a){this._startFreeform(),this._pathEls.push({CurveTo:[{x:t,y:e},{x:r,y:n},{x:o,y:a}]})}quadraticCurveTo(t,e,r,n){this._startFreeform(),this._pathEls.push({QuadTo:[{x:t,y:e},{x:r,y:n}]})}path(t){this._startFreeform(),this._pathEls.push(...GO(t))}rect(t,e,r,n,o=0,a=0,s=0,l=0){if(!WO([t,e,r,n]))return;let c={x:t,y:e,w:r,h:n,radii:[o,a,s,l]};this._pathPrimitives++,this._simpleShape=this._pathPrimitives===1&&this._pathEls.length===0?{kind:"rect",rect:c,smoothing:0}:null,qO(this._pathEls,c)}ellipse(t,e,r,n,o,a,s,l){if(!!WO([t,e,r,n])){if(r<0||n<0)throw Error("radii cannot be negative");this._pathPrimitives++,this._simpleShape=this._pathPrimitives===1&&this._pathEls.length===0?{kind:"ellipse",cx:t,cy:e,rx:r,ry:n}:null,KV(this._pathEls,t,e,r,n)}}clipRect(t,e,r,n,o=0,a=0,s=0,l=0){let c=Oe.invert(this._ctm);!c||this._clips.push({m:Oe.copy(this._ctm),inv:c,rect:{x:t,y:e,w:r,h:n,radii:[o,a,s,l]}})}fill(){this._emit(!0)}stroke(){this._strokeColor.a<=0||this._lineWidth<=0||this._emit(!1)}_emit(t){let e=this._effectChain(t);if(t&&this._fillColor.a<=0&&!e)return;let r=this._classifyShape();if(!r)return;let n=this._applyClips(r);if(n==="skip")return;if(!t&&n!==r){let a=rh(r);if(a){this._emitClippedRectStroke(a,e);return}}r=n;let o={shape:r,color:t?Cd(this._fillColor):[0,0,0,0],transform:Oe.getAbcdef(this._ctm)};t||(o.stroke=this._strokeDesc()),e&&(o.effect_chain=e),this._shapes.push(o)}_emitClippedRectStroke(t,e){let r=this._lineWidth,n=this._strokeMode==="outside"?r:this._strokeMode==="center"?r/2:0,o=r-n,a=Math.min(t.w,t.h)/2,s=t.radii.map(g=>Math.max(0,Math.min(g,a))),l={x:t.x-n,y:t.y-n,w:t.w+n*2,h:t.h+n*2,radii:s.map(g=>g>0?g+n:0)},c=t.w-o*2,d=t.h-o*2,u=c>0&&d>0?{x:t.x+o,y:t.y+o,w:c,h:d,radii:s.map(g=>Math.max(0,g-o))}:null,p=this._applyClips(ag(l,0));if(p==="skip")return;let h=rh(p)??l,f=null;if(u){let g=this._applyClips(ag(u,0));f=g==="skip"?null:rh(g)??u}let m=[];qO(m,h),f&&QV(m,f);let y={shape:{Custom:m},color:Cd(this._strokeColor),transform:Oe.getAbcdef(this._ctm)};e&&(y.effect_chain=e),this._shapes.push(y)}_classifyShape(){let t=this._simpleShape;return t?t.kind==="rect"?ag(t.rect,t.smoothing):{Ellipse:{center_x:t.cx,center_y:t.cy,rx:t.rx,ry:t.ry}}:this._pathEls.length===0?null:{Custom:this._pathEls.slice()}}_strokeDesc(){return{width:this._lineWidth,line_join:"Miter",color:Cd(this._strokeColor),align:XV[this._strokeMode],cap:"Butt"}}_effectChain(t){let e=this.camera?.scale??1,r=[];if(t&&this._dropShadowColor.a>0&&r.push({DropShadow:{position:[this._dropShadowOffsetX*e,this._dropShadowOffsetY*e],blur:{Uniform:{size:2*this._dropShadowBlur*e}},spread:0,color:Cd(this._dropShadowColor)}}),t&&this._backgroundBlur>0){let[n,o]=Oe.getScale(this._ctm),a=(n+o)/2;r.push({BackgroundBlur:{blur:{Uniform:{size:2*this._backgroundBlur*a}}}})}if(this._layerBlur>0&&r.push({LayerBlur:{blur:{Uniform:{size:2*this._layerBlur*e}}}}),t&&this._innerShadowColor.a>0){let[n,o,a,s]=Oe.getAbcdef(this._ctm),l=this._innerShadowOffsetX,c=this._innerShadowOffsetY;r.push({InnerShadow:{position:[n*l+a*c,o*l+s*c],blur:{Uniform:{size:2*this._innerShadowBlur*e}},spread:this._innerShadowSpread*e,color:Cd(this._innerShadowColor)}})}return r.length>0?r:void 0}_applyClips(t,e=this._ctm){if(this._clips.length===0)return t;let r=t;for(let n of this._clips){let o=Oe.append(n.inv,e),[a,s,l,c,d,u]=Oe.getAbcdef(o),p=Math.abs(s)<=1e-6*(Math.abs(a)+Math.abs(c))&&Math.abs(l)<=1e-6*(Math.abs(a)+Math.abs(c)),h=YV(r);if(!h)return r;if(!p){zO();continue}let f=a*h.minX+d,m=a*h.maxX+d,y=c*h.minY+u,g=c*h.maxY+u,v=Math.min(f,m),b=Math.max(f,m),S=Math.min(y,g),x=Math.max(y,g),w=n.rect,A=Math.max(v,w.x),C=Math.max(S,w.y),P=Math.min(b,w.x+w.w),M=Math.min(x,w.y+w.h);if(A>=P||C>=M)return"skip";if(A===v&&C===S&&P===b&&M===x)continue;let I=rh(r);if(!I||a===0||c===0){zO();continue}let _=(A-d)/a,E=(P-d)/a,R=(C-u)/c,L=(M-u)/c,F=Math.min(_,E),k=Math.min(R,L),W=Math.abs(E-_),U=Math.abs(L-R),[G,q,X,Y]=I.radii,K=F!==I.x,te=k!==I.y,ue=F+W!==I.x+I.w,se=k+U!==I.y+I.h,ce=Math.min(W,U)/2,de=[K||te?0:Math.min(G,ce),ue||te?0:Math.min(q,ce),ue||se?0:Math.min(X,ce),K||se?0:Math.min(Y,ce)];r=ag({x:F,y:k,w:W,h:U,radii:de},0)}return r}drawText(t,e){let r=this._engineFonts.has(e.font),n=this._fontXPerEm.get(e.font),o=!r&&n?n/HV:1,a={TextSimple:{text:t,font_size:e.fontSize*o,size:[e.width,e.height],horizontal_align:jO[e.horizontalAlign]??"Left",vertical_align:HO[e.verticalAlign]??"Top",line_height:e.lineHeight,letter_spacing:e.letterSpacing,...r?{font_id:e.font}:{}}},s=this._effectChain(!0),l=this._fillColor.a>0,c=this._strokeColor.a>0&&this._lineWidth>0;if(l||c||s){let d=Oe.append(this._ctm,Oe.translate(Oe.identity(),e.x,e.y));if(this._applyClips(a,d)!=="skip"){let u={shape:a,color:l?Cd(this._fillColor):[0,0,0,0],transform:Oe.getAbcdef(d)};c&&(u.stroke=this._strokeDesc()),s&&(u.effect_chain=s),this._shapes.push(u)}}return{height:this._measureTextHeight(t,e)}}_measureTextHeight(t,e){let r=`${e.font}|${e.fontSize}|${e.lineHeight}|${e.letterSpacing}|${e.width}|${t}`,n=this._measureCache.get(r);if(n!==void 0)return n;let o=0,a=this._engine;if(a&&!this._crashed&&this._fontsFlushed.has(e.font))try{let[,s]=a.scene.measureTextNaturalSize({size:[e.width,e.height],text:t,fontSize:e.fontSize,horizontalAlign:jO[e.horizontalAlign]??"Left",verticalAlign:HO[e.verticalAlign]??"Top",lineHeight:e.lineHeight,letterSpacing:e.letterSpacing,textTransform:"None",font:e.font,version:0,autoSize:"None",truncate:"None"});o=s}catch{}if(!(o>0)){let s=e.fontSize*.55+Math.max(0,e.letterSpacing),l=Math.max(1,Math.floor(e.width/s)),c=0;for(let d of t.split(`
|
|
1311
|
+
`,r.pyramidTextureSize.value=new me.Vector2(this.pyramidRenderTarget[0].width,this.pyramidRenderTarget[0].height),Object.assign(o.uniforms,r)};this.material.shapeBlendhack=n,this.material.root.shapeBlendhack=n}dispose(){super.dispose(),G2()?.release(this)}},Jp=US;Jp.streamCompaction=new ly;var bV=new me.Matrix4,xV=new me.Matrix4,wd=new me.Quaternion,Fl=new me.Vector3,Jy=new me.Vector3,SV=new me.Quaternion;function wV(i,t=0){let e=this.children.length;for(;e--;){let r=this.children[e];Pa.is(r)&&bO.call(r,i,t+1)}}function bO(i,t=0){if(i(this,t)!==!0){let r=this.children.length;for(;r--;){let n=this.children[r];Pa.is(n)&&bO.call(n,i,t+1)}}}function AV(){if(this.shapesDataTexture.value===void 0){let y=new me.DataTexture(new Float32Array(4*Br*Ma),Br,Ma,me.RGBAFormat,me.FloatType);this.shapesDataTexture.value=y}let i=this.shapesDataTexture.value,t=i.image.data,e=0,r=0,n=this.data.geometry.blendRange,o=bV.copy(this.matrixWorld).invert(),a=this._npart,s=0;this._meshSdfWanted.clear();let l=null;if(wV.call(this,y=>{if(y.visible===!1)return!0;let g;if(y instanceof Fn)return;if(y instanceof vd||Ap(y))return;y instanceof Rr?g=y.object:g=y;let v=y.data?.cloner;if(Le.is(y)&&v&&!v.hideBase&&v.type!=="radial"&&v.disabled!==!0||!(g instanceof tt))return;let b=g.geometry.userData.parameters,S=b?.shapeBlendNode??g.dataPatched?.geometry?.shapeBlendNode;if(S===void 0)return;if(xV.multiplyMatrices(o,y.matrixWorld).decompose(Jy,wd,Fl),b?.type==="TorusGeometry"&&b.arc!==360){let E=b.arc*Math.PI/180;E=E/4,wd.multiply(SV.set(0,0,Math.sin(E),Math.cos(E)))}let w=S.overrideGlobalBlend?S.blendRange:n;w=w/this.bboxSize*2,t[s*4]=(Jy.x-this.bboxOffset)/this.bboxSize*2,t[s*4+1]=(Jy.y-this.bboxOffset)/this.bboxSize*2,t[s*4+2]=(Jy.z-this.bboxOffset)/this.bboxSize*2,t[s*4+3]=S.operation===0?1:S.operation===2?-1:-2,t[Br*4+s*4]=-wd.x,t[Br*4+s*4+1]=-wd.y,t[Br*4+s*4+2]=-wd.z,t[Br*4+s*4+3]=wd.w;let A=new Float32Array(4),C=0,P=w;if(b?.type==="SphereGeometry")b.width===b.height&&b.width===b.depth?A[0]=0:A[0]=1,A[1]=b.width/this.bboxSize,A[2]=b.height/this.bboxSize,A[3]=b.depth/this.bboxSize,P=Math.max(A[1],A[2],A[3])*Fl.x+w;else if(b?.type==="CubeGeometry"){C=b.cornerRadius;let E=b.width,R=b.height,L=b.depth;A[0]=2,A[1]=(E-2*C)/this.bboxSize,A[2]=(R-2*C)/this.bboxSize,A[3]=(L-2*C)/this.bboxSize,P=Math.sqrt(E**2+R**2+L**2)/this.bboxSize*Fl.x+w}else if(b?.type==="CylinderGeometry"){C=b.cornerRadius;let E=b.height,R=b.radiusBottom,L=b.radiusTop;if(L>=R){let F=Math.atan2(L-R,E),k=(Math.PI/2-F)/2;L-=C/Math.tan(k),R-=C*Math.tan(k)}else if(R>L){let F=Math.atan2(R-L,E),k=(Math.PI/2-F)/2;L-=C*Math.tan(k),R-=C/Math.tan(k)}A[1]=(b.height-2*C)/this.bboxSize,R===L?(A[0]=3,A[2]=R/this.bboxSize*2):(A[0]=4,A[2]=R/this.bboxSize*2,A[3]=L/this.bboxSize*2),P=(Math.hypot(A[1],Math.max(Math.abs(A[2]),Math.abs(A[3])))+C/this.bboxSize*2)*Fl.x+w}else if(b?.type==="TorusGeometry"){if(A[0]=5,A[1]=(b.width-b.depth)/this.bboxSize,A[2]=b.depth/this.bboxSize,b.arc!==360){A[0]=6,A[3]=A[1],t[Br*12+s*4+3]=A[2];let E=2*Math.atan2(A[2]/2,A[1]),R=b.arc*Math.PI/180/2-E;A[1]=Math.sin(R),A[2]=Math.cos(R)}P=b.width*Fl.x/this.bboxSize+w}else{let E=g.geometry;(l??(l=new Set)).add(E.uuid);let R=this._meshSdfBaked.get(E.uuid),L=vV(E);if((R===void 0||R.posVersion!==L)&&this._meshSdfWanted.set(E.uuid,E),R===void 0)return;A[0]=7,A[1]=R.slot,A[2]=R.boxHalf.x/this.bboxSize*2,A[3]=R.boxHalf.y/this.bboxSize*2,t[Br*12+s*4+3]=R.boxHalf.z/this.bboxSize*2,P=Math.hypot(R.boxHalf.x,R.boxHalf.y,R.boxHalf.z)/this.bboxSize*2*Fl.x+w}t.set(A,Br*8+s*4),e=Math.max(e,P),r=Math.max(r,w),this._reach[s]=P,t[Br*12+s*4]=w,t[Br*12+s*4+1]=C/this.bboxSize*2,t[Br*12+s*4+2]=Fl.x;let M=Array.isArray(g.material)?g.material[0]:g.material,B=M,I,_;if(B?.getShapeBlendBaseColor){let E=B.getShapeBlendBaseColor();I=E,_=E.a}else M?.uniforms?.nodeU0!==void 0?(I=M.uniforms.nodeU0.node.value,_=M.uniforms.nodeU1?.value??1):(I={r:1,g:1,b:1},_=1);S.operation!==0&&!S.useColor&&(_=-1),t[Br*16+s*4]=I.r,t[Br*16+s*4+1]=I.g,t[Br*16+s*4+2]=I.b,t[Br*16+s*4+3]=_,_<1&&this.material.defines?.SHAPEBLEND_C===1&&this.material.setTransparent(!0),s++}),this._meshSdfBaked.size>0){let y=l??new Set;for(let g of this._meshSdfBaked.keys())y.has(g)||this._meshSdfBaked.delete(g)}this.npart=s,this._maxBlendK=r;let c=e*1.1+2/(this.spatialDivisions-1)+4/(this.resolution-1);this.spatialPassUniforms.span.value=c;let d=this._prevShapeData,u=a!==s,p=d===null||this._prevSpan!==c||u,h=p||GS,f=this._fieldDirtyMin.set(1/0,1/0,1/0),m=this._fieldDirtyMax.set(-1/0,-1/0,-1/0);if(d!==null){let y=Math.max(s,a);for(let g=0;g<y;g++){let v=!1;for(let B=0;B<Ma;B++){let I=Br*4*B+g*4;if(t[I]!==d[I]||t[I+1]!==d[I+1]||t[I+2]!==d[I+2]||t[I+3]!==d[I+3]){v=!0;break}}if(!v)continue;if(p=!0,h)break;let b=t[g*4],S=t[g*4+1],x=t[g*4+2],w=d[g*4],A=d[g*4+1],C=d[g*4+2],P=this._reach[g],M=this._prevReach[g];if(!Number.isFinite(b+S+x+P)||!Number.isFinite(w+A+C+M)){h=!0;continue}f.x=Math.min(f.x,b-P,w-M),f.y=Math.min(f.y,S-P,A-M),f.z=Math.min(f.z,x-P,C-M),m.x=Math.max(m.x,b+P,w+M),m.y=Math.max(m.y,S+P,A+M),m.z=Math.max(m.z,x+P,C+M)}}return GS&&(p=!0),this._fieldDirtyFull=h||f.x===1/0,p&&(d===null?this._prevShapeData=new Float32Array(t):d.set(t),this._prevReach.set(this._reach),this._prevSpan=c,i.needsUpdate=!0),p}Oi("ShapeBlendGeometry",(i,t,e)=>new Jp(i,t,e));Pe("shape-blends");var $y=class extends tt{get forceComputeSize(){return!0}get shape(){return this.geometry.userData.shape}updateEntityBoxSize(t,e){let r=this.geometry.getAttribute("position");r!==void 0?Dp(r,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:r.count,t,e):super.updateEntityBoxSize(t,e)}};Oi("VectorGeometry",(i,t,e)=>new $y(i,t,e));Pe("vector-shapes");var eg=class extends tt{constructor(e,r,n){super(e,r,n);this.isPathObject=!0;this._shapeId=null;this._lastShapeParams=null;this._lastShape=null;this._context=n}get profileShape(){return this._lastShape??void 0}updateState(e,r){super.updateState(e,r),this.updateShape(),this.refreshAttachedCloners(r)}updateShape(){let e={...this.data.geometry.extrusion.shape};for(let o in e)typeof e[o]=="string"&&(e[o]=this._context.shared.getVariable(e[o],[this.uuid,"geometry","extrusion","shape",o]));let r;if(e.type==="Custom"){let o=e.shapeId;if(o!==this._shapeId&&this.detachShape(),o){this._shapeId=o;let a=this._context.scene.find(o);a?.data&&(a.attachedPaths.add(this),r=a.geometry.userData?.shape),r||this._context.scene.addPendingCommand(()=>this.updateShape())}}else if(this._lastShape!==null&&this._sameShapeParams(e))r=this._lastShape;else{let o;switch(e.type){case"Rectangle":o=ud;break;case"Ellipse":o=cd;break;case"Polygon":o=Py;break;case"Star":o=My;break;default:throw new Error(`Unknown shape type: ${e.type}`)}r=o.create({parameters:e}).userData.shape,this._lastShapeParams=e,this._lastShape=r??null}let n=this.geometry;if(r&&n.inputs){if(this._lastShape=r,e.type==="Custom"&&(this._lastShapeParams=null),n.inputs.shapeData===r)return;n.inputs.shapeData=r,n.build()}}_sameShapeParams(e){let r=this._lastShapeParams;if(r===null)return!1;for(let n in e)if(!Object.is(e[n],r[n]))return!1;for(let n in r)if(!(n in e))return!1;return!0}detachShape(){this._shapeId!==null&&this._context.scene.find(this._shapeId)?.attachedPaths.delete(this)}supportsInPlaceGeometryUpdate(){return!1}createGeometryDelayed(e){this.geometryCreateDeleyed=e.shared,this.updateShape(),this.refreshAttachedPaths(e)}updateTransformState(e,r){return super.updateTransformState(e,r)}updateGeometryInteractions(e,r){super.updateGeometryInteractions(e,r),this.updateShape()}updateEntityBoxSize(e,r){let n=this.geometry.getAttribute("position");n!==void 0&&n.count>0?Dp(n,this.geometry.drawRange.start,this.geometry.drawRange.count<1/0?this.geometry.drawRange.count:n.count,e,r):super.updateEntityBoxSize(e,r)}};var ke=require("three");function xO(i,t){let e=2*Math.PI;return(i%e+e)%e===(t%e+e)%e}var SO=new ke.Matrix4,CV=new ke.Matrix4,EV=new ke.Matrix4().makeScale(1,1,-1),wO=new ke.Vector3,AO=new ke.Vector3,zS=new ke.Vector3,TV=new ke.Vector3,PV=new ke.Vector3,MV=new ke.Vector3,OV=new ke.Vector3,CO=new WeakMap,jS=new WeakMap;function IV(i,t,e){let r=[new ke.Vector3,new ke.Vector3,new ke.Vector3],n=[new ke.Vector3,new ke.Vector3,new ke.Vector3];return i.extractBasis(r[0],r[1],r[2]),t.extractBasis(n[0],n[1],n[2]),r.forEach((o,a)=>{let s=n[a],l=ke.MathUtils.lerp(o.length(),s.length(),e);o.lerp(s,e).setLength(l)}),new ke.Matrix4().makeBasis(r[0],r[1],r[2])}function EO(i){i.setIndex(null),i.setAttribute("position",new ke.BufferAttribute(new Float32Array(0),3)),i.setAttribute("normal",new ke.BufferAttribute(new Float32Array(0),3)),i.setAttribute("uv",new ke.BufferAttribute(new Float32Array(0),2)),i.setDrawRange(0,0)}var TO=class{static create(i){return this.build(this.normalizeInputs(i))}static normalizeInputs(i,t){let e=Object.assign({},t?.parameters??{width:100,height:100,depth:1,subdivisions:12,roundness:0,extrudeBevelSize:0,extrudeBevelSegments:3},i.parameters),r=Math.abs(e.width),n=Math.abs(e.height??e.width),o=Math.abs(e.depth??0),a=i.shapeData??t?.shapeData??cd.create({parameters:{...fl,width:typeof fl.width=="number"?fl.width:100,height:typeof fl.height=="number"?fl.height:100}}).userData.shape;return{ownerId:i.ownerId??t?.ownerId,path:i.path??Oc.defaultData(),parameters:Object.assign(e,{width:r,height:n,depth:o,extrusion:{...gm,...e.extrusion}}),shapeData:a}}static build(i){if(i.path.points.length>=2){let e=new HS(i);return Object.assign(e,{userData:{...i,type:"PathGeometry"}})}else{let e=new ke.BufferGeometry;return EO(e),Object.assign(e,{userData:{...i,type:"PathGeometry"}})}}},HS=class extends ke.BufferGeometry{constructor(e){super();this.type="PathExtrusionGeometry",this.inputs=e,this.build()}_isGeometryClosed(){return this.inputs.path.isClosed&&this.inputs.parameters.extrusion.depth===1}_isOpenEnded(){let e=this.inputs.parameters.extrusion;return!(this.inputs.path.isClosed&&e.depth===1)||!xO(e.twist,0)||e.startScale!==e.endScale}build(){let{points:e,matrices:r}=this._getSampledPath();if(e.length<2){EO(this);return}let{depth:n,offset:o}=this.inputs.parameters.extrusion;n=Math.max(0,Math.min(n,1)),o=Math.max(0,Math.min(o,1));let a=this.inputs.path.isClosed?e.length:e.length-1,s=Math.floor(o*a),l=this.inputs.path.isClosed?Math.ceil((n+o)*a):Math.ceil(Math.min(1,n+o)*a),c=Math.min(Math.max(2,l-s+1),a+2),d=[],u=[];for(let Y=0;Y<c;Y++){let K=this.inputs.path.isClosed?(Y+s)%e.length:Math.min(Y+s,e.length-1);d.push(e[K].clone()),u.push(r[K].clone())}let p=(Y,K,te)=>{d[Y]=d[Y].clone().lerp(d[K],te),u[Y]=IV(u[Y],u[K],te)},h=0,f=o*a%1;(!this.inputs.path.isClosed||n<=1)&&(f||o===0)&&(h=f,p(0,1,h));let m=0,y=(o+n)*a%1;if((this.inputs.path.isClosed&&n<=1||!this.inputs.path.isClosed&&o+n<1)&&y&&(m=y,p(d.length-1,d.length-2,1-m)),n===0){let Y=d.length-1;d[Y].copy(d[0]),u[Y].copy(u[0])}this._applyPathModifiers(u,h,m);let{bevel:g,bevelSides:v}=this.inputs.parameters.extrusion,b=5;this.inputs.parameters.extrusion.shape.type==="Custom"&&(b=this.inputs.parameters.extrusion.shape.shapeQuality==="low"?5:12);let{regions:S,infos:x,vertices:w}=this._getShapePoints(b),A=g>0?this.inputs.parameters.extrusion.capType:"flat",C=A==="round"?TM(this.inputs.shapeData,g,v,b,this.inputs.ownerId):void 0,P=C!==void 0&&this.inputs.parameters.extrusionVersion===1?Sy(C):C,M=A==="round"&&P===void 0?"flat":A,B=P!==void 0?P.positions.length/3:0,I=0,_=0;x.sort((Y,K)=>Y.start-K.start),x.forEach(Y=>{Y.verticesStart=I,Y.verticesCount=Y.continuous.reduce((K,te,ue)=>K+(ue===0||!te?2:1),0),_+=Y.verticesCount,I=_});let E=_*c,R,L=0;this._isOpenEnded()&&M==="flat"&&(R=this._getSurfaceTesselation(S),L=R.vertexCount);let F=E+2*L+B*2,k=E+2*L,W={positions:new Float32Array(F*3),normals:new Float32Array(F*3),uvs:new Float32Array(F*2)},U=0;x.forEach(Y=>{U+=Y.count});let G=U*(c-1)*6+(R?2*R.elementCount*3:0)+(P!==void 0?2*P.indices.length:0),q=new Uint32Array(G),X=0;if(x.forEach(Y=>{X=this._extrudeRegion(Y,w,u,d,W,q,X,this._isGeometryClosed()&&!this._isOpenEnded())}),R&&(X=this._closeEnd(R,E,q,X,W,u[0],d[0],!1),X=this._closeEnd(R,E+L,q,X,W,u[u.length-1],d[d.length-1],!0)),P!==void 0){let Y={positions:W.positions,normals:W.normals,uvs:W.uvs,indices:q};Gp(P,Y,k,X,SO.copy(u[0]).setPosition(d[0]).multiply(EV),(K,te,ue)=>[ue,1e-4]),X+=P.indices.length,k+=B,Gp(P,Y,k,X,SO.copy(u[u.length-1]).setPosition(d[d.length-1]),(K,te,ue)=>[ue,1]),X+=P.indices.length}this.setAttribute("position",new ke.BufferAttribute(W.positions,3)),this.setAttribute("normal",new ke.BufferAttribute(W.normals,3)),this.setAttribute("uv",new ke.BufferAttribute(W.uvs,2)),this._setIndexFromUint32(q)}_setIndexFromUint32(e){let r=!1;for(let n=e.length-1;n>=0;--n)if(e[n]>=65535){r=!0;break}this.setIndex(new ke.BufferAttribute(r?e:new Uint16Array(e),1))}_getSampledPath(){let e=this.inputs.path,r=zm(e),n=CO.get(r);if(n===void 0||n.subdivisions!==e.subdivisions||n.subdivisionMode!==e.subdivisionMode){let o=this._extractPathPoints(r),a=o.length<2?[]:this._computeBasisMatrices(o);n={subdivisions:e.subdivisions,subdivisionMode:e.subdivisionMode,points:o,matrices:a},CO.set(r,n)}return n}_extractPathPoints(e){let r=this.inputs.path.subdivisions,n=this.inputs.path.subdivisionMode==="uniform"?e.getSpacedPoints(r*4):e.getPoints(r);if(n.length<2)return[];let o=[n[0]];return n.forEach(s=>{o[o.length-1].distanceToSquared(s)>.001&&o.push(s)}),this.inputs.path.isClosed&&o[o.length-1].distanceTo(o[0])<.001&&o.pop(),o}_computeBasisMatrices(e){let r=[],n=e.length,o=this.inputs.path.isClosed,a=new ke.Vector3,s=new ke.Vector3,l=new ke.Vector3,c=new ke.Vector3,d=new ke.Vector3(0,1,0);for(let y=0;y<n;y++){let g=e[y],v;y===0?v=o?e[n-1]:wO.copy(g).multiplyScalar(2).sub(e[1]):v=e[y-1];let b;y===n-1?b=o?e[0]:wO.copy(g).multiplyScalar(2).sub(e[y-1]):b=e[y+1],AO.subVectors(g,v).normalize(),zS.subVectors(b,g).normalize();let S=TV.addVectors(AO,zS);S.lengthSq()<1e-10&&(S.copy(zS),S.dot(l)<0&&S.negate()),S.normalize(),l.copy(S),y===0&&(S.equals(d)||PV.copy(S).negate().equals(d))&&d.set(0,0,1);let x=MV.crossVectors(d,S).normalize(),w=OV.crossVectors(S,x).normalize();d.copy(w),c.copy(x),y===0&&(a.copy(w),s.copy(S));let A=new ke.Matrix4().makeBasis(x,w,S);r.push(A)}let u=o?s:l,p=o?a:new ke.Vector3(0,1,0),h=u.clone().cross(c).normalize(),f=Math.acos(p.dot(h));if(isNaN(f))return r;let m=p.clone().cross(h);u.dot(m)>0&&(f*=-1);for(let y=1;y<r.length;y++)r[y].multiply(CV.makeRotationZ(f*y/r.length));return r}_applyPathModifiers(e,r,n){let o=e.length,{angle:a,twist:s,startScale:l,endScale:c}=this.inputs.parameters.extrusion,d=new ke.Matrix4,u=new ke.Matrix4;return e.forEach((p,h)=>{let f=h===0?0:h===o-1?1:(h-r)/(o-(n===0?0:1)-(r+(1-n)));d.makeRotationZ(ke.MathUtils.lerp(a,a+s,f)*ke.MathUtils.DEG2RAD);let m=ke.MathUtils.lerp(l,c,f);u.makeScale(m,m,m),p.multiply(d).multiply(u)}),e}_getShapePoints(e,r=Tt.ODD){let n=this.inputs.shapeData,o=jS.get(n);return(o===void 0||o.curveSegments!==e||o.windingRule!==r)&&(o={curveSegments:e,windingRule:r,shapePoints:this._computeShapePoints(e,r)},jS.set(n,o)),o.shapePoints}_getSurfaceTesselation(e){let r=jS.get(this.inputs.shapeData);if(r?.surfaceTesselation!==void 0)return r.surfaceTesselation;let n;try{n=Ss({windingRule:Tt.ODD,elementType:kr.POLYGONS,polySize:3,vertexSize:2,strict:!0,contours:e})}catch{n=xy}return r!==void 0&&(r.surfaceTesselation=n),n}_computeShapePoints(e=12,r=Tt.ODD){let n=this.inputs.shapeData,o=n.extractShapePointsToFlatArray([],e),a=n.shapeHoles.map(m=>{let y=m.extractShapePointsToFlatArray([],e),g=[];for(let v=y.length-1;v>=1;v-=2){let b=y[v-1],S=y[v-0];g.push(b,S)}return g}),s;try{s=Ss({windingRule:r,elementType:kr.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[o]})}catch{s=by}let l;try{l=Ss({windingRule:Tt.ODD,elementType:kr.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[...a]})}catch{l=vM}if(!s)throw new Error("error generating geometry");let c=s.elementCount;if(l){s.elementCount+=l.elementCount;for(let m=0;m<l.elements.length;m++){let y=l.elements[m],g=m%2===0?s.vertexCount:0;s.elements.push(y+g)}for(let m=0;m<l.vertexIndices.length;m++){let y=l.vertexIndices[m],g=s.vertexCount;s.vertexIndices.push(y+g)}for(let m=0;m<l.vertices.length;m++){let y=l.vertices[m];s.vertices.push(y)}}let d=1/0,u=-1/0,p=1/0,h=-1/0;for(let m=0,y=s.vertexCount;m<y;m++){let g=m*2,v=s.vertices[g+0],b=s.vertices[g+1];v<d&&(d=v),v>u&&(u=v),b<p&&(p=b),b>h&&(h=b)}let f=[];for(let m=s.elementCount-1;m>=0;m--){let y=m>=c,g=m*2,v=s.elements[g+0],b=s.elements[g+1],S=v+b,x={start:v,count:b,normals:[],isHole:y,continuous:[],verticesStart:0,verticesCount:0};f.push(x);let w=v,A=S-1,C=v+1,P=n.roundedCurves.length;do{let M=w-v,B=s.vertices[A*2+0],I=s.vertices[A*2+1],_=s.vertices[w*2+0],E=s.vertices[w*2+1],R=s.vertices[C*2+0],L=s.vertices[C*2+1],F=_-B,k=E-I,W=Math.sqrt(F*F+k*k);F/=W,k/=W;let U=_-R,G=E-L,q=Math.sqrt(U*U+G*G);U/=q,G/=q,x.normals[M*2+0]=-G,x.normals[M*2+1]=U;let X=s.vertexIndices[w];if(Array.isArray(X))x.continuous[M]=!1;else{let[Y,K]=n.getCurveIndexFromVertexId(X-1,!0);if(K>0&&K<1)x.continuous[M]=!0;else{let te=K===1?Y+1:Y-1;te=(te+P)%P;let ue=K===1?0:1,se=n.roundedCurves[Y].getTangent(K),ce=n.roundedCurves[te].getTangent(ue);x.continuous[M]=se.dot(ce)>.95}}y&&(x.normals[M*2+0]*=-1,x.normals[M*2+1]*=-1),[A,w,C]=[w,C,C+1],C>=S&&(C-=b)}while(C!==v+1)}return{regions:[o,...a],infos:f,vertices:s.vertices}}_insertVertex(e,r,n,o,a){let s=r*2,l=r*3;e.positions[l+0]=n.x,e.positions[l+1]=n.y,e.positions[l+2]=n.z,e.normals[l+0]=o.x,e.normals[l+1]=o.y,e.normals[l+2]=o.z,e.uvs[s+0]=a.x,e.uvs[s+1]=a.y}_extrudeRegion(e,r,n,o,a,s,l,c){let d=e.wallTemplate;if(d===void 0){d=[];for(let S=0;S<e.count;S++){let x=(e.start+S)*2,w=r[x+0],A=r[x+1],C,P;if(e.continuous[S])C=e.normals[S*2+0],P=e.normals[S*2+1];else{let B=S===0?(e.start+e.count-1)*2:x-2,I=w-r[B+0];C=-(A-r[B+1]),P=I,e.isHole||(C=-C,P=-P)}let M=S===0?1:S/e.count;if(d.push(w,A,C,P,M,0),!e.continuous[S]||S===0)if(S===0)d.push(w,A,e.normals[0],e.normals[1],0,1);else{let B=S===e.count-1?e.start*2:x+2,I=r[B+0]-w;C=-(r[B+1]-A),P=I,e.isHole||(C=-C,P=-P),d.push(w,A,C,P,M,1)}}e.wallTemplate=d}let u=n.length,p=d.length,h=a.positions,f=a.normals,m=a.uvs;for(let S=0;S<u;S++){let x=n[S].elements,w=x[0],A=x[1],C=x[2],P=x[4],M=x[5],B=x[6],I=x[12],_=x[13],E=x[14],R=o[S],L=S/(u-1),F=0,k=0,W=0,U=e.verticesStart*u+e.verticesCount*S;for(let G=0;G<p;G+=6){if(d[G+5]===0){let de=d[G+0],ge=d[G+1];F=w*de+P*ge+I+R.x,k=A*de+M*ge+_+R.y,W=C*de+B*ge+E+R.z}let q=d[G+2],X=d[G+3],Y=w*q+P*X+I,K=A*q+M*X+_,te=C*q+B*X+E,ue=1/(Math.sqrt(Y*Y+K*K+te*te)||1);Y*=ue,K*=ue,te*=ue;let se=U*2,ce=U*3;h[ce+0]=F,h[ce+1]=k,h[ce+2]=W,f[ce+0]=Y,f[ce+1]=K,f[ce+2]=te,m[se+0]=d[G+4],m[se+1]=L,U++}}let y=e.wallQuadPattern;if(y===void 0){y=[];let S=0;for(let x=0;x<e.count;x++)(!e.continuous[x]||x===0)&&S++,y.push(S,x===e.count-1?0:S+1),S++;e.wallQuadPattern=y}let g=u-1,v=y.length,b=e.isHole;for(let S=0;S<g;S++){let x=e.verticesStart*u+e.verticesCount*S,w=x+e.verticesCount;for(let A=0;A<v;A+=2){let C=x+y[A],P=x+y[A+1],M=w+y[A+1],B=w+y[A];b?(s[l++]=C,s[l++]=M,s[l++]=P,s[l++]=C,s[l++]=B,s[l++]=M):(s[l++]=C,s[l++]=P,s[l++]=M,s[l++]=C,s[l++]=M,s[l++]=B)}}return l}_closeEnd(e,r,n,o,a,s,l,c){let d=e.vertexCount,u=new ke.Vector3(0,0,c?-1:1).applyMatrix4(s),p=new ke.Vector3,h=new ke.Vector2;for(let m=0;m<d;m++){let y=2*m;p.set(e.vertices[y+0],e.vertices[y+1],0).applyMatrix4(s).add(l),this._insertVertex(a,r+m,p,u,h)}let f=e.elements;for(let m=0;m<e.elementCount;m++){let y=3*m;n[o++]=f[y+0]+r,n[o++]=f[y+(c?1:2)]+r,n[o++]=f[y+(c?2:1)]+r}return o}};Oi("PathGeometry",(i,t,e)=>new eg(i,t,e));Ep("PathGeometry",TO);Pe("3d-paths");Mi.Cloner=Fn;Pe("cloners");gt();var Ad=require("three");function $p(i){if(i.component){let t=i.component.instances.indexOf(i);t>=0&&i.component.instances.splice(t,1);for(let e of i.children)Le.is(e)&&$p(e)}}var eh=class extends ki(Ad.Group,Fi){constructor(e,r,n){super();this.isComponentObject=!0;r.type==="Instance"&&typeof e=="string"&&(r=this.transformAssignData(r,n)),this.super_Entity(e,r),this.objectHelper.update()}get isComponentRoot(){return this.data.type==="Component"&&typeof this.identity=="string"}get isInstanceRoot(){return this.data.type==="Instance"&&typeof this.identity=="string"}transformAssignData(e,r){let n=fs.getComponentData({scene:r.scene.data,shared:r.shared.data},e.component);if(n){let o,a;for(let s of No.rootOverrideProps)e[s]===void 0?(o===void 0&&(o={...e}),o[s]=n.data[s]):(a===void 0&&(a={}),a[s]=e[s],o===void 0&&(o={...e}),o[s]=Mo.apply(n.data[s],e[s]));return this.overrideData=a,o}else return{...yr.defaultData,...e,...Sp(yr.defaultData,No.rootOverrideProps)}}updateByOp(e,r,n,o){let a;if(this.isInstanceRoot&&!o){if(r=this.transformAssignData(r,n),e.type===0&&e.path.length===0&&this.component)for(let s of No.rootOverrideProps)s in e.props&&e.props[s]===void 0&&(a===void 0&&(a={...e,props:{...e.props}}),a.props[s]=this.component.data[s]);else if(e.type===0&&e.path.length>0&&No.rootOverrideProps.includes(e.path[0])){let s=e.path[0];a===void 0&&(a={...e,path:[],props:{[s]:r[s]}})}}super.updateByOp(a??e,r,n,o)}updateState(e,r){this.updateState_Entity(e,r)}expandInstanceChildren(e){let r=this.data;if(this.component===void 0){let n=e.scene.find(r.component)??null,o=!1;if(n!==this.oldComponent){if(this.oldComponent){let a=0;for(let s of this.children)if(Le.is(s))e.scene.disposeAndUnregisterEntityRecursivelyIfNotReregistered(s),$p(s),a+=1;else break;this.children.splice(0,a)}o=!0}if(n){let a={};MO(e,[this.uuid],r.overrides,this,n,n,0,o,a);for(let s of this.children)if(Le.is(s)){let l=s.data;l.type==="Empty"&&l.animations&&s.traverseEntity(c=>{let d=c.dataPatched;if(c instanceof tt&&d.bones&&d.boneInverses){let u=c.dataPatched;if(u.bones&&u.boneInverses){let p=u.bones.map(m=>e.scene.find(a[m])),h=u.boneInverses.map(m=>new Ad.Matrix4().fromArray(m)),f=new Ad.Skeleton(p,h);c.bind(f,c.bindMatrix)}}else c.matrixAutoUpdate=!0})}}this.oldComponent=this.component}}};function PO(i,t,e,r){return i.component===t&&so(i.identity,r)?i.overrideData===e?2:1:0}function MO(i,t,e,r,n,o,a,s,l){if(a>50)return!1;if(r.component!==n){if(r.component){let d=r.component.instances.indexOf(r);d>=0&&r.component.instances.splice(d,1)}n.instances.find(d=>d===r)||n.instances.push(r),r.component=n}n instanceof eh&&n.isInstanceRoot&&n.expandInstanceChildren(i);let c=0;for(let d of n.children)if(Le.is(d)){let u=[...t,...typeof d.identity=="string"?[d.identity]:d.identity],p=Dc.resolve(e,u,1);p!=null&&!(p instanceof bt)&&(Object.setPrototypeOf(p,bt.prototype),console.error("wrong prototype"));let h=null,f;if(!s){let m=r.children[c];if(h=Le.is(m)?m:null,h!==null){let y=PO(h,d,p,u);f=y>=1?h.stateSelection:void 0,y!==2&&(h=null)}if(h===null&&(h=i.scene.findInstance(u)??null,h!==null)){let y=PO(h,d,p,u);if(f=y>=1?h.stateSelection:void 0,y!==2)h=null;else{let g=h.parent.children.indexOf(h);h.parent.children.splice(g,1),r.children.splice(c,0,h),h.parent===r?(g<=c&&console.error("not possible"),void 0):(h.parent=r,h.matrixWorldNeedsUpdate=!0,h.resetBBoxNeedsUpdate(),h.updateVisible(),i.pendingDeletes.delete(h),void 0)}}}if(h===null){let m=p?Mo.apply(d.data,p):d.data;no.is(m.type)&&(m={...m,type:"Empty"}),h=Mi.createEntity(u,m,i),h.overrideData=p,r.add(h),r.children.splice(r.children.length-1,1),r.children.splice(c,0,h),h.updateState(h.data,i),f&&h.changeSelectedState(f,i),i.scene.registerInstanceAndSetUuid(h)}if(h.isBone){let m=h.identity[h.identity.length-1];l[m]=h.uuid}c+=1,MO(i,t,e,h,d,o,a+1,s,l)}if(!s){let d=c;for(;;){let u=r.children[c];if(Le.is(u))i.pendingDeletes.add(u);else break;c+=1}r.children.splice(d,c-d)}return!0}var OO=(i,t,e)=>new eh(i,t,e);wl("Component",OO);wl("Instance",OO);Pe("components");var WS=1e-10;function IO(i){let t=i[0][0],e=i[1][0],r=i[0][1],n=i[1][1],o=Math.sqrt(t*t+e*e),a=o>WS?t/o:1,s=o>WS?e/o:0,l=a*t+s*e,c=a*n-s*r,d=a*r+s*n;return{rotation:Math.atan2(s,a),scale:[l,c],shear:[Math.abs(c)>WS?d/c:0,0]}}function DO({rotation:i,scale:t,shear:e}){let r=Math.cos(i),n=Math.sin(i),o=e[0]*t[1],a=e[1]*t[0];return[r*t[0]-n*a,n*t[0]+r*a,r*o-n*t[1],n*o+r*t[1]]}var Oe;(x=>{function i(){return[1,0,0,0,1,0,0,0,1]}x.identity=i;function t(w,A=x.identity()){for(let C=0,P=w.length;C<P;C++)A[C]=w[C];return A}x.copy=t;function e(w,A,C,P,M,B){return x.setAbcdef(x.identity(),w,A,C,P,M,B)}x.create=e;function r(w,A,C,P,M,B,I){return w[0]=A,w[1]=P,w[2]=B,w[3]=C,w[4]=M,w[5]=I,w}x.setAbcdef=r;function n(w,A){let[C,P,M,B,I,_]=a(w),[E,R,L,F,k,W]=a(A),U=E*C+R*M,G=E*P+R*B,q=L*C+F*M,X=L*P+F*B,Y=k*C+W*M+I,K=k*P+W*B+_;return x.create(U,G,q,X,Y,K)}x.append=n;function o(w,A){let[C,P,M,B,I,_]=a(w),[E,R,L,F,k,W]=a(A),U=C,G=P,q=M,X=B;(E!==1||R!==0||L!==0||F!==1)&&(U=C*E+P*L,G=C*R+P*F,q=M*E+B*L,X=M*R+B*F);let Y=I*E+_*L+k,K=I*R+_*F+W;return x.create(U,G,q,X,Y,K)}x.prepend=o;function a(w){return[w[0],w[3],w[1],w[4],w[2],w[5]]}x.getAbcdef=a;function s(w){let[A,C,P,M,B,I]=x.getAbcdef(w),_=A*M-C*P,E=M/_,R=-C/_,L=-P/_,F=A/_,k=(P*I-M*B)/_,W=-(A*I-C*B)/_;return x.create(E,R,L,F,k,W)}x.invert=s;function l([w,A],C){let[P,M,B,I,_,E]=x.getAbcdef(C);return[P*w+B*A+_,M*w+I*A+E]}x.apply=l;function c(w,A){let[C,P,M,B,I,_]=x.getAbcdef(A),E=1/(C*B+M*-P),[R,L]=w;return[B*E*R+-M*E*L+(_*M-I*B)*E,C*E*L+-P*E*R+(-_*C+I*P)*E]}x.applyInverse=c;function d(w,A,C=A){let[P,M,B,I,_,E]=x.getAbcdef(w);return x.setAbcdef(w,P*A,M*C,B*A,I*C,_*A,E*C),w}x.scale=d;function u(w,A){let C=Math.cos(A),P=Math.sin(A),[M,B,I,_,E,R]=x.getAbcdef(w);return x.setAbcdef(w,M*C-B*P,M*P+B*C,I*C-_*P,I*P+_*C,E*C-R*P,E*P+R*C),w}x.rotate=u;function p(w,A,C){let[P,M]=C,B=x.translate(w,-P,-M);return B=x.rotate(B,A),B=x.translate(B,P,M),B}x.rotateAround=p;function h(w,A,C){let[P,M,B,I,_,E]=x.getAbcdef(w);return x.setAbcdef(w,P,M,B,I,_+A,E+C),w}x.translate=h;function f(w,A,C){let[P,M,B,I]=x.getAbcdef(w);return x.setAbcdef(w,P,M,B,I,A,C),w}x.setTranslate=f;function m(w,A,C){let[P,M,B,I]=x.getAbcdef(w);return x.setAbcdef(w,P,M,B,I,A,C),w}x.setPosition=m;function y(w){let[A,C,P,M]=x.getAbcdef(w),B=Math.sqrt(A*A+C*C),I=Math.sqrt(P*P+M*M);return[B,I]}x.getScale=y;function g(w){let[,,,,A,C]=x.getAbcdef(w);return[A,C]}x.getPosition=g;function v(w,A){return x.decompose(w,A).rotation}x.getRotation=v;function b(w,A){let[C,P,M,B,I,_]=x.getAbcdef(w),{rotation:E,scale:R,shear:L}=IO([[C,M],[P,B]]);return{position:[I+(A[0]*C+A[1]*M)-A[0],_+(A[0]*P+A[1]*B)-A[1]],scale:R,rotation:E,shear:L,pivot:A}}x.decompose=b;function S(w,A,C,P,M=[0,0]){let[B,I]=w,[_,E]=P,[R,L,F,k]=DO({rotation:C,scale:A,shear:M}),W=B-(_*R+E*F)+_,U=I-(_*L+E*k)+E;return x.create(R,L,F,k,W,U)}x.compose=S})(Oe||(Oe={}));function DV(i,t){let[[e,r],[n,o]]=i,[[a,s],[l,c]]=t,d=(e-n)*(s-c)-(r-o)*(a-l);if(d===0)return!1;let u=((e-a)*(s-c)-(r-s)*(a-l))/d,p=-((e-n)*(r-s)-(r-o)*(e-a))/d;return u>=0&&u<=1&&p>=0&&p<=1}var BO=[[-1,1],[-1,-1],[1,-1],[1,1]],RO=(i,t,e)=>{let r=i.getCenter(),n=i.getHalfSize(),o=Oe.append(t,i.worldMatrix);n[0]===0&&n[1]===0?e.push(Oe.apply(r,o)):BO.forEach(a=>{let s=[a[0]*n[0]+r[0],a[1]*n[1]+r[1]];e.push(Oe.apply(s,o))})},Ps=class{constructor(){this.matrix=Oe.identity();this.min=[1/0,1/0];this.max=[-1/0,-1/0];this.vertices=[];this.edges=[]}setFromObjectSize(t,e=!1){t.updateWorldMatrix(),this.makeEmpty(),Oe.copy(t.worldMatrix,this.matrix);let r=Oe.invert(t.worldMatrix);this.expandByObjectSize(t,r,e)}expandByObjectSize(t,e,r=!1){let n=[],o=t.isBaseGroup===!0?t:void 0;r===!0&&o!==void 0?o.traverse(a=>{a.visible&&RO(a,e,n)}):RO(t,e,n),this.setFromPoints(n)}setFromSize(t,e,r){this.makeEmpty(),Oe.copy(r,this.matrix),this.expandBySize(t,e,r)}expandBySize(t,e,r){[Oe.apply([0,0],r),Oe.apply([0,e],r),Oe.apply([t,e],r),Oe.apply([t,0],r)].forEach(o=>this.expandByPoint(o))}getCenter(){let[t,e]=this.min,[r,n]=this.getHalfSize();return Oe.apply([t+r,e+n],this.matrix)}getSize(){return[this.max[0]-this.min[0],this.max[1]-this.min[1]]}getHalfSize(){return[(this.max[0]-this.min[0])*.5,(this.max[1]-this.min[1])*.5]}makeEmpty(){this.min=[1/0,1/0],this.max=[-1/0,-1/0]}setFromPoints(t){this.makeEmpty();for(let e of t)this.expandByPoint(e)}expandByPoint(t){this.min=[Math.min(this.min[0],t[0]),Math.min(this.min[1],t[1])],this.max=[Math.max(this.max[0],t[0]),Math.max(this.max[1],t[1])]}computeVertices(){let[t,e]=this.getHalfSize(),r=this.getCenter(),[n,o,a,s]=Oe.getAbcdef(this.matrix),l=Oe.create(n,o,a,s,r[0],r[1]);this.vertices=BO.map(([c,d])=>Oe.apply([c*t,d*e],l))}computeEdges(){this.edges=[];for(let t=0,e=this.vertices.length;t<e;++t)this.edges.push([this.vertices[t],this.vertices[(t+1)%e]])}project(t,e){let r=this.matrix;return e&&(r=Oe.append(e.worldMatrix,r)),Oe.applyInverse(t,r)}intersects(t,e,r){return this.intersectsInLocalSpace(...this.project([t,e],r))}intersectsInLocalSpace(t,e){let{min:r,max:n}=this;return t>=r[0]&&t<=n[0]&&e>=r[1]&&e<=n[1]}containsPoint(t){let[e,r]=t,[n,o]=this.min,[a,s]=this.max;return e>=n&&e<=a&&r>=o&&r<=s}intersectsBBox2D(t){for(let e=0,r=this.edges.length;e<r;e++){let n=this.edges[e];for(let o=0,a=t.edges.length;o<a;o++){let s=t.edges[o];if(DV(n,s))return!0}}for(let e=0,r=t.vertices.length;e<r;e++){let n=t.vertices[e];if(this.containsPoint(n))return!0}return!1}ensureMinMax(){let t=this.min,e=this.max;this.min=[Math.min(t[0],e[0]),Math.min(t[1],e[1])],this.max=[Math.max(t[0],e[0]),Math.max(t[1],e[1])]}copy(t){this.min=[...t.min],this.max=[...t.max],Oe.copy(t.matrix,this.matrix),this.computeVertices(),this.computeEdges()}clone(){let t=new Ps;return t.copy(this),t}};var RV='{"schema":13,"scenes":[{"fi":0,"id":"32603ebf4-bd9a-54ba-c1e9-6645c3ee7a53","data":{"name":"Page","backgroundColor":[0,0,0,0],"objects":[]}}],"assets":{"images":{},"videos":{},"colors":{},"audios":{},"numbers":{},"booleans":{},"strings":{},"dynamicVariables":{"counters":{},"randoms":{},"timers":{},"times":{}},"fonts":{},"animations":{},"geometries":{},"emojiArt":{}},"publish":{"logo":true,"presentationSizing":"Contain","allowPageScroll":true,"showBackground":true},"framePublish":{},"components":{}}',NO=()=>JSON.parse(RV);async function BV(i,t){return await i.default(t?{module_or_path:t}:void 0),Object.getOwnPropertyDescriptor(i.Engine.prototype,"scene")||Object.defineProperty(i.Engine.prototype,"scene",{get:function(){let e=Object.create(i.SceneController.prototype);return e.__wbg_ptr=this.__wbg_ptr,e}}),{createEngine:e=>i.Engine.create(e,NO(),!0)}}var tg,th;function NV(i){tg=i}function qS(){if(!th){if(!tg)return Promise.reject(new Error("HanaRenderer: no Hana UI loader registered. Call setHanaUILoader() from the host app before initializing a HanaRenderer."));th=tg(),th.catch(()=>{th=void 0})}return th}var LO;function LV(){let i=typeof process<"u"?"2.0.86":void 0;return`https://cdn.spline.design/@splinetool/runtime${i?`@${i}`:""}/build/hana-ui.wasm`}function _O(i){LO=i}function rg(){return tg||NV(async()=>{let t=await import("./hana-ui.js");return BV(t,LO??LV())}),qS().then(()=>{})}var og=gc(ig(),1);function GO(i){let t=[],e;try{e=(0,og.makeAbsolute)((0,og.parseSVG)(i))}catch(c){return console.error("[HanaRenderer] Failed to parse SVG path:",c),t}let r=0,n=0,o=0,a=0,s=null,l=null;for(let c of e){let d=null,u=null;switch(c.code){case"M":r=o=c.x,n=a=c.y,t.push({MoveTo:{x:r,y:n}});break;case"L":r=c.x,n=c.y,t.push({LineTo:{x:r,y:n}});break;case"H":r=c.x,t.push({LineTo:{x:r,y:n}});break;case"V":n=c.y,t.push({LineTo:{x:r,y:n}});break;case"C":{let p={x:c.x1,y:c.y1},h={x:c.x2,y:c.y2};r=c.x,n=c.y,t.push({CurveTo:[p,h,{x:r,y:n}]}),d=h;break}case"S":{let p=s?{x:2*r-s.x,y:2*n-s.y}:{x:r,y:n},h={x:c.x2,y:c.y2};r=c.x,n=c.y,t.push({CurveTo:[p,h,{x:r,y:n}]}),d=h;break}case"Q":{let p={x:c.x1,y:c.y1};r=c.x,n=c.y,t.push({QuadTo:[p,{x:r,y:n}]}),u=p;break}case"T":{let p=l?{x:2*r-l.x,y:2*n-l.y}:{x:r,y:n};r=c.x,n=c.y,t.push({QuadTo:[p,{x:r,y:n}]}),u=p;break}case"A":{let p=r,h=n;r=c.x,n=c.y,VV(t,p,h,c.rx,c.ry,c.xAxisRotation,c.largeArc,c.sweep,r,n);break}case"Z":r=o,n=a,t.push("ClosePath");break}s=d,l=u}return t}function VV(i,t,e,r,n,o,a,s,l,c){if(t===l&&e===c)return;if(r=Math.abs(r),n=Math.abs(n),r===0||n===0){i.push({LineTo:{x:l,y:c}});return}let d=o*Math.PI/180,u=Math.cos(d),p=Math.sin(d),h=(t-l)/2,f=(e-c)/2,m=u*h+p*f,y=-p*h+u*f,g=m*m/(r*r)+y*y/(n*n);if(g>1){let U=Math.sqrt(g);r*=U,n*=U}let v=r*r,b=n*n,S=v*b-v*y*y-b*m*m,x=v*y*y+b*m*m,w=(a!==s?1:-1)*Math.sqrt(Math.max(0,S/x)),A=w*(r*y)/n,C=w*(-n*m)/r,P=u*A-p*C+(t+l)/2,M=p*A+u*C+(e+c)/2,B=Math.atan2((y-C)/n,(m-A)/r),_=Math.atan2((-y-C)/n,(-m-A)/r)-B;!s&&_>0?_-=2*Math.PI:s&&_<0&&(_+=2*Math.PI);let E=Math.max(1,Math.ceil(Math.abs(_)/(Math.PI/2))),R=_/E,L=4/3*Math.tan(R/4),F=B,k=t,W=e;for(let U=0;U<E;U++){let G=F+R,q=Math.cos(F),X=Math.sin(F),Y=Math.cos(G),K=Math.sin(G),te=P+r*Y*u-n*K*p,ue=M+r*Y*p+n*K*u,se=-r*X*u-n*q*p,ce=-r*X*p+n*q*u,de=-r*K*u-n*Y*p,ge=-r*K*p+n*Y*u;i.push({CurveTo:[{x:k+L*se,y:W+L*ce},{x:te-L*de,y:ue-L*ge},{x:te,y:ue}]}),F=G,k=te,W=ue}}var sg=.5522847498307936,zV=150,jV=5*60*1e3,HV=1536/2816;function XO(i){let t=i.getUint32(0);if(t===65536||t===1330926671||t===1953658213)return 0;if(t===1953784678)return i.getUint32(8)>0?i.getUint32(12):void 0}function WV(i){try{return XO(new DataView(i))!==void 0}catch{return!1}}function qV(i){try{let t=new DataView(i),e=XO(t);if(e===void 0)return;let r=t.getUint16(e+4),n=-1,o=-1;for(let c=0;c<r;c++){let d=e+12+c*16,u=t.getUint32(d);u===1751474532&&(n=t.getUint32(d+8)),u===1330851634&&(o=t.getUint32(d+8))}if(n<0||o<0)return;let a=t.getUint16(n+18),s=t.getUint16(o);if(a===0||s<2)return;let l=t.getInt16(o+86);return l>0?l/a:void 0}catch{return}}var UO=!1;function zO(){UO||(UO=!0,console.warn("[HanaRenderer] clipRect: precise clipping of rotated/complex content is not supported by the Hana UI overlay yet; drawing unclipped. (Axis-aligned rectangles are clipped geometrically.)"))}var lg=class{constructor(t,e=1){this.canvas=t;this._dpr=e;this._width=0;this._height=0;this._isSizeDirty=!1;this._crashed=!1;this._shapes=[];this._lastPushedJSON="";this._ctm=Oe.identity();this._stack=[];this._clips=[];this._pathEls=[];this._simpleShape=null;this._pathPrimitives=0;this._fillColor=Ve.transparent;this._strokeColor=Ve.transparent;this._lineWidth=1;this._strokeMode="inside";this._layerBlur=0;this._backgroundBlur=0;this._dropShadowBlur=0;this._dropShadowOffsetX=0;this._dropShadowOffsetY=0;this._dropShadowColor=Ve.transparent;this._innerShadowBlur=0;this._innerShadowOffsetX=0;this._innerShadowOffsetY=0;this._innerShadowSpread=0;this._innerShadowColor=Ve.transparent;this._fonts=new Map;this._fontsFlushed=new Set;this._engineFonts=new Set;this._fontXPerEm=new Map;this._measureCache=new Map;try{let r=t.getBoundingClientRect();t.width=r.width*e,t.height=r.height*e}catch{console.log(t.width,e)}}get dpr(){return this._dpr}set dpr(t){this._dpr=t,this._isSizeDirty=!0}get width(){return this._width}get height(){return this._height}async init(){if(!(this._engine||this._crashed)){try{this._context=await qS(),this._engine=await this._context.createEngine(this.canvas)}catch(t){this._crashed=!0,console.error("[HanaRenderer] Failed to load the Hana UI engine; UI scenes will not render.",t);return}if(this._width>0&&this._height>0)this._syncViewport();else{let t=this.canvas.getBoundingClientRect();t.width>0&&t.height>0&&(this._width=t.width,this._height=t.height,this._syncViewport())}this._flushFonts(),this.uiFontReady=this._watchUiFont()}}_watchUiFont(){return new Promise(t=>{let e=this._engine;if(!e||typeof e.scene.isUiFontLoaded!="function"){t();return}let r=()=>{let a=!1;return this._guard(()=>{a=e.scene.isUiFontLoaded()}),a};if(r()){t();return}let n=Date.now(),o=setInterval(()=>{if(this._crashed||Date.now()-n>jV){clearInterval(o);return}r()&&(clearInterval(o),t())},zV)})}_syncViewport(){let t=this._engine;if(!t||this._crashed)return;let e=this._width,r=this._height;this.canvas.style.width=e+"px",this.canvas.style.height=r+"px",this.canvas.width=Math.max(1,Math.ceil(e*this._dpr)),this.canvas.height=Math.max(1,Math.ceil(r*this._dpr)),this._guard(()=>{t.resize([e,r],this._dpr),t.scene.updateCamera({position:[e/2,r/2],zoom:1})})}setSize(t,e){!this._isSizeDirty&&t===this._width&&e===this._height||(this._isSizeDirty=!1,this._width=t,this._height=e,this._engine?this._syncViewport():(this.canvas.style.width=t+"px",this.canvas.style.height=e+"px",this.canvas.width=Math.max(1,Math.ceil(t*this._dpr)),this.canvas.height=Math.max(1,Math.ceil(e*this._dpr))))}_guard(t){if(!this._crashed)try{t()}catch(e){this._crashed=!0,console.error("[HanaRenderer] Hana engine call failed; disabling this renderer instance.",e)}}async loadFont(t,e){try{let r=await fetch(t);if(!r.ok){console.error(`[HanaRenderer] loadFont: ${t} returned HTTP ${r.status}; skipping "${e}"`);return}let n=await r.arrayBuffer();if(n.byteLength===0){console.error(`[HanaRenderer] loadFont: ${t} was empty; skipping "${e}"`);return}this.registerFont(n,e)}catch(r){console.error(`[HanaRenderer] loadFont failed for "${e}" (${t}):`,r)}}registerFont(t,e){if(this._fonts.has(e))return;this._fonts.set(e,t),WV(t)&&this._engineFonts.add(e);let r=qV(t);r!==void 0&&this._fontXPerEm.set(e,r),this._flushFonts()}_flushFonts(){let t=this._engine;if(!!t)for(let[e,r]of this._fonts)this._fontsFlushed.has(e)||(this._fontsFlushed.add(e),this._guard(()=>{t.scene.addLocalFont(e,new Uint8Array(r))===!1&&this._engineFonts.delete(e)}))}set strokeColor(t){this._strokeColor=t}set fillColor(t){this._fillColor=t}set lineWidth(t){this._lineWidth=t}set strokeMode(t){this._strokeMode=t}set dropShadowBlur(t){this._dropShadowBlur=t}set dropShadowColor(t){this._dropShadowColor=t}set dropShadowOffsetX(t){this._dropShadowOffsetX=t}set dropShadowOffsetY(t){this._dropShadowOffsetY=t}set innerShadowBlur(t){this._innerShadowBlur=t}set innerShadowColor(t){this._innerShadowColor=t}set innerShadowOffsetX(t){this._innerShadowOffsetX=t}set innerShadowOffsetY(t){this._innerShadowOffsetY=t}set innerShadowSpread(t){this._innerShadowSpread=t}set layerBlur(t){this._layerBlur=t}set backgroundBlur(t){this._backgroundBlur=t}save(){this._stack.push({ctm:Oe.copy(this._ctm),clipLen:this._clips.length})}restore(){let t=this._stack.pop();!t||(this._ctm=t.ctm,this._clips.length=t.clipLen)}setTransform(t,e=!1){let r=Oe.identity();if(this.camera?.enabled&&(r=Oe.append(r,this.camera.worldMatrix),e)){let n=Oe.getScale(this.camera.worldMatrix);r=Oe.scale(r,1/n[0],1/n[1])}this._ctm=Oe.append(r,t)}transform(t){this._ctm=Oe.append(this._ctm,t)}beginPath(){this._pathEls=[],this._simpleShape=null,this._pathPrimitives=0}closePath(){this._pathEls.length!==0&&this._pathEls[this._pathEls.length-1]!=="ClosePath"&&this._pathEls.push("ClosePath")}_startFreeform(){this._simpleShape=null,this._pathPrimitives++}moveTo(t,e){this._startFreeform(),this._pathEls.push({MoveTo:{x:t,y:e}})}lineTo(t,e){this._startFreeform(),this._pathEls.push({LineTo:{x:t,y:e}})}bezierCurveTo(t,e,r,n,o,a){this._startFreeform(),this._pathEls.push({CurveTo:[{x:t,y:e},{x:r,y:n},{x:o,y:a}]})}quadraticCurveTo(t,e,r,n){this._startFreeform(),this._pathEls.push({QuadTo:[{x:t,y:e},{x:r,y:n}]})}path(t){this._startFreeform(),this._pathEls.push(...GO(t))}rect(t,e,r,n,o=0,a=0,s=0,l=0){if(!WO([t,e,r,n]))return;let c={x:t,y:e,w:r,h:n,radii:[o,a,s,l]};this._pathPrimitives++,this._simpleShape=this._pathPrimitives===1&&this._pathEls.length===0?{kind:"rect",rect:c,smoothing:0}:null,qO(this._pathEls,c)}ellipse(t,e,r,n,o,a,s,l){if(!!WO([t,e,r,n])){if(r<0||n<0)throw Error("radii cannot be negative");this._pathPrimitives++,this._simpleShape=this._pathPrimitives===1&&this._pathEls.length===0?{kind:"ellipse",cx:t,cy:e,rx:r,ry:n}:null,KV(this._pathEls,t,e,r,n)}}clipRect(t,e,r,n,o=0,a=0,s=0,l=0){let c=Oe.invert(this._ctm);!c||this._clips.push({m:Oe.copy(this._ctm),inv:c,rect:{x:t,y:e,w:r,h:n,radii:[o,a,s,l]}})}fill(){this._emit(!0)}stroke(){this._strokeColor.a<=0||this._lineWidth<=0||this._emit(!1)}_emit(t){let e=this._effectChain(t);if(t&&this._fillColor.a<=0&&!e)return;let r=this._classifyShape();if(!r)return;let n=this._applyClips(r);if(n==="skip")return;if(!t&&n!==r){let a=rh(r);if(a){this._emitClippedRectStroke(a,e);return}}r=n;let o={shape:r,color:t?Cd(this._fillColor):[0,0,0,0],transform:Oe.getAbcdef(this._ctm)};t||(o.stroke=this._strokeDesc()),e&&(o.effect_chain=e),this._shapes.push(o)}_emitClippedRectStroke(t,e){let r=this._lineWidth,n=this._strokeMode==="outside"?r:this._strokeMode==="center"?r/2:0,o=r-n,a=Math.min(t.w,t.h)/2,s=t.radii.map(g=>Math.max(0,Math.min(g,a))),l={x:t.x-n,y:t.y-n,w:t.w+n*2,h:t.h+n*2,radii:s.map(g=>g>0?g+n:0)},c=t.w-o*2,d=t.h-o*2,u=c>0&&d>0?{x:t.x+o,y:t.y+o,w:c,h:d,radii:s.map(g=>Math.max(0,g-o))}:null,p=this._applyClips(ag(l,0));if(p==="skip")return;let h=rh(p)??l,f=null;if(u){let g=this._applyClips(ag(u,0));f=g==="skip"?null:rh(g)??u}let m=[];qO(m,h),f&&QV(m,f);let y={shape:{Custom:m},color:Cd(this._strokeColor),transform:Oe.getAbcdef(this._ctm)};e&&(y.effect_chain=e),this._shapes.push(y)}_classifyShape(){let t=this._simpleShape;return t?t.kind==="rect"?ag(t.rect,t.smoothing):{Ellipse:{center_x:t.cx,center_y:t.cy,rx:t.rx,ry:t.ry}}:this._pathEls.length===0?null:{Custom:this._pathEls.slice()}}_strokeDesc(){return{width:this._lineWidth,line_join:"Miter",color:Cd(this._strokeColor),align:XV[this._strokeMode],cap:"Butt"}}_effectChain(t){let e=this.camera?.scale??1,r=[];if(t&&this._dropShadowColor.a>0&&r.push({DropShadow:{position:[this._dropShadowOffsetX*e,this._dropShadowOffsetY*e],blur:{Uniform:{size:2*this._dropShadowBlur*e}},spread:0,color:Cd(this._dropShadowColor)}}),t&&this._backgroundBlur>0){let[n,o]=Oe.getScale(this._ctm),a=(n+o)/2;r.push({BackgroundBlur:{blur:{Uniform:{size:2*this._backgroundBlur*a}}}})}if(this._layerBlur>0&&r.push({LayerBlur:{blur:{Uniform:{size:2*this._layerBlur*e}}}}),t&&this._innerShadowColor.a>0){let[n,o,a,s]=Oe.getAbcdef(this._ctm),l=this._innerShadowOffsetX,c=this._innerShadowOffsetY;r.push({InnerShadow:{position:[n*l+a*c,o*l+s*c],blur:{Uniform:{size:2*this._innerShadowBlur*e}},spread:this._innerShadowSpread*e,color:Cd(this._innerShadowColor)}})}return r.length>0?r:void 0}_applyClips(t,e=this._ctm){if(this._clips.length===0)return t;let r=t;for(let n of this._clips){let o=Oe.append(n.inv,e),[a,s,l,c,d,u]=Oe.getAbcdef(o),p=Math.abs(s)<=1e-6*(Math.abs(a)+Math.abs(c))&&Math.abs(l)<=1e-6*(Math.abs(a)+Math.abs(c)),h=YV(r);if(!h)return r;if(!p){zO();continue}let f=a*h.minX+d,m=a*h.maxX+d,y=c*h.minY+u,g=c*h.maxY+u,v=Math.min(f,m),b=Math.max(f,m),S=Math.min(y,g),x=Math.max(y,g),w=n.rect,A=Math.max(v,w.x),C=Math.max(S,w.y),P=Math.min(b,w.x+w.w),M=Math.min(x,w.y+w.h);if(A>=P||C>=M)return"skip";if(A===v&&C===S&&P===b&&M===x)continue;let I=rh(r);if(!I||a===0||c===0){zO();continue}let _=(A-d)/a,E=(P-d)/a,R=(C-u)/c,L=(M-u)/c,F=Math.min(_,E),k=Math.min(R,L),W=Math.abs(E-_),U=Math.abs(L-R),[G,q,X,Y]=I.radii,K=F!==I.x,te=k!==I.y,ue=F+W!==I.x+I.w,se=k+U!==I.y+I.h,ce=Math.min(W,U)/2,de=[K||te?0:Math.min(G,ce),ue||te?0:Math.min(q,ce),ue||se?0:Math.min(X,ce),K||se?0:Math.min(Y,ce)];r=ag({x:F,y:k,w:W,h:U,radii:de},0)}return r}drawText(t,e){let r=this._engineFonts.has(e.font),n=this._fontXPerEm.get(e.font),o=!r&&n?n/HV:1,a={TextSimple:{text:t,font_size:e.fontSize*o,size:[e.width,e.height],horizontal_align:jO[e.horizontalAlign]??"Left",vertical_align:HO[e.verticalAlign]??"Top",line_height:e.lineHeight,letter_spacing:e.letterSpacing,...r?{font_id:e.font}:{}}},s=this._effectChain(!0),l=this._fillColor.a>0,c=this._strokeColor.a>0&&this._lineWidth>0;if(l||c||s){let d=Oe.append(this._ctm,Oe.translate(Oe.identity(),e.x,e.y));if(this._applyClips(a,d)!=="skip"){let u={shape:a,color:l?Cd(this._fillColor):[0,0,0,0],transform:Oe.getAbcdef(d)};c&&(u.stroke=this._strokeDesc()),s&&(u.effect_chain=s),this._shapes.push(u)}}return{height:this._measureTextHeight(t,e)}}_measureTextHeight(t,e){let r=`${e.font}|${e.fontSize}|${e.lineHeight}|${e.letterSpacing}|${e.width}|${t}`,n=this._measureCache.get(r);if(n!==void 0)return n;let o=0,a=this._engine;if(a&&!this._crashed&&this._fontsFlushed.has(e.font))try{let[,s]=a.scene.measureTextNaturalSize({size:[e.width,e.height],text:t,fontSize:e.fontSize,horizontalAlign:jO[e.horizontalAlign]??"Left",verticalAlign:HO[e.verticalAlign]??"Top",lineHeight:e.lineHeight,letterSpacing:e.letterSpacing,textTransform:"None",font:e.font,version:0,autoSize:"None",truncate:"None"});o=s}catch{}if(!(o>0)){let s=e.fontSize*.55+Math.max(0,e.letterSpacing),l=Math.max(1,Math.floor(e.width/s)),c=0;for(let d of t.split(`
|
|
1312
1312
|
`))c+=Math.max(1,Math.ceil(d.length/l));o=c*e.fontSize*e.lineHeight}return this._measureCache.size>512&&this._measureCache.clear(),this._measureCache.set(r,o),o}clear(){this._shapes=[],this._ctm=Oe.identity(),this._stack.length=0,this._clips.length=0}render(){let t=this._engine;if(!t||this._crashed)return;let e=JSON.stringify(this._shapes);e!==this._lastPushedJSON&&(this._guard(()=>t.scene.updateUiShapes(this._shapes)),this._lastPushedJSON=e),this._guard(()=>t.onFrame())}},XV={inside:"Inside",outside:"Outside",center:"Center"},jO={[1]:"Left",[2]:"Right",[3]:"Center",[4]:"Justify"},HO={[1]:"Top",[2]:"Center",[3]:"Bottom"};function Cd({r:i,g:t,b:e,a:r}){return[i,t,e,r]}function WO(i){for(let t=0;t<i.length;t++)if(i[t]!==void 0&&!Number.isFinite(i[t]))return!1;return!0}function ag(i,t){let[e,r,n,o]=i.radii;return e===0&&r===0&&n===0&&o===0?{Rectangle:{x:i.x,y:i.y,width:i.w,height:i.h}}:{RoundedRectangle:{x:i.x,y:i.y,width:i.w,height:i.h,radius:[e,r,n,o],corner_smoothing:t}}}function rh(i){if("Rectangle"in i){let t=i.Rectangle;return{x:t.x,y:t.y,w:t.width,h:t.height,radii:[0,0,0,0]}}if("RoundedRectangle"in i){let t=i.RoundedRectangle;return{x:t.x,y:t.y,w:t.width,h:t.height,radii:[t.radius[0],t.radius[1],t.radius[2],t.radius[3]]}}return null}function YV(i){let t=rh(i);if(t)return{minX:t.x,minY:t.y,maxX:t.x+t.w,maxY:t.y+t.h};if("Ellipse"in i){let e=i.Ellipse;return{minX:e.center_x-e.rx,minY:e.center_y-e.ry,maxX:e.center_x+e.rx,maxY:e.center_y+e.ry}}if("TextSimple"in i){let e=i.TextSimple;return{minX:0,minY:0,maxX:e.size[0],maxY:e.size[1]}}if("Custom"in i){let e=1/0,r=1/0,n=-1/0,o=-1/0,a=s=>{s.x<e&&(e=s.x),s.y<r&&(r=s.y),s.x>n&&(n=s.x),s.y>o&&(o=s.y)};for(let s of i.Custom)s!=="ClosePath"&&("MoveTo"in s?a(s.MoveTo):"LineTo"in s?a(s.LineTo):"QuadTo"in s?s.QuadTo.forEach(a):"CurveTo"in s&&s.CurveTo.forEach(a));return e===1/0?null:{minX:e,minY:r,maxX:n,maxY:o}}return null}function qO(i,t){let{x:e,y:r,w:n,h:o}=t,a=Math.min(n,o)/2,[s,l,c,d]=t.radii.map(p=>Math.max(0,Math.min(p,a)));if(s===0&&l===0&&c===0&&d===0){i.push({MoveTo:{x:e,y:r}},{LineTo:{x:e+n,y:r}},{LineTo:{x:e+n,y:r+o}},{LineTo:{x:e,y:r+o}},"ClosePath");return}let u=1-sg;i.push({MoveTo:{x:e+s,y:r}}),i.push({LineTo:{x:e+n-l,y:r}}),l>0&&i.push({CurveTo:[{x:e+n-l*u,y:r},{x:e+n,y:r+l*u},{x:e+n,y:r+l}]}),i.push({LineTo:{x:e+n,y:r+o-c}}),c>0&&i.push({CurveTo:[{x:e+n,y:r+o-c*u},{x:e+n-c*u,y:r+o},{x:e+n-c,y:r+o}]}),i.push({LineTo:{x:e+d,y:r+o}}),d>0&&i.push({CurveTo:[{x:e+d*u,y:r+o},{x:e,y:r+o-d*u},{x:e,y:r+o-d}]}),i.push({LineTo:{x:e,y:r+s}}),s>0&&i.push({CurveTo:[{x:e,y:r+s*u},{x:e+s*u,y:r},{x:e+s,y:r}]}),i.push("ClosePath")}function QV(i,t){let{x:e,y:r,w:n,h:o}=t,a=Math.min(n,o)/2,[s,l,c,d]=t.radii.map(p=>Math.max(0,Math.min(p,a)));if(s===0&&l===0&&c===0&&d===0){i.push({MoveTo:{x:e,y:r}},{LineTo:{x:e,y:r+o}},{LineTo:{x:e+n,y:r+o}},{LineTo:{x:e+n,y:r}},"ClosePath");return}let u=1-sg;i.push({MoveTo:{x:e+s,y:r}}),s>0&&i.push({CurveTo:[{x:e+s*u,y:r},{x:e,y:r+s*u},{x:e,y:r+s}]}),i.push({LineTo:{x:e,y:r+o-d}}),d>0&&i.push({CurveTo:[{x:e,y:r+o-d*u},{x:e+d*u,y:r+o},{x:e+d,y:r+o}]}),i.push({LineTo:{x:e+n-c,y:r+o}}),c>0&&i.push({CurveTo:[{x:e+n-c*u,y:r+o},{x:e+n,y:r+o-c*u},{x:e+n,y:r+o-c}]}),i.push({LineTo:{x:e+n,y:r+l}}),l>0&&i.push({CurveTo:[{x:e+n,y:r+l*u},{x:e+n-l*u,y:r},{x:e+n-l,y:r}]}),i.push("ClosePath")}function KV(i,t,e,r,n){let o=r*sg,a=n*sg;i.push({MoveTo:{x:t+r,y:e}},{CurveTo:[{x:t+r,y:e+a},{x:t+o,y:e+n},{x:t,y:e+n}]},{CurveTo:[{x:t-o,y:e+n},{x:t-r,y:e+a},{x:t-r,y:e}]},{CurveTo:[{x:t-r,y:e-a},{x:t-o,y:e-n},{x:t,y:e-n}]},{CurveTo:[{x:t+o,y:e-n},{x:t+r,y:e-a},{x:t+r,y:e}]},"ClosePath")}function YO(i){let t=!1;return i.scene.objects.traverse((e,r)=>{(r.type==="Mesh"&&r.geometry.type==="UIGeometry"||r.type==="Page"&&r.uiFrame!==void 0)&&(t=!0)}),t}var ZV=Math.PI/180,kne=180/Math.PI;function QO(i,t,e,r,n,o){let a=i-e,s=t-r;return a*a/(n*n)+s*s/(o*o)<=1}function KO(i){return i*ZV}gt();function _a(i){return{all:i=i||new Map,on:function(t,e){var r=i.get(t);r?r.push(e):i.set(t,[e])},off:function(t,e){var r=i.get(t);r&&(e?r.splice(r.indexOf(e)>>>0,1):i.set(t,[]))},emit:function(t,e){var r=i.get(t);r&&r.slice().map(function(n){n(e)}),(r=i.get("*"))&&r.slice().map(function(n){n(t,e)})}}}var Fa=class{constructor(t,e,r){this.uuid=t;this.data=e;this.isObject2D=!0;this.localMatrix=Oe.identity();this.worldMatrix=Oe.identity();this.ignoreCameraZoom=!1;this.visible=!0;this._singleBBox=new Ps;this._recursiveBBox=new Ps;this.singleBBoxNeedsUpdate=!0;this.recursiveBBoxNeedsUpdate=!0;this.stateSelection=null;this.prevState=null;this.currentState=null;this.reversibleToState=null;this.currentTransitionEvent=null;this.previousAction=null;this.name="";this.position=[0,0];this.scale=[1,1];this.rotation=0;this.shear=[0,0];this.emitter=_a();this.dpr=r.dpr??1,this.dataPatched=e}project(t,e){let r=this.worldMatrix;return e&&(r=Oe.append(e.worldMatrix,r)),Oe.applyInverse(t,r)}intersects(t,e,r,n=!1){return this.visible&&!this.data.raycastLock&&this.intersectsInLocalSpace(...this.project([t,e],r),n)}intersectsInLocalSpace(t,e,r=!1){let{min:n,max:o}=r?this.recursiveBBox:this.singleBBox;return t>=n[0]&&t<=o[0]&&e>=n[1]&&e<=o[1]}applyTransforms(t){t.setTransform(this.worldMatrix,this.ignoreCameraZoom)}get singleBBox(){return this.singleBBoxNeedsUpdate&&(this.singleBBoxNeedsUpdate=!1,this._singleBBox.setFromObjectSize(this,!1),this._singleBBox.computeVertices(),this._singleBBox.computeEdges()),this._singleBBox}get recursiveBBox(){return this.recursiveBBoxNeedsUpdate&&(this.recursiveBBoxNeedsUpdate=!1,this._recursiveBBox.setFromObjectSize(this,!0),this._recursiveBBox.computeVertices(),this._recursiveBBox.computeEdges()),this._recursiveBBox}updateLocalMatrix(){this.localMatrix=Oe.compose(this.position,this.scale,KO(this.rotation),Ca.getPivot(this.dataPatched),this.shear)}updateWorldMatrix(t,e,r){let n=this.parent;e&&n!==null&&n!==void 0&&n.updateWorldMatrix(t,!0,!1),t&&this.updateLocalMatrix(),this.parent?this.worldMatrix=Oe.append(this.parent.worldMatrix,this.localMatrix):this.worldMatrix=Oe.copy(this.localMatrix),this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0}get pivot(){return Ca.getPivot(this.data)}getCenter(){return[0,0]}getHalfSize(){return[0,0]}get id(){return this.uuid}resetBBoxNeedsUpdateSelf(){this.singleBBoxNeedsUpdate=!0,this.recursiveBBoxNeedsUpdate=!0}resetBBoxNeedsUpdate(){this.resetBBoxNeedsUpdateSelf(),this.traverseAncestors(t=>{t.resetBBoxNeedsUpdateSelf()})}updateTransformState(t){let e=!1;t.position!==void 0&&(e=!0,this.position=t.position),t.rotation!==void 0&&(e=!0,this.rotation=t.rotation),t.scale!==void 0&&(e=!0,this.scale=t.scale),t.shear!==void 0&&(e=!0,this.shear=t.shear),e&&(this.updateWorldMatrix(!0,!1,!0),this.resetBBoxNeedsUpdate())}updateByOp(t,e,r){t.type===0&&t.props.visible!==void 0&&(this.visible=t.props.visible),this.data=e,this.data=e;let n=t,o=Ye(t.path,["states","*"]);if(o!==null){if(t.type===0){let[a]=o;if(this?.stateSelection===a){let s={...t.props};if(delete s.name,Object.values(t.props).some(l=>l===void 0)){let l=this.data;if(l!==void 0){let c=jt.zoom(l,t.path.slice(2));if(c)for(let d in t.props)t.props[d]===void 0&&d in c&&(s[d]=c[d])}}n={...t,props:s,path:t.path.slice(2)}}}}else if(t.type===0){let a=this.stateSelection?this.data.states.data(this.stateSelection):void 0;if(a!==void 0){if(t.props.name!==void 0&&a.name){let{name:l,...c}=a;a=c}let s=jt.removeOverridden(t.path,t.props,a);n={...t,props:s}}}this.updateByPatchedOpBase(n,Aa.patch(this.data,this.stateSelection?this.data.states.data(this.stateSelection):void 0),r)}changeSelectedState(t,e,r=!1){if(!(this.data.states.length===0&&!r)){for(let n of this.data.states)Aa.toOps(this.data,n.data).forEach(a=>{let s=xc.replaceProps(a,this.data);this.dataPatched=this.data,this.updateByPatchedOp(s,this.data,e)});if(t!==null){let n=this.data.states.data(t);n&&(this.dataPatched=Aa.patch(this.data,n),Aa.toOps(this.data,n).forEach(a=>{this.updateByPatchedOp(a,this.dataPatched,e)}))}r&&this.updateTransformState(this.dataPatched),this.stateSelection=t}}updateState(t,e){t.name!==void 0&&(this.name=t.name),t.visible!==void 0&&(this.visible=t.visible),this.updateTransformState(t)}updateByPatchedOpBase(t,e,r){this.dataPatched=e,this.updateByPatchedOp(t,e,r)}updateByPatchedOp(t,e,r){t.path.length===0&&t.type===0&&this.updateState(t.props,r),this.requestRender()}traverseFrameAncestors(t){this.traverseAncestors(e=>{e.data.type==="frame2d"&&t(e)})}traverseAncestors(t){let e=this.parent;for(;e;)t(e),e=e.parent}requestRender(){this.traverseFrameAncestors(t=>{t.requestRender()})}clone(t){let e=new Fa(this.uuid,this.data,t);return e.parent=void 0,e}addEventListener(t,e){this.emitter.on(t,e)}removeEventListener(t,e){this.emitter.off(t,e)}dispatchEvent(t){this.emitter.emit(t.type,{...t,target:t.target??this})}traverseSortNextHelper(){let t=this.parent;if(t){let e=t.children;if(e){let r=e.indexOf(this)+1;return e[r]?e[r]:t.traverseSortNextHelper()}}}sortNext(){let t=this.children;return t&&t.length>0&&t[0]?t[0]:this.traverseSortNextHelper()}isDescendantOf(t){t instanceof Fa&&(t=t.uuid);let e=this;for(;e.parent;){if(e.parent.uuid===t)return!0;e=e.parent}return!1}};gt();var nh=class{constructor(t,e,r){this.uuid=t;this.data=e;this.enabled=!1;this.color=Ve.transparent;this.blurRadius=0;this.offset=[0,0];this.spread=0;this.update(e)}update(t){t.color!==void 0&&(this.color=t.color),t.enabled!==void 0&&(this.enabled=t.enabled),t.blurRadius!==void 0&&(this.blurRadius=t.blurRadius),t.offset!==void 0&&(this.offset=t.offset),t.spread!==void 0&&(this.spread=t.spread)}};var ih=class{constructor(t,e,r){this.uuid=t;this.data=e;this.enabled=!1;this.radius=0;this.update(e)}update(t){t.enabled!==void 0&&(this.enabled=t.enabled),t.radius!==void 0&&(this.radius=t.radius)}};var cg=class{constructor(t,e,r){this.uuid=t;this.data=e;this.enabled=!1;this.color=Ve.transparent;this.update(e)}update(t){t.enabled!==void 0&&(this.enabled=t.enabled),t.color!==void 0&&(this.color=t.color)}};var dg=class{constructor(t,e,r){this.uuid=t;this.data=e;this.enabled=!1;this.color=Ve.transparent;this.thickness=0;this.mode="inside";this.update(e)}update(t){t.enabled!==void 0&&(this.enabled=t.enabled),t.color!==void 0&&(this.color=t.color),t.thickness!==void 0&&(this.thickness=t.thickness),t.mode!==void 0&&(this.mode=t.mode)}};var qt=class extends Fa{constructor(e,r,n){super(e,r,n);this.uuid=e;this.data=r;this.autoClose=!0;this.fill=new cg(e+"-fill",r.fill,n),this.stroke=new dg(e+"-stroke",r.stroke,n),this.dropShadow=new nh(e+"-dropShadow",r.dropShadow,n),this.innerShadow=new nh(e+"-innerShadow",r.innerShadow,n),this.backgroundBlur=new ih(e+"-backgroundBlur",r.backgroundBlur,n),this.layerBlur=new ih(e+"-layerBlur",r.layerBlur,n)}applyFillStroke(e){e.fillColor=this.fill.enabled?this.fill.color:Ve.transparent,e.strokeColor=this.stroke.enabled&&this.stroke.thickness>0?this.stroke.color:Ve.transparent,e.strokeMode=this.stroke.mode,e.lineWidth=this.stroke.thickness}applyFilters(e){this.layerBlur.enabled?e.layerBlur=this.layerBlur.radius*5:e.layerBlur=0,this.backgroundBlur.enabled?e.backgroundBlur=this.backgroundBlur.radius*5:e.backgroundBlur=0,this.dropShadow.enabled?(e.dropShadowBlur=this.dropShadow.blurRadius*5,e.dropShadowColor=this.dropShadow.color,e.dropShadowOffsetX=this.dropShadow.offset[0],e.dropShadowOffsetY=this.dropShadow.offset[1]):e.dropShadowColor=Ve.transparent,this.innerShadow.enabled?(e.innerShadowSpread=this.innerShadow.spread,e.innerShadowBlur=this.innerShadow.blurRadius*5,e.innerShadowColor=this.innerShadow.color,e.innerShadowOffsetX=this.innerShadow.offset[0],e.innerShadowOffsetY=this.innerShadow.offset[1]):e.innerShadowColor=Ve.transparent}innerDraw(e){}draw(e){!this.visible||(e.save(),this.applyTransforms(e),this.applyFilters(e),this.applyFillStroke(e),e.beginPath(),this.innerDraw(e),this.autoClose&&e.closePath(),this.fill.enabled&&e.fill(),this.stroke.enabled&&e.stroke(),e.restore())}updateByPatchedOp(e,r,n){super.updateByPatchedOp(e,r,n),e.type===0&&(Ye(e.path,["fill"])?this.fill.update(e.props):Ye(e.path,["stroke"])?this.stroke.update(e.props):Ye(e.path,["dropShadow"])?this.dropShadow.update(e.props):Ye(e.path,["innerShadow"])?this.innerShadow.update(e.props):Ye(e.path,["layerBlur"])?this.layerBlur.update(e.props):Ye(e.path,["backgroundBlur"])?this.backgroundBlur.update(e.props):this.resetBBoxNeedsUpdate())}updateState(e,r){super.updateState(e,r),e.fill!==void 0&&this.fill.update(e.fill),e.stroke!==void 0&&this.stroke.update(e.stroke),e.dropShadow!==void 0&&this.dropShadow.update(e.dropShadow),e.innerShadow!==void 0&&this.innerShadow.update(e.innerShadow),e.layerBlur!==void 0&&this.layerBlur.update(e.layerBlur),e.backgroundBlur!==void 0&&this.backgroundBlur.update(e.backgroundBlur)}clone(e){let r=new qt(this.uuid,this.data,e);return r.parent=void 0,r}};var Ms=class extends qt{constructor(e,r,n){super(e,r,n);this.uuid=e;this.data=r;this.width=0;this.height=0;this.updateState(r,n)}innerDraw(e){e.ellipse(this.width*.5,this.height*.5,this.width*.5,this.height*.5,0,0,Math.PI*2)}intersectsInLocalSpace(e,r){return QO(e,r,this.width*.5,this.height*.5,this.width*.5,this.height*.5)}getCenter(){return[this.width*.5,this.height*.5]}getHalfSize(){return[this.width*.5,this.height*.5]}updateSizeState(e){let r=!1;e.width!==void 0&&(this.width=typeof e.width=="number"?e.width:this.width,r=!0),e.height!==void 0&&(this.height=typeof e.height=="number"?e.height:this.height,r=!0),r&&this.updateWorldMatrix(!0,!1,!0)}updateState(e,r){super.updateState(e,r),this.updateSizeState(e)}clone(e){let r=new Ms(this.uuid,this.data,e);return r.parent=void 0,r}};var Gi=class extends qt{constructor(e,r,n){super(e,r,n);this.uuid=e;this.data=r;this.width=0;this.height=0;this.cornerRadius=[0,0,0,0];this.updateState(r,n)}innerDraw(e){e.rect(0,0,this.width,this.height,...this.cornerRadius)}getCenter(){return[this.width*.5,this.height*.5]}getHalfSize(){return[this.width*.5,this.height*.5]}updateCornerState(e){e.cornerRadius!==void 0&&(this.cornerRadius=e.cornerRadius)}updateSizeState(e){let r=!1;e.width!==void 0&&(this.width=typeof e.width=="number"?e.width:this.width,r=!0),e.height!==void 0&&(this.height=typeof e.height=="number"?e.height:this.height,r=!0),r&&this.updateWorldMatrix(!0,!1,!0)}updateState(e,r){super.updateState(e,r),this.updateSizeState(e),this.updateCornerState(e)}clone(e){let r=new Gi(this.uuid,this.data,e);return r.parent=void 0,r}};var Os=class extends qt{constructor(e,r,n){super(e,r,n);this.uuid=e;this.data=r;this._textHeight=0;this._textHeightDirty=!0;this.width=0;this.height=0;this.updateState(r,n)}get textHeight(){return this._textHeight}applyFillStroke(e){e.fillColor=this.fill.enabled?this.fill.color:Ve.transparent,e.strokeColor=this.stroke.enabled&&this.stroke.thickness>0?this.stroke.color:Ve.transparent,e.strokeMode="center",e.lineWidth=this.stroke.thickness}innerDraw(e){this._fontHolder?.arrayBuffer&&this._fontHolder.arrayBuffer.byteLength>1&&this.data.font&&e.registerFont(this._fontHolder.arrayBuffer,this.data.font);let r=this.data.textTransform,n=this.data.text.textValue.toString(),o=r===2?n.toUpperCase():r===3?n.toLowerCase():n,{height:a}=e.drawText(o,{x:0,y:0,width:this.width,height:this.height,fontSize:this.data.fontSize,lineHeight:this.data.lineHeight??1,letterSpacing:this.data.letterSpacing??0,horizontalAlign:this.data.horizontalAlign,verticalAlign:this.data.verticalAlign,font:this.data.font});this._textHeight=a}getCenter(){return[this.width*.5,this.height*.5]}getHalfSize(){return[this.width*.5,this.height*.5]}updateSizeState(e){let r=!1;e.width!==void 0&&(this.width=typeof e.width=="number"?e.width:this.width,r=!0),e.height!==void 0&&(this.height=typeof e.height=="number"?e.height:this.height,r=!0),r&&this.updateWorldMatrix(!0,!1,!0)}updateFontState(e,{shared:r}){e.font!==void 0&&(this._fontHolder=r.getFont(e.font),this._fontHolder&&!this._fontHolder.isLoaded&&this._fontHolder.loadingPromise.then(()=>{this.requestRender()}))}updateState(e,r){super.updateState(e,r),this.updateSizeState(e),this.updateFontState(e,r)}clone(e){let r=new Os(this.uuid,this.data,e);return r.parent=void 0,r}};var Ed=class extends qt{constructor(e,r,n){super(e,r,n);this.uuid=e;this.data=r;this.curves=[];this.extremasBBox={min:[0,0],max:[0,0]};this.updateState(r,n)}computeExtremas(){this.curves.length===0&&this.computeCurves();let e=this.curves.map(o=>ug.extremas(o)),r=[1/0,1/0],n=[-1/0,-1/0];for(let o=0,a=e.length;o<a;o++){let s=e[o];s[0][0]<r[0]&&(r[0]=s[0][0]),s[0][1]<r[1]&&(r[1]=s[0][1]),s[1][0]>n[0]&&(n[0]=s[1][0]),s[1][1]>n[1]&&(n[1]=s[1][1])}return this.extremasBBox.min=[r[0],r[1]],this.extremasBBox.max=[n[0],n[1]],this.extremasBBox}computeCurves(){this.curves=[];for(let n=1,o=this.data.points.length;n<o;n++){let a=this.data.points[n].data,s=this.data.points[n-1].data,l={start:s.position,cp1:s.controlNext.position,cp2:a.controlPrevious.position,end:a.position};this.curves.push(l)}let e=this.data.points[0].data,r=this.data.points[this.data.points.length-1].data;if(this.data.isClosed){let n={start:r.position,cp1:r.controlNext.position,cp2:e.controlPrevious.position,end:e.position};this.curves.push(n)}}getCenter(){let[e,r]=this.extremasBBox.min,[n,o]=this.getHalfSize();return[e+n,r+o]}getHalfSize(){let{min:e,max:r}=this.extremasBBox;return[(r[0]-e[0])*.5,(r[1]-e[1])*.5]}innerDraw(e){for(let o=0,a=this.data.points.length;o<a;o++){let s=this.data.points[o].data;if(o===0){let[l,c]=s.position;e.moveTo(l,c)}else{let l=this.data.points[o-1].data,[c,d]=l.controlNext.position,[u,p]=s.controlPrevious.position,[h,f]=s.position,m={start:l.position,cp1:l.controlNext.position,cp2:s.controlPrevious.position,end:s.position};ug.derive(m),e.bezierCurveTo(c,d,u,p,h,f)}}let r=this.data.points[0].data,n=this.data.points[this.data.points.length-1].data;if(this.data.isClosed){let[o,a]=n.controlNext.position,[s,l]=r.controlPrevious.position,[c,d]=r.position;e.bezierCurveTo(o,a,s,l,c,d)}}updateState(e,r){super.updateState(e,r),this.computeExtremas()}clone(e){let r=new Ed(this.uuid,this.data,e);return r.parent=void 0,r}},ug;(o=>{function i(a){let s=a.start,l=a.cp1,c=a.cp2,d=a.end,u=[3*(l[0]-s[0]),3*(l[1]-s[1])],p=[3*(c[0]-l[0]),3*(c[1]-l[1])],h=[3*(d[0]-c[0]),3*(d[1]-c[1])],f={start:u,cp:p,end:h};return a.derivative=f,f.derivative=XS.derive(f),f}o.derive=i;function t(a,s,l,c=!1){let d=a-2*s+l;if(d!==0){let u=-Math.sqrt(Math.abs(s*s-a*l)),p=-a+s,h=-(u+p)/d,f=-(-u+p)/d;return[h,f]}else if(s!==l&&d===0)return[(2*s-l)/(2*(s-l))];return[]}function e(a){let s=a.derivative??o.derive(a),l=s.start,c=s.cp,d=s.end;return[t(l[0],c[0],d[0]),t(l[1],c[1],d[1])]}o.droot=e;function r(a){let[s,l]=o.droot(a),c=[a.start[0],a.end[0]],d=[a.start[1],a.end[1]];for(let u of s)c.push(o.compute(a,Math.min(1,Math.max(0,u)))[0]);for(let u of l)d.push(o.compute(a,Math.min(1,Math.max(0,u)))[1]);return c.sort((u,p)=>u-p),d.sort((u,p)=>u-p),[[c[0],d[0]],[c[c.length-1],d[d.length-1]]]}o.extremas=r;function n(a,s){if(s===0)return[...a.start];if(s===1)return[...a.end];let l=1-s,c=l*l,d=s*s,u=c*l,p=c*s*3,h=l*d*3,f=s*d;return[u*a.start[0]+p*a.cp1[0]+h*a.cp2[0]+f*a.end[0],u*a.start[1]+p*a.cp1[1]+h*a.cp2[1]+f*a.end[1]]}o.compute=n})(ug||(ug={}));var XS;(r=>{function i(n){let o=n.start,a=n.cp,s=n.end,l=[2*(a[0]-o[0]),2*(a[1]-o[1])],c=[2*(s[0]-a[0]),2*(s[1]-a[1])],d={start:l,end:c};return d.derivative=YS.derive(d),n.derivative=d,d}r.derive=i;function t(n){let o=n.derivative??r.derive(n),a=o.start,s=o.end;return[a[0]!==s[0]?a[0]/(a[0]-s[0]):0,a[1]!==s[1]?a[1]/(a[1]-s[1]):0]}r.droot=t;function e(n,o){if(o===0)return[...n.start];if(o===1)return[...n.end];let a=1-o,s=a*a,l=o*o,c=s,d=a*o*2,u=l;return[c*n.start[0]+d*n.cp[0]+u*n.end[0],c*n.start[1]+d*n.cp[1]+u*n.end[1]]}r.compute=e})(XS||(XS={}));var YS;(e=>{function i(r){let n=r.start,o=r.end,a=[o[0]-n[0],o[1]-n[1]];return r.derivative=a,r.derivative}e.derive=i;function t(r,n){if(n===0)return[...r.start];if(n===1)return[...r.end];let o=r.start,a=r.end;return[o[0]+(a[0]-o[0])*n,o[1]+(a[1]-o[1])*n]}e.compute=t})(YS||(YS={}));var kn=class extends Fa{constructor(e,r,n){super(e,r,n);this.uuid=e;this.data=r;this.context=n;this.isBaseGroup=!0;this.children=[]}add(e){e.parent&&e.parent instanceof kn&&e.parent.remove(e),this.children.push(e),e.parent=this}remove(e){let r=this.children.indexOf(e);r>=0&&(this.children.splice(r,1),e.parent=void 0)}traverse(e){let r=e(this);if(r!==!0)for(let n of this.children)n instanceof kn?n.traverse(e):r=e(n)}intersectsChildrenHelper(e,r,n,o,a){for(let s of this.children)if(s.intersects(e,r,n,!1)&&(a.push(s),o)||s instanceof kn&&s.intersectsChildrenHelper(e,r,n,o,a))return!0;return!1}intersectsChildren(e,r,n,o=!1,a=[],s=!1){return this.intersectsChildrenHelper(e,r,n,o,a),a}intersectsChildrenHelperReverse(e,r,n,o,a){for(let s of this.children)if(s instanceof kn&&s.intersectsChildrenHelperReverse(e,r,n,o,a)||s.intersects(e,r,n,!1)&&(a.push(s),o))return!0;return!1}intersectsChildrenReverse(e,r,n,o=!1,a=[],s=!1){return this.intersectsChildrenHelperReverse(e,r,n,o,a),a}updateWorldMatrix(e,r,n){if(super.updateWorldMatrix(e,r,n),n&&this.children)for(let o of this.children)o.updateWorldMatrix(e,!1,!0)}find(e){let r;return this.traverse(n=>{n.uuid===e&&(r=n)}),r}innerDrawChildren(e){for(let r=this.children.length-1;r>=0;r--)this.children[r].draw(e)}resetBBoxNeedsUpdate(){super.resetBBoxNeedsUpdate(),this.traverse(e=>{e.resetBBoxNeedsUpdateSelf()})}clone(e){let r=new kn(this.uuid,this.data,e);r.parent=void 0;for(let n of this.children)r.add(n.clone(e));return r}},Kn=class extends kn{constructor(e,r,n){super(e,r,n);this.uuid=e;this.data=r;this.updateState(r,n)}draw(e){!this.visible||(e.save(),this.applyTransforms(e),this.innerDrawChildren(e),e.restore())}clone(e){let r=new Kn(this.uuid,this.data,e);r.parent=void 0;for(let n of this.children)r.add(n.clone(e));return r}};gt();var un=class extends kn{constructor(e,r,n){super(e,r,n);this.uuid=e;this.width=0;this.height=0;this.clipped=!0;this.background=new Gi(e+"-background",Vc.defaultData,n),this.background.parent=this,this.updateState(r,n)}get fill(){return this.background.fill}get stroke(){return this.background.stroke}get backgroundBlur(){return this.background.backgroundBlur}get layerBlur(){return this.background.layerBlur}get dropShadow(){return this.background.dropShadow}get innerShadow(){return this.background.innerShadow}get cornerRadius(){return this.background.cornerRadius}set cornerRadius(e){this.background.cornerRadius=e}updateLocalMatrix(){super.updateLocalMatrix(),this.background?.updateLocalMatrix()}updateWorldMatrix(e,r,n){super.updateWorldMatrix(e,r,n),this.background?.updateWorldMatrix(e,r,n)}draw(e){if(!this.visible)return;e.save();let r=this.width,n=this.height;this.applyTransforms(e),this.background.width=r,this.background.height=n,this.background.draw(e),this.clipped&&e.clipRect(0,0,r,n,...this.cornerRadius),this.innerDrawChildren(e),e.restore()}getCenter(){return[this.width*.5,this.height*.5]}getHalfSize(){return[this.width*.5,this.height*.5]}updateCornerState(e){e.cornerRadius!==void 0&&(this.cornerRadius=e.cornerRadius)}updateSizeState(e){let r=!1;e.width!==void 0&&(this.width=typeof e.width=="number"?e.width:this.width,r=!0),e.height!==void 0&&(this.height=typeof e.height=="number"?e.height:this.height,r=!0),r&&this.updateWorldMatrix(!0,!1,!0)}updateState(e,r){super.updateState(e,r),this.updateSizeState(e),this.updateCornerState(e),e.fill!==void 0&&this.fill.update(e.fill),e.stroke!==void 0&&this.stroke.update(e.stroke),e.dropShadow!==void 0&&this.dropShadow.update(e.dropShadow),e.innerShadow!==void 0&&this.innerShadow.update(e.innerShadow),e.layerBlur!==void 0&&this.layerBlur.update(e.layerBlur),e.backgroundBlur!==void 0&&this.backgroundBlur.update(e.backgroundBlur),e.clipped!==void 0&&(this.clipped=e.clipped)}requestRender(){super.requestRender(),this.dispatchEvent({type:"render"})}dispose(){this.removeEventListener("render")}updateByPatchedOp(e,r,n){super.updateByPatchedOp(e,r,n),e.type===0&&(Ye(e.path,["fill"])?this.fill.update(e.props):Ye(e.path,["stroke"])?this.stroke.update(e.props):Ye(e.path,["dropShadow"])?this.dropShadow.update(e.props):Ye(e.path,["innerShadow"])?this.innerShadow.update(e.props):Ye(e.path,["layerBlur"])?this.layerBlur.update(e.props):Ye(e.path,["backgroundBlur"])?this.backgroundBlur.update(e.props):this.resetBBoxNeedsUpdate())}clone(e){let r=new un(this.uuid,this.data,e);r.parent=void 0;for(let n of this.children)r.add(n.clone(e));return r}};var ZO=gc(ig(),1),pg=new Map,JV=4096,Td=null;function $V(i){let t=pg.get(i);if(t!==void 0)return t;if(Td===null||!Td.isConnected){let r=document.createElementNS("http://www.w3.org/2000/svg","svg");r.setAttribute("aria-hidden","true"),r.style.cssText="position:absolute;width:0;height:0;overflow:hidden;visibility:hidden;pointer-events:none",Td=document.createElementNS("http://www.w3.org/2000/svg","path"),r.appendChild(Td),document.body.appendChild(r)}Td.setAttribute("d",i);let e=Td.getBBox();return pg.size>=JV&&pg.clear(),pg.set(i,e),e}var ka=class extends qt{constructor(e,r,n){super(e,r,n);this.uuid=e;this.data=r;this._pathBBox=new DOMRect;this.path="";this.updateState(r,n),this.autoClose=!1,this.computeSVGBBox()}computeSVGBBox(){let e=this.path;JO(this.path)&&(console.warn("Invalid SVG path",this.uuid),e=""),this._pathBBox=$V(e)}innerDraw(e){e.path(this.path)}intersectsInLocalSpace(e,r){return e>=this._pathBBox.x&&e<=this._pathBBox.x+this._pathBBox.width&&r>=this._pathBBox.y&&r<=this._pathBBox.y+this._pathBBox.height}getCenter(){return[(this._pathBBox.x+this._pathBBox.width)/2,(this._pathBBox.y+this._pathBBox.height)/2]}getHalfSize(){return[(this._pathBBox.x+this._pathBBox.width)/2,(this._pathBBox.y+this._pathBBox.height)/2]}updateState(e,r){super.updateState(e,r),e.path!==void 0&&(this.path=e.path,this.computeSVGBBox())}clone(e){let r=new ka(this.uuid,this.data,e);return r.parent=void 0,r}};function JO(i){return/NaN/.test(i)}function $O(i,t=1,e=1){if(t<=0||e<=0)return i;if(JO(i))return console.warn("Cannot scale invalid path",i),hg([]);if(t===1&&e===1)return i;try{let n=(0,ZO.parseSVG)(i).map(o=>{let a={...o};return"x"in a&&(a.x=a.x*t),"y"in a&&(a.y=a.y*e),"x1"in a&&(a.x1=a.x1*t),"x2"in a&&(a.x2=a.x2*t),"y1"in a&&(a.y1=a.y1*e),"y2"in a&&(a.y2=a.y2*e),"rx"in a&&(a.rx=a.rx*t),"ry"in a&&(a.ry=a.ry*e),a});return hg(n)}catch(r){return console.warn("Error parsing SVG path",r),hg([])}}function hg(i){let t=["rx","ry","xAxisRotation","largeArc","sweep","x1","y1","x2","y2","x","y"],e;return i.map(r=>{let n=[];t.forEach(a=>{if(a in r){let s=r[a]*1;n.length&&s>=0&&n.push(","),n.push(s)}});let o=(e===r.code?n[0]<0?"":",":r.code)+n.join("");return e=r.code,o}).join("")}function eI(i,t,e){switch(t.type){case"ellipse2d":return new Ms(i,t,e);case"rectangle2d":return new Gi(i,t,e);case"text2d":return new Os(i,t,e);case"vector2d":return new Ed(i,t,e);case"path2d":return new ka(i,t,e);case"frame2d":return new un(i,t,e);case"group2d":default:return new Kn(i,t,e)}}mr();var QS=class{constructor(t,e,r){this.uuid=t;this.data=e;this.group=new Kn(QS.GROUP_ID,{...bp.defaultData},r),this.createChildrenObjects(e.objects,this.group,r)}createObject(t,e,r,n,o,a){let s=eI(t,e,a);s&&(n.add(s),n.children.splice(o,0,n.children.pop()),s.updateWorldMatrix(),r.length>0&&(s instanceof Kn||s instanceof un)&&this.createChildrenObjects(r,s,a))}createChildrenObjects(t,e,r){let n=0;for(let o of t)this.createObject(o.id,o.data,o.children,e,n,r),n+=1}draw(t){this.group.draw(t)}updateEntityByOp(t,e,r,n){let o=this.find(t);if(o)try{o.updateByOp(e,r,{shared:n})}catch(a){console.error(a)}}updateTreeByOp(t,e){if(t.path.length===0&&t.type===7){let r=t.parent===null?this.group:this.find(t.parent);r!==void 0&&r instanceof kn&&(this.createObject(t.id,t.data,t.children,r,t.localIndex,e),r.requestRender())}else if(t.path.length===0&&t.type===8){let r=this.find(t.id);if(r!==void 0&&r.parent!==void 0&&r.parent instanceof kn){let n=r.parent;r.resetBBoxNeedsUpdate(),n?.remove(r),n?.requestRender()}}else if(t.path.length===0&&t.type===9){let r=this.find(t.id);if(r!==void 0){let n=r.parent,o=t.parent===null?this:this.find(t.parent);if(o===void 0&&!1&&console.error("unexpected",o,t),o instanceof kn||o===this){o.add(r);let a=t.localIndex;o.children.splice(a,0,o.children.pop()),r.updateWorldMatrix(!0,!1,!0),n?.requestRender(),r.requestRender()}r.resetBBoxNeedsUpdate()}}}add(t){this.group.add(t)}remove(t){this.group.remove(t)}traverse(t){this.group.traverse(e=>{e!==this.group&&t(e)})}intersectsChildren(t,e,r,n=!1,o=[]){return this.group.intersectsChildren(t,e,r,n,o,!0)}intersectsChildrenReverse(t,e,r,n=!1,o=[]){return this.group.intersectsChildrenReverse(t,e,r,n,o,!0)}find(t){return this.group.find(t)}get children(){return this.group.children}project(t,e){return this.group.project(t,e)}getWithSortKey(t){let e=this.find(t);if(e===void 0)return;let r=[],n=e;for(;n!==this.group;){let o=n;n=n.parent;let a=n.children.indexOf(o);r.splice(0,0,a)}return{entity:e,sortKey:r}}getAllSorted(t){let e=[];for(let r of t){let n=this.getWithSortKey(r.id);n!==void 0&&e.push(n)}return e.sort((r,n)=>nl(r.sortKey,n.sortKey)),e.map(r=>r.entity)}},Vl=QS;Vl.GROUP_ID="scene2d";function KS({constraints:i,newParentWidth:t,newParentHeight:e,initialParentWidth:r,initialParentHeight:n,objectInitialWidth:o,objectInitialHeight:a,objectInitialPosition:s}){let{horizontalConstraint:l,verticalConstraint:c}=i,d=t-r,u=e-n,p=o,h=a,f=s[0],m=s[1];if(l!==0){if(l===1)f+=d;else if(l===3)f+=d/2;else if(l===2)p=Math.max(1,p+d);else if(l===4){let y=t/r;p*=y,f*=y}}if(c!==0){if(c===1)m+=u;else if(c===3)m+=u/2;else if(c===2)h=Math.max(1,h+u);else if(c===4){let y=e/n;h*=y,m*=y}}return{width:p,height:h,position:[f,m]}}var eG=gc(ig(),1);var Uoe={mm:{mm:1,cm:.1,in:1/25.4,pt:72/25.4,pc:6/25.4,px:-1},cm:{mm:10,cm:1,in:1/2.54,pt:72/2.54,pc:6/2.54,px:-1},in:{mm:25.4,cm:2.54,in:1,pt:72,pc:6,px:-1},pt:{mm:25.4/72,cm:2.54/72,in:1/72,pt:1,pc:6/72,px:-1},pc:{mm:25.4/6,cm:2.54/6,in:1/6,pt:72/6,pc:1,px:-1},px:{mm:1,px:1,cm:1,in:1,pt:1,pc:1}};gt();var Nr=require("three");var tG=new Set;function tI(i){tG.add(i)}function ZS(i,t,e,r){return r?e:2048/Math.max(1,i,t)}function rI(i,t,e,r){let n=ZS(i,t,e,r),o=Math.max(e,512/Math.min(i,t)),a=Math.min(o,n);return{width:Math.max(1,Math.ceil(i*a)),height:Math.max(1,Math.ceil(t*a))}}var rG=`
|
|
1313
1313
|
varying vec2 vUv;
|
|
1314
1314
|
void main() {
|
|
@@ -1324,7 +1324,7 @@ void main() {
|
|
|
1324
1324
|
`,e),u=e.horizontalAlign===1?d:0,p=this.getLineInitialOffsetX(s[0],l,e.horizontalAlign,t[0],d),h=this.getLineInitialOffsetY(a,t.length,c,o,e.verticalAlign),f=[],m=t.map(()=>[]),y=t.map(()=>[]);for(let v=0;v<t.length;v++){let b=t[v],S={features:{liga:!0},letterSpacing:e.letterSpacing},x=[];try{x=n.stringToGlyphs(b,S)}catch(M){this.warnLayoutError(M)}p=this.getLineInitialOffsetX(s[v],l,e.horizontalAlign,b,d);let w=[];try{w=this.reverseLigaturesTable(n,b,x)}catch(M){this.warnLayoutError(M)}let A=this.computeSpaceWidthForLine(t,v,e,r),C=0,P=x[0];P&&e.horizontalAlign===2&&P.leftSideBearing!==void 0&&(p-=P.leftSideBearing*o);try{this.font?.forEachGlyph(b,p,h,e.fontSize,S,(M,B,I,_,E)=>{let R=M.index===0?`
|
|
1325
1325
|
`:M.unicode?String.fromCharCode(M.unicode):void 0,L=w[C],F=0;if(R===`
|
|
1326
1326
|
`)F=u;else if(R===" ")F=A;else{let k=this.createPath(M,o,B,I,e);k&&(F=k.offsetX,f.push(k.path))}if(!L||L.replacements.length===1)y[v].push([B,I]),m[v].push(F);else{let k=L.replacements.map(q=>(n.glyphs.get(q).advanceWidth??0)*o),W=k.reduce((q,X)=>q+=X,0),U=k.map(q=>q/W),G=B;for(let q=0;q<U.length;q++){let X=F*U[q];y[v].push([G,I]),m[v].push(X),G+=X}}C++})}catch(M){this.warnLayoutError(M)}h-=a}let g=[];for(let v=0,b=f.length;v<b;v++)g.push(...f[v].toShapes());return{shapes:g,charWidths:m,lineWidths:s,charCoords:y}}get isUserFont(){return this._isUserFont}get arrayBuffer(){return this._arrayBuffer}get ascender(){return this.font?.ascender??0}get descender(){return this.font?.descender??0}get familyName(){return this.font?.names.fontFamily??""}get subfamilyName(){return this.font?.names.fontSubfamily??""}get unitsPerEm(){return this.font?.unitsPerEm??1}getLineInitialOffsetX(t,e,r,n,o){return(r===3||r===2)&&n.indexOf(`
|
|
1327
|
-
`)>=0&&(t-=o),r===3?e*.5-t*.5:r===2?e-t:0}getLineInitialOffsetY(t,e,r,n,o){let a=e*t,s=Math.abs(this.ascender-this.descender)*n,l=t-s,c=-this.ascender*n-l/2;return o===3?-(r-a-c):o===2?-(r*.5-a*.5-c):c}createPath(t,e,r,n,o){let a=t.getPath(r,-n,o.fontSize,{kerning:!1,letterSpacing:o.letterSpacing});if(!a){console.error('THREE.Font: character "'+t+'" does not exists in font family '+this.familyName+".");return}let s=new mg,l=(t.advanceWidth??1)*e;if(t)for(let c of a.commands){let d=s.currentPath?.currentPoint;if(!(d&&c.type!=="Z"&&d.x===c.x&&-d.y===c.y))switch(c.type){case"M":s.moveTo(c.x,-c.y);break;case"L":s.lineTo(c.x,-c.y);break;case"Q":s.quadraticCurveTo(c.x1,-c.y1,c.x,-c.y);break;case"C":s.bezierCurveTo(c.x1,-c.y1,c.x2,-c.y2,c.x,-c.y);break}}return s.subPaths.forEach(c=>{let d=yG(c.curves);d!==void 0&&c.currentPoint.distanceTo(d)>0&&c.lineTo(d.x,d.y)}),{offsetX:l,path:s}}getCharWidth(t,e){try{return this.font?.getAdvanceWidth(t,e.fontSize,{kerning:!0,letterSpacing:e.letterSpacing})??0}catch(r){return this.warnLayoutError(r),0}}getTextWidth(t,e){try{return this.font?.getAdvanceWidth(t,e.fontSize,{kerning:!0,letterSpacing:e.letterSpacing})??0}catch(r){return this.warnLayoutError(r),0}}computeSpaceWidthForLine(t,e,r,n){let o=this.getCharWidth(" ",r),a=t[e];if(a){let s=this.countSpaces(a.trimEnd());if(r.horizontalAlign===4&&e<t.length-1&&s){let l=typeof r.width=="string"?Number(n.getVariable(r.width)):r.width,c=this.getTextWidth(a,r);return(l-(c-s*o))/s}}return o}countSpaces(t){return(t.match(/ /g)||[]).length}};function yG(i){if(i.length){let t=i[0];if(t instanceof Md.LineCurve)return t.v1;if(t instanceof Md.CubicBezierCurve||t instanceof Md.QuadraticBezierCurve)return t.v0}}Oi("TextGeometry",(i,t,e)=>new Es(i,t,e));var cI={create:(i,t)=>new hd(i,t)};Ep("TextGeometry",cI);Ep("InputGeometry",cI);qP(gg);Pe("text");var dI=200,gG=null;function uI(i){gG=i}var ah=(i,t)=>{let e=t.x-i.x,r=t.y-i.y;return Math.sqrt(e*e+r*r)},pI=(i,t)=>{let e=t.x-i.x,r=t.y-i.y;return vG(Math.atan2(r,e))},hI=(i,t,e)=>{let r={x:0,y:0};return e=bg(e),r.x=i.x-t*Math.cos(e),r.y=i.y-t*Math.sin(e),r},bg=i=>i*(Math.PI/180),vG=i=>i*(180/Math.PI),fI=i=>isNaN(i.buttons)?i.pressure!==0:i.buttons!==0,vg=new Map,mI=i=>{vg.has(i)&&clearTimeout(vg.get(i)),vg.set(i,setTimeout(function(){vg.delete(i),i()},100))},Od=(i,t,e)=>{let r=t.split(/[ ,]+/g),n;for(let o=0;o<r.length;o+=1)n=r[o],i.addEventListener?i.addEventListener(n,e,!1):i.attachEvent&&i.attachEvent(n,e)},Id=(i,t,e)=>{let r=t.split(/[ ,]+/g),n;for(let o=0;o<r.length;o+=1)n=r[o],i.removeEventListener?i.removeEventListener(n,e):i.detachEvent&&i.detachEvent(n,e)};var xg=i=>(i.preventDefault(),i.type.match(/^touch/)?i.changedTouches:i),o1=()=>{if(typeof window>"u")return;let i=window.pageXOffset!==void 0?window.pageXOffset:(document.documentElement||document.body.parentNode||document.body).scrollLeft,t=window.pageYOffset!==void 0?window.pageYOffset:(document.documentElement||document.body.parentNode||document.body).scrollTop;return{x:i,y:t}},Sg=(i,t)=>{t.top||t.right||t.bottom||t.left?(i.style.top=t.top,i.style.right=t.right,i.style.bottom=t.bottom,i.style.left=t.left):(i.style.left=t.x+"px",i.style.top=t.y+"px")},wg=(i,t,e)=>{let r=gI(i);for(let n in r)if(Object.prototype.hasOwnProperty.call(r,n))if(typeof t=="string")r[n]=t+" "+e;else{let o="";for(let a=0,s=t.length;a<s;a+=1)o+=t[a]+" "+e+", ";r[n]=o.slice(0,-2)}return r},yI=(i,t)=>{let e=gI(i);for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&(e[r]=t);return e},gI=i=>{let t={};return t[i]="",["webkit","Moz","o"].forEach(function(r){t[r+i.charAt(0).toUpperCase()+i.slice(1)]=""}),t},Ag=(i,t)=>{for(let e in t)Object.prototype.hasOwnProperty.call(t,e)&&(i[e]=t[e]);return i},vI=(i,t)=>{let e={};for(let r in i)Object.prototype.hasOwnProperty.call(i,r)&&Object.prototype.hasOwnProperty.call(t,r)?e[r]=t[r]:Object.prototype.hasOwnProperty.call(i,r)&&(e[r]=i[r]);return e},sh=(i,t)=>{if(i.length)for(let e=0,r=i.length;e<r;e+=1)t(i[e]);else t(i)},bI=(i,t,e)=>({x:Math.min(Math.max(i.x,t.x-e),t.x+e),y:Math.min(Math.max(i.y,t.y-e),t.y+e)});typeof window<"u"&&(xI="ontouchstart"in window,SI=!!window.PointerEvent,wI=!!window.MSPointerEvent);var xI,SI,wI,lh={touch:{start:"touchstart",move:"touchmove",end:"touchend, touchcancel"},mouse:{start:"mousedown",move:"mousemove",end:"mouseup"},pointer:{start:"pointerdown",move:"pointermove",end:"pointerup, pointercancel"},MSPointer:{start:"MSPointerDown",move:"MSPointerMove",end:"MSPointerUp"}},Dd,ch={};SI?Dd=lh.pointer:wI?Dd=lh.MSPointer:xI?(Dd=lh.touch,ch=lh.mouse):Dd=lh.mouse;function Gl(){}Gl.prototype.on=function(i,t){var e=this,r=i.split(/[ ,]+/g),n;e._handlers_=e._handlers_||{};for(var o=0;o<r.length;o+=1)n=r[o],e._handlers_[n]=e._handlers_[n]||[],e._handlers_[n].push(t);return e};Gl.prototype.off=function(i,t){var e=this;return e._handlers_=e._handlers_||{},i===void 0?e._handlers_={}:t===void 0?e._handlers_[i]=null:e._handlers_[i]&&e._handlers_[i].indexOf(t)>=0&&e._handlers_[i].splice(e._handlers_[i].indexOf(t),1),e};Gl.prototype.trigger=function(i,t){var e=this,r=i.split(/[ ,]+/g),n;e._handlers_=e._handlers_||{};for(var o=0;o<r.length;o+=1)n=r[o],e._handlers_[n]&&e._handlers_[n].length&&e._handlers_[n].forEach(function(a){a.call(e,{type:n,target:e},t)})};Gl.prototype.config=function(i){var t=this;t.options=t.defaults||{},i&&(t.options=vI(t.options,i))};Gl.prototype.bindEvt=function(i,t){var e=this;return e._domHandlers_=e._domHandlers_||{},e._domHandlers_[t]=function(){typeof e["on"+t]=="function"?e["on"+t].apply(e,arguments):console.warn('[WARNING] : Missing "on'+t+'" handler.')},Od(i,Dd[t],e._domHandlers_[t]),ch[t]&&Od(i,ch[t],e._domHandlers_[t]),e};Gl.prototype.unbindEvt=function(i,t){var e=this;return e._domHandlers_=e._domHandlers_||{},Id(i,Dd[t],e._domHandlers_[t]),ch[t]&&Id(i,ch[t],e._domHandlers_[t]),delete e._domHandlers_[t],this};var Rd=Gl;function qr(i,t){return this.identifier=t.identifier,this.position=t.position,this.frontPosition=t.frontPosition,this.collection=i,this.defaults={size:100,threshold:.1,color:"white",fadeTime:250,dataOnly:!1,restJoystick:!0,restOpacity:1,mode:"dynamic",zone:document.body,lockX:!1,lockY:!1,shape:"circle"},this.config(t),this.options.mode==="dynamic"&&(this.options.restOpacity=0),this.id=qr.id,qr.id+=1,this.buildEl().stylize(),this.instance={el:this.ui.el,on:this.on.bind(this),off:this.off.bind(this),show:this.show.bind(this),hide:this.hide.bind(this),add:this.addToDom.bind(this),remove:this.removeFromDom.bind(this),destroy:this.destroy.bind(this),setPosition:this.setPosition.bind(this),resetDirection:this.resetDirection.bind(this),computeDirection:this.computeDirection.bind(this),trigger:this.trigger.bind(this),position:this.position,frontPosition:this.frontPosition,ui:this.ui,identifier:this.identifier,id:this.id,options:this.options},this.instance}qr.prototype=new Rd;qr.constructor=qr;qr.id=0;qr.prototype.buildEl=function(i){return this.ui={},this.options.dataOnly?this:(this.ui.el=document.createElement("div"),this.ui.back=document.createElement("div"),this.ui.front=document.createElement("div"),this.ui.el.className="nipple collection_"+this.collection.id,this.ui.back.className="back",this.ui.front.className="front",this.ui.el.setAttribute("id","nipple_"+this.collection.id+"_"+this.id),this.ui.el.appendChild(this.ui.back),this.ui.el.appendChild(this.ui.front),this)};qr.prototype.stylize=function(){if(this.options.dataOnly)return this;var i=this.options.fadeTime+"ms",t=yI("borderRadius","50%"),e=wg("transition","opacity",i),r={};return r.el={position:"absolute",opacity:this.options.restOpacity,display:"block",zIndex:999},r.back={position:"absolute",display:"block",width:this.options.size+"px",height:this.options.size+"px",marginLeft:-this.options.size/2+"px",marginTop:-this.options.size/2+"px",background:"rgba(255, 255, 255, .4)",border:"solid 2px rgba(0, 0, 0, .1)"},r.front={width:this.options.size/2+"px",height:this.options.size/2+"px",position:"absolute",display:"block",marginLeft:-this.options.size/4+"px",marginTop:-this.options.size/4+"px",background:"rgba(255, 255, 255, .8)",border:"solid 2px rgba(0, 0, 0, .1)"},Ag(r.el,e),this.options.shape==="circle"&&Ag(r.back,t),Ag(r.front,t),this.applyStyles(r),this};qr.prototype.applyStyles=function(i){for(var t in this.ui)if(Object.prototype.hasOwnProperty.call(this.ui,t))for(var e in i[t])this.ui[t].style[e]=i[t][e];return this};qr.prototype.addToDom=function(){return this.options.dataOnly||document.body.contains(this.ui.el)?this:(this.options.zone.appendChild(this.ui.el),this)};qr.prototype.removeFromDom=function(){return this.options.dataOnly||!document.body.contains(this.ui.el)?this:(this.options.zone.removeChild(this.ui.el),this)};qr.prototype.destroy=function(){clearTimeout(this.removeTimeout),clearTimeout(this.showTimeout),clearTimeout(this.restTimeout),this.trigger("destroyed",this.instance),this.removeFromDom(),this.off(),this.ui=null,this.instance=null,this.collection=null,this.options=null};qr.prototype.show=function(i){var t=this;return t.options.dataOnly||(clearTimeout(t.removeTimeout),clearTimeout(t.showTimeout),clearTimeout(t.restTimeout),t.addToDom(),t.restCallback(),setTimeout(function(){t.ui.el.style.opacity=1},0),t.showTimeout=setTimeout(function(){t.trigger("shown",t.instance),typeof i=="function"&&i.call(this)},t.options.fadeTime)),t};qr.prototype.hide=function(i){var t=this;if(t.options.dataOnly)return t;if(t.ui.el.style.opacity=t.options.restOpacity,clearTimeout(t.removeTimeout),clearTimeout(t.showTimeout),clearTimeout(t.restTimeout),t.removeTimeout=setTimeout(function(){var e=t.options.mode==="dynamic"?"none":"block";t.ui.el.style.display=e,typeof i=="function"&&i.call(t),t.trigger("hidden",t.instance)},t.options.fadeTime),t.options.restJoystick){let e=t.options.restJoystick,r={};r.x=e===!0||e.x!==!1?0:t.instance.frontPosition.x,r.y=e===!0||e.y!==!1?0:t.instance.frontPosition.y,t.setPosition(i,r)}return t};qr.prototype.setPosition=function(i,t){var e=this;e.frontPosition={x:t.x,y:t.y};var r=e.options.fadeTime+"ms",n={};n.front=wg("transition",["top","left"],r);var o={front:{}};o.front={left:e.frontPosition.x+"px",top:e.frontPosition.y+"px"},e.applyStyles(n),e.applyStyles(o),e.restTimeout=setTimeout(function(){typeof i=="function"&&i.call(e),e.restCallback()},e.options.fadeTime)};qr.prototype.restCallback=function(){var i=this,t={};t.front=wg("transition","none",""),i.applyStyles(t),i.trigger("rested",i.instance)};qr.prototype.resetDirection=function(){this.direction={x:!1,y:!1,angle:!1}};qr.prototype.computeDirection=function(i){var t=i.angle.radian,e=Math.PI/4,r=Math.PI/2,n,o,a;if(t>e&&t<e*3&&!i.lockX?n="up":t>-e&&t<=e&&!i.lockY?n="left":t>-e*3&&t<=-e&&!i.lockX?n="down":i.lockY||(n="right"),i.lockY||(t>-r&&t<r?o="left":o="right"),i.lockX||(t>0?a="up":a="down"),i.force>this.options.threshold){var s={},l;for(l in this.direction)Object.prototype.hasOwnProperty.call(this.direction,l)&&(s[l]=this.direction[l]);var c={};this.direction={x:o,y:a,angle:n},i.direction=this.direction;for(l in s)s[l]===this.direction[l]&&(c[l]=!0);if(c.x&&c.y&&c.angle)return i;(!c.x||!c.y)&&this.trigger("plain",i),c.x||this.trigger("plain:"+o,i),c.y||this.trigger("plain:"+a,i),c.angle||this.trigger("dir dir:"+n,i)}else this.resetDirection();return i};var AI=qr;function Lr(i,t){var e=this;e.nipples=[],e.idles=[],e.actives=[],e.ids=[],e.pressureIntervals={},e.manager=i,e.id=Lr.id,Lr.id+=1,e.defaults={zone:document.body,multitouch:!1,maxNumberOfNipples:10,mode:"dynamic",position:{top:0,left:0},catchDistance:200,size:100,threshold:.1,color:"white",fadeTime:250,dataOnly:!1,restJoystick:!0,restOpacity:1,lockX:!1,lockY:!1,shape:"circle",dynamicPage:!1,follow:!1},e.config(t),(e.options.mode==="static"||e.options.mode==="semi")&&(e.options.multitouch=!1),e.options.multitouch||(e.options.maxNumberOfNipples=1);let r=getComputedStyle(e.options.zone.parentElement);return r&&r.display==="flex"&&(e.parentIsFlex=!0),e.updateBox(),e.prepareNipples(),e.bindings(),e.begin(),e.nipples}Lr.prototype=new Rd;Lr.constructor=Lr;Lr.id=0;Lr.prototype.prepareNipples=function(){var i=this,t=i.nipples;t.on=i.on.bind(i),t.off=i.off.bind(i),t.options=i.options,t.destroy=i.destroy.bind(i),t.ids=i.ids,t.id=i.id,t.processOnMove=i.processOnMove.bind(i),t.processOnEnd=i.processOnEnd.bind(i),t.get=function(e){if(e===void 0)return t[0];for(var r=0,n=t.length;r<n;r+=1)if(t[r].identifier===e)return t[r];return!1}};Lr.prototype.bindings=function(){var i=this;i.bindEvt(i.options.zone,"start"),i.options.zone.style.touchAction="none",i.options.zone.style.msTouchAction="none"};Lr.prototype.begin=function(){var i=this,t=i.options;if(t.mode==="static"){var e=i.createNipple(t.position,i.manager.getIdentifier());e.add(),i.idles.push(e)}};Lr.prototype.createNipple=function(i,t){var e=this,r=e.manager.scroll,n={},o=e.options,a={x:e.parentIsFlex?r.x:r.x+e.box.left,y:e.parentIsFlex?r.y:r.y+e.box.top};if(i.x&&i.y)n={x:i.x-a.x,y:i.y-a.y};else if(i.top||i.right||i.bottom||i.left){var s=document.createElement("DIV");s.style.display="hidden",s.style.top=i.top,s.style.right=i.right,s.style.bottom=i.bottom,s.style.left=i.left,s.style.position="absolute",o.zone.appendChild(s);var l=s.getBoundingClientRect();o.zone.removeChild(s),n=i,i={x:l.left+r.x,y:l.top+r.y}}var c=new AI(e,{color:o.color,size:o.size,threshold:o.threshold,fadeTime:o.fadeTime,dataOnly:o.dataOnly,restJoystick:o.restJoystick,restOpacity:o.restOpacity,mode:o.mode,identifier:t,position:i,zone:o.zone,frontPosition:{x:0,y:0},shape:o.shape});return o.dataOnly||(Sg(c.ui.el,n),Sg(c.ui.front,c.frontPosition)),e.nipples.push(c),e.trigger("added "+c.identifier+":added",c),e.manager.trigger("added "+c.identifier+":added",c),e.bindNipple(c),c};Lr.prototype.updateBox=function(){var i=this;i.box=i.options.zone.getBoundingClientRect()};Lr.prototype.bindNipple=function(i){var t=this,e,r=function(n,o){e=n.type+" "+o.id+":"+n.type,t.trigger(e,o)};i.on("destroyed",t.onDestroyed.bind(t)),i.on("shown hidden rested dir plain",r),i.on("dir:up dir:right dir:down dir:left",r),i.on("plain:up plain:right plain:down plain:left",r)};Lr.prototype.pressureFn=function(i,t,e){var r=this,n=0;clearInterval(r.pressureIntervals[e]),r.pressureIntervals[e]=setInterval(function(){var o=i.force||i.pressure||i.webkitForce||0;o!==n&&(t.trigger("pressure",o),r.trigger("pressure "+t.identifier+":pressure",o),n=o)}.bind(r),100)};Lr.prototype.onstart=function(i){var t=this,e=t.options,r=i;i=xg(i),t.updateBox();var n=function(o){t.actives.length<e.maxNumberOfNipples?t.processOnStart(o):r.type.match(/^touch/)&&(Object.keys(t.manager.ids).forEach(function(a){if(Object.values(r.touches).findIndex(function(l){return l.identifier===a})<0){var s=[i[0]];s.identifier=a,t.processOnEnd(s)}}),t.actives.length<e.maxNumberOfNipples&&t.processOnStart(o))};return sh(i,n),t.manager.bindDocument(),!1};Lr.prototype.processOnStart=function(i){var t=this,e=t.options,r,n=t.manager.getIdentifier(i),o=i.force||i.pressure||i.webkitForce||0,a={x:i.pageX,y:i.pageY},s=t.getOrCreate(n,a);s.identifier!==n&&t.manager.removeIdentifier(s.identifier),s.identifier=n;var l=function(d){d.trigger("start",d),t.trigger("start "+d.id+":start",d),d.show(),o>0&&t.pressureFn(i,d,d.identifier),t.processOnMove(i)};if((r=t.idles.indexOf(s))>=0&&t.idles.splice(r,1),t.actives.push(s),t.ids.push(s.identifier),e.mode!=="semi")l(s);else{var c=ah(a,s.position);if(c<=e.catchDistance)l(s);else{s.destroy(),t.processOnStart(i);return}}return s};Lr.prototype.getOrCreate=function(i,t){var e=this,r=e.options,n;return/(semi|static)/.test(r.mode)?(n=e.idles[0],n?(e.idles.splice(0,1),n):r.mode==="semi"?e.createNipple(t,i):(console.warn("Coudln't find the needed nipple."),!1)):(n=e.createNipple(t,i),n)};Lr.prototype.processOnMove=function(i){var t=this,e=t.options,r=t.manager.getIdentifier(i),n=t.nipples.get(r),o=t.manager.scroll;if(!fI(i)){this.processOnEnd(i);return}if(!n){console.error("Found zombie joystick with ID "+r),t.manager.removeIdentifier(r);return}if(e.dynamicPage){var a=n.el.getBoundingClientRect();n.position={x:o.x+a.left,y:o.y+a.top}}n.identifier=r;var s=n.options.size/2,l={x:i.pageX,y:i.pageY};e.lockX&&(l.y=n.position.y),e.lockY&&(l.x=n.position.x);var c=ah(l,n.position),d=pI(l,n.position),u=bg(d),p=c/s,h={distance:c,position:l},f,m;if(n.options.shape==="circle"?(f=Math.min(c,s),m=hI(n.position,f,d)):(m=bI(l,n.position,s),f=ah(m,n.position)),e.follow){if(c>s){let b=l.x-m.x,S=l.y-m.y;n.position.x+=b,n.position.y+=S,n.el.style.top=n.position.y-(t.box.top+o.y)+"px",n.el.style.left=n.position.x-(t.box.left+o.x)+"px",c=ah(l,n.position)}}else l=m,c=f;var y=l.x-n.position.x,g=l.y-n.position.y;n.frontPosition={x:y,y:g},e.dataOnly||Sg(n.ui.front,n.frontPosition);var v={identifier:n.identifier,position:l,force:p,pressure:i.force||i.pressure||i.webkitForce||0,distance:c,angle:{radian:u,degree:d},vector:{x:y/s,y:-g/s},raw:h,instance:n,lockX:e.lockX,lockY:e.lockY};v=n.computeDirection(v),v.angle={radian:bg(180-d),degree:180-d},n.trigger("move",v),t.trigger("move "+n.id+":move",v)};Lr.prototype.processOnEnd=function(i){var t=this,e=t.options,r=t.manager.getIdentifier(i),n=t.nipples.get(r),o=t.manager.removeIdentifier(n.identifier);!n||(e.dataOnly||n.hide(function(){e.mode==="dynamic"&&(n.trigger("removed",n),t.trigger("removed "+n.id+":removed",n),t.manager.trigger("removed "+n.id+":removed",n),n.destroy())}),clearInterval(t.pressureIntervals[n.identifier]),n.resetDirection(),n.trigger("end",n),t.trigger("end "+n.id+":end",n),t.ids.indexOf(n.identifier)>=0&&t.ids.splice(t.ids.indexOf(n.identifier),1),t.actives.indexOf(n)>=0&&t.actives.splice(t.actives.indexOf(n),1),/(semi|static)/.test(e.mode)?t.idles.push(n):t.nipples.indexOf(n)>=0&&t.nipples.splice(t.nipples.indexOf(n),1),t.manager.unbindDocument(),/(semi|static)/.test(e.mode)&&(t.manager.ids[o.id]=o.identifier))};Lr.prototype.onDestroyed=function(i,t){var e=this;e.nipples.indexOf(t)>=0&&e.nipples.splice(e.nipples.indexOf(t),1),e.actives.indexOf(t)>=0&&e.actives.splice(e.actives.indexOf(t),1),e.idles.indexOf(t)>=0&&e.idles.splice(e.idles.indexOf(t),1),e.ids.indexOf(t.identifier)>=0&&e.ids.splice(e.ids.indexOf(t.identifier),1),e.manager.removeIdentifier(t.identifier),e.manager.unbindDocument()};Lr.prototype.destroy=function(){var i=this;i.unbindEvt(i.options.zone,"start"),i.nipples.forEach(function(e){e.destroy()});for(var t in i.pressureIntervals)Object.prototype.hasOwnProperty.call(i.pressureIntervals,t)&&clearInterval(i.pressureIntervals[t]);i.trigger("destroyed",i.nipples),i.manager.unbindDocument(),i.off(),i.pressureIntervals={},i.nipples=[],i.idles=[],i.actives=[],i.ids=[],i.manager=null};var CI=Lr;function Vr(i){var t=this;t.ids={},t.index=0,t.collections=[],t.scroll=o1(),t._windowBound=!1,t.config(i),t.prepareCollections();var e=function(){var r;t.collections.forEach(function(n){n.forEach(function(o){r=o.el.getBoundingClientRect(),o.position={x:t.scroll.x+r.left,y:t.scroll.y+r.top}})})};return t._onResize=function(){mI(e)},t._onScroll=function(){t.scroll=o1()},t.collections}Vr.prototype=new Rd;Vr.constructor=Vr;Vr.prototype.prepareCollections=function(){var i=this;i.collections.create=i.create.bind(i),i.collections.on=i.on.bind(i),i.collections.off=i.off.bind(i),i.collections.destroy=i.destroy.bind(i),i.collections.get=function(t){var e;return i.collections.every(function(r){return e=r.get(t),!e}),e}};Vr.prototype.create=function(i){return this.createCollection(i)};Vr.prototype.bindWindowEvents=function(){var i=this;i._windowBound||typeof window>"u"||(i._windowBound=!0,Od(window,"resize",i._onResize),Od(window,"scroll",i._onScroll))};Vr.prototype.unbindWindowEvents=function(){var i=this;!i._windowBound||typeof window>"u"||(i._windowBound=!1,Id(window,"resize",i._onResize),Id(window,"scroll",i._onScroll))};Vr.prototype.createCollection=function(i){var t=this,e=new CI(t,i);return t.bindCollection(e),t.collections.push(e),t.bindWindowEvents(),e};Vr.prototype.bindCollection=function(i){var t=this,e,r=function(n,o){e=n.type+" "+o.id+":"+n.type,t.trigger(e,o)};i.on("destroyed",t.onDestroyed.bind(t)),i.on("shown hidden rested dir plain",r),i.on("dir:up dir:right dir:down dir:left",r),i.on("plain:up plain:right plain:down plain:left",r)};Vr.prototype.bindDocument=function(){var i=this;i.binded||(i.bindEvt(document,"move").bindEvt(document,"end"),i.binded=!0)};Vr.prototype.unbindDocument=function(i){var t=this;(!Object.keys(t.ids).length||i===!0)&&(t.unbindEvt(document,"move").unbindEvt(document,"end"),t.binded=!1)};Vr.prototype.getIdentifier=function(i){var t;return i?(t=i.identifier===void 0?i.pointerId:i.identifier,t===void 0&&(t=this.latest||0)):t=this.index,this.ids[t]===void 0&&(this.ids[t]=this.index,this.index+=1),this.latest=t,this.ids[t]};Vr.prototype.removeIdentifier=function(i){var t={};for(var e in this.ids)if(this.ids[e]===i){t.id=e,t.identifier=this.ids[e],delete this.ids[e];break}return t};Vr.prototype.onmove=function(i){var t=this;return t.onAny("move",i),!1};Vr.prototype.onend=function(i){var t=this;return t.onAny("end",i),!1};Vr.prototype.oncancel=function(i){var t=this;return t.onAny("end",i),!1};Vr.prototype.onAny=function(i,t){var e=this,r,n="processOn"+i.charAt(0).toUpperCase()+i.slice(1);t=xg(t);var o=function(s,l,c){c.ids.indexOf(l)>=0&&(c[n](s),s._found_=!0)},a=function(s){r=e.getIdentifier(s),sh(e.collections,o.bind(null,s,r)),s._found_||e.removeIdentifier(r)};return sh(t,a),!1};Vr.prototype.destroy=function(){var i=this;i.unbindDocument(!0),i.unbindWindowEvents(),i.ids={},i.index=0,i.collections.forEach(function(t){t.destroy()}),i.collections=[],i.off()};Vr.prototype.onDestroyed=function(i,t){var e=this;if(e.collections.indexOf(t)<0)return!1;e.collections.splice(e.collections.indexOf(t),1),e.collections.length===0&&e.unbindWindowEvents()};var EI=Vr;var Bd=null;function TI(){return Bd||(Bd=new EI),Bd}var bG={create:function(i){return TI().create(i)},destroy:function(){Bd&&(Bd.destroy(),Bd=null)},get factory(){return TI()}},PI=bG;var ne=require("three");var St=require("three");var pn=require("three");var Eg=new pn.Vector3,Ui=new pn.Camera,a1=class extends pn.LineSegments{constructor(e){let r=new pn.BufferGeometry,n=new pn.LineBasicMaterial({color:16777215,vertexColors:!0,toneMapped:!1}),o=[],a=[],s={},l=new pn.Color(15711266),c=new pn.Color(15711266),d=new pn.Color(2857471);u("n1","n2",l),u("n2","n4",l),u("n4","n3",l),u("n3","n1",l),u("f1","f2",l),u("f2","f4",l),u("f4","f3",l),u("f3","f1",l),u("n1","f1",l),u("n2","f2",l),u("n3","f3",l),u("n4","f4",l),u("p","n1",c),u("p","n2",c),u("p","n3",c),u("p","n4",c),u("u1","u2",d),u("u2","u3",d),u("u3","u1",d);function u(h,f,m){p(h,m),p(f,m)}function p(h,f){o.push(0,0,0),a.push(f.r,f.g,f.b),s[h]===void 0&&(s[h]=[]),s[h].push(o.length/3-1)}r.setAttribute("position",new pn.Float32BufferAttribute(o,3)),r.setAttribute("color",new pn.Float32BufferAttribute(a,3));super(r,n);this.type="CameraHelper",this.camera=e,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=s,this.update()}update(){let e=this.geometry,r=this.pointMap,n=!0;Ui.projectionMatrixInverse.elements=[.5112609807824982,-0,-0,-0,-0,.41421356237309503,-0,-0,-0,-0,-0,-.099999,-0,-0,-1.0000000000000002,.100001];let o=1,a=1,s=n?.8:1e-4;yo("n1",r,e,Ui,-o,-a,s),yo("n2",r,e,Ui,o,-a,s),yo("n3",r,e,Ui,-o,a,s),yo("n4",r,e,Ui,o,a,s);let l=s;yo("f1",r,e,Ui,-o,-a,l),yo("f2",r,e,Ui,o,-a,l),yo("f3",r,e,Ui,-o,a,l),yo("f4",r,e,Ui,o,a,l);let c=l,d=.5;yo("u1",r,e,Ui,o*.7*d,a*1.1,c),yo("u2",r,e,Ui,-o*.7*d,a*1.1,c),yo("u3",r,e,Ui,0,a*(1.1+.9*d),c),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};function yo(i,t,e,r,n,o,a){Eg.set(n,o,a).unproject(r);let s=t[i];if(s!==void 0){let l=e.getAttribute("position");for(let c=0,d=s.length;c<d;c++)l.setXYZ(s[c],Eg.x,Eg.y,Eg.z)}}var Tg=class extends jo(a1){constructor(e){super(e);this.object=e;this.name=`CombinedCameraHelper: ${e.uuid}`}updateMatrixWorld(e){super.updateMatrixWorld(e),this.updateTarget()}updateTarget(){let e=this.object.getTarget();this.updateWorldMatrix(!0,!1),this.worldToLocal(e)}raycast(e,r){Ho(this.object,this.geometry,e,r,!0)}};var Pg=790;function MI(i){return 1-Math.pow(1-i,3)}var Nd=new St.Vector3,s1=new St.Vector3,l1=new St.Quaternion,c1=new St.Vector3,dh=new St.Vector3,d1=new St.Vector3,$o=class extends ki(St.Camera,Tg){constructor(e="",r={...ml.defaultData,name:""}){super();this._cameraType="OrthographicCamera";this.targetOffset=io.DefaultTargetOffset;this.isUpVectorFlipped=!1;this.angleOffsetFromUp=0;this.wasMovedByUser=!1;this.wasMovedBySwitchCameraAction=!1;this._createdAt=typeof performance<"u"?performance.now():0;this._tickProjectionTransition=()=>{let e=this._projectionTransition;if(e===void 0)return;if(this.disposed){this._endProjectionTransition();return}e.raf=requestAnimationFrame(this._tickProjectionTransition);let r=$o.projectionTransitionRequestRender??e.requestRender;this.updateProjectionMatrix(),r?.()};this.super_Entity(e,r),this.previousProjectionMatrix=new St.Matrix4,this.matrixAutoUpdate=!0,this.width=window.innerWidth,this.height=window.innerHeight;let n=this.width,o=this.height;this.orthoCamera=new St.OrthographicCamera(n*-.5,n*.5,o*.5,o*-.5,-5e4,1e4),this.perspCamera=new St.PerspectiveCamera(45,n/o,50,1e4),this.left=this.orthoCamera.left,this.right=this.orthoCamera.right,this.top=this.orthoCamera.top,this.bottom=this.orthoCamera.bottom,this.far=this.orthoCamera.far,this.view=this.orthoCamera.view,this.aspect=this.perspCamera.aspect,this.focus=this.perspCamera.focus,this.filmGauge=this.perspCamera.filmGauge,this.filmOffset=this.perspCamera.filmOffset,this.objectHelper.update()}static withoutProjectionTransition(e){let r=$o.projectionTransitionsEnabled;$o.projectionTransitionsEnabled=!1;try{return e()}finally{$o.projectionTransitionsEnabled=r}}get isPerspectiveCamera(){return this.cameraType==="PerspectiveCamera"}get isOrthographicCamera(){return!this.isPerspectiveCamera}get cameraType(){return this._cameraType}set fov(e){this.perspCamera.fov=e}get fov(){return this.perspCamera.fov}setNear(e,r){e==="PerspectiveCamera"?this.perspCamera.near=r:this.orthoCamera.near=r}setZoom(e,r){r>=0&&(e==="PerspectiveCamera"?this.perspCamera.zoom=r:this.orthoCamera.zoom=r)}set cameraType(e){e==="PerspectiveCamera"?this.toPerspective():e==="OrthographicCamera"&&this.toOrthographic()}get near(){return this._cameraType==="PerspectiveCamera"?this.perspCamera.near:this.orthoCamera.near}set near(e){this._cameraType==="PerspectiveCamera"?this.perspCamera.near=e:this.orthoCamera.near=e}get zoom(){return this._cameraType==="PerspectiveCamera"?this.perspCamera.zoom:this.orthoCamera.zoom}set zoom(e){e>=0&&(this._cameraType==="PerspectiveCamera"?this.perspCamera.zoom=e:this.orthoCamera.zoom=e)}lookAt(e,r,n){typeof e=="number"&&(e=new St.Vector3(e,r,n)),super.lookAt(e),this.getWorldPosition(Nd),this.targetOffset=Nd.distanceTo(e)}getTarget(e=new St.Vector3){return this.getWorldDirection(s1),this.getWorldPosition(Nd),s1.multiplyScalar(this.targetOffset),e.copy(Nd).add(s1),e}getDistanceToTarget(){let e=this.getTarget();return this.getWorldPosition(Nd),Nd.distanceTo(e)}updateUp(){this.getWorldQuaternion(l1),c1.set(0,0,1).applyQuaternion(l1),dh.copy(St.Object3D.DEFAULT_UP),this.isUpVectorFlipped&&dh.negate(),dh.applyQuaternion(l1),d1.copy(St.Object3D.DEFAULT_UP).projectOnPlane(c1),this.angleOffsetFromUp=d1.angleTo(dh),this.angleOffsetFromUp*=d1.cross(dh).dot(c1)>=0?1:-1}updateTransformState(e,r){let n=super.updateTransformState(e,r);return e.isUpVectorFlipped!==void 0&&(this.isUpVectorFlipped=e.isUpVectorFlipped),this.updateUp(),n}getViewFrontToObject(e){let r=e.getWorldPosition(new St.Vector3),o=e.getWorldDirection(new St.Vector3).multiplyScalar(this.targetOffset);return{position:r.clone().add(o),target:r}}getViewToTarget(e){let n=this.getWorldDirection(new St.Vector3).multiplyScalar(this.targetOffset);return{position:e.clone().sub(n),target:e}}getViewToObject(e){let r=new St.Vector3;return e.getWorldPosition(r),this.getViewToTarget(r)}setViewplaneSize(e,r,n=!1){if(this.aspect=e/r,n){let o=e>r?this.aspect:1,a=e>r?1:this.aspect;this.left=-Pg*.5*o,this.right=Pg*.5*o,this.top=Pg*.5*(1/a),this.bottom=-Pg*.5*(1/a)}else this.left=-e*.5,this.right=e*.5,this.top=r*.5,this.bottom=-r*.5;this.updateProjectionMatrix()}copyViewPlaneSize(e){this.aspect=e.aspect,this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.updateProjectionMatrix()}toOrthographic(){this.orthoCamera.left=this.left,this.orthoCamera.right=this.right,this.orthoCamera.top=this.top,this.orthoCamera.bottom=this.bottom,this.orthoCamera.view=this.view,this.orthoCamera.far=this.far,this.orthoCamera.updateProjectionMatrix(),this.projectionMatrix=this.orthoCamera.projectionMatrix,this.projectionMatrixInverse=this.orthoCamera.projectionMatrixInverse,this._cameraType="OrthographicCamera",this._applyProjectionTransition(),this.objectHelper&&this.objectHelper.update()}toPerspective(){this.perspCamera.aspect=this.aspect,this.perspCamera.fov=this.fov,this.perspCamera.view=this.view,this.perspCamera.far=this.far,this.perspCamera.updateProjectionMatrix(),this.projectionMatrix=this.perspCamera.projectionMatrix,this.projectionMatrixInverse=this.perspCamera.projectionMatrixInverse,this._cameraType="PerspectiveCamera",this._applyProjectionTransition(),this.objectHelper&&this.objectHelper.update()}get isProjectionTransitioning(){return this._projectionTransition!==void 0}get projectionTransitionProgress(){let e=this._projectionTransition;if(e===void 0)return 1;let r=(performance.now()-e.start)/e.duration;return r>=1?1:r<=0?0:MI(r)}get _activeSubCamera(){return this._cameraType==="PerspectiveCamera"?this.perspCamera:this.orthoCamera}_canAnimateProjection(){return $o.projectionTransitionsEnabled&&typeof requestAnimationFrame=="function"&&typeof performance<"u"&&performance.now()-this._createdAt>=$o.projectionTransitionMinAgeMs}_beginProjectionTransition(e){let r=this._projectionTransition;r===void 0&&(r={from:new St.Matrix4,blend:new St.Matrix4,blendInverse:new St.Matrix4,start:0,duration:$o.projectionTransitionDuration,referenceDepth:1,raf:0,requestRender:e},this._projectionTransition=r),r.from.copy(this.projectionMatrix),r.start=performance.now(),r.duration=$o.projectionTransitionDuration,r.referenceDepth=Number.isFinite(this.targetOffset)?Math.max(1,this.targetOffset):1,e&&(r.requestRender=e),r.raf!==0&&cancelAnimationFrame(r.raf),r.raf=requestAnimationFrame(this._tickProjectionTransition)}_applyProjectionTransition(){let e=this._projectionTransition;if(e===void 0)return;let r=(performance.now()-e.start)/e.duration;if(r>=1){this._endProjectionTransition();return}let n=MI(r),o=e.from.elements,a=this._activeSubCamera.projectionMatrix.elements,s=e.blend.elements,l=e.referenceDepth,c=Math.max(1e-6,o[15]-o[11]*l),d=Math.max(1e-6,a[15]-a[11]*l),u=n*c/(n*c+(1-n)*d);for(let p=0;p<16;p++)s[p]=o[p]+(a[p]-o[p])*u;e.blendInverse.copy(e.blend).invert(),this.projectionMatrix=e.blend,this.projectionMatrixInverse=e.blendInverse}_endProjectionTransition(){let e=this._projectionTransition;if(e===void 0)return;e.raf!==0&&cancelAnimationFrame(e.raf),this._projectionTransition=void 0;let r=this._activeSubCamera;this.projectionMatrix=r.projectionMatrix,this.projectionMatrixInverse=r.projectionMatrixInverse}_syncProjectionTransition(e){let r=e._projectionTransition;if(r===void 0){this._projectionTransition!==void 0&&this._endProjectionTransition();return}let n=this._projectionTransition;n===void 0?(n={from:new St.Matrix4,blend:new St.Matrix4,blendInverse:new St.Matrix4,start:0,duration:1,referenceDepth:1,raf:0,requestRender:void 0},this._projectionTransition=n):n.raf!==0&&(cancelAnimationFrame(n.raf),n.raf=0),n.requestRender=void 0,n.from.copy(r.from),n.start=r.start,n.duration=r.duration,n.referenceDepth=r.referenceDepth,this._applyProjectionTransition()}setFocalLength(e){this.perspCamera.setFocalLength(e),this.toPerspective()}getFocalLength(){return this.perspCamera.getFocalLength()}getEffectiveFOV(){return this.perspCamera.getEffectiveFOV()}getFilmWidth(){return this.perspCamera.getFilmWidth()}getFilmHeight(){return this.perspCamera.getFilmHeight()}setViewOffset(e,r,n,o,a,s){this._cameraType==="PerspectiveCamera"?this.perspCamera.setViewOffset(e,r,n,o,a,s):this.orthoCamera.setViewOffset(e,r,n,o,a,s),this._applyProjectionTransition()}clearViewOffset(){this._cameraType==="PerspectiveCamera"?(this.perspCamera.clearViewOffset(),this.toPerspective()):(this.orthoCamera.clearViewOffset(),this.toOrthographic())}copyHistory(){this.previousProjectionMatrix&&this.previousProjectionMatrix.copy(this.projectionMatrix)}updateProjectionMatrix(){this._cameraType==="PerspectiveCamera"?this.toPerspective():this._cameraType==="OrthographicCamera"&&this.toOrthographic()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,r){super.updateWorldMatrix(e,r),this.matrixWorldInverse.copy(this.matrixWorld).invert()}copy(e,r){return super.copy(e,r),this.parent=e.parent,this.orthoCamera.copy(e.orthoCamera),this.perspCamera.copy(e.perspCamera),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.far=e.far,this.view=e.view===null?null:Object.assign({},e.view),this._cameraType=e._cameraType,this.aspect=e.aspect,this.fov=e.fov,this.focus=e.focus,this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this.targetOffset=io.sanitizeTargetOffset(e.targetOffset),this.updateProjectionMatrix(),this._syncProjectionTransition(e),this}toCameraState(e=[]){let r={type:this.cameraType,far:this.far,orthographic:{near:this.orthoCamera.near,zoom:this.orthoCamera.zoom},perspective:{near:this.perspCamera.near,fov:this.perspCamera.fov,zoom:this.perspCamera.zoom},up:this.up.toArray(),targetOffset:this.targetOffset,isUpVectorFlipped:this.isUpVectorFlipped};return wp(r,e)}updateCameraSubtype(e,r){let n=e==="perspective"?"PerspectiveCamera":"OrthographicCamera";r.zoom!==void 0&&this.setZoom(n,r.zoom),r.near!==void 0&&this.setNear(n,r.near),r.fov!==void 0&&n==="PerspectiveCamera"&&(this.fov=r.fov)}updateState(e,r){this.updateCameraState(e,r)}updateCameraState(e,r){this.updateState_Entity(e,r),e.far!==void 0&&(this.far=e.far),e.orthographic!==void 0&&this.updateCameraSubtype("orthographic",e.orthographic),e.perspective!==void 0&&this.updateCameraSubtype("perspective",e.perspective),e.type!==void 0&&(e.type!==this._cameraType&&this._canAnimateProjection()&&this._beginProjectionTransition(r?.shared.requestRender),this.cameraType=e.type),e.up!==void 0&&this.up.fromArray(e.up.map(n=>typeof n=="number"?n:0)),e.targetOffset!==void 0&&(this.targetOffset=io.sanitizeTargetOffset(e.targetOffset)),e.isUpVectorFlipped!==void 0&&(this.isUpVectorFlipped=e.isUpVectorFlipped),this.updateProjectionMatrix()}updateByPatchedOp(e,r,n){super.updateByPatchedOp(e,r,n),e.path.length===1&&e.type===0&&this.updateCameraSubtype(e.path[0],e.props)}toState(e){return{...super.toState(e),...this.toCameraState(e),type:this.cameraType}}},wt=$o;wt.projectionTransitionsEnabled=!1,wt.projectionTransitionDuration=350,wt.projectionTransitionMinAgeMs=1e3;var wG=null;function OI(i){wG=i}var AG,II=new Promise(i=>{AG=i});var Xr=require("three");var Ld=require("three");function CG(i){let t=i.elements,e=t[0]**2+t[1]**2+t[2]**2,r=t[4]**2+t[5]**2+t[6]**2,n=t[8]**2+t[9]**2+t[10]**2,o=t[0]**2+t[4]**2+t[8]**2,a=t[1]**2+t[5]**2+t[9]**2,s=t[2]**2+t[6]**2+t[10]**2,l=1e-8;return e<l||r<l||n<l||o<l||a<l||s<l}function Mg(i,t){let e=new Ld.BufferGeometry;if(t&&CG(t))return e.setAttribute("position",new Ld.Float32BufferAttribute([],3)),e.setIndex([]),e;if(!i.getAttribute("position"))return e.setAttribute("position",new Ld.Float32BufferAttribute([],3)),e.setIndex([]),e;let{positions:r,triIndices:n}=Hp(i.getAttribute("position"),i.getIndex());return e.setAttribute("position",new Ld.Float32BufferAttribute(r,3)),e.setIndex(n),t&&e.applyMatrix4(t),e}var EG=require("three/examples/jsm/utils/BufferGeometryUtils.js");var TG;II.then(i=>TG=i);var Dse=new Xr.Vector3,Rse=new Xr.Quaternion,Bse=new Xr.Vector3,Nse=new Xr.Euler(0,0,0,"YXZ"),Lse=new Xr.Euler(0,0,0,"XYZ"),_se=new Xr.Vector3,Fse=new Xr.Vector3,kse=new Xr.Vector3(1,1,1),Vse=new Xr.Quaternion,Gse=new Xr.Matrix4,Use=new Xr.Matrix4;var zse=new Xr.Quaternion,jse=new Xr.Sphere;var u1={type:"beginEvent",eventName:"Collision"};var p1=i=>i.states.some(t=>t.data.position!==void 0||t.data.rotation!==void 0||t.data.hiddenMatrix!==void 0||t.data.cloner!==void 0||t.data.pathSnapping!==void 0);var GI=require("three");gt();var DI=4,h1=8;var f1=.02,m1=.3,PG=65,RI=new ne.Vector3,BI=new ne.Vector3,MG=new ne.Vector3,En=new ne.Vector3,Va=new ne.Vector3,_d=new ne.Vector3,y1=new ne.Matrix4,NI=new ne.Matrix4,OG=new ne.Matrix4,fi=new ne.Quaternion,Ul=new ne.Quaternion,Fd=new ne.Euler(0,0,0,"YXZ"),IG=new ne.Vector3(1,0,0),ea=new ne.Vector3(0,1,0),DG=new ne.Vector3(0,0,1),LI=new ne.Vector3(1,1,1),g1=[],_I=i=>g1[i]??(g1[i]=new ne.Vector3),v1=new ne.Vector3,RG=new ne.Vector3,BG=new ne.Vector3,NG=new ne.Vector3,FI=new ne.Quaternion,LG=new ne.Vector3,kI=new ne.Quaternion,_G=1,FG=.025,kG=16e-6,VI=12,VG=20,rn=new ne.Line3,zi=new ne.Box3,GG={type:"requestRender"},UG={type:"updateMatrix"},Og=class extends ne.EventDispatcher{constructor(e,r,n,o,a,s,l,c,d){super();this.object=e;this.domElement=r;this.data=n;this.gloabalPhysics=o;this.controlsManager=a;this.cameraFollow=s;this.camera=l;this.page=c;this.sharedAssets=d;this.enableDamping=!0;this.hiddenMatrix0=new ne.Matrix4;this.target0=new ne.Vector3;this.zoom0=1;this.rotForce=1;this.moveForce=1;this.pixelsPerMeter=dI;this.euler0=new ne.Euler(0,0,0,"YXZ");this.position0Cam=new ne.Vector3;this.quat0Cam=new ne.Quaternion;this.scale0Cam=new ne.Vector3;this.hiddenMatrix0Cam=new ne.Matrix4;this.threshEndTranslate=.01;this.threshEndRotate=1e-8;this.threshEndRotVel=.005;this.collider={type:"capsule",radius:40,segment:new ne.Line3(new ne.Vector3(0,-40,0),new ne.Vector3(0,40,0)),matrix:new ne.Matrix4,position:new ne.Vector3,rotation:new ne.Quaternion};this.euler=new ne.Euler(0,0,0,"YXZ");this.eulerDelta=new ne.Vector3;this.lastPosition=new ne.Vector3;this.lastCameraQuaternion=new ne.Quaternion;this.lastCameraPosition=new ne.Vector3;this.PI_2=Math.PI/2;this.prevMouse=new ne.Vector2;this.velocityTarget=new ne.Vector3;this.velocity=new ne.Vector3;this.directionXZ=new ne.Vector3;this.rotVelocityStick=new ne.Vector3;this.rotVelocityTarget=new ne.Vector3;this.rotVelocity=new ne.Vector3;this.rotDirection=new ne.Vector3;this.nonColliderRotOffset=new ne.Matrix4;this.nonColliderPosOffset=new ne.Matrix4;this.firstPointerId=-1;this.rot=new ne.Vector3;this.path=[];this.movementState={moveNegZ:0,movePosZ:0,moveNegX:0,movePosX:0,moveNegY:0,movePosY:0,rotPosX:0,rotNegX:0,rotPosY:0,rotNegY:0,jump:0,run:0};this.onObject=!1;this.actionState={};this.keyAssignments=[["moveNegZ","W"],["moveNegX","A"],["movePosZ","S"],["movePosX","D"],["rotPosX","ArrowUp"],["rotPosY","ArrowLeft"],["rotNegX","ArrowDown"],["rotNegY","ArrowRight"],["jump"," "]];this.collisionEnabled=!0;this.offsetMatrix=new ne.Matrix4;this.objectToTarget=new ne.Vector3;this.objectToTarget0=new ne.Vector3;this.objectToCamXZ=new ne.Vector3;this.objectToCamXZ0=new ne.Vector3;this.targetToCamera=new ne.Vector3;this.targetToCamera0=new ne.Vector3;this.cameraPolarAxis0=new ne.Vector3;this.targetPos=new ne.Vector3;this.targetQuat=new ne.Quaternion;this.lerpFactorPos=new ne.Vector3().setScalar(.3);this.lerpFactorPosStart=.3;this.lerpFactorPosEnd=.3;this.lerpFactorRotStart=.3;this.lerpFactorRotEnd=.3;this.lerpFactorPosCamera=.3;this.lerpFactorRotCamera=.3;this.objXZQuat=new ne.Quaternion;this.objXZQuatInv=new ne.Quaternion;this.objXZRotMat=new ne.Matrix4;this.isFirstPerson=!1;this.didHit=!1;this.groundVelocity=new ne.Vector3;this.pushedVelocity=new ne.Vector3;this.groundYRotation=0;this.objectRealQuat=new ne.Quaternion;this.colliderWorldQuat=new ne.Quaternion;this.groundNormal=new ne.Vector3;this.groundTilt=new ne.Quaternion;this.groundTiltInv=new ne.Quaternion;this.lastHitObj=null;this.isFirstFrame=!0;this.rotationAccumWhenOrientWithCamera=0;this.navMeshPathDest=null;this.position=new ne.Vector3;this.quaternion=new ne.Quaternion;this.scale=new ne.Vector3;this.initialAction=!0;this.onPointerDown=e=>{!(e.target===this.domElement||e.target instanceof HTMLElement&&e.target.tagName==="SPLINE-VIEWER"&&e.target.shadowRoot?.contains(this.domElement))||this.firstPointerId!==-1||(this.firstPointerId=e.pointerId,this.domElement.ownerDocument.addEventListener("pointermove",this.onPointerMove),this.domElement.ownerDocument.addEventListener("pointerup",this.onPointerUp),this.rotBy!=="keys"&&!Xn&&!S0&&this.domElement.requestPointerLock(),this.prevMouse.set(e.clientX,e.clientY))};this.onPointerUp=e=>{this.firstPointerId=-1,this.domElement.ownerDocument.removeEventListener("pointermove",this.onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this.onPointerUp),e.pointerType==="mouse"&&this.domElement.ownerDocument.exitPointerLock()};this.onPointerMove=e=>{if(e.pointerId!==this.firstPointerId)return;let r=e.clientX-this.prevMouse.x,n=e.clientY-this.prevMouse.y;this.prevMouse.set(e.clientX,e.clientY),e.pointerType==="mouse"&&this.rotBy!=="keys"&&(S0&&MT<15.5&&!Xn?(this.eulerDelta.y=-r*this.mouseOrbitSensitivity,this.eulerDelta.x=-n*this.mouseOrbitSensitivity):(this.eulerDelta.y=-e.movementX*this.mouseOrbitSensitivity,this.eulerDelta.x=-e.movementY*this.mouseOrbitSensitivity)),e.pointerType!=="mouse"&&this.rotByTouch==="drag"&&(this.eulerDelta.y=-r*this.mouseOrbitSensitivity*5,this.eulerDelta.x=-n*this.mouseOrbitSensitivity*5),this.controlsManager.requestRender()};this.onPointerlockChange=e=>{this.domElement.ownerDocument.pointerLockElement===this.domElement?Og.isLocked=!0:Og.isLocked=!1};this.onPointerlockError=()=>{console.error("SPE.GameControls: Unable to use Pointer Lock API")};this.handleVisibilityChange=()=>{if(document?.hidden)for(let e in this.movementState)this.movementState[e]=0};this.onKeyDown=e=>{!(e.target instanceof HTMLInputElement)&&(e.code==="ArrowLeft"||e.code==="ArrowUp"||e.code==="ArrowRight"||e.code==="ArrowDown"||e.code==="Space")&&e.preventDefault();for(let r of this.keyAssignments)if(e.key.toUpperCase()===r[1]||e.key===r[1]){this.movementState[r[0]]=1;break}this.controlsManager.requestRender()};this.onKeyUp=e=>{for(let r of this.keyAssignments)if(e.key.toUpperCase()===r[1]||e.key===r[1]||e.code.slice(3,e.code.length).toUpperCase()===r[1]){this.movementState[r[0]]=0;break}};this.copyVRGamePadValues=(e,r)=>{for(let n=2;n<4;n++){let o=e.axes[n];r===0?n===2?this.movementState.movePosX=o:this.movementState.movePosZ=o:(e.buttons[3].pressed?this.movementState.jump=1:this.movementState.jump=0,n===2?this.movementState.rotPosY=o:this.moveMode==="fly"&&(this.movementState.moveNegY=o))}};this.sharedGameControlGlobals=a.sharedGameControlGlobals,e===l&&(this.isFirstPerson=!0),this.hiddenMatrix0.copy(this.object.hiddenMatrix),this.object.parent?this.object.hiddenMatrix.copy(this.object.parent.matrixWorld).invert():this.object.hiddenMatrix.identity(),this.object.matrix.copy(this.object.matrixWorld),this.object.matrix.decompose(this.position,this.quaternion,this.scale),this.euler0.setFromQuaternion(this.quaternion,"YXZ");let u=this.euler0.clone(),p=u.y;if(this.objectRealQuat.copy(this.quaternion),u.y=0,this.quaternion.setFromEuler(u),this.objXZQuat.copy(this.quaternion),this.objXZQuatInv.copy(this.objXZQuat).invert(),this.objXZRotMat.makeRotationFromQuaternion(this.quaternion),u.set(0,p,0),this.quaternion.setFromEuler(u),this.rot.setFromEuler(u),this.object.matrixAutoUpdate=!1,(this.isFirstPerson||this.cameraFollow===!0)&&(this.target0.copy(this.camera.getTarget()),this.zoom0=this.camera.zoom),this.cameraFollow===!0){this.position0Cam.copy(this.camera.position),this.quat0Cam.copy(this.camera.quaternion),this.scale0Cam.copy(this.camera.scale),this.hiddenMatrix0Cam.copy(this.camera.hiddenMatrix),this.camera.parent?(this.camera.hiddenMatrix.copy(this.camera?.parent.matrixWorld),this.camera.matrix.copy(this.camera.matrixWorld)):this.camera.hiddenMatrix.identity(),this.camera.matrix.copy(this.camera.matrixWorld),this.camera.matrix.decompose(this.camera.position,this.camera.quaternion,this.camera.scale),this.camera.matrixAutoUpdate=!1,this.offsetMatrix.copy(this.object.matrix).invert().multiply(this.camera.matrix);let y=new ne.Vector3(0,0,-1).applyQuaternion(this.camera.quaternion),g=new ne.Vector3().subVectors(this.position,this.camera.position);this.objectToCamXZ.copy(g),this.objectToCamXZ.y=0,this.objectToCamXZ0.copy(this.objectToCamXZ);let v;Math.abs(y.y)<1e-6?(g.y=0,y.y=0,v=g.projectOnVector(y)):g.y/y.y>0?v=y.multiplyScalar(g.y/y.y):v=y.multiplyScalar(g.length()),this.targetToCamera0.copy(v).negate();let b=this.camera.position.clone().add(v);this.objectToTarget0.subVectors(b,this.position);let S=new ne.Euler().setFromQuaternion(this.camera.quaternion,"YXZ");this.cameraPolarOffset=-S.x,S.x=0,S.z=0,S.y-=Math.PI/2,this.cameraPolarAxis0.set(0,0,-1).applyEuler(S)}if(this.object instanceof wt&&(this.object.matrixAutoUpdate=!1),this.euler.setFromQuaternion(this.quaternion,"YXZ"),this.rotByTouch=n.rotByTouch??"joystick",this.rotBy=n.rotBy??"keys",this.rotationMode=n.rotationMode??"normal",this.moveMode=n.moveMode??"walk",this.collisionEnabled=n.collisionEnabled,this.speedTranslate=(n.speedTranslate??250)*_G,this.speedOrbit=(n.speedRotate??100)*FG,this.mouseOrbitSensitivity=(n.speedRotate??100)*kG,this.keyAssignments=n.keyAssignments.map(y=>{let g=[y[0],y[1]];return g[1]==="\u25B2"?g[1]="ArrowUp":g[1]==="\u25C0"?g[1]="ArrowLeft":g[1]==="\u25BC"?g[1]="ArrowDown":g[1]==="\u25B6"?g[1]="ArrowRight":g[1]==="\u21E7"?g[1]="Shift":g[1]==="\u21B5"?g[1]="Enter":g[1]==="Space"?g[1]=" ":g[1]==="\u2318"?g[1]="Meta":g[1]==="Ctrl"?g[1]="Control":g[1]==="Esc"&&(g[1]="Escape"),g}),n.rotBy==="mouse"){let y;y=this.keyAssignments.findIndex(g=>g[0]==="rotNegX"),y!==-1&&(this.keyAssignments[y][1]=""),y=this.keyAssignments.findIndex(g=>g[0]==="rotPosX"),y!==-1&&(this.keyAssignments[y][1]=""),y=this.keyAssignments.findIndex(g=>g[0]==="rotPosY"),y!==-1&&(this.keyAssignments[y][1]=""),y=this.keyAssignments.findIndex(g=>g[0]==="rotNegY"),y!==-1&&(this.keyAssignments[y][1]="")}this.lerpFactorPosStart=1-.02**(1/((n.delayPos[0]??.3)*60)),this.lerpFactorPosEnd=1-.02**(1/((n.delayPos[1]??.3)*60)),this.lerpFactorPos.setScalar(this.lerpFactorPosStart),this.lerpFactorRotStart=1-.02**(1/((n.delayRot[0]??.3)*60)),this.lerpFactorRotEnd=1-.02**(1/((n.delayRot[1]??.3)*60)),this.lerpFactorPosCamera=1-.02**(1/((n.delayPosCamera??.3)*60)),this.lerpFactorRotCamera=1-.02**(1/((n.delayRotCamera??.3)*60)),this.gravity=(this.gloabalPhysics.gravity??hs.defaultData.gravity)*VI,this.usePhysics=this.gloabalPhysics.usePhysics??hs.defaultData.usePhysics,this.jumpPower=n.jumpPower*VG,this.resetYPosition=this.position.y+Math.abs(n.resetYPosition)*(this.gravity>0?1:-1),this.alignToGround=n.alignToGround??!1,this.orientMode=n.autoOrientMove?n.orientMode:"none",this.orientWith=n.orientWith??Fc.defaultDataThirdPerson.orientWith,this.slopeThresh=PG*Math.PI/180,n.collider.type==="capsule"?(this.collider.radius=n.collider.radius,this.collider.segment.start.y=n.collider.height/2-n.collider.radius,this.collider.segment.end.y=-this.collider.segment.start.y,this.offset=n.collider.height*f1/this.pixelsPerMeter,this.stepThresh=n.collider.height*m1/this.pixelsPerMeter,this.colliderHeight=n.collider.height):n.collider.type==="sphere"?(this.collider.radius=n.collider.radius,this.collider.segment.start.y=0,this.collider.segment.end.y=0,this.offset=2*n.collider.radius*f1/this.pixelsPerMeter,this.stepThresh=2*n.collider.radius*m1/this.pixelsPerMeter,this.colliderHeight=n.collider.radius*2):(this.offset=n.collider.height*f1/this.pixelsPerMeter,this.stepThresh=n.collider.height*m1/this.pixelsPerMeter,this.colliderHeight=n.collider.height),this.collider.type=n.collider.type;let h=new ne.Vector3().fromArray(n.collider.position.map(y=>typeof y=="number"?y:0)),f=new ne.Quaternion().setFromEuler(new ne.Euler().fromArray([...n.collider.rotation.map(y=>typeof y=="number"?y:0),"XYZ"]));this.collider.position.copy(h).multiply(this.scale),this.collider.rotation.copy(f),this.collider.matrix.compose(h,f,LI),n.cameraXAxis!==void 0&&(this.cameraXAxis=n.cameraXAxis,this.cameraYAxis=n.cameraYAxis,this.minPolarAngle=n.cameraRotXLimits[0],this.maxPolarAngle=n.cameraRotXLimits[1],this.minAzimuthAngleRel=n.cameraRotYLimits[0],this.maxAzimuthAngleRel=n.cameraRotYLimits[1]),this.forwardDir=n.forwardDirection??"-z",this.isFirstPerson&&(this.forwardDir="-z"),this.runMultiplier=n.runMultiplier??2;let m=n.navmesh.destinationHelperRadius*2;if(m>0){let y=new le;y.push({fi:0,data:{...Zt.defaultData("light","phong"),alpha:0},id:"layer1"}),y.push({fi:0,data:{...Zt.defaultData("color"),color:n.navmesh.destinationHelperColor,alpha:n.navmesh.destinationHelperColor.a},id:"layer2"});let g=Fy({layers:y},{scene:this.page.scene,shared:this.sharedAssets});this.navMeshPathDest=new GI.Mesh(hy.create({parameters:{width:m,height:m/10,hollow:.7}}),g),this.navMeshPathDest.material.userData.opacity0=n.navmesh.destinationHelperColor.a}this.activate()}reset(e=!1){if(this.object.hiddenMatrix.copy(this.hiddenMatrix0),e){this.object.updateMatrix(),this.object.updateMatrixWorld(),this.object.matrix.copy(this.object.matrixWorld),this.object.matrix.decompose(this.position,this.quaternion,this.scale),this.object.parent?this.object.hiddenMatrix.copy(this.object.parent.matrixWorld).invert():this.object.hiddenMatrix.identity();let r=new ne.Euler().setFromQuaternion(this.quaternion,"YXZ"),n=r.y;this.objectRealQuat.copy(this.quaternion),r.y=0,this.quaternion.setFromEuler(r),this.objXZQuat.copy(this.quaternion),this.objXZQuatInv.copy(this.objXZQuat).invert(),this.objXZRotMat.makeRotationFromQuaternion(this.quaternion),r.set(0,n,0),this.quaternion.setFromEuler(r),this.rot.setFromEuler(r),this.euler.setFromQuaternion(this.quaternion,"YXZ"),this.velocityTarget.set(0,0,0),this.velocity.set(0,0,0)}else this.object instanceof wt?this.object.matrixAutoUpdate=!0:this.object.updateMatrix();this.cameraFollow===!0&&(this.camera.quaternion.copy(this.quat0Cam),this.camera.position.copy(this.position0Cam),this.camera.scale.copy(this.scale0Cam),this.camera.hiddenMatrix.copy(this.hiddenMatrix0Cam),this.camera.matrixAutoUpdate=!0),this.controlsManager.requestRender()}activate(){this.instantiateActions(),this.domElement.ownerDocument.addEventListener("pointerdown",this.onPointerDown),this.domElement.ownerDocument.addEventListener("keydown",this.onKeyDown),this.domElement.ownerDocument.addEventListener("keyup",this.onKeyUp),this.domElement.ownerDocument.addEventListener("pointerlockchange",this.onPointerlockChange),this.domElement.ownerDocument.addEventListener("pointerlockerror",this.onPointerlockError),this.domElement.ownerDocument.addEventListener("visibilitychange",this.handleVisibilityChange)}deactivate(){this.disposeActions(),this.domElement.ownerDocument.removeEventListener("pointerdown",this.onPointerDown),this.domElement.ownerDocument.removeEventListener("keydown",this.onKeyDown),this.domElement.ownerDocument.removeEventListener("keyup",this.onKeyUp),this.domElement.ownerDocument.removeEventListener("pointerlockchange",this.onPointerlockChange),this.domElement.ownerDocument.removeEventListener("pointerlockerror",this.onPointerlockError),this.domElement.ownerDocument.removeEventListener("visibilitychange",this.handleVisibilityChange)}dispose(){this.deactivate(),this.navMeshPathDest?.parent&&this.page.remove(this.navMeshPathDest)}instantiateActions(){let e=this.data,r=this.sharedAssets;e.gameActions!==void 0&&(this.actions={},_c.list.forEach(n=>{this.actions[n]=Gt({...e,disabled:!1,type:"GameControl"},e.gameActions[n],this.page,r,this.controlsManager.eventManager,this.object)})),this.dispatchStopEvent("move"),this.dispatchStopEvent("run"),this.dispatchStopEvent("jump"),this.dispatchStartEvent("idle"),this.initialAction&&(this.initialAction=!1)}disposeActions(){this.initialAction=!1,this.dispatchStopEvent("idle"),this.dispatchStopEvent("move"),this.dispatchStopEvent("run"),this.dispatchStopEvent("jump"),br(this.actions.idle),br(this.actions.move),br(this.actions.run),br(this.actions.jump)}dispatchStartEvent(e){this.actions[e]!==void 0&&(this.actionState[e]||(this.actionState[e]=!0,this.actions[e].Transition.forEach(r=>{r.play()}),this.actions[e].Animation.forEach(r=>{r.play(this.initialAction===!1)}),this.actions[e].TimelineAnimation.forEach(r=>{r.play()}),this.actions[e].Create.forEach(r=>{r.dispatchStart()}),this.actions[e].Audio.forEach(r=>{r.dispatchGameControl("start")}),this.actions[e].Particles.forEach(r=>{r.dispatchGameControl("start")})))}dispatchStopEvent(e){this.actions[e]!==void 0&&(!this.actionState[e]||(this.actionState[e]=!1,this.actions[e].Transition.forEach(r=>{r.stop(),r.object.currentState!==null&&r.object.changeSelectedState(null,{scene:this.page.scene,shared:this.sharedAssets})}),this.actions[e].TimelineAnimation.forEach(r=>{r.stop()}),this.actions[e].Create.forEach(r=>{r.dispatchStop()}),this.actions[e].Audio.forEach(r=>{r.dispatchGameControl("stop")}),this.actions[e].Particles.forEach(r=>{r.dispatchGameControl("stop")})))}get colliderWorldPosition(){return En.copy(this.collider.position).applyQuaternion(this.objectRealQuat).add(this.position)}update(e){if(this.gravity<0?this.position.y<this.resetYPosition:this.position.y>this.resetYPosition)return this.reset(!0),!0;this.sharedGameControlGlobals.gamePads.forEach(this.copyVRGamePadValues);let r=(this.isFirstFrame?16.6:e)/1e3;this.isFirstFrame&&(this.isFirstFrame=!1);let n=r*60,o=!1;if(this.groundYRotation=0,this.groundVelocity.set(0,0,0),this.usePhysics&&this.collisionEnabled&&this.object.rigidBody?.collider(0).shape){let s=Va.set(0,(this.velocity.y===0?this.pixelsPerMeter*Math.max(Math.abs(this.gravity)/(10*VI),1)*(this.gravity>0?1:-1):this.velocity.y)*r,0).divideScalar(this.pixelsPerMeter),l=this.sharedGameControlGlobals.rapierWorld.castShape(this.colliderWorldPosition.divideScalar(this.pixelsPerMeter),this.colliderWorldQuat,s,this.object.rigidBody?.collider(0).shape,0,1,!1,h1,void 0,void 0,this.object.rigidBody);if(l){this.onObject=!0,this.groundNormal.set(l.normal2.x,l.normal2.y,l.normal2.z).applyQuaternion(this.colliderWorldQuat).negate(),this.alignToGround&&this.groundTiltAdjustment(this.groundNormal),Math.acos(this.groundNormal.y)<this.slopeThresh&&(o=!0),l.collider.parent()?.bodyType()===0&&Math.acos(this.groundNormal.y)*(180/Math.PI)>45&&(this.onObject=!1);let c=l.collider.parent(),d=c!==null&&c.isKinematic()?c:null,u=d===null?void 0:this.sharedGameControlGlobals.kinematicBodyToEntity.get(d.handle);if(d!==null&&u?.userData.isFollowingObj!==this.object.uuid){let p=this.object.getWorldPosition(En).add(this.collider.position).divideScalar(this.pixelsPerMeter),h=d.velocityAtPoint(p);this.groundVelocity.set(h.x,h.y,h.z).multiplyScalar(this.pixelsPerMeter),this.groundYRotation=d.angvel().y*r}}else this.onObject=!1}if(this.moveMode==="walk"&&this.collisionEnabled&&(this.movementState.jump===1&&this.onObject&&(this.velocityTarget.y=this.jumpPower,this.movementState.jump=0,this.dispatchStopEvent("idle"),this.dispatchStopEvent("move"),this.dispatchStopEvent("run"),this.dispatchStopEvent("jump"),this.dispatchStartEvent("jump"),this.onObject=!1),this.onObject?this.velocityTarget.y/=2:this.velocityTarget.y+=this.gravity*n),this.moveMode==="fly"&&(this.velocityTarget.y=(this.movementState.movePosY-this.movementState.moveNegY)*this.speedTranslate),this.directionXZ.z=this.movementState.movePosZ-this.movementState.moveNegZ,this.directionXZ.x=this.movementState.movePosX-this.movementState.moveNegX,this.forwardDir==="+z"&&this.directionXZ.multiplyScalar(-1),this.directionXZ.manhattanLength()>0&&(this.path=[]),this.navMeshPathDest){let s=this.navMeshPathDest.material;if(this.moveMode==="walk"&&this.path.length>1){this.navMeshPathDest.position.copy(this.path[this.path.length-1]),this.navMeshPathDest.parent||this.page.add(this.navMeshPathDest);let l=En.subVectors(this.path[1],this.position),c=Va.subVectors(this.path[1],this.path[0]);l.dot(c)<0?this.path.shift():(this.directionXZ.x=c.x,this.directionXZ.z=c.z),s.opacity=s.userData.opacity0}else s.opacity-=.05*s.userData.opacity0,this.navMeshPathDest.material.opacity<=0&&this.navMeshPathDest.parent&&this.page.remove(this.navMeshPathDest)}this.directionXZ.normalize(),this.movementState.run?this.moveForce=this.runMultiplier:this.moveForce=1,this.velocityTarget.z=this.directionXZ.z*this.speedTranslate*this.moveForce,this.velocityTarget.x=this.directionXZ.x*this.speedTranslate*this.moveForce,(this.moveMode==="walk"?this.velocityTarget.x+this.velocityTarget.z===0:this.velocityTarget.manhattanLength()===0)?this.lerpFactorPos.setScalar(this.lerpFactorPosEnd):this.lerpFactorPos.setScalar(this.lerpFactorPosStart),this.moveMode==="walk"&&(this.lerpFactorPos.y=1),this.didHit===!1&&this.pushedVelocity.manhattanLength()===0||this.usePhysics===!1?(this.velocity.x+=(this.velocityTarget.x-this.velocity.x)*(1-(1-this.lerpFactorPos.x)**n),this.velocity.y+=(this.velocityTarget.y-this.velocity.y)*(1-(1-this.lerpFactorPos.y)**n),this.velocity.z+=(this.velocityTarget.z-this.velocity.z)*(1-(1-this.lerpFactorPos.z)**n)):this.velocity.copy(this.velocityTarget),(this.moveMode==="walk"?this.velocity.x**2+this.velocity.z**2<this.speedTranslate:this.velocity.lengthSq()<this.speedTranslate)?(this.dispatchStopEvent("move"),this.dispatchStopEvent("run"),this.onObject&&(this.dispatchStopEvent("jump"),this.dispatchStartEvent("idle"))):(this.dispatchStopEvent("idle"),(this.onObject||this.moveMode==="fly")&&(this.dispatchStopEvent("jump"),this.movementState.run?(this.dispatchStopEvent("move"),this.dispatchStartEvent("run")):(this.dispatchStopEvent("run"),this.dispatchStartEvent("move"))));let a=MG.copy(this.velocity);if(this.orientMode!=="none"&&this.isFirstPerson===!1){let s=Va.copy(a);s.y=0,a.set(0,a.y,s.length()*(this.forwardDir==="+z"?1:-1))}if(this.directionXZ.manhattanLength()>0&&this.orientMode!=="none"&&this.isFirstPerson===!1)if(this.orientWith==="camera"&&this.path.length<=1){let s=En;this.camera.getWorldDirection(s);let l=_d.copy(ea).multiplyScalar(s.dot(ea));s.sub(l);let c=Va.copy(this.directionXZ);c.x*=-1,this.rot.y=s.angleTo(c)*(s.cross(c).y>0?-1:1)+this.rotationAccumWhenOrientWithCamera}else this.rot.y=(this.path.length>1?0:this.euler.y)+Math.atan2(-this.directionXZ.z,this.directionXZ.x)+Math.PI/2*(this.forwardDir==="+z"?1:-1);if(Fd.setFromVector3(this.rot),this.moveMode==="walk"&&(Fd.x=0),a.applyEuler(Fd),o&&(Ul.setFromUnitVectors(ea,this.groundNormal),a.applyQuaternion(Ul)),this.usePhysics===!0&&this.object.rigidBody){this.pushedVelocity.set(0,0,0);let s=0;for(let l of this.sharedGameControlGlobals.entitiesWithTransformAnim){if(l.rigidBody===void 0||l.prevQ===void 0)continue;(l.hasNonUniformScale?l.matrixWorldRigid:l.matrixWorld).decompose(v1,FI,RG);let c=this.object.getWorldPosition(BG).add(this.collider.position).sub(v1);kI.copy(l.prevQ).invert().premultiply(FI);let d=_d.subVectors(v1,l.prevT).add(NG.copy(c).applyQuaternion(kI).sub(c)).divideScalar(r).divideScalar(this.pixelsPerMeter),u=l.rigidBody.collider(0).castCollider(d,this.object.rigidBody.collider(0),En.copy(a).divideScalar(this.pixelsPerMeter),0,r,!1);d.multiplyScalar(this.pixelsPerMeter);let p=Le.is(l)?l:l.object;if(u!==null&&this.lastHitObj!==p){let h;l instanceof Rr&&(h=l);let f=this.sharedGameControlGlobals.entityToCollisionEvents[p.uuid];if(f)for(let m of f)m.data.target==="character"&&(m.dispatch(h),p.dispatchEvent(u1));this.lastHitObj=p}u!==null&&(Math.abs(d.x)>Math.abs(this.pushedVelocity.x)&&(this.pushedVelocity.x=d.x),Math.abs(d.y)>Math.abs(this.pushedVelocity.y)&&(this.pushedVelocity.y=d.y),Math.abs(d.z)>Math.abs(this.pushedVelocity.z)&&(this.pushedVelocity.z=d.z),_I(s++).copy(u.normal1).applyQuaternion(l.quaternion))}if(s>0){for(let l=0;l<s;l++){let c=_I(l),d=c.dot(a);d<0&&a.addScaledVector(c,-d)}a.add(this.pushedVelocity)}else a.add(this.groundVelocity)}if(this.rotDirection.y=Number(this.movementState.rotPosY)-Number(this.movementState.rotNegY),this.rotDirection.x=Number(this.movementState.rotPosX)-Number(this.movementState.rotNegX),this.rotDirection.normalize(),this.rotationMode==="normal"&&(this.movementState.rotPosX||this.movementState.rotNegX)||this.rotationMode==="steer"&&(this.movementState.rotPosX||this.movementState.rotNegX)&&(this.movementState.movePosZ||this.movementState.moveNegZ||this.moveMode==="walk")?this.rotVelocityStick.x=-this.rotDirection.x*this.speedOrbit*this.rotForce:this.rotVelocityStick.x=0,this.rotationMode==="normal"&&(this.movementState.rotPosY||this.movementState.rotNegY)||this.rotationMode==="steer"&&(this.movementState.rotPosY||this.movementState.rotNegY)&&(this.movementState.movePosZ||this.movementState.moveNegZ)?this.rotVelocityStick.y=-this.rotDirection.y*this.speedOrbit*this.rotForce:this.rotVelocityStick.y=0,this.rotVelocityTarget.subVectors(this.eulerDelta.divideScalar(r),this.rotVelocityStick),this.rotVelocityTarget.manhattanLength()===0?this.rotVelocity.lerp(this.rotVelocityTarget,1-(1-this.lerpFactorRotEnd)**n):this.rotVelocity.lerp(this.rotVelocityTarget,1-(1-this.lerpFactorRotStart)**n),this.euler.x+=this.rotVelocity.x*r,this.euler.y+=this.rotVelocity.y*r+this.groundYRotation,this.rotVelocityTarget.y===0&&this.directionXZ.manhattanLength()===0?this.rotationAccumWhenOrientWithCamera=0:(this.cameraFollow===!1||this.cameraYAxis==="Locked")&&(this.rotationAccumWhenOrientWithCamera+=this.rotVelocity.y*r),this.isFirstPerson===!1&&this.orientMode!=="none"&&this.directionXZ.manhattanLength()>0){if(this.orientMode==="radial"){this.objectToCamXZ.copy(this.objectToCamXZ0).applyAxisAngle(ea,this.euler.y-this.euler0.y);let s=Va.copy(this.objectToCamXZ).normalize(),l=_d.copy(a).multiplyScalar(r);l.y=0;let c=l.sub(En.copy(s).multiplyScalar(l.dot(s))).cross(s).y;this.euler.y-=Math.atan2(c,this.objectToCamXZ.length())}}else this.rot.y+=this.rotVelocity.y*r+this.groundYRotation,this.rotVelocityTarget.y!==0&&(this.cameraFollow===!1||this.cameraYAxis==="Locked")&&(this.euler.y=this.rot.y);if(this.cameraFollow===!0&&(this.moveMode==="walk"?this.cameraXAxis==="Limit"?this.euler.x=ne.MathUtils.clamp(this.euler.x,-this.maxPolarAngle+this.cameraPolarOffset+1e-6,-this.minPolarAngle+this.cameraPolarOffset-1e-6):this.euler.x=ne.MathUtils.clamp(this.euler.x,-this.PI_2+this.cameraPolarOffset,this.PI_2+this.cameraPolarOffset):this.cameraXAxis==="Limit"&&(this.euler.x=ne.MathUtils.clamp(this.euler.x,-this.PI_2,this.PI_2))),this.moveMode==="fly"?this.rot.x=this.euler.x:this.isFirstPerson&&(Fd.copy(this.euler),Fd.y=0,this.nonColliderRotOffset.makeRotationFromEuler(Fd)),fi.setFromAxisAngle(IG,this.rot.x),Ul.setFromAxisAngle(ea,this.rot.y),Ul.multiply(fi),fi.setFromAxisAngle(DG,this.rot.z),Ul.multiply(fi),this.quaternion.copy(Ul),this.objectRealQuat.multiplyQuaternions(this.quaternion,this.objXZQuat),this.colliderWorldQuat.copy(this.objectRealQuat).multiply(this.collider.rotation),this.collisionEnabled)if(this.usePhysics&&this.object.rigidBody?.collider(0).shape){let s=Va.copy(a).multiplyScalar(r/this.pixelsPerMeter),l=null;this.didHit=!1;let c=new ne.Vector3;for(let p=0;p<5;p++){let h=s.length(),f=_d.copy(s).normalize();if(l=this.sharedGameControlGlobals.rapierWorld.castShape(this.colliderWorldPosition.divideScalar(this.pixelsPerMeter).add(c),this.colliderWorldQuat,f,this.object.rigidBody.collider(0).shape,0,h,!1,h1|DI,void 0,void 0,this.object.rigidBody),l!==null){this.didHit=!0;let m=this.sharedGameControlGlobals.colliderToEntity.get(l.collider.handle);if(m!==this.lastHitObj&&p===0){this.lastHitObj=m;let b=this.sharedGameControlGlobals.entityToCollisionEvents[m?.uuid];if(b){for(let S of b)if(S.data.target==="character"){let x=(this.sharedGameControlGlobals.rapierWorld?.getCollider(l.collider.handle))._parent,w;if(m.cloner){for(let A of m.cloner.children)if(A.rigidBody===x){w=A;break}}S.dispatch(w),m.dispatchEvent(u1)}}}let y=RI.set(l.normal2.x,l.normal2.y,l.normal2.z).applyQuaternion(this.colliderWorldQuat),g=BI.copy(f).multiplyScalar(l.time_of_impact).dot(y),v=l.time_of_impact;if(v===0&&(this.position.y+=this.offset*this.pixelsPerMeter),g>this.offset&&(v=l.time_of_impact*(g-this.offset)/g,c.addScaledVector(f,v)),s.copy(f).multiplyScalar(h-v),Math.acos(-y.y)>this.slopeThresh){let b=this.colliderWorldPosition.divideScalar(this.pixelsPerMeter).add(c),S=_d.copy(l.witness2).applyQuaternion(this.colliderWorldQuat);S.y=0;let x=b.add(S);x.y+=this.stepThresh;let w=this.sharedGameControlGlobals.rapierWorld.castShape(x,this.colliderWorldQuat,s,this.object.rigidBody?.collider(0).shape,0,1,!1,h1|DI,void 0,void 0,this.object.rigidBody);w!==null&&w.time_of_impact===0&&(y.y=0,y.normalize())}s.addScaledVector(y,-s.dot(y))}else{p===0&&this.directionXZ.manhattanLength()!==0&&(this.lastHitObj=null),c.add(s);break}}this.position.addScaledVector(c,this.pixelsPerMeter),En.copy(this.position).divideScalar(this.pixelsPerMeter),fi.copy(this.quaternion).premultiply(this.groundTilt).multiply(this.objXZQuat);let d=this.object.rigidBody,u=d!==void 0&&LG.copy(En).sub(d.translation()).lengthSq()>1;d!==void 0&&(u?(d.setTranslation(En,!0),d.setRotation(fi,!0)):(d.setNextKinematicTranslation(En),d.setNextKinematicRotation(fi)))}else{let s=this.onObject?1:5,l=a.multiplyScalar(r/s);for(let c=0;c<s;c++)this.position.add(l),this.collisionAdjustment(r/s)}else this.position.addScaledVector(a,r);if(this.moveMode==="walk"&&this.onObject&&(this.velocityTarget.y=0,this.velocity.y=0),this.quaternion.premultiply(this.groundTilt).multiply(this.objXZQuat),this.object.matrix.compose(this.position,this.quaternion,this.scale),this.object.matrixWorldNeedsUpdate=!0,this.object.matrix.multiply(this.nonColliderPosOffset).multiply(this.nonColliderRotOffset),this.quaternion.premultiply(this.groundTiltInv).multiply(this.objXZQuatInv),this.cameraFollow===!0){this.updateFollowArms();let s=this.objectToTarget.add(this.position),l=this.targetToCamera.add(s);y1.lookAt(l,s,ea).setPosition(l),y1.decompose(this.targetPos,this.targetQuat,En),this.camera.quaternion.slerp(this.targetQuat,1-(1-this.lerpFactorRotCamera)**n),this.camera.position.lerp(this.targetPos,1-(1-this.lerpFactorPosCamera)**n),this.camera.updateMatrix(),this.camera.updateMatrixWorld(),this.cameraYAxis==="Limit"&&this.orientMode==="cartesian"&&(this.euler.y=ne.MathUtils.clamp(this.euler.y,this.minAzimuthAngleRel,this.maxAzimuthAngleRel)),this.euler.x=ne.MathUtils.clamp(this.euler.x,-this.PI_2+(this.cameraPolarOffset<0?this.cameraPolarOffset:0),this.PI_2+(this.cameraPolarOffset>0?this.cameraPolarOffset:0))}return this.eulerDelta.set(0,0,0),this.object.dispatchEvent(UG),this.path.length<2&&this.lastPosition.distanceToSquared(this.position)<this.threshEndTranslate&&Math.abs(this.rotVelocity.x)<this.threshEndRotVel&&Math.abs(this.rotVelocity.y)<this.threshEndRotVel&&(this.camera===void 0||this.isFirstPerson||this.lastCameraPosition.distanceToSquared(this.camera.position)<this.threshEndTranslate&&8*(1-this.lastCameraQuaternion.dot(this.camera.quaternion))<this.threshEndRotate)&&(this.moveMode==="fly"||this.onObject===!0||this.collisionEnabled===!1)&&(this.navMeshPathDest===null||this.navMeshPathDest.material.opacity<-.04*this.navMeshPathDest?.material?.userData.opacity0)?!1:(this.camera&&(this.lastCameraPosition.copy(this.camera.position),this.lastCameraQuaternion.copy(this.camera.quaternion)),this.lastPosition.copy(this.position),this.object.dispatchEvent(GG),!0)}updateFollowArms(){this.objectToTarget.copy(this.objectToTarget0),this.targetToCamera.copy(this.targetToCamera0);let e=fi.setFromAxisAngle(ea,this.cameraYAxis==="Limit"&&this.orientMode!=="radial"?ne.MathUtils.clamp(this.euler.y-this.euler0.y,this.minAzimuthAngleRel,this.maxAzimuthAngleRel):this.euler.y-this.euler0.y);(this.cameraYAxis!=="Locked"||this.orientMode==="radial")&&this.objectToTarget.applyQuaternion(e);let r;this.cameraXAxis==="Limit"?r=ne.MathUtils.clamp(this.euler.x,-this.maxPolarAngle+this.cameraPolarOffset+1e-6,-this.minPolarAngle+this.cameraPolarOffset-1e-6):r=ne.MathUtils.clamp(this.euler.x,-this.PI_2+this.cameraPolarOffset+1e-6,this.PI_2+this.cameraPolarOffset-1e-6);let n=En.copy(this.cameraPolarAxis0);(this.cameraYAxis!=="Locked"||this.orientMode==="radial")&&n.applyQuaternion(e);let o=Ul.setFromAxisAngle(n,r);this.cameraYAxis!=="Locked"&&this.targetToCamera.applyQuaternion(e),this.cameraXAxis!=="Locked"&&this.targetToCamera.applyQuaternion(o)}groundTiltAdjustment(e){ea.angleTo(e)*180/Math.PI<15||ea.angleTo(e)*180/Math.PI>85?fi.identity():fi.setFromUnitVectors(ea,e),this.groundTilt.slerp(fi,.06),this.groundTiltInv.copy(this.groundTilt).invert()}collisionAdjustment(e){let r=BI.set(0,0,0);this.object.matrix.compose(this.position,this.quaternion,this.scale);let n=y1.multiplyMatrices(this.object.matrix,this.objXZRotMat).multiply(this.collider.matrix).decompose(En,fi,Va).compose(En,fi,LI);this.sharedGameControlGlobals.entitiesWithTransformAnim.forEach(a=>{if(a===this.object||a.isDescendantOf(this.object)||!a.bvhGeometry||!a.bvhGeometry.boundsTree)return;zi.makeEmpty(),a.updateMatrixWorldRigid();let s=a.matrixWorldRigid,l=NI.copy(s).invert(),c=OG.copy(NI).multiply(n);rn.copy(this.collider.segment),rn.start.applyMatrix4(c),rn.end.applyMatrix4(c);let d=RI.copy(this.position).applyMatrix4(l);zi.expandByPoint(rn.start),zi.expandByPoint(rn.end),zi.min.addScalar(-this.collider.radius),zi.max.addScalar(this.collider.radius),a.bvhGeometry.boundsTree.shapecast({boundsTraverseOrder(u){return u.distanceToPoint(rn.end)},intersectsBounds:u=>u.intersectsBox(zi),intersectsTriangle:u=>{let p=En,h=Va,f=u.closestPointToSegment(rn,p,h);if(f<this.collider.radius){let m=this.collider.radius-f,y=h.sub(p).normalize(),g=_d.copy(d);g.addScaledVector(y,m);let v=g.applyMatrix4(s).sub(this.position);r.add(v),rn.start.addScaledVector(y,m),rn.end.addScaledVector(y,m)}}})}),zi.makeEmpty(),rn.copy(this.collider.segment),rn.start.applyMatrix4(n),rn.end.applyMatrix4(n),zi.expandByPoint(rn.start),zi.expandByPoint(rn.end),zi.min.addScalar(-this.collider.radius),zi.max.addScalar(this.collider.radius),this.sharedGameControlGlobals.staticMeshBVH?.shapecast({boundsTraverseOrder(a){return a.distanceToPoint(rn.end)},intersectsBounds:a=>a.intersectsBox(zi),intersectsTriangle:a=>{let s=En,l=Va,c=a.closestPointToSegment(rn,s,l);if(c<this.collider.radius){let d=this.collider.radius-c,u=l.sub(s).normalize();this.alignToGround&&this.groundTiltAdjustment(u),r.addScaledVector(u,d),rn.start.addScaledVector(u,d),rn.end.addScaledVector(u,d)}}}),this.onObject=Math.abs(r.y)>Math.abs(e*this.velocity.y*.25),this.onObject&&this.dispatchStopEvent("jump");let o=Math.max(0,r.length()-1e-5);r.normalize().multiplyScalar(o),this.position.add(r)}pause(){this.firstPointerId=-1,this.movementState={moveNegZ:0,movePosZ:0,moveNegX:0,movePosX:0,moveNegY:0,movePosY:0,rotPosX:0,rotNegX:0,rotPosY:0,rotNegY:0,jump:0,run:0},this.deactivate()}resume(){this.activate()}},uh=Og;uh.isLocked=!1;var go=require("three"),HI=require("three/examples/jsm/utils/BufferGeometryUtils.js");var zG,UI=new Promise(i=>{zG=i});var zI;var jG=!1?typeof window<"u"?window.location.href:"":"https://cdn.spline.design/@splinetool/runtime@2.0.84/build/",HG=i=>`
|
|
1327
|
+
`)>=0&&(t-=o),r===3?e*.5-t*.5:r===2?e-t:0}getLineInitialOffsetY(t,e,r,n,o){let a=e*t,s=Math.abs(this.ascender-this.descender)*n,l=t-s,c=-this.ascender*n-l/2;return o===3?-(r-a-c):o===2?-(r*.5-a*.5-c):c}createPath(t,e,r,n,o){let a=t.getPath(r,-n,o.fontSize,{kerning:!1,letterSpacing:o.letterSpacing});if(!a){console.error('THREE.Font: character "'+t+'" does not exists in font family '+this.familyName+".");return}let s=new mg,l=(t.advanceWidth??1)*e;if(t)for(let c of a.commands){let d=s.currentPath?.currentPoint;if(!(d&&c.type!=="Z"&&d.x===c.x&&-d.y===c.y))switch(c.type){case"M":s.moveTo(c.x,-c.y);break;case"L":s.lineTo(c.x,-c.y);break;case"Q":s.quadraticCurveTo(c.x1,-c.y1,c.x,-c.y);break;case"C":s.bezierCurveTo(c.x1,-c.y1,c.x2,-c.y2,c.x,-c.y);break}}return s.subPaths.forEach(c=>{let d=yG(c.curves);d!==void 0&&c.currentPoint.distanceTo(d)>0&&c.lineTo(d.x,d.y)}),{offsetX:l,path:s}}getCharWidth(t,e){try{return this.font?.getAdvanceWidth(t,e.fontSize,{kerning:!0,letterSpacing:e.letterSpacing})??0}catch(r){return this.warnLayoutError(r),0}}getTextWidth(t,e){try{return this.font?.getAdvanceWidth(t,e.fontSize,{kerning:!0,letterSpacing:e.letterSpacing})??0}catch(r){return this.warnLayoutError(r),0}}computeSpaceWidthForLine(t,e,r,n){let o=this.getCharWidth(" ",r),a=t[e];if(a){let s=this.countSpaces(a.trimEnd());if(r.horizontalAlign===4&&e<t.length-1&&s){let l=typeof r.width=="string"?Number(n.getVariable(r.width)):r.width,c=this.getTextWidth(a,r);return(l-(c-s*o))/s}}return o}countSpaces(t){return(t.match(/ /g)||[]).length}};function yG(i){if(i.length){let t=i[0];if(t instanceof Md.LineCurve)return t.v1;if(t instanceof Md.CubicBezierCurve||t instanceof Md.QuadraticBezierCurve)return t.v0}}Oi("TextGeometry",(i,t,e)=>new Es(i,t,e));var cI={create:(i,t)=>new hd(i,t)};Ep("TextGeometry",cI);Ep("InputGeometry",cI);qP(gg);Pe("text");var dI=200,gG=null;function uI(i){gG=i}var ah=(i,t)=>{let e=t.x-i.x,r=t.y-i.y;return Math.sqrt(e*e+r*r)},pI=(i,t)=>{let e=t.x-i.x,r=t.y-i.y;return vG(Math.atan2(r,e))},hI=(i,t,e)=>{let r={x:0,y:0};return e=bg(e),r.x=i.x-t*Math.cos(e),r.y=i.y-t*Math.sin(e),r},bg=i=>i*(Math.PI/180),vG=i=>i*(180/Math.PI),fI=i=>isNaN(i.buttons)?i.pressure!==0:i.buttons!==0,vg=new Map,mI=i=>{vg.has(i)&&clearTimeout(vg.get(i)),vg.set(i,setTimeout(function(){vg.delete(i),i()},100))},Od=(i,t,e)=>{let r=t.split(/[ ,]+/g),n;for(let o=0;o<r.length;o+=1)n=r[o],i.addEventListener?i.addEventListener(n,e,!1):i.attachEvent&&i.attachEvent(n,e)},Id=(i,t,e)=>{let r=t.split(/[ ,]+/g),n;for(let o=0;o<r.length;o+=1)n=r[o],i.removeEventListener?i.removeEventListener(n,e):i.detachEvent&&i.detachEvent(n,e)};var xg=i=>(i.preventDefault(),i.type.match(/^touch/)?i.changedTouches:i),o1=()=>{if(typeof window>"u")return;let i=window.pageXOffset!==void 0?window.pageXOffset:(document.documentElement||document.body.parentNode||document.body).scrollLeft,t=window.pageYOffset!==void 0?window.pageYOffset:(document.documentElement||document.body.parentNode||document.body).scrollTop;return{x:i,y:t}},Sg=(i,t)=>{t.top||t.right||t.bottom||t.left?(i.style.top=t.top,i.style.right=t.right,i.style.bottom=t.bottom,i.style.left=t.left):(i.style.left=t.x+"px",i.style.top=t.y+"px")},wg=(i,t,e)=>{let r=gI(i);for(let n in r)if(Object.prototype.hasOwnProperty.call(r,n))if(typeof t=="string")r[n]=t+" "+e;else{let o="";for(let a=0,s=t.length;a<s;a+=1)o+=t[a]+" "+e+", ";r[n]=o.slice(0,-2)}return r},yI=(i,t)=>{let e=gI(i);for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&(e[r]=t);return e},gI=i=>{let t={};return t[i]="",["webkit","Moz","o"].forEach(function(r){t[r+i.charAt(0).toUpperCase()+i.slice(1)]=""}),t},Ag=(i,t)=>{for(let e in t)Object.prototype.hasOwnProperty.call(t,e)&&(i[e]=t[e]);return i},vI=(i,t)=>{let e={};for(let r in i)Object.prototype.hasOwnProperty.call(i,r)&&Object.prototype.hasOwnProperty.call(t,r)?e[r]=t[r]:Object.prototype.hasOwnProperty.call(i,r)&&(e[r]=i[r]);return e},sh=(i,t)=>{if(i.length)for(let e=0,r=i.length;e<r;e+=1)t(i[e]);else t(i)},bI=(i,t,e)=>({x:Math.min(Math.max(i.x,t.x-e),t.x+e),y:Math.min(Math.max(i.y,t.y-e),t.y+e)});typeof window<"u"&&(xI="ontouchstart"in window,SI=!!window.PointerEvent,wI=!!window.MSPointerEvent);var xI,SI,wI,lh={touch:{start:"touchstart",move:"touchmove",end:"touchend, touchcancel"},mouse:{start:"mousedown",move:"mousemove",end:"mouseup"},pointer:{start:"pointerdown",move:"pointermove",end:"pointerup, pointercancel"},MSPointer:{start:"MSPointerDown",move:"MSPointerMove",end:"MSPointerUp"}},Dd,ch={};SI?Dd=lh.pointer:wI?Dd=lh.MSPointer:xI?(Dd=lh.touch,ch=lh.mouse):Dd=lh.mouse;function Gl(){}Gl.prototype.on=function(i,t){var e=this,r=i.split(/[ ,]+/g),n;e._handlers_=e._handlers_||{};for(var o=0;o<r.length;o+=1)n=r[o],e._handlers_[n]=e._handlers_[n]||[],e._handlers_[n].push(t);return e};Gl.prototype.off=function(i,t){var e=this;return e._handlers_=e._handlers_||{},i===void 0?e._handlers_={}:t===void 0?e._handlers_[i]=null:e._handlers_[i]&&e._handlers_[i].indexOf(t)>=0&&e._handlers_[i].splice(e._handlers_[i].indexOf(t),1),e};Gl.prototype.trigger=function(i,t){var e=this,r=i.split(/[ ,]+/g),n;e._handlers_=e._handlers_||{};for(var o=0;o<r.length;o+=1)n=r[o],e._handlers_[n]&&e._handlers_[n].length&&e._handlers_[n].forEach(function(a){a.call(e,{type:n,target:e},t)})};Gl.prototype.config=function(i){var t=this;t.options=t.defaults||{},i&&(t.options=vI(t.options,i))};Gl.prototype.bindEvt=function(i,t){var e=this;return e._domHandlers_=e._domHandlers_||{},e._domHandlers_[t]=function(){typeof e["on"+t]=="function"?e["on"+t].apply(e,arguments):console.warn('[WARNING] : Missing "on'+t+'" handler.')},Od(i,Dd[t],e._domHandlers_[t]),ch[t]&&Od(i,ch[t],e._domHandlers_[t]),e};Gl.prototype.unbindEvt=function(i,t){var e=this;return e._domHandlers_=e._domHandlers_||{},Id(i,Dd[t],e._domHandlers_[t]),ch[t]&&Id(i,ch[t],e._domHandlers_[t]),delete e._domHandlers_[t],this};var Rd=Gl;function qr(i,t){return this.identifier=t.identifier,this.position=t.position,this.frontPosition=t.frontPosition,this.collection=i,this.defaults={size:100,threshold:.1,color:"white",fadeTime:250,dataOnly:!1,restJoystick:!0,restOpacity:1,mode:"dynamic",zone:document.body,lockX:!1,lockY:!1,shape:"circle"},this.config(t),this.options.mode==="dynamic"&&(this.options.restOpacity=0),this.id=qr.id,qr.id+=1,this.buildEl().stylize(),this.instance={el:this.ui.el,on:this.on.bind(this),off:this.off.bind(this),show:this.show.bind(this),hide:this.hide.bind(this),add:this.addToDom.bind(this),remove:this.removeFromDom.bind(this),destroy:this.destroy.bind(this),setPosition:this.setPosition.bind(this),resetDirection:this.resetDirection.bind(this),computeDirection:this.computeDirection.bind(this),trigger:this.trigger.bind(this),position:this.position,frontPosition:this.frontPosition,ui:this.ui,identifier:this.identifier,id:this.id,options:this.options},this.instance}qr.prototype=new Rd;qr.constructor=qr;qr.id=0;qr.prototype.buildEl=function(i){return this.ui={},this.options.dataOnly?this:(this.ui.el=document.createElement("div"),this.ui.back=document.createElement("div"),this.ui.front=document.createElement("div"),this.ui.el.className="nipple collection_"+this.collection.id,this.ui.back.className="back",this.ui.front.className="front",this.ui.el.setAttribute("id","nipple_"+this.collection.id+"_"+this.id),this.ui.el.appendChild(this.ui.back),this.ui.el.appendChild(this.ui.front),this)};qr.prototype.stylize=function(){if(this.options.dataOnly)return this;var i=this.options.fadeTime+"ms",t=yI("borderRadius","50%"),e=wg("transition","opacity",i),r={};return r.el={position:"absolute",opacity:this.options.restOpacity,display:"block",zIndex:999},r.back={position:"absolute",display:"block",width:this.options.size+"px",height:this.options.size+"px",marginLeft:-this.options.size/2+"px",marginTop:-this.options.size/2+"px",background:"rgba(255, 255, 255, .4)",border:"solid 2px rgba(0, 0, 0, .1)"},r.front={width:this.options.size/2+"px",height:this.options.size/2+"px",position:"absolute",display:"block",marginLeft:-this.options.size/4+"px",marginTop:-this.options.size/4+"px",background:"rgba(255, 255, 255, .8)",border:"solid 2px rgba(0, 0, 0, .1)"},Ag(r.el,e),this.options.shape==="circle"&&Ag(r.back,t),Ag(r.front,t),this.applyStyles(r),this};qr.prototype.applyStyles=function(i){for(var t in this.ui)if(Object.prototype.hasOwnProperty.call(this.ui,t))for(var e in i[t])this.ui[t].style[e]=i[t][e];return this};qr.prototype.addToDom=function(){return this.options.dataOnly||document.body.contains(this.ui.el)?this:(this.options.zone.appendChild(this.ui.el),this)};qr.prototype.removeFromDom=function(){return this.options.dataOnly||!document.body.contains(this.ui.el)?this:(this.options.zone.removeChild(this.ui.el),this)};qr.prototype.destroy=function(){clearTimeout(this.removeTimeout),clearTimeout(this.showTimeout),clearTimeout(this.restTimeout),this.trigger("destroyed",this.instance),this.removeFromDom(),this.off(),this.ui=null,this.instance=null,this.collection=null,this.options=null};qr.prototype.show=function(i){var t=this;return t.options.dataOnly||(clearTimeout(t.removeTimeout),clearTimeout(t.showTimeout),clearTimeout(t.restTimeout),t.addToDom(),t.restCallback(),setTimeout(function(){t.ui.el.style.opacity=1},0),t.showTimeout=setTimeout(function(){t.trigger("shown",t.instance),typeof i=="function"&&i.call(this)},t.options.fadeTime)),t};qr.prototype.hide=function(i){var t=this;if(t.options.dataOnly)return t;if(t.ui.el.style.opacity=t.options.restOpacity,clearTimeout(t.removeTimeout),clearTimeout(t.showTimeout),clearTimeout(t.restTimeout),t.removeTimeout=setTimeout(function(){var e=t.options.mode==="dynamic"?"none":"block";t.ui.el.style.display=e,typeof i=="function"&&i.call(t),t.trigger("hidden",t.instance)},t.options.fadeTime),t.options.restJoystick){let e=t.options.restJoystick,r={};r.x=e===!0||e.x!==!1?0:t.instance.frontPosition.x,r.y=e===!0||e.y!==!1?0:t.instance.frontPosition.y,t.setPosition(i,r)}return t};qr.prototype.setPosition=function(i,t){var e=this;e.frontPosition={x:t.x,y:t.y};var r=e.options.fadeTime+"ms",n={};n.front=wg("transition",["top","left"],r);var o={front:{}};o.front={left:e.frontPosition.x+"px",top:e.frontPosition.y+"px"},e.applyStyles(n),e.applyStyles(o),e.restTimeout=setTimeout(function(){typeof i=="function"&&i.call(e),e.restCallback()},e.options.fadeTime)};qr.prototype.restCallback=function(){var i=this,t={};t.front=wg("transition","none",""),i.applyStyles(t),i.trigger("rested",i.instance)};qr.prototype.resetDirection=function(){this.direction={x:!1,y:!1,angle:!1}};qr.prototype.computeDirection=function(i){var t=i.angle.radian,e=Math.PI/4,r=Math.PI/2,n,o,a;if(t>e&&t<e*3&&!i.lockX?n="up":t>-e&&t<=e&&!i.lockY?n="left":t>-e*3&&t<=-e&&!i.lockX?n="down":i.lockY||(n="right"),i.lockY||(t>-r&&t<r?o="left":o="right"),i.lockX||(t>0?a="up":a="down"),i.force>this.options.threshold){var s={},l;for(l in this.direction)Object.prototype.hasOwnProperty.call(this.direction,l)&&(s[l]=this.direction[l]);var c={};this.direction={x:o,y:a,angle:n},i.direction=this.direction;for(l in s)s[l]===this.direction[l]&&(c[l]=!0);if(c.x&&c.y&&c.angle)return i;(!c.x||!c.y)&&this.trigger("plain",i),c.x||this.trigger("plain:"+o,i),c.y||this.trigger("plain:"+a,i),c.angle||this.trigger("dir dir:"+n,i)}else this.resetDirection();return i};var AI=qr;function Lr(i,t){var e=this;e.nipples=[],e.idles=[],e.actives=[],e.ids=[],e.pressureIntervals={},e.manager=i,e.id=Lr.id,Lr.id+=1,e.defaults={zone:document.body,multitouch:!1,maxNumberOfNipples:10,mode:"dynamic",position:{top:0,left:0},catchDistance:200,size:100,threshold:.1,color:"white",fadeTime:250,dataOnly:!1,restJoystick:!0,restOpacity:1,lockX:!1,lockY:!1,shape:"circle",dynamicPage:!1,follow:!1},e.config(t),(e.options.mode==="static"||e.options.mode==="semi")&&(e.options.multitouch=!1),e.options.multitouch||(e.options.maxNumberOfNipples=1);let r=getComputedStyle(e.options.zone.parentElement);return r&&r.display==="flex"&&(e.parentIsFlex=!0),e.updateBox(),e.prepareNipples(),e.bindings(),e.begin(),e.nipples}Lr.prototype=new Rd;Lr.constructor=Lr;Lr.id=0;Lr.prototype.prepareNipples=function(){var i=this,t=i.nipples;t.on=i.on.bind(i),t.off=i.off.bind(i),t.options=i.options,t.destroy=i.destroy.bind(i),t.ids=i.ids,t.id=i.id,t.processOnMove=i.processOnMove.bind(i),t.processOnEnd=i.processOnEnd.bind(i),t.get=function(e){if(e===void 0)return t[0];for(var r=0,n=t.length;r<n;r+=1)if(t[r].identifier===e)return t[r];return!1}};Lr.prototype.bindings=function(){var i=this;i.bindEvt(i.options.zone,"start"),i.options.zone.style.touchAction="none",i.options.zone.style.msTouchAction="none"};Lr.prototype.begin=function(){var i=this,t=i.options;if(t.mode==="static"){var e=i.createNipple(t.position,i.manager.getIdentifier());e.add(),i.idles.push(e)}};Lr.prototype.createNipple=function(i,t){var e=this,r=e.manager.scroll,n={},o=e.options,a={x:e.parentIsFlex?r.x:r.x+e.box.left,y:e.parentIsFlex?r.y:r.y+e.box.top};if(i.x&&i.y)n={x:i.x-a.x,y:i.y-a.y};else if(i.top||i.right||i.bottom||i.left){var s=document.createElement("DIV");s.style.display="hidden",s.style.top=i.top,s.style.right=i.right,s.style.bottom=i.bottom,s.style.left=i.left,s.style.position="absolute",o.zone.appendChild(s);var l=s.getBoundingClientRect();o.zone.removeChild(s),n=i,i={x:l.left+r.x,y:l.top+r.y}}var c=new AI(e,{color:o.color,size:o.size,threshold:o.threshold,fadeTime:o.fadeTime,dataOnly:o.dataOnly,restJoystick:o.restJoystick,restOpacity:o.restOpacity,mode:o.mode,identifier:t,position:i,zone:o.zone,frontPosition:{x:0,y:0},shape:o.shape});return o.dataOnly||(Sg(c.ui.el,n),Sg(c.ui.front,c.frontPosition)),e.nipples.push(c),e.trigger("added "+c.identifier+":added",c),e.manager.trigger("added "+c.identifier+":added",c),e.bindNipple(c),c};Lr.prototype.updateBox=function(){var i=this;i.box=i.options.zone.getBoundingClientRect()};Lr.prototype.bindNipple=function(i){var t=this,e,r=function(n,o){e=n.type+" "+o.id+":"+n.type,t.trigger(e,o)};i.on("destroyed",t.onDestroyed.bind(t)),i.on("shown hidden rested dir plain",r),i.on("dir:up dir:right dir:down dir:left",r),i.on("plain:up plain:right plain:down plain:left",r)};Lr.prototype.pressureFn=function(i,t,e){var r=this,n=0;clearInterval(r.pressureIntervals[e]),r.pressureIntervals[e]=setInterval(function(){var o=i.force||i.pressure||i.webkitForce||0;o!==n&&(t.trigger("pressure",o),r.trigger("pressure "+t.identifier+":pressure",o),n=o)}.bind(r),100)};Lr.prototype.onstart=function(i){var t=this,e=t.options,r=i;i=xg(i),t.updateBox();var n=function(o){t.actives.length<e.maxNumberOfNipples?t.processOnStart(o):r.type.match(/^touch/)&&(Object.keys(t.manager.ids).forEach(function(a){if(Object.values(r.touches).findIndex(function(l){return l.identifier===a})<0){var s=[i[0]];s.identifier=a,t.processOnEnd(s)}}),t.actives.length<e.maxNumberOfNipples&&t.processOnStart(o))};return sh(i,n),t.manager.bindDocument(),!1};Lr.prototype.processOnStart=function(i){var t=this,e=t.options,r,n=t.manager.getIdentifier(i),o=i.force||i.pressure||i.webkitForce||0,a={x:i.pageX,y:i.pageY},s=t.getOrCreate(n,a);s.identifier!==n&&t.manager.removeIdentifier(s.identifier),s.identifier=n;var l=function(d){d.trigger("start",d),t.trigger("start "+d.id+":start",d),d.show(),o>0&&t.pressureFn(i,d,d.identifier),t.processOnMove(i)};if((r=t.idles.indexOf(s))>=0&&t.idles.splice(r,1),t.actives.push(s),t.ids.push(s.identifier),e.mode!=="semi")l(s);else{var c=ah(a,s.position);if(c<=e.catchDistance)l(s);else{s.destroy(),t.processOnStart(i);return}}return s};Lr.prototype.getOrCreate=function(i,t){var e=this,r=e.options,n;return/(semi|static)/.test(r.mode)?(n=e.idles[0],n?(e.idles.splice(0,1),n):r.mode==="semi"?e.createNipple(t,i):(console.warn("Coudln't find the needed nipple."),!1)):(n=e.createNipple(t,i),n)};Lr.prototype.processOnMove=function(i){var t=this,e=t.options,r=t.manager.getIdentifier(i),n=t.nipples.get(r),o=t.manager.scroll;if(!fI(i)){this.processOnEnd(i);return}if(!n){console.error("Found zombie joystick with ID "+r),t.manager.removeIdentifier(r);return}if(e.dynamicPage){var a=n.el.getBoundingClientRect();n.position={x:o.x+a.left,y:o.y+a.top}}n.identifier=r;var s=n.options.size/2,l={x:i.pageX,y:i.pageY};e.lockX&&(l.y=n.position.y),e.lockY&&(l.x=n.position.x);var c=ah(l,n.position),d=pI(l,n.position),u=bg(d),p=c/s,h={distance:c,position:l},f,m;if(n.options.shape==="circle"?(f=Math.min(c,s),m=hI(n.position,f,d)):(m=bI(l,n.position,s),f=ah(m,n.position)),e.follow){if(c>s){let b=l.x-m.x,S=l.y-m.y;n.position.x+=b,n.position.y+=S,n.el.style.top=n.position.y-(t.box.top+o.y)+"px",n.el.style.left=n.position.x-(t.box.left+o.x)+"px",c=ah(l,n.position)}}else l=m,c=f;var y=l.x-n.position.x,g=l.y-n.position.y;n.frontPosition={x:y,y:g},e.dataOnly||Sg(n.ui.front,n.frontPosition);var v={identifier:n.identifier,position:l,force:p,pressure:i.force||i.pressure||i.webkitForce||0,distance:c,angle:{radian:u,degree:d},vector:{x:y/s,y:-g/s},raw:h,instance:n,lockX:e.lockX,lockY:e.lockY};v=n.computeDirection(v),v.angle={radian:bg(180-d),degree:180-d},n.trigger("move",v),t.trigger("move "+n.id+":move",v)};Lr.prototype.processOnEnd=function(i){var t=this,e=t.options,r=t.manager.getIdentifier(i),n=t.nipples.get(r),o=t.manager.removeIdentifier(n.identifier);!n||(e.dataOnly||n.hide(function(){e.mode==="dynamic"&&(n.trigger("removed",n),t.trigger("removed "+n.id+":removed",n),t.manager.trigger("removed "+n.id+":removed",n),n.destroy())}),clearInterval(t.pressureIntervals[n.identifier]),n.resetDirection(),n.trigger("end",n),t.trigger("end "+n.id+":end",n),t.ids.indexOf(n.identifier)>=0&&t.ids.splice(t.ids.indexOf(n.identifier),1),t.actives.indexOf(n)>=0&&t.actives.splice(t.actives.indexOf(n),1),/(semi|static)/.test(e.mode)?t.idles.push(n):t.nipples.indexOf(n)>=0&&t.nipples.splice(t.nipples.indexOf(n),1),t.manager.unbindDocument(),/(semi|static)/.test(e.mode)&&(t.manager.ids[o.id]=o.identifier))};Lr.prototype.onDestroyed=function(i,t){var e=this;e.nipples.indexOf(t)>=0&&e.nipples.splice(e.nipples.indexOf(t),1),e.actives.indexOf(t)>=0&&e.actives.splice(e.actives.indexOf(t),1),e.idles.indexOf(t)>=0&&e.idles.splice(e.idles.indexOf(t),1),e.ids.indexOf(t.identifier)>=0&&e.ids.splice(e.ids.indexOf(t.identifier),1),e.manager.removeIdentifier(t.identifier),e.manager.unbindDocument()};Lr.prototype.destroy=function(){var i=this;i.unbindEvt(i.options.zone,"start"),i.nipples.forEach(function(e){e.destroy()});for(var t in i.pressureIntervals)Object.prototype.hasOwnProperty.call(i.pressureIntervals,t)&&clearInterval(i.pressureIntervals[t]);i.trigger("destroyed",i.nipples),i.manager.unbindDocument(),i.off(),i.pressureIntervals={},i.nipples=[],i.idles=[],i.actives=[],i.ids=[],i.manager=null};var CI=Lr;function Vr(i){var t=this;t.ids={},t.index=0,t.collections=[],t.scroll=o1(),t._windowBound=!1,t.config(i),t.prepareCollections();var e=function(){var r;t.collections.forEach(function(n){n.forEach(function(o){r=o.el.getBoundingClientRect(),o.position={x:t.scroll.x+r.left,y:t.scroll.y+r.top}})})};return t._onResize=function(){mI(e)},t._onScroll=function(){t.scroll=o1()},t.collections}Vr.prototype=new Rd;Vr.constructor=Vr;Vr.prototype.prepareCollections=function(){var i=this;i.collections.create=i.create.bind(i),i.collections.on=i.on.bind(i),i.collections.off=i.off.bind(i),i.collections.destroy=i.destroy.bind(i),i.collections.get=function(t){var e;return i.collections.every(function(r){return e=r.get(t),!e}),e}};Vr.prototype.create=function(i){return this.createCollection(i)};Vr.prototype.bindWindowEvents=function(){var i=this;i._windowBound||typeof window>"u"||(i._windowBound=!0,Od(window,"resize",i._onResize),Od(window,"scroll",i._onScroll))};Vr.prototype.unbindWindowEvents=function(){var i=this;!i._windowBound||typeof window>"u"||(i._windowBound=!1,Id(window,"resize",i._onResize),Id(window,"scroll",i._onScroll))};Vr.prototype.createCollection=function(i){var t=this,e=new CI(t,i);return t.bindCollection(e),t.collections.push(e),t.bindWindowEvents(),e};Vr.prototype.bindCollection=function(i){var t=this,e,r=function(n,o){e=n.type+" "+o.id+":"+n.type,t.trigger(e,o)};i.on("destroyed",t.onDestroyed.bind(t)),i.on("shown hidden rested dir plain",r),i.on("dir:up dir:right dir:down dir:left",r),i.on("plain:up plain:right plain:down plain:left",r)};Vr.prototype.bindDocument=function(){var i=this;i.binded||(i.bindEvt(document,"move").bindEvt(document,"end"),i.binded=!0)};Vr.prototype.unbindDocument=function(i){var t=this;(!Object.keys(t.ids).length||i===!0)&&(t.unbindEvt(document,"move").unbindEvt(document,"end"),t.binded=!1)};Vr.prototype.getIdentifier=function(i){var t;return i?(t=i.identifier===void 0?i.pointerId:i.identifier,t===void 0&&(t=this.latest||0)):t=this.index,this.ids[t]===void 0&&(this.ids[t]=this.index,this.index+=1),this.latest=t,this.ids[t]};Vr.prototype.removeIdentifier=function(i){var t={};for(var e in this.ids)if(this.ids[e]===i){t.id=e,t.identifier=this.ids[e],delete this.ids[e];break}return t};Vr.prototype.onmove=function(i){var t=this;return t.onAny("move",i),!1};Vr.prototype.onend=function(i){var t=this;return t.onAny("end",i),!1};Vr.prototype.oncancel=function(i){var t=this;return t.onAny("end",i),!1};Vr.prototype.onAny=function(i,t){var e=this,r,n="processOn"+i.charAt(0).toUpperCase()+i.slice(1);t=xg(t);var o=function(s,l,c){c.ids.indexOf(l)>=0&&(c[n](s),s._found_=!0)},a=function(s){r=e.getIdentifier(s),sh(e.collections,o.bind(null,s,r)),s._found_||e.removeIdentifier(r)};return sh(t,a),!1};Vr.prototype.destroy=function(){var i=this;i.unbindDocument(!0),i.unbindWindowEvents(),i.ids={},i.index=0,i.collections.forEach(function(t){t.destroy()}),i.collections=[],i.off()};Vr.prototype.onDestroyed=function(i,t){var e=this;if(e.collections.indexOf(t)<0)return!1;e.collections.splice(e.collections.indexOf(t),1),e.collections.length===0&&e.unbindWindowEvents()};var EI=Vr;var Bd=null;function TI(){return Bd||(Bd=new EI),Bd}var bG={create:function(i){return TI().create(i)},destroy:function(){Bd&&(Bd.destroy(),Bd=null)},get factory(){return TI()}},PI=bG;var ne=require("three");var St=require("three");var pn=require("three");var Eg=new pn.Vector3,Ui=new pn.Camera,a1=class extends pn.LineSegments{constructor(e){let r=new pn.BufferGeometry,n=new pn.LineBasicMaterial({color:16777215,vertexColors:!0,toneMapped:!1}),o=[],a=[],s={},l=new pn.Color(15711266),c=new pn.Color(15711266),d=new pn.Color(2857471);u("n1","n2",l),u("n2","n4",l),u("n4","n3",l),u("n3","n1",l),u("f1","f2",l),u("f2","f4",l),u("f4","f3",l),u("f3","f1",l),u("n1","f1",l),u("n2","f2",l),u("n3","f3",l),u("n4","f4",l),u("p","n1",c),u("p","n2",c),u("p","n3",c),u("p","n4",c),u("u1","u2",d),u("u2","u3",d),u("u3","u1",d);function u(h,f,m){p(h,m),p(f,m)}function p(h,f){o.push(0,0,0),a.push(f.r,f.g,f.b),s[h]===void 0&&(s[h]=[]),s[h].push(o.length/3-1)}r.setAttribute("position",new pn.Float32BufferAttribute(o,3)),r.setAttribute("color",new pn.Float32BufferAttribute(a,3));super(r,n);this.type="CameraHelper",this.camera=e,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=s,this.update()}update(){let e=this.geometry,r=this.pointMap,n=!0;Ui.projectionMatrixInverse.elements=[.5112609807824982,-0,-0,-0,-0,.41421356237309503,-0,-0,-0,-0,-0,-.099999,-0,-0,-1.0000000000000002,.100001];let o=1,a=1,s=n?.8:1e-4;yo("n1",r,e,Ui,-o,-a,s),yo("n2",r,e,Ui,o,-a,s),yo("n3",r,e,Ui,-o,a,s),yo("n4",r,e,Ui,o,a,s);let l=s;yo("f1",r,e,Ui,-o,-a,l),yo("f2",r,e,Ui,o,-a,l),yo("f3",r,e,Ui,-o,a,l),yo("f4",r,e,Ui,o,a,l);let c=l,d=.5;yo("u1",r,e,Ui,o*.7*d,a*1.1,c),yo("u2",r,e,Ui,-o*.7*d,a*1.1,c),yo("u3",r,e,Ui,0,a*(1.1+.9*d),c),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};function yo(i,t,e,r,n,o,a){Eg.set(n,o,a).unproject(r);let s=t[i];if(s!==void 0){let l=e.getAttribute("position");for(let c=0,d=s.length;c<d;c++)l.setXYZ(s[c],Eg.x,Eg.y,Eg.z)}}var Tg=class extends jo(a1){constructor(e){super(e);this.object=e;this.name=`CombinedCameraHelper: ${e.uuid}`}updateMatrixWorld(e){super.updateMatrixWorld(e),this.updateTarget()}updateTarget(){let e=this.object.getTarget();this.updateWorldMatrix(!0,!1),this.worldToLocal(e)}raycast(e,r){Ho(this.object,this.geometry,e,r,!0)}};var Pg=790;function MI(i){return 1-Math.pow(1-i,3)}var Nd=new St.Vector3,s1=new St.Vector3,l1=new St.Quaternion,c1=new St.Vector3,dh=new St.Vector3,d1=new St.Vector3,$o=class extends ki(St.Camera,Tg){constructor(e="",r={...ml.defaultData,name:""}){super();this._cameraType="OrthographicCamera";this.targetOffset=io.DefaultTargetOffset;this.isUpVectorFlipped=!1;this.angleOffsetFromUp=0;this.wasMovedByUser=!1;this.wasMovedBySwitchCameraAction=!1;this._createdAt=typeof performance<"u"?performance.now():0;this._tickProjectionTransition=()=>{let e=this._projectionTransition;if(e===void 0)return;if(this.disposed){this._endProjectionTransition();return}e.raf=requestAnimationFrame(this._tickProjectionTransition);let r=$o.projectionTransitionRequestRender??e.requestRender;this.updateProjectionMatrix(),r?.()};this.super_Entity(e,r),this.previousProjectionMatrix=new St.Matrix4,this.matrixAutoUpdate=!0,this.width=window.innerWidth,this.height=window.innerHeight;let n=this.width,o=this.height;this.orthoCamera=new St.OrthographicCamera(n*-.5,n*.5,o*.5,o*-.5,-5e4,1e4),this.perspCamera=new St.PerspectiveCamera(45,n/o,50,1e4),this.left=this.orthoCamera.left,this.right=this.orthoCamera.right,this.top=this.orthoCamera.top,this.bottom=this.orthoCamera.bottom,this.far=this.orthoCamera.far,this.view=this.orthoCamera.view,this.aspect=this.perspCamera.aspect,this.focus=this.perspCamera.focus,this.filmGauge=this.perspCamera.filmGauge,this.filmOffset=this.perspCamera.filmOffset,this.objectHelper.update()}static withoutProjectionTransition(e){let r=$o.projectionTransitionsEnabled;$o.projectionTransitionsEnabled=!1;try{return e()}finally{$o.projectionTransitionsEnabled=r}}get isPerspectiveCamera(){return this.cameraType==="PerspectiveCamera"}get isOrthographicCamera(){return!this.isPerspectiveCamera}get cameraType(){return this._cameraType}set fov(e){this.perspCamera.fov=e}get fov(){return this.perspCamera.fov}setNear(e,r){e==="PerspectiveCamera"?this.perspCamera.near=r:this.orthoCamera.near=r}setZoom(e,r){r>=0&&(e==="PerspectiveCamera"?this.perspCamera.zoom=r:this.orthoCamera.zoom=r)}set cameraType(e){e==="PerspectiveCamera"?this.toPerspective():e==="OrthographicCamera"&&this.toOrthographic()}get near(){return this._cameraType==="PerspectiveCamera"?this.perspCamera.near:this.orthoCamera.near}set near(e){this._cameraType==="PerspectiveCamera"?this.perspCamera.near=e:this.orthoCamera.near=e}get zoom(){return this._cameraType==="PerspectiveCamera"?this.perspCamera.zoom:this.orthoCamera.zoom}set zoom(e){e>=0&&(this._cameraType==="PerspectiveCamera"?this.perspCamera.zoom=e:this.orthoCamera.zoom=e)}lookAt(e,r,n){typeof e=="number"&&(e=new St.Vector3(e,r,n)),super.lookAt(e),this.getWorldPosition(Nd),this.targetOffset=Nd.distanceTo(e)}getTarget(e=new St.Vector3){return this.getWorldDirection(s1),this.getWorldPosition(Nd),s1.multiplyScalar(this.targetOffset),e.copy(Nd).add(s1),e}getDistanceToTarget(){let e=this.getTarget();return this.getWorldPosition(Nd),Nd.distanceTo(e)}updateUp(){this.getWorldQuaternion(l1),c1.set(0,0,1).applyQuaternion(l1),dh.copy(St.Object3D.DEFAULT_UP),this.isUpVectorFlipped&&dh.negate(),dh.applyQuaternion(l1),d1.copy(St.Object3D.DEFAULT_UP).projectOnPlane(c1),this.angleOffsetFromUp=d1.angleTo(dh),this.angleOffsetFromUp*=d1.cross(dh).dot(c1)>=0?1:-1}updateTransformState(e,r){let n=super.updateTransformState(e,r);return e.isUpVectorFlipped!==void 0&&(this.isUpVectorFlipped=e.isUpVectorFlipped),this.updateUp(),n}getViewFrontToObject(e){let r=e.getWorldPosition(new St.Vector3),o=e.getWorldDirection(new St.Vector3).multiplyScalar(this.targetOffset);return{position:r.clone().add(o),target:r}}getViewToTarget(e){let n=this.getWorldDirection(new St.Vector3).multiplyScalar(this.targetOffset);return{position:e.clone().sub(n),target:e}}getViewToObject(e){let r=new St.Vector3;return e.getWorldPosition(r),this.getViewToTarget(r)}setViewplaneSize(e,r,n=!1){if(this.aspect=e/r,n){let o=e>r?this.aspect:1,a=e>r?1:this.aspect;this.left=-Pg*.5*o,this.right=Pg*.5*o,this.top=Pg*.5*(1/a),this.bottom=-Pg*.5*(1/a)}else this.left=-e*.5,this.right=e*.5,this.top=r*.5,this.bottom=-r*.5;this.updateProjectionMatrix()}copyViewPlaneSize(e){this.aspect=e.aspect,this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.updateProjectionMatrix()}toOrthographic(){this.orthoCamera.left=this.left,this.orthoCamera.right=this.right,this.orthoCamera.top=this.top,this.orthoCamera.bottom=this.bottom,this.orthoCamera.view=this.view,this.orthoCamera.far=this.far,this.orthoCamera.updateProjectionMatrix(),this.projectionMatrix=this.orthoCamera.projectionMatrix,this.projectionMatrixInverse=this.orthoCamera.projectionMatrixInverse,this._cameraType="OrthographicCamera",this._applyProjectionTransition(),this.objectHelper&&this.objectHelper.update()}toPerspective(){this.perspCamera.aspect=this.aspect,this.perspCamera.fov=this.fov,this.perspCamera.view=this.view,this.perspCamera.far=this.far,this.perspCamera.updateProjectionMatrix(),this.projectionMatrix=this.perspCamera.projectionMatrix,this.projectionMatrixInverse=this.perspCamera.projectionMatrixInverse,this._cameraType="PerspectiveCamera",this._applyProjectionTransition(),this.objectHelper&&this.objectHelper.update()}get isProjectionTransitioning(){return this._projectionTransition!==void 0}get projectionTransitionProgress(){let e=this._projectionTransition;if(e===void 0)return 1;let r=(performance.now()-e.start)/e.duration;return r>=1?1:r<=0?0:MI(r)}get _activeSubCamera(){return this._cameraType==="PerspectiveCamera"?this.perspCamera:this.orthoCamera}_canAnimateProjection(){return $o.projectionTransitionsEnabled&&typeof requestAnimationFrame=="function"&&typeof performance<"u"&&performance.now()-this._createdAt>=$o.projectionTransitionMinAgeMs}_beginProjectionTransition(e){let r=this._projectionTransition;r===void 0&&(r={from:new St.Matrix4,blend:new St.Matrix4,blendInverse:new St.Matrix4,start:0,duration:$o.projectionTransitionDuration,referenceDepth:1,raf:0,requestRender:e},this._projectionTransition=r),r.from.copy(this.projectionMatrix),r.start=performance.now(),r.duration=$o.projectionTransitionDuration,r.referenceDepth=Number.isFinite(this.targetOffset)?Math.max(1,this.targetOffset):1,e&&(r.requestRender=e),r.raf!==0&&cancelAnimationFrame(r.raf),r.raf=requestAnimationFrame(this._tickProjectionTransition)}_applyProjectionTransition(){let e=this._projectionTransition;if(e===void 0)return;let r=(performance.now()-e.start)/e.duration;if(r>=1){this._endProjectionTransition();return}let n=MI(r),o=e.from.elements,a=this._activeSubCamera.projectionMatrix.elements,s=e.blend.elements,l=e.referenceDepth,c=Math.max(1e-6,o[15]-o[11]*l),d=Math.max(1e-6,a[15]-a[11]*l),u=n*c/(n*c+(1-n)*d);for(let p=0;p<16;p++)s[p]=o[p]+(a[p]-o[p])*u;e.blendInverse.copy(e.blend).invert(),this.projectionMatrix=e.blend,this.projectionMatrixInverse=e.blendInverse}_endProjectionTransition(){let e=this._projectionTransition;if(e===void 0)return;e.raf!==0&&cancelAnimationFrame(e.raf),this._projectionTransition=void 0;let r=this._activeSubCamera;this.projectionMatrix=r.projectionMatrix,this.projectionMatrixInverse=r.projectionMatrixInverse}_syncProjectionTransition(e){let r=e._projectionTransition;if(r===void 0){this._projectionTransition!==void 0&&this._endProjectionTransition();return}let n=this._projectionTransition;n===void 0?(n={from:new St.Matrix4,blend:new St.Matrix4,blendInverse:new St.Matrix4,start:0,duration:1,referenceDepth:1,raf:0,requestRender:void 0},this._projectionTransition=n):n.raf!==0&&(cancelAnimationFrame(n.raf),n.raf=0),n.requestRender=void 0,n.from.copy(r.from),n.start=r.start,n.duration=r.duration,n.referenceDepth=r.referenceDepth,this._applyProjectionTransition()}setFocalLength(e){this.perspCamera.setFocalLength(e),this.toPerspective()}getFocalLength(){return this.perspCamera.getFocalLength()}getEffectiveFOV(){return this.perspCamera.getEffectiveFOV()}getFilmWidth(){return this.perspCamera.getFilmWidth()}getFilmHeight(){return this.perspCamera.getFilmHeight()}setViewOffset(e,r,n,o,a,s){this._cameraType==="PerspectiveCamera"?this.perspCamera.setViewOffset(e,r,n,o,a,s):this.orthoCamera.setViewOffset(e,r,n,o,a,s),this._applyProjectionTransition()}clearViewOffset(){this._cameraType==="PerspectiveCamera"?(this.perspCamera.clearViewOffset(),this.toPerspective()):(this.orthoCamera.clearViewOffset(),this.toOrthographic())}copyHistory(){this.previousProjectionMatrix&&this.previousProjectionMatrix.copy(this.projectionMatrix)}updateProjectionMatrix(){this._cameraType==="PerspectiveCamera"?this.toPerspective():this._cameraType==="OrthographicCamera"&&this.toOrthographic()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,r){super.updateWorldMatrix(e,r),this.matrixWorldInverse.copy(this.matrixWorld).invert()}copy(e,r){return super.copy(e,r),this.parent=e.parent,this.orthoCamera.copy(e.orthoCamera),this.perspCamera.copy(e.perspCamera),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.far=e.far,this.view=e.view===null?null:Object.assign({},e.view),this._cameraType=e._cameraType,this.aspect=e.aspect,this.fov=e.fov,this.focus=e.focus,this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this.targetOffset=io.sanitizeTargetOffset(e.targetOffset),this.updateProjectionMatrix(),this._syncProjectionTransition(e),this}toCameraState(e=[]){let r={type:this.cameraType,far:this.far,orthographic:{near:this.orthoCamera.near,zoom:this.orthoCamera.zoom},perspective:{near:this.perspCamera.near,fov:this.perspCamera.fov,zoom:this.perspCamera.zoom},up:this.up.toArray(),targetOffset:this.targetOffset,isUpVectorFlipped:this.isUpVectorFlipped};return wp(r,e)}updateCameraSubtype(e,r){let n=e==="perspective"?"PerspectiveCamera":"OrthographicCamera";r.zoom!==void 0&&this.setZoom(n,r.zoom),r.near!==void 0&&this.setNear(n,r.near),r.fov!==void 0&&n==="PerspectiveCamera"&&(this.fov=r.fov)}updateState(e,r){this.updateCameraState(e,r)}updateCameraState(e,r){this.updateState_Entity(e,r),e.far!==void 0&&(this.far=e.far),e.orthographic!==void 0&&this.updateCameraSubtype("orthographic",e.orthographic),e.perspective!==void 0&&this.updateCameraSubtype("perspective",e.perspective),e.type!==void 0&&(e.type!==this._cameraType&&this._canAnimateProjection()&&this._beginProjectionTransition(r?.shared.requestRender),this.cameraType=e.type),e.up!==void 0&&this.up.fromArray(e.up.map(n=>typeof n=="number"?n:0)),e.targetOffset!==void 0&&(this.targetOffset=io.sanitizeTargetOffset(e.targetOffset)),e.isUpVectorFlipped!==void 0&&(this.isUpVectorFlipped=e.isUpVectorFlipped),this.updateProjectionMatrix()}updateByPatchedOp(e,r,n){super.updateByPatchedOp(e,r,n),e.path.length===1&&e.type===0&&this.updateCameraSubtype(e.path[0],e.props)}toState(e){return{...super.toState(e),...this.toCameraState(e),type:this.cameraType}}},wt=$o;wt.projectionTransitionsEnabled=!1,wt.projectionTransitionDuration=350,wt.projectionTransitionMinAgeMs=1e3;var wG=null;function OI(i){wG=i}var AG,II=new Promise(i=>{AG=i});var Xr=require("three");var Ld=require("three");function CG(i){let t=i.elements,e=t[0]**2+t[1]**2+t[2]**2,r=t[4]**2+t[5]**2+t[6]**2,n=t[8]**2+t[9]**2+t[10]**2,o=t[0]**2+t[4]**2+t[8]**2,a=t[1]**2+t[5]**2+t[9]**2,s=t[2]**2+t[6]**2+t[10]**2,l=1e-8;return e<l||r<l||n<l||o<l||a<l||s<l}function Mg(i,t){let e=new Ld.BufferGeometry;if(t&&CG(t))return e.setAttribute("position",new Ld.Float32BufferAttribute([],3)),e.setIndex([]),e;if(!i.getAttribute("position"))return e.setAttribute("position",new Ld.Float32BufferAttribute([],3)),e.setIndex([]),e;let{positions:r,triIndices:n}=Hp(i.getAttribute("position"),i.getIndex());return e.setAttribute("position",new Ld.Float32BufferAttribute(r,3)),e.setIndex(n),t&&e.applyMatrix4(t),e}var EG=require("three/examples/jsm/utils/BufferGeometryUtils.js");var TG;II.then(i=>TG=i);var Dse=new Xr.Vector3,Rse=new Xr.Quaternion,Bse=new Xr.Vector3,Nse=new Xr.Euler(0,0,0,"YXZ"),Lse=new Xr.Euler(0,0,0,"XYZ"),_se=new Xr.Vector3,Fse=new Xr.Vector3,kse=new Xr.Vector3(1,1,1),Vse=new Xr.Quaternion,Gse=new Xr.Matrix4,Use=new Xr.Matrix4;var zse=new Xr.Quaternion,jse=new Xr.Sphere;var u1={type:"beginEvent",eventName:"Collision"};var p1=i=>i.states.some(t=>t.data.position!==void 0||t.data.rotation!==void 0||t.data.hiddenMatrix!==void 0||t.data.cloner!==void 0||t.data.pathSnapping!==void 0);var GI=require("three");gt();var DI=4,h1=8;var f1=.02,m1=.3,PG=65,RI=new ne.Vector3,BI=new ne.Vector3,MG=new ne.Vector3,En=new ne.Vector3,Va=new ne.Vector3,_d=new ne.Vector3,y1=new ne.Matrix4,NI=new ne.Matrix4,OG=new ne.Matrix4,fi=new ne.Quaternion,Ul=new ne.Quaternion,Fd=new ne.Euler(0,0,0,"YXZ"),IG=new ne.Vector3(1,0,0),ea=new ne.Vector3(0,1,0),DG=new ne.Vector3(0,0,1),LI=new ne.Vector3(1,1,1),g1=[],_I=i=>g1[i]??(g1[i]=new ne.Vector3),v1=new ne.Vector3,RG=new ne.Vector3,BG=new ne.Vector3,NG=new ne.Vector3,FI=new ne.Quaternion,LG=new ne.Vector3,kI=new ne.Quaternion,_G=1,FG=.025,kG=16e-6,VI=12,VG=20,rn=new ne.Line3,zi=new ne.Box3,GG={type:"requestRender"},UG={type:"updateMatrix"},Og=class extends ne.EventDispatcher{constructor(e,r,n,o,a,s,l,c,d){super();this.object=e;this.domElement=r;this.data=n;this.gloabalPhysics=o;this.controlsManager=a;this.cameraFollow=s;this.camera=l;this.page=c;this.sharedAssets=d;this.enableDamping=!0;this.hiddenMatrix0=new ne.Matrix4;this.target0=new ne.Vector3;this.zoom0=1;this.rotForce=1;this.moveForce=1;this.pixelsPerMeter=dI;this.euler0=new ne.Euler(0,0,0,"YXZ");this.position0Cam=new ne.Vector3;this.quat0Cam=new ne.Quaternion;this.scale0Cam=new ne.Vector3;this.hiddenMatrix0Cam=new ne.Matrix4;this.threshEndTranslate=.01;this.threshEndRotate=1e-8;this.threshEndRotVel=.005;this.collider={type:"capsule",radius:40,segment:new ne.Line3(new ne.Vector3(0,-40,0),new ne.Vector3(0,40,0)),matrix:new ne.Matrix4,position:new ne.Vector3,rotation:new ne.Quaternion};this.euler=new ne.Euler(0,0,0,"YXZ");this.eulerDelta=new ne.Vector3;this.lastPosition=new ne.Vector3;this.lastCameraQuaternion=new ne.Quaternion;this.lastCameraPosition=new ne.Vector3;this.PI_2=Math.PI/2;this.prevMouse=new ne.Vector2;this.velocityTarget=new ne.Vector3;this.velocity=new ne.Vector3;this.directionXZ=new ne.Vector3;this.rotVelocityStick=new ne.Vector3;this.rotVelocityTarget=new ne.Vector3;this.rotVelocity=new ne.Vector3;this.rotDirection=new ne.Vector3;this.nonColliderRotOffset=new ne.Matrix4;this.nonColliderPosOffset=new ne.Matrix4;this.firstPointerId=-1;this.rot=new ne.Vector3;this.path=[];this.movementState={moveNegZ:0,movePosZ:0,moveNegX:0,movePosX:0,moveNegY:0,movePosY:0,rotPosX:0,rotNegX:0,rotPosY:0,rotNegY:0,jump:0,run:0};this.onObject=!1;this.actionState={};this.keyAssignments=[["moveNegZ","W"],["moveNegX","A"],["movePosZ","S"],["movePosX","D"],["rotPosX","ArrowUp"],["rotPosY","ArrowLeft"],["rotNegX","ArrowDown"],["rotNegY","ArrowRight"],["jump"," "]];this.collisionEnabled=!0;this.offsetMatrix=new ne.Matrix4;this.objectToTarget=new ne.Vector3;this.objectToTarget0=new ne.Vector3;this.objectToCamXZ=new ne.Vector3;this.objectToCamXZ0=new ne.Vector3;this.targetToCamera=new ne.Vector3;this.targetToCamera0=new ne.Vector3;this.cameraPolarAxis0=new ne.Vector3;this.targetPos=new ne.Vector3;this.targetQuat=new ne.Quaternion;this.lerpFactorPos=new ne.Vector3().setScalar(.3);this.lerpFactorPosStart=.3;this.lerpFactorPosEnd=.3;this.lerpFactorRotStart=.3;this.lerpFactorRotEnd=.3;this.lerpFactorPosCamera=.3;this.lerpFactorRotCamera=.3;this.objXZQuat=new ne.Quaternion;this.objXZQuatInv=new ne.Quaternion;this.objXZRotMat=new ne.Matrix4;this.isFirstPerson=!1;this.didHit=!1;this.groundVelocity=new ne.Vector3;this.pushedVelocity=new ne.Vector3;this.groundYRotation=0;this.objectRealQuat=new ne.Quaternion;this.colliderWorldQuat=new ne.Quaternion;this.groundNormal=new ne.Vector3;this.groundTilt=new ne.Quaternion;this.groundTiltInv=new ne.Quaternion;this.lastHitObj=null;this.isFirstFrame=!0;this.rotationAccumWhenOrientWithCamera=0;this.navMeshPathDest=null;this.position=new ne.Vector3;this.quaternion=new ne.Quaternion;this.scale=new ne.Vector3;this.initialAction=!0;this.onPointerDown=e=>{!(e.target===this.domElement||e.target instanceof HTMLElement&&e.target.tagName==="SPLINE-VIEWER"&&e.target.shadowRoot?.contains(this.domElement))||this.firstPointerId!==-1||(this.firstPointerId=e.pointerId,this.domElement.ownerDocument.addEventListener("pointermove",this.onPointerMove),this.domElement.ownerDocument.addEventListener("pointerup",this.onPointerUp),this.rotBy!=="keys"&&!Xn&&!S0&&this.domElement.requestPointerLock(),this.prevMouse.set(e.clientX,e.clientY))};this.onPointerUp=e=>{this.firstPointerId=-1,this.domElement.ownerDocument.removeEventListener("pointermove",this.onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this.onPointerUp),e.pointerType==="mouse"&&this.domElement.ownerDocument.exitPointerLock()};this.onPointerMove=e=>{if(e.pointerId!==this.firstPointerId)return;let r=e.clientX-this.prevMouse.x,n=e.clientY-this.prevMouse.y;this.prevMouse.set(e.clientX,e.clientY),e.pointerType==="mouse"&&this.rotBy!=="keys"&&(S0&&MT<15.5&&!Xn?(this.eulerDelta.y=-r*this.mouseOrbitSensitivity,this.eulerDelta.x=-n*this.mouseOrbitSensitivity):(this.eulerDelta.y=-e.movementX*this.mouseOrbitSensitivity,this.eulerDelta.x=-e.movementY*this.mouseOrbitSensitivity)),e.pointerType!=="mouse"&&this.rotByTouch==="drag"&&(this.eulerDelta.y=-r*this.mouseOrbitSensitivity*5,this.eulerDelta.x=-n*this.mouseOrbitSensitivity*5),this.controlsManager.requestRender()};this.onPointerlockChange=e=>{this.domElement.ownerDocument.pointerLockElement===this.domElement?Og.isLocked=!0:Og.isLocked=!1};this.onPointerlockError=()=>{console.error("SPE.GameControls: Unable to use Pointer Lock API")};this.handleVisibilityChange=()=>{if(document?.hidden)for(let e in this.movementState)this.movementState[e]=0};this.onKeyDown=e=>{!(e.target instanceof HTMLInputElement)&&(e.code==="ArrowLeft"||e.code==="ArrowUp"||e.code==="ArrowRight"||e.code==="ArrowDown"||e.code==="Space")&&e.preventDefault();for(let r of this.keyAssignments)if(e.key.toUpperCase()===r[1]||e.key===r[1]){this.movementState[r[0]]=1;break}this.controlsManager.requestRender()};this.onKeyUp=e=>{for(let r of this.keyAssignments)if(e.key.toUpperCase()===r[1]||e.key===r[1]||e.code.slice(3,e.code.length).toUpperCase()===r[1]){this.movementState[r[0]]=0;break}};this.copyVRGamePadValues=(e,r)=>{for(let n=2;n<4;n++){let o=e.axes[n];r===0?n===2?this.movementState.movePosX=o:this.movementState.movePosZ=o:(e.buttons[3].pressed?this.movementState.jump=1:this.movementState.jump=0,n===2?this.movementState.rotPosY=o:this.moveMode==="fly"&&(this.movementState.moveNegY=o))}};this.sharedGameControlGlobals=a.sharedGameControlGlobals,e===l&&(this.isFirstPerson=!0),this.hiddenMatrix0.copy(this.object.hiddenMatrix),this.object.parent?this.object.hiddenMatrix.copy(this.object.parent.matrixWorld).invert():this.object.hiddenMatrix.identity(),this.object.matrix.copy(this.object.matrixWorld),this.object.matrix.decompose(this.position,this.quaternion,this.scale),this.euler0.setFromQuaternion(this.quaternion,"YXZ");let u=this.euler0.clone(),p=u.y;if(this.objectRealQuat.copy(this.quaternion),u.y=0,this.quaternion.setFromEuler(u),this.objXZQuat.copy(this.quaternion),this.objXZQuatInv.copy(this.objXZQuat).invert(),this.objXZRotMat.makeRotationFromQuaternion(this.quaternion),u.set(0,p,0),this.quaternion.setFromEuler(u),this.rot.setFromEuler(u),this.object.matrixAutoUpdate=!1,(this.isFirstPerson||this.cameraFollow===!0)&&(this.target0.copy(this.camera.getTarget()),this.zoom0=this.camera.zoom),this.cameraFollow===!0){this.position0Cam.copy(this.camera.position),this.quat0Cam.copy(this.camera.quaternion),this.scale0Cam.copy(this.camera.scale),this.hiddenMatrix0Cam.copy(this.camera.hiddenMatrix),this.camera.parent?(this.camera.hiddenMatrix.copy(this.camera?.parent.matrixWorld),this.camera.matrix.copy(this.camera.matrixWorld)):this.camera.hiddenMatrix.identity(),this.camera.matrix.copy(this.camera.matrixWorld),this.camera.matrix.decompose(this.camera.position,this.camera.quaternion,this.camera.scale),this.camera.matrixAutoUpdate=!1,this.offsetMatrix.copy(this.object.matrix).invert().multiply(this.camera.matrix);let y=new ne.Vector3(0,0,-1).applyQuaternion(this.camera.quaternion),g=new ne.Vector3().subVectors(this.position,this.camera.position);this.objectToCamXZ.copy(g),this.objectToCamXZ.y=0,this.objectToCamXZ0.copy(this.objectToCamXZ);let v;Math.abs(y.y)<1e-6?(g.y=0,y.y=0,v=g.projectOnVector(y)):g.y/y.y>0?v=y.multiplyScalar(g.y/y.y):v=y.multiplyScalar(g.length()),this.targetToCamera0.copy(v).negate();let b=this.camera.position.clone().add(v);this.objectToTarget0.subVectors(b,this.position);let S=new ne.Euler().setFromQuaternion(this.camera.quaternion,"YXZ");this.cameraPolarOffset=-S.x,S.x=0,S.z=0,S.y-=Math.PI/2,this.cameraPolarAxis0.set(0,0,-1).applyEuler(S)}if(this.object instanceof wt&&(this.object.matrixAutoUpdate=!1),this.euler.setFromQuaternion(this.quaternion,"YXZ"),this.rotByTouch=n.rotByTouch??"joystick",this.rotBy=n.rotBy??"keys",this.rotationMode=n.rotationMode??"normal",this.moveMode=n.moveMode??"walk",this.collisionEnabled=n.collisionEnabled,this.speedTranslate=(n.speedTranslate??250)*_G,this.speedOrbit=(n.speedRotate??100)*FG,this.mouseOrbitSensitivity=(n.speedRotate??100)*kG,this.keyAssignments=n.keyAssignments.map(y=>{let g=[y[0],y[1]];return g[1]==="\u25B2"?g[1]="ArrowUp":g[1]==="\u25C0"?g[1]="ArrowLeft":g[1]==="\u25BC"?g[1]="ArrowDown":g[1]==="\u25B6"?g[1]="ArrowRight":g[1]==="\u21E7"?g[1]="Shift":g[1]==="\u21B5"?g[1]="Enter":g[1]==="Space"?g[1]=" ":g[1]==="\u2318"?g[1]="Meta":g[1]==="Ctrl"?g[1]="Control":g[1]==="Esc"&&(g[1]="Escape"),g}),n.rotBy==="mouse"){let y;y=this.keyAssignments.findIndex(g=>g[0]==="rotNegX"),y!==-1&&(this.keyAssignments[y][1]=""),y=this.keyAssignments.findIndex(g=>g[0]==="rotPosX"),y!==-1&&(this.keyAssignments[y][1]=""),y=this.keyAssignments.findIndex(g=>g[0]==="rotPosY"),y!==-1&&(this.keyAssignments[y][1]=""),y=this.keyAssignments.findIndex(g=>g[0]==="rotNegY"),y!==-1&&(this.keyAssignments[y][1]="")}this.lerpFactorPosStart=1-.02**(1/((n.delayPos[0]??.3)*60)),this.lerpFactorPosEnd=1-.02**(1/((n.delayPos[1]??.3)*60)),this.lerpFactorPos.setScalar(this.lerpFactorPosStart),this.lerpFactorRotStart=1-.02**(1/((n.delayRot[0]??.3)*60)),this.lerpFactorRotEnd=1-.02**(1/((n.delayRot[1]??.3)*60)),this.lerpFactorPosCamera=1-.02**(1/((n.delayPosCamera??.3)*60)),this.lerpFactorRotCamera=1-.02**(1/((n.delayRotCamera??.3)*60)),this.gravity=(this.gloabalPhysics.gravity??hs.defaultData.gravity)*VI,this.usePhysics=this.gloabalPhysics.usePhysics??hs.defaultData.usePhysics,this.jumpPower=n.jumpPower*VG,this.resetYPosition=this.position.y+Math.abs(n.resetYPosition)*(this.gravity>0?1:-1),this.alignToGround=n.alignToGround??!1,this.orientMode=n.autoOrientMove?n.orientMode:"none",this.orientWith=n.orientWith??Fc.defaultDataThirdPerson.orientWith,this.slopeThresh=PG*Math.PI/180,n.collider.type==="capsule"?(this.collider.radius=n.collider.radius,this.collider.segment.start.y=n.collider.height/2-n.collider.radius,this.collider.segment.end.y=-this.collider.segment.start.y,this.offset=n.collider.height*f1/this.pixelsPerMeter,this.stepThresh=n.collider.height*m1/this.pixelsPerMeter,this.colliderHeight=n.collider.height):n.collider.type==="sphere"?(this.collider.radius=n.collider.radius,this.collider.segment.start.y=0,this.collider.segment.end.y=0,this.offset=2*n.collider.radius*f1/this.pixelsPerMeter,this.stepThresh=2*n.collider.radius*m1/this.pixelsPerMeter,this.colliderHeight=n.collider.radius*2):(this.offset=n.collider.height*f1/this.pixelsPerMeter,this.stepThresh=n.collider.height*m1/this.pixelsPerMeter,this.colliderHeight=n.collider.height),this.collider.type=n.collider.type;let h=new ne.Vector3().fromArray(n.collider.position.map(y=>typeof y=="number"?y:0)),f=new ne.Quaternion().setFromEuler(new ne.Euler().fromArray([...n.collider.rotation.map(y=>typeof y=="number"?y:0),"XYZ"]));this.collider.position.copy(h).multiply(this.scale),this.collider.rotation.copy(f),this.collider.matrix.compose(h,f,LI),n.cameraXAxis!==void 0&&(this.cameraXAxis=n.cameraXAxis,this.cameraYAxis=n.cameraYAxis,this.minPolarAngle=n.cameraRotXLimits[0],this.maxPolarAngle=n.cameraRotXLimits[1],this.minAzimuthAngleRel=n.cameraRotYLimits[0],this.maxAzimuthAngleRel=n.cameraRotYLimits[1]),this.forwardDir=n.forwardDirection??"-z",this.isFirstPerson&&(this.forwardDir="-z"),this.runMultiplier=n.runMultiplier??2;let m=n.navmesh.destinationHelperRadius*2;if(m>0){let y=new le;y.push({fi:0,data:{...Zt.defaultData("light","phong"),alpha:0},id:"layer1"}),y.push({fi:0,data:{...Zt.defaultData("color"),color:n.navmesh.destinationHelperColor,alpha:n.navmesh.destinationHelperColor.a},id:"layer2"});let g=Fy({layers:y},{scene:this.page.scene,shared:this.sharedAssets});this.navMeshPathDest=new GI.Mesh(hy.create({parameters:{width:m,height:m/10,hollow:.7}}),g),this.navMeshPathDest.material.userData.opacity0=n.navmesh.destinationHelperColor.a}this.activate()}reset(e=!1){if(this.object.hiddenMatrix.copy(this.hiddenMatrix0),e){this.object.updateMatrix(),this.object.updateMatrixWorld(),this.object.matrix.copy(this.object.matrixWorld),this.object.matrix.decompose(this.position,this.quaternion,this.scale),this.object.parent?this.object.hiddenMatrix.copy(this.object.parent.matrixWorld).invert():this.object.hiddenMatrix.identity();let r=new ne.Euler().setFromQuaternion(this.quaternion,"YXZ"),n=r.y;this.objectRealQuat.copy(this.quaternion),r.y=0,this.quaternion.setFromEuler(r),this.objXZQuat.copy(this.quaternion),this.objXZQuatInv.copy(this.objXZQuat).invert(),this.objXZRotMat.makeRotationFromQuaternion(this.quaternion),r.set(0,n,0),this.quaternion.setFromEuler(r),this.rot.setFromEuler(r),this.euler.setFromQuaternion(this.quaternion,"YXZ"),this.velocityTarget.set(0,0,0),this.velocity.set(0,0,0)}else this.object instanceof wt?this.object.matrixAutoUpdate=!0:this.object.updateMatrix();this.cameraFollow===!0&&(this.camera.quaternion.copy(this.quat0Cam),this.camera.position.copy(this.position0Cam),this.camera.scale.copy(this.scale0Cam),this.camera.hiddenMatrix.copy(this.hiddenMatrix0Cam),this.camera.matrixAutoUpdate=!0),this.controlsManager.requestRender()}activate(){this.instantiateActions(),this.domElement.ownerDocument.addEventListener("pointerdown",this.onPointerDown),this.domElement.ownerDocument.addEventListener("keydown",this.onKeyDown),this.domElement.ownerDocument.addEventListener("keyup",this.onKeyUp),this.domElement.ownerDocument.addEventListener("pointerlockchange",this.onPointerlockChange),this.domElement.ownerDocument.addEventListener("pointerlockerror",this.onPointerlockError),this.domElement.ownerDocument.addEventListener("visibilitychange",this.handleVisibilityChange)}deactivate(){this.disposeActions(),this.domElement.ownerDocument.removeEventListener("pointerdown",this.onPointerDown),this.domElement.ownerDocument.removeEventListener("keydown",this.onKeyDown),this.domElement.ownerDocument.removeEventListener("keyup",this.onKeyUp),this.domElement.ownerDocument.removeEventListener("pointerlockchange",this.onPointerlockChange),this.domElement.ownerDocument.removeEventListener("pointerlockerror",this.onPointerlockError),this.domElement.ownerDocument.removeEventListener("visibilitychange",this.handleVisibilityChange)}dispose(){this.deactivate(),this.navMeshPathDest?.parent&&this.page.remove(this.navMeshPathDest)}instantiateActions(){let e=this.data,r=this.sharedAssets;e.gameActions!==void 0&&(this.actions={},_c.list.forEach(n=>{this.actions[n]=Gt({...e,disabled:!1,type:"GameControl"},e.gameActions[n],this.page,r,this.controlsManager.eventManager,this.object)})),this.dispatchStopEvent("move"),this.dispatchStopEvent("run"),this.dispatchStopEvent("jump"),this.dispatchStartEvent("idle"),this.initialAction&&(this.initialAction=!1)}disposeActions(){this.initialAction=!1,this.dispatchStopEvent("idle"),this.dispatchStopEvent("move"),this.dispatchStopEvent("run"),this.dispatchStopEvent("jump"),br(this.actions.idle),br(this.actions.move),br(this.actions.run),br(this.actions.jump)}dispatchStartEvent(e){this.actions[e]!==void 0&&(this.actionState[e]||(this.actionState[e]=!0,this.actions[e].Transition.forEach(r=>{r.play()}),this.actions[e].Animation.forEach(r=>{r.play(this.initialAction===!1)}),this.actions[e].TimelineAnimation.forEach(r=>{r.play()}),this.actions[e].Create.forEach(r=>{r.dispatchStart()}),this.actions[e].Audio.forEach(r=>{r.dispatchGameControl("start")}),this.actions[e].Particles.forEach(r=>{r.dispatchGameControl("start")})))}dispatchStopEvent(e){this.actions[e]!==void 0&&(!this.actionState[e]||(this.actionState[e]=!1,this.actions[e].Transition.forEach(r=>{r.stop(),r.object.currentState!==null&&r.object.changeSelectedState(null,{scene:this.page.scene,shared:this.sharedAssets})}),this.actions[e].TimelineAnimation.forEach(r=>{r.stop()}),this.actions[e].Create.forEach(r=>{r.dispatchStop()}),this.actions[e].Audio.forEach(r=>{r.dispatchGameControl("stop")}),this.actions[e].Particles.forEach(r=>{r.dispatchGameControl("stop")})))}get colliderWorldPosition(){return En.copy(this.collider.position).applyQuaternion(this.objectRealQuat).add(this.position)}update(e){if(this.gravity<0?this.position.y<this.resetYPosition:this.position.y>this.resetYPosition)return this.reset(!0),!0;this.sharedGameControlGlobals.gamePads.forEach(this.copyVRGamePadValues);let r=(this.isFirstFrame?16.6:e)/1e3;this.isFirstFrame&&(this.isFirstFrame=!1);let n=r*60,o=!1;if(this.groundYRotation=0,this.groundVelocity.set(0,0,0),this.usePhysics&&this.collisionEnabled&&this.object.rigidBody?.collider(0).shape){let s=Va.set(0,(this.velocity.y===0?this.pixelsPerMeter*Math.max(Math.abs(this.gravity)/(10*VI),1)*(this.gravity>0?1:-1):this.velocity.y)*r,0).divideScalar(this.pixelsPerMeter),l=this.sharedGameControlGlobals.rapierWorld.castShape(this.colliderWorldPosition.divideScalar(this.pixelsPerMeter),this.colliderWorldQuat,s,this.object.rigidBody?.collider(0).shape,0,1,!1,h1,void 0,void 0,this.object.rigidBody);if(l){this.onObject=!0,this.groundNormal.set(l.normal2.x,l.normal2.y,l.normal2.z).applyQuaternion(this.colliderWorldQuat).negate(),this.alignToGround&&this.groundTiltAdjustment(this.groundNormal),Math.acos(this.groundNormal.y)<this.slopeThresh&&(o=!0),l.collider.parent()?.bodyType()===0&&Math.acos(this.groundNormal.y)*(180/Math.PI)>45&&(this.onObject=!1);let c=l.collider.parent(),d=c!==null&&c.isKinematic()?c:null,u=d===null?void 0:this.sharedGameControlGlobals.kinematicBodyToEntity.get(d.handle);if(d!==null&&u?.userData.isFollowingObj!==this.object.uuid){let p=this.object.getWorldPosition(En).add(this.collider.position).divideScalar(this.pixelsPerMeter),h=d.velocityAtPoint(p);this.groundVelocity.set(h.x,h.y,h.z).multiplyScalar(this.pixelsPerMeter),this.groundYRotation=d.angvel().y*r}}else this.onObject=!1}if(this.moveMode==="walk"&&this.collisionEnabled&&(this.movementState.jump===1&&this.onObject&&(this.velocityTarget.y=this.jumpPower,this.movementState.jump=0,this.dispatchStopEvent("idle"),this.dispatchStopEvent("move"),this.dispatchStopEvent("run"),this.dispatchStopEvent("jump"),this.dispatchStartEvent("jump"),this.onObject=!1),this.onObject?this.velocityTarget.y/=2:this.velocityTarget.y+=this.gravity*n),this.moveMode==="fly"&&(this.velocityTarget.y=(this.movementState.movePosY-this.movementState.moveNegY)*this.speedTranslate),this.directionXZ.z=this.movementState.movePosZ-this.movementState.moveNegZ,this.directionXZ.x=this.movementState.movePosX-this.movementState.moveNegX,this.forwardDir==="+z"&&this.directionXZ.multiplyScalar(-1),this.directionXZ.manhattanLength()>0&&(this.path=[]),this.navMeshPathDest){let s=this.navMeshPathDest.material;if(this.moveMode==="walk"&&this.path.length>1){this.navMeshPathDest.position.copy(this.path[this.path.length-1]),this.navMeshPathDest.parent||this.page.add(this.navMeshPathDest);let l=En.subVectors(this.path[1],this.position),c=Va.subVectors(this.path[1],this.path[0]);l.dot(c)<0?this.path.shift():(this.directionXZ.x=c.x,this.directionXZ.z=c.z),s.opacity=s.userData.opacity0}else s.opacity-=.05*s.userData.opacity0,this.navMeshPathDest.material.opacity<=0&&this.navMeshPathDest.parent&&this.page.remove(this.navMeshPathDest)}this.directionXZ.normalize(),this.movementState.run?this.moveForce=this.runMultiplier:this.moveForce=1,this.velocityTarget.z=this.directionXZ.z*this.speedTranslate*this.moveForce,this.velocityTarget.x=this.directionXZ.x*this.speedTranslate*this.moveForce,(this.moveMode==="walk"?this.velocityTarget.x+this.velocityTarget.z===0:this.velocityTarget.manhattanLength()===0)?this.lerpFactorPos.setScalar(this.lerpFactorPosEnd):this.lerpFactorPos.setScalar(this.lerpFactorPosStart),this.moveMode==="walk"&&(this.lerpFactorPos.y=1),this.didHit===!1&&this.pushedVelocity.manhattanLength()===0||this.usePhysics===!1?(this.velocity.x+=(this.velocityTarget.x-this.velocity.x)*(1-(1-this.lerpFactorPos.x)**n),this.velocity.y+=(this.velocityTarget.y-this.velocity.y)*(1-(1-this.lerpFactorPos.y)**n),this.velocity.z+=(this.velocityTarget.z-this.velocity.z)*(1-(1-this.lerpFactorPos.z)**n)):this.velocity.copy(this.velocityTarget),(this.moveMode==="walk"?this.velocity.x**2+this.velocity.z**2<this.speedTranslate:this.velocity.lengthSq()<this.speedTranslate)?(this.dispatchStopEvent("move"),this.dispatchStopEvent("run"),this.onObject&&(this.dispatchStopEvent("jump"),this.dispatchStartEvent("idle"))):(this.dispatchStopEvent("idle"),(this.onObject||this.moveMode==="fly")&&(this.dispatchStopEvent("jump"),this.movementState.run?(this.dispatchStopEvent("move"),this.dispatchStartEvent("run")):(this.dispatchStopEvent("run"),this.dispatchStartEvent("move"))));let a=MG.copy(this.velocity);if(this.orientMode!=="none"&&this.isFirstPerson===!1){let s=Va.copy(a);s.y=0,a.set(0,a.y,s.length()*(this.forwardDir==="+z"?1:-1))}if(this.directionXZ.manhattanLength()>0&&this.orientMode!=="none"&&this.isFirstPerson===!1)if(this.orientWith==="camera"&&this.path.length<=1){let s=En;this.camera.getWorldDirection(s);let l=_d.copy(ea).multiplyScalar(s.dot(ea));s.sub(l);let c=Va.copy(this.directionXZ);c.x*=-1,this.rot.y=s.angleTo(c)*(s.cross(c).y>0?-1:1)+this.rotationAccumWhenOrientWithCamera}else this.rot.y=(this.path.length>1?0:this.euler.y)+Math.atan2(-this.directionXZ.z,this.directionXZ.x)+Math.PI/2*(this.forwardDir==="+z"?1:-1);if(Fd.setFromVector3(this.rot),this.moveMode==="walk"&&(Fd.x=0),a.applyEuler(Fd),o&&(Ul.setFromUnitVectors(ea,this.groundNormal),a.applyQuaternion(Ul)),this.usePhysics===!0&&this.object.rigidBody){this.pushedVelocity.set(0,0,0);let s=0;for(let l of this.sharedGameControlGlobals.entitiesWithTransformAnim){if(l.rigidBody===void 0||l.prevQ===void 0)continue;(l.hasNonUniformScale?l.matrixWorldRigid:l.matrixWorld).decompose(v1,FI,RG);let c=this.object.getWorldPosition(BG).add(this.collider.position).sub(v1);kI.copy(l.prevQ).invert().premultiply(FI);let d=_d.subVectors(v1,l.prevT).add(NG.copy(c).applyQuaternion(kI).sub(c)).divideScalar(r).divideScalar(this.pixelsPerMeter),u=l.rigidBody.collider(0).castCollider(d,this.object.rigidBody.collider(0),En.copy(a).divideScalar(this.pixelsPerMeter),0,r,!1);d.multiplyScalar(this.pixelsPerMeter);let p=Le.is(l)?l:l.object;if(u!==null&&this.lastHitObj!==p){let h;l instanceof Rr&&(h=l);let f=this.sharedGameControlGlobals.entityToCollisionEvents[p.uuid];if(f)for(let m of f)m.data.target==="character"&&(m.dispatch(h),p.dispatchEvent(u1));this.lastHitObj=p}u!==null&&(Math.abs(d.x)>Math.abs(this.pushedVelocity.x)&&(this.pushedVelocity.x=d.x),Math.abs(d.y)>Math.abs(this.pushedVelocity.y)&&(this.pushedVelocity.y=d.y),Math.abs(d.z)>Math.abs(this.pushedVelocity.z)&&(this.pushedVelocity.z=d.z),_I(s++).copy(u.normal1).applyQuaternion(l.quaternion))}if(s>0){for(let l=0;l<s;l++){let c=_I(l),d=c.dot(a);d<0&&a.addScaledVector(c,-d)}a.add(this.pushedVelocity)}else a.add(this.groundVelocity)}if(this.rotDirection.y=Number(this.movementState.rotPosY)-Number(this.movementState.rotNegY),this.rotDirection.x=Number(this.movementState.rotPosX)-Number(this.movementState.rotNegX),this.rotDirection.normalize(),this.rotationMode==="normal"&&(this.movementState.rotPosX||this.movementState.rotNegX)||this.rotationMode==="steer"&&(this.movementState.rotPosX||this.movementState.rotNegX)&&(this.movementState.movePosZ||this.movementState.moveNegZ||this.moveMode==="walk")?this.rotVelocityStick.x=-this.rotDirection.x*this.speedOrbit*this.rotForce:this.rotVelocityStick.x=0,this.rotationMode==="normal"&&(this.movementState.rotPosY||this.movementState.rotNegY)||this.rotationMode==="steer"&&(this.movementState.rotPosY||this.movementState.rotNegY)&&(this.movementState.movePosZ||this.movementState.moveNegZ)?this.rotVelocityStick.y=-this.rotDirection.y*this.speedOrbit*this.rotForce:this.rotVelocityStick.y=0,this.rotVelocityTarget.subVectors(this.eulerDelta.divideScalar(r),this.rotVelocityStick),this.rotVelocityTarget.manhattanLength()===0?this.rotVelocity.lerp(this.rotVelocityTarget,1-(1-this.lerpFactorRotEnd)**n):this.rotVelocity.lerp(this.rotVelocityTarget,1-(1-this.lerpFactorRotStart)**n),this.euler.x+=this.rotVelocity.x*r,this.euler.y+=this.rotVelocity.y*r+this.groundYRotation,this.rotVelocityTarget.y===0&&this.directionXZ.manhattanLength()===0?this.rotationAccumWhenOrientWithCamera=0:(this.cameraFollow===!1||this.cameraYAxis==="Locked")&&(this.rotationAccumWhenOrientWithCamera+=this.rotVelocity.y*r),this.isFirstPerson===!1&&this.orientMode!=="none"&&this.directionXZ.manhattanLength()>0){if(this.orientMode==="radial"){this.objectToCamXZ.copy(this.objectToCamXZ0).applyAxisAngle(ea,this.euler.y-this.euler0.y);let s=Va.copy(this.objectToCamXZ).normalize(),l=_d.copy(a).multiplyScalar(r);l.y=0;let c=l.sub(En.copy(s).multiplyScalar(l.dot(s))).cross(s).y;this.euler.y-=Math.atan2(c,this.objectToCamXZ.length())}}else this.rot.y+=this.rotVelocity.y*r+this.groundYRotation,this.rotVelocityTarget.y!==0&&(this.cameraFollow===!1||this.cameraYAxis==="Locked")&&(this.euler.y=this.rot.y);if(this.cameraFollow===!0&&(this.moveMode==="walk"?this.cameraXAxis==="Limit"?this.euler.x=ne.MathUtils.clamp(this.euler.x,-this.maxPolarAngle+this.cameraPolarOffset+1e-6,-this.minPolarAngle+this.cameraPolarOffset-1e-6):this.euler.x=ne.MathUtils.clamp(this.euler.x,-this.PI_2+this.cameraPolarOffset,this.PI_2+this.cameraPolarOffset):this.cameraXAxis==="Limit"&&(this.euler.x=ne.MathUtils.clamp(this.euler.x,-this.PI_2,this.PI_2))),this.moveMode==="fly"?this.rot.x=this.euler.x:this.isFirstPerson&&(Fd.copy(this.euler),Fd.y=0,this.nonColliderRotOffset.makeRotationFromEuler(Fd)),fi.setFromAxisAngle(IG,this.rot.x),Ul.setFromAxisAngle(ea,this.rot.y),Ul.multiply(fi),fi.setFromAxisAngle(DG,this.rot.z),Ul.multiply(fi),this.quaternion.copy(Ul),this.objectRealQuat.multiplyQuaternions(this.quaternion,this.objXZQuat),this.colliderWorldQuat.copy(this.objectRealQuat).multiply(this.collider.rotation),this.collisionEnabled)if(this.usePhysics&&this.object.rigidBody?.collider(0).shape){let s=Va.copy(a).multiplyScalar(r/this.pixelsPerMeter),l=null;this.didHit=!1;let c=new ne.Vector3;for(let p=0;p<5;p++){let h=s.length(),f=_d.copy(s).normalize();if(l=this.sharedGameControlGlobals.rapierWorld.castShape(this.colliderWorldPosition.divideScalar(this.pixelsPerMeter).add(c),this.colliderWorldQuat,f,this.object.rigidBody.collider(0).shape,0,h,!1,h1|DI,void 0,void 0,this.object.rigidBody),l!==null){this.didHit=!0;let m=this.sharedGameControlGlobals.colliderToEntity.get(l.collider.handle);if(m!==this.lastHitObj&&p===0){this.lastHitObj=m;let b=this.sharedGameControlGlobals.entityToCollisionEvents[m?.uuid];if(b){for(let S of b)if(S.data.target==="character"){let x=(this.sharedGameControlGlobals.rapierWorld?.getCollider(l.collider.handle))._parent,w;if(m.cloner){for(let A of m.cloner.children)if(A.rigidBody===x){w=A;break}}S.dispatch(w),m.dispatchEvent(u1)}}}let y=RI.set(l.normal2.x,l.normal2.y,l.normal2.z).applyQuaternion(this.colliderWorldQuat),g=BI.copy(f).multiplyScalar(l.time_of_impact).dot(y),v=l.time_of_impact;if(v===0&&(this.position.y+=this.offset*this.pixelsPerMeter),g>this.offset&&(v=l.time_of_impact*(g-this.offset)/g,c.addScaledVector(f,v)),s.copy(f).multiplyScalar(h-v),Math.acos(-y.y)>this.slopeThresh){let b=this.colliderWorldPosition.divideScalar(this.pixelsPerMeter).add(c),S=_d.copy(l.witness2).applyQuaternion(this.colliderWorldQuat);S.y=0;let x=b.add(S);x.y+=this.stepThresh;let w=this.sharedGameControlGlobals.rapierWorld.castShape(x,this.colliderWorldQuat,s,this.object.rigidBody?.collider(0).shape,0,1,!1,h1|DI,void 0,void 0,this.object.rigidBody);w!==null&&w.time_of_impact===0&&(y.y=0,y.normalize())}s.addScaledVector(y,-s.dot(y))}else{p===0&&this.directionXZ.manhattanLength()!==0&&(this.lastHitObj=null),c.add(s);break}}this.position.addScaledVector(c,this.pixelsPerMeter),En.copy(this.position).divideScalar(this.pixelsPerMeter),fi.copy(this.quaternion).premultiply(this.groundTilt).multiply(this.objXZQuat);let d=this.object.rigidBody,u=d!==void 0&&LG.copy(En).sub(d.translation()).lengthSq()>1;d!==void 0&&(u?(d.setTranslation(En,!0),d.setRotation(fi,!0)):(d.setNextKinematicTranslation(En),d.setNextKinematicRotation(fi)))}else{let s=this.onObject?1:5,l=a.multiplyScalar(r/s);for(let c=0;c<s;c++)this.position.add(l),this.collisionAdjustment(r/s)}else this.position.addScaledVector(a,r);if(this.moveMode==="walk"&&this.onObject&&(this.velocityTarget.y=0,this.velocity.y=0),this.quaternion.premultiply(this.groundTilt).multiply(this.objXZQuat),this.object.matrix.compose(this.position,this.quaternion,this.scale),this.object.matrixWorldNeedsUpdate=!0,this.object.matrix.multiply(this.nonColliderPosOffset).multiply(this.nonColliderRotOffset),this.quaternion.premultiply(this.groundTiltInv).multiply(this.objXZQuatInv),this.cameraFollow===!0){this.updateFollowArms();let s=this.objectToTarget.add(this.position),l=this.targetToCamera.add(s);y1.lookAt(l,s,ea).setPosition(l),y1.decompose(this.targetPos,this.targetQuat,En),this.camera.quaternion.slerp(this.targetQuat,1-(1-this.lerpFactorRotCamera)**n),this.camera.position.lerp(this.targetPos,1-(1-this.lerpFactorPosCamera)**n),this.camera.updateMatrix(),this.camera.updateMatrixWorld(),this.cameraYAxis==="Limit"&&this.orientMode==="cartesian"&&(this.euler.y=ne.MathUtils.clamp(this.euler.y,this.minAzimuthAngleRel,this.maxAzimuthAngleRel)),this.euler.x=ne.MathUtils.clamp(this.euler.x,-this.PI_2+(this.cameraPolarOffset<0?this.cameraPolarOffset:0),this.PI_2+(this.cameraPolarOffset>0?this.cameraPolarOffset:0))}return this.eulerDelta.set(0,0,0),this.object.dispatchEvent(UG),this.path.length<2&&this.lastPosition.distanceToSquared(this.position)<this.threshEndTranslate&&Math.abs(this.rotVelocity.x)<this.threshEndRotVel&&Math.abs(this.rotVelocity.y)<this.threshEndRotVel&&(this.camera===void 0||this.isFirstPerson||this.lastCameraPosition.distanceToSquared(this.camera.position)<this.threshEndTranslate&&8*(1-this.lastCameraQuaternion.dot(this.camera.quaternion))<this.threshEndRotate)&&(this.moveMode==="fly"||this.onObject===!0||this.collisionEnabled===!1)&&(this.navMeshPathDest===null||this.navMeshPathDest.material.opacity<-.04*this.navMeshPathDest?.material?.userData.opacity0)?!1:(this.camera&&(this.lastCameraPosition.copy(this.camera.position),this.lastCameraQuaternion.copy(this.camera.quaternion)),this.lastPosition.copy(this.position),this.object.dispatchEvent(GG),!0)}updateFollowArms(){this.objectToTarget.copy(this.objectToTarget0),this.targetToCamera.copy(this.targetToCamera0);let e=fi.setFromAxisAngle(ea,this.cameraYAxis==="Limit"&&this.orientMode!=="radial"?ne.MathUtils.clamp(this.euler.y-this.euler0.y,this.minAzimuthAngleRel,this.maxAzimuthAngleRel):this.euler.y-this.euler0.y);(this.cameraYAxis!=="Locked"||this.orientMode==="radial")&&this.objectToTarget.applyQuaternion(e);let r;this.cameraXAxis==="Limit"?r=ne.MathUtils.clamp(this.euler.x,-this.maxPolarAngle+this.cameraPolarOffset+1e-6,-this.minPolarAngle+this.cameraPolarOffset-1e-6):r=ne.MathUtils.clamp(this.euler.x,-this.PI_2+this.cameraPolarOffset+1e-6,this.PI_2+this.cameraPolarOffset-1e-6);let n=En.copy(this.cameraPolarAxis0);(this.cameraYAxis!=="Locked"||this.orientMode==="radial")&&n.applyQuaternion(e);let o=Ul.setFromAxisAngle(n,r);this.cameraYAxis!=="Locked"&&this.targetToCamera.applyQuaternion(e),this.cameraXAxis!=="Locked"&&this.targetToCamera.applyQuaternion(o)}groundTiltAdjustment(e){ea.angleTo(e)*180/Math.PI<15||ea.angleTo(e)*180/Math.PI>85?fi.identity():fi.setFromUnitVectors(ea,e),this.groundTilt.slerp(fi,.06),this.groundTiltInv.copy(this.groundTilt).invert()}collisionAdjustment(e){let r=BI.set(0,0,0);this.object.matrix.compose(this.position,this.quaternion,this.scale);let n=y1.multiplyMatrices(this.object.matrix,this.objXZRotMat).multiply(this.collider.matrix).decompose(En,fi,Va).compose(En,fi,LI);this.sharedGameControlGlobals.entitiesWithTransformAnim.forEach(a=>{if(a===this.object||a.isDescendantOf(this.object)||!a.bvhGeometry||!a.bvhGeometry.boundsTree)return;zi.makeEmpty(),a.updateMatrixWorldRigid();let s=a.matrixWorldRigid,l=NI.copy(s).invert(),c=OG.copy(NI).multiply(n);rn.copy(this.collider.segment),rn.start.applyMatrix4(c),rn.end.applyMatrix4(c);let d=RI.copy(this.position).applyMatrix4(l);zi.expandByPoint(rn.start),zi.expandByPoint(rn.end),zi.min.addScalar(-this.collider.radius),zi.max.addScalar(this.collider.radius),a.bvhGeometry.boundsTree.shapecast({boundsTraverseOrder(u){return u.distanceToPoint(rn.end)},intersectsBounds:u=>u.intersectsBox(zi),intersectsTriangle:u=>{let p=En,h=Va,f=u.closestPointToSegment(rn,p,h);if(f<this.collider.radius){let m=this.collider.radius-f,y=h.sub(p).normalize(),g=_d.copy(d);g.addScaledVector(y,m);let v=g.applyMatrix4(s).sub(this.position);r.add(v),rn.start.addScaledVector(y,m),rn.end.addScaledVector(y,m)}}})}),zi.makeEmpty(),rn.copy(this.collider.segment),rn.start.applyMatrix4(n),rn.end.applyMatrix4(n),zi.expandByPoint(rn.start),zi.expandByPoint(rn.end),zi.min.addScalar(-this.collider.radius),zi.max.addScalar(this.collider.radius),this.sharedGameControlGlobals.staticMeshBVH?.shapecast({boundsTraverseOrder(a){return a.distanceToPoint(rn.end)},intersectsBounds:a=>a.intersectsBox(zi),intersectsTriangle:a=>{let s=En,l=Va,c=a.closestPointToSegment(rn,s,l);if(c<this.collider.radius){let d=this.collider.radius-c,u=l.sub(s).normalize();this.alignToGround&&this.groundTiltAdjustment(u),r.addScaledVector(u,d),rn.start.addScaledVector(u,d),rn.end.addScaledVector(u,d)}}}),this.onObject=Math.abs(r.y)>Math.abs(e*this.velocity.y*.25),this.onObject&&this.dispatchStopEvent("jump");let o=Math.max(0,r.length()-1e-5);r.normalize().multiplyScalar(o),this.position.add(r)}pause(){this.firstPointerId=-1,this.movementState={moveNegZ:0,movePosZ:0,moveNegX:0,movePosX:0,moveNegY:0,movePosY:0,rotPosX:0,rotNegX:0,rotPosY:0,rotNegY:0,jump:0,run:0},this.deactivate()}resume(){this.activate()}},uh=Og;uh.isLocked=!1;var go=require("three"),HI=require("three/examples/jsm/utils/BufferGeometryUtils.js");var zG,UI=new Promise(i=>{zG=i});var zI;var jG=!1?typeof window<"u"?window.location.href:"":"https://cdn.spline.design/@splinetool/runtime@2.0.86/build/",HG=i=>`
|
|
1328
1328
|
(async function() {
|
|
1329
1329
|
const [wasmImport, wasmBinary] = await Promise.all([
|
|
1330
1330
|
import('${i}' + 'navmesh.js'),
|
|
@@ -5240,4 +5240,4 @@ vec3 lab2rgb (in vec3 lab) {
|
|
|
5240
5240
|
|
|
5241
5241
|
`;var Zb=class extends _L.ShaderMaterial{constructor(e,r){super();this.needsJitter=!0;this.type="ParticleMaterial";this.nodeExtensions={derivatives:!1,fragDepth:!1,drawBuffers:!1,shaderTextureLOD:!1};this.easeOpacity="linearFadeIn";this.easeSize="linearFadeIn";this.useSizeEnd=!1;this.isColoringRandom=!1;this.init(e,r),this.context=r}reset(){}init(e,r){this.transparent=!0,this.depthTest=!0,this.depthWrite=!1,this.easeOpacity=e.ease,this.easeSize=e.easeSize,this.layers=[],vt.startContext(vt.globalContext),this.lightLayer=new Hn(0,"",{...Zt.defaultData("light","phong"),visible:!1},new Ys,{},r.shared),vt.endContext(vt.globalContext),this.build()}updateState(e){e.coloring!==void 0&&(this.isColoringRandom=e.coloring==="random"),e.color!==void 0&&(e.color instanceof Array?this.uniforms.uColor.value=e.color:this.uniforms.uColor.value=this.context.shared.color(e.color)),e.color2!==void 0&&(e.color2 instanceof Array?this.uniforms.uColor2.value=e.color2:this.uniforms.uColor2.value=this.context.shared.color(e.color2)),e.size!==void 0&&(this.uniforms.uSize.value=e.size[0],this.uniforms.uSizeEnd.value=e.size[1],e.size[0]!==e.size[1]?this.useSizeEnd=!0:this.useSizeEnd=!1),e.ease!==void 0&&(this.easeOpacity=e.ease,this.build()),e.easeSize!==void 0&&(this.easeSize=e.easeSize,this.build()),this.needsUpdate=!0}onBeforeCompile(e){this.build(),e.defines=this.defines,e.uniforms=this.uniforms,e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader}build(){let e=new Eu;return e.needsJitter=this.needsJitter,e.addFragmentParsCode(ON),e.buildShader("vertex",this.fragment),e.buildShader("fragment",this.fragment),e.addFragmentFinalCode(IN),this.isColoringRandom&&e.define("USE_RANDOM_COLORING"),this.useSizeEnd&&e.define("USE_SIZE_END"),e.addVertexParsCode(RL),e.addFragmentParsCode(NL),e.addVertexFinalCode(BL({easeSize:this.easeSize})),e.addFragmentFinalCode(LL({easeOpacity:this.easeOpacity})),this.vertexShader=e.getCode("vertex"),this.fragmentShader=e.getCode("fragment"),this.defines=e.defines,this.uniforms={...e.uniforms,...this.uniforms},this.nodeExtensions=e.extensions,this}get nodeMaterial(){return this}get fragment(){return this.lightLayer.node}getDefines(){return this.defines}nodeMaterialDispose(){this.layers.forEach(e=>e.dispose()),super.dispose()}};var FL=require("three/examples/jsm/misc/GPUComputationRenderer.js");bP({createMaterial:(i,t)=>new Zb(i,t),createComputation:(i,t,e)=>new FL.GPUComputationRenderer(i,t,e)});var DA=require("three");function kL(i,t,e,r){let n=e,o=n.type==="texture"?n.texture.image!=null?r.uiBuffer(n.texture.image)??r.image(n.texture.image):r.getImage(""):r.video(n.texture.video),a=new $a(o,n.texture.wrapping??(n.type==="texture"?1e3:1001),n.texture.minFilter??1008,n.texture.magFilter??1006),s=new Eb(o),l=new Tb(dc(n.texture.repeat??[1,1],r),dc(n.texture.offset??[0,0],r),he(n.texture.rotation??0,r)),c=new ee(n.crop?1:0),d=new Fe(n.projection??0),u=new Fe(["x","y","z"].indexOf(n.axis)??0),p=n.projectionAxis?["x","y","z"].indexOf(n.projectionAxis):-1,h=new Fe(n.side??0),f=new Kt(n.size?new DA.Vector2(...dc(n.size,r)):new DA.Vector2(100,100)),m=new ee(n.blending??0),y=new ee(_i(n.alpha,r)),g=new Fe(n.mode??0),v=new kt(n.isMask??!1),b=new ts(a,s,c,d,u,h,f,m,l,y,g,v,p),S=new Re(b.calpha,"f");return new He(i,t,n,{texture:a,textureSize:s,crop:c,projection:d,axis:u,side:h,size:f,blending:m,mat:l,alpha:y,mode:g,isMask:v},b,g,S,v,r)}ut("texture",kL);ut("video",kL);var VL=require("three");ut("matcap",(i,t,e,r)=>{let n=e,o=n.texture.image!=null?r.image(n.texture.image):r.getImage(""),a=new $a(o,n.texture.wrapping??1001,n.texture.minFilter??1008,n.texture.magFilter??1006),s=new ee(_i(n.alpha,r)),l=new Fe(n.mode??0),c=new kt(n.isMask??!1),d=new ee((he(n.texture.rotation??0,r)??0)*VL.MathUtils.DEG2RAD),u=new Lu(a,s,l,c,d),p=new Re(u.calpha,"f");return new He(i,t,n,{texture:a,alpha:s,mode:l,isMask:c,rotation:d},u,l,p,c,r)});var GL=require("three");ut("displace",(i,t,e,r)=>{let n=e;if(n.displacementType==="noise"){let o=new hr(new GL.Vector3(...n.offset.map(g=>he(g,r)??0))),a=new ee(he(n.scale,r)??10),s=new ee(he(n.intensity,r)??8),l=new ee(he(n.movement,r)??1),c=new Fe(n.noiseType??0),d=new Fe(n.voronoiStyle??0),u=new ee(he(n.smoothness,r)??.5),p=new ee(he(n.seed,r)??0),h=new ee(he(n.highCut,r)??1),f=new ee(he(n.lowCut,r)??0),m=new Fe(he(n.quality,r)??1),y=new ju(s,l,o,d,u,p,h,f,m,a,c);return new Wu(i,t,n,{offset:o,scale:a,intensity:s,movement:l,noiseType:c,voronoiStyle:d,smoothness:u,seed:p,highCut:h,lowCut:f,quality:m},y,r)}else throw new Error});ut("cavity",(i,t,e,r)=>{let n=Rt(e,r),o=new ee(he(n.ridge,r)??1),a=new ee(he(n.valley,r)??1),s=Bt(n),l=new Ru(o,a,je.normalViewRenderTarget,je.resolution,s.alpha,s.mode,s.isMask),c=new Re(l.calpha,"f");return new He(i,t,e,{ridge:o,valley:a,...s},l,s.mode,c,s.isMask,r)});ut("dust",(i,t,e,r)=>{let n=Rt(e,r),o=new ot(n.color??10323813),a=new ee(n.coverage??.2),s=new ee(n.softness??.2),l=new ee(n.noiseStrength??.2),c=new ee(n.noiseScale??1),d=Bt(n),u=new Bu(o,a,s,l,c,d.alpha,d.isMask),p=new Re(u.calpha,"f");return new He(i,t,e,{color:o,coverage:a,softness:s,noiseStrength:l,noiseScale:c,...d},u,d.mode,p,d.isMask,r)});ut("fresnel",(i,t,e,r)=>{let n=Rt(e,r),o=new ot(n.color??16777215),a=new ee(he(n.bias,r)??.1),s=new ee(he(n.scale,r)??1),l=new ee(he(n.intensity,r)??2),c=new ee(he(n.factor,r)??1),d=Bt(n),u=new hf(o,a,s,l,c,d.alpha,d.mode,d.isMask),p=new Re(u.calpha,"f");return new He(i,t,e,{color:o,bias:a,scale:s,intensity:l,factor:c,...d},u,d.mode,p,d.isMask,r)});var Xu=require("three");ut("gradient",(i,t,e,r)=>{let n=Rt(e,r),o=new Fe(n.gradientType??0),a=new kt(n.smooth??!1),s;n.colors?s=new bi(n.colors.length,n.colors):(s=new bi(10,new Xu.Vector4(0,0,0,1)),s.value[1]=new Xu.Vector4(1,1,1,1));let l;n.steps?l=new vi(n.steps.length,n.steps):(l=new vi(10,1),l.value[0]=0);let c=new Kt(eo(n.offset??new Xu.Vector2(0,0),r)),d=new Kt(eo(n.morph??new Xu.Vector2(0,0),r)),u=new ee(he(n.angle??0,r)),p=Bt(n),h=new Nu(o,a,s,l,c,d,u,p.alpha,p.isMask),f=new Re(h.calpha,"f");return new He(i,t,e,{gradientType:o,smooth:a,colors:s,steps:l,offset:c,morph:d,angle:u,...p},h,p.mode,f,p.isMask,r)});var RA=require("three");ut("depth",(i,t,e,r)=>{let n=Rt(e,r),o=new Fe(n.gradientType??0),a=new kt(n.smooth??!1),s=new ee(he(n.near,r)??50),l=new ee(he(n.far,r)??200),c=new ee(n.isVector??1),d=new ee(n.isWorldSpace??0),u=new hr(xi(n.origin,r)),p=new hr(xi(n.direction,r)),h;n.colors?h=new bi(n.colors.length,n.colors):(h=new bi(2,new RA.Vector4(0,0,0,1)),h.value[1]=new RA.Vector4(1,1,1,1));let f;n.steps?f=new vi(n.steps.length,n.steps):(f=new vi(2,1),f.value[0]=0);let m=Bt(n),y=new Du(o,a,s,l,c,d,u,p,h,f,m.alpha,m.isMask),g=new Re(y.calpha,"f");return new He(i,t,e,{gradientType:o,smooth:a,near:s,far:l,isVector:c,isWorldSpace:d,origin:u,direction:p,colors:h,steps:f,...m},y,m.mode,g,m.isMask,r)});var UL=require("three");ut("normal",(i,t,e,r)=>{let n=Rt(e,r),o=new hr(n.cnormal??new UL.Vector3(1,1,1)),a=Bt(n),s=new Ou(o,a.alpha),l=new Re(s.calpha,"f");return new He(i,t,e,{cnormal:o,...a},s,a.mode,l,a.isMask,r)});var Yu=require("three");ut("noise",(i,t,e,r)=>{let n=Rt(e,r),o=new ee(he(n.scale,r)??1),a=new hr(xi(n.size??new Yu.Vector3(100,100,100),r)),s=new ee(he(n.move,r)??1),l=new Kt(eo(n.fA??new Yu.Vector2(1.7,9.2),r)),c=new Kt(eo(n.fB??new Yu.Vector2(8.3,2.8),r)),d=new Kt(eo(n.distortion??new Yu.Vector2(1,1),r)),u=new On(n.colorA),p=new On(n.colorB),h=new On(n.colorC),f=new On(n.colorD),m=new Fe(n.noiseType??0),y=new Fe(n.voronoiStyle??0),g=new ee(he(n.highCut,r)??1),v=new ee(he(n.lowCut,r)??0),b=new ee(he(n.smoothness,r)??.5),S=new ee(he(n.seed,r)??.5),x=new Fe(n.quality??1),w=Bt(n),A=new _u(o,a,s,l,c,d,u,p,h,f,w.alpha,m,w.isMask,y,g,v,b,S,x),C=new Re(A.calpha,"f");return new He(i,t,e,{scale:o,size:a,move:s,fA:l,fB:c,distortion:d,colorA:u,colorB:p,colorC:h,colorD:f,noiseType:m,...w,voronoiStyle:y,highCut:g,lowCut:v,smoothness:b,seed:S,quality:x},A,w.mode,C,w.isMask,r)});ut("rainbow",(i,t,e,r,n)=>{let o=Rt(e,r),a=new ee(he(o.filmThickness,r)??30),s=new ee(he(o.movement,r)??0),l=new hr(xi(o.wavelengths,r)),c=new ee(he(o.noiseStrength,r)??0),d=new ee(he(o.noiseScale,r)??1),u=new hr(xi(o.offset,r)),p=Bt(o),h=n?.forceRainbowNoise===!0,f=h||po(o.noiseStrength),m=new Vu(a,s,l,c,d,u,p.alpha,p.isMask,f),y=new Re(m.calpha,"f"),g=new He(i,t,e,{filmThickness:a,movement:s,wavelengths:l,noiseStrength:c,noiseScale:d,offset:u,...p},m,p.mode,y,p.isMask,r);return g.noiseCompiledIn=f,g.noiseForced=h,g});var Qu=require("three");ut("toon",(i,t,e,r)=>{let n=Rt(e,r),o=new Fe(n.positioning??0),a;n.colors?a=new bi(n.colors.length,n.colors):(a=new bi(10,new Qu.Vector4(0,0,0,1)),a.value[1]=new Qu.Vector4(1,1,1,1));let s;n.steps?s=new vi(n.steps.length,n.steps):(s=new vi(10,1),s.value[0]=0);let l=new hr(xi(n.source??new Qu.Vector3(0,0,0),r)),c=new kt(n.isWorldSpace??!0),d=new ee(he(n.noiseStrength??0,r)),u=new ee(he(n.noiseScale??1,r)),p=new On(n.shadowColor),h=new hr(xi(n.offset??new Qu.Vector3(0,0,0),r)),f=Bt(n),m=new Gu(o,a,s,l,c,d,u,p,h,f.alpha),y=new Re(m.calpha,"f");return new He(i,t,e,{positioning:o,colors:a,steps:s,source:l,isWorldSpace:c,noiseStrength:d,noiseScale:u,shadowColor:p,offset:h,...f},m,f.mode,y,f.isMask,r)});var zL=require("three");ut("outline",(i,t,e,r)=>{let n=Rt(e,r),o=new ot(n.outlineColor??16777215),a=new ot(n.contourColor??16777215),s=new ee(he(n.outlineWidth??.1,r)),l=new ee(he(n.contourWidth??.1,r)),c=new ee(he(n.outlineThreshold??.1,r)),d=new ee(he(n.contourThreshold??.1,r)),u=new ee(he(n.outlineSmoothing??.1,r)),p=new ee(he(n.contourFrequency??.1,r)),h=new hr(xi(n.contourDirection??new zL.Vector3(0,1,0),r)),f=new kt(n.positionalLines??!1),m=new kt(n.compensation??!0),y=je.normalRenderTarget,g=je.normalRenderTargetDepth,v=je.pixelRatioNode,b=je.resolution,S=Bt(n),x=new Fu(o,a,s,l,c,d,u,p,h,f,m,b,y,g,v,S.alpha),w=new Re(x.calpha,"f");return new He(i,t,e,{outlineColor:o,contourColor:a,outlineWidth:s,contourWidth:l,outlineThreshold:c,contourThreshold:d,outlineSmoothing:u,contourFrequency:p,contourDirection:h,positionalLines:f,compensation:m,...S},x,S.mode,w,S.isMask,r)});ut("transmission",(i,t,e,r)=>{let n=Rt(e,r),o=new ee(he(n.thickness??10,r)),a=new ee(he(n.ior??1.5,r)),s=new ee(he(n.roughness??.5,r)),l=je.transmissionSize,c=je.transmissionRenderTarget,d=je.transmissionRenderTargetDepth,u=window.innerWidth,p=window.innerHeight,h=u>=p?new Kt(p/u,1):new Kt(1,u/p),f=Bt(n),m=new Uu(o,a,s,l,c,d,h,f.alpha),y=new Re(m.calpha,"f");return new He(i,t,e,{thickness:o,ior:a,roughness:s,aspectRatio:h,...f},m,f.mode,y,f.isMask,r)});var jL=!1;function yH(){jL||(jL=!0,console.warn("[spline] The reflection material layer requires the WebGPU renderer \u2014 it renders as invisible on the classic WebGL pipeline."))}ut("reflection",(i,t,e,r)=>{yH();let n=Rt(e,r),o=new ee(n.blur??0),a=new ee(n.thickness??10/1e4),s=new Fe(n.steps??60),l=new ee(n.stepSize??5/1e3),c=new Fe(n.tracingMode??1),d=Bt(n),u=new ot(0,0,0,1),p=new ee(0),h=new es(u,p),f=new Re(h.calpha,"f");return new He(i,t,e,{blur:o,thickness:a,steps:s,stepSize:l,tracingMode:c,...d},h,d.mode,f,d.isMask,r)});var Jb=require("three");ut("pattern",(i,t,e,r)=>{let n=Rt(e,r),o=new Fe(n.style??0),a=new Fe(n.projection??0),s=new Fe(["x","y","z"].indexOf(n.axis)??0),l=new ee(he(n.blending??0,r)),c=new Kt(eo(n.offset,r)),d=new On(n.colorA),u=new On(n.colorB),p=new Kt(eo(n.frequency??new Jb.Vector2(10,10),r)),h=new ee(he(n.size??.5,r)),f=new ee(he(n.variation??0,r)),m=new ee(he(n.smoothness??.5,r)),y=new ee(he(n.zigzag??0,r)),g=new ee(he(n.rotation??0,r)),v=new Kt(eo(n.vertical??new Jb.Vector2(0,1),r)),b=new Kt(eo(n.horizontal??new Jb.Vector2(0,1),r)),S=new Fe(n.sides??6),x=Bt(n),w=new ku(o,a,s,l,c,d,u,p,h,f,m,y,g,v,b,S,x.alpha,x.isMask),A=new Re(w.calpha,"f");return new He(i,t,e,{style:o,projection:a,axis:s,blending:l,offset:c,colorA:d,colorB:u,frequency:p,size:h,variation:f,smoothness:m,zigzag:y,rotation:g,vertical:v,horizontal:b,sides:S,...x},w,x.mode,A,x.isMask,r)});ut("vertexColor",(i,t,e,r)=>{let n=Rt(e,r),o=Bt(n),a=new zu(o.alpha),s=new Re(a.calpha,"f");return new He(i,t,e,{...o},a,o.mode,s,o.isMask,r)});a2({createRootMaterial:(i,t)=>new qu(i,t),createSharedMaterial:(i,t,e)=>new Kb(i,t,e)});u2((i,t)=>i?KN(t):ZN());c2(()=>{let i=new HL.ShadowMaterial;return i.depthWrite=!1,i.opacity=.5,i.onBeforeCompile=t=>{t.fragmentShader=`layout(location = 1) out vec4 gVelocity;
|
|
5242
5242
|
`+t.fragmentShader.replace("void main() {",`void main() {
|
|
5243
|
-
gVelocity = vec4(0.0);`)},i});var WL="The SplineLoader only accepts .splinecode files that are generated from Spline export panel.",$b=class extends ex.Loader{load(t,e,r,n=console.error){let o=new ex.FileLoader(this.manager);o.setPath(this.path),o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),t.endsWith(".spline")?console.warn(WL+" The .spline files are only meant to be used by the Editor."):t.endsWith(".splinecode")||console.warn(WL),o.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){n(s)}},r,a=>n(a))}async parse(t){let e=await mN(t,PL),r=yN(e);e.version&&"2.0.
|
|
5243
|
+
gVelocity = vec4(0.0);`)},i});var WL="The SplineLoader only accepts .splinecode files that are generated from Spline export panel.",$b=class extends ex.Loader{load(t,e,r,n=console.error){let o=new ex.FileLoader(this.manager);o.setPath(this.path),o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),t.endsWith(".spline")?console.warn(WL+" The .spline files are only meant to be used by the Editor."):t.endsWith(".splinecode")||console.warn(WL),o.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){n(s)}},r,a=>n(a))}async parse(t){let e=await mN(t,PL),r=yN(e);e.version&&"2.0.86"&&(0,qL.default)(e.version,"2.0.86")>0&&console.warn("Your .splinecode file is more recent than the library. Please upgrade @splinetool/loader to the latest version."),await Promise.allSettled([r.length&&fN(),Y2(e)&&ZM(),q0(e)&&sI(),YO(e)&&rg(),qb(e)&&MA()].filter(Boolean)),r.length&&await gN(r);let n=!1,o=new As(e.shared,{},n);Object.values(o.getMaterials()).forEach(l=>Object.assign(l,{isAsset:!0}));let a=new Qb(e.scene,o);qb(e)&&a.initializeSplatViewer();let s=a.activeCamera;return s&&Object.assign(s,{makeDefault:!0}),a=EL(a),a=SL(a),a=wL(a),a=AL(a),a=TL(a),a}};
|