@needle-tools/engine 4.11.5-next.a900688 → 4.11.5-next.aa5e3b8

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.
Files changed (75) hide show
  1. package/dist/generateMeshBVH.worker-D1Vr8UHG.js +21 -0
  2. package/dist/{gltf-progressive-GwdQV1Qx.umd.cjs → gltf-progressive-DWcmTMCh.umd.cjs} +1 -1
  3. package/dist/{gltf-progressive-CftVUJy3.min.js → gltf-progressive-DZrY8VT6.min.js} +2 -2
  4. package/dist/{gltf-progressive-BvlZQAkt.js → gltf-progressive-DgYz5BYa.js} +19 -19
  5. package/dist/loader.worker-Dip-PthR.js +23 -0
  6. package/dist/{needle-engine.bundle-vPWPv18K.min.js → needle-engine.bundle-DC-_T-N6.min.js} +115 -120
  7. package/dist/{needle-engine.bundle-Dsfd8BPk.umd.cjs → needle-engine.bundle-DCQk5ghP.umd.cjs} +124 -129
  8. package/dist/{needle-engine.bundle-Bwinyjsh.js → needle-engine.bundle-De0bbaDg.js} +2634 -2604
  9. package/dist/needle-engine.js +336 -335
  10. package/dist/needle-engine.min.js +1 -1
  11. package/dist/needle-engine.umd.cjs +1 -1
  12. package/dist/{postprocessing-CJC0Npcd.js → postprocessing-BTW9pD_s.js} +1822 -1723
  13. package/dist/{postprocessing-DrM4PWU3.umd.cjs → postprocessing-CMgoN5t5.umd.cjs} +229 -158
  14. package/dist/{postprocessing-l7zsdO_Q.min.js → postprocessing-DYDtB188.min.js} +227 -156
  15. package/dist/rapier-B3oL1ap-.js +5217 -0
  16. package/dist/rapier-DJ-luMxr.min.js +1 -0
  17. package/dist/rapier-DQltNJbN.umd.cjs +1 -0
  18. package/dist/{three-BDW9I486.min.js → three-B7CT31Bt.min.js} +1 -5
  19. package/dist/{three-MHVqtJYj.js → three-DfMvBzXi.js} +0 -5
  20. package/dist/{three-examples-CgwGHSgz.umd.cjs → three-examples-CsW4_6LI.umd.cjs} +2 -7
  21. package/dist/{three-examples-fvEPSC8L.min.js → three-examples-D1P7eEhn.min.js} +2 -7
  22. package/dist/{three-examples-C5Ht-QFN.js → three-examples-D1SK93ek.js} +1 -7
  23. package/dist/{three-mesh-ui-BjWTTk1R.js → three-mesh-ui-C_uSB5dD.js} +1 -1
  24. package/dist/{three-mesh-ui-Bm32sS2a.umd.cjs → three-mesh-ui-DpATDXwU.umd.cjs} +1 -1
  25. package/dist/{three-mesh-ui-CLdkp21K.min.js → three-mesh-ui-LQ44s0AL.min.js} +1 -1
  26. package/dist/{three-iFaDq9U3.umd.cjs → three-qj71I7J3.umd.cjs} +2 -6
  27. package/dist/{vendor-6kAXU6fm.umd.cjs → vendor-DhTcel4c.umd.cjs} +2 -7
  28. package/dist/{vendor-petGQl0N.js → vendor-Dkpn1a8s.js} +1 -7
  29. package/dist/{vendor-CsyK1CFs.min.js → vendor-DtTGRuXh.min.js} +2 -7
  30. package/lib/engine/debug/debug_spector.d.ts +16 -0
  31. package/lib/engine/debug/debug_spector.js +28 -0
  32. package/lib/engine/debug/debug_spector.js.map +1 -0
  33. package/lib/engine/engine_application.d.ts +7 -0
  34. package/lib/engine/engine_application.js +8 -1
  35. package/lib/engine/engine_application.js.map +1 -1
  36. package/lib/engine/engine_assetdatabase.d.ts +0 -6
  37. package/lib/engine/engine_assetdatabase.js +0 -15
  38. package/lib/engine/engine_assetdatabase.js.map +1 -1
  39. package/lib/engine/engine_context.d.ts +1 -0
  40. package/lib/engine/engine_context.js +5 -2
  41. package/lib/engine/engine_context.js.map +1 -1
  42. package/lib/engine/engine_gltf_builtin_components.js +1 -1
  43. package/lib/engine/engine_gltf_builtin_components.js.map +1 -1
  44. package/lib/engine/engine_loaders.js +24 -25
  45. package/lib/engine/engine_loaders.js.map +1 -1
  46. package/lib/engine/engine_physics.js +6 -2
  47. package/lib/engine/engine_physics.js.map +1 -1
  48. package/lib/engine/engine_physics_rapier.d.ts +11 -2
  49. package/lib/engine/engine_physics_rapier.js +9 -0
  50. package/lib/engine/engine_physics_rapier.js.map +1 -1
  51. package/lib/engine/engine_types.d.ts +16 -0
  52. package/lib/engine-components/RendererInstancing.d.ts +5 -3
  53. package/lib/engine-components/RendererInstancing.js +64 -31
  54. package/lib/engine-components/RendererInstancing.js.map +1 -1
  55. package/lib/engine-components/Skybox.js.map +1 -1
  56. package/lib/needle-engine.js +2 -1
  57. package/lib/needle-engine.js.map +1 -1
  58. package/package.json +1 -1
  59. package/src/engine/debug/debug_spector.ts +43 -0
  60. package/src/engine/engine_application.ts +16 -1
  61. package/src/engine/engine_assetdatabase.ts +0 -21
  62. package/src/engine/engine_context.ts +6 -2
  63. package/src/engine/engine_gltf_builtin_components.ts +1 -1
  64. package/src/engine/engine_loaders.ts +24 -26
  65. package/src/engine/engine_physics.ts +6 -2
  66. package/src/engine/engine_physics_rapier.ts +11 -2
  67. package/src/engine/engine_types.ts +17 -0
  68. package/src/engine-components/RendererInstancing.ts +69 -33
  69. package/src/engine-components/Skybox.ts +1 -1
  70. package/src/needle-engine.ts +4 -2
  71. package/dist/generateMeshBVH.worker-B9bjdr6J.js +0 -25
  72. package/dist/loader.worker-CiTwpNPW.js +0 -27
  73. package/dist/rapier-BqdcSmKY.umd.cjs +0 -1
  74. package/dist/rapier-Cg3w3nFI.min.js +0 -1
  75. package/dist/rapier-sU12SWAs.js +0 -5217
