@needle-tools/engine 4.17.0-alpha.1 → 4.17.0-alpha.2
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/dist/{needle-engine.bundle-C_75Dogj.js → needle-engine.bundle-CJwjIrR6.js} +5626 -5626
- package/dist/{needle-engine.bundle-D-7RuvsA.min.js → needle-engine.bundle-CtpBqMQp.min.js} +120 -120
- package/dist/{needle-engine.bundle-B6V00PAM.umd.cjs → needle-engine.bundle-D2dj69wb.umd.cjs} +110 -110
- 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/{vendor-CipoooTV.umd.cjs → vendor-C1ziZ1Wa.umd.cjs} +1 -1
- package/dist/{vendor-CQMI3jTS.js → vendor-DAjEh81o.js} +11 -2
- package/dist/{vendor-BPp9F5vR.min.js → vendor-oBh9SadS.min.js} +1 -1
- package/lib/engine/engine_utils_format.js +36 -18
- package/lib/engine/engine_utils_format.js.map +1 -1
- package/lib/engine/physics/workers/mesh-bvh/GenerateMeshBVHWorker.js +7 -7
- package/lib/engine/physics/workers/mesh-bvh/GenerateMeshBVHWorker.js.map +1 -1
- package/lib/engine/webcomponents/needle-engine.js +1 -3
- package/lib/engine/webcomponents/needle-engine.js.map +1 -1
- package/package.json +2 -2
- package/plugins/vite/alias.js +9 -4
- package/plugins/vite/dependencies.js +9 -0
- package/plugins/vite/logger.client.js +0 -1
- package/plugins/vite/transform.js +1 -1
- package/src/engine/engine_utils_format.ts +18 -18
- package/src/engine/physics/workers/mesh-bvh/GenerateMeshBVHWorker.js +8 -7
- package/src/engine/webcomponents/needle-engine.ts +1 -3
|
@@ -1113,4 +1113,4 @@ void main() {
|
|
|
1113
1113
|
vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );
|
|
1114
1114
|
|
|
1115
1115
|
#include <fog_vertex>
|
|
1116
|
-
}`;class _d extends Kc{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 ti,this.indexBuffer=new dt(new Uint32Array(this.maxParticles*6),1),this.indexBuffer.setUsage(et),this.geometry.setIndex(this.indexBuffer),this.positionBuffer=new dt(new Float32Array(this.maxParticles*6),3),this.positionBuffer.setUsage(et),this.geometry.setAttribute("position",this.positionBuffer),this.previousBuffer=new dt(new Float32Array(this.maxParticles*6),3),this.previousBuffer.setUsage(et),this.geometry.setAttribute("previous",this.previousBuffer),this.nextBuffer=new dt(new Float32Array(this.maxParticles*6),3),this.nextBuffer.setUsage(et),this.geometry.setAttribute("next",this.nextBuffer),this.widthBuffer=new dt(new Float32Array(this.maxParticles*2),1),this.widthBuffer.setUsage(et),this.geometry.setAttribute("width",this.widthBuffer),this.sideBuffer=new dt(new Float32Array(this.maxParticles*2),1),this.sideBuffer.setUsage(et),this.geometry.setAttribute("side",this.sideBuffer),this.uvBuffer=new dt(new Float32Array(this.maxParticles*4),2),this.uvBuffer.setUsage(et),this.geometry.setAttribute("uv",this.uvBuffer),this.colorBuffer=new dt(new Float32Array(this.maxParticles*8),4),this.colorBuffer.setUsage(et),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 Xn(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=to(this.settings.material.map.channel),e.map=new Et(this.settings.material.map),e.mapTransform=new Et(new Vt().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 bs({uniforms:e,defines:t,vertexShader:wd,fragmentShader:xd,transparent:this.settings.material.transparent,depthWrite:!this.settings.material.transparent,side:this.settings.material.side,blending:this.settings.material.blending||sa,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,d=this.settings.vTileCount,f=1/u,m=1/d;for(let x=0;x<l;x++){const _=c[x],g=_.uvTile%d,v=Math.floor(_.uvTile/d+.001),w=_.previous.values();let S=w.next(),T=S.value,M=T;S.done||(S=w.next());let P;S.value!==void 0?P=S.value:P=M;for(let E=0;E<_.previous.length;E++,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)):(_.parentMatrix?this.vector_.copy(M.position).applyMatrix4(_.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,T.position.x,T.position.y,T.position.z),this.previousBuffer.setXYZ(e+1,T.position.x,T.position.y,T.position.z)):(_.parentMatrix?this.vector_.copy(T.position).applyMatrix4(_.parentMatrix):this.vector_.copy(T.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,P.position.x,P.position.y,P.position.z),this.nextBuffer.setXYZ(e+1,P.position.x,P.position.y,P.position.z)):(_.parentMatrix?this.vector_.copy(P.position).applyMatrix4(_.parentMatrix):this.vector_.copy(P.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(_.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,(E/_.previous.length+g)*f,(d-v-1)*m),this.uvBuffer.setXY(e+1,(E/_.previous.length+g)*f,(d-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),E+1<_.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++),T=M,M=P,S.done||(S=w.next(),S.value!==void 0&&(P=S.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 er{get geometry(){return this._geometry}set geometry(e){if(this._geometry=e,e===void 0||typeof e=="string")return;const t=new mn;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 q,this._tempB=new q,this._tempC=new q,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],d=t.getIndex().array[i*3+2],f=t.getAttribute("position");this._tempA.fromBufferAttribute(f,l),this._tempB.fromBufferAttribute(f,u),this._tempC.fromBufferAttribute(f,d),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 er(t.geometries[e.geometry])}clone(){return new er(this._geometry)}update(e,t){}}ed({id:"three.quarks",emitterShapes:[{type:"mesh_surface",params:[["geometry",["geometry"]]],constructor:er,loadJSON:er.fromJSON}],behaviors:[]});class Oo extends ia{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(Oo.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 _d(t);break;case V.Mesh:case V.BillBoard:case V.VerticalBillBoard:case V.HorizontalBillBoard:case V.StretchedBillBoard:n=new bd(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 Td=Oo;ld(),console.log("%c Particle system powered by three.quarks. https://quarks.art/","font-size: 14px; font-weight: bold;");const $c=Math.sqrt(5),Md=($c-1)/4,je=(5-$c)/20,Rr=r=>Math.floor(r)|0,Ar=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 Cd(r=Math.random){const e=Pd(r),t=new Float64Array(e).map(a=>Ar[a%32*4]),n=new Float64Array(e).map(a=>Ar[a%32*4+1]),i=new Float64Array(e).map(a=>Ar[a%32*4+2]),s=new Float64Array(e).map(a=>Ar[a%32*4+3]);return function(a,o,c,l){let u,d,f,m,x;const _=(a+o+c+l)*Md,g=Rr(a+_),v=Rr(o+_),w=Rr(c+_),S=Rr(l+_),T=(g+v+w+S)*je,M=g-T,P=v-T,E=w-T,O=S-T,A=a-M,R=o-P,B=c-E,I=l-O;let U=0,L=0,J=0,H=0;A>R?U++:L++,A>B?U++:J++,A>I?U++:H++,R>B?L++:J++,R>I?L++:H++,B>I?J++:H++;const se=U>=3?1:0,W=L>=3?1:0,pe=J>=3?1:0,ne=H>=3?1:0,he=U>=2?1:0,oe=L>=2?1:0,le=J>=2?1:0,xe=H>=2?1:0,ge=U>=1?1:0,de=L>=1?1:0,re=J>=1?1:0,Ze=H>=1?1:0,Ue=A-se+je,ke=R-W+je,lt=B-pe+je,De=I-ne+je,ve=A-he+2*je,ue=R-oe+2*je,ft=B-le+2*je,Re=I-xe+2*je,fe=A-ge+3*je,rt=R-de+3*je,wt=B-re+3*je,_t=I-Ze+3*je,st=A-1+4*je,Tt=R-1+4*je,mt=B-1+4*je,yt=I-1+4*je,ut=g&255,Ae=v&255,Ke=w&255,ht=S&255;let Qe=.6-A*A-R*R-B*B-I*I;if(Qe<0)u=0;else{const ae=ut+e[Ae+e[Ke+e[ht]]];Qe*=Qe,u=Qe*Qe*(t[ae]*A+n[ae]*R+i[ae]*B+s[ae]*I)}let $=.6-Ue*Ue-ke*ke-lt*lt-De*De;if($<0)d=0;else{const ae=ut+se+e[Ae+W+e[Ke+pe+e[ht+ne]]];$*=$,d=$*$*(t[ae]*Ue+n[ae]*ke+i[ae]*lt+s[ae]*De)}let Mt=.6-ve*ve-ue*ue-ft*ft-Re*Re;if(Mt<0)f=0;else{const ae=ut+he+e[Ae+oe+e[Ke+le+e[ht+xe]]];Mt*=Mt,f=Mt*Mt*(t[ae]*ve+n[ae]*ue+i[ae]*ft+s[ae]*Re)}let jt=.6-fe*fe-rt*rt-wt*wt-_t*_t;if(jt<0)m=0;else{const ae=ut+ge+e[Ae+de+e[Ke+re+e[ht+Ze]]];jt*=jt,m=jt*jt*(t[ae]*fe+n[ae]*rt+i[ae]*wt+s[ae]*_t)}let Ct=.6-st*st-Tt*Tt-mt*mt-yt*yt;if(Ct<0)x=0;else{const ae=ut+1+e[Ae+1+e[Ke+1+e[ht+1]]];Ct*=Ct,x=Ct*Ct*(t[ae]*st+n[ae]*Tt+i[ae]*mt+s[ae]*yt)}return 27*(u+d+f+m+x)}}function Pd(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 Ed=Object.defineProperty,kd=(r,e,t)=>e in r?Ed(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Me=(r,e,t)=>(kd(r,typeof e!="symbol"?e+"":e,t),t);(function(){class r{}class e extends r{constructor(p){super(),Me(this,"value"),this.value=p}}class t extends r{constructor(p){super(),Me(this,"value"),this.value=p}}class n extends r{constructor(p){super(),Me(this,"value"),this.value=p}}class i extends r{constructor(p,y="unrestricted"){super(),Me(this,"type"),Me(this,"value"),this.value=p,this.type=y}}class s extends r{constructor(p){super(),Me(this,"value"),this.value=p}}class a extends r{}class o extends r{constructor(p){super(),Me(this,"value"),this.value=p}}class c extends r{}class l extends r{constructor(p){super(),Me(this,"value"),this.value=p}}class u extends r{constructor(p,y="integer"){super(),Me(this,"value"),Me(this,"type"),this.value=p,this.type=y}}class d extends r{constructor(p){super(),Me(this,"value"),this.value=p}}class f extends r{constructor(p,y,b){super(),Me(this,"value"),Me(this,"type"),Me(this,"unit"),this.value=p,this.type=y,this.unit=b}}class m extends r{}class x extends r{}class _ extends r{}class g extends r{}class v extends r{}class w extends r{}class S extends r{}class T extends r{}class M extends r{}class P extends r{}class E extends r{}class O extends r{}class A{constructor(p){Me(this,"input"),Me(this,"index",0),this.input=p}consume(){const p=this.input.codePointAt(this.index);return p!==void 0&&(this.index+=String.fromCodePoint(p).length),p}reconsume(p){p!==void 0&&(this.index-=String.fromCodePoint(p).length)}peek(){const p=[];let y=this.index;for(let b=0;b<3&&y<this.input.length;b++){const C=this.input.codePointAt(y);p.push(C),y+=String.fromCodePoint(C).length}return p}}function R(h){return h===10}function B(h){return R(h)||h===8192||h===32}function I(h){return h>=48&&h<=57}function U(h){return I(h)||h>=65&&h<=70||h>=97&&h<=102}function L(h){return function(p){return function(y){return y>=65&&y<=90}(p)||function(y){return y>=97&&y<=122}(p)}(h)||function(p){return p>=128}(h)||h===95}function J(h){return L(h)||I(h)||h===45}function H(h){return h>=0&&h<=8||h===11||h>=14&&h<=31||h===127}function se(h,p){return h===92&&!R(p)}function W(h,p,y){return h===45?L(p)||p===45||se(p,y):!!L(h)||h===92&&se(h,p)}function pe(h,p,y){return h===43||h===45?I(p)||p===46&&I(y):I(h===46?p:h)}function ne(h){const p=h.consume();if(U(p)){let y=[p];for(;U(...h.peek())&&y.length<5;)y.push(h.consume());B(...h.peek())&&h.consume();const b=parseInt(String.fromCodePoint(...y),16);return b===0||b>1114111?65533:b}return p===void 0?65533:p}function he(h,p){const y=new s("");for(;;){const b=h.consume();if(b===p||b===void 0)return y;if(b===10)return h.reconsume(b),new a;if(b===92){const C=h.peek()[0];C===void 0||(R(C)?h.consume():y.value+=String.fromCodePoint(ne(h)))}else y.value+=String.fromCodePoint(b)}}function oe(h){let p="";for(;;){const y=h.consume();if(J(y))p+=String.fromCodePoint(y);else{if(!se(...h.peek()))return h.reconsume(y),p;p+=String.fromCodePoint(ne(h))}}}function le(h){let p=function(y){let b="integer",C="";for([43,45].includes(y.peek()[0])&&(C+=String.fromCodePoint(y.consume()));I(...y.peek());)C+=String.fromCodePoint(y.consume());if(y.peek()[0]===46&&I(y.peek()[1]))for(C+=String.fromCodePoint(y.consume(),y.consume()),b="number";I(...y.peek());)C+=String.fromCodePoint(y.consume());return[69,101].includes(y.peek()[0])&&([45,43].includes(y.peek()[1])&&I(y.peek()[2])?(C+=String.fromCodePoint(y.consume(),y.consume(),y.consume()),b="number"):I(y.peek()[1])&&(C+=String.fromCodePoint(y.consume(),y.consume()),b="number")),{value:parseFloat(C),type:b}}(h);return W(...h.peek())?new f(p.value,p.type,oe(h)):h.peek()[0]===37?(h.consume(),new d(p.value)):new u(p.value,p.type)}function xe(h){for(;;){const p=h.consume();if(p===41||p===void 0)return;se(...h.peek())&&ne(h)}}function ge(h){const p=oe(h);if(p.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(p):function(y){const b=new o("");for(;B(...y.peek());)y.consume();for(;;){const C=y.consume();if(C===41||C===void 0)return b;if(B(C)){for(;B(...y.peek());)y.consume();return y.peek()[0]===41||y.peek()[0]===void 0?(y.consume(),b):(xe(y),new c)}if([34,39,40].includes(C)||H(C))return xe(y),new c;if(C===92){if(!se(...y.peek()))return xe(y),new c;b.value+=ne(y)}else b.value+=String.fromCodePoint(C)}}(h)}return h.peek()[0]===40?(h.consume(),new t(p)):new e(p)}function de(h){const p=h.consume(),y=h.peek();if(B(p)){for(;B(...h.peek());)h.consume();return new m}if(p===34)return he(h,p);if(p===35){if(J(y[0])||se(...y)){const b=new i;return W(...y)&&(b.type="id"),b.value=oe(h),b}return new l(String.fromCodePoint(p))}return p===39?he(h,p):p===40?new M:p===41?new P:p===43?pe(...y)?(h.reconsume(p),le(h)):new l(String.fromCodePoint(p)):p===44?new w:p===45?pe(...h.peek())?(h.reconsume(p),le(h)):h.peek()[0]===45&&h.peek()[1]===62?(h.consume(),h.consume(),new _):W(...h.peek())?(h.reconsume(p),ge(h)):new l(String.fromCodePoint(p)):p===46?pe(...h.peek())?(h.reconsume(p),le(h)):new l(String.fromCodePoint(p)):p===58?new g:p===59?new v:p===60?y[0]===33&&y[1]===45&&y[2]===45?(h.consume(),h.consume(),h.consume(),new x):new l(String.fromCodePoint(p)):p===64?W(...y)?new n(oe(h)):new l(String.fromCodePoint(p)):p===91?new S:p===92?se(...y)?(h.reconsume(p),ge(h)):new l(String.fromCodePoint(p)):p===93?new T:p===123?new E:p===125?new O:I(p)?(h.reconsume(p),le(h)):L(p)?(h.reconsume(p),ge(h)):p===void 0?void 0:new l(String.fromCodePoint(p))}const re=new Set(["px","deg","s","hz","dppx","number","fr"]);function Ze(h){return re.has(h.toLowerCase())}function Ue(h,p){if(["x","y"].includes(h))return h;if(!p)throw new Error("To determine the normalized axis the computedStyle of the source is required.");const y=p.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 ke(h){const p=[];let y=0;function b(){let k=0;const z=y;for(;y<h.length;){const D=h.slice(y,y+1);if(/\s/.test(D)&&k===0)break;if(D==="(")k+=1;else if(D===")"&&(k-=1,k===0)){y++;break}y++}return h.slice(z,y)}function C(){for(;/\s/.test(h.slice(y,y+1));)y++}for(;y<h.length;){const k=h.slice(y,y+1);/\s/.test(k)?C():p.push(b())}return p}function lt(h,p){return h.reduce((y,b)=>(y.has(b[p])?y.get(b[p]).push(b):y.set(b[p],[b]),y),new Map)}function De(h,p){const y=[],b=[];for(const C of h)p(C)?y.push(C):b.push(C);return[y,b]}function ve(h,p={}){function y(b){return Array.from(b).map(C=>ve(C,p))}if(h instanceof CSSUnitValue){if(h.unit==="percent"&&p.percentageReference){const C=h.value/100*p.percentageReference.value,k=p.percentageReference.unit;return new CSSUnitValue(C,k)}const b=h.toSum();if(b&&b.values.length===1&&(h=b.values[0]),h instanceof CSSUnitValue&&h.unit==="em"&&p.fontSize&&(h=new CSSUnitValue(h.value*p.fontSize.value,p.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(ve(h.value,p));break;case"clamp":h=new CSSMathClamp(ve(h.lower,p),ve(h.value,p),ve(h.upper,p));break;case"invert":h=new CSSMathInvert(ve(h.value,p));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 b=Array.from(h.values);if(b.every(C=>C instanceof CSSUnitValue&&C.unit!=="percent"&&Ze(C.unit)&&C.unit===b[0].unit)){const C=Math[h.operator].apply(Math,b.map(({value:k})=>k));return new CSSUnitValue(C,b[0].unit)}}if(h instanceof CSSMathMin||h instanceof CSSMathMax){const b=Array.from(h.values),[C,k]=De(b,D=>D instanceof CSSUnitValue&&D.unit!=="percent"),z=Array.from(lt(C,"unit").values());if(z.some(D=>D.length>0)){const D=z.map(N=>{const F=Math[h.operator].apply(Math,N.map(({value:X})=>X));return new CSSUnitValue(F,N[0].unit)});h=h instanceof CSSMathMin?new CSSMathMin(...D,...k):new CSSMathMax(...D,...k)}return b.length===1?b[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 b=function(k){const z=k.filter(D=>D instanceof CSSUnitValue);return[...k.filter(D=>!(D instanceof CSSUnitValue)),...Array.from(lt(z,"unit").entries()).map(([D,N])=>{const F=N.reduce((X,{value:Z})=>X+Z,0);return new CSSUnitValue(F,D)})]},C=[];for(const k of h.values)k instanceof CSSMathSum?C.push(...k.values):C.push(k);return C=b(C),C.length===1?C[0]:new CSSMathSum(...C)}if(h instanceof CSSMathProduct){let b=[];for(const z of h.values)z instanceof CSSMathProduct?b.push(...z.values):b.push(z);const[C,k]=De(b,z=>z instanceof CSSUnitValue&&z.unit==="number");if(C.length>1){const z=C.reduce((D,{value:N})=>D*N,1);b=[new CSSUnitValue(z,"number"),...k]}if(b.length===2){let z,D;for(const N of b)N instanceof CSSUnitValue&&N.unit==="number"?z=N:N instanceof CSSMathSum&&[...N.values].every(F=>F instanceof CSSUnitValue)&&(D=N);if(z&&D)return new CSSMathSum(...[...D.values].map(N=>new CSSUnitValue(N.value*z.value,N.unit)))}if(b.every(z=>z instanceof CSSUnitValue&&Ze(z.unit)||z instanceof CSSMathInvert&&z.value instanceof CSSUnitValue&&Ze(z.value.unit))){const z=new CSSMathProduct(...b).toSum();if(z&&z.values.length===1)return z.values[0]}return new CSSMathProduct(...b)}return h}const ue=null,ft=["percent","length","angle","time","frequency","resolution","flex"],Re={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}}},fe=new Map;for(const h of Object.values(Re))if(h.compatible)for(const p of h.units)fe.set(p,h);function rt(h){return fe.get(h)}function wt(h,p){const y={...h};for(const b of Object.keys(p))y[b]?y[b]+=p[b]:y[b]=p[b];return y}function _t(h){return h==="number"?{}:h==="percent"?{percent:1}:Re.absoluteLengths.units.has(h)||Re.fontRelativeLengths.units.has(h)||Re.viewportRelativeLengths.units.has(h)?{length:1}:Re.angle.units.has(h)?{angle:1}:Re.time.units.has(h)?{time:1}:Re.frequency.units.has(h)?{frequency:1}:Re.resolution.units.has(h)?{resolution:1}:h==="fr"?{flex:1}:ue}function st(h){if(h instanceof CSSUnitValue){let{unit:p,value:y}=h;const b=rt(h.unit);return b&&p!==b.canonicalUnit&&(y*=b.ratios[p],p=b.canonicalUnit),p==="number"?[[y,{}]]:[[y,{[p]:1}]]}if(h instanceof CSSMathInvert){if(!(h.value instanceof CSSUnitValue))throw new Error("Not implemented");const p=st(h.value);if(p===ue||p.length>1)return ue;const y=p[0],b={};for(const[C,k]of Object.entries(y[1]))b[C]=-1*k;return p[0]=[1/y[0],b],p}if(h instanceof CSSMathProduct){let p=[[1,{}]];for(const y of h.values){const b=st(y),C=[];if(b===ue)return ue;for(const k of p)for(const z of b)C.push([k[0]*z[0],wt(k[1],z[1])]);p=C}return p}throw new Error("Not implemented")}function Tt(h,p){if(_t(p)===ue)throw new SyntaxError("The string did not match the expected pattern.");const y=st(h);if(!y)throw new TypeError;if(y.length>1)throw new TypeError("Sum has more than one item");const b=function(C,k){const z=C.unit,D=C.value,N=rt(z),F=rt(k);return!F||N!==F?ue:new CSSUnitValue(D*F.ratios[z]/F.ratios[k],k)}(mt(y[0]),p);if(b===ue)throw new TypeError;return b}function mt(h){const[p,y]=h,b=Object.entries(y);if(b.length>1)return ue;if(b.length===0)return new CSSUnitValue(p,"number");const C=b[0];return C[1]!==1?ue:new CSSUnitValue(p,C[0])}function yt(h,...p){if(p&&p.length)throw new Error("Not implemented");const y=st(h).map(b=>mt(b));if(y.some(b=>b===ue))throw new TypeError("Type error");return new CSSMathSum(...y)}function ut(h,p){if(h.percentHint&&p.percentHint&&h.percentHint!==p.percentHint)return ue;const y={...h,percentHint:h.percentHint??p.percentHint};for(const b of ft)p[b]&&(y[b]??(y[b]=0),y[b]+=p[b]);return y}class Ae{constructor(p,y){Me(this,"name"),Me(this,"values"),this.name=p,this.values=y}}class Ke{constructor(p,y){Me(this,"value"),Me(this,"associatedToken"),this.value=p,this.associatedToken=y}}function ht(h){if(Array.isArray(h))return h;if(typeof h=="string")return function(p){const y=new A(p),b=[];for(;;){const C=de(y);if(C===void 0)return b;b.push(C)}}(h);throw new TypeError("Invalid input type "+typeof h)}function Qe(h){const p=h.shift();return p instanceof E||p instanceof S||p instanceof M?function(y,b){let C;if(b instanceof E)C=O;else if(b instanceof M)C=P;else{if(!(b instanceof S))return;C=T}const k=new Ke([],b);for(;;){const z=y.shift();if(z instanceof C||z===void 0)return k;y.unshift(z),k.value.push(Qe(y))}}(h,p):p instanceof t?function(y,b){const C=new Ae(y.value,[]);for(;;){const k=b.shift();if(k instanceof P||k===void 0)return C;b.unshift(k),C.values.push(Qe(b))}}(p,h):p}function $(h){if(h instanceof M||h instanceof P)return 6;if(h instanceof l)switch(h.value){case"*":case"/":return 4;case"+":case"-":return 2}}function Mt(h){return h[h.length-1]}function jt(h,p,y){const b=["+","-"].includes(h.value)?"ADDITION":"MULTIPLICATION",C=p.type===b?p.values:[p],k=y.type===b?y.values:[y];return h.value==="-"?k[0]={type:"NEGATE",value:k[0]}:h.value==="/"&&(k[0]={type:"INVERT",value:k[0]}),{type:b,values:[...C,...k]}}function Ct(h){if(h.type==="ADDITION")return new CSSMathSum(...h.values.map(p=>Ct(p)));if(h.type==="MULTIPLICATION")return new CSSMathProduct(...h.values.map(p=>Ct(p)));if(h.type==="NEGATE")return new CSSMathNegate(Ct(h.value));if(h.type==="INVERT")return new CSSMathInvert(Ct(h.value));if(h instanceof Ke)return ae(new Ae("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 Io(h)}function ae(h){if(h.name==="min"||h.name==="max"){const b=h.values.filter(C=>!(C instanceof m||C instanceof w)).map(C=>ve(ae(new Ae("calc",C))));return h.name==="min"?new CSSMathMin(...b):new CSSMathMax(...b)}if(h.name!=="calc")return null;const p=Ct(function(b){const C=[],k=[];for(;b.length;){const z=b.shift();if(z instanceof u||z instanceof f||z instanceof d||z instanceof Ae||z instanceof Ke||z instanceof e)k.push(z);else if(z instanceof l&&["*","/","+","-"].includes(z.value)){for(;C.length&&!(Mt(C)instanceof M)&&$(Mt(C))>$(z);){const D=C.pop(),N=k.pop(),F=k.pop();k.push(jt(D,F,N))}C.push(z)}else if(z instanceof M)C.push(z);else if(z instanceof P){if(!C.length)return null;for(;!(Mt(C)instanceof M);){const D=C.pop(),N=k.pop(),F=k.pop();k.push(jt(D,F,N))}if(!(Mt(C)instanceof M))return null;C.pop()}else if(!(z instanceof m))return null}for(;C.length;){if(Mt(C)instanceof M)return null;const z=C.pop(),D=k.pop(),N=k.pop();k.push(jt(z,N,D))}return k[0]}([...h.values]));let y;try{y=ve(p)}catch{new CSSStyleSheet().insertRule("error",0)}return y instanceof CSSUnitValue?new CSSMathSum(y):y}function Io(h){return h instanceof Ae&&["calc","min","max","clamp"].includes(h.name)?ae(h):h instanceof u&&h.value===0&&!h.unit?new CSSUnitValue(0,"px"):h instanceof u?new CSSUnitValue(h.value,"number"):h instanceof d?new CSSUnitValue(h.value,"percent"):h instanceof f?new CSSUnitValue(h.value,h.unit):void 0}function Bl(h){const p=function(y){const b=ht(y);for(;b[0]instanceof m;)b.shift();if(b[0]===void 0)return null;const C=Qe(b);for(;b[0]instanceof m;)b.shift();return b[0]===void 0?C:null}(h);return p===null&&new CSSStyleSheet().insertRule("error",0),p instanceof u||p instanceof d||p instanceof f||p instanceof Ae||new CSSStyleSheet().insertRule("error",0),p instanceof f&&_t(p.unit)===null&&new CSSStyleSheet().insertRule("error",0),Io(p)}(function(){let h=new WeakMap;function p(k){const z=[];for(let N=0;N<k.length;N++)z[N]=typeof(D=k[N])=="number"?new CSSUnitValue(D,"number"):D;var D;return z}class y{static parse(z){return z instanceof y?z:ve(Bl(z),{})}}class b extends y{constructor(z,D,N,F){super(),h.set(this,{values:p(z),operator:D,name:N||D,delimiter:F||", "})}get operator(){return h.get(this).operator}get values(){return h.get(this).values}toString(){const z=h.get(this);return`${z.name}(${z.values.join(z.delimiter)})`}}const C={CSSNumericValue:y,CSSMathValue:b,CSSUnitValue:class extends y{constructor(k,z){super(),h.set(this,{value:k,unit:z})}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 Tt(this,k)}toSum(...k){return yt(this,...k)}type(){return _t(h.get(this).unit)}toString(){const k=h.get(this);return`${k.value}${function(z){switch(z){case"percent":return"%";case"number":return"";default:return z.toLowerCase()}}(k.unit)}`}},CSSKeywordValue:class{constructor(k){this.value=k}toString(){return this.value.toString()}},CSSMathSum:class extends b{constructor(k){super(arguments,"sum","calc"," + ")}},CSSMathProduct:class extends b{constructor(k){super(arguments,"product","calc"," * ")}toSum(...k){return yt(this,...k)}type(){return h.get(this).values.map(k=>k.type()).reduce(ut)}},CSSMathNegate:class extends b{constructor(k){super([arguments[0]],"negate","-")}get value(){return h.get(this).values[0]}type(){return this.value.type()}},CSSMathInvert:class extends b{constructor(k){super([1,arguments[0]],"invert","calc"," / ")}get value(){return h.get(this).values[1]}type(){return function(k){const z={};for(const D of ft)z[D]=-1*k[D];return z}(h.get(this).values[1].type())}},CSSMathMax:class extends b{constructor(){super(arguments,"max")}},CSSMathMin:class extends b{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:z=>new CSSUnitValue(z,k)}))throw Error(`Error installing CSS.${k}`)});for(let[k,z]of Object.entries(C))if(!(k in window)&&!Reflect.defineProperty(window,k,{value:z}))throw Error(`Error installing CSSOM support for ${k}`)})();const Bo="block";let Ge=new WeakMap,Jt=new WeakMap;const tr=["entry","exit","cover","contain","entry-crossing","exit-crossing"];function zo(h){return h===document.scrollingElement?document:h}function dn(h){as(h);let p=Ge.get(h).animations;if(p.length===0)return;let y=h.currentTime;for(let b=0;b<p.length;b++)p[b].tickAnimation(y)}function No(h,p){if(!h)return null;const y=Jt.get(h).sourceMeasurements,b=getComputedStyle(h);let C=y.scrollTop;return Ue(p,b)==="x"&&(C=Math.abs(y.scrollLeft)),C}function os(h,p){const y=ve(h,p);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 as(h){if(!(h instanceof kn))return void function(y){const b=Ge.get(y);if(!b.anonymousSource)return;const C=Do(b.anonymousSource,b.anonymousTarget);Qn(y,C)}(h);const p=h.subject;if(!p||getComputedStyle(p).display=="none")return void Qn(h,null);Qn(h,ps(p))}function Uo(h){return["block","inline","x","y"].includes(h)}function cs(h){const p=getComputedStyle(h);return{scrollLeft:h.scrollLeft,scrollTop:h.scrollTop,scrollWidth:h.scrollWidth,scrollHeight:h.scrollHeight,clientWidth:h.clientWidth,clientHeight:h.clientHeight,writingMode:p.writingMode,direction:p.direction,scrollPaddingTop:p.scrollPaddingTop,scrollPaddingBottom:p.scrollPaddingBottom,scrollPaddingLeft:p.scrollPaddingLeft,scrollPaddingRight:p.scrollPaddingRight}}function ls(h,p){if(!h||!p)return;let y=0,b=0,C=p;const k=h.offsetParent;for(;C&&C!=k;)b+=C.offsetLeft,y+=C.offsetTop,C=C.offsetParent;b-=h.offsetLeft+h.clientLeft,y-=h.offsetTop+h.clientTop;const z=getComputedStyle(p);return{top:y,left:b,offsetWidth:p.offsetWidth,offsetHeight:p.offsetHeight,fontSize:z.fontSize}}function nr(h){let p=Jt.get(h);p.sourceMeasurements=cs(h);for(const y of p.timelineRefs){const b=y.deref();b instanceof kn&&(Ge.get(b).subjectMeasurements=ls(h,b.subject))}p.updateScheduled||(setTimeout(()=>{for(const y of p.timelineRefs){const b=y.deref();b&&dn(b)}p.updateScheduled=!1}),p.updateScheduled=!0)}function Qn(h,p){const y=Ge.get(h),b=y.source;if(b!=p){if(b){const C=Jt.get(b);if(C){C.timelineRefs.delete(h);const k=Array.from(C.timelineRefs).filter(z=>z.deref()===void 0);for(const z of k)C.timelineRefs.delete(z);C.timelineRefs.size===0&&(C.disconnect(),Jt.delete(b))}}if(y.source=p,p){let C=Jt.get(p);if(!C){C={timelineRefs:new Set,sourceMeasurements:cs(p)},Jt.set(p,C);const k=new ResizeObserver(N=>{for(const F of N)nr(y.source)});k.observe(p);for(const N of p.children)k.observe(N);const z=new MutationObserver(N=>{for(const F of N)nr(F.target)});z.observe(p,{attributes:!0,attributeFilter:["style","class"]});const D=()=>{C.sourceMeasurements.scrollLeft=p.scrollLeft,C.sourceMeasurements.scrollTop=p.scrollTop;for(const N of C.timelineRefs){const F=N.deref();F&&dn(F)}};zo(p).addEventListener("scroll",D),C.disconnect=()=>{k.disconnect(),z.disconnect(),zo(p).removeEventListener("scroll",D)}}C.timelineRefs.add(new WeakRef(h))}}}function us(h,p){let y=Ge.get(h).animations;for(let b=0;b<y.length;b++)y[b].animation==p&&y.splice(b,1)}function hs(h,p,y){let b=Ge.get(h).animations;for(let C=0;C<b.length;C++)if(b[C].animation==p)return;b.push({animation:p,tickAnimation:y}),queueMicrotask(()=>{dn(h)})}class $e{constructor(p){if(Ge.set(this,{source:null,axis:Bo,anonymousSource:p?p.anonymousSource:null,anonymousTarget:p?p.anonymousTarget:null,subject:null,inset:null,animations:[],subjectMeasurements:null}),Qn(this,p&&p.source!==void 0?p.source:document.scrollingElement),p&&p.axis!==void 0&&p.axis!=Bo){if(!Uo(p.axis))throw TypeError("Invalid axis");Ge.get(this).axis=p.axis}dn(this)}set source(p){Qn(this,p),dn(this)}get source(){return Ge.get(this).source}set axis(p){if(!Uo(p))throw TypeError("Invalid axis");Ge.get(this).axis=p,dn(this)}get axis(){return Ge.get(this).axis}get duration(){return CSS.percent(100)}get phase(){const p=this.source;if(!p)return"inactive";let y=getComputedStyle(p);return y.display=="none"?"inactive":p==document.scrollingElement||y.overflow!="visible"&&y.overflow!="clip"?"active":"inactive"}get currentTime(){const p=this.source;if(!p||!p.isConnected||this.phase=="inactive")return null;const y=getComputedStyle(p);if(y.display==="inline"||y.display==="none")return null;const b=this.axis,C=No(p,b),k=function(z,D){const N=Jt.get(z).sourceMeasurements,F=getComputedStyle(z).writingMode=="horizontal-tb";return D==="block"?D=F?"y":"x":D==="inline"&&(D=F?"x":"y"),D==="y"?N.scrollHeight-N.clientHeight:D==="x"?N.scrollWidth-N.clientWidth:void 0}(p,b);return k>0?CSS.percent(100*C/k):CSS.percent(100)}get __polyfill(){return!0}}function ds(h,p){let y=h.parentElement;for(;y!=null;){if(p(y))return y;y=y.parentElement}}function Do(h,p){switch(h){case"root":return document.scrollingElement;case"nearest":return ps(p);case"self":return p;default:throw new TypeError("Invalid ScrollTimeline Source Type.")}}function zl(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 Lo(h){const p=getComputedStyle(h);return p.transform!="none"||p.perspective!="none"||p.willChange=="transform"||p.willChange=="perspective"||p.filter!="none"||p.willChange=="filter"||p.backdropFilter!="none"}function Nl(h){return getComputedStyle(h).position!="static"||Lo(h)}function Ul(h){switch(getComputedStyle(h).position){case"static":case"relative":case"sticky":return ds(h,zl);case"absolute":return ds(h,Nl);case"fixed":return ds(h,Lo)}}function ps(h){if(h&&h.isConnected){for(;h=Ul(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 $n(h,p){const y=Ge.get(h),b=y.subjectMeasurements,C=Jt.get(y.source).sourceMeasurements;return h.phase==="inactive"?null:h instanceof kn?fs(p,C,b,y.axis,y.inset):null}function fs(h,p,y,b,C){const k=p.direction=="rtl"||p.writingMode=="vertical-rl";let z,D,N={fontSize:y.fontSize};Ue(b,p)==="x"?(z=y.offsetWidth,D=y.left,N.scrollPadding=[p.scrollPaddingLeft,p.scrollPaddingRight],k&&(D+=p.scrollWidth-p.clientWidth,N.scrollPadding=[p.scrollPaddingRight,p.scrollPaddingLeft]),N.containerSize=p.clientWidth):(z=y.offsetHeight,D=y.top,N.scrollPadding=[p.scrollPaddingTop,p.scrollPaddingBottom],N.containerSize=p.clientHeight);const F=function(vs,ar){const Yl={start:0,end:0};if(!vs)return Yl;const[Zl,Kl]=[vs.start,vs.end].map((ea,ta)=>ea==="auto"?ar.scrollPadding[ta]==="auto"?0:parseFloat(ar.scrollPadding[ta]):os(ea,{percentageReference:CSS.px(ar.containerSize),fontSize:CSS.px(parseFloat(ar.fontSize))}));return{start:Zl,end:Kl}}(C,N),X=D-N.containerSize+F.end,Z=D+z-F.start,K=X+z,me=Z-z,_e=Math.min(K,me),ot=Math.max(K,me);let Pt,gt;const $o=z>N.containerSize-F.start-F.end;switch(h){case"cover":Pt=X,gt=Z;break;case"contain":Pt=_e,gt=ot;break;case"entry":Pt=X,gt=_e;break;case"exit":Pt=ot,gt=Z;break;case"entry-crossing":Pt=X,gt=$o?ot:_e;break;case"exit-crossing":Pt=$o?_e:ot,gt=Z}return{start:Pt,end:gt}}function Fo(h,p){if(h instanceof kn){const{rangeName:y,offset:b}=p;return Vo($n(h,y),b,$n(h,"cover"),h.subject)}if(h instanceof $e){const{axis:y,source:b}=h,{sourceMeasurements:C}=Jt.get(b);let k;return k=Ue(y,C)==="x"?C.scrollWidth-C.clientWidth:C.scrollHeight-C.clientHeight,os(p,{percentageReference:CSS.px(k)})/k}unsupportedTimeline(h)}function Vo(h,p,y,b){if(!h||!y)return 0;let C=getComputedStyle(b);return(os(p,{percentageReference:CSS.px(h.end-h.start),fontSize:CSS.px(parseFloat(C.fontSize))})+h.start-y.start)/(y.end-y.start)}let kn=class extends $e{constructor(h){super(h);const p=Ge.get(this);p.subject=h&&h.subject?h.subject:void 0,h&&h.inset&&(p.inset=function(y){if(!y)return{start:0,end:0};let b;if(b=typeof y=="string"?ke(y).map(C=>{if(C==="auto")return"auto";try{return CSSNumericValue.parse(C)}catch{throw TypeError(`Could not parse inset "${y}"`)}}):Array.isArray(y)?y:[y],b.length===0||b.length>2)throw TypeError("Invalid inset");for(const C of b){if(C==="auto")continue;const k=C.type();if(k.length!==1&&k.percent!==1)throw TypeError("Invalid inset")}return{start:b[0],end:b[1]??b[0]}}(h.inset)),p.subject&&(new ResizeObserver(()=>{nr(p.source)}).observe(p.subject),new MutationObserver(()=>{nr(p.source)}).observe(p.subject,{attributes:!0,attributeFilter:["class","style"]})),as(this),p.subjectMeasurements=ls(p.source,p.subject),dn(this)}get source(){return as(this),Ge.get(this).source}set source(h){throw new Error("Cannot set the source of a view timeline")}get subject(){return Ge.get(this).subject}get axis(){return Ge.get(this).axis}get currentTime(){const h=No(this.source,this.axis);if(h==null)return null;const p=$n(this,"cover");if(!p)return null;const y=(h-p.start)/(p.end-p.start);return CSS.percent(100*y)}get startOffset(){return CSS.px($n(this,"cover").start)}get endOffset(){return CSS.px($n(this,"cover").end)}};const Dl=document.getAnimations,Ll=window.Element.prototype.getAnimations,Fl=window.Element.prototype.animate,jo=window.Animation;class Rn{constructor(){this.state="pending",this.nativeResolve=this.nativeReject=null,this.promise=new Promise((p,y)=>{this.nativeResolve=p,this.nativeReject=y})}resolve(p){this.state="resolved",this.nativeResolve(p)}reject(p){this.state="rejected",this.promise.catch(()=>{}),this.nativeReject(p)}}function ei(h){h.readyPromise=new Rn,requestAnimationFrame(()=>{var p;(((p=h.timeline)==null?void 0:p.currentTime)??null)!==null&&(ir(h),h.pendingTask!=="play"||h.startTime===null&&h.holdTime===null?h.pendingTask==="pause"&&Wo(h):Go(h))})}function Jo(){return new DOMException("The user aborted a request","AbortError")}function pn(h,p){if(p===null)return p;if(typeof p!="number")throw new DOMException(`Unexpected value: ${p}. Cannot convert to CssNumberish`,"InvalidStateError");const y=h.rangeDuration??100,b=Wt(h),C=b?y*p/b:0;return CSS.percent(C)}function Se(h,p){if(h.timeline){if(p===null)return p;if(p.unit==="percent"){const y=h.rangeDuration??100,b=Wt(h);return p.value*b/y}throw new DOMException("CSSNumericValue must be a percentage for progress based animations.","NotSupportedError")}{if(p==null||typeof p=="number")return p;const y=p.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 Go(h){const p=Se(h,h.timeline.currentTime);if(h.holdTime!=null)Bt(h),h.animation.playbackRate==0?h.startTime=p:(h.startTime=p-h.holdTime/h.animation.playbackRate,h.holdTime=null);else if(h.startTime!==null&&h.pendingPlaybackRate!==null){const y=(p-h.startTime)*h.animation.playbackRate;Bt(h);const b=h.animation.playbackRate;b==0?(h.holdTime=null,h.startTime=p):h.startTime=p-y/b}h.readyPromise&&h.readyPromise.state=="pending"&&h.readyPromise.resolve(h.proxy),Gt(h,!1,!1),Ht(h),h.pendingTask=null}function Wo(h){const p=Se(h,h.timeline.currentTime);h.startTime!=null&&h.holdTime==null&&(h.holdTime=(p-h.startTime)*h.animation.playbackRate),Bt(h),h.startTime=null,h.readyPromise.resolve(h.proxy),Gt(h,!1,!1),Ht(h),h.pendingTask=null}function Ho(h){if(!h.finishedPromise||h.finishedPromise.state!="pending"||h.proxy.playState!="finished")return;h.finishedPromise.resolve(h.proxy),h.animation.pause();const p=new CustomEvent("finish",{detail:{currentTime:h.proxy.currentTime,timelineTime:h.proxy.timeline.currentTime}});Object.defineProperty(p,"currentTime",{get:function(){return this.detail.currentTime}}),Object.defineProperty(p,"timelineTime",{get:function(){return this.detail.timelineTime}}),requestAnimationFrame(()=>{queueMicrotask(()=>{h.animation.dispatchEvent(p)})})}function An(h){return h.pendingPlaybackRate!==null?h.pendingPlaybackRate:h.animation.playbackRate}function Bt(h){h.pendingPlaybackRate!==null&&(h.animation.playbackRate=h.pendingPlaybackRate,h.pendingPlaybackRate=null)}function qo(h){if(!h.timeline)return null;const p=Se(h,h.timeline.currentTime);if(p===null||h.startTime===null)return null;let y=(p-h.startTime)*h.animation.playbackRate;return y==-0&&(y=0),y}function Gt(h,p,y){if(!h.timeline)return;let b=p?Se(h,h.proxy.currentTime):qo(h);if(b&&h.startTime!=null&&!h.proxy.pending){const C=An(h),k=Wt(h);let z=h.previousCurrentTime;C>0&&b>=k&&h.previousCurrentTime!=null?((z===null||z<k)&&(z=k),h.holdTime=p?b:z):C<0&&b<=0?((z==null||z>0)&&(z=0),h.holdTime=p?b:z):C!=0&&(p&&h.holdTime!==null&&(h.startTime=function(D,N){if(!D.timeline)return null;const F=Se(D,D.timeline.currentTime);return F==null?null:F-N/D.animation.playbackRate}(h,h.holdTime)),h.holdTime=null)}Ht(h),h.previousCurrentTime=Se(h,h.proxy.currentTime),h.proxy.playState=="finished"?(h.finishedPromise||(h.finishedPromise=new Rn),h.finishedPromise.state=="pending"&&(y?Ho(h):Promise.resolve().then(()=>{Ho(h)}))):(h.finishedPromise&&h.finishedPromise.state=="resolved"&&(h.finishedPromise=new Rn),h.animation.playState!="paused"&&h.animation.pause())}function Wt(h){const p=function(b){const C=b.proxy.effect.getTiming();return b.normalizedTiming||C}(h),y=p.delay+p.endDelay+p.iterations*p.duration;return Math.max(0,y)}function Ht(h){if(h.timeline)if(h.startTime!==null){const p=h.timeline.currentTime;if(p==null)return;ms(h,(Se(h,p)-h.startTime)*h.animation.playbackRate)}else h.holdTime!==null&&ms(h,h.holdTime)}function ms(h,p){const y=h.timeline,b=h.animation.playbackRate,C=y.currentTime&&y.currentTime.value==(b<0?0:100)?b<0?.001:-.001:0;h.animation.currentTime=p+C}function ys(h,p){if(!h.timeline)return;const y=h.proxy.playState=="paused"&&h.proxy.pending;let b=!1,C=Se(h,h.proxy.currentTime);An(h)==0&&C==null&&(h.holdTime=0),C==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,b=!0),(h.holdTime!==null||h.autoAlignStartTime||y||h.pendingPlaybackRate!==null)&&(h.readyPromise&&!b&&(h.readyPromise=null),Ht(h),h.readyPromise||ei(h),h.pendingTask="play",hs(h.timeline,h.animation,gs.bind(h.proxy)),Gt(h,!1,!1))}function gs(h){const p=Y.get(this);if(!p)return;if(h==null)return void(p.proxy.playState!=="paused"&&p.animation.playState!="idle"&&p.animation.cancel());ir(p),p.pendingTask&&requestAnimationFrame(()=>{p.pendingTask!=="play"||p.startTime===null&&p.holdTime===null?p.pendingTask==="pause"&&Wo(p):Go(p)});const y=this.playState;if(y=="running"||y=="finished"){const b=Se(p,h);ms(p,(b-Se(p,this.startTime))*this.playbackRate),Gt(p,!1,!1)}}function Xo(h){h.specifiedTiming=null}let Y=new WeakMap;window.addEventListener("pagehide",h=>{Y=new WeakMap},!1);let Yo=new WeakMap;function ir(h){if(!h.autoAlignStartTime||!h.timeline||!h.timeline.currentTime||h.proxy.playState==="idle"||h.proxy.playState==="paused"&&h.holdTime!==null)return;const p=h.rangeDuration;let y,b;try{y=CSS.percent(100*function(k){if(!k.animationRange)return 0;const z=k.animationRange.start==="normal"?Zo(k.timeline):k.animationRange.start;return Fo(k.timeline,z)}(h))}catch(k){y=CSS.percent(0),h.animationRange.start="normal",console.warn("Exception when calculating start offset",k)}try{b=CSS.percent(100*(1-function(k){if(!k.animationRange)return 0;const z=k.animationRange.end==="normal"?Ko(k.timeline):k.animationRange.end;return 1-Fo(k.timeline,z)}(h)))}catch(k){b=CSS.percent(100),h.animationRange.end="normal",console.warn("Exception when calculating end offset",k)}h.rangeDuration=b.value-y.value;const C=An(h);h.startTime=Se(h,C>=0?y:b),h.holdTime=null,h.rangeDuration!==p&&Xo(h)}function rr(h){throw new Error("Unsupported timeline class")}function Zo(h){return h instanceof ViewTimeline?{rangeName:"cover",offset:CSS.percent(0)}:h instanceof $e?CSS.percent(0):void rr()}function Ko(h){return h instanceof ViewTimeline?{rangeName:"cover",offset:CSS.percent(100)}:h instanceof $e?CSS.percent(100):void rr()}function Vl(h,p){if(!p)return{start:"normal",end:"normal"};const y={start:Zo(h),end:Ko(h)};if(h instanceof ViewTimeline){const b=ke(p),C=[],k=[];if(b.forEach(z=>{if(tr.includes(z))C.push(z);else try{k.push(CSSNumericValue.parse(z))}catch{throw TypeError(`Could not parse range "${p}"`)}}),C.length>2||k.length>2||k.length==1)throw TypeError("Invalid time range or unsupported time range format.");return C.length&&(y.start.rangeName=C[0],y.end.rangeName=C.length>1?C[1]:C[0]),k.length>1&&(y.start.offset=k[0],y.end.offset=k[1]),y}if(h instanceof $e){const b=p.split(" ");if(b.length!=2)throw TypeError("Invalid time range or unsupported time range format.");return y.start=CSSNumericValue.parse(b[0]),y.end=CSSNumericValue.parse(b[1]),y}rr()}function sr(h,p,y){if(!p||p==="normal")return"normal";if(h instanceof ViewTimeline){let b="cover",C=y==="start"?CSS.percent(0):CSS.percent(100);if(p instanceof Object)p.rangeName!==void 0&&(b=p.rangeName),p.offset!==void 0&&(C=p.offset);else{const k=ke(p);k.length===1?tr.includes(k[0])?b=k[0]:C=ve(CSSNumericValue.parse(k[0]),{}):k.length===2&&(b=k[0],C=ve(CSSNumericValue.parse(k[1]),{}))}if(!tr.includes(b))throw TypeError("Invalid range name");return{rangeName:b,offset:C}}if(h instanceof $e)return CSSNumericValue.parse(p);rr()}class or{constructor(p,y,b={}){const C=y instanceof $e,k=p instanceof jo?p:new jo(p,C?void 0:y);Yo.set(k,this),Y.set(this,{animation:k,timeline:C?y:void 0,playState:C?"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:C?Vl(y,b["animation-range"]):null,proxy:this})}get effect(){const p=Y.get(this);return p.timeline?(p.effect||(p.effect=function(y){const b=y.animation.effect,C=b.updateTiming,k={apply:function(F){b.getTiming();const X=F.apply(b);if(y.timeline){const Z=y.duration??100;X.localTime=pn(y,X.localTime),X.endTime=pn(y,X.endTime),X.activeDuration=pn(y,X.activeDuration);const K=Wt(y),me=X.iterations?(K-X.delay-X.endDelay)/X.iterations:0;X.duration=K?CSS.percent(Z*me/K):CSS.percent(0),y.timeline.currentTime===void 0&&(X.localTime=null)}return X}},z={apply:function(F,X){if(y.specifiedTiming)return y.specifiedTiming;y.specifiedTiming=F.apply(b);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),C.apply(b,[K])),y.normalizedTiming=K,y.specifiedTiming}},D={apply:function(F,X,Z){if(Z&&Z.length){if(y.timeline&&Z[0]){const K=Z[0],me=K.duration;if(me===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");me!==void 0&&me!=="auto"&&(y.autoDurationEffect=null)}y.specifiedTiming&&F.apply(b,[y.specifiedTiming]),F.apply(b,Z),Xo(y)}}},N=new Proxy(b,{get:function(F,X){const Z=F[X];return typeof Z=="function"?Z.bind(b):Z},set:function(F,X,Z){return F[X]=Z,!0}});return N.getComputedTiming=new Proxy(b.getComputedTiming,k),N.getTiming=new Proxy(b.getTiming,z),N.updateTiming=new Proxy(b.updateTiming,D),N}(p)),p.effect):p.animation.effect}set effect(p){const y=Y.get(this);y.animation.effect=p,y.effect=null,y.autoDurationEffect=null}get timeline(){const p=Y.get(this);return p.timeline||p.animation.timeline}set timeline(p){const y=Y.get(this),b=this.timeline;if(b==p)return;const C=this.playState,k=this.currentTime;let z,D=Wt(y);z=k===null?null:D===0?0:Se(y,k)/D;const N=b instanceof $e,F=p instanceof $e,X=this.pending;if(N&&us(y.timeline,y.animation),F)return y.timeline=p,Bt(y),y.autoAlignStartTime=!0,y.startTime=null,y.holdTime=null,C!=="running"&&C!=="finished"||(y.readyPromise&&y.readyPromise.state!=="resolved"||ei(y),y.pendingTask="play",hs(y.timeline,y.animation,gs.bind(this))),C==="paused"&&z!==null&&(y.holdTime=z*D),X&&(y.readyPromise&&y.readyPromise.state!="resolved"||ei(y),y.pendingTask=C=="paused"?"pause":"play"),y.startTime!==null&&(y.holdTime=null),void Gt(y,!1,!1);if(y.animation.timeline!=p)throw TypeError("Unsupported timeline: "+p);if(us(y.timeline,y.animation),y.timeline=null,N)switch(k!==null&&(y.animation.currentTime=z*Wt(y)),C){case"paused":y.animation.pause();break;case"running":case"finished":y.animation.play()}}get startTime(){const p=Y.get(this);return p.timeline?pn(p,p.startTime):p.animation.startTime}set startTime(p){const y=Y.get(this);if(p=Se(y,p),!y.timeline)return void(y.animation.startTime=p);y.autoAlignStartTime=!1,Se(y,y.timeline.currentTime)==null&&y.startTime!=null&&(y.holdTime=null,Ht(y));const b=Se(y,this.currentTime);Bt(y),y.startTime=p,y.startTime!==null&&y.animation.playbackRate!=0?y.holdTime=null:y.holdTime=b,y.pendingTask&&(y.pendingTask=null,y.readyPromise.resolve(this)),Gt(y,!0,!1),Ht(y)}get currentTime(){const p=Y.get(this);return p.timeline?p.holdTime!=null?pn(p,p.holdTime):pn(p,qo(p)):p.animation.currentTime}set currentTime(p){const y=Y.get(this);y.timeline?(function(b,C){if(C==null&&b.currentTime!==null)throw new TypeError;C=Se(b,C),b.autoAlignStartTime=!1,b.holdTime!==null||b.startTime===null||b.timeline.phase==="inactive"||b.animation.playbackRate===0?b.holdTime=C:b.startTime=Se(b,b.timeline.currentTime)-C/b.animation.playbackRate,b.timeline.phase==="inactive"&&(b.startTime=null),b.previousCurrentTime=null}(y,p),y.pendingTask=="pause"&&(y.holdTime=Se(y,p),Bt(y),y.startTime=null,y.pendingTask=null,y.readyPromise.resolve(this)),Gt(y,!0,!1)):y.animation.currentTime=p}get playbackRate(){return Y.get(this).animation.playbackRate}set playbackRate(p){const y=Y.get(this);if(!y.timeline)return void(y.animation.playbackRate=p);y.pendingPlaybackRate=null;const b=this.currentTime;y.animation.playbackRate=p,b!==null&&(this.currentTime=b)}get playState(){const p=Y.get(this);if(!p.timeline)return p.animation.playState;const y=Se(p,this.currentTime);return y===null&&p.startTime===null&&p.pendingTask==null?"idle":p.pendingTask=="pause"||p.startTime===null&&p.pendingTask!="play"?"paused":y!=null&&(p.animation.playbackRate>0&&y>=Wt(p)||p.animation.playbackRate<0&&y<=0)?"finished":"running"}get rangeStart(){var p;return((p=Y.get(this).animationRange)==null?void 0:p.start)??"normal"}set rangeStart(p){const y=Y.get(this);if(!y.timeline)return y.animation.rangeStart=p;y.timeline instanceof $e&&(y.animationRange.start=sr(y.timeline,p,"start"),ir(y),Ht(y))}get rangeEnd(){var p;return((p=Y.get(this).animationRange)==null?void 0:p.end)??"normal"}set rangeEnd(p){const y=Y.get(this);if(!y.timeline)return y.animation.rangeEnd=p;y.timeline instanceof $e&&(y.animationRange.end=sr(y.timeline,p,"end"),ir(y),Ht(y))}get replaceState(){return Y.get(this).animation.pending}get pending(){const p=Y.get(this);return p.timeline?!!p.readyPromise&&p.readyPromise.state=="pending":p.animation.pending}finish(){const p=Y.get(this);if(!p.timeline)return void p.animation.finish();const y=An(p),b=Wt(p);if(y==0)throw new DOMException("Cannot finish Animation with a playbackRate of 0.","InvalidStateError");if(y>0&&b==1/0)throw new DOMException("Cannot finish Animation with an infinite target effect end.","InvalidStateError");Bt(p);const C=y<0?0:b;this.currentTime=pn(p,C);const k=Se(p,p.timeline.currentTime);p.startTime===null&&k!==null&&(p.startTime=k-C/p.animation.playbackRate),p.pendingTask=="pause"&&p.startTime!==null&&(p.holdTime=null,p.pendingTask=null,p.readyPromise.resolve(this)),p.pendingTask=="play"&&p.startTime!==null&&(p.pendingTask=null,p.readyPromise.resolve(this)),Gt(p,!0,!0)}play(){const p=Y.get(this);p.timeline?ys(p):p.animation.play()}pause(){const p=Y.get(this);p.timeline?this.playState!="paused"&&(p.animation.currentTime===null&&(p.autoAlignStartTime=!0),p.pendingTask=="play"?p.pendingTask=null:p.readyPromise=null,p.readyPromise||ei(p),p.pendingTask="pause",hs(p.timeline,p.animation,gs.bind(p.proxy))):p.animation.pause()}reverse(){const p=Y.get(this),y=An(p),b=Se(p,this.currentTime),C=Wt(p)==1/0,k=y!=0&&(y<0||b>0||!C);if(!p.timeline||!k)return k&&(p.pendingPlaybackRate=-An(p)),void p.animation.reverse();if(p.timeline.phase=="inactive")throw new DOMException("Cannot reverse an animation with no active timeline","InvalidStateError");this.updatePlaybackRate(-y),ys(p)}updatePlaybackRate(p){const y=Y.get(this);if(y.pendingPlaybackRate=p,!y.timeline)return void y.animation.updatePlaybackRate(p);const b=this.playState;if(!y.readyPromise||y.readyPromise.state!="pending")switch(b){case"idle":case"paused":Bt(y);break;case"finished":const C=Se(y,y.timeline.currentTime),k=C!==null?(C-y.startTime)*y.animation.playbackRate:null;y.startTime=p==0?C:C!=null&&k!=null?(C-k)/p:null,Bt(y),Gt(y,!1,!1),Ht(y);break;default:ys(y)}}persist(){Y.get(this).animation.persist()}get id(){return Y.get(this).animation.id}set id(p){Y.get(this).animation.id=p}cancel(){const p=Y.get(this);p.timeline?(this.playState!="idle"&&(function(y){y.pendingTask&&(y.pendingTask=null,Bt(y),y.readyPromise.reject(Jo()),ei(y),y.readyPromise.resolve(y.proxy))}(p),p.finishedPromise&&p.finishedPromise.state=="pending"&&p.finishedPromise.reject(Jo()),p.finishedPromise=new Rn,p.animation.cancel()),p.startTime=null,p.holdTime=null,us(p.timeline,p.animation)):p.animation.cancel()}get onfinish(){return Y.get(this).animation.onfinish}set onfinish(p){Y.get(this).animation.onfinish=p}get oncancel(){return Y.get(this).animation.oncancel}set oncancel(p){Y.get(this).animation.oncancel=p}get onremove(){return Y.get(this).animation.onremove}set onremove(p){Y.get(this).animation.onremove=p}get finished(){const p=Y.get(this);return p.timeline?(p.finishedPromise||(p.finishedPromise=new Rn),p.finishedPromise.promise):p.animation.finished}get ready(){const p=Y.get(this);return p.timeline?(p.readyPromise||(p.readyPromise=new Rn,p.readyPromise.resolve(this)),p.readyPromise.promise):p.animation.ready}addEventListener(p,y,b){Y.get(this).animation.addEventListener(p,y,b)}removeEventListener(p,y,b){Y.get(this).animation.removeEventListener(p,y,b)}dispatchEvent(p){Y.get(this).animation.dispatchEvent(p)}}function jl(h,p){const y=p.timeline;y instanceof $e&&delete p.timeline;const b=Fl.apply(this,[h,p]),C=new or(b,y);return y instanceof $e&&(b.pause(),Y.get(C).animationRange={start:sr(y,p.rangeStart,"start"),end:sr(y,p.rangeEnd,"end")},C.play()),C}function Qo(h){for(let p=0;p<h.length;++p){let y=Yo.get(h[p]);y&&(h[p]=y)}return h}function Jl(h){return Qo(Ll.apply(this,[h]))}function Gl(h){return Qo(Dl.apply(this,[h]))}const Oe={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\(([^)]*)\)/},On=["block","inline","x","y"],Wl=["nearest","root","self"],tn=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,p,y){const b={sheetSrc:h,index:0,name:y};for(;b.index<b.sheetSrc.length&&(this.eatWhitespace(b),!(b.index>=b.sheetSrc.length));){if(this.lookAhead("/*",b)){for(;this.lookAhead("/*",b);)this.eatComment(b),this.eatWhitespace(b);continue}const C=this.parseQualifiedRule(b);C&&(p?this.parseKeyframesAndSaveNameMapping(C,b):this.handleScrollTimelineProps(C,b))}return b.sheetSrc}getAnimationTimelineOptions(h,p){for(let y=this.cssRulesWithTimelineName.length-1;y>=0;y--){const b=this.cssRulesWithTimelineName[y];try{if(p.matches(b.selector)&&(!b["animation-name"]||b["animation-name"]==h))return{"animation-timeline":b["animation-timeline"],"animation-range":b["animation-range"]}}catch{}}return null}getAnonymousScrollTimelineOptions(h,p){const y=this.anonymousScrollTimelineOptions.get(h);return y?{anonymousSource:y.source,anonymousTarget:p,source:Do(y.source??"nearest",p),axis:y.axis?y.axis:"block"}:null}getScrollTimelineOptions(h,p){const y=this.getAnonymousScrollTimelineOptions(h,p);if(y)return y;for(let b=this.sourceSelectorToScrollTimeline.length-1;b>=0;b--){const C=this.sourceSelectorToScrollTimeline[b];if(C.name==h){const k=this.findPreviousSiblingOrAncestorMatchingSelector(p,C.selector);if(k)return{source:k,...C.axis?{axis:C.axis}:{}}}}return null}findPreviousSiblingOrAncestorMatchingSelector(h,p){let y=h;for(;y;){if(y.matches(p))return y;y=y.previousElementSibling||y.parentElement}return null}getAnonymousViewTimelineOptions(h,p){const y=this.anonymousViewTimelineOptions.get(h);return y?{subject:p,axis:y.axis?y.axis:"block",inset:y.inset?y.inset:"auto"}:null}getViewTimelineOptions(h,p){const y=this.getAnonymousViewTimelineOptions(h,p);if(y)return y;for(let b=this.subjectSelectorToViewTimeline.length-1;b>=0;b--){const C=this.subjectSelectorToViewTimeline[b];if(C.name==h){const k=this.findPreviousSiblingOrAncestorMatchingSelector(p,C.selector);if(k)return{subject:k,axis:C.axis,inset:C.inset}}}return null}handleScrollTimelineProps(h,p){if(h.selector.includes("@keyframes"))return;const y=h.block.contents.includes("animation-name:"),b=h.block.contents.includes("animation-timeline:"),C=h.block.contents.includes("animation:");if(this.saveSourceSelectorToScrollTimeline(h),this.saveSubjectSelectorToViewTimeline(h),!b&&!y&&!C)return;let k=[],z=[],D=!1;b&&(k=this.extractScrollTimelineNames(h.block.contents)),y&&(z=this.extractMatches(h.block.contents,Oe.ANIMATION_NAME)),b&&y||(C&&this.extractMatches(h.block.contents,Oe.ANIMATION).forEach(N=>{const F=this.extractAnimationName(N);F&&b&&z.push(F),b&&(this.hasDuration(N)||(this.hasAutoDuration(N)&&(h.block.contents=h.block.contents.replace("auto"," ")),h.block.contents=h.block.contents.replace(N," 1s "+N),D=!0))}),D&&this.replacePart(h.block.startIndex,h.block.endIndex,h.block.contents,p)),this.saveRelationInList(h,k,z)}saveSourceSelectorToScrollTimeline(h){const p=h.block.contents.includes("scroll-timeline:"),y=h.block.contents.includes("scroll-timeline-name:"),b=h.block.contents.includes("scroll-timeline-axis:");if(!p&&!y)return;let C=[];if(p){const z=this.extractMatches(h.block.contents,Oe.SCROLL_TIMELINE);for(const D of z){const N=this.split(D);let F={selector:h.selector,name:""};N.length==1?F.name=N[0]:N.length==2&&(On.includes(N[0])?(F.axis=N[0],F.name=N[1]):(F.axis=N[1],F.name=N[0])),C.push(F)}}if(y){const z=this.extractMatches(h.block.contents,Oe.SCROLL_TIMELINE_NAME);for(let D=0;D<z.length;D++)if(D<C.length)C[D].name=z[D];else{let N={selector:h.selector,name:z[D]};C.push(N)}}let k=[];if(b){const z=this.extractMatches(h.block.contents,Oe.SCROLL_TIMELINE_AXIS);if(k=z.filter(D=>On.includes(D)),k.length!=z.length)throw new Error("Invalid axis")}for(let z=0;z<C.length;z++)k.length&&(C[z].axis=k[z%C.length]);this.sourceSelectorToScrollTimeline.push(...C)}saveSubjectSelectorToViewTimeline(h){const p=h.block.contents.includes("view-timeline:"),y=h.block.contents.includes("view-timeline-name:"),b=h.block.contents.includes("view-timeline-axis:"),C=h.block.contents.includes("view-timeline-inset:");if(!p&&!y)return;let k=[];if(p){const N=this.extractMatches(h.block.contents,Oe.VIEW_TIMELINE);for(let F of N){const X=this.split(F);let Z={selector:h.selector,name:"",inset:null};X.length==1?Z.name=X[0]:X.length==2&&(On.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,Oe.VIEW_TIMELINE_NAME);for(let F=0;F<N.length;F++)if(F<k.length)k[F].name=N[F];else{let X={selector:h.selector,name:N[F],inset:null};k.push(X)}}let z=[],D=[];if(C&&(z=this.extractMatches(h.block.contents,Oe.VIEW_TIMELINE_INSET)),b){const N=this.extractMatches(h.block.contents,Oe.VIEW_TIMELINE_AXIS);if(D=N.filter(F=>On.includes(F)),D.length!=N.length)throw new Error("Invalid axis")}for(let N=0;N<k.length;N++)z.length&&(k[N].inset=z[N%k.length]),D.length&&(k[N].axis=D[N%k.length]);this.subjectSelectorToViewTimeline.push(...k)}hasDuration(h){return h.split(" ").filter(p=>{return y=p,Oe.TIME.exec(y);var y}).length>=1}hasAutoDuration(h){return h.split(" ").filter(p=>p==="auto").length>=1}saveRelationInList(h,p,y){let b=[];h.block.contents.includes("animation-range:")&&(b=this.extractMatches(h.block.contents,Oe.ANIMATION_TIME_RANGE));const C=Math.max(p.length,y.length,b.length);for(let k=0;k<C;k++)this.cssRulesWithTimelineName.push({selector:h.selector,"animation-timeline":p[k%p.length],...y.length?{"animation-name":y[k%y.length]}:{},...b.length?{"animation-range":b[k%b.length]}:{}})}extractScrollTimelineNames(h){const p=Oe.ANIMATION_TIMELINE.exec(h)[1].trim(),y=[];return p.split(",").map(b=>b.trim()).forEach(b=>{if(function(C){return(C.startsWith("scroll")||C.startsWith("view"))&&C.includes("(")}(b)){const C=this.saveAnonymousTimelineName(b);y.push(C)}else y.push(b)}),y}saveAnonymousTimelineName(h){const p=":t"+this.nextAnonymousTimelineNameIndex++;return h.startsWith("scroll(")?this.anonymousScrollTimelineOptions.set(p,this.parseAnonymousScrollTimeline(h)):this.anonymousViewTimelineOptions.set(p,this.parseAnonymousViewTimeline(h)),p}parseAnonymousScrollTimeline(h){const p=Oe.ANONYMOUS_SCROLL_TIMELINE.exec(h);if(!p)return null;const y=p[1],b={};return y.split(" ").forEach(C=>{On.includes(C)?b.axis=C:Wl.includes(C)&&(b.source=C)}),b}parseAnonymousViewTimeline(h){const p=Oe.ANONYMOUS_VIEW_TIMELINE.exec(h);if(!p)return null;const y=p[1],b={};return y.split(" ").forEach(C=>{On.includes(C)?b.axis=C:b.inset=b.inset?`${b.inset} ${C}`:C}),b}extractAnimationName(h){return this.findMatchingEntryInContainer(h,this.keyframeNamesSelectors)}findMatchingEntryInContainer(h,p){const y=h.split(" ").filter(b=>p.has(b));return y?y[0]:null}parseIdentifier(h){Oe.IDENTIFIER.lastIndex=h.index;const p=Oe.IDENTIFIER.exec(h.sheetSrc);if(!p)throw this.parseError(h,"Expected an identifier");return h.index+=p[0].length,p[0]}parseKeyframesAndSaveNameMapping(h,p){if(h.selector.startsWith("@keyframes")){const y=this.replaceKeyframesAndGetMapping(h,p);h.selector.split(" ").forEach((b,C)=>{C>0&&this.keyframeNamesSelectors.set(b,y)})}}replaceKeyframesAndGetMapping(h,p){function y(N){return tr.some(F=>N.startsWith(F))}const b=h.block.contents,C=function(N){let F=0,X=-1,Z=-1;const K=[];for(let me=0;me<N.length;me++)N[me]=="{"?F++:N[me]=="}"&&F--,F==1&&N[me]!="{"&&N[me]!="}"&&X==-1&&(X=me),F==2&&N[me]=="{"&&(Z=me,K.push({start:X,end:Z}),X=Z=-1);return K}(b);if(C.length==0)return new Map;const k=new Map;let z=!1;const D=[];D.push(b.substring(0,C[0].start));for(let N=0;N<C.length;N++){const F=b.substring(C[N].start,C[N].end);let X=[];F.split(",").forEach(Z=>{const K=Z.split(" ").map(_e=>_e.trim()).filter(_e=>_e!="").join(" "),me=k.size;k.set(me,K),X.push(`${me}%`),y(K)&&(z=!0)}),D.push(X.join(",")),N==C.length-1?D.push(b.substring(C[N].end)):D.push(b.substring(C[N].end,C[N+1].start))}return z?(h.block.contents=D.join(""),this.replacePart(h.block.startIndex,h.block.endIndex,h.block.contents,p),k):new Map}parseQualifiedRule(h){const p=h.index,y=this.parseSelector(h).trim();if(y)return{selector:y,block:this.eatBlock(h),startIndex:p,endIndex:h.index}}removeEnclosingDoubleQuotes(h){let p=h[0]=='"'?1:0,y=h[h.length-1]=='"'?h.length-1:h.length;return h.substring(p,y)}assertString(h,p){if(h.sheetSrc.substr(h.index,p.length)!=p)throw this.parseError(h,`Did not find expected sequence ${p}`);h.index+=p.length}replacePart(h,p,y,b){if(b.sheetSrc=b.sheetSrc.slice(0,h)+y+b.sheetSrc.slice(p),b.index>=p){const C=b.index-p;b.index=h+y.length+C}}eatComment(h){this.assertString(h,"/*"),this.eatUntil("*/",h,!0),this.assertString(h,"*/")}eatBlock(h){const p=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 b=h.index;return{startIndex:p,endIndex:b,contents:h.sheetSrc.slice(p,b)}}advance(h){if(h.index++,h.index>h.sheetSrc.length)throw this.parseError(h,"Advanced beyond the end")}parseError(h,p){return Error(`(${h.name?h.name:"<anonymous file>"}): ${p}`)}eatUntil(h,p,y=!1){const b=p.index;for(;!this.lookAhead(h,p);)this.advance(p);return y&&(p.sheetSrc=p.sheetSrc.slice(0,b)+" ".repeat(p.index-b)+p.sheetSrc.slice(p.index)),p.sheetSrc.slice(b,p.index)}parseSelector(h){let p=h.index;if(this.eatUntil("{",h),p===h.index)throw Error("Empty selector");return h.sheetSrc.slice(p,h.index)}eatWhitespace(h){Oe.WHITE_SPACE.lastIndex=h.index;const p=Oe.WHITE_SPACE.exec(h.sheetSrc);p&&(h.index+=p[0].length)}lookAhead(h,p){return p.sheetSrc.substr(p.index,h.length)==h}peek(h){return h.sheetSrc[h.index]}extractMatches(h,p,y=","){return p.exec(h)[1].trim().split(y).map(b=>b.trim())}split(h){return h.split(" ").map(p=>p.trim()).filter(p=>p!="")}};function Hl(h,p,y,b,C,k){const z=cs(p),D=ls(p,y);return Vo(fs(h,z,D,b,C),k,fs("cover",z,D,b,C),y)}function ql(h,p,y){const b=tn.getAnimationTimelineOptions(p,y);if(!b)return null;const C=b["animation-timeline"];if(!C)return null;let k=tn.getScrollTimelineOptions(C,y)||tn.getViewTimelineOptions(C,y);return k?(k.subject&&function(z,D){const N=ps(D.subject),F=D.axis||D.axis;function X(K,me){let _e=null;for(const[ot,Pt]of K)if(ot==100*me.offset){if(Pt=="from")_e=0;else if(Pt=="to")_e=100;else{const gt=Pt.split(" ");_e=gt.length==1?parseFloat(gt[0]):100*Hl(gt[0],N,D.subject,F,D.inset,CSS.percent(parseFloat(gt[1])))}break}return _e}const Z=tn.keyframeNamesSelectors.get(z.animationName);if(Z&&Z.size){const K=[];z.effect.getKeyframes().forEach(_e=>{const ot=X(Z,_e);ot!==null&&ot>=0&&ot<=100&&(_e.offset=ot/100,K.push(_e))});const me=K.sort((_e,ot)=>_e.offset<ot.offset?-1:_e.affset>ot.offset?1:0);z.effect.setKeyframes(me)}}(h,k),{timeline:k.source?new $e(k):new kn(k),animOptions:b}):null}function Xl(){if(CSS.supports("animation-timeline: --works"))return!0;(function(){function p(b){if(b.innerHTML.trim().length===0||"aphrodite"in b.dataset)return;let C=tn.transpileStyleSheet(b.innerHTML,!0);C=tn.transpileStyleSheet(C,!1),b.innerHTML=C}function y(b){b.type!="text/css"&&b.rel!="stylesheet"||!b.href||new URL(b.href,document.baseURI).origin==location.origin&&fetch(b.getAttribute("href")).then(async C=>{const k=await C.text();let z=tn.transpileStyleSheet(k,!0);if(z=tn.transpileStyleSheet(k,!1),z!=k){const D=new Blob([z],{type:"text/css"}),N=URL.createObjectURL(D);b.setAttribute("href",N)}})}new MutationObserver(b=>{for(const C of b)for(const k of C.addedNodes)k instanceof HTMLStyleElement&&p(k),k instanceof HTMLLinkElement&&y(k)}).observe(document.documentElement,{childList:!0,subtree:!0}),document.querySelectorAll("style").forEach(b=>p(b)),document.querySelectorAll("link").forEach(b=>y(b))})();const h=CSS.supports;CSS.supports=p=>(p=p.replaceAll(/(animation-timeline|scroll-timeline(-(name|axis))?|view-timeline(-(name|axis|inset))?|timeline-scope)\s*:/g,"--supported-property:"),h(p)),window.addEventListener("animationstart",p=>{p.target.getAnimations().filter(y=>y.animationName===p.animationName).forEach(y=>{const b=ql(y,y.animationName,p.target);if(b)if(!b.timeline||y instanceof or)y.timeline=b.timeline;else{const C=new or(y,b.timeline,b.animOptions);y.pause(),C.play()}})})}(function(){if(!Xl()){if(!Reflect.defineProperty(window,"ScrollTimeline",{value:$e}))throw Error("Error installing ScrollTimeline polyfill: could not attach ScrollTimeline to window");if(!Reflect.defineProperty(window,"ViewTimeline",{value:kn}))throw Error("Error installing ViewTimeline polyfill: could not attach ViewTimeline to window");if(!Reflect.defineProperty(Element.prototype,"animate",{value:jl}))throw Error("Error installing ScrollTimeline polyfill: could not attach WAAPI's animate to DOM Element");if(!Reflect.defineProperty(window,"Animation",{value:or}))throw Error("Error installing Animation constructor.");if(!Reflect.defineProperty(Element.prototype,"getAnimations",{value:Jl}))throw Error("Error installing ScrollTimeline polyfill: could not attach WAAPI's getAnimations to DOM Element");if(!Reflect.defineProperty(document,"getAnimations",{value:Gl}))throw Error("Error installing ScrollTimeline polyfill: could not attach WAAPI's getAnimations to document")}})()})();class Rd{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 ce;(function(r){r.open="open",r.close="close",r.error="error",r.message="message",r.retry="retry",r.reconnect="reconnect"})(ce||(ce={}));class el{constructor(e,t,n){var i,s,a,o,c,l,u,d,f,m,x,_,g,v,w;this._closedByUser=!1,this.handleOpenEvent=S=>this.handleEvent(ce.open,S),this.handleErrorEvent=S=>this.handleEvent(ce.error,S),this.handleCloseEvent=S=>this.handleEvent(ce.close,S),this.handleMessageEvent=S=>this.handleEvent(ce.message,S),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=(d=n?.listeners)===null||d===void 0?void 0:d.error)!==null&&f!==void 0?f:[]],message:[...(x=(m=n?.listeners)===null||m===void 0?void 0:m.message)!==null&&x!==void 0?x:[]],retry:[...(g=(_=n?.listeners)===null||_===void 0?void 0:_.retry)!==null&&g!==void 0?g:[]],reconnect:[...(w=(v=n?.listeners)===null||v===void 0?void 0:v.reconnect)!==null&&w!==void 0?w:[]]}},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(ce.open,this.handleOpenEvent),this._underlyingWebsocket.addEventListener(ce.close,this.handleCloseEvent),this._underlyingWebsocket.addEventListener(ce.error,this.handleErrorEvent),this._underlyingWebsocket.addEventListener(ce.message,this.handleMessageEvent),this._underlyingWebsocket}clearWebsocket(){this._underlyingWebsocket.removeEventListener(ce.open,this.handleOpenEvent),this._underlyingWebsocket.removeEventListener(ce.close,this.handleCloseEvent),this._underlyingWebsocket.removeEventListener(ce.error,this.handleErrorEvent),this._underlyingWebsocket.removeEventListener(ce.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 ce.close:this.dispatchEvent(e,t),this.scheduleConnectionRetryIfNeeded();break;case ce.open:if(this.backoff!==void 0&&this._lastConnection!==void 0){const n={retries:this.backoff.retries,lastConnection:new Date(this._lastConnection)},i=new CustomEvent(ce.reconnect,{detail:n});this.dispatchEvent(ce.reconnect,i),this.backoff.reset()}this._lastConnection=new Date,this.dispatchEvent(e,t),this.sendBufferedData();break;case ce.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(ce.retry,{detail:n});this.handleEvent(ce.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 Ad{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(ce.open,e,t),this}onClose(e,t){return this.addListener(ce.close,e,t),this}onError(e,t){return this.addListener(ce.error,e,t),this}onMessage(e,t){return this.addListener(ce.message,e,t),this}onRetry(e,t){return this.addListener(ce.retry,e,t),this}onReconnect(e,t){return this.addListener(ce.reconnect,e,t),this}build(){return new el(this._url,this._protocols,this._options)}addListener(e,t,n){var i,s,a,o,c,l,u,d,f,m,x,_,g,v,w,S,T,M,P,E,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=(d=(u=this._options)===null||u===void 0?void 0:u.listeners)===null||d===void 0?void 0:d.error)!==null&&f!==void 0?f:[],message:(_=(x=(m=this._options)===null||m===void 0?void 0:m.listeners)===null||x===void 0?void 0:x.message)!==null&&_!==void 0?_:[],retry:(w=(v=(g=this._options)===null||g===void 0?void 0:g.listeners)===null||v===void 0?void 0:v.retry)!==null&&w!==void 0?w:[],reconnect:(M=(T=(S=this._options)===null||S===void 0?void 0:S.listeners)===null||T===void 0?void 0:T.reconnect)!==null&&M!==void 0?M:[],[e]:[...(O=(E=(P=this._options)===null||P===void 0?void 0:P.listeners)===null||E===void 0?void 0:E[e])!==null&&O!==void 0?O:[],{listener:t,options:n}]}}),this}}const Od=Object.freeze(Object.defineProperty({__proto__:null,ExponentialBackoff:Rd,Websocket:el,WebsocketBuilder:Ad,get WebsocketEvent(){return ce}},Symbol.toStringTag,{value:"Module"})),no=0,tl=1,nl=2,io=2,ro=1.25,il=1,qe=32,Pe=qe/4,rl=65535,Or=Math.pow(2,-24),Ir=Symbol("SKIP_GENERATION"),sl={strategy:no,maxDepth:40,maxLeafSize:10,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,indirect:!1,verbose:!0,range:null,[Ir]:!1};function be(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 ol(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 al(r,e){e.set(r)}function cl(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 Br(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 fi(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)}function Ee(r,e){return e[r+15]===rl}function Xe(r,e){return e[r+6]}function it(r,e){return e[r+14]}function ze(r){return r+Pe}function Ne(r,e){const t=e[r+6];return r+t*Pe}function so(r,e){return e[r+7]}function oo(r,e,t,n,i){let s=1/0,a=1/0,o=1/0,c=-1/0,l=-1/0,u=-1/0,d=1/0,f=1/0,m=1/0,x=-1/0,_=-1/0,g=-1/0;const v=r.offset||0;for(let w=(e-v)*6,S=(e+t-v)*6;w<S;w+=6){const T=r[w+0],M=r[w+1],P=T-M,E=T+M;P<s&&(s=P),E>c&&(c=E),T<d&&(d=T),T>x&&(x=T);const O=r[w+2],A=r[w+3],R=O-A,B=O+A;R<a&&(a=R),B>l&&(l=B),O<f&&(f=O),O>_&&(_=O);const I=r[w+4],U=r[w+5],L=I-U,J=I+U;L<o&&(o=L),J>u&&(u=J),I<m&&(m=I),I>g&&(g=I)}n[0]=s,n[1]=a,n[2]=o,n[3]=c,n[4]=l,n[5]=u,i[0]=d,i[1]=f,i[2]=m,i[3]=x,i[4]=_,i[5]=g}const Kt=32,Id=(r,e)=>r.candidate-e.candidate,an=new Array(Kt).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),zr=new Float32Array(6);function Bd(r,e,t,n,i,s){let a=-1,o=0;if(s===no)a=ol(e),a!==-1&&(o=(e[a]+e[a+3])/2);else if(s===tl)a=ol(r),a!==-1&&(o=zd(t,n,i,a));else if(s===nl){const c=fi(r);let l=ro*i;const u=t.offset||0,d=(n-u)*6,f=(n+i-u)*6;for(let m=0;m<3;m++){const x=e[m],_=(e[m+3]-x)/Kt;if(i<Kt/4){const g=[...an];g.length=i;let v=0;for(let S=d;S<f;S+=6,v++){const T=g[v];T.candidate=t[S+2*m],T.count=0;const{bounds:M,leftCacheBounds:P,rightCacheBounds:E}=T;for(let O=0;O<3;O++)E[O]=1/0,E[O+3]=-1/0,P[O]=1/0,P[O+3]=-1/0,M[O]=1/0,M[O+3]=-1/0;Br(S,t,M)}g.sort(Id);let w=i;for(let S=0;S<w;S++){const T=g[S];for(;S+1<w&&g[S+1].candidate===T.candidate;)g.splice(S+1,1),w--}for(let S=d;S<f;S+=6){const T=t[S+2*m];for(let M=0;M<w;M++){const P=g[M];T>=P.candidate?Br(S,t,P.rightCacheBounds):(Br(S,t,P.leftCacheBounds),P.count++)}}for(let S=0;S<w;S++){const T=g[S],M=T.count,P=i-T.count,E=T.leftCacheBounds,O=T.rightCacheBounds;let A=0;M!==0&&(A=fi(E)/c);let R=0;P!==0&&(R=fi(O)/c);const B=il+ro*(A*M+R*P);B<l&&(a=m,l=B,o=T.candidate)}}else{for(let w=0;w<Kt;w++){const S=an[w];S.count=0,S.candidate=x+_+w*_;const T=S.bounds;for(let M=0;M<3;M++)T[M]=1/0,T[M+3]=-1/0}for(let w=d;w<f;w+=6){let S=~~((t[w+2*m]-x)/_);S>=Kt&&(S=Kt-1);const T=an[S];T.count++,Br(w,t,T.bounds)}const g=an[Kt-1];al(g.bounds,g.rightCacheBounds);for(let w=Kt-2;w>=0;w--){const S=an[w],T=an[w+1];cl(S.bounds,T.rightCacheBounds,S.rightCacheBounds)}let v=0;for(let w=0;w<Kt-1;w++){const S=an[w],T=S.count,M=S.bounds,P=an[w+1].rightCacheBounds;T!==0&&(v===0?al(M,zr):cl(M,zr,zr)),v+=T;let E=0,O=0;v!==0&&(E=fi(zr)/c);const A=i-v;A!==0&&(O=fi(P)/c);const R=il+ro*(E*v+O*A);R<l&&(a=m,l=R,o=S.candidate)}}}}else console.warn(`BVH: Invalid build strategy value ${s} used.`);return{axis:a,pos:o}}function zd(r,e,t,n){let i=0;const s=r.offset;for(let a=e,o=e+t;a<o;a++)i+=r[(a-s)*6+n*2];return i/t}class ao{constructor(){this.boundingData=new Float32Array(6)}}function Nd(r,e,t,n,i,s){let a=n,o=n+i-1;const c=s.pos,l=s.axis*2,u=t.offset||0;for(;;){for(;a<=o&&t[(a-u)*6+l]<c;)a++;for(;a<=o&&t[(o-u)*6+l]>=c;)o--;if(a<o){for(let d=0;d<e;d++){let f=r[a*e+d];r[a*e+d]=r[o*e+d],r[o*e+d]=f}for(let d=0;d<6;d++){const f=a-u,m=o-u,x=t[f*6+d];t[f*6+d]=t[m*6+d],t[m*6+d]=x}a++,o--}else return a}}let ll,Nr,co,ul;const Ud=Math.pow(2,32);function lo(r){return"count"in r?1:1+lo(r.left)+lo(r.right)}function Dd(r,e,t){return ll=new Float32Array(t),Nr=new Uint32Array(t),co=new Uint16Array(t),ul=new Uint8Array(t),uo(r,e)}function uo(r,e){const t=r/4,n=r/2,i="count"in e,s=e.boundingData;for(let a=0;a<6;a++)ll[t+a]=s[a];if(i)return e.buffer?(ul.set(new Uint8Array(e.buffer),r),r+e.buffer.byteLength):(Nr[t+6]=e.offset,co[n+14]=e.count,co[n+15]=rl,r+qe);{const{left:a,right:o,splitAxis:c}=e,l=r+qe;let u=uo(l,a);const d=r/qe,f=u/qe-d;if(f>Ud)throw new Error("MeshBVH: Cannot store relative child node offset greater than 32 bits.");return Nr[t+6]=f,Nr[t+7]=c,uo(u,o)}}function Ld(r,e,t,n,i){const{maxDepth:s,verbose:a,maxLeafSize:o,strategy:c,onProgress:l}=i,u=r.primitiveBuffer,d=r.primitiveBufferStride,f=new Float32Array(6);let m=!1;const x=new ao;return oo(e,t,n,x.boundingData,f),g(x,t,n,f),x;function _(v){l&&l(v/n)}function g(v,w,S,T=null,M=0){if(!m&&M>=s&&(m=!0,a&&console.warn(`BVH: Max depth of ${s} reached when generating BVH. Consider increasing maxDepth.`)),S<=o||M>=s)return _(w+S),v.offset=w,v.count=S,v;const P=Bd(v.boundingData,T,e,w,S,c);if(P.axis===-1)return _(w+S),v.offset=w,v.count=S,v;const E=Nd(u,d,e,w,S,P);if(E===w||E===w+S)_(w+S),v.offset=w,v.count=S;else{v.splitAxis=P.axis;const O=new ao,A=w,R=E-w;v.left=O,oo(e,A,R,O.boundingData,f),g(O,A,R,f,M+1);const B=new ao,I=E,U=S-R;v.right=B,oo(e,I,U,B.boundingData,f),g(B,I,U,f,M+1)}return v}}function Fd(r,e){const t=e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,n=r.getRootRanges(e.range),i=n[0],s=n[n.length-1],a={offset:i.offset,count:s.offset+s.count-i.offset},o=new Float32Array(6*a.count);o.offset=a.offset,r.computePrimitiveBounds(a.offset,a.count,o),r._roots=n.map(c=>{const l=Ld(r,o,c.offset,c.count,e),u=lo(l),d=new t(qe*u);return Dd(0,l,d),d})}class ho{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 Vd{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 ye=new Vd;let cn,Un;const Dn=[],Ur=new ho(()=>new zt);function jd(r,e,t,n,i,s){cn=Ur.getPrimitive(),Un=Ur.getPrimitive(),Dn.push(cn,Un),ye.setBuffer(r._roots[e]);const a=po(0,r.geometry,t,n,i,s);ye.clearBuffer(),Ur.releasePrimitive(cn),Ur.releasePrimitive(Un),Dn.pop(),Dn.pop();const o=Dn.length;return o>0&&(Un=Dn[o-1],cn=Dn[o-2]),a}function po(r,e,t,n,i=null,s=0,a=0){const{float32Array:o,uint16Array:c,uint32Array:l}=ye;let u=r*2;if(Ee(u,c)){const d=Xe(r,l),f=it(u,c);return be(r,o,cn),n(d,f,!1,a,s+r/Pe,cn)}else{let d=function(B){const{uint16Array:I,uint32Array:U}=ye;let L=B*2;for(;!Ee(L,I);)B=ze(B),L=B*2;return Xe(B,U)},f=function(B){const{uint16Array:I,uint32Array:U}=ye;let L=B*2;for(;!Ee(L,I);)B=Ne(B,U),L=B*2;return Xe(B,U)+it(L,I)};const m=ze(r),x=Ne(r,l);let _=m,g=x,v,w,S,T;if(i&&(S=cn,T=Un,be(_,o,S),be(g,o,T),v=i(S),w=i(T),w<v)){_=x,g=m;const B=v;v=w,w=B,S=T}S||(S=cn,be(_,o,S));const M=Ee(_*2,c),P=t(S,M,v,a+1,s+_/Pe);let E;if(P===io){const B=d(_),I=f(_)-B;E=n(B,I,!0,a+1,s+_/Pe,S)}else E=P&&po(_,e,t,n,i,s,a+1);if(E)return!0;T=Un,be(g,o,T);const O=Ee(g*2,c),A=t(T,O,w,a+1,s+g/Pe);let R;if(A===io){const B=d(g),I=f(g)-B;R=n(B,I,!0,a+1,s+g/Pe,T)}else R=A&&po(g,e,t,n,i,s,a+1);return!!R}}const mi=new ye.constructor,Dr=new ye.constructor,ln=new ho(()=>new zt),Ln=new zt,Fn=new zt,fo=new zt,mo=new zt;let yo=!1;function Jd(r,e,t,n){if(yo)throw new Error("MeshBVH: Recursive calls to bvhcast not supported.");yo=!0;const i=r._roots,s=e._roots;let a,o=0,c=0;const l=new kt().copy(t).invert();for(let u=0,d=i.length;u<d;u++){mi.setBuffer(i[u]),c=0;const f=ln.getPrimitive();be(0,mi.float32Array,f),f.applyMatrix4(l);for(let m=0,x=s.length;m<x&&(Dr.setBuffer(s[m]),a=Ot(0,0,t,l,n,o,c,0,0,f),Dr.clearBuffer(),c+=s[m].byteLength/qe,!a);m++);if(ln.releasePrimitive(f),mi.clearBuffer(),o+=i[u].byteLength/qe,a)break}return yo=!1,a}function Ot(r,e,t,n,i,s=0,a=0,o=0,c=0,l=null,u=!1){let d,f;u?(d=Dr,f=mi):(d=mi,f=Dr);const m=d.float32Array,x=d.uint32Array,_=d.uint16Array,g=f.float32Array,v=f.uint32Array,w=f.uint16Array,S=r*2,T=e*2,M=Ee(S,_),P=Ee(T,w);let E=!1;if(P&&M)u?E=i(Xe(e,v),it(e*2,w),Xe(r,x),it(r*2,_),c,a+e/Pe,o,s+r/Pe):E=i(Xe(r,x),it(r*2,_),Xe(e,v),it(e*2,w),o,s+r/Pe,c,a+e/Pe);else if(P){const O=ln.getPrimitive();be(e,g,O),O.applyMatrix4(t);const A=ze(r),R=Ne(r,x);be(A,m,Ln),be(R,m,Fn);const B=O.intersectsBox(Ln),I=O.intersectsBox(Fn);E=B&&Ot(e,A,n,t,i,a,s,c,o+1,O,!u)||I&&Ot(e,R,n,t,i,a,s,c,o+1,O,!u),ln.releasePrimitive(O)}else{const O=ze(e),A=Ne(e,v);be(O,g,fo),be(A,g,mo);const R=l.intersectsBox(fo),B=l.intersectsBox(mo);if(R&&B)E=Ot(r,O,t,n,i,s,a,o,c+1,l,u)||Ot(r,A,t,n,i,s,a,o,c+1,l,u);else if(R)if(M)E=Ot(r,O,t,n,i,s,a,o,c+1,l,u);else{const I=ln.getPrimitive();I.copy(fo).applyMatrix4(t);const U=ze(r),L=Ne(r,x);be(U,m,Ln),be(L,m,Fn);const J=I.intersectsBox(Ln),H=I.intersectsBox(Fn);E=J&&Ot(O,U,n,t,i,a,s,c,o+1,I,!u)||H&&Ot(O,L,n,t,i,a,s,c,o+1,I,!u),ln.releasePrimitive(I)}else if(B)if(M)E=Ot(r,A,t,n,i,s,a,o,c+1,l,u);else{const I=ln.getPrimitive();I.copy(mo).applyMatrix4(t);const U=ze(r),L=Ne(r,x);be(U,m,Ln),be(L,m,Fn);const J=I.intersectsBox(Ln),H=I.intersectsBox(Fn);E=J&&Ot(A,U,n,t,i,a,s,c,o+1,I,!u)||H&&Ot(A,L,n,t,i,a,s,c,o+1,I,!u),ln.releasePrimitive(I)}}return E}const hl=new zt,Vn=new Float32Array(6);class dl{constructor(){this._roots=null,this.primitiveBuffer=null,this.primitiveBufferStride=null}init(e){e={...sl,...e},Fd(this,e)}getRootRanges(){throw new Error("BVH: getRootRanges() not implemented")}writePrimitiveBounds(){throw new Error("BVH: writePrimitiveBounds() not implemented")}writePrimitiveRangeBounds(e,t,n,i){let s=1/0,a=1/0,o=1/0,c=-1/0,l=-1/0,u=-1/0;for(let d=e,f=e+t;d<f;d++){this.writePrimitiveBounds(d,Vn,0);const[m,x,_,g,v,w]=Vn;m<s&&(s=m),g>c&&(c=g),x<a&&(a=x),v>l&&(l=v),_<o&&(o=_),w>u&&(u=w)}return n[i+0]=s,n[i+1]=a,n[i+2]=o,n[i+3]=c,n[i+4]=l,n[i+5]=u,n}computePrimitiveBounds(e,t,n){const i=n.offset||0;for(let s=e,a=e+t;s<a;s++){this.writePrimitiveBounds(s,Vn,0);const[o,c,l,u,d,f]=Vn,m=(o+u)/2,x=(c+d)/2,_=(l+f)/2,g=(u-o)/2,v=(d-c)/2,w=(f-l)/2,S=(s-i)*6;n[S+0]=m,n[S+1]=g+(Math.abs(m)+g)*Or,n[S+2]=x,n[S+3]=v+(Math.abs(x)+v)*Or,n[S+4]=_,n[S+5]=w+(Math.abs(_)+w)*Or}return n}shiftPrimitiveOffsets(e){const t=this._indirectBuffer;if(t)for(let n=0,i=t.length;n<i;n++)t[n]+=e;else{const n=this._roots;for(let i=0;i<n.length;i++){const s=n[i],a=new Uint32Array(s),o=new Uint16Array(s),c=s.byteLength/qe;for(let l=0;l<c;l++){const u=Pe*l,d=2*u;Ee(d,o)&&(a[u+6]+=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=Ee(l,s);if(u){const d=i[o+6],f=s[l+14];e(c,u,new Float32Array(n,o*4,6),d,f)}else{const d=ze(o),f=Ne(o,i),m=so(o,i);e(c,u,new Float32Array(n,o*4,6),m)||(a(d,c+1),a(f,c+1))}}}refit(){const e=this._roots;for(let t=0,n=e.length;t<n;t++){const i=e[t],s=new Uint32Array(i),a=new Uint16Array(i),o=new Float32Array(i),c=i.byteLength/qe;for(let l=c-1;l>=0;l--){const u=l*Pe,d=u*2;if(Ee(d,a)){const f=Xe(u,s),m=it(d,a);this.writePrimitiveRangeBounds(f,m,Vn,0),o.set(Vn,u)}else{const f=ze(u),m=Ne(u,s);for(let x=0;x<3;x++){const _=o[f+x],g=o[f+x+3],v=o[m+x],w=o[m+x+3];o[u+x]=_<v?_:v,o[u+x+3]=g>w?g:w}}}}}getBoundingBox(e){return e.makeEmpty(),this._roots.forEach(t=>{be(0,new Float32Array(t),hl),e.union(hl)}),e}shapecast(e){let{boundsTraverseOrder:t,intersectsBounds:n,intersectsRange:i,intersectsPrimitive:s,scratchPrimitive:a,iterate:o}=e;if(i&&s){const d=i;i=(f,m,x,_,g)=>d(f,m,x,_,g)?!0:o(f,m,this,s,x,_,a)}else i||(s?i=(d,f,m,x)=>o(d,f,this,s,m,x,a):i=(d,f,m)=>m);let c=!1,l=0;const u=this._roots;for(let d=0,f=u.length;d<f;d++){const m=u[d];if(c=jd(this,d,n,i,t,l),c)break;l+=m.byteLength/qe}return c}bvhcast(e,t,n){let{intersectsRanges:i}=n;return Jd(this,e,t,i)}}function Gd(){return typeof SharedArrayBuffer<"u"}function go(r){return r.index?r.index.count:r.attributes.position.count}function Lr(r){return go(r)/3}function Wd(r,e=ArrayBuffer){return r>65535?new Uint32Array(new e(4*r)):new Uint16Array(new e(2*r))}function Hd(r,e){if(!r.index){const t=r.attributes.position.count,n=e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,i=Wd(t,n);r.setIndex(new dt(i,1));for(let s=0;s<t;s++)i[s]=s}}function qd(r,e,t){const n=go(r)/t,i=e||r.drawRange,s=i.start/t,a=(i.start+i.count)/t,o=Math.max(0,s),c=Math.min(n,a)-o;return{offset:Math.floor(o),count:Math.floor(c)}}function Xd(r,e){return r.groups.map(t=>({offset:t.start/e,count:t.count/e}))}function pl(r,e,t){const n=qd(r,e,t),i=Xd(r,t);if(!i.length)return[n];const s=[],a=n.offset,o=n.offset+n.count,c=go(r)/t,l=[];for(const f of i){const{offset:m,count:x}=f,_=m,g=isFinite(x)?x:c-m,v=m+g;_<o&&v>a&&(l.push({pos:Math.max(a,_),isStart:!0}),l.push({pos:Math.min(o,v),isStart:!1}))}l.sort((f,m)=>f.pos!==m.pos?f.pos-m.pos:f.type==="end"?-1:1);let u=0,d=null;for(const f of l){const m=f.pos;u!==0&&m!==d&&s.push({offset:d,count:m-d}),u+=f.isStart?1:-1,d=m}return s}function fl(r,e){const t=r[r.length-1],n=t.offset+t.count>2**16,i=r.reduce((l,u)=>l+u.count,0),s=n?4:2,a=e?new SharedArrayBuffer(i*s):new ArrayBuffer(i*s),o=n?new Uint32Array(a):new Uint16Array(a);let c=0;for(let l=0;l<r.length;l++){const{offset:u,count:d}=r[l];for(let f=0;f<d;f++)o[c+f]=u+f;c+=d}return o}class ml extends dl{get indirect(){return!!this._indirectBuffer}get primitiveStride(){return null}get primitiveBufferStride(){return this.indirect?1:this.primitiveStride}set primitiveBufferStride(e){}get primitiveBuffer(){return this.indirect?this._indirectBuffer:this.geometry.index.array}set primitiveBuffer(e){}constructor(e,t={}){if(e.isBufferGeometry){if(e.index&&e.index.isInterleavedBufferAttribute)throw new Error("BVH: InterleavedBufferAttribute is not supported for the index attribute.")}else throw new Error("BVH: Only BufferGeometries are supported.");if(t.useSharedArrayBuffer&&!Gd())throw new Error("BVH: SharedArrayBuffer is not available.");super(),this.geometry=e,this.resolvePrimitiveIndex=t.indirect?n=>this._indirectBuffer[n]:n=>n,this.primitiveBuffer=null,this.primitiveBufferStride=null,this._indirectBuffer=null,t={...sl,...t},t[Ir]||this.init(t)}init(e){const{geometry:t,primitiveStride:n}=this;if(e.indirect){const i=pl(t,e.range,n),s=fl(i,e.useSharedArrayBuffer);this._indirectBuffer=s}else Hd(t,e);super.init(e),!t.boundingBox&&e.setBoundingBox&&(t.boundingBox=this.getBoundingBox(new zt))}getRootRanges(e){return this.indirect?[{offset:0,count:this._indirectBuffer.length}]:pl(this.geometry,e,this.primitiveStride)}raycastObject3D(){throw new Error("BVH: raycastObject3D() not implemented")}}class Qt{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}}Qt.prototype.setFromBox=function(){const r=new q;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 Yd=function(){const r=new q,e=new q,t=new q;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),d=l.dot(o),f=l.dot(l),m=t.dot(o),x=o.dot(o)*f-d*d;let _,g;x!==0?_=(u*d-m*f)/x:_=0,g=(u+_*d)/f,s.x=_,s.y=g}}(),vo=function(){const r=new nn,e=new q,t=new q;return function(n,i,s,a){Yd(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 d=e,f=t;if(n.closestPointToPoint(u,!0,e),i.closestPointToPoint(l,!0,t),d.distanceToSquared(u)<=f.distanceToSquared(l)){s.copy(d),a.copy(u);return}else{s.copy(l),a.copy(f);return}}}}(),Zd=function(){const r=new q,e=new q,t=new oa,n=new qt;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 d=s.getPlane(t);if(Math.abs(d.distanceToPoint(o))<=a){const f=d.projectPoint(o,e);if(s.containsPoint(f))return!0}return!1}}(),Kd=["x","y","z"],$t=1e-15,yl=$t*$t;function vt(r){return Math.abs(r)<$t}class St extends mn{constructor(...e){super(...e),this.isExtendedTriangle=!0,this.satAxes=new Array(4).fill().map(()=>new q),this.satBounds=new Array(4).fill().map(()=>new Qt),this.points=[this.a,this.b,this.c],this.plane=new oa,this.isDegenerateIntoSegment=!1,this.isDegenerateIntoPoint=!1,this.degenerateSegment=new qt,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 d=s[2],f=a[2];d.subVectors(t,n),f.setFromPoints(d,i);const m=s[3],x=a[3];m.subVectors(n,e),x.setFromPoints(m,i);const _=l.length(),g=d.length(),v=m.length();this.isDegenerateIntoPoint=!1,this.isDegenerateIntoSegment=!1,_<$t?g<$t||v<$t?this.isDegenerateIntoPoint=!0:(this.isDegenerateIntoSegment=!0,this.degenerateSegment.start.copy(e),this.degenerateSegment.end.copy(n)):g<$t?v<$t?this.isDegenerateIntoPoint=!0:(this.isDegenerateIntoSegment=!0,this.degenerateSegment.start.copy(t),this.degenerateSegment.end.copy(e)):v<$t&&(this.isDegenerateIntoSegment=!0,this.degenerateSegment.start.copy(n),this.degenerateSegment.end.copy(t)),this.plane.setFromNormalAndCoplanarPoint(o,e),this.needsUpdate=!1}}St.prototype.closestPointToSegment=function(){const r=new q,e=new q,t=new qt;return function(n,i=null,s=null){const{start:a,end:o}=n,c=this.points;let l,u=1/0;for(let d=0;d<3;d++){const f=(d+1)%3;t.start.copy(c[d]),t.end.copy(c[f]),vo(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)}}(),St.prototype.intersectsTriangle=function(){const r=new St,e=new Qt,t=new Qt,n=new q,i=new q,s=new q,a=new q,o=new qt,c=new qt,l=new q,u=new nn,d=new nn;function f(S,T,M,P){const E=n;!S.isDegenerateIntoPoint&&!S.isDegenerateIntoSegment?E.copy(S.plane.normal):E.copy(T.plane.normal);const O=S.satBounds,A=S.satAxes;for(let I=1;I<4;I++){const U=O[I],L=A[I];if(e.setFromPoints(L,T.points),U.isSeparated(e)||(a.copy(E).cross(L),e.setFromPoints(a,S.points),t.setFromPoints(a,T.points),e.isSeparated(t)))return!1}const R=T.satBounds,B=T.satAxes;for(let I=1;I<4;I++){const U=R[I],L=B[I];if(e.setFromPoints(L,S.points),U.isSeparated(e)||(a.crossVectors(E,L),e.setFromPoints(a,S.points),t.setFromPoints(a,T.points),e.isSeparated(t)))return!1}return M&&(P||console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."),M.start.set(0,0,0),M.end.set(0,0,0)),!0}function m(S,T,M,P,E,O,A,R,B,I,U){let L=A/(A-R);I.x=P+(E-P)*L,U.start.subVectors(T,S).multiplyScalar(L).add(S),L=A/(A-B),I.y=P+(O-P)*L,U.end.subVectors(M,S).multiplyScalar(L).add(S)}function x(S,T,M,P,E,O,A,R,B,I,U){if(E>0)m(S.c,S.a,S.b,P,T,M,B,A,R,I,U);else if(O>0)m(S.b,S.a,S.c,M,T,P,R,A,B,I,U);else if(R*B>0||A!=0)m(S.a,S.b,S.c,T,M,P,A,R,B,I,U);else if(R!=0)m(S.b,S.a,S.c,M,T,P,R,A,B,I,U);else if(B!=0)m(S.c,S.a,S.b,P,T,M,B,A,R,I,U);else return!0;return!1}function _(S,T,M,P){const E=T.degenerateSegment,O=S.plane.distanceToPoint(E.start),A=S.plane.distanceToPoint(E.end);return vt(O)?vt(A)?f(S,T,M,P):(M&&(M.start.copy(E.start),M.end.copy(E.start)),S.containsPoint(E.start)):vt(A)?(M&&(M.start.copy(E.end),M.end.copy(E.end)),S.containsPoint(E.end)):S.plane.intersectLine(E,n)!=null?(M&&(M.start.copy(n),M.end.copy(n)),S.containsPoint(n)):!1}function g(S,T,M){const P=T.a;return vt(S.plane.distanceToPoint(P))&&S.containsPoint(P)?(M&&(M.start.copy(P),M.end.copy(P)),!0):!1}function v(S,T,M){const P=S.degenerateSegment,E=T.a;return P.closestPointToPoint(E,!0,n),E.distanceToSquared(n)<yl?(M&&(M.start.copy(E),M.end.copy(E)),!0):!1}function w(S,T,M,P){if(S.isDegenerateIntoSegment)if(T.isDegenerateIntoSegment){const E=S.degenerateSegment,O=T.degenerateSegment,A=i,R=s;E.delta(A),O.delta(R);const B=n.subVectors(O.start,E.start),I=A.x*R.y-A.y*R.x;if(vt(I))return!1;const U=(B.x*R.y-B.y*R.x)/I,L=-(A.x*B.y-A.y*B.x)/I;if(U<0||U>1||L<0||L>1)return!1;const J=E.start.z+A.z*U,H=O.start.z+R.z*L;return vt(J-H)?(M&&(M.start.copy(E.start).addScaledVector(A,U),M.end.copy(E.start).addScaledVector(A,U)),!0):!1}else return T.isDegenerateIntoPoint?v(S,T,M):_(T,S,M,P);else{if(S.isDegenerateIntoPoint)return T.isDegenerateIntoPoint?T.a.distanceToSquared(S.a)<yl?(M&&(M.start.copy(S.a),M.end.copy(S.a)),!0):!1:T.isDegenerateIntoSegment?v(T,S,M):g(T,S,M);if(T.isDegenerateIntoPoint)return g(S,T,M);if(T.isDegenerateIntoSegment)return _(S,T,M,P)}}return function(S,T=null,M=!1){this.needsUpdate&&this.update(),S.isExtendedTriangle?S.needsUpdate&&S.update():(r.copy(S),r.update(),S=r);const P=w(this,S,T,M);if(P!==void 0)return P;const E=this.plane,O=S.plane;let A=O.distanceToPoint(this.a),R=O.distanceToPoint(this.b),B=O.distanceToPoint(this.c);vt(A)&&(A=0),vt(R)&&(R=0),vt(B)&&(B=0);const I=A*R,U=A*B;if(I>0&&U>0)return!1;let L=E.distanceToPoint(S.a),J=E.distanceToPoint(S.b),H=E.distanceToPoint(S.c);vt(L)&&(L=0),vt(J)&&(J=0),vt(H)&&(H=0);const se=L*J,W=L*H;if(se>0&&W>0)return!1;i.copy(E.normal),s.copy(O.normal);const pe=i.cross(s);let ne=0,he=Math.abs(pe.x);const oe=Math.abs(pe.y);oe>he&&(he=oe,ne=1),Math.abs(pe.z)>he&&(ne=2);const le=Kd[ne],xe=this.a[le],ge=this.b[le],de=this.c[le],re=S.a[le],Ze=S.b[le],Ue=S.c[le];if(x(this,xe,ge,de,I,U,A,R,B,u,o))return f(this,S,T,M);if(x(S,re,Ze,Ue,se,W,L,J,H,d,c))return f(this,S,T,M);if(u.y<u.x){const ke=u.y;u.y=u.x,u.x=ke,l.copy(o.start),o.start.copy(o.end),o.end.copy(l)}if(d.y<d.x){const ke=d.y;d.y=d.x,d.x=ke,l.copy(c.start),c.start.copy(c.end),c.end.copy(l)}return u.y<d.x||d.y<u.x?!1:(T&&(d.x>u.x?T.start.copy(c.start):T.start.copy(o.start),d.y<u.y?T.end.copy(c.end):T.end.copy(o.end)),!0)}}(),St.prototype.distanceToPoint=function(){const r=new q;return function(e){return this.closestPointToPoint(e,r),e.distanceTo(r)}}(),St.prototype.distanceToTriangle=function(){const r=new q,e=new q,t=["a","b","c"],n=new qt,i=new qt;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 d;const f=t[u],m=s[f];this.closestPointToPoint(m,r),d=m.distanceToSquared(r),d<l&&(l=d,a&&a.copy(r),o&&o.copy(m));const x=this[f];s.closestPointToPoint(x,r),d=x.distanceToSquared(r),d<l&&(l=d,a&&a.copy(x),o&&o.copy(r))}for(let u=0;u<3;u++){const d=t[u],f=t[(u+1)%3];n.set(this[d],this[f]);for(let m=0;m<3;m++){const x=t[m],_=t[(m+1)%3];i.set(s[x],s[_]),vo(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 Ye{constructor(e,t,n){this.isOrientedBox=!0,this.min=new q,this.max=new q,this.matrix=new kt,this.invMatrix=new kt,this.points=new Array(8).fill().map(()=>new q),this.satAxes=new Array(3).fill().map(()=>new q),this.satBounds=new Array(3).fill().map(()=>new Qt),this.alignedSatBounds=new Array(3).fill().map(()=>new Qt),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}}Ye.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 d=1*c|2*l|4*u,f=n[d];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],d=1<<c,f=n[d];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}}(),Ye.prototype.intersectsBox=function(){const r=new Qt;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}}(),Ye.prototype.intersectsTriangle=function(){const r=new St,e=new Array(3),t=new Qt,n=new Qt,i=new q;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 d=0;d<3;d++){const f=a[d],m=o[d];if(t.setFromPoints(m,e),f.isSeparated(t))return!1}const c=s.satBounds,l=s.satAxes,u=this.points;for(let d=0;d<3;d++){const f=c[d],m=l[d];if(t.setFromPoints(m,u),f.isSeparated(t))return!1}for(let d=0;d<3;d++){const f=o[d];for(let m=0;m<4;m++){const x=l[m];if(i.crossVectors(f,x),t.setFromPoints(i,e),n.setFromPoints(i,u),t.isSeparated(n))return!1}}return!0}}(),Ye.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}}(),Ye.prototype.distanceToPoint=function(){const r=new q;return function(e){return this.closestPointToPoint(e,r),e.distanceTo(r)}}(),Ye.prototype.distanceToBox=function(){const r=["x","y","z"],e=new Array(12).fill().map(()=>new qt),t=new Array(12).fill().map(()=>new qt),n=new q,i=new q;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,d=s.max,f=this.points;let m=1/0;for(let _=0;_<8;_++){const g=f[_];i.copy(g).clamp(u,d);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 x=0;for(let _=0;_<3;_++)for(let g=0;g<=1;g++)for(let v=0;v<=1;v++){const w=(_+1)%3,S=(_+2)%3,T=g<<w|v<<S,M=1<<_|g<<w|v<<S,P=f[T],E=f[M];e[x].set(P,E);const O=r[_],A=r[w],R=r[S],B=t[x],I=B.start,U=B.end;I[O]=u[O],I[A]=g?u[A]:d[A],I[R]=v?u[R]:d[A],U[O]=d[O],U[A]=g?u[A]:d[A],U[R]=v?u[R]:d[A],x++}for(let _=0;_<=1;_++)for(let g=0;g<=1;g++)for(let v=0;v<=1;v++){i.x=_?d.x:u.x,i.y=g?d.y:u.y,i.z=v?d.z:u.z,this.closestPointToPoint(i,n);const w=i.distanceToSquared(n);if(w<m&&(m=w,o&&o.copy(n),c&&c.copy(i),w<l))return Math.sqrt(w)}for(let _=0;_<12;_++){const g=e[_];for(let v=0;v<12;v++){const w=t[v];vo(g,w,n,i);const S=n.distanceToSquared(i);if(S<m&&(m=S,o&&o.copy(n),c&&c.copy(i),S<l))return Math.sqrt(S)}}return Math.sqrt(m)}}();class Qd extends ho{constructor(){super(()=>new St)}}const bt=new Qd,yi=new q,So=new q;function $d(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=>(yi.copy(e).clamp(u.min,u.max),yi.distanceToSquared(e)),intersectsBounds:(u,d,f)=>f<o&&f<a,intersectsTriangle:(u,d)=>{u.closestPointToPoint(e,yi);const f=e.distanceToSquared(yi);return f<o&&(So.copy(yi),o=f,c=d),f<s}}),o===1/0)return null;const l=Math.sqrt(o);return t.point?t.point.copy(So):t.point=So.clone(),t.distance=l,t.faceIndex=c,t}const Fr=parseInt(aa)>=169,ep=parseInt(aa)<=161,vn=new q,Sn=new q,bn=new q,Vr=new nn,jr=new nn,Jr=new nn,gl=new q,vl=new q,Sl=new q,gi=new q;function tp(r,e,t,n,i,s,a,o){let c;if(s===nu?c=r.intersectTriangle(n,t,e,!0,i):c=r.intersectTriangle(e,t,n,s!==Ss,i),c===null)return null;const l=r.origin.distanceTo(i);return l<a||l>o?null:{distance:l,point:i.clone()}}function bl(r,e,t,n,i,s,a,o,c,l,u){vn.fromBufferAttribute(e,s),Sn.fromBufferAttribute(e,a),bn.fromBufferAttribute(e,o);const d=tp(r,vn,Sn,bn,gi,c,l,u);if(d){if(n){Vr.fromBufferAttribute(n,s),jr.fromBufferAttribute(n,a),Jr.fromBufferAttribute(n,o),d.uv=new nn;const m=mn.getInterpolation(gi,vn,Sn,bn,Vr,jr,Jr,d.uv);Fr||(d.uv=m)}if(i){Vr.fromBufferAttribute(i,s),jr.fromBufferAttribute(i,a),Jr.fromBufferAttribute(i,o),d.uv1=new nn;const m=mn.getInterpolation(gi,vn,Sn,bn,Vr,jr,Jr,d.uv1);Fr||(d.uv1=m),ep&&(d.uv2=d.uv1)}if(t){gl.fromBufferAttribute(t,s),vl.fromBufferAttribute(t,a),Sl.fromBufferAttribute(t,o),d.normal=new q;const m=mn.getInterpolation(gi,vn,Sn,bn,gl,vl,Sl,d.normal);d.normal.dot(r.direction)>0&&d.normal.multiplyScalar(-1),Fr||(d.normal=m)}const f={a:s,b:a,c:o,normal:new q,materialIndex:0};if(mn.getNormal(vn,Sn,bn,f.normal),d.face=f,d.faceIndex=s,Fr){const m=new q;mn.getBarycoord(gi,vn,Sn,bn,m),d.barycoord=m}}return d}function xl(r){return r&&r.isMaterial?r.side:r}function Gr(r,e,t,n,i,s,a){const o=n*3;let c=o+0,l=o+1,u=o+2;const{index:d,groups:f}=r;r.index&&(c=d.getX(c),l=d.getX(l),u=d.getX(u));const{position:m,normal:x,uv:_,uv1:g}=r.attributes;if(Array.isArray(e)){const v=n*3;for(let w=0,S=f.length;w<S;w++){const{start:T,count:M,materialIndex:P}=f[w];if(v>=T&&v<T+M){const E=xl(e[P]),O=bl(t,m,x,_,g,c,l,u,E,s,a);if(O)if(O.faceIndex=n,O.face.materialIndex=P,i)i.push(O);else return O}}}else{const v=xl(e),w=bl(t,m,x,_,g,c,l,u,v,s,a);if(w)if(w.faceIndex=n,w.face.materialIndex=0,i)i.push(w);else return w}return null}function Ce(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 np(r,e,t,n,i,s,a,o){const{geometry:c,_indirectBuffer:l}=r;for(let u=n,d=n+i;u<d;u++)Gr(c,e,t,u,s,a,o)}function ip(r,e,t,n,i,s,a){const{geometry:o,_indirectBuffer:c}=r;let l=1/0,u=null;for(let d=n,f=n+i;d<f;d++){let m;m=Gr(o,e,t,d,null,s,a),m&&m.distance<l&&(u=m,l=m.distance)}return u}function rp(r,e,t,n,i,s,a){const{geometry:o}=t,{index:c}=o,l=o.attributes.position;for(let u=r,d=e+r;u<d;u++){let f;if(f=u,Ce(a,f*3,c,l),a.needsUpdate=!0,n(a,f,i,s))return!0}return!1}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),d(0,l),l+=s.byteLength;function d(f,m,x=!1){const _=f*2;if(Ee(_,o)){const g=Xe(f,a),v=it(_,o);let w=1/0,S=1/0,T=1/0,M=-1/0,P=-1/0,E=-1/0;for(let O=3*g,A=3*(g+v);O<A;O++){let R=n[O];const B=i.getX(R),I=i.getY(R),U=i.getZ(R);B<w&&(w=B),B>M&&(M=B),I<S&&(S=I),I>P&&(P=I),U<T&&(T=U),U>E&&(E=U)}return c[f+0]!==w||c[f+1]!==S||c[f+2]!==T||c[f+3]!==M||c[f+4]!==P||c[f+5]!==E?(c[f+0]=w,c[f+1]=S,c[f+2]=T,c[f+3]=M,c[f+4]=P,c[f+5]=E,!0):!1}else{const g=ze(f),v=Ne(f,a);let w=x,S=!1,T=!1;if(e){if(!w){const R=g/Pe+m/qe,B=v/Pe+m/qe;S=e.has(R),T=e.has(B),w=!S&&!T}}else S=!0,T=!0;const M=w||S,P=w||T;let E=!1;M&&(E=d(g,m,w));let O=!1;P&&(O=d(v,m,w));const A=E||O;if(A)for(let R=0;R<3;R++){const B=g+R,I=v+R,U=c[B],L=c[B+3],J=c[I],H=c[I+3];c[f+R]=U<J?U:J,c[f+R+3]=L>H?L:H}return A}}}function un(r,e,t,n,i){let s,a,o,c,l,u;const d=1/t.direction.x,f=1/t.direction.y,m=1/t.direction.z,x=t.origin.x,_=t.origin.y,g=t.origin.z;let v=e[r],w=e[r+3],S=e[r+1],T=e[r+3+1],M=e[r+2],P=e[r+3+2];return d>=0?(s=(v-x)*d,a=(w-x)*d):(s=(w-x)*d,a=(v-x)*d),f>=0?(o=(S-_)*f,c=(T-_)*f):(o=(T-_)*f,c=(S-_)*f),s>c||o>a||((o>s||isNaN(s))&&(s=o),(c<a||isNaN(a))&&(a=c),m>=0?(l=(M-g)*m,u=(P-g)*m):(l=(P-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 op(r,e,t,n,i,s,a,o){const{geometry:c,_indirectBuffer:l}=r;for(let u=n,d=n+i;u<d;u++){let f=l?l[u]:u;Gr(c,e,t,f,s,a,o)}}function ap(r,e,t,n,i,s,a){const{geometry:o,_indirectBuffer:c}=r;let l=1/0,u=null;for(let d=n,f=n+i;d<f;d++){let m;m=Gr(o,e,t,c?c[d]:d,null,s,a),m&&m.distance<l&&(u=m,l=m.distance)}return u}function cp(r,e,t,n,i,s,a){const{geometry:o}=t,{index:c}=o,l=o.attributes.position;for(let u=r,d=e+r;u<d;u++){let f;if(f=t.resolveTriangleIndex(u),Ce(a,f*3,c,l),a.needsUpdate=!0,n(a,f,i,s))return!0}return!1}function lp(r,e,t,n,i,s,a){ye.setBuffer(r._roots[e]),bo(0,r,t,n,i,s,a),ye.clearBuffer()}function bo(r,e,t,n,i,s,a){const{float32Array:o,uint16Array:c,uint32Array:l}=ye,u=r*2;if(Ee(u,c)){const d=Xe(r,l),f=it(u,c);np(e,t,n,d,f,i,s,a)}else{const d=ze(r);un(d,o,n,s,a)&&bo(d,e,t,n,i,s,a);const f=Ne(r,l);un(f,o,n,s,a)&&bo(f,e,t,n,i,s,a)}}const up=["x","y","z"];function hp(r,e,t,n,i,s){ye.setBuffer(r._roots[e]);const a=xo(0,r,t,n,i,s);return ye.clearBuffer(),a}function xo(r,e,t,n,i,s){const{float32Array:a,uint16Array:o,uint32Array:c}=ye;let l=r*2;if(Ee(l,o)){const u=Xe(r,c),d=it(l,o);return ip(e,t,n,u,d,i,s)}else{const u=so(r,c),d=up[u],f=n.direction[d]>=0;let m,x;f?(m=ze(r),x=Ne(r,c)):(m=Ne(r,c),x=ze(r));const _=un(m,a,n,i,s)?xo(m,e,t,n,i,s):null;if(_){const v=_.point[d];if(f?v<=a[x+u]:v>=a[x+u+3])return _}const g=un(x,a,n,i,s)?xo(x,e,t,n,i,s):null;return _&&g?_.distance<=g.distance?_:g:_||g||null}}const Wr=new zt,jn=new St,Jn=new St,vi=new kt,wl=new Ye,Hr=new Ye;function dp(r,e,t,n){ye.setBuffer(r._roots[e]);const i=wo(0,r,t,n);return ye.clearBuffer(),i}function wo(r,e,t,n,i=null){const{float32Array:s,uint16Array:a,uint32Array:o}=ye;let c=r*2;if(i===null&&(t.boundingBox||t.computeBoundingBox(),wl.set(t.boundingBox.min,t.boundingBox.max,n),i=wl),Ee(c,a)){const l=e.geometry,u=l.index,d=l.attributes.position,f=t.index,m=t.attributes.position,x=Xe(r,o),_=it(c,a);if(vi.copy(n).invert(),t.boundsTree)return be(r,s,Hr),Hr.matrix.copy(vi),Hr.needsUpdate=!0,t.boundsTree.shapecast({intersectsBounds:g=>Hr.intersectsBox(g),intersectsTriangle:g=>{g.a.applyMatrix4(n),g.b.applyMatrix4(n),g.c.applyMatrix4(n),g.needsUpdate=!0;for(let v=x*3,w=(_+x)*3;v<w;v+=3)if(Ce(Jn,v,u,d),Jn.needsUpdate=!0,g.intersectsTriangle(Jn))return!0;return!1}});{const g=Lr(t);for(let v=x*3,w=(_+x)*3;v<w;v+=3){Ce(jn,v,u,d),jn.a.applyMatrix4(vi),jn.b.applyMatrix4(vi),jn.c.applyMatrix4(vi),jn.needsUpdate=!0;for(let S=0,T=g*3;S<T;S+=3)if(Ce(Jn,S,f,m),Jn.needsUpdate=!0,jn.intersectsTriangle(Jn))return!0}}}else{const l=ze(r),u=Ne(r,o);return be(l,s,Wr),!!(i.intersectsBox(Wr)&&wo(l,e,t,n,i)||(be(u,s,Wr),i.intersectsBox(Wr)&&wo(u,e,t,n,i)))}}const qr=new kt,_o=new Ye,Si=new Ye,pp=new q,fp=new q,mp=new q,yp=new q;function gp(r,e,t,n={},i={},s=0,a=1/0){e.boundingBox||e.computeBoundingBox(),_o.set(e.boundingBox.min,e.boundingBox.max,t),_o.needsUpdate=!0;const o=r.geometry,c=o.attributes.position,l=o.index,u=e.attributes.position,d=e.index,f=bt.getPrimitive(),m=bt.getPrimitive();let x=pp,_=fp,g=null,v=null;i&&(g=mp,v=yp);let w=1/0,S=null,T=null;return qr.copy(t).invert(),Si.matrix.copy(qr),r.shapecast({boundsTraverseOrder:M=>_o.distanceToBox(M),intersectsBounds:(M,P,E)=>E<w&&E<a?(P&&(Si.min.copy(M.min),Si.max.copy(M.max),Si.needsUpdate=!0),!0):!1,intersectsRange:(M,P)=>{if(e.boundsTree)return e.boundsTree.shapecast({boundsTraverseOrder:E=>Si.distanceToBox(E),intersectsBounds:(E,O,A)=>A<w&&A<a,intersectsRange:(E,O)=>{for(let A=E,R=E+O;A<R;A++){Ce(m,3*A,d,u),m.a.applyMatrix4(t),m.b.applyMatrix4(t),m.c.applyMatrix4(t),m.needsUpdate=!0;for(let B=M,I=M+P;B<I;B++){Ce(f,3*B,l,c),f.needsUpdate=!0;const U=f.distanceToTriangle(m,x,g);if(U<w&&(_.copy(x),v&&v.copy(g),w=U,S=B,T=A),U<s)return!0}}}});{const E=Lr(e);for(let O=0,A=E;O<A;O++){Ce(m,3*O,d,u),m.a.applyMatrix4(t),m.b.applyMatrix4(t),m.c.applyMatrix4(t),m.needsUpdate=!0;for(let R=M,B=M+P;R<B;R++){Ce(f,3*R,l,c),f.needsUpdate=!0;const I=f.distanceToTriangle(m,x,g);if(I<w&&(_.copy(x),v&&v.copy(g),w=I,S=R,T=O),I<s)return!0}}}}}),bt.releasePrimitive(f),bt.releasePrimitive(m),w===1/0?null:(n.point?n.point.copy(_):n.point=_.clone(),n.distance=w,n.faceIndex=S,i&&(i.point?i.point.copy(v):i.point=v.clone(),i.point.applyMatrix4(qr),_.applyMatrix4(qr),i.distance=_.sub(i.point).length(),i.faceIndex=T),n)}function vp(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),d(0,l),l+=s.byteLength;function d(f,m,x=!1){const _=f*2;if(Ee(_,o)){const g=Xe(f,a),v=it(_,o);let w=1/0,S=1/0,T=1/0,M=-1/0,P=-1/0,E=-1/0;for(let O=g,A=g+v;O<A;O++){const R=3*r.resolveTriangleIndex(O);for(let B=0;B<3;B++){let I=R+B;I=n?n[I]:I;const U=i.getX(I),L=i.getY(I),J=i.getZ(I);U<w&&(w=U),U>M&&(M=U),L<S&&(S=L),L>P&&(P=L),J<T&&(T=J),J>E&&(E=J)}}return c[f+0]!==w||c[f+1]!==S||c[f+2]!==T||c[f+3]!==M||c[f+4]!==P||c[f+5]!==E?(c[f+0]=w,c[f+1]=S,c[f+2]=T,c[f+3]=M,c[f+4]=P,c[f+5]=E,!0):!1}else{const g=ze(f),v=Ne(f,a);let w=x,S=!1,T=!1;if(e){if(!w){const R=g/Pe+m/qe,B=v/Pe+m/qe;S=e.has(R),T=e.has(B),w=!S&&!T}}else S=!0,T=!0;const M=w||S,P=w||T;let E=!1;M&&(E=d(g,m,w));let O=!1;P&&(O=d(v,m,w));const A=E||O;if(A)for(let R=0;R<3;R++){const B=g+R,I=v+R,U=c[B],L=c[B+3],J=c[I],H=c[I+3];c[f+R]=U<J?U:J,c[f+R+3]=L>H?L:H}return A}}}function Sp(r,e,t,n,i,s,a){ye.setBuffer(r._roots[e]),To(0,r,t,n,i,s,a),ye.clearBuffer()}function To(r,e,t,n,i,s,a){const{float32Array:o,uint16Array:c,uint32Array:l}=ye,u=r*2;if(Ee(u,c)){const d=Xe(r,l),f=it(u,c);op(e,t,n,d,f,i,s,a)}else{const d=ze(r);un(d,o,n,s,a)&&To(d,e,t,n,i,s,a);const f=Ne(r,l);un(f,o,n,s,a)&&To(f,e,t,n,i,s,a)}}const bp=["x","y","z"];function xp(r,e,t,n,i,s){ye.setBuffer(r._roots[e]);const a=Mo(0,r,t,n,i,s);return ye.clearBuffer(),a}function Mo(r,e,t,n,i,s){const{float32Array:a,uint16Array:o,uint32Array:c}=ye;let l=r*2;if(Ee(l,o)){const u=Xe(r,c),d=it(l,o);return ap(e,t,n,u,d,i,s)}else{const u=so(r,c),d=bp[u],f=n.direction[d]>=0;let m,x;f?(m=ze(r),x=Ne(r,c)):(m=Ne(r,c),x=ze(r));const _=un(m,a,n,i,s)?Mo(m,e,t,n,i,s):null;if(_){const v=_.point[d];if(f?v<=a[x+u]:v>=a[x+u+3])return _}const g=un(x,a,n,i,s)?Mo(x,e,t,n,i,s):null;return _&&g?_.distance<=g.distance?_:g:_||g||null}}const Xr=new zt,Gn=new St,Wn=new St,bi=new kt,_l=new Ye,Yr=new Ye;function wp(r,e,t,n){ye.setBuffer(r._roots[e]);const i=Co(0,r,t,n);return ye.clearBuffer(),i}function Co(r,e,t,n,i=null){const{float32Array:s,uint16Array:a,uint32Array:o}=ye;let c=r*2;if(i===null&&(t.boundingBox||t.computeBoundingBox(),_l.set(t.boundingBox.min,t.boundingBox.max,n),i=_l),Ee(c,a)){const l=e.geometry,u=l.index,d=l.attributes.position,f=t.index,m=t.attributes.position,x=Xe(r,o),_=it(c,a);if(bi.copy(n).invert(),t.boundsTree)return be(r,s,Yr),Yr.matrix.copy(bi),Yr.needsUpdate=!0,t.boundsTree.shapecast({intersectsBounds:g=>Yr.intersectsBox(g),intersectsTriangle:g=>{g.a.applyMatrix4(n),g.b.applyMatrix4(n),g.c.applyMatrix4(n),g.needsUpdate=!0;for(let v=x,w=_+x;v<w;v++)if(Ce(Wn,3*e.resolveTriangleIndex(v),u,d),Wn.needsUpdate=!0,g.intersectsTriangle(Wn))return!0;return!1}});{const g=Lr(t);for(let v=x,w=_+x;v<w;v++){const S=e.resolveTriangleIndex(v);Ce(Gn,3*S,u,d),Gn.a.applyMatrix4(bi),Gn.b.applyMatrix4(bi),Gn.c.applyMatrix4(bi),Gn.needsUpdate=!0;for(let T=0,M=g*3;T<M;T+=3)if(Ce(Wn,T,f,m),Wn.needsUpdate=!0,Gn.intersectsTriangle(Wn))return!0}}}else{const l=ze(r),u=Ne(r,o);return be(l,s,Xr),!!(i.intersectsBox(Xr)&&Co(l,e,t,n,i)||(be(u,s,Xr),i.intersectsBox(Xr)&&Co(u,e,t,n,i)))}}const Zr=new kt,Po=new Ye,xi=new Ye,_p=new q,Tp=new q,Mp=new q,Cp=new q;function Pp(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,d=e.index,f=bt.getPrimitive(),m=bt.getPrimitive();let x=_p,_=Tp,g=null,v=null;i&&(g=Mp,v=Cp);let w=1/0,S=null,T=null;return Zr.copy(t).invert(),xi.matrix.copy(Zr),r.shapecast({boundsTraverseOrder:M=>Po.distanceToBox(M),intersectsBounds:(M,P,E)=>E<w&&E<a?(P&&(xi.min.copy(M.min),xi.max.copy(M.max),xi.needsUpdate=!0),!0):!1,intersectsRange:(M,P)=>{if(e.boundsTree){const E=e.boundsTree;return E.shapecast({boundsTraverseOrder:O=>xi.distanceToBox(O),intersectsBounds:(O,A,R)=>R<w&&R<a,intersectsRange:(O,A)=>{for(let R=O,B=O+A;R<B;R++){const I=E.resolveTriangleIndex(R);Ce(m,3*I,d,u),m.a.applyMatrix4(t),m.b.applyMatrix4(t),m.c.applyMatrix4(t),m.needsUpdate=!0;for(let U=M,L=M+P;U<L;U++){const J=r.resolveTriangleIndex(U);Ce(f,3*J,l,c),f.needsUpdate=!0;const H=f.distanceToTriangle(m,x,g);if(H<w&&(_.copy(x),v&&v.copy(g),w=H,S=U,T=R),H<s)return!0}}}})}else{const E=Lr(e);for(let O=0,A=E;O<A;O++){Ce(m,3*O,d,u),m.a.applyMatrix4(t),m.b.applyMatrix4(t),m.c.applyMatrix4(t),m.needsUpdate=!0;for(let R=M,B=M+P;R<B;R++){const I=r.resolveTriangleIndex(R);Ce(f,3*I,l,c),f.needsUpdate=!0;const U=f.distanceToTriangle(m,x,g);if(U<w&&(_.copy(x),v&&v.copy(g),w=U,S=R,T=O),U<s)return!0}}}}}),bt.releasePrimitive(f),bt.releasePrimitive(m),w===1/0?null:(n.point?n.point.copy(_):n.point=_.clone(),n.distance=w,n.faceIndex=S,i&&(i.point?i.point.copy(v):i.point=v.clone(),i.point.applyMatrix4(Zr),_.applyMatrix4(Zr),i.distance=_.sub(i.point).length(),i.faceIndex=T),n)}function Tl(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 Kr=new Ye,Qr=new iu,Ml=new q,Cl=new kt,Pl=new q,Eo=["getX","getY","getZ"];class Kn extends ml{static serialize(e,t={}){t={cloneBuffers:!0,...t};const n=e.geometry,i=e._roots,s=e._indirectBuffer,a=n.getIndex(),o={version:1,roots:null,index:null,indirectBuffer:null};return t.cloneBuffers?(o.roots=i.map(c=>c.slice()),o.index=a?a.array.slice():null,o.indirectBuffer=s?s.slice():null):(o.roots=i,o.index=a?a.array:null,o.indirectBuffer=s),o}static deserialize(e,t,n={}){n={setIndex:!0,indirect:!!e.indirectBuffer,...n};const{index:i,roots:s,indirectBuffer:a}=e;e.version||(console.warn("MeshBVH.deserialize: Serialization format has been changed and will be fixed up. It is recommended to regenerate any stored serialized data."),c(s));const o=new Kn(t,{...n,[Ir]:!0});if(o._roots=s,o._indirectBuffer=a||null,n.setIndex){const l=t.getIndex();if(l===null){const u=new dt(e.index,1,!1);t.setIndex(u)}else l.array!==i&&(l.array.set(i),l.needsUpdate=!0)}return o;function c(l){for(let u=0;u<l.length;u++){const d=l[u],f=new Uint32Array(d),m=new Uint16Array(d);for(let x=0,_=d.byteLength/qe;x<_;x++){const g=Pe*x,v=2*g;Ee(v,m)||(f[g+6]=f[g+6]/Pe-x)}}}}get primitiveStride(){return 3}get resolveTriangleIndex(){return this.resolvePrimitiveIndex}constructor(e,t={}){t.maxLeafTris&&(console.warn('MeshBVH: "maxLeafTris" option has been deprecated. Use maxLeafSize, instead.'),t={...t,maxLeafSize:t.maxLeafTris}),super(e,t)}shiftTriangleOffsets(e){return super.shiftPrimitiveOffsets(e)}writePrimitiveBounds(e,t,n){const i=this.geometry,s=this._indirectBuffer,a=i.attributes.position,o=i.index?i.index.array:null,c=(s?s[e]:e)*3;let l=c+0,u=c+1,d=c+2;o&&(l=o[l],u=o[u],d=o[d]);for(let f=0;f<3;f++){const m=a[Eo[f]](l),x=a[Eo[f]](u),_=a[Eo[f]](d);let g=m;x<g&&(g=x),_<g&&(g=_);let v=m;x>v&&(v=x),_>v&&(v=_),t[n+f]=g,t[n+f+3]=v}return t}computePrimitiveBounds(e,t,n){const i=this.geometry,s=this._indirectBuffer,a=i.attributes.position,o=i.index?i.index.array:null,c=a.normalized;if(e<0||t+e-n.offset>n.length/6)throw new Error("MeshBVH: compute triangle bounds range is invalid.");const l=a.array,u=a.offset||0;let d=3;a.isInterleavedBufferAttribute&&(d=a.data.stride);const f=["getX","getY","getZ"],m=n.offset;for(let x=e,_=e+t;x<_;x++){const g=(s?s[x]:x)*3,v=(x-m)*6;let w=g+0,S=g+1,T=g+2;o&&(w=o[w],S=o[S],T=o[T]),c||(w=w*d+u,S=S*d+u,T=T*d+u);for(let M=0;M<3;M++){let P,E,O;c?(P=a[f[M]](w),E=a[f[M]](S),O=a[f[M]](T)):(P=l[w+M],E=l[S+M],O=l[T+M]);let A=P;E<A&&(A=E),O<A&&(A=O);let R=P;E>R&&(R=E),O>R&&(R=O);const B=(R-A)/2,I=M*2;n[v+I+0]=A+B,n[v+I+1]=B+(Math.abs(A)+B)*Or}}return n}raycastObject3D(e,t,n=[]){const{material:i}=e;if(i===void 0)return;Cl.copy(e.matrixWorld).invert(),Qr.copy(t.ray).applyMatrix4(Cl),Pl.setFromMatrixScale(e.matrixWorld),Ml.copy(Qr.direction).multiply(Pl);const s=Ml.length(),a=t.near/s,o=t.far/s;if(t.firstHitOnly===!0){let c=this.raycastFirst(Qr,i,a,o);c=Tl(c,e,t),c&&n.push(c)}else{const c=this.raycast(Qr,i,a,o);for(let l=0,u=c.length;l<u;l++){const d=Tl(c[l],e,t);d&&n.push(d)}}return n}refit(e=null){return(this.indirect?vp:sp)(this,e)}raycast(e,t=ca,n=0,i=1/0){const s=this._roots,a=[],o=this.indirect?Sp:lp;for(let c=0,l=s.length;c<l;c++)o(this,c,t,e,a,n,i);return a}raycastFirst(e,t=ca,n=0,i=1/0){const s=this._roots;let a=null;const o=this.indirect?xp:hp;for(let c=0,l=s.length;c<l;c++){const u=o(this,c,t,e,n,i);u!=null&&(a==null||u.distance<a.distance)&&(a=u)}return a}intersectsGeometry(e,t){let n=!1;const i=this._roots,s=this.indirect?wp:dp;for(let a=0,o=i.length;a<o&&(n=s(this,a,e,t),!n);a++);return n}shapecast(e){const t=bt.getPrimitive(),n=super.shapecast({...e,intersectsPrimitive:e.intersectsTriangle,scratchPrimitive:t,iterate:this.indirect?cp:rp});return bt.releasePrimitive(t),n}bvhcast(e,t,n){let{intersectsRanges:i,intersectsTriangles:s}=n;const a=bt.getPrimitive(),o=this.geometry.index,c=this.geometry.attributes.position,l=this.indirect?x=>{const _=this.resolveTriangleIndex(x);Ce(a,_*3,o,c)}:x=>{Ce(a,x*3,o,c)},u=bt.getPrimitive(),d=e.geometry.index,f=e.geometry.attributes.position,m=e.indirect?x=>{const _=e.resolveTriangleIndex(x);Ce(u,_*3,d,f)}:x=>{Ce(u,x*3,d,f)};if(s){if(!(e instanceof Kn))throw new Error('MeshBVH: "intersectsTriangles" callback can only be used with another MeshBVH.');const x=(_,g,v,w,S,T,M,P)=>{for(let E=v,O=v+w;E<O;E++){m(E),u.a.applyMatrix4(t),u.b.applyMatrix4(t),u.c.applyMatrix4(t),u.needsUpdate=!0;for(let A=_,R=_+g;A<R;A++)if(l(A),a.needsUpdate=!0,s(a,u,A,E,S,T,M,P))return!0}return!1};if(i){const _=i;i=function(g,v,w,S,T,M,P,E){return _(g,v,w,S,T,M,P,E)?!0:x(g,v,w,S,T,M,P,E)}}else i=x}return super.bvhcast(e,t,{intersectsRanges:i})}intersectsBox(e,t){return Kr.set(e.min,e.max,t),Kr.needsUpdate=!0,this.shapecast({intersectsBounds:n=>Kr.intersectsBox(n),intersectsTriangle:n=>Kr.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?Pp:gp)(this,e,t,n,i,s,a)}closestPointToPoint(e,t={},n=0,i=1/0){return $d(this,e,t,n,i)}}const Hn={Mesh:lr.prototype.raycast,Line:ha.prototype.raycast,LineSegments:la.prototype.raycast,LineLoop:ua.prototype.raycast,Points:da.prototype.raycast,BatchedMesh:su.prototype.raycast},Je=new lr,$r=[];function Ep(r,e){if(this.isBatchedMesh)kp.call(this,r,e);else{const{geometry:t}=this;if(t.boundsTree)t.boundsTree.raycastObject3D(this,r,e);else{let n;if(this instanceof lr)n=Hn.Mesh;else if(this instanceof la)n=Hn.LineSegments;else if(this instanceof ua)n=Hn.LineLoop;else if(this instanceof ha)n=Hn.Line;else if(this instanceof da)n=Hn.Points;else throw new Error("BVH: Fallback raycast function not found.");n.call(this,r,e)}}}function kp(r,e){if(this.boundsTrees){const t=this.boundsTrees,n=this._drawInfo||this._instanceInfo,i=this._drawRanges||this._geometryInfo,s=this.matrixWorld;Je.material=this.material,Je.geometry=this.geometry;const a=Je.geometry.boundsTree,o=Je.geometry.drawRange;Je.geometry.boundingSphere===null&&(Je.geometry.boundingSphere=new ru);for(let c=0,l=n.length;c<l;c++){if(!this.getVisibleAt(c))continue;const u=n[c].geometryIndex;if(Je.geometry.boundsTree=t[u],this.getMatrixAt(c,Je.matrixWorld).premultiply(s),!Je.geometry.boundsTree){this.getBoundingBoxAt(u,Je.geometry.boundingBox),this.getBoundingSphereAt(u,Je.geometry.boundingSphere);const d=i[u];Je.geometry.setDrawRange(d.start,d.count)}Je.raycast(r,$r);for(let d=0,f=$r.length;d<f;d++){const m=$r[d];m.object=this,m.batchId=c,e.push(m)}$r.length=0}Je.geometry.boundsTree=a,Je.geometry.drawRange=o,Je.material=null,Je.geometry=null}else Hn.BatchedMesh.call(this,r,e)}function Rp(r={}){const{type:e=Kn}=r;return this.boundsTree=new e(this,r),this.boundsTree}const xn=new q,wn=new q,_n=new q,El=new xs,es=new q,ko=new q,kl=new xs,Rl=new xs,ts=new kt,Al=new kt;function wi(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 _i(r,e=null){const t=r.array.constructor,n=r.normalized,i=r.itemSize,s=e===null?r.count:e;return new dt(new t(i*s),i,n)}function Ol(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 Ap(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 Il(r,e,t){const n=r.skeleton,i=r.geometry,s=n.bones,a=n.boneInverses;kl.fromBufferAttribute(i.attributes.skinIndex,e),Rl.fromBufferAttribute(i.attributes.skinWeight,e),ts.elements.fill(0);for(let o=0;o<4;o++){const c=Rl.getComponent(o);if(c!==0){const l=kl.getComponent(o);Al.multiplyMatrices(s[l].matrixWorld,a[l]),Ap(ts,Al,c)}}return ts.multiply(r.bindMatrix).premultiply(r.bindMatrixInverse),t.transformDirection(ts),t}function Ro(r,e,t,n,i){es.set(0,0,0);for(let s=0,a=r.length;s<a;s++){const o=e[s],c=r[s];o!==0&&(ko.fromBufferAttribute(c,n),t?es.addScaledVector(ko,o):es.addScaledVector(ko.sub(i),o))}i.add(es)}function Op(r,e={useGroups:!1,updateIndex:!1,skipAttributes:[]},t=new ti){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 d=r[u];let f=0;if(n!==(d.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 d.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(d.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=d.index.count;else if(d.attributes.position!==void 0)m=d.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 d=0;for(let f=0;f<r.length;++f)d+=r[f].index.count;t.setIndex(new dt(new Uint32Array(d),1,!1)),u=!0}if(s||u){const d=t.index;let f=0,m=0;for(let x=0;x<r.length;++x){const _=r[x],g=_.index;if(a[x]!==!0)for(let v=0;v<g.count;++v)d.setX(f,g.getX(v)+m),f++;m+=_.attributes.position.count}}}for(const u in c){const d=c[u];if(!(u in t.attributes)){let x=0;for(const _ in d)x+=d[_].count;t.setAttribute(u,_i(c[u][0],x))}const f=t.attributes[u];let m=0;for(let x=0,_=d.length;x<_;x++){const g=d[x];a[x]!==!0&&Ol(g,f,m),m+=g.count}}return t}function Ip(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 Bp(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 zp{constructor(e){this.matrixWorld=new kt,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&&Ip(e.skeleton&&e.skeleton.boneMatrices||null,this.boneMatrices)&&this.primitiveCount===n)}}class Np{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 ti),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 ti){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],d=a.get(l);!d||d.didChange(l)?(this._convertToStaticGeometry(l,u),t.push(!1),d?d.update():a.set(l,new zp(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 dt(new Float32Array(0),4,!1))}else Op(s,{useGroups:i,skipAttributes:t},e);for(const o in e.attributes)e.attributes[o].needsUpdate=!0;return e}_convertToStaticGeometry(e,t=new ti){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",_i(o.position)),s&&!c.normal&&o.normal&&t.setAttribute("normal",_i(o.normal)),a&&!c.tangent&&o.tangent&&t.setAttribute("tangent",_i(o.tangent)),wi(n.index,t.index),wi(o.position,c.position),s&&wi(o.normal,c.normal),a&&wi(o.tangent,c.tangent);const l=o.position,u=s?o.normal:null,d=a?o.tangent:null,f=n.morphAttributes.position,m=n.morphAttributes.normal,x=n.morphAttributes.tangent,_=n.morphTargetsRelative,g=e.morphTargetInfluences,v=new ou;v.getNormalMatrix(e.matrixWorld),n.index&&t.index.array.set(n.index.array);for(let w=0,S=o.position.count;w<S;w++)xn.fromBufferAttribute(l,w),u&&wn.fromBufferAttribute(u,w),d&&(El.fromBufferAttribute(d,w),_n.fromBufferAttribute(d,w)),g&&(f&&Ro(f,g,_,w,xn),m&&Ro(m,g,_,w,wn),x&&Ro(x,g,_,w,_n)),e.isSkinnedMesh&&(e.applyBoneTransform(w,xn),u&&Il(e,w,wn),d&&Il(e,w,_n)),i&&xn.applyMatrix4(e.matrixWorld),c.position.setXYZ(w,xn.x,xn.y,xn.z),u&&(i&&wn.applyNormalMatrix(v),c.normal.setXYZ(w,wn.x,wn.y,wn.z)),d&&(i&&_n.transformDirection(e.matrixWorld),c.tangent.setXYZW(w,_n.x,_n.y,_n.z,El.w));for(const w in this.attributes){const S=this.attributes[w];S==="position"||S==="tangent"||S==="normal"||!(S in o)||(c[S]||t.setAttribute(S,_i(o[S])),wi(o[S],c[S]),Ol(o[S],c[S]))}return e.matrixWorld.determinant()<0&&Bp(t),t}}const Up=Object.freeze(Object.defineProperty({__proto__:null,AVERAGE:tl,BVH:dl,CENTER:no,CONTAINED:io,ExtendedTriangle:St,GeometryBVH:ml,MeshBVH:Kn,OrientedBox:Ye,SAH:nl,SKIP_GENERATION:Ir,StaticGeometryGenerator:Np,acceleratedRaycast:Ep,computeBoundsTree:Rp,generateIndirectBuffer:fl},Symbol.toStringTag,{value:"Module"}));class Dp{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 xt={node:"node",material:"material",camera:"camera",light:"light"},qn="KHR_animation_pointer",Lp={CUBICSPLINE:void 0,LINEAR:pa,STEP:cu};class Fp{constructor(e){this.name=qn,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){const t=e.target,n=t.extensions&&t.extensions[qn]&&t.path&&t.path==="pointer";if(!n)return null;let i,s=xt.node,a;if(n){const c=t.extensions[qn];let l=c.pointer;if(!l){console.warn("Invalid path",c,t);return}if(l.startsWith("/materials/")?s=xt.material:l.startsWith("/extensions/KHR_lights_punctual/lights/")?s=xt.light:l.startsWith("/cameras/")&&(s=xt.camera),a=this._tryResolveTargetId(l,s),a===null||isNaN(a)){console.warn("Failed resolving animation node id: "+a,l);return}switch(s){case xt.material:const u=("/materials/"+a.toString()+"/").length,d=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=d+i;break;case xt.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 xt.light:const x=("/extensions/KHR_lights_punctual/lights/"+a.toString()+"/").length;switch(i=l.substring(x),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 xt.camera:const _=("/cameras/"+a.toString()+"/").length,g=l.substring(0,_);switch(i=l.substring(_),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[qn].pointer=l}if(a==null||isNaN(a)){console.warn("Failed resolving animation node id: "+a,t);return}let o;return s===xt.node?o=this.parser.getDependency("node",a):s===xt.material?o=this.parser.getDependency("material",a):s===xt.light?o=this.parser.getDependency("light",a):s===xt.camera?o=this.parser.getDependency("camera",a):console.error("Unhandled type",s),o}createAnimationTracksWithAnimationPointer(e,t,n,i,s){if(!(s.extensions&&s.extensions[qn]&&s.path&&s.path==="pointer"))return null;let a=s.extensions[qn].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 au&&f.morphTargetInfluences&&(c[3]=f.name,c[4]="morphTargetInfluences",d(this.parser));return o}d(this.parser);function u(f,m){try{const x=m.split(".").filter(Boolean),_=x[x.length-1].replace(/\[.*\]$/,"");return _ in f?typeof f[_]=="boolean":!1}catch{return!1}}function d(f){a=c.join(".");let m,x=!1;switch(n.itemSize){case 1:Object.prototype.toString.call(n.array)==="[object Uint8Array]"&&u(e,a)?(m=pu,x=!0):m=fu;break;case 2:case 3:m=du;break;case 4:a.endsWith(".quaternion")?m=uu:m=hu;break}if(!m){console.warn("Unsupported output accessor format",n);return}const _=i.interpolation!==void 0?Lp[i.interpolation]:pa;let g=f._getArrayFromAccessor(n);a.endsWith(".fov")&&(g=g.map(w=>w/Math.PI*180)),x&&(g=g.map(w=>w>0));const v=new m(a,t.array,g,_);if(_==="CUBICSPLINE"&&f._createCubicSplineTrackInterpolant(v),o.push(v),a&&n.itemSize===4&&a.startsWith(".materials.")&&a.endsWith(".color")){const w=new Float32Array(g.length/4);for(let T=0,M=g.length/4;T<M;T+=1)w[T]=g[T*4+3];const S=new m(a.replace(".color",".opacity"),t.array,w,_);_==="CUBICSPLINE"&&f._createCubicSplineTrackInterpolant(v),o.push(S)}}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=[],d=[];for(let f=0,m=s.channels.length;f<m;f++){const x=s.channels[f],_=s.samplers[x.sampler],g=x.target,v=s.parameters!==void 0?s.parameters[_.input]:_.input,w=s.parameters!==void 0?s.parameters[_.output]:_.output;let S=t.loadAnimationTargetFromChannelWithAnimationPointer(x);S||(S=t.loadAnimationTargetFromChannel(x)),o.push(S),c.push(i.getDependency("accessor",v)),l.push(i.getDependency("accessor",w)),u.push(_),d.push(g)}return Promise.all([Promise.all(o),Promise.all(c),Promise.all(l),Promise.all(u),Promise.all(d)]).then(function(f){const m=f[0],x=f[1],_=f[2],g=f[3],v=f[4],w=[];for(let S=0,T=m.length;S<T;S++){const M=m[S],P=x[S],E=_[S],O=g[S],A=v[S];if(M===void 0)continue;M.updateMatrix&&(M.updateMatrix(),M.matrixAutoUpdate=!0);let R=t.createAnimationTracksWithAnimationPointer(M,P,E,O,A);if(R||(R=i._createAnimationTracks(M,P,E,O,A)),R)for(let B=0;B<R.length;B++)w.push(R[B])}return new lu(a,void 0,w)})}}const Vp=Object.freeze(Object.defineProperty({__proto__:null,GLTFAnimationPointerExtension:Fp},Symbol.toStringTag,{value:"Module"}));export{Ac as $70d766613f57b014$export$2e2bcd8739ae039,Td as BatchedParticleRenderer,Ao as Builder,Ti as ByteBuffer,Mn as ConstantColor,te as ConstantValue,It as Matrix4,Kn as MeshBVH,xu as MotionController,ss as ParticleSystem,V as RenderMode,ma as SIZE_PREFIX_LENGTH,Er as TrailParticle,ct as Vector4,Dp as WorkerBase,$u as bundler,Cd as createNoise4D,yu as fetchProfile,Od as index,Up as index$1,Vp as index$2,mh as md5,uh as v5};
|
|
1116
|
+
}`;class _d extends Kc{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 ti,this.indexBuffer=new dt(new Uint32Array(this.maxParticles*6),1),this.indexBuffer.setUsage(et),this.geometry.setIndex(this.indexBuffer),this.positionBuffer=new dt(new Float32Array(this.maxParticles*6),3),this.positionBuffer.setUsage(et),this.geometry.setAttribute("position",this.positionBuffer),this.previousBuffer=new dt(new Float32Array(this.maxParticles*6),3),this.previousBuffer.setUsage(et),this.geometry.setAttribute("previous",this.previousBuffer),this.nextBuffer=new dt(new Float32Array(this.maxParticles*6),3),this.nextBuffer.setUsage(et),this.geometry.setAttribute("next",this.nextBuffer),this.widthBuffer=new dt(new Float32Array(this.maxParticles*2),1),this.widthBuffer.setUsage(et),this.geometry.setAttribute("width",this.widthBuffer),this.sideBuffer=new dt(new Float32Array(this.maxParticles*2),1),this.sideBuffer.setUsage(et),this.geometry.setAttribute("side",this.sideBuffer),this.uvBuffer=new dt(new Float32Array(this.maxParticles*4),2),this.uvBuffer.setUsage(et),this.geometry.setAttribute("uv",this.uvBuffer),this.colorBuffer=new dt(new Float32Array(this.maxParticles*8),4),this.colorBuffer.setUsage(et),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 Xn(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=to(this.settings.material.map.channel),e.map=new Et(this.settings.material.map),e.mapTransform=new Et(new Vt().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 bs({uniforms:e,defines:t,vertexShader:wd,fragmentShader:xd,transparent:this.settings.material.transparent,depthWrite:!this.settings.material.transparent,side:this.settings.material.side,blending:this.settings.material.blending||sa,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,d=this.settings.vTileCount,f=1/u,m=1/d;for(let x=0;x<l;x++){const _=c[x],g=_.uvTile%d,v=Math.floor(_.uvTile/d+.001),w=_.previous.values();let S=w.next(),T=S.value,M=T;S.done||(S=w.next());let P;S.value!==void 0?P=S.value:P=M;for(let E=0;E<_.previous.length;E++,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)):(_.parentMatrix?this.vector_.copy(M.position).applyMatrix4(_.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,T.position.x,T.position.y,T.position.z),this.previousBuffer.setXYZ(e+1,T.position.x,T.position.y,T.position.z)):(_.parentMatrix?this.vector_.copy(T.position).applyMatrix4(_.parentMatrix):this.vector_.copy(T.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,P.position.x,P.position.y,P.position.z),this.nextBuffer.setXYZ(e+1,P.position.x,P.position.y,P.position.z)):(_.parentMatrix?this.vector_.copy(P.position).applyMatrix4(_.parentMatrix):this.vector_.copy(P.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(_.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,(E/_.previous.length+g)*f,(d-v-1)*m),this.uvBuffer.setXY(e+1,(E/_.previous.length+g)*f,(d-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),E+1<_.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++),T=M,M=P,S.done||(S=w.next(),S.value!==void 0&&(P=S.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 er{get geometry(){return this._geometry}set geometry(e){if(this._geometry=e,e===void 0||typeof e=="string")return;const t=new mn;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 q,this._tempB=new q,this._tempC=new q,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],d=t.getIndex().array[i*3+2],f=t.getAttribute("position");this._tempA.fromBufferAttribute(f,l),this._tempB.fromBufferAttribute(f,u),this._tempC.fromBufferAttribute(f,d),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 er(t.geometries[e.geometry])}clone(){return new er(this._geometry)}update(e,t){}}ed({id:"three.quarks",emitterShapes:[{type:"mesh_surface",params:[["geometry",["geometry"]]],constructor:er,loadJSON:er.fromJSON}],behaviors:[]});class Oo extends ia{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(Oo.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 _d(t);break;case V.Mesh:case V.BillBoard:case V.VerticalBillBoard:case V.HorizontalBillBoard:case V.StretchedBillBoard:n=new bd(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 Td=Oo;ld(),console.log("%c Particle system powered by three.quarks. https://quarks.art/","font-size: 14px; font-weight: bold;");const $c=Math.sqrt(5),Md=($c-1)/4,je=(5-$c)/20,Rr=r=>Math.floor(r)|0,Ar=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 Cd(r=Math.random){const e=Pd(r),t=new Float64Array(e).map(a=>Ar[a%32*4]),n=new Float64Array(e).map(a=>Ar[a%32*4+1]),i=new Float64Array(e).map(a=>Ar[a%32*4+2]),s=new Float64Array(e).map(a=>Ar[a%32*4+3]);return function(a,o,c,l){let u,d,f,m,x;const _=(a+o+c+l)*Md,g=Rr(a+_),v=Rr(o+_),w=Rr(c+_),S=Rr(l+_),T=(g+v+w+S)*je,M=g-T,P=v-T,E=w-T,O=S-T,A=a-M,R=o-P,B=c-E,I=l-O;let U=0,L=0,J=0,H=0;A>R?U++:L++,A>B?U++:J++,A>I?U++:H++,R>B?L++:J++,R>I?L++:H++,B>I?J++:H++;const se=U>=3?1:0,W=L>=3?1:0,pe=J>=3?1:0,ne=H>=3?1:0,he=U>=2?1:0,oe=L>=2?1:0,le=J>=2?1:0,xe=H>=2?1:0,ge=U>=1?1:0,de=L>=1?1:0,re=J>=1?1:0,Ze=H>=1?1:0,Ue=A-se+je,ke=R-W+je,lt=B-pe+je,De=I-ne+je,ve=A-he+2*je,ue=R-oe+2*je,ft=B-le+2*je,Re=I-xe+2*je,fe=A-ge+3*je,rt=R-de+3*je,wt=B-re+3*je,_t=I-Ze+3*je,st=A-1+4*je,Tt=R-1+4*je,mt=B-1+4*je,yt=I-1+4*je,ut=g&255,Ae=v&255,Ke=w&255,ht=S&255;let Qe=.6-A*A-R*R-B*B-I*I;if(Qe<0)u=0;else{const ae=ut+e[Ae+e[Ke+e[ht]]];Qe*=Qe,u=Qe*Qe*(t[ae]*A+n[ae]*R+i[ae]*B+s[ae]*I)}let $=.6-Ue*Ue-ke*ke-lt*lt-De*De;if($<0)d=0;else{const ae=ut+se+e[Ae+W+e[Ke+pe+e[ht+ne]]];$*=$,d=$*$*(t[ae]*Ue+n[ae]*ke+i[ae]*lt+s[ae]*De)}let Mt=.6-ve*ve-ue*ue-ft*ft-Re*Re;if(Mt<0)f=0;else{const ae=ut+he+e[Ae+oe+e[Ke+le+e[ht+xe]]];Mt*=Mt,f=Mt*Mt*(t[ae]*ve+n[ae]*ue+i[ae]*ft+s[ae]*Re)}let jt=.6-fe*fe-rt*rt-wt*wt-_t*_t;if(jt<0)m=0;else{const ae=ut+ge+e[Ae+de+e[Ke+re+e[ht+Ze]]];jt*=jt,m=jt*jt*(t[ae]*fe+n[ae]*rt+i[ae]*wt+s[ae]*_t)}let Ct=.6-st*st-Tt*Tt-mt*mt-yt*yt;if(Ct<0)x=0;else{const ae=ut+1+e[Ae+1+e[Ke+1+e[ht+1]]];Ct*=Ct,x=Ct*Ct*(t[ae]*st+n[ae]*Tt+i[ae]*mt+s[ae]*yt)}return 27*(u+d+f+m+x)}}function Pd(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 Ed=Object.defineProperty,kd=(r,e,t)=>e in r?Ed(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Me=(r,e,t)=>(kd(r,typeof e!="symbol"?e+"":e,t),t);(function(){class r{}class e extends r{constructor(p){super(),Me(this,"value"),this.value=p}}class t extends r{constructor(p){super(),Me(this,"value"),this.value=p}}class n extends r{constructor(p){super(),Me(this,"value"),this.value=p}}class i extends r{constructor(p,y="unrestricted"){super(),Me(this,"type"),Me(this,"value"),this.value=p,this.type=y}}class s extends r{constructor(p){super(),Me(this,"value"),this.value=p}}class a extends r{}class o extends r{constructor(p){super(),Me(this,"value"),this.value=p}}class c extends r{}class l extends r{constructor(p){super(),Me(this,"value"),this.value=p}}class u extends r{constructor(p,y="integer"){super(),Me(this,"value"),Me(this,"type"),this.value=p,this.type=y}}class d extends r{constructor(p){super(),Me(this,"value"),this.value=p}}class f extends r{constructor(p,y,b){super(),Me(this,"value"),Me(this,"type"),Me(this,"unit"),this.value=p,this.type=y,this.unit=b}}class m extends r{}class x extends r{}class _ extends r{}class g extends r{}class v extends r{}class w extends r{}class S extends r{}class T extends r{}class M extends r{}class P extends r{}class E extends r{}class O extends r{}class A{constructor(p){Me(this,"input"),Me(this,"index",0),this.input=p}consume(){const p=this.input.codePointAt(this.index);return p!==void 0&&(this.index+=String.fromCodePoint(p).length),p}reconsume(p){p!==void 0&&(this.index-=String.fromCodePoint(p).length)}peek(){const p=[];let y=this.index;for(let b=0;b<3&&y<this.input.length;b++){const C=this.input.codePointAt(y);p.push(C),y+=String.fromCodePoint(C).length}return p}}function R(h){return h===10}function B(h){return R(h)||h===8192||h===32}function I(h){return h>=48&&h<=57}function U(h){return I(h)||h>=65&&h<=70||h>=97&&h<=102}function L(h){return function(p){return function(y){return y>=65&&y<=90}(p)||function(y){return y>=97&&y<=122}(p)}(h)||function(p){return p>=128}(h)||h===95}function J(h){return L(h)||I(h)||h===45}function H(h){return h>=0&&h<=8||h===11||h>=14&&h<=31||h===127}function se(h,p){return h===92&&!R(p)}function W(h,p,y){return h===45?L(p)||p===45||se(p,y):!!L(h)||h===92&&se(h,p)}function pe(h,p,y){return h===43||h===45?I(p)||p===46&&I(y):I(h===46?p:h)}function ne(h){const p=h.consume();if(U(p)){let y=[p];for(;U(...h.peek())&&y.length<5;)y.push(h.consume());B(...h.peek())&&h.consume();const b=parseInt(String.fromCodePoint(...y),16);return b===0||b>1114111?65533:b}return p===void 0?65533:p}function he(h,p){const y=new s("");for(;;){const b=h.consume();if(b===p||b===void 0)return y;if(b===10)return h.reconsume(b),new a;if(b===92){const C=h.peek()[0];C===void 0||(R(C)?h.consume():y.value+=String.fromCodePoint(ne(h)))}else y.value+=String.fromCodePoint(b)}}function oe(h){let p="";for(;;){const y=h.consume();if(J(y))p+=String.fromCodePoint(y);else{if(!se(...h.peek()))return h.reconsume(y),p;p+=String.fromCodePoint(ne(h))}}}function le(h){let p=function(y){let b="integer",C="";for([43,45].includes(y.peek()[0])&&(C+=String.fromCodePoint(y.consume()));I(...y.peek());)C+=String.fromCodePoint(y.consume());if(y.peek()[0]===46&&I(y.peek()[1]))for(C+=String.fromCodePoint(y.consume(),y.consume()),b="number";I(...y.peek());)C+=String.fromCodePoint(y.consume());return[69,101].includes(y.peek()[0])&&([45,43].includes(y.peek()[1])&&I(y.peek()[2])?(C+=String.fromCodePoint(y.consume(),y.consume(),y.consume()),b="number"):I(y.peek()[1])&&(C+=String.fromCodePoint(y.consume(),y.consume()),b="number")),{value:parseFloat(C),type:b}}(h);return W(...h.peek())?new f(p.value,p.type,oe(h)):h.peek()[0]===37?(h.consume(),new d(p.value)):new u(p.value,p.type)}function xe(h){for(;;){const p=h.consume();if(p===41||p===void 0)return;se(...h.peek())&&ne(h)}}function ge(h){const p=oe(h);if(p.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(p):function(y){const b=new o("");for(;B(...y.peek());)y.consume();for(;;){const C=y.consume();if(C===41||C===void 0)return b;if(B(C)){for(;B(...y.peek());)y.consume();return y.peek()[0]===41||y.peek()[0]===void 0?(y.consume(),b):(xe(y),new c)}if([34,39,40].includes(C)||H(C))return xe(y),new c;if(C===92){if(!se(...y.peek()))return xe(y),new c;b.value+=ne(y)}else b.value+=String.fromCodePoint(C)}}(h)}return h.peek()[0]===40?(h.consume(),new t(p)):new e(p)}function de(h){const p=h.consume(),y=h.peek();if(B(p)){for(;B(...h.peek());)h.consume();return new m}if(p===34)return he(h,p);if(p===35){if(J(y[0])||se(...y)){const b=new i;return W(...y)&&(b.type="id"),b.value=oe(h),b}return new l(String.fromCodePoint(p))}return p===39?he(h,p):p===40?new M:p===41?new P:p===43?pe(...y)?(h.reconsume(p),le(h)):new l(String.fromCodePoint(p)):p===44?new w:p===45?pe(...h.peek())?(h.reconsume(p),le(h)):h.peek()[0]===45&&h.peek()[1]===62?(h.consume(),h.consume(),new _):W(...h.peek())?(h.reconsume(p),ge(h)):new l(String.fromCodePoint(p)):p===46?pe(...h.peek())?(h.reconsume(p),le(h)):new l(String.fromCodePoint(p)):p===58?new g:p===59?new v:p===60?y[0]===33&&y[1]===45&&y[2]===45?(h.consume(),h.consume(),h.consume(),new x):new l(String.fromCodePoint(p)):p===64?W(...y)?new n(oe(h)):new l(String.fromCodePoint(p)):p===91?new S:p===92?se(...y)?(h.reconsume(p),ge(h)):new l(String.fromCodePoint(p)):p===93?new T:p===123?new E:p===125?new O:I(p)?(h.reconsume(p),le(h)):L(p)?(h.reconsume(p),ge(h)):p===void 0?void 0:new l(String.fromCodePoint(p))}const re=new Set(["px","deg","s","hz","dppx","number","fr"]);function Ze(h){return re.has(h.toLowerCase())}function Ue(h,p){if(["x","y"].includes(h))return h;if(!p)throw new Error("To determine the normalized axis the computedStyle of the source is required.");const y=p.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 ke(h){const p=[];let y=0;function b(){let k=0;const z=y;for(;y<h.length;){const D=h.slice(y,y+1);if(/\s/.test(D)&&k===0)break;if(D==="(")k+=1;else if(D===")"&&(k-=1,k===0)){y++;break}y++}return h.slice(z,y)}function C(){for(;/\s/.test(h.slice(y,y+1));)y++}for(;y<h.length;){const k=h.slice(y,y+1);/\s/.test(k)?C():p.push(b())}return p}function lt(h,p){return h.reduce((y,b)=>(y.has(b[p])?y.get(b[p]).push(b):y.set(b[p],[b]),y),new Map)}function De(h,p){const y=[],b=[];for(const C of h)p(C)?y.push(C):b.push(C);return[y,b]}function ve(h,p={}){function y(b){return Array.from(b).map(C=>ve(C,p))}if(h instanceof CSSUnitValue){if(h.unit==="percent"&&p.percentageReference){const C=h.value/100*p.percentageReference.value,k=p.percentageReference.unit;return new CSSUnitValue(C,k)}const b=h.toSum();if(b&&b.values.length===1&&(h=b.values[0]),h instanceof CSSUnitValue&&h.unit==="em"&&p.fontSize&&(h=new CSSUnitValue(h.value*p.fontSize.value,p.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(ve(h.value,p));break;case"clamp":h=new CSSMathClamp(ve(h.lower,p),ve(h.value,p),ve(h.upper,p));break;case"invert":h=new CSSMathInvert(ve(h.value,p));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 b=Array.from(h.values);if(b.every(C=>C instanceof CSSUnitValue&&C.unit!=="percent"&&Ze(C.unit)&&C.unit===b[0].unit)){const C=Math[h.operator].apply(Math,b.map(({value:k})=>k));return new CSSUnitValue(C,b[0].unit)}}if(h instanceof CSSMathMin||h instanceof CSSMathMax){const b=Array.from(h.values),[C,k]=De(b,D=>D instanceof CSSUnitValue&&D.unit!=="percent"),z=Array.from(lt(C,"unit").values());if(z.some(D=>D.length>0)){const D=z.map(N=>{const F=Math[h.operator].apply(Math,N.map(({value:X})=>X));return new CSSUnitValue(F,N[0].unit)});h=h instanceof CSSMathMin?new CSSMathMin(...D,...k):new CSSMathMax(...D,...k)}return b.length===1?b[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 b=function(k){const z=k.filter(D=>D instanceof CSSUnitValue);return[...k.filter(D=>!(D instanceof CSSUnitValue)),...Array.from(lt(z,"unit").entries()).map(([D,N])=>{const F=N.reduce((X,{value:Z})=>X+Z,0);return new CSSUnitValue(F,D)})]},C=[];for(const k of h.values)k instanceof CSSMathSum?C.push(...k.values):C.push(k);return C=b(C),C.length===1?C[0]:new CSSMathSum(...C)}if(h instanceof CSSMathProduct){let b=[];for(const z of h.values)z instanceof CSSMathProduct?b.push(...z.values):b.push(z);const[C,k]=De(b,z=>z instanceof CSSUnitValue&&z.unit==="number");if(C.length>1){const z=C.reduce((D,{value:N})=>D*N,1);b=[new CSSUnitValue(z,"number"),...k]}if(b.length===2){let z,D;for(const N of b)N instanceof CSSUnitValue&&N.unit==="number"?z=N:N instanceof CSSMathSum&&[...N.values].every(F=>F instanceof CSSUnitValue)&&(D=N);if(z&&D)return new CSSMathSum(...[...D.values].map(N=>new CSSUnitValue(N.value*z.value,N.unit)))}if(b.every(z=>z instanceof CSSUnitValue&&Ze(z.unit)||z instanceof CSSMathInvert&&z.value instanceof CSSUnitValue&&Ze(z.value.unit))){const z=new CSSMathProduct(...b).toSum();if(z&&z.values.length===1)return z.values[0]}return new CSSMathProduct(...b)}return h}const ue=null,ft=["percent","length","angle","time","frequency","resolution","flex"],Re={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}}},fe=new Map;for(const h of Object.values(Re))if(h.compatible)for(const p of h.units)fe.set(p,h);function rt(h){return fe.get(h)}function wt(h,p){const y={...h};for(const b of Object.keys(p))y[b]?y[b]+=p[b]:y[b]=p[b];return y}function _t(h){return h==="number"?{}:h==="percent"?{percent:1}:Re.absoluteLengths.units.has(h)||Re.fontRelativeLengths.units.has(h)||Re.viewportRelativeLengths.units.has(h)?{length:1}:Re.angle.units.has(h)?{angle:1}:Re.time.units.has(h)?{time:1}:Re.frequency.units.has(h)?{frequency:1}:Re.resolution.units.has(h)?{resolution:1}:h==="fr"?{flex:1}:ue}function st(h){if(h instanceof CSSUnitValue){let{unit:p,value:y}=h;const b=rt(h.unit);return b&&p!==b.canonicalUnit&&(y*=b.ratios[p],p=b.canonicalUnit),p==="number"?[[y,{}]]:[[y,{[p]:1}]]}if(h instanceof CSSMathInvert){if(!(h.value instanceof CSSUnitValue))throw new Error("Not implemented");const p=st(h.value);if(p===ue||p.length>1)return ue;const y=p[0],b={};for(const[C,k]of Object.entries(y[1]))b[C]=-1*k;return p[0]=[1/y[0],b],p}if(h instanceof CSSMathProduct){let p=[[1,{}]];for(const y of h.values){const b=st(y),C=[];if(b===ue)return ue;for(const k of p)for(const z of b)C.push([k[0]*z[0],wt(k[1],z[1])]);p=C}return p}throw new Error("Not implemented")}function Tt(h,p){if(_t(p)===ue)throw new SyntaxError("The string did not match the expected pattern.");const y=st(h);if(!y)throw new TypeError;if(y.length>1)throw new TypeError("Sum has more than one item");const b=function(C,k){const z=C.unit,D=C.value,N=rt(z),F=rt(k);return!F||N!==F?ue:new CSSUnitValue(D*F.ratios[z]/F.ratios[k],k)}(mt(y[0]),p);if(b===ue)throw new TypeError;return b}function mt(h){const[p,y]=h,b=Object.entries(y);if(b.length>1)return ue;if(b.length===0)return new CSSUnitValue(p,"number");const C=b[0];return C[1]!==1?ue:new CSSUnitValue(p,C[0])}function yt(h,...p){if(p&&p.length)throw new Error("Not implemented");const y=st(h).map(b=>mt(b));if(y.some(b=>b===ue))throw new TypeError("Type error");return new CSSMathSum(...y)}function ut(h,p){if(h.percentHint&&p.percentHint&&h.percentHint!==p.percentHint)return ue;const y={...h,percentHint:h.percentHint??p.percentHint};for(const b of ft)p[b]&&(y[b]??(y[b]=0),y[b]+=p[b]);return y}class Ae{constructor(p,y){Me(this,"name"),Me(this,"values"),this.name=p,this.values=y}}class Ke{constructor(p,y){Me(this,"value"),Me(this,"associatedToken"),this.value=p,this.associatedToken=y}}function ht(h){if(Array.isArray(h))return h;if(typeof h=="string")return function(p){const y=new A(p),b=[];for(;;){const C=de(y);if(C===void 0)return b;b.push(C)}}(h);throw new TypeError("Invalid input type "+typeof h)}function Qe(h){const p=h.shift();return p instanceof E||p instanceof S||p instanceof M?function(y,b){let C;if(b instanceof E)C=O;else if(b instanceof M)C=P;else{if(!(b instanceof S))return;C=T}const k=new Ke([],b);for(;;){const z=y.shift();if(z instanceof C||z===void 0)return k;y.unshift(z),k.value.push(Qe(y))}}(h,p):p instanceof t?function(y,b){const C=new Ae(y.value,[]);for(;;){const k=b.shift();if(k instanceof P||k===void 0)return C;b.unshift(k),C.values.push(Qe(b))}}(p,h):p}function $(h){if(h instanceof M||h instanceof P)return 6;if(h instanceof l)switch(h.value){case"*":case"/":return 4;case"+":case"-":return 2}}function Mt(h){return h[h.length-1]}function jt(h,p,y){const b=["+","-"].includes(h.value)?"ADDITION":"MULTIPLICATION",C=p.type===b?p.values:[p],k=y.type===b?y.values:[y];return h.value==="-"?k[0]={type:"NEGATE",value:k[0]}:h.value==="/"&&(k[0]={type:"INVERT",value:k[0]}),{type:b,values:[...C,...k]}}function Ct(h){if(h.type==="ADDITION")return new CSSMathSum(...h.values.map(p=>Ct(p)));if(h.type==="MULTIPLICATION")return new CSSMathProduct(...h.values.map(p=>Ct(p)));if(h.type==="NEGATE")return new CSSMathNegate(Ct(h.value));if(h.type==="INVERT")return new CSSMathInvert(Ct(h.value));if(h instanceof Ke)return ae(new Ae("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 Io(h)}function ae(h){if(h.name==="min"||h.name==="max"){const b=h.values.filter(C=>!(C instanceof m||C instanceof w)).map(C=>ve(ae(new Ae("calc",C))));return h.name==="min"?new CSSMathMin(...b):new CSSMathMax(...b)}if(h.name!=="calc")return null;const p=Ct(function(b){const C=[],k=[];for(;b.length;){const z=b.shift();if(z instanceof u||z instanceof f||z instanceof d||z instanceof Ae||z instanceof Ke||z instanceof e)k.push(z);else if(z instanceof l&&["*","/","+","-"].includes(z.value)){for(;C.length&&!(Mt(C)instanceof M)&&$(Mt(C))>$(z);){const D=C.pop(),N=k.pop(),F=k.pop();k.push(jt(D,F,N))}C.push(z)}else if(z instanceof M)C.push(z);else if(z instanceof P){if(!C.length)return null;for(;!(Mt(C)instanceof M);){const D=C.pop(),N=k.pop(),F=k.pop();k.push(jt(D,F,N))}if(!(Mt(C)instanceof M))return null;C.pop()}else if(!(z instanceof m))return null}for(;C.length;){if(Mt(C)instanceof M)return null;const z=C.pop(),D=k.pop(),N=k.pop();k.push(jt(z,N,D))}return k[0]}([...h.values]));let y;try{y=ve(p)}catch{new CSSStyleSheet().insertRule("error",0)}return y instanceof CSSUnitValue?new CSSMathSum(y):y}function Io(h){return h instanceof Ae&&["calc","min","max","clamp"].includes(h.name)?ae(h):h instanceof u&&h.value===0&&!h.unit?new CSSUnitValue(0,"px"):h instanceof u?new CSSUnitValue(h.value,"number"):h instanceof d?new CSSUnitValue(h.value,"percent"):h instanceof f?new CSSUnitValue(h.value,h.unit):void 0}function Bl(h){const p=function(y){const b=ht(y);for(;b[0]instanceof m;)b.shift();if(b[0]===void 0)return null;const C=Qe(b);for(;b[0]instanceof m;)b.shift();return b[0]===void 0?C:null}(h);return p===null&&new CSSStyleSheet().insertRule("error",0),p instanceof u||p instanceof d||p instanceof f||p instanceof Ae||new CSSStyleSheet().insertRule("error",0),p instanceof f&&_t(p.unit)===null&&new CSSStyleSheet().insertRule("error",0),Io(p)}(function(){let h=new WeakMap;function p(k){const z=[];for(let N=0;N<k.length;N++)z[N]=typeof(D=k[N])=="number"?new CSSUnitValue(D,"number"):D;var D;return z}class y{static parse(z){return z instanceof y?z:ve(Bl(z),{})}}class b extends y{constructor(z,D,N,F){super(),h.set(this,{values:p(z),operator:D,name:N||D,delimiter:F||", "})}get operator(){return h.get(this).operator}get values(){return h.get(this).values}toString(){const z=h.get(this);return`${z.name}(${z.values.join(z.delimiter)})`}}const C={CSSNumericValue:y,CSSMathValue:b,CSSUnitValue:class extends y{constructor(k,z){super(),h.set(this,{value:k,unit:z})}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 Tt(this,k)}toSum(...k){return yt(this,...k)}type(){return _t(h.get(this).unit)}toString(){const k=h.get(this);return`${k.value}${function(z){switch(z){case"percent":return"%";case"number":return"";default:return z.toLowerCase()}}(k.unit)}`}},CSSKeywordValue:class{constructor(k){this.value=k}toString(){return this.value.toString()}},CSSMathSum:class extends b{constructor(k){super(arguments,"sum","calc"," + ")}},CSSMathProduct:class extends b{constructor(k){super(arguments,"product","calc"," * ")}toSum(...k){return yt(this,...k)}type(){return h.get(this).values.map(k=>k.type()).reduce(ut)}},CSSMathNegate:class extends b{constructor(k){super([arguments[0]],"negate","-")}get value(){return h.get(this).values[0]}type(){return this.value.type()}},CSSMathInvert:class extends b{constructor(k){super([1,arguments[0]],"invert","calc"," / ")}get value(){return h.get(this).values[1]}type(){return function(k){const z={};for(const D of ft)z[D]=-1*k[D];return z}(h.get(this).values[1].type())}},CSSMathMax:class extends b{constructor(){super(arguments,"max")}},CSSMathMin:class extends b{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:z=>new CSSUnitValue(z,k)}))throw Error(`Error installing CSS.${k}`)});for(let[k,z]of Object.entries(C))if(!(k in window)&&!Reflect.defineProperty(window,k,{value:z}))throw Error(`Error installing CSSOM support for ${k}`)})();const Bo="block";let Ge=new WeakMap,Jt=new WeakMap;const tr=["entry","exit","cover","contain","entry-crossing","exit-crossing"];function zo(h){return h===document.scrollingElement?document:h}function dn(h){as(h);let p=Ge.get(h).animations;if(p.length===0)return;let y=h.currentTime;for(let b=0;b<p.length;b++)p[b].tickAnimation(y)}function No(h,p){if(!h)return null;const y=Jt.get(h).sourceMeasurements,b=getComputedStyle(h);let C=y.scrollTop;return Ue(p,b)==="x"&&(C=Math.abs(y.scrollLeft)),C}function os(h,p){const y=ve(h,p);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 as(h){if(!(h instanceof kn))return void function(y){const b=Ge.get(y);if(!b.anonymousSource)return;const C=Do(b.anonymousSource,b.anonymousTarget);Qn(y,C)}(h);const p=h.subject;if(!p||getComputedStyle(p).display=="none")return void Qn(h,null);Qn(h,ps(p))}function Uo(h){return["block","inline","x","y"].includes(h)}function cs(h){const p=getComputedStyle(h);return{scrollLeft:h.scrollLeft,scrollTop:h.scrollTop,scrollWidth:h.scrollWidth,scrollHeight:h.scrollHeight,clientWidth:h.clientWidth,clientHeight:h.clientHeight,writingMode:p.writingMode,direction:p.direction,scrollPaddingTop:p.scrollPaddingTop,scrollPaddingBottom:p.scrollPaddingBottom,scrollPaddingLeft:p.scrollPaddingLeft,scrollPaddingRight:p.scrollPaddingRight}}function ls(h,p){if(!h||!p)return;let y=0,b=0,C=p;const k=h.offsetParent;for(;C&&C!=k;)b+=C.offsetLeft,y+=C.offsetTop,C=C.offsetParent;b-=h.offsetLeft+h.clientLeft,y-=h.offsetTop+h.clientTop;const z=getComputedStyle(p);return{top:y,left:b,offsetWidth:p.offsetWidth,offsetHeight:p.offsetHeight,fontSize:z.fontSize}}function nr(h){let p=Jt.get(h);p.sourceMeasurements=cs(h);for(const y of p.timelineRefs){const b=y.deref();b instanceof kn&&(Ge.get(b).subjectMeasurements=ls(h,b.subject))}p.updateScheduled||(setTimeout(()=>{for(const y of p.timelineRefs){const b=y.deref();b&&dn(b)}p.updateScheduled=!1}),p.updateScheduled=!0)}function Qn(h,p){const y=Ge.get(h),b=y.source;if(b!=p){if(b){const C=Jt.get(b);if(C){C.timelineRefs.delete(h);const k=Array.from(C.timelineRefs).filter(z=>z.deref()===void 0);for(const z of k)C.timelineRefs.delete(z);C.timelineRefs.size===0&&(C.disconnect(),Jt.delete(b))}}if(y.source=p,p){let C=Jt.get(p);if(!C){C={timelineRefs:new Set,sourceMeasurements:cs(p)},Jt.set(p,C);const k=new ResizeObserver(N=>{for(const F of N)nr(y.source)});k.observe(p);for(const N of p.children)k.observe(N);const z=new MutationObserver(N=>{for(const F of N)nr(F.target)});z.observe(p,{attributes:!0,attributeFilter:["style","class"]});const D=()=>{C.sourceMeasurements.scrollLeft=p.scrollLeft,C.sourceMeasurements.scrollTop=p.scrollTop;for(const N of C.timelineRefs){const F=N.deref();F&&dn(F)}};zo(p).addEventListener("scroll",D),C.disconnect=()=>{k.disconnect(),z.disconnect(),zo(p).removeEventListener("scroll",D)}}C.timelineRefs.add(new WeakRef(h))}}}function us(h,p){let y=Ge.get(h).animations;for(let b=0;b<y.length;b++)y[b].animation==p&&y.splice(b,1)}function hs(h,p,y){let b=Ge.get(h).animations;for(let C=0;C<b.length;C++)if(b[C].animation==p)return;b.push({animation:p,tickAnimation:y}),queueMicrotask(()=>{dn(h)})}class $e{constructor(p){if(Ge.set(this,{source:null,axis:Bo,anonymousSource:p?p.anonymousSource:null,anonymousTarget:p?p.anonymousTarget:null,subject:null,inset:null,animations:[],subjectMeasurements:null}),Qn(this,p&&p.source!==void 0?p.source:document.scrollingElement),p&&p.axis!==void 0&&p.axis!=Bo){if(!Uo(p.axis))throw TypeError("Invalid axis");Ge.get(this).axis=p.axis}dn(this)}set source(p){Qn(this,p),dn(this)}get source(){return Ge.get(this).source}set axis(p){if(!Uo(p))throw TypeError("Invalid axis");Ge.get(this).axis=p,dn(this)}get axis(){return Ge.get(this).axis}get duration(){return CSS.percent(100)}get phase(){const p=this.source;if(!p)return"inactive";let y=getComputedStyle(p);return y.display=="none"?"inactive":p==document.scrollingElement||y.overflow!="visible"&&y.overflow!="clip"?"active":"inactive"}get currentTime(){const p=this.source;if(!p||!p.isConnected||this.phase=="inactive")return null;const y=getComputedStyle(p);if(y.display==="inline"||y.display==="none")return null;const b=this.axis,C=No(p,b),k=function(z,D){const N=Jt.get(z).sourceMeasurements,F=getComputedStyle(z).writingMode=="horizontal-tb";return D==="block"?D=F?"y":"x":D==="inline"&&(D=F?"x":"y"),D==="y"?N.scrollHeight-N.clientHeight:D==="x"?N.scrollWidth-N.clientWidth:void 0}(p,b);return k>0?CSS.percent(100*C/k):CSS.percent(100)}get __polyfill(){return!0}}function ds(h,p){let y=h.parentElement;for(;y!=null;){if(p(y))return y;y=y.parentElement}}function Do(h,p){switch(h){case"root":return document.scrollingElement;case"nearest":return ps(p);case"self":return p;default:throw new TypeError("Invalid ScrollTimeline Source Type.")}}function zl(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 Lo(h){const p=getComputedStyle(h);return p.transform!="none"||p.perspective!="none"||p.willChange=="transform"||p.willChange=="perspective"||p.filter!="none"||p.willChange=="filter"||p.backdropFilter!="none"}function Nl(h){return getComputedStyle(h).position!="static"||Lo(h)}function Ul(h){switch(getComputedStyle(h).position){case"static":case"relative":case"sticky":return ds(h,zl);case"absolute":return ds(h,Nl);case"fixed":return ds(h,Lo)}}function ps(h){if(h&&h.isConnected){for(;h=Ul(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 $n(h,p){const y=Ge.get(h),b=y.subjectMeasurements,C=Jt.get(y.source).sourceMeasurements;return h.phase==="inactive"?null:h instanceof kn?fs(p,C,b,y.axis,y.inset):null}function fs(h,p,y,b,C){const k=p.direction=="rtl"||p.writingMode=="vertical-rl";let z,D,N={fontSize:y.fontSize};Ue(b,p)==="x"?(z=y.offsetWidth,D=y.left,N.scrollPadding=[p.scrollPaddingLeft,p.scrollPaddingRight],k&&(D+=p.scrollWidth-p.clientWidth,N.scrollPadding=[p.scrollPaddingRight,p.scrollPaddingLeft]),N.containerSize=p.clientWidth):(z=y.offsetHeight,D=y.top,N.scrollPadding=[p.scrollPaddingTop,p.scrollPaddingBottom],N.containerSize=p.clientHeight);const F=function(vs,ar){const Yl={start:0,end:0};if(!vs)return Yl;const[Zl,Kl]=[vs.start,vs.end].map((ea,ta)=>ea==="auto"?ar.scrollPadding[ta]==="auto"?0:parseFloat(ar.scrollPadding[ta]):os(ea,{percentageReference:CSS.px(ar.containerSize),fontSize:CSS.px(parseFloat(ar.fontSize))}));return{start:Zl,end:Kl}}(C,N),X=D-N.containerSize+F.end,Z=D+z-F.start,K=X+z,me=Z-z,_e=Math.min(K,me),ot=Math.max(K,me);let Pt,gt;const $o=z>N.containerSize-F.start-F.end;switch(h){case"cover":Pt=X,gt=Z;break;case"contain":Pt=_e,gt=ot;break;case"entry":Pt=X,gt=_e;break;case"exit":Pt=ot,gt=Z;break;case"entry-crossing":Pt=X,gt=$o?ot:_e;break;case"exit-crossing":Pt=$o?_e:ot,gt=Z}return{start:Pt,end:gt}}function Fo(h,p){if(h instanceof kn){const{rangeName:y,offset:b}=p;return Vo($n(h,y),b,$n(h,"cover"),h.subject)}if(h instanceof $e){const{axis:y,source:b}=h,{sourceMeasurements:C}=Jt.get(b);let k;return k=Ue(y,C)==="x"?C.scrollWidth-C.clientWidth:C.scrollHeight-C.clientHeight,os(p,{percentageReference:CSS.px(k)})/k}unsupportedTimeline(h)}function Vo(h,p,y,b){if(!h||!y)return 0;let C=getComputedStyle(b);return(os(p,{percentageReference:CSS.px(h.end-h.start),fontSize:CSS.px(parseFloat(C.fontSize))})+h.start-y.start)/(y.end-y.start)}let kn=class extends $e{constructor(h){super(h);const p=Ge.get(this);p.subject=h&&h.subject?h.subject:void 0,h&&h.inset&&(p.inset=function(y){if(!y)return{start:0,end:0};let b;if(b=typeof y=="string"?ke(y).map(C=>{if(C==="auto")return"auto";try{return CSSNumericValue.parse(C)}catch{throw TypeError(`Could not parse inset "${y}"`)}}):Array.isArray(y)?y:[y],b.length===0||b.length>2)throw TypeError("Invalid inset");for(const C of b){if(C==="auto")continue;const k=C.type();if(k.length!==1&&k.percent!==1)throw TypeError("Invalid inset")}return{start:b[0],end:b[1]??b[0]}}(h.inset)),p.subject&&(new ResizeObserver(()=>{nr(p.source)}).observe(p.subject),new MutationObserver(()=>{nr(p.source)}).observe(p.subject,{attributes:!0,attributeFilter:["class","style"]})),as(this),p.subjectMeasurements=ls(p.source,p.subject),dn(this)}get source(){return as(this),Ge.get(this).source}set source(h){throw new Error("Cannot set the source of a view timeline")}get subject(){return Ge.get(this).subject}get axis(){return Ge.get(this).axis}get currentTime(){const h=No(this.source,this.axis);if(h==null)return null;const p=$n(this,"cover");if(!p)return null;const y=(h-p.start)/(p.end-p.start);return CSS.percent(100*y)}get startOffset(){return CSS.px($n(this,"cover").start)}get endOffset(){return CSS.px($n(this,"cover").end)}};const Dl=document.getAnimations,Ll=window.Element.prototype.getAnimations,Fl=window.Element.prototype.animate,jo=window.Animation;class Rn{constructor(){this.state="pending",this.nativeResolve=this.nativeReject=null,this.promise=new Promise((p,y)=>{this.nativeResolve=p,this.nativeReject=y})}resolve(p){this.state="resolved",this.nativeResolve(p)}reject(p){this.state="rejected",this.promise.catch(()=>{}),this.nativeReject(p)}}function ei(h){h.readyPromise=new Rn,requestAnimationFrame(()=>{var p;(((p=h.timeline)==null?void 0:p.currentTime)??null)!==null&&(ir(h),h.pendingTask!=="play"||h.startTime===null&&h.holdTime===null?h.pendingTask==="pause"&&Wo(h):Go(h))})}function Jo(){return new DOMException("The user aborted a request","AbortError")}function pn(h,p){if(p===null)return p;if(typeof p!="number")throw new DOMException(`Unexpected value: ${p}. Cannot convert to CssNumberish`,"InvalidStateError");const y=h.rangeDuration??100,b=Wt(h),C=b?y*p/b:0;return CSS.percent(C)}function Se(h,p){if(h.timeline){if(p===null)return p;if(p.unit==="percent"){const y=h.rangeDuration??100,b=Wt(h);return p.value*b/y}throw new DOMException("CSSNumericValue must be a percentage for progress based animations.","NotSupportedError")}{if(p==null||typeof p=="number")return p;const y=p.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 Go(h){const p=Se(h,h.timeline.currentTime);if(h.holdTime!=null)Bt(h),h.animation.playbackRate==0?h.startTime=p:(h.startTime=p-h.holdTime/h.animation.playbackRate,h.holdTime=null);else if(h.startTime!==null&&h.pendingPlaybackRate!==null){const y=(p-h.startTime)*h.animation.playbackRate;Bt(h);const b=h.animation.playbackRate;b==0?(h.holdTime=null,h.startTime=p):h.startTime=p-y/b}h.readyPromise&&h.readyPromise.state=="pending"&&h.readyPromise.resolve(h.proxy),Gt(h,!1,!1),Ht(h),h.pendingTask=null}function Wo(h){const p=Se(h,h.timeline.currentTime);h.startTime!=null&&h.holdTime==null&&(h.holdTime=(p-h.startTime)*h.animation.playbackRate),Bt(h),h.startTime=null,h.readyPromise.resolve(h.proxy),Gt(h,!1,!1),Ht(h),h.pendingTask=null}function Ho(h){if(!h.finishedPromise||h.finishedPromise.state!="pending"||h.proxy.playState!="finished")return;h.finishedPromise.resolve(h.proxy),h.animation.pause();const p=new CustomEvent("finish",{detail:{currentTime:h.proxy.currentTime,timelineTime:h.proxy.timeline.currentTime}});Object.defineProperty(p,"currentTime",{get:function(){return this.detail.currentTime}}),Object.defineProperty(p,"timelineTime",{get:function(){return this.detail.timelineTime}}),requestAnimationFrame(()=>{queueMicrotask(()=>{h.animation.dispatchEvent(p)})})}function An(h){return h.pendingPlaybackRate!==null?h.pendingPlaybackRate:h.animation.playbackRate}function Bt(h){h.pendingPlaybackRate!==null&&(h.animation.playbackRate=h.pendingPlaybackRate,h.pendingPlaybackRate=null)}function qo(h){if(!h.timeline)return null;const p=Se(h,h.timeline.currentTime);if(p===null||h.startTime===null)return null;let y=(p-h.startTime)*h.animation.playbackRate;return y==-0&&(y=0),y}function Gt(h,p,y){if(!h.timeline)return;let b=p?Se(h,h.proxy.currentTime):qo(h);if(b&&h.startTime!=null&&!h.proxy.pending){const C=An(h),k=Wt(h);let z=h.previousCurrentTime;C>0&&b>=k&&h.previousCurrentTime!=null?((z===null||z<k)&&(z=k),h.holdTime=p?b:z):C<0&&b<=0?((z==null||z>0)&&(z=0),h.holdTime=p?b:z):C!=0&&(p&&h.holdTime!==null&&(h.startTime=function(D,N){if(!D.timeline)return null;const F=Se(D,D.timeline.currentTime);return F==null?null:F-N/D.animation.playbackRate}(h,h.holdTime)),h.holdTime=null)}Ht(h),h.previousCurrentTime=Se(h,h.proxy.currentTime),h.proxy.playState=="finished"?(h.finishedPromise||(h.finishedPromise=new Rn),h.finishedPromise.state=="pending"&&(y?Ho(h):Promise.resolve().then(()=>{Ho(h)}))):(h.finishedPromise&&h.finishedPromise.state=="resolved"&&(h.finishedPromise=new Rn),h.animation.playState!="paused"&&h.animation.pause())}function Wt(h){const p=function(b){const C=b.proxy.effect.getTiming();return b.normalizedTiming||C}(h),y=p.delay+p.endDelay+p.iterations*p.duration;return Math.max(0,y)}function Ht(h){if(h.timeline)if(h.startTime!==null){const p=h.timeline.currentTime;if(p==null)return;ms(h,(Se(h,p)-h.startTime)*h.animation.playbackRate)}else h.holdTime!==null&&ms(h,h.holdTime)}function ms(h,p){const y=h.timeline,b=h.animation.playbackRate,C=y.currentTime&&y.currentTime.value==(b<0?0:100)?b<0?.001:-.001:0;h.animation.currentTime=p+C}function ys(h,p){if(!h.timeline)return;const y=h.proxy.playState=="paused"&&h.proxy.pending;let b=!1,C=Se(h,h.proxy.currentTime);An(h)==0&&C==null&&(h.holdTime=0),C==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,b=!0),(h.holdTime!==null||h.autoAlignStartTime||y||h.pendingPlaybackRate!==null)&&(h.readyPromise&&!b&&(h.readyPromise=null),Ht(h),h.readyPromise||ei(h),h.pendingTask="play",hs(h.timeline,h.animation,gs.bind(h.proxy)),Gt(h,!1,!1))}function gs(h){const p=Y.get(this);if(!p)return;if(h==null)return void(p.proxy.playState!=="paused"&&p.animation.playState!="idle"&&p.animation.cancel());ir(p),p.pendingTask&&requestAnimationFrame(()=>{p.pendingTask!=="play"||p.startTime===null&&p.holdTime===null?p.pendingTask==="pause"&&Wo(p):Go(p)});const y=this.playState;if(y=="running"||y=="finished"){const b=Se(p,h);ms(p,(b-Se(p,this.startTime))*this.playbackRate),Gt(p,!1,!1)}}function Xo(h){h.specifiedTiming=null}let Y=new WeakMap;window.addEventListener("pagehide",h=>{Y=new WeakMap},!1);let Yo=new WeakMap;function ir(h){if(!h.autoAlignStartTime||!h.timeline||!h.timeline.currentTime||h.proxy.playState==="idle"||h.proxy.playState==="paused"&&h.holdTime!==null)return;const p=h.rangeDuration;let y,b;try{y=CSS.percent(100*function(k){if(!k.animationRange)return 0;const z=k.animationRange.start==="normal"?Zo(k.timeline):k.animationRange.start;return Fo(k.timeline,z)}(h))}catch(k){y=CSS.percent(0),h.animationRange.start="normal",console.warn("Exception when calculating start offset",k)}try{b=CSS.percent(100*(1-function(k){if(!k.animationRange)return 0;const z=k.animationRange.end==="normal"?Ko(k.timeline):k.animationRange.end;return 1-Fo(k.timeline,z)}(h)))}catch(k){b=CSS.percent(100),h.animationRange.end="normal",console.warn("Exception when calculating end offset",k)}h.rangeDuration=b.value-y.value;const C=An(h);h.startTime=Se(h,C>=0?y:b),h.holdTime=null,h.rangeDuration!==p&&Xo(h)}function rr(h){throw new Error("Unsupported timeline class")}function Zo(h){return h instanceof ViewTimeline?{rangeName:"cover",offset:CSS.percent(0)}:h instanceof $e?CSS.percent(0):void rr()}function Ko(h){return h instanceof ViewTimeline?{rangeName:"cover",offset:CSS.percent(100)}:h instanceof $e?CSS.percent(100):void rr()}function Vl(h,p){if(!p)return{start:"normal",end:"normal"};const y={start:Zo(h),end:Ko(h)};if(h instanceof ViewTimeline){const b=ke(p),C=[],k=[];if(b.forEach(z=>{if(tr.includes(z))C.push(z);else try{k.push(CSSNumericValue.parse(z))}catch{throw TypeError(`Could not parse range "${p}"`)}}),C.length>2||k.length>2||k.length==1)throw TypeError("Invalid time range or unsupported time range format.");return C.length&&(y.start.rangeName=C[0],y.end.rangeName=C.length>1?C[1]:C[0]),k.length>1&&(y.start.offset=k[0],y.end.offset=k[1]),y}if(h instanceof $e){const b=p.split(" ");if(b.length!=2)throw TypeError("Invalid time range or unsupported time range format.");return y.start=CSSNumericValue.parse(b[0]),y.end=CSSNumericValue.parse(b[1]),y}rr()}function sr(h,p,y){if(!p||p==="normal")return"normal";if(h instanceof ViewTimeline){let b="cover",C=y==="start"?CSS.percent(0):CSS.percent(100);if(p instanceof Object)p.rangeName!==void 0&&(b=p.rangeName),p.offset!==void 0&&(C=p.offset);else{const k=ke(p);k.length===1?tr.includes(k[0])?b=k[0]:C=ve(CSSNumericValue.parse(k[0]),{}):k.length===2&&(b=k[0],C=ve(CSSNumericValue.parse(k[1]),{}))}if(!tr.includes(b))throw TypeError("Invalid range name");return{rangeName:b,offset:C}}if(h instanceof $e)return CSSNumericValue.parse(p);rr()}class or{constructor(p,y,b={}){const C=y instanceof $e,k=p instanceof jo?p:new jo(p,C?void 0:y);Yo.set(k,this),Y.set(this,{animation:k,timeline:C?y:void 0,playState:C?"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:C?Vl(y,b["animation-range"]):null,proxy:this})}get effect(){const p=Y.get(this);return p.timeline?(p.effect||(p.effect=function(y){const b=y.animation.effect,C=b.updateTiming,k={apply:function(F){b.getTiming();const X=F.apply(b);if(y.timeline){const Z=y.duration??100;X.localTime=pn(y,X.localTime),X.endTime=pn(y,X.endTime),X.activeDuration=pn(y,X.activeDuration);const K=Wt(y),me=X.iterations?(K-X.delay-X.endDelay)/X.iterations:0;X.duration=K?CSS.percent(Z*me/K):CSS.percent(0),y.timeline.currentTime===void 0&&(X.localTime=null)}return X}},z={apply:function(F,X){if(y.specifiedTiming)return y.specifiedTiming;y.specifiedTiming=F.apply(b);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),C.apply(b,[K])),y.normalizedTiming=K,y.specifiedTiming}},D={apply:function(F,X,Z){if(Z&&Z.length){if(y.timeline&&Z[0]){const K=Z[0],me=K.duration;if(me===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");me!==void 0&&me!=="auto"&&(y.autoDurationEffect=null)}y.specifiedTiming&&F.apply(b,[y.specifiedTiming]),F.apply(b,Z),Xo(y)}}},N=new Proxy(b,{get:function(F,X){const Z=F[X];return typeof Z=="function"?Z.bind(b):Z},set:function(F,X,Z){return F[X]=Z,!0}});return N.getComputedTiming=new Proxy(b.getComputedTiming,k),N.getTiming=new Proxy(b.getTiming,z),N.updateTiming=new Proxy(b.updateTiming,D),N}(p)),p.effect):p.animation.effect}set effect(p){const y=Y.get(this);y.animation.effect=p,y.effect=null,y.autoDurationEffect=null}get timeline(){const p=Y.get(this);return p.timeline||p.animation.timeline}set timeline(p){const y=Y.get(this),b=this.timeline;if(b==p)return;const C=this.playState,k=this.currentTime;let z,D=Wt(y);z=k===null?null:D===0?0:Se(y,k)/D;const N=b instanceof $e,F=p instanceof $e,X=this.pending;if(N&&us(y.timeline,y.animation),F)return y.timeline=p,Bt(y),y.autoAlignStartTime=!0,y.startTime=null,y.holdTime=null,C!=="running"&&C!=="finished"||(y.readyPromise&&y.readyPromise.state!=="resolved"||ei(y),y.pendingTask="play",hs(y.timeline,y.animation,gs.bind(this))),C==="paused"&&z!==null&&(y.holdTime=z*D),X&&(y.readyPromise&&y.readyPromise.state!="resolved"||ei(y),y.pendingTask=C=="paused"?"pause":"play"),y.startTime!==null&&(y.holdTime=null),void Gt(y,!1,!1);if(y.animation.timeline!=p)throw TypeError("Unsupported timeline: "+p);if(us(y.timeline,y.animation),y.timeline=null,N)switch(k!==null&&(y.animation.currentTime=z*Wt(y)),C){case"paused":y.animation.pause();break;case"running":case"finished":y.animation.play()}}get startTime(){const p=Y.get(this);return p.timeline?pn(p,p.startTime):p.animation.startTime}set startTime(p){const y=Y.get(this);if(p=Se(y,p),!y.timeline)return void(y.animation.startTime=p);y.autoAlignStartTime=!1,Se(y,y.timeline.currentTime)==null&&y.startTime!=null&&(y.holdTime=null,Ht(y));const b=Se(y,this.currentTime);Bt(y),y.startTime=p,y.startTime!==null&&y.animation.playbackRate!=0?y.holdTime=null:y.holdTime=b,y.pendingTask&&(y.pendingTask=null,y.readyPromise.resolve(this)),Gt(y,!0,!1),Ht(y)}get currentTime(){const p=Y.get(this);return p.timeline?p.holdTime!=null?pn(p,p.holdTime):pn(p,qo(p)):p.animation.currentTime}set currentTime(p){const y=Y.get(this);y.timeline?(function(b,C){if(C==null&&b.currentTime!==null)throw new TypeError;C=Se(b,C),b.autoAlignStartTime=!1,b.holdTime!==null||b.startTime===null||b.timeline.phase==="inactive"||b.animation.playbackRate===0?b.holdTime=C:b.startTime=Se(b,b.timeline.currentTime)-C/b.animation.playbackRate,b.timeline.phase==="inactive"&&(b.startTime=null),b.previousCurrentTime=null}(y,p),y.pendingTask=="pause"&&(y.holdTime=Se(y,p),Bt(y),y.startTime=null,y.pendingTask=null,y.readyPromise.resolve(this)),Gt(y,!0,!1)):y.animation.currentTime=p}get playbackRate(){return Y.get(this).animation.playbackRate}set playbackRate(p){const y=Y.get(this);if(!y.timeline)return void(y.animation.playbackRate=p);y.pendingPlaybackRate=null;const b=this.currentTime;y.animation.playbackRate=p,b!==null&&(this.currentTime=b)}get playState(){const p=Y.get(this);if(!p.timeline)return p.animation.playState;const y=Se(p,this.currentTime);return y===null&&p.startTime===null&&p.pendingTask==null?"idle":p.pendingTask=="pause"||p.startTime===null&&p.pendingTask!="play"?"paused":y!=null&&(p.animation.playbackRate>0&&y>=Wt(p)||p.animation.playbackRate<0&&y<=0)?"finished":"running"}get rangeStart(){var p;return((p=Y.get(this).animationRange)==null?void 0:p.start)??"normal"}set rangeStart(p){const y=Y.get(this);if(!y.timeline)return y.animation.rangeStart=p;y.timeline instanceof $e&&(y.animationRange.start=sr(y.timeline,p,"start"),ir(y),Ht(y))}get rangeEnd(){var p;return((p=Y.get(this).animationRange)==null?void 0:p.end)??"normal"}set rangeEnd(p){const y=Y.get(this);if(!y.timeline)return y.animation.rangeEnd=p;y.timeline instanceof $e&&(y.animationRange.end=sr(y.timeline,p,"end"),ir(y),Ht(y))}get replaceState(){return Y.get(this).animation.pending}get pending(){const p=Y.get(this);return p.timeline?!!p.readyPromise&&p.readyPromise.state=="pending":p.animation.pending}finish(){const p=Y.get(this);if(!p.timeline)return void p.animation.finish();const y=An(p),b=Wt(p);if(y==0)throw new DOMException("Cannot finish Animation with a playbackRate of 0.","InvalidStateError");if(y>0&&b==1/0)throw new DOMException("Cannot finish Animation with an infinite target effect end.","InvalidStateError");Bt(p);const C=y<0?0:b;this.currentTime=pn(p,C);const k=Se(p,p.timeline.currentTime);p.startTime===null&&k!==null&&(p.startTime=k-C/p.animation.playbackRate),p.pendingTask=="pause"&&p.startTime!==null&&(p.holdTime=null,p.pendingTask=null,p.readyPromise.resolve(this)),p.pendingTask=="play"&&p.startTime!==null&&(p.pendingTask=null,p.readyPromise.resolve(this)),Gt(p,!0,!0)}play(){const p=Y.get(this);p.timeline?ys(p):p.animation.play()}pause(){const p=Y.get(this);p.timeline?this.playState!="paused"&&(p.animation.currentTime===null&&(p.autoAlignStartTime=!0),p.pendingTask=="play"?p.pendingTask=null:p.readyPromise=null,p.readyPromise||ei(p),p.pendingTask="pause",hs(p.timeline,p.animation,gs.bind(p.proxy))):p.animation.pause()}reverse(){const p=Y.get(this),y=An(p),b=Se(p,this.currentTime),C=Wt(p)==1/0,k=y!=0&&(y<0||b>0||!C);if(!p.timeline||!k)return k&&(p.pendingPlaybackRate=-An(p)),void p.animation.reverse();if(p.timeline.phase=="inactive")throw new DOMException("Cannot reverse an animation with no active timeline","InvalidStateError");this.updatePlaybackRate(-y),ys(p)}updatePlaybackRate(p){const y=Y.get(this);if(y.pendingPlaybackRate=p,!y.timeline)return void y.animation.updatePlaybackRate(p);const b=this.playState;if(!y.readyPromise||y.readyPromise.state!="pending")switch(b){case"idle":case"paused":Bt(y);break;case"finished":const C=Se(y,y.timeline.currentTime),k=C!==null?(C-y.startTime)*y.animation.playbackRate:null;y.startTime=p==0?C:C!=null&&k!=null?(C-k)/p:null,Bt(y),Gt(y,!1,!1),Ht(y);break;default:ys(y)}}persist(){Y.get(this).animation.persist()}get id(){return Y.get(this).animation.id}set id(p){Y.get(this).animation.id=p}cancel(){const p=Y.get(this);p.timeline?(this.playState!="idle"&&(function(y){y.pendingTask&&(y.pendingTask=null,Bt(y),y.readyPromise.reject(Jo()),ei(y),y.readyPromise.resolve(y.proxy))}(p),p.finishedPromise&&p.finishedPromise.state=="pending"&&p.finishedPromise.reject(Jo()),p.finishedPromise=new Rn,p.animation.cancel()),p.startTime=null,p.holdTime=null,us(p.timeline,p.animation)):p.animation.cancel()}get onfinish(){return Y.get(this).animation.onfinish}set onfinish(p){Y.get(this).animation.onfinish=p}get oncancel(){return Y.get(this).animation.oncancel}set oncancel(p){Y.get(this).animation.oncancel=p}get onremove(){return Y.get(this).animation.onremove}set onremove(p){Y.get(this).animation.onremove=p}get finished(){const p=Y.get(this);return p.timeline?(p.finishedPromise||(p.finishedPromise=new Rn),p.finishedPromise.promise):p.animation.finished}get ready(){const p=Y.get(this);return p.timeline?(p.readyPromise||(p.readyPromise=new Rn,p.readyPromise.resolve(this)),p.readyPromise.promise):p.animation.ready}addEventListener(p,y,b){Y.get(this).animation.addEventListener(p,y,b)}removeEventListener(p,y,b){Y.get(this).animation.removeEventListener(p,y,b)}dispatchEvent(p){Y.get(this).animation.dispatchEvent(p)}}function jl(h,p){const y=p.timeline;y instanceof $e&&delete p.timeline;const b=Fl.apply(this,[h,p]),C=new or(b,y);return y instanceof $e&&(b.pause(),Y.get(C).animationRange={start:sr(y,p.rangeStart,"start"),end:sr(y,p.rangeEnd,"end")},C.play()),C}function Qo(h){for(let p=0;p<h.length;++p){let y=Yo.get(h[p]);y&&(h[p]=y)}return h}function Jl(h){return Qo(Ll.apply(this,[h]))}function Gl(h){return Qo(Dl.apply(this,[h]))}const Oe={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\(([^)]*)\)/},On=["block","inline","x","y"],Wl=["nearest","root","self"],tn=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,p,y){const b={sheetSrc:h,index:0,name:y};for(;b.index<b.sheetSrc.length&&(this.eatWhitespace(b),!(b.index>=b.sheetSrc.length));){if(this.lookAhead("/*",b)){for(;this.lookAhead("/*",b);)this.eatComment(b),this.eatWhitespace(b);continue}const C=this.parseQualifiedRule(b);C&&(p?this.parseKeyframesAndSaveNameMapping(C,b):this.handleScrollTimelineProps(C,b))}return b.sheetSrc}getAnimationTimelineOptions(h,p){for(let y=this.cssRulesWithTimelineName.length-1;y>=0;y--){const b=this.cssRulesWithTimelineName[y];try{if(p.matches(b.selector)&&(!b["animation-name"]||b["animation-name"]==h))return{"animation-timeline":b["animation-timeline"],"animation-range":b["animation-range"]}}catch{}}return null}getAnonymousScrollTimelineOptions(h,p){const y=this.anonymousScrollTimelineOptions.get(h);return y?{anonymousSource:y.source,anonymousTarget:p,source:Do(y.source??"nearest",p),axis:y.axis?y.axis:"block"}:null}getScrollTimelineOptions(h,p){const y=this.getAnonymousScrollTimelineOptions(h,p);if(y)return y;for(let b=this.sourceSelectorToScrollTimeline.length-1;b>=0;b--){const C=this.sourceSelectorToScrollTimeline[b];if(C.name==h){const k=this.findPreviousSiblingOrAncestorMatchingSelector(p,C.selector);if(k)return{source:k,...C.axis?{axis:C.axis}:{}}}}return null}findPreviousSiblingOrAncestorMatchingSelector(h,p){let y=h;for(;y;){if(y.matches(p))return y;y=y.previousElementSibling||y.parentElement}return null}getAnonymousViewTimelineOptions(h,p){const y=this.anonymousViewTimelineOptions.get(h);return y?{subject:p,axis:y.axis?y.axis:"block",inset:y.inset?y.inset:"auto"}:null}getViewTimelineOptions(h,p){const y=this.getAnonymousViewTimelineOptions(h,p);if(y)return y;for(let b=this.subjectSelectorToViewTimeline.length-1;b>=0;b--){const C=this.subjectSelectorToViewTimeline[b];if(C.name==h){const k=this.findPreviousSiblingOrAncestorMatchingSelector(p,C.selector);if(k)return{subject:k,axis:C.axis,inset:C.inset}}}return null}handleScrollTimelineProps(h,p){if(h.selector.includes("@keyframes"))return;const y=h.block.contents.includes("animation-name:"),b=h.block.contents.includes("animation-timeline:"),C=h.block.contents.includes("animation:");if(this.saveSourceSelectorToScrollTimeline(h),this.saveSubjectSelectorToViewTimeline(h),!b&&!y&&!C)return;let k=[],z=[],D=!1;b&&(k=this.extractScrollTimelineNames(h.block.contents)),y&&(z=this.extractMatches(h.block.contents,Oe.ANIMATION_NAME)),b&&y||(C&&this.extractMatches(h.block.contents,Oe.ANIMATION).forEach(N=>{const F=this.extractAnimationName(N);F&&b&&z.push(F),b&&(this.hasDuration(N)||(this.hasAutoDuration(N)&&(h.block.contents=h.block.contents.replace("auto"," ")),h.block.contents=h.block.contents.replace(N," 1s "+N),D=!0))}),D&&this.replacePart(h.block.startIndex,h.block.endIndex,h.block.contents,p)),this.saveRelationInList(h,k,z)}saveSourceSelectorToScrollTimeline(h){const p=h.block.contents.includes("scroll-timeline:"),y=h.block.contents.includes("scroll-timeline-name:"),b=h.block.contents.includes("scroll-timeline-axis:");if(!p&&!y)return;let C=[];if(p){const z=this.extractMatches(h.block.contents,Oe.SCROLL_TIMELINE);for(const D of z){const N=this.split(D);let F={selector:h.selector,name:""};N.length==1?F.name=N[0]:N.length==2&&(On.includes(N[0])?(F.axis=N[0],F.name=N[1]):(F.axis=N[1],F.name=N[0])),C.push(F)}}if(y){const z=this.extractMatches(h.block.contents,Oe.SCROLL_TIMELINE_NAME);for(let D=0;D<z.length;D++)if(D<C.length)C[D].name=z[D];else{let N={selector:h.selector,name:z[D]};C.push(N)}}let k=[];if(b){const z=this.extractMatches(h.block.contents,Oe.SCROLL_TIMELINE_AXIS);if(k=z.filter(D=>On.includes(D)),k.length!=z.length)throw new Error("Invalid axis")}for(let z=0;z<C.length;z++)k.length&&(C[z].axis=k[z%C.length]);this.sourceSelectorToScrollTimeline.push(...C)}saveSubjectSelectorToViewTimeline(h){const p=h.block.contents.includes("view-timeline:"),y=h.block.contents.includes("view-timeline-name:"),b=h.block.contents.includes("view-timeline-axis:"),C=h.block.contents.includes("view-timeline-inset:");if(!p&&!y)return;let k=[];if(p){const N=this.extractMatches(h.block.contents,Oe.VIEW_TIMELINE);for(let F of N){const X=this.split(F);let Z={selector:h.selector,name:"",inset:null};X.length==1?Z.name=X[0]:X.length==2&&(On.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,Oe.VIEW_TIMELINE_NAME);for(let F=0;F<N.length;F++)if(F<k.length)k[F].name=N[F];else{let X={selector:h.selector,name:N[F],inset:null};k.push(X)}}let z=[],D=[];if(C&&(z=this.extractMatches(h.block.contents,Oe.VIEW_TIMELINE_INSET)),b){const N=this.extractMatches(h.block.contents,Oe.VIEW_TIMELINE_AXIS);if(D=N.filter(F=>On.includes(F)),D.length!=N.length)throw new Error("Invalid axis")}for(let N=0;N<k.length;N++)z.length&&(k[N].inset=z[N%k.length]),D.length&&(k[N].axis=D[N%k.length]);this.subjectSelectorToViewTimeline.push(...k)}hasDuration(h){return h.split(" ").filter(p=>{return y=p,Oe.TIME.exec(y);var y}).length>=1}hasAutoDuration(h){return h.split(" ").filter(p=>p==="auto").length>=1}saveRelationInList(h,p,y){let b=[];h.block.contents.includes("animation-range:")&&(b=this.extractMatches(h.block.contents,Oe.ANIMATION_TIME_RANGE));const C=Math.max(p.length,y.length,b.length);for(let k=0;k<C;k++)this.cssRulesWithTimelineName.push({selector:h.selector,"animation-timeline":p[k%p.length],...y.length?{"animation-name":y[k%y.length]}:{},...b.length?{"animation-range":b[k%b.length]}:{}})}extractScrollTimelineNames(h){const p=Oe.ANIMATION_TIMELINE.exec(h)[1].trim(),y=[];return p.split(",").map(b=>b.trim()).forEach(b=>{if(function(C){return(C.startsWith("scroll")||C.startsWith("view"))&&C.includes("(")}(b)){const C=this.saveAnonymousTimelineName(b);y.push(C)}else y.push(b)}),y}saveAnonymousTimelineName(h){const p=":t"+this.nextAnonymousTimelineNameIndex++;return h.startsWith("scroll(")?this.anonymousScrollTimelineOptions.set(p,this.parseAnonymousScrollTimeline(h)):this.anonymousViewTimelineOptions.set(p,this.parseAnonymousViewTimeline(h)),p}parseAnonymousScrollTimeline(h){const p=Oe.ANONYMOUS_SCROLL_TIMELINE.exec(h);if(!p)return null;const y=p[1],b={};return y.split(" ").forEach(C=>{On.includes(C)?b.axis=C:Wl.includes(C)&&(b.source=C)}),b}parseAnonymousViewTimeline(h){const p=Oe.ANONYMOUS_VIEW_TIMELINE.exec(h);if(!p)return null;const y=p[1],b={};return y.split(" ").forEach(C=>{On.includes(C)?b.axis=C:b.inset=b.inset?`${b.inset} ${C}`:C}),b}extractAnimationName(h){return this.findMatchingEntryInContainer(h,this.keyframeNamesSelectors)}findMatchingEntryInContainer(h,p){const y=h.split(" ").filter(b=>p.has(b));return y?y[0]:null}parseIdentifier(h){Oe.IDENTIFIER.lastIndex=h.index;const p=Oe.IDENTIFIER.exec(h.sheetSrc);if(!p)throw this.parseError(h,"Expected an identifier");return h.index+=p[0].length,p[0]}parseKeyframesAndSaveNameMapping(h,p){if(h.selector.startsWith("@keyframes")){const y=this.replaceKeyframesAndGetMapping(h,p);h.selector.split(" ").forEach((b,C)=>{C>0&&this.keyframeNamesSelectors.set(b,y)})}}replaceKeyframesAndGetMapping(h,p){function y(N){return tr.some(F=>N.startsWith(F))}const b=h.block.contents,C=function(N){let F=0,X=-1,Z=-1;const K=[];for(let me=0;me<N.length;me++)N[me]=="{"?F++:N[me]=="}"&&F--,F==1&&N[me]!="{"&&N[me]!="}"&&X==-1&&(X=me),F==2&&N[me]=="{"&&(Z=me,K.push({start:X,end:Z}),X=Z=-1);return K}(b);if(C.length==0)return new Map;const k=new Map;let z=!1;const D=[];D.push(b.substring(0,C[0].start));for(let N=0;N<C.length;N++){const F=b.substring(C[N].start,C[N].end);let X=[];F.split(",").forEach(Z=>{const K=Z.split(" ").map(_e=>_e.trim()).filter(_e=>_e!="").join(" "),me=k.size;k.set(me,K),X.push(`${me}%`),y(K)&&(z=!0)}),D.push(X.join(",")),N==C.length-1?D.push(b.substring(C[N].end)):D.push(b.substring(C[N].end,C[N+1].start))}return z?(h.block.contents=D.join(""),this.replacePart(h.block.startIndex,h.block.endIndex,h.block.contents,p),k):new Map}parseQualifiedRule(h){const p=h.index,y=this.parseSelector(h).trim();if(y)return{selector:y,block:this.eatBlock(h),startIndex:p,endIndex:h.index}}removeEnclosingDoubleQuotes(h){let p=h[0]=='"'?1:0,y=h[h.length-1]=='"'?h.length-1:h.length;return h.substring(p,y)}assertString(h,p){if(h.sheetSrc.substr(h.index,p.length)!=p)throw this.parseError(h,`Did not find expected sequence ${p}`);h.index+=p.length}replacePart(h,p,y,b){if(b.sheetSrc=b.sheetSrc.slice(0,h)+y+b.sheetSrc.slice(p),b.index>=p){const C=b.index-p;b.index=h+y.length+C}}eatComment(h){this.assertString(h,"/*"),this.eatUntil("*/",h,!0),this.assertString(h,"*/")}eatBlock(h){const p=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 b=h.index;return{startIndex:p,endIndex:b,contents:h.sheetSrc.slice(p,b)}}advance(h){if(h.index++,h.index>h.sheetSrc.length)throw this.parseError(h,"Advanced beyond the end")}parseError(h,p){return Error(`(${h.name?h.name:"<anonymous file>"}): ${p}`)}eatUntil(h,p,y=!1){const b=p.index;for(;!this.lookAhead(h,p);)this.advance(p);return y&&(p.sheetSrc=p.sheetSrc.slice(0,b)+" ".repeat(p.index-b)+p.sheetSrc.slice(p.index)),p.sheetSrc.slice(b,p.index)}parseSelector(h){let p=h.index;if(this.eatUntil("{",h),p===h.index)throw Error("Empty selector");return h.sheetSrc.slice(p,h.index)}eatWhitespace(h){Oe.WHITE_SPACE.lastIndex=h.index;const p=Oe.WHITE_SPACE.exec(h.sheetSrc);p&&(h.index+=p[0].length)}lookAhead(h,p){return p.sheetSrc.substr(p.index,h.length)==h}peek(h){return h.sheetSrc[h.index]}extractMatches(h,p,y=","){return p.exec(h)[1].trim().split(y).map(b=>b.trim())}split(h){return h.split(" ").map(p=>p.trim()).filter(p=>p!="")}};function Hl(h,p,y,b,C,k){const z=cs(p),D=ls(p,y);return Vo(fs(h,z,D,b,C),k,fs("cover",z,D,b,C),y)}function ql(h,p,y){const b=tn.getAnimationTimelineOptions(p,y);if(!b)return null;const C=b["animation-timeline"];if(!C)return null;let k=tn.getScrollTimelineOptions(C,y)||tn.getViewTimelineOptions(C,y);return k?(k.subject&&function(z,D){const N=ps(D.subject),F=D.axis||D.axis;function X(K,me){let _e=null;for(const[ot,Pt]of K)if(ot==100*me.offset){if(Pt=="from")_e=0;else if(Pt=="to")_e=100;else{const gt=Pt.split(" ");_e=gt.length==1?parseFloat(gt[0]):100*Hl(gt[0],N,D.subject,F,D.inset,CSS.percent(parseFloat(gt[1])))}break}return _e}const Z=tn.keyframeNamesSelectors.get(z.animationName);if(Z&&Z.size){const K=[];z.effect.getKeyframes().forEach(_e=>{const ot=X(Z,_e);ot!==null&&ot>=0&&ot<=100&&(_e.offset=ot/100,K.push(_e))});const me=K.sort((_e,ot)=>_e.offset<ot.offset?-1:_e.affset>ot.offset?1:0);z.effect.setKeyframes(me)}}(h,k),{timeline:k.source?new $e(k):new kn(k),animOptions:b}):null}function Xl(){if(CSS.supports("animation-timeline: --works"))return!0;(function(){function p(b){if(b.innerHTML.trim().length===0||"aphrodite"in b.dataset)return;let C=tn.transpileStyleSheet(b.innerHTML,!0);C=tn.transpileStyleSheet(C,!1),b.innerHTML=C}function y(b){b.type!="text/css"&&b.rel!="stylesheet"||!b.href||new URL(b.href,document.baseURI).origin==location.origin&&fetch(b.getAttribute("href")).then(async C=>{const k=await C.text();let z=tn.transpileStyleSheet(k,!0);if(z=tn.transpileStyleSheet(k,!1),z!=k){const D=new Blob([z],{type:"text/css"}),N=URL.createObjectURL(D);b.setAttribute("href",N)}})}new MutationObserver(b=>{for(const C of b)for(const k of C.addedNodes)k instanceof HTMLStyleElement&&p(k),k instanceof HTMLLinkElement&&y(k)}).observe(document.documentElement,{childList:!0,subtree:!0}),document.querySelectorAll("style").forEach(b=>p(b)),document.querySelectorAll("link").forEach(b=>y(b))})();const h=CSS.supports;CSS.supports=p=>(p=p.replaceAll(/(animation-timeline|scroll-timeline(-(name|axis))?|view-timeline(-(name|axis|inset))?|timeline-scope)\s*:/g,"--supported-property:"),h(p)),window.addEventListener("animationstart",p=>{p.target.getAnimations().filter(y=>y.animationName===p.animationName).forEach(y=>{const b=ql(y,y.animationName,p.target);if(b)if(!b.timeline||y instanceof or)y.timeline=b.timeline;else{const C=new or(y,b.timeline,b.animOptions);y.pause(),C.play()}})})}(function(){if(!Xl()){if(!Reflect.defineProperty(window,"ScrollTimeline",{value:$e}))throw Error("Error installing ScrollTimeline polyfill: could not attach ScrollTimeline to window");if(!Reflect.defineProperty(window,"ViewTimeline",{value:kn}))throw Error("Error installing ViewTimeline polyfill: could not attach ViewTimeline to window");if(!Reflect.defineProperty(Element.prototype,"animate",{value:jl}))throw Error("Error installing ScrollTimeline polyfill: could not attach WAAPI's animate to DOM Element");if(!Reflect.defineProperty(window,"Animation",{value:or}))throw Error("Error installing Animation constructor.");if(!Reflect.defineProperty(Element.prototype,"getAnimations",{value:Jl}))throw Error("Error installing ScrollTimeline polyfill: could not attach WAAPI's getAnimations to DOM Element");if(!Reflect.defineProperty(document,"getAnimations",{value:Gl}))throw Error("Error installing ScrollTimeline polyfill: could not attach WAAPI's getAnimations to document")}})()})();class Rd{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 ce;(function(r){r.open="open",r.close="close",r.error="error",r.message="message",r.retry="retry",r.reconnect="reconnect"})(ce||(ce={}));class el{constructor(e,t,n){var i,s,a,o,c,l,u,d,f,m,x,_,g,v,w;this._closedByUser=!1,this.handleOpenEvent=S=>this.handleEvent(ce.open,S),this.handleErrorEvent=S=>this.handleEvent(ce.error,S),this.handleCloseEvent=S=>this.handleEvent(ce.close,S),this.handleMessageEvent=S=>this.handleEvent(ce.message,S),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=(d=n?.listeners)===null||d===void 0?void 0:d.error)!==null&&f!==void 0?f:[]],message:[...(x=(m=n?.listeners)===null||m===void 0?void 0:m.message)!==null&&x!==void 0?x:[]],retry:[...(g=(_=n?.listeners)===null||_===void 0?void 0:_.retry)!==null&&g!==void 0?g:[]],reconnect:[...(w=(v=n?.listeners)===null||v===void 0?void 0:v.reconnect)!==null&&w!==void 0?w:[]]}},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(ce.open,this.handleOpenEvent),this._underlyingWebsocket.addEventListener(ce.close,this.handleCloseEvent),this._underlyingWebsocket.addEventListener(ce.error,this.handleErrorEvent),this._underlyingWebsocket.addEventListener(ce.message,this.handleMessageEvent),this._underlyingWebsocket}clearWebsocket(){this._underlyingWebsocket.removeEventListener(ce.open,this.handleOpenEvent),this._underlyingWebsocket.removeEventListener(ce.close,this.handleCloseEvent),this._underlyingWebsocket.removeEventListener(ce.error,this.handleErrorEvent),this._underlyingWebsocket.removeEventListener(ce.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 ce.close:this.dispatchEvent(e,t),this.scheduleConnectionRetryIfNeeded();break;case ce.open:if(this.backoff!==void 0&&this._lastConnection!==void 0){const n={retries:this.backoff.retries,lastConnection:new Date(this._lastConnection)},i=new CustomEvent(ce.reconnect,{detail:n});this.dispatchEvent(ce.reconnect,i),this.backoff.reset()}this._lastConnection=new Date,this.dispatchEvent(e,t),this.sendBufferedData();break;case ce.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(ce.retry,{detail:n});this.handleEvent(ce.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 Ad{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(ce.open,e,t),this}onClose(e,t){return this.addListener(ce.close,e,t),this}onError(e,t){return this.addListener(ce.error,e,t),this}onMessage(e,t){return this.addListener(ce.message,e,t),this}onRetry(e,t){return this.addListener(ce.retry,e,t),this}onReconnect(e,t){return this.addListener(ce.reconnect,e,t),this}build(){return new el(this._url,this._protocols,this._options)}addListener(e,t,n){var i,s,a,o,c,l,u,d,f,m,x,_,g,v,w,S,T,M,P,E,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=(d=(u=this._options)===null||u===void 0?void 0:u.listeners)===null||d===void 0?void 0:d.error)!==null&&f!==void 0?f:[],message:(_=(x=(m=this._options)===null||m===void 0?void 0:m.listeners)===null||x===void 0?void 0:x.message)!==null&&_!==void 0?_:[],retry:(w=(v=(g=this._options)===null||g===void 0?void 0:g.listeners)===null||v===void 0?void 0:v.retry)!==null&&w!==void 0?w:[],reconnect:(M=(T=(S=this._options)===null||S===void 0?void 0:S.listeners)===null||T===void 0?void 0:T.reconnect)!==null&&M!==void 0?M:[],[e]:[...(O=(E=(P=this._options)===null||P===void 0?void 0:P.listeners)===null||E===void 0?void 0:E[e])!==null&&O!==void 0?O:[],{listener:t,options:n}]}}),this}}const Od=Object.freeze(Object.defineProperty({__proto__:null,ExponentialBackoff:Rd,Websocket:el,WebsocketBuilder:Ad,get WebsocketEvent(){return ce}},Symbol.toStringTag,{value:"Module"})),no=0,tl=1,nl=2,io=2,ro=1.25,il=1,qe=32,Pe=qe/4,rl=65535,Or=Math.pow(2,-24),Ir=Symbol("SKIP_GENERATION"),sl={strategy:no,maxDepth:40,maxLeafSize:10,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,indirect:!1,verbose:!0,range:null,[Ir]:!1};function be(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 ol(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 al(r,e){e.set(r)}function cl(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 Br(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 fi(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)}function Ee(r,e){return e[r+15]===rl}function Xe(r,e){return e[r+6]}function it(r,e){return e[r+14]}function ze(r){return r+Pe}function Ne(r,e){const t=e[r+6];return r+t*Pe}function so(r,e){return e[r+7]}function oo(r,e,t,n,i){let s=1/0,a=1/0,o=1/0,c=-1/0,l=-1/0,u=-1/0,d=1/0,f=1/0,m=1/0,x=-1/0,_=-1/0,g=-1/0;const v=r.offset||0;for(let w=(e-v)*6,S=(e+t-v)*6;w<S;w+=6){const T=r[w+0],M=r[w+1],P=T-M,E=T+M;P<s&&(s=P),E>c&&(c=E),T<d&&(d=T),T>x&&(x=T);const O=r[w+2],A=r[w+3],R=O-A,B=O+A;R<a&&(a=R),B>l&&(l=B),O<f&&(f=O),O>_&&(_=O);const I=r[w+4],U=r[w+5],L=I-U,J=I+U;L<o&&(o=L),J>u&&(u=J),I<m&&(m=I),I>g&&(g=I)}n[0]=s,n[1]=a,n[2]=o,n[3]=c,n[4]=l,n[5]=u,i[0]=d,i[1]=f,i[2]=m,i[3]=x,i[4]=_,i[5]=g}const Kt=32,Id=(r,e)=>r.candidate-e.candidate,an=new Array(Kt).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),zr=new Float32Array(6);function Bd(r,e,t,n,i,s){let a=-1,o=0;if(s===no)a=ol(e),a!==-1&&(o=(e[a]+e[a+3])/2);else if(s===tl)a=ol(r),a!==-1&&(o=zd(t,n,i,a));else if(s===nl){const c=fi(r);let l=ro*i;const u=t.offset||0,d=(n-u)*6,f=(n+i-u)*6;for(let m=0;m<3;m++){const x=e[m],_=(e[m+3]-x)/Kt;if(i<Kt/4){const g=[...an];g.length=i;let v=0;for(let S=d;S<f;S+=6,v++){const T=g[v];T.candidate=t[S+2*m],T.count=0;const{bounds:M,leftCacheBounds:P,rightCacheBounds:E}=T;for(let O=0;O<3;O++)E[O]=1/0,E[O+3]=-1/0,P[O]=1/0,P[O+3]=-1/0,M[O]=1/0,M[O+3]=-1/0;Br(S,t,M)}g.sort(Id);let w=i;for(let S=0;S<w;S++){const T=g[S];for(;S+1<w&&g[S+1].candidate===T.candidate;)g.splice(S+1,1),w--}for(let S=d;S<f;S+=6){const T=t[S+2*m];for(let M=0;M<w;M++){const P=g[M];T>=P.candidate?Br(S,t,P.rightCacheBounds):(Br(S,t,P.leftCacheBounds),P.count++)}}for(let S=0;S<w;S++){const T=g[S],M=T.count,P=i-T.count,E=T.leftCacheBounds,O=T.rightCacheBounds;let A=0;M!==0&&(A=fi(E)/c);let R=0;P!==0&&(R=fi(O)/c);const B=il+ro*(A*M+R*P);B<l&&(a=m,l=B,o=T.candidate)}}else{for(let w=0;w<Kt;w++){const S=an[w];S.count=0,S.candidate=x+_+w*_;const T=S.bounds;for(let M=0;M<3;M++)T[M]=1/0,T[M+3]=-1/0}for(let w=d;w<f;w+=6){let S=~~((t[w+2*m]-x)/_);S>=Kt&&(S=Kt-1);const T=an[S];T.count++,Br(w,t,T.bounds)}const g=an[Kt-1];al(g.bounds,g.rightCacheBounds);for(let w=Kt-2;w>=0;w--){const S=an[w],T=an[w+1];cl(S.bounds,T.rightCacheBounds,S.rightCacheBounds)}let v=0;for(let w=0;w<Kt-1;w++){const S=an[w],T=S.count,M=S.bounds,P=an[w+1].rightCacheBounds;T!==0&&(v===0?al(M,zr):cl(M,zr,zr)),v+=T;let E=0,O=0;v!==0&&(E=fi(zr)/c);const A=i-v;A!==0&&(O=fi(P)/c);const R=il+ro*(E*v+O*A);R<l&&(a=m,l=R,o=S.candidate)}}}}else console.warn(`BVH: Invalid build strategy value ${s} used.`);return{axis:a,pos:o}}function zd(r,e,t,n){let i=0;const s=r.offset;for(let a=e,o=e+t;a<o;a++)i+=r[(a-s)*6+n*2];return i/t}class ao{constructor(){this.boundingData=new Float32Array(6)}}function Nd(r,e,t,n,i,s){let a=n,o=n+i-1;const c=s.pos,l=s.axis*2,u=t.offset||0;for(;;){for(;a<=o&&t[(a-u)*6+l]<c;)a++;for(;a<=o&&t[(o-u)*6+l]>=c;)o--;if(a<o){for(let d=0;d<e;d++){let f=r[a*e+d];r[a*e+d]=r[o*e+d],r[o*e+d]=f}for(let d=0;d<6;d++){const f=a-u,m=o-u,x=t[f*6+d];t[f*6+d]=t[m*6+d],t[m*6+d]=x}a++,o--}else return a}}let ll,Nr,co,ul;const Ud=Math.pow(2,32);function lo(r){return"count"in r?1:1+lo(r.left)+lo(r.right)}function Dd(r,e,t){return ll=new Float32Array(t),Nr=new Uint32Array(t),co=new Uint16Array(t),ul=new Uint8Array(t),uo(r,e)}function uo(r,e){const t=r/4,n=r/2,i="count"in e,s=e.boundingData;for(let a=0;a<6;a++)ll[t+a]=s[a];if(i)return e.buffer?(ul.set(new Uint8Array(e.buffer),r),r+e.buffer.byteLength):(Nr[t+6]=e.offset,co[n+14]=e.count,co[n+15]=rl,r+qe);{const{left:a,right:o,splitAxis:c}=e,l=r+qe;let u=uo(l,a);const d=r/qe,f=u/qe-d;if(f>Ud)throw new Error("MeshBVH: Cannot store relative child node offset greater than 32 bits.");return Nr[t+6]=f,Nr[t+7]=c,uo(u,o)}}function Ld(r,e,t,n,i){const{maxDepth:s,verbose:a,maxLeafSize:o,strategy:c,onProgress:l}=i,u=r.primitiveBuffer,d=r.primitiveBufferStride,f=new Float32Array(6);let m=!1;const x=new ao;return oo(e,t,n,x.boundingData,f),g(x,t,n,f),x;function _(v){l&&l(v/n)}function g(v,w,S,T=null,M=0){if(!m&&M>=s&&(m=!0,a&&console.warn(`BVH: Max depth of ${s} reached when generating BVH. Consider increasing maxDepth.`)),S<=o||M>=s)return _(w+S),v.offset=w,v.count=S,v;const P=Bd(v.boundingData,T,e,w,S,c);if(P.axis===-1)return _(w+S),v.offset=w,v.count=S,v;const E=Nd(u,d,e,w,S,P);if(E===w||E===w+S)_(w+S),v.offset=w,v.count=S;else{v.splitAxis=P.axis;const O=new ao,A=w,R=E-w;v.left=O,oo(e,A,R,O.boundingData,f),g(O,A,R,f,M+1);const B=new ao,I=E,U=S-R;v.right=B,oo(e,I,U,B.boundingData,f),g(B,I,U,f,M+1)}return v}}function Fd(r,e){const t=e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,n=r.getRootRanges(e.range),i=n[0],s=n[n.length-1],a={offset:i.offset,count:s.offset+s.count-i.offset},o=new Float32Array(6*a.count);o.offset=a.offset,r.computePrimitiveBounds(a.offset,a.count,o),r._roots=n.map(c=>{const l=Ld(r,o,c.offset,c.count,e),u=lo(l),d=new t(qe*u);return Dd(0,l,d),d})}class ho{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 Vd{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 ye=new Vd;let cn,Un;const Dn=[],Ur=new ho(()=>new zt);function jd(r,e,t,n,i,s){cn=Ur.getPrimitive(),Un=Ur.getPrimitive(),Dn.push(cn,Un),ye.setBuffer(r._roots[e]);const a=po(0,r.geometry,t,n,i,s);ye.clearBuffer(),Ur.releasePrimitive(cn),Ur.releasePrimitive(Un),Dn.pop(),Dn.pop();const o=Dn.length;return o>0&&(Un=Dn[o-1],cn=Dn[o-2]),a}function po(r,e,t,n,i=null,s=0,a=0){const{float32Array:o,uint16Array:c,uint32Array:l}=ye;let u=r*2;if(Ee(u,c)){const d=Xe(r,l),f=it(u,c);return be(r,o,cn),n(d,f,!1,a,s+r/Pe,cn)}else{let d=function(B){const{uint16Array:I,uint32Array:U}=ye;let L=B*2;for(;!Ee(L,I);)B=ze(B),L=B*2;return Xe(B,U)},f=function(B){const{uint16Array:I,uint32Array:U}=ye;let L=B*2;for(;!Ee(L,I);)B=Ne(B,U),L=B*2;return Xe(B,U)+it(L,I)};const m=ze(r),x=Ne(r,l);let _=m,g=x,v,w,S,T;if(i&&(S=cn,T=Un,be(_,o,S),be(g,o,T),v=i(S),w=i(T),w<v)){_=x,g=m;const B=v;v=w,w=B,S=T}S||(S=cn,be(_,o,S));const M=Ee(_*2,c),P=t(S,M,v,a+1,s+_/Pe);let E;if(P===io){const B=d(_),I=f(_)-B;E=n(B,I,!0,a+1,s+_/Pe,S)}else E=P&&po(_,e,t,n,i,s,a+1);if(E)return!0;T=Un,be(g,o,T);const O=Ee(g*2,c),A=t(T,O,w,a+1,s+g/Pe);let R;if(A===io){const B=d(g),I=f(g)-B;R=n(B,I,!0,a+1,s+g/Pe,T)}else R=A&&po(g,e,t,n,i,s,a+1);return!!R}}const mi=new ye.constructor,Dr=new ye.constructor,ln=new ho(()=>new zt),Ln=new zt,Fn=new zt,fo=new zt,mo=new zt;let yo=!1;function Jd(r,e,t,n){if(yo)throw new Error("MeshBVH: Recursive calls to bvhcast not supported.");yo=!0;const i=r._roots,s=e._roots;let a,o=0,c=0;const l=new kt().copy(t).invert();for(let u=0,d=i.length;u<d;u++){mi.setBuffer(i[u]),c=0;const f=ln.getPrimitive();be(0,mi.float32Array,f),f.applyMatrix4(l);for(let m=0,x=s.length;m<x&&(Dr.setBuffer(s[m]),a=Ot(0,0,t,l,n,o,c,0,0,f),Dr.clearBuffer(),c+=s[m].byteLength/qe,!a);m++);if(ln.releasePrimitive(f),mi.clearBuffer(),o+=i[u].byteLength/qe,a)break}return yo=!1,a}function Ot(r,e,t,n,i,s=0,a=0,o=0,c=0,l=null,u=!1){let d,f;u?(d=Dr,f=mi):(d=mi,f=Dr);const m=d.float32Array,x=d.uint32Array,_=d.uint16Array,g=f.float32Array,v=f.uint32Array,w=f.uint16Array,S=r*2,T=e*2,M=Ee(S,_),P=Ee(T,w);let E=!1;if(P&&M)u?E=i(Xe(e,v),it(e*2,w),Xe(r,x),it(r*2,_),c,a+e/Pe,o,s+r/Pe):E=i(Xe(r,x),it(r*2,_),Xe(e,v),it(e*2,w),o,s+r/Pe,c,a+e/Pe);else if(P){const O=ln.getPrimitive();be(e,g,O),O.applyMatrix4(t);const A=ze(r),R=Ne(r,x);be(A,m,Ln),be(R,m,Fn);const B=O.intersectsBox(Ln),I=O.intersectsBox(Fn);E=B&&Ot(e,A,n,t,i,a,s,c,o+1,O,!u)||I&&Ot(e,R,n,t,i,a,s,c,o+1,O,!u),ln.releasePrimitive(O)}else{const O=ze(e),A=Ne(e,v);be(O,g,fo),be(A,g,mo);const R=l.intersectsBox(fo),B=l.intersectsBox(mo);if(R&&B)E=Ot(r,O,t,n,i,s,a,o,c+1,l,u)||Ot(r,A,t,n,i,s,a,o,c+1,l,u);else if(R)if(M)E=Ot(r,O,t,n,i,s,a,o,c+1,l,u);else{const I=ln.getPrimitive();I.copy(fo).applyMatrix4(t);const U=ze(r),L=Ne(r,x);be(U,m,Ln),be(L,m,Fn);const J=I.intersectsBox(Ln),H=I.intersectsBox(Fn);E=J&&Ot(O,U,n,t,i,a,s,c,o+1,I,!u)||H&&Ot(O,L,n,t,i,a,s,c,o+1,I,!u),ln.releasePrimitive(I)}else if(B)if(M)E=Ot(r,A,t,n,i,s,a,o,c+1,l,u);else{const I=ln.getPrimitive();I.copy(mo).applyMatrix4(t);const U=ze(r),L=Ne(r,x);be(U,m,Ln),be(L,m,Fn);const J=I.intersectsBox(Ln),H=I.intersectsBox(Fn);E=J&&Ot(A,U,n,t,i,a,s,c,o+1,I,!u)||H&&Ot(A,L,n,t,i,a,s,c,o+1,I,!u),ln.releasePrimitive(I)}}return E}const hl=new zt,Vn=new Float32Array(6);class dl{constructor(){this._roots=null,this.primitiveBuffer=null,this.primitiveBufferStride=null}init(e){e={...sl,...e},Fd(this,e)}getRootRanges(){throw new Error("BVH: getRootRanges() not implemented")}writePrimitiveBounds(){throw new Error("BVH: writePrimitiveBounds() not implemented")}writePrimitiveRangeBounds(e,t,n,i){let s=1/0,a=1/0,o=1/0,c=-1/0,l=-1/0,u=-1/0;for(let d=e,f=e+t;d<f;d++){this.writePrimitiveBounds(d,Vn,0);const[m,x,_,g,v,w]=Vn;m<s&&(s=m),g>c&&(c=g),x<a&&(a=x),v>l&&(l=v),_<o&&(o=_),w>u&&(u=w)}return n[i+0]=s,n[i+1]=a,n[i+2]=o,n[i+3]=c,n[i+4]=l,n[i+5]=u,n}computePrimitiveBounds(e,t,n){const i=n.offset||0;for(let s=e,a=e+t;s<a;s++){this.writePrimitiveBounds(s,Vn,0);const[o,c,l,u,d,f]=Vn,m=(o+u)/2,x=(c+d)/2,_=(l+f)/2,g=(u-o)/2,v=(d-c)/2,w=(f-l)/2,S=(s-i)*6;n[S+0]=m,n[S+1]=g+(Math.abs(m)+g)*Or,n[S+2]=x,n[S+3]=v+(Math.abs(x)+v)*Or,n[S+4]=_,n[S+5]=w+(Math.abs(_)+w)*Or}return n}shiftPrimitiveOffsets(e){const t=this._indirectBuffer;if(t)for(let n=0,i=t.length;n<i;n++)t[n]+=e;else{const n=this._roots;for(let i=0;i<n.length;i++){const s=n[i],a=new Uint32Array(s),o=new Uint16Array(s),c=s.byteLength/qe;for(let l=0;l<c;l++){const u=Pe*l,d=2*u;Ee(d,o)&&(a[u+6]+=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=Ee(l,s);if(u){const d=i[o+6],f=s[l+14];e(c,u,new Float32Array(n,o*4,6),d,f)}else{const d=ze(o),f=Ne(o,i),m=so(o,i);e(c,u,new Float32Array(n,o*4,6),m)||(a(d,c+1),a(f,c+1))}}}refit(){const e=this._roots;for(let t=0,n=e.length;t<n;t++){const i=e[t],s=new Uint32Array(i),a=new Uint16Array(i),o=new Float32Array(i),c=i.byteLength/qe;for(let l=c-1;l>=0;l--){const u=l*Pe,d=u*2;if(Ee(d,a)){const f=Xe(u,s),m=it(d,a);this.writePrimitiveRangeBounds(f,m,Vn,0),o.set(Vn,u)}else{const f=ze(u),m=Ne(u,s);for(let x=0;x<3;x++){const _=o[f+x],g=o[f+x+3],v=o[m+x],w=o[m+x+3];o[u+x]=_<v?_:v,o[u+x+3]=g>w?g:w}}}}}getBoundingBox(e){return e.makeEmpty(),this._roots.forEach(t=>{be(0,new Float32Array(t),hl),e.union(hl)}),e}shapecast(e){let{boundsTraverseOrder:t,intersectsBounds:n,intersectsRange:i,intersectsPrimitive:s,scratchPrimitive:a,iterate:o}=e;if(i&&s){const d=i;i=(f,m,x,_,g)=>d(f,m,x,_,g)?!0:o(f,m,this,s,x,_,a)}else i||(s?i=(d,f,m,x)=>o(d,f,this,s,m,x,a):i=(d,f,m)=>m);let c=!1,l=0;const u=this._roots;for(let d=0,f=u.length;d<f;d++){const m=u[d];if(c=jd(this,d,n,i,t,l),c)break;l+=m.byteLength/qe}return c}bvhcast(e,t,n){let{intersectsRanges:i}=n;return Jd(this,e,t,i)}}function Gd(){return typeof SharedArrayBuffer<"u"}function go(r){return r.index?r.index.count:r.attributes.position.count}function Lr(r){return go(r)/3}function Wd(r,e=ArrayBuffer){return r>65535?new Uint32Array(new e(4*r)):new Uint16Array(new e(2*r))}function Hd(r,e){if(!r.index){const t=r.attributes.position.count,n=e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,i=Wd(t,n);r.setIndex(new dt(i,1));for(let s=0;s<t;s++)i[s]=s}}function qd(r,e,t){const n=go(r)/t,i=e||r.drawRange,s=i.start/t,a=(i.start+i.count)/t,o=Math.max(0,s),c=Math.min(n,a)-o;return{offset:Math.floor(o),count:Math.floor(c)}}function Xd(r,e){return r.groups.map(t=>({offset:t.start/e,count:t.count/e}))}function pl(r,e,t){const n=qd(r,e,t),i=Xd(r,t);if(!i.length)return[n];const s=[],a=n.offset,o=n.offset+n.count,c=go(r)/t,l=[];for(const f of i){const{offset:m,count:x}=f,_=m,g=isFinite(x)?x:c-m,v=m+g;_<o&&v>a&&(l.push({pos:Math.max(a,_),isStart:!0}),l.push({pos:Math.min(o,v),isStart:!1}))}l.sort((f,m)=>f.pos!==m.pos?f.pos-m.pos:f.type==="end"?-1:1);let u=0,d=null;for(const f of l){const m=f.pos;u!==0&&m!==d&&s.push({offset:d,count:m-d}),u+=f.isStart?1:-1,d=m}return s}function fl(r,e){const t=r[r.length-1],n=t.offset+t.count>2**16,i=r.reduce((l,u)=>l+u.count,0),s=n?4:2,a=e?new SharedArrayBuffer(i*s):new ArrayBuffer(i*s),o=n?new Uint32Array(a):new Uint16Array(a);let c=0;for(let l=0;l<r.length;l++){const{offset:u,count:d}=r[l];for(let f=0;f<d;f++)o[c+f]=u+f;c+=d}return o}class ml extends dl{get indirect(){return!!this._indirectBuffer}get primitiveStride(){return null}get primitiveBufferStride(){return this.indirect?1:this.primitiveStride}set primitiveBufferStride(e){}get primitiveBuffer(){return this.indirect?this._indirectBuffer:this.geometry.index.array}set primitiveBuffer(e){}constructor(e,t={}){if(e.isBufferGeometry){if(e.index&&e.index.isInterleavedBufferAttribute)throw new Error("BVH: InterleavedBufferAttribute is not supported for the index attribute.")}else throw new Error("BVH: Only BufferGeometries are supported.");if(t.useSharedArrayBuffer&&!Gd())throw new Error("BVH: SharedArrayBuffer is not available.");super(),this.geometry=e,this.resolvePrimitiveIndex=t.indirect?n=>this._indirectBuffer[n]:n=>n,this.primitiveBuffer=null,this.primitiveBufferStride=null,this._indirectBuffer=null,t={...sl,...t},t[Ir]||this.init(t)}init(e){const{geometry:t,primitiveStride:n}=this;if(e.indirect){const i=pl(t,e.range,n),s=fl(i,e.useSharedArrayBuffer);this._indirectBuffer=s}else Hd(t,e);super.init(e),!t.boundingBox&&e.setBoundingBox&&(t.boundingBox=this.getBoundingBox(new zt))}getRootRanges(e){return this.indirect?[{offset:0,count:this._indirectBuffer.length}]:pl(this.geometry,e,this.primitiveStride)}raycastObject3D(){throw new Error("BVH: raycastObject3D() not implemented")}}class Qt{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}}Qt.prototype.setFromBox=function(){const r=new q;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 Yd=function(){const r=new q,e=new q,t=new q;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),d=l.dot(o),f=l.dot(l),m=t.dot(o),x=o.dot(o)*f-d*d;let _,g;x!==0?_=(u*d-m*f)/x:_=0,g=(u+_*d)/f,s.x=_,s.y=g}}(),vo=function(){const r=new nn,e=new q,t=new q;return function(n,i,s,a){Yd(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 d=e,f=t;if(n.closestPointToPoint(u,!0,e),i.closestPointToPoint(l,!0,t),d.distanceToSquared(u)<=f.distanceToSquared(l)){s.copy(d),a.copy(u);return}else{s.copy(l),a.copy(f);return}}}}(),Zd=function(){const r=new q,e=new q,t=new oa,n=new qt;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 d=s.getPlane(t);if(Math.abs(d.distanceToPoint(o))<=a){const f=d.projectPoint(o,e);if(s.containsPoint(f))return!0}return!1}}(),Kd=["x","y","z"],$t=1e-15,yl=$t*$t;function vt(r){return Math.abs(r)<$t}class St extends mn{constructor(...e){super(...e),this.isExtendedTriangle=!0,this.satAxes=new Array(4).fill().map(()=>new q),this.satBounds=new Array(4).fill().map(()=>new Qt),this.points=[this.a,this.b,this.c],this.plane=new oa,this.isDegenerateIntoSegment=!1,this.isDegenerateIntoPoint=!1,this.degenerateSegment=new qt,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 d=s[2],f=a[2];d.subVectors(t,n),f.setFromPoints(d,i);const m=s[3],x=a[3];m.subVectors(n,e),x.setFromPoints(m,i);const _=l.length(),g=d.length(),v=m.length();this.isDegenerateIntoPoint=!1,this.isDegenerateIntoSegment=!1,_<$t?g<$t||v<$t?this.isDegenerateIntoPoint=!0:(this.isDegenerateIntoSegment=!0,this.degenerateSegment.start.copy(e),this.degenerateSegment.end.copy(n)):g<$t?v<$t?this.isDegenerateIntoPoint=!0:(this.isDegenerateIntoSegment=!0,this.degenerateSegment.start.copy(t),this.degenerateSegment.end.copy(e)):v<$t&&(this.isDegenerateIntoSegment=!0,this.degenerateSegment.start.copy(n),this.degenerateSegment.end.copy(t)),this.plane.setFromNormalAndCoplanarPoint(o,e),this.needsUpdate=!1}}St.prototype.closestPointToSegment=function(){const r=new q,e=new q,t=new qt;return function(n,i=null,s=null){const{start:a,end:o}=n,c=this.points;let l,u=1/0;for(let d=0;d<3;d++){const f=(d+1)%3;t.start.copy(c[d]),t.end.copy(c[f]),vo(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)}}(),St.prototype.intersectsTriangle=function(){const r=new St,e=new Qt,t=new Qt,n=new q,i=new q,s=new q,a=new q,o=new qt,c=new qt,l=new q,u=new nn,d=new nn;function f(S,T,M,P){const E=n;!S.isDegenerateIntoPoint&&!S.isDegenerateIntoSegment?E.copy(S.plane.normal):E.copy(T.plane.normal);const O=S.satBounds,A=S.satAxes;for(let I=1;I<4;I++){const U=O[I],L=A[I];if(e.setFromPoints(L,T.points),U.isSeparated(e)||(a.copy(E).cross(L),e.setFromPoints(a,S.points),t.setFromPoints(a,T.points),e.isSeparated(t)))return!1}const R=T.satBounds,B=T.satAxes;for(let I=1;I<4;I++){const U=R[I],L=B[I];if(e.setFromPoints(L,S.points),U.isSeparated(e)||(a.crossVectors(E,L),e.setFromPoints(a,S.points),t.setFromPoints(a,T.points),e.isSeparated(t)))return!1}return M&&(P||console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."),M.start.set(0,0,0),M.end.set(0,0,0)),!0}function m(S,T,M,P,E,O,A,R,B,I,U){let L=A/(A-R);I.x=P+(E-P)*L,U.start.subVectors(T,S).multiplyScalar(L).add(S),L=A/(A-B),I.y=P+(O-P)*L,U.end.subVectors(M,S).multiplyScalar(L).add(S)}function x(S,T,M,P,E,O,A,R,B,I,U){if(E>0)m(S.c,S.a,S.b,P,T,M,B,A,R,I,U);else if(O>0)m(S.b,S.a,S.c,M,T,P,R,A,B,I,U);else if(R*B>0||A!=0)m(S.a,S.b,S.c,T,M,P,A,R,B,I,U);else if(R!=0)m(S.b,S.a,S.c,M,T,P,R,A,B,I,U);else if(B!=0)m(S.c,S.a,S.b,P,T,M,B,A,R,I,U);else return!0;return!1}function _(S,T,M,P){const E=T.degenerateSegment,O=S.plane.distanceToPoint(E.start),A=S.plane.distanceToPoint(E.end);return vt(O)?vt(A)?f(S,T,M,P):(M&&(M.start.copy(E.start),M.end.copy(E.start)),S.containsPoint(E.start)):vt(A)?(M&&(M.start.copy(E.end),M.end.copy(E.end)),S.containsPoint(E.end)):S.plane.intersectLine(E,n)!=null?(M&&(M.start.copy(n),M.end.copy(n)),S.containsPoint(n)):!1}function g(S,T,M){const P=T.a;return vt(S.plane.distanceToPoint(P))&&S.containsPoint(P)?(M&&(M.start.copy(P),M.end.copy(P)),!0):!1}function v(S,T,M){const P=S.degenerateSegment,E=T.a;return P.closestPointToPoint(E,!0,n),E.distanceToSquared(n)<yl?(M&&(M.start.copy(E),M.end.copy(E)),!0):!1}function w(S,T,M,P){if(S.isDegenerateIntoSegment)if(T.isDegenerateIntoSegment){const E=S.degenerateSegment,O=T.degenerateSegment,A=i,R=s;E.delta(A),O.delta(R);const B=n.subVectors(O.start,E.start),I=A.x*R.y-A.y*R.x;if(vt(I))return!1;const U=(B.x*R.y-B.y*R.x)/I,L=-(A.x*B.y-A.y*B.x)/I;if(U<0||U>1||L<0||L>1)return!1;const J=E.start.z+A.z*U,H=O.start.z+R.z*L;return vt(J-H)?(M&&(M.start.copy(E.start).addScaledVector(A,U),M.end.copy(E.start).addScaledVector(A,U)),!0):!1}else return T.isDegenerateIntoPoint?v(S,T,M):_(T,S,M,P);else{if(S.isDegenerateIntoPoint)return T.isDegenerateIntoPoint?T.a.distanceToSquared(S.a)<yl?(M&&(M.start.copy(S.a),M.end.copy(S.a)),!0):!1:T.isDegenerateIntoSegment?v(T,S,M):g(T,S,M);if(T.isDegenerateIntoPoint)return g(S,T,M);if(T.isDegenerateIntoSegment)return _(S,T,M,P)}}return function(S,T=null,M=!1){this.needsUpdate&&this.update(),S.isExtendedTriangle?S.needsUpdate&&S.update():(r.copy(S),r.update(),S=r);const P=w(this,S,T,M);if(P!==void 0)return P;const E=this.plane,O=S.plane;let A=O.distanceToPoint(this.a),R=O.distanceToPoint(this.b),B=O.distanceToPoint(this.c);vt(A)&&(A=0),vt(R)&&(R=0),vt(B)&&(B=0);const I=A*R,U=A*B;if(I>0&&U>0)return!1;let L=E.distanceToPoint(S.a),J=E.distanceToPoint(S.b),H=E.distanceToPoint(S.c);vt(L)&&(L=0),vt(J)&&(J=0),vt(H)&&(H=0);const se=L*J,W=L*H;if(se>0&&W>0)return!1;i.copy(E.normal),s.copy(O.normal);const pe=i.cross(s);let ne=0,he=Math.abs(pe.x);const oe=Math.abs(pe.y);oe>he&&(he=oe,ne=1),Math.abs(pe.z)>he&&(ne=2);const le=Kd[ne],xe=this.a[le],ge=this.b[le],de=this.c[le],re=S.a[le],Ze=S.b[le],Ue=S.c[le];if(x(this,xe,ge,de,I,U,A,R,B,u,o))return f(this,S,T,M);if(x(S,re,Ze,Ue,se,W,L,J,H,d,c))return f(this,S,T,M);if(u.y<u.x){const ke=u.y;u.y=u.x,u.x=ke,l.copy(o.start),o.start.copy(o.end),o.end.copy(l)}if(d.y<d.x){const ke=d.y;d.y=d.x,d.x=ke,l.copy(c.start),c.start.copy(c.end),c.end.copy(l)}return u.y<d.x||d.y<u.x?!1:(T&&(d.x>u.x?T.start.copy(c.start):T.start.copy(o.start),d.y<u.y?T.end.copy(c.end):T.end.copy(o.end)),!0)}}(),St.prototype.distanceToPoint=function(){const r=new q;return function(e){return this.closestPointToPoint(e,r),e.distanceTo(r)}}(),St.prototype.distanceToTriangle=function(){const r=new q,e=new q,t=["a","b","c"],n=new qt,i=new qt;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 d;const f=t[u],m=s[f];this.closestPointToPoint(m,r),d=m.distanceToSquared(r),d<l&&(l=d,a&&a.copy(r),o&&o.copy(m));const x=this[f];s.closestPointToPoint(x,r),d=x.distanceToSquared(r),d<l&&(l=d,a&&a.copy(x),o&&o.copy(r))}for(let u=0;u<3;u++){const d=t[u],f=t[(u+1)%3];n.set(this[d],this[f]);for(let m=0;m<3;m++){const x=t[m],_=t[(m+1)%3];i.set(s[x],s[_]),vo(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 Ye{constructor(e,t,n){this.isOrientedBox=!0,this.min=new q,this.max=new q,this.matrix=new kt,this.invMatrix=new kt,this.points=new Array(8).fill().map(()=>new q),this.satAxes=new Array(3).fill().map(()=>new q),this.satBounds=new Array(3).fill().map(()=>new Qt),this.alignedSatBounds=new Array(3).fill().map(()=>new Qt),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}}Ye.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 d=1*c|2*l|4*u,f=n[d];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],d=1<<c,f=n[d];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}}(),Ye.prototype.intersectsBox=function(){const r=new Qt;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}}(),Ye.prototype.intersectsTriangle=function(){const r=new St,e=new Array(3),t=new Qt,n=new Qt,i=new q;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 d=0;d<3;d++){const f=a[d],m=o[d];if(t.setFromPoints(m,e),f.isSeparated(t))return!1}const c=s.satBounds,l=s.satAxes,u=this.points;for(let d=0;d<3;d++){const f=c[d],m=l[d];if(t.setFromPoints(m,u),f.isSeparated(t))return!1}for(let d=0;d<3;d++){const f=o[d];for(let m=0;m<4;m++){const x=l[m];if(i.crossVectors(f,x),t.setFromPoints(i,e),n.setFromPoints(i,u),t.isSeparated(n))return!1}}return!0}}(),Ye.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}}(),Ye.prototype.distanceToPoint=function(){const r=new q;return function(e){return this.closestPointToPoint(e,r),e.distanceTo(r)}}(),Ye.prototype.distanceToBox=function(){const r=["x","y","z"],e=new Array(12).fill().map(()=>new qt),t=new Array(12).fill().map(()=>new qt),n=new q,i=new q;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,d=s.max,f=this.points;let m=1/0;for(let _=0;_<8;_++){const g=f[_];i.copy(g).clamp(u,d);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 x=0;for(let _=0;_<3;_++)for(let g=0;g<=1;g++)for(let v=0;v<=1;v++){const w=(_+1)%3,S=(_+2)%3,T=g<<w|v<<S,M=1<<_|g<<w|v<<S,P=f[T],E=f[M];e[x].set(P,E);const O=r[_],A=r[w],R=r[S],B=t[x],I=B.start,U=B.end;I[O]=u[O],I[A]=g?u[A]:d[A],I[R]=v?u[R]:d[A],U[O]=d[O],U[A]=g?u[A]:d[A],U[R]=v?u[R]:d[A],x++}for(let _=0;_<=1;_++)for(let g=0;g<=1;g++)for(let v=0;v<=1;v++){i.x=_?d.x:u.x,i.y=g?d.y:u.y,i.z=v?d.z:u.z,this.closestPointToPoint(i,n);const w=i.distanceToSquared(n);if(w<m&&(m=w,o&&o.copy(n),c&&c.copy(i),w<l))return Math.sqrt(w)}for(let _=0;_<12;_++){const g=e[_];for(let v=0;v<12;v++){const w=t[v];vo(g,w,n,i);const S=n.distanceToSquared(i);if(S<m&&(m=S,o&&o.copy(n),c&&c.copy(i),S<l))return Math.sqrt(S)}}return Math.sqrt(m)}}();class Qd extends ho{constructor(){super(()=>new St)}}const bt=new Qd,yi=new q,So=new q;function $d(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=>(yi.copy(e).clamp(u.min,u.max),yi.distanceToSquared(e)),intersectsBounds:(u,d,f)=>f<o&&f<a,intersectsTriangle:(u,d)=>{u.closestPointToPoint(e,yi);const f=e.distanceToSquared(yi);return f<o&&(So.copy(yi),o=f,c=d),f<s}}),o===1/0)return null;const l=Math.sqrt(o);return t.point?t.point.copy(So):t.point=So.clone(),t.distance=l,t.faceIndex=c,t}const Fr=parseInt(aa)>=169,ep=parseInt(aa)<=161,vn=new q,Sn=new q,bn=new q,Vr=new nn,jr=new nn,Jr=new nn,gl=new q,vl=new q,Sl=new q,gi=new q;function tp(r,e,t,n,i,s,a,o){let c;if(s===nu?c=r.intersectTriangle(n,t,e,!0,i):c=r.intersectTriangle(e,t,n,s!==Ss,i),c===null)return null;const l=r.origin.distanceTo(i);return l<a||l>o?null:{distance:l,point:i.clone()}}function bl(r,e,t,n,i,s,a,o,c,l,u){vn.fromBufferAttribute(e,s),Sn.fromBufferAttribute(e,a),bn.fromBufferAttribute(e,o);const d=tp(r,vn,Sn,bn,gi,c,l,u);if(d){if(n){Vr.fromBufferAttribute(n,s),jr.fromBufferAttribute(n,a),Jr.fromBufferAttribute(n,o),d.uv=new nn;const m=mn.getInterpolation(gi,vn,Sn,bn,Vr,jr,Jr,d.uv);Fr||(d.uv=m)}if(i){Vr.fromBufferAttribute(i,s),jr.fromBufferAttribute(i,a),Jr.fromBufferAttribute(i,o),d.uv1=new nn;const m=mn.getInterpolation(gi,vn,Sn,bn,Vr,jr,Jr,d.uv1);Fr||(d.uv1=m),ep&&(d.uv2=d.uv1)}if(t){gl.fromBufferAttribute(t,s),vl.fromBufferAttribute(t,a),Sl.fromBufferAttribute(t,o),d.normal=new q;const m=mn.getInterpolation(gi,vn,Sn,bn,gl,vl,Sl,d.normal);d.normal.dot(r.direction)>0&&d.normal.multiplyScalar(-1),Fr||(d.normal=m)}const f={a:s,b:a,c:o,normal:new q,materialIndex:0};if(mn.getNormal(vn,Sn,bn,f.normal),d.face=f,d.faceIndex=s,Fr){const m=new q;mn.getBarycoord(gi,vn,Sn,bn,m),d.barycoord=m}}return d}function xl(r){return r&&r.isMaterial?r.side:r}function Gr(r,e,t,n,i,s,a){const o=n*3;let c=o+0,l=o+1,u=o+2;const{index:d,groups:f}=r;r.index&&(c=d.getX(c),l=d.getX(l),u=d.getX(u));const{position:m,normal:x,uv:_,uv1:g}=r.attributes;if(Array.isArray(e)){const v=n*3;for(let w=0,S=f.length;w<S;w++){const{start:T,count:M,materialIndex:P}=f[w];if(v>=T&&v<T+M){const E=xl(e[P]),O=bl(t,m,x,_,g,c,l,u,E,s,a);if(O)if(O.faceIndex=n,O.face.materialIndex=P,i)i.push(O);else return O}}}else{const v=xl(e),w=bl(t,m,x,_,g,c,l,u,v,s,a);if(w)if(w.faceIndex=n,w.face.materialIndex=0,i)i.push(w);else return w}return null}function Ce(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 np(r,e,t,n,i,s,a,o){const{geometry:c,_indirectBuffer:l}=r;for(let u=n,d=n+i;u<d;u++)Gr(c,e,t,u,s,a,o)}function ip(r,e,t,n,i,s,a){const{geometry:o,_indirectBuffer:c}=r;let l=1/0,u=null;for(let d=n,f=n+i;d<f;d++){let m;m=Gr(o,e,t,d,null,s,a),m&&m.distance<l&&(u=m,l=m.distance)}return u}function rp(r,e,t,n,i,s,a){const{geometry:o}=t,{index:c}=o,l=o.attributes.position;for(let u=r,d=e+r;u<d;u++){let f;if(f=u,Ce(a,f*3,c,l),a.needsUpdate=!0,n(a,f,i,s))return!0}return!1}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),d(0,l),l+=s.byteLength;function d(f,m,x=!1){const _=f*2;if(Ee(_,o)){const g=Xe(f,a),v=it(_,o);let w=1/0,S=1/0,T=1/0,M=-1/0,P=-1/0,E=-1/0;for(let O=3*g,A=3*(g+v);O<A;O++){let R=n[O];const B=i.getX(R),I=i.getY(R),U=i.getZ(R);B<w&&(w=B),B>M&&(M=B),I<S&&(S=I),I>P&&(P=I),U<T&&(T=U),U>E&&(E=U)}return c[f+0]!==w||c[f+1]!==S||c[f+2]!==T||c[f+3]!==M||c[f+4]!==P||c[f+5]!==E?(c[f+0]=w,c[f+1]=S,c[f+2]=T,c[f+3]=M,c[f+4]=P,c[f+5]=E,!0):!1}else{const g=ze(f),v=Ne(f,a);let w=x,S=!1,T=!1;if(e){if(!w){const R=g/Pe+m/qe,B=v/Pe+m/qe;S=e.has(R),T=e.has(B),w=!S&&!T}}else S=!0,T=!0;const M=w||S,P=w||T;let E=!1;M&&(E=d(g,m,w));let O=!1;P&&(O=d(v,m,w));const A=E||O;if(A)for(let R=0;R<3;R++){const B=g+R,I=v+R,U=c[B],L=c[B+3],J=c[I],H=c[I+3];c[f+R]=U<J?U:J,c[f+R+3]=L>H?L:H}return A}}}function un(r,e,t,n,i){let s,a,o,c,l,u;const d=1/t.direction.x,f=1/t.direction.y,m=1/t.direction.z,x=t.origin.x,_=t.origin.y,g=t.origin.z;let v=e[r],w=e[r+3],S=e[r+1],T=e[r+3+1],M=e[r+2],P=e[r+3+2];return d>=0?(s=(v-x)*d,a=(w-x)*d):(s=(w-x)*d,a=(v-x)*d),f>=0?(o=(S-_)*f,c=(T-_)*f):(o=(T-_)*f,c=(S-_)*f),s>c||o>a||((o>s||isNaN(s))&&(s=o),(c<a||isNaN(a))&&(a=c),m>=0?(l=(M-g)*m,u=(P-g)*m):(l=(P-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 op(r,e,t,n,i,s,a,o){const{geometry:c,_indirectBuffer:l}=r;for(let u=n,d=n+i;u<d;u++){let f=l?l[u]:u;Gr(c,e,t,f,s,a,o)}}function ap(r,e,t,n,i,s,a){const{geometry:o,_indirectBuffer:c}=r;let l=1/0,u=null;for(let d=n,f=n+i;d<f;d++){let m;m=Gr(o,e,t,c?c[d]:d,null,s,a),m&&m.distance<l&&(u=m,l=m.distance)}return u}function cp(r,e,t,n,i,s,a){const{geometry:o}=t,{index:c}=o,l=o.attributes.position;for(let u=r,d=e+r;u<d;u++){let f;if(f=t.resolveTriangleIndex(u),Ce(a,f*3,c,l),a.needsUpdate=!0,n(a,f,i,s))return!0}return!1}function lp(r,e,t,n,i,s,a){ye.setBuffer(r._roots[e]),bo(0,r,t,n,i,s,a),ye.clearBuffer()}function bo(r,e,t,n,i,s,a){const{float32Array:o,uint16Array:c,uint32Array:l}=ye,u=r*2;if(Ee(u,c)){const d=Xe(r,l),f=it(u,c);np(e,t,n,d,f,i,s,a)}else{const d=ze(r);un(d,o,n,s,a)&&bo(d,e,t,n,i,s,a);const f=Ne(r,l);un(f,o,n,s,a)&&bo(f,e,t,n,i,s,a)}}const up=["x","y","z"];function hp(r,e,t,n,i,s){ye.setBuffer(r._roots[e]);const a=xo(0,r,t,n,i,s);return ye.clearBuffer(),a}function xo(r,e,t,n,i,s){const{float32Array:a,uint16Array:o,uint32Array:c}=ye;let l=r*2;if(Ee(l,o)){const u=Xe(r,c),d=it(l,o);return ip(e,t,n,u,d,i,s)}else{const u=so(r,c),d=up[u],f=n.direction[d]>=0;let m,x;f?(m=ze(r),x=Ne(r,c)):(m=Ne(r,c),x=ze(r));const _=un(m,a,n,i,s)?xo(m,e,t,n,i,s):null;if(_){const v=_.point[d];if(f?v<=a[x+u]:v>=a[x+u+3])return _}const g=un(x,a,n,i,s)?xo(x,e,t,n,i,s):null;return _&&g?_.distance<=g.distance?_:g:_||g||null}}const Wr=new zt,jn=new St,Jn=new St,vi=new kt,wl=new Ye,Hr=new Ye;function dp(r,e,t,n){ye.setBuffer(r._roots[e]);const i=wo(0,r,t,n);return ye.clearBuffer(),i}function wo(r,e,t,n,i=null){const{float32Array:s,uint16Array:a,uint32Array:o}=ye;let c=r*2;if(i===null&&(t.boundingBox||t.computeBoundingBox(),wl.set(t.boundingBox.min,t.boundingBox.max,n),i=wl),Ee(c,a)){const l=e.geometry,u=l.index,d=l.attributes.position,f=t.index,m=t.attributes.position,x=Xe(r,o),_=it(c,a);if(vi.copy(n).invert(),t.boundsTree)return be(r,s,Hr),Hr.matrix.copy(vi),Hr.needsUpdate=!0,t.boundsTree.shapecast({intersectsBounds:g=>Hr.intersectsBox(g),intersectsTriangle:g=>{g.a.applyMatrix4(n),g.b.applyMatrix4(n),g.c.applyMatrix4(n),g.needsUpdate=!0;for(let v=x*3,w=(_+x)*3;v<w;v+=3)if(Ce(Jn,v,u,d),Jn.needsUpdate=!0,g.intersectsTriangle(Jn))return!0;return!1}});{const g=Lr(t);for(let v=x*3,w=(_+x)*3;v<w;v+=3){Ce(jn,v,u,d),jn.a.applyMatrix4(vi),jn.b.applyMatrix4(vi),jn.c.applyMatrix4(vi),jn.needsUpdate=!0;for(let S=0,T=g*3;S<T;S+=3)if(Ce(Jn,S,f,m),Jn.needsUpdate=!0,jn.intersectsTriangle(Jn))return!0}}}else{const l=ze(r),u=Ne(r,o);return be(l,s,Wr),!!(i.intersectsBox(Wr)&&wo(l,e,t,n,i)||(be(u,s,Wr),i.intersectsBox(Wr)&&wo(u,e,t,n,i)))}}const qr=new kt,_o=new Ye,Si=new Ye,pp=new q,fp=new q,mp=new q,yp=new q;function gp(r,e,t,n={},i={},s=0,a=1/0){e.boundingBox||e.computeBoundingBox(),_o.set(e.boundingBox.min,e.boundingBox.max,t),_o.needsUpdate=!0;const o=r.geometry,c=o.attributes.position,l=o.index,u=e.attributes.position,d=e.index,f=bt.getPrimitive(),m=bt.getPrimitive();let x=pp,_=fp,g=null,v=null;i&&(g=mp,v=yp);let w=1/0,S=null,T=null;return qr.copy(t).invert(),Si.matrix.copy(qr),r.shapecast({boundsTraverseOrder:M=>_o.distanceToBox(M),intersectsBounds:(M,P,E)=>E<w&&E<a?(P&&(Si.min.copy(M.min),Si.max.copy(M.max),Si.needsUpdate=!0),!0):!1,intersectsRange:(M,P)=>{if(e.boundsTree)return e.boundsTree.shapecast({boundsTraverseOrder:E=>Si.distanceToBox(E),intersectsBounds:(E,O,A)=>A<w&&A<a,intersectsRange:(E,O)=>{for(let A=E,R=E+O;A<R;A++){Ce(m,3*A,d,u),m.a.applyMatrix4(t),m.b.applyMatrix4(t),m.c.applyMatrix4(t),m.needsUpdate=!0;for(let B=M,I=M+P;B<I;B++){Ce(f,3*B,l,c),f.needsUpdate=!0;const U=f.distanceToTriangle(m,x,g);if(U<w&&(_.copy(x),v&&v.copy(g),w=U,S=B,T=A),U<s)return!0}}}});{const E=Lr(e);for(let O=0,A=E;O<A;O++){Ce(m,3*O,d,u),m.a.applyMatrix4(t),m.b.applyMatrix4(t),m.c.applyMatrix4(t),m.needsUpdate=!0;for(let R=M,B=M+P;R<B;R++){Ce(f,3*R,l,c),f.needsUpdate=!0;const I=f.distanceToTriangle(m,x,g);if(I<w&&(_.copy(x),v&&v.copy(g),w=I,S=R,T=O),I<s)return!0}}}}}),bt.releasePrimitive(f),bt.releasePrimitive(m),w===1/0?null:(n.point?n.point.copy(_):n.point=_.clone(),n.distance=w,n.faceIndex=S,i&&(i.point?i.point.copy(v):i.point=v.clone(),i.point.applyMatrix4(qr),_.applyMatrix4(qr),i.distance=_.sub(i.point).length(),i.faceIndex=T),n)}function vp(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),d(0,l),l+=s.byteLength;function d(f,m,x=!1){const _=f*2;if(Ee(_,o)){const g=Xe(f,a),v=it(_,o);let w=1/0,S=1/0,T=1/0,M=-1/0,P=-1/0,E=-1/0;for(let O=g,A=g+v;O<A;O++){const R=3*r.resolveTriangleIndex(O);for(let B=0;B<3;B++){let I=R+B;I=n?n[I]:I;const U=i.getX(I),L=i.getY(I),J=i.getZ(I);U<w&&(w=U),U>M&&(M=U),L<S&&(S=L),L>P&&(P=L),J<T&&(T=J),J>E&&(E=J)}}return c[f+0]!==w||c[f+1]!==S||c[f+2]!==T||c[f+3]!==M||c[f+4]!==P||c[f+5]!==E?(c[f+0]=w,c[f+1]=S,c[f+2]=T,c[f+3]=M,c[f+4]=P,c[f+5]=E,!0):!1}else{const g=ze(f),v=Ne(f,a);let w=x,S=!1,T=!1;if(e){if(!w){const R=g/Pe+m/qe,B=v/Pe+m/qe;S=e.has(R),T=e.has(B),w=!S&&!T}}else S=!0,T=!0;const M=w||S,P=w||T;let E=!1;M&&(E=d(g,m,w));let O=!1;P&&(O=d(v,m,w));const A=E||O;if(A)for(let R=0;R<3;R++){const B=g+R,I=v+R,U=c[B],L=c[B+3],J=c[I],H=c[I+3];c[f+R]=U<J?U:J,c[f+R+3]=L>H?L:H}return A}}}function Sp(r,e,t,n,i,s,a){ye.setBuffer(r._roots[e]),To(0,r,t,n,i,s,a),ye.clearBuffer()}function To(r,e,t,n,i,s,a){const{float32Array:o,uint16Array:c,uint32Array:l}=ye,u=r*2;if(Ee(u,c)){const d=Xe(r,l),f=it(u,c);op(e,t,n,d,f,i,s,a)}else{const d=ze(r);un(d,o,n,s,a)&&To(d,e,t,n,i,s,a);const f=Ne(r,l);un(f,o,n,s,a)&&To(f,e,t,n,i,s,a)}}const bp=["x","y","z"];function xp(r,e,t,n,i,s){ye.setBuffer(r._roots[e]);const a=Mo(0,r,t,n,i,s);return ye.clearBuffer(),a}function Mo(r,e,t,n,i,s){const{float32Array:a,uint16Array:o,uint32Array:c}=ye;let l=r*2;if(Ee(l,o)){const u=Xe(r,c),d=it(l,o);return ap(e,t,n,u,d,i,s)}else{const u=so(r,c),d=bp[u],f=n.direction[d]>=0;let m,x;f?(m=ze(r),x=Ne(r,c)):(m=Ne(r,c),x=ze(r));const _=un(m,a,n,i,s)?Mo(m,e,t,n,i,s):null;if(_){const v=_.point[d];if(f?v<=a[x+u]:v>=a[x+u+3])return _}const g=un(x,a,n,i,s)?Mo(x,e,t,n,i,s):null;return _&&g?_.distance<=g.distance?_:g:_||g||null}}const Xr=new zt,Gn=new St,Wn=new St,bi=new kt,_l=new Ye,Yr=new Ye;function wp(r,e,t,n){ye.setBuffer(r._roots[e]);const i=Co(0,r,t,n);return ye.clearBuffer(),i}function Co(r,e,t,n,i=null){const{float32Array:s,uint16Array:a,uint32Array:o}=ye;let c=r*2;if(i===null&&(t.boundingBox||t.computeBoundingBox(),_l.set(t.boundingBox.min,t.boundingBox.max,n),i=_l),Ee(c,a)){const l=e.geometry,u=l.index,d=l.attributes.position,f=t.index,m=t.attributes.position,x=Xe(r,o),_=it(c,a);if(bi.copy(n).invert(),t.boundsTree)return be(r,s,Yr),Yr.matrix.copy(bi),Yr.needsUpdate=!0,t.boundsTree.shapecast({intersectsBounds:g=>Yr.intersectsBox(g),intersectsTriangle:g=>{g.a.applyMatrix4(n),g.b.applyMatrix4(n),g.c.applyMatrix4(n),g.needsUpdate=!0;for(let v=x,w=_+x;v<w;v++)if(Ce(Wn,3*e.resolveTriangleIndex(v),u,d),Wn.needsUpdate=!0,g.intersectsTriangle(Wn))return!0;return!1}});{const g=Lr(t);for(let v=x,w=_+x;v<w;v++){const S=e.resolveTriangleIndex(v);Ce(Gn,3*S,u,d),Gn.a.applyMatrix4(bi),Gn.b.applyMatrix4(bi),Gn.c.applyMatrix4(bi),Gn.needsUpdate=!0;for(let T=0,M=g*3;T<M;T+=3)if(Ce(Wn,T,f,m),Wn.needsUpdate=!0,Gn.intersectsTriangle(Wn))return!0}}}else{const l=ze(r),u=Ne(r,o);return be(l,s,Xr),!!(i.intersectsBox(Xr)&&Co(l,e,t,n,i)||(be(u,s,Xr),i.intersectsBox(Xr)&&Co(u,e,t,n,i)))}}const Zr=new kt,Po=new Ye,xi=new Ye,_p=new q,Tp=new q,Mp=new q,Cp=new q;function Pp(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,d=e.index,f=bt.getPrimitive(),m=bt.getPrimitive();let x=_p,_=Tp,g=null,v=null;i&&(g=Mp,v=Cp);let w=1/0,S=null,T=null;return Zr.copy(t).invert(),xi.matrix.copy(Zr),r.shapecast({boundsTraverseOrder:M=>Po.distanceToBox(M),intersectsBounds:(M,P,E)=>E<w&&E<a?(P&&(xi.min.copy(M.min),xi.max.copy(M.max),xi.needsUpdate=!0),!0):!1,intersectsRange:(M,P)=>{if(e.boundsTree){const E=e.boundsTree;return E.shapecast({boundsTraverseOrder:O=>xi.distanceToBox(O),intersectsBounds:(O,A,R)=>R<w&&R<a,intersectsRange:(O,A)=>{for(let R=O,B=O+A;R<B;R++){const I=E.resolveTriangleIndex(R);Ce(m,3*I,d,u),m.a.applyMatrix4(t),m.b.applyMatrix4(t),m.c.applyMatrix4(t),m.needsUpdate=!0;for(let U=M,L=M+P;U<L;U++){const J=r.resolveTriangleIndex(U);Ce(f,3*J,l,c),f.needsUpdate=!0;const H=f.distanceToTriangle(m,x,g);if(H<w&&(_.copy(x),v&&v.copy(g),w=H,S=U,T=R),H<s)return!0}}}})}else{const E=Lr(e);for(let O=0,A=E;O<A;O++){Ce(m,3*O,d,u),m.a.applyMatrix4(t),m.b.applyMatrix4(t),m.c.applyMatrix4(t),m.needsUpdate=!0;for(let R=M,B=M+P;R<B;R++){const I=r.resolveTriangleIndex(R);Ce(f,3*I,l,c),f.needsUpdate=!0;const U=f.distanceToTriangle(m,x,g);if(U<w&&(_.copy(x),v&&v.copy(g),w=U,S=R,T=O),U<s)return!0}}}}}),bt.releasePrimitive(f),bt.releasePrimitive(m),w===1/0?null:(n.point?n.point.copy(_):n.point=_.clone(),n.distance=w,n.faceIndex=S,i&&(i.point?i.point.copy(v):i.point=v.clone(),i.point.applyMatrix4(Zr),_.applyMatrix4(Zr),i.distance=_.sub(i.point).length(),i.faceIndex=T),n)}function Tl(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 Kr=new Ye,Qr=new iu,Ml=new q,Cl=new kt,Pl=new q,Eo=["getX","getY","getZ"];class Kn extends ml{static serialize(e,t={}){t={cloneBuffers:!0,...t};const n=e.geometry,i=e._roots,s=e._indirectBuffer,a=n.getIndex(),o={version:1,roots:null,index:null,indirectBuffer:null};return t.cloneBuffers?(o.roots=i.map(c=>c.slice()),o.index=a?a.array.slice():null,o.indirectBuffer=s?s.slice():null):(o.roots=i,o.index=a?a.array:null,o.indirectBuffer=s),o}static deserialize(e,t,n={}){n={setIndex:!0,indirect:!!e.indirectBuffer,...n};const{index:i,roots:s,indirectBuffer:a}=e;e.version||(console.warn("MeshBVH.deserialize: Serialization format has been changed and will be fixed up. It is recommended to regenerate any stored serialized data."),c(s));const o=new Kn(t,{...n,[Ir]:!0});if(o._roots=s,o._indirectBuffer=a||null,n.setIndex){const l=t.getIndex();if(l===null){const u=new dt(e.index,1,!1);t.setIndex(u)}else l.array!==i&&(l.array.set(i),l.needsUpdate=!0)}return o;function c(l){for(let u=0;u<l.length;u++){const d=l[u],f=new Uint32Array(d),m=new Uint16Array(d);for(let x=0,_=d.byteLength/qe;x<_;x++){const g=Pe*x,v=2*g;Ee(v,m)||(f[g+6]=f[g+6]/Pe-x)}}}}get primitiveStride(){return 3}get resolveTriangleIndex(){return this.resolvePrimitiveIndex}constructor(e,t={}){t.maxLeafTris&&(console.warn('MeshBVH: "maxLeafTris" option has been deprecated. Use maxLeafSize, instead.'),t={...t,maxLeafSize:t.maxLeafTris}),super(e,t)}shiftTriangleOffsets(e){return super.shiftPrimitiveOffsets(e)}writePrimitiveBounds(e,t,n){const i=this.geometry,s=this._indirectBuffer,a=i.attributes.position,o=i.index?i.index.array:null,c=(s?s[e]:e)*3;let l=c+0,u=c+1,d=c+2;o&&(l=o[l],u=o[u],d=o[d]);for(let f=0;f<3;f++){const m=a[Eo[f]](l),x=a[Eo[f]](u),_=a[Eo[f]](d);let g=m;x<g&&(g=x),_<g&&(g=_);let v=m;x>v&&(v=x),_>v&&(v=_),t[n+f]=g,t[n+f+3]=v}return t}computePrimitiveBounds(e,t,n){const i=this.geometry,s=this._indirectBuffer,a=i.attributes.position,o=i.index?i.index.array:null,c=a.normalized;if(e<0||t+e-n.offset>n.length/6)throw new Error("MeshBVH: compute triangle bounds range is invalid.");const l=a.array,u=a.offset||0;let d=3;a.isInterleavedBufferAttribute&&(d=a.data.stride);const f=["getX","getY","getZ"],m=n.offset;for(let x=e,_=e+t;x<_;x++){const g=(s?s[x]:x)*3,v=(x-m)*6;let w=g+0,S=g+1,T=g+2;o&&(w=o[w],S=o[S],T=o[T]),c||(w=w*d+u,S=S*d+u,T=T*d+u);for(let M=0;M<3;M++){let P,E,O;c?(P=a[f[M]](w),E=a[f[M]](S),O=a[f[M]](T)):(P=l[w+M],E=l[S+M],O=l[T+M]);let A=P;E<A&&(A=E),O<A&&(A=O);let R=P;E>R&&(R=E),O>R&&(R=O);const B=(R-A)/2,I=M*2;n[v+I+0]=A+B,n[v+I+1]=B+(Math.abs(A)+B)*Or}}return n}raycastObject3D(e,t,n=[]){const{material:i}=e;if(i===void 0)return;Cl.copy(e.matrixWorld).invert(),Qr.copy(t.ray).applyMatrix4(Cl),Pl.setFromMatrixScale(e.matrixWorld),Ml.copy(Qr.direction).multiply(Pl);const s=Ml.length(),a=t.near/s,o=t.far/s;if(t.firstHitOnly===!0){let c=this.raycastFirst(Qr,i,a,o);c=Tl(c,e,t),c&&n.push(c)}else{const c=this.raycast(Qr,i,a,o);for(let l=0,u=c.length;l<u;l++){const d=Tl(c[l],e,t);d&&n.push(d)}}return n}refit(e=null){return(this.indirect?vp:sp)(this,e)}raycast(e,t=ca,n=0,i=1/0){const s=this._roots,a=[],o=this.indirect?Sp:lp;for(let c=0,l=s.length;c<l;c++)o(this,c,t,e,a,n,i);return a}raycastFirst(e,t=ca,n=0,i=1/0){const s=this._roots;let a=null;const o=this.indirect?xp:hp;for(let c=0,l=s.length;c<l;c++){const u=o(this,c,t,e,n,i);u!=null&&(a==null||u.distance<a.distance)&&(a=u)}return a}intersectsGeometry(e,t){let n=!1;const i=this._roots,s=this.indirect?wp:dp;for(let a=0,o=i.length;a<o&&(n=s(this,a,e,t),!n);a++);return n}shapecast(e){const t=bt.getPrimitive(),n=super.shapecast({...e,intersectsPrimitive:e.intersectsTriangle,scratchPrimitive:t,iterate:this.indirect?cp:rp});return bt.releasePrimitive(t),n}bvhcast(e,t,n){let{intersectsRanges:i,intersectsTriangles:s}=n;const a=bt.getPrimitive(),o=this.geometry.index,c=this.geometry.attributes.position,l=this.indirect?x=>{const _=this.resolveTriangleIndex(x);Ce(a,_*3,o,c)}:x=>{Ce(a,x*3,o,c)},u=bt.getPrimitive(),d=e.geometry.index,f=e.geometry.attributes.position,m=e.indirect?x=>{const _=e.resolveTriangleIndex(x);Ce(u,_*3,d,f)}:x=>{Ce(u,x*3,d,f)};if(s){if(!(e instanceof Kn))throw new Error('MeshBVH: "intersectsTriangles" callback can only be used with another MeshBVH.');const x=(_,g,v,w,S,T,M,P)=>{for(let E=v,O=v+w;E<O;E++){m(E),u.a.applyMatrix4(t),u.b.applyMatrix4(t),u.c.applyMatrix4(t),u.needsUpdate=!0;for(let A=_,R=_+g;A<R;A++)if(l(A),a.needsUpdate=!0,s(a,u,A,E,S,T,M,P))return!0}return!1};if(i){const _=i;i=function(g,v,w,S,T,M,P,E){return _(g,v,w,S,T,M,P,E)?!0:x(g,v,w,S,T,M,P,E)}}else i=x}return super.bvhcast(e,t,{intersectsRanges:i})}intersectsBox(e,t){return Kr.set(e.min,e.max,t),Kr.needsUpdate=!0,this.shapecast({intersectsBounds:n=>Kr.intersectsBox(n),intersectsTriangle:n=>Kr.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?Pp:gp)(this,e,t,n,i,s,a)}closestPointToPoint(e,t={},n=0,i=1/0){return $d(this,e,t,n,i)}}const Hn={Mesh:lr.prototype.raycast,Line:ha.prototype.raycast,LineSegments:la.prototype.raycast,LineLoop:ua.prototype.raycast,Points:da.prototype.raycast,BatchedMesh:su.prototype.raycast},Je=new lr,$r=[];function Ep(r,e){if(this.isBatchedMesh)kp.call(this,r,e);else{const{geometry:t}=this;if(t.boundsTree)t.boundsTree.raycastObject3D(this,r,e);else{let n;if(this instanceof lr)n=Hn.Mesh;else if(this instanceof la)n=Hn.LineSegments;else if(this instanceof ua)n=Hn.LineLoop;else if(this instanceof ha)n=Hn.Line;else if(this instanceof da)n=Hn.Points;else throw new Error("BVH: Fallback raycast function not found.");n.call(this,r,e)}}}function kp(r,e){if(this.boundsTrees){const t=this.boundsTrees,n=this._drawInfo||this._instanceInfo,i=this._drawRanges||this._geometryInfo,s=this.matrixWorld;Je.material=this.material,Je.geometry=this.geometry;const a=Je.geometry.boundsTree,o=Je.geometry.drawRange;Je.geometry.boundingSphere===null&&(Je.geometry.boundingSphere=new ru);for(let c=0,l=n.length;c<l;c++){if(!this.getVisibleAt(c))continue;const u=n[c].geometryIndex;if(Je.geometry.boundsTree=t[u],this.getMatrixAt(c,Je.matrixWorld).premultiply(s),!Je.geometry.boundsTree){this.getBoundingBoxAt(u,Je.geometry.boundingBox),this.getBoundingSphereAt(u,Je.geometry.boundingSphere);const d=i[u];Je.geometry.setDrawRange(d.start,d.count)}Je.raycast(r,$r);for(let d=0,f=$r.length;d<f;d++){const m=$r[d];m.object=this,m.batchId=c,e.push(m)}$r.length=0}Je.geometry.boundsTree=a,Je.geometry.drawRange=o,Je.material=null,Je.geometry=null}else Hn.BatchedMesh.call(this,r,e)}function Rp(r={}){const{type:e=Kn}=r;return this.boundsTree=new e(this,r),this.boundsTree}const xn=new q,wn=new q,_n=new q,El=new xs,es=new q,ko=new q,kl=new xs,Rl=new xs,ts=new kt,Al=new kt;function wi(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 _i(r,e=null){const t=r.array.constructor,n=r.normalized,i=r.itemSize,s=e===null?r.count:e;return new dt(new t(i*s),i,n)}function Ol(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 Ap(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 Il(r,e,t){const n=r.skeleton,i=r.geometry,s=n.bones,a=n.boneInverses;kl.fromBufferAttribute(i.attributes.skinIndex,e),Rl.fromBufferAttribute(i.attributes.skinWeight,e),ts.elements.fill(0);for(let o=0;o<4;o++){const c=Rl.getComponent(o);if(c!==0){const l=kl.getComponent(o);Al.multiplyMatrices(s[l].matrixWorld,a[l]),Ap(ts,Al,c)}}return ts.multiply(r.bindMatrix).premultiply(r.bindMatrixInverse),t.transformDirection(ts),t}function Ro(r,e,t,n,i){es.set(0,0,0);for(let s=0,a=r.length;s<a;s++){const o=e[s],c=r[s];o!==0&&(ko.fromBufferAttribute(c,n),t?es.addScaledVector(ko,o):es.addScaledVector(ko.sub(i),o))}i.add(es)}function Op(r,e={useGroups:!1,updateIndex:!1,skipAttributes:[]},t=new ti){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 d=r[u];let f=0;if(n!==(d.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 d.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(d.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=d.index.count;else if(d.attributes.position!==void 0)m=d.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 d=0;for(let f=0;f<r.length;++f)d+=r[f].index.count;t.setIndex(new dt(new Uint32Array(d),1,!1)),u=!0}if(s||u){const d=t.index;let f=0,m=0;for(let x=0;x<r.length;++x){const _=r[x],g=_.index;if(a[x]!==!0)for(let v=0;v<g.count;++v)d.setX(f,g.getX(v)+m),f++;m+=_.attributes.position.count}}}for(const u in c){const d=c[u];if(!(u in t.attributes)){let x=0;for(const _ in d)x+=d[_].count;t.setAttribute(u,_i(c[u][0],x))}const f=t.attributes[u];let m=0;for(let x=0,_=d.length;x<_;x++){const g=d[x];a[x]!==!0&&Ol(g,f,m),m+=g.count}}return t}function Ip(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 Bp(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 zp{constructor(e){this.matrixWorld=new kt,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&&Ip(e.skeleton&&e.skeleton.boneMatrices||null,this.boneMatrices)&&this.primitiveCount===n)}}class Np{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 ti),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 ti){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],d=a.get(l);!d||d.didChange(l)?(this._convertToStaticGeometry(l,u),t.push(!1),d?d.update():a.set(l,new zp(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 dt(new Float32Array(0),4,!1))}else Op(s,{useGroups:i,skipAttributes:t},e);for(const o in e.attributes)e.attributes[o].needsUpdate=!0;return e}_convertToStaticGeometry(e,t=new ti){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",_i(o.position)),s&&!c.normal&&o.normal&&t.setAttribute("normal",_i(o.normal)),a&&!c.tangent&&o.tangent&&t.setAttribute("tangent",_i(o.tangent)),wi(n.index,t.index),wi(o.position,c.position),s&&wi(o.normal,c.normal),a&&wi(o.tangent,c.tangent);const l=o.position,u=s?o.normal:null,d=a?o.tangent:null,f=n.morphAttributes.position,m=n.morphAttributes.normal,x=n.morphAttributes.tangent,_=n.morphTargetsRelative,g=e.morphTargetInfluences,v=new ou;v.getNormalMatrix(e.matrixWorld),n.index&&t.index.array.set(n.index.array);for(let w=0,S=o.position.count;w<S;w++)xn.fromBufferAttribute(l,w),u&&wn.fromBufferAttribute(u,w),d&&(El.fromBufferAttribute(d,w),_n.fromBufferAttribute(d,w)),g&&(f&&Ro(f,g,_,w,xn),m&&Ro(m,g,_,w,wn),x&&Ro(x,g,_,w,_n)),e.isSkinnedMesh&&(e.applyBoneTransform(w,xn),u&&Il(e,w,wn),d&&Il(e,w,_n)),i&&xn.applyMatrix4(e.matrixWorld),c.position.setXYZ(w,xn.x,xn.y,xn.z),u&&(i&&wn.applyNormalMatrix(v),c.normal.setXYZ(w,wn.x,wn.y,wn.z)),d&&(i&&_n.transformDirection(e.matrixWorld),c.tangent.setXYZW(w,_n.x,_n.y,_n.z,El.w));for(const w in this.attributes){const S=this.attributes[w];S==="position"||S==="tangent"||S==="normal"||!(S in o)||(c[S]||t.setAttribute(S,_i(o[S])),wi(o[S],c[S]),Ol(o[S],c[S]))}return e.matrixWorld.determinant()<0&&Bp(t),t}}const Up=Object.freeze(Object.defineProperty({__proto__:null,AVERAGE:tl,BVH:dl,CENTER:no,CONTAINED:io,ExtendedTriangle:St,GeometryBVH:ml,MeshBVH:Kn,OrientedBox:Ye,SAH:nl,SKIP_GENERATION:Ir,StaticGeometryGenerator:Np,acceleratedRaycast:Ep,computeBoundsTree:Rp,generateIndirectBuffer:fl},Symbol.toStringTag,{value:"Module"}));class Dp{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}}function Lp(r){return new Worker("/generateMeshBVH.worker-DiCnZlf3.js",{name:r?.name})}const xt={node:"node",material:"material",camera:"camera",light:"light"},qn="KHR_animation_pointer",Fp={CUBICSPLINE:void 0,LINEAR:pa,STEP:cu};class Vp{constructor(e){this.name=qn,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){const t=e.target,n=t.extensions&&t.extensions[qn]&&t.path&&t.path==="pointer";if(!n)return null;let i,s=xt.node,a;if(n){const c=t.extensions[qn];let l=c.pointer;if(!l){console.warn("Invalid path",c,t);return}if(l.startsWith("/materials/")?s=xt.material:l.startsWith("/extensions/KHR_lights_punctual/lights/")?s=xt.light:l.startsWith("/cameras/")&&(s=xt.camera),a=this._tryResolveTargetId(l,s),a===null||isNaN(a)){console.warn("Failed resolving animation node id: "+a,l);return}switch(s){case xt.material:const u=("/materials/"+a.toString()+"/").length,d=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=d+i;break;case xt.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 xt.light:const x=("/extensions/KHR_lights_punctual/lights/"+a.toString()+"/").length;switch(i=l.substring(x),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 xt.camera:const _=("/cameras/"+a.toString()+"/").length,g=l.substring(0,_);switch(i=l.substring(_),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[qn].pointer=l}if(a==null||isNaN(a)){console.warn("Failed resolving animation node id: "+a,t);return}let o;return s===xt.node?o=this.parser.getDependency("node",a):s===xt.material?o=this.parser.getDependency("material",a):s===xt.light?o=this.parser.getDependency("light",a):s===xt.camera?o=this.parser.getDependency("camera",a):console.error("Unhandled type",s),o}createAnimationTracksWithAnimationPointer(e,t,n,i,s){if(!(s.extensions&&s.extensions[qn]&&s.path&&s.path==="pointer"))return null;let a=s.extensions[qn].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 au&&f.morphTargetInfluences&&(c[3]=f.name,c[4]="morphTargetInfluences",d(this.parser));return o}d(this.parser);function u(f,m){try{const x=m.split(".").filter(Boolean),_=x[x.length-1].replace(/\[.*\]$/,"");return _ in f?typeof f[_]=="boolean":!1}catch{return!1}}function d(f){a=c.join(".");let m,x=!1;switch(n.itemSize){case 1:Object.prototype.toString.call(n.array)==="[object Uint8Array]"&&u(e,a)?(m=pu,x=!0):m=fu;break;case 2:case 3:m=du;break;case 4:a.endsWith(".quaternion")?m=uu:m=hu;break}if(!m){console.warn("Unsupported output accessor format",n);return}const _=i.interpolation!==void 0?Fp[i.interpolation]:pa;let g=f._getArrayFromAccessor(n);a.endsWith(".fov")&&(g=g.map(w=>w/Math.PI*180)),x&&(g=g.map(w=>w>0));const v=new m(a,t.array,g,_);if(_==="CUBICSPLINE"&&f._createCubicSplineTrackInterpolant(v),o.push(v),a&&n.itemSize===4&&a.startsWith(".materials.")&&a.endsWith(".color")){const w=new Float32Array(g.length/4);for(let T=0,M=g.length/4;T<M;T+=1)w[T]=g[T*4+3];const S=new m(a.replace(".color",".opacity"),t.array,w,_);_==="CUBICSPLINE"&&f._createCubicSplineTrackInterpolant(v),o.push(S)}}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=[],d=[];for(let f=0,m=s.channels.length;f<m;f++){const x=s.channels[f],_=s.samplers[x.sampler],g=x.target,v=s.parameters!==void 0?s.parameters[_.input]:_.input,w=s.parameters!==void 0?s.parameters[_.output]:_.output;let S=t.loadAnimationTargetFromChannelWithAnimationPointer(x);S||(S=t.loadAnimationTargetFromChannel(x)),o.push(S),c.push(i.getDependency("accessor",v)),l.push(i.getDependency("accessor",w)),u.push(_),d.push(g)}return Promise.all([Promise.all(o),Promise.all(c),Promise.all(l),Promise.all(u),Promise.all(d)]).then(function(f){const m=f[0],x=f[1],_=f[2],g=f[3],v=f[4],w=[];for(let S=0,T=m.length;S<T;S++){const M=m[S],P=x[S],E=_[S],O=g[S],A=v[S];if(M===void 0)continue;M.updateMatrix&&(M.updateMatrix(),M.matrixAutoUpdate=!0);let R=t.createAnimationTracksWithAnimationPointer(M,P,E,O,A);if(R||(R=i._createAnimationTracks(M,P,E,O,A)),R)for(let B=0;B<R.length;B++)w.push(R[B])}return new lu(a,void 0,w)})}}const jp=Object.freeze(Object.defineProperty({__proto__:null,GLTFAnimationPointerExtension:Vp},Symbol.toStringTag,{value:"Module"}));export{Ac as $70d766613f57b014$export$2e2bcd8739ae039,Td as BatchedParticleRenderer,Ao as Builder,Ti as ByteBuffer,Mn as ConstantColor,te as ConstantValue,It as Matrix4,Kn as MeshBVH,xu as MotionController,ss as ParticleSystem,V as RenderMode,ma as SIZE_PREFIX_LENGTH,Er as TrailParticle,ct as Vector4,Dp as WorkerBase,Lp as WorkerWrapper,$u as bundler,Cd as createNoise4D,yu as fetchProfile,Od as index,Up as index$1,jp as index$2,mh as md5,uh as v5};
|