@needle-tools/engine 4.11.1 → 4.11.3-next.ccd3ad6
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/CHANGELOG.md +8 -0
- package/dist/{needle-engine.bundle-BSk8yk3v.min.js → needle-engine.bundle-B5jHHYAr.min.js} +93 -93
- package/dist/{needle-engine.bundle-6yF8G5KJ.js → needle-engine.bundle-BzhDhLwp.js} +980 -956
- package/dist/{needle-engine.bundle-DPVYipMl.umd.cjs → needle-engine.bundle-DN-okHp8.umd.cjs} +82 -82
- package/dist/needle-engine.js +2 -2
- package/dist/needle-engine.min.js +1 -1
- package/dist/needle-engine.umd.cjs +1 -1
- package/dist/rapier-BqdcSmKY.umd.cjs +1 -0
- package/dist/rapier-Cg3w3nFI.min.js +1 -0
- package/dist/rapier-sU12SWAs.js +5217 -0
- package/dist/{vendor-DWGd3dEf.min.js → vendor-BahM12Xj.min.js} +1 -1
- package/dist/{vendor-DJBpoQcM.js → vendor-Becub4o1.js} +1 -1
- package/dist/{vendor-CAWj5cBK.umd.cjs → vendor-H-9KkM5B.umd.cjs} +1 -1
- package/lib/engine-components/Animation.d.ts +1 -1
- package/lib/engine-components/Animation.js +2 -2
- package/lib/engine-components/Animation.js.map +1 -1
- package/lib/engine-components/SeeThrough.js +5 -1
- package/lib/engine-components/SeeThrough.js.map +1 -1
- package/lib/engine-components/export/usdz/ThreeUSDZExporter.d.ts +5 -5
- package/lib/engine-components/export/usdz/ThreeUSDZExporter.js +16 -13
- package/lib/engine-components/export/usdz/ThreeUSDZExporter.js.map +1 -1
- package/lib/engine-components/export/usdz/USDZExporter.js +0 -1
- package/lib/engine-components/export/usdz/USDZExporter.js.map +1 -1
- package/lib/engine-components/export/usdz/extensions/behavior/BehaviourComponents.d.ts +8 -0
- package/lib/engine-components/export/usdz/extensions/behavior/BehaviourComponents.js +24 -0
- package/lib/engine-components/export/usdz/extensions/behavior/BehaviourComponents.js.map +1 -1
- package/lib/engine-components/splines/SplineWalker.js +3 -2
- package/lib/engine-components/splines/SplineWalker.js.map +1 -1
- package/lib/engine-components/web/Clickthrough.js.map +1 -1
- package/package.json +3 -3
- package/plugins/types/userconfig.d.ts +7 -0
- package/plugins/vite/build-pipeline.js +15 -7
- package/src/engine-components/Animation.ts +3 -2
- package/src/engine-components/SeeThrough.ts +5 -1
- package/src/engine-components/export/usdz/ThreeUSDZExporter.ts +27 -15
- package/src/engine-components/export/usdz/USDZExporter.ts +0 -1
- package/src/engine-components/export/usdz/extensions/behavior/BehaviourComponents.ts +28 -0
- package/src/engine-components/splines/SplineWalker.ts +3 -2
- package/src/engine-components/web/Clickthrough.ts +1 -0
- package/dist/rapier-BIeDFw5K.umd.cjs +0 -1
- package/dist/rapier-DQM98oaj.min.js +0 -1
- package/dist/rapier-DpcIWXum.js +0 -5217
|
@@ -1118,4 +1118,4 @@ void main() {
|
|
|
1118
1118
|
vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );
|
|
1119
1119
|
|
|
1120
1120
|
#include <fog_vertex>
|
|
1121
|
-
}`;class ad extends Fc{constructor(e){super(e),this.vector_=new G,this.vector2_=new G,this.vector3_=new G,this.quaternion_=new ie,this.maxParticles=1e4,this.setupBuffers(),this.rebuildMaterial()}setupBuffers(){this.geometry&&this.geometry.dispose(),this.geometry=new Yn,this.indexBuffer=new ot(new Uint32Array(this.maxParticles*6),1),this.indexBuffer.setUsage(He),this.geometry.setIndex(this.indexBuffer),this.positionBuffer=new ot(new Float32Array(this.maxParticles*6),3),this.positionBuffer.setUsage(He),this.geometry.setAttribute("position",this.positionBuffer),this.previousBuffer=new ot(new Float32Array(this.maxParticles*6),3),this.previousBuffer.setUsage(He),this.geometry.setAttribute("previous",this.previousBuffer),this.nextBuffer=new ot(new Float32Array(this.maxParticles*6),3),this.nextBuffer.setUsage(He),this.geometry.setAttribute("next",this.nextBuffer),this.widthBuffer=new ot(new Float32Array(this.maxParticles*2),1),this.widthBuffer.setUsage(He),this.geometry.setAttribute("width",this.widthBuffer),this.sideBuffer=new ot(new Float32Array(this.maxParticles*2),1),this.sideBuffer.setUsage(He),this.geometry.setAttribute("side",this.sideBuffer),this.uvBuffer=new ot(new Float32Array(this.maxParticles*4),2),this.uvBuffer.setUsage(He),this.geometry.setAttribute("uv",this.uvBuffer),this.colorBuffer=new ot(new Float32Array(this.maxParticles*8),4),this.colorBuffer.setUsage(He),this.geometry.setAttribute("color",this.colorBuffer)}expandBuffers(e){for(;e>=this.maxParticles;)this.maxParticles*=2;this.setupBuffers()}rebuildMaterial(){this.layers.mask=this.settings.layers.mask;const e={lineWidth:{value:1},map:{value:null},useMap:{value:0},alphaMap:{value:null},useAlphaMap:{value:0},resolution:{value:new Jn(1,1)},sizeAttenuation:{value:1},visibility:{value:1},alphaTest:{value:0}},t={};if(t.USE_UV="",t.USE_COLOR_ALPHA="",this.settings.material.map&&(t.USE_MAP="",t.MAP_UV=Ys(this.settings.material.map.channel),e.map=new Mt(this.settings.material.map),e.mapTransform=new Mt(new Dt().copy(this.settings.material.map.matrix))),this.settings.material.defines&&this.settings.material.defines.USE_COLOR_AS_ALPHA!==void 0&&(t.USE_COLOR_AS_ALPHA=""),this.settings.renderMode===V.Trail)this.material=new ps({uniforms:e,defines:t,vertexShader:od,fragmentShader:sd,transparent:this.settings.material.transparent,depthWrite:!this.settings.material.transparent,side:this.settings.material.side,blending:this.settings.material.blending||Ko,blendDst:this.settings.material.blendDst,blendSrc:this.settings.material.blendSrc,blendEquation:this.settings.material.blendEquation,premultipliedAlpha:this.settings.material.premultipliedAlpha});else throw new Error("render mode unavailable")}update(){let e=0,t=0,n=0;this.systems.forEach(i=>{for(let s=0;s<i.particleNum;s++)n+=i.particles[s].previous.length*2}),n>this.maxParticles&&this.expandBuffers(n),this.systems.forEach(i=>{i.emitter.updateMatrixWorld&&(i.emitter.updateWorldMatrix(!0,!1),i.emitter.updateMatrixWorld(!0));const s=this.quaternion_,a=this.vector2_,o=this.vector3_;i.emitter.matrixWorld.decompose(a,s,o);const c=i.particles,l=i.particleNum,u=this.settings.uTileCount,p=this.settings.vTileCount,f=1/u,m=1/p;for(let b=0;b<l;b++){const x=c[b],g=x.uvTile%p,v=Math.floor(x.uvTile/p+.001),_=x.previous.values();let w=_.next(),C=w.value,M=C;w.done||(w=_.next());let E;w.value!==void 0?E=w.value:E=M;for(let P=0;P<x.previous.length;P++,e+=2){if(this.positionBuffer.setXYZ(e,M.position.x,M.position.y,M.position.z),this.positionBuffer.setXYZ(e+1,M.position.x,M.position.y,M.position.z),i.worldSpace?(this.positionBuffer.setXYZ(e,M.position.x,M.position.y,M.position.z),this.positionBuffer.setXYZ(e+1,M.position.x,M.position.y,M.position.z)):(x.parentMatrix?this.vector_.copy(M.position).applyMatrix4(x.parentMatrix):this.vector_.copy(M.position).applyMatrix4(i.emitter.matrixWorld),this.positionBuffer.setXYZ(e,this.vector_.x,this.vector_.y,this.vector_.z),this.positionBuffer.setXYZ(e+1,this.vector_.x,this.vector_.y,this.vector_.z)),i.worldSpace?(this.previousBuffer.setXYZ(e,C.position.x,C.position.y,C.position.z),this.previousBuffer.setXYZ(e+1,C.position.x,C.position.y,C.position.z)):(x.parentMatrix?this.vector_.copy(C.position).applyMatrix4(x.parentMatrix):this.vector_.copy(C.position).applyMatrix4(i.emitter.matrixWorld),this.previousBuffer.setXYZ(e,this.vector_.x,this.vector_.y,this.vector_.z),this.previousBuffer.setXYZ(e+1,this.vector_.x,this.vector_.y,this.vector_.z)),i.worldSpace?(this.nextBuffer.setXYZ(e,E.position.x,E.position.y,E.position.z),this.nextBuffer.setXYZ(e+1,E.position.x,E.position.y,E.position.z)):(x.parentMatrix?this.vector_.copy(E.position).applyMatrix4(x.parentMatrix):this.vector_.copy(E.position).applyMatrix4(i.emitter.matrixWorld),this.nextBuffer.setXYZ(e,this.vector_.x,this.vector_.y,this.vector_.z),this.nextBuffer.setXYZ(e+1,this.vector_.x,this.vector_.y,this.vector_.z)),this.sideBuffer.setX(e,-1),this.sideBuffer.setX(e+1,1),i.worldSpace)this.widthBuffer.setX(e,M.size),this.widthBuffer.setX(e+1,M.size);else if(x.parentMatrix)this.widthBuffer.setX(e,M.size),this.widthBuffer.setX(e+1,M.size);else{const O=(Math.abs(o.x)+Math.abs(o.y)+Math.abs(o.z))/3;this.widthBuffer.setX(e,M.size*O),this.widthBuffer.setX(e+1,M.size*O)}this.uvBuffer.setXY(e,(P/x.previous.length+g)*f,(p-v-1)*m),this.uvBuffer.setXY(e+1,(P/x.previous.length+g)*f,(p-v)*m),this.colorBuffer.setXYZW(e,M.color.x,M.color.y,M.color.z,M.color.w),this.colorBuffer.setXYZW(e+1,M.color.x,M.color.y,M.color.z,M.color.w),P+1<x.previous.length&&(this.indexBuffer.setX(t*3,e),this.indexBuffer.setX(t*3+1,e+1),this.indexBuffer.setX(t*3+2,e+2),t++,this.indexBuffer.setX(t*3,e+2),this.indexBuffer.setX(t*3+1,e+1),this.indexBuffer.setX(t*3+2,e+3),t++),C=M,M=E,w.done||(w=_.next(),w.value!==void 0&&(E=w.value))}}}),this.positionBuffer.clearUpdateRanges(),this.positionBuffer.addUpdateRange(0,e*3),this.positionBuffer.needsUpdate=!0,this.previousBuffer.clearUpdateRanges(),this.previousBuffer.addUpdateRange(0,e*3),this.previousBuffer.needsUpdate=!0,this.nextBuffer.clearUpdateRanges(),this.nextBuffer.addUpdateRange(0,e*3),this.nextBuffer.needsUpdate=!0,this.sideBuffer.clearUpdateRanges(),this.sideBuffer.addUpdateRange(0,e),this.sideBuffer.needsUpdate=!0,this.widthBuffer.clearUpdateRanges(),this.widthBuffer.addUpdateRange(0,e),this.widthBuffer.needsUpdate=!0,this.uvBuffer.clearUpdateRanges(),this.uvBuffer.addUpdateRange(0,e*2),this.uvBuffer.needsUpdate=!0,this.colorBuffer.clearUpdateRanges(),this.colorBuffer.addUpdateRange(0,e*4),this.colorBuffer.needsUpdate=!0,this.indexBuffer.clearUpdateRanges(),this.indexBuffer.addUpdateRange(0,t*3),this.indexBuffer.needsUpdate=!0,this.geometry.setDrawRange(0,t*3)}dispose(){this.geometry.dispose()}}class Ki{get geometry(){return this._geometry}set geometry(e){if(this._geometry=e,e===void 0||typeof e=="string")return;const t=new un;this._triangleIndexToArea.length=0;let n=0;if(!e.getIndex())return;const i=e.getIndex().array,s=i.length/3;this._triangleIndexToArea.push(0);for(let a=0;a<s;a++)t.setFromAttributeAndIndices(e.getAttribute("position"),i[a*3],i[a*3+1],i[a*3+2]),n+=t.getArea(),this._triangleIndexToArea.push(n);e.userData.triangleIndexToArea=this._triangleIndexToArea}constructor(e){this.type="mesh_surface",this._triangleIndexToArea=[],this._tempA=new W,this._tempB=new W,this._tempC=new W,e&&(this.geometry=e)}initialize(e){const t=this._geometry;if(!t||t.getIndex()===null){e.position.set(0,0,0),e.velocity.set(0,0,1).multiplyScalar(e.startSpeed);return}const n=this._triangleIndexToArea.length-1;let i=0,s=n;const a=Math.random()*this._triangleIndexToArea[n];for(;i+1<s;){const m=Math.floor((i+s)/2);a<this._triangleIndexToArea[m]?s=m:i=m}let o=Math.random(),c=Math.random();o+c>1&&(o=1-o,c=1-c);const l=t.getIndex().array[i*3],u=t.getIndex().array[i*3+1],p=t.getIndex().array[i*3+2],f=t.getAttribute("position");this._tempA.fromBufferAttribute(f,l),this._tempB.fromBufferAttribute(f,u),this._tempC.fromBufferAttribute(f,p),this._tempB.sub(this._tempA),this._tempC.sub(this._tempA),this._tempA.addScaledVector(this._tempB,o).addScaledVector(this._tempC,c),e.position.copy(this._tempA),this._tempA.copy(this._tempB).cross(this._tempC).normalize(),e.velocity.copy(this._tempA).normalize().multiplyScalar(e.startSpeed)}toJSON(){return{type:"mesh_surface",mesh:this._geometry?this._geometry.uuid:""}}static fromJSON(e,t){return new Ki(t.geometries[e.geometry])}clone(){return new Ki(this._geometry)}update(e,t){}}Dh({id:"three.quarks",emitterShapes:[{type:"mesh_surface",params:[["geometry",["geometry"]]],constructor:Ki,loadJSON:Ki.fromJSON}],behaviors:[]});class To extends Yo{constructor(){super(),this.batches=[],this.systemToBatchIndex=new Map,this.type="BatchedRenderer",this.depthTexture=null}static equals(e,t){return e.material.side===t.material.side&&e.material.blending===t.material.blending&&e.material.blendSrc===t.material.blendSrc&&e.material.blendDst===t.material.blendDst&&e.material.blendEquation===t.material.blendEquation&&e.material.premultipliedAlpha===t.material.premultipliedAlpha&&e.material.transparent===t.material.transparent&&e.material.depthTest===t.material.depthTest&&e.material.type===t.material.type&&e.material.alphaTest===t.material.alphaTest&&e.material.map===t.material.map&&e.renderMode===t.renderMode&&e.blendTiles===t.blendTiles&&e.softParticles===t.softParticles&&e.softFarFade===t.softFarFade&&e.softNearFade===t.softNearFade&&e.uTileCount===t.uTileCount&&e.vTileCount===t.vTileCount&&e.instancingGeometry===t.instancingGeometry&&e.renderOrder===t.renderOrder&&e.layers.mask===t.layers.mask}addSystem(e){e._renderer=this;const t=e.getRendererSettings();for(let i=0;i<this.batches.length;i++)if(To.equals(this.batches[i].settings,t)){this.batches[i].addSystem(e),this.systemToBatchIndex.set(e,i);return}let n;switch(t.renderMode){case V.Trail:n=new ad(t);break;case V.Mesh:case V.BillBoard:case V.VerticalBillBoard:case V.HorizontalBillBoard:case V.StretchedBillBoard:n=new rd(t);break}this.depthTexture&&n.applyDepthTexture(this.depthTexture),n.addSystem(e),this.batches.push(n),this.systemToBatchIndex.set(e,this.batches.length-1),this.add(n)}deleteSystem(e){const t=this.systemToBatchIndex.get(e);t!=null&&(this.batches[t].removeSystem(e),this.systemToBatchIndex.delete(e))}setDepthTexture(e){this.depthTexture=e;for(const t of this.batches)t.applyDepthTexture(e)}updateSystem(e){this.deleteSystem(e),this.addSystem(e)}update(e){this.systemToBatchIndex.forEach((t,n)=>{n.update(e)});for(let t=0;t<this.batches.length;t++)this.batches[t].update()}}const cd=To;qh(),console.log("%c Particle system powered by three.quarks. https://quarks.art/","font-size: 14px; font-weight: bold;");const jc=Math.sqrt(5),ld=(jc-1)/4,Ne=(5-jc)/20,Cr=r=>Math.floor(r)|0,Er=new Float64Array([0,1,1,1,0,1,1,-1,0,1,-1,1,0,1,-1,-1,0,-1,1,1,0,-1,1,-1,0,-1,-1,1,0,-1,-1,-1,1,0,1,1,1,0,1,-1,1,0,-1,1,1,0,-1,-1,-1,0,1,1,-1,0,1,-1,-1,0,-1,1,-1,0,-1,-1,1,1,0,1,1,1,0,-1,1,-1,0,1,1,-1,0,-1,-1,1,0,1,-1,1,0,-1,-1,-1,0,1,-1,-1,0,-1,1,1,1,0,1,1,-1,0,1,-1,1,0,1,-1,-1,0,-1,1,1,0,-1,1,-1,0,-1,-1,1,0,-1,-1,-1,0]);function ud(r=Math.random){const e=hd(r),t=new Float64Array(e).map(a=>Er[a%32*4]),n=new Float64Array(e).map(a=>Er[a%32*4+1]),i=new Float64Array(e).map(a=>Er[a%32*4+2]),s=new Float64Array(e).map(a=>Er[a%32*4+3]);return function(a,o,c,l){let u,p,f,m,b;const x=(a+o+c+l)*ld,g=Cr(a+x),v=Cr(o+x),_=Cr(c+x),w=Cr(l+x),C=(g+v+_+w)*Ne,M=g-C,E=v-C,P=_-C,O=w-C,R=a-M,A=o-E,B=c-P,z=l-O;let D=0,F=0,H=0,q=0;R>A?D++:F++,R>B?D++:H++,R>z?D++:q++,A>B?F++:H++,A>z?F++:q++,B>z?H++:q++;const $=D>=3?1:0,J=F>=3?1:0,Se=H>=3?1:0,ce=q>=3?1:0,me=D>=2?1:0,le=F>=2?1:0,xe=H>=2?1:0,Ce=q>=2?1:0,ye=D>=1?1:0,pe=F>=1?1:0,oe=H>=1?1:0,nt=q>=1?1:0,je=R-$+Ne,Ye=A-J+Ne,it=B-Se+Ne,Oe=z-ce+Ne,fe=R-me+2*Ne,ae=A-le+2*Ne,lt=B-xe+2*Ne,Ee=z-Ce+2*Ne,ue=R-ye+3*Ne,Ze=A-pe+3*Ne,St=B-oe+3*Ne,bt=z-nt+3*Ne,Ke=R-1+4*Ne,xt=A-1+4*Ne,ut=B-1+4*Ne,ht=z-1+4*Ne,rt=g&255,Pe=v&255,Je=_&255,st=w&255;let Ge=.6-R*R-A*A-B*B-z*z;if(Ge<0)u=0;else{const re=rt+e[Pe+e[Je+e[st]]];Ge*=Ge,u=Ge*Ge*(t[re]*R+n[re]*A+i[re]*B+s[re]*z)}let ee=.6-je*je-Ye*Ye-it*it-Oe*Oe;if(ee<0)p=0;else{const re=rt+$+e[Pe+J+e[Je+Se+e[st+ce]]];ee*=ee,p=ee*ee*(t[re]*je+n[re]*Ye+i[re]*it+s[re]*Oe)}let wt=.6-fe*fe-ae*ae-lt*lt-Ee*Ee;if(wt<0)f=0;else{const re=rt+me+e[Pe+le+e[Je+xe+e[st+Ce]]];wt*=wt,f=wt*wt*(t[re]*fe+n[re]*ae+i[re]*lt+s[re]*Ee)}let Lt=.6-ue*ue-Ze*Ze-St*St-bt*bt;if(Lt<0)m=0;else{const re=rt+ye+e[Pe+pe+e[Je+oe+e[st+nt]]];Lt*=Lt,m=Lt*Lt*(t[re]*ue+n[re]*Ze+i[re]*St+s[re]*bt)}let _t=.6-Ke*Ke-xt*xt-ut*ut-ht*ht;if(_t<0)b=0;else{const re=rt+1+e[Pe+1+e[Je+1+e[st+1]]];_t*=_t,b=_t*_t*(t[re]*Ke+n[re]*xt+i[re]*ut+s[re]*ht)}return 27*(u+p+f+m+b)}}function hd(r){const e=new Uint8Array(512);for(let t=0;t<512/2;t++)e[t]=t;for(let t=0;t<512/2-1;t++){const n=t+~~(r()*(256-t)),i=e[t];e[t]=e[n],e[n]=i}for(let t=256;t<512;t++)e[t]=e[t-256];return e}var dd=Object.defineProperty,pd=(r,e,t)=>e in r?dd(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Te=(r,e,t)=>(pd(r,typeof e!="symbol"?e+"":e,t),t);(function(){class r{}class e extends r{constructor(d){super(),Te(this,"value"),this.value=d}}class t extends r{constructor(d){super(),Te(this,"value"),this.value=d}}class n extends r{constructor(d){super(),Te(this,"value"),this.value=d}}class i extends r{constructor(d,y="unrestricted"){super(),Te(this,"type"),Te(this,"value"),this.value=d,this.type=y}}class s extends r{constructor(d){super(),Te(this,"value"),this.value=d}}class a extends r{}class o extends r{constructor(d){super(),Te(this,"value"),this.value=d}}class c extends r{}class l extends r{constructor(d){super(),Te(this,"value"),this.value=d}}class u extends r{constructor(d,y="integer"){super(),Te(this,"value"),Te(this,"type"),this.value=d,this.type=y}}class p extends r{constructor(d){super(),Te(this,"value"),this.value=d}}class f extends r{constructor(d,y,S){super(),Te(this,"value"),Te(this,"type"),Te(this,"unit"),this.value=d,this.type=y,this.unit=S}}class m extends r{}class b extends r{}class x extends r{}class g extends r{}class v extends r{}class _ extends r{}class w extends r{}class C extends r{}class M extends r{}class E extends r{}class P extends r{}class O extends r{}class R{constructor(d){Te(this,"input"),Te(this,"index",0),this.input=d}consume(){const d=this.input.codePointAt(this.index);return d!==void 0&&(this.index+=String.fromCodePoint(d).length),d}reconsume(d){d!==void 0&&(this.index-=String.fromCodePoint(d).length)}peek(){const d=[];let y=this.index;for(let S=0;S<3&&y<this.input.length;S++){const T=this.input.codePointAt(y);d.push(T),y+=String.fromCodePoint(T).length}return d}}function A(h){return h===10}function B(h){return A(h)||h===8192||h===32}function z(h){return h>=48&&h<=57}function D(h){return z(h)||h>=65&&h<=70||h>=97&&h<=102}function F(h){return function(d){return function(y){return y>=65&&y<=90}(d)||function(y){return y>=97&&y<=122}(d)}(h)||function(d){return d>=128}(h)||h===95}function H(h){return F(h)||z(h)||h===45}function q(h){return h>=0&&h<=8||h===11||h>=14&&h<=31||h===127}function $(h,d){return h===92&&!A(d)}function J(h,d,y){return h===45?F(d)||d===45||$(d,y):!!F(h)||h===92&&$(h,d)}function Se(h,d,y){return h===43||h===45?z(d)||d===46&&z(y):z(h===46?d:h)}function ce(h){const d=h.consume();if(D(d)){let y=[d];for(;D(...h.peek())&&y.length<5;)y.push(h.consume());B(...h.peek())&&h.consume();const S=parseInt(String.fromCodePoint(...y),16);return S===0||S>1114111?65533:S}return d===void 0?65533:d}function me(h,d){const y=new s("");for(;;){const S=h.consume();if(S===d||S===void 0)return y;if(S===10)return h.reconsume(S),new a;if(S===92){const T=h.peek()[0];T===void 0||(A(T)?h.consume():y.value+=String.fromCodePoint(ce(h)))}else y.value+=String.fromCodePoint(S)}}function le(h){let d="";for(;;){const y=h.consume();if(H(y))d+=String.fromCodePoint(y);else{if(!$(...h.peek()))return h.reconsume(y),d;d+=String.fromCodePoint(ce(h))}}}function xe(h){let d=function(y){let S="integer",T="";for([43,45].includes(y.peek()[0])&&(T+=String.fromCodePoint(y.consume()));z(...y.peek());)T+=String.fromCodePoint(y.consume());if(y.peek()[0]===46&&z(y.peek()[1]))for(T+=String.fromCodePoint(y.consume(),y.consume()),S="number";z(...y.peek());)T+=String.fromCodePoint(y.consume());return[69,101].includes(y.peek()[0])&&([45,43].includes(y.peek()[1])&&z(y.peek()[2])?(T+=String.fromCodePoint(y.consume(),y.consume(),y.consume()),S="number"):z(y.peek()[1])&&(T+=String.fromCodePoint(y.consume(),y.consume()),S="number")),{value:parseFloat(T),type:S}}(h);return J(...h.peek())?new f(d.value,d.type,le(h)):h.peek()[0]===37?(h.consume(),new p(d.value)):new u(d.value,d.type)}function Ce(h){for(;;){const d=h.consume();if(d===41||d===void 0)return;$(...h.peek())&&ce(h)}}function ye(h){const d=le(h);if(d.match(/url/i)&&h.peek()[0]===40){for(h.consume();B(h.peek()[0])&&B(h.peek()[1]);)h.consume();return[34,39].includes(h.peek()[0])||B(h.peek()[0])&&[34,39].includes(h.peek()[1])?new t(d):function(y){const S=new o("");for(;B(...y.peek());)y.consume();for(;;){const T=y.consume();if(T===41||T===void 0)return S;if(B(T)){for(;B(...y.peek());)y.consume();return y.peek()[0]===41||y.peek()[0]===void 0?(y.consume(),S):(Ce(y),new c)}if([34,39,40].includes(T)||q(T))return Ce(y),new c;if(T===92){if(!$(...y.peek()))return Ce(y),new c;S.value+=ce(y)}else S.value+=String.fromCodePoint(T)}}(h)}return h.peek()[0]===40?(h.consume(),new t(d)):new e(d)}function pe(h){const d=h.consume(),y=h.peek();if(B(d)){for(;B(...h.peek());)h.consume();return new m}if(d===34)return me(h,d);if(d===35){if(H(y[0])||$(...y)){const S=new i;return J(...y)&&(S.type="id"),S.value=le(h),S}return new l(String.fromCodePoint(d))}return d===39?me(h,d):d===40?new M:d===41?new E:d===43?Se(...y)?(h.reconsume(d),xe(h)):new l(String.fromCodePoint(d)):d===44?new _:d===45?Se(...h.peek())?(h.reconsume(d),xe(h)):h.peek()[0]===45&&h.peek()[1]===62?(h.consume(),h.consume(),new x):J(...h.peek())?(h.reconsume(d),ye(h)):new l(String.fromCodePoint(d)):d===46?Se(...h.peek())?(h.reconsume(d),xe(h)):new l(String.fromCodePoint(d)):d===58?new g:d===59?new v:d===60?y[0]===33&&y[1]===45&&y[2]===45?(h.consume(),h.consume(),h.consume(),new b):new l(String.fromCodePoint(d)):d===64?J(...y)?new n(le(h)):new l(String.fromCodePoint(d)):d===91?new w:d===92?$(...y)?(h.reconsume(d),ye(h)):new l(String.fromCodePoint(d)):d===93?new C:d===123?new P:d===125?new O:z(d)?(h.reconsume(d),xe(h)):F(d)?(h.reconsume(d),ye(h)):d===void 0?void 0:new l(String.fromCodePoint(d))}const oe=new Set(["px","deg","s","hz","dppx","number","fr"]);function nt(h){return oe.has(h.toLowerCase())}function je(h,d){if(["x","y"].includes(h))return h;if(!d)throw new Error("To determine the normalized axis the computedStyle of the source is required.");const y=d.writingMode=="horizontal-tb";if(h==="block")h=y?"y":"x";else{if(h!=="inline")throw new TypeError(`Invalid axis \u201C${h}\u201D`);h=y?"x":"y"}return h}function Ye(h){const d=[];let y=0;function S(){let k=0;const I=y;for(;y<h.length;){const U=h.slice(y,y+1);if(/\s/.test(U)&&k===0)break;if(U==="(")k+=1;else if(U===")"&&(k-=1,k===0)){y++;break}y++}return h.slice(I,y)}function T(){for(;/\s/.test(h.slice(y,y+1));)y++}for(;y<h.length;){const k=h.slice(y,y+1);/\s/.test(k)?T():d.push(S())}return d}function it(h,d){return h.reduce((y,S)=>(y.has(S[d])?y.get(S[d]).push(S):y.set(S[d],[S]),y),new Map)}function Oe(h,d){const y=[],S=[];for(const T of h)d(T)?y.push(T):S.push(T);return[y,S]}function fe(h,d={}){function y(S){return Array.from(S).map(T=>fe(T,d))}if(h instanceof CSSUnitValue){if(h.unit==="percent"&&d.percentageReference){const T=h.value/100*d.percentageReference.value,k=d.percentageReference.unit;return new CSSUnitValue(T,k)}const S=h.toSum();if(S&&S.values.length===1&&(h=S.values[0]),h instanceof CSSUnitValue&&h.unit==="em"&&d.fontSize&&(h=new CSSUnitValue(h.value*d.fontSize.value,d.fontSize.unit)),h instanceof CSSKeywordValue){if(h.value==="e")return new CSSUnitValue(Math.E,"number");if(h.value==="pi")return new CSSUnitValue(Math.PI,"number")}return h}if(!h.operator)return h;switch(h.operator){case"sum":h=new CSSMathSum(...y(h.values));break;case"product":h=new CSSMathProduct(...y(h.values));break;case"negate":h=new CSSMathNegate(fe(h.value,d));break;case"clamp":h=new CSSMathClamp(fe(h.lower,d),fe(h.value,d),fe(h.upper,d));break;case"invert":h=new CSSMathInvert(fe(h.value,d));break;case"min":h=new CSSMathMin(...y(h.values));break;case"max":h=new CSSMathMax(...y(h.values))}if(h instanceof CSSMathMin||h instanceof CSSMathMax){const S=Array.from(h.values);if(S.every(T=>T instanceof CSSUnitValue&&T.unit!=="percent"&&nt(T.unit)&&T.unit===S[0].unit)){const T=Math[h.operator].apply(Math,S.map(({value:k})=>k));return new CSSUnitValue(T,S[0].unit)}}if(h instanceof CSSMathMin||h instanceof CSSMathMax){const S=Array.from(h.values),[T,k]=Oe(S,U=>U instanceof CSSUnitValue&&U.unit!=="percent"),I=Array.from(it(T,"unit").values());if(I.some(U=>U.length>0)){const U=I.map(N=>{const L=Math[h.operator].apply(Math,N.map(({value:X})=>X));return new CSSUnitValue(L,N[0].unit)});h=h instanceof CSSMathMin?new CSSMathMin(...U,...k):new CSSMathMax(...U,...k)}return S.length===1?S[0]:h}if(h instanceof CSSMathNegate)return h.value instanceof CSSUnitValue?new CSSUnitValue(0-h.value.value,h.value.unit):h.value instanceof CSSMathNegate?h.value.value:h;if(h instanceof CSSMathInvert)return h.value instanceof CSSMathInvert?h.value.value:h;if(h instanceof CSSMathSum){let S=function(k){const I=k.filter(U=>U instanceof CSSUnitValue);return[...k.filter(U=>!(U instanceof CSSUnitValue)),...Array.from(it(I,"unit").entries()).map(([U,N])=>{const L=N.reduce((X,{value:Z})=>X+Z,0);return new CSSUnitValue(L,U)})]},T=[];for(const k of h.values)k instanceof CSSMathSum?T.push(...k.values):T.push(k);return T=S(T),T.length===1?T[0]:new CSSMathSum(...T)}if(h instanceof CSSMathProduct){let S=[];for(const I of h.values)I instanceof CSSMathProduct?S.push(...I.values):S.push(I);const[T,k]=Oe(S,I=>I instanceof CSSUnitValue&&I.unit==="number");if(T.length>1){const I=T.reduce((U,{value:N})=>U*N,1);S=[new CSSUnitValue(I,"number"),...k]}if(S.length===2){let I,U;for(const N of S)N instanceof CSSUnitValue&&N.unit==="number"?I=N:N instanceof CSSMathSum&&[...N.values].every(L=>L instanceof CSSUnitValue)&&(U=N);if(I&&U)return new CSSMathSum(...[...U.values].map(N=>new CSSUnitValue(N.value*I.value,N.unit)))}if(S.every(I=>I instanceof CSSUnitValue&&nt(I.unit)||I instanceof CSSMathInvert&&I.value instanceof CSSUnitValue&&nt(I.value.unit))){const I=new CSSMathProduct(...S).toSum();if(I&&I.values.length===1)return I.values[0]}return new CSSMathProduct(...S)}return h}const ae=null,lt=["percent","length","angle","time","frequency","resolution","flex"],Ee={fontRelativeLengths:{units:new Set(["em","rem","ex","rex","cap","rcap","ch","rch","ic","ric","lh","rlh"])},viewportRelativeLengths:{units:new Set(["vw","lvw","svw","dvw","vh","lvh","svh","dvh","vi","lvi","svi","dvi","vb","lvb","svb","dvb","vmin","lvmin","svmin","dvmin","vmax","lvmax","svmax","dvmax"])},absoluteLengths:{units:new Set(["cm","mm","Q","in","pt","pc","px"]),compatible:!0,canonicalUnit:"px",ratios:{cm:96/2.54,mm:96/2.54/10,Q:96/2.54/40,in:96,pc:16,pt:96/72,px:1}},angle:{units:new Set(["deg","grad","rad","turn"]),compatible:!0,canonicalUnit:"deg",ratios:{deg:1,grad:.9,rad:180/Math.PI,turn:360}},time:{units:new Set(["s","ms"]),compatible:!0,canonicalUnit:"s",ratios:{s:1,ms:.001}},frequency:{units:new Set(["hz","khz"]),compatible:!0,canonicalUnit:"hz",ratios:{hz:1,khz:1e3}},resolution:{units:new Set(["dpi","dpcm","dppx"]),compatible:!0,canonicalUnit:"dppx",ratios:{dpi:1/96,dpcm:2.54/96,dppx:1}}},ue=new Map;for(const h of Object.values(Ee))if(h.compatible)for(const d of h.units)ue.set(d,h);function Ze(h){return ue.get(h)}function St(h,d){const y={...h};for(const S of Object.keys(d))y[S]?y[S]+=d[S]:y[S]=d[S];return y}function bt(h){return h==="number"?{}:h==="percent"?{percent:1}:Ee.absoluteLengths.units.has(h)||Ee.fontRelativeLengths.units.has(h)||Ee.viewportRelativeLengths.units.has(h)?{length:1}:Ee.angle.units.has(h)?{angle:1}:Ee.time.units.has(h)?{time:1}:Ee.frequency.units.has(h)?{frequency:1}:Ee.resolution.units.has(h)?{resolution:1}:h==="fr"?{flex:1}:ae}function Ke(h){if(h instanceof CSSUnitValue){let{unit:d,value:y}=h;const S=Ze(h.unit);return S&&d!==S.canonicalUnit&&(y*=S.ratios[d],d=S.canonicalUnit),d==="number"?[[y,{}]]:[[y,{[d]:1}]]}if(h instanceof CSSMathInvert){if(!(h.value instanceof CSSUnitValue))throw new Error("Not implemented");const d=Ke(h.value);if(d===ae||d.length>1)return ae;const y=d[0],S={};for(const[T,k]of Object.entries(y[1]))S[T]=-1*k;return d[0]=[1/y[0],S],d}if(h instanceof CSSMathProduct){let d=[[1,{}]];for(const y of h.values){const S=Ke(y),T=[];if(S===ae)return ae;for(const k of d)for(const I of S)T.push([k[0]*I[0],St(k[1],I[1])]);d=T}return d}throw new Error("Not implemented")}function xt(h,d){if(bt(d)===ae)throw new SyntaxError("The string did not match the expected pattern.");const y=Ke(h);if(!y)throw new TypeError;if(y.length>1)throw new TypeError("Sum has more than one item");const S=function(T,k){const I=T.unit,U=T.value,N=Ze(I),L=Ze(k);return!L||N!==L?ae:new CSSUnitValue(U*L.ratios[I]/L.ratios[k],k)}(ut(y[0]),d);if(S===ae)throw new TypeError;return S}function ut(h){const[d,y]=h,S=Object.entries(y);if(S.length>1)return ae;if(S.length===0)return new CSSUnitValue(d,"number");const T=S[0];return T[1]!==1?ae:new CSSUnitValue(d,T[0])}function ht(h,...d){if(d&&d.length)throw new Error("Not implemented");const y=Ke(h).map(S=>ut(S));if(y.some(S=>S===ae))throw new TypeError("Type error");return new CSSMathSum(...y)}function rt(h,d){if(h.percentHint&&d.percentHint&&h.percentHint!==d.percentHint)return ae;const y={...h,percentHint:h.percentHint??d.percentHint};for(const S of lt)d[S]&&(y[S]??(y[S]=0),y[S]+=d[S]);return y}class Pe{constructor(d,y){Te(this,"name"),Te(this,"values"),this.name=d,this.values=y}}class Je{constructor(d,y){Te(this,"value"),Te(this,"associatedToken"),this.value=d,this.associatedToken=y}}function st(h){if(Array.isArray(h))return h;if(typeof h=="string")return function(d){const y=new R(d),S=[];for(;;){const T=pe(y);if(T===void 0)return S;S.push(T)}}(h);throw new TypeError("Invalid input type "+typeof h)}function Ge(h){const d=h.shift();return d instanceof P||d instanceof w||d instanceof M?function(y,S){let T;if(S instanceof P)T=O;else if(S instanceof M)T=E;else{if(!(S instanceof w))return;T=C}const k=new Je([],S);for(;;){const I=y.shift();if(I instanceof T||I===void 0)return k;y.unshift(I),k.value.push(Ge(y))}}(h,d):d instanceof t?function(y,S){const T=new Pe(y.value,[]);for(;;){const k=S.shift();if(k instanceof E||k===void 0)return T;S.unshift(k),T.values.push(Ge(S))}}(d,h):d}function ee(h){if(h instanceof M||h instanceof E)return 6;if(h instanceof l)switch(h.value){case"*":case"/":return 4;case"+":case"-":return 2}}function wt(h){return h[h.length-1]}function Lt(h,d,y){const S=["+","-"].includes(h.value)?"ADDITION":"MULTIPLICATION",T=d.type===S?d.values:[d],k=y.type===S?y.values:[y];return h.value==="-"?k[0]={type:"NEGATE",value:k[0]}:h.value==="/"&&(k[0]={type:"INVERT",value:k[0]}),{type:S,values:[...T,...k]}}function _t(h){if(h.type==="ADDITION")return new CSSMathSum(...h.values.map(d=>_t(d)));if(h.type==="MULTIPLICATION")return new CSSMathProduct(...h.values.map(d=>_t(d)));if(h.type==="NEGATE")return new CSSMathNegate(_t(h.value));if(h.type==="INVERT")return new CSSMathInvert(_t(h.value));if(h instanceof Je)return re(new Pe("calc",h.value));if(h instanceof e){if(h.value==="e")return new CSSUnitValue(Math.E,"number");if(h.value==="pi")return new CSSUnitValue(Math.PI,"number");throw new SyntaxError("Invalid math expression")}return Mo(h)}function re(h){if(h.name==="min"||h.name==="max"){const S=h.values.filter(T=>!(T instanceof m||T instanceof _)).map(T=>fe(re(new Pe("calc",T))));return h.name==="min"?new CSSMathMin(...S):new CSSMathMax(...S)}if(h.name!=="calc")return null;const d=_t(function(S){const T=[],k=[];for(;S.length;){const I=S.shift();if(I instanceof u||I instanceof f||I instanceof p||I instanceof Pe||I instanceof Je||I instanceof e)k.push(I);else if(I instanceof l&&["*","/","+","-"].includes(I.value)){for(;T.length&&!(wt(T)instanceof M)&&ee(wt(T))>ee(I);){const U=T.pop(),N=k.pop(),L=k.pop();k.push(Lt(U,L,N))}T.push(I)}else if(I instanceof M)T.push(I);else if(I instanceof E){if(!T.length)return null;for(;!(wt(T)instanceof M);){const U=T.pop(),N=k.pop(),L=k.pop();k.push(Lt(U,L,N))}if(!(wt(T)instanceof M))return null;T.pop()}else if(!(I instanceof m))return null}for(;T.length;){if(wt(T)instanceof M)return null;const I=T.pop(),U=k.pop(),N=k.pop();k.push(Lt(I,N,U))}return k[0]}([...h.values]));let y;try{y=fe(d)}catch{new CSSStyleSheet().insertRule("error",0)}return y instanceof CSSUnitValue?new CSSMathSum(y):y}function Mo(h){return h instanceof Pe&&["calc","min","max","clamp"].includes(h.name)?re(h):h instanceof u&&h.value===0&&!h.unit?new CSSUnitValue(0,"px"):h instanceof u?new CSSUnitValue(h.value,"number"):h instanceof p?new CSSUnitValue(h.value,"percent"):h instanceof f?new CSSUnitValue(h.value,h.unit):void 0}function vl(h){const d=function(y){const S=st(y);for(;S[0]instanceof m;)S.shift();if(S[0]===void 0)return null;const T=Ge(S);for(;S[0]instanceof m;)S.shift();return S[0]===void 0?T:null}(h);return d===null&&new CSSStyleSheet().insertRule("error",0),d instanceof u||d instanceof p||d instanceof f||d instanceof Pe||new CSSStyleSheet().insertRule("error",0),d instanceof f&&bt(d.unit)===null&&new CSSStyleSheet().insertRule("error",0),Mo(d)}(function(){let h=new WeakMap;function d(k){const I=[];for(let N=0;N<k.length;N++)I[N]=typeof(U=k[N])=="number"?new CSSUnitValue(U,"number"):U;var U;return I}class y{static parse(I){return I instanceof y?I:fe(vl(I),{})}}class S extends y{constructor(I,U,N,L){super(),h.set(this,{values:d(I),operator:U,name:N||U,delimiter:L||", "})}get operator(){return h.get(this).operator}get values(){return h.get(this).values}toString(){const I=h.get(this);return`${I.name}(${I.values.join(I.delimiter)})`}}const T={CSSNumericValue:y,CSSMathValue:S,CSSUnitValue:class extends y{constructor(k,I){super(),h.set(this,{value:k,unit:I})}get value(){return h.get(this).value}set value(k){h.get(this).value=k}get unit(){return h.get(this).unit}to(k){return xt(this,k)}toSum(...k){return ht(this,...k)}type(){return bt(h.get(this).unit)}toString(){const k=h.get(this);return`${k.value}${function(I){switch(I){case"percent":return"%";case"number":return"";default:return I.toLowerCase()}}(k.unit)}`}},CSSKeywordValue:class{constructor(k){this.value=k}toString(){return this.value.toString()}},CSSMathSum:class extends S{constructor(k){super(arguments,"sum","calc"," + ")}},CSSMathProduct:class extends S{constructor(k){super(arguments,"product","calc"," * ")}toSum(...k){return ht(this,...k)}type(){return h.get(this).values.map(k=>k.type()).reduce(rt)}},CSSMathNegate:class extends S{constructor(k){super([arguments[0]],"negate","-")}get value(){return h.get(this).values[0]}type(){return this.value.type()}},CSSMathInvert:class extends S{constructor(k){super([1,arguments[0]],"invert","calc"," / ")}get value(){return h.get(this).values[1]}type(){return function(k){const I={};for(const U of lt)I[U]=-1*k[U];return I}(h.get(this).values[1].type())}},CSSMathMax:class extends S{constructor(){super(arguments,"max")}},CSSMathMin:class extends S{constructor(){super(arguments,"min")}}};if(!window.CSS&&!Reflect.defineProperty(window,"CSS",{value:{}}))throw Error("Error installing CSSOM support");window.CSSUnitValue||["number","percent","em","ex","px","cm","mm","in","pt","pc","Q","vw","vh","vmin","vmax","rems","ch","deg","rad","grad","turn","ms","s","Hz","kHz","dppx","dpi","dpcm","fr"].forEach(k=>{if(!Reflect.defineProperty(CSS,k,{value:I=>new CSSUnitValue(I,k)}))throw Error(`Error installing CSS.${k}`)});for(let[k,I]of Object.entries(T))if(!(k in window)&&!Reflect.defineProperty(window,k,{value:I}))throw Error(`Error installing CSSOM support for ${k}`)})();const Co="block";let De=new WeakMap,Ft=new WeakMap;const Qi=["entry","exit","cover","contain","entry-crossing","exit-crossing"];function Eo(h){return h===document.scrollingElement?document:h}function an(h){es(h);let d=De.get(h).animations;if(d.length===0)return;let y=h.currentTime;for(let S=0;S<d.length;S++)d[S].tickAnimation(y)}function Po(h,d){if(!h)return null;const y=Ft.get(h).sourceMeasurements,S=getComputedStyle(h);let T=y.scrollTop;return je(d,S)==="x"&&(T=Math.abs(y.scrollLeft)),T}function $r(h,d){const y=fe(h,d);if(y instanceof CSSUnitValue){if(y.unit==="px")return y.value;throw TypeError("Unhandled unit type "+y.unit)}throw TypeError("Unsupported value type: "+typeof h)}function es(h){if(!(h instanceof Mn))return void function(y){const S=De.get(y);if(!S.anonymousSource)return;const T=Ro(S.anonymousSource,S.anonymousTarget);Hn(y,T)}(h);const d=h.subject;if(!d||getComputedStyle(d).display=="none")return void Hn(h,null);Hn(h,os(d))}function ko(h){return["block","inline","x","y"].includes(h)}function ts(h){const d=getComputedStyle(h);return{scrollLeft:h.scrollLeft,scrollTop:h.scrollTop,scrollWidth:h.scrollWidth,scrollHeight:h.scrollHeight,clientWidth:h.clientWidth,clientHeight:h.clientHeight,writingMode:d.writingMode,direction:d.direction,scrollPaddingTop:d.scrollPaddingTop,scrollPaddingBottom:d.scrollPaddingBottom,scrollPaddingLeft:d.scrollPaddingLeft,scrollPaddingRight:d.scrollPaddingRight}}function ns(h,d){if(!h||!d)return;let y=0,S=0,T=d;const k=h.offsetParent;for(;T&&T!=k;)S+=T.offsetLeft,y+=T.offsetTop,T=T.offsetParent;S-=h.offsetLeft+h.clientLeft,y-=h.offsetTop+h.clientTop;const I=getComputedStyle(d);return{top:y,left:S,offsetWidth:d.offsetWidth,offsetHeight:d.offsetHeight,fontSize:I.fontSize}}function $i(h){let d=Ft.get(h);d.sourceMeasurements=ts(h);for(const y of d.timelineRefs){const S=y.deref();S instanceof Mn&&(De.get(S).subjectMeasurements=ns(h,S.subject))}d.updateScheduled||(setTimeout(()=>{for(const y of d.timelineRefs){const S=y.deref();S&&an(S)}d.updateScheduled=!1}),d.updateScheduled=!0)}function Hn(h,d){const y=De.get(h),S=y.source;if(S!=d){if(S){const T=Ft.get(S);if(T){T.timelineRefs.delete(h);const k=Array.from(T.timelineRefs).filter(I=>I.deref()===void 0);for(const I of k)T.timelineRefs.delete(I);T.timelineRefs.size===0&&(T.disconnect(),Ft.delete(S))}}if(y.source=d,d){let T=Ft.get(d);if(!T){T={timelineRefs:new Set,sourceMeasurements:ts(d)},Ft.set(d,T);const k=new ResizeObserver(N=>{for(const L of N)$i(y.source)});k.observe(d);for(const N of d.children)k.observe(N);const I=new MutationObserver(N=>{for(const L of N)$i(L.target)});I.observe(d,{attributes:!0,attributeFilter:["style","class"]});const U=()=>{T.sourceMeasurements.scrollLeft=d.scrollLeft,T.sourceMeasurements.scrollTop=d.scrollTop;for(const N of T.timelineRefs){const L=N.deref();L&&an(L)}};Eo(d).addEventListener("scroll",U),T.disconnect=()=>{k.disconnect(),I.disconnect(),Eo(d).removeEventListener("scroll",U)}}T.timelineRefs.add(new WeakRef(h))}}}function is(h,d){let y=De.get(h).animations;for(let S=0;S<y.length;S++)y[S].animation==d&&y.splice(S,1)}function rs(h,d,y){let S=De.get(h).animations;for(let T=0;T<S.length;T++)if(S[T].animation==d)return;S.push({animation:d,tickAnimation:y}),queueMicrotask(()=>{an(h)})}class We{constructor(d){if(De.set(this,{source:null,axis:Co,anonymousSource:d?d.anonymousSource:null,anonymousTarget:d?d.anonymousTarget:null,subject:null,inset:null,animations:[],subjectMeasurements:null}),Hn(this,d&&d.source!==void 0?d.source:document.scrollingElement),d&&d.axis!==void 0&&d.axis!=Co){if(!ko(d.axis))throw TypeError("Invalid axis");De.get(this).axis=d.axis}an(this)}set source(d){Hn(this,d),an(this)}get source(){return De.get(this).source}set axis(d){if(!ko(d))throw TypeError("Invalid axis");De.get(this).axis=d,an(this)}get axis(){return De.get(this).axis}get duration(){return CSS.percent(100)}get phase(){const d=this.source;if(!d)return"inactive";let y=getComputedStyle(d);return y.display=="none"?"inactive":d==document.scrollingElement||y.overflow!="visible"&&y.overflow!="clip"?"active":"inactive"}get currentTime(){const d=this.source;if(!d||!d.isConnected||this.phase=="inactive")return null;const y=getComputedStyle(d);if(y.display==="inline"||y.display==="none")return null;const S=this.axis,T=Po(d,S),k=function(I,U){const N=Ft.get(I).sourceMeasurements,L=getComputedStyle(I).writingMode=="horizontal-tb";return U==="block"?U=L?"y":"x":U==="inline"&&(U=L?"x":"y"),U==="y"?N.scrollHeight-N.clientHeight:U==="x"?N.scrollWidth-N.clientWidth:void 0}(d,S);return k>0?CSS.percent(100*T/k):CSS.percent(100)}get __polyfill(){return!0}}function ss(h,d){let y=h.parentElement;for(;y!=null;){if(d(y))return y;y=y.parentElement}}function Ro(h,d){switch(h){case"root":return document.scrollingElement;case"nearest":return os(d);case"self":return d;default:throw new TypeError("Invalid ScrollTimeline Source Type.")}}function Sl(h){switch(getComputedStyle(h).display){case"block":case"inline-block":case"list-item":case"table":case"table-caption":case"flow-root":case"flex":case"grid":return!0}return!1}function Ao(h){const d=getComputedStyle(h);return d.transform!="none"||d.perspective!="none"||d.willChange=="transform"||d.willChange=="perspective"||d.filter!="none"||d.willChange=="filter"||d.backdropFilter!="none"}function bl(h){return getComputedStyle(h).position!="static"||Ao(h)}function xl(h){switch(getComputedStyle(h).position){case"static":case"relative":case"sticky":return ss(h,Sl);case"absolute":return ss(h,bl);case"fixed":return ss(h,Ao)}}function os(h){if(h&&h.isConnected){for(;h=xl(h);)switch(getComputedStyle(h)["overflow-x"]){case"auto":case"scroll":case"hidden":return h==document.body&&getComputedStyle(document.scrollingElement).overflow=="visible"?document.scrollingElement:h}return document.scrollingElement}}function qn(h,d){const y=De.get(h),S=y.subjectMeasurements,T=Ft.get(y.source).sourceMeasurements;return h.phase==="inactive"?null:h instanceof Mn?as(d,T,S,y.axis,y.inset):null}function as(h,d,y,S,T){const k=d.direction=="rtl"||d.writingMode=="vertical-rl";let I,U,N={fontSize:y.fontSize};je(S,d)==="x"?(I=y.offsetWidth,U=y.left,N.scrollPadding=[d.scrollPaddingLeft,d.scrollPaddingRight],k&&(U+=d.scrollWidth-d.clientWidth,N.scrollPadding=[d.scrollPaddingRight,d.scrollPaddingLeft]),N.containerSize=d.clientWidth):(I=y.offsetHeight,U=y.top,N.scrollPadding=[d.scrollPaddingTop,d.scrollPaddingBottom],N.containerSize=d.clientHeight);const L=function(hs,rr){const Il={start:0,end:0};if(!hs)return Il;const[zl,Bl]=[hs.start,hs.end].map((Ho,qo)=>Ho==="auto"?rr.scrollPadding[qo]==="auto"?0:parseFloat(rr.scrollPadding[qo]):$r(Ho,{percentageReference:CSS.px(rr.containerSize),fontSize:CSS.px(parseFloat(rr.fontSize))}));return{start:zl,end:Bl}}(T,N),X=U-N.containerSize+L.end,Z=U+I-L.start,K=X+I,he=Z-I,we=Math.min(K,he),Qe=Math.max(K,he);let Tt,dt;const Wo=I>N.containerSize-L.start-L.end;switch(h){case"cover":Tt=X,dt=Z;break;case"contain":Tt=we,dt=Qe;break;case"entry":Tt=X,dt=we;break;case"exit":Tt=Qe,dt=Z;break;case"entry-crossing":Tt=X,dt=Wo?Qe:we;break;case"exit-crossing":Tt=Wo?we:Qe,dt=Z}return{start:Tt,end:dt}}function Oo(h,d){if(h instanceof Mn){const{rangeName:y,offset:S}=d;return Io(qn(h,y),S,qn(h,"cover"),h.subject)}if(h instanceof We){const{axis:y,source:S}=h,{sourceMeasurements:T}=Ft.get(S);let k;return k=je(y,T)==="x"?T.scrollWidth-T.clientWidth:T.scrollHeight-T.clientHeight,$r(d,{percentageReference:CSS.px(k)})/k}unsupportedTimeline(h)}function Io(h,d,y,S){if(!h||!y)return 0;let T=getComputedStyle(S);return($r(d,{percentageReference:CSS.px(h.end-h.start),fontSize:CSS.px(parseFloat(T.fontSize))})+h.start-y.start)/(y.end-y.start)}let Mn=class extends We{constructor(h){super(h);const d=De.get(this);d.subject=h&&h.subject?h.subject:void 0,h&&h.inset&&(d.inset=function(y){if(!y)return{start:0,end:0};let S;if(S=typeof y=="string"?Ye(y).map(T=>{if(T==="auto")return"auto";try{return CSSNumericValue.parse(T)}catch{throw TypeError(`Could not parse inset "${y}"`)}}):Array.isArray(y)?y:[y],S.length===0||S.length>2)throw TypeError("Invalid inset");for(const T of S){if(T==="auto")continue;const k=T.type();if(k.length!==1&&k.percent!==1)throw TypeError("Invalid inset")}return{start:S[0],end:S[1]??S[0]}}(h.inset)),d.subject&&(new ResizeObserver(()=>{$i(d.source)}).observe(d.subject),new MutationObserver(()=>{$i(d.source)}).observe(d.subject,{attributes:!0,attributeFilter:["class","style"]})),es(this),d.subjectMeasurements=ns(d.source,d.subject),an(this)}get source(){return es(this),De.get(this).source}set source(h){throw new Error("Cannot set the source of a view timeline")}get subject(){return De.get(this).subject}get axis(){return De.get(this).axis}get currentTime(){const h=Po(this.source,this.axis);if(h==null)return null;const d=qn(this,"cover");if(!d)return null;const y=(h-d.start)/(d.end-d.start);return CSS.percent(100*y)}get startOffset(){return CSS.px(qn(this,"cover").start)}get endOffset(){return CSS.px(qn(this,"cover").end)}};const wl=document.getAnimations,_l=window.Element.prototype.getAnimations,Tl=window.Element.prototype.animate,zo=window.Animation;class Cn{constructor(){this.state="pending",this.nativeResolve=this.nativeReject=null,this.promise=new Promise((d,y)=>{this.nativeResolve=d,this.nativeReject=y})}resolve(d){this.state="resolved",this.nativeResolve(d)}reject(d){this.state="rejected",this.promise.catch(()=>{}),this.nativeReject(d)}}function Xn(h){h.readyPromise=new Cn,requestAnimationFrame(()=>{var d;(((d=h.timeline)==null?void 0:d.currentTime)??null)!==null&&(er(h),h.pendingTask!=="play"||h.startTime===null&&h.holdTime===null?h.pendingTask==="pause"&&Uo(h):No(h))})}function Bo(){return new DOMException("The user aborted a request","AbortError")}function cn(h,d){if(d===null)return d;if(typeof d!="number")throw new DOMException(`Unexpected value: ${d}. Cannot convert to CssNumberish`,"InvalidStateError");const y=h.rangeDuration??100,S=jt(h),T=S?y*d/S:0;return CSS.percent(T)}function ge(h,d){if(h.timeline){if(d===null)return d;if(d.unit==="percent"){const y=h.rangeDuration??100,S=jt(h);return d.value*S/y}throw new DOMException("CSSNumericValue must be a percentage for progress based animations.","NotSupportedError")}{if(d==null||typeof d=="number")return d;const y=d.to("ms");if(y)return y.value;throw new DOMException("CSSNumericValue must be either a number or a time value for time based animations.","InvalidStateError")}}function No(h){const d=ge(h,h.timeline.currentTime);if(h.holdTime!=null)At(h),h.animation.playbackRate==0?h.startTime=d:(h.startTime=d-h.holdTime/h.animation.playbackRate,h.holdTime=null);else if(h.startTime!==null&&h.pendingPlaybackRate!==null){const y=(d-h.startTime)*h.animation.playbackRate;At(h);const S=h.animation.playbackRate;S==0?(h.holdTime=null,h.startTime=d):h.startTime=d-y/S}h.readyPromise&&h.readyPromise.state=="pending"&&h.readyPromise.resolve(h.proxy),Vt(h,!1,!1),Jt(h),h.pendingTask=null}function Uo(h){const d=ge(h,h.timeline.currentTime);h.startTime!=null&&h.holdTime==null&&(h.holdTime=(d-h.startTime)*h.animation.playbackRate),At(h),h.startTime=null,h.readyPromise.resolve(h.proxy),Vt(h,!1,!1),Jt(h),h.pendingTask=null}function Do(h){if(!h.finishedPromise||h.finishedPromise.state!="pending"||h.proxy.playState!="finished")return;h.finishedPromise.resolve(h.proxy),h.animation.pause();const d=new CustomEvent("finish",{detail:{currentTime:h.proxy.currentTime,timelineTime:h.proxy.timeline.currentTime}});Object.defineProperty(d,"currentTime",{get:function(){return this.detail.currentTime}}),Object.defineProperty(d,"timelineTime",{get:function(){return this.detail.timelineTime}}),requestAnimationFrame(()=>{queueMicrotask(()=>{h.animation.dispatchEvent(d)})})}function En(h){return h.pendingPlaybackRate!==null?h.pendingPlaybackRate:h.animation.playbackRate}function At(h){h.pendingPlaybackRate!==null&&(h.animation.playbackRate=h.pendingPlaybackRate,h.pendingPlaybackRate=null)}function Lo(h){if(!h.timeline)return null;const d=ge(h,h.timeline.currentTime);if(d===null||h.startTime===null)return null;let y=(d-h.startTime)*h.animation.playbackRate;return y==-0&&(y=0),y}function Vt(h,d,y){if(!h.timeline)return;let S=d?ge(h,h.proxy.currentTime):Lo(h);if(S&&h.startTime!=null&&!h.proxy.pending){const T=En(h),k=jt(h);let I=h.previousCurrentTime;T>0&&S>=k&&h.previousCurrentTime!=null?((I===null||I<k)&&(I=k),h.holdTime=d?S:I):T<0&&S<=0?((I==null||I>0)&&(I=0),h.holdTime=d?S:I):T!=0&&(d&&h.holdTime!==null&&(h.startTime=function(U,N){if(!U.timeline)return null;const L=ge(U,U.timeline.currentTime);return L==null?null:L-N/U.animation.playbackRate}(h,h.holdTime)),h.holdTime=null)}Jt(h),h.previousCurrentTime=ge(h,h.proxy.currentTime),h.proxy.playState=="finished"?(h.finishedPromise||(h.finishedPromise=new Cn),h.finishedPromise.state=="pending"&&(y?Do(h):Promise.resolve().then(()=>{Do(h)}))):(h.finishedPromise&&h.finishedPromise.state=="resolved"&&(h.finishedPromise=new Cn),h.animation.playState!="paused"&&h.animation.pause())}function jt(h){const d=function(S){const T=S.proxy.effect.getTiming();return S.normalizedTiming||T}(h),y=d.delay+d.endDelay+d.iterations*d.duration;return Math.max(0,y)}function Jt(h){if(h.timeline)if(h.startTime!==null){const d=h.timeline.currentTime;if(d==null)return;cs(h,(ge(h,d)-h.startTime)*h.animation.playbackRate)}else h.holdTime!==null&&cs(h,h.holdTime)}function cs(h,d){const y=h.timeline,S=h.animation.playbackRate,T=y.currentTime&&y.currentTime.value==(S<0?0:100)?S<0?.001:-.001:0;h.animation.currentTime=d+T}function ls(h,d){if(!h.timeline)return;const y=h.proxy.playState=="paused"&&h.proxy.pending;let S=!1,T=ge(h,h.proxy.currentTime);En(h)==0&&T==null&&(h.holdTime=0),T==null&&(h.autoAlignStartTime=!0),(h.proxy.playState==="finished"||y)&&(h.holdTime=null,h.startTime=null,h.autoAlignStartTime=!0),h.holdTime&&(h.startTime=null),h.pendingTask&&(h.pendingTask=null,S=!0),(h.holdTime!==null||h.autoAlignStartTime||y||h.pendingPlaybackRate!==null)&&(h.readyPromise&&!S&&(h.readyPromise=null),Jt(h),h.readyPromise||Xn(h),h.pendingTask="play",rs(h.timeline,h.animation,us.bind(h.proxy)),Vt(h,!1,!1))}function us(h){const d=Y.get(this);if(!d)return;if(h==null)return void(d.proxy.playState!=="paused"&&d.animation.playState!="idle"&&d.animation.cancel());er(d),d.pendingTask&&requestAnimationFrame(()=>{d.pendingTask!=="play"||d.startTime===null&&d.holdTime===null?d.pendingTask==="pause"&&Uo(d):No(d)});const y=this.playState;if(y=="running"||y=="finished"){const S=ge(d,h);cs(d,(S-ge(d,this.startTime))*this.playbackRate),Vt(d,!1,!1)}}function Fo(h){h.specifiedTiming=null}let Y=new WeakMap;window.addEventListener("pagehide",h=>{Y=new WeakMap},!1);let Vo=new WeakMap;function er(h){if(!h.autoAlignStartTime||!h.timeline||!h.timeline.currentTime||h.proxy.playState==="idle"||h.proxy.playState==="paused"&&h.holdTime!==null)return;const d=h.rangeDuration;let y,S;try{y=CSS.percent(100*function(k){if(!k.animationRange)return 0;const I=k.animationRange.start==="normal"?jo(k.timeline):k.animationRange.start;return Oo(k.timeline,I)}(h))}catch(k){y=CSS.percent(0),h.animationRange.start="normal",console.warn("Exception when calculating start offset",k)}try{S=CSS.percent(100*(1-function(k){if(!k.animationRange)return 0;const I=k.animationRange.end==="normal"?Jo(k.timeline):k.animationRange.end;return 1-Oo(k.timeline,I)}(h)))}catch(k){S=CSS.percent(100),h.animationRange.end="normal",console.warn("Exception when calculating end offset",k)}h.rangeDuration=S.value-y.value;const T=En(h);h.startTime=ge(h,T>=0?y:S),h.holdTime=null,h.rangeDuration!==d&&Fo(h)}function tr(h){throw new Error("Unsupported timeline class")}function jo(h){return h instanceof ViewTimeline?{rangeName:"cover",offset:CSS.percent(0)}:h instanceof We?CSS.percent(0):void tr()}function Jo(h){return h instanceof ViewTimeline?{rangeName:"cover",offset:CSS.percent(100)}:h instanceof We?CSS.percent(100):void tr()}function Ml(h,d){if(!d)return{start:"normal",end:"normal"};const y={start:jo(h),end:Jo(h)};if(h instanceof ViewTimeline){const S=Ye(d),T=[],k=[];if(S.forEach(I=>{if(Qi.includes(I))T.push(I);else try{k.push(CSSNumericValue.parse(I))}catch{throw TypeError(`Could not parse range "${d}"`)}}),T.length>2||k.length>2||k.length==1)throw TypeError("Invalid time range or unsupported time range format.");return T.length&&(y.start.rangeName=T[0],y.end.rangeName=T.length>1?T[1]:T[0]),k.length>1&&(y.start.offset=k[0],y.end.offset=k[1]),y}if(h instanceof We){const S=d.split(" ");if(S.length!=2)throw TypeError("Invalid time range or unsupported time range format.");return y.start=CSSNumericValue.parse(S[0]),y.end=CSSNumericValue.parse(S[1]),y}tr()}function nr(h,d,y){if(!d||d==="normal")return"normal";if(h instanceof ViewTimeline){let S="cover",T=y==="start"?CSS.percent(0):CSS.percent(100);if(d instanceof Object)d.rangeName!==void 0&&(S=d.rangeName),d.offset!==void 0&&(T=d.offset);else{const k=Ye(d);k.length===1?Qi.includes(k[0])?S=k[0]:T=fe(CSSNumericValue.parse(k[0]),{}):k.length===2&&(S=k[0],T=fe(CSSNumericValue.parse(k[1]),{}))}if(!Qi.includes(S))throw TypeError("Invalid range name");return{rangeName:S,offset:T}}if(h instanceof We)return CSSNumericValue.parse(d);tr()}class ir{constructor(d,y,S={}){const T=y instanceof We,k=d instanceof zo?d:new zo(d,T?void 0:y);Vo.set(k,this),Y.set(this,{animation:k,timeline:T?y:void 0,playState:T?"idle":null,readyPromise:null,finishedPromise:null,startTime:null,holdTime:null,rangeDuration:null,previousCurrentTime:null,autoAlignStartTime:!1,pendingPlaybackRate:null,pendingTask:null,specifiedTiming:null,normalizedTiming:null,effect:null,animationRange:T?Ml(y,S["animation-range"]):null,proxy:this})}get effect(){const d=Y.get(this);return d.timeline?(d.effect||(d.effect=function(y){const S=y.animation.effect,T=S.updateTiming,k={apply:function(L){S.getTiming();const X=L.apply(S);if(y.timeline){const Z=y.duration??100;X.localTime=cn(y,X.localTime),X.endTime=cn(y,X.endTime),X.activeDuration=cn(y,X.activeDuration);const K=jt(y),he=X.iterations?(K-X.delay-X.endDelay)/X.iterations:0;X.duration=K?CSS.percent(Z*he/K):CSS.percent(0),y.timeline.currentTime===void 0&&(X.localTime=null)}return X}},I={apply:function(L,X){if(y.specifiedTiming)return y.specifiedTiming;y.specifiedTiming=L.apply(S);let Z,K=Object.assign({},y.specifiedTiming);if(K.duration===1/0)throw TypeError("Effect duration cannot be Infinity when used with Scroll Timelines");return(K.duration===null||K.duration==="auto"||y.autoDurationEffect)&&y.timeline&&(y.autoDurationEffect=!0,K.delay=0,K.endDelay=0,Z=K.iterations?1e5:0,K.duration=K.iterations?(Z-K.delay-K.endDelay)/K.iterations:0,K.duration<0&&(K.duration=0,K.endDelay=Z-K.delay),T.apply(S,[K])),y.normalizedTiming=K,y.specifiedTiming}},U={apply:function(L,X,Z){if(Z&&Z.length){if(y.timeline&&Z[0]){const K=Z[0],he=K.duration;if(he===1/0)throw TypeError("Effect duration cannot be Infinity when used with Scroll Timelines");if(K.iterations===1/0)throw TypeError("Effect iterations cannot be Infinity when used with Scroll Timelines");he!==void 0&&he!=="auto"&&(y.autoDurationEffect=null)}y.specifiedTiming&&L.apply(S,[y.specifiedTiming]),L.apply(S,Z),Fo(y)}}},N=new Proxy(S,{get:function(L,X){const Z=L[X];return typeof Z=="function"?Z.bind(S):Z},set:function(L,X,Z){return L[X]=Z,!0}});return N.getComputedTiming=new Proxy(S.getComputedTiming,k),N.getTiming=new Proxy(S.getTiming,I),N.updateTiming=new Proxy(S.updateTiming,U),N}(d)),d.effect):d.animation.effect}set effect(d){const y=Y.get(this);y.animation.effect=d,y.effect=null,y.autoDurationEffect=null}get timeline(){const d=Y.get(this);return d.timeline||d.animation.timeline}set timeline(d){const y=Y.get(this),S=this.timeline;if(S==d)return;const T=this.playState,k=this.currentTime;let I,U=jt(y);I=k===null?null:U===0?0:ge(y,k)/U;const N=S instanceof We,L=d instanceof We,X=this.pending;if(N&&is(y.timeline,y.animation),L)return y.timeline=d,At(y),y.autoAlignStartTime=!0,y.startTime=null,y.holdTime=null,T!=="running"&&T!=="finished"||(y.readyPromise&&y.readyPromise.state!=="resolved"||Xn(y),y.pendingTask="play",rs(y.timeline,y.animation,us.bind(this))),T==="paused"&&I!==null&&(y.holdTime=I*U),X&&(y.readyPromise&&y.readyPromise.state!="resolved"||Xn(y),y.pendingTask=T=="paused"?"pause":"play"),y.startTime!==null&&(y.holdTime=null),void Vt(y,!1,!1);if(y.animation.timeline!=d)throw TypeError("Unsupported timeline: "+d);if(is(y.timeline,y.animation),y.timeline=null,N)switch(k!==null&&(y.animation.currentTime=I*jt(y)),T){case"paused":y.animation.pause();break;case"running":case"finished":y.animation.play()}}get startTime(){const d=Y.get(this);return d.timeline?cn(d,d.startTime):d.animation.startTime}set startTime(d){const y=Y.get(this);if(d=ge(y,d),!y.timeline)return void(y.animation.startTime=d);y.autoAlignStartTime=!1,ge(y,y.timeline.currentTime)==null&&y.startTime!=null&&(y.holdTime=null,Jt(y));const S=ge(y,this.currentTime);At(y),y.startTime=d,y.startTime!==null&&y.animation.playbackRate!=0?y.holdTime=null:y.holdTime=S,y.pendingTask&&(y.pendingTask=null,y.readyPromise.resolve(this)),Vt(y,!0,!1),Jt(y)}get currentTime(){const d=Y.get(this);return d.timeline?d.holdTime!=null?cn(d,d.holdTime):cn(d,Lo(d)):d.animation.currentTime}set currentTime(d){const y=Y.get(this);y.timeline?(function(S,T){if(T==null&&S.currentTime!==null)throw new TypeError;T=ge(S,T),S.autoAlignStartTime=!1,S.holdTime!==null||S.startTime===null||S.timeline.phase==="inactive"||S.animation.playbackRate===0?S.holdTime=T:S.startTime=ge(S,S.timeline.currentTime)-T/S.animation.playbackRate,S.timeline.phase==="inactive"&&(S.startTime=null),S.previousCurrentTime=null}(y,d),y.pendingTask=="pause"&&(y.holdTime=ge(y,d),At(y),y.startTime=null,y.pendingTask=null,y.readyPromise.resolve(this)),Vt(y,!0,!1)):y.animation.currentTime=d}get playbackRate(){return Y.get(this).animation.playbackRate}set playbackRate(d){const y=Y.get(this);if(!y.timeline)return void(y.animation.playbackRate=d);y.pendingPlaybackRate=null;const S=this.currentTime;y.animation.playbackRate=d,S!==null&&(this.currentTime=S)}get playState(){const d=Y.get(this);if(!d.timeline)return d.animation.playState;const y=ge(d,this.currentTime);return y===null&&d.startTime===null&&d.pendingTask==null?"idle":d.pendingTask=="pause"||d.startTime===null&&d.pendingTask!="play"?"paused":y!=null&&(d.animation.playbackRate>0&&y>=jt(d)||d.animation.playbackRate<0&&y<=0)?"finished":"running"}get rangeStart(){var d;return((d=Y.get(this).animationRange)==null?void 0:d.start)??"normal"}set rangeStart(d){const y=Y.get(this);if(!y.timeline)return y.animation.rangeStart=d;y.timeline instanceof We&&(y.animationRange.start=nr(y.timeline,d,"start"),er(y),Jt(y))}get rangeEnd(){var d;return((d=Y.get(this).animationRange)==null?void 0:d.end)??"normal"}set rangeEnd(d){const y=Y.get(this);if(!y.timeline)return y.animation.rangeEnd=d;y.timeline instanceof We&&(y.animationRange.end=nr(y.timeline,d,"end"),er(y),Jt(y))}get replaceState(){return Y.get(this).animation.pending}get pending(){const d=Y.get(this);return d.timeline?!!d.readyPromise&&d.readyPromise.state=="pending":d.animation.pending}finish(){const d=Y.get(this);if(!d.timeline)return void d.animation.finish();const y=En(d),S=jt(d);if(y==0)throw new DOMException("Cannot finish Animation with a playbackRate of 0.","InvalidStateError");if(y>0&&S==1/0)throw new DOMException("Cannot finish Animation with an infinite target effect end.","InvalidStateError");At(d);const T=y<0?0:S;this.currentTime=cn(d,T);const k=ge(d,d.timeline.currentTime);d.startTime===null&&k!==null&&(d.startTime=k-T/d.animation.playbackRate),d.pendingTask=="pause"&&d.startTime!==null&&(d.holdTime=null,d.pendingTask=null,d.readyPromise.resolve(this)),d.pendingTask=="play"&&d.startTime!==null&&(d.pendingTask=null,d.readyPromise.resolve(this)),Vt(d,!0,!0)}play(){const d=Y.get(this);d.timeline?ls(d):d.animation.play()}pause(){const d=Y.get(this);d.timeline?this.playState!="paused"&&(d.animation.currentTime===null&&(d.autoAlignStartTime=!0),d.pendingTask=="play"?d.pendingTask=null:d.readyPromise=null,d.readyPromise||Xn(d),d.pendingTask="pause",rs(d.timeline,d.animation,us.bind(d.proxy))):d.animation.pause()}reverse(){const d=Y.get(this),y=En(d),S=ge(d,this.currentTime),T=jt(d)==1/0,k=y!=0&&(y<0||S>0||!T);if(!d.timeline||!k)return k&&(d.pendingPlaybackRate=-En(d)),void d.animation.reverse();if(d.timeline.phase=="inactive")throw new DOMException("Cannot reverse an animation with no active timeline","InvalidStateError");this.updatePlaybackRate(-y),ls(d)}updatePlaybackRate(d){const y=Y.get(this);if(y.pendingPlaybackRate=d,!y.timeline)return void y.animation.updatePlaybackRate(d);const S=this.playState;if(!y.readyPromise||y.readyPromise.state!="pending")switch(S){case"idle":case"paused":At(y);break;case"finished":const T=ge(y,y.timeline.currentTime),k=T!==null?(T-y.startTime)*y.animation.playbackRate:null;y.startTime=d==0?T:T!=null&&k!=null?(T-k)/d:null,At(y),Vt(y,!1,!1),Jt(y);break;default:ls(y)}}persist(){Y.get(this).animation.persist()}get id(){return Y.get(this).animation.id}set id(d){Y.get(this).animation.id=d}cancel(){const d=Y.get(this);d.timeline?(this.playState!="idle"&&(function(y){y.pendingTask&&(y.pendingTask=null,At(y),y.readyPromise.reject(Bo()),Xn(y),y.readyPromise.resolve(y.proxy))}(d),d.finishedPromise&&d.finishedPromise.state=="pending"&&d.finishedPromise.reject(Bo()),d.finishedPromise=new Cn,d.animation.cancel()),d.startTime=null,d.holdTime=null,is(d.timeline,d.animation)):d.animation.cancel()}get onfinish(){return Y.get(this).animation.onfinish}set onfinish(d){Y.get(this).animation.onfinish=d}get oncancel(){return Y.get(this).animation.oncancel}set oncancel(d){Y.get(this).animation.oncancel=d}get onremove(){return Y.get(this).animation.onremove}set onremove(d){Y.get(this).animation.onremove=d}get finished(){const d=Y.get(this);return d.timeline?(d.finishedPromise||(d.finishedPromise=new Cn),d.finishedPromise.promise):d.animation.finished}get ready(){const d=Y.get(this);return d.timeline?(d.readyPromise||(d.readyPromise=new Cn,d.readyPromise.resolve(this)),d.readyPromise.promise):d.animation.ready}addEventListener(d,y,S){Y.get(this).animation.addEventListener(d,y,S)}removeEventListener(d,y,S){Y.get(this).animation.removeEventListener(d,y,S)}dispatchEvent(d){Y.get(this).animation.dispatchEvent(d)}}function Cl(h,d){const y=d.timeline;y instanceof We&&delete d.timeline;const S=Tl.apply(this,[h,d]),T=new ir(S,y);return y instanceof We&&(S.pause(),Y.get(T).animationRange={start:nr(y,d.rangeStart,"start"),end:nr(y,d.rangeEnd,"end")},T.play()),T}function Go(h){for(let d=0;d<h.length;++d){let y=Vo.get(h[d]);y&&(h[d]=y)}return h}function El(h){return Go(_l.apply(this,[h]))}function Pl(h){return Go(wl.apply(this,[h]))}const ke={IDENTIFIER:/[\w\\\@_-]+/g,WHITE_SPACE:/\s*/g,TIME:/^[0-9]+(s|ms)/,SCROLL_TIMELINE:/scroll-timeline\s*:([^;}]+)/,SCROLL_TIMELINE_NAME:/scroll-timeline-name\s*:([^;}]+)/,SCROLL_TIMELINE_AXIS:/scroll-timeline-axis\s*:([^;}]+)/,VIEW_TIMELINE:/view-timeline\s*:([^;}]+)/,VIEW_TIMELINE_NAME:/view-timeline-name\s*:([^;}]+)/,VIEW_TIMELINE_AXIS:/view-timeline-axis\s*:([^;}]+)/,VIEW_TIMELINE_INSET:/view-timeline-inset\s*:([^;}]+)/,ANIMATION_TIMELINE:/animation-timeline\s*:([^;}]+)/,ANIMATION_TIME_RANGE:/animation-range\s*:([^;}]+)/,ANIMATION_NAME:/animation-name\s*:([^;}]+)/,ANIMATION:/animation\s*:([^;}]+)/,ANONYMOUS_SCROLL_TIMELINE:/scroll\(([^)]*)\)/,ANONYMOUS_VIEW_TIMELINE:/view\(([^)]*)\)/},Pn=["block","inline","x","y"],kl=["nearest","root","self"],Kt=new class{constructor(){this.cssRulesWithTimelineName=[],this.nextAnonymousTimelineNameIndex=0,this.anonymousScrollTimelineOptions=new Map,this.anonymousViewTimelineOptions=new Map,this.sourceSelectorToScrollTimeline=[],this.subjectSelectorToViewTimeline=[],this.keyframeNamesSelectors=new Map}transpileStyleSheet(h,d,y){const S={sheetSrc:h,index:0,name:y};for(;S.index<S.sheetSrc.length&&(this.eatWhitespace(S),!(S.index>=S.sheetSrc.length));){if(this.lookAhead("/*",S)){for(;this.lookAhead("/*",S);)this.eatComment(S),this.eatWhitespace(S);continue}const T=this.parseQualifiedRule(S);T&&(d?this.parseKeyframesAndSaveNameMapping(T,S):this.handleScrollTimelineProps(T,S))}return S.sheetSrc}getAnimationTimelineOptions(h,d){for(let y=this.cssRulesWithTimelineName.length-1;y>=0;y--){const S=this.cssRulesWithTimelineName[y];try{if(d.matches(S.selector)&&(!S["animation-name"]||S["animation-name"]==h))return{"animation-timeline":S["animation-timeline"],"animation-range":S["animation-range"]}}catch{}}return null}getAnonymousScrollTimelineOptions(h,d){const y=this.anonymousScrollTimelineOptions.get(h);return y?{anonymousSource:y.source,anonymousTarget:d,source:Ro(y.source??"nearest",d),axis:y.axis?y.axis:"block"}:null}getScrollTimelineOptions(h,d){const y=this.getAnonymousScrollTimelineOptions(h,d);if(y)return y;for(let S=this.sourceSelectorToScrollTimeline.length-1;S>=0;S--){const T=this.sourceSelectorToScrollTimeline[S];if(T.name==h){const k=this.findPreviousSiblingOrAncestorMatchingSelector(d,T.selector);if(k)return{source:k,...T.axis?{axis:T.axis}:{}}}}return null}findPreviousSiblingOrAncestorMatchingSelector(h,d){let y=h;for(;y;){if(y.matches(d))return y;y=y.previousElementSibling||y.parentElement}return null}getAnonymousViewTimelineOptions(h,d){const y=this.anonymousViewTimelineOptions.get(h);return y?{subject:d,axis:y.axis?y.axis:"block",inset:y.inset?y.inset:"auto"}:null}getViewTimelineOptions(h,d){const y=this.getAnonymousViewTimelineOptions(h,d);if(y)return y;for(let S=this.subjectSelectorToViewTimeline.length-1;S>=0;S--){const T=this.subjectSelectorToViewTimeline[S];if(T.name==h){const k=this.findPreviousSiblingOrAncestorMatchingSelector(d,T.selector);if(k)return{subject:k,axis:T.axis,inset:T.inset}}}return null}handleScrollTimelineProps(h,d){if(h.selector.includes("@keyframes"))return;const y=h.block.contents.includes("animation-name:"),S=h.block.contents.includes("animation-timeline:"),T=h.block.contents.includes("animation:");if(this.saveSourceSelectorToScrollTimeline(h),this.saveSubjectSelectorToViewTimeline(h),!S&&!y&&!T)return;let k=[],I=[],U=!1;S&&(k=this.extractScrollTimelineNames(h.block.contents)),y&&(I=this.extractMatches(h.block.contents,ke.ANIMATION_NAME)),S&&y||(T&&this.extractMatches(h.block.contents,ke.ANIMATION).forEach(N=>{const L=this.extractAnimationName(N);L&&S&&I.push(L),S&&(this.hasDuration(N)||(this.hasAutoDuration(N)&&(h.block.contents=h.block.contents.replace("auto"," ")),h.block.contents=h.block.contents.replace(N," 1s "+N),U=!0))}),U&&this.replacePart(h.block.startIndex,h.block.endIndex,h.block.contents,d)),this.saveRelationInList(h,k,I)}saveSourceSelectorToScrollTimeline(h){const d=h.block.contents.includes("scroll-timeline:"),y=h.block.contents.includes("scroll-timeline-name:"),S=h.block.contents.includes("scroll-timeline-axis:");if(!d&&!y)return;let T=[];if(d){const I=this.extractMatches(h.block.contents,ke.SCROLL_TIMELINE);for(const U of I){const N=this.split(U);let L={selector:h.selector,name:""};N.length==1?L.name=N[0]:N.length==2&&(Pn.includes(N[0])?(L.axis=N[0],L.name=N[1]):(L.axis=N[1],L.name=N[0])),T.push(L)}}if(y){const I=this.extractMatches(h.block.contents,ke.SCROLL_TIMELINE_NAME);for(let U=0;U<I.length;U++)if(U<T.length)T[U].name=I[U];else{let N={selector:h.selector,name:I[U]};T.push(N)}}let k=[];if(S){const I=this.extractMatches(h.block.contents,ke.SCROLL_TIMELINE_AXIS);if(k=I.filter(U=>Pn.includes(U)),k.length!=I.length)throw new Error("Invalid axis")}for(let I=0;I<T.length;I++)k.length&&(T[I].axis=k[I%T.length]);this.sourceSelectorToScrollTimeline.push(...T)}saveSubjectSelectorToViewTimeline(h){const d=h.block.contents.includes("view-timeline:"),y=h.block.contents.includes("view-timeline-name:"),S=h.block.contents.includes("view-timeline-axis:"),T=h.block.contents.includes("view-timeline-inset:");if(!d&&!y)return;let k=[];if(d){const N=this.extractMatches(h.block.contents,ke.VIEW_TIMELINE);for(let L of N){const X=this.split(L);let Z={selector:h.selector,name:"",inset:null};X.length==1?Z.name=X[0]:X.length==2&&(Pn.includes(X[0])?(Z.axis=X[0],Z.name=X[1]):(Z.axis=X[1],Z.name=X[0])),k.push(Z)}}if(y){const N=this.extractMatches(h.block.contents,ke.VIEW_TIMELINE_NAME);for(let L=0;L<N.length;L++)if(L<k.length)k[L].name=N[L];else{let X={selector:h.selector,name:N[L],inset:null};k.push(X)}}let I=[],U=[];if(T&&(I=this.extractMatches(h.block.contents,ke.VIEW_TIMELINE_INSET)),S){const N=this.extractMatches(h.block.contents,ke.VIEW_TIMELINE_AXIS);if(U=N.filter(L=>Pn.includes(L)),U.length!=N.length)throw new Error("Invalid axis")}for(let N=0;N<k.length;N++)I.length&&(k[N].inset=I[N%k.length]),U.length&&(k[N].axis=U[N%k.length]);this.subjectSelectorToViewTimeline.push(...k)}hasDuration(h){return h.split(" ").filter(d=>{return y=d,ke.TIME.exec(y);var y}).length>=1}hasAutoDuration(h){return h.split(" ").filter(d=>d==="auto").length>=1}saveRelationInList(h,d,y){let S=[];h.block.contents.includes("animation-range:")&&(S=this.extractMatches(h.block.contents,ke.ANIMATION_TIME_RANGE));const T=Math.max(d.length,y.length,S.length);for(let k=0;k<T;k++)this.cssRulesWithTimelineName.push({selector:h.selector,"animation-timeline":d[k%d.length],...y.length?{"animation-name":y[k%y.length]}:{},...S.length?{"animation-range":S[k%S.length]}:{}})}extractScrollTimelineNames(h){const d=ke.ANIMATION_TIMELINE.exec(h)[1].trim(),y=[];return d.split(",").map(S=>S.trim()).forEach(S=>{if(function(T){return(T.startsWith("scroll")||T.startsWith("view"))&&T.includes("(")}(S)){const T=this.saveAnonymousTimelineName(S);y.push(T)}else y.push(S)}),y}saveAnonymousTimelineName(h){const d=":t"+this.nextAnonymousTimelineNameIndex++;return h.startsWith("scroll(")?this.anonymousScrollTimelineOptions.set(d,this.parseAnonymousScrollTimeline(h)):this.anonymousViewTimelineOptions.set(d,this.parseAnonymousViewTimeline(h)),d}parseAnonymousScrollTimeline(h){const d=ke.ANONYMOUS_SCROLL_TIMELINE.exec(h);if(!d)return null;const y=d[1],S={};return y.split(" ").forEach(T=>{Pn.includes(T)?S.axis=T:kl.includes(T)&&(S.source=T)}),S}parseAnonymousViewTimeline(h){const d=ke.ANONYMOUS_VIEW_TIMELINE.exec(h);if(!d)return null;const y=d[1],S={};return y.split(" ").forEach(T=>{Pn.includes(T)?S.axis=T:S.inset=S.inset?`${S.inset} ${T}`:T}),S}extractAnimationName(h){return this.findMatchingEntryInContainer(h,this.keyframeNamesSelectors)}findMatchingEntryInContainer(h,d){const y=h.split(" ").filter(S=>d.has(S));return y?y[0]:null}parseIdentifier(h){ke.IDENTIFIER.lastIndex=h.index;const d=ke.IDENTIFIER.exec(h.sheetSrc);if(!d)throw this.parseError(h,"Expected an identifier");return h.index+=d[0].length,d[0]}parseKeyframesAndSaveNameMapping(h,d){if(h.selector.startsWith("@keyframes")){const y=this.replaceKeyframesAndGetMapping(h,d);h.selector.split(" ").forEach((S,T)=>{T>0&&this.keyframeNamesSelectors.set(S,y)})}}replaceKeyframesAndGetMapping(h,d){function y(N){return Qi.some(L=>N.startsWith(L))}const S=h.block.contents,T=function(N){let L=0,X=-1,Z=-1;const K=[];for(let he=0;he<N.length;he++)N[he]=="{"?L++:N[he]=="}"&&L--,L==1&&N[he]!="{"&&N[he]!="}"&&X==-1&&(X=he),L==2&&N[he]=="{"&&(Z=he,K.push({start:X,end:Z}),X=Z=-1);return K}(S);if(T.length==0)return new Map;const k=new Map;let I=!1;const U=[];U.push(S.substring(0,T[0].start));for(let N=0;N<T.length;N++){const L=S.substring(T[N].start,T[N].end);let X=[];L.split(",").forEach(Z=>{const K=Z.split(" ").map(we=>we.trim()).filter(we=>we!="").join(" "),he=k.size;k.set(he,K),X.push(`${he}%`),y(K)&&(I=!0)}),U.push(X.join(",")),N==T.length-1?U.push(S.substring(T[N].end)):U.push(S.substring(T[N].end,T[N+1].start))}return I?(h.block.contents=U.join(""),this.replacePart(h.block.startIndex,h.block.endIndex,h.block.contents,d),k):new Map}parseQualifiedRule(h){const d=h.index,y=this.parseSelector(h).trim();if(y)return{selector:y,block:this.eatBlock(h),startIndex:d,endIndex:h.index}}removeEnclosingDoubleQuotes(h){let d=h[0]=='"'?1:0,y=h[h.length-1]=='"'?h.length-1:h.length;return h.substring(d,y)}assertString(h,d){if(h.sheetSrc.substr(h.index,d.length)!=d)throw this.parseError(h,`Did not find expected sequence ${d}`);h.index+=d.length}replacePart(h,d,y,S){if(S.sheetSrc=S.sheetSrc.slice(0,h)+y+S.sheetSrc.slice(d),S.index>=d){const T=S.index-d;S.index=h+y.length+T}}eatComment(h){this.assertString(h,"/*"),this.eatUntil("*/",h,!0),this.assertString(h,"*/")}eatBlock(h){const d=h.index;this.assertString(h,"{");let y=1;for(;y!=0;)this.lookAhead("/*",h)?this.eatComment(h):(h.sheetSrc[h.index]==="{"?y++:h.sheetSrc[h.index]==="}"&&y--,this.advance(h));const S=h.index;return{startIndex:d,endIndex:S,contents:h.sheetSrc.slice(d,S)}}advance(h){if(h.index++,h.index>h.sheetSrc.length)throw this.parseError(h,"Advanced beyond the end")}parseError(h,d){return Error(`(${h.name?h.name:"<anonymous file>"}): ${d}`)}eatUntil(h,d,y=!1){const S=d.index;for(;!this.lookAhead(h,d);)this.advance(d);return y&&(d.sheetSrc=d.sheetSrc.slice(0,S)+" ".repeat(d.index-S)+d.sheetSrc.slice(d.index)),d.sheetSrc.slice(S,d.index)}parseSelector(h){let d=h.index;if(this.eatUntil("{",h),d===h.index)throw Error("Empty selector");return h.sheetSrc.slice(d,h.index)}eatWhitespace(h){ke.WHITE_SPACE.lastIndex=h.index;const d=ke.WHITE_SPACE.exec(h.sheetSrc);d&&(h.index+=d[0].length)}lookAhead(h,d){return d.sheetSrc.substr(d.index,h.length)==h}peek(h){return h.sheetSrc[h.index]}extractMatches(h,d,y=","){return d.exec(h)[1].trim().split(y).map(S=>S.trim())}split(h){return h.split(" ").map(d=>d.trim()).filter(d=>d!="")}};function Rl(h,d,y,S,T,k){const I=ts(d),U=ns(d,y);return Io(as(h,I,U,S,T),k,as("cover",I,U,S,T),y)}function Al(h,d,y){const S=Kt.getAnimationTimelineOptions(d,y);if(!S)return null;const T=S["animation-timeline"];if(!T)return null;let k=Kt.getScrollTimelineOptions(T,y)||Kt.getViewTimelineOptions(T,y);return k?(k.subject&&function(I,U){const N=os(U.subject),L=U.axis||U.axis;function X(K,he){let we=null;for(const[Qe,Tt]of K)if(Qe==100*he.offset){if(Tt=="from")we=0;else if(Tt=="to")we=100;else{const dt=Tt.split(" ");we=dt.length==1?parseFloat(dt[0]):100*Rl(dt[0],N,U.subject,L,U.inset,CSS.percent(parseFloat(dt[1])))}break}return we}const Z=Kt.keyframeNamesSelectors.get(I.animationName);if(Z&&Z.size){const K=[];I.effect.getKeyframes().forEach(we=>{const Qe=X(Z,we);Qe!==null&&Qe>=0&&Qe<=100&&(we.offset=Qe/100,K.push(we))});const he=K.sort((we,Qe)=>we.offset<Qe.offset?-1:we.affset>Qe.offset?1:0);I.effect.setKeyframes(he)}}(h,k),{timeline:k.source?new We(k):new Mn(k),animOptions:S}):null}function Ol(){if(CSS.supports("animation-timeline: --works"))return!0;(function(){function d(S){if(S.innerHTML.trim().length===0||"aphrodite"in S.dataset)return;let T=Kt.transpileStyleSheet(S.innerHTML,!0);T=Kt.transpileStyleSheet(T,!1),S.innerHTML=T}function y(S){S.type!="text/css"&&S.rel!="stylesheet"||!S.href||new URL(S.href,document.baseURI).origin==location.origin&&fetch(S.getAttribute("href")).then(async T=>{const k=await T.text();let I=Kt.transpileStyleSheet(k,!0);if(I=Kt.transpileStyleSheet(k,!1),I!=k){const U=new Blob([I],{type:"text/css"}),N=URL.createObjectURL(U);S.setAttribute("href",N)}})}new MutationObserver(S=>{for(const T of S)for(const k of T.addedNodes)k instanceof HTMLStyleElement&&d(k),k instanceof HTMLLinkElement&&y(k)}).observe(document.documentElement,{childList:!0,subtree:!0}),document.querySelectorAll("style").forEach(S=>d(S)),document.querySelectorAll("link").forEach(S=>y(S))})();const h=CSS.supports;CSS.supports=d=>(d=d.replaceAll(/(animation-timeline|scroll-timeline(-(name|axis))?|view-timeline(-(name|axis|inset))?|timeline-scope)\s*:/g,"--supported-property:"),h(d)),window.addEventListener("animationstart",d=>{d.target.getAnimations().filter(y=>y.animationName===d.animationName).forEach(y=>{const S=Al(y,y.animationName,d.target);if(S)if(!S.timeline||y instanceof ir)y.timeline=S.timeline;else{const T=new ir(y,S.timeline,S.animOptions);y.pause(),T.play()}})})}(function(){if(!Ol()){if(!Reflect.defineProperty(window,"ScrollTimeline",{value:We}))throw Error("Error installing ScrollTimeline polyfill: could not attach ScrollTimeline to window");if(!Reflect.defineProperty(window,"ViewTimeline",{value:Mn}))throw Error("Error installing ViewTimeline polyfill: could not attach ViewTimeline to window");if(!Reflect.defineProperty(Element.prototype,"animate",{value:Cl}))throw Error("Error installing ScrollTimeline polyfill: could not attach WAAPI's animate to DOM Element");if(!Reflect.defineProperty(window,"Animation",{value:ir}))throw Error("Error installing Animation constructor.");if(!Reflect.defineProperty(Element.prototype,"getAnimations",{value:El}))throw Error("Error installing ScrollTimeline polyfill: could not attach WAAPI's getAnimations to DOM Element");if(!Reflect.defineProperty(document,"getAnimations",{value:Pl}))throw Error("Error installing ScrollTimeline polyfill: could not attach WAAPI's getAnimations to document")}})()})();class fd{constructor(e,t){if(this._retries=0,!Number.isInteger(e)||e<0)throw new Error("Base must be a positive integer or zero");if(t!==void 0&&(!Number.isInteger(t)||t<0))throw new Error("ExpMax must be a undefined, a positive integer or zero");this.base=e,this.expMax=t,this.i=0}get retries(){return this._retries}get current(){return this.base*Math.pow(2,this.i)}next(){return this._retries++,this.i=this.expMax===void 0?this.i+1:Math.min(this.i+1,this.expMax),this.current}reset(){this._retries=0,this.i=0}}var se;(function(r){r.open="open",r.close="close",r.error="error",r.message="message",r.retry="retry",r.reconnect="reconnect"})(se||(se={}));class Jc{constructor(e,t,n){var i,s,a,o,c,l,u,p,f,m,b,x,g,v,_;this._closedByUser=!1,this.handleOpenEvent=w=>this.handleEvent(se.open,w),this.handleErrorEvent=w=>this.handleEvent(se.error,w),this.handleCloseEvent=w=>this.handleEvent(se.close,w),this.handleMessageEvent=w=>this.handleEvent(se.message,w),this._url=e,this._protocols=t,this._options={buffer:n?.buffer,retry:{maxRetries:(i=n?.retry)===null||i===void 0?void 0:i.maxRetries,instantReconnect:(s=n?.retry)===null||s===void 0?void 0:s.instantReconnect,backoff:(a=n?.retry)===null||a===void 0?void 0:a.backoff},listeners:{open:[...(c=(o=n?.listeners)===null||o===void 0?void 0:o.open)!==null&&c!==void 0?c:[]],close:[...(u=(l=n?.listeners)===null||l===void 0?void 0:l.close)!==null&&u!==void 0?u:[]],error:[...(f=(p=n?.listeners)===null||p===void 0?void 0:p.error)!==null&&f!==void 0?f:[]],message:[...(b=(m=n?.listeners)===null||m===void 0?void 0:m.message)!==null&&b!==void 0?b:[]],retry:[...(g=(x=n?.listeners)===null||x===void 0?void 0:x.retry)!==null&&g!==void 0?g:[]],reconnect:[...(_=(v=n?.listeners)===null||v===void 0?void 0:v.reconnect)!==null&&_!==void 0?_:[]]}},this._underlyingWebsocket=this.tryConnect()}get url(){return this._url}get protocols(){return this._protocols}get buffer(){return this._options.buffer}get maxRetries(){return this._options.retry.maxRetries}get instantReconnect(){return this._options.retry.instantReconnect}get backoff(){return this._options.retry.backoff}get closedByUser(){return this._closedByUser}get lastConnection(){return this._lastConnection}get underlyingWebsocket(){return this._underlyingWebsocket}get readyState(){return this._underlyingWebsocket.readyState}get bufferedAmount(){return this._underlyingWebsocket.bufferedAmount}get extensions(){return this._underlyingWebsocket.extensions}get binaryType(){return this._underlyingWebsocket.binaryType}set binaryType(e){this._underlyingWebsocket.binaryType=e}send(e){this.closedByUser||(this._underlyingWebsocket.readyState===this._underlyingWebsocket.OPEN?this._underlyingWebsocket.send(e):this.buffer!==void 0&&this.buffer.add(e))}close(e,t){this.cancelScheduledConnectionRetry(),this._closedByUser=!0,this._underlyingWebsocket.close(e,t)}addEventListener(e,t,n){this._options.listeners[e].push({listener:t,options:n})}removeEventListener(e,t,n){const i=s=>s.listener!==t||s.options!==n;this._options.listeners[e]=this._options.listeners[e].filter(i)}tryConnect(){return this._underlyingWebsocket=new WebSocket(this.url,this.protocols),this._underlyingWebsocket.addEventListener(se.open,this.handleOpenEvent),this._underlyingWebsocket.addEventListener(se.close,this.handleCloseEvent),this._underlyingWebsocket.addEventListener(se.error,this.handleErrorEvent),this._underlyingWebsocket.addEventListener(se.message,this.handleMessageEvent),this._underlyingWebsocket}clearWebsocket(){this._underlyingWebsocket.removeEventListener(se.open,this.handleOpenEvent),this._underlyingWebsocket.removeEventListener(se.close,this.handleCloseEvent),this._underlyingWebsocket.removeEventListener(se.error,this.handleErrorEvent),this._underlyingWebsocket.removeEventListener(se.message,this.handleMessageEvent),this._underlyingWebsocket.close()}dispatchEvent(e,t){const n=this._options.listeners[e],i=[];n.forEach(({listener:s,options:a})=>{s(this,t),(a===void 0||a.once===void 0||!a.once)&&i.push({listener:s,options:a})}),this._options.listeners[e]=i}handleEvent(e,t){switch(e){case se.close:this.dispatchEvent(e,t),this.scheduleConnectionRetryIfNeeded();break;case se.open:if(this.backoff!==void 0&&this._lastConnection!==void 0){const n={retries:this.backoff.retries,lastConnection:new Date(this._lastConnection)},i=new CustomEvent(se.reconnect,{detail:n});this.dispatchEvent(se.reconnect,i),this.backoff.reset()}this._lastConnection=new Date,this.dispatchEvent(e,t),this.sendBufferedData();break;case se.retry:this.dispatchEvent(e,t),this.clearWebsocket(),this.tryConnect();break;default:this.dispatchEvent(e,t);break}}sendBufferedData(){if(this.buffer!==void 0)for(let e=this.buffer.read();e!==void 0;e=this.buffer.read())this.send(e)}scheduleConnectionRetryIfNeeded(){if(this.closedByUser||this.backoff===void 0)return;const e=n=>{const i=new CustomEvent(se.retry,{detail:n});this.handleEvent(se.retry,i)},t={backoff:this._options.retry.instantReconnect===!0?0:this.backoff.next(),retries:this._options.retry.instantReconnect===!0?0:this.backoff.retries,lastConnection:this._lastConnection};(this._options.retry.maxRetries===void 0||t.retries<=this._options.retry.maxRetries)&&(this.retryTimeout=globalThis.setTimeout(()=>e(t),t.backoff))}cancelScheduledConnectionRetry(){globalThis.clearTimeout(this.retryTimeout)}}class md{constructor(e){this._url=e}get url(){return this._url}withProtocols(e){return this._protocols=e,this}get protocols(){return this._protocols}withMaxRetries(e){var t;return this._options=Object.assign(Object.assign({},this._options),{retry:Object.assign(Object.assign({},(t=this._options)===null||t===void 0?void 0:t.retry),{maxRetries:e})}),this}get maxRetries(){var e,t;return(t=(e=this._options)===null||e===void 0?void 0:e.retry)===null||t===void 0?void 0:t.maxRetries}withInstantReconnect(e){var t;return this._options=Object.assign(Object.assign({},this._options),{retry:Object.assign(Object.assign({},(t=this._options)===null||t===void 0?void 0:t.retry),{instantReconnect:e})}),this}get instantReconnect(){var e,t;return(t=(e=this._options)===null||e===void 0?void 0:e.retry)===null||t===void 0?void 0:t.instantReconnect}withBackoff(e){var t;return this._options=Object.assign(Object.assign({},this._options),{retry:Object.assign(Object.assign({},(t=this._options)===null||t===void 0?void 0:t.retry),{backoff:e})}),this}get backoff(){var e,t;return(t=(e=this._options)===null||e===void 0?void 0:e.retry)===null||t===void 0?void 0:t.backoff}withBuffer(e){return this._options=Object.assign(Object.assign({},this._options),{buffer:e}),this}get buffer(){var e;return(e=this._options)===null||e===void 0?void 0:e.buffer}onOpen(e,t){return this.addListener(se.open,e,t),this}onClose(e,t){return this.addListener(se.close,e,t),this}onError(e,t){return this.addListener(se.error,e,t),this}onMessage(e,t){return this.addListener(se.message,e,t),this}onRetry(e,t){return this.addListener(se.retry,e,t),this}onReconnect(e,t){return this.addListener(se.reconnect,e,t),this}build(){return new Jc(this._url,this._protocols,this._options)}addListener(e,t,n){var i,s,a,o,c,l,u,p,f,m,b,x,g,v,_,w,C,M,E,P,O;return this._options=Object.assign(Object.assign({},this._options),{listeners:{open:(a=(s=(i=this._options)===null||i===void 0?void 0:i.listeners)===null||s===void 0?void 0:s.open)!==null&&a!==void 0?a:[],close:(l=(c=(o=this._options)===null||o===void 0?void 0:o.listeners)===null||c===void 0?void 0:c.close)!==null&&l!==void 0?l:[],error:(f=(p=(u=this._options)===null||u===void 0?void 0:u.listeners)===null||p===void 0?void 0:p.error)!==null&&f!==void 0?f:[],message:(x=(b=(m=this._options)===null||m===void 0?void 0:m.listeners)===null||b===void 0?void 0:b.message)!==null&&x!==void 0?x:[],retry:(_=(v=(g=this._options)===null||g===void 0?void 0:g.listeners)===null||v===void 0?void 0:v.retry)!==null&&_!==void 0?_:[],reconnect:(M=(C=(w=this._options)===null||w===void 0?void 0:w.listeners)===null||C===void 0?void 0:C.reconnect)!==null&&M!==void 0?M:[],[e]:[...(O=(P=(E=this._options)===null||E===void 0?void 0:E.listeners)===null||P===void 0?void 0:P[e])!==null&&O!==void 0?O:[],{listener:t,options:n}]}}),this}}const yd=Object.freeze(Object.defineProperty({__proto__:null,ExponentialBackoff:fd,Websocket:Jc,WebsocketBuilder:md,get WebsocketEvent(){return se}},Symbol.toStringTag,{value:"Module"})),Zs=0,Gc=1,Wc=2,Ks=2,Qs=1.25,Hc=1,ci=32,Pr=65535,gd=Math.pow(2,-24),$s=Symbol("SKIP_GENERATION");function vd(r){return r.index?r.index.count:r.attributes.position.count}function zn(r){return vd(r)/3}function Sd(r,e=ArrayBuffer){return r>65535?new Uint32Array(new e(4*r)):new Uint16Array(new e(2*r))}function bd(r,e){if(!r.index){const t=r.attributes.position.count,n=e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,i=Sd(t,n);r.setIndex(new ot(i,1));for(let s=0;s<t;s++)i[s]=s}}function qc(r,e){const t=zn(r),n=e||r.drawRange,i=n.start/3,s=(n.start+n.count)/3,a=Math.max(0,i),o=Math.min(t,s)-a;return[{offset:Math.floor(a),count:Math.floor(o)}]}function Xc(r,e){if(!r.groups||!r.groups.length)return qc(r,e);const t=[],n=new Set,i=e||r.drawRange,s=i.start/3,a=(i.start+i.count)/3;for(const c of r.groups){const l=c.start/3,u=(c.start+c.count)/3;n.add(Math.max(s,l)),n.add(Math.min(a,u))}const o=Array.from(n.values()).sort((c,l)=>c-l);for(let c=0;c<o.length-1;c++){const l=o[c],u=o[c+1];t.push({offset:Math.floor(l),count:Math.floor(u-l)})}return t}function xd(r,e){const t=zn(r),n=Xc(r,e).sort((a,o)=>a.offset-o.offset),i=n[n.length-1];i.count=Math.min(t-i.offset,i.count);let s=0;return n.forEach(({count:a})=>s+=a),t!==s}function eo(r,e,t,n,i){let s=1/0,a=1/0,o=1/0,c=-1/0,l=-1/0,u=-1/0,p=1/0,f=1/0,m=1/0,b=-1/0,x=-1/0,g=-1/0;for(let v=e*6,_=(e+t)*6;v<_;v+=6){const w=r[v+0],C=r[v+1],M=w-C,E=w+C;M<s&&(s=M),E>c&&(c=E),w<p&&(p=w),w>b&&(b=w);const P=r[v+2],O=r[v+3],R=P-O,A=P+O;R<a&&(a=R),A>l&&(l=A),P<f&&(f=P),P>x&&(x=P);const B=r[v+4],z=r[v+5],D=B-z,F=B+z;D<o&&(o=D),F>u&&(u=F),B<m&&(m=B),B>g&&(g=B)}n[0]=s,n[1]=a,n[2]=o,n[3]=c,n[4]=l,n[5]=u,i[0]=p,i[1]=f,i[2]=m,i[3]=b,i[4]=x,i[5]=g}function wd(r,e=null,t=null,n=null){const i=r.attributes.position,s=r.index?r.index.array:null,a=zn(r),o=i.normalized;let c;e===null?(c=new Float32Array(a*6),t=0,n=a):(c=e,t=t||0,n=n||a);const l=i.array,u=i.offset||0;let p=3;i.isInterleavedBufferAttribute&&(p=i.data.stride);const f=["getX","getY","getZ"];for(let m=t;m<t+n;m++){const b=m*3,x=m*6;let g=b+0,v=b+1,_=b+2;s&&(g=s[g],v=s[v],_=s[_]),o||(g=g*p+u,v=v*p+u,_=_*p+u);for(let w=0;w<3;w++){let C,M,E;o?(C=i[f[w]](g),M=i[f[w]](v),E=i[f[w]](_)):(C=l[g+w],M=l[v+w],E=l[_+w]);let P=C;M<P&&(P=M),E<P&&(P=E);let O=C;M>O&&(O=M),E>O&&(O=E);const R=(O-P)/2,A=w*2;c[x+A+0]=P+R,c[x+A+1]=R+(Math.abs(P)+R)*gd}}return c}function ve(r,e,t){return t.min.x=e[r],t.min.y=e[r+1],t.min.z=e[r+2],t.max.x=e[r+3],t.max.y=e[r+4],t.max.z=e[r+5],t}function Yc(r){let e=-1,t=-1/0;for(let n=0;n<3;n++){const i=r[n+3]-r[n];i>t&&(t=i,e=n)}return e}function Zc(r,e){e.set(r)}function Kc(r,e,t){let n,i;for(let s=0;s<3;s++){const a=s+3;n=r[s],i=e[s],t[s]=n<i?n:i,n=r[a],i=e[a],t[a]=n>i?n:i}}function kr(r,e,t){for(let n=0;n<3;n++){const i=e[r+2*n],s=e[r+2*n+1],a=i-s,o=i+s;a<t[n]&&(t[n]=a),o>t[n+3]&&(t[n+3]=o)}}function li(r){const e=r[3]-r[0],t=r[4]-r[1],n=r[5]-r[2];return 2*(e*t+t*n+n*e)}const Xt=32,_d=(r,e)=>r.candidate-e.candidate,tn=new Array(Xt).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),Rr=new Float32Array(6);function Td(r,e,t,n,i,s){let a=-1,o=0;if(s===Zs)a=Yc(e),a!==-1&&(o=(e[a]+e[a+3])/2);else if(s===Gc)a=Yc(r),a!==-1&&(o=Md(t,n,i,a));else if(s===Wc){const c=li(r);let l=Qs*i;const u=n*6,p=(n+i)*6;for(let f=0;f<3;f++){const m=e[f],b=(e[f+3]-m)/Xt;if(i<Xt/4){const x=[...tn];x.length=i;let g=0;for(let _=u;_<p;_+=6,g++){const w=x[g];w.candidate=t[_+2*f],w.count=0;const{bounds:C,leftCacheBounds:M,rightCacheBounds:E}=w;for(let P=0;P<3;P++)E[P]=1/0,E[P+3]=-1/0,M[P]=1/0,M[P+3]=-1/0,C[P]=1/0,C[P+3]=-1/0;kr(_,t,C)}x.sort(_d);let v=i;for(let _=0;_<v;_++){const w=x[_];for(;_+1<v&&x[_+1].candidate===w.candidate;)x.splice(_+1,1),v--}for(let _=u;_<p;_+=6){const w=t[_+2*f];for(let C=0;C<v;C++){const M=x[C];w>=M.candidate?kr(_,t,M.rightCacheBounds):(kr(_,t,M.leftCacheBounds),M.count++)}}for(let _=0;_<v;_++){const w=x[_],C=w.count,M=i-w.count,E=w.leftCacheBounds,P=w.rightCacheBounds;let O=0;C!==0&&(O=li(E)/c);let R=0;M!==0&&(R=li(P)/c);const A=Hc+Qs*(O*C+R*M);A<l&&(a=f,l=A,o=w.candidate)}}else{for(let v=0;v<Xt;v++){const _=tn[v];_.count=0,_.candidate=m+b+v*b;const w=_.bounds;for(let C=0;C<3;C++)w[C]=1/0,w[C+3]=-1/0}for(let v=u;v<p;v+=6){let _=~~((t[v+2*f]-m)/b);_>=Xt&&(_=Xt-1);const w=tn[_];w.count++,kr(v,t,w.bounds)}const x=tn[Xt-1];Zc(x.bounds,x.rightCacheBounds);for(let v=Xt-2;v>=0;v--){const _=tn[v],w=tn[v+1];Kc(_.bounds,w.rightCacheBounds,_.rightCacheBounds)}let g=0;for(let v=0;v<Xt-1;v++){const _=tn[v],w=_.count,C=_.bounds,M=tn[v+1].rightCacheBounds;w!==0&&(g===0?Zc(C,Rr):Kc(C,Rr,Rr)),g+=w;let E=0,P=0;g!==0&&(E=li(Rr)/c);const O=i-g;O!==0&&(P=li(M)/c);const R=Hc+Qs*(E*g+P*O);R<l&&(a=f,l=R,o=_.candidate)}}}}else console.warn(`MeshBVH: Invalid build strategy value ${s} used.`);return{axis:a,pos:o}}function Md(r,e,t,n){let i=0;for(let s=e,a=e+t;s<a;s++)i+=r[s*6+n*2];return i/t}class to{constructor(){this.boundingData=new Float32Array(6)}}function Cd(r,e,t,n,i,s){let a=n,o=n+i-1;const c=s.pos,l=s.axis*2;for(;;){for(;a<=o&&t[a*6+l]<c;)a++;for(;a<=o&&t[o*6+l]>=c;)o--;if(a<o){for(let u=0;u<3;u++){let p=e[a*3+u];e[a*3+u]=e[o*3+u],e[o*3+u]=p}for(let u=0;u<6;u++){let p=t[a*6+u];t[a*6+u]=t[o*6+u],t[o*6+u]=p}a++,o--}else return a}}function Ed(r,e,t,n,i,s){let a=n,o=n+i-1;const c=s.pos,l=s.axis*2;for(;;){for(;a<=o&&t[a*6+l]<c;)a++;for(;a<=o&&t[o*6+l]>=c;)o--;if(a<o){let u=r[a];r[a]=r[o],r[o]=u;for(let p=0;p<6;p++){let f=t[a*6+p];t[a*6+p]=t[o*6+p],t[o*6+p]=f}a++,o--}else return a}}function et(r,e){return e[r+15]===65535}function ct(r,e){return e[r+6]}function pt(r,e){return e[r+14]}function ft(r){return r+8}function mt(r,e){return e[r+6]}function Qc(r,e){return e[r+7]}let $c,ui,Ar,el;const Pd=Math.pow(2,32);function no(r){return"count"in r?1:1+no(r.left)+no(r.right)}function kd(r,e,t){return $c=new Float32Array(t),ui=new Uint32Array(t),Ar=new Uint16Array(t),el=new Uint8Array(t),io(r,e)}function io(r,e){const t=r/4,n=r/2,i="count"in e,s=e.boundingData;for(let a=0;a<6;a++)$c[t+a]=s[a];if(i)if(e.buffer){const a=e.buffer;el.set(new Uint8Array(a),r);for(let o=r,c=r+a.byteLength;o<c;o+=ci){const l=o/2;et(l,Ar)||(ui[o/4+6]+=t)}return r+a.byteLength}else{const a=e.offset,o=e.count;return ui[t+6]=a,Ar[n+14]=o,Ar[n+15]=Pr,r+ci}else{const a=e.left,o=e.right,c=e.splitAxis;let l;if(l=io(r+ci,a),l/4>Pd)throw new Error("MeshBVH: Cannot store child pointer greater than 32 bits.");return ui[t+6]=l/4,l=io(l,o),ui[t+7]=c,l}}function Rd(r,e){const t=(r.index?r.index.count:r.attributes.position.count)/3,n=t>2**16,i=n?4:2,s=e?new SharedArrayBuffer(t*i):new ArrayBuffer(t*i),a=n?new Uint32Array(s):new Uint16Array(s);for(let o=0,c=a.length;o<c;o++)a[o]=o;return a}function Ad(r,e,t,n,i){const{maxDepth:s,verbose:a,maxLeafTris:o,strategy:c,onProgress:l,indirect:u}=i,p=r._indirectBuffer,f=r.geometry,m=f.index?f.index.array:null,b=u?Ed:Cd,x=zn(f),g=new Float32Array(6);let v=!1;const _=new to;return eo(e,t,n,_.boundingData,g),C(_,t,n,g),_;function w(M){l&&l(M/x)}function C(M,E,P,O=null,R=0){if(!v&&R>=s&&(v=!0,a&&(console.warn(`MeshBVH: Max depth of ${s} reached when generating BVH. Consider increasing maxDepth.`),console.warn(f))),P<=o||R>=s)return w(E+P),M.offset=E,M.count=P,M;const A=Td(M.boundingData,O,e,E,P,c);if(A.axis===-1)return w(E+P),M.offset=E,M.count=P,M;const B=b(p,m,e,E,P,A);if(B===E||B===E+P)w(E+P),M.offset=E,M.count=P;else{M.splitAxis=A.axis;const z=new to,D=E,F=B-E;M.left=z,eo(e,D,F,z.boundingData,g),C(z,D,F,g,R+1);const H=new to,q=B,$=P-F;M.right=H,eo(e,q,$,H.boundingData,g),C(H,q,$,g,R+1)}return M}}function Od(r,e){const t=r.geometry;e.indirect&&(r._indirectBuffer=Rd(t,e.useSharedArrayBuffer),xd(t,e.range)&&!e.verbose&&console.warn('MeshBVH: Provided geometry contains groups or a range that do not fully span the vertex contents while using the "indirect" option. BVH may incorrectly report intersections on unrendered portions of the geometry.')),r._indirectBuffer||bd(t,e);const n=e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,i=wd(t),s=e.indirect?qc(t,e.range):Xc(t,e.range);r._roots=s.map(a=>{const o=Ad(r,i,a.offset,a.count,e),c=no(o),l=new n(ci*c);return kd(0,o,l),l})}class Yt{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(e,t){let n=1/0,i=-1/0;for(let s=0,a=e.length;s<a;s++){const o=e[s][t];n=o<n?o:n,i=o>i?o:i}this.min=n,this.max=i}setFromPoints(e,t){let n=1/0,i=-1/0;for(let s=0,a=t.length;s<a;s++){const o=t[s],c=e.dot(o);n=c<n?c:n,i=c>i?c:i}this.min=n,this.max=i}isSeparated(e){return this.min>e.max||e.min>this.max}}Yt.prototype.setFromBox=function(){const r=new W;return function(e,t){const n=t.min,i=t.max;let s=1/0,a=-1/0;for(let o=0;o<=1;o++)for(let c=0;c<=1;c++)for(let l=0;l<=1;l++){r.x=n.x*o+i.x*(1-o),r.y=n.y*c+i.y*(1-c),r.z=n.z*l+i.z*(1-l);const u=e.dot(r);s=Math.min(u,s),a=Math.max(u,a)}this.min=s,this.max=a}}();const Id=function(){const r=new W,e=new W,t=new W;return function(n,i,s){const a=n.start,o=r,c=i.start,l=e;t.subVectors(a,c),r.subVectors(n.end,n.start),e.subVectors(i.end,i.start);const u=t.dot(l),p=l.dot(o),f=l.dot(l),m=t.dot(o),b=o.dot(o)*f-p*p;let x,g;b!==0?x=(u*p-m*f)/b:x=0,g=(u+x*p)/f,s.x=x,s.y=g}}(),ro=function(){const r=new kn,e=new W,t=new W;return function(n,i,s,a){Id(n,i,r);let o=r.x,c=r.y;if(o>=0&&o<=1&&c>=0&&c<=1){n.at(o,s),i.at(c,a);return}else if(o>=0&&o<=1){c<0?i.at(0,a):i.at(1,a),n.closestPointToPoint(a,!0,s);return}else if(c>=0&&c<=1){o<0?n.at(0,s):n.at(1,s),i.closestPointToPoint(s,!0,a);return}else{let l;o<0?l=n.start:l=n.end;let u;c<0?u=i.start:u=i.end;const p=e,f=t;if(n.closestPointToPoint(u,!0,e),i.closestPointToPoint(l,!0,t),p.distanceToSquared(u)<=f.distanceToSquared(l)){s.copy(p),a.copy(u);return}else{s.copy(l),a.copy(f);return}}}}(),zd=function(){const r=new W,e=new W,t=new Qo,n=new Gt;return function(i,s){const{radius:a,center:o}=i,{a:c,b:l,c:u}=s;if(n.start=c,n.end=l,n.closestPointToPoint(o,!0,r).distanceTo(o)<=a||(n.start=c,n.end=u,n.closestPointToPoint(o,!0,r).distanceTo(o)<=a)||(n.start=l,n.end=u,n.closestPointToPoint(o,!0,r).distanceTo(o)<=a))return!0;const p=s.getPlane(t);if(Math.abs(p.distanceToPoint(o))<=a){const f=p.projectPoint(o,e);if(s.containsPoint(f))return!0}return!1}}(),Bd=1e-15;function so(r){return Math.abs(r)<Bd}class yt extends un{constructor(...e){super(...e),this.isExtendedTriangle=!0,this.satAxes=new Array(4).fill().map(()=>new W),this.satBounds=new Array(4).fill().map(()=>new Yt),this.points=[this.a,this.b,this.c],this.sphere=new $o,this.plane=new Qo,this.needsUpdate=!0}intersectsSphere(e){return zd(e,this)}update(){const e=this.a,t=this.b,n=this.c,i=this.points,s=this.satAxes,a=this.satBounds,o=s[0],c=a[0];this.getNormal(o),c.setFromPoints(o,i);const l=s[1],u=a[1];l.subVectors(e,t),u.setFromPoints(l,i);const p=s[2],f=a[2];p.subVectors(t,n),f.setFromPoints(p,i);const m=s[3],b=a[3];m.subVectors(n,e),b.setFromPoints(m,i),this.sphere.setFromPoints(this.points),this.plane.setFromNormalAndCoplanarPoint(o,e),this.needsUpdate=!1}}yt.prototype.closestPointToSegment=function(){const r=new W,e=new W,t=new Gt;return function(n,i=null,s=null){const{start:a,end:o}=n,c=this.points;let l,u=1/0;for(let p=0;p<3;p++){const f=(p+1)%3;t.start.copy(c[p]),t.end.copy(c[f]),ro(t,n,r,e),l=r.distanceToSquared(e),l<u&&(u=l,i&&i.copy(r),s&&s.copy(e))}return this.closestPointToPoint(a,r),l=a.distanceToSquared(r),l<u&&(u=l,i&&i.copy(r),s&&s.copy(a)),this.closestPointToPoint(o,r),l=o.distanceToSquared(r),l<u&&(u=l,i&&i.copy(r),s&&s.copy(o)),Math.sqrt(u)}}(),yt.prototype.intersectsTriangle=function(){const r=new yt,e=new Array(3),t=new Array(3),n=new Yt,i=new Yt,s=new W,a=new W,o=new W,c=new W,l=new W,u=new Gt,p=new Gt,f=new Gt,m=new W;function b(x,g,v){const _=x.points;let w=0,C=-1;for(let M=0;M<3;M++){const{start:E,end:P}=u;E.copy(_[M]),P.copy(_[(M+1)%3]),u.delta(a);const O=so(g.distanceToPoint(E));if(so(g.normal.dot(a))&&O){v.copy(u),w=2;break}const R=g.intersectLine(u,m);if(!R&&O&&m.copy(E),(R||O)&&!so(m.distanceTo(P))){if(w<=1)(w===1?v.start:v.end).copy(m),O&&(C=w);else if(w>=2){(C===1?v.start:v.end).copy(m),w=2;break}if(w++,w===2&&C===-1)break}}return w}return function(x,g=null,v=!1){this.needsUpdate&&this.update(),x.isExtendedTriangle?x.needsUpdate&&x.update():(r.copy(x),r.update(),x=r);const _=this.plane,w=x.plane;if(Math.abs(_.normal.dot(w.normal))>1-1e-10){const C=this.satBounds,M=this.satAxes;t[0]=x.a,t[1]=x.b,t[2]=x.c;for(let O=0;O<4;O++){const R=C[O],A=M[O];if(n.setFromPoints(A,t),R.isSeparated(n))return!1}const E=x.satBounds,P=x.satAxes;e[0]=this.a,e[1]=this.b,e[2]=this.c;for(let O=0;O<4;O++){const R=E[O],A=P[O];if(n.setFromPoints(A,e),R.isSeparated(n))return!1}for(let O=0;O<4;O++){const R=M[O];for(let A=0;A<4;A++){const B=P[A];if(s.crossVectors(R,B),n.setFromPoints(s,e),i.setFromPoints(s,t),n.isSeparated(i))return!1}}return g&&(v||console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."),g.start.set(0,0,0),g.end.set(0,0,0)),!0}else{const C=b(this,w,p);if(C===1&&x.containsPoint(p.end))return g&&(g.start.copy(p.end),g.end.copy(p.end)),!0;if(C!==2)return!1;const M=b(x,_,f);if(M===1&&this.containsPoint(f.end))return g&&(g.start.copy(f.end),g.end.copy(f.end)),!0;if(M!==2)return!1;if(p.delta(o),f.delta(c),o.dot(c)<0){let z=f.start;f.start=f.end,f.end=z}const E=p.start.dot(o),P=p.end.dot(o),O=f.start.dot(o),R=f.end.dot(o),A=P<O,B=E<R;return E!==R&&O!==P&&A===B?!1:(g&&(l.subVectors(p.start,f.start),l.dot(o)>0?g.start.copy(p.start):g.start.copy(f.start),l.subVectors(p.end,f.end),l.dot(o)<0?g.end.copy(p.end):g.end.copy(f.end)),!0)}}}(),yt.prototype.distanceToPoint=function(){const r=new W;return function(e){return this.closestPointToPoint(e,r),e.distanceTo(r)}}(),yt.prototype.distanceToTriangle=function(){const r=new W,e=new W,t=["a","b","c"],n=new Gt,i=new Gt;return function(s,a=null,o=null){const c=a||o?n:null;if(this.intersectsTriangle(s,c))return(a||o)&&(a&&c.getCenter(a),o&&c.getCenter(o)),0;let l=1/0;for(let u=0;u<3;u++){let p;const f=t[u],m=s[f];this.closestPointToPoint(m,r),p=m.distanceToSquared(r),p<l&&(l=p,a&&a.copy(r),o&&o.copy(m));const b=this[f];s.closestPointToPoint(b,r),p=b.distanceToSquared(r),p<l&&(l=p,a&&a.copy(b),o&&o.copy(r))}for(let u=0;u<3;u++){const p=t[u],f=t[(u+1)%3];n.set(this[p],this[f]);for(let m=0;m<3;m++){const b=t[m],x=t[(m+1)%3];i.set(s[b],s[x]),ro(n,i,r,e);const g=r.distanceToSquared(e);g<l&&(l=g,a&&a.copy(r),o&&o.copy(e))}}return Math.sqrt(l)}}();class Ve{constructor(e,t,n){this.isOrientedBox=!0,this.min=new W,this.max=new W,this.matrix=new Ct,this.invMatrix=new Ct,this.points=new Array(8).fill().map(()=>new W),this.satAxes=new Array(3).fill().map(()=>new W),this.satBounds=new Array(3).fill().map(()=>new Yt),this.alignedSatBounds=new Array(3).fill().map(()=>new Yt),this.needsUpdate=!1,e&&this.min.copy(e),t&&this.max.copy(t),n&&this.matrix.copy(n)}set(e,t,n){this.min.copy(e),this.max.copy(t),this.matrix.copy(n),this.needsUpdate=!0}copy(e){this.min.copy(e.min),this.max.copy(e.max),this.matrix.copy(e.matrix),this.needsUpdate=!0}}Ve.prototype.update=function(){return function(){const r=this.matrix,e=this.min,t=this.max,n=this.points;for(let c=0;c<=1;c++)for(let l=0;l<=1;l++)for(let u=0;u<=1;u++){const p=1*c|2*l|4*u,f=n[p];f.x=c?t.x:e.x,f.y=l?t.y:e.y,f.z=u?t.z:e.z,f.applyMatrix4(r)}const i=this.satBounds,s=this.satAxes,a=n[0];for(let c=0;c<3;c++){const l=s[c],u=i[c],p=1<<c,f=n[p];l.subVectors(a,f),u.setFromPoints(l,n)}const o=this.alignedSatBounds;o[0].setFromPointsField(n,"x"),o[1].setFromPointsField(n,"y"),o[2].setFromPointsField(n,"z"),this.invMatrix.copy(this.matrix).invert(),this.needsUpdate=!1}}(),Ve.prototype.intersectsBox=function(){const r=new Yt;return function(e){this.needsUpdate&&this.update();const t=e.min,n=e.max,i=this.satBounds,s=this.satAxes,a=this.alignedSatBounds;if(r.min=t.x,r.max=n.x,a[0].isSeparated(r)||(r.min=t.y,r.max=n.y,a[1].isSeparated(r))||(r.min=t.z,r.max=n.z,a[2].isSeparated(r)))return!1;for(let o=0;o<3;o++){const c=s[o],l=i[o];if(r.setFromBox(c,e),l.isSeparated(r))return!1}return!0}}(),Ve.prototype.intersectsTriangle=function(){const r=new yt,e=new Array(3),t=new Yt,n=new Yt,i=new W;return function(s){this.needsUpdate&&this.update(),s.isExtendedTriangle?s.needsUpdate&&s.update():(r.copy(s),r.update(),s=r);const a=this.satBounds,o=this.satAxes;e[0]=s.a,e[1]=s.b,e[2]=s.c;for(let p=0;p<3;p++){const f=a[p],m=o[p];if(t.setFromPoints(m,e),f.isSeparated(t))return!1}const c=s.satBounds,l=s.satAxes,u=this.points;for(let p=0;p<3;p++){const f=c[p],m=l[p];if(t.setFromPoints(m,u),f.isSeparated(t))return!1}for(let p=0;p<3;p++){const f=o[p];for(let m=0;m<4;m++){const b=l[m];if(i.crossVectors(f,b),t.setFromPoints(i,e),n.setFromPoints(i,u),t.isSeparated(n))return!1}}return!0}}(),Ve.prototype.closestPointToPoint=function(){return function(r,e){return this.needsUpdate&&this.update(),e.copy(r).applyMatrix4(this.invMatrix).clamp(this.min,this.max).applyMatrix4(this.matrix),e}}(),Ve.prototype.distanceToPoint=function(){const r=new W;return function(e){return this.closestPointToPoint(e,r),e.distanceTo(r)}}(),Ve.prototype.distanceToBox=function(){const r=["x","y","z"],e=new Array(12).fill().map(()=>new Gt),t=new Array(12).fill().map(()=>new Gt),n=new W,i=new W;return function(s,a=0,o=null,c=null){if(this.needsUpdate&&this.update(),this.intersectsBox(s))return(o||c)&&(s.getCenter(i),this.closestPointToPoint(i,n),s.closestPointToPoint(n,i),o&&o.copy(n),c&&c.copy(i)),0;const l=a*a,u=s.min,p=s.max,f=this.points;let m=1/0;for(let x=0;x<8;x++){const g=f[x];i.copy(g).clamp(u,p);const v=g.distanceToSquared(i);if(v<m&&(m=v,o&&o.copy(g),c&&c.copy(i),v<l))return Math.sqrt(v)}let b=0;for(let x=0;x<3;x++)for(let g=0;g<=1;g++)for(let v=0;v<=1;v++){const _=(x+1)%3,w=(x+2)%3,C=g<<_|v<<w,M=1<<x|g<<_|v<<w,E=f[C],P=f[M];e[b].set(E,P);const O=r[x],R=r[_],A=r[w],B=t[b],z=B.start,D=B.end;z[O]=u[O],z[R]=g?u[R]:p[R],z[A]=v?u[A]:p[R],D[O]=p[O],D[R]=g?u[R]:p[R],D[A]=v?u[A]:p[R],b++}for(let x=0;x<=1;x++)for(let g=0;g<=1;g++)for(let v=0;v<=1;v++){i.x=x?p.x:u.x,i.y=g?p.y:u.y,i.z=v?p.z:u.z,this.closestPointToPoint(i,n);const _=i.distanceToSquared(n);if(_<m&&(m=_,o&&o.copy(n),c&&c.copy(i),_<l))return Math.sqrt(_)}for(let x=0;x<12;x++){const g=e[x];for(let v=0;v<12;v++){const _=t[v];ro(g,_,n,i);const w=n.distanceToSquared(i);if(w<m&&(m=w,o&&o.copy(n),c&&c.copy(i),w<l))return Math.sqrt(w)}}return Math.sqrt(m)}}();class oo{constructor(e){this._getNewPrimitive=e,this._primitives=[]}getPrimitive(){const e=this._primitives;return e.length===0?this._getNewPrimitive():e.pop()}releasePrimitive(e){this._primitives.push(e)}}class Nd extends oo{constructor(){super(()=>new yt)}}const gt=new Nd;class Ud{constructor(){this.float32Array=null,this.uint16Array=null,this.uint32Array=null;const e=[];let t=null;this.setBuffer=n=>{t&&e.push(t),t=n,this.float32Array=new Float32Array(n),this.uint16Array=new Uint16Array(n),this.uint32Array=new Uint32Array(n)},this.clearBuffer=()=>{t=null,this.float32Array=null,this.uint16Array=null,this.uint32Array=null,e.length!==0&&this.setBuffer(e.pop())}}}const de=new Ud;let nn,Bn;const Nn=[],Or=new oo(()=>new Ot);function Dd(r,e,t,n,i,s){nn=Or.getPrimitive(),Bn=Or.getPrimitive(),Nn.push(nn,Bn),de.setBuffer(r._roots[e]);const a=ao(0,r.geometry,t,n,i,s);de.clearBuffer(),Or.releasePrimitive(nn),Or.releasePrimitive(Bn),Nn.pop(),Nn.pop();const o=Nn.length;return o>0&&(Bn=Nn[o-1],nn=Nn[o-2]),a}function ao(r,e,t,n,i=null,s=0,a=0){const{float32Array:o,uint16Array:c,uint32Array:l}=de;let u=r*2;if(et(u,c)){const p=ct(r,l),f=pt(u,c);return ve(r,o,nn),n(p,f,!1,a,s+r,nn)}else{let p=function(B){const{uint16Array:z,uint32Array:D}=de;let F=B*2;for(;!et(F,z);)B=ft(B),F=B*2;return ct(B,D)},f=function(B){const{uint16Array:z,uint32Array:D}=de;let F=B*2;for(;!et(F,z);)B=mt(B,D),F=B*2;return ct(B,D)+pt(F,z)};const m=ft(r),b=mt(r,l);let x=m,g=b,v,_,w,C;if(i&&(w=nn,C=Bn,ve(x,o,w),ve(g,o,C),v=i(w),_=i(C),_<v)){x=b,g=m;const B=v;v=_,_=B,w=C}w||(w=nn,ve(x,o,w));const M=et(x*2,c),E=t(w,M,v,a+1,s+x);let P;if(E===Ks){const B=p(x),z=f(x)-B;P=n(B,z,!0,a+1,s+x,w)}else P=E&&ao(x,e,t,n,i,s,a+1);if(P)return!0;C=Bn,ve(g,o,C);const O=et(g*2,c),R=t(C,O,_,a+1,s+g);let A;if(R===Ks){const B=p(g),z=f(g)-B;A=n(B,z,!0,a+1,s+g,C)}else A=R&&ao(g,e,t,n,i,s,a+1);return!!A}}const hi=new W,co=new W;function Ld(r,e,t={},n=0,i=1/0){const s=n*n,a=i*i;let o=1/0,c=null;if(r.shapecast({boundsTraverseOrder:u=>(hi.copy(e).clamp(u.min,u.max),hi.distanceToSquared(e)),intersectsBounds:(u,p,f)=>f<o&&f<a,intersectsTriangle:(u,p)=>{u.closestPointToPoint(e,hi);const f=e.distanceToSquared(hi);return f<o&&(co.copy(hi),o=f,c=p),f<s}}),o===1/0)return null;const l=Math.sqrt(o);return t.point?t.point.copy(co):t.point=co.clone(),t.distance=l,t.faceIndex=c,t}const Fd=parseInt(Vl)>=169,pn=new W,fn=new W,mn=new W,Ir=new kn,zr=new kn,Br=new kn,tl=new W,nl=new W,il=new W,di=new W;function Vd(r,e,t,n,i,s,a,o){let c;if(s===Fl?c=r.intersectTriangle(n,t,e,!0,i):c=r.intersectTriangle(e,t,n,s!==ds,i),c===null)return null;const l=r.origin.distanceTo(i);return l<a||l>o?null:{distance:l,point:i.clone()}}function jd(r,e,t,n,i,s,a,o,c,l,u){pn.fromBufferAttribute(e,s),fn.fromBufferAttribute(e,a),mn.fromBufferAttribute(e,o);const p=Vd(r,pn,fn,mn,di,c,l,u);if(p){const f=new W;un.getBarycoord(di,pn,fn,mn,f),n&&(Ir.fromBufferAttribute(n,s),zr.fromBufferAttribute(n,a),Br.fromBufferAttribute(n,o),p.uv=un.getInterpolation(di,pn,fn,mn,Ir,zr,Br,new kn)),i&&(Ir.fromBufferAttribute(i,s),zr.fromBufferAttribute(i,a),Br.fromBufferAttribute(i,o),p.uv1=un.getInterpolation(di,pn,fn,mn,Ir,zr,Br,new kn)),t&&(tl.fromBufferAttribute(t,s),nl.fromBufferAttribute(t,a),il.fromBufferAttribute(t,o),p.normal=un.getInterpolation(di,pn,fn,mn,tl,nl,il,new W),p.normal.dot(r.direction)>0&&p.normal.multiplyScalar(-1));const m={a:s,b:a,c:o,normal:new W,materialIndex:0};un.getNormal(pn,fn,mn,m.normal),p.face=m,p.faceIndex=s,Fd&&(p.barycoord=f)}return p}function Nr(r,e,t,n,i,s,a){const o=n*3;let c=o+0,l=o+1,u=o+2;const p=r.index;r.index&&(c=p.getX(c),l=p.getX(l),u=p.getX(u));const{position:f,normal:m,uv:b,uv1:x}=r.attributes,g=jd(t,f,m,b,x,c,l,u,e,s,a);return g?(g.faceIndex=n,i&&i.push(g),g):null}function Me(r,e,t,n){const i=r.a,s=r.b,a=r.c;let o=e,c=e+1,l=e+2;t&&(o=t.getX(o),c=t.getX(c),l=t.getX(l)),i.x=n.getX(o),i.y=n.getY(o),i.z=n.getZ(o),s.x=n.getX(c),s.y=n.getY(c),s.z=n.getZ(c),a.x=n.getX(l),a.y=n.getY(l),a.z=n.getZ(l)}function Jd(r,e,t,n,i,s,a,o){const{geometry:c,_indirectBuffer:l}=r;for(let u=n,p=n+i;u<p;u++)Nr(c,e,t,u,s,a,o)}function Gd(r,e,t,n,i,s,a){const{geometry:o,_indirectBuffer:c}=r;let l=1/0,u=null;for(let p=n,f=n+i;p<f;p++){let m;m=Nr(o,e,t,p,null,s,a),m&&m.distance<l&&(u=m,l=m.distance)}return u}function Wd(r,e,t,n,i,s,a){const{geometry:o}=t,{index:c}=o,l=o.attributes.position;for(let u=r,p=e+r;u<p;u++){let f;if(f=u,Me(a,f*3,c,l),a.needsUpdate=!0,n(a,f,i,s))return!0}return!1}function Hd(r,e=null){e&&Array.isArray(e)&&(e=new Set(e));const t=r.geometry,n=t.index?t.index.array:null,i=t.attributes.position;let s,a,o,c,l=0;const u=r._roots;for(let f=0,m=u.length;f<m;f++)s=u[f],a=new Uint32Array(s),o=new Uint16Array(s),c=new Float32Array(s),p(0,l),l+=s.byteLength;function p(f,m,b=!1){const x=f*2;if(o[x+15]===Pr){const g=a[f+6],v=o[x+14];let _=1/0,w=1/0,C=1/0,M=-1/0,E=-1/0,P=-1/0;for(let O=3*g,R=3*(g+v);O<R;O++){let A=n[O];const B=i.getX(A),z=i.getY(A),D=i.getZ(A);B<_&&(_=B),B>M&&(M=B),z<w&&(w=z),z>E&&(E=z),D<C&&(C=D),D>P&&(P=D)}return c[f+0]!==_||c[f+1]!==w||c[f+2]!==C||c[f+3]!==M||c[f+4]!==E||c[f+5]!==P?(c[f+0]=_,c[f+1]=w,c[f+2]=C,c[f+3]=M,c[f+4]=E,c[f+5]=P,!0):!1}else{const g=f+8,v=a[f+6],_=g+m,w=v+m;let C=b,M=!1,E=!1;e?C||(M=e.has(_),E=e.has(w),C=!M&&!E):(M=!0,E=!0);const P=C||M,O=C||E;let R=!1;P&&(R=p(g,m,C));let A=!1;O&&(A=p(v,m,C));const B=R||A;if(B)for(let z=0;z<3;z++){const D=g+z,F=v+z,H=c[D],q=c[D+3],$=c[F],J=c[F+3];c[f+z]=H<$?H:$,c[f+z+3]=q>J?q:J}return B}}}function rn(r,e,t,n,i){let s,a,o,c,l,u;const p=1/t.direction.x,f=1/t.direction.y,m=1/t.direction.z,b=t.origin.x,x=t.origin.y,g=t.origin.z;let v=e[r],_=e[r+3],w=e[r+1],C=e[r+3+1],M=e[r+2],E=e[r+3+2];return p>=0?(s=(v-b)*p,a=(_-b)*p):(s=(_-b)*p,a=(v-b)*p),f>=0?(o=(w-x)*f,c=(C-x)*f):(o=(C-x)*f,c=(w-x)*f),s>c||o>a||((o>s||isNaN(s))&&(s=o),(c<a||isNaN(a))&&(a=c),m>=0?(l=(M-g)*m,u=(E-g)*m):(l=(E-g)*m,u=(M-g)*m),s>u||l>a)?!1:((l>s||s!==s)&&(s=l),(u<a||a!==a)&&(a=u),s<=i&&a>=n)}function qd(r,e,t,n,i,s,a,o){const{geometry:c,_indirectBuffer:l}=r;for(let u=n,p=n+i;u<p;u++){let f=l?l[u]:u;Nr(c,e,t,f,s,a,o)}}function Xd(r,e,t,n,i,s,a){const{geometry:o,_indirectBuffer:c}=r;let l=1/0,u=null;for(let p=n,f=n+i;p<f;p++){let m;m=Nr(o,e,t,c?c[p]:p,null,s,a),m&&m.distance<l&&(u=m,l=m.distance)}return u}function Yd(r,e,t,n,i,s,a){const{geometry:o}=t,{index:c}=o,l=o.attributes.position;for(let u=r,p=e+r;u<p;u++){let f;if(f=t.resolveTriangleIndex(u),Me(a,f*3,c,l),a.needsUpdate=!0,n(a,f,i,s))return!0}return!1}function Zd(r,e,t,n,i,s,a){de.setBuffer(r._roots[e]),lo(0,r,t,n,i,s,a),de.clearBuffer()}function lo(r,e,t,n,i,s,a){const{float32Array:o,uint16Array:c,uint32Array:l}=de,u=r*2;if(et(u,c)){const p=ct(r,l),f=pt(u,c);Jd(e,t,n,p,f,i,s,a)}else{const p=ft(r);rn(p,o,n,s,a)&&lo(p,e,t,n,i,s,a);const f=mt(r,l);rn(f,o,n,s,a)&&lo(f,e,t,n,i,s,a)}}const Kd=["x","y","z"];function Qd(r,e,t,n,i,s){de.setBuffer(r._roots[e]);const a=uo(0,r,t,n,i,s);return de.clearBuffer(),a}function uo(r,e,t,n,i,s){const{float32Array:a,uint16Array:o,uint32Array:c}=de;let l=r*2;if(et(l,o)){const u=ct(r,c),p=pt(l,o);return Gd(e,t,n,u,p,i,s)}else{const u=Qc(r,c),p=Kd[u],f=n.direction[p]>=0;let m,b;f?(m=ft(r),b=mt(r,c)):(m=mt(r,c),b=ft(r));const x=rn(m,a,n,i,s)?uo(m,e,t,n,i,s):null;if(x){const v=x.point[p];if(f?v<=a[b+u]:v>=a[b+u+3])return x}const g=rn(b,a,n,i,s)?uo(b,e,t,n,i,s):null;return x&&g?x.distance<=g.distance?x:g:x||g||null}}const Ur=new Ot,Un=new yt,Dn=new yt,pi=new Ct,rl=new Ve,Dr=new Ve;function $d(r,e,t,n){de.setBuffer(r._roots[e]);const i=ho(0,r,t,n);return de.clearBuffer(),i}function ho(r,e,t,n,i=null){const{float32Array:s,uint16Array:a,uint32Array:o}=de;let c=r*2;if(i===null&&(t.boundingBox||t.computeBoundingBox(),rl.set(t.boundingBox.min,t.boundingBox.max,n),i=rl),et(c,a)){const l=e.geometry,u=l.index,p=l.attributes.position,f=t.index,m=t.attributes.position,b=ct(r,o),x=pt(c,a);if(pi.copy(n).invert(),t.boundsTree)return ve(r,s,Dr),Dr.matrix.copy(pi),Dr.needsUpdate=!0,t.boundsTree.shapecast({intersectsBounds:g=>Dr.intersectsBox(g),intersectsTriangle:g=>{g.a.applyMatrix4(n),g.b.applyMatrix4(n),g.c.applyMatrix4(n),g.needsUpdate=!0;for(let v=b*3,_=(x+b)*3;v<_;v+=3)if(Me(Dn,v,u,p),Dn.needsUpdate=!0,g.intersectsTriangle(Dn))return!0;return!1}});for(let g=b*3,v=(x+b)*3;g<v;g+=3){Me(Un,g,u,p),Un.a.applyMatrix4(pi),Un.b.applyMatrix4(pi),Un.c.applyMatrix4(pi),Un.needsUpdate=!0;for(let _=0,w=f.count;_<w;_+=3)if(Me(Dn,_,f,m),Dn.needsUpdate=!0,Un.intersectsTriangle(Dn))return!0}}else{const l=r+8,u=o[r+6];return ve(l,s,Ur),!!(i.intersectsBox(Ur)&&ho(l,e,t,n,i)||(ve(u,s,Ur),i.intersectsBox(Ur)&&ho(u,e,t,n,i)))}}const Lr=new Ct,po=new Ve,fi=new Ve,ep=new W,tp=new W,np=new W,ip=new W;function rp(r,e,t,n={},i={},s=0,a=1/0){e.boundingBox||e.computeBoundingBox(),po.set(e.boundingBox.min,e.boundingBox.max,t),po.needsUpdate=!0;const o=r.geometry,c=o.attributes.position,l=o.index,u=e.attributes.position,p=e.index,f=gt.getPrimitive(),m=gt.getPrimitive();let b=ep,x=tp,g=null,v=null;i&&(g=np,v=ip);let _=1/0,w=null,C=null;return Lr.copy(t).invert(),fi.matrix.copy(Lr),r.shapecast({boundsTraverseOrder:M=>po.distanceToBox(M),intersectsBounds:(M,E,P)=>P<_&&P<a?(E&&(fi.min.copy(M.min),fi.max.copy(M.max),fi.needsUpdate=!0),!0):!1,intersectsRange:(M,E)=>{if(e.boundsTree)return e.boundsTree.shapecast({boundsTraverseOrder:P=>fi.distanceToBox(P),intersectsBounds:(P,O,R)=>R<_&&R<a,intersectsRange:(P,O)=>{for(let R=P,A=P+O;R<A;R++){Me(m,3*R,p,u),m.a.applyMatrix4(t),m.b.applyMatrix4(t),m.c.applyMatrix4(t),m.needsUpdate=!0;for(let B=M,z=M+E;B<z;B++){Me(f,3*B,l,c),f.needsUpdate=!0;const D=f.distanceToTriangle(m,b,g);if(D<_&&(x.copy(b),v&&v.copy(g),_=D,w=B,C=R),D<s)return!0}}}});{const P=zn(e);for(let O=0,R=P;O<R;O++){Me(m,3*O,p,u),m.a.applyMatrix4(t),m.b.applyMatrix4(t),m.c.applyMatrix4(t),m.needsUpdate=!0;for(let A=M,B=M+E;A<B;A++){Me(f,3*A,l,c),f.needsUpdate=!0;const z=f.distanceToTriangle(m,b,g);if(z<_&&(x.copy(b),v&&v.copy(g),_=z,w=A,C=O),z<s)return!0}}}}}),gt.releasePrimitive(f),gt.releasePrimitive(m),_===1/0?null:(n.point?n.point.copy(x):n.point=x.clone(),n.distance=_,n.faceIndex=w,i&&(i.point?i.point.copy(v):i.point=v.clone(),i.point.applyMatrix4(Lr),x.applyMatrix4(Lr),i.distance=x.sub(i.point).length(),i.faceIndex=C),n)}function sp(r,e=null){e&&Array.isArray(e)&&(e=new Set(e));const t=r.geometry,n=t.index?t.index.array:null,i=t.attributes.position;let s,a,o,c,l=0;const u=r._roots;for(let f=0,m=u.length;f<m;f++)s=u[f],a=new Uint32Array(s),o=new Uint16Array(s),c=new Float32Array(s),p(0,l),l+=s.byteLength;function p(f,m,b=!1){const x=f*2;if(o[x+15]===Pr){const g=a[f+6],v=o[x+14];let _=1/0,w=1/0,C=1/0,M=-1/0,E=-1/0,P=-1/0;for(let O=g,R=g+v;O<R;O++){const A=3*r.resolveTriangleIndex(O);for(let B=0;B<3;B++){let z=A+B;z=n?n[z]:z;const D=i.getX(z),F=i.getY(z),H=i.getZ(z);D<_&&(_=D),D>M&&(M=D),F<w&&(w=F),F>E&&(E=F),H<C&&(C=H),H>P&&(P=H)}}return c[f+0]!==_||c[f+1]!==w||c[f+2]!==C||c[f+3]!==M||c[f+4]!==E||c[f+5]!==P?(c[f+0]=_,c[f+1]=w,c[f+2]=C,c[f+3]=M,c[f+4]=E,c[f+5]=P,!0):!1}else{const g=f+8,v=a[f+6],_=g+m,w=v+m;let C=b,M=!1,E=!1;e?C||(M=e.has(_),E=e.has(w),C=!M&&!E):(M=!0,E=!0);const P=C||M,O=C||E;let R=!1;P&&(R=p(g,m,C));let A=!1;O&&(A=p(v,m,C));const B=R||A;if(B)for(let z=0;z<3;z++){const D=g+z,F=v+z,H=c[D],q=c[D+3],$=c[F],J=c[F+3];c[f+z]=H<$?H:$,c[f+z+3]=q>J?q:J}return B}}}function op(r,e,t,n,i,s,a){de.setBuffer(r._roots[e]),fo(0,r,t,n,i,s,a),de.clearBuffer()}function fo(r,e,t,n,i,s,a){const{float32Array:o,uint16Array:c,uint32Array:l}=de,u=r*2;if(et(u,c)){const p=ct(r,l),f=pt(u,c);qd(e,t,n,p,f,i,s,a)}else{const p=ft(r);rn(p,o,n,s,a)&&fo(p,e,t,n,i,s,a);const f=mt(r,l);rn(f,o,n,s,a)&&fo(f,e,t,n,i,s,a)}}const ap=["x","y","z"];function cp(r,e,t,n,i,s){de.setBuffer(r._roots[e]);const a=mo(0,r,t,n,i,s);return de.clearBuffer(),a}function mo(r,e,t,n,i,s){const{float32Array:a,uint16Array:o,uint32Array:c}=de;let l=r*2;if(et(l,o)){const u=ct(r,c),p=pt(l,o);return Xd(e,t,n,u,p,i,s)}else{const u=Qc(r,c),p=ap[u],f=n.direction[p]>=0;let m,b;f?(m=ft(r),b=mt(r,c)):(m=mt(r,c),b=ft(r));const x=rn(m,a,n,i,s)?mo(m,e,t,n,i,s):null;if(x){const v=x.point[p];if(f?v<=a[b+u]:v>=a[b+u+3])return x}const g=rn(b,a,n,i,s)?mo(b,e,t,n,i,s):null;return x&&g?x.distance<=g.distance?x:g:x||g||null}}const Fr=new Ot,Ln=new yt,Fn=new yt,mi=new Ct,sl=new Ve,Vr=new Ve;function lp(r,e,t,n){de.setBuffer(r._roots[e]);const i=yo(0,r,t,n);return de.clearBuffer(),i}function yo(r,e,t,n,i=null){const{float32Array:s,uint16Array:a,uint32Array:o}=de;let c=r*2;if(i===null&&(t.boundingBox||t.computeBoundingBox(),sl.set(t.boundingBox.min,t.boundingBox.max,n),i=sl),et(c,a)){const l=e.geometry,u=l.index,p=l.attributes.position,f=t.index,m=t.attributes.position,b=ct(r,o),x=pt(c,a);if(mi.copy(n).invert(),t.boundsTree)return ve(r,s,Vr),Vr.matrix.copy(mi),Vr.needsUpdate=!0,t.boundsTree.shapecast({intersectsBounds:g=>Vr.intersectsBox(g),intersectsTriangle:g=>{g.a.applyMatrix4(n),g.b.applyMatrix4(n),g.c.applyMatrix4(n),g.needsUpdate=!0;for(let v=b,_=x+b;v<_;v++)if(Me(Fn,3*e.resolveTriangleIndex(v),u,p),Fn.needsUpdate=!0,g.intersectsTriangle(Fn))return!0;return!1}});for(let g=b,v=x+b;g<v;g++){const _=e.resolveTriangleIndex(g);Me(Ln,3*_,u,p),Ln.a.applyMatrix4(mi),Ln.b.applyMatrix4(mi),Ln.c.applyMatrix4(mi),Ln.needsUpdate=!0;for(let w=0,C=f.count;w<C;w+=3)if(Me(Fn,w,f,m),Fn.needsUpdate=!0,Ln.intersectsTriangle(Fn))return!0}}else{const l=r+8,u=o[r+6];return ve(l,s,Fr),!!(i.intersectsBox(Fr)&&yo(l,e,t,n,i)||(ve(u,s,Fr),i.intersectsBox(Fr)&&yo(u,e,t,n,i)))}}const jr=new Ct,go=new Ve,yi=new Ve,up=new W,hp=new W,dp=new W,pp=new W;function fp(r,e,t,n={},i={},s=0,a=1/0){e.boundingBox||e.computeBoundingBox(),go.set(e.boundingBox.min,e.boundingBox.max,t),go.needsUpdate=!0;const o=r.geometry,c=o.attributes.position,l=o.index,u=e.attributes.position,p=e.index,f=gt.getPrimitive(),m=gt.getPrimitive();let b=up,x=hp,g=null,v=null;i&&(g=dp,v=pp);let _=1/0,w=null,C=null;return jr.copy(t).invert(),yi.matrix.copy(jr),r.shapecast({boundsTraverseOrder:M=>go.distanceToBox(M),intersectsBounds:(M,E,P)=>P<_&&P<a?(E&&(yi.min.copy(M.min),yi.max.copy(M.max),yi.needsUpdate=!0),!0):!1,intersectsRange:(M,E)=>{if(e.boundsTree){const P=e.boundsTree;return P.shapecast({boundsTraverseOrder:O=>yi.distanceToBox(O),intersectsBounds:(O,R,A)=>A<_&&A<a,intersectsRange:(O,R)=>{for(let A=O,B=O+R;A<B;A++){const z=P.resolveTriangleIndex(A);Me(m,3*z,p,u),m.a.applyMatrix4(t),m.b.applyMatrix4(t),m.c.applyMatrix4(t),m.needsUpdate=!0;for(let D=M,F=M+E;D<F;D++){const H=r.resolveTriangleIndex(D);Me(f,3*H,l,c),f.needsUpdate=!0;const q=f.distanceToTriangle(m,b,g);if(q<_&&(x.copy(b),v&&v.copy(g),_=q,w=D,C=A),q<s)return!0}}}})}else{const P=zn(e);for(let O=0,R=P;O<R;O++){Me(m,3*O,p,u),m.a.applyMatrix4(t),m.b.applyMatrix4(t),m.c.applyMatrix4(t),m.needsUpdate=!0;for(let A=M,B=M+E;A<B;A++){const z=r.resolveTriangleIndex(A);Me(f,3*z,l,c),f.needsUpdate=!0;const D=f.distanceToTriangle(m,b,g);if(D<_&&(x.copy(b),v&&v.copy(g),_=D,w=A,C=O),D<s)return!0}}}}}),gt.releasePrimitive(f),gt.releasePrimitive(m),_===1/0?null:(n.point?n.point.copy(x):n.point=x.clone(),n.distance=_,n.faceIndex=w,i&&(i.point?i.point.copy(v):i.point=v.clone(),i.point.applyMatrix4(jr),x.applyMatrix4(jr),i.distance=x.sub(i.point).length(),i.faceIndex=C),n)}function mp(){return typeof SharedArrayBuffer<"u"}const gi=new de.constructor,Jr=new de.constructor,sn=new oo(()=>new Ot),Vn=new Ot,jn=new Ot,vo=new Ot,So=new Ot;let bo=!1;function yp(r,e,t,n){if(bo)throw new Error("MeshBVH: Recursive calls to bvhcast not supported.");bo=!0;const i=r._roots,s=e._roots;let a,o=0,c=0;const l=new Ct().copy(t).invert();for(let u=0,p=i.length;u<p;u++){gi.setBuffer(i[u]),c=0;const f=sn.getPrimitive();ve(0,gi.float32Array,f),f.applyMatrix4(l);for(let m=0,b=s.length;m<b&&(Jr.setBuffer(s[m]),a=kt(0,0,t,l,n,o,c,0,0,f),Jr.clearBuffer(),c+=s[m].length,!a);m++);if(sn.releasePrimitive(f),gi.clearBuffer(),o+=i[u].length,a)break}return bo=!1,a}function kt(r,e,t,n,i,s=0,a=0,o=0,c=0,l=null,u=!1){let p,f;u?(p=Jr,f=gi):(p=gi,f=Jr);const m=p.float32Array,b=p.uint32Array,x=p.uint16Array,g=f.float32Array,v=f.uint32Array,_=f.uint16Array,w=r*2,C=e*2,M=et(w,x),E=et(C,_);let P=!1;if(E&&M)u?P=i(ct(e,v),pt(e*2,_),ct(r,b),pt(r*2,x),c,a+e,o,s+r):P=i(ct(r,b),pt(r*2,x),ct(e,v),pt(e*2,_),o,s+r,c,a+e);else if(E){const O=sn.getPrimitive();ve(e,g,O),O.applyMatrix4(t);const R=ft(r),A=mt(r,b);ve(R,m,Vn),ve(A,m,jn);const B=O.intersectsBox(Vn),z=O.intersectsBox(jn);P=B&&kt(e,R,n,t,i,a,s,c,o+1,O,!u)||z&&kt(e,A,n,t,i,a,s,c,o+1,O,!u),sn.releasePrimitive(O)}else{const O=ft(e),R=mt(e,v);ve(O,g,vo),ve(R,g,So);const A=l.intersectsBox(vo),B=l.intersectsBox(So);if(A&&B)P=kt(r,O,t,n,i,s,a,o,c+1,l,u)||kt(r,R,t,n,i,s,a,o,c+1,l,u);else if(A)if(M)P=kt(r,O,t,n,i,s,a,o,c+1,l,u);else{const z=sn.getPrimitive();z.copy(vo).applyMatrix4(t);const D=ft(r),F=mt(r,b);ve(D,m,Vn),ve(F,m,jn);const H=z.intersectsBox(Vn),q=z.intersectsBox(jn);P=H&&kt(O,D,n,t,i,a,s,c,o+1,z,!u)||q&&kt(O,F,n,t,i,a,s,c,o+1,z,!u),sn.releasePrimitive(z)}else if(B)if(M)P=kt(r,R,t,n,i,s,a,o,c+1,l,u);else{const z=sn.getPrimitive();z.copy(So).applyMatrix4(t);const D=ft(r),F=mt(r,b);ve(D,m,Vn),ve(F,m,jn);const H=z.intersectsBox(Vn),q=z.intersectsBox(jn);P=H&&kt(R,D,n,t,i,a,s,c,o+1,z,!u)||q&&kt(R,F,n,t,i,a,s,c,o+1,z,!u),sn.releasePrimitive(z)}}return P}const Gr=new Ve,ol=new Ot,gp={strategy:Zs,maxDepth:40,maxLeafTris:10,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,indirect:!1,verbose:!0,range:null};class xi{static serialize(e,t={}){t={cloneBuffers:!0,...t};const n=e.geometry,i=e._roots,s=e._indirectBuffer,a=n.getIndex();let o;return t.cloneBuffers?o={roots:i.map(c=>c.slice()),index:a?a.array.slice():null,indirectBuffer:s?s.slice():null}:o={roots:i,index:a?a.array:null,indirectBuffer:s},o}static deserialize(e,t,n={}){n={setIndex:!0,indirect:!!e.indirectBuffer,...n};const{index:i,roots:s,indirectBuffer:a}=e,o=new xi(t,{...n,[$s]:!0});if(o._roots=s,o._indirectBuffer=a||null,n.setIndex){const c=t.getIndex();if(c===null){const l=new ot(e.index,1,!1);t.setIndex(l)}else c.array!==i&&(c.array.set(i),c.needsUpdate=!0)}return o}get indirect(){return!!this._indirectBuffer}constructor(e,t={}){if(e.isBufferGeometry){if(e.index&&e.index.isInterleavedBufferAttribute)throw new Error("MeshBVH: InterleavedBufferAttribute is not supported for the index attribute.")}else throw new Error("MeshBVH: Only BufferGeometries are supported.");if(t=Object.assign({...gp,[$s]:!1},t),t.useSharedArrayBuffer&&!mp())throw new Error("MeshBVH: SharedArrayBuffer is not available.");this.geometry=e,this._roots=null,this._indirectBuffer=null,t[$s]||(Od(this,t),!e.boundingBox&&t.setBoundingBox&&(e.boundingBox=this.getBoundingBox(new Ot))),this.resolveTriangleIndex=t.indirect?n=>this._indirectBuffer[n]:n=>n}refit(e=null){return(this.indirect?sp:Hd)(this,e)}traverse(e,t=0){const n=this._roots[t],i=new Uint32Array(n),s=new Uint16Array(n);a(0);function a(o,c=0){const l=o*2,u=s[l+15]===Pr;if(u){const p=i[o+6],f=s[l+14];e(c,u,new Float32Array(n,o*4,6),p,f)}else{const p=o+ci/4,f=i[o+6],m=i[o+7];e(c,u,new Float32Array(n,o*4,6),m)||(a(p,c+1),a(f,c+1))}}}raycast(e,t=ea,n=0,i=1/0){const s=this._roots,a=this.geometry,o=[],c=t.isMaterial,l=Array.isArray(t),u=a.groups,p=c?t.side:t,f=this.indirect?op:Zd;for(let m=0,b=s.length;m<b;m++){const x=l?t[u[m].materialIndex].side:p,g=o.length;if(f(this,m,x,e,o,n,i),l){const v=u[m].materialIndex;for(let _=g,w=o.length;_<w;_++)o[_].face.materialIndex=v}}return o}raycastFirst(e,t=ea,n=0,i=1/0){const s=this._roots,a=this.geometry,o=t.isMaterial,c=Array.isArray(t);let l=null;const u=a.groups,p=o?t.side:t,f=this.indirect?cp:Qd;for(let m=0,b=s.length;m<b;m++){const x=c?t[u[m].materialIndex].side:p,g=f(this,m,x,e,n,i);g!=null&&(l==null||g.distance<l.distance)&&(l=g,c&&(g.face.materialIndex=u[m].materialIndex))}return l}intersectsGeometry(e,t){let n=!1;const i=this._roots,s=this.indirect?lp:$d;for(let a=0,o=i.length;a<o&&(n=s(this,a,e,t),!n);a++);return n}shapecast(e){const t=gt.getPrimitive(),n=this.indirect?Yd:Wd;let{boundsTraverseOrder:i,intersectsBounds:s,intersectsRange:a,intersectsTriangle:o}=e;if(a&&o){const p=a;a=(f,m,b,x,g)=>p(f,m,b,x,g)?!0:n(f,m,this,o,b,x,t)}else a||(o?a=(p,f,m,b)=>n(p,f,this,o,m,b,t):a=(p,f,m)=>m);let c=!1,l=0;const u=this._roots;for(let p=0,f=u.length;p<f;p++){const m=u[p];if(c=Dd(this,p,s,a,i,l),c)break;l+=m.byteLength}return gt.releasePrimitive(t),c}bvhcast(e,t,n){let{intersectsRanges:i,intersectsTriangles:s}=n;const a=gt.getPrimitive(),o=this.geometry.index,c=this.geometry.attributes.position,l=this.indirect?b=>{const x=this.resolveTriangleIndex(b);Me(a,x*3,o,c)}:b=>{Me(a,b*3,o,c)},u=gt.getPrimitive(),p=e.geometry.index,f=e.geometry.attributes.position,m=e.indirect?b=>{const x=e.resolveTriangleIndex(b);Me(u,x*3,p,f)}:b=>{Me(u,b*3,p,f)};if(s){const b=(x,g,v,_,w,C,M,E)=>{for(let P=v,O=v+_;P<O;P++){m(P),u.a.applyMatrix4(t),u.b.applyMatrix4(t),u.c.applyMatrix4(t),u.needsUpdate=!0;for(let R=x,A=x+g;R<A;R++)if(l(R),a.needsUpdate=!0,s(a,u,R,P,w,C,M,E))return!0}return!1};if(i){const x=i;i=function(g,v,_,w,C,M,E,P){return x(g,v,_,w,C,M,E,P)?!0:b(g,v,_,w,C,M,E,P)}}else i=b}return yp(this,e,t,i)}intersectsBox(e,t){return Gr.set(e.min,e.max,t),Gr.needsUpdate=!0,this.shapecast({intersectsBounds:n=>Gr.intersectsBox(n),intersectsTriangle:n=>Gr.intersectsTriangle(n)})}intersectsSphere(e){return this.shapecast({intersectsBounds:t=>e.intersectsBox(t),intersectsTriangle:t=>t.intersectsSphere(e)})}closestPointToGeometry(e,t,n={},i={},s=0,a=1/0){return(this.indirect?fp:rp)(this,e,t,n,i,s,a)}closestPointToPoint(e,t={},n=0,i=1/0){return Ld(this,e,t,n,i)}getBoundingBox(e){return e.makeEmpty(),this._roots.forEach(t=>{ve(0,new Float32Array(t),ol),e.union(ol)}),e}}function al(r,e,t){return r===null?null:(r.point.applyMatrix4(e.matrixWorld),r.distance=r.point.distanceTo(t.ray.origin),r.object=e,r)}const Wr=new Jl,cl=new W,ll=new Ct,vp=fs.prototype.raycast,Sp=jl.prototype.raycast,ul=new W,Ue=new fs,Hr=[];function bp(r,e){this.isBatchedMesh?xp.call(this,r,e):wp.call(this,r,e)}function xp(r,e){if(this.boundsTrees){const t=this.boundsTrees,n=this._drawInfo||this._instanceInfo,i=this._drawRanges||this._geometryInfo,s=this.matrixWorld;Ue.material=this.material,Ue.geometry=this.geometry;const a=Ue.geometry.boundsTree,o=Ue.geometry.drawRange;Ue.geometry.boundingSphere===null&&(Ue.geometry.boundingSphere=new $o);for(let c=0,l=n.length;c<l;c++){if(!this.getVisibleAt(c))continue;const u=n[c].geometryIndex;if(Ue.geometry.boundsTree=t[u],this.getMatrixAt(c,Ue.matrixWorld).premultiply(s),!Ue.geometry.boundsTree){this.getBoundingBoxAt(u,Ue.geometry.boundingBox),this.getBoundingSphereAt(u,Ue.geometry.boundingSphere);const p=i[u];Ue.geometry.setDrawRange(p.start,p.count)}Ue.raycast(r,Hr);for(let p=0,f=Hr.length;p<f;p++){const m=Hr[p];m.object=this,m.batchId=c,e.push(m)}Hr.length=0}Ue.geometry.boundsTree=a,Ue.geometry.drawRange=o,Ue.material=null,Ue.geometry=null}else Sp.call(this,r,e)}function wp(r,e){if(this.geometry.boundsTree){if(this.material===void 0)return;ll.copy(this.matrixWorld).invert(),Wr.copy(r.ray).applyMatrix4(ll),ul.setFromMatrixScale(this.matrixWorld),cl.copy(Wr.direction).multiply(ul);const t=cl.length(),n=r.near/t,i=r.far/t,s=this.geometry.boundsTree;if(r.firstHitOnly===!0){const a=al(s.raycastFirst(Wr,this.material,n,i),this,r);a&&e.push(a)}else{const a=s.raycast(Wr,this.material,n,i);for(let o=0,c=a.length;o<c;o++){const l=al(a[o],this,r);l&&e.push(l)}}}else vp.call(this,r,e)}function _p(r={}){return this.boundsTree=new xi(this,r),this.boundsTree}const yn=new W,gn=new W,vn=new W,hl=new ms,qr=new W,xo=new W,dl=new ms,pl=new ms,Xr=new Ct,fl=new Ct;function vi(r,e){if(!r&&!e)return;const t=r.count===e.count,n=r.normalized===e.normalized,i=r.array.constructor===e.array.constructor,s=r.itemSize===e.itemSize;if(!t||!n||!i||!s)throw new Error}function Si(r,e=null){const t=r.array.constructor,n=r.normalized,i=r.itemSize,s=e===null?r.count:e;return new ot(new t(i*s),i,n)}function ml(r,e,t=0){if(r.isInterleavedBufferAttribute){const n=r.itemSize;for(let i=0,s=r.count;i<s;i++){const a=i+t;e.setX(a,r.getX(i)),n>=2&&e.setY(a,r.getY(i)),n>=3&&e.setZ(a,r.getZ(i)),n>=4&&e.setW(a,r.getW(i))}}else{const n=e.array,i=n.constructor,s=n.BYTES_PER_ELEMENT*r.itemSize*t;new i(n.buffer,s,r.array.length).set(r.array)}}function Tp(r,e,t){const n=r.elements,i=e.elements;for(let s=0,a=i.length;s<a;s++)n[s]+=i[s]*t}function yl(r,e,t){const n=r.skeleton,i=r.geometry,s=n.bones,a=n.boneInverses;dl.fromBufferAttribute(i.attributes.skinIndex,e),pl.fromBufferAttribute(i.attributes.skinWeight,e),Xr.elements.fill(0);for(let o=0;o<4;o++){const c=pl.getComponent(o);if(c!==0){const l=dl.getComponent(o);fl.multiplyMatrices(s[l].matrixWorld,a[l]),Tp(Xr,fl,c)}}return Xr.multiply(r.bindMatrix).premultiply(r.bindMatrixInverse),t.transformDirection(Xr),t}function wo(r,e,t,n,i){qr.set(0,0,0);for(let s=0,a=r.length;s<a;s++){const o=e[s],c=r[s];o!==0&&(xo.fromBufferAttribute(c,n),t?qr.addScaledVector(xo,o):qr.addScaledVector(xo.sub(i),o))}i.add(qr)}function Mp(r,e={useGroups:!1,updateIndex:!1,skipAttributes:[]},t=new Yn){const n=r[0].index!==null,{useGroups:i=!1,updateIndex:s=!1,skipAttributes:a=[]}=e,o=new Set(Object.keys(r[0].attributes)),c={};let l=0;t.clearGroups();for(let u=0;u<r.length;++u){const p=r[u];let f=0;if(n!==(p.index!==null))throw new Error("StaticGeometryGenerator: All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them.");for(const m in p.attributes){if(!o.has(m))throw new Error('StaticGeometryGenerator: All geometries must have compatible attributes; make sure "'+m+'" attribute exists among all geometries, or in none of them.');c[m]===void 0&&(c[m]=[]),c[m].push(p.attributes[m]),f++}if(f!==o.size)throw new Error("StaticGeometryGenerator: Make sure all geometries have the same number of attributes.");if(i){let m;if(n)m=p.index.count;else if(p.attributes.position!==void 0)m=p.attributes.position.count;else throw new Error("StaticGeometryGenerator: The geometry must have either an index or a position attribute");t.addGroup(l,m,u),l+=m}}if(n){let u=!1;if(!t.index){let p=0;for(let f=0;f<r.length;++f)p+=r[f].index.count;t.setIndex(new ot(new Uint32Array(p),1,!1)),u=!0}if(s||u){const p=t.index;let f=0,m=0;for(let b=0;b<r.length;++b){const x=r[b],g=x.index;if(a[b]!==!0)for(let v=0;v<g.count;++v)p.setX(f,g.getX(v)+m),f++;m+=x.attributes.position.count}}}for(const u in c){const p=c[u];if(!(u in t.attributes)){let b=0;for(const x in p)b+=p[x].count;t.setAttribute(u,Si(c[u][0],b))}const f=t.attributes[u];let m=0;for(let b=0,x=p.length;b<x;b++){const g=p[b];a[b]!==!0&&ml(g,f,m),m+=g.count}}return t}function Cp(r,e){if(r===null||e===null)return r===e;if(r.length!==e.length)return!1;for(let t=0,n=r.length;t<n;t++)if(r[t]!==e[t])return!1;return!0}function Ep(r){const{index:e,attributes:t}=r;if(e)for(let n=0,i=e.count;n<i;n+=3){const s=e.getX(n),a=e.getX(n+2);e.setX(n,a),e.setX(n+2,s)}else for(const n in t){const i=t[n],s=i.itemSize;for(let a=0,o=i.count;a<o;a+=3)for(let c=0;c<s;c++){const l=i.getComponent(a,c),u=i.getComponent(a+2,c);i.setComponent(a,c,u),i.setComponent(a+2,c,l)}}return r}class Pp{constructor(e){this.matrixWorld=new Ct,this.geometryHash=null,this.boneMatrices=null,this.primitiveCount=-1,this.mesh=e,this.update()}update(){const e=this.mesh,t=e.geometry,n=e.skeleton,i=(t.index?t.index.count:t.attributes.position.count)/3;if(this.matrixWorld.copy(e.matrixWorld),this.geometryHash=t.attributes.position.version,this.primitiveCount=i,n){n.boneTexture||n.computeBoneTexture(),n.update();const s=n.boneMatrices;!this.boneMatrices||this.boneMatrices.length!==s.length?this.boneMatrices=s.slice():this.boneMatrices.set(s)}else this.boneMatrices=null}didChange(){const e=this.mesh,t=e.geometry,n=(t.index?t.index.count:t.attributes.position.count)/3;return!(this.matrixWorld.equals(e.matrixWorld)&&this.geometryHash===t.attributes.position.version&&Cp(e.skeleton&&e.skeleton.boneMatrices||null,this.boneMatrices)&&this.primitiveCount===n)}}class kp{constructor(e){Array.isArray(e)||(e=[e]);const t=[];e.forEach(n=>{n.traverseVisible(i=>{i.isMesh&&t.push(i)})}),this.meshes=t,this.useGroups=!0,this.applyWorldTransforms=!0,this.attributes=["position","normal","color","tangent","uv","uv2"],this._intermediateGeometry=new Array(t.length).fill().map(()=>new Yn),this._diffMap=new WeakMap}getMaterials(){const e=[];return this.meshes.forEach(t=>{Array.isArray(t.material)?e.push(...t.material):e.push(t.material)}),e}generate(e=new Yn){let t=[];const{meshes:n,useGroups:i,_intermediateGeometry:s,_diffMap:a}=this;for(let o=0,c=n.length;o<c;o++){const l=n[o],u=s[o],p=a.get(l);!p||p.didChange(l)?(this._convertToStaticGeometry(l,u),t.push(!1),p?p.update():a.set(l,new Pp(l))):t.push(!0)}if(s.length===0){e.setIndex(null);const o=e.attributes;for(const c in o)e.deleteAttribute(c);for(const c in this.attributes)e.setAttribute(this.attributes[c],new ot(new Float32Array(0),4,!1))}else Mp(s,{useGroups:i,skipAttributes:t},e);for(const o in e.attributes)e.attributes[o].needsUpdate=!0;return e}_convertToStaticGeometry(e,t=new Yn){const n=e.geometry,i=this.applyWorldTransforms,s=this.attributes.includes("normal"),a=this.attributes.includes("tangent"),o=n.attributes,c=t.attributes;!t.index&&n.index&&(t.index=n.index.clone()),c.position||t.setAttribute("position",Si(o.position)),s&&!c.normal&&o.normal&&t.setAttribute("normal",Si(o.normal)),a&&!c.tangent&&o.tangent&&t.setAttribute("tangent",Si(o.tangent)),vi(n.index,t.index),vi(o.position,c.position),s&&vi(o.normal,c.normal),a&&vi(o.tangent,c.tangent);const l=o.position,u=s?o.normal:null,p=a?o.tangent:null,f=n.morphAttributes.position,m=n.morphAttributes.normal,b=n.morphAttributes.tangent,x=n.morphTargetsRelative,g=e.morphTargetInfluences,v=new Gl;v.getNormalMatrix(e.matrixWorld),n.index&&t.index.array.set(n.index.array);for(let _=0,w=o.position.count;_<w;_++)yn.fromBufferAttribute(l,_),u&&gn.fromBufferAttribute(u,_),p&&(hl.fromBufferAttribute(p,_),vn.fromBufferAttribute(p,_)),g&&(f&&wo(f,g,x,_,yn),m&&wo(m,g,x,_,gn),b&&wo(b,g,x,_,vn)),e.isSkinnedMesh&&(e.applyBoneTransform(_,yn),u&&yl(e,_,gn),p&&yl(e,_,vn)),i&&yn.applyMatrix4(e.matrixWorld),c.position.setXYZ(_,yn.x,yn.y,yn.z),u&&(i&&gn.applyNormalMatrix(v),c.normal.setXYZ(_,gn.x,gn.y,gn.z)),p&&(i&&vn.transformDirection(e.matrixWorld),c.tangent.setXYZW(_,vn.x,vn.y,vn.z,hl.w));for(const _ in this.attributes){const w=this.attributes[_];w==="position"||w==="tangent"||w==="normal"||!(w in o)||(c[w]||t.setAttribute(w,Si(o[w])),vi(o[w],c[w]),ml(o[w],c[w]))}return e.matrixWorld.determinant()<0&&Ep(t),t}}const Rp=Object.freeze(Object.defineProperty({__proto__:null,AVERAGE:Gc,CENTER:Zs,CONTAINED:Ks,ExtendedTriangle:yt,MeshBVH:xi,OrientedBox:Ve,SAH:Wc,StaticGeometryGenerator:kp,acceleratedRaycast:bp,computeBoundsTree:_p},Symbol.toStringTag,{value:"Module"}));class Ap{constructor(e){this.name="WorkerBase",this.running=!1,this.worker=e,this.worker.onerror=t=>{throw t.message?new Error(`${this.name}: Could not create Web Worker with error "${t.message}"`):new Error(`${this.name}: Could not create Web Worker.`)}}runTask(){}generate(...e){if(this.running)throw new Error("GenerateMeshBVHWorker: Already running job.");if(this.worker===null)throw new Error("GenerateMeshBVHWorker: Worker has been disposed.");this.running=!0;const t=this.runTask(this.worker,...e);return t.finally(()=>{this.running=!1}),t}dispose(){this.worker.terminate(),this.worker=null}}const vt={node:"node",material:"material",camera:"camera",light:"light"},Sn="KHR_animation_pointer",Op={CUBICSPLINE:void 0,LINEAR:ta,STEP:Hl};class Ip{constructor(e){this.name=Sn,this.parser=e,this.animationPointerResolver=null}setAnimationPointerResolver(e){return this.animationPointerResolver=e,this}loadAnimationTargetFromChannel(e){const t=e.target,n=t.node!==void 0?t.node:t.id;return this.parser.getDependency("node",n)}loadAnimationTargetFromChannelWithAnimationPointer(e){Bp();const t=e.target,n=t.extensions&&t.extensions[Sn]&&t.path&&t.path==="pointer";if(!n)return null;let i,s=vt.node,a;if(n){const c=t.extensions[Sn];let l=c.pointer;if(!l){console.warn("Invalid path",c,t);return}if(l.startsWith("/materials/")?s=vt.material:l.startsWith("/extensions/KHR_lights_punctual/lights/")?s=vt.light:l.startsWith("/cameras/")&&(s=vt.camera),a=this._tryResolveTargetId(l,s),a===null||isNaN(a)){console.warn("Failed resolving animation node id: "+a,l);return}switch(s){case vt.material:const u=("/materials/"+a.toString()+"/").length,p=l.substring(0,u);switch(i=l.substring(u),i){case"pbrMetallicRoughness/baseColorFactor":i="color";break;case"pbrMetallicRoughness/roughnessFactor":i="roughness";break;case"pbrMetallicRoughness/metallicFactor":i="metalness";break;case"emissiveFactor":i="emissive";break;case"alphaCutoff":i="alphaTest";break;case"occlusionTexture/strength":i="aoMapIntensity";break;case"normalTexture/scale":i="normalScale";break;case"pbrMetallicRoughness/baseColorTexture/extensions/KHR_texture_transform/scale":i="map/repeat";break;case"pbrMetallicRoughness/baseColorTexture/extensions/KHR_texture_transform/offset":i="map/offset";break;case"emissiveTexture/extensions/KHR_texture_transform/scale":i="emissiveMap/repeat";break;case"emissiveTexture/extensions/KHR_texture_transform/offset":i="emissiveMap/offset";break;case"extensions/KHR_materials_emissive_strength/emissiveStrength":i="emissiveIntensity";break;case"extensions/KHR_materials_transmission/transmissionFactor":i="transmission";break;case"extensions/KHR_materials_ior/ior":i="ior";break;case"extensions/KHR_materials_volume/thicknessFactor":i="thickness";break;case"extensions/KHR_materials_volume/attenuationColor":i="attenuationColor";break;case"extensions/KHR_materials_volume/attenuationDistance":i="attenuationDistance";break;case"extensions/KHR_materials_iridescence/iridescenceFactor":i="iridescence";break;case"extensions/KHR_materials_iridescence/iridescenceIor":i="iridescenceIOR";break;case"extensions/KHR_materials_iridescence/iridescenceThicknessMinimum":i="iridescenceThicknessRange[0]";break;case"extensions/KHR_materials_iridescence/iridescenceThicknessMaximum":i="iridescenceThicknessRange[1]";break;case"extensions/KHR_materials_clearcoat/clearcoatFactor":i="clearcoat";break;case"extensions/KHR_materials_clearcoat/clearcoatRoughnessFactor":i="clearcoatRoughness";break;case"extensions/KHR_materials_sheen/sheenColorFactor":i="sheenColor";break;case"extensions/KHR_materials_sheen/sheenRoughnessFactor":i="sheenRoughness";break;case"extensions/KHR_materials_specular/specularFactor":i="specularIntensity";break;case"extensions/KHR_materials_specular/specularColorFactor":i="specularColor";break}l=p+i;break;case vt.node:const f=("/nodes/"+a.toString()+"/").length,m=l.substring(0,f);switch(i=l.substring(f),i){case"translation":i="position";break;case"rotation":i="quaternion";break;case"scale":i="scale";break;case"weights":i="morphTargetInfluences";break;case"KHR_node_visibility/visible":i="visible";break}l=m+i;break;case vt.light:const b=("/extensions/KHR_lights_punctual/lights/"+a.toString()+"/").length;switch(i=l.substring(b),i){case"color":break;case"intensity":break;case"spot/innerConeAngle":i="penumbra";break;case"spot/outerConeAngle":i="angle";break;case"range":i="distance";break}l="/lights/"+a.toString()+"/"+i;break;case vt.camera:const x=("/cameras/"+a.toString()+"/").length,g=l.substring(0,x);switch(i=l.substring(x),i){case"perspective/yfov":i="fov";break;case"perspective/znear":case"orthographic/znear":i="near";break;case"perspective/zfar":case"orthographic/zfar":i="far";break;case"perspective/aspect":i="aspect";break;case"orthographic/xmag":i="zoom";break;case"orthographic/ymag":i="zoom";break}l=g+i;break}this.animationPointerResolver?.resolvePath&&(l=this.animationPointerResolver.resolvePath(l)),t.extensions[Sn].pointer=l}if(a==null||isNaN(a)){console.warn("Failed resolving animation node id: "+a,t);return}let o;return s===vt.node?o=this.parser.getDependency("node",a):s===vt.material?o=this.parser.getDependency("material",a):s===vt.light?o=this.parser.getDependency("light",a):s===vt.camera?o=this.parser.getDependency("camera",a):console.error("Unhandled type",s),o}createAnimationTracksWithAnimationPointer(e,t,n,i,s){if(!(s.extensions&&s.extensions[Sn]&&s.path&&s.path==="pointer"))return null;let a=s.extensions[Sn].pointer;if(!a)return null;const o=[];a=a.replaceAll("/",".");const c=a.split(".");var l=e.name!==void 0&&e.name!==null?e.name:e.uuid;if(c[2]=l,c[3]==="morphTargetInfluences"&&e.type==="Group"){for(const f of e.children)f instanceof Wl&&f.morphTargetInfluences&&(c[3]=f.name,c[4]="morphTargetInfluences",p(this.parser));return o}p(this.parser);function u(f,m){try{const b=m.split(".").filter(Boolean),x=b[b.length-1].replace(/\[.*\]$/,"");return x in f?typeof f[x]=="boolean":!1}catch{return!1}}function p(f){a=c.join(".");let m,b=!1;switch(n.itemSize){case 1:Object.prototype.toString.call(n.array)==="[object Uint8Array]"&&u(e,a)?(m=Kl,b=!0):m=Ql;break;case 2:case 3:m=Zl;break;case 4:a.endsWith(".quaternion")?m=Xl:m=Yl;break}if(!m){console.warn("Unsupported output accessor format",n);return}const x=i.interpolation!==void 0?Op[i.interpolation]:ta;let g=f._getArrayFromAccessor(n);a.endsWith(".fov")&&(g=g.map(_=>_/Math.PI*180)),b&&(g=g.map(_=>_>0));const v=new m(a,t.array,g,x);if(x==="CUBICSPLINE"&&f._createCubicSplineTrackInterpolant(v),o.push(v),a&&n.itemSize===4&&a.startsWith(".materials.")&&a.endsWith(".color")){const _=new Float32Array(g.length/4);for(let C=0,M=g.length/4;C<M;C+=1)_[C]=g[C*4+3];const w=new m(a.replace(".color",".opacity"),t.array,_,x);x==="CUBICSPLINE"&&f._createCubicSplineTrackInterpolant(v),o.push(w)}}return o}_tryResolveTargetId(e,t){let n="";return t==="node"?n=e.substring(7):t==="material"?n=e.substring(11):t==="light"?n=e.substring(39):t==="camera"&&(n=e.substring(9)),n=n.substring(0,n.indexOf("/")),Number.parseInt(n)}loadAnimation(e){const t=this,n=this.parser.json,i=this.parser,s=n.animations[e],a=s.name?s.name:"animation_"+e,o=[],c=[],l=[],u=[],p=[];for(let f=0,m=s.channels.length;f<m;f++){const b=s.channels[f],x=s.samplers[b.sampler],g=b.target,v=s.parameters!==void 0?s.parameters[x.input]:x.input,_=s.parameters!==void 0?s.parameters[x.output]:x.output;let w=t.loadAnimationTargetFromChannelWithAnimationPointer(b);w||(w=t.loadAnimationTargetFromChannel(b)),o.push(w),c.push(i.getDependency("accessor",v)),l.push(i.getDependency("accessor",_)),u.push(x),p.push(g)}return Promise.all([Promise.all(o),Promise.all(c),Promise.all(l),Promise.all(u),Promise.all(p)]).then(function(f){const m=f[0],b=f[1],x=f[2],g=f[3],v=f[4],_=[];for(let w=0,C=m.length;w<C;w++){const M=m[w],E=b[w],P=x[w],O=g[w],R=v[w];if(M===void 0)continue;M.updateMatrix&&(M.updateMatrix(),M.matrixAutoUpdate=!0);let A=t.createAnimationTracksWithAnimationPointer(M,E,P,O,R);if(A||(A=i._createAnimationTracks(M,E,P,O,R)),A)for(let B=0;B<A.length;B++)_.push(A[B])}return new ql(a,void 0,_)})}}let gl=!1,zp=null;function Bp(){if(gl)return;gl=!0;const r=zp||=na.findNode;na.findNode=function(e,t){if(!t)return r(e,t);if(t.startsWith(".materials.")){const n=t.substring(11).substring(t.indexOf(".")),i=n.indexOf("."),s=i<0?n:n.substring(0,i);let a=null;return e.traverse(o=>{a!==null||o.type!=="Mesh"&&o.type!=="SkinnedMesh"||o.material&&(o.material.uuid===s||o.material.name===s)&&(a=o.material,a!==null&&(n.endsWith(".map")?a=a.map:n.endsWith(".emissiveMap")&&(a=a.emissiveMap)))}),a}else if(t.startsWith(".nodes.")||t.startsWith(".lights.")||t.startsWith(".cameras.")){const n=t.split(".");let i;for(let s=1;s<n.length;s++){const a=n[s];if(a.length==36)i=e.getObjectByProperty("uuid",a);else if(i&&i[a]){const o=Number.parseInt(a);let c=a;o>=0&&(c=o),i=i[c]}else{const o=e.getObjectByName(a);o&&(i=o)}}if(!i){const s=r(e,n[2]);return s||console.warn(Sn+": Property binding not found",t,e,e.name,n),s}return i}return r(e,t)}}const Np=Object.freeze(Object.defineProperty({__proto__:null,GLTFAnimationPointerExtension:Ip},Symbol.toStringTag,{value:"Module"}));export{bc as $70d766613f57b014$export$2e2bcd8739ae039,cd as BatchedParticleRenderer,_o as Builder,bi as ByteBuffer,xn as ConstantColor,ne as ConstantValue,Rt as Matrix4,xi as MeshBVH,su as MotionController,Qr as ParticleSystem,V as RenderMode,ra as SIZE_PREFIX_LENGTH,Tr as TrailParticle,tt as Vector4,Ap as WorkerBase,Uu as bundler,ud as createNoise4D,eu as fetchProfile,yd as index,Rp as index$1,Np as index$2,$u as md5,Xu as v5};
|
|
1121
|
+
}`;class ad extends Fc{constructor(e){super(e),this.vector_=new G,this.vector2_=new G,this.vector3_=new G,this.quaternion_=new ie,this.maxParticles=1e4,this.setupBuffers(),this.rebuildMaterial()}setupBuffers(){this.geometry&&this.geometry.dispose(),this.geometry=new Yn,this.indexBuffer=new ot(new Uint32Array(this.maxParticles*6),1),this.indexBuffer.setUsage(He),this.geometry.setIndex(this.indexBuffer),this.positionBuffer=new ot(new Float32Array(this.maxParticles*6),3),this.positionBuffer.setUsage(He),this.geometry.setAttribute("position",this.positionBuffer),this.previousBuffer=new ot(new Float32Array(this.maxParticles*6),3),this.previousBuffer.setUsage(He),this.geometry.setAttribute("previous",this.previousBuffer),this.nextBuffer=new ot(new Float32Array(this.maxParticles*6),3),this.nextBuffer.setUsage(He),this.geometry.setAttribute("next",this.nextBuffer),this.widthBuffer=new ot(new Float32Array(this.maxParticles*2),1),this.widthBuffer.setUsage(He),this.geometry.setAttribute("width",this.widthBuffer),this.sideBuffer=new ot(new Float32Array(this.maxParticles*2),1),this.sideBuffer.setUsage(He),this.geometry.setAttribute("side",this.sideBuffer),this.uvBuffer=new ot(new Float32Array(this.maxParticles*4),2),this.uvBuffer.setUsage(He),this.geometry.setAttribute("uv",this.uvBuffer),this.colorBuffer=new ot(new Float32Array(this.maxParticles*8),4),this.colorBuffer.setUsage(He),this.geometry.setAttribute("color",this.colorBuffer)}expandBuffers(e){for(;e>=this.maxParticles;)this.maxParticles*=2;this.setupBuffers()}rebuildMaterial(){this.layers.mask=this.settings.layers.mask;const e={lineWidth:{value:1},map:{value:null},useMap:{value:0},alphaMap:{value:null},useAlphaMap:{value:0},resolution:{value:new Jn(1,1)},sizeAttenuation:{value:1},visibility:{value:1},alphaTest:{value:0}},t={};if(t.USE_UV="",t.USE_COLOR_ALPHA="",this.settings.material.map&&(t.USE_MAP="",t.MAP_UV=Ys(this.settings.material.map.channel),e.map=new Mt(this.settings.material.map),e.mapTransform=new Mt(new Dt().copy(this.settings.material.map.matrix))),this.settings.material.defines&&this.settings.material.defines.USE_COLOR_AS_ALPHA!==void 0&&(t.USE_COLOR_AS_ALPHA=""),this.settings.renderMode===V.Trail)this.material=new ps({uniforms:e,defines:t,vertexShader:od,fragmentShader:sd,transparent:this.settings.material.transparent,depthWrite:!this.settings.material.transparent,side:this.settings.material.side,blending:this.settings.material.blending||Ko,blendDst:this.settings.material.blendDst,blendSrc:this.settings.material.blendSrc,blendEquation:this.settings.material.blendEquation,premultipliedAlpha:this.settings.material.premultipliedAlpha});else throw new Error("render mode unavailable")}update(){let e=0,t=0,n=0;this.systems.forEach(i=>{for(let s=0;s<i.particleNum;s++)n+=i.particles[s].previous.length*2}),n>this.maxParticles&&this.expandBuffers(n),this.systems.forEach(i=>{i.emitter.updateMatrixWorld&&(i.emitter.updateWorldMatrix(!0,!1),i.emitter.updateMatrixWorld(!0));const s=this.quaternion_,a=this.vector2_,o=this.vector3_;i.emitter.matrixWorld.decompose(a,s,o);const c=i.particles,l=i.particleNum,u=this.settings.uTileCount,p=this.settings.vTileCount,f=1/u,m=1/p;for(let b=0;b<l;b++){const x=c[b],g=x.uvTile%p,v=Math.floor(x.uvTile/p+.001),_=x.previous.values();let w=_.next(),C=w.value,M=C;w.done||(w=_.next());let E;w.value!==void 0?E=w.value:E=M;for(let P=0;P<x.previous.length;P++,e+=2){if(this.positionBuffer.setXYZ(e,M.position.x,M.position.y,M.position.z),this.positionBuffer.setXYZ(e+1,M.position.x,M.position.y,M.position.z),i.worldSpace?(this.positionBuffer.setXYZ(e,M.position.x,M.position.y,M.position.z),this.positionBuffer.setXYZ(e+1,M.position.x,M.position.y,M.position.z)):(x.parentMatrix?this.vector_.copy(M.position).applyMatrix4(x.parentMatrix):this.vector_.copy(M.position).applyMatrix4(i.emitter.matrixWorld),this.positionBuffer.setXYZ(e,this.vector_.x,this.vector_.y,this.vector_.z),this.positionBuffer.setXYZ(e+1,this.vector_.x,this.vector_.y,this.vector_.z)),i.worldSpace?(this.previousBuffer.setXYZ(e,C.position.x,C.position.y,C.position.z),this.previousBuffer.setXYZ(e+1,C.position.x,C.position.y,C.position.z)):(x.parentMatrix?this.vector_.copy(C.position).applyMatrix4(x.parentMatrix):this.vector_.copy(C.position).applyMatrix4(i.emitter.matrixWorld),this.previousBuffer.setXYZ(e,this.vector_.x,this.vector_.y,this.vector_.z),this.previousBuffer.setXYZ(e+1,this.vector_.x,this.vector_.y,this.vector_.z)),i.worldSpace?(this.nextBuffer.setXYZ(e,E.position.x,E.position.y,E.position.z),this.nextBuffer.setXYZ(e+1,E.position.x,E.position.y,E.position.z)):(x.parentMatrix?this.vector_.copy(E.position).applyMatrix4(x.parentMatrix):this.vector_.copy(E.position).applyMatrix4(i.emitter.matrixWorld),this.nextBuffer.setXYZ(e,this.vector_.x,this.vector_.y,this.vector_.z),this.nextBuffer.setXYZ(e+1,this.vector_.x,this.vector_.y,this.vector_.z)),this.sideBuffer.setX(e,-1),this.sideBuffer.setX(e+1,1),i.worldSpace)this.widthBuffer.setX(e,M.size),this.widthBuffer.setX(e+1,M.size);else if(x.parentMatrix)this.widthBuffer.setX(e,M.size),this.widthBuffer.setX(e+1,M.size);else{const O=(Math.abs(o.x)+Math.abs(o.y)+Math.abs(o.z))/3;this.widthBuffer.setX(e,M.size*O),this.widthBuffer.setX(e+1,M.size*O)}this.uvBuffer.setXY(e,(P/x.previous.length+g)*f,(p-v-1)*m),this.uvBuffer.setXY(e+1,(P/x.previous.length+g)*f,(p-v)*m),this.colorBuffer.setXYZW(e,M.color.x,M.color.y,M.color.z,M.color.w),this.colorBuffer.setXYZW(e+1,M.color.x,M.color.y,M.color.z,M.color.w),P+1<x.previous.length&&(this.indexBuffer.setX(t*3,e),this.indexBuffer.setX(t*3+1,e+1),this.indexBuffer.setX(t*3+2,e+2),t++,this.indexBuffer.setX(t*3,e+2),this.indexBuffer.setX(t*3+1,e+1),this.indexBuffer.setX(t*3+2,e+3),t++),C=M,M=E,w.done||(w=_.next(),w.value!==void 0&&(E=w.value))}}}),this.positionBuffer.clearUpdateRanges(),this.positionBuffer.addUpdateRange(0,e*3),this.positionBuffer.needsUpdate=!0,this.previousBuffer.clearUpdateRanges(),this.previousBuffer.addUpdateRange(0,e*3),this.previousBuffer.needsUpdate=!0,this.nextBuffer.clearUpdateRanges(),this.nextBuffer.addUpdateRange(0,e*3),this.nextBuffer.needsUpdate=!0,this.sideBuffer.clearUpdateRanges(),this.sideBuffer.addUpdateRange(0,e),this.sideBuffer.needsUpdate=!0,this.widthBuffer.clearUpdateRanges(),this.widthBuffer.addUpdateRange(0,e),this.widthBuffer.needsUpdate=!0,this.uvBuffer.clearUpdateRanges(),this.uvBuffer.addUpdateRange(0,e*2),this.uvBuffer.needsUpdate=!0,this.colorBuffer.clearUpdateRanges(),this.colorBuffer.addUpdateRange(0,e*4),this.colorBuffer.needsUpdate=!0,this.indexBuffer.clearUpdateRanges(),this.indexBuffer.addUpdateRange(0,t*3),this.indexBuffer.needsUpdate=!0,this.geometry.setDrawRange(0,t*3)}dispose(){this.geometry.dispose()}}class Ki{get geometry(){return this._geometry}set geometry(e){if(this._geometry=e,e===void 0||typeof e=="string")return;const t=new un;this._triangleIndexToArea.length=0;let n=0;if(!e.getIndex())return;const i=e.getIndex().array,s=i.length/3;this._triangleIndexToArea.push(0);for(let a=0;a<s;a++)t.setFromAttributeAndIndices(e.getAttribute("position"),i[a*3],i[a*3+1],i[a*3+2]),n+=t.getArea(),this._triangleIndexToArea.push(n);e.userData.triangleIndexToArea=this._triangleIndexToArea}constructor(e){this.type="mesh_surface",this._triangleIndexToArea=[],this._tempA=new W,this._tempB=new W,this._tempC=new W,e&&(this.geometry=e)}initialize(e){const t=this._geometry;if(!t||t.getIndex()===null){e.position.set(0,0,0),e.velocity.set(0,0,1).multiplyScalar(e.startSpeed);return}const n=this._triangleIndexToArea.length-1;let i=0,s=n;const a=Math.random()*this._triangleIndexToArea[n];for(;i+1<s;){const m=Math.floor((i+s)/2);a<this._triangleIndexToArea[m]?s=m:i=m}let o=Math.random(),c=Math.random();o+c>1&&(o=1-o,c=1-c);const l=t.getIndex().array[i*3],u=t.getIndex().array[i*3+1],p=t.getIndex().array[i*3+2],f=t.getAttribute("position");this._tempA.fromBufferAttribute(f,l),this._tempB.fromBufferAttribute(f,u),this._tempC.fromBufferAttribute(f,p),this._tempB.sub(this._tempA),this._tempC.sub(this._tempA),this._tempA.addScaledVector(this._tempB,o).addScaledVector(this._tempC,c),e.position.copy(this._tempA),this._tempA.copy(this._tempB).cross(this._tempC).normalize(),e.velocity.copy(this._tempA).normalize().multiplyScalar(e.startSpeed)}toJSON(){return{type:"mesh_surface",mesh:this._geometry?this._geometry.uuid:""}}static fromJSON(e,t){return new Ki(t.geometries[e.geometry])}clone(){return new Ki(this._geometry)}update(e,t){}}Dh({id:"three.quarks",emitterShapes:[{type:"mesh_surface",params:[["geometry",["geometry"]]],constructor:Ki,loadJSON:Ki.fromJSON}],behaviors:[]});class To extends Yo{constructor(){super(),this.batches=[],this.systemToBatchIndex=new Map,this.type="BatchedRenderer",this.depthTexture=null}static equals(e,t){return e.material.side===t.material.side&&e.material.blending===t.material.blending&&e.material.blendSrc===t.material.blendSrc&&e.material.blendDst===t.material.blendDst&&e.material.blendEquation===t.material.blendEquation&&e.material.premultipliedAlpha===t.material.premultipliedAlpha&&e.material.transparent===t.material.transparent&&e.material.depthTest===t.material.depthTest&&e.material.type===t.material.type&&e.material.alphaTest===t.material.alphaTest&&e.material.map===t.material.map&&e.renderMode===t.renderMode&&e.blendTiles===t.blendTiles&&e.softParticles===t.softParticles&&e.softFarFade===t.softFarFade&&e.softNearFade===t.softNearFade&&e.uTileCount===t.uTileCount&&e.vTileCount===t.vTileCount&&e.instancingGeometry===t.instancingGeometry&&e.renderOrder===t.renderOrder&&e.layers.mask===t.layers.mask}addSystem(e){e._renderer=this;const t=e.getRendererSettings();for(let i=0;i<this.batches.length;i++)if(To.equals(this.batches[i].settings,t)){this.batches[i].addSystem(e),this.systemToBatchIndex.set(e,i);return}let n;switch(t.renderMode){case V.Trail:n=new ad(t);break;case V.Mesh:case V.BillBoard:case V.VerticalBillBoard:case V.HorizontalBillBoard:case V.StretchedBillBoard:n=new rd(t);break}this.depthTexture&&n.applyDepthTexture(this.depthTexture),n.addSystem(e),this.batches.push(n),this.systemToBatchIndex.set(e,this.batches.length-1),this.add(n)}deleteSystem(e){const t=this.systemToBatchIndex.get(e);t!=null&&(this.batches[t].removeSystem(e),this.systemToBatchIndex.delete(e))}setDepthTexture(e){this.depthTexture=e;for(const t of this.batches)t.applyDepthTexture(e)}updateSystem(e){this.deleteSystem(e),this.addSystem(e)}update(e){this.systemToBatchIndex.forEach((t,n)=>{n.update(e)});for(let t=0;t<this.batches.length;t++)this.batches[t].update()}}const cd=To;qh(),console.log("%c Particle system powered by three.quarks. https://quarks.art/","font-size: 14px; font-weight: bold;");const jc=Math.sqrt(5),ld=(jc-1)/4,Ne=(5-jc)/20,Cr=r=>Math.floor(r)|0,Er=new Float64Array([0,1,1,1,0,1,1,-1,0,1,-1,1,0,1,-1,-1,0,-1,1,1,0,-1,1,-1,0,-1,-1,1,0,-1,-1,-1,1,0,1,1,1,0,1,-1,1,0,-1,1,1,0,-1,-1,-1,0,1,1,-1,0,1,-1,-1,0,-1,1,-1,0,-1,-1,1,1,0,1,1,1,0,-1,1,-1,0,1,1,-1,0,-1,-1,1,0,1,-1,1,0,-1,-1,-1,0,1,-1,-1,0,-1,1,1,1,0,1,1,-1,0,1,-1,1,0,1,-1,-1,0,-1,1,1,0,-1,1,-1,0,-1,-1,1,0,-1,-1,-1,0]);function ud(r=Math.random){const e=hd(r),t=new Float64Array(e).map(a=>Er[a%32*4]),n=new Float64Array(e).map(a=>Er[a%32*4+1]),i=new Float64Array(e).map(a=>Er[a%32*4+2]),s=new Float64Array(e).map(a=>Er[a%32*4+3]);return function(a,o,c,l){let u,p,f,m,b;const x=(a+o+c+l)*ld,g=Cr(a+x),v=Cr(o+x),_=Cr(c+x),w=Cr(l+x),C=(g+v+_+w)*Ne,M=g-C,E=v-C,P=_-C,O=w-C,R=a-M,A=o-E,B=c-P,z=l-O;let D=0,F=0,H=0,q=0;R>A?D++:F++,R>B?D++:H++,R>z?D++:q++,A>B?F++:H++,A>z?F++:q++,B>z?H++:q++;const $=D>=3?1:0,J=F>=3?1:0,Se=H>=3?1:0,ce=q>=3?1:0,me=D>=2?1:0,le=F>=2?1:0,xe=H>=2?1:0,Ce=q>=2?1:0,ye=D>=1?1:0,pe=F>=1?1:0,oe=H>=1?1:0,nt=q>=1?1:0,je=R-$+Ne,Ye=A-J+Ne,it=B-Se+Ne,Oe=z-ce+Ne,fe=R-me+2*Ne,ae=A-le+2*Ne,lt=B-xe+2*Ne,Ee=z-Ce+2*Ne,ue=R-ye+3*Ne,Ze=A-pe+3*Ne,St=B-oe+3*Ne,bt=z-nt+3*Ne,Ke=R-1+4*Ne,xt=A-1+4*Ne,ut=B-1+4*Ne,ht=z-1+4*Ne,rt=g&255,Pe=v&255,Je=_&255,st=w&255;let Ge=.6-R*R-A*A-B*B-z*z;if(Ge<0)u=0;else{const re=rt+e[Pe+e[Je+e[st]]];Ge*=Ge,u=Ge*Ge*(t[re]*R+n[re]*A+i[re]*B+s[re]*z)}let ee=.6-je*je-Ye*Ye-it*it-Oe*Oe;if(ee<0)p=0;else{const re=rt+$+e[Pe+J+e[Je+Se+e[st+ce]]];ee*=ee,p=ee*ee*(t[re]*je+n[re]*Ye+i[re]*it+s[re]*Oe)}let wt=.6-fe*fe-ae*ae-lt*lt-Ee*Ee;if(wt<0)f=0;else{const re=rt+me+e[Pe+le+e[Je+xe+e[st+Ce]]];wt*=wt,f=wt*wt*(t[re]*fe+n[re]*ae+i[re]*lt+s[re]*Ee)}let Lt=.6-ue*ue-Ze*Ze-St*St-bt*bt;if(Lt<0)m=0;else{const re=rt+ye+e[Pe+pe+e[Je+oe+e[st+nt]]];Lt*=Lt,m=Lt*Lt*(t[re]*ue+n[re]*Ze+i[re]*St+s[re]*bt)}let _t=.6-Ke*Ke-xt*xt-ut*ut-ht*ht;if(_t<0)b=0;else{const re=rt+1+e[Pe+1+e[Je+1+e[st+1]]];_t*=_t,b=_t*_t*(t[re]*Ke+n[re]*xt+i[re]*ut+s[re]*ht)}return 27*(u+p+f+m+b)}}function hd(r){const e=new Uint8Array(512);for(let t=0;t<512/2;t++)e[t]=t;for(let t=0;t<512/2-1;t++){const n=t+~~(r()*(256-t)),i=e[t];e[t]=e[n],e[n]=i}for(let t=256;t<512;t++)e[t]=e[t-256];return e}var dd=Object.defineProperty,pd=(r,e,t)=>e in r?dd(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Te=(r,e,t)=>(pd(r,typeof e!="symbol"?e+"":e,t),t);(function(){class r{}class e extends r{constructor(d){super(),Te(this,"value"),this.value=d}}class t extends r{constructor(d){super(),Te(this,"value"),this.value=d}}class n extends r{constructor(d){super(),Te(this,"value"),this.value=d}}class i extends r{constructor(d,y="unrestricted"){super(),Te(this,"type"),Te(this,"value"),this.value=d,this.type=y}}class s extends r{constructor(d){super(),Te(this,"value"),this.value=d}}class a extends r{}class o extends r{constructor(d){super(),Te(this,"value"),this.value=d}}class c extends r{}class l extends r{constructor(d){super(),Te(this,"value"),this.value=d}}class u extends r{constructor(d,y="integer"){super(),Te(this,"value"),Te(this,"type"),this.value=d,this.type=y}}class p extends r{constructor(d){super(),Te(this,"value"),this.value=d}}class f extends r{constructor(d,y,S){super(),Te(this,"value"),Te(this,"type"),Te(this,"unit"),this.value=d,this.type=y,this.unit=S}}class m extends r{}class b extends r{}class x extends r{}class g extends r{}class v extends r{}class _ extends r{}class w extends r{}class C extends r{}class M extends r{}class E extends r{}class P extends r{}class O extends r{}class R{constructor(d){Te(this,"input"),Te(this,"index",0),this.input=d}consume(){const d=this.input.codePointAt(this.index);return d!==void 0&&(this.index+=String.fromCodePoint(d).length),d}reconsume(d){d!==void 0&&(this.index-=String.fromCodePoint(d).length)}peek(){const d=[];let y=this.index;for(let S=0;S<3&&y<this.input.length;S++){const T=this.input.codePointAt(y);d.push(T),y+=String.fromCodePoint(T).length}return d}}function A(h){return h===10}function B(h){return A(h)||h===8192||h===32}function z(h){return h>=48&&h<=57}function D(h){return z(h)||h>=65&&h<=70||h>=97&&h<=102}function F(h){return function(d){return function(y){return y>=65&&y<=90}(d)||function(y){return y>=97&&y<=122}(d)}(h)||function(d){return d>=128}(h)||h===95}function H(h){return F(h)||z(h)||h===45}function q(h){return h>=0&&h<=8||h===11||h>=14&&h<=31||h===127}function $(h,d){return h===92&&!A(d)}function J(h,d,y){return h===45?F(d)||d===45||$(d,y):!!F(h)||h===92&&$(h,d)}function Se(h,d,y){return h===43||h===45?z(d)||d===46&&z(y):z(h===46?d:h)}function ce(h){const d=h.consume();if(D(d)){let y=[d];for(;D(...h.peek())&&y.length<5;)y.push(h.consume());B(...h.peek())&&h.consume();const S=parseInt(String.fromCodePoint(...y),16);return S===0||S>1114111?65533:S}return d===void 0?65533:d}function me(h,d){const y=new s("");for(;;){const S=h.consume();if(S===d||S===void 0)return y;if(S===10)return h.reconsume(S),new a;if(S===92){const T=h.peek()[0];T===void 0||(A(T)?h.consume():y.value+=String.fromCodePoint(ce(h)))}else y.value+=String.fromCodePoint(S)}}function le(h){let d="";for(;;){const y=h.consume();if(H(y))d+=String.fromCodePoint(y);else{if(!$(...h.peek()))return h.reconsume(y),d;d+=String.fromCodePoint(ce(h))}}}function xe(h){let d=function(y){let S="integer",T="";for([43,45].includes(y.peek()[0])&&(T+=String.fromCodePoint(y.consume()));z(...y.peek());)T+=String.fromCodePoint(y.consume());if(y.peek()[0]===46&&z(y.peek()[1]))for(T+=String.fromCodePoint(y.consume(),y.consume()),S="number";z(...y.peek());)T+=String.fromCodePoint(y.consume());return[69,101].includes(y.peek()[0])&&([45,43].includes(y.peek()[1])&&z(y.peek()[2])?(T+=String.fromCodePoint(y.consume(),y.consume(),y.consume()),S="number"):z(y.peek()[1])&&(T+=String.fromCodePoint(y.consume(),y.consume()),S="number")),{value:parseFloat(T),type:S}}(h);return J(...h.peek())?new f(d.value,d.type,le(h)):h.peek()[0]===37?(h.consume(),new p(d.value)):new u(d.value,d.type)}function Ce(h){for(;;){const d=h.consume();if(d===41||d===void 0)return;$(...h.peek())&&ce(h)}}function ye(h){const d=le(h);if(d.match(/url/i)&&h.peek()[0]===40){for(h.consume();B(h.peek()[0])&&B(h.peek()[1]);)h.consume();return[34,39].includes(h.peek()[0])||B(h.peek()[0])&&[34,39].includes(h.peek()[1])?new t(d):function(y){const S=new o("");for(;B(...y.peek());)y.consume();for(;;){const T=y.consume();if(T===41||T===void 0)return S;if(B(T)){for(;B(...y.peek());)y.consume();return y.peek()[0]===41||y.peek()[0]===void 0?(y.consume(),S):(Ce(y),new c)}if([34,39,40].includes(T)||q(T))return Ce(y),new c;if(T===92){if(!$(...y.peek()))return Ce(y),new c;S.value+=ce(y)}else S.value+=String.fromCodePoint(T)}}(h)}return h.peek()[0]===40?(h.consume(),new t(d)):new e(d)}function pe(h){const d=h.consume(),y=h.peek();if(B(d)){for(;B(...h.peek());)h.consume();return new m}if(d===34)return me(h,d);if(d===35){if(H(y[0])||$(...y)){const S=new i;return J(...y)&&(S.type="id"),S.value=le(h),S}return new l(String.fromCodePoint(d))}return d===39?me(h,d):d===40?new M:d===41?new E:d===43?Se(...y)?(h.reconsume(d),xe(h)):new l(String.fromCodePoint(d)):d===44?new _:d===45?Se(...h.peek())?(h.reconsume(d),xe(h)):h.peek()[0]===45&&h.peek()[1]===62?(h.consume(),h.consume(),new x):J(...h.peek())?(h.reconsume(d),ye(h)):new l(String.fromCodePoint(d)):d===46?Se(...h.peek())?(h.reconsume(d),xe(h)):new l(String.fromCodePoint(d)):d===58?new g:d===59?new v:d===60?y[0]===33&&y[1]===45&&y[2]===45?(h.consume(),h.consume(),h.consume(),new b):new l(String.fromCodePoint(d)):d===64?J(...y)?new n(le(h)):new l(String.fromCodePoint(d)):d===91?new w:d===92?$(...y)?(h.reconsume(d),ye(h)):new l(String.fromCodePoint(d)):d===93?new C:d===123?new P:d===125?new O:z(d)?(h.reconsume(d),xe(h)):F(d)?(h.reconsume(d),ye(h)):d===void 0?void 0:new l(String.fromCodePoint(d))}const oe=new Set(["px","deg","s","hz","dppx","number","fr"]);function nt(h){return oe.has(h.toLowerCase())}function je(h,d){if(["x","y"].includes(h))return h;if(!d)throw new Error("To determine the normalized axis the computedStyle of the source is required.");const y=d.writingMode=="horizontal-tb";if(h==="block")h=y?"y":"x";else{if(h!=="inline")throw new TypeError(`Invalid axis \u201C${h}\u201D`);h=y?"x":"y"}return h}function Ye(h){const d=[];let y=0;function S(){let k=0;const I=y;for(;y<h.length;){const U=h.slice(y,y+1);if(/\s/.test(U)&&k===0)break;if(U==="(")k+=1;else if(U===")"&&(k-=1,k===0)){y++;break}y++}return h.slice(I,y)}function T(){for(;/\s/.test(h.slice(y,y+1));)y++}for(;y<h.length;){const k=h.slice(y,y+1);/\s/.test(k)?T():d.push(S())}return d}function it(h,d){return h.reduce((y,S)=>(y.has(S[d])?y.get(S[d]).push(S):y.set(S[d],[S]),y),new Map)}function Oe(h,d){const y=[],S=[];for(const T of h)d(T)?y.push(T):S.push(T);return[y,S]}function fe(h,d={}){function y(S){return Array.from(S).map(T=>fe(T,d))}if(h instanceof CSSUnitValue){if(h.unit==="percent"&&d.percentageReference){const T=h.value/100*d.percentageReference.value,k=d.percentageReference.unit;return new CSSUnitValue(T,k)}const S=h.toSum();if(S&&S.values.length===1&&(h=S.values[0]),h instanceof CSSUnitValue&&h.unit==="em"&&d.fontSize&&(h=new CSSUnitValue(h.value*d.fontSize.value,d.fontSize.unit)),h instanceof CSSKeywordValue){if(h.value==="e")return new CSSUnitValue(Math.E,"number");if(h.value==="pi")return new CSSUnitValue(Math.PI,"number")}return h}if(!h.operator)return h;switch(h.operator){case"sum":h=new CSSMathSum(...y(h.values));break;case"product":h=new CSSMathProduct(...y(h.values));break;case"negate":h=new CSSMathNegate(fe(h.value,d));break;case"clamp":h=new CSSMathClamp(fe(h.lower,d),fe(h.value,d),fe(h.upper,d));break;case"invert":h=new CSSMathInvert(fe(h.value,d));break;case"min":h=new CSSMathMin(...y(h.values));break;case"max":h=new CSSMathMax(...y(h.values))}if(h instanceof CSSMathMin||h instanceof CSSMathMax){const S=Array.from(h.values);if(S.every(T=>T instanceof CSSUnitValue&&T.unit!=="percent"&&nt(T.unit)&&T.unit===S[0].unit)){const T=Math[h.operator].apply(Math,S.map(({value:k})=>k));return new CSSUnitValue(T,S[0].unit)}}if(h instanceof CSSMathMin||h instanceof CSSMathMax){const S=Array.from(h.values),[T,k]=Oe(S,U=>U instanceof CSSUnitValue&&U.unit!=="percent"),I=Array.from(it(T,"unit").values());if(I.some(U=>U.length>0)){const U=I.map(N=>{const L=Math[h.operator].apply(Math,N.map(({value:X})=>X));return new CSSUnitValue(L,N[0].unit)});h=h instanceof CSSMathMin?new CSSMathMin(...U,...k):new CSSMathMax(...U,...k)}return S.length===1?S[0]:h}if(h instanceof CSSMathNegate)return h.value instanceof CSSUnitValue?new CSSUnitValue(0-h.value.value,h.value.unit):h.value instanceof CSSMathNegate?h.value.value:h;if(h instanceof CSSMathInvert)return h.value instanceof CSSMathInvert?h.value.value:h;if(h instanceof CSSMathSum){let S=function(k){const I=k.filter(U=>U instanceof CSSUnitValue);return[...k.filter(U=>!(U instanceof CSSUnitValue)),...Array.from(it(I,"unit").entries()).map(([U,N])=>{const L=N.reduce((X,{value:Z})=>X+Z,0);return new CSSUnitValue(L,U)})]},T=[];for(const k of h.values)k instanceof CSSMathSum?T.push(...k.values):T.push(k);return T=S(T),T.length===1?T[0]:new CSSMathSum(...T)}if(h instanceof CSSMathProduct){let S=[];for(const I of h.values)I instanceof CSSMathProduct?S.push(...I.values):S.push(I);const[T,k]=Oe(S,I=>I instanceof CSSUnitValue&&I.unit==="number");if(T.length>1){const I=T.reduce((U,{value:N})=>U*N,1);S=[new CSSUnitValue(I,"number"),...k]}if(S.length===2){let I,U;for(const N of S)N instanceof CSSUnitValue&&N.unit==="number"?I=N:N instanceof CSSMathSum&&[...N.values].every(L=>L instanceof CSSUnitValue)&&(U=N);if(I&&U)return new CSSMathSum(...[...U.values].map(N=>new CSSUnitValue(N.value*I.value,N.unit)))}if(S.every(I=>I instanceof CSSUnitValue&&nt(I.unit)||I instanceof CSSMathInvert&&I.value instanceof CSSUnitValue&&nt(I.value.unit))){const I=new CSSMathProduct(...S).toSum();if(I&&I.values.length===1)return I.values[0]}return new CSSMathProduct(...S)}return h}const ae=null,lt=["percent","length","angle","time","frequency","resolution","flex"],Ee={fontRelativeLengths:{units:new Set(["em","rem","ex","rex","cap","rcap","ch","rch","ic","ric","lh","rlh"])},viewportRelativeLengths:{units:new Set(["vw","lvw","svw","dvw","vh","lvh","svh","dvh","vi","lvi","svi","dvi","vb","lvb","svb","dvb","vmin","lvmin","svmin","dvmin","vmax","lvmax","svmax","dvmax"])},absoluteLengths:{units:new Set(["cm","mm","Q","in","pt","pc","px"]),compatible:!0,canonicalUnit:"px",ratios:{cm:96/2.54,mm:96/2.54/10,Q:96/2.54/40,in:96,pc:16,pt:96/72,px:1}},angle:{units:new Set(["deg","grad","rad","turn"]),compatible:!0,canonicalUnit:"deg",ratios:{deg:1,grad:.9,rad:180/Math.PI,turn:360}},time:{units:new Set(["s","ms"]),compatible:!0,canonicalUnit:"s",ratios:{s:1,ms:.001}},frequency:{units:new Set(["hz","khz"]),compatible:!0,canonicalUnit:"hz",ratios:{hz:1,khz:1e3}},resolution:{units:new Set(["dpi","dpcm","dppx"]),compatible:!0,canonicalUnit:"dppx",ratios:{dpi:1/96,dpcm:2.54/96,dppx:1}}},ue=new Map;for(const h of Object.values(Ee))if(h.compatible)for(const d of h.units)ue.set(d,h);function Ze(h){return ue.get(h)}function St(h,d){const y={...h};for(const S of Object.keys(d))y[S]?y[S]+=d[S]:y[S]=d[S];return y}function bt(h){return h==="number"?{}:h==="percent"?{percent:1}:Ee.absoluteLengths.units.has(h)||Ee.fontRelativeLengths.units.has(h)||Ee.viewportRelativeLengths.units.has(h)?{length:1}:Ee.angle.units.has(h)?{angle:1}:Ee.time.units.has(h)?{time:1}:Ee.frequency.units.has(h)?{frequency:1}:Ee.resolution.units.has(h)?{resolution:1}:h==="fr"?{flex:1}:ae}function Ke(h){if(h instanceof CSSUnitValue){let{unit:d,value:y}=h;const S=Ze(h.unit);return S&&d!==S.canonicalUnit&&(y*=S.ratios[d],d=S.canonicalUnit),d==="number"?[[y,{}]]:[[y,{[d]:1}]]}if(h instanceof CSSMathInvert){if(!(h.value instanceof CSSUnitValue))throw new Error("Not implemented");const d=Ke(h.value);if(d===ae||d.length>1)return ae;const y=d[0],S={};for(const[T,k]of Object.entries(y[1]))S[T]=-1*k;return d[0]=[1/y[0],S],d}if(h instanceof CSSMathProduct){let d=[[1,{}]];for(const y of h.values){const S=Ke(y),T=[];if(S===ae)return ae;for(const k of d)for(const I of S)T.push([k[0]*I[0],St(k[1],I[1])]);d=T}return d}throw new Error("Not implemented")}function xt(h,d){if(bt(d)===ae)throw new SyntaxError("The string did not match the expected pattern.");const y=Ke(h);if(!y)throw new TypeError;if(y.length>1)throw new TypeError("Sum has more than one item");const S=function(T,k){const I=T.unit,U=T.value,N=Ze(I),L=Ze(k);return!L||N!==L?ae:new CSSUnitValue(U*L.ratios[I]/L.ratios[k],k)}(ut(y[0]),d);if(S===ae)throw new TypeError;return S}function ut(h){const[d,y]=h,S=Object.entries(y);if(S.length>1)return ae;if(S.length===0)return new CSSUnitValue(d,"number");const T=S[0];return T[1]!==1?ae:new CSSUnitValue(d,T[0])}function ht(h,...d){if(d&&d.length)throw new Error("Not implemented");const y=Ke(h).map(S=>ut(S));if(y.some(S=>S===ae))throw new TypeError("Type error");return new CSSMathSum(...y)}function rt(h,d){if(h.percentHint&&d.percentHint&&h.percentHint!==d.percentHint)return ae;const y={...h,percentHint:h.percentHint??d.percentHint};for(const S of lt)d[S]&&(y[S]??(y[S]=0),y[S]+=d[S]);return y}class Pe{constructor(d,y){Te(this,"name"),Te(this,"values"),this.name=d,this.values=y}}class Je{constructor(d,y){Te(this,"value"),Te(this,"associatedToken"),this.value=d,this.associatedToken=y}}function st(h){if(Array.isArray(h))return h;if(typeof h=="string")return function(d){const y=new R(d),S=[];for(;;){const T=pe(y);if(T===void 0)return S;S.push(T)}}(h);throw new TypeError("Invalid input type "+typeof h)}function Ge(h){const d=h.shift();return d instanceof P||d instanceof w||d instanceof M?function(y,S){let T;if(S instanceof P)T=O;else if(S instanceof M)T=E;else{if(!(S instanceof w))return;T=C}const k=new Je([],S);for(;;){const I=y.shift();if(I instanceof T||I===void 0)return k;y.unshift(I),k.value.push(Ge(y))}}(h,d):d instanceof t?function(y,S){const T=new Pe(y.value,[]);for(;;){const k=S.shift();if(k instanceof E||k===void 0)return T;S.unshift(k),T.values.push(Ge(S))}}(d,h):d}function ee(h){if(h instanceof M||h instanceof E)return 6;if(h instanceof l)switch(h.value){case"*":case"/":return 4;case"+":case"-":return 2}}function wt(h){return h[h.length-1]}function Lt(h,d,y){const S=["+","-"].includes(h.value)?"ADDITION":"MULTIPLICATION",T=d.type===S?d.values:[d],k=y.type===S?y.values:[y];return h.value==="-"?k[0]={type:"NEGATE",value:k[0]}:h.value==="/"&&(k[0]={type:"INVERT",value:k[0]}),{type:S,values:[...T,...k]}}function _t(h){if(h.type==="ADDITION")return new CSSMathSum(...h.values.map(d=>_t(d)));if(h.type==="MULTIPLICATION")return new CSSMathProduct(...h.values.map(d=>_t(d)));if(h.type==="NEGATE")return new CSSMathNegate(_t(h.value));if(h.type==="INVERT")return new CSSMathInvert(_t(h.value));if(h instanceof Je)return re(new Pe("calc",h.value));if(h instanceof e){if(h.value==="e")return new CSSUnitValue(Math.E,"number");if(h.value==="pi")return new CSSUnitValue(Math.PI,"number");throw new SyntaxError("Invalid math expression")}return Mo(h)}function re(h){if(h.name==="min"||h.name==="max"){const S=h.values.filter(T=>!(T instanceof m||T instanceof _)).map(T=>fe(re(new Pe("calc",T))));return h.name==="min"?new CSSMathMin(...S):new CSSMathMax(...S)}if(h.name!=="calc")return null;const d=_t(function(S){const T=[],k=[];for(;S.length;){const I=S.shift();if(I instanceof u||I instanceof f||I instanceof p||I instanceof Pe||I instanceof Je||I instanceof e)k.push(I);else if(I instanceof l&&["*","/","+","-"].includes(I.value)){for(;T.length&&!(wt(T)instanceof M)&&ee(wt(T))>ee(I);){const U=T.pop(),N=k.pop(),L=k.pop();k.push(Lt(U,L,N))}T.push(I)}else if(I instanceof M)T.push(I);else if(I instanceof E){if(!T.length)return null;for(;!(wt(T)instanceof M);){const U=T.pop(),N=k.pop(),L=k.pop();k.push(Lt(U,L,N))}if(!(wt(T)instanceof M))return null;T.pop()}else if(!(I instanceof m))return null}for(;T.length;){if(wt(T)instanceof M)return null;const I=T.pop(),U=k.pop(),N=k.pop();k.push(Lt(I,N,U))}return k[0]}([...h.values]));let y;try{y=fe(d)}catch{new CSSStyleSheet().insertRule("error",0)}return y instanceof CSSUnitValue?new CSSMathSum(y):y}function Mo(h){return h instanceof Pe&&["calc","min","max","clamp"].includes(h.name)?re(h):h instanceof u&&h.value===0&&!h.unit?new CSSUnitValue(0,"px"):h instanceof u?new CSSUnitValue(h.value,"number"):h instanceof p?new CSSUnitValue(h.value,"percent"):h instanceof f?new CSSUnitValue(h.value,h.unit):void 0}function vl(h){const d=function(y){const S=st(y);for(;S[0]instanceof m;)S.shift();if(S[0]===void 0)return null;const T=Ge(S);for(;S[0]instanceof m;)S.shift();return S[0]===void 0?T:null}(h);return d===null&&new CSSStyleSheet().insertRule("error",0),d instanceof u||d instanceof p||d instanceof f||d instanceof Pe||new CSSStyleSheet().insertRule("error",0),d instanceof f&&bt(d.unit)===null&&new CSSStyleSheet().insertRule("error",0),Mo(d)}(function(){let h=new WeakMap;function d(k){const I=[];for(let N=0;N<k.length;N++)I[N]=typeof(U=k[N])=="number"?new CSSUnitValue(U,"number"):U;var U;return I}class y{static parse(I){return I instanceof y?I:fe(vl(I),{})}}class S extends y{constructor(I,U,N,L){super(),h.set(this,{values:d(I),operator:U,name:N||U,delimiter:L||", "})}get operator(){return h.get(this).operator}get values(){return h.get(this).values}toString(){const I=h.get(this);return`${I.name}(${I.values.join(I.delimiter)})`}}const T={CSSNumericValue:y,CSSMathValue:S,CSSUnitValue:class extends y{constructor(k,I){super(),h.set(this,{value:k,unit:I})}get value(){return h.get(this).value}set value(k){h.get(this).value=k}get unit(){return h.get(this).unit}to(k){return xt(this,k)}toSum(...k){return ht(this,...k)}type(){return bt(h.get(this).unit)}toString(){const k=h.get(this);return`${k.value}${function(I){switch(I){case"percent":return"%";case"number":return"";default:return I.toLowerCase()}}(k.unit)}`}},CSSKeywordValue:class{constructor(k){this.value=k}toString(){return this.value.toString()}},CSSMathSum:class extends S{constructor(k){super(arguments,"sum","calc"," + ")}},CSSMathProduct:class extends S{constructor(k){super(arguments,"product","calc"," * ")}toSum(...k){return ht(this,...k)}type(){return h.get(this).values.map(k=>k.type()).reduce(rt)}},CSSMathNegate:class extends S{constructor(k){super([arguments[0]],"negate","-")}get value(){return h.get(this).values[0]}type(){return this.value.type()}},CSSMathInvert:class extends S{constructor(k){super([1,arguments[0]],"invert","calc"," / ")}get value(){return h.get(this).values[1]}type(){return function(k){const I={};for(const U of lt)I[U]=-1*k[U];return I}(h.get(this).values[1].type())}},CSSMathMax:class extends S{constructor(){super(arguments,"max")}},CSSMathMin:class extends S{constructor(){super(arguments,"min")}}};if(!window.CSS&&!Reflect.defineProperty(window,"CSS",{value:{}}))throw Error("Error installing CSSOM support");window.CSSUnitValue||["number","percent","em","ex","px","cm","mm","in","pt","pc","Q","vw","vh","vmin","vmax","rems","ch","deg","rad","grad","turn","ms","s","Hz","kHz","dppx","dpi","dpcm","fr"].forEach(k=>{if(!Reflect.defineProperty(CSS,k,{value:I=>new CSSUnitValue(I,k)}))throw Error(`Error installing CSS.${k}`)});for(let[k,I]of Object.entries(T))if(!(k in window)&&!Reflect.defineProperty(window,k,{value:I}))throw Error(`Error installing CSSOM support for ${k}`)})();const Co="block";let De=new WeakMap,Ft=new WeakMap;const Qi=["entry","exit","cover","contain","entry-crossing","exit-crossing"];function Eo(h){return h===document.scrollingElement?document:h}function an(h){es(h);let d=De.get(h).animations;if(d.length===0)return;let y=h.currentTime;for(let S=0;S<d.length;S++)d[S].tickAnimation(y)}function Po(h,d){if(!h)return null;const y=Ft.get(h).sourceMeasurements,S=getComputedStyle(h);let T=y.scrollTop;return je(d,S)==="x"&&(T=Math.abs(y.scrollLeft)),T}function $r(h,d){const y=fe(h,d);if(y instanceof CSSUnitValue){if(y.unit==="px")return y.value;throw TypeError("Unhandled unit type "+y.unit)}throw TypeError("Unsupported value type: "+typeof h)}function es(h){if(!(h instanceof Mn))return void function(y){const S=De.get(y);if(!S.anonymousSource)return;const T=Ro(S.anonymousSource,S.anonymousTarget);Hn(y,T)}(h);const d=h.subject;if(!d||getComputedStyle(d).display=="none")return void Hn(h,null);Hn(h,os(d))}function ko(h){return["block","inline","x","y"].includes(h)}function ts(h){const d=getComputedStyle(h);return{scrollLeft:h.scrollLeft,scrollTop:h.scrollTop,scrollWidth:h.scrollWidth,scrollHeight:h.scrollHeight,clientWidth:h.clientWidth,clientHeight:h.clientHeight,writingMode:d.writingMode,direction:d.direction,scrollPaddingTop:d.scrollPaddingTop,scrollPaddingBottom:d.scrollPaddingBottom,scrollPaddingLeft:d.scrollPaddingLeft,scrollPaddingRight:d.scrollPaddingRight}}function ns(h,d){if(!h||!d)return;let y=0,S=0,T=d;const k=h.offsetParent;for(;T&&T!=k;)S+=T.offsetLeft,y+=T.offsetTop,T=T.offsetParent;S-=h.offsetLeft+h.clientLeft,y-=h.offsetTop+h.clientTop;const I=getComputedStyle(d);return{top:y,left:S,offsetWidth:d.offsetWidth,offsetHeight:d.offsetHeight,fontSize:I.fontSize}}function $i(h){let d=Ft.get(h);d.sourceMeasurements=ts(h);for(const y of d.timelineRefs){const S=y.deref();S instanceof Mn&&(De.get(S).subjectMeasurements=ns(h,S.subject))}d.updateScheduled||(setTimeout(()=>{for(const y of d.timelineRefs){const S=y.deref();S&&an(S)}d.updateScheduled=!1}),d.updateScheduled=!0)}function Hn(h,d){const y=De.get(h),S=y.source;if(S!=d){if(S){const T=Ft.get(S);if(T){T.timelineRefs.delete(h);const k=Array.from(T.timelineRefs).filter(I=>I.deref()===void 0);for(const I of k)T.timelineRefs.delete(I);T.timelineRefs.size===0&&(T.disconnect(),Ft.delete(S))}}if(y.source=d,d){let T=Ft.get(d);if(!T){T={timelineRefs:new Set,sourceMeasurements:ts(d)},Ft.set(d,T);const k=new ResizeObserver(N=>{for(const L of N)$i(y.source)});k.observe(d);for(const N of d.children)k.observe(N);const I=new MutationObserver(N=>{for(const L of N)$i(L.target)});I.observe(d,{attributes:!0,attributeFilter:["style","class"]});const U=()=>{T.sourceMeasurements.scrollLeft=d.scrollLeft,T.sourceMeasurements.scrollTop=d.scrollTop;for(const N of T.timelineRefs){const L=N.deref();L&&an(L)}};Eo(d).addEventListener("scroll",U),T.disconnect=()=>{k.disconnect(),I.disconnect(),Eo(d).removeEventListener("scroll",U)}}T.timelineRefs.add(new WeakRef(h))}}}function is(h,d){let y=De.get(h).animations;for(let S=0;S<y.length;S++)y[S].animation==d&&y.splice(S,1)}function rs(h,d,y){let S=De.get(h).animations;for(let T=0;T<S.length;T++)if(S[T].animation==d)return;S.push({animation:d,tickAnimation:y}),queueMicrotask(()=>{an(h)})}class We{constructor(d){if(De.set(this,{source:null,axis:Co,anonymousSource:d?d.anonymousSource:null,anonymousTarget:d?d.anonymousTarget:null,subject:null,inset:null,animations:[],subjectMeasurements:null}),Hn(this,d&&d.source!==void 0?d.source:document.scrollingElement),d&&d.axis!==void 0&&d.axis!=Co){if(!ko(d.axis))throw TypeError("Invalid axis");De.get(this).axis=d.axis}an(this)}set source(d){Hn(this,d),an(this)}get source(){return De.get(this).source}set axis(d){if(!ko(d))throw TypeError("Invalid axis");De.get(this).axis=d,an(this)}get axis(){return De.get(this).axis}get duration(){return CSS.percent(100)}get phase(){const d=this.source;if(!d)return"inactive";let y=getComputedStyle(d);return y.display=="none"?"inactive":d==document.scrollingElement||y.overflow!="visible"&&y.overflow!="clip"?"active":"inactive"}get currentTime(){const d=this.source;if(!d||!d.isConnected||this.phase=="inactive")return null;const y=getComputedStyle(d);if(y.display==="inline"||y.display==="none")return null;const S=this.axis,T=Po(d,S),k=function(I,U){const N=Ft.get(I).sourceMeasurements,L=getComputedStyle(I).writingMode=="horizontal-tb";return U==="block"?U=L?"y":"x":U==="inline"&&(U=L?"x":"y"),U==="y"?N.scrollHeight-N.clientHeight:U==="x"?N.scrollWidth-N.clientWidth:void 0}(d,S);return k>0?CSS.percent(100*T/k):CSS.percent(100)}get __polyfill(){return!0}}function ss(h,d){let y=h.parentElement;for(;y!=null;){if(d(y))return y;y=y.parentElement}}function Ro(h,d){switch(h){case"root":return document.scrollingElement;case"nearest":return os(d);case"self":return d;default:throw new TypeError("Invalid ScrollTimeline Source Type.")}}function Sl(h){switch(getComputedStyle(h).display){case"block":case"inline-block":case"list-item":case"table":case"table-caption":case"flow-root":case"flex":case"grid":return!0}return!1}function Ao(h){const d=getComputedStyle(h);return d.transform!="none"||d.perspective!="none"||d.willChange=="transform"||d.willChange=="perspective"||d.filter!="none"||d.willChange=="filter"||d.backdropFilter!="none"}function bl(h){return getComputedStyle(h).position!="static"||Ao(h)}function xl(h){switch(getComputedStyle(h).position){case"static":case"relative":case"sticky":return ss(h,Sl);case"absolute":return ss(h,bl);case"fixed":return ss(h,Ao)}}function os(h){if(h&&h.isConnected){for(;h=xl(h);)switch(getComputedStyle(h)["overflow-x"]){case"auto":case"scroll":case"hidden":return h==document.body&&getComputedStyle(document.scrollingElement).overflow=="visible"?document.scrollingElement:h}return document.scrollingElement}}function qn(h,d){const y=De.get(h),S=y.subjectMeasurements,T=Ft.get(y.source).sourceMeasurements;return h.phase==="inactive"?null:h instanceof Mn?as(d,T,S,y.axis,y.inset):null}function as(h,d,y,S,T){const k=d.direction=="rtl"||d.writingMode=="vertical-rl";let I,U,N={fontSize:y.fontSize};je(S,d)==="x"?(I=y.offsetWidth,U=y.left,N.scrollPadding=[d.scrollPaddingLeft,d.scrollPaddingRight],k&&(U+=d.scrollWidth-d.clientWidth,N.scrollPadding=[d.scrollPaddingRight,d.scrollPaddingLeft]),N.containerSize=d.clientWidth):(I=y.offsetHeight,U=y.top,N.scrollPadding=[d.scrollPaddingTop,d.scrollPaddingBottom],N.containerSize=d.clientHeight);const L=function(hs,rr){const Il={start:0,end:0};if(!hs)return Il;const[zl,Bl]=[hs.start,hs.end].map((Ho,qo)=>Ho==="auto"?rr.scrollPadding[qo]==="auto"?0:parseFloat(rr.scrollPadding[qo]):$r(Ho,{percentageReference:CSS.px(rr.containerSize),fontSize:CSS.px(parseFloat(rr.fontSize))}));return{start:zl,end:Bl}}(T,N),X=U-N.containerSize+L.end,Z=U+I-L.start,K=X+I,he=Z-I,we=Math.min(K,he),Qe=Math.max(K,he);let Tt,dt;const Wo=I>N.containerSize-L.start-L.end;switch(h){case"cover":Tt=X,dt=Z;break;case"contain":Tt=we,dt=Qe;break;case"entry":Tt=X,dt=we;break;case"exit":Tt=Qe,dt=Z;break;case"entry-crossing":Tt=X,dt=Wo?Qe:we;break;case"exit-crossing":Tt=Wo?we:Qe,dt=Z}return{start:Tt,end:dt}}function Oo(h,d){if(h instanceof Mn){const{rangeName:y,offset:S}=d;return Io(qn(h,y),S,qn(h,"cover"),h.subject)}if(h instanceof We){const{axis:y,source:S}=h,{sourceMeasurements:T}=Ft.get(S);let k;return k=je(y,T)==="x"?T.scrollWidth-T.clientWidth:T.scrollHeight-T.clientHeight,$r(d,{percentageReference:CSS.px(k)})/k}unsupportedTimeline(h)}function Io(h,d,y,S){if(!h||!y)return 0;let T=getComputedStyle(S);return($r(d,{percentageReference:CSS.px(h.end-h.start),fontSize:CSS.px(parseFloat(T.fontSize))})+h.start-y.start)/(y.end-y.start)}let Mn=class extends We{constructor(h){super(h);const d=De.get(this);d.subject=h&&h.subject?h.subject:void 0,h&&h.inset&&(d.inset=function(y){if(!y)return{start:0,end:0};let S;if(S=typeof y=="string"?Ye(y).map(T=>{if(T==="auto")return"auto";try{return CSSNumericValue.parse(T)}catch{throw TypeError(`Could not parse inset "${y}"`)}}):Array.isArray(y)?y:[y],S.length===0||S.length>2)throw TypeError("Invalid inset");for(const T of S){if(T==="auto")continue;const k=T.type();if(k.length!==1&&k.percent!==1)throw TypeError("Invalid inset")}return{start:S[0],end:S[1]??S[0]}}(h.inset)),d.subject&&(new ResizeObserver(()=>{$i(d.source)}).observe(d.subject),new MutationObserver(()=>{$i(d.source)}).observe(d.subject,{attributes:!0,attributeFilter:["class","style"]})),es(this),d.subjectMeasurements=ns(d.source,d.subject),an(this)}get source(){return es(this),De.get(this).source}set source(h){throw new Error("Cannot set the source of a view timeline")}get subject(){return De.get(this).subject}get axis(){return De.get(this).axis}get currentTime(){const h=Po(this.source,this.axis);if(h==null)return null;const d=qn(this,"cover");if(!d)return null;const y=(h-d.start)/(d.end-d.start);return CSS.percent(100*y)}get startOffset(){return CSS.px(qn(this,"cover").start)}get endOffset(){return CSS.px(qn(this,"cover").end)}};const wl=document.getAnimations,_l=window.Element.prototype.getAnimations,Tl=window.Element.prototype.animate,zo=window.Animation;class Cn{constructor(){this.state="pending",this.nativeResolve=this.nativeReject=null,this.promise=new Promise((d,y)=>{this.nativeResolve=d,this.nativeReject=y})}resolve(d){this.state="resolved",this.nativeResolve(d)}reject(d){this.state="rejected",this.promise.catch(()=>{}),this.nativeReject(d)}}function Xn(h){h.readyPromise=new Cn,requestAnimationFrame(()=>{var d;(((d=h.timeline)==null?void 0:d.currentTime)??null)!==null&&(er(h),h.pendingTask!=="play"||h.startTime===null&&h.holdTime===null?h.pendingTask==="pause"&&Uo(h):No(h))})}function Bo(){return new DOMException("The user aborted a request","AbortError")}function cn(h,d){if(d===null)return d;if(typeof d!="number")throw new DOMException(`Unexpected value: ${d}. Cannot convert to CssNumberish`,"InvalidStateError");const y=h.rangeDuration??100,S=jt(h),T=S?y*d/S:0;return CSS.percent(T)}function ge(h,d){if(h.timeline){if(d===null)return d;if(d.unit==="percent"){const y=h.rangeDuration??100,S=jt(h);return d.value*S/y}throw new DOMException("CSSNumericValue must be a percentage for progress based animations.","NotSupportedError")}{if(d==null||typeof d=="number")return d;const y=d.to("ms");if(y)return y.value;throw new DOMException("CSSNumericValue must be either a number or a time value for time based animations.","InvalidStateError")}}function No(h){const d=ge(h,h.timeline.currentTime);if(h.holdTime!=null)At(h),h.animation.playbackRate==0?h.startTime=d:(h.startTime=d-h.holdTime/h.animation.playbackRate,h.holdTime=null);else if(h.startTime!==null&&h.pendingPlaybackRate!==null){const y=(d-h.startTime)*h.animation.playbackRate;At(h);const S=h.animation.playbackRate;S==0?(h.holdTime=null,h.startTime=d):h.startTime=d-y/S}h.readyPromise&&h.readyPromise.state=="pending"&&h.readyPromise.resolve(h.proxy),Vt(h,!1,!1),Jt(h),h.pendingTask=null}function Uo(h){const d=ge(h,h.timeline.currentTime);h.startTime!=null&&h.holdTime==null&&(h.holdTime=(d-h.startTime)*h.animation.playbackRate),At(h),h.startTime=null,h.readyPromise.resolve(h.proxy),Vt(h,!1,!1),Jt(h),h.pendingTask=null}function Do(h){if(!h.finishedPromise||h.finishedPromise.state!="pending"||h.proxy.playState!="finished")return;h.finishedPromise.resolve(h.proxy),h.animation.pause();const d=new CustomEvent("finish",{detail:{currentTime:h.proxy.currentTime,timelineTime:h.proxy.timeline.currentTime}});Object.defineProperty(d,"currentTime",{get:function(){return this.detail.currentTime}}),Object.defineProperty(d,"timelineTime",{get:function(){return this.detail.timelineTime}}),requestAnimationFrame(()=>{queueMicrotask(()=>{h.animation.dispatchEvent(d)})})}function En(h){return h.pendingPlaybackRate!==null?h.pendingPlaybackRate:h.animation.playbackRate}function At(h){h.pendingPlaybackRate!==null&&(h.animation.playbackRate=h.pendingPlaybackRate,h.pendingPlaybackRate=null)}function Lo(h){if(!h.timeline)return null;const d=ge(h,h.timeline.currentTime);if(d===null||h.startTime===null)return null;let y=(d-h.startTime)*h.animation.playbackRate;return y==-0&&(y=0),y}function Vt(h,d,y){if(!h.timeline)return;let S=d?ge(h,h.proxy.currentTime):Lo(h);if(S&&h.startTime!=null&&!h.proxy.pending){const T=En(h),k=jt(h);let I=h.previousCurrentTime;T>0&&S>=k&&h.previousCurrentTime!=null?((I===null||I<k)&&(I=k),h.holdTime=d?S:I):T<0&&S<=0?((I==null||I>0)&&(I=0),h.holdTime=d?S:I):T!=0&&(d&&h.holdTime!==null&&(h.startTime=function(U,N){if(!U.timeline)return null;const L=ge(U,U.timeline.currentTime);return L==null?null:L-N/U.animation.playbackRate}(h,h.holdTime)),h.holdTime=null)}Jt(h),h.previousCurrentTime=ge(h,h.proxy.currentTime),h.proxy.playState=="finished"?(h.finishedPromise||(h.finishedPromise=new Cn),h.finishedPromise.state=="pending"&&(y?Do(h):Promise.resolve().then(()=>{Do(h)}))):(h.finishedPromise&&h.finishedPromise.state=="resolved"&&(h.finishedPromise=new Cn),h.animation.playState!="paused"&&h.animation.pause())}function jt(h){const d=function(S){const T=S.proxy.effect.getTiming();return S.normalizedTiming||T}(h),y=d.delay+d.endDelay+d.iterations*d.duration;return Math.max(0,y)}function Jt(h){if(h.timeline)if(h.startTime!==null){const d=h.timeline.currentTime;if(d==null)return;cs(h,(ge(h,d)-h.startTime)*h.animation.playbackRate)}else h.holdTime!==null&&cs(h,h.holdTime)}function cs(h,d){const y=h.timeline,S=h.animation.playbackRate,T=y.currentTime&&y.currentTime.value==(S<0?0:100)?S<0?.001:-.001:0;h.animation.currentTime=d+T}function ls(h,d){if(!h.timeline)return;const y=h.proxy.playState=="paused"&&h.proxy.pending;let S=!1,T=ge(h,h.proxy.currentTime);En(h)==0&&T==null&&(h.holdTime=0),T==null&&(h.autoAlignStartTime=!0),(h.proxy.playState==="finished"||y)&&(h.holdTime=null,h.startTime=null,h.autoAlignStartTime=!0),h.holdTime&&(h.startTime=null),h.pendingTask&&(h.pendingTask=null,S=!0),(h.holdTime!==null||h.autoAlignStartTime||y||h.pendingPlaybackRate!==null)&&(h.readyPromise&&!S&&(h.readyPromise=null),Jt(h),h.readyPromise||Xn(h),h.pendingTask="play",rs(h.timeline,h.animation,us.bind(h.proxy)),Vt(h,!1,!1))}function us(h){const d=Y.get(this);if(!d)return;if(h==null)return void(d.proxy.playState!=="paused"&&d.animation.playState!="idle"&&d.animation.cancel());er(d),d.pendingTask&&requestAnimationFrame(()=>{d.pendingTask!=="play"||d.startTime===null&&d.holdTime===null?d.pendingTask==="pause"&&Uo(d):No(d)});const y=this.playState;if(y=="running"||y=="finished"){const S=ge(d,h);cs(d,(S-ge(d,this.startTime))*this.playbackRate),Vt(d,!1,!1)}}function Fo(h){h.specifiedTiming=null}let Y=new WeakMap;window.addEventListener("pagehide",h=>{Y=new WeakMap},!1);let Vo=new WeakMap;function er(h){if(!h.autoAlignStartTime||!h.timeline||!h.timeline.currentTime||h.proxy.playState==="idle"||h.proxy.playState==="paused"&&h.holdTime!==null)return;const d=h.rangeDuration;let y,S;try{y=CSS.percent(100*function(k){if(!k.animationRange)return 0;const I=k.animationRange.start==="normal"?jo(k.timeline):k.animationRange.start;return Oo(k.timeline,I)}(h))}catch(k){y=CSS.percent(0),h.animationRange.start="normal",console.warn("Exception when calculating start offset",k)}try{S=CSS.percent(100*(1-function(k){if(!k.animationRange)return 0;const I=k.animationRange.end==="normal"?Jo(k.timeline):k.animationRange.end;return 1-Oo(k.timeline,I)}(h)))}catch(k){S=CSS.percent(100),h.animationRange.end="normal",console.warn("Exception when calculating end offset",k)}h.rangeDuration=S.value-y.value;const T=En(h);h.startTime=ge(h,T>=0?y:S),h.holdTime=null,h.rangeDuration!==d&&Fo(h)}function tr(h){throw new Error("Unsupported timeline class")}function jo(h){return h instanceof ViewTimeline?{rangeName:"cover",offset:CSS.percent(0)}:h instanceof We?CSS.percent(0):void tr()}function Jo(h){return h instanceof ViewTimeline?{rangeName:"cover",offset:CSS.percent(100)}:h instanceof We?CSS.percent(100):void tr()}function Ml(h,d){if(!d)return{start:"normal",end:"normal"};const y={start:jo(h),end:Jo(h)};if(h instanceof ViewTimeline){const S=Ye(d),T=[],k=[];if(S.forEach(I=>{if(Qi.includes(I))T.push(I);else try{k.push(CSSNumericValue.parse(I))}catch{throw TypeError(`Could not parse range "${d}"`)}}),T.length>2||k.length>2||k.length==1)throw TypeError("Invalid time range or unsupported time range format.");return T.length&&(y.start.rangeName=T[0],y.end.rangeName=T.length>1?T[1]:T[0]),k.length>1&&(y.start.offset=k[0],y.end.offset=k[1]),y}if(h instanceof We){const S=d.split(" ");if(S.length!=2)throw TypeError("Invalid time range or unsupported time range format.");return y.start=CSSNumericValue.parse(S[0]),y.end=CSSNumericValue.parse(S[1]),y}tr()}function nr(h,d,y){if(!d||d==="normal")return"normal";if(h instanceof ViewTimeline){let S="cover",T=y==="start"?CSS.percent(0):CSS.percent(100);if(d instanceof Object)d.rangeName!==void 0&&(S=d.rangeName),d.offset!==void 0&&(T=d.offset);else{const k=Ye(d);k.length===1?Qi.includes(k[0])?S=k[0]:T=fe(CSSNumericValue.parse(k[0]),{}):k.length===2&&(S=k[0],T=fe(CSSNumericValue.parse(k[1]),{}))}if(!Qi.includes(S))throw TypeError("Invalid range name");return{rangeName:S,offset:T}}if(h instanceof We)return CSSNumericValue.parse(d);tr()}class ir{constructor(d,y,S={}){const T=y instanceof We,k=d instanceof zo?d:new zo(d,T?void 0:y);Vo.set(k,this),Y.set(this,{animation:k,timeline:T?y:void 0,playState:T?"idle":null,readyPromise:null,finishedPromise:null,startTime:null,holdTime:null,rangeDuration:null,previousCurrentTime:null,autoAlignStartTime:!1,pendingPlaybackRate:null,pendingTask:null,specifiedTiming:null,normalizedTiming:null,effect:null,animationRange:T?Ml(y,S["animation-range"]):null,proxy:this})}get effect(){const d=Y.get(this);return d.timeline?(d.effect||(d.effect=function(y){const S=y.animation.effect,T=S.updateTiming,k={apply:function(L){S.getTiming();const X=L.apply(S);if(y.timeline){const Z=y.duration??100;X.localTime=cn(y,X.localTime),X.endTime=cn(y,X.endTime),X.activeDuration=cn(y,X.activeDuration);const K=jt(y),he=X.iterations?(K-X.delay-X.endDelay)/X.iterations:0;X.duration=K?CSS.percent(Z*he/K):CSS.percent(0),y.timeline.currentTime===void 0&&(X.localTime=null)}return X}},I={apply:function(L,X){if(y.specifiedTiming)return y.specifiedTiming;y.specifiedTiming=L.apply(S);let Z,K=Object.assign({},y.specifiedTiming);if(K.duration===1/0)throw TypeError("Effect duration cannot be Infinity when used with Scroll Timelines");return(K.duration===null||K.duration==="auto"||y.autoDurationEffect)&&y.timeline&&(y.autoDurationEffect=!0,K.delay=0,K.endDelay=0,Z=K.iterations?1e5:0,K.duration=K.iterations?(Z-K.delay-K.endDelay)/K.iterations:0,K.duration<0&&(K.duration=0,K.endDelay=Z-K.delay),T.apply(S,[K])),y.normalizedTiming=K,y.specifiedTiming}},U={apply:function(L,X,Z){if(Z&&Z.length){if(y.timeline&&Z[0]){const K=Z[0],he=K.duration;if(he===1/0)throw TypeError("Effect duration cannot be Infinity when used with Scroll Timelines");if(K.iterations===1/0)throw TypeError("Effect iterations cannot be Infinity when used with Scroll Timelines");he!==void 0&&he!=="auto"&&(y.autoDurationEffect=null)}y.specifiedTiming&&L.apply(S,[y.specifiedTiming]),L.apply(S,Z),Fo(y)}}},N=new Proxy(S,{get:function(L,X){const Z=L[X];return typeof Z=="function"?Z.bind(S):Z},set:function(L,X,Z){return L[X]=Z,!0}});return N.getComputedTiming=new Proxy(S.getComputedTiming,k),N.getTiming=new Proxy(S.getTiming,I),N.updateTiming=new Proxy(S.updateTiming,U),N}(d)),d.effect):d.animation.effect}set effect(d){const y=Y.get(this);y.animation.effect=d,y.effect=null,y.autoDurationEffect=null}get timeline(){const d=Y.get(this);return d.timeline||d.animation.timeline}set timeline(d){const y=Y.get(this),S=this.timeline;if(S==d)return;const T=this.playState,k=this.currentTime;let I,U=jt(y);I=k===null?null:U===0?0:ge(y,k)/U;const N=S instanceof We,L=d instanceof We,X=this.pending;if(N&&is(y.timeline,y.animation),L)return y.timeline=d,At(y),y.autoAlignStartTime=!0,y.startTime=null,y.holdTime=null,T!=="running"&&T!=="finished"||(y.readyPromise&&y.readyPromise.state!=="resolved"||Xn(y),y.pendingTask="play",rs(y.timeline,y.animation,us.bind(this))),T==="paused"&&I!==null&&(y.holdTime=I*U),X&&(y.readyPromise&&y.readyPromise.state!="resolved"||Xn(y),y.pendingTask=T=="paused"?"pause":"play"),y.startTime!==null&&(y.holdTime=null),void Vt(y,!1,!1);if(y.animation.timeline!=d)throw TypeError("Unsupported timeline: "+d);if(is(y.timeline,y.animation),y.timeline=null,N)switch(k!==null&&(y.animation.currentTime=I*jt(y)),T){case"paused":y.animation.pause();break;case"running":case"finished":y.animation.play()}}get startTime(){const d=Y.get(this);return d.timeline?cn(d,d.startTime):d.animation.startTime}set startTime(d){const y=Y.get(this);if(d=ge(y,d),!y.timeline)return void(y.animation.startTime=d);y.autoAlignStartTime=!1,ge(y,y.timeline.currentTime)==null&&y.startTime!=null&&(y.holdTime=null,Jt(y));const S=ge(y,this.currentTime);At(y),y.startTime=d,y.startTime!==null&&y.animation.playbackRate!=0?y.holdTime=null:y.holdTime=S,y.pendingTask&&(y.pendingTask=null,y.readyPromise.resolve(this)),Vt(y,!0,!1),Jt(y)}get currentTime(){const d=Y.get(this);return d.timeline?d.holdTime!=null?cn(d,d.holdTime):cn(d,Lo(d)):d.animation.currentTime}set currentTime(d){const y=Y.get(this);y.timeline?(function(S,T){if(T==null&&S.currentTime!==null)throw new TypeError;T=ge(S,T),S.autoAlignStartTime=!1,S.holdTime!==null||S.startTime===null||S.timeline.phase==="inactive"||S.animation.playbackRate===0?S.holdTime=T:S.startTime=ge(S,S.timeline.currentTime)-T/S.animation.playbackRate,S.timeline.phase==="inactive"&&(S.startTime=null),S.previousCurrentTime=null}(y,d),y.pendingTask=="pause"&&(y.holdTime=ge(y,d),At(y),y.startTime=null,y.pendingTask=null,y.readyPromise.resolve(this)),Vt(y,!0,!1)):y.animation.currentTime=d}get playbackRate(){return Y.get(this).animation.playbackRate}set playbackRate(d){const y=Y.get(this);if(!y.timeline)return void(y.animation.playbackRate=d);y.pendingPlaybackRate=null;const S=this.currentTime;y.animation.playbackRate=d,S!==null&&(this.currentTime=S)}get playState(){const d=Y.get(this);if(!d.timeline)return d.animation.playState;const y=ge(d,this.currentTime);return y===null&&d.startTime===null&&d.pendingTask==null?"idle":d.pendingTask=="pause"||d.startTime===null&&d.pendingTask!="play"?"paused":y!=null&&(d.animation.playbackRate>0&&y>=jt(d)||d.animation.playbackRate<0&&y<=0)?"finished":"running"}get rangeStart(){var d;return((d=Y.get(this).animationRange)==null?void 0:d.start)??"normal"}set rangeStart(d){const y=Y.get(this);if(!y.timeline)return y.animation.rangeStart=d;y.timeline instanceof We&&(y.animationRange.start=nr(y.timeline,d,"start"),er(y),Jt(y))}get rangeEnd(){var d;return((d=Y.get(this).animationRange)==null?void 0:d.end)??"normal"}set rangeEnd(d){const y=Y.get(this);if(!y.timeline)return y.animation.rangeEnd=d;y.timeline instanceof We&&(y.animationRange.end=nr(y.timeline,d,"end"),er(y),Jt(y))}get replaceState(){return Y.get(this).animation.pending}get pending(){const d=Y.get(this);return d.timeline?!!d.readyPromise&&d.readyPromise.state=="pending":d.animation.pending}finish(){const d=Y.get(this);if(!d.timeline)return void d.animation.finish();const y=En(d),S=jt(d);if(y==0)throw new DOMException("Cannot finish Animation with a playbackRate of 0.","InvalidStateError");if(y>0&&S==1/0)throw new DOMException("Cannot finish Animation with an infinite target effect end.","InvalidStateError");At(d);const T=y<0?0:S;this.currentTime=cn(d,T);const k=ge(d,d.timeline.currentTime);d.startTime===null&&k!==null&&(d.startTime=k-T/d.animation.playbackRate),d.pendingTask=="pause"&&d.startTime!==null&&(d.holdTime=null,d.pendingTask=null,d.readyPromise.resolve(this)),d.pendingTask=="play"&&d.startTime!==null&&(d.pendingTask=null,d.readyPromise.resolve(this)),Vt(d,!0,!0)}play(){const d=Y.get(this);d.timeline?ls(d):d.animation.play()}pause(){const d=Y.get(this);d.timeline?this.playState!="paused"&&(d.animation.currentTime===null&&(d.autoAlignStartTime=!0),d.pendingTask=="play"?d.pendingTask=null:d.readyPromise=null,d.readyPromise||Xn(d),d.pendingTask="pause",rs(d.timeline,d.animation,us.bind(d.proxy))):d.animation.pause()}reverse(){const d=Y.get(this),y=En(d),S=ge(d,this.currentTime),T=jt(d)==1/0,k=y!=0&&(y<0||S>0||!T);if(!d.timeline||!k)return k&&(d.pendingPlaybackRate=-En(d)),void d.animation.reverse();if(d.timeline.phase=="inactive")throw new DOMException("Cannot reverse an animation with no active timeline","InvalidStateError");this.updatePlaybackRate(-y),ls(d)}updatePlaybackRate(d){const y=Y.get(this);if(y.pendingPlaybackRate=d,!y.timeline)return void y.animation.updatePlaybackRate(d);const S=this.playState;if(!y.readyPromise||y.readyPromise.state!="pending")switch(S){case"idle":case"paused":At(y);break;case"finished":const T=ge(y,y.timeline.currentTime),k=T!==null?(T-y.startTime)*y.animation.playbackRate:null;y.startTime=d==0?T:T!=null&&k!=null?(T-k)/d:null,At(y),Vt(y,!1,!1),Jt(y);break;default:ls(y)}}persist(){Y.get(this).animation.persist()}get id(){return Y.get(this).animation.id}set id(d){Y.get(this).animation.id=d}cancel(){const d=Y.get(this);d.timeline?(this.playState!="idle"&&(function(y){y.pendingTask&&(y.pendingTask=null,At(y),y.readyPromise.reject(Bo()),Xn(y),y.readyPromise.resolve(y.proxy))}(d),d.finishedPromise&&d.finishedPromise.state=="pending"&&d.finishedPromise.reject(Bo()),d.finishedPromise=new Cn,d.animation.cancel()),d.startTime=null,d.holdTime=null,is(d.timeline,d.animation)):d.animation.cancel()}get onfinish(){return Y.get(this).animation.onfinish}set onfinish(d){Y.get(this).animation.onfinish=d}get oncancel(){return Y.get(this).animation.oncancel}set oncancel(d){Y.get(this).animation.oncancel=d}get onremove(){return Y.get(this).animation.onremove}set onremove(d){Y.get(this).animation.onremove=d}get finished(){const d=Y.get(this);return d.timeline?(d.finishedPromise||(d.finishedPromise=new Cn),d.finishedPromise.promise):d.animation.finished}get ready(){const d=Y.get(this);return d.timeline?(d.readyPromise||(d.readyPromise=new Cn,d.readyPromise.resolve(this)),d.readyPromise.promise):d.animation.ready}addEventListener(d,y,S){Y.get(this).animation.addEventListener(d,y,S)}removeEventListener(d,y,S){Y.get(this).animation.removeEventListener(d,y,S)}dispatchEvent(d){Y.get(this).animation.dispatchEvent(d)}}function Cl(h,d){const y=d.timeline;y instanceof We&&delete d.timeline;const S=Tl.apply(this,[h,d]),T=new ir(S,y);return y instanceof We&&(S.pause(),Y.get(T).animationRange={start:nr(y,d.rangeStart,"start"),end:nr(y,d.rangeEnd,"end")},T.play()),T}function Go(h){for(let d=0;d<h.length;++d){let y=Vo.get(h[d]);y&&(h[d]=y)}return h}function El(h){return Go(_l.apply(this,[h]))}function Pl(h){return Go(wl.apply(this,[h]))}const ke={IDENTIFIER:/[\w\\\@_-]+/g,WHITE_SPACE:/\s*/g,TIME:/^[0-9]+(s|ms)/,SCROLL_TIMELINE:/scroll-timeline\s*:([^;}]+)/,SCROLL_TIMELINE_NAME:/scroll-timeline-name\s*:([^;}]+)/,SCROLL_TIMELINE_AXIS:/scroll-timeline-axis\s*:([^;}]+)/,VIEW_TIMELINE:/view-timeline\s*:([^;}]+)/,VIEW_TIMELINE_NAME:/view-timeline-name\s*:([^;}]+)/,VIEW_TIMELINE_AXIS:/view-timeline-axis\s*:([^;}]+)/,VIEW_TIMELINE_INSET:/view-timeline-inset\s*:([^;}]+)/,ANIMATION_TIMELINE:/animation-timeline\s*:([^;}]+)/,ANIMATION_TIME_RANGE:/animation-range\s*:([^;}]+)/,ANIMATION_NAME:/animation-name\s*:([^;}]+)/,ANIMATION:/animation\s*:([^;}]+)/,ANONYMOUS_SCROLL_TIMELINE:/scroll\(([^)]*)\)/,ANONYMOUS_VIEW_TIMELINE:/view\(([^)]*)\)/},Pn=["block","inline","x","y"],kl=["nearest","root","self"],Kt=new class{constructor(){this.cssRulesWithTimelineName=[],this.nextAnonymousTimelineNameIndex=0,this.anonymousScrollTimelineOptions=new Map,this.anonymousViewTimelineOptions=new Map,this.sourceSelectorToScrollTimeline=[],this.subjectSelectorToViewTimeline=[],this.keyframeNamesSelectors=new Map}transpileStyleSheet(h,d,y){const S={sheetSrc:h,index:0,name:y};for(;S.index<S.sheetSrc.length&&(this.eatWhitespace(S),!(S.index>=S.sheetSrc.length));){if(this.lookAhead("/*",S)){for(;this.lookAhead("/*",S);)this.eatComment(S),this.eatWhitespace(S);continue}const T=this.parseQualifiedRule(S);T&&(d?this.parseKeyframesAndSaveNameMapping(T,S):this.handleScrollTimelineProps(T,S))}return S.sheetSrc}getAnimationTimelineOptions(h,d){for(let y=this.cssRulesWithTimelineName.length-1;y>=0;y--){const S=this.cssRulesWithTimelineName[y];try{if(d.matches(S.selector)&&(!S["animation-name"]||S["animation-name"]==h))return{"animation-timeline":S["animation-timeline"],"animation-range":S["animation-range"]}}catch{}}return null}getAnonymousScrollTimelineOptions(h,d){const y=this.anonymousScrollTimelineOptions.get(h);return y?{anonymousSource:y.source,anonymousTarget:d,source:Ro(y.source??"nearest",d),axis:y.axis?y.axis:"block"}:null}getScrollTimelineOptions(h,d){const y=this.getAnonymousScrollTimelineOptions(h,d);if(y)return y;for(let S=this.sourceSelectorToScrollTimeline.length-1;S>=0;S--){const T=this.sourceSelectorToScrollTimeline[S];if(T.name==h){const k=this.findPreviousSiblingOrAncestorMatchingSelector(d,T.selector);if(k)return{source:k,...T.axis?{axis:T.axis}:{}}}}return null}findPreviousSiblingOrAncestorMatchingSelector(h,d){let y=h;for(;y;){if(y.matches(d))return y;y=y.previousElementSibling||y.parentElement}return null}getAnonymousViewTimelineOptions(h,d){const y=this.anonymousViewTimelineOptions.get(h);return y?{subject:d,axis:y.axis?y.axis:"block",inset:y.inset?y.inset:"auto"}:null}getViewTimelineOptions(h,d){const y=this.getAnonymousViewTimelineOptions(h,d);if(y)return y;for(let S=this.subjectSelectorToViewTimeline.length-1;S>=0;S--){const T=this.subjectSelectorToViewTimeline[S];if(T.name==h){const k=this.findPreviousSiblingOrAncestorMatchingSelector(d,T.selector);if(k)return{subject:k,axis:T.axis,inset:T.inset}}}return null}handleScrollTimelineProps(h,d){if(h.selector.includes("@keyframes"))return;const y=h.block.contents.includes("animation-name:"),S=h.block.contents.includes("animation-timeline:"),T=h.block.contents.includes("animation:");if(this.saveSourceSelectorToScrollTimeline(h),this.saveSubjectSelectorToViewTimeline(h),!S&&!y&&!T)return;let k=[],I=[],U=!1;S&&(k=this.extractScrollTimelineNames(h.block.contents)),y&&(I=this.extractMatches(h.block.contents,ke.ANIMATION_NAME)),S&&y||(T&&this.extractMatches(h.block.contents,ke.ANIMATION).forEach(N=>{const L=this.extractAnimationName(N);L&&S&&I.push(L),S&&(this.hasDuration(N)||(this.hasAutoDuration(N)&&(h.block.contents=h.block.contents.replace("auto"," ")),h.block.contents=h.block.contents.replace(N," 1s "+N),U=!0))}),U&&this.replacePart(h.block.startIndex,h.block.endIndex,h.block.contents,d)),this.saveRelationInList(h,k,I)}saveSourceSelectorToScrollTimeline(h){const d=h.block.contents.includes("scroll-timeline:"),y=h.block.contents.includes("scroll-timeline-name:"),S=h.block.contents.includes("scroll-timeline-axis:");if(!d&&!y)return;let T=[];if(d){const I=this.extractMatches(h.block.contents,ke.SCROLL_TIMELINE);for(const U of I){const N=this.split(U);let L={selector:h.selector,name:""};N.length==1?L.name=N[0]:N.length==2&&(Pn.includes(N[0])?(L.axis=N[0],L.name=N[1]):(L.axis=N[1],L.name=N[0])),T.push(L)}}if(y){const I=this.extractMatches(h.block.contents,ke.SCROLL_TIMELINE_NAME);for(let U=0;U<I.length;U++)if(U<T.length)T[U].name=I[U];else{let N={selector:h.selector,name:I[U]};T.push(N)}}let k=[];if(S){const I=this.extractMatches(h.block.contents,ke.SCROLL_TIMELINE_AXIS);if(k=I.filter(U=>Pn.includes(U)),k.length!=I.length)throw new Error("Invalid axis")}for(let I=0;I<T.length;I++)k.length&&(T[I].axis=k[I%T.length]);this.sourceSelectorToScrollTimeline.push(...T)}saveSubjectSelectorToViewTimeline(h){const d=h.block.contents.includes("view-timeline:"),y=h.block.contents.includes("view-timeline-name:"),S=h.block.contents.includes("view-timeline-axis:"),T=h.block.contents.includes("view-timeline-inset:");if(!d&&!y)return;let k=[];if(d){const N=this.extractMatches(h.block.contents,ke.VIEW_TIMELINE);for(let L of N){const X=this.split(L);let Z={selector:h.selector,name:"",inset:null};X.length==1?Z.name=X[0]:X.length==2&&(Pn.includes(X[0])?(Z.axis=X[0],Z.name=X[1]):(Z.axis=X[1],Z.name=X[0])),k.push(Z)}}if(y){const N=this.extractMatches(h.block.contents,ke.VIEW_TIMELINE_NAME);for(let L=0;L<N.length;L++)if(L<k.length)k[L].name=N[L];else{let X={selector:h.selector,name:N[L],inset:null};k.push(X)}}let I=[],U=[];if(T&&(I=this.extractMatches(h.block.contents,ke.VIEW_TIMELINE_INSET)),S){const N=this.extractMatches(h.block.contents,ke.VIEW_TIMELINE_AXIS);if(U=N.filter(L=>Pn.includes(L)),U.length!=N.length)throw new Error("Invalid axis")}for(let N=0;N<k.length;N++)I.length&&(k[N].inset=I[N%k.length]),U.length&&(k[N].axis=U[N%k.length]);this.subjectSelectorToViewTimeline.push(...k)}hasDuration(h){return h.split(" ").filter(d=>{return y=d,ke.TIME.exec(y);var y}).length>=1}hasAutoDuration(h){return h.split(" ").filter(d=>d==="auto").length>=1}saveRelationInList(h,d,y){let S=[];h.block.contents.includes("animation-range:")&&(S=this.extractMatches(h.block.contents,ke.ANIMATION_TIME_RANGE));const T=Math.max(d.length,y.length,S.length);for(let k=0;k<T;k++)this.cssRulesWithTimelineName.push({selector:h.selector,"animation-timeline":d[k%d.length],...y.length?{"animation-name":y[k%y.length]}:{},...S.length?{"animation-range":S[k%S.length]}:{}})}extractScrollTimelineNames(h){const d=ke.ANIMATION_TIMELINE.exec(h)[1].trim(),y=[];return d.split(",").map(S=>S.trim()).forEach(S=>{if(function(T){return(T.startsWith("scroll")||T.startsWith("view"))&&T.includes("(")}(S)){const T=this.saveAnonymousTimelineName(S);y.push(T)}else y.push(S)}),y}saveAnonymousTimelineName(h){const d=":t"+this.nextAnonymousTimelineNameIndex++;return h.startsWith("scroll(")?this.anonymousScrollTimelineOptions.set(d,this.parseAnonymousScrollTimeline(h)):this.anonymousViewTimelineOptions.set(d,this.parseAnonymousViewTimeline(h)),d}parseAnonymousScrollTimeline(h){const d=ke.ANONYMOUS_SCROLL_TIMELINE.exec(h);if(!d)return null;const y=d[1],S={};return y.split(" ").forEach(T=>{Pn.includes(T)?S.axis=T:kl.includes(T)&&(S.source=T)}),S}parseAnonymousViewTimeline(h){const d=ke.ANONYMOUS_VIEW_TIMELINE.exec(h);if(!d)return null;const y=d[1],S={};return y.split(" ").forEach(T=>{Pn.includes(T)?S.axis=T:S.inset=S.inset?`${S.inset} ${T}`:T}),S}extractAnimationName(h){return this.findMatchingEntryInContainer(h,this.keyframeNamesSelectors)}findMatchingEntryInContainer(h,d){const y=h.split(" ").filter(S=>d.has(S));return y?y[0]:null}parseIdentifier(h){ke.IDENTIFIER.lastIndex=h.index;const d=ke.IDENTIFIER.exec(h.sheetSrc);if(!d)throw this.parseError(h,"Expected an identifier");return h.index+=d[0].length,d[0]}parseKeyframesAndSaveNameMapping(h,d){if(h.selector.startsWith("@keyframes")){const y=this.replaceKeyframesAndGetMapping(h,d);h.selector.split(" ").forEach((S,T)=>{T>0&&this.keyframeNamesSelectors.set(S,y)})}}replaceKeyframesAndGetMapping(h,d){function y(N){return Qi.some(L=>N.startsWith(L))}const S=h.block.contents,T=function(N){let L=0,X=-1,Z=-1;const K=[];for(let he=0;he<N.length;he++)N[he]=="{"?L++:N[he]=="}"&&L--,L==1&&N[he]!="{"&&N[he]!="}"&&X==-1&&(X=he),L==2&&N[he]=="{"&&(Z=he,K.push({start:X,end:Z}),X=Z=-1);return K}(S);if(T.length==0)return new Map;const k=new Map;let I=!1;const U=[];U.push(S.substring(0,T[0].start));for(let N=0;N<T.length;N++){const L=S.substring(T[N].start,T[N].end);let X=[];L.split(",").forEach(Z=>{const K=Z.split(" ").map(we=>we.trim()).filter(we=>we!="").join(" "),he=k.size;k.set(he,K),X.push(`${he}%`),y(K)&&(I=!0)}),U.push(X.join(",")),N==T.length-1?U.push(S.substring(T[N].end)):U.push(S.substring(T[N].end,T[N+1].start))}return I?(h.block.contents=U.join(""),this.replacePart(h.block.startIndex,h.block.endIndex,h.block.contents,d),k):new Map}parseQualifiedRule(h){const d=h.index,y=this.parseSelector(h).trim();if(y)return{selector:y,block:this.eatBlock(h),startIndex:d,endIndex:h.index}}removeEnclosingDoubleQuotes(h){let d=h[0]=='"'?1:0,y=h[h.length-1]=='"'?h.length-1:h.length;return h.substring(d,y)}assertString(h,d){if(h.sheetSrc.substr(h.index,d.length)!=d)throw this.parseError(h,`Did not find expected sequence ${d}`);h.index+=d.length}replacePart(h,d,y,S){if(S.sheetSrc=S.sheetSrc.slice(0,h)+y+S.sheetSrc.slice(d),S.index>=d){const T=S.index-d;S.index=h+y.length+T}}eatComment(h){this.assertString(h,"/*"),this.eatUntil("*/",h,!0),this.assertString(h,"*/")}eatBlock(h){const d=h.index;this.assertString(h,"{");let y=1;for(;y!=0;)this.lookAhead("/*",h)?this.eatComment(h):(h.sheetSrc[h.index]==="{"?y++:h.sheetSrc[h.index]==="}"&&y--,this.advance(h));const S=h.index;return{startIndex:d,endIndex:S,contents:h.sheetSrc.slice(d,S)}}advance(h){if(h.index++,h.index>h.sheetSrc.length)throw this.parseError(h,"Advanced beyond the end")}parseError(h,d){return Error(`(${h.name?h.name:"<anonymous file>"}): ${d}`)}eatUntil(h,d,y=!1){const S=d.index;for(;!this.lookAhead(h,d);)this.advance(d);return y&&(d.sheetSrc=d.sheetSrc.slice(0,S)+" ".repeat(d.index-S)+d.sheetSrc.slice(d.index)),d.sheetSrc.slice(S,d.index)}parseSelector(h){let d=h.index;if(this.eatUntil("{",h),d===h.index)throw Error("Empty selector");return h.sheetSrc.slice(d,h.index)}eatWhitespace(h){ke.WHITE_SPACE.lastIndex=h.index;const d=ke.WHITE_SPACE.exec(h.sheetSrc);d&&(h.index+=d[0].length)}lookAhead(h,d){return d.sheetSrc.substr(d.index,h.length)==h}peek(h){return h.sheetSrc[h.index]}extractMatches(h,d,y=","){return d.exec(h)[1].trim().split(y).map(S=>S.trim())}split(h){return h.split(" ").map(d=>d.trim()).filter(d=>d!="")}};function Rl(h,d,y,S,T,k){const I=ts(d),U=ns(d,y);return Io(as(h,I,U,S,T),k,as("cover",I,U,S,T),y)}function Al(h,d,y){const S=Kt.getAnimationTimelineOptions(d,y);if(!S)return null;const T=S["animation-timeline"];if(!T)return null;let k=Kt.getScrollTimelineOptions(T,y)||Kt.getViewTimelineOptions(T,y);return k?(k.subject&&function(I,U){const N=os(U.subject),L=U.axis||U.axis;function X(K,he){let we=null;for(const[Qe,Tt]of K)if(Qe==100*he.offset){if(Tt=="from")we=0;else if(Tt=="to")we=100;else{const dt=Tt.split(" ");we=dt.length==1?parseFloat(dt[0]):100*Rl(dt[0],N,U.subject,L,U.inset,CSS.percent(parseFloat(dt[1])))}break}return we}const Z=Kt.keyframeNamesSelectors.get(I.animationName);if(Z&&Z.size){const K=[];I.effect.getKeyframes().forEach(we=>{const Qe=X(Z,we);Qe!==null&&Qe>=0&&Qe<=100&&(we.offset=Qe/100,K.push(we))});const he=K.sort((we,Qe)=>we.offset<Qe.offset?-1:we.affset>Qe.offset?1:0);I.effect.setKeyframes(he)}}(h,k),{timeline:k.source?new We(k):new Mn(k),animOptions:S}):null}function Ol(){if(CSS.supports("animation-timeline: --works"))return!0;(function(){function d(S){if(S.innerHTML.trim().length===0||"aphrodite"in S.dataset)return;let T=Kt.transpileStyleSheet(S.innerHTML,!0);T=Kt.transpileStyleSheet(T,!1),S.innerHTML=T}function y(S){S.type!="text/css"&&S.rel!="stylesheet"||!S.href||new URL(S.href,document.baseURI).origin==location.origin&&fetch(S.getAttribute("href")).then(async T=>{const k=await T.text();let I=Kt.transpileStyleSheet(k,!0);if(I=Kt.transpileStyleSheet(k,!1),I!=k){const U=new Blob([I],{type:"text/css"}),N=URL.createObjectURL(U);S.setAttribute("href",N)}})}new MutationObserver(S=>{for(const T of S)for(const k of T.addedNodes)k instanceof HTMLStyleElement&&d(k),k instanceof HTMLLinkElement&&y(k)}).observe(document.documentElement,{childList:!0,subtree:!0}),document.querySelectorAll("style").forEach(S=>d(S)),document.querySelectorAll("link").forEach(S=>y(S))})();const h=CSS.supports;CSS.supports=d=>(d=d.replaceAll(/(animation-timeline|scroll-timeline(-(name|axis))?|view-timeline(-(name|axis|inset))?|timeline-scope)\s*:/g,"--supported-property:"),h(d)),window.addEventListener("animationstart",d=>{d.target.getAnimations().filter(y=>y.animationName===d.animationName).forEach(y=>{const S=Al(y,y.animationName,d.target);if(S)if(!S.timeline||y instanceof ir)y.timeline=S.timeline;else{const T=new ir(y,S.timeline,S.animOptions);y.pause(),T.play()}})})}(function(){if(!Ol()){if(!Reflect.defineProperty(window,"ScrollTimeline",{value:We}))throw Error("Error installing ScrollTimeline polyfill: could not attach ScrollTimeline to window");if(!Reflect.defineProperty(window,"ViewTimeline",{value:Mn}))throw Error("Error installing ViewTimeline polyfill: could not attach ViewTimeline to window");if(!Reflect.defineProperty(Element.prototype,"animate",{value:Cl}))throw Error("Error installing ScrollTimeline polyfill: could not attach WAAPI's animate to DOM Element");if(!Reflect.defineProperty(window,"Animation",{value:ir}))throw Error("Error installing Animation constructor.");if(!Reflect.defineProperty(Element.prototype,"getAnimations",{value:El}))throw Error("Error installing ScrollTimeline polyfill: could not attach WAAPI's getAnimations to DOM Element");if(!Reflect.defineProperty(document,"getAnimations",{value:Pl}))throw Error("Error installing ScrollTimeline polyfill: could not attach WAAPI's getAnimations to document")}})()})();class fd{constructor(e,t){if(this._retries=0,!Number.isInteger(e)||e<0)throw new Error("Base must be a positive integer or zero");if(t!==void 0&&(!Number.isInteger(t)||t<0))throw new Error("ExpMax must be a undefined, a positive integer or zero");this.base=e,this.expMax=t,this.i=0}get retries(){return this._retries}get current(){return this.base*Math.pow(2,this.i)}next(){return this._retries++,this.i=this.expMax===void 0?this.i+1:Math.min(this.i+1,this.expMax),this.current}reset(){this._retries=0,this.i=0}}var se;(function(r){r.open="open",r.close="close",r.error="error",r.message="message",r.retry="retry",r.reconnect="reconnect"})(se||(se={}));class Jc{constructor(e,t,n){var i,s,a,o,c,l,u,p,f,m,b,x,g,v,_;this._closedByUser=!1,this.handleOpenEvent=w=>this.handleEvent(se.open,w),this.handleErrorEvent=w=>this.handleEvent(se.error,w),this.handleCloseEvent=w=>this.handleEvent(se.close,w),this.handleMessageEvent=w=>this.handleEvent(se.message,w),this._url=e,this._protocols=t,this._options={buffer:n?.buffer,retry:{maxRetries:(i=n?.retry)===null||i===void 0?void 0:i.maxRetries,instantReconnect:(s=n?.retry)===null||s===void 0?void 0:s.instantReconnect,backoff:(a=n?.retry)===null||a===void 0?void 0:a.backoff},listeners:{open:[...(c=(o=n?.listeners)===null||o===void 0?void 0:o.open)!==null&&c!==void 0?c:[]],close:[...(u=(l=n?.listeners)===null||l===void 0?void 0:l.close)!==null&&u!==void 0?u:[]],error:[...(f=(p=n?.listeners)===null||p===void 0?void 0:p.error)!==null&&f!==void 0?f:[]],message:[...(b=(m=n?.listeners)===null||m===void 0?void 0:m.message)!==null&&b!==void 0?b:[]],retry:[...(g=(x=n?.listeners)===null||x===void 0?void 0:x.retry)!==null&&g!==void 0?g:[]],reconnect:[...(_=(v=n?.listeners)===null||v===void 0?void 0:v.reconnect)!==null&&_!==void 0?_:[]]}},this._underlyingWebsocket=this.tryConnect()}get url(){return this._url}get protocols(){return this._protocols}get buffer(){return this._options.buffer}get maxRetries(){return this._options.retry.maxRetries}get instantReconnect(){return this._options.retry.instantReconnect}get backoff(){return this._options.retry.backoff}get closedByUser(){return this._closedByUser}get lastConnection(){return this._lastConnection}get underlyingWebsocket(){return this._underlyingWebsocket}get readyState(){return this._underlyingWebsocket.readyState}get bufferedAmount(){return this._underlyingWebsocket.bufferedAmount}get extensions(){return this._underlyingWebsocket.extensions}get binaryType(){return this._underlyingWebsocket.binaryType}set binaryType(e){this._underlyingWebsocket.binaryType=e}send(e){this.closedByUser||(this._underlyingWebsocket.readyState===this._underlyingWebsocket.OPEN?this._underlyingWebsocket.send(e):this.buffer!==void 0&&this.buffer.add(e))}close(e,t){this.cancelScheduledConnectionRetry(),this._closedByUser=!0,this._underlyingWebsocket.close(e,t)}addEventListener(e,t,n){this._options.listeners[e].push({listener:t,options:n})}removeEventListener(e,t,n){const i=s=>s.listener!==t||s.options!==n;this._options.listeners[e]=this._options.listeners[e].filter(i)}tryConnect(){return this._underlyingWebsocket=new WebSocket(this.url,this.protocols),this._underlyingWebsocket.addEventListener(se.open,this.handleOpenEvent),this._underlyingWebsocket.addEventListener(se.close,this.handleCloseEvent),this._underlyingWebsocket.addEventListener(se.error,this.handleErrorEvent),this._underlyingWebsocket.addEventListener(se.message,this.handleMessageEvent),this._underlyingWebsocket}clearWebsocket(){this._underlyingWebsocket.removeEventListener(se.open,this.handleOpenEvent),this._underlyingWebsocket.removeEventListener(se.close,this.handleCloseEvent),this._underlyingWebsocket.removeEventListener(se.error,this.handleErrorEvent),this._underlyingWebsocket.removeEventListener(se.message,this.handleMessageEvent),this._underlyingWebsocket.close()}dispatchEvent(e,t){const n=this._options.listeners[e],i=[];n.forEach(({listener:s,options:a})=>{s(this,t),(a===void 0||a.once===void 0||!a.once)&&i.push({listener:s,options:a})}),this._options.listeners[e]=i}handleEvent(e,t){switch(e){case se.close:this.dispatchEvent(e,t),this.scheduleConnectionRetryIfNeeded();break;case se.open:if(this.backoff!==void 0&&this._lastConnection!==void 0){const n={retries:this.backoff.retries,lastConnection:new Date(this._lastConnection)},i=new CustomEvent(se.reconnect,{detail:n});this.dispatchEvent(se.reconnect,i),this.backoff.reset()}this._lastConnection=new Date,this.dispatchEvent(e,t),this.sendBufferedData();break;case se.retry:this.dispatchEvent(e,t),this.clearWebsocket(),this.tryConnect();break;default:this.dispatchEvent(e,t);break}}sendBufferedData(){if(this.buffer!==void 0)for(let e=this.buffer.read();e!==void 0;e=this.buffer.read())this.send(e)}scheduleConnectionRetryIfNeeded(){if(this.closedByUser||this.backoff===void 0)return;const e=n=>{const i=new CustomEvent(se.retry,{detail:n});this.handleEvent(se.retry,i)},t={backoff:this._options.retry.instantReconnect===!0?0:this.backoff.next(),retries:this._options.retry.instantReconnect===!0?0:this.backoff.retries,lastConnection:this._lastConnection};(this._options.retry.maxRetries===void 0||t.retries<=this._options.retry.maxRetries)&&(this.retryTimeout=globalThis.setTimeout(()=>e(t),t.backoff))}cancelScheduledConnectionRetry(){globalThis.clearTimeout(this.retryTimeout)}}class md{constructor(e){this._url=e}get url(){return this._url}withProtocols(e){return this._protocols=e,this}get protocols(){return this._protocols}withMaxRetries(e){var t;return this._options=Object.assign(Object.assign({},this._options),{retry:Object.assign(Object.assign({},(t=this._options)===null||t===void 0?void 0:t.retry),{maxRetries:e})}),this}get maxRetries(){var e,t;return(t=(e=this._options)===null||e===void 0?void 0:e.retry)===null||t===void 0?void 0:t.maxRetries}withInstantReconnect(e){var t;return this._options=Object.assign(Object.assign({},this._options),{retry:Object.assign(Object.assign({},(t=this._options)===null||t===void 0?void 0:t.retry),{instantReconnect:e})}),this}get instantReconnect(){var e,t;return(t=(e=this._options)===null||e===void 0?void 0:e.retry)===null||t===void 0?void 0:t.instantReconnect}withBackoff(e){var t;return this._options=Object.assign(Object.assign({},this._options),{retry:Object.assign(Object.assign({},(t=this._options)===null||t===void 0?void 0:t.retry),{backoff:e})}),this}get backoff(){var e,t;return(t=(e=this._options)===null||e===void 0?void 0:e.retry)===null||t===void 0?void 0:t.backoff}withBuffer(e){return this._options=Object.assign(Object.assign({},this._options),{buffer:e}),this}get buffer(){var e;return(e=this._options)===null||e===void 0?void 0:e.buffer}onOpen(e,t){return this.addListener(se.open,e,t),this}onClose(e,t){return this.addListener(se.close,e,t),this}onError(e,t){return this.addListener(se.error,e,t),this}onMessage(e,t){return this.addListener(se.message,e,t),this}onRetry(e,t){return this.addListener(se.retry,e,t),this}onReconnect(e,t){return this.addListener(se.reconnect,e,t),this}build(){return new Jc(this._url,this._protocols,this._options)}addListener(e,t,n){var i,s,a,o,c,l,u,p,f,m,b,x,g,v,_,w,C,M,E,P,O;return this._options=Object.assign(Object.assign({},this._options),{listeners:{open:(a=(s=(i=this._options)===null||i===void 0?void 0:i.listeners)===null||s===void 0?void 0:s.open)!==null&&a!==void 0?a:[],close:(l=(c=(o=this._options)===null||o===void 0?void 0:o.listeners)===null||c===void 0?void 0:c.close)!==null&&l!==void 0?l:[],error:(f=(p=(u=this._options)===null||u===void 0?void 0:u.listeners)===null||p===void 0?void 0:p.error)!==null&&f!==void 0?f:[],message:(x=(b=(m=this._options)===null||m===void 0?void 0:m.listeners)===null||b===void 0?void 0:b.message)!==null&&x!==void 0?x:[],retry:(_=(v=(g=this._options)===null||g===void 0?void 0:g.listeners)===null||v===void 0?void 0:v.retry)!==null&&_!==void 0?_:[],reconnect:(M=(C=(w=this._options)===null||w===void 0?void 0:w.listeners)===null||C===void 0?void 0:C.reconnect)!==null&&M!==void 0?M:[],[e]:[...(O=(P=(E=this._options)===null||E===void 0?void 0:E.listeners)===null||P===void 0?void 0:P[e])!==null&&O!==void 0?O:[],{listener:t,options:n}]}}),this}}const yd=Object.freeze(Object.defineProperty({__proto__:null,ExponentialBackoff:fd,Websocket:Jc,WebsocketBuilder:md,get WebsocketEvent(){return se}},Symbol.toStringTag,{value:"Module"})),Zs=0,Gc=1,Wc=2,Ks=2,Qs=1.25,Hc=1,ci=32,Pr=65535,gd=Math.pow(2,-24),$s=Symbol("SKIP_GENERATION");function vd(r){return r.index?r.index.count:r.attributes.position.count}function zn(r){return vd(r)/3}function Sd(r,e=ArrayBuffer){return r>65535?new Uint32Array(new e(4*r)):new Uint16Array(new e(2*r))}function bd(r,e){if(!r.index){const t=r.attributes.position.count,n=e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,i=Sd(t,n);r.setIndex(new ot(i,1));for(let s=0;s<t;s++)i[s]=s}}function qc(r,e){const t=zn(r),n=e||r.drawRange,i=n.start/3,s=(n.start+n.count)/3,a=Math.max(0,i),o=Math.min(t,s)-a;return[{offset:Math.floor(a),count:Math.floor(o)}]}function Xc(r,e){if(!r.groups||!r.groups.length)return qc(r,e);const t=[],n=new Set,i=e||r.drawRange,s=i.start/3,a=(i.start+i.count)/3;for(const c of r.groups){const l=c.start/3,u=(c.start+c.count)/3;n.add(Math.max(s,l)),n.add(Math.min(a,u))}const o=Array.from(n.values()).sort((c,l)=>c-l);for(let c=0;c<o.length-1;c++){const l=o[c],u=o[c+1];t.push({offset:Math.floor(l),count:Math.floor(u-l)})}return t}function xd(r,e){const t=zn(r),n=Xc(r,e).sort((a,o)=>a.offset-o.offset),i=n[n.length-1];i.count=Math.min(t-i.offset,i.count);let s=0;return n.forEach(({count:a})=>s+=a),t!==s}function eo(r,e,t,n,i){let s=1/0,a=1/0,o=1/0,c=-1/0,l=-1/0,u=-1/0,p=1/0,f=1/0,m=1/0,b=-1/0,x=-1/0,g=-1/0;for(let v=e*6,_=(e+t)*6;v<_;v+=6){const w=r[v+0],C=r[v+1],M=w-C,E=w+C;M<s&&(s=M),E>c&&(c=E),w<p&&(p=w),w>b&&(b=w);const P=r[v+2],O=r[v+3],R=P-O,A=P+O;R<a&&(a=R),A>l&&(l=A),P<f&&(f=P),P>x&&(x=P);const B=r[v+4],z=r[v+5],D=B-z,F=B+z;D<o&&(o=D),F>u&&(u=F),B<m&&(m=B),B>g&&(g=B)}n[0]=s,n[1]=a,n[2]=o,n[3]=c,n[4]=l,n[5]=u,i[0]=p,i[1]=f,i[2]=m,i[3]=b,i[4]=x,i[5]=g}function wd(r,e=null,t=null,n=null){const i=r.attributes.position,s=r.index?r.index.array:null,a=zn(r),o=i.normalized;let c;e===null?(c=new Float32Array(a*6),t=0,n=a):(c=e,t=t||0,n=n||a);const l=i.array,u=i.offset||0;let p=3;i.isInterleavedBufferAttribute&&(p=i.data.stride);const f=["getX","getY","getZ"];for(let m=t;m<t+n;m++){const b=m*3,x=m*6;let g=b+0,v=b+1,_=b+2;s&&(g=s[g],v=s[v],_=s[_]),o||(g=g*p+u,v=v*p+u,_=_*p+u);for(let w=0;w<3;w++){let C,M,E;o?(C=i[f[w]](g),M=i[f[w]](v),E=i[f[w]](_)):(C=l[g+w],M=l[v+w],E=l[_+w]);let P=C;M<P&&(P=M),E<P&&(P=E);let O=C;M>O&&(O=M),E>O&&(O=E);const R=(O-P)/2,A=w*2;c[x+A+0]=P+R,c[x+A+1]=R+(Math.abs(P)+R)*gd}}return c}function ve(r,e,t){return t.min.x=e[r],t.min.y=e[r+1],t.min.z=e[r+2],t.max.x=e[r+3],t.max.y=e[r+4],t.max.z=e[r+5],t}function Yc(r){let e=-1,t=-1/0;for(let n=0;n<3;n++){const i=r[n+3]-r[n];i>t&&(t=i,e=n)}return e}function Zc(r,e){e.set(r)}function Kc(r,e,t){let n,i;for(let s=0;s<3;s++){const a=s+3;n=r[s],i=e[s],t[s]=n<i?n:i,n=r[a],i=e[a],t[a]=n>i?n:i}}function kr(r,e,t){for(let n=0;n<3;n++){const i=e[r+2*n],s=e[r+2*n+1],a=i-s,o=i+s;a<t[n]&&(t[n]=a),o>t[n+3]&&(t[n+3]=o)}}function li(r){const e=r[3]-r[0],t=r[4]-r[1],n=r[5]-r[2];return 2*(e*t+t*n+n*e)}const Xt=32,_d=(r,e)=>r.candidate-e.candidate,tn=new Array(Xt).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),Rr=new Float32Array(6);function Td(r,e,t,n,i,s){let a=-1,o=0;if(s===Zs)a=Yc(e),a!==-1&&(o=(e[a]+e[a+3])/2);else if(s===Gc)a=Yc(r),a!==-1&&(o=Md(t,n,i,a));else if(s===Wc){const c=li(r);let l=Qs*i;const u=n*6,p=(n+i)*6;for(let f=0;f<3;f++){const m=e[f],b=(e[f+3]-m)/Xt;if(i<Xt/4){const x=[...tn];x.length=i;let g=0;for(let _=u;_<p;_+=6,g++){const w=x[g];w.candidate=t[_+2*f],w.count=0;const{bounds:C,leftCacheBounds:M,rightCacheBounds:E}=w;for(let P=0;P<3;P++)E[P]=1/0,E[P+3]=-1/0,M[P]=1/0,M[P+3]=-1/0,C[P]=1/0,C[P+3]=-1/0;kr(_,t,C)}x.sort(_d);let v=i;for(let _=0;_<v;_++){const w=x[_];for(;_+1<v&&x[_+1].candidate===w.candidate;)x.splice(_+1,1),v--}for(let _=u;_<p;_+=6){const w=t[_+2*f];for(let C=0;C<v;C++){const M=x[C];w>=M.candidate?kr(_,t,M.rightCacheBounds):(kr(_,t,M.leftCacheBounds),M.count++)}}for(let _=0;_<v;_++){const w=x[_],C=w.count,M=i-w.count,E=w.leftCacheBounds,P=w.rightCacheBounds;let O=0;C!==0&&(O=li(E)/c);let R=0;M!==0&&(R=li(P)/c);const A=Hc+Qs*(O*C+R*M);A<l&&(a=f,l=A,o=w.candidate)}}else{for(let v=0;v<Xt;v++){const _=tn[v];_.count=0,_.candidate=m+b+v*b;const w=_.bounds;for(let C=0;C<3;C++)w[C]=1/0,w[C+3]=-1/0}for(let v=u;v<p;v+=6){let _=~~((t[v+2*f]-m)/b);_>=Xt&&(_=Xt-1);const w=tn[_];w.count++,kr(v,t,w.bounds)}const x=tn[Xt-1];Zc(x.bounds,x.rightCacheBounds);for(let v=Xt-2;v>=0;v--){const _=tn[v],w=tn[v+1];Kc(_.bounds,w.rightCacheBounds,_.rightCacheBounds)}let g=0;for(let v=0;v<Xt-1;v++){const _=tn[v],w=_.count,C=_.bounds,M=tn[v+1].rightCacheBounds;w!==0&&(g===0?Zc(C,Rr):Kc(C,Rr,Rr)),g+=w;let E=0,P=0;g!==0&&(E=li(Rr)/c);const O=i-g;O!==0&&(P=li(M)/c);const R=Hc+Qs*(E*g+P*O);R<l&&(a=f,l=R,o=_.candidate)}}}}else console.warn(`MeshBVH: Invalid build strategy value ${s} used.`);return{axis:a,pos:o}}function Md(r,e,t,n){let i=0;for(let s=e,a=e+t;s<a;s++)i+=r[s*6+n*2];return i/t}class to{constructor(){this.boundingData=new Float32Array(6)}}function Cd(r,e,t,n,i,s){let a=n,o=n+i-1;const c=s.pos,l=s.axis*2;for(;;){for(;a<=o&&t[a*6+l]<c;)a++;for(;a<=o&&t[o*6+l]>=c;)o--;if(a<o){for(let u=0;u<3;u++){let p=e[a*3+u];e[a*3+u]=e[o*3+u],e[o*3+u]=p}for(let u=0;u<6;u++){let p=t[a*6+u];t[a*6+u]=t[o*6+u],t[o*6+u]=p}a++,o--}else return a}}function Ed(r,e,t,n,i,s){let a=n,o=n+i-1;const c=s.pos,l=s.axis*2;for(;;){for(;a<=o&&t[a*6+l]<c;)a++;for(;a<=o&&t[o*6+l]>=c;)o--;if(a<o){let u=r[a];r[a]=r[o],r[o]=u;for(let p=0;p<6;p++){let f=t[a*6+p];t[a*6+p]=t[o*6+p],t[o*6+p]=f}a++,o--}else return a}}function et(r,e){return e[r+15]===65535}function ct(r,e){return e[r+6]}function pt(r,e){return e[r+14]}function ft(r){return r+8}function mt(r,e){return e[r+6]}function Qc(r,e){return e[r+7]}let $c,ui,Ar,el;const Pd=Math.pow(2,32);function no(r){return"count"in r?1:1+no(r.left)+no(r.right)}function kd(r,e,t){return $c=new Float32Array(t),ui=new Uint32Array(t),Ar=new Uint16Array(t),el=new Uint8Array(t),io(r,e)}function io(r,e){const t=r/4,n=r/2,i="count"in e,s=e.boundingData;for(let a=0;a<6;a++)$c[t+a]=s[a];if(i)if(e.buffer){const a=e.buffer;el.set(new Uint8Array(a),r);for(let o=r,c=r+a.byteLength;o<c;o+=ci){const l=o/2;et(l,Ar)||(ui[o/4+6]+=t)}return r+a.byteLength}else{const a=e.offset,o=e.count;return ui[t+6]=a,Ar[n+14]=o,Ar[n+15]=Pr,r+ci}else{const a=e.left,o=e.right,c=e.splitAxis;let l;if(l=io(r+ci,a),l/4>Pd)throw new Error("MeshBVH: Cannot store child pointer greater than 32 bits.");return ui[t+6]=l/4,l=io(l,o),ui[t+7]=c,l}}function Rd(r,e){const t=(r.index?r.index.count:r.attributes.position.count)/3,n=t>2**16,i=n?4:2,s=e?new SharedArrayBuffer(t*i):new ArrayBuffer(t*i),a=n?new Uint32Array(s):new Uint16Array(s);for(let o=0,c=a.length;o<c;o++)a[o]=o;return a}function Ad(r,e,t,n,i){const{maxDepth:s,verbose:a,maxLeafTris:o,strategy:c,onProgress:l,indirect:u}=i,p=r._indirectBuffer,f=r.geometry,m=f.index?f.index.array:null,b=u?Ed:Cd,x=zn(f),g=new Float32Array(6);let v=!1;const _=new to;return eo(e,t,n,_.boundingData,g),C(_,t,n,g),_;function w(M){l&&l(M/x)}function C(M,E,P,O=null,R=0){if(!v&&R>=s&&(v=!0,a&&(console.warn(`MeshBVH: Max depth of ${s} reached when generating BVH. Consider increasing maxDepth.`),console.warn(f))),P<=o||R>=s)return w(E+P),M.offset=E,M.count=P,M;const A=Td(M.boundingData,O,e,E,P,c);if(A.axis===-1)return w(E+P),M.offset=E,M.count=P,M;const B=b(p,m,e,E,P,A);if(B===E||B===E+P)w(E+P),M.offset=E,M.count=P;else{M.splitAxis=A.axis;const z=new to,D=E,F=B-E;M.left=z,eo(e,D,F,z.boundingData,g),C(z,D,F,g,R+1);const H=new to,q=B,$=P-F;M.right=H,eo(e,q,$,H.boundingData,g),C(H,q,$,g,R+1)}return M}}function Od(r,e){const t=r.geometry;e.indirect&&(r._indirectBuffer=Rd(t,e.useSharedArrayBuffer),xd(t,e.range)&&!e.verbose&&console.warn('MeshBVH: Provided geometry contains groups or a range that do not fully span the vertex contents while using the "indirect" option. BVH may incorrectly report intersections on unrendered portions of the geometry.')),r._indirectBuffer||bd(t,e);const n=e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,i=wd(t),s=e.indirect?qc(t,e.range):Xc(t,e.range);r._roots=s.map(a=>{const o=Ad(r,i,a.offset,a.count,e),c=no(o),l=new n(ci*c);return kd(0,o,l),l})}class Yt{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(e,t){let n=1/0,i=-1/0;for(let s=0,a=e.length;s<a;s++){const o=e[s][t];n=o<n?o:n,i=o>i?o:i}this.min=n,this.max=i}setFromPoints(e,t){let n=1/0,i=-1/0;for(let s=0,a=t.length;s<a;s++){const o=t[s],c=e.dot(o);n=c<n?c:n,i=c>i?c:i}this.min=n,this.max=i}isSeparated(e){return this.min>e.max||e.min>this.max}}Yt.prototype.setFromBox=function(){const r=new W;return function(e,t){const n=t.min,i=t.max;let s=1/0,a=-1/0;for(let o=0;o<=1;o++)for(let c=0;c<=1;c++)for(let l=0;l<=1;l++){r.x=n.x*o+i.x*(1-o),r.y=n.y*c+i.y*(1-c),r.z=n.z*l+i.z*(1-l);const u=e.dot(r);s=Math.min(u,s),a=Math.max(u,a)}this.min=s,this.max=a}}();const Id=function(){const r=new W,e=new W,t=new W;return function(n,i,s){const a=n.start,o=r,c=i.start,l=e;t.subVectors(a,c),r.subVectors(n.end,n.start),e.subVectors(i.end,i.start);const u=t.dot(l),p=l.dot(o),f=l.dot(l),m=t.dot(o),b=o.dot(o)*f-p*p;let x,g;b!==0?x=(u*p-m*f)/b:x=0,g=(u+x*p)/f,s.x=x,s.y=g}}(),ro=function(){const r=new kn,e=new W,t=new W;return function(n,i,s,a){Id(n,i,r);let o=r.x,c=r.y;if(o>=0&&o<=1&&c>=0&&c<=1){n.at(o,s),i.at(c,a);return}else if(o>=0&&o<=1){c<0?i.at(0,a):i.at(1,a),n.closestPointToPoint(a,!0,s);return}else if(c>=0&&c<=1){o<0?n.at(0,s):n.at(1,s),i.closestPointToPoint(s,!0,a);return}else{let l;o<0?l=n.start:l=n.end;let u;c<0?u=i.start:u=i.end;const p=e,f=t;if(n.closestPointToPoint(u,!0,e),i.closestPointToPoint(l,!0,t),p.distanceToSquared(u)<=f.distanceToSquared(l)){s.copy(p),a.copy(u);return}else{s.copy(l),a.copy(f);return}}}}(),zd=function(){const r=new W,e=new W,t=new Qo,n=new Gt;return function(i,s){const{radius:a,center:o}=i,{a:c,b:l,c:u}=s;if(n.start=c,n.end=l,n.closestPointToPoint(o,!0,r).distanceTo(o)<=a||(n.start=c,n.end=u,n.closestPointToPoint(o,!0,r).distanceTo(o)<=a)||(n.start=l,n.end=u,n.closestPointToPoint(o,!0,r).distanceTo(o)<=a))return!0;const p=s.getPlane(t);if(Math.abs(p.distanceToPoint(o))<=a){const f=p.projectPoint(o,e);if(s.containsPoint(f))return!0}return!1}}(),Bd=1e-15;function so(r){return Math.abs(r)<Bd}class yt extends un{constructor(...e){super(...e),this.isExtendedTriangle=!0,this.satAxes=new Array(4).fill().map(()=>new W),this.satBounds=new Array(4).fill().map(()=>new Yt),this.points=[this.a,this.b,this.c],this.sphere=new $o,this.plane=new Qo,this.needsUpdate=!0}intersectsSphere(e){return zd(e,this)}update(){const e=this.a,t=this.b,n=this.c,i=this.points,s=this.satAxes,a=this.satBounds,o=s[0],c=a[0];this.getNormal(o),c.setFromPoints(o,i);const l=s[1],u=a[1];l.subVectors(e,t),u.setFromPoints(l,i);const p=s[2],f=a[2];p.subVectors(t,n),f.setFromPoints(p,i);const m=s[3],b=a[3];m.subVectors(n,e),b.setFromPoints(m,i),this.sphere.setFromPoints(this.points),this.plane.setFromNormalAndCoplanarPoint(o,e),this.needsUpdate=!1}}yt.prototype.closestPointToSegment=function(){const r=new W,e=new W,t=new Gt;return function(n,i=null,s=null){const{start:a,end:o}=n,c=this.points;let l,u=1/0;for(let p=0;p<3;p++){const f=(p+1)%3;t.start.copy(c[p]),t.end.copy(c[f]),ro(t,n,r,e),l=r.distanceToSquared(e),l<u&&(u=l,i&&i.copy(r),s&&s.copy(e))}return this.closestPointToPoint(a,r),l=a.distanceToSquared(r),l<u&&(u=l,i&&i.copy(r),s&&s.copy(a)),this.closestPointToPoint(o,r),l=o.distanceToSquared(r),l<u&&(u=l,i&&i.copy(r),s&&s.copy(o)),Math.sqrt(u)}}(),yt.prototype.intersectsTriangle=function(){const r=new yt,e=new Array(3),t=new Array(3),n=new Yt,i=new Yt,s=new W,a=new W,o=new W,c=new W,l=new W,u=new Gt,p=new Gt,f=new Gt,m=new W;function b(x,g,v){const _=x.points;let w=0,C=-1;for(let M=0;M<3;M++){const{start:E,end:P}=u;E.copy(_[M]),P.copy(_[(M+1)%3]),u.delta(a);const O=so(g.distanceToPoint(E));if(so(g.normal.dot(a))&&O){v.copy(u),w=2;break}const R=g.intersectLine(u,m);if(!R&&O&&m.copy(E),(R||O)&&!so(m.distanceTo(P))){if(w<=1)(w===1?v.start:v.end).copy(m),O&&(C=w);else if(w>=2){(C===1?v.start:v.end).copy(m),w=2;break}if(w++,w===2&&C===-1)break}}return w}return function(x,g=null,v=!1){this.needsUpdate&&this.update(),x.isExtendedTriangle?x.needsUpdate&&x.update():(r.copy(x),r.update(),x=r);const _=this.plane,w=x.plane;if(Math.abs(_.normal.dot(w.normal))>1-1e-10){const C=this.satBounds,M=this.satAxes;t[0]=x.a,t[1]=x.b,t[2]=x.c;for(let O=0;O<4;O++){const R=C[O],A=M[O];if(n.setFromPoints(A,t),R.isSeparated(n))return!1}const E=x.satBounds,P=x.satAxes;e[0]=this.a,e[1]=this.b,e[2]=this.c;for(let O=0;O<4;O++){const R=E[O],A=P[O];if(n.setFromPoints(A,e),R.isSeparated(n))return!1}for(let O=0;O<4;O++){const R=M[O];for(let A=0;A<4;A++){const B=P[A];if(s.crossVectors(R,B),n.setFromPoints(s,e),i.setFromPoints(s,t),n.isSeparated(i))return!1}}return g&&(v||console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."),g.start.set(0,0,0),g.end.set(0,0,0)),!0}else{const C=b(this,w,p);if(C===1&&x.containsPoint(p.end))return g&&(g.start.copy(p.end),g.end.copy(p.end)),!0;if(C!==2)return!1;const M=b(x,_,f);if(M===1&&this.containsPoint(f.end))return g&&(g.start.copy(f.end),g.end.copy(f.end)),!0;if(M!==2)return!1;if(p.delta(o),f.delta(c),o.dot(c)<0){let z=f.start;f.start=f.end,f.end=z}const E=p.start.dot(o),P=p.end.dot(o),O=f.start.dot(o),R=f.end.dot(o),A=P<O,B=E<R;return E!==R&&O!==P&&A===B?!1:(g&&(l.subVectors(p.start,f.start),l.dot(o)>0?g.start.copy(p.start):g.start.copy(f.start),l.subVectors(p.end,f.end),l.dot(o)<0?g.end.copy(p.end):g.end.copy(f.end)),!0)}}}(),yt.prototype.distanceToPoint=function(){const r=new W;return function(e){return this.closestPointToPoint(e,r),e.distanceTo(r)}}(),yt.prototype.distanceToTriangle=function(){const r=new W,e=new W,t=["a","b","c"],n=new Gt,i=new Gt;return function(s,a=null,o=null){const c=a||o?n:null;if(this.intersectsTriangle(s,c))return(a||o)&&(a&&c.getCenter(a),o&&c.getCenter(o)),0;let l=1/0;for(let u=0;u<3;u++){let p;const f=t[u],m=s[f];this.closestPointToPoint(m,r),p=m.distanceToSquared(r),p<l&&(l=p,a&&a.copy(r),o&&o.copy(m));const b=this[f];s.closestPointToPoint(b,r),p=b.distanceToSquared(r),p<l&&(l=p,a&&a.copy(b),o&&o.copy(r))}for(let u=0;u<3;u++){const p=t[u],f=t[(u+1)%3];n.set(this[p],this[f]);for(let m=0;m<3;m++){const b=t[m],x=t[(m+1)%3];i.set(s[b],s[x]),ro(n,i,r,e);const g=r.distanceToSquared(e);g<l&&(l=g,a&&a.copy(r),o&&o.copy(e))}}return Math.sqrt(l)}}();class Ve{constructor(e,t,n){this.isOrientedBox=!0,this.min=new W,this.max=new W,this.matrix=new Ct,this.invMatrix=new Ct,this.points=new Array(8).fill().map(()=>new W),this.satAxes=new Array(3).fill().map(()=>new W),this.satBounds=new Array(3).fill().map(()=>new Yt),this.alignedSatBounds=new Array(3).fill().map(()=>new Yt),this.needsUpdate=!1,e&&this.min.copy(e),t&&this.max.copy(t),n&&this.matrix.copy(n)}set(e,t,n){this.min.copy(e),this.max.copy(t),this.matrix.copy(n),this.needsUpdate=!0}copy(e){this.min.copy(e.min),this.max.copy(e.max),this.matrix.copy(e.matrix),this.needsUpdate=!0}}Ve.prototype.update=function(){return function(){const r=this.matrix,e=this.min,t=this.max,n=this.points;for(let c=0;c<=1;c++)for(let l=0;l<=1;l++)for(let u=0;u<=1;u++){const p=1*c|2*l|4*u,f=n[p];f.x=c?t.x:e.x,f.y=l?t.y:e.y,f.z=u?t.z:e.z,f.applyMatrix4(r)}const i=this.satBounds,s=this.satAxes,a=n[0];for(let c=0;c<3;c++){const l=s[c],u=i[c],p=1<<c,f=n[p];l.subVectors(a,f),u.setFromPoints(l,n)}const o=this.alignedSatBounds;o[0].setFromPointsField(n,"x"),o[1].setFromPointsField(n,"y"),o[2].setFromPointsField(n,"z"),this.invMatrix.copy(this.matrix).invert(),this.needsUpdate=!1}}(),Ve.prototype.intersectsBox=function(){const r=new Yt;return function(e){this.needsUpdate&&this.update();const t=e.min,n=e.max,i=this.satBounds,s=this.satAxes,a=this.alignedSatBounds;if(r.min=t.x,r.max=n.x,a[0].isSeparated(r)||(r.min=t.y,r.max=n.y,a[1].isSeparated(r))||(r.min=t.z,r.max=n.z,a[2].isSeparated(r)))return!1;for(let o=0;o<3;o++){const c=s[o],l=i[o];if(r.setFromBox(c,e),l.isSeparated(r))return!1}return!0}}(),Ve.prototype.intersectsTriangle=function(){const r=new yt,e=new Array(3),t=new Yt,n=new Yt,i=new W;return function(s){this.needsUpdate&&this.update(),s.isExtendedTriangle?s.needsUpdate&&s.update():(r.copy(s),r.update(),s=r);const a=this.satBounds,o=this.satAxes;e[0]=s.a,e[1]=s.b,e[2]=s.c;for(let p=0;p<3;p++){const f=a[p],m=o[p];if(t.setFromPoints(m,e),f.isSeparated(t))return!1}const c=s.satBounds,l=s.satAxes,u=this.points;for(let p=0;p<3;p++){const f=c[p],m=l[p];if(t.setFromPoints(m,u),f.isSeparated(t))return!1}for(let p=0;p<3;p++){const f=o[p];for(let m=0;m<4;m++){const b=l[m];if(i.crossVectors(f,b),t.setFromPoints(i,e),n.setFromPoints(i,u),t.isSeparated(n))return!1}}return!0}}(),Ve.prototype.closestPointToPoint=function(){return function(r,e){return this.needsUpdate&&this.update(),e.copy(r).applyMatrix4(this.invMatrix).clamp(this.min,this.max).applyMatrix4(this.matrix),e}}(),Ve.prototype.distanceToPoint=function(){const r=new W;return function(e){return this.closestPointToPoint(e,r),e.distanceTo(r)}}(),Ve.prototype.distanceToBox=function(){const r=["x","y","z"],e=new Array(12).fill().map(()=>new Gt),t=new Array(12).fill().map(()=>new Gt),n=new W,i=new W;return function(s,a=0,o=null,c=null){if(this.needsUpdate&&this.update(),this.intersectsBox(s))return(o||c)&&(s.getCenter(i),this.closestPointToPoint(i,n),s.closestPointToPoint(n,i),o&&o.copy(n),c&&c.copy(i)),0;const l=a*a,u=s.min,p=s.max,f=this.points;let m=1/0;for(let x=0;x<8;x++){const g=f[x];i.copy(g).clamp(u,p);const v=g.distanceToSquared(i);if(v<m&&(m=v,o&&o.copy(g),c&&c.copy(i),v<l))return Math.sqrt(v)}let b=0;for(let x=0;x<3;x++)for(let g=0;g<=1;g++)for(let v=0;v<=1;v++){const _=(x+1)%3,w=(x+2)%3,C=g<<_|v<<w,M=1<<x|g<<_|v<<w,E=f[C],P=f[M];e[b].set(E,P);const O=r[x],R=r[_],A=r[w],B=t[b],z=B.start,D=B.end;z[O]=u[O],z[R]=g?u[R]:p[R],z[A]=v?u[A]:p[R],D[O]=p[O],D[R]=g?u[R]:p[R],D[A]=v?u[A]:p[R],b++}for(let x=0;x<=1;x++)for(let g=0;g<=1;g++)for(let v=0;v<=1;v++){i.x=x?p.x:u.x,i.y=g?p.y:u.y,i.z=v?p.z:u.z,this.closestPointToPoint(i,n);const _=i.distanceToSquared(n);if(_<m&&(m=_,o&&o.copy(n),c&&c.copy(i),_<l))return Math.sqrt(_)}for(let x=0;x<12;x++){const g=e[x];for(let v=0;v<12;v++){const _=t[v];ro(g,_,n,i);const w=n.distanceToSquared(i);if(w<m&&(m=w,o&&o.copy(n),c&&c.copy(i),w<l))return Math.sqrt(w)}}return Math.sqrt(m)}}();class oo{constructor(e){this._getNewPrimitive=e,this._primitives=[]}getPrimitive(){const e=this._primitives;return e.length===0?this._getNewPrimitive():e.pop()}releasePrimitive(e){this._primitives.push(e)}}class Nd extends oo{constructor(){super(()=>new yt)}}const gt=new Nd;class Ud{constructor(){this.float32Array=null,this.uint16Array=null,this.uint32Array=null;const e=[];let t=null;this.setBuffer=n=>{t&&e.push(t),t=n,this.float32Array=new Float32Array(n),this.uint16Array=new Uint16Array(n),this.uint32Array=new Uint32Array(n)},this.clearBuffer=()=>{t=null,this.float32Array=null,this.uint16Array=null,this.uint32Array=null,e.length!==0&&this.setBuffer(e.pop())}}}const de=new Ud;let nn,Bn;const Nn=[],Or=new oo(()=>new Ot);function Dd(r,e,t,n,i,s){nn=Or.getPrimitive(),Bn=Or.getPrimitive(),Nn.push(nn,Bn),de.setBuffer(r._roots[e]);const a=ao(0,r.geometry,t,n,i,s);de.clearBuffer(),Or.releasePrimitive(nn),Or.releasePrimitive(Bn),Nn.pop(),Nn.pop();const o=Nn.length;return o>0&&(Bn=Nn[o-1],nn=Nn[o-2]),a}function ao(r,e,t,n,i=null,s=0,a=0){const{float32Array:o,uint16Array:c,uint32Array:l}=de;let u=r*2;if(et(u,c)){const p=ct(r,l),f=pt(u,c);return ve(r,o,nn),n(p,f,!1,a,s+r,nn)}else{let p=function(B){const{uint16Array:z,uint32Array:D}=de;let F=B*2;for(;!et(F,z);)B=ft(B),F=B*2;return ct(B,D)},f=function(B){const{uint16Array:z,uint32Array:D}=de;let F=B*2;for(;!et(F,z);)B=mt(B,D),F=B*2;return ct(B,D)+pt(F,z)};const m=ft(r),b=mt(r,l);let x=m,g=b,v,_,w,C;if(i&&(w=nn,C=Bn,ve(x,o,w),ve(g,o,C),v=i(w),_=i(C),_<v)){x=b,g=m;const B=v;v=_,_=B,w=C}w||(w=nn,ve(x,o,w));const M=et(x*2,c),E=t(w,M,v,a+1,s+x);let P;if(E===Ks){const B=p(x),z=f(x)-B;P=n(B,z,!0,a+1,s+x,w)}else P=E&&ao(x,e,t,n,i,s,a+1);if(P)return!0;C=Bn,ve(g,o,C);const O=et(g*2,c),R=t(C,O,_,a+1,s+g);let A;if(R===Ks){const B=p(g),z=f(g)-B;A=n(B,z,!0,a+1,s+g,C)}else A=R&&ao(g,e,t,n,i,s,a+1);return!!A}}const hi=new W,co=new W;function Ld(r,e,t={},n=0,i=1/0){const s=n*n,a=i*i;let o=1/0,c=null;if(r.shapecast({boundsTraverseOrder:u=>(hi.copy(e).clamp(u.min,u.max),hi.distanceToSquared(e)),intersectsBounds:(u,p,f)=>f<o&&f<a,intersectsTriangle:(u,p)=>{u.closestPointToPoint(e,hi);const f=e.distanceToSquared(hi);return f<o&&(co.copy(hi),o=f,c=p),f<s}}),o===1/0)return null;const l=Math.sqrt(o);return t.point?t.point.copy(co):t.point=co.clone(),t.distance=l,t.faceIndex=c,t}const Fd=parseInt(Vl)>=169,pn=new W,fn=new W,mn=new W,Ir=new kn,zr=new kn,Br=new kn,tl=new W,nl=new W,il=new W,di=new W;function Vd(r,e,t,n,i,s,a,o){let c;if(s===Fl?c=r.intersectTriangle(n,t,e,!0,i):c=r.intersectTriangle(e,t,n,s!==ds,i),c===null)return null;const l=r.origin.distanceTo(i);return l<a||l>o?null:{distance:l,point:i.clone()}}function jd(r,e,t,n,i,s,a,o,c,l,u){pn.fromBufferAttribute(e,s),fn.fromBufferAttribute(e,a),mn.fromBufferAttribute(e,o);const p=Vd(r,pn,fn,mn,di,c,l,u);if(p){const f=new W;un.getBarycoord(di,pn,fn,mn,f),n&&(Ir.fromBufferAttribute(n,s),zr.fromBufferAttribute(n,a),Br.fromBufferAttribute(n,o),p.uv=un.getInterpolation(di,pn,fn,mn,Ir,zr,Br,new kn)),i&&(Ir.fromBufferAttribute(i,s),zr.fromBufferAttribute(i,a),Br.fromBufferAttribute(i,o),p.uv1=un.getInterpolation(di,pn,fn,mn,Ir,zr,Br,new kn)),t&&(tl.fromBufferAttribute(t,s),nl.fromBufferAttribute(t,a),il.fromBufferAttribute(t,o),p.normal=un.getInterpolation(di,pn,fn,mn,tl,nl,il,new W),p.normal.dot(r.direction)>0&&p.normal.multiplyScalar(-1));const m={a:s,b:a,c:o,normal:new W,materialIndex:0};un.getNormal(pn,fn,mn,m.normal),p.face=m,p.faceIndex=s,Fd&&(p.barycoord=f)}return p}function Nr(r,e,t,n,i,s,a){const o=n*3;let c=o+0,l=o+1,u=o+2;const p=r.index;r.index&&(c=p.getX(c),l=p.getX(l),u=p.getX(u));const{position:f,normal:m,uv:b,uv1:x}=r.attributes,g=jd(t,f,m,b,x,c,l,u,e,s,a);return g?(g.faceIndex=n,i&&i.push(g),g):null}function Me(r,e,t,n){const i=r.a,s=r.b,a=r.c;let o=e,c=e+1,l=e+2;t&&(o=t.getX(o),c=t.getX(c),l=t.getX(l)),i.x=n.getX(o),i.y=n.getY(o),i.z=n.getZ(o),s.x=n.getX(c),s.y=n.getY(c),s.z=n.getZ(c),a.x=n.getX(l),a.y=n.getY(l),a.z=n.getZ(l)}function Jd(r,e,t,n,i,s,a,o){const{geometry:c,_indirectBuffer:l}=r;for(let u=n,p=n+i;u<p;u++)Nr(c,e,t,u,s,a,o)}function Gd(r,e,t,n,i,s,a){const{geometry:o,_indirectBuffer:c}=r;let l=1/0,u=null;for(let p=n,f=n+i;p<f;p++){let m;m=Nr(o,e,t,p,null,s,a),m&&m.distance<l&&(u=m,l=m.distance)}return u}function Wd(r,e,t,n,i,s,a){const{geometry:o}=t,{index:c}=o,l=o.attributes.position;for(let u=r,p=e+r;u<p;u++){let f;if(f=u,Me(a,f*3,c,l),a.needsUpdate=!0,n(a,f,i,s))return!0}return!1}function Hd(r,e=null){e&&Array.isArray(e)&&(e=new Set(e));const t=r.geometry,n=t.index?t.index.array:null,i=t.attributes.position;let s,a,o,c,l=0;const u=r._roots;for(let f=0,m=u.length;f<m;f++)s=u[f],a=new Uint32Array(s),o=new Uint16Array(s),c=new Float32Array(s),p(0,l),l+=s.byteLength;function p(f,m,b=!1){const x=f*2;if(o[x+15]===Pr){const g=a[f+6],v=o[x+14];let _=1/0,w=1/0,C=1/0,M=-1/0,E=-1/0,P=-1/0;for(let O=3*g,R=3*(g+v);O<R;O++){let A=n[O];const B=i.getX(A),z=i.getY(A),D=i.getZ(A);B<_&&(_=B),B>M&&(M=B),z<w&&(w=z),z>E&&(E=z),D<C&&(C=D),D>P&&(P=D)}return c[f+0]!==_||c[f+1]!==w||c[f+2]!==C||c[f+3]!==M||c[f+4]!==E||c[f+5]!==P?(c[f+0]=_,c[f+1]=w,c[f+2]=C,c[f+3]=M,c[f+4]=E,c[f+5]=P,!0):!1}else{const g=f+8,v=a[f+6],_=g+m,w=v+m;let C=b,M=!1,E=!1;e?C||(M=e.has(_),E=e.has(w),C=!M&&!E):(M=!0,E=!0);const P=C||M,O=C||E;let R=!1;P&&(R=p(g,m,C));let A=!1;O&&(A=p(v,m,C));const B=R||A;if(B)for(let z=0;z<3;z++){const D=g+z,F=v+z,H=c[D],q=c[D+3],$=c[F],J=c[F+3];c[f+z]=H<$?H:$,c[f+z+3]=q>J?q:J}return B}}}function rn(r,e,t,n,i){let s,a,o,c,l,u;const p=1/t.direction.x,f=1/t.direction.y,m=1/t.direction.z,b=t.origin.x,x=t.origin.y,g=t.origin.z;let v=e[r],_=e[r+3],w=e[r+1],C=e[r+3+1],M=e[r+2],E=e[r+3+2];return p>=0?(s=(v-b)*p,a=(_-b)*p):(s=(_-b)*p,a=(v-b)*p),f>=0?(o=(w-x)*f,c=(C-x)*f):(o=(C-x)*f,c=(w-x)*f),s>c||o>a||((o>s||isNaN(s))&&(s=o),(c<a||isNaN(a))&&(a=c),m>=0?(l=(M-g)*m,u=(E-g)*m):(l=(E-g)*m,u=(M-g)*m),s>u||l>a)?!1:((l>s||s!==s)&&(s=l),(u<a||a!==a)&&(a=u),s<=i&&a>=n)}function qd(r,e,t,n,i,s,a,o){const{geometry:c,_indirectBuffer:l}=r;for(let u=n,p=n+i;u<p;u++){let f=l?l[u]:u;Nr(c,e,t,f,s,a,o)}}function Xd(r,e,t,n,i,s,a){const{geometry:o,_indirectBuffer:c}=r;let l=1/0,u=null;for(let p=n,f=n+i;p<f;p++){let m;m=Nr(o,e,t,c?c[p]:p,null,s,a),m&&m.distance<l&&(u=m,l=m.distance)}return u}function Yd(r,e,t,n,i,s,a){const{geometry:o}=t,{index:c}=o,l=o.attributes.position;for(let u=r,p=e+r;u<p;u++){let f;if(f=t.resolveTriangleIndex(u),Me(a,f*3,c,l),a.needsUpdate=!0,n(a,f,i,s))return!0}return!1}function Zd(r,e,t,n,i,s,a){de.setBuffer(r._roots[e]),lo(0,r,t,n,i,s,a),de.clearBuffer()}function lo(r,e,t,n,i,s,a){const{float32Array:o,uint16Array:c,uint32Array:l}=de,u=r*2;if(et(u,c)){const p=ct(r,l),f=pt(u,c);Jd(e,t,n,p,f,i,s,a)}else{const p=ft(r);rn(p,o,n,s,a)&&lo(p,e,t,n,i,s,a);const f=mt(r,l);rn(f,o,n,s,a)&&lo(f,e,t,n,i,s,a)}}const Kd=["x","y","z"];function Qd(r,e,t,n,i,s){de.setBuffer(r._roots[e]);const a=uo(0,r,t,n,i,s);return de.clearBuffer(),a}function uo(r,e,t,n,i,s){const{float32Array:a,uint16Array:o,uint32Array:c}=de;let l=r*2;if(et(l,o)){const u=ct(r,c),p=pt(l,o);return Gd(e,t,n,u,p,i,s)}else{const u=Qc(r,c),p=Kd[u],f=n.direction[p]>=0;let m,b;f?(m=ft(r),b=mt(r,c)):(m=mt(r,c),b=ft(r));const x=rn(m,a,n,i,s)?uo(m,e,t,n,i,s):null;if(x){const v=x.point[p];if(f?v<=a[b+u]:v>=a[b+u+3])return x}const g=rn(b,a,n,i,s)?uo(b,e,t,n,i,s):null;return x&&g?x.distance<=g.distance?x:g:x||g||null}}const Ur=new Ot,Un=new yt,Dn=new yt,pi=new Ct,rl=new Ve,Dr=new Ve;function $d(r,e,t,n){de.setBuffer(r._roots[e]);const i=ho(0,r,t,n);return de.clearBuffer(),i}function ho(r,e,t,n,i=null){const{float32Array:s,uint16Array:a,uint32Array:o}=de;let c=r*2;if(i===null&&(t.boundingBox||t.computeBoundingBox(),rl.set(t.boundingBox.min,t.boundingBox.max,n),i=rl),et(c,a)){const l=e.geometry,u=l.index,p=l.attributes.position,f=t.index,m=t.attributes.position,b=ct(r,o),x=pt(c,a);if(pi.copy(n).invert(),t.boundsTree)return ve(r,s,Dr),Dr.matrix.copy(pi),Dr.needsUpdate=!0,t.boundsTree.shapecast({intersectsBounds:g=>Dr.intersectsBox(g),intersectsTriangle:g=>{g.a.applyMatrix4(n),g.b.applyMatrix4(n),g.c.applyMatrix4(n),g.needsUpdate=!0;for(let v=b*3,_=(x+b)*3;v<_;v+=3)if(Me(Dn,v,u,p),Dn.needsUpdate=!0,g.intersectsTriangle(Dn))return!0;return!1}});for(let g=b*3,v=(x+b)*3;g<v;g+=3){Me(Un,g,u,p),Un.a.applyMatrix4(pi),Un.b.applyMatrix4(pi),Un.c.applyMatrix4(pi),Un.needsUpdate=!0;for(let _=0,w=f.count;_<w;_+=3)if(Me(Dn,_,f,m),Dn.needsUpdate=!0,Un.intersectsTriangle(Dn))return!0}}else{const l=r+8,u=o[r+6];return ve(l,s,Ur),!!(i.intersectsBox(Ur)&&ho(l,e,t,n,i)||(ve(u,s,Ur),i.intersectsBox(Ur)&&ho(u,e,t,n,i)))}}const Lr=new Ct,po=new Ve,fi=new Ve,ep=new W,tp=new W,np=new W,ip=new W;function rp(r,e,t,n={},i={},s=0,a=1/0){e.boundingBox||e.computeBoundingBox(),po.set(e.boundingBox.min,e.boundingBox.max,t),po.needsUpdate=!0;const o=r.geometry,c=o.attributes.position,l=o.index,u=e.attributes.position,p=e.index,f=gt.getPrimitive(),m=gt.getPrimitive();let b=ep,x=tp,g=null,v=null;i&&(g=np,v=ip);let _=1/0,w=null,C=null;return Lr.copy(t).invert(),fi.matrix.copy(Lr),r.shapecast({boundsTraverseOrder:M=>po.distanceToBox(M),intersectsBounds:(M,E,P)=>P<_&&P<a?(E&&(fi.min.copy(M.min),fi.max.copy(M.max),fi.needsUpdate=!0),!0):!1,intersectsRange:(M,E)=>{if(e.boundsTree)return e.boundsTree.shapecast({boundsTraverseOrder:P=>fi.distanceToBox(P),intersectsBounds:(P,O,R)=>R<_&&R<a,intersectsRange:(P,O)=>{for(let R=P,A=P+O;R<A;R++){Me(m,3*R,p,u),m.a.applyMatrix4(t),m.b.applyMatrix4(t),m.c.applyMatrix4(t),m.needsUpdate=!0;for(let B=M,z=M+E;B<z;B++){Me(f,3*B,l,c),f.needsUpdate=!0;const D=f.distanceToTriangle(m,b,g);if(D<_&&(x.copy(b),v&&v.copy(g),_=D,w=B,C=R),D<s)return!0}}}});{const P=zn(e);for(let O=0,R=P;O<R;O++){Me(m,3*O,p,u),m.a.applyMatrix4(t),m.b.applyMatrix4(t),m.c.applyMatrix4(t),m.needsUpdate=!0;for(let A=M,B=M+E;A<B;A++){Me(f,3*A,l,c),f.needsUpdate=!0;const z=f.distanceToTriangle(m,b,g);if(z<_&&(x.copy(b),v&&v.copy(g),_=z,w=A,C=O),z<s)return!0}}}}}),gt.releasePrimitive(f),gt.releasePrimitive(m),_===1/0?null:(n.point?n.point.copy(x):n.point=x.clone(),n.distance=_,n.faceIndex=w,i&&(i.point?i.point.copy(v):i.point=v.clone(),i.point.applyMatrix4(Lr),x.applyMatrix4(Lr),i.distance=x.sub(i.point).length(),i.faceIndex=C),n)}function sp(r,e=null){e&&Array.isArray(e)&&(e=new Set(e));const t=r.geometry,n=t.index?t.index.array:null,i=t.attributes.position;let s,a,o,c,l=0;const u=r._roots;for(let f=0,m=u.length;f<m;f++)s=u[f],a=new Uint32Array(s),o=new Uint16Array(s),c=new Float32Array(s),p(0,l),l+=s.byteLength;function p(f,m,b=!1){const x=f*2;if(o[x+15]===Pr){const g=a[f+6],v=o[x+14];let _=1/0,w=1/0,C=1/0,M=-1/0,E=-1/0,P=-1/0;for(let O=g,R=g+v;O<R;O++){const A=3*r.resolveTriangleIndex(O);for(let B=0;B<3;B++){let z=A+B;z=n?n[z]:z;const D=i.getX(z),F=i.getY(z),H=i.getZ(z);D<_&&(_=D),D>M&&(M=D),F<w&&(w=F),F>E&&(E=F),H<C&&(C=H),H>P&&(P=H)}}return c[f+0]!==_||c[f+1]!==w||c[f+2]!==C||c[f+3]!==M||c[f+4]!==E||c[f+5]!==P?(c[f+0]=_,c[f+1]=w,c[f+2]=C,c[f+3]=M,c[f+4]=E,c[f+5]=P,!0):!1}else{const g=f+8,v=a[f+6],_=g+m,w=v+m;let C=b,M=!1,E=!1;e?C||(M=e.has(_),E=e.has(w),C=!M&&!E):(M=!0,E=!0);const P=C||M,O=C||E;let R=!1;P&&(R=p(g,m,C));let A=!1;O&&(A=p(v,m,C));const B=R||A;if(B)for(let z=0;z<3;z++){const D=g+z,F=v+z,H=c[D],q=c[D+3],$=c[F],J=c[F+3];c[f+z]=H<$?H:$,c[f+z+3]=q>J?q:J}return B}}}function op(r,e,t,n,i,s,a){de.setBuffer(r._roots[e]),fo(0,r,t,n,i,s,a),de.clearBuffer()}function fo(r,e,t,n,i,s,a){const{float32Array:o,uint16Array:c,uint32Array:l}=de,u=r*2;if(et(u,c)){const p=ct(r,l),f=pt(u,c);qd(e,t,n,p,f,i,s,a)}else{const p=ft(r);rn(p,o,n,s,a)&&fo(p,e,t,n,i,s,a);const f=mt(r,l);rn(f,o,n,s,a)&&fo(f,e,t,n,i,s,a)}}const ap=["x","y","z"];function cp(r,e,t,n,i,s){de.setBuffer(r._roots[e]);const a=mo(0,r,t,n,i,s);return de.clearBuffer(),a}function mo(r,e,t,n,i,s){const{float32Array:a,uint16Array:o,uint32Array:c}=de;let l=r*2;if(et(l,o)){const u=ct(r,c),p=pt(l,o);return Xd(e,t,n,u,p,i,s)}else{const u=Qc(r,c),p=ap[u],f=n.direction[p]>=0;let m,b;f?(m=ft(r),b=mt(r,c)):(m=mt(r,c),b=ft(r));const x=rn(m,a,n,i,s)?mo(m,e,t,n,i,s):null;if(x){const v=x.point[p];if(f?v<=a[b+u]:v>=a[b+u+3])return x}const g=rn(b,a,n,i,s)?mo(b,e,t,n,i,s):null;return x&&g?x.distance<=g.distance?x:g:x||g||null}}const Fr=new Ot,Ln=new yt,Fn=new yt,mi=new Ct,sl=new Ve,Vr=new Ve;function lp(r,e,t,n){de.setBuffer(r._roots[e]);const i=yo(0,r,t,n);return de.clearBuffer(),i}function yo(r,e,t,n,i=null){const{float32Array:s,uint16Array:a,uint32Array:o}=de;let c=r*2;if(i===null&&(t.boundingBox||t.computeBoundingBox(),sl.set(t.boundingBox.min,t.boundingBox.max,n),i=sl),et(c,a)){const l=e.geometry,u=l.index,p=l.attributes.position,f=t.index,m=t.attributes.position,b=ct(r,o),x=pt(c,a);if(mi.copy(n).invert(),t.boundsTree)return ve(r,s,Vr),Vr.matrix.copy(mi),Vr.needsUpdate=!0,t.boundsTree.shapecast({intersectsBounds:g=>Vr.intersectsBox(g),intersectsTriangle:g=>{g.a.applyMatrix4(n),g.b.applyMatrix4(n),g.c.applyMatrix4(n),g.needsUpdate=!0;for(let v=b,_=x+b;v<_;v++)if(Me(Fn,3*e.resolveTriangleIndex(v),u,p),Fn.needsUpdate=!0,g.intersectsTriangle(Fn))return!0;return!1}});for(let g=b,v=x+b;g<v;g++){const _=e.resolveTriangleIndex(g);Me(Ln,3*_,u,p),Ln.a.applyMatrix4(mi),Ln.b.applyMatrix4(mi),Ln.c.applyMatrix4(mi),Ln.needsUpdate=!0;for(let w=0,C=f.count;w<C;w+=3)if(Me(Fn,w,f,m),Fn.needsUpdate=!0,Ln.intersectsTriangle(Fn))return!0}}else{const l=r+8,u=o[r+6];return ve(l,s,Fr),!!(i.intersectsBox(Fr)&&yo(l,e,t,n,i)||(ve(u,s,Fr),i.intersectsBox(Fr)&&yo(u,e,t,n,i)))}}const jr=new Ct,go=new Ve,yi=new Ve,up=new W,hp=new W,dp=new W,pp=new W;function fp(r,e,t,n={},i={},s=0,a=1/0){e.boundingBox||e.computeBoundingBox(),go.set(e.boundingBox.min,e.boundingBox.max,t),go.needsUpdate=!0;const o=r.geometry,c=o.attributes.position,l=o.index,u=e.attributes.position,p=e.index,f=gt.getPrimitive(),m=gt.getPrimitive();let b=up,x=hp,g=null,v=null;i&&(g=dp,v=pp);let _=1/0,w=null,C=null;return jr.copy(t).invert(),yi.matrix.copy(jr),r.shapecast({boundsTraverseOrder:M=>go.distanceToBox(M),intersectsBounds:(M,E,P)=>P<_&&P<a?(E&&(yi.min.copy(M.min),yi.max.copy(M.max),yi.needsUpdate=!0),!0):!1,intersectsRange:(M,E)=>{if(e.boundsTree){const P=e.boundsTree;return P.shapecast({boundsTraverseOrder:O=>yi.distanceToBox(O),intersectsBounds:(O,R,A)=>A<_&&A<a,intersectsRange:(O,R)=>{for(let A=O,B=O+R;A<B;A++){const z=P.resolveTriangleIndex(A);Me(m,3*z,p,u),m.a.applyMatrix4(t),m.b.applyMatrix4(t),m.c.applyMatrix4(t),m.needsUpdate=!0;for(let D=M,F=M+E;D<F;D++){const H=r.resolveTriangleIndex(D);Me(f,3*H,l,c),f.needsUpdate=!0;const q=f.distanceToTriangle(m,b,g);if(q<_&&(x.copy(b),v&&v.copy(g),_=q,w=D,C=A),q<s)return!0}}}})}else{const P=zn(e);for(let O=0,R=P;O<R;O++){Me(m,3*O,p,u),m.a.applyMatrix4(t),m.b.applyMatrix4(t),m.c.applyMatrix4(t),m.needsUpdate=!0;for(let A=M,B=M+E;A<B;A++){const z=r.resolveTriangleIndex(A);Me(f,3*z,l,c),f.needsUpdate=!0;const D=f.distanceToTriangle(m,b,g);if(D<_&&(x.copy(b),v&&v.copy(g),_=D,w=A,C=O),D<s)return!0}}}}}),gt.releasePrimitive(f),gt.releasePrimitive(m),_===1/0?null:(n.point?n.point.copy(x):n.point=x.clone(),n.distance=_,n.faceIndex=w,i&&(i.point?i.point.copy(v):i.point=v.clone(),i.point.applyMatrix4(jr),x.applyMatrix4(jr),i.distance=x.sub(i.point).length(),i.faceIndex=C),n)}function mp(){return typeof SharedArrayBuffer<"u"}const gi=new de.constructor,Jr=new de.constructor,sn=new oo(()=>new Ot),Vn=new Ot,jn=new Ot,vo=new Ot,So=new Ot;let bo=!1;function yp(r,e,t,n){if(bo)throw new Error("MeshBVH: Recursive calls to bvhcast not supported.");bo=!0;const i=r._roots,s=e._roots;let a,o=0,c=0;const l=new Ct().copy(t).invert();for(let u=0,p=i.length;u<p;u++){gi.setBuffer(i[u]),c=0;const f=sn.getPrimitive();ve(0,gi.float32Array,f),f.applyMatrix4(l);for(let m=0,b=s.length;m<b&&(Jr.setBuffer(s[m]),a=kt(0,0,t,l,n,o,c,0,0,f),Jr.clearBuffer(),c+=s[m].length,!a);m++);if(sn.releasePrimitive(f),gi.clearBuffer(),o+=i[u].length,a)break}return bo=!1,a}function kt(r,e,t,n,i,s=0,a=0,o=0,c=0,l=null,u=!1){let p,f;u?(p=Jr,f=gi):(p=gi,f=Jr);const m=p.float32Array,b=p.uint32Array,x=p.uint16Array,g=f.float32Array,v=f.uint32Array,_=f.uint16Array,w=r*2,C=e*2,M=et(w,x),E=et(C,_);let P=!1;if(E&&M)u?P=i(ct(e,v),pt(e*2,_),ct(r,b),pt(r*2,x),c,a+e,o,s+r):P=i(ct(r,b),pt(r*2,x),ct(e,v),pt(e*2,_),o,s+r,c,a+e);else if(E){const O=sn.getPrimitive();ve(e,g,O),O.applyMatrix4(t);const R=ft(r),A=mt(r,b);ve(R,m,Vn),ve(A,m,jn);const B=O.intersectsBox(Vn),z=O.intersectsBox(jn);P=B&&kt(e,R,n,t,i,a,s,c,o+1,O,!u)||z&&kt(e,A,n,t,i,a,s,c,o+1,O,!u),sn.releasePrimitive(O)}else{const O=ft(e),R=mt(e,v);ve(O,g,vo),ve(R,g,So);const A=l.intersectsBox(vo),B=l.intersectsBox(So);if(A&&B)P=kt(r,O,t,n,i,s,a,o,c+1,l,u)||kt(r,R,t,n,i,s,a,o,c+1,l,u);else if(A)if(M)P=kt(r,O,t,n,i,s,a,o,c+1,l,u);else{const z=sn.getPrimitive();z.copy(vo).applyMatrix4(t);const D=ft(r),F=mt(r,b);ve(D,m,Vn),ve(F,m,jn);const H=z.intersectsBox(Vn),q=z.intersectsBox(jn);P=H&&kt(O,D,n,t,i,a,s,c,o+1,z,!u)||q&&kt(O,F,n,t,i,a,s,c,o+1,z,!u),sn.releasePrimitive(z)}else if(B)if(M)P=kt(r,R,t,n,i,s,a,o,c+1,l,u);else{const z=sn.getPrimitive();z.copy(So).applyMatrix4(t);const D=ft(r),F=mt(r,b);ve(D,m,Vn),ve(F,m,jn);const H=z.intersectsBox(Vn),q=z.intersectsBox(jn);P=H&&kt(R,D,n,t,i,a,s,c,o+1,z,!u)||q&&kt(R,F,n,t,i,a,s,c,o+1,z,!u),sn.releasePrimitive(z)}}return P}const Gr=new Ve,ol=new Ot,gp={strategy:Zs,maxDepth:40,maxLeafTris:10,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,indirect:!1,verbose:!0,range:null};class xi{static serialize(e,t={}){t={cloneBuffers:!0,...t};const n=e.geometry,i=e._roots,s=e._indirectBuffer,a=n.getIndex();let o;return t.cloneBuffers?o={roots:i.map(c=>c.slice()),index:a?a.array.slice():null,indirectBuffer:s?s.slice():null}:o={roots:i,index:a?a.array:null,indirectBuffer:s},o}static deserialize(e,t,n={}){n={setIndex:!0,indirect:!!e.indirectBuffer,...n};const{index:i,roots:s,indirectBuffer:a}=e,o=new xi(t,{...n,[$s]:!0});if(o._roots=s,o._indirectBuffer=a||null,n.setIndex){const c=t.getIndex();if(c===null){const l=new ot(e.index,1,!1);t.setIndex(l)}else c.array!==i&&(c.array.set(i),c.needsUpdate=!0)}return o}get indirect(){return!!this._indirectBuffer}constructor(e,t={}){if(e.isBufferGeometry){if(e.index&&e.index.isInterleavedBufferAttribute)throw new Error("MeshBVH: InterleavedBufferAttribute is not supported for the index attribute.")}else throw new Error("MeshBVH: Only BufferGeometries are supported.");if(t=Object.assign({...gp,[$s]:!1},t),t.useSharedArrayBuffer&&!mp())throw new Error("MeshBVH: SharedArrayBuffer is not available.");this.geometry=e,this._roots=null,this._indirectBuffer=null,t[$s]||(Od(this,t),!e.boundingBox&&t.setBoundingBox&&(e.boundingBox=this.getBoundingBox(new Ot))),this.resolveTriangleIndex=t.indirect?n=>this._indirectBuffer[n]:n=>n}refit(e=null){return(this.indirect?sp:Hd)(this,e)}traverse(e,t=0){const n=this._roots[t],i=new Uint32Array(n),s=new Uint16Array(n);a(0);function a(o,c=0){const l=o*2,u=s[l+15]===Pr;if(u){const p=i[o+6],f=s[l+14];e(c,u,new Float32Array(n,o*4,6),p,f)}else{const p=o+ci/4,f=i[o+6],m=i[o+7];e(c,u,new Float32Array(n,o*4,6),m)||(a(p,c+1),a(f,c+1))}}}raycast(e,t=ea,n=0,i=1/0){const s=this._roots,a=this.geometry,o=[],c=t.isMaterial,l=Array.isArray(t),u=a.groups,p=c?t.side:t,f=this.indirect?op:Zd;for(let m=0,b=s.length;m<b;m++){const x=l?t[u[m].materialIndex].side:p,g=o.length;if(f(this,m,x,e,o,n,i),l){const v=u[m].materialIndex;for(let _=g,w=o.length;_<w;_++)o[_].face.materialIndex=v}}return o}raycastFirst(e,t=ea,n=0,i=1/0){const s=this._roots,a=this.geometry,o=t.isMaterial,c=Array.isArray(t);let l=null;const u=a.groups,p=o?t.side:t,f=this.indirect?cp:Qd;for(let m=0,b=s.length;m<b;m++){const x=c?t[u[m].materialIndex].side:p,g=f(this,m,x,e,n,i);g!=null&&(l==null||g.distance<l.distance)&&(l=g,c&&(g.face.materialIndex=u[m].materialIndex))}return l}intersectsGeometry(e,t){let n=!1;const i=this._roots,s=this.indirect?lp:$d;for(let a=0,o=i.length;a<o&&(n=s(this,a,e,t),!n);a++);return n}shapecast(e){const t=gt.getPrimitive(),n=this.indirect?Yd:Wd;let{boundsTraverseOrder:i,intersectsBounds:s,intersectsRange:a,intersectsTriangle:o}=e;if(a&&o){const p=a;a=(f,m,b,x,g)=>p(f,m,b,x,g)?!0:n(f,m,this,o,b,x,t)}else a||(o?a=(p,f,m,b)=>n(p,f,this,o,m,b,t):a=(p,f,m)=>m);let c=!1,l=0;const u=this._roots;for(let p=0,f=u.length;p<f;p++){const m=u[p];if(c=Dd(this,p,s,a,i,l),c)break;l+=m.byteLength}return gt.releasePrimitive(t),c}bvhcast(e,t,n){let{intersectsRanges:i,intersectsTriangles:s}=n;const a=gt.getPrimitive(),o=this.geometry.index,c=this.geometry.attributes.position,l=this.indirect?b=>{const x=this.resolveTriangleIndex(b);Me(a,x*3,o,c)}:b=>{Me(a,b*3,o,c)},u=gt.getPrimitive(),p=e.geometry.index,f=e.geometry.attributes.position,m=e.indirect?b=>{const x=e.resolveTriangleIndex(b);Me(u,x*3,p,f)}:b=>{Me(u,b*3,p,f)};if(s){const b=(x,g,v,_,w,C,M,E)=>{for(let P=v,O=v+_;P<O;P++){m(P),u.a.applyMatrix4(t),u.b.applyMatrix4(t),u.c.applyMatrix4(t),u.needsUpdate=!0;for(let R=x,A=x+g;R<A;R++)if(l(R),a.needsUpdate=!0,s(a,u,R,P,w,C,M,E))return!0}return!1};if(i){const x=i;i=function(g,v,_,w,C,M,E,P){return x(g,v,_,w,C,M,E,P)?!0:b(g,v,_,w,C,M,E,P)}}else i=b}return yp(this,e,t,i)}intersectsBox(e,t){return Gr.set(e.min,e.max,t),Gr.needsUpdate=!0,this.shapecast({intersectsBounds:n=>Gr.intersectsBox(n),intersectsTriangle:n=>Gr.intersectsTriangle(n)})}intersectsSphere(e){return this.shapecast({intersectsBounds:t=>e.intersectsBox(t),intersectsTriangle:t=>t.intersectsSphere(e)})}closestPointToGeometry(e,t,n={},i={},s=0,a=1/0){return(this.indirect?fp:rp)(this,e,t,n,i,s,a)}closestPointToPoint(e,t={},n=0,i=1/0){return Ld(this,e,t,n,i)}getBoundingBox(e){return e.makeEmpty(),this._roots.forEach(t=>{ve(0,new Float32Array(t),ol),e.union(ol)}),e}}function al(r,e,t){return r===null?null:(r.point.applyMatrix4(e.matrixWorld),r.distance=r.point.distanceTo(t.ray.origin),r.object=e,r)}const Wr=new Jl,cl=new W,ll=new Ct,vp=fs.prototype.raycast,Sp=jl.prototype.raycast,ul=new W,Ue=new fs,Hr=[];function bp(r,e){this.isBatchedMesh?xp.call(this,r,e):wp.call(this,r,e)}function xp(r,e){if(this.boundsTrees){const t=this.boundsTrees,n=this._drawInfo||this._instanceInfo,i=this._drawRanges||this._geometryInfo,s=this.matrixWorld;Ue.material=this.material,Ue.geometry=this.geometry;const a=Ue.geometry.boundsTree,o=Ue.geometry.drawRange;Ue.geometry.boundingSphere===null&&(Ue.geometry.boundingSphere=new $o);for(let c=0,l=n.length;c<l;c++){if(!this.getVisibleAt(c))continue;const u=n[c].geometryIndex;if(Ue.geometry.boundsTree=t[u],this.getMatrixAt(c,Ue.matrixWorld).premultiply(s),!Ue.geometry.boundsTree){this.getBoundingBoxAt(u,Ue.geometry.boundingBox),this.getBoundingSphereAt(u,Ue.geometry.boundingSphere);const p=i[u];Ue.geometry.setDrawRange(p.start,p.count)}Ue.raycast(r,Hr);for(let p=0,f=Hr.length;p<f;p++){const m=Hr[p];m.object=this,m.batchId=c,e.push(m)}Hr.length=0}Ue.geometry.boundsTree=a,Ue.geometry.drawRange=o,Ue.material=null,Ue.geometry=null}else Sp.call(this,r,e)}function wp(r,e){if(this.geometry.boundsTree){if(this.material===void 0)return;ll.copy(this.matrixWorld).invert(),Wr.copy(r.ray).applyMatrix4(ll),ul.setFromMatrixScale(this.matrixWorld),cl.copy(Wr.direction).multiply(ul);const t=cl.length(),n=r.near/t,i=r.far/t,s=this.geometry.boundsTree;if(r.firstHitOnly===!0){const a=al(s.raycastFirst(Wr,this.material,n,i),this,r);a&&e.push(a)}else{const a=s.raycast(Wr,this.material,n,i);for(let o=0,c=a.length;o<c;o++){const l=al(a[o],this,r);l&&e.push(l)}}}else vp.call(this,r,e)}function _p(r={}){return this.boundsTree=new xi(this,r),this.boundsTree}const yn=new W,gn=new W,vn=new W,hl=new ms,qr=new W,xo=new W,dl=new ms,pl=new ms,Xr=new Ct,fl=new Ct;function vi(r,e){if(!r&&!e)return;const t=r.count===e.count,n=r.normalized===e.normalized,i=r.array.constructor===e.array.constructor,s=r.itemSize===e.itemSize;if(!t||!n||!i||!s)throw new Error}function Si(r,e=null){const t=r.array.constructor,n=r.normalized,i=r.itemSize,s=e===null?r.count:e;return new ot(new t(i*s),i,n)}function ml(r,e,t=0){if(r.isInterleavedBufferAttribute){const n=r.itemSize;for(let i=0,s=r.count;i<s;i++){const a=i+t;e.setX(a,r.getX(i)),n>=2&&e.setY(a,r.getY(i)),n>=3&&e.setZ(a,r.getZ(i)),n>=4&&e.setW(a,r.getW(i))}}else{const n=e.array,i=n.constructor,s=n.BYTES_PER_ELEMENT*r.itemSize*t;new i(n.buffer,s,r.array.length).set(r.array)}}function Tp(r,e,t){const n=r.elements,i=e.elements;for(let s=0,a=i.length;s<a;s++)n[s]+=i[s]*t}function yl(r,e,t){const n=r.skeleton,i=r.geometry,s=n.bones,a=n.boneInverses;dl.fromBufferAttribute(i.attributes.skinIndex,e),pl.fromBufferAttribute(i.attributes.skinWeight,e),Xr.elements.fill(0);for(let o=0;o<4;o++){const c=pl.getComponent(o);if(c!==0){const l=dl.getComponent(o);fl.multiplyMatrices(s[l].matrixWorld,a[l]),Tp(Xr,fl,c)}}return Xr.multiply(r.bindMatrix).premultiply(r.bindMatrixInverse),t.transformDirection(Xr),t}function wo(r,e,t,n,i){qr.set(0,0,0);for(let s=0,a=r.length;s<a;s++){const o=e[s],c=r[s];o!==0&&(xo.fromBufferAttribute(c,n),t?qr.addScaledVector(xo,o):qr.addScaledVector(xo.sub(i),o))}i.add(qr)}function Mp(r,e={useGroups:!1,updateIndex:!1,skipAttributes:[]},t=new Yn){const n=r[0].index!==null,{useGroups:i=!1,updateIndex:s=!1,skipAttributes:a=[]}=e,o=new Set(Object.keys(r[0].attributes)),c={};let l=0;t.clearGroups();for(let u=0;u<r.length;++u){const p=r[u];let f=0;if(n!==(p.index!==null))throw new Error("StaticGeometryGenerator: All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them.");for(const m in p.attributes){if(!o.has(m))throw new Error('StaticGeometryGenerator: All geometries must have compatible attributes; make sure "'+m+'" attribute exists among all geometries, or in none of them.');c[m]===void 0&&(c[m]=[]),c[m].push(p.attributes[m]),f++}if(f!==o.size)throw new Error("StaticGeometryGenerator: Make sure all geometries have the same number of attributes.");if(i){let m;if(n)m=p.index.count;else if(p.attributes.position!==void 0)m=p.attributes.position.count;else throw new Error("StaticGeometryGenerator: The geometry must have either an index or a position attribute");t.addGroup(l,m,u),l+=m}}if(n){let u=!1;if(!t.index){let p=0;for(let f=0;f<r.length;++f)p+=r[f].index.count;t.setIndex(new ot(new Uint32Array(p),1,!1)),u=!0}if(s||u){const p=t.index;let f=0,m=0;for(let b=0;b<r.length;++b){const x=r[b],g=x.index;if(a[b]!==!0)for(let v=0;v<g.count;++v)p.setX(f,g.getX(v)+m),f++;m+=x.attributes.position.count}}}for(const u in c){const p=c[u];if(!(u in t.attributes)){let b=0;for(const x in p)b+=p[x].count;t.setAttribute(u,Si(c[u][0],b))}const f=t.attributes[u];let m=0;for(let b=0,x=p.length;b<x;b++){const g=p[b];a[b]!==!0&&ml(g,f,m),m+=g.count}}return t}function Cp(r,e){if(r===null||e===null)return r===e;if(r.length!==e.length)return!1;for(let t=0,n=r.length;t<n;t++)if(r[t]!==e[t])return!1;return!0}function Ep(r){const{index:e,attributes:t}=r;if(e)for(let n=0,i=e.count;n<i;n+=3){const s=e.getX(n),a=e.getX(n+2);e.setX(n,a),e.setX(n+2,s)}else for(const n in t){const i=t[n],s=i.itemSize;for(let a=0,o=i.count;a<o;a+=3)for(let c=0;c<s;c++){const l=i.getComponent(a,c),u=i.getComponent(a+2,c);i.setComponent(a,c,u),i.setComponent(a+2,c,l)}}return r}class Pp{constructor(e){this.matrixWorld=new Ct,this.geometryHash=null,this.boneMatrices=null,this.primitiveCount=-1,this.mesh=e,this.update()}update(){const e=this.mesh,t=e.geometry,n=e.skeleton,i=(t.index?t.index.count:t.attributes.position.count)/3;if(this.matrixWorld.copy(e.matrixWorld),this.geometryHash=t.attributes.position.version,this.primitiveCount=i,n){n.boneTexture||n.computeBoneTexture(),n.update();const s=n.boneMatrices;!this.boneMatrices||this.boneMatrices.length!==s.length?this.boneMatrices=s.slice():this.boneMatrices.set(s)}else this.boneMatrices=null}didChange(){const e=this.mesh,t=e.geometry,n=(t.index?t.index.count:t.attributes.position.count)/3;return!(this.matrixWorld.equals(e.matrixWorld)&&this.geometryHash===t.attributes.position.version&&Cp(e.skeleton&&e.skeleton.boneMatrices||null,this.boneMatrices)&&this.primitiveCount===n)}}class kp{constructor(e){Array.isArray(e)||(e=[e]);const t=[];e.forEach(n=>{n.traverseVisible(i=>{i.isMesh&&t.push(i)})}),this.meshes=t,this.useGroups=!0,this.applyWorldTransforms=!0,this.attributes=["position","normal","color","tangent","uv","uv2"],this._intermediateGeometry=new Array(t.length).fill().map(()=>new Yn),this._diffMap=new WeakMap}getMaterials(){const e=[];return this.meshes.forEach(t=>{Array.isArray(t.material)?e.push(...t.material):e.push(t.material)}),e}generate(e=new Yn){let t=[];const{meshes:n,useGroups:i,_intermediateGeometry:s,_diffMap:a}=this;for(let o=0,c=n.length;o<c;o++){const l=n[o],u=s[o],p=a.get(l);!p||p.didChange(l)?(this._convertToStaticGeometry(l,u),t.push(!1),p?p.update():a.set(l,new Pp(l))):t.push(!0)}if(s.length===0){e.setIndex(null);const o=e.attributes;for(const c in o)e.deleteAttribute(c);for(const c in this.attributes)e.setAttribute(this.attributes[c],new ot(new Float32Array(0),4,!1))}else Mp(s,{useGroups:i,skipAttributes:t},e);for(const o in e.attributes)e.attributes[o].needsUpdate=!0;return e}_convertToStaticGeometry(e,t=new Yn){const n=e.geometry,i=this.applyWorldTransforms,s=this.attributes.includes("normal"),a=this.attributes.includes("tangent"),o=n.attributes,c=t.attributes;!t.index&&n.index&&(t.index=n.index.clone()),c.position||t.setAttribute("position",Si(o.position)),s&&!c.normal&&o.normal&&t.setAttribute("normal",Si(o.normal)),a&&!c.tangent&&o.tangent&&t.setAttribute("tangent",Si(o.tangent)),vi(n.index,t.index),vi(o.position,c.position),s&&vi(o.normal,c.normal),a&&vi(o.tangent,c.tangent);const l=o.position,u=s?o.normal:null,p=a?o.tangent:null,f=n.morphAttributes.position,m=n.morphAttributes.normal,b=n.morphAttributes.tangent,x=n.morphTargetsRelative,g=e.morphTargetInfluences,v=new Gl;v.getNormalMatrix(e.matrixWorld),n.index&&t.index.array.set(n.index.array);for(let _=0,w=o.position.count;_<w;_++)yn.fromBufferAttribute(l,_),u&&gn.fromBufferAttribute(u,_),p&&(hl.fromBufferAttribute(p,_),vn.fromBufferAttribute(p,_)),g&&(f&&wo(f,g,x,_,yn),m&&wo(m,g,x,_,gn),b&&wo(b,g,x,_,vn)),e.isSkinnedMesh&&(e.applyBoneTransform(_,yn),u&&yl(e,_,gn),p&&yl(e,_,vn)),i&&yn.applyMatrix4(e.matrixWorld),c.position.setXYZ(_,yn.x,yn.y,yn.z),u&&(i&&gn.applyNormalMatrix(v),c.normal.setXYZ(_,gn.x,gn.y,gn.z)),p&&(i&&vn.transformDirection(e.matrixWorld),c.tangent.setXYZW(_,vn.x,vn.y,vn.z,hl.w));for(const _ in this.attributes){const w=this.attributes[_];w==="position"||w==="tangent"||w==="normal"||!(w in o)||(c[w]||t.setAttribute(w,Si(o[w])),vi(o[w],c[w]),ml(o[w],c[w]))}return e.matrixWorld.determinant()<0&&Ep(t),t}}const Rp=Object.freeze(Object.defineProperty({__proto__:null,AVERAGE:Gc,CENTER:Zs,CONTAINED:Ks,ExtendedTriangle:yt,MeshBVH:xi,OrientedBox:Ve,SAH:Wc,StaticGeometryGenerator:kp,acceleratedRaycast:bp,computeBoundsTree:_p},Symbol.toStringTag,{value:"Module"}));class Ap{constructor(e){this.name="WorkerBase",this.running=!1,this.worker=e,this.worker.onerror=t=>{throw t.message?new Error(`${this.name}: Could not create Web Worker with error "${t.message}"`):new Error(`${this.name}: Could not create Web Worker.`)}}runTask(){}generate(...e){if(this.running)throw new Error("GenerateMeshBVHWorker: Already running job.");if(this.worker===null)throw new Error("GenerateMeshBVHWorker: Worker has been disposed.");this.running=!0;const t=this.runTask(this.worker,...e);return t.finally(()=>{this.running=!1}),t}dispose(){this.worker.terminate(),this.worker=null}}const vt={node:"node",material:"material",camera:"camera",light:"light"},Sn="KHR_animation_pointer",Op={CUBICSPLINE:void 0,LINEAR:ta,STEP:Hl};class Ip{constructor(e){this.name=Sn,this.parser=e,this.animationPointerResolver=null}setAnimationPointerResolver(e){return this.animationPointerResolver=e,this}loadAnimationTargetFromChannel(e){const t=e.target,n=t.node!==void 0?t.node:t.id;return this.parser.getDependency("node",n)}loadAnimationTargetFromChannelWithAnimationPointer(e){Bp();const t=e.target,n=t.extensions&&t.extensions[Sn]&&t.path&&t.path==="pointer";if(!n)return null;let i,s=vt.node,a;if(n){const c=t.extensions[Sn];let l=c.pointer;if(!l){console.warn("Invalid path",c,t);return}if(l.startsWith("/materials/")?s=vt.material:l.startsWith("/extensions/KHR_lights_punctual/lights/")?s=vt.light:l.startsWith("/cameras/")&&(s=vt.camera),a=this._tryResolveTargetId(l,s),a===null||isNaN(a)){console.warn("Failed resolving animation node id: "+a,l);return}switch(s){case vt.material:const u=("/materials/"+a.toString()+"/").length,p=l.substring(0,u);switch(i=l.substring(u),i){case"pbrMetallicRoughness/baseColorFactor":i="color";break;case"pbrMetallicRoughness/roughnessFactor":i="roughness";break;case"pbrMetallicRoughness/metallicFactor":i="metalness";break;case"emissiveFactor":i="emissive";break;case"alphaCutoff":i="alphaTest";break;case"occlusionTexture/strength":i="aoMapIntensity";break;case"normalTexture/scale":i="normalScale";break;case"pbrMetallicRoughness/baseColorTexture/extensions/KHR_texture_transform/scale":i="map/repeat";break;case"pbrMetallicRoughness/baseColorTexture/extensions/KHR_texture_transform/offset":i="map/offset";break;case"emissiveTexture/extensions/KHR_texture_transform/scale":i="emissiveMap/repeat";break;case"emissiveTexture/extensions/KHR_texture_transform/offset":i="emissiveMap/offset";break;case"extensions/KHR_materials_emissive_strength/emissiveStrength":i="emissiveIntensity";break;case"extensions/KHR_materials_transmission/transmissionFactor":i="transmission";break;case"extensions/KHR_materials_ior/ior":i="ior";break;case"extensions/KHR_materials_volume/thicknessFactor":i="thickness";break;case"extensions/KHR_materials_volume/attenuationColor":i="attenuationColor";break;case"extensions/KHR_materials_volume/attenuationDistance":i="attenuationDistance";break;case"extensions/KHR_materials_iridescence/iridescenceFactor":i="iridescence";break;case"extensions/KHR_materials_iridescence/iridescenceIor":i="iridescenceIOR";break;case"extensions/KHR_materials_iridescence/iridescenceThicknessMinimum":i="iridescenceThicknessRange[0]";break;case"extensions/KHR_materials_iridescence/iridescenceThicknessMaximum":i="iridescenceThicknessRange[1]";break;case"extensions/KHR_materials_clearcoat/clearcoatFactor":i="clearcoat";break;case"extensions/KHR_materials_clearcoat/clearcoatRoughnessFactor":i="clearcoatRoughness";break;case"extensions/KHR_materials_sheen/sheenColorFactor":i="sheenColor";break;case"extensions/KHR_materials_sheen/sheenRoughnessFactor":i="sheenRoughness";break;case"extensions/KHR_materials_specular/specularFactor":i="specularIntensity";break;case"extensions/KHR_materials_specular/specularColorFactor":i="specularColor";break}l=p+i;break;case vt.node:const f=("/nodes/"+a.toString()+"/").length,m=l.substring(0,f);switch(i=l.substring(f),i){case"translation":i="position";break;case"rotation":i="quaternion";break;case"scale":i="scale";break;case"weights":i="morphTargetInfluences";break;case"extensions/KHR_node_visibility/visible":i="visible";break}l=m+i;break;case vt.light:const b=("/extensions/KHR_lights_punctual/lights/"+a.toString()+"/").length;switch(i=l.substring(b),i){case"color":break;case"intensity":break;case"spot/innerConeAngle":i="penumbra";break;case"spot/outerConeAngle":i="angle";break;case"range":i="distance";break}l="/lights/"+a.toString()+"/"+i;break;case vt.camera:const x=("/cameras/"+a.toString()+"/").length,g=l.substring(0,x);switch(i=l.substring(x),i){case"perspective/yfov":i="fov";break;case"perspective/znear":case"orthographic/znear":i="near";break;case"perspective/zfar":case"orthographic/zfar":i="far";break;case"perspective/aspect":i="aspect";break;case"orthographic/xmag":i="zoom";break;case"orthographic/ymag":i="zoom";break}l=g+i;break}this.animationPointerResolver?.resolvePath&&(l=this.animationPointerResolver.resolvePath(l)),t.extensions[Sn].pointer=l}if(a==null||isNaN(a)){console.warn("Failed resolving animation node id: "+a,t);return}let o;return s===vt.node?o=this.parser.getDependency("node",a):s===vt.material?o=this.parser.getDependency("material",a):s===vt.light?o=this.parser.getDependency("light",a):s===vt.camera?o=this.parser.getDependency("camera",a):console.error("Unhandled type",s),o}createAnimationTracksWithAnimationPointer(e,t,n,i,s){if(!(s.extensions&&s.extensions[Sn]&&s.path&&s.path==="pointer"))return null;let a=s.extensions[Sn].pointer;if(!a)return null;const o=[];a=a.replaceAll("/",".");const c=a.split(".");var l=e.name!==void 0&&e.name!==null?e.name:e.uuid;if(c[2]=l,c[3]==="morphTargetInfluences"&&e.type==="Group"){for(const f of e.children)f instanceof Wl&&f.morphTargetInfluences&&(c[3]=f.name,c[4]="morphTargetInfluences",p(this.parser));return o}p(this.parser);function u(f,m){try{const b=m.split(".").filter(Boolean),x=b[b.length-1].replace(/\[.*\]$/,"");return x in f?typeof f[x]=="boolean":!1}catch{return!1}}function p(f){a=c.join(".");let m,b=!1;switch(n.itemSize){case 1:Object.prototype.toString.call(n.array)==="[object Uint8Array]"&&u(e,a)?(m=Kl,b=!0):m=Ql;break;case 2:case 3:m=Zl;break;case 4:a.endsWith(".quaternion")?m=Xl:m=Yl;break}if(!m){console.warn("Unsupported output accessor format",n);return}const x=i.interpolation!==void 0?Op[i.interpolation]:ta;let g=f._getArrayFromAccessor(n);a.endsWith(".fov")&&(g=g.map(_=>_/Math.PI*180)),b&&(g=g.map(_=>_>0));const v=new m(a,t.array,g,x);if(x==="CUBICSPLINE"&&f._createCubicSplineTrackInterpolant(v),o.push(v),a&&n.itemSize===4&&a.startsWith(".materials.")&&a.endsWith(".color")){const _=new Float32Array(g.length/4);for(let C=0,M=g.length/4;C<M;C+=1)_[C]=g[C*4+3];const w=new m(a.replace(".color",".opacity"),t.array,_,x);x==="CUBICSPLINE"&&f._createCubicSplineTrackInterpolant(v),o.push(w)}}return o}_tryResolveTargetId(e,t){let n="";return t==="node"?n=e.substring(7):t==="material"?n=e.substring(11):t==="light"?n=e.substring(39):t==="camera"&&(n=e.substring(9)),n=n.substring(0,n.indexOf("/")),Number.parseInt(n)}loadAnimation(e){const t=this,n=this.parser.json,i=this.parser,s=n.animations[e],a=s.name?s.name:"animation_"+e,o=[],c=[],l=[],u=[],p=[];for(let f=0,m=s.channels.length;f<m;f++){const b=s.channels[f],x=s.samplers[b.sampler],g=b.target,v=s.parameters!==void 0?s.parameters[x.input]:x.input,_=s.parameters!==void 0?s.parameters[x.output]:x.output;let w=t.loadAnimationTargetFromChannelWithAnimationPointer(b);w||(w=t.loadAnimationTargetFromChannel(b)),o.push(w),c.push(i.getDependency("accessor",v)),l.push(i.getDependency("accessor",_)),u.push(x),p.push(g)}return Promise.all([Promise.all(o),Promise.all(c),Promise.all(l),Promise.all(u),Promise.all(p)]).then(function(f){const m=f[0],b=f[1],x=f[2],g=f[3],v=f[4],_=[];for(let w=0,C=m.length;w<C;w++){const M=m[w],E=b[w],P=x[w],O=g[w],R=v[w];if(M===void 0)continue;M.updateMatrix&&(M.updateMatrix(),M.matrixAutoUpdate=!0);let A=t.createAnimationTracksWithAnimationPointer(M,E,P,O,R);if(A||(A=i._createAnimationTracks(M,E,P,O,R)),A)for(let B=0;B<A.length;B++)_.push(A[B])}return new ql(a,void 0,_)})}}let gl=!1,zp=null;function Bp(){if(gl)return;gl=!0;const r=zp||=na.findNode;na.findNode=function(e,t){if(!t)return r(e,t);if(t.startsWith(".materials.")){const n=t.substring(11).substring(t.indexOf(".")),i=n.indexOf("."),s=i<0?n:n.substring(0,i);let a=null;return e.traverse(o=>{a!==null||o.type!=="Mesh"&&o.type!=="SkinnedMesh"||o.material&&(o.material.uuid===s||o.material.name===s)&&(a=o.material,a!==null&&(n.endsWith(".map")?a=a.map:n.endsWith(".emissiveMap")&&(a=a.emissiveMap)))}),a}else if(t.startsWith(".nodes.")||t.startsWith(".lights.")||t.startsWith(".cameras.")){const n=t.split(".");let i;for(let s=1;s<n.length;s++){const a=n[s];if(a.length==36)i=e.getObjectByProperty("uuid",a);else if(i&&i[a]){const o=Number.parseInt(a);let c=a;o>=0&&(c=o),i=i[c]}else{const o=e.getObjectByName(a);o&&(i=o)}}if(!i){const s=r(e,n[2]);return s||console.warn(Sn+": Property binding not found",t,e,e.name,n),s}return i}return r(e,t)}}const Np=Object.freeze(Object.defineProperty({__proto__:null,GLTFAnimationPointerExtension:Ip},Symbol.toStringTag,{value:"Module"}));export{bc as $70d766613f57b014$export$2e2bcd8739ae039,cd as BatchedParticleRenderer,_o as Builder,bi as ByteBuffer,xn as ConstantColor,ne as ConstantValue,Rt as Matrix4,xi as MeshBVH,su as MotionController,Qr as ParticleSystem,V as RenderMode,ra as SIZE_PREFIX_LENGTH,Tr as TrailParticle,tt as Vector4,Ap as WorkerBase,Uu as bundler,ud as createNoise4D,eu as fetchProfile,yd as index,Rp as index$1,Np as index$2,$u as md5,Xu as v5};
|