@needle-tools/engine 4.11.1 → 4.11.3-next.ccd3ad6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/dist/{needle-engine.bundle-BSk8yk3v.min.js → needle-engine.bundle-B5jHHYAr.min.js} +93 -93
- package/dist/{needle-engine.bundle-6yF8G5KJ.js → needle-engine.bundle-BzhDhLwp.js} +980 -956
- package/dist/{needle-engine.bundle-DPVYipMl.umd.cjs → needle-engine.bundle-DN-okHp8.umd.cjs} +82 -82
- package/dist/needle-engine.js +2 -2
- package/dist/needle-engine.min.js +1 -1
- package/dist/needle-engine.umd.cjs +1 -1
- package/dist/rapier-BqdcSmKY.umd.cjs +1 -0
- package/dist/rapier-Cg3w3nFI.min.js +1 -0
- package/dist/rapier-sU12SWAs.js +5217 -0
- package/dist/{vendor-DWGd3dEf.min.js → vendor-BahM12Xj.min.js} +1 -1
- package/dist/{vendor-DJBpoQcM.js → vendor-Becub4o1.js} +1 -1
- package/dist/{vendor-CAWj5cBK.umd.cjs → vendor-H-9KkM5B.umd.cjs} +1 -1
- package/lib/engine-components/Animation.d.ts +1 -1
- package/lib/engine-components/Animation.js +2 -2
- package/lib/engine-components/Animation.js.map +1 -1
- package/lib/engine-components/SeeThrough.js +5 -1
- package/lib/engine-components/SeeThrough.js.map +1 -1
- package/lib/engine-components/export/usdz/ThreeUSDZExporter.d.ts +5 -5
- package/lib/engine-components/export/usdz/ThreeUSDZExporter.js +16 -13
- package/lib/engine-components/export/usdz/ThreeUSDZExporter.js.map +1 -1
- package/lib/engine-components/export/usdz/USDZExporter.js +0 -1
- package/lib/engine-components/export/usdz/USDZExporter.js.map +1 -1
- package/lib/engine-components/export/usdz/extensions/behavior/BehaviourComponents.d.ts +8 -0
- package/lib/engine-components/export/usdz/extensions/behavior/BehaviourComponents.js +24 -0
- package/lib/engine-components/export/usdz/extensions/behavior/BehaviourComponents.js.map +1 -1
- package/lib/engine-components/splines/SplineWalker.js +3 -2
- package/lib/engine-components/splines/SplineWalker.js.map +1 -1
- package/lib/engine-components/web/Clickthrough.js.map +1 -1
- package/package.json +3 -3
- package/plugins/types/userconfig.d.ts +7 -0
- package/plugins/vite/build-pipeline.js +15 -7
- package/src/engine-components/Animation.ts +3 -2
- package/src/engine-components/SeeThrough.ts +5 -1
- package/src/engine-components/export/usdz/ThreeUSDZExporter.ts +27 -15
- package/src/engine-components/export/usdz/USDZExporter.ts +0 -1
- package/src/engine-components/export/usdz/extensions/behavior/BehaviourComponents.ts +28 -0
- package/src/engine-components/splines/SplineWalker.ts +3 -2
- package/src/engine-components/web/Clickthrough.ts +1 -0
- package/dist/rapier-BIeDFw5K.umd.cjs +0 -1
- package/dist/rapier-DQM98oaj.min.js +0 -1
- package/dist/rapier-DpcIWXum.js +0 -5217
|
@@ -1118,4 +1118,4 @@ void main() {
|
|
|
1118
1118
|
vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );
|
|
1119
1119
|
|
|
1120
1120
|
#include <fog_vertex>
|
|
1121
|
-
}`;class Sh extends Nc{constructor(e){super(e),this.vector_=new $,this.vector2_=new $,this.vector3_=new $,this.quaternion_=new ne,this.maxParticles=1e4,this.setupBuffers(),this.rebuildMaterial()}setupBuffers(){this.geometry&&this.geometry.dispose(),this.geometry=new R.BufferGeometry,this.indexBuffer=new R.BufferAttribute(new Uint32Array(this.maxParticles*6),1),this.indexBuffer.setUsage(R.DynamicDrawUsage),this.geometry.setIndex(this.indexBuffer),this.positionBuffer=new R.BufferAttribute(new Float32Array(this.maxParticles*6),3),this.positionBuffer.setUsage(R.DynamicDrawUsage),this.geometry.setAttribute("position",this.positionBuffer),this.previousBuffer=new R.BufferAttribute(new Float32Array(this.maxParticles*6),3),this.previousBuffer.setUsage(R.DynamicDrawUsage),this.geometry.setAttribute("previous",this.previousBuffer),this.nextBuffer=new R.BufferAttribute(new Float32Array(this.maxParticles*6),3),this.nextBuffer.setUsage(R.DynamicDrawUsage),this.geometry.setAttribute("next",this.nextBuffer),this.widthBuffer=new R.BufferAttribute(new Float32Array(this.maxParticles*2),1),this.widthBuffer.setUsage(R.DynamicDrawUsage),this.geometry.setAttribute("width",this.widthBuffer),this.sideBuffer=new R.BufferAttribute(new Float32Array(this.maxParticles*2),1),this.sideBuffer.setUsage(R.DynamicDrawUsage),this.geometry.setAttribute("side",this.sideBuffer),this.uvBuffer=new R.BufferAttribute(new Float32Array(this.maxParticles*4),2),this.uvBuffer.setUsage(R.DynamicDrawUsage),this.geometry.setAttribute("uv",this.uvBuffer),this.colorBuffer=new R.BufferAttribute(new Float32Array(this.maxParticles*8),4),this.colorBuffer.setUsage(R.DynamicDrawUsage),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 On(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=Gs(this.settings.material.map.channel),e.map=new R.Uniform$1(this.settings.material.map),e.mapTransform=new R.Uniform$1(new At().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===exports.RenderMode.Trail)this.material=new R.ShaderMaterial({uniforms:e,defines:t,vertexShader:vh,fragmentShader:gh,transparent:this.settings.material.transparent,depthWrite:!this.settings.material.transparent,side:this.settings.material.side,blending:this.settings.material.blending||R.AdditiveBlending,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,f=this.settings.vTileCount,p=1/u,m=1/f;for(let x=0;x<l;x++){const T=c[x],g=T.uvTile%f,v=Math.floor(T.uvTile/f+.001),b=T.previous.values();let _=b.next(),w=_.value,C=w;_.done||(_=b.next());let P;_.value!==void 0?P=_.value:P=C;for(let E=0;E<T.previous.length;E++,e+=2){if(this.positionBuffer.setXYZ(e,C.position.x,C.position.y,C.position.z),this.positionBuffer.setXYZ(e+1,C.position.x,C.position.y,C.position.z),i.worldSpace?(this.positionBuffer.setXYZ(e,C.position.x,C.position.y,C.position.z),this.positionBuffer.setXYZ(e+1,C.position.x,C.position.y,C.position.z)):(T.parentMatrix?this.vector_.copy(C.position).applyMatrix4(T.parentMatrix):this.vector_.copy(C.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,w.position.x,w.position.y,w.position.z),this.previousBuffer.setXYZ(e+1,w.position.x,w.position.y,w.position.z)):(T.parentMatrix?this.vector_.copy(w.position).applyMatrix4(T.parentMatrix):this.vector_.copy(w.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)):(T.parentMatrix?this.vector_.copy(P.position).applyMatrix4(T.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,C.size),this.widthBuffer.setX(e+1,C.size);else if(T.parentMatrix)this.widthBuffer.setX(e,C.size),this.widthBuffer.setX(e+1,C.size);else{const I=(Math.abs(o.x)+Math.abs(o.y)+Math.abs(o.z))/3;this.widthBuffer.setX(e,C.size*I),this.widthBuffer.setX(e+1,C.size*I)}this.uvBuffer.setXY(e,(E/T.previous.length+g)*p,(f-v-1)*m),this.uvBuffer.setXY(e+1,(E/T.previous.length+g)*p,(f-v)*m),this.colorBuffer.setXYZW(e,C.color.x,C.color.y,C.color.z,C.color.w),this.colorBuffer.setXYZW(e+1,C.color.x,C.color.y,C.color.z,C.color.w),E+1<T.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++),w=C,C=P,_.done||(_=b.next(),_.value!==void 0&&(P=_.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 Di{get geometry(){return this._geometry}set geometry(e){if(this._geometry=e,e===void 0||typeof e=="string")return;const t=new R.Triangle;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 R.Vector3,this._tempB=new R.Vector3,this._tempC=new R.Vector3,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],f=t.getIndex().array[i*3+2],p=t.getAttribute("position");this._tempA.fromBufferAttribute(p,l),this._tempB.fromBufferAttribute(p,u),this._tempC.fromBufferAttribute(p,f),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 Di(t.geometries[e.geometry])}clone(){return new Di(this._geometry)}update(e,t){}}Yu({id:"three.quarks",emitterShapes:[{type:"mesh_surface",params:[["geometry",["geometry"]]],constructor:Di,loadJSON:Di.fromJSON}],behaviors:[]});class lo extends R.Object3D{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(lo.equals(this.batches[i].settings,t)){this.batches[i].addSystem(e),this.systemToBatchIndex.set(e,i);return}let n;switch(t.renderMode){case exports.RenderMode.Trail:n=new Sh(t);break;case exports.RenderMode.Mesh:case exports.RenderMode.BillBoard:case exports.RenderMode.VerticalBillBoard:case exports.RenderMode.HorizontalBillBoard:case exports.RenderMode.StretchedBillBoard:n=new yh(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 xh=lo;sh();console.log("%c Particle system powered by three.quarks. https://quarks.art/","font-size: 14px; font-weight: bold;");const Uc=Math.sqrt(5),_h=(Uc-1)/4,ze=(5-Uc)/20,nr=r=>Math.floor(r)|0,ir=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 bh(r=Math.random){const e=Th(r),t=new Float64Array(e).map(a=>ir[a%32*4]),n=new Float64Array(e).map(a=>ir[a%32*4+1]),i=new Float64Array(e).map(a=>ir[a%32*4+2]),s=new Float64Array(e).map(a=>ir[a%32*4+3]);return function(o,c,l,u){let f,p,m,x,T;const g=(o+c+l+u)*_h,v=nr(o+g),b=nr(c+g),_=nr(l+g),w=nr(u+g),C=(v+b+_+w)*ze,P=v-C,E=b-C,I=_-C,O=w-C,A=o-P,N=c-E,B=l-I,D=u-O;let L=0,J=0,W=0,Y=0;A>N?L++:J++,A>B?L++:W++,A>D?L++:Y++,N>B?J++:W++,N>D?J++:Y++,B>D?W++:Y++;const G=L>=3?1:0,se=J>=3?1:0,ce=W>=3?1:0,me=Y>=3?1:0,le=L>=2?1:0,xe=J>=2?1:0,Ce=W>=2?1:0,ye=Y>=2?1:0,de=L>=1?1:0,oe=J>=1?1:0,et=W>=1?1:0,We=Y>=1?1:0,He=A-G+ze,tt=N-se+ze,Ae=B-ce+ze,pe=D-me+ze,ie=A-le+2*ze,st=N-xe+2*ze,we=B-Ce+2*ze,ue=D-ye+2*ze,qe=A-de+3*ze,mt=N-oe+3*ze,yt=B-et+3*ze,Xe=D-We+3*ze,gt=A-1+4*ze,ot=N-1+4*ze,at=B-1+4*ze,vt=D-1+4*ze,Pe=v&255,Ve=b&255,nt=_&255,Je=w&255;let Q=.6-A*A-N*N-B*B-D*D;if(Q<0)f=0;else{const ae=Pe+e[Ve+e[nt+e[Je]]];Q*=Q,f=Q*Q*(t[ae]*A+n[ae]*N+i[ae]*B+s[ae]*D)}let St=.6-He*He-tt*tt-Ae*Ae-pe*pe;if(St<0)p=0;else{const ae=Pe+G+e[Ve+se+e[nt+ce+e[Je+me]]];St*=St,p=St*St*(t[ae]*He+n[ae]*tt+i[ae]*Ae+s[ae]*pe)}let zt=.6-ie*ie-st*st-we*we-ue*ue;if(zt<0)m=0;else{const ae=Pe+le+e[Ve+xe+e[nt+Ce+e[Je+ye]]];zt*=zt,m=zt*zt*(t[ae]*ie+n[ae]*st+i[ae]*we+s[ae]*ue)}let xt=.6-qe*qe-mt*mt-yt*yt-Xe*Xe;if(xt<0)x=0;else{const ae=Pe+de+e[Ve+oe+e[nt+et+e[Je+We]]];xt*=xt,x=xt*xt*(t[ae]*qe+n[ae]*mt+i[ae]*yt+s[ae]*Xe)}let It=.6-gt*gt-ot*ot-at*at-vt*vt;if(It<0)T=0;else{const ae=Pe+1+e[Ve+1+e[nt+1+e[Je+1]]];It*=It,T=It*It*(t[ae]*gt+n[ae]*ot+i[ae]*at+s[ae]*vt)}return 27*(f+p+m+x+T)}}function Th(r){const t=new Uint8Array(512);for(let n=0;n<512/2;n++)t[n]=n;for(let n=0;n<512/2-1;n++){const i=n+~~(r()*(256-n)),s=t[n];t[n]=t[i],t[i]=s}for(let n=256;n<512;n++)t[n]=t[n-256];return t}var Mh=Object.defineProperty,Ch=(r,e,t)=>e in r?Mh(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Te=(r,e,t)=>(Ch(r,typeof e!="symbol"?e+"":e,t),t);(function(){class r{}class e extends r{constructor(d){super(),Te(this,"value"),this.value=d}}class t extends r{constructor(d){super(),Te(this,"value"),this.value=d}}class n extends r{constructor(d){super(),Te(this,"value"),this.value=d}}class i extends r{constructor(d,y="unrestricted"){super(),Te(this,"type"),Te(this,"value"),this.value=d,this.type=y}}class s extends r{constructor(d){super(),Te(this,"value"),this.value=d}}class a extends r{}class o extends r{constructor(d){super(),Te(this,"value"),this.value=d}}class c extends r{}class l extends r{constructor(d){super(),Te(this,"value"),this.value=d}}class u extends r{constructor(d,y="integer"){super(),Te(this,"value"),Te(this,"type"),this.value=d,this.type=y}}class f extends r{constructor(d){super(),Te(this,"value"),this.value=d}}class p extends r{constructor(d,y,S){super(),Te(this,"value"),Te(this,"type"),Te(this,"unit"),this.value=d,this.type=y,this.unit=S}}class m extends r{}class x extends r{}class T extends r{}class g extends r{}class v extends r{}class b extends r{}class _ extends r{}class w extends r{}class C extends r{}class P extends r{}class E extends r{}class I extends r{}class O{constructor(d){Te(this,"input"),Te(this,"index",0),this.input=d}consume(){const d=this.input.codePointAt(this.index);return d!==void 0&&(this.index+=String.fromCodePoint(d).length),d}reconsume(d){d!==void 0&&(this.index-=String.fromCodePoint(d).length)}peek(){const d=[];let y=this.index;for(let S=0;S<3&&y<this.input.length;S++){const M=this.input.codePointAt(y);d.push(M),y+=String.fromCodePoint(M).length}return d}}function A(h){return h===10}function N(h){return A(h)||h===8192||h===32}function B(h){return h>=48&&h<=57}function D(h){return B(h)||h>=65&&h<=70||h>=97&&h<=102}function L(h){return(function(d){return(function(y){return y>=65&&y<=90})(d)||(function(y){return y>=97&&y<=122})(d)})(h)||(function(d){return d>=128})(h)||h===95}function J(h){return L(h)||B(h)||h===45}function W(h){return h>=0&&h<=8||h===11||h>=14&&h<=31||h===127}function Y(h,d){return h===92&&!A(d)}function G(h,d,y){return h===45?L(d)||d===45||Y(d,y):!!L(h)||h===92&&Y(h,d)}function se(h,d,y){return h===43||h===45?B(d)||d===46&&B(y):B(h===46?d:h)}function ce(h){const d=h.consume();if(D(d)){let y=[d];for(;D(...h.peek())&&y.length<5;)y.push(h.consume());N(...h.peek())&&h.consume();const S=parseInt(String.fromCodePoint(...y),16);return S===0||S>1114111?65533:S}return d===void 0?65533:d}function me(h,d){const y=new s("");for(;;){const S=h.consume();if(S===d||S===void 0)return y;if(S===10)return h.reconsume(S),new a;if(S===92){const M=h.peek()[0];M===void 0||(A(M)?h.consume():y.value+=String.fromCodePoint(ce(h)))}else y.value+=String.fromCodePoint(S)}}function le(h){let d="";for(;;){const y=h.consume();if(J(y))d+=String.fromCodePoint(y);else{if(!Y(...h.peek()))return h.reconsume(y),d;d+=String.fromCodePoint(ce(h))}}}function xe(h){let d=(function(y){let S="integer",M="";for([43,45].includes(y.peek()[0])&&(M+=String.fromCodePoint(y.consume()));B(...y.peek());)M+=String.fromCodePoint(y.consume());if(y.peek()[0]===46&&B(y.peek()[1]))for(M+=String.fromCodePoint(y.consume(),y.consume()),S="number";B(...y.peek());)M+=String.fromCodePoint(y.consume());return[69,101].includes(y.peek()[0])&&([45,43].includes(y.peek()[1])&&B(y.peek()[2])?(M+=String.fromCodePoint(y.consume(),y.consume(),y.consume()),S="number"):B(y.peek()[1])&&(M+=String.fromCodePoint(y.consume(),y.consume()),S="number")),{value:parseFloat(M),type:S}})(h);return G(...h.peek())?new p(d.value,d.type,le(h)):h.peek()[0]===37?(h.consume(),new f(d.value)):new u(d.value,d.type)}function Ce(h){for(;;){const d=h.consume();if(d===41||d===void 0)return;Y(...h.peek())&&ce(h)}}function ye(h){const d=le(h);if(d.match(/url/i)&&h.peek()[0]===40){for(h.consume();N(h.peek()[0])&&N(h.peek()[1]);)h.consume();return[34,39].includes(h.peek()[0])||N(h.peek()[0])&&[34,39].includes(h.peek()[1])?new t(d):(function(y){const S=new o("");for(;N(...y.peek());)y.consume();for(;;){const M=y.consume();if(M===41||M===void 0)return S;if(N(M)){for(;N(...y.peek());)y.consume();return y.peek()[0]===41||y.peek()[0]===void 0?(y.consume(),S):(Ce(y),new c)}if([34,39,40].includes(M)||W(M))return Ce(y),new c;if(M===92){if(!Y(...y.peek()))return Ce(y),new c;S.value+=ce(y)}else S.value+=String.fromCodePoint(M)}})(h)}return h.peek()[0]===40?(h.consume(),new t(d)):new e(d)}function de(h){const d=h.consume(),y=h.peek();if(N(d)){for(;N(...h.peek());)h.consume();return new m}if(d===34)return me(h,d);if(d===35){if(J(y[0])||Y(...y)){const S=new i;return G(...y)&&(S.type="id"),S.value=le(h),S}return new l(String.fromCodePoint(d))}return d===39?me(h,d):d===40?new C:d===41?new P:d===43?se(...y)?(h.reconsume(d),xe(h)):new l(String.fromCodePoint(d)):d===44?new b:d===45?se(...h.peek())?(h.reconsume(d),xe(h)):h.peek()[0]===45&&h.peek()[1]===62?(h.consume(),h.consume(),new T):G(...h.peek())?(h.reconsume(d),ye(h)):new l(String.fromCodePoint(d)):d===46?se(...h.peek())?(h.reconsume(d),xe(h)):new l(String.fromCodePoint(d)):d===58?new g:d===59?new v:d===60?y[0]===33&&y[1]===45&&y[2]===45?(h.consume(),h.consume(),h.consume(),new x):new l(String.fromCodePoint(d)):d===64?G(...y)?new n(le(h)):new l(String.fromCodePoint(d)):d===91?new _:d===92?Y(...y)?(h.reconsume(d),ye(h)):new l(String.fromCodePoint(d)):d===93?new w:d===123?new E:d===125?new I:B(d)?(h.reconsume(d),xe(h)):L(d)?(h.reconsume(d),ye(h)):d===void 0?void 0:new l(String.fromCodePoint(d))}const oe=new Set(["px","deg","s","hz","dppx","number","fr"]);function et(h){return oe.has(h.toLowerCase())}function We(h,d){if(["x","y"].includes(h))return h;if(!d)throw new Error("To determine the normalized axis the computedStyle of the source is required.");const y=d.writingMode=="horizontal-tb";if(h==="block")h=y?"y":"x";else{if(h!=="inline")throw new TypeError(`Invalid axis “${h}”`);h=y?"x":"y"}return h}function He(h){const d=[];let y=0;function S(){let k=0;const z=y;for(;y<h.length;){const F=h.slice(y,y+1);if(/\s/.test(F)&&k===0)break;if(F==="(")k+=1;else if(F===")"&&(k-=1,k===0)){y++;break}y++}return h.slice(z,y)}function M(){for(;/\s/.test(h.slice(y,y+1));)y++}for(;y<h.length;){const k=h.slice(y,y+1);/\s/.test(k)?M():d.push(S())}return d}function tt(h,d){return h.reduce(((y,S)=>(y.has(S[d])?y.get(S[d]).push(S):y.set(S[d],[S]),y)),new Map)}function Ae(h,d){const y=[],S=[];for(const M of h)d(M)?y.push(M):S.push(M);return[y,S]}function pe(h,d={}){function y(S){return Array.from(S).map((M=>pe(M,d)))}if(h instanceof CSSUnitValue){if(h.unit==="percent"&&d.percentageReference){const M=h.value/100*d.percentageReference.value,k=d.percentageReference.unit;return new CSSUnitValue(M,k)}const S=h.toSum();if(S&&S.values.length===1&&(h=S.values[0]),h instanceof CSSUnitValue&&h.unit==="em"&&d.fontSize&&(h=new CSSUnitValue(h.value*d.fontSize.value,d.fontSize.unit)),h instanceof CSSKeywordValue){if(h.value==="e")return new CSSUnitValue(Math.E,"number");if(h.value==="pi")return new CSSUnitValue(Math.PI,"number")}return h}if(!h.operator)return h;switch(h.operator){case"sum":h=new CSSMathSum(...y(h.values));break;case"product":h=new CSSMathProduct(...y(h.values));break;case"negate":h=new CSSMathNegate(pe(h.value,d));break;case"clamp":h=new CSSMathClamp(pe(h.lower,d),pe(h.value,d),pe(h.upper,d));break;case"invert":h=new CSSMathInvert(pe(h.value,d));break;case"min":h=new CSSMathMin(...y(h.values));break;case"max":h=new CSSMathMax(...y(h.values))}if(h instanceof CSSMathMin||h instanceof CSSMathMax){const S=Array.from(h.values);if(S.every((M=>M instanceof CSSUnitValue&&M.unit!=="percent"&&et(M.unit)&&M.unit===S[0].unit))){const M=Math[h.operator].apply(Math,S.map((({value:k})=>k)));return new CSSUnitValue(M,S[0].unit)}}if(h instanceof CSSMathMin||h instanceof CSSMathMax){const S=Array.from(h.values),[M,k]=Ae(S,(F=>F instanceof CSSUnitValue&&F.unit!=="percent")),z=Array.from(tt(M,"unit").values());if(z.some((F=>F.length>0))){const F=z.map((U=>{const V=Math[h.operator].apply(Math,U.map((({value:H})=>H)));return new CSSUnitValue(V,U[0].unit)}));h=h instanceof CSSMathMin?new CSSMathMin(...F,...k):new CSSMathMax(...F,...k)}return S.length===1?S[0]:h}if(h instanceof CSSMathNegate)return h.value instanceof CSSUnitValue?new CSSUnitValue(0-h.value.value,h.value.unit):h.value instanceof CSSMathNegate?h.value.value:h;if(h instanceof CSSMathInvert)return h.value instanceof CSSMathInvert?h.value.value:h;if(h instanceof CSSMathSum){let S=function(k){const z=k.filter((F=>F instanceof CSSUnitValue));return[...k.filter((F=>!(F instanceof CSSUnitValue))),...Array.from(tt(z,"unit").entries()).map((([F,U])=>{const V=U.reduce(((H,{value:X})=>H+X),0);return new CSSUnitValue(V,F)}))]},M=[];for(const k of h.values)k instanceof CSSMathSum?M.push(...k.values):M.push(k);return M=S(M),M.length===1?M[0]:new CSSMathSum(...M)}if(h instanceof CSSMathProduct){let S=[];for(const z of h.values)z instanceof CSSMathProduct?S.push(...z.values):S.push(z);const[M,k]=Ae(S,(z=>z instanceof CSSUnitValue&&z.unit==="number"));if(M.length>1){const z=M.reduce(((F,{value:U})=>F*U),1);S=[new CSSUnitValue(z,"number"),...k]}if(S.length===2){let z,F;for(const U of S)U instanceof CSSUnitValue&&U.unit==="number"?z=U:U instanceof CSSMathSum&&[...U.values].every((V=>V instanceof CSSUnitValue))&&(F=U);if(z&&F)return new CSSMathSum(...[...F.values].map((U=>new CSSUnitValue(U.value*z.value,U.unit))))}if(S.every((z=>z instanceof CSSUnitValue&&et(z.unit)||z instanceof CSSMathInvert&&z.value instanceof CSSUnitValue&&et(z.value.unit)))){const z=new CSSMathProduct(...S).toSum();if(z&&z.values.length===1)return z.values[0]}return new CSSMathProduct(...S)}return h}const ie=null,st=["percent","length","angle","time","frequency","resolution","flex"],we={fontRelativeLengths:{units:new Set(["em","rem","ex","rex","cap","rcap","ch","rch","ic","ric","lh","rlh"])},viewportRelativeLengths:{units:new Set(["vw","lvw","svw","dvw","vh","lvh","svh","dvh","vi","lvi","svi","dvi","vb","lvb","svb","dvb","vmin","lvmin","svmin","dvmin","vmax","lvmax","svmax","dvmax"])},absoluteLengths:{units:new Set(["cm","mm","Q","in","pt","pc","px"]),compatible:!0,canonicalUnit:"px",ratios:{cm:96/2.54,mm:96/2.54/10,Q:96/2.54/40,in:96,pc:16,pt:96/72,px:1}},angle:{units:new Set(["deg","grad","rad","turn"]),compatible:!0,canonicalUnit:"deg",ratios:{deg:1,grad:.9,rad:180/Math.PI,turn:360}},time:{units:new Set(["s","ms"]),compatible:!0,canonicalUnit:"s",ratios:{s:1,ms:.001}},frequency:{units:new Set(["hz","khz"]),compatible:!0,canonicalUnit:"hz",ratios:{hz:1,khz:1e3}},resolution:{units:new Set(["dpi","dpcm","dppx"]),compatible:!0,canonicalUnit:"dppx",ratios:{dpi:1/96,dpcm:2.54/96,dppx:1}}},ue=new Map;for(const h of Object.values(we))if(h.compatible)for(const d of h.units)ue.set(d,h);function qe(h){return ue.get(h)}function mt(h,d){const y={...h};for(const S of Object.keys(d))y[S]?y[S]+=d[S]:y[S]=d[S];return y}function yt(h){return h==="number"?{}:h==="percent"?{percent:1}:we.absoluteLengths.units.has(h)||we.fontRelativeLengths.units.has(h)||we.viewportRelativeLengths.units.has(h)?{length:1}:we.angle.units.has(h)?{angle:1}:we.time.units.has(h)?{time:1}:we.frequency.units.has(h)?{frequency:1}:we.resolution.units.has(h)?{resolution:1}:h==="fr"?{flex:1}:ie}function Xe(h){if(h instanceof CSSUnitValue){let{unit:d,value:y}=h;const S=qe(h.unit);return S&&d!==S.canonicalUnit&&(y*=S.ratios[d],d=S.canonicalUnit),d==="number"?[[y,{}]]:[[y,{[d]:1}]]}if(h instanceof CSSMathInvert){if(!(h.value instanceof CSSUnitValue))throw new Error("Not implemented");const d=Xe(h.value);if(d===ie||d.length>1)return ie;const y=d[0],S={};for(const[M,k]of Object.entries(y[1]))S[M]=-1*k;return d[0]=[1/y[0],S],d}if(h instanceof CSSMathProduct){let d=[[1,{}]];for(const y of h.values){const S=Xe(y),M=[];if(S===ie)return ie;for(const k of d)for(const z of S)M.push([k[0]*z[0],mt(k[1],z[1])]);d=M}return d}throw new Error("Not implemented")}function gt(h,d){if(yt(d)===ie)throw new SyntaxError("The string did not match the expected pattern.");const y=Xe(h);if(!y)throw new TypeError;if(y.length>1)throw new TypeError("Sum has more than one item");const S=(function(M,k){const z=M.unit,F=M.value,U=qe(z),V=qe(k);return!V||U!==V?ie:new CSSUnitValue(F*V.ratios[z]/V.ratios[k],k)})(ot(y[0]),d);if(S===ie)throw new TypeError;return S}function ot(h){const[d,y]=h,S=Object.entries(y);if(S.length>1)return ie;if(S.length===0)return new CSSUnitValue(d,"number");const M=S[0];return M[1]!==1?ie:new CSSUnitValue(d,M[0])}function at(h,...d){if(d&&d.length)throw new Error("Not implemented");const y=Xe(h).map((S=>ot(S)));if(y.some((S=>S===ie)))throw new TypeError("Type error");return new CSSMathSum(...y)}function vt(h,d){if(h.percentHint&&d.percentHint&&h.percentHint!==d.percentHint)return ie;const y={...h,percentHint:h.percentHint??d.percentHint};for(const S of st)d[S]&&(y[S]??(y[S]=0),y[S]+=d[S]);return y}class Pe{constructor(d,y){Te(this,"name"),Te(this,"values"),this.name=d,this.values=y}}class Ve{constructor(d,y){Te(this,"value"),Te(this,"associatedToken"),this.value=d,this.associatedToken=y}}function nt(h){if(Array.isArray(h))return h;if(typeof h=="string")return(function(d){const y=new O(d),S=[];for(;;){const M=de(y);if(M===void 0)return S;S.push(M)}})(h);throw new TypeError("Invalid input type "+typeof h)}function Je(h){const d=h.shift();return d instanceof E||d instanceof _||d instanceof C?(function(y,S){let M;if(S instanceof E)M=I;else if(S instanceof C)M=P;else{if(!(S instanceof _))return;M=w}const k=new Ve([],S);for(;;){const z=y.shift();if(z instanceof M||z===void 0)return k;y.unshift(z),k.value.push(Je(y))}})(h,d):d instanceof t?(function(y,S){const M=new Pe(y.value,[]);for(;;){const k=S.shift();if(k instanceof P||k===void 0)return M;S.unshift(k),M.values.push(Je(S))}})(d,h):d}function Q(h){if(h instanceof C||h instanceof P)return 6;if(h instanceof l)switch(h.value){case"*":case"/":return 4;case"+":case"-":return 2}}function St(h){return h[h.length-1]}function zt(h,d,y){const S=["+","-"].includes(h.value)?"ADDITION":"MULTIPLICATION",M=d.type===S?d.values:[d],k=y.type===S?y.values:[y];return h.value==="-"?k[0]={type:"NEGATE",value:k[0]}:h.value==="/"&&(k[0]={type:"INVERT",value:k[0]}),{type:S,values:[...M,...k]}}function xt(h){if(h.type==="ADDITION")return new CSSMathSum(...h.values.map((d=>xt(d))));if(h.type==="MULTIPLICATION")return new CSSMathProduct(...h.values.map((d=>xt(d))));if(h.type==="NEGATE")return new CSSMathNegate(xt(h.value));if(h.type==="INVERT")return new CSSMathInvert(xt(h.value));if(h instanceof Ve)return It(new Pe("calc",h.value));if(h instanceof e){if(h.value==="e")return new CSSUnitValue(Math.E,"number");if(h.value==="pi")return new CSSUnitValue(Math.PI,"number");throw new SyntaxError("Invalid math expression")}return ae(h)}function It(h){if(h.name==="min"||h.name==="max"){const S=h.values.filter((M=>!(M instanceof m||M instanceof b))).map((M=>pe(It(new Pe("calc",M)))));return h.name==="min"?new CSSMathMin(...S):new CSSMathMax(...S)}if(h.name!=="calc")return null;const d=xt((function(S){const M=[],k=[];for(;S.length;){const z=S.shift();if(z instanceof u||z instanceof p||z instanceof f||z instanceof Pe||z instanceof Ve||z instanceof e)k.push(z);else if(z instanceof l&&["*","/","+","-"].includes(z.value)){for(;M.length&&!(St(M)instanceof C)&&Q(St(M))>Q(z);){const F=M.pop(),U=k.pop(),V=k.pop();k.push(zt(F,V,U))}M.push(z)}else if(z instanceof C)M.push(z);else if(z instanceof P){if(!M.length)return null;for(;!(St(M)instanceof C);){const F=M.pop(),U=k.pop(),V=k.pop();k.push(zt(F,V,U))}if(!(St(M)instanceof C))return null;M.pop()}else if(!(z instanceof m))return null}for(;M.length;){if(St(M)instanceof C)return null;const z=M.pop(),F=k.pop(),U=k.pop();k.push(zt(z,U,F))}return k[0]})([...h.values]));let y;try{y=pe(d)}catch{new CSSStyleSheet().insertRule("error",0)}return y instanceof CSSUnitValue?new CSSMathSum(y):y}function ae(h){return h instanceof Pe&&["calc","min","max","clamp"].includes(h.name)?It(h):h instanceof u&&h.value===0&&!h.unit?new CSSUnitValue(0,"px"):h instanceof u?new CSSUnitValue(h.value,"number"):h instanceof f?new CSSUnitValue(h.value,"percent"):h instanceof p?new CSSUnitValue(h.value,h.unit):void 0}function Hc(h){const d=(function(y){const S=nt(y);for(;S[0]instanceof m;)S.shift();if(S[0]===void 0)return null;const M=Je(S);for(;S[0]instanceof m;)S.shift();return S[0]===void 0?M:null})(h);return d===null&&new CSSStyleSheet().insertRule("error",0),d instanceof u||d instanceof f||d instanceof p||d instanceof Pe||new CSSStyleSheet().insertRule("error",0),d instanceof p&&yt(d.unit)===null&&new CSSStyleSheet().insertRule("error",0),ae(d)}(function(){let h=new WeakMap;function d(k){const z=[];for(let U=0;U<k.length;U++)z[U]=typeof(F=k[U])=="number"?new CSSUnitValue(F,"number"):F;var F;return z}class y{static parse(z){return z instanceof y?z:pe(Hc(z),{})}}class S extends y{constructor(z,F,U,V){super(),h.set(this,{values:d(z),operator:F,name:U||F,delimiter:V||", "})}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 M={CSSNumericValue:y,CSSMathValue:S,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 gt(this,k)}toSum(...k){return at(this,...k)}type(){return yt(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 S{constructor(k){super(arguments,"sum","calc"," + ")}},CSSMathProduct:class extends S{constructor(k){super(arguments,"product","calc"," * ")}toSum(...k){return at(this,...k)}type(){return h.get(this).values.map((k=>k.type())).reduce(vt)}},CSSMathNegate:class extends S{constructor(k){super([arguments[0]],"negate","-")}get value(){return h.get(this).values[0]}type(){return this.value.type()}},CSSMathInvert:class extends S{constructor(k){super([1,arguments[0]],"invert","calc"," / ")}get value(){return h.get(this).values[1]}type(){return(function(k){const z={};for(const F of st)z[F]=-1*k[F];return z})(h.get(this).values[1].type())}},CSSMathMax:class extends S{constructor(){super(arguments,"max")}},CSSMathMin:class extends S{constructor(){super(arguments,"min")}}};if(!window.CSS&&!Reflect.defineProperty(window,"CSS",{value:{}}))throw Error("Error installing CSSOM support");window.CSSUnitValue||["number","percent","em","ex","px","cm","mm","in","pt","pc","Q","vw","vh","vmin","vmax","rems","ch","deg","rad","grad","turn","ms","s","Hz","kHz","dppx","dpi","dpcm","fr"].forEach((k=>{if(!Reflect.defineProperty(CSS,k,{value:z=>new CSSUnitValue(z,k)}))throw Error(`Error installing CSS.${k}`)}));for(let[k,z]of Object.entries(M))if(!(k in window)&&!Reflect.defineProperty(window,k,{value:z}))throw Error(`Error installing CSSOM support for ${k}`)})();const po="block";let Ue=new WeakMap,Bt=new WeakMap;const Ji=["entry","exit","cover","contain","entry-crossing","exit-crossing"];function mo(h){return h===document.scrollingElement?document:h}function en(h){jr(h);let d=Ue.get(h).animations;if(d.length===0)return;let y=h.currentTime;for(let S=0;S<d.length;S++)d[S].tickAnimation(y)}function yo(h,d){if(!h)return null;const y=Bt.get(h).sourceMeasurements,S=getComputedStyle(h);let M=y.scrollTop;return We(d,S)==="x"&&(M=Math.abs(y.scrollLeft)),M}function Jr(h,d){const y=pe(h,d);if(y instanceof CSSUnitValue){if(y.unit==="px")return y.value;throw TypeError("Unhandled unit type "+y.unit)}throw TypeError("Unsupported value type: "+typeof h)}function jr(h){if(!(h instanceof vn))return void(function(y){const S=Ue.get(y);if(!S.anonymousSource)return;const M=vo(S.anonymousSource,S.anonymousTarget);gn(y,M)})(h);const d=h.subject;if(!d||getComputedStyle(d).display=="none")return void gn(h,null);gn(h,Xr(d))}function go(h){return["block","inline","x","y"].includes(h)}function Gr(h){const d=getComputedStyle(h);return{scrollLeft:h.scrollLeft,scrollTop:h.scrollTop,scrollWidth:h.scrollWidth,scrollHeight:h.scrollHeight,clientWidth:h.clientWidth,clientHeight:h.clientHeight,writingMode:d.writingMode,direction:d.direction,scrollPaddingTop:d.scrollPaddingTop,scrollPaddingBottom:d.scrollPaddingBottom,scrollPaddingLeft:d.scrollPaddingLeft,scrollPaddingRight:d.scrollPaddingRight}}function $r(h,d){if(!h||!d)return;let y=0,S=0,M=d;const k=h.offsetParent;for(;M&&M!=k;)S+=M.offsetLeft,y+=M.offsetTop,M=M.offsetParent;S-=h.offsetLeft+h.clientLeft,y-=h.offsetTop+h.clientTop;const z=getComputedStyle(d);return{top:y,left:S,offsetWidth:d.offsetWidth,offsetHeight:d.offsetHeight,fontSize:z.fontSize}}function ji(h){let d=Bt.get(h);d.sourceMeasurements=Gr(h);for(const y of d.timelineRefs){const S=y.deref();S instanceof vn&&(Ue.get(S).subjectMeasurements=$r(h,S.subject))}d.updateScheduled||(setTimeout((()=>{for(const y of d.timelineRefs){const S=y.deref();S&&en(S)}d.updateScheduled=!1})),d.updateScheduled=!0)}function gn(h,d){const y=Ue.get(h),S=y.source;if(S!=d){if(S){const M=Bt.get(S);if(M){M.timelineRefs.delete(h);const k=Array.from(M.timelineRefs).filter((z=>z.deref()===void 0));for(const z of k)M.timelineRefs.delete(z);M.timelineRefs.size===0&&(M.disconnect(),Bt.delete(S))}}if(y.source=d,d){let M=Bt.get(d);if(!M){M={timelineRefs:new Set,sourceMeasurements:Gr(d)},Bt.set(d,M);const k=new ResizeObserver((U=>{for(const V of U)ji(y.source)}));k.observe(d);for(const U of d.children)k.observe(U);const z=new MutationObserver((U=>{for(const V of U)ji(V.target)}));z.observe(d,{attributes:!0,attributeFilter:["style","class"]});const F=()=>{M.sourceMeasurements.scrollLeft=d.scrollLeft,M.sourceMeasurements.scrollTop=d.scrollTop;for(const U of M.timelineRefs){const V=U.deref();V&&en(V)}};mo(d).addEventListener("scroll",F),M.disconnect=()=>{k.disconnect(),z.disconnect(),mo(d).removeEventListener("scroll",F)}}M.timelineRefs.add(new WeakRef(h))}}}function Wr(h,d){let y=Ue.get(h).animations;for(let S=0;S<y.length;S++)y[S].animation==d&&y.splice(S,1)}function Hr(h,d,y){let S=Ue.get(h).animations;for(let M=0;M<S.length;M++)if(S[M].animation==d)return;S.push({animation:d,tickAnimation:y}),queueMicrotask((()=>{en(h)}))}class je{constructor(d){if(Ue.set(this,{source:null,axis:po,anonymousSource:d?d.anonymousSource:null,anonymousTarget:d?d.anonymousTarget:null,subject:null,inset:null,animations:[],subjectMeasurements:null}),gn(this,d&&d.source!==void 0?d.source:document.scrollingElement),d&&d.axis!==void 0&&d.axis!=po){if(!go(d.axis))throw TypeError("Invalid axis");Ue.get(this).axis=d.axis}en(this)}set source(d){gn(this,d),en(this)}get source(){return Ue.get(this).source}set axis(d){if(!go(d))throw TypeError("Invalid axis");Ue.get(this).axis=d,en(this)}get axis(){return Ue.get(this).axis}get duration(){return CSS.percent(100)}get phase(){const d=this.source;if(!d)return"inactive";let y=getComputedStyle(d);return y.display=="none"?"inactive":d==document.scrollingElement||y.overflow!="visible"&&y.overflow!="clip"?"active":"inactive"}get currentTime(){const y=this.source;if(!y||!y.isConnected||this.phase=="inactive")return null;const S=getComputedStyle(y);if(S.display==="inline"||S.display==="none")return null;const M=this.axis,k=yo(y,M),z=(function(F,U){const V=Bt.get(F).sourceMeasurements,H=getComputedStyle(F).writingMode=="horizontal-tb";return U==="block"?U=H?"y":"x":U==="inline"&&(U=H?"x":"y"),U==="y"?V.scrollHeight-V.clientHeight:U==="x"?V.scrollWidth-V.clientWidth:void 0})(y,M);return z>0?CSS.percent(100*k/z):CSS.percent(100)}get __polyfill(){return!0}}function qr(h,d){let y=h.parentElement;for(;y!=null;){if(d(y))return y;y=y.parentElement}}function vo(h,d){switch(h){case"root":return document.scrollingElement;case"nearest":return Xr(d);case"self":return d;default:throw new TypeError("Invalid ScrollTimeline Source Type.")}}function qc(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 So(h){const d=getComputedStyle(h);return d.transform!="none"||d.perspective!="none"||d.willChange=="transform"||d.willChange=="perspective"||d.filter!="none"||d.willChange=="filter"||d.backdropFilter!="none"}function Xc(h){return getComputedStyle(h).position!="static"||So(h)}function Yc(h){switch(getComputedStyle(h).position){case"static":case"relative":case"sticky":return qr(h,qc);case"absolute":return qr(h,Xc);case"fixed":return qr(h,So)}}function Xr(h){if(h&&h.isConnected){for(;h=Yc(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 Dn(h,d){const y=Ue.get(h),S=y.subjectMeasurements,M=Bt.get(y.source).sourceMeasurements;return h.phase==="inactive"?null:h instanceof vn?Yr(d,M,S,y.axis,y.inset):null}function Yr(h,d,y,S,M){const k=d.direction=="rtl"||d.writingMode=="vertical-rl";let z,F,U={fontSize:y.fontSize};We(S,d)==="x"?(z=y.offsetWidth,F=y.left,U.scrollPadding=[d.scrollPaddingLeft,d.scrollPaddingRight],k&&(F+=d.scrollWidth-d.clientWidth,U.scrollPadding=[d.scrollPaddingRight,d.scrollPaddingLeft]),U.containerSize=d.clientWidth):(z=y.offsetHeight,F=y.top,U.scrollPadding=[d.scrollPaddingTop,d.scrollPaddingBottom],U.containerSize=d.clientHeight);const V=(function(es,qi){const cl={start:0,end:0};if(!es)return cl;const[ll,ul]=[es.start,es.end].map(((Io,Bo)=>Io==="auto"?qi.scrollPadding[Bo]==="auto"?0:parseFloat(qi.scrollPadding[Bo]):Jr(Io,{percentageReference:CSS.px(qi.containerSize),fontSize:CSS.px(parseFloat(qi.fontSize))})));return{start:ll,end:ul}})(M,U),H=F-U.containerSize+V.end,X=F+z-V.start,Z=H+z,he=X-z,_e=Math.min(Z,he),Ye=Math.max(Z,he);let _t,ct;const zo=z>U.containerSize-V.start-V.end;switch(h){case"cover":_t=H,ct=X;break;case"contain":_t=_e,ct=Ye;break;case"entry":_t=H,ct=_e;break;case"exit":_t=Ye,ct=X;break;case"entry-crossing":_t=H,ct=zo?Ye:_e;break;case"exit-crossing":_t=zo?_e:Ye,ct=X}return{start:_t,end:ct}}function xo(h,d){if(h instanceof vn){const{rangeName:y,offset:S}=d;return _o(Dn(h,y),S,Dn(h,"cover"),h.subject)}if(h instanceof je){const{axis:y,source:S}=h,{sourceMeasurements:M}=Bt.get(S);let k;return k=We(y,M)==="x"?M.scrollWidth-M.clientWidth:M.scrollHeight-M.clientHeight,Jr(d,{percentageReference:CSS.px(k)})/k}unsupportedTimeline(h)}function _o(h,d,y,S){if(!h||!y)return 0;let M=getComputedStyle(S);return(Jr(d,{percentageReference:CSS.px(h.end-h.start),fontSize:CSS.px(parseFloat(M.fontSize))})+h.start-y.start)/(y.end-y.start)}let vn=class extends je{constructor(d){super(d);const y=Ue.get(this);y.subject=d&&d.subject?d.subject:void 0,d&&d.inset&&(y.inset=(function(S){if(!S)return{start:0,end:0};let M;if(M=typeof S=="string"?He(S).map((k=>{if(k==="auto")return"auto";try{return CSSNumericValue.parse(k)}catch{throw TypeError(`Could not parse inset "${S}"`)}})):Array.isArray(S)?S:[S],M.length===0||M.length>2)throw TypeError("Invalid inset");for(const k of M){if(k==="auto")continue;const z=k.type();if(z.length!==1&&z.percent!==1)throw TypeError("Invalid inset")}return{start:M[0],end:M[1]??M[0]}})(d.inset)),y.subject&&(new ResizeObserver((()=>{ji(y.source)})).observe(y.subject),new MutationObserver((()=>{ji(y.source)})).observe(y.subject,{attributes:!0,attributeFilter:["class","style"]})),jr(this),y.subjectMeasurements=$r(y.source,y.subject),en(this)}get source(){return jr(this),Ue.get(this).source}set source(d){throw new Error("Cannot set the source of a view timeline")}get subject(){return Ue.get(this).subject}get axis(){return Ue.get(this).axis}get currentTime(){const y=yo(this.source,this.axis);if(y==null)return null;const S=Dn(this,"cover");if(!S)return null;const M=(y-S.start)/(S.end-S.start);return CSS.percent(100*M)}get startOffset(){return CSS.px(Dn(this,"cover").start)}get endOffset(){return CSS.px(Dn(this,"cover").end)}};const Zc=document.getAnimations,Kc=window.Element.prototype.getAnimations,Qc=window.Element.prototype.animate,bo=window.Animation;class Sn{constructor(){this.state="pending",this.nativeResolve=this.nativeReject=null,this.promise=new Promise(((d,y)=>{this.nativeResolve=d,this.nativeReject=y}))}resolve(d){this.state="resolved",this.nativeResolve(d)}reject(d){this.state="rejected",this.promise.catch((()=>{})),this.nativeReject(d)}}function Fn(h){h.readyPromise=new Sn,requestAnimationFrame((()=>{var d;(((d=h.timeline)==null?void 0:d.currentTime)??null)!==null&&(Gi(h),h.pendingTask!=="play"||h.startTime===null&&h.holdTime===null?h.pendingTask==="pause"&&Co(h):Mo(h))}))}function To(){return new DOMException("The user aborted a request","AbortError")}function tn(h,d){if(d===null)return d;if(typeof d!="number")throw new DOMException(`Unexpected value: ${d}. Cannot convert to CssNumberish`,"InvalidStateError");const y=h.rangeDuration??100,S=Ut(h),M=S?y*d/S:0;return CSS.percent(M)}function ge(h,d){if(h.timeline){if(d===null)return d;if(d.unit==="percent"){const y=h.rangeDuration??100,S=Ut(h);return d.value*S/y}throw new DOMException("CSSNumericValue must be a percentage for progress based animations.","NotSupportedError")}{if(d==null||typeof d=="number")return d;const y=d.to("ms");if(y)return y.value;throw new DOMException("CSSNumericValue must be either a number or a time value for time based animations.","InvalidStateError")}}function Mo(h){const d=ge(h,h.timeline.currentTime);if(h.holdTime!=null)wt(h),h.animation.playbackRate==0?h.startTime=d:(h.startTime=d-h.holdTime/h.animation.playbackRate,h.holdTime=null);else if(h.startTime!==null&&h.pendingPlaybackRate!==null){const y=(d-h.startTime)*h.animation.playbackRate;wt(h);const S=h.animation.playbackRate;S==0?(h.holdTime=null,h.startTime=d):h.startTime=d-y/S}h.readyPromise&&h.readyPromise.state=="pending"&&h.readyPromise.resolve(h.proxy),Nt(h,!1,!1),Dt(h),h.pendingTask=null}function Co(h){const d=ge(h,h.timeline.currentTime);h.startTime!=null&&h.holdTime==null&&(h.holdTime=(d-h.startTime)*h.animation.playbackRate),wt(h),h.startTime=null,h.readyPromise.resolve(h.proxy),Nt(h,!1,!1),Dt(h),h.pendingTask=null}function wo(h){if(!h.finishedPromise||h.finishedPromise.state!="pending"||h.proxy.playState!="finished")return;h.finishedPromise.resolve(h.proxy),h.animation.pause();const d=new CustomEvent("finish",{detail:{currentTime:h.proxy.currentTime,timelineTime:h.proxy.timeline.currentTime}});Object.defineProperty(d,"currentTime",{get:function(){return this.detail.currentTime}}),Object.defineProperty(d,"timelineTime",{get:function(){return this.detail.timelineTime}}),requestAnimationFrame((()=>{queueMicrotask((()=>{h.animation.dispatchEvent(d)}))}))}function xn(h){return h.pendingPlaybackRate!==null?h.pendingPlaybackRate:h.animation.playbackRate}function wt(h){h.pendingPlaybackRate!==null&&(h.animation.playbackRate=h.pendingPlaybackRate,h.pendingPlaybackRate=null)}function Po(h){if(!h.timeline)return null;const d=ge(h,h.timeline.currentTime);if(d===null||h.startTime===null)return null;let y=(d-h.startTime)*h.animation.playbackRate;return y==-0&&(y=0),y}function Nt(h,d,y){if(!h.timeline)return;let S=d?ge(h,h.proxy.currentTime):Po(h);if(S&&h.startTime!=null&&!h.proxy.pending){const M=xn(h),k=Ut(h);let z=h.previousCurrentTime;M>0&&S>=k&&h.previousCurrentTime!=null?((z===null||z<k)&&(z=k),h.holdTime=d?S:z):M<0&&S<=0?((z==null||z>0)&&(z=0),h.holdTime=d?S:z):M!=0&&(d&&h.holdTime!==null&&(h.startTime=(function(F,U){if(!F.timeline)return null;const V=ge(F,F.timeline.currentTime);return V==null?null:V-U/F.animation.playbackRate})(h,h.holdTime)),h.holdTime=null)}Dt(h),h.previousCurrentTime=ge(h,h.proxy.currentTime),h.proxy.playState=="finished"?(h.finishedPromise||(h.finishedPromise=new Sn),h.finishedPromise.state=="pending"&&(y?wo(h):Promise.resolve().then((()=>{wo(h)})))):(h.finishedPromise&&h.finishedPromise.state=="resolved"&&(h.finishedPromise=new Sn),h.animation.playState!="paused"&&h.animation.pause())}function Ut(h){const d=(function(S){const M=S.proxy.effect.getTiming();return S.normalizedTiming||M})(h),y=d.delay+d.endDelay+d.iterations*d.duration;return Math.max(0,y)}function Dt(h){if(h.timeline)if(h.startTime!==null){const d=h.timeline.currentTime;if(d==null)return;Zr(h,(ge(h,d)-h.startTime)*h.animation.playbackRate)}else h.holdTime!==null&&Zr(h,h.holdTime)}function Zr(h,d){const y=h.timeline,S=h.animation.playbackRate,M=y.currentTime&&y.currentTime.value==(S<0?0:100)?S<0?.001:-.001:0;h.animation.currentTime=d+M}function Kr(h,d){if(!h.timeline)return;const y=h.proxy.playState=="paused"&&h.proxy.pending;let S=!1,M=ge(h,h.proxy.currentTime);xn(h)==0&&M==null&&(h.holdTime=0),M==null&&(h.autoAlignStartTime=!0),(h.proxy.playState==="finished"||y)&&(h.holdTime=null,h.startTime=null,h.autoAlignStartTime=!0),h.holdTime&&(h.startTime=null),h.pendingTask&&(h.pendingTask=null,S=!0),(h.holdTime!==null||h.autoAlignStartTime||y||h.pendingPlaybackRate!==null)&&(h.readyPromise&&!S&&(h.readyPromise=null),Dt(h),h.readyPromise||Fn(h),h.pendingTask="play",Hr(h.timeline,h.animation,Qr.bind(h.proxy)),Nt(h,!1,!1))}function Qr(h){const d=q.get(this);if(!d)return;if(h==null)return void(d.proxy.playState!=="paused"&&d.animation.playState!="idle"&&d.animation.cancel());Gi(d),d.pendingTask&&requestAnimationFrame((()=>{d.pendingTask!=="play"||d.startTime===null&&d.holdTime===null?d.pendingTask==="pause"&&Co(d):Mo(d)}));const y=this.playState;if(y=="running"||y=="finished"){const S=ge(d,h);Zr(d,(S-ge(d,this.startTime))*this.playbackRate),Nt(d,!1,!1)}}function Eo(h){h.specifiedTiming=null}let q=new WeakMap;window.addEventListener("pagehide",(h=>{q=new WeakMap}),!1);let ko=new WeakMap;function Gi(h){if(!h.autoAlignStartTime||!h.timeline||!h.timeline.currentTime||h.proxy.playState==="idle"||h.proxy.playState==="paused"&&h.holdTime!==null)return;const d=h.rangeDuration;let y,S;try{y=CSS.percent(100*(function(k){if(!k.animationRange)return 0;const z=k.animationRange.start==="normal"?Ro(k.timeline):k.animationRange.start;return xo(k.timeline,z)})(h))}catch(k){y=CSS.percent(0),h.animationRange.start="normal",console.warn("Exception when calculating start offset",k)}try{S=CSS.percent(100*(1-(function(k){if(!k.animationRange)return 0;const z=k.animationRange.end==="normal"?Ao(k.timeline):k.animationRange.end;return 1-xo(k.timeline,z)})(h)))}catch(k){S=CSS.percent(100),h.animationRange.end="normal",console.warn("Exception when calculating end offset",k)}h.rangeDuration=S.value-y.value;const M=xn(h);h.startTime=ge(h,M>=0?y:S),h.holdTime=null,h.rangeDuration!==d&&Eo(h)}function $i(h){throw new Error("Unsupported timeline class")}function Ro(h){return h instanceof ViewTimeline?{rangeName:"cover",offset:CSS.percent(0)}:h instanceof je?CSS.percent(0):void $i()}function Ao(h){return h instanceof ViewTimeline?{rangeName:"cover",offset:CSS.percent(100)}:h instanceof je?CSS.percent(100):void $i()}function el(h,d){if(!d)return{start:"normal",end:"normal"};const y={start:Ro(h),end:Ao(h)};if(h instanceof ViewTimeline){const S=He(d),M=[],k=[];if(S.forEach((z=>{if(Ji.includes(z))M.push(z);else try{k.push(CSSNumericValue.parse(z))}catch{throw TypeError(`Could not parse range "${d}"`)}})),M.length>2||k.length>2||k.length==1)throw TypeError("Invalid time range or unsupported time range format.");return M.length&&(y.start.rangeName=M[0],y.end.rangeName=M.length>1?M[1]:M[0]),k.length>1&&(y.start.offset=k[0],y.end.offset=k[1]),y}if(h instanceof je){const S=d.split(" ");if(S.length!=2)throw TypeError("Invalid time range or unsupported time range format.");return y.start=CSSNumericValue.parse(S[0]),y.end=CSSNumericValue.parse(S[1]),y}$i()}function Wi(h,d,y){if(!d||d==="normal")return"normal";if(h instanceof ViewTimeline){let S="cover",M=y==="start"?CSS.percent(0):CSS.percent(100);if(d instanceof Object)d.rangeName!==void 0&&(S=d.rangeName),d.offset!==void 0&&(M=d.offset);else{const k=He(d);k.length===1?Ji.includes(k[0])?S=k[0]:M=pe(CSSNumericValue.parse(k[0]),{}):k.length===2&&(S=k[0],M=pe(CSSNumericValue.parse(k[1]),{}))}if(!Ji.includes(S))throw TypeError("Invalid range name");return{rangeName:S,offset:M}}if(h instanceof je)return CSSNumericValue.parse(d);$i()}class Hi{constructor(d,y,S={}){const M=y instanceof je,k=d instanceof bo?d:new bo(d,M?void 0:y);ko.set(k,this),q.set(this,{animation:k,timeline:M?y:void 0,playState:M?"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:M?el(y,S["animation-range"]):null,proxy:this})}get effect(){const d=q.get(this);return d.timeline?(d.effect||(d.effect=(function(y){const S=y.animation.effect,M=S.updateTiming,k={apply:function(V){S.getTiming();const H=V.apply(S);if(y.timeline){const X=y.duration??100;H.localTime=tn(y,H.localTime),H.endTime=tn(y,H.endTime),H.activeDuration=tn(y,H.activeDuration);const Z=Ut(y),he=H.iterations?(Z-H.delay-H.endDelay)/H.iterations:0;H.duration=Z?CSS.percent(X*he/Z):CSS.percent(0),y.timeline.currentTime===void 0&&(H.localTime=null)}return H}},z={apply:function(V,H){if(y.specifiedTiming)return y.specifiedTiming;y.specifiedTiming=V.apply(S);let X,Z=Object.assign({},y.specifiedTiming);if(Z.duration===1/0)throw TypeError("Effect duration cannot be Infinity when used with Scroll Timelines");return(Z.duration===null||Z.duration==="auto"||y.autoDurationEffect)&&y.timeline&&(y.autoDurationEffect=!0,Z.delay=0,Z.endDelay=0,X=Z.iterations?1e5:0,Z.duration=Z.iterations?(X-Z.delay-Z.endDelay)/Z.iterations:0,Z.duration<0&&(Z.duration=0,Z.endDelay=X-Z.delay),M.apply(S,[Z])),y.normalizedTiming=Z,y.specifiedTiming}},F={apply:function(V,H,X){if(X&&X.length){if(y.timeline&&X[0]){const Z=X[0],he=Z.duration;if(he===1/0)throw TypeError("Effect duration cannot be Infinity when used with Scroll Timelines");if(Z.iterations===1/0)throw TypeError("Effect iterations cannot be Infinity when used with Scroll Timelines");he!==void 0&&he!=="auto"&&(y.autoDurationEffect=null)}y.specifiedTiming&&V.apply(S,[y.specifiedTiming]),V.apply(S,X),Eo(y)}}},U=new Proxy(S,{get:function(V,H){const X=V[H];return typeof X=="function"?X.bind(S):X},set:function(V,H,X){return V[H]=X,!0}});return U.getComputedTiming=new Proxy(S.getComputedTiming,k),U.getTiming=new Proxy(S.getTiming,z),U.updateTiming=new Proxy(S.updateTiming,F),U})(d)),d.effect):d.animation.effect}set effect(d){const y=q.get(this);y.animation.effect=d,y.effect=null,y.autoDurationEffect=null}get timeline(){const d=q.get(this);return d.timeline||d.animation.timeline}set timeline(d){const y=q.get(this),S=this.timeline;if(S==d)return;const M=this.playState,k=this.currentTime;let z,F=Ut(y);z=k===null?null:F===0?0:ge(y,k)/F;const U=S instanceof je,V=d instanceof je,H=this.pending;if(U&&Wr(y.timeline,y.animation),V)return y.timeline=d,wt(y),y.autoAlignStartTime=!0,y.startTime=null,y.holdTime=null,M!=="running"&&M!=="finished"||(y.readyPromise&&y.readyPromise.state!=="resolved"||Fn(y),y.pendingTask="play",Hr(y.timeline,y.animation,Qr.bind(this))),M==="paused"&&z!==null&&(y.holdTime=z*F),H&&(y.readyPromise&&y.readyPromise.state!="resolved"||Fn(y),y.pendingTask=M=="paused"?"pause":"play"),y.startTime!==null&&(y.holdTime=null),void Nt(y,!1,!1);if(y.animation.timeline!=d)throw TypeError("Unsupported timeline: "+d);if(Wr(y.timeline,y.animation),y.timeline=null,U)switch(k!==null&&(y.animation.currentTime=z*Ut(y)),M){case"paused":y.animation.pause();break;case"running":case"finished":y.animation.play()}}get startTime(){const d=q.get(this);return d.timeline?tn(d,d.startTime):d.animation.startTime}set startTime(d){const y=q.get(this);if(d=ge(y,d),!y.timeline)return void(y.animation.startTime=d);y.autoAlignStartTime=!1,ge(y,y.timeline.currentTime)==null&&y.startTime!=null&&(y.holdTime=null,Dt(y));const S=ge(y,this.currentTime);wt(y),y.startTime=d,y.startTime!==null&&y.animation.playbackRate!=0?y.holdTime=null:y.holdTime=S,y.pendingTask&&(y.pendingTask=null,y.readyPromise.resolve(this)),Nt(y,!0,!1),Dt(y)}get currentTime(){const d=q.get(this);return d.timeline?d.holdTime!=null?tn(d,d.holdTime):tn(d,Po(d)):d.animation.currentTime}set currentTime(d){const y=q.get(this);y.timeline?((function(S,M){if(M==null&&S.currentTime!==null)throw new TypeError;M=ge(S,M),S.autoAlignStartTime=!1,S.holdTime!==null||S.startTime===null||S.timeline.phase==="inactive"||S.animation.playbackRate===0?S.holdTime=M:S.startTime=ge(S,S.timeline.currentTime)-M/S.animation.playbackRate,S.timeline.phase==="inactive"&&(S.startTime=null),S.previousCurrentTime=null})(y,d),y.pendingTask=="pause"&&(y.holdTime=ge(y,d),wt(y),y.startTime=null,y.pendingTask=null,y.readyPromise.resolve(this)),Nt(y,!0,!1)):y.animation.currentTime=d}get playbackRate(){return q.get(this).animation.playbackRate}set playbackRate(d){const y=q.get(this);if(!y.timeline)return void(y.animation.playbackRate=d);y.pendingPlaybackRate=null;const S=this.currentTime;y.animation.playbackRate=d,S!==null&&(this.currentTime=S)}get playState(){const d=q.get(this);if(!d.timeline)return d.animation.playState;const y=ge(d,this.currentTime);return y===null&&d.startTime===null&&d.pendingTask==null?"idle":d.pendingTask=="pause"||d.startTime===null&&d.pendingTask!="play"?"paused":y!=null&&(d.animation.playbackRate>0&&y>=Ut(d)||d.animation.playbackRate<0&&y<=0)?"finished":"running"}get rangeStart(){var d;return((d=q.get(this).animationRange)==null?void 0:d.start)??"normal"}set rangeStart(d){const y=q.get(this);if(!y.timeline)return y.animation.rangeStart=d;y.timeline instanceof je&&(y.animationRange.start=Wi(y.timeline,d,"start"),Gi(y),Dt(y))}get rangeEnd(){var d;return((d=q.get(this).animationRange)==null?void 0:d.end)??"normal"}set rangeEnd(d){const y=q.get(this);if(!y.timeline)return y.animation.rangeEnd=d;y.timeline instanceof je&&(y.animationRange.end=Wi(y.timeline,d,"end"),Gi(y),Dt(y))}get replaceState(){return q.get(this).animation.pending}get pending(){const d=q.get(this);return d.timeline?!!d.readyPromise&&d.readyPromise.state=="pending":d.animation.pending}finish(){const d=q.get(this);if(!d.timeline)return void d.animation.finish();const y=xn(d),S=Ut(d);if(y==0)throw new DOMException("Cannot finish Animation with a playbackRate of 0.","InvalidStateError");if(y>0&&S==1/0)throw new DOMException("Cannot finish Animation with an infinite target effect end.","InvalidStateError");wt(d);const M=y<0?0:S;this.currentTime=tn(d,M);const k=ge(d,d.timeline.currentTime);d.startTime===null&&k!==null&&(d.startTime=k-M/d.animation.playbackRate),d.pendingTask=="pause"&&d.startTime!==null&&(d.holdTime=null,d.pendingTask=null,d.readyPromise.resolve(this)),d.pendingTask=="play"&&d.startTime!==null&&(d.pendingTask=null,d.readyPromise.resolve(this)),Nt(d,!0,!0)}play(){const d=q.get(this);d.timeline?Kr(d):d.animation.play()}pause(){const d=q.get(this);d.timeline?this.playState!="paused"&&(d.animation.currentTime===null&&(d.autoAlignStartTime=!0),d.pendingTask=="play"?d.pendingTask=null:d.readyPromise=null,d.readyPromise||Fn(d),d.pendingTask="pause",Hr(d.timeline,d.animation,Qr.bind(d.proxy))):d.animation.pause()}reverse(){const d=q.get(this),y=xn(d),S=ge(d,this.currentTime),M=Ut(d)==1/0,k=y!=0&&(y<0||S>0||!M);if(!d.timeline||!k)return k&&(d.pendingPlaybackRate=-xn(d)),void d.animation.reverse();if(d.timeline.phase=="inactive")throw new DOMException("Cannot reverse an animation with no active timeline","InvalidStateError");this.updatePlaybackRate(-y),Kr(d)}updatePlaybackRate(d){const y=q.get(this);if(y.pendingPlaybackRate=d,!y.timeline)return void y.animation.updatePlaybackRate(d);const S=this.playState;if(!y.readyPromise||y.readyPromise.state!="pending")switch(S){case"idle":case"paused":wt(y);break;case"finished":const M=ge(y,y.timeline.currentTime),k=M!==null?(M-y.startTime)*y.animation.playbackRate:null;y.startTime=d==0?M:M!=null&&k!=null?(M-k)/d:null,wt(y),Nt(y,!1,!1),Dt(y);break;default:Kr(y)}}persist(){q.get(this).animation.persist()}get id(){return q.get(this).animation.id}set id(d){q.get(this).animation.id=d}cancel(){const d=q.get(this);d.timeline?(this.playState!="idle"&&((function(y){y.pendingTask&&(y.pendingTask=null,wt(y),y.readyPromise.reject(To()),Fn(y),y.readyPromise.resolve(y.proxy))})(d),d.finishedPromise&&d.finishedPromise.state=="pending"&&d.finishedPromise.reject(To()),d.finishedPromise=new Sn,d.animation.cancel()),d.startTime=null,d.holdTime=null,Wr(d.timeline,d.animation)):d.animation.cancel()}get onfinish(){return q.get(this).animation.onfinish}set onfinish(d){q.get(this).animation.onfinish=d}get oncancel(){return q.get(this).animation.oncancel}set oncancel(d){q.get(this).animation.oncancel=d}get onremove(){return q.get(this).animation.onremove}set onremove(d){q.get(this).animation.onremove=d}get finished(){const d=q.get(this);return d.timeline?(d.finishedPromise||(d.finishedPromise=new Sn),d.finishedPromise.promise):d.animation.finished}get ready(){const d=q.get(this);return d.timeline?(d.readyPromise||(d.readyPromise=new Sn,d.readyPromise.resolve(this)),d.readyPromise.promise):d.animation.ready}addEventListener(d,y,S){q.get(this).animation.addEventListener(d,y,S)}removeEventListener(d,y,S){q.get(this).animation.removeEventListener(d,y,S)}dispatchEvent(d){q.get(this).animation.dispatchEvent(d)}}function tl(h,d){const y=d.timeline;y instanceof je&&delete d.timeline;const S=Qc.apply(this,[h,d]),M=new Hi(S,y);return y instanceof je&&(S.pause(),q.get(M).animationRange={start:Wi(y,d.rangeStart,"start"),end:Wi(y,d.rangeEnd,"end")},M.play()),M}function Oo(h){for(let d=0;d<h.length;++d){let y=ko.get(h[d]);y&&(h[d]=y)}return h}function nl(h){return Oo(Kc.apply(this,[h]))}function il(h){return Oo(Zc.apply(this,[h]))}const Ee={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\(([^)]*)\)/},_n=["block","inline","x","y"],rl=["nearest","root","self"],$t=new class{constructor(){this.cssRulesWithTimelineName=[],this.nextAnonymousTimelineNameIndex=0,this.anonymousScrollTimelineOptions=new Map,this.anonymousViewTimelineOptions=new Map,this.sourceSelectorToScrollTimeline=[],this.subjectSelectorToViewTimeline=[],this.keyframeNamesSelectors=new Map}transpileStyleSheet(h,d,y){const S={sheetSrc:h,index:0,name:y};for(;S.index<S.sheetSrc.length&&(this.eatWhitespace(S),!(S.index>=S.sheetSrc.length));){if(this.lookAhead("/*",S)){for(;this.lookAhead("/*",S);)this.eatComment(S),this.eatWhitespace(S);continue}const M=this.parseQualifiedRule(S);M&&(d?this.parseKeyframesAndSaveNameMapping(M,S):this.handleScrollTimelineProps(M,S))}return S.sheetSrc}getAnimationTimelineOptions(h,d){for(let y=this.cssRulesWithTimelineName.length-1;y>=0;y--){const S=this.cssRulesWithTimelineName[y];try{if(d.matches(S.selector)&&(!S["animation-name"]||S["animation-name"]==h))return{"animation-timeline":S["animation-timeline"],"animation-range":S["animation-range"]}}catch{}}return null}getAnonymousScrollTimelineOptions(h,d){const y=this.anonymousScrollTimelineOptions.get(h);return y?{anonymousSource:y.source,anonymousTarget:d,source:vo(y.source??"nearest",d),axis:y.axis?y.axis:"block"}:null}getScrollTimelineOptions(h,d){const y=this.getAnonymousScrollTimelineOptions(h,d);if(y)return y;for(let S=this.sourceSelectorToScrollTimeline.length-1;S>=0;S--){const M=this.sourceSelectorToScrollTimeline[S];if(M.name==h){const k=this.findPreviousSiblingOrAncestorMatchingSelector(d,M.selector);if(k)return{source:k,...M.axis?{axis:M.axis}:{}}}}return null}findPreviousSiblingOrAncestorMatchingSelector(h,d){let y=h;for(;y;){if(y.matches(d))return y;y=y.previousElementSibling||y.parentElement}return null}getAnonymousViewTimelineOptions(h,d){const y=this.anonymousViewTimelineOptions.get(h);return y?{subject:d,axis:y.axis?y.axis:"block",inset:y.inset?y.inset:"auto"}:null}getViewTimelineOptions(h,d){const y=this.getAnonymousViewTimelineOptions(h,d);if(y)return y;for(let S=this.subjectSelectorToViewTimeline.length-1;S>=0;S--){const M=this.subjectSelectorToViewTimeline[S];if(M.name==h){const k=this.findPreviousSiblingOrAncestorMatchingSelector(d,M.selector);if(k)return{subject:k,axis:M.axis,inset:M.inset}}}return null}handleScrollTimelineProps(h,d){if(h.selector.includes("@keyframes"))return;const y=h.block.contents.includes("animation-name:"),S=h.block.contents.includes("animation-timeline:"),M=h.block.contents.includes("animation:");if(this.saveSourceSelectorToScrollTimeline(h),this.saveSubjectSelectorToViewTimeline(h),!S&&!y&&!M)return;let k=[],z=[],F=!1;S&&(k=this.extractScrollTimelineNames(h.block.contents)),y&&(z=this.extractMatches(h.block.contents,Ee.ANIMATION_NAME)),S&&y||(M&&this.extractMatches(h.block.contents,Ee.ANIMATION).forEach((U=>{const V=this.extractAnimationName(U);V&&S&&z.push(V),S&&(this.hasDuration(U)||(this.hasAutoDuration(U)&&(h.block.contents=h.block.contents.replace("auto"," ")),h.block.contents=h.block.contents.replace(U," 1s "+U),F=!0))})),F&&this.replacePart(h.block.startIndex,h.block.endIndex,h.block.contents,d)),this.saveRelationInList(h,k,z)}saveSourceSelectorToScrollTimeline(h){const d=h.block.contents.includes("scroll-timeline:"),y=h.block.contents.includes("scroll-timeline-name:"),S=h.block.contents.includes("scroll-timeline-axis:");if(!d&&!y)return;let M=[];if(d){const z=this.extractMatches(h.block.contents,Ee.SCROLL_TIMELINE);for(const F of z){const U=this.split(F);let V={selector:h.selector,name:""};U.length==1?V.name=U[0]:U.length==2&&(_n.includes(U[0])?(V.axis=U[0],V.name=U[1]):(V.axis=U[1],V.name=U[0])),M.push(V)}}if(y){const z=this.extractMatches(h.block.contents,Ee.SCROLL_TIMELINE_NAME);for(let F=0;F<z.length;F++)if(F<M.length)M[F].name=z[F];else{let U={selector:h.selector,name:z[F]};M.push(U)}}let k=[];if(S){const z=this.extractMatches(h.block.contents,Ee.SCROLL_TIMELINE_AXIS);if(k=z.filter((F=>_n.includes(F))),k.length!=z.length)throw new Error("Invalid axis")}for(let z=0;z<M.length;z++)k.length&&(M[z].axis=k[z%M.length]);this.sourceSelectorToScrollTimeline.push(...M)}saveSubjectSelectorToViewTimeline(h){const d=h.block.contents.includes("view-timeline:"),y=h.block.contents.includes("view-timeline-name:"),S=h.block.contents.includes("view-timeline-axis:"),M=h.block.contents.includes("view-timeline-inset:");if(!d&&!y)return;let k=[];if(d){const U=this.extractMatches(h.block.contents,Ee.VIEW_TIMELINE);for(let V of U){const H=this.split(V);let X={selector:h.selector,name:"",inset:null};H.length==1?X.name=H[0]:H.length==2&&(_n.includes(H[0])?(X.axis=H[0],X.name=H[1]):(X.axis=H[1],X.name=H[0])),k.push(X)}}if(y){const U=this.extractMatches(h.block.contents,Ee.VIEW_TIMELINE_NAME);for(let V=0;V<U.length;V++)if(V<k.length)k[V].name=U[V];else{let H={selector:h.selector,name:U[V],inset:null};k.push(H)}}let z=[],F=[];if(M&&(z=this.extractMatches(h.block.contents,Ee.VIEW_TIMELINE_INSET)),S){const U=this.extractMatches(h.block.contents,Ee.VIEW_TIMELINE_AXIS);if(F=U.filter((V=>_n.includes(V))),F.length!=U.length)throw new Error("Invalid axis")}for(let U=0;U<k.length;U++)z.length&&(k[U].inset=z[U%k.length]),F.length&&(k[U].axis=F[U%k.length]);this.subjectSelectorToViewTimeline.push(...k)}hasDuration(h){return h.split(" ").filter((d=>{return y=d,Ee.TIME.exec(y);var y})).length>=1}hasAutoDuration(h){return h.split(" ").filter((d=>d==="auto")).length>=1}saveRelationInList(h,d,y){let S=[];h.block.contents.includes("animation-range:")&&(S=this.extractMatches(h.block.contents,Ee.ANIMATION_TIME_RANGE));const M=Math.max(d.length,y.length,S.length);for(let k=0;k<M;k++)this.cssRulesWithTimelineName.push({selector:h.selector,"animation-timeline":d[k%d.length],...y.length?{"animation-name":y[k%y.length]}:{},...S.length?{"animation-range":S[k%S.length]}:{}})}extractScrollTimelineNames(h){const d=Ee.ANIMATION_TIMELINE.exec(h)[1].trim(),y=[];return d.split(",").map((S=>S.trim())).forEach((S=>{if((function(M){return(M.startsWith("scroll")||M.startsWith("view"))&&M.includes("(")})(S)){const M=this.saveAnonymousTimelineName(S);y.push(M)}else y.push(S)})),y}saveAnonymousTimelineName(h){const d=":t"+this.nextAnonymousTimelineNameIndex++;return h.startsWith("scroll(")?this.anonymousScrollTimelineOptions.set(d,this.parseAnonymousScrollTimeline(h)):this.anonymousViewTimelineOptions.set(d,this.parseAnonymousViewTimeline(h)),d}parseAnonymousScrollTimeline(h){const d=Ee.ANONYMOUS_SCROLL_TIMELINE.exec(h);if(!d)return null;const y=d[1],S={};return y.split(" ").forEach((M=>{_n.includes(M)?S.axis=M:rl.includes(M)&&(S.source=M)})),S}parseAnonymousViewTimeline(h){const d=Ee.ANONYMOUS_VIEW_TIMELINE.exec(h);if(!d)return null;const y=d[1],S={};return y.split(" ").forEach((M=>{_n.includes(M)?S.axis=M:S.inset=S.inset?`${S.inset} ${M}`:M})),S}extractAnimationName(h){return this.findMatchingEntryInContainer(h,this.keyframeNamesSelectors)}findMatchingEntryInContainer(h,d){const y=h.split(" ").filter((S=>d.has(S)));return y?y[0]:null}parseIdentifier(h){Ee.IDENTIFIER.lastIndex=h.index;const d=Ee.IDENTIFIER.exec(h.sheetSrc);if(!d)throw this.parseError(h,"Expected an identifier");return h.index+=d[0].length,d[0]}parseKeyframesAndSaveNameMapping(h,d){if(h.selector.startsWith("@keyframes")){const y=this.replaceKeyframesAndGetMapping(h,d);h.selector.split(" ").forEach(((S,M)=>{M>0&&this.keyframeNamesSelectors.set(S,y)}))}}replaceKeyframesAndGetMapping(h,d){function y(U){return Ji.some((V=>U.startsWith(V)))}const S=h.block.contents,M=(function(U){let V=0,H=-1,X=-1;const Z=[];for(let he=0;he<U.length;he++)U[he]=="{"?V++:U[he]=="}"&&V--,V==1&&U[he]!="{"&&U[he]!="}"&&H==-1&&(H=he),V==2&&U[he]=="{"&&(X=he,Z.push({start:H,end:X}),H=X=-1);return Z})(S);if(M.length==0)return new Map;const k=new Map;let z=!1;const F=[];F.push(S.substring(0,M[0].start));for(let U=0;U<M.length;U++){const V=S.substring(M[U].start,M[U].end);let H=[];V.split(",").forEach((X=>{const Z=X.split(" ").map((_e=>_e.trim())).filter((_e=>_e!="")).join(" "),he=k.size;k.set(he,Z),H.push(`${he}%`),y(Z)&&(z=!0)})),F.push(H.join(",")),U==M.length-1?F.push(S.substring(M[U].end)):F.push(S.substring(M[U].end,M[U+1].start))}return z?(h.block.contents=F.join(""),this.replacePart(h.block.startIndex,h.block.endIndex,h.block.contents,d),k):new Map}parseQualifiedRule(h){const d=h.index,y=this.parseSelector(h).trim();if(y)return{selector:y,block:this.eatBlock(h),startIndex:d,endIndex:h.index}}removeEnclosingDoubleQuotes(h){let d=h[0]=='"'?1:0,y=h[h.length-1]=='"'?h.length-1:h.length;return h.substring(d,y)}assertString(h,d){if(h.sheetSrc.substr(h.index,d.length)!=d)throw this.parseError(h,`Did not find expected sequence ${d}`);h.index+=d.length}replacePart(h,d,y,S){if(S.sheetSrc=S.sheetSrc.slice(0,h)+y+S.sheetSrc.slice(d),S.index>=d){const M=S.index-d;S.index=h+y.length+M}}eatComment(h){this.assertString(h,"/*"),this.eatUntil("*/",h,!0),this.assertString(h,"*/")}eatBlock(h){const d=h.index;this.assertString(h,"{");let y=1;for(;y!=0;)this.lookAhead("/*",h)?this.eatComment(h):(h.sheetSrc[h.index]==="{"?y++:h.sheetSrc[h.index]==="}"&&y--,this.advance(h));const S=h.index;return{startIndex:d,endIndex:S,contents:h.sheetSrc.slice(d,S)}}advance(h){if(h.index++,h.index>h.sheetSrc.length)throw this.parseError(h,"Advanced beyond the end")}parseError(h,d){return Error(`(${h.name?h.name:"<anonymous file>"}): ${d}`)}eatUntil(h,d,y=!1){const S=d.index;for(;!this.lookAhead(h,d);)this.advance(d);return y&&(d.sheetSrc=d.sheetSrc.slice(0,S)+" ".repeat(d.index-S)+d.sheetSrc.slice(d.index)),d.sheetSrc.slice(S,d.index)}parseSelector(h){let d=h.index;if(this.eatUntil("{",h),d===h.index)throw Error("Empty selector");return h.sheetSrc.slice(d,h.index)}eatWhitespace(h){Ee.WHITE_SPACE.lastIndex=h.index;const d=Ee.WHITE_SPACE.exec(h.sheetSrc);d&&(h.index+=d[0].length)}lookAhead(h,d){return d.sheetSrc.substr(d.index,h.length)==h}peek(h){return h.sheetSrc[h.index]}extractMatches(h,d,y=","){return d.exec(h)[1].trim().split(y).map((S=>S.trim()))}split(h){return h.split(" ").map((d=>d.trim())).filter((d=>d!=""))}};function sl(h,d,y,S,M,k){const z=Gr(d),F=$r(d,y);return _o(Yr(h,z,F,S,M),k,Yr("cover",z,F,S,M),y)}function ol(h,d,y){const S=$t.getAnimationTimelineOptions(d,y);if(!S)return null;const M=S["animation-timeline"];if(!M)return null;let k=$t.getScrollTimelineOptions(M,y)||$t.getViewTimelineOptions(M,y);return k?(k.subject&&(function(z,F){const U=Xr(F.subject),V=F.axis||F.axis;function H(Z,he){let _e=null;for(const[Ye,_t]of Z)if(Ye==100*he.offset){if(_t=="from")_e=0;else if(_t=="to")_e=100;else{const ct=_t.split(" ");_e=ct.length==1?parseFloat(ct[0]):100*sl(ct[0],U,F.subject,V,F.inset,CSS.percent(parseFloat(ct[1])))}break}return _e}const X=$t.keyframeNamesSelectors.get(z.animationName);if(X&&X.size){const Z=[];z.effect.getKeyframes().forEach((_e=>{const Ye=H(X,_e);Ye!==null&&Ye>=0&&Ye<=100&&(_e.offset=Ye/100,Z.push(_e))}));const he=Z.sort(((_e,Ye)=>_e.offset<Ye.offset?-1:_e.affset>Ye.offset?1:0));z.effect.setKeyframes(he)}})(h,k),{timeline:k.source?new je(k):new vn(k),animOptions:S}):null}function al(){if(CSS.supports("animation-timeline: --works"))return!0;(function(){function d(S){if(S.innerHTML.trim().length===0||"aphrodite"in S.dataset)return;let M=$t.transpileStyleSheet(S.innerHTML,!0);M=$t.transpileStyleSheet(M,!1),S.innerHTML=M}function y(S){S.type!="text/css"&&S.rel!="stylesheet"||!S.href||new URL(S.href,document.baseURI).origin==location.origin&&fetch(S.getAttribute("href")).then((async M=>{const k=await M.text();let z=$t.transpileStyleSheet(k,!0);if(z=$t.transpileStyleSheet(k,!1),z!=k){const F=new Blob([z],{type:"text/css"}),U=URL.createObjectURL(F);S.setAttribute("href",U)}}))}new MutationObserver((S=>{for(const M of S)for(const k of M.addedNodes)k instanceof HTMLStyleElement&&d(k),k instanceof HTMLLinkElement&&y(k)})).observe(document.documentElement,{childList:!0,subtree:!0}),document.querySelectorAll("style").forEach((S=>d(S))),document.querySelectorAll("link").forEach((S=>y(S)))})();const h=CSS.supports;CSS.supports=d=>(d=d.replaceAll(/(animation-timeline|scroll-timeline(-(name|axis))?|view-timeline(-(name|axis|inset))?|timeline-scope)\s*:/g,"--supported-property:"),h(d)),window.addEventListener("animationstart",(d=>{d.target.getAnimations().filter((y=>y.animationName===d.animationName)).forEach((y=>{const S=ol(y,y.animationName,d.target);if(S)if(!S.timeline||y instanceof Hi)y.timeline=S.timeline;else{const M=new Hi(y,S.timeline,S.animOptions);y.pause(),M.play()}}))}))}(function(){if(!al()){if(!Reflect.defineProperty(window,"ScrollTimeline",{value:je}))throw Error("Error installing ScrollTimeline polyfill: could not attach ScrollTimeline to window");if(!Reflect.defineProperty(window,"ViewTimeline",{value:vn}))throw Error("Error installing ViewTimeline polyfill: could not attach ViewTimeline to window");if(!Reflect.defineProperty(Element.prototype,"animate",{value:tl}))throw Error("Error installing ScrollTimeline polyfill: could not attach WAAPI's animate to DOM Element");if(!Reflect.defineProperty(window,"Animation",{value:Hi}))throw Error("Error installing Animation constructor.");if(!Reflect.defineProperty(Element.prototype,"getAnimations",{value:nl}))throw Error("Error installing ScrollTimeline polyfill: could not attach WAAPI's getAnimations to DOM Element");if(!Reflect.defineProperty(document,"getAnimations",{value:il}))throw Error("Error installing ScrollTimeline polyfill: could not attach WAAPI's getAnimations to document")}})()})();class wh{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 re;(function(r){r.open="open",r.close="close",r.error="error",r.message="message",r.retry="retry",r.reconnect="reconnect"})(re||(re={}));class Dc{constructor(e,t,n){var i,s,a,o,c,l,u,f,p,m,x,T,g,v,b;this._closedByUser=!1,this.handleOpenEvent=_=>this.handleEvent(re.open,_),this.handleErrorEvent=_=>this.handleEvent(re.error,_),this.handleCloseEvent=_=>this.handleEvent(re.close,_),this.handleMessageEvent=_=>this.handleEvent(re.message,_),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:[...(p=(f=n?.listeners)===null||f===void 0?void 0:f.error)!==null&&p!==void 0?p:[]],message:[...(x=(m=n?.listeners)===null||m===void 0?void 0:m.message)!==null&&x!==void 0?x:[]],retry:[...(g=(T=n?.listeners)===null||T===void 0?void 0:T.retry)!==null&&g!==void 0?g:[]],reconnect:[...(b=(v=n?.listeners)===null||v===void 0?void 0:v.reconnect)!==null&&b!==void 0?b:[]]}},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(re.open,this.handleOpenEvent),this._underlyingWebsocket.addEventListener(re.close,this.handleCloseEvent),this._underlyingWebsocket.addEventListener(re.error,this.handleErrorEvent),this._underlyingWebsocket.addEventListener(re.message,this.handleMessageEvent),this._underlyingWebsocket}clearWebsocket(){this._underlyingWebsocket.removeEventListener(re.open,this.handleOpenEvent),this._underlyingWebsocket.removeEventListener(re.close,this.handleCloseEvent),this._underlyingWebsocket.removeEventListener(re.error,this.handleErrorEvent),this._underlyingWebsocket.removeEventListener(re.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 re.close:this.dispatchEvent(e,t),this.scheduleConnectionRetryIfNeeded();break;case re.open:if(this.backoff!==void 0&&this._lastConnection!==void 0){const n={retries:this.backoff.retries,lastConnection:new Date(this._lastConnection)},i=new CustomEvent(re.reconnect,{detail:n});this.dispatchEvent(re.reconnect,i),this.backoff.reset()}this._lastConnection=new Date,this.dispatchEvent(e,t),this.sendBufferedData();break;case re.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(re.retry,{detail:n});this.handleEvent(re.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 Ph{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(re.open,e,t),this}onClose(e,t){return this.addListener(re.close,e,t),this}onError(e,t){return this.addListener(re.error,e,t),this}onMessage(e,t){return this.addListener(re.message,e,t),this}onRetry(e,t){return this.addListener(re.retry,e,t),this}onReconnect(e,t){return this.addListener(re.reconnect,e,t),this}build(){return new Dc(this._url,this._protocols,this._options)}addListener(e,t,n){var i,s,a,o,c,l,u,f,p,m,x,T,g,v,b,_,w,C,P,E,I;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:(p=(f=(u=this._options)===null||u===void 0?void 0:u.listeners)===null||f===void 0?void 0:f.error)!==null&&p!==void 0?p:[],message:(T=(x=(m=this._options)===null||m===void 0?void 0:m.listeners)===null||x===void 0?void 0:x.message)!==null&&T!==void 0?T:[],retry:(b=(v=(g=this._options)===null||g===void 0?void 0:g.listeners)===null||v===void 0?void 0:v.retry)!==null&&b!==void 0?b:[],reconnect:(C=(w=(_=this._options)===null||_===void 0?void 0:_.listeners)===null||w===void 0?void 0:w.reconnect)!==null&&C!==void 0?C:[],[e]:[...(I=(E=(P=this._options)===null||P===void 0?void 0:P.listeners)===null||E===void 0?void 0:E[e])!==null&&I!==void 0?I:[],{listener:t,options:n}]}}),this}}const Eh=Object.freeze(Object.defineProperty({__proto__:null,ExponentialBackoff:wh,Websocket:Dc,WebsocketBuilder:Ph,get WebsocketEvent(){return re}},Symbol.toStringTag,{value:"Module"})),uo=0,Fc=1,Lc=2,$s=2,xs=1.25,_a=1,ii=32,Lr=65535,kh=Math.pow(2,-24),_s=Symbol("SKIP_GENERATION");function Rh(r){return r.index?r.index.count:r.attributes.position.count}function Un(r){return Rh(r)/3}function Ah(r,e=ArrayBuffer){return r>65535?new Uint32Array(new e(4*r)):new Uint16Array(new e(2*r))}function Oh(r,e){if(!r.index){const t=r.attributes.position.count,n=e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,i=Ah(t,n);r.setIndex(new R.BufferAttribute(i,1));for(let s=0;s<t;s++)i[s]=s}}function Vc(r,e){const t=Un(r),n=e||r.drawRange,i=n.start/3,s=(n.start+n.count)/3,a=Math.max(0,i),o=Math.min(t,s)-a;return[{offset:Math.floor(a),count:Math.floor(o)}]}function Jc(r,e){if(!r.groups||!r.groups.length)return Vc(r,e);const t=[],n=new Set,i=e||r.drawRange,s=i.start/3,a=(i.start+i.count)/3;for(const c of r.groups){const l=c.start/3,u=(c.start+c.count)/3;n.add(Math.max(s,l)),n.add(Math.min(a,u))}const o=Array.from(n.values()).sort((c,l)=>c-l);for(let c=0;c<o.length-1;c++){const l=o[c],u=o[c+1];t.push({offset:Math.floor(l),count:Math.floor(u-l)})}return t}function zh(r,e){const t=Un(r),n=Jc(r,e).sort((a,o)=>a.offset-o.offset),i=n[n.length-1];i.count=Math.min(t-i.offset,i.count);let s=0;return n.forEach(({count:a})=>s+=a),t!==s}function bs(r,e,t,n,i){let s=1/0,a=1/0,o=1/0,c=-1/0,l=-1/0,u=-1/0,f=1/0,p=1/0,m=1/0,x=-1/0,T=-1/0,g=-1/0;for(let v=e*6,b=(e+t)*6;v<b;v+=6){const _=r[v+0],w=r[v+1],C=_-w,P=_+w;C<s&&(s=C),P>c&&(c=P),_<f&&(f=_),_>x&&(x=_);const E=r[v+2],I=r[v+3],O=E-I,A=E+I;O<a&&(a=O),A>l&&(l=A),E<p&&(p=E),E>T&&(T=E);const N=r[v+4],B=r[v+5],D=N-B,L=N+B;D<o&&(o=D),L>u&&(u=L),N<m&&(m=N),N>g&&(g=N)}n[0]=s,n[1]=a,n[2]=o,n[3]=c,n[4]=l,n[5]=u,i[0]=f,i[1]=p,i[2]=m,i[3]=x,i[4]=T,i[5]=g}function Ih(r,e=null,t=null,n=null){const i=r.attributes.position,s=r.index?r.index.array:null,a=Un(r),o=i.normalized;let c;e===null?(c=new Float32Array(a*6),t=0,n=a):(c=e,t=t||0,n=n||a);const l=i.array,u=i.offset||0;let f=3;i.isInterleavedBufferAttribute&&(f=i.data.stride);const p=["getX","getY","getZ"];for(let m=t;m<t+n;m++){const x=m*3,T=m*6;let g=x+0,v=x+1,b=x+2;s&&(g=s[g],v=s[v],b=s[b]),o||(g=g*f+u,v=v*f+u,b=b*f+u);for(let _=0;_<3;_++){let w,C,P;o?(w=i[p[_]](g),C=i[p[_]](v),P=i[p[_]](b)):(w=l[g+_],C=l[v+_],P=l[b+_]);let E=w;C<E&&(E=C),P<E&&(E=P);let I=w;C>I&&(I=C),P>I&&(I=P);const O=(I-E)/2,A=_*2;c[T+A+0]=E+O,c[T+A+1]=O+(Math.abs(E)+O)*kh}}return c}function ve(r,e,t){return t.min.x=e[r],t.min.y=e[r+1],t.min.z=e[r+2],t.max.x=e[r+3],t.max.y=e[r+4],t.max.z=e[r+5],t}function ba(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 Ta(r,e){e.set(r)}function Ma(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 rr(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 jn(r){const e=r[3]-r[0],t=r[4]-r[1],n=r[5]-r[2];return 2*(e*t+t*n+n*e)}const Ft=32,Bh=(r,e)=>r.candidate-e.candidate,qt=new Array(Ft).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),sr=new Float32Array(6);function Nh(r,e,t,n,i,s){let a=-1,o=0;if(s===uo)a=ba(e),a!==-1&&(o=(e[a]+e[a+3])/2);else if(s===Fc)a=ba(r),a!==-1&&(o=Uh(t,n,i,a));else if(s===Lc){const c=jn(r);let l=xs*i;const u=n*6,f=(n+i)*6;for(let p=0;p<3;p++){const m=e[p],g=(e[p+3]-m)/Ft;if(i<Ft/4){const v=[...qt];v.length=i;let b=0;for(let w=u;w<f;w+=6,b++){const C=v[b];C.candidate=t[w+2*p],C.count=0;const{bounds:P,leftCacheBounds:E,rightCacheBounds:I}=C;for(let O=0;O<3;O++)I[O]=1/0,I[O+3]=-1/0,E[O]=1/0,E[O+3]=-1/0,P[O]=1/0,P[O+3]=-1/0;rr(w,t,P)}v.sort(Bh);let _=i;for(let w=0;w<_;w++){const C=v[w];for(;w+1<_&&v[w+1].candidate===C.candidate;)v.splice(w+1,1),_--}for(let w=u;w<f;w+=6){const C=t[w+2*p];for(let P=0;P<_;P++){const E=v[P];C>=E.candidate?rr(w,t,E.rightCacheBounds):(rr(w,t,E.leftCacheBounds),E.count++)}}for(let w=0;w<_;w++){const C=v[w],P=C.count,E=i-C.count,I=C.leftCacheBounds,O=C.rightCacheBounds;let A=0;P!==0&&(A=jn(I)/c);let N=0;E!==0&&(N=jn(O)/c);const B=_a+xs*(A*P+N*E);B<l&&(a=p,l=B,o=C.candidate)}}else{for(let _=0;_<Ft;_++){const w=qt[_];w.count=0,w.candidate=m+g+_*g;const C=w.bounds;for(let P=0;P<3;P++)C[P]=1/0,C[P+3]=-1/0}for(let _=u;_<f;_+=6){let P=~~((t[_+2*p]-m)/g);P>=Ft&&(P=Ft-1);const E=qt[P];E.count++,rr(_,t,E.bounds)}const v=qt[Ft-1];Ta(v.bounds,v.rightCacheBounds);for(let _=Ft-2;_>=0;_--){const w=qt[_],C=qt[_+1];Ma(w.bounds,C.rightCacheBounds,w.rightCacheBounds)}let b=0;for(let _=0;_<Ft-1;_++){const w=qt[_],C=w.count,P=w.bounds,I=qt[_+1].rightCacheBounds;C!==0&&(b===0?Ta(P,sr):Ma(P,sr,sr)),b+=C;let O=0,A=0;b!==0&&(O=jn(sr)/c);const N=i-b;N!==0&&(A=jn(I)/c);const B=_a+xs*(O*b+A*N);B<l&&(a=p,l=B,o=w.candidate)}}}}else console.warn(`MeshBVH: Invalid build strategy value ${s} used.`);return{axis:a,pos:o}}function Uh(r,e,t,n){let i=0;for(let s=e,a=e+t;s<a;s++)i+=r[s*6+n*2];return i/t}class Ts{constructor(){this.boundingData=new Float32Array(6)}}function Dh(r,e,t,n,i,s){let a=n,o=n+i-1;const c=s.pos,l=s.axis*2;for(;;){for(;a<=o&&t[a*6+l]<c;)a++;for(;a<=o&&t[o*6+l]>=c;)o--;if(a<o){for(let u=0;u<3;u++){let f=e[a*3+u];e[a*3+u]=e[o*3+u],e[o*3+u]=f}for(let u=0;u<6;u++){let f=t[a*6+u];t[a*6+u]=t[o*6+u],t[o*6+u]=f}a++,o--}else return a}}function Fh(r,e,t,n,i,s){let a=n,o=n+i-1;const c=s.pos,l=s.axis*2;for(;;){for(;a<=o&&t[a*6+l]<c;)a++;for(;a<=o&&t[o*6+l]>=c;)o--;if(a<o){let u=r[a];r[a]=r[o],r[o]=u;for(let f=0;f<6;f++){let p=t[a*6+f];t[a*6+f]=t[o*6+f],t[o*6+f]=p}a++,o--}else return a}}function Ke(r,e){return e[r+15]===65535}function rt(r,e){return e[r+6]}function ut(r,e){return e[r+14]}function ht(r){return r+8}function ft(r,e){return e[r+6]}function jc(r,e){return e[r+7]}let Gc,ei,Cr,$c;const Lh=Math.pow(2,32);function Ws(r){return"count"in r?1:1+Ws(r.left)+Ws(r.right)}function Vh(r,e,t){return Gc=new Float32Array(t),ei=new Uint32Array(t),Cr=new Uint16Array(t),$c=new Uint8Array(t),Hs(r,e)}function Hs(r,e){const t=r/4,n=r/2,i="count"in e,s=e.boundingData;for(let a=0;a<6;a++)Gc[t+a]=s[a];if(i)if(e.buffer){const a=e.buffer;$c.set(new Uint8Array(a),r);for(let o=r,c=r+a.byteLength;o<c;o+=ii){const l=o/2;Ke(l,Cr)||(ei[o/4+6]+=t)}return r+a.byteLength}else{const a=e.offset,o=e.count;return ei[t+6]=a,Cr[n+14]=o,Cr[n+15]=Lr,r+ii}else{const a=e.left,o=e.right,c=e.splitAxis;let l;if(l=Hs(r+ii,a),l/4>Lh)throw new Error("MeshBVH: Cannot store child pointer greater than 32 bits.");return ei[t+6]=l/4,l=Hs(l,o),ei[t+7]=c,l}}function Jh(r,e){const t=(r.index?r.index.count:r.attributes.position.count)/3,n=t>2**16,i=n?4:2,s=e?new SharedArrayBuffer(t*i):new ArrayBuffer(t*i),a=n?new Uint32Array(s):new Uint16Array(s);for(let o=0,c=a.length;o<c;o++)a[o]=o;return a}function jh(r,e,t,n,i){const{maxDepth:s,verbose:a,maxLeafTris:o,strategy:c,onProgress:l,indirect:u}=i,f=r._indirectBuffer,p=r.geometry,m=p.index?p.index.array:null,x=u?Fh:Dh,T=Un(p),g=new Float32Array(6);let v=!1;const b=new Ts;return bs(e,t,n,b.boundingData,g),w(b,t,n,g),b;function _(C){l&&l(C/T)}function w(C,P,E,I=null,O=0){if(!v&&O>=s&&(v=!0,a&&(console.warn(`MeshBVH: Max depth of ${s} reached when generating BVH. Consider increasing maxDepth.`),console.warn(p))),E<=o||O>=s)return _(P+E),C.offset=P,C.count=E,C;const A=Nh(C.boundingData,I,e,P,E,c);if(A.axis===-1)return _(P+E),C.offset=P,C.count=E,C;const N=x(f,m,e,P,E,A);if(N===P||N===P+E)_(P+E),C.offset=P,C.count=E;else{C.splitAxis=A.axis;const B=new Ts,D=P,L=N-P;C.left=B,bs(e,D,L,B.boundingData,g),w(B,D,L,g,O+1);const J=new Ts,W=N,Y=E-L;C.right=J,bs(e,W,Y,J.boundingData,g),w(J,W,Y,g,O+1)}return C}}function Gh(r,e){const t=r.geometry;e.indirect&&(r._indirectBuffer=Jh(t,e.useSharedArrayBuffer),zh(t,e.range)&&!e.verbose&&console.warn('MeshBVH: Provided geometry contains groups or a range that do not fully span the vertex contents while using the "indirect" option. BVH may incorrectly report intersections on unrendered portions of the geometry.')),r._indirectBuffer||Oh(t,e);const n=e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,i=Ih(t),s=e.indirect?Vc(t,e.range):Jc(t,e.range);r._roots=s.map(a=>{const o=jh(r,i,a.offset,a.count,e),c=Ws(o),l=new n(ii*c);return Vh(0,o,l),l})}class Gt{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 c=e[s][t];n=c<n?c:n,i=c>i?c: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}}Gt.prototype.setFromBox=(function(){const r=new R.Vector3;return function(t,n){const i=n.min,s=n.max;let a=1/0,o=-1/0;for(let c=0;c<=1;c++)for(let l=0;l<=1;l++)for(let u=0;u<=1;u++){r.x=i.x*c+s.x*(1-c),r.y=i.y*l+s.y*(1-l),r.z=i.z*u+s.z*(1-u);const f=t.dot(r);a=Math.min(f,a),o=Math.max(f,o)}this.min=a,this.max=o}})();const $h=(function(){const r=new R.Vector3,e=new R.Vector3,t=new R.Vector3;return function(i,s,a){const o=i.start,c=r,l=s.start,u=e;t.subVectors(o,l),r.subVectors(i.end,i.start),e.subVectors(s.end,s.start);const f=t.dot(u),p=u.dot(c),m=u.dot(u),x=t.dot(c),g=c.dot(c)*m-p*p;let v,b;g!==0?v=(f*p-x*m)/g:v=0,b=(f+v*p)/m,a.x=v,a.y=b}})(),ho=(function(){const r=new R.Vector2,e=new R.Vector3,t=new R.Vector3;return function(i,s,a,o){$h(i,s,r);let c=r.x,l=r.y;if(c>=0&&c<=1&&l>=0&&l<=1){i.at(c,a),s.at(l,o);return}else if(c>=0&&c<=1){l<0?s.at(0,o):s.at(1,o),i.closestPointToPoint(o,!0,a);return}else if(l>=0&&l<=1){c<0?i.at(0,a):i.at(1,a),s.closestPointToPoint(a,!0,o);return}else{let u;c<0?u=i.start:u=i.end;let f;l<0?f=s.start:f=s.end;const p=e,m=t;if(i.closestPointToPoint(f,!0,e),s.closestPointToPoint(u,!0,t),p.distanceToSquared(f)<=m.distanceToSquared(u)){a.copy(p),o.copy(f);return}else{a.copy(u),o.copy(m);return}}}})(),Wh=(function(){const r=new R.Vector3,e=new R.Vector3,t=new R.Plane,n=new R.Line3;return function(s,a){const{radius:o,center:c}=s,{a:l,b:u,c:f}=a;if(n.start=l,n.end=u,n.closestPointToPoint(c,!0,r).distanceTo(c)<=o||(n.start=l,n.end=f,n.closestPointToPoint(c,!0,r).distanceTo(c)<=o)||(n.start=u,n.end=f,n.closestPointToPoint(c,!0,r).distanceTo(c)<=o))return!0;const T=a.getPlane(t);if(Math.abs(T.distanceToPoint(c))<=o){const v=T.projectPoint(c,e);if(a.containsPoint(v))return!0}return!1}})(),Hh=1e-15;function Ms(r){return Math.abs(r)<Hh}class pt extends R.Triangle{constructor(...e){super(...e),this.isExtendedTriangle=!0,this.satAxes=new Array(4).fill().map(()=>new R.Vector3),this.satBounds=new Array(4).fill().map(()=>new Gt),this.points=[this.a,this.b,this.c],this.sphere=new R.Sphere,this.plane=new R.Plane,this.needsUpdate=!0}intersectsSphere(e){return Wh(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 f=s[2],p=a[2];f.subVectors(t,n),p.setFromPoints(f,i);const m=s[3],x=a[3];m.subVectors(n,e),x.setFromPoints(m,i),this.sphere.setFromPoints(this.points),this.plane.setFromNormalAndCoplanarPoint(o,e),this.needsUpdate=!1}}pt.prototype.closestPointToSegment=(function(){const r=new R.Vector3,e=new R.Vector3,t=new R.Line3;return function(i,s=null,a=null){const{start:o,end:c}=i,l=this.points;let u,f=1/0;for(let p=0;p<3;p++){const m=(p+1)%3;t.start.copy(l[p]),t.end.copy(l[m]),ho(t,i,r,e),u=r.distanceToSquared(e),u<f&&(f=u,s&&s.copy(r),a&&a.copy(e))}return this.closestPointToPoint(o,r),u=o.distanceToSquared(r),u<f&&(f=u,s&&s.copy(r),a&&a.copy(o)),this.closestPointToPoint(c,r),u=c.distanceToSquared(r),u<f&&(f=u,s&&s.copy(r),a&&a.copy(c)),Math.sqrt(f)}})();pt.prototype.intersectsTriangle=(function(){const r=new pt,e=new Array(3),t=new Array(3),n=new Gt,i=new Gt,s=new R.Vector3,a=new R.Vector3,o=new R.Vector3,c=new R.Vector3,l=new R.Vector3,u=new R.Line3,f=new R.Line3,p=new R.Line3,m=new R.Vector3;function x(T,g,v){const b=T.points;let _=0,w=-1;for(let C=0;C<3;C++){const{start:P,end:E}=u;P.copy(b[C]),E.copy(b[(C+1)%3]),u.delta(a);const I=Ms(g.distanceToPoint(P));if(Ms(g.normal.dot(a))&&I){v.copy(u),_=2;break}const O=g.intersectLine(u,m);if(!O&&I&&m.copy(P),(O||I)&&!Ms(m.distanceTo(E))){if(_<=1)(_===1?v.start:v.end).copy(m),I&&(w=_);else if(_>=2){(w===1?v.start:v.end).copy(m),_=2;break}if(_++,_===2&&w===-1)break}}return _}return function(g,v=null,b=!1){this.needsUpdate&&this.update(),g.isExtendedTriangle?g.needsUpdate&&g.update():(r.copy(g),r.update(),g=r);const _=this.plane,w=g.plane;if(Math.abs(_.normal.dot(w.normal))>1-1e-10){const C=this.satBounds,P=this.satAxes;t[0]=g.a,t[1]=g.b,t[2]=g.c;for(let O=0;O<4;O++){const A=C[O],N=P[O];if(n.setFromPoints(N,t),A.isSeparated(n))return!1}const E=g.satBounds,I=g.satAxes;e[0]=this.a,e[1]=this.b,e[2]=this.c;for(let O=0;O<4;O++){const A=E[O],N=I[O];if(n.setFromPoints(N,e),A.isSeparated(n))return!1}for(let O=0;O<4;O++){const A=P[O];for(let N=0;N<4;N++){const B=I[N];if(s.crossVectors(A,B),n.setFromPoints(s,e),i.setFromPoints(s,t),n.isSeparated(i))return!1}}return v&&(b||console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."),v.start.set(0,0,0),v.end.set(0,0,0)),!0}else{const C=x(this,w,f);if(C===1&&g.containsPoint(f.end))return v&&(v.start.copy(f.end),v.end.copy(f.end)),!0;if(C!==2)return!1;const P=x(g,_,p);if(P===1&&this.containsPoint(p.end))return v&&(v.start.copy(p.end),v.end.copy(p.end)),!0;if(P!==2)return!1;if(f.delta(o),p.delta(c),o.dot(c)<0){let D=p.start;p.start=p.end,p.end=D}const E=f.start.dot(o),I=f.end.dot(o),O=p.start.dot(o),A=p.end.dot(o),N=I<O,B=E<A;return E!==A&&O!==I&&N===B?!1:(v&&(l.subVectors(f.start,p.start),l.dot(o)>0?v.start.copy(f.start):v.start.copy(p.start),l.subVectors(f.end,p.end),l.dot(o)<0?v.end.copy(f.end):v.end.copy(p.end)),!0)}}})();pt.prototype.distanceToPoint=(function(){const r=new R.Vector3;return function(t){return this.closestPointToPoint(t,r),t.distanceTo(r)}})();pt.prototype.distanceToTriangle=(function(){const r=new R.Vector3,e=new R.Vector3,t=["a","b","c"],n=new R.Line3,i=new R.Line3;return function(a,o=null,c=null){const l=o||c?n:null;if(this.intersectsTriangle(a,l))return(o||c)&&(o&&l.getCenter(o),c&&l.getCenter(c)),0;let u=1/0;for(let f=0;f<3;f++){let p;const m=t[f],x=a[m];this.closestPointToPoint(x,r),p=x.distanceToSquared(r),p<u&&(u=p,o&&o.copy(r),c&&c.copy(x));const T=this[m];a.closestPointToPoint(T,r),p=T.distanceToSquared(r),p<u&&(u=p,o&&o.copy(T),c&&c.copy(r))}for(let f=0;f<3;f++){const p=t[f],m=t[(f+1)%3];n.set(this[p],this[m]);for(let x=0;x<3;x++){const T=t[x],g=t[(x+1)%3];i.set(a[T],a[g]),ho(n,i,r,e);const v=r.distanceToSquared(e);v<u&&(u=v,o&&o.copy(r),c&&c.copy(e))}}return Math.sqrt(u)}})();class Le{constructor(e,t,n){this.isOrientedBox=!0,this.min=new R.Vector3,this.max=new R.Vector3,this.matrix=new R.Matrix4,this.invMatrix=new R.Matrix4,this.points=new Array(8).fill().map(()=>new R.Vector3),this.satAxes=new Array(3).fill().map(()=>new R.Vector3),this.satBounds=new Array(3).fill().map(()=>new Gt),this.alignedSatBounds=new Array(3).fill().map(()=>new Gt),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}}Le.prototype.update=(function(){return function(){const e=this.matrix,t=this.min,n=this.max,i=this.points;for(let l=0;l<=1;l++)for(let u=0;u<=1;u++)for(let f=0;f<=1;f++){const p=1*l|2*u|4*f,m=i[p];m.x=l?n.x:t.x,m.y=u?n.y:t.y,m.z=f?n.z:t.z,m.applyMatrix4(e)}const s=this.satBounds,a=this.satAxes,o=i[0];for(let l=0;l<3;l++){const u=a[l],f=s[l],p=1<<l,m=i[p];u.subVectors(o,m),f.setFromPoints(u,i)}const c=this.alignedSatBounds;c[0].setFromPointsField(i,"x"),c[1].setFromPointsField(i,"y"),c[2].setFromPointsField(i,"z"),this.invMatrix.copy(this.matrix).invert(),this.needsUpdate=!1}})();Le.prototype.intersectsBox=(function(){const r=new Gt;return function(t){this.needsUpdate&&this.update();const n=t.min,i=t.max,s=this.satBounds,a=this.satAxes,o=this.alignedSatBounds;if(r.min=n.x,r.max=i.x,o[0].isSeparated(r)||(r.min=n.y,r.max=i.y,o[1].isSeparated(r))||(r.min=n.z,r.max=i.z,o[2].isSeparated(r)))return!1;for(let c=0;c<3;c++){const l=a[c],u=s[c];if(r.setFromBox(l,t),u.isSeparated(r))return!1}return!0}})();Le.prototype.intersectsTriangle=(function(){const r=new pt,e=new Array(3),t=new Gt,n=new Gt,i=new R.Vector3;return function(a){this.needsUpdate&&this.update(),a.isExtendedTriangle?a.needsUpdate&&a.update():(r.copy(a),r.update(),a=r);const o=this.satBounds,c=this.satAxes;e[0]=a.a,e[1]=a.b,e[2]=a.c;for(let p=0;p<3;p++){const m=o[p],x=c[p];if(t.setFromPoints(x,e),m.isSeparated(t))return!1}const l=a.satBounds,u=a.satAxes,f=this.points;for(let p=0;p<3;p++){const m=l[p],x=u[p];if(t.setFromPoints(x,f),m.isSeparated(t))return!1}for(let p=0;p<3;p++){const m=c[p];for(let x=0;x<4;x++){const T=u[x];if(i.crossVectors(m,T),t.setFromPoints(i,e),n.setFromPoints(i,f),t.isSeparated(n))return!1}}return!0}})();Le.prototype.closestPointToPoint=(function(){return function(e,t){return this.needsUpdate&&this.update(),t.copy(e).applyMatrix4(this.invMatrix).clamp(this.min,this.max).applyMatrix4(this.matrix),t}})();Le.prototype.distanceToPoint=(function(){const r=new R.Vector3;return function(t){return this.closestPointToPoint(t,r),t.distanceTo(r)}})();Le.prototype.distanceToBox=(function(){const r=["x","y","z"],e=new Array(12).fill().map(()=>new R.Line3),t=new Array(12).fill().map(()=>new R.Line3),n=new R.Vector3,i=new R.Vector3;return function(a,o=0,c=null,l=null){if(this.needsUpdate&&this.update(),this.intersectsBox(a))return(c||l)&&(a.getCenter(i),this.closestPointToPoint(i,n),a.closestPointToPoint(n,i),c&&c.copy(n),l&&l.copy(i)),0;const u=o*o,f=a.min,p=a.max,m=this.points;let x=1/0;for(let g=0;g<8;g++){const v=m[g];i.copy(v).clamp(f,p);const b=v.distanceToSquared(i);if(b<x&&(x=b,c&&c.copy(v),l&&l.copy(i),b<u))return Math.sqrt(b)}let T=0;for(let g=0;g<3;g++)for(let v=0;v<=1;v++)for(let b=0;b<=1;b++){const _=(g+1)%3,w=(g+2)%3,C=v<<_|b<<w,P=1<<g|v<<_|b<<w,E=m[C],I=m[P];e[T].set(E,I);const A=r[g],N=r[_],B=r[w],D=t[T],L=D.start,J=D.end;L[A]=f[A],L[N]=v?f[N]:p[N],L[B]=b?f[B]:p[N],J[A]=p[A],J[N]=v?f[N]:p[N],J[B]=b?f[B]:p[N],T++}for(let g=0;g<=1;g++)for(let v=0;v<=1;v++)for(let b=0;b<=1;b++){i.x=g?p.x:f.x,i.y=v?p.y:f.y,i.z=b?p.z:f.z,this.closestPointToPoint(i,n);const _=i.distanceToSquared(n);if(_<x&&(x=_,c&&c.copy(n),l&&l.copy(i),_<u))return Math.sqrt(_)}for(let g=0;g<12;g++){const v=e[g];for(let b=0;b<12;b++){const _=t[b];ho(v,_,n,i);const w=n.distanceToSquared(i);if(w<x&&(x=w,c&&c.copy(n),l&&l.copy(i),w<u))return Math.sqrt(w)}}return Math.sqrt(x)}})();class fo{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 qh extends fo{constructor(){super(()=>new pt)}}const dt=new qh;class Xh{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 fe=new Xh;let Kt,An;const Tn=[],or=new fo(()=>new R.Box3);function Yh(r,e,t,n,i,s){Kt=or.getPrimitive(),An=or.getPrimitive(),Tn.push(Kt,An),fe.setBuffer(r._roots[e]);const a=qs(0,r.geometry,t,n,i,s);fe.clearBuffer(),or.releasePrimitive(Kt),or.releasePrimitive(An),Tn.pop(),Tn.pop();const o=Tn.length;return o>0&&(An=Tn[o-1],Kt=Tn[o-2]),a}function qs(r,e,t,n,i=null,s=0,a=0){const{float32Array:o,uint16Array:c,uint32Array:l}=fe;let u=r*2;if(Ke(u,c)){const p=rt(r,l),m=ut(u,c);return ve(r,o,Kt),n(p,m,!1,a,s+r,Kt)}else{let A=function(B){const{uint16Array:D,uint32Array:L}=fe;let J=B*2;for(;!Ke(J,D);)B=ht(B),J=B*2;return rt(B,L)},N=function(B){const{uint16Array:D,uint32Array:L}=fe;let J=B*2;for(;!Ke(J,D);)B=ft(B,L),J=B*2;return rt(B,L)+ut(J,D)};const p=ht(r),m=ft(r,l);let x=p,T=m,g,v,b,_;if(i&&(b=Kt,_=An,ve(x,o,b),ve(T,o,_),g=i(b),v=i(_),v<g)){x=m,T=p;const B=g;g=v,v=B,b=_}b||(b=Kt,ve(x,o,b));const w=Ke(x*2,c),C=t(b,w,g,a+1,s+x);let P;if(C===$s){const B=A(x),L=N(x)-B;P=n(B,L,!0,a+1,s+x,b)}else P=C&&qs(x,e,t,n,i,s,a+1);if(P)return!0;_=An,ve(T,o,_);const E=Ke(T*2,c),I=t(_,E,v,a+1,s+T);let O;if(I===$s){const B=A(T),L=N(T)-B;O=n(B,L,!0,a+1,s+T,_)}else O=I&&qs(T,e,t,n,i,s,a+1);return!!O}}const Gn=new R.Vector3,Cs=new R.Vector3;function Zh(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=>(Gn.copy(e).clamp(u.min,u.max),Gn.distanceToSquared(e)),intersectsBounds:(u,f,p)=>p<o&&p<a,intersectsTriangle:(u,f)=>{u.closestPointToPoint(e,Gn);const p=e.distanceToSquared(Gn);return p<o&&(Cs.copy(Gn),o=p,c=f),p<s}}),o===1/0)return null;const l=Math.sqrt(o);return t.point?t.point.copy(Cs):t.point=Cs.clone(),t.distance=l,t.faceIndex=c,t}const Kh=parseInt(R.REVISION)>=169,sn=new R.Vector3,on=new R.Vector3,an=new R.Vector3,ar=new R.Vector2,cr=new R.Vector2,lr=new R.Vector2,Ca=new R.Vector3,wa=new R.Vector3,Pa=new R.Vector3,$n=new R.Vector3;function Qh(r,e,t,n,i,s,a,o){let c;if(s===R.BackSide?c=r.intersectTriangle(n,t,e,!0,i):c=r.intersectTriangle(e,t,n,s!==R.DoubleSide,i),c===null)return null;const l=r.origin.distanceTo(i);return l<a||l>o?null:{distance:l,point:i.clone()}}function ef(r,e,t,n,i,s,a,o,c,l,u){sn.fromBufferAttribute(e,s),on.fromBufferAttribute(e,a),an.fromBufferAttribute(e,o);const f=Qh(r,sn,on,an,$n,c,l,u);if(f){const p=new R.Vector3;R.Triangle.getBarycoord($n,sn,on,an,p),n&&(ar.fromBufferAttribute(n,s),cr.fromBufferAttribute(n,a),lr.fromBufferAttribute(n,o),f.uv=R.Triangle.getInterpolation($n,sn,on,an,ar,cr,lr,new R.Vector2)),i&&(ar.fromBufferAttribute(i,s),cr.fromBufferAttribute(i,a),lr.fromBufferAttribute(i,o),f.uv1=R.Triangle.getInterpolation($n,sn,on,an,ar,cr,lr,new R.Vector2)),t&&(Ca.fromBufferAttribute(t,s),wa.fromBufferAttribute(t,a),Pa.fromBufferAttribute(t,o),f.normal=R.Triangle.getInterpolation($n,sn,on,an,Ca,wa,Pa,new R.Vector3),f.normal.dot(r.direction)>0&&f.normal.multiplyScalar(-1));const m={a:s,b:a,c:o,normal:new R.Vector3,materialIndex:0};R.Triangle.getNormal(sn,on,an,m.normal),f.face=m,f.faceIndex=s,Kh&&(f.barycoord=p)}return f}function Vr(r,e,t,n,i,s,a){const o=n*3;let c=o+0,l=o+1,u=o+2;const f=r.index;r.index&&(c=f.getX(c),l=f.getX(l),u=f.getX(u));const{position:p,normal:m,uv:x,uv1:T}=r.attributes,g=ef(t,p,m,x,T,c,l,u,e,s,a);return g?(g.faceIndex=n,i&&i.push(g),g):null}function Me(r,e,t,n){const i=r.a,s=r.b,a=r.c;let o=e,c=e+1,l=e+2;t&&(o=t.getX(o),c=t.getX(c),l=t.getX(l)),i.x=n.getX(o),i.y=n.getY(o),i.z=n.getZ(o),s.x=n.getX(c),s.y=n.getY(c),s.z=n.getZ(c),a.x=n.getX(l),a.y=n.getY(l),a.z=n.getZ(l)}function tf(r,e,t,n,i,s,a,o){const{geometry:c,_indirectBuffer:l}=r;for(let u=n,f=n+i;u<f;u++)Vr(c,e,t,u,s,a,o)}function nf(r,e,t,n,i,s,a){const{geometry:o,_indirectBuffer:c}=r;let l=1/0,u=null;for(let f=n,p=n+i;f<p;f++){let m;m=Vr(o,e,t,f,null,s,a),m&&m.distance<l&&(u=m,l=m.distance)}return u}function rf(r,e,t,n,i,s,a){const{geometry:o}=t,{index:c}=o,l=o.attributes.position;for(let u=r,f=e+r;u<f;u++){let p;if(p=u,Me(a,p*3,c,l),a.needsUpdate=!0,n(a,p,i,s))return!0}return!1}function sf(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 p=0,m=u.length;p<m;p++)s=u[p],a=new Uint32Array(s),o=new Uint16Array(s),c=new Float32Array(s),f(0,l),l+=s.byteLength;function f(p,m,x=!1){const T=p*2;if(o[T+15]===Lr){const v=a[p+6],b=o[T+14];let _=1/0,w=1/0,C=1/0,P=-1/0,E=-1/0,I=-1/0;for(let O=3*v,A=3*(v+b);O<A;O++){let N=n[O];const B=i.getX(N),D=i.getY(N),L=i.getZ(N);B<_&&(_=B),B>P&&(P=B),D<w&&(w=D),D>E&&(E=D),L<C&&(C=L),L>I&&(I=L)}return c[p+0]!==_||c[p+1]!==w||c[p+2]!==C||c[p+3]!==P||c[p+4]!==E||c[p+5]!==I?(c[p+0]=_,c[p+1]=w,c[p+2]=C,c[p+3]=P,c[p+4]=E,c[p+5]=I,!0):!1}else{const v=p+8,b=a[p+6],_=v+m,w=b+m;let C=x,P=!1,E=!1;e?C||(P=e.has(_),E=e.has(w),C=!P&&!E):(P=!0,E=!0);const I=C||P,O=C||E;let A=!1;I&&(A=f(v,m,C));let N=!1;O&&(N=f(b,m,C));const B=A||N;if(B)for(let D=0;D<3;D++){const L=v+D,J=b+D,W=c[L],Y=c[L+3],G=c[J],se=c[J+3];c[p+D]=W<G?W:G,c[p+D+3]=Y>se?Y:se}return B}}}function Qt(r,e,t,n,i){let s,a,o,c,l,u;const f=1/t.direction.x,p=1/t.direction.y,m=1/t.direction.z,x=t.origin.x,T=t.origin.y,g=t.origin.z;let v=e[r],b=e[r+3],_=e[r+1],w=e[r+3+1],C=e[r+2],P=e[r+3+2];return f>=0?(s=(v-x)*f,a=(b-x)*f):(s=(b-x)*f,a=(v-x)*f),p>=0?(o=(_-T)*p,c=(w-T)*p):(o=(w-T)*p,c=(_-T)*p),s>c||o>a||((o>s||isNaN(s))&&(s=o),(c<a||isNaN(a))&&(a=c),m>=0?(l=(C-g)*m,u=(P-g)*m):(l=(P-g)*m,u=(C-g)*m),s>u||l>a)?!1:((l>s||s!==s)&&(s=l),(u<a||a!==a)&&(a=u),s<=i&&a>=n)}function of(r,e,t,n,i,s,a,o){const{geometry:c,_indirectBuffer:l}=r;for(let u=n,f=n+i;u<f;u++){let p=l?l[u]:u;Vr(c,e,t,p,s,a,o)}}function af(r,e,t,n,i,s,a){const{geometry:o,_indirectBuffer:c}=r;let l=1/0,u=null;for(let f=n,p=n+i;f<p;f++){let m;m=Vr(o,e,t,c?c[f]:f,null,s,a),m&&m.distance<l&&(u=m,l=m.distance)}return u}function cf(r,e,t,n,i,s,a){const{geometry:o}=t,{index:c}=o,l=o.attributes.position;for(let u=r,f=e+r;u<f;u++){let p;if(p=t.resolveTriangleIndex(u),Me(a,p*3,c,l),a.needsUpdate=!0,n(a,p,i,s))return!0}return!1}function lf(r,e,t,n,i,s,a){fe.setBuffer(r._roots[e]),Xs(0,r,t,n,i,s,a),fe.clearBuffer()}function Xs(r,e,t,n,i,s,a){const{float32Array:o,uint16Array:c,uint32Array:l}=fe,u=r*2;if(Ke(u,c)){const p=rt(r,l),m=ut(u,c);tf(e,t,n,p,m,i,s,a)}else{const p=ht(r);Qt(p,o,n,s,a)&&Xs(p,e,t,n,i,s,a);const m=ft(r,l);Qt(m,o,n,s,a)&&Xs(m,e,t,n,i,s,a)}}const uf=["x","y","z"];function hf(r,e,t,n,i,s){fe.setBuffer(r._roots[e]);const a=Ys(0,r,t,n,i,s);return fe.clearBuffer(),a}function Ys(r,e,t,n,i,s){const{float32Array:a,uint16Array:o,uint32Array:c}=fe;let l=r*2;if(Ke(l,o)){const f=rt(r,c),p=ut(l,o);return nf(e,t,n,f,p,i,s)}else{const f=jc(r,c),p=uf[f],x=n.direction[p]>=0;let T,g;x?(T=ht(r),g=ft(r,c)):(T=ft(r,c),g=ht(r));const b=Qt(T,a,n,i,s)?Ys(T,e,t,n,i,s):null;if(b){const C=b.point[p];if(x?C<=a[g+f]:C>=a[g+f+3])return b}const w=Qt(g,a,n,i,s)?Ys(g,e,t,n,i,s):null;return b&&w?b.distance<=w.distance?b:w:b||w||null}}const ur=new R.Box3,Mn=new pt,Cn=new pt,Wn=new R.Matrix4,Ea=new Le,hr=new Le;function ff(r,e,t,n){fe.setBuffer(r._roots[e]);const i=Zs(0,r,t,n);return fe.clearBuffer(),i}function Zs(r,e,t,n,i=null){const{float32Array:s,uint16Array:a,uint32Array:o}=fe;let c=r*2;if(i===null&&(t.boundingBox||t.computeBoundingBox(),Ea.set(t.boundingBox.min,t.boundingBox.max,n),i=Ea),Ke(c,a)){const u=e.geometry,f=u.index,p=u.attributes.position,m=t.index,x=t.attributes.position,T=rt(r,o),g=ut(c,a);if(Wn.copy(n).invert(),t.boundsTree)return ve(r,s,hr),hr.matrix.copy(Wn),hr.needsUpdate=!0,t.boundsTree.shapecast({intersectsBounds:b=>hr.intersectsBox(b),intersectsTriangle:b=>{b.a.applyMatrix4(n),b.b.applyMatrix4(n),b.c.applyMatrix4(n),b.needsUpdate=!0;for(let _=T*3,w=(g+T)*3;_<w;_+=3)if(Me(Cn,_,f,p),Cn.needsUpdate=!0,b.intersectsTriangle(Cn))return!0;return!1}});for(let v=T*3,b=(g+T)*3;v<b;v+=3){Me(Mn,v,f,p),Mn.a.applyMatrix4(Wn),Mn.b.applyMatrix4(Wn),Mn.c.applyMatrix4(Wn),Mn.needsUpdate=!0;for(let _=0,w=m.count;_<w;_+=3)if(Me(Cn,_,m,x),Cn.needsUpdate=!0,Mn.intersectsTriangle(Cn))return!0}}else{const u=r+8,f=o[r+6];return ve(u,s,ur),!!(i.intersectsBox(ur)&&Zs(u,e,t,n,i)||(ve(f,s,ur),i.intersectsBox(ur)&&Zs(f,e,t,n,i)))}}const fr=new R.Matrix4,ws=new Le,Hn=new Le,df=new R.Vector3,pf=new R.Vector3,mf=new R.Vector3,yf=new R.Vector3;function gf(r,e,t,n={},i={},s=0,a=1/0){e.boundingBox||e.computeBoundingBox(),ws.set(e.boundingBox.min,e.boundingBox.max,t),ws.needsUpdate=!0;const o=r.geometry,c=o.attributes.position,l=o.index,u=e.attributes.position,f=e.index,p=dt.getPrimitive(),m=dt.getPrimitive();let x=df,T=pf,g=null,v=null;i&&(g=mf,v=yf);let b=1/0,_=null,w=null;return fr.copy(t).invert(),Hn.matrix.copy(fr),r.shapecast({boundsTraverseOrder:C=>ws.distanceToBox(C),intersectsBounds:(C,P,E)=>E<b&&E<a?(P&&(Hn.min.copy(C.min),Hn.max.copy(C.max),Hn.needsUpdate=!0),!0):!1,intersectsRange:(C,P)=>{if(e.boundsTree)return e.boundsTree.shapecast({boundsTraverseOrder:I=>Hn.distanceToBox(I),intersectsBounds:(I,O,A)=>A<b&&A<a,intersectsRange:(I,O)=>{for(let A=I,N=I+O;A<N;A++){Me(m,3*A,f,u),m.a.applyMatrix4(t),m.b.applyMatrix4(t),m.c.applyMatrix4(t),m.needsUpdate=!0;for(let B=C,D=C+P;B<D;B++){Me(p,3*B,l,c),p.needsUpdate=!0;const L=p.distanceToTriangle(m,x,g);if(L<b&&(T.copy(x),v&&v.copy(g),b=L,_=B,w=A),L<s)return!0}}}});{const E=Un(e);for(let I=0,O=E;I<O;I++){Me(m,3*I,f,u),m.a.applyMatrix4(t),m.b.applyMatrix4(t),m.c.applyMatrix4(t),m.needsUpdate=!0;for(let A=C,N=C+P;A<N;A++){Me(p,3*A,l,c),p.needsUpdate=!0;const B=p.distanceToTriangle(m,x,g);if(B<b&&(T.copy(x),v&&v.copy(g),b=B,_=A,w=I),B<s)return!0}}}}}),dt.releasePrimitive(p),dt.releasePrimitive(m),b===1/0?null:(n.point?n.point.copy(T):n.point=T.clone(),n.distance=b,n.faceIndex=_,i&&(i.point?i.point.copy(v):i.point=v.clone(),i.point.applyMatrix4(fr),T.applyMatrix4(fr),i.distance=T.sub(i.point).length(),i.faceIndex=w),n)}function vf(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 p=0,m=u.length;p<m;p++)s=u[p],a=new Uint32Array(s),o=new Uint16Array(s),c=new Float32Array(s),f(0,l),l+=s.byteLength;function f(p,m,x=!1){const T=p*2;if(o[T+15]===Lr){const v=a[p+6],b=o[T+14];let _=1/0,w=1/0,C=1/0,P=-1/0,E=-1/0,I=-1/0;for(let O=v,A=v+b;O<A;O++){const N=3*r.resolveTriangleIndex(O);for(let B=0;B<3;B++){let D=N+B;D=n?n[D]:D;const L=i.getX(D),J=i.getY(D),W=i.getZ(D);L<_&&(_=L),L>P&&(P=L),J<w&&(w=J),J>E&&(E=J),W<C&&(C=W),W>I&&(I=W)}}return c[p+0]!==_||c[p+1]!==w||c[p+2]!==C||c[p+3]!==P||c[p+4]!==E||c[p+5]!==I?(c[p+0]=_,c[p+1]=w,c[p+2]=C,c[p+3]=P,c[p+4]=E,c[p+5]=I,!0):!1}else{const v=p+8,b=a[p+6],_=v+m,w=b+m;let C=x,P=!1,E=!1;e?C||(P=e.has(_),E=e.has(w),C=!P&&!E):(P=!0,E=!0);const I=C||P,O=C||E;let A=!1;I&&(A=f(v,m,C));let N=!1;O&&(N=f(b,m,C));const B=A||N;if(B)for(let D=0;D<3;D++){const L=v+D,J=b+D,W=c[L],Y=c[L+3],G=c[J],se=c[J+3];c[p+D]=W<G?W:G,c[p+D+3]=Y>se?Y:se}return B}}}function Sf(r,e,t,n,i,s,a){fe.setBuffer(r._roots[e]),Ks(0,r,t,n,i,s,a),fe.clearBuffer()}function Ks(r,e,t,n,i,s,a){const{float32Array:o,uint16Array:c,uint32Array:l}=fe,u=r*2;if(Ke(u,c)){const p=rt(r,l),m=ut(u,c);of(e,t,n,p,m,i,s,a)}else{const p=ht(r);Qt(p,o,n,s,a)&&Ks(p,e,t,n,i,s,a);const m=ft(r,l);Qt(m,o,n,s,a)&&Ks(m,e,t,n,i,s,a)}}const xf=["x","y","z"];function _f(r,e,t,n,i,s){fe.setBuffer(r._roots[e]);const a=Qs(0,r,t,n,i,s);return fe.clearBuffer(),a}function Qs(r,e,t,n,i,s){const{float32Array:a,uint16Array:o,uint32Array:c}=fe;let l=r*2;if(Ke(l,o)){const f=rt(r,c),p=ut(l,o);return af(e,t,n,f,p,i,s)}else{const f=jc(r,c),p=xf[f],x=n.direction[p]>=0;let T,g;x?(T=ht(r),g=ft(r,c)):(T=ft(r,c),g=ht(r));const b=Qt(T,a,n,i,s)?Qs(T,e,t,n,i,s):null;if(b){const C=b.point[p];if(x?C<=a[g+f]:C>=a[g+f+3])return b}const w=Qt(g,a,n,i,s)?Qs(g,e,t,n,i,s):null;return b&&w?b.distance<=w.distance?b:w:b||w||null}}const dr=new R.Box3,wn=new pt,Pn=new pt,qn=new R.Matrix4,ka=new Le,pr=new Le;function bf(r,e,t,n){fe.setBuffer(r._roots[e]);const i=eo(0,r,t,n);return fe.clearBuffer(),i}function eo(r,e,t,n,i=null){const{float32Array:s,uint16Array:a,uint32Array:o}=fe;let c=r*2;if(i===null&&(t.boundingBox||t.computeBoundingBox(),ka.set(t.boundingBox.min,t.boundingBox.max,n),i=ka),Ke(c,a)){const u=e.geometry,f=u.index,p=u.attributes.position,m=t.index,x=t.attributes.position,T=rt(r,o),g=ut(c,a);if(qn.copy(n).invert(),t.boundsTree)return ve(r,s,pr),pr.matrix.copy(qn),pr.needsUpdate=!0,t.boundsTree.shapecast({intersectsBounds:b=>pr.intersectsBox(b),intersectsTriangle:b=>{b.a.applyMatrix4(n),b.b.applyMatrix4(n),b.c.applyMatrix4(n),b.needsUpdate=!0;for(let _=T,w=g+T;_<w;_++)if(Me(Pn,3*e.resolveTriangleIndex(_),f,p),Pn.needsUpdate=!0,b.intersectsTriangle(Pn))return!0;return!1}});for(let v=T,b=g+T;v<b;v++){const _=e.resolveTriangleIndex(v);Me(wn,3*_,f,p),wn.a.applyMatrix4(qn),wn.b.applyMatrix4(qn),wn.c.applyMatrix4(qn),wn.needsUpdate=!0;for(let w=0,C=m.count;w<C;w+=3)if(Me(Pn,w,m,x),Pn.needsUpdate=!0,wn.intersectsTriangle(Pn))return!0}}else{const u=r+8,f=o[r+6];return ve(u,s,dr),!!(i.intersectsBox(dr)&&eo(u,e,t,n,i)||(ve(f,s,dr),i.intersectsBox(dr)&&eo(f,e,t,n,i)))}}const mr=new R.Matrix4,Ps=new Le,Xn=new Le,Tf=new R.Vector3,Mf=new R.Vector3,Cf=new R.Vector3,wf=new R.Vector3;function Pf(r,e,t,n={},i={},s=0,a=1/0){e.boundingBox||e.computeBoundingBox(),Ps.set(e.boundingBox.min,e.boundingBox.max,t),Ps.needsUpdate=!0;const o=r.geometry,c=o.attributes.position,l=o.index,u=e.attributes.position,f=e.index,p=dt.getPrimitive(),m=dt.getPrimitive();let x=Tf,T=Mf,g=null,v=null;i&&(g=Cf,v=wf);let b=1/0,_=null,w=null;return mr.copy(t).invert(),Xn.matrix.copy(mr),r.shapecast({boundsTraverseOrder:C=>Ps.distanceToBox(C),intersectsBounds:(C,P,E)=>E<b&&E<a?(P&&(Xn.min.copy(C.min),Xn.max.copy(C.max),Xn.needsUpdate=!0),!0):!1,intersectsRange:(C,P)=>{if(e.boundsTree){const E=e.boundsTree;return E.shapecast({boundsTraverseOrder:I=>Xn.distanceToBox(I),intersectsBounds:(I,O,A)=>A<b&&A<a,intersectsRange:(I,O)=>{for(let A=I,N=I+O;A<N;A++){const B=E.resolveTriangleIndex(A);Me(m,3*B,f,u),m.a.applyMatrix4(t),m.b.applyMatrix4(t),m.c.applyMatrix4(t),m.needsUpdate=!0;for(let D=C,L=C+P;D<L;D++){const J=r.resolveTriangleIndex(D);Me(p,3*J,l,c),p.needsUpdate=!0;const W=p.distanceToTriangle(m,x,g);if(W<b&&(T.copy(x),v&&v.copy(g),b=W,_=D,w=A),W<s)return!0}}}})}else{const E=Un(e);for(let I=0,O=E;I<O;I++){Me(m,3*I,f,u),m.a.applyMatrix4(t),m.b.applyMatrix4(t),m.c.applyMatrix4(t),m.needsUpdate=!0;for(let A=C,N=C+P;A<N;A++){const B=r.resolveTriangleIndex(A);Me(p,3*B,l,c),p.needsUpdate=!0;const D=p.distanceToTriangle(m,x,g);if(D<b&&(T.copy(x),v&&v.copy(g),b=D,_=A,w=I),D<s)return!0}}}}}),dt.releasePrimitive(p),dt.releasePrimitive(m),b===1/0?null:(n.point?n.point.copy(T):n.point=T.clone(),n.distance=b,n.faceIndex=_,i&&(i.point?i.point.copy(v):i.point=v.clone(),i.point.applyMatrix4(mr),T.applyMatrix4(mr),i.distance=T.sub(i.point).length(),i.faceIndex=w),n)}function Ef(){return typeof SharedArrayBuffer<"u"}const ri=new fe.constructor,Br=new fe.constructor,Yt=new fo(()=>new R.Box3),En=new R.Box3,kn=new R.Box3,Es=new R.Box3,ks=new R.Box3;let Rs=!1;function kf(r,e,t,n){if(Rs)throw new Error("MeshBVH: Recursive calls to bvhcast not supported.");Rs=!0;const i=r._roots,s=e._roots;let a,o=0,c=0;const l=new R.Matrix4().copy(t).invert();for(let u=0,f=i.length;u<f;u++){ri.setBuffer(i[u]),c=0;const p=Yt.getPrimitive();ve(0,ri.float32Array,p),p.applyMatrix4(l);for(let m=0,x=s.length;m<x&&(Br.setBuffer(s[m]),a=Tt(0,0,t,l,n,o,c,0,0,p),Br.clearBuffer(),c+=s[m].length,!a);m++);if(Yt.releasePrimitive(p),ri.clearBuffer(),o+=i[u].length,a)break}return Rs=!1,a}function Tt(r,e,t,n,i,s=0,a=0,o=0,c=0,l=null,u=!1){let f,p;u?(f=Br,p=ri):(f=ri,p=Br);const m=f.float32Array,x=f.uint32Array,T=f.uint16Array,g=p.float32Array,v=p.uint32Array,b=p.uint16Array,_=r*2,w=e*2,C=Ke(_,T),P=Ke(w,b);let E=!1;if(P&&C)u?E=i(rt(e,v),ut(e*2,b),rt(r,x),ut(r*2,T),c,a+e,o,s+r):E=i(rt(r,x),ut(r*2,T),rt(e,v),ut(e*2,b),o,s+r,c,a+e);else if(P){const I=Yt.getPrimitive();ve(e,g,I),I.applyMatrix4(t);const O=ht(r),A=ft(r,x);ve(O,m,En),ve(A,m,kn);const N=I.intersectsBox(En),B=I.intersectsBox(kn);E=N&&Tt(e,O,n,t,i,a,s,c,o+1,I,!u)||B&&Tt(e,A,n,t,i,a,s,c,o+1,I,!u),Yt.releasePrimitive(I)}else{const I=ht(e),O=ft(e,v);ve(I,g,Es),ve(O,g,ks);const A=l.intersectsBox(Es),N=l.intersectsBox(ks);if(A&&N)E=Tt(r,I,t,n,i,s,a,o,c+1,l,u)||Tt(r,O,t,n,i,s,a,o,c+1,l,u);else if(A)if(C)E=Tt(r,I,t,n,i,s,a,o,c+1,l,u);else{const B=Yt.getPrimitive();B.copy(Es).applyMatrix4(t);const D=ht(r),L=ft(r,x);ve(D,m,En),ve(L,m,kn);const J=B.intersectsBox(En),W=B.intersectsBox(kn);E=J&&Tt(I,D,n,t,i,a,s,c,o+1,B,!u)||W&&Tt(I,L,n,t,i,a,s,c,o+1,B,!u),Yt.releasePrimitive(B)}else if(N)if(C)E=Tt(r,O,t,n,i,s,a,o,c+1,l,u);else{const B=Yt.getPrimitive();B.copy(ks).applyMatrix4(t);const D=ht(r),L=ft(r,x);ve(D,m,En),ve(L,m,kn);const J=B.intersectsBox(En),W=B.intersectsBox(kn);E=J&&Tt(O,D,n,t,i,a,s,c,o+1,B,!u)||W&&Tt(O,L,n,t,i,a,s,c,o+1,B,!u),Yt.releasePrimitive(B)}}return E}const yr=new Le,Ra=new R.Box3,Rf={strategy:uo,maxDepth:40,maxLeafTris:10,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,indirect:!1,verbose:!0,range:null};class Vi{static serialize(e,t={}){t={cloneBuffers:!0,...t};const n=e.geometry,i=e._roots,s=e._indirectBuffer,a=n.getIndex();let o;return t.cloneBuffers?o={roots:i.map(c=>c.slice()),index:a?a.array.slice():null,indirectBuffer:s?s.slice():null}:o={roots:i,index:a?a.array:null,indirectBuffer:s},o}static deserialize(e,t,n={}){n={setIndex:!0,indirect:!!e.indirectBuffer,...n};const{index:i,roots:s,indirectBuffer:a}=e,o=new Vi(t,{...n,[_s]:!0});if(o._roots=s,o._indirectBuffer=a||null,n.setIndex){const c=t.getIndex();if(c===null){const l=new R.BufferAttribute(e.index,1,!1);t.setIndex(l)}else c.array!==i&&(c.array.set(i),c.needsUpdate=!0)}return o}get indirect(){return!!this._indirectBuffer}constructor(e,t={}){if(e.isBufferGeometry){if(e.index&&e.index.isInterleavedBufferAttribute)throw new Error("MeshBVH: InterleavedBufferAttribute is not supported for the index attribute.")}else throw new Error("MeshBVH: Only BufferGeometries are supported.");if(t=Object.assign({...Rf,[_s]:!1},t),t.useSharedArrayBuffer&&!Ef())throw new Error("MeshBVH: SharedArrayBuffer is not available.");this.geometry=e,this._roots=null,this._indirectBuffer=null,t[_s]||(Gh(this,t),!e.boundingBox&&t.setBoundingBox&&(e.boundingBox=this.getBoundingBox(new R.Box3))),this.resolveTriangleIndex=t.indirect?n=>this._indirectBuffer[n]:n=>n}refit(e=null){return(this.indirect?vf:sf)(this,e)}traverse(e,t=0){const n=this._roots[t],i=new Uint32Array(n),s=new Uint16Array(n);a(0);function a(o,c=0){const l=o*2,u=s[l+15]===Lr;if(u){const f=i[o+6],p=s[l+14];e(c,u,new Float32Array(n,o*4,6),f,p)}else{const f=o+ii/4,p=i[o+6],m=i[o+7];e(c,u,new Float32Array(n,o*4,6),m)||(a(f,c+1),a(p,c+1))}}}raycast(e,t=R.FrontSide,n=0,i=1/0){const s=this._roots,a=this.geometry,o=[],c=t.isMaterial,l=Array.isArray(t),u=a.groups,f=c?t.side:t,p=this.indirect?Sf:lf;for(let m=0,x=s.length;m<x;m++){const T=l?t[u[m].materialIndex].side:f,g=o.length;if(p(this,m,T,e,o,n,i),l){const v=u[m].materialIndex;for(let b=g,_=o.length;b<_;b++)o[b].face.materialIndex=v}}return o}raycastFirst(e,t=R.FrontSide,n=0,i=1/0){const s=this._roots,a=this.geometry,o=t.isMaterial,c=Array.isArray(t);let l=null;const u=a.groups,f=o?t.side:t,p=this.indirect?_f:hf;for(let m=0,x=s.length;m<x;m++){const T=c?t[u[m].materialIndex].side:f,g=p(this,m,T,e,n,i);g!=null&&(l==null||g.distance<l.distance)&&(l=g,c&&(g.face.materialIndex=u[m].materialIndex))}return l}intersectsGeometry(e,t){let n=!1;const i=this._roots,s=this.indirect?bf:ff;for(let a=0,o=i.length;a<o&&(n=s(this,a,e,t),!n);a++);return n}shapecast(e){const t=dt.getPrimitive(),n=this.indirect?cf:rf;let{boundsTraverseOrder:i,intersectsBounds:s,intersectsRange:a,intersectsTriangle:o}=e;if(a&&o){const f=a;a=(p,m,x,T,g)=>f(p,m,x,T,g)?!0:n(p,m,this,o,x,T,t)}else a||(o?a=(f,p,m,x)=>n(f,p,this,o,m,x,t):a=(f,p,m)=>m);let c=!1,l=0;const u=this._roots;for(let f=0,p=u.length;f<p;f++){const m=u[f];if(c=Yh(this,f,s,a,i,l),c)break;l+=m.byteLength}return dt.releasePrimitive(t),c}bvhcast(e,t,n){let{intersectsRanges:i,intersectsTriangles:s}=n;const a=dt.getPrimitive(),o=this.geometry.index,c=this.geometry.attributes.position,l=this.indirect?x=>{const T=this.resolveTriangleIndex(x);Me(a,T*3,o,c)}:x=>{Me(a,x*3,o,c)},u=dt.getPrimitive(),f=e.geometry.index,p=e.geometry.attributes.position,m=e.indirect?x=>{const T=e.resolveTriangleIndex(x);Me(u,T*3,f,p)}:x=>{Me(u,x*3,f,p)};if(s){const x=(T,g,v,b,_,w,C,P)=>{for(let E=v,I=v+b;E<I;E++){m(E),u.a.applyMatrix4(t),u.b.applyMatrix4(t),u.c.applyMatrix4(t),u.needsUpdate=!0;for(let O=T,A=T+g;O<A;O++)if(l(O),a.needsUpdate=!0,s(a,u,O,E,_,w,C,P))return!0}return!1};if(i){const T=i;i=function(g,v,b,_,w,C,P,E){return T(g,v,b,_,w,C,P,E)?!0:x(g,v,b,_,w,C,P,E)}}else i=x}return kf(this,e,t,i)}intersectsBox(e,t){return yr.set(e.min,e.max,t),yr.needsUpdate=!0,this.shapecast({intersectsBounds:n=>yr.intersectsBox(n),intersectsTriangle:n=>yr.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?Pf:gf)(this,e,t,n,i,s,a)}closestPointToPoint(e,t={},n=0,i=1/0){return Zh(this,e,t,n,i)}getBoundingBox(e){return e.makeEmpty(),this._roots.forEach(n=>{ve(0,new Float32Array(n),Ra),e.union(Ra)}),e}}function Aa(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 gr=new R.Ray,Oa=new R.Vector3,za=new R.Matrix4,Af=R.Mesh.prototype.raycast,Of=R.BatchedMesh.prototype.raycast,Ia=new R.Vector3,Ie=new R.Mesh,vr=[];function zf(r,e){this.isBatchedMesh?If.call(this,r,e):Bf.call(this,r,e)}function If(r,e){if(this.boundsTrees){const t=this.boundsTrees,n=this._drawInfo||this._instanceInfo,i=this._drawRanges||this._geometryInfo,s=this.matrixWorld;Ie.material=this.material,Ie.geometry=this.geometry;const a=Ie.geometry.boundsTree,o=Ie.geometry.drawRange;Ie.geometry.boundingSphere===null&&(Ie.geometry.boundingSphere=new R.Sphere);for(let c=0,l=n.length;c<l;c++){if(!this.getVisibleAt(c))continue;const u=n[c].geometryIndex;if(Ie.geometry.boundsTree=t[u],this.getMatrixAt(c,Ie.matrixWorld).premultiply(s),!Ie.geometry.boundsTree){this.getBoundingBoxAt(u,Ie.geometry.boundingBox),this.getBoundingSphereAt(u,Ie.geometry.boundingSphere);const f=i[u];Ie.geometry.setDrawRange(f.start,f.count)}Ie.raycast(r,vr);for(let f=0,p=vr.length;f<p;f++){const m=vr[f];m.object=this,m.batchId=c,e.push(m)}vr.length=0}Ie.geometry.boundsTree=a,Ie.geometry.drawRange=o,Ie.material=null,Ie.geometry=null}else Of.call(this,r,e)}function Bf(r,e){if(this.geometry.boundsTree){if(this.material===void 0)return;za.copy(this.matrixWorld).invert(),gr.copy(r.ray).applyMatrix4(za),Ia.setFromMatrixScale(this.matrixWorld),Oa.copy(gr.direction).multiply(Ia);const t=Oa.length(),n=r.near/t,i=r.far/t,s=this.geometry.boundsTree;if(r.firstHitOnly===!0){const a=Aa(s.raycastFirst(gr,this.material,n,i),this,r);a&&e.push(a)}else{const a=s.raycast(gr,this.material,n,i);for(let o=0,c=a.length;o<c;o++){const l=Aa(a[o],this,r);l&&e.push(l)}}}else Af.call(this,r,e)}function Nf(r={}){return this.boundsTree=new Vi(this,r),this.boundsTree}const cn=new R.Vector3,ln=new R.Vector3,un=new R.Vector3,Ba=new R.Vector4,Sr=new R.Vector3,As=new R.Vector3,Na=new R.Vector4,Ua=new R.Vector4,xr=new R.Matrix4,Da=new R.Matrix4;function Yn(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 ti(r,e=null){const t=r.array.constructor,n=r.normalized,i=r.itemSize,s=e===null?r.count:e;return new R.BufferAttribute(new t(i*s),i,n)}function Wc(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 Uf(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 Fa(r,e,t){const n=r.skeleton,i=r.geometry,s=n.bones,a=n.boneInverses;Na.fromBufferAttribute(i.attributes.skinIndex,e),Ua.fromBufferAttribute(i.attributes.skinWeight,e),xr.elements.fill(0);for(let o=0;o<4;o++){const c=Ua.getComponent(o);if(c!==0){const l=Na.getComponent(o);Da.multiplyMatrices(s[l].matrixWorld,a[l]),Uf(xr,Da,c)}}return xr.multiply(r.bindMatrix).premultiply(r.bindMatrixInverse),t.transformDirection(xr),t}function Os(r,e,t,n,i){Sr.set(0,0,0);for(let s=0,a=r.length;s<a;s++){const o=e[s],c=r[s];o!==0&&(As.fromBufferAttribute(c,n),t?Sr.addScaledVector(As,o):Sr.addScaledVector(As.sub(i),o))}i.add(Sr)}function Df(r,e={useGroups:!1,updateIndex:!1,skipAttributes:[]},t=new R.BufferGeometry){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 f=r[u];let p=0;if(n!==(f.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 f.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(f.attributes[m]),p++}if(p!==o.size)throw new Error("StaticGeometryGenerator: Make sure all geometries have the same number of attributes.");if(i){let m;if(n)m=f.index.count;else if(f.attributes.position!==void 0)m=f.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 f=0;for(let p=0;p<r.length;++p)f+=r[p].index.count;t.setIndex(new R.BufferAttribute(new Uint32Array(f),1,!1)),u=!0}if(s||u){const f=t.index;let p=0,m=0;for(let x=0;x<r.length;++x){const T=r[x],g=T.index;if(a[x]!==!0)for(let v=0;v<g.count;++v)f.setX(p,g.getX(v)+m),p++;m+=T.attributes.position.count}}}for(const u in c){const f=c[u];if(!(u in t.attributes)){let x=0;for(const T in f)x+=f[T].count;t.setAttribute(u,ti(c[u][0],x))}const p=t.attributes[u];let m=0;for(let x=0,T=f.length;x<T;x++){const g=f[x];a[x]!==!0&&Wc(g,p,m),m+=g.count}}return t}function Ff(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 Lf(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 Vf{constructor(e){this.matrixWorld=new R.Matrix4,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&&Ff(e.skeleton&&e.skeleton.boneMatrices||null,this.boneMatrices)&&this.primitiveCount===n)}}class Jf{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 R.BufferGeometry),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 R.BufferGeometry){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],f=a.get(l);!f||f.didChange(l)?(this._convertToStaticGeometry(l,u),t.push(!1),f?f.update():a.set(l,new Vf(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 R.BufferAttribute(new Float32Array(0),4,!1))}else Df(s,{useGroups:i,skipAttributes:t},e);for(const o in e.attributes)e.attributes[o].needsUpdate=!0;return e}_convertToStaticGeometry(e,t=new R.BufferGeometry){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",ti(o.position)),s&&!c.normal&&o.normal&&t.setAttribute("normal",ti(o.normal)),a&&!c.tangent&&o.tangent&&t.setAttribute("tangent",ti(o.tangent)),Yn(n.index,t.index),Yn(o.position,c.position),s&&Yn(o.normal,c.normal),a&&Yn(o.tangent,c.tangent);const l=o.position,u=s?o.normal:null,f=a?o.tangent:null,p=n.morphAttributes.position,m=n.morphAttributes.normal,x=n.morphAttributes.tangent,T=n.morphTargetsRelative,g=e.morphTargetInfluences,v=new R.Matrix3;v.getNormalMatrix(e.matrixWorld),n.index&&t.index.array.set(n.index.array);for(let b=0,_=o.position.count;b<_;b++)cn.fromBufferAttribute(l,b),u&&ln.fromBufferAttribute(u,b),f&&(Ba.fromBufferAttribute(f,b),un.fromBufferAttribute(f,b)),g&&(p&&Os(p,g,T,b,cn),m&&Os(m,g,T,b,ln),x&&Os(x,g,T,b,un)),e.isSkinnedMesh&&(e.applyBoneTransform(b,cn),u&&Fa(e,b,ln),f&&Fa(e,b,un)),i&&cn.applyMatrix4(e.matrixWorld),c.position.setXYZ(b,cn.x,cn.y,cn.z),u&&(i&&ln.applyNormalMatrix(v),c.normal.setXYZ(b,ln.x,ln.y,ln.z)),f&&(i&&un.transformDirection(e.matrixWorld),c.tangent.setXYZW(b,un.x,un.y,un.z,Ba.w));for(const b in this.attributes){const _=this.attributes[b];_==="position"||_==="tangent"||_==="normal"||!(_ in o)||(c[_]||t.setAttribute(_,ti(o[_])),Yn(o[_],c[_]),Wc(o[_],c[_]))}return e.matrixWorld.determinant()<0&&Lf(t),t}}const jf=Object.freeze(Object.defineProperty({__proto__:null,AVERAGE:Fc,CENTER:uo,CONTAINED:$s,ExtendedTriangle:pt,MeshBVH:Vi,OrientedBox:Le,SAH:Lc,StaticGeometryGenerator:Jf,acceleratedRaycast:zf,computeBoundsTree:Nf},Symbol.toStringTag,{value:"Module"}));class Gf{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 lt={node:"node",material:"material",camera:"camera",light:"light"},hn="KHR_animation_pointer",$f={CUBICSPLINE:void 0,LINEAR:R.InterpolateLinear,STEP:R.InterpolateDiscrete};class Wf{constructor(e){this.name=hn,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){qf();const t=e.target,n=t.extensions&&t.extensions[hn]&&t.path&&t.path==="pointer";if(!n)return null;let i,s=lt.node,a;if(n){const c=t.extensions[hn];let l=c.pointer;if(!l){console.warn("Invalid path",c,t);return}if(l.startsWith("/materials/")?s=lt.material:l.startsWith("/extensions/KHR_lights_punctual/lights/")?s=lt.light:l.startsWith("/cameras/")&&(s=lt.camera),a=this._tryResolveTargetId(l,s),a===null||isNaN(a)){console.warn("Failed resolving animation node id: "+a,l);return}switch(s){case lt.material:const u=("/materials/"+a.toString()+"/").length,f=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=f+i;break;case lt.node:const p=("/nodes/"+a.toString()+"/").length,m=l.substring(0,p);switch(i=l.substring(p),i){case"translation":i="position";break;case"rotation":i="quaternion";break;case"scale":i="scale";break;case"weights":i="morphTargetInfluences";break;case"KHR_node_visibility/visible":i="visible";break}l=m+i;break;case lt.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 lt.camera:const T=("/cameras/"+a.toString()+"/").length,g=l.substring(0,T);switch(i=l.substring(T),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[hn].pointer=l}if(a==null||isNaN(a)){console.warn("Failed resolving animation node id: "+a,t);return}let o;return s===lt.node?o=this.parser.getDependency("node",a):s===lt.material?o=this.parser.getDependency("material",a):s===lt.light?o=this.parser.getDependency("light",a):s===lt.camera?o=this.parser.getDependency("camera",a):console.error("Unhandled type",s),o}createAnimationTracksWithAnimationPointer(e,t,n,i,s){if(!(s.extensions&&s.extensions[hn]&&s.path&&s.path==="pointer"))return null;let o=s.extensions[hn].pointer;if(!o)return null;const c=[];o=o.replaceAll("/",".");const l=o.split(".");var f=e.name!==void 0&&e.name!==null?e.name:e.uuid;if(l[2]=f,l[3]==="morphTargetInfluences"&&e.type==="Group"){for(const x of e.children)x instanceof R.SkinnedMesh&&x.morphTargetInfluences&&(l[3]=x.name,l[4]="morphTargetInfluences",m(this.parser));return c}m(this.parser);function p(x,T){try{const g=T.split(".").filter(Boolean),b=g[g.length-1].replace(/\[.*\]$/,"");return b in x?typeof x[b]=="boolean":!1}catch{return!1}}function m(x){o=l.join(".");let T,g=!1;switch(n.itemSize){case 1:Object.prototype.toString.call(n.array)==="[object Uint8Array]"&&p(e,o)?(T=R.BooleanKeyframeTrack,g=!0):T=R.NumberKeyframeTrack;break;case 2:case 3:T=R.VectorKeyframeTrack;break;case 4:o.endsWith(".quaternion")?T=R.QuaternionKeyframeTrack:T=R.ColorKeyframeTrack;break}if(!T){console.warn("Unsupported output accessor format",n);return}const v=i.interpolation!==void 0?$f[i.interpolation]:R.InterpolateLinear;let b=x._getArrayFromAccessor(n);o.endsWith(".fov")&&(b=b.map(w=>w/Math.PI*180)),g&&(b=b.map(w=>w>0));const _=new T(o,t.array,b,v);if(v==="CUBICSPLINE"&&x._createCubicSplineTrackInterpolant(_),c.push(_),o&&n.itemSize===4&&o.startsWith(".materials.")&&o.endsWith(".color")){const w=new Float32Array(b.length/4);for(let P=0,E=b.length/4;P<E;P+=1)w[P]=b[P*4+3];const C=new T(o.replace(".color",".opacity"),t.array,w,v);v==="CUBICSPLINE"&&x._createCubicSplineTrackInterpolant(_),c.push(C)}}return c}_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=[],f=[];for(let p=0,m=s.channels.length;p<m;p++){const x=s.channels[p],T=s.samplers[x.sampler],g=x.target,v=s.parameters!==void 0?s.parameters[T.input]:T.input,b=s.parameters!==void 0?s.parameters[T.output]:T.output;let _=t.loadAnimationTargetFromChannelWithAnimationPointer(x);_||(_=t.loadAnimationTargetFromChannel(x)),o.push(_),c.push(i.getDependency("accessor",v)),l.push(i.getDependency("accessor",b)),u.push(T),f.push(g)}return Promise.all([Promise.all(o),Promise.all(c),Promise.all(l),Promise.all(u),Promise.all(f)]).then(function(p){const m=p[0],x=p[1],T=p[2],g=p[3],v=p[4],b=[];for(let _=0,w=m.length;_<w;_++){const C=m[_],P=x[_],E=T[_],I=g[_],O=v[_];if(C===void 0)continue;C.updateMatrix&&(C.updateMatrix(),C.matrixAutoUpdate=!0);let A=t.createAnimationTracksWithAnimationPointer(C,P,E,I,O);if(A||(A=i._createAnimationTracks(C,P,E,I,O)),A)for(let N=0;N<A.length;N++)b.push(A[N])}return new R.AnimationClip(a,void 0,b)})}}let La=!1,Hf=null;function qf(){if(La)return;La=!0;const r=Hf||=R.PropertyBinding.findNode;R.PropertyBinding.findNode=function(e,t){if(!t)return r(e,t);if(t.startsWith(".materials.")){const n=t.substring(11).substring(t.indexOf(".")),i=n.indexOf("."),s=i<0?n:n.substring(0,i);let a=null;return e.traverse(o=>{a!==null||o.type!=="Mesh"&&o.type!=="SkinnedMesh"||o.material&&(o.material.uuid===s||o.material.name===s)&&(a=o.material,a!==null&&(n.endsWith(".map")?a=a.map:n.endsWith(".emissiveMap")&&(a=a.emissiveMap)))}),a}else if(t.startsWith(".nodes.")||t.startsWith(".lights.")||t.startsWith(".cameras.")){const n=t.split(".");let i;for(let s=1;s<n.length;s++){const a=n[s];if(a.length==36)i=e.getObjectByProperty("uuid",a);else if(i&&i[a]){const c=Number.parseInt(a);let l=a;c>=0&&(l=c),i=i[l]}else{const c=e.getObjectByName(a);c&&(i=c)}}if(!i){const s=r(e,n[2]);return s||console.warn(hn+": Property binding not found",t,e,e.name,n),s}return i}return r(e,t)}}const Xf=Object.freeze(Object.defineProperty({__proto__:null,GLTFAnimationPointerExtension:Wf},Symbol.toStringTag,{value:"Module"}));exports.$70d766613f57b014$export$2e2bcd8739ae039=kc;exports.BatchedParticleRenderer=xh;exports.Builder=to;exports.ByteBuffer=si;exports.ConstantColor=pn;exports.ConstantValue=ee;exports.Matrix4=Ct;exports.MeshBVH=Vi;exports.MotionController=gl;exports.ParticleSystem=Ir;exports.SIZE_PREFIX_LENGTH=Ja;exports.TrailParticle=Or;exports.Vector4=Qe;exports.WorkerBase=Gf;exports.bundler=Xl;exports.createNoise4D=bh;exports.fetchProfile=fl;exports.index=Eh;exports.index$1=jf;exports.index$2=Xf;exports.md5=hu;exports.v5=ou;
|
|
1121
|
+
}`;class Sh extends Nc{constructor(e){super(e),this.vector_=new $,this.vector2_=new $,this.vector3_=new $,this.quaternion_=new ne,this.maxParticles=1e4,this.setupBuffers(),this.rebuildMaterial()}setupBuffers(){this.geometry&&this.geometry.dispose(),this.geometry=new R.BufferGeometry,this.indexBuffer=new R.BufferAttribute(new Uint32Array(this.maxParticles*6),1),this.indexBuffer.setUsage(R.DynamicDrawUsage),this.geometry.setIndex(this.indexBuffer),this.positionBuffer=new R.BufferAttribute(new Float32Array(this.maxParticles*6),3),this.positionBuffer.setUsage(R.DynamicDrawUsage),this.geometry.setAttribute("position",this.positionBuffer),this.previousBuffer=new R.BufferAttribute(new Float32Array(this.maxParticles*6),3),this.previousBuffer.setUsage(R.DynamicDrawUsage),this.geometry.setAttribute("previous",this.previousBuffer),this.nextBuffer=new R.BufferAttribute(new Float32Array(this.maxParticles*6),3),this.nextBuffer.setUsage(R.DynamicDrawUsage),this.geometry.setAttribute("next",this.nextBuffer),this.widthBuffer=new R.BufferAttribute(new Float32Array(this.maxParticles*2),1),this.widthBuffer.setUsage(R.DynamicDrawUsage),this.geometry.setAttribute("width",this.widthBuffer),this.sideBuffer=new R.BufferAttribute(new Float32Array(this.maxParticles*2),1),this.sideBuffer.setUsage(R.DynamicDrawUsage),this.geometry.setAttribute("side",this.sideBuffer),this.uvBuffer=new R.BufferAttribute(new Float32Array(this.maxParticles*4),2),this.uvBuffer.setUsage(R.DynamicDrawUsage),this.geometry.setAttribute("uv",this.uvBuffer),this.colorBuffer=new R.BufferAttribute(new Float32Array(this.maxParticles*8),4),this.colorBuffer.setUsage(R.DynamicDrawUsage),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 On(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=Gs(this.settings.material.map.channel),e.map=new R.Uniform$1(this.settings.material.map),e.mapTransform=new R.Uniform$1(new At().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===exports.RenderMode.Trail)this.material=new R.ShaderMaterial({uniforms:e,defines:t,vertexShader:vh,fragmentShader:gh,transparent:this.settings.material.transparent,depthWrite:!this.settings.material.transparent,side:this.settings.material.side,blending:this.settings.material.blending||R.AdditiveBlending,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,f=this.settings.vTileCount,p=1/u,m=1/f;for(let x=0;x<l;x++){const T=c[x],g=T.uvTile%f,v=Math.floor(T.uvTile/f+.001),b=T.previous.values();let _=b.next(),w=_.value,C=w;_.done||(_=b.next());let P;_.value!==void 0?P=_.value:P=C;for(let E=0;E<T.previous.length;E++,e+=2){if(this.positionBuffer.setXYZ(e,C.position.x,C.position.y,C.position.z),this.positionBuffer.setXYZ(e+1,C.position.x,C.position.y,C.position.z),i.worldSpace?(this.positionBuffer.setXYZ(e,C.position.x,C.position.y,C.position.z),this.positionBuffer.setXYZ(e+1,C.position.x,C.position.y,C.position.z)):(T.parentMatrix?this.vector_.copy(C.position).applyMatrix4(T.parentMatrix):this.vector_.copy(C.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,w.position.x,w.position.y,w.position.z),this.previousBuffer.setXYZ(e+1,w.position.x,w.position.y,w.position.z)):(T.parentMatrix?this.vector_.copy(w.position).applyMatrix4(T.parentMatrix):this.vector_.copy(w.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)):(T.parentMatrix?this.vector_.copy(P.position).applyMatrix4(T.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,C.size),this.widthBuffer.setX(e+1,C.size);else if(T.parentMatrix)this.widthBuffer.setX(e,C.size),this.widthBuffer.setX(e+1,C.size);else{const I=(Math.abs(o.x)+Math.abs(o.y)+Math.abs(o.z))/3;this.widthBuffer.setX(e,C.size*I),this.widthBuffer.setX(e+1,C.size*I)}this.uvBuffer.setXY(e,(E/T.previous.length+g)*p,(f-v-1)*m),this.uvBuffer.setXY(e+1,(E/T.previous.length+g)*p,(f-v)*m),this.colorBuffer.setXYZW(e,C.color.x,C.color.y,C.color.z,C.color.w),this.colorBuffer.setXYZW(e+1,C.color.x,C.color.y,C.color.z,C.color.w),E+1<T.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++),w=C,C=P,_.done||(_=b.next(),_.value!==void 0&&(P=_.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 Di{get geometry(){return this._geometry}set geometry(e){if(this._geometry=e,e===void 0||typeof e=="string")return;const t=new R.Triangle;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 R.Vector3,this._tempB=new R.Vector3,this._tempC=new R.Vector3,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],f=t.getIndex().array[i*3+2],p=t.getAttribute("position");this._tempA.fromBufferAttribute(p,l),this._tempB.fromBufferAttribute(p,u),this._tempC.fromBufferAttribute(p,f),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 Di(t.geometries[e.geometry])}clone(){return new Di(this._geometry)}update(e,t){}}Yu({id:"three.quarks",emitterShapes:[{type:"mesh_surface",params:[["geometry",["geometry"]]],constructor:Di,loadJSON:Di.fromJSON}],behaviors:[]});class lo extends R.Object3D{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(lo.equals(this.batches[i].settings,t)){this.batches[i].addSystem(e),this.systemToBatchIndex.set(e,i);return}let n;switch(t.renderMode){case exports.RenderMode.Trail:n=new Sh(t);break;case exports.RenderMode.Mesh:case exports.RenderMode.BillBoard:case exports.RenderMode.VerticalBillBoard:case exports.RenderMode.HorizontalBillBoard:case exports.RenderMode.StretchedBillBoard:n=new yh(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 xh=lo;sh();console.log("%c Particle system powered by three.quarks. https://quarks.art/","font-size: 14px; font-weight: bold;");const Uc=Math.sqrt(5),_h=(Uc-1)/4,ze=(5-Uc)/20,nr=r=>Math.floor(r)|0,ir=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 bh(r=Math.random){const e=Th(r),t=new Float64Array(e).map(a=>ir[a%32*4]),n=new Float64Array(e).map(a=>ir[a%32*4+1]),i=new Float64Array(e).map(a=>ir[a%32*4+2]),s=new Float64Array(e).map(a=>ir[a%32*4+3]);return function(o,c,l,u){let f,p,m,x,T;const g=(o+c+l+u)*_h,v=nr(o+g),b=nr(c+g),_=nr(l+g),w=nr(u+g),C=(v+b+_+w)*ze,P=v-C,E=b-C,I=_-C,O=w-C,A=o-P,N=c-E,B=l-I,D=u-O;let L=0,J=0,W=0,Y=0;A>N?L++:J++,A>B?L++:W++,A>D?L++:Y++,N>B?J++:W++,N>D?J++:Y++,B>D?W++:Y++;const G=L>=3?1:0,se=J>=3?1:0,ce=W>=3?1:0,me=Y>=3?1:0,le=L>=2?1:0,xe=J>=2?1:0,Ce=W>=2?1:0,ye=Y>=2?1:0,de=L>=1?1:0,oe=J>=1?1:0,et=W>=1?1:0,We=Y>=1?1:0,He=A-G+ze,tt=N-se+ze,Ae=B-ce+ze,pe=D-me+ze,ie=A-le+2*ze,st=N-xe+2*ze,we=B-Ce+2*ze,ue=D-ye+2*ze,qe=A-de+3*ze,mt=N-oe+3*ze,yt=B-et+3*ze,Xe=D-We+3*ze,gt=A-1+4*ze,ot=N-1+4*ze,at=B-1+4*ze,vt=D-1+4*ze,Pe=v&255,Ve=b&255,nt=_&255,Je=w&255;let Q=.6-A*A-N*N-B*B-D*D;if(Q<0)f=0;else{const ae=Pe+e[Ve+e[nt+e[Je]]];Q*=Q,f=Q*Q*(t[ae]*A+n[ae]*N+i[ae]*B+s[ae]*D)}let St=.6-He*He-tt*tt-Ae*Ae-pe*pe;if(St<0)p=0;else{const ae=Pe+G+e[Ve+se+e[nt+ce+e[Je+me]]];St*=St,p=St*St*(t[ae]*He+n[ae]*tt+i[ae]*Ae+s[ae]*pe)}let zt=.6-ie*ie-st*st-we*we-ue*ue;if(zt<0)m=0;else{const ae=Pe+le+e[Ve+xe+e[nt+Ce+e[Je+ye]]];zt*=zt,m=zt*zt*(t[ae]*ie+n[ae]*st+i[ae]*we+s[ae]*ue)}let xt=.6-qe*qe-mt*mt-yt*yt-Xe*Xe;if(xt<0)x=0;else{const ae=Pe+de+e[Ve+oe+e[nt+et+e[Je+We]]];xt*=xt,x=xt*xt*(t[ae]*qe+n[ae]*mt+i[ae]*yt+s[ae]*Xe)}let It=.6-gt*gt-ot*ot-at*at-vt*vt;if(It<0)T=0;else{const ae=Pe+1+e[Ve+1+e[nt+1+e[Je+1]]];It*=It,T=It*It*(t[ae]*gt+n[ae]*ot+i[ae]*at+s[ae]*vt)}return 27*(f+p+m+x+T)}}function Th(r){const t=new Uint8Array(512);for(let n=0;n<512/2;n++)t[n]=n;for(let n=0;n<512/2-1;n++){const i=n+~~(r()*(256-n)),s=t[n];t[n]=t[i],t[i]=s}for(let n=256;n<512;n++)t[n]=t[n-256];return t}var Mh=Object.defineProperty,Ch=(r,e,t)=>e in r?Mh(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Te=(r,e,t)=>(Ch(r,typeof e!="symbol"?e+"":e,t),t);(function(){class r{}class e extends r{constructor(d){super(),Te(this,"value"),this.value=d}}class t extends r{constructor(d){super(),Te(this,"value"),this.value=d}}class n extends r{constructor(d){super(),Te(this,"value"),this.value=d}}class i extends r{constructor(d,y="unrestricted"){super(),Te(this,"type"),Te(this,"value"),this.value=d,this.type=y}}class s extends r{constructor(d){super(),Te(this,"value"),this.value=d}}class a extends r{}class o extends r{constructor(d){super(),Te(this,"value"),this.value=d}}class c extends r{}class l extends r{constructor(d){super(),Te(this,"value"),this.value=d}}class u extends r{constructor(d,y="integer"){super(),Te(this,"value"),Te(this,"type"),this.value=d,this.type=y}}class f extends r{constructor(d){super(),Te(this,"value"),this.value=d}}class p extends r{constructor(d,y,S){super(),Te(this,"value"),Te(this,"type"),Te(this,"unit"),this.value=d,this.type=y,this.unit=S}}class m extends r{}class x extends r{}class T extends r{}class g extends r{}class v extends r{}class b extends r{}class _ extends r{}class w extends r{}class C extends r{}class P extends r{}class E extends r{}class I extends r{}class O{constructor(d){Te(this,"input"),Te(this,"index",0),this.input=d}consume(){const d=this.input.codePointAt(this.index);return d!==void 0&&(this.index+=String.fromCodePoint(d).length),d}reconsume(d){d!==void 0&&(this.index-=String.fromCodePoint(d).length)}peek(){const d=[];let y=this.index;for(let S=0;S<3&&y<this.input.length;S++){const M=this.input.codePointAt(y);d.push(M),y+=String.fromCodePoint(M).length}return d}}function A(h){return h===10}function N(h){return A(h)||h===8192||h===32}function B(h){return h>=48&&h<=57}function D(h){return B(h)||h>=65&&h<=70||h>=97&&h<=102}function L(h){return(function(d){return(function(y){return y>=65&&y<=90})(d)||(function(y){return y>=97&&y<=122})(d)})(h)||(function(d){return d>=128})(h)||h===95}function J(h){return L(h)||B(h)||h===45}function W(h){return h>=0&&h<=8||h===11||h>=14&&h<=31||h===127}function Y(h,d){return h===92&&!A(d)}function G(h,d,y){return h===45?L(d)||d===45||Y(d,y):!!L(h)||h===92&&Y(h,d)}function se(h,d,y){return h===43||h===45?B(d)||d===46&&B(y):B(h===46?d:h)}function ce(h){const d=h.consume();if(D(d)){let y=[d];for(;D(...h.peek())&&y.length<5;)y.push(h.consume());N(...h.peek())&&h.consume();const S=parseInt(String.fromCodePoint(...y),16);return S===0||S>1114111?65533:S}return d===void 0?65533:d}function me(h,d){const y=new s("");for(;;){const S=h.consume();if(S===d||S===void 0)return y;if(S===10)return h.reconsume(S),new a;if(S===92){const M=h.peek()[0];M===void 0||(A(M)?h.consume():y.value+=String.fromCodePoint(ce(h)))}else y.value+=String.fromCodePoint(S)}}function le(h){let d="";for(;;){const y=h.consume();if(J(y))d+=String.fromCodePoint(y);else{if(!Y(...h.peek()))return h.reconsume(y),d;d+=String.fromCodePoint(ce(h))}}}function xe(h){let d=(function(y){let S="integer",M="";for([43,45].includes(y.peek()[0])&&(M+=String.fromCodePoint(y.consume()));B(...y.peek());)M+=String.fromCodePoint(y.consume());if(y.peek()[0]===46&&B(y.peek()[1]))for(M+=String.fromCodePoint(y.consume(),y.consume()),S="number";B(...y.peek());)M+=String.fromCodePoint(y.consume());return[69,101].includes(y.peek()[0])&&([45,43].includes(y.peek()[1])&&B(y.peek()[2])?(M+=String.fromCodePoint(y.consume(),y.consume(),y.consume()),S="number"):B(y.peek()[1])&&(M+=String.fromCodePoint(y.consume(),y.consume()),S="number")),{value:parseFloat(M),type:S}})(h);return G(...h.peek())?new p(d.value,d.type,le(h)):h.peek()[0]===37?(h.consume(),new f(d.value)):new u(d.value,d.type)}function Ce(h){for(;;){const d=h.consume();if(d===41||d===void 0)return;Y(...h.peek())&&ce(h)}}function ye(h){const d=le(h);if(d.match(/url/i)&&h.peek()[0]===40){for(h.consume();N(h.peek()[0])&&N(h.peek()[1]);)h.consume();return[34,39].includes(h.peek()[0])||N(h.peek()[0])&&[34,39].includes(h.peek()[1])?new t(d):(function(y){const S=new o("");for(;N(...y.peek());)y.consume();for(;;){const M=y.consume();if(M===41||M===void 0)return S;if(N(M)){for(;N(...y.peek());)y.consume();return y.peek()[0]===41||y.peek()[0]===void 0?(y.consume(),S):(Ce(y),new c)}if([34,39,40].includes(M)||W(M))return Ce(y),new c;if(M===92){if(!Y(...y.peek()))return Ce(y),new c;S.value+=ce(y)}else S.value+=String.fromCodePoint(M)}})(h)}return h.peek()[0]===40?(h.consume(),new t(d)):new e(d)}function de(h){const d=h.consume(),y=h.peek();if(N(d)){for(;N(...h.peek());)h.consume();return new m}if(d===34)return me(h,d);if(d===35){if(J(y[0])||Y(...y)){const S=new i;return G(...y)&&(S.type="id"),S.value=le(h),S}return new l(String.fromCodePoint(d))}return d===39?me(h,d):d===40?new C:d===41?new P:d===43?se(...y)?(h.reconsume(d),xe(h)):new l(String.fromCodePoint(d)):d===44?new b:d===45?se(...h.peek())?(h.reconsume(d),xe(h)):h.peek()[0]===45&&h.peek()[1]===62?(h.consume(),h.consume(),new T):G(...h.peek())?(h.reconsume(d),ye(h)):new l(String.fromCodePoint(d)):d===46?se(...h.peek())?(h.reconsume(d),xe(h)):new l(String.fromCodePoint(d)):d===58?new g:d===59?new v:d===60?y[0]===33&&y[1]===45&&y[2]===45?(h.consume(),h.consume(),h.consume(),new x):new l(String.fromCodePoint(d)):d===64?G(...y)?new n(le(h)):new l(String.fromCodePoint(d)):d===91?new _:d===92?Y(...y)?(h.reconsume(d),ye(h)):new l(String.fromCodePoint(d)):d===93?new w:d===123?new E:d===125?new I:B(d)?(h.reconsume(d),xe(h)):L(d)?(h.reconsume(d),ye(h)):d===void 0?void 0:new l(String.fromCodePoint(d))}const oe=new Set(["px","deg","s","hz","dppx","number","fr"]);function et(h){return oe.has(h.toLowerCase())}function We(h,d){if(["x","y"].includes(h))return h;if(!d)throw new Error("To determine the normalized axis the computedStyle of the source is required.");const y=d.writingMode=="horizontal-tb";if(h==="block")h=y?"y":"x";else{if(h!=="inline")throw new TypeError(`Invalid axis “${h}”`);h=y?"x":"y"}return h}function He(h){const d=[];let y=0;function S(){let k=0;const z=y;for(;y<h.length;){const F=h.slice(y,y+1);if(/\s/.test(F)&&k===0)break;if(F==="(")k+=1;else if(F===")"&&(k-=1,k===0)){y++;break}y++}return h.slice(z,y)}function M(){for(;/\s/.test(h.slice(y,y+1));)y++}for(;y<h.length;){const k=h.slice(y,y+1);/\s/.test(k)?M():d.push(S())}return d}function tt(h,d){return h.reduce(((y,S)=>(y.has(S[d])?y.get(S[d]).push(S):y.set(S[d],[S]),y)),new Map)}function Ae(h,d){const y=[],S=[];for(const M of h)d(M)?y.push(M):S.push(M);return[y,S]}function pe(h,d={}){function y(S){return Array.from(S).map((M=>pe(M,d)))}if(h instanceof CSSUnitValue){if(h.unit==="percent"&&d.percentageReference){const M=h.value/100*d.percentageReference.value,k=d.percentageReference.unit;return new CSSUnitValue(M,k)}const S=h.toSum();if(S&&S.values.length===1&&(h=S.values[0]),h instanceof CSSUnitValue&&h.unit==="em"&&d.fontSize&&(h=new CSSUnitValue(h.value*d.fontSize.value,d.fontSize.unit)),h instanceof CSSKeywordValue){if(h.value==="e")return new CSSUnitValue(Math.E,"number");if(h.value==="pi")return new CSSUnitValue(Math.PI,"number")}return h}if(!h.operator)return h;switch(h.operator){case"sum":h=new CSSMathSum(...y(h.values));break;case"product":h=new CSSMathProduct(...y(h.values));break;case"negate":h=new CSSMathNegate(pe(h.value,d));break;case"clamp":h=new CSSMathClamp(pe(h.lower,d),pe(h.value,d),pe(h.upper,d));break;case"invert":h=new CSSMathInvert(pe(h.value,d));break;case"min":h=new CSSMathMin(...y(h.values));break;case"max":h=new CSSMathMax(...y(h.values))}if(h instanceof CSSMathMin||h instanceof CSSMathMax){const S=Array.from(h.values);if(S.every((M=>M instanceof CSSUnitValue&&M.unit!=="percent"&&et(M.unit)&&M.unit===S[0].unit))){const M=Math[h.operator].apply(Math,S.map((({value:k})=>k)));return new CSSUnitValue(M,S[0].unit)}}if(h instanceof CSSMathMin||h instanceof CSSMathMax){const S=Array.from(h.values),[M,k]=Ae(S,(F=>F instanceof CSSUnitValue&&F.unit!=="percent")),z=Array.from(tt(M,"unit").values());if(z.some((F=>F.length>0))){const F=z.map((U=>{const V=Math[h.operator].apply(Math,U.map((({value:H})=>H)));return new CSSUnitValue(V,U[0].unit)}));h=h instanceof CSSMathMin?new CSSMathMin(...F,...k):new CSSMathMax(...F,...k)}return S.length===1?S[0]:h}if(h instanceof CSSMathNegate)return h.value instanceof CSSUnitValue?new CSSUnitValue(0-h.value.value,h.value.unit):h.value instanceof CSSMathNegate?h.value.value:h;if(h instanceof CSSMathInvert)return h.value instanceof CSSMathInvert?h.value.value:h;if(h instanceof CSSMathSum){let S=function(k){const z=k.filter((F=>F instanceof CSSUnitValue));return[...k.filter((F=>!(F instanceof CSSUnitValue))),...Array.from(tt(z,"unit").entries()).map((([F,U])=>{const V=U.reduce(((H,{value:X})=>H+X),0);return new CSSUnitValue(V,F)}))]},M=[];for(const k of h.values)k instanceof CSSMathSum?M.push(...k.values):M.push(k);return M=S(M),M.length===1?M[0]:new CSSMathSum(...M)}if(h instanceof CSSMathProduct){let S=[];for(const z of h.values)z instanceof CSSMathProduct?S.push(...z.values):S.push(z);const[M,k]=Ae(S,(z=>z instanceof CSSUnitValue&&z.unit==="number"));if(M.length>1){const z=M.reduce(((F,{value:U})=>F*U),1);S=[new CSSUnitValue(z,"number"),...k]}if(S.length===2){let z,F;for(const U of S)U instanceof CSSUnitValue&&U.unit==="number"?z=U:U instanceof CSSMathSum&&[...U.values].every((V=>V instanceof CSSUnitValue))&&(F=U);if(z&&F)return new CSSMathSum(...[...F.values].map((U=>new CSSUnitValue(U.value*z.value,U.unit))))}if(S.every((z=>z instanceof CSSUnitValue&&et(z.unit)||z instanceof CSSMathInvert&&z.value instanceof CSSUnitValue&&et(z.value.unit)))){const z=new CSSMathProduct(...S).toSum();if(z&&z.values.length===1)return z.values[0]}return new CSSMathProduct(...S)}return h}const ie=null,st=["percent","length","angle","time","frequency","resolution","flex"],we={fontRelativeLengths:{units:new Set(["em","rem","ex","rex","cap","rcap","ch","rch","ic","ric","lh","rlh"])},viewportRelativeLengths:{units:new Set(["vw","lvw","svw","dvw","vh","lvh","svh","dvh","vi","lvi","svi","dvi","vb","lvb","svb","dvb","vmin","lvmin","svmin","dvmin","vmax","lvmax","svmax","dvmax"])},absoluteLengths:{units:new Set(["cm","mm","Q","in","pt","pc","px"]),compatible:!0,canonicalUnit:"px",ratios:{cm:96/2.54,mm:96/2.54/10,Q:96/2.54/40,in:96,pc:16,pt:96/72,px:1}},angle:{units:new Set(["deg","grad","rad","turn"]),compatible:!0,canonicalUnit:"deg",ratios:{deg:1,grad:.9,rad:180/Math.PI,turn:360}},time:{units:new Set(["s","ms"]),compatible:!0,canonicalUnit:"s",ratios:{s:1,ms:.001}},frequency:{units:new Set(["hz","khz"]),compatible:!0,canonicalUnit:"hz",ratios:{hz:1,khz:1e3}},resolution:{units:new Set(["dpi","dpcm","dppx"]),compatible:!0,canonicalUnit:"dppx",ratios:{dpi:1/96,dpcm:2.54/96,dppx:1}}},ue=new Map;for(const h of Object.values(we))if(h.compatible)for(const d of h.units)ue.set(d,h);function qe(h){return ue.get(h)}function mt(h,d){const y={...h};for(const S of Object.keys(d))y[S]?y[S]+=d[S]:y[S]=d[S];return y}function yt(h){return h==="number"?{}:h==="percent"?{percent:1}:we.absoluteLengths.units.has(h)||we.fontRelativeLengths.units.has(h)||we.viewportRelativeLengths.units.has(h)?{length:1}:we.angle.units.has(h)?{angle:1}:we.time.units.has(h)?{time:1}:we.frequency.units.has(h)?{frequency:1}:we.resolution.units.has(h)?{resolution:1}:h==="fr"?{flex:1}:ie}function Xe(h){if(h instanceof CSSUnitValue){let{unit:d,value:y}=h;const S=qe(h.unit);return S&&d!==S.canonicalUnit&&(y*=S.ratios[d],d=S.canonicalUnit),d==="number"?[[y,{}]]:[[y,{[d]:1}]]}if(h instanceof CSSMathInvert){if(!(h.value instanceof CSSUnitValue))throw new Error("Not implemented");const d=Xe(h.value);if(d===ie||d.length>1)return ie;const y=d[0],S={};for(const[M,k]of Object.entries(y[1]))S[M]=-1*k;return d[0]=[1/y[0],S],d}if(h instanceof CSSMathProduct){let d=[[1,{}]];for(const y of h.values){const S=Xe(y),M=[];if(S===ie)return ie;for(const k of d)for(const z of S)M.push([k[0]*z[0],mt(k[1],z[1])]);d=M}return d}throw new Error("Not implemented")}function gt(h,d){if(yt(d)===ie)throw new SyntaxError("The string did not match the expected pattern.");const y=Xe(h);if(!y)throw new TypeError;if(y.length>1)throw new TypeError("Sum has more than one item");const S=(function(M,k){const z=M.unit,F=M.value,U=qe(z),V=qe(k);return!V||U!==V?ie:new CSSUnitValue(F*V.ratios[z]/V.ratios[k],k)})(ot(y[0]),d);if(S===ie)throw new TypeError;return S}function ot(h){const[d,y]=h,S=Object.entries(y);if(S.length>1)return ie;if(S.length===0)return new CSSUnitValue(d,"number");const M=S[0];return M[1]!==1?ie:new CSSUnitValue(d,M[0])}function at(h,...d){if(d&&d.length)throw new Error("Not implemented");const y=Xe(h).map((S=>ot(S)));if(y.some((S=>S===ie)))throw new TypeError("Type error");return new CSSMathSum(...y)}function vt(h,d){if(h.percentHint&&d.percentHint&&h.percentHint!==d.percentHint)return ie;const y={...h,percentHint:h.percentHint??d.percentHint};for(const S of st)d[S]&&(y[S]??(y[S]=0),y[S]+=d[S]);return y}class Pe{constructor(d,y){Te(this,"name"),Te(this,"values"),this.name=d,this.values=y}}class Ve{constructor(d,y){Te(this,"value"),Te(this,"associatedToken"),this.value=d,this.associatedToken=y}}function nt(h){if(Array.isArray(h))return h;if(typeof h=="string")return(function(d){const y=new O(d),S=[];for(;;){const M=de(y);if(M===void 0)return S;S.push(M)}})(h);throw new TypeError("Invalid input type "+typeof h)}function Je(h){const d=h.shift();return d instanceof E||d instanceof _||d instanceof C?(function(y,S){let M;if(S instanceof E)M=I;else if(S instanceof C)M=P;else{if(!(S instanceof _))return;M=w}const k=new Ve([],S);for(;;){const z=y.shift();if(z instanceof M||z===void 0)return k;y.unshift(z),k.value.push(Je(y))}})(h,d):d instanceof t?(function(y,S){const M=new Pe(y.value,[]);for(;;){const k=S.shift();if(k instanceof P||k===void 0)return M;S.unshift(k),M.values.push(Je(S))}})(d,h):d}function Q(h){if(h instanceof C||h instanceof P)return 6;if(h instanceof l)switch(h.value){case"*":case"/":return 4;case"+":case"-":return 2}}function St(h){return h[h.length-1]}function zt(h,d,y){const S=["+","-"].includes(h.value)?"ADDITION":"MULTIPLICATION",M=d.type===S?d.values:[d],k=y.type===S?y.values:[y];return h.value==="-"?k[0]={type:"NEGATE",value:k[0]}:h.value==="/"&&(k[0]={type:"INVERT",value:k[0]}),{type:S,values:[...M,...k]}}function xt(h){if(h.type==="ADDITION")return new CSSMathSum(...h.values.map((d=>xt(d))));if(h.type==="MULTIPLICATION")return new CSSMathProduct(...h.values.map((d=>xt(d))));if(h.type==="NEGATE")return new CSSMathNegate(xt(h.value));if(h.type==="INVERT")return new CSSMathInvert(xt(h.value));if(h instanceof Ve)return It(new Pe("calc",h.value));if(h instanceof e){if(h.value==="e")return new CSSUnitValue(Math.E,"number");if(h.value==="pi")return new CSSUnitValue(Math.PI,"number");throw new SyntaxError("Invalid math expression")}return ae(h)}function It(h){if(h.name==="min"||h.name==="max"){const S=h.values.filter((M=>!(M instanceof m||M instanceof b))).map((M=>pe(It(new Pe("calc",M)))));return h.name==="min"?new CSSMathMin(...S):new CSSMathMax(...S)}if(h.name!=="calc")return null;const d=xt((function(S){const M=[],k=[];for(;S.length;){const z=S.shift();if(z instanceof u||z instanceof p||z instanceof f||z instanceof Pe||z instanceof Ve||z instanceof e)k.push(z);else if(z instanceof l&&["*","/","+","-"].includes(z.value)){for(;M.length&&!(St(M)instanceof C)&&Q(St(M))>Q(z);){const F=M.pop(),U=k.pop(),V=k.pop();k.push(zt(F,V,U))}M.push(z)}else if(z instanceof C)M.push(z);else if(z instanceof P){if(!M.length)return null;for(;!(St(M)instanceof C);){const F=M.pop(),U=k.pop(),V=k.pop();k.push(zt(F,V,U))}if(!(St(M)instanceof C))return null;M.pop()}else if(!(z instanceof m))return null}for(;M.length;){if(St(M)instanceof C)return null;const z=M.pop(),F=k.pop(),U=k.pop();k.push(zt(z,U,F))}return k[0]})([...h.values]));let y;try{y=pe(d)}catch{new CSSStyleSheet().insertRule("error",0)}return y instanceof CSSUnitValue?new CSSMathSum(y):y}function ae(h){return h instanceof Pe&&["calc","min","max","clamp"].includes(h.name)?It(h):h instanceof u&&h.value===0&&!h.unit?new CSSUnitValue(0,"px"):h instanceof u?new CSSUnitValue(h.value,"number"):h instanceof f?new CSSUnitValue(h.value,"percent"):h instanceof p?new CSSUnitValue(h.value,h.unit):void 0}function Hc(h){const d=(function(y){const S=nt(y);for(;S[0]instanceof m;)S.shift();if(S[0]===void 0)return null;const M=Je(S);for(;S[0]instanceof m;)S.shift();return S[0]===void 0?M:null})(h);return d===null&&new CSSStyleSheet().insertRule("error",0),d instanceof u||d instanceof f||d instanceof p||d instanceof Pe||new CSSStyleSheet().insertRule("error",0),d instanceof p&&yt(d.unit)===null&&new CSSStyleSheet().insertRule("error",0),ae(d)}(function(){let h=new WeakMap;function d(k){const z=[];for(let U=0;U<k.length;U++)z[U]=typeof(F=k[U])=="number"?new CSSUnitValue(F,"number"):F;var F;return z}class y{static parse(z){return z instanceof y?z:pe(Hc(z),{})}}class S extends y{constructor(z,F,U,V){super(),h.set(this,{values:d(z),operator:F,name:U||F,delimiter:V||", "})}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 M={CSSNumericValue:y,CSSMathValue:S,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 gt(this,k)}toSum(...k){return at(this,...k)}type(){return yt(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 S{constructor(k){super(arguments,"sum","calc"," + ")}},CSSMathProduct:class extends S{constructor(k){super(arguments,"product","calc"," * ")}toSum(...k){return at(this,...k)}type(){return h.get(this).values.map((k=>k.type())).reduce(vt)}},CSSMathNegate:class extends S{constructor(k){super([arguments[0]],"negate","-")}get value(){return h.get(this).values[0]}type(){return this.value.type()}},CSSMathInvert:class extends S{constructor(k){super([1,arguments[0]],"invert","calc"," / ")}get value(){return h.get(this).values[1]}type(){return(function(k){const z={};for(const F of st)z[F]=-1*k[F];return z})(h.get(this).values[1].type())}},CSSMathMax:class extends S{constructor(){super(arguments,"max")}},CSSMathMin:class extends S{constructor(){super(arguments,"min")}}};if(!window.CSS&&!Reflect.defineProperty(window,"CSS",{value:{}}))throw Error("Error installing CSSOM support");window.CSSUnitValue||["number","percent","em","ex","px","cm","mm","in","pt","pc","Q","vw","vh","vmin","vmax","rems","ch","deg","rad","grad","turn","ms","s","Hz","kHz","dppx","dpi","dpcm","fr"].forEach((k=>{if(!Reflect.defineProperty(CSS,k,{value:z=>new CSSUnitValue(z,k)}))throw Error(`Error installing CSS.${k}`)}));for(let[k,z]of Object.entries(M))if(!(k in window)&&!Reflect.defineProperty(window,k,{value:z}))throw Error(`Error installing CSSOM support for ${k}`)})();const po="block";let Ue=new WeakMap,Bt=new WeakMap;const Ji=["entry","exit","cover","contain","entry-crossing","exit-crossing"];function mo(h){return h===document.scrollingElement?document:h}function en(h){jr(h);let d=Ue.get(h).animations;if(d.length===0)return;let y=h.currentTime;for(let S=0;S<d.length;S++)d[S].tickAnimation(y)}function yo(h,d){if(!h)return null;const y=Bt.get(h).sourceMeasurements,S=getComputedStyle(h);let M=y.scrollTop;return We(d,S)==="x"&&(M=Math.abs(y.scrollLeft)),M}function Jr(h,d){const y=pe(h,d);if(y instanceof CSSUnitValue){if(y.unit==="px")return y.value;throw TypeError("Unhandled unit type "+y.unit)}throw TypeError("Unsupported value type: "+typeof h)}function jr(h){if(!(h instanceof vn))return void(function(y){const S=Ue.get(y);if(!S.anonymousSource)return;const M=vo(S.anonymousSource,S.anonymousTarget);gn(y,M)})(h);const d=h.subject;if(!d||getComputedStyle(d).display=="none")return void gn(h,null);gn(h,Xr(d))}function go(h){return["block","inline","x","y"].includes(h)}function Gr(h){const d=getComputedStyle(h);return{scrollLeft:h.scrollLeft,scrollTop:h.scrollTop,scrollWidth:h.scrollWidth,scrollHeight:h.scrollHeight,clientWidth:h.clientWidth,clientHeight:h.clientHeight,writingMode:d.writingMode,direction:d.direction,scrollPaddingTop:d.scrollPaddingTop,scrollPaddingBottom:d.scrollPaddingBottom,scrollPaddingLeft:d.scrollPaddingLeft,scrollPaddingRight:d.scrollPaddingRight}}function $r(h,d){if(!h||!d)return;let y=0,S=0,M=d;const k=h.offsetParent;for(;M&&M!=k;)S+=M.offsetLeft,y+=M.offsetTop,M=M.offsetParent;S-=h.offsetLeft+h.clientLeft,y-=h.offsetTop+h.clientTop;const z=getComputedStyle(d);return{top:y,left:S,offsetWidth:d.offsetWidth,offsetHeight:d.offsetHeight,fontSize:z.fontSize}}function ji(h){let d=Bt.get(h);d.sourceMeasurements=Gr(h);for(const y of d.timelineRefs){const S=y.deref();S instanceof vn&&(Ue.get(S).subjectMeasurements=$r(h,S.subject))}d.updateScheduled||(setTimeout((()=>{for(const y of d.timelineRefs){const S=y.deref();S&&en(S)}d.updateScheduled=!1})),d.updateScheduled=!0)}function gn(h,d){const y=Ue.get(h),S=y.source;if(S!=d){if(S){const M=Bt.get(S);if(M){M.timelineRefs.delete(h);const k=Array.from(M.timelineRefs).filter((z=>z.deref()===void 0));for(const z of k)M.timelineRefs.delete(z);M.timelineRefs.size===0&&(M.disconnect(),Bt.delete(S))}}if(y.source=d,d){let M=Bt.get(d);if(!M){M={timelineRefs:new Set,sourceMeasurements:Gr(d)},Bt.set(d,M);const k=new ResizeObserver((U=>{for(const V of U)ji(y.source)}));k.observe(d);for(const U of d.children)k.observe(U);const z=new MutationObserver((U=>{for(const V of U)ji(V.target)}));z.observe(d,{attributes:!0,attributeFilter:["style","class"]});const F=()=>{M.sourceMeasurements.scrollLeft=d.scrollLeft,M.sourceMeasurements.scrollTop=d.scrollTop;for(const U of M.timelineRefs){const V=U.deref();V&&en(V)}};mo(d).addEventListener("scroll",F),M.disconnect=()=>{k.disconnect(),z.disconnect(),mo(d).removeEventListener("scroll",F)}}M.timelineRefs.add(new WeakRef(h))}}}function Wr(h,d){let y=Ue.get(h).animations;for(let S=0;S<y.length;S++)y[S].animation==d&&y.splice(S,1)}function Hr(h,d,y){let S=Ue.get(h).animations;for(let M=0;M<S.length;M++)if(S[M].animation==d)return;S.push({animation:d,tickAnimation:y}),queueMicrotask((()=>{en(h)}))}class je{constructor(d){if(Ue.set(this,{source:null,axis:po,anonymousSource:d?d.anonymousSource:null,anonymousTarget:d?d.anonymousTarget:null,subject:null,inset:null,animations:[],subjectMeasurements:null}),gn(this,d&&d.source!==void 0?d.source:document.scrollingElement),d&&d.axis!==void 0&&d.axis!=po){if(!go(d.axis))throw TypeError("Invalid axis");Ue.get(this).axis=d.axis}en(this)}set source(d){gn(this,d),en(this)}get source(){return Ue.get(this).source}set axis(d){if(!go(d))throw TypeError("Invalid axis");Ue.get(this).axis=d,en(this)}get axis(){return Ue.get(this).axis}get duration(){return CSS.percent(100)}get phase(){const d=this.source;if(!d)return"inactive";let y=getComputedStyle(d);return y.display=="none"?"inactive":d==document.scrollingElement||y.overflow!="visible"&&y.overflow!="clip"?"active":"inactive"}get currentTime(){const y=this.source;if(!y||!y.isConnected||this.phase=="inactive")return null;const S=getComputedStyle(y);if(S.display==="inline"||S.display==="none")return null;const M=this.axis,k=yo(y,M),z=(function(F,U){const V=Bt.get(F).sourceMeasurements,H=getComputedStyle(F).writingMode=="horizontal-tb";return U==="block"?U=H?"y":"x":U==="inline"&&(U=H?"x":"y"),U==="y"?V.scrollHeight-V.clientHeight:U==="x"?V.scrollWidth-V.clientWidth:void 0})(y,M);return z>0?CSS.percent(100*k/z):CSS.percent(100)}get __polyfill(){return!0}}function qr(h,d){let y=h.parentElement;for(;y!=null;){if(d(y))return y;y=y.parentElement}}function vo(h,d){switch(h){case"root":return document.scrollingElement;case"nearest":return Xr(d);case"self":return d;default:throw new TypeError("Invalid ScrollTimeline Source Type.")}}function qc(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 So(h){const d=getComputedStyle(h);return d.transform!="none"||d.perspective!="none"||d.willChange=="transform"||d.willChange=="perspective"||d.filter!="none"||d.willChange=="filter"||d.backdropFilter!="none"}function Xc(h){return getComputedStyle(h).position!="static"||So(h)}function Yc(h){switch(getComputedStyle(h).position){case"static":case"relative":case"sticky":return qr(h,qc);case"absolute":return qr(h,Xc);case"fixed":return qr(h,So)}}function Xr(h){if(h&&h.isConnected){for(;h=Yc(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 Dn(h,d){const y=Ue.get(h),S=y.subjectMeasurements,M=Bt.get(y.source).sourceMeasurements;return h.phase==="inactive"?null:h instanceof vn?Yr(d,M,S,y.axis,y.inset):null}function Yr(h,d,y,S,M){const k=d.direction=="rtl"||d.writingMode=="vertical-rl";let z,F,U={fontSize:y.fontSize};We(S,d)==="x"?(z=y.offsetWidth,F=y.left,U.scrollPadding=[d.scrollPaddingLeft,d.scrollPaddingRight],k&&(F+=d.scrollWidth-d.clientWidth,U.scrollPadding=[d.scrollPaddingRight,d.scrollPaddingLeft]),U.containerSize=d.clientWidth):(z=y.offsetHeight,F=y.top,U.scrollPadding=[d.scrollPaddingTop,d.scrollPaddingBottom],U.containerSize=d.clientHeight);const V=(function(es,qi){const cl={start:0,end:0};if(!es)return cl;const[ll,ul]=[es.start,es.end].map(((Io,Bo)=>Io==="auto"?qi.scrollPadding[Bo]==="auto"?0:parseFloat(qi.scrollPadding[Bo]):Jr(Io,{percentageReference:CSS.px(qi.containerSize),fontSize:CSS.px(parseFloat(qi.fontSize))})));return{start:ll,end:ul}})(M,U),H=F-U.containerSize+V.end,X=F+z-V.start,Z=H+z,he=X-z,_e=Math.min(Z,he),Ye=Math.max(Z,he);let _t,ct;const zo=z>U.containerSize-V.start-V.end;switch(h){case"cover":_t=H,ct=X;break;case"contain":_t=_e,ct=Ye;break;case"entry":_t=H,ct=_e;break;case"exit":_t=Ye,ct=X;break;case"entry-crossing":_t=H,ct=zo?Ye:_e;break;case"exit-crossing":_t=zo?_e:Ye,ct=X}return{start:_t,end:ct}}function xo(h,d){if(h instanceof vn){const{rangeName:y,offset:S}=d;return _o(Dn(h,y),S,Dn(h,"cover"),h.subject)}if(h instanceof je){const{axis:y,source:S}=h,{sourceMeasurements:M}=Bt.get(S);let k;return k=We(y,M)==="x"?M.scrollWidth-M.clientWidth:M.scrollHeight-M.clientHeight,Jr(d,{percentageReference:CSS.px(k)})/k}unsupportedTimeline(h)}function _o(h,d,y,S){if(!h||!y)return 0;let M=getComputedStyle(S);return(Jr(d,{percentageReference:CSS.px(h.end-h.start),fontSize:CSS.px(parseFloat(M.fontSize))})+h.start-y.start)/(y.end-y.start)}let vn=class extends je{constructor(d){super(d);const y=Ue.get(this);y.subject=d&&d.subject?d.subject:void 0,d&&d.inset&&(y.inset=(function(S){if(!S)return{start:0,end:0};let M;if(M=typeof S=="string"?He(S).map((k=>{if(k==="auto")return"auto";try{return CSSNumericValue.parse(k)}catch{throw TypeError(`Could not parse inset "${S}"`)}})):Array.isArray(S)?S:[S],M.length===0||M.length>2)throw TypeError("Invalid inset");for(const k of M){if(k==="auto")continue;const z=k.type();if(z.length!==1&&z.percent!==1)throw TypeError("Invalid inset")}return{start:M[0],end:M[1]??M[0]}})(d.inset)),y.subject&&(new ResizeObserver((()=>{ji(y.source)})).observe(y.subject),new MutationObserver((()=>{ji(y.source)})).observe(y.subject,{attributes:!0,attributeFilter:["class","style"]})),jr(this),y.subjectMeasurements=$r(y.source,y.subject),en(this)}get source(){return jr(this),Ue.get(this).source}set source(d){throw new Error("Cannot set the source of a view timeline")}get subject(){return Ue.get(this).subject}get axis(){return Ue.get(this).axis}get currentTime(){const y=yo(this.source,this.axis);if(y==null)return null;const S=Dn(this,"cover");if(!S)return null;const M=(y-S.start)/(S.end-S.start);return CSS.percent(100*M)}get startOffset(){return CSS.px(Dn(this,"cover").start)}get endOffset(){return CSS.px(Dn(this,"cover").end)}};const Zc=document.getAnimations,Kc=window.Element.prototype.getAnimations,Qc=window.Element.prototype.animate,bo=window.Animation;class Sn{constructor(){this.state="pending",this.nativeResolve=this.nativeReject=null,this.promise=new Promise(((d,y)=>{this.nativeResolve=d,this.nativeReject=y}))}resolve(d){this.state="resolved",this.nativeResolve(d)}reject(d){this.state="rejected",this.promise.catch((()=>{})),this.nativeReject(d)}}function Fn(h){h.readyPromise=new Sn,requestAnimationFrame((()=>{var d;(((d=h.timeline)==null?void 0:d.currentTime)??null)!==null&&(Gi(h),h.pendingTask!=="play"||h.startTime===null&&h.holdTime===null?h.pendingTask==="pause"&&Co(h):Mo(h))}))}function To(){return new DOMException("The user aborted a request","AbortError")}function tn(h,d){if(d===null)return d;if(typeof d!="number")throw new DOMException(`Unexpected value: ${d}. Cannot convert to CssNumberish`,"InvalidStateError");const y=h.rangeDuration??100,S=Ut(h),M=S?y*d/S:0;return CSS.percent(M)}function ge(h,d){if(h.timeline){if(d===null)return d;if(d.unit==="percent"){const y=h.rangeDuration??100,S=Ut(h);return d.value*S/y}throw new DOMException("CSSNumericValue must be a percentage for progress based animations.","NotSupportedError")}{if(d==null||typeof d=="number")return d;const y=d.to("ms");if(y)return y.value;throw new DOMException("CSSNumericValue must be either a number or a time value for time based animations.","InvalidStateError")}}function Mo(h){const d=ge(h,h.timeline.currentTime);if(h.holdTime!=null)wt(h),h.animation.playbackRate==0?h.startTime=d:(h.startTime=d-h.holdTime/h.animation.playbackRate,h.holdTime=null);else if(h.startTime!==null&&h.pendingPlaybackRate!==null){const y=(d-h.startTime)*h.animation.playbackRate;wt(h);const S=h.animation.playbackRate;S==0?(h.holdTime=null,h.startTime=d):h.startTime=d-y/S}h.readyPromise&&h.readyPromise.state=="pending"&&h.readyPromise.resolve(h.proxy),Nt(h,!1,!1),Dt(h),h.pendingTask=null}function Co(h){const d=ge(h,h.timeline.currentTime);h.startTime!=null&&h.holdTime==null&&(h.holdTime=(d-h.startTime)*h.animation.playbackRate),wt(h),h.startTime=null,h.readyPromise.resolve(h.proxy),Nt(h,!1,!1),Dt(h),h.pendingTask=null}function wo(h){if(!h.finishedPromise||h.finishedPromise.state!="pending"||h.proxy.playState!="finished")return;h.finishedPromise.resolve(h.proxy),h.animation.pause();const d=new CustomEvent("finish",{detail:{currentTime:h.proxy.currentTime,timelineTime:h.proxy.timeline.currentTime}});Object.defineProperty(d,"currentTime",{get:function(){return this.detail.currentTime}}),Object.defineProperty(d,"timelineTime",{get:function(){return this.detail.timelineTime}}),requestAnimationFrame((()=>{queueMicrotask((()=>{h.animation.dispatchEvent(d)}))}))}function xn(h){return h.pendingPlaybackRate!==null?h.pendingPlaybackRate:h.animation.playbackRate}function wt(h){h.pendingPlaybackRate!==null&&(h.animation.playbackRate=h.pendingPlaybackRate,h.pendingPlaybackRate=null)}function Po(h){if(!h.timeline)return null;const d=ge(h,h.timeline.currentTime);if(d===null||h.startTime===null)return null;let y=(d-h.startTime)*h.animation.playbackRate;return y==-0&&(y=0),y}function Nt(h,d,y){if(!h.timeline)return;let S=d?ge(h,h.proxy.currentTime):Po(h);if(S&&h.startTime!=null&&!h.proxy.pending){const M=xn(h),k=Ut(h);let z=h.previousCurrentTime;M>0&&S>=k&&h.previousCurrentTime!=null?((z===null||z<k)&&(z=k),h.holdTime=d?S:z):M<0&&S<=0?((z==null||z>0)&&(z=0),h.holdTime=d?S:z):M!=0&&(d&&h.holdTime!==null&&(h.startTime=(function(F,U){if(!F.timeline)return null;const V=ge(F,F.timeline.currentTime);return V==null?null:V-U/F.animation.playbackRate})(h,h.holdTime)),h.holdTime=null)}Dt(h),h.previousCurrentTime=ge(h,h.proxy.currentTime),h.proxy.playState=="finished"?(h.finishedPromise||(h.finishedPromise=new Sn),h.finishedPromise.state=="pending"&&(y?wo(h):Promise.resolve().then((()=>{wo(h)})))):(h.finishedPromise&&h.finishedPromise.state=="resolved"&&(h.finishedPromise=new Sn),h.animation.playState!="paused"&&h.animation.pause())}function Ut(h){const d=(function(S){const M=S.proxy.effect.getTiming();return S.normalizedTiming||M})(h),y=d.delay+d.endDelay+d.iterations*d.duration;return Math.max(0,y)}function Dt(h){if(h.timeline)if(h.startTime!==null){const d=h.timeline.currentTime;if(d==null)return;Zr(h,(ge(h,d)-h.startTime)*h.animation.playbackRate)}else h.holdTime!==null&&Zr(h,h.holdTime)}function Zr(h,d){const y=h.timeline,S=h.animation.playbackRate,M=y.currentTime&&y.currentTime.value==(S<0?0:100)?S<0?.001:-.001:0;h.animation.currentTime=d+M}function Kr(h,d){if(!h.timeline)return;const y=h.proxy.playState=="paused"&&h.proxy.pending;let S=!1,M=ge(h,h.proxy.currentTime);xn(h)==0&&M==null&&(h.holdTime=0),M==null&&(h.autoAlignStartTime=!0),(h.proxy.playState==="finished"||y)&&(h.holdTime=null,h.startTime=null,h.autoAlignStartTime=!0),h.holdTime&&(h.startTime=null),h.pendingTask&&(h.pendingTask=null,S=!0),(h.holdTime!==null||h.autoAlignStartTime||y||h.pendingPlaybackRate!==null)&&(h.readyPromise&&!S&&(h.readyPromise=null),Dt(h),h.readyPromise||Fn(h),h.pendingTask="play",Hr(h.timeline,h.animation,Qr.bind(h.proxy)),Nt(h,!1,!1))}function Qr(h){const d=q.get(this);if(!d)return;if(h==null)return void(d.proxy.playState!=="paused"&&d.animation.playState!="idle"&&d.animation.cancel());Gi(d),d.pendingTask&&requestAnimationFrame((()=>{d.pendingTask!=="play"||d.startTime===null&&d.holdTime===null?d.pendingTask==="pause"&&Co(d):Mo(d)}));const y=this.playState;if(y=="running"||y=="finished"){const S=ge(d,h);Zr(d,(S-ge(d,this.startTime))*this.playbackRate),Nt(d,!1,!1)}}function Eo(h){h.specifiedTiming=null}let q=new WeakMap;window.addEventListener("pagehide",(h=>{q=new WeakMap}),!1);let ko=new WeakMap;function Gi(h){if(!h.autoAlignStartTime||!h.timeline||!h.timeline.currentTime||h.proxy.playState==="idle"||h.proxy.playState==="paused"&&h.holdTime!==null)return;const d=h.rangeDuration;let y,S;try{y=CSS.percent(100*(function(k){if(!k.animationRange)return 0;const z=k.animationRange.start==="normal"?Ro(k.timeline):k.animationRange.start;return xo(k.timeline,z)})(h))}catch(k){y=CSS.percent(0),h.animationRange.start="normal",console.warn("Exception when calculating start offset",k)}try{S=CSS.percent(100*(1-(function(k){if(!k.animationRange)return 0;const z=k.animationRange.end==="normal"?Ao(k.timeline):k.animationRange.end;return 1-xo(k.timeline,z)})(h)))}catch(k){S=CSS.percent(100),h.animationRange.end="normal",console.warn("Exception when calculating end offset",k)}h.rangeDuration=S.value-y.value;const M=xn(h);h.startTime=ge(h,M>=0?y:S),h.holdTime=null,h.rangeDuration!==d&&Eo(h)}function $i(h){throw new Error("Unsupported timeline class")}function Ro(h){return h instanceof ViewTimeline?{rangeName:"cover",offset:CSS.percent(0)}:h instanceof je?CSS.percent(0):void $i()}function Ao(h){return h instanceof ViewTimeline?{rangeName:"cover",offset:CSS.percent(100)}:h instanceof je?CSS.percent(100):void $i()}function el(h,d){if(!d)return{start:"normal",end:"normal"};const y={start:Ro(h),end:Ao(h)};if(h instanceof ViewTimeline){const S=He(d),M=[],k=[];if(S.forEach((z=>{if(Ji.includes(z))M.push(z);else try{k.push(CSSNumericValue.parse(z))}catch{throw TypeError(`Could not parse range "${d}"`)}})),M.length>2||k.length>2||k.length==1)throw TypeError("Invalid time range or unsupported time range format.");return M.length&&(y.start.rangeName=M[0],y.end.rangeName=M.length>1?M[1]:M[0]),k.length>1&&(y.start.offset=k[0],y.end.offset=k[1]),y}if(h instanceof je){const S=d.split(" ");if(S.length!=2)throw TypeError("Invalid time range or unsupported time range format.");return y.start=CSSNumericValue.parse(S[0]),y.end=CSSNumericValue.parse(S[1]),y}$i()}function Wi(h,d,y){if(!d||d==="normal")return"normal";if(h instanceof ViewTimeline){let S="cover",M=y==="start"?CSS.percent(0):CSS.percent(100);if(d instanceof Object)d.rangeName!==void 0&&(S=d.rangeName),d.offset!==void 0&&(M=d.offset);else{const k=He(d);k.length===1?Ji.includes(k[0])?S=k[0]:M=pe(CSSNumericValue.parse(k[0]),{}):k.length===2&&(S=k[0],M=pe(CSSNumericValue.parse(k[1]),{}))}if(!Ji.includes(S))throw TypeError("Invalid range name");return{rangeName:S,offset:M}}if(h instanceof je)return CSSNumericValue.parse(d);$i()}class Hi{constructor(d,y,S={}){const M=y instanceof je,k=d instanceof bo?d:new bo(d,M?void 0:y);ko.set(k,this),q.set(this,{animation:k,timeline:M?y:void 0,playState:M?"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:M?el(y,S["animation-range"]):null,proxy:this})}get effect(){const d=q.get(this);return d.timeline?(d.effect||(d.effect=(function(y){const S=y.animation.effect,M=S.updateTiming,k={apply:function(V){S.getTiming();const H=V.apply(S);if(y.timeline){const X=y.duration??100;H.localTime=tn(y,H.localTime),H.endTime=tn(y,H.endTime),H.activeDuration=tn(y,H.activeDuration);const Z=Ut(y),he=H.iterations?(Z-H.delay-H.endDelay)/H.iterations:0;H.duration=Z?CSS.percent(X*he/Z):CSS.percent(0),y.timeline.currentTime===void 0&&(H.localTime=null)}return H}},z={apply:function(V,H){if(y.specifiedTiming)return y.specifiedTiming;y.specifiedTiming=V.apply(S);let X,Z=Object.assign({},y.specifiedTiming);if(Z.duration===1/0)throw TypeError("Effect duration cannot be Infinity when used with Scroll Timelines");return(Z.duration===null||Z.duration==="auto"||y.autoDurationEffect)&&y.timeline&&(y.autoDurationEffect=!0,Z.delay=0,Z.endDelay=0,X=Z.iterations?1e5:0,Z.duration=Z.iterations?(X-Z.delay-Z.endDelay)/Z.iterations:0,Z.duration<0&&(Z.duration=0,Z.endDelay=X-Z.delay),M.apply(S,[Z])),y.normalizedTiming=Z,y.specifiedTiming}},F={apply:function(V,H,X){if(X&&X.length){if(y.timeline&&X[0]){const Z=X[0],he=Z.duration;if(he===1/0)throw TypeError("Effect duration cannot be Infinity when used with Scroll Timelines");if(Z.iterations===1/0)throw TypeError("Effect iterations cannot be Infinity when used with Scroll Timelines");he!==void 0&&he!=="auto"&&(y.autoDurationEffect=null)}y.specifiedTiming&&V.apply(S,[y.specifiedTiming]),V.apply(S,X),Eo(y)}}},U=new Proxy(S,{get:function(V,H){const X=V[H];return typeof X=="function"?X.bind(S):X},set:function(V,H,X){return V[H]=X,!0}});return U.getComputedTiming=new Proxy(S.getComputedTiming,k),U.getTiming=new Proxy(S.getTiming,z),U.updateTiming=new Proxy(S.updateTiming,F),U})(d)),d.effect):d.animation.effect}set effect(d){const y=q.get(this);y.animation.effect=d,y.effect=null,y.autoDurationEffect=null}get timeline(){const d=q.get(this);return d.timeline||d.animation.timeline}set timeline(d){const y=q.get(this),S=this.timeline;if(S==d)return;const M=this.playState,k=this.currentTime;let z,F=Ut(y);z=k===null?null:F===0?0:ge(y,k)/F;const U=S instanceof je,V=d instanceof je,H=this.pending;if(U&&Wr(y.timeline,y.animation),V)return y.timeline=d,wt(y),y.autoAlignStartTime=!0,y.startTime=null,y.holdTime=null,M!=="running"&&M!=="finished"||(y.readyPromise&&y.readyPromise.state!=="resolved"||Fn(y),y.pendingTask="play",Hr(y.timeline,y.animation,Qr.bind(this))),M==="paused"&&z!==null&&(y.holdTime=z*F),H&&(y.readyPromise&&y.readyPromise.state!="resolved"||Fn(y),y.pendingTask=M=="paused"?"pause":"play"),y.startTime!==null&&(y.holdTime=null),void Nt(y,!1,!1);if(y.animation.timeline!=d)throw TypeError("Unsupported timeline: "+d);if(Wr(y.timeline,y.animation),y.timeline=null,U)switch(k!==null&&(y.animation.currentTime=z*Ut(y)),M){case"paused":y.animation.pause();break;case"running":case"finished":y.animation.play()}}get startTime(){const d=q.get(this);return d.timeline?tn(d,d.startTime):d.animation.startTime}set startTime(d){const y=q.get(this);if(d=ge(y,d),!y.timeline)return void(y.animation.startTime=d);y.autoAlignStartTime=!1,ge(y,y.timeline.currentTime)==null&&y.startTime!=null&&(y.holdTime=null,Dt(y));const S=ge(y,this.currentTime);wt(y),y.startTime=d,y.startTime!==null&&y.animation.playbackRate!=0?y.holdTime=null:y.holdTime=S,y.pendingTask&&(y.pendingTask=null,y.readyPromise.resolve(this)),Nt(y,!0,!1),Dt(y)}get currentTime(){const d=q.get(this);return d.timeline?d.holdTime!=null?tn(d,d.holdTime):tn(d,Po(d)):d.animation.currentTime}set currentTime(d){const y=q.get(this);y.timeline?((function(S,M){if(M==null&&S.currentTime!==null)throw new TypeError;M=ge(S,M),S.autoAlignStartTime=!1,S.holdTime!==null||S.startTime===null||S.timeline.phase==="inactive"||S.animation.playbackRate===0?S.holdTime=M:S.startTime=ge(S,S.timeline.currentTime)-M/S.animation.playbackRate,S.timeline.phase==="inactive"&&(S.startTime=null),S.previousCurrentTime=null})(y,d),y.pendingTask=="pause"&&(y.holdTime=ge(y,d),wt(y),y.startTime=null,y.pendingTask=null,y.readyPromise.resolve(this)),Nt(y,!0,!1)):y.animation.currentTime=d}get playbackRate(){return q.get(this).animation.playbackRate}set playbackRate(d){const y=q.get(this);if(!y.timeline)return void(y.animation.playbackRate=d);y.pendingPlaybackRate=null;const S=this.currentTime;y.animation.playbackRate=d,S!==null&&(this.currentTime=S)}get playState(){const d=q.get(this);if(!d.timeline)return d.animation.playState;const y=ge(d,this.currentTime);return y===null&&d.startTime===null&&d.pendingTask==null?"idle":d.pendingTask=="pause"||d.startTime===null&&d.pendingTask!="play"?"paused":y!=null&&(d.animation.playbackRate>0&&y>=Ut(d)||d.animation.playbackRate<0&&y<=0)?"finished":"running"}get rangeStart(){var d;return((d=q.get(this).animationRange)==null?void 0:d.start)??"normal"}set rangeStart(d){const y=q.get(this);if(!y.timeline)return y.animation.rangeStart=d;y.timeline instanceof je&&(y.animationRange.start=Wi(y.timeline,d,"start"),Gi(y),Dt(y))}get rangeEnd(){var d;return((d=q.get(this).animationRange)==null?void 0:d.end)??"normal"}set rangeEnd(d){const y=q.get(this);if(!y.timeline)return y.animation.rangeEnd=d;y.timeline instanceof je&&(y.animationRange.end=Wi(y.timeline,d,"end"),Gi(y),Dt(y))}get replaceState(){return q.get(this).animation.pending}get pending(){const d=q.get(this);return d.timeline?!!d.readyPromise&&d.readyPromise.state=="pending":d.animation.pending}finish(){const d=q.get(this);if(!d.timeline)return void d.animation.finish();const y=xn(d),S=Ut(d);if(y==0)throw new DOMException("Cannot finish Animation with a playbackRate of 0.","InvalidStateError");if(y>0&&S==1/0)throw new DOMException("Cannot finish Animation with an infinite target effect end.","InvalidStateError");wt(d);const M=y<0?0:S;this.currentTime=tn(d,M);const k=ge(d,d.timeline.currentTime);d.startTime===null&&k!==null&&(d.startTime=k-M/d.animation.playbackRate),d.pendingTask=="pause"&&d.startTime!==null&&(d.holdTime=null,d.pendingTask=null,d.readyPromise.resolve(this)),d.pendingTask=="play"&&d.startTime!==null&&(d.pendingTask=null,d.readyPromise.resolve(this)),Nt(d,!0,!0)}play(){const d=q.get(this);d.timeline?Kr(d):d.animation.play()}pause(){const d=q.get(this);d.timeline?this.playState!="paused"&&(d.animation.currentTime===null&&(d.autoAlignStartTime=!0),d.pendingTask=="play"?d.pendingTask=null:d.readyPromise=null,d.readyPromise||Fn(d),d.pendingTask="pause",Hr(d.timeline,d.animation,Qr.bind(d.proxy))):d.animation.pause()}reverse(){const d=q.get(this),y=xn(d),S=ge(d,this.currentTime),M=Ut(d)==1/0,k=y!=0&&(y<0||S>0||!M);if(!d.timeline||!k)return k&&(d.pendingPlaybackRate=-xn(d)),void d.animation.reverse();if(d.timeline.phase=="inactive")throw new DOMException("Cannot reverse an animation with no active timeline","InvalidStateError");this.updatePlaybackRate(-y),Kr(d)}updatePlaybackRate(d){const y=q.get(this);if(y.pendingPlaybackRate=d,!y.timeline)return void y.animation.updatePlaybackRate(d);const S=this.playState;if(!y.readyPromise||y.readyPromise.state!="pending")switch(S){case"idle":case"paused":wt(y);break;case"finished":const M=ge(y,y.timeline.currentTime),k=M!==null?(M-y.startTime)*y.animation.playbackRate:null;y.startTime=d==0?M:M!=null&&k!=null?(M-k)/d:null,wt(y),Nt(y,!1,!1),Dt(y);break;default:Kr(y)}}persist(){q.get(this).animation.persist()}get id(){return q.get(this).animation.id}set id(d){q.get(this).animation.id=d}cancel(){const d=q.get(this);d.timeline?(this.playState!="idle"&&((function(y){y.pendingTask&&(y.pendingTask=null,wt(y),y.readyPromise.reject(To()),Fn(y),y.readyPromise.resolve(y.proxy))})(d),d.finishedPromise&&d.finishedPromise.state=="pending"&&d.finishedPromise.reject(To()),d.finishedPromise=new Sn,d.animation.cancel()),d.startTime=null,d.holdTime=null,Wr(d.timeline,d.animation)):d.animation.cancel()}get onfinish(){return q.get(this).animation.onfinish}set onfinish(d){q.get(this).animation.onfinish=d}get oncancel(){return q.get(this).animation.oncancel}set oncancel(d){q.get(this).animation.oncancel=d}get onremove(){return q.get(this).animation.onremove}set onremove(d){q.get(this).animation.onremove=d}get finished(){const d=q.get(this);return d.timeline?(d.finishedPromise||(d.finishedPromise=new Sn),d.finishedPromise.promise):d.animation.finished}get ready(){const d=q.get(this);return d.timeline?(d.readyPromise||(d.readyPromise=new Sn,d.readyPromise.resolve(this)),d.readyPromise.promise):d.animation.ready}addEventListener(d,y,S){q.get(this).animation.addEventListener(d,y,S)}removeEventListener(d,y,S){q.get(this).animation.removeEventListener(d,y,S)}dispatchEvent(d){q.get(this).animation.dispatchEvent(d)}}function tl(h,d){const y=d.timeline;y instanceof je&&delete d.timeline;const S=Qc.apply(this,[h,d]),M=new Hi(S,y);return y instanceof je&&(S.pause(),q.get(M).animationRange={start:Wi(y,d.rangeStart,"start"),end:Wi(y,d.rangeEnd,"end")},M.play()),M}function Oo(h){for(let d=0;d<h.length;++d){let y=ko.get(h[d]);y&&(h[d]=y)}return h}function nl(h){return Oo(Kc.apply(this,[h]))}function il(h){return Oo(Zc.apply(this,[h]))}const Ee={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\(([^)]*)\)/},_n=["block","inline","x","y"],rl=["nearest","root","self"],$t=new class{constructor(){this.cssRulesWithTimelineName=[],this.nextAnonymousTimelineNameIndex=0,this.anonymousScrollTimelineOptions=new Map,this.anonymousViewTimelineOptions=new Map,this.sourceSelectorToScrollTimeline=[],this.subjectSelectorToViewTimeline=[],this.keyframeNamesSelectors=new Map}transpileStyleSheet(h,d,y){const S={sheetSrc:h,index:0,name:y};for(;S.index<S.sheetSrc.length&&(this.eatWhitespace(S),!(S.index>=S.sheetSrc.length));){if(this.lookAhead("/*",S)){for(;this.lookAhead("/*",S);)this.eatComment(S),this.eatWhitespace(S);continue}const M=this.parseQualifiedRule(S);M&&(d?this.parseKeyframesAndSaveNameMapping(M,S):this.handleScrollTimelineProps(M,S))}return S.sheetSrc}getAnimationTimelineOptions(h,d){for(let y=this.cssRulesWithTimelineName.length-1;y>=0;y--){const S=this.cssRulesWithTimelineName[y];try{if(d.matches(S.selector)&&(!S["animation-name"]||S["animation-name"]==h))return{"animation-timeline":S["animation-timeline"],"animation-range":S["animation-range"]}}catch{}}return null}getAnonymousScrollTimelineOptions(h,d){const y=this.anonymousScrollTimelineOptions.get(h);return y?{anonymousSource:y.source,anonymousTarget:d,source:vo(y.source??"nearest",d),axis:y.axis?y.axis:"block"}:null}getScrollTimelineOptions(h,d){const y=this.getAnonymousScrollTimelineOptions(h,d);if(y)return y;for(let S=this.sourceSelectorToScrollTimeline.length-1;S>=0;S--){const M=this.sourceSelectorToScrollTimeline[S];if(M.name==h){const k=this.findPreviousSiblingOrAncestorMatchingSelector(d,M.selector);if(k)return{source:k,...M.axis?{axis:M.axis}:{}}}}return null}findPreviousSiblingOrAncestorMatchingSelector(h,d){let y=h;for(;y;){if(y.matches(d))return y;y=y.previousElementSibling||y.parentElement}return null}getAnonymousViewTimelineOptions(h,d){const y=this.anonymousViewTimelineOptions.get(h);return y?{subject:d,axis:y.axis?y.axis:"block",inset:y.inset?y.inset:"auto"}:null}getViewTimelineOptions(h,d){const y=this.getAnonymousViewTimelineOptions(h,d);if(y)return y;for(let S=this.subjectSelectorToViewTimeline.length-1;S>=0;S--){const M=this.subjectSelectorToViewTimeline[S];if(M.name==h){const k=this.findPreviousSiblingOrAncestorMatchingSelector(d,M.selector);if(k)return{subject:k,axis:M.axis,inset:M.inset}}}return null}handleScrollTimelineProps(h,d){if(h.selector.includes("@keyframes"))return;const y=h.block.contents.includes("animation-name:"),S=h.block.contents.includes("animation-timeline:"),M=h.block.contents.includes("animation:");if(this.saveSourceSelectorToScrollTimeline(h),this.saveSubjectSelectorToViewTimeline(h),!S&&!y&&!M)return;let k=[],z=[],F=!1;S&&(k=this.extractScrollTimelineNames(h.block.contents)),y&&(z=this.extractMatches(h.block.contents,Ee.ANIMATION_NAME)),S&&y||(M&&this.extractMatches(h.block.contents,Ee.ANIMATION).forEach((U=>{const V=this.extractAnimationName(U);V&&S&&z.push(V),S&&(this.hasDuration(U)||(this.hasAutoDuration(U)&&(h.block.contents=h.block.contents.replace("auto"," ")),h.block.contents=h.block.contents.replace(U," 1s "+U),F=!0))})),F&&this.replacePart(h.block.startIndex,h.block.endIndex,h.block.contents,d)),this.saveRelationInList(h,k,z)}saveSourceSelectorToScrollTimeline(h){const d=h.block.contents.includes("scroll-timeline:"),y=h.block.contents.includes("scroll-timeline-name:"),S=h.block.contents.includes("scroll-timeline-axis:");if(!d&&!y)return;let M=[];if(d){const z=this.extractMatches(h.block.contents,Ee.SCROLL_TIMELINE);for(const F of z){const U=this.split(F);let V={selector:h.selector,name:""};U.length==1?V.name=U[0]:U.length==2&&(_n.includes(U[0])?(V.axis=U[0],V.name=U[1]):(V.axis=U[1],V.name=U[0])),M.push(V)}}if(y){const z=this.extractMatches(h.block.contents,Ee.SCROLL_TIMELINE_NAME);for(let F=0;F<z.length;F++)if(F<M.length)M[F].name=z[F];else{let U={selector:h.selector,name:z[F]};M.push(U)}}let k=[];if(S){const z=this.extractMatches(h.block.contents,Ee.SCROLL_TIMELINE_AXIS);if(k=z.filter((F=>_n.includes(F))),k.length!=z.length)throw new Error("Invalid axis")}for(let z=0;z<M.length;z++)k.length&&(M[z].axis=k[z%M.length]);this.sourceSelectorToScrollTimeline.push(...M)}saveSubjectSelectorToViewTimeline(h){const d=h.block.contents.includes("view-timeline:"),y=h.block.contents.includes("view-timeline-name:"),S=h.block.contents.includes("view-timeline-axis:"),M=h.block.contents.includes("view-timeline-inset:");if(!d&&!y)return;let k=[];if(d){const U=this.extractMatches(h.block.contents,Ee.VIEW_TIMELINE);for(let V of U){const H=this.split(V);let X={selector:h.selector,name:"",inset:null};H.length==1?X.name=H[0]:H.length==2&&(_n.includes(H[0])?(X.axis=H[0],X.name=H[1]):(X.axis=H[1],X.name=H[0])),k.push(X)}}if(y){const U=this.extractMatches(h.block.contents,Ee.VIEW_TIMELINE_NAME);for(let V=0;V<U.length;V++)if(V<k.length)k[V].name=U[V];else{let H={selector:h.selector,name:U[V],inset:null};k.push(H)}}let z=[],F=[];if(M&&(z=this.extractMatches(h.block.contents,Ee.VIEW_TIMELINE_INSET)),S){const U=this.extractMatches(h.block.contents,Ee.VIEW_TIMELINE_AXIS);if(F=U.filter((V=>_n.includes(V))),F.length!=U.length)throw new Error("Invalid axis")}for(let U=0;U<k.length;U++)z.length&&(k[U].inset=z[U%k.length]),F.length&&(k[U].axis=F[U%k.length]);this.subjectSelectorToViewTimeline.push(...k)}hasDuration(h){return h.split(" ").filter((d=>{return y=d,Ee.TIME.exec(y);var y})).length>=1}hasAutoDuration(h){return h.split(" ").filter((d=>d==="auto")).length>=1}saveRelationInList(h,d,y){let S=[];h.block.contents.includes("animation-range:")&&(S=this.extractMatches(h.block.contents,Ee.ANIMATION_TIME_RANGE));const M=Math.max(d.length,y.length,S.length);for(let k=0;k<M;k++)this.cssRulesWithTimelineName.push({selector:h.selector,"animation-timeline":d[k%d.length],...y.length?{"animation-name":y[k%y.length]}:{},...S.length?{"animation-range":S[k%S.length]}:{}})}extractScrollTimelineNames(h){const d=Ee.ANIMATION_TIMELINE.exec(h)[1].trim(),y=[];return d.split(",").map((S=>S.trim())).forEach((S=>{if((function(M){return(M.startsWith("scroll")||M.startsWith("view"))&&M.includes("(")})(S)){const M=this.saveAnonymousTimelineName(S);y.push(M)}else y.push(S)})),y}saveAnonymousTimelineName(h){const d=":t"+this.nextAnonymousTimelineNameIndex++;return h.startsWith("scroll(")?this.anonymousScrollTimelineOptions.set(d,this.parseAnonymousScrollTimeline(h)):this.anonymousViewTimelineOptions.set(d,this.parseAnonymousViewTimeline(h)),d}parseAnonymousScrollTimeline(h){const d=Ee.ANONYMOUS_SCROLL_TIMELINE.exec(h);if(!d)return null;const y=d[1],S={};return y.split(" ").forEach((M=>{_n.includes(M)?S.axis=M:rl.includes(M)&&(S.source=M)})),S}parseAnonymousViewTimeline(h){const d=Ee.ANONYMOUS_VIEW_TIMELINE.exec(h);if(!d)return null;const y=d[1],S={};return y.split(" ").forEach((M=>{_n.includes(M)?S.axis=M:S.inset=S.inset?`${S.inset} ${M}`:M})),S}extractAnimationName(h){return this.findMatchingEntryInContainer(h,this.keyframeNamesSelectors)}findMatchingEntryInContainer(h,d){const y=h.split(" ").filter((S=>d.has(S)));return y?y[0]:null}parseIdentifier(h){Ee.IDENTIFIER.lastIndex=h.index;const d=Ee.IDENTIFIER.exec(h.sheetSrc);if(!d)throw this.parseError(h,"Expected an identifier");return h.index+=d[0].length,d[0]}parseKeyframesAndSaveNameMapping(h,d){if(h.selector.startsWith("@keyframes")){const y=this.replaceKeyframesAndGetMapping(h,d);h.selector.split(" ").forEach(((S,M)=>{M>0&&this.keyframeNamesSelectors.set(S,y)}))}}replaceKeyframesAndGetMapping(h,d){function y(U){return Ji.some((V=>U.startsWith(V)))}const S=h.block.contents,M=(function(U){let V=0,H=-1,X=-1;const Z=[];for(let he=0;he<U.length;he++)U[he]=="{"?V++:U[he]=="}"&&V--,V==1&&U[he]!="{"&&U[he]!="}"&&H==-1&&(H=he),V==2&&U[he]=="{"&&(X=he,Z.push({start:H,end:X}),H=X=-1);return Z})(S);if(M.length==0)return new Map;const k=new Map;let z=!1;const F=[];F.push(S.substring(0,M[0].start));for(let U=0;U<M.length;U++){const V=S.substring(M[U].start,M[U].end);let H=[];V.split(",").forEach((X=>{const Z=X.split(" ").map((_e=>_e.trim())).filter((_e=>_e!="")).join(" "),he=k.size;k.set(he,Z),H.push(`${he}%`),y(Z)&&(z=!0)})),F.push(H.join(",")),U==M.length-1?F.push(S.substring(M[U].end)):F.push(S.substring(M[U].end,M[U+1].start))}return z?(h.block.contents=F.join(""),this.replacePart(h.block.startIndex,h.block.endIndex,h.block.contents,d),k):new Map}parseQualifiedRule(h){const d=h.index,y=this.parseSelector(h).trim();if(y)return{selector:y,block:this.eatBlock(h),startIndex:d,endIndex:h.index}}removeEnclosingDoubleQuotes(h){let d=h[0]=='"'?1:0,y=h[h.length-1]=='"'?h.length-1:h.length;return h.substring(d,y)}assertString(h,d){if(h.sheetSrc.substr(h.index,d.length)!=d)throw this.parseError(h,`Did not find expected sequence ${d}`);h.index+=d.length}replacePart(h,d,y,S){if(S.sheetSrc=S.sheetSrc.slice(0,h)+y+S.sheetSrc.slice(d),S.index>=d){const M=S.index-d;S.index=h+y.length+M}}eatComment(h){this.assertString(h,"/*"),this.eatUntil("*/",h,!0),this.assertString(h,"*/")}eatBlock(h){const d=h.index;this.assertString(h,"{");let y=1;for(;y!=0;)this.lookAhead("/*",h)?this.eatComment(h):(h.sheetSrc[h.index]==="{"?y++:h.sheetSrc[h.index]==="}"&&y--,this.advance(h));const S=h.index;return{startIndex:d,endIndex:S,contents:h.sheetSrc.slice(d,S)}}advance(h){if(h.index++,h.index>h.sheetSrc.length)throw this.parseError(h,"Advanced beyond the end")}parseError(h,d){return Error(`(${h.name?h.name:"<anonymous file>"}): ${d}`)}eatUntil(h,d,y=!1){const S=d.index;for(;!this.lookAhead(h,d);)this.advance(d);return y&&(d.sheetSrc=d.sheetSrc.slice(0,S)+" ".repeat(d.index-S)+d.sheetSrc.slice(d.index)),d.sheetSrc.slice(S,d.index)}parseSelector(h){let d=h.index;if(this.eatUntil("{",h),d===h.index)throw Error("Empty selector");return h.sheetSrc.slice(d,h.index)}eatWhitespace(h){Ee.WHITE_SPACE.lastIndex=h.index;const d=Ee.WHITE_SPACE.exec(h.sheetSrc);d&&(h.index+=d[0].length)}lookAhead(h,d){return d.sheetSrc.substr(d.index,h.length)==h}peek(h){return h.sheetSrc[h.index]}extractMatches(h,d,y=","){return d.exec(h)[1].trim().split(y).map((S=>S.trim()))}split(h){return h.split(" ").map((d=>d.trim())).filter((d=>d!=""))}};function sl(h,d,y,S,M,k){const z=Gr(d),F=$r(d,y);return _o(Yr(h,z,F,S,M),k,Yr("cover",z,F,S,M),y)}function ol(h,d,y){const S=$t.getAnimationTimelineOptions(d,y);if(!S)return null;const M=S["animation-timeline"];if(!M)return null;let k=$t.getScrollTimelineOptions(M,y)||$t.getViewTimelineOptions(M,y);return k?(k.subject&&(function(z,F){const U=Xr(F.subject),V=F.axis||F.axis;function H(Z,he){let _e=null;for(const[Ye,_t]of Z)if(Ye==100*he.offset){if(_t=="from")_e=0;else if(_t=="to")_e=100;else{const ct=_t.split(" ");_e=ct.length==1?parseFloat(ct[0]):100*sl(ct[0],U,F.subject,V,F.inset,CSS.percent(parseFloat(ct[1])))}break}return _e}const X=$t.keyframeNamesSelectors.get(z.animationName);if(X&&X.size){const Z=[];z.effect.getKeyframes().forEach((_e=>{const Ye=H(X,_e);Ye!==null&&Ye>=0&&Ye<=100&&(_e.offset=Ye/100,Z.push(_e))}));const he=Z.sort(((_e,Ye)=>_e.offset<Ye.offset?-1:_e.affset>Ye.offset?1:0));z.effect.setKeyframes(he)}})(h,k),{timeline:k.source?new je(k):new vn(k),animOptions:S}):null}function al(){if(CSS.supports("animation-timeline: --works"))return!0;(function(){function d(S){if(S.innerHTML.trim().length===0||"aphrodite"in S.dataset)return;let M=$t.transpileStyleSheet(S.innerHTML,!0);M=$t.transpileStyleSheet(M,!1),S.innerHTML=M}function y(S){S.type!="text/css"&&S.rel!="stylesheet"||!S.href||new URL(S.href,document.baseURI).origin==location.origin&&fetch(S.getAttribute("href")).then((async M=>{const k=await M.text();let z=$t.transpileStyleSheet(k,!0);if(z=$t.transpileStyleSheet(k,!1),z!=k){const F=new Blob([z],{type:"text/css"}),U=URL.createObjectURL(F);S.setAttribute("href",U)}}))}new MutationObserver((S=>{for(const M of S)for(const k of M.addedNodes)k instanceof HTMLStyleElement&&d(k),k instanceof HTMLLinkElement&&y(k)})).observe(document.documentElement,{childList:!0,subtree:!0}),document.querySelectorAll("style").forEach((S=>d(S))),document.querySelectorAll("link").forEach((S=>y(S)))})();const h=CSS.supports;CSS.supports=d=>(d=d.replaceAll(/(animation-timeline|scroll-timeline(-(name|axis))?|view-timeline(-(name|axis|inset))?|timeline-scope)\s*:/g,"--supported-property:"),h(d)),window.addEventListener("animationstart",(d=>{d.target.getAnimations().filter((y=>y.animationName===d.animationName)).forEach((y=>{const S=ol(y,y.animationName,d.target);if(S)if(!S.timeline||y instanceof Hi)y.timeline=S.timeline;else{const M=new Hi(y,S.timeline,S.animOptions);y.pause(),M.play()}}))}))}(function(){if(!al()){if(!Reflect.defineProperty(window,"ScrollTimeline",{value:je}))throw Error("Error installing ScrollTimeline polyfill: could not attach ScrollTimeline to window");if(!Reflect.defineProperty(window,"ViewTimeline",{value:vn}))throw Error("Error installing ViewTimeline polyfill: could not attach ViewTimeline to window");if(!Reflect.defineProperty(Element.prototype,"animate",{value:tl}))throw Error("Error installing ScrollTimeline polyfill: could not attach WAAPI's animate to DOM Element");if(!Reflect.defineProperty(window,"Animation",{value:Hi}))throw Error("Error installing Animation constructor.");if(!Reflect.defineProperty(Element.prototype,"getAnimations",{value:nl}))throw Error("Error installing ScrollTimeline polyfill: could not attach WAAPI's getAnimations to DOM Element");if(!Reflect.defineProperty(document,"getAnimations",{value:il}))throw Error("Error installing ScrollTimeline polyfill: could not attach WAAPI's getAnimations to document")}})()})();class wh{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 re;(function(r){r.open="open",r.close="close",r.error="error",r.message="message",r.retry="retry",r.reconnect="reconnect"})(re||(re={}));class Dc{constructor(e,t,n){var i,s,a,o,c,l,u,f,p,m,x,T,g,v,b;this._closedByUser=!1,this.handleOpenEvent=_=>this.handleEvent(re.open,_),this.handleErrorEvent=_=>this.handleEvent(re.error,_),this.handleCloseEvent=_=>this.handleEvent(re.close,_),this.handleMessageEvent=_=>this.handleEvent(re.message,_),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:[...(p=(f=n?.listeners)===null||f===void 0?void 0:f.error)!==null&&p!==void 0?p:[]],message:[...(x=(m=n?.listeners)===null||m===void 0?void 0:m.message)!==null&&x!==void 0?x:[]],retry:[...(g=(T=n?.listeners)===null||T===void 0?void 0:T.retry)!==null&&g!==void 0?g:[]],reconnect:[...(b=(v=n?.listeners)===null||v===void 0?void 0:v.reconnect)!==null&&b!==void 0?b:[]]}},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(re.open,this.handleOpenEvent),this._underlyingWebsocket.addEventListener(re.close,this.handleCloseEvent),this._underlyingWebsocket.addEventListener(re.error,this.handleErrorEvent),this._underlyingWebsocket.addEventListener(re.message,this.handleMessageEvent),this._underlyingWebsocket}clearWebsocket(){this._underlyingWebsocket.removeEventListener(re.open,this.handleOpenEvent),this._underlyingWebsocket.removeEventListener(re.close,this.handleCloseEvent),this._underlyingWebsocket.removeEventListener(re.error,this.handleErrorEvent),this._underlyingWebsocket.removeEventListener(re.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 re.close:this.dispatchEvent(e,t),this.scheduleConnectionRetryIfNeeded();break;case re.open:if(this.backoff!==void 0&&this._lastConnection!==void 0){const n={retries:this.backoff.retries,lastConnection:new Date(this._lastConnection)},i=new CustomEvent(re.reconnect,{detail:n});this.dispatchEvent(re.reconnect,i),this.backoff.reset()}this._lastConnection=new Date,this.dispatchEvent(e,t),this.sendBufferedData();break;case re.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(re.retry,{detail:n});this.handleEvent(re.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 Ph{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(re.open,e,t),this}onClose(e,t){return this.addListener(re.close,e,t),this}onError(e,t){return this.addListener(re.error,e,t),this}onMessage(e,t){return this.addListener(re.message,e,t),this}onRetry(e,t){return this.addListener(re.retry,e,t),this}onReconnect(e,t){return this.addListener(re.reconnect,e,t),this}build(){return new Dc(this._url,this._protocols,this._options)}addListener(e,t,n){var i,s,a,o,c,l,u,f,p,m,x,T,g,v,b,_,w,C,P,E,I;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:(p=(f=(u=this._options)===null||u===void 0?void 0:u.listeners)===null||f===void 0?void 0:f.error)!==null&&p!==void 0?p:[],message:(T=(x=(m=this._options)===null||m===void 0?void 0:m.listeners)===null||x===void 0?void 0:x.message)!==null&&T!==void 0?T:[],retry:(b=(v=(g=this._options)===null||g===void 0?void 0:g.listeners)===null||v===void 0?void 0:v.retry)!==null&&b!==void 0?b:[],reconnect:(C=(w=(_=this._options)===null||_===void 0?void 0:_.listeners)===null||w===void 0?void 0:w.reconnect)!==null&&C!==void 0?C:[],[e]:[...(I=(E=(P=this._options)===null||P===void 0?void 0:P.listeners)===null||E===void 0?void 0:E[e])!==null&&I!==void 0?I:[],{listener:t,options:n}]}}),this}}const Eh=Object.freeze(Object.defineProperty({__proto__:null,ExponentialBackoff:wh,Websocket:Dc,WebsocketBuilder:Ph,get WebsocketEvent(){return re}},Symbol.toStringTag,{value:"Module"})),uo=0,Fc=1,Lc=2,$s=2,xs=1.25,_a=1,ii=32,Lr=65535,kh=Math.pow(2,-24),_s=Symbol("SKIP_GENERATION");function Rh(r){return r.index?r.index.count:r.attributes.position.count}function Un(r){return Rh(r)/3}function Ah(r,e=ArrayBuffer){return r>65535?new Uint32Array(new e(4*r)):new Uint16Array(new e(2*r))}function Oh(r,e){if(!r.index){const t=r.attributes.position.count,n=e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,i=Ah(t,n);r.setIndex(new R.BufferAttribute(i,1));for(let s=0;s<t;s++)i[s]=s}}function Vc(r,e){const t=Un(r),n=e||r.drawRange,i=n.start/3,s=(n.start+n.count)/3,a=Math.max(0,i),o=Math.min(t,s)-a;return[{offset:Math.floor(a),count:Math.floor(o)}]}function Jc(r,e){if(!r.groups||!r.groups.length)return Vc(r,e);const t=[],n=new Set,i=e||r.drawRange,s=i.start/3,a=(i.start+i.count)/3;for(const c of r.groups){const l=c.start/3,u=(c.start+c.count)/3;n.add(Math.max(s,l)),n.add(Math.min(a,u))}const o=Array.from(n.values()).sort((c,l)=>c-l);for(let c=0;c<o.length-1;c++){const l=o[c],u=o[c+1];t.push({offset:Math.floor(l),count:Math.floor(u-l)})}return t}function zh(r,e){const t=Un(r),n=Jc(r,e).sort((a,o)=>a.offset-o.offset),i=n[n.length-1];i.count=Math.min(t-i.offset,i.count);let s=0;return n.forEach(({count:a})=>s+=a),t!==s}function bs(r,e,t,n,i){let s=1/0,a=1/0,o=1/0,c=-1/0,l=-1/0,u=-1/0,f=1/0,p=1/0,m=1/0,x=-1/0,T=-1/0,g=-1/0;for(let v=e*6,b=(e+t)*6;v<b;v+=6){const _=r[v+0],w=r[v+1],C=_-w,P=_+w;C<s&&(s=C),P>c&&(c=P),_<f&&(f=_),_>x&&(x=_);const E=r[v+2],I=r[v+3],O=E-I,A=E+I;O<a&&(a=O),A>l&&(l=A),E<p&&(p=E),E>T&&(T=E);const N=r[v+4],B=r[v+5],D=N-B,L=N+B;D<o&&(o=D),L>u&&(u=L),N<m&&(m=N),N>g&&(g=N)}n[0]=s,n[1]=a,n[2]=o,n[3]=c,n[4]=l,n[5]=u,i[0]=f,i[1]=p,i[2]=m,i[3]=x,i[4]=T,i[5]=g}function Ih(r,e=null,t=null,n=null){const i=r.attributes.position,s=r.index?r.index.array:null,a=Un(r),o=i.normalized;let c;e===null?(c=new Float32Array(a*6),t=0,n=a):(c=e,t=t||0,n=n||a);const l=i.array,u=i.offset||0;let f=3;i.isInterleavedBufferAttribute&&(f=i.data.stride);const p=["getX","getY","getZ"];for(let m=t;m<t+n;m++){const x=m*3,T=m*6;let g=x+0,v=x+1,b=x+2;s&&(g=s[g],v=s[v],b=s[b]),o||(g=g*f+u,v=v*f+u,b=b*f+u);for(let _=0;_<3;_++){let w,C,P;o?(w=i[p[_]](g),C=i[p[_]](v),P=i[p[_]](b)):(w=l[g+_],C=l[v+_],P=l[b+_]);let E=w;C<E&&(E=C),P<E&&(E=P);let I=w;C>I&&(I=C),P>I&&(I=P);const O=(I-E)/2,A=_*2;c[T+A+0]=E+O,c[T+A+1]=O+(Math.abs(E)+O)*kh}}return c}function ve(r,e,t){return t.min.x=e[r],t.min.y=e[r+1],t.min.z=e[r+2],t.max.x=e[r+3],t.max.y=e[r+4],t.max.z=e[r+5],t}function ba(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 Ta(r,e){e.set(r)}function Ma(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 rr(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 jn(r){const e=r[3]-r[0],t=r[4]-r[1],n=r[5]-r[2];return 2*(e*t+t*n+n*e)}const Ft=32,Bh=(r,e)=>r.candidate-e.candidate,qt=new Array(Ft).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),sr=new Float32Array(6);function Nh(r,e,t,n,i,s){let a=-1,o=0;if(s===uo)a=ba(e),a!==-1&&(o=(e[a]+e[a+3])/2);else if(s===Fc)a=ba(r),a!==-1&&(o=Uh(t,n,i,a));else if(s===Lc){const c=jn(r);let l=xs*i;const u=n*6,f=(n+i)*6;for(let p=0;p<3;p++){const m=e[p],g=(e[p+3]-m)/Ft;if(i<Ft/4){const v=[...qt];v.length=i;let b=0;for(let w=u;w<f;w+=6,b++){const C=v[b];C.candidate=t[w+2*p],C.count=0;const{bounds:P,leftCacheBounds:E,rightCacheBounds:I}=C;for(let O=0;O<3;O++)I[O]=1/0,I[O+3]=-1/0,E[O]=1/0,E[O+3]=-1/0,P[O]=1/0,P[O+3]=-1/0;rr(w,t,P)}v.sort(Bh);let _=i;for(let w=0;w<_;w++){const C=v[w];for(;w+1<_&&v[w+1].candidate===C.candidate;)v.splice(w+1,1),_--}for(let w=u;w<f;w+=6){const C=t[w+2*p];for(let P=0;P<_;P++){const E=v[P];C>=E.candidate?rr(w,t,E.rightCacheBounds):(rr(w,t,E.leftCacheBounds),E.count++)}}for(let w=0;w<_;w++){const C=v[w],P=C.count,E=i-C.count,I=C.leftCacheBounds,O=C.rightCacheBounds;let A=0;P!==0&&(A=jn(I)/c);let N=0;E!==0&&(N=jn(O)/c);const B=_a+xs*(A*P+N*E);B<l&&(a=p,l=B,o=C.candidate)}}else{for(let _=0;_<Ft;_++){const w=qt[_];w.count=0,w.candidate=m+g+_*g;const C=w.bounds;for(let P=0;P<3;P++)C[P]=1/0,C[P+3]=-1/0}for(let _=u;_<f;_+=6){let P=~~((t[_+2*p]-m)/g);P>=Ft&&(P=Ft-1);const E=qt[P];E.count++,rr(_,t,E.bounds)}const v=qt[Ft-1];Ta(v.bounds,v.rightCacheBounds);for(let _=Ft-2;_>=0;_--){const w=qt[_],C=qt[_+1];Ma(w.bounds,C.rightCacheBounds,w.rightCacheBounds)}let b=0;for(let _=0;_<Ft-1;_++){const w=qt[_],C=w.count,P=w.bounds,I=qt[_+1].rightCacheBounds;C!==0&&(b===0?Ta(P,sr):Ma(P,sr,sr)),b+=C;let O=0,A=0;b!==0&&(O=jn(sr)/c);const N=i-b;N!==0&&(A=jn(I)/c);const B=_a+xs*(O*b+A*N);B<l&&(a=p,l=B,o=w.candidate)}}}}else console.warn(`MeshBVH: Invalid build strategy value ${s} used.`);return{axis:a,pos:o}}function Uh(r,e,t,n){let i=0;for(let s=e,a=e+t;s<a;s++)i+=r[s*6+n*2];return i/t}class Ts{constructor(){this.boundingData=new Float32Array(6)}}function Dh(r,e,t,n,i,s){let a=n,o=n+i-1;const c=s.pos,l=s.axis*2;for(;;){for(;a<=o&&t[a*6+l]<c;)a++;for(;a<=o&&t[o*6+l]>=c;)o--;if(a<o){for(let u=0;u<3;u++){let f=e[a*3+u];e[a*3+u]=e[o*3+u],e[o*3+u]=f}for(let u=0;u<6;u++){let f=t[a*6+u];t[a*6+u]=t[o*6+u],t[o*6+u]=f}a++,o--}else return a}}function Fh(r,e,t,n,i,s){let a=n,o=n+i-1;const c=s.pos,l=s.axis*2;for(;;){for(;a<=o&&t[a*6+l]<c;)a++;for(;a<=o&&t[o*6+l]>=c;)o--;if(a<o){let u=r[a];r[a]=r[o],r[o]=u;for(let f=0;f<6;f++){let p=t[a*6+f];t[a*6+f]=t[o*6+f],t[o*6+f]=p}a++,o--}else return a}}function Ke(r,e){return e[r+15]===65535}function rt(r,e){return e[r+6]}function ut(r,e){return e[r+14]}function ht(r){return r+8}function ft(r,e){return e[r+6]}function jc(r,e){return e[r+7]}let Gc,ei,Cr,$c;const Lh=Math.pow(2,32);function Ws(r){return"count"in r?1:1+Ws(r.left)+Ws(r.right)}function Vh(r,e,t){return Gc=new Float32Array(t),ei=new Uint32Array(t),Cr=new Uint16Array(t),$c=new Uint8Array(t),Hs(r,e)}function Hs(r,e){const t=r/4,n=r/2,i="count"in e,s=e.boundingData;for(let a=0;a<6;a++)Gc[t+a]=s[a];if(i)if(e.buffer){const a=e.buffer;$c.set(new Uint8Array(a),r);for(let o=r,c=r+a.byteLength;o<c;o+=ii){const l=o/2;Ke(l,Cr)||(ei[o/4+6]+=t)}return r+a.byteLength}else{const a=e.offset,o=e.count;return ei[t+6]=a,Cr[n+14]=o,Cr[n+15]=Lr,r+ii}else{const a=e.left,o=e.right,c=e.splitAxis;let l;if(l=Hs(r+ii,a),l/4>Lh)throw new Error("MeshBVH: Cannot store child pointer greater than 32 bits.");return ei[t+6]=l/4,l=Hs(l,o),ei[t+7]=c,l}}function Jh(r,e){const t=(r.index?r.index.count:r.attributes.position.count)/3,n=t>2**16,i=n?4:2,s=e?new SharedArrayBuffer(t*i):new ArrayBuffer(t*i),a=n?new Uint32Array(s):new Uint16Array(s);for(let o=0,c=a.length;o<c;o++)a[o]=o;return a}function jh(r,e,t,n,i){const{maxDepth:s,verbose:a,maxLeafTris:o,strategy:c,onProgress:l,indirect:u}=i,f=r._indirectBuffer,p=r.geometry,m=p.index?p.index.array:null,x=u?Fh:Dh,T=Un(p),g=new Float32Array(6);let v=!1;const b=new Ts;return bs(e,t,n,b.boundingData,g),w(b,t,n,g),b;function _(C){l&&l(C/T)}function w(C,P,E,I=null,O=0){if(!v&&O>=s&&(v=!0,a&&(console.warn(`MeshBVH: Max depth of ${s} reached when generating BVH. Consider increasing maxDepth.`),console.warn(p))),E<=o||O>=s)return _(P+E),C.offset=P,C.count=E,C;const A=Nh(C.boundingData,I,e,P,E,c);if(A.axis===-1)return _(P+E),C.offset=P,C.count=E,C;const N=x(f,m,e,P,E,A);if(N===P||N===P+E)_(P+E),C.offset=P,C.count=E;else{C.splitAxis=A.axis;const B=new Ts,D=P,L=N-P;C.left=B,bs(e,D,L,B.boundingData,g),w(B,D,L,g,O+1);const J=new Ts,W=N,Y=E-L;C.right=J,bs(e,W,Y,J.boundingData,g),w(J,W,Y,g,O+1)}return C}}function Gh(r,e){const t=r.geometry;e.indirect&&(r._indirectBuffer=Jh(t,e.useSharedArrayBuffer),zh(t,e.range)&&!e.verbose&&console.warn('MeshBVH: Provided geometry contains groups or a range that do not fully span the vertex contents while using the "indirect" option. BVH may incorrectly report intersections on unrendered portions of the geometry.')),r._indirectBuffer||Oh(t,e);const n=e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,i=Ih(t),s=e.indirect?Vc(t,e.range):Jc(t,e.range);r._roots=s.map(a=>{const o=jh(r,i,a.offset,a.count,e),c=Ws(o),l=new n(ii*c);return Vh(0,o,l),l})}class Gt{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 c=e[s][t];n=c<n?c:n,i=c>i?c: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}}Gt.prototype.setFromBox=(function(){const r=new R.Vector3;return function(t,n){const i=n.min,s=n.max;let a=1/0,o=-1/0;for(let c=0;c<=1;c++)for(let l=0;l<=1;l++)for(let u=0;u<=1;u++){r.x=i.x*c+s.x*(1-c),r.y=i.y*l+s.y*(1-l),r.z=i.z*u+s.z*(1-u);const f=t.dot(r);a=Math.min(f,a),o=Math.max(f,o)}this.min=a,this.max=o}})();const $h=(function(){const r=new R.Vector3,e=new R.Vector3,t=new R.Vector3;return function(i,s,a){const o=i.start,c=r,l=s.start,u=e;t.subVectors(o,l),r.subVectors(i.end,i.start),e.subVectors(s.end,s.start);const f=t.dot(u),p=u.dot(c),m=u.dot(u),x=t.dot(c),g=c.dot(c)*m-p*p;let v,b;g!==0?v=(f*p-x*m)/g:v=0,b=(f+v*p)/m,a.x=v,a.y=b}})(),ho=(function(){const r=new R.Vector2,e=new R.Vector3,t=new R.Vector3;return function(i,s,a,o){$h(i,s,r);let c=r.x,l=r.y;if(c>=0&&c<=1&&l>=0&&l<=1){i.at(c,a),s.at(l,o);return}else if(c>=0&&c<=1){l<0?s.at(0,o):s.at(1,o),i.closestPointToPoint(o,!0,a);return}else if(l>=0&&l<=1){c<0?i.at(0,a):i.at(1,a),s.closestPointToPoint(a,!0,o);return}else{let u;c<0?u=i.start:u=i.end;let f;l<0?f=s.start:f=s.end;const p=e,m=t;if(i.closestPointToPoint(f,!0,e),s.closestPointToPoint(u,!0,t),p.distanceToSquared(f)<=m.distanceToSquared(u)){a.copy(p),o.copy(f);return}else{a.copy(u),o.copy(m);return}}}})(),Wh=(function(){const r=new R.Vector3,e=new R.Vector3,t=new R.Plane,n=new R.Line3;return function(s,a){const{radius:o,center:c}=s,{a:l,b:u,c:f}=a;if(n.start=l,n.end=u,n.closestPointToPoint(c,!0,r).distanceTo(c)<=o||(n.start=l,n.end=f,n.closestPointToPoint(c,!0,r).distanceTo(c)<=o)||(n.start=u,n.end=f,n.closestPointToPoint(c,!0,r).distanceTo(c)<=o))return!0;const T=a.getPlane(t);if(Math.abs(T.distanceToPoint(c))<=o){const v=T.projectPoint(c,e);if(a.containsPoint(v))return!0}return!1}})(),Hh=1e-15;function Ms(r){return Math.abs(r)<Hh}class pt extends R.Triangle{constructor(...e){super(...e),this.isExtendedTriangle=!0,this.satAxes=new Array(4).fill().map(()=>new R.Vector3),this.satBounds=new Array(4).fill().map(()=>new Gt),this.points=[this.a,this.b,this.c],this.sphere=new R.Sphere,this.plane=new R.Plane,this.needsUpdate=!0}intersectsSphere(e){return Wh(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 f=s[2],p=a[2];f.subVectors(t,n),p.setFromPoints(f,i);const m=s[3],x=a[3];m.subVectors(n,e),x.setFromPoints(m,i),this.sphere.setFromPoints(this.points),this.plane.setFromNormalAndCoplanarPoint(o,e),this.needsUpdate=!1}}pt.prototype.closestPointToSegment=(function(){const r=new R.Vector3,e=new R.Vector3,t=new R.Line3;return function(i,s=null,a=null){const{start:o,end:c}=i,l=this.points;let u,f=1/0;for(let p=0;p<3;p++){const m=(p+1)%3;t.start.copy(l[p]),t.end.copy(l[m]),ho(t,i,r,e),u=r.distanceToSquared(e),u<f&&(f=u,s&&s.copy(r),a&&a.copy(e))}return this.closestPointToPoint(o,r),u=o.distanceToSquared(r),u<f&&(f=u,s&&s.copy(r),a&&a.copy(o)),this.closestPointToPoint(c,r),u=c.distanceToSquared(r),u<f&&(f=u,s&&s.copy(r),a&&a.copy(c)),Math.sqrt(f)}})();pt.prototype.intersectsTriangle=(function(){const r=new pt,e=new Array(3),t=new Array(3),n=new Gt,i=new Gt,s=new R.Vector3,a=new R.Vector3,o=new R.Vector3,c=new R.Vector3,l=new R.Vector3,u=new R.Line3,f=new R.Line3,p=new R.Line3,m=new R.Vector3;function x(T,g,v){const b=T.points;let _=0,w=-1;for(let C=0;C<3;C++){const{start:P,end:E}=u;P.copy(b[C]),E.copy(b[(C+1)%3]),u.delta(a);const I=Ms(g.distanceToPoint(P));if(Ms(g.normal.dot(a))&&I){v.copy(u),_=2;break}const O=g.intersectLine(u,m);if(!O&&I&&m.copy(P),(O||I)&&!Ms(m.distanceTo(E))){if(_<=1)(_===1?v.start:v.end).copy(m),I&&(w=_);else if(_>=2){(w===1?v.start:v.end).copy(m),_=2;break}if(_++,_===2&&w===-1)break}}return _}return function(g,v=null,b=!1){this.needsUpdate&&this.update(),g.isExtendedTriangle?g.needsUpdate&&g.update():(r.copy(g),r.update(),g=r);const _=this.plane,w=g.plane;if(Math.abs(_.normal.dot(w.normal))>1-1e-10){const C=this.satBounds,P=this.satAxes;t[0]=g.a,t[1]=g.b,t[2]=g.c;for(let O=0;O<4;O++){const A=C[O],N=P[O];if(n.setFromPoints(N,t),A.isSeparated(n))return!1}const E=g.satBounds,I=g.satAxes;e[0]=this.a,e[1]=this.b,e[2]=this.c;for(let O=0;O<4;O++){const A=E[O],N=I[O];if(n.setFromPoints(N,e),A.isSeparated(n))return!1}for(let O=0;O<4;O++){const A=P[O];for(let N=0;N<4;N++){const B=I[N];if(s.crossVectors(A,B),n.setFromPoints(s,e),i.setFromPoints(s,t),n.isSeparated(i))return!1}}return v&&(b||console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."),v.start.set(0,0,0),v.end.set(0,0,0)),!0}else{const C=x(this,w,f);if(C===1&&g.containsPoint(f.end))return v&&(v.start.copy(f.end),v.end.copy(f.end)),!0;if(C!==2)return!1;const P=x(g,_,p);if(P===1&&this.containsPoint(p.end))return v&&(v.start.copy(p.end),v.end.copy(p.end)),!0;if(P!==2)return!1;if(f.delta(o),p.delta(c),o.dot(c)<0){let D=p.start;p.start=p.end,p.end=D}const E=f.start.dot(o),I=f.end.dot(o),O=p.start.dot(o),A=p.end.dot(o),N=I<O,B=E<A;return E!==A&&O!==I&&N===B?!1:(v&&(l.subVectors(f.start,p.start),l.dot(o)>0?v.start.copy(f.start):v.start.copy(p.start),l.subVectors(f.end,p.end),l.dot(o)<0?v.end.copy(f.end):v.end.copy(p.end)),!0)}}})();pt.prototype.distanceToPoint=(function(){const r=new R.Vector3;return function(t){return this.closestPointToPoint(t,r),t.distanceTo(r)}})();pt.prototype.distanceToTriangle=(function(){const r=new R.Vector3,e=new R.Vector3,t=["a","b","c"],n=new R.Line3,i=new R.Line3;return function(a,o=null,c=null){const l=o||c?n:null;if(this.intersectsTriangle(a,l))return(o||c)&&(o&&l.getCenter(o),c&&l.getCenter(c)),0;let u=1/0;for(let f=0;f<3;f++){let p;const m=t[f],x=a[m];this.closestPointToPoint(x,r),p=x.distanceToSquared(r),p<u&&(u=p,o&&o.copy(r),c&&c.copy(x));const T=this[m];a.closestPointToPoint(T,r),p=T.distanceToSquared(r),p<u&&(u=p,o&&o.copy(T),c&&c.copy(r))}for(let f=0;f<3;f++){const p=t[f],m=t[(f+1)%3];n.set(this[p],this[m]);for(let x=0;x<3;x++){const T=t[x],g=t[(x+1)%3];i.set(a[T],a[g]),ho(n,i,r,e);const v=r.distanceToSquared(e);v<u&&(u=v,o&&o.copy(r),c&&c.copy(e))}}return Math.sqrt(u)}})();class Le{constructor(e,t,n){this.isOrientedBox=!0,this.min=new R.Vector3,this.max=new R.Vector3,this.matrix=new R.Matrix4,this.invMatrix=new R.Matrix4,this.points=new Array(8).fill().map(()=>new R.Vector3),this.satAxes=new Array(3).fill().map(()=>new R.Vector3),this.satBounds=new Array(3).fill().map(()=>new Gt),this.alignedSatBounds=new Array(3).fill().map(()=>new Gt),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}}Le.prototype.update=(function(){return function(){const e=this.matrix,t=this.min,n=this.max,i=this.points;for(let l=0;l<=1;l++)for(let u=0;u<=1;u++)for(let f=0;f<=1;f++){const p=1*l|2*u|4*f,m=i[p];m.x=l?n.x:t.x,m.y=u?n.y:t.y,m.z=f?n.z:t.z,m.applyMatrix4(e)}const s=this.satBounds,a=this.satAxes,o=i[0];for(let l=0;l<3;l++){const u=a[l],f=s[l],p=1<<l,m=i[p];u.subVectors(o,m),f.setFromPoints(u,i)}const c=this.alignedSatBounds;c[0].setFromPointsField(i,"x"),c[1].setFromPointsField(i,"y"),c[2].setFromPointsField(i,"z"),this.invMatrix.copy(this.matrix).invert(),this.needsUpdate=!1}})();Le.prototype.intersectsBox=(function(){const r=new Gt;return function(t){this.needsUpdate&&this.update();const n=t.min,i=t.max,s=this.satBounds,a=this.satAxes,o=this.alignedSatBounds;if(r.min=n.x,r.max=i.x,o[0].isSeparated(r)||(r.min=n.y,r.max=i.y,o[1].isSeparated(r))||(r.min=n.z,r.max=i.z,o[2].isSeparated(r)))return!1;for(let c=0;c<3;c++){const l=a[c],u=s[c];if(r.setFromBox(l,t),u.isSeparated(r))return!1}return!0}})();Le.prototype.intersectsTriangle=(function(){const r=new pt,e=new Array(3),t=new Gt,n=new Gt,i=new R.Vector3;return function(a){this.needsUpdate&&this.update(),a.isExtendedTriangle?a.needsUpdate&&a.update():(r.copy(a),r.update(),a=r);const o=this.satBounds,c=this.satAxes;e[0]=a.a,e[1]=a.b,e[2]=a.c;for(let p=0;p<3;p++){const m=o[p],x=c[p];if(t.setFromPoints(x,e),m.isSeparated(t))return!1}const l=a.satBounds,u=a.satAxes,f=this.points;for(let p=0;p<3;p++){const m=l[p],x=u[p];if(t.setFromPoints(x,f),m.isSeparated(t))return!1}for(let p=0;p<3;p++){const m=c[p];for(let x=0;x<4;x++){const T=u[x];if(i.crossVectors(m,T),t.setFromPoints(i,e),n.setFromPoints(i,f),t.isSeparated(n))return!1}}return!0}})();Le.prototype.closestPointToPoint=(function(){return function(e,t){return this.needsUpdate&&this.update(),t.copy(e).applyMatrix4(this.invMatrix).clamp(this.min,this.max).applyMatrix4(this.matrix),t}})();Le.prototype.distanceToPoint=(function(){const r=new R.Vector3;return function(t){return this.closestPointToPoint(t,r),t.distanceTo(r)}})();Le.prototype.distanceToBox=(function(){const r=["x","y","z"],e=new Array(12).fill().map(()=>new R.Line3),t=new Array(12).fill().map(()=>new R.Line3),n=new R.Vector3,i=new R.Vector3;return function(a,o=0,c=null,l=null){if(this.needsUpdate&&this.update(),this.intersectsBox(a))return(c||l)&&(a.getCenter(i),this.closestPointToPoint(i,n),a.closestPointToPoint(n,i),c&&c.copy(n),l&&l.copy(i)),0;const u=o*o,f=a.min,p=a.max,m=this.points;let x=1/0;for(let g=0;g<8;g++){const v=m[g];i.copy(v).clamp(f,p);const b=v.distanceToSquared(i);if(b<x&&(x=b,c&&c.copy(v),l&&l.copy(i),b<u))return Math.sqrt(b)}let T=0;for(let g=0;g<3;g++)for(let v=0;v<=1;v++)for(let b=0;b<=1;b++){const _=(g+1)%3,w=(g+2)%3,C=v<<_|b<<w,P=1<<g|v<<_|b<<w,E=m[C],I=m[P];e[T].set(E,I);const A=r[g],N=r[_],B=r[w],D=t[T],L=D.start,J=D.end;L[A]=f[A],L[N]=v?f[N]:p[N],L[B]=b?f[B]:p[N],J[A]=p[A],J[N]=v?f[N]:p[N],J[B]=b?f[B]:p[N],T++}for(let g=0;g<=1;g++)for(let v=0;v<=1;v++)for(let b=0;b<=1;b++){i.x=g?p.x:f.x,i.y=v?p.y:f.y,i.z=b?p.z:f.z,this.closestPointToPoint(i,n);const _=i.distanceToSquared(n);if(_<x&&(x=_,c&&c.copy(n),l&&l.copy(i),_<u))return Math.sqrt(_)}for(let g=0;g<12;g++){const v=e[g];for(let b=0;b<12;b++){const _=t[b];ho(v,_,n,i);const w=n.distanceToSquared(i);if(w<x&&(x=w,c&&c.copy(n),l&&l.copy(i),w<u))return Math.sqrt(w)}}return Math.sqrt(x)}})();class fo{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 qh extends fo{constructor(){super(()=>new pt)}}const dt=new qh;class Xh{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 fe=new Xh;let Kt,An;const Tn=[],or=new fo(()=>new R.Box3);function Yh(r,e,t,n,i,s){Kt=or.getPrimitive(),An=or.getPrimitive(),Tn.push(Kt,An),fe.setBuffer(r._roots[e]);const a=qs(0,r.geometry,t,n,i,s);fe.clearBuffer(),or.releasePrimitive(Kt),or.releasePrimitive(An),Tn.pop(),Tn.pop();const o=Tn.length;return o>0&&(An=Tn[o-1],Kt=Tn[o-2]),a}function qs(r,e,t,n,i=null,s=0,a=0){const{float32Array:o,uint16Array:c,uint32Array:l}=fe;let u=r*2;if(Ke(u,c)){const p=rt(r,l),m=ut(u,c);return ve(r,o,Kt),n(p,m,!1,a,s+r,Kt)}else{let A=function(B){const{uint16Array:D,uint32Array:L}=fe;let J=B*2;for(;!Ke(J,D);)B=ht(B),J=B*2;return rt(B,L)},N=function(B){const{uint16Array:D,uint32Array:L}=fe;let J=B*2;for(;!Ke(J,D);)B=ft(B,L),J=B*2;return rt(B,L)+ut(J,D)};const p=ht(r),m=ft(r,l);let x=p,T=m,g,v,b,_;if(i&&(b=Kt,_=An,ve(x,o,b),ve(T,o,_),g=i(b),v=i(_),v<g)){x=m,T=p;const B=g;g=v,v=B,b=_}b||(b=Kt,ve(x,o,b));const w=Ke(x*2,c),C=t(b,w,g,a+1,s+x);let P;if(C===$s){const B=A(x),L=N(x)-B;P=n(B,L,!0,a+1,s+x,b)}else P=C&&qs(x,e,t,n,i,s,a+1);if(P)return!0;_=An,ve(T,o,_);const E=Ke(T*2,c),I=t(_,E,v,a+1,s+T);let O;if(I===$s){const B=A(T),L=N(T)-B;O=n(B,L,!0,a+1,s+T,_)}else O=I&&qs(T,e,t,n,i,s,a+1);return!!O}}const Gn=new R.Vector3,Cs=new R.Vector3;function Zh(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=>(Gn.copy(e).clamp(u.min,u.max),Gn.distanceToSquared(e)),intersectsBounds:(u,f,p)=>p<o&&p<a,intersectsTriangle:(u,f)=>{u.closestPointToPoint(e,Gn);const p=e.distanceToSquared(Gn);return p<o&&(Cs.copy(Gn),o=p,c=f),p<s}}),o===1/0)return null;const l=Math.sqrt(o);return t.point?t.point.copy(Cs):t.point=Cs.clone(),t.distance=l,t.faceIndex=c,t}const Kh=parseInt(R.REVISION)>=169,sn=new R.Vector3,on=new R.Vector3,an=new R.Vector3,ar=new R.Vector2,cr=new R.Vector2,lr=new R.Vector2,Ca=new R.Vector3,wa=new R.Vector3,Pa=new R.Vector3,$n=new R.Vector3;function Qh(r,e,t,n,i,s,a,o){let c;if(s===R.BackSide?c=r.intersectTriangle(n,t,e,!0,i):c=r.intersectTriangle(e,t,n,s!==R.DoubleSide,i),c===null)return null;const l=r.origin.distanceTo(i);return l<a||l>o?null:{distance:l,point:i.clone()}}function ef(r,e,t,n,i,s,a,o,c,l,u){sn.fromBufferAttribute(e,s),on.fromBufferAttribute(e,a),an.fromBufferAttribute(e,o);const f=Qh(r,sn,on,an,$n,c,l,u);if(f){const p=new R.Vector3;R.Triangle.getBarycoord($n,sn,on,an,p),n&&(ar.fromBufferAttribute(n,s),cr.fromBufferAttribute(n,a),lr.fromBufferAttribute(n,o),f.uv=R.Triangle.getInterpolation($n,sn,on,an,ar,cr,lr,new R.Vector2)),i&&(ar.fromBufferAttribute(i,s),cr.fromBufferAttribute(i,a),lr.fromBufferAttribute(i,o),f.uv1=R.Triangle.getInterpolation($n,sn,on,an,ar,cr,lr,new R.Vector2)),t&&(Ca.fromBufferAttribute(t,s),wa.fromBufferAttribute(t,a),Pa.fromBufferAttribute(t,o),f.normal=R.Triangle.getInterpolation($n,sn,on,an,Ca,wa,Pa,new R.Vector3),f.normal.dot(r.direction)>0&&f.normal.multiplyScalar(-1));const m={a:s,b:a,c:o,normal:new R.Vector3,materialIndex:0};R.Triangle.getNormal(sn,on,an,m.normal),f.face=m,f.faceIndex=s,Kh&&(f.barycoord=p)}return f}function Vr(r,e,t,n,i,s,a){const o=n*3;let c=o+0,l=o+1,u=o+2;const f=r.index;r.index&&(c=f.getX(c),l=f.getX(l),u=f.getX(u));const{position:p,normal:m,uv:x,uv1:T}=r.attributes,g=ef(t,p,m,x,T,c,l,u,e,s,a);return g?(g.faceIndex=n,i&&i.push(g),g):null}function Me(r,e,t,n){const i=r.a,s=r.b,a=r.c;let o=e,c=e+1,l=e+2;t&&(o=t.getX(o),c=t.getX(c),l=t.getX(l)),i.x=n.getX(o),i.y=n.getY(o),i.z=n.getZ(o),s.x=n.getX(c),s.y=n.getY(c),s.z=n.getZ(c),a.x=n.getX(l),a.y=n.getY(l),a.z=n.getZ(l)}function tf(r,e,t,n,i,s,a,o){const{geometry:c,_indirectBuffer:l}=r;for(let u=n,f=n+i;u<f;u++)Vr(c,e,t,u,s,a,o)}function nf(r,e,t,n,i,s,a){const{geometry:o,_indirectBuffer:c}=r;let l=1/0,u=null;for(let f=n,p=n+i;f<p;f++){let m;m=Vr(o,e,t,f,null,s,a),m&&m.distance<l&&(u=m,l=m.distance)}return u}function rf(r,e,t,n,i,s,a){const{geometry:o}=t,{index:c}=o,l=o.attributes.position;for(let u=r,f=e+r;u<f;u++){let p;if(p=u,Me(a,p*3,c,l),a.needsUpdate=!0,n(a,p,i,s))return!0}return!1}function sf(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 p=0,m=u.length;p<m;p++)s=u[p],a=new Uint32Array(s),o=new Uint16Array(s),c=new Float32Array(s),f(0,l),l+=s.byteLength;function f(p,m,x=!1){const T=p*2;if(o[T+15]===Lr){const v=a[p+6],b=o[T+14];let _=1/0,w=1/0,C=1/0,P=-1/0,E=-1/0,I=-1/0;for(let O=3*v,A=3*(v+b);O<A;O++){let N=n[O];const B=i.getX(N),D=i.getY(N),L=i.getZ(N);B<_&&(_=B),B>P&&(P=B),D<w&&(w=D),D>E&&(E=D),L<C&&(C=L),L>I&&(I=L)}return c[p+0]!==_||c[p+1]!==w||c[p+2]!==C||c[p+3]!==P||c[p+4]!==E||c[p+5]!==I?(c[p+0]=_,c[p+1]=w,c[p+2]=C,c[p+3]=P,c[p+4]=E,c[p+5]=I,!0):!1}else{const v=p+8,b=a[p+6],_=v+m,w=b+m;let C=x,P=!1,E=!1;e?C||(P=e.has(_),E=e.has(w),C=!P&&!E):(P=!0,E=!0);const I=C||P,O=C||E;let A=!1;I&&(A=f(v,m,C));let N=!1;O&&(N=f(b,m,C));const B=A||N;if(B)for(let D=0;D<3;D++){const L=v+D,J=b+D,W=c[L],Y=c[L+3],G=c[J],se=c[J+3];c[p+D]=W<G?W:G,c[p+D+3]=Y>se?Y:se}return B}}}function Qt(r,e,t,n,i){let s,a,o,c,l,u;const f=1/t.direction.x,p=1/t.direction.y,m=1/t.direction.z,x=t.origin.x,T=t.origin.y,g=t.origin.z;let v=e[r],b=e[r+3],_=e[r+1],w=e[r+3+1],C=e[r+2],P=e[r+3+2];return f>=0?(s=(v-x)*f,a=(b-x)*f):(s=(b-x)*f,a=(v-x)*f),p>=0?(o=(_-T)*p,c=(w-T)*p):(o=(w-T)*p,c=(_-T)*p),s>c||o>a||((o>s||isNaN(s))&&(s=o),(c<a||isNaN(a))&&(a=c),m>=0?(l=(C-g)*m,u=(P-g)*m):(l=(P-g)*m,u=(C-g)*m),s>u||l>a)?!1:((l>s||s!==s)&&(s=l),(u<a||a!==a)&&(a=u),s<=i&&a>=n)}function of(r,e,t,n,i,s,a,o){const{geometry:c,_indirectBuffer:l}=r;for(let u=n,f=n+i;u<f;u++){let p=l?l[u]:u;Vr(c,e,t,p,s,a,o)}}function af(r,e,t,n,i,s,a){const{geometry:o,_indirectBuffer:c}=r;let l=1/0,u=null;for(let f=n,p=n+i;f<p;f++){let m;m=Vr(o,e,t,c?c[f]:f,null,s,a),m&&m.distance<l&&(u=m,l=m.distance)}return u}function cf(r,e,t,n,i,s,a){const{geometry:o}=t,{index:c}=o,l=o.attributes.position;for(let u=r,f=e+r;u<f;u++){let p;if(p=t.resolveTriangleIndex(u),Me(a,p*3,c,l),a.needsUpdate=!0,n(a,p,i,s))return!0}return!1}function lf(r,e,t,n,i,s,a){fe.setBuffer(r._roots[e]),Xs(0,r,t,n,i,s,a),fe.clearBuffer()}function Xs(r,e,t,n,i,s,a){const{float32Array:o,uint16Array:c,uint32Array:l}=fe,u=r*2;if(Ke(u,c)){const p=rt(r,l),m=ut(u,c);tf(e,t,n,p,m,i,s,a)}else{const p=ht(r);Qt(p,o,n,s,a)&&Xs(p,e,t,n,i,s,a);const m=ft(r,l);Qt(m,o,n,s,a)&&Xs(m,e,t,n,i,s,a)}}const uf=["x","y","z"];function hf(r,e,t,n,i,s){fe.setBuffer(r._roots[e]);const a=Ys(0,r,t,n,i,s);return fe.clearBuffer(),a}function Ys(r,e,t,n,i,s){const{float32Array:a,uint16Array:o,uint32Array:c}=fe;let l=r*2;if(Ke(l,o)){const f=rt(r,c),p=ut(l,o);return nf(e,t,n,f,p,i,s)}else{const f=jc(r,c),p=uf[f],x=n.direction[p]>=0;let T,g;x?(T=ht(r),g=ft(r,c)):(T=ft(r,c),g=ht(r));const b=Qt(T,a,n,i,s)?Ys(T,e,t,n,i,s):null;if(b){const C=b.point[p];if(x?C<=a[g+f]:C>=a[g+f+3])return b}const w=Qt(g,a,n,i,s)?Ys(g,e,t,n,i,s):null;return b&&w?b.distance<=w.distance?b:w:b||w||null}}const ur=new R.Box3,Mn=new pt,Cn=new pt,Wn=new R.Matrix4,Ea=new Le,hr=new Le;function ff(r,e,t,n){fe.setBuffer(r._roots[e]);const i=Zs(0,r,t,n);return fe.clearBuffer(),i}function Zs(r,e,t,n,i=null){const{float32Array:s,uint16Array:a,uint32Array:o}=fe;let c=r*2;if(i===null&&(t.boundingBox||t.computeBoundingBox(),Ea.set(t.boundingBox.min,t.boundingBox.max,n),i=Ea),Ke(c,a)){const u=e.geometry,f=u.index,p=u.attributes.position,m=t.index,x=t.attributes.position,T=rt(r,o),g=ut(c,a);if(Wn.copy(n).invert(),t.boundsTree)return ve(r,s,hr),hr.matrix.copy(Wn),hr.needsUpdate=!0,t.boundsTree.shapecast({intersectsBounds:b=>hr.intersectsBox(b),intersectsTriangle:b=>{b.a.applyMatrix4(n),b.b.applyMatrix4(n),b.c.applyMatrix4(n),b.needsUpdate=!0;for(let _=T*3,w=(g+T)*3;_<w;_+=3)if(Me(Cn,_,f,p),Cn.needsUpdate=!0,b.intersectsTriangle(Cn))return!0;return!1}});for(let v=T*3,b=(g+T)*3;v<b;v+=3){Me(Mn,v,f,p),Mn.a.applyMatrix4(Wn),Mn.b.applyMatrix4(Wn),Mn.c.applyMatrix4(Wn),Mn.needsUpdate=!0;for(let _=0,w=m.count;_<w;_+=3)if(Me(Cn,_,m,x),Cn.needsUpdate=!0,Mn.intersectsTriangle(Cn))return!0}}else{const u=r+8,f=o[r+6];return ve(u,s,ur),!!(i.intersectsBox(ur)&&Zs(u,e,t,n,i)||(ve(f,s,ur),i.intersectsBox(ur)&&Zs(f,e,t,n,i)))}}const fr=new R.Matrix4,ws=new Le,Hn=new Le,df=new R.Vector3,pf=new R.Vector3,mf=new R.Vector3,yf=new R.Vector3;function gf(r,e,t,n={},i={},s=0,a=1/0){e.boundingBox||e.computeBoundingBox(),ws.set(e.boundingBox.min,e.boundingBox.max,t),ws.needsUpdate=!0;const o=r.geometry,c=o.attributes.position,l=o.index,u=e.attributes.position,f=e.index,p=dt.getPrimitive(),m=dt.getPrimitive();let x=df,T=pf,g=null,v=null;i&&(g=mf,v=yf);let b=1/0,_=null,w=null;return fr.copy(t).invert(),Hn.matrix.copy(fr),r.shapecast({boundsTraverseOrder:C=>ws.distanceToBox(C),intersectsBounds:(C,P,E)=>E<b&&E<a?(P&&(Hn.min.copy(C.min),Hn.max.copy(C.max),Hn.needsUpdate=!0),!0):!1,intersectsRange:(C,P)=>{if(e.boundsTree)return e.boundsTree.shapecast({boundsTraverseOrder:I=>Hn.distanceToBox(I),intersectsBounds:(I,O,A)=>A<b&&A<a,intersectsRange:(I,O)=>{for(let A=I,N=I+O;A<N;A++){Me(m,3*A,f,u),m.a.applyMatrix4(t),m.b.applyMatrix4(t),m.c.applyMatrix4(t),m.needsUpdate=!0;for(let B=C,D=C+P;B<D;B++){Me(p,3*B,l,c),p.needsUpdate=!0;const L=p.distanceToTriangle(m,x,g);if(L<b&&(T.copy(x),v&&v.copy(g),b=L,_=B,w=A),L<s)return!0}}}});{const E=Un(e);for(let I=0,O=E;I<O;I++){Me(m,3*I,f,u),m.a.applyMatrix4(t),m.b.applyMatrix4(t),m.c.applyMatrix4(t),m.needsUpdate=!0;for(let A=C,N=C+P;A<N;A++){Me(p,3*A,l,c),p.needsUpdate=!0;const B=p.distanceToTriangle(m,x,g);if(B<b&&(T.copy(x),v&&v.copy(g),b=B,_=A,w=I),B<s)return!0}}}}}),dt.releasePrimitive(p),dt.releasePrimitive(m),b===1/0?null:(n.point?n.point.copy(T):n.point=T.clone(),n.distance=b,n.faceIndex=_,i&&(i.point?i.point.copy(v):i.point=v.clone(),i.point.applyMatrix4(fr),T.applyMatrix4(fr),i.distance=T.sub(i.point).length(),i.faceIndex=w),n)}function vf(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 p=0,m=u.length;p<m;p++)s=u[p],a=new Uint32Array(s),o=new Uint16Array(s),c=new Float32Array(s),f(0,l),l+=s.byteLength;function f(p,m,x=!1){const T=p*2;if(o[T+15]===Lr){const v=a[p+6],b=o[T+14];let _=1/0,w=1/0,C=1/0,P=-1/0,E=-1/0,I=-1/0;for(let O=v,A=v+b;O<A;O++){const N=3*r.resolveTriangleIndex(O);for(let B=0;B<3;B++){let D=N+B;D=n?n[D]:D;const L=i.getX(D),J=i.getY(D),W=i.getZ(D);L<_&&(_=L),L>P&&(P=L),J<w&&(w=J),J>E&&(E=J),W<C&&(C=W),W>I&&(I=W)}}return c[p+0]!==_||c[p+1]!==w||c[p+2]!==C||c[p+3]!==P||c[p+4]!==E||c[p+5]!==I?(c[p+0]=_,c[p+1]=w,c[p+2]=C,c[p+3]=P,c[p+4]=E,c[p+5]=I,!0):!1}else{const v=p+8,b=a[p+6],_=v+m,w=b+m;let C=x,P=!1,E=!1;e?C||(P=e.has(_),E=e.has(w),C=!P&&!E):(P=!0,E=!0);const I=C||P,O=C||E;let A=!1;I&&(A=f(v,m,C));let N=!1;O&&(N=f(b,m,C));const B=A||N;if(B)for(let D=0;D<3;D++){const L=v+D,J=b+D,W=c[L],Y=c[L+3],G=c[J],se=c[J+3];c[p+D]=W<G?W:G,c[p+D+3]=Y>se?Y:se}return B}}}function Sf(r,e,t,n,i,s,a){fe.setBuffer(r._roots[e]),Ks(0,r,t,n,i,s,a),fe.clearBuffer()}function Ks(r,e,t,n,i,s,a){const{float32Array:o,uint16Array:c,uint32Array:l}=fe,u=r*2;if(Ke(u,c)){const p=rt(r,l),m=ut(u,c);of(e,t,n,p,m,i,s,a)}else{const p=ht(r);Qt(p,o,n,s,a)&&Ks(p,e,t,n,i,s,a);const m=ft(r,l);Qt(m,o,n,s,a)&&Ks(m,e,t,n,i,s,a)}}const xf=["x","y","z"];function _f(r,e,t,n,i,s){fe.setBuffer(r._roots[e]);const a=Qs(0,r,t,n,i,s);return fe.clearBuffer(),a}function Qs(r,e,t,n,i,s){const{float32Array:a,uint16Array:o,uint32Array:c}=fe;let l=r*2;if(Ke(l,o)){const f=rt(r,c),p=ut(l,o);return af(e,t,n,f,p,i,s)}else{const f=jc(r,c),p=xf[f],x=n.direction[p]>=0;let T,g;x?(T=ht(r),g=ft(r,c)):(T=ft(r,c),g=ht(r));const b=Qt(T,a,n,i,s)?Qs(T,e,t,n,i,s):null;if(b){const C=b.point[p];if(x?C<=a[g+f]:C>=a[g+f+3])return b}const w=Qt(g,a,n,i,s)?Qs(g,e,t,n,i,s):null;return b&&w?b.distance<=w.distance?b:w:b||w||null}}const dr=new R.Box3,wn=new pt,Pn=new pt,qn=new R.Matrix4,ka=new Le,pr=new Le;function bf(r,e,t,n){fe.setBuffer(r._roots[e]);const i=eo(0,r,t,n);return fe.clearBuffer(),i}function eo(r,e,t,n,i=null){const{float32Array:s,uint16Array:a,uint32Array:o}=fe;let c=r*2;if(i===null&&(t.boundingBox||t.computeBoundingBox(),ka.set(t.boundingBox.min,t.boundingBox.max,n),i=ka),Ke(c,a)){const u=e.geometry,f=u.index,p=u.attributes.position,m=t.index,x=t.attributes.position,T=rt(r,o),g=ut(c,a);if(qn.copy(n).invert(),t.boundsTree)return ve(r,s,pr),pr.matrix.copy(qn),pr.needsUpdate=!0,t.boundsTree.shapecast({intersectsBounds:b=>pr.intersectsBox(b),intersectsTriangle:b=>{b.a.applyMatrix4(n),b.b.applyMatrix4(n),b.c.applyMatrix4(n),b.needsUpdate=!0;for(let _=T,w=g+T;_<w;_++)if(Me(Pn,3*e.resolveTriangleIndex(_),f,p),Pn.needsUpdate=!0,b.intersectsTriangle(Pn))return!0;return!1}});for(let v=T,b=g+T;v<b;v++){const _=e.resolveTriangleIndex(v);Me(wn,3*_,f,p),wn.a.applyMatrix4(qn),wn.b.applyMatrix4(qn),wn.c.applyMatrix4(qn),wn.needsUpdate=!0;for(let w=0,C=m.count;w<C;w+=3)if(Me(Pn,w,m,x),Pn.needsUpdate=!0,wn.intersectsTriangle(Pn))return!0}}else{const u=r+8,f=o[r+6];return ve(u,s,dr),!!(i.intersectsBox(dr)&&eo(u,e,t,n,i)||(ve(f,s,dr),i.intersectsBox(dr)&&eo(f,e,t,n,i)))}}const mr=new R.Matrix4,Ps=new Le,Xn=new Le,Tf=new R.Vector3,Mf=new R.Vector3,Cf=new R.Vector3,wf=new R.Vector3;function Pf(r,e,t,n={},i={},s=0,a=1/0){e.boundingBox||e.computeBoundingBox(),Ps.set(e.boundingBox.min,e.boundingBox.max,t),Ps.needsUpdate=!0;const o=r.geometry,c=o.attributes.position,l=o.index,u=e.attributes.position,f=e.index,p=dt.getPrimitive(),m=dt.getPrimitive();let x=Tf,T=Mf,g=null,v=null;i&&(g=Cf,v=wf);let b=1/0,_=null,w=null;return mr.copy(t).invert(),Xn.matrix.copy(mr),r.shapecast({boundsTraverseOrder:C=>Ps.distanceToBox(C),intersectsBounds:(C,P,E)=>E<b&&E<a?(P&&(Xn.min.copy(C.min),Xn.max.copy(C.max),Xn.needsUpdate=!0),!0):!1,intersectsRange:(C,P)=>{if(e.boundsTree){const E=e.boundsTree;return E.shapecast({boundsTraverseOrder:I=>Xn.distanceToBox(I),intersectsBounds:(I,O,A)=>A<b&&A<a,intersectsRange:(I,O)=>{for(let A=I,N=I+O;A<N;A++){const B=E.resolveTriangleIndex(A);Me(m,3*B,f,u),m.a.applyMatrix4(t),m.b.applyMatrix4(t),m.c.applyMatrix4(t),m.needsUpdate=!0;for(let D=C,L=C+P;D<L;D++){const J=r.resolveTriangleIndex(D);Me(p,3*J,l,c),p.needsUpdate=!0;const W=p.distanceToTriangle(m,x,g);if(W<b&&(T.copy(x),v&&v.copy(g),b=W,_=D,w=A),W<s)return!0}}}})}else{const E=Un(e);for(let I=0,O=E;I<O;I++){Me(m,3*I,f,u),m.a.applyMatrix4(t),m.b.applyMatrix4(t),m.c.applyMatrix4(t),m.needsUpdate=!0;for(let A=C,N=C+P;A<N;A++){const B=r.resolveTriangleIndex(A);Me(p,3*B,l,c),p.needsUpdate=!0;const D=p.distanceToTriangle(m,x,g);if(D<b&&(T.copy(x),v&&v.copy(g),b=D,_=A,w=I),D<s)return!0}}}}}),dt.releasePrimitive(p),dt.releasePrimitive(m),b===1/0?null:(n.point?n.point.copy(T):n.point=T.clone(),n.distance=b,n.faceIndex=_,i&&(i.point?i.point.copy(v):i.point=v.clone(),i.point.applyMatrix4(mr),T.applyMatrix4(mr),i.distance=T.sub(i.point).length(),i.faceIndex=w),n)}function Ef(){return typeof SharedArrayBuffer<"u"}const ri=new fe.constructor,Br=new fe.constructor,Yt=new fo(()=>new R.Box3),En=new R.Box3,kn=new R.Box3,Es=new R.Box3,ks=new R.Box3;let Rs=!1;function kf(r,e,t,n){if(Rs)throw new Error("MeshBVH: Recursive calls to bvhcast not supported.");Rs=!0;const i=r._roots,s=e._roots;let a,o=0,c=0;const l=new R.Matrix4().copy(t).invert();for(let u=0,f=i.length;u<f;u++){ri.setBuffer(i[u]),c=0;const p=Yt.getPrimitive();ve(0,ri.float32Array,p),p.applyMatrix4(l);for(let m=0,x=s.length;m<x&&(Br.setBuffer(s[m]),a=Tt(0,0,t,l,n,o,c,0,0,p),Br.clearBuffer(),c+=s[m].length,!a);m++);if(Yt.releasePrimitive(p),ri.clearBuffer(),o+=i[u].length,a)break}return Rs=!1,a}function Tt(r,e,t,n,i,s=0,a=0,o=0,c=0,l=null,u=!1){let f,p;u?(f=Br,p=ri):(f=ri,p=Br);const m=f.float32Array,x=f.uint32Array,T=f.uint16Array,g=p.float32Array,v=p.uint32Array,b=p.uint16Array,_=r*2,w=e*2,C=Ke(_,T),P=Ke(w,b);let E=!1;if(P&&C)u?E=i(rt(e,v),ut(e*2,b),rt(r,x),ut(r*2,T),c,a+e,o,s+r):E=i(rt(r,x),ut(r*2,T),rt(e,v),ut(e*2,b),o,s+r,c,a+e);else if(P){const I=Yt.getPrimitive();ve(e,g,I),I.applyMatrix4(t);const O=ht(r),A=ft(r,x);ve(O,m,En),ve(A,m,kn);const N=I.intersectsBox(En),B=I.intersectsBox(kn);E=N&&Tt(e,O,n,t,i,a,s,c,o+1,I,!u)||B&&Tt(e,A,n,t,i,a,s,c,o+1,I,!u),Yt.releasePrimitive(I)}else{const I=ht(e),O=ft(e,v);ve(I,g,Es),ve(O,g,ks);const A=l.intersectsBox(Es),N=l.intersectsBox(ks);if(A&&N)E=Tt(r,I,t,n,i,s,a,o,c+1,l,u)||Tt(r,O,t,n,i,s,a,o,c+1,l,u);else if(A)if(C)E=Tt(r,I,t,n,i,s,a,o,c+1,l,u);else{const B=Yt.getPrimitive();B.copy(Es).applyMatrix4(t);const D=ht(r),L=ft(r,x);ve(D,m,En),ve(L,m,kn);const J=B.intersectsBox(En),W=B.intersectsBox(kn);E=J&&Tt(I,D,n,t,i,a,s,c,o+1,B,!u)||W&&Tt(I,L,n,t,i,a,s,c,o+1,B,!u),Yt.releasePrimitive(B)}else if(N)if(C)E=Tt(r,O,t,n,i,s,a,o,c+1,l,u);else{const B=Yt.getPrimitive();B.copy(ks).applyMatrix4(t);const D=ht(r),L=ft(r,x);ve(D,m,En),ve(L,m,kn);const J=B.intersectsBox(En),W=B.intersectsBox(kn);E=J&&Tt(O,D,n,t,i,a,s,c,o+1,B,!u)||W&&Tt(O,L,n,t,i,a,s,c,o+1,B,!u),Yt.releasePrimitive(B)}}return E}const yr=new Le,Ra=new R.Box3,Rf={strategy:uo,maxDepth:40,maxLeafTris:10,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,indirect:!1,verbose:!0,range:null};class Vi{static serialize(e,t={}){t={cloneBuffers:!0,...t};const n=e.geometry,i=e._roots,s=e._indirectBuffer,a=n.getIndex();let o;return t.cloneBuffers?o={roots:i.map(c=>c.slice()),index:a?a.array.slice():null,indirectBuffer:s?s.slice():null}:o={roots:i,index:a?a.array:null,indirectBuffer:s},o}static deserialize(e,t,n={}){n={setIndex:!0,indirect:!!e.indirectBuffer,...n};const{index:i,roots:s,indirectBuffer:a}=e,o=new Vi(t,{...n,[_s]:!0});if(o._roots=s,o._indirectBuffer=a||null,n.setIndex){const c=t.getIndex();if(c===null){const l=new R.BufferAttribute(e.index,1,!1);t.setIndex(l)}else c.array!==i&&(c.array.set(i),c.needsUpdate=!0)}return o}get indirect(){return!!this._indirectBuffer}constructor(e,t={}){if(e.isBufferGeometry){if(e.index&&e.index.isInterleavedBufferAttribute)throw new Error("MeshBVH: InterleavedBufferAttribute is not supported for the index attribute.")}else throw new Error("MeshBVH: Only BufferGeometries are supported.");if(t=Object.assign({...Rf,[_s]:!1},t),t.useSharedArrayBuffer&&!Ef())throw new Error("MeshBVH: SharedArrayBuffer is not available.");this.geometry=e,this._roots=null,this._indirectBuffer=null,t[_s]||(Gh(this,t),!e.boundingBox&&t.setBoundingBox&&(e.boundingBox=this.getBoundingBox(new R.Box3))),this.resolveTriangleIndex=t.indirect?n=>this._indirectBuffer[n]:n=>n}refit(e=null){return(this.indirect?vf:sf)(this,e)}traverse(e,t=0){const n=this._roots[t],i=new Uint32Array(n),s=new Uint16Array(n);a(0);function a(o,c=0){const l=o*2,u=s[l+15]===Lr;if(u){const f=i[o+6],p=s[l+14];e(c,u,new Float32Array(n,o*4,6),f,p)}else{const f=o+ii/4,p=i[o+6],m=i[o+7];e(c,u,new Float32Array(n,o*4,6),m)||(a(f,c+1),a(p,c+1))}}}raycast(e,t=R.FrontSide,n=0,i=1/0){const s=this._roots,a=this.geometry,o=[],c=t.isMaterial,l=Array.isArray(t),u=a.groups,f=c?t.side:t,p=this.indirect?Sf:lf;for(let m=0,x=s.length;m<x;m++){const T=l?t[u[m].materialIndex].side:f,g=o.length;if(p(this,m,T,e,o,n,i),l){const v=u[m].materialIndex;for(let b=g,_=o.length;b<_;b++)o[b].face.materialIndex=v}}return o}raycastFirst(e,t=R.FrontSide,n=0,i=1/0){const s=this._roots,a=this.geometry,o=t.isMaterial,c=Array.isArray(t);let l=null;const u=a.groups,f=o?t.side:t,p=this.indirect?_f:hf;for(let m=0,x=s.length;m<x;m++){const T=c?t[u[m].materialIndex].side:f,g=p(this,m,T,e,n,i);g!=null&&(l==null||g.distance<l.distance)&&(l=g,c&&(g.face.materialIndex=u[m].materialIndex))}return l}intersectsGeometry(e,t){let n=!1;const i=this._roots,s=this.indirect?bf:ff;for(let a=0,o=i.length;a<o&&(n=s(this,a,e,t),!n);a++);return n}shapecast(e){const t=dt.getPrimitive(),n=this.indirect?cf:rf;let{boundsTraverseOrder:i,intersectsBounds:s,intersectsRange:a,intersectsTriangle:o}=e;if(a&&o){const f=a;a=(p,m,x,T,g)=>f(p,m,x,T,g)?!0:n(p,m,this,o,x,T,t)}else a||(o?a=(f,p,m,x)=>n(f,p,this,o,m,x,t):a=(f,p,m)=>m);let c=!1,l=0;const u=this._roots;for(let f=0,p=u.length;f<p;f++){const m=u[f];if(c=Yh(this,f,s,a,i,l),c)break;l+=m.byteLength}return dt.releasePrimitive(t),c}bvhcast(e,t,n){let{intersectsRanges:i,intersectsTriangles:s}=n;const a=dt.getPrimitive(),o=this.geometry.index,c=this.geometry.attributes.position,l=this.indirect?x=>{const T=this.resolveTriangleIndex(x);Me(a,T*3,o,c)}:x=>{Me(a,x*3,o,c)},u=dt.getPrimitive(),f=e.geometry.index,p=e.geometry.attributes.position,m=e.indirect?x=>{const T=e.resolveTriangleIndex(x);Me(u,T*3,f,p)}:x=>{Me(u,x*3,f,p)};if(s){const x=(T,g,v,b,_,w,C,P)=>{for(let E=v,I=v+b;E<I;E++){m(E),u.a.applyMatrix4(t),u.b.applyMatrix4(t),u.c.applyMatrix4(t),u.needsUpdate=!0;for(let O=T,A=T+g;O<A;O++)if(l(O),a.needsUpdate=!0,s(a,u,O,E,_,w,C,P))return!0}return!1};if(i){const T=i;i=function(g,v,b,_,w,C,P,E){return T(g,v,b,_,w,C,P,E)?!0:x(g,v,b,_,w,C,P,E)}}else i=x}return kf(this,e,t,i)}intersectsBox(e,t){return yr.set(e.min,e.max,t),yr.needsUpdate=!0,this.shapecast({intersectsBounds:n=>yr.intersectsBox(n),intersectsTriangle:n=>yr.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?Pf:gf)(this,e,t,n,i,s,a)}closestPointToPoint(e,t={},n=0,i=1/0){return Zh(this,e,t,n,i)}getBoundingBox(e){return e.makeEmpty(),this._roots.forEach(n=>{ve(0,new Float32Array(n),Ra),e.union(Ra)}),e}}function Aa(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 gr=new R.Ray,Oa=new R.Vector3,za=new R.Matrix4,Af=R.Mesh.prototype.raycast,Of=R.BatchedMesh.prototype.raycast,Ia=new R.Vector3,Ie=new R.Mesh,vr=[];function zf(r,e){this.isBatchedMesh?If.call(this,r,e):Bf.call(this,r,e)}function If(r,e){if(this.boundsTrees){const t=this.boundsTrees,n=this._drawInfo||this._instanceInfo,i=this._drawRanges||this._geometryInfo,s=this.matrixWorld;Ie.material=this.material,Ie.geometry=this.geometry;const a=Ie.geometry.boundsTree,o=Ie.geometry.drawRange;Ie.geometry.boundingSphere===null&&(Ie.geometry.boundingSphere=new R.Sphere);for(let c=0,l=n.length;c<l;c++){if(!this.getVisibleAt(c))continue;const u=n[c].geometryIndex;if(Ie.geometry.boundsTree=t[u],this.getMatrixAt(c,Ie.matrixWorld).premultiply(s),!Ie.geometry.boundsTree){this.getBoundingBoxAt(u,Ie.geometry.boundingBox),this.getBoundingSphereAt(u,Ie.geometry.boundingSphere);const f=i[u];Ie.geometry.setDrawRange(f.start,f.count)}Ie.raycast(r,vr);for(let f=0,p=vr.length;f<p;f++){const m=vr[f];m.object=this,m.batchId=c,e.push(m)}vr.length=0}Ie.geometry.boundsTree=a,Ie.geometry.drawRange=o,Ie.material=null,Ie.geometry=null}else Of.call(this,r,e)}function Bf(r,e){if(this.geometry.boundsTree){if(this.material===void 0)return;za.copy(this.matrixWorld).invert(),gr.copy(r.ray).applyMatrix4(za),Ia.setFromMatrixScale(this.matrixWorld),Oa.copy(gr.direction).multiply(Ia);const t=Oa.length(),n=r.near/t,i=r.far/t,s=this.geometry.boundsTree;if(r.firstHitOnly===!0){const a=Aa(s.raycastFirst(gr,this.material,n,i),this,r);a&&e.push(a)}else{const a=s.raycast(gr,this.material,n,i);for(let o=0,c=a.length;o<c;o++){const l=Aa(a[o],this,r);l&&e.push(l)}}}else Af.call(this,r,e)}function Nf(r={}){return this.boundsTree=new Vi(this,r),this.boundsTree}const cn=new R.Vector3,ln=new R.Vector3,un=new R.Vector3,Ba=new R.Vector4,Sr=new R.Vector3,As=new R.Vector3,Na=new R.Vector4,Ua=new R.Vector4,xr=new R.Matrix4,Da=new R.Matrix4;function Yn(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 ti(r,e=null){const t=r.array.constructor,n=r.normalized,i=r.itemSize,s=e===null?r.count:e;return new R.BufferAttribute(new t(i*s),i,n)}function Wc(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 Uf(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 Fa(r,e,t){const n=r.skeleton,i=r.geometry,s=n.bones,a=n.boneInverses;Na.fromBufferAttribute(i.attributes.skinIndex,e),Ua.fromBufferAttribute(i.attributes.skinWeight,e),xr.elements.fill(0);for(let o=0;o<4;o++){const c=Ua.getComponent(o);if(c!==0){const l=Na.getComponent(o);Da.multiplyMatrices(s[l].matrixWorld,a[l]),Uf(xr,Da,c)}}return xr.multiply(r.bindMatrix).premultiply(r.bindMatrixInverse),t.transformDirection(xr),t}function Os(r,e,t,n,i){Sr.set(0,0,0);for(let s=0,a=r.length;s<a;s++){const o=e[s],c=r[s];o!==0&&(As.fromBufferAttribute(c,n),t?Sr.addScaledVector(As,o):Sr.addScaledVector(As.sub(i),o))}i.add(Sr)}function Df(r,e={useGroups:!1,updateIndex:!1,skipAttributes:[]},t=new R.BufferGeometry){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 f=r[u];let p=0;if(n!==(f.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 f.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(f.attributes[m]),p++}if(p!==o.size)throw new Error("StaticGeometryGenerator: Make sure all geometries have the same number of attributes.");if(i){let m;if(n)m=f.index.count;else if(f.attributes.position!==void 0)m=f.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 f=0;for(let p=0;p<r.length;++p)f+=r[p].index.count;t.setIndex(new R.BufferAttribute(new Uint32Array(f),1,!1)),u=!0}if(s||u){const f=t.index;let p=0,m=0;for(let x=0;x<r.length;++x){const T=r[x],g=T.index;if(a[x]!==!0)for(let v=0;v<g.count;++v)f.setX(p,g.getX(v)+m),p++;m+=T.attributes.position.count}}}for(const u in c){const f=c[u];if(!(u in t.attributes)){let x=0;for(const T in f)x+=f[T].count;t.setAttribute(u,ti(c[u][0],x))}const p=t.attributes[u];let m=0;for(let x=0,T=f.length;x<T;x++){const g=f[x];a[x]!==!0&&Wc(g,p,m),m+=g.count}}return t}function Ff(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 Lf(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 Vf{constructor(e){this.matrixWorld=new R.Matrix4,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&&Ff(e.skeleton&&e.skeleton.boneMatrices||null,this.boneMatrices)&&this.primitiveCount===n)}}class Jf{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 R.BufferGeometry),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 R.BufferGeometry){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],f=a.get(l);!f||f.didChange(l)?(this._convertToStaticGeometry(l,u),t.push(!1),f?f.update():a.set(l,new Vf(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 R.BufferAttribute(new Float32Array(0),4,!1))}else Df(s,{useGroups:i,skipAttributes:t},e);for(const o in e.attributes)e.attributes[o].needsUpdate=!0;return e}_convertToStaticGeometry(e,t=new R.BufferGeometry){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",ti(o.position)),s&&!c.normal&&o.normal&&t.setAttribute("normal",ti(o.normal)),a&&!c.tangent&&o.tangent&&t.setAttribute("tangent",ti(o.tangent)),Yn(n.index,t.index),Yn(o.position,c.position),s&&Yn(o.normal,c.normal),a&&Yn(o.tangent,c.tangent);const l=o.position,u=s?o.normal:null,f=a?o.tangent:null,p=n.morphAttributes.position,m=n.morphAttributes.normal,x=n.morphAttributes.tangent,T=n.morphTargetsRelative,g=e.morphTargetInfluences,v=new R.Matrix3;v.getNormalMatrix(e.matrixWorld),n.index&&t.index.array.set(n.index.array);for(let b=0,_=o.position.count;b<_;b++)cn.fromBufferAttribute(l,b),u&&ln.fromBufferAttribute(u,b),f&&(Ba.fromBufferAttribute(f,b),un.fromBufferAttribute(f,b)),g&&(p&&Os(p,g,T,b,cn),m&&Os(m,g,T,b,ln),x&&Os(x,g,T,b,un)),e.isSkinnedMesh&&(e.applyBoneTransform(b,cn),u&&Fa(e,b,ln),f&&Fa(e,b,un)),i&&cn.applyMatrix4(e.matrixWorld),c.position.setXYZ(b,cn.x,cn.y,cn.z),u&&(i&&ln.applyNormalMatrix(v),c.normal.setXYZ(b,ln.x,ln.y,ln.z)),f&&(i&&un.transformDirection(e.matrixWorld),c.tangent.setXYZW(b,un.x,un.y,un.z,Ba.w));for(const b in this.attributes){const _=this.attributes[b];_==="position"||_==="tangent"||_==="normal"||!(_ in o)||(c[_]||t.setAttribute(_,ti(o[_])),Yn(o[_],c[_]),Wc(o[_],c[_]))}return e.matrixWorld.determinant()<0&&Lf(t),t}}const jf=Object.freeze(Object.defineProperty({__proto__:null,AVERAGE:Fc,CENTER:uo,CONTAINED:$s,ExtendedTriangle:pt,MeshBVH:Vi,OrientedBox:Le,SAH:Lc,StaticGeometryGenerator:Jf,acceleratedRaycast:zf,computeBoundsTree:Nf},Symbol.toStringTag,{value:"Module"}));class Gf{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 lt={node:"node",material:"material",camera:"camera",light:"light"},hn="KHR_animation_pointer",$f={CUBICSPLINE:void 0,LINEAR:R.InterpolateLinear,STEP:R.InterpolateDiscrete};class Wf{constructor(e){this.name=hn,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){qf();const t=e.target,n=t.extensions&&t.extensions[hn]&&t.path&&t.path==="pointer";if(!n)return null;let i,s=lt.node,a;if(n){const c=t.extensions[hn];let l=c.pointer;if(!l){console.warn("Invalid path",c,t);return}if(l.startsWith("/materials/")?s=lt.material:l.startsWith("/extensions/KHR_lights_punctual/lights/")?s=lt.light:l.startsWith("/cameras/")&&(s=lt.camera),a=this._tryResolveTargetId(l,s),a===null||isNaN(a)){console.warn("Failed resolving animation node id: "+a,l);return}switch(s){case lt.material:const u=("/materials/"+a.toString()+"/").length,f=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=f+i;break;case lt.node:const p=("/nodes/"+a.toString()+"/").length,m=l.substring(0,p);switch(i=l.substring(p),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 lt.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 lt.camera:const T=("/cameras/"+a.toString()+"/").length,g=l.substring(0,T);switch(i=l.substring(T),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[hn].pointer=l}if(a==null||isNaN(a)){console.warn("Failed resolving animation node id: "+a,t);return}let o;return s===lt.node?o=this.parser.getDependency("node",a):s===lt.material?o=this.parser.getDependency("material",a):s===lt.light?o=this.parser.getDependency("light",a):s===lt.camera?o=this.parser.getDependency("camera",a):console.error("Unhandled type",s),o}createAnimationTracksWithAnimationPointer(e,t,n,i,s){if(!(s.extensions&&s.extensions[hn]&&s.path&&s.path==="pointer"))return null;let o=s.extensions[hn].pointer;if(!o)return null;const c=[];o=o.replaceAll("/",".");const l=o.split(".");var f=e.name!==void 0&&e.name!==null?e.name:e.uuid;if(l[2]=f,l[3]==="morphTargetInfluences"&&e.type==="Group"){for(const x of e.children)x instanceof R.SkinnedMesh&&x.morphTargetInfluences&&(l[3]=x.name,l[4]="morphTargetInfluences",m(this.parser));return c}m(this.parser);function p(x,T){try{const g=T.split(".").filter(Boolean),b=g[g.length-1].replace(/\[.*\]$/,"");return b in x?typeof x[b]=="boolean":!1}catch{return!1}}function m(x){o=l.join(".");let T,g=!1;switch(n.itemSize){case 1:Object.prototype.toString.call(n.array)==="[object Uint8Array]"&&p(e,o)?(T=R.BooleanKeyframeTrack,g=!0):T=R.NumberKeyframeTrack;break;case 2:case 3:T=R.VectorKeyframeTrack;break;case 4:o.endsWith(".quaternion")?T=R.QuaternionKeyframeTrack:T=R.ColorKeyframeTrack;break}if(!T){console.warn("Unsupported output accessor format",n);return}const v=i.interpolation!==void 0?$f[i.interpolation]:R.InterpolateLinear;let b=x._getArrayFromAccessor(n);o.endsWith(".fov")&&(b=b.map(w=>w/Math.PI*180)),g&&(b=b.map(w=>w>0));const _=new T(o,t.array,b,v);if(v==="CUBICSPLINE"&&x._createCubicSplineTrackInterpolant(_),c.push(_),o&&n.itemSize===4&&o.startsWith(".materials.")&&o.endsWith(".color")){const w=new Float32Array(b.length/4);for(let P=0,E=b.length/4;P<E;P+=1)w[P]=b[P*4+3];const C=new T(o.replace(".color",".opacity"),t.array,w,v);v==="CUBICSPLINE"&&x._createCubicSplineTrackInterpolant(_),c.push(C)}}return c}_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=[],f=[];for(let p=0,m=s.channels.length;p<m;p++){const x=s.channels[p],T=s.samplers[x.sampler],g=x.target,v=s.parameters!==void 0?s.parameters[T.input]:T.input,b=s.parameters!==void 0?s.parameters[T.output]:T.output;let _=t.loadAnimationTargetFromChannelWithAnimationPointer(x);_||(_=t.loadAnimationTargetFromChannel(x)),o.push(_),c.push(i.getDependency("accessor",v)),l.push(i.getDependency("accessor",b)),u.push(T),f.push(g)}return Promise.all([Promise.all(o),Promise.all(c),Promise.all(l),Promise.all(u),Promise.all(f)]).then(function(p){const m=p[0],x=p[1],T=p[2],g=p[3],v=p[4],b=[];for(let _=0,w=m.length;_<w;_++){const C=m[_],P=x[_],E=T[_],I=g[_],O=v[_];if(C===void 0)continue;C.updateMatrix&&(C.updateMatrix(),C.matrixAutoUpdate=!0);let A=t.createAnimationTracksWithAnimationPointer(C,P,E,I,O);if(A||(A=i._createAnimationTracks(C,P,E,I,O)),A)for(let N=0;N<A.length;N++)b.push(A[N])}return new R.AnimationClip(a,void 0,b)})}}let La=!1,Hf=null;function qf(){if(La)return;La=!0;const r=Hf||=R.PropertyBinding.findNode;R.PropertyBinding.findNode=function(e,t){if(!t)return r(e,t);if(t.startsWith(".materials.")){const n=t.substring(11).substring(t.indexOf(".")),i=n.indexOf("."),s=i<0?n:n.substring(0,i);let a=null;return e.traverse(o=>{a!==null||o.type!=="Mesh"&&o.type!=="SkinnedMesh"||o.material&&(o.material.uuid===s||o.material.name===s)&&(a=o.material,a!==null&&(n.endsWith(".map")?a=a.map:n.endsWith(".emissiveMap")&&(a=a.emissiveMap)))}),a}else if(t.startsWith(".nodes.")||t.startsWith(".lights.")||t.startsWith(".cameras.")){const n=t.split(".");let i;for(let s=1;s<n.length;s++){const a=n[s];if(a.length==36)i=e.getObjectByProperty("uuid",a);else if(i&&i[a]){const c=Number.parseInt(a);let l=a;c>=0&&(l=c),i=i[l]}else{const c=e.getObjectByName(a);c&&(i=c)}}if(!i){const s=r(e,n[2]);return s||console.warn(hn+": Property binding not found",t,e,e.name,n),s}return i}return r(e,t)}}const Xf=Object.freeze(Object.defineProperty({__proto__:null,GLTFAnimationPointerExtension:Wf},Symbol.toStringTag,{value:"Module"}));exports.$70d766613f57b014$export$2e2bcd8739ae039=kc;exports.BatchedParticleRenderer=xh;exports.Builder=to;exports.ByteBuffer=si;exports.ConstantColor=pn;exports.ConstantValue=ee;exports.Matrix4=Ct;exports.MeshBVH=Vi;exports.MotionController=gl;exports.ParticleSystem=Ir;exports.SIZE_PREFIX_LENGTH=Ja;exports.TrailParticle=Or;exports.Vector4=Qe;exports.WorkerBase=Gf;exports.bundler=Xl;exports.createNoise4D=bh;exports.fetchProfile=fl;exports.index=Eh;exports.index$1=jf;exports.index$2=Xf;exports.md5=hu;exports.v5=ou;
|