@needle-tools/engine 4.11.0-next.8bfb2f5 → 4.11.0-next.c7baa24
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 +7 -1
- package/README.md +3 -1
- package/components.needle.json +1 -1
- package/dist/{gltf-progressive-CXVECA3a.js → gltf-progressive-BvlZQAkt.js} +3 -3
- package/dist/{gltf-progressive-D4Z_Khp3.min.js → gltf-progressive-CftVUJy3.min.js} +1 -1
- package/dist/{gltf-progressive-CHeORqEv.umd.cjs → gltf-progressive-GwdQV1Qx.umd.cjs} +1 -1
- package/dist/{needle-engine.bundle-8EmDJd2O.umd.cjs → needle-engine.bundle-DBDKvYj5.umd.cjs} +142 -142
- package/dist/{needle-engine.bundle-DtF-fcok.min.js → needle-engine.bundle-qNZSuWhD.min.js} +144 -144
- package/dist/{needle-engine.bundle-lul9TfB2.js → needle-engine.bundle-tE15q9uM.js} +6264 -6202
- package/dist/needle-engine.d.ts +6 -0
- package/dist/needle-engine.js +4 -4
- package/dist/needle-engine.min.js +1 -1
- package/dist/needle-engine.umd.cjs +1 -1
- package/dist/{postprocessing-DQ2pynXW.js → postprocessing-CJC0Npcd.js} +2 -2
- package/dist/{postprocessing-BsnRNRRS.umd.cjs → postprocessing-DrM4PWU3.umd.cjs} +1 -1
- package/dist/{postprocessing-BHMVuZQ1.min.js → postprocessing-l7zsdO_Q.min.js} +1 -1
- package/dist/{three-qw28ZtTy.min.js → three-BDW9I486.min.js} +13 -13
- package/dist/{three-CJSAehtG.js → three-MHVqtJYj.js} +1 -0
- package/dist/{three-examples-Doq0rvFU.js → three-examples-C5Ht-QFN.js} +1 -1
- package/dist/{three-examples-Deqc1bNw.umd.cjs → three-examples-CgwGHSgz.umd.cjs} +1 -1
- package/dist/{three-examples-BivkhnvN.min.js → three-examples-fvEPSC8L.min.js} +1 -1
- package/dist/{three-B-jwTHao.umd.cjs → three-iFaDq9U3.umd.cjs} +13 -13
- package/dist/{three-mesh-ui-CktOi6oI.js → three-mesh-ui-BjWTTk1R.js} +1 -1
- package/dist/{three-mesh-ui-CsHwj9cJ.umd.cjs → three-mesh-ui-Bm32sS2a.umd.cjs} +1 -1
- package/dist/{three-mesh-ui-DhYXcXZe.min.js → three-mesh-ui-CLdkp21K.min.js} +1 -1
- package/dist/{vendor-BcsPRUmt.umd.cjs → vendor-CAWj5cBK.umd.cjs} +2 -2
- package/dist/{vendor-CyfN5nor.js → vendor-DJBpoQcM.js} +608 -599
- package/dist/{vendor-DyavoogU.min.js → vendor-DWGd3dEf.min.js} +20 -20
- package/lib/engine/js-extensions/Object3D.d.ts +6 -0
- package/lib/engine/js-extensions/Object3D.js +15 -0
- package/lib/engine/js-extensions/Object3D.js.map +1 -1
- package/lib/engine-components/Collider.d.ts +26 -0
- package/lib/engine-components/Collider.js +26 -0
- package/lib/engine-components/Collider.js.map +1 -1
- package/lib/engine-components/ContactShadows.d.ts +11 -2
- package/lib/engine-components/ContactShadows.js +11 -2
- package/lib/engine-components/ContactShadows.js.map +1 -1
- package/lib/engine-components/DropListener.d.ts +3 -0
- package/lib/engine-components/DropListener.js +44 -21
- package/lib/engine-components/DropListener.js.map +1 -1
- package/lib/engine-components/Duplicatable.d.ts +2 -2
- package/lib/engine-components/Duplicatable.js +2 -2
- package/lib/engine-components/EventList.d.ts +18 -1
- package/lib/engine-components/EventList.js +18 -1
- package/lib/engine-components/EventList.js.map +1 -1
- package/lib/engine-components/GroundProjection.d.ts +3 -0
- package/lib/engine-components/GroundProjection.js +3 -0
- package/lib/engine-components/GroundProjection.js.map +1 -1
- package/lib/engine-components/Interactable.d.ts +4 -0
- package/lib/engine-components/Interactable.js +4 -0
- package/lib/engine-components/Interactable.js.map +1 -1
- package/lib/engine-components/OrbitControls.d.ts +4 -2
- package/lib/engine-components/OrbitControls.js +31 -3
- package/lib/engine-components/OrbitControls.js.map +1 -1
- package/lib/engine-components/RigidBody.d.ts +5 -0
- package/lib/engine-components/RigidBody.js +5 -0
- package/lib/engine-components/RigidBody.js.map +1 -1
- package/lib/engine-components/SeeThrough.js +20 -0
- package/lib/engine-components/SeeThrough.js.map +1 -1
- package/lib/engine-components/export/usdz/ThreeUSDZExporter.d.ts +4 -2
- package/lib/engine-components/export/usdz/ThreeUSDZExporter.js +69 -14
- package/lib/engine-components/export/usdz/ThreeUSDZExporter.js.map +1 -1
- package/lib/engine-components/ui/Text.js +6 -1
- package/lib/engine-components/ui/Text.js.map +1 -1
- package/lib/engine-components/utils/LookAt.d.ts +3 -0
- package/lib/engine-components/utils/LookAt.js +3 -0
- package/lib/engine-components/utils/LookAt.js.map +1 -1
- package/lib/engine-components/utils/OpenURL.d.ts +2 -1
- package/lib/engine-components/utils/OpenURL.js +2 -1
- package/lib/engine-components/utils/OpenURL.js.map +1 -1
- package/lib/engine-components/web/ScrollFollow.js +1 -2
- package/lib/engine-components/web/ScrollFollow.js.map +1 -1
- package/lib/engine-components/webxr/WebARCameraBackground.d.ts +2 -0
- package/lib/engine-components/webxr/WebARCameraBackground.js +2 -0
- package/lib/engine-components/webxr/WebARCameraBackground.js.map +1 -1
- package/lib/engine-components/webxr/WebARSessionRoot.d.ts +1 -1
- package/lib/engine-components/webxr/WebARSessionRoot.js +1 -1
- package/lib/engine-components/webxr/WebXR.d.ts +2 -0
- package/lib/engine-components/webxr/WebXR.js +2 -0
- package/lib/engine-components/webxr/WebXR.js.map +1 -1
- package/lib/engine-components/webxr/WebXRImageTracking.d.ts +29 -0
- package/lib/engine-components/webxr/WebXRImageTracking.js +29 -0
- package/lib/engine-components/webxr/WebXRImageTracking.js.map +1 -1
- package/package.json +2 -2
- package/plugins/vite/index.js +4 -1
- package/plugins/vite/needle-app.js +103 -57
- package/src/engine/js-extensions/Object3D.ts +24 -0
- package/src/engine-components/Collider.ts +27 -1
- package/src/engine-components/ContactShadows.ts +12 -4
- package/src/engine-components/DropListener.ts +45 -24
- package/src/engine-components/Duplicatable.ts +2 -2
- package/src/engine-components/EventList.ts +18 -1
- package/src/engine-components/GroundProjection.ts +4 -1
- package/src/engine-components/Interactable.ts +4 -1
- package/src/engine-components/OrbitControls.ts +27 -3
- package/src/engine-components/RigidBody.ts +6 -1
- package/src/engine-components/SeeThrough.ts +42 -2
- package/src/engine-components/export/usdz/ThreeUSDZExporter.ts +117 -17
- package/src/engine-components/ui/Text.ts +11 -2
- package/src/engine-components/utils/LookAt.ts +3 -0
- package/src/engine-components/utils/OpenURL.ts +3 -2
- package/src/engine-components/web/ScrollFollow.ts +1 -1
- package/src/engine-components/webxr/WebARCameraBackground.ts +2 -0
- package/src/engine-components/webxr/WebARSessionRoot.ts +1 -1
- package/src/engine-components/webxr/WebXR.ts +2 -0
- package/src/engine-components/webxr/WebXRImageTracking.ts +30 -3
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{PlaneGeometry as Xo,ShaderChunk as Nl,Object3D as Yo,Layers as sr,MeshBasicMaterial as Zo,DoubleSide as ds,AdditiveBlending as Ko,InstancedBufferAttribute as ln,DynamicDrawUsage as He,InstancedBufferGeometry as Ul,Uniform$1 as Mt,ShaderMaterial as ps,BufferGeometry as Yn,BufferAttribute as ot,Mesh as fs,MeshStandardMaterial as Dl,MeshPhysicalMaterial as Ll,Triangle as un,Vector3 as W,Plane as Qo,Line3 as Gt,Vector2 as kn,Sphere as $o,Matrix4 as Ct,Box3 as Ot,BackSide as Fl,REVISION as Vl,FrontSide as ea,BatchedMesh as jl,Ray as Jl,Matrix3 as Gl,Vector4 as ms,SkinnedMesh as Wl,InterpolateDiscrete as Hl,InterpolateLinear as ta,AnimationClip as ql,QuaternionKeyframeTrack as Xl,ColorKeyframeTrack as Yl,VectorKeyframeTrack as Zl,NumberKeyframeTrack as Kl,PropertyBinding as na}from"./three-qw28ZtTy.min.js";const Re={ComponentState:Object.freeze({DEFAULT:"default",TOUCHED:"touched",PRESSED:"pressed"}),ComponentProperty:Object.freeze({BUTTON:"button",X_AXIS:"xAxis",Y_AXIS:"yAxis",STATE:"state"}),ButtonTouchThreshold:.05,AxisTouchThreshold:.1,VisualResponseProperty:Object.freeze({TRANSFORM:"transform",VISIBILITY:"visibility"})};async function ia(r){const e=await fetch(r);if(e.ok)return e.json();throw new Error(e.statusText)}async function Ql(r){return await ia(`${r}/profilesList.json`)}async function $l(r,e,t=null,n=!0){if(!r)throw new Error("No xrInputSource supplied");const i=await Ql(e);let s;if(r.profiles.some(c=>{const l=i[c];return l&&(s={profileId:c,profilePath:`${e}/${l.path}`,deprecated:!!l.deprecated}),!!s}),!s){if(!t)throw new Error("No matching profile name found");const c=i[t];if(!c)throw new Error(`No matching profile name found and default profile "${t}" missing.`);s={profileId:t,profilePath:`${e}/${c.path}`,deprecated:!!c.deprecated}}const a=await ia(s.profilePath);let o;if(n){let c;if(r.handedness==="any"?c=a.layouts[Object.keys(a.layouts)[0]]:c=a.layouts[r.handedness],!c)throw new Error(`No matching handedness, ${r.handedness}, in profile ${s.profileId}`);c.assetPath&&(o=s.profilePath.replace("profile.json",c.assetPath))}return{profile:a,assetPath:o}}const eu={xAxis:0,yAxis:0,button:0,state:Re.ComponentState.DEFAULT};function tu(r=0,e=0){let t=r,n=e;if(Math.sqrt(r*r+e*e)>1){const i=Math.atan2(e,r);t=Math.cos(i),n=Math.sin(i)}return{normalizedXAxis:t*.5+.5,normalizedYAxis:n*.5+.5}}class nu{constructor(e){this.componentProperty=e.componentProperty,this.states=e.states,this.valueNodeName=e.valueNodeName,this.valueNodeProperty=e.valueNodeProperty,this.valueNodeProperty===Re.VisualResponseProperty.TRANSFORM&&(this.minNodeName=e.minNodeName,this.maxNodeName=e.maxNodeName),this.value=0,this.updateFromComponent(eu)}updateFromComponent({xAxis:e,yAxis:t,button:n,state:i}){const{normalizedXAxis:s,normalizedYAxis:a}=tu(e,t);switch(this.componentProperty){case Re.ComponentProperty.X_AXIS:this.value=this.states.includes(i)?s:.5;break;case Re.ComponentProperty.Y_AXIS:this.value=this.states.includes(i)?a:.5;break;case Re.ComponentProperty.BUTTON:this.value=this.states.includes(i)?n:0;break;case Re.ComponentProperty.STATE:this.valueNodeProperty===Re.VisualResponseProperty.VISIBILITY?this.value=this.states.includes(i):this.value=this.states.includes(i)?1:0;break;default:throw new Error(`Unexpected visualResponse componentProperty ${this.componentProperty}`)}}}class iu{constructor(e,t){if(!e||!t||!t.visualResponses||!t.gamepadIndices||Object.keys(t.gamepadIndices).length===0)throw new Error("Invalid arguments supplied");this.id=e,this.type=t.type,this.rootNodeName=t.rootNodeName,this.touchPointNodeName=t.touchPointNodeName,this.visualResponses={},Object.keys(t.visualResponses).forEach(n=>{const i=new nu(t.visualResponses[n]);this.visualResponses[n]=i}),this.gamepadIndices=Object.assign({},t.gamepadIndices),this.values={state:Re.ComponentState.DEFAULT,button:this.gamepadIndices.button!==void 0?0:void 0,xAxis:this.gamepadIndices.xAxis!==void 0?0:void 0,yAxis:this.gamepadIndices.yAxis!==void 0?0:void 0}}get data(){return{id:this.id,...this.values}}updateFromGamepad(e){if(this.values.state=Re.ComponentState.DEFAULT,this.gamepadIndices.button!==void 0&&e.buttons.length>this.gamepadIndices.button){const t=e.buttons[this.gamepadIndices.button];this.values.button=t.value,this.values.button=this.values.button<0?0:this.values.button,this.values.button=this.values.button>1?1:this.values.button,t.pressed||this.values.button===1?this.values.state=Re.ComponentState.PRESSED:(t.touched||this.values.button>Re.ButtonTouchThreshold)&&(this.values.state=Re.ComponentState.TOUCHED)}this.gamepadIndices.xAxis!==void 0&&e.axes.length>this.gamepadIndices.xAxis&&(this.values.xAxis=e.axes[this.gamepadIndices.xAxis],this.values.xAxis=this.values.xAxis<-1?-1:this.values.xAxis,this.values.xAxis=this.values.xAxis>1?1:this.values.xAxis,this.values.state===Re.ComponentState.DEFAULT&&Math.abs(this.values.xAxis)>Re.AxisTouchThreshold&&(this.values.state=Re.ComponentState.TOUCHED)),this.gamepadIndices.yAxis!==void 0&&e.axes.length>this.gamepadIndices.yAxis&&(this.values.yAxis=e.axes[this.gamepadIndices.yAxis],this.values.yAxis=this.values.yAxis<-1?-1:this.values.yAxis,this.values.yAxis=this.values.yAxis>1?1:this.values.yAxis,this.values.state===Re.ComponentState.DEFAULT&&Math.abs(this.values.yAxis)>Re.AxisTouchThreshold&&(this.values.state=Re.ComponentState.TOUCHED)),Object.values(this.visualResponses).forEach(t=>{t.updateFromComponent(this.values)})}}class ru{constructor(e,t,n){if(!e)throw new Error("No xrInputSource supplied");if(!t)throw new Error("No profile supplied");this.xrInputSource=e,this.assetUrl=n,this.id=t.profileId,this.layoutDescription=t.layouts[e.handedness],this.components={},Object.keys(this.layoutDescription.components).forEach(i=>{const s=this.layoutDescription.components[i];this.components[i]=new iu(i,s)}),this.updateFromGamepad()}get gripSpace(){return this.xrInputSource.gripSpace}get targetRaySpace(){return this.xrInputSource.targetRaySpace}get data(){const e=[];return Object.values(this.components).forEach(t=>{e.push(t.data)}),e}updateFromGamepad(){Object.values(this.components).forEach(e=>{e.updateFromGamepad(this.xrInputSource.gamepad)})}}const ys=2,It=4,Wt=4,ra=4,Qt=new Int32Array(2),sa=new Float32Array(Qt.buffer),oa=new Float64Array(Qt.buffer),or=new Uint16Array(new Uint8Array([1,0]).buffer)[0]===1;class Zt{constructor(e,t){this.low=e|0,this.high=t|0}static create(e,t){return e==0&&t==0?Zt.ZERO:new Zt(e,t)}toFloat64(){return(this.low>>>0)+this.high*4294967296}equals(e){return this.low==e.low&&this.high==e.high}}Zt.ZERO=new Zt(0,0);var gs;(function(r){r[r.UTF8_BYTES=1]="UTF8_BYTES",r[r.UTF16_STRING=2]="UTF16_STRING"})(gs||(gs={}));class bi{constructor(e){this.bytes_=e,this.position_=0}static allocate(e){return new bi(new Uint8Array(e))}clear(){this.position_=0}bytes(){return this.bytes_}position(){return this.position_}setPosition(e){this.position_=e}capacity(){return this.bytes_.length}readInt8(e){return this.readUint8(e)<<24>>24}readUint8(e){return this.bytes_[e]}readInt16(e){return this.readUint16(e)<<16>>16}readUint16(e){return this.bytes_[e]|this.bytes_[e+1]<<8}readInt32(e){return this.bytes_[e]|this.bytes_[e+1]<<8|this.bytes_[e+2]<<16|this.bytes_[e+3]<<24}readUint32(e){return this.readInt32(e)>>>0}readInt64(e){return new Zt(this.readInt32(e),this.readInt32(e+4))}readUint64(e){return new Zt(this.readUint32(e),this.readUint32(e+4))}readFloat32(e){return Qt[0]=this.readInt32(e),sa[0]}readFloat64(e){return Qt[or?0:1]=this.readInt32(e),Qt[or?1:0]=this.readInt32(e+4),oa[0]}writeInt8(e,t){this.bytes_[e]=t}writeUint8(e,t){this.bytes_[e]=t}writeInt16(e,t){this.bytes_[e]=t,this.bytes_[e+1]=t>>8}writeUint16(e,t){this.bytes_[e]=t,this.bytes_[e+1]=t>>8}writeInt32(e,t){this.bytes_[e]=t,this.bytes_[e+1]=t>>8,this.bytes_[e+2]=t>>16,this.bytes_[e+3]=t>>24}writeUint32(e,t){this.bytes_[e]=t,this.bytes_[e+1]=t>>8,this.bytes_[e+2]=t>>16,this.bytes_[e+3]=t>>24}writeInt64(e,t){this.writeInt32(e,t.low),this.writeInt32(e+4,t.high)}writeUint64(e,t){this.writeUint32(e,t.low),this.writeUint32(e+4,t.high)}writeFloat32(e,t){sa[0]=t,this.writeInt32(e,Qt[0])}writeFloat64(e,t){oa[0]=t,this.writeInt32(e,Qt[or?0:1]),this.writeInt32(e+4,Qt[or?1:0])}getBufferIdentifier(){if(this.bytes_.length<this.position_+It+Wt)throw new Error("FlatBuffers: ByteBuffer is too short to contain an identifier.");let e="";for(let t=0;t<Wt;t++)e+=String.fromCharCode(this.readInt8(this.position_+It+t));return e}__offset(e,t){const n=e-this.readInt32(e);return t<this.readInt16(n)?this.readInt16(n+t):0}__union(e,t){return e.bb_pos=t+this.readInt32(t),e.bb=this,e}__string(e,t){e+=this.readInt32(e);const n=this.readInt32(e);let i="",s=0;if(e+=It,t===gs.UTF8_BYTES)return this.bytes_.subarray(e,e+n);for(;s<n;){let a;const o=this.readUint8(e+s++);if(o<192)a=o;else{const c=this.readUint8(e+s++);if(o<224)a=(o&31)<<6|c&63;else{const l=this.readUint8(e+s++);if(o<240)a=(o&15)<<12|(c&63)<<6|l&63;else{const u=this.readUint8(e+s++);a=(o&7)<<18|(c&63)<<12|(l&63)<<6|u&63}}}a<65536?i+=String.fromCharCode(a):(a-=65536,i+=String.fromCharCode((a>>10)+55296,(a&1023)+56320))}return i}__union_with_string(e,t){return typeof e=="string"?this.__string(t):this.__union(e,t)}__indirect(e){return e+this.readInt32(e)}__vector(e){return e+this.readInt32(e)+It}__vector_len(e){return this.readInt32(e+this.readInt32(e))}__has_identifier(e){if(e.length!=Wt)throw new Error("FlatBuffers: file identifier must be length "+Wt);for(let t=0;t<Wt;t++)if(e.charCodeAt(t)!=this.readInt8(this.position()+It+t))return!1;return!0}createLong(e,t){return Zt.create(e,t)}createScalarList(e,t){const n=[];for(let i=0;i<t;++i)e(i)!==null&&n.push(e(i));return n}createObjList(e,t){const n=[];for(let i=0;i<t;++i){const s=e(i);s!==null&&n.push(s.unpack())}return n}}class _o{constructor(e){this.minalign=1,this.vtable=null,this.vtable_in_use=0,this.isNested=!1,this.object_start=0,this.vtables=[],this.vector_num_elems=0,this.force_defaults=!1,this.string_maps=null;let t;e?t=e:t=1024,this.bb=bi.allocate(t),this.space=t}clear(){this.bb.clear(),this.space=this.bb.capacity(),this.minalign=1,this.vtable=null,this.vtable_in_use=0,this.isNested=!1,this.object_start=0,this.vtables=[],this.vector_num_elems=0,this.force_defaults=!1,this.string_maps=null}forceDefaults(e){this.force_defaults=e}dataBuffer(){return this.bb}asUint8Array(){return this.bb.bytes().subarray(this.bb.position(),this.bb.position()+this.offset())}prep(e,t){e>this.minalign&&(this.minalign=e);const n=~(this.bb.capacity()-this.space+t)+1&e-1;for(;this.space<n+e+t;){const i=this.bb.capacity();this.bb=_o.growByteBuffer(this.bb),this.space+=this.bb.capacity()-i}this.pad(n)}pad(e){for(let t=0;t<e;t++)this.bb.writeInt8(--this.space,0)}writeInt8(e){this.bb.writeInt8(this.space-=1,e)}writeInt16(e){this.bb.writeInt16(this.space-=2,e)}writeInt32(e){this.bb.writeInt32(this.space-=4,e)}writeInt64(e){this.bb.writeInt64(this.space-=8,e)}writeFloat32(e){this.bb.writeFloat32(this.space-=4,e)}writeFloat64(e){this.bb.writeFloat64(this.space-=8,e)}addInt8(e){this.prep(1,0),this.writeInt8(e)}addInt16(e){this.prep(2,0),this.writeInt16(e)}addInt32(e){this.prep(4,0),this.writeInt32(e)}addInt64(e){this.prep(8,0),this.writeInt64(e)}addFloat32(e){this.prep(4,0),this.writeFloat32(e)}addFloat64(e){this.prep(8,0),this.writeFloat64(e)}addFieldInt8(e,t,n){(this.force_defaults||t!=n)&&(this.addInt8(t),this.slot(e))}addFieldInt16(e,t,n){(this.force_defaults||t!=n)&&(this.addInt16(t),this.slot(e))}addFieldInt32(e,t,n){(this.force_defaults||t!=n)&&(this.addInt32(t),this.slot(e))}addFieldInt64(e,t,n){(this.force_defaults||!t.equals(n))&&(this.addInt64(t),this.slot(e))}addFieldFloat32(e,t,n){(this.force_defaults||t!=n)&&(this.addFloat32(t),this.slot(e))}addFieldFloat64(e,t,n){(this.force_defaults||t!=n)&&(this.addFloat64(t),this.slot(e))}addFieldOffset(e,t,n){(this.force_defaults||t!=n)&&(this.addOffset(t),this.slot(e))}addFieldStruct(e,t,n){t!=n&&(this.nested(t),this.slot(e))}nested(e){if(e!=this.offset())throw new Error("FlatBuffers: struct must be serialized inline.")}notNested(){if(this.isNested)throw new Error("FlatBuffers: object serialization must not be nested.")}slot(e){this.vtable!==null&&(this.vtable[e]=this.offset())}offset(){return this.bb.capacity()-this.space}static growByteBuffer(e){const t=e.capacity();if(t&3221225472)throw new Error("FlatBuffers: cannot grow buffer beyond 2 gigabytes.");const n=t<<1,i=bi.allocate(n);return i.setPosition(n-t),i.bytes().set(e.bytes(),n-t),i}addOffset(e){this.prep(It,0),this.writeInt32(this.offset()-e+It)}startObject(e){this.notNested(),this.vtable==null&&(this.vtable=[]),this.vtable_in_use=e;for(let t=0;t<e;t++)this.vtable[t]=0;this.isNested=!0,this.object_start=this.offset()}endObject(){if(this.vtable==null||!this.isNested)throw new Error("FlatBuffers: endObject called without startObject");this.addInt32(0);const e=this.offset();let t=this.vtable_in_use-1;for(;t>=0&&this.vtable[t]==0;t--);const n=t+1;for(;t>=0;t--)this.addInt16(this.vtable[t]!=0?e-this.vtable[t]:0);const i=2;this.addInt16(e-this.object_start);const s=(n+i)*ys;this.addInt16(s);let a=0;const o=this.space;e:for(t=0;t<this.vtables.length;t++){const c=this.bb.capacity()-this.vtables[t];if(s==this.bb.readInt16(c)){for(let l=ys;l<s;l+=ys)if(this.bb.readInt16(o+l)!=this.bb.readInt16(c+l))continue e;a=this.vtables[t];break}}return a?(this.space=this.bb.capacity()-e,this.bb.writeInt32(this.space,a-e)):(this.vtables.push(this.offset()),this.bb.writeInt32(this.bb.capacity()-e,this.offset()-e)),this.isNested=!1,e}finish(e,t,n){const i=n?ra:0;if(t){const s=t;if(this.prep(this.minalign,It+Wt+i),s.length!=Wt)throw new Error("FlatBuffers: file identifier must be length "+Wt);for(let a=Wt-1;a>=0;a--)this.writeInt8(s.charCodeAt(a))}this.prep(this.minalign,It+i),this.addOffset(e),i&&this.addInt32(this.bb.capacity()-this.space),this.bb.setPosition(this.space)}finishSizePrefixed(e,t){this.finish(e,t,!0)}requiredField(e,t){const n=this.bb.capacity()-e,i=n-this.bb.readInt32(n);if(this.bb.readInt16(i+t)==0)throw new Error("FlatBuffers: field "+t+" must be set")}startVector(e,t,n){this.notNested(),this.vector_num_elems=t,this.prep(It,e*t),this.prep(n,e*t)}endVector(){return this.writeInt32(this.vector_num_elems),this.offset()}createSharedString(e){if(!e)return 0;if(this.string_maps||(this.string_maps=new Map),this.string_maps.has(e))return this.string_maps.get(e);const t=this.createString(e);return this.string_maps.set(e,t),t}createString(e){if(!e)return 0;let t;if(e instanceof Uint8Array)t=e;else{t=[];let n=0;for(;n<e.length;){let i;const s=e.charCodeAt(n++);if(s<55296||s>=56320)i=s;else{const a=e.charCodeAt(n++);i=(s<<10)+a+-56613888}i<128?t.push(i):(i<2048?t.push(i>>6&31|192):(i<65536?t.push(i>>12&15|224):t.push(i>>18&7|240,i>>12&63|128),t.push(i>>6&63|128)),t.push(i&63|128))}}this.addInt8(0),this.startVector(1,t.length,1),this.bb.setPosition(this.space-=t.length);for(let n=0,i=this.space,s=this.bb.bytes();n<t.length;n++)s[i++]=t[n];return this.endVector()}createLong(e,t){return Zt.create(e,t)}createObjectOffset(e){return e===null?0:typeof e=="string"?this.createString(e):e.pack(this)}createObjectOffsetList(e){const t=[];for(let n=0;n<e.length;++n){const i=e[n];if(i!==null)t.push(this.createObjectOffset(i));else throw new Error("FlatBuffers: Argument for createObjectOffsetList cannot contain null.")}return t}createStructOffsetList(e,t){return t(this,e.length),this.createObjectOffsetList(e),this.endVector()}}function ar(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var aa={exports:{}},ca;function la(){return ca||(ca=1,function(r){var e={};e.useBlobBuilder=function(){try{return new Blob([]),!1}catch{return!0}}(),e.useArrayBufferView=!e.useBlobBuilder&&function(){try{return new Blob([new Uint8Array([])]).size===0}catch{return!0}}(),r.exports.binaryFeatures=e;var t=r.exports.BlobBuilder;typeof window<"u"&&(t=r.exports.BlobBuilder=window.WebKitBlobBuilder||window.MozBlobBuilder||window.MSBlobBuilder||window.BlobBuilder);function n(){this._pieces=[],this._parts=[]}n.prototype.append=function(i){typeof i=="number"?this._pieces.push(i):(this.flush(),this._parts.push(i))},n.prototype.flush=function(){if(this._pieces.length>0){var i=new Uint8Array(this._pieces);e.useArrayBufferView||(i=i.buffer),this._parts.push(i),this._pieces=[]}},n.prototype.getBuffer=function(){if(this.flush(),e.useBlobBuilder){for(var i=new t,s=0,a=this._parts.length;s<a;s++)i.append(this._parts[s]);return i.getBlob()}else return new Blob(this._parts)},r.exports.BufferBuilder=n}(aa)),aa.exports}var vs,ua;function su(){if(ua)return vs;ua=1;var r=la().BufferBuilder,e=la().binaryFeatures,t={unpack:function(o){var c=new n(o);return c.unpack()},pack:function(o){var c=new i;c.pack(o);var l=c.getBuffer();return l}};vs=t;function n(o){this.index=0,this.dataBuffer=o,this.dataView=new Uint8Array(this.dataBuffer),this.length=this.dataBuffer.byteLength}n.prototype.unpack=function(){var o=this.unpack_uint8();if(o<128)return o;if((o^224)<32)return(o^224)-32;var c;if((c=o^160)<=15)return this.unpack_raw(c);if((c=o^176)<=15)return this.unpack_string(c);if((c=o^144)<=15)return this.unpack_array(c);if((c=o^128)<=15)return this.unpack_map(c);switch(o){case 192:return null;case 193:return;case 194:return!1;case 195:return!0;case 202:return this.unpack_float();case 203:return this.unpack_double();case 204:return this.unpack_uint8();case 205:return this.unpack_uint16();case 206:return this.unpack_uint32();case 207:return this.unpack_uint64();case 208:return this.unpack_int8();case 209:return this.unpack_int16();case 210:return this.unpack_int32();case 211:return this.unpack_int64();case 212:return;case 213:return;case 214:return;case 215:return;case 216:return c=this.unpack_uint16(),this.unpack_string(c);case 217:return c=this.unpack_uint32(),this.unpack_string(c);case 218:return c=this.unpack_uint16(),this.unpack_raw(c);case 219:return c=this.unpack_uint32(),this.unpack_raw(c);case 220:return c=this.unpack_uint16(),this.unpack_array(c);case 221:return c=this.unpack_uint32(),this.unpack_array(c);case 222:return c=this.unpack_uint16(),this.unpack_map(c);case 223:return c=this.unpack_uint32(),this.unpack_map(c)}},n.prototype.unpack_uint8=function(){var o=this.dataView[this.index]&255;return this.index++,o},n.prototype.unpack_uint16=function(){var o=this.read(2),c=(o[0]&255)*256+(o[1]&255);return this.index+=2,c},n.prototype.unpack_uint32=function(){var o=this.read(4),c=((o[0]*256+o[1])*256+o[2])*256+o[3];return this.index+=4,c},n.prototype.unpack_uint64=function(){var o=this.read(8),c=((((((o[0]*256+o[1])*256+o[2])*256+o[3])*256+o[4])*256+o[5])*256+o[6])*256+o[7];return this.index+=8,c},n.prototype.unpack_int8=function(){var o=this.unpack_uint8();return o<128?o:o-256},n.prototype.unpack_int16=function(){var o=this.unpack_uint16();return o<32768?o:o-65536},n.prototype.unpack_int32=function(){var o=this.unpack_uint32();return o<Math.pow(2,31)?o:o-Math.pow(2,32)},n.prototype.unpack_int64=function(){var o=this.unpack_uint64();return o<Math.pow(2,63)?o:o-Math.pow(2,64)},n.prototype.unpack_raw=function(o){if(this.length<this.index+o)throw new Error("BinaryPackFailure: index is out of range "+this.index+" "+o+" "+this.length);var c=this.dataBuffer.slice(this.index,this.index+o);return this.index+=o,c},n.prototype.unpack_string=function(o){for(var c=this.read(o),l=0,u="",p,f;l<o;)p=c[l],p<128?(u+=String.fromCharCode(p),l++):(p^192)<32?(f=(p^192)<<6|c[l+1]&63,u+=String.fromCharCode(f),l+=2):(f=(p&15)<<12|(c[l+1]&63)<<6|c[l+2]&63,u+=String.fromCharCode(f),l+=3);return this.index+=o,u},n.prototype.unpack_array=function(o){for(var c=new Array(o),l=0;l<o;l++)c[l]=this.unpack();return c},n.prototype.unpack_map=function(o){for(var c={},l=0;l<o;l++){var u=this.unpack(),p=this.unpack();c[u]=p}return c},n.prototype.unpack_float=function(){var o=this.unpack_uint32(),c=o>>31,l=(o>>23&255)-127,u=o&8388607|8388608;return(c===0?1:-1)*u*Math.pow(2,l-23)},n.prototype.unpack_double=function(){var o=this.unpack_uint32(),c=this.unpack_uint32(),l=o>>31,u=(o>>20&2047)-1023,p=o&1048575|1048576,f=p*Math.pow(2,u-20)+c*Math.pow(2,u-52);return(l===0?1:-1)*f},n.prototype.read=function(o){var c=this.index;if(c+o<=this.length)return this.dataView.subarray(c,c+o);throw new Error("BinaryPackFailure: read index out of range")};function i(){this.bufferBuilder=new r}i.prototype.getBuffer=function(){return this.bufferBuilder.getBuffer()},i.prototype.pack=function(o){var c=typeof o;if(c==="string")this.pack_string(o);else if(c==="number")Math.floor(o)===o?this.pack_integer(o):this.pack_double(o);else if(c==="boolean")o===!0?this.bufferBuilder.append(195):o===!1&&this.bufferBuilder.append(194);else if(c==="undefined")this.bufferBuilder.append(192);else if(c==="object")if(o===null)this.bufferBuilder.append(192);else{var l=o.constructor;if(l==Array)this.pack_array(o);else if(l==Blob||l==File||o instanceof Blob||o instanceof File)this.pack_bin(o);else if(l==ArrayBuffer)e.useArrayBufferView?this.pack_bin(new Uint8Array(o)):this.pack_bin(o);else if("BYTES_PER_ELEMENT"in o)e.useArrayBufferView?this.pack_bin(new Uint8Array(o.buffer)):this.pack_bin(o.buffer);else if(l==Object||l.toString().startsWith("class"))this.pack_object(o);else if(l==Date)this.pack_string(o.toString());else if(typeof o.toBinaryPack=="function")this.bufferBuilder.append(o.toBinaryPack());else throw new Error('Type "'+l.toString()+'" not yet supported')}else throw new Error('Type "'+c+'" not yet supported');this.bufferBuilder.flush()},i.prototype.pack_bin=function(o){var c=o.length||o.byteLength||o.size;if(c<=15)this.pack_uint8(160+c);else if(c<=65535)this.bufferBuilder.append(218),this.pack_uint16(c);else if(c<=4294967295)this.bufferBuilder.append(219),this.pack_uint32(c);else throw new Error("Invalid length");this.bufferBuilder.append(o)},i.prototype.pack_string=function(o){var c=a(o);if(c<=15)this.pack_uint8(176+c);else if(c<=65535)this.bufferBuilder.append(216),this.pack_uint16(c);else if(c<=4294967295)this.bufferBuilder.append(217),this.pack_uint32(c);else throw new Error("Invalid length");this.bufferBuilder.append(o)},i.prototype.pack_array=function(o){var c=o.length;if(c<=15)this.pack_uint8(144+c);else if(c<=65535)this.bufferBuilder.append(220),this.pack_uint16(c);else if(c<=4294967295)this.bufferBuilder.append(221),this.pack_uint32(c);else throw new Error("Invalid length");for(var l=0;l<c;l++)this.pack(o[l])},i.prototype.pack_integer=function(o){if(o>=-32&&o<=127)this.bufferBuilder.append(o&255);else if(o>=0&&o<=255)this.bufferBuilder.append(204),this.pack_uint8(o);else if(o>=-128&&o<=127)this.bufferBuilder.append(208),this.pack_int8(o);else if(o>=0&&o<=65535)this.bufferBuilder.append(205),this.pack_uint16(o);else if(o>=-32768&&o<=32767)this.bufferBuilder.append(209),this.pack_int16(o);else if(o>=0&&o<=4294967295)this.bufferBuilder.append(206),this.pack_uint32(o);else if(o>=-2147483648&&o<=2147483647)this.bufferBuilder.append(210),this.pack_int32(o);else if(o>=-9223372036854776e3&&o<=9223372036854776e3)this.bufferBuilder.append(211),this.pack_int64(o);else if(o>=0&&o<=18446744073709552e3)this.bufferBuilder.append(207),this.pack_uint64(o);else throw new Error("Invalid integer")},i.prototype.pack_double=function(o){var c=0;o<0&&(c=1,o=-o);var l=Math.floor(Math.log(o)/Math.LN2),u=o/Math.pow(2,l)-1,p=Math.floor(u*Math.pow(2,52)),f=Math.pow(2,32),m=c<<31|l+1023<<20|p/f&1048575,b=p%f;this.bufferBuilder.append(203),this.pack_int32(m),this.pack_int32(b)},i.prototype.pack_object=function(o){var c=Object.keys(o),l=c.length;if(l<=15)this.pack_uint8(128+l);else if(l<=65535)this.bufferBuilder.append(222),this.pack_uint16(l);else if(l<=4294967295)this.bufferBuilder.append(223),this.pack_uint32(l);else throw new Error("Invalid length");for(var u in o)o.hasOwnProperty(u)&&(this.pack(u),this.pack(o[u]))},i.prototype.pack_uint8=function(o){this.bufferBuilder.append(o)},i.prototype.pack_uint16=function(o){this.bufferBuilder.append(o>>8),this.bufferBuilder.append(o&255)},i.prototype.pack_uint32=function(o){var c=o&4294967295;this.bufferBuilder.append((c&4278190080)>>>24),this.bufferBuilder.append((c&16711680)>>>16),this.bufferBuilder.append((c&65280)>>>8),this.bufferBuilder.append(c&255)},i.prototype.pack_uint64=function(o){var c=o/Math.pow(2,32),l=o%Math.pow(2,32);this.bufferBuilder.append((c&4278190080)>>>24),this.bufferBuilder.append((c&16711680)>>>16),this.bufferBuilder.append((c&65280)>>>8),this.bufferBuilder.append(c&255),this.bufferBuilder.append((l&4278190080)>>>24),this.bufferBuilder.append((l&16711680)>>>16),this.bufferBuilder.append((l&65280)>>>8),this.bufferBuilder.append(l&255)},i.prototype.pack_int8=function(o){this.bufferBuilder.append(o&255)},i.prototype.pack_int16=function(o){this.bufferBuilder.append((o&65280)>>8),this.bufferBuilder.append(o&255)},i.prototype.pack_int32=function(o){this.bufferBuilder.append(o>>>24&255),this.bufferBuilder.append((o&16711680)>>>16),this.bufferBuilder.append((o&65280)>>>8),this.bufferBuilder.append(o&255)},i.prototype.pack_int64=function(o){var c=Math.floor(o/Math.pow(2,32)),l=o%Math.pow(2,32);this.bufferBuilder.append((c&4278190080)>>>24),this.bufferBuilder.append((c&16711680)>>>16),this.bufferBuilder.append((c&65280)>>>8),this.bufferBuilder.append(c&255),this.bufferBuilder.append((l&4278190080)>>>24),this.bufferBuilder.append((l&16711680)>>>16),this.bufferBuilder.append((l&65280)>>>8),this.bufferBuilder.append(l&255)};function s(o){var c=o.charCodeAt(0);return c<=2047?"00":c<=65535?"000":c<=2097151?"0000":c<=67108863?"00000":"000000"}function a(o){return o.length>600?new Blob([o]).size:o.replace(/[^\u0000-\u007F]/g,s).length}return vs}var ou=su();const ha=ar(ou);let da=!0,pa=!0;function Zn(r,e,t){const n=r.match(e);return n&&n.length>=t&&parseInt(n[t],10)}function Rn(r,e,t){if(!r.RTCPeerConnection)return;const n=r.RTCPeerConnection.prototype,i=n.addEventListener;n.addEventListener=function(a,o){if(a!==e)return i.apply(this,arguments);const c=l=>{const u=t(l);u&&(o.handleEvent?o.handleEvent(u):o(u))};return this._eventMap=this._eventMap||{},this._eventMap[e]||(this._eventMap[e]=new Map),this._eventMap[e].set(o,c),i.apply(this,[a,c])};const s=n.removeEventListener;n.removeEventListener=function(a,o){if(a!==e||!this._eventMap||!this._eventMap[e])return s.apply(this,arguments);if(!this._eventMap[e].has(o))return s.apply(this,arguments);const c=this._eventMap[e].get(o);return this._eventMap[e].delete(o),this._eventMap[e].size===0&&delete this._eventMap[e],Object.keys(this._eventMap).length===0&&delete this._eventMap,s.apply(this,[a,c])},Object.defineProperty(n,"on"+e,{get(){return this["_on"+e]},set(a){this["_on"+e]&&(this.removeEventListener(e,this["_on"+e]),delete this["_on"+e]),a&&this.addEventListener(e,this["_on"+e]=a)},enumerable:!0,configurable:!0})}function au(r){return typeof r!="boolean"?new Error("Argument type: "+typeof r+". Please use a boolean."):(da=r,r?"adapter.js logging disabled":"adapter.js logging enabled")}function cu(r){return typeof r!="boolean"?new Error("Argument type: "+typeof r+". Please use a boolean."):(pa=!r,"adapter.js deprecation warnings "+(r?"disabled":"enabled"))}function Ss(){if(typeof window=="object"){if(da)return;typeof console<"u"&&typeof console.log=="function"&&console.log.apply(console,arguments)}}function cr(r,e){pa&&console.warn(r+" is deprecated, please use "+e+" instead.")}function lu(r){const e={browser:null,version:null};if(typeof r>"u"||!r.navigator)return e.browser="Not a browser.",e;const{navigator:t}=r;if(t.mozGetUserMedia)e.browser="firefox",e.version=Zn(t.userAgent,/Firefox\/(\d+)\./,1);else if(t.webkitGetUserMedia||r.isSecureContext===!1&&r.webkitRTCPeerConnection&&!r.RTCIceGatherer)e.browser="chrome",e.version=Zn(t.userAgent,/Chrom(e|ium)\/(\d+)\./,2);else if(t.mediaDevices&&t.userAgent.match(/Edge\/(\d+).(\d+)$/))e.browser="edge",e.version=Zn(t.userAgent,/Edge\/(\d+).(\d+)$/,2);else if(r.RTCPeerConnection&&t.userAgent.match(/AppleWebKit\/(\d+)\./))e.browser="safari",e.version=Zn(t.userAgent,/AppleWebKit\/(\d+)\./,1),e.supportsUnifiedPlan=r.RTCRtpTransceiver&&"currentDirection"in r.RTCRtpTransceiver.prototype;else return e.browser="Not a supported browser.",e;return e}function fa(r){return Object.prototype.toString.call(r)==="[object Object]"}function ma(r){return fa(r)?Object.keys(r).reduce(function(e,t){const n=fa(r[t]),i=n?ma(r[t]):r[t],s=n&&!Object.keys(i).length;return i===void 0||s?e:Object.assign(e,{[t]:i})},{}):r}function bs(r,e,t){!e||t.has(e.id)||(t.set(e.id,e),Object.keys(e).forEach(n=>{n.endsWith("Id")?bs(r,r.get(e[n]),t):n.endsWith("Ids")&&e[n].forEach(i=>{bs(r,r.get(i),t)})}))}function ya(r,e,t){const n=t?"outbound-rtp":"inbound-rtp",i=new Map;if(e===null)return i;const s=[];return r.forEach(a=>{a.type==="track"&&a.trackIdentifier===e.id&&s.push(a)}),s.forEach(a=>{r.forEach(o=>{o.type===n&&o.trackId===a.id&&bs(r,o,i)})}),i}const ga=Ss;function va(r,e){const t=r&&r.navigator;if(!t.mediaDevices)return;const n=function(o){if(typeof o!="object"||o.mandatory||o.optional)return o;const c={};return Object.keys(o).forEach(l=>{if(l==="require"||l==="advanced"||l==="mediaSource")return;const u=typeof o[l]=="object"?o[l]:{ideal:o[l]};u.exact!==void 0&&typeof u.exact=="number"&&(u.min=u.max=u.exact);const p=function(f,m){return f?f+m.charAt(0).toUpperCase()+m.slice(1):m==="deviceId"?"sourceId":m};if(u.ideal!==void 0){c.optional=c.optional||[];let f={};typeof u.ideal=="number"?(f[p("min",l)]=u.ideal,c.optional.push(f),f={},f[p("max",l)]=u.ideal,c.optional.push(f)):(f[p("",l)]=u.ideal,c.optional.push(f))}u.exact!==void 0&&typeof u.exact!="number"?(c.mandatory=c.mandatory||{},c.mandatory[p("",l)]=u.exact):["min","max"].forEach(f=>{u[f]!==void 0&&(c.mandatory=c.mandatory||{},c.mandatory[p(f,l)]=u[f])})}),o.advanced&&(c.optional=(c.optional||[]).concat(o.advanced)),c},i=function(o,c){if(e.version>=61)return c(o);if(o=JSON.parse(JSON.stringify(o)),o&&typeof o.audio=="object"){const l=function(u,p,f){p in u&&!(f in u)&&(u[f]=u[p],delete u[p])};o=JSON.parse(JSON.stringify(o)),l(o.audio,"autoGainControl","googAutoGainControl"),l(o.audio,"noiseSuppression","googNoiseSuppression"),o.audio=n(o.audio)}if(o&&typeof o.video=="object"){let l=o.video.facingMode;l=l&&(typeof l=="object"?l:{ideal:l});const u=e.version<66;if(l&&(l.exact==="user"||l.exact==="environment"||l.ideal==="user"||l.ideal==="environment")&&!(t.mediaDevices.getSupportedConstraints&&t.mediaDevices.getSupportedConstraints().facingMode&&!u)){delete o.video.facingMode;let p;if(l.exact==="environment"||l.ideal==="environment"?p=["back","rear"]:(l.exact==="user"||l.ideal==="user")&&(p=["front"]),p)return t.mediaDevices.enumerateDevices().then(f=>{f=f.filter(b=>b.kind==="videoinput");let m=f.find(b=>p.some(x=>b.label.toLowerCase().includes(x)));return!m&&f.length&&p.includes("back")&&(m=f[f.length-1]),m&&(o.video.deviceId=l.exact?{exact:m.deviceId}:{ideal:m.deviceId}),o.video=n(o.video),ga("chrome: "+JSON.stringify(o)),c(o)})}o.video=n(o.video)}return ga("chrome: "+JSON.stringify(o)),c(o)},s=function(o){return e.version>=64?o:{name:{PermissionDeniedError:"NotAllowedError",PermissionDismissedError:"NotAllowedError",InvalidStateError:"NotAllowedError",DevicesNotFoundError:"NotFoundError",ConstraintNotSatisfiedError:"OverconstrainedError",TrackStartError:"NotReadableError",MediaDeviceFailedDueToShutdown:"NotAllowedError",MediaDeviceKillSwitchOn:"NotAllowedError",TabCaptureError:"AbortError",ScreenCaptureError:"AbortError",DeviceCaptureError:"AbortError"}[o.name]||o.name,message:o.message,constraint:o.constraint||o.constraintName,toString(){return this.name+(this.message&&": ")+this.message}}},a=function(o,c,l){i(o,u=>{t.webkitGetUserMedia(u,c,p=>{l&&l(s(p))})})};if(t.getUserMedia=a.bind(t),t.mediaDevices.getUserMedia){const o=t.mediaDevices.getUserMedia.bind(t.mediaDevices);Object.getOwnPropertyDescriptor(t.mediaDevices,"getUserMedia")?.writable&&(t.mediaDevices.getUserMedia=function(c){return i(c,l=>o(l).then(u=>{if(l.audio&&!u.getAudioTracks().length||l.video&&!u.getVideoTracks().length)throw u.getTracks().forEach(p=>{p.stop()}),new DOMException("","NotFoundError");return u},u=>Promise.reject(s(u))))})}}function uu(r,e){if(!(r.navigator.mediaDevices&&"getDisplayMedia"in r.navigator.mediaDevices)&&r.navigator.mediaDevices){if(typeof e!="function"){console.error("shimGetDisplayMedia: getSourceId argument is not a function");return}r.navigator.mediaDevices.getDisplayMedia=function(t){return e(t).then(n=>{const i=t.video&&t.video.width,s=t.video&&t.video.height,a=t.video&&t.video.frameRate;return t.video={mandatory:{chromeMediaSource:"desktop",chromeMediaSourceId:n,maxFrameRate:a||3}},i&&(t.video.mandatory.maxWidth=i),s&&(t.video.mandatory.maxHeight=s),r.navigator.mediaDevices.getUserMedia(t)})}}}function Sa(r){r.MediaStream=r.MediaStream||r.webkitMediaStream}function ba(r){if(typeof r=="object"&&r.RTCPeerConnection&&!("ontrack"in r.RTCPeerConnection.prototype)){Object.defineProperty(r.RTCPeerConnection.prototype,"ontrack",{get(){return this._ontrack},set(t){this._ontrack&&this.removeEventListener("track",this._ontrack),this.addEventListener("track",this._ontrack=t)},enumerable:!0,configurable:!0});const e=r.RTCPeerConnection.prototype.setRemoteDescription;r.RTCPeerConnection.prototype.setRemoteDescription=function(){return this._ontrackpoly||(this._ontrackpoly=t=>{t.stream.addEventListener("addtrack",n=>{let i;r.RTCPeerConnection.prototype.getReceivers?i=this.getReceivers().find(a=>a.track&&a.track.id===n.track.id):i={track:n.track};const s=new Event("track");s.track=n.track,s.receiver=i,s.transceiver={receiver:i},s.streams=[t.stream],this.dispatchEvent(s)}),t.stream.getTracks().forEach(n=>{let i;r.RTCPeerConnection.prototype.getReceivers?i=this.getReceivers().find(a=>a.track&&a.track.id===n.id):i={track:n};const s=new Event("track");s.track=n,s.receiver=i,s.transceiver={receiver:i},s.streams=[t.stream],this.dispatchEvent(s)})},this.addEventListener("addstream",this._ontrackpoly)),e.apply(this,arguments)}}else Rn(r,"track",e=>(e.transceiver||Object.defineProperty(e,"transceiver",{value:{receiver:e.receiver}}),e))}function xa(r){if(typeof r=="object"&&r.RTCPeerConnection&&!("getSenders"in r.RTCPeerConnection.prototype)&&"createDTMFSender"in r.RTCPeerConnection.prototype){const e=function(i,s){return{track:s,get dtmf(){return this._dtmf===void 0&&(s.kind==="audio"?this._dtmf=i.createDTMFSender(s):this._dtmf=null),this._dtmf},_pc:i}};if(!r.RTCPeerConnection.prototype.getSenders){r.RTCPeerConnection.prototype.getSenders=function(){return this._senders=this._senders||[],this._senders.slice()};const i=r.RTCPeerConnection.prototype.addTrack;r.RTCPeerConnection.prototype.addTrack=function(a,o){let c=i.apply(this,arguments);return c||(c=e(this,a),this._senders.push(c)),c};const s=r.RTCPeerConnection.prototype.removeTrack;r.RTCPeerConnection.prototype.removeTrack=function(a){s.apply(this,arguments);const o=this._senders.indexOf(a);o!==-1&&this._senders.splice(o,1)}}const t=r.RTCPeerConnection.prototype.addStream;r.RTCPeerConnection.prototype.addStream=function(i){this._senders=this._senders||[],t.apply(this,[i]),i.getTracks().forEach(s=>{this._senders.push(e(this,s))})};const n=r.RTCPeerConnection.prototype.removeStream;r.RTCPeerConnection.prototype.removeStream=function(i){this._senders=this._senders||[],n.apply(this,[i]),i.getTracks().forEach(s=>{const a=this._senders.find(o=>o.track===s);a&&this._senders.splice(this._senders.indexOf(a),1)})}}else if(typeof r=="object"&&r.RTCPeerConnection&&"getSenders"in r.RTCPeerConnection.prototype&&"createDTMFSender"in r.RTCPeerConnection.prototype&&r.RTCRtpSender&&!("dtmf"in r.RTCRtpSender.prototype)){const e=r.RTCPeerConnection.prototype.getSenders;r.RTCPeerConnection.prototype.getSenders=function(){const t=e.apply(this,[]);return t.forEach(n=>n._pc=this),t},Object.defineProperty(r.RTCRtpSender.prototype,"dtmf",{get(){return this._dtmf===void 0&&(this.track.kind==="audio"?this._dtmf=this._pc.createDTMFSender(this.track):this._dtmf=null),this._dtmf}})}}function wa(r){if(!r.RTCPeerConnection)return;const e=r.RTCPeerConnection.prototype.getStats;r.RTCPeerConnection.prototype.getStats=function(){const[t,n,i]=arguments;if(arguments.length>0&&typeof t=="function")return e.apply(this,arguments);if(e.length===0&&(arguments.length===0||typeof t!="function"))return e.apply(this,[]);const s=function(o){const c={};return o.result().forEach(l=>{const u={id:l.id,timestamp:l.timestamp,type:{localcandidate:"local-candidate",remotecandidate:"remote-candidate"}[l.type]||l.type};l.names().forEach(p=>{u[p]=l.stat(p)}),c[u.id]=u}),c},a=function(o){return new Map(Object.keys(o).map(c=>[c,o[c]]))};if(arguments.length>=2){const o=function(c){n(a(s(c)))};return e.apply(this,[o,t])}return new Promise((o,c)=>{e.apply(this,[function(l){o(a(s(l)))},c])}).then(n,i)}}function _a(r){if(!(typeof r=="object"&&r.RTCPeerConnection&&r.RTCRtpSender&&r.RTCRtpReceiver))return;if(!("getStats"in r.RTCRtpSender.prototype)){const t=r.RTCPeerConnection.prototype.getSenders;t&&(r.RTCPeerConnection.prototype.getSenders=function(){const i=t.apply(this,[]);return i.forEach(s=>s._pc=this),i});const n=r.RTCPeerConnection.prototype.addTrack;n&&(r.RTCPeerConnection.prototype.addTrack=function(){const i=n.apply(this,arguments);return i._pc=this,i}),r.RTCRtpSender.prototype.getStats=function(){const i=this;return this._pc.getStats().then(s=>ya(s,i.track,!0))}}if(!("getStats"in r.RTCRtpReceiver.prototype)){const t=r.RTCPeerConnection.prototype.getReceivers;t&&(r.RTCPeerConnection.prototype.getReceivers=function(){const n=t.apply(this,[]);return n.forEach(i=>i._pc=this),n}),Rn(r,"track",n=>(n.receiver._pc=n.srcElement,n)),r.RTCRtpReceiver.prototype.getStats=function(){const n=this;return this._pc.getStats().then(i=>ya(i,n.track,!1))}}if(!("getStats"in r.RTCRtpSender.prototype&&"getStats"in r.RTCRtpReceiver.prototype))return;const e=r.RTCPeerConnection.prototype.getStats;r.RTCPeerConnection.prototype.getStats=function(){if(arguments.length>0&&arguments[0]instanceof r.MediaStreamTrack){const t=arguments[0];let n,i,s;return this.getSenders().forEach(a=>{a.track===t&&(n?s=!0:n=a)}),this.getReceivers().forEach(a=>(a.track===t&&(i?s=!0:i=a),a.track===t)),s||n&&i?Promise.reject(new DOMException("There are more than one sender or receiver for the track.","InvalidAccessError")):n?n.getStats():i?i.getStats():Promise.reject(new DOMException("There is no sender or receiver for the track.","InvalidAccessError"))}return e.apply(this,arguments)}}function Ta(r){r.RTCPeerConnection.prototype.getLocalStreams=function(){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},Object.keys(this._shimmedLocalStreams).map(s=>this._shimmedLocalStreams[s][0])};const e=r.RTCPeerConnection.prototype.addTrack;r.RTCPeerConnection.prototype.addTrack=function(s,a){if(!a)return e.apply(this,arguments);this._shimmedLocalStreams=this._shimmedLocalStreams||{};const o=e.apply(this,arguments);return this._shimmedLocalStreams[a.id]?this._shimmedLocalStreams[a.id].indexOf(o)===-1&&this._shimmedLocalStreams[a.id].push(o):this._shimmedLocalStreams[a.id]=[a,o],o};const t=r.RTCPeerConnection.prototype.addStream;r.RTCPeerConnection.prototype.addStream=function(s){this._shimmedLocalStreams=this._shimmedLocalStreams||{},s.getTracks().forEach(c=>{if(this.getSenders().find(l=>l.track===c))throw new DOMException("Track already exists.","InvalidAccessError")});const a=this.getSenders();t.apply(this,arguments);const o=this.getSenders().filter(c=>a.indexOf(c)===-1);this._shimmedLocalStreams[s.id]=[s].concat(o)};const n=r.RTCPeerConnection.prototype.removeStream;r.RTCPeerConnection.prototype.removeStream=function(s){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},delete this._shimmedLocalStreams[s.id],n.apply(this,arguments)};const i=r.RTCPeerConnection.prototype.removeTrack;r.RTCPeerConnection.prototype.removeTrack=function(s){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},s&&Object.keys(this._shimmedLocalStreams).forEach(a=>{const o=this._shimmedLocalStreams[a].indexOf(s);o!==-1&&this._shimmedLocalStreams[a].splice(o,1),this._shimmedLocalStreams[a].length===1&&delete this._shimmedLocalStreams[a]}),i.apply(this,arguments)}}function Ma(r,e){if(!r.RTCPeerConnection)return;if(r.RTCPeerConnection.prototype.addTrack&&e.version>=65)return Ta(r);const t=r.RTCPeerConnection.prototype.getLocalStreams;r.RTCPeerConnection.prototype.getLocalStreams=function(){const l=t.apply(this);return this._reverseStreams=this._reverseStreams||{},l.map(u=>this._reverseStreams[u.id])};const n=r.RTCPeerConnection.prototype.addStream;r.RTCPeerConnection.prototype.addStream=function(l){if(this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},l.getTracks().forEach(u=>{if(this.getSenders().find(p=>p.track===u))throw new DOMException("Track already exists.","InvalidAccessError")}),!this._reverseStreams[l.id]){const u=new r.MediaStream(l.getTracks());this._streams[l.id]=u,this._reverseStreams[u.id]=l,l=u}n.apply(this,[l])};const i=r.RTCPeerConnection.prototype.removeStream;r.RTCPeerConnection.prototype.removeStream=function(l){this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},i.apply(this,[this._streams[l.id]||l]),delete this._reverseStreams[this._streams[l.id]?this._streams[l.id].id:l.id],delete this._streams[l.id]},r.RTCPeerConnection.prototype.addTrack=function(l,u){if(this.signalingState==="closed")throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");const p=[].slice.call(arguments,1);if(p.length!==1||!p[0].getTracks().find(m=>m===l))throw new DOMException("The adapter.js addTrack polyfill only supports a single stream which is associated with the specified track.","NotSupportedError");if(this.getSenders().find(m=>m.track===l))throw new DOMException("Track already exists.","InvalidAccessError");this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{};const f=this._streams[u.id];if(f)f.addTrack(l),Promise.resolve().then(()=>{this.dispatchEvent(new Event("negotiationneeded"))});else{const m=new r.MediaStream([l]);this._streams[u.id]=m,this._reverseStreams[m.id]=u,this.addStream(m)}return this.getSenders().find(m=>m.track===l)};function s(l,u){let p=u.sdp;return Object.keys(l._reverseStreams||[]).forEach(f=>{const m=l._reverseStreams[f],b=l._streams[m.id];p=p.replace(new RegExp(b.id,"g"),m.id)}),new RTCSessionDescription({type:u.type,sdp:p})}function a(l,u){let p=u.sdp;return Object.keys(l._reverseStreams||[]).forEach(f=>{const m=l._reverseStreams[f],b=l._streams[m.id];p=p.replace(new RegExp(m.id,"g"),b.id)}),new RTCSessionDescription({type:u.type,sdp:p})}["createOffer","createAnswer"].forEach(function(l){const u=r.RTCPeerConnection.prototype[l],p={[l](){const f=arguments;return arguments.length&&typeof arguments[0]=="function"?u.apply(this,[m=>{const b=s(this,m);f[0].apply(null,[b])},m=>{f[1]&&f[1].apply(null,m)},arguments[2]]):u.apply(this,arguments).then(m=>s(this,m))}};r.RTCPeerConnection.prototype[l]=p[l]});const o=r.RTCPeerConnection.prototype.setLocalDescription;r.RTCPeerConnection.prototype.setLocalDescription=function(){return!arguments.length||!arguments[0].type?o.apply(this,arguments):(arguments[0]=a(this,arguments[0]),o.apply(this,arguments))};const c=Object.getOwnPropertyDescriptor(r.RTCPeerConnection.prototype,"localDescription");Object.defineProperty(r.RTCPeerConnection.prototype,"localDescription",{get(){const l=c.get.apply(this);return l.type===""?l:s(this,l)}}),r.RTCPeerConnection.prototype.removeTrack=function(l){if(this.signalingState==="closed")throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");if(!l._pc)throw new DOMException("Argument 1 of RTCPeerConnection.removeTrack does not implement interface RTCRtpSender.","TypeError");if(l._pc!==this)throw new DOMException("Sender was not created by this connection.","InvalidAccessError");this._streams=this._streams||{};let u;Object.keys(this._streams).forEach(p=>{this._streams[p].getTracks().find(f=>l.track===f)&&(u=this._streams[p])}),u&&(u.getTracks().length===1?this.removeStream(this._reverseStreams[u.id]):u.removeTrack(l.track),this.dispatchEvent(new Event("negotiationneeded")))}}function xs(r,e){!r.RTCPeerConnection&&r.webkitRTCPeerConnection&&(r.RTCPeerConnection=r.webkitRTCPeerConnection),r.RTCPeerConnection&&e.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach(function(t){const n=r.RTCPeerConnection.prototype[t],i={[t](){return arguments[0]=new(t==="addIceCandidate"?r.RTCIceCandidate:r.RTCSessionDescription)(arguments[0]),n.apply(this,arguments)}};r.RTCPeerConnection.prototype[t]=i[t]})}function Ca(r,e){Rn(r,"negotiationneeded",t=>{const n=t.target;if(!((e.version<72||n.getConfiguration&&n.getConfiguration().sdpSemantics==="plan-b")&&n.signalingState!=="stable"))return t})}const Ea=Object.freeze(Object.defineProperty({__proto__:null,fixNegotiationNeeded:Ca,shimAddTrackRemoveTrack:Ma,shimAddTrackRemoveTrackWithNative:Ta,shimGetDisplayMedia:uu,shimGetSendersWithDtmf:xa,shimGetStats:wa,shimGetUserMedia:va,shimMediaStream:Sa,shimOnTrack:ba,shimPeerConnection:xs,shimSenderReceiverGetStats:_a},Symbol.toStringTag,{value:"Module"}));function hu(r,e){let t=!1;return r=JSON.parse(JSON.stringify(r)),r.filter(n=>{if(n&&(n.urls||n.url)){let i=n.urls||n.url;n.url&&!n.urls&&cr("RTCIceServer.url","RTCIceServer.urls");const s=typeof i=="string";return s&&(i=[i]),i=i.filter(a=>{if(a.indexOf("stun:")===0)return!1;const o=a.startsWith("turn")&&!a.startsWith("turn:[")&&a.includes("transport=udp");return o&&!t?(t=!0,!0):o&&!t}),delete n.url,n.urls=s?i[0]:i,!!i.length}})}var Pa={exports:{}},ka;function Ra(){return ka||(ka=1,function(r){var e={};e.generateIdentifier=function(){return Math.random().toString(36).substr(2,10)},e.localCName=e.generateIdentifier(),e.splitLines=function(t){return t.trim().split(`
|
|
1
|
+
import{PlaneGeometry as Xo,ShaderChunk as Nl,Object3D as Yo,Layers as sr,MeshBasicMaterial as Zo,DoubleSide as ds,AdditiveBlending as Ko,InstancedBufferAttribute as ln,DynamicDrawUsage as He,InstancedBufferGeometry as Ul,Uniform$1 as Mt,ShaderMaterial as ps,BufferGeometry as Yn,BufferAttribute as ot,Mesh as fs,MeshStandardMaterial as Dl,MeshPhysicalMaterial as Ll,Triangle as un,Vector3 as W,Plane as Qo,Line3 as Gt,Vector2 as kn,Sphere as $o,Matrix4 as Ct,Box3 as Ot,BackSide as Fl,REVISION as Vl,FrontSide as ea,BatchedMesh as jl,Ray as Jl,Matrix3 as Gl,Vector4 as ms,SkinnedMesh as Wl,InterpolateDiscrete as Hl,InterpolateLinear as ta,AnimationClip as ql,QuaternionKeyframeTrack as Xl,ColorKeyframeTrack as Yl,VectorKeyframeTrack as Zl,BooleanKeyframeTrack as Kl,NumberKeyframeTrack as Ql,PropertyBinding as na}from"./three-BDW9I486.min.js";const Re={ComponentState:Object.freeze({DEFAULT:"default",TOUCHED:"touched",PRESSED:"pressed"}),ComponentProperty:Object.freeze({BUTTON:"button",X_AXIS:"xAxis",Y_AXIS:"yAxis",STATE:"state"}),ButtonTouchThreshold:.05,AxisTouchThreshold:.1,VisualResponseProperty:Object.freeze({TRANSFORM:"transform",VISIBILITY:"visibility"})};async function ia(r){const e=await fetch(r);if(e.ok)return e.json();throw new Error(e.statusText)}async function $l(r){return await ia(`${r}/profilesList.json`)}async function eu(r,e,t=null,n=!0){if(!r)throw new Error("No xrInputSource supplied");const i=await $l(e);let s;if(r.profiles.some(c=>{const l=i[c];return l&&(s={profileId:c,profilePath:`${e}/${l.path}`,deprecated:!!l.deprecated}),!!s}),!s){if(!t)throw new Error("No matching profile name found");const c=i[t];if(!c)throw new Error(`No matching profile name found and default profile "${t}" missing.`);s={profileId:t,profilePath:`${e}/${c.path}`,deprecated:!!c.deprecated}}const a=await ia(s.profilePath);let o;if(n){let c;if(r.handedness==="any"?c=a.layouts[Object.keys(a.layouts)[0]]:c=a.layouts[r.handedness],!c)throw new Error(`No matching handedness, ${r.handedness}, in profile ${s.profileId}`);c.assetPath&&(o=s.profilePath.replace("profile.json",c.assetPath))}return{profile:a,assetPath:o}}const tu={xAxis:0,yAxis:0,button:0,state:Re.ComponentState.DEFAULT};function nu(r=0,e=0){let t=r,n=e;if(Math.sqrt(r*r+e*e)>1){const i=Math.atan2(e,r);t=Math.cos(i),n=Math.sin(i)}return{normalizedXAxis:t*.5+.5,normalizedYAxis:n*.5+.5}}class iu{constructor(e){this.componentProperty=e.componentProperty,this.states=e.states,this.valueNodeName=e.valueNodeName,this.valueNodeProperty=e.valueNodeProperty,this.valueNodeProperty===Re.VisualResponseProperty.TRANSFORM&&(this.minNodeName=e.minNodeName,this.maxNodeName=e.maxNodeName),this.value=0,this.updateFromComponent(tu)}updateFromComponent({xAxis:e,yAxis:t,button:n,state:i}){const{normalizedXAxis:s,normalizedYAxis:a}=nu(e,t);switch(this.componentProperty){case Re.ComponentProperty.X_AXIS:this.value=this.states.includes(i)?s:.5;break;case Re.ComponentProperty.Y_AXIS:this.value=this.states.includes(i)?a:.5;break;case Re.ComponentProperty.BUTTON:this.value=this.states.includes(i)?n:0;break;case Re.ComponentProperty.STATE:this.valueNodeProperty===Re.VisualResponseProperty.VISIBILITY?this.value=this.states.includes(i):this.value=this.states.includes(i)?1:0;break;default:throw new Error(`Unexpected visualResponse componentProperty ${this.componentProperty}`)}}}class ru{constructor(e,t){if(!e||!t||!t.visualResponses||!t.gamepadIndices||Object.keys(t.gamepadIndices).length===0)throw new Error("Invalid arguments supplied");this.id=e,this.type=t.type,this.rootNodeName=t.rootNodeName,this.touchPointNodeName=t.touchPointNodeName,this.visualResponses={},Object.keys(t.visualResponses).forEach(n=>{const i=new iu(t.visualResponses[n]);this.visualResponses[n]=i}),this.gamepadIndices=Object.assign({},t.gamepadIndices),this.values={state:Re.ComponentState.DEFAULT,button:this.gamepadIndices.button!==void 0?0:void 0,xAxis:this.gamepadIndices.xAxis!==void 0?0:void 0,yAxis:this.gamepadIndices.yAxis!==void 0?0:void 0}}get data(){return{id:this.id,...this.values}}updateFromGamepad(e){if(this.values.state=Re.ComponentState.DEFAULT,this.gamepadIndices.button!==void 0&&e.buttons.length>this.gamepadIndices.button){const t=e.buttons[this.gamepadIndices.button];this.values.button=t.value,this.values.button=this.values.button<0?0:this.values.button,this.values.button=this.values.button>1?1:this.values.button,t.pressed||this.values.button===1?this.values.state=Re.ComponentState.PRESSED:(t.touched||this.values.button>Re.ButtonTouchThreshold)&&(this.values.state=Re.ComponentState.TOUCHED)}this.gamepadIndices.xAxis!==void 0&&e.axes.length>this.gamepadIndices.xAxis&&(this.values.xAxis=e.axes[this.gamepadIndices.xAxis],this.values.xAxis=this.values.xAxis<-1?-1:this.values.xAxis,this.values.xAxis=this.values.xAxis>1?1:this.values.xAxis,this.values.state===Re.ComponentState.DEFAULT&&Math.abs(this.values.xAxis)>Re.AxisTouchThreshold&&(this.values.state=Re.ComponentState.TOUCHED)),this.gamepadIndices.yAxis!==void 0&&e.axes.length>this.gamepadIndices.yAxis&&(this.values.yAxis=e.axes[this.gamepadIndices.yAxis],this.values.yAxis=this.values.yAxis<-1?-1:this.values.yAxis,this.values.yAxis=this.values.yAxis>1?1:this.values.yAxis,this.values.state===Re.ComponentState.DEFAULT&&Math.abs(this.values.yAxis)>Re.AxisTouchThreshold&&(this.values.state=Re.ComponentState.TOUCHED)),Object.values(this.visualResponses).forEach(t=>{t.updateFromComponent(this.values)})}}class su{constructor(e,t,n){if(!e)throw new Error("No xrInputSource supplied");if(!t)throw new Error("No profile supplied");this.xrInputSource=e,this.assetUrl=n,this.id=t.profileId,this.layoutDescription=t.layouts[e.handedness],this.components={},Object.keys(this.layoutDescription.components).forEach(i=>{const s=this.layoutDescription.components[i];this.components[i]=new ru(i,s)}),this.updateFromGamepad()}get gripSpace(){return this.xrInputSource.gripSpace}get targetRaySpace(){return this.xrInputSource.targetRaySpace}get data(){const e=[];return Object.values(this.components).forEach(t=>{e.push(t.data)}),e}updateFromGamepad(){Object.values(this.components).forEach(e=>{e.updateFromGamepad(this.xrInputSource.gamepad)})}}const ys=2,It=4,Wt=4,ra=4,Qt=new Int32Array(2),sa=new Float32Array(Qt.buffer),oa=new Float64Array(Qt.buffer),or=new Uint16Array(new Uint8Array([1,0]).buffer)[0]===1;class Zt{constructor(e,t){this.low=e|0,this.high=t|0}static create(e,t){return e==0&&t==0?Zt.ZERO:new Zt(e,t)}toFloat64(){return(this.low>>>0)+this.high*4294967296}equals(e){return this.low==e.low&&this.high==e.high}}Zt.ZERO=new Zt(0,0);var gs;(function(r){r[r.UTF8_BYTES=1]="UTF8_BYTES",r[r.UTF16_STRING=2]="UTF16_STRING"})(gs||(gs={}));class bi{constructor(e){this.bytes_=e,this.position_=0}static allocate(e){return new bi(new Uint8Array(e))}clear(){this.position_=0}bytes(){return this.bytes_}position(){return this.position_}setPosition(e){this.position_=e}capacity(){return this.bytes_.length}readInt8(e){return this.readUint8(e)<<24>>24}readUint8(e){return this.bytes_[e]}readInt16(e){return this.readUint16(e)<<16>>16}readUint16(e){return this.bytes_[e]|this.bytes_[e+1]<<8}readInt32(e){return this.bytes_[e]|this.bytes_[e+1]<<8|this.bytes_[e+2]<<16|this.bytes_[e+3]<<24}readUint32(e){return this.readInt32(e)>>>0}readInt64(e){return new Zt(this.readInt32(e),this.readInt32(e+4))}readUint64(e){return new Zt(this.readUint32(e),this.readUint32(e+4))}readFloat32(e){return Qt[0]=this.readInt32(e),sa[0]}readFloat64(e){return Qt[or?0:1]=this.readInt32(e),Qt[or?1:0]=this.readInt32(e+4),oa[0]}writeInt8(e,t){this.bytes_[e]=t}writeUint8(e,t){this.bytes_[e]=t}writeInt16(e,t){this.bytes_[e]=t,this.bytes_[e+1]=t>>8}writeUint16(e,t){this.bytes_[e]=t,this.bytes_[e+1]=t>>8}writeInt32(e,t){this.bytes_[e]=t,this.bytes_[e+1]=t>>8,this.bytes_[e+2]=t>>16,this.bytes_[e+3]=t>>24}writeUint32(e,t){this.bytes_[e]=t,this.bytes_[e+1]=t>>8,this.bytes_[e+2]=t>>16,this.bytes_[e+3]=t>>24}writeInt64(e,t){this.writeInt32(e,t.low),this.writeInt32(e+4,t.high)}writeUint64(e,t){this.writeUint32(e,t.low),this.writeUint32(e+4,t.high)}writeFloat32(e,t){sa[0]=t,this.writeInt32(e,Qt[0])}writeFloat64(e,t){oa[0]=t,this.writeInt32(e,Qt[or?0:1]),this.writeInt32(e+4,Qt[or?1:0])}getBufferIdentifier(){if(this.bytes_.length<this.position_+It+Wt)throw new Error("FlatBuffers: ByteBuffer is too short to contain an identifier.");let e="";for(let t=0;t<Wt;t++)e+=String.fromCharCode(this.readInt8(this.position_+It+t));return e}__offset(e,t){const n=e-this.readInt32(e);return t<this.readInt16(n)?this.readInt16(n+t):0}__union(e,t){return e.bb_pos=t+this.readInt32(t),e.bb=this,e}__string(e,t){e+=this.readInt32(e);const n=this.readInt32(e);let i="",s=0;if(e+=It,t===gs.UTF8_BYTES)return this.bytes_.subarray(e,e+n);for(;s<n;){let a;const o=this.readUint8(e+s++);if(o<192)a=o;else{const c=this.readUint8(e+s++);if(o<224)a=(o&31)<<6|c&63;else{const l=this.readUint8(e+s++);if(o<240)a=(o&15)<<12|(c&63)<<6|l&63;else{const u=this.readUint8(e+s++);a=(o&7)<<18|(c&63)<<12|(l&63)<<6|u&63}}}a<65536?i+=String.fromCharCode(a):(a-=65536,i+=String.fromCharCode((a>>10)+55296,(a&1023)+56320))}return i}__union_with_string(e,t){return typeof e=="string"?this.__string(t):this.__union(e,t)}__indirect(e){return e+this.readInt32(e)}__vector(e){return e+this.readInt32(e)+It}__vector_len(e){return this.readInt32(e+this.readInt32(e))}__has_identifier(e){if(e.length!=Wt)throw new Error("FlatBuffers: file identifier must be length "+Wt);for(let t=0;t<Wt;t++)if(e.charCodeAt(t)!=this.readInt8(this.position()+It+t))return!1;return!0}createLong(e,t){return Zt.create(e,t)}createScalarList(e,t){const n=[];for(let i=0;i<t;++i)e(i)!==null&&n.push(e(i));return n}createObjList(e,t){const n=[];for(let i=0;i<t;++i){const s=e(i);s!==null&&n.push(s.unpack())}return n}}class _o{constructor(e){this.minalign=1,this.vtable=null,this.vtable_in_use=0,this.isNested=!1,this.object_start=0,this.vtables=[],this.vector_num_elems=0,this.force_defaults=!1,this.string_maps=null;let t;e?t=e:t=1024,this.bb=bi.allocate(t),this.space=t}clear(){this.bb.clear(),this.space=this.bb.capacity(),this.minalign=1,this.vtable=null,this.vtable_in_use=0,this.isNested=!1,this.object_start=0,this.vtables=[],this.vector_num_elems=0,this.force_defaults=!1,this.string_maps=null}forceDefaults(e){this.force_defaults=e}dataBuffer(){return this.bb}asUint8Array(){return this.bb.bytes().subarray(this.bb.position(),this.bb.position()+this.offset())}prep(e,t){e>this.minalign&&(this.minalign=e);const n=~(this.bb.capacity()-this.space+t)+1&e-1;for(;this.space<n+e+t;){const i=this.bb.capacity();this.bb=_o.growByteBuffer(this.bb),this.space+=this.bb.capacity()-i}this.pad(n)}pad(e){for(let t=0;t<e;t++)this.bb.writeInt8(--this.space,0)}writeInt8(e){this.bb.writeInt8(this.space-=1,e)}writeInt16(e){this.bb.writeInt16(this.space-=2,e)}writeInt32(e){this.bb.writeInt32(this.space-=4,e)}writeInt64(e){this.bb.writeInt64(this.space-=8,e)}writeFloat32(e){this.bb.writeFloat32(this.space-=4,e)}writeFloat64(e){this.bb.writeFloat64(this.space-=8,e)}addInt8(e){this.prep(1,0),this.writeInt8(e)}addInt16(e){this.prep(2,0),this.writeInt16(e)}addInt32(e){this.prep(4,0),this.writeInt32(e)}addInt64(e){this.prep(8,0),this.writeInt64(e)}addFloat32(e){this.prep(4,0),this.writeFloat32(e)}addFloat64(e){this.prep(8,0),this.writeFloat64(e)}addFieldInt8(e,t,n){(this.force_defaults||t!=n)&&(this.addInt8(t),this.slot(e))}addFieldInt16(e,t,n){(this.force_defaults||t!=n)&&(this.addInt16(t),this.slot(e))}addFieldInt32(e,t,n){(this.force_defaults||t!=n)&&(this.addInt32(t),this.slot(e))}addFieldInt64(e,t,n){(this.force_defaults||!t.equals(n))&&(this.addInt64(t),this.slot(e))}addFieldFloat32(e,t,n){(this.force_defaults||t!=n)&&(this.addFloat32(t),this.slot(e))}addFieldFloat64(e,t,n){(this.force_defaults||t!=n)&&(this.addFloat64(t),this.slot(e))}addFieldOffset(e,t,n){(this.force_defaults||t!=n)&&(this.addOffset(t),this.slot(e))}addFieldStruct(e,t,n){t!=n&&(this.nested(t),this.slot(e))}nested(e){if(e!=this.offset())throw new Error("FlatBuffers: struct must be serialized inline.")}notNested(){if(this.isNested)throw new Error("FlatBuffers: object serialization must not be nested.")}slot(e){this.vtable!==null&&(this.vtable[e]=this.offset())}offset(){return this.bb.capacity()-this.space}static growByteBuffer(e){const t=e.capacity();if(t&3221225472)throw new Error("FlatBuffers: cannot grow buffer beyond 2 gigabytes.");const n=t<<1,i=bi.allocate(n);return i.setPosition(n-t),i.bytes().set(e.bytes(),n-t),i}addOffset(e){this.prep(It,0),this.writeInt32(this.offset()-e+It)}startObject(e){this.notNested(),this.vtable==null&&(this.vtable=[]),this.vtable_in_use=e;for(let t=0;t<e;t++)this.vtable[t]=0;this.isNested=!0,this.object_start=this.offset()}endObject(){if(this.vtable==null||!this.isNested)throw new Error("FlatBuffers: endObject called without startObject");this.addInt32(0);const e=this.offset();let t=this.vtable_in_use-1;for(;t>=0&&this.vtable[t]==0;t--);const n=t+1;for(;t>=0;t--)this.addInt16(this.vtable[t]!=0?e-this.vtable[t]:0);const i=2;this.addInt16(e-this.object_start);const s=(n+i)*ys;this.addInt16(s);let a=0;const o=this.space;e:for(t=0;t<this.vtables.length;t++){const c=this.bb.capacity()-this.vtables[t];if(s==this.bb.readInt16(c)){for(let l=ys;l<s;l+=ys)if(this.bb.readInt16(o+l)!=this.bb.readInt16(c+l))continue e;a=this.vtables[t];break}}return a?(this.space=this.bb.capacity()-e,this.bb.writeInt32(this.space,a-e)):(this.vtables.push(this.offset()),this.bb.writeInt32(this.bb.capacity()-e,this.offset()-e)),this.isNested=!1,e}finish(e,t,n){const i=n?ra:0;if(t){const s=t;if(this.prep(this.minalign,It+Wt+i),s.length!=Wt)throw new Error("FlatBuffers: file identifier must be length "+Wt);for(let a=Wt-1;a>=0;a--)this.writeInt8(s.charCodeAt(a))}this.prep(this.minalign,It+i),this.addOffset(e),i&&this.addInt32(this.bb.capacity()-this.space),this.bb.setPosition(this.space)}finishSizePrefixed(e,t){this.finish(e,t,!0)}requiredField(e,t){const n=this.bb.capacity()-e,i=n-this.bb.readInt32(n);if(this.bb.readInt16(i+t)==0)throw new Error("FlatBuffers: field "+t+" must be set")}startVector(e,t,n){this.notNested(),this.vector_num_elems=t,this.prep(It,e*t),this.prep(n,e*t)}endVector(){return this.writeInt32(this.vector_num_elems),this.offset()}createSharedString(e){if(!e)return 0;if(this.string_maps||(this.string_maps=new Map),this.string_maps.has(e))return this.string_maps.get(e);const t=this.createString(e);return this.string_maps.set(e,t),t}createString(e){if(!e)return 0;let t;if(e instanceof Uint8Array)t=e;else{t=[];let n=0;for(;n<e.length;){let i;const s=e.charCodeAt(n++);if(s<55296||s>=56320)i=s;else{const a=e.charCodeAt(n++);i=(s<<10)+a+-56613888}i<128?t.push(i):(i<2048?t.push(i>>6&31|192):(i<65536?t.push(i>>12&15|224):t.push(i>>18&7|240,i>>12&63|128),t.push(i>>6&63|128)),t.push(i&63|128))}}this.addInt8(0),this.startVector(1,t.length,1),this.bb.setPosition(this.space-=t.length);for(let n=0,i=this.space,s=this.bb.bytes();n<t.length;n++)s[i++]=t[n];return this.endVector()}createLong(e,t){return Zt.create(e,t)}createObjectOffset(e){return e===null?0:typeof e=="string"?this.createString(e):e.pack(this)}createObjectOffsetList(e){const t=[];for(let n=0;n<e.length;++n){const i=e[n];if(i!==null)t.push(this.createObjectOffset(i));else throw new Error("FlatBuffers: Argument for createObjectOffsetList cannot contain null.")}return t}createStructOffsetList(e,t){return t(this,e.length),this.createObjectOffsetList(e),this.endVector()}}function ar(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var aa={exports:{}},ca;function la(){return ca||(ca=1,function(r){var e={};e.useBlobBuilder=function(){try{return new Blob([]),!1}catch{return!0}}(),e.useArrayBufferView=!e.useBlobBuilder&&function(){try{return new Blob([new Uint8Array([])]).size===0}catch{return!0}}(),r.exports.binaryFeatures=e;var t=r.exports.BlobBuilder;typeof window<"u"&&(t=r.exports.BlobBuilder=window.WebKitBlobBuilder||window.MozBlobBuilder||window.MSBlobBuilder||window.BlobBuilder);function n(){this._pieces=[],this._parts=[]}n.prototype.append=function(i){typeof i=="number"?this._pieces.push(i):(this.flush(),this._parts.push(i))},n.prototype.flush=function(){if(this._pieces.length>0){var i=new Uint8Array(this._pieces);e.useArrayBufferView||(i=i.buffer),this._parts.push(i),this._pieces=[]}},n.prototype.getBuffer=function(){if(this.flush(),e.useBlobBuilder){for(var i=new t,s=0,a=this._parts.length;s<a;s++)i.append(this._parts[s]);return i.getBlob()}else return new Blob(this._parts)},r.exports.BufferBuilder=n}(aa)),aa.exports}var vs,ua;function ou(){if(ua)return vs;ua=1;var r=la().BufferBuilder,e=la().binaryFeatures,t={unpack:function(o){var c=new n(o);return c.unpack()},pack:function(o){var c=new i;c.pack(o);var l=c.getBuffer();return l}};vs=t;function n(o){this.index=0,this.dataBuffer=o,this.dataView=new Uint8Array(this.dataBuffer),this.length=this.dataBuffer.byteLength}n.prototype.unpack=function(){var o=this.unpack_uint8();if(o<128)return o;if((o^224)<32)return(o^224)-32;var c;if((c=o^160)<=15)return this.unpack_raw(c);if((c=o^176)<=15)return this.unpack_string(c);if((c=o^144)<=15)return this.unpack_array(c);if((c=o^128)<=15)return this.unpack_map(c);switch(o){case 192:return null;case 193:return;case 194:return!1;case 195:return!0;case 202:return this.unpack_float();case 203:return this.unpack_double();case 204:return this.unpack_uint8();case 205:return this.unpack_uint16();case 206:return this.unpack_uint32();case 207:return this.unpack_uint64();case 208:return this.unpack_int8();case 209:return this.unpack_int16();case 210:return this.unpack_int32();case 211:return this.unpack_int64();case 212:return;case 213:return;case 214:return;case 215:return;case 216:return c=this.unpack_uint16(),this.unpack_string(c);case 217:return c=this.unpack_uint32(),this.unpack_string(c);case 218:return c=this.unpack_uint16(),this.unpack_raw(c);case 219:return c=this.unpack_uint32(),this.unpack_raw(c);case 220:return c=this.unpack_uint16(),this.unpack_array(c);case 221:return c=this.unpack_uint32(),this.unpack_array(c);case 222:return c=this.unpack_uint16(),this.unpack_map(c);case 223:return c=this.unpack_uint32(),this.unpack_map(c)}},n.prototype.unpack_uint8=function(){var o=this.dataView[this.index]&255;return this.index++,o},n.prototype.unpack_uint16=function(){var o=this.read(2),c=(o[0]&255)*256+(o[1]&255);return this.index+=2,c},n.prototype.unpack_uint32=function(){var o=this.read(4),c=((o[0]*256+o[1])*256+o[2])*256+o[3];return this.index+=4,c},n.prototype.unpack_uint64=function(){var o=this.read(8),c=((((((o[0]*256+o[1])*256+o[2])*256+o[3])*256+o[4])*256+o[5])*256+o[6])*256+o[7];return this.index+=8,c},n.prototype.unpack_int8=function(){var o=this.unpack_uint8();return o<128?o:o-256},n.prototype.unpack_int16=function(){var o=this.unpack_uint16();return o<32768?o:o-65536},n.prototype.unpack_int32=function(){var o=this.unpack_uint32();return o<Math.pow(2,31)?o:o-Math.pow(2,32)},n.prototype.unpack_int64=function(){var o=this.unpack_uint64();return o<Math.pow(2,63)?o:o-Math.pow(2,64)},n.prototype.unpack_raw=function(o){if(this.length<this.index+o)throw new Error("BinaryPackFailure: index is out of range "+this.index+" "+o+" "+this.length);var c=this.dataBuffer.slice(this.index,this.index+o);return this.index+=o,c},n.prototype.unpack_string=function(o){for(var c=this.read(o),l=0,u="",p,f;l<o;)p=c[l],p<128?(u+=String.fromCharCode(p),l++):(p^192)<32?(f=(p^192)<<6|c[l+1]&63,u+=String.fromCharCode(f),l+=2):(f=(p&15)<<12|(c[l+1]&63)<<6|c[l+2]&63,u+=String.fromCharCode(f),l+=3);return this.index+=o,u},n.prototype.unpack_array=function(o){for(var c=new Array(o),l=0;l<o;l++)c[l]=this.unpack();return c},n.prototype.unpack_map=function(o){for(var c={},l=0;l<o;l++){var u=this.unpack(),p=this.unpack();c[u]=p}return c},n.prototype.unpack_float=function(){var o=this.unpack_uint32(),c=o>>31,l=(o>>23&255)-127,u=o&8388607|8388608;return(c===0?1:-1)*u*Math.pow(2,l-23)},n.prototype.unpack_double=function(){var o=this.unpack_uint32(),c=this.unpack_uint32(),l=o>>31,u=(o>>20&2047)-1023,p=o&1048575|1048576,f=p*Math.pow(2,u-20)+c*Math.pow(2,u-52);return(l===0?1:-1)*f},n.prototype.read=function(o){var c=this.index;if(c+o<=this.length)return this.dataView.subarray(c,c+o);throw new Error("BinaryPackFailure: read index out of range")};function i(){this.bufferBuilder=new r}i.prototype.getBuffer=function(){return this.bufferBuilder.getBuffer()},i.prototype.pack=function(o){var c=typeof o;if(c==="string")this.pack_string(o);else if(c==="number")Math.floor(o)===o?this.pack_integer(o):this.pack_double(o);else if(c==="boolean")o===!0?this.bufferBuilder.append(195):o===!1&&this.bufferBuilder.append(194);else if(c==="undefined")this.bufferBuilder.append(192);else if(c==="object")if(o===null)this.bufferBuilder.append(192);else{var l=o.constructor;if(l==Array)this.pack_array(o);else if(l==Blob||l==File||o instanceof Blob||o instanceof File)this.pack_bin(o);else if(l==ArrayBuffer)e.useArrayBufferView?this.pack_bin(new Uint8Array(o)):this.pack_bin(o);else if("BYTES_PER_ELEMENT"in o)e.useArrayBufferView?this.pack_bin(new Uint8Array(o.buffer)):this.pack_bin(o.buffer);else if(l==Object||l.toString().startsWith("class"))this.pack_object(o);else if(l==Date)this.pack_string(o.toString());else if(typeof o.toBinaryPack=="function")this.bufferBuilder.append(o.toBinaryPack());else throw new Error('Type "'+l.toString()+'" not yet supported')}else throw new Error('Type "'+c+'" not yet supported');this.bufferBuilder.flush()},i.prototype.pack_bin=function(o){var c=o.length||o.byteLength||o.size;if(c<=15)this.pack_uint8(160+c);else if(c<=65535)this.bufferBuilder.append(218),this.pack_uint16(c);else if(c<=4294967295)this.bufferBuilder.append(219),this.pack_uint32(c);else throw new Error("Invalid length");this.bufferBuilder.append(o)},i.prototype.pack_string=function(o){var c=a(o);if(c<=15)this.pack_uint8(176+c);else if(c<=65535)this.bufferBuilder.append(216),this.pack_uint16(c);else if(c<=4294967295)this.bufferBuilder.append(217),this.pack_uint32(c);else throw new Error("Invalid length");this.bufferBuilder.append(o)},i.prototype.pack_array=function(o){var c=o.length;if(c<=15)this.pack_uint8(144+c);else if(c<=65535)this.bufferBuilder.append(220),this.pack_uint16(c);else if(c<=4294967295)this.bufferBuilder.append(221),this.pack_uint32(c);else throw new Error("Invalid length");for(var l=0;l<c;l++)this.pack(o[l])},i.prototype.pack_integer=function(o){if(o>=-32&&o<=127)this.bufferBuilder.append(o&255);else if(o>=0&&o<=255)this.bufferBuilder.append(204),this.pack_uint8(o);else if(o>=-128&&o<=127)this.bufferBuilder.append(208),this.pack_int8(o);else if(o>=0&&o<=65535)this.bufferBuilder.append(205),this.pack_uint16(o);else if(o>=-32768&&o<=32767)this.bufferBuilder.append(209),this.pack_int16(o);else if(o>=0&&o<=4294967295)this.bufferBuilder.append(206),this.pack_uint32(o);else if(o>=-2147483648&&o<=2147483647)this.bufferBuilder.append(210),this.pack_int32(o);else if(o>=-9223372036854776e3&&o<=9223372036854776e3)this.bufferBuilder.append(211),this.pack_int64(o);else if(o>=0&&o<=18446744073709552e3)this.bufferBuilder.append(207),this.pack_uint64(o);else throw new Error("Invalid integer")},i.prototype.pack_double=function(o){var c=0;o<0&&(c=1,o=-o);var l=Math.floor(Math.log(o)/Math.LN2),u=o/Math.pow(2,l)-1,p=Math.floor(u*Math.pow(2,52)),f=Math.pow(2,32),m=c<<31|l+1023<<20|p/f&1048575,b=p%f;this.bufferBuilder.append(203),this.pack_int32(m),this.pack_int32(b)},i.prototype.pack_object=function(o){var c=Object.keys(o),l=c.length;if(l<=15)this.pack_uint8(128+l);else if(l<=65535)this.bufferBuilder.append(222),this.pack_uint16(l);else if(l<=4294967295)this.bufferBuilder.append(223),this.pack_uint32(l);else throw new Error("Invalid length");for(var u in o)o.hasOwnProperty(u)&&(this.pack(u),this.pack(o[u]))},i.prototype.pack_uint8=function(o){this.bufferBuilder.append(o)},i.prototype.pack_uint16=function(o){this.bufferBuilder.append(o>>8),this.bufferBuilder.append(o&255)},i.prototype.pack_uint32=function(o){var c=o&4294967295;this.bufferBuilder.append((c&4278190080)>>>24),this.bufferBuilder.append((c&16711680)>>>16),this.bufferBuilder.append((c&65280)>>>8),this.bufferBuilder.append(c&255)},i.prototype.pack_uint64=function(o){var c=o/Math.pow(2,32),l=o%Math.pow(2,32);this.bufferBuilder.append((c&4278190080)>>>24),this.bufferBuilder.append((c&16711680)>>>16),this.bufferBuilder.append((c&65280)>>>8),this.bufferBuilder.append(c&255),this.bufferBuilder.append((l&4278190080)>>>24),this.bufferBuilder.append((l&16711680)>>>16),this.bufferBuilder.append((l&65280)>>>8),this.bufferBuilder.append(l&255)},i.prototype.pack_int8=function(o){this.bufferBuilder.append(o&255)},i.prototype.pack_int16=function(o){this.bufferBuilder.append((o&65280)>>8),this.bufferBuilder.append(o&255)},i.prototype.pack_int32=function(o){this.bufferBuilder.append(o>>>24&255),this.bufferBuilder.append((o&16711680)>>>16),this.bufferBuilder.append((o&65280)>>>8),this.bufferBuilder.append(o&255)},i.prototype.pack_int64=function(o){var c=Math.floor(o/Math.pow(2,32)),l=o%Math.pow(2,32);this.bufferBuilder.append((c&4278190080)>>>24),this.bufferBuilder.append((c&16711680)>>>16),this.bufferBuilder.append((c&65280)>>>8),this.bufferBuilder.append(c&255),this.bufferBuilder.append((l&4278190080)>>>24),this.bufferBuilder.append((l&16711680)>>>16),this.bufferBuilder.append((l&65280)>>>8),this.bufferBuilder.append(l&255)};function s(o){var c=o.charCodeAt(0);return c<=2047?"00":c<=65535?"000":c<=2097151?"0000":c<=67108863?"00000":"000000"}function a(o){return o.length>600?new Blob([o]).size:o.replace(/[^\u0000-\u007F]/g,s).length}return vs}var au=ou();const ha=ar(au);let da=!0,pa=!0;function Zn(r,e,t){const n=r.match(e);return n&&n.length>=t&&parseInt(n[t],10)}function Rn(r,e,t){if(!r.RTCPeerConnection)return;const n=r.RTCPeerConnection.prototype,i=n.addEventListener;n.addEventListener=function(a,o){if(a!==e)return i.apply(this,arguments);const c=l=>{const u=t(l);u&&(o.handleEvent?o.handleEvent(u):o(u))};return this._eventMap=this._eventMap||{},this._eventMap[e]||(this._eventMap[e]=new Map),this._eventMap[e].set(o,c),i.apply(this,[a,c])};const s=n.removeEventListener;n.removeEventListener=function(a,o){if(a!==e||!this._eventMap||!this._eventMap[e])return s.apply(this,arguments);if(!this._eventMap[e].has(o))return s.apply(this,arguments);const c=this._eventMap[e].get(o);return this._eventMap[e].delete(o),this._eventMap[e].size===0&&delete this._eventMap[e],Object.keys(this._eventMap).length===0&&delete this._eventMap,s.apply(this,[a,c])},Object.defineProperty(n,"on"+e,{get(){return this["_on"+e]},set(a){this["_on"+e]&&(this.removeEventListener(e,this["_on"+e]),delete this["_on"+e]),a&&this.addEventListener(e,this["_on"+e]=a)},enumerable:!0,configurable:!0})}function cu(r){return typeof r!="boolean"?new Error("Argument type: "+typeof r+". Please use a boolean."):(da=r,r?"adapter.js logging disabled":"adapter.js logging enabled")}function lu(r){return typeof r!="boolean"?new Error("Argument type: "+typeof r+". Please use a boolean."):(pa=!r,"adapter.js deprecation warnings "+(r?"disabled":"enabled"))}function Ss(){if(typeof window=="object"){if(da)return;typeof console<"u"&&typeof console.log=="function"&&console.log.apply(console,arguments)}}function cr(r,e){pa&&console.warn(r+" is deprecated, please use "+e+" instead.")}function uu(r){const e={browser:null,version:null};if(typeof r>"u"||!r.navigator)return e.browser="Not a browser.",e;const{navigator:t}=r;if(t.mozGetUserMedia)e.browser="firefox",e.version=Zn(t.userAgent,/Firefox\/(\d+)\./,1);else if(t.webkitGetUserMedia||r.isSecureContext===!1&&r.webkitRTCPeerConnection&&!r.RTCIceGatherer)e.browser="chrome",e.version=Zn(t.userAgent,/Chrom(e|ium)\/(\d+)\./,2);else if(t.mediaDevices&&t.userAgent.match(/Edge\/(\d+).(\d+)$/))e.browser="edge",e.version=Zn(t.userAgent,/Edge\/(\d+).(\d+)$/,2);else if(r.RTCPeerConnection&&t.userAgent.match(/AppleWebKit\/(\d+)\./))e.browser="safari",e.version=Zn(t.userAgent,/AppleWebKit\/(\d+)\./,1),e.supportsUnifiedPlan=r.RTCRtpTransceiver&&"currentDirection"in r.RTCRtpTransceiver.prototype;else return e.browser="Not a supported browser.",e;return e}function fa(r){return Object.prototype.toString.call(r)==="[object Object]"}function ma(r){return fa(r)?Object.keys(r).reduce(function(e,t){const n=fa(r[t]),i=n?ma(r[t]):r[t],s=n&&!Object.keys(i).length;return i===void 0||s?e:Object.assign(e,{[t]:i})},{}):r}function bs(r,e,t){!e||t.has(e.id)||(t.set(e.id,e),Object.keys(e).forEach(n=>{n.endsWith("Id")?bs(r,r.get(e[n]),t):n.endsWith("Ids")&&e[n].forEach(i=>{bs(r,r.get(i),t)})}))}function ya(r,e,t){const n=t?"outbound-rtp":"inbound-rtp",i=new Map;if(e===null)return i;const s=[];return r.forEach(a=>{a.type==="track"&&a.trackIdentifier===e.id&&s.push(a)}),s.forEach(a=>{r.forEach(o=>{o.type===n&&o.trackId===a.id&&bs(r,o,i)})}),i}const ga=Ss;function va(r,e){const t=r&&r.navigator;if(!t.mediaDevices)return;const n=function(o){if(typeof o!="object"||o.mandatory||o.optional)return o;const c={};return Object.keys(o).forEach(l=>{if(l==="require"||l==="advanced"||l==="mediaSource")return;const u=typeof o[l]=="object"?o[l]:{ideal:o[l]};u.exact!==void 0&&typeof u.exact=="number"&&(u.min=u.max=u.exact);const p=function(f,m){return f?f+m.charAt(0).toUpperCase()+m.slice(1):m==="deviceId"?"sourceId":m};if(u.ideal!==void 0){c.optional=c.optional||[];let f={};typeof u.ideal=="number"?(f[p("min",l)]=u.ideal,c.optional.push(f),f={},f[p("max",l)]=u.ideal,c.optional.push(f)):(f[p("",l)]=u.ideal,c.optional.push(f))}u.exact!==void 0&&typeof u.exact!="number"?(c.mandatory=c.mandatory||{},c.mandatory[p("",l)]=u.exact):["min","max"].forEach(f=>{u[f]!==void 0&&(c.mandatory=c.mandatory||{},c.mandatory[p(f,l)]=u[f])})}),o.advanced&&(c.optional=(c.optional||[]).concat(o.advanced)),c},i=function(o,c){if(e.version>=61)return c(o);if(o=JSON.parse(JSON.stringify(o)),o&&typeof o.audio=="object"){const l=function(u,p,f){p in u&&!(f in u)&&(u[f]=u[p],delete u[p])};o=JSON.parse(JSON.stringify(o)),l(o.audio,"autoGainControl","googAutoGainControl"),l(o.audio,"noiseSuppression","googNoiseSuppression"),o.audio=n(o.audio)}if(o&&typeof o.video=="object"){let l=o.video.facingMode;l=l&&(typeof l=="object"?l:{ideal:l});const u=e.version<66;if(l&&(l.exact==="user"||l.exact==="environment"||l.ideal==="user"||l.ideal==="environment")&&!(t.mediaDevices.getSupportedConstraints&&t.mediaDevices.getSupportedConstraints().facingMode&&!u)){delete o.video.facingMode;let p;if(l.exact==="environment"||l.ideal==="environment"?p=["back","rear"]:(l.exact==="user"||l.ideal==="user")&&(p=["front"]),p)return t.mediaDevices.enumerateDevices().then(f=>{f=f.filter(b=>b.kind==="videoinput");let m=f.find(b=>p.some(x=>b.label.toLowerCase().includes(x)));return!m&&f.length&&p.includes("back")&&(m=f[f.length-1]),m&&(o.video.deviceId=l.exact?{exact:m.deviceId}:{ideal:m.deviceId}),o.video=n(o.video),ga("chrome: "+JSON.stringify(o)),c(o)})}o.video=n(o.video)}return ga("chrome: "+JSON.stringify(o)),c(o)},s=function(o){return e.version>=64?o:{name:{PermissionDeniedError:"NotAllowedError",PermissionDismissedError:"NotAllowedError",InvalidStateError:"NotAllowedError",DevicesNotFoundError:"NotFoundError",ConstraintNotSatisfiedError:"OverconstrainedError",TrackStartError:"NotReadableError",MediaDeviceFailedDueToShutdown:"NotAllowedError",MediaDeviceKillSwitchOn:"NotAllowedError",TabCaptureError:"AbortError",ScreenCaptureError:"AbortError",DeviceCaptureError:"AbortError"}[o.name]||o.name,message:o.message,constraint:o.constraint||o.constraintName,toString(){return this.name+(this.message&&": ")+this.message}}},a=function(o,c,l){i(o,u=>{t.webkitGetUserMedia(u,c,p=>{l&&l(s(p))})})};if(t.getUserMedia=a.bind(t),t.mediaDevices.getUserMedia){const o=t.mediaDevices.getUserMedia.bind(t.mediaDevices);Object.getOwnPropertyDescriptor(t.mediaDevices,"getUserMedia")?.writable&&(t.mediaDevices.getUserMedia=function(c){return i(c,l=>o(l).then(u=>{if(l.audio&&!u.getAudioTracks().length||l.video&&!u.getVideoTracks().length)throw u.getTracks().forEach(p=>{p.stop()}),new DOMException("","NotFoundError");return u},u=>Promise.reject(s(u))))})}}function hu(r,e){if(!(r.navigator.mediaDevices&&"getDisplayMedia"in r.navigator.mediaDevices)&&r.navigator.mediaDevices){if(typeof e!="function"){console.error("shimGetDisplayMedia: getSourceId argument is not a function");return}r.navigator.mediaDevices.getDisplayMedia=function(t){return e(t).then(n=>{const i=t.video&&t.video.width,s=t.video&&t.video.height,a=t.video&&t.video.frameRate;return t.video={mandatory:{chromeMediaSource:"desktop",chromeMediaSourceId:n,maxFrameRate:a||3}},i&&(t.video.mandatory.maxWidth=i),s&&(t.video.mandatory.maxHeight=s),r.navigator.mediaDevices.getUserMedia(t)})}}}function Sa(r){r.MediaStream=r.MediaStream||r.webkitMediaStream}function ba(r){if(typeof r=="object"&&r.RTCPeerConnection&&!("ontrack"in r.RTCPeerConnection.prototype)){Object.defineProperty(r.RTCPeerConnection.prototype,"ontrack",{get(){return this._ontrack},set(t){this._ontrack&&this.removeEventListener("track",this._ontrack),this.addEventListener("track",this._ontrack=t)},enumerable:!0,configurable:!0});const e=r.RTCPeerConnection.prototype.setRemoteDescription;r.RTCPeerConnection.prototype.setRemoteDescription=function(){return this._ontrackpoly||(this._ontrackpoly=t=>{t.stream.addEventListener("addtrack",n=>{let i;r.RTCPeerConnection.prototype.getReceivers?i=this.getReceivers().find(a=>a.track&&a.track.id===n.track.id):i={track:n.track};const s=new Event("track");s.track=n.track,s.receiver=i,s.transceiver={receiver:i},s.streams=[t.stream],this.dispatchEvent(s)}),t.stream.getTracks().forEach(n=>{let i;r.RTCPeerConnection.prototype.getReceivers?i=this.getReceivers().find(a=>a.track&&a.track.id===n.id):i={track:n};const s=new Event("track");s.track=n,s.receiver=i,s.transceiver={receiver:i},s.streams=[t.stream],this.dispatchEvent(s)})},this.addEventListener("addstream",this._ontrackpoly)),e.apply(this,arguments)}}else Rn(r,"track",e=>(e.transceiver||Object.defineProperty(e,"transceiver",{value:{receiver:e.receiver}}),e))}function xa(r){if(typeof r=="object"&&r.RTCPeerConnection&&!("getSenders"in r.RTCPeerConnection.prototype)&&"createDTMFSender"in r.RTCPeerConnection.prototype){const e=function(i,s){return{track:s,get dtmf(){return this._dtmf===void 0&&(s.kind==="audio"?this._dtmf=i.createDTMFSender(s):this._dtmf=null),this._dtmf},_pc:i}};if(!r.RTCPeerConnection.prototype.getSenders){r.RTCPeerConnection.prototype.getSenders=function(){return this._senders=this._senders||[],this._senders.slice()};const i=r.RTCPeerConnection.prototype.addTrack;r.RTCPeerConnection.prototype.addTrack=function(a,o){let c=i.apply(this,arguments);return c||(c=e(this,a),this._senders.push(c)),c};const s=r.RTCPeerConnection.prototype.removeTrack;r.RTCPeerConnection.prototype.removeTrack=function(a){s.apply(this,arguments);const o=this._senders.indexOf(a);o!==-1&&this._senders.splice(o,1)}}const t=r.RTCPeerConnection.prototype.addStream;r.RTCPeerConnection.prototype.addStream=function(i){this._senders=this._senders||[],t.apply(this,[i]),i.getTracks().forEach(s=>{this._senders.push(e(this,s))})};const n=r.RTCPeerConnection.prototype.removeStream;r.RTCPeerConnection.prototype.removeStream=function(i){this._senders=this._senders||[],n.apply(this,[i]),i.getTracks().forEach(s=>{const a=this._senders.find(o=>o.track===s);a&&this._senders.splice(this._senders.indexOf(a),1)})}}else if(typeof r=="object"&&r.RTCPeerConnection&&"getSenders"in r.RTCPeerConnection.prototype&&"createDTMFSender"in r.RTCPeerConnection.prototype&&r.RTCRtpSender&&!("dtmf"in r.RTCRtpSender.prototype)){const e=r.RTCPeerConnection.prototype.getSenders;r.RTCPeerConnection.prototype.getSenders=function(){const t=e.apply(this,[]);return t.forEach(n=>n._pc=this),t},Object.defineProperty(r.RTCRtpSender.prototype,"dtmf",{get(){return this._dtmf===void 0&&(this.track.kind==="audio"?this._dtmf=this._pc.createDTMFSender(this.track):this._dtmf=null),this._dtmf}})}}function wa(r){if(!r.RTCPeerConnection)return;const e=r.RTCPeerConnection.prototype.getStats;r.RTCPeerConnection.prototype.getStats=function(){const[t,n,i]=arguments;if(arguments.length>0&&typeof t=="function")return e.apply(this,arguments);if(e.length===0&&(arguments.length===0||typeof t!="function"))return e.apply(this,[]);const s=function(o){const c={};return o.result().forEach(l=>{const u={id:l.id,timestamp:l.timestamp,type:{localcandidate:"local-candidate",remotecandidate:"remote-candidate"}[l.type]||l.type};l.names().forEach(p=>{u[p]=l.stat(p)}),c[u.id]=u}),c},a=function(o){return new Map(Object.keys(o).map(c=>[c,o[c]]))};if(arguments.length>=2){const o=function(c){n(a(s(c)))};return e.apply(this,[o,t])}return new Promise((o,c)=>{e.apply(this,[function(l){o(a(s(l)))},c])}).then(n,i)}}function _a(r){if(!(typeof r=="object"&&r.RTCPeerConnection&&r.RTCRtpSender&&r.RTCRtpReceiver))return;if(!("getStats"in r.RTCRtpSender.prototype)){const t=r.RTCPeerConnection.prototype.getSenders;t&&(r.RTCPeerConnection.prototype.getSenders=function(){const i=t.apply(this,[]);return i.forEach(s=>s._pc=this),i});const n=r.RTCPeerConnection.prototype.addTrack;n&&(r.RTCPeerConnection.prototype.addTrack=function(){const i=n.apply(this,arguments);return i._pc=this,i}),r.RTCRtpSender.prototype.getStats=function(){const i=this;return this._pc.getStats().then(s=>ya(s,i.track,!0))}}if(!("getStats"in r.RTCRtpReceiver.prototype)){const t=r.RTCPeerConnection.prototype.getReceivers;t&&(r.RTCPeerConnection.prototype.getReceivers=function(){const n=t.apply(this,[]);return n.forEach(i=>i._pc=this),n}),Rn(r,"track",n=>(n.receiver._pc=n.srcElement,n)),r.RTCRtpReceiver.prototype.getStats=function(){const n=this;return this._pc.getStats().then(i=>ya(i,n.track,!1))}}if(!("getStats"in r.RTCRtpSender.prototype&&"getStats"in r.RTCRtpReceiver.prototype))return;const e=r.RTCPeerConnection.prototype.getStats;r.RTCPeerConnection.prototype.getStats=function(){if(arguments.length>0&&arguments[0]instanceof r.MediaStreamTrack){const t=arguments[0];let n,i,s;return this.getSenders().forEach(a=>{a.track===t&&(n?s=!0:n=a)}),this.getReceivers().forEach(a=>(a.track===t&&(i?s=!0:i=a),a.track===t)),s||n&&i?Promise.reject(new DOMException("There are more than one sender or receiver for the track.","InvalidAccessError")):n?n.getStats():i?i.getStats():Promise.reject(new DOMException("There is no sender or receiver for the track.","InvalidAccessError"))}return e.apply(this,arguments)}}function Ta(r){r.RTCPeerConnection.prototype.getLocalStreams=function(){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},Object.keys(this._shimmedLocalStreams).map(s=>this._shimmedLocalStreams[s][0])};const e=r.RTCPeerConnection.prototype.addTrack;r.RTCPeerConnection.prototype.addTrack=function(s,a){if(!a)return e.apply(this,arguments);this._shimmedLocalStreams=this._shimmedLocalStreams||{};const o=e.apply(this,arguments);return this._shimmedLocalStreams[a.id]?this._shimmedLocalStreams[a.id].indexOf(o)===-1&&this._shimmedLocalStreams[a.id].push(o):this._shimmedLocalStreams[a.id]=[a,o],o};const t=r.RTCPeerConnection.prototype.addStream;r.RTCPeerConnection.prototype.addStream=function(s){this._shimmedLocalStreams=this._shimmedLocalStreams||{},s.getTracks().forEach(c=>{if(this.getSenders().find(l=>l.track===c))throw new DOMException("Track already exists.","InvalidAccessError")});const a=this.getSenders();t.apply(this,arguments);const o=this.getSenders().filter(c=>a.indexOf(c)===-1);this._shimmedLocalStreams[s.id]=[s].concat(o)};const n=r.RTCPeerConnection.prototype.removeStream;r.RTCPeerConnection.prototype.removeStream=function(s){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},delete this._shimmedLocalStreams[s.id],n.apply(this,arguments)};const i=r.RTCPeerConnection.prototype.removeTrack;r.RTCPeerConnection.prototype.removeTrack=function(s){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},s&&Object.keys(this._shimmedLocalStreams).forEach(a=>{const o=this._shimmedLocalStreams[a].indexOf(s);o!==-1&&this._shimmedLocalStreams[a].splice(o,1),this._shimmedLocalStreams[a].length===1&&delete this._shimmedLocalStreams[a]}),i.apply(this,arguments)}}function Ma(r,e){if(!r.RTCPeerConnection)return;if(r.RTCPeerConnection.prototype.addTrack&&e.version>=65)return Ta(r);const t=r.RTCPeerConnection.prototype.getLocalStreams;r.RTCPeerConnection.prototype.getLocalStreams=function(){const l=t.apply(this);return this._reverseStreams=this._reverseStreams||{},l.map(u=>this._reverseStreams[u.id])};const n=r.RTCPeerConnection.prototype.addStream;r.RTCPeerConnection.prototype.addStream=function(l){if(this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},l.getTracks().forEach(u=>{if(this.getSenders().find(p=>p.track===u))throw new DOMException("Track already exists.","InvalidAccessError")}),!this._reverseStreams[l.id]){const u=new r.MediaStream(l.getTracks());this._streams[l.id]=u,this._reverseStreams[u.id]=l,l=u}n.apply(this,[l])};const i=r.RTCPeerConnection.prototype.removeStream;r.RTCPeerConnection.prototype.removeStream=function(l){this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},i.apply(this,[this._streams[l.id]||l]),delete this._reverseStreams[this._streams[l.id]?this._streams[l.id].id:l.id],delete this._streams[l.id]},r.RTCPeerConnection.prototype.addTrack=function(l,u){if(this.signalingState==="closed")throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");const p=[].slice.call(arguments,1);if(p.length!==1||!p[0].getTracks().find(m=>m===l))throw new DOMException("The adapter.js addTrack polyfill only supports a single stream which is associated with the specified track.","NotSupportedError");if(this.getSenders().find(m=>m.track===l))throw new DOMException("Track already exists.","InvalidAccessError");this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{};const f=this._streams[u.id];if(f)f.addTrack(l),Promise.resolve().then(()=>{this.dispatchEvent(new Event("negotiationneeded"))});else{const m=new r.MediaStream([l]);this._streams[u.id]=m,this._reverseStreams[m.id]=u,this.addStream(m)}return this.getSenders().find(m=>m.track===l)};function s(l,u){let p=u.sdp;return Object.keys(l._reverseStreams||[]).forEach(f=>{const m=l._reverseStreams[f],b=l._streams[m.id];p=p.replace(new RegExp(b.id,"g"),m.id)}),new RTCSessionDescription({type:u.type,sdp:p})}function a(l,u){let p=u.sdp;return Object.keys(l._reverseStreams||[]).forEach(f=>{const m=l._reverseStreams[f],b=l._streams[m.id];p=p.replace(new RegExp(m.id,"g"),b.id)}),new RTCSessionDescription({type:u.type,sdp:p})}["createOffer","createAnswer"].forEach(function(l){const u=r.RTCPeerConnection.prototype[l],p={[l](){const f=arguments;return arguments.length&&typeof arguments[0]=="function"?u.apply(this,[m=>{const b=s(this,m);f[0].apply(null,[b])},m=>{f[1]&&f[1].apply(null,m)},arguments[2]]):u.apply(this,arguments).then(m=>s(this,m))}};r.RTCPeerConnection.prototype[l]=p[l]});const o=r.RTCPeerConnection.prototype.setLocalDescription;r.RTCPeerConnection.prototype.setLocalDescription=function(){return!arguments.length||!arguments[0].type?o.apply(this,arguments):(arguments[0]=a(this,arguments[0]),o.apply(this,arguments))};const c=Object.getOwnPropertyDescriptor(r.RTCPeerConnection.prototype,"localDescription");Object.defineProperty(r.RTCPeerConnection.prototype,"localDescription",{get(){const l=c.get.apply(this);return l.type===""?l:s(this,l)}}),r.RTCPeerConnection.prototype.removeTrack=function(l){if(this.signalingState==="closed")throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");if(!l._pc)throw new DOMException("Argument 1 of RTCPeerConnection.removeTrack does not implement interface RTCRtpSender.","TypeError");if(l._pc!==this)throw new DOMException("Sender was not created by this connection.","InvalidAccessError");this._streams=this._streams||{};let u;Object.keys(this._streams).forEach(p=>{this._streams[p].getTracks().find(f=>l.track===f)&&(u=this._streams[p])}),u&&(u.getTracks().length===1?this.removeStream(this._reverseStreams[u.id]):u.removeTrack(l.track),this.dispatchEvent(new Event("negotiationneeded")))}}function xs(r,e){!r.RTCPeerConnection&&r.webkitRTCPeerConnection&&(r.RTCPeerConnection=r.webkitRTCPeerConnection),r.RTCPeerConnection&&e.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach(function(t){const n=r.RTCPeerConnection.prototype[t],i={[t](){return arguments[0]=new(t==="addIceCandidate"?r.RTCIceCandidate:r.RTCSessionDescription)(arguments[0]),n.apply(this,arguments)}};r.RTCPeerConnection.prototype[t]=i[t]})}function Ca(r,e){Rn(r,"negotiationneeded",t=>{const n=t.target;if(!((e.version<72||n.getConfiguration&&n.getConfiguration().sdpSemantics==="plan-b")&&n.signalingState!=="stable"))return t})}const Ea=Object.freeze(Object.defineProperty({__proto__:null,fixNegotiationNeeded:Ca,shimAddTrackRemoveTrack:Ma,shimAddTrackRemoveTrackWithNative:Ta,shimGetDisplayMedia:hu,shimGetSendersWithDtmf:xa,shimGetStats:wa,shimGetUserMedia:va,shimMediaStream:Sa,shimOnTrack:ba,shimPeerConnection:xs,shimSenderReceiverGetStats:_a},Symbol.toStringTag,{value:"Module"}));function du(r,e){let t=!1;return r=JSON.parse(JSON.stringify(r)),r.filter(n=>{if(n&&(n.urls||n.url)){let i=n.urls||n.url;n.url&&!n.urls&&cr("RTCIceServer.url","RTCIceServer.urls");const s=typeof i=="string";return s&&(i=[i]),i=i.filter(a=>{if(a.indexOf("stun:")===0)return!1;const o=a.startsWith("turn")&&!a.startsWith("turn:[")&&a.includes("transport=udp");return o&&!t?(t=!0,!0):o&&!t}),delete n.url,n.urls=s?i[0]:i,!!i.length}})}var Pa={exports:{}},ka;function Ra(){return ka||(ka=1,function(r){var e={};e.generateIdentifier=function(){return Math.random().toString(36).substr(2,10)},e.localCName=e.generateIdentifier(),e.splitLines=function(t){return t.trim().split(`
|
|
2
2
|
`).map(function(n){return n.trim()})},e.splitSections=function(t){var n=t.split(`
|
|
3
3
|
m=`);return n.map(function(i,s){return(s>0?"m="+i:i).trim()+`\r
|
|
4
4
|
`})},e.getDescription=function(t){var n=e.splitSections(t);return n&&n[0]},e.getMediaSections=function(t){var n=e.splitSections(t);return n.shift(),n},e.matchPrefix=function(t,n){return e.splitLines(t).filter(function(i){return i.indexOf(n)===0})},e.parseCandidate=function(t){var n;t.indexOf("a=candidate:")===0?n=t.substring(12).split(" "):n=t.substring(10).split(" ");for(var i={foundation:n[0],component:parseInt(n[1],10),protocol:n[2].toLowerCase(),priority:parseInt(n[3],10),ip:n[4],address:n[4],port:parseInt(n[5],10),type:n[7]},s=8;s<n.length;s+=2)switch(n[s]){case"raddr":i.relatedAddress=n[s+1];break;case"rport":i.relatedPort=parseInt(n[s+1],10);break;case"tcptype":i.tcpType=n[s+1];break;case"ufrag":i.ufrag=n[s+1],i.usernameFragment=n[s+1];break;default:i[n[s]]=n[s+1];break}return i},e.writeCandidate=function(t){var n=[];n.push(t.foundation),n.push(t.component),n.push(t.protocol.toUpperCase()),n.push(t.priority),n.push(t.address||t.ip),n.push(t.port);var i=t.type;return n.push("typ"),n.push(i),i!=="host"&&t.relatedAddress&&t.relatedPort&&(n.push("raddr"),n.push(t.relatedAddress),n.push("rport"),n.push(t.relatedPort)),t.tcpType&&t.protocol.toLowerCase()==="tcp"&&(n.push("tcptype"),n.push(t.tcpType)),(t.usernameFragment||t.ufrag)&&(n.push("ufrag"),n.push(t.usernameFragment||t.ufrag)),"candidate:"+n.join(" ")},e.parseIceOptions=function(t){return t.substr(14).split(" ")},e.parseRtpMap=function(t){var n=t.substr(9).split(" "),i={payloadType:parseInt(n.shift(),10)};return n=n[0].split("/"),i.name=n[0],i.clockRate=parseInt(n[1],10),i.channels=n.length===3?parseInt(n[2],10):1,i.numChannels=i.channels,i},e.writeRtpMap=function(t){var n=t.payloadType;t.preferredPayloadType!==void 0&&(n=t.preferredPayloadType);var i=t.channels||t.numChannels||1;return"a=rtpmap:"+n+" "+t.name+"/"+t.clockRate+(i!==1?"/"+i:"")+`\r
|
|
@@ -36,7 +36,7 @@ t=0 0\r
|
|
|
36
36
|
`;a+="a="+o,a+="a=ssrc:"+t.sendEncodingParameters[0].ssrc+" "+o,t.sendEncodingParameters[0].rtx&&(a+="a=ssrc:"+t.sendEncodingParameters[0].rtx.ssrc+" "+o,a+="a=ssrc-group:FID "+t.sendEncodingParameters[0].ssrc+" "+t.sendEncodingParameters[0].rtx.ssrc+`\r
|
|
37
37
|
`)}return a+="a=ssrc:"+t.sendEncodingParameters[0].ssrc+" cname:"+e.localCName+`\r
|
|
38
38
|
`,t.rtpSender&&t.sendEncodingParameters[0].rtx&&(a+="a=ssrc:"+t.sendEncodingParameters[0].rtx.ssrc+" cname:"+e.localCName+`\r
|
|
39
|
-
`),a},e.getDirection=function(t,n){for(var i=e.splitLines(t),s=0;s<i.length;s++)switch(i[s]){case"a=sendrecv":case"a=sendonly":case"a=recvonly":case"a=inactive":return i[s].substr(2)}return n?e.getDirection(n):"sendrecv"},e.getKind=function(t){var n=e.splitLines(t),i=n[0].split(" ");return i[0].substr(2)},e.isRejected=function(t){return t.split(" ",2)[1]==="0"},e.parseMLine=function(t){var n=e.splitLines(t),i=n[0].substr(2).split(" ");return{kind:i[0],port:parseInt(i[1],10),protocol:i[2],fmt:i.slice(3).join(" ")}},e.parseOLine=function(t){var n=e.matchPrefix(t,"o=")[0],i=n.substr(2).split(" ");return{username:i[0],sessionId:i[1],sessionVersion:parseInt(i[2],10),netType:i[3],addressType:i[4],address:i[5]}},e.isValidSDP=function(t){if(typeof t!="string"||t.length===0)return!1;for(var n=e.splitLines(t),i=0;i<n.length;i++)if(n[i].length<2||n[i].charAt(1)!=="=")return!1;return!0},r.exports=e}(Pa)),Pa.exports}var ws,Aa;function
|
|
39
|
+
`),a},e.getDirection=function(t,n){for(var i=e.splitLines(t),s=0;s<i.length;s++)switch(i[s]){case"a=sendrecv":case"a=sendonly":case"a=recvonly":case"a=inactive":return i[s].substr(2)}return n?e.getDirection(n):"sendrecv"},e.getKind=function(t){var n=e.splitLines(t),i=n[0].split(" ");return i[0].substr(2)},e.isRejected=function(t){return t.split(" ",2)[1]==="0"},e.parseMLine=function(t){var n=e.splitLines(t),i=n[0].substr(2).split(" ");return{kind:i[0],port:parseInt(i[1],10),protocol:i[2],fmt:i.slice(3).join(" ")}},e.parseOLine=function(t){var n=e.matchPrefix(t,"o=")[0],i=n.substr(2).split(" ");return{username:i[0],sessionId:i[1],sessionVersion:parseInt(i[2],10),netType:i[3],addressType:i[4],address:i[5]}},e.isValidSDP=function(t){if(typeof t!="string"||t.length===0)return!1;for(var n=e.splitLines(t),i=0;i<n.length;i++)if(n[i].length<2||n[i].charAt(1)!=="=")return!1;return!0},r.exports=e}(Pa)),Pa.exports}var ws,Aa;function pu(){if(Aa)return ws;Aa=1;var r=Ra();function e(c){return{inboundrtp:"inbound-rtp",outboundrtp:"outbound-rtp",candidatepair:"candidate-pair",localcandidate:"local-candidate",remotecandidate:"remote-candidate"}[c.type]||c.type}function t(c,l,u,p,f){var m=r.writeRtpDescription(c.kind,l);if(m+=r.writeIceParameters(c.iceGatherer.getLocalParameters()),m+=r.writeDtlsParameters(c.dtlsTransport.getLocalParameters(),u==="offer"?"actpass":f||"active"),m+="a=mid:"+c.mid+`\r
|
|
40
40
|
`,c.rtpSender&&c.rtpReceiver?m+=`a=sendrecv\r
|
|
41
41
|
`:c.rtpSender?m+=`a=sendonly\r
|
|
42
42
|
`:c.rtpReceiver?m+=`a=recvonly\r
|
|
@@ -66,21 +66,21 @@ a=mid:`+C.mid+`\r
|
|
|
66
66
|
`;return}if(C.stream){var E;C.kind==="audio"?E=C.stream.getAudioTracks()[0]:C.kind==="video"&&(E=C.stream.getVideoTracks()[0]),E&&l>=15019&&C.kind==="video"&&!C.sendEncodingParameters[0].rtx&&(C.sendEncodingParameters[0].rtx={ssrc:C.sendEncodingParameters[0].ssrc+1})}var P=i(C.localCapabilities,C.remoteCapabilities),O=P.codecs.filter(function(R){return R.name.toLowerCase()==="rtx"}).length;!O&&C.sendEncodingParameters[0].rtx&&delete C.sendEncodingParameters[0].rtx,v+=t(C,P,"answer",C.stream,g._dtlsRole),C.rtcpParameters&&C.rtcpParameters.reducedSize&&(v+=`a=rtcp-rsize\r
|
|
67
67
|
`)}});var w=new c.RTCSessionDescription({type:"answer",sdp:v});return Promise.resolve(w)},m.prototype.addIceCandidate=function(g){var v=this,_;return g&&!(g.sdpMLineIndex!==void 0||g.sdpMid)?Promise.reject(new TypeError("sdpMLineIndex or sdpMid required")):new Promise(function(w,C){if(v._remoteDescription)if(!g||g.candidate==="")for(var M=0;M<v.transceivers.length&&!(!v.transceivers[M].rejected&&(v.transceivers[M].iceTransport.addRemoteCandidate({}),_=r.getMediaSections(v._remoteDescription.sdp),_[M]+=`a=end-of-candidates\r
|
|
68
68
|
`,v._remoteDescription.sdp=r.getDescription(v._remoteDescription.sdp)+_.join(""),v.usingBundle));M++);else{var E=g.sdpMLineIndex;if(g.sdpMid){for(var P=0;P<v.transceivers.length;P++)if(v.transceivers[P].mid===g.sdpMid){E=P;break}}var O=v.transceivers[E];if(O){if(O.rejected)return w();var R=Object.keys(g.candidate).length>0?r.parseCandidate(g.candidate):{};if(R.protocol==="tcp"&&(R.port===0||R.port===9)||R.component&&R.component!==1)return w();if((E===0||E>0&&O.iceTransport!==v.transceivers[0].iceTransport)&&!a(O.iceTransport,R))return C(o("OperationError","Can not add ICE candidate"));var A=g.candidate.trim();A.indexOf("a=")===0&&(A=A.substr(2)),_=r.getMediaSections(v._remoteDescription.sdp),_[E]+="a="+(R.type?A:"end-of-candidates")+`\r
|
|
69
|
-
`,v._remoteDescription.sdp=r.getDescription(v._remoteDescription.sdp)+_.join("")}else return C(o("OperationError","Can not add ICE candidate"))}else return C(o("InvalidStateError","Can not add ICE candidate without a remote description"));w()})},m.prototype.getStats=function(g){if(g&&g instanceof c.MediaStreamTrack){var v=null;if(this.transceivers.forEach(function(w){w.rtpSender&&w.rtpSender.track===g?v=w.rtpSender:w.rtpReceiver&&w.rtpReceiver.track===g&&(v=w.rtpReceiver)}),!v)throw o("InvalidAccessError","Invalid selector.");return v.getStats()}var _=[];return this.transceivers.forEach(function(w){["rtpSender","rtpReceiver","iceGatherer","iceTransport","dtlsTransport"].forEach(function(C){w[C]&&_.push(w[C].getStats())})}),Promise.all(_).then(function(w){var C=new Map;return w.forEach(function(M){M.forEach(function(E){C.set(E.id,E)})}),C})};var b=["RTCRtpSender","RTCRtpReceiver","RTCIceGatherer","RTCIceTransport","RTCDtlsTransport"];b.forEach(function(g){var v=c[g];if(v&&v.prototype&&v.prototype.getStats){var _=v.prototype.getStats;v.prototype.getStats=function(){return _.apply(this).then(function(w){var C=new Map;return Object.keys(w).forEach(function(M){w[M].type=e(w[M]),C.set(M,w[M])}),C})}}});var x=["createOffer","createAnswer"];return x.forEach(function(g){var v=m.prototype[g];m.prototype[g]=function(){var _=arguments;return typeof _[0]=="function"||typeof _[1]=="function"?v.apply(this,[arguments[2]]).then(function(w){typeof _[0]=="function"&&_[0].apply(null,[w])},function(w){typeof _[1]=="function"&&_[1].apply(null,[w])}):v.apply(this,arguments)}}),x=["setLocalDescription","setRemoteDescription","addIceCandidate"],x.forEach(function(g){var v=m.prototype[g];m.prototype[g]=function(){var _=arguments;return typeof _[1]=="function"||typeof _[2]=="function"?v.apply(this,arguments).then(function(){typeof _[1]=="function"&&_[1].apply(null)},function(w){typeof _[2]=="function"&&_[2].apply(null,[w])}):v.apply(this,arguments)}}),["getStats"].forEach(function(g){var v=m.prototype[g];m.prototype[g]=function(){var _=arguments;return typeof _[1]=="function"?v.apply(this,arguments).then(function(){typeof _[1]=="function"&&_[1].apply(null)}):v.apply(this,arguments)}}),m},ws}var pu=du();const fu=ar(pu);function Oa(r){const e=r&&r.navigator,t=function(i){return{name:{PermissionDeniedError:"NotAllowedError"}[i.name]||i.name,message:i.message,constraint:i.constraint,toString(){return this.name}}},n=e.mediaDevices.getUserMedia.bind(e.mediaDevices);Object.getOwnPropertyDescriptor(e.mediaDevices,"getUserMedia")?.writable&&(e.mediaDevices.getUserMedia=function(i){return n(i).catch(s=>Promise.reject(t(s)))})}function Ia(r){"getDisplayMedia"in r.navigator&&r.navigator.mediaDevices&&(r.navigator.mediaDevices&&"getDisplayMedia"in r.navigator.mediaDevices||(r.navigator.mediaDevices.getDisplayMedia=r.navigator.getDisplayMedia.bind(r.navigator)))}function _s(r,e){if(r.RTCIceGatherer&&(r.RTCIceCandidate||(r.RTCIceCandidate=function(n){return n}),r.RTCSessionDescription||(r.RTCSessionDescription=function(n){return n}),e.version<15025)){const n=Object.getOwnPropertyDescriptor(r.MediaStreamTrack.prototype,"enabled");Object.defineProperty(r.MediaStreamTrack.prototype,"enabled",{set(i){n.set.call(this,i);const s=new Event("enabled");s.enabled=i,this.dispatchEvent(s)}})}r.RTCRtpSender&&!("dtmf"in r.RTCRtpSender.prototype)&&Object.defineProperty(r.RTCRtpSender.prototype,"dtmf",{get(){return this._dtmf===void 0&&(this.track.kind==="audio"?this._dtmf=new r.RTCDtmfSender(this):this.track.kind==="video"&&(this._dtmf=null)),this._dtmf}}),r.RTCDtmfSender&&!r.RTCDTMFSender&&(r.RTCDTMFSender=r.RTCDtmfSender);const t=fu(r,e.version);r.RTCPeerConnection=function(n){return n&&n.iceServers&&(n.iceServers=hu(n.iceServers,e.version),Ss("ICE servers after filtering:",n.iceServers)),new t(n)},r.RTCPeerConnection.prototype=t.prototype}function za(r){r.RTCRtpSender&&!("replaceTrack"in r.RTCRtpSender.prototype)&&(r.RTCRtpSender.prototype.replaceTrack=r.RTCRtpSender.prototype.setTrack)}const Ba=Object.freeze(Object.defineProperty({__proto__:null,shimGetDisplayMedia:Ia,shimGetUserMedia:Oa,shimPeerConnection:_s,shimReplaceTrack:za},Symbol.toStringTag,{value:"Module"}));function Na(r,e){const t=r&&r.navigator,n=r&&r.MediaStreamTrack;if(t.getUserMedia=function(i,s,a){cr("navigator.getUserMedia","navigator.mediaDevices.getUserMedia"),t.mediaDevices.getUserMedia(i).then(s,a)},!(e.version>55&&"autoGainControl"in t.mediaDevices.getSupportedConstraints())){const i=function(a,o,c){o in a&&!(c in a)&&(a[c]=a[o],delete a[o])},s=t.mediaDevices.getUserMedia.bind(t.mediaDevices);if(Object.getOwnPropertyDescriptor(t.mediaDevices,"getUserMedia")?.writable&&(t.mediaDevices.getUserMedia=function(a){return typeof a=="object"&&typeof a.audio=="object"&&(a=JSON.parse(JSON.stringify(a)),i(a.audio,"autoGainControl","mozAutoGainControl"),i(a.audio,"noiseSuppression","mozNoiseSuppression")),s(a)}),n&&n.prototype.getSettings){const a=n.prototype.getSettings;n.prototype.getSettings=function(){const o=a.apply(this,arguments);return i(o,"mozAutoGainControl","autoGainControl"),i(o,"mozNoiseSuppression","noiseSuppression"),o}}if(n&&n.prototype.applyConstraints){const a=n.prototype.applyConstraints;n.prototype.applyConstraints=function(o){return this.kind==="audio"&&typeof o=="object"&&(o=JSON.parse(JSON.stringify(o)),i(o,"autoGainControl","mozAutoGainControl"),i(o,"noiseSuppression","mozNoiseSuppression")),a.apply(this,[o])}}}}function mu(r,e){r.navigator.mediaDevices&&"getDisplayMedia"in r.navigator.mediaDevices||r.navigator.mediaDevices&&(r.navigator.mediaDevices.getDisplayMedia=function(t){if(!(t&&t.video)){const n=new DOMException("getDisplayMedia without video constraints is undefined");return n.name="NotFoundError",n.code=8,Promise.reject(n)}return t.video===!0?t.video={mediaSource:e}:t.video.mediaSource=e,r.navigator.mediaDevices.getUserMedia(t)})}function Ua(r){typeof r=="object"&&r.RTCTrackEvent&&"receiver"in r.RTCTrackEvent.prototype&&!("transceiver"in r.RTCTrackEvent.prototype)&&Object.defineProperty(r.RTCTrackEvent.prototype,"transceiver",{get(){return{receiver:this.receiver}}})}function Ts(r,e){if(typeof r!="object"||!(r.RTCPeerConnection||r.mozRTCPeerConnection))return;!r.RTCPeerConnection&&r.mozRTCPeerConnection&&(r.RTCPeerConnection=r.mozRTCPeerConnection),e.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach(function(i){const s=r.RTCPeerConnection.prototype[i],a={[i](){return arguments[0]=new(i==="addIceCandidate"?r.RTCIceCandidate:r.RTCSessionDescription)(arguments[0]),s.apply(this,arguments)}};r.RTCPeerConnection.prototype[i]=a[i]});const t={inboundrtp:"inbound-rtp",outboundrtp:"outbound-rtp",candidatepair:"candidate-pair",localcandidate:"local-candidate",remotecandidate:"remote-candidate"},n=r.RTCPeerConnection.prototype.getStats;r.RTCPeerConnection.prototype.getStats=function(){const[i,s,a]=arguments;return n.apply(this,[i||null]).then(o=>{if(e.version<53&&!s)try{o.forEach(c=>{c.type=t[c.type]||c.type})}catch(c){if(c.name!=="TypeError")throw c;o.forEach((l,u)=>{o.set(u,Object.assign({},l,{type:t[l.type]||l.type}))})}return o}).then(s,a)}}function Da(r){if(!(typeof r=="object"&&r.RTCPeerConnection&&r.RTCRtpSender)||r.RTCRtpSender&&"getStats"in r.RTCRtpSender.prototype)return;const e=r.RTCPeerConnection.prototype.getSenders;e&&(r.RTCPeerConnection.prototype.getSenders=function(){const n=e.apply(this,[]);return n.forEach(i=>i._pc=this),n});const t=r.RTCPeerConnection.prototype.addTrack;t&&(r.RTCPeerConnection.prototype.addTrack=function(){const n=t.apply(this,arguments);return n._pc=this,n}),r.RTCRtpSender.prototype.getStats=function(){return this.track?this._pc.getStats(this.track):Promise.resolve(new Map)}}function La(r){if(!(typeof r=="object"&&r.RTCPeerConnection&&r.RTCRtpSender)||r.RTCRtpSender&&"getStats"in r.RTCRtpReceiver.prototype)return;const e=r.RTCPeerConnection.prototype.getReceivers;e&&(r.RTCPeerConnection.prototype.getReceivers=function(){const t=e.apply(this,[]);return t.forEach(n=>n._pc=this),t}),Rn(r,"track",t=>(t.receiver._pc=t.srcElement,t)),r.RTCRtpReceiver.prototype.getStats=function(){return this._pc.getStats(this.track)}}function Fa(r){!r.RTCPeerConnection||"removeStream"in r.RTCPeerConnection.prototype||(r.RTCPeerConnection.prototype.removeStream=function(e){cr("removeStream","removeTrack"),this.getSenders().forEach(t=>{t.track&&e.getTracks().includes(t.track)&&this.removeTrack(t)})})}function Va(r){r.DataChannel&&!r.RTCDataChannel&&(r.RTCDataChannel=r.DataChannel)}function ja(r){if(!(typeof r=="object"&&r.RTCPeerConnection))return;const e=r.RTCPeerConnection.prototype.addTransceiver;e&&(r.RTCPeerConnection.prototype.addTransceiver=function(){this.setParametersPromises=[];const t=arguments[1],n=t&&"sendEncodings"in t;n&&t.sendEncodings.forEach(s=>{if("rid"in s&&!/^[a-z0-9]{0,16}$/i.test(s.rid))throw new TypeError("Invalid RID value provided.");if("scaleResolutionDownBy"in s&&!(parseFloat(s.scaleResolutionDownBy)>=1))throw new RangeError("scale_resolution_down_by must be >= 1.0");if("maxFramerate"in s&&!(parseFloat(s.maxFramerate)>=0))throw new RangeError("max_framerate must be >= 0.0")});const i=e.apply(this,arguments);if(n){const{sender:s}=i,a=s.getParameters();(!("encodings"in a)||a.encodings.length===1&&Object.keys(a.encodings[0]).length===0)&&(a.encodings=t.sendEncodings,s.sendEncodings=t.sendEncodings,this.setParametersPromises.push(s.setParameters(a).then(()=>{delete s.sendEncodings}).catch(()=>{delete s.sendEncodings})))}return i})}function Ja(r){if(!(typeof r=="object"&&r.RTCRtpSender))return;const e=r.RTCRtpSender.prototype.getParameters;e&&(r.RTCRtpSender.prototype.getParameters=function(){const t=e.apply(this,arguments);return"encodings"in t||(t.encodings=[].concat(this.sendEncodings||[{}])),t})}function Ga(r){if(!(typeof r=="object"&&r.RTCPeerConnection))return;const e=r.RTCPeerConnection.prototype.createOffer;r.RTCPeerConnection.prototype.createOffer=function(){return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then(()=>e.apply(this,arguments)).finally(()=>{this.setParametersPromises=[]}):e.apply(this,arguments)}}function Wa(r){if(!(typeof r=="object"&&r.RTCPeerConnection))return;const e=r.RTCPeerConnection.prototype.createAnswer;r.RTCPeerConnection.prototype.createAnswer=function(){return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then(()=>e.apply(this,arguments)).finally(()=>{this.setParametersPromises=[]}):e.apply(this,arguments)}}const Ha=Object.freeze(Object.defineProperty({__proto__:null,shimAddTransceiver:ja,shimCreateAnswer:Wa,shimCreateOffer:Ga,shimGetDisplayMedia:mu,shimGetParameters:Ja,shimGetUserMedia:Na,shimOnTrack:Ua,shimPeerConnection:Ts,shimRTCDataChannel:Va,shimReceiverGetStats:La,shimRemoveStream:Fa,shimSenderGetStats:Da},Symbol.toStringTag,{value:"Module"}));function qa(r){if(!(typeof r!="object"||!r.RTCPeerConnection)){if("getLocalStreams"in r.RTCPeerConnection.prototype||(r.RTCPeerConnection.prototype.getLocalStreams=function(){return this._localStreams||(this._localStreams=[]),this._localStreams}),!("addStream"in r.RTCPeerConnection.prototype)){const e=r.RTCPeerConnection.prototype.addTrack;r.RTCPeerConnection.prototype.addStream=function(t){this._localStreams||(this._localStreams=[]),this._localStreams.includes(t)||this._localStreams.push(t),t.getAudioTracks().forEach(n=>e.call(this,n,t)),t.getVideoTracks().forEach(n=>e.call(this,n,t))},r.RTCPeerConnection.prototype.addTrack=function(t,...n){return n&&n.forEach(i=>{this._localStreams?this._localStreams.includes(i)||this._localStreams.push(i):this._localStreams=[i]}),e.apply(this,arguments)}}"removeStream"in r.RTCPeerConnection.prototype||(r.RTCPeerConnection.prototype.removeStream=function(e){this._localStreams||(this._localStreams=[]);const t=this._localStreams.indexOf(e);if(t===-1)return;this._localStreams.splice(t,1);const n=e.getTracks();this.getSenders().forEach(i=>{n.includes(i.track)&&this.removeTrack(i)})})}}function Xa(r){if(!(typeof r!="object"||!r.RTCPeerConnection)&&("getRemoteStreams"in r.RTCPeerConnection.prototype||(r.RTCPeerConnection.prototype.getRemoteStreams=function(){return this._remoteStreams?this._remoteStreams:[]}),!("onaddstream"in r.RTCPeerConnection.prototype))){Object.defineProperty(r.RTCPeerConnection.prototype,"onaddstream",{get(){return this._onaddstream},set(t){this._onaddstream&&(this.removeEventListener("addstream",this._onaddstream),this.removeEventListener("track",this._onaddstreampoly)),this.addEventListener("addstream",this._onaddstream=t),this.addEventListener("track",this._onaddstreampoly=n=>{n.streams.forEach(i=>{if(this._remoteStreams||(this._remoteStreams=[]),this._remoteStreams.includes(i))return;this._remoteStreams.push(i);const s=new Event("addstream");s.stream=i,this.dispatchEvent(s)})})}});const e=r.RTCPeerConnection.prototype.setRemoteDescription;r.RTCPeerConnection.prototype.setRemoteDescription=function(){const t=this;return this._onaddstreampoly||this.addEventListener("track",this._onaddstreampoly=function(n){n.streams.forEach(i=>{if(t._remoteStreams||(t._remoteStreams=[]),t._remoteStreams.indexOf(i)>=0)return;t._remoteStreams.push(i);const s=new Event("addstream");s.stream=i,t.dispatchEvent(s)})}),e.apply(t,arguments)}}}function Ya(r){if(typeof r!="object"||!r.RTCPeerConnection)return;const e=r.RTCPeerConnection.prototype,t=e.createOffer,n=e.createAnswer,i=e.setLocalDescription,s=e.setRemoteDescription,a=e.addIceCandidate;e.createOffer=function(c,l){const u=arguments.length>=2?arguments[2]:arguments[0],p=t.apply(this,[u]);return l?(p.then(c,l),Promise.resolve()):p},e.createAnswer=function(c,l){const u=arguments.length>=2?arguments[2]:arguments[0],p=n.apply(this,[u]);return l?(p.then(c,l),Promise.resolve()):p};let o=function(c,l,u){const p=i.apply(this,[c]);return u?(p.then(l,u),Promise.resolve()):p};e.setLocalDescription=o,o=function(c,l,u){const p=s.apply(this,[c]);return u?(p.then(l,u),Promise.resolve()):p},e.setRemoteDescription=o,o=function(c,l,u){const p=a.apply(this,[c]);return u?(p.then(l,u),Promise.resolve()):p},e.addIceCandidate=o}function Za(r){const e=r&&r.navigator;if(e.mediaDevices&&e.mediaDevices.getUserMedia){const t=e.mediaDevices,n=t.getUserMedia.bind(t);e.mediaDevices.getUserMedia=i=>n(Ka(i))}!e.getUserMedia&&e.mediaDevices&&e.mediaDevices.getUserMedia&&(e.getUserMedia=function(t,n,i){e.mediaDevices.getUserMedia(t).then(n,i)}.bind(e))}function Ka(r){return r&&r.video!==void 0?Object.assign({},r,{video:ma(r.video)}):r}function Qa(r){if(!r.RTCPeerConnection)return;const e=r.RTCPeerConnection;r.RTCPeerConnection=function(t,n){if(t&&t.iceServers){const i=[];for(let s=0;s<t.iceServers.length;s++){let a=t.iceServers[s];!a.hasOwnProperty("urls")&&a.hasOwnProperty("url")?(cr("RTCIceServer.url","RTCIceServer.urls"),a=JSON.parse(JSON.stringify(a)),a.urls=a.url,delete a.url,i.push(a)):i.push(t.iceServers[s])}t.iceServers=i}return new e(t,n)},r.RTCPeerConnection.prototype=e.prototype,"generateCertificate"in e&&Object.defineProperty(r.RTCPeerConnection,"generateCertificate",{get(){return e.generateCertificate}})}function $a(r){typeof r=="object"&&r.RTCTrackEvent&&"receiver"in r.RTCTrackEvent.prototype&&!("transceiver"in r.RTCTrackEvent.prototype)&&Object.defineProperty(r.RTCTrackEvent.prototype,"transceiver",{get(){return{receiver:this.receiver}}})}function ec(r){const e=r.RTCPeerConnection.prototype.createOffer;r.RTCPeerConnection.prototype.createOffer=function(t){if(t){typeof t.offerToReceiveAudio<"u"&&(t.offerToReceiveAudio=!!t.offerToReceiveAudio);const n=this.getTransceivers().find(s=>s.receiver.track.kind==="audio");t.offerToReceiveAudio===!1&&n?n.direction==="sendrecv"?n.setDirection?n.setDirection("sendonly"):n.direction="sendonly":n.direction==="recvonly"&&(n.setDirection?n.setDirection("inactive"):n.direction="inactive"):t.offerToReceiveAudio===!0&&!n&&this.addTransceiver("audio"),typeof t.offerToReceiveVideo<"u"&&(t.offerToReceiveVideo=!!t.offerToReceiveVideo);const i=this.getTransceivers().find(s=>s.receiver.track.kind==="video");t.offerToReceiveVideo===!1&&i?i.direction==="sendrecv"?i.setDirection?i.setDirection("sendonly"):i.direction="sendonly":i.direction==="recvonly"&&(i.setDirection?i.setDirection("inactive"):i.direction="inactive"):t.offerToReceiveVideo===!0&&!i&&this.addTransceiver("video")}return e.apply(this,arguments)}}function tc(r){typeof r!="object"||r.AudioContext||(r.AudioContext=r.webkitAudioContext)}const nc=Object.freeze(Object.defineProperty({__proto__:null,shimAudioContext:tc,shimCallbacksAPI:Ya,shimConstraints:Ka,shimCreateOfferLegacy:ec,shimGetUserMedia:Za,shimLocalStreamsAPI:qa,shimRTCIceServerUrls:Qa,shimRemoteStreamsAPI:Xa,shimTrackEventTransceiver:$a},Symbol.toStringTag,{value:"Module"}));var yu=Ra();const lr=ar(yu);function ur(r){if(!r.RTCIceCandidate||r.RTCIceCandidate&&"foundation"in r.RTCIceCandidate.prototype)return;const e=r.RTCIceCandidate;r.RTCIceCandidate=function(t){if(typeof t=="object"&&t.candidate&&t.candidate.indexOf("a=")===0&&(t=JSON.parse(JSON.stringify(t)),t.candidate=t.candidate.substr(2)),t.candidate&&t.candidate.length){const n=new e(t),i=lr.parseCandidate(t.candidate),s=Object.assign(n,i);return s.toJSON=function(){return{candidate:s.candidate,sdpMid:s.sdpMid,sdpMLineIndex:s.sdpMLineIndex,usernameFragment:s.usernameFragment}},s}return new e(t)},r.RTCIceCandidate.prototype=e.prototype,Rn(r,"icecandidate",t=>(t.candidate&&Object.defineProperty(t,"candidate",{value:new r.RTCIceCandidate(t.candidate),writable:"false"}),t))}function Kn(r,e){if(!r.RTCPeerConnection)return;"sctp"in r.RTCPeerConnection.prototype||Object.defineProperty(r.RTCPeerConnection.prototype,"sctp",{get(){return typeof this._sctp>"u"?null:this._sctp}});const t=function(o){if(!o||!o.sdp)return!1;const c=lr.splitSections(o.sdp);return c.shift(),c.some(l=>{const u=lr.parseMLine(l);return u&&u.kind==="application"&&u.protocol.indexOf("SCTP")!==-1})},n=function(o){const c=o.sdp.match(/mozilla...THIS_IS_SDPARTA-(\d+)/);if(c===null||c.length<2)return-1;const l=parseInt(c[1],10);return l!==l?-1:l},i=function(o){let c=65536;return e.browser==="firefox"&&(e.version<57?o===-1?c=16384:c=2147483637:e.version<60?c=e.version===57?65535:65536:c=2147483637),c},s=function(o,c){let l=65536;e.browser==="firefox"&&e.version===57&&(l=65535);const u=lr.matchPrefix(o.sdp,"a=max-message-size:");return u.length>0?l=parseInt(u[0].substr(19),10):e.browser==="firefox"&&c!==-1&&(l=2147483637),l},a=r.RTCPeerConnection.prototype.setRemoteDescription;r.RTCPeerConnection.prototype.setRemoteDescription=function(){if(this._sctp=null,e.browser==="chrome"&&e.version>=76){const{sdpSemantics:o}=this.getConfiguration();o==="plan-b"&&Object.defineProperty(this,"sctp",{get(){return typeof this._sctp>"u"?null:this._sctp},enumerable:!0,configurable:!0})}if(t(arguments[0])){const o=n(arguments[0]),c=i(o),l=s(arguments[0],o);let u;c===0&&l===0?u=Number.POSITIVE_INFINITY:c===0||l===0?u=Math.max(c,l):u=Math.min(c,l);const p={};Object.defineProperty(p,"maxMessageSize",{get(){return u}}),this._sctp=p}return a.apply(this,arguments)}}function Qn(r){if(!(r.RTCPeerConnection&&"createDataChannel"in r.RTCPeerConnection.prototype))return;function e(n,i){const s=n.send;n.send=function(){const a=arguments[0],o=a.length||a.size||a.byteLength;if(n.readyState==="open"&&i.sctp&&o>i.sctp.maxMessageSize)throw new TypeError("Message too large (can send a maximum of "+i.sctp.maxMessageSize+" bytes)");return s.apply(n,arguments)}}const t=r.RTCPeerConnection.prototype.createDataChannel;r.RTCPeerConnection.prototype.createDataChannel=function(){const n=t.apply(this,arguments);return e(n,this),n},Rn(r,"datachannel",n=>(e(n.channel,n.target),n))}function Ms(r){if(!r.RTCPeerConnection||"connectionState"in r.RTCPeerConnection.prototype)return;const e=r.RTCPeerConnection.prototype;Object.defineProperty(e,"connectionState",{get(){return{completed:"connected",checking:"connecting"}[this.iceConnectionState]||this.iceConnectionState},enumerable:!0,configurable:!0}),Object.defineProperty(e,"onconnectionstatechange",{get(){return this._onconnectionstatechange||null},set(t){this._onconnectionstatechange&&(this.removeEventListener("connectionstatechange",this._onconnectionstatechange),delete this._onconnectionstatechange),t&&this.addEventListener("connectionstatechange",this._onconnectionstatechange=t)},enumerable:!0,configurable:!0}),["setLocalDescription","setRemoteDescription"].forEach(t=>{const n=e[t];e[t]=function(){return this._connectionstatechangepoly||(this._connectionstatechangepoly=i=>{const s=i.target;if(s._lastConnectionState!==s.connectionState){s._lastConnectionState=s.connectionState;const a=new Event("connectionstatechange",i);s.dispatchEvent(a)}return i},this.addEventListener("iceconnectionstatechange",this._connectionstatechangepoly)),n.apply(this,arguments)}})}function Cs(r,e){if(!r.RTCPeerConnection||e.browser==="chrome"&&e.version>=71||e.browser==="safari"&&e.version>=605)return;const t=r.RTCPeerConnection.prototype.setRemoteDescription;r.RTCPeerConnection.prototype.setRemoteDescription=function(n){if(n&&n.sdp&&n.sdp.indexOf(`
|
|
69
|
+
`,v._remoteDescription.sdp=r.getDescription(v._remoteDescription.sdp)+_.join("")}else return C(o("OperationError","Can not add ICE candidate"))}else return C(o("InvalidStateError","Can not add ICE candidate without a remote description"));w()})},m.prototype.getStats=function(g){if(g&&g instanceof c.MediaStreamTrack){var v=null;if(this.transceivers.forEach(function(w){w.rtpSender&&w.rtpSender.track===g?v=w.rtpSender:w.rtpReceiver&&w.rtpReceiver.track===g&&(v=w.rtpReceiver)}),!v)throw o("InvalidAccessError","Invalid selector.");return v.getStats()}var _=[];return this.transceivers.forEach(function(w){["rtpSender","rtpReceiver","iceGatherer","iceTransport","dtlsTransport"].forEach(function(C){w[C]&&_.push(w[C].getStats())})}),Promise.all(_).then(function(w){var C=new Map;return w.forEach(function(M){M.forEach(function(E){C.set(E.id,E)})}),C})};var b=["RTCRtpSender","RTCRtpReceiver","RTCIceGatherer","RTCIceTransport","RTCDtlsTransport"];b.forEach(function(g){var v=c[g];if(v&&v.prototype&&v.prototype.getStats){var _=v.prototype.getStats;v.prototype.getStats=function(){return _.apply(this).then(function(w){var C=new Map;return Object.keys(w).forEach(function(M){w[M].type=e(w[M]),C.set(M,w[M])}),C})}}});var x=["createOffer","createAnswer"];return x.forEach(function(g){var v=m.prototype[g];m.prototype[g]=function(){var _=arguments;return typeof _[0]=="function"||typeof _[1]=="function"?v.apply(this,[arguments[2]]).then(function(w){typeof _[0]=="function"&&_[0].apply(null,[w])},function(w){typeof _[1]=="function"&&_[1].apply(null,[w])}):v.apply(this,arguments)}}),x=["setLocalDescription","setRemoteDescription","addIceCandidate"],x.forEach(function(g){var v=m.prototype[g];m.prototype[g]=function(){var _=arguments;return typeof _[1]=="function"||typeof _[2]=="function"?v.apply(this,arguments).then(function(){typeof _[1]=="function"&&_[1].apply(null)},function(w){typeof _[2]=="function"&&_[2].apply(null,[w])}):v.apply(this,arguments)}}),["getStats"].forEach(function(g){var v=m.prototype[g];m.prototype[g]=function(){var _=arguments;return typeof _[1]=="function"?v.apply(this,arguments).then(function(){typeof _[1]=="function"&&_[1].apply(null)}):v.apply(this,arguments)}}),m},ws}var fu=pu();const mu=ar(fu);function Oa(r){const e=r&&r.navigator,t=function(i){return{name:{PermissionDeniedError:"NotAllowedError"}[i.name]||i.name,message:i.message,constraint:i.constraint,toString(){return this.name}}},n=e.mediaDevices.getUserMedia.bind(e.mediaDevices);Object.getOwnPropertyDescriptor(e.mediaDevices,"getUserMedia")?.writable&&(e.mediaDevices.getUserMedia=function(i){return n(i).catch(s=>Promise.reject(t(s)))})}function Ia(r){"getDisplayMedia"in r.navigator&&r.navigator.mediaDevices&&(r.navigator.mediaDevices&&"getDisplayMedia"in r.navigator.mediaDevices||(r.navigator.mediaDevices.getDisplayMedia=r.navigator.getDisplayMedia.bind(r.navigator)))}function _s(r,e){if(r.RTCIceGatherer&&(r.RTCIceCandidate||(r.RTCIceCandidate=function(n){return n}),r.RTCSessionDescription||(r.RTCSessionDescription=function(n){return n}),e.version<15025)){const n=Object.getOwnPropertyDescriptor(r.MediaStreamTrack.prototype,"enabled");Object.defineProperty(r.MediaStreamTrack.prototype,"enabled",{set(i){n.set.call(this,i);const s=new Event("enabled");s.enabled=i,this.dispatchEvent(s)}})}r.RTCRtpSender&&!("dtmf"in r.RTCRtpSender.prototype)&&Object.defineProperty(r.RTCRtpSender.prototype,"dtmf",{get(){return this._dtmf===void 0&&(this.track.kind==="audio"?this._dtmf=new r.RTCDtmfSender(this):this.track.kind==="video"&&(this._dtmf=null)),this._dtmf}}),r.RTCDtmfSender&&!r.RTCDTMFSender&&(r.RTCDTMFSender=r.RTCDtmfSender);const t=mu(r,e.version);r.RTCPeerConnection=function(n){return n&&n.iceServers&&(n.iceServers=du(n.iceServers,e.version),Ss("ICE servers after filtering:",n.iceServers)),new t(n)},r.RTCPeerConnection.prototype=t.prototype}function za(r){r.RTCRtpSender&&!("replaceTrack"in r.RTCRtpSender.prototype)&&(r.RTCRtpSender.prototype.replaceTrack=r.RTCRtpSender.prototype.setTrack)}const Ba=Object.freeze(Object.defineProperty({__proto__:null,shimGetDisplayMedia:Ia,shimGetUserMedia:Oa,shimPeerConnection:_s,shimReplaceTrack:za},Symbol.toStringTag,{value:"Module"}));function Na(r,e){const t=r&&r.navigator,n=r&&r.MediaStreamTrack;if(t.getUserMedia=function(i,s,a){cr("navigator.getUserMedia","navigator.mediaDevices.getUserMedia"),t.mediaDevices.getUserMedia(i).then(s,a)},!(e.version>55&&"autoGainControl"in t.mediaDevices.getSupportedConstraints())){const i=function(a,o,c){o in a&&!(c in a)&&(a[c]=a[o],delete a[o])},s=t.mediaDevices.getUserMedia.bind(t.mediaDevices);if(Object.getOwnPropertyDescriptor(t.mediaDevices,"getUserMedia")?.writable&&(t.mediaDevices.getUserMedia=function(a){return typeof a=="object"&&typeof a.audio=="object"&&(a=JSON.parse(JSON.stringify(a)),i(a.audio,"autoGainControl","mozAutoGainControl"),i(a.audio,"noiseSuppression","mozNoiseSuppression")),s(a)}),n&&n.prototype.getSettings){const a=n.prototype.getSettings;n.prototype.getSettings=function(){const o=a.apply(this,arguments);return i(o,"mozAutoGainControl","autoGainControl"),i(o,"mozNoiseSuppression","noiseSuppression"),o}}if(n&&n.prototype.applyConstraints){const a=n.prototype.applyConstraints;n.prototype.applyConstraints=function(o){return this.kind==="audio"&&typeof o=="object"&&(o=JSON.parse(JSON.stringify(o)),i(o,"autoGainControl","mozAutoGainControl"),i(o,"noiseSuppression","mozNoiseSuppression")),a.apply(this,[o])}}}}function yu(r,e){r.navigator.mediaDevices&&"getDisplayMedia"in r.navigator.mediaDevices||r.navigator.mediaDevices&&(r.navigator.mediaDevices.getDisplayMedia=function(t){if(!(t&&t.video)){const n=new DOMException("getDisplayMedia without video constraints is undefined");return n.name="NotFoundError",n.code=8,Promise.reject(n)}return t.video===!0?t.video={mediaSource:e}:t.video.mediaSource=e,r.navigator.mediaDevices.getUserMedia(t)})}function Ua(r){typeof r=="object"&&r.RTCTrackEvent&&"receiver"in r.RTCTrackEvent.prototype&&!("transceiver"in r.RTCTrackEvent.prototype)&&Object.defineProperty(r.RTCTrackEvent.prototype,"transceiver",{get(){return{receiver:this.receiver}}})}function Ts(r,e){if(typeof r!="object"||!(r.RTCPeerConnection||r.mozRTCPeerConnection))return;!r.RTCPeerConnection&&r.mozRTCPeerConnection&&(r.RTCPeerConnection=r.mozRTCPeerConnection),e.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach(function(i){const s=r.RTCPeerConnection.prototype[i],a={[i](){return arguments[0]=new(i==="addIceCandidate"?r.RTCIceCandidate:r.RTCSessionDescription)(arguments[0]),s.apply(this,arguments)}};r.RTCPeerConnection.prototype[i]=a[i]});const t={inboundrtp:"inbound-rtp",outboundrtp:"outbound-rtp",candidatepair:"candidate-pair",localcandidate:"local-candidate",remotecandidate:"remote-candidate"},n=r.RTCPeerConnection.prototype.getStats;r.RTCPeerConnection.prototype.getStats=function(){const[i,s,a]=arguments;return n.apply(this,[i||null]).then(o=>{if(e.version<53&&!s)try{o.forEach(c=>{c.type=t[c.type]||c.type})}catch(c){if(c.name!=="TypeError")throw c;o.forEach((l,u)=>{o.set(u,Object.assign({},l,{type:t[l.type]||l.type}))})}return o}).then(s,a)}}function Da(r){if(!(typeof r=="object"&&r.RTCPeerConnection&&r.RTCRtpSender)||r.RTCRtpSender&&"getStats"in r.RTCRtpSender.prototype)return;const e=r.RTCPeerConnection.prototype.getSenders;e&&(r.RTCPeerConnection.prototype.getSenders=function(){const n=e.apply(this,[]);return n.forEach(i=>i._pc=this),n});const t=r.RTCPeerConnection.prototype.addTrack;t&&(r.RTCPeerConnection.prototype.addTrack=function(){const n=t.apply(this,arguments);return n._pc=this,n}),r.RTCRtpSender.prototype.getStats=function(){return this.track?this._pc.getStats(this.track):Promise.resolve(new Map)}}function La(r){if(!(typeof r=="object"&&r.RTCPeerConnection&&r.RTCRtpSender)||r.RTCRtpSender&&"getStats"in r.RTCRtpReceiver.prototype)return;const e=r.RTCPeerConnection.prototype.getReceivers;e&&(r.RTCPeerConnection.prototype.getReceivers=function(){const t=e.apply(this,[]);return t.forEach(n=>n._pc=this),t}),Rn(r,"track",t=>(t.receiver._pc=t.srcElement,t)),r.RTCRtpReceiver.prototype.getStats=function(){return this._pc.getStats(this.track)}}function Fa(r){!r.RTCPeerConnection||"removeStream"in r.RTCPeerConnection.prototype||(r.RTCPeerConnection.prototype.removeStream=function(e){cr("removeStream","removeTrack"),this.getSenders().forEach(t=>{t.track&&e.getTracks().includes(t.track)&&this.removeTrack(t)})})}function Va(r){r.DataChannel&&!r.RTCDataChannel&&(r.RTCDataChannel=r.DataChannel)}function ja(r){if(!(typeof r=="object"&&r.RTCPeerConnection))return;const e=r.RTCPeerConnection.prototype.addTransceiver;e&&(r.RTCPeerConnection.prototype.addTransceiver=function(){this.setParametersPromises=[];const t=arguments[1],n=t&&"sendEncodings"in t;n&&t.sendEncodings.forEach(s=>{if("rid"in s&&!/^[a-z0-9]{0,16}$/i.test(s.rid))throw new TypeError("Invalid RID value provided.");if("scaleResolutionDownBy"in s&&!(parseFloat(s.scaleResolutionDownBy)>=1))throw new RangeError("scale_resolution_down_by must be >= 1.0");if("maxFramerate"in s&&!(parseFloat(s.maxFramerate)>=0))throw new RangeError("max_framerate must be >= 0.0")});const i=e.apply(this,arguments);if(n){const{sender:s}=i,a=s.getParameters();(!("encodings"in a)||a.encodings.length===1&&Object.keys(a.encodings[0]).length===0)&&(a.encodings=t.sendEncodings,s.sendEncodings=t.sendEncodings,this.setParametersPromises.push(s.setParameters(a).then(()=>{delete s.sendEncodings}).catch(()=>{delete s.sendEncodings})))}return i})}function Ja(r){if(!(typeof r=="object"&&r.RTCRtpSender))return;const e=r.RTCRtpSender.prototype.getParameters;e&&(r.RTCRtpSender.prototype.getParameters=function(){const t=e.apply(this,arguments);return"encodings"in t||(t.encodings=[].concat(this.sendEncodings||[{}])),t})}function Ga(r){if(!(typeof r=="object"&&r.RTCPeerConnection))return;const e=r.RTCPeerConnection.prototype.createOffer;r.RTCPeerConnection.prototype.createOffer=function(){return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then(()=>e.apply(this,arguments)).finally(()=>{this.setParametersPromises=[]}):e.apply(this,arguments)}}function Wa(r){if(!(typeof r=="object"&&r.RTCPeerConnection))return;const e=r.RTCPeerConnection.prototype.createAnswer;r.RTCPeerConnection.prototype.createAnswer=function(){return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then(()=>e.apply(this,arguments)).finally(()=>{this.setParametersPromises=[]}):e.apply(this,arguments)}}const Ha=Object.freeze(Object.defineProperty({__proto__:null,shimAddTransceiver:ja,shimCreateAnswer:Wa,shimCreateOffer:Ga,shimGetDisplayMedia:yu,shimGetParameters:Ja,shimGetUserMedia:Na,shimOnTrack:Ua,shimPeerConnection:Ts,shimRTCDataChannel:Va,shimReceiverGetStats:La,shimRemoveStream:Fa,shimSenderGetStats:Da},Symbol.toStringTag,{value:"Module"}));function qa(r){if(!(typeof r!="object"||!r.RTCPeerConnection)){if("getLocalStreams"in r.RTCPeerConnection.prototype||(r.RTCPeerConnection.prototype.getLocalStreams=function(){return this._localStreams||(this._localStreams=[]),this._localStreams}),!("addStream"in r.RTCPeerConnection.prototype)){const e=r.RTCPeerConnection.prototype.addTrack;r.RTCPeerConnection.prototype.addStream=function(t){this._localStreams||(this._localStreams=[]),this._localStreams.includes(t)||this._localStreams.push(t),t.getAudioTracks().forEach(n=>e.call(this,n,t)),t.getVideoTracks().forEach(n=>e.call(this,n,t))},r.RTCPeerConnection.prototype.addTrack=function(t,...n){return n&&n.forEach(i=>{this._localStreams?this._localStreams.includes(i)||this._localStreams.push(i):this._localStreams=[i]}),e.apply(this,arguments)}}"removeStream"in r.RTCPeerConnection.prototype||(r.RTCPeerConnection.prototype.removeStream=function(e){this._localStreams||(this._localStreams=[]);const t=this._localStreams.indexOf(e);if(t===-1)return;this._localStreams.splice(t,1);const n=e.getTracks();this.getSenders().forEach(i=>{n.includes(i.track)&&this.removeTrack(i)})})}}function Xa(r){if(!(typeof r!="object"||!r.RTCPeerConnection)&&("getRemoteStreams"in r.RTCPeerConnection.prototype||(r.RTCPeerConnection.prototype.getRemoteStreams=function(){return this._remoteStreams?this._remoteStreams:[]}),!("onaddstream"in r.RTCPeerConnection.prototype))){Object.defineProperty(r.RTCPeerConnection.prototype,"onaddstream",{get(){return this._onaddstream},set(t){this._onaddstream&&(this.removeEventListener("addstream",this._onaddstream),this.removeEventListener("track",this._onaddstreampoly)),this.addEventListener("addstream",this._onaddstream=t),this.addEventListener("track",this._onaddstreampoly=n=>{n.streams.forEach(i=>{if(this._remoteStreams||(this._remoteStreams=[]),this._remoteStreams.includes(i))return;this._remoteStreams.push(i);const s=new Event("addstream");s.stream=i,this.dispatchEvent(s)})})}});const e=r.RTCPeerConnection.prototype.setRemoteDescription;r.RTCPeerConnection.prototype.setRemoteDescription=function(){const t=this;return this._onaddstreampoly||this.addEventListener("track",this._onaddstreampoly=function(n){n.streams.forEach(i=>{if(t._remoteStreams||(t._remoteStreams=[]),t._remoteStreams.indexOf(i)>=0)return;t._remoteStreams.push(i);const s=new Event("addstream");s.stream=i,t.dispatchEvent(s)})}),e.apply(t,arguments)}}}function Ya(r){if(typeof r!="object"||!r.RTCPeerConnection)return;const e=r.RTCPeerConnection.prototype,t=e.createOffer,n=e.createAnswer,i=e.setLocalDescription,s=e.setRemoteDescription,a=e.addIceCandidate;e.createOffer=function(c,l){const u=arguments.length>=2?arguments[2]:arguments[0],p=t.apply(this,[u]);return l?(p.then(c,l),Promise.resolve()):p},e.createAnswer=function(c,l){const u=arguments.length>=2?arguments[2]:arguments[0],p=n.apply(this,[u]);return l?(p.then(c,l),Promise.resolve()):p};let o=function(c,l,u){const p=i.apply(this,[c]);return u?(p.then(l,u),Promise.resolve()):p};e.setLocalDescription=o,o=function(c,l,u){const p=s.apply(this,[c]);return u?(p.then(l,u),Promise.resolve()):p},e.setRemoteDescription=o,o=function(c,l,u){const p=a.apply(this,[c]);return u?(p.then(l,u),Promise.resolve()):p},e.addIceCandidate=o}function Za(r){const e=r&&r.navigator;if(e.mediaDevices&&e.mediaDevices.getUserMedia){const t=e.mediaDevices,n=t.getUserMedia.bind(t);e.mediaDevices.getUserMedia=i=>n(Ka(i))}!e.getUserMedia&&e.mediaDevices&&e.mediaDevices.getUserMedia&&(e.getUserMedia=function(t,n,i){e.mediaDevices.getUserMedia(t).then(n,i)}.bind(e))}function Ka(r){return r&&r.video!==void 0?Object.assign({},r,{video:ma(r.video)}):r}function Qa(r){if(!r.RTCPeerConnection)return;const e=r.RTCPeerConnection;r.RTCPeerConnection=function(t,n){if(t&&t.iceServers){const i=[];for(let s=0;s<t.iceServers.length;s++){let a=t.iceServers[s];!a.hasOwnProperty("urls")&&a.hasOwnProperty("url")?(cr("RTCIceServer.url","RTCIceServer.urls"),a=JSON.parse(JSON.stringify(a)),a.urls=a.url,delete a.url,i.push(a)):i.push(t.iceServers[s])}t.iceServers=i}return new e(t,n)},r.RTCPeerConnection.prototype=e.prototype,"generateCertificate"in e&&Object.defineProperty(r.RTCPeerConnection,"generateCertificate",{get(){return e.generateCertificate}})}function $a(r){typeof r=="object"&&r.RTCTrackEvent&&"receiver"in r.RTCTrackEvent.prototype&&!("transceiver"in r.RTCTrackEvent.prototype)&&Object.defineProperty(r.RTCTrackEvent.prototype,"transceiver",{get(){return{receiver:this.receiver}}})}function ec(r){const e=r.RTCPeerConnection.prototype.createOffer;r.RTCPeerConnection.prototype.createOffer=function(t){if(t){typeof t.offerToReceiveAudio<"u"&&(t.offerToReceiveAudio=!!t.offerToReceiveAudio);const n=this.getTransceivers().find(s=>s.receiver.track.kind==="audio");t.offerToReceiveAudio===!1&&n?n.direction==="sendrecv"?n.setDirection?n.setDirection("sendonly"):n.direction="sendonly":n.direction==="recvonly"&&(n.setDirection?n.setDirection("inactive"):n.direction="inactive"):t.offerToReceiveAudio===!0&&!n&&this.addTransceiver("audio"),typeof t.offerToReceiveVideo<"u"&&(t.offerToReceiveVideo=!!t.offerToReceiveVideo);const i=this.getTransceivers().find(s=>s.receiver.track.kind==="video");t.offerToReceiveVideo===!1&&i?i.direction==="sendrecv"?i.setDirection?i.setDirection("sendonly"):i.direction="sendonly":i.direction==="recvonly"&&(i.setDirection?i.setDirection("inactive"):i.direction="inactive"):t.offerToReceiveVideo===!0&&!i&&this.addTransceiver("video")}return e.apply(this,arguments)}}function tc(r){typeof r!="object"||r.AudioContext||(r.AudioContext=r.webkitAudioContext)}const nc=Object.freeze(Object.defineProperty({__proto__:null,shimAudioContext:tc,shimCallbacksAPI:Ya,shimConstraints:Ka,shimCreateOfferLegacy:ec,shimGetUserMedia:Za,shimLocalStreamsAPI:qa,shimRTCIceServerUrls:Qa,shimRemoteStreamsAPI:Xa,shimTrackEventTransceiver:$a},Symbol.toStringTag,{value:"Module"}));var gu=Ra();const lr=ar(gu);function ur(r){if(!r.RTCIceCandidate||r.RTCIceCandidate&&"foundation"in r.RTCIceCandidate.prototype)return;const e=r.RTCIceCandidate;r.RTCIceCandidate=function(t){if(typeof t=="object"&&t.candidate&&t.candidate.indexOf("a=")===0&&(t=JSON.parse(JSON.stringify(t)),t.candidate=t.candidate.substr(2)),t.candidate&&t.candidate.length){const n=new e(t),i=lr.parseCandidate(t.candidate),s=Object.assign(n,i);return s.toJSON=function(){return{candidate:s.candidate,sdpMid:s.sdpMid,sdpMLineIndex:s.sdpMLineIndex,usernameFragment:s.usernameFragment}},s}return new e(t)},r.RTCIceCandidate.prototype=e.prototype,Rn(r,"icecandidate",t=>(t.candidate&&Object.defineProperty(t,"candidate",{value:new r.RTCIceCandidate(t.candidate),writable:"false"}),t))}function Kn(r,e){if(!r.RTCPeerConnection)return;"sctp"in r.RTCPeerConnection.prototype||Object.defineProperty(r.RTCPeerConnection.prototype,"sctp",{get(){return typeof this._sctp>"u"?null:this._sctp}});const t=function(o){if(!o||!o.sdp)return!1;const c=lr.splitSections(o.sdp);return c.shift(),c.some(l=>{const u=lr.parseMLine(l);return u&&u.kind==="application"&&u.protocol.indexOf("SCTP")!==-1})},n=function(o){const c=o.sdp.match(/mozilla...THIS_IS_SDPARTA-(\d+)/);if(c===null||c.length<2)return-1;const l=parseInt(c[1],10);return l!==l?-1:l},i=function(o){let c=65536;return e.browser==="firefox"&&(e.version<57?o===-1?c=16384:c=2147483637:e.version<60?c=e.version===57?65535:65536:c=2147483637),c},s=function(o,c){let l=65536;e.browser==="firefox"&&e.version===57&&(l=65535);const u=lr.matchPrefix(o.sdp,"a=max-message-size:");return u.length>0?l=parseInt(u[0].substr(19),10):e.browser==="firefox"&&c!==-1&&(l=2147483637),l},a=r.RTCPeerConnection.prototype.setRemoteDescription;r.RTCPeerConnection.prototype.setRemoteDescription=function(){if(this._sctp=null,e.browser==="chrome"&&e.version>=76){const{sdpSemantics:o}=this.getConfiguration();o==="plan-b"&&Object.defineProperty(this,"sctp",{get(){return typeof this._sctp>"u"?null:this._sctp},enumerable:!0,configurable:!0})}if(t(arguments[0])){const o=n(arguments[0]),c=i(o),l=s(arguments[0],o);let u;c===0&&l===0?u=Number.POSITIVE_INFINITY:c===0||l===0?u=Math.max(c,l):u=Math.min(c,l);const p={};Object.defineProperty(p,"maxMessageSize",{get(){return u}}),this._sctp=p}return a.apply(this,arguments)}}function Qn(r){if(!(r.RTCPeerConnection&&"createDataChannel"in r.RTCPeerConnection.prototype))return;function e(n,i){const s=n.send;n.send=function(){const a=arguments[0],o=a.length||a.size||a.byteLength;if(n.readyState==="open"&&i.sctp&&o>i.sctp.maxMessageSize)throw new TypeError("Message too large (can send a maximum of "+i.sctp.maxMessageSize+" bytes)");return s.apply(n,arguments)}}const t=r.RTCPeerConnection.prototype.createDataChannel;r.RTCPeerConnection.prototype.createDataChannel=function(){const n=t.apply(this,arguments);return e(n,this),n},Rn(r,"datachannel",n=>(e(n.channel,n.target),n))}function Ms(r){if(!r.RTCPeerConnection||"connectionState"in r.RTCPeerConnection.prototype)return;const e=r.RTCPeerConnection.prototype;Object.defineProperty(e,"connectionState",{get(){return{completed:"connected",checking:"connecting"}[this.iceConnectionState]||this.iceConnectionState},enumerable:!0,configurable:!0}),Object.defineProperty(e,"onconnectionstatechange",{get(){return this._onconnectionstatechange||null},set(t){this._onconnectionstatechange&&(this.removeEventListener("connectionstatechange",this._onconnectionstatechange),delete this._onconnectionstatechange),t&&this.addEventListener("connectionstatechange",this._onconnectionstatechange=t)},enumerable:!0,configurable:!0}),["setLocalDescription","setRemoteDescription"].forEach(t=>{const n=e[t];e[t]=function(){return this._connectionstatechangepoly||(this._connectionstatechangepoly=i=>{const s=i.target;if(s._lastConnectionState!==s.connectionState){s._lastConnectionState=s.connectionState;const a=new Event("connectionstatechange",i);s.dispatchEvent(a)}return i},this.addEventListener("iceconnectionstatechange",this._connectionstatechangepoly)),n.apply(this,arguments)}})}function Cs(r,e){if(!r.RTCPeerConnection||e.browser==="chrome"&&e.version>=71||e.browser==="safari"&&e.version>=605)return;const t=r.RTCPeerConnection.prototype.setRemoteDescription;r.RTCPeerConnection.prototype.setRemoteDescription=function(n){if(n&&n.sdp&&n.sdp.indexOf(`
|
|
70
70
|
a=extmap-allow-mixed`)!==-1){const i=n.sdp.split(`
|
|
71
71
|
`).filter(s=>s.trim()!=="a=extmap-allow-mixed").join(`
|
|
72
|
-
`);r.RTCSessionDescription&&n instanceof r.RTCSessionDescription?arguments[0]=new r.RTCSessionDescription({type:n.type,sdp:i}):n.sdp=i}return t.apply(this,arguments)}}function hr(r,e){if(!(r.RTCPeerConnection&&r.RTCPeerConnection.prototype))return;const t=r.RTCPeerConnection.prototype.addIceCandidate;!t||t.length===0||(r.RTCPeerConnection.prototype.addIceCandidate=function(){return arguments[0]?(e.browser==="chrome"&&e.version<78||e.browser==="firefox"&&e.version<68||e.browser==="safari")&&arguments[0]&&arguments[0].candidate===""?Promise.resolve():t.apply(this,arguments):(arguments[1]&&arguments[1].apply(null),Promise.resolve())})}const
|
|
72
|
+
`);r.RTCSessionDescription&&n instanceof r.RTCSessionDescription?arguments[0]=new r.RTCSessionDescription({type:n.type,sdp:i}):n.sdp=i}return t.apply(this,arguments)}}function hr(r,e){if(!(r.RTCPeerConnection&&r.RTCPeerConnection.prototype))return;const t=r.RTCPeerConnection.prototype.addIceCandidate;!t||t.length===0||(r.RTCPeerConnection.prototype.addIceCandidate=function(){return arguments[0]?(e.browser==="chrome"&&e.version<78||e.browser==="firefox"&&e.version<68||e.browser==="safari")&&arguments[0]&&arguments[0].candidate===""?Promise.resolve():t.apply(this,arguments):(arguments[1]&&arguments[1].apply(null),Promise.resolve())})}const vu=Object.freeze(Object.defineProperty({__proto__:null,removeExtmapAllowMixed:Cs,shimAddIceCandidateNullOrEmpty:hr,shimConnectionState:Ms,shimMaxMessageSize:Kn,shimRTCIceCandidate:ur,shimSendThrowTypeError:Qn},Symbol.toStringTag,{value:"Module"}));function Su({window:r}={},e={shimChrome:!0,shimFirefox:!0,shimEdge:!0,shimSafari:!0}){const t=Ss,n=uu(r),i={browserDetails:n,commonShim:vu,extractVersion:Zn,disableLog:cu,disableWarnings:lu};switch(n.browser){case"chrome":if(!Ea||!xs||!e.shimChrome)return t("Chrome shim is not included in this adapter release."),i;if(n.version===null)return t("Chrome shim can not determine version, not shimming."),i;t("adapter.js shimming chrome."),i.browserShim=Ea,hr(r,n),va(r,n),Sa(r),xs(r,n),ba(r),Ma(r,n),xa(r),wa(r),_a(r),Ca(r,n),ur(r),Ms(r),Kn(r,n),Qn(r),Cs(r,n);break;case"firefox":if(!Ha||!Ts||!e.shimFirefox)return t("Firefox shim is not included in this adapter release."),i;t("adapter.js shimming firefox."),i.browserShim=Ha,hr(r,n),Na(r,n),Ts(r,n),Ua(r),Fa(r),Da(r),La(r),Va(r),ja(r),Ja(r),Ga(r),Wa(r),ur(r),Ms(r),Kn(r,n),Qn(r);break;case"edge":if(!Ba||!_s||!e.shimEdge)return t("MS edge shim is not included in this adapter release."),i;t("adapter.js shimming edge."),i.browserShim=Ba,Oa(r),Ia(r),_s(r,n),za(r),Kn(r,n),Qn(r);break;case"safari":if(!nc||!e.shimSafari)return t("Safari shim is not included in this adapter release."),i;t("adapter.js shimming safari."),i.browserShim=nc,hr(r,n),Qa(r),ec(r),Ya(r),qa(r),Xa(r),$a(r),Za(r),tc(r),ur(r),Kn(r,n),Qn(r),Cs(r,n);break;default:t("Unsupported browser!");break}return i}const ic=Su({window:typeof window>"u"?void 0:window});function zt(r,e,t,n){Object.defineProperty(r,e,{get:t,set:n,enumerable:!0,configurable:!0})}var Es=ic.default||ic,$n=new(function(){function r(){this.isIOS=["iPad","iPhone","iPod"].includes(navigator.platform),this.supportedBrowsers=["firefox","chrome","safari"],this.minFirefoxVersion=59,this.minChromeVersion=72,this.minSafariVersion=605}return r.prototype.isWebRTCSupported=function(){return typeof RTCPeerConnection<"u"},r.prototype.isBrowserSupported=function(){var e=this.getBrowser(),t=this.getVersion(),n=this.supportedBrowsers.includes(e);return n?e==="chrome"?t>=this.minChromeVersion:e==="firefox"?t>=this.minFirefoxVersion:e==="safari"?!this.isIOS&&t>=this.minSafariVersion:!1:!1},r.prototype.getBrowser=function(){return Es.browserDetails.browser},r.prototype.getVersion=function(){return Es.browserDetails.version||0},r.prototype.isUnifiedPlanSupported=function(){var e=this.getBrowser(),t=Es.browserDetails.version||0;if(e==="chrome"&&t<this.minChromeVersion)return!1;if(e==="firefox"&&t>=this.minFirefoxVersion)return!0;if(!window.RTCRtpTransceiver||!("currentDirection"in RTCRtpTransceiver.prototype))return!1;var n,i=!1;try{n=new RTCPeerConnection,n.addTransceiver("audio"),i=!0}catch{}finally{n&&n.close()}return i},r.prototype.toString=function(){return`Supports:
|
|
73
73
|
browser:`.concat(this.getBrowser(),`
|
|
74
74
|
version:`).concat(this.getVersion(),`
|
|
75
75
|
isIOS:`).concat(this.isIOS,`
|
|
76
76
|
isWebRTCSupported:`).concat(this.isWebRTCSupported(),`
|
|
77
77
|
isBrowserSupported:`).concat(this.isBrowserSupported(),`
|
|
78
|
-
isUnifiedPlanSupported:`).concat(this.isUnifiedPlanSupported())},r}()),rc={iceServers:[{urls:"stun:stun.l.google.com:19302"},{urls:["turn:eu-0.turn.peerjs.com:3478","turn:us-0.turn.peerjs.com:3478"],username:"peerjs",credential:"peerjsp"}],sdpSemantics:"unified-plan"},Su=function(){function r(){this.CLOUD_HOST="0.peerjs.com",this.CLOUD_PORT=443,this.chunkedBrowsers={Chrome:1,chrome:1},this.chunkedMTU=16300,this.defaultConfig=rc,this.browser=$n.getBrowser(),this.browserVersion=$n.getVersion(),this.supports=function(){var e={browser:$n.isBrowserSupported(),webRTC:$n.isWebRTCSupported(),audioVideo:!1,data:!1,binaryBlob:!1,reliable:!1};if(!e.webRTC)return e;var t;try{t=new RTCPeerConnection(rc),e.audioVideo=!0;var n=void 0;try{n=t.createDataChannel("_PEERJSTEST",{ordered:!0}),e.data=!0,e.reliable=!!n.ordered;try{n.binaryType="blob",e.binaryBlob=!$n.isIOS}catch{}}catch{}finally{n&&n.close()}}catch{}finally{t&&t.close()}return e}(),this.pack=ha.pack,this.unpack=ha.unpack,this._dataCount=1}return r.prototype.noop=function(){},r.prototype.validateId=function(e){return!e||/^[A-Za-z0-9]+(?:[ _-][A-Za-z0-9]+)*$/.test(e)},r.prototype.chunk=function(e){for(var t=[],n=e.size,i=Math.ceil(n/te.chunkedMTU),s=0,a=0;a<n;){var o=Math.min(n,a+te.chunkedMTU),c=e.slice(a,o),l={__peerData:this._dataCount,n:s,data:c,total:i};t.push(l),a=o,s++}return this._dataCount++,t},r.prototype.blobToArrayBuffer=function(e,t){var n=new FileReader;return n.onload=function(i){i.target&&t(i.target.result)},n.readAsArrayBuffer(e),n},r.prototype.binaryStringToArrayBuffer=function(e){for(var t=new Uint8Array(e.length),n=0;n<e.length;n++)t[n]=e.charCodeAt(n)&255;return t.buffer},r.prototype.randomToken=function(){return Math.random().toString(36).slice(2)},r.prototype.isSecure=function(){return location.protocol==="https:"},r}(),te=new Su,sc={};zt(sc,"Peer",()=>Is,r=>Is=r);var ei={},bu=Object.prototype.hasOwnProperty,qe="~";function ti(){}Object.create&&(ti.prototype=Object.create(null),new ti().__proto__||(qe=!1));function xu(r,e,t){this.fn=r,this.context=e,this.once=t||!1}function oc(r,e,t,n,i){if(typeof t!="function")throw new TypeError("The listener must be a function");var s=new xu(t,n||r,i),a=qe?qe+e:e;return r._events[a]?r._events[a].fn?r._events[a]=[r._events[a],s]:r._events[a].push(s):(r._events[a]=s,r._eventsCount++),r}function dr(r,e){--r._eventsCount===0?r._events=new ti:delete r._events[e]}function Le(){this._events=new ti,this._eventsCount=0}Le.prototype.eventNames=function(){var r=[],e,t;if(this._eventsCount===0)return r;for(t in e=this._events)bu.call(e,t)&&r.push(qe?t.slice(1):t);return Object.getOwnPropertySymbols?r.concat(Object.getOwnPropertySymbols(e)):r},Le.prototype.listeners=function(r){var e=qe?qe+r:r,t=this._events[e];if(!t)return[];if(t.fn)return[t.fn];for(var n=0,i=t.length,s=new Array(i);n<i;n++)s[n]=t[n].fn;return s},Le.prototype.listenerCount=function(r){var e=qe?qe+r:r,t=this._events[e];return t?t.fn?1:t.length:0},Le.prototype.emit=function(r,e,t,n,i,s){var a=qe?qe+r:r;if(!this._events[a])return!1;var o=this._events[a],c=arguments.length,l,u;if(o.fn){switch(o.once&&this.removeListener(r,o.fn,void 0,!0),c){case 1:return o.fn.call(o.context),!0;case 2:return o.fn.call(o.context,e),!0;case 3:return o.fn.call(o.context,e,t),!0;case 4:return o.fn.call(o.context,e,t,n),!0;case 5:return o.fn.call(o.context,e,t,n,i),!0;case 6:return o.fn.call(o.context,e,t,n,i,s),!0}for(u=1,l=new Array(c-1);u<c;u++)l[u-1]=arguments[u];o.fn.apply(o.context,l)}else{var p=o.length,f;for(u=0;u<p;u++)switch(o[u].once&&this.removeListener(r,o[u].fn,void 0,!0),c){case 1:o[u].fn.call(o[u].context);break;case 2:o[u].fn.call(o[u].context,e);break;case 3:o[u].fn.call(o[u].context,e,t);break;case 4:o[u].fn.call(o[u].context,e,t,n);break;default:if(!l)for(f=1,l=new Array(c-1);f<c;f++)l[f-1]=arguments[f];o[u].fn.apply(o[u].context,l)}}return!0},Le.prototype.on=function(r,e,t){return oc(this,r,e,t,!1)},Le.prototype.once=function(r,e,t){return oc(this,r,e,t,!0)},Le.prototype.removeListener=function(r,e,t,n){var i=qe?qe+r:r;if(!this._events[i])return this;if(!e)return dr(this,i),this;var s=this._events[i];if(s.fn)s.fn===e&&(!n||s.once)&&(!t||s.context===t)&&dr(this,i);else{for(var a=0,o=[],c=s.length;a<c;a++)(s[a].fn!==e||n&&!s[a].once||t&&s[a].context!==t)&&o.push(s[a]);o.length?this._events[i]=o.length===1?o[0]:o:dr(this,i)}return this},Le.prototype.removeAllListeners=function(r){var e;return r?(e=qe?qe+r:r,this._events[e]&&dr(this,e)):(this._events=new ti,this._eventsCount=0),this},Le.prototype.off=Le.prototype.removeListener,Le.prototype.addListener=Le.prototype.on,Le.prefixed=qe,Le.EventEmitter=Le,ei=Le;var j={};zt(j,"LogLevel",()=>$e,r=>$e=r),zt(j,"default",()=>ac,r=>ac=r);var hn=function(r,e){var t=typeof Symbol=="function"&&r[Symbol.iterator];if(!t)return r;var n=t.call(r),i,s=[],a;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)s.push(i.value)}catch(o){a={error:o}}finally{try{i&&!i.done&&(t=n.return)&&t.call(n)}finally{if(a)throw a.error}}return s},dn=function(r,e,t){if(t||arguments.length===2)for(var n=0,i=e.length,s;n<i;n++)(s||!(n in e))&&(s||(s=Array.prototype.slice.call(e,0,n)),s[n]=e[n]);return r.concat(s||Array.prototype.slice.call(e))},wu="PeerJS: ",$e;(function(r){r[r.Disabled=0]="Disabled",r[r.Errors=1]="Errors",r[r.Warnings=2]="Warnings",r[r.All=3]="All"})($e||($e={}));var _u=function(){function r(){this._logLevel=$e.Disabled}return Object.defineProperty(r.prototype,"logLevel",{get:function(){return this._logLevel},set:function(e){this._logLevel=e},enumerable:!1,configurable:!0}),r.prototype.log=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this._logLevel>=$e.All&&this._print.apply(this,dn([$e.All],hn(e),!1))},r.prototype.warn=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this._logLevel>=$e.Warnings&&this._print.apply(this,dn([$e.Warnings],hn(e),!1))},r.prototype.error=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this._logLevel>=$e.Errors&&this._print.apply(this,dn([$e.Errors],hn(e),!1))},r.prototype.setLogFunction=function(e){this._print=e},r.prototype._print=function(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];var i=dn([wu],hn(t),!1);for(var s in i)i[s]instanceof Error&&(i[s]="("+i[s].name+") "+i[s].message);e>=$e.All?console.log.apply(console,dn([],hn(i),!1)):e>=$e.Warnings?console.warn.apply(console,dn(["WARNING"],hn(i),!1)):e>=$e.Errors&&console.error.apply(console,dn(["ERROR"],hn(i),!1))},r}(),ac=new _u,cc={};zt(cc,"Socket",()=>lc,r=>lc=r);var Et;(function(r){r.Data="data",r.Media="media"})(Et||(Et={}));var be;(function(r){r.BrowserIncompatible="browser-incompatible",r.Disconnected="disconnected",r.InvalidID="invalid-id",r.InvalidKey="invalid-key",r.Network="network",r.PeerUnavailable="peer-unavailable",r.SslUnavailable="ssl-unavailable",r.ServerError="server-error",r.SocketError="socket-error",r.SocketClosed="socket-closed",r.UnavailableID="unavailable-id",r.WebRTC="webrtc"})(be||(be={}));var Ht;(function(r){r.Binary="binary",r.BinaryUTF8="binary-utf8",r.JSON="json"})(Ht||(Ht={}));var qt;(function(r){r.Message="message",r.Disconnected="disconnected",r.Error="error",r.Close="close"})(qt||(qt={}));var Ie;(function(r){r.Heartbeat="HEARTBEAT",r.Candidate="CANDIDATE",r.Offer="OFFER",r.Answer="ANSWER",r.Open="OPEN",r.Error="ERROR",r.IdTaken="ID-TAKEN",r.InvalidKey="INVALID-KEY",r.Leave="LEAVE",r.Expire="EXPIRE"})(Ie||(Ie={}));var Ps={};Ps=JSON.parse('{"name":"peerjs","version":"1.4.7","keywords":["peerjs","webrtc","p2p","rtc"],"description":"PeerJS client","homepage":"https://peerjs.com","bugs":{"url":"https://github.com/peers/peerjs/issues"},"repository":{"type":"git","url":"https://github.com/peers/peerjs"},"license":"MIT","contributors":["Michelle Bu <michelle@michellebu.com>","afrokick <devbyru@gmail.com>","ericz <really.ez@gmail.com>","Jairo <kidandcat@gmail.com>","Jonas Gloning <34194370+jonasgloning@users.noreply.github.com>","Jairo Caro-Accino Viciana <jairo@galax.be>","Carlos Caballero <carlos.caballero.gonzalez@gmail.com>","hc <hheennrryy@gmail.com>","Muhammad Asif <capripio@gmail.com>","PrashoonB <prashoonbhattacharjee@gmail.com>","Harsh Bardhan Mishra <47351025+HarshCasper@users.noreply.github.com>","akotynski <aleksanderkotbury@gmail.com>","lmb <i@lmb.io>","Jairooo <jairocaro@msn.com>","Moritz St\xFCckler <moritz.stueckler@gmail.com>","Simon <crydotsnakegithub@gmail.com>","Denis Lukov <denismassters@gmail.com>","Philipp Hancke <fippo@andyet.net>","Hans Oksendahl <hansoksendahl@gmail.com>","Jess <jessachandler@gmail.com>","khankuan <khankuan@gmail.com>","DUODVK <kurmanov.work@gmail.com>","XiZhao <kwang1imsa@gmail.com>","Matthias Lohr <matthias@lohr.me>","=frank tree <=frnktrb@googlemail.com>","Andre Eckardt <aeckardt@outlook.com>","Chris Cowan <agentme49@gmail.com>","Alex Chuev <alex@chuev.com>","alxnull <alxnull@e.mail.de>","Yemel Jardi <angel.jardi@gmail.com>","Ben Parnell <benjaminparnell.94@gmail.com>","Benny Lichtner <bennlich@gmail.com>","fresheneesz <bitetrudpublic@gmail.com>","bob.barstead@exaptive.com <bob.barstead@exaptive.com>","chandika <chandika@gmail.com>","emersion <contact@emersion.fr>","Christopher Van <cvan@users.noreply.github.com>","eddieherm <edhermoso@gmail.com>","Eduardo Pinho <enet4mikeenet@gmail.com>","Evandro Zanatta <ezanatta@tray.net.br>","Gardner Bickford <gardner@users.noreply.github.com>","Gian Luca <gianluca.cecchi@cynny.com>","PatrickJS <github@gdi2290.com>","jonnyf <github@jonathanfoss.co.uk>","Hizkia Felix <hizkifw@gmail.com>","Hristo Oskov <hristo.oskov@gmail.com>","Isaac Madwed <i.madwed@gmail.com>","Ilya Konanykhin <ilya.konanykhin@gmail.com>","jasonbarry <jasbarry@me.com>","Jonathan Burke <jonathan.burke.1311@googlemail.com>","Josh Hamit <josh.hamit@gmail.com>","Jordan Austin <jrax86@gmail.com>","Joel Wetzell <jwetzell@yahoo.com>","xizhao <kevin.wang@cloudera.com>","Alberto Torres <kungfoobar@gmail.com>","Jonathan Mayol <mayoljonathan@gmail.com>","Jefferson Felix <me@jsfelix.dev>","Rolf Erik Lekang <me@rolflekang.com>","Kevin Mai-Husan Chia <mhchia@users.noreply.github.com>","Pepijn de Vos <pepijndevos@gmail.com>","JooYoung <qkdlql@naver.com>","Tobias Speicher <rootcommander@gmail.com>","Steve Blaurock <sblaurock@gmail.com>","Kyrylo Shegeda <shegeda@ualberta.ca>","Diwank Singh Tomer <singh@diwank.name>","So\u0308ren Balko <Soeren.Balko@gmail.com>","Arpit Solanki <solankiarpit1997@gmail.com>","Yuki Ito <yuki@gnnk.net>","Artur Zayats <zag2art@gmail.com>"],"funding":{"type":"opencollective","url":"https://opencollective.com/peer"},"collective":{"type":"opencollective","url":"https://opencollective.com/peer"},"files":["dist/*"],"sideEffects":["lib/global.ts","lib/supports.ts"],"main":"dist/bundler.cjs","module":"dist/bundler.mjs","browser-minified":"dist/peerjs.min.js","browser-unminified":"dist/peerjs.js","types":"dist/types.d.ts","engines":{"node":">= 10"},"targets":{"types":{"source":"lib/exports.ts"},"main":{"source":"lib/exports.ts","sourceMap":{"inlineSources":true}},"module":{"source":"lib/exports.ts","includeNodeModules":["eventemitter3"],"sourceMap":{"inlineSources":true}},"browser-minified":{"context":"browser","outputFormat":"global","optimize":true,"engines":{"browsers":"cover 99%, not dead"},"source":"lib/global.ts"},"browser-unminified":{"context":"browser","outputFormat":"global","optimize":false,"engines":{"browsers":"cover 99%, not dead"},"source":"lib/global.ts"}},"scripts":{"contributors":"git-authors-cli --print=false && prettier --write package.json && git add package.json package-lock.json && git commit -m \\"chore(contributors): update and sort contributors list\\"","check":"tsc --noEmit","watch":"parcel watch","build":"rm -rf dist && parcel build","prepublishOnly":"npm run build","test":"mocha -r ts-node/register -r jsdom-global/register test/**/*.ts","format":"prettier --write .","semantic-release":"semantic-release"},"devDependencies":{"@parcel/config-default":"^2.5.0","@parcel/packager-ts":"^2.5.0","@parcel/transformer-typescript-tsc":"^2.5.0","@parcel/transformer-typescript-types":"^2.5.0","@semantic-release/changelog":"^6.0.1","@semantic-release/git":"^10.0.1","@types/chai":"^4.3.0","@types/mocha":"^9.1.0","@types/node":"^17.0.18","chai":"^4.3.6","git-authors-cli":"^1.0.40","jsdom":"^19.0.0","jsdom-global":"^3.0.2","mocha":"^9.2.0","mock-socket":"8.0.5","parcel":"^2.5.0","parcel-transformer-tsc-sourcemaps":"^1.0.2","prettier":"^2.6.2","semantic-release":"^19.0.2","standard":"^16.0.4","ts-node":"^10.5.0","typescript":"^4.5.5"},"dependencies":{"@swc/helpers":"^0.3.13","eventemitter3":"^4.0.7","peerjs-js-binarypack":"1.0.1","webrtc-adapter":"^7.7.1"}}');var Tu=function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var s in i)Object.prototype.hasOwnProperty.call(i,s)&&(n[s]=i[s])},r(e,t)};return function(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}}(),Mu=function(r,e){var t=typeof Symbol=="function"&&r[Symbol.iterator];if(!t)return r;var n=t.call(r),i,s=[],a;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)s.push(i.value)}catch(o){a={error:o}}finally{try{i&&!i.done&&(t=n.return)&&t.call(n)}finally{if(a)throw a.error}}return s},Cu=function(r,e,t){if(t||arguments.length===2)for(var n=0,i=e.length,s;n<i;n++)(s||!(n in e))&&(s||(s=Array.prototype.slice.call(e,0,n)),s[n]=e[n]);return r.concat(s||Array.prototype.slice.call(e))},Eu=function(r){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&r[e],n=0;if(t)return t.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&n>=r.length&&(r=void 0),{value:r&&r[n++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},lc=function(r){Tu(e,r);function e(t,n,i,s,a,o){o===void 0&&(o=5e3);var c=r.call(this)||this;c.pingInterval=o,c._disconnected=!0,c._messagesQueue=[];var l=t?"wss://":"ws://";return c._baseUrl=l+n+":"+i+s+"peerjs?key="+a,c}return e.prototype.start=function(t,n){var i=this;this._id=t;var s="".concat(this._baseUrl,"&id=").concat(t,"&token=").concat(n);this._socket||!this._disconnected||(this._socket=new WebSocket(s+"&version="+Ps.version),this._disconnected=!1,this._socket.onmessage=function(a){var o;try{o=JSON.parse(a.data),j.default.log("Server message received:",o)}catch{j.default.log("Invalid server message",a.data);return}i.emit(qt.Message,o)},this._socket.onclose=function(a){i._disconnected||(j.default.log("Socket closed.",a),i._cleanup(),i._disconnected=!0,i.emit(qt.Disconnected))},this._socket.onopen=function(){i._disconnected||(i._sendQueuedMessages(),j.default.log("Socket open"),i._scheduleHeartbeat())})},e.prototype._scheduleHeartbeat=function(){var t=this;this._wsPingTimer=setTimeout(function(){t._sendHeartbeat()},this.pingInterval)},e.prototype._sendHeartbeat=function(){if(!this._wsOpen()){j.default.log("Cannot send heartbeat, because socket closed");return}var t=JSON.stringify({type:Ie.Heartbeat});this._socket.send(t),this._scheduleHeartbeat()},e.prototype._wsOpen=function(){return!!this._socket&&this._socket.readyState===1},e.prototype._sendQueuedMessages=function(){var t,n,i=Cu([],Mu(this._messagesQueue),!1);this._messagesQueue=[];try{for(var s=Eu(i),a=s.next();!a.done;a=s.next()){var o=a.value;this.send(o)}}catch(c){t={error:c}}finally{try{a&&!a.done&&(n=s.return)&&n.call(s)}finally{if(t)throw t.error}}},e.prototype.send=function(t){if(!this._disconnected){if(!this._id){this._messagesQueue.push(t);return}if(!t.type){this.emit(qt.Error,"Invalid message");return}if(this._wsOpen()){var n=JSON.stringify(t);this._socket.send(n)}}},e.prototype.close=function(){this._disconnected||(this._cleanup(),this._disconnected=!0)},e.prototype._cleanup=function(){this._socket&&(this._socket.onopen=this._socket.onmessage=this._socket.onclose=null,this._socket.close(),this._socket=void 0),clearTimeout(this._wsPingTimer)},e}(ei.EventEmitter),ks={};zt(ks,"MediaConnection",()=>dc,r=>dc=r);var Rs={};zt(Rs,"Negotiator",()=>uc,r=>uc=r);var pr=function(){return pr=Object.assign||function(r){for(var e,t=1,n=arguments.length;t<n;t++){e=arguments[t];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(r[i]=e[i])}return r},pr.apply(this,arguments)},fr=function(r,e,t,n){function i(s){return s instanceof t?s:new t(function(a){a(s)})}return new(t||(t=Promise))(function(s,a){function o(u){try{l(n.next(u))}catch(p){a(p)}}function c(u){try{l(n.throw(u))}catch(p){a(p)}}function l(u){u.done?s(u.value):i(u.value).then(o,c)}l((n=n.apply(r,e||[])).next())})},mr=function(r,e){var t={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},n,i,s,a;return a={next:o(0),throw:o(1),return:o(2)},typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function o(l){return function(u){return c([l,u])}}function c(l){if(n)throw new TypeError("Generator is already executing.");for(;t;)try{if(n=1,i&&(s=l[0]&2?i.return:l[0]?i.throw||((s=i.return)&&s.call(i),0):i.next)&&!(s=s.call(i,l[1])).done)return s;switch(i=0,s&&(l=[l[0]&2,s.value]),l[0]){case 0:case 1:s=l;break;case 4:return t.label++,{value:l[1],done:!1};case 5:t.label++,i=l[1],l=[0];continue;case 7:l=t.ops.pop(),t.trys.pop();continue;default:if(s=t.trys,!(s=s.length>0&&s[s.length-1])&&(l[0]===6||l[0]===2)){t=0;continue}if(l[0]===3&&(!s||l[1]>s[0]&&l[1]<s[3])){t.label=l[1];break}if(l[0]===6&&t.label<s[1]){t.label=s[1],s=l;break}if(s&&t.label<s[2]){t.label=s[2],t.ops.push(l);break}s[2]&&t.ops.pop(),t.trys.pop();continue}l=e.call(r,t)}catch(u){l=[6,u],i=0}finally{n=s=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}},uc=function(){function r(e){this.connection=e}return r.prototype.startConnection=function(e){var t=this._startPeerConnection();if(this.connection.peerConnection=t,this.connection.type===Et.Media&&e._stream&&this._addTracksToConnection(e._stream,t),e.originator){if(this.connection.type===Et.Data){var n=this.connection,i={ordered:!!e.reliable},s=t.createDataChannel(n.label,i);n.initialize(s)}this._makeOffer()}else this.handleSDP("OFFER",e.sdp)},r.prototype._startPeerConnection=function(){j.default.log("Creating RTCPeerConnection.");var e=new RTCPeerConnection(this.connection.provider.options.config);return this._setupListeners(e),e},r.prototype._setupListeners=function(e){var t=this,n=this.connection.peer,i=this.connection.connectionId,s=this.connection.type,a=this.connection.provider;j.default.log("Listening for ICE candidates."),e.onicecandidate=function(o){!o.candidate||!o.candidate.candidate||(j.default.log("Received ICE candidates for ".concat(n,":"),o.candidate),a.socket.send({type:Ie.Candidate,payload:{candidate:o.candidate,type:s,connectionId:i},dst:n}))},e.oniceconnectionstatechange=function(){switch(e.iceConnectionState){case"failed":j.default.log("iceConnectionState is failed, closing connections to "+n),t.connection.emit("error",new Error("Negotiation of connection to "+n+" failed.")),t.connection.close();break;case"closed":j.default.log("iceConnectionState is closed, closing connections to "+n),t.connection.emit("error",new Error("Connection to "+n+" closed.")),t.connection.close();break;case"disconnected":j.default.log("iceConnectionState changed to disconnected on the connection with "+n);break;case"completed":e.onicecandidate=te.noop;break}t.connection.emit("iceStateChanged",e.iceConnectionState)},j.default.log("Listening for data channel"),e.ondatachannel=function(o){j.default.log("Received data channel");var c=o.channel,l=a.getConnection(n,i);l.initialize(c)},j.default.log("Listening for remote stream"),e.ontrack=function(o){j.default.log("Received remote stream");var c=o.streams[0],l=a.getConnection(n,i);if(l.type===Et.Media){var u=l;t._addStreamToMediaConnection(c,u)}}},r.prototype.cleanup=function(){j.default.log("Cleaning up PeerConnection to "+this.connection.peer);var e=this.connection.peerConnection;if(e){this.connection.peerConnection=null,e.onicecandidate=e.oniceconnectionstatechange=e.ondatachannel=e.ontrack=function(){};var t=e.signalingState!=="closed",n=!1;if(this.connection.type===Et.Data){var i=this.connection,s=i.dataChannel;s&&(n=!!s.readyState&&s.readyState!=="closed")}(t||n)&&e.close()}},r.prototype._makeOffer=function(){return fr(this,void 0,Promise,function(){var e,t,n,i,s,a,o;return mr(this,function(c){switch(c.label){case 0:e=this.connection.peerConnection,t=this.connection.provider,c.label=1;case 1:return c.trys.push([1,7,,8]),[4,e.createOffer(this.connection.options.constraints)];case 2:n=c.sent(),j.default.log("Created offer."),this.connection.options.sdpTransform&&typeof this.connection.options.sdpTransform=="function"&&(n.sdp=this.connection.options.sdpTransform(n.sdp)||n.sdp),c.label=3;case 3:return c.trys.push([3,5,,6]),[4,e.setLocalDescription(n)];case 4:return c.sent(),j.default.log("Set localDescription:",n,"for:".concat(this.connection.peer)),i={sdp:n,type:this.connection.type,connectionId:this.connection.connectionId,metadata:this.connection.metadata,browser:te.browser},this.connection.type===Et.Data&&(s=this.connection,i=pr(pr({},i),{label:s.label,reliable:s.reliable,serialization:s.serialization})),t.socket.send({type:Ie.Offer,payload:i,dst:this.connection.peer}),[3,6];case 5:return a=c.sent(),a!="OperationError: Failed to set local offer sdp: Called in wrong state: kHaveRemoteOffer"&&(t.emitError(be.WebRTC,a),j.default.log("Failed to setLocalDescription, ",a)),[3,6];case 6:return[3,8];case 7:return o=c.sent(),t.emitError(be.WebRTC,o),j.default.log("Failed to createOffer, ",o),[3,8];case 8:return[2]}})})},r.prototype._makeAnswer=function(){return fr(this,void 0,Promise,function(){var e,t,n,i,s;return mr(this,function(a){switch(a.label){case 0:e=this.connection.peerConnection,t=this.connection.provider,a.label=1;case 1:return a.trys.push([1,7,,8]),[4,e.createAnswer()];case 2:n=a.sent(),j.default.log("Created answer."),this.connection.options.sdpTransform&&typeof this.connection.options.sdpTransform=="function"&&(n.sdp=this.connection.options.sdpTransform(n.sdp)||n.sdp),a.label=3;case 3:return a.trys.push([3,5,,6]),[4,e.setLocalDescription(n)];case 4:return a.sent(),j.default.log("Set localDescription:",n,"for:".concat(this.connection.peer)),t.socket.send({type:Ie.Answer,payload:{sdp:n,type:this.connection.type,connectionId:this.connection.connectionId,browser:te.browser},dst:this.connection.peer}),[3,6];case 5:return i=a.sent(),t.emitError(be.WebRTC,i),j.default.log("Failed to setLocalDescription, ",i),[3,6];case 6:return[3,8];case 7:return s=a.sent(),t.emitError(be.WebRTC,s),j.default.log("Failed to create answer, ",s),[3,8];case 8:return[2]}})})},r.prototype.handleSDP=function(e,t){return fr(this,void 0,Promise,function(){var n,i,s,a;return mr(this,function(o){switch(o.label){case 0:t=new RTCSessionDescription(t),n=this.connection.peerConnection,i=this.connection.provider,j.default.log("Setting remote description",t),s=this,o.label=1;case 1:return o.trys.push([1,5,,6]),[4,n.setRemoteDescription(t)];case 2:return o.sent(),j.default.log("Set remoteDescription:".concat(e," for:").concat(this.connection.peer)),e!=="OFFER"?[3,4]:[4,s._makeAnswer()];case 3:o.sent(),o.label=4;case 4:return[3,6];case 5:return a=o.sent(),i.emitError(be.WebRTC,a),j.default.log("Failed to setRemoteDescription, ",a),[3,6];case 6:return[2]}})})},r.prototype.handleCandidate=function(e){return fr(this,void 0,Promise,function(){var t,n,i,s,a,o;return mr(this,function(c){switch(c.label){case 0:j.default.log("handleCandidate:",e),t=e.candidate,n=e.sdpMLineIndex,i=e.sdpMid,s=this.connection.peerConnection,a=this.connection.provider,c.label=1;case 1:return c.trys.push([1,3,,4]),[4,s.addIceCandidate(new RTCIceCandidate({sdpMid:i,sdpMLineIndex:n,candidate:t}))];case 2:return c.sent(),j.default.log("Added ICE candidate for:".concat(this.connection.peer)),[3,4];case 3:return o=c.sent(),a.emitError(be.WebRTC,o),j.default.log("Failed to handleCandidate, ",o),[3,4];case 4:return[2]}})})},r.prototype._addTracksToConnection=function(e,t){if(j.default.log("add tracks from stream ".concat(e.id," to peer connection")),!t.addTrack)return j.default.error("Your browser does't support RTCPeerConnection#addTrack. Ignored.");e.getTracks().forEach(function(n){t.addTrack(n,e)})},r.prototype._addStreamToMediaConnection=function(e,t){j.default.log("add stream ".concat(e.id," to media connection ").concat(t.connectionId)),t.addStream(e)},r}(),As={};zt(As,"BaseConnection",()=>hc,r=>hc=r);var Pu=function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var s in i)Object.prototype.hasOwnProperty.call(i,s)&&(n[s]=i[s])},r(e,t)};return function(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}}(),hc=function(r){Pu(e,r);function e(t,n,i){var s=r.call(this)||this;return s.peer=t,s.provider=n,s.options=i,s._open=!1,s.metadata=i.metadata,s}return Object.defineProperty(e.prototype,"open",{get:function(){return this._open},enumerable:!1,configurable:!0}),e}(ei.EventEmitter),ku=function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var s in i)Object.prototype.hasOwnProperty.call(i,s)&&(n[s]=i[s])},r(e,t)};return function(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}}(),yr=function(){return yr=Object.assign||function(r){for(var e,t=1,n=arguments.length;t<n;t++){e=arguments[t];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(r[i]=e[i])}return r},yr.apply(this,arguments)},Ru=function(r){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&r[e],n=0;if(t)return t.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&n>=r.length&&(r=void 0),{value:r&&r[n++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},dc=function(r){ku(e,r);function e(t,n,i){var s=r.call(this,t,n,i)||this;return s._localStream=s.options._stream,s.connectionId=s.options.connectionId||e.ID_PREFIX+te.randomToken(),s._negotiator=new Rs.Negotiator(s),s._localStream&&s._negotiator.startConnection({_stream:s._localStream,originator:!0}),s}return Object.defineProperty(e.prototype,"type",{get:function(){return Et.Media},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"localStream",{get:function(){return this._localStream},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"remoteStream",{get:function(){return this._remoteStream},enumerable:!1,configurable:!0}),e.prototype.addStream=function(t){j.default.log("Receiving stream",t),this._remoteStream=t,r.prototype.emit.call(this,"stream",t)},e.prototype.handleMessage=function(t){var n=t.type,i=t.payload;switch(t.type){case Ie.Answer:this._negotiator.handleSDP(n,i.sdp),this._open=!0;break;case Ie.Candidate:this._negotiator.handleCandidate(i.candidate);break;default:j.default.warn("Unrecognized message type:".concat(n," from peer:").concat(this.peer));break}},e.prototype.answer=function(t,n){var i,s;if(n===void 0&&(n={}),this._localStream){j.default.warn("Local stream already exists on this MediaConnection. Are you answering a call twice?");return}this._localStream=t,n&&n.sdpTransform&&(this.options.sdpTransform=n.sdpTransform),this._negotiator.startConnection(yr(yr({},this.options._payload),{_stream:t}));var a=this.provider._getMessages(this.connectionId);try{for(var o=Ru(a),c=o.next();!c.done;c=o.next()){var l=c.value;this.handleMessage(l)}}catch(u){i={error:u}}finally{try{c&&!c.done&&(s=o.return)&&s.call(o)}finally{if(i)throw i.error}}this._open=!0},e.prototype.close=function(){this._negotiator&&(this._negotiator.cleanup(),this._negotiator=null),this._localStream=null,this._remoteStream=null,this.provider&&(this.provider._removeConnection(this),this.provider=null),this.options&&this.options._stream&&(this.options._stream=null),this.open&&(this._open=!1,r.prototype.emit.call(this,"close"))},e.ID_PREFIX="mc_",e}(As.BaseConnection),Os={};zt(Os,"DataConnection",()=>mc,r=>mc=r);var pc={};zt(pc,"EncodingQueue",()=>fc,r=>fc=r);var Au=function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var s in i)Object.prototype.hasOwnProperty.call(i,s)&&(n[s]=i[s])},r(e,t)};return function(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}}(),fc=function(r){Au(e,r);function e(){var t=r.call(this)||this;return t.fileReader=new FileReader,t._queue=[],t._processing=!1,t.fileReader.onload=function(n){t._processing=!1,n.target&&t.emit("done",n.target.result),t.doNextTask()},t.fileReader.onerror=function(n){j.default.error("EncodingQueue error:",n),t._processing=!1,t.destroy(),t.emit("error",n)},t}return Object.defineProperty(e.prototype,"queue",{get:function(){return this._queue},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"size",{get:function(){return this.queue.length},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"processing",{get:function(){return this._processing},enumerable:!1,configurable:!0}),e.prototype.enque=function(t){this.queue.push(t),!this.processing&&this.doNextTask()},e.prototype.destroy=function(){this.fileReader.abort(),this._queue=[]},e.prototype.doNextTask=function(){this.size!==0&&(this.processing||(this._processing=!0,this.fileReader.readAsArrayBuffer(this.queue.shift())))},e}(ei.EventEmitter),Ou=function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var s in i)Object.prototype.hasOwnProperty.call(i,s)&&(n[s]=i[s])},r(e,t)};return function(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}}(),Iu=function(r){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&r[e],n=0;if(t)return t.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&n>=r.length&&(r=void 0),{value:r&&r[n++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},mc=function(r){Ou(e,r);function e(t,n,i){var s=r.call(this,t,n,i)||this;return s.stringify=JSON.stringify,s.parse=JSON.parse,s._buffer=[],s._bufferSize=0,s._buffering=!1,s._chunkedData={},s._encodingQueue=new pc.EncodingQueue,s.connectionId=s.options.connectionId||e.ID_PREFIX+te.randomToken(),s.label=s.options.label||s.connectionId,s.serialization=s.options.serialization||Ht.Binary,s.reliable=!!s.options.reliable,s._encodingQueue.on("done",function(a){s._bufferedSend(a)}),s._encodingQueue.on("error",function(){j.default.error("DC#".concat(s.connectionId,": Error occured in encoding from blob to arraybuffer, close DC")),s.close()}),s._negotiator=new Rs.Negotiator(s),s._negotiator.startConnection(s.options._payload||{originator:!0}),s}return Object.defineProperty(e.prototype,"type",{get:function(){return Et.Data},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"dataChannel",{get:function(){return this._dc},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"bufferSize",{get:function(){return this._bufferSize},enumerable:!1,configurable:!0}),e.prototype.initialize=function(t){this._dc=t,this._configureDataChannel()},e.prototype._configureDataChannel=function(){var t=this;(!te.supports.binaryBlob||te.supports.reliable)&&(this.dataChannel.binaryType="arraybuffer"),this.dataChannel.onopen=function(){j.default.log("DC#".concat(t.connectionId," dc connection success")),t._open=!0,t.emit("open")},this.dataChannel.onmessage=function(n){j.default.log("DC#".concat(t.connectionId," dc onmessage:"),n.data),t._handleDataMessage(n)},this.dataChannel.onclose=function(){j.default.log("DC#".concat(t.connectionId," dc closed for:"),t.peer),t.close()}},e.prototype._handleDataMessage=function(t){var n=this,i=t.data,s=i.constructor,a=this.serialization===Ht.Binary||this.serialization===Ht.BinaryUTF8,o=i;if(a){if(s===Blob){te.blobToArrayBuffer(i,function(l){var u=te.unpack(l);n.emit("data",u)});return}else if(s===ArrayBuffer)o=te.unpack(i);else if(s===String){var c=te.binaryStringToArrayBuffer(i);o=te.unpack(c)}}else this.serialization===Ht.JSON&&(o=this.parse(i));if(o.__peerData){this._handleChunk(o);return}r.prototype.emit.call(this,"data",o)},e.prototype._handleChunk=function(t){var n=t.__peerData,i=this._chunkedData[n]||{data:[],count:0,total:t.total};if(i.data[t.n]=t.data,i.count++,this._chunkedData[n]=i,i.total===i.count){delete this._chunkedData[n];var s=new Blob(i.data);this._handleDataMessage({data:s})}},e.prototype.close=function(){this._buffer=[],this._bufferSize=0,this._chunkedData={},this._negotiator&&(this._negotiator.cleanup(),this._negotiator=null),this.provider&&(this.provider._removeConnection(this),this.provider=null),this.dataChannel&&(this.dataChannel.onopen=null,this.dataChannel.onmessage=null,this.dataChannel.onclose=null,this._dc=null),this._encodingQueue&&(this._encodingQueue.destroy(),this._encodingQueue.removeAllListeners(),this._encodingQueue=null),this.open&&(this._open=!1,r.prototype.emit.call(this,"close"))},e.prototype.send=function(t,n){if(!this.open){r.prototype.emit.call(this,"error",new Error("Connection is not open. You should listen for the `open` event before sending messages."));return}if(this.serialization===Ht.JSON)this._bufferedSend(this.stringify(t));else if(this.serialization===Ht.Binary||this.serialization===Ht.BinaryUTF8){var i=te.pack(t);if(!n&&i.size>te.chunkedMTU){this._sendChunks(i);return}te.supports.binaryBlob?this._bufferedSend(i):this._encodingQueue.enque(i)}else this._bufferedSend(t)},e.prototype._bufferedSend=function(t){(this._buffering||!this._trySend(t))&&(this._buffer.push(t),this._bufferSize=this._buffer.length)},e.prototype._trySend=function(t){var n=this;if(!this.open)return!1;if(this.dataChannel.bufferedAmount>e.MAX_BUFFERED_AMOUNT)return this._buffering=!0,setTimeout(function(){n._buffering=!1,n._tryBuffer()},50),!1;try{this.dataChannel.send(t)}catch(i){return j.default.error("DC#:".concat(this.connectionId," Error when sending:"),i),this._buffering=!0,this.close(),!1}return!0},e.prototype._tryBuffer=function(){if(this.open&&this._buffer.length!==0){var t=this._buffer[0];this._trySend(t)&&(this._buffer.shift(),this._bufferSize=this._buffer.length,this._tryBuffer())}},e.prototype._sendChunks=function(t){var n,i,s=te.chunk(t);j.default.log("DC#".concat(this.connectionId," Try to send ").concat(s.length," chunks..."));try{for(var a=Iu(s),o=a.next();!o.done;o=a.next()){var c=o.value;this.send(c,!0)}}catch(l){n={error:l}}finally{try{o&&!o.done&&(i=a.return)&&i.call(a)}finally{if(n)throw n.error}}},e.prototype.handleMessage=function(t){var n=t.payload;switch(t.type){case Ie.Answer:this._negotiator.handleSDP(t.type,n.sdp);break;case Ie.Candidate:this._negotiator.handleCandidate(n.candidate);break;default:j.default.warn("Unrecognized message type:",t.type,"from peer:",this.peer);break}},e.ID_PREFIX="dc_",e.MAX_BUFFERED_AMOUNT=8388608,e}(As.BaseConnection),yc={};zt(yc,"API",()=>Sc,r=>Sc=r);var gc=function(r,e,t,n){function i(s){return s instanceof t?s:new t(function(a){a(s)})}return new(t||(t=Promise))(function(s,a){function o(u){try{l(n.next(u))}catch(p){a(p)}}function c(u){try{l(n.throw(u))}catch(p){a(p)}}function l(u){u.done?s(u.value):i(u.value).then(o,c)}l((n=n.apply(r,e||[])).next())})},vc=function(r,e){var t={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},n,i,s,a;return a={next:o(0),throw:o(1),return:o(2)},typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function o(l){return function(u){return c([l,u])}}function c(l){if(n)throw new TypeError("Generator is already executing.");for(;t;)try{if(n=1,i&&(s=l[0]&2?i.return:l[0]?i.throw||((s=i.return)&&s.call(i),0):i.next)&&!(s=s.call(i,l[1])).done)return s;switch(i=0,s&&(l=[l[0]&2,s.value]),l[0]){case 0:case 1:s=l;break;case 4:return t.label++,{value:l[1],done:!1};case 5:t.label++,i=l[1],l=[0];continue;case 7:l=t.ops.pop(),t.trys.pop();continue;default:if(s=t.trys,!(s=s.length>0&&s[s.length-1])&&(l[0]===6||l[0]===2)){t=0;continue}if(l[0]===3&&(!s||l[1]>s[0]&&l[1]<s[3])){t.label=l[1];break}if(l[0]===6&&t.label<s[1]){t.label=s[1],s=l;break}if(s&&t.label<s[2]){t.label=s[2],t.ops.push(l);break}s[2]&&t.ops.pop(),t.trys.pop();continue}l=e.call(r,t)}catch(u){l=[6,u],i=0}finally{n=s=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}},Sc=function(){function r(e){this._options=e}return r.prototype._buildRequest=function(e){var t=this._options.secure?"https":"http",n=this._options,i=n.host,s=n.port,a=n.path,o=n.key,c=new URL("".concat(t,"://").concat(i,":").concat(s).concat(a).concat(o,"/").concat(e));return c.searchParams.set("ts","".concat(Date.now()).concat(Math.random())),c.searchParams.set("version",Ps.version),fetch(c.href,{referrerPolicy:this._options.referrerPolicy})},r.prototype.retrieveId=function(){return gc(this,void 0,Promise,function(){var e,t,n;return vc(this,function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,this._buildRequest("id")];case 1:if(e=i.sent(),e.status!==200)throw new Error("Error. Status:".concat(e.status));return[2,e.text()];case 2:throw t=i.sent(),j.default.error("Error retrieving ID",t),n="",this._options.path==="/"&&this._options.host!==te.CLOUD_HOST&&(n=" If you passed in a `path` to your self-hosted PeerServer, you'll also need to pass in that same path when creating a new Peer."),new Error("Could not get an ID from the server."+n);case 3:return[2]}})})},r.prototype.listAllPeers=function(){return gc(this,void 0,Promise,function(){var e,t,n;return vc(this,function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,this._buildRequest("peers")];case 1:if(e=i.sent(),e.status!==200)throw e.status===401?(t="",this._options.host===te.CLOUD_HOST?t="It looks like you're using the cloud server. You can email team@peerjs.com to enable peer listing for your API key.":t="You need to enable `allow_discovery` on your self-hosted PeerServer to use this feature.",new Error("It doesn't look like you have permission to list peers IDs. "+t)):new Error("Error. Status:".concat(e.status));return[2,e.json()];case 2:throw n=i.sent(),j.default.error("Error retrieving list peers",n),new Error("Could not get list peers from the server."+n);case 3:return[2]}})})},r}(),zu=function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var s in i)Object.prototype.hasOwnProperty.call(i,s)&&(n[s]=i[s])},r(e,t)};return function(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}}(),ni=function(){return ni=Object.assign||function(r){for(var e,t=1,n=arguments.length;t<n;t++){e=arguments[t];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(r[i]=e[i])}return r},ni.apply(this,arguments)},ii=function(r){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&r[e],n=0;if(t)return t.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&n>=r.length&&(r=void 0),{value:r&&r[n++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},Bu=function(r,e){var t=typeof Symbol=="function"&&r[Symbol.iterator];if(!t)return r;var n=t.call(r),i,s=[],a;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)s.push(i.value)}catch(o){a={error:o}}finally{try{i&&!i.done&&(t=n.return)&&t.call(n)}finally{if(a)throw a.error}}return s},Is=function(r){zu(e,r);function e(t,n){var i=r.call(this)||this;i._id=null,i._lastServerId=null,i._destroyed=!1,i._disconnected=!1,i._open=!1,i._connections=new Map,i._lostMessages=new Map;var s;return t&&t.constructor==Object?n=t:t&&(s=t.toString()),n=ni({debug:0,host:te.CLOUD_HOST,port:te.CLOUD_PORT,path:"/",key:e.DEFAULT_KEY,token:te.randomToken(),config:te.defaultConfig,referrerPolicy:"strict-origin-when-cross-origin"},n),i._options=n,i._options.host==="/"&&(i._options.host=window.location.hostname),i._options.path&&(i._options.path[0]!=="/"&&(i._options.path="/"+i._options.path),i._options.path[i._options.path.length-1]!=="/"&&(i._options.path+="/")),i._options.secure===void 0&&i._options.host!==te.CLOUD_HOST?i._options.secure=te.isSecure():i._options.host==te.CLOUD_HOST&&(i._options.secure=!0),i._options.logFunction&&j.default.setLogFunction(i._options.logFunction),j.default.logLevel=i._options.debug||0,i._api=new yc.API(n),i._socket=i._createServerConnection(),!te.supports.audioVideo&&!te.supports.data?(i._delayedAbort(be.BrowserIncompatible,"The current browser does not support WebRTC"),i):s&&!te.validateId(s)?(i._delayedAbort(be.InvalidID,'ID "'.concat(s,'" is invalid')),i):(s?i._initialize(s):i._api.retrieveId().then(function(a){return i._initialize(a)}).catch(function(a){return i._abort(be.ServerError,a)}),i)}return Object.defineProperty(e.prototype,"id",{get:function(){return this._id},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"options",{get:function(){return this._options},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"open",{get:function(){return this._open},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"socket",{get:function(){return this._socket},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"connections",{get:function(){var t,n,i=Object.create(null);try{for(var s=ii(this._connections),a=s.next();!a.done;a=s.next()){var o=Bu(a.value,2),c=o[0],l=o[1];i[c]=l}}catch(u){t={error:u}}finally{try{a&&!a.done&&(n=s.return)&&n.call(s)}finally{if(t)throw t.error}}return i},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"destroyed",{get:function(){return this._destroyed},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"disconnected",{get:function(){return this._disconnected},enumerable:!1,configurable:!0}),e.prototype._createServerConnection=function(){var t=this,n=new cc.Socket(this._options.secure,this._options.host,this._options.port,this._options.path,this._options.key,this._options.pingInterval);return n.on(qt.Message,function(i){t._handleMessage(i)}),n.on(qt.Error,function(i){t._abort(be.SocketError,i)}),n.on(qt.Disconnected,function(){t.disconnected||(t.emitError(be.Network,"Lost connection to server."),t.disconnect())}),n.on(qt.Close,function(){t.disconnected||t._abort(be.SocketClosed,"Underlying socket is already closed.")}),n},e.prototype._initialize=function(t){this._id=t,this.socket.start(t,this._options.token)},e.prototype._handleMessage=function(t){var n,i,s=t.type,a=t.payload,o=t.src;switch(s){case Ie.Open:this._lastServerId=this.id,this._open=!0,this.emit("open",this.id);break;case Ie.Error:this._abort(be.ServerError,a.msg);break;case Ie.IdTaken:this._abort(be.UnavailableID,'ID "'.concat(this.id,'" is taken'));break;case Ie.InvalidKey:this._abort(be.InvalidKey,'API KEY "'.concat(this._options.key,'" is invalid'));break;case Ie.Leave:j.default.log("Received leave message from ".concat(o)),this._cleanupPeer(o),this._connections.delete(o);break;case Ie.Expire:this.emitError(be.PeerUnavailable,"Could not connect to peer ".concat(o));break;case Ie.Offer:var b=a.connectionId,x=this.getConnection(o,b);if(x&&(x.close(),j.default.warn("Offer received for existing Connection ID:".concat(b))),a.type===Et.Media){var c=new ks.MediaConnection(o,this,{connectionId:b,_payload:a,metadata:a.metadata});x=c,this._addConnection(o,x),this.emit("call",c)}else if(a.type===Et.Data){var l=new Os.DataConnection(o,this,{connectionId:b,_payload:a,metadata:a.metadata,label:a.label,serialization:a.serialization,reliable:a.reliable});x=l,this._addConnection(o,x),this.emit("connection",l)}else{j.default.warn("Received malformed connection type:".concat(a.type));return}var u=this._getMessages(b);try{for(var p=ii(u),f=p.next();!f.done;f=p.next()){var m=f.value;x.handleMessage(m)}}catch(g){n={error:g}}finally{try{f&&!f.done&&(i=p.return)&&i.call(p)}finally{if(n)throw n.error}}break;default:if(!a){j.default.warn("You received a malformed message from ".concat(o," of type ").concat(s));return}var b=a.connectionId,x=this.getConnection(o,b);x&&x.peerConnection?x.handleMessage(t):b?this._storeMessage(b,t):j.default.warn("You received an unrecognized message:",t);break}},e.prototype._storeMessage=function(t,n){this._lostMessages.has(t)||this._lostMessages.set(t,[]),this._lostMessages.get(t).push(n)},e.prototype._getMessages=function(t){var n=this._lostMessages.get(t);return n?(this._lostMessages.delete(t),n):[]},e.prototype.connect=function(t,n){if(n===void 0&&(n={}),this.disconnected){j.default.warn("You cannot connect to a new Peer because you called .disconnect() on this Peer and ended your connection with the server. You can create a new Peer to reconnect, or call reconnect on this peer if you believe its ID to still be available."),this.emitError(be.Disconnected,"Cannot connect to new Peer after disconnecting from server.");return}var i=new Os.DataConnection(t,this,n);return this._addConnection(t,i),i},e.prototype.call=function(t,n,i){if(i===void 0&&(i={}),this.disconnected){j.default.warn("You cannot connect to a new Peer because you called .disconnect() on this Peer and ended your connection with the server. You can create a new Peer to reconnect."),this.emitError(be.Disconnected,"Cannot connect to new Peer after disconnecting from server.");return}if(!n){j.default.error("To call a peer, you must provide a stream from your browser's `getUserMedia`.");return}var s=new ks.MediaConnection(t,this,ni(ni({},i),{_stream:n}));return this._addConnection(t,s),s},e.prototype._addConnection=function(t,n){j.default.log("add connection ".concat(n.type,":").concat(n.connectionId," to peerId:").concat(t)),this._connections.has(t)||this._connections.set(t,[]),this._connections.get(t).push(n)},e.prototype._removeConnection=function(t){var n=this._connections.get(t.peer);if(n){var i=n.indexOf(t);i!==-1&&n.splice(i,1)}this._lostMessages.delete(t.connectionId)},e.prototype.getConnection=function(t,n){var i,s,a=this._connections.get(t);if(!a)return null;try{for(var o=ii(a),c=o.next();!c.done;c=o.next()){var l=c.value;if(l.connectionId===n)return l}}catch(u){i={error:u}}finally{try{c&&!c.done&&(s=o.return)&&s.call(o)}finally{if(i)throw i.error}}return null},e.prototype._delayedAbort=function(t,n){var i=this;setTimeout(function(){i._abort(t,n)},0)},e.prototype._abort=function(t,n){j.default.error("Aborting!"),this.emitError(t,n),this._lastServerId?this.disconnect():this.destroy()},e.prototype.emitError=function(t,n){j.default.error("Error:",n);var i;typeof n=="string"?i=new Error(n):i=n,i.type=t,this.emit("error",i)},e.prototype.destroy=function(){this.destroyed||(j.default.log("Destroy peer with ID:".concat(this.id)),this.disconnect(),this._cleanup(),this._destroyed=!0,this.emit("close"))},e.prototype._cleanup=function(){var t,n;try{for(var i=ii(this._connections.keys()),s=i.next();!s.done;s=i.next()){var a=s.value;this._cleanupPeer(a),this._connections.delete(a)}}catch(o){t={error:o}}finally{try{s&&!s.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}this.socket.removeAllListeners()},e.prototype._cleanupPeer=function(t){var n,i,s=this._connections.get(t);if(s)try{for(var a=ii(s),o=a.next();!o.done;o=a.next()){var c=o.value;c.close()}}catch(l){n={error:l}}finally{try{o&&!o.done&&(i=a.return)&&i.call(a)}finally{if(n)throw n.error}}},e.prototype.disconnect=function(){if(!this.disconnected){var t=this.id;j.default.log("Disconnect peer with ID:".concat(t)),this._disconnected=!0,this._open=!1,this.socket.close(),this._lastServerId=t,this._id=null,this.emit("disconnected",t)}},e.prototype.reconnect=function(){if(this.disconnected&&!this.destroyed)j.default.log("Attempting reconnection to server with ID ".concat(this._lastServerId)),this._disconnected=!1,this._initialize(this._lastServerId);else{if(this.destroyed)throw new Error("This peer cannot reconnect to the server. It has already been destroyed.");if(!this.disconnected&&!this.open)j.default.error("In a hurry? We're still trying to make the initial connection!");else throw new Error("Peer ".concat(this.id," cannot reconnect because it is not disconnected from the server!"))}},e.prototype.listAllPeers=function(t){var n=this;t===void 0&&(t=function(i){}),this._api.listAllPeers().then(function(i){return t(i)}).catch(function(i){return n._abort(be.ServerError,i)})},e.DEFAULT_KEY="peerjs",e}(ei.EventEmitter),bc=sc.Peer;const Nu=Object.freeze(Object.defineProperty({__proto__:null,get Peer(){return Is},default:bc,util:te},Symbol.toStringTag,{value:"Module"})),Uu=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function Du(r){return typeof r=="string"&&Uu.test(r)}const ze=[];for(let r=0;r<256;++r)ze.push((r+256).toString(16).slice(1));function Lu(r,e=0){return ze[r[e+0]]+ze[r[e+1]]+ze[r[e+2]]+ze[r[e+3]]+"-"+ze[r[e+4]]+ze[r[e+5]]+"-"+ze[r[e+6]]+ze[r[e+7]]+"-"+ze[r[e+8]]+ze[r[e+9]]+"-"+ze[r[e+10]]+ze[r[e+11]]+ze[r[e+12]]+ze[r[e+13]]+ze[r[e+14]]+ze[r[e+15]]}function Fu(r){if(!Du(r))throw TypeError("Invalid UUID");let e;const t=new Uint8Array(16);return t[0]=(e=parseInt(r.slice(0,8),16))>>>24,t[1]=e>>>16&255,t[2]=e>>>8&255,t[3]=e&255,t[4]=(e=parseInt(r.slice(9,13),16))>>>8,t[5]=e&255,t[6]=(e=parseInt(r.slice(14,18),16))>>>8,t[7]=e&255,t[8]=(e=parseInt(r.slice(19,23),16))>>>8,t[9]=e&255,t[10]=(e=parseInt(r.slice(24,36),16))/1099511627776&255,t[11]=e/4294967296&255,t[12]=e>>>24&255,t[13]=e>>>16&255,t[14]=e>>>8&255,t[15]=e&255,t}function Vu(r){r=unescape(encodeURIComponent(r));const e=[];for(let t=0;t<r.length;++t)e.push(r.charCodeAt(t));return e}const ju="6ba7b810-9dad-11d1-80b4-00c04fd430c8",Ju="6ba7b811-9dad-11d1-80b4-00c04fd430c8";function Gu(r,e,t){function n(i,s,a,o){var c;if(typeof i=="string"&&(i=Vu(i)),typeof s=="string"&&(s=Fu(s)),((c=s)===null||c===void 0?void 0:c.length)!==16)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");let l=new Uint8Array(16+i.length);if(l.set(s),l.set(i,s.length),l=t(l),l[6]=l[6]&15|e,l[8]=l[8]&63|128,a){o=o||0;for(let u=0;u<16;++u)a[o+u]=l[u];return a}return Lu(l)}try{n.name=r}catch{}return n.DNS=ju,n.URL=Ju,n}function Wu(r,e,t,n){switch(r){case 0:return e&t^~e&n;case 1:return e^t^n;case 2:return e&t^e&n^t&n;case 3:return e^t^n}}function zs(r,e){return r<<e|r>>>32-e}function Hu(r){const e=[1518500249,1859775393,2400959708,3395469782],t=[1732584193,4023233417,2562383102,271733878,3285377520];if(typeof r=="string"){const a=unescape(encodeURIComponent(r));r=[];for(let o=0;o<a.length;++o)r.push(a.charCodeAt(o))}else Array.isArray(r)||(r=Array.prototype.slice.call(r));r.push(128);const n=r.length/4+2,i=Math.ceil(n/16),s=new Array(i);for(let a=0;a<i;++a){const o=new Uint32Array(16);for(let c=0;c<16;++c)o[c]=r[a*64+c*4]<<24|r[a*64+c*4+1]<<16|r[a*64+c*4+2]<<8|r[a*64+c*4+3];s[a]=o}s[i-1][14]=(r.length-1)*8/Math.pow(2,32),s[i-1][14]=Math.floor(s[i-1][14]),s[i-1][15]=(r.length-1)*8&4294967295;for(let a=0;a<i;++a){const o=new Uint32Array(80);for(let m=0;m<16;++m)o[m]=s[a][m];for(let m=16;m<80;++m)o[m]=zs(o[m-3]^o[m-8]^o[m-14]^o[m-16],1);let c=t[0],l=t[1],u=t[2],p=t[3],f=t[4];for(let m=0;m<80;++m){const b=Math.floor(m/20),x=zs(c,5)+Wu(b,l,u,p)+f+e[b]+o[m]>>>0;f=p,p=u,u=zs(l,30)>>>0,l=c,c=x}t[0]=t[0]+c>>>0,t[1]=t[1]+l>>>0,t[2]=t[2]+u>>>0,t[3]=t[3]+p>>>0,t[4]=t[4]+f>>>0}return[t[0]>>24&255,t[0]>>16&255,t[0]>>8&255,t[0]&255,t[1]>>24&255,t[1]>>16&255,t[1]>>8&255,t[1]&255,t[2]>>24&255,t[2]>>16&255,t[2]>>8&255,t[2]&255,t[3]>>24&255,t[3]>>16&255,t[3]>>8&255,t[3]&255,t[4]>>24&255,t[4]>>16&255,t[4]>>8&255,t[4]&255]}const qu=Gu("v5",80,Hu);var xc={exports:{}},wc={exports:{}},_c;function Xu(){return _c||(_c=1,function(){var r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",e={rotl:function(t,n){return t<<n|t>>>32-n},rotr:function(t,n){return t<<32-n|t>>>n},endian:function(t){if(t.constructor==Number)return e.rotl(t,8)&16711935|e.rotl(t,24)&4278255360;for(var n=0;n<t.length;n++)t[n]=e.endian(t[n]);return t},randomBytes:function(t){for(var n=[];t>0;t--)n.push(Math.floor(Math.random()*256));return n},bytesToWords:function(t){for(var n=[],i=0,s=0;i<t.length;i++,s+=8)n[s>>>5]|=t[i]<<24-s%32;return n},wordsToBytes:function(t){for(var n=[],i=0;i<t.length*32;i+=8)n.push(t[i>>>5]>>>24-i%32&255);return n},bytesToHex:function(t){for(var n=[],i=0;i<t.length;i++)n.push((t[i]>>>4).toString(16)),n.push((t[i]&15).toString(16));return n.join("")},hexToBytes:function(t){for(var n=[],i=0;i<t.length;i+=2)n.push(parseInt(t.substr(i,2),16));return n},bytesToBase64:function(t){for(var n=[],i=0;i<t.length;i+=3)for(var s=t[i]<<16|t[i+1]<<8|t[i+2],a=0;a<4;a++)i*8+a*6<=t.length*8?n.push(r.charAt(s>>>6*(3-a)&63)):n.push("=");return n.join("")},base64ToBytes:function(t){t=t.replace(/[^A-Z0-9+\/]/ig,"");for(var n=[],i=0,s=0;i<t.length;s=++i%4)s!=0&&n.push((r.indexOf(t.charAt(i-1))&Math.pow(2,-2*s+8)-1)<<s*2|r.indexOf(t.charAt(i))>>>6-s*2);return n}};wc.exports=e}()),wc.exports}var Bs,Tc;function Mc(){if(Tc)return Bs;Tc=1;var r={utf8:{stringToBytes:function(e){return r.bin.stringToBytes(unescape(encodeURIComponent(e)))},bytesToString:function(e){return decodeURIComponent(escape(r.bin.bytesToString(e)))}},bin:{stringToBytes:function(e){for(var t=[],n=0;n<e.length;n++)t.push(e.charCodeAt(n)&255);return t},bytesToString:function(e){for(var t=[],n=0;n<e.length;n++)t.push(String.fromCharCode(e[n]));return t.join("")}}};return Bs=r,Bs}/*!
|
|
78
|
+
isUnifiedPlanSupported:`).concat(this.isUnifiedPlanSupported())},r}()),rc={iceServers:[{urls:"stun:stun.l.google.com:19302"},{urls:["turn:eu-0.turn.peerjs.com:3478","turn:us-0.turn.peerjs.com:3478"],username:"peerjs",credential:"peerjsp"}],sdpSemantics:"unified-plan"},bu=function(){function r(){this.CLOUD_HOST="0.peerjs.com",this.CLOUD_PORT=443,this.chunkedBrowsers={Chrome:1,chrome:1},this.chunkedMTU=16300,this.defaultConfig=rc,this.browser=$n.getBrowser(),this.browserVersion=$n.getVersion(),this.supports=function(){var e={browser:$n.isBrowserSupported(),webRTC:$n.isWebRTCSupported(),audioVideo:!1,data:!1,binaryBlob:!1,reliable:!1};if(!e.webRTC)return e;var t;try{t=new RTCPeerConnection(rc),e.audioVideo=!0;var n=void 0;try{n=t.createDataChannel("_PEERJSTEST",{ordered:!0}),e.data=!0,e.reliable=!!n.ordered;try{n.binaryType="blob",e.binaryBlob=!$n.isIOS}catch{}}catch{}finally{n&&n.close()}}catch{}finally{t&&t.close()}return e}(),this.pack=ha.pack,this.unpack=ha.unpack,this._dataCount=1}return r.prototype.noop=function(){},r.prototype.validateId=function(e){return!e||/^[A-Za-z0-9]+(?:[ _-][A-Za-z0-9]+)*$/.test(e)},r.prototype.chunk=function(e){for(var t=[],n=e.size,i=Math.ceil(n/te.chunkedMTU),s=0,a=0;a<n;){var o=Math.min(n,a+te.chunkedMTU),c=e.slice(a,o),l={__peerData:this._dataCount,n:s,data:c,total:i};t.push(l),a=o,s++}return this._dataCount++,t},r.prototype.blobToArrayBuffer=function(e,t){var n=new FileReader;return n.onload=function(i){i.target&&t(i.target.result)},n.readAsArrayBuffer(e),n},r.prototype.binaryStringToArrayBuffer=function(e){for(var t=new Uint8Array(e.length),n=0;n<e.length;n++)t[n]=e.charCodeAt(n)&255;return t.buffer},r.prototype.randomToken=function(){return Math.random().toString(36).slice(2)},r.prototype.isSecure=function(){return location.protocol==="https:"},r}(),te=new bu,sc={};zt(sc,"Peer",()=>Is,r=>Is=r);var ei={},xu=Object.prototype.hasOwnProperty,qe="~";function ti(){}Object.create&&(ti.prototype=Object.create(null),new ti().__proto__||(qe=!1));function wu(r,e,t){this.fn=r,this.context=e,this.once=t||!1}function oc(r,e,t,n,i){if(typeof t!="function")throw new TypeError("The listener must be a function");var s=new wu(t,n||r,i),a=qe?qe+e:e;return r._events[a]?r._events[a].fn?r._events[a]=[r._events[a],s]:r._events[a].push(s):(r._events[a]=s,r._eventsCount++),r}function dr(r,e){--r._eventsCount===0?r._events=new ti:delete r._events[e]}function Le(){this._events=new ti,this._eventsCount=0}Le.prototype.eventNames=function(){var r=[],e,t;if(this._eventsCount===0)return r;for(t in e=this._events)xu.call(e,t)&&r.push(qe?t.slice(1):t);return Object.getOwnPropertySymbols?r.concat(Object.getOwnPropertySymbols(e)):r},Le.prototype.listeners=function(r){var e=qe?qe+r:r,t=this._events[e];if(!t)return[];if(t.fn)return[t.fn];for(var n=0,i=t.length,s=new Array(i);n<i;n++)s[n]=t[n].fn;return s},Le.prototype.listenerCount=function(r){var e=qe?qe+r:r,t=this._events[e];return t?t.fn?1:t.length:0},Le.prototype.emit=function(r,e,t,n,i,s){var a=qe?qe+r:r;if(!this._events[a])return!1;var o=this._events[a],c=arguments.length,l,u;if(o.fn){switch(o.once&&this.removeListener(r,o.fn,void 0,!0),c){case 1:return o.fn.call(o.context),!0;case 2:return o.fn.call(o.context,e),!0;case 3:return o.fn.call(o.context,e,t),!0;case 4:return o.fn.call(o.context,e,t,n),!0;case 5:return o.fn.call(o.context,e,t,n,i),!0;case 6:return o.fn.call(o.context,e,t,n,i,s),!0}for(u=1,l=new Array(c-1);u<c;u++)l[u-1]=arguments[u];o.fn.apply(o.context,l)}else{var p=o.length,f;for(u=0;u<p;u++)switch(o[u].once&&this.removeListener(r,o[u].fn,void 0,!0),c){case 1:o[u].fn.call(o[u].context);break;case 2:o[u].fn.call(o[u].context,e);break;case 3:o[u].fn.call(o[u].context,e,t);break;case 4:o[u].fn.call(o[u].context,e,t,n);break;default:if(!l)for(f=1,l=new Array(c-1);f<c;f++)l[f-1]=arguments[f];o[u].fn.apply(o[u].context,l)}}return!0},Le.prototype.on=function(r,e,t){return oc(this,r,e,t,!1)},Le.prototype.once=function(r,e,t){return oc(this,r,e,t,!0)},Le.prototype.removeListener=function(r,e,t,n){var i=qe?qe+r:r;if(!this._events[i])return this;if(!e)return dr(this,i),this;var s=this._events[i];if(s.fn)s.fn===e&&(!n||s.once)&&(!t||s.context===t)&&dr(this,i);else{for(var a=0,o=[],c=s.length;a<c;a++)(s[a].fn!==e||n&&!s[a].once||t&&s[a].context!==t)&&o.push(s[a]);o.length?this._events[i]=o.length===1?o[0]:o:dr(this,i)}return this},Le.prototype.removeAllListeners=function(r){var e;return r?(e=qe?qe+r:r,this._events[e]&&dr(this,e)):(this._events=new ti,this._eventsCount=0),this},Le.prototype.off=Le.prototype.removeListener,Le.prototype.addListener=Le.prototype.on,Le.prefixed=qe,Le.EventEmitter=Le,ei=Le;var j={};zt(j,"LogLevel",()=>$e,r=>$e=r),zt(j,"default",()=>ac,r=>ac=r);var hn=function(r,e){var t=typeof Symbol=="function"&&r[Symbol.iterator];if(!t)return r;var n=t.call(r),i,s=[],a;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)s.push(i.value)}catch(o){a={error:o}}finally{try{i&&!i.done&&(t=n.return)&&t.call(n)}finally{if(a)throw a.error}}return s},dn=function(r,e,t){if(t||arguments.length===2)for(var n=0,i=e.length,s;n<i;n++)(s||!(n in e))&&(s||(s=Array.prototype.slice.call(e,0,n)),s[n]=e[n]);return r.concat(s||Array.prototype.slice.call(e))},_u="PeerJS: ",$e;(function(r){r[r.Disabled=0]="Disabled",r[r.Errors=1]="Errors",r[r.Warnings=2]="Warnings",r[r.All=3]="All"})($e||($e={}));var Tu=function(){function r(){this._logLevel=$e.Disabled}return Object.defineProperty(r.prototype,"logLevel",{get:function(){return this._logLevel},set:function(e){this._logLevel=e},enumerable:!1,configurable:!0}),r.prototype.log=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this._logLevel>=$e.All&&this._print.apply(this,dn([$e.All],hn(e),!1))},r.prototype.warn=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this._logLevel>=$e.Warnings&&this._print.apply(this,dn([$e.Warnings],hn(e),!1))},r.prototype.error=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this._logLevel>=$e.Errors&&this._print.apply(this,dn([$e.Errors],hn(e),!1))},r.prototype.setLogFunction=function(e){this._print=e},r.prototype._print=function(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];var i=dn([_u],hn(t),!1);for(var s in i)i[s]instanceof Error&&(i[s]="("+i[s].name+") "+i[s].message);e>=$e.All?console.log.apply(console,dn([],hn(i),!1)):e>=$e.Warnings?console.warn.apply(console,dn(["WARNING"],hn(i),!1)):e>=$e.Errors&&console.error.apply(console,dn(["ERROR"],hn(i),!1))},r}(),ac=new Tu,cc={};zt(cc,"Socket",()=>lc,r=>lc=r);var Et;(function(r){r.Data="data",r.Media="media"})(Et||(Et={}));var be;(function(r){r.BrowserIncompatible="browser-incompatible",r.Disconnected="disconnected",r.InvalidID="invalid-id",r.InvalidKey="invalid-key",r.Network="network",r.PeerUnavailable="peer-unavailable",r.SslUnavailable="ssl-unavailable",r.ServerError="server-error",r.SocketError="socket-error",r.SocketClosed="socket-closed",r.UnavailableID="unavailable-id",r.WebRTC="webrtc"})(be||(be={}));var Ht;(function(r){r.Binary="binary",r.BinaryUTF8="binary-utf8",r.JSON="json"})(Ht||(Ht={}));var qt;(function(r){r.Message="message",r.Disconnected="disconnected",r.Error="error",r.Close="close"})(qt||(qt={}));var Ie;(function(r){r.Heartbeat="HEARTBEAT",r.Candidate="CANDIDATE",r.Offer="OFFER",r.Answer="ANSWER",r.Open="OPEN",r.Error="ERROR",r.IdTaken="ID-TAKEN",r.InvalidKey="INVALID-KEY",r.Leave="LEAVE",r.Expire="EXPIRE"})(Ie||(Ie={}));var Ps={};Ps=JSON.parse('{"name":"peerjs","version":"1.4.7","keywords":["peerjs","webrtc","p2p","rtc"],"description":"PeerJS client","homepage":"https://peerjs.com","bugs":{"url":"https://github.com/peers/peerjs/issues"},"repository":{"type":"git","url":"https://github.com/peers/peerjs"},"license":"MIT","contributors":["Michelle Bu <michelle@michellebu.com>","afrokick <devbyru@gmail.com>","ericz <really.ez@gmail.com>","Jairo <kidandcat@gmail.com>","Jonas Gloning <34194370+jonasgloning@users.noreply.github.com>","Jairo Caro-Accino Viciana <jairo@galax.be>","Carlos Caballero <carlos.caballero.gonzalez@gmail.com>","hc <hheennrryy@gmail.com>","Muhammad Asif <capripio@gmail.com>","PrashoonB <prashoonbhattacharjee@gmail.com>","Harsh Bardhan Mishra <47351025+HarshCasper@users.noreply.github.com>","akotynski <aleksanderkotbury@gmail.com>","lmb <i@lmb.io>","Jairooo <jairocaro@msn.com>","Moritz St\xFCckler <moritz.stueckler@gmail.com>","Simon <crydotsnakegithub@gmail.com>","Denis Lukov <denismassters@gmail.com>","Philipp Hancke <fippo@andyet.net>","Hans Oksendahl <hansoksendahl@gmail.com>","Jess <jessachandler@gmail.com>","khankuan <khankuan@gmail.com>","DUODVK <kurmanov.work@gmail.com>","XiZhao <kwang1imsa@gmail.com>","Matthias Lohr <matthias@lohr.me>","=frank tree <=frnktrb@googlemail.com>","Andre Eckardt <aeckardt@outlook.com>","Chris Cowan <agentme49@gmail.com>","Alex Chuev <alex@chuev.com>","alxnull <alxnull@e.mail.de>","Yemel Jardi <angel.jardi@gmail.com>","Ben Parnell <benjaminparnell.94@gmail.com>","Benny Lichtner <bennlich@gmail.com>","fresheneesz <bitetrudpublic@gmail.com>","bob.barstead@exaptive.com <bob.barstead@exaptive.com>","chandika <chandika@gmail.com>","emersion <contact@emersion.fr>","Christopher Van <cvan@users.noreply.github.com>","eddieherm <edhermoso@gmail.com>","Eduardo Pinho <enet4mikeenet@gmail.com>","Evandro Zanatta <ezanatta@tray.net.br>","Gardner Bickford <gardner@users.noreply.github.com>","Gian Luca <gianluca.cecchi@cynny.com>","PatrickJS <github@gdi2290.com>","jonnyf <github@jonathanfoss.co.uk>","Hizkia Felix <hizkifw@gmail.com>","Hristo Oskov <hristo.oskov@gmail.com>","Isaac Madwed <i.madwed@gmail.com>","Ilya Konanykhin <ilya.konanykhin@gmail.com>","jasonbarry <jasbarry@me.com>","Jonathan Burke <jonathan.burke.1311@googlemail.com>","Josh Hamit <josh.hamit@gmail.com>","Jordan Austin <jrax86@gmail.com>","Joel Wetzell <jwetzell@yahoo.com>","xizhao <kevin.wang@cloudera.com>","Alberto Torres <kungfoobar@gmail.com>","Jonathan Mayol <mayoljonathan@gmail.com>","Jefferson Felix <me@jsfelix.dev>","Rolf Erik Lekang <me@rolflekang.com>","Kevin Mai-Husan Chia <mhchia@users.noreply.github.com>","Pepijn de Vos <pepijndevos@gmail.com>","JooYoung <qkdlql@naver.com>","Tobias Speicher <rootcommander@gmail.com>","Steve Blaurock <sblaurock@gmail.com>","Kyrylo Shegeda <shegeda@ualberta.ca>","Diwank Singh Tomer <singh@diwank.name>","So\u0308ren Balko <Soeren.Balko@gmail.com>","Arpit Solanki <solankiarpit1997@gmail.com>","Yuki Ito <yuki@gnnk.net>","Artur Zayats <zag2art@gmail.com>"],"funding":{"type":"opencollective","url":"https://opencollective.com/peer"},"collective":{"type":"opencollective","url":"https://opencollective.com/peer"},"files":["dist/*"],"sideEffects":["lib/global.ts","lib/supports.ts"],"main":"dist/bundler.cjs","module":"dist/bundler.mjs","browser-minified":"dist/peerjs.min.js","browser-unminified":"dist/peerjs.js","types":"dist/types.d.ts","engines":{"node":">= 10"},"targets":{"types":{"source":"lib/exports.ts"},"main":{"source":"lib/exports.ts","sourceMap":{"inlineSources":true}},"module":{"source":"lib/exports.ts","includeNodeModules":["eventemitter3"],"sourceMap":{"inlineSources":true}},"browser-minified":{"context":"browser","outputFormat":"global","optimize":true,"engines":{"browsers":"cover 99%, not dead"},"source":"lib/global.ts"},"browser-unminified":{"context":"browser","outputFormat":"global","optimize":false,"engines":{"browsers":"cover 99%, not dead"},"source":"lib/global.ts"}},"scripts":{"contributors":"git-authors-cli --print=false && prettier --write package.json && git add package.json package-lock.json && git commit -m \\"chore(contributors): update and sort contributors list\\"","check":"tsc --noEmit","watch":"parcel watch","build":"rm -rf dist && parcel build","prepublishOnly":"npm run build","test":"mocha -r ts-node/register -r jsdom-global/register test/**/*.ts","format":"prettier --write .","semantic-release":"semantic-release"},"devDependencies":{"@parcel/config-default":"^2.5.0","@parcel/packager-ts":"^2.5.0","@parcel/transformer-typescript-tsc":"^2.5.0","@parcel/transformer-typescript-types":"^2.5.0","@semantic-release/changelog":"^6.0.1","@semantic-release/git":"^10.0.1","@types/chai":"^4.3.0","@types/mocha":"^9.1.0","@types/node":"^17.0.18","chai":"^4.3.6","git-authors-cli":"^1.0.40","jsdom":"^19.0.0","jsdom-global":"^3.0.2","mocha":"^9.2.0","mock-socket":"8.0.5","parcel":"^2.5.0","parcel-transformer-tsc-sourcemaps":"^1.0.2","prettier":"^2.6.2","semantic-release":"^19.0.2","standard":"^16.0.4","ts-node":"^10.5.0","typescript":"^4.5.5"},"dependencies":{"@swc/helpers":"^0.3.13","eventemitter3":"^4.0.7","peerjs-js-binarypack":"1.0.1","webrtc-adapter":"^7.7.1"}}');var Mu=function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var s in i)Object.prototype.hasOwnProperty.call(i,s)&&(n[s]=i[s])},r(e,t)};return function(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}}(),Cu=function(r,e){var t=typeof Symbol=="function"&&r[Symbol.iterator];if(!t)return r;var n=t.call(r),i,s=[],a;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)s.push(i.value)}catch(o){a={error:o}}finally{try{i&&!i.done&&(t=n.return)&&t.call(n)}finally{if(a)throw a.error}}return s},Eu=function(r,e,t){if(t||arguments.length===2)for(var n=0,i=e.length,s;n<i;n++)(s||!(n in e))&&(s||(s=Array.prototype.slice.call(e,0,n)),s[n]=e[n]);return r.concat(s||Array.prototype.slice.call(e))},Pu=function(r){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&r[e],n=0;if(t)return t.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&n>=r.length&&(r=void 0),{value:r&&r[n++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},lc=function(r){Mu(e,r);function e(t,n,i,s,a,o){o===void 0&&(o=5e3);var c=r.call(this)||this;c.pingInterval=o,c._disconnected=!0,c._messagesQueue=[];var l=t?"wss://":"ws://";return c._baseUrl=l+n+":"+i+s+"peerjs?key="+a,c}return e.prototype.start=function(t,n){var i=this;this._id=t;var s="".concat(this._baseUrl,"&id=").concat(t,"&token=").concat(n);this._socket||!this._disconnected||(this._socket=new WebSocket(s+"&version="+Ps.version),this._disconnected=!1,this._socket.onmessage=function(a){var o;try{o=JSON.parse(a.data),j.default.log("Server message received:",o)}catch{j.default.log("Invalid server message",a.data);return}i.emit(qt.Message,o)},this._socket.onclose=function(a){i._disconnected||(j.default.log("Socket closed.",a),i._cleanup(),i._disconnected=!0,i.emit(qt.Disconnected))},this._socket.onopen=function(){i._disconnected||(i._sendQueuedMessages(),j.default.log("Socket open"),i._scheduleHeartbeat())})},e.prototype._scheduleHeartbeat=function(){var t=this;this._wsPingTimer=setTimeout(function(){t._sendHeartbeat()},this.pingInterval)},e.prototype._sendHeartbeat=function(){if(!this._wsOpen()){j.default.log("Cannot send heartbeat, because socket closed");return}var t=JSON.stringify({type:Ie.Heartbeat});this._socket.send(t),this._scheduleHeartbeat()},e.prototype._wsOpen=function(){return!!this._socket&&this._socket.readyState===1},e.prototype._sendQueuedMessages=function(){var t,n,i=Eu([],Cu(this._messagesQueue),!1);this._messagesQueue=[];try{for(var s=Pu(i),a=s.next();!a.done;a=s.next()){var o=a.value;this.send(o)}}catch(c){t={error:c}}finally{try{a&&!a.done&&(n=s.return)&&n.call(s)}finally{if(t)throw t.error}}},e.prototype.send=function(t){if(!this._disconnected){if(!this._id){this._messagesQueue.push(t);return}if(!t.type){this.emit(qt.Error,"Invalid message");return}if(this._wsOpen()){var n=JSON.stringify(t);this._socket.send(n)}}},e.prototype.close=function(){this._disconnected||(this._cleanup(),this._disconnected=!0)},e.prototype._cleanup=function(){this._socket&&(this._socket.onopen=this._socket.onmessage=this._socket.onclose=null,this._socket.close(),this._socket=void 0),clearTimeout(this._wsPingTimer)},e}(ei.EventEmitter),ks={};zt(ks,"MediaConnection",()=>dc,r=>dc=r);var Rs={};zt(Rs,"Negotiator",()=>uc,r=>uc=r);var pr=function(){return pr=Object.assign||function(r){for(var e,t=1,n=arguments.length;t<n;t++){e=arguments[t];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(r[i]=e[i])}return r},pr.apply(this,arguments)},fr=function(r,e,t,n){function i(s){return s instanceof t?s:new t(function(a){a(s)})}return new(t||(t=Promise))(function(s,a){function o(u){try{l(n.next(u))}catch(p){a(p)}}function c(u){try{l(n.throw(u))}catch(p){a(p)}}function l(u){u.done?s(u.value):i(u.value).then(o,c)}l((n=n.apply(r,e||[])).next())})},mr=function(r,e){var t={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},n,i,s,a;return a={next:o(0),throw:o(1),return:o(2)},typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function o(l){return function(u){return c([l,u])}}function c(l){if(n)throw new TypeError("Generator is already executing.");for(;t;)try{if(n=1,i&&(s=l[0]&2?i.return:l[0]?i.throw||((s=i.return)&&s.call(i),0):i.next)&&!(s=s.call(i,l[1])).done)return s;switch(i=0,s&&(l=[l[0]&2,s.value]),l[0]){case 0:case 1:s=l;break;case 4:return t.label++,{value:l[1],done:!1};case 5:t.label++,i=l[1],l=[0];continue;case 7:l=t.ops.pop(),t.trys.pop();continue;default:if(s=t.trys,!(s=s.length>0&&s[s.length-1])&&(l[0]===6||l[0]===2)){t=0;continue}if(l[0]===3&&(!s||l[1]>s[0]&&l[1]<s[3])){t.label=l[1];break}if(l[0]===6&&t.label<s[1]){t.label=s[1],s=l;break}if(s&&t.label<s[2]){t.label=s[2],t.ops.push(l);break}s[2]&&t.ops.pop(),t.trys.pop();continue}l=e.call(r,t)}catch(u){l=[6,u],i=0}finally{n=s=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}},uc=function(){function r(e){this.connection=e}return r.prototype.startConnection=function(e){var t=this._startPeerConnection();if(this.connection.peerConnection=t,this.connection.type===Et.Media&&e._stream&&this._addTracksToConnection(e._stream,t),e.originator){if(this.connection.type===Et.Data){var n=this.connection,i={ordered:!!e.reliable},s=t.createDataChannel(n.label,i);n.initialize(s)}this._makeOffer()}else this.handleSDP("OFFER",e.sdp)},r.prototype._startPeerConnection=function(){j.default.log("Creating RTCPeerConnection.");var e=new RTCPeerConnection(this.connection.provider.options.config);return this._setupListeners(e),e},r.prototype._setupListeners=function(e){var t=this,n=this.connection.peer,i=this.connection.connectionId,s=this.connection.type,a=this.connection.provider;j.default.log("Listening for ICE candidates."),e.onicecandidate=function(o){!o.candidate||!o.candidate.candidate||(j.default.log("Received ICE candidates for ".concat(n,":"),o.candidate),a.socket.send({type:Ie.Candidate,payload:{candidate:o.candidate,type:s,connectionId:i},dst:n}))},e.oniceconnectionstatechange=function(){switch(e.iceConnectionState){case"failed":j.default.log("iceConnectionState is failed, closing connections to "+n),t.connection.emit("error",new Error("Negotiation of connection to "+n+" failed.")),t.connection.close();break;case"closed":j.default.log("iceConnectionState is closed, closing connections to "+n),t.connection.emit("error",new Error("Connection to "+n+" closed.")),t.connection.close();break;case"disconnected":j.default.log("iceConnectionState changed to disconnected on the connection with "+n);break;case"completed":e.onicecandidate=te.noop;break}t.connection.emit("iceStateChanged",e.iceConnectionState)},j.default.log("Listening for data channel"),e.ondatachannel=function(o){j.default.log("Received data channel");var c=o.channel,l=a.getConnection(n,i);l.initialize(c)},j.default.log("Listening for remote stream"),e.ontrack=function(o){j.default.log("Received remote stream");var c=o.streams[0],l=a.getConnection(n,i);if(l.type===Et.Media){var u=l;t._addStreamToMediaConnection(c,u)}}},r.prototype.cleanup=function(){j.default.log("Cleaning up PeerConnection to "+this.connection.peer);var e=this.connection.peerConnection;if(e){this.connection.peerConnection=null,e.onicecandidate=e.oniceconnectionstatechange=e.ondatachannel=e.ontrack=function(){};var t=e.signalingState!=="closed",n=!1;if(this.connection.type===Et.Data){var i=this.connection,s=i.dataChannel;s&&(n=!!s.readyState&&s.readyState!=="closed")}(t||n)&&e.close()}},r.prototype._makeOffer=function(){return fr(this,void 0,Promise,function(){var e,t,n,i,s,a,o;return mr(this,function(c){switch(c.label){case 0:e=this.connection.peerConnection,t=this.connection.provider,c.label=1;case 1:return c.trys.push([1,7,,8]),[4,e.createOffer(this.connection.options.constraints)];case 2:n=c.sent(),j.default.log("Created offer."),this.connection.options.sdpTransform&&typeof this.connection.options.sdpTransform=="function"&&(n.sdp=this.connection.options.sdpTransform(n.sdp)||n.sdp),c.label=3;case 3:return c.trys.push([3,5,,6]),[4,e.setLocalDescription(n)];case 4:return c.sent(),j.default.log("Set localDescription:",n,"for:".concat(this.connection.peer)),i={sdp:n,type:this.connection.type,connectionId:this.connection.connectionId,metadata:this.connection.metadata,browser:te.browser},this.connection.type===Et.Data&&(s=this.connection,i=pr(pr({},i),{label:s.label,reliable:s.reliable,serialization:s.serialization})),t.socket.send({type:Ie.Offer,payload:i,dst:this.connection.peer}),[3,6];case 5:return a=c.sent(),a!="OperationError: Failed to set local offer sdp: Called in wrong state: kHaveRemoteOffer"&&(t.emitError(be.WebRTC,a),j.default.log("Failed to setLocalDescription, ",a)),[3,6];case 6:return[3,8];case 7:return o=c.sent(),t.emitError(be.WebRTC,o),j.default.log("Failed to createOffer, ",o),[3,8];case 8:return[2]}})})},r.prototype._makeAnswer=function(){return fr(this,void 0,Promise,function(){var e,t,n,i,s;return mr(this,function(a){switch(a.label){case 0:e=this.connection.peerConnection,t=this.connection.provider,a.label=1;case 1:return a.trys.push([1,7,,8]),[4,e.createAnswer()];case 2:n=a.sent(),j.default.log("Created answer."),this.connection.options.sdpTransform&&typeof this.connection.options.sdpTransform=="function"&&(n.sdp=this.connection.options.sdpTransform(n.sdp)||n.sdp),a.label=3;case 3:return a.trys.push([3,5,,6]),[4,e.setLocalDescription(n)];case 4:return a.sent(),j.default.log("Set localDescription:",n,"for:".concat(this.connection.peer)),t.socket.send({type:Ie.Answer,payload:{sdp:n,type:this.connection.type,connectionId:this.connection.connectionId,browser:te.browser},dst:this.connection.peer}),[3,6];case 5:return i=a.sent(),t.emitError(be.WebRTC,i),j.default.log("Failed to setLocalDescription, ",i),[3,6];case 6:return[3,8];case 7:return s=a.sent(),t.emitError(be.WebRTC,s),j.default.log("Failed to create answer, ",s),[3,8];case 8:return[2]}})})},r.prototype.handleSDP=function(e,t){return fr(this,void 0,Promise,function(){var n,i,s,a;return mr(this,function(o){switch(o.label){case 0:t=new RTCSessionDescription(t),n=this.connection.peerConnection,i=this.connection.provider,j.default.log("Setting remote description",t),s=this,o.label=1;case 1:return o.trys.push([1,5,,6]),[4,n.setRemoteDescription(t)];case 2:return o.sent(),j.default.log("Set remoteDescription:".concat(e," for:").concat(this.connection.peer)),e!=="OFFER"?[3,4]:[4,s._makeAnswer()];case 3:o.sent(),o.label=4;case 4:return[3,6];case 5:return a=o.sent(),i.emitError(be.WebRTC,a),j.default.log("Failed to setRemoteDescription, ",a),[3,6];case 6:return[2]}})})},r.prototype.handleCandidate=function(e){return fr(this,void 0,Promise,function(){var t,n,i,s,a,o;return mr(this,function(c){switch(c.label){case 0:j.default.log("handleCandidate:",e),t=e.candidate,n=e.sdpMLineIndex,i=e.sdpMid,s=this.connection.peerConnection,a=this.connection.provider,c.label=1;case 1:return c.trys.push([1,3,,4]),[4,s.addIceCandidate(new RTCIceCandidate({sdpMid:i,sdpMLineIndex:n,candidate:t}))];case 2:return c.sent(),j.default.log("Added ICE candidate for:".concat(this.connection.peer)),[3,4];case 3:return o=c.sent(),a.emitError(be.WebRTC,o),j.default.log("Failed to handleCandidate, ",o),[3,4];case 4:return[2]}})})},r.prototype._addTracksToConnection=function(e,t){if(j.default.log("add tracks from stream ".concat(e.id," to peer connection")),!t.addTrack)return j.default.error("Your browser does't support RTCPeerConnection#addTrack. Ignored.");e.getTracks().forEach(function(n){t.addTrack(n,e)})},r.prototype._addStreamToMediaConnection=function(e,t){j.default.log("add stream ".concat(e.id," to media connection ").concat(t.connectionId)),t.addStream(e)},r}(),As={};zt(As,"BaseConnection",()=>hc,r=>hc=r);var ku=function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var s in i)Object.prototype.hasOwnProperty.call(i,s)&&(n[s]=i[s])},r(e,t)};return function(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}}(),hc=function(r){ku(e,r);function e(t,n,i){var s=r.call(this)||this;return s.peer=t,s.provider=n,s.options=i,s._open=!1,s.metadata=i.metadata,s}return Object.defineProperty(e.prototype,"open",{get:function(){return this._open},enumerable:!1,configurable:!0}),e}(ei.EventEmitter),Ru=function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var s in i)Object.prototype.hasOwnProperty.call(i,s)&&(n[s]=i[s])},r(e,t)};return function(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}}(),yr=function(){return yr=Object.assign||function(r){for(var e,t=1,n=arguments.length;t<n;t++){e=arguments[t];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(r[i]=e[i])}return r},yr.apply(this,arguments)},Au=function(r){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&r[e],n=0;if(t)return t.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&n>=r.length&&(r=void 0),{value:r&&r[n++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},dc=function(r){Ru(e,r);function e(t,n,i){var s=r.call(this,t,n,i)||this;return s._localStream=s.options._stream,s.connectionId=s.options.connectionId||e.ID_PREFIX+te.randomToken(),s._negotiator=new Rs.Negotiator(s),s._localStream&&s._negotiator.startConnection({_stream:s._localStream,originator:!0}),s}return Object.defineProperty(e.prototype,"type",{get:function(){return Et.Media},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"localStream",{get:function(){return this._localStream},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"remoteStream",{get:function(){return this._remoteStream},enumerable:!1,configurable:!0}),e.prototype.addStream=function(t){j.default.log("Receiving stream",t),this._remoteStream=t,r.prototype.emit.call(this,"stream",t)},e.prototype.handleMessage=function(t){var n=t.type,i=t.payload;switch(t.type){case Ie.Answer:this._negotiator.handleSDP(n,i.sdp),this._open=!0;break;case Ie.Candidate:this._negotiator.handleCandidate(i.candidate);break;default:j.default.warn("Unrecognized message type:".concat(n," from peer:").concat(this.peer));break}},e.prototype.answer=function(t,n){var i,s;if(n===void 0&&(n={}),this._localStream){j.default.warn("Local stream already exists on this MediaConnection. Are you answering a call twice?");return}this._localStream=t,n&&n.sdpTransform&&(this.options.sdpTransform=n.sdpTransform),this._negotiator.startConnection(yr(yr({},this.options._payload),{_stream:t}));var a=this.provider._getMessages(this.connectionId);try{for(var o=Au(a),c=o.next();!c.done;c=o.next()){var l=c.value;this.handleMessage(l)}}catch(u){i={error:u}}finally{try{c&&!c.done&&(s=o.return)&&s.call(o)}finally{if(i)throw i.error}}this._open=!0},e.prototype.close=function(){this._negotiator&&(this._negotiator.cleanup(),this._negotiator=null),this._localStream=null,this._remoteStream=null,this.provider&&(this.provider._removeConnection(this),this.provider=null),this.options&&this.options._stream&&(this.options._stream=null),this.open&&(this._open=!1,r.prototype.emit.call(this,"close"))},e.ID_PREFIX="mc_",e}(As.BaseConnection),Os={};zt(Os,"DataConnection",()=>mc,r=>mc=r);var pc={};zt(pc,"EncodingQueue",()=>fc,r=>fc=r);var Ou=function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var s in i)Object.prototype.hasOwnProperty.call(i,s)&&(n[s]=i[s])},r(e,t)};return function(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}}(),fc=function(r){Ou(e,r);function e(){var t=r.call(this)||this;return t.fileReader=new FileReader,t._queue=[],t._processing=!1,t.fileReader.onload=function(n){t._processing=!1,n.target&&t.emit("done",n.target.result),t.doNextTask()},t.fileReader.onerror=function(n){j.default.error("EncodingQueue error:",n),t._processing=!1,t.destroy(),t.emit("error",n)},t}return Object.defineProperty(e.prototype,"queue",{get:function(){return this._queue},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"size",{get:function(){return this.queue.length},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"processing",{get:function(){return this._processing},enumerable:!1,configurable:!0}),e.prototype.enque=function(t){this.queue.push(t),!this.processing&&this.doNextTask()},e.prototype.destroy=function(){this.fileReader.abort(),this._queue=[]},e.prototype.doNextTask=function(){this.size!==0&&(this.processing||(this._processing=!0,this.fileReader.readAsArrayBuffer(this.queue.shift())))},e}(ei.EventEmitter),Iu=function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var s in i)Object.prototype.hasOwnProperty.call(i,s)&&(n[s]=i[s])},r(e,t)};return function(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}}(),zu=function(r){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&r[e],n=0;if(t)return t.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&n>=r.length&&(r=void 0),{value:r&&r[n++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},mc=function(r){Iu(e,r);function e(t,n,i){var s=r.call(this,t,n,i)||this;return s.stringify=JSON.stringify,s.parse=JSON.parse,s._buffer=[],s._bufferSize=0,s._buffering=!1,s._chunkedData={},s._encodingQueue=new pc.EncodingQueue,s.connectionId=s.options.connectionId||e.ID_PREFIX+te.randomToken(),s.label=s.options.label||s.connectionId,s.serialization=s.options.serialization||Ht.Binary,s.reliable=!!s.options.reliable,s._encodingQueue.on("done",function(a){s._bufferedSend(a)}),s._encodingQueue.on("error",function(){j.default.error("DC#".concat(s.connectionId,": Error occured in encoding from blob to arraybuffer, close DC")),s.close()}),s._negotiator=new Rs.Negotiator(s),s._negotiator.startConnection(s.options._payload||{originator:!0}),s}return Object.defineProperty(e.prototype,"type",{get:function(){return Et.Data},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"dataChannel",{get:function(){return this._dc},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"bufferSize",{get:function(){return this._bufferSize},enumerable:!1,configurable:!0}),e.prototype.initialize=function(t){this._dc=t,this._configureDataChannel()},e.prototype._configureDataChannel=function(){var t=this;(!te.supports.binaryBlob||te.supports.reliable)&&(this.dataChannel.binaryType="arraybuffer"),this.dataChannel.onopen=function(){j.default.log("DC#".concat(t.connectionId," dc connection success")),t._open=!0,t.emit("open")},this.dataChannel.onmessage=function(n){j.default.log("DC#".concat(t.connectionId," dc onmessage:"),n.data),t._handleDataMessage(n)},this.dataChannel.onclose=function(){j.default.log("DC#".concat(t.connectionId," dc closed for:"),t.peer),t.close()}},e.prototype._handleDataMessage=function(t){var n=this,i=t.data,s=i.constructor,a=this.serialization===Ht.Binary||this.serialization===Ht.BinaryUTF8,o=i;if(a){if(s===Blob){te.blobToArrayBuffer(i,function(l){var u=te.unpack(l);n.emit("data",u)});return}else if(s===ArrayBuffer)o=te.unpack(i);else if(s===String){var c=te.binaryStringToArrayBuffer(i);o=te.unpack(c)}}else this.serialization===Ht.JSON&&(o=this.parse(i));if(o.__peerData){this._handleChunk(o);return}r.prototype.emit.call(this,"data",o)},e.prototype._handleChunk=function(t){var n=t.__peerData,i=this._chunkedData[n]||{data:[],count:0,total:t.total};if(i.data[t.n]=t.data,i.count++,this._chunkedData[n]=i,i.total===i.count){delete this._chunkedData[n];var s=new Blob(i.data);this._handleDataMessage({data:s})}},e.prototype.close=function(){this._buffer=[],this._bufferSize=0,this._chunkedData={},this._negotiator&&(this._negotiator.cleanup(),this._negotiator=null),this.provider&&(this.provider._removeConnection(this),this.provider=null),this.dataChannel&&(this.dataChannel.onopen=null,this.dataChannel.onmessage=null,this.dataChannel.onclose=null,this._dc=null),this._encodingQueue&&(this._encodingQueue.destroy(),this._encodingQueue.removeAllListeners(),this._encodingQueue=null),this.open&&(this._open=!1,r.prototype.emit.call(this,"close"))},e.prototype.send=function(t,n){if(!this.open){r.prototype.emit.call(this,"error",new Error("Connection is not open. You should listen for the `open` event before sending messages."));return}if(this.serialization===Ht.JSON)this._bufferedSend(this.stringify(t));else if(this.serialization===Ht.Binary||this.serialization===Ht.BinaryUTF8){var i=te.pack(t);if(!n&&i.size>te.chunkedMTU){this._sendChunks(i);return}te.supports.binaryBlob?this._bufferedSend(i):this._encodingQueue.enque(i)}else this._bufferedSend(t)},e.prototype._bufferedSend=function(t){(this._buffering||!this._trySend(t))&&(this._buffer.push(t),this._bufferSize=this._buffer.length)},e.prototype._trySend=function(t){var n=this;if(!this.open)return!1;if(this.dataChannel.bufferedAmount>e.MAX_BUFFERED_AMOUNT)return this._buffering=!0,setTimeout(function(){n._buffering=!1,n._tryBuffer()},50),!1;try{this.dataChannel.send(t)}catch(i){return j.default.error("DC#:".concat(this.connectionId," Error when sending:"),i),this._buffering=!0,this.close(),!1}return!0},e.prototype._tryBuffer=function(){if(this.open&&this._buffer.length!==0){var t=this._buffer[0];this._trySend(t)&&(this._buffer.shift(),this._bufferSize=this._buffer.length,this._tryBuffer())}},e.prototype._sendChunks=function(t){var n,i,s=te.chunk(t);j.default.log("DC#".concat(this.connectionId," Try to send ").concat(s.length," chunks..."));try{for(var a=zu(s),o=a.next();!o.done;o=a.next()){var c=o.value;this.send(c,!0)}}catch(l){n={error:l}}finally{try{o&&!o.done&&(i=a.return)&&i.call(a)}finally{if(n)throw n.error}}},e.prototype.handleMessage=function(t){var n=t.payload;switch(t.type){case Ie.Answer:this._negotiator.handleSDP(t.type,n.sdp);break;case Ie.Candidate:this._negotiator.handleCandidate(n.candidate);break;default:j.default.warn("Unrecognized message type:",t.type,"from peer:",this.peer);break}},e.ID_PREFIX="dc_",e.MAX_BUFFERED_AMOUNT=8388608,e}(As.BaseConnection),yc={};zt(yc,"API",()=>Sc,r=>Sc=r);var gc=function(r,e,t,n){function i(s){return s instanceof t?s:new t(function(a){a(s)})}return new(t||(t=Promise))(function(s,a){function o(u){try{l(n.next(u))}catch(p){a(p)}}function c(u){try{l(n.throw(u))}catch(p){a(p)}}function l(u){u.done?s(u.value):i(u.value).then(o,c)}l((n=n.apply(r,e||[])).next())})},vc=function(r,e){var t={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},n,i,s,a;return a={next:o(0),throw:o(1),return:o(2)},typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function o(l){return function(u){return c([l,u])}}function c(l){if(n)throw new TypeError("Generator is already executing.");for(;t;)try{if(n=1,i&&(s=l[0]&2?i.return:l[0]?i.throw||((s=i.return)&&s.call(i),0):i.next)&&!(s=s.call(i,l[1])).done)return s;switch(i=0,s&&(l=[l[0]&2,s.value]),l[0]){case 0:case 1:s=l;break;case 4:return t.label++,{value:l[1],done:!1};case 5:t.label++,i=l[1],l=[0];continue;case 7:l=t.ops.pop(),t.trys.pop();continue;default:if(s=t.trys,!(s=s.length>0&&s[s.length-1])&&(l[0]===6||l[0]===2)){t=0;continue}if(l[0]===3&&(!s||l[1]>s[0]&&l[1]<s[3])){t.label=l[1];break}if(l[0]===6&&t.label<s[1]){t.label=s[1],s=l;break}if(s&&t.label<s[2]){t.label=s[2],t.ops.push(l);break}s[2]&&t.ops.pop(),t.trys.pop();continue}l=e.call(r,t)}catch(u){l=[6,u],i=0}finally{n=s=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}},Sc=function(){function r(e){this._options=e}return r.prototype._buildRequest=function(e){var t=this._options.secure?"https":"http",n=this._options,i=n.host,s=n.port,a=n.path,o=n.key,c=new URL("".concat(t,"://").concat(i,":").concat(s).concat(a).concat(o,"/").concat(e));return c.searchParams.set("ts","".concat(Date.now()).concat(Math.random())),c.searchParams.set("version",Ps.version),fetch(c.href,{referrerPolicy:this._options.referrerPolicy})},r.prototype.retrieveId=function(){return gc(this,void 0,Promise,function(){var e,t,n;return vc(this,function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,this._buildRequest("id")];case 1:if(e=i.sent(),e.status!==200)throw new Error("Error. Status:".concat(e.status));return[2,e.text()];case 2:throw t=i.sent(),j.default.error("Error retrieving ID",t),n="",this._options.path==="/"&&this._options.host!==te.CLOUD_HOST&&(n=" If you passed in a `path` to your self-hosted PeerServer, you'll also need to pass in that same path when creating a new Peer."),new Error("Could not get an ID from the server."+n);case 3:return[2]}})})},r.prototype.listAllPeers=function(){return gc(this,void 0,Promise,function(){var e,t,n;return vc(this,function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,this._buildRequest("peers")];case 1:if(e=i.sent(),e.status!==200)throw e.status===401?(t="",this._options.host===te.CLOUD_HOST?t="It looks like you're using the cloud server. You can email team@peerjs.com to enable peer listing for your API key.":t="You need to enable `allow_discovery` on your self-hosted PeerServer to use this feature.",new Error("It doesn't look like you have permission to list peers IDs. "+t)):new Error("Error. Status:".concat(e.status));return[2,e.json()];case 2:throw n=i.sent(),j.default.error("Error retrieving list peers",n),new Error("Could not get list peers from the server."+n);case 3:return[2]}})})},r}(),Bu=function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var s in i)Object.prototype.hasOwnProperty.call(i,s)&&(n[s]=i[s])},r(e,t)};return function(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}}(),ni=function(){return ni=Object.assign||function(r){for(var e,t=1,n=arguments.length;t<n;t++){e=arguments[t];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(r[i]=e[i])}return r},ni.apply(this,arguments)},ii=function(r){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&r[e],n=0;if(t)return t.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&n>=r.length&&(r=void 0),{value:r&&r[n++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},Nu=function(r,e){var t=typeof Symbol=="function"&&r[Symbol.iterator];if(!t)return r;var n=t.call(r),i,s=[],a;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)s.push(i.value)}catch(o){a={error:o}}finally{try{i&&!i.done&&(t=n.return)&&t.call(n)}finally{if(a)throw a.error}}return s},Is=function(r){Bu(e,r);function e(t,n){var i=r.call(this)||this;i._id=null,i._lastServerId=null,i._destroyed=!1,i._disconnected=!1,i._open=!1,i._connections=new Map,i._lostMessages=new Map;var s;return t&&t.constructor==Object?n=t:t&&(s=t.toString()),n=ni({debug:0,host:te.CLOUD_HOST,port:te.CLOUD_PORT,path:"/",key:e.DEFAULT_KEY,token:te.randomToken(),config:te.defaultConfig,referrerPolicy:"strict-origin-when-cross-origin"},n),i._options=n,i._options.host==="/"&&(i._options.host=window.location.hostname),i._options.path&&(i._options.path[0]!=="/"&&(i._options.path="/"+i._options.path),i._options.path[i._options.path.length-1]!=="/"&&(i._options.path+="/")),i._options.secure===void 0&&i._options.host!==te.CLOUD_HOST?i._options.secure=te.isSecure():i._options.host==te.CLOUD_HOST&&(i._options.secure=!0),i._options.logFunction&&j.default.setLogFunction(i._options.logFunction),j.default.logLevel=i._options.debug||0,i._api=new yc.API(n),i._socket=i._createServerConnection(),!te.supports.audioVideo&&!te.supports.data?(i._delayedAbort(be.BrowserIncompatible,"The current browser does not support WebRTC"),i):s&&!te.validateId(s)?(i._delayedAbort(be.InvalidID,'ID "'.concat(s,'" is invalid')),i):(s?i._initialize(s):i._api.retrieveId().then(function(a){return i._initialize(a)}).catch(function(a){return i._abort(be.ServerError,a)}),i)}return Object.defineProperty(e.prototype,"id",{get:function(){return this._id},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"options",{get:function(){return this._options},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"open",{get:function(){return this._open},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"socket",{get:function(){return this._socket},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"connections",{get:function(){var t,n,i=Object.create(null);try{for(var s=ii(this._connections),a=s.next();!a.done;a=s.next()){var o=Nu(a.value,2),c=o[0],l=o[1];i[c]=l}}catch(u){t={error:u}}finally{try{a&&!a.done&&(n=s.return)&&n.call(s)}finally{if(t)throw t.error}}return i},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"destroyed",{get:function(){return this._destroyed},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"disconnected",{get:function(){return this._disconnected},enumerable:!1,configurable:!0}),e.prototype._createServerConnection=function(){var t=this,n=new cc.Socket(this._options.secure,this._options.host,this._options.port,this._options.path,this._options.key,this._options.pingInterval);return n.on(qt.Message,function(i){t._handleMessage(i)}),n.on(qt.Error,function(i){t._abort(be.SocketError,i)}),n.on(qt.Disconnected,function(){t.disconnected||(t.emitError(be.Network,"Lost connection to server."),t.disconnect())}),n.on(qt.Close,function(){t.disconnected||t._abort(be.SocketClosed,"Underlying socket is already closed.")}),n},e.prototype._initialize=function(t){this._id=t,this.socket.start(t,this._options.token)},e.prototype._handleMessage=function(t){var n,i,s=t.type,a=t.payload,o=t.src;switch(s){case Ie.Open:this._lastServerId=this.id,this._open=!0,this.emit("open",this.id);break;case Ie.Error:this._abort(be.ServerError,a.msg);break;case Ie.IdTaken:this._abort(be.UnavailableID,'ID "'.concat(this.id,'" is taken'));break;case Ie.InvalidKey:this._abort(be.InvalidKey,'API KEY "'.concat(this._options.key,'" is invalid'));break;case Ie.Leave:j.default.log("Received leave message from ".concat(o)),this._cleanupPeer(o),this._connections.delete(o);break;case Ie.Expire:this.emitError(be.PeerUnavailable,"Could not connect to peer ".concat(o));break;case Ie.Offer:var b=a.connectionId,x=this.getConnection(o,b);if(x&&(x.close(),j.default.warn("Offer received for existing Connection ID:".concat(b))),a.type===Et.Media){var c=new ks.MediaConnection(o,this,{connectionId:b,_payload:a,metadata:a.metadata});x=c,this._addConnection(o,x),this.emit("call",c)}else if(a.type===Et.Data){var l=new Os.DataConnection(o,this,{connectionId:b,_payload:a,metadata:a.metadata,label:a.label,serialization:a.serialization,reliable:a.reliable});x=l,this._addConnection(o,x),this.emit("connection",l)}else{j.default.warn("Received malformed connection type:".concat(a.type));return}var u=this._getMessages(b);try{for(var p=ii(u),f=p.next();!f.done;f=p.next()){var m=f.value;x.handleMessage(m)}}catch(g){n={error:g}}finally{try{f&&!f.done&&(i=p.return)&&i.call(p)}finally{if(n)throw n.error}}break;default:if(!a){j.default.warn("You received a malformed message from ".concat(o," of type ").concat(s));return}var b=a.connectionId,x=this.getConnection(o,b);x&&x.peerConnection?x.handleMessage(t):b?this._storeMessage(b,t):j.default.warn("You received an unrecognized message:",t);break}},e.prototype._storeMessage=function(t,n){this._lostMessages.has(t)||this._lostMessages.set(t,[]),this._lostMessages.get(t).push(n)},e.prototype._getMessages=function(t){var n=this._lostMessages.get(t);return n?(this._lostMessages.delete(t),n):[]},e.prototype.connect=function(t,n){if(n===void 0&&(n={}),this.disconnected){j.default.warn("You cannot connect to a new Peer because you called .disconnect() on this Peer and ended your connection with the server. You can create a new Peer to reconnect, or call reconnect on this peer if you believe its ID to still be available."),this.emitError(be.Disconnected,"Cannot connect to new Peer after disconnecting from server.");return}var i=new Os.DataConnection(t,this,n);return this._addConnection(t,i),i},e.prototype.call=function(t,n,i){if(i===void 0&&(i={}),this.disconnected){j.default.warn("You cannot connect to a new Peer because you called .disconnect() on this Peer and ended your connection with the server. You can create a new Peer to reconnect."),this.emitError(be.Disconnected,"Cannot connect to new Peer after disconnecting from server.");return}if(!n){j.default.error("To call a peer, you must provide a stream from your browser's `getUserMedia`.");return}var s=new ks.MediaConnection(t,this,ni(ni({},i),{_stream:n}));return this._addConnection(t,s),s},e.prototype._addConnection=function(t,n){j.default.log("add connection ".concat(n.type,":").concat(n.connectionId," to peerId:").concat(t)),this._connections.has(t)||this._connections.set(t,[]),this._connections.get(t).push(n)},e.prototype._removeConnection=function(t){var n=this._connections.get(t.peer);if(n){var i=n.indexOf(t);i!==-1&&n.splice(i,1)}this._lostMessages.delete(t.connectionId)},e.prototype.getConnection=function(t,n){var i,s,a=this._connections.get(t);if(!a)return null;try{for(var o=ii(a),c=o.next();!c.done;c=o.next()){var l=c.value;if(l.connectionId===n)return l}}catch(u){i={error:u}}finally{try{c&&!c.done&&(s=o.return)&&s.call(o)}finally{if(i)throw i.error}}return null},e.prototype._delayedAbort=function(t,n){var i=this;setTimeout(function(){i._abort(t,n)},0)},e.prototype._abort=function(t,n){j.default.error("Aborting!"),this.emitError(t,n),this._lastServerId?this.disconnect():this.destroy()},e.prototype.emitError=function(t,n){j.default.error("Error:",n);var i;typeof n=="string"?i=new Error(n):i=n,i.type=t,this.emit("error",i)},e.prototype.destroy=function(){this.destroyed||(j.default.log("Destroy peer with ID:".concat(this.id)),this.disconnect(),this._cleanup(),this._destroyed=!0,this.emit("close"))},e.prototype._cleanup=function(){var t,n;try{for(var i=ii(this._connections.keys()),s=i.next();!s.done;s=i.next()){var a=s.value;this._cleanupPeer(a),this._connections.delete(a)}}catch(o){t={error:o}}finally{try{s&&!s.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}this.socket.removeAllListeners()},e.prototype._cleanupPeer=function(t){var n,i,s=this._connections.get(t);if(s)try{for(var a=ii(s),o=a.next();!o.done;o=a.next()){var c=o.value;c.close()}}catch(l){n={error:l}}finally{try{o&&!o.done&&(i=a.return)&&i.call(a)}finally{if(n)throw n.error}}},e.prototype.disconnect=function(){if(!this.disconnected){var t=this.id;j.default.log("Disconnect peer with ID:".concat(t)),this._disconnected=!0,this._open=!1,this.socket.close(),this._lastServerId=t,this._id=null,this.emit("disconnected",t)}},e.prototype.reconnect=function(){if(this.disconnected&&!this.destroyed)j.default.log("Attempting reconnection to server with ID ".concat(this._lastServerId)),this._disconnected=!1,this._initialize(this._lastServerId);else{if(this.destroyed)throw new Error("This peer cannot reconnect to the server. It has already been destroyed.");if(!this.disconnected&&!this.open)j.default.error("In a hurry? We're still trying to make the initial connection!");else throw new Error("Peer ".concat(this.id," cannot reconnect because it is not disconnected from the server!"))}},e.prototype.listAllPeers=function(t){var n=this;t===void 0&&(t=function(i){}),this._api.listAllPeers().then(function(i){return t(i)}).catch(function(i){return n._abort(be.ServerError,i)})},e.DEFAULT_KEY="peerjs",e}(ei.EventEmitter),bc=sc.Peer;const Uu=Object.freeze(Object.defineProperty({__proto__:null,get Peer(){return Is},default:bc,util:te},Symbol.toStringTag,{value:"Module"})),Du=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function Lu(r){return typeof r=="string"&&Du.test(r)}const ze=[];for(let r=0;r<256;++r)ze.push((r+256).toString(16).slice(1));function Fu(r,e=0){return ze[r[e+0]]+ze[r[e+1]]+ze[r[e+2]]+ze[r[e+3]]+"-"+ze[r[e+4]]+ze[r[e+5]]+"-"+ze[r[e+6]]+ze[r[e+7]]+"-"+ze[r[e+8]]+ze[r[e+9]]+"-"+ze[r[e+10]]+ze[r[e+11]]+ze[r[e+12]]+ze[r[e+13]]+ze[r[e+14]]+ze[r[e+15]]}function Vu(r){if(!Lu(r))throw TypeError("Invalid UUID");let e;const t=new Uint8Array(16);return t[0]=(e=parseInt(r.slice(0,8),16))>>>24,t[1]=e>>>16&255,t[2]=e>>>8&255,t[3]=e&255,t[4]=(e=parseInt(r.slice(9,13),16))>>>8,t[5]=e&255,t[6]=(e=parseInt(r.slice(14,18),16))>>>8,t[7]=e&255,t[8]=(e=parseInt(r.slice(19,23),16))>>>8,t[9]=e&255,t[10]=(e=parseInt(r.slice(24,36),16))/1099511627776&255,t[11]=e/4294967296&255,t[12]=e>>>24&255,t[13]=e>>>16&255,t[14]=e>>>8&255,t[15]=e&255,t}function ju(r){r=unescape(encodeURIComponent(r));const e=[];for(let t=0;t<r.length;++t)e.push(r.charCodeAt(t));return e}const Ju="6ba7b810-9dad-11d1-80b4-00c04fd430c8",Gu="6ba7b811-9dad-11d1-80b4-00c04fd430c8";function Wu(r,e,t){function n(i,s,a,o){var c;if(typeof i=="string"&&(i=ju(i)),typeof s=="string"&&(s=Vu(s)),((c=s)===null||c===void 0?void 0:c.length)!==16)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");let l=new Uint8Array(16+i.length);if(l.set(s),l.set(i,s.length),l=t(l),l[6]=l[6]&15|e,l[8]=l[8]&63|128,a){o=o||0;for(let u=0;u<16;++u)a[o+u]=l[u];return a}return Fu(l)}try{n.name=r}catch{}return n.DNS=Ju,n.URL=Gu,n}function Hu(r,e,t,n){switch(r){case 0:return e&t^~e&n;case 1:return e^t^n;case 2:return e&t^e&n^t&n;case 3:return e^t^n}}function zs(r,e){return r<<e|r>>>32-e}function qu(r){const e=[1518500249,1859775393,2400959708,3395469782],t=[1732584193,4023233417,2562383102,271733878,3285377520];if(typeof r=="string"){const a=unescape(encodeURIComponent(r));r=[];for(let o=0;o<a.length;++o)r.push(a.charCodeAt(o))}else Array.isArray(r)||(r=Array.prototype.slice.call(r));r.push(128);const n=r.length/4+2,i=Math.ceil(n/16),s=new Array(i);for(let a=0;a<i;++a){const o=new Uint32Array(16);for(let c=0;c<16;++c)o[c]=r[a*64+c*4]<<24|r[a*64+c*4+1]<<16|r[a*64+c*4+2]<<8|r[a*64+c*4+3];s[a]=o}s[i-1][14]=(r.length-1)*8/Math.pow(2,32),s[i-1][14]=Math.floor(s[i-1][14]),s[i-1][15]=(r.length-1)*8&4294967295;for(let a=0;a<i;++a){const o=new Uint32Array(80);for(let m=0;m<16;++m)o[m]=s[a][m];for(let m=16;m<80;++m)o[m]=zs(o[m-3]^o[m-8]^o[m-14]^o[m-16],1);let c=t[0],l=t[1],u=t[2],p=t[3],f=t[4];for(let m=0;m<80;++m){const b=Math.floor(m/20),x=zs(c,5)+Hu(b,l,u,p)+f+e[b]+o[m]>>>0;f=p,p=u,u=zs(l,30)>>>0,l=c,c=x}t[0]=t[0]+c>>>0,t[1]=t[1]+l>>>0,t[2]=t[2]+u>>>0,t[3]=t[3]+p>>>0,t[4]=t[4]+f>>>0}return[t[0]>>24&255,t[0]>>16&255,t[0]>>8&255,t[0]&255,t[1]>>24&255,t[1]>>16&255,t[1]>>8&255,t[1]&255,t[2]>>24&255,t[2]>>16&255,t[2]>>8&255,t[2]&255,t[3]>>24&255,t[3]>>16&255,t[3]>>8&255,t[3]&255,t[4]>>24&255,t[4]>>16&255,t[4]>>8&255,t[4]&255]}const Xu=Wu("v5",80,qu);var xc={exports:{}},wc={exports:{}},_c;function Yu(){return _c||(_c=1,function(){var r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",e={rotl:function(t,n){return t<<n|t>>>32-n},rotr:function(t,n){return t<<32-n|t>>>n},endian:function(t){if(t.constructor==Number)return e.rotl(t,8)&16711935|e.rotl(t,24)&4278255360;for(var n=0;n<t.length;n++)t[n]=e.endian(t[n]);return t},randomBytes:function(t){for(var n=[];t>0;t--)n.push(Math.floor(Math.random()*256));return n},bytesToWords:function(t){for(var n=[],i=0,s=0;i<t.length;i++,s+=8)n[s>>>5]|=t[i]<<24-s%32;return n},wordsToBytes:function(t){for(var n=[],i=0;i<t.length*32;i+=8)n.push(t[i>>>5]>>>24-i%32&255);return n},bytesToHex:function(t){for(var n=[],i=0;i<t.length;i++)n.push((t[i]>>>4).toString(16)),n.push((t[i]&15).toString(16));return n.join("")},hexToBytes:function(t){for(var n=[],i=0;i<t.length;i+=2)n.push(parseInt(t.substr(i,2),16));return n},bytesToBase64:function(t){for(var n=[],i=0;i<t.length;i+=3)for(var s=t[i]<<16|t[i+1]<<8|t[i+2],a=0;a<4;a++)i*8+a*6<=t.length*8?n.push(r.charAt(s>>>6*(3-a)&63)):n.push("=");return n.join("")},base64ToBytes:function(t){t=t.replace(/[^A-Z0-9+\/]/ig,"");for(var n=[],i=0,s=0;i<t.length;s=++i%4)s!=0&&n.push((r.indexOf(t.charAt(i-1))&Math.pow(2,-2*s+8)-1)<<s*2|r.indexOf(t.charAt(i))>>>6-s*2);return n}};wc.exports=e}()),wc.exports}var Bs,Tc;function Mc(){if(Tc)return Bs;Tc=1;var r={utf8:{stringToBytes:function(e){return r.bin.stringToBytes(unescape(encodeURIComponent(e)))},bytesToString:function(e){return decodeURIComponent(escape(r.bin.bytesToString(e)))}},bin:{stringToBytes:function(e){for(var t=[],n=0;n<e.length;n++)t.push(e.charCodeAt(n)&255);return t},bytesToString:function(e){for(var t=[],n=0;n<e.length;n++)t.push(String.fromCharCode(e[n]));return t.join("")}}};return Bs=r,Bs}/*!
|
|
79
79
|
* Determine if an object is a Buffer
|
|
80
80
|
*
|
|
81
81
|
* @author Feross Aboukhadijeh <https://feross.org>
|
|
82
82
|
* @license MIT
|
|
83
|
-
*/var Ns,Cc;function Yu(){if(Cc)return Ns;Cc=1,Ns=function(t){return t!=null&&(r(t)||e(t)||!!t._isBuffer)};function r(t){return!!t.constructor&&typeof t.constructor.isBuffer=="function"&&t.constructor.isBuffer(t)}function e(t){return typeof t.readFloatLE=="function"&&typeof t.slice=="function"&&r(t.slice(0,0))}return Ns}var Ec;function Zu(){return Ec||(Ec=1,function(){var r=Xu(),e=Mc().utf8,t=Yu(),n=Mc().bin,i=function(s,a){s.constructor==String?a&&a.encoding==="binary"?s=n.stringToBytes(s):s=e.stringToBytes(s):t(s)?s=Array.prototype.slice.call(s,0):!Array.isArray(s)&&s.constructor!==Uint8Array&&(s=s.toString());for(var o=r.bytesToWords(s),c=s.length*8,l=1732584193,u=-271733879,p=-1732584194,f=271733878,m=0;m<o.length;m++)o[m]=(o[m]<<8|o[m]>>>24)&16711935|(o[m]<<24|o[m]>>>8)&4278255360;o[c>>>5]|=128<<c%32,o[(c+64>>>9<<4)+14]=c;for(var b=i._ff,x=i._gg,g=i._hh,v=i._ii,m=0;m<o.length;m+=16){var _=l,w=u,C=p,M=f;l=b(l,u,p,f,o[m+0],7,-680876936),f=b(f,l,u,p,o[m+1],12,-389564586),p=b(p,f,l,u,o[m+2],17,606105819),u=b(u,p,f,l,o[m+3],22,-1044525330),l=b(l,u,p,f,o[m+4],7,-176418897),f=b(f,l,u,p,o[m+5],12,1200080426),p=b(p,f,l,u,o[m+6],17,-1473231341),u=b(u,p,f,l,o[m+7],22,-45705983),l=b(l,u,p,f,o[m+8],7,1770035416),f=b(f,l,u,p,o[m+9],12,-1958414417),p=b(p,f,l,u,o[m+10],17,-42063),u=b(u,p,f,l,o[m+11],22,-1990404162),l=b(l,u,p,f,o[m+12],7,1804603682),f=b(f,l,u,p,o[m+13],12,-40341101),p=b(p,f,l,u,o[m+14],17,-1502002290),u=b(u,p,f,l,o[m+15],22,1236535329),l=x(l,u,p,f,o[m+1],5,-165796510),f=x(f,l,u,p,o[m+6],9,-1069501632),p=x(p,f,l,u,o[m+11],14,643717713),u=x(u,p,f,l,o[m+0],20,-373897302),l=x(l,u,p,f,o[m+5],5,-701558691),f=x(f,l,u,p,o[m+10],9,38016083),p=x(p,f,l,u,o[m+15],14,-660478335),u=x(u,p,f,l,o[m+4],20,-405537848),l=x(l,u,p,f,o[m+9],5,568446438),f=x(f,l,u,p,o[m+14],9,-1019803690),p=x(p,f,l,u,o[m+3],14,-187363961),u=x(u,p,f,l,o[m+8],20,1163531501),l=x(l,u,p,f,o[m+13],5,-1444681467),f=x(f,l,u,p,o[m+2],9,-51403784),p=x(p,f,l,u,o[m+7],14,1735328473),u=x(u,p,f,l,o[m+12],20,-1926607734),l=g(l,u,p,f,o[m+5],4,-378558),f=g(f,l,u,p,o[m+8],11,-2022574463),p=g(p,f,l,u,o[m+11],16,1839030562),u=g(u,p,f,l,o[m+14],23,-35309556),l=g(l,u,p,f,o[m+1],4,-1530992060),f=g(f,l,u,p,o[m+4],11,1272893353),p=g(p,f,l,u,o[m+7],16,-155497632),u=g(u,p,f,l,o[m+10],23,-1094730640),l=g(l,u,p,f,o[m+13],4,681279174),f=g(f,l,u,p,o[m+0],11,-358537222),p=g(p,f,l,u,o[m+3],16,-722521979),u=g(u,p,f,l,o[m+6],23,76029189),l=g(l,u,p,f,o[m+9],4,-640364487),f=g(f,l,u,p,o[m+12],11,-421815835),p=g(p,f,l,u,o[m+15],16,530742520),u=g(u,p,f,l,o[m+2],23,-995338651),l=v(l,u,p,f,o[m+0],6,-198630844),f=v(f,l,u,p,o[m+7],10,1126891415),p=v(p,f,l,u,o[m+14],15,-1416354905),u=v(u,p,f,l,o[m+5],21,-57434055),l=v(l,u,p,f,o[m+12],6,1700485571),f=v(f,l,u,p,o[m+3],10,-1894986606),p=v(p,f,l,u,o[m+10],15,-1051523),u=v(u,p,f,l,o[m+1],21,-2054922799),l=v(l,u,p,f,o[m+8],6,1873313359),f=v(f,l,u,p,o[m+15],10,-30611744),p=v(p,f,l,u,o[m+6],15,-1560198380),u=v(u,p,f,l,o[m+13],21,1309151649),l=v(l,u,p,f,o[m+4],6,-145523070),f=v(f,l,u,p,o[m+11],10,-1120210379),p=v(p,f,l,u,o[m+2],15,718787259),u=v(u,p,f,l,o[m+9],21,-343485551),l=l+_>>>0,u=u+w>>>0,p=p+C>>>0,f=f+M>>>0}return r.endian([l,u,p,f])};i._ff=function(s,a,o,c,l,u,p){var f=s+(a&o|~a&c)+(l>>>0)+p;return(f<<u|f>>>32-u)+a},i._gg=function(s,a,o,c,l,u,p){var f=s+(a&c|o&~c)+(l>>>0)+p;return(f<<u|f>>>32-u)+a},i._hh=function(s,a,o,c,l,u,p){var f=s+(a^o^c)+(l>>>0)+p;return(f<<u|f>>>32-u)+a},i._ii=function(s,a,o,c,l,u,p){var f=s+(o^(a|~c))+(l>>>0)+p;return(f<<u|f>>>32-u)+a},i._blocksize=16,i._digestsize=16,xc.exports=function(s,a){if(s==null)throw new Error("Illegal argument "+s);var o=r.wordsToBytes(i(s,a));return a&&a.asBytes?o:a&&a.asString?n.bytesToString(o):r.bytesToHex(o)}}()),xc.exports}var Ku=Zu();const Qu=ar(Ku),Fe=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"];let Pc=1234567;const kc=Math.PI/180,Rc=180/Math.PI;function $u(){const r=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(Fe[r&255]+Fe[r>>8&255]+Fe[r>>16&255]+Fe[r>>24&255]+"-"+Fe[e&255]+Fe[e>>8&255]+"-"+Fe[e>>16&15|64]+Fe[e>>24&255]+"-"+Fe[t&63|128]+Fe[t>>8&255]+"-"+Fe[t>>16&255]+Fe[t>>24&255]+Fe[n&255]+Fe[n>>8&255]+Fe[n>>16&255]+Fe[n>>24&255]).toLowerCase()}function Bt(r,e,t){return Math.max(e,Math.min(t,r))}function Ac(r,e){return(r%e+e)%e}function eh(r,e,t,n,i){return n+(r-e)*(i-n)/(t-e)}function th(r,e,t){return r!==e?(t-r)/(e-r):0}function Oc(r,e,t){return(1-t)*r+t*e}function nh(r,e,t,n){return Oc(r,e,1-Math.exp(-t*n))}function ih(r,e=1){return e-Math.abs(Ac(r,e*2)-e)}function rh(r,e,t){return r<=e?0:r>=t?1:(r=(r-e)/(t-e),r*r*(3-2*r))}function sh(r,e,t){return r<=e?0:r>=t?1:(r=(r-e)/(t-e),r*r*r*(r*(r*6-15)+10))}function oh(r,e){return r+Math.floor(Math.random()*(e-r+1))}function ah(r,e){return r+Math.random()*(e-r)}function ch(r){return r*(.5-Math.random())}function lh(r){r!==void 0&&(Pc=r);let e=Pc+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}function uh(r){return r*kc}function hh(r){return r*Rc}function dh(r){return(r&r-1)===0&&r!==0}function ph(r){return Math.pow(2,Math.ceil(Math.log(r)/Math.LN2))}function fh(r){return Math.pow(2,Math.floor(Math.log(r)/Math.LN2))}function mh(r,e,t,n,i){const s=Math.cos,a=Math.sin,o=s(t/2),c=a(t/2),l=s((e+n)/2),u=a((e+n)/2),p=s((e-n)/2),f=a((e-n)/2),m=s((n-e)/2),b=a((n-e)/2);switch(i){case"XYX":r.set(o*u,c*p,c*f,o*l);break;case"YZY":r.set(c*f,o*u,c*p,o*l);break;case"ZXZ":r.set(c*p,c*f,o*u,o*l);break;case"XZX":r.set(o*u,c*b,c*m,o*l);break;case"YXY":r.set(c*m,o*u,c*b,o*l);break;case"ZYZ":r.set(c*b,c*m,o*u,o*l);break;default:console.warn("../math.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+i)}}function yh(r,e){switch(e.constructor){case Float32Array:return r;case Uint32Array:return r/4294967295;case Uint16Array:return r/65535;case Uint8Array:return r/255;case Int32Array:return Math.max(r/2147483647,-1);case Int16Array:return Math.max(r/32767,-1);case Int8Array:return Math.max(r/127,-1);default:throw new Error("Invalid component type.")}}function gh(r,e){switch(e.constructor){case Float32Array:return r;case Uint32Array:return Math.round(r*4294967295);case Uint16Array:return Math.round(r*65535);case Uint8Array:return Math.round(r*255);case Int32Array:return Math.round(r*2147483647);case Int16Array:return Math.round(r*32767);case Int8Array:return Math.round(r*127);default:throw new Error("Invalid component type.")}}const An={DEG2RAD:kc,RAD2DEG:Rc,generateUUID:$u,clamp:Bt,euclideanModulo:Ac,mapLinear:eh,inverseLerp:th,lerp:Oc,damp:nh,pingpong:ih,smoothstep:rh,smootherstep:sh,randInt:oh,randFloat:ah,randFloatSpread:ch,seededRandom:lh,degToRad:uh,radToDeg:hh,isPowerOfTwo:dh,ceilPowerOfTwo:ph,floorPowerOfTwo:fh,setQuaternionFromProperEuler:mh,normalize:gh,denormalize:yh};class ie{constructor(e=0,t=0,n=0,i=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=i}static slerpFlat(e,t,n,i,s,a,o){let c=n[i+0],l=n[i+1],u=n[i+2],p=n[i+3];const f=s[a+0],m=s[a+1],b=s[a+2],x=s[a+3];if(o===0){e[t+0]=c,e[t+1]=l,e[t+2]=u,e[t+3]=p;return}if(o===1){e[t+0]=f,e[t+1]=m,e[t+2]=b,e[t+3]=x;return}if(p!==x||c!==f||l!==m||u!==b){let g=1-o;const v=c*f+l*m+u*b+p*x,_=v>=0?1:-1,w=1-v*v;if(w>Number.EPSILON){const M=Math.sqrt(w),E=Math.atan2(M,v*_);g=Math.sin(g*E)/M,o=Math.sin(o*E)/M}const C=o*_;if(c=c*g+f*C,l=l*g+m*C,u=u*g+b*C,p=p*g+x*C,g===1-o){const M=1/Math.sqrt(c*c+l*l+u*u+p*p);c*=M,l*=M,u*=M,p*=M}}e[t]=c,e[t+1]=l,e[t+2]=u,e[t+3]=p}static multiplyQuaternionsFlat(e,t,n,i,s,a){const o=n[i],c=n[i+1],l=n[i+2],u=n[i+3],p=s[a],f=s[a+1],m=s[a+2],b=s[a+3];return e[t]=o*b+u*p+c*m-l*f,e[t+1]=c*b+u*f+l*p-o*m,e[t+2]=l*b+u*m+o*f-c*p,e[t+3]=u*b-o*p-c*f-l*m,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,i){return this._x=e,this._y=t,this._z=n,this._w=i,this._onChangeCallback(),this}clone(){return new ie(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){const n=e._x,i=e._y,s=e._z,a=e._order,o=Math.cos,c=Math.sin,l=o(n/2),u=o(i/2),p=o(s/2),f=c(n/2),m=c(i/2),b=c(s/2);switch(a){case"XYZ":this._x=f*u*p+l*m*b,this._y=l*m*p-f*u*b,this._z=l*u*b+f*m*p,this._w=l*u*p-f*m*b;break;case"YXZ":this._x=f*u*p+l*m*b,this._y=l*m*p-f*u*b,this._z=l*u*b-f*m*p,this._w=l*u*p+f*m*b;break;case"ZXY":this._x=f*u*p-l*m*b,this._y=l*m*p+f*u*b,this._z=l*u*b+f*m*p,this._w=l*u*p-f*m*b;break;case"ZYX":this._x=f*u*p-l*m*b,this._y=l*m*p+f*u*b,this._z=l*u*b-f*m*p,this._w=l*u*p+f*m*b;break;case"YZX":this._x=f*u*p+l*m*b,this._y=l*m*p+f*u*b,this._z=l*u*b-f*m*p,this._w=l*u*p-f*m*b;break;case"XZY":this._x=f*u*p-l*m*b,this._y=l*m*p-f*u*b,this._z=l*u*b+f*m*p,this._w=l*u*p+f*m*b;break;default:console.warn("../math.Quaternion: .setFromEuler() encountered an unknown order: "+a)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const n=t/2,i=Math.sin(n);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,n=t[0],i=t[4],s=t[8],a=t[1],o=t[5],c=t[9],l=t[2],u=t[6],p=t[10],f=n+o+p;if(f>0){const m=.5/Math.sqrt(f+1);this._w=.25/m,this._x=(u-c)*m,this._y=(s-l)*m,this._z=(a-i)*m}else if(n>o&&n>p){const m=2*Math.sqrt(1+n-o-p);this._w=(u-c)/m,this._x=.25*m,this._y=(i+a)/m,this._z=(s+l)/m}else if(o>p){const m=2*Math.sqrt(1+o-n-p);this._w=(s-l)/m,this._x=(i+a)/m,this._y=.25*m,this._z=(c+u)/m}else{const m=2*Math.sqrt(1+p-n-o);this._w=(a-i)/m,this._x=(s+l)/m,this._y=(c+u)/m,this._z=.25*m}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<Number.EPSILON?(n=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(Bt(this.dot(e),-1,1)))}rotateTowards(e,t){const n=this.angleTo(e);if(n===0)return this;const i=Math.min(1,t/n);return this.slerp(e,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){const n=e._x,i=e._y,s=e._z,a=e._w,o=t._x,c=t._y,l=t._z,u=t._w;return this._x=n*u+a*o+i*l-s*c,this._y=i*u+a*c+s*o-n*l,this._z=s*u+a*l+n*c-i*o,this._w=a*u-n*o-i*c-s*l,this._onChangeCallback(),this}slerp(e,t){if(t===0)return this;if(t===1)return this.copy(e);const n=this._x,i=this._y,s=this._z,a=this._w;let o=a*e._w+n*e._x+i*e._y+s*e._z;if(o<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,o=-o):this.copy(e),o>=1)return this._w=a,this._x=n,this._y=i,this._z=s,this;const c=1-o*o;if(c<=Number.EPSILON){const m=1-t;return this._w=m*a+t*this._w,this._x=m*n+t*this._x,this._y=m*i+t*this._y,this._z=m*s+t*this._z,this.normalize(),this}const l=Math.sqrt(c),u=Math.atan2(l,o),p=Math.sin((1-t)*u)/l,f=Math.sin(t*u)/l;return this._w=a*p+this._w*f,this._x=n*p+this._x*f,this._y=i*p+this._y*f,this._z=s*p+this._z*f,this._onChangeCallback(),this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){const e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),i=Math.sqrt(1-n),s=Math.sqrt(n);return this.set(i*Math.sin(e),i*Math.cos(e),s*Math.sin(t),s*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class G{constructor(e=0,t=0,n=0){this.isVector3=!0,G.prototype.isVector3=!0,this.x=e,this.y=t,this.z=n}set(e,t,n){return n===void 0&&(n=this.z),this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new G(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(Ic.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Ic.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,n=this.y,i=this.z,s=e.elements;return this.x=s[0]*t+s[3]*n+s[6]*i,this.y=s[1]*t+s[4]*n+s[7]*i,this.z=s[2]*t+s[5]*n+s[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,n=this.y,i=this.z,s=e.elements,a=1/(s[3]*t+s[7]*n+s[11]*i+s[15]);return this.x=(s[0]*t+s[4]*n+s[8]*i+s[12])*a,this.y=(s[1]*t+s[5]*n+s[9]*i+s[13])*a,this.z=(s[2]*t+s[6]*n+s[10]*i+s[14])*a,this}applyQuaternion(e){const t=this.x,n=this.y,i=this.z,s=e.x,a=e.y,o=e.z,c=e.w,l=2*(a*i-o*n),u=2*(o*t-s*i),p=2*(s*n-a*t);return this.x=t+c*l+a*p-o*u,this.y=n+c*u+o*l-s*p,this.z=i+c*p+s*u-a*l,this}transformDirection(e){const t=this.x,n=this.y,i=this.z,s=e.elements;return this.x=s[0]*t+s[4]*n+s[8]*i,this.y=s[1]*t+s[5]*n+s[9]*i,this.z=s[2]*t+s[6]*n+s[10]*i,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const n=e.x,i=e.y,s=e.z,a=t.x,o=t.y,c=t.z;return this.x=i*c-s*o,this.y=s*a-n*c,this.z=n*o-i*a,this}projectOnVector(e){const t=e.lengthSq();if(t===0)return this.set(0,0,0);const n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return Us.copy(this).projectOnVector(e),this.sub(Us)}reflect(e){return this.sub(Us.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(Bt(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y,i=this.z-e.z;return t*t+n*n+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSphericalCoords(e,t,n){const i=Math.sin(t)*e;return this.x=i*Math.sin(n),this.y=Math.cos(t)*e,this.z=i*Math.cos(n),this}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){const t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),i=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=i,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=Math.random()*Math.PI*2,t=Math.random()*2-1,n=Math.sqrt(1-t*t);return this.x=n*Math.cos(e),this.y=t,this.z=n*Math.sin(e),this}abs(){return this.x=Math.abs(this.x),this.y=Math.abs(this.y),this.z=Math.abs(this.z),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const Us=new G,Ic=new ie,gr=2e3,zc=2001;class Rt{constructor(e,t,n,i,s,a,o,c,l,u,p,f,m,b,x,g){this.isMatrix4=!0,Rt.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,t,n,i,s,a,o,c,l,u,p,f,m,b,x,g)}extractPosition(e){return console.warn("THREE.Matrix4: .extractPosition() has been renamed to .copyPosition()."),this.copyPosition(e)}multiplyToArray(e,t,n){return console.error("THREE.Matrix4: .multiplyToArray() has been removed."),this}setRotationFromQuaternion(e){return this.makeRotationFromQuaternion(e)}set(e,t,n,i,s,a,o,c,l,u,p,f,m,b,x,g){const v=this.elements;return v[0]=e,v[4]=t,v[8]=n,v[12]=i,v[1]=s,v[5]=a,v[9]=o,v[13]=c,v[2]=l,v[6]=u,v[10]=p,v[14]=f,v[3]=m,v[7]=b,v[11]=x,v[15]=g,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new Rt().fromArray(this.elements)}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){const t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){const t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,n){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){const t=this.elements,n=e.elements,i=1/On.setFromMatrixColumn(e,0).length(),s=1/On.setFromMatrixColumn(e,1).length(),a=1/On.setFromMatrixColumn(e,2).length();return t[0]=n[0]*i,t[1]=n[1]*i,t[2]=n[2]*i,t[3]=0,t[4]=n[4]*s,t[5]=n[5]*s,t[6]=n[6]*s,t[7]=0,t[8]=n[8]*a,t[9]=n[9]*a,t[10]=n[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){const t=this.elements,n=e.x,i=e.y,s=e.z,a=Math.cos(n),o=Math.sin(n),c=Math.cos(i),l=Math.sin(i),u=Math.cos(s),p=Math.sin(s);if(e.order==="XYZ"){const f=a*u,m=a*p,b=o*u,x=o*p;t[0]=c*u,t[4]=-c*p,t[8]=l,t[1]=m+b*l,t[5]=f-x*l,t[9]=-o*c,t[2]=x-f*l,t[6]=b+m*l,t[10]=a*c}else if(e.order==="YXZ"){const f=c*u,m=c*p,b=l*u,x=l*p;t[0]=f+x*o,t[4]=b*o-m,t[8]=a*l,t[1]=a*p,t[5]=a*u,t[9]=-o,t[2]=m*o-b,t[6]=x+f*o,t[10]=a*c}else if(e.order==="ZXY"){const f=c*u,m=c*p,b=l*u,x=l*p;t[0]=f-x*o,t[4]=-a*p,t[8]=b+m*o,t[1]=m+b*o,t[5]=a*u,t[9]=x-f*o,t[2]=-a*l,t[6]=o,t[10]=a*c}else if(e.order==="ZYX"){const f=a*u,m=a*p,b=o*u,x=o*p;t[0]=c*u,t[4]=b*l-m,t[8]=f*l+x,t[1]=c*p,t[5]=x*l+f,t[9]=m*l-b,t[2]=-l,t[6]=o*c,t[10]=a*c}else if(e.order==="YZX"){const f=a*c,m=a*l,b=o*c,x=o*l;t[0]=c*u,t[4]=x-f*p,t[8]=b*p+m,t[1]=p,t[5]=a*u,t[9]=-o*u,t[2]=-l*u,t[6]=m*p+b,t[10]=f-x*p}else if(e.order==="XZY"){const f=a*c,m=a*l,b=o*c,x=o*l;t[0]=c*u,t[4]=-p,t[8]=l*u,t[1]=f*p+x,t[5]=a*u,t[9]=m*p-b,t[2]=b*p-m,t[6]=o*u,t[10]=x*p+f}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(vh,e,Sh)}lookAt(e,t,n){const i=this.elements;return at.subVectors(e,t),at.lengthSq()===0&&(at.z=1),at.normalize(),$t.crossVectors(n,at),$t.lengthSq()===0&&(Math.abs(n.z)===1?at.x+=1e-4:at.z+=1e-4,at.normalize(),$t.crossVectors(n,at)),$t.normalize(),vr.crossVectors(at,$t),i[0]=$t.x,i[4]=vr.x,i[8]=at.x,i[1]=$t.y,i[5]=vr.y,i[9]=at.y,i[2]=$t.z,i[6]=vr.z,i[10]=at.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,i=t.elements,s=this.elements,a=n[0],o=n[4],c=n[8],l=n[12],u=n[1],p=n[5],f=n[9],m=n[13],b=n[2],x=n[6],g=n[10],v=n[14],_=n[3],w=n[7],C=n[11],M=n[15],E=i[0],P=i[4],O=i[8],R=i[12],A=i[1],B=i[5],z=i[9],D=i[13],F=i[2],H=i[6],q=i[10],$=i[14],J=i[3],Se=i[7],ce=i[11],me=i[15];return s[0]=a*E+o*A+c*F+l*J,s[4]=a*P+o*B+c*H+l*Se,s[8]=a*O+o*z+c*q+l*ce,s[12]=a*R+o*D+c*$+l*me,s[1]=u*E+p*A+f*F+m*J,s[5]=u*P+p*B+f*H+m*Se,s[9]=u*O+p*z+f*q+m*ce,s[13]=u*R+p*D+f*$+m*me,s[2]=b*E+x*A+g*F+v*J,s[6]=b*P+x*B+g*H+v*Se,s[10]=b*O+x*z+g*q+v*ce,s[14]=b*R+x*D+g*$+v*me,s[3]=_*E+w*A+C*F+M*J,s[7]=_*P+w*B+C*H+M*Se,s[11]=_*O+w*z+C*q+M*ce,s[15]=_*R+w*D+C*$+M*me,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[4],i=e[8],s=e[12],a=e[1],o=e[5],c=e[9],l=e[13],u=e[2],p=e[6],f=e[10],m=e[14],b=e[3],x=e[7],g=e[11],v=e[15];return b*(+s*c*p-i*l*p-s*o*f+n*l*f+i*o*m-n*c*m)+x*(+t*c*m-t*l*f+s*a*f-i*a*m+i*l*u-s*c*u)+g*(+t*l*p-t*o*m-s*a*p+n*a*m+s*o*u-n*l*u)+v*(-i*o*u-t*c*p+t*o*f+i*a*p-n*a*f+n*c*u)}transpose(){const e=this.elements;let t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,n){const i=this.elements;return e.isVector3?(i[12]=e.x,i[13]=e.y,i[14]=e.z):(i[12]=e,i[13]=t,i[14]=n),this}invert(){const e=this.elements,t=e[0],n=e[1],i=e[2],s=e[3],a=e[4],o=e[5],c=e[6],l=e[7],u=e[8],p=e[9],f=e[10],m=e[11],b=e[12],x=e[13],g=e[14],v=e[15],_=p*g*l-x*f*l+x*c*m-o*g*m-p*c*v+o*f*v,w=b*f*l-u*g*l-b*c*m+a*g*m+u*c*v-a*f*v,C=u*x*l-b*p*l+b*o*m-a*x*m-u*o*v+a*p*v,M=b*p*c-u*x*c-b*o*f+a*x*f+u*o*g-a*p*g,E=t*_+n*w+i*C+s*M;if(E===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const P=1/E;return e[0]=_*P,e[1]=(x*f*s-p*g*s-x*i*m+n*g*m+p*i*v-n*f*v)*P,e[2]=(o*g*s-x*c*s+x*i*l-n*g*l-o*i*v+n*c*v)*P,e[3]=(p*c*s-o*f*s-p*i*l+n*f*l+o*i*m-n*c*m)*P,e[4]=w*P,e[5]=(u*g*s-b*f*s+b*i*m-t*g*m-u*i*v+t*f*v)*P,e[6]=(b*c*s-a*g*s-b*i*l+t*g*l+a*i*v-t*c*v)*P,e[7]=(a*f*s-u*c*s+u*i*l-t*f*l-a*i*m+t*c*m)*P,e[8]=C*P,e[9]=(b*p*s-u*x*s-b*n*m+t*x*m+u*n*v-t*p*v)*P,e[10]=(a*x*s-b*o*s+b*n*l-t*x*l-a*n*v+t*o*v)*P,e[11]=(u*o*s-a*p*s-u*n*l+t*p*l+a*n*m-t*o*m)*P,e[12]=M*P,e[13]=(u*x*i-b*p*i+b*n*f-t*x*f-u*n*g+t*p*g)*P,e[14]=(b*o*i-a*x*i-b*n*c+t*x*c+a*n*g-t*o*g)*P,e[15]=(a*p*i-u*o*i+u*n*c-t*p*c-a*n*f+t*o*f)*P,this}scale(e){const t=this.elements,n=e.x,i=e.y,s=e.z;return t[0]*=n,t[4]*=i,t[8]*=s,t[1]*=n,t[5]*=i,t[9]*=s,t[2]*=n,t[6]*=i,t[10]*=s,t[3]*=n,t[7]*=i,t[11]*=s,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],i=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,i))}makeTranslation(e,t,n){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const n=Math.cos(t),i=Math.sin(t),s=1-n,a=e.x,o=e.y,c=e.z,l=s*a,u=s*o;return this.set(l*a+n,l*o-i*c,l*c+i*o,0,l*o+i*c,u*o+n,u*c-i*a,0,l*c-i*o,u*c+i*a,s*c*c+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,i,s,a){return this.set(1,n,s,0,e,1,a,0,t,i,1,0,0,0,0,1),this}compose(e,t,n){const i=this.elements,s=t._x,a=t._y,o=t._z,c=t._w,l=s+s,u=a+a,p=o+o,f=s*l,m=s*u,b=s*p,x=a*u,g=a*p,v=o*p,_=c*l,w=c*u,C=c*p,M=n.x,E=n.y,P=n.z;return i[0]=(1-(x+v))*M,i[1]=(m+C)*M,i[2]=(b-w)*M,i[3]=0,i[4]=(m-C)*E,i[5]=(1-(f+v))*E,i[6]=(g+_)*E,i[7]=0,i[8]=(b+w)*P,i[9]=(g-_)*P,i[10]=(1-(f+x))*P,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,t,n){const i=this.elements;let s=On.set(i[0],i[1],i[2]).length();const a=On.set(i[4],i[5],i[6]).length(),o=On.set(i[8],i[9],i[10]).length();this.determinant()<0&&(s=-s),e.x=i[12],e.y=i[13],e.z=i[14],Pt.copy(this);const c=1/s,l=1/a,u=1/o;return Pt.elements[0]*=c,Pt.elements[1]*=c,Pt.elements[2]*=c,Pt.elements[4]*=l,Pt.elements[5]*=l,Pt.elements[6]*=l,Pt.elements[8]*=u,Pt.elements[9]*=u,Pt.elements[10]*=u,t.setFromRotationMatrix(Pt),n.x=s,n.y=a,n.z=o,this}makePerspective(e,t,n,i,s,a,o=gr){const c=this.elements,l=2*s/(t-e),u=2*s/(n-i),p=(t+e)/(t-e),f=(n+i)/(n-i);let m,b;if(o===gr)m=-(a+s)/(a-s),b=-2*a*s/(a-s);else if(o===zc)m=-a/(a-s),b=-a*s/(a-s);else throw new Error("Matrix4.makePerspective(): Invalid coordinate system: "+o);return c[0]=l,c[4]=0,c[8]=p,c[12]=0,c[1]=0,c[5]=u,c[9]=f,c[13]=0,c[2]=0,c[6]=0,c[10]=m,c[14]=b,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(e,t,n,i,s,a,o=gr){const c=this.elements,l=1/(t-e),u=1/(n-i),p=1/(a-s),f=(t+e)*l,m=(n+i)*u;let b,x;if(o===gr)b=(a+s)*p,x=-2*p;else if(o===zc)b=s*p,x=-1*p;else throw new Error("../math.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return c[0]=2*l,c[4]=0,c[8]=0,c[12]=-f,c[1]=0,c[5]=2*u,c[9]=0,c[13]=-m,c[2]=0,c[6]=0,c[10]=x,c[14]=-b,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(e){const t=this.elements,n=e.elements;for(let i=0;i<16;i++)if(t[i]!==n[i])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}}const On=new G,Pt=new Rt,vh=new G(0,0,0),Sh=new G(1,1,1),$t=new G,vr=new G,at=new G,Bc=new Rt,Nc=new ie;class wi{constructor(e=0,t=0,n=0,i=wi.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=n,this._order=i}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,i=this._order){return this._x=e,this._y=t,this._z=n,this._order=i,this._onChangeCallback(),this}clone(){return new wi(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,n=!0){const i=e.elements,s=i[0],a=i[4],o=i[8],c=i[1],l=i[5],u=i[9],p=i[2],f=i[6],m=i[10];switch(t){case"XYZ":this._y=Math.asin(Bt(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-u,m),this._z=Math.atan2(-a,s)):(this._x=Math.atan2(f,l),this._z=0);break;case"YXZ":this._x=Math.asin(-Bt(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(o,m),this._z=Math.atan2(c,l)):(this._y=Math.atan2(-p,s),this._z=0);break;case"ZXY":this._x=Math.asin(Bt(f,-1,1)),Math.abs(f)<.9999999?(this._y=Math.atan2(-p,m),this._z=Math.atan2(-a,l)):(this._y=0,this._z=Math.atan2(c,s));break;case"ZYX":this._y=Math.asin(-Bt(p,-1,1)),Math.abs(p)<.9999999?(this._x=Math.atan2(f,m),this._z=Math.atan2(c,s)):(this._x=0,this._z=Math.atan2(-a,l));break;case"YZX":this._z=Math.asin(Bt(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-u,l),this._y=Math.atan2(-p,s)):(this._x=0,this._y=Math.atan2(o,m));break;case"XZY":this._z=Math.asin(-Bt(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(f,l),this._y=Math.atan2(o,s)):(this._x=Math.atan2(-u,m),this._y=0);break;default:console.warn("../math.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,n===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return Bc.makeRotationFromQuaternion(e),this.setFromRotationMatrix(Bc,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return Nc.setFromEuler(this),this.setFromQuaternion(Nc,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(e){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}wi.DEFAULT_ORDER="XYZ";class Jn{constructor(e=0,t=0){this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new Jn(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const t=this.x,n=this.y,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6],this.y=i[1]*t+i[4]*n+i[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(Bt(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}rotateAround(e,t){const n=Math.cos(t),i=Math.sin(t),s=this.x-e.x,a=this.y-e.y;return this.x=s*n-a*i+e.x,this.y=s*i+a*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}Jn.isVector2=!0;class tt{constructor(e=0,t=0,n=0,i=1){tt.prototype.isVector4=!0,this.x=e,this.y=t,this.z=n,this.w=i}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,i){return this.x=e,this.y=t,this.z=n,this.w=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new tt(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const t=this.x,n=this.y,i=this.z,s=this.w,a=e.elements;return this.x=a[0]*t+a[4]*n+a[8]*i+a[12]*s,this.y=a[1]*t+a[5]*n+a[9]*i+a[13]*s,this.z=a[2]*t+a[6]*n+a[10]*i+a[14]*s,this.w=a[3]*t+a[7]*n+a[11]*i+a[15]*s,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,n,i,s;const a=e.elements,o=a[0],c=a[4],l=a[8],u=a[1],p=a[5],f=a[9],m=a[2],b=a[6],x=a[10];if(Math.abs(c-u)<.01&&Math.abs(l-m)<.01&&Math.abs(f-b)<.01){if(Math.abs(c+u)<.1&&Math.abs(l+m)<.1&&Math.abs(f+b)<.1&&Math.abs(o+p+x-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const v=(o+1)/2,_=(p+1)/2,w=(x+1)/2,C=(c+u)/4,M=(l+m)/4,E=(f+b)/4;return v>_&&v>w?v<.01?(n=0,i=.707106781,s=.707106781):(n=Math.sqrt(v),i=C/n,s=M/n):_>w?_<.01?(n=.707106781,i=0,s=.707106781):(i=Math.sqrt(_),n=C/i,s=E/i):w<.01?(n=.707106781,i=.707106781,s=0):(s=Math.sqrt(w),n=M/s,i=E/s),this.set(n,i,s,t),this}let g=Math.sqrt((b-f)*(b-f)+(l-m)*(l-m)+(u-c)*(u-c));return Math.abs(g)<.001&&(g=1),this.x=(b-f)/g,this.y=(l-m)/g,this.z=(u-c)/g,this.w=Math.acos((o+p+x-1)/2),this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this.w=Math.max(e.w,Math.min(t.w,this.w)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this.w=Math.max(e,Math.min(t,this.w)),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class Dt{constructor(e,t,n,i,s,a,o,c,l){Dt.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,n,i,s,a,o,c,l)}set(e,t,n,i,s,a,o,c,l){const u=this.elements;return u[0]=e,u[1]=i,u[2]=o,u[3]=t,u[4]=s,u[5]=c,u[6]=n,u[7]=a,u[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,i=t.elements,s=this.elements,a=n[0],o=n[3],c=n[6],l=n[1],u=n[4],p=n[7],f=n[2],m=n[5],b=n[8],x=i[0],g=i[3],v=i[6],_=i[1],w=i[4],C=i[7],M=i[2],E=i[5],P=i[8];return s[0]=a*x+o*_+c*M,s[3]=a*g+o*w+c*E,s[6]=a*v+o*C+c*P,s[1]=l*x+u*_+p*M,s[4]=l*g+u*w+p*E,s[7]=l*v+u*C+p*P,s[2]=f*x+m*_+b*M,s[5]=f*g+m*w+b*E,s[8]=f*v+m*C+b*P,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[1],i=e[2],s=e[3],a=e[4],o=e[5],c=e[6],l=e[7],u=e[8];return t*a*u-t*o*l-n*s*u+n*o*c+i*s*l-i*a*c}invert(){const e=this.elements,t=e[0],n=e[1],i=e[2],s=e[3],a=e[4],o=e[5],c=e[6],l=e[7],u=e[8],p=u*a-o*l,f=o*c-u*s,m=l*s-a*c,b=t*p+n*f+i*m;if(b===0)return this.set(0,0,0,0,0,0,0,0,0);const x=1/b;return e[0]=p*x,e[1]=(i*l-u*n)*x,e[2]=(o*n-i*a)*x,e[3]=f*x,e[4]=(u*t-i*c)*x,e[5]=(i*s-o*t)*x,e[6]=m*x,e[7]=(n*c-l*t)*x,e[8]=(a*t-n*s)*x,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,i,s,a,o){const c=Math.cos(s),l=Math.sin(s);return this.set(n*c,n*l,-n*(c*a+l*o)+a+e,-i*l,i*c,-i*(-l*a+c*o)+o+t,0,0,1),this}scale(e,t){return this.premultiply(Ds.makeScale(e,t)),this}rotate(e){return this.premultiply(Ds.makeRotation(-e)),this}translate(e,t){return this.premultiply(Ds.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){const t=this.elements,n=e.elements;for(let i=0;i<9;i++)if(t[i]!==n[i])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new Dt().fromArray(this.elements)}}const Ds=new Dt;var Xe;(function(r){r[r.Random=0]="Random",r[r.Loop=1]="Loop",r[r.PingPong=2]="PingPong",r[r.Burst=3]="Burst"})(Xe||(Xe={}));function ri(r,e,t,n){let i;switch(Xe.Random===r?e=Math.random():Xe.Burst===r&&n.isBursting&&(e=n.burstParticleIndex/n.burstParticleCount),t>0?i=Math.floor(e/t)*t:i=e,r){case Xe.Loop:i=i%1;break;case Xe.PingPong:i=Math.abs(i%2-1);break}return i}class bn{constructor(e,t,n,i){this.p=[e,t,n,i]}genValue(e){const t=e*e,n=e*e*e,i=1-e,s=i*i,a=s*i;return this.p[0]*a+this.p[1]*s*e*3+this.p[2]*i*t*3+this.p[3]*n}derivativeCoefficients(e){const t=[];for(let n=e,i=n.length-1;i>0;i--){const s=[];for(let a=0;a<i;a++){const o=i*(n[a+1]-n[a]);s.push(o)}t.push(s),n=s}return t}getSlope(e){const t=this.derivativeCoefficients(this.p)[0],n=1-e,i=n*n,s=n*e*2,a=e*e;return i*t[0]+s*t[1]+a*t[2]}controlCurve(e,t){this.p[1]=e/3+this.p[0],this.p[2]=this.p[3]-t/3}hull(e){let t=this.p,n=[],i,s=0,a=0,o=0;const c=[];for(c[s++]=t[0],c[s++]=t[1],c[s++]=t[2],c[s++]=t[3];t.length>1;){for(n=[],a=0,o=t.length-1;a<o;a++)i=e*t[a]+(1-e)*t[a+1],c[s++]=i,n.push(i);t=n}return c}split(e){const t=this.hull(e);return{left:new bn(t[0],t[4],t[7],t[9]),right:new bn(t[9],t[8],t[6],t[3]),span:t}}clone(){return new bn(this.p[0],this.p[1],this.p[2],this.p[3])}toJSON(){return{p0:this.p[0],p1:this.p[1],p2:this.p[2],p3:this.p[3]}}static fromJSON(e){return new bn(e.p0,e.p1,e.p2,e.p3)}}const si=r=>({r:r.x,g:r.y,b:r.z,a:r.w}),oi=r=>new tt(r.r,r.g,r.b,r.a),bh=(r,e)=>{switch(e){case"Vector3":return new G(r.x,r.y,r.z);case"Vector4":return new tt(r.x,r.y,r.z,r.w);case"Color":return new G(r.r,r.g,r.b);case"Number":return r;default:return r}},xh=(r,e)=>{switch(e){case"Vector3":return{x:r.x,y:r.y,z:r.z};case"Vector4":return{x:r.x,y:r.y,z:r.z,w:r.w};case"Color":return{r:r.x,g:r.y,b:r.z};case"Number":return r;default:return r}};class Yr{constructor(e,t){this.a=e,this.b=t,this.type="value"}startGen(e){}genColor(e,t){const n=Math.random();return t.copy(this.a).lerp(this.b,n)}toJSON(){return{type:"RandomColor",a:si(this.a),b:si(this.b)}}static fromJSON(e){return new Yr(oi(e.a),oi(e.b))}clone(){return new Yr(this.a.clone(),this.b.clone())}}class Gn{constructor(e,t){this.a=e,this.b=t,this.indexCount=-1,this.type="value"}startGen(e){this.indexCount=e.length,e.push(Math.random())}genColor(e,t){return this.indexCount===-1&&this.startGen(e),t.copy(this.a).lerp(this.b,e[this.indexCount])}toJSON(){return{type:"ColorRange",a:si(this.a),b:si(this.b)}}static fromJSON(e){return new Gn(oi(e.a),oi(e.b))}clone(){return new Gn(this.a.clone(),this.b.clone())}}class on{constructor(e,t){this.subType=t,this.type="function",this.keys=e}findKey(e){let t=0,n=0,i=this.keys.length-1;for(;n+1<i;)if(t=Math.floor((n+i)/2),e<this.getStartX(t))i=t-1;else if(e>this.getEndX(t))n=t+1;else return t;for(let s=n;s<=i;s++)if(e>=this.getStartX(s)&&e<=this.getEndX(s))return s;return-1}getStartX(e){return this.keys[e][1]}getEndX(e){return e+1<this.keys.length?this.keys[e+1][1]:1}genValue(e,t){const n=this.findKey(t);return this.subType==="Number"?n===-1?this.keys[0][0]:n+1>=this.keys.length?this.keys[this.keys.length-1][0]:(this.keys[n+1][0]-this.keys[n][0])*((t-this.getStartX(n))/(this.getEndX(n)-this.getStartX(n)))+this.keys[n][0]:n===-1?e.copy(this.keys[0][0]):n+1>=this.keys.length?e.copy(this.keys[this.keys.length-1][0]):e.copy(this.keys[n][0]).lerp(this.keys[n+1][0],(t-this.getStartX(n))/(this.getEndX(n)-this.getStartX(n)))}toJSON(){return this.keys[0][0].constructor.name,{type:"CLinearFunction",subType:this.subType,keys:this.keys.map(([e,t])=>({value:xh(e,this.subType),pos:t}))}}static fromJSON(e){return new on(e.keys.map(t=>[bh(t.value,e.subType),t.pos]),e.subType)}clone(){return this.subType==="Number"?new on(this.keys.map(([e,t])=>[e,t]),this.subType):new on(this.keys.map(([e,t])=>[e.clone(),t]),this.subType)}}const Sr=new G;class Tn{constructor(e=[[new G(0,0,0),0],[new G(1,1,1),0]],t=[[1,0],[1,1]]){this.type="function",this.color=new on(e,"Color"),this.alpha=new on(t,"Number")}genColor(e,t,n){return this.color.genValue(Sr,n),t.set(Sr.x,Sr.y,Sr.z,this.alpha.genValue(1,n))}toJSON(){return{type:"Gradient",color:this.color.toJSON(),alpha:this.alpha.toJSON()}}static fromJSON(e){if(e.functions){const t=e.functions.map(n=>[Gn.fromJSON(n.function).a,n.start]);return e.functions.length>0&&t.push([Gn.fromJSON(e.functions[e.functions.length-1].function).b,1]),new Tn(t.map(n=>[new G(n[0].x,n[0].y,n[0].z),n[1]]),t.map(n=>[n[0].w,n[1]]))}else{const t=new Tn;return t.alpha=on.fromJSON(e.alpha),t.color=on.fromJSON(e.color),t}}clone(){const e=new Tn;return e.alpha=this.alpha.clone(),e.color=this.color.clone(),e}startGen(e){}}const Ls=new tt;class Zr{constructor(e,t){this.indexCount=0,this.type="function",this.gradient1=e,this.gradient2=t}startGen(e){this.indexCount=e.length,e.push(Math.random())}genColor(e,t,n){return this.gradient1.genColor(e,t,n),this.gradient2.genColor(e,Ls,n),e&&e[this.indexCount]!==void 0?t.lerp(Ls,e[this.indexCount]):t.lerp(Ls,Math.random()),t}toJSON(){return{type:"RandomColorBetweenGradient",gradient1:this.gradient1.toJSON(),gradient2:this.gradient2.toJSON()}}static fromJSON(e){return new Zr(Tn.fromJSON(e.gradient1),Tn.fromJSON(e.gradient2))}clone(){return new Zr(this.gradient1.clone(),this.gradient2.clone())}}class xn{constructor(e){this.color=e,this.type="value"}startGen(e){}genColor(e,t){return t.copy(this.color)}toJSON(){return{type:"ConstantColor",color:si(this.color)}}static fromJSON(e){return new xn(oi(e.color))}clone(){return new xn(this.color.clone())}}function Fs(r){switch(r.type){case"ConstantColor":return xn.fromJSON(r);case"ColorRange":return Gn.fromJSON(r);case"RandomColor":return Yr.fromJSON(r);case"Gradient":return Tn.fromJSON(r);case"RandomColorBetweenGradient":return Zr.fromJSON(r);default:return new xn(new tt(1,1,1,1))}}class ne{constructor(e){this.value=e,this.type="value"}startGen(e){}genValue(e){return this.value}toJSON(){return{type:"ConstantValue",value:this.value}}static fromJSON(e){return new ne(e.value)}clone(){return new ne(this.value)}}class wn{constructor(e,t){this.a=e,this.b=t,this.indexCount=-1,this.type="value"}startGen(e){this.indexCount=e.length,e.push(Math.random())}genValue(e){return this.indexCount===-1&&this.startGen(e),An.lerp(this.a,this.b,e[this.indexCount])}toJSON(){return{type:"IntervalValue",a:this.a,b:this.b}}static fromJSON(e){return new wn(e.a,e.b)}clone(){return new wn(this.a,this.b)}}class wh{constructor(){this.functions=new Array}findFunction(e){let t=0,n=0,i=this.functions.length-1;for(;n+1<i;)if(t=Math.floor((n+i)/2),e<this.getStartX(t))i=t-1;else if(e>this.getEndX(t))n=t+1;else return t;for(let s=n;s<=i;s++)if(e>=this.functions[s][1]&&e<=this.getEndX(s))return s;return-1}getStartX(e){return this.functions[e][1]}setStartX(e,t){e>0&&(this.functions[e][1]=t)}getEndX(e){return e+1<this.functions.length?this.functions[e+1][1]:1}setEndX(e,t){e+1<this.functions.length&&(this.functions[e+1][1]=t)}insertFunction(e,t){const n=this.findFunction(e);this.functions.splice(n+1,0,[t,e])}removeFunction(e){return this.functions.splice(e,1)[0][0]}getFunction(e){return this.functions[e][0]}setFunction(e,t){this.functions[e][0]=t}get numOfFunctions(){return this.functions.length}}class _i extends wh{constructor(e=[[new bn(0,1/3,1/3*2,1),0]]){super(),this.type="function",this.functions=e}genValue(e,t=0){const n=this.findFunction(t);return n===-1?0:this.functions[n][0].genValue((t-this.getStartX(n))/(this.getEndX(n)-this.getStartX(n)))}toSVG(e,t){if(t<1)return"";let n=["M",0,this.functions[0][0].p[0]].join(" ");for(let i=1/t;i<=1;i+=1/t)n=[n,"L",i*e,this.genValue(void 0,i)].join(" ");return n}toJSON(){return{type:"PiecewiseBezier",functions:this.functions.map(([e,t])=>({function:e.toJSON(),start:t}))}}static fromJSON(e){return new _i(e.functions.map(t=>[bn.fromJSON(t.function),t.start]))}clone(){return new _i(this.functions.map(([e,t])=>[e.clone(),t]))}startGen(e){}}function Q(r){switch(r.type){case"ConstantValue":return ne.fromJSON(r);case"IntervalValue":return wn.fromJSON(r);case"PiecewiseBezier":return _i.fromJSON(r);default:return new ne(0)}}class Ti{constructor(){this.indexCount=0,this.type="rotation"}startGen(e){this.indexCount=e.length,e.push(new ie);let t,n,i,s,a,o;do t=Math.random()*2-1,n=Math.random()*2-1,i=t*t+n*n;while(i>1);do s=Math.random()*2-1,a=Math.random()*2-1,o=s*s+a*a;while(o>1);const c=Math.sqrt((1-i)/o);e[this.indexCount].set(t,n,c*s,c*a)}genValue(e,t,n,i){return this.indexCount===-1&&this.startGen(e),t.copy(e[this.indexCount]),t}toJSON(){return{type:"RandomQuat"}}static fromJSON(e){return new Ti}clone(){return new Ti}}class Mi{constructor(e,t){this.axis=e,this.angle=t,this.type="rotation"}startGen(e){this.angle.startGen(e)}genValue(e,t,n,i){return t.setFromAxisAngle(this.axis,this.angle.genValue(e,i)*n)}toJSON(){return{type:"AxisAngle",axis:{x:this.axis.x,y:this.axis.y,z:this.axis.z},angle:this.angle.toJSON()}}static fromJSON(e){return new Mi(new G(e.axis.x,e.axis.y,e.axis.z),Q(e.angle))}clone(){return new Mi(this.axis.clone(),this.angle.clone())}}class Kr{constructor(e,t,n,i){this.angleX=e,this.angleY=t,this.angleZ=n,this.type="rotation",this.eular=new wi(0,0,0,i)}startGen(e){this.angleX.startGen(e),this.angleY.startGen(e),this.angleZ.startGen(e)}genValue(e,t,n,i){return this.eular.set(this.angleX.genValue(e,i)*n,this.angleY.genValue(e,i)*n,this.angleZ.genValue(e,i)*n),t.setFromEuler(this.eular)}toJSON(){return{type:"Euler",angleX:this.angleX.toJSON(),angleY:this.angleY.toJSON(),angleZ:this.angleZ.toJSON(),eulerOrder:this.eular.order}}static fromJSON(e){return new Kr(Q(e.angleX),Q(e.angleY),Q(e.angleZ),e.eulerOrder)}clone(){return new Kr(this.angleX,this.angleY,this.angleZ,this.eular.order)}}function Uc(r){switch(r.type){case"AxisAngle":return Mi.fromJSON(r);case"Euler":return Kr.fromJSON(r);case"RandomQuat":return Ti.fromJSON(r);default:return new Ti}}class _n{constructor(e,t,n){this.x=e,this.y=t,this.z=n,this.type="vec3function"}startGen(e){this.x.startGen(e),this.y.startGen(e),this.z.startGen(e)}genValue(e,t,n){return t.set(this.x.genValue(e,n),this.y.genValue(e,n),this.z.genValue(e,n))}toJSON(){return{type:"Vector3Function",x:this.x.toJSON(),y:this.y.toJSON(),z:this.z.toJSON()}}static fromJSON(e){return new _n(Q(e.x),Q(e.y),Q(e.z))}clone(){return new _n(this.x,this.y,this.z)}}function _h(r){switch(r.type){case"Vector3Function":return _n.fromJSON(r);default:return new _n(new ne(0),new ne(0),new ne(0))}}function br(r){switch(r.type){case"ConstantValue":case"IntervalValue":case"PiecewiseBezier":return Q(r);case"AxisAngle":case"RandomQuat":case"Euler":return Uc(r);case"Vector3Function":return _h(r);default:return new ne(0)}}class Ci{constructor(e={}){var t,n,i,s,a,o,c;this.type="cone",this.currentValue=0,this.radius=(t=e.radius)!==null&&t!==void 0?t:10,this.arc=(n=e.arc)!==null&&n!==void 0?n:2*Math.PI,this.thickness=(i=e.thickness)!==null&&i!==void 0?i:1,this.angle=(s=e.angle)!==null&&s!==void 0?s:Math.PI/6,this.mode=(a=e.mode)!==null&&a!==void 0?a:Xe.Random,this.spread=(o=e.spread)!==null&&o!==void 0?o:0,this.speed=(c=e.speed)!==null&&c!==void 0?c:new ne(1),this.memory=[]}update(e,t){Xe.Random!=this.mode&&(this.currentValue+=this.speed.genValue(this.memory,e.emissionState.time/e.duration)*t)}initialize(e,t){const n=ri(this.mode,this.currentValue,this.spread,t),i=An.lerp(1-this.thickness,1,Math.random()),s=n*this.arc,a=Math.sqrt(i),o=Math.sin(s),c=Math.cos(s);e.position.x=a*c,e.position.y=a*o,e.position.z=0;const l=this.angle*a;e.velocity.set(0,0,Math.cos(l)).addScaledVector(e.position,Math.sin(l)).multiplyScalar(e.startSpeed),e.position.multiplyScalar(this.radius)}toJSON(){return{type:"cone",radius:this.radius,arc:this.arc,thickness:this.thickness,angle:this.angle,mode:this.mode,spread:this.spread,speed:this.speed.toJSON()}}static fromJSON(e){return new Ci({radius:e.radius,arc:e.arc,thickness:e.thickness,angle:e.angle,mode:e.mode,speed:e.speed?Q(e.speed):void 0,spread:e.spread})}clone(){return new Ci({radius:this.radius,arc:this.arc,thickness:this.thickness,angle:this.angle,mode:this.mode,speed:this.speed.clone(),spread:this.spread})}}class Ei{constructor(e={}){var t,n,i,s,a,o;this.type="circle",this.currentValue=0,this.radius=(t=e.radius)!==null&&t!==void 0?t:10,this.arc=(n=e.arc)!==null&&n!==void 0?n:2*Math.PI,this.thickness=(i=e.thickness)!==null&&i!==void 0?i:1,this.mode=(s=e.mode)!==null&&s!==void 0?s:Xe.Random,this.spread=(a=e.spread)!==null&&a!==void 0?a:0,this.speed=(o=e.speed)!==null&&o!==void 0?o:new ne(1),this.memory=[]}update(e,t){this.currentValue+=this.speed.genValue(this.memory,e.emissionState.time/e.duration)*t}initialize(e,t){const n=ri(this.mode,this.currentValue,this.spread,t),i=An.lerp(1-this.thickness,1,Math.random()),s=n*this.arc;e.position.x=Math.cos(s),e.position.y=Math.sin(s),e.position.z=0,e.velocity.copy(e.position).multiplyScalar(e.startSpeed),e.position.multiplyScalar(this.radius*i)}toJSON(){return{type:"circle",radius:this.radius,arc:this.arc,thickness:this.thickness,mode:this.mode,spread:this.spread,speed:this.speed.toJSON()}}static fromJSON(e){return new Ei({radius:e.radius,arc:e.arc,thickness:e.thickness,mode:e.mode,speed:e.speed?Q(e.speed):void 0,spread:e.spread})}clone(){return new Ei({radius:this.radius,arc:this.arc,thickness:this.thickness,mode:this.mode,speed:this.speed.clone(),spread:this.spread})}}function xr(r,e){return Math.floor(Math.random()*(e-r))+r}const wr=new G(0,1,0),_r=new G(0,0,0),Th=new G(1,1,1),Dc=new G(0,0,1);class Pi{constructor(e={}){var t,n,i,s,a,o,c;this.type="donut",this.currentValue=0,this.radius=(t=e.radius)!==null&&t!==void 0?t:10,this.arc=(n=e.arc)!==null&&n!==void 0?n:2*Math.PI,this.thickness=(i=e.thickness)!==null&&i!==void 0?i:1,this.donutRadius=(s=e.donutRadius)!==null&&s!==void 0?s:this.radius*.2,this.mode=(a=e.mode)!==null&&a!==void 0?a:Xe.Random,this.spread=(o=e.spread)!==null&&o!==void 0?o:0,this.speed=(c=e.speed)!==null&&c!==void 0?c:new ne(1),this.memory=[],this._m1=new Rt}update(e,t){Xe.Random!=this.mode&&(this.currentValue+=this.speed.genValue(this.memory,e.emissionState.time/e.duration)*t)}initialize(e,t){const n=ri(this.mode,this.currentValue,this.spread,t),i=Math.random(),s=An.lerp(1-this.thickness,1,Math.random()),a=n*this.arc,o=i*Math.PI*2,c=Math.sin(a),l=Math.cos(a);e.position.x=this.radius*l,e.position.y=this.radius*c,e.position.z=0,e.velocity.z=this.donutRadius*s*Math.sin(o),e.velocity.x=this.donutRadius*s*Math.cos(o)*l,e.velocity.y=this.donutRadius*s*Math.cos(o)*c,e.position.add(e.velocity),e.velocity.normalize().multiplyScalar(e.startSpeed),e.rotation instanceof ie&&(this._m1.lookAt(_r,e.velocity,wr),e.rotation.setFromRotationMatrix(this._m1))}toJSON(){return{type:"donut",radius:this.radius,arc:this.arc,thickness:this.thickness,donutRadius:this.donutRadius,mode:this.mode,spread:this.spread,speed:this.speed.toJSON()}}static fromJSON(e){return new Pi({radius:e.radius,arc:e.arc,thickness:e.thickness,donutRadius:e.donutRadius,mode:e.mode,speed:e.speed?Q(e.speed):void 0,spread:e.spread})}clone(){return new Pi({radius:this.radius,arc:this.arc,thickness:this.thickness,donutRadius:this.donutRadius,mode:this.mode,speed:this.speed.clone(),spread:this.spread})}}class ki{constructor(){this.type="point",this._m1=new Rt}update(e,t){}initialize(e){const t=Math.random(),n=Math.random(),i=t*Math.PI*2,s=Math.acos(2*n-1),a=Math.cbrt(Math.random()),o=Math.sin(i),c=Math.cos(i),l=Math.sin(s),u=Math.cos(s);e.velocity.x=a*l*c,e.velocity.y=a*l*o,e.velocity.z=a*u,e.velocity.multiplyScalar(e.startSpeed),e.position.setScalar(0),e.rotation instanceof ie&&(this._m1.lookAt(_r,e.position,wr),e.rotation.setFromRotationMatrix(this._m1))}toJSON(){return{type:"point"}}static fromJSON(e){return new ki}clone(){return new ki}}class Wn{constructor(e={}){var t,n,i,s,a,o;this.type="sphere",this.currentValue=0,this.radius=(t=e.radius)!==null&&t!==void 0?t:10,this.arc=(n=e.arc)!==null&&n!==void 0?n:2*Math.PI,this.thickness=(i=e.thickness)!==null&&i!==void 0?i:1,this.mode=(s=e.mode)!==null&&s!==void 0?s:Xe.Random,this.spread=(a=e.spread)!==null&&a!==void 0?a:0,this.speed=(o=e.speed)!==null&&o!==void 0?o:new ne(1),this.memory=[],this._m1=new Rt}update(e,t){Xe.Random!=this.mode&&(this.currentValue+=this.speed.genValue(this.memory,e.emissionState.time/e.duration)*t)}initialize(e,t){const n=ri(this.mode,this.currentValue,this.spread,t),i=Math.random(),s=An.lerp(1-this.thickness,1,Math.random()),a=n*this.arc,o=Math.acos(2*i-1),c=Math.sin(a),l=Math.cos(a),u=Math.sin(o),p=Math.cos(o);e.position.x=u*l,e.position.y=u*c,e.position.z=p,e.velocity.copy(e.position).multiplyScalar(e.startSpeed),e.position.multiplyScalar(this.radius*s),e.rotation instanceof ie&&(this._m1.lookAt(_r,e.position,wr),e.rotation.setFromRotationMatrix(this._m1))}toJSON(){return{type:"sphere",radius:this.radius,arc:this.arc,thickness:this.thickness,mode:this.mode,spread:this.spread,speed:this.speed.toJSON()}}static fromJSON(e){return new Wn({radius:e.radius,arc:e.arc,thickness:e.thickness,mode:e.mode,speed:e.speed?Q(e.speed):void 0,spread:e.spread})}clone(){return new Wn({radius:this.radius,arc:this.arc,thickness:this.thickness,mode:this.mode,speed:this.speed.clone(),spread:this.spread})}}class Ri{constructor(e={}){var t,n,i,s,a,o;this.type="sphere",this.currentValue=0,this.radius=(t=e.radius)!==null&&t!==void 0?t:10,this.arc=(n=e.arc)!==null&&n!==void 0?n:2*Math.PI,this.thickness=(i=e.thickness)!==null&&i!==void 0?i:1,this.mode=(s=e.mode)!==null&&s!==void 0?s:Xe.Random,this.spread=(a=e.spread)!==null&&a!==void 0?a:0,this.speed=(o=e.speed)!==null&&o!==void 0?o:new ne(1),this.memory=[],this._m1=new Rt}update(e,t){Xe.Random!=this.mode&&(this.currentValue+=this.speed.genValue(this.memory,e.emissionState.time/e.duration)*t)}initialize(e,t){const n=ri(this.mode,this.currentValue,this.spread,t),i=Math.random(),s=An.lerp(1-this.thickness,1,Math.random()),a=n*this.arc,o=Math.acos(i),c=Math.sin(a),l=Math.cos(a),u=Math.sin(o),p=Math.cos(o);e.position.x=u*l,e.position.y=u*c,e.position.z=p,e.velocity.copy(e.position).multiplyScalar(e.startSpeed),e.position.multiplyScalar(this.radius*s),e.rotation instanceof ie&&(this._m1.lookAt(_r,e.position,wr),e.rotation.setFromRotationMatrix(this._m1))}toJSON(){return{type:"hemisphere",radius:this.radius,arc:this.arc,thickness:this.thickness,mode:this.mode,spread:this.spread,speed:this.speed.toJSON()}}static fromJSON(e){return new Ri({radius:e.radius,arc:e.arc,thickness:e.thickness,mode:e.mode,speed:e.speed?Q(e.speed):void 0,spread:e.spread})}clone(){return new Ri({radius:this.radius,arc:this.arc,thickness:this.thickness,mode:this.mode,speed:this.speed.clone(),spread:this.spread})}}class Ai{constructor(e={}){var t,n,i,s;this.type="grid",this.width=(t=e.width)!==null&&t!==void 0?t:1,this.height=(n=e.height)!==null&&n!==void 0?n:1,this.column=(i=e.column)!==null&&i!==void 0?i:10,this.row=(s=e.row)!==null&&s!==void 0?s:10}initialize(e){const t=Math.floor(Math.random()*this.row),n=Math.floor(Math.random()*this.column);e.position.x=n*this.width/this.column-this.width/2,e.position.y=t*this.height/this.row-this.height/2,e.position.z=0,e.velocity.set(0,0,e.startSpeed)}toJSON(){return{type:"grid",width:this.width,height:this.height,column:this.column,row:this.row}}static fromJSON(e){return new Ai(e)}clone(){return new Ai({width:this.width,height:this.height,column:this.column,row:this.row})}update(e,t){}}const Vs={circle:{type:"circle",params:[["radius",["number"]],["arc",["radian"]],["thickness",["number"]],["mode",["emitterMode"]],["spread",["number"]],["speed",["valueFunc"]]],constructor:Ei,loadJSON:Ei.fromJSON},cone:{type:"cone",params:[["radius",["number"]],["arc",["radian"]],["thickness",["number"]],["angle",["radian"]],["mode",["emitterMode"]],["spread",["number"]],["speed",["valueFunc"]]],constructor:Ci,loadJSON:Ci.fromJSON},donut:{type:"donut",params:[["radius",["number"]],["arc",["radian"]],["thickness",["number"]],["donutRadius",["number"]],["mode",["emitterMode"]],["spread",["number"]],["speed",["valueFunc"]]],constructor:Pi,loadJSON:Pi.fromJSON},point:{type:"point",params:[],constructor:ki,loadJSON:ki.fromJSON},sphere:{type:"sphere",params:[["radius",["number"]],["arc",["radian"]],["thickness",["number"]],["angle",["radian"]],["mode",["emitterMode"]],["spread",["number"]],["speed",["valueFunc"]]],constructor:Wn,loadJSON:Wn.fromJSON},hemisphere:{type:"hemisphere",params:[["radius",["number"]],["arc",["radian"]],["thickness",["number"]],["angle",["radian"]],["mode",["emitterMode"]],["spread",["number"]],["speed",["valueFunc"]]],constructor:Ri,loadJSON:Ri.fromJSON},grid:{type:"grid",params:[["width",["number"]],["height",["number"]],["rows",["number"]],["column",["number"]]],constructor:Ai,loadJSON:Ai.fromJSON}};function Mh(r,e){return Vs[r.type].loadJSON(r,e)}class Oi{constructor(e){this.color=e,this.type="ColorOverLife"}initialize(e){this.color.startGen(e.memory)}update(e,t){this.color.genColor(e.memory,e.color,e.age/e.life),e.color.x*=e.startColor.x,e.color.y*=e.startColor.y,e.color.z*=e.startColor.z,e.color.w*=e.startColor.w}frameUpdate(e){}toJSON(){return{type:this.type,color:this.color.toJSON()}}static fromJSON(e){return new Oi(Fs(e.color))}clone(){return new Oi(this.color.clone())}reset(){}}class Ii{constructor(e){this.angularVelocity=e,this.type="RotationOverLife"}initialize(e){typeof e.rotation=="number"&&this.angularVelocity.startGen(e.memory)}update(e,t){typeof e.rotation=="number"&&(e.rotation+=t*this.angularVelocity.genValue(e.memory,e.age/e.life))}toJSON(){return{type:this.type,angularVelocity:this.angularVelocity.toJSON()}}static fromJSON(e){return new Ii(Q(e.angularVelocity))}frameUpdate(e){}clone(){return new Ii(this.angularVelocity.clone())}reset(){}}class zi{constructor(e){this.angularVelocity=e,this.type="Rotation3DOverLife",this.tempQuat=new ie,this.tempQuat2=new ie}initialize(e){e.rotation instanceof ie&&(e.angularVelocity=new ie,this.angularVelocity.startGen(e.memory))}update(e,t){e.rotation instanceof ie&&(this.angularVelocity.genValue(e.memory,this.tempQuat,t,e.age/e.life),e.rotation.multiply(this.tempQuat))}toJSON(){return{type:this.type,angularVelocity:this.angularVelocity.toJSON()}}static fromJSON(e){return new zi(Uc(e.angularVelocity))}frameUpdate(e){}clone(){return new zi(this.angularVelocity.clone())}reset(){}}class Bi{initialize(e,t){this.ps=t,this.x.startGen(e.memory),this.y.startGen(e.memory),this.z.startGen(e.memory)}constructor(e,t,n){this.x=e,this.y=t,this.z=n,this.type="ForceOverLife",this._temp=new G,this._tempScale=new G,this._tempQ=new ie}update(e,t){this._temp.set(this.x.genValue(e.memory,e.age/e.life),this.y.genValue(e.memory,e.age/e.life),this.z.genValue(e.memory,e.age/e.life)),this.ps.worldSpace?e.velocity.addScaledVector(this._temp,t):(this._temp.multiply(this._tempScale).applyQuaternion(this._tempQ),e.velocity.addScaledVector(this._temp,t))}toJSON(){return{type:this.type,x:this.x.toJSON(),y:this.y.toJSON(),z:this.z.toJSON()}}static fromJSON(e){return new Bi(Q(e.x),Q(e.y),Q(e.z))}frameUpdate(e){if(this.ps&&!this.ps.worldSpace){const t=this._temp,n=this._tempQ,i=this._tempScale;this.ps.emitter.matrixWorld.decompose(t,n,i),n.invert(),i.set(1/i.x,1/i.y,1/i.z)}}clone(){return new Bi(this.x.clone(),this.y.clone(),this.z.clone())}reset(){}}class Ni{initialize(e){this.size.startGen(e.memory)}constructor(e){this.size=e,this.type="SizeOverLife"}update(e){this.size instanceof _n?this.size.genValue(e.memory,e.size,e.age/e.life).multiply(e.startSize):e.size.copy(e.startSize).multiplyScalar(this.size.genValue(e.memory,e.age/e.life))}toJSON(){return{type:this.type,size:this.size.toJSON()}}static fromJSON(e){return new Ni(br(e.size))}frameUpdate(e){}clone(){return new Ni(this.size.clone())}reset(){}}class Ui{initialize(e){this.speed.startGen(e.memory)}constructor(e){this.speed=e,this.type="SpeedOverLife"}update(e){e.speedModifier=this.speed.genValue(e.memory,e.age/e.life)}toJSON(){return{type:this.type,speed:this.speed.toJSON()}}static fromJSON(e){return new Ui(Q(e.speed))}frameUpdate(e){}clone(){return new Ui(this.speed.clone())}reset(){}}class Di{constructor(e){this.frame=e,this.type="FrameOverLife"}initialize(e){this.frame.startGen(e.memory)}update(e,t){this.frame instanceof _i&&(e.uvTile=this.frame.genValue(e.memory,e.age/e.life))}frameUpdate(e){}toJSON(){return{type:this.type,frame:this.frame.toJSON()}}static fromJSON(e){return new Di(Q(e.frame))}clone(){return new Di(this.frame.clone())}reset(){}}class Li{constructor(e,t=new G(0,1,0)){this.orbitSpeed=e,this.axis=t,this.type="OrbitOverLife",this.temp=new G,this.rotation=new ie}initialize(e){this.orbitSpeed.startGen(e.memory)}update(e,t){this.temp.copy(e.position).projectOnVector(this.axis),this.rotation.setFromAxisAngle(this.axis,this.orbitSpeed.genValue(e.memory,e.age/e.life)*t),e.position.sub(this.temp),e.position.applyQuaternion(this.rotation),e.position.add(this.temp)}frameUpdate(e){}toJSON(){return{type:this.type,orbitSpeed:this.orbitSpeed.toJSON(),axis:[this.axis.x,this.axis.y,this.axis.z]}}static fromJSON(e){return new Li(Q(e.orbitSpeed),e.axis?new G(e.axis[0],e.axis[1],e.axis[2]):void 0)}clone(){return new Li(this.orbitSpeed.clone())}reset(){}}class js{constructor(e){this.data=e,this.next=null,this.prev=null}hasPrev(){return this.prev!==null}hasNext(){return this.next!==null}}class Ch{constructor(){this.length=0,this.head=this.tail=null}isEmpty(){return this.head===null}clear(){this.length=0,this.head=this.tail=null}front(){return this.head===null?null:this.head.data}back(){return this.tail===null?null:this.tail.data}dequeue(){if(this.head){const e=this.head.data;return this.head=this.head.next,this.head?this.head.prev=null:this.tail=null,this.length--,e}}pop(){if(this.tail){const e=this.tail.data;return this.tail=this.tail.prev,this.tail?this.tail.next=null:this.head=null,this.length--,e}}queue(e){const t=new js(e);this.tail||(this.tail=t),this.head&&(this.head.prev=t,t.next=this.head),this.head=t,this.length++}push(e){const t=new js(e);this.head||(this.head=t),this.tail&&(this.tail.next=t,t.prev=this.tail),this.tail=t,this.length++}insertBefore(e,t){const n=new js(t);n.next=e,n.prev=e.prev,n.prev!==null&&(n.prev.next=n),n.next.prev=n,e==this.head&&(this.head=n),this.length++}remove(e){if(this.head===null||this.tail===null)return;let t=this.head;for(e===this.head.data&&(this.head=this.head.next),e===this.tail.data&&(this.tail=this.tail.prev);t.next!==null&&t.data!==e;)t=t.next;t.data===e&&(t.prev!==null&&(t.prev.next=t.next),t.next!==null&&(t.next.prev=t.prev),this.length--)}*values(){let e=this.head;for(;e!==null;)yield e.data,e=e.next}}class Eh{constructor(){this.startSpeed=0,this.startColor=new tt,this.startSize=new G(1,1,1),this.position=new G,this.velocity=new G,this.age=0,this.life=1,this.size=new G(1,1,1),this.speedModifier=1,this.rotation=0,this.color=new tt,this.uvTile=0,this.memory=[]}get died(){return this.age>=this.life}reset(){this.memory.length=0}}class Ph{constructor(e,t,n){this.position=e,this.size=t,this.color=n}}class Tr{constructor(){this.startSpeed=0,this.startColor=new tt,this.startSize=new G(1,1,1),this.position=new G,this.velocity=new G,this.age=0,this.life=1,this.size=new G(1,1,1),this.length=100,this.speedModifier=1,this.color=new tt,this.previous=new Ch,this.uvTile=0,this.memory=[]}update(){for(this.age<=this.life?this.previous.push(new Ph(this.position.clone(),this.size.x,this.color.clone())):this.previous.length>0&&this.previous.dequeue();this.previous.length>this.length;)this.previous.dequeue()}get died(){return this.age>=this.life}reset(){this.memory.length=0,this.previous.clear()}}class Fi{initialize(e){this.width.startGen(e.memory)}constructor(e){this.width=e,this.type="WidthOverLength"}update(e){if(e instanceof Tr){const t=e.previous.values();for(let n=0;n<e.previous.length;n++){const i=t.next();i.value.size=this.width.genValue(e.memory,(e.previous.length-n)/e.length)}}}frameUpdate(e){}toJSON(){return{type:this.type,width:this.width.toJSON()}}static fromJSON(e){return new Fi(Q(e.width))}clone(){return new Fi(this.width.clone())}reset(){}}class Vi{constructor(e,t){this.direction=e,this.magnitude=t,this.type="ApplyForce",this.memory={data:[],dataCount:0},this.magnitudeValue=this.magnitude.genValue(this.memory)}initialize(e){}update(e,t){e.velocity.addScaledVector(this.direction,this.magnitudeValue*t)}frameUpdate(e){this.magnitudeValue=this.magnitude.genValue(this.memory)}toJSON(){return{type:this.type,direction:[this.direction.x,this.direction.y,this.direction.z],magnitude:this.magnitude.toJSON()}}static fromJSON(e){var t;return new Vi(new G(e.direction[0],e.direction[1],e.direction[2]),Q((t=e.magnitude)!==null&&t!==void 0?t:e.force))}clone(){return new Vi(this.direction.clone(),this.magnitude.clone())}reset(){}}class ji{constructor(e,t){this.center=e,this.magnitude=t,this.type="GravityForce",this.temp=new G}initialize(e){}update(e,t){this.temp.copy(this.center).sub(e.position).normalize(),e.velocity.addScaledVector(this.temp,this.magnitude/e.position.distanceToSquared(this.center)*t)}frameUpdate(e){}toJSON(){return{type:this.type,center:[this.center.x,this.center.y,this.center.z],magnitude:this.magnitude}}static fromJSON(e){return new ji(new G(e.center[0],e.center[1],e.center[2]),e.magnitude)}clone(){return new ji(this.center.clone(),this.magnitude)}reset(){}}class Ji{constructor(e){this.angle=e,this.type="ChangeEmitDirection",this._temp=new G,this._q=new ie,this.memory={data:[],dataCount:0}}initialize(e){const t=e.velocity.length();t!=0&&(e.velocity.normalize(),e.velocity.x===0&&e.velocity.y===0?this._temp.set(0,e.velocity.z,0):this._temp.set(-e.velocity.y,e.velocity.x,0),this.angle.startGen(this.memory),this._q.setFromAxisAngle(this._temp.normalize(),this.angle.genValue(this.memory)),this._temp.copy(e.velocity),e.velocity.applyQuaternion(this._q),this._q.setFromAxisAngle(this._temp,Math.random()*Math.PI*2),e.velocity.applyQuaternion(this._q),e.velocity.setLength(t))}update(e,t){}frameUpdate(e){}toJSON(){return{type:this.type,angle:this.angle.toJSON()}}static fromJSON(e){return new Ji(Q(e.angle))}clone(){return new Ji(this.angle)}reset(){}}var In;(function(r){r[r.Death=0]="Death",r[r.Birth=1]="Birth",r[r.Frame=2]="Frame"})(In||(In={}));class Gi{constructor(e,t,n,i=In.Frame,s=1){this.particleSystem=e,this.useVelocityAsBasis=t,this.subParticleSystem=n,this.mode=i,this.emitProbability=s,this.type="EmitSubParticleSystem",this.q_=new ie,this.v_=new G,this.v2_=new G,this.subEmissions=new Array,this.subParticleSystem&&this.subParticleSystem.system&&(this.subParticleSystem.system.onlyUsedByOther=!0)}initialize(e){}update(e,t){this.mode===In.Frame?this.emit(e,t):this.mode===In.Birth&&e.age===0?this.emit(e,t):this.mode===In.Death&&e.age+t>=e.life&&this.emit(e,t)}emit(e,t){if(!this.subParticleSystem||Math.random()>this.emitProbability)return;const n=new Rt;this.setMatrixFromParticle(n,e),this.subEmissions.push({burstParticleCount:0,burstParticleIndex:0,isBursting:!1,burstIndex:0,burstWaveIndex:0,time:0,waitEmiting:0,matrix:n,travelDistance:0,particle:e})}frameUpdate(e){if(this.subParticleSystem)for(let t=0;t<this.subEmissions.length;t++)if(this.subEmissions[t].time>=this.subParticleSystem.system.duration)this.subEmissions[t]=this.subEmissions[this.subEmissions.length-1],this.subEmissions.length=this.subEmissions.length-1,t--;else{const n=this.subEmissions[t];n.particle&&n.particle.age<n.particle.life?this.setMatrixFromParticle(n.matrix,n.particle):n.particle=void 0,this.subParticleSystem.system.emit(e,n,n.matrix)}}toJSON(){return{type:this.type,subParticleSystem:this.subParticleSystem?this.subParticleSystem.uuid:"",useVelocityAsBasis:this.useVelocityAsBasis,mode:this.mode,emitProbability:this.emitProbability}}static fromJSON(e,t){return new Gi(t,e.useVelocityAsBasis,e.subParticleSystem,e.mode,e.emitProbability)}clone(){return new Gi(this.particleSystem,this.useVelocityAsBasis,this.subParticleSystem,this.mode,this.emitProbability)}reset(){}setMatrixFromParticle(e,t){let n;if(t.rotation===void 0||this.useVelocityAsBasis)if(t.velocity.x===0&&t.velocity.y===0&&(t.velocity.z===1||t.velocity.z===0))e.set(1,0,0,t.position.x,0,1,0,t.position.y,0,0,1,t.position.z,0,0,0,1);else{this.v_.copy(Dc).cross(t.velocity),this.v2_.copy(t.velocity).cross(this.v_);const i=this.v_.length(),s=this.v2_.length();e.set(this.v_.x/i,this.v2_.x/s,t.velocity.x,t.position.x,this.v_.y/i,this.v2_.y/s,t.velocity.y,t.position.y,this.v_.z/i,this.v2_.z/s,t.velocity.z,t.position.z,0,0,0,1)}else t.rotation instanceof ie?n=t.rotation:(this.q_.setFromAxisAngle(Dc,t.rotation),n=this.q_),e.compose(t.position,n,Th);this.particleSystem.worldSpace||e.multiplyMatrices(this.particleSystem.emitter.matrixWorld,e)}}const kh=.5*(Math.sqrt(3)-1),ai=(3-Math.sqrt(3))/6,Rh=1/3,Nt=1/6,Ah=(Math.sqrt(5)-1)/4,Be=(5-Math.sqrt(5))/20,Ae=new Float32Array([1,1,0,-1,1,0,1,-1,0,-1,-1,0,1,0,1,-1,0,1,1,0,-1,-1,0,-1,0,1,1,0,-1,1,0,1,-1,0,-1,-1]),_e=new Float32Array([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]);class Lc{constructor(e=Math.random){const t=typeof e=="function"?e:Ih(e);this.p=Oh(t),this.perm=new Uint8Array(512),this.permMod12=new Uint8Array(512);for(let n=0;n<512;n++)this.perm[n]=this.p[n&255],this.permMod12[n]=this.perm[n]%12}noise2D(e,t){const n=this.permMod12,i=this.perm;let s=0,a=0,o=0;const c=(e+t)*kh,l=Math.floor(e+c),u=Math.floor(t+c),p=(l+u)*ai,f=l-p,m=u-p,b=e-f,x=t-m;let g,v;b>x?(g=1,v=0):(g=0,v=1);const _=b-g+ai,w=x-v+ai,C=b-1+2*ai,M=x-1+2*ai,E=l&255,P=u&255;let O=.5-b*b-x*x;if(O>=0){const B=n[E+i[P]]*3;O*=O,s=O*O*(Ae[B]*b+Ae[B+1]*x)}let R=.5-_*_-w*w;if(R>=0){const B=n[E+g+i[P+v]]*3;R*=R,a=R*R*(Ae[B]*_+Ae[B+1]*w)}let A=.5-C*C-M*M;if(A>=0){const B=n[E+1+i[P+1]]*3;A*=A,o=A*A*(Ae[B]*C+Ae[B+1]*M)}return 70*(s+a+o)}noise3D(e,t,n){const i=this.permMod12,s=this.perm;let a,o,c,l;const u=(e+t+n)*Rh,p=Math.floor(e+u),f=Math.floor(t+u),m=Math.floor(n+u),b=(p+f+m)*Nt,x=p-b,g=f-b,v=m-b,_=e-x,w=t-g,C=n-v;let M,E,P,O,R,A;_>=w?w>=C?(M=1,E=0,P=0,O=1,R=1,A=0):_>=C?(M=1,E=0,P=0,O=1,R=0,A=1):(M=0,E=0,P=1,O=1,R=0,A=1):w<C?(M=0,E=0,P=1,O=0,R=1,A=1):_<C?(M=0,E=1,P=0,O=0,R=1,A=1):(M=0,E=1,P=0,O=1,R=1,A=0);const B=_-M+Nt,z=w-E+Nt,D=C-P+Nt,F=_-O+2*Nt,H=w-R+2*Nt,q=C-A+2*Nt,$=_-1+3*Nt,J=w-1+3*Nt,Se=C-1+3*Nt,ce=p&255,me=f&255,le=m&255;let xe=.6-_*_-w*w-C*C;if(xe<0)a=0;else{const oe=i[ce+s[me+s[le]]]*3;xe*=xe,a=xe*xe*(Ae[oe]*_+Ae[oe+1]*w+Ae[oe+2]*C)}let Ce=.6-B*B-z*z-D*D;if(Ce<0)o=0;else{const oe=i[ce+M+s[me+E+s[le+P]]]*3;Ce*=Ce,o=Ce*Ce*(Ae[oe]*B+Ae[oe+1]*z+Ae[oe+2]*D)}let ye=.6-F*F-H*H-q*q;if(ye<0)c=0;else{const oe=i[ce+O+s[me+R+s[le+A]]]*3;ye*=ye,c=ye*ye*(Ae[oe]*F+Ae[oe+1]*H+Ae[oe+2]*q)}let pe=.6-$*$-J*J-Se*Se;if(pe<0)l=0;else{const oe=i[ce+1+s[me+1+s[le+1]]]*3;pe*=pe,l=pe*pe*(Ae[oe]*$+Ae[oe+1]*J+Ae[oe+2]*Se)}return 32*(a+o+c+l)}noise4D(e,t,n,i){const s=this.perm;let a,o,c,l,u;const p=(e+t+n+i)*Ah,f=Math.floor(e+p),m=Math.floor(t+p),b=Math.floor(n+p),x=Math.floor(i+p),g=(f+m+b+x)*Be,v=f-g,_=m-g,w=b-g,C=x-g,M=e-v,E=t-_,P=n-w,O=i-C;let R=0,A=0,B=0,z=0;M>E?R++:A++,M>P?R++:B++,M>O?R++:z++,E>P?A++:B++,E>O?A++:z++,P>O?B++:z++;const D=R>=3?1:0,F=A>=3?1:0,H=B>=3?1:0,q=z>=3?1:0,$=R>=2?1:0,J=A>=2?1:0,Se=B>=2?1:0,ce=z>=2?1:0,me=R>=1?1:0,le=A>=1?1:0,xe=B>=1?1:0,Ce=z>=1?1:0,ye=M-D+Be,pe=E-F+Be,oe=P-H+Be,nt=O-q+Be,je=M-$+2*Be,Ye=E-J+2*Be,it=P-Se+2*Be,Oe=O-ce+2*Be,fe=M-me+3*Be,ae=E-le+3*Be,lt=P-xe+3*Be,Ee=O-Ce+3*Be,ue=M-1+4*Be,Ze=E-1+4*Be,St=P-1+4*Be,bt=O-1+4*Be,Ke=f&255,xt=m&255,ut=b&255,ht=x&255;let rt=.6-M*M-E*E-P*P-O*O;if(rt<0)a=0;else{const ee=s[Ke+s[xt+s[ut+s[ht]]]]%32*4;rt*=rt,a=rt*rt*(_e[ee]*M+_e[ee+1]*E+_e[ee+2]*P+_e[ee+3]*O)}let Pe=.6-ye*ye-pe*pe-oe*oe-nt*nt;if(Pe<0)o=0;else{const ee=s[Ke+D+s[xt+F+s[ut+H+s[ht+q]]]]%32*4;Pe*=Pe,o=Pe*Pe*(_e[ee]*ye+_e[ee+1]*pe+_e[ee+2]*oe+_e[ee+3]*nt)}let Je=.6-je*je-Ye*Ye-it*it-Oe*Oe;if(Je<0)c=0;else{const ee=s[Ke+$+s[xt+J+s[ut+Se+s[ht+ce]]]]%32*4;Je*=Je,c=Je*Je*(_e[ee]*je+_e[ee+1]*Ye+_e[ee+2]*it+_e[ee+3]*Oe)}let st=.6-fe*fe-ae*ae-lt*lt-Ee*Ee;if(st<0)l=0;else{const ee=s[Ke+me+s[xt+le+s[ut+xe+s[ht+Ce]]]]%32*4;st*=st,l=st*st*(_e[ee]*fe+_e[ee+1]*ae+_e[ee+2]*lt+_e[ee+3]*Ee)}let Ge=.6-ue*ue-Ze*Ze-St*St-bt*bt;if(Ge<0)u=0;else{const ee=s[Ke+1+s[xt+1+s[ut+1+s[ht+1]]]]%32*4;Ge*=Ge,u=Ge*Ge*(_e[ee]*ue+_e[ee+1]*Ze+_e[ee+2]*St+_e[ee+3]*bt)}return 27*(a+o+c+l+u)}}function Oh(r){const e=new Uint8Array(256);for(let t=0;t<256;t++)e[t]=t;for(let t=0;t<255;t++){const n=t+~~(r()*(256-t)),i=e[t];e[t]=e[n],e[n]=i}return e}function Ih(r){let e=0,t=0,n=0,i=1;const s=zh();return e=s(" "),t=s(" "),n=s(" "),e-=s(r),e<0&&(e+=1),t-=s(r),t<0&&(t+=1),n-=s(r),n<0&&(n+=1),function(){const a=2091639*e+i*23283064365386963e-26;return e=t,t=n,n=a-(i=a|0)}}function zh(){let r=4022871197;return function(e){e=e.toString();for(let t=0;t<e.length;t++){r+=e.charCodeAt(t);let n=.02519603282416938*r;r=n>>>0,n-=r,n*=r,r=n>>>0,n-=r,r+=n*4294967296}return(r>>>0)*23283064365386963e-26}}class Wi{constructor(e,t,n,i){this.scale=e,this.octaves=t,this.velocityMultiplier=n,this.timeScale=i,this.type="TurbulenceField",this.generator=new Lc,this.timeOffset=new G,this.temp=new G,this.temp2=new G,this.timeOffset.x=Math.random()/this.scale.x*this.timeScale.x,this.timeOffset.y=Math.random()/this.scale.y*this.timeScale.y,this.timeOffset.z=Math.random()/this.scale.z*this.timeScale.z}initialize(e){}update(e,t){const n=e.position.x/this.scale.x,i=e.position.y/this.scale.y,s=e.position.z/this.scale.z;this.temp.set(0,0,0);let a=1;for(let o=0;o<this.octaves;o++)this.temp2.set(this.generator.noise4D(n*a,i*a,s*a,this.timeOffset.x*a)/a,this.generator.noise4D(n*a,i*a,s*a,this.timeOffset.y*a)/a,this.generator.noise4D(n*a,i*a,s*a,this.timeOffset.z*a)/a),this.temp.add(this.temp2),a*=2;this.temp.multiply(this.velocityMultiplier),e.velocity.addScaledVector(this.temp,t)}toJSON(){return{type:this.type,scale:[this.scale.x,this.scale.y,this.scale.z],octaves:this.octaves,velocityMultiplier:[this.velocityMultiplier.x,this.velocityMultiplier.y,this.velocityMultiplier.z],timeScale:[this.timeScale.x,this.timeScale.y,this.timeScale.z]}}frameUpdate(e){this.timeOffset.x+=e*this.timeScale.x,this.timeOffset.y+=e*this.timeScale.y,this.timeOffset.z+=e*this.timeScale.z}static fromJSON(e){return new Wi(new G(e.scale[0],e.scale[1],e.scale[2]),e.octaves,new G(e.velocityMultiplier[0],e.velocityMultiplier[1],e.velocityMultiplier[2]),new G(e.timeScale[0],e.timeScale[1],e.timeScale[2]))}clone(){return new Wi(this.scale.clone(),this.octaves,this.velocityMultiplier.clone(),this.timeScale.clone())}reset(){}}const Ut=[],Js=new G,Gs=new ie;class Hi{constructor(e,t,n=new ne(1),i=new ne(0)){if(this.frequency=e,this.power=t,this.positionAmount=n,this.rotationAmount=i,this.type="Noise",this.duration=0,Ut.length===0)for(let s=0;s<100;s++)Ut.push(new Lc)}initialize(e){e.lastPosNoise=new G,typeof e.rotation=="number"?e.lastRotNoise=0:e.lastRotNoise=new ie,e.generatorIndex=[xr(0,100),xr(0,100),xr(0,100),xr(0,100)],this.positionAmount.startGen(e.memory),this.rotationAmount.startGen(e.memory),this.frequency.startGen(e.memory),this.power.startGen(e.memory)}update(e,t){let n=this.frequency.genValue(e.memory,e.age/e.life),i=this.power.genValue(e.memory,e.age/e.life),s=this.positionAmount.genValue(e.memory,e.age/e.life),a=this.rotationAmount.genValue(e.memory,e.age/e.life);s>0&&e.lastPosNoise!==void 0&&(e.position.sub(e.lastPosNoise),Js.set(Ut[e.generatorIndex[0]].noise2D(0,e.age*n)*i*s,Ut[e.generatorIndex[1]].noise2D(0,e.age*n)*i*s,Ut[e.generatorIndex[2]].noise2D(0,e.age*n)*i*s),e.position.add(Js),e.lastPosNoise.copy(Js)),a>0&&e.lastRotNoise!==void 0&&(typeof e.rotation=="number"?(e.rotation-=e.lastRotNoise,e.rotation+=Ut[e.generatorIndex[3]].noise2D(0,e.age*n)*Math.PI*i*a):(e.lastRotNoise.invert(),e.rotation.multiply(e.lastRotNoise),Gs.set(Ut[e.generatorIndex[0]].noise2D(0,e.age*n)*i*a,Ut[e.generatorIndex[1]].noise2D(0,e.age*n)*i*a,Ut[e.generatorIndex[2]].noise2D(0,e.age*n)*i*a,Ut[e.generatorIndex[3]].noise2D(0,e.age*n)*i*a).normalize(),e.rotation.multiply(Gs),e.lastRotNoise.copy(Gs)))}toJSON(){return{type:this.type,frequency:this.frequency.toJSON(),power:this.power.toJSON(),positionAmount:this.positionAmount.toJSON(),rotationAmount:this.rotationAmount.toJSON()}}frameUpdate(e){this.duration+=e}static fromJSON(e){return new Hi(Q(e.frequency),Q(e.power),Q(e.positionAmount),Q(e.rotationAmount))}clone(){return new Hi(this.frequency.clone(),this.power.clone(),this.positionAmount.clone(),this.rotationAmount.clone())}reset(){}}class qi{constructor(e,t){this.color=e,this.speedRange=t,this.type="ColorBySpeed"}initialize(e){this.color.startGen(e.memory)}update(e,t){const n=(e.startSpeed-this.speedRange.a)/(this.speedRange.b-this.speedRange.a);this.color.genColor(e.memory,e.color,n),e.color.x*=e.startColor.x,e.color.y*=e.startColor.y,e.color.z*=e.startColor.z,e.color.w*=e.startColor.w}frameUpdate(e){}toJSON(){return{type:this.type,color:this.color.toJSON(),speedRange:this.speedRange.toJSON()}}static fromJSON(e){return new qi(Fs(e.color),wn.fromJSON(e.speedRange))}clone(){return new qi(this.color.clone(),this.speedRange.clone())}reset(){}}class Xi{initialize(e){this.size.startGen(e.memory)}constructor(e,t){this.size=e,this.speedRange=t,this.type="SizeBySpeed"}update(e){const t=(e.startSpeed-this.speedRange.a)/(this.speedRange.b-this.speedRange.a);this.size instanceof _n?this.size.genValue(e.memory,e.size,t).multiply(e.startSize):e.size.copy(e.startSize).multiplyScalar(this.size.genValue(e.memory,t))}toJSON(){return{type:this.type,size:this.size.toJSON(),speedRange:this.speedRange.toJSON()}}static fromJSON(e){return new Xi(br(e.size),wn.fromJSON(e.speedRange))}frameUpdate(e){}clone(){return new Xi(this.size.clone(),this.speedRange.clone())}reset(){}}class Yi{constructor(e,t){this.angularVelocity=e,this.speedRange=t,this.type="RotationBySpeed",this.tempQuat=new ie}initialize(e){typeof e.rotation=="number"&&this.angularVelocity.startGen(e.memory)}update(e,t){if(typeof e.rotation=="number"){const n=(e.startSpeed-this.speedRange.a)/(this.speedRange.b-this.speedRange.a);e.rotation+=t*this.angularVelocity.genValue(e.memory,n)}}toJSON(){return{type:this.type,angularVelocity:this.angularVelocity.toJSON(),speedRange:this.speedRange.toJSON()}}static fromJSON(e){return new Yi(Q(e.angularVelocity),wn.fromJSON(e.speedRange))}frameUpdate(e){}clone(){return new Yi(this.angularVelocity.clone(),this.speedRange.clone())}reset(){}}class Zi{initialize(e){this.speed.startGen(e.memory)}constructor(e,t){this.speed=e,this.dampen=t,this.type="LimitSpeedOverLife"}update(e,t){let n=e.velocity.length(),i=this.speed.genValue(e.memory,e.age/e.life);if(n>i){const s=(n-i)/n;e.velocity.multiplyScalar(1-s*this.dampen*t*20)}}toJSON(){return{type:this.type,speed:this.speed.toJSON(),dampen:this.dampen}}static fromJSON(e){return new Zi(Q(e.speed),e.dampen)}frameUpdate(e){}clone(){return new Zi(this.speed.clone(),this.dampen)}reset(){}}const Mr={ApplyForce:{type:"ApplyForce",constructor:Vi,params:[["direction",["vec3"]],["magnitude",["value"]]],loadJSON:Vi.fromJSON},Noise:{type:"Noise",constructor:Hi,params:[["frequency",["value"]],["power",["value"]],["positionAmount",["value"]],["rotationAmount",["value"]]],loadJSON:Hi.fromJSON},TurbulenceField:{type:"TurbulenceField",constructor:Wi,params:[["scale",["vec3"]],["octaves",["number"]],["velocityMultiplier",["vec3"]],["timeScale",["vec3"]]],loadJSON:Wi.fromJSON},GravityForce:{type:"GravityForce",constructor:ji,params:[["center",["vec3"]],["magnitude",["number"]]],loadJSON:ji.fromJSON},ColorOverLife:{type:"ColorOverLife",constructor:Oi,params:[["color",["colorFunc"]]],loadJSON:Oi.fromJSON},RotationOverLife:{type:"RotationOverLife",constructor:Ii,params:[["angularVelocity",["value","valueFunc"]]],loadJSON:Ii.fromJSON},Rotation3DOverLife:{type:"Rotation3DOverLife",constructor:zi,params:[["angularVelocity",["rotationFunc"]]],loadJSON:zi.fromJSON},SizeOverLife:{type:"SizeOverLife",constructor:Ni,params:[["size",["value","valueFunc","vec3Func"]]],loadJSON:Ni.fromJSON},ColorBySpeed:{type:"ColorBySpeed",constructor:qi,params:[["color",["colorFunc"]],["speedRange",["range"]]],loadJSON:qi.fromJSON},RotationBySpeed:{type:"RotationBySpeed",constructor:Yi,params:[["angularVelocity",["value","valueFunc"]],["speedRange",["range"]]],loadJSON:Yi.fromJSON},SizeBySpeed:{type:"SizeBySpeed",constructor:Xi,params:[["size",["value","valueFunc","vec3Func"]],["speedRange",["range"]]],loadJSON:Xi.fromJSON},SpeedOverLife:{type:"SpeedOverLife",constructor:Ui,params:[["speed",["value","valueFunc"]]],loadJSON:Ui.fromJSON},FrameOverLife:{type:"FrameOverLife",constructor:Di,params:[["frame",["value","valueFunc"]]],loadJSON:Di.fromJSON},ForceOverLife:{type:"ForceOverLife",constructor:Bi,params:[["x",["value","valueFunc"]],["y",["value","valueFunc"]],["z",["value","valueFunc"]]],loadJSON:Bi.fromJSON},OrbitOverLife:{type:"OrbitOverLife",constructor:Li,params:[["orbitSpeed",["value","valueFunc"]],["axis",["vec3"]]],loadJSON:Li.fromJSON},WidthOverLength:{type:"WidthOverLength",constructor:Fi,params:[["width",["value","valueFunc"]]],loadJSON:Fi.fromJSON},ChangeEmitDirection:{type:"ChangeEmitDirection",constructor:Ji,params:[["angle",["value"]]],loadJSON:Ji.fromJSON},EmitSubParticleSystem:{type:"EmitSubParticleSystem",constructor:Gi,params:[["particleSystem",["self"]],["useVelocityAsBasis",["boolean"]],["subParticleSystem",["particleSystem"]],["mode",["number"]],["emitProbability",["number"]]],loadJSON:Gi.fromJSON},LimitSpeedOverLife:{type:"LimitSpeedOverLife",constructor:Zi,params:[["speed",["value","valueFunc"]],["dampen",["number"]]],loadJSON:Zi.fromJSON}};function Bh(r,e){return Mr[r.type]?Mr[r.type].loadJSON(r,e):null}const Nh=[];function Uh(r){if(!Nh.find(e=>e.id===r.id)){for(const e of r.emitterShapes)Vs[e.type]||(Vs[e.type]=e);for(const e of r.behaviors)Mr[e.type]||(Mr[e.type]=e)}}var Dh=`
|
|
83
|
+
*/var Ns,Cc;function Zu(){if(Cc)return Ns;Cc=1,Ns=function(t){return t!=null&&(r(t)||e(t)||!!t._isBuffer)};function r(t){return!!t.constructor&&typeof t.constructor.isBuffer=="function"&&t.constructor.isBuffer(t)}function e(t){return typeof t.readFloatLE=="function"&&typeof t.slice=="function"&&r(t.slice(0,0))}return Ns}var Ec;function Ku(){return Ec||(Ec=1,function(){var r=Yu(),e=Mc().utf8,t=Zu(),n=Mc().bin,i=function(s,a){s.constructor==String?a&&a.encoding==="binary"?s=n.stringToBytes(s):s=e.stringToBytes(s):t(s)?s=Array.prototype.slice.call(s,0):!Array.isArray(s)&&s.constructor!==Uint8Array&&(s=s.toString());for(var o=r.bytesToWords(s),c=s.length*8,l=1732584193,u=-271733879,p=-1732584194,f=271733878,m=0;m<o.length;m++)o[m]=(o[m]<<8|o[m]>>>24)&16711935|(o[m]<<24|o[m]>>>8)&4278255360;o[c>>>5]|=128<<c%32,o[(c+64>>>9<<4)+14]=c;for(var b=i._ff,x=i._gg,g=i._hh,v=i._ii,m=0;m<o.length;m+=16){var _=l,w=u,C=p,M=f;l=b(l,u,p,f,o[m+0],7,-680876936),f=b(f,l,u,p,o[m+1],12,-389564586),p=b(p,f,l,u,o[m+2],17,606105819),u=b(u,p,f,l,o[m+3],22,-1044525330),l=b(l,u,p,f,o[m+4],7,-176418897),f=b(f,l,u,p,o[m+5],12,1200080426),p=b(p,f,l,u,o[m+6],17,-1473231341),u=b(u,p,f,l,o[m+7],22,-45705983),l=b(l,u,p,f,o[m+8],7,1770035416),f=b(f,l,u,p,o[m+9],12,-1958414417),p=b(p,f,l,u,o[m+10],17,-42063),u=b(u,p,f,l,o[m+11],22,-1990404162),l=b(l,u,p,f,o[m+12],7,1804603682),f=b(f,l,u,p,o[m+13],12,-40341101),p=b(p,f,l,u,o[m+14],17,-1502002290),u=b(u,p,f,l,o[m+15],22,1236535329),l=x(l,u,p,f,o[m+1],5,-165796510),f=x(f,l,u,p,o[m+6],9,-1069501632),p=x(p,f,l,u,o[m+11],14,643717713),u=x(u,p,f,l,o[m+0],20,-373897302),l=x(l,u,p,f,o[m+5],5,-701558691),f=x(f,l,u,p,o[m+10],9,38016083),p=x(p,f,l,u,o[m+15],14,-660478335),u=x(u,p,f,l,o[m+4],20,-405537848),l=x(l,u,p,f,o[m+9],5,568446438),f=x(f,l,u,p,o[m+14],9,-1019803690),p=x(p,f,l,u,o[m+3],14,-187363961),u=x(u,p,f,l,o[m+8],20,1163531501),l=x(l,u,p,f,o[m+13],5,-1444681467),f=x(f,l,u,p,o[m+2],9,-51403784),p=x(p,f,l,u,o[m+7],14,1735328473),u=x(u,p,f,l,o[m+12],20,-1926607734),l=g(l,u,p,f,o[m+5],4,-378558),f=g(f,l,u,p,o[m+8],11,-2022574463),p=g(p,f,l,u,o[m+11],16,1839030562),u=g(u,p,f,l,o[m+14],23,-35309556),l=g(l,u,p,f,o[m+1],4,-1530992060),f=g(f,l,u,p,o[m+4],11,1272893353),p=g(p,f,l,u,o[m+7],16,-155497632),u=g(u,p,f,l,o[m+10],23,-1094730640),l=g(l,u,p,f,o[m+13],4,681279174),f=g(f,l,u,p,o[m+0],11,-358537222),p=g(p,f,l,u,o[m+3],16,-722521979),u=g(u,p,f,l,o[m+6],23,76029189),l=g(l,u,p,f,o[m+9],4,-640364487),f=g(f,l,u,p,o[m+12],11,-421815835),p=g(p,f,l,u,o[m+15],16,530742520),u=g(u,p,f,l,o[m+2],23,-995338651),l=v(l,u,p,f,o[m+0],6,-198630844),f=v(f,l,u,p,o[m+7],10,1126891415),p=v(p,f,l,u,o[m+14],15,-1416354905),u=v(u,p,f,l,o[m+5],21,-57434055),l=v(l,u,p,f,o[m+12],6,1700485571),f=v(f,l,u,p,o[m+3],10,-1894986606),p=v(p,f,l,u,o[m+10],15,-1051523),u=v(u,p,f,l,o[m+1],21,-2054922799),l=v(l,u,p,f,o[m+8],6,1873313359),f=v(f,l,u,p,o[m+15],10,-30611744),p=v(p,f,l,u,o[m+6],15,-1560198380),u=v(u,p,f,l,o[m+13],21,1309151649),l=v(l,u,p,f,o[m+4],6,-145523070),f=v(f,l,u,p,o[m+11],10,-1120210379),p=v(p,f,l,u,o[m+2],15,718787259),u=v(u,p,f,l,o[m+9],21,-343485551),l=l+_>>>0,u=u+w>>>0,p=p+C>>>0,f=f+M>>>0}return r.endian([l,u,p,f])};i._ff=function(s,a,o,c,l,u,p){var f=s+(a&o|~a&c)+(l>>>0)+p;return(f<<u|f>>>32-u)+a},i._gg=function(s,a,o,c,l,u,p){var f=s+(a&c|o&~c)+(l>>>0)+p;return(f<<u|f>>>32-u)+a},i._hh=function(s,a,o,c,l,u,p){var f=s+(a^o^c)+(l>>>0)+p;return(f<<u|f>>>32-u)+a},i._ii=function(s,a,o,c,l,u,p){var f=s+(o^(a|~c))+(l>>>0)+p;return(f<<u|f>>>32-u)+a},i._blocksize=16,i._digestsize=16,xc.exports=function(s,a){if(s==null)throw new Error("Illegal argument "+s);var o=r.wordsToBytes(i(s,a));return a&&a.asBytes?o:a&&a.asString?n.bytesToString(o):r.bytesToHex(o)}}()),xc.exports}var Qu=Ku();const $u=ar(Qu),Fe=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"];let Pc=1234567;const kc=Math.PI/180,Rc=180/Math.PI;function eh(){const r=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(Fe[r&255]+Fe[r>>8&255]+Fe[r>>16&255]+Fe[r>>24&255]+"-"+Fe[e&255]+Fe[e>>8&255]+"-"+Fe[e>>16&15|64]+Fe[e>>24&255]+"-"+Fe[t&63|128]+Fe[t>>8&255]+"-"+Fe[t>>16&255]+Fe[t>>24&255]+Fe[n&255]+Fe[n>>8&255]+Fe[n>>16&255]+Fe[n>>24&255]).toLowerCase()}function Bt(r,e,t){return Math.max(e,Math.min(t,r))}function Ac(r,e){return(r%e+e)%e}function th(r,e,t,n,i){return n+(r-e)*(i-n)/(t-e)}function nh(r,e,t){return r!==e?(t-r)/(e-r):0}function Oc(r,e,t){return(1-t)*r+t*e}function ih(r,e,t,n){return Oc(r,e,1-Math.exp(-t*n))}function rh(r,e=1){return e-Math.abs(Ac(r,e*2)-e)}function sh(r,e,t){return r<=e?0:r>=t?1:(r=(r-e)/(t-e),r*r*(3-2*r))}function oh(r,e,t){return r<=e?0:r>=t?1:(r=(r-e)/(t-e),r*r*r*(r*(r*6-15)+10))}function ah(r,e){return r+Math.floor(Math.random()*(e-r+1))}function ch(r,e){return r+Math.random()*(e-r)}function lh(r){return r*(.5-Math.random())}function uh(r){r!==void 0&&(Pc=r);let e=Pc+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}function hh(r){return r*kc}function dh(r){return r*Rc}function ph(r){return(r&r-1)===0&&r!==0}function fh(r){return Math.pow(2,Math.ceil(Math.log(r)/Math.LN2))}function mh(r){return Math.pow(2,Math.floor(Math.log(r)/Math.LN2))}function yh(r,e,t,n,i){const s=Math.cos,a=Math.sin,o=s(t/2),c=a(t/2),l=s((e+n)/2),u=a((e+n)/2),p=s((e-n)/2),f=a((e-n)/2),m=s((n-e)/2),b=a((n-e)/2);switch(i){case"XYX":r.set(o*u,c*p,c*f,o*l);break;case"YZY":r.set(c*f,o*u,c*p,o*l);break;case"ZXZ":r.set(c*p,c*f,o*u,o*l);break;case"XZX":r.set(o*u,c*b,c*m,o*l);break;case"YXY":r.set(c*m,o*u,c*b,o*l);break;case"ZYZ":r.set(c*b,c*m,o*u,o*l);break;default:console.warn("../math.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+i)}}function gh(r,e){switch(e.constructor){case Float32Array:return r;case Uint32Array:return r/4294967295;case Uint16Array:return r/65535;case Uint8Array:return r/255;case Int32Array:return Math.max(r/2147483647,-1);case Int16Array:return Math.max(r/32767,-1);case Int8Array:return Math.max(r/127,-1);default:throw new Error("Invalid component type.")}}function vh(r,e){switch(e.constructor){case Float32Array:return r;case Uint32Array:return Math.round(r*4294967295);case Uint16Array:return Math.round(r*65535);case Uint8Array:return Math.round(r*255);case Int32Array:return Math.round(r*2147483647);case Int16Array:return Math.round(r*32767);case Int8Array:return Math.round(r*127);default:throw new Error("Invalid component type.")}}const An={DEG2RAD:kc,RAD2DEG:Rc,generateUUID:eh,clamp:Bt,euclideanModulo:Ac,mapLinear:th,inverseLerp:nh,lerp:Oc,damp:ih,pingpong:rh,smoothstep:sh,smootherstep:oh,randInt:ah,randFloat:ch,randFloatSpread:lh,seededRandom:uh,degToRad:hh,radToDeg:dh,isPowerOfTwo:ph,ceilPowerOfTwo:fh,floorPowerOfTwo:mh,setQuaternionFromProperEuler:yh,normalize:vh,denormalize:gh};class ie{constructor(e=0,t=0,n=0,i=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=i}static slerpFlat(e,t,n,i,s,a,o){let c=n[i+0],l=n[i+1],u=n[i+2],p=n[i+3];const f=s[a+0],m=s[a+1],b=s[a+2],x=s[a+3];if(o===0){e[t+0]=c,e[t+1]=l,e[t+2]=u,e[t+3]=p;return}if(o===1){e[t+0]=f,e[t+1]=m,e[t+2]=b,e[t+3]=x;return}if(p!==x||c!==f||l!==m||u!==b){let g=1-o;const v=c*f+l*m+u*b+p*x,_=v>=0?1:-1,w=1-v*v;if(w>Number.EPSILON){const M=Math.sqrt(w),E=Math.atan2(M,v*_);g=Math.sin(g*E)/M,o=Math.sin(o*E)/M}const C=o*_;if(c=c*g+f*C,l=l*g+m*C,u=u*g+b*C,p=p*g+x*C,g===1-o){const M=1/Math.sqrt(c*c+l*l+u*u+p*p);c*=M,l*=M,u*=M,p*=M}}e[t]=c,e[t+1]=l,e[t+2]=u,e[t+3]=p}static multiplyQuaternionsFlat(e,t,n,i,s,a){const o=n[i],c=n[i+1],l=n[i+2],u=n[i+3],p=s[a],f=s[a+1],m=s[a+2],b=s[a+3];return e[t]=o*b+u*p+c*m-l*f,e[t+1]=c*b+u*f+l*p-o*m,e[t+2]=l*b+u*m+o*f-c*p,e[t+3]=u*b-o*p-c*f-l*m,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,i){return this._x=e,this._y=t,this._z=n,this._w=i,this._onChangeCallback(),this}clone(){return new ie(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){const n=e._x,i=e._y,s=e._z,a=e._order,o=Math.cos,c=Math.sin,l=o(n/2),u=o(i/2),p=o(s/2),f=c(n/2),m=c(i/2),b=c(s/2);switch(a){case"XYZ":this._x=f*u*p+l*m*b,this._y=l*m*p-f*u*b,this._z=l*u*b+f*m*p,this._w=l*u*p-f*m*b;break;case"YXZ":this._x=f*u*p+l*m*b,this._y=l*m*p-f*u*b,this._z=l*u*b-f*m*p,this._w=l*u*p+f*m*b;break;case"ZXY":this._x=f*u*p-l*m*b,this._y=l*m*p+f*u*b,this._z=l*u*b+f*m*p,this._w=l*u*p-f*m*b;break;case"ZYX":this._x=f*u*p-l*m*b,this._y=l*m*p+f*u*b,this._z=l*u*b-f*m*p,this._w=l*u*p+f*m*b;break;case"YZX":this._x=f*u*p+l*m*b,this._y=l*m*p+f*u*b,this._z=l*u*b-f*m*p,this._w=l*u*p-f*m*b;break;case"XZY":this._x=f*u*p-l*m*b,this._y=l*m*p-f*u*b,this._z=l*u*b+f*m*p,this._w=l*u*p+f*m*b;break;default:console.warn("../math.Quaternion: .setFromEuler() encountered an unknown order: "+a)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const n=t/2,i=Math.sin(n);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,n=t[0],i=t[4],s=t[8],a=t[1],o=t[5],c=t[9],l=t[2],u=t[6],p=t[10],f=n+o+p;if(f>0){const m=.5/Math.sqrt(f+1);this._w=.25/m,this._x=(u-c)*m,this._y=(s-l)*m,this._z=(a-i)*m}else if(n>o&&n>p){const m=2*Math.sqrt(1+n-o-p);this._w=(u-c)/m,this._x=.25*m,this._y=(i+a)/m,this._z=(s+l)/m}else if(o>p){const m=2*Math.sqrt(1+o-n-p);this._w=(s-l)/m,this._x=(i+a)/m,this._y=.25*m,this._z=(c+u)/m}else{const m=2*Math.sqrt(1+p-n-o);this._w=(a-i)/m,this._x=(s+l)/m,this._y=(c+u)/m,this._z=.25*m}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<Number.EPSILON?(n=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(Bt(this.dot(e),-1,1)))}rotateTowards(e,t){const n=this.angleTo(e);if(n===0)return this;const i=Math.min(1,t/n);return this.slerp(e,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){const n=e._x,i=e._y,s=e._z,a=e._w,o=t._x,c=t._y,l=t._z,u=t._w;return this._x=n*u+a*o+i*l-s*c,this._y=i*u+a*c+s*o-n*l,this._z=s*u+a*l+n*c-i*o,this._w=a*u-n*o-i*c-s*l,this._onChangeCallback(),this}slerp(e,t){if(t===0)return this;if(t===1)return this.copy(e);const n=this._x,i=this._y,s=this._z,a=this._w;let o=a*e._w+n*e._x+i*e._y+s*e._z;if(o<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,o=-o):this.copy(e),o>=1)return this._w=a,this._x=n,this._y=i,this._z=s,this;const c=1-o*o;if(c<=Number.EPSILON){const m=1-t;return this._w=m*a+t*this._w,this._x=m*n+t*this._x,this._y=m*i+t*this._y,this._z=m*s+t*this._z,this.normalize(),this}const l=Math.sqrt(c),u=Math.atan2(l,o),p=Math.sin((1-t)*u)/l,f=Math.sin(t*u)/l;return this._w=a*p+this._w*f,this._x=n*p+this._x*f,this._y=i*p+this._y*f,this._z=s*p+this._z*f,this._onChangeCallback(),this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){const e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),i=Math.sqrt(1-n),s=Math.sqrt(n);return this.set(i*Math.sin(e),i*Math.cos(e),s*Math.sin(t),s*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class G{constructor(e=0,t=0,n=0){this.isVector3=!0,G.prototype.isVector3=!0,this.x=e,this.y=t,this.z=n}set(e,t,n){return n===void 0&&(n=this.z),this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new G(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(Ic.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Ic.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,n=this.y,i=this.z,s=e.elements;return this.x=s[0]*t+s[3]*n+s[6]*i,this.y=s[1]*t+s[4]*n+s[7]*i,this.z=s[2]*t+s[5]*n+s[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,n=this.y,i=this.z,s=e.elements,a=1/(s[3]*t+s[7]*n+s[11]*i+s[15]);return this.x=(s[0]*t+s[4]*n+s[8]*i+s[12])*a,this.y=(s[1]*t+s[5]*n+s[9]*i+s[13])*a,this.z=(s[2]*t+s[6]*n+s[10]*i+s[14])*a,this}applyQuaternion(e){const t=this.x,n=this.y,i=this.z,s=e.x,a=e.y,o=e.z,c=e.w,l=2*(a*i-o*n),u=2*(o*t-s*i),p=2*(s*n-a*t);return this.x=t+c*l+a*p-o*u,this.y=n+c*u+o*l-s*p,this.z=i+c*p+s*u-a*l,this}transformDirection(e){const t=this.x,n=this.y,i=this.z,s=e.elements;return this.x=s[0]*t+s[4]*n+s[8]*i,this.y=s[1]*t+s[5]*n+s[9]*i,this.z=s[2]*t+s[6]*n+s[10]*i,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const n=e.x,i=e.y,s=e.z,a=t.x,o=t.y,c=t.z;return this.x=i*c-s*o,this.y=s*a-n*c,this.z=n*o-i*a,this}projectOnVector(e){const t=e.lengthSq();if(t===0)return this.set(0,0,0);const n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return Us.copy(this).projectOnVector(e),this.sub(Us)}reflect(e){return this.sub(Us.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(Bt(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y,i=this.z-e.z;return t*t+n*n+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSphericalCoords(e,t,n){const i=Math.sin(t)*e;return this.x=i*Math.sin(n),this.y=Math.cos(t)*e,this.z=i*Math.cos(n),this}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){const t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),i=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=i,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=Math.random()*Math.PI*2,t=Math.random()*2-1,n=Math.sqrt(1-t*t);return this.x=n*Math.cos(e),this.y=t,this.z=n*Math.sin(e),this}abs(){return this.x=Math.abs(this.x),this.y=Math.abs(this.y),this.z=Math.abs(this.z),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const Us=new G,Ic=new ie,gr=2e3,zc=2001;class Rt{constructor(e,t,n,i,s,a,o,c,l,u,p,f,m,b,x,g){this.isMatrix4=!0,Rt.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,t,n,i,s,a,o,c,l,u,p,f,m,b,x,g)}extractPosition(e){return console.warn("THREE.Matrix4: .extractPosition() has been renamed to .copyPosition()."),this.copyPosition(e)}multiplyToArray(e,t,n){return console.error("THREE.Matrix4: .multiplyToArray() has been removed."),this}setRotationFromQuaternion(e){return this.makeRotationFromQuaternion(e)}set(e,t,n,i,s,a,o,c,l,u,p,f,m,b,x,g){const v=this.elements;return v[0]=e,v[4]=t,v[8]=n,v[12]=i,v[1]=s,v[5]=a,v[9]=o,v[13]=c,v[2]=l,v[6]=u,v[10]=p,v[14]=f,v[3]=m,v[7]=b,v[11]=x,v[15]=g,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new Rt().fromArray(this.elements)}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){const t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){const t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,n){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){const t=this.elements,n=e.elements,i=1/On.setFromMatrixColumn(e,0).length(),s=1/On.setFromMatrixColumn(e,1).length(),a=1/On.setFromMatrixColumn(e,2).length();return t[0]=n[0]*i,t[1]=n[1]*i,t[2]=n[2]*i,t[3]=0,t[4]=n[4]*s,t[5]=n[5]*s,t[6]=n[6]*s,t[7]=0,t[8]=n[8]*a,t[9]=n[9]*a,t[10]=n[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){const t=this.elements,n=e.x,i=e.y,s=e.z,a=Math.cos(n),o=Math.sin(n),c=Math.cos(i),l=Math.sin(i),u=Math.cos(s),p=Math.sin(s);if(e.order==="XYZ"){const f=a*u,m=a*p,b=o*u,x=o*p;t[0]=c*u,t[4]=-c*p,t[8]=l,t[1]=m+b*l,t[5]=f-x*l,t[9]=-o*c,t[2]=x-f*l,t[6]=b+m*l,t[10]=a*c}else if(e.order==="YXZ"){const f=c*u,m=c*p,b=l*u,x=l*p;t[0]=f+x*o,t[4]=b*o-m,t[8]=a*l,t[1]=a*p,t[5]=a*u,t[9]=-o,t[2]=m*o-b,t[6]=x+f*o,t[10]=a*c}else if(e.order==="ZXY"){const f=c*u,m=c*p,b=l*u,x=l*p;t[0]=f-x*o,t[4]=-a*p,t[8]=b+m*o,t[1]=m+b*o,t[5]=a*u,t[9]=x-f*o,t[2]=-a*l,t[6]=o,t[10]=a*c}else if(e.order==="ZYX"){const f=a*u,m=a*p,b=o*u,x=o*p;t[0]=c*u,t[4]=b*l-m,t[8]=f*l+x,t[1]=c*p,t[5]=x*l+f,t[9]=m*l-b,t[2]=-l,t[6]=o*c,t[10]=a*c}else if(e.order==="YZX"){const f=a*c,m=a*l,b=o*c,x=o*l;t[0]=c*u,t[4]=x-f*p,t[8]=b*p+m,t[1]=p,t[5]=a*u,t[9]=-o*u,t[2]=-l*u,t[6]=m*p+b,t[10]=f-x*p}else if(e.order==="XZY"){const f=a*c,m=a*l,b=o*c,x=o*l;t[0]=c*u,t[4]=-p,t[8]=l*u,t[1]=f*p+x,t[5]=a*u,t[9]=m*p-b,t[2]=b*p-m,t[6]=o*u,t[10]=x*p+f}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(Sh,e,bh)}lookAt(e,t,n){const i=this.elements;return at.subVectors(e,t),at.lengthSq()===0&&(at.z=1),at.normalize(),$t.crossVectors(n,at),$t.lengthSq()===0&&(Math.abs(n.z)===1?at.x+=1e-4:at.z+=1e-4,at.normalize(),$t.crossVectors(n,at)),$t.normalize(),vr.crossVectors(at,$t),i[0]=$t.x,i[4]=vr.x,i[8]=at.x,i[1]=$t.y,i[5]=vr.y,i[9]=at.y,i[2]=$t.z,i[6]=vr.z,i[10]=at.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,i=t.elements,s=this.elements,a=n[0],o=n[4],c=n[8],l=n[12],u=n[1],p=n[5],f=n[9],m=n[13],b=n[2],x=n[6],g=n[10],v=n[14],_=n[3],w=n[7],C=n[11],M=n[15],E=i[0],P=i[4],O=i[8],R=i[12],A=i[1],B=i[5],z=i[9],D=i[13],F=i[2],H=i[6],q=i[10],$=i[14],J=i[3],Se=i[7],ce=i[11],me=i[15];return s[0]=a*E+o*A+c*F+l*J,s[4]=a*P+o*B+c*H+l*Se,s[8]=a*O+o*z+c*q+l*ce,s[12]=a*R+o*D+c*$+l*me,s[1]=u*E+p*A+f*F+m*J,s[5]=u*P+p*B+f*H+m*Se,s[9]=u*O+p*z+f*q+m*ce,s[13]=u*R+p*D+f*$+m*me,s[2]=b*E+x*A+g*F+v*J,s[6]=b*P+x*B+g*H+v*Se,s[10]=b*O+x*z+g*q+v*ce,s[14]=b*R+x*D+g*$+v*me,s[3]=_*E+w*A+C*F+M*J,s[7]=_*P+w*B+C*H+M*Se,s[11]=_*O+w*z+C*q+M*ce,s[15]=_*R+w*D+C*$+M*me,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[4],i=e[8],s=e[12],a=e[1],o=e[5],c=e[9],l=e[13],u=e[2],p=e[6],f=e[10],m=e[14],b=e[3],x=e[7],g=e[11],v=e[15];return b*(+s*c*p-i*l*p-s*o*f+n*l*f+i*o*m-n*c*m)+x*(+t*c*m-t*l*f+s*a*f-i*a*m+i*l*u-s*c*u)+g*(+t*l*p-t*o*m-s*a*p+n*a*m+s*o*u-n*l*u)+v*(-i*o*u-t*c*p+t*o*f+i*a*p-n*a*f+n*c*u)}transpose(){const e=this.elements;let t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,n){const i=this.elements;return e.isVector3?(i[12]=e.x,i[13]=e.y,i[14]=e.z):(i[12]=e,i[13]=t,i[14]=n),this}invert(){const e=this.elements,t=e[0],n=e[1],i=e[2],s=e[3],a=e[4],o=e[5],c=e[6],l=e[7],u=e[8],p=e[9],f=e[10],m=e[11],b=e[12],x=e[13],g=e[14],v=e[15],_=p*g*l-x*f*l+x*c*m-o*g*m-p*c*v+o*f*v,w=b*f*l-u*g*l-b*c*m+a*g*m+u*c*v-a*f*v,C=u*x*l-b*p*l+b*o*m-a*x*m-u*o*v+a*p*v,M=b*p*c-u*x*c-b*o*f+a*x*f+u*o*g-a*p*g,E=t*_+n*w+i*C+s*M;if(E===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const P=1/E;return e[0]=_*P,e[1]=(x*f*s-p*g*s-x*i*m+n*g*m+p*i*v-n*f*v)*P,e[2]=(o*g*s-x*c*s+x*i*l-n*g*l-o*i*v+n*c*v)*P,e[3]=(p*c*s-o*f*s-p*i*l+n*f*l+o*i*m-n*c*m)*P,e[4]=w*P,e[5]=(u*g*s-b*f*s+b*i*m-t*g*m-u*i*v+t*f*v)*P,e[6]=(b*c*s-a*g*s-b*i*l+t*g*l+a*i*v-t*c*v)*P,e[7]=(a*f*s-u*c*s+u*i*l-t*f*l-a*i*m+t*c*m)*P,e[8]=C*P,e[9]=(b*p*s-u*x*s-b*n*m+t*x*m+u*n*v-t*p*v)*P,e[10]=(a*x*s-b*o*s+b*n*l-t*x*l-a*n*v+t*o*v)*P,e[11]=(u*o*s-a*p*s-u*n*l+t*p*l+a*n*m-t*o*m)*P,e[12]=M*P,e[13]=(u*x*i-b*p*i+b*n*f-t*x*f-u*n*g+t*p*g)*P,e[14]=(b*o*i-a*x*i-b*n*c+t*x*c+a*n*g-t*o*g)*P,e[15]=(a*p*i-u*o*i+u*n*c-t*p*c-a*n*f+t*o*f)*P,this}scale(e){const t=this.elements,n=e.x,i=e.y,s=e.z;return t[0]*=n,t[4]*=i,t[8]*=s,t[1]*=n,t[5]*=i,t[9]*=s,t[2]*=n,t[6]*=i,t[10]*=s,t[3]*=n,t[7]*=i,t[11]*=s,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],i=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,i))}makeTranslation(e,t,n){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const n=Math.cos(t),i=Math.sin(t),s=1-n,a=e.x,o=e.y,c=e.z,l=s*a,u=s*o;return this.set(l*a+n,l*o-i*c,l*c+i*o,0,l*o+i*c,u*o+n,u*c-i*a,0,l*c-i*o,u*c+i*a,s*c*c+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,i,s,a){return this.set(1,n,s,0,e,1,a,0,t,i,1,0,0,0,0,1),this}compose(e,t,n){const i=this.elements,s=t._x,a=t._y,o=t._z,c=t._w,l=s+s,u=a+a,p=o+o,f=s*l,m=s*u,b=s*p,x=a*u,g=a*p,v=o*p,_=c*l,w=c*u,C=c*p,M=n.x,E=n.y,P=n.z;return i[0]=(1-(x+v))*M,i[1]=(m+C)*M,i[2]=(b-w)*M,i[3]=0,i[4]=(m-C)*E,i[5]=(1-(f+v))*E,i[6]=(g+_)*E,i[7]=0,i[8]=(b+w)*P,i[9]=(g-_)*P,i[10]=(1-(f+x))*P,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,t,n){const i=this.elements;let s=On.set(i[0],i[1],i[2]).length();const a=On.set(i[4],i[5],i[6]).length(),o=On.set(i[8],i[9],i[10]).length();this.determinant()<0&&(s=-s),e.x=i[12],e.y=i[13],e.z=i[14],Pt.copy(this);const c=1/s,l=1/a,u=1/o;return Pt.elements[0]*=c,Pt.elements[1]*=c,Pt.elements[2]*=c,Pt.elements[4]*=l,Pt.elements[5]*=l,Pt.elements[6]*=l,Pt.elements[8]*=u,Pt.elements[9]*=u,Pt.elements[10]*=u,t.setFromRotationMatrix(Pt),n.x=s,n.y=a,n.z=o,this}makePerspective(e,t,n,i,s,a,o=gr){const c=this.elements,l=2*s/(t-e),u=2*s/(n-i),p=(t+e)/(t-e),f=(n+i)/(n-i);let m,b;if(o===gr)m=-(a+s)/(a-s),b=-2*a*s/(a-s);else if(o===zc)m=-a/(a-s),b=-a*s/(a-s);else throw new Error("Matrix4.makePerspective(): Invalid coordinate system: "+o);return c[0]=l,c[4]=0,c[8]=p,c[12]=0,c[1]=0,c[5]=u,c[9]=f,c[13]=0,c[2]=0,c[6]=0,c[10]=m,c[14]=b,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(e,t,n,i,s,a,o=gr){const c=this.elements,l=1/(t-e),u=1/(n-i),p=1/(a-s),f=(t+e)*l,m=(n+i)*u;let b,x;if(o===gr)b=(a+s)*p,x=-2*p;else if(o===zc)b=s*p,x=-1*p;else throw new Error("../math.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return c[0]=2*l,c[4]=0,c[8]=0,c[12]=-f,c[1]=0,c[5]=2*u,c[9]=0,c[13]=-m,c[2]=0,c[6]=0,c[10]=x,c[14]=-b,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(e){const t=this.elements,n=e.elements;for(let i=0;i<16;i++)if(t[i]!==n[i])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}}const On=new G,Pt=new Rt,Sh=new G(0,0,0),bh=new G(1,1,1),$t=new G,vr=new G,at=new G,Bc=new Rt,Nc=new ie;class wi{constructor(e=0,t=0,n=0,i=wi.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=n,this._order=i}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,i=this._order){return this._x=e,this._y=t,this._z=n,this._order=i,this._onChangeCallback(),this}clone(){return new wi(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,n=!0){const i=e.elements,s=i[0],a=i[4],o=i[8],c=i[1],l=i[5],u=i[9],p=i[2],f=i[6],m=i[10];switch(t){case"XYZ":this._y=Math.asin(Bt(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-u,m),this._z=Math.atan2(-a,s)):(this._x=Math.atan2(f,l),this._z=0);break;case"YXZ":this._x=Math.asin(-Bt(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(o,m),this._z=Math.atan2(c,l)):(this._y=Math.atan2(-p,s),this._z=0);break;case"ZXY":this._x=Math.asin(Bt(f,-1,1)),Math.abs(f)<.9999999?(this._y=Math.atan2(-p,m),this._z=Math.atan2(-a,l)):(this._y=0,this._z=Math.atan2(c,s));break;case"ZYX":this._y=Math.asin(-Bt(p,-1,1)),Math.abs(p)<.9999999?(this._x=Math.atan2(f,m),this._z=Math.atan2(c,s)):(this._x=0,this._z=Math.atan2(-a,l));break;case"YZX":this._z=Math.asin(Bt(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-u,l),this._y=Math.atan2(-p,s)):(this._x=0,this._y=Math.atan2(o,m));break;case"XZY":this._z=Math.asin(-Bt(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(f,l),this._y=Math.atan2(o,s)):(this._x=Math.atan2(-u,m),this._y=0);break;default:console.warn("../math.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,n===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return Bc.makeRotationFromQuaternion(e),this.setFromRotationMatrix(Bc,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return Nc.setFromEuler(this),this.setFromQuaternion(Nc,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(e){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}wi.DEFAULT_ORDER="XYZ";class Jn{constructor(e=0,t=0){this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new Jn(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const t=this.x,n=this.y,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6],this.y=i[1]*t+i[4]*n+i[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(Bt(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}rotateAround(e,t){const n=Math.cos(t),i=Math.sin(t),s=this.x-e.x,a=this.y-e.y;return this.x=s*n-a*i+e.x,this.y=s*i+a*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}Jn.isVector2=!0;class tt{constructor(e=0,t=0,n=0,i=1){tt.prototype.isVector4=!0,this.x=e,this.y=t,this.z=n,this.w=i}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,i){return this.x=e,this.y=t,this.z=n,this.w=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new tt(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const t=this.x,n=this.y,i=this.z,s=this.w,a=e.elements;return this.x=a[0]*t+a[4]*n+a[8]*i+a[12]*s,this.y=a[1]*t+a[5]*n+a[9]*i+a[13]*s,this.z=a[2]*t+a[6]*n+a[10]*i+a[14]*s,this.w=a[3]*t+a[7]*n+a[11]*i+a[15]*s,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,n,i,s;const a=e.elements,o=a[0],c=a[4],l=a[8],u=a[1],p=a[5],f=a[9],m=a[2],b=a[6],x=a[10];if(Math.abs(c-u)<.01&&Math.abs(l-m)<.01&&Math.abs(f-b)<.01){if(Math.abs(c+u)<.1&&Math.abs(l+m)<.1&&Math.abs(f+b)<.1&&Math.abs(o+p+x-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const v=(o+1)/2,_=(p+1)/2,w=(x+1)/2,C=(c+u)/4,M=(l+m)/4,E=(f+b)/4;return v>_&&v>w?v<.01?(n=0,i=.707106781,s=.707106781):(n=Math.sqrt(v),i=C/n,s=M/n):_>w?_<.01?(n=.707106781,i=0,s=.707106781):(i=Math.sqrt(_),n=C/i,s=E/i):w<.01?(n=.707106781,i=.707106781,s=0):(s=Math.sqrt(w),n=M/s,i=E/s),this.set(n,i,s,t),this}let g=Math.sqrt((b-f)*(b-f)+(l-m)*(l-m)+(u-c)*(u-c));return Math.abs(g)<.001&&(g=1),this.x=(b-f)/g,this.y=(l-m)/g,this.z=(u-c)/g,this.w=Math.acos((o+p+x-1)/2),this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this.w=Math.max(e.w,Math.min(t.w,this.w)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this.w=Math.max(e,Math.min(t,this.w)),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class Dt{constructor(e,t,n,i,s,a,o,c,l){Dt.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,n,i,s,a,o,c,l)}set(e,t,n,i,s,a,o,c,l){const u=this.elements;return u[0]=e,u[1]=i,u[2]=o,u[3]=t,u[4]=s,u[5]=c,u[6]=n,u[7]=a,u[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,i=t.elements,s=this.elements,a=n[0],o=n[3],c=n[6],l=n[1],u=n[4],p=n[7],f=n[2],m=n[5],b=n[8],x=i[0],g=i[3],v=i[6],_=i[1],w=i[4],C=i[7],M=i[2],E=i[5],P=i[8];return s[0]=a*x+o*_+c*M,s[3]=a*g+o*w+c*E,s[6]=a*v+o*C+c*P,s[1]=l*x+u*_+p*M,s[4]=l*g+u*w+p*E,s[7]=l*v+u*C+p*P,s[2]=f*x+m*_+b*M,s[5]=f*g+m*w+b*E,s[8]=f*v+m*C+b*P,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[1],i=e[2],s=e[3],a=e[4],o=e[5],c=e[6],l=e[7],u=e[8];return t*a*u-t*o*l-n*s*u+n*o*c+i*s*l-i*a*c}invert(){const e=this.elements,t=e[0],n=e[1],i=e[2],s=e[3],a=e[4],o=e[5],c=e[6],l=e[7],u=e[8],p=u*a-o*l,f=o*c-u*s,m=l*s-a*c,b=t*p+n*f+i*m;if(b===0)return this.set(0,0,0,0,0,0,0,0,0);const x=1/b;return e[0]=p*x,e[1]=(i*l-u*n)*x,e[2]=(o*n-i*a)*x,e[3]=f*x,e[4]=(u*t-i*c)*x,e[5]=(i*s-o*t)*x,e[6]=m*x,e[7]=(n*c-l*t)*x,e[8]=(a*t-n*s)*x,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,i,s,a,o){const c=Math.cos(s),l=Math.sin(s);return this.set(n*c,n*l,-n*(c*a+l*o)+a+e,-i*l,i*c,-i*(-l*a+c*o)+o+t,0,0,1),this}scale(e,t){return this.premultiply(Ds.makeScale(e,t)),this}rotate(e){return this.premultiply(Ds.makeRotation(-e)),this}translate(e,t){return this.premultiply(Ds.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){const t=this.elements,n=e.elements;for(let i=0;i<9;i++)if(t[i]!==n[i])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new Dt().fromArray(this.elements)}}const Ds=new Dt;var Xe;(function(r){r[r.Random=0]="Random",r[r.Loop=1]="Loop",r[r.PingPong=2]="PingPong",r[r.Burst=3]="Burst"})(Xe||(Xe={}));function ri(r,e,t,n){let i;switch(Xe.Random===r?e=Math.random():Xe.Burst===r&&n.isBursting&&(e=n.burstParticleIndex/n.burstParticleCount),t>0?i=Math.floor(e/t)*t:i=e,r){case Xe.Loop:i=i%1;break;case Xe.PingPong:i=Math.abs(i%2-1);break}return i}class bn{constructor(e,t,n,i){this.p=[e,t,n,i]}genValue(e){const t=e*e,n=e*e*e,i=1-e,s=i*i,a=s*i;return this.p[0]*a+this.p[1]*s*e*3+this.p[2]*i*t*3+this.p[3]*n}derivativeCoefficients(e){const t=[];for(let n=e,i=n.length-1;i>0;i--){const s=[];for(let a=0;a<i;a++){const o=i*(n[a+1]-n[a]);s.push(o)}t.push(s),n=s}return t}getSlope(e){const t=this.derivativeCoefficients(this.p)[0],n=1-e,i=n*n,s=n*e*2,a=e*e;return i*t[0]+s*t[1]+a*t[2]}controlCurve(e,t){this.p[1]=e/3+this.p[0],this.p[2]=this.p[3]-t/3}hull(e){let t=this.p,n=[],i,s=0,a=0,o=0;const c=[];for(c[s++]=t[0],c[s++]=t[1],c[s++]=t[2],c[s++]=t[3];t.length>1;){for(n=[],a=0,o=t.length-1;a<o;a++)i=e*t[a]+(1-e)*t[a+1],c[s++]=i,n.push(i);t=n}return c}split(e){const t=this.hull(e);return{left:new bn(t[0],t[4],t[7],t[9]),right:new bn(t[9],t[8],t[6],t[3]),span:t}}clone(){return new bn(this.p[0],this.p[1],this.p[2],this.p[3])}toJSON(){return{p0:this.p[0],p1:this.p[1],p2:this.p[2],p3:this.p[3]}}static fromJSON(e){return new bn(e.p0,e.p1,e.p2,e.p3)}}const si=r=>({r:r.x,g:r.y,b:r.z,a:r.w}),oi=r=>new tt(r.r,r.g,r.b,r.a),xh=(r,e)=>{switch(e){case"Vector3":return new G(r.x,r.y,r.z);case"Vector4":return new tt(r.x,r.y,r.z,r.w);case"Color":return new G(r.r,r.g,r.b);case"Number":return r;default:return r}},wh=(r,e)=>{switch(e){case"Vector3":return{x:r.x,y:r.y,z:r.z};case"Vector4":return{x:r.x,y:r.y,z:r.z,w:r.w};case"Color":return{r:r.x,g:r.y,b:r.z};case"Number":return r;default:return r}};class Yr{constructor(e,t){this.a=e,this.b=t,this.type="value"}startGen(e){}genColor(e,t){const n=Math.random();return t.copy(this.a).lerp(this.b,n)}toJSON(){return{type:"RandomColor",a:si(this.a),b:si(this.b)}}static fromJSON(e){return new Yr(oi(e.a),oi(e.b))}clone(){return new Yr(this.a.clone(),this.b.clone())}}class Gn{constructor(e,t){this.a=e,this.b=t,this.indexCount=-1,this.type="value"}startGen(e){this.indexCount=e.length,e.push(Math.random())}genColor(e,t){return this.indexCount===-1&&this.startGen(e),t.copy(this.a).lerp(this.b,e[this.indexCount])}toJSON(){return{type:"ColorRange",a:si(this.a),b:si(this.b)}}static fromJSON(e){return new Gn(oi(e.a),oi(e.b))}clone(){return new Gn(this.a.clone(),this.b.clone())}}class on{constructor(e,t){this.subType=t,this.type="function",this.keys=e}findKey(e){let t=0,n=0,i=this.keys.length-1;for(;n+1<i;)if(t=Math.floor((n+i)/2),e<this.getStartX(t))i=t-1;else if(e>this.getEndX(t))n=t+1;else return t;for(let s=n;s<=i;s++)if(e>=this.getStartX(s)&&e<=this.getEndX(s))return s;return-1}getStartX(e){return this.keys[e][1]}getEndX(e){return e+1<this.keys.length?this.keys[e+1][1]:1}genValue(e,t){const n=this.findKey(t);return this.subType==="Number"?n===-1?this.keys[0][0]:n+1>=this.keys.length?this.keys[this.keys.length-1][0]:(this.keys[n+1][0]-this.keys[n][0])*((t-this.getStartX(n))/(this.getEndX(n)-this.getStartX(n)))+this.keys[n][0]:n===-1?e.copy(this.keys[0][0]):n+1>=this.keys.length?e.copy(this.keys[this.keys.length-1][0]):e.copy(this.keys[n][0]).lerp(this.keys[n+1][0],(t-this.getStartX(n))/(this.getEndX(n)-this.getStartX(n)))}toJSON(){return this.keys[0][0].constructor.name,{type:"CLinearFunction",subType:this.subType,keys:this.keys.map(([e,t])=>({value:wh(e,this.subType),pos:t}))}}static fromJSON(e){return new on(e.keys.map(t=>[xh(t.value,e.subType),t.pos]),e.subType)}clone(){return this.subType==="Number"?new on(this.keys.map(([e,t])=>[e,t]),this.subType):new on(this.keys.map(([e,t])=>[e.clone(),t]),this.subType)}}const Sr=new G;class Tn{constructor(e=[[new G(0,0,0),0],[new G(1,1,1),0]],t=[[1,0],[1,1]]){this.type="function",this.color=new on(e,"Color"),this.alpha=new on(t,"Number")}genColor(e,t,n){return this.color.genValue(Sr,n),t.set(Sr.x,Sr.y,Sr.z,this.alpha.genValue(1,n))}toJSON(){return{type:"Gradient",color:this.color.toJSON(),alpha:this.alpha.toJSON()}}static fromJSON(e){if(e.functions){const t=e.functions.map(n=>[Gn.fromJSON(n.function).a,n.start]);return e.functions.length>0&&t.push([Gn.fromJSON(e.functions[e.functions.length-1].function).b,1]),new Tn(t.map(n=>[new G(n[0].x,n[0].y,n[0].z),n[1]]),t.map(n=>[n[0].w,n[1]]))}else{const t=new Tn;return t.alpha=on.fromJSON(e.alpha),t.color=on.fromJSON(e.color),t}}clone(){const e=new Tn;return e.alpha=this.alpha.clone(),e.color=this.color.clone(),e}startGen(e){}}const Ls=new tt;class Zr{constructor(e,t){this.indexCount=0,this.type="function",this.gradient1=e,this.gradient2=t}startGen(e){this.indexCount=e.length,e.push(Math.random())}genColor(e,t,n){return this.gradient1.genColor(e,t,n),this.gradient2.genColor(e,Ls,n),e&&e[this.indexCount]!==void 0?t.lerp(Ls,e[this.indexCount]):t.lerp(Ls,Math.random()),t}toJSON(){return{type:"RandomColorBetweenGradient",gradient1:this.gradient1.toJSON(),gradient2:this.gradient2.toJSON()}}static fromJSON(e){return new Zr(Tn.fromJSON(e.gradient1),Tn.fromJSON(e.gradient2))}clone(){return new Zr(this.gradient1.clone(),this.gradient2.clone())}}class xn{constructor(e){this.color=e,this.type="value"}startGen(e){}genColor(e,t){return t.copy(this.color)}toJSON(){return{type:"ConstantColor",color:si(this.color)}}static fromJSON(e){return new xn(oi(e.color))}clone(){return new xn(this.color.clone())}}function Fs(r){switch(r.type){case"ConstantColor":return xn.fromJSON(r);case"ColorRange":return Gn.fromJSON(r);case"RandomColor":return Yr.fromJSON(r);case"Gradient":return Tn.fromJSON(r);case"RandomColorBetweenGradient":return Zr.fromJSON(r);default:return new xn(new tt(1,1,1,1))}}class ne{constructor(e){this.value=e,this.type="value"}startGen(e){}genValue(e){return this.value}toJSON(){return{type:"ConstantValue",value:this.value}}static fromJSON(e){return new ne(e.value)}clone(){return new ne(this.value)}}class wn{constructor(e,t){this.a=e,this.b=t,this.indexCount=-1,this.type="value"}startGen(e){this.indexCount=e.length,e.push(Math.random())}genValue(e){return this.indexCount===-1&&this.startGen(e),An.lerp(this.a,this.b,e[this.indexCount])}toJSON(){return{type:"IntervalValue",a:this.a,b:this.b}}static fromJSON(e){return new wn(e.a,e.b)}clone(){return new wn(this.a,this.b)}}class _h{constructor(){this.functions=new Array}findFunction(e){let t=0,n=0,i=this.functions.length-1;for(;n+1<i;)if(t=Math.floor((n+i)/2),e<this.getStartX(t))i=t-1;else if(e>this.getEndX(t))n=t+1;else return t;for(let s=n;s<=i;s++)if(e>=this.functions[s][1]&&e<=this.getEndX(s))return s;return-1}getStartX(e){return this.functions[e][1]}setStartX(e,t){e>0&&(this.functions[e][1]=t)}getEndX(e){return e+1<this.functions.length?this.functions[e+1][1]:1}setEndX(e,t){e+1<this.functions.length&&(this.functions[e+1][1]=t)}insertFunction(e,t){const n=this.findFunction(e);this.functions.splice(n+1,0,[t,e])}removeFunction(e){return this.functions.splice(e,1)[0][0]}getFunction(e){return this.functions[e][0]}setFunction(e,t){this.functions[e][0]=t}get numOfFunctions(){return this.functions.length}}class _i extends _h{constructor(e=[[new bn(0,1/3,1/3*2,1),0]]){super(),this.type="function",this.functions=e}genValue(e,t=0){const n=this.findFunction(t);return n===-1?0:this.functions[n][0].genValue((t-this.getStartX(n))/(this.getEndX(n)-this.getStartX(n)))}toSVG(e,t){if(t<1)return"";let n=["M",0,this.functions[0][0].p[0]].join(" ");for(let i=1/t;i<=1;i+=1/t)n=[n,"L",i*e,this.genValue(void 0,i)].join(" ");return n}toJSON(){return{type:"PiecewiseBezier",functions:this.functions.map(([e,t])=>({function:e.toJSON(),start:t}))}}static fromJSON(e){return new _i(e.functions.map(t=>[bn.fromJSON(t.function),t.start]))}clone(){return new _i(this.functions.map(([e,t])=>[e.clone(),t]))}startGen(e){}}function Q(r){switch(r.type){case"ConstantValue":return ne.fromJSON(r);case"IntervalValue":return wn.fromJSON(r);case"PiecewiseBezier":return _i.fromJSON(r);default:return new ne(0)}}class Ti{constructor(){this.indexCount=0,this.type="rotation"}startGen(e){this.indexCount=e.length,e.push(new ie);let t,n,i,s,a,o;do t=Math.random()*2-1,n=Math.random()*2-1,i=t*t+n*n;while(i>1);do s=Math.random()*2-1,a=Math.random()*2-1,o=s*s+a*a;while(o>1);const c=Math.sqrt((1-i)/o);e[this.indexCount].set(t,n,c*s,c*a)}genValue(e,t,n,i){return this.indexCount===-1&&this.startGen(e),t.copy(e[this.indexCount]),t}toJSON(){return{type:"RandomQuat"}}static fromJSON(e){return new Ti}clone(){return new Ti}}class Mi{constructor(e,t){this.axis=e,this.angle=t,this.type="rotation"}startGen(e){this.angle.startGen(e)}genValue(e,t,n,i){return t.setFromAxisAngle(this.axis,this.angle.genValue(e,i)*n)}toJSON(){return{type:"AxisAngle",axis:{x:this.axis.x,y:this.axis.y,z:this.axis.z},angle:this.angle.toJSON()}}static fromJSON(e){return new Mi(new G(e.axis.x,e.axis.y,e.axis.z),Q(e.angle))}clone(){return new Mi(this.axis.clone(),this.angle.clone())}}class Kr{constructor(e,t,n,i){this.angleX=e,this.angleY=t,this.angleZ=n,this.type="rotation",this.eular=new wi(0,0,0,i)}startGen(e){this.angleX.startGen(e),this.angleY.startGen(e),this.angleZ.startGen(e)}genValue(e,t,n,i){return this.eular.set(this.angleX.genValue(e,i)*n,this.angleY.genValue(e,i)*n,this.angleZ.genValue(e,i)*n),t.setFromEuler(this.eular)}toJSON(){return{type:"Euler",angleX:this.angleX.toJSON(),angleY:this.angleY.toJSON(),angleZ:this.angleZ.toJSON(),eulerOrder:this.eular.order}}static fromJSON(e){return new Kr(Q(e.angleX),Q(e.angleY),Q(e.angleZ),e.eulerOrder)}clone(){return new Kr(this.angleX,this.angleY,this.angleZ,this.eular.order)}}function Uc(r){switch(r.type){case"AxisAngle":return Mi.fromJSON(r);case"Euler":return Kr.fromJSON(r);case"RandomQuat":return Ti.fromJSON(r);default:return new Ti}}class _n{constructor(e,t,n){this.x=e,this.y=t,this.z=n,this.type="vec3function"}startGen(e){this.x.startGen(e),this.y.startGen(e),this.z.startGen(e)}genValue(e,t,n){return t.set(this.x.genValue(e,n),this.y.genValue(e,n),this.z.genValue(e,n))}toJSON(){return{type:"Vector3Function",x:this.x.toJSON(),y:this.y.toJSON(),z:this.z.toJSON()}}static fromJSON(e){return new _n(Q(e.x),Q(e.y),Q(e.z))}clone(){return new _n(this.x,this.y,this.z)}}function Th(r){switch(r.type){case"Vector3Function":return _n.fromJSON(r);default:return new _n(new ne(0),new ne(0),new ne(0))}}function br(r){switch(r.type){case"ConstantValue":case"IntervalValue":case"PiecewiseBezier":return Q(r);case"AxisAngle":case"RandomQuat":case"Euler":return Uc(r);case"Vector3Function":return Th(r);default:return new ne(0)}}class Ci{constructor(e={}){var t,n,i,s,a,o,c;this.type="cone",this.currentValue=0,this.radius=(t=e.radius)!==null&&t!==void 0?t:10,this.arc=(n=e.arc)!==null&&n!==void 0?n:2*Math.PI,this.thickness=(i=e.thickness)!==null&&i!==void 0?i:1,this.angle=(s=e.angle)!==null&&s!==void 0?s:Math.PI/6,this.mode=(a=e.mode)!==null&&a!==void 0?a:Xe.Random,this.spread=(o=e.spread)!==null&&o!==void 0?o:0,this.speed=(c=e.speed)!==null&&c!==void 0?c:new ne(1),this.memory=[]}update(e,t){Xe.Random!=this.mode&&(this.currentValue+=this.speed.genValue(this.memory,e.emissionState.time/e.duration)*t)}initialize(e,t){const n=ri(this.mode,this.currentValue,this.spread,t),i=An.lerp(1-this.thickness,1,Math.random()),s=n*this.arc,a=Math.sqrt(i),o=Math.sin(s),c=Math.cos(s);e.position.x=a*c,e.position.y=a*o,e.position.z=0;const l=this.angle*a;e.velocity.set(0,0,Math.cos(l)).addScaledVector(e.position,Math.sin(l)).multiplyScalar(e.startSpeed),e.position.multiplyScalar(this.radius)}toJSON(){return{type:"cone",radius:this.radius,arc:this.arc,thickness:this.thickness,angle:this.angle,mode:this.mode,spread:this.spread,speed:this.speed.toJSON()}}static fromJSON(e){return new Ci({radius:e.radius,arc:e.arc,thickness:e.thickness,angle:e.angle,mode:e.mode,speed:e.speed?Q(e.speed):void 0,spread:e.spread})}clone(){return new Ci({radius:this.radius,arc:this.arc,thickness:this.thickness,angle:this.angle,mode:this.mode,speed:this.speed.clone(),spread:this.spread})}}class Ei{constructor(e={}){var t,n,i,s,a,o;this.type="circle",this.currentValue=0,this.radius=(t=e.radius)!==null&&t!==void 0?t:10,this.arc=(n=e.arc)!==null&&n!==void 0?n:2*Math.PI,this.thickness=(i=e.thickness)!==null&&i!==void 0?i:1,this.mode=(s=e.mode)!==null&&s!==void 0?s:Xe.Random,this.spread=(a=e.spread)!==null&&a!==void 0?a:0,this.speed=(o=e.speed)!==null&&o!==void 0?o:new ne(1),this.memory=[]}update(e,t){this.currentValue+=this.speed.genValue(this.memory,e.emissionState.time/e.duration)*t}initialize(e,t){const n=ri(this.mode,this.currentValue,this.spread,t),i=An.lerp(1-this.thickness,1,Math.random()),s=n*this.arc;e.position.x=Math.cos(s),e.position.y=Math.sin(s),e.position.z=0,e.velocity.copy(e.position).multiplyScalar(e.startSpeed),e.position.multiplyScalar(this.radius*i)}toJSON(){return{type:"circle",radius:this.radius,arc:this.arc,thickness:this.thickness,mode:this.mode,spread:this.spread,speed:this.speed.toJSON()}}static fromJSON(e){return new Ei({radius:e.radius,arc:e.arc,thickness:e.thickness,mode:e.mode,speed:e.speed?Q(e.speed):void 0,spread:e.spread})}clone(){return new Ei({radius:this.radius,arc:this.arc,thickness:this.thickness,mode:this.mode,speed:this.speed.clone(),spread:this.spread})}}function xr(r,e){return Math.floor(Math.random()*(e-r))+r}const wr=new G(0,1,0),_r=new G(0,0,0),Mh=new G(1,1,1),Dc=new G(0,0,1);class Pi{constructor(e={}){var t,n,i,s,a,o,c;this.type="donut",this.currentValue=0,this.radius=(t=e.radius)!==null&&t!==void 0?t:10,this.arc=(n=e.arc)!==null&&n!==void 0?n:2*Math.PI,this.thickness=(i=e.thickness)!==null&&i!==void 0?i:1,this.donutRadius=(s=e.donutRadius)!==null&&s!==void 0?s:this.radius*.2,this.mode=(a=e.mode)!==null&&a!==void 0?a:Xe.Random,this.spread=(o=e.spread)!==null&&o!==void 0?o:0,this.speed=(c=e.speed)!==null&&c!==void 0?c:new ne(1),this.memory=[],this._m1=new Rt}update(e,t){Xe.Random!=this.mode&&(this.currentValue+=this.speed.genValue(this.memory,e.emissionState.time/e.duration)*t)}initialize(e,t){const n=ri(this.mode,this.currentValue,this.spread,t),i=Math.random(),s=An.lerp(1-this.thickness,1,Math.random()),a=n*this.arc,o=i*Math.PI*2,c=Math.sin(a),l=Math.cos(a);e.position.x=this.radius*l,e.position.y=this.radius*c,e.position.z=0,e.velocity.z=this.donutRadius*s*Math.sin(o),e.velocity.x=this.donutRadius*s*Math.cos(o)*l,e.velocity.y=this.donutRadius*s*Math.cos(o)*c,e.position.add(e.velocity),e.velocity.normalize().multiplyScalar(e.startSpeed),e.rotation instanceof ie&&(this._m1.lookAt(_r,e.velocity,wr),e.rotation.setFromRotationMatrix(this._m1))}toJSON(){return{type:"donut",radius:this.radius,arc:this.arc,thickness:this.thickness,donutRadius:this.donutRadius,mode:this.mode,spread:this.spread,speed:this.speed.toJSON()}}static fromJSON(e){return new Pi({radius:e.radius,arc:e.arc,thickness:e.thickness,donutRadius:e.donutRadius,mode:e.mode,speed:e.speed?Q(e.speed):void 0,spread:e.spread})}clone(){return new Pi({radius:this.radius,arc:this.arc,thickness:this.thickness,donutRadius:this.donutRadius,mode:this.mode,speed:this.speed.clone(),spread:this.spread})}}class ki{constructor(){this.type="point",this._m1=new Rt}update(e,t){}initialize(e){const t=Math.random(),n=Math.random(),i=t*Math.PI*2,s=Math.acos(2*n-1),a=Math.cbrt(Math.random()),o=Math.sin(i),c=Math.cos(i),l=Math.sin(s),u=Math.cos(s);e.velocity.x=a*l*c,e.velocity.y=a*l*o,e.velocity.z=a*u,e.velocity.multiplyScalar(e.startSpeed),e.position.setScalar(0),e.rotation instanceof ie&&(this._m1.lookAt(_r,e.position,wr),e.rotation.setFromRotationMatrix(this._m1))}toJSON(){return{type:"point"}}static fromJSON(e){return new ki}clone(){return new ki}}class Wn{constructor(e={}){var t,n,i,s,a,o;this.type="sphere",this.currentValue=0,this.radius=(t=e.radius)!==null&&t!==void 0?t:10,this.arc=(n=e.arc)!==null&&n!==void 0?n:2*Math.PI,this.thickness=(i=e.thickness)!==null&&i!==void 0?i:1,this.mode=(s=e.mode)!==null&&s!==void 0?s:Xe.Random,this.spread=(a=e.spread)!==null&&a!==void 0?a:0,this.speed=(o=e.speed)!==null&&o!==void 0?o:new ne(1),this.memory=[],this._m1=new Rt}update(e,t){Xe.Random!=this.mode&&(this.currentValue+=this.speed.genValue(this.memory,e.emissionState.time/e.duration)*t)}initialize(e,t){const n=ri(this.mode,this.currentValue,this.spread,t),i=Math.random(),s=An.lerp(1-this.thickness,1,Math.random()),a=n*this.arc,o=Math.acos(2*i-1),c=Math.sin(a),l=Math.cos(a),u=Math.sin(o),p=Math.cos(o);e.position.x=u*l,e.position.y=u*c,e.position.z=p,e.velocity.copy(e.position).multiplyScalar(e.startSpeed),e.position.multiplyScalar(this.radius*s),e.rotation instanceof ie&&(this._m1.lookAt(_r,e.position,wr),e.rotation.setFromRotationMatrix(this._m1))}toJSON(){return{type:"sphere",radius:this.radius,arc:this.arc,thickness:this.thickness,mode:this.mode,spread:this.spread,speed:this.speed.toJSON()}}static fromJSON(e){return new Wn({radius:e.radius,arc:e.arc,thickness:e.thickness,mode:e.mode,speed:e.speed?Q(e.speed):void 0,spread:e.spread})}clone(){return new Wn({radius:this.radius,arc:this.arc,thickness:this.thickness,mode:this.mode,speed:this.speed.clone(),spread:this.spread})}}class Ri{constructor(e={}){var t,n,i,s,a,o;this.type="sphere",this.currentValue=0,this.radius=(t=e.radius)!==null&&t!==void 0?t:10,this.arc=(n=e.arc)!==null&&n!==void 0?n:2*Math.PI,this.thickness=(i=e.thickness)!==null&&i!==void 0?i:1,this.mode=(s=e.mode)!==null&&s!==void 0?s:Xe.Random,this.spread=(a=e.spread)!==null&&a!==void 0?a:0,this.speed=(o=e.speed)!==null&&o!==void 0?o:new ne(1),this.memory=[],this._m1=new Rt}update(e,t){Xe.Random!=this.mode&&(this.currentValue+=this.speed.genValue(this.memory,e.emissionState.time/e.duration)*t)}initialize(e,t){const n=ri(this.mode,this.currentValue,this.spread,t),i=Math.random(),s=An.lerp(1-this.thickness,1,Math.random()),a=n*this.arc,o=Math.acos(i),c=Math.sin(a),l=Math.cos(a),u=Math.sin(o),p=Math.cos(o);e.position.x=u*l,e.position.y=u*c,e.position.z=p,e.velocity.copy(e.position).multiplyScalar(e.startSpeed),e.position.multiplyScalar(this.radius*s),e.rotation instanceof ie&&(this._m1.lookAt(_r,e.position,wr),e.rotation.setFromRotationMatrix(this._m1))}toJSON(){return{type:"hemisphere",radius:this.radius,arc:this.arc,thickness:this.thickness,mode:this.mode,spread:this.spread,speed:this.speed.toJSON()}}static fromJSON(e){return new Ri({radius:e.radius,arc:e.arc,thickness:e.thickness,mode:e.mode,speed:e.speed?Q(e.speed):void 0,spread:e.spread})}clone(){return new Ri({radius:this.radius,arc:this.arc,thickness:this.thickness,mode:this.mode,speed:this.speed.clone(),spread:this.spread})}}class Ai{constructor(e={}){var t,n,i,s;this.type="grid",this.width=(t=e.width)!==null&&t!==void 0?t:1,this.height=(n=e.height)!==null&&n!==void 0?n:1,this.column=(i=e.column)!==null&&i!==void 0?i:10,this.row=(s=e.row)!==null&&s!==void 0?s:10}initialize(e){const t=Math.floor(Math.random()*this.row),n=Math.floor(Math.random()*this.column);e.position.x=n*this.width/this.column-this.width/2,e.position.y=t*this.height/this.row-this.height/2,e.position.z=0,e.velocity.set(0,0,e.startSpeed)}toJSON(){return{type:"grid",width:this.width,height:this.height,column:this.column,row:this.row}}static fromJSON(e){return new Ai(e)}clone(){return new Ai({width:this.width,height:this.height,column:this.column,row:this.row})}update(e,t){}}const Vs={circle:{type:"circle",params:[["radius",["number"]],["arc",["radian"]],["thickness",["number"]],["mode",["emitterMode"]],["spread",["number"]],["speed",["valueFunc"]]],constructor:Ei,loadJSON:Ei.fromJSON},cone:{type:"cone",params:[["radius",["number"]],["arc",["radian"]],["thickness",["number"]],["angle",["radian"]],["mode",["emitterMode"]],["spread",["number"]],["speed",["valueFunc"]]],constructor:Ci,loadJSON:Ci.fromJSON},donut:{type:"donut",params:[["radius",["number"]],["arc",["radian"]],["thickness",["number"]],["donutRadius",["number"]],["mode",["emitterMode"]],["spread",["number"]],["speed",["valueFunc"]]],constructor:Pi,loadJSON:Pi.fromJSON},point:{type:"point",params:[],constructor:ki,loadJSON:ki.fromJSON},sphere:{type:"sphere",params:[["radius",["number"]],["arc",["radian"]],["thickness",["number"]],["angle",["radian"]],["mode",["emitterMode"]],["spread",["number"]],["speed",["valueFunc"]]],constructor:Wn,loadJSON:Wn.fromJSON},hemisphere:{type:"hemisphere",params:[["radius",["number"]],["arc",["radian"]],["thickness",["number"]],["angle",["radian"]],["mode",["emitterMode"]],["spread",["number"]],["speed",["valueFunc"]]],constructor:Ri,loadJSON:Ri.fromJSON},grid:{type:"grid",params:[["width",["number"]],["height",["number"]],["rows",["number"]],["column",["number"]]],constructor:Ai,loadJSON:Ai.fromJSON}};function Ch(r,e){return Vs[r.type].loadJSON(r,e)}class Oi{constructor(e){this.color=e,this.type="ColorOverLife"}initialize(e){this.color.startGen(e.memory)}update(e,t){this.color.genColor(e.memory,e.color,e.age/e.life),e.color.x*=e.startColor.x,e.color.y*=e.startColor.y,e.color.z*=e.startColor.z,e.color.w*=e.startColor.w}frameUpdate(e){}toJSON(){return{type:this.type,color:this.color.toJSON()}}static fromJSON(e){return new Oi(Fs(e.color))}clone(){return new Oi(this.color.clone())}reset(){}}class Ii{constructor(e){this.angularVelocity=e,this.type="RotationOverLife"}initialize(e){typeof e.rotation=="number"&&this.angularVelocity.startGen(e.memory)}update(e,t){typeof e.rotation=="number"&&(e.rotation+=t*this.angularVelocity.genValue(e.memory,e.age/e.life))}toJSON(){return{type:this.type,angularVelocity:this.angularVelocity.toJSON()}}static fromJSON(e){return new Ii(Q(e.angularVelocity))}frameUpdate(e){}clone(){return new Ii(this.angularVelocity.clone())}reset(){}}class zi{constructor(e){this.angularVelocity=e,this.type="Rotation3DOverLife",this.tempQuat=new ie,this.tempQuat2=new ie}initialize(e){e.rotation instanceof ie&&(e.angularVelocity=new ie,this.angularVelocity.startGen(e.memory))}update(e,t){e.rotation instanceof ie&&(this.angularVelocity.genValue(e.memory,this.tempQuat,t,e.age/e.life),e.rotation.multiply(this.tempQuat))}toJSON(){return{type:this.type,angularVelocity:this.angularVelocity.toJSON()}}static fromJSON(e){return new zi(Uc(e.angularVelocity))}frameUpdate(e){}clone(){return new zi(this.angularVelocity.clone())}reset(){}}class Bi{initialize(e,t){this.ps=t,this.x.startGen(e.memory),this.y.startGen(e.memory),this.z.startGen(e.memory)}constructor(e,t,n){this.x=e,this.y=t,this.z=n,this.type="ForceOverLife",this._temp=new G,this._tempScale=new G,this._tempQ=new ie}update(e,t){this._temp.set(this.x.genValue(e.memory,e.age/e.life),this.y.genValue(e.memory,e.age/e.life),this.z.genValue(e.memory,e.age/e.life)),this.ps.worldSpace?e.velocity.addScaledVector(this._temp,t):(this._temp.multiply(this._tempScale).applyQuaternion(this._tempQ),e.velocity.addScaledVector(this._temp,t))}toJSON(){return{type:this.type,x:this.x.toJSON(),y:this.y.toJSON(),z:this.z.toJSON()}}static fromJSON(e){return new Bi(Q(e.x),Q(e.y),Q(e.z))}frameUpdate(e){if(this.ps&&!this.ps.worldSpace){const t=this._temp,n=this._tempQ,i=this._tempScale;this.ps.emitter.matrixWorld.decompose(t,n,i),n.invert(),i.set(1/i.x,1/i.y,1/i.z)}}clone(){return new Bi(this.x.clone(),this.y.clone(),this.z.clone())}reset(){}}class Ni{initialize(e){this.size.startGen(e.memory)}constructor(e){this.size=e,this.type="SizeOverLife"}update(e){this.size instanceof _n?this.size.genValue(e.memory,e.size,e.age/e.life).multiply(e.startSize):e.size.copy(e.startSize).multiplyScalar(this.size.genValue(e.memory,e.age/e.life))}toJSON(){return{type:this.type,size:this.size.toJSON()}}static fromJSON(e){return new Ni(br(e.size))}frameUpdate(e){}clone(){return new Ni(this.size.clone())}reset(){}}class Ui{initialize(e){this.speed.startGen(e.memory)}constructor(e){this.speed=e,this.type="SpeedOverLife"}update(e){e.speedModifier=this.speed.genValue(e.memory,e.age/e.life)}toJSON(){return{type:this.type,speed:this.speed.toJSON()}}static fromJSON(e){return new Ui(Q(e.speed))}frameUpdate(e){}clone(){return new Ui(this.speed.clone())}reset(){}}class Di{constructor(e){this.frame=e,this.type="FrameOverLife"}initialize(e){this.frame.startGen(e.memory)}update(e,t){this.frame instanceof _i&&(e.uvTile=this.frame.genValue(e.memory,e.age/e.life))}frameUpdate(e){}toJSON(){return{type:this.type,frame:this.frame.toJSON()}}static fromJSON(e){return new Di(Q(e.frame))}clone(){return new Di(this.frame.clone())}reset(){}}class Li{constructor(e,t=new G(0,1,0)){this.orbitSpeed=e,this.axis=t,this.type="OrbitOverLife",this.temp=new G,this.rotation=new ie}initialize(e){this.orbitSpeed.startGen(e.memory)}update(e,t){this.temp.copy(e.position).projectOnVector(this.axis),this.rotation.setFromAxisAngle(this.axis,this.orbitSpeed.genValue(e.memory,e.age/e.life)*t),e.position.sub(this.temp),e.position.applyQuaternion(this.rotation),e.position.add(this.temp)}frameUpdate(e){}toJSON(){return{type:this.type,orbitSpeed:this.orbitSpeed.toJSON(),axis:[this.axis.x,this.axis.y,this.axis.z]}}static fromJSON(e){return new Li(Q(e.orbitSpeed),e.axis?new G(e.axis[0],e.axis[1],e.axis[2]):void 0)}clone(){return new Li(this.orbitSpeed.clone())}reset(){}}class js{constructor(e){this.data=e,this.next=null,this.prev=null}hasPrev(){return this.prev!==null}hasNext(){return this.next!==null}}class Eh{constructor(){this.length=0,this.head=this.tail=null}isEmpty(){return this.head===null}clear(){this.length=0,this.head=this.tail=null}front(){return this.head===null?null:this.head.data}back(){return this.tail===null?null:this.tail.data}dequeue(){if(this.head){const e=this.head.data;return this.head=this.head.next,this.head?this.head.prev=null:this.tail=null,this.length--,e}}pop(){if(this.tail){const e=this.tail.data;return this.tail=this.tail.prev,this.tail?this.tail.next=null:this.head=null,this.length--,e}}queue(e){const t=new js(e);this.tail||(this.tail=t),this.head&&(this.head.prev=t,t.next=this.head),this.head=t,this.length++}push(e){const t=new js(e);this.head||(this.head=t),this.tail&&(this.tail.next=t,t.prev=this.tail),this.tail=t,this.length++}insertBefore(e,t){const n=new js(t);n.next=e,n.prev=e.prev,n.prev!==null&&(n.prev.next=n),n.next.prev=n,e==this.head&&(this.head=n),this.length++}remove(e){if(this.head===null||this.tail===null)return;let t=this.head;for(e===this.head.data&&(this.head=this.head.next),e===this.tail.data&&(this.tail=this.tail.prev);t.next!==null&&t.data!==e;)t=t.next;t.data===e&&(t.prev!==null&&(t.prev.next=t.next),t.next!==null&&(t.next.prev=t.prev),this.length--)}*values(){let e=this.head;for(;e!==null;)yield e.data,e=e.next}}class Ph{constructor(){this.startSpeed=0,this.startColor=new tt,this.startSize=new G(1,1,1),this.position=new G,this.velocity=new G,this.age=0,this.life=1,this.size=new G(1,1,1),this.speedModifier=1,this.rotation=0,this.color=new tt,this.uvTile=0,this.memory=[]}get died(){return this.age>=this.life}reset(){this.memory.length=0}}class kh{constructor(e,t,n){this.position=e,this.size=t,this.color=n}}class Tr{constructor(){this.startSpeed=0,this.startColor=new tt,this.startSize=new G(1,1,1),this.position=new G,this.velocity=new G,this.age=0,this.life=1,this.size=new G(1,1,1),this.length=100,this.speedModifier=1,this.color=new tt,this.previous=new Eh,this.uvTile=0,this.memory=[]}update(){for(this.age<=this.life?this.previous.push(new kh(this.position.clone(),this.size.x,this.color.clone())):this.previous.length>0&&this.previous.dequeue();this.previous.length>this.length;)this.previous.dequeue()}get died(){return this.age>=this.life}reset(){this.memory.length=0,this.previous.clear()}}class Fi{initialize(e){this.width.startGen(e.memory)}constructor(e){this.width=e,this.type="WidthOverLength"}update(e){if(e instanceof Tr){const t=e.previous.values();for(let n=0;n<e.previous.length;n++){const i=t.next();i.value.size=this.width.genValue(e.memory,(e.previous.length-n)/e.length)}}}frameUpdate(e){}toJSON(){return{type:this.type,width:this.width.toJSON()}}static fromJSON(e){return new Fi(Q(e.width))}clone(){return new Fi(this.width.clone())}reset(){}}class Vi{constructor(e,t){this.direction=e,this.magnitude=t,this.type="ApplyForce",this.memory={data:[],dataCount:0},this.magnitudeValue=this.magnitude.genValue(this.memory)}initialize(e){}update(e,t){e.velocity.addScaledVector(this.direction,this.magnitudeValue*t)}frameUpdate(e){this.magnitudeValue=this.magnitude.genValue(this.memory)}toJSON(){return{type:this.type,direction:[this.direction.x,this.direction.y,this.direction.z],magnitude:this.magnitude.toJSON()}}static fromJSON(e){var t;return new Vi(new G(e.direction[0],e.direction[1],e.direction[2]),Q((t=e.magnitude)!==null&&t!==void 0?t:e.force))}clone(){return new Vi(this.direction.clone(),this.magnitude.clone())}reset(){}}class ji{constructor(e,t){this.center=e,this.magnitude=t,this.type="GravityForce",this.temp=new G}initialize(e){}update(e,t){this.temp.copy(this.center).sub(e.position).normalize(),e.velocity.addScaledVector(this.temp,this.magnitude/e.position.distanceToSquared(this.center)*t)}frameUpdate(e){}toJSON(){return{type:this.type,center:[this.center.x,this.center.y,this.center.z],magnitude:this.magnitude}}static fromJSON(e){return new ji(new G(e.center[0],e.center[1],e.center[2]),e.magnitude)}clone(){return new ji(this.center.clone(),this.magnitude)}reset(){}}class Ji{constructor(e){this.angle=e,this.type="ChangeEmitDirection",this._temp=new G,this._q=new ie,this.memory={data:[],dataCount:0}}initialize(e){const t=e.velocity.length();t!=0&&(e.velocity.normalize(),e.velocity.x===0&&e.velocity.y===0?this._temp.set(0,e.velocity.z,0):this._temp.set(-e.velocity.y,e.velocity.x,0),this.angle.startGen(this.memory),this._q.setFromAxisAngle(this._temp.normalize(),this.angle.genValue(this.memory)),this._temp.copy(e.velocity),e.velocity.applyQuaternion(this._q),this._q.setFromAxisAngle(this._temp,Math.random()*Math.PI*2),e.velocity.applyQuaternion(this._q),e.velocity.setLength(t))}update(e,t){}frameUpdate(e){}toJSON(){return{type:this.type,angle:this.angle.toJSON()}}static fromJSON(e){return new Ji(Q(e.angle))}clone(){return new Ji(this.angle)}reset(){}}var In;(function(r){r[r.Death=0]="Death",r[r.Birth=1]="Birth",r[r.Frame=2]="Frame"})(In||(In={}));class Gi{constructor(e,t,n,i=In.Frame,s=1){this.particleSystem=e,this.useVelocityAsBasis=t,this.subParticleSystem=n,this.mode=i,this.emitProbability=s,this.type="EmitSubParticleSystem",this.q_=new ie,this.v_=new G,this.v2_=new G,this.subEmissions=new Array,this.subParticleSystem&&this.subParticleSystem.system&&(this.subParticleSystem.system.onlyUsedByOther=!0)}initialize(e){}update(e,t){this.mode===In.Frame?this.emit(e,t):this.mode===In.Birth&&e.age===0?this.emit(e,t):this.mode===In.Death&&e.age+t>=e.life&&this.emit(e,t)}emit(e,t){if(!this.subParticleSystem||Math.random()>this.emitProbability)return;const n=new Rt;this.setMatrixFromParticle(n,e),this.subEmissions.push({burstParticleCount:0,burstParticleIndex:0,isBursting:!1,burstIndex:0,burstWaveIndex:0,time:0,waitEmiting:0,matrix:n,travelDistance:0,particle:e})}frameUpdate(e){if(this.subParticleSystem)for(let t=0;t<this.subEmissions.length;t++)if(this.subEmissions[t].time>=this.subParticleSystem.system.duration)this.subEmissions[t]=this.subEmissions[this.subEmissions.length-1],this.subEmissions.length=this.subEmissions.length-1,t--;else{const n=this.subEmissions[t];n.particle&&n.particle.age<n.particle.life?this.setMatrixFromParticle(n.matrix,n.particle):n.particle=void 0,this.subParticleSystem.system.emit(e,n,n.matrix)}}toJSON(){return{type:this.type,subParticleSystem:this.subParticleSystem?this.subParticleSystem.uuid:"",useVelocityAsBasis:this.useVelocityAsBasis,mode:this.mode,emitProbability:this.emitProbability}}static fromJSON(e,t){return new Gi(t,e.useVelocityAsBasis,e.subParticleSystem,e.mode,e.emitProbability)}clone(){return new Gi(this.particleSystem,this.useVelocityAsBasis,this.subParticleSystem,this.mode,this.emitProbability)}reset(){}setMatrixFromParticle(e,t){let n;if(t.rotation===void 0||this.useVelocityAsBasis)if(t.velocity.x===0&&t.velocity.y===0&&(t.velocity.z===1||t.velocity.z===0))e.set(1,0,0,t.position.x,0,1,0,t.position.y,0,0,1,t.position.z,0,0,0,1);else{this.v_.copy(Dc).cross(t.velocity),this.v2_.copy(t.velocity).cross(this.v_);const i=this.v_.length(),s=this.v2_.length();e.set(this.v_.x/i,this.v2_.x/s,t.velocity.x,t.position.x,this.v_.y/i,this.v2_.y/s,t.velocity.y,t.position.y,this.v_.z/i,this.v2_.z/s,t.velocity.z,t.position.z,0,0,0,1)}else t.rotation instanceof ie?n=t.rotation:(this.q_.setFromAxisAngle(Dc,t.rotation),n=this.q_),e.compose(t.position,n,Mh);this.particleSystem.worldSpace||e.multiplyMatrices(this.particleSystem.emitter.matrixWorld,e)}}const Rh=.5*(Math.sqrt(3)-1),ai=(3-Math.sqrt(3))/6,Ah=1/3,Nt=1/6,Oh=(Math.sqrt(5)-1)/4,Be=(5-Math.sqrt(5))/20,Ae=new Float32Array([1,1,0,-1,1,0,1,-1,0,-1,-1,0,1,0,1,-1,0,1,1,0,-1,-1,0,-1,0,1,1,0,-1,1,0,1,-1,0,-1,-1]),_e=new Float32Array([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]);class Lc{constructor(e=Math.random){const t=typeof e=="function"?e:zh(e);this.p=Ih(t),this.perm=new Uint8Array(512),this.permMod12=new Uint8Array(512);for(let n=0;n<512;n++)this.perm[n]=this.p[n&255],this.permMod12[n]=this.perm[n]%12}noise2D(e,t){const n=this.permMod12,i=this.perm;let s=0,a=0,o=0;const c=(e+t)*Rh,l=Math.floor(e+c),u=Math.floor(t+c),p=(l+u)*ai,f=l-p,m=u-p,b=e-f,x=t-m;let g,v;b>x?(g=1,v=0):(g=0,v=1);const _=b-g+ai,w=x-v+ai,C=b-1+2*ai,M=x-1+2*ai,E=l&255,P=u&255;let O=.5-b*b-x*x;if(O>=0){const B=n[E+i[P]]*3;O*=O,s=O*O*(Ae[B]*b+Ae[B+1]*x)}let R=.5-_*_-w*w;if(R>=0){const B=n[E+g+i[P+v]]*3;R*=R,a=R*R*(Ae[B]*_+Ae[B+1]*w)}let A=.5-C*C-M*M;if(A>=0){const B=n[E+1+i[P+1]]*3;A*=A,o=A*A*(Ae[B]*C+Ae[B+1]*M)}return 70*(s+a+o)}noise3D(e,t,n){const i=this.permMod12,s=this.perm;let a,o,c,l;const u=(e+t+n)*Ah,p=Math.floor(e+u),f=Math.floor(t+u),m=Math.floor(n+u),b=(p+f+m)*Nt,x=p-b,g=f-b,v=m-b,_=e-x,w=t-g,C=n-v;let M,E,P,O,R,A;_>=w?w>=C?(M=1,E=0,P=0,O=1,R=1,A=0):_>=C?(M=1,E=0,P=0,O=1,R=0,A=1):(M=0,E=0,P=1,O=1,R=0,A=1):w<C?(M=0,E=0,P=1,O=0,R=1,A=1):_<C?(M=0,E=1,P=0,O=0,R=1,A=1):(M=0,E=1,P=0,O=1,R=1,A=0);const B=_-M+Nt,z=w-E+Nt,D=C-P+Nt,F=_-O+2*Nt,H=w-R+2*Nt,q=C-A+2*Nt,$=_-1+3*Nt,J=w-1+3*Nt,Se=C-1+3*Nt,ce=p&255,me=f&255,le=m&255;let xe=.6-_*_-w*w-C*C;if(xe<0)a=0;else{const oe=i[ce+s[me+s[le]]]*3;xe*=xe,a=xe*xe*(Ae[oe]*_+Ae[oe+1]*w+Ae[oe+2]*C)}let Ce=.6-B*B-z*z-D*D;if(Ce<0)o=0;else{const oe=i[ce+M+s[me+E+s[le+P]]]*3;Ce*=Ce,o=Ce*Ce*(Ae[oe]*B+Ae[oe+1]*z+Ae[oe+2]*D)}let ye=.6-F*F-H*H-q*q;if(ye<0)c=0;else{const oe=i[ce+O+s[me+R+s[le+A]]]*3;ye*=ye,c=ye*ye*(Ae[oe]*F+Ae[oe+1]*H+Ae[oe+2]*q)}let pe=.6-$*$-J*J-Se*Se;if(pe<0)l=0;else{const oe=i[ce+1+s[me+1+s[le+1]]]*3;pe*=pe,l=pe*pe*(Ae[oe]*$+Ae[oe+1]*J+Ae[oe+2]*Se)}return 32*(a+o+c+l)}noise4D(e,t,n,i){const s=this.perm;let a,o,c,l,u;const p=(e+t+n+i)*Oh,f=Math.floor(e+p),m=Math.floor(t+p),b=Math.floor(n+p),x=Math.floor(i+p),g=(f+m+b+x)*Be,v=f-g,_=m-g,w=b-g,C=x-g,M=e-v,E=t-_,P=n-w,O=i-C;let R=0,A=0,B=0,z=0;M>E?R++:A++,M>P?R++:B++,M>O?R++:z++,E>P?A++:B++,E>O?A++:z++,P>O?B++:z++;const D=R>=3?1:0,F=A>=3?1:0,H=B>=3?1:0,q=z>=3?1:0,$=R>=2?1:0,J=A>=2?1:0,Se=B>=2?1:0,ce=z>=2?1:0,me=R>=1?1:0,le=A>=1?1:0,xe=B>=1?1:0,Ce=z>=1?1:0,ye=M-D+Be,pe=E-F+Be,oe=P-H+Be,nt=O-q+Be,je=M-$+2*Be,Ye=E-J+2*Be,it=P-Se+2*Be,Oe=O-ce+2*Be,fe=M-me+3*Be,ae=E-le+3*Be,lt=P-xe+3*Be,Ee=O-Ce+3*Be,ue=M-1+4*Be,Ze=E-1+4*Be,St=P-1+4*Be,bt=O-1+4*Be,Ke=f&255,xt=m&255,ut=b&255,ht=x&255;let rt=.6-M*M-E*E-P*P-O*O;if(rt<0)a=0;else{const ee=s[Ke+s[xt+s[ut+s[ht]]]]%32*4;rt*=rt,a=rt*rt*(_e[ee]*M+_e[ee+1]*E+_e[ee+2]*P+_e[ee+3]*O)}let Pe=.6-ye*ye-pe*pe-oe*oe-nt*nt;if(Pe<0)o=0;else{const ee=s[Ke+D+s[xt+F+s[ut+H+s[ht+q]]]]%32*4;Pe*=Pe,o=Pe*Pe*(_e[ee]*ye+_e[ee+1]*pe+_e[ee+2]*oe+_e[ee+3]*nt)}let Je=.6-je*je-Ye*Ye-it*it-Oe*Oe;if(Je<0)c=0;else{const ee=s[Ke+$+s[xt+J+s[ut+Se+s[ht+ce]]]]%32*4;Je*=Je,c=Je*Je*(_e[ee]*je+_e[ee+1]*Ye+_e[ee+2]*it+_e[ee+3]*Oe)}let st=.6-fe*fe-ae*ae-lt*lt-Ee*Ee;if(st<0)l=0;else{const ee=s[Ke+me+s[xt+le+s[ut+xe+s[ht+Ce]]]]%32*4;st*=st,l=st*st*(_e[ee]*fe+_e[ee+1]*ae+_e[ee+2]*lt+_e[ee+3]*Ee)}let Ge=.6-ue*ue-Ze*Ze-St*St-bt*bt;if(Ge<0)u=0;else{const ee=s[Ke+1+s[xt+1+s[ut+1+s[ht+1]]]]%32*4;Ge*=Ge,u=Ge*Ge*(_e[ee]*ue+_e[ee+1]*Ze+_e[ee+2]*St+_e[ee+3]*bt)}return 27*(a+o+c+l+u)}}function Ih(r){const e=new Uint8Array(256);for(let t=0;t<256;t++)e[t]=t;for(let t=0;t<255;t++){const n=t+~~(r()*(256-t)),i=e[t];e[t]=e[n],e[n]=i}return e}function zh(r){let e=0,t=0,n=0,i=1;const s=Bh();return e=s(" "),t=s(" "),n=s(" "),e-=s(r),e<0&&(e+=1),t-=s(r),t<0&&(t+=1),n-=s(r),n<0&&(n+=1),function(){const a=2091639*e+i*23283064365386963e-26;return e=t,t=n,n=a-(i=a|0)}}function Bh(){let r=4022871197;return function(e){e=e.toString();for(let t=0;t<e.length;t++){r+=e.charCodeAt(t);let n=.02519603282416938*r;r=n>>>0,n-=r,n*=r,r=n>>>0,n-=r,r+=n*4294967296}return(r>>>0)*23283064365386963e-26}}class Wi{constructor(e,t,n,i){this.scale=e,this.octaves=t,this.velocityMultiplier=n,this.timeScale=i,this.type="TurbulenceField",this.generator=new Lc,this.timeOffset=new G,this.temp=new G,this.temp2=new G,this.timeOffset.x=Math.random()/this.scale.x*this.timeScale.x,this.timeOffset.y=Math.random()/this.scale.y*this.timeScale.y,this.timeOffset.z=Math.random()/this.scale.z*this.timeScale.z}initialize(e){}update(e,t){const n=e.position.x/this.scale.x,i=e.position.y/this.scale.y,s=e.position.z/this.scale.z;this.temp.set(0,0,0);let a=1;for(let o=0;o<this.octaves;o++)this.temp2.set(this.generator.noise4D(n*a,i*a,s*a,this.timeOffset.x*a)/a,this.generator.noise4D(n*a,i*a,s*a,this.timeOffset.y*a)/a,this.generator.noise4D(n*a,i*a,s*a,this.timeOffset.z*a)/a),this.temp.add(this.temp2),a*=2;this.temp.multiply(this.velocityMultiplier),e.velocity.addScaledVector(this.temp,t)}toJSON(){return{type:this.type,scale:[this.scale.x,this.scale.y,this.scale.z],octaves:this.octaves,velocityMultiplier:[this.velocityMultiplier.x,this.velocityMultiplier.y,this.velocityMultiplier.z],timeScale:[this.timeScale.x,this.timeScale.y,this.timeScale.z]}}frameUpdate(e){this.timeOffset.x+=e*this.timeScale.x,this.timeOffset.y+=e*this.timeScale.y,this.timeOffset.z+=e*this.timeScale.z}static fromJSON(e){return new Wi(new G(e.scale[0],e.scale[1],e.scale[2]),e.octaves,new G(e.velocityMultiplier[0],e.velocityMultiplier[1],e.velocityMultiplier[2]),new G(e.timeScale[0],e.timeScale[1],e.timeScale[2]))}clone(){return new Wi(this.scale.clone(),this.octaves,this.velocityMultiplier.clone(),this.timeScale.clone())}reset(){}}const Ut=[],Js=new G,Gs=new ie;class Hi{constructor(e,t,n=new ne(1),i=new ne(0)){if(this.frequency=e,this.power=t,this.positionAmount=n,this.rotationAmount=i,this.type="Noise",this.duration=0,Ut.length===0)for(let s=0;s<100;s++)Ut.push(new Lc)}initialize(e){e.lastPosNoise=new G,typeof e.rotation=="number"?e.lastRotNoise=0:e.lastRotNoise=new ie,e.generatorIndex=[xr(0,100),xr(0,100),xr(0,100),xr(0,100)],this.positionAmount.startGen(e.memory),this.rotationAmount.startGen(e.memory),this.frequency.startGen(e.memory),this.power.startGen(e.memory)}update(e,t){let n=this.frequency.genValue(e.memory,e.age/e.life),i=this.power.genValue(e.memory,e.age/e.life),s=this.positionAmount.genValue(e.memory,e.age/e.life),a=this.rotationAmount.genValue(e.memory,e.age/e.life);s>0&&e.lastPosNoise!==void 0&&(e.position.sub(e.lastPosNoise),Js.set(Ut[e.generatorIndex[0]].noise2D(0,e.age*n)*i*s,Ut[e.generatorIndex[1]].noise2D(0,e.age*n)*i*s,Ut[e.generatorIndex[2]].noise2D(0,e.age*n)*i*s),e.position.add(Js),e.lastPosNoise.copy(Js)),a>0&&e.lastRotNoise!==void 0&&(typeof e.rotation=="number"?(e.rotation-=e.lastRotNoise,e.rotation+=Ut[e.generatorIndex[3]].noise2D(0,e.age*n)*Math.PI*i*a):(e.lastRotNoise.invert(),e.rotation.multiply(e.lastRotNoise),Gs.set(Ut[e.generatorIndex[0]].noise2D(0,e.age*n)*i*a,Ut[e.generatorIndex[1]].noise2D(0,e.age*n)*i*a,Ut[e.generatorIndex[2]].noise2D(0,e.age*n)*i*a,Ut[e.generatorIndex[3]].noise2D(0,e.age*n)*i*a).normalize(),e.rotation.multiply(Gs),e.lastRotNoise.copy(Gs)))}toJSON(){return{type:this.type,frequency:this.frequency.toJSON(),power:this.power.toJSON(),positionAmount:this.positionAmount.toJSON(),rotationAmount:this.rotationAmount.toJSON()}}frameUpdate(e){this.duration+=e}static fromJSON(e){return new Hi(Q(e.frequency),Q(e.power),Q(e.positionAmount),Q(e.rotationAmount))}clone(){return new Hi(this.frequency.clone(),this.power.clone(),this.positionAmount.clone(),this.rotationAmount.clone())}reset(){}}class qi{constructor(e,t){this.color=e,this.speedRange=t,this.type="ColorBySpeed"}initialize(e){this.color.startGen(e.memory)}update(e,t){const n=(e.startSpeed-this.speedRange.a)/(this.speedRange.b-this.speedRange.a);this.color.genColor(e.memory,e.color,n),e.color.x*=e.startColor.x,e.color.y*=e.startColor.y,e.color.z*=e.startColor.z,e.color.w*=e.startColor.w}frameUpdate(e){}toJSON(){return{type:this.type,color:this.color.toJSON(),speedRange:this.speedRange.toJSON()}}static fromJSON(e){return new qi(Fs(e.color),wn.fromJSON(e.speedRange))}clone(){return new qi(this.color.clone(),this.speedRange.clone())}reset(){}}class Xi{initialize(e){this.size.startGen(e.memory)}constructor(e,t){this.size=e,this.speedRange=t,this.type="SizeBySpeed"}update(e){const t=(e.startSpeed-this.speedRange.a)/(this.speedRange.b-this.speedRange.a);this.size instanceof _n?this.size.genValue(e.memory,e.size,t).multiply(e.startSize):e.size.copy(e.startSize).multiplyScalar(this.size.genValue(e.memory,t))}toJSON(){return{type:this.type,size:this.size.toJSON(),speedRange:this.speedRange.toJSON()}}static fromJSON(e){return new Xi(br(e.size),wn.fromJSON(e.speedRange))}frameUpdate(e){}clone(){return new Xi(this.size.clone(),this.speedRange.clone())}reset(){}}class Yi{constructor(e,t){this.angularVelocity=e,this.speedRange=t,this.type="RotationBySpeed",this.tempQuat=new ie}initialize(e){typeof e.rotation=="number"&&this.angularVelocity.startGen(e.memory)}update(e,t){if(typeof e.rotation=="number"){const n=(e.startSpeed-this.speedRange.a)/(this.speedRange.b-this.speedRange.a);e.rotation+=t*this.angularVelocity.genValue(e.memory,n)}}toJSON(){return{type:this.type,angularVelocity:this.angularVelocity.toJSON(),speedRange:this.speedRange.toJSON()}}static fromJSON(e){return new Yi(Q(e.angularVelocity),wn.fromJSON(e.speedRange))}frameUpdate(e){}clone(){return new Yi(this.angularVelocity.clone(),this.speedRange.clone())}reset(){}}class Zi{initialize(e){this.speed.startGen(e.memory)}constructor(e,t){this.speed=e,this.dampen=t,this.type="LimitSpeedOverLife"}update(e,t){let n=e.velocity.length(),i=this.speed.genValue(e.memory,e.age/e.life);if(n>i){const s=(n-i)/n;e.velocity.multiplyScalar(1-s*this.dampen*t*20)}}toJSON(){return{type:this.type,speed:this.speed.toJSON(),dampen:this.dampen}}static fromJSON(e){return new Zi(Q(e.speed),e.dampen)}frameUpdate(e){}clone(){return new Zi(this.speed.clone(),this.dampen)}reset(){}}const Mr={ApplyForce:{type:"ApplyForce",constructor:Vi,params:[["direction",["vec3"]],["magnitude",["value"]]],loadJSON:Vi.fromJSON},Noise:{type:"Noise",constructor:Hi,params:[["frequency",["value"]],["power",["value"]],["positionAmount",["value"]],["rotationAmount",["value"]]],loadJSON:Hi.fromJSON},TurbulenceField:{type:"TurbulenceField",constructor:Wi,params:[["scale",["vec3"]],["octaves",["number"]],["velocityMultiplier",["vec3"]],["timeScale",["vec3"]]],loadJSON:Wi.fromJSON},GravityForce:{type:"GravityForce",constructor:ji,params:[["center",["vec3"]],["magnitude",["number"]]],loadJSON:ji.fromJSON},ColorOverLife:{type:"ColorOverLife",constructor:Oi,params:[["color",["colorFunc"]]],loadJSON:Oi.fromJSON},RotationOverLife:{type:"RotationOverLife",constructor:Ii,params:[["angularVelocity",["value","valueFunc"]]],loadJSON:Ii.fromJSON},Rotation3DOverLife:{type:"Rotation3DOverLife",constructor:zi,params:[["angularVelocity",["rotationFunc"]]],loadJSON:zi.fromJSON},SizeOverLife:{type:"SizeOverLife",constructor:Ni,params:[["size",["value","valueFunc","vec3Func"]]],loadJSON:Ni.fromJSON},ColorBySpeed:{type:"ColorBySpeed",constructor:qi,params:[["color",["colorFunc"]],["speedRange",["range"]]],loadJSON:qi.fromJSON},RotationBySpeed:{type:"RotationBySpeed",constructor:Yi,params:[["angularVelocity",["value","valueFunc"]],["speedRange",["range"]]],loadJSON:Yi.fromJSON},SizeBySpeed:{type:"SizeBySpeed",constructor:Xi,params:[["size",["value","valueFunc","vec3Func"]],["speedRange",["range"]]],loadJSON:Xi.fromJSON},SpeedOverLife:{type:"SpeedOverLife",constructor:Ui,params:[["speed",["value","valueFunc"]]],loadJSON:Ui.fromJSON},FrameOverLife:{type:"FrameOverLife",constructor:Di,params:[["frame",["value","valueFunc"]]],loadJSON:Di.fromJSON},ForceOverLife:{type:"ForceOverLife",constructor:Bi,params:[["x",["value","valueFunc"]],["y",["value","valueFunc"]],["z",["value","valueFunc"]]],loadJSON:Bi.fromJSON},OrbitOverLife:{type:"OrbitOverLife",constructor:Li,params:[["orbitSpeed",["value","valueFunc"]],["axis",["vec3"]]],loadJSON:Li.fromJSON},WidthOverLength:{type:"WidthOverLength",constructor:Fi,params:[["width",["value","valueFunc"]]],loadJSON:Fi.fromJSON},ChangeEmitDirection:{type:"ChangeEmitDirection",constructor:Ji,params:[["angle",["value"]]],loadJSON:Ji.fromJSON},EmitSubParticleSystem:{type:"EmitSubParticleSystem",constructor:Gi,params:[["particleSystem",["self"]],["useVelocityAsBasis",["boolean"]],["subParticleSystem",["particleSystem"]],["mode",["number"]],["emitProbability",["number"]]],loadJSON:Gi.fromJSON},LimitSpeedOverLife:{type:"LimitSpeedOverLife",constructor:Zi,params:[["speed",["value","valueFunc"]],["dampen",["number"]]],loadJSON:Zi.fromJSON}};function Nh(r,e){return Mr[r.type]?Mr[r.type].loadJSON(r,e):null}const Uh=[];function Dh(r){if(!Uh.find(e=>e.id===r.id)){for(const e of r.emitterShapes)Vs[e.type]||(Vs[e.type]=e);for(const e of r.behaviors)Mr[e.type]||(Mr[e.type]=e)}}var Lh=`
|
|
84
84
|
#ifdef SOFT_PARTICLES
|
|
85
85
|
|
|
86
86
|
/* #ifdef LOGDEPTH
|
|
@@ -102,7 +102,7 @@ a=extmap-allow-mixed`)!==-1){const i=n.sdp.split(`
|
|
|
102
102
|
|
|
103
103
|
//gl_FragColor = vec4(softParticlesFade , 0, 0, 1);
|
|
104
104
|
#endif
|
|
105
|
-
`,
|
|
105
|
+
`,Fh=`
|
|
106
106
|
#ifdef SOFT_PARTICLES
|
|
107
107
|
|
|
108
108
|
uniform sampler2D depthTexture;
|
|
@@ -124,17 +124,17 @@ a=extmap-allow-mixed`)!==-1){const i=n.sdp.split(`
|
|
|
124
124
|
}
|
|
125
125
|
|
|
126
126
|
#endif
|
|
127
|
-
`,
|
|
127
|
+
`,Vh=`
|
|
128
128
|
#ifdef SOFT_PARTICLES
|
|
129
129
|
varying vec4 projPosition;
|
|
130
130
|
varying float linearDepth;
|
|
131
131
|
#endif
|
|
132
|
-
`,
|
|
132
|
+
`,jh=`
|
|
133
133
|
#ifdef SOFT_PARTICLES
|
|
134
134
|
projPosition = gl_Position;
|
|
135
135
|
linearDepth = -mvPosition.z;
|
|
136
136
|
#endif
|
|
137
|
-
`,
|
|
137
|
+
`,Jh=`
|
|
138
138
|
#ifdef USE_MAP
|
|
139
139
|
vec4 texelColor = texture2D( map, vUv);
|
|
140
140
|
#ifdef TILE_BLEND
|
|
@@ -142,7 +142,7 @@ a=extmap-allow-mixed`)!==-1){const i=n.sdp.split(`
|
|
|
142
142
|
#endif
|
|
143
143
|
diffuseColor *= texelColor;
|
|
144
144
|
#endif
|
|
145
|
-
`,
|
|
145
|
+
`,Gh=`
|
|
146
146
|
#if defined( USE_UV ) || defined( USE_ANISOTROPY )
|
|
147
147
|
|
|
148
148
|
varying vec2 vUv;
|
|
@@ -293,7 +293,7 @@ a=extmap-allow-mixed`)!==-1){const i=n.sdp.split(`
|
|
|
293
293
|
varying vec2 vThicknessMapUv;
|
|
294
294
|
|
|
295
295
|
#endif
|
|
296
|
-
`,
|
|
296
|
+
`,Wh=`
|
|
297
297
|
#ifdef UV_TILE
|
|
298
298
|
attribute float uvTile;
|
|
299
299
|
uniform vec2 tileCount;
|
|
@@ -463,7 +463,7 @@ a=extmap-allow-mixed`)!==-1){const i=n.sdp.split(`
|
|
|
463
463
|
varying vec2 vThicknessMapUv;
|
|
464
464
|
|
|
465
465
|
#endif
|
|
466
|
-
`,
|
|
466
|
+
`,Hh=`
|
|
467
467
|
#ifdef UV_TILE
|
|
468
468
|
mat3 tileTransform = makeTileTransform(floor(uvTile));
|
|
469
469
|
#ifdef TILE_BLEND
|
|
@@ -601,7 +601,7 @@ vThicknessMapUv = ( tileTransform * thicknessMapTransform * vec3( THICKNESSMAP_U
|
|
|
601
601
|
|
|
602
602
|
#endif
|
|
603
603
|
|
|
604
|
-
`;const en=Nl;function Hh(){en.tile_pars_vertex=Gh,en.tile_vertex=Wh,en.tile_pars_fragment=Jh,en.tile_fragment=jh,en.soft_pars_vertex=Fh,en.soft_vertex=Vh,en.soft_pars_fragment=Lh,en.soft_fragment=Dh}class qh extends Yo{constructor(e){super(),this.type="ParticleEmitter",this.system=e}clone(){const e=this.system.clone();return e.emitter.copy(this,!0),e.emitter}dispose(){}extractFromCache(e){const t=[];for(const n in e){const i=e[n];delete i.metadata,t.push(i)}return t}toJSON(e,t={}){const n=this.children;this.children=this.children.filter(s=>s.type!=="ParticleSystemPreview");const i=super.toJSON(e);return this.children=n,this.system!==null&&(i.object.ps=this.system.toJSON(e,t)),i}}var V;(function(r){r[r.BillBoard=0]="BillBoard",r[r.StretchedBillBoard=1]="StretchedBillBoard",r[r.Mesh=2]="Mesh",r[r.Trail=3]="Trail",r[r.HorizontalBillBoard=4]="HorizontalBillBoard",r[r.VerticalBillBoard=5]="VerticalBillBoard"})(V||(V={}));class Fc extends fs{constructor(e){super(),this.type="VFXBatch",this.maxParticles=1e3,this.systems=new Set;const t=new sr;t.mask=e.layers.mask;const n=e.material.clone();n.defines={},Object.assign(n.defines,e.material.defines),this.settings={instancingGeometry:e.instancingGeometry,renderMode:e.renderMode,renderOrder:e.renderOrder,material:n,uTileCount:e.uTileCount,vTileCount:e.vTileCount,blendTiles:e.blendTiles,softParticles:e.softParticles,softNearFade:e.softNearFade,softFarFade:e.softFarFade,layers:t},this.frustumCulled=!1,this.renderOrder=this.settings.renderOrder}addSystem(e){this.systems.add(e)}removeSystem(e){this.systems.delete(e)}applyDepthTexture(e){const t=this.material.uniforms.depthTexture;t&&t.value!==e&&(t.value=e,this.material.needsUpdate=!0)}}const Xh=new G(0,0,1),Ws=new ie,Yh=new G,Zh=new G;new G;const Vc=60,Kh=new Xo(1,1,1,1);class Qr{set time(e){this.emissionState.time=e}get time(){return this.emissionState.time}get layers(){return this.rendererSettings.layers}get texture(){return this.rendererSettings.material.map}set texture(e){this.rendererSettings.material.map=e,this.neededToUpdateRender=!0}get material(){return this.rendererSettings.material}set material(e){this.rendererSettings.material=e,this.neededToUpdateRender=!0}get uTileCount(){return this.rendererSettings.uTileCount}set uTileCount(e){this.rendererSettings.uTileCount=e,this.neededToUpdateRender=!0}get vTileCount(){return this.rendererSettings.vTileCount}set vTileCount(e){this.rendererSettings.vTileCount=e,this.neededToUpdateRender=!0}get blendTiles(){return this.rendererSettings.blendTiles}set blendTiles(e){this.rendererSettings.blendTiles=e,this.neededToUpdateRender=!0}get softParticles(){return this.rendererSettings.softParticles}set softParticles(e){this.rendererSettings.softParticles=e,this.neededToUpdateRender=!0}get softNearFade(){return this.rendererSettings.softNearFade}set softNearFade(e){this.rendererSettings.softNearFade=e,this.neededToUpdateRender=!0}get softFarFade(){return this.rendererSettings.softFarFade}set softFarFade(e){this.rendererSettings.softFarFade=e,this.neededToUpdateRender=!0}get instancingGeometry(){return this.rendererSettings.instancingGeometry}set instancingGeometry(e){this.restart(),this.particles.length=0,this.rendererSettings.instancingGeometry=e,this.neededToUpdateRender=!0}get renderMode(){return this.rendererSettings.renderMode}set renderMode(e){if((this.rendererSettings.renderMode!=V.Trail&&e===V.Trail||this.rendererSettings.renderMode==V.Trail&&e!==V.Trail)&&(this.restart(),this.particles.length=0),this.rendererSettings.renderMode!==e)switch(e){case V.Trail:this.rendererEmitterSettings={startLength:new ne(30),followLocalOrigin:!1};break;case V.Mesh:this.rendererEmitterSettings={geometry:new Xo(1,1)},this.startRotation=new Mi(new G(0,1,0),new ne(0));break;case V.StretchedBillBoard:this.rendererEmitterSettings={speedFactor:0,lengthFactor:2},this.rendererSettings.renderMode===V.Mesh&&(this.startRotation=new ne(0));break;case V.BillBoard:case V.VerticalBillBoard:case V.HorizontalBillBoard:this.rendererEmitterSettings={},this.rendererSettings.renderMode===V.Mesh&&(this.startRotation=new ne(0));break}this.rendererSettings.renderMode=e,this.neededToUpdateRender=!0}get renderOrder(){return this.rendererSettings.renderOrder}set renderOrder(e){this.rendererSettings.renderOrder=e,this.neededToUpdateRender=!0}get blending(){return this.rendererSettings.material.blending}set blending(e){this.rendererSettings.material.blending=e,this.neededToUpdateRender=!0}constructor(e){var t,n,i,s,a,o,c,l,u,p,f,m,b,x,g,v,_,w,C,M,E,P,O,R,A,B;if(this.temp=new G,this.travelDistance=0,this.normalMatrix=new Dt,this.memory=[],this.listeners={},this.firstTimeUpdate=!0,this.autoDestroy=e.autoDestroy===void 0?!1:e.autoDestroy,this.duration=(t=e.duration)!==null&&t!==void 0?t:1,this.looping=e.looping===void 0?!0:e.looping,this.prewarm=e.prewarm===void 0?!1:e.prewarm,this.startLife=(n=e.startLife)!==null&&n!==void 0?n:new ne(5),this.startSpeed=(i=e.startSpeed)!==null&&i!==void 0?i:new ne(0),this.startRotation=(s=e.startRotation)!==null&&s!==void 0?s:new ne(0),this.startSize=(a=e.startSize)!==null&&a!==void 0?a:new ne(1),this.startColor=(o=e.startColor)!==null&&o!==void 0?o:new xn(new tt(1,1,1,1)),this.emissionOverTime=(c=e.emissionOverTime)!==null&&c!==void 0?c:new ne(10),this.emissionOverDistance=(l=e.emissionOverDistance)!==null&&l!==void 0?l:new ne(0),this.emissionBursts=(u=e.emissionBursts)!==null&&u!==void 0?u:[],this.onlyUsedByOther=(p=e.onlyUsedByOther)!==null&&p!==void 0?p:!1,this.emitterShape=(f=e.shape)!==null&&f!==void 0?f:new Wn,this.behaviors=(m=e.behaviors)!==null&&m!==void 0?m:new Array,this.worldSpace=(b=e.worldSpace)!==null&&b!==void 0?b:!1,this.rendererEmitterSettings=(x=e.rendererEmitterSettings)!==null&&x!==void 0?x:{},e.renderMode===V.StretchedBillBoard){const z=this.rendererEmitterSettings;e.speedFactor!==void 0&&(z.speedFactor=e.speedFactor),z.speedFactor=(g=z.speedFactor)!==null&&g!==void 0?g:0,z.lengthFactor=(v=z.lengthFactor)!==null&&v!==void 0?v:0}this.rendererSettings={instancingGeometry:(_=e.instancingGeometry)!==null&&_!==void 0?_:Kh,renderMode:(w=e.renderMode)!==null&&w!==void 0?w:V.BillBoard,renderOrder:(C=e.renderOrder)!==null&&C!==void 0?C:0,material:e.material,uTileCount:(M=e.uTileCount)!==null&&M!==void 0?M:1,vTileCount:(E=e.vTileCount)!==null&&E!==void 0?E:1,blendTiles:(P=e.blendTiles)!==null&&P!==void 0?P:!1,softParticles:(O=e.softParticles)!==null&&O!==void 0?O:!1,softNearFade:(R=e.softNearFade)!==null&&R!==void 0?R:0,softFarFade:(A=e.softFarFade)!==null&&A!==void 0?A:0,layers:(B=e.layers)!==null&&B!==void 0?B:new sr},this.neededToUpdateRender=!0,this.particles=new Array,this.startTileIndex=e.startTileIndex||new ne(0),this.emitter=new qh(this),this.paused=!1,this.particleNum=0,this.emissionState={isBursting:!1,burstParticleIndex:0,burstParticleCount:0,burstIndex:0,burstWaveIndex:0,time:0,waitEmiting:0,travelDistance:0},this.emissionBursts.forEach(z=>z.count.startGen(this.memory)),this.emissionOverDistance.startGen(this.memory),this.emitEnded=!1,this.markForDestroy=!1,this.prewarmed=!1}pause(){this.paused=!0}play(){this.paused=!1}stop(){this.restart(),this.pause()}spawn(e,t,n){Ws.setFromRotationMatrix(n);const i=Yh,s=Ws,a=Zh;n.decompose(i,s,a);for(let o=0;o<e;o++){for(t.burstParticleIndex=o,this.particleNum++;this.particles.length<this.particleNum;)this.rendererSettings.renderMode===V.Trail?this.particles.push(new Tr):this.particles.push(new Eh);const c=this.particles[this.particleNum-1];if(c.reset(),c.speedModifier=1,this.startColor.startGen(c.memory),this.startColor.genColor(c.memory,c.startColor,this.emissionState.time),c.color.copy(c.startColor),this.startSpeed.startGen(c.memory),c.startSpeed=this.startSpeed.genValue(c.memory,t.time/this.duration),this.startLife.startGen(c.memory),c.life=this.startLife.genValue(c.memory,t.time/this.duration),c.age=0,this.startSize.startGen(c.memory),this.startSize.type==="vec3function")this.startSize.genValue(c.memory,c.startSize,t.time/this.duration);else{const l=this.startSize.genValue(c.memory,t.time/this.duration);c.startSize.set(l,l,l)}if(this.startTileIndex.startGen(c.memory),c.uvTile=this.startTileIndex.genValue(c.memory),c.size.copy(c.startSize),this.rendererSettings.renderMode===V.Mesh||this.rendererSettings.renderMode===V.BillBoard||this.rendererSettings.renderMode===V.VerticalBillBoard||this.rendererSettings.renderMode===V.HorizontalBillBoard||this.rendererSettings.renderMode===V.StretchedBillBoard){const l=c;this.startRotation.startGen(c.memory),this.rendererSettings.renderMode===V.Mesh?(l.rotation instanceof ie||(l.rotation=new ie),this.startRotation.type==="rotation"?this.startRotation.genValue(c.memory,l.rotation,1,t.time/this.duration):l.rotation.setFromAxisAngle(Xh,this.startRotation.genValue(l.memory,t.time/this.duration))):this.startRotation.type==="rotation"?l.rotation=0:l.rotation=this.startRotation.genValue(l.memory,t.time/this.duration)}else if(this.rendererSettings.renderMode===V.Trail){const l=c;this.rendererEmitterSettings.startLength.startGen(l.memory),l.length=this.rendererEmitterSettings.startLength.genValue(l.memory,t.time/this.duration)}if(this.emitterShape.initialize(c,t),this.rendererSettings.renderMode===V.Trail&&this.rendererEmitterSettings.followLocalOrigin){const l=c;l.localPosition=new G().copy(l.position)}this.worldSpace?(c.position.applyMatrix4(n),c.startSize.multiply(a).abs(),c.size.copy(c.startSize),c.velocity.multiply(a).applyMatrix3(this.normalMatrix),c.rotation&&c.rotation instanceof ie&&c.rotation.multiplyQuaternions(Ws,c.rotation)):this.onlyUsedByOther&&(c.parentMatrix=n);for(let l=0;l<this.behaviors.length;l++)this.behaviors[l].initialize(c,this)}}endEmit(){this.emitEnded=!0,this.autoDestroy&&(this.markForDestroy=!0),this.fire({type:"emitEnd",particleSystem:this})}dispose(){this._renderer&&this._renderer.deleteSystem(this),this.emitter.dispose(),this.emitter.parent&&this.emitter.parent.remove(this.emitter),this.fire({type:"destroy",particleSystem:this})}restart(){this.memory.length=0,this.paused=!1,this.particleNum=0,this.emissionState.isBursting=!1,this.emissionState.burstIndex=0,this.emissionState.burstWaveIndex=0,this.emissionState.time=0,this.emissionState.waitEmiting=0,this.behaviors.forEach(e=>{e.reset()}),this.emitEnded=!1,this.markForDestroy=!1,this.prewarmed=!1,this.emissionBursts.forEach(e=>e.count.startGen(this.memory)),this.emissionOverDistance.startGen(this.memory)}update(e){if(this.paused)return;let t=this.emitter;for(;t.parent;)t=t.parent;if(t.type!=="Scene"){this.dispose();return}if(this.firstTimeUpdate&&(this.firstTimeUpdate=!1,this.emitter.updateWorldMatrix(!0,!1)),this.emitEnded&&this.particleNum===0){this.markForDestroy&&this.emitter.parent&&this.dispose();return}if(this.looping&&this.prewarm&&!this.prewarmed){this.prewarmed=!0;for(let n=0;n<this.duration*Vc;n++)this.update(1/Vc)}e>.1&&(e=.1),this.neededToUpdateRender&&(this._renderer&&this._renderer.updateSystem(this),this.neededToUpdateRender=!1),this.onlyUsedByOther||this.emit(e,this.emissionState,this.emitter.matrixWorld),this.emitterShape.update(this,e);for(let n=0;n<this.behaviors.length;n++){this.behaviors[n].frameUpdate(e);for(let i=0;i<this.particleNum;i++)this.particles[i].died||this.behaviors[n].update(this.particles[i],e)}for(let n=0;n<this.particleNum;n++)this.rendererEmitterSettings.followLocalOrigin&&this.particles[n].localPosition?(this.particles[n].position.copy(this.particles[n].localPosition),this.particles[n].parentMatrix?this.particles[n].position.applyMatrix4(this.particles[n].parentMatrix):this.particles[n].position.applyMatrix4(this.emitter.matrixWorld)):this.particles[n].position.addScaledVector(this.particles[n].velocity,e*this.particles[n].speedModifier),this.particles[n].age+=e;if(this.rendererSettings.renderMode===V.Trail)for(let n=0;n<this.particleNum;n++)this.particles[n].update();for(let n=0;n<this.particleNum;n++){const i=this.particles[n];i.died&&(!(i instanceof Tr)||i.previous.length===0)&&(this.particles[n]=this.particles[this.particleNum-1],this.particles[this.particleNum-1]=i,this.particleNum--,n--,this.fire({type:"particleDied",particleSystem:this,particle:i}))}}emit(e,t,n){t.time>this.duration&&(this.looping?(t.time-=this.duration,t.burstIndex=0,this.behaviors.forEach(s=>{s.reset()})):!this.emitEnded&&!this.onlyUsedByOther&&this.endEmit()),this.normalMatrix.getNormalMatrix(n);const i=Math.ceil(t.waitEmiting);for(this.spawn(i,t,n),t.waitEmiting-=i;t.burstIndex<this.emissionBursts.length&&this.emissionBursts[t.burstIndex].time<=t.time;){if(Math.random()<this.emissionBursts[t.burstIndex].probability){const s=this.emissionBursts[t.burstIndex].count.genValue(this.memory,this.time);t.isBursting=!0,t.burstParticleCount=s,this.spawn(s,t,n),t.isBursting=!1}t.burstIndex++}if(!this.emitEnded&&(t.waitEmiting+=e*this.emissionOverTime.genValue(this.memory,t.time/this.duration),t.previousWorldPos!=null)){this.temp.set(n.elements[12],n.elements[13],n.elements[14]),t.travelDistance+=t.previousWorldPos.distanceTo(this.temp);const s=this.emissionOverDistance.genValue(this.memory,t.time/this.duration);if(t.travelDistance*s>0){const a=Math.floor(t.travelDistance*s);t.travelDistance-=a/s,t.waitEmiting+=a}}t.previousWorldPos===void 0&&(t.previousWorldPos=new G),t.previousWorldPos.set(n.elements[12],n.elements[13],n.elements[14]),t.time+=e}toJSON(e,t={}){var n;if((e===void 0||typeof e=="string")&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}}),e.materials[this.rendererSettings.material.uuid]=this.rendererSettings.material.toJSON(e),t.useUrlForImage&&((n=this.texture)===null||n===void 0?void 0:n.source)!==void 0){const a=this.texture.source;e.images[a.uuid]={uuid:a.uuid,url:this.texture.image.url}}let i;this.renderMode===V.Trail?i={startLength:this.rendererEmitterSettings.startLength.toJSON(),followLocalOrigin:this.rendererEmitterSettings.followLocalOrigin}:this.renderMode===V.Mesh?i={}:this.renderMode===V.StretchedBillBoard?i={speedFactor:this.rendererEmitterSettings.speedFactor,lengthFactor:this.rendererEmitterSettings.lengthFactor}:i={};const s=this.rendererSettings.instancingGeometry;return e.geometries&&!e.geometries[s.uuid]&&(e.geometries[s.uuid]=s.toJSON()),{version:"3.0",autoDestroy:this.autoDestroy,looping:this.looping,prewarm:this.prewarm,duration:this.duration,shape:this.emitterShape.toJSON(),startLife:this.startLife.toJSON(),startSpeed:this.startSpeed.toJSON(),startRotation:this.startRotation.toJSON(),startSize:this.startSize.toJSON(),startColor:this.startColor.toJSON(),emissionOverTime:this.emissionOverTime.toJSON(),emissionOverDistance:this.emissionOverDistance.toJSON(),emissionBursts:this.emissionBursts.map(a=>({time:a.time,count:a.count.toJSON(),probability:a.probability,interval:a.interval,cycle:a.cycle})),onlyUsedByOther:this.onlyUsedByOther,instancingGeometry:this.rendererSettings.instancingGeometry.uuid,renderOrder:this.renderOrder,renderMode:this.renderMode,rendererEmitterSettings:i,material:this.rendererSettings.material.uuid,layers:this.layers.mask,startTileIndex:this.startTileIndex.toJSON(),uTileCount:this.uTileCount,vTileCount:this.vTileCount,blendTiles:this.blendTiles,softParticles:this.rendererSettings.softParticles,softFarFade:this.rendererSettings.softFarFade,softNearFade:this.rendererSettings.softNearFade,behaviors:this.behaviors.map(a=>a.toJSON()),worldSpace:this.worldSpace}}static fromJSON(e,t,n){var i,s;const a=Mh(e.shape,t);let o;if(e.renderMode===V.Trail){const u=e.rendererEmitterSettings;o={startLength:u.startLength!=null?Q(u.startLength):new ne(30),followLocalOrigin:u.followLocalOrigin}}else e.renderMode===V.Mesh?o={}:e.renderMode===V.StretchedBillBoard?(o=e.rendererEmitterSettings,e.speedFactor!=null&&(o.speedFactor=e.speedFactor)):o={};const c=new sr;e.layers&&(c.mask=e.layers);const l=new Qr({autoDestroy:e.autoDestroy,looping:e.looping,prewarm:e.prewarm,duration:e.duration,shape:a,startLife:Q(e.startLife),startSpeed:Q(e.startSpeed),startRotation:br(e.startRotation),startSize:br(e.startSize),startColor:Fs(e.startColor),emissionOverTime:Q(e.emissionOverTime),emissionOverDistance:Q(e.emissionOverDistance),emissionBursts:(i=e.emissionBursts)===null||i===void 0?void 0:i.map(u=>{var p,f,m;return{time:u.time,count:typeof u.count=="number"?new ne(u.count):Q(u.count),probability:(p=u.probability)!==null&&p!==void 0?p:1,interval:(f=u.interval)!==null&&f!==void 0?f:.1,cycle:(m=u.cycle)!==null&&m!==void 0?m:1}}),onlyUsedByOther:e.onlyUsedByOther,instancingGeometry:t.geometries[e.instancingGeometry],renderMode:e.renderMode,rendererEmitterSettings:o,renderOrder:e.renderOrder,layers:c,material:e.material?t.materials[e.material]:e.texture?new Zo({map:t.textures[e.texture],transparent:(s=e.transparent)!==null&&s!==void 0?s:!0,blending:e.blending,side:ds}):new Zo({color:16777215,transparent:!0,blending:Ko,side:ds}),startTileIndex:typeof e.startTileIndex=="number"?new ne(e.startTileIndex):Q(e.startTileIndex),uTileCount:e.uTileCount,vTileCount:e.vTileCount,blendTiles:e.blendTiles,softParticles:e.softParticles,softFarFade:e.softFarFade,softNearFade:e.softNearFade,behaviors:[],worldSpace:e.worldSpace});return l.behaviors=e.behaviors.map(u=>{const p=Bh(u,l);return p.type==="EmitSubParticleSystem"&&(n[u.subParticleSystem]=p),p}),l}addBehavior(e){this.behaviors.push(e)}getRendererSettings(){return this.rendererSettings}addEventListener(e,t){this.listeners[e]||(this.listeners[e]=[]),this.listeners[e].push(t)}removeAllEventListeners(e){this.listeners[e]&&(this.listeners[e]=[])}removeEventListener(e,t){if(this.listeners[e]){const n=this.listeners[e].indexOf(t);n!==-1&&this.listeners[e].splice(n,1)}}fire(e){this.listeners[e.type]&&this.listeners[e.type].forEach(t=>t(e))}clone(){const e=[];for(const s of this.emissionBursts){const a={};Object.assign(a,s),e.push(a)}const t=[];for(const s of this.behaviors)t.push(s.clone());let n;this.renderMode===V.Trail?n={startLength:this.rendererEmitterSettings.startLength.clone(),followLocalOrigin:this.rendererEmitterSettings.followLocalOrigin}:this.renderMode===V.StretchedBillBoard?n={lengthFactor:this.rendererEmitterSettings.lengthFactor,speedFactor:this.rendererEmitterSettings.speedFactor}:n={};const i=new sr;return i.mask=this.layers.mask,new Qr({autoDestroy:this.autoDestroy,looping:this.looping,duration:this.duration,shape:this.emitterShape.clone(),startLife:this.startLife.clone(),startSpeed:this.startSpeed.clone(),startRotation:this.startRotation.clone(),startSize:this.startSize.clone(),startColor:this.startColor.clone(),emissionOverTime:this.emissionOverTime.clone(),emissionOverDistance:this.emissionOverDistance.clone(),emissionBursts:e,onlyUsedByOther:this.onlyUsedByOther,instancingGeometry:this.rendererSettings.instancingGeometry,renderMode:this.renderMode,renderOrder:this.renderOrder,rendererEmitterSettings:n,material:this.rendererSettings.material,startTileIndex:this.startTileIndex,uTileCount:this.uTileCount,vTileCount:this.vTileCount,blendTiles:this.blendTiles,softParticles:this.softParticles,softFarFade:this.softFarFade,softNearFade:this.softNearFade,behaviors:t,worldSpace:this.worldSpace,layers:i})}}var Hs=`
|
|
604
|
+
`;const en=Nl;function qh(){en.tile_pars_vertex=Wh,en.tile_vertex=Hh,en.tile_pars_fragment=Gh,en.tile_fragment=Jh,en.soft_pars_vertex=Vh,en.soft_vertex=jh,en.soft_pars_fragment=Fh,en.soft_fragment=Lh}class Xh extends Yo{constructor(e){super(),this.type="ParticleEmitter",this.system=e}clone(){const e=this.system.clone();return e.emitter.copy(this,!0),e.emitter}dispose(){}extractFromCache(e){const t=[];for(const n in e){const i=e[n];delete i.metadata,t.push(i)}return t}toJSON(e,t={}){const n=this.children;this.children=this.children.filter(s=>s.type!=="ParticleSystemPreview");const i=super.toJSON(e);return this.children=n,this.system!==null&&(i.object.ps=this.system.toJSON(e,t)),i}}var V;(function(r){r[r.BillBoard=0]="BillBoard",r[r.StretchedBillBoard=1]="StretchedBillBoard",r[r.Mesh=2]="Mesh",r[r.Trail=3]="Trail",r[r.HorizontalBillBoard=4]="HorizontalBillBoard",r[r.VerticalBillBoard=5]="VerticalBillBoard"})(V||(V={}));class Fc extends fs{constructor(e){super(),this.type="VFXBatch",this.maxParticles=1e3,this.systems=new Set;const t=new sr;t.mask=e.layers.mask;const n=e.material.clone();n.defines={},Object.assign(n.defines,e.material.defines),this.settings={instancingGeometry:e.instancingGeometry,renderMode:e.renderMode,renderOrder:e.renderOrder,material:n,uTileCount:e.uTileCount,vTileCount:e.vTileCount,blendTiles:e.blendTiles,softParticles:e.softParticles,softNearFade:e.softNearFade,softFarFade:e.softFarFade,layers:t},this.frustumCulled=!1,this.renderOrder=this.settings.renderOrder}addSystem(e){this.systems.add(e)}removeSystem(e){this.systems.delete(e)}applyDepthTexture(e){const t=this.material.uniforms.depthTexture;t&&t.value!==e&&(t.value=e,this.material.needsUpdate=!0)}}const Yh=new G(0,0,1),Ws=new ie,Zh=new G,Kh=new G;new G;const Vc=60,Qh=new Xo(1,1,1,1);class Qr{set time(e){this.emissionState.time=e}get time(){return this.emissionState.time}get layers(){return this.rendererSettings.layers}get texture(){return this.rendererSettings.material.map}set texture(e){this.rendererSettings.material.map=e,this.neededToUpdateRender=!0}get material(){return this.rendererSettings.material}set material(e){this.rendererSettings.material=e,this.neededToUpdateRender=!0}get uTileCount(){return this.rendererSettings.uTileCount}set uTileCount(e){this.rendererSettings.uTileCount=e,this.neededToUpdateRender=!0}get vTileCount(){return this.rendererSettings.vTileCount}set vTileCount(e){this.rendererSettings.vTileCount=e,this.neededToUpdateRender=!0}get blendTiles(){return this.rendererSettings.blendTiles}set blendTiles(e){this.rendererSettings.blendTiles=e,this.neededToUpdateRender=!0}get softParticles(){return this.rendererSettings.softParticles}set softParticles(e){this.rendererSettings.softParticles=e,this.neededToUpdateRender=!0}get softNearFade(){return this.rendererSettings.softNearFade}set softNearFade(e){this.rendererSettings.softNearFade=e,this.neededToUpdateRender=!0}get softFarFade(){return this.rendererSettings.softFarFade}set softFarFade(e){this.rendererSettings.softFarFade=e,this.neededToUpdateRender=!0}get instancingGeometry(){return this.rendererSettings.instancingGeometry}set instancingGeometry(e){this.restart(),this.particles.length=0,this.rendererSettings.instancingGeometry=e,this.neededToUpdateRender=!0}get renderMode(){return this.rendererSettings.renderMode}set renderMode(e){if((this.rendererSettings.renderMode!=V.Trail&&e===V.Trail||this.rendererSettings.renderMode==V.Trail&&e!==V.Trail)&&(this.restart(),this.particles.length=0),this.rendererSettings.renderMode!==e)switch(e){case V.Trail:this.rendererEmitterSettings={startLength:new ne(30),followLocalOrigin:!1};break;case V.Mesh:this.rendererEmitterSettings={geometry:new Xo(1,1)},this.startRotation=new Mi(new G(0,1,0),new ne(0));break;case V.StretchedBillBoard:this.rendererEmitterSettings={speedFactor:0,lengthFactor:2},this.rendererSettings.renderMode===V.Mesh&&(this.startRotation=new ne(0));break;case V.BillBoard:case V.VerticalBillBoard:case V.HorizontalBillBoard:this.rendererEmitterSettings={},this.rendererSettings.renderMode===V.Mesh&&(this.startRotation=new ne(0));break}this.rendererSettings.renderMode=e,this.neededToUpdateRender=!0}get renderOrder(){return this.rendererSettings.renderOrder}set renderOrder(e){this.rendererSettings.renderOrder=e,this.neededToUpdateRender=!0}get blending(){return this.rendererSettings.material.blending}set blending(e){this.rendererSettings.material.blending=e,this.neededToUpdateRender=!0}constructor(e){var t,n,i,s,a,o,c,l,u,p,f,m,b,x,g,v,_,w,C,M,E,P,O,R,A,B;if(this.temp=new G,this.travelDistance=0,this.normalMatrix=new Dt,this.memory=[],this.listeners={},this.firstTimeUpdate=!0,this.autoDestroy=e.autoDestroy===void 0?!1:e.autoDestroy,this.duration=(t=e.duration)!==null&&t!==void 0?t:1,this.looping=e.looping===void 0?!0:e.looping,this.prewarm=e.prewarm===void 0?!1:e.prewarm,this.startLife=(n=e.startLife)!==null&&n!==void 0?n:new ne(5),this.startSpeed=(i=e.startSpeed)!==null&&i!==void 0?i:new ne(0),this.startRotation=(s=e.startRotation)!==null&&s!==void 0?s:new ne(0),this.startSize=(a=e.startSize)!==null&&a!==void 0?a:new ne(1),this.startColor=(o=e.startColor)!==null&&o!==void 0?o:new xn(new tt(1,1,1,1)),this.emissionOverTime=(c=e.emissionOverTime)!==null&&c!==void 0?c:new ne(10),this.emissionOverDistance=(l=e.emissionOverDistance)!==null&&l!==void 0?l:new ne(0),this.emissionBursts=(u=e.emissionBursts)!==null&&u!==void 0?u:[],this.onlyUsedByOther=(p=e.onlyUsedByOther)!==null&&p!==void 0?p:!1,this.emitterShape=(f=e.shape)!==null&&f!==void 0?f:new Wn,this.behaviors=(m=e.behaviors)!==null&&m!==void 0?m:new Array,this.worldSpace=(b=e.worldSpace)!==null&&b!==void 0?b:!1,this.rendererEmitterSettings=(x=e.rendererEmitterSettings)!==null&&x!==void 0?x:{},e.renderMode===V.StretchedBillBoard){const z=this.rendererEmitterSettings;e.speedFactor!==void 0&&(z.speedFactor=e.speedFactor),z.speedFactor=(g=z.speedFactor)!==null&&g!==void 0?g:0,z.lengthFactor=(v=z.lengthFactor)!==null&&v!==void 0?v:0}this.rendererSettings={instancingGeometry:(_=e.instancingGeometry)!==null&&_!==void 0?_:Qh,renderMode:(w=e.renderMode)!==null&&w!==void 0?w:V.BillBoard,renderOrder:(C=e.renderOrder)!==null&&C!==void 0?C:0,material:e.material,uTileCount:(M=e.uTileCount)!==null&&M!==void 0?M:1,vTileCount:(E=e.vTileCount)!==null&&E!==void 0?E:1,blendTiles:(P=e.blendTiles)!==null&&P!==void 0?P:!1,softParticles:(O=e.softParticles)!==null&&O!==void 0?O:!1,softNearFade:(R=e.softNearFade)!==null&&R!==void 0?R:0,softFarFade:(A=e.softFarFade)!==null&&A!==void 0?A:0,layers:(B=e.layers)!==null&&B!==void 0?B:new sr},this.neededToUpdateRender=!0,this.particles=new Array,this.startTileIndex=e.startTileIndex||new ne(0),this.emitter=new Xh(this),this.paused=!1,this.particleNum=0,this.emissionState={isBursting:!1,burstParticleIndex:0,burstParticleCount:0,burstIndex:0,burstWaveIndex:0,time:0,waitEmiting:0,travelDistance:0},this.emissionBursts.forEach(z=>z.count.startGen(this.memory)),this.emissionOverDistance.startGen(this.memory),this.emitEnded=!1,this.markForDestroy=!1,this.prewarmed=!1}pause(){this.paused=!0}play(){this.paused=!1}stop(){this.restart(),this.pause()}spawn(e,t,n){Ws.setFromRotationMatrix(n);const i=Zh,s=Ws,a=Kh;n.decompose(i,s,a);for(let o=0;o<e;o++){for(t.burstParticleIndex=o,this.particleNum++;this.particles.length<this.particleNum;)this.rendererSettings.renderMode===V.Trail?this.particles.push(new Tr):this.particles.push(new Ph);const c=this.particles[this.particleNum-1];if(c.reset(),c.speedModifier=1,this.startColor.startGen(c.memory),this.startColor.genColor(c.memory,c.startColor,this.emissionState.time),c.color.copy(c.startColor),this.startSpeed.startGen(c.memory),c.startSpeed=this.startSpeed.genValue(c.memory,t.time/this.duration),this.startLife.startGen(c.memory),c.life=this.startLife.genValue(c.memory,t.time/this.duration),c.age=0,this.startSize.startGen(c.memory),this.startSize.type==="vec3function")this.startSize.genValue(c.memory,c.startSize,t.time/this.duration);else{const l=this.startSize.genValue(c.memory,t.time/this.duration);c.startSize.set(l,l,l)}if(this.startTileIndex.startGen(c.memory),c.uvTile=this.startTileIndex.genValue(c.memory),c.size.copy(c.startSize),this.rendererSettings.renderMode===V.Mesh||this.rendererSettings.renderMode===V.BillBoard||this.rendererSettings.renderMode===V.VerticalBillBoard||this.rendererSettings.renderMode===V.HorizontalBillBoard||this.rendererSettings.renderMode===V.StretchedBillBoard){const l=c;this.startRotation.startGen(c.memory),this.rendererSettings.renderMode===V.Mesh?(l.rotation instanceof ie||(l.rotation=new ie),this.startRotation.type==="rotation"?this.startRotation.genValue(c.memory,l.rotation,1,t.time/this.duration):l.rotation.setFromAxisAngle(Yh,this.startRotation.genValue(l.memory,t.time/this.duration))):this.startRotation.type==="rotation"?l.rotation=0:l.rotation=this.startRotation.genValue(l.memory,t.time/this.duration)}else if(this.rendererSettings.renderMode===V.Trail){const l=c;this.rendererEmitterSettings.startLength.startGen(l.memory),l.length=this.rendererEmitterSettings.startLength.genValue(l.memory,t.time/this.duration)}if(this.emitterShape.initialize(c,t),this.rendererSettings.renderMode===V.Trail&&this.rendererEmitterSettings.followLocalOrigin){const l=c;l.localPosition=new G().copy(l.position)}this.worldSpace?(c.position.applyMatrix4(n),c.startSize.multiply(a).abs(),c.size.copy(c.startSize),c.velocity.multiply(a).applyMatrix3(this.normalMatrix),c.rotation&&c.rotation instanceof ie&&c.rotation.multiplyQuaternions(Ws,c.rotation)):this.onlyUsedByOther&&(c.parentMatrix=n);for(let l=0;l<this.behaviors.length;l++)this.behaviors[l].initialize(c,this)}}endEmit(){this.emitEnded=!0,this.autoDestroy&&(this.markForDestroy=!0),this.fire({type:"emitEnd",particleSystem:this})}dispose(){this._renderer&&this._renderer.deleteSystem(this),this.emitter.dispose(),this.emitter.parent&&this.emitter.parent.remove(this.emitter),this.fire({type:"destroy",particleSystem:this})}restart(){this.memory.length=0,this.paused=!1,this.particleNum=0,this.emissionState.isBursting=!1,this.emissionState.burstIndex=0,this.emissionState.burstWaveIndex=0,this.emissionState.time=0,this.emissionState.waitEmiting=0,this.behaviors.forEach(e=>{e.reset()}),this.emitEnded=!1,this.markForDestroy=!1,this.prewarmed=!1,this.emissionBursts.forEach(e=>e.count.startGen(this.memory)),this.emissionOverDistance.startGen(this.memory)}update(e){if(this.paused)return;let t=this.emitter;for(;t.parent;)t=t.parent;if(t.type!=="Scene"){this.dispose();return}if(this.firstTimeUpdate&&(this.firstTimeUpdate=!1,this.emitter.updateWorldMatrix(!0,!1)),this.emitEnded&&this.particleNum===0){this.markForDestroy&&this.emitter.parent&&this.dispose();return}if(this.looping&&this.prewarm&&!this.prewarmed){this.prewarmed=!0;for(let n=0;n<this.duration*Vc;n++)this.update(1/Vc)}e>.1&&(e=.1),this.neededToUpdateRender&&(this._renderer&&this._renderer.updateSystem(this),this.neededToUpdateRender=!1),this.onlyUsedByOther||this.emit(e,this.emissionState,this.emitter.matrixWorld),this.emitterShape.update(this,e);for(let n=0;n<this.behaviors.length;n++){this.behaviors[n].frameUpdate(e);for(let i=0;i<this.particleNum;i++)this.particles[i].died||this.behaviors[n].update(this.particles[i],e)}for(let n=0;n<this.particleNum;n++)this.rendererEmitterSettings.followLocalOrigin&&this.particles[n].localPosition?(this.particles[n].position.copy(this.particles[n].localPosition),this.particles[n].parentMatrix?this.particles[n].position.applyMatrix4(this.particles[n].parentMatrix):this.particles[n].position.applyMatrix4(this.emitter.matrixWorld)):this.particles[n].position.addScaledVector(this.particles[n].velocity,e*this.particles[n].speedModifier),this.particles[n].age+=e;if(this.rendererSettings.renderMode===V.Trail)for(let n=0;n<this.particleNum;n++)this.particles[n].update();for(let n=0;n<this.particleNum;n++){const i=this.particles[n];i.died&&(!(i instanceof Tr)||i.previous.length===0)&&(this.particles[n]=this.particles[this.particleNum-1],this.particles[this.particleNum-1]=i,this.particleNum--,n--,this.fire({type:"particleDied",particleSystem:this,particle:i}))}}emit(e,t,n){t.time>this.duration&&(this.looping?(t.time-=this.duration,t.burstIndex=0,this.behaviors.forEach(s=>{s.reset()})):!this.emitEnded&&!this.onlyUsedByOther&&this.endEmit()),this.normalMatrix.getNormalMatrix(n);const i=Math.ceil(t.waitEmiting);for(this.spawn(i,t,n),t.waitEmiting-=i;t.burstIndex<this.emissionBursts.length&&this.emissionBursts[t.burstIndex].time<=t.time;){if(Math.random()<this.emissionBursts[t.burstIndex].probability){const s=this.emissionBursts[t.burstIndex].count.genValue(this.memory,this.time);t.isBursting=!0,t.burstParticleCount=s,this.spawn(s,t,n),t.isBursting=!1}t.burstIndex++}if(!this.emitEnded&&(t.waitEmiting+=e*this.emissionOverTime.genValue(this.memory,t.time/this.duration),t.previousWorldPos!=null)){this.temp.set(n.elements[12],n.elements[13],n.elements[14]),t.travelDistance+=t.previousWorldPos.distanceTo(this.temp);const s=this.emissionOverDistance.genValue(this.memory,t.time/this.duration);if(t.travelDistance*s>0){const a=Math.floor(t.travelDistance*s);t.travelDistance-=a/s,t.waitEmiting+=a}}t.previousWorldPos===void 0&&(t.previousWorldPos=new G),t.previousWorldPos.set(n.elements[12],n.elements[13],n.elements[14]),t.time+=e}toJSON(e,t={}){var n;if((e===void 0||typeof e=="string")&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}}),e.materials[this.rendererSettings.material.uuid]=this.rendererSettings.material.toJSON(e),t.useUrlForImage&&((n=this.texture)===null||n===void 0?void 0:n.source)!==void 0){const a=this.texture.source;e.images[a.uuid]={uuid:a.uuid,url:this.texture.image.url}}let i;this.renderMode===V.Trail?i={startLength:this.rendererEmitterSettings.startLength.toJSON(),followLocalOrigin:this.rendererEmitterSettings.followLocalOrigin}:this.renderMode===V.Mesh?i={}:this.renderMode===V.StretchedBillBoard?i={speedFactor:this.rendererEmitterSettings.speedFactor,lengthFactor:this.rendererEmitterSettings.lengthFactor}:i={};const s=this.rendererSettings.instancingGeometry;return e.geometries&&!e.geometries[s.uuid]&&(e.geometries[s.uuid]=s.toJSON()),{version:"3.0",autoDestroy:this.autoDestroy,looping:this.looping,prewarm:this.prewarm,duration:this.duration,shape:this.emitterShape.toJSON(),startLife:this.startLife.toJSON(),startSpeed:this.startSpeed.toJSON(),startRotation:this.startRotation.toJSON(),startSize:this.startSize.toJSON(),startColor:this.startColor.toJSON(),emissionOverTime:this.emissionOverTime.toJSON(),emissionOverDistance:this.emissionOverDistance.toJSON(),emissionBursts:this.emissionBursts.map(a=>({time:a.time,count:a.count.toJSON(),probability:a.probability,interval:a.interval,cycle:a.cycle})),onlyUsedByOther:this.onlyUsedByOther,instancingGeometry:this.rendererSettings.instancingGeometry.uuid,renderOrder:this.renderOrder,renderMode:this.renderMode,rendererEmitterSettings:i,material:this.rendererSettings.material.uuid,layers:this.layers.mask,startTileIndex:this.startTileIndex.toJSON(),uTileCount:this.uTileCount,vTileCount:this.vTileCount,blendTiles:this.blendTiles,softParticles:this.rendererSettings.softParticles,softFarFade:this.rendererSettings.softFarFade,softNearFade:this.rendererSettings.softNearFade,behaviors:this.behaviors.map(a=>a.toJSON()),worldSpace:this.worldSpace}}static fromJSON(e,t,n){var i,s;const a=Ch(e.shape,t);let o;if(e.renderMode===V.Trail){const u=e.rendererEmitterSettings;o={startLength:u.startLength!=null?Q(u.startLength):new ne(30),followLocalOrigin:u.followLocalOrigin}}else e.renderMode===V.Mesh?o={}:e.renderMode===V.StretchedBillBoard?(o=e.rendererEmitterSettings,e.speedFactor!=null&&(o.speedFactor=e.speedFactor)):o={};const c=new sr;e.layers&&(c.mask=e.layers);const l=new Qr({autoDestroy:e.autoDestroy,looping:e.looping,prewarm:e.prewarm,duration:e.duration,shape:a,startLife:Q(e.startLife),startSpeed:Q(e.startSpeed),startRotation:br(e.startRotation),startSize:br(e.startSize),startColor:Fs(e.startColor),emissionOverTime:Q(e.emissionOverTime),emissionOverDistance:Q(e.emissionOverDistance),emissionBursts:(i=e.emissionBursts)===null||i===void 0?void 0:i.map(u=>{var p,f,m;return{time:u.time,count:typeof u.count=="number"?new ne(u.count):Q(u.count),probability:(p=u.probability)!==null&&p!==void 0?p:1,interval:(f=u.interval)!==null&&f!==void 0?f:.1,cycle:(m=u.cycle)!==null&&m!==void 0?m:1}}),onlyUsedByOther:e.onlyUsedByOther,instancingGeometry:t.geometries[e.instancingGeometry],renderMode:e.renderMode,rendererEmitterSettings:o,renderOrder:e.renderOrder,layers:c,material:e.material?t.materials[e.material]:e.texture?new Zo({map:t.textures[e.texture],transparent:(s=e.transparent)!==null&&s!==void 0?s:!0,blending:e.blending,side:ds}):new Zo({color:16777215,transparent:!0,blending:Ko,side:ds}),startTileIndex:typeof e.startTileIndex=="number"?new ne(e.startTileIndex):Q(e.startTileIndex),uTileCount:e.uTileCount,vTileCount:e.vTileCount,blendTiles:e.blendTiles,softParticles:e.softParticles,softFarFade:e.softFarFade,softNearFade:e.softNearFade,behaviors:[],worldSpace:e.worldSpace});return l.behaviors=e.behaviors.map(u=>{const p=Nh(u,l);return p.type==="EmitSubParticleSystem"&&(n[u.subParticleSystem]=p),p}),l}addBehavior(e){this.behaviors.push(e)}getRendererSettings(){return this.rendererSettings}addEventListener(e,t){this.listeners[e]||(this.listeners[e]=[]),this.listeners[e].push(t)}removeAllEventListeners(e){this.listeners[e]&&(this.listeners[e]=[])}removeEventListener(e,t){if(this.listeners[e]){const n=this.listeners[e].indexOf(t);n!==-1&&this.listeners[e].splice(n,1)}}fire(e){this.listeners[e.type]&&this.listeners[e.type].forEach(t=>t(e))}clone(){const e=[];for(const s of this.emissionBursts){const a={};Object.assign(a,s),e.push(a)}const t=[];for(const s of this.behaviors)t.push(s.clone());let n;this.renderMode===V.Trail?n={startLength:this.rendererEmitterSettings.startLength.clone(),followLocalOrigin:this.rendererEmitterSettings.followLocalOrigin}:this.renderMode===V.StretchedBillBoard?n={lengthFactor:this.rendererEmitterSettings.lengthFactor,speedFactor:this.rendererEmitterSettings.speedFactor}:n={};const i=new sr;return i.mask=this.layers.mask,new Qr({autoDestroy:this.autoDestroy,looping:this.looping,duration:this.duration,shape:this.emitterShape.clone(),startLife:this.startLife.clone(),startSpeed:this.startSpeed.clone(),startRotation:this.startRotation.clone(),startSize:this.startSize.clone(),startColor:this.startColor.clone(),emissionOverTime:this.emissionOverTime.clone(),emissionOverDistance:this.emissionOverDistance.clone(),emissionBursts:e,onlyUsedByOther:this.onlyUsedByOther,instancingGeometry:this.rendererSettings.instancingGeometry,renderMode:this.renderMode,renderOrder:this.renderOrder,rendererEmitterSettings:n,material:this.rendererSettings.material,startTileIndex:this.startTileIndex,uTileCount:this.uTileCount,vTileCount:this.vTileCount,blendTiles:this.blendTiles,softParticles:this.softParticles,softFarFade:this.softFarFade,softNearFade:this.softNearFade,behaviors:t,worldSpace:this.worldSpace,layers:i})}}var Hs=`
|
|
605
605
|
|
|
606
606
|
#include <common>
|
|
607
607
|
#include <color_pars_fragment>
|
|
@@ -801,7 +801,7 @@ outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoat
|
|
|
801
801
|
#include <fog_fragment>
|
|
802
802
|
#include <premultiplied_alpha_fragment>
|
|
803
803
|
#include <dithering_fragment>
|
|
804
|
-
}
|
|
804
|
+
}`,$h=`
|
|
805
805
|
#include <common>
|
|
806
806
|
#include <color_pars_vertex>
|
|
807
807
|
#include <logdepthbuf_pars_vertex>
|
|
@@ -847,7 +847,7 @@ void main() {
|
|
|
847
847
|
#include <tile_vertex>
|
|
848
848
|
#include <soft_vertex>
|
|
849
849
|
}
|
|
850
|
-
|
|
850
|
+
`,ed=`
|
|
851
851
|
#include <common>
|
|
852
852
|
#include <color_pars_vertex>
|
|
853
853
|
#include <logdepthbuf_pars_vertex>
|
|
@@ -969,7 +969,7 @@ void main() {
|
|
|
969
969
|
vWorldPosition = worldPosition.xyz;
|
|
970
970
|
#endif
|
|
971
971
|
}
|
|
972
|
-
`,
|
|
972
|
+
`,td=`
|
|
973
973
|
#include <common>
|
|
974
974
|
#include <color_pars_vertex>
|
|
975
975
|
#include <logdepthbuf_pars_vertex>
|
|
@@ -1010,7 +1010,7 @@ void main() {
|
|
|
1010
1010
|
#include <tile_vertex>
|
|
1011
1011
|
#include <soft_vertex>
|
|
1012
1012
|
}
|
|
1013
|
-
`;function Ys(r){return r===0?"uv":`uv${r}`}class
|
|
1013
|
+
`;function Ys(r){return r===0?"uv":`uv${r}`}class nd extends Dl{constructor(e){super(e)}onBeforeCompile(e,t){super.onBeforeCompile(e,t),e.vertexShader=Xs,e.fragmentShader=qs}}class id extends Ll{constructor(e){super(e)}onBeforeCompile(e,t){super.onBeforeCompile(e,t),e.vertexShader=Xs,e.fragmentShader=qs}}class rd extends Fc{constructor(e){super(e),this.vector_=new G,this.vector2_=new G,this.vector3_=new G,this.quaternion_=new ie,this.quaternion2_=new ie,this.quaternion3_=new ie,this.rotationMat_=new Dt,this.rotationMat2_=new Dt,this.maxParticles=1e3,this.setupBuffers(),this.rebuildMaterial()}buildExpandableBuffers(){this.offsetBuffer=new ln(new Float32Array(this.maxParticles*3),3),this.offsetBuffer.setUsage(He),this.geometry.setAttribute("offset",this.offsetBuffer),this.colorBuffer=new ln(new Float32Array(this.maxParticles*4),4),this.colorBuffer.setUsage(He),this.geometry.setAttribute("color",this.colorBuffer),this.settings.renderMode===V.Mesh?(this.rotationBuffer=new ln(new Float32Array(this.maxParticles*4),4),this.rotationBuffer.setUsage(He),this.geometry.setAttribute("rotation",this.rotationBuffer)):(this.settings.renderMode===V.BillBoard||this.settings.renderMode===V.HorizontalBillBoard||this.settings.renderMode===V.VerticalBillBoard||this.settings.renderMode===V.StretchedBillBoard)&&(this.rotationBuffer=new ln(new Float32Array(this.maxParticles),1),this.rotationBuffer.setUsage(He),this.geometry.setAttribute("rotation",this.rotationBuffer)),this.sizeBuffer=new ln(new Float32Array(this.maxParticles*3),3),this.sizeBuffer.setUsage(He),this.geometry.setAttribute("size",this.sizeBuffer),this.uvTileBuffer=new ln(new Float32Array(this.maxParticles),1),this.uvTileBuffer.setUsage(He),this.geometry.setAttribute("uvTile",this.uvTileBuffer),this.settings.renderMode===V.StretchedBillBoard&&(this.velocityBuffer=new ln(new Float32Array(this.maxParticles*4),4),this.velocityBuffer.setUsage(He),this.geometry.setAttribute("velocity",this.velocityBuffer))}setupBuffers(){this.geometry&&this.geometry.dispose(),this.geometry=new Ul,this.geometry.setIndex(this.settings.instancingGeometry.getIndex()),this.settings.instancingGeometry.hasAttribute("normal")&&this.geometry.setAttribute("normal",this.settings.instancingGeometry.getAttribute("normal")),this.geometry.setAttribute("position",this.settings.instancingGeometry.getAttribute("position")),this.geometry.setAttribute("uv",this.settings.instancingGeometry.getAttribute("uv")),this.buildExpandableBuffers()}expandBuffers(e){for(;e>=this.maxParticles;)this.maxParticles*=2;this.setupBuffers()}rebuildMaterial(){this.layers.mask=this.settings.layers.mask;const e={},t={};this.settings.material.type!=="MeshStandardMaterial"&&this.settings.material.type!=="MeshPhysicalMaterial"&&(e.map=new Mt(this.settings.material.map)),this.settings.material.alphaTest&&(t.USE_ALPHATEST="",e.alphaTest=new Mt(this.settings.material.alphaTest)),t.USE_UV="";const n=this.settings.uTileCount,i=this.settings.vTileCount;(n>1||i>1)&&(t.UV_TILE="",e.tileCount=new Mt(new Jn(n,i))),this.settings.material.defines&&this.settings.material.defines.USE_COLOR_AS_ALPHA!==void 0&&(t.USE_COLOR_AS_ALPHA=""),this.settings.material.normalMap&&(t.USE_NORMALMAP="",t.NORMALMAP_UV=Ys(this.settings.material.normalMap.channel),e.normalMapTransform=new Mt(new Dt().copy(this.settings.material.normalMap.matrix))),this.settings.material.map&&(t.USE_MAP="",this.settings.blendTiles&&(t.TILE_BLEND=""),t.MAP_UV=Ys(this.settings.material.map.channel),e.mapTransform=new Mt(new Dt().copy(this.settings.material.map.matrix))),t.USE_COLOR_ALPHA="";let s;if(this.settings.softParticles){t.SOFT_PARTICLES="";const o=this.settings.softNearFade,c=1/(this.settings.softFarFade-this.settings.softNearFade);e.softParams=new Mt(new Jn(o,c)),e.depthTexture=new Mt(null);const l=e.projParams=new Mt(new tt);s=(u,p,f)=>{l.value.set(f.near,f.far,0,0)}}let a=!1;if(this.settings.renderMode===V.BillBoard||this.settings.renderMode===V.VerticalBillBoard||this.settings.renderMode===V.HorizontalBillBoard||this.settings.renderMode===V.Mesh){let o,c;this.settings.renderMode===V.Mesh?this.settings.material.type==="MeshStandardMaterial"||this.settings.material.type==="MeshPhysicalMaterial"?(t.USE_COLOR="",o=Xs,c=qs,a=!0):(o=ed,c=Hs):(o=$h,c=Hs),this.settings.renderMode===V.VerticalBillBoard?t.VERTICAL="":this.settings.renderMode===V.HorizontalBillBoard&&(t.HORIZONTAL="");let l=!1;this.settings.renderMode===V.Mesh&&(this.settings.material.type==="MeshStandardMaterial"?(this.material=new nd({}),this.material.copy(this.settings.material),this.material.uniforms=e,this.material.defines=t,l=!0):this.settings.material.type==="MeshPhysicalMaterial"&&(this.material=new id({}),this.material.copy(this.settings.material),this.material.uniforms=e,this.material.defines=t,l=!0)),l||(this.material=new ps({uniforms:e,defines:t,vertexShader:o,fragmentShader:c,transparent:this.settings.material.transparent,depthWrite:!this.settings.material.transparent,blending:this.settings.material.blending,blendDst:this.settings.material.blendDst,blendSrc:this.settings.material.blendSrc,blendEquation:this.settings.material.blendEquation,premultipliedAlpha:this.settings.material.premultipliedAlpha,side:this.settings.material.side,alphaTest:this.settings.material.alphaTest,depthTest:this.settings.material.depthTest,lights:a}))}else if(this.settings.renderMode===V.StretchedBillBoard)e.speedFactor=new Mt(1),this.material=new ps({uniforms:e,defines:t,vertexShader:td,fragmentShader:Hs,transparent:this.settings.material.transparent,depthWrite:!this.settings.material.transparent,blending:this.settings.material.blending,blendDst:this.settings.material.blendDst,blendSrc:this.settings.material.blendSrc,blendEquation:this.settings.material.blendEquation,premultipliedAlpha:this.settings.material.premultipliedAlpha,side:this.settings.material.side,alphaTest:this.settings.material.alphaTest,depthTest:this.settings.material.depthTest});else throw new Error("render mode unavailable");this.material&&s&&(this.material.onBeforeRender=s)}update(){let e=0,t=0;this.systems.forEach(n=>{t+=n.particleNum}),t>this.maxParticles&&this.expandBuffers(t),this.systems.forEach(n=>{n.emitter.updateMatrixWorld&&(n.emitter.updateWorldMatrix(!0,!1),n.emitter.updateMatrixWorld(!0));const i=n.particles,s=n.particleNum,a=this.quaternion2_,o=this.vector2_,c=this.vector3_;n.emitter.matrixWorld.decompose(o,a,c),this.rotationMat_.setFromMatrix4(n.emitter.matrixWorld);for(let l=0;l<s;l++,e++){const u=i[l];if(this.settings.renderMode===V.Mesh){let f;if(n.worldSpace)f=u.rotation;else{let m;u.parentMatrix?m=this.quaternion3_.setFromRotationMatrix(u.parentMatrix):m=a,f=this.quaternion_,f.copy(m).multiply(u.rotation)}this.rotationBuffer.setXYZW(e,f.x,f.y,f.z,f.w)}else(this.settings.renderMode===V.StretchedBillBoard||this.settings.renderMode===V.VerticalBillBoard||this.settings.renderMode===V.HorizontalBillBoard||this.settings.renderMode===V.BillBoard)&&this.rotationBuffer.setX(e,u.rotation);let p;if(n.worldSpace?p=u.position:(p=this.vector_,u.parentMatrix?p.copy(u.position).applyMatrix4(u.parentMatrix):p.copy(u.position).applyMatrix4(n.emitter.matrixWorld)),this.offsetBuffer.setXYZ(e,p.x,p.y,p.z),this.colorBuffer.setXYZW(e,u.color.x,u.color.y,u.color.z,u.color.w),n.worldSpace?this.sizeBuffer.setXYZ(e,u.size.x,u.size.y,u.size.z):u.parentMatrix?this.sizeBuffer.setXYZ(e,u.size.x,u.size.y,u.size.z):this.sizeBuffer.setXYZ(e,u.size.x*Math.abs(c.x),u.size.y*Math.abs(c.y),u.size.z*Math.abs(c.z)),this.uvTileBuffer.setX(e,u.uvTile),this.settings.renderMode===V.StretchedBillBoard&&this.velocityBuffer){let f=n.rendererEmitterSettings.speedFactor;f===0&&(f=.001);const m=n.rendererEmitterSettings.lengthFactor;let b;n.worldSpace?b=u.velocity:(b=this.vector_,u.parentMatrix?(this.rotationMat2_.setFromMatrix4(u.parentMatrix),b.copy(u.velocity).applyMatrix3(this.rotationMat2_)):b.copy(u.velocity).applyMatrix3(this.rotationMat_)),this.velocityBuffer.setXYZW(e,b.x*f,b.y*f,b.z*f,m)}}}),this.geometry.instanceCount=e,e>0&&(this.offsetBuffer.clearUpdateRanges(),this.offsetBuffer.addUpdateRange(0,e*3),this.offsetBuffer.needsUpdate=!0,this.sizeBuffer.clearUpdateRanges(),this.sizeBuffer.addUpdateRange(0,e*3),this.sizeBuffer.needsUpdate=!0,this.colorBuffer.clearUpdateRanges(),this.colorBuffer.addUpdateRange(0,e*4),this.colorBuffer.needsUpdate=!0,this.uvTileBuffer.clearUpdateRanges(),this.uvTileBuffer.addUpdateRange(0,e),this.uvTileBuffer.needsUpdate=!0,this.settings.renderMode===V.StretchedBillBoard&&this.velocityBuffer&&(this.velocityBuffer.clearUpdateRanges(),this.velocityBuffer.addUpdateRange(0,e*4),this.velocityBuffer.needsUpdate=!0),this.settings.renderMode===V.Mesh?(this.rotationBuffer.clearUpdateRanges(),this.rotationBuffer.addUpdateRange(0,e*4),this.rotationBuffer.needsUpdate=!0):(this.settings.renderMode===V.StretchedBillBoard||this.settings.renderMode===V.HorizontalBillBoard||this.settings.renderMode===V.VerticalBillBoard||this.settings.renderMode===V.BillBoard)&&(this.rotationBuffer.clearUpdateRanges(),this.rotationBuffer.addUpdateRange(0,e),this.rotationBuffer.needsUpdate=!0))}dispose(){this.geometry.dispose()}}var sd=`
|
|
1014
1014
|
|
|
1015
1015
|
#include <common>
|
|
1016
1016
|
#include <tile_pars_fragment>
|
|
@@ -1043,7 +1043,7 @@ void main() {
|
|
|
1043
1043
|
|
|
1044
1044
|
#include <fog_fragment>
|
|
1045
1045
|
#include <tonemapping_fragment>
|
|
1046
|
-
}`,
|
|
1046
|
+
}`,od=`
|
|
1047
1047
|
#include <common>
|
|
1048
1048
|
#include <tile_pars_vertex>
|
|
1049
1049
|
#include <color_pars_vertex>
|
|
@@ -1118,4 +1118,4 @@ void main() {
|
|
|
1118
1118
|
vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );
|
|
1119
1119
|
|
|
1120
1120
|
#include <fog_vertex>
|
|
1121
|
-
}`;class od extends Fc{constructor(e){super(e),this.vector_=new G,this.vector2_=new G,this.vector3_=new G,this.quaternion_=new ie,this.maxParticles=1e4,this.setupBuffers(),this.rebuildMaterial()}setupBuffers(){this.geometry&&this.geometry.dispose(),this.geometry=new Yn,this.indexBuffer=new ot(new Uint32Array(this.maxParticles*6),1),this.indexBuffer.setUsage(He),this.geometry.setIndex(this.indexBuffer),this.positionBuffer=new ot(new Float32Array(this.maxParticles*6),3),this.positionBuffer.setUsage(He),this.geometry.setAttribute("position",this.positionBuffer),this.previousBuffer=new ot(new Float32Array(this.maxParticles*6),3),this.previousBuffer.setUsage(He),this.geometry.setAttribute("previous",this.previousBuffer),this.nextBuffer=new ot(new Float32Array(this.maxParticles*6),3),this.nextBuffer.setUsage(He),this.geometry.setAttribute("next",this.nextBuffer),this.widthBuffer=new ot(new Float32Array(this.maxParticles*2),1),this.widthBuffer.setUsage(He),this.geometry.setAttribute("width",this.widthBuffer),this.sideBuffer=new ot(new Float32Array(this.maxParticles*2),1),this.sideBuffer.setUsage(He),this.geometry.setAttribute("side",this.sideBuffer),this.uvBuffer=new ot(new Float32Array(this.maxParticles*4),2),this.uvBuffer.setUsage(He),this.geometry.setAttribute("uv",this.uvBuffer),this.colorBuffer=new ot(new Float32Array(this.maxParticles*8),4),this.colorBuffer.setUsage(He),this.geometry.setAttribute("color",this.colorBuffer)}expandBuffers(e){for(;e>=this.maxParticles;)this.maxParticles*=2;this.setupBuffers()}rebuildMaterial(){this.layers.mask=this.settings.layers.mask;const e={lineWidth:{value:1},map:{value:null},useMap:{value:0},alphaMap:{value:null},useAlphaMap:{value:0},resolution:{value:new Jn(1,1)},sizeAttenuation:{value:1},visibility:{value:1},alphaTest:{value:0}},t={};if(t.USE_UV="",t.USE_COLOR_ALPHA="",this.settings.material.map&&(t.USE_MAP="",t.MAP_UV=Ys(this.settings.material.map.channel),e.map=new Mt(this.settings.material.map),e.mapTransform=new Mt(new Dt().copy(this.settings.material.map.matrix))),this.settings.material.defines&&this.settings.material.defines.USE_COLOR_AS_ALPHA!==void 0&&(t.USE_COLOR_AS_ALPHA=""),this.settings.renderMode===V.Trail)this.material=new ps({uniforms:e,defines:t,vertexShader:sd,fragmentShader:rd,transparent:this.settings.material.transparent,depthWrite:!this.settings.material.transparent,side:this.settings.material.side,blending:this.settings.material.blending||Ko,blendDst:this.settings.material.blendDst,blendSrc:this.settings.material.blendSrc,blendEquation:this.settings.material.blendEquation,premultipliedAlpha:this.settings.material.premultipliedAlpha});else throw new Error("render mode unavailable")}update(){let e=0,t=0,n=0;this.systems.forEach(i=>{for(let s=0;s<i.particleNum;s++)n+=i.particles[s].previous.length*2}),n>this.maxParticles&&this.expandBuffers(n),this.systems.forEach(i=>{i.emitter.updateMatrixWorld&&(i.emitter.updateWorldMatrix(!0,!1),i.emitter.updateMatrixWorld(!0));const s=this.quaternion_,a=this.vector2_,o=this.vector3_;i.emitter.matrixWorld.decompose(a,s,o);const c=i.particles,l=i.particleNum,u=this.settings.uTileCount,p=this.settings.vTileCount,f=1/u,m=1/p;for(let b=0;b<l;b++){const x=c[b],g=x.uvTile%p,v=Math.floor(x.uvTile/p+.001),_=x.previous.values();let w=_.next(),C=w.value,M=C;w.done||(w=_.next());let E;w.value!==void 0?E=w.value:E=M;for(let P=0;P<x.previous.length;P++,e+=2){if(this.positionBuffer.setXYZ(e,M.position.x,M.position.y,M.position.z),this.positionBuffer.setXYZ(e+1,M.position.x,M.position.y,M.position.z),i.worldSpace?(this.positionBuffer.setXYZ(e,M.position.x,M.position.y,M.position.z),this.positionBuffer.setXYZ(e+1,M.position.x,M.position.y,M.position.z)):(x.parentMatrix?this.vector_.copy(M.position).applyMatrix4(x.parentMatrix):this.vector_.copy(M.position).applyMatrix4(i.emitter.matrixWorld),this.positionBuffer.setXYZ(e,this.vector_.x,this.vector_.y,this.vector_.z),this.positionBuffer.setXYZ(e+1,this.vector_.x,this.vector_.y,this.vector_.z)),i.worldSpace?(this.previousBuffer.setXYZ(e,C.position.x,C.position.y,C.position.z),this.previousBuffer.setXYZ(e+1,C.position.x,C.position.y,C.position.z)):(x.parentMatrix?this.vector_.copy(C.position).applyMatrix4(x.parentMatrix):this.vector_.copy(C.position).applyMatrix4(i.emitter.matrixWorld),this.previousBuffer.setXYZ(e,this.vector_.x,this.vector_.y,this.vector_.z),this.previousBuffer.setXYZ(e+1,this.vector_.x,this.vector_.y,this.vector_.z)),i.worldSpace?(this.nextBuffer.setXYZ(e,E.position.x,E.position.y,E.position.z),this.nextBuffer.setXYZ(e+1,E.position.x,E.position.y,E.position.z)):(x.parentMatrix?this.vector_.copy(E.position).applyMatrix4(x.parentMatrix):this.vector_.copy(E.position).applyMatrix4(i.emitter.matrixWorld),this.nextBuffer.setXYZ(e,this.vector_.x,this.vector_.y,this.vector_.z),this.nextBuffer.setXYZ(e+1,this.vector_.x,this.vector_.y,this.vector_.z)),this.sideBuffer.setX(e,-1),this.sideBuffer.setX(e+1,1),i.worldSpace)this.widthBuffer.setX(e,M.size),this.widthBuffer.setX(e+1,M.size);else if(x.parentMatrix)this.widthBuffer.setX(e,M.size),this.widthBuffer.setX(e+1,M.size);else{const O=(Math.abs(o.x)+Math.abs(o.y)+Math.abs(o.z))/3;this.widthBuffer.setX(e,M.size*O),this.widthBuffer.setX(e+1,M.size*O)}this.uvBuffer.setXY(e,(P/x.previous.length+g)*f,(p-v-1)*m),this.uvBuffer.setXY(e+1,(P/x.previous.length+g)*f,(p-v)*m),this.colorBuffer.setXYZW(e,M.color.x,M.color.y,M.color.z,M.color.w),this.colorBuffer.setXYZW(e+1,M.color.x,M.color.y,M.color.z,M.color.w),P+1<x.previous.length&&(this.indexBuffer.setX(t*3,e),this.indexBuffer.setX(t*3+1,e+1),this.indexBuffer.setX(t*3+2,e+2),t++,this.indexBuffer.setX(t*3,e+2),this.indexBuffer.setX(t*3+1,e+1),this.indexBuffer.setX(t*3+2,e+3),t++),C=M,M=E,w.done||(w=_.next(),w.value!==void 0&&(E=w.value))}}}),this.positionBuffer.clearUpdateRanges(),this.positionBuffer.addUpdateRange(0,e*3),this.positionBuffer.needsUpdate=!0,this.previousBuffer.clearUpdateRanges(),this.previousBuffer.addUpdateRange(0,e*3),this.previousBuffer.needsUpdate=!0,this.nextBuffer.clearUpdateRanges(),this.nextBuffer.addUpdateRange(0,e*3),this.nextBuffer.needsUpdate=!0,this.sideBuffer.clearUpdateRanges(),this.sideBuffer.addUpdateRange(0,e),this.sideBuffer.needsUpdate=!0,this.widthBuffer.clearUpdateRanges(),this.widthBuffer.addUpdateRange(0,e),this.widthBuffer.needsUpdate=!0,this.uvBuffer.clearUpdateRanges(),this.uvBuffer.addUpdateRange(0,e*2),this.uvBuffer.needsUpdate=!0,this.colorBuffer.clearUpdateRanges(),this.colorBuffer.addUpdateRange(0,e*4),this.colorBuffer.needsUpdate=!0,this.indexBuffer.clearUpdateRanges(),this.indexBuffer.addUpdateRange(0,t*3),this.indexBuffer.needsUpdate=!0,this.geometry.setDrawRange(0,t*3)}dispose(){this.geometry.dispose()}}class Ki{get geometry(){return this._geometry}set geometry(e){if(this._geometry=e,e===void 0||typeof e=="string")return;const t=new un;this._triangleIndexToArea.length=0;let n=0;if(!e.getIndex())return;const i=e.getIndex().array,s=i.length/3;this._triangleIndexToArea.push(0);for(let a=0;a<s;a++)t.setFromAttributeAndIndices(e.getAttribute("position"),i[a*3],i[a*3+1],i[a*3+2]),n+=t.getArea(),this._triangleIndexToArea.push(n);e.userData.triangleIndexToArea=this._triangleIndexToArea}constructor(e){this.type="mesh_surface",this._triangleIndexToArea=[],this._tempA=new W,this._tempB=new W,this._tempC=new W,e&&(this.geometry=e)}initialize(e){const t=this._geometry;if(!t||t.getIndex()===null){e.position.set(0,0,0),e.velocity.set(0,0,1).multiplyScalar(e.startSpeed);return}const n=this._triangleIndexToArea.length-1;let i=0,s=n;const a=Math.random()*this._triangleIndexToArea[n];for(;i+1<s;){const m=Math.floor((i+s)/2);a<this._triangleIndexToArea[m]?s=m:i=m}let o=Math.random(),c=Math.random();o+c>1&&(o=1-o,c=1-c);const l=t.getIndex().array[i*3],u=t.getIndex().array[i*3+1],p=t.getIndex().array[i*3+2],f=t.getAttribute("position");this._tempA.fromBufferAttribute(f,l),this._tempB.fromBufferAttribute(f,u),this._tempC.fromBufferAttribute(f,p),this._tempB.sub(this._tempA),this._tempC.sub(this._tempA),this._tempA.addScaledVector(this._tempB,o).addScaledVector(this._tempC,c),e.position.copy(this._tempA),this._tempA.copy(this._tempB).cross(this._tempC).normalize(),e.velocity.copy(this._tempA).normalize().multiplyScalar(e.startSpeed)}toJSON(){return{type:"mesh_surface",mesh:this._geometry?this._geometry.uuid:""}}static fromJSON(e,t){return new Ki(t.geometries[e.geometry])}clone(){return new Ki(this._geometry)}update(e,t){}}Uh({id:"three.quarks",emitterShapes:[{type:"mesh_surface",params:[["geometry",["geometry"]]],constructor:Ki,loadJSON:Ki.fromJSON}],behaviors:[]});class To extends Yo{constructor(){super(),this.batches=[],this.systemToBatchIndex=new Map,this.type="BatchedRenderer",this.depthTexture=null}static equals(e,t){return e.material.side===t.material.side&&e.material.blending===t.material.blending&&e.material.blendSrc===t.material.blendSrc&&e.material.blendDst===t.material.blendDst&&e.material.blendEquation===t.material.blendEquation&&e.material.premultipliedAlpha===t.material.premultipliedAlpha&&e.material.transparent===t.material.transparent&&e.material.depthTest===t.material.depthTest&&e.material.type===t.material.type&&e.material.alphaTest===t.material.alphaTest&&e.material.map===t.material.map&&e.renderMode===t.renderMode&&e.blendTiles===t.blendTiles&&e.softParticles===t.softParticles&&e.softFarFade===t.softFarFade&&e.softNearFade===t.softNearFade&&e.uTileCount===t.uTileCount&&e.vTileCount===t.vTileCount&&e.instancingGeometry===t.instancingGeometry&&e.renderOrder===t.renderOrder&&e.layers.mask===t.layers.mask}addSystem(e){e._renderer=this;const t=e.getRendererSettings();for(let i=0;i<this.batches.length;i++)if(To.equals(this.batches[i].settings,t)){this.batches[i].addSystem(e),this.systemToBatchIndex.set(e,i);return}let n;switch(t.renderMode){case V.Trail:n=new od(t);break;case V.Mesh:case V.BillBoard:case V.VerticalBillBoard:case V.HorizontalBillBoard:case V.StretchedBillBoard:n=new id(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 ad=To;Hh(),console.log("%c Particle system powered by three.quarks. https://quarks.art/","font-size: 14px; font-weight: bold;");const jc=Math.sqrt(5),cd=(jc-1)/4,Ne=(5-jc)/20,Cr=r=>Math.floor(r)|0,Er=new Float64Array([0,1,1,1,0,1,1,-1,0,1,-1,1,0,1,-1,-1,0,-1,1,1,0,-1,1,-1,0,-1,-1,1,0,-1,-1,-1,1,0,1,1,1,0,1,-1,1,0,-1,1,1,0,-1,-1,-1,0,1,1,-1,0,1,-1,-1,0,-1,1,-1,0,-1,-1,1,1,0,1,1,1,0,-1,1,-1,0,1,1,-1,0,-1,-1,1,0,1,-1,1,0,-1,-1,-1,0,1,-1,-1,0,-1,1,1,1,0,1,1,-1,0,1,-1,1,0,1,-1,-1,0,-1,1,1,0,-1,1,-1,0,-1,-1,1,0,-1,-1,-1,0]);function ld(r=Math.random){const e=ud(r),t=new Float64Array(e).map(a=>Er[a%32*4]),n=new Float64Array(e).map(a=>Er[a%32*4+1]),i=new Float64Array(e).map(a=>Er[a%32*4+2]),s=new Float64Array(e).map(a=>Er[a%32*4+3]);return function(a,o,c,l){let u,p,f,m,b;const x=(a+o+c+l)*cd,g=Cr(a+x),v=Cr(o+x),_=Cr(c+x),w=Cr(l+x),C=(g+v+_+w)*Ne,M=g-C,E=v-C,P=_-C,O=w-C,R=a-M,A=o-E,B=c-P,z=l-O;let D=0,F=0,H=0,q=0;R>A?D++:F++,R>B?D++:H++,R>z?D++:q++,A>B?F++:H++,A>z?F++:q++,B>z?H++:q++;const $=D>=3?1:0,J=F>=3?1:0,Se=H>=3?1:0,ce=q>=3?1:0,me=D>=2?1:0,le=F>=2?1:0,xe=H>=2?1:0,Ce=q>=2?1:0,ye=D>=1?1:0,pe=F>=1?1:0,oe=H>=1?1:0,nt=q>=1?1:0,je=R-$+Ne,Ye=A-J+Ne,it=B-Se+Ne,Oe=z-ce+Ne,fe=R-me+2*Ne,ae=A-le+2*Ne,lt=B-xe+2*Ne,Ee=z-Ce+2*Ne,ue=R-ye+3*Ne,Ze=A-pe+3*Ne,St=B-oe+3*Ne,bt=z-nt+3*Ne,Ke=R-1+4*Ne,xt=A-1+4*Ne,ut=B-1+4*Ne,ht=z-1+4*Ne,rt=g&255,Pe=v&255,Je=_&255,st=w&255;let Ge=.6-R*R-A*A-B*B-z*z;if(Ge<0)u=0;else{const re=rt+e[Pe+e[Je+e[st]]];Ge*=Ge,u=Ge*Ge*(t[re]*R+n[re]*A+i[re]*B+s[re]*z)}let ee=.6-je*je-Ye*Ye-it*it-Oe*Oe;if(ee<0)p=0;else{const re=rt+$+e[Pe+J+e[Je+Se+e[st+ce]]];ee*=ee,p=ee*ee*(t[re]*je+n[re]*Ye+i[re]*it+s[re]*Oe)}let wt=.6-fe*fe-ae*ae-lt*lt-Ee*Ee;if(wt<0)f=0;else{const re=rt+me+e[Pe+le+e[Je+xe+e[st+Ce]]];wt*=wt,f=wt*wt*(t[re]*fe+n[re]*ae+i[re]*lt+s[re]*Ee)}let Lt=.6-ue*ue-Ze*Ze-St*St-bt*bt;if(Lt<0)m=0;else{const re=rt+ye+e[Pe+pe+e[Je+oe+e[st+nt]]];Lt*=Lt,m=Lt*Lt*(t[re]*ue+n[re]*Ze+i[re]*St+s[re]*bt)}let _t=.6-Ke*Ke-xt*xt-ut*ut-ht*ht;if(_t<0)b=0;else{const re=rt+1+e[Pe+1+e[Je+1+e[st+1]]];_t*=_t,b=_t*_t*(t[re]*Ke+n[re]*xt+i[re]*ut+s[re]*ht)}return 27*(u+p+f+m+b)}}function ud(r){const e=new Uint8Array(512);for(let t=0;t<512/2;t++)e[t]=t;for(let t=0;t<512/2-1;t++){const n=t+~~(r()*(256-t)),i=e[t];e[t]=e[n],e[n]=i}for(let t=256;t<512;t++)e[t]=e[t-256];return e}var hd=Object.defineProperty,dd=(r,e,t)=>e in r?hd(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Te=(r,e,t)=>(dd(r,typeof e!="symbol"?e+"":e,t),t);(function(){class r{}class e extends r{constructor(d){super(),Te(this,"value"),this.value=d}}class t extends r{constructor(d){super(),Te(this,"value"),this.value=d}}class n extends r{constructor(d){super(),Te(this,"value"),this.value=d}}class i extends r{constructor(d,y="unrestricted"){super(),Te(this,"type"),Te(this,"value"),this.value=d,this.type=y}}class s extends r{constructor(d){super(),Te(this,"value"),this.value=d}}class a extends r{}class o extends r{constructor(d){super(),Te(this,"value"),this.value=d}}class c extends r{}class l extends r{constructor(d){super(),Te(this,"value"),this.value=d}}class u extends r{constructor(d,y="integer"){super(),Te(this,"value"),Te(this,"type"),this.value=d,this.type=y}}class p extends r{constructor(d){super(),Te(this,"value"),this.value=d}}class f extends r{constructor(d,y,S){super(),Te(this,"value"),Te(this,"type"),Te(this,"unit"),this.value=d,this.type=y,this.unit=S}}class m extends r{}class b extends r{}class x extends r{}class g extends r{}class v extends r{}class _ extends r{}class w extends r{}class C extends r{}class M extends r{}class E extends r{}class P extends r{}class O extends r{}class R{constructor(d){Te(this,"input"),Te(this,"index",0),this.input=d}consume(){const d=this.input.codePointAt(this.index);return d!==void 0&&(this.index+=String.fromCodePoint(d).length),d}reconsume(d){d!==void 0&&(this.index-=String.fromCodePoint(d).length)}peek(){const d=[];let y=this.index;for(let S=0;S<3&&y<this.input.length;S++){const T=this.input.codePointAt(y);d.push(T),y+=String.fromCodePoint(T).length}return d}}function A(h){return h===10}function B(h){return A(h)||h===8192||h===32}function z(h){return h>=48&&h<=57}function D(h){return z(h)||h>=65&&h<=70||h>=97&&h<=102}function F(h){return function(d){return function(y){return y>=65&&y<=90}(d)||function(y){return y>=97&&y<=122}(d)}(h)||function(d){return d>=128}(h)||h===95}function H(h){return F(h)||z(h)||h===45}function q(h){return h>=0&&h<=8||h===11||h>=14&&h<=31||h===127}function $(h,d){return h===92&&!A(d)}function J(h,d,y){return h===45?F(d)||d===45||$(d,y):!!F(h)||h===92&&$(h,d)}function Se(h,d,y){return h===43||h===45?z(d)||d===46&&z(y):z(h===46?d:h)}function ce(h){const d=h.consume();if(D(d)){let y=[d];for(;D(...h.peek())&&y.length<5;)y.push(h.consume());B(...h.peek())&&h.consume();const S=parseInt(String.fromCodePoint(...y),16);return S===0||S>1114111?65533:S}return d===void 0?65533:d}function me(h,d){const y=new s("");for(;;){const S=h.consume();if(S===d||S===void 0)return y;if(S===10)return h.reconsume(S),new a;if(S===92){const T=h.peek()[0];T===void 0||(A(T)?h.consume():y.value+=String.fromCodePoint(ce(h)))}else y.value+=String.fromCodePoint(S)}}function le(h){let d="";for(;;){const y=h.consume();if(H(y))d+=String.fromCodePoint(y);else{if(!$(...h.peek()))return h.reconsume(y),d;d+=String.fromCodePoint(ce(h))}}}function xe(h){let d=function(y){let S="integer",T="";for([43,45].includes(y.peek()[0])&&(T+=String.fromCodePoint(y.consume()));z(...y.peek());)T+=String.fromCodePoint(y.consume());if(y.peek()[0]===46&&z(y.peek()[1]))for(T+=String.fromCodePoint(y.consume(),y.consume()),S="number";z(...y.peek());)T+=String.fromCodePoint(y.consume());return[69,101].includes(y.peek()[0])&&([45,43].includes(y.peek()[1])&&z(y.peek()[2])?(T+=String.fromCodePoint(y.consume(),y.consume(),y.consume()),S="number"):z(y.peek()[1])&&(T+=String.fromCodePoint(y.consume(),y.consume()),S="number")),{value:parseFloat(T),type:S}}(h);return J(...h.peek())?new f(d.value,d.type,le(h)):h.peek()[0]===37?(h.consume(),new p(d.value)):new u(d.value,d.type)}function Ce(h){for(;;){const d=h.consume();if(d===41||d===void 0)return;$(...h.peek())&&ce(h)}}function ye(h){const d=le(h);if(d.match(/url/i)&&h.peek()[0]===40){for(h.consume();B(h.peek()[0])&&B(h.peek()[1]);)h.consume();return[34,39].includes(h.peek()[0])||B(h.peek()[0])&&[34,39].includes(h.peek()[1])?new t(d):function(y){const S=new o("");for(;B(...y.peek());)y.consume();for(;;){const T=y.consume();if(T===41||T===void 0)return S;if(B(T)){for(;B(...y.peek());)y.consume();return y.peek()[0]===41||y.peek()[0]===void 0?(y.consume(),S):(Ce(y),new c)}if([34,39,40].includes(T)||q(T))return Ce(y),new c;if(T===92){if(!$(...y.peek()))return Ce(y),new c;S.value+=ce(y)}else S.value+=String.fromCodePoint(T)}}(h)}return h.peek()[0]===40?(h.consume(),new t(d)):new e(d)}function pe(h){const d=h.consume(),y=h.peek();if(B(d)){for(;B(...h.peek());)h.consume();return new m}if(d===34)return me(h,d);if(d===35){if(H(y[0])||$(...y)){const S=new i;return J(...y)&&(S.type="id"),S.value=le(h),S}return new l(String.fromCodePoint(d))}return d===39?me(h,d):d===40?new M:d===41?new E:d===43?Se(...y)?(h.reconsume(d),xe(h)):new l(String.fromCodePoint(d)):d===44?new _:d===45?Se(...h.peek())?(h.reconsume(d),xe(h)):h.peek()[0]===45&&h.peek()[1]===62?(h.consume(),h.consume(),new x):J(...h.peek())?(h.reconsume(d),ye(h)):new l(String.fromCodePoint(d)):d===46?Se(...h.peek())?(h.reconsume(d),xe(h)):new l(String.fromCodePoint(d)):d===58?new g:d===59?new v:d===60?y[0]===33&&y[1]===45&&y[2]===45?(h.consume(),h.consume(),h.consume(),new b):new l(String.fromCodePoint(d)):d===64?J(...y)?new n(le(h)):new l(String.fromCodePoint(d)):d===91?new w:d===92?$(...y)?(h.reconsume(d),ye(h)):new l(String.fromCodePoint(d)):d===93?new C:d===123?new P:d===125?new O:z(d)?(h.reconsume(d),xe(h)):F(d)?(h.reconsume(d),ye(h)):d===void 0?void 0:new l(String.fromCodePoint(d))}const oe=new Set(["px","deg","s","hz","dppx","number","fr"]);function nt(h){return oe.has(h.toLowerCase())}function je(h,d){if(["x","y"].includes(h))return h;if(!d)throw new Error("To determine the normalized axis the computedStyle of the source is required.");const y=d.writingMode=="horizontal-tb";if(h==="block")h=y?"y":"x";else{if(h!=="inline")throw new TypeError(`Invalid axis \u201C${h}\u201D`);h=y?"x":"y"}return h}function Ye(h){const d=[];let y=0;function S(){let k=0;const I=y;for(;y<h.length;){const U=h.slice(y,y+1);if(/\s/.test(U)&&k===0)break;if(U==="(")k+=1;else if(U===")"&&(k-=1,k===0)){y++;break}y++}return h.slice(I,y)}function T(){for(;/\s/.test(h.slice(y,y+1));)y++}for(;y<h.length;){const k=h.slice(y,y+1);/\s/.test(k)?T():d.push(S())}return d}function it(h,d){return h.reduce((y,S)=>(y.has(S[d])?y.get(S[d]).push(S):y.set(S[d],[S]),y),new Map)}function Oe(h,d){const y=[],S=[];for(const T of h)d(T)?y.push(T):S.push(T);return[y,S]}function fe(h,d={}){function y(S){return Array.from(S).map(T=>fe(T,d))}if(h instanceof CSSUnitValue){if(h.unit==="percent"&&d.percentageReference){const T=h.value/100*d.percentageReference.value,k=d.percentageReference.unit;return new CSSUnitValue(T,k)}const S=h.toSum();if(S&&S.values.length===1&&(h=S.values[0]),h instanceof CSSUnitValue&&h.unit==="em"&&d.fontSize&&(h=new CSSUnitValue(h.value*d.fontSize.value,d.fontSize.unit)),h instanceof CSSKeywordValue){if(h.value==="e")return new CSSUnitValue(Math.E,"number");if(h.value==="pi")return new CSSUnitValue(Math.PI,"number")}return h}if(!h.operator)return h;switch(h.operator){case"sum":h=new CSSMathSum(...y(h.values));break;case"product":h=new CSSMathProduct(...y(h.values));break;case"negate":h=new CSSMathNegate(fe(h.value,d));break;case"clamp":h=new CSSMathClamp(fe(h.lower,d),fe(h.value,d),fe(h.upper,d));break;case"invert":h=new CSSMathInvert(fe(h.value,d));break;case"min":h=new CSSMathMin(...y(h.values));break;case"max":h=new CSSMathMax(...y(h.values))}if(h instanceof CSSMathMin||h instanceof CSSMathMax){const S=Array.from(h.values);if(S.every(T=>T instanceof CSSUnitValue&&T.unit!=="percent"&&nt(T.unit)&&T.unit===S[0].unit)){const T=Math[h.operator].apply(Math,S.map(({value:k})=>k));return new CSSUnitValue(T,S[0].unit)}}if(h instanceof CSSMathMin||h instanceof CSSMathMax){const S=Array.from(h.values),[T,k]=Oe(S,U=>U instanceof CSSUnitValue&&U.unit!=="percent"),I=Array.from(it(T,"unit").values());if(I.some(U=>U.length>0)){const U=I.map(N=>{const L=Math[h.operator].apply(Math,N.map(({value:X})=>X));return new CSSUnitValue(L,N[0].unit)});h=h instanceof CSSMathMin?new CSSMathMin(...U,...k):new CSSMathMax(...U,...k)}return S.length===1?S[0]:h}if(h instanceof CSSMathNegate)return h.value instanceof CSSUnitValue?new CSSUnitValue(0-h.value.value,h.value.unit):h.value instanceof CSSMathNegate?h.value.value:h;if(h instanceof CSSMathInvert)return h.value instanceof CSSMathInvert?h.value.value:h;if(h instanceof CSSMathSum){let S=function(k){const I=k.filter(U=>U instanceof CSSUnitValue);return[...k.filter(U=>!(U instanceof CSSUnitValue)),...Array.from(it(I,"unit").entries()).map(([U,N])=>{const L=N.reduce((X,{value:Z})=>X+Z,0);return new CSSUnitValue(L,U)})]},T=[];for(const k of h.values)k instanceof CSSMathSum?T.push(...k.values):T.push(k);return T=S(T),T.length===1?T[0]:new CSSMathSum(...T)}if(h instanceof CSSMathProduct){let S=[];for(const I of h.values)I instanceof CSSMathProduct?S.push(...I.values):S.push(I);const[T,k]=Oe(S,I=>I instanceof CSSUnitValue&&I.unit==="number");if(T.length>1){const I=T.reduce((U,{value:N})=>U*N,1);S=[new CSSUnitValue(I,"number"),...k]}if(S.length===2){let I,U;for(const N of S)N instanceof CSSUnitValue&&N.unit==="number"?I=N:N instanceof CSSMathSum&&[...N.values].every(L=>L instanceof CSSUnitValue)&&(U=N);if(I&&U)return new CSSMathSum(...[...U.values].map(N=>new CSSUnitValue(N.value*I.value,N.unit)))}if(S.every(I=>I instanceof CSSUnitValue&&nt(I.unit)||I instanceof CSSMathInvert&&I.value instanceof CSSUnitValue&&nt(I.value.unit))){const I=new CSSMathProduct(...S).toSum();if(I&&I.values.length===1)return I.values[0]}return new CSSMathProduct(...S)}return h}const ae=null,lt=["percent","length","angle","time","frequency","resolution","flex"],Ee={fontRelativeLengths:{units:new Set(["em","rem","ex","rex","cap","rcap","ch","rch","ic","ric","lh","rlh"])},viewportRelativeLengths:{units:new Set(["vw","lvw","svw","dvw","vh","lvh","svh","dvh","vi","lvi","svi","dvi","vb","lvb","svb","dvb","vmin","lvmin","svmin","dvmin","vmax","lvmax","svmax","dvmax"])},absoluteLengths:{units:new Set(["cm","mm","Q","in","pt","pc","px"]),compatible:!0,canonicalUnit:"px",ratios:{cm:96/2.54,mm:96/2.54/10,Q:96/2.54/40,in:96,pc:16,pt:96/72,px:1}},angle:{units:new Set(["deg","grad","rad","turn"]),compatible:!0,canonicalUnit:"deg",ratios:{deg:1,grad:.9,rad:180/Math.PI,turn:360}},time:{units:new Set(["s","ms"]),compatible:!0,canonicalUnit:"s",ratios:{s:1,ms:.001}},frequency:{units:new Set(["hz","khz"]),compatible:!0,canonicalUnit:"hz",ratios:{hz:1,khz:1e3}},resolution:{units:new Set(["dpi","dpcm","dppx"]),compatible:!0,canonicalUnit:"dppx",ratios:{dpi:1/96,dpcm:2.54/96,dppx:1}}},ue=new Map;for(const h of Object.values(Ee))if(h.compatible)for(const d of h.units)ue.set(d,h);function Ze(h){return ue.get(h)}function St(h,d){const y={...h};for(const S of Object.keys(d))y[S]?y[S]+=d[S]:y[S]=d[S];return y}function bt(h){return h==="number"?{}:h==="percent"?{percent:1}:Ee.absoluteLengths.units.has(h)||Ee.fontRelativeLengths.units.has(h)||Ee.viewportRelativeLengths.units.has(h)?{length:1}:Ee.angle.units.has(h)?{angle:1}:Ee.time.units.has(h)?{time:1}:Ee.frequency.units.has(h)?{frequency:1}:Ee.resolution.units.has(h)?{resolution:1}:h==="fr"?{flex:1}:ae}function Ke(h){if(h instanceof CSSUnitValue){let{unit:d,value:y}=h;const S=Ze(h.unit);return S&&d!==S.canonicalUnit&&(y*=S.ratios[d],d=S.canonicalUnit),d==="number"?[[y,{}]]:[[y,{[d]:1}]]}if(h instanceof CSSMathInvert){if(!(h.value instanceof CSSUnitValue))throw new Error("Not implemented");const d=Ke(h.value);if(d===ae||d.length>1)return ae;const y=d[0],S={};for(const[T,k]of Object.entries(y[1]))S[T]=-1*k;return d[0]=[1/y[0],S],d}if(h instanceof CSSMathProduct){let d=[[1,{}]];for(const y of h.values){const S=Ke(y),T=[];if(S===ae)return ae;for(const k of d)for(const I of S)T.push([k[0]*I[0],St(k[1],I[1])]);d=T}return d}throw new Error("Not implemented")}function xt(h,d){if(bt(d)===ae)throw new SyntaxError("The string did not match the expected pattern.");const y=Ke(h);if(!y)throw new TypeError;if(y.length>1)throw new TypeError("Sum has more than one item");const S=function(T,k){const I=T.unit,U=T.value,N=Ze(I),L=Ze(k);return!L||N!==L?ae:new CSSUnitValue(U*L.ratios[I]/L.ratios[k],k)}(ut(y[0]),d);if(S===ae)throw new TypeError;return S}function ut(h){const[d,y]=h,S=Object.entries(y);if(S.length>1)return ae;if(S.length===0)return new CSSUnitValue(d,"number");const T=S[0];return T[1]!==1?ae:new CSSUnitValue(d,T[0])}function ht(h,...d){if(d&&d.length)throw new Error("Not implemented");const y=Ke(h).map(S=>ut(S));if(y.some(S=>S===ae))throw new TypeError("Type error");return new CSSMathSum(...y)}function rt(h,d){if(h.percentHint&&d.percentHint&&h.percentHint!==d.percentHint)return ae;const y={...h,percentHint:h.percentHint??d.percentHint};for(const S of lt)d[S]&&(y[S]??(y[S]=0),y[S]+=d[S]);return y}class Pe{constructor(d,y){Te(this,"name"),Te(this,"values"),this.name=d,this.values=y}}class Je{constructor(d,y){Te(this,"value"),Te(this,"associatedToken"),this.value=d,this.associatedToken=y}}function st(h){if(Array.isArray(h))return h;if(typeof h=="string")return function(d){const y=new R(d),S=[];for(;;){const T=pe(y);if(T===void 0)return S;S.push(T)}}(h);throw new TypeError("Invalid input type "+typeof h)}function Ge(h){const d=h.shift();return d instanceof P||d instanceof w||d instanceof M?function(y,S){let T;if(S instanceof P)T=O;else if(S instanceof M)T=E;else{if(!(S instanceof w))return;T=C}const k=new Je([],S);for(;;){const I=y.shift();if(I instanceof T||I===void 0)return k;y.unshift(I),k.value.push(Ge(y))}}(h,d):d instanceof t?function(y,S){const T=new Pe(y.value,[]);for(;;){const k=S.shift();if(k instanceof E||k===void 0)return T;S.unshift(k),T.values.push(Ge(S))}}(d,h):d}function ee(h){if(h instanceof M||h instanceof E)return 6;if(h instanceof l)switch(h.value){case"*":case"/":return 4;case"+":case"-":return 2}}function wt(h){return h[h.length-1]}function Lt(h,d,y){const S=["+","-"].includes(h.value)?"ADDITION":"MULTIPLICATION",T=d.type===S?d.values:[d],k=y.type===S?y.values:[y];return h.value==="-"?k[0]={type:"NEGATE",value:k[0]}:h.value==="/"&&(k[0]={type:"INVERT",value:k[0]}),{type:S,values:[...T,...k]}}function _t(h){if(h.type==="ADDITION")return new CSSMathSum(...h.values.map(d=>_t(d)));if(h.type==="MULTIPLICATION")return new CSSMathProduct(...h.values.map(d=>_t(d)));if(h.type==="NEGATE")return new CSSMathNegate(_t(h.value));if(h.type==="INVERT")return new CSSMathInvert(_t(h.value));if(h instanceof Je)return re(new Pe("calc",h.value));if(h instanceof e){if(h.value==="e")return new CSSUnitValue(Math.E,"number");if(h.value==="pi")return new CSSUnitValue(Math.PI,"number");throw new SyntaxError("Invalid math expression")}return Mo(h)}function re(h){if(h.name==="min"||h.name==="max"){const S=h.values.filter(T=>!(T instanceof m||T instanceof _)).map(T=>fe(re(new Pe("calc",T))));return h.name==="min"?new CSSMathMin(...S):new CSSMathMax(...S)}if(h.name!=="calc")return null;const d=_t(function(S){const T=[],k=[];for(;S.length;){const I=S.shift();if(I instanceof u||I instanceof f||I instanceof p||I instanceof Pe||I instanceof Je||I instanceof e)k.push(I);else if(I instanceof l&&["*","/","+","-"].includes(I.value)){for(;T.length&&!(wt(T)instanceof M)&&ee(wt(T))>ee(I);){const U=T.pop(),N=k.pop(),L=k.pop();k.push(Lt(U,L,N))}T.push(I)}else if(I instanceof M)T.push(I);else if(I instanceof E){if(!T.length)return null;for(;!(wt(T)instanceof M);){const U=T.pop(),N=k.pop(),L=k.pop();k.push(Lt(U,L,N))}if(!(wt(T)instanceof M))return null;T.pop()}else if(!(I instanceof m))return null}for(;T.length;){if(wt(T)instanceof M)return null;const I=T.pop(),U=k.pop(),N=k.pop();k.push(Lt(I,N,U))}return k[0]}([...h.values]));let y;try{y=fe(d)}catch{new CSSStyleSheet().insertRule("error",0)}return y instanceof CSSUnitValue?new CSSMathSum(y):y}function Mo(h){return h instanceof Pe&&["calc","min","max","clamp"].includes(h.name)?re(h):h instanceof u&&h.value===0&&!h.unit?new CSSUnitValue(0,"px"):h instanceof u?new CSSUnitValue(h.value,"number"):h instanceof p?new CSSUnitValue(h.value,"percent"):h instanceof f?new CSSUnitValue(h.value,h.unit):void 0}function vl(h){const d=function(y){const S=st(y);for(;S[0]instanceof m;)S.shift();if(S[0]===void 0)return null;const T=Ge(S);for(;S[0]instanceof m;)S.shift();return S[0]===void 0?T:null}(h);return d===null&&new CSSStyleSheet().insertRule("error",0),d instanceof u||d instanceof p||d instanceof f||d instanceof Pe||new CSSStyleSheet().insertRule("error",0),d instanceof f&&bt(d.unit)===null&&new CSSStyleSheet().insertRule("error",0),Mo(d)}(function(){let h=new WeakMap;function d(k){const I=[];for(let N=0;N<k.length;N++)I[N]=typeof(U=k[N])=="number"?new CSSUnitValue(U,"number"):U;var U;return I}class y{static parse(I){return I instanceof y?I:fe(vl(I),{})}}class S extends y{constructor(I,U,N,L){super(),h.set(this,{values:d(I),operator:U,name:N||U,delimiter:L||", "})}get operator(){return h.get(this).operator}get values(){return h.get(this).values}toString(){const I=h.get(this);return`${I.name}(${I.values.join(I.delimiter)})`}}const T={CSSNumericValue:y,CSSMathValue:S,CSSUnitValue:class extends y{constructor(k,I){super(),h.set(this,{value:k,unit:I})}get value(){return h.get(this).value}set value(k){h.get(this).value=k}get unit(){return h.get(this).unit}to(k){return xt(this,k)}toSum(...k){return ht(this,...k)}type(){return bt(h.get(this).unit)}toString(){const k=h.get(this);return`${k.value}${function(I){switch(I){case"percent":return"%";case"number":return"";default:return I.toLowerCase()}}(k.unit)}`}},CSSKeywordValue:class{constructor(k){this.value=k}toString(){return this.value.toString()}},CSSMathSum:class extends S{constructor(k){super(arguments,"sum","calc"," + ")}},CSSMathProduct:class extends S{constructor(k){super(arguments,"product","calc"," * ")}toSum(...k){return ht(this,...k)}type(){return h.get(this).values.map(k=>k.type()).reduce(rt)}},CSSMathNegate:class extends S{constructor(k){super([arguments[0]],"negate","-")}get value(){return h.get(this).values[0]}type(){return this.value.type()}},CSSMathInvert:class extends S{constructor(k){super([1,arguments[0]],"invert","calc"," / ")}get value(){return h.get(this).values[1]}type(){return function(k){const I={};for(const U of lt)I[U]=-1*k[U];return I}(h.get(this).values[1].type())}},CSSMathMax:class extends S{constructor(){super(arguments,"max")}},CSSMathMin:class extends S{constructor(){super(arguments,"min")}}};if(!window.CSS&&!Reflect.defineProperty(window,"CSS",{value:{}}))throw Error("Error installing CSSOM support");window.CSSUnitValue||["number","percent","em","ex","px","cm","mm","in","pt","pc","Q","vw","vh","vmin","vmax","rems","ch","deg","rad","grad","turn","ms","s","Hz","kHz","dppx","dpi","dpcm","fr"].forEach(k=>{if(!Reflect.defineProperty(CSS,k,{value:I=>new CSSUnitValue(I,k)}))throw Error(`Error installing CSS.${k}`)});for(let[k,I]of Object.entries(T))if(!(k in window)&&!Reflect.defineProperty(window,k,{value:I}))throw Error(`Error installing CSSOM support for ${k}`)})();const Co="block";let De=new WeakMap,Ft=new WeakMap;const Qi=["entry","exit","cover","contain","entry-crossing","exit-crossing"];function Eo(h){return h===document.scrollingElement?document:h}function an(h){es(h);let d=De.get(h).animations;if(d.length===0)return;let y=h.currentTime;for(let S=0;S<d.length;S++)d[S].tickAnimation(y)}function Po(h,d){if(!h)return null;const y=Ft.get(h).sourceMeasurements,S=getComputedStyle(h);let T=y.scrollTop;return je(d,S)==="x"&&(T=Math.abs(y.scrollLeft)),T}function $r(h,d){const y=fe(h,d);if(y instanceof CSSUnitValue){if(y.unit==="px")return y.value;throw TypeError("Unhandled unit type "+y.unit)}throw TypeError("Unsupported value type: "+typeof h)}function es(h){if(!(h instanceof Mn))return void function(y){const S=De.get(y);if(!S.anonymousSource)return;const T=Ro(S.anonymousSource,S.anonymousTarget);Hn(y,T)}(h);const d=h.subject;if(!d||getComputedStyle(d).display=="none")return void Hn(h,null);Hn(h,os(d))}function ko(h){return["block","inline","x","y"].includes(h)}function ts(h){const d=getComputedStyle(h);return{scrollLeft:h.scrollLeft,scrollTop:h.scrollTop,scrollWidth:h.scrollWidth,scrollHeight:h.scrollHeight,clientWidth:h.clientWidth,clientHeight:h.clientHeight,writingMode:d.writingMode,direction:d.direction,scrollPaddingTop:d.scrollPaddingTop,scrollPaddingBottom:d.scrollPaddingBottom,scrollPaddingLeft:d.scrollPaddingLeft,scrollPaddingRight:d.scrollPaddingRight}}function ns(h,d){if(!h||!d)return;let y=0,S=0,T=d;const k=h.offsetParent;for(;T&&T!=k;)S+=T.offsetLeft,y+=T.offsetTop,T=T.offsetParent;S-=h.offsetLeft+h.clientLeft,y-=h.offsetTop+h.clientTop;const I=getComputedStyle(d);return{top:y,left:S,offsetWidth:d.offsetWidth,offsetHeight:d.offsetHeight,fontSize:I.fontSize}}function $i(h){let d=Ft.get(h);d.sourceMeasurements=ts(h);for(const y of d.timelineRefs){const S=y.deref();S instanceof Mn&&(De.get(S).subjectMeasurements=ns(h,S.subject))}d.updateScheduled||(setTimeout(()=>{for(const y of d.timelineRefs){const S=y.deref();S&&an(S)}d.updateScheduled=!1}),d.updateScheduled=!0)}function Hn(h,d){const y=De.get(h),S=y.source;if(S!=d){if(S){const T=Ft.get(S);if(T){T.timelineRefs.delete(h);const k=Array.from(T.timelineRefs).filter(I=>I.deref()===void 0);for(const I of k)T.timelineRefs.delete(I);T.timelineRefs.size===0&&(T.disconnect(),Ft.delete(S))}}if(y.source=d,d){let T=Ft.get(d);if(!T){T={timelineRefs:new Set,sourceMeasurements:ts(d)},Ft.set(d,T);const k=new ResizeObserver(N=>{for(const L of N)$i(y.source)});k.observe(d);for(const N of d.children)k.observe(N);const I=new MutationObserver(N=>{for(const L of N)$i(L.target)});I.observe(d,{attributes:!0,attributeFilter:["style","class"]});const U=()=>{T.sourceMeasurements.scrollLeft=d.scrollLeft,T.sourceMeasurements.scrollTop=d.scrollTop;for(const N of T.timelineRefs){const L=N.deref();L&&an(L)}};Eo(d).addEventListener("scroll",U),T.disconnect=()=>{k.disconnect(),I.disconnect(),Eo(d).removeEventListener("scroll",U)}}T.timelineRefs.add(new WeakRef(h))}}}function is(h,d){let y=De.get(h).animations;for(let S=0;S<y.length;S++)y[S].animation==d&&y.splice(S,1)}function rs(h,d,y){let S=De.get(h).animations;for(let T=0;T<S.length;T++)if(S[T].animation==d)return;S.push({animation:d,tickAnimation:y}),queueMicrotask(()=>{an(h)})}class We{constructor(d){if(De.set(this,{source:null,axis:Co,anonymousSource:d?d.anonymousSource:null,anonymousTarget:d?d.anonymousTarget:null,subject:null,inset:null,animations:[],subjectMeasurements:null}),Hn(this,d&&d.source!==void 0?d.source:document.scrollingElement),d&&d.axis!==void 0&&d.axis!=Co){if(!ko(d.axis))throw TypeError("Invalid axis");De.get(this).axis=d.axis}an(this)}set source(d){Hn(this,d),an(this)}get source(){return De.get(this).source}set axis(d){if(!ko(d))throw TypeError("Invalid axis");De.get(this).axis=d,an(this)}get axis(){return De.get(this).axis}get duration(){return CSS.percent(100)}get phase(){const d=this.source;if(!d)return"inactive";let y=getComputedStyle(d);return y.display=="none"?"inactive":d==document.scrollingElement||y.overflow!="visible"&&y.overflow!="clip"?"active":"inactive"}get currentTime(){const d=this.source;if(!d||!d.isConnected||this.phase=="inactive")return null;const y=getComputedStyle(d);if(y.display==="inline"||y.display==="none")return null;const S=this.axis,T=Po(d,S),k=function(I,U){const N=Ft.get(I).sourceMeasurements,L=getComputedStyle(I).writingMode=="horizontal-tb";return U==="block"?U=L?"y":"x":U==="inline"&&(U=L?"x":"y"),U==="y"?N.scrollHeight-N.clientHeight:U==="x"?N.scrollWidth-N.clientWidth:void 0}(d,S);return k>0?CSS.percent(100*T/k):CSS.percent(100)}get __polyfill(){return!0}}function ss(h,d){let y=h.parentElement;for(;y!=null;){if(d(y))return y;y=y.parentElement}}function Ro(h,d){switch(h){case"root":return document.scrollingElement;case"nearest":return os(d);case"self":return d;default:throw new TypeError("Invalid ScrollTimeline Source Type.")}}function Sl(h){switch(getComputedStyle(h).display){case"block":case"inline-block":case"list-item":case"table":case"table-caption":case"flow-root":case"flex":case"grid":return!0}return!1}function Ao(h){const d=getComputedStyle(h);return d.transform!="none"||d.perspective!="none"||d.willChange=="transform"||d.willChange=="perspective"||d.filter!="none"||d.willChange=="filter"||d.backdropFilter!="none"}function bl(h){return getComputedStyle(h).position!="static"||Ao(h)}function xl(h){switch(getComputedStyle(h).position){case"static":case"relative":case"sticky":return ss(h,Sl);case"absolute":return ss(h,bl);case"fixed":return ss(h,Ao)}}function os(h){if(h&&h.isConnected){for(;h=xl(h);)switch(getComputedStyle(h)["overflow-x"]){case"auto":case"scroll":case"hidden":return h==document.body&&getComputedStyle(document.scrollingElement).overflow=="visible"?document.scrollingElement:h}return document.scrollingElement}}function qn(h,d){const y=De.get(h),S=y.subjectMeasurements,T=Ft.get(y.source).sourceMeasurements;return h.phase==="inactive"?null:h instanceof Mn?as(d,T,S,y.axis,y.inset):null}function as(h,d,y,S,T){const k=d.direction=="rtl"||d.writingMode=="vertical-rl";let I,U,N={fontSize:y.fontSize};je(S,d)==="x"?(I=y.offsetWidth,U=y.left,N.scrollPadding=[d.scrollPaddingLeft,d.scrollPaddingRight],k&&(U+=d.scrollWidth-d.clientWidth,N.scrollPadding=[d.scrollPaddingRight,d.scrollPaddingLeft]),N.containerSize=d.clientWidth):(I=y.offsetHeight,U=y.top,N.scrollPadding=[d.scrollPaddingTop,d.scrollPaddingBottom],N.containerSize=d.clientHeight);const L=function(hs,rr){const Il={start:0,end:0};if(!hs)return Il;const[zl,Bl]=[hs.start,hs.end].map((Ho,qo)=>Ho==="auto"?rr.scrollPadding[qo]==="auto"?0:parseFloat(rr.scrollPadding[qo]):$r(Ho,{percentageReference:CSS.px(rr.containerSize),fontSize:CSS.px(parseFloat(rr.fontSize))}));return{start:zl,end:Bl}}(T,N),X=U-N.containerSize+L.end,Z=U+I-L.start,K=X+I,he=Z-I,we=Math.min(K,he),Qe=Math.max(K,he);let Tt,dt;const Wo=I>N.containerSize-L.start-L.end;switch(h){case"cover":Tt=X,dt=Z;break;case"contain":Tt=we,dt=Qe;break;case"entry":Tt=X,dt=we;break;case"exit":Tt=Qe,dt=Z;break;case"entry-crossing":Tt=X,dt=Wo?Qe:we;break;case"exit-crossing":Tt=Wo?we:Qe,dt=Z}return{start:Tt,end:dt}}function Oo(h,d){if(h instanceof Mn){const{rangeName:y,offset:S}=d;return Io(qn(h,y),S,qn(h,"cover"),h.subject)}if(h instanceof We){const{axis:y,source:S}=h,{sourceMeasurements:T}=Ft.get(S);let k;return k=je(y,T)==="x"?T.scrollWidth-T.clientWidth:T.scrollHeight-T.clientHeight,$r(d,{percentageReference:CSS.px(k)})/k}unsupportedTimeline(h)}function Io(h,d,y,S){if(!h||!y)return 0;let T=getComputedStyle(S);return($r(d,{percentageReference:CSS.px(h.end-h.start),fontSize:CSS.px(parseFloat(T.fontSize))})+h.start-y.start)/(y.end-y.start)}let Mn=class extends We{constructor(h){super(h);const d=De.get(this);d.subject=h&&h.subject?h.subject:void 0,h&&h.inset&&(d.inset=function(y){if(!y)return{start:0,end:0};let S;if(S=typeof y=="string"?Ye(y).map(T=>{if(T==="auto")return"auto";try{return CSSNumericValue.parse(T)}catch{throw TypeError(`Could not parse inset "${y}"`)}}):Array.isArray(y)?y:[y],S.length===0||S.length>2)throw TypeError("Invalid inset");for(const T of S){if(T==="auto")continue;const k=T.type();if(k.length!==1&&k.percent!==1)throw TypeError("Invalid inset")}return{start:S[0],end:S[1]??S[0]}}(h.inset)),d.subject&&(new ResizeObserver(()=>{$i(d.source)}).observe(d.subject),new MutationObserver(()=>{$i(d.source)}).observe(d.subject,{attributes:!0,attributeFilter:["class","style"]})),es(this),d.subjectMeasurements=ns(d.source,d.subject),an(this)}get source(){return es(this),De.get(this).source}set source(h){throw new Error("Cannot set the source of a view timeline")}get subject(){return De.get(this).subject}get axis(){return De.get(this).axis}get currentTime(){const h=Po(this.source,this.axis);if(h==null)return null;const d=qn(this,"cover");if(!d)return null;const y=(h-d.start)/(d.end-d.start);return CSS.percent(100*y)}get startOffset(){return CSS.px(qn(this,"cover").start)}get endOffset(){return CSS.px(qn(this,"cover").end)}};const wl=document.getAnimations,_l=window.Element.prototype.getAnimations,Tl=window.Element.prototype.animate,zo=window.Animation;class Cn{constructor(){this.state="pending",this.nativeResolve=this.nativeReject=null,this.promise=new Promise((d,y)=>{this.nativeResolve=d,this.nativeReject=y})}resolve(d){this.state="resolved",this.nativeResolve(d)}reject(d){this.state="rejected",this.promise.catch(()=>{}),this.nativeReject(d)}}function Xn(h){h.readyPromise=new Cn,requestAnimationFrame(()=>{var d;(((d=h.timeline)==null?void 0:d.currentTime)??null)!==null&&(er(h),h.pendingTask!=="play"||h.startTime===null&&h.holdTime===null?h.pendingTask==="pause"&&Uo(h):No(h))})}function Bo(){return new DOMException("The user aborted a request","AbortError")}function cn(h,d){if(d===null)return d;if(typeof d!="number")throw new DOMException(`Unexpected value: ${d}. Cannot convert to CssNumberish`,"InvalidStateError");const y=h.rangeDuration??100,S=jt(h),T=S?y*d/S:0;return CSS.percent(T)}function ge(h,d){if(h.timeline){if(d===null)return d;if(d.unit==="percent"){const y=h.rangeDuration??100,S=jt(h);return d.value*S/y}throw new DOMException("CSSNumericValue must be a percentage for progress based animations.","NotSupportedError")}{if(d==null||typeof d=="number")return d;const y=d.to("ms");if(y)return y.value;throw new DOMException("CSSNumericValue must be either a number or a time value for time based animations.","InvalidStateError")}}function No(h){const d=ge(h,h.timeline.currentTime);if(h.holdTime!=null)At(h),h.animation.playbackRate==0?h.startTime=d:(h.startTime=d-h.holdTime/h.animation.playbackRate,h.holdTime=null);else if(h.startTime!==null&&h.pendingPlaybackRate!==null){const y=(d-h.startTime)*h.animation.playbackRate;At(h);const S=h.animation.playbackRate;S==0?(h.holdTime=null,h.startTime=d):h.startTime=d-y/S}h.readyPromise&&h.readyPromise.state=="pending"&&h.readyPromise.resolve(h.proxy),Vt(h,!1,!1),Jt(h),h.pendingTask=null}function Uo(h){const d=ge(h,h.timeline.currentTime);h.startTime!=null&&h.holdTime==null&&(h.holdTime=(d-h.startTime)*h.animation.playbackRate),At(h),h.startTime=null,h.readyPromise.resolve(h.proxy),Vt(h,!1,!1),Jt(h),h.pendingTask=null}function Do(h){if(!h.finishedPromise||h.finishedPromise.state!="pending"||h.proxy.playState!="finished")return;h.finishedPromise.resolve(h.proxy),h.animation.pause();const d=new CustomEvent("finish",{detail:{currentTime:h.proxy.currentTime,timelineTime:h.proxy.timeline.currentTime}});Object.defineProperty(d,"currentTime",{get:function(){return this.detail.currentTime}}),Object.defineProperty(d,"timelineTime",{get:function(){return this.detail.timelineTime}}),requestAnimationFrame(()=>{queueMicrotask(()=>{h.animation.dispatchEvent(d)})})}function En(h){return h.pendingPlaybackRate!==null?h.pendingPlaybackRate:h.animation.playbackRate}function At(h){h.pendingPlaybackRate!==null&&(h.animation.playbackRate=h.pendingPlaybackRate,h.pendingPlaybackRate=null)}function Lo(h){if(!h.timeline)return null;const d=ge(h,h.timeline.currentTime);if(d===null||h.startTime===null)return null;let y=(d-h.startTime)*h.animation.playbackRate;return y==-0&&(y=0),y}function Vt(h,d,y){if(!h.timeline)return;let S=d?ge(h,h.proxy.currentTime):Lo(h);if(S&&h.startTime!=null&&!h.proxy.pending){const T=En(h),k=jt(h);let I=h.previousCurrentTime;T>0&&S>=k&&h.previousCurrentTime!=null?((I===null||I<k)&&(I=k),h.holdTime=d?S:I):T<0&&S<=0?((I==null||I>0)&&(I=0),h.holdTime=d?S:I):T!=0&&(d&&h.holdTime!==null&&(h.startTime=function(U,N){if(!U.timeline)return null;const L=ge(U,U.timeline.currentTime);return L==null?null:L-N/U.animation.playbackRate}(h,h.holdTime)),h.holdTime=null)}Jt(h),h.previousCurrentTime=ge(h,h.proxy.currentTime),h.proxy.playState=="finished"?(h.finishedPromise||(h.finishedPromise=new Cn),h.finishedPromise.state=="pending"&&(y?Do(h):Promise.resolve().then(()=>{Do(h)}))):(h.finishedPromise&&h.finishedPromise.state=="resolved"&&(h.finishedPromise=new Cn),h.animation.playState!="paused"&&h.animation.pause())}function jt(h){const d=function(S){const T=S.proxy.effect.getTiming();return S.normalizedTiming||T}(h),y=d.delay+d.endDelay+d.iterations*d.duration;return Math.max(0,y)}function Jt(h){if(h.timeline)if(h.startTime!==null){const d=h.timeline.currentTime;if(d==null)return;cs(h,(ge(h,d)-h.startTime)*h.animation.playbackRate)}else h.holdTime!==null&&cs(h,h.holdTime)}function cs(h,d){const y=h.timeline,S=h.animation.playbackRate,T=y.currentTime&&y.currentTime.value==(S<0?0:100)?S<0?.001:-.001:0;h.animation.currentTime=d+T}function ls(h,d){if(!h.timeline)return;const y=h.proxy.playState=="paused"&&h.proxy.pending;let S=!1,T=ge(h,h.proxy.currentTime);En(h)==0&&T==null&&(h.holdTime=0),T==null&&(h.autoAlignStartTime=!0),(h.proxy.playState==="finished"||y)&&(h.holdTime=null,h.startTime=null,h.autoAlignStartTime=!0),h.holdTime&&(h.startTime=null),h.pendingTask&&(h.pendingTask=null,S=!0),(h.holdTime!==null||h.autoAlignStartTime||y||h.pendingPlaybackRate!==null)&&(h.readyPromise&&!S&&(h.readyPromise=null),Jt(h),h.readyPromise||Xn(h),h.pendingTask="play",rs(h.timeline,h.animation,us.bind(h.proxy)),Vt(h,!1,!1))}function us(h){const d=Y.get(this);if(!d)return;if(h==null)return void(d.proxy.playState!=="paused"&&d.animation.playState!="idle"&&d.animation.cancel());er(d),d.pendingTask&&requestAnimationFrame(()=>{d.pendingTask!=="play"||d.startTime===null&&d.holdTime===null?d.pendingTask==="pause"&&Uo(d):No(d)});const y=this.playState;if(y=="running"||y=="finished"){const S=ge(d,h);cs(d,(S-ge(d,this.startTime))*this.playbackRate),Vt(d,!1,!1)}}function Fo(h){h.specifiedTiming=null}let Y=new WeakMap;window.addEventListener("pagehide",h=>{Y=new WeakMap},!1);let Vo=new WeakMap;function er(h){if(!h.autoAlignStartTime||!h.timeline||!h.timeline.currentTime||h.proxy.playState==="idle"||h.proxy.playState==="paused"&&h.holdTime!==null)return;const d=h.rangeDuration;let y,S;try{y=CSS.percent(100*function(k){if(!k.animationRange)return 0;const I=k.animationRange.start==="normal"?jo(k.timeline):k.animationRange.start;return Oo(k.timeline,I)}(h))}catch(k){y=CSS.percent(0),h.animationRange.start="normal",console.warn("Exception when calculating start offset",k)}try{S=CSS.percent(100*(1-function(k){if(!k.animationRange)return 0;const I=k.animationRange.end==="normal"?Jo(k.timeline):k.animationRange.end;return 1-Oo(k.timeline,I)}(h)))}catch(k){S=CSS.percent(100),h.animationRange.end="normal",console.warn("Exception when calculating end offset",k)}h.rangeDuration=S.value-y.value;const T=En(h);h.startTime=ge(h,T>=0?y:S),h.holdTime=null,h.rangeDuration!==d&&Fo(h)}function tr(h){throw new Error("Unsupported timeline class")}function jo(h){return h instanceof ViewTimeline?{rangeName:"cover",offset:CSS.percent(0)}:h instanceof We?CSS.percent(0):void tr()}function Jo(h){return h instanceof ViewTimeline?{rangeName:"cover",offset:CSS.percent(100)}:h instanceof We?CSS.percent(100):void tr()}function Ml(h,d){if(!d)return{start:"normal",end:"normal"};const y={start:jo(h),end:Jo(h)};if(h instanceof ViewTimeline){const S=Ye(d),T=[],k=[];if(S.forEach(I=>{if(Qi.includes(I))T.push(I);else try{k.push(CSSNumericValue.parse(I))}catch{throw TypeError(`Could not parse range "${d}"`)}}),T.length>2||k.length>2||k.length==1)throw TypeError("Invalid time range or unsupported time range format.");return T.length&&(y.start.rangeName=T[0],y.end.rangeName=T.length>1?T[1]:T[0]),k.length>1&&(y.start.offset=k[0],y.end.offset=k[1]),y}if(h instanceof We){const S=d.split(" ");if(S.length!=2)throw TypeError("Invalid time range or unsupported time range format.");return y.start=CSSNumericValue.parse(S[0]),y.end=CSSNumericValue.parse(S[1]),y}tr()}function nr(h,d,y){if(!d||d==="normal")return"normal";if(h instanceof ViewTimeline){let S="cover",T=y==="start"?CSS.percent(0):CSS.percent(100);if(d instanceof Object)d.rangeName!==void 0&&(S=d.rangeName),d.offset!==void 0&&(T=d.offset);else{const k=Ye(d);k.length===1?Qi.includes(k[0])?S=k[0]:T=fe(CSSNumericValue.parse(k[0]),{}):k.length===2&&(S=k[0],T=fe(CSSNumericValue.parse(k[1]),{}))}if(!Qi.includes(S))throw TypeError("Invalid range name");return{rangeName:S,offset:T}}if(h instanceof We)return CSSNumericValue.parse(d);tr()}class ir{constructor(d,y,S={}){const T=y instanceof We,k=d instanceof zo?d:new zo(d,T?void 0:y);Vo.set(k,this),Y.set(this,{animation:k,timeline:T?y:void 0,playState:T?"idle":null,readyPromise:null,finishedPromise:null,startTime:null,holdTime:null,rangeDuration:null,previousCurrentTime:null,autoAlignStartTime:!1,pendingPlaybackRate:null,pendingTask:null,specifiedTiming:null,normalizedTiming:null,effect:null,animationRange:T?Ml(y,S["animation-range"]):null,proxy:this})}get effect(){const d=Y.get(this);return d.timeline?(d.effect||(d.effect=function(y){const S=y.animation.effect,T=S.updateTiming,k={apply:function(L){S.getTiming();const X=L.apply(S);if(y.timeline){const Z=y.duration??100;X.localTime=cn(y,X.localTime),X.endTime=cn(y,X.endTime),X.activeDuration=cn(y,X.activeDuration);const K=jt(y),he=X.iterations?(K-X.delay-X.endDelay)/X.iterations:0;X.duration=K?CSS.percent(Z*he/K):CSS.percent(0),y.timeline.currentTime===void 0&&(X.localTime=null)}return X}},I={apply:function(L,X){if(y.specifiedTiming)return y.specifiedTiming;y.specifiedTiming=L.apply(S);let Z,K=Object.assign({},y.specifiedTiming);if(K.duration===1/0)throw TypeError("Effect duration cannot be Infinity when used with Scroll Timelines");return(K.duration===null||K.duration==="auto"||y.autoDurationEffect)&&y.timeline&&(y.autoDurationEffect=!0,K.delay=0,K.endDelay=0,Z=K.iterations?1e5:0,K.duration=K.iterations?(Z-K.delay-K.endDelay)/K.iterations:0,K.duration<0&&(K.duration=0,K.endDelay=Z-K.delay),T.apply(S,[K])),y.normalizedTiming=K,y.specifiedTiming}},U={apply:function(L,X,Z){if(Z&&Z.length){if(y.timeline&&Z[0]){const K=Z[0],he=K.duration;if(he===1/0)throw TypeError("Effect duration cannot be Infinity when used with Scroll Timelines");if(K.iterations===1/0)throw TypeError("Effect iterations cannot be Infinity when used with Scroll Timelines");he!==void 0&&he!=="auto"&&(y.autoDurationEffect=null)}y.specifiedTiming&&L.apply(S,[y.specifiedTiming]),L.apply(S,Z),Fo(y)}}},N=new Proxy(S,{get:function(L,X){const Z=L[X];return typeof Z=="function"?Z.bind(S):Z},set:function(L,X,Z){return L[X]=Z,!0}});return N.getComputedTiming=new Proxy(S.getComputedTiming,k),N.getTiming=new Proxy(S.getTiming,I),N.updateTiming=new Proxy(S.updateTiming,U),N}(d)),d.effect):d.animation.effect}set effect(d){const y=Y.get(this);y.animation.effect=d,y.effect=null,y.autoDurationEffect=null}get timeline(){const d=Y.get(this);return d.timeline||d.animation.timeline}set timeline(d){const y=Y.get(this),S=this.timeline;if(S==d)return;const T=this.playState,k=this.currentTime;let I,U=jt(y);I=k===null?null:U===0?0:ge(y,k)/U;const N=S instanceof We,L=d instanceof We,X=this.pending;if(N&&is(y.timeline,y.animation),L)return y.timeline=d,At(y),y.autoAlignStartTime=!0,y.startTime=null,y.holdTime=null,T!=="running"&&T!=="finished"||(y.readyPromise&&y.readyPromise.state!=="resolved"||Xn(y),y.pendingTask="play",rs(y.timeline,y.animation,us.bind(this))),T==="paused"&&I!==null&&(y.holdTime=I*U),X&&(y.readyPromise&&y.readyPromise.state!="resolved"||Xn(y),y.pendingTask=T=="paused"?"pause":"play"),y.startTime!==null&&(y.holdTime=null),void Vt(y,!1,!1);if(y.animation.timeline!=d)throw TypeError("Unsupported timeline: "+d);if(is(y.timeline,y.animation),y.timeline=null,N)switch(k!==null&&(y.animation.currentTime=I*jt(y)),T){case"paused":y.animation.pause();break;case"running":case"finished":y.animation.play()}}get startTime(){const d=Y.get(this);return d.timeline?cn(d,d.startTime):d.animation.startTime}set startTime(d){const y=Y.get(this);if(d=ge(y,d),!y.timeline)return void(y.animation.startTime=d);y.autoAlignStartTime=!1,ge(y,y.timeline.currentTime)==null&&y.startTime!=null&&(y.holdTime=null,Jt(y));const S=ge(y,this.currentTime);At(y),y.startTime=d,y.startTime!==null&&y.animation.playbackRate!=0?y.holdTime=null:y.holdTime=S,y.pendingTask&&(y.pendingTask=null,y.readyPromise.resolve(this)),Vt(y,!0,!1),Jt(y)}get currentTime(){const d=Y.get(this);return d.timeline?d.holdTime!=null?cn(d,d.holdTime):cn(d,Lo(d)):d.animation.currentTime}set currentTime(d){const y=Y.get(this);y.timeline?(function(S,T){if(T==null&&S.currentTime!==null)throw new TypeError;T=ge(S,T),S.autoAlignStartTime=!1,S.holdTime!==null||S.startTime===null||S.timeline.phase==="inactive"||S.animation.playbackRate===0?S.holdTime=T:S.startTime=ge(S,S.timeline.currentTime)-T/S.animation.playbackRate,S.timeline.phase==="inactive"&&(S.startTime=null),S.previousCurrentTime=null}(y,d),y.pendingTask=="pause"&&(y.holdTime=ge(y,d),At(y),y.startTime=null,y.pendingTask=null,y.readyPromise.resolve(this)),Vt(y,!0,!1)):y.animation.currentTime=d}get playbackRate(){return Y.get(this).animation.playbackRate}set playbackRate(d){const y=Y.get(this);if(!y.timeline)return void(y.animation.playbackRate=d);y.pendingPlaybackRate=null;const S=this.currentTime;y.animation.playbackRate=d,S!==null&&(this.currentTime=S)}get playState(){const d=Y.get(this);if(!d.timeline)return d.animation.playState;const y=ge(d,this.currentTime);return y===null&&d.startTime===null&&d.pendingTask==null?"idle":d.pendingTask=="pause"||d.startTime===null&&d.pendingTask!="play"?"paused":y!=null&&(d.animation.playbackRate>0&&y>=jt(d)||d.animation.playbackRate<0&&y<=0)?"finished":"running"}get rangeStart(){var d;return((d=Y.get(this).animationRange)==null?void 0:d.start)??"normal"}set rangeStart(d){const y=Y.get(this);if(!y.timeline)return y.animation.rangeStart=d;y.timeline instanceof We&&(y.animationRange.start=nr(y.timeline,d,"start"),er(y),Jt(y))}get rangeEnd(){var d;return((d=Y.get(this).animationRange)==null?void 0:d.end)??"normal"}set rangeEnd(d){const y=Y.get(this);if(!y.timeline)return y.animation.rangeEnd=d;y.timeline instanceof We&&(y.animationRange.end=nr(y.timeline,d,"end"),er(y),Jt(y))}get replaceState(){return Y.get(this).animation.pending}get pending(){const d=Y.get(this);return d.timeline?!!d.readyPromise&&d.readyPromise.state=="pending":d.animation.pending}finish(){const d=Y.get(this);if(!d.timeline)return void d.animation.finish();const y=En(d),S=jt(d);if(y==0)throw new DOMException("Cannot finish Animation with a playbackRate of 0.","InvalidStateError");if(y>0&&S==1/0)throw new DOMException("Cannot finish Animation with an infinite target effect end.","InvalidStateError");At(d);const T=y<0?0:S;this.currentTime=cn(d,T);const k=ge(d,d.timeline.currentTime);d.startTime===null&&k!==null&&(d.startTime=k-T/d.animation.playbackRate),d.pendingTask=="pause"&&d.startTime!==null&&(d.holdTime=null,d.pendingTask=null,d.readyPromise.resolve(this)),d.pendingTask=="play"&&d.startTime!==null&&(d.pendingTask=null,d.readyPromise.resolve(this)),Vt(d,!0,!0)}play(){const d=Y.get(this);d.timeline?ls(d):d.animation.play()}pause(){const d=Y.get(this);d.timeline?this.playState!="paused"&&(d.animation.currentTime===null&&(d.autoAlignStartTime=!0),d.pendingTask=="play"?d.pendingTask=null:d.readyPromise=null,d.readyPromise||Xn(d),d.pendingTask="pause",rs(d.timeline,d.animation,us.bind(d.proxy))):d.animation.pause()}reverse(){const d=Y.get(this),y=En(d),S=ge(d,this.currentTime),T=jt(d)==1/0,k=y!=0&&(y<0||S>0||!T);if(!d.timeline||!k)return k&&(d.pendingPlaybackRate=-En(d)),void d.animation.reverse();if(d.timeline.phase=="inactive")throw new DOMException("Cannot reverse an animation with no active timeline","InvalidStateError");this.updatePlaybackRate(-y),ls(d)}updatePlaybackRate(d){const y=Y.get(this);if(y.pendingPlaybackRate=d,!y.timeline)return void y.animation.updatePlaybackRate(d);const S=this.playState;if(!y.readyPromise||y.readyPromise.state!="pending")switch(S){case"idle":case"paused":At(y);break;case"finished":const T=ge(y,y.timeline.currentTime),k=T!==null?(T-y.startTime)*y.animation.playbackRate:null;y.startTime=d==0?T:T!=null&&k!=null?(T-k)/d:null,At(y),Vt(y,!1,!1),Jt(y);break;default:ls(y)}}persist(){Y.get(this).animation.persist()}get id(){return Y.get(this).animation.id}set id(d){Y.get(this).animation.id=d}cancel(){const d=Y.get(this);d.timeline?(this.playState!="idle"&&(function(y){y.pendingTask&&(y.pendingTask=null,At(y),y.readyPromise.reject(Bo()),Xn(y),y.readyPromise.resolve(y.proxy))}(d),d.finishedPromise&&d.finishedPromise.state=="pending"&&d.finishedPromise.reject(Bo()),d.finishedPromise=new Cn,d.animation.cancel()),d.startTime=null,d.holdTime=null,is(d.timeline,d.animation)):d.animation.cancel()}get onfinish(){return Y.get(this).animation.onfinish}set onfinish(d){Y.get(this).animation.onfinish=d}get oncancel(){return Y.get(this).animation.oncancel}set oncancel(d){Y.get(this).animation.oncancel=d}get onremove(){return Y.get(this).animation.onremove}set onremove(d){Y.get(this).animation.onremove=d}get finished(){const d=Y.get(this);return d.timeline?(d.finishedPromise||(d.finishedPromise=new Cn),d.finishedPromise.promise):d.animation.finished}get ready(){const d=Y.get(this);return d.timeline?(d.readyPromise||(d.readyPromise=new Cn,d.readyPromise.resolve(this)),d.readyPromise.promise):d.animation.ready}addEventListener(d,y,S){Y.get(this).animation.addEventListener(d,y,S)}removeEventListener(d,y,S){Y.get(this).animation.removeEventListener(d,y,S)}dispatchEvent(d){Y.get(this).animation.dispatchEvent(d)}}function Cl(h,d){const y=d.timeline;y instanceof We&&delete d.timeline;const S=Tl.apply(this,[h,d]),T=new ir(S,y);return y instanceof We&&(S.pause(),Y.get(T).animationRange={start:nr(y,d.rangeStart,"start"),end:nr(y,d.rangeEnd,"end")},T.play()),T}function Go(h){for(let d=0;d<h.length;++d){let y=Vo.get(h[d]);y&&(h[d]=y)}return h}function El(h){return Go(_l.apply(this,[h]))}function Pl(h){return Go(wl.apply(this,[h]))}const ke={IDENTIFIER:/[\w\\\@_-]+/g,WHITE_SPACE:/\s*/g,TIME:/^[0-9]+(s|ms)/,SCROLL_TIMELINE:/scroll-timeline\s*:([^;}]+)/,SCROLL_TIMELINE_NAME:/scroll-timeline-name\s*:([^;}]+)/,SCROLL_TIMELINE_AXIS:/scroll-timeline-axis\s*:([^;}]+)/,VIEW_TIMELINE:/view-timeline\s*:([^;}]+)/,VIEW_TIMELINE_NAME:/view-timeline-name\s*:([^;}]+)/,VIEW_TIMELINE_AXIS:/view-timeline-axis\s*:([^;}]+)/,VIEW_TIMELINE_INSET:/view-timeline-inset\s*:([^;}]+)/,ANIMATION_TIMELINE:/animation-timeline\s*:([^;}]+)/,ANIMATION_TIME_RANGE:/animation-range\s*:([^;}]+)/,ANIMATION_NAME:/animation-name\s*:([^;}]+)/,ANIMATION:/animation\s*:([^;}]+)/,ANONYMOUS_SCROLL_TIMELINE:/scroll\(([^)]*)\)/,ANONYMOUS_VIEW_TIMELINE:/view\(([^)]*)\)/},Pn=["block","inline","x","y"],kl=["nearest","root","self"],Kt=new class{constructor(){this.cssRulesWithTimelineName=[],this.nextAnonymousTimelineNameIndex=0,this.anonymousScrollTimelineOptions=new Map,this.anonymousViewTimelineOptions=new Map,this.sourceSelectorToScrollTimeline=[],this.subjectSelectorToViewTimeline=[],this.keyframeNamesSelectors=new Map}transpileStyleSheet(h,d,y){const S={sheetSrc:h,index:0,name:y};for(;S.index<S.sheetSrc.length&&(this.eatWhitespace(S),!(S.index>=S.sheetSrc.length));){if(this.lookAhead("/*",S)){for(;this.lookAhead("/*",S);)this.eatComment(S),this.eatWhitespace(S);continue}const T=this.parseQualifiedRule(S);T&&(d?this.parseKeyframesAndSaveNameMapping(T,S):this.handleScrollTimelineProps(T,S))}return S.sheetSrc}getAnimationTimelineOptions(h,d){for(let y=this.cssRulesWithTimelineName.length-1;y>=0;y--){const S=this.cssRulesWithTimelineName[y];try{if(d.matches(S.selector)&&(!S["animation-name"]||S["animation-name"]==h))return{"animation-timeline":S["animation-timeline"],"animation-range":S["animation-range"]}}catch{}}return null}getAnonymousScrollTimelineOptions(h,d){const y=this.anonymousScrollTimelineOptions.get(h);return y?{anonymousSource:y.source,anonymousTarget:d,source:Ro(y.source??"nearest",d),axis:y.axis?y.axis:"block"}:null}getScrollTimelineOptions(h,d){const y=this.getAnonymousScrollTimelineOptions(h,d);if(y)return y;for(let S=this.sourceSelectorToScrollTimeline.length-1;S>=0;S--){const T=this.sourceSelectorToScrollTimeline[S];if(T.name==h){const k=this.findPreviousSiblingOrAncestorMatchingSelector(d,T.selector);if(k)return{source:k,...T.axis?{axis:T.axis}:{}}}}return null}findPreviousSiblingOrAncestorMatchingSelector(h,d){let y=h;for(;y;){if(y.matches(d))return y;y=y.previousElementSibling||y.parentElement}return null}getAnonymousViewTimelineOptions(h,d){const y=this.anonymousViewTimelineOptions.get(h);return y?{subject:d,axis:y.axis?y.axis:"block",inset:y.inset?y.inset:"auto"}:null}getViewTimelineOptions(h,d){const y=this.getAnonymousViewTimelineOptions(h,d);if(y)return y;for(let S=this.subjectSelectorToViewTimeline.length-1;S>=0;S--){const T=this.subjectSelectorToViewTimeline[S];if(T.name==h){const k=this.findPreviousSiblingOrAncestorMatchingSelector(d,T.selector);if(k)return{subject:k,axis:T.axis,inset:T.inset}}}return null}handleScrollTimelineProps(h,d){if(h.selector.includes("@keyframes"))return;const y=h.block.contents.includes("animation-name:"),S=h.block.contents.includes("animation-timeline:"),T=h.block.contents.includes("animation:");if(this.saveSourceSelectorToScrollTimeline(h),this.saveSubjectSelectorToViewTimeline(h),!S&&!y&&!T)return;let k=[],I=[],U=!1;S&&(k=this.extractScrollTimelineNames(h.block.contents)),y&&(I=this.extractMatches(h.block.contents,ke.ANIMATION_NAME)),S&&y||(T&&this.extractMatches(h.block.contents,ke.ANIMATION).forEach(N=>{const L=this.extractAnimationName(N);L&&S&&I.push(L),S&&(this.hasDuration(N)||(this.hasAutoDuration(N)&&(h.block.contents=h.block.contents.replace("auto"," ")),h.block.contents=h.block.contents.replace(N," 1s "+N),U=!0))}),U&&this.replacePart(h.block.startIndex,h.block.endIndex,h.block.contents,d)),this.saveRelationInList(h,k,I)}saveSourceSelectorToScrollTimeline(h){const d=h.block.contents.includes("scroll-timeline:"),y=h.block.contents.includes("scroll-timeline-name:"),S=h.block.contents.includes("scroll-timeline-axis:");if(!d&&!y)return;let T=[];if(d){const I=this.extractMatches(h.block.contents,ke.SCROLL_TIMELINE);for(const U of I){const N=this.split(U);let L={selector:h.selector,name:""};N.length==1?L.name=N[0]:N.length==2&&(Pn.includes(N[0])?(L.axis=N[0],L.name=N[1]):(L.axis=N[1],L.name=N[0])),T.push(L)}}if(y){const I=this.extractMatches(h.block.contents,ke.SCROLL_TIMELINE_NAME);for(let U=0;U<I.length;U++)if(U<T.length)T[U].name=I[U];else{let N={selector:h.selector,name:I[U]};T.push(N)}}let k=[];if(S){const I=this.extractMatches(h.block.contents,ke.SCROLL_TIMELINE_AXIS);if(k=I.filter(U=>Pn.includes(U)),k.length!=I.length)throw new Error("Invalid axis")}for(let I=0;I<T.length;I++)k.length&&(T[I].axis=k[I%T.length]);this.sourceSelectorToScrollTimeline.push(...T)}saveSubjectSelectorToViewTimeline(h){const d=h.block.contents.includes("view-timeline:"),y=h.block.contents.includes("view-timeline-name:"),S=h.block.contents.includes("view-timeline-axis:"),T=h.block.contents.includes("view-timeline-inset:");if(!d&&!y)return;let k=[];if(d){const N=this.extractMatches(h.block.contents,ke.VIEW_TIMELINE);for(let L of N){const X=this.split(L);let Z={selector:h.selector,name:"",inset:null};X.length==1?Z.name=X[0]:X.length==2&&(Pn.includes(X[0])?(Z.axis=X[0],Z.name=X[1]):(Z.axis=X[1],Z.name=X[0])),k.push(Z)}}if(y){const N=this.extractMatches(h.block.contents,ke.VIEW_TIMELINE_NAME);for(let L=0;L<N.length;L++)if(L<k.length)k[L].name=N[L];else{let X={selector:h.selector,name:N[L],inset:null};k.push(X)}}let I=[],U=[];if(T&&(I=this.extractMatches(h.block.contents,ke.VIEW_TIMELINE_INSET)),S){const N=this.extractMatches(h.block.contents,ke.VIEW_TIMELINE_AXIS);if(U=N.filter(L=>Pn.includes(L)),U.length!=N.length)throw new Error("Invalid axis")}for(let N=0;N<k.length;N++)I.length&&(k[N].inset=I[N%k.length]),U.length&&(k[N].axis=U[N%k.length]);this.subjectSelectorToViewTimeline.push(...k)}hasDuration(h){return h.split(" ").filter(d=>{return y=d,ke.TIME.exec(y);var y}).length>=1}hasAutoDuration(h){return h.split(" ").filter(d=>d==="auto").length>=1}saveRelationInList(h,d,y){let S=[];h.block.contents.includes("animation-range:")&&(S=this.extractMatches(h.block.contents,ke.ANIMATION_TIME_RANGE));const T=Math.max(d.length,y.length,S.length);for(let k=0;k<T;k++)this.cssRulesWithTimelineName.push({selector:h.selector,"animation-timeline":d[k%d.length],...y.length?{"animation-name":y[k%y.length]}:{},...S.length?{"animation-range":S[k%S.length]}:{}})}extractScrollTimelineNames(h){const d=ke.ANIMATION_TIMELINE.exec(h)[1].trim(),y=[];return d.split(",").map(S=>S.trim()).forEach(S=>{if(function(T){return(T.startsWith("scroll")||T.startsWith("view"))&&T.includes("(")}(S)){const T=this.saveAnonymousTimelineName(S);y.push(T)}else y.push(S)}),y}saveAnonymousTimelineName(h){const d=":t"+this.nextAnonymousTimelineNameIndex++;return h.startsWith("scroll(")?this.anonymousScrollTimelineOptions.set(d,this.parseAnonymousScrollTimeline(h)):this.anonymousViewTimelineOptions.set(d,this.parseAnonymousViewTimeline(h)),d}parseAnonymousScrollTimeline(h){const d=ke.ANONYMOUS_SCROLL_TIMELINE.exec(h);if(!d)return null;const y=d[1],S={};return y.split(" ").forEach(T=>{Pn.includes(T)?S.axis=T:kl.includes(T)&&(S.source=T)}),S}parseAnonymousViewTimeline(h){const d=ke.ANONYMOUS_VIEW_TIMELINE.exec(h);if(!d)return null;const y=d[1],S={};return y.split(" ").forEach(T=>{Pn.includes(T)?S.axis=T:S.inset=S.inset?`${S.inset} ${T}`:T}),S}extractAnimationName(h){return this.findMatchingEntryInContainer(h,this.keyframeNamesSelectors)}findMatchingEntryInContainer(h,d){const y=h.split(" ").filter(S=>d.has(S));return y?y[0]:null}parseIdentifier(h){ke.IDENTIFIER.lastIndex=h.index;const d=ke.IDENTIFIER.exec(h.sheetSrc);if(!d)throw this.parseError(h,"Expected an identifier");return h.index+=d[0].length,d[0]}parseKeyframesAndSaveNameMapping(h,d){if(h.selector.startsWith("@keyframes")){const y=this.replaceKeyframesAndGetMapping(h,d);h.selector.split(" ").forEach((S,T)=>{T>0&&this.keyframeNamesSelectors.set(S,y)})}}replaceKeyframesAndGetMapping(h,d){function y(N){return Qi.some(L=>N.startsWith(L))}const S=h.block.contents,T=function(N){let L=0,X=-1,Z=-1;const K=[];for(let he=0;he<N.length;he++)N[he]=="{"?L++:N[he]=="}"&&L--,L==1&&N[he]!="{"&&N[he]!="}"&&X==-1&&(X=he),L==2&&N[he]=="{"&&(Z=he,K.push({start:X,end:Z}),X=Z=-1);return K}(S);if(T.length==0)return new Map;const k=new Map;let I=!1;const U=[];U.push(S.substring(0,T[0].start));for(let N=0;N<T.length;N++){const L=S.substring(T[N].start,T[N].end);let X=[];L.split(",").forEach(Z=>{const K=Z.split(" ").map(we=>we.trim()).filter(we=>we!="").join(" "),he=k.size;k.set(he,K),X.push(`${he}%`),y(K)&&(I=!0)}),U.push(X.join(",")),N==T.length-1?U.push(S.substring(T[N].end)):U.push(S.substring(T[N].end,T[N+1].start))}return I?(h.block.contents=U.join(""),this.replacePart(h.block.startIndex,h.block.endIndex,h.block.contents,d),k):new Map}parseQualifiedRule(h){const d=h.index,y=this.parseSelector(h).trim();if(y)return{selector:y,block:this.eatBlock(h),startIndex:d,endIndex:h.index}}removeEnclosingDoubleQuotes(h){let d=h[0]=='"'?1:0,y=h[h.length-1]=='"'?h.length-1:h.length;return h.substring(d,y)}assertString(h,d){if(h.sheetSrc.substr(h.index,d.length)!=d)throw this.parseError(h,`Did not find expected sequence ${d}`);h.index+=d.length}replacePart(h,d,y,S){if(S.sheetSrc=S.sheetSrc.slice(0,h)+y+S.sheetSrc.slice(d),S.index>=d){const T=S.index-d;S.index=h+y.length+T}}eatComment(h){this.assertString(h,"/*"),this.eatUntil("*/",h,!0),this.assertString(h,"*/")}eatBlock(h){const d=h.index;this.assertString(h,"{");let y=1;for(;y!=0;)this.lookAhead("/*",h)?this.eatComment(h):(h.sheetSrc[h.index]==="{"?y++:h.sheetSrc[h.index]==="}"&&y--,this.advance(h));const S=h.index;return{startIndex:d,endIndex:S,contents:h.sheetSrc.slice(d,S)}}advance(h){if(h.index++,h.index>h.sheetSrc.length)throw this.parseError(h,"Advanced beyond the end")}parseError(h,d){return Error(`(${h.name?h.name:"<anonymous file>"}): ${d}`)}eatUntil(h,d,y=!1){const S=d.index;for(;!this.lookAhead(h,d);)this.advance(d);return y&&(d.sheetSrc=d.sheetSrc.slice(0,S)+" ".repeat(d.index-S)+d.sheetSrc.slice(d.index)),d.sheetSrc.slice(S,d.index)}parseSelector(h){let d=h.index;if(this.eatUntil("{",h),d===h.index)throw Error("Empty selector");return h.sheetSrc.slice(d,h.index)}eatWhitespace(h){ke.WHITE_SPACE.lastIndex=h.index;const d=ke.WHITE_SPACE.exec(h.sheetSrc);d&&(h.index+=d[0].length)}lookAhead(h,d){return d.sheetSrc.substr(d.index,h.length)==h}peek(h){return h.sheetSrc[h.index]}extractMatches(h,d,y=","){return d.exec(h)[1].trim().split(y).map(S=>S.trim())}split(h){return h.split(" ").map(d=>d.trim()).filter(d=>d!="")}};function Rl(h,d,y,S,T,k){const I=ts(d),U=ns(d,y);return Io(as(h,I,U,S,T),k,as("cover",I,U,S,T),y)}function Al(h,d,y){const S=Kt.getAnimationTimelineOptions(d,y);if(!S)return null;const T=S["animation-timeline"];if(!T)return null;let k=Kt.getScrollTimelineOptions(T,y)||Kt.getViewTimelineOptions(T,y);return k?(k.subject&&function(I,U){const N=os(U.subject),L=U.axis||U.axis;function X(K,he){let we=null;for(const[Qe,Tt]of K)if(Qe==100*he.offset){if(Tt=="from")we=0;else if(Tt=="to")we=100;else{const dt=Tt.split(" ");we=dt.length==1?parseFloat(dt[0]):100*Rl(dt[0],N,U.subject,L,U.inset,CSS.percent(parseFloat(dt[1])))}break}return we}const Z=Kt.keyframeNamesSelectors.get(I.animationName);if(Z&&Z.size){const K=[];I.effect.getKeyframes().forEach(we=>{const Qe=X(Z,we);Qe!==null&&Qe>=0&&Qe<=100&&(we.offset=Qe/100,K.push(we))});const he=K.sort((we,Qe)=>we.offset<Qe.offset?-1:we.affset>Qe.offset?1:0);I.effect.setKeyframes(he)}}(h,k),{timeline:k.source?new We(k):new Mn(k),animOptions:S}):null}function Ol(){if(CSS.supports("animation-timeline: --works"))return!0;(function(){function d(S){if(S.innerHTML.trim().length===0||"aphrodite"in S.dataset)return;let T=Kt.transpileStyleSheet(S.innerHTML,!0);T=Kt.transpileStyleSheet(T,!1),S.innerHTML=T}function y(S){S.type!="text/css"&&S.rel!="stylesheet"||!S.href||new URL(S.href,document.baseURI).origin==location.origin&&fetch(S.getAttribute("href")).then(async T=>{const k=await T.text();let I=Kt.transpileStyleSheet(k,!0);if(I=Kt.transpileStyleSheet(k,!1),I!=k){const U=new Blob([I],{type:"text/css"}),N=URL.createObjectURL(U);S.setAttribute("href",N)}})}new MutationObserver(S=>{for(const T of S)for(const k of T.addedNodes)k instanceof HTMLStyleElement&&d(k),k instanceof HTMLLinkElement&&y(k)}).observe(document.documentElement,{childList:!0,subtree:!0}),document.querySelectorAll("style").forEach(S=>d(S)),document.querySelectorAll("link").forEach(S=>y(S))})();const h=CSS.supports;CSS.supports=d=>(d=d.replaceAll(/(animation-timeline|scroll-timeline(-(name|axis))?|view-timeline(-(name|axis|inset))?|timeline-scope)\s*:/g,"--supported-property:"),h(d)),window.addEventListener("animationstart",d=>{d.target.getAnimations().filter(y=>y.animationName===d.animationName).forEach(y=>{const S=Al(y,y.animationName,d.target);if(S)if(!S.timeline||y instanceof ir)y.timeline=S.timeline;else{const T=new ir(y,S.timeline,S.animOptions);y.pause(),T.play()}})})}(function(){if(!Ol()){if(!Reflect.defineProperty(window,"ScrollTimeline",{value:We}))throw Error("Error installing ScrollTimeline polyfill: could not attach ScrollTimeline to window");if(!Reflect.defineProperty(window,"ViewTimeline",{value:Mn}))throw Error("Error installing ViewTimeline polyfill: could not attach ViewTimeline to window");if(!Reflect.defineProperty(Element.prototype,"animate",{value:Cl}))throw Error("Error installing ScrollTimeline polyfill: could not attach WAAPI's animate to DOM Element");if(!Reflect.defineProperty(window,"Animation",{value:ir}))throw Error("Error installing Animation constructor.");if(!Reflect.defineProperty(Element.prototype,"getAnimations",{value:El}))throw Error("Error installing ScrollTimeline polyfill: could not attach WAAPI's getAnimations to DOM Element");if(!Reflect.defineProperty(document,"getAnimations",{value:Pl}))throw Error("Error installing ScrollTimeline polyfill: could not attach WAAPI's getAnimations to document")}})()})();class pd{constructor(e,t){if(this._retries=0,!Number.isInteger(e)||e<0)throw new Error("Base must be a positive integer or zero");if(t!==void 0&&(!Number.isInteger(t)||t<0))throw new Error("ExpMax must be a undefined, a positive integer or zero");this.base=e,this.expMax=t,this.i=0}get retries(){return this._retries}get current(){return this.base*Math.pow(2,this.i)}next(){return this._retries++,this.i=this.expMax===void 0?this.i+1:Math.min(this.i+1,this.expMax),this.current}reset(){this._retries=0,this.i=0}}var se;(function(r){r.open="open",r.close="close",r.error="error",r.message="message",r.retry="retry",r.reconnect="reconnect"})(se||(se={}));class Jc{constructor(e,t,n){var i,s,a,o,c,l,u,p,f,m,b,x,g,v,_;this._closedByUser=!1,this.handleOpenEvent=w=>this.handleEvent(se.open,w),this.handleErrorEvent=w=>this.handleEvent(se.error,w),this.handleCloseEvent=w=>this.handleEvent(se.close,w),this.handleMessageEvent=w=>this.handleEvent(se.message,w),this._url=e,this._protocols=t,this._options={buffer:n?.buffer,retry:{maxRetries:(i=n?.retry)===null||i===void 0?void 0:i.maxRetries,instantReconnect:(s=n?.retry)===null||s===void 0?void 0:s.instantReconnect,backoff:(a=n?.retry)===null||a===void 0?void 0:a.backoff},listeners:{open:[...(c=(o=n?.listeners)===null||o===void 0?void 0:o.open)!==null&&c!==void 0?c:[]],close:[...(u=(l=n?.listeners)===null||l===void 0?void 0:l.close)!==null&&u!==void 0?u:[]],error:[...(f=(p=n?.listeners)===null||p===void 0?void 0:p.error)!==null&&f!==void 0?f:[]],message:[...(b=(m=n?.listeners)===null||m===void 0?void 0:m.message)!==null&&b!==void 0?b:[]],retry:[...(g=(x=n?.listeners)===null||x===void 0?void 0:x.retry)!==null&&g!==void 0?g:[]],reconnect:[...(_=(v=n?.listeners)===null||v===void 0?void 0:v.reconnect)!==null&&_!==void 0?_:[]]}},this._underlyingWebsocket=this.tryConnect()}get url(){return this._url}get protocols(){return this._protocols}get buffer(){return this._options.buffer}get maxRetries(){return this._options.retry.maxRetries}get instantReconnect(){return this._options.retry.instantReconnect}get backoff(){return this._options.retry.backoff}get closedByUser(){return this._closedByUser}get lastConnection(){return this._lastConnection}get underlyingWebsocket(){return this._underlyingWebsocket}get readyState(){return this._underlyingWebsocket.readyState}get bufferedAmount(){return this._underlyingWebsocket.bufferedAmount}get extensions(){return this._underlyingWebsocket.extensions}get binaryType(){return this._underlyingWebsocket.binaryType}set binaryType(e){this._underlyingWebsocket.binaryType=e}send(e){this.closedByUser||(this._underlyingWebsocket.readyState===this._underlyingWebsocket.OPEN?this._underlyingWebsocket.send(e):this.buffer!==void 0&&this.buffer.add(e))}close(e,t){this.cancelScheduledConnectionRetry(),this._closedByUser=!0,this._underlyingWebsocket.close(e,t)}addEventListener(e,t,n){this._options.listeners[e].push({listener:t,options:n})}removeEventListener(e,t,n){const i=s=>s.listener!==t||s.options!==n;this._options.listeners[e]=this._options.listeners[e].filter(i)}tryConnect(){return this._underlyingWebsocket=new WebSocket(this.url,this.protocols),this._underlyingWebsocket.addEventListener(se.open,this.handleOpenEvent),this._underlyingWebsocket.addEventListener(se.close,this.handleCloseEvent),this._underlyingWebsocket.addEventListener(se.error,this.handleErrorEvent),this._underlyingWebsocket.addEventListener(se.message,this.handleMessageEvent),this._underlyingWebsocket}clearWebsocket(){this._underlyingWebsocket.removeEventListener(se.open,this.handleOpenEvent),this._underlyingWebsocket.removeEventListener(se.close,this.handleCloseEvent),this._underlyingWebsocket.removeEventListener(se.error,this.handleErrorEvent),this._underlyingWebsocket.removeEventListener(se.message,this.handleMessageEvent),this._underlyingWebsocket.close()}dispatchEvent(e,t){const n=this._options.listeners[e],i=[];n.forEach(({listener:s,options:a})=>{s(this,t),(a===void 0||a.once===void 0||!a.once)&&i.push({listener:s,options:a})}),this._options.listeners[e]=i}handleEvent(e,t){switch(e){case se.close:this.dispatchEvent(e,t),this.scheduleConnectionRetryIfNeeded();break;case se.open:if(this.backoff!==void 0&&this._lastConnection!==void 0){const n={retries:this.backoff.retries,lastConnection:new Date(this._lastConnection)},i=new CustomEvent(se.reconnect,{detail:n});this.dispatchEvent(se.reconnect,i),this.backoff.reset()}this._lastConnection=new Date,this.dispatchEvent(e,t),this.sendBufferedData();break;case se.retry:this.dispatchEvent(e,t),this.clearWebsocket(),this.tryConnect();break;default:this.dispatchEvent(e,t);break}}sendBufferedData(){if(this.buffer!==void 0)for(let e=this.buffer.read();e!==void 0;e=this.buffer.read())this.send(e)}scheduleConnectionRetryIfNeeded(){if(this.closedByUser||this.backoff===void 0)return;const e=n=>{const i=new CustomEvent(se.retry,{detail:n});this.handleEvent(se.retry,i)},t={backoff:this._options.retry.instantReconnect===!0?0:this.backoff.next(),retries:this._options.retry.instantReconnect===!0?0:this.backoff.retries,lastConnection:this._lastConnection};(this._options.retry.maxRetries===void 0||t.retries<=this._options.retry.maxRetries)&&(this.retryTimeout=globalThis.setTimeout(()=>e(t),t.backoff))}cancelScheduledConnectionRetry(){globalThis.clearTimeout(this.retryTimeout)}}class fd{constructor(e){this._url=e}get url(){return this._url}withProtocols(e){return this._protocols=e,this}get protocols(){return this._protocols}withMaxRetries(e){var t;return this._options=Object.assign(Object.assign({},this._options),{retry:Object.assign(Object.assign({},(t=this._options)===null||t===void 0?void 0:t.retry),{maxRetries:e})}),this}get maxRetries(){var e,t;return(t=(e=this._options)===null||e===void 0?void 0:e.retry)===null||t===void 0?void 0:t.maxRetries}withInstantReconnect(e){var t;return this._options=Object.assign(Object.assign({},this._options),{retry:Object.assign(Object.assign({},(t=this._options)===null||t===void 0?void 0:t.retry),{instantReconnect:e})}),this}get instantReconnect(){var e,t;return(t=(e=this._options)===null||e===void 0?void 0:e.retry)===null||t===void 0?void 0:t.instantReconnect}withBackoff(e){var t;return this._options=Object.assign(Object.assign({},this._options),{retry:Object.assign(Object.assign({},(t=this._options)===null||t===void 0?void 0:t.retry),{backoff:e})}),this}get backoff(){var e,t;return(t=(e=this._options)===null||e===void 0?void 0:e.retry)===null||t===void 0?void 0:t.backoff}withBuffer(e){return this._options=Object.assign(Object.assign({},this._options),{buffer:e}),this}get buffer(){var e;return(e=this._options)===null||e===void 0?void 0:e.buffer}onOpen(e,t){return this.addListener(se.open,e,t),this}onClose(e,t){return this.addListener(se.close,e,t),this}onError(e,t){return this.addListener(se.error,e,t),this}onMessage(e,t){return this.addListener(se.message,e,t),this}onRetry(e,t){return this.addListener(se.retry,e,t),this}onReconnect(e,t){return this.addListener(se.reconnect,e,t),this}build(){return new Jc(this._url,this._protocols,this._options)}addListener(e,t,n){var i,s,a,o,c,l,u,p,f,m,b,x,g,v,_,w,C,M,E,P,O;return this._options=Object.assign(Object.assign({},this._options),{listeners:{open:(a=(s=(i=this._options)===null||i===void 0?void 0:i.listeners)===null||s===void 0?void 0:s.open)!==null&&a!==void 0?a:[],close:(l=(c=(o=this._options)===null||o===void 0?void 0:o.listeners)===null||c===void 0?void 0:c.close)!==null&&l!==void 0?l:[],error:(f=(p=(u=this._options)===null||u===void 0?void 0:u.listeners)===null||p===void 0?void 0:p.error)!==null&&f!==void 0?f:[],message:(x=(b=(m=this._options)===null||m===void 0?void 0:m.listeners)===null||b===void 0?void 0:b.message)!==null&&x!==void 0?x:[],retry:(_=(v=(g=this._options)===null||g===void 0?void 0:g.listeners)===null||v===void 0?void 0:v.retry)!==null&&_!==void 0?_:[],reconnect:(M=(C=(w=this._options)===null||w===void 0?void 0:w.listeners)===null||C===void 0?void 0:C.reconnect)!==null&&M!==void 0?M:[],[e]:[...(O=(P=(E=this._options)===null||E===void 0?void 0:E.listeners)===null||P===void 0?void 0:P[e])!==null&&O!==void 0?O:[],{listener:t,options:n}]}}),this}}const md=Object.freeze(Object.defineProperty({__proto__:null,ExponentialBackoff:pd,Websocket:Jc,WebsocketBuilder:fd,get WebsocketEvent(){return se}},Symbol.toStringTag,{value:"Module"})),Zs=0,Gc=1,Wc=2,Ks=2,Qs=1.25,Hc=1,ci=32,Pr=65535,yd=Math.pow(2,-24),$s=Symbol("SKIP_GENERATION");function gd(r){return r.index?r.index.count:r.attributes.position.count}function zn(r){return gd(r)/3}function vd(r,e=ArrayBuffer){return r>65535?new Uint32Array(new e(4*r)):new Uint16Array(new e(2*r))}function Sd(r,e){if(!r.index){const t=r.attributes.position.count,n=e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,i=vd(t,n);r.setIndex(new ot(i,1));for(let s=0;s<t;s++)i[s]=s}}function qc(r,e){const t=zn(r),n=e||r.drawRange,i=n.start/3,s=(n.start+n.count)/3,a=Math.max(0,i),o=Math.min(t,s)-a;return[{offset:Math.floor(a),count:Math.floor(o)}]}function Xc(r,e){if(!r.groups||!r.groups.length)return qc(r,e);const t=[],n=new Set,i=e||r.drawRange,s=i.start/3,a=(i.start+i.count)/3;for(const c of r.groups){const l=c.start/3,u=(c.start+c.count)/3;n.add(Math.max(s,l)),n.add(Math.min(a,u))}const o=Array.from(n.values()).sort((c,l)=>c-l);for(let c=0;c<o.length-1;c++){const l=o[c],u=o[c+1];t.push({offset:Math.floor(l),count:Math.floor(u-l)})}return t}function bd(r,e){const t=zn(r),n=Xc(r,e).sort((a,o)=>a.offset-o.offset),i=n[n.length-1];i.count=Math.min(t-i.offset,i.count);let s=0;return n.forEach(({count:a})=>s+=a),t!==s}function eo(r,e,t,n,i){let s=1/0,a=1/0,o=1/0,c=-1/0,l=-1/0,u=-1/0,p=1/0,f=1/0,m=1/0,b=-1/0,x=-1/0,g=-1/0;for(let v=e*6,_=(e+t)*6;v<_;v+=6){const w=r[v+0],C=r[v+1],M=w-C,E=w+C;M<s&&(s=M),E>c&&(c=E),w<p&&(p=w),w>b&&(b=w);const P=r[v+2],O=r[v+3],R=P-O,A=P+O;R<a&&(a=R),A>l&&(l=A),P<f&&(f=P),P>x&&(x=P);const B=r[v+4],z=r[v+5],D=B-z,F=B+z;D<o&&(o=D),F>u&&(u=F),B<m&&(m=B),B>g&&(g=B)}n[0]=s,n[1]=a,n[2]=o,n[3]=c,n[4]=l,n[5]=u,i[0]=p,i[1]=f,i[2]=m,i[3]=b,i[4]=x,i[5]=g}function xd(r,e=null,t=null,n=null){const i=r.attributes.position,s=r.index?r.index.array:null,a=zn(r),o=i.normalized;let c;e===null?(c=new Float32Array(a*6),t=0,n=a):(c=e,t=t||0,n=n||a);const l=i.array,u=i.offset||0;let p=3;i.isInterleavedBufferAttribute&&(p=i.data.stride);const f=["getX","getY","getZ"];for(let m=t;m<t+n;m++){const b=m*3,x=m*6;let g=b+0,v=b+1,_=b+2;s&&(g=s[g],v=s[v],_=s[_]),o||(g=g*p+u,v=v*p+u,_=_*p+u);for(let w=0;w<3;w++){let C,M,E;o?(C=i[f[w]](g),M=i[f[w]](v),E=i[f[w]](_)):(C=l[g+w],M=l[v+w],E=l[_+w]);let P=C;M<P&&(P=M),E<P&&(P=E);let O=C;M>O&&(O=M),E>O&&(O=E);const R=(O-P)/2,A=w*2;c[x+A+0]=P+R,c[x+A+1]=R+(Math.abs(P)+R)*yd}}return c}function ve(r,e,t){return t.min.x=e[r],t.min.y=e[r+1],t.min.z=e[r+2],t.max.x=e[r+3],t.max.y=e[r+4],t.max.z=e[r+5],t}function Yc(r){let e=-1,t=-1/0;for(let n=0;n<3;n++){const i=r[n+3]-r[n];i>t&&(t=i,e=n)}return e}function Zc(r,e){e.set(r)}function Kc(r,e,t){let n,i;for(let s=0;s<3;s++){const a=s+3;n=r[s],i=e[s],t[s]=n<i?n:i,n=r[a],i=e[a],t[a]=n>i?n:i}}function kr(r,e,t){for(let n=0;n<3;n++){const i=e[r+2*n],s=e[r+2*n+1],a=i-s,o=i+s;a<t[n]&&(t[n]=a),o>t[n+3]&&(t[n+3]=o)}}function li(r){const e=r[3]-r[0],t=r[4]-r[1],n=r[5]-r[2];return 2*(e*t+t*n+n*e)}const Xt=32,wd=(r,e)=>r.candidate-e.candidate,tn=new Array(Xt).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),Rr=new Float32Array(6);function _d(r,e,t,n,i,s){let a=-1,o=0;if(s===Zs)a=Yc(e),a!==-1&&(o=(e[a]+e[a+3])/2);else if(s===Gc)a=Yc(r),a!==-1&&(o=Td(t,n,i,a));else if(s===Wc){const c=li(r);let l=Qs*i;const u=n*6,p=(n+i)*6;for(let f=0;f<3;f++){const m=e[f],b=(e[f+3]-m)/Xt;if(i<Xt/4){const x=[...tn];x.length=i;let g=0;for(let _=u;_<p;_+=6,g++){const w=x[g];w.candidate=t[_+2*f],w.count=0;const{bounds:C,leftCacheBounds:M,rightCacheBounds:E}=w;for(let P=0;P<3;P++)E[P]=1/0,E[P+3]=-1/0,M[P]=1/0,M[P+3]=-1/0,C[P]=1/0,C[P+3]=-1/0;kr(_,t,C)}x.sort(wd);let v=i;for(let _=0;_<v;_++){const w=x[_];for(;_+1<v&&x[_+1].candidate===w.candidate;)x.splice(_+1,1),v--}for(let _=u;_<p;_+=6){const w=t[_+2*f];for(let C=0;C<v;C++){const M=x[C];w>=M.candidate?kr(_,t,M.rightCacheBounds):(kr(_,t,M.leftCacheBounds),M.count++)}}for(let _=0;_<v;_++){const w=x[_],C=w.count,M=i-w.count,E=w.leftCacheBounds,P=w.rightCacheBounds;let O=0;C!==0&&(O=li(E)/c);let R=0;M!==0&&(R=li(P)/c);const A=Hc+Qs*(O*C+R*M);A<l&&(a=f,l=A,o=w.candidate)}}else{for(let v=0;v<Xt;v++){const _=tn[v];_.count=0,_.candidate=m+b+v*b;const w=_.bounds;for(let C=0;C<3;C++)w[C]=1/0,w[C+3]=-1/0}for(let v=u;v<p;v+=6){let _=~~((t[v+2*f]-m)/b);_>=Xt&&(_=Xt-1);const w=tn[_];w.count++,kr(v,t,w.bounds)}const x=tn[Xt-1];Zc(x.bounds,x.rightCacheBounds);for(let v=Xt-2;v>=0;v--){const _=tn[v],w=tn[v+1];Kc(_.bounds,w.rightCacheBounds,_.rightCacheBounds)}let g=0;for(let v=0;v<Xt-1;v++){const _=tn[v],w=_.count,C=_.bounds,M=tn[v+1].rightCacheBounds;w!==0&&(g===0?Zc(C,Rr):Kc(C,Rr,Rr)),g+=w;let E=0,P=0;g!==0&&(E=li(Rr)/c);const O=i-g;O!==0&&(P=li(M)/c);const R=Hc+Qs*(E*g+P*O);R<l&&(a=f,l=R,o=_.candidate)}}}}else console.warn(`MeshBVH: Invalid build strategy value ${s} used.`);return{axis:a,pos:o}}function Td(r,e,t,n){let i=0;for(let s=e,a=e+t;s<a;s++)i+=r[s*6+n*2];return i/t}class to{constructor(){this.boundingData=new Float32Array(6)}}function Md(r,e,t,n,i,s){let a=n,o=n+i-1;const c=s.pos,l=s.axis*2;for(;;){for(;a<=o&&t[a*6+l]<c;)a++;for(;a<=o&&t[o*6+l]>=c;)o--;if(a<o){for(let u=0;u<3;u++){let p=e[a*3+u];e[a*3+u]=e[o*3+u],e[o*3+u]=p}for(let u=0;u<6;u++){let p=t[a*6+u];t[a*6+u]=t[o*6+u],t[o*6+u]=p}a++,o--}else return a}}function Cd(r,e,t,n,i,s){let a=n,o=n+i-1;const c=s.pos,l=s.axis*2;for(;;){for(;a<=o&&t[a*6+l]<c;)a++;for(;a<=o&&t[o*6+l]>=c;)o--;if(a<o){let u=r[a];r[a]=r[o],r[o]=u;for(let p=0;p<6;p++){let f=t[a*6+p];t[a*6+p]=t[o*6+p],t[o*6+p]=f}a++,o--}else return a}}function et(r,e){return e[r+15]===65535}function ct(r,e){return e[r+6]}function pt(r,e){return e[r+14]}function ft(r){return r+8}function mt(r,e){return e[r+6]}function Qc(r,e){return e[r+7]}let $c,ui,Ar,el;const Ed=Math.pow(2,32);function no(r){return"count"in r?1:1+no(r.left)+no(r.right)}function Pd(r,e,t){return $c=new Float32Array(t),ui=new Uint32Array(t),Ar=new Uint16Array(t),el=new Uint8Array(t),io(r,e)}function io(r,e){const t=r/4,n=r/2,i="count"in e,s=e.boundingData;for(let a=0;a<6;a++)$c[t+a]=s[a];if(i)if(e.buffer){const a=e.buffer;el.set(new Uint8Array(a),r);for(let o=r,c=r+a.byteLength;o<c;o+=ci){const l=o/2;et(l,Ar)||(ui[o/4+6]+=t)}return r+a.byteLength}else{const a=e.offset,o=e.count;return ui[t+6]=a,Ar[n+14]=o,Ar[n+15]=Pr,r+ci}else{const a=e.left,o=e.right,c=e.splitAxis;let l;if(l=io(r+ci,a),l/4>Ed)throw new Error("MeshBVH: Cannot store child pointer greater than 32 bits.");return ui[t+6]=l/4,l=io(l,o),ui[t+7]=c,l}}function kd(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 Rd(r,e,t,n,i){const{maxDepth:s,verbose:a,maxLeafTris:o,strategy:c,onProgress:l,indirect:u}=i,p=r._indirectBuffer,f=r.geometry,m=f.index?f.index.array:null,b=u?Cd:Md,x=zn(f),g=new Float32Array(6);let v=!1;const _=new to;return eo(e,t,n,_.boundingData,g),C(_,t,n,g),_;function w(M){l&&l(M/x)}function C(M,E,P,O=null,R=0){if(!v&&R>=s&&(v=!0,a&&(console.warn(`MeshBVH: Max depth of ${s} reached when generating BVH. Consider increasing maxDepth.`),console.warn(f))),P<=o||R>=s)return w(E+P),M.offset=E,M.count=P,M;const A=_d(M.boundingData,O,e,E,P,c);if(A.axis===-1)return w(E+P),M.offset=E,M.count=P,M;const B=b(p,m,e,E,P,A);if(B===E||B===E+P)w(E+P),M.offset=E,M.count=P;else{M.splitAxis=A.axis;const z=new to,D=E,F=B-E;M.left=z,eo(e,D,F,z.boundingData,g),C(z,D,F,g,R+1);const H=new to,q=B,$=P-F;M.right=H,eo(e,q,$,H.boundingData,g),C(H,q,$,g,R+1)}return M}}function Ad(r,e){const t=r.geometry;e.indirect&&(r._indirectBuffer=kd(t,e.useSharedArrayBuffer),bd(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||Sd(t,e);const n=e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,i=xd(t),s=e.indirect?qc(t,e.range):Xc(t,e.range);r._roots=s.map(a=>{const o=Rd(r,i,a.offset,a.count,e),c=no(o),l=new n(ci*c);return Pd(0,o,l),l})}class Yt{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(e,t){let n=1/0,i=-1/0;for(let s=0,a=e.length;s<a;s++){const o=e[s][t];n=o<n?o:n,i=o>i?o:i}this.min=n,this.max=i}setFromPoints(e,t){let n=1/0,i=-1/0;for(let s=0,a=t.length;s<a;s++){const o=t[s],c=e.dot(o);n=c<n?c:n,i=c>i?c:i}this.min=n,this.max=i}isSeparated(e){return this.min>e.max||e.min>this.max}}Yt.prototype.setFromBox=function(){const r=new W;return function(e,t){const n=t.min,i=t.max;let s=1/0,a=-1/0;for(let o=0;o<=1;o++)for(let c=0;c<=1;c++)for(let l=0;l<=1;l++){r.x=n.x*o+i.x*(1-o),r.y=n.y*c+i.y*(1-c),r.z=n.z*l+i.z*(1-l);const u=e.dot(r);s=Math.min(u,s),a=Math.max(u,a)}this.min=s,this.max=a}}();const Od=function(){const r=new W,e=new W,t=new W;return function(n,i,s){const a=n.start,o=r,c=i.start,l=e;t.subVectors(a,c),r.subVectors(n.end,n.start),e.subVectors(i.end,i.start);const u=t.dot(l),p=l.dot(o),f=l.dot(l),m=t.dot(o),b=o.dot(o)*f-p*p;let x,g;b!==0?x=(u*p-m*f)/b:x=0,g=(u+x*p)/f,s.x=x,s.y=g}}(),ro=function(){const r=new kn,e=new W,t=new W;return function(n,i,s,a){Od(n,i,r);let o=r.x,c=r.y;if(o>=0&&o<=1&&c>=0&&c<=1){n.at(o,s),i.at(c,a);return}else if(o>=0&&o<=1){c<0?i.at(0,a):i.at(1,a),n.closestPointToPoint(a,!0,s);return}else if(c>=0&&c<=1){o<0?n.at(0,s):n.at(1,s),i.closestPointToPoint(s,!0,a);return}else{let l;o<0?l=n.start:l=n.end;let u;c<0?u=i.start:u=i.end;const p=e,f=t;if(n.closestPointToPoint(u,!0,e),i.closestPointToPoint(l,!0,t),p.distanceToSquared(u)<=f.distanceToSquared(l)){s.copy(p),a.copy(u);return}else{s.copy(l),a.copy(f);return}}}}(),Id=function(){const r=new W,e=new W,t=new Qo,n=new Gt;return function(i,s){const{radius:a,center:o}=i,{a:c,b:l,c:u}=s;if(n.start=c,n.end=l,n.closestPointToPoint(o,!0,r).distanceTo(o)<=a||(n.start=c,n.end=u,n.closestPointToPoint(o,!0,r).distanceTo(o)<=a)||(n.start=l,n.end=u,n.closestPointToPoint(o,!0,r).distanceTo(o)<=a))return!0;const p=s.getPlane(t);if(Math.abs(p.distanceToPoint(o))<=a){const f=p.projectPoint(o,e);if(s.containsPoint(f))return!0}return!1}}(),zd=1e-15;function so(r){return Math.abs(r)<zd}class yt extends un{constructor(...e){super(...e),this.isExtendedTriangle=!0,this.satAxes=new Array(4).fill().map(()=>new W),this.satBounds=new Array(4).fill().map(()=>new Yt),this.points=[this.a,this.b,this.c],this.sphere=new $o,this.plane=new Qo,this.needsUpdate=!0}intersectsSphere(e){return Id(e,this)}update(){const e=this.a,t=this.b,n=this.c,i=this.points,s=this.satAxes,a=this.satBounds,o=s[0],c=a[0];this.getNormal(o),c.setFromPoints(o,i);const l=s[1],u=a[1];l.subVectors(e,t),u.setFromPoints(l,i);const p=s[2],f=a[2];p.subVectors(t,n),f.setFromPoints(p,i);const m=s[3],b=a[3];m.subVectors(n,e),b.setFromPoints(m,i),this.sphere.setFromPoints(this.points),this.plane.setFromNormalAndCoplanarPoint(o,e),this.needsUpdate=!1}}yt.prototype.closestPointToSegment=function(){const r=new W,e=new W,t=new Gt;return function(n,i=null,s=null){const{start:a,end:o}=n,c=this.points;let l,u=1/0;for(let p=0;p<3;p++){const f=(p+1)%3;t.start.copy(c[p]),t.end.copy(c[f]),ro(t,n,r,e),l=r.distanceToSquared(e),l<u&&(u=l,i&&i.copy(r),s&&s.copy(e))}return this.closestPointToPoint(a,r),l=a.distanceToSquared(r),l<u&&(u=l,i&&i.copy(r),s&&s.copy(a)),this.closestPointToPoint(o,r),l=o.distanceToSquared(r),l<u&&(u=l,i&&i.copy(r),s&&s.copy(o)),Math.sqrt(u)}}(),yt.prototype.intersectsTriangle=function(){const r=new yt,e=new Array(3),t=new Array(3),n=new Yt,i=new Yt,s=new W,a=new W,o=new W,c=new W,l=new W,u=new Gt,p=new Gt,f=new Gt,m=new W;function b(x,g,v){const _=x.points;let w=0,C=-1;for(let M=0;M<3;M++){const{start:E,end:P}=u;E.copy(_[M]),P.copy(_[(M+1)%3]),u.delta(a);const O=so(g.distanceToPoint(E));if(so(g.normal.dot(a))&&O){v.copy(u),w=2;break}const R=g.intersectLine(u,m);if(!R&&O&&m.copy(E),(R||O)&&!so(m.distanceTo(P))){if(w<=1)(w===1?v.start:v.end).copy(m),O&&(C=w);else if(w>=2){(C===1?v.start:v.end).copy(m),w=2;break}if(w++,w===2&&C===-1)break}}return w}return function(x,g=null,v=!1){this.needsUpdate&&this.update(),x.isExtendedTriangle?x.needsUpdate&&x.update():(r.copy(x),r.update(),x=r);const _=this.plane,w=x.plane;if(Math.abs(_.normal.dot(w.normal))>1-1e-10){const C=this.satBounds,M=this.satAxes;t[0]=x.a,t[1]=x.b,t[2]=x.c;for(let O=0;O<4;O++){const R=C[O],A=M[O];if(n.setFromPoints(A,t),R.isSeparated(n))return!1}const E=x.satBounds,P=x.satAxes;e[0]=this.a,e[1]=this.b,e[2]=this.c;for(let O=0;O<4;O++){const R=E[O],A=P[O];if(n.setFromPoints(A,e),R.isSeparated(n))return!1}for(let O=0;O<4;O++){const R=M[O];for(let A=0;A<4;A++){const B=P[A];if(s.crossVectors(R,B),n.setFromPoints(s,e),i.setFromPoints(s,t),n.isSeparated(i))return!1}}return g&&(v||console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."),g.start.set(0,0,0),g.end.set(0,0,0)),!0}else{const C=b(this,w,p);if(C===1&&x.containsPoint(p.end))return g&&(g.start.copy(p.end),g.end.copy(p.end)),!0;if(C!==2)return!1;const M=b(x,_,f);if(M===1&&this.containsPoint(f.end))return g&&(g.start.copy(f.end),g.end.copy(f.end)),!0;if(M!==2)return!1;if(p.delta(o),f.delta(c),o.dot(c)<0){let z=f.start;f.start=f.end,f.end=z}const E=p.start.dot(o),P=p.end.dot(o),O=f.start.dot(o),R=f.end.dot(o),A=P<O,B=E<R;return E!==R&&O!==P&&A===B?!1:(g&&(l.subVectors(p.start,f.start),l.dot(o)>0?g.start.copy(p.start):g.start.copy(f.start),l.subVectors(p.end,f.end),l.dot(o)<0?g.end.copy(p.end):g.end.copy(f.end)),!0)}}}(),yt.prototype.distanceToPoint=function(){const r=new W;return function(e){return this.closestPointToPoint(e,r),e.distanceTo(r)}}(),yt.prototype.distanceToTriangle=function(){const r=new W,e=new W,t=["a","b","c"],n=new Gt,i=new Gt;return function(s,a=null,o=null){const c=a||o?n:null;if(this.intersectsTriangle(s,c))return(a||o)&&(a&&c.getCenter(a),o&&c.getCenter(o)),0;let l=1/0;for(let u=0;u<3;u++){let p;const f=t[u],m=s[f];this.closestPointToPoint(m,r),p=m.distanceToSquared(r),p<l&&(l=p,a&&a.copy(r),o&&o.copy(m));const b=this[f];s.closestPointToPoint(b,r),p=b.distanceToSquared(r),p<l&&(l=p,a&&a.copy(b),o&&o.copy(r))}for(let u=0;u<3;u++){const p=t[u],f=t[(u+1)%3];n.set(this[p],this[f]);for(let m=0;m<3;m++){const b=t[m],x=t[(m+1)%3];i.set(s[b],s[x]),ro(n,i,r,e);const g=r.distanceToSquared(e);g<l&&(l=g,a&&a.copy(r),o&&o.copy(e))}}return Math.sqrt(l)}}();class Ve{constructor(e,t,n){this.isOrientedBox=!0,this.min=new W,this.max=new W,this.matrix=new Ct,this.invMatrix=new Ct,this.points=new Array(8).fill().map(()=>new W),this.satAxes=new Array(3).fill().map(()=>new W),this.satBounds=new Array(3).fill().map(()=>new Yt),this.alignedSatBounds=new Array(3).fill().map(()=>new Yt),this.needsUpdate=!1,e&&this.min.copy(e),t&&this.max.copy(t),n&&this.matrix.copy(n)}set(e,t,n){this.min.copy(e),this.max.copy(t),this.matrix.copy(n),this.needsUpdate=!0}copy(e){this.min.copy(e.min),this.max.copy(e.max),this.matrix.copy(e.matrix),this.needsUpdate=!0}}Ve.prototype.update=function(){return function(){const r=this.matrix,e=this.min,t=this.max,n=this.points;for(let c=0;c<=1;c++)for(let l=0;l<=1;l++)for(let u=0;u<=1;u++){const p=1*c|2*l|4*u,f=n[p];f.x=c?t.x:e.x,f.y=l?t.y:e.y,f.z=u?t.z:e.z,f.applyMatrix4(r)}const i=this.satBounds,s=this.satAxes,a=n[0];for(let c=0;c<3;c++){const l=s[c],u=i[c],p=1<<c,f=n[p];l.subVectors(a,f),u.setFromPoints(l,n)}const o=this.alignedSatBounds;o[0].setFromPointsField(n,"x"),o[1].setFromPointsField(n,"y"),o[2].setFromPointsField(n,"z"),this.invMatrix.copy(this.matrix).invert(),this.needsUpdate=!1}}(),Ve.prototype.intersectsBox=function(){const r=new Yt;return function(e){this.needsUpdate&&this.update();const t=e.min,n=e.max,i=this.satBounds,s=this.satAxes,a=this.alignedSatBounds;if(r.min=t.x,r.max=n.x,a[0].isSeparated(r)||(r.min=t.y,r.max=n.y,a[1].isSeparated(r))||(r.min=t.z,r.max=n.z,a[2].isSeparated(r)))return!1;for(let o=0;o<3;o++){const c=s[o],l=i[o];if(r.setFromBox(c,e),l.isSeparated(r))return!1}return!0}}(),Ve.prototype.intersectsTriangle=function(){const r=new yt,e=new Array(3),t=new Yt,n=new Yt,i=new W;return function(s){this.needsUpdate&&this.update(),s.isExtendedTriangle?s.needsUpdate&&s.update():(r.copy(s),r.update(),s=r);const a=this.satBounds,o=this.satAxes;e[0]=s.a,e[1]=s.b,e[2]=s.c;for(let p=0;p<3;p++){const f=a[p],m=o[p];if(t.setFromPoints(m,e),f.isSeparated(t))return!1}const c=s.satBounds,l=s.satAxes,u=this.points;for(let p=0;p<3;p++){const f=c[p],m=l[p];if(t.setFromPoints(m,u),f.isSeparated(t))return!1}for(let p=0;p<3;p++){const f=o[p];for(let m=0;m<4;m++){const b=l[m];if(i.crossVectors(f,b),t.setFromPoints(i,e),n.setFromPoints(i,u),t.isSeparated(n))return!1}}return!0}}(),Ve.prototype.closestPointToPoint=function(){return function(r,e){return this.needsUpdate&&this.update(),e.copy(r).applyMatrix4(this.invMatrix).clamp(this.min,this.max).applyMatrix4(this.matrix),e}}(),Ve.prototype.distanceToPoint=function(){const r=new W;return function(e){return this.closestPointToPoint(e,r),e.distanceTo(r)}}(),Ve.prototype.distanceToBox=function(){const r=["x","y","z"],e=new Array(12).fill().map(()=>new Gt),t=new Array(12).fill().map(()=>new Gt),n=new W,i=new W;return function(s,a=0,o=null,c=null){if(this.needsUpdate&&this.update(),this.intersectsBox(s))return(o||c)&&(s.getCenter(i),this.closestPointToPoint(i,n),s.closestPointToPoint(n,i),o&&o.copy(n),c&&c.copy(i)),0;const l=a*a,u=s.min,p=s.max,f=this.points;let m=1/0;for(let x=0;x<8;x++){const g=f[x];i.copy(g).clamp(u,p);const v=g.distanceToSquared(i);if(v<m&&(m=v,o&&o.copy(g),c&&c.copy(i),v<l))return Math.sqrt(v)}let b=0;for(let x=0;x<3;x++)for(let g=0;g<=1;g++)for(let v=0;v<=1;v++){const _=(x+1)%3,w=(x+2)%3,C=g<<_|v<<w,M=1<<x|g<<_|v<<w,E=f[C],P=f[M];e[b].set(E,P);const O=r[x],R=r[_],A=r[w],B=t[b],z=B.start,D=B.end;z[O]=u[O],z[R]=g?u[R]:p[R],z[A]=v?u[A]:p[R],D[O]=p[O],D[R]=g?u[R]:p[R],D[A]=v?u[A]:p[R],b++}for(let x=0;x<=1;x++)for(let g=0;g<=1;g++)for(let v=0;v<=1;v++){i.x=x?p.x:u.x,i.y=g?p.y:u.y,i.z=v?p.z:u.z,this.closestPointToPoint(i,n);const _=i.distanceToSquared(n);if(_<m&&(m=_,o&&o.copy(n),c&&c.copy(i),_<l))return Math.sqrt(_)}for(let x=0;x<12;x++){const g=e[x];for(let v=0;v<12;v++){const _=t[v];ro(g,_,n,i);const w=n.distanceToSquared(i);if(w<m&&(m=w,o&&o.copy(n),c&&c.copy(i),w<l))return Math.sqrt(w)}}return Math.sqrt(m)}}();class oo{constructor(e){this._getNewPrimitive=e,this._primitives=[]}getPrimitive(){const e=this._primitives;return e.length===0?this._getNewPrimitive():e.pop()}releasePrimitive(e){this._primitives.push(e)}}class Bd extends oo{constructor(){super(()=>new yt)}}const gt=new Bd;class Nd{constructor(){this.float32Array=null,this.uint16Array=null,this.uint32Array=null;const e=[];let t=null;this.setBuffer=n=>{t&&e.push(t),t=n,this.float32Array=new Float32Array(n),this.uint16Array=new Uint16Array(n),this.uint32Array=new Uint32Array(n)},this.clearBuffer=()=>{t=null,this.float32Array=null,this.uint16Array=null,this.uint32Array=null,e.length!==0&&this.setBuffer(e.pop())}}}const de=new Nd;let nn,Bn;const Nn=[],Or=new oo(()=>new Ot);function Ud(r,e,t,n,i,s){nn=Or.getPrimitive(),Bn=Or.getPrimitive(),Nn.push(nn,Bn),de.setBuffer(r._roots[e]);const a=ao(0,r.geometry,t,n,i,s);de.clearBuffer(),Or.releasePrimitive(nn),Or.releasePrimitive(Bn),Nn.pop(),Nn.pop();const o=Nn.length;return o>0&&(Bn=Nn[o-1],nn=Nn[o-2]),a}function ao(r,e,t,n,i=null,s=0,a=0){const{float32Array:o,uint16Array:c,uint32Array:l}=de;let u=r*2;if(et(u,c)){const p=ct(r,l),f=pt(u,c);return ve(r,o,nn),n(p,f,!1,a,s+r,nn)}else{let p=function(B){const{uint16Array:z,uint32Array:D}=de;let F=B*2;for(;!et(F,z);)B=ft(B),F=B*2;return ct(B,D)},f=function(B){const{uint16Array:z,uint32Array:D}=de;let F=B*2;for(;!et(F,z);)B=mt(B,D),F=B*2;return ct(B,D)+pt(F,z)};const m=ft(r),b=mt(r,l);let x=m,g=b,v,_,w,C;if(i&&(w=nn,C=Bn,ve(x,o,w),ve(g,o,C),v=i(w),_=i(C),_<v)){x=b,g=m;const B=v;v=_,_=B,w=C}w||(w=nn,ve(x,o,w));const M=et(x*2,c),E=t(w,M,v,a+1,s+x);let P;if(E===Ks){const B=p(x),z=f(x)-B;P=n(B,z,!0,a+1,s+x,w)}else P=E&&ao(x,e,t,n,i,s,a+1);if(P)return!0;C=Bn,ve(g,o,C);const O=et(g*2,c),R=t(C,O,_,a+1,s+g);let A;if(R===Ks){const B=p(g),z=f(g)-B;A=n(B,z,!0,a+1,s+g,C)}else A=R&&ao(g,e,t,n,i,s,a+1);return!!A}}const hi=new W,co=new W;function Dd(r,e,t={},n=0,i=1/0){const s=n*n,a=i*i;let o=1/0,c=null;if(r.shapecast({boundsTraverseOrder:u=>(hi.copy(e).clamp(u.min,u.max),hi.distanceToSquared(e)),intersectsBounds:(u,p,f)=>f<o&&f<a,intersectsTriangle:(u,p)=>{u.closestPointToPoint(e,hi);const f=e.distanceToSquared(hi);return f<o&&(co.copy(hi),o=f,c=p),f<s}}),o===1/0)return null;const l=Math.sqrt(o);return t.point?t.point.copy(co):t.point=co.clone(),t.distance=l,t.faceIndex=c,t}const Ld=parseInt(Vl)>=169,pn=new W,fn=new W,mn=new W,Ir=new kn,zr=new kn,Br=new kn,tl=new W,nl=new W,il=new W,di=new W;function Fd(r,e,t,n,i,s,a,o){let c;if(s===Fl?c=r.intersectTriangle(n,t,e,!0,i):c=r.intersectTriangle(e,t,n,s!==ds,i),c===null)return null;const l=r.origin.distanceTo(i);return l<a||l>o?null:{distance:l,point:i.clone()}}function Vd(r,e,t,n,i,s,a,o,c,l,u){pn.fromBufferAttribute(e,s),fn.fromBufferAttribute(e,a),mn.fromBufferAttribute(e,o);const p=Fd(r,pn,fn,mn,di,c,l,u);if(p){const f=new W;un.getBarycoord(di,pn,fn,mn,f),n&&(Ir.fromBufferAttribute(n,s),zr.fromBufferAttribute(n,a),Br.fromBufferAttribute(n,o),p.uv=un.getInterpolation(di,pn,fn,mn,Ir,zr,Br,new kn)),i&&(Ir.fromBufferAttribute(i,s),zr.fromBufferAttribute(i,a),Br.fromBufferAttribute(i,o),p.uv1=un.getInterpolation(di,pn,fn,mn,Ir,zr,Br,new kn)),t&&(tl.fromBufferAttribute(t,s),nl.fromBufferAttribute(t,a),il.fromBufferAttribute(t,o),p.normal=un.getInterpolation(di,pn,fn,mn,tl,nl,il,new W),p.normal.dot(r.direction)>0&&p.normal.multiplyScalar(-1));const m={a:s,b:a,c:o,normal:new W,materialIndex:0};un.getNormal(pn,fn,mn,m.normal),p.face=m,p.faceIndex=s,Ld&&(p.barycoord=f)}return p}function Nr(r,e,t,n,i,s,a){const o=n*3;let c=o+0,l=o+1,u=o+2;const p=r.index;r.index&&(c=p.getX(c),l=p.getX(l),u=p.getX(u));const{position:f,normal:m,uv:b,uv1:x}=r.attributes,g=Vd(t,f,m,b,x,c,l,u,e,s,a);return g?(g.faceIndex=n,i&&i.push(g),g):null}function Me(r,e,t,n){const i=r.a,s=r.b,a=r.c;let o=e,c=e+1,l=e+2;t&&(o=t.getX(o),c=t.getX(c),l=t.getX(l)),i.x=n.getX(o),i.y=n.getY(o),i.z=n.getZ(o),s.x=n.getX(c),s.y=n.getY(c),s.z=n.getZ(c),a.x=n.getX(l),a.y=n.getY(l),a.z=n.getZ(l)}function jd(r,e,t,n,i,s,a,o){const{geometry:c,_indirectBuffer:l}=r;for(let u=n,p=n+i;u<p;u++)Nr(c,e,t,u,s,a,o)}function Jd(r,e,t,n,i,s,a){const{geometry:o,_indirectBuffer:c}=r;let l=1/0,u=null;for(let p=n,f=n+i;p<f;p++){let m;m=Nr(o,e,t,p,null,s,a),m&&m.distance<l&&(u=m,l=m.distance)}return u}function Gd(r,e,t,n,i,s,a){const{geometry:o}=t,{index:c}=o,l=o.attributes.position;for(let u=r,p=e+r;u<p;u++){let f;if(f=u,Me(a,f*3,c,l),a.needsUpdate=!0,n(a,f,i,s))return!0}return!1}function Wd(r,e=null){e&&Array.isArray(e)&&(e=new Set(e));const t=r.geometry,n=t.index?t.index.array:null,i=t.attributes.position;let s,a,o,c,l=0;const u=r._roots;for(let f=0,m=u.length;f<m;f++)s=u[f],a=new Uint32Array(s),o=new Uint16Array(s),c=new Float32Array(s),p(0,l),l+=s.byteLength;function p(f,m,b=!1){const x=f*2;if(o[x+15]===Pr){const g=a[f+6],v=o[x+14];let _=1/0,w=1/0,C=1/0,M=-1/0,E=-1/0,P=-1/0;for(let O=3*g,R=3*(g+v);O<R;O++){let A=n[O];const B=i.getX(A),z=i.getY(A),D=i.getZ(A);B<_&&(_=B),B>M&&(M=B),z<w&&(w=z),z>E&&(E=z),D<C&&(C=D),D>P&&(P=D)}return c[f+0]!==_||c[f+1]!==w||c[f+2]!==C||c[f+3]!==M||c[f+4]!==E||c[f+5]!==P?(c[f+0]=_,c[f+1]=w,c[f+2]=C,c[f+3]=M,c[f+4]=E,c[f+5]=P,!0):!1}else{const g=f+8,v=a[f+6],_=g+m,w=v+m;let C=b,M=!1,E=!1;e?C||(M=e.has(_),E=e.has(w),C=!M&&!E):(M=!0,E=!0);const P=C||M,O=C||E;let R=!1;P&&(R=p(g,m,C));let A=!1;O&&(A=p(v,m,C));const B=R||A;if(B)for(let z=0;z<3;z++){const D=g+z,F=v+z,H=c[D],q=c[D+3],$=c[F],J=c[F+3];c[f+z]=H<$?H:$,c[f+z+3]=q>J?q:J}return B}}}function rn(r,e,t,n,i){let s,a,o,c,l,u;const p=1/t.direction.x,f=1/t.direction.y,m=1/t.direction.z,b=t.origin.x,x=t.origin.y,g=t.origin.z;let v=e[r],_=e[r+3],w=e[r+1],C=e[r+3+1],M=e[r+2],E=e[r+3+2];return p>=0?(s=(v-b)*p,a=(_-b)*p):(s=(_-b)*p,a=(v-b)*p),f>=0?(o=(w-x)*f,c=(C-x)*f):(o=(C-x)*f,c=(w-x)*f),s>c||o>a||((o>s||isNaN(s))&&(s=o),(c<a||isNaN(a))&&(a=c),m>=0?(l=(M-g)*m,u=(E-g)*m):(l=(E-g)*m,u=(M-g)*m),s>u||l>a)?!1:((l>s||s!==s)&&(s=l),(u<a||a!==a)&&(a=u),s<=i&&a>=n)}function Hd(r,e,t,n,i,s,a,o){const{geometry:c,_indirectBuffer:l}=r;for(let u=n,p=n+i;u<p;u++){let f=l?l[u]:u;Nr(c,e,t,f,s,a,o)}}function qd(r,e,t,n,i,s,a){const{geometry:o,_indirectBuffer:c}=r;let l=1/0,u=null;for(let p=n,f=n+i;p<f;p++){let m;m=Nr(o,e,t,c?c[p]:p,null,s,a),m&&m.distance<l&&(u=m,l=m.distance)}return u}function Xd(r,e,t,n,i,s,a){const{geometry:o}=t,{index:c}=o,l=o.attributes.position;for(let u=r,p=e+r;u<p;u++){let f;if(f=t.resolveTriangleIndex(u),Me(a,f*3,c,l),a.needsUpdate=!0,n(a,f,i,s))return!0}return!1}function Yd(r,e,t,n,i,s,a){de.setBuffer(r._roots[e]),lo(0,r,t,n,i,s,a),de.clearBuffer()}function lo(r,e,t,n,i,s,a){const{float32Array:o,uint16Array:c,uint32Array:l}=de,u=r*2;if(et(u,c)){const p=ct(r,l),f=pt(u,c);jd(e,t,n,p,f,i,s,a)}else{const p=ft(r);rn(p,o,n,s,a)&&lo(p,e,t,n,i,s,a);const f=mt(r,l);rn(f,o,n,s,a)&&lo(f,e,t,n,i,s,a)}}const Zd=["x","y","z"];function Kd(r,e,t,n,i,s){de.setBuffer(r._roots[e]);const a=uo(0,r,t,n,i,s);return de.clearBuffer(),a}function uo(r,e,t,n,i,s){const{float32Array:a,uint16Array:o,uint32Array:c}=de;let l=r*2;if(et(l,o)){const u=ct(r,c),p=pt(l,o);return Jd(e,t,n,u,p,i,s)}else{const u=Qc(r,c),p=Zd[u],f=n.direction[p]>=0;let m,b;f?(m=ft(r),b=mt(r,c)):(m=mt(r,c),b=ft(r));const x=rn(m,a,n,i,s)?uo(m,e,t,n,i,s):null;if(x){const v=x.point[p];if(f?v<=a[b+u]:v>=a[b+u+3])return x}const g=rn(b,a,n,i,s)?uo(b,e,t,n,i,s):null;return x&&g?x.distance<=g.distance?x:g:x||g||null}}const Ur=new Ot,Un=new yt,Dn=new yt,pi=new Ct,rl=new Ve,Dr=new Ve;function Qd(r,e,t,n){de.setBuffer(r._roots[e]);const i=ho(0,r,t,n);return de.clearBuffer(),i}function ho(r,e,t,n,i=null){const{float32Array:s,uint16Array:a,uint32Array:o}=de;let c=r*2;if(i===null&&(t.boundingBox||t.computeBoundingBox(),rl.set(t.boundingBox.min,t.boundingBox.max,n),i=rl),et(c,a)){const l=e.geometry,u=l.index,p=l.attributes.position,f=t.index,m=t.attributes.position,b=ct(r,o),x=pt(c,a);if(pi.copy(n).invert(),t.boundsTree)return ve(r,s,Dr),Dr.matrix.copy(pi),Dr.needsUpdate=!0,t.boundsTree.shapecast({intersectsBounds:g=>Dr.intersectsBox(g),intersectsTriangle:g=>{g.a.applyMatrix4(n),g.b.applyMatrix4(n),g.c.applyMatrix4(n),g.needsUpdate=!0;for(let v=b*3,_=(x+b)*3;v<_;v+=3)if(Me(Dn,v,u,p),Dn.needsUpdate=!0,g.intersectsTriangle(Dn))return!0;return!1}});for(let g=b*3,v=(x+b)*3;g<v;g+=3){Me(Un,g,u,p),Un.a.applyMatrix4(pi),Un.b.applyMatrix4(pi),Un.c.applyMatrix4(pi),Un.needsUpdate=!0;for(let _=0,w=f.count;_<w;_+=3)if(Me(Dn,_,f,m),Dn.needsUpdate=!0,Un.intersectsTriangle(Dn))return!0}}else{const l=r+8,u=o[r+6];return ve(l,s,Ur),!!(i.intersectsBox(Ur)&&ho(l,e,t,n,i)||(ve(u,s,Ur),i.intersectsBox(Ur)&&ho(u,e,t,n,i)))}}const Lr=new Ct,po=new Ve,fi=new Ve,$d=new W,ep=new W,tp=new W,np=new W;function ip(r,e,t,n={},i={},s=0,a=1/0){e.boundingBox||e.computeBoundingBox(),po.set(e.boundingBox.min,e.boundingBox.max,t),po.needsUpdate=!0;const o=r.geometry,c=o.attributes.position,l=o.index,u=e.attributes.position,p=e.index,f=gt.getPrimitive(),m=gt.getPrimitive();let b=$d,x=ep,g=null,v=null;i&&(g=tp,v=np);let _=1/0,w=null,C=null;return Lr.copy(t).invert(),fi.matrix.copy(Lr),r.shapecast({boundsTraverseOrder:M=>po.distanceToBox(M),intersectsBounds:(M,E,P)=>P<_&&P<a?(E&&(fi.min.copy(M.min),fi.max.copy(M.max),fi.needsUpdate=!0),!0):!1,intersectsRange:(M,E)=>{if(e.boundsTree)return e.boundsTree.shapecast({boundsTraverseOrder:P=>fi.distanceToBox(P),intersectsBounds:(P,O,R)=>R<_&&R<a,intersectsRange:(P,O)=>{for(let R=P,A=P+O;R<A;R++){Me(m,3*R,p,u),m.a.applyMatrix4(t),m.b.applyMatrix4(t),m.c.applyMatrix4(t),m.needsUpdate=!0;for(let B=M,z=M+E;B<z;B++){Me(f,3*B,l,c),f.needsUpdate=!0;const D=f.distanceToTriangle(m,b,g);if(D<_&&(x.copy(b),v&&v.copy(g),_=D,w=B,C=R),D<s)return!0}}}});{const P=zn(e);for(let O=0,R=P;O<R;O++){Me(m,3*O,p,u),m.a.applyMatrix4(t),m.b.applyMatrix4(t),m.c.applyMatrix4(t),m.needsUpdate=!0;for(let A=M,B=M+E;A<B;A++){Me(f,3*A,l,c),f.needsUpdate=!0;const z=f.distanceToTriangle(m,b,g);if(z<_&&(x.copy(b),v&&v.copy(g),_=z,w=A,C=O),z<s)return!0}}}}}),gt.releasePrimitive(f),gt.releasePrimitive(m),_===1/0?null:(n.point?n.point.copy(x):n.point=x.clone(),n.distance=_,n.faceIndex=w,i&&(i.point?i.point.copy(v):i.point=v.clone(),i.point.applyMatrix4(Lr),x.applyMatrix4(Lr),i.distance=x.sub(i.point).length(),i.faceIndex=C),n)}function rp(r,e=null){e&&Array.isArray(e)&&(e=new Set(e));const t=r.geometry,n=t.index?t.index.array:null,i=t.attributes.position;let s,a,o,c,l=0;const u=r._roots;for(let f=0,m=u.length;f<m;f++)s=u[f],a=new Uint32Array(s),o=new Uint16Array(s),c=new Float32Array(s),p(0,l),l+=s.byteLength;function p(f,m,b=!1){const x=f*2;if(o[x+15]===Pr){const g=a[f+6],v=o[x+14];let _=1/0,w=1/0,C=1/0,M=-1/0,E=-1/0,P=-1/0;for(let O=g,R=g+v;O<R;O++){const A=3*r.resolveTriangleIndex(O);for(let B=0;B<3;B++){let z=A+B;z=n?n[z]:z;const D=i.getX(z),F=i.getY(z),H=i.getZ(z);D<_&&(_=D),D>M&&(M=D),F<w&&(w=F),F>E&&(E=F),H<C&&(C=H),H>P&&(P=H)}}return c[f+0]!==_||c[f+1]!==w||c[f+2]!==C||c[f+3]!==M||c[f+4]!==E||c[f+5]!==P?(c[f+0]=_,c[f+1]=w,c[f+2]=C,c[f+3]=M,c[f+4]=E,c[f+5]=P,!0):!1}else{const g=f+8,v=a[f+6],_=g+m,w=v+m;let C=b,M=!1,E=!1;e?C||(M=e.has(_),E=e.has(w),C=!M&&!E):(M=!0,E=!0);const P=C||M,O=C||E;let R=!1;P&&(R=p(g,m,C));let A=!1;O&&(A=p(v,m,C));const B=R||A;if(B)for(let z=0;z<3;z++){const D=g+z,F=v+z,H=c[D],q=c[D+3],$=c[F],J=c[F+3];c[f+z]=H<$?H:$,c[f+z+3]=q>J?q:J}return B}}}function sp(r,e,t,n,i,s,a){de.setBuffer(r._roots[e]),fo(0,r,t,n,i,s,a),de.clearBuffer()}function fo(r,e,t,n,i,s,a){const{float32Array:o,uint16Array:c,uint32Array:l}=de,u=r*2;if(et(u,c)){const p=ct(r,l),f=pt(u,c);Hd(e,t,n,p,f,i,s,a)}else{const p=ft(r);rn(p,o,n,s,a)&&fo(p,e,t,n,i,s,a);const f=mt(r,l);rn(f,o,n,s,a)&&fo(f,e,t,n,i,s,a)}}const op=["x","y","z"];function ap(r,e,t,n,i,s){de.setBuffer(r._roots[e]);const a=mo(0,r,t,n,i,s);return de.clearBuffer(),a}function mo(r,e,t,n,i,s){const{float32Array:a,uint16Array:o,uint32Array:c}=de;let l=r*2;if(et(l,o)){const u=ct(r,c),p=pt(l,o);return qd(e,t,n,u,p,i,s)}else{const u=Qc(r,c),p=op[u],f=n.direction[p]>=0;let m,b;f?(m=ft(r),b=mt(r,c)):(m=mt(r,c),b=ft(r));const x=rn(m,a,n,i,s)?mo(m,e,t,n,i,s):null;if(x){const v=x.point[p];if(f?v<=a[b+u]:v>=a[b+u+3])return x}const g=rn(b,a,n,i,s)?mo(b,e,t,n,i,s):null;return x&&g?x.distance<=g.distance?x:g:x||g||null}}const Fr=new Ot,Ln=new yt,Fn=new yt,mi=new Ct,sl=new Ve,Vr=new Ve;function cp(r,e,t,n){de.setBuffer(r._roots[e]);const i=yo(0,r,t,n);return de.clearBuffer(),i}function yo(r,e,t,n,i=null){const{float32Array:s,uint16Array:a,uint32Array:o}=de;let c=r*2;if(i===null&&(t.boundingBox||t.computeBoundingBox(),sl.set(t.boundingBox.min,t.boundingBox.max,n),i=sl),et(c,a)){const l=e.geometry,u=l.index,p=l.attributes.position,f=t.index,m=t.attributes.position,b=ct(r,o),x=pt(c,a);if(mi.copy(n).invert(),t.boundsTree)return ve(r,s,Vr),Vr.matrix.copy(mi),Vr.needsUpdate=!0,t.boundsTree.shapecast({intersectsBounds:g=>Vr.intersectsBox(g),intersectsTriangle:g=>{g.a.applyMatrix4(n),g.b.applyMatrix4(n),g.c.applyMatrix4(n),g.needsUpdate=!0;for(let v=b,_=x+b;v<_;v++)if(Me(Fn,3*e.resolveTriangleIndex(v),u,p),Fn.needsUpdate=!0,g.intersectsTriangle(Fn))return!0;return!1}});for(let g=b,v=x+b;g<v;g++){const _=e.resolveTriangleIndex(g);Me(Ln,3*_,u,p),Ln.a.applyMatrix4(mi),Ln.b.applyMatrix4(mi),Ln.c.applyMatrix4(mi),Ln.needsUpdate=!0;for(let w=0,C=f.count;w<C;w+=3)if(Me(Fn,w,f,m),Fn.needsUpdate=!0,Ln.intersectsTriangle(Fn))return!0}}else{const l=r+8,u=o[r+6];return ve(l,s,Fr),!!(i.intersectsBox(Fr)&&yo(l,e,t,n,i)||(ve(u,s,Fr),i.intersectsBox(Fr)&&yo(u,e,t,n,i)))}}const jr=new Ct,go=new Ve,yi=new Ve,lp=new W,up=new W,hp=new W,dp=new W;function pp(r,e,t,n={},i={},s=0,a=1/0){e.boundingBox||e.computeBoundingBox(),go.set(e.boundingBox.min,e.boundingBox.max,t),go.needsUpdate=!0;const o=r.geometry,c=o.attributes.position,l=o.index,u=e.attributes.position,p=e.index,f=gt.getPrimitive(),m=gt.getPrimitive();let b=lp,x=up,g=null,v=null;i&&(g=hp,v=dp);let _=1/0,w=null,C=null;return jr.copy(t).invert(),yi.matrix.copy(jr),r.shapecast({boundsTraverseOrder:M=>go.distanceToBox(M),intersectsBounds:(M,E,P)=>P<_&&P<a?(E&&(yi.min.copy(M.min),yi.max.copy(M.max),yi.needsUpdate=!0),!0):!1,intersectsRange:(M,E)=>{if(e.boundsTree){const P=e.boundsTree;return P.shapecast({boundsTraverseOrder:O=>yi.distanceToBox(O),intersectsBounds:(O,R,A)=>A<_&&A<a,intersectsRange:(O,R)=>{for(let A=O,B=O+R;A<B;A++){const z=P.resolveTriangleIndex(A);Me(m,3*z,p,u),m.a.applyMatrix4(t),m.b.applyMatrix4(t),m.c.applyMatrix4(t),m.needsUpdate=!0;for(let D=M,F=M+E;D<F;D++){const H=r.resolveTriangleIndex(D);Me(f,3*H,l,c),f.needsUpdate=!0;const q=f.distanceToTriangle(m,b,g);if(q<_&&(x.copy(b),v&&v.copy(g),_=q,w=D,C=A),q<s)return!0}}}})}else{const P=zn(e);for(let O=0,R=P;O<R;O++){Me(m,3*O,p,u),m.a.applyMatrix4(t),m.b.applyMatrix4(t),m.c.applyMatrix4(t),m.needsUpdate=!0;for(let A=M,B=M+E;A<B;A++){const z=r.resolveTriangleIndex(A);Me(f,3*z,l,c),f.needsUpdate=!0;const D=f.distanceToTriangle(m,b,g);if(D<_&&(x.copy(b),v&&v.copy(g),_=D,w=A,C=O),D<s)return!0}}}}}),gt.releasePrimitive(f),gt.releasePrimitive(m),_===1/0?null:(n.point?n.point.copy(x):n.point=x.clone(),n.distance=_,n.faceIndex=w,i&&(i.point?i.point.copy(v):i.point=v.clone(),i.point.applyMatrix4(jr),x.applyMatrix4(jr),i.distance=x.sub(i.point).length(),i.faceIndex=C),n)}function fp(){return typeof SharedArrayBuffer<"u"}const gi=new de.constructor,Jr=new de.constructor,sn=new oo(()=>new Ot),Vn=new Ot,jn=new Ot,vo=new Ot,So=new Ot;let bo=!1;function mp(r,e,t,n){if(bo)throw new Error("MeshBVH: Recursive calls to bvhcast not supported.");bo=!0;const i=r._roots,s=e._roots;let a,o=0,c=0;const l=new Ct().copy(t).invert();for(let u=0,p=i.length;u<p;u++){gi.setBuffer(i[u]),c=0;const f=sn.getPrimitive();ve(0,gi.float32Array,f),f.applyMatrix4(l);for(let m=0,b=s.length;m<b&&(Jr.setBuffer(s[m]),a=kt(0,0,t,l,n,o,c,0,0,f),Jr.clearBuffer(),c+=s[m].length,!a);m++);if(sn.releasePrimitive(f),gi.clearBuffer(),o+=i[u].length,a)break}return bo=!1,a}function kt(r,e,t,n,i,s=0,a=0,o=0,c=0,l=null,u=!1){let p,f;u?(p=Jr,f=gi):(p=gi,f=Jr);const m=p.float32Array,b=p.uint32Array,x=p.uint16Array,g=f.float32Array,v=f.uint32Array,_=f.uint16Array,w=r*2,C=e*2,M=et(w,x),E=et(C,_);let P=!1;if(E&&M)u?P=i(ct(e,v),pt(e*2,_),ct(r,b),pt(r*2,x),c,a+e,o,s+r):P=i(ct(r,b),pt(r*2,x),ct(e,v),pt(e*2,_),o,s+r,c,a+e);else if(E){const O=sn.getPrimitive();ve(e,g,O),O.applyMatrix4(t);const R=ft(r),A=mt(r,b);ve(R,m,Vn),ve(A,m,jn);const B=O.intersectsBox(Vn),z=O.intersectsBox(jn);P=B&&kt(e,R,n,t,i,a,s,c,o+1,O,!u)||z&&kt(e,A,n,t,i,a,s,c,o+1,O,!u),sn.releasePrimitive(O)}else{const O=ft(e),R=mt(e,v);ve(O,g,vo),ve(R,g,So);const A=l.intersectsBox(vo),B=l.intersectsBox(So);if(A&&B)P=kt(r,O,t,n,i,s,a,o,c+1,l,u)||kt(r,R,t,n,i,s,a,o,c+1,l,u);else if(A)if(M)P=kt(r,O,t,n,i,s,a,o,c+1,l,u);else{const z=sn.getPrimitive();z.copy(vo).applyMatrix4(t);const D=ft(r),F=mt(r,b);ve(D,m,Vn),ve(F,m,jn);const H=z.intersectsBox(Vn),q=z.intersectsBox(jn);P=H&&kt(O,D,n,t,i,a,s,c,o+1,z,!u)||q&&kt(O,F,n,t,i,a,s,c,o+1,z,!u),sn.releasePrimitive(z)}else if(B)if(M)P=kt(r,R,t,n,i,s,a,o,c+1,l,u);else{const z=sn.getPrimitive();z.copy(So).applyMatrix4(t);const D=ft(r),F=mt(r,b);ve(D,m,Vn),ve(F,m,jn);const H=z.intersectsBox(Vn),q=z.intersectsBox(jn);P=H&&kt(R,D,n,t,i,a,s,c,o+1,z,!u)||q&&kt(R,F,n,t,i,a,s,c,o+1,z,!u),sn.releasePrimitive(z)}}return P}const Gr=new Ve,ol=new Ot,yp={strategy:Zs,maxDepth:40,maxLeafTris:10,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,indirect:!1,verbose:!0,range:null};class xi{static serialize(e,t={}){t={cloneBuffers:!0,...t};const n=e.geometry,i=e._roots,s=e._indirectBuffer,a=n.getIndex();let o;return t.cloneBuffers?o={roots:i.map(c=>c.slice()),index:a?a.array.slice():null,indirectBuffer:s?s.slice():null}:o={roots:i,index:a?a.array:null,indirectBuffer:s},o}static deserialize(e,t,n={}){n={setIndex:!0,indirect:!!e.indirectBuffer,...n};const{index:i,roots:s,indirectBuffer:a}=e,o=new xi(t,{...n,[$s]:!0});if(o._roots=s,o._indirectBuffer=a||null,n.setIndex){const c=t.getIndex();if(c===null){const l=new ot(e.index,1,!1);t.setIndex(l)}else c.array!==i&&(c.array.set(i),c.needsUpdate=!0)}return o}get indirect(){return!!this._indirectBuffer}constructor(e,t={}){if(e.isBufferGeometry){if(e.index&&e.index.isInterleavedBufferAttribute)throw new Error("MeshBVH: InterleavedBufferAttribute is not supported for the index attribute.")}else throw new Error("MeshBVH: Only BufferGeometries are supported.");if(t=Object.assign({...yp,[$s]:!1},t),t.useSharedArrayBuffer&&!fp())throw new Error("MeshBVH: SharedArrayBuffer is not available.");this.geometry=e,this._roots=null,this._indirectBuffer=null,t[$s]||(Ad(this,t),!e.boundingBox&&t.setBoundingBox&&(e.boundingBox=this.getBoundingBox(new Ot))),this.resolveTriangleIndex=t.indirect?n=>this._indirectBuffer[n]:n=>n}refit(e=null){return(this.indirect?rp:Wd)(this,e)}traverse(e,t=0){const n=this._roots[t],i=new Uint32Array(n),s=new Uint16Array(n);a(0);function a(o,c=0){const l=o*2,u=s[l+15]===Pr;if(u){const p=i[o+6],f=s[l+14];e(c,u,new Float32Array(n,o*4,6),p,f)}else{const p=o+ci/4,f=i[o+6],m=i[o+7];e(c,u,new Float32Array(n,o*4,6),m)||(a(p,c+1),a(f,c+1))}}}raycast(e,t=ea,n=0,i=1/0){const s=this._roots,a=this.geometry,o=[],c=t.isMaterial,l=Array.isArray(t),u=a.groups,p=c?t.side:t,f=this.indirect?sp:Yd;for(let m=0,b=s.length;m<b;m++){const x=l?t[u[m].materialIndex].side:p,g=o.length;if(f(this,m,x,e,o,n,i),l){const v=u[m].materialIndex;for(let _=g,w=o.length;_<w;_++)o[_].face.materialIndex=v}}return o}raycastFirst(e,t=ea,n=0,i=1/0){const s=this._roots,a=this.geometry,o=t.isMaterial,c=Array.isArray(t);let l=null;const u=a.groups,p=o?t.side:t,f=this.indirect?ap:Kd;for(let m=0,b=s.length;m<b;m++){const x=c?t[u[m].materialIndex].side:p,g=f(this,m,x,e,n,i);g!=null&&(l==null||g.distance<l.distance)&&(l=g,c&&(g.face.materialIndex=u[m].materialIndex))}return l}intersectsGeometry(e,t){let n=!1;const i=this._roots,s=this.indirect?cp:Qd;for(let a=0,o=i.length;a<o&&(n=s(this,a,e,t),!n);a++);return n}shapecast(e){const t=gt.getPrimitive(),n=this.indirect?Xd:Gd;let{boundsTraverseOrder:i,intersectsBounds:s,intersectsRange:a,intersectsTriangle:o}=e;if(a&&o){const p=a;a=(f,m,b,x,g)=>p(f,m,b,x,g)?!0:n(f,m,this,o,b,x,t)}else a||(o?a=(p,f,m,b)=>n(p,f,this,o,m,b,t):a=(p,f,m)=>m);let c=!1,l=0;const u=this._roots;for(let p=0,f=u.length;p<f;p++){const m=u[p];if(c=Ud(this,p,s,a,i,l),c)break;l+=m.byteLength}return gt.releasePrimitive(t),c}bvhcast(e,t,n){let{intersectsRanges:i,intersectsTriangles:s}=n;const a=gt.getPrimitive(),o=this.geometry.index,c=this.geometry.attributes.position,l=this.indirect?b=>{const x=this.resolveTriangleIndex(b);Me(a,x*3,o,c)}:b=>{Me(a,b*3,o,c)},u=gt.getPrimitive(),p=e.geometry.index,f=e.geometry.attributes.position,m=e.indirect?b=>{const x=e.resolveTriangleIndex(b);Me(u,x*3,p,f)}:b=>{Me(u,b*3,p,f)};if(s){const b=(x,g,v,_,w,C,M,E)=>{for(let P=v,O=v+_;P<O;P++){m(P),u.a.applyMatrix4(t),u.b.applyMatrix4(t),u.c.applyMatrix4(t),u.needsUpdate=!0;for(let R=x,A=x+g;R<A;R++)if(l(R),a.needsUpdate=!0,s(a,u,R,P,w,C,M,E))return!0}return!1};if(i){const x=i;i=function(g,v,_,w,C,M,E,P){return x(g,v,_,w,C,M,E,P)?!0:b(g,v,_,w,C,M,E,P)}}else i=b}return mp(this,e,t,i)}intersectsBox(e,t){return Gr.set(e.min,e.max,t),Gr.needsUpdate=!0,this.shapecast({intersectsBounds:n=>Gr.intersectsBox(n),intersectsTriangle:n=>Gr.intersectsTriangle(n)})}intersectsSphere(e){return this.shapecast({intersectsBounds:t=>e.intersectsBox(t),intersectsTriangle:t=>t.intersectsSphere(e)})}closestPointToGeometry(e,t,n={},i={},s=0,a=1/0){return(this.indirect?pp:ip)(this,e,t,n,i,s,a)}closestPointToPoint(e,t={},n=0,i=1/0){return Dd(this,e,t,n,i)}getBoundingBox(e){return e.makeEmpty(),this._roots.forEach(t=>{ve(0,new Float32Array(t),ol),e.union(ol)}),e}}function al(r,e,t){return r===null?null:(r.point.applyMatrix4(e.matrixWorld),r.distance=r.point.distanceTo(t.ray.origin),r.object=e,r)}const Wr=new Jl,cl=new W,ll=new Ct,gp=fs.prototype.raycast,vp=jl.prototype.raycast,ul=new W,Ue=new fs,Hr=[];function Sp(r,e){this.isBatchedMesh?bp.call(this,r,e):xp.call(this,r,e)}function bp(r,e){if(this.boundsTrees){const t=this.boundsTrees,n=this._drawInfo||this._instanceInfo,i=this._drawRanges||this._geometryInfo,s=this.matrixWorld;Ue.material=this.material,Ue.geometry=this.geometry;const a=Ue.geometry.boundsTree,o=Ue.geometry.drawRange;Ue.geometry.boundingSphere===null&&(Ue.geometry.boundingSphere=new $o);for(let c=0,l=n.length;c<l;c++){if(!this.getVisibleAt(c))continue;const u=n[c].geometryIndex;if(Ue.geometry.boundsTree=t[u],this.getMatrixAt(c,Ue.matrixWorld).premultiply(s),!Ue.geometry.boundsTree){this.getBoundingBoxAt(u,Ue.geometry.boundingBox),this.getBoundingSphereAt(u,Ue.geometry.boundingSphere);const p=i[u];Ue.geometry.setDrawRange(p.start,p.count)}Ue.raycast(r,Hr);for(let p=0,f=Hr.length;p<f;p++){const m=Hr[p];m.object=this,m.batchId=c,e.push(m)}Hr.length=0}Ue.geometry.boundsTree=a,Ue.geometry.drawRange=o,Ue.material=null,Ue.geometry=null}else vp.call(this,r,e)}function xp(r,e){if(this.geometry.boundsTree){if(this.material===void 0)return;ll.copy(this.matrixWorld).invert(),Wr.copy(r.ray).applyMatrix4(ll),ul.setFromMatrixScale(this.matrixWorld),cl.copy(Wr.direction).multiply(ul);const t=cl.length(),n=r.near/t,i=r.far/t,s=this.geometry.boundsTree;if(r.firstHitOnly===!0){const a=al(s.raycastFirst(Wr,this.material,n,i),this,r);a&&e.push(a)}else{const a=s.raycast(Wr,this.material,n,i);for(let o=0,c=a.length;o<c;o++){const l=al(a[o],this,r);l&&e.push(l)}}}else gp.call(this,r,e)}function wp(r={}){return this.boundsTree=new xi(this,r),this.boundsTree}const yn=new W,gn=new W,vn=new W,hl=new ms,qr=new W,xo=new W,dl=new ms,pl=new ms,Xr=new Ct,fl=new Ct;function vi(r,e){if(!r&&!e)return;const t=r.count===e.count,n=r.normalized===e.normalized,i=r.array.constructor===e.array.constructor,s=r.itemSize===e.itemSize;if(!t||!n||!i||!s)throw new Error}function Si(r,e=null){const t=r.array.constructor,n=r.normalized,i=r.itemSize,s=e===null?r.count:e;return new ot(new t(i*s),i,n)}function ml(r,e,t=0){if(r.isInterleavedBufferAttribute){const n=r.itemSize;for(let i=0,s=r.count;i<s;i++){const a=i+t;e.setX(a,r.getX(i)),n>=2&&e.setY(a,r.getY(i)),n>=3&&e.setZ(a,r.getZ(i)),n>=4&&e.setW(a,r.getW(i))}}else{const n=e.array,i=n.constructor,s=n.BYTES_PER_ELEMENT*r.itemSize*t;new i(n.buffer,s,r.array.length).set(r.array)}}function _p(r,e,t){const n=r.elements,i=e.elements;for(let s=0,a=i.length;s<a;s++)n[s]+=i[s]*t}function yl(r,e,t){const n=r.skeleton,i=r.geometry,s=n.bones,a=n.boneInverses;dl.fromBufferAttribute(i.attributes.skinIndex,e),pl.fromBufferAttribute(i.attributes.skinWeight,e),Xr.elements.fill(0);for(let o=0;o<4;o++){const c=pl.getComponent(o);if(c!==0){const l=dl.getComponent(o);fl.multiplyMatrices(s[l].matrixWorld,a[l]),_p(Xr,fl,c)}}return Xr.multiply(r.bindMatrix).premultiply(r.bindMatrixInverse),t.transformDirection(Xr),t}function wo(r,e,t,n,i){qr.set(0,0,0);for(let s=0,a=r.length;s<a;s++){const o=e[s],c=r[s];o!==0&&(xo.fromBufferAttribute(c,n),t?qr.addScaledVector(xo,o):qr.addScaledVector(xo.sub(i),o))}i.add(qr)}function Tp(r,e={useGroups:!1,updateIndex:!1,skipAttributes:[]},t=new Yn){const n=r[0].index!==null,{useGroups:i=!1,updateIndex:s=!1,skipAttributes:a=[]}=e,o=new Set(Object.keys(r[0].attributes)),c={};let l=0;t.clearGroups();for(let u=0;u<r.length;++u){const p=r[u];let f=0;if(n!==(p.index!==null))throw new Error("StaticGeometryGenerator: All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them.");for(const m in p.attributes){if(!o.has(m))throw new Error('StaticGeometryGenerator: All geometries must have compatible attributes; make sure "'+m+'" attribute exists among all geometries, or in none of them.');c[m]===void 0&&(c[m]=[]),c[m].push(p.attributes[m]),f++}if(f!==o.size)throw new Error("StaticGeometryGenerator: Make sure all geometries have the same number of attributes.");if(i){let m;if(n)m=p.index.count;else if(p.attributes.position!==void 0)m=p.attributes.position.count;else throw new Error("StaticGeometryGenerator: The geometry must have either an index or a position attribute");t.addGroup(l,m,u),l+=m}}if(n){let u=!1;if(!t.index){let p=0;for(let f=0;f<r.length;++f)p+=r[f].index.count;t.setIndex(new ot(new Uint32Array(p),1,!1)),u=!0}if(s||u){const p=t.index;let f=0,m=0;for(let b=0;b<r.length;++b){const x=r[b],g=x.index;if(a[b]!==!0)for(let v=0;v<g.count;++v)p.setX(f,g.getX(v)+m),f++;m+=x.attributes.position.count}}}for(const u in c){const p=c[u];if(!(u in t.attributes)){let b=0;for(const x in p)b+=p[x].count;t.setAttribute(u,Si(c[u][0],b))}const f=t.attributes[u];let m=0;for(let b=0,x=p.length;b<x;b++){const g=p[b];a[b]!==!0&&ml(g,f,m),m+=g.count}}return t}function Mp(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 Cp(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 Ep{constructor(e){this.matrixWorld=new Ct,this.geometryHash=null,this.boneMatrices=null,this.primitiveCount=-1,this.mesh=e,this.update()}update(){const e=this.mesh,t=e.geometry,n=e.skeleton,i=(t.index?t.index.count:t.attributes.position.count)/3;if(this.matrixWorld.copy(e.matrixWorld),this.geometryHash=t.attributes.position.version,this.primitiveCount=i,n){n.boneTexture||n.computeBoneTexture(),n.update();const s=n.boneMatrices;!this.boneMatrices||this.boneMatrices.length!==s.length?this.boneMatrices=s.slice():this.boneMatrices.set(s)}else this.boneMatrices=null}didChange(){const e=this.mesh,t=e.geometry,n=(t.index?t.index.count:t.attributes.position.count)/3;return!(this.matrixWorld.equals(e.matrixWorld)&&this.geometryHash===t.attributes.position.version&&Mp(e.skeleton&&e.skeleton.boneMatrices||null,this.boneMatrices)&&this.primitiveCount===n)}}class Pp{constructor(e){Array.isArray(e)||(e=[e]);const t=[];e.forEach(n=>{n.traverseVisible(i=>{i.isMesh&&t.push(i)})}),this.meshes=t,this.useGroups=!0,this.applyWorldTransforms=!0,this.attributes=["position","normal","color","tangent","uv","uv2"],this._intermediateGeometry=new Array(t.length).fill().map(()=>new Yn),this._diffMap=new WeakMap}getMaterials(){const e=[];return this.meshes.forEach(t=>{Array.isArray(t.material)?e.push(...t.material):e.push(t.material)}),e}generate(e=new Yn){let t=[];const{meshes:n,useGroups:i,_intermediateGeometry:s,_diffMap:a}=this;for(let o=0,c=n.length;o<c;o++){const l=n[o],u=s[o],p=a.get(l);!p||p.didChange(l)?(this._convertToStaticGeometry(l,u),t.push(!1),p?p.update():a.set(l,new Ep(l))):t.push(!0)}if(s.length===0){e.setIndex(null);const o=e.attributes;for(const c in o)e.deleteAttribute(c);for(const c in this.attributes)e.setAttribute(this.attributes[c],new ot(new Float32Array(0),4,!1))}else Tp(s,{useGroups:i,skipAttributes:t},e);for(const o in e.attributes)e.attributes[o].needsUpdate=!0;return e}_convertToStaticGeometry(e,t=new Yn){const n=e.geometry,i=this.applyWorldTransforms,s=this.attributes.includes("normal"),a=this.attributes.includes("tangent"),o=n.attributes,c=t.attributes;!t.index&&n.index&&(t.index=n.index.clone()),c.position||t.setAttribute("position",Si(o.position)),s&&!c.normal&&o.normal&&t.setAttribute("normal",Si(o.normal)),a&&!c.tangent&&o.tangent&&t.setAttribute("tangent",Si(o.tangent)),vi(n.index,t.index),vi(o.position,c.position),s&&vi(o.normal,c.normal),a&&vi(o.tangent,c.tangent);const l=o.position,u=s?o.normal:null,p=a?o.tangent:null,f=n.morphAttributes.position,m=n.morphAttributes.normal,b=n.morphAttributes.tangent,x=n.morphTargetsRelative,g=e.morphTargetInfluences,v=new Gl;v.getNormalMatrix(e.matrixWorld),n.index&&t.index.array.set(n.index.array);for(let _=0,w=o.position.count;_<w;_++)yn.fromBufferAttribute(l,_),u&&gn.fromBufferAttribute(u,_),p&&(hl.fromBufferAttribute(p,_),vn.fromBufferAttribute(p,_)),g&&(f&&wo(f,g,x,_,yn),m&&wo(m,g,x,_,gn),b&&wo(b,g,x,_,vn)),e.isSkinnedMesh&&(e.applyBoneTransform(_,yn),u&&yl(e,_,gn),p&&yl(e,_,vn)),i&&yn.applyMatrix4(e.matrixWorld),c.position.setXYZ(_,yn.x,yn.y,yn.z),u&&(i&&gn.applyNormalMatrix(v),c.normal.setXYZ(_,gn.x,gn.y,gn.z)),p&&(i&&vn.transformDirection(e.matrixWorld),c.tangent.setXYZW(_,vn.x,vn.y,vn.z,hl.w));for(const _ in this.attributes){const w=this.attributes[_];w==="position"||w==="tangent"||w==="normal"||!(w in o)||(c[w]||t.setAttribute(w,Si(o[w])),vi(o[w],c[w]),ml(o[w],c[w]))}return e.matrixWorld.determinant()<0&&Cp(t),t}}const kp=Object.freeze(Object.defineProperty({__proto__:null,AVERAGE:Gc,CENTER:Zs,CONTAINED:Ks,ExtendedTriangle:yt,MeshBVH:xi,OrientedBox:Ve,SAH:Wc,StaticGeometryGenerator:Pp,acceleratedRaycast:Sp,computeBoundsTree:wp},Symbol.toStringTag,{value:"Module"}));class Rp{constructor(e){this.name="WorkerBase",this.running=!1,this.worker=e,this.worker.onerror=t=>{throw t.message?new Error(`${this.name}: Could not create Web Worker with error "${t.message}"`):new Error(`${this.name}: Could not create Web Worker.`)}}runTask(){}generate(...e){if(this.running)throw new Error("GenerateMeshBVHWorker: Already running job.");if(this.worker===null)throw new Error("GenerateMeshBVHWorker: Worker has been disposed.");this.running=!0;const t=this.runTask(this.worker,...e);return t.finally(()=>{this.running=!1}),t}dispose(){this.worker.terminate(),this.worker=null}}const vt={node:"node",material:"material",camera:"camera",light:"light"},Sn="KHR_animation_pointer",Ap={CUBICSPLINE:void 0,LINEAR:ta,STEP:Hl};class Op{constructor(e){this.name=Sn,this.parser=e,this.animationPointerResolver=null}setAnimationPointerResolver(e){return this.animationPointerResolver=e,this}loadAnimationTargetFromChannel(e){const t=e.target,n=t.node!==void 0?t.node:t.id;return this.parser.getDependency("node",n)}loadAnimationTargetFromChannelWithAnimationPointer(e){zp();const t=e.target,n=t.extensions&&t.extensions[Sn]&&t.path&&t.path==="pointer";if(!n)return null;let i,s=vt.node,a;if(n){const c=t.extensions[Sn];let l=c.pointer;if(!l){console.warn("Invalid path",c,t);return}if(l.startsWith("/materials/")?s=vt.material:l.startsWith("/extensions/KHR_lights_punctual/lights/")?s=vt.light:l.startsWith("/cameras/")&&(s=vt.camera),a=this._tryResolveTargetId(l,s),a===null||isNaN(a)){console.warn("Failed resolving animation node id: "+a,l);return}switch(s){case vt.material:const u=("/materials/"+a.toString()+"/").length,p=l.substring(0,u);switch(i=l.substring(u),i){case"pbrMetallicRoughness/baseColorFactor":i="color";break;case"pbrMetallicRoughness/roughnessFactor":i="roughness";break;case"pbrMetallicRoughness/metallicFactor":i="metalness";break;case"emissiveFactor":i="emissive";break;case"alphaCutoff":i="alphaTest";break;case"occlusionTexture/strength":i="aoMapIntensity";break;case"normalTexture/scale":i="normalScale";break;case"pbrMetallicRoughness/baseColorTexture/extensions/KHR_texture_transform/scale":i="map/repeat";break;case"pbrMetallicRoughness/baseColorTexture/extensions/KHR_texture_transform/offset":i="map/offset";break;case"emissiveTexture/extensions/KHR_texture_transform/scale":i="emissiveMap/repeat";break;case"emissiveTexture/extensions/KHR_texture_transform/offset":i="emissiveMap/offset";break;case"extensions/KHR_materials_emissive_strength/emissiveStrength":i="emissiveIntensity";break;case"extensions/KHR_materials_transmission/transmissionFactor":i="transmission";break;case"extensions/KHR_materials_ior/ior":i="ior";break;case"extensions/KHR_materials_volume/thicknessFactor":i="thickness";break;case"extensions/KHR_materials_volume/attenuationColor":i="attenuationColor";break;case"extensions/KHR_materials_volume/attenuationDistance":i="attenuationDistance";break;case"extensions/KHR_materials_iridescence/iridescenceFactor":i="iridescence";break;case"extensions/KHR_materials_iridescence/iridescenceIor":i="iridescenceIOR";break;case"extensions/KHR_materials_iridescence/iridescenceThicknessMinimum":i="iridescenceThicknessRange[0]";break;case"extensions/KHR_materials_iridescence/iridescenceThicknessMaximum":i="iridescenceThicknessRange[1]";break;case"extensions/KHR_materials_clearcoat/clearcoatFactor":i="clearcoat";break;case"extensions/KHR_materials_clearcoat/clearcoatRoughnessFactor":i="clearcoatRoughness";break;case"extensions/KHR_materials_sheen/sheenColorFactor":i="sheenColor";break;case"extensions/KHR_materials_sheen/sheenRoughnessFactor":i="sheenRoughness";break;case"extensions/KHR_materials_specular/specularFactor":i="specularIntensity";break;case"extensions/KHR_materials_specular/specularColorFactor":i="specularColor";break}l=p+i;break;case vt.node:const f=("/nodes/"+a.toString()+"/").length,m=l.substring(0,f);switch(i=l.substring(f),i){case"translation":i="position";break;case"rotation":i="quaternion";break;case"scale":i="scale";break;case"weights":i="morphTargetInfluences";break;case"KHR_node_visibility/visible":i="visible";break}l=m+i;break;case vt.light:const b=("/extensions/KHR_lights_punctual/lights/"+a.toString()+"/").length;switch(i=l.substring(b),i){case"color":break;case"intensity":break;case"spot/innerConeAngle":i="penumbra";break;case"spot/outerConeAngle":i="angle";break;case"range":i="distance";break}l="/lights/"+a.toString()+"/"+i;break;case vt.camera:const x=("/cameras/"+a.toString()+"/").length,g=l.substring(0,x);switch(i=l.substring(x),i){case"perspective/yfov":i="fov";break;case"perspective/znear":case"orthographic/znear":i="near";break;case"perspective/zfar":case"orthographic/zfar":i="far";break;case"perspective/aspect":i="aspect";break;case"orthographic/xmag":i="zoom";break;case"orthographic/ymag":i="zoom";break}l=g+i;break}this.animationPointerResolver?.resolvePath&&(l=this.animationPointerResolver.resolvePath(l)),t.extensions[Sn].pointer=l}if(a==null||isNaN(a)){console.warn("Failed resolving animation node id: "+a,t);return}let o;return s===vt.node?o=this.parser.getDependency("node",a):s===vt.material?o=this.parser.getDependency("material",a):s===vt.light?o=this.parser.getDependency("light",a):s===vt.camera?o=this.parser.getDependency("camera",a):console.error("Unhandled type",s),o}createAnimationTracksWithAnimationPointer(e,t,n,i,s){if(!(s.extensions&&s.extensions[Sn]&&s.path&&s.path==="pointer"))return null;let a=s.extensions[Sn].pointer;if(!a)return null;const o=[];a=a.replaceAll("/",".");const c=a.split(".");var l=e.name!==void 0&&e.name!==null?e.name:e.uuid;if(c[2]=l,c[3]==="morphTargetInfluences"&&e.type==="Group"){for(const p of e.children)p instanceof Wl&&p.morphTargetInfluences&&(c[3]=p.name,c[4]="morphTargetInfluences",u(this.parser));return o}u(this.parser);function u(p){a=c.join(".");let f;switch(n.itemSize){case 1:f=Kl;break;case 2:case 3:f=Zl;break;case 4:a.endsWith(".quaternion")?f=Xl:f=Yl;break}if(!f){console.warn("Unsupported output accessor format",n);return}const m=i.interpolation!==void 0?Ap[i.interpolation]:ta;let b=p._getArrayFromAccessor(n);a.endsWith(".fov")&&(b=b.map(g=>g/Math.PI*180));const x=new f(a,t.array,b,m);if(m==="CUBICSPLINE"&&p._createCubicSplineTrackInterpolant(x),o.push(x),a&&n.itemSize===4&&a.startsWith(".materials.")&&a.endsWith(".color")){const g=new Float32Array(b.length/4);for(let _=0,w=b.length/4;_<w;_+=1)g[_]=b[_*4+3];const v=new f(a.replace(".color",".opacity"),t.array,g,m);m==="CUBICSPLINE"&&p._createCubicSplineTrackInterpolant(x),o.push(v)}}return o}_tryResolveTargetId(e,t){let n="";return t==="node"?n=e.substring(7):t==="material"?n=e.substring(11):t==="light"?n=e.substring(39):t==="camera"&&(n=e.substring(9)),n=n.substring(0,n.indexOf("/")),Number.parseInt(n)}loadAnimation(e){const t=this,n=this.parser.json,i=this.parser,s=n.animations[e],a=s.name?s.name:"animation_"+e,o=[],c=[],l=[],u=[],p=[];for(let f=0,m=s.channels.length;f<m;f++){const b=s.channels[f],x=s.samplers[b.sampler],g=b.target,v=s.parameters!==void 0?s.parameters[x.input]:x.input,_=s.parameters!==void 0?s.parameters[x.output]:x.output;let w=t.loadAnimationTargetFromChannelWithAnimationPointer(b);w||(w=t.loadAnimationTargetFromChannel(b)),o.push(w),c.push(i.getDependency("accessor",v)),l.push(i.getDependency("accessor",_)),u.push(x),p.push(g)}return Promise.all([Promise.all(o),Promise.all(c),Promise.all(l),Promise.all(u),Promise.all(p)]).then(function(f){const m=f[0],b=f[1],x=f[2],g=f[3],v=f[4],_=[];for(let w=0,C=m.length;w<C;w++){const M=m[w],E=b[w],P=x[w],O=g[w],R=v[w];if(M===void 0)continue;M.updateMatrix&&(M.updateMatrix(),M.matrixAutoUpdate=!0);let A=t.createAnimationTracksWithAnimationPointer(M,E,P,O,R);if(A||(A=i._createAnimationTracks(M,E,P,O,R)),A)for(let B=0;B<A.length;B++)_.push(A[B])}return new ql(a,void 0,_)})}}let gl=!1,Ip=null;function zp(){if(gl)return;gl=!0;const r=Ip||=na.findNode;na.findNode=function(e,t){if(!t)return r(e,t);if(t.startsWith(".materials.")){const n=t.substring(11).substring(t.indexOf(".")),i=n.indexOf("."),s=i<0?n:n.substring(0,i);let a=null;return e.traverse(o=>{a!==null||o.type!=="Mesh"&&o.type!=="SkinnedMesh"||o.material&&(o.material.uuid===s||o.material.name===s)&&(a=o.material,a!==null&&(n.endsWith(".map")?a=a.map:n.endsWith(".emissiveMap")&&(a=a.emissiveMap)))}),a}else if(t.startsWith(".nodes.")||t.startsWith(".lights.")||t.startsWith(".cameras.")){const n=t.split(".");let i;for(let s=1;s<n.length;s++){const a=n[s];if(a.length==36)i=e.getObjectByProperty("uuid",a);else if(i&&i[a]){const o=Number.parseInt(a);let c=a;o>=0&&(c=o),i=i[c]}else{const o=e.getObjectByName(a);o&&(i=o)}}if(!i){const s=r(e,n[2]);return s||console.warn(Sn+": Property binding not found",t,e,e.name,n),s}return i}return r(e,t)}}const Bp=Object.freeze(Object.defineProperty({__proto__:null,GLTFAnimationPointerExtension:Op},Symbol.toStringTag,{value:"Module"}));export{bc as $70d766613f57b014$export$2e2bcd8739ae039,ad as BatchedParticleRenderer,_o as Builder,bi as ByteBuffer,xn as ConstantColor,ne as ConstantValue,Rt as Matrix4,xi as MeshBVH,ru as MotionController,Qr as ParticleSystem,V as RenderMode,ra as SIZE_PREFIX_LENGTH,Tr as TrailParticle,tt as Vector4,Rp as WorkerBase,Nu as bundler,ld as createNoise4D,$l as fetchProfile,md as index,kp as index$1,Bp as index$2,Qu as md5,qu as v5};
|
|
1121
|
+
}`;class ad extends Fc{constructor(e){super(e),this.vector_=new G,this.vector2_=new G,this.vector3_=new G,this.quaternion_=new ie,this.maxParticles=1e4,this.setupBuffers(),this.rebuildMaterial()}setupBuffers(){this.geometry&&this.geometry.dispose(),this.geometry=new Yn,this.indexBuffer=new ot(new Uint32Array(this.maxParticles*6),1),this.indexBuffer.setUsage(He),this.geometry.setIndex(this.indexBuffer),this.positionBuffer=new ot(new Float32Array(this.maxParticles*6),3),this.positionBuffer.setUsage(He),this.geometry.setAttribute("position",this.positionBuffer),this.previousBuffer=new ot(new Float32Array(this.maxParticles*6),3),this.previousBuffer.setUsage(He),this.geometry.setAttribute("previous",this.previousBuffer),this.nextBuffer=new ot(new Float32Array(this.maxParticles*6),3),this.nextBuffer.setUsage(He),this.geometry.setAttribute("next",this.nextBuffer),this.widthBuffer=new ot(new Float32Array(this.maxParticles*2),1),this.widthBuffer.setUsage(He),this.geometry.setAttribute("width",this.widthBuffer),this.sideBuffer=new ot(new Float32Array(this.maxParticles*2),1),this.sideBuffer.setUsage(He),this.geometry.setAttribute("side",this.sideBuffer),this.uvBuffer=new ot(new Float32Array(this.maxParticles*4),2),this.uvBuffer.setUsage(He),this.geometry.setAttribute("uv",this.uvBuffer),this.colorBuffer=new ot(new Float32Array(this.maxParticles*8),4),this.colorBuffer.setUsage(He),this.geometry.setAttribute("color",this.colorBuffer)}expandBuffers(e){for(;e>=this.maxParticles;)this.maxParticles*=2;this.setupBuffers()}rebuildMaterial(){this.layers.mask=this.settings.layers.mask;const e={lineWidth:{value:1},map:{value:null},useMap:{value:0},alphaMap:{value:null},useAlphaMap:{value:0},resolution:{value:new Jn(1,1)},sizeAttenuation:{value:1},visibility:{value:1},alphaTest:{value:0}},t={};if(t.USE_UV="",t.USE_COLOR_ALPHA="",this.settings.material.map&&(t.USE_MAP="",t.MAP_UV=Ys(this.settings.material.map.channel),e.map=new Mt(this.settings.material.map),e.mapTransform=new Mt(new Dt().copy(this.settings.material.map.matrix))),this.settings.material.defines&&this.settings.material.defines.USE_COLOR_AS_ALPHA!==void 0&&(t.USE_COLOR_AS_ALPHA=""),this.settings.renderMode===V.Trail)this.material=new ps({uniforms:e,defines:t,vertexShader:od,fragmentShader:sd,transparent:this.settings.material.transparent,depthWrite:!this.settings.material.transparent,side:this.settings.material.side,blending:this.settings.material.blending||Ko,blendDst:this.settings.material.blendDst,blendSrc:this.settings.material.blendSrc,blendEquation:this.settings.material.blendEquation,premultipliedAlpha:this.settings.material.premultipliedAlpha});else throw new Error("render mode unavailable")}update(){let e=0,t=0,n=0;this.systems.forEach(i=>{for(let s=0;s<i.particleNum;s++)n+=i.particles[s].previous.length*2}),n>this.maxParticles&&this.expandBuffers(n),this.systems.forEach(i=>{i.emitter.updateMatrixWorld&&(i.emitter.updateWorldMatrix(!0,!1),i.emitter.updateMatrixWorld(!0));const s=this.quaternion_,a=this.vector2_,o=this.vector3_;i.emitter.matrixWorld.decompose(a,s,o);const c=i.particles,l=i.particleNum,u=this.settings.uTileCount,p=this.settings.vTileCount,f=1/u,m=1/p;for(let b=0;b<l;b++){const x=c[b],g=x.uvTile%p,v=Math.floor(x.uvTile/p+.001),_=x.previous.values();let w=_.next(),C=w.value,M=C;w.done||(w=_.next());let E;w.value!==void 0?E=w.value:E=M;for(let P=0;P<x.previous.length;P++,e+=2){if(this.positionBuffer.setXYZ(e,M.position.x,M.position.y,M.position.z),this.positionBuffer.setXYZ(e+1,M.position.x,M.position.y,M.position.z),i.worldSpace?(this.positionBuffer.setXYZ(e,M.position.x,M.position.y,M.position.z),this.positionBuffer.setXYZ(e+1,M.position.x,M.position.y,M.position.z)):(x.parentMatrix?this.vector_.copy(M.position).applyMatrix4(x.parentMatrix):this.vector_.copy(M.position).applyMatrix4(i.emitter.matrixWorld),this.positionBuffer.setXYZ(e,this.vector_.x,this.vector_.y,this.vector_.z),this.positionBuffer.setXYZ(e+1,this.vector_.x,this.vector_.y,this.vector_.z)),i.worldSpace?(this.previousBuffer.setXYZ(e,C.position.x,C.position.y,C.position.z),this.previousBuffer.setXYZ(e+1,C.position.x,C.position.y,C.position.z)):(x.parentMatrix?this.vector_.copy(C.position).applyMatrix4(x.parentMatrix):this.vector_.copy(C.position).applyMatrix4(i.emitter.matrixWorld),this.previousBuffer.setXYZ(e,this.vector_.x,this.vector_.y,this.vector_.z),this.previousBuffer.setXYZ(e+1,this.vector_.x,this.vector_.y,this.vector_.z)),i.worldSpace?(this.nextBuffer.setXYZ(e,E.position.x,E.position.y,E.position.z),this.nextBuffer.setXYZ(e+1,E.position.x,E.position.y,E.position.z)):(x.parentMatrix?this.vector_.copy(E.position).applyMatrix4(x.parentMatrix):this.vector_.copy(E.position).applyMatrix4(i.emitter.matrixWorld),this.nextBuffer.setXYZ(e,this.vector_.x,this.vector_.y,this.vector_.z),this.nextBuffer.setXYZ(e+1,this.vector_.x,this.vector_.y,this.vector_.z)),this.sideBuffer.setX(e,-1),this.sideBuffer.setX(e+1,1),i.worldSpace)this.widthBuffer.setX(e,M.size),this.widthBuffer.setX(e+1,M.size);else if(x.parentMatrix)this.widthBuffer.setX(e,M.size),this.widthBuffer.setX(e+1,M.size);else{const O=(Math.abs(o.x)+Math.abs(o.y)+Math.abs(o.z))/3;this.widthBuffer.setX(e,M.size*O),this.widthBuffer.setX(e+1,M.size*O)}this.uvBuffer.setXY(e,(P/x.previous.length+g)*f,(p-v-1)*m),this.uvBuffer.setXY(e+1,(P/x.previous.length+g)*f,(p-v)*m),this.colorBuffer.setXYZW(e,M.color.x,M.color.y,M.color.z,M.color.w),this.colorBuffer.setXYZW(e+1,M.color.x,M.color.y,M.color.z,M.color.w),P+1<x.previous.length&&(this.indexBuffer.setX(t*3,e),this.indexBuffer.setX(t*3+1,e+1),this.indexBuffer.setX(t*3+2,e+2),t++,this.indexBuffer.setX(t*3,e+2),this.indexBuffer.setX(t*3+1,e+1),this.indexBuffer.setX(t*3+2,e+3),t++),C=M,M=E,w.done||(w=_.next(),w.value!==void 0&&(E=w.value))}}}),this.positionBuffer.clearUpdateRanges(),this.positionBuffer.addUpdateRange(0,e*3),this.positionBuffer.needsUpdate=!0,this.previousBuffer.clearUpdateRanges(),this.previousBuffer.addUpdateRange(0,e*3),this.previousBuffer.needsUpdate=!0,this.nextBuffer.clearUpdateRanges(),this.nextBuffer.addUpdateRange(0,e*3),this.nextBuffer.needsUpdate=!0,this.sideBuffer.clearUpdateRanges(),this.sideBuffer.addUpdateRange(0,e),this.sideBuffer.needsUpdate=!0,this.widthBuffer.clearUpdateRanges(),this.widthBuffer.addUpdateRange(0,e),this.widthBuffer.needsUpdate=!0,this.uvBuffer.clearUpdateRanges(),this.uvBuffer.addUpdateRange(0,e*2),this.uvBuffer.needsUpdate=!0,this.colorBuffer.clearUpdateRanges(),this.colorBuffer.addUpdateRange(0,e*4),this.colorBuffer.needsUpdate=!0,this.indexBuffer.clearUpdateRanges(),this.indexBuffer.addUpdateRange(0,t*3),this.indexBuffer.needsUpdate=!0,this.geometry.setDrawRange(0,t*3)}dispose(){this.geometry.dispose()}}class Ki{get geometry(){return this._geometry}set geometry(e){if(this._geometry=e,e===void 0||typeof e=="string")return;const t=new un;this._triangleIndexToArea.length=0;let n=0;if(!e.getIndex())return;const i=e.getIndex().array,s=i.length/3;this._triangleIndexToArea.push(0);for(let a=0;a<s;a++)t.setFromAttributeAndIndices(e.getAttribute("position"),i[a*3],i[a*3+1],i[a*3+2]),n+=t.getArea(),this._triangleIndexToArea.push(n);e.userData.triangleIndexToArea=this._triangleIndexToArea}constructor(e){this.type="mesh_surface",this._triangleIndexToArea=[],this._tempA=new W,this._tempB=new W,this._tempC=new W,e&&(this.geometry=e)}initialize(e){const t=this._geometry;if(!t||t.getIndex()===null){e.position.set(0,0,0),e.velocity.set(0,0,1).multiplyScalar(e.startSpeed);return}const n=this._triangleIndexToArea.length-1;let i=0,s=n;const a=Math.random()*this._triangleIndexToArea[n];for(;i+1<s;){const m=Math.floor((i+s)/2);a<this._triangleIndexToArea[m]?s=m:i=m}let o=Math.random(),c=Math.random();o+c>1&&(o=1-o,c=1-c);const l=t.getIndex().array[i*3],u=t.getIndex().array[i*3+1],p=t.getIndex().array[i*3+2],f=t.getAttribute("position");this._tempA.fromBufferAttribute(f,l),this._tempB.fromBufferAttribute(f,u),this._tempC.fromBufferAttribute(f,p),this._tempB.sub(this._tempA),this._tempC.sub(this._tempA),this._tempA.addScaledVector(this._tempB,o).addScaledVector(this._tempC,c),e.position.copy(this._tempA),this._tempA.copy(this._tempB).cross(this._tempC).normalize(),e.velocity.copy(this._tempA).normalize().multiplyScalar(e.startSpeed)}toJSON(){return{type:"mesh_surface",mesh:this._geometry?this._geometry.uuid:""}}static fromJSON(e,t){return new Ki(t.geometries[e.geometry])}clone(){return new Ki(this._geometry)}update(e,t){}}Dh({id:"three.quarks",emitterShapes:[{type:"mesh_surface",params:[["geometry",["geometry"]]],constructor:Ki,loadJSON:Ki.fromJSON}],behaviors:[]});class To extends Yo{constructor(){super(),this.batches=[],this.systemToBatchIndex=new Map,this.type="BatchedRenderer",this.depthTexture=null}static equals(e,t){return e.material.side===t.material.side&&e.material.blending===t.material.blending&&e.material.blendSrc===t.material.blendSrc&&e.material.blendDst===t.material.blendDst&&e.material.blendEquation===t.material.blendEquation&&e.material.premultipliedAlpha===t.material.premultipliedAlpha&&e.material.transparent===t.material.transparent&&e.material.depthTest===t.material.depthTest&&e.material.type===t.material.type&&e.material.alphaTest===t.material.alphaTest&&e.material.map===t.material.map&&e.renderMode===t.renderMode&&e.blendTiles===t.blendTiles&&e.softParticles===t.softParticles&&e.softFarFade===t.softFarFade&&e.softNearFade===t.softNearFade&&e.uTileCount===t.uTileCount&&e.vTileCount===t.vTileCount&&e.instancingGeometry===t.instancingGeometry&&e.renderOrder===t.renderOrder&&e.layers.mask===t.layers.mask}addSystem(e){e._renderer=this;const t=e.getRendererSettings();for(let i=0;i<this.batches.length;i++)if(To.equals(this.batches[i].settings,t)){this.batches[i].addSystem(e),this.systemToBatchIndex.set(e,i);return}let n;switch(t.renderMode){case V.Trail:n=new ad(t);break;case V.Mesh:case V.BillBoard:case V.VerticalBillBoard:case V.HorizontalBillBoard:case V.StretchedBillBoard:n=new rd(t);break}this.depthTexture&&n.applyDepthTexture(this.depthTexture),n.addSystem(e),this.batches.push(n),this.systemToBatchIndex.set(e,this.batches.length-1),this.add(n)}deleteSystem(e){const t=this.systemToBatchIndex.get(e);t!=null&&(this.batches[t].removeSystem(e),this.systemToBatchIndex.delete(e))}setDepthTexture(e){this.depthTexture=e;for(const t of this.batches)t.applyDepthTexture(e)}updateSystem(e){this.deleteSystem(e),this.addSystem(e)}update(e){this.systemToBatchIndex.forEach((t,n)=>{n.update(e)});for(let t=0;t<this.batches.length;t++)this.batches[t].update()}}const cd=To;qh(),console.log("%c Particle system powered by three.quarks. https://quarks.art/","font-size: 14px; font-weight: bold;");const jc=Math.sqrt(5),ld=(jc-1)/4,Ne=(5-jc)/20,Cr=r=>Math.floor(r)|0,Er=new Float64Array([0,1,1,1,0,1,1,-1,0,1,-1,1,0,1,-1,-1,0,-1,1,1,0,-1,1,-1,0,-1,-1,1,0,-1,-1,-1,1,0,1,1,1,0,1,-1,1,0,-1,1,1,0,-1,-1,-1,0,1,1,-1,0,1,-1,-1,0,-1,1,-1,0,-1,-1,1,1,0,1,1,1,0,-1,1,-1,0,1,1,-1,0,-1,-1,1,0,1,-1,1,0,-1,-1,-1,0,1,-1,-1,0,-1,1,1,1,0,1,1,-1,0,1,-1,1,0,1,-1,-1,0,-1,1,1,0,-1,1,-1,0,-1,-1,1,0,-1,-1,-1,0]);function ud(r=Math.random){const e=hd(r),t=new Float64Array(e).map(a=>Er[a%32*4]),n=new Float64Array(e).map(a=>Er[a%32*4+1]),i=new Float64Array(e).map(a=>Er[a%32*4+2]),s=new Float64Array(e).map(a=>Er[a%32*4+3]);return function(a,o,c,l){let u,p,f,m,b;const x=(a+o+c+l)*ld,g=Cr(a+x),v=Cr(o+x),_=Cr(c+x),w=Cr(l+x),C=(g+v+_+w)*Ne,M=g-C,E=v-C,P=_-C,O=w-C,R=a-M,A=o-E,B=c-P,z=l-O;let D=0,F=0,H=0,q=0;R>A?D++:F++,R>B?D++:H++,R>z?D++:q++,A>B?F++:H++,A>z?F++:q++,B>z?H++:q++;const $=D>=3?1:0,J=F>=3?1:0,Se=H>=3?1:0,ce=q>=3?1:0,me=D>=2?1:0,le=F>=2?1:0,xe=H>=2?1:0,Ce=q>=2?1:0,ye=D>=1?1:0,pe=F>=1?1:0,oe=H>=1?1:0,nt=q>=1?1:0,je=R-$+Ne,Ye=A-J+Ne,it=B-Se+Ne,Oe=z-ce+Ne,fe=R-me+2*Ne,ae=A-le+2*Ne,lt=B-xe+2*Ne,Ee=z-Ce+2*Ne,ue=R-ye+3*Ne,Ze=A-pe+3*Ne,St=B-oe+3*Ne,bt=z-nt+3*Ne,Ke=R-1+4*Ne,xt=A-1+4*Ne,ut=B-1+4*Ne,ht=z-1+4*Ne,rt=g&255,Pe=v&255,Je=_&255,st=w&255;let Ge=.6-R*R-A*A-B*B-z*z;if(Ge<0)u=0;else{const re=rt+e[Pe+e[Je+e[st]]];Ge*=Ge,u=Ge*Ge*(t[re]*R+n[re]*A+i[re]*B+s[re]*z)}let ee=.6-je*je-Ye*Ye-it*it-Oe*Oe;if(ee<0)p=0;else{const re=rt+$+e[Pe+J+e[Je+Se+e[st+ce]]];ee*=ee,p=ee*ee*(t[re]*je+n[re]*Ye+i[re]*it+s[re]*Oe)}let wt=.6-fe*fe-ae*ae-lt*lt-Ee*Ee;if(wt<0)f=0;else{const re=rt+me+e[Pe+le+e[Je+xe+e[st+Ce]]];wt*=wt,f=wt*wt*(t[re]*fe+n[re]*ae+i[re]*lt+s[re]*Ee)}let Lt=.6-ue*ue-Ze*Ze-St*St-bt*bt;if(Lt<0)m=0;else{const re=rt+ye+e[Pe+pe+e[Je+oe+e[st+nt]]];Lt*=Lt,m=Lt*Lt*(t[re]*ue+n[re]*Ze+i[re]*St+s[re]*bt)}let _t=.6-Ke*Ke-xt*xt-ut*ut-ht*ht;if(_t<0)b=0;else{const re=rt+1+e[Pe+1+e[Je+1+e[st+1]]];_t*=_t,b=_t*_t*(t[re]*Ke+n[re]*xt+i[re]*ut+s[re]*ht)}return 27*(u+p+f+m+b)}}function hd(r){const e=new Uint8Array(512);for(let t=0;t<512/2;t++)e[t]=t;for(let t=0;t<512/2-1;t++){const n=t+~~(r()*(256-t)),i=e[t];e[t]=e[n],e[n]=i}for(let t=256;t<512;t++)e[t]=e[t-256];return e}var dd=Object.defineProperty,pd=(r,e,t)=>e in r?dd(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Te=(r,e,t)=>(pd(r,typeof e!="symbol"?e+"":e,t),t);(function(){class r{}class e extends r{constructor(d){super(),Te(this,"value"),this.value=d}}class t extends r{constructor(d){super(),Te(this,"value"),this.value=d}}class n extends r{constructor(d){super(),Te(this,"value"),this.value=d}}class i extends r{constructor(d,y="unrestricted"){super(),Te(this,"type"),Te(this,"value"),this.value=d,this.type=y}}class s extends r{constructor(d){super(),Te(this,"value"),this.value=d}}class a extends r{}class o extends r{constructor(d){super(),Te(this,"value"),this.value=d}}class c extends r{}class l extends r{constructor(d){super(),Te(this,"value"),this.value=d}}class u extends r{constructor(d,y="integer"){super(),Te(this,"value"),Te(this,"type"),this.value=d,this.type=y}}class p extends r{constructor(d){super(),Te(this,"value"),this.value=d}}class f extends r{constructor(d,y,S){super(),Te(this,"value"),Te(this,"type"),Te(this,"unit"),this.value=d,this.type=y,this.unit=S}}class m extends r{}class b extends r{}class x extends r{}class g extends r{}class v extends r{}class _ extends r{}class w extends r{}class C extends r{}class M extends r{}class E extends r{}class P extends r{}class O extends r{}class R{constructor(d){Te(this,"input"),Te(this,"index",0),this.input=d}consume(){const d=this.input.codePointAt(this.index);return d!==void 0&&(this.index+=String.fromCodePoint(d).length),d}reconsume(d){d!==void 0&&(this.index-=String.fromCodePoint(d).length)}peek(){const d=[];let y=this.index;for(let S=0;S<3&&y<this.input.length;S++){const T=this.input.codePointAt(y);d.push(T),y+=String.fromCodePoint(T).length}return d}}function A(h){return h===10}function B(h){return A(h)||h===8192||h===32}function z(h){return h>=48&&h<=57}function D(h){return z(h)||h>=65&&h<=70||h>=97&&h<=102}function F(h){return function(d){return function(y){return y>=65&&y<=90}(d)||function(y){return y>=97&&y<=122}(d)}(h)||function(d){return d>=128}(h)||h===95}function H(h){return F(h)||z(h)||h===45}function q(h){return h>=0&&h<=8||h===11||h>=14&&h<=31||h===127}function $(h,d){return h===92&&!A(d)}function J(h,d,y){return h===45?F(d)||d===45||$(d,y):!!F(h)||h===92&&$(h,d)}function Se(h,d,y){return h===43||h===45?z(d)||d===46&&z(y):z(h===46?d:h)}function ce(h){const d=h.consume();if(D(d)){let y=[d];for(;D(...h.peek())&&y.length<5;)y.push(h.consume());B(...h.peek())&&h.consume();const S=parseInt(String.fromCodePoint(...y),16);return S===0||S>1114111?65533:S}return d===void 0?65533:d}function me(h,d){const y=new s("");for(;;){const S=h.consume();if(S===d||S===void 0)return y;if(S===10)return h.reconsume(S),new a;if(S===92){const T=h.peek()[0];T===void 0||(A(T)?h.consume():y.value+=String.fromCodePoint(ce(h)))}else y.value+=String.fromCodePoint(S)}}function le(h){let d="";for(;;){const y=h.consume();if(H(y))d+=String.fromCodePoint(y);else{if(!$(...h.peek()))return h.reconsume(y),d;d+=String.fromCodePoint(ce(h))}}}function xe(h){let d=function(y){let S="integer",T="";for([43,45].includes(y.peek()[0])&&(T+=String.fromCodePoint(y.consume()));z(...y.peek());)T+=String.fromCodePoint(y.consume());if(y.peek()[0]===46&&z(y.peek()[1]))for(T+=String.fromCodePoint(y.consume(),y.consume()),S="number";z(...y.peek());)T+=String.fromCodePoint(y.consume());return[69,101].includes(y.peek()[0])&&([45,43].includes(y.peek()[1])&&z(y.peek()[2])?(T+=String.fromCodePoint(y.consume(),y.consume(),y.consume()),S="number"):z(y.peek()[1])&&(T+=String.fromCodePoint(y.consume(),y.consume()),S="number")),{value:parseFloat(T),type:S}}(h);return J(...h.peek())?new f(d.value,d.type,le(h)):h.peek()[0]===37?(h.consume(),new p(d.value)):new u(d.value,d.type)}function Ce(h){for(;;){const d=h.consume();if(d===41||d===void 0)return;$(...h.peek())&&ce(h)}}function ye(h){const d=le(h);if(d.match(/url/i)&&h.peek()[0]===40){for(h.consume();B(h.peek()[0])&&B(h.peek()[1]);)h.consume();return[34,39].includes(h.peek()[0])||B(h.peek()[0])&&[34,39].includes(h.peek()[1])?new t(d):function(y){const S=new o("");for(;B(...y.peek());)y.consume();for(;;){const T=y.consume();if(T===41||T===void 0)return S;if(B(T)){for(;B(...y.peek());)y.consume();return y.peek()[0]===41||y.peek()[0]===void 0?(y.consume(),S):(Ce(y),new c)}if([34,39,40].includes(T)||q(T))return Ce(y),new c;if(T===92){if(!$(...y.peek()))return Ce(y),new c;S.value+=ce(y)}else S.value+=String.fromCodePoint(T)}}(h)}return h.peek()[0]===40?(h.consume(),new t(d)):new e(d)}function pe(h){const d=h.consume(),y=h.peek();if(B(d)){for(;B(...h.peek());)h.consume();return new m}if(d===34)return me(h,d);if(d===35){if(H(y[0])||$(...y)){const S=new i;return J(...y)&&(S.type="id"),S.value=le(h),S}return new l(String.fromCodePoint(d))}return d===39?me(h,d):d===40?new M:d===41?new E:d===43?Se(...y)?(h.reconsume(d),xe(h)):new l(String.fromCodePoint(d)):d===44?new _:d===45?Se(...h.peek())?(h.reconsume(d),xe(h)):h.peek()[0]===45&&h.peek()[1]===62?(h.consume(),h.consume(),new x):J(...h.peek())?(h.reconsume(d),ye(h)):new l(String.fromCodePoint(d)):d===46?Se(...h.peek())?(h.reconsume(d),xe(h)):new l(String.fromCodePoint(d)):d===58?new g:d===59?new v:d===60?y[0]===33&&y[1]===45&&y[2]===45?(h.consume(),h.consume(),h.consume(),new b):new l(String.fromCodePoint(d)):d===64?J(...y)?new n(le(h)):new l(String.fromCodePoint(d)):d===91?new w:d===92?$(...y)?(h.reconsume(d),ye(h)):new l(String.fromCodePoint(d)):d===93?new C:d===123?new P:d===125?new O:z(d)?(h.reconsume(d),xe(h)):F(d)?(h.reconsume(d),ye(h)):d===void 0?void 0:new l(String.fromCodePoint(d))}const oe=new Set(["px","deg","s","hz","dppx","number","fr"]);function nt(h){return oe.has(h.toLowerCase())}function je(h,d){if(["x","y"].includes(h))return h;if(!d)throw new Error("To determine the normalized axis the computedStyle of the source is required.");const y=d.writingMode=="horizontal-tb";if(h==="block")h=y?"y":"x";else{if(h!=="inline")throw new TypeError(`Invalid axis \u201C${h}\u201D`);h=y?"x":"y"}return h}function Ye(h){const d=[];let y=0;function S(){let k=0;const I=y;for(;y<h.length;){const U=h.slice(y,y+1);if(/\s/.test(U)&&k===0)break;if(U==="(")k+=1;else if(U===")"&&(k-=1,k===0)){y++;break}y++}return h.slice(I,y)}function T(){for(;/\s/.test(h.slice(y,y+1));)y++}for(;y<h.length;){const k=h.slice(y,y+1);/\s/.test(k)?T():d.push(S())}return d}function it(h,d){return h.reduce((y,S)=>(y.has(S[d])?y.get(S[d]).push(S):y.set(S[d],[S]),y),new Map)}function Oe(h,d){const y=[],S=[];for(const T of h)d(T)?y.push(T):S.push(T);return[y,S]}function fe(h,d={}){function y(S){return Array.from(S).map(T=>fe(T,d))}if(h instanceof CSSUnitValue){if(h.unit==="percent"&&d.percentageReference){const T=h.value/100*d.percentageReference.value,k=d.percentageReference.unit;return new CSSUnitValue(T,k)}const S=h.toSum();if(S&&S.values.length===1&&(h=S.values[0]),h instanceof CSSUnitValue&&h.unit==="em"&&d.fontSize&&(h=new CSSUnitValue(h.value*d.fontSize.value,d.fontSize.unit)),h instanceof CSSKeywordValue){if(h.value==="e")return new CSSUnitValue(Math.E,"number");if(h.value==="pi")return new CSSUnitValue(Math.PI,"number")}return h}if(!h.operator)return h;switch(h.operator){case"sum":h=new CSSMathSum(...y(h.values));break;case"product":h=new CSSMathProduct(...y(h.values));break;case"negate":h=new CSSMathNegate(fe(h.value,d));break;case"clamp":h=new CSSMathClamp(fe(h.lower,d),fe(h.value,d),fe(h.upper,d));break;case"invert":h=new CSSMathInvert(fe(h.value,d));break;case"min":h=new CSSMathMin(...y(h.values));break;case"max":h=new CSSMathMax(...y(h.values))}if(h instanceof CSSMathMin||h instanceof CSSMathMax){const S=Array.from(h.values);if(S.every(T=>T instanceof CSSUnitValue&&T.unit!=="percent"&&nt(T.unit)&&T.unit===S[0].unit)){const T=Math[h.operator].apply(Math,S.map(({value:k})=>k));return new CSSUnitValue(T,S[0].unit)}}if(h instanceof CSSMathMin||h instanceof CSSMathMax){const S=Array.from(h.values),[T,k]=Oe(S,U=>U instanceof CSSUnitValue&&U.unit!=="percent"),I=Array.from(it(T,"unit").values());if(I.some(U=>U.length>0)){const U=I.map(N=>{const L=Math[h.operator].apply(Math,N.map(({value:X})=>X));return new CSSUnitValue(L,N[0].unit)});h=h instanceof CSSMathMin?new CSSMathMin(...U,...k):new CSSMathMax(...U,...k)}return S.length===1?S[0]:h}if(h instanceof CSSMathNegate)return h.value instanceof CSSUnitValue?new CSSUnitValue(0-h.value.value,h.value.unit):h.value instanceof CSSMathNegate?h.value.value:h;if(h instanceof CSSMathInvert)return h.value instanceof CSSMathInvert?h.value.value:h;if(h instanceof CSSMathSum){let S=function(k){const I=k.filter(U=>U instanceof CSSUnitValue);return[...k.filter(U=>!(U instanceof CSSUnitValue)),...Array.from(it(I,"unit").entries()).map(([U,N])=>{const L=N.reduce((X,{value:Z})=>X+Z,0);return new CSSUnitValue(L,U)})]},T=[];for(const k of h.values)k instanceof CSSMathSum?T.push(...k.values):T.push(k);return T=S(T),T.length===1?T[0]:new CSSMathSum(...T)}if(h instanceof CSSMathProduct){let S=[];for(const I of h.values)I instanceof CSSMathProduct?S.push(...I.values):S.push(I);const[T,k]=Oe(S,I=>I instanceof CSSUnitValue&&I.unit==="number");if(T.length>1){const I=T.reduce((U,{value:N})=>U*N,1);S=[new CSSUnitValue(I,"number"),...k]}if(S.length===2){let I,U;for(const N of S)N instanceof CSSUnitValue&&N.unit==="number"?I=N:N instanceof CSSMathSum&&[...N.values].every(L=>L instanceof CSSUnitValue)&&(U=N);if(I&&U)return new CSSMathSum(...[...U.values].map(N=>new CSSUnitValue(N.value*I.value,N.unit)))}if(S.every(I=>I instanceof CSSUnitValue&&nt(I.unit)||I instanceof CSSMathInvert&&I.value instanceof CSSUnitValue&&nt(I.value.unit))){const I=new CSSMathProduct(...S).toSum();if(I&&I.values.length===1)return I.values[0]}return new CSSMathProduct(...S)}return h}const ae=null,lt=["percent","length","angle","time","frequency","resolution","flex"],Ee={fontRelativeLengths:{units:new Set(["em","rem","ex","rex","cap","rcap","ch","rch","ic","ric","lh","rlh"])},viewportRelativeLengths:{units:new Set(["vw","lvw","svw","dvw","vh","lvh","svh","dvh","vi","lvi","svi","dvi","vb","lvb","svb","dvb","vmin","lvmin","svmin","dvmin","vmax","lvmax","svmax","dvmax"])},absoluteLengths:{units:new Set(["cm","mm","Q","in","pt","pc","px"]),compatible:!0,canonicalUnit:"px",ratios:{cm:96/2.54,mm:96/2.54/10,Q:96/2.54/40,in:96,pc:16,pt:96/72,px:1}},angle:{units:new Set(["deg","grad","rad","turn"]),compatible:!0,canonicalUnit:"deg",ratios:{deg:1,grad:.9,rad:180/Math.PI,turn:360}},time:{units:new Set(["s","ms"]),compatible:!0,canonicalUnit:"s",ratios:{s:1,ms:.001}},frequency:{units:new Set(["hz","khz"]),compatible:!0,canonicalUnit:"hz",ratios:{hz:1,khz:1e3}},resolution:{units:new Set(["dpi","dpcm","dppx"]),compatible:!0,canonicalUnit:"dppx",ratios:{dpi:1/96,dpcm:2.54/96,dppx:1}}},ue=new Map;for(const h of Object.values(Ee))if(h.compatible)for(const d of h.units)ue.set(d,h);function Ze(h){return ue.get(h)}function St(h,d){const y={...h};for(const S of Object.keys(d))y[S]?y[S]+=d[S]:y[S]=d[S];return y}function bt(h){return h==="number"?{}:h==="percent"?{percent:1}:Ee.absoluteLengths.units.has(h)||Ee.fontRelativeLengths.units.has(h)||Ee.viewportRelativeLengths.units.has(h)?{length:1}:Ee.angle.units.has(h)?{angle:1}:Ee.time.units.has(h)?{time:1}:Ee.frequency.units.has(h)?{frequency:1}:Ee.resolution.units.has(h)?{resolution:1}:h==="fr"?{flex:1}:ae}function Ke(h){if(h instanceof CSSUnitValue){let{unit:d,value:y}=h;const S=Ze(h.unit);return S&&d!==S.canonicalUnit&&(y*=S.ratios[d],d=S.canonicalUnit),d==="number"?[[y,{}]]:[[y,{[d]:1}]]}if(h instanceof CSSMathInvert){if(!(h.value instanceof CSSUnitValue))throw new Error("Not implemented");const d=Ke(h.value);if(d===ae||d.length>1)return ae;const y=d[0],S={};for(const[T,k]of Object.entries(y[1]))S[T]=-1*k;return d[0]=[1/y[0],S],d}if(h instanceof CSSMathProduct){let d=[[1,{}]];for(const y of h.values){const S=Ke(y),T=[];if(S===ae)return ae;for(const k of d)for(const I of S)T.push([k[0]*I[0],St(k[1],I[1])]);d=T}return d}throw new Error("Not implemented")}function xt(h,d){if(bt(d)===ae)throw new SyntaxError("The string did not match the expected pattern.");const y=Ke(h);if(!y)throw new TypeError;if(y.length>1)throw new TypeError("Sum has more than one item");const S=function(T,k){const I=T.unit,U=T.value,N=Ze(I),L=Ze(k);return!L||N!==L?ae:new CSSUnitValue(U*L.ratios[I]/L.ratios[k],k)}(ut(y[0]),d);if(S===ae)throw new TypeError;return S}function ut(h){const[d,y]=h,S=Object.entries(y);if(S.length>1)return ae;if(S.length===0)return new CSSUnitValue(d,"number");const T=S[0];return T[1]!==1?ae:new CSSUnitValue(d,T[0])}function ht(h,...d){if(d&&d.length)throw new Error("Not implemented");const y=Ke(h).map(S=>ut(S));if(y.some(S=>S===ae))throw new TypeError("Type error");return new CSSMathSum(...y)}function rt(h,d){if(h.percentHint&&d.percentHint&&h.percentHint!==d.percentHint)return ae;const y={...h,percentHint:h.percentHint??d.percentHint};for(const S of lt)d[S]&&(y[S]??(y[S]=0),y[S]+=d[S]);return y}class Pe{constructor(d,y){Te(this,"name"),Te(this,"values"),this.name=d,this.values=y}}class Je{constructor(d,y){Te(this,"value"),Te(this,"associatedToken"),this.value=d,this.associatedToken=y}}function st(h){if(Array.isArray(h))return h;if(typeof h=="string")return function(d){const y=new R(d),S=[];for(;;){const T=pe(y);if(T===void 0)return S;S.push(T)}}(h);throw new TypeError("Invalid input type "+typeof h)}function Ge(h){const d=h.shift();return d instanceof P||d instanceof w||d instanceof M?function(y,S){let T;if(S instanceof P)T=O;else if(S instanceof M)T=E;else{if(!(S instanceof w))return;T=C}const k=new Je([],S);for(;;){const I=y.shift();if(I instanceof T||I===void 0)return k;y.unshift(I),k.value.push(Ge(y))}}(h,d):d instanceof t?function(y,S){const T=new Pe(y.value,[]);for(;;){const k=S.shift();if(k instanceof E||k===void 0)return T;S.unshift(k),T.values.push(Ge(S))}}(d,h):d}function ee(h){if(h instanceof M||h instanceof E)return 6;if(h instanceof l)switch(h.value){case"*":case"/":return 4;case"+":case"-":return 2}}function wt(h){return h[h.length-1]}function Lt(h,d,y){const S=["+","-"].includes(h.value)?"ADDITION":"MULTIPLICATION",T=d.type===S?d.values:[d],k=y.type===S?y.values:[y];return h.value==="-"?k[0]={type:"NEGATE",value:k[0]}:h.value==="/"&&(k[0]={type:"INVERT",value:k[0]}),{type:S,values:[...T,...k]}}function _t(h){if(h.type==="ADDITION")return new CSSMathSum(...h.values.map(d=>_t(d)));if(h.type==="MULTIPLICATION")return new CSSMathProduct(...h.values.map(d=>_t(d)));if(h.type==="NEGATE")return new CSSMathNegate(_t(h.value));if(h.type==="INVERT")return new CSSMathInvert(_t(h.value));if(h instanceof Je)return re(new Pe("calc",h.value));if(h instanceof e){if(h.value==="e")return new CSSUnitValue(Math.E,"number");if(h.value==="pi")return new CSSUnitValue(Math.PI,"number");throw new SyntaxError("Invalid math expression")}return Mo(h)}function re(h){if(h.name==="min"||h.name==="max"){const S=h.values.filter(T=>!(T instanceof m||T instanceof _)).map(T=>fe(re(new Pe("calc",T))));return h.name==="min"?new CSSMathMin(...S):new CSSMathMax(...S)}if(h.name!=="calc")return null;const d=_t(function(S){const T=[],k=[];for(;S.length;){const I=S.shift();if(I instanceof u||I instanceof f||I instanceof p||I instanceof Pe||I instanceof Je||I instanceof e)k.push(I);else if(I instanceof l&&["*","/","+","-"].includes(I.value)){for(;T.length&&!(wt(T)instanceof M)&&ee(wt(T))>ee(I);){const U=T.pop(),N=k.pop(),L=k.pop();k.push(Lt(U,L,N))}T.push(I)}else if(I instanceof M)T.push(I);else if(I instanceof E){if(!T.length)return null;for(;!(wt(T)instanceof M);){const U=T.pop(),N=k.pop(),L=k.pop();k.push(Lt(U,L,N))}if(!(wt(T)instanceof M))return null;T.pop()}else if(!(I instanceof m))return null}for(;T.length;){if(wt(T)instanceof M)return null;const I=T.pop(),U=k.pop(),N=k.pop();k.push(Lt(I,N,U))}return k[0]}([...h.values]));let y;try{y=fe(d)}catch{new CSSStyleSheet().insertRule("error",0)}return y instanceof CSSUnitValue?new CSSMathSum(y):y}function Mo(h){return h instanceof Pe&&["calc","min","max","clamp"].includes(h.name)?re(h):h instanceof u&&h.value===0&&!h.unit?new CSSUnitValue(0,"px"):h instanceof u?new CSSUnitValue(h.value,"number"):h instanceof p?new CSSUnitValue(h.value,"percent"):h instanceof f?new CSSUnitValue(h.value,h.unit):void 0}function vl(h){const d=function(y){const S=st(y);for(;S[0]instanceof m;)S.shift();if(S[0]===void 0)return null;const T=Ge(S);for(;S[0]instanceof m;)S.shift();return S[0]===void 0?T:null}(h);return d===null&&new CSSStyleSheet().insertRule("error",0),d instanceof u||d instanceof p||d instanceof f||d instanceof Pe||new CSSStyleSheet().insertRule("error",0),d instanceof f&&bt(d.unit)===null&&new CSSStyleSheet().insertRule("error",0),Mo(d)}(function(){let h=new WeakMap;function d(k){const I=[];for(let N=0;N<k.length;N++)I[N]=typeof(U=k[N])=="number"?new CSSUnitValue(U,"number"):U;var U;return I}class y{static parse(I){return I instanceof y?I:fe(vl(I),{})}}class S extends y{constructor(I,U,N,L){super(),h.set(this,{values:d(I),operator:U,name:N||U,delimiter:L||", "})}get operator(){return h.get(this).operator}get values(){return h.get(this).values}toString(){const I=h.get(this);return`${I.name}(${I.values.join(I.delimiter)})`}}const T={CSSNumericValue:y,CSSMathValue:S,CSSUnitValue:class extends y{constructor(k,I){super(),h.set(this,{value:k,unit:I})}get value(){return h.get(this).value}set value(k){h.get(this).value=k}get unit(){return h.get(this).unit}to(k){return xt(this,k)}toSum(...k){return ht(this,...k)}type(){return bt(h.get(this).unit)}toString(){const k=h.get(this);return`${k.value}${function(I){switch(I){case"percent":return"%";case"number":return"";default:return I.toLowerCase()}}(k.unit)}`}},CSSKeywordValue:class{constructor(k){this.value=k}toString(){return this.value.toString()}},CSSMathSum:class extends S{constructor(k){super(arguments,"sum","calc"," + ")}},CSSMathProduct:class extends S{constructor(k){super(arguments,"product","calc"," * ")}toSum(...k){return ht(this,...k)}type(){return h.get(this).values.map(k=>k.type()).reduce(rt)}},CSSMathNegate:class extends S{constructor(k){super([arguments[0]],"negate","-")}get value(){return h.get(this).values[0]}type(){return this.value.type()}},CSSMathInvert:class extends S{constructor(k){super([1,arguments[0]],"invert","calc"," / ")}get value(){return h.get(this).values[1]}type(){return function(k){const I={};for(const U of lt)I[U]=-1*k[U];return I}(h.get(this).values[1].type())}},CSSMathMax:class extends S{constructor(){super(arguments,"max")}},CSSMathMin:class extends S{constructor(){super(arguments,"min")}}};if(!window.CSS&&!Reflect.defineProperty(window,"CSS",{value:{}}))throw Error("Error installing CSSOM support");window.CSSUnitValue||["number","percent","em","ex","px","cm","mm","in","pt","pc","Q","vw","vh","vmin","vmax","rems","ch","deg","rad","grad","turn","ms","s","Hz","kHz","dppx","dpi","dpcm","fr"].forEach(k=>{if(!Reflect.defineProperty(CSS,k,{value:I=>new CSSUnitValue(I,k)}))throw Error(`Error installing CSS.${k}`)});for(let[k,I]of Object.entries(T))if(!(k in window)&&!Reflect.defineProperty(window,k,{value:I}))throw Error(`Error installing CSSOM support for ${k}`)})();const Co="block";let De=new WeakMap,Ft=new WeakMap;const Qi=["entry","exit","cover","contain","entry-crossing","exit-crossing"];function Eo(h){return h===document.scrollingElement?document:h}function an(h){es(h);let d=De.get(h).animations;if(d.length===0)return;let y=h.currentTime;for(let S=0;S<d.length;S++)d[S].tickAnimation(y)}function Po(h,d){if(!h)return null;const y=Ft.get(h).sourceMeasurements,S=getComputedStyle(h);let T=y.scrollTop;return je(d,S)==="x"&&(T=Math.abs(y.scrollLeft)),T}function $r(h,d){const y=fe(h,d);if(y instanceof CSSUnitValue){if(y.unit==="px")return y.value;throw TypeError("Unhandled unit type "+y.unit)}throw TypeError("Unsupported value type: "+typeof h)}function es(h){if(!(h instanceof Mn))return void function(y){const S=De.get(y);if(!S.anonymousSource)return;const T=Ro(S.anonymousSource,S.anonymousTarget);Hn(y,T)}(h);const d=h.subject;if(!d||getComputedStyle(d).display=="none")return void Hn(h,null);Hn(h,os(d))}function ko(h){return["block","inline","x","y"].includes(h)}function ts(h){const d=getComputedStyle(h);return{scrollLeft:h.scrollLeft,scrollTop:h.scrollTop,scrollWidth:h.scrollWidth,scrollHeight:h.scrollHeight,clientWidth:h.clientWidth,clientHeight:h.clientHeight,writingMode:d.writingMode,direction:d.direction,scrollPaddingTop:d.scrollPaddingTop,scrollPaddingBottom:d.scrollPaddingBottom,scrollPaddingLeft:d.scrollPaddingLeft,scrollPaddingRight:d.scrollPaddingRight}}function ns(h,d){if(!h||!d)return;let y=0,S=0,T=d;const k=h.offsetParent;for(;T&&T!=k;)S+=T.offsetLeft,y+=T.offsetTop,T=T.offsetParent;S-=h.offsetLeft+h.clientLeft,y-=h.offsetTop+h.clientTop;const I=getComputedStyle(d);return{top:y,left:S,offsetWidth:d.offsetWidth,offsetHeight:d.offsetHeight,fontSize:I.fontSize}}function $i(h){let d=Ft.get(h);d.sourceMeasurements=ts(h);for(const y of d.timelineRefs){const S=y.deref();S instanceof Mn&&(De.get(S).subjectMeasurements=ns(h,S.subject))}d.updateScheduled||(setTimeout(()=>{for(const y of d.timelineRefs){const S=y.deref();S&&an(S)}d.updateScheduled=!1}),d.updateScheduled=!0)}function Hn(h,d){const y=De.get(h),S=y.source;if(S!=d){if(S){const T=Ft.get(S);if(T){T.timelineRefs.delete(h);const k=Array.from(T.timelineRefs).filter(I=>I.deref()===void 0);for(const I of k)T.timelineRefs.delete(I);T.timelineRefs.size===0&&(T.disconnect(),Ft.delete(S))}}if(y.source=d,d){let T=Ft.get(d);if(!T){T={timelineRefs:new Set,sourceMeasurements:ts(d)},Ft.set(d,T);const k=new ResizeObserver(N=>{for(const L of N)$i(y.source)});k.observe(d);for(const N of d.children)k.observe(N);const I=new MutationObserver(N=>{for(const L of N)$i(L.target)});I.observe(d,{attributes:!0,attributeFilter:["style","class"]});const U=()=>{T.sourceMeasurements.scrollLeft=d.scrollLeft,T.sourceMeasurements.scrollTop=d.scrollTop;for(const N of T.timelineRefs){const L=N.deref();L&&an(L)}};Eo(d).addEventListener("scroll",U),T.disconnect=()=>{k.disconnect(),I.disconnect(),Eo(d).removeEventListener("scroll",U)}}T.timelineRefs.add(new WeakRef(h))}}}function is(h,d){let y=De.get(h).animations;for(let S=0;S<y.length;S++)y[S].animation==d&&y.splice(S,1)}function rs(h,d,y){let S=De.get(h).animations;for(let T=0;T<S.length;T++)if(S[T].animation==d)return;S.push({animation:d,tickAnimation:y}),queueMicrotask(()=>{an(h)})}class We{constructor(d){if(De.set(this,{source:null,axis:Co,anonymousSource:d?d.anonymousSource:null,anonymousTarget:d?d.anonymousTarget:null,subject:null,inset:null,animations:[],subjectMeasurements:null}),Hn(this,d&&d.source!==void 0?d.source:document.scrollingElement),d&&d.axis!==void 0&&d.axis!=Co){if(!ko(d.axis))throw TypeError("Invalid axis");De.get(this).axis=d.axis}an(this)}set source(d){Hn(this,d),an(this)}get source(){return De.get(this).source}set axis(d){if(!ko(d))throw TypeError("Invalid axis");De.get(this).axis=d,an(this)}get axis(){return De.get(this).axis}get duration(){return CSS.percent(100)}get phase(){const d=this.source;if(!d)return"inactive";let y=getComputedStyle(d);return y.display=="none"?"inactive":d==document.scrollingElement||y.overflow!="visible"&&y.overflow!="clip"?"active":"inactive"}get currentTime(){const d=this.source;if(!d||!d.isConnected||this.phase=="inactive")return null;const y=getComputedStyle(d);if(y.display==="inline"||y.display==="none")return null;const S=this.axis,T=Po(d,S),k=function(I,U){const N=Ft.get(I).sourceMeasurements,L=getComputedStyle(I).writingMode=="horizontal-tb";return U==="block"?U=L?"y":"x":U==="inline"&&(U=L?"x":"y"),U==="y"?N.scrollHeight-N.clientHeight:U==="x"?N.scrollWidth-N.clientWidth:void 0}(d,S);return k>0?CSS.percent(100*T/k):CSS.percent(100)}get __polyfill(){return!0}}function ss(h,d){let y=h.parentElement;for(;y!=null;){if(d(y))return y;y=y.parentElement}}function Ro(h,d){switch(h){case"root":return document.scrollingElement;case"nearest":return os(d);case"self":return d;default:throw new TypeError("Invalid ScrollTimeline Source Type.")}}function Sl(h){switch(getComputedStyle(h).display){case"block":case"inline-block":case"list-item":case"table":case"table-caption":case"flow-root":case"flex":case"grid":return!0}return!1}function Ao(h){const d=getComputedStyle(h);return d.transform!="none"||d.perspective!="none"||d.willChange=="transform"||d.willChange=="perspective"||d.filter!="none"||d.willChange=="filter"||d.backdropFilter!="none"}function bl(h){return getComputedStyle(h).position!="static"||Ao(h)}function xl(h){switch(getComputedStyle(h).position){case"static":case"relative":case"sticky":return ss(h,Sl);case"absolute":return ss(h,bl);case"fixed":return ss(h,Ao)}}function os(h){if(h&&h.isConnected){for(;h=xl(h);)switch(getComputedStyle(h)["overflow-x"]){case"auto":case"scroll":case"hidden":return h==document.body&&getComputedStyle(document.scrollingElement).overflow=="visible"?document.scrollingElement:h}return document.scrollingElement}}function qn(h,d){const y=De.get(h),S=y.subjectMeasurements,T=Ft.get(y.source).sourceMeasurements;return h.phase==="inactive"?null:h instanceof Mn?as(d,T,S,y.axis,y.inset):null}function as(h,d,y,S,T){const k=d.direction=="rtl"||d.writingMode=="vertical-rl";let I,U,N={fontSize:y.fontSize};je(S,d)==="x"?(I=y.offsetWidth,U=y.left,N.scrollPadding=[d.scrollPaddingLeft,d.scrollPaddingRight],k&&(U+=d.scrollWidth-d.clientWidth,N.scrollPadding=[d.scrollPaddingRight,d.scrollPaddingLeft]),N.containerSize=d.clientWidth):(I=y.offsetHeight,U=y.top,N.scrollPadding=[d.scrollPaddingTop,d.scrollPaddingBottom],N.containerSize=d.clientHeight);const L=function(hs,rr){const Il={start:0,end:0};if(!hs)return Il;const[zl,Bl]=[hs.start,hs.end].map((Ho,qo)=>Ho==="auto"?rr.scrollPadding[qo]==="auto"?0:parseFloat(rr.scrollPadding[qo]):$r(Ho,{percentageReference:CSS.px(rr.containerSize),fontSize:CSS.px(parseFloat(rr.fontSize))}));return{start:zl,end:Bl}}(T,N),X=U-N.containerSize+L.end,Z=U+I-L.start,K=X+I,he=Z-I,we=Math.min(K,he),Qe=Math.max(K,he);let Tt,dt;const Wo=I>N.containerSize-L.start-L.end;switch(h){case"cover":Tt=X,dt=Z;break;case"contain":Tt=we,dt=Qe;break;case"entry":Tt=X,dt=we;break;case"exit":Tt=Qe,dt=Z;break;case"entry-crossing":Tt=X,dt=Wo?Qe:we;break;case"exit-crossing":Tt=Wo?we:Qe,dt=Z}return{start:Tt,end:dt}}function Oo(h,d){if(h instanceof Mn){const{rangeName:y,offset:S}=d;return Io(qn(h,y),S,qn(h,"cover"),h.subject)}if(h instanceof We){const{axis:y,source:S}=h,{sourceMeasurements:T}=Ft.get(S);let k;return k=je(y,T)==="x"?T.scrollWidth-T.clientWidth:T.scrollHeight-T.clientHeight,$r(d,{percentageReference:CSS.px(k)})/k}unsupportedTimeline(h)}function Io(h,d,y,S){if(!h||!y)return 0;let T=getComputedStyle(S);return($r(d,{percentageReference:CSS.px(h.end-h.start),fontSize:CSS.px(parseFloat(T.fontSize))})+h.start-y.start)/(y.end-y.start)}let Mn=class extends We{constructor(h){super(h);const d=De.get(this);d.subject=h&&h.subject?h.subject:void 0,h&&h.inset&&(d.inset=function(y){if(!y)return{start:0,end:0};let S;if(S=typeof y=="string"?Ye(y).map(T=>{if(T==="auto")return"auto";try{return CSSNumericValue.parse(T)}catch{throw TypeError(`Could not parse inset "${y}"`)}}):Array.isArray(y)?y:[y],S.length===0||S.length>2)throw TypeError("Invalid inset");for(const T of S){if(T==="auto")continue;const k=T.type();if(k.length!==1&&k.percent!==1)throw TypeError("Invalid inset")}return{start:S[0],end:S[1]??S[0]}}(h.inset)),d.subject&&(new ResizeObserver(()=>{$i(d.source)}).observe(d.subject),new MutationObserver(()=>{$i(d.source)}).observe(d.subject,{attributes:!0,attributeFilter:["class","style"]})),es(this),d.subjectMeasurements=ns(d.source,d.subject),an(this)}get source(){return es(this),De.get(this).source}set source(h){throw new Error("Cannot set the source of a view timeline")}get subject(){return De.get(this).subject}get axis(){return De.get(this).axis}get currentTime(){const h=Po(this.source,this.axis);if(h==null)return null;const d=qn(this,"cover");if(!d)return null;const y=(h-d.start)/(d.end-d.start);return CSS.percent(100*y)}get startOffset(){return CSS.px(qn(this,"cover").start)}get endOffset(){return CSS.px(qn(this,"cover").end)}};const wl=document.getAnimations,_l=window.Element.prototype.getAnimations,Tl=window.Element.prototype.animate,zo=window.Animation;class Cn{constructor(){this.state="pending",this.nativeResolve=this.nativeReject=null,this.promise=new Promise((d,y)=>{this.nativeResolve=d,this.nativeReject=y})}resolve(d){this.state="resolved",this.nativeResolve(d)}reject(d){this.state="rejected",this.promise.catch(()=>{}),this.nativeReject(d)}}function Xn(h){h.readyPromise=new Cn,requestAnimationFrame(()=>{var d;(((d=h.timeline)==null?void 0:d.currentTime)??null)!==null&&(er(h),h.pendingTask!=="play"||h.startTime===null&&h.holdTime===null?h.pendingTask==="pause"&&Uo(h):No(h))})}function Bo(){return new DOMException("The user aborted a request","AbortError")}function cn(h,d){if(d===null)return d;if(typeof d!="number")throw new DOMException(`Unexpected value: ${d}. Cannot convert to CssNumberish`,"InvalidStateError");const y=h.rangeDuration??100,S=jt(h),T=S?y*d/S:0;return CSS.percent(T)}function ge(h,d){if(h.timeline){if(d===null)return d;if(d.unit==="percent"){const y=h.rangeDuration??100,S=jt(h);return d.value*S/y}throw new DOMException("CSSNumericValue must be a percentage for progress based animations.","NotSupportedError")}{if(d==null||typeof d=="number")return d;const y=d.to("ms");if(y)return y.value;throw new DOMException("CSSNumericValue must be either a number or a time value for time based animations.","InvalidStateError")}}function No(h){const d=ge(h,h.timeline.currentTime);if(h.holdTime!=null)At(h),h.animation.playbackRate==0?h.startTime=d:(h.startTime=d-h.holdTime/h.animation.playbackRate,h.holdTime=null);else if(h.startTime!==null&&h.pendingPlaybackRate!==null){const y=(d-h.startTime)*h.animation.playbackRate;At(h);const S=h.animation.playbackRate;S==0?(h.holdTime=null,h.startTime=d):h.startTime=d-y/S}h.readyPromise&&h.readyPromise.state=="pending"&&h.readyPromise.resolve(h.proxy),Vt(h,!1,!1),Jt(h),h.pendingTask=null}function Uo(h){const d=ge(h,h.timeline.currentTime);h.startTime!=null&&h.holdTime==null&&(h.holdTime=(d-h.startTime)*h.animation.playbackRate),At(h),h.startTime=null,h.readyPromise.resolve(h.proxy),Vt(h,!1,!1),Jt(h),h.pendingTask=null}function Do(h){if(!h.finishedPromise||h.finishedPromise.state!="pending"||h.proxy.playState!="finished")return;h.finishedPromise.resolve(h.proxy),h.animation.pause();const d=new CustomEvent("finish",{detail:{currentTime:h.proxy.currentTime,timelineTime:h.proxy.timeline.currentTime}});Object.defineProperty(d,"currentTime",{get:function(){return this.detail.currentTime}}),Object.defineProperty(d,"timelineTime",{get:function(){return this.detail.timelineTime}}),requestAnimationFrame(()=>{queueMicrotask(()=>{h.animation.dispatchEvent(d)})})}function En(h){return h.pendingPlaybackRate!==null?h.pendingPlaybackRate:h.animation.playbackRate}function At(h){h.pendingPlaybackRate!==null&&(h.animation.playbackRate=h.pendingPlaybackRate,h.pendingPlaybackRate=null)}function Lo(h){if(!h.timeline)return null;const d=ge(h,h.timeline.currentTime);if(d===null||h.startTime===null)return null;let y=(d-h.startTime)*h.animation.playbackRate;return y==-0&&(y=0),y}function Vt(h,d,y){if(!h.timeline)return;let S=d?ge(h,h.proxy.currentTime):Lo(h);if(S&&h.startTime!=null&&!h.proxy.pending){const T=En(h),k=jt(h);let I=h.previousCurrentTime;T>0&&S>=k&&h.previousCurrentTime!=null?((I===null||I<k)&&(I=k),h.holdTime=d?S:I):T<0&&S<=0?((I==null||I>0)&&(I=0),h.holdTime=d?S:I):T!=0&&(d&&h.holdTime!==null&&(h.startTime=function(U,N){if(!U.timeline)return null;const L=ge(U,U.timeline.currentTime);return L==null?null:L-N/U.animation.playbackRate}(h,h.holdTime)),h.holdTime=null)}Jt(h),h.previousCurrentTime=ge(h,h.proxy.currentTime),h.proxy.playState=="finished"?(h.finishedPromise||(h.finishedPromise=new Cn),h.finishedPromise.state=="pending"&&(y?Do(h):Promise.resolve().then(()=>{Do(h)}))):(h.finishedPromise&&h.finishedPromise.state=="resolved"&&(h.finishedPromise=new Cn),h.animation.playState!="paused"&&h.animation.pause())}function jt(h){const d=function(S){const T=S.proxy.effect.getTiming();return S.normalizedTiming||T}(h),y=d.delay+d.endDelay+d.iterations*d.duration;return Math.max(0,y)}function Jt(h){if(h.timeline)if(h.startTime!==null){const d=h.timeline.currentTime;if(d==null)return;cs(h,(ge(h,d)-h.startTime)*h.animation.playbackRate)}else h.holdTime!==null&&cs(h,h.holdTime)}function cs(h,d){const y=h.timeline,S=h.animation.playbackRate,T=y.currentTime&&y.currentTime.value==(S<0?0:100)?S<0?.001:-.001:0;h.animation.currentTime=d+T}function ls(h,d){if(!h.timeline)return;const y=h.proxy.playState=="paused"&&h.proxy.pending;let S=!1,T=ge(h,h.proxy.currentTime);En(h)==0&&T==null&&(h.holdTime=0),T==null&&(h.autoAlignStartTime=!0),(h.proxy.playState==="finished"||y)&&(h.holdTime=null,h.startTime=null,h.autoAlignStartTime=!0),h.holdTime&&(h.startTime=null),h.pendingTask&&(h.pendingTask=null,S=!0),(h.holdTime!==null||h.autoAlignStartTime||y||h.pendingPlaybackRate!==null)&&(h.readyPromise&&!S&&(h.readyPromise=null),Jt(h),h.readyPromise||Xn(h),h.pendingTask="play",rs(h.timeline,h.animation,us.bind(h.proxy)),Vt(h,!1,!1))}function us(h){const d=Y.get(this);if(!d)return;if(h==null)return void(d.proxy.playState!=="paused"&&d.animation.playState!="idle"&&d.animation.cancel());er(d),d.pendingTask&&requestAnimationFrame(()=>{d.pendingTask!=="play"||d.startTime===null&&d.holdTime===null?d.pendingTask==="pause"&&Uo(d):No(d)});const y=this.playState;if(y=="running"||y=="finished"){const S=ge(d,h);cs(d,(S-ge(d,this.startTime))*this.playbackRate),Vt(d,!1,!1)}}function Fo(h){h.specifiedTiming=null}let Y=new WeakMap;window.addEventListener("pagehide",h=>{Y=new WeakMap},!1);let Vo=new WeakMap;function er(h){if(!h.autoAlignStartTime||!h.timeline||!h.timeline.currentTime||h.proxy.playState==="idle"||h.proxy.playState==="paused"&&h.holdTime!==null)return;const d=h.rangeDuration;let y,S;try{y=CSS.percent(100*function(k){if(!k.animationRange)return 0;const I=k.animationRange.start==="normal"?jo(k.timeline):k.animationRange.start;return Oo(k.timeline,I)}(h))}catch(k){y=CSS.percent(0),h.animationRange.start="normal",console.warn("Exception when calculating start offset",k)}try{S=CSS.percent(100*(1-function(k){if(!k.animationRange)return 0;const I=k.animationRange.end==="normal"?Jo(k.timeline):k.animationRange.end;return 1-Oo(k.timeline,I)}(h)))}catch(k){S=CSS.percent(100),h.animationRange.end="normal",console.warn("Exception when calculating end offset",k)}h.rangeDuration=S.value-y.value;const T=En(h);h.startTime=ge(h,T>=0?y:S),h.holdTime=null,h.rangeDuration!==d&&Fo(h)}function tr(h){throw new Error("Unsupported timeline class")}function jo(h){return h instanceof ViewTimeline?{rangeName:"cover",offset:CSS.percent(0)}:h instanceof We?CSS.percent(0):void tr()}function Jo(h){return h instanceof ViewTimeline?{rangeName:"cover",offset:CSS.percent(100)}:h instanceof We?CSS.percent(100):void tr()}function Ml(h,d){if(!d)return{start:"normal",end:"normal"};const y={start:jo(h),end:Jo(h)};if(h instanceof ViewTimeline){const S=Ye(d),T=[],k=[];if(S.forEach(I=>{if(Qi.includes(I))T.push(I);else try{k.push(CSSNumericValue.parse(I))}catch{throw TypeError(`Could not parse range "${d}"`)}}),T.length>2||k.length>2||k.length==1)throw TypeError("Invalid time range or unsupported time range format.");return T.length&&(y.start.rangeName=T[0],y.end.rangeName=T.length>1?T[1]:T[0]),k.length>1&&(y.start.offset=k[0],y.end.offset=k[1]),y}if(h instanceof We){const S=d.split(" ");if(S.length!=2)throw TypeError("Invalid time range or unsupported time range format.");return y.start=CSSNumericValue.parse(S[0]),y.end=CSSNumericValue.parse(S[1]),y}tr()}function nr(h,d,y){if(!d||d==="normal")return"normal";if(h instanceof ViewTimeline){let S="cover",T=y==="start"?CSS.percent(0):CSS.percent(100);if(d instanceof Object)d.rangeName!==void 0&&(S=d.rangeName),d.offset!==void 0&&(T=d.offset);else{const k=Ye(d);k.length===1?Qi.includes(k[0])?S=k[0]:T=fe(CSSNumericValue.parse(k[0]),{}):k.length===2&&(S=k[0],T=fe(CSSNumericValue.parse(k[1]),{}))}if(!Qi.includes(S))throw TypeError("Invalid range name");return{rangeName:S,offset:T}}if(h instanceof We)return CSSNumericValue.parse(d);tr()}class ir{constructor(d,y,S={}){const T=y instanceof We,k=d instanceof zo?d:new zo(d,T?void 0:y);Vo.set(k,this),Y.set(this,{animation:k,timeline:T?y:void 0,playState:T?"idle":null,readyPromise:null,finishedPromise:null,startTime:null,holdTime:null,rangeDuration:null,previousCurrentTime:null,autoAlignStartTime:!1,pendingPlaybackRate:null,pendingTask:null,specifiedTiming:null,normalizedTiming:null,effect:null,animationRange:T?Ml(y,S["animation-range"]):null,proxy:this})}get effect(){const d=Y.get(this);return d.timeline?(d.effect||(d.effect=function(y){const S=y.animation.effect,T=S.updateTiming,k={apply:function(L){S.getTiming();const X=L.apply(S);if(y.timeline){const Z=y.duration??100;X.localTime=cn(y,X.localTime),X.endTime=cn(y,X.endTime),X.activeDuration=cn(y,X.activeDuration);const K=jt(y),he=X.iterations?(K-X.delay-X.endDelay)/X.iterations:0;X.duration=K?CSS.percent(Z*he/K):CSS.percent(0),y.timeline.currentTime===void 0&&(X.localTime=null)}return X}},I={apply:function(L,X){if(y.specifiedTiming)return y.specifiedTiming;y.specifiedTiming=L.apply(S);let Z,K=Object.assign({},y.specifiedTiming);if(K.duration===1/0)throw TypeError("Effect duration cannot be Infinity when used with Scroll Timelines");return(K.duration===null||K.duration==="auto"||y.autoDurationEffect)&&y.timeline&&(y.autoDurationEffect=!0,K.delay=0,K.endDelay=0,Z=K.iterations?1e5:0,K.duration=K.iterations?(Z-K.delay-K.endDelay)/K.iterations:0,K.duration<0&&(K.duration=0,K.endDelay=Z-K.delay),T.apply(S,[K])),y.normalizedTiming=K,y.specifiedTiming}},U={apply:function(L,X,Z){if(Z&&Z.length){if(y.timeline&&Z[0]){const K=Z[0],he=K.duration;if(he===1/0)throw TypeError("Effect duration cannot be Infinity when used with Scroll Timelines");if(K.iterations===1/0)throw TypeError("Effect iterations cannot be Infinity when used with Scroll Timelines");he!==void 0&&he!=="auto"&&(y.autoDurationEffect=null)}y.specifiedTiming&&L.apply(S,[y.specifiedTiming]),L.apply(S,Z),Fo(y)}}},N=new Proxy(S,{get:function(L,X){const Z=L[X];return typeof Z=="function"?Z.bind(S):Z},set:function(L,X,Z){return L[X]=Z,!0}});return N.getComputedTiming=new Proxy(S.getComputedTiming,k),N.getTiming=new Proxy(S.getTiming,I),N.updateTiming=new Proxy(S.updateTiming,U),N}(d)),d.effect):d.animation.effect}set effect(d){const y=Y.get(this);y.animation.effect=d,y.effect=null,y.autoDurationEffect=null}get timeline(){const d=Y.get(this);return d.timeline||d.animation.timeline}set timeline(d){const y=Y.get(this),S=this.timeline;if(S==d)return;const T=this.playState,k=this.currentTime;let I,U=jt(y);I=k===null?null:U===0?0:ge(y,k)/U;const N=S instanceof We,L=d instanceof We,X=this.pending;if(N&&is(y.timeline,y.animation),L)return y.timeline=d,At(y),y.autoAlignStartTime=!0,y.startTime=null,y.holdTime=null,T!=="running"&&T!=="finished"||(y.readyPromise&&y.readyPromise.state!=="resolved"||Xn(y),y.pendingTask="play",rs(y.timeline,y.animation,us.bind(this))),T==="paused"&&I!==null&&(y.holdTime=I*U),X&&(y.readyPromise&&y.readyPromise.state!="resolved"||Xn(y),y.pendingTask=T=="paused"?"pause":"play"),y.startTime!==null&&(y.holdTime=null),void Vt(y,!1,!1);if(y.animation.timeline!=d)throw TypeError("Unsupported timeline: "+d);if(is(y.timeline,y.animation),y.timeline=null,N)switch(k!==null&&(y.animation.currentTime=I*jt(y)),T){case"paused":y.animation.pause();break;case"running":case"finished":y.animation.play()}}get startTime(){const d=Y.get(this);return d.timeline?cn(d,d.startTime):d.animation.startTime}set startTime(d){const y=Y.get(this);if(d=ge(y,d),!y.timeline)return void(y.animation.startTime=d);y.autoAlignStartTime=!1,ge(y,y.timeline.currentTime)==null&&y.startTime!=null&&(y.holdTime=null,Jt(y));const S=ge(y,this.currentTime);At(y),y.startTime=d,y.startTime!==null&&y.animation.playbackRate!=0?y.holdTime=null:y.holdTime=S,y.pendingTask&&(y.pendingTask=null,y.readyPromise.resolve(this)),Vt(y,!0,!1),Jt(y)}get currentTime(){const d=Y.get(this);return d.timeline?d.holdTime!=null?cn(d,d.holdTime):cn(d,Lo(d)):d.animation.currentTime}set currentTime(d){const y=Y.get(this);y.timeline?(function(S,T){if(T==null&&S.currentTime!==null)throw new TypeError;T=ge(S,T),S.autoAlignStartTime=!1,S.holdTime!==null||S.startTime===null||S.timeline.phase==="inactive"||S.animation.playbackRate===0?S.holdTime=T:S.startTime=ge(S,S.timeline.currentTime)-T/S.animation.playbackRate,S.timeline.phase==="inactive"&&(S.startTime=null),S.previousCurrentTime=null}(y,d),y.pendingTask=="pause"&&(y.holdTime=ge(y,d),At(y),y.startTime=null,y.pendingTask=null,y.readyPromise.resolve(this)),Vt(y,!0,!1)):y.animation.currentTime=d}get playbackRate(){return Y.get(this).animation.playbackRate}set playbackRate(d){const y=Y.get(this);if(!y.timeline)return void(y.animation.playbackRate=d);y.pendingPlaybackRate=null;const S=this.currentTime;y.animation.playbackRate=d,S!==null&&(this.currentTime=S)}get playState(){const d=Y.get(this);if(!d.timeline)return d.animation.playState;const y=ge(d,this.currentTime);return y===null&&d.startTime===null&&d.pendingTask==null?"idle":d.pendingTask=="pause"||d.startTime===null&&d.pendingTask!="play"?"paused":y!=null&&(d.animation.playbackRate>0&&y>=jt(d)||d.animation.playbackRate<0&&y<=0)?"finished":"running"}get rangeStart(){var d;return((d=Y.get(this).animationRange)==null?void 0:d.start)??"normal"}set rangeStart(d){const y=Y.get(this);if(!y.timeline)return y.animation.rangeStart=d;y.timeline instanceof We&&(y.animationRange.start=nr(y.timeline,d,"start"),er(y),Jt(y))}get rangeEnd(){var d;return((d=Y.get(this).animationRange)==null?void 0:d.end)??"normal"}set rangeEnd(d){const y=Y.get(this);if(!y.timeline)return y.animation.rangeEnd=d;y.timeline instanceof We&&(y.animationRange.end=nr(y.timeline,d,"end"),er(y),Jt(y))}get replaceState(){return Y.get(this).animation.pending}get pending(){const d=Y.get(this);return d.timeline?!!d.readyPromise&&d.readyPromise.state=="pending":d.animation.pending}finish(){const d=Y.get(this);if(!d.timeline)return void d.animation.finish();const y=En(d),S=jt(d);if(y==0)throw new DOMException("Cannot finish Animation with a playbackRate of 0.","InvalidStateError");if(y>0&&S==1/0)throw new DOMException("Cannot finish Animation with an infinite target effect end.","InvalidStateError");At(d);const T=y<0?0:S;this.currentTime=cn(d,T);const k=ge(d,d.timeline.currentTime);d.startTime===null&&k!==null&&(d.startTime=k-T/d.animation.playbackRate),d.pendingTask=="pause"&&d.startTime!==null&&(d.holdTime=null,d.pendingTask=null,d.readyPromise.resolve(this)),d.pendingTask=="play"&&d.startTime!==null&&(d.pendingTask=null,d.readyPromise.resolve(this)),Vt(d,!0,!0)}play(){const d=Y.get(this);d.timeline?ls(d):d.animation.play()}pause(){const d=Y.get(this);d.timeline?this.playState!="paused"&&(d.animation.currentTime===null&&(d.autoAlignStartTime=!0),d.pendingTask=="play"?d.pendingTask=null:d.readyPromise=null,d.readyPromise||Xn(d),d.pendingTask="pause",rs(d.timeline,d.animation,us.bind(d.proxy))):d.animation.pause()}reverse(){const d=Y.get(this),y=En(d),S=ge(d,this.currentTime),T=jt(d)==1/0,k=y!=0&&(y<0||S>0||!T);if(!d.timeline||!k)return k&&(d.pendingPlaybackRate=-En(d)),void d.animation.reverse();if(d.timeline.phase=="inactive")throw new DOMException("Cannot reverse an animation with no active timeline","InvalidStateError");this.updatePlaybackRate(-y),ls(d)}updatePlaybackRate(d){const y=Y.get(this);if(y.pendingPlaybackRate=d,!y.timeline)return void y.animation.updatePlaybackRate(d);const S=this.playState;if(!y.readyPromise||y.readyPromise.state!="pending")switch(S){case"idle":case"paused":At(y);break;case"finished":const T=ge(y,y.timeline.currentTime),k=T!==null?(T-y.startTime)*y.animation.playbackRate:null;y.startTime=d==0?T:T!=null&&k!=null?(T-k)/d:null,At(y),Vt(y,!1,!1),Jt(y);break;default:ls(y)}}persist(){Y.get(this).animation.persist()}get id(){return Y.get(this).animation.id}set id(d){Y.get(this).animation.id=d}cancel(){const d=Y.get(this);d.timeline?(this.playState!="idle"&&(function(y){y.pendingTask&&(y.pendingTask=null,At(y),y.readyPromise.reject(Bo()),Xn(y),y.readyPromise.resolve(y.proxy))}(d),d.finishedPromise&&d.finishedPromise.state=="pending"&&d.finishedPromise.reject(Bo()),d.finishedPromise=new Cn,d.animation.cancel()),d.startTime=null,d.holdTime=null,is(d.timeline,d.animation)):d.animation.cancel()}get onfinish(){return Y.get(this).animation.onfinish}set onfinish(d){Y.get(this).animation.onfinish=d}get oncancel(){return Y.get(this).animation.oncancel}set oncancel(d){Y.get(this).animation.oncancel=d}get onremove(){return Y.get(this).animation.onremove}set onremove(d){Y.get(this).animation.onremove=d}get finished(){const d=Y.get(this);return d.timeline?(d.finishedPromise||(d.finishedPromise=new Cn),d.finishedPromise.promise):d.animation.finished}get ready(){const d=Y.get(this);return d.timeline?(d.readyPromise||(d.readyPromise=new Cn,d.readyPromise.resolve(this)),d.readyPromise.promise):d.animation.ready}addEventListener(d,y,S){Y.get(this).animation.addEventListener(d,y,S)}removeEventListener(d,y,S){Y.get(this).animation.removeEventListener(d,y,S)}dispatchEvent(d){Y.get(this).animation.dispatchEvent(d)}}function Cl(h,d){const y=d.timeline;y instanceof We&&delete d.timeline;const S=Tl.apply(this,[h,d]),T=new ir(S,y);return y instanceof We&&(S.pause(),Y.get(T).animationRange={start:nr(y,d.rangeStart,"start"),end:nr(y,d.rangeEnd,"end")},T.play()),T}function Go(h){for(let d=0;d<h.length;++d){let y=Vo.get(h[d]);y&&(h[d]=y)}return h}function El(h){return Go(_l.apply(this,[h]))}function Pl(h){return Go(wl.apply(this,[h]))}const ke={IDENTIFIER:/[\w\\\@_-]+/g,WHITE_SPACE:/\s*/g,TIME:/^[0-9]+(s|ms)/,SCROLL_TIMELINE:/scroll-timeline\s*:([^;}]+)/,SCROLL_TIMELINE_NAME:/scroll-timeline-name\s*:([^;}]+)/,SCROLL_TIMELINE_AXIS:/scroll-timeline-axis\s*:([^;}]+)/,VIEW_TIMELINE:/view-timeline\s*:([^;}]+)/,VIEW_TIMELINE_NAME:/view-timeline-name\s*:([^;}]+)/,VIEW_TIMELINE_AXIS:/view-timeline-axis\s*:([^;}]+)/,VIEW_TIMELINE_INSET:/view-timeline-inset\s*:([^;}]+)/,ANIMATION_TIMELINE:/animation-timeline\s*:([^;}]+)/,ANIMATION_TIME_RANGE:/animation-range\s*:([^;}]+)/,ANIMATION_NAME:/animation-name\s*:([^;}]+)/,ANIMATION:/animation\s*:([^;}]+)/,ANONYMOUS_SCROLL_TIMELINE:/scroll\(([^)]*)\)/,ANONYMOUS_VIEW_TIMELINE:/view\(([^)]*)\)/},Pn=["block","inline","x","y"],kl=["nearest","root","self"],Kt=new class{constructor(){this.cssRulesWithTimelineName=[],this.nextAnonymousTimelineNameIndex=0,this.anonymousScrollTimelineOptions=new Map,this.anonymousViewTimelineOptions=new Map,this.sourceSelectorToScrollTimeline=[],this.subjectSelectorToViewTimeline=[],this.keyframeNamesSelectors=new Map}transpileStyleSheet(h,d,y){const S={sheetSrc:h,index:0,name:y};for(;S.index<S.sheetSrc.length&&(this.eatWhitespace(S),!(S.index>=S.sheetSrc.length));){if(this.lookAhead("/*",S)){for(;this.lookAhead("/*",S);)this.eatComment(S),this.eatWhitespace(S);continue}const T=this.parseQualifiedRule(S);T&&(d?this.parseKeyframesAndSaveNameMapping(T,S):this.handleScrollTimelineProps(T,S))}return S.sheetSrc}getAnimationTimelineOptions(h,d){for(let y=this.cssRulesWithTimelineName.length-1;y>=0;y--){const S=this.cssRulesWithTimelineName[y];try{if(d.matches(S.selector)&&(!S["animation-name"]||S["animation-name"]==h))return{"animation-timeline":S["animation-timeline"],"animation-range":S["animation-range"]}}catch{}}return null}getAnonymousScrollTimelineOptions(h,d){const y=this.anonymousScrollTimelineOptions.get(h);return y?{anonymousSource:y.source,anonymousTarget:d,source:Ro(y.source??"nearest",d),axis:y.axis?y.axis:"block"}:null}getScrollTimelineOptions(h,d){const y=this.getAnonymousScrollTimelineOptions(h,d);if(y)return y;for(let S=this.sourceSelectorToScrollTimeline.length-1;S>=0;S--){const T=this.sourceSelectorToScrollTimeline[S];if(T.name==h){const k=this.findPreviousSiblingOrAncestorMatchingSelector(d,T.selector);if(k)return{source:k,...T.axis?{axis:T.axis}:{}}}}return null}findPreviousSiblingOrAncestorMatchingSelector(h,d){let y=h;for(;y;){if(y.matches(d))return y;y=y.previousElementSibling||y.parentElement}return null}getAnonymousViewTimelineOptions(h,d){const y=this.anonymousViewTimelineOptions.get(h);return y?{subject:d,axis:y.axis?y.axis:"block",inset:y.inset?y.inset:"auto"}:null}getViewTimelineOptions(h,d){const y=this.getAnonymousViewTimelineOptions(h,d);if(y)return y;for(let S=this.subjectSelectorToViewTimeline.length-1;S>=0;S--){const T=this.subjectSelectorToViewTimeline[S];if(T.name==h){const k=this.findPreviousSiblingOrAncestorMatchingSelector(d,T.selector);if(k)return{subject:k,axis:T.axis,inset:T.inset}}}return null}handleScrollTimelineProps(h,d){if(h.selector.includes("@keyframes"))return;const y=h.block.contents.includes("animation-name:"),S=h.block.contents.includes("animation-timeline:"),T=h.block.contents.includes("animation:");if(this.saveSourceSelectorToScrollTimeline(h),this.saveSubjectSelectorToViewTimeline(h),!S&&!y&&!T)return;let k=[],I=[],U=!1;S&&(k=this.extractScrollTimelineNames(h.block.contents)),y&&(I=this.extractMatches(h.block.contents,ke.ANIMATION_NAME)),S&&y||(T&&this.extractMatches(h.block.contents,ke.ANIMATION).forEach(N=>{const L=this.extractAnimationName(N);L&&S&&I.push(L),S&&(this.hasDuration(N)||(this.hasAutoDuration(N)&&(h.block.contents=h.block.contents.replace("auto"," ")),h.block.contents=h.block.contents.replace(N," 1s "+N),U=!0))}),U&&this.replacePart(h.block.startIndex,h.block.endIndex,h.block.contents,d)),this.saveRelationInList(h,k,I)}saveSourceSelectorToScrollTimeline(h){const d=h.block.contents.includes("scroll-timeline:"),y=h.block.contents.includes("scroll-timeline-name:"),S=h.block.contents.includes("scroll-timeline-axis:");if(!d&&!y)return;let T=[];if(d){const I=this.extractMatches(h.block.contents,ke.SCROLL_TIMELINE);for(const U of I){const N=this.split(U);let L={selector:h.selector,name:""};N.length==1?L.name=N[0]:N.length==2&&(Pn.includes(N[0])?(L.axis=N[0],L.name=N[1]):(L.axis=N[1],L.name=N[0])),T.push(L)}}if(y){const I=this.extractMatches(h.block.contents,ke.SCROLL_TIMELINE_NAME);for(let U=0;U<I.length;U++)if(U<T.length)T[U].name=I[U];else{let N={selector:h.selector,name:I[U]};T.push(N)}}let k=[];if(S){const I=this.extractMatches(h.block.contents,ke.SCROLL_TIMELINE_AXIS);if(k=I.filter(U=>Pn.includes(U)),k.length!=I.length)throw new Error("Invalid axis")}for(let I=0;I<T.length;I++)k.length&&(T[I].axis=k[I%T.length]);this.sourceSelectorToScrollTimeline.push(...T)}saveSubjectSelectorToViewTimeline(h){const d=h.block.contents.includes("view-timeline:"),y=h.block.contents.includes("view-timeline-name:"),S=h.block.contents.includes("view-timeline-axis:"),T=h.block.contents.includes("view-timeline-inset:");if(!d&&!y)return;let k=[];if(d){const N=this.extractMatches(h.block.contents,ke.VIEW_TIMELINE);for(let L of N){const X=this.split(L);let Z={selector:h.selector,name:"",inset:null};X.length==1?Z.name=X[0]:X.length==2&&(Pn.includes(X[0])?(Z.axis=X[0],Z.name=X[1]):(Z.axis=X[1],Z.name=X[0])),k.push(Z)}}if(y){const N=this.extractMatches(h.block.contents,ke.VIEW_TIMELINE_NAME);for(let L=0;L<N.length;L++)if(L<k.length)k[L].name=N[L];else{let X={selector:h.selector,name:N[L],inset:null};k.push(X)}}let I=[],U=[];if(T&&(I=this.extractMatches(h.block.contents,ke.VIEW_TIMELINE_INSET)),S){const N=this.extractMatches(h.block.contents,ke.VIEW_TIMELINE_AXIS);if(U=N.filter(L=>Pn.includes(L)),U.length!=N.length)throw new Error("Invalid axis")}for(let N=0;N<k.length;N++)I.length&&(k[N].inset=I[N%k.length]),U.length&&(k[N].axis=U[N%k.length]);this.subjectSelectorToViewTimeline.push(...k)}hasDuration(h){return h.split(" ").filter(d=>{return y=d,ke.TIME.exec(y);var y}).length>=1}hasAutoDuration(h){return h.split(" ").filter(d=>d==="auto").length>=1}saveRelationInList(h,d,y){let S=[];h.block.contents.includes("animation-range:")&&(S=this.extractMatches(h.block.contents,ke.ANIMATION_TIME_RANGE));const T=Math.max(d.length,y.length,S.length);for(let k=0;k<T;k++)this.cssRulesWithTimelineName.push({selector:h.selector,"animation-timeline":d[k%d.length],...y.length?{"animation-name":y[k%y.length]}:{},...S.length?{"animation-range":S[k%S.length]}:{}})}extractScrollTimelineNames(h){const d=ke.ANIMATION_TIMELINE.exec(h)[1].trim(),y=[];return d.split(",").map(S=>S.trim()).forEach(S=>{if(function(T){return(T.startsWith("scroll")||T.startsWith("view"))&&T.includes("(")}(S)){const T=this.saveAnonymousTimelineName(S);y.push(T)}else y.push(S)}),y}saveAnonymousTimelineName(h){const d=":t"+this.nextAnonymousTimelineNameIndex++;return h.startsWith("scroll(")?this.anonymousScrollTimelineOptions.set(d,this.parseAnonymousScrollTimeline(h)):this.anonymousViewTimelineOptions.set(d,this.parseAnonymousViewTimeline(h)),d}parseAnonymousScrollTimeline(h){const d=ke.ANONYMOUS_SCROLL_TIMELINE.exec(h);if(!d)return null;const y=d[1],S={};return y.split(" ").forEach(T=>{Pn.includes(T)?S.axis=T:kl.includes(T)&&(S.source=T)}),S}parseAnonymousViewTimeline(h){const d=ke.ANONYMOUS_VIEW_TIMELINE.exec(h);if(!d)return null;const y=d[1],S={};return y.split(" ").forEach(T=>{Pn.includes(T)?S.axis=T:S.inset=S.inset?`${S.inset} ${T}`:T}),S}extractAnimationName(h){return this.findMatchingEntryInContainer(h,this.keyframeNamesSelectors)}findMatchingEntryInContainer(h,d){const y=h.split(" ").filter(S=>d.has(S));return y?y[0]:null}parseIdentifier(h){ke.IDENTIFIER.lastIndex=h.index;const d=ke.IDENTIFIER.exec(h.sheetSrc);if(!d)throw this.parseError(h,"Expected an identifier");return h.index+=d[0].length,d[0]}parseKeyframesAndSaveNameMapping(h,d){if(h.selector.startsWith("@keyframes")){const y=this.replaceKeyframesAndGetMapping(h,d);h.selector.split(" ").forEach((S,T)=>{T>0&&this.keyframeNamesSelectors.set(S,y)})}}replaceKeyframesAndGetMapping(h,d){function y(N){return Qi.some(L=>N.startsWith(L))}const S=h.block.contents,T=function(N){let L=0,X=-1,Z=-1;const K=[];for(let he=0;he<N.length;he++)N[he]=="{"?L++:N[he]=="}"&&L--,L==1&&N[he]!="{"&&N[he]!="}"&&X==-1&&(X=he),L==2&&N[he]=="{"&&(Z=he,K.push({start:X,end:Z}),X=Z=-1);return K}(S);if(T.length==0)return new Map;const k=new Map;let I=!1;const U=[];U.push(S.substring(0,T[0].start));for(let N=0;N<T.length;N++){const L=S.substring(T[N].start,T[N].end);let X=[];L.split(",").forEach(Z=>{const K=Z.split(" ").map(we=>we.trim()).filter(we=>we!="").join(" "),he=k.size;k.set(he,K),X.push(`${he}%`),y(K)&&(I=!0)}),U.push(X.join(",")),N==T.length-1?U.push(S.substring(T[N].end)):U.push(S.substring(T[N].end,T[N+1].start))}return I?(h.block.contents=U.join(""),this.replacePart(h.block.startIndex,h.block.endIndex,h.block.contents,d),k):new Map}parseQualifiedRule(h){const d=h.index,y=this.parseSelector(h).trim();if(y)return{selector:y,block:this.eatBlock(h),startIndex:d,endIndex:h.index}}removeEnclosingDoubleQuotes(h){let d=h[0]=='"'?1:0,y=h[h.length-1]=='"'?h.length-1:h.length;return h.substring(d,y)}assertString(h,d){if(h.sheetSrc.substr(h.index,d.length)!=d)throw this.parseError(h,`Did not find expected sequence ${d}`);h.index+=d.length}replacePart(h,d,y,S){if(S.sheetSrc=S.sheetSrc.slice(0,h)+y+S.sheetSrc.slice(d),S.index>=d){const T=S.index-d;S.index=h+y.length+T}}eatComment(h){this.assertString(h,"/*"),this.eatUntil("*/",h,!0),this.assertString(h,"*/")}eatBlock(h){const d=h.index;this.assertString(h,"{");let y=1;for(;y!=0;)this.lookAhead("/*",h)?this.eatComment(h):(h.sheetSrc[h.index]==="{"?y++:h.sheetSrc[h.index]==="}"&&y--,this.advance(h));const S=h.index;return{startIndex:d,endIndex:S,contents:h.sheetSrc.slice(d,S)}}advance(h){if(h.index++,h.index>h.sheetSrc.length)throw this.parseError(h,"Advanced beyond the end")}parseError(h,d){return Error(`(${h.name?h.name:"<anonymous file>"}): ${d}`)}eatUntil(h,d,y=!1){const S=d.index;for(;!this.lookAhead(h,d);)this.advance(d);return y&&(d.sheetSrc=d.sheetSrc.slice(0,S)+" ".repeat(d.index-S)+d.sheetSrc.slice(d.index)),d.sheetSrc.slice(S,d.index)}parseSelector(h){let d=h.index;if(this.eatUntil("{",h),d===h.index)throw Error("Empty selector");return h.sheetSrc.slice(d,h.index)}eatWhitespace(h){ke.WHITE_SPACE.lastIndex=h.index;const d=ke.WHITE_SPACE.exec(h.sheetSrc);d&&(h.index+=d[0].length)}lookAhead(h,d){return d.sheetSrc.substr(d.index,h.length)==h}peek(h){return h.sheetSrc[h.index]}extractMatches(h,d,y=","){return d.exec(h)[1].trim().split(y).map(S=>S.trim())}split(h){return h.split(" ").map(d=>d.trim()).filter(d=>d!="")}};function Rl(h,d,y,S,T,k){const I=ts(d),U=ns(d,y);return Io(as(h,I,U,S,T),k,as("cover",I,U,S,T),y)}function Al(h,d,y){const S=Kt.getAnimationTimelineOptions(d,y);if(!S)return null;const T=S["animation-timeline"];if(!T)return null;let k=Kt.getScrollTimelineOptions(T,y)||Kt.getViewTimelineOptions(T,y);return k?(k.subject&&function(I,U){const N=os(U.subject),L=U.axis||U.axis;function X(K,he){let we=null;for(const[Qe,Tt]of K)if(Qe==100*he.offset){if(Tt=="from")we=0;else if(Tt=="to")we=100;else{const dt=Tt.split(" ");we=dt.length==1?parseFloat(dt[0]):100*Rl(dt[0],N,U.subject,L,U.inset,CSS.percent(parseFloat(dt[1])))}break}return we}const Z=Kt.keyframeNamesSelectors.get(I.animationName);if(Z&&Z.size){const K=[];I.effect.getKeyframes().forEach(we=>{const Qe=X(Z,we);Qe!==null&&Qe>=0&&Qe<=100&&(we.offset=Qe/100,K.push(we))});const he=K.sort((we,Qe)=>we.offset<Qe.offset?-1:we.affset>Qe.offset?1:0);I.effect.setKeyframes(he)}}(h,k),{timeline:k.source?new We(k):new Mn(k),animOptions:S}):null}function Ol(){if(CSS.supports("animation-timeline: --works"))return!0;(function(){function d(S){if(S.innerHTML.trim().length===0||"aphrodite"in S.dataset)return;let T=Kt.transpileStyleSheet(S.innerHTML,!0);T=Kt.transpileStyleSheet(T,!1),S.innerHTML=T}function y(S){S.type!="text/css"&&S.rel!="stylesheet"||!S.href||new URL(S.href,document.baseURI).origin==location.origin&&fetch(S.getAttribute("href")).then(async T=>{const k=await T.text();let I=Kt.transpileStyleSheet(k,!0);if(I=Kt.transpileStyleSheet(k,!1),I!=k){const U=new Blob([I],{type:"text/css"}),N=URL.createObjectURL(U);S.setAttribute("href",N)}})}new MutationObserver(S=>{for(const T of S)for(const k of T.addedNodes)k instanceof HTMLStyleElement&&d(k),k instanceof HTMLLinkElement&&y(k)}).observe(document.documentElement,{childList:!0,subtree:!0}),document.querySelectorAll("style").forEach(S=>d(S)),document.querySelectorAll("link").forEach(S=>y(S))})();const h=CSS.supports;CSS.supports=d=>(d=d.replaceAll(/(animation-timeline|scroll-timeline(-(name|axis))?|view-timeline(-(name|axis|inset))?|timeline-scope)\s*:/g,"--supported-property:"),h(d)),window.addEventListener("animationstart",d=>{d.target.getAnimations().filter(y=>y.animationName===d.animationName).forEach(y=>{const S=Al(y,y.animationName,d.target);if(S)if(!S.timeline||y instanceof ir)y.timeline=S.timeline;else{const T=new ir(y,S.timeline,S.animOptions);y.pause(),T.play()}})})}(function(){if(!Ol()){if(!Reflect.defineProperty(window,"ScrollTimeline",{value:We}))throw Error("Error installing ScrollTimeline polyfill: could not attach ScrollTimeline to window");if(!Reflect.defineProperty(window,"ViewTimeline",{value:Mn}))throw Error("Error installing ViewTimeline polyfill: could not attach ViewTimeline to window");if(!Reflect.defineProperty(Element.prototype,"animate",{value:Cl}))throw Error("Error installing ScrollTimeline polyfill: could not attach WAAPI's animate to DOM Element");if(!Reflect.defineProperty(window,"Animation",{value:ir}))throw Error("Error installing Animation constructor.");if(!Reflect.defineProperty(Element.prototype,"getAnimations",{value:El}))throw Error("Error installing ScrollTimeline polyfill: could not attach WAAPI's getAnimations to DOM Element");if(!Reflect.defineProperty(document,"getAnimations",{value:Pl}))throw Error("Error installing ScrollTimeline polyfill: could not attach WAAPI's getAnimations to document")}})()})();class fd{constructor(e,t){if(this._retries=0,!Number.isInteger(e)||e<0)throw new Error("Base must be a positive integer or zero");if(t!==void 0&&(!Number.isInteger(t)||t<0))throw new Error("ExpMax must be a undefined, a positive integer or zero");this.base=e,this.expMax=t,this.i=0}get retries(){return this._retries}get current(){return this.base*Math.pow(2,this.i)}next(){return this._retries++,this.i=this.expMax===void 0?this.i+1:Math.min(this.i+1,this.expMax),this.current}reset(){this._retries=0,this.i=0}}var se;(function(r){r.open="open",r.close="close",r.error="error",r.message="message",r.retry="retry",r.reconnect="reconnect"})(se||(se={}));class Jc{constructor(e,t,n){var i,s,a,o,c,l,u,p,f,m,b,x,g,v,_;this._closedByUser=!1,this.handleOpenEvent=w=>this.handleEvent(se.open,w),this.handleErrorEvent=w=>this.handleEvent(se.error,w),this.handleCloseEvent=w=>this.handleEvent(se.close,w),this.handleMessageEvent=w=>this.handleEvent(se.message,w),this._url=e,this._protocols=t,this._options={buffer:n?.buffer,retry:{maxRetries:(i=n?.retry)===null||i===void 0?void 0:i.maxRetries,instantReconnect:(s=n?.retry)===null||s===void 0?void 0:s.instantReconnect,backoff:(a=n?.retry)===null||a===void 0?void 0:a.backoff},listeners:{open:[...(c=(o=n?.listeners)===null||o===void 0?void 0:o.open)!==null&&c!==void 0?c:[]],close:[...(u=(l=n?.listeners)===null||l===void 0?void 0:l.close)!==null&&u!==void 0?u:[]],error:[...(f=(p=n?.listeners)===null||p===void 0?void 0:p.error)!==null&&f!==void 0?f:[]],message:[...(b=(m=n?.listeners)===null||m===void 0?void 0:m.message)!==null&&b!==void 0?b:[]],retry:[...(g=(x=n?.listeners)===null||x===void 0?void 0:x.retry)!==null&&g!==void 0?g:[]],reconnect:[...(_=(v=n?.listeners)===null||v===void 0?void 0:v.reconnect)!==null&&_!==void 0?_:[]]}},this._underlyingWebsocket=this.tryConnect()}get url(){return this._url}get protocols(){return this._protocols}get buffer(){return this._options.buffer}get maxRetries(){return this._options.retry.maxRetries}get instantReconnect(){return this._options.retry.instantReconnect}get backoff(){return this._options.retry.backoff}get closedByUser(){return this._closedByUser}get lastConnection(){return this._lastConnection}get underlyingWebsocket(){return this._underlyingWebsocket}get readyState(){return this._underlyingWebsocket.readyState}get bufferedAmount(){return this._underlyingWebsocket.bufferedAmount}get extensions(){return this._underlyingWebsocket.extensions}get binaryType(){return this._underlyingWebsocket.binaryType}set binaryType(e){this._underlyingWebsocket.binaryType=e}send(e){this.closedByUser||(this._underlyingWebsocket.readyState===this._underlyingWebsocket.OPEN?this._underlyingWebsocket.send(e):this.buffer!==void 0&&this.buffer.add(e))}close(e,t){this.cancelScheduledConnectionRetry(),this._closedByUser=!0,this._underlyingWebsocket.close(e,t)}addEventListener(e,t,n){this._options.listeners[e].push({listener:t,options:n})}removeEventListener(e,t,n){const i=s=>s.listener!==t||s.options!==n;this._options.listeners[e]=this._options.listeners[e].filter(i)}tryConnect(){return this._underlyingWebsocket=new WebSocket(this.url,this.protocols),this._underlyingWebsocket.addEventListener(se.open,this.handleOpenEvent),this._underlyingWebsocket.addEventListener(se.close,this.handleCloseEvent),this._underlyingWebsocket.addEventListener(se.error,this.handleErrorEvent),this._underlyingWebsocket.addEventListener(se.message,this.handleMessageEvent),this._underlyingWebsocket}clearWebsocket(){this._underlyingWebsocket.removeEventListener(se.open,this.handleOpenEvent),this._underlyingWebsocket.removeEventListener(se.close,this.handleCloseEvent),this._underlyingWebsocket.removeEventListener(se.error,this.handleErrorEvent),this._underlyingWebsocket.removeEventListener(se.message,this.handleMessageEvent),this._underlyingWebsocket.close()}dispatchEvent(e,t){const n=this._options.listeners[e],i=[];n.forEach(({listener:s,options:a})=>{s(this,t),(a===void 0||a.once===void 0||!a.once)&&i.push({listener:s,options:a})}),this._options.listeners[e]=i}handleEvent(e,t){switch(e){case se.close:this.dispatchEvent(e,t),this.scheduleConnectionRetryIfNeeded();break;case se.open:if(this.backoff!==void 0&&this._lastConnection!==void 0){const n={retries:this.backoff.retries,lastConnection:new Date(this._lastConnection)},i=new CustomEvent(se.reconnect,{detail:n});this.dispatchEvent(se.reconnect,i),this.backoff.reset()}this._lastConnection=new Date,this.dispatchEvent(e,t),this.sendBufferedData();break;case se.retry:this.dispatchEvent(e,t),this.clearWebsocket(),this.tryConnect();break;default:this.dispatchEvent(e,t);break}}sendBufferedData(){if(this.buffer!==void 0)for(let e=this.buffer.read();e!==void 0;e=this.buffer.read())this.send(e)}scheduleConnectionRetryIfNeeded(){if(this.closedByUser||this.backoff===void 0)return;const e=n=>{const i=new CustomEvent(se.retry,{detail:n});this.handleEvent(se.retry,i)},t={backoff:this._options.retry.instantReconnect===!0?0:this.backoff.next(),retries:this._options.retry.instantReconnect===!0?0:this.backoff.retries,lastConnection:this._lastConnection};(this._options.retry.maxRetries===void 0||t.retries<=this._options.retry.maxRetries)&&(this.retryTimeout=globalThis.setTimeout(()=>e(t),t.backoff))}cancelScheduledConnectionRetry(){globalThis.clearTimeout(this.retryTimeout)}}class md{constructor(e){this._url=e}get url(){return this._url}withProtocols(e){return this._protocols=e,this}get protocols(){return this._protocols}withMaxRetries(e){var t;return this._options=Object.assign(Object.assign({},this._options),{retry:Object.assign(Object.assign({},(t=this._options)===null||t===void 0?void 0:t.retry),{maxRetries:e})}),this}get maxRetries(){var e,t;return(t=(e=this._options)===null||e===void 0?void 0:e.retry)===null||t===void 0?void 0:t.maxRetries}withInstantReconnect(e){var t;return this._options=Object.assign(Object.assign({},this._options),{retry:Object.assign(Object.assign({},(t=this._options)===null||t===void 0?void 0:t.retry),{instantReconnect:e})}),this}get instantReconnect(){var e,t;return(t=(e=this._options)===null||e===void 0?void 0:e.retry)===null||t===void 0?void 0:t.instantReconnect}withBackoff(e){var t;return this._options=Object.assign(Object.assign({},this._options),{retry:Object.assign(Object.assign({},(t=this._options)===null||t===void 0?void 0:t.retry),{backoff:e})}),this}get backoff(){var e,t;return(t=(e=this._options)===null||e===void 0?void 0:e.retry)===null||t===void 0?void 0:t.backoff}withBuffer(e){return this._options=Object.assign(Object.assign({},this._options),{buffer:e}),this}get buffer(){var e;return(e=this._options)===null||e===void 0?void 0:e.buffer}onOpen(e,t){return this.addListener(se.open,e,t),this}onClose(e,t){return this.addListener(se.close,e,t),this}onError(e,t){return this.addListener(se.error,e,t),this}onMessage(e,t){return this.addListener(se.message,e,t),this}onRetry(e,t){return this.addListener(se.retry,e,t),this}onReconnect(e,t){return this.addListener(se.reconnect,e,t),this}build(){return new Jc(this._url,this._protocols,this._options)}addListener(e,t,n){var i,s,a,o,c,l,u,p,f,m,b,x,g,v,_,w,C,M,E,P,O;return this._options=Object.assign(Object.assign({},this._options),{listeners:{open:(a=(s=(i=this._options)===null||i===void 0?void 0:i.listeners)===null||s===void 0?void 0:s.open)!==null&&a!==void 0?a:[],close:(l=(c=(o=this._options)===null||o===void 0?void 0:o.listeners)===null||c===void 0?void 0:c.close)!==null&&l!==void 0?l:[],error:(f=(p=(u=this._options)===null||u===void 0?void 0:u.listeners)===null||p===void 0?void 0:p.error)!==null&&f!==void 0?f:[],message:(x=(b=(m=this._options)===null||m===void 0?void 0:m.listeners)===null||b===void 0?void 0:b.message)!==null&&x!==void 0?x:[],retry:(_=(v=(g=this._options)===null||g===void 0?void 0:g.listeners)===null||v===void 0?void 0:v.retry)!==null&&_!==void 0?_:[],reconnect:(M=(C=(w=this._options)===null||w===void 0?void 0:w.listeners)===null||C===void 0?void 0:C.reconnect)!==null&&M!==void 0?M:[],[e]:[...(O=(P=(E=this._options)===null||E===void 0?void 0:E.listeners)===null||P===void 0?void 0:P[e])!==null&&O!==void 0?O:[],{listener:t,options:n}]}}),this}}const yd=Object.freeze(Object.defineProperty({__proto__:null,ExponentialBackoff:fd,Websocket:Jc,WebsocketBuilder:md,get WebsocketEvent(){return se}},Symbol.toStringTag,{value:"Module"})),Zs=0,Gc=1,Wc=2,Ks=2,Qs=1.25,Hc=1,ci=32,Pr=65535,gd=Math.pow(2,-24),$s=Symbol("SKIP_GENERATION");function vd(r){return r.index?r.index.count:r.attributes.position.count}function zn(r){return vd(r)/3}function Sd(r,e=ArrayBuffer){return r>65535?new Uint32Array(new e(4*r)):new Uint16Array(new e(2*r))}function bd(r,e){if(!r.index){const t=r.attributes.position.count,n=e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,i=Sd(t,n);r.setIndex(new ot(i,1));for(let s=0;s<t;s++)i[s]=s}}function qc(r,e){const t=zn(r),n=e||r.drawRange,i=n.start/3,s=(n.start+n.count)/3,a=Math.max(0,i),o=Math.min(t,s)-a;return[{offset:Math.floor(a),count:Math.floor(o)}]}function Xc(r,e){if(!r.groups||!r.groups.length)return qc(r,e);const t=[],n=new Set,i=e||r.drawRange,s=i.start/3,a=(i.start+i.count)/3;for(const c of r.groups){const l=c.start/3,u=(c.start+c.count)/3;n.add(Math.max(s,l)),n.add(Math.min(a,u))}const o=Array.from(n.values()).sort((c,l)=>c-l);for(let c=0;c<o.length-1;c++){const l=o[c],u=o[c+1];t.push({offset:Math.floor(l),count:Math.floor(u-l)})}return t}function xd(r,e){const t=zn(r),n=Xc(r,e).sort((a,o)=>a.offset-o.offset),i=n[n.length-1];i.count=Math.min(t-i.offset,i.count);let s=0;return n.forEach(({count:a})=>s+=a),t!==s}function eo(r,e,t,n,i){let s=1/0,a=1/0,o=1/0,c=-1/0,l=-1/0,u=-1/0,p=1/0,f=1/0,m=1/0,b=-1/0,x=-1/0,g=-1/0;for(let v=e*6,_=(e+t)*6;v<_;v+=6){const w=r[v+0],C=r[v+1],M=w-C,E=w+C;M<s&&(s=M),E>c&&(c=E),w<p&&(p=w),w>b&&(b=w);const P=r[v+2],O=r[v+3],R=P-O,A=P+O;R<a&&(a=R),A>l&&(l=A),P<f&&(f=P),P>x&&(x=P);const B=r[v+4],z=r[v+5],D=B-z,F=B+z;D<o&&(o=D),F>u&&(u=F),B<m&&(m=B),B>g&&(g=B)}n[0]=s,n[1]=a,n[2]=o,n[3]=c,n[4]=l,n[5]=u,i[0]=p,i[1]=f,i[2]=m,i[3]=b,i[4]=x,i[5]=g}function wd(r,e=null,t=null,n=null){const i=r.attributes.position,s=r.index?r.index.array:null,a=zn(r),o=i.normalized;let c;e===null?(c=new Float32Array(a*6),t=0,n=a):(c=e,t=t||0,n=n||a);const l=i.array,u=i.offset||0;let p=3;i.isInterleavedBufferAttribute&&(p=i.data.stride);const f=["getX","getY","getZ"];for(let m=t;m<t+n;m++){const b=m*3,x=m*6;let g=b+0,v=b+1,_=b+2;s&&(g=s[g],v=s[v],_=s[_]),o||(g=g*p+u,v=v*p+u,_=_*p+u);for(let w=0;w<3;w++){let C,M,E;o?(C=i[f[w]](g),M=i[f[w]](v),E=i[f[w]](_)):(C=l[g+w],M=l[v+w],E=l[_+w]);let P=C;M<P&&(P=M),E<P&&(P=E);let O=C;M>O&&(O=M),E>O&&(O=E);const R=(O-P)/2,A=w*2;c[x+A+0]=P+R,c[x+A+1]=R+(Math.abs(P)+R)*gd}}return c}function ve(r,e,t){return t.min.x=e[r],t.min.y=e[r+1],t.min.z=e[r+2],t.max.x=e[r+3],t.max.y=e[r+4],t.max.z=e[r+5],t}function Yc(r){let e=-1,t=-1/0;for(let n=0;n<3;n++){const i=r[n+3]-r[n];i>t&&(t=i,e=n)}return e}function Zc(r,e){e.set(r)}function Kc(r,e,t){let n,i;for(let s=0;s<3;s++){const a=s+3;n=r[s],i=e[s],t[s]=n<i?n:i,n=r[a],i=e[a],t[a]=n>i?n:i}}function kr(r,e,t){for(let n=0;n<3;n++){const i=e[r+2*n],s=e[r+2*n+1],a=i-s,o=i+s;a<t[n]&&(t[n]=a),o>t[n+3]&&(t[n+3]=o)}}function li(r){const e=r[3]-r[0],t=r[4]-r[1],n=r[5]-r[2];return 2*(e*t+t*n+n*e)}const Xt=32,_d=(r,e)=>r.candidate-e.candidate,tn=new Array(Xt).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),Rr=new Float32Array(6);function Td(r,e,t,n,i,s){let a=-1,o=0;if(s===Zs)a=Yc(e),a!==-1&&(o=(e[a]+e[a+3])/2);else if(s===Gc)a=Yc(r),a!==-1&&(o=Md(t,n,i,a));else if(s===Wc){const c=li(r);let l=Qs*i;const u=n*6,p=(n+i)*6;for(let f=0;f<3;f++){const m=e[f],b=(e[f+3]-m)/Xt;if(i<Xt/4){const x=[...tn];x.length=i;let g=0;for(let _=u;_<p;_+=6,g++){const w=x[g];w.candidate=t[_+2*f],w.count=0;const{bounds:C,leftCacheBounds:M,rightCacheBounds:E}=w;for(let P=0;P<3;P++)E[P]=1/0,E[P+3]=-1/0,M[P]=1/0,M[P+3]=-1/0,C[P]=1/0,C[P+3]=-1/0;kr(_,t,C)}x.sort(_d);let v=i;for(let _=0;_<v;_++){const w=x[_];for(;_+1<v&&x[_+1].candidate===w.candidate;)x.splice(_+1,1),v--}for(let _=u;_<p;_+=6){const w=t[_+2*f];for(let C=0;C<v;C++){const M=x[C];w>=M.candidate?kr(_,t,M.rightCacheBounds):(kr(_,t,M.leftCacheBounds),M.count++)}}for(let _=0;_<v;_++){const w=x[_],C=w.count,M=i-w.count,E=w.leftCacheBounds,P=w.rightCacheBounds;let O=0;C!==0&&(O=li(E)/c);let R=0;M!==0&&(R=li(P)/c);const A=Hc+Qs*(O*C+R*M);A<l&&(a=f,l=A,o=w.candidate)}}else{for(let v=0;v<Xt;v++){const _=tn[v];_.count=0,_.candidate=m+b+v*b;const w=_.bounds;for(let C=0;C<3;C++)w[C]=1/0,w[C+3]=-1/0}for(let v=u;v<p;v+=6){let _=~~((t[v+2*f]-m)/b);_>=Xt&&(_=Xt-1);const w=tn[_];w.count++,kr(v,t,w.bounds)}const x=tn[Xt-1];Zc(x.bounds,x.rightCacheBounds);for(let v=Xt-2;v>=0;v--){const _=tn[v],w=tn[v+1];Kc(_.bounds,w.rightCacheBounds,_.rightCacheBounds)}let g=0;for(let v=0;v<Xt-1;v++){const _=tn[v],w=_.count,C=_.bounds,M=tn[v+1].rightCacheBounds;w!==0&&(g===0?Zc(C,Rr):Kc(C,Rr,Rr)),g+=w;let E=0,P=0;g!==0&&(E=li(Rr)/c);const O=i-g;O!==0&&(P=li(M)/c);const R=Hc+Qs*(E*g+P*O);R<l&&(a=f,l=R,o=_.candidate)}}}}else console.warn(`MeshBVH: Invalid build strategy value ${s} used.`);return{axis:a,pos:o}}function Md(r,e,t,n){let i=0;for(let s=e,a=e+t;s<a;s++)i+=r[s*6+n*2];return i/t}class to{constructor(){this.boundingData=new Float32Array(6)}}function Cd(r,e,t,n,i,s){let a=n,o=n+i-1;const c=s.pos,l=s.axis*2;for(;;){for(;a<=o&&t[a*6+l]<c;)a++;for(;a<=o&&t[o*6+l]>=c;)o--;if(a<o){for(let u=0;u<3;u++){let p=e[a*3+u];e[a*3+u]=e[o*3+u],e[o*3+u]=p}for(let u=0;u<6;u++){let p=t[a*6+u];t[a*6+u]=t[o*6+u],t[o*6+u]=p}a++,o--}else return a}}function Ed(r,e,t,n,i,s){let a=n,o=n+i-1;const c=s.pos,l=s.axis*2;for(;;){for(;a<=o&&t[a*6+l]<c;)a++;for(;a<=o&&t[o*6+l]>=c;)o--;if(a<o){let u=r[a];r[a]=r[o],r[o]=u;for(let p=0;p<6;p++){let f=t[a*6+p];t[a*6+p]=t[o*6+p],t[o*6+p]=f}a++,o--}else return a}}function et(r,e){return e[r+15]===65535}function ct(r,e){return e[r+6]}function pt(r,e){return e[r+14]}function ft(r){return r+8}function mt(r,e){return e[r+6]}function Qc(r,e){return e[r+7]}let $c,ui,Ar,el;const Pd=Math.pow(2,32);function no(r){return"count"in r?1:1+no(r.left)+no(r.right)}function kd(r,e,t){return $c=new Float32Array(t),ui=new Uint32Array(t),Ar=new Uint16Array(t),el=new Uint8Array(t),io(r,e)}function io(r,e){const t=r/4,n=r/2,i="count"in e,s=e.boundingData;for(let a=0;a<6;a++)$c[t+a]=s[a];if(i)if(e.buffer){const a=e.buffer;el.set(new Uint8Array(a),r);for(let o=r,c=r+a.byteLength;o<c;o+=ci){const l=o/2;et(l,Ar)||(ui[o/4+6]+=t)}return r+a.byteLength}else{const a=e.offset,o=e.count;return ui[t+6]=a,Ar[n+14]=o,Ar[n+15]=Pr,r+ci}else{const a=e.left,o=e.right,c=e.splitAxis;let l;if(l=io(r+ci,a),l/4>Pd)throw new Error("MeshBVH: Cannot store child pointer greater than 32 bits.");return ui[t+6]=l/4,l=io(l,o),ui[t+7]=c,l}}function Rd(r,e){const t=(r.index?r.index.count:r.attributes.position.count)/3,n=t>2**16,i=n?4:2,s=e?new SharedArrayBuffer(t*i):new ArrayBuffer(t*i),a=n?new Uint32Array(s):new Uint16Array(s);for(let o=0,c=a.length;o<c;o++)a[o]=o;return a}function Ad(r,e,t,n,i){const{maxDepth:s,verbose:a,maxLeafTris:o,strategy:c,onProgress:l,indirect:u}=i,p=r._indirectBuffer,f=r.geometry,m=f.index?f.index.array:null,b=u?Ed:Cd,x=zn(f),g=new Float32Array(6);let v=!1;const _=new to;return eo(e,t,n,_.boundingData,g),C(_,t,n,g),_;function w(M){l&&l(M/x)}function C(M,E,P,O=null,R=0){if(!v&&R>=s&&(v=!0,a&&(console.warn(`MeshBVH: Max depth of ${s} reached when generating BVH. Consider increasing maxDepth.`),console.warn(f))),P<=o||R>=s)return w(E+P),M.offset=E,M.count=P,M;const A=Td(M.boundingData,O,e,E,P,c);if(A.axis===-1)return w(E+P),M.offset=E,M.count=P,M;const B=b(p,m,e,E,P,A);if(B===E||B===E+P)w(E+P),M.offset=E,M.count=P;else{M.splitAxis=A.axis;const z=new to,D=E,F=B-E;M.left=z,eo(e,D,F,z.boundingData,g),C(z,D,F,g,R+1);const H=new to,q=B,$=P-F;M.right=H,eo(e,q,$,H.boundingData,g),C(H,q,$,g,R+1)}return M}}function Od(r,e){const t=r.geometry;e.indirect&&(r._indirectBuffer=Rd(t,e.useSharedArrayBuffer),xd(t,e.range)&&!e.verbose&&console.warn('MeshBVH: Provided geometry contains groups or a range that do not fully span the vertex contents while using the "indirect" option. BVH may incorrectly report intersections on unrendered portions of the geometry.')),r._indirectBuffer||bd(t,e);const n=e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,i=wd(t),s=e.indirect?qc(t,e.range):Xc(t,e.range);r._roots=s.map(a=>{const o=Ad(r,i,a.offset,a.count,e),c=no(o),l=new n(ci*c);return kd(0,o,l),l})}class Yt{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(e,t){let n=1/0,i=-1/0;for(let s=0,a=e.length;s<a;s++){const o=e[s][t];n=o<n?o:n,i=o>i?o:i}this.min=n,this.max=i}setFromPoints(e,t){let n=1/0,i=-1/0;for(let s=0,a=t.length;s<a;s++){const o=t[s],c=e.dot(o);n=c<n?c:n,i=c>i?c:i}this.min=n,this.max=i}isSeparated(e){return this.min>e.max||e.min>this.max}}Yt.prototype.setFromBox=function(){const r=new W;return function(e,t){const n=t.min,i=t.max;let s=1/0,a=-1/0;for(let o=0;o<=1;o++)for(let c=0;c<=1;c++)for(let l=0;l<=1;l++){r.x=n.x*o+i.x*(1-o),r.y=n.y*c+i.y*(1-c),r.z=n.z*l+i.z*(1-l);const u=e.dot(r);s=Math.min(u,s),a=Math.max(u,a)}this.min=s,this.max=a}}();const Id=function(){const r=new W,e=new W,t=new W;return function(n,i,s){const a=n.start,o=r,c=i.start,l=e;t.subVectors(a,c),r.subVectors(n.end,n.start),e.subVectors(i.end,i.start);const u=t.dot(l),p=l.dot(o),f=l.dot(l),m=t.dot(o),b=o.dot(o)*f-p*p;let x,g;b!==0?x=(u*p-m*f)/b:x=0,g=(u+x*p)/f,s.x=x,s.y=g}}(),ro=function(){const r=new kn,e=new W,t=new W;return function(n,i,s,a){Id(n,i,r);let o=r.x,c=r.y;if(o>=0&&o<=1&&c>=0&&c<=1){n.at(o,s),i.at(c,a);return}else if(o>=0&&o<=1){c<0?i.at(0,a):i.at(1,a),n.closestPointToPoint(a,!0,s);return}else if(c>=0&&c<=1){o<0?n.at(0,s):n.at(1,s),i.closestPointToPoint(s,!0,a);return}else{let l;o<0?l=n.start:l=n.end;let u;c<0?u=i.start:u=i.end;const p=e,f=t;if(n.closestPointToPoint(u,!0,e),i.closestPointToPoint(l,!0,t),p.distanceToSquared(u)<=f.distanceToSquared(l)){s.copy(p),a.copy(u);return}else{s.copy(l),a.copy(f);return}}}}(),zd=function(){const r=new W,e=new W,t=new Qo,n=new Gt;return function(i,s){const{radius:a,center:o}=i,{a:c,b:l,c:u}=s;if(n.start=c,n.end=l,n.closestPointToPoint(o,!0,r).distanceTo(o)<=a||(n.start=c,n.end=u,n.closestPointToPoint(o,!0,r).distanceTo(o)<=a)||(n.start=l,n.end=u,n.closestPointToPoint(o,!0,r).distanceTo(o)<=a))return!0;const p=s.getPlane(t);if(Math.abs(p.distanceToPoint(o))<=a){const f=p.projectPoint(o,e);if(s.containsPoint(f))return!0}return!1}}(),Bd=1e-15;function so(r){return Math.abs(r)<Bd}class yt extends un{constructor(...e){super(...e),this.isExtendedTriangle=!0,this.satAxes=new Array(4).fill().map(()=>new W),this.satBounds=new Array(4).fill().map(()=>new Yt),this.points=[this.a,this.b,this.c],this.sphere=new $o,this.plane=new Qo,this.needsUpdate=!0}intersectsSphere(e){return zd(e,this)}update(){const e=this.a,t=this.b,n=this.c,i=this.points,s=this.satAxes,a=this.satBounds,o=s[0],c=a[0];this.getNormal(o),c.setFromPoints(o,i);const l=s[1],u=a[1];l.subVectors(e,t),u.setFromPoints(l,i);const p=s[2],f=a[2];p.subVectors(t,n),f.setFromPoints(p,i);const m=s[3],b=a[3];m.subVectors(n,e),b.setFromPoints(m,i),this.sphere.setFromPoints(this.points),this.plane.setFromNormalAndCoplanarPoint(o,e),this.needsUpdate=!1}}yt.prototype.closestPointToSegment=function(){const r=new W,e=new W,t=new Gt;return function(n,i=null,s=null){const{start:a,end:o}=n,c=this.points;let l,u=1/0;for(let p=0;p<3;p++){const f=(p+1)%3;t.start.copy(c[p]),t.end.copy(c[f]),ro(t,n,r,e),l=r.distanceToSquared(e),l<u&&(u=l,i&&i.copy(r),s&&s.copy(e))}return this.closestPointToPoint(a,r),l=a.distanceToSquared(r),l<u&&(u=l,i&&i.copy(r),s&&s.copy(a)),this.closestPointToPoint(o,r),l=o.distanceToSquared(r),l<u&&(u=l,i&&i.copy(r),s&&s.copy(o)),Math.sqrt(u)}}(),yt.prototype.intersectsTriangle=function(){const r=new yt,e=new Array(3),t=new Array(3),n=new Yt,i=new Yt,s=new W,a=new W,o=new W,c=new W,l=new W,u=new Gt,p=new Gt,f=new Gt,m=new W;function b(x,g,v){const _=x.points;let w=0,C=-1;for(let M=0;M<3;M++){const{start:E,end:P}=u;E.copy(_[M]),P.copy(_[(M+1)%3]),u.delta(a);const O=so(g.distanceToPoint(E));if(so(g.normal.dot(a))&&O){v.copy(u),w=2;break}const R=g.intersectLine(u,m);if(!R&&O&&m.copy(E),(R||O)&&!so(m.distanceTo(P))){if(w<=1)(w===1?v.start:v.end).copy(m),O&&(C=w);else if(w>=2){(C===1?v.start:v.end).copy(m),w=2;break}if(w++,w===2&&C===-1)break}}return w}return function(x,g=null,v=!1){this.needsUpdate&&this.update(),x.isExtendedTriangle?x.needsUpdate&&x.update():(r.copy(x),r.update(),x=r);const _=this.plane,w=x.plane;if(Math.abs(_.normal.dot(w.normal))>1-1e-10){const C=this.satBounds,M=this.satAxes;t[0]=x.a,t[1]=x.b,t[2]=x.c;for(let O=0;O<4;O++){const R=C[O],A=M[O];if(n.setFromPoints(A,t),R.isSeparated(n))return!1}const E=x.satBounds,P=x.satAxes;e[0]=this.a,e[1]=this.b,e[2]=this.c;for(let O=0;O<4;O++){const R=E[O],A=P[O];if(n.setFromPoints(A,e),R.isSeparated(n))return!1}for(let O=0;O<4;O++){const R=M[O];for(let A=0;A<4;A++){const B=P[A];if(s.crossVectors(R,B),n.setFromPoints(s,e),i.setFromPoints(s,t),n.isSeparated(i))return!1}}return g&&(v||console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."),g.start.set(0,0,0),g.end.set(0,0,0)),!0}else{const C=b(this,w,p);if(C===1&&x.containsPoint(p.end))return g&&(g.start.copy(p.end),g.end.copy(p.end)),!0;if(C!==2)return!1;const M=b(x,_,f);if(M===1&&this.containsPoint(f.end))return g&&(g.start.copy(f.end),g.end.copy(f.end)),!0;if(M!==2)return!1;if(p.delta(o),f.delta(c),o.dot(c)<0){let z=f.start;f.start=f.end,f.end=z}const E=p.start.dot(o),P=p.end.dot(o),O=f.start.dot(o),R=f.end.dot(o),A=P<O,B=E<R;return E!==R&&O!==P&&A===B?!1:(g&&(l.subVectors(p.start,f.start),l.dot(o)>0?g.start.copy(p.start):g.start.copy(f.start),l.subVectors(p.end,f.end),l.dot(o)<0?g.end.copy(p.end):g.end.copy(f.end)),!0)}}}(),yt.prototype.distanceToPoint=function(){const r=new W;return function(e){return this.closestPointToPoint(e,r),e.distanceTo(r)}}(),yt.prototype.distanceToTriangle=function(){const r=new W,e=new W,t=["a","b","c"],n=new Gt,i=new Gt;return function(s,a=null,o=null){const c=a||o?n:null;if(this.intersectsTriangle(s,c))return(a||o)&&(a&&c.getCenter(a),o&&c.getCenter(o)),0;let l=1/0;for(let u=0;u<3;u++){let p;const f=t[u],m=s[f];this.closestPointToPoint(m,r),p=m.distanceToSquared(r),p<l&&(l=p,a&&a.copy(r),o&&o.copy(m));const b=this[f];s.closestPointToPoint(b,r),p=b.distanceToSquared(r),p<l&&(l=p,a&&a.copy(b),o&&o.copy(r))}for(let u=0;u<3;u++){const p=t[u],f=t[(u+1)%3];n.set(this[p],this[f]);for(let m=0;m<3;m++){const b=t[m],x=t[(m+1)%3];i.set(s[b],s[x]),ro(n,i,r,e);const g=r.distanceToSquared(e);g<l&&(l=g,a&&a.copy(r),o&&o.copy(e))}}return Math.sqrt(l)}}();class Ve{constructor(e,t,n){this.isOrientedBox=!0,this.min=new W,this.max=new W,this.matrix=new Ct,this.invMatrix=new Ct,this.points=new Array(8).fill().map(()=>new W),this.satAxes=new Array(3).fill().map(()=>new W),this.satBounds=new Array(3).fill().map(()=>new Yt),this.alignedSatBounds=new Array(3).fill().map(()=>new Yt),this.needsUpdate=!1,e&&this.min.copy(e),t&&this.max.copy(t),n&&this.matrix.copy(n)}set(e,t,n){this.min.copy(e),this.max.copy(t),this.matrix.copy(n),this.needsUpdate=!0}copy(e){this.min.copy(e.min),this.max.copy(e.max),this.matrix.copy(e.matrix),this.needsUpdate=!0}}Ve.prototype.update=function(){return function(){const r=this.matrix,e=this.min,t=this.max,n=this.points;for(let c=0;c<=1;c++)for(let l=0;l<=1;l++)for(let u=0;u<=1;u++){const p=1*c|2*l|4*u,f=n[p];f.x=c?t.x:e.x,f.y=l?t.y:e.y,f.z=u?t.z:e.z,f.applyMatrix4(r)}const i=this.satBounds,s=this.satAxes,a=n[0];for(let c=0;c<3;c++){const l=s[c],u=i[c],p=1<<c,f=n[p];l.subVectors(a,f),u.setFromPoints(l,n)}const o=this.alignedSatBounds;o[0].setFromPointsField(n,"x"),o[1].setFromPointsField(n,"y"),o[2].setFromPointsField(n,"z"),this.invMatrix.copy(this.matrix).invert(),this.needsUpdate=!1}}(),Ve.prototype.intersectsBox=function(){const r=new Yt;return function(e){this.needsUpdate&&this.update();const t=e.min,n=e.max,i=this.satBounds,s=this.satAxes,a=this.alignedSatBounds;if(r.min=t.x,r.max=n.x,a[0].isSeparated(r)||(r.min=t.y,r.max=n.y,a[1].isSeparated(r))||(r.min=t.z,r.max=n.z,a[2].isSeparated(r)))return!1;for(let o=0;o<3;o++){const c=s[o],l=i[o];if(r.setFromBox(c,e),l.isSeparated(r))return!1}return!0}}(),Ve.prototype.intersectsTriangle=function(){const r=new yt,e=new Array(3),t=new Yt,n=new Yt,i=new W;return function(s){this.needsUpdate&&this.update(),s.isExtendedTriangle?s.needsUpdate&&s.update():(r.copy(s),r.update(),s=r);const a=this.satBounds,o=this.satAxes;e[0]=s.a,e[1]=s.b,e[2]=s.c;for(let p=0;p<3;p++){const f=a[p],m=o[p];if(t.setFromPoints(m,e),f.isSeparated(t))return!1}const c=s.satBounds,l=s.satAxes,u=this.points;for(let p=0;p<3;p++){const f=c[p],m=l[p];if(t.setFromPoints(m,u),f.isSeparated(t))return!1}for(let p=0;p<3;p++){const f=o[p];for(let m=0;m<4;m++){const b=l[m];if(i.crossVectors(f,b),t.setFromPoints(i,e),n.setFromPoints(i,u),t.isSeparated(n))return!1}}return!0}}(),Ve.prototype.closestPointToPoint=function(){return function(r,e){return this.needsUpdate&&this.update(),e.copy(r).applyMatrix4(this.invMatrix).clamp(this.min,this.max).applyMatrix4(this.matrix),e}}(),Ve.prototype.distanceToPoint=function(){const r=new W;return function(e){return this.closestPointToPoint(e,r),e.distanceTo(r)}}(),Ve.prototype.distanceToBox=function(){const r=["x","y","z"],e=new Array(12).fill().map(()=>new Gt),t=new Array(12).fill().map(()=>new Gt),n=new W,i=new W;return function(s,a=0,o=null,c=null){if(this.needsUpdate&&this.update(),this.intersectsBox(s))return(o||c)&&(s.getCenter(i),this.closestPointToPoint(i,n),s.closestPointToPoint(n,i),o&&o.copy(n),c&&c.copy(i)),0;const l=a*a,u=s.min,p=s.max,f=this.points;let m=1/0;for(let x=0;x<8;x++){const g=f[x];i.copy(g).clamp(u,p);const v=g.distanceToSquared(i);if(v<m&&(m=v,o&&o.copy(g),c&&c.copy(i),v<l))return Math.sqrt(v)}let b=0;for(let x=0;x<3;x++)for(let g=0;g<=1;g++)for(let v=0;v<=1;v++){const _=(x+1)%3,w=(x+2)%3,C=g<<_|v<<w,M=1<<x|g<<_|v<<w,E=f[C],P=f[M];e[b].set(E,P);const O=r[x],R=r[_],A=r[w],B=t[b],z=B.start,D=B.end;z[O]=u[O],z[R]=g?u[R]:p[R],z[A]=v?u[A]:p[R],D[O]=p[O],D[R]=g?u[R]:p[R],D[A]=v?u[A]:p[R],b++}for(let x=0;x<=1;x++)for(let g=0;g<=1;g++)for(let v=0;v<=1;v++){i.x=x?p.x:u.x,i.y=g?p.y:u.y,i.z=v?p.z:u.z,this.closestPointToPoint(i,n);const _=i.distanceToSquared(n);if(_<m&&(m=_,o&&o.copy(n),c&&c.copy(i),_<l))return Math.sqrt(_)}for(let x=0;x<12;x++){const g=e[x];for(let v=0;v<12;v++){const _=t[v];ro(g,_,n,i);const w=n.distanceToSquared(i);if(w<m&&(m=w,o&&o.copy(n),c&&c.copy(i),w<l))return Math.sqrt(w)}}return Math.sqrt(m)}}();class oo{constructor(e){this._getNewPrimitive=e,this._primitives=[]}getPrimitive(){const e=this._primitives;return e.length===0?this._getNewPrimitive():e.pop()}releasePrimitive(e){this._primitives.push(e)}}class Nd extends oo{constructor(){super(()=>new yt)}}const gt=new Nd;class Ud{constructor(){this.float32Array=null,this.uint16Array=null,this.uint32Array=null;const e=[];let t=null;this.setBuffer=n=>{t&&e.push(t),t=n,this.float32Array=new Float32Array(n),this.uint16Array=new Uint16Array(n),this.uint32Array=new Uint32Array(n)},this.clearBuffer=()=>{t=null,this.float32Array=null,this.uint16Array=null,this.uint32Array=null,e.length!==0&&this.setBuffer(e.pop())}}}const de=new Ud;let nn,Bn;const Nn=[],Or=new oo(()=>new Ot);function Dd(r,e,t,n,i,s){nn=Or.getPrimitive(),Bn=Or.getPrimitive(),Nn.push(nn,Bn),de.setBuffer(r._roots[e]);const a=ao(0,r.geometry,t,n,i,s);de.clearBuffer(),Or.releasePrimitive(nn),Or.releasePrimitive(Bn),Nn.pop(),Nn.pop();const o=Nn.length;return o>0&&(Bn=Nn[o-1],nn=Nn[o-2]),a}function ao(r,e,t,n,i=null,s=0,a=0){const{float32Array:o,uint16Array:c,uint32Array:l}=de;let u=r*2;if(et(u,c)){const p=ct(r,l),f=pt(u,c);return ve(r,o,nn),n(p,f,!1,a,s+r,nn)}else{let p=function(B){const{uint16Array:z,uint32Array:D}=de;let F=B*2;for(;!et(F,z);)B=ft(B),F=B*2;return ct(B,D)},f=function(B){const{uint16Array:z,uint32Array:D}=de;let F=B*2;for(;!et(F,z);)B=mt(B,D),F=B*2;return ct(B,D)+pt(F,z)};const m=ft(r),b=mt(r,l);let x=m,g=b,v,_,w,C;if(i&&(w=nn,C=Bn,ve(x,o,w),ve(g,o,C),v=i(w),_=i(C),_<v)){x=b,g=m;const B=v;v=_,_=B,w=C}w||(w=nn,ve(x,o,w));const M=et(x*2,c),E=t(w,M,v,a+1,s+x);let P;if(E===Ks){const B=p(x),z=f(x)-B;P=n(B,z,!0,a+1,s+x,w)}else P=E&&ao(x,e,t,n,i,s,a+1);if(P)return!0;C=Bn,ve(g,o,C);const O=et(g*2,c),R=t(C,O,_,a+1,s+g);let A;if(R===Ks){const B=p(g),z=f(g)-B;A=n(B,z,!0,a+1,s+g,C)}else A=R&&ao(g,e,t,n,i,s,a+1);return!!A}}const hi=new W,co=new W;function Ld(r,e,t={},n=0,i=1/0){const s=n*n,a=i*i;let o=1/0,c=null;if(r.shapecast({boundsTraverseOrder:u=>(hi.copy(e).clamp(u.min,u.max),hi.distanceToSquared(e)),intersectsBounds:(u,p,f)=>f<o&&f<a,intersectsTriangle:(u,p)=>{u.closestPointToPoint(e,hi);const f=e.distanceToSquared(hi);return f<o&&(co.copy(hi),o=f,c=p),f<s}}),o===1/0)return null;const l=Math.sqrt(o);return t.point?t.point.copy(co):t.point=co.clone(),t.distance=l,t.faceIndex=c,t}const Fd=parseInt(Vl)>=169,pn=new W,fn=new W,mn=new W,Ir=new kn,zr=new kn,Br=new kn,tl=new W,nl=new W,il=new W,di=new W;function Vd(r,e,t,n,i,s,a,o){let c;if(s===Fl?c=r.intersectTriangle(n,t,e,!0,i):c=r.intersectTriangle(e,t,n,s!==ds,i),c===null)return null;const l=r.origin.distanceTo(i);return l<a||l>o?null:{distance:l,point:i.clone()}}function jd(r,e,t,n,i,s,a,o,c,l,u){pn.fromBufferAttribute(e,s),fn.fromBufferAttribute(e,a),mn.fromBufferAttribute(e,o);const p=Vd(r,pn,fn,mn,di,c,l,u);if(p){const f=new W;un.getBarycoord(di,pn,fn,mn,f),n&&(Ir.fromBufferAttribute(n,s),zr.fromBufferAttribute(n,a),Br.fromBufferAttribute(n,o),p.uv=un.getInterpolation(di,pn,fn,mn,Ir,zr,Br,new kn)),i&&(Ir.fromBufferAttribute(i,s),zr.fromBufferAttribute(i,a),Br.fromBufferAttribute(i,o),p.uv1=un.getInterpolation(di,pn,fn,mn,Ir,zr,Br,new kn)),t&&(tl.fromBufferAttribute(t,s),nl.fromBufferAttribute(t,a),il.fromBufferAttribute(t,o),p.normal=un.getInterpolation(di,pn,fn,mn,tl,nl,il,new W),p.normal.dot(r.direction)>0&&p.normal.multiplyScalar(-1));const m={a:s,b:a,c:o,normal:new W,materialIndex:0};un.getNormal(pn,fn,mn,m.normal),p.face=m,p.faceIndex=s,Fd&&(p.barycoord=f)}return p}function Nr(r,e,t,n,i,s,a){const o=n*3;let c=o+0,l=o+1,u=o+2;const p=r.index;r.index&&(c=p.getX(c),l=p.getX(l),u=p.getX(u));const{position:f,normal:m,uv:b,uv1:x}=r.attributes,g=jd(t,f,m,b,x,c,l,u,e,s,a);return g?(g.faceIndex=n,i&&i.push(g),g):null}function Me(r,e,t,n){const i=r.a,s=r.b,a=r.c;let o=e,c=e+1,l=e+2;t&&(o=t.getX(o),c=t.getX(c),l=t.getX(l)),i.x=n.getX(o),i.y=n.getY(o),i.z=n.getZ(o),s.x=n.getX(c),s.y=n.getY(c),s.z=n.getZ(c),a.x=n.getX(l),a.y=n.getY(l),a.z=n.getZ(l)}function Jd(r,e,t,n,i,s,a,o){const{geometry:c,_indirectBuffer:l}=r;for(let u=n,p=n+i;u<p;u++)Nr(c,e,t,u,s,a,o)}function Gd(r,e,t,n,i,s,a){const{geometry:o,_indirectBuffer:c}=r;let l=1/0,u=null;for(let p=n,f=n+i;p<f;p++){let m;m=Nr(o,e,t,p,null,s,a),m&&m.distance<l&&(u=m,l=m.distance)}return u}function Wd(r,e,t,n,i,s,a){const{geometry:o}=t,{index:c}=o,l=o.attributes.position;for(let u=r,p=e+r;u<p;u++){let f;if(f=u,Me(a,f*3,c,l),a.needsUpdate=!0,n(a,f,i,s))return!0}return!1}function Hd(r,e=null){e&&Array.isArray(e)&&(e=new Set(e));const t=r.geometry,n=t.index?t.index.array:null,i=t.attributes.position;let s,a,o,c,l=0;const u=r._roots;for(let f=0,m=u.length;f<m;f++)s=u[f],a=new Uint32Array(s),o=new Uint16Array(s),c=new Float32Array(s),p(0,l),l+=s.byteLength;function p(f,m,b=!1){const x=f*2;if(o[x+15]===Pr){const g=a[f+6],v=o[x+14];let _=1/0,w=1/0,C=1/0,M=-1/0,E=-1/0,P=-1/0;for(let O=3*g,R=3*(g+v);O<R;O++){let A=n[O];const B=i.getX(A),z=i.getY(A),D=i.getZ(A);B<_&&(_=B),B>M&&(M=B),z<w&&(w=z),z>E&&(E=z),D<C&&(C=D),D>P&&(P=D)}return c[f+0]!==_||c[f+1]!==w||c[f+2]!==C||c[f+3]!==M||c[f+4]!==E||c[f+5]!==P?(c[f+0]=_,c[f+1]=w,c[f+2]=C,c[f+3]=M,c[f+4]=E,c[f+5]=P,!0):!1}else{const g=f+8,v=a[f+6],_=g+m,w=v+m;let C=b,M=!1,E=!1;e?C||(M=e.has(_),E=e.has(w),C=!M&&!E):(M=!0,E=!0);const P=C||M,O=C||E;let R=!1;P&&(R=p(g,m,C));let A=!1;O&&(A=p(v,m,C));const B=R||A;if(B)for(let z=0;z<3;z++){const D=g+z,F=v+z,H=c[D],q=c[D+3],$=c[F],J=c[F+3];c[f+z]=H<$?H:$,c[f+z+3]=q>J?q:J}return B}}}function rn(r,e,t,n,i){let s,a,o,c,l,u;const p=1/t.direction.x,f=1/t.direction.y,m=1/t.direction.z,b=t.origin.x,x=t.origin.y,g=t.origin.z;let v=e[r],_=e[r+3],w=e[r+1],C=e[r+3+1],M=e[r+2],E=e[r+3+2];return p>=0?(s=(v-b)*p,a=(_-b)*p):(s=(_-b)*p,a=(v-b)*p),f>=0?(o=(w-x)*f,c=(C-x)*f):(o=(C-x)*f,c=(w-x)*f),s>c||o>a||((o>s||isNaN(s))&&(s=o),(c<a||isNaN(a))&&(a=c),m>=0?(l=(M-g)*m,u=(E-g)*m):(l=(E-g)*m,u=(M-g)*m),s>u||l>a)?!1:((l>s||s!==s)&&(s=l),(u<a||a!==a)&&(a=u),s<=i&&a>=n)}function qd(r,e,t,n,i,s,a,o){const{geometry:c,_indirectBuffer:l}=r;for(let u=n,p=n+i;u<p;u++){let f=l?l[u]:u;Nr(c,e,t,f,s,a,o)}}function Xd(r,e,t,n,i,s,a){const{geometry:o,_indirectBuffer:c}=r;let l=1/0,u=null;for(let p=n,f=n+i;p<f;p++){let m;m=Nr(o,e,t,c?c[p]:p,null,s,a),m&&m.distance<l&&(u=m,l=m.distance)}return u}function Yd(r,e,t,n,i,s,a){const{geometry:o}=t,{index:c}=o,l=o.attributes.position;for(let u=r,p=e+r;u<p;u++){let f;if(f=t.resolveTriangleIndex(u),Me(a,f*3,c,l),a.needsUpdate=!0,n(a,f,i,s))return!0}return!1}function Zd(r,e,t,n,i,s,a){de.setBuffer(r._roots[e]),lo(0,r,t,n,i,s,a),de.clearBuffer()}function lo(r,e,t,n,i,s,a){const{float32Array:o,uint16Array:c,uint32Array:l}=de,u=r*2;if(et(u,c)){const p=ct(r,l),f=pt(u,c);Jd(e,t,n,p,f,i,s,a)}else{const p=ft(r);rn(p,o,n,s,a)&&lo(p,e,t,n,i,s,a);const f=mt(r,l);rn(f,o,n,s,a)&&lo(f,e,t,n,i,s,a)}}const Kd=["x","y","z"];function Qd(r,e,t,n,i,s){de.setBuffer(r._roots[e]);const a=uo(0,r,t,n,i,s);return de.clearBuffer(),a}function uo(r,e,t,n,i,s){const{float32Array:a,uint16Array:o,uint32Array:c}=de;let l=r*2;if(et(l,o)){const u=ct(r,c),p=pt(l,o);return Gd(e,t,n,u,p,i,s)}else{const u=Qc(r,c),p=Kd[u],f=n.direction[p]>=0;let m,b;f?(m=ft(r),b=mt(r,c)):(m=mt(r,c),b=ft(r));const x=rn(m,a,n,i,s)?uo(m,e,t,n,i,s):null;if(x){const v=x.point[p];if(f?v<=a[b+u]:v>=a[b+u+3])return x}const g=rn(b,a,n,i,s)?uo(b,e,t,n,i,s):null;return x&&g?x.distance<=g.distance?x:g:x||g||null}}const Ur=new Ot,Un=new yt,Dn=new yt,pi=new Ct,rl=new Ve,Dr=new Ve;function $d(r,e,t,n){de.setBuffer(r._roots[e]);const i=ho(0,r,t,n);return de.clearBuffer(),i}function ho(r,e,t,n,i=null){const{float32Array:s,uint16Array:a,uint32Array:o}=de;let c=r*2;if(i===null&&(t.boundingBox||t.computeBoundingBox(),rl.set(t.boundingBox.min,t.boundingBox.max,n),i=rl),et(c,a)){const l=e.geometry,u=l.index,p=l.attributes.position,f=t.index,m=t.attributes.position,b=ct(r,o),x=pt(c,a);if(pi.copy(n).invert(),t.boundsTree)return ve(r,s,Dr),Dr.matrix.copy(pi),Dr.needsUpdate=!0,t.boundsTree.shapecast({intersectsBounds:g=>Dr.intersectsBox(g),intersectsTriangle:g=>{g.a.applyMatrix4(n),g.b.applyMatrix4(n),g.c.applyMatrix4(n),g.needsUpdate=!0;for(let v=b*3,_=(x+b)*3;v<_;v+=3)if(Me(Dn,v,u,p),Dn.needsUpdate=!0,g.intersectsTriangle(Dn))return!0;return!1}});for(let g=b*3,v=(x+b)*3;g<v;g+=3){Me(Un,g,u,p),Un.a.applyMatrix4(pi),Un.b.applyMatrix4(pi),Un.c.applyMatrix4(pi),Un.needsUpdate=!0;for(let _=0,w=f.count;_<w;_+=3)if(Me(Dn,_,f,m),Dn.needsUpdate=!0,Un.intersectsTriangle(Dn))return!0}}else{const l=r+8,u=o[r+6];return ve(l,s,Ur),!!(i.intersectsBox(Ur)&&ho(l,e,t,n,i)||(ve(u,s,Ur),i.intersectsBox(Ur)&&ho(u,e,t,n,i)))}}const Lr=new Ct,po=new Ve,fi=new Ve,ep=new W,tp=new W,np=new W,ip=new W;function rp(r,e,t,n={},i={},s=0,a=1/0){e.boundingBox||e.computeBoundingBox(),po.set(e.boundingBox.min,e.boundingBox.max,t),po.needsUpdate=!0;const o=r.geometry,c=o.attributes.position,l=o.index,u=e.attributes.position,p=e.index,f=gt.getPrimitive(),m=gt.getPrimitive();let b=ep,x=tp,g=null,v=null;i&&(g=np,v=ip);let _=1/0,w=null,C=null;return Lr.copy(t).invert(),fi.matrix.copy(Lr),r.shapecast({boundsTraverseOrder:M=>po.distanceToBox(M),intersectsBounds:(M,E,P)=>P<_&&P<a?(E&&(fi.min.copy(M.min),fi.max.copy(M.max),fi.needsUpdate=!0),!0):!1,intersectsRange:(M,E)=>{if(e.boundsTree)return e.boundsTree.shapecast({boundsTraverseOrder:P=>fi.distanceToBox(P),intersectsBounds:(P,O,R)=>R<_&&R<a,intersectsRange:(P,O)=>{for(let R=P,A=P+O;R<A;R++){Me(m,3*R,p,u),m.a.applyMatrix4(t),m.b.applyMatrix4(t),m.c.applyMatrix4(t),m.needsUpdate=!0;for(let B=M,z=M+E;B<z;B++){Me(f,3*B,l,c),f.needsUpdate=!0;const D=f.distanceToTriangle(m,b,g);if(D<_&&(x.copy(b),v&&v.copy(g),_=D,w=B,C=R),D<s)return!0}}}});{const P=zn(e);for(let O=0,R=P;O<R;O++){Me(m,3*O,p,u),m.a.applyMatrix4(t),m.b.applyMatrix4(t),m.c.applyMatrix4(t),m.needsUpdate=!0;for(let A=M,B=M+E;A<B;A++){Me(f,3*A,l,c),f.needsUpdate=!0;const z=f.distanceToTriangle(m,b,g);if(z<_&&(x.copy(b),v&&v.copy(g),_=z,w=A,C=O),z<s)return!0}}}}}),gt.releasePrimitive(f),gt.releasePrimitive(m),_===1/0?null:(n.point?n.point.copy(x):n.point=x.clone(),n.distance=_,n.faceIndex=w,i&&(i.point?i.point.copy(v):i.point=v.clone(),i.point.applyMatrix4(Lr),x.applyMatrix4(Lr),i.distance=x.sub(i.point).length(),i.faceIndex=C),n)}function sp(r,e=null){e&&Array.isArray(e)&&(e=new Set(e));const t=r.geometry,n=t.index?t.index.array:null,i=t.attributes.position;let s,a,o,c,l=0;const u=r._roots;for(let f=0,m=u.length;f<m;f++)s=u[f],a=new Uint32Array(s),o=new Uint16Array(s),c=new Float32Array(s),p(0,l),l+=s.byteLength;function p(f,m,b=!1){const x=f*2;if(o[x+15]===Pr){const g=a[f+6],v=o[x+14];let _=1/0,w=1/0,C=1/0,M=-1/0,E=-1/0,P=-1/0;for(let O=g,R=g+v;O<R;O++){const A=3*r.resolveTriangleIndex(O);for(let B=0;B<3;B++){let z=A+B;z=n?n[z]:z;const D=i.getX(z),F=i.getY(z),H=i.getZ(z);D<_&&(_=D),D>M&&(M=D),F<w&&(w=F),F>E&&(E=F),H<C&&(C=H),H>P&&(P=H)}}return c[f+0]!==_||c[f+1]!==w||c[f+2]!==C||c[f+3]!==M||c[f+4]!==E||c[f+5]!==P?(c[f+0]=_,c[f+1]=w,c[f+2]=C,c[f+3]=M,c[f+4]=E,c[f+5]=P,!0):!1}else{const g=f+8,v=a[f+6],_=g+m,w=v+m;let C=b,M=!1,E=!1;e?C||(M=e.has(_),E=e.has(w),C=!M&&!E):(M=!0,E=!0);const P=C||M,O=C||E;let R=!1;P&&(R=p(g,m,C));let A=!1;O&&(A=p(v,m,C));const B=R||A;if(B)for(let z=0;z<3;z++){const D=g+z,F=v+z,H=c[D],q=c[D+3],$=c[F],J=c[F+3];c[f+z]=H<$?H:$,c[f+z+3]=q>J?q:J}return B}}}function op(r,e,t,n,i,s,a){de.setBuffer(r._roots[e]),fo(0,r,t,n,i,s,a),de.clearBuffer()}function fo(r,e,t,n,i,s,a){const{float32Array:o,uint16Array:c,uint32Array:l}=de,u=r*2;if(et(u,c)){const p=ct(r,l),f=pt(u,c);qd(e,t,n,p,f,i,s,a)}else{const p=ft(r);rn(p,o,n,s,a)&&fo(p,e,t,n,i,s,a);const f=mt(r,l);rn(f,o,n,s,a)&&fo(f,e,t,n,i,s,a)}}const ap=["x","y","z"];function cp(r,e,t,n,i,s){de.setBuffer(r._roots[e]);const a=mo(0,r,t,n,i,s);return de.clearBuffer(),a}function mo(r,e,t,n,i,s){const{float32Array:a,uint16Array:o,uint32Array:c}=de;let l=r*2;if(et(l,o)){const u=ct(r,c),p=pt(l,o);return Xd(e,t,n,u,p,i,s)}else{const u=Qc(r,c),p=ap[u],f=n.direction[p]>=0;let m,b;f?(m=ft(r),b=mt(r,c)):(m=mt(r,c),b=ft(r));const x=rn(m,a,n,i,s)?mo(m,e,t,n,i,s):null;if(x){const v=x.point[p];if(f?v<=a[b+u]:v>=a[b+u+3])return x}const g=rn(b,a,n,i,s)?mo(b,e,t,n,i,s):null;return x&&g?x.distance<=g.distance?x:g:x||g||null}}const Fr=new Ot,Ln=new yt,Fn=new yt,mi=new Ct,sl=new Ve,Vr=new Ve;function lp(r,e,t,n){de.setBuffer(r._roots[e]);const i=yo(0,r,t,n);return de.clearBuffer(),i}function yo(r,e,t,n,i=null){const{float32Array:s,uint16Array:a,uint32Array:o}=de;let c=r*2;if(i===null&&(t.boundingBox||t.computeBoundingBox(),sl.set(t.boundingBox.min,t.boundingBox.max,n),i=sl),et(c,a)){const l=e.geometry,u=l.index,p=l.attributes.position,f=t.index,m=t.attributes.position,b=ct(r,o),x=pt(c,a);if(mi.copy(n).invert(),t.boundsTree)return ve(r,s,Vr),Vr.matrix.copy(mi),Vr.needsUpdate=!0,t.boundsTree.shapecast({intersectsBounds:g=>Vr.intersectsBox(g),intersectsTriangle:g=>{g.a.applyMatrix4(n),g.b.applyMatrix4(n),g.c.applyMatrix4(n),g.needsUpdate=!0;for(let v=b,_=x+b;v<_;v++)if(Me(Fn,3*e.resolveTriangleIndex(v),u,p),Fn.needsUpdate=!0,g.intersectsTriangle(Fn))return!0;return!1}});for(let g=b,v=x+b;g<v;g++){const _=e.resolveTriangleIndex(g);Me(Ln,3*_,u,p),Ln.a.applyMatrix4(mi),Ln.b.applyMatrix4(mi),Ln.c.applyMatrix4(mi),Ln.needsUpdate=!0;for(let w=0,C=f.count;w<C;w+=3)if(Me(Fn,w,f,m),Fn.needsUpdate=!0,Ln.intersectsTriangle(Fn))return!0}}else{const l=r+8,u=o[r+6];return ve(l,s,Fr),!!(i.intersectsBox(Fr)&&yo(l,e,t,n,i)||(ve(u,s,Fr),i.intersectsBox(Fr)&&yo(u,e,t,n,i)))}}const jr=new Ct,go=new Ve,yi=new Ve,up=new W,hp=new W,dp=new W,pp=new W;function fp(r,e,t,n={},i={},s=0,a=1/0){e.boundingBox||e.computeBoundingBox(),go.set(e.boundingBox.min,e.boundingBox.max,t),go.needsUpdate=!0;const o=r.geometry,c=o.attributes.position,l=o.index,u=e.attributes.position,p=e.index,f=gt.getPrimitive(),m=gt.getPrimitive();let b=up,x=hp,g=null,v=null;i&&(g=dp,v=pp);let _=1/0,w=null,C=null;return jr.copy(t).invert(),yi.matrix.copy(jr),r.shapecast({boundsTraverseOrder:M=>go.distanceToBox(M),intersectsBounds:(M,E,P)=>P<_&&P<a?(E&&(yi.min.copy(M.min),yi.max.copy(M.max),yi.needsUpdate=!0),!0):!1,intersectsRange:(M,E)=>{if(e.boundsTree){const P=e.boundsTree;return P.shapecast({boundsTraverseOrder:O=>yi.distanceToBox(O),intersectsBounds:(O,R,A)=>A<_&&A<a,intersectsRange:(O,R)=>{for(let A=O,B=O+R;A<B;A++){const z=P.resolveTriangleIndex(A);Me(m,3*z,p,u),m.a.applyMatrix4(t),m.b.applyMatrix4(t),m.c.applyMatrix4(t),m.needsUpdate=!0;for(let D=M,F=M+E;D<F;D++){const H=r.resolveTriangleIndex(D);Me(f,3*H,l,c),f.needsUpdate=!0;const q=f.distanceToTriangle(m,b,g);if(q<_&&(x.copy(b),v&&v.copy(g),_=q,w=D,C=A),q<s)return!0}}}})}else{const P=zn(e);for(let O=0,R=P;O<R;O++){Me(m,3*O,p,u),m.a.applyMatrix4(t),m.b.applyMatrix4(t),m.c.applyMatrix4(t),m.needsUpdate=!0;for(let A=M,B=M+E;A<B;A++){const z=r.resolveTriangleIndex(A);Me(f,3*z,l,c),f.needsUpdate=!0;const D=f.distanceToTriangle(m,b,g);if(D<_&&(x.copy(b),v&&v.copy(g),_=D,w=A,C=O),D<s)return!0}}}}}),gt.releasePrimitive(f),gt.releasePrimitive(m),_===1/0?null:(n.point?n.point.copy(x):n.point=x.clone(),n.distance=_,n.faceIndex=w,i&&(i.point?i.point.copy(v):i.point=v.clone(),i.point.applyMatrix4(jr),x.applyMatrix4(jr),i.distance=x.sub(i.point).length(),i.faceIndex=C),n)}function mp(){return typeof SharedArrayBuffer<"u"}const gi=new de.constructor,Jr=new de.constructor,sn=new oo(()=>new Ot),Vn=new Ot,jn=new Ot,vo=new Ot,So=new Ot;let bo=!1;function yp(r,e,t,n){if(bo)throw new Error("MeshBVH: Recursive calls to bvhcast not supported.");bo=!0;const i=r._roots,s=e._roots;let a,o=0,c=0;const l=new Ct().copy(t).invert();for(let u=0,p=i.length;u<p;u++){gi.setBuffer(i[u]),c=0;const f=sn.getPrimitive();ve(0,gi.float32Array,f),f.applyMatrix4(l);for(let m=0,b=s.length;m<b&&(Jr.setBuffer(s[m]),a=kt(0,0,t,l,n,o,c,0,0,f),Jr.clearBuffer(),c+=s[m].length,!a);m++);if(sn.releasePrimitive(f),gi.clearBuffer(),o+=i[u].length,a)break}return bo=!1,a}function kt(r,e,t,n,i,s=0,a=0,o=0,c=0,l=null,u=!1){let p,f;u?(p=Jr,f=gi):(p=gi,f=Jr);const m=p.float32Array,b=p.uint32Array,x=p.uint16Array,g=f.float32Array,v=f.uint32Array,_=f.uint16Array,w=r*2,C=e*2,M=et(w,x),E=et(C,_);let P=!1;if(E&&M)u?P=i(ct(e,v),pt(e*2,_),ct(r,b),pt(r*2,x),c,a+e,o,s+r):P=i(ct(r,b),pt(r*2,x),ct(e,v),pt(e*2,_),o,s+r,c,a+e);else if(E){const O=sn.getPrimitive();ve(e,g,O),O.applyMatrix4(t);const R=ft(r),A=mt(r,b);ve(R,m,Vn),ve(A,m,jn);const B=O.intersectsBox(Vn),z=O.intersectsBox(jn);P=B&&kt(e,R,n,t,i,a,s,c,o+1,O,!u)||z&&kt(e,A,n,t,i,a,s,c,o+1,O,!u),sn.releasePrimitive(O)}else{const O=ft(e),R=mt(e,v);ve(O,g,vo),ve(R,g,So);const A=l.intersectsBox(vo),B=l.intersectsBox(So);if(A&&B)P=kt(r,O,t,n,i,s,a,o,c+1,l,u)||kt(r,R,t,n,i,s,a,o,c+1,l,u);else if(A)if(M)P=kt(r,O,t,n,i,s,a,o,c+1,l,u);else{const z=sn.getPrimitive();z.copy(vo).applyMatrix4(t);const D=ft(r),F=mt(r,b);ve(D,m,Vn),ve(F,m,jn);const H=z.intersectsBox(Vn),q=z.intersectsBox(jn);P=H&&kt(O,D,n,t,i,a,s,c,o+1,z,!u)||q&&kt(O,F,n,t,i,a,s,c,o+1,z,!u),sn.releasePrimitive(z)}else if(B)if(M)P=kt(r,R,t,n,i,s,a,o,c+1,l,u);else{const z=sn.getPrimitive();z.copy(So).applyMatrix4(t);const D=ft(r),F=mt(r,b);ve(D,m,Vn),ve(F,m,jn);const H=z.intersectsBox(Vn),q=z.intersectsBox(jn);P=H&&kt(R,D,n,t,i,a,s,c,o+1,z,!u)||q&&kt(R,F,n,t,i,a,s,c,o+1,z,!u),sn.releasePrimitive(z)}}return P}const Gr=new Ve,ol=new Ot,gp={strategy:Zs,maxDepth:40,maxLeafTris:10,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,indirect:!1,verbose:!0,range:null};class xi{static serialize(e,t={}){t={cloneBuffers:!0,...t};const n=e.geometry,i=e._roots,s=e._indirectBuffer,a=n.getIndex();let o;return t.cloneBuffers?o={roots:i.map(c=>c.slice()),index:a?a.array.slice():null,indirectBuffer:s?s.slice():null}:o={roots:i,index:a?a.array:null,indirectBuffer:s},o}static deserialize(e,t,n={}){n={setIndex:!0,indirect:!!e.indirectBuffer,...n};const{index:i,roots:s,indirectBuffer:a}=e,o=new xi(t,{...n,[$s]:!0});if(o._roots=s,o._indirectBuffer=a||null,n.setIndex){const c=t.getIndex();if(c===null){const l=new ot(e.index,1,!1);t.setIndex(l)}else c.array!==i&&(c.array.set(i),c.needsUpdate=!0)}return o}get indirect(){return!!this._indirectBuffer}constructor(e,t={}){if(e.isBufferGeometry){if(e.index&&e.index.isInterleavedBufferAttribute)throw new Error("MeshBVH: InterleavedBufferAttribute is not supported for the index attribute.")}else throw new Error("MeshBVH: Only BufferGeometries are supported.");if(t=Object.assign({...gp,[$s]:!1},t),t.useSharedArrayBuffer&&!mp())throw new Error("MeshBVH: SharedArrayBuffer is not available.");this.geometry=e,this._roots=null,this._indirectBuffer=null,t[$s]||(Od(this,t),!e.boundingBox&&t.setBoundingBox&&(e.boundingBox=this.getBoundingBox(new Ot))),this.resolveTriangleIndex=t.indirect?n=>this._indirectBuffer[n]:n=>n}refit(e=null){return(this.indirect?sp:Hd)(this,e)}traverse(e,t=0){const n=this._roots[t],i=new Uint32Array(n),s=new Uint16Array(n);a(0);function a(o,c=0){const l=o*2,u=s[l+15]===Pr;if(u){const p=i[o+6],f=s[l+14];e(c,u,new Float32Array(n,o*4,6),p,f)}else{const p=o+ci/4,f=i[o+6],m=i[o+7];e(c,u,new Float32Array(n,o*4,6),m)||(a(p,c+1),a(f,c+1))}}}raycast(e,t=ea,n=0,i=1/0){const s=this._roots,a=this.geometry,o=[],c=t.isMaterial,l=Array.isArray(t),u=a.groups,p=c?t.side:t,f=this.indirect?op:Zd;for(let m=0,b=s.length;m<b;m++){const x=l?t[u[m].materialIndex].side:p,g=o.length;if(f(this,m,x,e,o,n,i),l){const v=u[m].materialIndex;for(let _=g,w=o.length;_<w;_++)o[_].face.materialIndex=v}}return o}raycastFirst(e,t=ea,n=0,i=1/0){const s=this._roots,a=this.geometry,o=t.isMaterial,c=Array.isArray(t);let l=null;const u=a.groups,p=o?t.side:t,f=this.indirect?cp:Qd;for(let m=0,b=s.length;m<b;m++){const x=c?t[u[m].materialIndex].side:p,g=f(this,m,x,e,n,i);g!=null&&(l==null||g.distance<l.distance)&&(l=g,c&&(g.face.materialIndex=u[m].materialIndex))}return l}intersectsGeometry(e,t){let n=!1;const i=this._roots,s=this.indirect?lp:$d;for(let a=0,o=i.length;a<o&&(n=s(this,a,e,t),!n);a++);return n}shapecast(e){const t=gt.getPrimitive(),n=this.indirect?Yd:Wd;let{boundsTraverseOrder:i,intersectsBounds:s,intersectsRange:a,intersectsTriangle:o}=e;if(a&&o){const p=a;a=(f,m,b,x,g)=>p(f,m,b,x,g)?!0:n(f,m,this,o,b,x,t)}else a||(o?a=(p,f,m,b)=>n(p,f,this,o,m,b,t):a=(p,f,m)=>m);let c=!1,l=0;const u=this._roots;for(let p=0,f=u.length;p<f;p++){const m=u[p];if(c=Dd(this,p,s,a,i,l),c)break;l+=m.byteLength}return gt.releasePrimitive(t),c}bvhcast(e,t,n){let{intersectsRanges:i,intersectsTriangles:s}=n;const a=gt.getPrimitive(),o=this.geometry.index,c=this.geometry.attributes.position,l=this.indirect?b=>{const x=this.resolveTriangleIndex(b);Me(a,x*3,o,c)}:b=>{Me(a,b*3,o,c)},u=gt.getPrimitive(),p=e.geometry.index,f=e.geometry.attributes.position,m=e.indirect?b=>{const x=e.resolveTriangleIndex(b);Me(u,x*3,p,f)}:b=>{Me(u,b*3,p,f)};if(s){const b=(x,g,v,_,w,C,M,E)=>{for(let P=v,O=v+_;P<O;P++){m(P),u.a.applyMatrix4(t),u.b.applyMatrix4(t),u.c.applyMatrix4(t),u.needsUpdate=!0;for(let R=x,A=x+g;R<A;R++)if(l(R),a.needsUpdate=!0,s(a,u,R,P,w,C,M,E))return!0}return!1};if(i){const x=i;i=function(g,v,_,w,C,M,E,P){return x(g,v,_,w,C,M,E,P)?!0:b(g,v,_,w,C,M,E,P)}}else i=b}return yp(this,e,t,i)}intersectsBox(e,t){return Gr.set(e.min,e.max,t),Gr.needsUpdate=!0,this.shapecast({intersectsBounds:n=>Gr.intersectsBox(n),intersectsTriangle:n=>Gr.intersectsTriangle(n)})}intersectsSphere(e){return this.shapecast({intersectsBounds:t=>e.intersectsBox(t),intersectsTriangle:t=>t.intersectsSphere(e)})}closestPointToGeometry(e,t,n={},i={},s=0,a=1/0){return(this.indirect?fp:rp)(this,e,t,n,i,s,a)}closestPointToPoint(e,t={},n=0,i=1/0){return Ld(this,e,t,n,i)}getBoundingBox(e){return e.makeEmpty(),this._roots.forEach(t=>{ve(0,new Float32Array(t),ol),e.union(ol)}),e}}function al(r,e,t){return r===null?null:(r.point.applyMatrix4(e.matrixWorld),r.distance=r.point.distanceTo(t.ray.origin),r.object=e,r)}const Wr=new Jl,cl=new W,ll=new Ct,vp=fs.prototype.raycast,Sp=jl.prototype.raycast,ul=new W,Ue=new fs,Hr=[];function bp(r,e){this.isBatchedMesh?xp.call(this,r,e):wp.call(this,r,e)}function xp(r,e){if(this.boundsTrees){const t=this.boundsTrees,n=this._drawInfo||this._instanceInfo,i=this._drawRanges||this._geometryInfo,s=this.matrixWorld;Ue.material=this.material,Ue.geometry=this.geometry;const a=Ue.geometry.boundsTree,o=Ue.geometry.drawRange;Ue.geometry.boundingSphere===null&&(Ue.geometry.boundingSphere=new $o);for(let c=0,l=n.length;c<l;c++){if(!this.getVisibleAt(c))continue;const u=n[c].geometryIndex;if(Ue.geometry.boundsTree=t[u],this.getMatrixAt(c,Ue.matrixWorld).premultiply(s),!Ue.geometry.boundsTree){this.getBoundingBoxAt(u,Ue.geometry.boundingBox),this.getBoundingSphereAt(u,Ue.geometry.boundingSphere);const p=i[u];Ue.geometry.setDrawRange(p.start,p.count)}Ue.raycast(r,Hr);for(let p=0,f=Hr.length;p<f;p++){const m=Hr[p];m.object=this,m.batchId=c,e.push(m)}Hr.length=0}Ue.geometry.boundsTree=a,Ue.geometry.drawRange=o,Ue.material=null,Ue.geometry=null}else Sp.call(this,r,e)}function wp(r,e){if(this.geometry.boundsTree){if(this.material===void 0)return;ll.copy(this.matrixWorld).invert(),Wr.copy(r.ray).applyMatrix4(ll),ul.setFromMatrixScale(this.matrixWorld),cl.copy(Wr.direction).multiply(ul);const t=cl.length(),n=r.near/t,i=r.far/t,s=this.geometry.boundsTree;if(r.firstHitOnly===!0){const a=al(s.raycastFirst(Wr,this.material,n,i),this,r);a&&e.push(a)}else{const a=s.raycast(Wr,this.material,n,i);for(let o=0,c=a.length;o<c;o++){const l=al(a[o],this,r);l&&e.push(l)}}}else vp.call(this,r,e)}function _p(r={}){return this.boundsTree=new xi(this,r),this.boundsTree}const yn=new W,gn=new W,vn=new W,hl=new ms,qr=new W,xo=new W,dl=new ms,pl=new ms,Xr=new Ct,fl=new Ct;function vi(r,e){if(!r&&!e)return;const t=r.count===e.count,n=r.normalized===e.normalized,i=r.array.constructor===e.array.constructor,s=r.itemSize===e.itemSize;if(!t||!n||!i||!s)throw new Error}function Si(r,e=null){const t=r.array.constructor,n=r.normalized,i=r.itemSize,s=e===null?r.count:e;return new ot(new t(i*s),i,n)}function ml(r,e,t=0){if(r.isInterleavedBufferAttribute){const n=r.itemSize;for(let i=0,s=r.count;i<s;i++){const a=i+t;e.setX(a,r.getX(i)),n>=2&&e.setY(a,r.getY(i)),n>=3&&e.setZ(a,r.getZ(i)),n>=4&&e.setW(a,r.getW(i))}}else{const n=e.array,i=n.constructor,s=n.BYTES_PER_ELEMENT*r.itemSize*t;new i(n.buffer,s,r.array.length).set(r.array)}}function Tp(r,e,t){const n=r.elements,i=e.elements;for(let s=0,a=i.length;s<a;s++)n[s]+=i[s]*t}function yl(r,e,t){const n=r.skeleton,i=r.geometry,s=n.bones,a=n.boneInverses;dl.fromBufferAttribute(i.attributes.skinIndex,e),pl.fromBufferAttribute(i.attributes.skinWeight,e),Xr.elements.fill(0);for(let o=0;o<4;o++){const c=pl.getComponent(o);if(c!==0){const l=dl.getComponent(o);fl.multiplyMatrices(s[l].matrixWorld,a[l]),Tp(Xr,fl,c)}}return Xr.multiply(r.bindMatrix).premultiply(r.bindMatrixInverse),t.transformDirection(Xr),t}function wo(r,e,t,n,i){qr.set(0,0,0);for(let s=0,a=r.length;s<a;s++){const o=e[s],c=r[s];o!==0&&(xo.fromBufferAttribute(c,n),t?qr.addScaledVector(xo,o):qr.addScaledVector(xo.sub(i),o))}i.add(qr)}function Mp(r,e={useGroups:!1,updateIndex:!1,skipAttributes:[]},t=new Yn){const n=r[0].index!==null,{useGroups:i=!1,updateIndex:s=!1,skipAttributes:a=[]}=e,o=new Set(Object.keys(r[0].attributes)),c={};let l=0;t.clearGroups();for(let u=0;u<r.length;++u){const p=r[u];let f=0;if(n!==(p.index!==null))throw new Error("StaticGeometryGenerator: All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them.");for(const m in p.attributes){if(!o.has(m))throw new Error('StaticGeometryGenerator: All geometries must have compatible attributes; make sure "'+m+'" attribute exists among all geometries, or in none of them.');c[m]===void 0&&(c[m]=[]),c[m].push(p.attributes[m]),f++}if(f!==o.size)throw new Error("StaticGeometryGenerator: Make sure all geometries have the same number of attributes.");if(i){let m;if(n)m=p.index.count;else if(p.attributes.position!==void 0)m=p.attributes.position.count;else throw new Error("StaticGeometryGenerator: The geometry must have either an index or a position attribute");t.addGroup(l,m,u),l+=m}}if(n){let u=!1;if(!t.index){let p=0;for(let f=0;f<r.length;++f)p+=r[f].index.count;t.setIndex(new ot(new Uint32Array(p),1,!1)),u=!0}if(s||u){const p=t.index;let f=0,m=0;for(let b=0;b<r.length;++b){const x=r[b],g=x.index;if(a[b]!==!0)for(let v=0;v<g.count;++v)p.setX(f,g.getX(v)+m),f++;m+=x.attributes.position.count}}}for(const u in c){const p=c[u];if(!(u in t.attributes)){let b=0;for(const x in p)b+=p[x].count;t.setAttribute(u,Si(c[u][0],b))}const f=t.attributes[u];let m=0;for(let b=0,x=p.length;b<x;b++){const g=p[b];a[b]!==!0&&ml(g,f,m),m+=g.count}}return t}function Cp(r,e){if(r===null||e===null)return r===e;if(r.length!==e.length)return!1;for(let t=0,n=r.length;t<n;t++)if(r[t]!==e[t])return!1;return!0}function Ep(r){const{index:e,attributes:t}=r;if(e)for(let n=0,i=e.count;n<i;n+=3){const s=e.getX(n),a=e.getX(n+2);e.setX(n,a),e.setX(n+2,s)}else for(const n in t){const i=t[n],s=i.itemSize;for(let a=0,o=i.count;a<o;a+=3)for(let c=0;c<s;c++){const l=i.getComponent(a,c),u=i.getComponent(a+2,c);i.setComponent(a,c,u),i.setComponent(a+2,c,l)}}return r}class Pp{constructor(e){this.matrixWorld=new Ct,this.geometryHash=null,this.boneMatrices=null,this.primitiveCount=-1,this.mesh=e,this.update()}update(){const e=this.mesh,t=e.geometry,n=e.skeleton,i=(t.index?t.index.count:t.attributes.position.count)/3;if(this.matrixWorld.copy(e.matrixWorld),this.geometryHash=t.attributes.position.version,this.primitiveCount=i,n){n.boneTexture||n.computeBoneTexture(),n.update();const s=n.boneMatrices;!this.boneMatrices||this.boneMatrices.length!==s.length?this.boneMatrices=s.slice():this.boneMatrices.set(s)}else this.boneMatrices=null}didChange(){const e=this.mesh,t=e.geometry,n=(t.index?t.index.count:t.attributes.position.count)/3;return!(this.matrixWorld.equals(e.matrixWorld)&&this.geometryHash===t.attributes.position.version&&Cp(e.skeleton&&e.skeleton.boneMatrices||null,this.boneMatrices)&&this.primitiveCount===n)}}class kp{constructor(e){Array.isArray(e)||(e=[e]);const t=[];e.forEach(n=>{n.traverseVisible(i=>{i.isMesh&&t.push(i)})}),this.meshes=t,this.useGroups=!0,this.applyWorldTransforms=!0,this.attributes=["position","normal","color","tangent","uv","uv2"],this._intermediateGeometry=new Array(t.length).fill().map(()=>new Yn),this._diffMap=new WeakMap}getMaterials(){const e=[];return this.meshes.forEach(t=>{Array.isArray(t.material)?e.push(...t.material):e.push(t.material)}),e}generate(e=new Yn){let t=[];const{meshes:n,useGroups:i,_intermediateGeometry:s,_diffMap:a}=this;for(let o=0,c=n.length;o<c;o++){const l=n[o],u=s[o],p=a.get(l);!p||p.didChange(l)?(this._convertToStaticGeometry(l,u),t.push(!1),p?p.update():a.set(l,new Pp(l))):t.push(!0)}if(s.length===0){e.setIndex(null);const o=e.attributes;for(const c in o)e.deleteAttribute(c);for(const c in this.attributes)e.setAttribute(this.attributes[c],new ot(new Float32Array(0),4,!1))}else Mp(s,{useGroups:i,skipAttributes:t},e);for(const o in e.attributes)e.attributes[o].needsUpdate=!0;return e}_convertToStaticGeometry(e,t=new Yn){const n=e.geometry,i=this.applyWorldTransforms,s=this.attributes.includes("normal"),a=this.attributes.includes("tangent"),o=n.attributes,c=t.attributes;!t.index&&n.index&&(t.index=n.index.clone()),c.position||t.setAttribute("position",Si(o.position)),s&&!c.normal&&o.normal&&t.setAttribute("normal",Si(o.normal)),a&&!c.tangent&&o.tangent&&t.setAttribute("tangent",Si(o.tangent)),vi(n.index,t.index),vi(o.position,c.position),s&&vi(o.normal,c.normal),a&&vi(o.tangent,c.tangent);const l=o.position,u=s?o.normal:null,p=a?o.tangent:null,f=n.morphAttributes.position,m=n.morphAttributes.normal,b=n.morphAttributes.tangent,x=n.morphTargetsRelative,g=e.morphTargetInfluences,v=new Gl;v.getNormalMatrix(e.matrixWorld),n.index&&t.index.array.set(n.index.array);for(let _=0,w=o.position.count;_<w;_++)yn.fromBufferAttribute(l,_),u&&gn.fromBufferAttribute(u,_),p&&(hl.fromBufferAttribute(p,_),vn.fromBufferAttribute(p,_)),g&&(f&&wo(f,g,x,_,yn),m&&wo(m,g,x,_,gn),b&&wo(b,g,x,_,vn)),e.isSkinnedMesh&&(e.applyBoneTransform(_,yn),u&&yl(e,_,gn),p&&yl(e,_,vn)),i&&yn.applyMatrix4(e.matrixWorld),c.position.setXYZ(_,yn.x,yn.y,yn.z),u&&(i&&gn.applyNormalMatrix(v),c.normal.setXYZ(_,gn.x,gn.y,gn.z)),p&&(i&&vn.transformDirection(e.matrixWorld),c.tangent.setXYZW(_,vn.x,vn.y,vn.z,hl.w));for(const _ in this.attributes){const w=this.attributes[_];w==="position"||w==="tangent"||w==="normal"||!(w in o)||(c[w]||t.setAttribute(w,Si(o[w])),vi(o[w],c[w]),ml(o[w],c[w]))}return e.matrixWorld.determinant()<0&&Ep(t),t}}const Rp=Object.freeze(Object.defineProperty({__proto__:null,AVERAGE:Gc,CENTER:Zs,CONTAINED:Ks,ExtendedTriangle:yt,MeshBVH:xi,OrientedBox:Ve,SAH:Wc,StaticGeometryGenerator:kp,acceleratedRaycast:bp,computeBoundsTree:_p},Symbol.toStringTag,{value:"Module"}));class Ap{constructor(e){this.name="WorkerBase",this.running=!1,this.worker=e,this.worker.onerror=t=>{throw t.message?new Error(`${this.name}: Could not create Web Worker with error "${t.message}"`):new Error(`${this.name}: Could not create Web Worker.`)}}runTask(){}generate(...e){if(this.running)throw new Error("GenerateMeshBVHWorker: Already running job.");if(this.worker===null)throw new Error("GenerateMeshBVHWorker: Worker has been disposed.");this.running=!0;const t=this.runTask(this.worker,...e);return t.finally(()=>{this.running=!1}),t}dispose(){this.worker.terminate(),this.worker=null}}const vt={node:"node",material:"material",camera:"camera",light:"light"},Sn="KHR_animation_pointer",Op={CUBICSPLINE:void 0,LINEAR:ta,STEP:Hl};class Ip{constructor(e){this.name=Sn,this.parser=e,this.animationPointerResolver=null}setAnimationPointerResolver(e){return this.animationPointerResolver=e,this}loadAnimationTargetFromChannel(e){const t=e.target,n=t.node!==void 0?t.node:t.id;return this.parser.getDependency("node",n)}loadAnimationTargetFromChannelWithAnimationPointer(e){Bp();const t=e.target,n=t.extensions&&t.extensions[Sn]&&t.path&&t.path==="pointer";if(!n)return null;let i,s=vt.node,a;if(n){const c=t.extensions[Sn];let l=c.pointer;if(!l){console.warn("Invalid path",c,t);return}if(l.startsWith("/materials/")?s=vt.material:l.startsWith("/extensions/KHR_lights_punctual/lights/")?s=vt.light:l.startsWith("/cameras/")&&(s=vt.camera),a=this._tryResolveTargetId(l,s),a===null||isNaN(a)){console.warn("Failed resolving animation node id: "+a,l);return}switch(s){case vt.material:const u=("/materials/"+a.toString()+"/").length,p=l.substring(0,u);switch(i=l.substring(u),i){case"pbrMetallicRoughness/baseColorFactor":i="color";break;case"pbrMetallicRoughness/roughnessFactor":i="roughness";break;case"pbrMetallicRoughness/metallicFactor":i="metalness";break;case"emissiveFactor":i="emissive";break;case"alphaCutoff":i="alphaTest";break;case"occlusionTexture/strength":i="aoMapIntensity";break;case"normalTexture/scale":i="normalScale";break;case"pbrMetallicRoughness/baseColorTexture/extensions/KHR_texture_transform/scale":i="map/repeat";break;case"pbrMetallicRoughness/baseColorTexture/extensions/KHR_texture_transform/offset":i="map/offset";break;case"emissiveTexture/extensions/KHR_texture_transform/scale":i="emissiveMap/repeat";break;case"emissiveTexture/extensions/KHR_texture_transform/offset":i="emissiveMap/offset";break;case"extensions/KHR_materials_emissive_strength/emissiveStrength":i="emissiveIntensity";break;case"extensions/KHR_materials_transmission/transmissionFactor":i="transmission";break;case"extensions/KHR_materials_ior/ior":i="ior";break;case"extensions/KHR_materials_volume/thicknessFactor":i="thickness";break;case"extensions/KHR_materials_volume/attenuationColor":i="attenuationColor";break;case"extensions/KHR_materials_volume/attenuationDistance":i="attenuationDistance";break;case"extensions/KHR_materials_iridescence/iridescenceFactor":i="iridescence";break;case"extensions/KHR_materials_iridescence/iridescenceIor":i="iridescenceIOR";break;case"extensions/KHR_materials_iridescence/iridescenceThicknessMinimum":i="iridescenceThicknessRange[0]";break;case"extensions/KHR_materials_iridescence/iridescenceThicknessMaximum":i="iridescenceThicknessRange[1]";break;case"extensions/KHR_materials_clearcoat/clearcoatFactor":i="clearcoat";break;case"extensions/KHR_materials_clearcoat/clearcoatRoughnessFactor":i="clearcoatRoughness";break;case"extensions/KHR_materials_sheen/sheenColorFactor":i="sheenColor";break;case"extensions/KHR_materials_sheen/sheenRoughnessFactor":i="sheenRoughness";break;case"extensions/KHR_materials_specular/specularFactor":i="specularIntensity";break;case"extensions/KHR_materials_specular/specularColorFactor":i="specularColor";break}l=p+i;break;case vt.node:const f=("/nodes/"+a.toString()+"/").length,m=l.substring(0,f);switch(i=l.substring(f),i){case"translation":i="position";break;case"rotation":i="quaternion";break;case"scale":i="scale";break;case"weights":i="morphTargetInfluences";break;case"KHR_node_visibility/visible":i="visible";break}l=m+i;break;case vt.light:const b=("/extensions/KHR_lights_punctual/lights/"+a.toString()+"/").length;switch(i=l.substring(b),i){case"color":break;case"intensity":break;case"spot/innerConeAngle":i="penumbra";break;case"spot/outerConeAngle":i="angle";break;case"range":i="distance";break}l="/lights/"+a.toString()+"/"+i;break;case vt.camera:const x=("/cameras/"+a.toString()+"/").length,g=l.substring(0,x);switch(i=l.substring(x),i){case"perspective/yfov":i="fov";break;case"perspective/znear":case"orthographic/znear":i="near";break;case"perspective/zfar":case"orthographic/zfar":i="far";break;case"perspective/aspect":i="aspect";break;case"orthographic/xmag":i="zoom";break;case"orthographic/ymag":i="zoom";break}l=g+i;break}this.animationPointerResolver?.resolvePath&&(l=this.animationPointerResolver.resolvePath(l)),t.extensions[Sn].pointer=l}if(a==null||isNaN(a)){console.warn("Failed resolving animation node id: "+a,t);return}let o;return s===vt.node?o=this.parser.getDependency("node",a):s===vt.material?o=this.parser.getDependency("material",a):s===vt.light?o=this.parser.getDependency("light",a):s===vt.camera?o=this.parser.getDependency("camera",a):console.error("Unhandled type",s),o}createAnimationTracksWithAnimationPointer(e,t,n,i,s){if(!(s.extensions&&s.extensions[Sn]&&s.path&&s.path==="pointer"))return null;let a=s.extensions[Sn].pointer;if(!a)return null;const o=[];a=a.replaceAll("/",".");const c=a.split(".");var l=e.name!==void 0&&e.name!==null?e.name:e.uuid;if(c[2]=l,c[3]==="morphTargetInfluences"&&e.type==="Group"){for(const f of e.children)f instanceof Wl&&f.morphTargetInfluences&&(c[3]=f.name,c[4]="morphTargetInfluences",p(this.parser));return o}p(this.parser);function u(f,m){try{const b=m.split(".").filter(Boolean),x=b[b.length-1].replace(/\[.*\]$/,"");return x in f?typeof f[x]=="boolean":!1}catch{return!1}}function p(f){a=c.join(".");let m,b=!1;switch(n.itemSize){case 1:Object.prototype.toString.call(n.array)==="[object Uint8Array]"&&u(e,a)?(m=Kl,b=!0):m=Ql;break;case 2:case 3:m=Zl;break;case 4:a.endsWith(".quaternion")?m=Xl:m=Yl;break}if(!m){console.warn("Unsupported output accessor format",n);return}const x=i.interpolation!==void 0?Op[i.interpolation]:ta;let g=f._getArrayFromAccessor(n);a.endsWith(".fov")&&(g=g.map(_=>_/Math.PI*180)),b&&(g=g.map(_=>_>0));const v=new m(a,t.array,g,x);if(x==="CUBICSPLINE"&&f._createCubicSplineTrackInterpolant(v),o.push(v),a&&n.itemSize===4&&a.startsWith(".materials.")&&a.endsWith(".color")){const _=new Float32Array(g.length/4);for(let C=0,M=g.length/4;C<M;C+=1)_[C]=g[C*4+3];const w=new m(a.replace(".color",".opacity"),t.array,_,x);x==="CUBICSPLINE"&&f._createCubicSplineTrackInterpolant(v),o.push(w)}}return o}_tryResolveTargetId(e,t){let n="";return t==="node"?n=e.substring(7):t==="material"?n=e.substring(11):t==="light"?n=e.substring(39):t==="camera"&&(n=e.substring(9)),n=n.substring(0,n.indexOf("/")),Number.parseInt(n)}loadAnimation(e){const t=this,n=this.parser.json,i=this.parser,s=n.animations[e],a=s.name?s.name:"animation_"+e,o=[],c=[],l=[],u=[],p=[];for(let f=0,m=s.channels.length;f<m;f++){const b=s.channels[f],x=s.samplers[b.sampler],g=b.target,v=s.parameters!==void 0?s.parameters[x.input]:x.input,_=s.parameters!==void 0?s.parameters[x.output]:x.output;let w=t.loadAnimationTargetFromChannelWithAnimationPointer(b);w||(w=t.loadAnimationTargetFromChannel(b)),o.push(w),c.push(i.getDependency("accessor",v)),l.push(i.getDependency("accessor",_)),u.push(x),p.push(g)}return Promise.all([Promise.all(o),Promise.all(c),Promise.all(l),Promise.all(u),Promise.all(p)]).then(function(f){const m=f[0],b=f[1],x=f[2],g=f[3],v=f[4],_=[];for(let w=0,C=m.length;w<C;w++){const M=m[w],E=b[w],P=x[w],O=g[w],R=v[w];if(M===void 0)continue;M.updateMatrix&&(M.updateMatrix(),M.matrixAutoUpdate=!0);let A=t.createAnimationTracksWithAnimationPointer(M,E,P,O,R);if(A||(A=i._createAnimationTracks(M,E,P,O,R)),A)for(let B=0;B<A.length;B++)_.push(A[B])}return new ql(a,void 0,_)})}}let gl=!1,zp=null;function Bp(){if(gl)return;gl=!0;const r=zp||=na.findNode;na.findNode=function(e,t){if(!t)return r(e,t);if(t.startsWith(".materials.")){const n=t.substring(11).substring(t.indexOf(".")),i=n.indexOf("."),s=i<0?n:n.substring(0,i);let a=null;return e.traverse(o=>{a!==null||o.type!=="Mesh"&&o.type!=="SkinnedMesh"||o.material&&(o.material.uuid===s||o.material.name===s)&&(a=o.material,a!==null&&(n.endsWith(".map")?a=a.map:n.endsWith(".emissiveMap")&&(a=a.emissiveMap)))}),a}else if(t.startsWith(".nodes.")||t.startsWith(".lights.")||t.startsWith(".cameras.")){const n=t.split(".");let i;for(let s=1;s<n.length;s++){const a=n[s];if(a.length==36)i=e.getObjectByProperty("uuid",a);else if(i&&i[a]){const o=Number.parseInt(a);let c=a;o>=0&&(c=o),i=i[c]}else{const o=e.getObjectByName(a);o&&(i=o)}}if(!i){const s=r(e,n[2]);return s||console.warn(Sn+": Property binding not found",t,e,e.name,n),s}return i}return r(e,t)}}const Np=Object.freeze(Object.defineProperty({__proto__:null,GLTFAnimationPointerExtension:Ip},Symbol.toStringTag,{value:"Module"}));export{bc as $70d766613f57b014$export$2e2bcd8739ae039,cd as BatchedParticleRenderer,_o as Builder,bi as ByteBuffer,xn as ConstantColor,ne as ConstantValue,Rt as Matrix4,xi as MeshBVH,su as MotionController,Qr as ParticleSystem,V as RenderMode,ra as SIZE_PREFIX_LENGTH,Tr as TrailParticle,tt as Vector4,Ap as WorkerBase,Uu as bundler,ud as createNoise4D,eu as fetchProfile,yd as index,Rp as index$1,Np as index$2,$u as md5,Xu as v5};
|