@@ -1,4 +1,4 @@
1
- "use strict";const R=require("./three-iFaDq9U3.umd.cjs"),Ae={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 Ga(r){const e=await fetch(r);if(e.ok)return e.json();throw new Error(e.statusText)}async function pl(r){return await Ga(`${r}/profilesList.json`)}async function ml(r,e,t=null,n=!0){if(!r)throw new Error("No xrInputSource supplied");const i=await pl(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 Ga(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 yl={xAxis:0,yAxis:0,button:0,state:Ae.ComponentState.DEFAULT};function gl(r=0,e=0){let t=r,n=e;if(Math.sqrt(r*r+e*e)>1){const a=Math.atan2(e,r);t=Math.cos(a),n=Math.sin(a)}return{normalizedXAxis:t*.5+.5,normalizedYAxis:n*.5+.5}}class vl{constructor(e){this.componentProperty=e.componentProperty,this.states=e.states,this.valueNodeName=e.valueNodeName,this.valueNodeProperty=e.valueNodeProperty,this.valueNodeProperty===Ae.VisualResponseProperty.TRANSFORM&&(this.minNodeName=e.minNodeName,this.maxNodeName=e.maxNodeName),this.value=0,this.updateFromComponent(yl)}updateFromComponent({xAxis:e,yAxis:t,button:n,state:i}){const{normalizedXAxis:s,normalizedYAxis:a}=gl(e,t);switch(this.componentProperty){case Ae.ComponentProperty.X_AXIS:this.value=this.states.includes(i)?s:.5;break;case Ae.ComponentProperty.Y_AXIS:this.value=this.states.includes(i)?a:.5;break;case Ae.ComponentProperty.BUTTON:this.value=this.states.includes(i)?n:0;break;case Ae.ComponentProperty.STATE:this.valueNodeProperty===Ae.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 Sl{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 vl(t.visualResponses[n]);this.visualResponses[n]=i}),this.gamepadIndices=Object.assign({},t.gamepadIndices),this.values={state:Ae.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=Ae.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=Ae.ComponentState.PRESSED:(t.touched||this.values.button>Ae.ButtonTouchThreshold)&&(this.values.state=Ae.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===Ae.ComponentState.DEFAULT&&Math.abs(this.values.xAxis)>Ae.AxisTouchThreshold&&(this.values.state=Ae.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===Ae.ComponentState.DEFAULT&&Math.abs(this.values.yAxis)>Ae.AxisTouchThreshold&&(this.values.state=Ae.ComponentState.TOUCHED)),Object.values(this.visualResponses).forEach(t=>{t.updateFromComponent(this.values)})}}class xl{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 Sl(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 rs=2,At=4,jt=4,$a=4,Zt=new Int32Array(2),Do=new Float32Array(Zt.buffer),Fo=new Float64Array(Zt.buffer),Zi=new Uint16Array(new Uint8Array([1,0]).buffer)[0]===1;class $t{constructor(e,t){this.low=e|0,this.high=t|0}static create(e,t){return e==0&&t==0?$t.ZERO:new $t(e,t)}toFloat64(){return(this.low>>>0)+this.high*4294967296}equals(e){return this.low==e.low&&this.high==e.high}}$t.ZERO=new $t(0,0);var Bs;(function(r){r[r.UTF8_BYTES=1]="UTF8_BYTES",r[r.UTF16_STRING=2]="UTF16_STRING"})(Bs||(Bs={}));class ai{constructor(e){this.bytes_=e,this.position_=0}static allocate(e){return new ai(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 $t(this.readInt32(e),this.readInt32(e+4))}readUint64(e){return new $t(this.readUint32(e),this.readUint32(e+4))}readFloat32(e){return Zt[0]=this.readInt32(e),Do[0]}readFloat64(e){return Zt[Zi?0:1]=this.readInt32(e),Zt[Zi?1:0]=this.readInt32(e+4),Fo[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){Do[0]=t,this.writeInt32(e,Zt[0])}writeFloat64(e,t){Fo[0]=t,this.writeInt32(e,Zt[Zi?0:1]),this.writeInt32(e+4,Zt[Zi?1:0])}getBufferIdentifier(){if(this.bytes_.length<this.position_+At+jt)throw new Error("FlatBuffers: ByteBuffer is too short to contain an identifier.");let e="";for(let t=0;t<jt;t++)e+=String.fromCharCode(this.readInt8(this.position_+At+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+=At,t===Bs.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)+At}__vector_len(e){return this.readInt32(e+this.readInt32(e))}__has_identifier(e){if(e.length!=jt)throw new Error("FlatBuffers: file identifier must be length "+jt);for(let t=0;t<jt;t++)if(e.charCodeAt(t)!=this.readInt8(this.position()+At+t))return!1;return!0}createLong(e,t){return $t.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 io{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=ai.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=io.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=ai.allocate(n);return i.setPosition(n-t),i.bytes().set(e.bytes(),n-t),i}addOffset(e){this.prep(At,0),this.writeInt32(this.offset()-e+At)}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)*rs;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=rs;l<s;l+=rs)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?$a:0;if(t){const s=t;if(this.prep(this.minalign,At+jt+i),s.length!=jt)throw new Error("FlatBuffers: file identifier must be length "+jt);for(let a=jt-1;a>=0;a--)this.writeInt8(s.charCodeAt(a))}this.prep(this.minalign,At+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(At,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 $t.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 Fr(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var ss={exports:{}},Lo;function Vo(){return Lo||(Lo=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})(ss)),ss.exports}var os,Jo;function _l(){if(Jo)return os;Jo=1;var r=Vo().BufferBuilder,e=Vo().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}};os=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="",f,p;l<o;)f=c[l],f<128?(u+=String.fromCharCode(f),l++):(f^192)<32?(p=(f^192)<<6|c[l+1]&63,u+=String.fromCharCode(p),l+=2):(p=(f&15)<<12|(c[l+1]&63)<<6|c[l+2]&63,u+=String.fromCharCode(p),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(),f=this.unpack();c[u]=f}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,f=o&1048575|1048576,p=f*Math.pow(2,u-20)+c*Math.pow(2,u-52);return(l===0?1:-1)*p},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,f=Math.floor(u*Math.pow(2,52)),p=Math.pow(2,32),m=c<<31|l+1023<<20|f/p&1048575,_=f%p;this.bufferBuilder.append(203),this.pack_int32(m),this.pack_int32(_)},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 os}var bl=_l();const jo=Fr(bl);let Wa=!0,Ha=!0;function Qn(r,e,t){const n=r.match(e);return n&&n.length>=t&&parseInt(n[t],10)}function Dn(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 Tl(r){return typeof r!="boolean"?new Error("Argument type: "+typeof r+". Please use a boolean."):(Wa=r,r?"adapter.js logging disabled":"adapter.js logging enabled")}function Ml(r){return typeof r!="boolean"?new Error("Argument type: "+typeof r+". Please use a boolean."):(Ha=!r,"adapter.js deprecation warnings "+(r?"disabled":"enabled"))}function ro(){if(typeof window=="object"){if(Wa)return;typeof console<"u"&&typeof console.log=="function"&&console.log.apply(console,arguments)}}function Lr(r,e){Ha&&console.warn(r+" is deprecated, please use "+e+" instead.")}function Cl(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=Qn(t.userAgent,/Firefox\/(\d+)\./,1);else if(t.webkitGetUserMedia||r.isSecureContext===!1&&r.webkitRTCPeerConnection&&!r.RTCIceGatherer)e.browser="chrome",e.version=Qn(t.userAgent,/Chrom(e|ium)\/(\d+)\./,2);else if(t.mediaDevices&&t.userAgent.match(/Edge\/(\d+).(\d+)$/))e.browser="edge",e.version=Qn(t.userAgent,/Edge\/(\d+).(\d+)$/,2);else if(r.RTCPeerConnection&&t.userAgent.match(/AppleWebKit\/(\d+)\./))e.browser="safari",e.version=Qn(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 Go(r){return Object.prototype.toString.call(r)==="[object Object]"}function qa(r){return Go(r)?Object.keys(r).reduce(function(e,t){const n=Go(r[t]),i=n?qa(r[t]):r[t],s=n&&!Object.keys(i).length;return i===void 0||s?e:Object.assign(e,{[t]:i})},{}):r}function Ns(r,e,t){!e||t.has(e.id)||(t.set(e.id,e),Object.keys(e).forEach(n=>{n.endsWith("Id")?Ns(r,r.get(e[n]),t):n.endsWith("Ids")&&e[n].forEach(i=>{Ns(r,r.get(i),t)})}))}function $o(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&&Ns(r,o,i)})}),i}const Wo=ro;function Xa(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 f=function(p,m){return p?p+m.charAt(0).toUpperCase()+m.slice(1):m==="deviceId"?"sourceId":m};if(u.ideal!==void 0){c.optional=c.optional||[];let p={};typeof u.ideal=="number"?(p[f("min",l)]=u.ideal,c.optional.push(p),p={},p[f("max",l)]=u.ideal,c.optional.push(p)):(p[f("",l)]=u.ideal,c.optional.push(p))}u.exact!==void 0&&typeof u.exact!="number"?(c.mandatory=c.mandatory||{},c.mandatory[f("",l)]=u.exact):["min","max"].forEach(p=>{u[p]!==void 0&&(c.mandatory=c.mandatory||{},c.mandatory[f(p,l)]=u[p])})}),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,f,p){f in u&&!(p in u)&&(u[p]=u[f],delete u[f])};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 f;if(l.exact==="environment"||l.ideal==="environment"?f=["back","rear"]:(l.exact==="user"||l.ideal==="user")&&(f=["front"]),f)return t.mediaDevices.enumerateDevices().then(p=>{p=p.filter(_=>_.kind==="videoinput");let m=p.find(_=>f.some(T=>_.label.toLowerCase().includes(T)));return!m&&p.length&&f.includes("back")&&(m=p[p.length-1]),m&&(o.video.deviceId=l.exact?{exact:m.deviceId}:{ideal:m.deviceId}),o.video=n(o.video),Wo("chrome: "+JSON.stringify(o)),c(o)})}o.video=n(o.video)}return Wo("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,f=>{l&&l(s(f))})})};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(f=>{f.stop()}),new DOMException("","NotFoundError");return u},u=>Promise.reject(s(u))))})}}function wl(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(n){return e(n).then(i=>{const s=n.video&&n.video.width,a=n.video&&n.video.height,o=n.video&&n.video.frameRate;return n.video={mandatory:{chromeMediaSource:"desktop",chromeMediaSourceId:i,maxFrameRate:o||3}},s&&(n.video.mandatory.maxWidth=s),a&&(n.video.mandatory.maxHeight=a),r.navigator.mediaDevices.getUserMedia(n)})}}}function Ya(r){r.MediaStream=r.MediaStream||r.webkitMediaStream}function Za(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=n=>{n.stream.addEventListener("addtrack",i=>{let s;r.RTCPeerConnection.prototype.getReceivers?s=this.getReceivers().find(o=>o.track&&o.track.id===i.track.id):s={track:i.track};const a=new Event("track");a.track=i.track,a.receiver=s,a.transceiver={receiver:s},a.streams=[n.stream],this.dispatchEvent(a)}),n.stream.getTracks().forEach(i=>{let s;r.RTCPeerConnection.prototype.getReceivers?s=this.getReceivers().find(o=>o.track&&o.track.id===i.id):s={track:i};const a=new Event("track");a.track=i,a.receiver=s,a.transceiver={receiver:s},a.streams=[n.stream],this.dispatchEvent(a)})},this.addEventListener("addstream",this._ontrackpoly)),e.apply(this,arguments)}}else Dn(r,"track",e=>(e.transceiver||Object.defineProperty(e,"transceiver",{value:{receiver:e.receiver}}),e))}function Ka(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(o,c){let l=i.apply(this,arguments);return l||(l=e(this,o),this._senders.push(l)),l};const s=r.RTCPeerConnection.prototype.removeTrack;r.RTCPeerConnection.prototype.removeTrack=function(o){s.apply(this,arguments);const c=this._senders.indexOf(o);c!==-1&&this._senders.splice(c,1)}}const t=r.RTCPeerConnection.prototype.addStream;r.RTCPeerConnection.prototype.addStream=function(s){this._senders=this._senders||[],t.apply(this,[s]),s.getTracks().forEach(a=>{this._senders.push(e(this,a))})};const n=r.RTCPeerConnection.prototype.removeStream;r.RTCPeerConnection.prototype.removeStream=function(s){this._senders=this._senders||[],n.apply(this,[s]),s.getTracks().forEach(a=>{const o=this._senders.find(c=>c.track===a);o&&this._senders.splice(this._senders.indexOf(o),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 n=e.apply(this,[]);return n.forEach(i=>i._pc=this),n},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 Qa(r){if(!r.RTCPeerConnection)return;const e=r.RTCPeerConnection.prototype.getStats;r.RTCPeerConnection.prototype.getStats=function(){const[n,i,s]=arguments;if(arguments.length>0&&typeof n=="function")return e.apply(this,arguments);if(e.length===0&&(arguments.length===0||typeof n!="function"))return e.apply(this,[]);const a=function(c){const l={};return c.result().forEach(f=>{const p={id:f.id,timestamp:f.timestamp,type:{localcandidate:"local-candidate",remotecandidate:"remote-candidate"}[f.type]||f.type};f.names().forEach(m=>{p[m]=f.stat(m)}),l[p.id]=p}),l},o=function(c){return new Map(Object.keys(c).map(l=>[l,c[l]]))};if(arguments.length>=2){const c=function(l){i(o(a(l)))};return e.apply(this,[c,n])}return new Promise((c,l)=>{e.apply(this,[function(u){c(o(a(u)))},l])}).then(i,s)}}function ec(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 s=t.apply(this,[]);return s.forEach(a=>a._pc=this),s});const n=r.RTCPeerConnection.prototype.addTrack;n&&(r.RTCPeerConnection.prototype.addTrack=function(){const s=n.apply(this,arguments);return s._pc=this,s}),r.RTCRtpSender.prototype.getStats=function(){const s=this;return this._pc.getStats().then(a=>$o(a,s.track,!0))}}if(!("getStats"in r.RTCRtpReceiver.prototype)){const t=r.RTCPeerConnection.prototype.getReceivers;t&&(r.RTCPeerConnection.prototype.getReceivers=function(){const i=t.apply(this,[]);return i.forEach(s=>s._pc=this),i}),Dn(r,"track",n=>(n.receiver._pc=n.srcElement,n)),r.RTCRtpReceiver.prototype.getStats=function(){const i=this;return this._pc.getStats().then(s=>$o(s,i.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 n=arguments[0];let i,s,a;return this.getSenders().forEach(o=>{o.track===n&&(i?a=!0:i=o)}),this.getReceivers().forEach(o=>(o.track===n&&(s?a=!0:s=o),o.track===n)),a||i&&s?Promise.reject(new DOMException("There are more than one sender or receiver for the track.","InvalidAccessError")):i?i.getStats():s?s.getStats():Promise.reject(new DOMException("There is no sender or receiver for the track.","InvalidAccessError"))}return e.apply(this,arguments)}}function tc(r){r.RTCPeerConnection.prototype.getLocalStreams=function(){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},Object.keys(this._shimmedLocalStreams).map(a=>this._shimmedLocalStreams[a][0])};const e=r.RTCPeerConnection.prototype.addTrack;r.RTCPeerConnection.prototype.addTrack=function(a,o){if(!o)return e.apply(this,arguments);this._shimmedLocalStreams=this._shimmedLocalStreams||{};const c=e.apply(this,arguments);return this._shimmedLocalStreams[o.id]?this._shimmedLocalStreams[o.id].indexOf(c)===-1&&this._shimmedLocalStreams[o.id].push(c):this._shimmedLocalStreams[o.id]=[o,c],c};const t=r.RTCPeerConnection.prototype.addStream;r.RTCPeerConnection.prototype.addStream=function(a){this._shimmedLocalStreams=this._shimmedLocalStreams||{},a.getTracks().forEach(l=>{if(this.getSenders().find(f=>f.track===l))throw new DOMException("Track already exists.","InvalidAccessError")});const o=this.getSenders();t.apply(this,arguments);const c=this.getSenders().filter(l=>o.indexOf(l)===-1);this._shimmedLocalStreams[a.id]=[a].concat(c)};const n=r.RTCPeerConnection.prototype.removeStream;r.RTCPeerConnection.prototype.removeStream=function(a){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},delete this._shimmedLocalStreams[a.id],n.apply(this,arguments)};const i=r.RTCPeerConnection.prototype.removeTrack;r.RTCPeerConnection.prototype.removeTrack=function(a){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},a&&Object.keys(this._shimmedLocalStreams).forEach(o=>{const c=this._shimmedLocalStreams[o].indexOf(a);c!==-1&&this._shimmedLocalStreams[o].splice(c,1),this._shimmedLocalStreams[o].length===1&&delete this._shimmedLocalStreams[o]}),i.apply(this,arguments)}}function nc(r,e){if(!r.RTCPeerConnection)return;if(r.RTCPeerConnection.prototype.addTrack&&e.version>=65)return tc(r);const t=r.RTCPeerConnection.prototype.getLocalStreams;r.RTCPeerConnection.prototype.getLocalStreams=function(){const u=t.apply(this);return this._reverseStreams=this._reverseStreams||{},u.map(f=>this._reverseStreams[f.id])};const n=r.RTCPeerConnection.prototype.addStream;r.RTCPeerConnection.prototype.addStream=function(u){if(this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},u.getTracks().forEach(f=>{if(this.getSenders().find(m=>m.track===f))throw new DOMException("Track already exists.","InvalidAccessError")}),!this._reverseStreams[u.id]){const f=new r.MediaStream(u.getTracks());this._streams[u.id]=f,this._reverseStreams[f.id]=u,u=f}n.apply(this,[u])};const i=r.RTCPeerConnection.prototype.removeStream;r.RTCPeerConnection.prototype.removeStream=function(u){this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},i.apply(this,[this._streams[u.id]||u]),delete this._reverseStreams[this._streams[u.id]?this._streams[u.id].id:u.id],delete this._streams[u.id]},r.RTCPeerConnection.prototype.addTrack=function(u,f){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(T=>T===u))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(T=>T.track===u))throw new DOMException("Track already exists.","InvalidAccessError");this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{};const _=this._streams[f.id];if(_)_.addTrack(u),Promise.resolve().then(()=>{this.dispatchEvent(new Event("negotiationneeded"))});else{const T=new r.MediaStream([u]);this._streams[f.id]=T,this._reverseStreams[T.id]=f,this.addStream(T)}return this.getSenders().find(T=>T.track===u)};function s(l,u){let f=u.sdp;return Object.keys(l._reverseStreams||[]).forEach(p=>{const m=l._reverseStreams[p],_=l._streams[m.id];f=f.replace(new RegExp(_.id,"g"),m.id)}),new RTCSessionDescription({type:u.type,sdp:f})}function a(l,u){let f=u.sdp;return Object.keys(l._reverseStreams||[]).forEach(p=>{const m=l._reverseStreams[p],_=l._streams[m.id];f=f.replace(new RegExp(m.id,"g"),_.id)}),new RTCSessionDescription({type:u.type,sdp:f})}["createOffer","createAnswer"].forEach(function(l){const u=r.RTCPeerConnection.prototype[l],f={[l](){const p=arguments;return arguments.length&&typeof arguments[0]=="function"?u.apply(this,[_=>{const T=s(this,_);p[0].apply(null,[T])},_=>{p[1]&&p[1].apply(null,_)},arguments[2]]):u.apply(this,arguments).then(_=>s(this,_))}};r.RTCPeerConnection.prototype[l]=f[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(u){if(this.signalingState==="closed")throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");if(!u._pc)throw new DOMException("Argument 1 of RTCPeerConnection.removeTrack does not implement interface RTCRtpSender.","TypeError");if(!(u._pc===this))throw new DOMException("Sender was not created by this connection.","InvalidAccessError");this._streams=this._streams||{};let p;Object.keys(this._streams).forEach(m=>{this._streams[m].getTracks().find(T=>u.track===T)&&(p=this._streams[m])}),p&&(p.getTracks().length===1?this.removeStream(this._reverseStreams[p.id]):p.removeTrack(u.track),this.dispatchEvent(new Event("negotiationneeded")))}}function Us(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 ic(r,e){Dn(r,"negotiationneeded",t=>{const n=t.target;if(!((e.version<72||n.getConfiguration&&n.getConfiguration().sdpSemantics==="plan-b")&&n.signalingState!=="stable"))return t})}const Ho=Object.freeze(Object.defineProperty({__proto__:null,fixNegotiationNeeded:ic,shimAddTrackRemoveTrack:nc,shimAddTrackRemoveTrackWithNative:tc,shimGetDisplayMedia:wl,shimGetSendersWithDtmf:Ka,shimGetStats:Qa,shimGetUserMedia:Xa,shimMediaStream:Ya,shimOnTrack:Za,shimPeerConnection:Us,shimSenderReceiverGetStats:ec},Symbol.toStringTag,{value:"Module"}));function Pl(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&&Lr("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 as={exports:{}},qo;function rc(){return qo||(qo=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
+ "use strict";const R=require("./three-qj71I7J3.umd.cjs"),Ae={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 Ga(r){const e=await fetch(r);if(e.ok)return e.json();throw new Error(e.statusText)}async function pl(r){return await Ga(`${r}/profilesList.json`)}async function ml(r,e,t=null,n=!0){if(!r)throw new Error("No xrInputSource supplied");const i=await pl(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 Ga(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 yl={xAxis:0,yAxis:0,button:0,state:Ae.ComponentState.DEFAULT};function gl(r=0,e=0){let t=r,n=e;if(Math.sqrt(r*r+e*e)>1){const a=Math.atan2(e,r);t=Math.cos(a),n=Math.sin(a)}return{normalizedXAxis:t*.5+.5,normalizedYAxis:n*.5+.5}}class vl{constructor(e){this.componentProperty=e.componentProperty,this.states=e.states,this.valueNodeName=e.valueNodeName,this.valueNodeProperty=e.valueNodeProperty,this.valueNodeProperty===Ae.VisualResponseProperty.TRANSFORM&&(this.minNodeName=e.minNodeName,this.maxNodeName=e.maxNodeName),this.value=0,this.updateFromComponent(yl)}updateFromComponent({xAxis:e,yAxis:t,button:n,state:i}){const{normalizedXAxis:s,normalizedYAxis:a}=gl(e,t);switch(this.componentProperty){case Ae.ComponentProperty.X_AXIS:this.value=this.states.includes(i)?s:.5;break;case Ae.ComponentProperty.Y_AXIS:this.value=this.states.includes(i)?a:.5;break;case Ae.ComponentProperty.BUTTON:this.value=this.states.includes(i)?n:0;break;case Ae.ComponentProperty.STATE:this.valueNodeProperty===Ae.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 Sl{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 vl(t.visualResponses[n]);this.visualResponses[n]=i}),this.gamepadIndices=Object.assign({},t.gamepadIndices),this.values={state:Ae.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=Ae.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=Ae.ComponentState.PRESSED:(t.touched||this.values.button>Ae.ButtonTouchThreshold)&&(this.values.state=Ae.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===Ae.ComponentState.DEFAULT&&Math.abs(this.values.xAxis)>Ae.AxisTouchThreshold&&(this.values.state=Ae.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===Ae.ComponentState.DEFAULT&&Math.abs(this.values.yAxis)>Ae.AxisTouchThreshold&&(this.values.state=Ae.ComponentState.TOUCHED)),Object.values(this.visualResponses).forEach(t=>{t.updateFromComponent(this.values)})}}class xl{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 Sl(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 rs=2,At=4,jt=4,$a=4,Zt=new Int32Array(2),Do=new Float32Array(Zt.buffer),Fo=new Float64Array(Zt.buffer),Zi=new Uint16Array(new Uint8Array([1,0]).buffer)[0]===1;class $t{constructor(e,t){this.low=e|0,this.high=t|0}static create(e,t){return e==0&&t==0?$t.ZERO:new $t(e,t)}toFloat64(){return(this.low>>>0)+this.high*4294967296}equals(e){return this.low==e.low&&this.high==e.high}}$t.ZERO=new $t(0,0);var Bs;(function(r){r[r.UTF8_BYTES=1]="UTF8_BYTES",r[r.UTF16_STRING=2]="UTF16_STRING"})(Bs||(Bs={}));class ai{constructor(e){this.bytes_=e,this.position_=0}static allocate(e){return new ai(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 $t(this.readInt32(e),this.readInt32(e+4))}readUint64(e){return new $t(this.readUint32(e),this.readUint32(e+4))}readFloat32(e){return Zt[0]=this.readInt32(e),Do[0]}readFloat64(e){return Zt[Zi?0:1]=this.readInt32(e),Zt[Zi?1:0]=this.readInt32(e+4),Fo[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){Do[0]=t,this.writeInt32(e,Zt[0])}writeFloat64(e,t){Fo[0]=t,this.writeInt32(e,Zt[Zi?0:1]),this.writeInt32(e+4,Zt[Zi?1:0])}getBufferIdentifier(){if(this.bytes_.length<this.position_+At+jt)throw new Error("FlatBuffers: ByteBuffer is too short to contain an identifier.");let e="";for(let t=0;t<jt;t++)e+=String.fromCharCode(this.readInt8(this.position_+At+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+=At,t===Bs.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)+At}__vector_len(e){return this.readInt32(e+this.readInt32(e))}__has_identifier(e){if(e.length!=jt)throw new Error("FlatBuffers: file identifier must be length "+jt);for(let t=0;t<jt;t++)if(e.charCodeAt(t)!=this.readInt8(this.position()+At+t))return!1;return!0}createLong(e,t){return $t.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 io{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=ai.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=io.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=ai.allocate(n);return i.setPosition(n-t),i.bytes().set(e.bytes(),n-t),i}addOffset(e){this.prep(At,0),this.writeInt32(this.offset()-e+At)}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)*rs;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=rs;l<s;l+=rs)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?$a:0;if(t){const s=t;if(this.prep(this.minalign,At+jt+i),s.length!=jt)throw new Error("FlatBuffers: file identifier must be length "+jt);for(let a=jt-1;a>=0;a--)this.writeInt8(s.charCodeAt(a))}this.prep(this.minalign,At+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(At,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 $t.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 Fr(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var ss={exports:{}},Lo;function Vo(){return Lo||(Lo=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})(ss)),ss.exports}var os,Jo;function _l(){if(Jo)return os;Jo=1;var r=Vo().BufferBuilder,e=Vo().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}};os=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="",f,p;l<o;)f=c[l],f<128?(u+=String.fromCharCode(f),l++):(f^192)<32?(p=(f^192)<<6|c[l+1]&63,u+=String.fromCharCode(p),l+=2):(p=(f&15)<<12|(c[l+1]&63)<<6|c[l+2]&63,u+=String.fromCharCode(p),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(),f=this.unpack();c[u]=f}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,f=o&1048575|1048576,p=f*Math.pow(2,u-20)+c*Math.pow(2,u-52);return(l===0?1:-1)*p},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,f=Math.floor(u*Math.pow(2,52)),p=Math.pow(2,32),m=c<<31|l+1023<<20|f/p&1048575,_=f%p;this.bufferBuilder.append(203),this.pack_int32(m),this.pack_int32(_)},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 os}var bl=_l();const jo=Fr(bl);let Wa=!0,Ha=!0;function Qn(r,e,t){const n=r.match(e);return n&&n.length>=t&&parseInt(n[t],10)}function Dn(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 Tl(r){return typeof r!="boolean"?new Error("Argument type: "+typeof r+". Please use a boolean."):(Wa=r,r?"adapter.js logging disabled":"adapter.js logging enabled")}function Ml(r){return typeof r!="boolean"?new Error("Argument type: "+typeof r+". Please use a boolean."):(Ha=!r,"adapter.js deprecation warnings "+(r?"disabled":"enabled"))}function ro(){if(typeof window=="object"){if(Wa)return;typeof console<"u"&&typeof console.log=="function"&&console.log.apply(console,arguments)}}function Lr(r,e){Ha&&console.warn(r+" is deprecated, please use "+e+" instead.")}function Cl(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=Qn(t.userAgent,/Firefox\/(\d+)\./,1);else if(t.webkitGetUserMedia||r.isSecureContext===!1&&r.webkitRTCPeerConnection&&!r.RTCIceGatherer)e.browser="chrome",e.version=Qn(t.userAgent,/Chrom(e|ium)\/(\d+)\./,2);else if(t.mediaDevices&&t.userAgent.match(/Edge\/(\d+).(\d+)$/))e.browser="edge",e.version=Qn(t.userAgent,/Edge\/(\d+).(\d+)$/,2);else if(r.RTCPeerConnection&&t.userAgent.match(/AppleWebKit\/(\d+)\./))e.browser="safari",e.version=Qn(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 Go(r){return Object.prototype.toString.call(r)==="[object Object]"}function qa(r){return Go(r)?Object.keys(r).reduce(function(e,t){const n=Go(r[t]),i=n?qa(r[t]):r[t],s=n&&!Object.keys(i).length;return i===void 0||s?e:Object.assign(e,{[t]:i})},{}):r}function Ns(r,e,t){!e||t.has(e.id)||(t.set(e.id,e),Object.keys(e).forEach(n=>{n.endsWith("Id")?Ns(r,r.get(e[n]),t):n.endsWith("Ids")&&e[n].forEach(i=>{Ns(r,r.get(i),t)})}))}function $o(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&&Ns(r,o,i)})}),i}const Wo=ro;function Xa(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 f=function(p,m){return p?p+m.charAt(0).toUpperCase()+m.slice(1):m==="deviceId"?"sourceId":m};if(u.ideal!==void 0){c.optional=c.optional||[];let p={};typeof u.ideal=="number"?(p[f("min",l)]=u.ideal,c.optional.push(p),p={},p[f("max",l)]=u.ideal,c.optional.push(p)):(p[f("",l)]=u.ideal,c.optional.push(p))}u.exact!==void 0&&typeof u.exact!="number"?(c.mandatory=c.mandatory||{},c.mandatory[f("",l)]=u.exact):["min","max"].forEach(p=>{u[p]!==void 0&&(c.mandatory=c.mandatory||{},c.mandatory[f(p,l)]=u[p])})}),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,f,p){f in u&&!(p in u)&&(u[p]=u[f],delete u[f])};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 f;if(l.exact==="environment"||l.ideal==="environment"?f=["back","rear"]:(l.exact==="user"||l.ideal==="user")&&(f=["front"]),f)return t.mediaDevices.enumerateDevices().then(p=>{p=p.filter(_=>_.kind==="videoinput");let m=p.find(_=>f.some(T=>_.label.toLowerCase().includes(T)));return!m&&p.length&&f.includes("back")&&(m=p[p.length-1]),m&&(o.video.deviceId=l.exact?{exact:m.deviceId}:{ideal:m.deviceId}),o.video=n(o.video),Wo("chrome: "+JSON.stringify(o)),c(o)})}o.video=n(o.video)}return Wo("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,f=>{l&&l(s(f))})})};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(f=>{f.stop()}),new DOMException("","NotFoundError");return u},u=>Promise.reject(s(u))))})}}function wl(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(n){return e(n).then(i=>{const s=n.video&&n.video.width,a=n.video&&n.video.height,o=n.video&&n.video.frameRate;return n.video={mandatory:{chromeMediaSource:"desktop",chromeMediaSourceId:i,maxFrameRate:o||3}},s&&(n.video.mandatory.maxWidth=s),a&&(n.video.mandatory.maxHeight=a),r.navigator.mediaDevices.getUserMedia(n)})}}}function Ya(r){r.MediaStream=r.MediaStream||r.webkitMediaStream}function Za(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=n=>{n.stream.addEventListener("addtrack",i=>{let s;r.RTCPeerConnection.prototype.getReceivers?s=this.getReceivers().find(o=>o.track&&o.track.id===i.track.id):s={track:i.track};const a=new Event("track");a.track=i.track,a.receiver=s,a.transceiver={receiver:s},a.streams=[n.stream],this.dispatchEvent(a)}),n.stream.getTracks().forEach(i=>{let s;r.RTCPeerConnection.prototype.getReceivers?s=this.getReceivers().find(o=>o.track&&o.track.id===i.id):s={track:i};const a=new Event("track");a.track=i,a.receiver=s,a.transceiver={receiver:s},a.streams=[n.stream],this.dispatchEvent(a)})},this.addEventListener("addstream",this._ontrackpoly)),e.apply(this,arguments)}}else Dn(r,"track",e=>(e.transceiver||Object.defineProperty(e,"transceiver",{value:{receiver:e.receiver}}),e))}function Ka(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(o,c){let l=i.apply(this,arguments);return l||(l=e(this,o),this._senders.push(l)),l};const s=r.RTCPeerConnection.prototype.removeTrack;r.RTCPeerConnection.prototype.removeTrack=function(o){s.apply(this,arguments);const c=this._senders.indexOf(o);c!==-1&&this._senders.splice(c,1)}}const t=r.RTCPeerConnection.prototype.addStream;r.RTCPeerConnection.prototype.addStream=function(s){this._senders=this._senders||[],t.apply(this,[s]),s.getTracks().forEach(a=>{this._senders.push(e(this,a))})};const n=r.RTCPeerConnection.prototype.removeStream;r.RTCPeerConnection.prototype.removeStream=function(s){this._senders=this._senders||[],n.apply(this,[s]),s.getTracks().forEach(a=>{const o=this._senders.find(c=>c.track===a);o&&this._senders.splice(this._senders.indexOf(o),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 n=e.apply(this,[]);return n.forEach(i=>i._pc=this),n},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 Qa(r){if(!r.RTCPeerConnection)return;const e=r.RTCPeerConnection.prototype.getStats;r.RTCPeerConnection.prototype.getStats=function(){const[n,i,s]=arguments;if(arguments.length>0&&typeof n=="function")return e.apply(this,arguments);if(e.length===0&&(arguments.length===0||typeof n!="function"))return e.apply(this,[]);const a=function(c){const l={};return c.result().forEach(f=>{const p={id:f.id,timestamp:f.timestamp,type:{localcandidate:"local-candidate",remotecandidate:"remote-candidate"}[f.type]||f.type};f.names().forEach(m=>{p[m]=f.stat(m)}),l[p.id]=p}),l},o=function(c){return new Map(Object.keys(c).map(l=>[l,c[l]]))};if(arguments.length>=2){const c=function(l){i(o(a(l)))};return e.apply(this,[c,n])}return new Promise((c,l)=>{e.apply(this,[function(u){c(o(a(u)))},l])}).then(i,s)}}function ec(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 s=t.apply(this,[]);return s.forEach(a=>a._pc=this),s});const n=r.RTCPeerConnection.prototype.addTrack;n&&(r.RTCPeerConnection.prototype.addTrack=function(){const s=n.apply(this,arguments);return s._pc=this,s}),r.RTCRtpSender.prototype.getStats=function(){const s=this;return this._pc.getStats().then(a=>$o(a,s.track,!0))}}if(!("getStats"in r.RTCRtpReceiver.prototype)){const t=r.RTCPeerConnection.prototype.getReceivers;t&&(r.RTCPeerConnection.prototype.getReceivers=function(){const i=t.apply(this,[]);return i.forEach(s=>s._pc=this),i}),Dn(r,"track",n=>(n.receiver._pc=n.srcElement,n)),r.RTCRtpReceiver.prototype.getStats=function(){const i=this;return this._pc.getStats().then(s=>$o(s,i.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 n=arguments[0];let i,s,a;return this.getSenders().forEach(o=>{o.track===n&&(i?a=!0:i=o)}),this.getReceivers().forEach(o=>(o.track===n&&(s?a=!0:s=o),o.track===n)),a||i&&s?Promise.reject(new DOMException("There are more than one sender or receiver for the track.","InvalidAccessError")):i?i.getStats():s?s.getStats():Promise.reject(new DOMException("There is no sender or receiver for the track.","InvalidAccessError"))}return e.apply(this,arguments)}}function tc(r){r.RTCPeerConnection.prototype.getLocalStreams=function(){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},Object.keys(this._shimmedLocalStreams).map(a=>this._shimmedLocalStreams[a][0])};const e=r.RTCPeerConnection.prototype.addTrack;r.RTCPeerConnection.prototype.addTrack=function(a,o){if(!o)return e.apply(this,arguments);this._shimmedLocalStreams=this._shimmedLocalStreams||{};const c=e.apply(this,arguments);return this._shimmedLocalStreams[o.id]?this._shimmedLocalStreams[o.id].indexOf(c)===-1&&this._shimmedLocalStreams[o.id].push(c):this._shimmedLocalStreams[o.id]=[o,c],c};const t=r.RTCPeerConnection.prototype.addStream;r.RTCPeerConnection.prototype.addStream=function(a){this._shimmedLocalStreams=this._shimmedLocalStreams||{},a.getTracks().forEach(l=>{if(this.getSenders().find(f=>f.track===l))throw new DOMException("Track already exists.","InvalidAccessError")});const o=this.getSenders();t.apply(this,arguments);const c=this.getSenders().filter(l=>o.indexOf(l)===-1);this._shimmedLocalStreams[a.id]=[a].concat(c)};const n=r.RTCPeerConnection.prototype.removeStream;r.RTCPeerConnection.prototype.removeStream=function(a){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},delete this._shimmedLocalStreams[a.id],n.apply(this,arguments)};const i=r.RTCPeerConnection.prototype.removeTrack;r.RTCPeerConnection.prototype.removeTrack=function(a){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},a&&Object.keys(this._shimmedLocalStreams).forEach(o=>{const c=this._shimmedLocalStreams[o].indexOf(a);c!==-1&&this._shimmedLocalStreams[o].splice(c,1),this._shimmedLocalStreams[o].length===1&&delete this._shimmedLocalStreams[o]}),i.apply(this,arguments)}}function nc(r,e){if(!r.RTCPeerConnection)return;if(r.RTCPeerConnection.prototype.addTrack&&e.version>=65)return tc(r);const t=r.RTCPeerConnection.prototype.getLocalStreams;r.RTCPeerConnection.prototype.getLocalStreams=function(){const u=t.apply(this);return this._reverseStreams=this._reverseStreams||{},u.map(f=>this._reverseStreams[f.id])};const n=r.RTCPeerConnection.prototype.addStream;r.RTCPeerConnection.prototype.addStream=function(u){if(this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},u.getTracks().forEach(f=>{if(this.getSenders().find(m=>m.track===f))throw new DOMException("Track already exists.","InvalidAccessError")}),!this._reverseStreams[u.id]){const f=new r.MediaStream(u.getTracks());this._streams[u.id]=f,this._reverseStreams[f.id]=u,u=f}n.apply(this,[u])};const i=r.RTCPeerConnection.prototype.removeStream;r.RTCPeerConnection.prototype.removeStream=function(u){this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},i.apply(this,[this._streams[u.id]||u]),delete this._reverseStreams[this._streams[u.id]?this._streams[u.id].id:u.id],delete this._streams[u.id]},r.RTCPeerConnection.prototype.addTrack=function(u,f){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(T=>T===u))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(T=>T.track===u))throw new DOMException("Track already exists.","InvalidAccessError");this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{};const _=this._streams[f.id];if(_)_.addTrack(u),Promise.resolve().then(()=>{this.dispatchEvent(new Event("negotiationneeded"))});else{const T=new r.MediaStream([u]);this._streams[f.id]=T,this._reverseStreams[T.id]=f,this.addStream(T)}return this.getSenders().find(T=>T.track===u)};function s(l,u){let f=u.sdp;return Object.keys(l._reverseStreams||[]).forEach(p=>{const m=l._reverseStreams[p],_=l._streams[m.id];f=f.replace(new RegExp(_.id,"g"),m.id)}),new RTCSessionDescription({type:u.type,sdp:f})}function a(l,u){let f=u.sdp;return Object.keys(l._reverseStreams||[]).forEach(p=>{const m=l._reverseStreams[p],_=l._streams[m.id];f=f.replace(new RegExp(m.id,"g"),_.id)}),new RTCSessionDescription({type:u.type,sdp:f})}["createOffer","createAnswer"].forEach(function(l){const u=r.RTCPeerConnection.prototype[l],f={[l](){const p=arguments;return arguments.length&&typeof arguments[0]=="function"?u.apply(this,[_=>{const T=s(this,_);p[0].apply(null,[T])},_=>{p[1]&&p[1].apply(null,_)},arguments[2]]):u.apply(this,arguments).then(_=>s(this,_))}};r.RTCPeerConnection.prototype[l]=f[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(u){if(this.signalingState==="closed")throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");if(!u._pc)throw new DOMException("Argument 1 of RTCPeerConnection.removeTrack does not implement interface RTCRtpSender.","TypeError");if(!(u._pc===this))throw new DOMException("Sender was not created by this connection.","InvalidAccessError");this._streams=this._streams||{};let p;Object.keys(this._streams).forEach(m=>{this._streams[m].getTracks().find(T=>u.track===T)&&(p=this._streams[m])}),p&&(p.getTracks().length===1?this.removeStream(this._reverseStreams[p.id]):p.removeTrack(u.track),this.dispatchEvent(new Event("negotiationneeded")))}}function Us(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 ic(r,e){Dn(r,"negotiationneeded",t=>{const n=t.target;if(!((e.version<72||n.getConfiguration&&n.getConfiguration().sdpSemantics==="plan-b")&&n.signalingState!=="stable"))return t})}const Ho=Object.freeze(Object.defineProperty({__proto__:null,fixNegotiationNeeded:ic,shimAddTrackRemoveTrack:nc,shimAddTrackRemoveTrackWithNative:tc,shimGetDisplayMedia:wl,shimGetSendersWithDtmf:Ka,shimGetStats:Qa,shimGetUserMedia:Xa,shimMediaStream:Ya,shimOnTrack:Za,shimPeerConnection:Us,shimSenderReceiverGetStats:ec},Symbol.toStringTag,{value:"Module"}));function Pl(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&&Lr("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 as={exports:{}},qo;function rc(){return qo||(qo=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
@@ -75,12 +75,7 @@ a=extmap-allow-mixed`)!==-1){const s=i.sdp.split(`
75
75
  isIOS:`).concat(this.isIOS,`
76
76
  isWebRTCSupported:`).concat(this.isWebRTCSupported(),`
77
77
  isBrowserSupported:`).concat(this.isBrowserSupported(),`
78
- isUnifiedPlanSupported:`).concat(this.isUnifiedPlanSupported())},r})()),ea={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"},Bl=(function(){function r(){this.CLOUD_HOST="0.peerjs.com",this.CLOUD_PORT=443,this.chunkedBrowsers={Chrome:1,chrome:1},this.chunkedMTU=16300,this.defaultConfig=ea,this.browser=Jn.getBrowser(),this.browserVersion=Jn.getVersion(),this.supports=(function(){var e={browser:Jn.isBrowserSupported(),webRTC:Jn.isWebRTCSupported(),audioVideo:!1,data:!1,binaryBlob:!1,reliable:!1};if(!e.webRTC)return e;var t;try{t=new RTCPeerConnection(ea),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=!Jn.isIOS}catch{}}catch{}finally{n&&n.close()}}catch{}finally{t&&t.close()}return e})(),this.pack=jo.pack,this.unpack=jo.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 Bl,Pc={};zt(Pc,"Peer",()=>Gs,r=>Gs=r);var Vi={},Nl=Object.prototype.hasOwnProperty,Xe="~";function ci(){}Object.create&&(ci.prototype=Object.create(null),new ci().__proto__||(Xe=!1));function Ul(r,e,t){this.fn=r,this.context=e,this.once=t||!1}function Ec(r,e,t,n,i){if(typeof t!="function")throw new TypeError("The listener must be a function");var s=new Ul(t,n||r,i),a=Xe?Xe+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 Pr(r,e){--r._eventsCount===0?r._events=new ci:delete r._events[e]}function Ve(){this._events=new ci,this._eventsCount=0}Ve.prototype.eventNames=function(){var e=[],t,n;if(this._eventsCount===0)return e;for(n in t=this._events)Nl.call(t,n)&&e.push(Xe?n.slice(1):n);return Object.getOwnPropertySymbols?e.concat(Object.getOwnPropertySymbols(t)):e};Ve.prototype.listeners=function(e){var t=Xe?Xe+e:e,n=this._events[t];if(!n)return[];if(n.fn)return[n.fn];for(var i=0,s=n.length,a=new Array(s);i<s;i++)a[i]=n[i].fn;return a};Ve.prototype.listenerCount=function(e){var t=Xe?Xe+e:e,n=this._events[t];return n?n.fn?1:n.length:0};Ve.prototype.emit=function(e,t,n,i,s,a){var o=Xe?Xe+e:e;if(!this._events[o])return!1;var c=this._events[o],l=arguments.length,u,f;if(c.fn){switch(c.once&&this.removeListener(e,c.fn,void 0,!0),l){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,t),!0;case 3:return c.fn.call(c.context,t,n),!0;case 4:return c.fn.call(c.context,t,n,i),!0;case 5:return c.fn.call(c.context,t,n,i,s),!0;case 6:return c.fn.call(c.context,t,n,i,s,a),!0}for(f=1,u=new Array(l-1);f<l;f++)u[f-1]=arguments[f];c.fn.apply(c.context,u)}else{var p=c.length,m;for(f=0;f<p;f++)switch(c[f].once&&this.removeListener(e,c[f].fn,void 0,!0),l){case 1:c[f].fn.call(c[f].context);break;case 2:c[f].fn.call(c[f].context,t);break;case 3:c[f].fn.call(c[f].context,t,n);break;case 4:c[f].fn.call(c[f].context,t,n,i);break;default:if(!u)for(m=1,u=new Array(l-1);m<l;m++)u[m-1]=arguments[m];c[f].fn.apply(c[f].context,u)}}return!0};Ve.prototype.on=function(e,t,n){return Ec(this,e,t,n,!1)};Ve.prototype.once=function(e,t,n){return Ec(this,e,t,n,!0)};Ve.prototype.removeListener=function(e,t,n,i){var s=Xe?Xe+e:e;if(!this._events[s])return this;if(!t)return Pr(this,s),this;var a=this._events[s];if(a.fn)a.fn===t&&(!i||a.once)&&(!n||a.context===n)&&Pr(this,s);else{for(var o=0,c=[],l=a.length;o<l;o++)(a[o].fn!==t||i&&!a[o].once||n&&a[o].context!==n)&&c.push(a[o]);c.length?this._events[s]=c.length===1?c[0]:c:Pr(this,s)}return this};Ve.prototype.removeAllListeners=function(e){var t;return e?(t=Xe?Xe+e:e,this._events[t]&&Pr(this,t)):(this._events=new ci,this._eventsCount=0),this};Ve.prototype.off=Ve.prototype.removeListener;Ve.prototype.addListener=Ve.prototype.on;Ve.prefixed=Xe;Ve.EventEmitter=Ve;Vi=Ve;var $={};zt($,"LogLevel",()=>Qe,r=>Qe=r);zt($,"default",()=>ta,r=>ta=r);var on=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},an=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))},Dl="PeerJS: ",Qe;(function(r){r[r.Disabled=0]="Disabled",r[r.Errors=1]="Errors",r[r.Warnings=2]="Warnings",r[r.All=3]="All"})(Qe||(Qe={}));var Fl=(function(){function r(){this._logLevel=Qe.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>=Qe.All&&this._print.apply(this,an([Qe.All],on(e),!1))},r.prototype.warn=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this._logLevel>=Qe.Warnings&&this._print.apply(this,an([Qe.Warnings],on(e),!1))},r.prototype.error=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this._logLevel>=Qe.Errors&&this._print.apply(this,an([Qe.Errors],on(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=an([Dl],on(t),!1);for(var s in i)i[s]instanceof Error&&(i[s]="("+i[s].name+") "+i[s].message);e>=Qe.All?console.log.apply(console,an([],on(i),!1)):e>=Qe.Warnings?console.warn.apply(console,an(["WARNING"],on(i),!1)):e>=Qe.Errors&&console.error.apply(console,an(["ERROR"],on(i),!1))},r})(),ta=new Fl,kc={};zt(kc,"Socket",()=>na,r=>na=r);var Ct;(function(r){r.Data="data",r.Media="media"})(Ct||(Ct={}));var _e;(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"})(_e||(_e={}));var Vt;(function(r){r.Binary="binary",r.BinaryUTF8="binary-utf8",r.JSON="json"})(Vt||(Vt={}));var Gt;(function(r){r.Message="message",r.Disconnected="disconnected",r.Error="error",r.Close="close"})(Gt||(Gt={}));var Ne;(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"})(Ne||(Ne={}));var so={};so=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ückler <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>","Sören 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 Ll=(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)}})(),Vl=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},Jl=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))},jl=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.")},na=(function(r){Ll(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="+so.version),this._disconnected=!1,this._socket.onmessage=function(a){var o;try{o=JSON.parse(a.data),$.default.log("Server message received:",o)}catch{$.default.log("Invalid server message",a.data);return}i.emit(Gt.Message,o)},this._socket.onclose=function(a){i._disconnected||($.default.log("Socket closed.",a),i._cleanup(),i._disconnected=!0,i.emit(Gt.Disconnected))},this._socket.onopen=function(){i._disconnected||(i._sendQueuedMessages(),$.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()){$.default.log("Cannot send heartbeat, because socket closed");return}var t=JSON.stringify({type:Ne.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=Jl([],Vl(this._messagesQueue),!1);this._messagesQueue=[];try{for(var s=jl(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(Gt.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})(Vi.EventEmitter),Js={};zt(Js,"MediaConnection",()=>sa,r=>sa=r);var oo={};zt(oo,"Negotiator",()=>ia,r=>ia=r);var kr=function(){return kr=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},kr.apply(this,arguments)},Ki=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(f){a(f)}}function c(u){try{l(n.throw(u))}catch(f){a(f)}}function l(u){u.done?s(u.value):i(u.value).then(o,c)}l((n=n.apply(r,e||[])).next())})},Qi=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}}},ia=(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===Ct.Media&&e._stream&&this._addTracksToConnection(e._stream,t),e.originator){if(this.connection.type===Ct.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(){$.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;$.default.log("Listening for ICE candidates."),e.onicecandidate=function(o){!o.candidate||!o.candidate.candidate||($.default.log("Received ICE candidates for ".concat(n,":"),o.candidate),a.socket.send({type:Ne.Candidate,payload:{candidate:o.candidate,type:s,connectionId:i},dst:n}))},e.oniceconnectionstatechange=function(){switch(e.iceConnectionState){case"failed":$.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":$.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":$.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)},$.default.log("Listening for data channel"),e.ondatachannel=function(o){$.default.log("Received data channel");var c=o.channel,l=a.getConnection(n,i);l.initialize(c)},$.default.log("Listening for remote stream"),e.ontrack=function(o){$.default.log("Received remote stream");var c=o.streams[0],l=a.getConnection(n,i);if(l.type===Ct.Media){var u=l;t._addStreamToMediaConnection(c,u)}}},r.prototype.cleanup=function(){$.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===Ct.Data){var i=this.connection,s=i.dataChannel;s&&(n=!!s.readyState&&s.readyState!=="closed")}(t||n)&&e.close()}},r.prototype._makeOffer=function(){return Ki(this,void 0,Promise,function(){var e,t,n,i,s,a,o;return Qi(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(),$.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(),$.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===Ct.Data&&(s=this.connection,i=kr(kr({},i),{label:s.label,reliable:s.reliable,serialization:s.serialization})),t.socket.send({type:Ne.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(_e.WebRTC,a),$.default.log("Failed to setLocalDescription, ",a)),[3,6];case 6:return[3,8];case 7:return o=c.sent(),t.emitError(_e.WebRTC,o),$.default.log("Failed to createOffer, ",o),[3,8];case 8:return[2]}})})},r.prototype._makeAnswer=function(){return Ki(this,void 0,Promise,function(){var e,t,n,i,s;return Qi(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(),$.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(),$.default.log("Set localDescription:",n,"for:".concat(this.connection.peer)),t.socket.send({type:Ne.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(_e.WebRTC,i),$.default.log("Failed to setLocalDescription, ",i),[3,6];case 6:return[3,8];case 7:return s=a.sent(),t.emitError(_e.WebRTC,s),$.default.log("Failed to create answer, ",s),[3,8];case 8:return[2]}})})},r.prototype.handleSDP=function(e,t){return Ki(this,void 0,Promise,function(){var n,i,s,a;return Qi(this,function(o){switch(o.label){case 0:t=new RTCSessionDescription(t),n=this.connection.peerConnection,i=this.connection.provider,$.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(),$.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(_e.WebRTC,a),$.default.log("Failed to setRemoteDescription, ",a),[3,6];case 6:return[2]}})})},r.prototype.handleCandidate=function(e){return Ki(this,void 0,Promise,function(){var t,n,i,s,a,o;return Qi(this,function(c){switch(c.label){case 0:$.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(),$.default.log("Added ICE candidate for:".concat(this.connection.peer)),[3,4];case 3:return o=c.sent(),a.emitError(_e.WebRTC,o),$.default.log("Failed to handleCandidate, ",o),[3,4];case 4:return[2]}})})},r.prototype._addTracksToConnection=function(e,t){if($.default.log("add tracks from stream ".concat(e.id," to peer connection")),!t.addTrack)return $.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){$.default.log("add stream ".concat(e.id," to media connection ").concat(t.connectionId)),t.addStream(e)},r})(),ao={};zt(ao,"BaseConnection",()=>ra,r=>ra=r);var Gl=(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)}})(),ra=(function(r){Gl(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})(Vi.EventEmitter),$l=(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)}})(),Rr=function(){return Rr=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},Rr.apply(this,arguments)},Wl=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.")},sa=(function(r){$l(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 oo.Negotiator(s),s._localStream&&s._negotiator.startConnection({_stream:s._localStream,originator:!0}),s}return Object.defineProperty(e.prototype,"type",{get:function(){return Ct.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){$.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 Ne.Answer:this._negotiator.handleSDP(n,i.sdp),this._open=!0;break;case Ne.Candidate:this._negotiator.handleCandidate(i.candidate);break;default:$.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){$.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(Rr(Rr({},this.options._payload),{_stream:t}));var a=this.provider._getMessages(this.connectionId);try{for(var o=Wl(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})(ao.BaseConnection),js={};zt(js,"DataConnection",()=>aa,r=>aa=r);var Rc={};zt(Rc,"EncodingQueue",()=>oa,r=>oa=r);var Hl=(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)}})(),oa=(function(r){Hl(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){$.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})(Vi.EventEmitter),ql=(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)}})(),Xl=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.")},aa=(function(r){ql(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 Rc.EncodingQueue,s.connectionId=s.options.connectionId||e.ID_PREFIX+te.randomToken(),s.label=s.options.label||s.connectionId,s.serialization=s.options.serialization||Vt.Binary,s.reliable=!!s.options.reliable,s._encodingQueue.on("done",function(a){s._bufferedSend(a)}),s._encodingQueue.on("error",function(){$.default.error("DC#".concat(s.connectionId,": Error occured in encoding from blob to arraybuffer, close DC")),s.close()}),s._negotiator=new oo.Negotiator(s),s._negotiator.startConnection(s.options._payload||{originator:!0}),s}return Object.defineProperty(e.prototype,"type",{get:function(){return Ct.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(){$.default.log("DC#".concat(t.connectionId," dc connection success")),t._open=!0,t.emit("open")},this.dataChannel.onmessage=function(n){$.default.log("DC#".concat(t.connectionId," dc onmessage:"),n.data),t._handleDataMessage(n)},this.dataChannel.onclose=function(){$.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===Vt.Binary||this.serialization===Vt.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===Vt.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===Vt.JSON)this._bufferedSend(this.stringify(t));else if(this.serialization===Vt.Binary||this.serialization===Vt.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 $.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);$.default.log("DC#".concat(this.connectionId," Try to send ").concat(s.length," chunks..."));try{for(var a=Xl(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 Ne.Answer:this._negotiator.handleSDP(t.type,n.sdp);break;case Ne.Candidate:this._negotiator.handleCandidate(n.candidate);break;default:$.default.warn("Unrecognized message type:",t.type,"from peer:",this.peer);break}},e.ID_PREFIX="dc_",e.MAX_BUFFERED_AMOUNT=8388608,e})(ao.BaseConnection),Ac={};zt(Ac,"API",()=>ua,r=>ua=r);var ca=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(f){a(f)}}function c(u){try{l(n.throw(u))}catch(f){a(f)}}function l(u){u.done?s(u.value):i(u.value).then(o,c)}l((n=n.apply(r,e||[])).next())})},la=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}}},ua=(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",so.version),fetch(c.href,{referrerPolicy:this._options.referrerPolicy})},r.prototype.retrieveId=function(){return ca(this,void 0,Promise,function(){var e,t,n;return la(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(),$.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 ca(this,void 0,Promise,function(){var e,t,n;return la(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(),$.default.error("Error retrieving list peers",n),new Error("Could not get list peers from the server."+n);case 3:return[2]}})})},r})(),Yl=(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)}})(),ri=function(){return ri=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},ri.apply(this,arguments)},jn=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.")},Zl=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},Gs=(function(r){Yl(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=ri({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&&$.default.setLogFunction(i._options.logFunction),$.default.logLevel=i._options.debug||0,i._api=new Ac.API(n),i._socket=i._createServerConnection(),!te.supports.audioVideo&&!te.supports.data?(i._delayedAbort(_e.BrowserIncompatible,"The current browser does not support WebRTC"),i):s&&!te.validateId(s)?(i._delayedAbort(_e.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(_e.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=jn(this._connections),a=s.next();!a.done;a=s.next()){var o=Zl(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 kc.Socket(this._options.secure,this._options.host,this._options.port,this._options.path,this._options.key,this._options.pingInterval);return n.on(Gt.Message,function(i){t._handleMessage(i)}),n.on(Gt.Error,function(i){t._abort(_e.SocketError,i)}),n.on(Gt.Disconnected,function(){t.disconnected||(t.emitError(_e.Network,"Lost connection to server."),t.disconnect())}),n.on(Gt.Close,function(){t.disconnected||t._abort(_e.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 Ne.Open:this._lastServerId=this.id,this._open=!0,this.emit("open",this.id);break;case Ne.Error:this._abort(_e.ServerError,a.msg);break;case Ne.IdTaken:this._abort(_e.UnavailableID,'ID "'.concat(this.id,'" is taken'));break;case Ne.InvalidKey:this._abort(_e.InvalidKey,'API KEY "'.concat(this._options.key,'" is invalid'));break;case Ne.Leave:$.default.log("Received leave message from ".concat(o)),this._cleanupPeer(o),this._connections.delete(o);break;case Ne.Expire:this.emitError(_e.PeerUnavailable,"Could not connect to peer ".concat(o));break;case Ne.Offer:var _=a.connectionId,T=this.getConnection(o,_);if(T&&(T.close(),$.default.warn("Offer received for existing Connection ID:".concat(_))),a.type===Ct.Media){var c=new Js.MediaConnection(o,this,{connectionId:_,_payload:a,metadata:a.metadata});T=c,this._addConnection(o,T),this.emit("call",c)}else if(a.type===Ct.Data){var l=new js.DataConnection(o,this,{connectionId:_,_payload:a,metadata:a.metadata,label:a.label,serialization:a.serialization,reliable:a.reliable});T=l,this._addConnection(o,T),this.emit("connection",l)}else{$.default.warn("Received malformed connection type:".concat(a.type));return}var u=this._getMessages(_);try{for(var f=jn(u),p=f.next();!p.done;p=f.next()){var m=p.value;T.handleMessage(m)}}catch(g){n={error:g}}finally{try{p&&!p.done&&(i=f.return)&&i.call(f)}finally{if(n)throw n.error}}break;default:if(!a){$.default.warn("You received a malformed message from ".concat(o," of type ").concat(s));return}var _=a.connectionId,T=this.getConnection(o,_);T&&T.peerConnection?T.handleMessage(t):_?this._storeMessage(_,t):$.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){$.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(_e.Disconnected,"Cannot connect to new Peer after disconnecting from server.");return}var i=new js.DataConnection(t,this,n);return this._addConnection(t,i),i},e.prototype.call=function(t,n,i){if(i===void 0&&(i={}),this.disconnected){$.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(_e.Disconnected,"Cannot connect to new Peer after disconnecting from server.");return}if(!n){$.default.error("To call a peer, you must provide a stream from your browser's `getUserMedia`.");return}var s=new Js.MediaConnection(t,this,ri(ri({},i),{_stream:n}));return this._addConnection(t,s),s},e.prototype._addConnection=function(t,n){$.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=jn(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){$.default.error("Aborting!"),this.emitError(t,n),this._lastServerId?this.disconnect():this.destroy()},e.prototype.emitError=function(t,n){$.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||($.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=jn(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=jn(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;$.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)$.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)$.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(_e.ServerError,i)})},e.DEFAULT_KEY="peerjs",e})(Vi.EventEmitter),Oc=Pc.Peer;const Kl=Object.freeze(Object.defineProperty({__proto__:null,get Peer(){return Gs},default:Oc,util:te},Symbol.toStringTag,{value:"Module"})),Ql=/^(?:[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 eu(r){return typeof r=="string"&&Ql.test(r)}const Be=[];for(let r=0;r<256;++r)Be.push((r+256).toString(16).slice(1));function tu(r,e=0){return Be[r[e+0]]+Be[r[e+1]]+Be[r[e+2]]+Be[r[e+3]]+"-"+Be[r[e+4]]+Be[r[e+5]]+"-"+Be[r[e+6]]+Be[r[e+7]]+"-"+Be[r[e+8]]+Be[r[e+9]]+"-"+Be[r[e+10]]+Be[r[e+11]]+Be[r[e+12]]+Be[r[e+13]]+Be[r[e+14]]+Be[r[e+15]]}function nu(r){if(!eu(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 iu(r){r=unescape(encodeURIComponent(r));const e=[];for(let t=0;t<r.length;++t)e.push(r.charCodeAt(t));return e}const ru="6ba7b810-9dad-11d1-80b4-00c04fd430c8",su="6ba7b811-9dad-11d1-80b4-00c04fd430c8";function ou(r,e,t){function n(i,s,a,o){var c;if(typeof i=="string"&&(i=iu(i)),typeof s=="string"&&(s=nu(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 tu(l)}try{n.name=r}catch{}return n.DNS=ru,n.URL=su,n}function au(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 us(r,e){return r<<e|r>>>32-e}function cu(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]=us(o[m-3]^o[m-8]^o[m-14]^o[m-16],1);let c=t[0],l=t[1],u=t[2],f=t[3],p=t[4];for(let m=0;m<80;++m){const _=Math.floor(m/20),T=us(c,5)+au(_,l,u,f)+p+e[_]+o[m]>>>0;p=f,f=u,u=us(l,30)>>>0,l=c,c=T}t[0]=t[0]+c>>>0,t[1]=t[1]+l>>>0,t[2]=t[2]+u>>>0,t[3]=t[3]+f>>>0,t[4]=t[4]+p>>>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 lu=ou("v5",80,cu);var hs={exports:{}},fs={exports:{}},ha;function uu(){return ha||(ha=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}};fs.exports=e})()),fs.exports}var ds,fa;function da(){if(fa)return ds;fa=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 ds=r,ds}/*!
79
- * Determine if an object is a Buffer
80
- *
81
- * @author Feross Aboukhadijeh <https://feross.org>
82
- * @license MIT
83
- */var ps,pa;function hu(){if(pa)return ps;pa=1,ps=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 ps}var ma;function fu(){return ma||(ma=1,(function(){var r=uu(),e=da().utf8,t=hu(),n=da().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,f=-1732584194,p=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 _=i._ff,T=i._gg,g=i._hh,v=i._ii,m=0;m<o.length;m+=16){var b=l,x=u,C=f,M=p;l=_(l,u,f,p,o[m+0],7,-680876936),p=_(p,l,u,f,o[m+1],12,-389564586),f=_(f,p,l,u,o[m+2],17,606105819),u=_(u,f,p,l,o[m+3],22,-1044525330),l=_(l,u,f,p,o[m+4],7,-176418897),p=_(p,l,u,f,o[m+5],12,1200080426),f=_(f,p,l,u,o[m+6],17,-1473231341),u=_(u,f,p,l,o[m+7],22,-45705983),l=_(l,u,f,p,o[m+8],7,1770035416),p=_(p,l,u,f,o[m+9],12,-1958414417),f=_(f,p,l,u,o[m+10],17,-42063),u=_(u,f,p,l,o[m+11],22,-1990404162),l=_(l,u,f,p,o[m+12],7,1804603682),p=_(p,l,u,f,o[m+13],12,-40341101),f=_(f,p,l,u,o[m+14],17,-1502002290),u=_(u,f,p,l,o[m+15],22,1236535329),l=T(l,u,f,p,o[m+1],5,-165796510),p=T(p,l,u,f,o[m+6],9,-1069501632),f=T(f,p,l,u,o[m+11],14,643717713),u=T(u,f,p,l,o[m+0],20,-373897302),l=T(l,u,f,p,o[m+5],5,-701558691),p=T(p,l,u,f,o[m+10],9,38016083),f=T(f,p,l,u,o[m+15],14,-660478335),u=T(u,f,p,l,o[m+4],20,-405537848),l=T(l,u,f,p,o[m+9],5,568446438),p=T(p,l,u,f,o[m+14],9,-1019803690),f=T(f,p,l,u,o[m+3],14,-187363961),u=T(u,f,p,l,o[m+8],20,1163531501),l=T(l,u,f,p,o[m+13],5,-1444681467),p=T(p,l,u,f,o[m+2],9,-51403784),f=T(f,p,l,u,o[m+7],14,1735328473),u=T(u,f,p,l,o[m+12],20,-1926607734),l=g(l,u,f,p,o[m+5],4,-378558),p=g(p,l,u,f,o[m+8],11,-2022574463),f=g(f,p,l,u,o[m+11],16,1839030562),u=g(u,f,p,l,o[m+14],23,-35309556),l=g(l,u,f,p,o[m+1],4,-1530992060),p=g(p,l,u,f,o[m+4],11,1272893353),f=g(f,p,l,u,o[m+7],16,-155497632),u=g(u,f,p,l,o[m+10],23,-1094730640),l=g(l,u,f,p,o[m+13],4,681279174),p=g(p,l,u,f,o[m+0],11,-358537222),f=g(f,p,l,u,o[m+3],16,-722521979),u=g(u,f,p,l,o[m+6],23,76029189),l=g(l,u,f,p,o[m+9],4,-640364487),p=g(p,l,u,f,o[m+12],11,-421815835),f=g(f,p,l,u,o[m+15],16,530742520),u=g(u,f,p,l,o[m+2],23,-995338651),l=v(l,u,f,p,o[m+0],6,-198630844),p=v(p,l,u,f,o[m+7],10,1126891415),f=v(f,p,l,u,o[m+14],15,-1416354905),u=v(u,f,p,l,o[m+5],21,-57434055),l=v(l,u,f,p,o[m+12],6,1700485571),p=v(p,l,u,f,o[m+3],10,-1894986606),f=v(f,p,l,u,o[m+10],15,-1051523),u=v(u,f,p,l,o[m+1],21,-2054922799),l=v(l,u,f,p,o[m+8],6,1873313359),p=v(p,l,u,f,o[m+15],10,-30611744),f=v(f,p,l,u,o[m+6],15,-1560198380),u=v(u,f,p,l,o[m+13],21,1309151649),l=v(l,u,f,p,o[m+4],6,-145523070),p=v(p,l,u,f,o[m+11],10,-1120210379),f=v(f,p,l,u,o[m+2],15,718787259),u=v(u,f,p,l,o[m+9],21,-343485551),l=l+b>>>0,u=u+x>>>0,f=f+C>>>0,p=p+M>>>0}return r.endian([l,u,f,p])};i._ff=function(s,a,o,c,l,u,f){var p=s+(a&o|~a&c)+(l>>>0)+f;return(p<<u|p>>>32-u)+a},i._gg=function(s,a,o,c,l,u,f){var p=s+(a&c|o&~c)+(l>>>0)+f;return(p<<u|p>>>32-u)+a},i._hh=function(s,a,o,c,l,u,f){var p=s+(a^o^c)+(l>>>0)+f;return(p<<u|p>>>32-u)+a},i._ii=function(s,a,o,c,l,u,f){var p=s+(o^(a|~c))+(l>>>0)+f;return(p<<u|p>>>32-u)+a},i._blocksize=16,i._digestsize=16,hs.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)}})()),hs.exports}var du=fu();const pu=Fr(du),Le=["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 ya=1234567;const zc=Math.PI/180,Ic=180/Math.PI;function mu(){const r=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(Le[r&255]+Le[r>>8&255]+Le[r>>16&255]+Le[r>>24&255]+"-"+Le[e&255]+Le[e>>8&255]+"-"+Le[e>>16&15|64]+Le[e>>24&255]+"-"+Le[t&63|128]+Le[t>>8&255]+"-"+Le[t>>16&255]+Le[t>>24&255]+Le[n&255]+Le[n>>8&255]+Le[n>>16&255]+Le[n>>24&255]).toLowerCase()}function Rt(r,e,t){return Math.max(e,Math.min(t,r))}function Bc(r,e){return(r%e+e)%e}function yu(r,e,t,n,i){return n+(r-e)*(i-n)/(t-e)}function gu(r,e,t){return r!==e?(t-r)/(e-r):0}function Nc(r,e,t){return(1-t)*r+t*e}function vu(r,e,t,n){return Nc(r,e,1-Math.exp(-t*n))}function Su(r,e=1){return e-Math.abs(Bc(r,e*2)-e)}function xu(r,e,t){return r<=e?0:r>=t?1:(r=(r-e)/(t-e),r*r*(3-2*r))}function _u(r,e,t){return r<=e?0:r>=t?1:(r=(r-e)/(t-e),r*r*r*(r*(r*6-15)+10))}function bu(r,e){return r+Math.floor(Math.random()*(e-r+1))}function Tu(r,e){return r+Math.random()*(e-r)}function Mu(r){return r*(.5-Math.random())}function Cu(r){r!==void 0&&(ya=r);let e=ya+=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 wu(r){return r*zc}function Pu(r){return r*Ic}function Eu(r){return(r&r-1)===0&&r!==0}function ku(r){return Math.pow(2,Math.ceil(Math.log(r)/Math.LN2))}function Ru(r){return Math.pow(2,Math.floor(Math.log(r)/Math.LN2))}function Au(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),f=s((e-n)/2),p=a((e-n)/2),m=s((n-e)/2),_=a((n-e)/2);switch(i){case"XYX":r.set(o*u,c*f,c*p,o*l);break;case"YZY":r.set(c*p,o*u,c*f,o*l);break;case"ZXZ":r.set(c*f,c*p,o*u,o*l);break;case"XZX":r.set(o*u,c*_,c*m,o*l);break;case"YXY":r.set(c*m,o*u,c*_,o*l);break;case"ZYZ":r.set(c*_,c*m,o*u,o*l);break;default:console.warn("../math.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+i)}}function Ou(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 zu(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 Fn={DEG2RAD:zc,RAD2DEG:Ic,generateUUID:mu,clamp:Rt,euclideanModulo:Bc,mapLinear:yu,inverseLerp:gu,lerp:Nc,damp:vu,pingpong:Su,smoothstep:xu,smootherstep:_u,randInt:bu,randFloat:Tu,randFloatSpread:Mu,seededRandom:Cu,degToRad:wu,radToDeg:Pu,isPowerOfTwo:Eu,ceilPowerOfTwo:ku,floorPowerOfTwo:Ru,setQuaternionFromProperEuler:Au,normalize:zu,denormalize:Ou};class re{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],f=n[i+3];const p=s[a+0],m=s[a+1],_=s[a+2],T=s[a+3];if(o===0){e[t+0]=c,e[t+1]=l,e[t+2]=u,e[t+3]=f;return}if(o===1){e[t+0]=p,e[t+1]=m,e[t+2]=_,e[t+3]=T;return}if(f!==T||c!==p||l!==m||u!==_){let g=1-o;const v=c*p+l*m+u*_+f*T,b=v>=0?1:-1,x=1-v*v;if(x>Number.EPSILON){const M=Math.sqrt(x),P=Math.atan2(M,v*b);g=Math.sin(g*P)/M,o=Math.sin(o*P)/M}const C=o*b;if(c=c*g+p*C,l=l*g+m*C,u=u*g+_*C,f=f*g+T*C,g===1-o){const M=1/Math.sqrt(c*c+l*l+u*u+f*f);c*=M,l*=M,u*=M,f*=M}}e[t]=c,e[t+1]=l,e[t+2]=u,e[t+3]=f}static multiplyQuaternionsFlat(e,t,n,i,s,a){const o=n[i],c=n[i+1],l=n[i+2],u=n[i+3],f=s[a],p=s[a+1],m=s[a+2],_=s[a+3];return e[t]=o*_+u*f+c*m-l*p,e[t+1]=c*_+u*p+l*f-o*m,e[t+2]=l*_+u*m+o*p-c*f,e[t+3]=u*_-o*f-c*p-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 re(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),f=o(s/2),p=c(n/2),m=c(i/2),_=c(s/2);switch(a){case"XYZ":this._x=p*u*f+l*m*_,this._y=l*m*f-p*u*_,this._z=l*u*_+p*m*f,this._w=l*u*f-p*m*_;break;case"YXZ":this._x=p*u*f+l*m*_,this._y=l*m*f-p*u*_,this._z=l*u*_-p*m*f,this._w=l*u*f+p*m*_;break;case"ZXY":this._x=p*u*f-l*m*_,this._y=l*m*f+p*u*_,this._z=l*u*_+p*m*f,this._w=l*u*f-p*m*_;break;case"ZYX":this._x=p*u*f-l*m*_,this._y=l*m*f+p*u*_,this._z=l*u*_-p*m*f,this._w=l*u*f+p*m*_;break;case"YZX":this._x=p*u*f+l*m*_,this._y=l*m*f+p*u*_,this._z=l*u*_-p*m*f,this._w=l*u*f-p*m*_;break;case"XZY":this._x=p*u*f-l*m*_,this._y=l*m*f-p*u*_,this._z=l*u*_+p*m*f,this._w=l*u*f+p*m*_;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],f=t[10],p=n+o+f;if(p>0){const m=.5/Math.sqrt(p+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>f){const m=2*Math.sqrt(1+n-o-f);this._w=(u-c)/m,this._x=.25*m,this._y=(i+a)/m,this._z=(s+l)/m}else if(o>f){const m=2*Math.sqrt(1+o-n-f);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+f-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(Rt(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),f=Math.sin((1-t)*u)/l,p=Math.sin(t*u)/l;return this._w=a*f+this._w*p,this._x=n*f+this._x*p,this._y=i*f+this._y*p,this._z=s*f+this._z*p,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 W{constructor(e=0,t=0,n=0){this.isVector3=!0,W.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 W(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(ga.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(ga.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),f=2*(s*n-a*t);return this.x=t+c*l+a*f-o*u,this.y=n+c*u+o*l-s*f,this.z=i+c*f+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 ms.copy(this).projectOnVector(e),this.sub(ms)}reflect(e){return this.sub(ms.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(Rt(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 ms=new W,ga=new re,er=2e3,va=2001;class wt{constructor(e,t,n,i,s,a,o,c,l,u,f,p,m,_,T,g){this.isMatrix4=!0,wt.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,f,p,m,_,T,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,f,p,m,_,T,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]=f,v[14]=p,v[3]=m,v[7]=_,v[11]=T,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 wt().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/Cn.setFromMatrixColumn(e,0).length(),s=1/Cn.setFromMatrixColumn(e,1).length(),a=1/Cn.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),f=Math.sin(s);if(e.order==="XYZ"){const p=a*u,m=a*f,_=o*u,T=o*f;t[0]=c*u,t[4]=-c*f,t[8]=l,t[1]=m+_*l,t[5]=p-T*l,t[9]=-o*c,t[2]=T-p*l,t[6]=_+m*l,t[10]=a*c}else if(e.order==="YXZ"){const p=c*u,m=c*f,_=l*u,T=l*f;t[0]=p+T*o,t[4]=_*o-m,t[8]=a*l,t[1]=a*f,t[5]=a*u,t[9]=-o,t[2]=m*o-_,t[6]=T+p*o,t[10]=a*c}else if(e.order==="ZXY"){const p=c*u,m=c*f,_=l*u,T=l*f;t[0]=p-T*o,t[4]=-a*f,t[8]=_+m*o,t[1]=m+_*o,t[5]=a*u,t[9]=T-p*o,t[2]=-a*l,t[6]=o,t[10]=a*c}else if(e.order==="ZYX"){const p=a*u,m=a*f,_=o*u,T=o*f;t[0]=c*u,t[4]=_*l-m,t[8]=p*l+T,t[1]=c*f,t[5]=T*l+p,t[9]=m*l-_,t[2]=-l,t[6]=o*c,t[10]=a*c}else if(e.order==="YZX"){const p=a*c,m=a*l,_=o*c,T=o*l;t[0]=c*u,t[4]=T-p*f,t[8]=_*f+m,t[1]=f,t[5]=a*u,t[9]=-o*u,t[2]=-l*u,t[6]=m*f+_,t[10]=p-T*f}else if(e.order==="XZY"){const p=a*c,m=a*l,_=o*c,T=o*l;t[0]=c*u,t[4]=-f,t[8]=l*u,t[1]=p*f+T,t[5]=a*u,t[9]=m*f-_,t[2]=_*f-m,t[6]=o*u,t[10]=T*f+p}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(Iu,e,Bu)}lookAt(e,t,n){const i=this.elements;return it.subVectors(e,t),it.lengthSq()===0&&(it.z=1),it.normalize(),qt.crossVectors(n,it),qt.lengthSq()===0&&(Math.abs(n.z)===1?it.x+=1e-4:it.z+=1e-4,it.normalize(),qt.crossVectors(n,it)),qt.normalize(),tr.crossVectors(it,qt),i[0]=qt.x,i[4]=tr.x,i[8]=it.x,i[1]=qt.y,i[5]=tr.y,i[9]=it.y,i[2]=qt.z,i[6]=tr.z,i[10]=it.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],f=n[5],p=n[9],m=n[13],_=n[2],T=n[6],g=n[10],v=n[14],b=n[3],x=n[7],C=n[11],M=n[15],P=i[0],E=i[4],I=i[8],O=i[12],A=i[1],N=i[5],z=i[9],U=i[13],F=i[2],J=i[6],j=i[10],q=i[14],G=i[3],ne=i[7],ie=i[11],he=i[15];return s[0]=a*P+o*A+c*F+l*G,s[4]=a*E+o*N+c*J+l*ne,s[8]=a*I+o*z+c*j+l*ie,s[12]=a*O+o*U+c*q+l*he,s[1]=u*P+f*A+p*F+m*G,s[5]=u*E+f*N+p*J+m*ne,s[9]=u*I+f*z+p*j+m*ie,s[13]=u*O+f*U+p*q+m*he,s[2]=_*P+T*A+g*F+v*G,s[6]=_*E+T*N+g*J+v*ne,s[10]=_*I+T*z+g*j+v*ie,s[14]=_*O+T*U+g*q+v*he,s[3]=b*P+x*A+C*F+M*G,s[7]=b*E+x*N+C*J+M*ne,s[11]=b*I+x*z+C*j+M*ie,s[15]=b*O+x*U+C*q+M*he,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],f=e[6],p=e[10],m=e[14],_=e[3],T=e[7],g=e[11],v=e[15];return _*(+s*c*f-i*l*f-s*o*p+n*l*p+i*o*m-n*c*m)+T*(+t*c*m-t*l*p+s*a*p-i*a*m+i*l*u-s*c*u)+g*(+t*l*f-t*o*m-s*a*f+n*a*m+s*o*u-n*l*u)+v*(-i*o*u-t*c*f+t*o*p+i*a*f-n*a*p+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],f=e[9],p=e[10],m=e[11],_=e[12],T=e[13],g=e[14],v=e[15],b=f*g*l-T*p*l+T*c*m-o*g*m-f*c*v+o*p*v,x=_*p*l-u*g*l-_*c*m+a*g*m+u*c*v-a*p*v,C=u*T*l-_*f*l+_*o*m-a*T*m-u*o*v+a*f*v,M=_*f*c-u*T*c-_*o*p+a*T*p+u*o*g-a*f*g,P=t*b+n*x+i*C+s*M;if(P===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const E=1/P;return e[0]=b*E,e[1]=(T*p*s-f*g*s-T*i*m+n*g*m+f*i*v-n*p*v)*E,e[2]=(o*g*s-T*c*s+T*i*l-n*g*l-o*i*v+n*c*v)*E,e[3]=(f*c*s-o*p*s-f*i*l+n*p*l+o*i*m-n*c*m)*E,e[4]=x*E,e[5]=(u*g*s-_*p*s+_*i*m-t*g*m-u*i*v+t*p*v)*E,e[6]=(_*c*s-a*g*s-_*i*l+t*g*l+a*i*v-t*c*v)*E,e[7]=(a*p*s-u*c*s+u*i*l-t*p*l-a*i*m+t*c*m)*E,e[8]=C*E,e[9]=(_*f*s-u*T*s-_*n*m+t*T*m+u*n*v-t*f*v)*E,e[10]=(a*T*s-_*o*s+_*n*l-t*T*l-a*n*v+t*o*v)*E,e[11]=(u*o*s-a*f*s-u*n*l+t*f*l+a*n*m-t*o*m)*E,e[12]=M*E,e[13]=(u*T*i-_*f*i+_*n*p-t*T*p-u*n*g+t*f*g)*E,e[14]=(_*o*i-a*T*i-_*n*c+t*T*c+a*n*g-t*o*g)*E,e[15]=(a*f*i-u*o*i+u*n*c-t*f*c-a*n*p+t*o*p)*E,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,f=o+o,p=s*l,m=s*u,_=s*f,T=a*u,g=a*f,v=o*f,b=c*l,x=c*u,C=c*f,M=n.x,P=n.y,E=n.z;return i[0]=(1-(T+v))*M,i[1]=(m+C)*M,i[2]=(_-x)*M,i[3]=0,i[4]=(m-C)*P,i[5]=(1-(p+v))*P,i[6]=(g+b)*P,i[7]=0,i[8]=(_+x)*E,i[9]=(g-b)*E,i[10]=(1-(p+T))*E,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=Cn.set(i[0],i[1],i[2]).length();const a=Cn.set(i[4],i[5],i[6]).length(),o=Cn.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],Tt.copy(this);const l=1/s,u=1/a,f=1/o;return Tt.elements[0]*=l,Tt.elements[1]*=l,Tt.elements[2]*=l,Tt.elements[4]*=u,Tt.elements[5]*=u,Tt.elements[6]*=u,Tt.elements[8]*=f,Tt.elements[9]*=f,Tt.elements[10]*=f,t.setFromRotationMatrix(Tt),n.x=s,n.y=a,n.z=o,this}makePerspective(e,t,n,i,s,a,o=er){const c=this.elements,l=2*s/(t-e),u=2*s/(n-i),f=(t+e)/(t-e),p=(n+i)/(n-i);let m,_;if(o===er)m=-(a+s)/(a-s),_=-2*a*s/(a-s);else if(o===va)m=-a/(a-s),_=-a*s/(a-s);else throw new Error("Matrix4.makePerspective(): Invalid coordinate system: "+o);return c[0]=l,c[4]=0,c[8]=f,c[12]=0,c[1]=0,c[5]=u,c[9]=p,c[13]=0,c[2]=0,c[6]=0,c[10]=m,c[14]=_,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(e,t,n,i,s,a,o=er){const c=this.elements,l=1/(t-e),u=1/(n-i),f=1/(a-s),p=(t+e)*l,m=(n+i)*u;let _,T;if(o===er)_=(a+s)*f,T=-2*f;else if(o===va)_=s*f,T=-1*f;else throw new Error("../math.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return c[0]=2*l,c[4]=0,c[8]=0,c[12]=-p,c[1]=0,c[5]=2*u,c[9]=0,c[13]=-m,c[2]=0,c[6]=0,c[10]=T,c[14]=-_,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 Cn=new W,Tt=new wt,Iu=new W(0,0,0),Bu=new W(1,1,1),qt=new W,tr=new W,it=new W,Sa=new wt,xa=new re;class li{constructor(e=0,t=0,n=0,i=li.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 li(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],f=i[2],p=i[6],m=i[10];switch(t){case"XYZ":this._y=Math.asin(Rt(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-u,m),this._z=Math.atan2(-a,s)):(this._x=Math.atan2(p,l),this._z=0);break;case"YXZ":this._x=Math.asin(-Rt(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(o,m),this._z=Math.atan2(c,l)):(this._y=Math.atan2(-f,s),this._z=0);break;case"ZXY":this._x=Math.asin(Rt(p,-1,1)),Math.abs(p)<.9999999?(this._y=Math.atan2(-f,m),this._z=Math.atan2(-a,l)):(this._y=0,this._z=Math.atan2(c,s));break;case"ZYX":this._y=Math.asin(-Rt(f,-1,1)),Math.abs(f)<.9999999?(this._x=Math.atan2(p,m),this._z=Math.atan2(c,s)):(this._x=0,this._z=Math.atan2(-a,l));break;case"YZX":this._z=Math.asin(Rt(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-u,l),this._y=Math.atan2(-f,s)):(this._x=0,this._y=Math.atan2(o,m));break;case"XZY":this._z=Math.asin(-Rt(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(p,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 Sa.makeRotationFromQuaternion(e),this.setFromRotationMatrix(Sa,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return xa.setFromEuler(this),this.setFromQuaternion(xa,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}}li.DEFAULT_ORDER="XYZ";class Bn{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 Bn(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(Rt(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}}Bn.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 c=e.elements,l=c[0],u=c[4],f=c[8],p=c[1],m=c[5],_=c[9],T=c[2],g=c[6],v=c[10];if(Math.abs(u-p)<.01&&Math.abs(f-T)<.01&&Math.abs(_-g)<.01){if(Math.abs(u+p)<.1&&Math.abs(f+T)<.1&&Math.abs(_+g)<.1&&Math.abs(l+m+v-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const x=(l+1)/2,C=(m+1)/2,M=(v+1)/2,P=(u+p)/4,E=(f+T)/4,I=(_+g)/4;return x>C&&x>M?x<.01?(n=0,i=.707106781,s=.707106781):(n=Math.sqrt(x),i=P/n,s=E/n):C>M?C<.01?(n=.707106781,i=0,s=.707106781):(i=Math.sqrt(C),n=P/i,s=I/i):M<.01?(n=.707106781,i=.707106781,s=0):(s=Math.sqrt(M),n=E/s,i=I/s),this.set(n,i,s,t),this}let b=Math.sqrt((g-_)*(g-_)+(f-T)*(f-T)+(p-u)*(p-u));return Math.abs(b)<.001&&(b=1),this.x=(g-_)/b,this.y=(f-T)/b,this.z=(p-u)/b,this.w=Math.acos((l+m+v-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 Ot{constructor(e,t,n,i,s,a,o,c,l){Ot.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],f=n[7],p=n[2],m=n[5],_=n[8],T=i[0],g=i[3],v=i[6],b=i[1],x=i[4],C=i[7],M=i[2],P=i[5],E=i[8];return s[0]=a*T+o*b+c*M,s[3]=a*g+o*x+c*P,s[6]=a*v+o*C+c*E,s[1]=l*T+u*b+f*M,s[4]=l*g+u*x+f*P,s[7]=l*v+u*C+f*E,s[2]=p*T+m*b+_*M,s[5]=p*g+m*x+_*P,s[8]=p*v+m*C+_*E,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],f=u*a-o*l,p=o*c-u*s,m=l*s-a*c,_=t*f+n*p+i*m;if(_===0)return this.set(0,0,0,0,0,0,0,0,0);const T=1/_;return e[0]=f*T,e[1]=(i*l-u*n)*T,e[2]=(o*n-i*a)*T,e[3]=p*T,e[4]=(u*t-i*c)*T,e[5]=(i*s-o*t)*T,e[6]=m*T,e[7]=(n*c-l*t)*T,e[8]=(a*t-n*s)*T,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(ys.makeScale(e,t)),this}rotate(e){return this.premultiply(ys.makeRotation(-e)),this}translate(e,t){return this.premultiply(ys.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 Ot().fromArray(this.elements)}}const ys=new Ot;var qe;(function(r){r[r.Random=0]="Random",r[r.Loop=1]="Loop",r[r.PingPong=2]="PingPong",r[r.Burst=3]="Burst"})(qe||(qe={}));function Ji(r,e,t,n){let i;switch(qe.Random===r?e=Math.random():qe.Burst===r&&n.isBursting&&(e=n.burstParticleIndex/n.burstParticleCount),t>0?i=Math.floor(e/t)*t:i=e,r){case qe.Loop:i=i%1;break;case qe.PingPong:i=Math.abs(i%2-1);break}return i}class mn{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 mn(t[0],t[4],t[7],t[9]),right:new mn(t[9],t[8],t[6],t[3]),span:t}}clone(){return new mn(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 mn(e.p0,e.p1,e.p2,e.p3)}}const ui=r=>({r:r.x,g:r.y,b:r.z,a:r.w}),hi=r=>new tt(r.r,r.g,r.b,r.a),Nu=(r,e)=>{switch(e){case"Vector3":return new W(r.x,r.y,r.z);case"Vector4":return new tt(r.x,r.y,r.z,r.w);case"Color":return new W(r.r,r.g,r.b);case"Number":return r;default:return r}},Uu=(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 Ar{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:ui(this.a),b:ui(this.b)}}static fromJSON(e){return new Ar(hi(e.a),hi(e.b))}clone(){return new Ar(this.a.clone(),this.b.clone())}}class Nn{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:ui(this.a),b:ui(this.b)}}static fromJSON(e){return new Nn(hi(e.a),hi(e.b))}clone(){return new Nn(this.a.clone(),this.b.clone())}}class Qt{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:Uu(e,this.subType),pos:t}))}}static fromJSON(e){return new Qt(e.keys.map(t=>[Nu(t.value,e.subType),t.pos]),e.subType)}clone(){return this.subType==="Number"?new Qt(this.keys.map(([e,t])=>[e,t]),this.subType):new Qt(this.keys.map(([e,t])=>[e.clone(),t]),this.subType)}}const nr=new W;class yn{constructor(e=[[new W(0,0,0),0],[new W(1,1,1),0]],t=[[1,0],[1,1]]){this.type="function",this.color=new Qt(e,"Color"),this.alpha=new Qt(t,"Number")}genColor(e,t,n){return this.color.genValue(nr,n),t.set(nr.x,nr.y,nr.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=>[Nn.fromJSON(n.function).a,n.start]);return e.functions.length>0&&t.push([Nn.fromJSON(e.functions[e.functions.length-1].function).b,1]),new yn(t.map(n=>[new W(n[0].x,n[0].y,n[0].z),n[1]]),t.map(n=>[n[0].w,n[1]]))}else{const t=new yn;return t.alpha=Qt.fromJSON(e.alpha),t.color=Qt.fromJSON(e.color),t}}clone(){const e=new yn;return e.alpha=this.alpha.clone(),e.color=this.color.clone(),e}startGen(e){}}const gs=new tt;class Or{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,gs,n),e&&e[this.indexCount]!==void 0?t.lerp(gs,e[this.indexCount]):t.lerp(gs,Math.random()),t}toJSON(){return{type:"RandomColorBetweenGradient",gradient1:this.gradient1.toJSON(),gradient2:this.gradient2.toJSON()}}static fromJSON(e){return new Or(yn.fromJSON(e.gradient1),yn.fromJSON(e.gradient2))}clone(){return new Or(this.gradient1.clone(),this.gradient2.clone())}}class gn{constructor(e){this.color=e,this.type="value"}startGen(e){}genColor(e,t){return t.copy(this.color)}toJSON(){return{type:"ConstantColor",color:ui(this.color)}}static fromJSON(e){return new gn(hi(e.color))}clone(){return new gn(this.color.clone())}}function co(r){switch(r.type){case"ConstantColor":return gn.fromJSON(r);case"ColorRange":return Nn.fromJSON(r);case"RandomColor":return Ar.fromJSON(r);case"Gradient":return yn.fromJSON(r);case"RandomColorBetweenGradient":return Or.fromJSON(r);default:return new gn(new tt(1,1,1,1))}}class ee{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 ee(e.value)}clone(){return new ee(this.value)}}class vn{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),Fn.lerp(this.a,this.b,e[this.indexCount])}toJSON(){return{type:"IntervalValue",a:this.a,b:this.b}}static fromJSON(e){return new vn(e.a,e.b)}clone(){return new vn(this.a,this.b)}}class Du{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 fi extends Du{constructor(e=[[new mn(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 fi(e.functions.map(t=>[mn.fromJSON(t.function),t.start]))}clone(){return new fi(this.functions.map(([e,t])=>[e.clone(),t]))}startGen(e){}}function K(r){switch(r.type){case"ConstantValue":return ee.fromJSON(r);case"IntervalValue":return vn.fromJSON(r);case"PiecewiseBezier":return fi.fromJSON(r);default:return new ee(0)}}class di{constructor(){this.indexCount=0,this.type="rotation"}startGen(e){this.indexCount=e.length,e.push(new re);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 di}clone(){return new di}}class pi{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 pi(new W(e.axis.x,e.axis.y,e.axis.z),K(e.angle))}clone(){return new pi(this.axis.clone(),this.angle.clone())}}class zr{constructor(e,t,n,i){this.angleX=e,this.angleY=t,this.angleZ=n,this.type="rotation",this.eular=new li(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 zr(K(e.angleX),K(e.angleY),K(e.angleZ),e.eulerOrder)}clone(){return new zr(this.angleX,this.angleY,this.angleZ,this.eular.order)}}function Uc(r){switch(r.type){case"AxisAngle":return pi.fromJSON(r);case"Euler":return zr.fromJSON(r);case"RandomQuat":return di.fromJSON(r);default:return new di}}class Sn{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 Sn(K(e.x),K(e.y),K(e.z))}clone(){return new Sn(this.x,this.y,this.z)}}function Fu(r){switch(r.type){case"Vector3Function":return Sn.fromJSON(r);default:return new Sn(new ee(0),new ee(0),new ee(0))}}function Ir(r){switch(r.type){case"ConstantValue":case"IntervalValue":case"PiecewiseBezier":return K(r);case"AxisAngle":case"RandomQuat":case"Euler":return Uc(r);case"Vector3Function":return Fu(r);default:return new ee(0)}}class mi{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:qe.Random,this.spread=(o=e.spread)!==null&&o!==void 0?o:0,this.speed=(c=e.speed)!==null&&c!==void 0?c:new ee(1),this.memory=[]}update(e,t){qe.Random!=this.mode&&(this.currentValue+=this.speed.genValue(this.memory,e.emissionState.time/e.duration)*t)}initialize(e,t){const n=Ji(this.mode,this.currentValue,this.spread,t),i=Fn.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 mi({radius:e.radius,arc:e.arc,thickness:e.thickness,angle:e.angle,mode:e.mode,speed:e.speed?K(e.speed):void 0,spread:e.spread})}clone(){return new mi({radius:this.radius,arc:this.arc,thickness:this.thickness,angle:this.angle,mode:this.mode,speed:this.speed.clone(),spread:this.spread})}}class yi{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:qe.Random,this.spread=(a=e.spread)!==null&&a!==void 0?a:0,this.speed=(o=e.speed)!==null&&o!==void 0?o:new ee(1),this.memory=[]}update(e,t){this.currentValue+=this.speed.genValue(this.memory,e.emissionState.time/e.duration)*t}initialize(e,t){const n=Ji(this.mode,this.currentValue,this.spread,t),i=Fn.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 yi({radius:e.radius,arc:e.arc,thickness:e.thickness,mode:e.mode,speed:e.speed?K(e.speed):void 0,spread:e.spread})}clone(){return new yi({radius:this.radius,arc:this.arc,thickness:this.thickness,mode:this.mode,speed:this.speed.clone(),spread:this.spread})}}function ir(r,e){return Math.floor(Math.random()*(e-r))+r}const Vr=new W(0,1,0),Jr=new W(0,0,0),Lu=new W(1,1,1),_a=new W(0,0,1);class gi{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:qe.Random,this.spread=(o=e.spread)!==null&&o!==void 0?o:0,this.speed=(c=e.speed)!==null&&c!==void 0?c:new ee(1),this.memory=[],this._m1=new wt}update(e,t){qe.Random!=this.mode&&(this.currentValue+=this.speed.genValue(this.memory,e.emissionState.time/e.duration)*t)}initialize(e,t){const n=Ji(this.mode,this.currentValue,this.spread,t),i=Math.random(),s=Fn.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 re&&(this._m1.lookAt(Jr,e.velocity,Vr),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 gi({radius:e.radius,arc:e.arc,thickness:e.thickness,donutRadius:e.donutRadius,mode:e.mode,speed:e.speed?K(e.speed):void 0,spread:e.spread})}clone(){return new gi({radius:this.radius,arc:this.arc,thickness:this.thickness,donutRadius:this.donutRadius,mode:this.mode,speed:this.speed.clone(),spread:this.spread})}}class vi{constructor(){this.type="point",this._m1=new wt}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 re&&(this._m1.lookAt(Jr,e.position,Vr),e.rotation.setFromRotationMatrix(this._m1))}toJSON(){return{type:"point"}}static fromJSON(e){return new vi}clone(){return new vi}}class Un{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:qe.Random,this.spread=(a=e.spread)!==null&&a!==void 0?a:0,this.speed=(o=e.speed)!==null&&o!==void 0?o:new ee(1),this.memory=[],this._m1=new wt}update(e,t){qe.Random!=this.mode&&(this.currentValue+=this.speed.genValue(this.memory,e.emissionState.time/e.duration)*t)}initialize(e,t){const n=Ji(this.mode,this.currentValue,this.spread,t),i=Math.random(),s=Fn.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),f=Math.cos(o);e.position.x=u*l,e.position.y=u*c,e.position.z=f,e.velocity.copy(e.position).multiplyScalar(e.startSpeed),e.position.multiplyScalar(this.radius*s),e.rotation instanceof re&&(this._m1.lookAt(Jr,e.position,Vr),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 Un({radius:e.radius,arc:e.arc,thickness:e.thickness,mode:e.mode,speed:e.speed?K(e.speed):void 0,spread:e.spread})}clone(){return new Un({radius:this.radius,arc:this.arc,thickness:this.thickness,mode:this.mode,speed:this.speed.clone(),spread:this.spread})}}class Si{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:qe.Random,this.spread=(a=e.spread)!==null&&a!==void 0?a:0,this.speed=(o=e.speed)!==null&&o!==void 0?o:new ee(1),this.memory=[],this._m1=new wt}update(e,t){qe.Random!=this.mode&&(this.currentValue+=this.speed.genValue(this.memory,e.emissionState.time/e.duration)*t)}initialize(e,t){const n=Ji(this.mode,this.currentValue,this.spread,t),i=Math.random(),s=Fn.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),f=Math.cos(o);e.position.x=u*l,e.position.y=u*c,e.position.z=f,e.velocity.copy(e.position).multiplyScalar(e.startSpeed),e.position.multiplyScalar(this.radius*s),e.rotation instanceof re&&(this._m1.lookAt(Jr,e.position,Vr),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 Si({radius:e.radius,arc:e.arc,thickness:e.thickness,mode:e.mode,speed:e.speed?K(e.speed):void 0,spread:e.spread})}clone(){return new Si({radius:this.radius,arc:this.arc,thickness:this.thickness,mode:this.mode,speed:this.speed.clone(),spread:this.spread})}}class xi{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 xi(e)}clone(){return new xi({width:this.width,height:this.height,column:this.column,row:this.row})}update(e,t){}}const $s={circle:{type:"circle",params:[["radius",["number"]],["arc",["radian"]],["thickness",["number"]],["mode",["emitterMode"]],["spread",["number"]],["speed",["valueFunc"]]],constructor:yi,loadJSON:yi.fromJSON},cone:{type:"cone",params:[["radius",["number"]],["arc",["radian"]],["thickness",["number"]],["angle",["radian"]],["mode",["emitterMode"]],["spread",["number"]],["speed",["valueFunc"]]],constructor:mi,loadJSON:mi.fromJSON},donut:{type:"donut",params:[["radius",["number"]],["arc",["radian"]],["thickness",["number"]],["donutRadius",["number"]],["mode",["emitterMode"]],["spread",["number"]],["speed",["valueFunc"]]],constructor:gi,loadJSON:gi.fromJSON},point:{type:"point",params:[],constructor:vi,loadJSON:vi.fromJSON},sphere:{type:"sphere",params:[["radius",["number"]],["arc",["radian"]],["thickness",["number"]],["angle",["radian"]],["mode",["emitterMode"]],["spread",["number"]],["speed",["valueFunc"]]],constructor:Un,loadJSON:Un.fromJSON},hemisphere:{type:"hemisphere",params:[["radius",["number"]],["arc",["radian"]],["thickness",["number"]],["angle",["radian"]],["mode",["emitterMode"]],["spread",["number"]],["speed",["valueFunc"]]],constructor:Si,loadJSON:Si.fromJSON},grid:{type:"grid",params:[["width",["number"]],["height",["number"]],["rows",["number"]],["column",["number"]]],constructor:xi,loadJSON:xi.fromJSON}};function Vu(r,e){return $s[r.type].loadJSON(r,e)}class _i{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 _i(co(e.color))}clone(){return new _i(this.color.clone())}reset(){}}class bi{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 bi(K(e.angularVelocity))}frameUpdate(e){}clone(){return new bi(this.angularVelocity.clone())}reset(){}}class Ti{constructor(e){this.angularVelocity=e,this.type="Rotation3DOverLife",this.tempQuat=new re,this.tempQuat2=new re}initialize(e){e.rotation instanceof re&&(e.angularVelocity=new re,this.angularVelocity.startGen(e.memory))}update(e,t){e.rotation instanceof re&&(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 Ti(Uc(e.angularVelocity))}frameUpdate(e){}clone(){return new Ti(this.angularVelocity.clone())}reset(){}}class Mi{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 W,this._tempScale=new W,this._tempQ=new re}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 Mi(K(e.x),K(e.y),K(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 Mi(this.x.clone(),this.y.clone(),this.z.clone())}reset(){}}class Ci{initialize(e){this.size.startGen(e.memory)}constructor(e){this.size=e,this.type="SizeOverLife"}update(e){this.size instanceof Sn?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 Ci(Ir(e.size))}frameUpdate(e){}clone(){return new Ci(this.size.clone())}reset(){}}class wi{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 wi(K(e.speed))}frameUpdate(e){}clone(){return new wi(this.speed.clone())}reset(){}}class Pi{constructor(e){this.frame=e,this.type="FrameOverLife"}initialize(e){this.frame.startGen(e.memory)}update(e,t){this.frame instanceof fi&&(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 Pi(K(e.frame))}clone(){return new Pi(this.frame.clone())}reset(){}}class Ei{constructor(e,t=new W(0,1,0)){this.orbitSpeed=e,this.axis=t,this.type="OrbitOverLife",this.temp=new W,this.rotation=new re}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 Ei(K(e.orbitSpeed),e.axis?new W(e.axis[0],e.axis[1],e.axis[2]):void 0)}clone(){return new Ei(this.orbitSpeed.clone())}reset(){}}class vs{constructor(e){this.data=e,this.next=null,this.prev=null}hasPrev(){return this.prev!==null}hasNext(){return this.next!==null}}class Ju{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 vs(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 vs(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 vs(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 ju{constructor(){this.startSpeed=0,this.startColor=new tt,this.startSize=new W(1,1,1),this.position=new W,this.velocity=new W,this.age=0,this.life=1,this.size=new W(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 Gu{constructor(e,t,n){this.position=e,this.size=t,this.color=n}}class Br{constructor(){this.startSpeed=0,this.startColor=new tt,this.startSize=new W(1,1,1),this.position=new W,this.velocity=new W,this.age=0,this.life=1,this.size=new W(1,1,1),this.length=100,this.speedModifier=1,this.color=new tt,this.previous=new Ju,this.uvTile=0,this.memory=[]}update(){for(this.age<=this.life?this.previous.push(new Gu(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 ki{initialize(e){this.width.startGen(e.memory)}constructor(e){this.width=e,this.type="WidthOverLength"}update(e){if(e instanceof Br){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 ki(K(e.width))}clone(){return new ki(this.width.clone())}reset(){}}class Ri{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 Ri(new W(e.direction[0],e.direction[1],e.direction[2]),K((t=e.magnitude)!==null&&t!==void 0?t:e.force))}clone(){return new Ri(this.direction.clone(),this.magnitude.clone())}reset(){}}class Ai{constructor(e,t){this.center=e,this.magnitude=t,this.type="GravityForce",this.temp=new W}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 Ai(new W(e.center[0],e.center[1],e.center[2]),e.magnitude)}clone(){return new Ai(this.center.clone(),this.magnitude)}reset(){}}class Oi{constructor(e){this.angle=e,this.type="ChangeEmitDirection",this._temp=new W,this._q=new re,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 Oi(K(e.angle))}clone(){return new Oi(this.angle)}reset(){}}var zn;(function(r){r[r.Death=0]="Death",r[r.Birth=1]="Birth",r[r.Frame=2]="Frame"})(zn||(zn={}));class zi{constructor(e,t,n,i=zn.Frame,s=1){this.particleSystem=e,this.useVelocityAsBasis=t,this.subParticleSystem=n,this.mode=i,this.emitProbability=s,this.type="EmitSubParticleSystem",this.q_=new re,this.v_=new W,this.v2_=new W,this.subEmissions=new Array,this.subParticleSystem&&this.subParticleSystem.system&&(this.subParticleSystem.system.onlyUsedByOther=!0)}initialize(e){}update(e,t){this.mode===zn.Frame?this.emit(e,t):this.mode===zn.Birth&&e.age===0?this.emit(e,t):this.mode===zn.Death&&e.age+t>=e.life&&this.emit(e,t)}emit(e,t){if(!this.subParticleSystem||Math.random()>this.emitProbability)return;const n=new wt;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 zi(t,e.useVelocityAsBasis,e.subParticleSystem,e.mode,e.emitProbability)}clone(){return new zi(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(_a).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 re?n=t.rotation:(this.q_.setFromAxisAngle(_a,t.rotation),n=this.q_),e.compose(t.position,n,Lu);this.particleSystem.worldSpace||e.multiplyMatrices(this.particleSystem.emitter.matrixWorld,e)}}const $u=.5*(Math.sqrt(3)-1),Gn=(3-Math.sqrt(3))/6,Wu=1/3,Et=1/6,Hu=(Math.sqrt(5)-1)/4,Oe=(5-Math.sqrt(5))/20,Re=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]),Me=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 Dc{constructor(e=Math.random){const t=typeof e=="function"?e:Xu(e);this.p=qu(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)*$u,l=Math.floor(e+c),u=Math.floor(t+c),f=(l+u)*Gn,p=l-f,m=u-f,_=e-p,T=t-m;let g,v;_>T?(g=1,v=0):(g=0,v=1);const b=_-g+Gn,x=T-v+Gn,C=_-1+2*Gn,M=T-1+2*Gn,P=l&255,E=u&255;let I=.5-_*_-T*T;if(I>=0){const N=n[P+i[E]]*3;I*=I,s=I*I*(Re[N]*_+Re[N+1]*T)}let O=.5-b*b-x*x;if(O>=0){const N=n[P+g+i[E+v]]*3;O*=O,a=O*O*(Re[N]*b+Re[N+1]*x)}let A=.5-C*C-M*M;if(A>=0){const N=n[P+1+i[E+1]]*3;A*=A,o=A*A*(Re[N]*C+Re[N+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)*Wu,f=Math.floor(e+u),p=Math.floor(t+u),m=Math.floor(n+u),_=(f+p+m)*Et,T=f-_,g=p-_,v=m-_,b=e-T,x=t-g,C=n-v;let M,P,E,I,O,A;b>=x?x>=C?(M=1,P=0,E=0,I=1,O=1,A=0):b>=C?(M=1,P=0,E=0,I=1,O=0,A=1):(M=0,P=0,E=1,I=1,O=0,A=1):x<C?(M=0,P=0,E=1,I=0,O=1,A=1):b<C?(M=0,P=1,E=0,I=0,O=1,A=1):(M=0,P=1,E=0,I=1,O=1,A=0);const N=b-M+Et,z=x-P+Et,U=C-E+Et,F=b-I+2*Et,J=x-O+2*Et,j=C-A+2*Et,q=b-1+3*Et,G=x-1+3*Et,ne=C-1+3*Et,ie=f&255,he=p&255,se=m&255;let ge=.6-b*b-x*x-C*C;if(ge<0)a=0;else{const ae=i[ie+s[he+s[se]]]*3;ge*=ge,a=ge*ge*(Re[ae]*b+Re[ae+1]*x+Re[ae+2]*C)}let be=.6-N*N-z*z-U*U;if(be<0)o=0;else{const ae=i[ie+M+s[he+P+s[se+E]]]*3;be*=be,o=be*be*(Re[ae]*N+Re[ae+1]*z+Re[ae+2]*U)}let oe=.6-F*F-J*J-j*j;if(oe<0)c=0;else{const ae=i[ie+I+s[he+O+s[se+A]]]*3;oe*=oe,c=oe*oe*(Re[ae]*F+Re[ae+1]*J+Re[ae+2]*j)}let fe=.6-q*q-G*G-ne*ne;if(fe<0)l=0;else{const ae=i[ie+1+s[he+1+s[se+1]]]*3;fe*=fe,l=fe*fe*(Re[ae]*q+Re[ae+1]*G+Re[ae+2]*ne)}return 32*(a+o+c+l)}noise4D(e,t,n,i){const s=this.perm;let a,o,c,l,u;const f=(e+t+n+i)*Hu,p=Math.floor(e+f),m=Math.floor(t+f),_=Math.floor(n+f),T=Math.floor(i+f),g=(p+m+_+T)*Oe,v=p-g,b=m-g,x=_-g,C=T-g,M=e-v,P=t-b,E=n-x,I=i-C;let O=0,A=0,N=0,z=0;M>P?O++:A++,M>E?O++:N++,M>I?O++:z++,P>E?A++:N++,P>I?A++:z++,E>I?N++:z++;const U=O>=3?1:0,F=A>=3?1:0,J=N>=3?1:0,j=z>=3?1:0,q=O>=2?1:0,G=A>=2?1:0,ne=N>=2?1:0,ie=z>=2?1:0,he=O>=1?1:0,se=A>=1?1:0,ge=N>=1?1:0,be=z>=1?1:0,oe=M-U+Oe,fe=P-F+Oe,ae=E-J+Oe,je=I-j+Oe,Ue=M-q+2*Oe,De=P-G+2*Oe,Ge=E-ne+2*Oe,xe=I-ie+2*Oe,ye=M-he+3*Oe,ce=P-se+3*Oe,st=E-ge+3*Oe,Pe=I-be+3*Oe,de=M-1+4*Oe,Ye=P-1+4*Oe,yt=E-1+4*Oe,gt=I-1+4*Oe,Ze=p&255,vt=m&255,ot=_&255,at=T&255;let St=.6-M*M-P*P-E*E-I*I;if(St<0)a=0;else{const Q=s[Ze+s[vt+s[ot+s[at]]]]%32*4;St*=St,a=St*St*(Me[Q]*M+Me[Q+1]*P+Me[Q+2]*E+Me[Q+3]*I)}let Ee=.6-oe*oe-fe*fe-ae*ae-je*je;if(Ee<0)o=0;else{const Q=s[Ze+U+s[vt+F+s[ot+J+s[at+j]]]]%32*4;Ee*=Ee,o=Ee*Ee*(Me[Q]*oe+Me[Q+1]*fe+Me[Q+2]*ae+Me[Q+3]*je)}let $e=.6-Ue*Ue-De*De-Ge*Ge-xe*xe;if($e<0)c=0;else{const Q=s[Ze+q+s[vt+G+s[ot+ne+s[at+ie]]]]%32*4;$e*=$e,c=$e*$e*(Me[Q]*Ue+Me[Q+1]*De+Me[Q+2]*Ge+Me[Q+3]*xe)}let nt=.6-ye*ye-ce*ce-st*st-Pe*Pe;if(nt<0)l=0;else{const Q=s[Ze+he+s[vt+se+s[ot+ge+s[at+be]]]]%32*4;nt*=nt,l=nt*nt*(Me[Q]*ye+Me[Q+1]*ce+Me[Q+2]*st+Me[Q+3]*Pe)}let We=.6-de*de-Ye*Ye-yt*yt-gt*gt;if(We<0)u=0;else{const Q=s[Ze+1+s[vt+1+s[ot+1+s[at+1]]]]%32*4;We*=We,u=We*We*(Me[Q]*de+Me[Q+1]*Ye+Me[Q+2]*yt+Me[Q+3]*gt)}return 27*(a+o+c+l+u)}}function qu(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 Xu(r){let e=0,t=0,n=0,i=1;const s=Yu();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 Yu(){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 Ii{constructor(e,t,n,i){this.scale=e,this.octaves=t,this.velocityMultiplier=n,this.timeScale=i,this.type="TurbulenceField",this.generator=new Dc,this.timeOffset=new W,this.temp=new W,this.temp2=new W,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 Ii(new W(e.scale[0],e.scale[1],e.scale[2]),e.octaves,new W(e.velocityMultiplier[0],e.velocityMultiplier[1],e.velocityMultiplier[2]),new W(e.timeScale[0],e.timeScale[1],e.timeScale[2]))}clone(){return new Ii(this.scale.clone(),this.octaves,this.velocityMultiplier.clone(),this.timeScale.clone())}reset(){}}const kt=[],Ss=new W,xs=new re;class Bi{constructor(e,t,n=new ee(1),i=new ee(0)){if(this.frequency=e,this.power=t,this.positionAmount=n,this.rotationAmount=i,this.type="Noise",this.duration=0,kt.length===0)for(let s=0;s<100;s++)kt.push(new Dc)}initialize(e){e.lastPosNoise=new W,typeof e.rotation=="number"?e.lastRotNoise=0:e.lastRotNoise=new re,e.generatorIndex=[ir(0,100),ir(0,100),ir(0,100),ir(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),Ss.set(kt[e.generatorIndex[0]].noise2D(0,e.age*n)*i*s,kt[e.generatorIndex[1]].noise2D(0,e.age*n)*i*s,kt[e.generatorIndex[2]].noise2D(0,e.age*n)*i*s),e.position.add(Ss),e.lastPosNoise.copy(Ss)),a>0&&e.lastRotNoise!==void 0&&(typeof e.rotation=="number"?(e.rotation-=e.lastRotNoise,e.rotation+=kt[e.generatorIndex[3]].noise2D(0,e.age*n)*Math.PI*i*a):(e.lastRotNoise.invert(),e.rotation.multiply(e.lastRotNoise),xs.set(kt[e.generatorIndex[0]].noise2D(0,e.age*n)*i*a,kt[e.generatorIndex[1]].noise2D(0,e.age*n)*i*a,kt[e.generatorIndex[2]].noise2D(0,e.age*n)*i*a,kt[e.generatorIndex[3]].noise2D(0,e.age*n)*i*a).normalize(),e.rotation.multiply(xs),e.lastRotNoise.copy(xs)))}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 Bi(K(e.frequency),K(e.power),K(e.positionAmount),K(e.rotationAmount))}clone(){return new Bi(this.frequency.clone(),this.power.clone(),this.positionAmount.clone(),this.rotationAmount.clone())}reset(){}}class Ni{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 Ni(co(e.color),vn.fromJSON(e.speedRange))}clone(){return new Ni(this.color.clone(),this.speedRange.clone())}reset(){}}class Ui{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 Sn?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 Ui(Ir(e.size),vn.fromJSON(e.speedRange))}frameUpdate(e){}clone(){return new Ui(this.size.clone(),this.speedRange.clone())}reset(){}}class Di{constructor(e,t){this.angularVelocity=e,this.speedRange=t,this.type="RotationBySpeed",this.tempQuat=new re}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 Di(K(e.angularVelocity),vn.fromJSON(e.speedRange))}frameUpdate(e){}clone(){return new Di(this.angularVelocity.clone(),this.speedRange.clone())}reset(){}}class Fi{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 Fi(K(e.speed),e.dampen)}frameUpdate(e){}clone(){return new Fi(this.speed.clone(),this.dampen)}reset(){}}const Nr={ApplyForce:{type:"ApplyForce",constructor:Ri,params:[["direction",["vec3"]],["magnitude",["value"]]],loadJSON:Ri.fromJSON},Noise:{type:"Noise",constructor:Bi,params:[["frequency",["value"]],["power",["value"]],["positionAmount",["value"]],["rotationAmount",["value"]]],loadJSON:Bi.fromJSON},TurbulenceField:{type:"TurbulenceField",constructor:Ii,params:[["scale",["vec3"]],["octaves",["number"]],["velocityMultiplier",["vec3"]],["timeScale",["vec3"]]],loadJSON:Ii.fromJSON},GravityForce:{type:"GravityForce",constructor:Ai,params:[["center",["vec3"]],["magnitude",["number"]]],loadJSON:Ai.fromJSON},ColorOverLife:{type:"ColorOverLife",constructor:_i,params:[["color",["colorFunc"]]],loadJSON:_i.fromJSON},RotationOverLife:{type:"RotationOverLife",constructor:bi,params:[["angularVelocity",["value","valueFunc"]]],loadJSON:bi.fromJSON},Rotation3DOverLife:{type:"Rotation3DOverLife",constructor:Ti,params:[["angularVelocity",["rotationFunc"]]],loadJSON:Ti.fromJSON},SizeOverLife:{type:"SizeOverLife",constructor:Ci,params:[["size",["value","valueFunc","vec3Func"]]],loadJSON:Ci.fromJSON},ColorBySpeed:{type:"ColorBySpeed",constructor:Ni,params:[["color",["colorFunc"]],["speedRange",["range"]]],loadJSON:Ni.fromJSON},RotationBySpeed:{type:"RotationBySpeed",constructor:Di,params:[["angularVelocity",["value","valueFunc"]],["speedRange",["range"]]],loadJSON:Di.fromJSON},SizeBySpeed:{type:"SizeBySpeed",constructor:Ui,params:[["size",["value","valueFunc","vec3Func"]],["speedRange",["range"]]],loadJSON:Ui.fromJSON},SpeedOverLife:{type:"SpeedOverLife",constructor:wi,params:[["speed",["value","valueFunc"]]],loadJSON:wi.fromJSON},FrameOverLife:{type:"FrameOverLife",constructor:Pi,params:[["frame",["value","valueFunc"]]],loadJSON:Pi.fromJSON},ForceOverLife:{type:"ForceOverLife",constructor:Mi,params:[["x",["value","valueFunc"]],["y",["value","valueFunc"]],["z",["value","valueFunc"]]],loadJSON:Mi.fromJSON},OrbitOverLife:{type:"OrbitOverLife",constructor:Ei,params:[["orbitSpeed",["value","valueFunc"]],["axis",["vec3"]]],loadJSON:Ei.fromJSON},WidthOverLength:{type:"WidthOverLength",constructor:ki,params:[["width",["value","valueFunc"]]],loadJSON:ki.fromJSON},ChangeEmitDirection:{type:"ChangeEmitDirection",constructor:Oi,params:[["angle",["value"]]],loadJSON:Oi.fromJSON},EmitSubParticleSystem:{type:"EmitSubParticleSystem",constructor:zi,params:[["particleSystem",["self"]],["useVelocityAsBasis",["boolean"]],["subParticleSystem",["particleSystem"]],["mode",["number"]],["emitProbability",["number"]]],loadJSON:zi.fromJSON},LimitSpeedOverLife:{type:"LimitSpeedOverLife",constructor:Fi,params:[["speed",["value","valueFunc"]],["dampen",["number"]]],loadJSON:Fi.fromJSON}};function Zu(r,e){return Nr[r.type]?Nr[r.type].loadJSON(r,e):null}const Ku=[];function Qu(r){if(!Ku.find(t=>t.id===r.id)){for(const t of r.emitterShapes)$s[t.type]||($s[t.type]=t);for(const t of r.behaviors)Nr[t.type]||(Nr[t.type]=t)}}var eh=`
78
+ isUnifiedPlanSupported:`).concat(this.isUnifiedPlanSupported())},r})()),ea={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"},Bl=(function(){function r(){this.CLOUD_HOST="0.peerjs.com",this.CLOUD_PORT=443,this.chunkedBrowsers={Chrome:1,chrome:1},this.chunkedMTU=16300,this.defaultConfig=ea,this.browser=Jn.getBrowser(),this.browserVersion=Jn.getVersion(),this.supports=(function(){var e={browser:Jn.isBrowserSupported(),webRTC:Jn.isWebRTCSupported(),audioVideo:!1,data:!1,binaryBlob:!1,reliable:!1};if(!e.webRTC)return e;var t;try{t=new RTCPeerConnection(ea),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=!Jn.isIOS}catch{}}catch{}finally{n&&n.close()}}catch{}finally{t&&t.close()}return e})(),this.pack=jo.pack,this.unpack=jo.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 Bl,Pc={};zt(Pc,"Peer",()=>Gs,r=>Gs=r);var Vi={},Nl=Object.prototype.hasOwnProperty,Xe="~";function ci(){}Object.create&&(ci.prototype=Object.create(null),new ci().__proto__||(Xe=!1));function Ul(r,e,t){this.fn=r,this.context=e,this.once=t||!1}function Ec(r,e,t,n,i){if(typeof t!="function")throw new TypeError("The listener must be a function");var s=new Ul(t,n||r,i),a=Xe?Xe+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 Pr(r,e){--r._eventsCount===0?r._events=new ci:delete r._events[e]}function Ve(){this._events=new ci,this._eventsCount=0}Ve.prototype.eventNames=function(){var e=[],t,n;if(this._eventsCount===0)return e;for(n in t=this._events)Nl.call(t,n)&&e.push(Xe?n.slice(1):n);return Object.getOwnPropertySymbols?e.concat(Object.getOwnPropertySymbols(t)):e};Ve.prototype.listeners=function(e){var t=Xe?Xe+e:e,n=this._events[t];if(!n)return[];if(n.fn)return[n.fn];for(var i=0,s=n.length,a=new Array(s);i<s;i++)a[i]=n[i].fn;return a};Ve.prototype.listenerCount=function(e){var t=Xe?Xe+e:e,n=this._events[t];return n?n.fn?1:n.length:0};Ve.prototype.emit=function(e,t,n,i,s,a){var o=Xe?Xe+e:e;if(!this._events[o])return!1;var c=this._events[o],l=arguments.length,u,f;if(c.fn){switch(c.once&&this.removeListener(e,c.fn,void 0,!0),l){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,t),!0;case 3:return c.fn.call(c.context,t,n),!0;case 4:return c.fn.call(c.context,t,n,i),!0;case 5:return c.fn.call(c.context,t,n,i,s),!0;case 6:return c.fn.call(c.context,t,n,i,s,a),!0}for(f=1,u=new Array(l-1);f<l;f++)u[f-1]=arguments[f];c.fn.apply(c.context,u)}else{var p=c.length,m;for(f=0;f<p;f++)switch(c[f].once&&this.removeListener(e,c[f].fn,void 0,!0),l){case 1:c[f].fn.call(c[f].context);break;case 2:c[f].fn.call(c[f].context,t);break;case 3:c[f].fn.call(c[f].context,t,n);break;case 4:c[f].fn.call(c[f].context,t,n,i);break;default:if(!u)for(m=1,u=new Array(l-1);m<l;m++)u[m-1]=arguments[m];c[f].fn.apply(c[f].context,u)}}return!0};Ve.prototype.on=function(e,t,n){return Ec(this,e,t,n,!1)};Ve.prototype.once=function(e,t,n){return Ec(this,e,t,n,!0)};Ve.prototype.removeListener=function(e,t,n,i){var s=Xe?Xe+e:e;if(!this._events[s])return this;if(!t)return Pr(this,s),this;var a=this._events[s];if(a.fn)a.fn===t&&(!i||a.once)&&(!n||a.context===n)&&Pr(this,s);else{for(var o=0,c=[],l=a.length;o<l;o++)(a[o].fn!==t||i&&!a[o].once||n&&a[o].context!==n)&&c.push(a[o]);c.length?this._events[s]=c.length===1?c[0]:c:Pr(this,s)}return this};Ve.prototype.removeAllListeners=function(e){var t;return e?(t=Xe?Xe+e:e,this._events[t]&&Pr(this,t)):(this._events=new ci,this._eventsCount=0),this};Ve.prototype.off=Ve.prototype.removeListener;Ve.prototype.addListener=Ve.prototype.on;Ve.prefixed=Xe;Ve.EventEmitter=Ve;Vi=Ve;var $={};zt($,"LogLevel",()=>Qe,r=>Qe=r);zt($,"default",()=>ta,r=>ta=r);var on=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},an=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))},Dl="PeerJS: ",Qe;(function(r){r[r.Disabled=0]="Disabled",r[r.Errors=1]="Errors",r[r.Warnings=2]="Warnings",r[r.All=3]="All"})(Qe||(Qe={}));var Fl=(function(){function r(){this._logLevel=Qe.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>=Qe.All&&this._print.apply(this,an([Qe.All],on(e),!1))},r.prototype.warn=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this._logLevel>=Qe.Warnings&&this._print.apply(this,an([Qe.Warnings],on(e),!1))},r.prototype.error=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this._logLevel>=Qe.Errors&&this._print.apply(this,an([Qe.Errors],on(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=an([Dl],on(t),!1);for(var s in i)i[s]instanceof Error&&(i[s]="("+i[s].name+") "+i[s].message);e>=Qe.All?console.log.apply(console,an([],on(i),!1)):e>=Qe.Warnings?console.warn.apply(console,an(["WARNING"],on(i),!1)):e>=Qe.Errors&&console.error.apply(console,an(["ERROR"],on(i),!1))},r})(),ta=new Fl,kc={};zt(kc,"Socket",()=>na,r=>na=r);var Ct;(function(r){r.Data="data",r.Media="media"})(Ct||(Ct={}));var _e;(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"})(_e||(_e={}));var Vt;(function(r){r.Binary="binary",r.BinaryUTF8="binary-utf8",r.JSON="json"})(Vt||(Vt={}));var Gt;(function(r){r.Message="message",r.Disconnected="disconnected",r.Error="error",r.Close="close"})(Gt||(Gt={}));var Ne;(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"})(Ne||(Ne={}));var so={};so=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ückler <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>","Sören 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 Ll=(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)}})(),Vl=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},Jl=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))},jl=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.")},na=(function(r){Ll(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="+so.version),this._disconnected=!1,this._socket.onmessage=function(a){var o;try{o=JSON.parse(a.data),$.default.log("Server message received:",o)}catch{$.default.log("Invalid server message",a.data);return}i.emit(Gt.Message,o)},this._socket.onclose=function(a){i._disconnected||($.default.log("Socket closed.",a),i._cleanup(),i._disconnected=!0,i.emit(Gt.Disconnected))},this._socket.onopen=function(){i._disconnected||(i._sendQueuedMessages(),$.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()){$.default.log("Cannot send heartbeat, because socket closed");return}var t=JSON.stringify({type:Ne.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=Jl([],Vl(this._messagesQueue),!1);this._messagesQueue=[];try{for(var s=jl(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(Gt.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})(Vi.EventEmitter),Js={};zt(Js,"MediaConnection",()=>sa,r=>sa=r);var oo={};zt(oo,"Negotiator",()=>ia,r=>ia=r);var kr=function(){return kr=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},kr.apply(this,arguments)},Ki=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(f){a(f)}}function c(u){try{l(n.throw(u))}catch(f){a(f)}}function l(u){u.done?s(u.value):i(u.value).then(o,c)}l((n=n.apply(r,e||[])).next())})},Qi=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}}},ia=(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===Ct.Media&&e._stream&&this._addTracksToConnection(e._stream,t),e.originator){if(this.connection.type===Ct.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(){$.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;$.default.log("Listening for ICE candidates."),e.onicecandidate=function(o){!o.candidate||!o.candidate.candidate||($.default.log("Received ICE candidates for ".concat(n,":"),o.candidate),a.socket.send({type:Ne.Candidate,payload:{candidate:o.candidate,type:s,connectionId:i},dst:n}))},e.oniceconnectionstatechange=function(){switch(e.iceConnectionState){case"failed":$.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":$.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":$.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)},$.default.log("Listening for data channel"),e.ondatachannel=function(o){$.default.log("Received data channel");var c=o.channel,l=a.getConnection(n,i);l.initialize(c)},$.default.log("Listening for remote stream"),e.ontrack=function(o){$.default.log("Received remote stream");var c=o.streams[0],l=a.getConnection(n,i);if(l.type===Ct.Media){var u=l;t._addStreamToMediaConnection(c,u)}}},r.prototype.cleanup=function(){$.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===Ct.Data){var i=this.connection,s=i.dataChannel;s&&(n=!!s.readyState&&s.readyState!=="closed")}(t||n)&&e.close()}},r.prototype._makeOffer=function(){return Ki(this,void 0,Promise,function(){var e,t,n,i,s,a,o;return Qi(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(),$.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(),$.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===Ct.Data&&(s=this.connection,i=kr(kr({},i),{label:s.label,reliable:s.reliable,serialization:s.serialization})),t.socket.send({type:Ne.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(_e.WebRTC,a),$.default.log("Failed to setLocalDescription, ",a)),[3,6];case 6:return[3,8];case 7:return o=c.sent(),t.emitError(_e.WebRTC,o),$.default.log("Failed to createOffer, ",o),[3,8];case 8:return[2]}})})},r.prototype._makeAnswer=function(){return Ki(this,void 0,Promise,function(){var e,t,n,i,s;return Qi(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(),$.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(),$.default.log("Set localDescription:",n,"for:".concat(this.connection.peer)),t.socket.send({type:Ne.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(_e.WebRTC,i),$.default.log("Failed to setLocalDescription, ",i),[3,6];case 6:return[3,8];case 7:return s=a.sent(),t.emitError(_e.WebRTC,s),$.default.log("Failed to create answer, ",s),[3,8];case 8:return[2]}})})},r.prototype.handleSDP=function(e,t){return Ki(this,void 0,Promise,function(){var n,i,s,a;return Qi(this,function(o){switch(o.label){case 0:t=new RTCSessionDescription(t),n=this.connection.peerConnection,i=this.connection.provider,$.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(),$.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(_e.WebRTC,a),$.default.log("Failed to setRemoteDescription, ",a),[3,6];case 6:return[2]}})})},r.prototype.handleCandidate=function(e){return Ki(this,void 0,Promise,function(){var t,n,i,s,a,o;return Qi(this,function(c){switch(c.label){case 0:$.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(),$.default.log("Added ICE candidate for:".concat(this.connection.peer)),[3,4];case 3:return o=c.sent(),a.emitError(_e.WebRTC,o),$.default.log("Failed to handleCandidate, ",o),[3,4];case 4:return[2]}})})},r.prototype._addTracksToConnection=function(e,t){if($.default.log("add tracks from stream ".concat(e.id," to peer connection")),!t.addTrack)return $.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){$.default.log("add stream ".concat(e.id," to media connection ").concat(t.connectionId)),t.addStream(e)},r})(),ao={};zt(ao,"BaseConnection",()=>ra,r=>ra=r);var Gl=(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)}})(),ra=(function(r){Gl(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})(Vi.EventEmitter),$l=(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)}})(),Rr=function(){return Rr=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},Rr.apply(this,arguments)},Wl=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.")},sa=(function(r){$l(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 oo.Negotiator(s),s._localStream&&s._negotiator.startConnection({_stream:s._localStream,originator:!0}),s}return Object.defineProperty(e.prototype,"type",{get:function(){return Ct.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){$.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 Ne.Answer:this._negotiator.handleSDP(n,i.sdp),this._open=!0;break;case Ne.Candidate:this._negotiator.handleCandidate(i.candidate);break;default:$.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){$.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(Rr(Rr({},this.options._payload),{_stream:t}));var a=this.provider._getMessages(this.connectionId);try{for(var o=Wl(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})(ao.BaseConnection),js={};zt(js,"DataConnection",()=>aa,r=>aa=r);var Rc={};zt(Rc,"EncodingQueue",()=>oa,r=>oa=r);var Hl=(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)}})(),oa=(function(r){Hl(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){$.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})(Vi.EventEmitter),ql=(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)}})(),Xl=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.")},aa=(function(r){ql(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 Rc.EncodingQueue,s.connectionId=s.options.connectionId||e.ID_PREFIX+te.randomToken(),s.label=s.options.label||s.connectionId,s.serialization=s.options.serialization||Vt.Binary,s.reliable=!!s.options.reliable,s._encodingQueue.on("done",function(a){s._bufferedSend(a)}),s._encodingQueue.on("error",function(){$.default.error("DC#".concat(s.connectionId,": Error occured in encoding from blob to arraybuffer, close DC")),s.close()}),s._negotiator=new oo.Negotiator(s),s._negotiator.startConnection(s.options._payload||{originator:!0}),s}return Object.defineProperty(e.prototype,"type",{get:function(){return Ct.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(){$.default.log("DC#".concat(t.connectionId," dc connection success")),t._open=!0,t.emit("open")},this.dataChannel.onmessage=function(n){$.default.log("DC#".concat(t.connectionId," dc onmessage:"),n.data),t._handleDataMessage(n)},this.dataChannel.onclose=function(){$.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===Vt.Binary||this.serialization===Vt.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===Vt.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===Vt.JSON)this._bufferedSend(this.stringify(t));else if(this.serialization===Vt.Binary||this.serialization===Vt.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 $.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);$.default.log("DC#".concat(this.connectionId," Try to send ").concat(s.length," chunks..."));try{for(var a=Xl(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 Ne.Answer:this._negotiator.handleSDP(t.type,n.sdp);break;case Ne.Candidate:this._negotiator.handleCandidate(n.candidate);break;default:$.default.warn("Unrecognized message type:",t.type,"from peer:",this.peer);break}},e.ID_PREFIX="dc_",e.MAX_BUFFERED_AMOUNT=8388608,e})(ao.BaseConnection),Ac={};zt(Ac,"API",()=>ua,r=>ua=r);var ca=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(f){a(f)}}function c(u){try{l(n.throw(u))}catch(f){a(f)}}function l(u){u.done?s(u.value):i(u.value).then(o,c)}l((n=n.apply(r,e||[])).next())})},la=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}}},ua=(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",so.version),fetch(c.href,{referrerPolicy:this._options.referrerPolicy})},r.prototype.retrieveId=function(){return ca(this,void 0,Promise,function(){var e,t,n;return la(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(),$.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 ca(this,void 0,Promise,function(){var e,t,n;return la(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(),$.default.error("Error retrieving list peers",n),new Error("Could not get list peers from the server."+n);case 3:return[2]}})})},r})(),Yl=(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)}})(),ri=function(){return ri=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},ri.apply(this,arguments)},jn=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.")},Zl=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},Gs=(function(r){Yl(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=ri({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&&$.default.setLogFunction(i._options.logFunction),$.default.logLevel=i._options.debug||0,i._api=new Ac.API(n),i._socket=i._createServerConnection(),!te.supports.audioVideo&&!te.supports.data?(i._delayedAbort(_e.BrowserIncompatible,"The current browser does not support WebRTC"),i):s&&!te.validateId(s)?(i._delayedAbort(_e.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(_e.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=jn(this._connections),a=s.next();!a.done;a=s.next()){var o=Zl(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 kc.Socket(this._options.secure,this._options.host,this._options.port,this._options.path,this._options.key,this._options.pingInterval);return n.on(Gt.Message,function(i){t._handleMessage(i)}),n.on(Gt.Error,function(i){t._abort(_e.SocketError,i)}),n.on(Gt.Disconnected,function(){t.disconnected||(t.emitError(_e.Network,"Lost connection to server."),t.disconnect())}),n.on(Gt.Close,function(){t.disconnected||t._abort(_e.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 Ne.Open:this._lastServerId=this.id,this._open=!0,this.emit("open",this.id);break;case Ne.Error:this._abort(_e.ServerError,a.msg);break;case Ne.IdTaken:this._abort(_e.UnavailableID,'ID "'.concat(this.id,'" is taken'));break;case Ne.InvalidKey:this._abort(_e.InvalidKey,'API KEY "'.concat(this._options.key,'" is invalid'));break;case Ne.Leave:$.default.log("Received leave message from ".concat(o)),this._cleanupPeer(o),this._connections.delete(o);break;case Ne.Expire:this.emitError(_e.PeerUnavailable,"Could not connect to peer ".concat(o));break;case Ne.Offer:var _=a.connectionId,T=this.getConnection(o,_);if(T&&(T.close(),$.default.warn("Offer received for existing Connection ID:".concat(_))),a.type===Ct.Media){var c=new Js.MediaConnection(o,this,{connectionId:_,_payload:a,metadata:a.metadata});T=c,this._addConnection(o,T),this.emit("call",c)}else if(a.type===Ct.Data){var l=new js.DataConnection(o,this,{connectionId:_,_payload:a,metadata:a.metadata,label:a.label,serialization:a.serialization,reliable:a.reliable});T=l,this._addConnection(o,T),this.emit("connection",l)}else{$.default.warn("Received malformed connection type:".concat(a.type));return}var u=this._getMessages(_);try{for(var f=jn(u),p=f.next();!p.done;p=f.next()){var m=p.value;T.handleMessage(m)}}catch(g){n={error:g}}finally{try{p&&!p.done&&(i=f.return)&&i.call(f)}finally{if(n)throw n.error}}break;default:if(!a){$.default.warn("You received a malformed message from ".concat(o," of type ").concat(s));return}var _=a.connectionId,T=this.getConnection(o,_);T&&T.peerConnection?T.handleMessage(t):_?this._storeMessage(_,t):$.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){$.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(_e.Disconnected,"Cannot connect to new Peer after disconnecting from server.");return}var i=new js.DataConnection(t,this,n);return this._addConnection(t,i),i},e.prototype.call=function(t,n,i){if(i===void 0&&(i={}),this.disconnected){$.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(_e.Disconnected,"Cannot connect to new Peer after disconnecting from server.");return}if(!n){$.default.error("To call a peer, you must provide a stream from your browser's `getUserMedia`.");return}var s=new Js.MediaConnection(t,this,ri(ri({},i),{_stream:n}));return this._addConnection(t,s),s},e.prototype._addConnection=function(t,n){$.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=jn(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){$.default.error("Aborting!"),this.emitError(t,n),this._lastServerId?this.disconnect():this.destroy()},e.prototype.emitError=function(t,n){$.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||($.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=jn(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=jn(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;$.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)$.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)$.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(_e.ServerError,i)})},e.DEFAULT_KEY="peerjs",e})(Vi.EventEmitter),Oc=Pc.Peer;const Kl=Object.freeze(Object.defineProperty({__proto__:null,get Peer(){return Gs},default:Oc,util:te},Symbol.toStringTag,{value:"Module"})),Ql=/^(?:[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 eu(r){return typeof r=="string"&&Ql.test(r)}const Be=[];for(let r=0;r<256;++r)Be.push((r+256).toString(16).slice(1));function tu(r,e=0){return Be[r[e+0]]+Be[r[e+1]]+Be[r[e+2]]+Be[r[e+3]]+"-"+Be[r[e+4]]+Be[r[e+5]]+"-"+Be[r[e+6]]+Be[r[e+7]]+"-"+Be[r[e+8]]+Be[r[e+9]]+"-"+Be[r[e+10]]+Be[r[e+11]]+Be[r[e+12]]+Be[r[e+13]]+Be[r[e+14]]+Be[r[e+15]]}function nu(r){if(!eu(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 iu(r){r=unescape(encodeURIComponent(r));const e=[];for(let t=0;t<r.length;++t)e.push(r.charCodeAt(t));return e}const ru="6ba7b810-9dad-11d1-80b4-00c04fd430c8",su="6ba7b811-9dad-11d1-80b4-00c04fd430c8";function ou(r,e,t){function n(i,s,a,o){var c;if(typeof i=="string"&&(i=iu(i)),typeof s=="string"&&(s=nu(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 tu(l)}try{n.name=r}catch{}return n.DNS=ru,n.URL=su,n}function au(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 us(r,e){return r<<e|r>>>32-e}function cu(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]=us(o[m-3]^o[m-8]^o[m-14]^o[m-16],1);let c=t[0],l=t[1],u=t[2],f=t[3],p=t[4];for(let m=0;m<80;++m){const _=Math.floor(m/20),T=us(c,5)+au(_,l,u,f)+p+e[_]+o[m]>>>0;p=f,f=u,u=us(l,30)>>>0,l=c,c=T}t[0]=t[0]+c>>>0,t[1]=t[1]+l>>>0,t[2]=t[2]+u>>>0,t[3]=t[3]+f>>>0,t[4]=t[4]+p>>>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 lu=ou("v5",80,cu);var hs={exports:{}},fs={exports:{}},ha;function uu(){return ha||(ha=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}};fs.exports=e})()),fs.exports}var ds,fa;function da(){if(fa)return ds;fa=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 ds=r,ds}var ps,pa;function hu(){if(pa)return ps;pa=1,ps=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 ps}var ma;function fu(){return ma||(ma=1,(function(){var r=uu(),e=da().utf8,t=hu(),n=da().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,f=-1732584194,p=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 _=i._ff,T=i._gg,g=i._hh,v=i._ii,m=0;m<o.length;m+=16){var b=l,x=u,C=f,M=p;l=_(l,u,f,p,o[m+0],7,-680876936),p=_(p,l,u,f,o[m+1],12,-389564586),f=_(f,p,l,u,o[m+2],17,606105819),u=_(u,f,p,l,o[m+3],22,-1044525330),l=_(l,u,f,p,o[m+4],7,-176418897),p=_(p,l,u,f,o[m+5],12,1200080426),f=_(f,p,l,u,o[m+6],17,-1473231341),u=_(u,f,p,l,o[m+7],22,-45705983),l=_(l,u,f,p,o[m+8],7,1770035416),p=_(p,l,u,f,o[m+9],12,-1958414417),f=_(f,p,l,u,o[m+10],17,-42063),u=_(u,f,p,l,o[m+11],22,-1990404162),l=_(l,u,f,p,o[m+12],7,1804603682),p=_(p,l,u,f,o[m+13],12,-40341101),f=_(f,p,l,u,o[m+14],17,-1502002290),u=_(u,f,p,l,o[m+15],22,1236535329),l=T(l,u,f,p,o[m+1],5,-165796510),p=T(p,l,u,f,o[m+6],9,-1069501632),f=T(f,p,l,u,o[m+11],14,643717713),u=T(u,f,p,l,o[m+0],20,-373897302),l=T(l,u,f,p,o[m+5],5,-701558691),p=T(p,l,u,f,o[m+10],9,38016083),f=T(f,p,l,u,o[m+15],14,-660478335),u=T(u,f,p,l,o[m+4],20,-405537848),l=T(l,u,f,p,o[m+9],5,568446438),p=T(p,l,u,f,o[m+14],9,-1019803690),f=T(f,p,l,u,o[m+3],14,-187363961),u=T(u,f,p,l,o[m+8],20,1163531501),l=T(l,u,f,p,o[m+13],5,-1444681467),p=T(p,l,u,f,o[m+2],9,-51403784),f=T(f,p,l,u,o[m+7],14,1735328473),u=T(u,f,p,l,o[m+12],20,-1926607734),l=g(l,u,f,p,o[m+5],4,-378558),p=g(p,l,u,f,o[m+8],11,-2022574463),f=g(f,p,l,u,o[m+11],16,1839030562),u=g(u,f,p,l,o[m+14],23,-35309556),l=g(l,u,f,p,o[m+1],4,-1530992060),p=g(p,l,u,f,o[m+4],11,1272893353),f=g(f,p,l,u,o[m+7],16,-155497632),u=g(u,f,p,l,o[m+10],23,-1094730640),l=g(l,u,f,p,o[m+13],4,681279174),p=g(p,l,u,f,o[m+0],11,-358537222),f=g(f,p,l,u,o[m+3],16,-722521979),u=g(u,f,p,l,o[m+6],23,76029189),l=g(l,u,f,p,o[m+9],4,-640364487),p=g(p,l,u,f,o[m+12],11,-421815835),f=g(f,p,l,u,o[m+15],16,530742520),u=g(u,f,p,l,o[m+2],23,-995338651),l=v(l,u,f,p,o[m+0],6,-198630844),p=v(p,l,u,f,o[m+7],10,1126891415),f=v(f,p,l,u,o[m+14],15,-1416354905),u=v(u,f,p,l,o[m+5],21,-57434055),l=v(l,u,f,p,o[m+12],6,1700485571),p=v(p,l,u,f,o[m+3],10,-1894986606),f=v(f,p,l,u,o[m+10],15,-1051523),u=v(u,f,p,l,o[m+1],21,-2054922799),l=v(l,u,f,p,o[m+8],6,1873313359),p=v(p,l,u,f,o[m+15],10,-30611744),f=v(f,p,l,u,o[m+6],15,-1560198380),u=v(u,f,p,l,o[m+13],21,1309151649),l=v(l,u,f,p,o[m+4],6,-145523070),p=v(p,l,u,f,o[m+11],10,-1120210379),f=v(f,p,l,u,o[m+2],15,718787259),u=v(u,f,p,l,o[m+9],21,-343485551),l=l+b>>>0,u=u+x>>>0,f=f+C>>>0,p=p+M>>>0}return r.endian([l,u,f,p])};i._ff=function(s,a,o,c,l,u,f){var p=s+(a&o|~a&c)+(l>>>0)+f;return(p<<u|p>>>32-u)+a},i._gg=function(s,a,o,c,l,u,f){var p=s+(a&c|o&~c)+(l>>>0)+f;return(p<<u|p>>>32-u)+a},i._hh=function(s,a,o,c,l,u,f){var p=s+(a^o^c)+(l>>>0)+f;return(p<<u|p>>>32-u)+a},i._ii=function(s,a,o,c,l,u,f){var p=s+(o^(a|~c))+(l>>>0)+f;return(p<<u|p>>>32-u)+a},i._blocksize=16,i._digestsize=16,hs.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)}})()),hs.exports}var du=fu();const pu=Fr(du),Le=["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 ya=1234567;const zc=Math.PI/180,Ic=180/Math.PI;function mu(){const r=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(Le[r&255]+Le[r>>8&255]+Le[r>>16&255]+Le[r>>24&255]+"-"+Le[e&255]+Le[e>>8&255]+"-"+Le[e>>16&15|64]+Le[e>>24&255]+"-"+Le[t&63|128]+Le[t>>8&255]+"-"+Le[t>>16&255]+Le[t>>24&255]+Le[n&255]+Le[n>>8&255]+Le[n>>16&255]+Le[n>>24&255]).toLowerCase()}function Rt(r,e,t){return Math.max(e,Math.min(t,r))}function Bc(r,e){return(r%e+e)%e}function yu(r,e,t,n,i){return n+(r-e)*(i-n)/(t-e)}function gu(r,e,t){return r!==e?(t-r)/(e-r):0}function Nc(r,e,t){return(1-t)*r+t*e}function vu(r,e,t,n){return Nc(r,e,1-Math.exp(-t*n))}function Su(r,e=1){return e-Math.abs(Bc(r,e*2)-e)}function xu(r,e,t){return r<=e?0:r>=t?1:(r=(r-e)/(t-e),r*r*(3-2*r))}function _u(r,e,t){return r<=e?0:r>=t?1:(r=(r-e)/(t-e),r*r*r*(r*(r*6-15)+10))}function bu(r,e){return r+Math.floor(Math.random()*(e-r+1))}function Tu(r,e){return r+Math.random()*(e-r)}function Mu(r){return r*(.5-Math.random())}function Cu(r){r!==void 0&&(ya=r);let e=ya+=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 wu(r){return r*zc}function Pu(r){return r*Ic}function Eu(r){return(r&r-1)===0&&r!==0}function ku(r){return Math.pow(2,Math.ceil(Math.log(r)/Math.LN2))}function Ru(r){return Math.pow(2,Math.floor(Math.log(r)/Math.LN2))}function Au(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),f=s((e-n)/2),p=a((e-n)/2),m=s((n-e)/2),_=a((n-e)/2);switch(i){case"XYX":r.set(o*u,c*f,c*p,o*l);break;case"YZY":r.set(c*p,o*u,c*f,o*l);break;case"ZXZ":r.set(c*f,c*p,o*u,o*l);break;case"XZX":r.set(o*u,c*_,c*m,o*l);break;case"YXY":r.set(c*m,o*u,c*_,o*l);break;case"ZYZ":r.set(c*_,c*m,o*u,o*l);break;default:console.warn("../math.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+i)}}function Ou(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 zu(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 Fn={DEG2RAD:zc,RAD2DEG:Ic,generateUUID:mu,clamp:Rt,euclideanModulo:Bc,mapLinear:yu,inverseLerp:gu,lerp:Nc,damp:vu,pingpong:Su,smoothstep:xu,smootherstep:_u,randInt:bu,randFloat:Tu,randFloatSpread:Mu,seededRandom:Cu,degToRad:wu,radToDeg:Pu,isPowerOfTwo:Eu,ceilPowerOfTwo:ku,floorPowerOfTwo:Ru,setQuaternionFromProperEuler:Au,normalize:zu,denormalize:Ou};class re{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],f=n[i+3];const p=s[a+0],m=s[a+1],_=s[a+2],T=s[a+3];if(o===0){e[t+0]=c,e[t+1]=l,e[t+2]=u,e[t+3]=f;return}if(o===1){e[t+0]=p,e[t+1]=m,e[t+2]=_,e[t+3]=T;return}if(f!==T||c!==p||l!==m||u!==_){let g=1-o;const v=c*p+l*m+u*_+f*T,b=v>=0?1:-1,x=1-v*v;if(x>Number.EPSILON){const M=Math.sqrt(x),P=Math.atan2(M,v*b);g=Math.sin(g*P)/M,o=Math.sin(o*P)/M}const C=o*b;if(c=c*g+p*C,l=l*g+m*C,u=u*g+_*C,f=f*g+T*C,g===1-o){const M=1/Math.sqrt(c*c+l*l+u*u+f*f);c*=M,l*=M,u*=M,f*=M}}e[t]=c,e[t+1]=l,e[t+2]=u,e[t+3]=f}static multiplyQuaternionsFlat(e,t,n,i,s,a){const o=n[i],c=n[i+1],l=n[i+2],u=n[i+3],f=s[a],p=s[a+1],m=s[a+2],_=s[a+3];return e[t]=o*_+u*f+c*m-l*p,e[t+1]=c*_+u*p+l*f-o*m,e[t+2]=l*_+u*m+o*p-c*f,e[t+3]=u*_-o*f-c*p-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 re(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),f=o(s/2),p=c(n/2),m=c(i/2),_=c(s/2);switch(a){case"XYZ":this._x=p*u*f+l*m*_,this._y=l*m*f-p*u*_,this._z=l*u*_+p*m*f,this._w=l*u*f-p*m*_;break;case"YXZ":this._x=p*u*f+l*m*_,this._y=l*m*f-p*u*_,this._z=l*u*_-p*m*f,this._w=l*u*f+p*m*_;break;case"ZXY":this._x=p*u*f-l*m*_,this._y=l*m*f+p*u*_,this._z=l*u*_+p*m*f,this._w=l*u*f-p*m*_;break;case"ZYX":this._x=p*u*f-l*m*_,this._y=l*m*f+p*u*_,this._z=l*u*_-p*m*f,this._w=l*u*f+p*m*_;break;case"YZX":this._x=p*u*f+l*m*_,this._y=l*m*f+p*u*_,this._z=l*u*_-p*m*f,this._w=l*u*f-p*m*_;break;case"XZY":this._x=p*u*f-l*m*_,this._y=l*m*f-p*u*_,this._z=l*u*_+p*m*f,this._w=l*u*f+p*m*_;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],f=t[10],p=n+o+f;if(p>0){const m=.5/Math.sqrt(p+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>f){const m=2*Math.sqrt(1+n-o-f);this._w=(u-c)/m,this._x=.25*m,this._y=(i+a)/m,this._z=(s+l)/m}else if(o>f){const m=2*Math.sqrt(1+o-n-f);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+f-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(Rt(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),f=Math.sin((1-t)*u)/l,p=Math.sin(t*u)/l;return this._w=a*f+this._w*p,this._x=n*f+this._x*p,this._y=i*f+this._y*p,this._z=s*f+this._z*p,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 W{constructor(e=0,t=0,n=0){this.isVector3=!0,W.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 W(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(ga.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(ga.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),f=2*(s*n-a*t);return this.x=t+c*l+a*f-o*u,this.y=n+c*u+o*l-s*f,this.z=i+c*f+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 ms.copy(this).projectOnVector(e),this.sub(ms)}reflect(e){return this.sub(ms.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(Rt(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 ms=new W,ga=new re,er=2e3,va=2001;class wt{constructor(e,t,n,i,s,a,o,c,l,u,f,p,m,_,T,g){this.isMatrix4=!0,wt.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,f,p,m,_,T,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,f,p,m,_,T,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]=f,v[14]=p,v[3]=m,v[7]=_,v[11]=T,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 wt().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/Cn.setFromMatrixColumn(e,0).length(),s=1/Cn.setFromMatrixColumn(e,1).length(),a=1/Cn.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),f=Math.sin(s);if(e.order==="XYZ"){const p=a*u,m=a*f,_=o*u,T=o*f;t[0]=c*u,t[4]=-c*f,t[8]=l,t[1]=m+_*l,t[5]=p-T*l,t[9]=-o*c,t[2]=T-p*l,t[6]=_+m*l,t[10]=a*c}else if(e.order==="YXZ"){const p=c*u,m=c*f,_=l*u,T=l*f;t[0]=p+T*o,t[4]=_*o-m,t[8]=a*l,t[1]=a*f,t[5]=a*u,t[9]=-o,t[2]=m*o-_,t[6]=T+p*o,t[10]=a*c}else if(e.order==="ZXY"){const p=c*u,m=c*f,_=l*u,T=l*f;t[0]=p-T*o,t[4]=-a*f,t[8]=_+m*o,t[1]=m+_*o,t[5]=a*u,t[9]=T-p*o,t[2]=-a*l,t[6]=o,t[10]=a*c}else if(e.order==="ZYX"){const p=a*u,m=a*f,_=o*u,T=o*f;t[0]=c*u,t[4]=_*l-m,t[8]=p*l+T,t[1]=c*f,t[5]=T*l+p,t[9]=m*l-_,t[2]=-l,t[6]=o*c,t[10]=a*c}else if(e.order==="YZX"){const p=a*c,m=a*l,_=o*c,T=o*l;t[0]=c*u,t[4]=T-p*f,t[8]=_*f+m,t[1]=f,t[5]=a*u,t[9]=-o*u,t[2]=-l*u,t[6]=m*f+_,t[10]=p-T*f}else if(e.order==="XZY"){const p=a*c,m=a*l,_=o*c,T=o*l;t[0]=c*u,t[4]=-f,t[8]=l*u,t[1]=p*f+T,t[5]=a*u,t[9]=m*f-_,t[2]=_*f-m,t[6]=o*u,t[10]=T*f+p}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(Iu,e,Bu)}lookAt(e,t,n){const i=this.elements;return it.subVectors(e,t),it.lengthSq()===0&&(it.z=1),it.normalize(),qt.crossVectors(n,it),qt.lengthSq()===0&&(Math.abs(n.z)===1?it.x+=1e-4:it.z+=1e-4,it.normalize(),qt.crossVectors(n,it)),qt.normalize(),tr.crossVectors(it,qt),i[0]=qt.x,i[4]=tr.x,i[8]=it.x,i[1]=qt.y,i[5]=tr.y,i[9]=it.y,i[2]=qt.z,i[6]=tr.z,i[10]=it.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],f=n[5],p=n[9],m=n[13],_=n[2],T=n[6],g=n[10],v=n[14],b=n[3],x=n[7],C=n[11],M=n[15],P=i[0],E=i[4],I=i[8],O=i[12],A=i[1],N=i[5],z=i[9],U=i[13],F=i[2],J=i[6],j=i[10],q=i[14],G=i[3],ne=i[7],ie=i[11],he=i[15];return s[0]=a*P+o*A+c*F+l*G,s[4]=a*E+o*N+c*J+l*ne,s[8]=a*I+o*z+c*j+l*ie,s[12]=a*O+o*U+c*q+l*he,s[1]=u*P+f*A+p*F+m*G,s[5]=u*E+f*N+p*J+m*ne,s[9]=u*I+f*z+p*j+m*ie,s[13]=u*O+f*U+p*q+m*he,s[2]=_*P+T*A+g*F+v*G,s[6]=_*E+T*N+g*J+v*ne,s[10]=_*I+T*z+g*j+v*ie,s[14]=_*O+T*U+g*q+v*he,s[3]=b*P+x*A+C*F+M*G,s[7]=b*E+x*N+C*J+M*ne,s[11]=b*I+x*z+C*j+M*ie,s[15]=b*O+x*U+C*q+M*he,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],f=e[6],p=e[10],m=e[14],_=e[3],T=e[7],g=e[11],v=e[15];return _*(+s*c*f-i*l*f-s*o*p+n*l*p+i*o*m-n*c*m)+T*(+t*c*m-t*l*p+s*a*p-i*a*m+i*l*u-s*c*u)+g*(+t*l*f-t*o*m-s*a*f+n*a*m+s*o*u-n*l*u)+v*(-i*o*u-t*c*f+t*o*p+i*a*f-n*a*p+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],f=e[9],p=e[10],m=e[11],_=e[12],T=e[13],g=e[14],v=e[15],b=f*g*l-T*p*l+T*c*m-o*g*m-f*c*v+o*p*v,x=_*p*l-u*g*l-_*c*m+a*g*m+u*c*v-a*p*v,C=u*T*l-_*f*l+_*o*m-a*T*m-u*o*v+a*f*v,M=_*f*c-u*T*c-_*o*p+a*T*p+u*o*g-a*f*g,P=t*b+n*x+i*C+s*M;if(P===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const E=1/P;return e[0]=b*E,e[1]=(T*p*s-f*g*s-T*i*m+n*g*m+f*i*v-n*p*v)*E,e[2]=(o*g*s-T*c*s+T*i*l-n*g*l-o*i*v+n*c*v)*E,e[3]=(f*c*s-o*p*s-f*i*l+n*p*l+o*i*m-n*c*m)*E,e[4]=x*E,e[5]=(u*g*s-_*p*s+_*i*m-t*g*m-u*i*v+t*p*v)*E,e[6]=(_*c*s-a*g*s-_*i*l+t*g*l+a*i*v-t*c*v)*E,e[7]=(a*p*s-u*c*s+u*i*l-t*p*l-a*i*m+t*c*m)*E,e[8]=C*E,e[9]=(_*f*s-u*T*s-_*n*m+t*T*m+u*n*v-t*f*v)*E,e[10]=(a*T*s-_*o*s+_*n*l-t*T*l-a*n*v+t*o*v)*E,e[11]=(u*o*s-a*f*s-u*n*l+t*f*l+a*n*m-t*o*m)*E,e[12]=M*E,e[13]=(u*T*i-_*f*i+_*n*p-t*T*p-u*n*g+t*f*g)*E,e[14]=(_*o*i-a*T*i-_*n*c+t*T*c+a*n*g-t*o*g)*E,e[15]=(a*f*i-u*o*i+u*n*c-t*f*c-a*n*p+t*o*p)*E,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,f=o+o,p=s*l,m=s*u,_=s*f,T=a*u,g=a*f,v=o*f,b=c*l,x=c*u,C=c*f,M=n.x,P=n.y,E=n.z;return i[0]=(1-(T+v))*M,i[1]=(m+C)*M,i[2]=(_-x)*M,i[3]=0,i[4]=(m-C)*P,i[5]=(1-(p+v))*P,i[6]=(g+b)*P,i[7]=0,i[8]=(_+x)*E,i[9]=(g-b)*E,i[10]=(1-(p+T))*E,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=Cn.set(i[0],i[1],i[2]).length();const a=Cn.set(i[4],i[5],i[6]).length(),o=Cn.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],Tt.copy(this);const l=1/s,u=1/a,f=1/o;return Tt.elements[0]*=l,Tt.elements[1]*=l,Tt.elements[2]*=l,Tt.elements[4]*=u,Tt.elements[5]*=u,Tt.elements[6]*=u,Tt.elements[8]*=f,Tt.elements[9]*=f,Tt.elements[10]*=f,t.setFromRotationMatrix(Tt),n.x=s,n.y=a,n.z=o,this}makePerspective(e,t,n,i,s,a,o=er){const c=this.elements,l=2*s/(t-e),u=2*s/(n-i),f=(t+e)/(t-e),p=(n+i)/(n-i);let m,_;if(o===er)m=-(a+s)/(a-s),_=-2*a*s/(a-s);else if(o===va)m=-a/(a-s),_=-a*s/(a-s);else throw new Error("Matrix4.makePerspective(): Invalid coordinate system: "+o);return c[0]=l,c[4]=0,c[8]=f,c[12]=0,c[1]=0,c[5]=u,c[9]=p,c[13]=0,c[2]=0,c[6]=0,c[10]=m,c[14]=_,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(e,t,n,i,s,a,o=er){const c=this.elements,l=1/(t-e),u=1/(n-i),f=1/(a-s),p=(t+e)*l,m=(n+i)*u;let _,T;if(o===er)_=(a+s)*f,T=-2*f;else if(o===va)_=s*f,T=-1*f;else throw new Error("../math.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return c[0]=2*l,c[4]=0,c[8]=0,c[12]=-p,c[1]=0,c[5]=2*u,c[9]=0,c[13]=-m,c[2]=0,c[6]=0,c[10]=T,c[14]=-_,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 Cn=new W,Tt=new wt,Iu=new W(0,0,0),Bu=new W(1,1,1),qt=new W,tr=new W,it=new W,Sa=new wt,xa=new re;class li{constructor(e=0,t=0,n=0,i=li.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 li(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],f=i[2],p=i[6],m=i[10];switch(t){case"XYZ":this._y=Math.asin(Rt(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-u,m),this._z=Math.atan2(-a,s)):(this._x=Math.atan2(p,l),this._z=0);break;case"YXZ":this._x=Math.asin(-Rt(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(o,m),this._z=Math.atan2(c,l)):(this._y=Math.atan2(-f,s),this._z=0);break;case"ZXY":this._x=Math.asin(Rt(p,-1,1)),Math.abs(p)<.9999999?(this._y=Math.atan2(-f,m),this._z=Math.atan2(-a,l)):(this._y=0,this._z=Math.atan2(c,s));break;case"ZYX":this._y=Math.asin(-Rt(f,-1,1)),Math.abs(f)<.9999999?(this._x=Math.atan2(p,m),this._z=Math.atan2(c,s)):(this._x=0,this._z=Math.atan2(-a,l));break;case"YZX":this._z=Math.asin(Rt(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-u,l),this._y=Math.atan2(-f,s)):(this._x=0,this._y=Math.atan2(o,m));break;case"XZY":this._z=Math.asin(-Rt(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(p,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 Sa.makeRotationFromQuaternion(e),this.setFromRotationMatrix(Sa,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return xa.setFromEuler(this),this.setFromQuaternion(xa,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}}li.DEFAULT_ORDER="XYZ";class Bn{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 Bn(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(Rt(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}}Bn.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 c=e.elements,l=c[0],u=c[4],f=c[8],p=c[1],m=c[5],_=c[9],T=c[2],g=c[6],v=c[10];if(Math.abs(u-p)<.01&&Math.abs(f-T)<.01&&Math.abs(_-g)<.01){if(Math.abs(u+p)<.1&&Math.abs(f+T)<.1&&Math.abs(_+g)<.1&&Math.abs(l+m+v-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const x=(l+1)/2,C=(m+1)/2,M=(v+1)/2,P=(u+p)/4,E=(f+T)/4,I=(_+g)/4;return x>C&&x>M?x<.01?(n=0,i=.707106781,s=.707106781):(n=Math.sqrt(x),i=P/n,s=E/n):C>M?C<.01?(n=.707106781,i=0,s=.707106781):(i=Math.sqrt(C),n=P/i,s=I/i):M<.01?(n=.707106781,i=.707106781,s=0):(s=Math.sqrt(M),n=E/s,i=I/s),this.set(n,i,s,t),this}let b=Math.sqrt((g-_)*(g-_)+(f-T)*(f-T)+(p-u)*(p-u));return Math.abs(b)<.001&&(b=1),this.x=(g-_)/b,this.y=(f-T)/b,this.z=(p-u)/b,this.w=Math.acos((l+m+v-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 Ot{constructor(e,t,n,i,s,a,o,c,l){Ot.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],f=n[7],p=n[2],m=n[5],_=n[8],T=i[0],g=i[3],v=i[6],b=i[1],x=i[4],C=i[7],M=i[2],P=i[5],E=i[8];return s[0]=a*T+o*b+c*M,s[3]=a*g+o*x+c*P,s[6]=a*v+o*C+c*E,s[1]=l*T+u*b+f*M,s[4]=l*g+u*x+f*P,s[7]=l*v+u*C+f*E,s[2]=p*T+m*b+_*M,s[5]=p*g+m*x+_*P,s[8]=p*v+m*C+_*E,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],f=u*a-o*l,p=o*c-u*s,m=l*s-a*c,_=t*f+n*p+i*m;if(_===0)return this.set(0,0,0,0,0,0,0,0,0);const T=1/_;return e[0]=f*T,e[1]=(i*l-u*n)*T,e[2]=(o*n-i*a)*T,e[3]=p*T,e[4]=(u*t-i*c)*T,e[5]=(i*s-o*t)*T,e[6]=m*T,e[7]=(n*c-l*t)*T,e[8]=(a*t-n*s)*T,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(ys.makeScale(e,t)),this}rotate(e){return this.premultiply(ys.makeRotation(-e)),this}translate(e,t){return this.premultiply(ys.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 Ot().fromArray(this.elements)}}const ys=new Ot;var qe;(function(r){r[r.Random=0]="Random",r[r.Loop=1]="Loop",r[r.PingPong=2]="PingPong",r[r.Burst=3]="Burst"})(qe||(qe={}));function Ji(r,e,t,n){let i;switch(qe.Random===r?e=Math.random():qe.Burst===r&&n.isBursting&&(e=n.burstParticleIndex/n.burstParticleCount),t>0?i=Math.floor(e/t)*t:i=e,r){case qe.Loop:i=i%1;break;case qe.PingPong:i=Math.abs(i%2-1);break}return i}class mn{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 mn(t[0],t[4],t[7],t[9]),right:new mn(t[9],t[8],t[6],t[3]),span:t}}clone(){return new mn(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 mn(e.p0,e.p1,e.p2,e.p3)}}const ui=r=>({r:r.x,g:r.y,b:r.z,a:r.w}),hi=r=>new tt(r.r,r.g,r.b,r.a),Nu=(r,e)=>{switch(e){case"Vector3":return new W(r.x,r.y,r.z);case"Vector4":return new tt(r.x,r.y,r.z,r.w);case"Color":return new W(r.r,r.g,r.b);case"Number":return r;default:return r}},Uu=(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 Ar{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:ui(this.a),b:ui(this.b)}}static fromJSON(e){return new Ar(hi(e.a),hi(e.b))}clone(){return new Ar(this.a.clone(),this.b.clone())}}class Nn{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:ui(this.a),b:ui(this.b)}}static fromJSON(e){return new Nn(hi(e.a),hi(e.b))}clone(){return new Nn(this.a.clone(),this.b.clone())}}class Qt{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:Uu(e,this.subType),pos:t}))}}static fromJSON(e){return new Qt(e.keys.map(t=>[Nu(t.value,e.subType),t.pos]),e.subType)}clone(){return this.subType==="Number"?new Qt(this.keys.map(([e,t])=>[e,t]),this.subType):new Qt(this.keys.map(([e,t])=>[e.clone(),t]),this.subType)}}const nr=new W;class yn{constructor(e=[[new W(0,0,0),0],[new W(1,1,1),0]],t=[[1,0],[1,1]]){this.type="function",this.color=new Qt(e,"Color"),this.alpha=new Qt(t,"Number")}genColor(e,t,n){return this.color.genValue(nr,n),t.set(nr.x,nr.y,nr.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=>[Nn.fromJSON(n.function).a,n.start]);return e.functions.length>0&&t.push([Nn.fromJSON(e.functions[e.functions.length-1].function).b,1]),new yn(t.map(n=>[new W(n[0].x,n[0].y,n[0].z),n[1]]),t.map(n=>[n[0].w,n[1]]))}else{const t=new yn;return t.alpha=Qt.fromJSON(e.alpha),t.color=Qt.fromJSON(e.color),t}}clone(){const e=new yn;return e.alpha=this.alpha.clone(),e.color=this.color.clone(),e}startGen(e){}}const gs=new tt;class Or{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,gs,n),e&&e[this.indexCount]!==void 0?t.lerp(gs,e[this.indexCount]):t.lerp(gs,Math.random()),t}toJSON(){return{type:"RandomColorBetweenGradient",gradient1:this.gradient1.toJSON(),gradient2:this.gradient2.toJSON()}}static fromJSON(e){return new Or(yn.fromJSON(e.gradient1),yn.fromJSON(e.gradient2))}clone(){return new Or(this.gradient1.clone(),this.gradient2.clone())}}class gn{constructor(e){this.color=e,this.type="value"}startGen(e){}genColor(e,t){return t.copy(this.color)}toJSON(){return{type:"ConstantColor",color:ui(this.color)}}static fromJSON(e){return new gn(hi(e.color))}clone(){return new gn(this.color.clone())}}function co(r){switch(r.type){case"ConstantColor":return gn.fromJSON(r);case"ColorRange":return Nn.fromJSON(r);case"RandomColor":return Ar.fromJSON(r);case"Gradient":return yn.fromJSON(r);case"RandomColorBetweenGradient":return Or.fromJSON(r);default:return new gn(new tt(1,1,1,1))}}class ee{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 ee(e.value)}clone(){return new ee(this.value)}}class vn{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),Fn.lerp(this.a,this.b,e[this.indexCount])}toJSON(){return{type:"IntervalValue",a:this.a,b:this.b}}static fromJSON(e){return new vn(e.a,e.b)}clone(){return new vn(this.a,this.b)}}class Du{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 fi extends Du{constructor(e=[[new mn(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 fi(e.functions.map(t=>[mn.fromJSON(t.function),t.start]))}clone(){return new fi(this.functions.map(([e,t])=>[e.clone(),t]))}startGen(e){}}function K(r){switch(r.type){case"ConstantValue":return ee.fromJSON(r);case"IntervalValue":return vn.fromJSON(r);case"PiecewiseBezier":return fi.fromJSON(r);default:return new ee(0)}}class di{constructor(){this.indexCount=0,this.type="rotation"}startGen(e){this.indexCount=e.length,e.push(new re);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 di}clone(){return new di}}class pi{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 pi(new W(e.axis.x,e.axis.y,e.axis.z),K(e.angle))}clone(){return new pi(this.axis.clone(),this.angle.clone())}}class zr{constructor(e,t,n,i){this.angleX=e,this.angleY=t,this.angleZ=n,this.type="rotation",this.eular=new li(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 zr(K(e.angleX),K(e.angleY),K(e.angleZ),e.eulerOrder)}clone(){return new zr(this.angleX,this.angleY,this.angleZ,this.eular.order)}}function Uc(r){switch(r.type){case"AxisAngle":return pi.fromJSON(r);case"Euler":return zr.fromJSON(r);case"RandomQuat":return di.fromJSON(r);default:return new di}}class Sn{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 Sn(K(e.x),K(e.y),K(e.z))}clone(){return new Sn(this.x,this.y,this.z)}}function Fu(r){switch(r.type){case"Vector3Function":return Sn.fromJSON(r);default:return new Sn(new ee(0),new ee(0),new ee(0))}}function Ir(r){switch(r.type){case"ConstantValue":case"IntervalValue":case"PiecewiseBezier":return K(r);case"AxisAngle":case"RandomQuat":case"Euler":return Uc(r);case"Vector3Function":return Fu(r);default:return new ee(0)}}class mi{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:qe.Random,this.spread=(o=e.spread)!==null&&o!==void 0?o:0,this.speed=(c=e.speed)!==null&&c!==void 0?c:new ee(1),this.memory=[]}update(e,t){qe.Random!=this.mode&&(this.currentValue+=this.speed.genValue(this.memory,e.emissionState.time/e.duration)*t)}initialize(e,t){const n=Ji(this.mode,this.currentValue,this.spread,t),i=Fn.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 mi({radius:e.radius,arc:e.arc,thickness:e.thickness,angle:e.angle,mode:e.mode,speed:e.speed?K(e.speed):void 0,spread:e.spread})}clone(){return new mi({radius:this.radius,arc:this.arc,thickness:this.thickness,angle:this.angle,mode:this.mode,speed:this.speed.clone(),spread:this.spread})}}class yi{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:qe.Random,this.spread=(a=e.spread)!==null&&a!==void 0?a:0,this.speed=(o=e.speed)!==null&&o!==void 0?o:new ee(1),this.memory=[]}update(e,t){this.currentValue+=this.speed.genValue(this.memory,e.emissionState.time/e.duration)*t}initialize(e,t){const n=Ji(this.mode,this.currentValue,this.spread,t),i=Fn.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 yi({radius:e.radius,arc:e.arc,thickness:e.thickness,mode:e.mode,speed:e.speed?K(e.speed):void 0,spread:e.spread})}clone(){return new yi({radius:this.radius,arc:this.arc,thickness:this.thickness,mode:this.mode,speed:this.speed.clone(),spread:this.spread})}}function ir(r,e){return Math.floor(Math.random()*(e-r))+r}const Vr=new W(0,1,0),Jr=new W(0,0,0),Lu=new W(1,1,1),_a=new W(0,0,1);class gi{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:qe.Random,this.spread=(o=e.spread)!==null&&o!==void 0?o:0,this.speed=(c=e.speed)!==null&&c!==void 0?c:new ee(1),this.memory=[],this._m1=new wt}update(e,t){qe.Random!=this.mode&&(this.currentValue+=this.speed.genValue(this.memory,e.emissionState.time/e.duration)*t)}initialize(e,t){const n=Ji(this.mode,this.currentValue,this.spread,t),i=Math.random(),s=Fn.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 re&&(this._m1.lookAt(Jr,e.velocity,Vr),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 gi({radius:e.radius,arc:e.arc,thickness:e.thickness,donutRadius:e.donutRadius,mode:e.mode,speed:e.speed?K(e.speed):void 0,spread:e.spread})}clone(){return new gi({radius:this.radius,arc:this.arc,thickness:this.thickness,donutRadius:this.donutRadius,mode:this.mode,speed:this.speed.clone(),spread:this.spread})}}class vi{constructor(){this.type="point",this._m1=new wt}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 re&&(this._m1.lookAt(Jr,e.position,Vr),e.rotation.setFromRotationMatrix(this._m1))}toJSON(){return{type:"point"}}static fromJSON(e){return new vi}clone(){return new vi}}class Un{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:qe.Random,this.spread=(a=e.spread)!==null&&a!==void 0?a:0,this.speed=(o=e.speed)!==null&&o!==void 0?o:new ee(1),this.memory=[],this._m1=new wt}update(e,t){qe.Random!=this.mode&&(this.currentValue+=this.speed.genValue(this.memory,e.emissionState.time/e.duration)*t)}initialize(e,t){const n=Ji(this.mode,this.currentValue,this.spread,t),i=Math.random(),s=Fn.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),f=Math.cos(o);e.position.x=u*l,e.position.y=u*c,e.position.z=f,e.velocity.copy(e.position).multiplyScalar(e.startSpeed),e.position.multiplyScalar(this.radius*s),e.rotation instanceof re&&(this._m1.lookAt(Jr,e.position,Vr),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 Un({radius:e.radius,arc:e.arc,thickness:e.thickness,mode:e.mode,speed:e.speed?K(e.speed):void 0,spread:e.spread})}clone(){return new Un({radius:this.radius,arc:this.arc,thickness:this.thickness,mode:this.mode,speed:this.speed.clone(),spread:this.spread})}}class Si{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:qe.Random,this.spread=(a=e.spread)!==null&&a!==void 0?a:0,this.speed=(o=e.speed)!==null&&o!==void 0?o:new ee(1),this.memory=[],this._m1=new wt}update(e,t){qe.Random!=this.mode&&(this.currentValue+=this.speed.genValue(this.memory,e.emissionState.time/e.duration)*t)}initialize(e,t){const n=Ji(this.mode,this.currentValue,this.spread,t),i=Math.random(),s=Fn.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),f=Math.cos(o);e.position.x=u*l,e.position.y=u*c,e.position.z=f,e.velocity.copy(e.position).multiplyScalar(e.startSpeed),e.position.multiplyScalar(this.radius*s),e.rotation instanceof re&&(this._m1.lookAt(Jr,e.position,Vr),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 Si({radius:e.radius,arc:e.arc,thickness:e.thickness,mode:e.mode,speed:e.speed?K(e.speed):void 0,spread:e.spread})}clone(){return new Si({radius:this.radius,arc:this.arc,thickness:this.thickness,mode:this.mode,speed:this.speed.clone(),spread:this.spread})}}class xi{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 xi(e)}clone(){return new xi({width:this.width,height:this.height,column:this.column,row:this.row})}update(e,t){}}const $s={circle:{type:"circle",params:[["radius",["number"]],["arc",["radian"]],["thickness",["number"]],["mode",["emitterMode"]],["spread",["number"]],["speed",["valueFunc"]]],constructor:yi,loadJSON:yi.fromJSON},cone:{type:"cone",params:[["radius",["number"]],["arc",["radian"]],["thickness",["number"]],["angle",["radian"]],["mode",["emitterMode"]],["spread",["number"]],["speed",["valueFunc"]]],constructor:mi,loadJSON:mi.fromJSON},donut:{type:"donut",params:[["radius",["number"]],["arc",["radian"]],["thickness",["number"]],["donutRadius",["number"]],["mode",["emitterMode"]],["spread",["number"]],["speed",["valueFunc"]]],constructor:gi,loadJSON:gi.fromJSON},point:{type:"point",params:[],constructor:vi,loadJSON:vi.fromJSON},sphere:{type:"sphere",params:[["radius",["number"]],["arc",["radian"]],["thickness",["number"]],["angle",["radian"]],["mode",["emitterMode"]],["spread",["number"]],["speed",["valueFunc"]]],constructor:Un,loadJSON:Un.fromJSON},hemisphere:{type:"hemisphere",params:[["radius",["number"]],["arc",["radian"]],["thickness",["number"]],["angle",["radian"]],["mode",["emitterMode"]],["spread",["number"]],["speed",["valueFunc"]]],constructor:Si,loadJSON:Si.fromJSON},grid:{type:"grid",params:[["width",["number"]],["height",["number"]],["rows",["number"]],["column",["number"]]],constructor:xi,loadJSON:xi.fromJSON}};function Vu(r,e){return $s[r.type].loadJSON(r,e)}class _i{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 _i(co(e.color))}clone(){return new _i(this.color.clone())}reset(){}}class bi{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 bi(K(e.angularVelocity))}frameUpdate(e){}clone(){return new bi(this.angularVelocity.clone())}reset(){}}class Ti{constructor(e){this.angularVelocity=e,this.type="Rotation3DOverLife",this.tempQuat=new re,this.tempQuat2=new re}initialize(e){e.rotation instanceof re&&(e.angularVelocity=new re,this.angularVelocity.startGen(e.memory))}update(e,t){e.rotation instanceof re&&(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 Ti(Uc(e.angularVelocity))}frameUpdate(e){}clone(){return new Ti(this.angularVelocity.clone())}reset(){}}class Mi{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 W,this._tempScale=new W,this._tempQ=new re}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 Mi(K(e.x),K(e.y),K(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 Mi(this.x.clone(),this.y.clone(),this.z.clone())}reset(){}}class Ci{initialize(e){this.size.startGen(e.memory)}constructor(e){this.size=e,this.type="SizeOverLife"}update(e){this.size instanceof Sn?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 Ci(Ir(e.size))}frameUpdate(e){}clone(){return new Ci(this.size.clone())}reset(){}}class wi{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 wi(K(e.speed))}frameUpdate(e){}clone(){return new wi(this.speed.clone())}reset(){}}class Pi{constructor(e){this.frame=e,this.type="FrameOverLife"}initialize(e){this.frame.startGen(e.memory)}update(e,t){this.frame instanceof fi&&(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 Pi(K(e.frame))}clone(){return new Pi(this.frame.clone())}reset(){}}class Ei{constructor(e,t=new W(0,1,0)){this.orbitSpeed=e,this.axis=t,this.type="OrbitOverLife",this.temp=new W,this.rotation=new re}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 Ei(K(e.orbitSpeed),e.axis?new W(e.axis[0],e.axis[1],e.axis[2]):void 0)}clone(){return new Ei(this.orbitSpeed.clone())}reset(){}}class vs{constructor(e){this.data=e,this.next=null,this.prev=null}hasPrev(){return this.prev!==null}hasNext(){return this.next!==null}}class Ju{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 vs(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 vs(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 vs(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 ju{constructor(){this.startSpeed=0,this.startColor=new tt,this.startSize=new W(1,1,1),this.position=new W,this.velocity=new W,this.age=0,this.life=1,this.size=new W(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 Gu{constructor(e,t,n){this.position=e,this.size=t,this.color=n}}class Br{constructor(){this.startSpeed=0,this.startColor=new tt,this.startSize=new W(1,1,1),this.position=new W,this.velocity=new W,this.age=0,this.life=1,this.size=new W(1,1,1),this.length=100,this.speedModifier=1,this.color=new tt,this.previous=new Ju,this.uvTile=0,this.memory=[]}update(){for(this.age<=this.life?this.previous.push(new Gu(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 ki{initialize(e){this.width.startGen(e.memory)}constructor(e){this.width=e,this.type="WidthOverLength"}update(e){if(e instanceof Br){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 ki(K(e.width))}clone(){return new ki(this.width.clone())}reset(){}}class Ri{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 Ri(new W(e.direction[0],e.direction[1],e.direction[2]),K((t=e.magnitude)!==null&&t!==void 0?t:e.force))}clone(){return new Ri(this.direction.clone(),this.magnitude.clone())}reset(){}}class Ai{constructor(e,t){this.center=e,this.magnitude=t,this.type="GravityForce",this.temp=new W}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 Ai(new W(e.center[0],e.center[1],e.center[2]),e.magnitude)}clone(){return new Ai(this.center.clone(),this.magnitude)}reset(){}}class Oi{constructor(e){this.angle=e,this.type="ChangeEmitDirection",this._temp=new W,this._q=new re,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 Oi(K(e.angle))}clone(){return new Oi(this.angle)}reset(){}}var zn;(function(r){r[r.Death=0]="Death",r[r.Birth=1]="Birth",r[r.Frame=2]="Frame"})(zn||(zn={}));class zi{constructor(e,t,n,i=zn.Frame,s=1){this.particleSystem=e,this.useVelocityAsBasis=t,this.subParticleSystem=n,this.mode=i,this.emitProbability=s,this.type="EmitSubParticleSystem",this.q_=new re,this.v_=new W,this.v2_=new W,this.subEmissions=new Array,this.subParticleSystem&&this.subParticleSystem.system&&(this.subParticleSystem.system.onlyUsedByOther=!0)}initialize(e){}update(e,t){this.mode===zn.Frame?this.emit(e,t):this.mode===zn.Birth&&e.age===0?this.emit(e,t):this.mode===zn.Death&&e.age+t>=e.life&&this.emit(e,t)}emit(e,t){if(!this.subParticleSystem||Math.random()>this.emitProbability)return;const n=new wt;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 zi(t,e.useVelocityAsBasis,e.subParticleSystem,e.mode,e.emitProbability)}clone(){return new zi(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(_a).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 re?n=t.rotation:(this.q_.setFromAxisAngle(_a,t.rotation),n=this.q_),e.compose(t.position,n,Lu);this.particleSystem.worldSpace||e.multiplyMatrices(this.particleSystem.emitter.matrixWorld,e)}}const $u=.5*(Math.sqrt(3)-1),Gn=(3-Math.sqrt(3))/6,Wu=1/3,Et=1/6,Hu=(Math.sqrt(5)-1)/4,Oe=(5-Math.sqrt(5))/20,Re=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]),Me=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 Dc{constructor(e=Math.random){const t=typeof e=="function"?e:Xu(e);this.p=qu(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)*$u,l=Math.floor(e+c),u=Math.floor(t+c),f=(l+u)*Gn,p=l-f,m=u-f,_=e-p,T=t-m;let g,v;_>T?(g=1,v=0):(g=0,v=1);const b=_-g+Gn,x=T-v+Gn,C=_-1+2*Gn,M=T-1+2*Gn,P=l&255,E=u&255;let I=.5-_*_-T*T;if(I>=0){const N=n[P+i[E]]*3;I*=I,s=I*I*(Re[N]*_+Re[N+1]*T)}let O=.5-b*b-x*x;if(O>=0){const N=n[P+g+i[E+v]]*3;O*=O,a=O*O*(Re[N]*b+Re[N+1]*x)}let A=.5-C*C-M*M;if(A>=0){const N=n[P+1+i[E+1]]*3;A*=A,o=A*A*(Re[N]*C+Re[N+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)*Wu,f=Math.floor(e+u),p=Math.floor(t+u),m=Math.floor(n+u),_=(f+p+m)*Et,T=f-_,g=p-_,v=m-_,b=e-T,x=t-g,C=n-v;let M,P,E,I,O,A;b>=x?x>=C?(M=1,P=0,E=0,I=1,O=1,A=0):b>=C?(M=1,P=0,E=0,I=1,O=0,A=1):(M=0,P=0,E=1,I=1,O=0,A=1):x<C?(M=0,P=0,E=1,I=0,O=1,A=1):b<C?(M=0,P=1,E=0,I=0,O=1,A=1):(M=0,P=1,E=0,I=1,O=1,A=0);const N=b-M+Et,z=x-P+Et,U=C-E+Et,F=b-I+2*Et,J=x-O+2*Et,j=C-A+2*Et,q=b-1+3*Et,G=x-1+3*Et,ne=C-1+3*Et,ie=f&255,he=p&255,se=m&255;let ge=.6-b*b-x*x-C*C;if(ge<0)a=0;else{const ae=i[ie+s[he+s[se]]]*3;ge*=ge,a=ge*ge*(Re[ae]*b+Re[ae+1]*x+Re[ae+2]*C)}let be=.6-N*N-z*z-U*U;if(be<0)o=0;else{const ae=i[ie+M+s[he+P+s[se+E]]]*3;be*=be,o=be*be*(Re[ae]*N+Re[ae+1]*z+Re[ae+2]*U)}let oe=.6-F*F-J*J-j*j;if(oe<0)c=0;else{const ae=i[ie+I+s[he+O+s[se+A]]]*3;oe*=oe,c=oe*oe*(Re[ae]*F+Re[ae+1]*J+Re[ae+2]*j)}let fe=.6-q*q-G*G-ne*ne;if(fe<0)l=0;else{const ae=i[ie+1+s[he+1+s[se+1]]]*3;fe*=fe,l=fe*fe*(Re[ae]*q+Re[ae+1]*G+Re[ae+2]*ne)}return 32*(a+o+c+l)}noise4D(e,t,n,i){const s=this.perm;let a,o,c,l,u;const f=(e+t+n+i)*Hu,p=Math.floor(e+f),m=Math.floor(t+f),_=Math.floor(n+f),T=Math.floor(i+f),g=(p+m+_+T)*Oe,v=p-g,b=m-g,x=_-g,C=T-g,M=e-v,P=t-b,E=n-x,I=i-C;let O=0,A=0,N=0,z=0;M>P?O++:A++,M>E?O++:N++,M>I?O++:z++,P>E?A++:N++,P>I?A++:z++,E>I?N++:z++;const U=O>=3?1:0,F=A>=3?1:0,J=N>=3?1:0,j=z>=3?1:0,q=O>=2?1:0,G=A>=2?1:0,ne=N>=2?1:0,ie=z>=2?1:0,he=O>=1?1:0,se=A>=1?1:0,ge=N>=1?1:0,be=z>=1?1:0,oe=M-U+Oe,fe=P-F+Oe,ae=E-J+Oe,je=I-j+Oe,Ue=M-q+2*Oe,De=P-G+2*Oe,Ge=E-ne+2*Oe,xe=I-ie+2*Oe,ye=M-he+3*Oe,ce=P-se+3*Oe,st=E-ge+3*Oe,Pe=I-be+3*Oe,de=M-1+4*Oe,Ye=P-1+4*Oe,yt=E-1+4*Oe,gt=I-1+4*Oe,Ze=p&255,vt=m&255,ot=_&255,at=T&255;let St=.6-M*M-P*P-E*E-I*I;if(St<0)a=0;else{const Q=s[Ze+s[vt+s[ot+s[at]]]]%32*4;St*=St,a=St*St*(Me[Q]*M+Me[Q+1]*P+Me[Q+2]*E+Me[Q+3]*I)}let Ee=.6-oe*oe-fe*fe-ae*ae-je*je;if(Ee<0)o=0;else{const Q=s[Ze+U+s[vt+F+s[ot+J+s[at+j]]]]%32*4;Ee*=Ee,o=Ee*Ee*(Me[Q]*oe+Me[Q+1]*fe+Me[Q+2]*ae+Me[Q+3]*je)}let $e=.6-Ue*Ue-De*De-Ge*Ge-xe*xe;if($e<0)c=0;else{const Q=s[Ze+q+s[vt+G+s[ot+ne+s[at+ie]]]]%32*4;$e*=$e,c=$e*$e*(Me[Q]*Ue+Me[Q+1]*De+Me[Q+2]*Ge+Me[Q+3]*xe)}let nt=.6-ye*ye-ce*ce-st*st-Pe*Pe;if(nt<0)l=0;else{const Q=s[Ze+he+s[vt+se+s[ot+ge+s[at+be]]]]%32*4;nt*=nt,l=nt*nt*(Me[Q]*ye+Me[Q+1]*ce+Me[Q+2]*st+Me[Q+3]*Pe)}let We=.6-de*de-Ye*Ye-yt*yt-gt*gt;if(We<0)u=0;else{const Q=s[Ze+1+s[vt+1+s[ot+1+s[at+1]]]]%32*4;We*=We,u=We*We*(Me[Q]*de+Me[Q+1]*Ye+Me[Q+2]*yt+Me[Q+3]*gt)}return 27*(a+o+c+l+u)}}function qu(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 Xu(r){let e=0,t=0,n=0,i=1;const s=Yu();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 Yu(){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 Ii{constructor(e,t,n,i){this.scale=e,this.octaves=t,this.velocityMultiplier=n,this.timeScale=i,this.type="TurbulenceField",this.generator=new Dc,this.timeOffset=new W,this.temp=new W,this.temp2=new W,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 Ii(new W(e.scale[0],e.scale[1],e.scale[2]),e.octaves,new W(e.velocityMultiplier[0],e.velocityMultiplier[1],e.velocityMultiplier[2]),new W(e.timeScale[0],e.timeScale[1],e.timeScale[2]))}clone(){return new Ii(this.scale.clone(),this.octaves,this.velocityMultiplier.clone(),this.timeScale.clone())}reset(){}}const kt=[],Ss=new W,xs=new re;class Bi{constructor(e,t,n=new ee(1),i=new ee(0)){if(this.frequency=e,this.power=t,this.positionAmount=n,this.rotationAmount=i,this.type="Noise",this.duration=0,kt.length===0)for(let s=0;s<100;s++)kt.push(new Dc)}initialize(e){e.lastPosNoise=new W,typeof e.rotation=="number"?e.lastRotNoise=0:e.lastRotNoise=new re,e.generatorIndex=[ir(0,100),ir(0,100),ir(0,100),ir(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),Ss.set(kt[e.generatorIndex[0]].noise2D(0,e.age*n)*i*s,kt[e.generatorIndex[1]].noise2D(0,e.age*n)*i*s,kt[e.generatorIndex[2]].noise2D(0,e.age*n)*i*s),e.position.add(Ss),e.lastPosNoise.copy(Ss)),a>0&&e.lastRotNoise!==void 0&&(typeof e.rotation=="number"?(e.rotation-=e.lastRotNoise,e.rotation+=kt[e.generatorIndex[3]].noise2D(0,e.age*n)*Math.PI*i*a):(e.lastRotNoise.invert(),e.rotation.multiply(e.lastRotNoise),xs.set(kt[e.generatorIndex[0]].noise2D(0,e.age*n)*i*a,kt[e.generatorIndex[1]].noise2D(0,e.age*n)*i*a,kt[e.generatorIndex[2]].noise2D(0,e.age*n)*i*a,kt[e.generatorIndex[3]].noise2D(0,e.age*n)*i*a).normalize(),e.rotation.multiply(xs),e.lastRotNoise.copy(xs)))}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 Bi(K(e.frequency),K(e.power),K(e.positionAmount),K(e.rotationAmount))}clone(){return new Bi(this.frequency.clone(),this.power.clone(),this.positionAmount.clone(),this.rotationAmount.clone())}reset(){}}class Ni{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 Ni(co(e.color),vn.fromJSON(e.speedRange))}clone(){return new Ni(this.color.clone(),this.speedRange.clone())}reset(){}}class Ui{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 Sn?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 Ui(Ir(e.size),vn.fromJSON(e.speedRange))}frameUpdate(e){}clone(){return new Ui(this.size.clone(),this.speedRange.clone())}reset(){}}class Di{constructor(e,t){this.angularVelocity=e,this.speedRange=t,this.type="RotationBySpeed",this.tempQuat=new re}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 Di(K(e.angularVelocity),vn.fromJSON(e.speedRange))}frameUpdate(e){}clone(){return new Di(this.angularVelocity.clone(),this.speedRange.clone())}reset(){}}class Fi{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 Fi(K(e.speed),e.dampen)}frameUpdate(e){}clone(){return new Fi(this.speed.clone(),this.dampen)}reset(){}}const Nr={ApplyForce:{type:"ApplyForce",constructor:Ri,params:[["direction",["vec3"]],["magnitude",["value"]]],loadJSON:Ri.fromJSON},Noise:{type:"Noise",constructor:Bi,params:[["frequency",["value"]],["power",["value"]],["positionAmount",["value"]],["rotationAmount",["value"]]],loadJSON:Bi.fromJSON},TurbulenceField:{type:"TurbulenceField",constructor:Ii,params:[["scale",["vec3"]],["octaves",["number"]],["velocityMultiplier",["vec3"]],["timeScale",["vec3"]]],loadJSON:Ii.fromJSON},GravityForce:{type:"GravityForce",constructor:Ai,params:[["center",["vec3"]],["magnitude",["number"]]],loadJSON:Ai.fromJSON},ColorOverLife:{type:"ColorOverLife",constructor:_i,params:[["color",["colorFunc"]]],loadJSON:_i.fromJSON},RotationOverLife:{type:"RotationOverLife",constructor:bi,params:[["angularVelocity",["value","valueFunc"]]],loadJSON:bi.fromJSON},Rotation3DOverLife:{type:"Rotation3DOverLife",constructor:Ti,params:[["angularVelocity",["rotationFunc"]]],loadJSON:Ti.fromJSON},SizeOverLife:{type:"SizeOverLife",constructor:Ci,params:[["size",["value","valueFunc","vec3Func"]]],loadJSON:Ci.fromJSON},ColorBySpeed:{type:"ColorBySpeed",constructor:Ni,params:[["color",["colorFunc"]],["speedRange",["range"]]],loadJSON:Ni.fromJSON},RotationBySpeed:{type:"RotationBySpeed",constructor:Di,params:[["angularVelocity",["value","valueFunc"]],["speedRange",["range"]]],loadJSON:Di.fromJSON},SizeBySpeed:{type:"SizeBySpeed",constructor:Ui,params:[["size",["value","valueFunc","vec3Func"]],["speedRange",["range"]]],loadJSON:Ui.fromJSON},SpeedOverLife:{type:"SpeedOverLife",constructor:wi,params:[["speed",["value","valueFunc"]]],loadJSON:wi.fromJSON},FrameOverLife:{type:"FrameOverLife",constructor:Pi,params:[["frame",["value","valueFunc"]]],loadJSON:Pi.fromJSON},ForceOverLife:{type:"ForceOverLife",constructor:Mi,params:[["x",["value","valueFunc"]],["y",["value","valueFunc"]],["z",["value","valueFunc"]]],loadJSON:Mi.fromJSON},OrbitOverLife:{type:"OrbitOverLife",constructor:Ei,params:[["orbitSpeed",["value","valueFunc"]],["axis",["vec3"]]],loadJSON:Ei.fromJSON},WidthOverLength:{type:"WidthOverLength",constructor:ki,params:[["width",["value","valueFunc"]]],loadJSON:ki.fromJSON},ChangeEmitDirection:{type:"ChangeEmitDirection",constructor:Oi,params:[["angle",["value"]]],loadJSON:Oi.fromJSON},EmitSubParticleSystem:{type:"EmitSubParticleSystem",constructor:zi,params:[["particleSystem",["self"]],["useVelocityAsBasis",["boolean"]],["subParticleSystem",["particleSystem"]],["mode",["number"]],["emitProbability",["number"]]],loadJSON:zi.fromJSON},LimitSpeedOverLife:{type:"LimitSpeedOverLife",constructor:Fi,params:[["speed",["value","valueFunc"]],["dampen",["number"]]],loadJSON:Fi.fromJSON}};function Zu(r,e){return Nr[r.type]?Nr[r.type].loadJSON(r,e):null}const Ku=[];function Qu(r){if(!Ku.find(t=>t.id===r.id)){for(const t of r.emitterShapes)$s[t.type]||($s[t.type]=t);for(const t of r.behaviors)Nr[t.type]||(Nr[t.type]=t)}}var eh=`
84
79
  #ifdef SOFT_PARTICLES
85
80
 
86
81
  /* #ifdef LOGDEPTH