@needle-tools/engine 4.8.6-next.7fdd4fa → 4.8.6-next.9f367ef
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{gltf-progressive-DXRy9EQz.js → gltf-progressive-BcHT3Nyo.js} +1 -1
- package/dist/{gltf-progressive-C-U_onhf.umd.cjs → gltf-progressive-CH3Q4H06.umd.cjs} +1 -1
- package/dist/{gltf-progressive-DViD_J_l.min.js → gltf-progressive-DR6HqF_h.min.js} +1 -1
- package/dist/{needle-engine.bundle-D6OHYyGz.min.js → needle-engine.bundle-BxavRmW9.min.js} +121 -121
- package/dist/{needle-engine.bundle-B1l8PaE0.umd.cjs → needle-engine.bundle-CTl1Bov3.umd.cjs} +113 -113
- package/dist/{needle-engine.bundle-C6TN-zhq.js → needle-engine.bundle-DhzKEPso.js} +3319 -3285
- package/dist/needle-engine.js +394 -393
- package/dist/needle-engine.min.js +1 -1
- package/dist/needle-engine.umd.cjs +1 -1
- package/dist/{postprocessing-61aXdqNz.umd.cjs → postprocessing-CVb_x9YY.umd.cjs} +1 -1
- package/dist/{postprocessing-D9jDHD0U.js → postprocessing-ORx-0eCx.js} +1 -1
- package/dist/{postprocessing-Be9Ds4NK.min.js → postprocessing-Ywv5oKkX.min.js} +1 -1
- package/dist/three-examples-BX_Sktc9.min.js +501 -0
- package/dist/{three-examples-BihZ_R96.js → three-examples-CNexix3E.js} +2436 -2781
- package/dist/{three-examples-Ce6Th3bv.umd.cjs → three-examples-DWxXVnws.umd.cjs} +21 -21
- package/dist/{vendor-BRpzuoJE.min.js → vendor-C43vobGc.min.js} +37 -37
- package/dist/{vendor-p_xp9KuJ.js → vendor-Z4SPrTcP.js} +2402 -2047
- package/dist/vendor-xfQ8tKF3.umd.cjs +1121 -0
- package/lib/engine/api.d.ts +1 -0
- package/lib/engine/api.js +1 -0
- package/lib/engine/api.js.map +1 -1
- package/lib/engine/engine_feature_flags.d.ts +3 -0
- package/lib/engine/engine_feature_flags.js +6 -0
- package/lib/engine/engine_feature_flags.js.map +1 -0
- package/lib/engine/engine_gameobject.js +0 -4
- package/lib/engine/engine_gameobject.js.map +1 -1
- package/lib/engine/engine_mainloop_utils.d.ts +2 -1
- package/lib/engine/engine_mainloop_utils.js +18 -6
- package/lib/engine/engine_mainloop_utils.js.map +1 -1
- package/lib/engine/extensions/extensions.js +2 -2
- package/lib/engine/extensions/extensions.js.map +1 -1
- package/lib/engine/js-extensions/Object3D.js +19 -0
- package/lib/engine/js-extensions/Object3D.js.map +1 -1
- package/lib/engine-components/Skybox.js +9 -3
- package/lib/engine-components/Skybox.js.map +1 -1
- package/package.json +2 -1
- package/src/engine/api.ts +2 -1
- package/src/engine/engine_feature_flags.ts +8 -0
- package/src/engine/engine_gameobject.ts +0 -4
- package/src/engine/engine_mainloop_utils.ts +24 -8
- package/src/engine/extensions/extensions.ts +2 -2
- package/src/engine/js-extensions/Object3D.ts +25 -2
- package/src/engine-components/Skybox.ts +8 -4
- package/dist/three-examples-DKY9Nfge.min.js +0 -501
- package/dist/vendor-Ja-vKV-a.umd.cjs +0 -1121
|
@@ -1,1121 +0,0 @@
|
|
|
1
|
-
"use strict";const M=require("./three-Dceyffus.umd.cjs"),st={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 uo(n){const t=await fetch(n);if(t.ok)return t.json();throw new Error(t.statusText)}async function ga(n){return await uo(`${n}/profilesList.json`)}async function va(n,t,e=null,i=!0){if(!n)throw new Error("No xrInputSource supplied");const r=await ga(t);let s;if(n.profiles.some(c=>{const l=r[c];return l&&(s={profileId:c,profilePath:`${t}/${l.path}`,deprecated:!!l.deprecated}),!!s}),!s){if(!e)throw new Error("No matching profile name found");const c=r[e];if(!c)throw new Error(`No matching profile name found and default profile "${e}" missing.`);s={profileId:e,profilePath:`${t}/${c.path}`,deprecated:!!c.deprecated}}const a=await uo(s.profilePath);let o;if(i){let c;if(n.handedness==="any"?c=a.layouts[Object.keys(a.layouts)[0]]:c=a.layouts[n.handedness],!c)throw new Error(`No matching handedness, ${n.handedness}, in profile ${s.profileId}`);c.assetPath&&(o=s.profilePath.replace("profile.json",c.assetPath))}return{profile:a,assetPath:o}}const _a={xAxis:0,yAxis:0,button:0,state:st.ComponentState.DEFAULT};function xa(n=0,t=0){let e=n,i=t;if(Math.sqrt(n*n+t*t)>1){const a=Math.atan2(t,n);e=Math.cos(a),i=Math.sin(a)}return{normalizedXAxis:e*.5+.5,normalizedYAxis:i*.5+.5}}class Sa{constructor(t){this.componentProperty=t.componentProperty,this.states=t.states,this.valueNodeName=t.valueNodeName,this.valueNodeProperty=t.valueNodeProperty,this.valueNodeProperty===st.VisualResponseProperty.TRANSFORM&&(this.minNodeName=t.minNodeName,this.maxNodeName=t.maxNodeName),this.value=0,this.updateFromComponent(_a)}updateFromComponent({xAxis:t,yAxis:e,button:i,state:r}){const{normalizedXAxis:s,normalizedYAxis:a}=xa(t,e);switch(this.componentProperty){case st.ComponentProperty.X_AXIS:this.value=this.states.includes(r)?s:.5;break;case st.ComponentProperty.Y_AXIS:this.value=this.states.includes(r)?a:.5;break;case st.ComponentProperty.BUTTON:this.value=this.states.includes(r)?i:0;break;case st.ComponentProperty.STATE:this.valueNodeProperty===st.VisualResponseProperty.VISIBILITY?this.value=this.states.includes(r):this.value=this.states.includes(r)?1:0;break;default:throw new Error(`Unexpected visualResponse componentProperty ${this.componentProperty}`)}}}class ba{constructor(t,e){if(!t||!e||!e.visualResponses||!e.gamepadIndices||Object.keys(e.gamepadIndices).length===0)throw new Error("Invalid arguments supplied");this.id=t,this.type=e.type,this.rootNodeName=e.rootNodeName,this.touchPointNodeName=e.touchPointNodeName,this.visualResponses={},Object.keys(e.visualResponses).forEach(i=>{const r=new Sa(e.visualResponses[i]);this.visualResponses[i]=r}),this.gamepadIndices=Object.assign({},e.gamepadIndices),this.values={state:st.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(t){if(this.values.state=st.ComponentState.DEFAULT,this.gamepadIndices.button!==void 0&&t.buttons.length>this.gamepadIndices.button){const e=t.buttons[this.gamepadIndices.button];this.values.button=e.value,this.values.button=this.values.button<0?0:this.values.button,this.values.button=this.values.button>1?1:this.values.button,e.pressed||this.values.button===1?this.values.state=st.ComponentState.PRESSED:(e.touched||this.values.button>st.ButtonTouchThreshold)&&(this.values.state=st.ComponentState.TOUCHED)}this.gamepadIndices.xAxis!==void 0&&t.axes.length>this.gamepadIndices.xAxis&&(this.values.xAxis=t.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===st.ComponentState.DEFAULT&&Math.abs(this.values.xAxis)>st.AxisTouchThreshold&&(this.values.state=st.ComponentState.TOUCHED)),this.gamepadIndices.yAxis!==void 0&&t.axes.length>this.gamepadIndices.yAxis&&(this.values.yAxis=t.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===st.ComponentState.DEFAULT&&Math.abs(this.values.yAxis)>st.AxisTouchThreshold&&(this.values.state=st.ComponentState.TOUCHED)),Object.values(this.visualResponses).forEach(e=>{e.updateFromComponent(this.values)})}}class Ta{constructor(t,e,i){if(!t)throw new Error("No xrInputSource supplied");if(!e)throw new Error("No profile supplied");this.xrInputSource=t,this.assetUrl=i,this.id=e.profileId,this.layoutDescription=e.layouts[t.handedness],this.components={},Object.keys(this.layoutDescription.components).forEach(r=>{const s=this.layoutDescription.components[r];this.components[r]=new ba(r,s)}),this.updateFromGamepad()}get gripSpace(){return this.xrInputSource.gripSpace}get targetRaySpace(){return this.xrInputSource.targetRaySpace}get data(){const t=[];return Object.values(this.components).forEach(e=>{t.push(e.data)}),t}updateFromGamepad(){Object.values(this.components).forEach(t=>{t.updateFromGamepad(this.xrInputSource.gamepad)})}}const Xr=2,qt=4,oe=4,ho=4,de=new Int32Array(2),os=new Float32Array(de.buffer),as=new Float64Array(de.buffer),tr=new Uint16Array(new Uint8Array([1,0]).buffer)[0]===1;class ce{constructor(t,e){this.low=t|0,this.high=e|0}static create(t,e){return t==0&&e==0?ce.ZERO:new ce(t,e)}toFloat64(){return(this.low>>>0)+this.high*4294967296}equals(t){return this.low==t.low&&this.high==t.high}}ce.ZERO=new ce(0,0);var Pn;(function(n){n[n.UTF8_BYTES=1]="UTF8_BYTES",n[n.UTF16_STRING=2]="UTF16_STRING"})(Pn||(Pn={}));class gi{constructor(t){this.bytes_=t,this.position_=0}static allocate(t){return new gi(new Uint8Array(t))}clear(){this.position_=0}bytes(){return this.bytes_}position(){return this.position_}setPosition(t){this.position_=t}capacity(){return this.bytes_.length}readInt8(t){return this.readUint8(t)<<24>>24}readUint8(t){return this.bytes_[t]}readInt16(t){return this.readUint16(t)<<16>>16}readUint16(t){return this.bytes_[t]|this.bytes_[t+1]<<8}readInt32(t){return this.bytes_[t]|this.bytes_[t+1]<<8|this.bytes_[t+2]<<16|this.bytes_[t+3]<<24}readUint32(t){return this.readInt32(t)>>>0}readInt64(t){return new ce(this.readInt32(t),this.readInt32(t+4))}readUint64(t){return new ce(this.readUint32(t),this.readUint32(t+4))}readFloat32(t){return de[0]=this.readInt32(t),os[0]}readFloat64(t){return de[tr?0:1]=this.readInt32(t),de[tr?1:0]=this.readInt32(t+4),as[0]}writeInt8(t,e){this.bytes_[t]=e}writeUint8(t,e){this.bytes_[t]=e}writeInt16(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8}writeUint16(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8}writeInt32(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8,this.bytes_[t+2]=e>>16,this.bytes_[t+3]=e>>24}writeUint32(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8,this.bytes_[t+2]=e>>16,this.bytes_[t+3]=e>>24}writeInt64(t,e){this.writeInt32(t,e.low),this.writeInt32(t+4,e.high)}writeUint64(t,e){this.writeUint32(t,e.low),this.writeUint32(t+4,e.high)}writeFloat32(t,e){os[0]=e,this.writeInt32(t,de[0])}writeFloat64(t,e){as[0]=e,this.writeInt32(t,de[tr?0:1]),this.writeInt32(t+4,de[tr?1:0])}getBufferIdentifier(){if(this.bytes_.length<this.position_+qt+oe)throw new Error("FlatBuffers: ByteBuffer is too short to contain an identifier.");let t="";for(let e=0;e<oe;e++)t+=String.fromCharCode(this.readInt8(this.position_+qt+e));return t}__offset(t,e){const i=t-this.readInt32(t);return e<this.readInt16(i)?this.readInt16(i+e):0}__union(t,e){return t.bb_pos=e+this.readInt32(e),t.bb=this,t}__string(t,e){t+=this.readInt32(t);const i=this.readInt32(t);let r="",s=0;if(t+=qt,e===Pn.UTF8_BYTES)return this.bytes_.subarray(t,t+i);for(;s<i;){let a;const o=this.readUint8(t+s++);if(o<192)a=o;else{const c=this.readUint8(t+s++);if(o<224)a=(o&31)<<6|c&63;else{const l=this.readUint8(t+s++);if(o<240)a=(o&15)<<12|(c&63)<<6|l&63;else{const u=this.readUint8(t+s++);a=(o&7)<<18|(c&63)<<12|(l&63)<<6|u&63}}}a<65536?r+=String.fromCharCode(a):(a-=65536,r+=String.fromCharCode((a>>10)+55296,(a&1023)+56320))}return r}__union_with_string(t,e){return typeof t=="string"?this.__string(e):this.__union(t,e)}__indirect(t){return t+this.readInt32(t)}__vector(t){return t+this.readInt32(t)+qt}__vector_len(t){return this.readInt32(t+this.readInt32(t))}__has_identifier(t){if(t.length!=oe)throw new Error("FlatBuffers: file identifier must be length "+oe);for(let e=0;e<oe;e++)if(t.charCodeAt(e)!=this.readInt8(this.position()+qt+e))return!1;return!0}createLong(t,e){return ce.create(t,e)}createScalarList(t,e){const i=[];for(let r=0;r<e;++r)t(r)!==null&&i.push(t(r));return i}createObjList(t,e){const i=[];for(let r=0;r<e;++r){const s=t(r);s!==null&&i.push(s.unpack())}return i}}class Wn{constructor(t){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 e;t?e=t:e=1024,this.bb=gi.allocate(e),this.space=e}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(t){this.force_defaults=t}dataBuffer(){return this.bb}asUint8Array(){return this.bb.bytes().subarray(this.bb.position(),this.bb.position()+this.offset())}prep(t,e){t>this.minalign&&(this.minalign=t);const i=~(this.bb.capacity()-this.space+e)+1&t-1;for(;this.space<i+t+e;){const r=this.bb.capacity();this.bb=Wn.growByteBuffer(this.bb),this.space+=this.bb.capacity()-r}this.pad(i)}pad(t){for(let e=0;e<t;e++)this.bb.writeInt8(--this.space,0)}writeInt8(t){this.bb.writeInt8(this.space-=1,t)}writeInt16(t){this.bb.writeInt16(this.space-=2,t)}writeInt32(t){this.bb.writeInt32(this.space-=4,t)}writeInt64(t){this.bb.writeInt64(this.space-=8,t)}writeFloat32(t){this.bb.writeFloat32(this.space-=4,t)}writeFloat64(t){this.bb.writeFloat64(this.space-=8,t)}addInt8(t){this.prep(1,0),this.writeInt8(t)}addInt16(t){this.prep(2,0),this.writeInt16(t)}addInt32(t){this.prep(4,0),this.writeInt32(t)}addInt64(t){this.prep(8,0),this.writeInt64(t)}addFloat32(t){this.prep(4,0),this.writeFloat32(t)}addFloat64(t){this.prep(8,0),this.writeFloat64(t)}addFieldInt8(t,e,i){(this.force_defaults||e!=i)&&(this.addInt8(e),this.slot(t))}addFieldInt16(t,e,i){(this.force_defaults||e!=i)&&(this.addInt16(e),this.slot(t))}addFieldInt32(t,e,i){(this.force_defaults||e!=i)&&(this.addInt32(e),this.slot(t))}addFieldInt64(t,e,i){(this.force_defaults||!e.equals(i))&&(this.addInt64(e),this.slot(t))}addFieldFloat32(t,e,i){(this.force_defaults||e!=i)&&(this.addFloat32(e),this.slot(t))}addFieldFloat64(t,e,i){(this.force_defaults||e!=i)&&(this.addFloat64(e),this.slot(t))}addFieldOffset(t,e,i){(this.force_defaults||e!=i)&&(this.addOffset(e),this.slot(t))}addFieldStruct(t,e,i){e!=i&&(this.nested(e),this.slot(t))}nested(t){if(t!=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(t){this.vtable!==null&&(this.vtable[t]=this.offset())}offset(){return this.bb.capacity()-this.space}static growByteBuffer(t){const e=t.capacity();if(e&3221225472)throw new Error("FlatBuffers: cannot grow buffer beyond 2 gigabytes.");const i=e<<1,r=gi.allocate(i);return r.setPosition(i-e),r.bytes().set(t.bytes(),i-e),r}addOffset(t){this.prep(qt,0),this.writeInt32(this.offset()-t+qt)}startObject(t){this.notNested(),this.vtable==null&&(this.vtable=[]),this.vtable_in_use=t;for(let e=0;e<t;e++)this.vtable[e]=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 t=this.offset();let e=this.vtable_in_use-1;for(;e>=0&&this.vtable[e]==0;e--);const i=e+1;for(;e>=0;e--)this.addInt16(this.vtable[e]!=0?t-this.vtable[e]:0);const r=2;this.addInt16(t-this.object_start);const s=(i+r)*Xr;this.addInt16(s);let a=0;const o=this.space;t:for(e=0;e<this.vtables.length;e++){const c=this.bb.capacity()-this.vtables[e];if(s==this.bb.readInt16(c)){for(let l=Xr;l<s;l+=Xr)if(this.bb.readInt16(o+l)!=this.bb.readInt16(c+l))continue t;a=this.vtables[e];break}}return a?(this.space=this.bb.capacity()-t,this.bb.writeInt32(this.space,a-t)):(this.vtables.push(this.offset()),this.bb.writeInt32(this.bb.capacity()-t,this.offset()-t)),this.isNested=!1,t}finish(t,e,i){const r=i?ho:0;if(e){const s=e;if(this.prep(this.minalign,qt+oe+r),s.length!=oe)throw new Error("FlatBuffers: file identifier must be length "+oe);for(let a=oe-1;a>=0;a--)this.writeInt8(s.charCodeAt(a))}this.prep(this.minalign,qt+r),this.addOffset(t),r&&this.addInt32(this.bb.capacity()-this.space),this.bb.setPosition(this.space)}finishSizePrefixed(t,e){this.finish(t,e,!0)}requiredField(t,e){const i=this.bb.capacity()-t,r=i-this.bb.readInt32(i);if(!(this.bb.readInt16(r+e)!=0))throw new Error("FlatBuffers: field "+e+" must be set")}startVector(t,e,i){this.notNested(),this.vector_num_elems=e,this.prep(qt,t*e),this.prep(i,t*e)}endVector(){return this.writeInt32(this.vector_num_elems),this.offset()}createSharedString(t){if(!t)return 0;if(this.string_maps||(this.string_maps=new Map),this.string_maps.has(t))return this.string_maps.get(t);const e=this.createString(t);return this.string_maps.set(t,e),e}createString(t){if(!t)return 0;let e;if(t instanceof Uint8Array)e=t;else{e=[];let i=0;for(;i<t.length;){let r;const s=t.charCodeAt(i++);if(s<55296||s>=56320)r=s;else{const a=t.charCodeAt(i++);r=(s<<10)+a+-56613888}r<128?e.push(r):(r<2048?e.push(r>>6&31|192):(r<65536?e.push(r>>12&15|224):e.push(r>>18&7|240,r>>12&63|128),e.push(r>>6&63|128)),e.push(r&63|128))}}this.addInt8(0),this.startVector(1,e.length,1),this.bb.setPosition(this.space-=e.length);for(let i=0,r=this.space,s=this.bb.bytes();i<e.length;i++)s[r++]=e[i];return this.endVector()}createLong(t,e){return ce.create(t,e)}createObjectOffset(t){return t===null?0:typeof t=="string"?this.createString(t):t.pack(this)}createObjectOffsetList(t){const e=[];for(let i=0;i<t.length;++i){const r=t[i];if(r!==null)e.push(this.createObjectOffset(r));else throw new Error("FlatBuffers: Argument for createObjectOffsetList cannot contain null.")}return e}createStructOffsetList(t,e){return e(this,t.length),this.createObjectOffsetList(t),this.endVector()}}function Vr(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var Wr={exports:{}},cs;function ls(){return cs||(cs=1,(function(n){var t={};t.useBlobBuilder=(function(){try{return new Blob([]),!1}catch{return!0}})(),t.useArrayBufferView=!t.useBlobBuilder&&(function(){try{return new Blob([new Uint8Array([])]).size===0}catch{return!0}})(),n.exports.binaryFeatures=t;var e=n.exports.BlobBuilder;typeof window<"u"&&(e=n.exports.BlobBuilder=window.WebKitBlobBuilder||window.MozBlobBuilder||window.MSBlobBuilder||window.BlobBuilder);function i(){this._pieces=[],this._parts=[]}i.prototype.append=function(r){typeof r=="number"?this._pieces.push(r):(this.flush(),this._parts.push(r))},i.prototype.flush=function(){if(this._pieces.length>0){var r=new Uint8Array(this._pieces);t.useArrayBufferView||(r=r.buffer),this._parts.push(r),this._pieces=[]}},i.prototype.getBuffer=function(){if(this.flush(),t.useBlobBuilder){for(var r=new e,s=0,a=this._parts.length;s<a;s++)r.append(this._parts[s]);return r.getBlob()}else return new Blob(this._parts)},n.exports.BufferBuilder=i})(Wr)),Wr.exports}var Hr,us;function Ma(){if(us)return Hr;us=1;var n=ls().BufferBuilder,t=ls().binaryFeatures,e={unpack:function(o){var c=new i(o);return c.unpack()},pack:function(o){var c=new r;c.pack(o);var l=c.getBuffer();return l}};Hr=e;function i(o){this.index=0,this.dataBuffer=o,this.dataView=new Uint8Array(this.dataBuffer),this.length=this.dataBuffer.byteLength}i.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)}},i.prototype.unpack_uint8=function(){var o=this.dataView[this.index]&255;return this.index++,o},i.prototype.unpack_uint16=function(){var o=this.read(2),c=(o[0]&255)*256+(o[1]&255);return this.index+=2,c},i.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},i.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},i.prototype.unpack_int8=function(){var o=this.unpack_uint8();return o<128?o:o-256},i.prototype.unpack_int16=function(){var o=this.unpack_uint16();return o<32768?o:o-65536},i.prototype.unpack_int32=function(){var o=this.unpack_uint32();return o<Math.pow(2,31)?o:o-Math.pow(2,32)},i.prototype.unpack_int64=function(){var o=this.unpack_uint64();return o<Math.pow(2,63)?o:o-Math.pow(2,64)},i.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},i.prototype.unpack_string=function(o){for(var c=this.read(o),l=0,u="",h,f;l<o;)h=c[l],h<128?(u+=String.fromCharCode(h),l++):(h^192)<32?(f=(h^192)<<6|c[l+1]&63,u+=String.fromCharCode(f),l+=2):(f=(h&15)<<12|(c[l+1]&63)<<6|c[l+2]&63,u+=String.fromCharCode(f),l+=3);return this.index+=o,u},i.prototype.unpack_array=function(o){for(var c=new Array(o),l=0;l<o;l++)c[l]=this.unpack();return c},i.prototype.unpack_map=function(o){for(var c={},l=0;l<o;l++){var u=this.unpack(),h=this.unpack();c[u]=h}return c},i.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)},i.prototype.unpack_double=function(){var o=this.unpack_uint32(),c=this.unpack_uint32(),l=o>>31,u=(o>>20&2047)-1023,h=o&1048575|1048576,f=h*Math.pow(2,u-20)+c*Math.pow(2,u-52);return(l===0?1:-1)*f},i.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 r(){this.bufferBuilder=new n}r.prototype.getBuffer=function(){return this.bufferBuilder.getBuffer()},r.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)t.useArrayBufferView?this.pack_bin(new Uint8Array(o)):this.pack_bin(o);else if("BYTES_PER_ELEMENT"in o)t.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()},r.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)},r.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)},r.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])},r.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")},r.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,h=Math.floor(u*Math.pow(2,52)),f=Math.pow(2,32),d=c<<31|l+1023<<20|h/f&1048575,y=h%f;this.bufferBuilder.append(203),this.pack_int32(d),this.pack_int32(y)},r.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]))},r.prototype.pack_uint8=function(o){this.bufferBuilder.append(o)},r.prototype.pack_uint16=function(o){this.bufferBuilder.append(o>>8),this.bufferBuilder.append(o&255)},r.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)},r.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)},r.prototype.pack_int8=function(o){this.bufferBuilder.append(o&255)},r.prototype.pack_int16=function(o){this.bufferBuilder.append((o&65280)>>8),this.bufferBuilder.append(o&255)},r.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)},r.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 Hr}var Ca=Ma();const hs=Vr(Ca);let fo=!0,po=!0;function li(n,t,e){const i=n.match(t);return i&&i.length>=e&&parseInt(i[e],10)}function $e(n,t,e){if(!n.RTCPeerConnection)return;const i=n.RTCPeerConnection.prototype,r=i.addEventListener;i.addEventListener=function(a,o){if(a!==t)return r.apply(this,arguments);const c=l=>{const u=e(l);u&&(o.handleEvent?o.handleEvent(u):o(u))};return this._eventMap=this._eventMap||{},this._eventMap[t]||(this._eventMap[t]=new Map),this._eventMap[t].set(o,c),r.apply(this,[a,c])};const s=i.removeEventListener;i.removeEventListener=function(a,o){if(a!==t||!this._eventMap||!this._eventMap[t])return s.apply(this,arguments);if(!this._eventMap[t].has(o))return s.apply(this,arguments);const c=this._eventMap[t].get(o);return this._eventMap[t].delete(o),this._eventMap[t].size===0&&delete this._eventMap[t],Object.keys(this._eventMap).length===0&&delete this._eventMap,s.apply(this,[a,c])},Object.defineProperty(i,"on"+t,{get(){return this["_on"+t]},set(a){this["_on"+t]&&(this.removeEventListener(t,this["_on"+t]),delete this["_on"+t]),a&&this.addEventListener(t,this["_on"+t]=a)},enumerable:!0,configurable:!0})}function Pa(n){return typeof n!="boolean"?new Error("Argument type: "+typeof n+". Please use a boolean."):(fo=n,n?"adapter.js logging disabled":"adapter.js logging enabled")}function wa(n){return typeof n!="boolean"?new Error("Argument type: "+typeof n+". Please use a boolean."):(po=!n,"adapter.js deprecation warnings "+(n?"disabled":"enabled"))}function Hn(){if(typeof window=="object"){if(fo)return;typeof console<"u"&&typeof console.log=="function"&&console.log.apply(console,arguments)}}function Jr(n,t){po&&console.warn(n+" is deprecated, please use "+t+" instead.")}function Ea(n){const t={browser:null,version:null};if(typeof n>"u"||!n.navigator)return t.browser="Not a browser.",t;const{navigator:e}=n;if(e.mozGetUserMedia)t.browser="firefox",t.version=li(e.userAgent,/Firefox\/(\d+)\./,1);else if(e.webkitGetUserMedia||n.isSecureContext===!1&&n.webkitRTCPeerConnection&&!n.RTCIceGatherer)t.browser="chrome",t.version=li(e.userAgent,/Chrom(e|ium)\/(\d+)\./,2);else if(e.mediaDevices&&e.userAgent.match(/Edge\/(\d+).(\d+)$/))t.browser="edge",t.version=li(e.userAgent,/Edge\/(\d+).(\d+)$/,2);else if(n.RTCPeerConnection&&e.userAgent.match(/AppleWebKit\/(\d+)\./))t.browser="safari",t.version=li(e.userAgent,/AppleWebKit\/(\d+)\./,1),t.supportsUnifiedPlan=n.RTCRtpTransceiver&&"currentDirection"in n.RTCRtpTransceiver.prototype;else return t.browser="Not a supported browser.",t;return t}function fs(n){return Object.prototype.toString.call(n)==="[object Object]"}function mo(n){return fs(n)?Object.keys(n).reduce(function(t,e){const i=fs(n[e]),r=i?mo(n[e]):n[e],s=i&&!Object.keys(r).length;return r===void 0||s?t:Object.assign(t,{[e]:r})},{}):n}function wn(n,t,e){!t||e.has(t.id)||(e.set(t.id,t),Object.keys(t).forEach(i=>{i.endsWith("Id")?wn(n,n.get(t[i]),e):i.endsWith("Ids")&&t[i].forEach(r=>{wn(n,n.get(r),e)})}))}function ds(n,t,e){const i=e?"outbound-rtp":"inbound-rtp",r=new Map;if(t===null)return r;const s=[];return n.forEach(a=>{a.type==="track"&&a.trackIdentifier===t.id&&s.push(a)}),s.forEach(a=>{n.forEach(o=>{o.type===i&&o.trackId===a.id&&wn(n,o,r)})}),r}const ps=Hn;function yo(n,t){const e=n&&n.navigator;if(!e.mediaDevices)return;const i=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 h=function(f,d){return f?f+d.charAt(0).toUpperCase()+d.slice(1):d==="deviceId"?"sourceId":d};if(u.ideal!==void 0){c.optional=c.optional||[];let f={};typeof u.ideal=="number"?(f[h("min",l)]=u.ideal,c.optional.push(f),f={},f[h("max",l)]=u.ideal,c.optional.push(f)):(f[h("",l)]=u.ideal,c.optional.push(f))}u.exact!==void 0&&typeof u.exact!="number"?(c.mandatory=c.mandatory||{},c.mandatory[h("",l)]=u.exact):["min","max"].forEach(f=>{u[f]!==void 0&&(c.mandatory=c.mandatory||{},c.mandatory[h(f,l)]=u[f])})}),o.advanced&&(c.optional=(c.optional||[]).concat(o.advanced)),c},r=function(o,c){if(t.version>=61)return c(o);if(o=JSON.parse(JSON.stringify(o)),o&&typeof o.audio=="object"){const l=function(u,h,f){h in u&&!(f in u)&&(u[f]=u[h],delete u[h])};o=JSON.parse(JSON.stringify(o)),l(o.audio,"autoGainControl","googAutoGainControl"),l(o.audio,"noiseSuppression","googNoiseSuppression"),o.audio=i(o.audio)}if(o&&typeof o.video=="object"){let l=o.video.facingMode;l=l&&(typeof l=="object"?l:{ideal:l});const u=t.version<66;if(l&&(l.exact==="user"||l.exact==="environment"||l.ideal==="user"||l.ideal==="environment")&&!(e.mediaDevices.getSupportedConstraints&&e.mediaDevices.getSupportedConstraints().facingMode&&!u)){delete o.video.facingMode;let h;if(l.exact==="environment"||l.ideal==="environment"?h=["back","rear"]:(l.exact==="user"||l.ideal==="user")&&(h=["front"]),h)return e.mediaDevices.enumerateDevices().then(f=>{f=f.filter(y=>y.kind==="videoinput");let d=f.find(y=>h.some(_=>y.label.toLowerCase().includes(_)));return!d&&f.length&&h.includes("back")&&(d=f[f.length-1]),d&&(o.video.deviceId=l.exact?{exact:d.deviceId}:{ideal:d.deviceId}),o.video=i(o.video),ps("chrome: "+JSON.stringify(o)),c(o)})}o.video=i(o.video)}return ps("chrome: "+JSON.stringify(o)),c(o)},s=function(o){return t.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){r(o,u=>{e.webkitGetUserMedia(u,c,h=>{l&&l(s(h))})})};if(e.getUserMedia=a.bind(e),e.mediaDevices.getUserMedia){const o=e.mediaDevices.getUserMedia.bind(e.mediaDevices);Object.getOwnPropertyDescriptor(e.mediaDevices,"getUserMedia")?.writable&&(e.mediaDevices.getUserMedia=function(c){return r(c,l=>o(l).then(u=>{if(l.audio&&!u.getAudioTracks().length||l.video&&!u.getVideoTracks().length)throw u.getTracks().forEach(h=>{h.stop()}),new DOMException("","NotFoundError");return u},u=>Promise.reject(s(u))))})}}function Ra(n,t){if(!(n.navigator.mediaDevices&&"getDisplayMedia"in n.navigator.mediaDevices)&&n.navigator.mediaDevices){if(typeof t!="function"){console.error("shimGetDisplayMedia: getSourceId argument is not a function");return}n.navigator.mediaDevices.getDisplayMedia=function(i){return t(i).then(r=>{const s=i.video&&i.video.width,a=i.video&&i.video.height,o=i.video&&i.video.frameRate;return i.video={mandatory:{chromeMediaSource:"desktop",chromeMediaSourceId:r,maxFrameRate:o||3}},s&&(i.video.mandatory.maxWidth=s),a&&(i.video.mandatory.maxHeight=a),n.navigator.mediaDevices.getUserMedia(i)})}}}function go(n){n.MediaStream=n.MediaStream||n.webkitMediaStream}function vo(n){if(typeof n=="object"&&n.RTCPeerConnection&&!("ontrack"in n.RTCPeerConnection.prototype)){Object.defineProperty(n.RTCPeerConnection.prototype,"ontrack",{get(){return this._ontrack},set(e){this._ontrack&&this.removeEventListener("track",this._ontrack),this.addEventListener("track",this._ontrack=e)},enumerable:!0,configurable:!0});const t=n.RTCPeerConnection.prototype.setRemoteDescription;n.RTCPeerConnection.prototype.setRemoteDescription=function(){return this._ontrackpoly||(this._ontrackpoly=i=>{i.stream.addEventListener("addtrack",r=>{let s;n.RTCPeerConnection.prototype.getReceivers?s=this.getReceivers().find(o=>o.track&&o.track.id===r.track.id):s={track:r.track};const a=new Event("track");a.track=r.track,a.receiver=s,a.transceiver={receiver:s},a.streams=[i.stream],this.dispatchEvent(a)}),i.stream.getTracks().forEach(r=>{let s;n.RTCPeerConnection.prototype.getReceivers?s=this.getReceivers().find(o=>o.track&&o.track.id===r.id):s={track:r};const a=new Event("track");a.track=r,a.receiver=s,a.transceiver={receiver:s},a.streams=[i.stream],this.dispatchEvent(a)})},this.addEventListener("addstream",this._ontrackpoly)),t.apply(this,arguments)}}else $e(n,"track",t=>(t.transceiver||Object.defineProperty(t,"transceiver",{value:{receiver:t.receiver}}),t))}function _o(n){if(typeof n=="object"&&n.RTCPeerConnection&&!("getSenders"in n.RTCPeerConnection.prototype)&&"createDTMFSender"in n.RTCPeerConnection.prototype){const t=function(r,s){return{track:s,get dtmf(){return this._dtmf===void 0&&(s.kind==="audio"?this._dtmf=r.createDTMFSender(s):this._dtmf=null),this._dtmf},_pc:r}};if(!n.RTCPeerConnection.prototype.getSenders){n.RTCPeerConnection.prototype.getSenders=function(){return this._senders=this._senders||[],this._senders.slice()};const r=n.RTCPeerConnection.prototype.addTrack;n.RTCPeerConnection.prototype.addTrack=function(o,c){let l=r.apply(this,arguments);return l||(l=t(this,o),this._senders.push(l)),l};const s=n.RTCPeerConnection.prototype.removeTrack;n.RTCPeerConnection.prototype.removeTrack=function(o){s.apply(this,arguments);const c=this._senders.indexOf(o);c!==-1&&this._senders.splice(c,1)}}const e=n.RTCPeerConnection.prototype.addStream;n.RTCPeerConnection.prototype.addStream=function(s){this._senders=this._senders||[],e.apply(this,[s]),s.getTracks().forEach(a=>{this._senders.push(t(this,a))})};const i=n.RTCPeerConnection.prototype.removeStream;n.RTCPeerConnection.prototype.removeStream=function(s){this._senders=this._senders||[],i.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 n=="object"&&n.RTCPeerConnection&&"getSenders"in n.RTCPeerConnection.prototype&&"createDTMFSender"in n.RTCPeerConnection.prototype&&n.RTCRtpSender&&!("dtmf"in n.RTCRtpSender.prototype)){const t=n.RTCPeerConnection.prototype.getSenders;n.RTCPeerConnection.prototype.getSenders=function(){const i=t.apply(this,[]);return i.forEach(r=>r._pc=this),i},Object.defineProperty(n.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 xo(n){if(!n.RTCPeerConnection)return;const t=n.RTCPeerConnection.prototype.getStats;n.RTCPeerConnection.prototype.getStats=function(){const[i,r,s]=arguments;if(arguments.length>0&&typeof i=="function")return t.apply(this,arguments);if(t.length===0&&(arguments.length===0||typeof i!="function"))return t.apply(this,[]);const a=function(c){const l={};return c.result().forEach(h=>{const f={id:h.id,timestamp:h.timestamp,type:{localcandidate:"local-candidate",remotecandidate:"remote-candidate"}[h.type]||h.type};h.names().forEach(d=>{f[d]=h.stat(d)}),l[f.id]=f}),l},o=function(c){return new Map(Object.keys(c).map(l=>[l,c[l]]))};if(arguments.length>=2){const c=function(l){r(o(a(l)))};return t.apply(this,[c,i])}return new Promise((c,l)=>{t.apply(this,[function(u){c(o(a(u)))},l])}).then(r,s)}}function So(n){if(!(typeof n=="object"&&n.RTCPeerConnection&&n.RTCRtpSender&&n.RTCRtpReceiver))return;if(!("getStats"in n.RTCRtpSender.prototype)){const e=n.RTCPeerConnection.prototype.getSenders;e&&(n.RTCPeerConnection.prototype.getSenders=function(){const s=e.apply(this,[]);return s.forEach(a=>a._pc=this),s});const i=n.RTCPeerConnection.prototype.addTrack;i&&(n.RTCPeerConnection.prototype.addTrack=function(){const s=i.apply(this,arguments);return s._pc=this,s}),n.RTCRtpSender.prototype.getStats=function(){const s=this;return this._pc.getStats().then(a=>ds(a,s.track,!0))}}if(!("getStats"in n.RTCRtpReceiver.prototype)){const e=n.RTCPeerConnection.prototype.getReceivers;e&&(n.RTCPeerConnection.prototype.getReceivers=function(){const r=e.apply(this,[]);return r.forEach(s=>s._pc=this),r}),$e(n,"track",i=>(i.receiver._pc=i.srcElement,i)),n.RTCRtpReceiver.prototype.getStats=function(){const r=this;return this._pc.getStats().then(s=>ds(s,r.track,!1))}}if(!("getStats"in n.RTCRtpSender.prototype&&"getStats"in n.RTCRtpReceiver.prototype))return;const t=n.RTCPeerConnection.prototype.getStats;n.RTCPeerConnection.prototype.getStats=function(){if(arguments.length>0&&arguments[0]instanceof n.MediaStreamTrack){const i=arguments[0];let r,s,a;return this.getSenders().forEach(o=>{o.track===i&&(r?a=!0:r=o)}),this.getReceivers().forEach(o=>(o.track===i&&(s?a=!0:s=o),o.track===i)),a||r&&s?Promise.reject(new DOMException("There are more than one sender or receiver for the track.","InvalidAccessError")):r?r.getStats():s?s.getStats():Promise.reject(new DOMException("There is no sender or receiver for the track.","InvalidAccessError"))}return t.apply(this,arguments)}}function bo(n){n.RTCPeerConnection.prototype.getLocalStreams=function(){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},Object.keys(this._shimmedLocalStreams).map(a=>this._shimmedLocalStreams[a][0])};const t=n.RTCPeerConnection.prototype.addTrack;n.RTCPeerConnection.prototype.addTrack=function(a,o){if(!o)return t.apply(this,arguments);this._shimmedLocalStreams=this._shimmedLocalStreams||{};const c=t.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 e=n.RTCPeerConnection.prototype.addStream;n.RTCPeerConnection.prototype.addStream=function(a){this._shimmedLocalStreams=this._shimmedLocalStreams||{},a.getTracks().forEach(l=>{if(this.getSenders().find(h=>h.track===l))throw new DOMException("Track already exists.","InvalidAccessError")});const o=this.getSenders();e.apply(this,arguments);const c=this.getSenders().filter(l=>o.indexOf(l)===-1);this._shimmedLocalStreams[a.id]=[a].concat(c)};const i=n.RTCPeerConnection.prototype.removeStream;n.RTCPeerConnection.prototype.removeStream=function(a){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},delete this._shimmedLocalStreams[a.id],i.apply(this,arguments)};const r=n.RTCPeerConnection.prototype.removeTrack;n.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]}),r.apply(this,arguments)}}function To(n,t){if(!n.RTCPeerConnection)return;if(n.RTCPeerConnection.prototype.addTrack&&t.version>=65)return bo(n);const e=n.RTCPeerConnection.prototype.getLocalStreams;n.RTCPeerConnection.prototype.getLocalStreams=function(){const u=e.apply(this);return this._reverseStreams=this._reverseStreams||{},u.map(h=>this._reverseStreams[h.id])};const i=n.RTCPeerConnection.prototype.addStream;n.RTCPeerConnection.prototype.addStream=function(u){if(this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},u.getTracks().forEach(h=>{if(this.getSenders().find(d=>d.track===h))throw new DOMException("Track already exists.","InvalidAccessError")}),!this._reverseStreams[u.id]){const h=new n.MediaStream(u.getTracks());this._streams[u.id]=h,this._reverseStreams[h.id]=u,u=h}i.apply(this,[u])};const r=n.RTCPeerConnection.prototype.removeStream;n.RTCPeerConnection.prototype.removeStream=function(u){this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},r.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]},n.RTCPeerConnection.prototype.addTrack=function(u,h){if(this.signalingState==="closed")throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");const f=[].slice.call(arguments,1);if(f.length!==1||!f[0].getTracks().find(_=>_===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(_=>_.track===u))throw new DOMException("Track already exists.","InvalidAccessError");this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{};const y=this._streams[h.id];if(y)y.addTrack(u),Promise.resolve().then(()=>{this.dispatchEvent(new Event("negotiationneeded"))});else{const _=new n.MediaStream([u]);this._streams[h.id]=_,this._reverseStreams[_.id]=h,this.addStream(_)}return this.getSenders().find(_=>_.track===u)};function s(l,u){let h=u.sdp;return Object.keys(l._reverseStreams||[]).forEach(f=>{const d=l._reverseStreams[f],y=l._streams[d.id];h=h.replace(new RegExp(y.id,"g"),d.id)}),new RTCSessionDescription({type:u.type,sdp:h})}function a(l,u){let h=u.sdp;return Object.keys(l._reverseStreams||[]).forEach(f=>{const d=l._reverseStreams[f],y=l._streams[d.id];h=h.replace(new RegExp(d.id,"g"),y.id)}),new RTCSessionDescription({type:u.type,sdp:h})}["createOffer","createAnswer"].forEach(function(l){const u=n.RTCPeerConnection.prototype[l],h={[l](){const f=arguments;return arguments.length&&typeof arguments[0]=="function"?u.apply(this,[y=>{const _=s(this,y);f[0].apply(null,[_])},y=>{f[1]&&f[1].apply(null,y)},arguments[2]]):u.apply(this,arguments).then(y=>s(this,y))}};n.RTCPeerConnection.prototype[l]=h[l]});const o=n.RTCPeerConnection.prototype.setLocalDescription;n.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(n.RTCPeerConnection.prototype,"localDescription");Object.defineProperty(n.RTCPeerConnection.prototype,"localDescription",{get(){const l=c.get.apply(this);return l.type===""?l:s(this,l)}}),n.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 f;Object.keys(this._streams).forEach(d=>{this._streams[d].getTracks().find(_=>u.track===_)&&(f=this._streams[d])}),f&&(f.getTracks().length===1?this.removeStream(this._reverseStreams[f.id]):f.removeTrack(u.track),this.dispatchEvent(new Event("negotiationneeded")))}}function En(n,t){!n.RTCPeerConnection&&n.webkitRTCPeerConnection&&(n.RTCPeerConnection=n.webkitRTCPeerConnection),n.RTCPeerConnection&&t.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach(function(e){const i=n.RTCPeerConnection.prototype[e],r={[e](){return arguments[0]=new(e==="addIceCandidate"?n.RTCIceCandidate:n.RTCSessionDescription)(arguments[0]),i.apply(this,arguments)}};n.RTCPeerConnection.prototype[e]=r[e]})}function Mo(n,t){$e(n,"negotiationneeded",e=>{const i=e.target;if(!((t.version<72||i.getConfiguration&&i.getConfiguration().sdpSemantics==="plan-b")&&i.signalingState!=="stable"))return e})}const ms=Object.freeze(Object.defineProperty({__proto__:null,fixNegotiationNeeded:Mo,shimAddTrackRemoveTrack:To,shimAddTrackRemoveTrackWithNative:bo,shimGetDisplayMedia:Ra,shimGetSendersWithDtmf:_o,shimGetStats:xo,shimGetUserMedia:yo,shimMediaStream:go,shimOnTrack:vo,shimPeerConnection:En,shimSenderReceiverGetStats:So},Symbol.toStringTag,{value:"Module"}));function Aa(n,t){let e=!1;return n=JSON.parse(JSON.stringify(n)),n.filter(i=>{if(i&&(i.urls||i.url)){let r=i.urls||i.url;i.url&&!i.urls&&Jr("RTCIceServer.url","RTCIceServer.urls");const s=typeof r=="string";return s&&(r=[r]),r=r.filter(a=>{if(a.indexOf("stun:")===0)return!1;const o=a.startsWith("turn")&&!a.startsWith("turn:[")&&a.includes("transport=udp");return o&&!e?(e=!0,!0):o&&!e}),delete i.url,i.urls=s?r[0]:r,!!r.length}})}var Yr={exports:{}},ys;function Co(){return ys||(ys=1,(function(n){var t={};t.generateIdentifier=function(){return Math.random().toString(36).substr(2,10)},t.localCName=t.generateIdentifier(),t.splitLines=function(e){return e.trim().split(`
|
|
2
|
-
`).map(function(i){return i.trim()})},t.splitSections=function(e){var i=e.split(`
|
|
3
|
-
m=`);return i.map(function(r,s){return(s>0?"m="+r:r).trim()+`\r
|
|
4
|
-
`})},t.getDescription=function(e){var i=t.splitSections(e);return i&&i[0]},t.getMediaSections=function(e){var i=t.splitSections(e);return i.shift(),i},t.matchPrefix=function(e,i){return t.splitLines(e).filter(function(r){return r.indexOf(i)===0})},t.parseCandidate=function(e){var i;e.indexOf("a=candidate:")===0?i=e.substring(12).split(" "):i=e.substring(10).split(" ");for(var r={foundation:i[0],component:parseInt(i[1],10),protocol:i[2].toLowerCase(),priority:parseInt(i[3],10),ip:i[4],address:i[4],port:parseInt(i[5],10),type:i[7]},s=8;s<i.length;s+=2)switch(i[s]){case"raddr":r.relatedAddress=i[s+1];break;case"rport":r.relatedPort=parseInt(i[s+1],10);break;case"tcptype":r.tcpType=i[s+1];break;case"ufrag":r.ufrag=i[s+1],r.usernameFragment=i[s+1];break;default:r[i[s]]=i[s+1];break}return r},t.writeCandidate=function(e){var i=[];i.push(e.foundation),i.push(e.component),i.push(e.protocol.toUpperCase()),i.push(e.priority),i.push(e.address||e.ip),i.push(e.port);var r=e.type;return i.push("typ"),i.push(r),r!=="host"&&e.relatedAddress&&e.relatedPort&&(i.push("raddr"),i.push(e.relatedAddress),i.push("rport"),i.push(e.relatedPort)),e.tcpType&&e.protocol.toLowerCase()==="tcp"&&(i.push("tcptype"),i.push(e.tcpType)),(e.usernameFragment||e.ufrag)&&(i.push("ufrag"),i.push(e.usernameFragment||e.ufrag)),"candidate:"+i.join(" ")},t.parseIceOptions=function(e){return e.substr(14).split(" ")},t.parseRtpMap=function(e){var i=e.substr(9).split(" "),r={payloadType:parseInt(i.shift(),10)};return i=i[0].split("/"),r.name=i[0],r.clockRate=parseInt(i[1],10),r.channels=i.length===3?parseInt(i[2],10):1,r.numChannels=r.channels,r},t.writeRtpMap=function(e){var i=e.payloadType;e.preferredPayloadType!==void 0&&(i=e.preferredPayloadType);var r=e.channels||e.numChannels||1;return"a=rtpmap:"+i+" "+e.name+"/"+e.clockRate+(r!==1?"/"+r:"")+`\r
|
|
5
|
-
`},t.parseExtmap=function(e){var i=e.substr(9).split(" ");return{id:parseInt(i[0],10),direction:i[0].indexOf("/")>0?i[0].split("/")[1]:"sendrecv",uri:i[1]}},t.writeExtmap=function(e){return"a=extmap:"+(e.id||e.preferredId)+(e.direction&&e.direction!=="sendrecv"?"/"+e.direction:"")+" "+e.uri+`\r
|
|
6
|
-
`},t.parseFmtp=function(e){for(var i={},r,s=e.substr(e.indexOf(" ")+1).split(";"),a=0;a<s.length;a++)r=s[a].trim().split("="),i[r[0].trim()]=r[1];return i},t.writeFmtp=function(e){var i="",r=e.payloadType;if(e.preferredPayloadType!==void 0&&(r=e.preferredPayloadType),e.parameters&&Object.keys(e.parameters).length){var s=[];Object.keys(e.parameters).forEach(function(a){e.parameters[a]?s.push(a+"="+e.parameters[a]):s.push(a)}),i+="a=fmtp:"+r+" "+s.join(";")+`\r
|
|
7
|
-
`}return i},t.parseRtcpFb=function(e){var i=e.substr(e.indexOf(" ")+1).split(" ");return{type:i.shift(),parameter:i.join(" ")}},t.writeRtcpFb=function(e){var i="",r=e.payloadType;return e.preferredPayloadType!==void 0&&(r=e.preferredPayloadType),e.rtcpFeedback&&e.rtcpFeedback.length&&e.rtcpFeedback.forEach(function(s){i+="a=rtcp-fb:"+r+" "+s.type+(s.parameter&&s.parameter.length?" "+s.parameter:"")+`\r
|
|
8
|
-
`}),i},t.parseSsrcMedia=function(e){var i=e.indexOf(" "),r={ssrc:parseInt(e.substr(7,i-7),10)},s=e.indexOf(":",i);return s>-1?(r.attribute=e.substr(i+1,s-i-1),r.value=e.substr(s+1)):r.attribute=e.substr(i+1),r},t.parseSsrcGroup=function(e){var i=e.substr(13).split(" ");return{semantics:i.shift(),ssrcs:i.map(function(r){return parseInt(r,10)})}},t.getMid=function(e){var i=t.matchPrefix(e,"a=mid:")[0];if(i)return i.substr(6)},t.parseFingerprint=function(e){var i=e.substr(14).split(" ");return{algorithm:i[0].toLowerCase(),value:i[1]}},t.getDtlsParameters=function(e,i){var r=t.matchPrefix(e+i,"a=fingerprint:");return{role:"auto",fingerprints:r.map(t.parseFingerprint)}},t.writeDtlsParameters=function(e,i){var r="a=setup:"+i+`\r
|
|
9
|
-
`;return e.fingerprints.forEach(function(s){r+="a=fingerprint:"+s.algorithm+" "+s.value+`\r
|
|
10
|
-
`}),r},t.parseCryptoLine=function(e){var i=e.substr(9).split(" ");return{tag:parseInt(i[0],10),cryptoSuite:i[1],keyParams:i[2],sessionParams:i.slice(3)}},t.writeCryptoLine=function(e){return"a=crypto:"+e.tag+" "+e.cryptoSuite+" "+(typeof e.keyParams=="object"?t.writeCryptoKeyParams(e.keyParams):e.keyParams)+(e.sessionParams?" "+e.sessionParams.join(" "):"")+`\r
|
|
11
|
-
`},t.parseCryptoKeyParams=function(e){if(e.indexOf("inline:")!==0)return null;var i=e.substr(7).split("|");return{keyMethod:"inline",keySalt:i[0],lifeTime:i[1],mkiValue:i[2]?i[2].split(":")[0]:void 0,mkiLength:i[2]?i[2].split(":")[1]:void 0}},t.writeCryptoKeyParams=function(e){return e.keyMethod+":"+e.keySalt+(e.lifeTime?"|"+e.lifeTime:"")+(e.mkiValue&&e.mkiLength?"|"+e.mkiValue+":"+e.mkiLength:"")},t.getCryptoParameters=function(e,i){var r=t.matchPrefix(e+i,"a=crypto:");return r.map(t.parseCryptoLine)},t.getIceParameters=function(e,i){var r=t.matchPrefix(e+i,"a=ice-ufrag:")[0],s=t.matchPrefix(e+i,"a=ice-pwd:")[0];return r&&s?{usernameFragment:r.substr(12),password:s.substr(10)}:null},t.writeIceParameters=function(e){return"a=ice-ufrag:"+e.usernameFragment+`\r
|
|
12
|
-
a=ice-pwd:`+e.password+`\r
|
|
13
|
-
`},t.parseRtpParameters=function(e){for(var i={codecs:[],headerExtensions:[],fecMechanisms:[],rtcp:[]},r=t.splitLines(e),s=r[0].split(" "),a=3;a<s.length;a++){var o=s[a],c=t.matchPrefix(e,"a=rtpmap:"+o+" ")[0];if(c){var l=t.parseRtpMap(c),u=t.matchPrefix(e,"a=fmtp:"+o+" ");switch(l.parameters=u.length?t.parseFmtp(u[0]):{},l.rtcpFeedback=t.matchPrefix(e,"a=rtcp-fb:"+o+" ").map(t.parseRtcpFb),i.codecs.push(l),l.name.toUpperCase()){case"RED":case"ULPFEC":i.fecMechanisms.push(l.name.toUpperCase());break}}}return t.matchPrefix(e,"a=extmap:").forEach(function(h){i.headerExtensions.push(t.parseExtmap(h))}),i},t.writeRtpDescription=function(e,i){var r="";r+="m="+e+" ",r+=i.codecs.length>0?"9":"0",r+=" UDP/TLS/RTP/SAVPF ",r+=i.codecs.map(function(a){return a.preferredPayloadType!==void 0?a.preferredPayloadType:a.payloadType}).join(" ")+`\r
|
|
14
|
-
`,r+=`c=IN IP4 0.0.0.0\r
|
|
15
|
-
`,r+=`a=rtcp:9 IN IP4 0.0.0.0\r
|
|
16
|
-
`,i.codecs.forEach(function(a){r+=t.writeRtpMap(a),r+=t.writeFmtp(a),r+=t.writeRtcpFb(a)});var s=0;return i.codecs.forEach(function(a){a.maxptime>s&&(s=a.maxptime)}),s>0&&(r+="a=maxptime:"+s+`\r
|
|
17
|
-
`),r+=`a=rtcp-mux\r
|
|
18
|
-
`,i.headerExtensions&&i.headerExtensions.forEach(function(a){r+=t.writeExtmap(a)}),r},t.parseRtpEncodingParameters=function(e){var i=[],r=t.parseRtpParameters(e),s=r.fecMechanisms.indexOf("RED")!==-1,a=r.fecMechanisms.indexOf("ULPFEC")!==-1,o=t.matchPrefix(e,"a=ssrc:").map(function(f){return t.parseSsrcMedia(f)}).filter(function(f){return f.attribute==="cname"}),c=o.length>0&&o[0].ssrc,l,u=t.matchPrefix(e,"a=ssrc-group:FID").map(function(f){var d=f.substr(17).split(" ");return d.map(function(y){return parseInt(y,10)})});u.length>0&&u[0].length>1&&u[0][0]===c&&(l=u[0][1]),r.codecs.forEach(function(f){if(f.name.toUpperCase()==="RTX"&&f.parameters.apt){var d={ssrc:c,codecPayloadType:parseInt(f.parameters.apt,10)};c&&l&&(d.rtx={ssrc:l}),i.push(d),s&&(d=JSON.parse(JSON.stringify(d)),d.fec={ssrc:c,mechanism:a?"red+ulpfec":"red"},i.push(d))}}),i.length===0&&c&&i.push({ssrc:c});var h=t.matchPrefix(e,"b=");return h.length&&(h[0].indexOf("b=TIAS:")===0?h=parseInt(h[0].substr(7),10):h[0].indexOf("b=AS:")===0?h=parseInt(h[0].substr(5),10)*1e3*.95-2e3*8:h=void 0,i.forEach(function(f){f.maxBitrate=h})),i},t.parseRtcpParameters=function(e){var i={},r=t.matchPrefix(e,"a=ssrc:").map(function(o){return t.parseSsrcMedia(o)}).filter(function(o){return o.attribute==="cname"})[0];r&&(i.cname=r.value,i.ssrc=r.ssrc);var s=t.matchPrefix(e,"a=rtcp-rsize");i.reducedSize=s.length>0,i.compound=s.length===0;var a=t.matchPrefix(e,"a=rtcp-mux");return i.mux=a.length>0,i},t.parseMsid=function(e){var i,r=t.matchPrefix(e,"a=msid:");if(r.length===1)return i=r[0].substr(7).split(" "),{stream:i[0],track:i[1]};var s=t.matchPrefix(e,"a=ssrc:").map(function(a){return t.parseSsrcMedia(a)}).filter(function(a){return a.attribute==="msid"});if(s.length>0)return i=s[0].value.split(" "),{stream:i[0],track:i[1]}},t.parseSctpDescription=function(e){var i=t.parseMLine(e),r=t.matchPrefix(e,"a=max-message-size:"),s;r.length>0&&(s=parseInt(r[0].substr(19),10)),isNaN(s)&&(s=65536);var a=t.matchPrefix(e,"a=sctp-port:");if(a.length>0)return{port:parseInt(a[0].substr(12),10),protocol:i.fmt,maxMessageSize:s};var o=t.matchPrefix(e,"a=sctpmap:");if(o.length>0){var c=t.matchPrefix(e,"a=sctpmap:")[0].substr(10).split(" ");return{port:parseInt(c[0],10),protocol:c[1],maxMessageSize:s}}},t.writeSctpDescription=function(e,i){var r=[];return e.protocol!=="DTLS/SCTP"?r=["m="+e.kind+" 9 "+e.protocol+" "+i.protocol+`\r
|
|
19
|
-
`,`c=IN IP4 0.0.0.0\r
|
|
20
|
-
`,"a=sctp-port:"+i.port+`\r
|
|
21
|
-
`]:r=["m="+e.kind+" 9 "+e.protocol+" "+i.port+`\r
|
|
22
|
-
`,`c=IN IP4 0.0.0.0\r
|
|
23
|
-
`,"a=sctpmap:"+i.port+" "+i.protocol+` 65535\r
|
|
24
|
-
`],i.maxMessageSize!==void 0&&r.push("a=max-message-size:"+i.maxMessageSize+`\r
|
|
25
|
-
`),r.join("")},t.generateSessionId=function(){return Math.random().toString().substr(2,21)},t.writeSessionBoilerplate=function(e,i,r){var s,a=i!==void 0?i:2;e?s=e:s=t.generateSessionId();var o=r||"thisisadapterortc";return`v=0\r
|
|
26
|
-
o=`+o+" "+s+" "+a+` IN IP4 127.0.0.1\r
|
|
27
|
-
s=-\r
|
|
28
|
-
t=0 0\r
|
|
29
|
-
`},t.writeMediaSection=function(e,i,r,s){var a=t.writeRtpDescription(e.kind,i);if(a+=t.writeIceParameters(e.iceGatherer.getLocalParameters()),a+=t.writeDtlsParameters(e.dtlsTransport.getLocalParameters(),r==="offer"?"actpass":"active"),a+="a=mid:"+e.mid+`\r
|
|
30
|
-
`,e.direction?a+="a="+e.direction+`\r
|
|
31
|
-
`:e.rtpSender&&e.rtpReceiver?a+=`a=sendrecv\r
|
|
32
|
-
`:e.rtpSender?a+=`a=sendonly\r
|
|
33
|
-
`:e.rtpReceiver?a+=`a=recvonly\r
|
|
34
|
-
`:a+=`a=inactive\r
|
|
35
|
-
`,e.rtpSender){var o="msid:"+s.id+" "+e.rtpSender.track.id+`\r
|
|
36
|
-
`;a+="a="+o,a+="a=ssrc:"+e.sendEncodingParameters[0].ssrc+" "+o,e.sendEncodingParameters[0].rtx&&(a+="a=ssrc:"+e.sendEncodingParameters[0].rtx.ssrc+" "+o,a+="a=ssrc-group:FID "+e.sendEncodingParameters[0].ssrc+" "+e.sendEncodingParameters[0].rtx.ssrc+`\r
|
|
37
|
-
`)}return a+="a=ssrc:"+e.sendEncodingParameters[0].ssrc+" cname:"+t.localCName+`\r
|
|
38
|
-
`,e.rtpSender&&e.sendEncodingParameters[0].rtx&&(a+="a=ssrc:"+e.sendEncodingParameters[0].rtx.ssrc+" cname:"+t.localCName+`\r
|
|
39
|
-
`),a},t.getDirection=function(e,i){for(var r=t.splitLines(e),s=0;s<r.length;s++)switch(r[s]){case"a=sendrecv":case"a=sendonly":case"a=recvonly":case"a=inactive":return r[s].substr(2)}return i?t.getDirection(i):"sendrecv"},t.getKind=function(e){var i=t.splitLines(e),r=i[0].split(" ");return r[0].substr(2)},t.isRejected=function(e){return e.split(" ",2)[1]==="0"},t.parseMLine=function(e){var i=t.splitLines(e),r=i[0].substr(2).split(" ");return{kind:r[0],port:parseInt(r[1],10),protocol:r[2],fmt:r.slice(3).join(" ")}},t.parseOLine=function(e){var i=t.matchPrefix(e,"o=")[0],r=i.substr(2).split(" ");return{username:r[0],sessionId:r[1],sessionVersion:parseInt(r[2],10),netType:r[3],addressType:r[4],address:r[5]}},t.isValidSDP=function(e){if(typeof e!="string"||e.length===0)return!1;for(var i=t.splitLines(e),r=0;r<i.length;r++)if(i[r].length<2||i[r].charAt(1)!=="=")return!1;return!0},n.exports=t})(Yr)),Yr.exports}var Zr,gs;function ka(){if(gs)return Zr;gs=1;var n=Co();function t(c){return{inboundrtp:"inbound-rtp",outboundrtp:"outbound-rtp",candidatepair:"candidate-pair",localcandidate:"local-candidate",remotecandidate:"remote-candidate"}[c.type]||c.type}function e(c,l,u,h,f){var d=n.writeRtpDescription(c.kind,l);if(d+=n.writeIceParameters(c.iceGatherer.getLocalParameters()),d+=n.writeDtlsParameters(c.dtlsTransport.getLocalParameters(),u==="offer"?"actpass":f||"active"),d+="a=mid:"+c.mid+`\r
|
|
40
|
-
`,c.rtpSender&&c.rtpReceiver?d+=`a=sendrecv\r
|
|
41
|
-
`:c.rtpSender?d+=`a=sendonly\r
|
|
42
|
-
`:c.rtpReceiver?d+=`a=recvonly\r
|
|
43
|
-
`:d+=`a=inactive\r
|
|
44
|
-
`,c.rtpSender){var y=c.rtpSender._initialTrackId||c.rtpSender.track.id;c.rtpSender._initialTrackId=y;var _="msid:"+(h?h.id:"-")+" "+y+`\r
|
|
45
|
-
`;d+="a="+_,d+="a=ssrc:"+c.sendEncodingParameters[0].ssrc+" "+_,c.sendEncodingParameters[0].rtx&&(d+="a=ssrc:"+c.sendEncodingParameters[0].rtx.ssrc+" "+_,d+="a=ssrc-group:FID "+c.sendEncodingParameters[0].ssrc+" "+c.sendEncodingParameters[0].rtx.ssrc+`\r
|
|
46
|
-
`)}return d+="a=ssrc:"+c.sendEncodingParameters[0].ssrc+" cname:"+n.localCName+`\r
|
|
47
|
-
`,c.rtpSender&&c.sendEncodingParameters[0].rtx&&(d+="a=ssrc:"+c.sendEncodingParameters[0].rtx.ssrc+" cname:"+n.localCName+`\r
|
|
48
|
-
`),d}function i(c,l){var u=!1;return c=JSON.parse(JSON.stringify(c)),c.filter(function(h){if(h&&(h.urls||h.url)){var f=h.urls||h.url;h.url&&!h.urls&&console.warn("RTCIceServer.url is deprecated! Use urls instead.");var d=typeof f=="string";return d&&(f=[f]),f=f.filter(function(y){var _=y.indexOf("turn:")===0&&y.indexOf("transport=udp")!==-1&&y.indexOf("turn:[")===-1&&!u;return _?(u=!0,!0):y.indexOf("stun:")===0&&l>=14393&&y.indexOf("?transport=udp")===-1}),delete h.url,h.urls=d?f[0]:f,!!f.length}})}function r(c,l){var u={codecs:[],headerExtensions:[],fecMechanisms:[]},h=function(d,y){d=parseInt(d,10);for(var _=0;_<y.length;_++)if(y[_].payloadType===d||y[_].preferredPayloadType===d)return y[_]},f=function(d,y,_,p){var m=h(d.parameters.apt,_),g=h(y.parameters.apt,p);return m&&g&&m.name.toLowerCase()===g.name.toLowerCase()};return c.codecs.forEach(function(d){for(var y=0;y<l.codecs.length;y++){var _=l.codecs[y];if(d.name.toLowerCase()===_.name.toLowerCase()&&d.clockRate===_.clockRate){if(d.name.toLowerCase()==="rtx"&&d.parameters&&_.parameters.apt&&!f(d,_,c.codecs,l.codecs))continue;_=JSON.parse(JSON.stringify(_)),_.numChannels=Math.min(d.numChannels,_.numChannels),u.codecs.push(_),_.rtcpFeedback=_.rtcpFeedback.filter(function(p){for(var m=0;m<d.rtcpFeedback.length;m++)if(d.rtcpFeedback[m].type===p.type&&d.rtcpFeedback[m].parameter===p.parameter)return!0;return!1});break}}}),c.headerExtensions.forEach(function(d){for(var y=0;y<l.headerExtensions.length;y++){var _=l.headerExtensions[y];if(d.uri===_.uri){u.headerExtensions.push(_);break}}}),u}function s(c,l,u){return{offer:{setLocalDescription:["stable","have-local-offer"],setRemoteDescription:["stable","have-remote-offer"]},answer:{setLocalDescription:["have-remote-offer","have-local-pranswer"],setRemoteDescription:["have-local-offer","have-remote-pranswer"]}}[l][c].indexOf(u)!==-1}function a(c,l){var u=c.getRemoteCandidates().find(function(h){return l.foundation===h.foundation&&l.ip===h.ip&&l.port===h.port&&l.priority===h.priority&&l.protocol===h.protocol&&l.type===h.type});return u||c.addRemoteCandidate(l),!u}function o(c,l){var u=new Error(l);return u.name=c,u.code={NotSupportedError:9,InvalidStateError:11,InvalidAccessError:15,TypeError:void 0,OperationError:void 0}[c],u}return Zr=function(c,l){function u(p,m){m.addTrack(p),m.dispatchEvent(new c.MediaStreamTrackEvent("addtrack",{track:p}))}function h(p,m){m.removeTrack(p),m.dispatchEvent(new c.MediaStreamTrackEvent("removetrack",{track:p}))}function f(p,m,g,v){var S=new Event("track");S.track=m,S.receiver=g,S.transceiver={receiver:g},S.streams=v,c.setTimeout(function(){p._dispatchEvent("track",S)})}var d=function(p){var m=this,g=document.createDocumentFragment();if(["addEventListener","removeEventListener","dispatchEvent"].forEach(function(S){m[S]=g[S].bind(g)}),this.canTrickleIceCandidates=null,this.needNegotiation=!1,this.localStreams=[],this.remoteStreams=[],this._localDescription=null,this._remoteDescription=null,this.signalingState="stable",this.iceConnectionState="new",this.connectionState="new",this.iceGatheringState="new",p=JSON.parse(JSON.stringify(p||{})),this.usingBundle=p.bundlePolicy==="max-bundle",p.rtcpMuxPolicy==="negotiate")throw o("NotSupportedError","rtcpMuxPolicy 'negotiate' is not supported");switch(p.rtcpMuxPolicy||(p.rtcpMuxPolicy="require"),p.iceTransportPolicy){case"all":case"relay":break;default:p.iceTransportPolicy="all";break}switch(p.bundlePolicy){case"balanced":case"max-compat":case"max-bundle":break;default:p.bundlePolicy="balanced";break}if(p.iceServers=i(p.iceServers||[],l),this._iceGatherers=[],p.iceCandidatePoolSize)for(var v=p.iceCandidatePoolSize;v>0;v--)this._iceGatherers.push(new c.RTCIceGatherer({iceServers:p.iceServers,gatherPolicy:p.iceTransportPolicy}));else p.iceCandidatePoolSize=0;this._config=p,this.transceivers=[],this._sdpSessionId=n.generateSessionId(),this._sdpSessionVersion=0,this._dtlsRole=void 0,this._isClosed=!1};Object.defineProperty(d.prototype,"localDescription",{configurable:!0,get:function(){return this._localDescription}}),Object.defineProperty(d.prototype,"remoteDescription",{configurable:!0,get:function(){return this._remoteDescription}}),d.prototype.onicecandidate=null,d.prototype.onaddstream=null,d.prototype.ontrack=null,d.prototype.onremovestream=null,d.prototype.onsignalingstatechange=null,d.prototype.oniceconnectionstatechange=null,d.prototype.onconnectionstatechange=null,d.prototype.onicegatheringstatechange=null,d.prototype.onnegotiationneeded=null,d.prototype.ondatachannel=null,d.prototype._dispatchEvent=function(p,m){this._isClosed||(this.dispatchEvent(m),typeof this["on"+p]=="function"&&this["on"+p](m))},d.prototype._emitGatheringStateChange=function(){var p=new Event("icegatheringstatechange");this._dispatchEvent("icegatheringstatechange",p)},d.prototype.getConfiguration=function(){return this._config},d.prototype.getLocalStreams=function(){return this.localStreams},d.prototype.getRemoteStreams=function(){return this.remoteStreams},d.prototype._createTransceiver=function(p,m){var g=this.transceivers.length>0,v={track:null,iceGatherer:null,iceTransport:null,dtlsTransport:null,localCapabilities:null,remoteCapabilities:null,rtpSender:null,rtpReceiver:null,kind:p,mid:null,sendEncodingParameters:null,recvEncodingParameters:null,stream:null,associatedRemoteMediaStreams:[],wantReceive:!0};if(this.usingBundle&&g)v.iceTransport=this.transceivers[0].iceTransport,v.dtlsTransport=this.transceivers[0].dtlsTransport;else{var S=this._createIceAndDtlsTransports();v.iceTransport=S.iceTransport,v.dtlsTransport=S.dtlsTransport}return m||this.transceivers.push(v),v},d.prototype.addTrack=function(p,m){if(this._isClosed)throw o("InvalidStateError","Attempted to call addTrack on a closed peerconnection.");var g=this.transceivers.find(function(x){return x.track===p});if(g)throw o("InvalidAccessError","Track already exists.");for(var v,S=0;S<this.transceivers.length;S++)!this.transceivers[S].track&&this.transceivers[S].kind===p.kind&&(v=this.transceivers[S]);return v||(v=this._createTransceiver(p.kind)),this._maybeFireNegotiationNeeded(),this.localStreams.indexOf(m)===-1&&this.localStreams.push(m),v.track=p,v.stream=m,v.rtpSender=new c.RTCRtpSender(p,v.dtlsTransport),v.rtpSender},d.prototype.addStream=function(p){var m=this;if(l>=15025)p.getTracks().forEach(function(v){m.addTrack(v,p)});else{var g=p.clone();p.getTracks().forEach(function(v,S){var x=g.getTracks()[S];v.addEventListener("enabled",function(b){x.enabled=b.enabled})}),g.getTracks().forEach(function(v){m.addTrack(v,g)})}},d.prototype.removeTrack=function(p){if(this._isClosed)throw o("InvalidStateError","Attempted to call removeTrack on a closed peerconnection.");if(!(p instanceof c.RTCRtpSender))throw new TypeError("Argument 1 of RTCPeerConnection.removeTrack does not implement interface RTCRtpSender.");var m=this.transceivers.find(function(S){return S.rtpSender===p});if(!m)throw o("InvalidAccessError","Sender was not created by this connection.");var g=m.stream;m.rtpSender.stop(),m.rtpSender=null,m.track=null,m.stream=null;var v=this.transceivers.map(function(S){return S.stream});v.indexOf(g)===-1&&this.localStreams.indexOf(g)>-1&&this.localStreams.splice(this.localStreams.indexOf(g),1),this._maybeFireNegotiationNeeded()},d.prototype.removeStream=function(p){var m=this;p.getTracks().forEach(function(g){var v=m.getSenders().find(function(S){return S.track===g});v&&m.removeTrack(v)})},d.prototype.getSenders=function(){return this.transceivers.filter(function(p){return!!p.rtpSender}).map(function(p){return p.rtpSender})},d.prototype.getReceivers=function(){return this.transceivers.filter(function(p){return!!p.rtpReceiver}).map(function(p){return p.rtpReceiver})},d.prototype._createIceGatherer=function(p,m){var g=this;if(m&&p>0)return this.transceivers[0].iceGatherer;if(this._iceGatherers.length)return this._iceGatherers.shift();var v=new c.RTCIceGatherer({iceServers:this._config.iceServers,gatherPolicy:this._config.iceTransportPolicy});return Object.defineProperty(v,"state",{value:"new",writable:!0}),this.transceivers[p].bufferedCandidateEvents=[],this.transceivers[p].bufferCandidates=function(S){var x=!S.candidate||Object.keys(S.candidate).length===0;v.state=x?"completed":"gathering",g.transceivers[p].bufferedCandidateEvents!==null&&g.transceivers[p].bufferedCandidateEvents.push(S)},v.addEventListener("localcandidate",this.transceivers[p].bufferCandidates),v},d.prototype._gather=function(p,m){var g=this,v=this.transceivers[m].iceGatherer;if(!v.onlocalcandidate){var S=this.transceivers[m].bufferedCandidateEvents;this.transceivers[m].bufferedCandidateEvents=null,v.removeEventListener("localcandidate",this.transceivers[m].bufferCandidates),v.onlocalcandidate=function(x){if(!(g.usingBundle&&m>0)){var b=new Event("icecandidate");b.candidate={sdpMid:p,sdpMLineIndex:m};var T=x.candidate,w=!T||Object.keys(T).length===0;if(w)(v.state==="new"||v.state==="gathering")&&(v.state="completed");else{v.state==="new"&&(v.state="gathering"),T.component=1,T.ufrag=v.getLocalParameters().usernameFragment;var C=n.writeCandidate(T);b.candidate=Object.assign(b.candidate,n.parseCandidate(C)),b.candidate.candidate=C,b.candidate.toJSON=function(){return{candidate:b.candidate.candidate,sdpMid:b.candidate.sdpMid,sdpMLineIndex:b.candidate.sdpMLineIndex,usernameFragment:b.candidate.usernameFragment}}}var P=n.getMediaSections(g._localDescription.sdp);w?P[b.candidate.sdpMLineIndex]+=`a=end-of-candidates\r
|
|
49
|
-
`:P[b.candidate.sdpMLineIndex]+="a="+b.candidate.candidate+`\r
|
|
50
|
-
`,g._localDescription.sdp=n.getDescription(g._localDescription.sdp)+P.join("");var R=g.transceivers.every(function(E){return E.iceGatherer&&E.iceGatherer.state==="completed"});g.iceGatheringState!=="gathering"&&(g.iceGatheringState="gathering",g._emitGatheringStateChange()),w||g._dispatchEvent("icecandidate",b),R&&(g._dispatchEvent("icecandidate",new Event("icecandidate")),g.iceGatheringState="complete",g._emitGatheringStateChange())}},c.setTimeout(function(){S.forEach(function(x){v.onlocalcandidate(x)})},0)}},d.prototype._createIceAndDtlsTransports=function(){var p=this,m=new c.RTCIceTransport(null);m.onicestatechange=function(){p._updateIceConnectionState(),p._updateConnectionState()};var g=new c.RTCDtlsTransport(m);return g.ondtlsstatechange=function(){p._updateConnectionState()},g.onerror=function(){Object.defineProperty(g,"state",{value:"failed",writable:!0}),p._updateConnectionState()},{iceTransport:m,dtlsTransport:g}},d.prototype._disposeIceAndDtlsTransports=function(p){var m=this.transceivers[p].iceGatherer;m&&(delete m.onlocalcandidate,delete this.transceivers[p].iceGatherer);var g=this.transceivers[p].iceTransport;g&&(delete g.onicestatechange,delete this.transceivers[p].iceTransport);var v=this.transceivers[p].dtlsTransport;v&&(delete v.ondtlsstatechange,delete v.onerror,delete this.transceivers[p].dtlsTransport)},d.prototype._transceive=function(p,m,g){var v=r(p.localCapabilities,p.remoteCapabilities);m&&p.rtpSender&&(v.encodings=p.sendEncodingParameters,v.rtcp={cname:n.localCName,compound:p.rtcpParameters.compound},p.recvEncodingParameters.length&&(v.rtcp.ssrc=p.recvEncodingParameters[0].ssrc),p.rtpSender.send(v)),g&&p.rtpReceiver&&v.codecs.length>0&&(p.kind==="video"&&p.recvEncodingParameters&&l<15019&&p.recvEncodingParameters.forEach(function(S){delete S.rtx}),p.recvEncodingParameters.length?v.encodings=p.recvEncodingParameters:v.encodings=[{}],v.rtcp={compound:p.rtcpParameters.compound},p.rtcpParameters.cname&&(v.rtcp.cname=p.rtcpParameters.cname),p.sendEncodingParameters.length&&(v.rtcp.ssrc=p.sendEncodingParameters[0].ssrc),p.rtpReceiver.receive(v))},d.prototype.setLocalDescription=function(p){var m=this;if(["offer","answer"].indexOf(p.type)===-1)return Promise.reject(o("TypeError",'Unsupported type "'+p.type+'"'));if(!s("setLocalDescription",p.type,m.signalingState)||m._isClosed)return Promise.reject(o("InvalidStateError","Can not set local "+p.type+" in state "+m.signalingState));var g,v;if(p.type==="offer")g=n.splitSections(p.sdp),v=g.shift(),g.forEach(function(x,b){var T=n.parseRtpParameters(x);m.transceivers[b].localCapabilities=T}),m.transceivers.forEach(function(x,b){m._gather(x.mid,b)});else if(p.type==="answer"){g=n.splitSections(m._remoteDescription.sdp),v=g.shift();var S=n.matchPrefix(v,"a=ice-lite").length>0;g.forEach(function(x,b){var T=m.transceivers[b],w=T.iceGatherer,C=T.iceTransport,P=T.dtlsTransport,R=T.localCapabilities,E=T.remoteCapabilities,A=n.isRejected(x)&&n.matchPrefix(x,"a=bundle-only").length===0;if(!A&&!T.rejected){var k=n.getIceParameters(x,v),z=n.getDtlsParameters(x,v);S&&(z.role="server"),(!m.usingBundle||b===0)&&(m._gather(T.mid,b),C.state==="new"&&C.start(w,k,S?"controlling":"controlled"),P.state==="new"&&P.start(z));var U=r(R,E);m._transceive(T,U.codecs.length>0,!1)}})}return m._localDescription={type:p.type,sdp:p.sdp},p.type==="offer"?m._updateSignalingState("have-local-offer"):m._updateSignalingState("stable"),Promise.resolve()},d.prototype.setRemoteDescription=function(p){var m=this;if(["offer","answer"].indexOf(p.type)===-1)return Promise.reject(o("TypeError",'Unsupported type "'+p.type+'"'));if(!s("setRemoteDescription",p.type,m.signalingState)||m._isClosed)return Promise.reject(o("InvalidStateError","Can not set remote "+p.type+" in state "+m.signalingState));var g={};m.remoteStreams.forEach(function(C){g[C.id]=C});var v=[],S=n.splitSections(p.sdp),x=S.shift(),b=n.matchPrefix(x,"a=ice-lite").length>0,T=n.matchPrefix(x,"a=group:BUNDLE ").length>0;m.usingBundle=T;var w=n.matchPrefix(x,"a=ice-options:")[0];return w?m.canTrickleIceCandidates=w.substr(14).split(" ").indexOf("trickle")>=0:m.canTrickleIceCandidates=!1,S.forEach(function(C,P){var R=n.splitLines(C),E=n.getKind(C),A=n.isRejected(C)&&n.matchPrefix(C,"a=bundle-only").length===0,k=R[0].substr(2).split(" ")[2],z=n.getDirection(C,x),U=n.parseMsid(C),L=n.getMid(C)||n.generateIdentifier();if(A||E==="application"&&(k==="DTLS/SCTP"||k==="UDP/DTLS/SCTP")){m.transceivers[P]={mid:L,kind:E,protocol:k,rejected:!0};return}!A&&m.transceivers[P]&&m.transceivers[P].rejected&&(m.transceivers[P]=m._createTransceiver(E,!0));var I,X,Z,it,K,pt,mt,rt,W,j=n.parseRtpParameters(C),Ht,Ft;A||(Ht=n.getIceParameters(C,x),Ft=n.getDtlsParameters(C,x),Ft.role="client"),mt=n.parseRtpEncodingParameters(C);var Lt=n.parseRtcpParameters(C),Vt=n.matchPrefix(C,"a=end-of-candidates",x).length>0,vt=n.matchPrefix(C,"a=candidate:").map(function(H){return n.parseCandidate(H)}).filter(function(H){return H.component===1});if((p.type==="offer"||p.type==="answer")&&!A&&T&&P>0&&m.transceivers[P]&&(m._disposeIceAndDtlsTransports(P),m.transceivers[P].iceGatherer=m.transceivers[0].iceGatherer,m.transceivers[P].iceTransport=m.transceivers[0].iceTransport,m.transceivers[P].dtlsTransport=m.transceivers[0].dtlsTransport,m.transceivers[P].rtpSender&&m.transceivers[P].rtpSender.setTransport(m.transceivers[0].dtlsTransport),m.transceivers[P].rtpReceiver&&m.transceivers[P].rtpReceiver.setTransport(m.transceivers[0].dtlsTransport)),p.type==="offer"&&!A){I=m.transceivers[P]||m._createTransceiver(E),I.mid=L,I.iceGatherer||(I.iceGatherer=m._createIceGatherer(P,T)),vt.length&&I.iceTransport.state==="new"&&(Vt&&(!T||P===0)?I.iceTransport.setRemoteCandidates(vt):vt.forEach(function(H){a(I.iceTransport,H)})),rt=c.RTCRtpReceiver.getCapabilities(E),l<15019&&(rt.codecs=rt.codecs.filter(function(H){return H.name!=="rtx"})),pt=I.sendEncodingParameters||[{ssrc:(2*P+2)*1001}];var At=!1;if(z==="sendrecv"||z==="sendonly"){if(At=!I.rtpReceiver,K=I.rtpReceiver||new c.RTCRtpReceiver(I.dtlsTransport,E),At){var _t;W=K.track,U&&U.stream==="-"||(U?(g[U.stream]||(g[U.stream]=new c.MediaStream,Object.defineProperty(g[U.stream],"id",{get:function(){return U.stream}})),Object.defineProperty(W,"id",{get:function(){return U.track}}),_t=g[U.stream]):(g.default||(g.default=new c.MediaStream),_t=g.default)),_t&&(u(W,_t),I.associatedRemoteMediaStreams.push(_t)),v.push([W,K,_t])}}else I.rtpReceiver&&I.rtpReceiver.track&&(I.associatedRemoteMediaStreams.forEach(function(H){var Jt=H.getTracks().find(function(Qt){return Qt.id===I.rtpReceiver.track.id});Jt&&h(Jt,H)}),I.associatedRemoteMediaStreams=[]);I.localCapabilities=rt,I.remoteCapabilities=j,I.rtpReceiver=K,I.rtcpParameters=Lt,I.sendEncodingParameters=pt,I.recvEncodingParameters=mt,m._transceive(m.transceivers[P],!1,At)}else if(p.type==="answer"&&!A){I=m.transceivers[P],X=I.iceGatherer,Z=I.iceTransport,it=I.dtlsTransport,K=I.rtpReceiver,pt=I.sendEncodingParameters,rt=I.localCapabilities,m.transceivers[P].recvEncodingParameters=mt,m.transceivers[P].remoteCapabilities=j,m.transceivers[P].rtcpParameters=Lt,vt.length&&Z.state==="new"&&((b||Vt)&&(!T||P===0)?Z.setRemoteCandidates(vt):vt.forEach(function(H){a(I.iceTransport,H)})),(!T||P===0)&&(Z.state==="new"&&Z.start(X,Ht,"controlling"),it.state==="new"&&it.start(Ft));var Yt=r(I.localCapabilities,I.remoteCapabilities),Zt=Yt.codecs.filter(function(H){return H.name.toLowerCase()==="rtx"}).length;!Zt&&I.sendEncodingParameters[0].rtx&&delete I.sendEncodingParameters[0].rtx,m._transceive(I,z==="sendrecv"||z==="recvonly",z==="sendrecv"||z==="sendonly"),K&&(z==="sendrecv"||z==="sendonly")?(W=K.track,U?(g[U.stream]||(g[U.stream]=new c.MediaStream),u(W,g[U.stream]),v.push([W,K,g[U.stream]])):(g.default||(g.default=new c.MediaStream),u(W,g.default),v.push([W,K,g.default]))):delete I.rtpReceiver}}),m._dtlsRole===void 0&&(m._dtlsRole=p.type==="offer"?"active":"passive"),m._remoteDescription={type:p.type,sdp:p.sdp},p.type==="offer"?m._updateSignalingState("have-remote-offer"):m._updateSignalingState("stable"),Object.keys(g).forEach(function(C){var P=g[C];if(P.getTracks().length){if(m.remoteStreams.indexOf(P)===-1){m.remoteStreams.push(P);var R=new Event("addstream");R.stream=P,c.setTimeout(function(){m._dispatchEvent("addstream",R)})}v.forEach(function(E){var A=E[0],k=E[1];P.id===E[2].id&&f(m,A,k,[P])})}}),v.forEach(function(C){C[2]||f(m,C[0],C[1],[])}),c.setTimeout(function(){m&&m.transceivers&&m.transceivers.forEach(function(C){C.iceTransport&&C.iceTransport.state==="new"&&C.iceTransport.getRemoteCandidates().length>0&&(console.warn("Timeout for addRemoteCandidate. Consider sending an end-of-candidates notification"),C.iceTransport.addRemoteCandidate({}))})},4e3),Promise.resolve()},d.prototype.close=function(){this.transceivers.forEach(function(p){p.iceTransport&&p.iceTransport.stop(),p.dtlsTransport&&p.dtlsTransport.stop(),p.rtpSender&&p.rtpSender.stop(),p.rtpReceiver&&p.rtpReceiver.stop()}),this._isClosed=!0,this._updateSignalingState("closed")},d.prototype._updateSignalingState=function(p){this.signalingState=p;var m=new Event("signalingstatechange");this._dispatchEvent("signalingstatechange",m)},d.prototype._maybeFireNegotiationNeeded=function(){var p=this;this.signalingState!=="stable"||this.needNegotiation===!0||(this.needNegotiation=!0,c.setTimeout(function(){if(p.needNegotiation){p.needNegotiation=!1;var m=new Event("negotiationneeded");p._dispatchEvent("negotiationneeded",m)}},0))},d.prototype._updateIceConnectionState=function(){var p,m={new:0,closed:0,checking:0,connected:0,completed:0,disconnected:0,failed:0};if(this.transceivers.forEach(function(v){v.iceTransport&&!v.rejected&&m[v.iceTransport.state]++}),p="new",m.failed>0?p="failed":m.checking>0?p="checking":m.disconnected>0?p="disconnected":m.new>0?p="new":m.connected>0?p="connected":m.completed>0&&(p="completed"),p!==this.iceConnectionState){this.iceConnectionState=p;var g=new Event("iceconnectionstatechange");this._dispatchEvent("iceconnectionstatechange",g)}},d.prototype._updateConnectionState=function(){var p,m={new:0,closed:0,connecting:0,connected:0,completed:0,disconnected:0,failed:0};if(this.transceivers.forEach(function(v){v.iceTransport&&v.dtlsTransport&&!v.rejected&&(m[v.iceTransport.state]++,m[v.dtlsTransport.state]++)}),m.connected+=m.completed,p="new",m.failed>0?p="failed":m.connecting>0?p="connecting":m.disconnected>0?p="disconnected":m.new>0?p="new":m.connected>0&&(p="connected"),p!==this.connectionState){this.connectionState=p;var g=new Event("connectionstatechange");this._dispatchEvent("connectionstatechange",g)}},d.prototype.createOffer=function(){var p=this;if(p._isClosed)return Promise.reject(o("InvalidStateError","Can not call createOffer after close"));var m=p.transceivers.filter(function(b){return b.kind==="audio"}).length,g=p.transceivers.filter(function(b){return b.kind==="video"}).length,v=arguments[0];if(v){if(v.mandatory||v.optional)throw new TypeError("Legacy mandatory/optional constraints not supported.");v.offerToReceiveAudio!==void 0&&(v.offerToReceiveAudio===!0?m=1:v.offerToReceiveAudio===!1?m=0:m=v.offerToReceiveAudio),v.offerToReceiveVideo!==void 0&&(v.offerToReceiveVideo===!0?g=1:v.offerToReceiveVideo===!1?g=0:g=v.offerToReceiveVideo)}for(p.transceivers.forEach(function(b){b.kind==="audio"?(m--,m<0&&(b.wantReceive=!1)):b.kind==="video"&&(g--,g<0&&(b.wantReceive=!1))});m>0||g>0;)m>0&&(p._createTransceiver("audio"),m--),g>0&&(p._createTransceiver("video"),g--);var S=n.writeSessionBoilerplate(p._sdpSessionId,p._sdpSessionVersion++);p.transceivers.forEach(function(b,T){var w=b.track,C=b.kind,P=b.mid||n.generateIdentifier();b.mid=P,b.iceGatherer||(b.iceGatherer=p._createIceGatherer(T,p.usingBundle));var R=c.RTCRtpSender.getCapabilities(C);l<15019&&(R.codecs=R.codecs.filter(function(A){return A.name!=="rtx"})),R.codecs.forEach(function(A){A.name==="H264"&&A.parameters["level-asymmetry-allowed"]===void 0&&(A.parameters["level-asymmetry-allowed"]="1"),b.remoteCapabilities&&b.remoteCapabilities.codecs&&b.remoteCapabilities.codecs.forEach(function(k){A.name.toLowerCase()===k.name.toLowerCase()&&A.clockRate===k.clockRate&&(A.preferredPayloadType=k.payloadType)})}),R.headerExtensions.forEach(function(A){var k=b.remoteCapabilities&&b.remoteCapabilities.headerExtensions||[];k.forEach(function(z){A.uri===z.uri&&(A.id=z.id)})});var E=b.sendEncodingParameters||[{ssrc:(2*T+1)*1001}];w&&l>=15019&&C==="video"&&!E[0].rtx&&(E[0].rtx={ssrc:E[0].ssrc+1}),b.wantReceive&&(b.rtpReceiver=new c.RTCRtpReceiver(b.dtlsTransport,C)),b.localCapabilities=R,b.sendEncodingParameters=E}),p._config.bundlePolicy!=="max-compat"&&(S+="a=group:BUNDLE "+p.transceivers.map(function(b){return b.mid}).join(" ")+`\r
|
|
51
|
-
`),S+=`a=ice-options:trickle\r
|
|
52
|
-
`,p.transceivers.forEach(function(b,T){S+=e(b,b.localCapabilities,"offer",b.stream,p._dtlsRole),S+=`a=rtcp-rsize\r
|
|
53
|
-
`,b.iceGatherer&&p.iceGatheringState!=="new"&&(T===0||!p.usingBundle)&&(b.iceGatherer.getLocalCandidates().forEach(function(w){w.component=1,S+="a="+n.writeCandidate(w)+`\r
|
|
54
|
-
`}),b.iceGatherer.state==="completed"&&(S+=`a=end-of-candidates\r
|
|
55
|
-
`))});var x=new c.RTCSessionDescription({type:"offer",sdp:S});return Promise.resolve(x)},d.prototype.createAnswer=function(){var p=this;if(p._isClosed)return Promise.reject(o("InvalidStateError","Can not call createAnswer after close"));if(!(p.signalingState==="have-remote-offer"||p.signalingState==="have-local-pranswer"))return Promise.reject(o("InvalidStateError","Can not call createAnswer in signalingState "+p.signalingState));var m=n.writeSessionBoilerplate(p._sdpSessionId,p._sdpSessionVersion++);p.usingBundle&&(m+="a=group:BUNDLE "+p.transceivers.map(function(S){return S.mid}).join(" ")+`\r
|
|
56
|
-
`),m+=`a=ice-options:trickle\r
|
|
57
|
-
`;var g=n.getMediaSections(p._remoteDescription.sdp).length;p.transceivers.forEach(function(S,x){if(!(x+1>g)){if(S.rejected){S.kind==="application"?S.protocol==="DTLS/SCTP"?m+=`m=application 0 DTLS/SCTP 5000\r
|
|
58
|
-
`:m+="m=application 0 "+S.protocol+` webrtc-datachannel\r
|
|
59
|
-
`:S.kind==="audio"?m+=`m=audio 0 UDP/TLS/RTP/SAVPF 0\r
|
|
60
|
-
a=rtpmap:0 PCMU/8000\r
|
|
61
|
-
`:S.kind==="video"&&(m+=`m=video 0 UDP/TLS/RTP/SAVPF 120\r
|
|
62
|
-
a=rtpmap:120 VP8/90000\r
|
|
63
|
-
`),m+=`c=IN IP4 0.0.0.0\r
|
|
64
|
-
a=inactive\r
|
|
65
|
-
a=mid:`+S.mid+`\r
|
|
66
|
-
`;return}if(S.stream){var b;S.kind==="audio"?b=S.stream.getAudioTracks()[0]:S.kind==="video"&&(b=S.stream.getVideoTracks()[0]),b&&l>=15019&&S.kind==="video"&&!S.sendEncodingParameters[0].rtx&&(S.sendEncodingParameters[0].rtx={ssrc:S.sendEncodingParameters[0].ssrc+1})}var T=r(S.localCapabilities,S.remoteCapabilities),w=T.codecs.filter(function(C){return C.name.toLowerCase()==="rtx"}).length;!w&&S.sendEncodingParameters[0].rtx&&delete S.sendEncodingParameters[0].rtx,m+=e(S,T,"answer",S.stream,p._dtlsRole),S.rtcpParameters&&S.rtcpParameters.reducedSize&&(m+=`a=rtcp-rsize\r
|
|
67
|
-
`)}});var v=new c.RTCSessionDescription({type:"answer",sdp:m});return Promise.resolve(v)},d.prototype.addIceCandidate=function(p){var m=this,g;return p&&!(p.sdpMLineIndex!==void 0||p.sdpMid)?Promise.reject(new TypeError("sdpMLineIndex or sdpMid required")):new Promise(function(v,S){if(m._remoteDescription)if(!p||p.candidate==="")for(var x=0;x<m.transceivers.length&&!(!m.transceivers[x].rejected&&(m.transceivers[x].iceTransport.addRemoteCandidate({}),g=n.getMediaSections(m._remoteDescription.sdp),g[x]+=`a=end-of-candidates\r
|
|
68
|
-
`,m._remoteDescription.sdp=n.getDescription(m._remoteDescription.sdp)+g.join(""),m.usingBundle));x++);else{var b=p.sdpMLineIndex;if(p.sdpMid){for(var T=0;T<m.transceivers.length;T++)if(m.transceivers[T].mid===p.sdpMid){b=T;break}}var w=m.transceivers[b];if(w){if(w.rejected)return v();var C=Object.keys(p.candidate).length>0?n.parseCandidate(p.candidate):{};if(C.protocol==="tcp"&&(C.port===0||C.port===9)||C.component&&C.component!==1)return v();if((b===0||b>0&&w.iceTransport!==m.transceivers[0].iceTransport)&&!a(w.iceTransport,C))return S(o("OperationError","Can not add ICE candidate"));var P=p.candidate.trim();P.indexOf("a=")===0&&(P=P.substr(2)),g=n.getMediaSections(m._remoteDescription.sdp),g[b]+="a="+(C.type?P:"end-of-candidates")+`\r
|
|
69
|
-
`,m._remoteDescription.sdp=n.getDescription(m._remoteDescription.sdp)+g.join("")}else return S(o("OperationError","Can not add ICE candidate"))}else return S(o("InvalidStateError","Can not add ICE candidate without a remote description"));v()})},d.prototype.getStats=function(p){if(p&&p instanceof c.MediaStreamTrack){var m=null;if(this.transceivers.forEach(function(v){v.rtpSender&&v.rtpSender.track===p?m=v.rtpSender:v.rtpReceiver&&v.rtpReceiver.track===p&&(m=v.rtpReceiver)}),!m)throw o("InvalidAccessError","Invalid selector.");return m.getStats()}var g=[];return this.transceivers.forEach(function(v){["rtpSender","rtpReceiver","iceGatherer","iceTransport","dtlsTransport"].forEach(function(S){v[S]&&g.push(v[S].getStats())})}),Promise.all(g).then(function(v){var S=new Map;return v.forEach(function(x){x.forEach(function(b){S.set(b.id,b)})}),S})};var y=["RTCRtpSender","RTCRtpReceiver","RTCIceGatherer","RTCIceTransport","RTCDtlsTransport"];y.forEach(function(p){var m=c[p];if(m&&m.prototype&&m.prototype.getStats){var g=m.prototype.getStats;m.prototype.getStats=function(){return g.apply(this).then(function(v){var S=new Map;return Object.keys(v).forEach(function(x){v[x].type=t(v[x]),S.set(x,v[x])}),S})}}});var _=["createOffer","createAnswer"];return _.forEach(function(p){var m=d.prototype[p];d.prototype[p]=function(){var g=arguments;return typeof g[0]=="function"||typeof g[1]=="function"?m.apply(this,[arguments[2]]).then(function(v){typeof g[0]=="function"&&g[0].apply(null,[v])},function(v){typeof g[1]=="function"&&g[1].apply(null,[v])}):m.apply(this,arguments)}}),_=["setLocalDescription","setRemoteDescription","addIceCandidate"],_.forEach(function(p){var m=d.prototype[p];d.prototype[p]=function(){var g=arguments;return typeof g[1]=="function"||typeof g[2]=="function"?m.apply(this,arguments).then(function(){typeof g[1]=="function"&&g[1].apply(null)},function(v){typeof g[2]=="function"&&g[2].apply(null,[v])}):m.apply(this,arguments)}}),["getStats"].forEach(function(p){var m=d.prototype[p];d.prototype[p]=function(){var g=arguments;return typeof g[1]=="function"?m.apply(this,arguments).then(function(){typeof g[1]=="function"&&g[1].apply(null)}):m.apply(this,arguments)}}),d},Zr}var za=ka();const Oa=Vr(za);function Po(n){const t=n&&n.navigator,e=function(r){return{name:{PermissionDeniedError:"NotAllowedError"}[r.name]||r.name,message:r.message,constraint:r.constraint,toString(){return this.name}}},i=t.mediaDevices.getUserMedia.bind(t.mediaDevices);Object.getOwnPropertyDescriptor(t.mediaDevices,"getUserMedia")?.writable&&(t.mediaDevices.getUserMedia=function(r){return i(r).catch(s=>Promise.reject(e(s)))})}function wo(n){"getDisplayMedia"in n.navigator&&n.navigator.mediaDevices&&(n.navigator.mediaDevices&&"getDisplayMedia"in n.navigator.mediaDevices||(n.navigator.mediaDevices.getDisplayMedia=n.navigator.getDisplayMedia.bind(n.navigator)))}function Rn(n,t){if(n.RTCIceGatherer&&(n.RTCIceCandidate||(n.RTCIceCandidate=function(r){return r}),n.RTCSessionDescription||(n.RTCSessionDescription=function(r){return r}),t.version<15025)){const i=Object.getOwnPropertyDescriptor(n.MediaStreamTrack.prototype,"enabled");Object.defineProperty(n.MediaStreamTrack.prototype,"enabled",{set(r){i.set.call(this,r);const s=new Event("enabled");s.enabled=r,this.dispatchEvent(s)}})}n.RTCRtpSender&&!("dtmf"in n.RTCRtpSender.prototype)&&Object.defineProperty(n.RTCRtpSender.prototype,"dtmf",{get(){return this._dtmf===void 0&&(this.track.kind==="audio"?this._dtmf=new n.RTCDtmfSender(this):this.track.kind==="video"&&(this._dtmf=null)),this._dtmf}}),n.RTCDtmfSender&&!n.RTCDTMFSender&&(n.RTCDTMFSender=n.RTCDtmfSender);const e=Oa(n,t.version);n.RTCPeerConnection=function(r){return r&&r.iceServers&&(r.iceServers=Aa(r.iceServers,t.version),Hn("ICE servers after filtering:",r.iceServers)),new e(r)},n.RTCPeerConnection.prototype=e.prototype}function Eo(n){n.RTCRtpSender&&!("replaceTrack"in n.RTCRtpSender.prototype)&&(n.RTCRtpSender.prototype.replaceTrack=n.RTCRtpSender.prototype.setTrack)}const vs=Object.freeze(Object.defineProperty({__proto__:null,shimGetDisplayMedia:wo,shimGetUserMedia:Po,shimPeerConnection:Rn,shimReplaceTrack:Eo},Symbol.toStringTag,{value:"Module"}));function Ro(n,t){const e=n&&n.navigator,i=n&&n.MediaStreamTrack;if(e.getUserMedia=function(r,s,a){Jr("navigator.getUserMedia","navigator.mediaDevices.getUserMedia"),e.mediaDevices.getUserMedia(r).then(s,a)},!(t.version>55&&"autoGainControl"in e.mediaDevices.getSupportedConstraints())){const r=function(a,o,c){o in a&&!(c in a)&&(a[c]=a[o],delete a[o])},s=e.mediaDevices.getUserMedia.bind(e.mediaDevices);if(Object.getOwnPropertyDescriptor(e.mediaDevices,"getUserMedia")?.writable&&(e.mediaDevices.getUserMedia=function(a){return typeof a=="object"&&typeof a.audio=="object"&&(a=JSON.parse(JSON.stringify(a)),r(a.audio,"autoGainControl","mozAutoGainControl"),r(a.audio,"noiseSuppression","mozNoiseSuppression")),s(a)}),i&&i.prototype.getSettings){const a=i.prototype.getSettings;i.prototype.getSettings=function(){const o=a.apply(this,arguments);return r(o,"mozAutoGainControl","autoGainControl"),r(o,"mozNoiseSuppression","noiseSuppression"),o}}if(i&&i.prototype.applyConstraints){const a=i.prototype.applyConstraints;i.prototype.applyConstraints=function(o){return this.kind==="audio"&&typeof o=="object"&&(o=JSON.parse(JSON.stringify(o)),r(o,"autoGainControl","mozAutoGainControl"),r(o,"noiseSuppression","mozNoiseSuppression")),a.apply(this,[o])}}}}function Ba(n,t){n.navigator.mediaDevices&&"getDisplayMedia"in n.navigator.mediaDevices||n.navigator.mediaDevices&&(n.navigator.mediaDevices.getDisplayMedia=function(i){if(!(i&&i.video)){const r=new DOMException("getDisplayMedia without video constraints is undefined");return r.name="NotFoundError",r.code=8,Promise.reject(r)}return i.video===!0?i.video={mediaSource:t}:i.video.mediaSource=t,n.navigator.mediaDevices.getUserMedia(i)})}function Ao(n){typeof n=="object"&&n.RTCTrackEvent&&"receiver"in n.RTCTrackEvent.prototype&&!("transceiver"in n.RTCTrackEvent.prototype)&&Object.defineProperty(n.RTCTrackEvent.prototype,"transceiver",{get(){return{receiver:this.receiver}}})}function An(n,t){if(typeof n!="object"||!(n.RTCPeerConnection||n.mozRTCPeerConnection))return;!n.RTCPeerConnection&&n.mozRTCPeerConnection&&(n.RTCPeerConnection=n.mozRTCPeerConnection),t.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach(function(r){const s=n.RTCPeerConnection.prototype[r],a={[r](){return arguments[0]=new(r==="addIceCandidate"?n.RTCIceCandidate:n.RTCSessionDescription)(arguments[0]),s.apply(this,arguments)}};n.RTCPeerConnection.prototype[r]=a[r]});const e={inboundrtp:"inbound-rtp",outboundrtp:"outbound-rtp",candidatepair:"candidate-pair",localcandidate:"local-candidate",remotecandidate:"remote-candidate"},i=n.RTCPeerConnection.prototype.getStats;n.RTCPeerConnection.prototype.getStats=function(){const[s,a,o]=arguments;return i.apply(this,[s||null]).then(c=>{if(t.version<53&&!a)try{c.forEach(l=>{l.type=e[l.type]||l.type})}catch(l){if(l.name!=="TypeError")throw l;c.forEach((u,h)=>{c.set(h,Object.assign({},u,{type:e[u.type]||u.type}))})}return c}).then(a,o)}}function ko(n){if(!(typeof n=="object"&&n.RTCPeerConnection&&n.RTCRtpSender)||n.RTCRtpSender&&"getStats"in n.RTCRtpSender.prototype)return;const t=n.RTCPeerConnection.prototype.getSenders;t&&(n.RTCPeerConnection.prototype.getSenders=function(){const r=t.apply(this,[]);return r.forEach(s=>s._pc=this),r});const e=n.RTCPeerConnection.prototype.addTrack;e&&(n.RTCPeerConnection.prototype.addTrack=function(){const r=e.apply(this,arguments);return r._pc=this,r}),n.RTCRtpSender.prototype.getStats=function(){return this.track?this._pc.getStats(this.track):Promise.resolve(new Map)}}function zo(n){if(!(typeof n=="object"&&n.RTCPeerConnection&&n.RTCRtpSender)||n.RTCRtpSender&&"getStats"in n.RTCRtpReceiver.prototype)return;const t=n.RTCPeerConnection.prototype.getReceivers;t&&(n.RTCPeerConnection.prototype.getReceivers=function(){const i=t.apply(this,[]);return i.forEach(r=>r._pc=this),i}),$e(n,"track",e=>(e.receiver._pc=e.srcElement,e)),n.RTCRtpReceiver.prototype.getStats=function(){return this._pc.getStats(this.track)}}function Oo(n){!n.RTCPeerConnection||"removeStream"in n.RTCPeerConnection.prototype||(n.RTCPeerConnection.prototype.removeStream=function(e){Jr("removeStream","removeTrack"),this.getSenders().forEach(i=>{i.track&&e.getTracks().includes(i.track)&&this.removeTrack(i)})})}function Bo(n){n.DataChannel&&!n.RTCDataChannel&&(n.RTCDataChannel=n.DataChannel)}function Io(n){if(!(typeof n=="object"&&n.RTCPeerConnection))return;const t=n.RTCPeerConnection.prototype.addTransceiver;t&&(n.RTCPeerConnection.prototype.addTransceiver=function(){this.setParametersPromises=[];const i=arguments[1],r=i&&"sendEncodings"in i;r&&i.sendEncodings.forEach(a=>{if("rid"in a&&!/^[a-z0-9]{0,16}$/i.test(a.rid))throw new TypeError("Invalid RID value provided.");if("scaleResolutionDownBy"in a&&!(parseFloat(a.scaleResolutionDownBy)>=1))throw new RangeError("scale_resolution_down_by must be >= 1.0");if("maxFramerate"in a&&!(parseFloat(a.maxFramerate)>=0))throw new RangeError("max_framerate must be >= 0.0")});const s=t.apply(this,arguments);if(r){const{sender:a}=s,o=a.getParameters();(!("encodings"in o)||o.encodings.length===1&&Object.keys(o.encodings[0]).length===0)&&(o.encodings=i.sendEncodings,a.sendEncodings=i.sendEncodings,this.setParametersPromises.push(a.setParameters(o).then(()=>{delete a.sendEncodings}).catch(()=>{delete a.sendEncodings})))}return s})}function Uo(n){if(!(typeof n=="object"&&n.RTCRtpSender))return;const t=n.RTCRtpSender.prototype.getParameters;t&&(n.RTCRtpSender.prototype.getParameters=function(){const i=t.apply(this,arguments);return"encodings"in i||(i.encodings=[].concat(this.sendEncodings||[{}])),i})}function No(n){if(!(typeof n=="object"&&n.RTCPeerConnection))return;const t=n.RTCPeerConnection.prototype.createOffer;n.RTCPeerConnection.prototype.createOffer=function(){return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then(()=>t.apply(this,arguments)).finally(()=>{this.setParametersPromises=[]}):t.apply(this,arguments)}}function Do(n){if(!(typeof n=="object"&&n.RTCPeerConnection))return;const t=n.RTCPeerConnection.prototype.createAnswer;n.RTCPeerConnection.prototype.createAnswer=function(){return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then(()=>t.apply(this,arguments)).finally(()=>{this.setParametersPromises=[]}):t.apply(this,arguments)}}const _s=Object.freeze(Object.defineProperty({__proto__:null,shimAddTransceiver:Io,shimCreateAnswer:Do,shimCreateOffer:No,shimGetDisplayMedia:Ba,shimGetParameters:Uo,shimGetUserMedia:Ro,shimOnTrack:Ao,shimPeerConnection:An,shimRTCDataChannel:Bo,shimReceiverGetStats:zo,shimRemoveStream:Oo,shimSenderGetStats:ko},Symbol.toStringTag,{value:"Module"}));function Fo(n){if(!(typeof n!="object"||!n.RTCPeerConnection)){if("getLocalStreams"in n.RTCPeerConnection.prototype||(n.RTCPeerConnection.prototype.getLocalStreams=function(){return this._localStreams||(this._localStreams=[]),this._localStreams}),!("addStream"in n.RTCPeerConnection.prototype)){const t=n.RTCPeerConnection.prototype.addTrack;n.RTCPeerConnection.prototype.addStream=function(i){this._localStreams||(this._localStreams=[]),this._localStreams.includes(i)||this._localStreams.push(i),i.getAudioTracks().forEach(r=>t.call(this,r,i)),i.getVideoTracks().forEach(r=>t.call(this,r,i))},n.RTCPeerConnection.prototype.addTrack=function(i,...r){return r&&r.forEach(s=>{this._localStreams?this._localStreams.includes(s)||this._localStreams.push(s):this._localStreams=[s]}),t.apply(this,arguments)}}"removeStream"in n.RTCPeerConnection.prototype||(n.RTCPeerConnection.prototype.removeStream=function(e){this._localStreams||(this._localStreams=[]);const i=this._localStreams.indexOf(e);if(i===-1)return;this._localStreams.splice(i,1);const r=e.getTracks();this.getSenders().forEach(s=>{r.includes(s.track)&&this.removeTrack(s)})})}}function Lo(n){if(!(typeof n!="object"||!n.RTCPeerConnection)&&("getRemoteStreams"in n.RTCPeerConnection.prototype||(n.RTCPeerConnection.prototype.getRemoteStreams=function(){return this._remoteStreams?this._remoteStreams:[]}),!("onaddstream"in n.RTCPeerConnection.prototype))){Object.defineProperty(n.RTCPeerConnection.prototype,"onaddstream",{get(){return this._onaddstream},set(e){this._onaddstream&&(this.removeEventListener("addstream",this._onaddstream),this.removeEventListener("track",this._onaddstreampoly)),this.addEventListener("addstream",this._onaddstream=e),this.addEventListener("track",this._onaddstreampoly=i=>{i.streams.forEach(r=>{if(this._remoteStreams||(this._remoteStreams=[]),this._remoteStreams.includes(r))return;this._remoteStreams.push(r);const s=new Event("addstream");s.stream=r,this.dispatchEvent(s)})})}});const t=n.RTCPeerConnection.prototype.setRemoteDescription;n.RTCPeerConnection.prototype.setRemoteDescription=function(){const i=this;return this._onaddstreampoly||this.addEventListener("track",this._onaddstreampoly=function(r){r.streams.forEach(s=>{if(i._remoteStreams||(i._remoteStreams=[]),i._remoteStreams.indexOf(s)>=0)return;i._remoteStreams.push(s);const a=new Event("addstream");a.stream=s,i.dispatchEvent(a)})}),t.apply(i,arguments)}}}function Vo(n){if(typeof n!="object"||!n.RTCPeerConnection)return;const t=n.RTCPeerConnection.prototype,e=t.createOffer,i=t.createAnswer,r=t.setLocalDescription,s=t.setRemoteDescription,a=t.addIceCandidate;t.createOffer=function(l,u){const h=arguments.length>=2?arguments[2]:arguments[0],f=e.apply(this,[h]);return u?(f.then(l,u),Promise.resolve()):f},t.createAnswer=function(l,u){const h=arguments.length>=2?arguments[2]:arguments[0],f=i.apply(this,[h]);return u?(f.then(l,u),Promise.resolve()):f};let o=function(c,l,u){const h=r.apply(this,[c]);return u?(h.then(l,u),Promise.resolve()):h};t.setLocalDescription=o,o=function(c,l,u){const h=s.apply(this,[c]);return u?(h.then(l,u),Promise.resolve()):h},t.setRemoteDescription=o,o=function(c,l,u){const h=a.apply(this,[c]);return u?(h.then(l,u),Promise.resolve()):h},t.addIceCandidate=o}function Jo(n){const t=n&&n.navigator;if(t.mediaDevices&&t.mediaDevices.getUserMedia){const e=t.mediaDevices,i=e.getUserMedia.bind(e);t.mediaDevices.getUserMedia=r=>i(Go(r))}!t.getUserMedia&&t.mediaDevices&&t.mediaDevices.getUserMedia&&(t.getUserMedia=(function(i,r,s){t.mediaDevices.getUserMedia(i).then(r,s)}).bind(t))}function Go(n){return n&&n.video!==void 0?Object.assign({},n,{video:mo(n.video)}):n}function jo(n){if(!n.RTCPeerConnection)return;const t=n.RTCPeerConnection;n.RTCPeerConnection=function(i,r){if(i&&i.iceServers){const s=[];for(let a=0;a<i.iceServers.length;a++){let o=i.iceServers[a];!o.hasOwnProperty("urls")&&o.hasOwnProperty("url")?(Jr("RTCIceServer.url","RTCIceServer.urls"),o=JSON.parse(JSON.stringify(o)),o.urls=o.url,delete o.url,s.push(o)):s.push(i.iceServers[a])}i.iceServers=s}return new t(i,r)},n.RTCPeerConnection.prototype=t.prototype,"generateCertificate"in t&&Object.defineProperty(n.RTCPeerConnection,"generateCertificate",{get(){return t.generateCertificate}})}function $o(n){typeof n=="object"&&n.RTCTrackEvent&&"receiver"in n.RTCTrackEvent.prototype&&!("transceiver"in n.RTCTrackEvent.prototype)&&Object.defineProperty(n.RTCTrackEvent.prototype,"transceiver",{get(){return{receiver:this.receiver}}})}function qo(n){const t=n.RTCPeerConnection.prototype.createOffer;n.RTCPeerConnection.prototype.createOffer=function(i){if(i){typeof i.offerToReceiveAudio<"u"&&(i.offerToReceiveAudio=!!i.offerToReceiveAudio);const r=this.getTransceivers().find(a=>a.receiver.track.kind==="audio");i.offerToReceiveAudio===!1&&r?r.direction==="sendrecv"?r.setDirection?r.setDirection("sendonly"):r.direction="sendonly":r.direction==="recvonly"&&(r.setDirection?r.setDirection("inactive"):r.direction="inactive"):i.offerToReceiveAudio===!0&&!r&&this.addTransceiver("audio"),typeof i.offerToReceiveVideo<"u"&&(i.offerToReceiveVideo=!!i.offerToReceiveVideo);const s=this.getTransceivers().find(a=>a.receiver.track.kind==="video");i.offerToReceiveVideo===!1&&s?s.direction==="sendrecv"?s.setDirection?s.setDirection("sendonly"):s.direction="sendonly":s.direction==="recvonly"&&(s.setDirection?s.setDirection("inactive"):s.direction="inactive"):i.offerToReceiveVideo===!0&&!s&&this.addTransceiver("video")}return t.apply(this,arguments)}}function Xo(n){typeof n!="object"||n.AudioContext||(n.AudioContext=n.webkitAudioContext)}const xs=Object.freeze(Object.defineProperty({__proto__:null,shimAudioContext:Xo,shimCallbacksAPI:Vo,shimConstraints:Go,shimCreateOfferLegacy:qo,shimGetUserMedia:Jo,shimLocalStreamsAPI:Fo,shimRTCIceServerUrls:jo,shimRemoteStreamsAPI:Lo,shimTrackEventTransceiver:$o},Symbol.toStringTag,{value:"Module"}));var Ia=Co();const Pr=Vr(Ia);function wr(n){if(!n.RTCIceCandidate||n.RTCIceCandidate&&"foundation"in n.RTCIceCandidate.prototype)return;const t=n.RTCIceCandidate;n.RTCIceCandidate=function(i){if(typeof i=="object"&&i.candidate&&i.candidate.indexOf("a=")===0&&(i=JSON.parse(JSON.stringify(i)),i.candidate=i.candidate.substr(2)),i.candidate&&i.candidate.length){const r=new t(i),s=Pr.parseCandidate(i.candidate),a=Object.assign(r,s);return a.toJSON=function(){return{candidate:a.candidate,sdpMid:a.sdpMid,sdpMLineIndex:a.sdpMLineIndex,usernameFragment:a.usernameFragment}},a}return new t(i)},n.RTCIceCandidate.prototype=t.prototype,$e(n,"icecandidate",e=>(e.candidate&&Object.defineProperty(e,"candidate",{value:new n.RTCIceCandidate(e.candidate),writable:"false"}),e))}function ui(n,t){if(!n.RTCPeerConnection)return;"sctp"in n.RTCPeerConnection.prototype||Object.defineProperty(n.RTCPeerConnection.prototype,"sctp",{get(){return typeof this._sctp>"u"?null:this._sctp}});const e=function(o){if(!o||!o.sdp)return!1;const c=Pr.splitSections(o.sdp);return c.shift(),c.some(l=>{const u=Pr.parseMLine(l);return u&&u.kind==="application"&&u.protocol.indexOf("SCTP")!==-1})},i=function(o){const c=o.sdp.match(/mozilla...THIS_IS_SDPARTA-(\d+)/);if(c===null||c.length<2)return-1;const l=parseInt(c[1],10);return l!==l?-1:l},r=function(o){let c=65536;return t.browser==="firefox"&&(t.version<57?o===-1?c=16384:c=2147483637:t.version<60?c=t.version===57?65535:65536:c=2147483637),c},s=function(o,c){let l=65536;t.browser==="firefox"&&t.version===57&&(l=65535);const u=Pr.matchPrefix(o.sdp,"a=max-message-size:");return u.length>0?l=parseInt(u[0].substr(19),10):t.browser==="firefox"&&c!==-1&&(l=2147483637),l},a=n.RTCPeerConnection.prototype.setRemoteDescription;n.RTCPeerConnection.prototype.setRemoteDescription=function(){if(this._sctp=null,t.browser==="chrome"&&t.version>=76){const{sdpSemantics:c}=this.getConfiguration();c==="plan-b"&&Object.defineProperty(this,"sctp",{get(){return typeof this._sctp>"u"?null:this._sctp},enumerable:!0,configurable:!0})}if(e(arguments[0])){const c=i(arguments[0]),l=r(c),u=s(arguments[0],c);let h;l===0&&u===0?h=Number.POSITIVE_INFINITY:l===0||u===0?h=Math.max(l,u):h=Math.min(l,u);const f={};Object.defineProperty(f,"maxMessageSize",{get(){return h}}),this._sctp=f}return a.apply(this,arguments)}}function hi(n){if(!(n.RTCPeerConnection&&"createDataChannel"in n.RTCPeerConnection.prototype))return;function t(i,r){const s=i.send;i.send=function(){const o=arguments[0],c=o.length||o.size||o.byteLength;if(i.readyState==="open"&&r.sctp&&c>r.sctp.maxMessageSize)throw new TypeError("Message too large (can send a maximum of "+r.sctp.maxMessageSize+" bytes)");return s.apply(i,arguments)}}const e=n.RTCPeerConnection.prototype.createDataChannel;n.RTCPeerConnection.prototype.createDataChannel=function(){const r=e.apply(this,arguments);return t(r,this),r},$e(n,"datachannel",i=>(t(i.channel,i.target),i))}function kn(n){if(!n.RTCPeerConnection||"connectionState"in n.RTCPeerConnection.prototype)return;const t=n.RTCPeerConnection.prototype;Object.defineProperty(t,"connectionState",{get(){return{completed:"connected",checking:"connecting"}[this.iceConnectionState]||this.iceConnectionState},enumerable:!0,configurable:!0}),Object.defineProperty(t,"onconnectionstatechange",{get(){return this._onconnectionstatechange||null},set(e){this._onconnectionstatechange&&(this.removeEventListener("connectionstatechange",this._onconnectionstatechange),delete this._onconnectionstatechange),e&&this.addEventListener("connectionstatechange",this._onconnectionstatechange=e)},enumerable:!0,configurable:!0}),["setLocalDescription","setRemoteDescription"].forEach(e=>{const i=t[e];t[e]=function(){return this._connectionstatechangepoly||(this._connectionstatechangepoly=r=>{const s=r.target;if(s._lastConnectionState!==s.connectionState){s._lastConnectionState=s.connectionState;const a=new Event("connectionstatechange",r);s.dispatchEvent(a)}return r},this.addEventListener("iceconnectionstatechange",this._connectionstatechangepoly)),i.apply(this,arguments)}})}function zn(n,t){if(!n.RTCPeerConnection||t.browser==="chrome"&&t.version>=71||t.browser==="safari"&&t.version>=605)return;const e=n.RTCPeerConnection.prototype.setRemoteDescription;n.RTCPeerConnection.prototype.setRemoteDescription=function(r){if(r&&r.sdp&&r.sdp.indexOf(`
|
|
70
|
-
a=extmap-allow-mixed`)!==-1){const s=r.sdp.split(`
|
|
71
|
-
`).filter(a=>a.trim()!=="a=extmap-allow-mixed").join(`
|
|
72
|
-
`);n.RTCSessionDescription&&r instanceof n.RTCSessionDescription?arguments[0]=new n.RTCSessionDescription({type:r.type,sdp:s}):r.sdp=s}return e.apply(this,arguments)}}function Er(n,t){if(!(n.RTCPeerConnection&&n.RTCPeerConnection.prototype))return;const e=n.RTCPeerConnection.prototype.addIceCandidate;!e||e.length===0||(n.RTCPeerConnection.prototype.addIceCandidate=function(){return arguments[0]?(t.browser==="chrome"&&t.version<78||t.browser==="firefox"&&t.version<68||t.browser==="safari")&&arguments[0]&&arguments[0].candidate===""?Promise.resolve():e.apply(this,arguments):(arguments[1]&&arguments[1].apply(null),Promise.resolve())})}const Ua=Object.freeze(Object.defineProperty({__proto__:null,removeExtmapAllowMixed:zn,shimAddIceCandidateNullOrEmpty:Er,shimConnectionState:kn,shimMaxMessageSize:ui,shimRTCIceCandidate:wr,shimSendThrowTypeError:hi},Symbol.toStringTag,{value:"Module"}));function Na({window:n}={},t={shimChrome:!0,shimFirefox:!0,shimEdge:!0,shimSafari:!0}){const e=Hn,i=Ea(n),r={browserDetails:i,commonShim:Ua,extractVersion:li,disableLog:Pa,disableWarnings:wa};switch(i.browser){case"chrome":if(!ms||!En||!t.shimChrome)return e("Chrome shim is not included in this adapter release."),r;if(i.version===null)return e("Chrome shim can not determine version, not shimming."),r;e("adapter.js shimming chrome."),r.browserShim=ms,Er(n,i),yo(n,i),go(n),En(n,i),vo(n),To(n,i),_o(n),xo(n),So(n),Mo(n,i),wr(n),kn(n),ui(n,i),hi(n),zn(n,i);break;case"firefox":if(!_s||!An||!t.shimFirefox)return e("Firefox shim is not included in this adapter release."),r;e("adapter.js shimming firefox."),r.browserShim=_s,Er(n,i),Ro(n,i),An(n,i),Ao(n),Oo(n),ko(n),zo(n),Bo(n),Io(n),Uo(n),No(n),Do(n),wr(n),kn(n),ui(n,i),hi(n);break;case"edge":if(!vs||!Rn||!t.shimEdge)return e("MS edge shim is not included in this adapter release."),r;e("adapter.js shimming edge."),r.browserShim=vs,Po(n),wo(n),Rn(n,i),Eo(n),ui(n,i),hi(n);break;case"safari":if(!xs||!t.shimSafari)return e("Safari shim is not included in this adapter release."),r;e("adapter.js shimming safari."),r.browserShim=xs,Er(n,i),jo(n),qo(n),Vo(n),Fo(n),Lo(n),$o(n),Jo(n),Xo(n),wr(n),ui(n,i),hi(n),zn(n,i);break;default:e("Unsupported browser!");break}return r}const Ss=Na({window:typeof window>"u"?void 0:window});function Wt(n,t,e,i){Object.defineProperty(n,t,{get:e,set:i,enumerable:!0,configurable:!0})}var Qr=Ss.default||Ss,Qe=new((function(){function n(){this.isIOS=["iPad","iPhone","iPod"].includes(navigator.platform),this.supportedBrowsers=["firefox","chrome","safari"],this.minFirefoxVersion=59,this.minChromeVersion=72,this.minSafariVersion=605}return n.prototype.isWebRTCSupported=function(){return typeof RTCPeerConnection<"u"},n.prototype.isBrowserSupported=function(){var t=this.getBrowser(),e=this.getVersion(),i=this.supportedBrowsers.includes(t);return i?t==="chrome"?e>=this.minChromeVersion:t==="firefox"?e>=this.minFirefoxVersion:t==="safari"?!this.isIOS&&e>=this.minSafariVersion:!1:!1},n.prototype.getBrowser=function(){return Qr.browserDetails.browser},n.prototype.getVersion=function(){return Qr.browserDetails.version||0},n.prototype.isUnifiedPlanSupported=function(){var t=this.getBrowser(),e=Qr.browserDetails.version||0;if(t==="chrome"&&e<this.minChromeVersion)return!1;if(t==="firefox"&&e>=this.minFirefoxVersion)return!0;if(!window.RTCRtpTransceiver||!("currentDirection"in RTCRtpTransceiver.prototype))return!1;var i,r=!1;try{i=new RTCPeerConnection,i.addTransceiver("audio"),r=!0}catch{}finally{i&&i.close()}return r},n.prototype.toString=function(){return`Supports:
|
|
73
|
-
browser:`.concat(this.getBrowser(),`
|
|
74
|
-
version:`).concat(this.getVersion(),`
|
|
75
|
-
isIOS:`).concat(this.isIOS,`
|
|
76
|
-
isWebRTCSupported:`).concat(this.isWebRTCSupported(),`
|
|
77
|
-
isBrowserSupported:`).concat(this.isBrowserSupported(),`
|
|
78
|
-
isUnifiedPlanSupported:`).concat(this.isUnifiedPlanSupported())},n})()),bs={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"},Da=(function(){function n(){this.CLOUD_HOST="0.peerjs.com",this.CLOUD_PORT=443,this.chunkedBrowsers={Chrome:1,chrome:1},this.chunkedMTU=16300,this.defaultConfig=bs,this.browser=Qe.getBrowser(),this.browserVersion=Qe.getVersion(),this.supports=(function(){var t={browser:Qe.isBrowserSupported(),webRTC:Qe.isWebRTCSupported(),audioVideo:!1,data:!1,binaryBlob:!1,reliable:!1};if(!t.webRTC)return t;var e;try{e=new RTCPeerConnection(bs),t.audioVideo=!0;var i=void 0;try{i=e.createDataChannel("_PEERJSTEST",{ordered:!0}),t.data=!0,t.reliable=!!i.ordered;try{i.binaryType="blob",t.binaryBlob=!Qe.isIOS}catch{}}catch{}finally{i&&i.close()}}catch{}finally{e&&e.close()}return t})(),this.pack=hs.pack,this.unpack=hs.unpack,this._dataCount=1}return n.prototype.noop=function(){},n.prototype.validateId=function(t){return!t||/^[A-Za-z0-9]+(?:[ _-][A-Za-z0-9]+)*$/.test(t)},n.prototype.chunk=function(t){for(var e=[],i=t.size,r=Math.ceil(i/F.chunkedMTU),s=0,a=0;a<i;){var o=Math.min(i,a+F.chunkedMTU),c=t.slice(a,o),l={__peerData:this._dataCount,n:s,data:c,total:r};e.push(l),a=o,s++}return this._dataCount++,e},n.prototype.blobToArrayBuffer=function(t,e){var i=new FileReader;return i.onload=function(r){r.target&&e(r.target.result)},i.readAsArrayBuffer(t),i},n.prototype.binaryStringToArrayBuffer=function(t){for(var e=new Uint8Array(t.length),i=0;i<t.length;i++)e[i]=t.charCodeAt(i)&255;return e.buffer},n.prototype.randomToken=function(){return Math.random().toString(36).slice(2)},n.prototype.isSecure=function(){return location.protocol==="https:"},n})(),F=new Da,Wo={};Wt(Wo,"Peer",()=>In,n=>In=n);var Zi={},Fa=Object.prototype.hasOwnProperty,gt="~";function vi(){}Object.create&&(vi.prototype=Object.create(null),new vi().__proto__||(gt=!1));function La(n,t,e){this.fn=n,this.context=t,this.once=e||!1}function Ho(n,t,e,i,r){if(typeof e!="function")throw new TypeError("The listener must be a function");var s=new La(e,i||n,r),a=gt?gt+t:t;return n._events[a]?n._events[a].fn?n._events[a]=[n._events[a],s]:n._events[a].push(s):(n._events[a]=s,n._eventsCount++),n}function Rr(n,t){--n._eventsCount===0?n._events=new vi:delete n._events[t]}function ft(){this._events=new vi,this._eventsCount=0}ft.prototype.eventNames=function(){var t=[],e,i;if(this._eventsCount===0)return t;for(i in e=this._events)Fa.call(e,i)&&t.push(gt?i.slice(1):i);return Object.getOwnPropertySymbols?t.concat(Object.getOwnPropertySymbols(e)):t};ft.prototype.listeners=function(t){var e=gt?gt+t:t,i=this._events[e];if(!i)return[];if(i.fn)return[i.fn];for(var r=0,s=i.length,a=new Array(s);r<s;r++)a[r]=i[r].fn;return a};ft.prototype.listenerCount=function(t){var e=gt?gt+t:t,i=this._events[e];return i?i.fn?1:i.length:0};ft.prototype.emit=function(t,e,i,r,s,a){var o=gt?gt+t:t;if(!this._events[o])return!1;var c=this._events[o],l=arguments.length,u,h;if(c.fn){switch(c.once&&this.removeListener(t,c.fn,void 0,!0),l){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,e),!0;case 3:return c.fn.call(c.context,e,i),!0;case 4:return c.fn.call(c.context,e,i,r),!0;case 5:return c.fn.call(c.context,e,i,r,s),!0;case 6:return c.fn.call(c.context,e,i,r,s,a),!0}for(h=1,u=new Array(l-1);h<l;h++)u[h-1]=arguments[h];c.fn.apply(c.context,u)}else{var f=c.length,d;for(h=0;h<f;h++)switch(c[h].once&&this.removeListener(t,c[h].fn,void 0,!0),l){case 1:c[h].fn.call(c[h].context);break;case 2:c[h].fn.call(c[h].context,e);break;case 3:c[h].fn.call(c[h].context,e,i);break;case 4:c[h].fn.call(c[h].context,e,i,r);break;default:if(!u)for(d=1,u=new Array(l-1);d<l;d++)u[d-1]=arguments[d];c[h].fn.apply(c[h].context,u)}}return!0};ft.prototype.on=function(t,e,i){return Ho(this,t,e,i,!1)};ft.prototype.once=function(t,e,i){return Ho(this,t,e,i,!0)};ft.prototype.removeListener=function(t,e,i,r){var s=gt?gt+t:t;if(!this._events[s])return this;if(!e)return Rr(this,s),this;var a=this._events[s];if(a.fn)a.fn===e&&(!r||a.once)&&(!i||a.context===i)&&Rr(this,s);else{for(var o=0,c=[],l=a.length;o<l;o++)(a[o].fn!==e||r&&!a[o].once||i&&a[o].context!==i)&&c.push(a[o]);c.length?this._events[s]=c.length===1?c[0]:c:Rr(this,s)}return this};ft.prototype.removeAllListeners=function(t){var e;return t?(e=gt?gt+t:t,this._events[e]&&Rr(this,e)):(this._events=new vi,this._eventsCount=0),this};ft.prototype.off=ft.prototype.removeListener;ft.prototype.addListener=ft.prototype.on;ft.prefixed=gt;ft.EventEmitter=ft;Zi=ft;var O={};Wt(O,"LogLevel",()=>xt,n=>xt=n);Wt(O,"default",()=>Ts,n=>Ts=n);var _e=function(n,t){var e=typeof Symbol=="function"&&n[Symbol.iterator];if(!e)return n;var i=e.call(n),r,s=[],a;try{for(;(t===void 0||t-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(o){a={error:o}}finally{try{r&&!r.done&&(e=i.return)&&e.call(i)}finally{if(a)throw a.error}}return s},xe=function(n,t,e){if(e||arguments.length===2)for(var i=0,r=t.length,s;i<r;i++)(s||!(i in t))&&(s||(s=Array.prototype.slice.call(t,0,i)),s[i]=t[i]);return n.concat(s||Array.prototype.slice.call(t))},Va="PeerJS: ",xt;(function(n){n[n.Disabled=0]="Disabled",n[n.Errors=1]="Errors",n[n.Warnings=2]="Warnings",n[n.All=3]="All"})(xt||(xt={}));var Ja=(function(){function n(){this._logLevel=xt.Disabled}return Object.defineProperty(n.prototype,"logLevel",{get:function(){return this._logLevel},set:function(t){this._logLevel=t},enumerable:!1,configurable:!0}),n.prototype.log=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this._logLevel>=xt.All&&this._print.apply(this,xe([xt.All],_e(t),!1))},n.prototype.warn=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this._logLevel>=xt.Warnings&&this._print.apply(this,xe([xt.Warnings],_e(t),!1))},n.prototype.error=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this._logLevel>=xt.Errors&&this._print.apply(this,xe([xt.Errors],_e(t),!1))},n.prototype.setLogFunction=function(t){this._print=t},n.prototype._print=function(t){for(var e=[],i=1;i<arguments.length;i++)e[i-1]=arguments[i];var r=xe([Va],_e(e),!1);for(var s in r)r[s]instanceof Error&&(r[s]="("+r[s].name+") "+r[s].message);t>=xt.All?console.log.apply(console,xe([],_e(r),!1)):t>=xt.Warnings?console.warn.apply(console,xe(["WARNING"],_e(r),!1)):t>=xt.Errors&&console.error.apply(console,xe(["ERROR"],_e(r),!1))},n})(),Ts=new Ja,Yo={};Wt(Yo,"Socket",()=>Ms,n=>Ms=n);var Nt;(function(n){n.Data="data",n.Media="media"})(Nt||(Nt={}));var Q;(function(n){n.BrowserIncompatible="browser-incompatible",n.Disconnected="disconnected",n.InvalidID="invalid-id",n.InvalidKey="invalid-key",n.Network="network",n.PeerUnavailable="peer-unavailable",n.SslUnavailable="ssl-unavailable",n.ServerError="server-error",n.SocketError="socket-error",n.SocketClosed="socket-closed",n.UnavailableID="unavailable-id",n.WebRTC="webrtc"})(Q||(Q={}));var se;(function(n){n.Binary="binary",n.BinaryUTF8="binary-utf8",n.JSON="json"})(se||(se={}));var ae;(function(n){n.Message="message",n.Disconnected="disconnected",n.Error="error",n.Close="close"})(ae||(ae={}));var ut;(function(n){n.Heartbeat="HEARTBEAT",n.Candidate="CANDIDATE",n.Offer="OFFER",n.Answer="ANSWER",n.Open="OPEN",n.Error="ERROR",n.IdTaken="ID-TAKEN",n.InvalidKey="INVALID-KEY",n.Leave="LEAVE",n.Expire="EXPIRE"})(ut||(ut={}));var Yn={};Yn=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 Ga=(function(){var n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,r){i.__proto__=r}||function(i,r){for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(i[s]=r[s])},n(t,e)};return function(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");n(t,e);function i(){this.constructor=t}t.prototype=e===null?Object.create(e):(i.prototype=e.prototype,new i)}})(),ja=function(n,t){var e=typeof Symbol=="function"&&n[Symbol.iterator];if(!e)return n;var i=e.call(n),r,s=[],a;try{for(;(t===void 0||t-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(o){a={error:o}}finally{try{r&&!r.done&&(e=i.return)&&e.call(i)}finally{if(a)throw a.error}}return s},$a=function(n,t,e){if(e||arguments.length===2)for(var i=0,r=t.length,s;i<r;i++)(s||!(i in t))&&(s||(s=Array.prototype.slice.call(t,0,i)),s[i]=t[i]);return n.concat(s||Array.prototype.slice.call(t))},qa=function(n){var t=typeof Symbol=="function"&&Symbol.iterator,e=t&&n[t],i=0;if(e)return e.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},Ms=(function(n){Ga(t,n);function t(e,i,r,s,a,o){o===void 0&&(o=5e3);var c=n.call(this)||this;c.pingInterval=o,c._disconnected=!0,c._messagesQueue=[];var l=e?"wss://":"ws://";return c._baseUrl=l+i+":"+r+s+"peerjs?key="+a,c}return t.prototype.start=function(e,i){var r=this;this._id=e;var s="".concat(this._baseUrl,"&id=").concat(e,"&token=").concat(i);this._socket||!this._disconnected||(this._socket=new WebSocket(s+"&version="+Yn.version),this._disconnected=!1,this._socket.onmessage=function(a){var o;try{o=JSON.parse(a.data),O.default.log("Server message received:",o)}catch{O.default.log("Invalid server message",a.data);return}r.emit(ae.Message,o)},this._socket.onclose=function(a){r._disconnected||(O.default.log("Socket closed.",a),r._cleanup(),r._disconnected=!0,r.emit(ae.Disconnected))},this._socket.onopen=function(){r._disconnected||(r._sendQueuedMessages(),O.default.log("Socket open"),r._scheduleHeartbeat())})},t.prototype._scheduleHeartbeat=function(){var e=this;this._wsPingTimer=setTimeout(function(){e._sendHeartbeat()},this.pingInterval)},t.prototype._sendHeartbeat=function(){if(!this._wsOpen()){O.default.log("Cannot send heartbeat, because socket closed");return}var e=JSON.stringify({type:ut.Heartbeat});this._socket.send(e),this._scheduleHeartbeat()},t.prototype._wsOpen=function(){return!!this._socket&&this._socket.readyState===1},t.prototype._sendQueuedMessages=function(){var e,i,r=$a([],ja(this._messagesQueue),!1);this._messagesQueue=[];try{for(var s=qa(r),a=s.next();!a.done;a=s.next()){var o=a.value;this.send(o)}}catch(c){e={error:c}}finally{try{a&&!a.done&&(i=s.return)&&i.call(s)}finally{if(e)throw e.error}}},t.prototype.send=function(e){if(!this._disconnected){if(!this._id){this._messagesQueue.push(e);return}if(!e.type){this.emit(ae.Error,"Invalid message");return}if(this._wsOpen()){var i=JSON.stringify(e);this._socket.send(i)}}},t.prototype.close=function(){this._disconnected||(this._cleanup(),this._disconnected=!0)},t.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)},t})(Zi.EventEmitter),On={};Wt(On,"MediaConnection",()=>ws,n=>ws=n);var Zn={};Wt(Zn,"Negotiator",()=>Cs,n=>Cs=n);var kr=function(){return kr=Object.assign||function(n){for(var t,e=1,i=arguments.length;e<i;e++){t=arguments[e];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])}return n},kr.apply(this,arguments)},er=function(n,t,e,i){function r(s){return s instanceof e?s:new e(function(a){a(s)})}return new(e||(e=Promise))(function(s,a){function o(u){try{l(i.next(u))}catch(h){a(h)}}function c(u){try{l(i.throw(u))}catch(h){a(h)}}function l(u){u.done?s(u.value):r(u.value).then(o,c)}l((i=i.apply(n,t||[])).next())})},ir=function(n,t){var e={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},i,r,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(i)throw new TypeError("Generator is already executing.");for(;e;)try{if(i=1,r&&(s=l[0]&2?r.return:l[0]?r.throw||((s=r.return)&&s.call(r),0):r.next)&&!(s=s.call(r,l[1])).done)return s;switch(r=0,s&&(l=[l[0]&2,s.value]),l[0]){case 0:case 1:s=l;break;case 4:return e.label++,{value:l[1],done:!1};case 5:e.label++,r=l[1],l=[0];continue;case 7:l=e.ops.pop(),e.trys.pop();continue;default:if(s=e.trys,!(s=s.length>0&&s[s.length-1])&&(l[0]===6||l[0]===2)){e=0;continue}if(l[0]===3&&(!s||l[1]>s[0]&&l[1]<s[3])){e.label=l[1];break}if(l[0]===6&&e.label<s[1]){e.label=s[1],s=l;break}if(s&&e.label<s[2]){e.label=s[2],e.ops.push(l);break}s[2]&&e.ops.pop(),e.trys.pop();continue}l=t.call(n,e)}catch(u){l=[6,u],r=0}finally{i=s=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}},Cs=(function(){function n(t){this.connection=t}return n.prototype.startConnection=function(t){var e=this._startPeerConnection();if(this.connection.peerConnection=e,this.connection.type===Nt.Media&&t._stream&&this._addTracksToConnection(t._stream,e),t.originator){if(this.connection.type===Nt.Data){var i=this.connection,r={ordered:!!t.reliable},s=e.createDataChannel(i.label,r);i.initialize(s)}this._makeOffer()}else this.handleSDP("OFFER",t.sdp)},n.prototype._startPeerConnection=function(){O.default.log("Creating RTCPeerConnection.");var t=new RTCPeerConnection(this.connection.provider.options.config);return this._setupListeners(t),t},n.prototype._setupListeners=function(t){var e=this,i=this.connection.peer,r=this.connection.connectionId,s=this.connection.type,a=this.connection.provider;O.default.log("Listening for ICE candidates."),t.onicecandidate=function(o){!o.candidate||!o.candidate.candidate||(O.default.log("Received ICE candidates for ".concat(i,":"),o.candidate),a.socket.send({type:ut.Candidate,payload:{candidate:o.candidate,type:s,connectionId:r},dst:i}))},t.oniceconnectionstatechange=function(){switch(t.iceConnectionState){case"failed":O.default.log("iceConnectionState is failed, closing connections to "+i),e.connection.emit("error",new Error("Negotiation of connection to "+i+" failed.")),e.connection.close();break;case"closed":O.default.log("iceConnectionState is closed, closing connections to "+i),e.connection.emit("error",new Error("Connection to "+i+" closed.")),e.connection.close();break;case"disconnected":O.default.log("iceConnectionState changed to disconnected on the connection with "+i);break;case"completed":t.onicecandidate=F.noop;break}e.connection.emit("iceStateChanged",t.iceConnectionState)},O.default.log("Listening for data channel"),t.ondatachannel=function(o){O.default.log("Received data channel");var c=o.channel,l=a.getConnection(i,r);l.initialize(c)},O.default.log("Listening for remote stream"),t.ontrack=function(o){O.default.log("Received remote stream");var c=o.streams[0],l=a.getConnection(i,r);if(l.type===Nt.Media){var u=l;e._addStreamToMediaConnection(c,u)}}},n.prototype.cleanup=function(){O.default.log("Cleaning up PeerConnection to "+this.connection.peer);var t=this.connection.peerConnection;if(t){this.connection.peerConnection=null,t.onicecandidate=t.oniceconnectionstatechange=t.ondatachannel=t.ontrack=function(){};var e=t.signalingState!=="closed",i=!1;if(this.connection.type===Nt.Data){var r=this.connection,s=r.dataChannel;s&&(i=!!s.readyState&&s.readyState!=="closed")}(e||i)&&t.close()}},n.prototype._makeOffer=function(){return er(this,void 0,Promise,function(){var t,e,i,r,s,a,o;return ir(this,function(c){switch(c.label){case 0:t=this.connection.peerConnection,e=this.connection.provider,c.label=1;case 1:return c.trys.push([1,7,,8]),[4,t.createOffer(this.connection.options.constraints)];case 2:i=c.sent(),O.default.log("Created offer."),this.connection.options.sdpTransform&&typeof this.connection.options.sdpTransform=="function"&&(i.sdp=this.connection.options.sdpTransform(i.sdp)||i.sdp),c.label=3;case 3:return c.trys.push([3,5,,6]),[4,t.setLocalDescription(i)];case 4:return c.sent(),O.default.log("Set localDescription:",i,"for:".concat(this.connection.peer)),r={sdp:i,type:this.connection.type,connectionId:this.connection.connectionId,metadata:this.connection.metadata,browser:F.browser},this.connection.type===Nt.Data&&(s=this.connection,r=kr(kr({},r),{label:s.label,reliable:s.reliable,serialization:s.serialization})),e.socket.send({type:ut.Offer,payload:r,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"&&(e.emitError(Q.WebRTC,a),O.default.log("Failed to setLocalDescription, ",a)),[3,6];case 6:return[3,8];case 7:return o=c.sent(),e.emitError(Q.WebRTC,o),O.default.log("Failed to createOffer, ",o),[3,8];case 8:return[2]}})})},n.prototype._makeAnswer=function(){return er(this,void 0,Promise,function(){var t,e,i,r,s;return ir(this,function(a){switch(a.label){case 0:t=this.connection.peerConnection,e=this.connection.provider,a.label=1;case 1:return a.trys.push([1,7,,8]),[4,t.createAnswer()];case 2:i=a.sent(),O.default.log("Created answer."),this.connection.options.sdpTransform&&typeof this.connection.options.sdpTransform=="function"&&(i.sdp=this.connection.options.sdpTransform(i.sdp)||i.sdp),a.label=3;case 3:return a.trys.push([3,5,,6]),[4,t.setLocalDescription(i)];case 4:return a.sent(),O.default.log("Set localDescription:",i,"for:".concat(this.connection.peer)),e.socket.send({type:ut.Answer,payload:{sdp:i,type:this.connection.type,connectionId:this.connection.connectionId,browser:F.browser},dst:this.connection.peer}),[3,6];case 5:return r=a.sent(),e.emitError(Q.WebRTC,r),O.default.log("Failed to setLocalDescription, ",r),[3,6];case 6:return[3,8];case 7:return s=a.sent(),e.emitError(Q.WebRTC,s),O.default.log("Failed to create answer, ",s),[3,8];case 8:return[2]}})})},n.prototype.handleSDP=function(t,e){return er(this,void 0,Promise,function(){var i,r,s,a;return ir(this,function(o){switch(o.label){case 0:e=new RTCSessionDescription(e),i=this.connection.peerConnection,r=this.connection.provider,O.default.log("Setting remote description",e),s=this,o.label=1;case 1:return o.trys.push([1,5,,6]),[4,i.setRemoteDescription(e)];case 2:return o.sent(),O.default.log("Set remoteDescription:".concat(t," for:").concat(this.connection.peer)),t!=="OFFER"?[3,4]:[4,s._makeAnswer()];case 3:o.sent(),o.label=4;case 4:return[3,6];case 5:return a=o.sent(),r.emitError(Q.WebRTC,a),O.default.log("Failed to setRemoteDescription, ",a),[3,6];case 6:return[2]}})})},n.prototype.handleCandidate=function(t){return er(this,void 0,Promise,function(){var e,i,r,s,a,o;return ir(this,function(c){switch(c.label){case 0:O.default.log("handleCandidate:",t),e=t.candidate,i=t.sdpMLineIndex,r=t.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:r,sdpMLineIndex:i,candidate:e}))];case 2:return c.sent(),O.default.log("Added ICE candidate for:".concat(this.connection.peer)),[3,4];case 3:return o=c.sent(),a.emitError(Q.WebRTC,o),O.default.log("Failed to handleCandidate, ",o),[3,4];case 4:return[2]}})})},n.prototype._addTracksToConnection=function(t,e){if(O.default.log("add tracks from stream ".concat(t.id," to peer connection")),!e.addTrack)return O.default.error("Your browser does't support RTCPeerConnection#addTrack. Ignored.");t.getTracks().forEach(function(i){e.addTrack(i,t)})},n.prototype._addStreamToMediaConnection=function(t,e){O.default.log("add stream ".concat(t.id," to media connection ").concat(e.connectionId)),e.addStream(t)},n})(),Qn={};Wt(Qn,"BaseConnection",()=>Ps,n=>Ps=n);var Xa=(function(){var n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,r){i.__proto__=r}||function(i,r){for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(i[s]=r[s])},n(t,e)};return function(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");n(t,e);function i(){this.constructor=t}t.prototype=e===null?Object.create(e):(i.prototype=e.prototype,new i)}})(),Ps=(function(n){Xa(t,n);function t(e,i,r){var s=n.call(this)||this;return s.peer=e,s.provider=i,s.options=r,s._open=!1,s.metadata=r.metadata,s}return Object.defineProperty(t.prototype,"open",{get:function(){return this._open},enumerable:!1,configurable:!0}),t})(Zi.EventEmitter),Wa=(function(){var n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,r){i.__proto__=r}||function(i,r){for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(i[s]=r[s])},n(t,e)};return function(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");n(t,e);function i(){this.constructor=t}t.prototype=e===null?Object.create(e):(i.prototype=e.prototype,new i)}})(),zr=function(){return zr=Object.assign||function(n){for(var t,e=1,i=arguments.length;e<i;e++){t=arguments[e];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])}return n},zr.apply(this,arguments)},Ha=function(n){var t=typeof Symbol=="function"&&Symbol.iterator,e=t&&n[t],i=0;if(e)return e.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},ws=(function(n){Wa(t,n);function t(e,i,r){var s=n.call(this,e,i,r)||this;return s._localStream=s.options._stream,s.connectionId=s.options.connectionId||t.ID_PREFIX+F.randomToken(),s._negotiator=new Zn.Negotiator(s),s._localStream&&s._negotiator.startConnection({_stream:s._localStream,originator:!0}),s}return Object.defineProperty(t.prototype,"type",{get:function(){return Nt.Media},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"localStream",{get:function(){return this._localStream},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"remoteStream",{get:function(){return this._remoteStream},enumerable:!1,configurable:!0}),t.prototype.addStream=function(e){O.default.log("Receiving stream",e),this._remoteStream=e,n.prototype.emit.call(this,"stream",e)},t.prototype.handleMessage=function(e){var i=e.type,r=e.payload;switch(e.type){case ut.Answer:this._negotiator.handleSDP(i,r.sdp),this._open=!0;break;case ut.Candidate:this._negotiator.handleCandidate(r.candidate);break;default:O.default.warn("Unrecognized message type:".concat(i," from peer:").concat(this.peer));break}},t.prototype.answer=function(e,i){var r,s;if(i===void 0&&(i={}),this._localStream){O.default.warn("Local stream already exists on this MediaConnection. Are you answering a call twice?");return}this._localStream=e,i&&i.sdpTransform&&(this.options.sdpTransform=i.sdpTransform),this._negotiator.startConnection(zr(zr({},this.options._payload),{_stream:e}));var a=this.provider._getMessages(this.connectionId);try{for(var o=Ha(a),c=o.next();!c.done;c=o.next()){var l=c.value;this.handleMessage(l)}}catch(u){r={error:u}}finally{try{c&&!c.done&&(s=o.return)&&s.call(o)}finally{if(r)throw r.error}}this._open=!0},t.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,n.prototype.emit.call(this,"close"))},t.ID_PREFIX="mc_",t})(Qn.BaseConnection),Bn={};Wt(Bn,"DataConnection",()=>Rs,n=>Rs=n);var Zo={};Wt(Zo,"EncodingQueue",()=>Es,n=>Es=n);var Ya=(function(){var n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,r){i.__proto__=r}||function(i,r){for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(i[s]=r[s])},n(t,e)};return function(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");n(t,e);function i(){this.constructor=t}t.prototype=e===null?Object.create(e):(i.prototype=e.prototype,new i)}})(),Es=(function(n){Ya(t,n);function t(){var e=n.call(this)||this;return e.fileReader=new FileReader,e._queue=[],e._processing=!1,e.fileReader.onload=function(i){e._processing=!1,i.target&&e.emit("done",i.target.result),e.doNextTask()},e.fileReader.onerror=function(i){O.default.error("EncodingQueue error:",i),e._processing=!1,e.destroy(),e.emit("error",i)},e}return Object.defineProperty(t.prototype,"queue",{get:function(){return this._queue},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"size",{get:function(){return this.queue.length},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"processing",{get:function(){return this._processing},enumerable:!1,configurable:!0}),t.prototype.enque=function(e){this.queue.push(e),!this.processing&&this.doNextTask()},t.prototype.destroy=function(){this.fileReader.abort(),this._queue=[]},t.prototype.doNextTask=function(){this.size!==0&&(this.processing||(this._processing=!0,this.fileReader.readAsArrayBuffer(this.queue.shift())))},t})(Zi.EventEmitter),Za=(function(){var n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,r){i.__proto__=r}||function(i,r){for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(i[s]=r[s])},n(t,e)};return function(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");n(t,e);function i(){this.constructor=t}t.prototype=e===null?Object.create(e):(i.prototype=e.prototype,new i)}})(),Qa=function(n){var t=typeof Symbol=="function"&&Symbol.iterator,e=t&&n[t],i=0;if(e)return e.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},Rs=(function(n){Za(t,n);function t(e,i,r){var s=n.call(this,e,i,r)||this;return s.stringify=JSON.stringify,s.parse=JSON.parse,s._buffer=[],s._bufferSize=0,s._buffering=!1,s._chunkedData={},s._encodingQueue=new Zo.EncodingQueue,s.connectionId=s.options.connectionId||t.ID_PREFIX+F.randomToken(),s.label=s.options.label||s.connectionId,s.serialization=s.options.serialization||se.Binary,s.reliable=!!s.options.reliable,s._encodingQueue.on("done",function(a){s._bufferedSend(a)}),s._encodingQueue.on("error",function(){O.default.error("DC#".concat(s.connectionId,": Error occured in encoding from blob to arraybuffer, close DC")),s.close()}),s._negotiator=new Zn.Negotiator(s),s._negotiator.startConnection(s.options._payload||{originator:!0}),s}return Object.defineProperty(t.prototype,"type",{get:function(){return Nt.Data},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"dataChannel",{get:function(){return this._dc},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"bufferSize",{get:function(){return this._bufferSize},enumerable:!1,configurable:!0}),t.prototype.initialize=function(e){this._dc=e,this._configureDataChannel()},t.prototype._configureDataChannel=function(){var e=this;(!F.supports.binaryBlob||F.supports.reliable)&&(this.dataChannel.binaryType="arraybuffer"),this.dataChannel.onopen=function(){O.default.log("DC#".concat(e.connectionId," dc connection success")),e._open=!0,e.emit("open")},this.dataChannel.onmessage=function(i){O.default.log("DC#".concat(e.connectionId," dc onmessage:"),i.data),e._handleDataMessage(i)},this.dataChannel.onclose=function(){O.default.log("DC#".concat(e.connectionId," dc closed for:"),e.peer),e.close()}},t.prototype._handleDataMessage=function(e){var i=this,r=e.data,s=r.constructor,a=this.serialization===se.Binary||this.serialization===se.BinaryUTF8,o=r;if(a){if(s===Blob){F.blobToArrayBuffer(r,function(l){var u=F.unpack(l);i.emit("data",u)});return}else if(s===ArrayBuffer)o=F.unpack(r);else if(s===String){var c=F.binaryStringToArrayBuffer(r);o=F.unpack(c)}}else this.serialization===se.JSON&&(o=this.parse(r));if(o.__peerData){this._handleChunk(o);return}n.prototype.emit.call(this,"data",o)},t.prototype._handleChunk=function(e){var i=e.__peerData,r=this._chunkedData[i]||{data:[],count:0,total:e.total};if(r.data[e.n]=e.data,r.count++,this._chunkedData[i]=r,r.total===r.count){delete this._chunkedData[i];var s=new Blob(r.data);this._handleDataMessage({data:s})}},t.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,n.prototype.emit.call(this,"close"))},t.prototype.send=function(e,i){if(!this.open){n.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===se.JSON)this._bufferedSend(this.stringify(e));else if(this.serialization===se.Binary||this.serialization===se.BinaryUTF8){var r=F.pack(e);if(!i&&r.size>F.chunkedMTU){this._sendChunks(r);return}F.supports.binaryBlob?this._bufferedSend(r):this._encodingQueue.enque(r)}else this._bufferedSend(e)},t.prototype._bufferedSend=function(e){(this._buffering||!this._trySend(e))&&(this._buffer.push(e),this._bufferSize=this._buffer.length)},t.prototype._trySend=function(e){var i=this;if(!this.open)return!1;if(this.dataChannel.bufferedAmount>t.MAX_BUFFERED_AMOUNT)return this._buffering=!0,setTimeout(function(){i._buffering=!1,i._tryBuffer()},50),!1;try{this.dataChannel.send(e)}catch(r){return O.default.error("DC#:".concat(this.connectionId," Error when sending:"),r),this._buffering=!0,this.close(),!1}return!0},t.prototype._tryBuffer=function(){if(this.open&&this._buffer.length!==0){var e=this._buffer[0];this._trySend(e)&&(this._buffer.shift(),this._bufferSize=this._buffer.length,this._tryBuffer())}},t.prototype._sendChunks=function(e){var i,r,s=F.chunk(e);O.default.log("DC#".concat(this.connectionId," Try to send ").concat(s.length," chunks..."));try{for(var a=Qa(s),o=a.next();!o.done;o=a.next()){var c=o.value;this.send(c,!0)}}catch(l){i={error:l}}finally{try{o&&!o.done&&(r=a.return)&&r.call(a)}finally{if(i)throw i.error}}},t.prototype.handleMessage=function(e){var i=e.payload;switch(e.type){case ut.Answer:this._negotiator.handleSDP(e.type,i.sdp);break;case ut.Candidate:this._negotiator.handleCandidate(i.candidate);break;default:O.default.warn("Unrecognized message type:",e.type,"from peer:",this.peer);break}},t.ID_PREFIX="dc_",t.MAX_BUFFERED_AMOUNT=8388608,t})(Qn.BaseConnection),Qo={};Wt(Qo,"API",()=>zs,n=>zs=n);var As=function(n,t,e,i){function r(s){return s instanceof e?s:new e(function(a){a(s)})}return new(e||(e=Promise))(function(s,a){function o(u){try{l(i.next(u))}catch(h){a(h)}}function c(u){try{l(i.throw(u))}catch(h){a(h)}}function l(u){u.done?s(u.value):r(u.value).then(o,c)}l((i=i.apply(n,t||[])).next())})},ks=function(n,t){var e={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},i,r,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(i)throw new TypeError("Generator is already executing.");for(;e;)try{if(i=1,r&&(s=l[0]&2?r.return:l[0]?r.throw||((s=r.return)&&s.call(r),0):r.next)&&!(s=s.call(r,l[1])).done)return s;switch(r=0,s&&(l=[l[0]&2,s.value]),l[0]){case 0:case 1:s=l;break;case 4:return e.label++,{value:l[1],done:!1};case 5:e.label++,r=l[1],l=[0];continue;case 7:l=e.ops.pop(),e.trys.pop();continue;default:if(s=e.trys,!(s=s.length>0&&s[s.length-1])&&(l[0]===6||l[0]===2)){e=0;continue}if(l[0]===3&&(!s||l[1]>s[0]&&l[1]<s[3])){e.label=l[1];break}if(l[0]===6&&e.label<s[1]){e.label=s[1],s=l;break}if(s&&e.label<s[2]){e.label=s[2],e.ops.push(l);break}s[2]&&e.ops.pop(),e.trys.pop();continue}l=t.call(n,e)}catch(u){l=[6,u],r=0}finally{i=s=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}},zs=(function(){function n(t){this._options=t}return n.prototype._buildRequest=function(t){var e=this._options.secure?"https":"http",i=this._options,r=i.host,s=i.port,a=i.path,o=i.key,c=new URL("".concat(e,"://").concat(r,":").concat(s).concat(a).concat(o,"/").concat(t));return c.searchParams.set("ts","".concat(Date.now()).concat(Math.random())),c.searchParams.set("version",Yn.version),fetch(c.href,{referrerPolicy:this._options.referrerPolicy})},n.prototype.retrieveId=function(){return As(this,void 0,Promise,function(){var t,e,i;return ks(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,this._buildRequest("id")];case 1:if(t=r.sent(),t.status!==200)throw new Error("Error. Status:".concat(t.status));return[2,t.text()];case 2:throw e=r.sent(),O.default.error("Error retrieving ID",e),i="",this._options.path==="/"&&this._options.host!==F.CLOUD_HOST&&(i=" 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."+i);case 3:return[2]}})})},n.prototype.listAllPeers=function(){return As(this,void 0,Promise,function(){var t,e,i;return ks(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,this._buildRequest("peers")];case 1:if(t=r.sent(),t.status!==200)throw t.status===401?(e="",this._options.host===F.CLOUD_HOST?e="It looks like you're using the cloud server. You can email team@peerjs.com to enable peer listing for your API key.":e="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. "+e)):new Error("Error. Status:".concat(t.status));return[2,t.json()];case 2:throw i=r.sent(),O.default.error("Error retrieving list peers",i),new Error("Could not get list peers from the server."+i);case 3:return[2]}})})},n})(),Ka=(function(){var n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,r){i.__proto__=r}||function(i,r){for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(i[s]=r[s])},n(t,e)};return function(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");n(t,e);function i(){this.constructor=t}t.prototype=e===null?Object.create(e):(i.prototype=e.prototype,new i)}})(),pi=function(){return pi=Object.assign||function(n){for(var t,e=1,i=arguments.length;e<i;e++){t=arguments[e];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])}return n},pi.apply(this,arguments)},Ke=function(n){var t=typeof Symbol=="function"&&Symbol.iterator,e=t&&n[t],i=0;if(e)return e.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},tc=function(n,t){var e=typeof Symbol=="function"&&n[Symbol.iterator];if(!e)return n;var i=e.call(n),r,s=[],a;try{for(;(t===void 0||t-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(o){a={error:o}}finally{try{r&&!r.done&&(e=i.return)&&e.call(i)}finally{if(a)throw a.error}}return s},In=(function(n){Ka(t,n);function t(e,i){var r=n.call(this)||this;r._id=null,r._lastServerId=null,r._destroyed=!1,r._disconnected=!1,r._open=!1,r._connections=new Map,r._lostMessages=new Map;var s;return e&&e.constructor==Object?i=e:e&&(s=e.toString()),i=pi({debug:0,host:F.CLOUD_HOST,port:F.CLOUD_PORT,path:"/",key:t.DEFAULT_KEY,token:F.randomToken(),config:F.defaultConfig,referrerPolicy:"strict-origin-when-cross-origin"},i),r._options=i,r._options.host==="/"&&(r._options.host=window.location.hostname),r._options.path&&(r._options.path[0]!=="/"&&(r._options.path="/"+r._options.path),r._options.path[r._options.path.length-1]!=="/"&&(r._options.path+="/")),r._options.secure===void 0&&r._options.host!==F.CLOUD_HOST?r._options.secure=F.isSecure():r._options.host==F.CLOUD_HOST&&(r._options.secure=!0),r._options.logFunction&&O.default.setLogFunction(r._options.logFunction),O.default.logLevel=r._options.debug||0,r._api=new Qo.API(i),r._socket=r._createServerConnection(),!F.supports.audioVideo&&!F.supports.data?(r._delayedAbort(Q.BrowserIncompatible,"The current browser does not support WebRTC"),r):s&&!F.validateId(s)?(r._delayedAbort(Q.InvalidID,'ID "'.concat(s,'" is invalid')),r):(s?r._initialize(s):r._api.retrieveId().then(function(a){return r._initialize(a)}).catch(function(a){return r._abort(Q.ServerError,a)}),r)}return Object.defineProperty(t.prototype,"id",{get:function(){return this._id},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"options",{get:function(){return this._options},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"open",{get:function(){return this._open},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"socket",{get:function(){return this._socket},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"connections",{get:function(){var e,i,r=Object.create(null);try{for(var s=Ke(this._connections),a=s.next();!a.done;a=s.next()){var o=tc(a.value,2),c=o[0],l=o[1];r[c]=l}}catch(u){e={error:u}}finally{try{a&&!a.done&&(i=s.return)&&i.call(s)}finally{if(e)throw e.error}}return r},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"destroyed",{get:function(){return this._destroyed},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"disconnected",{get:function(){return this._disconnected},enumerable:!1,configurable:!0}),t.prototype._createServerConnection=function(){var e=this,i=new Yo.Socket(this._options.secure,this._options.host,this._options.port,this._options.path,this._options.key,this._options.pingInterval);return i.on(ae.Message,function(r){e._handleMessage(r)}),i.on(ae.Error,function(r){e._abort(Q.SocketError,r)}),i.on(ae.Disconnected,function(){e.disconnected||(e.emitError(Q.Network,"Lost connection to server."),e.disconnect())}),i.on(ae.Close,function(){e.disconnected||e._abort(Q.SocketClosed,"Underlying socket is already closed.")}),i},t.prototype._initialize=function(e){this._id=e,this.socket.start(e,this._options.token)},t.prototype._handleMessage=function(e){var i,r,s=e.type,a=e.payload,o=e.src;switch(s){case ut.Open:this._lastServerId=this.id,this._open=!0,this.emit("open",this.id);break;case ut.Error:this._abort(Q.ServerError,a.msg);break;case ut.IdTaken:this._abort(Q.UnavailableID,'ID "'.concat(this.id,'" is taken'));break;case ut.InvalidKey:this._abort(Q.InvalidKey,'API KEY "'.concat(this._options.key,'" is invalid'));break;case ut.Leave:O.default.log("Received leave message from ".concat(o)),this._cleanupPeer(o),this._connections.delete(o);break;case ut.Expire:this.emitError(Q.PeerUnavailable,"Could not connect to peer ".concat(o));break;case ut.Offer:var y=a.connectionId,_=this.getConnection(o,y);if(_&&(_.close(),O.default.warn("Offer received for existing Connection ID:".concat(y))),a.type===Nt.Media){var c=new On.MediaConnection(o,this,{connectionId:y,_payload:a,metadata:a.metadata});_=c,this._addConnection(o,_),this.emit("call",c)}else if(a.type===Nt.Data){var l=new Bn.DataConnection(o,this,{connectionId:y,_payload:a,metadata:a.metadata,label:a.label,serialization:a.serialization,reliable:a.reliable});_=l,this._addConnection(o,_),this.emit("connection",l)}else{O.default.warn("Received malformed connection type:".concat(a.type));return}var u=this._getMessages(y);try{for(var h=Ke(u),f=h.next();!f.done;f=h.next()){var d=f.value;_.handleMessage(d)}}catch(p){i={error:p}}finally{try{f&&!f.done&&(r=h.return)&&r.call(h)}finally{if(i)throw i.error}}break;default:if(!a){O.default.warn("You received a malformed message from ".concat(o," of type ").concat(s));return}var y=a.connectionId,_=this.getConnection(o,y);_&&_.peerConnection?_.handleMessage(e):y?this._storeMessage(y,e):O.default.warn("You received an unrecognized message:",e);break}},t.prototype._storeMessage=function(e,i){this._lostMessages.has(e)||this._lostMessages.set(e,[]),this._lostMessages.get(e).push(i)},t.prototype._getMessages=function(e){var i=this._lostMessages.get(e);return i?(this._lostMessages.delete(e),i):[]},t.prototype.connect=function(e,i){if(i===void 0&&(i={}),this.disconnected){O.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(Q.Disconnected,"Cannot connect to new Peer after disconnecting from server.");return}var r=new Bn.DataConnection(e,this,i);return this._addConnection(e,r),r},t.prototype.call=function(e,i,r){if(r===void 0&&(r={}),this.disconnected){O.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(Q.Disconnected,"Cannot connect to new Peer after disconnecting from server.");return}if(!i){O.default.error("To call a peer, you must provide a stream from your browser's `getUserMedia`.");return}var s=new On.MediaConnection(e,this,pi(pi({},r),{_stream:i}));return this._addConnection(e,s),s},t.prototype._addConnection=function(e,i){O.default.log("add connection ".concat(i.type,":").concat(i.connectionId," to peerId:").concat(e)),this._connections.has(e)||this._connections.set(e,[]),this._connections.get(e).push(i)},t.prototype._removeConnection=function(e){var i=this._connections.get(e.peer);if(i){var r=i.indexOf(e);r!==-1&&i.splice(r,1)}this._lostMessages.delete(e.connectionId)},t.prototype.getConnection=function(e,i){var r,s,a=this._connections.get(e);if(!a)return null;try{for(var o=Ke(a),c=o.next();!c.done;c=o.next()){var l=c.value;if(l.connectionId===i)return l}}catch(u){r={error:u}}finally{try{c&&!c.done&&(s=o.return)&&s.call(o)}finally{if(r)throw r.error}}return null},t.prototype._delayedAbort=function(e,i){var r=this;setTimeout(function(){r._abort(e,i)},0)},t.prototype._abort=function(e,i){O.default.error("Aborting!"),this.emitError(e,i),this._lastServerId?this.disconnect():this.destroy()},t.prototype.emitError=function(e,i){O.default.error("Error:",i);var r;typeof i=="string"?r=new Error(i):r=i,r.type=e,this.emit("error",r)},t.prototype.destroy=function(){this.destroyed||(O.default.log("Destroy peer with ID:".concat(this.id)),this.disconnect(),this._cleanup(),this._destroyed=!0,this.emit("close"))},t.prototype._cleanup=function(){var e,i;try{for(var r=Ke(this._connections.keys()),s=r.next();!s.done;s=r.next()){var a=s.value;this._cleanupPeer(a),this._connections.delete(a)}}catch(o){e={error:o}}finally{try{s&&!s.done&&(i=r.return)&&i.call(r)}finally{if(e)throw e.error}}this.socket.removeAllListeners()},t.prototype._cleanupPeer=function(e){var i,r,s=this._connections.get(e);if(s)try{for(var a=Ke(s),o=a.next();!o.done;o=a.next()){var c=o.value;c.close()}}catch(l){i={error:l}}finally{try{o&&!o.done&&(r=a.return)&&r.call(a)}finally{if(i)throw i.error}}},t.prototype.disconnect=function(){if(!this.disconnected){var e=this.id;O.default.log("Disconnect peer with ID:".concat(e)),this._disconnected=!0,this._open=!1,this.socket.close(),this._lastServerId=e,this._id=null,this.emit("disconnected",e)}},t.prototype.reconnect=function(){if(this.disconnected&&!this.destroyed)O.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)O.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!"))}},t.prototype.listAllPeers=function(e){var i=this;e===void 0&&(e=function(r){}),this._api.listAllPeers().then(function(r){return e(r)}).catch(function(r){return i._abort(Q.ServerError,r)})},t.DEFAULT_KEY="peerjs",t})(Zi.EventEmitter),Ko=Wo.Peer;const ec=Object.freeze(Object.defineProperty({__proto__:null,get Peer(){return In},default:Ko,util:F},Symbol.toStringTag,{value:"Module"})),ic=/^(?:[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 rc(n){return typeof n=="string"&&ic.test(n)}const lt=[];for(let n=0;n<256;++n)lt.push((n+256).toString(16).slice(1));function nc(n,t=0){return lt[n[t+0]]+lt[n[t+1]]+lt[n[t+2]]+lt[n[t+3]]+"-"+lt[n[t+4]]+lt[n[t+5]]+"-"+lt[n[t+6]]+lt[n[t+7]]+"-"+lt[n[t+8]]+lt[n[t+9]]+"-"+lt[n[t+10]]+lt[n[t+11]]+lt[n[t+12]]+lt[n[t+13]]+lt[n[t+14]]+lt[n[t+15]]}function sc(n){if(!rc(n))throw TypeError("Invalid UUID");let t;const e=new Uint8Array(16);return e[0]=(t=parseInt(n.slice(0,8),16))>>>24,e[1]=t>>>16&255,e[2]=t>>>8&255,e[3]=t&255,e[4]=(t=parseInt(n.slice(9,13),16))>>>8,e[5]=t&255,e[6]=(t=parseInt(n.slice(14,18),16))>>>8,e[7]=t&255,e[8]=(t=parseInt(n.slice(19,23),16))>>>8,e[9]=t&255,e[10]=(t=parseInt(n.slice(24,36),16))/1099511627776&255,e[11]=t/4294967296&255,e[12]=t>>>24&255,e[13]=t>>>16&255,e[14]=t>>>8&255,e[15]=t&255,e}function oc(n){n=unescape(encodeURIComponent(n));const t=[];for(let e=0;e<n.length;++e)t.push(n.charCodeAt(e));return t}const ac="6ba7b810-9dad-11d1-80b4-00c04fd430c8",cc="6ba7b811-9dad-11d1-80b4-00c04fd430c8";function lc(n,t,e){function i(r,s,a,o){var c;if(typeof r=="string"&&(r=oc(r)),typeof s=="string"&&(s=sc(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+r.length);if(l.set(s),l.set(r,s.length),l=e(l),l[6]=l[6]&15|t,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 nc(l)}try{i.name=n}catch{}return i.DNS=ac,i.URL=cc,i}function uc(n,t,e,i){switch(n){case 0:return t&e^~t&i;case 1:return t^e^i;case 2:return t&e^t&i^e&i;case 3:return t^e^i}}function Kr(n,t){return n<<t|n>>>32-t}function hc(n){const t=[1518500249,1859775393,2400959708,3395469782],e=[1732584193,4023233417,2562383102,271733878,3285377520];if(typeof n=="string"){const a=unescape(encodeURIComponent(n));n=[];for(let o=0;o<a.length;++o)n.push(a.charCodeAt(o))}else Array.isArray(n)||(n=Array.prototype.slice.call(n));n.push(128);const i=n.length/4+2,r=Math.ceil(i/16),s=new Array(r);for(let a=0;a<r;++a){const o=new Uint32Array(16);for(let c=0;c<16;++c)o[c]=n[a*64+c*4]<<24|n[a*64+c*4+1]<<16|n[a*64+c*4+2]<<8|n[a*64+c*4+3];s[a]=o}s[r-1][14]=(n.length-1)*8/Math.pow(2,32),s[r-1][14]=Math.floor(s[r-1][14]),s[r-1][15]=(n.length-1)*8&4294967295;for(let a=0;a<r;++a){const o=new Uint32Array(80);for(let d=0;d<16;++d)o[d]=s[a][d];for(let d=16;d<80;++d)o[d]=Kr(o[d-3]^o[d-8]^o[d-14]^o[d-16],1);let c=e[0],l=e[1],u=e[2],h=e[3],f=e[4];for(let d=0;d<80;++d){const y=Math.floor(d/20),_=Kr(c,5)+uc(y,l,u,h)+f+t[y]+o[d]>>>0;f=h,h=u,u=Kr(l,30)>>>0,l=c,c=_}e[0]=e[0]+c>>>0,e[1]=e[1]+l>>>0,e[2]=e[2]+u>>>0,e[3]=e[3]+h>>>0,e[4]=e[4]+f>>>0}return[e[0]>>24&255,e[0]>>16&255,e[0]>>8&255,e[0]&255,e[1]>>24&255,e[1]>>16&255,e[1]>>8&255,e[1]&255,e[2]>>24&255,e[2]>>16&255,e[2]>>8&255,e[2]&255,e[3]>>24&255,e[3]>>16&255,e[3]>>8&255,e[3]&255,e[4]>>24&255,e[4]>>16&255,e[4]>>8&255,e[4]&255]}const fc=lc("v5",80,hc);var tn={exports:{}},en={exports:{}},Os;function dc(){return Os||(Os=1,(function(){var n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t={rotl:function(e,i){return e<<i|e>>>32-i},rotr:function(e,i){return e<<32-i|e>>>i},endian:function(e){if(e.constructor==Number)return t.rotl(e,8)&16711935|t.rotl(e,24)&4278255360;for(var i=0;i<e.length;i++)e[i]=t.endian(e[i]);return e},randomBytes:function(e){for(var i=[];e>0;e--)i.push(Math.floor(Math.random()*256));return i},bytesToWords:function(e){for(var i=[],r=0,s=0;r<e.length;r++,s+=8)i[s>>>5]|=e[r]<<24-s%32;return i},wordsToBytes:function(e){for(var i=[],r=0;r<e.length*32;r+=8)i.push(e[r>>>5]>>>24-r%32&255);return i},bytesToHex:function(e){for(var i=[],r=0;r<e.length;r++)i.push((e[r]>>>4).toString(16)),i.push((e[r]&15).toString(16));return i.join("")},hexToBytes:function(e){for(var i=[],r=0;r<e.length;r+=2)i.push(parseInt(e.substr(r,2),16));return i},bytesToBase64:function(e){for(var i=[],r=0;r<e.length;r+=3)for(var s=e[r]<<16|e[r+1]<<8|e[r+2],a=0;a<4;a++)r*8+a*6<=e.length*8?i.push(n.charAt(s>>>6*(3-a)&63)):i.push("=");return i.join("")},base64ToBytes:function(e){e=e.replace(/[^A-Z0-9+\/]/ig,"");for(var i=[],r=0,s=0;r<e.length;s=++r%4)s!=0&&i.push((n.indexOf(e.charAt(r-1))&Math.pow(2,-2*s+8)-1)<<s*2|n.indexOf(e.charAt(r))>>>6-s*2);return i}};en.exports=t})()),en.exports}var rn,Bs;function Is(){if(Bs)return rn;Bs=1;var n={utf8:{stringToBytes:function(t){return n.bin.stringToBytes(unescape(encodeURIComponent(t)))},bytesToString:function(t){return decodeURIComponent(escape(n.bin.bytesToString(t)))}},bin:{stringToBytes:function(t){for(var e=[],i=0;i<t.length;i++)e.push(t.charCodeAt(i)&255);return e},bytesToString:function(t){for(var e=[],i=0;i<t.length;i++)e.push(String.fromCharCode(t[i]));return e.join("")}}};return rn=n,rn}/*!
|
|
79
|
-
* Determine if an object is a Buffer
|
|
80
|
-
*
|
|
81
|
-
* @author Feross Aboukhadijeh <https://feross.org>
|
|
82
|
-
* @license MIT
|
|
83
|
-
*/var nn,Us;function pc(){if(Us)return nn;Us=1,nn=function(e){return e!=null&&(n(e)||t(e)||!!e._isBuffer)};function n(e){return!!e.constructor&&typeof e.constructor.isBuffer=="function"&&e.constructor.isBuffer(e)}function t(e){return typeof e.readFloatLE=="function"&&typeof e.slice=="function"&&n(e.slice(0,0))}return nn}var Ns;function mc(){return Ns||(Ns=1,(function(){var n=dc(),t=Is().utf8,e=pc(),i=Is().bin,r=function(s,a){s.constructor==String?a&&a.encoding==="binary"?s=i.stringToBytes(s):s=t.stringToBytes(s):e(s)?s=Array.prototype.slice.call(s,0):!Array.isArray(s)&&s.constructor!==Uint8Array&&(s=s.toString());for(var o=n.bytesToWords(s),c=s.length*8,l=1732584193,u=-271733879,h=-1732584194,f=271733878,d=0;d<o.length;d++)o[d]=(o[d]<<8|o[d]>>>24)&16711935|(o[d]<<24|o[d]>>>8)&4278255360;o[c>>>5]|=128<<c%32,o[(c+64>>>9<<4)+14]=c;for(var y=r._ff,_=r._gg,p=r._hh,m=r._ii,d=0;d<o.length;d+=16){var g=l,v=u,S=h,x=f;l=y(l,u,h,f,o[d+0],7,-680876936),f=y(f,l,u,h,o[d+1],12,-389564586),h=y(h,f,l,u,o[d+2],17,606105819),u=y(u,h,f,l,o[d+3],22,-1044525330),l=y(l,u,h,f,o[d+4],7,-176418897),f=y(f,l,u,h,o[d+5],12,1200080426),h=y(h,f,l,u,o[d+6],17,-1473231341),u=y(u,h,f,l,o[d+7],22,-45705983),l=y(l,u,h,f,o[d+8],7,1770035416),f=y(f,l,u,h,o[d+9],12,-1958414417),h=y(h,f,l,u,o[d+10],17,-42063),u=y(u,h,f,l,o[d+11],22,-1990404162),l=y(l,u,h,f,o[d+12],7,1804603682),f=y(f,l,u,h,o[d+13],12,-40341101),h=y(h,f,l,u,o[d+14],17,-1502002290),u=y(u,h,f,l,o[d+15],22,1236535329),l=_(l,u,h,f,o[d+1],5,-165796510),f=_(f,l,u,h,o[d+6],9,-1069501632),h=_(h,f,l,u,o[d+11],14,643717713),u=_(u,h,f,l,o[d+0],20,-373897302),l=_(l,u,h,f,o[d+5],5,-701558691),f=_(f,l,u,h,o[d+10],9,38016083),h=_(h,f,l,u,o[d+15],14,-660478335),u=_(u,h,f,l,o[d+4],20,-405537848),l=_(l,u,h,f,o[d+9],5,568446438),f=_(f,l,u,h,o[d+14],9,-1019803690),h=_(h,f,l,u,o[d+3],14,-187363961),u=_(u,h,f,l,o[d+8],20,1163531501),l=_(l,u,h,f,o[d+13],5,-1444681467),f=_(f,l,u,h,o[d+2],9,-51403784),h=_(h,f,l,u,o[d+7],14,1735328473),u=_(u,h,f,l,o[d+12],20,-1926607734),l=p(l,u,h,f,o[d+5],4,-378558),f=p(f,l,u,h,o[d+8],11,-2022574463),h=p(h,f,l,u,o[d+11],16,1839030562),u=p(u,h,f,l,o[d+14],23,-35309556),l=p(l,u,h,f,o[d+1],4,-1530992060),f=p(f,l,u,h,o[d+4],11,1272893353),h=p(h,f,l,u,o[d+7],16,-155497632),u=p(u,h,f,l,o[d+10],23,-1094730640),l=p(l,u,h,f,o[d+13],4,681279174),f=p(f,l,u,h,o[d+0],11,-358537222),h=p(h,f,l,u,o[d+3],16,-722521979),u=p(u,h,f,l,o[d+6],23,76029189),l=p(l,u,h,f,o[d+9],4,-640364487),f=p(f,l,u,h,o[d+12],11,-421815835),h=p(h,f,l,u,o[d+15],16,530742520),u=p(u,h,f,l,o[d+2],23,-995338651),l=m(l,u,h,f,o[d+0],6,-198630844),f=m(f,l,u,h,o[d+7],10,1126891415),h=m(h,f,l,u,o[d+14],15,-1416354905),u=m(u,h,f,l,o[d+5],21,-57434055),l=m(l,u,h,f,o[d+12],6,1700485571),f=m(f,l,u,h,o[d+3],10,-1894986606),h=m(h,f,l,u,o[d+10],15,-1051523),u=m(u,h,f,l,o[d+1],21,-2054922799),l=m(l,u,h,f,o[d+8],6,1873313359),f=m(f,l,u,h,o[d+15],10,-30611744),h=m(h,f,l,u,o[d+6],15,-1560198380),u=m(u,h,f,l,o[d+13],21,1309151649),l=m(l,u,h,f,o[d+4],6,-145523070),f=m(f,l,u,h,o[d+11],10,-1120210379),h=m(h,f,l,u,o[d+2],15,718787259),u=m(u,h,f,l,o[d+9],21,-343485551),l=l+g>>>0,u=u+v>>>0,h=h+S>>>0,f=f+x>>>0}return n.endian([l,u,h,f])};r._ff=function(s,a,o,c,l,u,h){var f=s+(a&o|~a&c)+(l>>>0)+h;return(f<<u|f>>>32-u)+a},r._gg=function(s,a,o,c,l,u,h){var f=s+(a&c|o&~c)+(l>>>0)+h;return(f<<u|f>>>32-u)+a},r._hh=function(s,a,o,c,l,u,h){var f=s+(a^o^c)+(l>>>0)+h;return(f<<u|f>>>32-u)+a},r._ii=function(s,a,o,c,l,u,h){var f=s+(o^(a|~c))+(l>>>0)+h;return(f<<u|f>>>32-u)+a},r._blocksize=16,r._digestsize=16,tn.exports=function(s,a){if(s==null)throw new Error("Illegal argument "+s);var o=n.wordsToBytes(r(s,a));return a&&a.asBytes?o:a&&a.asString?i.bytesToString(o):n.bytesToHex(o)}})()),tn.exports}var yc=mc();const gc=Vr(yc),ht=["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 Ds=1234567;const ta=Math.PI/180,ea=180/Math.PI;function vc(){const n=Math.random()*4294967295|0,t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,i=Math.random()*4294967295|0;return(ht[n&255]+ht[n>>8&255]+ht[n>>16&255]+ht[n>>24&255]+"-"+ht[t&255]+ht[t>>8&255]+"-"+ht[t>>16&15|64]+ht[t>>24&255]+"-"+ht[e&63|128]+ht[e>>8&255]+"-"+ht[e>>16&255]+ht[e>>24&255]+ht[i&255]+ht[i>>8&255]+ht[i>>16&255]+ht[i>>24&255]).toLowerCase()}function $t(n,t,e){return Math.max(t,Math.min(e,n))}function ia(n,t){return(n%t+t)%t}function _c(n,t,e,i,r){return i+(n-t)*(r-i)/(e-t)}function xc(n,t,e){return n!==t?(e-n)/(t-n):0}function ra(n,t,e){return(1-e)*n+e*t}function Sc(n,t,e,i){return ra(n,t,1-Math.exp(-e*i))}function bc(n,t=1){return t-Math.abs(ia(n,t*2)-t)}function Tc(n,t,e){return n<=t?0:n>=e?1:(n=(n-t)/(e-t),n*n*(3-2*n))}function Mc(n,t,e){return n<=t?0:n>=e?1:(n=(n-t)/(e-t),n*n*n*(n*(n*6-15)+10))}function Cc(n,t){return n+Math.floor(Math.random()*(t-n+1))}function Pc(n,t){return n+Math.random()*(t-n)}function wc(n){return n*(.5-Math.random())}function Ec(n){n!==void 0&&(Ds=n);let t=Ds+=1831565813;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}function Rc(n){return n*ta}function Ac(n){return n*ea}function kc(n){return(n&n-1)===0&&n!==0}function zc(n){return Math.pow(2,Math.ceil(Math.log(n)/Math.LN2))}function Oc(n){return Math.pow(2,Math.floor(Math.log(n)/Math.LN2))}function Bc(n,t,e,i,r){const s=Math.cos,a=Math.sin,o=s(e/2),c=a(e/2),l=s((t+i)/2),u=a((t+i)/2),h=s((t-i)/2),f=a((t-i)/2),d=s((i-t)/2),y=a((i-t)/2);switch(r){case"XYX":n.set(o*u,c*h,c*f,o*l);break;case"YZY":n.set(c*f,o*u,c*h,o*l);break;case"ZXZ":n.set(c*h,c*f,o*u,o*l);break;case"XZX":n.set(o*u,c*y,c*d,o*l);break;case"YXY":n.set(c*d,o*u,c*y,o*l);break;case"ZYZ":n.set(c*y,c*d,o*u,o*l);break;default:console.warn("../math.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}}function Ic(n,t){switch(t.constructor){case Float32Array:return n;case Uint32Array:return n/4294967295;case Uint16Array:return n/65535;case Uint8Array:return n/255;case Int32Array:return Math.max(n/2147483647,-1);case Int16Array:return Math.max(n/32767,-1);case Int8Array:return Math.max(n/127,-1);default:throw new Error("Invalid component type.")}}function Uc(n,t){switch(t.constructor){case Float32Array:return n;case Uint32Array:return Math.round(n*4294967295);case Uint16Array:return Math.round(n*65535);case Uint8Array:return Math.round(n*255);case Int32Array:return Math.round(n*2147483647);case Int16Array:return Math.round(n*32767);case Int8Array:return Math.round(n*127);default:throw new Error("Invalid component type.")}}const qe={DEG2RAD:ta,RAD2DEG:ea,generateUUID:vc,clamp:$t,euclideanModulo:ia,mapLinear:_c,inverseLerp:xc,lerp:ra,damp:Sc,pingpong:bc,smoothstep:Tc,smootherstep:Mc,randInt:Cc,randFloat:Pc,randFloatSpread:wc,seededRandom:Ec,degToRad:Rc,radToDeg:Ac,isPowerOfTwo:kc,ceilPowerOfTwo:zc,floorPowerOfTwo:Oc,setQuaternionFromProperEuler:Bc,normalize:Uc,denormalize:Ic};class J{constructor(t=0,e=0,i=0,r=1){this.isQuaternion=!0,this._x=t,this._y=e,this._z=i,this._w=r}static slerpFlat(t,e,i,r,s,a,o){let c=i[r+0],l=i[r+1],u=i[r+2],h=i[r+3];const f=s[a+0],d=s[a+1],y=s[a+2],_=s[a+3];if(o===0){t[e+0]=c,t[e+1]=l,t[e+2]=u,t[e+3]=h;return}if(o===1){t[e+0]=f,t[e+1]=d,t[e+2]=y,t[e+3]=_;return}if(h!==_||c!==f||l!==d||u!==y){let p=1-o;const m=c*f+l*d+u*y+h*_,g=m>=0?1:-1,v=1-m*m;if(v>Number.EPSILON){const x=Math.sqrt(v),b=Math.atan2(x,m*g);p=Math.sin(p*b)/x,o=Math.sin(o*b)/x}const S=o*g;if(c=c*p+f*S,l=l*p+d*S,u=u*p+y*S,h=h*p+_*S,p===1-o){const x=1/Math.sqrt(c*c+l*l+u*u+h*h);c*=x,l*=x,u*=x,h*=x}}t[e]=c,t[e+1]=l,t[e+2]=u,t[e+3]=h}static multiplyQuaternionsFlat(t,e,i,r,s,a){const o=i[r],c=i[r+1],l=i[r+2],u=i[r+3],h=s[a],f=s[a+1],d=s[a+2],y=s[a+3];return t[e]=o*y+u*h+c*d-l*f,t[e+1]=c*y+u*f+l*h-o*d,t[e+2]=l*y+u*d+o*f-c*h,t[e+3]=u*y-o*h-c*f-l*d,t}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get w(){return this._w}set w(t){this._w=t,this._onChangeCallback()}set(t,e,i,r){return this._x=t,this._y=e,this._z=i,this._w=r,this._onChangeCallback(),this}clone(){return new J(this._x,this._y,this._z,this._w)}copy(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this}setFromEuler(t,e=!0){const i=t._x,r=t._y,s=t._z,a=t._order,o=Math.cos,c=Math.sin,l=o(i/2),u=o(r/2),h=o(s/2),f=c(i/2),d=c(r/2),y=c(s/2);switch(a){case"XYZ":this._x=f*u*h+l*d*y,this._y=l*d*h-f*u*y,this._z=l*u*y+f*d*h,this._w=l*u*h-f*d*y;break;case"YXZ":this._x=f*u*h+l*d*y,this._y=l*d*h-f*u*y,this._z=l*u*y-f*d*h,this._w=l*u*h+f*d*y;break;case"ZXY":this._x=f*u*h-l*d*y,this._y=l*d*h+f*u*y,this._z=l*u*y+f*d*h,this._w=l*u*h-f*d*y;break;case"ZYX":this._x=f*u*h-l*d*y,this._y=l*d*h+f*u*y,this._z=l*u*y-f*d*h,this._w=l*u*h+f*d*y;break;case"YZX":this._x=f*u*h+l*d*y,this._y=l*d*h+f*u*y,this._z=l*u*y-f*d*h,this._w=l*u*h-f*d*y;break;case"XZY":this._x=f*u*h-l*d*y,this._y=l*d*h-f*u*y,this._z=l*u*y+f*d*h,this._w=l*u*h+f*d*y;break;default:console.warn("../math.Quaternion: .setFromEuler() encountered an unknown order: "+a)}return e===!0&&this._onChangeCallback(),this}setFromAxisAngle(t,e){const i=e/2,r=Math.sin(i);return this._x=t.x*r,this._y=t.y*r,this._z=t.z*r,this._w=Math.cos(i),this._onChangeCallback(),this}setFromRotationMatrix(t){const e=t.elements,i=e[0],r=e[4],s=e[8],a=e[1],o=e[5],c=e[9],l=e[2],u=e[6],h=e[10],f=i+o+h;if(f>0){const d=.5/Math.sqrt(f+1);this._w=.25/d,this._x=(u-c)*d,this._y=(s-l)*d,this._z=(a-r)*d}else if(i>o&&i>h){const d=2*Math.sqrt(1+i-o-h);this._w=(u-c)/d,this._x=.25*d,this._y=(r+a)/d,this._z=(s+l)/d}else if(o>h){const d=2*Math.sqrt(1+o-i-h);this._w=(s-l)/d,this._x=(r+a)/d,this._y=.25*d,this._z=(c+u)/d}else{const d=2*Math.sqrt(1+h-i-o);this._w=(a-r)/d,this._x=(s+l)/d,this._y=(c+u)/d,this._z=.25*d}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let i=t.dot(e)+1;return i<Number.EPSILON?(i=0,Math.abs(t.x)>Math.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=i):(this._x=0,this._y=-t.z,this._z=t.y,this._w=i)):(this._x=t.y*e.z-t.z*e.y,this._y=t.z*e.x-t.x*e.z,this._z=t.x*e.y-t.y*e.x,this._w=i),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs($t(this.dot(t),-1,1)))}rotateTowards(t,e){const i=this.angleTo(t);if(i===0)return this;const r=Math.min(1,e/i);return this.slerp(t,r),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(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._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 t=this.length();return t===0?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this._onChangeCallback(),this}multiply(t){return this.multiplyQuaternions(this,t)}premultiply(t){return this.multiplyQuaternions(t,this)}multiplyQuaternions(t,e){const i=t._x,r=t._y,s=t._z,a=t._w,o=e._x,c=e._y,l=e._z,u=e._w;return this._x=i*u+a*o+r*l-s*c,this._y=r*u+a*c+s*o-i*l,this._z=s*u+a*l+i*c-r*o,this._w=a*u-i*o-r*c-s*l,this._onChangeCallback(),this}slerp(t,e){if(e===0)return this;if(e===1)return this.copy(t);const i=this._x,r=this._y,s=this._z,a=this._w;let o=a*t._w+i*t._x+r*t._y+s*t._z;if(o<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,o=-o):this.copy(t),o>=1)return this._w=a,this._x=i,this._y=r,this._z=s,this;const c=1-o*o;if(c<=Number.EPSILON){const d=1-e;return this._w=d*a+e*this._w,this._x=d*i+e*this._x,this._y=d*r+e*this._y,this._z=d*s+e*this._z,this.normalize(),this}const l=Math.sqrt(c),u=Math.atan2(l,o),h=Math.sin((1-e)*u)/l,f=Math.sin(e*u)/l;return this._w=a*h+this._w*f,this._x=i*h+this._x*f,this._y=r*h+this._y*f,this._z=s*h+this._z*f,this._onChangeCallback(),this}slerpQuaternions(t,e,i){return this.copy(t).slerp(e,i)}random(){const t=2*Math.PI*Math.random(),e=2*Math.PI*Math.random(),i=Math.random(),r=Math.sqrt(1-i),s=Math.sqrt(i);return this.set(r*Math.sin(t),r*Math.cos(t),s*Math.sin(e),s*Math.cos(e))}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w}fromArray(t,e=0){return this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t}toJSON(){return this.toArray()}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class B{constructor(t=0,e=0,i=0){this.isVector3=!0,B.prototype.isVector3=!0,this.x=t,this.y=e,this.z=i}set(t,e,i){return i===void 0&&(i=this.z),this.x=t,this.y=e,this.z=i,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+t)}}clone(){return new B(this.x,this.y,this.z)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this}multiplyVectors(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this}applyEuler(t){return this.applyQuaternion(Fs.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(Fs.setFromAxisAngle(t,e))}applyMatrix3(t){const e=this.x,i=this.y,r=this.z,s=t.elements;return this.x=s[0]*e+s[3]*i+s[6]*r,this.y=s[1]*e+s[4]*i+s[7]*r,this.z=s[2]*e+s[5]*i+s[8]*r,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){const e=this.x,i=this.y,r=this.z,s=t.elements,a=1/(s[3]*e+s[7]*i+s[11]*r+s[15]);return this.x=(s[0]*e+s[4]*i+s[8]*r+s[12])*a,this.y=(s[1]*e+s[5]*i+s[9]*r+s[13])*a,this.z=(s[2]*e+s[6]*i+s[10]*r+s[14])*a,this}applyQuaternion(t){const e=this.x,i=this.y,r=this.z,s=t.x,a=t.y,o=t.z,c=t.w,l=2*(a*r-o*i),u=2*(o*e-s*r),h=2*(s*i-a*e);return this.x=e+c*l+a*h-o*u,this.y=i+c*u+o*l-s*h,this.z=r+c*h+s*u-a*l,this}transformDirection(t){const e=this.x,i=this.y,r=this.z,s=t.elements;return this.x=s[0]*e+s[4]*i+s[8]*r,this.y=s[1]*e+s[5]*i+s[9]*r,this.z=s[2]*e+s[6]*i+s[10]*r,this.normalize()}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this}divideScalar(t){return this.multiplyScalar(1/t)}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this.z=Math.max(t,Math.min(e,this.z)),this}clampLength(t,e){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(t,Math.min(e,i)))}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(t){return this.x*t.x+this.y*t.y+this.z*t.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(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this}lerpVectors(t,e,i){return this.x=t.x+(e.x-t.x)*i,this.y=t.y+(e.y-t.y)*i,this.z=t.z+(e.z-t.z)*i,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,e){const i=t.x,r=t.y,s=t.z,a=e.x,o=e.y,c=e.z;return this.x=r*c-s*o,this.y=s*a-i*c,this.z=i*o-r*a,this}projectOnVector(t){const e=t.lengthSq();if(e===0)return this.set(0,0,0);const i=t.dot(this)/e;return this.copy(t).multiplyScalar(i)}projectOnPlane(t){return sn.copy(this).projectOnVector(t),this.sub(sn)}reflect(t){return this.sub(sn.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;const i=this.dot(t)/e;return Math.acos($t(i,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,i=this.y-t.y,r=this.z-t.z;return e*e+i*i+r*r}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)}setFromSphericalCoords(t,e,i){const r=Math.sin(e)*t;return this.x=r*Math.sin(i),this.y=Math.cos(e)*t,this.z=r*Math.cos(i),this}setFromCylindricalCoords(t,e,i){return this.x=t*Math.sin(e),this.y=i,this.z=t*Math.cos(e),this}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this}setFromMatrixScale(t){const e=this.setFromMatrixColumn(t,0).length(),i=this.setFromMatrixColumn(t,1).length(),r=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=i,this.z=r,this}setFromMatrixColumn(t,e){return this.fromArray(t.elements,e*4)}setFromMatrix3Column(t,e){return this.fromArray(t.elements,e*3)}setFromEuler(t){return this.x=t._x,this.y=t._y,this.z=t._z,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const t=Math.random()*Math.PI*2,e=Math.random()*2-1,i=Math.sqrt(1-e*e);return this.x=i*Math.cos(t),this.y=e,this.z=i*Math.sin(t),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 sn=new B,Fs=new J,rr=2e3,Ls=2001;class Dt{constructor(t,e,i,r,s,a,o,c,l,u,h,f,d,y,_,p){this.isMatrix4=!0,Dt.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],t!==void 0&&this.set(t,e,i,r,s,a,o,c,l,u,h,f,d,y,_,p)}extractPosition(t){return console.warn("THREE.Matrix4: .extractPosition() has been renamed to .copyPosition()."),this.copyPosition(t)}multiplyToArray(t,e,i){return console.error("THREE.Matrix4: .multiplyToArray() has been removed."),this}setRotationFromQuaternion(t){return this.makeRotationFromQuaternion(t)}set(t,e,i,r,s,a,o,c,l,u,h,f,d,y,_,p){const m=this.elements;return m[0]=t,m[4]=e,m[8]=i,m[12]=r,m[1]=s,m[5]=a,m[9]=o,m[13]=c,m[2]=l,m[6]=u,m[10]=h,m[14]=f,m[3]=d,m[7]=y,m[11]=_,m[15]=p,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 Dt().fromArray(this.elements)}copy(t){const e=this.elements,i=t.elements;return e[0]=i[0],e[1]=i[1],e[2]=i[2],e[3]=i[3],e[4]=i[4],e[5]=i[5],e[6]=i[6],e[7]=i[7],e[8]=i[8],e[9]=i[9],e[10]=i[10],e[11]=i[11],e[12]=i[12],e[13]=i[13],e[14]=i[14],e[15]=i[15],this}copyPosition(t){const e=this.elements,i=t.elements;return e[12]=i[12],e[13]=i[13],e[14]=i[14],this}setFromMatrix3(t){const e=t.elements;return this.set(e[0],e[3],e[6],0,e[1],e[4],e[7],0,e[2],e[5],e[8],0,0,0,0,1),this}extractBasis(t,e,i){return t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),i.setFromMatrixColumn(this,2),this}makeBasis(t,e,i){return this.set(t.x,e.x,i.x,0,t.y,e.y,i.y,0,t.z,e.z,i.z,0,0,0,0,1),this}extractRotation(t){const e=this.elements,i=t.elements,r=1/ze.setFromMatrixColumn(t,0).length(),s=1/ze.setFromMatrixColumn(t,1).length(),a=1/ze.setFromMatrixColumn(t,2).length();return e[0]=i[0]*r,e[1]=i[1]*r,e[2]=i[2]*r,e[3]=0,e[4]=i[4]*s,e[5]=i[5]*s,e[6]=i[6]*s,e[7]=0,e[8]=i[8]*a,e[9]=i[9]*a,e[10]=i[10]*a,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromEuler(t){const e=this.elements,i=t.x,r=t.y,s=t.z,a=Math.cos(i),o=Math.sin(i),c=Math.cos(r),l=Math.sin(r),u=Math.cos(s),h=Math.sin(s);if(t.order==="XYZ"){const f=a*u,d=a*h,y=o*u,_=o*h;e[0]=c*u,e[4]=-c*h,e[8]=l,e[1]=d+y*l,e[5]=f-_*l,e[9]=-o*c,e[2]=_-f*l,e[6]=y+d*l,e[10]=a*c}else if(t.order==="YXZ"){const f=c*u,d=c*h,y=l*u,_=l*h;e[0]=f+_*o,e[4]=y*o-d,e[8]=a*l,e[1]=a*h,e[5]=a*u,e[9]=-o,e[2]=d*o-y,e[6]=_+f*o,e[10]=a*c}else if(t.order==="ZXY"){const f=c*u,d=c*h,y=l*u,_=l*h;e[0]=f-_*o,e[4]=-a*h,e[8]=y+d*o,e[1]=d+y*o,e[5]=a*u,e[9]=_-f*o,e[2]=-a*l,e[6]=o,e[10]=a*c}else if(t.order==="ZYX"){const f=a*u,d=a*h,y=o*u,_=o*h;e[0]=c*u,e[4]=y*l-d,e[8]=f*l+_,e[1]=c*h,e[5]=_*l+f,e[9]=d*l-y,e[2]=-l,e[6]=o*c,e[10]=a*c}else if(t.order==="YZX"){const f=a*c,d=a*l,y=o*c,_=o*l;e[0]=c*u,e[4]=_-f*h,e[8]=y*h+d,e[1]=h,e[5]=a*u,e[9]=-o*u,e[2]=-l*u,e[6]=d*h+y,e[10]=f-_*h}else if(t.order==="XZY"){const f=a*c,d=a*l,y=o*c,_=o*l;e[0]=c*u,e[4]=-h,e[8]=l*u,e[1]=f*h+_,e[5]=a*u,e[9]=d*h-y,e[2]=y*h-d,e[6]=o*u,e[10]=_*h+f}return e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromQuaternion(t){return this.compose(Nc,t,Dc)}lookAt(t,e,i){const r=this.elements;return Tt.subVectors(t,e),Tt.lengthSq()===0&&(Tt.z=1),Tt.normalize(),ue.crossVectors(i,Tt),ue.lengthSq()===0&&(Math.abs(i.z)===1?Tt.x+=1e-4:Tt.z+=1e-4,Tt.normalize(),ue.crossVectors(i,Tt)),ue.normalize(),nr.crossVectors(Tt,ue),r[0]=ue.x,r[4]=nr.x,r[8]=Tt.x,r[1]=ue.y,r[5]=nr.y,r[9]=Tt.y,r[2]=ue.z,r[6]=nr.z,r[10]=Tt.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const i=t.elements,r=e.elements,s=this.elements,a=i[0],o=i[4],c=i[8],l=i[12],u=i[1],h=i[5],f=i[9],d=i[13],y=i[2],_=i[6],p=i[10],m=i[14],g=i[3],v=i[7],S=i[11],x=i[15],b=r[0],T=r[4],w=r[8],C=r[12],P=r[1],R=r[5],E=r[9],A=r[13],k=r[2],z=r[6],U=r[10],L=r[14],I=r[3],X=r[7],Z=r[11],it=r[15];return s[0]=a*b+o*P+c*k+l*I,s[4]=a*T+o*R+c*z+l*X,s[8]=a*w+o*E+c*U+l*Z,s[12]=a*C+o*A+c*L+l*it,s[1]=u*b+h*P+f*k+d*I,s[5]=u*T+h*R+f*z+d*X,s[9]=u*w+h*E+f*U+d*Z,s[13]=u*C+h*A+f*L+d*it,s[2]=y*b+_*P+p*k+m*I,s[6]=y*T+_*R+p*z+m*X,s[10]=y*w+_*E+p*U+m*Z,s[14]=y*C+_*A+p*L+m*it,s[3]=g*b+v*P+S*k+x*I,s[7]=g*T+v*R+S*z+x*X,s[11]=g*w+v*E+S*U+x*Z,s[15]=g*C+v*A+S*L+x*it,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[4]*=t,e[8]*=t,e[12]*=t,e[1]*=t,e[5]*=t,e[9]*=t,e[13]*=t,e[2]*=t,e[6]*=t,e[10]*=t,e[14]*=t,e[3]*=t,e[7]*=t,e[11]*=t,e[15]*=t,this}determinant(){const t=this.elements,e=t[0],i=t[4],r=t[8],s=t[12],a=t[1],o=t[5],c=t[9],l=t[13],u=t[2],h=t[6],f=t[10],d=t[14],y=t[3],_=t[7],p=t[11],m=t[15];return y*(+s*c*h-r*l*h-s*o*f+i*l*f+r*o*d-i*c*d)+_*(+e*c*d-e*l*f+s*a*f-r*a*d+r*l*u-s*c*u)+p*(+e*l*h-e*o*d-s*a*h+i*a*d+s*o*u-i*l*u)+m*(-r*o*u-e*c*h+e*o*f+r*a*h-i*a*f+i*c*u)}transpose(){const t=this.elements;let e;return e=t[1],t[1]=t[4],t[4]=e,e=t[2],t[2]=t[8],t[8]=e,e=t[6],t[6]=t[9],t[9]=e,e=t[3],t[3]=t[12],t[12]=e,e=t[7],t[7]=t[13],t[13]=e,e=t[11],t[11]=t[14],t[14]=e,this}setPosition(t,e,i){const r=this.elements;return t.isVector3?(r[12]=t.x,r[13]=t.y,r[14]=t.z):(r[12]=t,r[13]=e,r[14]=i),this}invert(){const t=this.elements,e=t[0],i=t[1],r=t[2],s=t[3],a=t[4],o=t[5],c=t[6],l=t[7],u=t[8],h=t[9],f=t[10],d=t[11],y=t[12],_=t[13],p=t[14],m=t[15],g=h*p*l-_*f*l+_*c*d-o*p*d-h*c*m+o*f*m,v=y*f*l-u*p*l-y*c*d+a*p*d+u*c*m-a*f*m,S=u*_*l-y*h*l+y*o*d-a*_*d-u*o*m+a*h*m,x=y*h*c-u*_*c-y*o*f+a*_*f+u*o*p-a*h*p,b=e*g+i*v+r*S+s*x;if(b===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const T=1/b;return t[0]=g*T,t[1]=(_*f*s-h*p*s-_*r*d+i*p*d+h*r*m-i*f*m)*T,t[2]=(o*p*s-_*c*s+_*r*l-i*p*l-o*r*m+i*c*m)*T,t[3]=(h*c*s-o*f*s-h*r*l+i*f*l+o*r*d-i*c*d)*T,t[4]=v*T,t[5]=(u*p*s-y*f*s+y*r*d-e*p*d-u*r*m+e*f*m)*T,t[6]=(y*c*s-a*p*s-y*r*l+e*p*l+a*r*m-e*c*m)*T,t[7]=(a*f*s-u*c*s+u*r*l-e*f*l-a*r*d+e*c*d)*T,t[8]=S*T,t[9]=(y*h*s-u*_*s-y*i*d+e*_*d+u*i*m-e*h*m)*T,t[10]=(a*_*s-y*o*s+y*i*l-e*_*l-a*i*m+e*o*m)*T,t[11]=(u*o*s-a*h*s-u*i*l+e*h*l+a*i*d-e*o*d)*T,t[12]=x*T,t[13]=(u*_*r-y*h*r+y*i*f-e*_*f-u*i*p+e*h*p)*T,t[14]=(y*o*r-a*_*r-y*i*c+e*_*c+a*i*p-e*o*p)*T,t[15]=(a*h*r-u*o*r+u*i*c-e*h*c-a*i*f+e*o*f)*T,this}scale(t){const e=this.elements,i=t.x,r=t.y,s=t.z;return e[0]*=i,e[4]*=r,e[8]*=s,e[1]*=i,e[5]*=r,e[9]*=s,e[2]*=i,e[6]*=r,e[10]*=s,e[3]*=i,e[7]*=r,e[11]*=s,this}getMaxScaleOnAxis(){const t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],i=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],r=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,i,r))}makeTranslation(t,e,i){return t.isVector3?this.set(1,0,0,t.x,0,1,0,t.y,0,0,1,t.z,0,0,0,1):this.set(1,0,0,t,0,1,0,e,0,0,1,i,0,0,0,1),this}makeRotationX(t){const e=Math.cos(t),i=Math.sin(t);return this.set(1,0,0,0,0,e,-i,0,0,i,e,0,0,0,0,1),this}makeRotationY(t){const e=Math.cos(t),i=Math.sin(t);return this.set(e,0,i,0,0,1,0,0,-i,0,e,0,0,0,0,1),this}makeRotationZ(t){const e=Math.cos(t),i=Math.sin(t);return this.set(e,-i,0,0,i,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){const i=Math.cos(e),r=Math.sin(e),s=1-i,a=t.x,o=t.y,c=t.z,l=s*a,u=s*o;return this.set(l*a+i,l*o-r*c,l*c+r*o,0,l*o+r*c,u*o+i,u*c-r*a,0,l*c-r*o,u*c+r*a,s*c*c+i,0,0,0,0,1),this}makeScale(t,e,i){return this.set(t,0,0,0,0,e,0,0,0,0,i,0,0,0,0,1),this}makeShear(t,e,i,r,s,a){return this.set(1,i,s,0,t,1,a,0,e,r,1,0,0,0,0,1),this}compose(t,e,i){const r=this.elements,s=e._x,a=e._y,o=e._z,c=e._w,l=s+s,u=a+a,h=o+o,f=s*l,d=s*u,y=s*h,_=a*u,p=a*h,m=o*h,g=c*l,v=c*u,S=c*h,x=i.x,b=i.y,T=i.z;return r[0]=(1-(_+m))*x,r[1]=(d+S)*x,r[2]=(y-v)*x,r[3]=0,r[4]=(d-S)*b,r[5]=(1-(f+m))*b,r[6]=(p+g)*b,r[7]=0,r[8]=(y+v)*T,r[9]=(p-g)*T,r[10]=(1-(f+_))*T,r[11]=0,r[12]=t.x,r[13]=t.y,r[14]=t.z,r[15]=1,this}decompose(t,e,i){const r=this.elements;let s=ze.set(r[0],r[1],r[2]).length();const a=ze.set(r[4],r[5],r[6]).length(),o=ze.set(r[8],r[9],r[10]).length();this.determinant()<0&&(s=-s),t.x=r[12],t.y=r[13],t.z=r[14],It.copy(this);const l=1/s,u=1/a,h=1/o;return It.elements[0]*=l,It.elements[1]*=l,It.elements[2]*=l,It.elements[4]*=u,It.elements[5]*=u,It.elements[6]*=u,It.elements[8]*=h,It.elements[9]*=h,It.elements[10]*=h,e.setFromRotationMatrix(It),i.x=s,i.y=a,i.z=o,this}makePerspective(t,e,i,r,s,a,o=rr){const c=this.elements,l=2*s/(e-t),u=2*s/(i-r),h=(e+t)/(e-t),f=(i+r)/(i-r);let d,y;if(o===rr)d=-(a+s)/(a-s),y=-2*a*s/(a-s);else if(o===Ls)d=-a/(a-s),y=-a*s/(a-s);else throw new Error("Matrix4.makePerspective(): Invalid coordinate system: "+o);return c[0]=l,c[4]=0,c[8]=h,c[12]=0,c[1]=0,c[5]=u,c[9]=f,c[13]=0,c[2]=0,c[6]=0,c[10]=d,c[14]=y,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(t,e,i,r,s,a,o=rr){const c=this.elements,l=1/(e-t),u=1/(i-r),h=1/(a-s),f=(e+t)*l,d=(i+r)*u;let y,_;if(o===rr)y=(a+s)*h,_=-2*h;else if(o===Ls)y=s*h,_=-1*h;else throw new Error("../math.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return c[0]=2*l,c[4]=0,c[8]=0,c[12]=-f,c[1]=0,c[5]=2*u,c[9]=0,c[13]=-d,c[2]=0,c[6]=0,c[10]=_,c[14]=-y,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(t){const e=this.elements,i=t.elements;for(let r=0;r<16;r++)if(e[r]!==i[r])return!1;return!0}fromArray(t,e=0){for(let i=0;i<16;i++)this.elements[i]=t[i+e];return this}toArray(t=[],e=0){const i=this.elements;return t[e]=i[0],t[e+1]=i[1],t[e+2]=i[2],t[e+3]=i[3],t[e+4]=i[4],t[e+5]=i[5],t[e+6]=i[6],t[e+7]=i[7],t[e+8]=i[8],t[e+9]=i[9],t[e+10]=i[10],t[e+11]=i[11],t[e+12]=i[12],t[e+13]=i[13],t[e+14]=i[14],t[e+15]=i[15],t}}const ze=new B,It=new Dt,Nc=new B(0,0,0),Dc=new B(1,1,1),ue=new B,nr=new B,Tt=new B,Vs=new Dt,Js=new J;class _i{constructor(t=0,e=0,i=0,r=_i.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=e,this._z=i,this._order=r}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get order(){return this._order}set order(t){this._order=t,this._onChangeCallback()}set(t,e,i,r=this._order){return this._x=t,this._y=e,this._z=i,this._order=r,this._onChangeCallback(),this}clone(){return new _i(this._x,this._y,this._z,this._order)}copy(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this._onChangeCallback(),this}setFromRotationMatrix(t,e=this._order,i=!0){const r=t.elements,s=r[0],a=r[4],o=r[8],c=r[1],l=r[5],u=r[9],h=r[2],f=r[6],d=r[10];switch(e){case"XYZ":this._y=Math.asin($t(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-u,d),this._z=Math.atan2(-a,s)):(this._x=Math.atan2(f,l),this._z=0);break;case"YXZ":this._x=Math.asin(-$t(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(o,d),this._z=Math.atan2(c,l)):(this._y=Math.atan2(-h,s),this._z=0);break;case"ZXY":this._x=Math.asin($t(f,-1,1)),Math.abs(f)<.9999999?(this._y=Math.atan2(-h,d),this._z=Math.atan2(-a,l)):(this._y=0,this._z=Math.atan2(c,s));break;case"ZYX":this._y=Math.asin(-$t(h,-1,1)),Math.abs(h)<.9999999?(this._x=Math.atan2(f,d),this._z=Math.atan2(c,s)):(this._x=0,this._z=Math.atan2(-a,l));break;case"YZX":this._z=Math.asin($t(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-u,l),this._y=Math.atan2(-h,s)):(this._x=0,this._y=Math.atan2(o,d));break;case"XZY":this._z=Math.asin(-$t(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(f,l),this._y=Math.atan2(o,s)):(this._x=Math.atan2(-u,d),this._y=0);break;default:console.warn("../math.Euler: .setFromRotationMatrix() encountered an unknown order: "+e)}return this._order=e,i===!0&&this._onChangeCallback(),this}setFromQuaternion(t,e,i){return Vs.makeRotationFromQuaternion(t),this.setFromRotationMatrix(Vs,e,i)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return Js.setFromEuler(this),this.setFromQuaternion(Js,t)}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order}fromArray(t){return this._x=t[0],this._y=t[1],this._z=t[2],t[3]!==void 0&&(this._order=t[3]),this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._order,t}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(t){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}_i.DEFAULT_ORDER="XYZ";class Je{constructor(t=0,e=0){this.x=t,this.y=e}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}set(t,e){return this.x=t,this.y=e,this}setScalar(t){return this.x=t,this.y=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+t)}}clone(){return new Je(this.x,this.y)}copy(t){return this.x=t.x,this.y=t.y,this}add(t){return this.x+=t.x,this.y+=t.y,this}addScalar(t){return this.x+=t,this.y+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this}subScalar(t){return this.x-=t,this.y-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}multiplyScalar(t){return this.x*=t,this.y*=t,this}divide(t){return this.x/=t.x,this.y/=t.y,this}divideScalar(t){return this.multiplyScalar(1/t)}applyMatrix3(t){const e=this.x,i=this.y,r=t.elements;return this.x=r[0]*e+r[3]*i+r[6],this.y=r[1]*e+r[4]*i+r[7],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this}clampLength(t,e){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(t,Math.min(e,i)))}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(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.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(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;const i=this.dot(t)/e;return Math.acos($t(i,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,i=this.y-t.y;return e*e+i*i}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this}lerpVectors(t,e,i){return this.x=t.x+(e.x-t.x)*i,this.y=t.y+(e.y-t.y)*i,this}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t}rotateAround(t,e){const i=Math.cos(e),r=Math.sin(e),s=this.x-t.x,a=this.y-t.y;return this.x=s*i-a*r+t.x,this.y=s*r+a*i+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}Je.isVector2=!0;class bt{constructor(t=0,e=0,i=0,r=1){bt.prototype.isVector4=!0,this.x=t,this.y=e,this.z=i,this.w=r}get width(){return this.z}set width(t){this.z=t}get height(){return this.w}set height(t){this.w=t}set(t,e,i,r){return this.x=t,this.y=e,this.z=i,this.w=r,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this.w=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setW(t){return this.w=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;case 3:this.w=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){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: "+t)}}clone(){return new bt(this.x,this.y,this.z,this.w)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=t.w,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this.w=t.w+e.w,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this.w+=t.w*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this.w=t.w-e.w,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this.w*=t.w,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this}applyMatrix4(t){const e=this.x,i=this.y,r=this.z,s=this.w,a=t.elements;return this.x=a[0]*e+a[4]*i+a[8]*r+a[12]*s,this.y=a[1]*e+a[5]*i+a[9]*r+a[13]*s,this.z=a[2]*e+a[6]*i+a[10]*r+a[14]*s,this.w=a[3]*e+a[7]*i+a[11]*r+a[15]*s,this}divideScalar(t){return this.multiplyScalar(1/t)}setAxisAngleFromQuaternion(t){this.w=2*Math.acos(t.w);const e=Math.sqrt(1-t.w*t.w);return e<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=t.x/e,this.y=t.y/e,this.z=t.z/e),this}setAxisAngleFromRotationMatrix(t){let e,i,r,s;const c=t.elements,l=c[0],u=c[4],h=c[8],f=c[1],d=c[5],y=c[9],_=c[2],p=c[6],m=c[10];if(Math.abs(u-f)<.01&&Math.abs(h-_)<.01&&Math.abs(y-p)<.01){if(Math.abs(u+f)<.1&&Math.abs(h+_)<.1&&Math.abs(y+p)<.1&&Math.abs(l+d+m-3)<.1)return this.set(1,0,0,0),this;e=Math.PI;const v=(l+1)/2,S=(d+1)/2,x=(m+1)/2,b=(u+f)/4,T=(h+_)/4,w=(y+p)/4;return v>S&&v>x?v<.01?(i=0,r=.707106781,s=.707106781):(i=Math.sqrt(v),r=b/i,s=T/i):S>x?S<.01?(i=.707106781,r=0,s=.707106781):(r=Math.sqrt(S),i=b/r,s=w/r):x<.01?(i=.707106781,r=.707106781,s=0):(s=Math.sqrt(x),i=T/s,r=w/s),this.set(i,r,s,e),this}let g=Math.sqrt((p-y)*(p-y)+(h-_)*(h-_)+(f-u)*(f-u));return Math.abs(g)<.001&&(g=1),this.x=(p-y)/g,this.y=(h-_)/g,this.z=(f-u)/g,this.w=Math.acos((l+d+m-1)/2),this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this.w=Math.min(this.w,t.w),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this.w=Math.max(this.w,t.w),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this.w=Math.max(t.w,Math.min(e.w,this.w)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this.z=Math.max(t,Math.min(e,this.z)),this.w=Math.max(t,Math.min(e,this.w)),this}clampLength(t,e){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(t,Math.min(e,i)))}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(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.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(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this.w+=(t.w-this.w)*e,this}lerpVectors(t,e,i){return this.x=t.x+(e.x-t.x)*i,this.y=t.y+(e.y-t.y)*i,this.z=t.z+(e.z-t.z)*i,this.w=t.w+(e.w-t.w)*i,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z&&t.w===this.w}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this.w=t[e+3],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t[e+3]=this.w,t}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 Xt{constructor(t,e,i,r,s,a,o,c,l){Xt.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],t!==void 0&&this.set(t,e,i,r,s,a,o,c,l)}set(t,e,i,r,s,a,o,c,l){const u=this.elements;return u[0]=t,u[1]=r,u[2]=o,u[3]=e,u[4]=s,u[5]=c,u[6]=i,u[7]=a,u[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){const e=this.elements,i=t.elements;return e[0]=i[0],e[1]=i[1],e[2]=i[2],e[3]=i[3],e[4]=i[4],e[5]=i[5],e[6]=i[6],e[7]=i[7],e[8]=i[8],this}extractBasis(t,e,i){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),i.setFromMatrix3Column(this,2),this}setFromMatrix4(t){const e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const i=t.elements,r=e.elements,s=this.elements,a=i[0],o=i[3],c=i[6],l=i[1],u=i[4],h=i[7],f=i[2],d=i[5],y=i[8],_=r[0],p=r[3],m=r[6],g=r[1],v=r[4],S=r[7],x=r[2],b=r[5],T=r[8];return s[0]=a*_+o*g+c*x,s[3]=a*p+o*v+c*b,s[6]=a*m+o*S+c*T,s[1]=l*_+u*g+h*x,s[4]=l*p+u*v+h*b,s[7]=l*m+u*S+h*T,s[2]=f*_+d*g+y*x,s[5]=f*p+d*v+y*b,s[8]=f*m+d*S+y*T,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[3]*=t,e[6]*=t,e[1]*=t,e[4]*=t,e[7]*=t,e[2]*=t,e[5]*=t,e[8]*=t,this}determinant(){const t=this.elements,e=t[0],i=t[1],r=t[2],s=t[3],a=t[4],o=t[5],c=t[6],l=t[7],u=t[8];return e*a*u-e*o*l-i*s*u+i*o*c+r*s*l-r*a*c}invert(){const t=this.elements,e=t[0],i=t[1],r=t[2],s=t[3],a=t[4],o=t[5],c=t[6],l=t[7],u=t[8],h=u*a-o*l,f=o*c-u*s,d=l*s-a*c,y=e*h+i*f+r*d;if(y===0)return this.set(0,0,0,0,0,0,0,0,0);const _=1/y;return t[0]=h*_,t[1]=(r*l-u*i)*_,t[2]=(o*i-r*a)*_,t[3]=f*_,t[4]=(u*e-r*c)*_,t[5]=(r*s-o*e)*_,t[6]=d*_,t[7]=(i*c-l*e)*_,t[8]=(a*e-i*s)*_,this}transpose(){let t;const e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this}getNormalMatrix(t){return this.setFromMatrix4(t).invert().transpose()}transposeIntoArray(t){const e=this.elements;return t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8],this}setUvTransform(t,e,i,r,s,a,o){const c=Math.cos(s),l=Math.sin(s);return this.set(i*c,i*l,-i*(c*a+l*o)+a+t,-r*l,r*c,-r*(-l*a+c*o)+o+e,0,0,1),this}scale(t,e){return this.premultiply(on.makeScale(t,e)),this}rotate(t){return this.premultiply(on.makeRotation(-t)),this}translate(t,e){return this.premultiply(on.makeTranslation(t,e)),this}makeTranslation(t,e){return t.isVector2?this.set(1,0,t.x,0,1,t.y,0,0,1):this.set(1,0,t,0,1,e,0,0,1),this}makeRotation(t){const e=Math.cos(t),i=Math.sin(t);return this.set(e,-i,0,i,e,0,0,0,1),this}makeScale(t,e){return this.set(t,0,0,0,e,0,0,0,1),this}equals(t){const e=this.elements,i=t.elements;for(let r=0;r<9;r++)if(e[r]!==i[r])return!1;return!0}fromArray(t,e=0){for(let i=0;i<9;i++)this.elements[i]=t[i+e];return this}toArray(t=[],e=0){const i=this.elements;return t[e]=i[0],t[e+1]=i[1],t[e+2]=i[2],t[e+3]=i[3],t[e+4]=i[4],t[e+5]=i[5],t[e+6]=i[6],t[e+7]=i[7],t[e+8]=i[8],t}clone(){return new Xt().fromArray(this.elements)}}const on=new Xt;var yt;(function(n){n[n.Random=0]="Random",n[n.Loop=1]="Loop",n[n.PingPong=2]="PingPong",n[n.Burst=3]="Burst"})(yt||(yt={}));function Qi(n,t,e,i){let r;switch(yt.Random===n?t=Math.random():yt.Burst===n&&i.isBursting&&(t=i.burstParticleIndex/i.burstParticleCount),e>0?r=Math.floor(t/e)*e:r=t,n){case yt.Loop:r=r%1;break;case yt.PingPong:r=Math.abs(r%2-1);break}return r}class we{constructor(t,e,i,r){this.p=[t,e,i,r]}genValue(t){const e=t*t,i=t*t*t,r=1-t,s=r*r,a=s*r;return this.p[0]*a+this.p[1]*s*t*3+this.p[2]*r*e*3+this.p[3]*i}derivativeCoefficients(t){const e=[];for(let i=t,r=i.length-1;r>0;r--){const s=[];for(let a=0;a<r;a++){const o=r*(i[a+1]-i[a]);s.push(o)}e.push(s),i=s}return e}getSlope(t){const e=this.derivativeCoefficients(this.p)[0],i=1-t,r=i*i,s=i*t*2,a=t*t;return r*e[0]+s*e[1]+a*e[2]}controlCurve(t,e){this.p[1]=t/3+this.p[0],this.p[2]=this.p[3]-e/3}hull(t){let e=this.p,i=[],r,s=0,a=0,o=0;const c=[];for(c[s++]=e[0],c[s++]=e[1],c[s++]=e[2],c[s++]=e[3];e.length>1;){for(i=[],a=0,o=e.length-1;a<o;a++)r=t*e[a]+(1-t)*e[a+1],c[s++]=r,i.push(r);e=i}return c}split(t){const e=this.hull(t);return{left:new we(e[0],e[4],e[7],e[9]),right:new we(e[9],e[8],e[6],e[3]),span:e}}clone(){return new we(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(t){return new we(t.p0,t.p1,t.p2,t.p3)}}const xi=n=>({r:n.x,g:n.y,b:n.z,a:n.w}),Si=n=>new bt(n.r,n.g,n.b,n.a),Fc=(n,t)=>{switch(t){case"Vector3":return new B(n.x,n.y,n.z);case"Vector4":return new bt(n.x,n.y,n.z,n.w);case"Color":return new B(n.r,n.g,n.b);case"Number":return n;default:return n}},Lc=(n,t)=>{switch(t){case"Vector3":return{x:n.x,y:n.y,z:n.z};case"Vector4":return{x:n.x,y:n.y,z:n.z,w:n.w};case"Color":return{r:n.x,g:n.y,b:n.z};case"Number":return n;default:return n}};class Or{constructor(t,e){this.a=t,this.b=e,this.type="value"}startGen(t){}genColor(t,e){const i=Math.random();return e.copy(this.a).lerp(this.b,i)}toJSON(){return{type:"RandomColor",a:xi(this.a),b:xi(this.b)}}static fromJSON(t){return new Or(Si(t.a),Si(t.b))}clone(){return new Or(this.a.clone(),this.b.clone())}}class Ge{constructor(t,e){this.a=t,this.b=e,this.indexCount=-1,this.type="value"}startGen(t){this.indexCount=t.length,t.push(Math.random())}genColor(t,e){return this.indexCount===-1&&this.startGen(t),e.copy(this.a).lerp(this.b,t[this.indexCount])}toJSON(){return{type:"ColorRange",a:xi(this.a),b:xi(this.b)}}static fromJSON(t){return new Ge(Si(t.a),Si(t.b))}clone(){return new Ge(this.a.clone(),this.b.clone())}}class me{constructor(t,e){this.subType=e,this.type="function",this.keys=t}findKey(t){let e=0,i=0,r=this.keys.length-1;for(;i+1<r;)if(e=Math.floor((i+r)/2),t<this.getStartX(e))r=e-1;else if(t>this.getEndX(e))i=e+1;else return e;for(let s=i;s<=r;s++)if(t>=this.getStartX(s)&&t<=this.getEndX(s))return s;return-1}getStartX(t){return this.keys[t][1]}getEndX(t){return t+1<this.keys.length?this.keys[t+1][1]:1}genValue(t,e){const i=this.findKey(e);return this.subType==="Number"?i===-1?this.keys[0][0]:i+1>=this.keys.length?this.keys[this.keys.length-1][0]:(this.keys[i+1][0]-this.keys[i][0])*((e-this.getStartX(i))/(this.getEndX(i)-this.getStartX(i)))+this.keys[i][0]:i===-1?t.copy(this.keys[0][0]):i+1>=this.keys.length?t.copy(this.keys[this.keys.length-1][0]):t.copy(this.keys[i][0]).lerp(this.keys[i+1][0],(e-this.getStartX(i))/(this.getEndX(i)-this.getStartX(i)))}toJSON(){return this.keys[0][0].constructor.name,{type:"CLinearFunction",subType:this.subType,keys:this.keys.map(([t,e])=>({value:Lc(t,this.subType),pos:e}))}}static fromJSON(t){return new me(t.keys.map(e=>[Fc(e.value,t.subType),e.pos]),t.subType)}clone(){return this.subType==="Number"?new me(this.keys.map(([t,e])=>[t,e]),this.subType):new me(this.keys.map(([t,e])=>[t.clone(),e]),this.subType)}}const sr=new B;class Ee{constructor(t=[[new B(0,0,0),0],[new B(1,1,1),0]],e=[[1,0],[1,1]]){this.type="function",this.color=new me(t,"Color"),this.alpha=new me(e,"Number")}genColor(t,e,i){return this.color.genValue(sr,i),e.set(sr.x,sr.y,sr.z,this.alpha.genValue(1,i))}toJSON(){return{type:"Gradient",color:this.color.toJSON(),alpha:this.alpha.toJSON()}}static fromJSON(t){if(t.functions){const e=t.functions.map(i=>[Ge.fromJSON(i.function).a,i.start]);return t.functions.length>0&&e.push([Ge.fromJSON(t.functions[t.functions.length-1].function).b,1]),new Ee(e.map(i=>[new B(i[0].x,i[0].y,i[0].z),i[1]]),e.map(i=>[i[0].w,i[1]]))}else{const e=new Ee;return e.alpha=me.fromJSON(t.alpha),e.color=me.fromJSON(t.color),e}}clone(){const t=new Ee;return t.alpha=this.alpha.clone(),t.color=this.color.clone(),t}startGen(t){}}const an=new bt;class Br{constructor(t,e){this.indexCount=0,this.type="function",this.gradient1=t,this.gradient2=e}startGen(t){this.indexCount=t.length,t.push(Math.random())}genColor(t,e,i){return this.gradient1.genColor(t,e,i),this.gradient2.genColor(t,an,i),t&&t[this.indexCount]!==void 0?e.lerp(an,t[this.indexCount]):e.lerp(an,Math.random()),e}toJSON(){return{type:"RandomColorBetweenGradient",gradient1:this.gradient1.toJSON(),gradient2:this.gradient2.toJSON()}}static fromJSON(t){return new Br(Ee.fromJSON(t.gradient1),Ee.fromJSON(t.gradient2))}clone(){return new Br(this.gradient1.clone(),this.gradient2.clone())}}class Re{constructor(t){this.color=t,this.type="value"}startGen(t){}genColor(t,e){return e.copy(this.color)}toJSON(){return{type:"ConstantColor",color:xi(this.color)}}static fromJSON(t){return new Re(Si(t.color))}clone(){return new Re(this.color.clone())}}function Kn(n){switch(n.type){case"ConstantColor":return Re.fromJSON(n);case"ColorRange":return Ge.fromJSON(n);case"RandomColor":return Or.fromJSON(n);case"Gradient":return Ee.fromJSON(n);case"RandomColorBetweenGradient":return Br.fromJSON(n);default:return new Re(new bt(1,1,1,1))}}class D{constructor(t){this.value=t,this.type="value"}startGen(t){}genValue(t){return this.value}toJSON(){return{type:"ConstantValue",value:this.value}}static fromJSON(t){return new D(t.value)}clone(){return new D(this.value)}}class Ae{constructor(t,e){this.a=t,this.b=e,this.indexCount=-1,this.type="value"}startGen(t){this.indexCount=t.length,t.push(Math.random())}genValue(t){return this.indexCount===-1&&this.startGen(t),qe.lerp(this.a,this.b,t[this.indexCount])}toJSON(){return{type:"IntervalValue",a:this.a,b:this.b}}static fromJSON(t){return new Ae(t.a,t.b)}clone(){return new Ae(this.a,this.b)}}class Vc{constructor(){this.functions=new Array}findFunction(t){let e=0,i=0,r=this.functions.length-1;for(;i+1<r;)if(e=Math.floor((i+r)/2),t<this.getStartX(e))r=e-1;else if(t>this.getEndX(e))i=e+1;else return e;for(let s=i;s<=r;s++)if(t>=this.functions[s][1]&&t<=this.getEndX(s))return s;return-1}getStartX(t){return this.functions[t][1]}setStartX(t,e){t>0&&(this.functions[t][1]=e)}getEndX(t){return t+1<this.functions.length?this.functions[t+1][1]:1}setEndX(t,e){t+1<this.functions.length&&(this.functions[t+1][1]=e)}insertFunction(t,e){const i=this.findFunction(t);this.functions.splice(i+1,0,[e,t])}removeFunction(t){return this.functions.splice(t,1)[0][0]}getFunction(t){return this.functions[t][0]}setFunction(t,e){this.functions[t][0]=e}get numOfFunctions(){return this.functions.length}}class bi extends Vc{constructor(t=[[new we(0,1/3,1/3*2,1),0]]){super(),this.type="function",this.functions=t}genValue(t,e=0){const i=this.findFunction(e);return i===-1?0:this.functions[i][0].genValue((e-this.getStartX(i))/(this.getEndX(i)-this.getStartX(i)))}toSVG(t,e){if(e<1)return"";let i=["M",0,this.functions[0][0].p[0]].join(" ");for(let r=1/e;r<=1;r+=1/e)i=[i,"L",r*t,this.genValue(void 0,r)].join(" ");return i}toJSON(){return{type:"PiecewiseBezier",functions:this.functions.map(([t,e])=>({function:t.toJSON(),start:e}))}}static fromJSON(t){return new bi(t.functions.map(e=>[we.fromJSON(e.function),e.start]))}clone(){return new bi(this.functions.map(([t,e])=>[t.clone(),e]))}startGen(t){}}function N(n){switch(n.type){case"ConstantValue":return D.fromJSON(n);case"IntervalValue":return Ae.fromJSON(n);case"PiecewiseBezier":return bi.fromJSON(n);default:return new D(0)}}class Ti{constructor(){this.indexCount=0,this.type="rotation"}startGen(t){this.indexCount=t.length,t.push(new J);let e,i,r,s,a,o;do e=Math.random()*2-1,i=Math.random()*2-1,r=e*e+i*i;while(r>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-r)/o);t[this.indexCount].set(e,i,c*s,c*a)}genValue(t,e,i,r){return this.indexCount===-1&&this.startGen(t),e.copy(t[this.indexCount]),e}toJSON(){return{type:"RandomQuat"}}static fromJSON(t){return new Ti}clone(){return new Ti}}class Mi{constructor(t,e){this.axis=t,this.angle=e,this.type="rotation"}startGen(t){this.angle.startGen(t)}genValue(t,e,i,r){return e.setFromAxisAngle(this.axis,this.angle.genValue(t,r)*i)}toJSON(){return{type:"AxisAngle",axis:{x:this.axis.x,y:this.axis.y,z:this.axis.z},angle:this.angle.toJSON()}}static fromJSON(t){return new Mi(new B(t.axis.x,t.axis.y,t.axis.z),N(t.angle))}clone(){return new Mi(this.axis.clone(),this.angle.clone())}}class Ir{constructor(t,e,i,r){this.angleX=t,this.angleY=e,this.angleZ=i,this.type="rotation",this.eular=new _i(0,0,0,r)}startGen(t){this.angleX.startGen(t),this.angleY.startGen(t),this.angleZ.startGen(t)}genValue(t,e,i,r){return this.eular.set(this.angleX.genValue(t,r)*i,this.angleY.genValue(t,r)*i,this.angleZ.genValue(t,r)*i),e.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(t){return new Ir(N(t.angleX),N(t.angleY),N(t.angleZ),t.eulerOrder)}clone(){return new Ir(this.angleX,this.angleY,this.angleZ,this.eular.order)}}function na(n){switch(n.type){case"AxisAngle":return Mi.fromJSON(n);case"Euler":return Ir.fromJSON(n);case"RandomQuat":return Ti.fromJSON(n);default:return new Ti}}class ke{constructor(t,e,i){this.x=t,this.y=e,this.z=i,this.type="vec3function"}startGen(t){this.x.startGen(t),this.y.startGen(t),this.z.startGen(t)}genValue(t,e,i){return e.set(this.x.genValue(t,i),this.y.genValue(t,i),this.z.genValue(t,i))}toJSON(){return{type:"Vector3Function",x:this.x.toJSON(),y:this.y.toJSON(),z:this.z.toJSON()}}static fromJSON(t){return new ke(N(t.x),N(t.y),N(t.z))}clone(){return new ke(this.x,this.y,this.z)}}function Jc(n){switch(n.type){case"Vector3Function":return ke.fromJSON(n);default:return new ke(new D(0),new D(0),new D(0))}}function Ur(n){switch(n.type){case"ConstantValue":case"IntervalValue":case"PiecewiseBezier":return N(n);case"AxisAngle":case"RandomQuat":case"Euler":return na(n);case"Vector3Function":return Jc(n);default:return new D(0)}}class Ci{constructor(t={}){var e,i,r,s,a,o,c;this.type="cone",this.currentValue=0,this.radius=(e=t.radius)!==null&&e!==void 0?e:10,this.arc=(i=t.arc)!==null&&i!==void 0?i:2*Math.PI,this.thickness=(r=t.thickness)!==null&&r!==void 0?r:1,this.angle=(s=t.angle)!==null&&s!==void 0?s:Math.PI/6,this.mode=(a=t.mode)!==null&&a!==void 0?a:yt.Random,this.spread=(o=t.spread)!==null&&o!==void 0?o:0,this.speed=(c=t.speed)!==null&&c!==void 0?c:new D(1),this.memory=[]}update(t,e){yt.Random!=this.mode&&(this.currentValue+=this.speed.genValue(this.memory,t.emissionState.time/t.duration)*e)}initialize(t,e){const i=Qi(this.mode,this.currentValue,this.spread,e),r=qe.lerp(1-this.thickness,1,Math.random()),s=i*this.arc,a=Math.sqrt(r),o=Math.sin(s),c=Math.cos(s);t.position.x=a*c,t.position.y=a*o,t.position.z=0;const l=this.angle*a;t.velocity.set(0,0,Math.cos(l)).addScaledVector(t.position,Math.sin(l)).multiplyScalar(t.startSpeed),t.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(t){return new Ci({radius:t.radius,arc:t.arc,thickness:t.thickness,angle:t.angle,mode:t.mode,speed:t.speed?N(t.speed):void 0,spread:t.spread})}clone(){return new Ci({radius:this.radius,arc:this.arc,thickness:this.thickness,angle:this.angle,mode:this.mode,speed:this.speed.clone(),spread:this.spread})}}class Pi{constructor(t={}){var e,i,r,s,a,o;this.type="circle",this.currentValue=0,this.radius=(e=t.radius)!==null&&e!==void 0?e:10,this.arc=(i=t.arc)!==null&&i!==void 0?i:2*Math.PI,this.thickness=(r=t.thickness)!==null&&r!==void 0?r:1,this.mode=(s=t.mode)!==null&&s!==void 0?s:yt.Random,this.spread=(a=t.spread)!==null&&a!==void 0?a:0,this.speed=(o=t.speed)!==null&&o!==void 0?o:new D(1),this.memory=[]}update(t,e){this.currentValue+=this.speed.genValue(this.memory,t.emissionState.time/t.duration)*e}initialize(t,e){const i=Qi(this.mode,this.currentValue,this.spread,e),r=qe.lerp(1-this.thickness,1,Math.random()),s=i*this.arc;t.position.x=Math.cos(s),t.position.y=Math.sin(s),t.position.z=0,t.velocity.copy(t.position).multiplyScalar(t.startSpeed),t.position.multiplyScalar(this.radius*r)}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(t){return new Pi({radius:t.radius,arc:t.arc,thickness:t.thickness,mode:t.mode,speed:t.speed?N(t.speed):void 0,spread:t.spread})}clone(){return new Pi({radius:this.radius,arc:this.arc,thickness:this.thickness,mode:this.mode,speed:this.speed.clone(),spread:this.spread})}}function or(n,t){return Math.floor(Math.random()*(t-n))+n}const Gr=new B(0,1,0),jr=new B(0,0,0),Gc=new B(1,1,1),Gs=new B(0,0,1);class wi{constructor(t={}){var e,i,r,s,a,o,c;this.type="donut",this.currentValue=0,this.radius=(e=t.radius)!==null&&e!==void 0?e:10,this.arc=(i=t.arc)!==null&&i!==void 0?i:2*Math.PI,this.thickness=(r=t.thickness)!==null&&r!==void 0?r:1,this.donutRadius=(s=t.donutRadius)!==null&&s!==void 0?s:this.radius*.2,this.mode=(a=t.mode)!==null&&a!==void 0?a:yt.Random,this.spread=(o=t.spread)!==null&&o!==void 0?o:0,this.speed=(c=t.speed)!==null&&c!==void 0?c:new D(1),this.memory=[],this._m1=new Dt}update(t,e){yt.Random!=this.mode&&(this.currentValue+=this.speed.genValue(this.memory,t.emissionState.time/t.duration)*e)}initialize(t,e){const i=Qi(this.mode,this.currentValue,this.spread,e),r=Math.random(),s=qe.lerp(1-this.thickness,1,Math.random()),a=i*this.arc,o=r*Math.PI*2,c=Math.sin(a),l=Math.cos(a);t.position.x=this.radius*l,t.position.y=this.radius*c,t.position.z=0,t.velocity.z=this.donutRadius*s*Math.sin(o),t.velocity.x=this.donutRadius*s*Math.cos(o)*l,t.velocity.y=this.donutRadius*s*Math.cos(o)*c,t.position.add(t.velocity),t.velocity.normalize().multiplyScalar(t.startSpeed),t.rotation instanceof J&&(this._m1.lookAt(jr,t.velocity,Gr),t.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(t){return new wi({radius:t.radius,arc:t.arc,thickness:t.thickness,donutRadius:t.donutRadius,mode:t.mode,speed:t.speed?N(t.speed):void 0,spread:t.spread})}clone(){return new wi({radius:this.radius,arc:this.arc,thickness:this.thickness,donutRadius:this.donutRadius,mode:this.mode,speed:this.speed.clone(),spread:this.spread})}}class Ei{constructor(){this.type="point",this._m1=new Dt}update(t,e){}initialize(t){const e=Math.random(),i=Math.random(),r=e*Math.PI*2,s=Math.acos(2*i-1),a=Math.cbrt(Math.random()),o=Math.sin(r),c=Math.cos(r),l=Math.sin(s),u=Math.cos(s);t.velocity.x=a*l*c,t.velocity.y=a*l*o,t.velocity.z=a*u,t.velocity.multiplyScalar(t.startSpeed),t.position.setScalar(0),t.rotation instanceof J&&(this._m1.lookAt(jr,t.position,Gr),t.rotation.setFromRotationMatrix(this._m1))}toJSON(){return{type:"point"}}static fromJSON(t){return new Ei}clone(){return new Ei}}class je{constructor(t={}){var e,i,r,s,a,o;this.type="sphere",this.currentValue=0,this.radius=(e=t.radius)!==null&&e!==void 0?e:10,this.arc=(i=t.arc)!==null&&i!==void 0?i:2*Math.PI,this.thickness=(r=t.thickness)!==null&&r!==void 0?r:1,this.mode=(s=t.mode)!==null&&s!==void 0?s:yt.Random,this.spread=(a=t.spread)!==null&&a!==void 0?a:0,this.speed=(o=t.speed)!==null&&o!==void 0?o:new D(1),this.memory=[],this._m1=new Dt}update(t,e){yt.Random!=this.mode&&(this.currentValue+=this.speed.genValue(this.memory,t.emissionState.time/t.duration)*e)}initialize(t,e){const i=Qi(this.mode,this.currentValue,this.spread,e),r=Math.random(),s=qe.lerp(1-this.thickness,1,Math.random()),a=i*this.arc,o=Math.acos(2*r-1),c=Math.sin(a),l=Math.cos(a),u=Math.sin(o),h=Math.cos(o);t.position.x=u*l,t.position.y=u*c,t.position.z=h,t.velocity.copy(t.position).multiplyScalar(t.startSpeed),t.position.multiplyScalar(this.radius*s),t.rotation instanceof J&&(this._m1.lookAt(jr,t.position,Gr),t.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(t){return new je({radius:t.radius,arc:t.arc,thickness:t.thickness,mode:t.mode,speed:t.speed?N(t.speed):void 0,spread:t.spread})}clone(){return new je({radius:this.radius,arc:this.arc,thickness:this.thickness,mode:this.mode,speed:this.speed.clone(),spread:this.spread})}}class Ri{constructor(t={}){var e,i,r,s,a,o;this.type="sphere",this.currentValue=0,this.radius=(e=t.radius)!==null&&e!==void 0?e:10,this.arc=(i=t.arc)!==null&&i!==void 0?i:2*Math.PI,this.thickness=(r=t.thickness)!==null&&r!==void 0?r:1,this.mode=(s=t.mode)!==null&&s!==void 0?s:yt.Random,this.spread=(a=t.spread)!==null&&a!==void 0?a:0,this.speed=(o=t.speed)!==null&&o!==void 0?o:new D(1),this.memory=[],this._m1=new Dt}update(t,e){yt.Random!=this.mode&&(this.currentValue+=this.speed.genValue(this.memory,t.emissionState.time/t.duration)*e)}initialize(t,e){const i=Qi(this.mode,this.currentValue,this.spread,e),r=Math.random(),s=qe.lerp(1-this.thickness,1,Math.random()),a=i*this.arc,o=Math.acos(r),c=Math.sin(a),l=Math.cos(a),u=Math.sin(o),h=Math.cos(o);t.position.x=u*l,t.position.y=u*c,t.position.z=h,t.velocity.copy(t.position).multiplyScalar(t.startSpeed),t.position.multiplyScalar(this.radius*s),t.rotation instanceof J&&(this._m1.lookAt(jr,t.position,Gr),t.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(t){return new Ri({radius:t.radius,arc:t.arc,thickness:t.thickness,mode:t.mode,speed:t.speed?N(t.speed):void 0,spread:t.spread})}clone(){return new Ri({radius:this.radius,arc:this.arc,thickness:this.thickness,mode:this.mode,speed:this.speed.clone(),spread:this.spread})}}class Ai{constructor(t={}){var e,i,r,s;this.type="grid",this.width=(e=t.width)!==null&&e!==void 0?e:1,this.height=(i=t.height)!==null&&i!==void 0?i:1,this.column=(r=t.column)!==null&&r!==void 0?r:10,this.row=(s=t.row)!==null&&s!==void 0?s:10}initialize(t){const e=Math.floor(Math.random()*this.row),i=Math.floor(Math.random()*this.column);t.position.x=i*this.width/this.column-this.width/2,t.position.y=e*this.height/this.row-this.height/2,t.position.z=0,t.velocity.set(0,0,t.startSpeed)}toJSON(){return{type:"grid",width:this.width,height:this.height,column:this.column,row:this.row}}static fromJSON(t){return new Ai(t)}clone(){return new Ai({width:this.width,height:this.height,column:this.column,row:this.row})}update(t,e){}}const Un={circle:{type:"circle",params:[["radius",["number"]],["arc",["radian"]],["thickness",["number"]],["mode",["emitterMode"]],["spread",["number"]],["speed",["valueFunc"]]],constructor:Pi,loadJSON:Pi.fromJSON},cone:{type:"cone",params:[["radius",["number"]],["arc",["radian"]],["thickness",["number"]],["angle",["radian"]],["mode",["emitterMode"]],["spread",["number"]],["speed",["valueFunc"]]],constructor:Ci,loadJSON:Ci.fromJSON},donut:{type:"donut",params:[["radius",["number"]],["arc",["radian"]],["thickness",["number"]],["donutRadius",["number"]],["mode",["emitterMode"]],["spread",["number"]],["speed",["valueFunc"]]],constructor:wi,loadJSON:wi.fromJSON},point:{type:"point",params:[],constructor:Ei,loadJSON:Ei.fromJSON},sphere:{type:"sphere",params:[["radius",["number"]],["arc",["radian"]],["thickness",["number"]],["angle",["radian"]],["mode",["emitterMode"]],["spread",["number"]],["speed",["valueFunc"]]],constructor:je,loadJSON:je.fromJSON},hemisphere:{type:"hemisphere",params:[["radius",["number"]],["arc",["radian"]],["thickness",["number"]],["angle",["radian"]],["mode",["emitterMode"]],["spread",["number"]],["speed",["valueFunc"]]],constructor:Ri,loadJSON:Ri.fromJSON},grid:{type:"grid",params:[["width",["number"]],["height",["number"]],["rows",["number"]],["column",["number"]]],constructor:Ai,loadJSON:Ai.fromJSON}};function jc(n,t){return Un[n.type].loadJSON(n,t)}class ki{constructor(t){this.color=t,this.type="ColorOverLife"}initialize(t){this.color.startGen(t.memory)}update(t,e){this.color.genColor(t.memory,t.color,t.age/t.life),t.color.x*=t.startColor.x,t.color.y*=t.startColor.y,t.color.z*=t.startColor.z,t.color.w*=t.startColor.w}frameUpdate(t){}toJSON(){return{type:this.type,color:this.color.toJSON()}}static fromJSON(t){return new ki(Kn(t.color))}clone(){return new ki(this.color.clone())}reset(){}}class zi{constructor(t){this.angularVelocity=t,this.type="RotationOverLife"}initialize(t){typeof t.rotation=="number"&&this.angularVelocity.startGen(t.memory)}update(t,e){typeof t.rotation=="number"&&(t.rotation+=e*this.angularVelocity.genValue(t.memory,t.age/t.life))}toJSON(){return{type:this.type,angularVelocity:this.angularVelocity.toJSON()}}static fromJSON(t){return new zi(N(t.angularVelocity))}frameUpdate(t){}clone(){return new zi(this.angularVelocity.clone())}reset(){}}class Oi{constructor(t){this.angularVelocity=t,this.type="Rotation3DOverLife",this.tempQuat=new J,this.tempQuat2=new J}initialize(t){t.rotation instanceof J&&(t.angularVelocity=new J,this.angularVelocity.startGen(t.memory))}update(t,e){t.rotation instanceof J&&(this.angularVelocity.genValue(t.memory,this.tempQuat,e,t.age/t.life),t.rotation.multiply(this.tempQuat))}toJSON(){return{type:this.type,angularVelocity:this.angularVelocity.toJSON()}}static fromJSON(t){return new Oi(na(t.angularVelocity))}frameUpdate(t){}clone(){return new Oi(this.angularVelocity.clone())}reset(){}}class Bi{initialize(t,e){this.ps=e,this.x.startGen(t.memory),this.y.startGen(t.memory),this.z.startGen(t.memory)}constructor(t,e,i){this.x=t,this.y=e,this.z=i,this.type="ForceOverLife",this._temp=new B,this._tempScale=new B,this._tempQ=new J}update(t,e){this._temp.set(this.x.genValue(t.memory,t.age/t.life),this.y.genValue(t.memory,t.age/t.life),this.z.genValue(t.memory,t.age/t.life)),this.ps.worldSpace?t.velocity.addScaledVector(this._temp,e):(this._temp.multiply(this._tempScale).applyQuaternion(this._tempQ),t.velocity.addScaledVector(this._temp,e))}toJSON(){return{type:this.type,x:this.x.toJSON(),y:this.y.toJSON(),z:this.z.toJSON()}}static fromJSON(t){return new Bi(N(t.x),N(t.y),N(t.z))}frameUpdate(t){if(this.ps&&!this.ps.worldSpace){const e=this._temp,i=this._tempQ,r=this._tempScale;this.ps.emitter.matrixWorld.decompose(e,i,r),i.invert(),r.set(1/r.x,1/r.y,1/r.z)}}clone(){return new Bi(this.x.clone(),this.y.clone(),this.z.clone())}reset(){}}class Ii{initialize(t){this.size.startGen(t.memory)}constructor(t){this.size=t,this.type="SizeOverLife"}update(t){this.size instanceof ke?this.size.genValue(t.memory,t.size,t.age/t.life).multiply(t.startSize):t.size.copy(t.startSize).multiplyScalar(this.size.genValue(t.memory,t.age/t.life))}toJSON(){return{type:this.type,size:this.size.toJSON()}}static fromJSON(t){return new Ii(Ur(t.size))}frameUpdate(t){}clone(){return new Ii(this.size.clone())}reset(){}}class Ui{initialize(t){this.speed.startGen(t.memory)}constructor(t){this.speed=t,this.type="SpeedOverLife"}update(t){t.speedModifier=this.speed.genValue(t.memory,t.age/t.life)}toJSON(){return{type:this.type,speed:this.speed.toJSON()}}static fromJSON(t){return new Ui(N(t.speed))}frameUpdate(t){}clone(){return new Ui(this.speed.clone())}reset(){}}class Ni{constructor(t){this.frame=t,this.type="FrameOverLife"}initialize(t){this.frame.startGen(t.memory)}update(t,e){this.frame instanceof bi&&(t.uvTile=this.frame.genValue(t.memory,t.age/t.life))}frameUpdate(t){}toJSON(){return{type:this.type,frame:this.frame.toJSON()}}static fromJSON(t){return new Ni(N(t.frame))}clone(){return new Ni(this.frame.clone())}reset(){}}class Di{constructor(t,e=new B(0,1,0)){this.orbitSpeed=t,this.axis=e,this.type="OrbitOverLife",this.temp=new B,this.rotation=new J}initialize(t){this.orbitSpeed.startGen(t.memory)}update(t,e){this.temp.copy(t.position).projectOnVector(this.axis),this.rotation.setFromAxisAngle(this.axis,this.orbitSpeed.genValue(t.memory,t.age/t.life)*e),t.position.sub(this.temp),t.position.applyQuaternion(this.rotation),t.position.add(this.temp)}frameUpdate(t){}toJSON(){return{type:this.type,orbitSpeed:this.orbitSpeed.toJSON(),axis:[this.axis.x,this.axis.y,this.axis.z]}}static fromJSON(t){return new Di(N(t.orbitSpeed),t.axis?new B(t.axis[0],t.axis[1],t.axis[2]):void 0)}clone(){return new Di(this.orbitSpeed.clone())}reset(){}}class cn{constructor(t){this.data=t,this.next=null,this.prev=null}hasPrev(){return this.prev!==null}hasNext(){return this.next!==null}}class $c{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 t=this.head.data;return this.head=this.head.next,this.head?this.head.prev=null:this.tail=null,this.length--,t}}pop(){if(this.tail){const t=this.tail.data;return this.tail=this.tail.prev,this.tail?this.tail.next=null:this.head=null,this.length--,t}}queue(t){const e=new cn(t);this.tail||(this.tail=e),this.head&&(this.head.prev=e,e.next=this.head),this.head=e,this.length++}push(t){const e=new cn(t);this.head||(this.head=e),this.tail&&(this.tail.next=e,e.prev=this.tail),this.tail=e,this.length++}insertBefore(t,e){const i=new cn(e);i.next=t,i.prev=t.prev,i.prev!==null&&(i.prev.next=i),i.next.prev=i,t==this.head&&(this.head=i),this.length++}remove(t){if(this.head===null||this.tail===null)return;let e=this.head;for(t===this.head.data&&(this.head=this.head.next),t===this.tail.data&&(this.tail=this.tail.prev);e.next!==null&&e.data!==t;)e=e.next;e.data===t&&(e.prev!==null&&(e.prev.next=e.next),e.next!==null&&(e.next.prev=e.prev),this.length--)}*values(){let t=this.head;for(;t!==null;)yield t.data,t=t.next}}class qc{constructor(){this.startSpeed=0,this.startColor=new bt,this.startSize=new B(1,1,1),this.position=new B,this.velocity=new B,this.age=0,this.life=1,this.size=new B(1,1,1),this.speedModifier=1,this.rotation=0,this.color=new bt,this.uvTile=0,this.memory=[]}get died(){return this.age>=this.life}reset(){this.memory.length=0}}class Xc{constructor(t,e,i){this.position=t,this.size=e,this.color=i}}class Nr{constructor(){this.startSpeed=0,this.startColor=new bt,this.startSize=new B(1,1,1),this.position=new B,this.velocity=new B,this.age=0,this.life=1,this.size=new B(1,1,1),this.length=100,this.speedModifier=1,this.color=new bt,this.previous=new $c,this.uvTile=0,this.memory=[]}update(){for(this.age<=this.life?this.previous.push(new Xc(this.position.clone(),this.size.x,this.color.clone())):this.previous.length>0&&this.previous.dequeue();this.previous.length>this.length;)this.previous.dequeue()}get died(){return this.age>=this.life}reset(){this.memory.length=0,this.previous.clear()}}class Fi{initialize(t){this.width.startGen(t.memory)}constructor(t){this.width=t,this.type="WidthOverLength"}update(t){if(t instanceof Nr){const e=t.previous.values();for(let i=0;i<t.previous.length;i++){const r=e.next();r.value.size=this.width.genValue(t.memory,(t.previous.length-i)/t.length)}}}frameUpdate(t){}toJSON(){return{type:this.type,width:this.width.toJSON()}}static fromJSON(t){return new Fi(N(t.width))}clone(){return new Fi(this.width.clone())}reset(){}}class Li{constructor(t,e){this.direction=t,this.magnitude=e,this.type="ApplyForce",this.memory={data:[],dataCount:0},this.magnitudeValue=this.magnitude.genValue(this.memory)}initialize(t){}update(t,e){t.velocity.addScaledVector(this.direction,this.magnitudeValue*e)}frameUpdate(t){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(t){var e;return new Li(new B(t.direction[0],t.direction[1],t.direction[2]),N((e=t.magnitude)!==null&&e!==void 0?e:t.force))}clone(){return new Li(this.direction.clone(),this.magnitude.clone())}reset(){}}class Vi{constructor(t,e){this.center=t,this.magnitude=e,this.type="GravityForce",this.temp=new B}initialize(t){}update(t,e){this.temp.copy(this.center).sub(t.position).normalize(),t.velocity.addScaledVector(this.temp,this.magnitude/t.position.distanceToSquared(this.center)*e)}frameUpdate(t){}toJSON(){return{type:this.type,center:[this.center.x,this.center.y,this.center.z],magnitude:this.magnitude}}static fromJSON(t){return new Vi(new B(t.center[0],t.center[1],t.center[2]),t.magnitude)}clone(){return new Vi(this.center.clone(),this.magnitude)}reset(){}}class Ji{constructor(t){this.angle=t,this.type="ChangeEmitDirection",this._temp=new B,this._q=new J,this.memory={data:[],dataCount:0}}initialize(t){const e=t.velocity.length();e!=0&&(t.velocity.normalize(),t.velocity.x===0&&t.velocity.y===0?this._temp.set(0,t.velocity.z,0):this._temp.set(-t.velocity.y,t.velocity.x,0),this.angle.startGen(this.memory),this._q.setFromAxisAngle(this._temp.normalize(),this.angle.genValue(this.memory)),this._temp.copy(t.velocity),t.velocity.applyQuaternion(this._q),this._q.setFromAxisAngle(this._temp,Math.random()*Math.PI*2),t.velocity.applyQuaternion(this._q),t.velocity.setLength(e))}update(t,e){}frameUpdate(t){}toJSON(){return{type:this.type,angle:this.angle.toJSON()}}static fromJSON(t){return new Ji(N(t.angle))}clone(){return new Ji(this.angle)}reset(){}}var Le;(function(n){n[n.Death=0]="Death",n[n.Birth=1]="Birth",n[n.Frame=2]="Frame"})(Le||(Le={}));class Gi{constructor(t,e,i,r=Le.Frame,s=1){this.particleSystem=t,this.useVelocityAsBasis=e,this.subParticleSystem=i,this.mode=r,this.emitProbability=s,this.type="EmitSubParticleSystem",this.q_=new J,this.v_=new B,this.v2_=new B,this.subEmissions=new Array,this.subParticleSystem&&this.subParticleSystem.system&&(this.subParticleSystem.system.onlyUsedByOther=!0)}initialize(t){}update(t,e){this.mode===Le.Frame?this.emit(t,e):this.mode===Le.Birth&&t.age===0?this.emit(t,e):this.mode===Le.Death&&t.age+e>=t.life&&this.emit(t,e)}emit(t,e){if(!this.subParticleSystem||Math.random()>this.emitProbability)return;const i=new Dt;this.setMatrixFromParticle(i,t),this.subEmissions.push({burstParticleCount:0,burstParticleIndex:0,isBursting:!1,burstIndex:0,burstWaveIndex:0,time:0,waitEmiting:0,matrix:i,travelDistance:0,particle:t})}frameUpdate(t){if(this.subParticleSystem)for(let e=0;e<this.subEmissions.length;e++)if(this.subEmissions[e].time>=this.subParticleSystem.system.duration)this.subEmissions[e]=this.subEmissions[this.subEmissions.length-1],this.subEmissions.length=this.subEmissions.length-1,e--;else{const i=this.subEmissions[e];i.particle&&i.particle.age<i.particle.life?this.setMatrixFromParticle(i.matrix,i.particle):i.particle=void 0,this.subParticleSystem.system.emit(t,i,i.matrix)}}toJSON(){return{type:this.type,subParticleSystem:this.subParticleSystem?this.subParticleSystem.uuid:"",useVelocityAsBasis:this.useVelocityAsBasis,mode:this.mode,emitProbability:this.emitProbability}}static fromJSON(t,e){return new Gi(e,t.useVelocityAsBasis,t.subParticleSystem,t.mode,t.emitProbability)}clone(){return new Gi(this.particleSystem,this.useVelocityAsBasis,this.subParticleSystem,this.mode,this.emitProbability)}reset(){}setMatrixFromParticle(t,e){let i;if(e.rotation===void 0||this.useVelocityAsBasis)if(e.velocity.x===0&&e.velocity.y===0&&(e.velocity.z===1||e.velocity.z===0))t.set(1,0,0,e.position.x,0,1,0,e.position.y,0,0,1,e.position.z,0,0,0,1);else{this.v_.copy(Gs).cross(e.velocity),this.v2_.copy(e.velocity).cross(this.v_);const r=this.v_.length(),s=this.v2_.length();t.set(this.v_.x/r,this.v2_.x/s,e.velocity.x,e.position.x,this.v_.y/r,this.v2_.y/s,e.velocity.y,e.position.y,this.v_.z/r,this.v2_.z/s,e.velocity.z,e.position.z,0,0,0,1)}else e.rotation instanceof J?i=e.rotation:(this.q_.setFromAxisAngle(Gs,e.rotation),i=this.q_),t.compose(e.position,i,Gc);this.particleSystem.worldSpace||t.multiplyMatrices(this.particleSystem.emitter.matrixWorld,t)}}const Wc=.5*(Math.sqrt(3)-1),ti=(3-Math.sqrt(3))/6,Hc=1/3,Gt=1/6,Yc=(Math.sqrt(5)-1)/4,ot=(5-Math.sqrt(5))/20,nt=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]),tt=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 sa{constructor(t=Math.random){const e=typeof t=="function"?t:Qc(t);this.p=Zc(e),this.perm=new Uint8Array(512),this.permMod12=new Uint8Array(512);for(let i=0;i<512;i++)this.perm[i]=this.p[i&255],this.permMod12[i]=this.perm[i]%12}noise2D(t,e){const i=this.permMod12,r=this.perm;let s=0,a=0,o=0;const c=(t+e)*Wc,l=Math.floor(t+c),u=Math.floor(e+c),h=(l+u)*ti,f=l-h,d=u-h,y=t-f,_=e-d;let p,m;y>_?(p=1,m=0):(p=0,m=1);const g=y-p+ti,v=_-m+ti,S=y-1+2*ti,x=_-1+2*ti,b=l&255,T=u&255;let w=.5-y*y-_*_;if(w>=0){const R=i[b+r[T]]*3;w*=w,s=w*w*(nt[R]*y+nt[R+1]*_)}let C=.5-g*g-v*v;if(C>=0){const R=i[b+p+r[T+m]]*3;C*=C,a=C*C*(nt[R]*g+nt[R+1]*v)}let P=.5-S*S-x*x;if(P>=0){const R=i[b+1+r[T+1]]*3;P*=P,o=P*P*(nt[R]*S+nt[R+1]*x)}return 70*(s+a+o)}noise3D(t,e,i){const r=this.permMod12,s=this.perm;let a,o,c,l;const u=(t+e+i)*Hc,h=Math.floor(t+u),f=Math.floor(e+u),d=Math.floor(i+u),y=(h+f+d)*Gt,_=h-y,p=f-y,m=d-y,g=t-_,v=e-p,S=i-m;let x,b,T,w,C,P;g>=v?v>=S?(x=1,b=0,T=0,w=1,C=1,P=0):g>=S?(x=1,b=0,T=0,w=1,C=0,P=1):(x=0,b=0,T=1,w=1,C=0,P=1):v<S?(x=0,b=0,T=1,w=0,C=1,P=1):g<S?(x=0,b=1,T=0,w=0,C=1,P=1):(x=0,b=1,T=0,w=1,C=1,P=0);const R=g-x+Gt,E=v-b+Gt,A=S-T+Gt,k=g-w+2*Gt,z=v-C+2*Gt,U=S-P+2*Gt,L=g-1+3*Gt,I=v-1+3*Gt,X=S-1+3*Gt,Z=h&255,it=f&255,K=d&255;let pt=.6-g*g-v*v-S*S;if(pt<0)a=0;else{const j=r[Z+s[it+s[K]]]*3;pt*=pt,a=pt*pt*(nt[j]*g+nt[j+1]*v+nt[j+2]*S)}let mt=.6-R*R-E*E-A*A;if(mt<0)o=0;else{const j=r[Z+x+s[it+b+s[K+T]]]*3;mt*=mt,o=mt*mt*(nt[j]*R+nt[j+1]*E+nt[j+2]*A)}let rt=.6-k*k-z*z-U*U;if(rt<0)c=0;else{const j=r[Z+w+s[it+C+s[K+P]]]*3;rt*=rt,c=rt*rt*(nt[j]*k+nt[j+1]*z+nt[j+2]*U)}let W=.6-L*L-I*I-X*X;if(W<0)l=0;else{const j=r[Z+1+s[it+1+s[K+1]]]*3;W*=W,l=W*W*(nt[j]*L+nt[j+1]*I+nt[j+2]*X)}return 32*(a+o+c+l)}noise4D(t,e,i,r){const s=this.perm;let a,o,c,l,u;const h=(t+e+i+r)*Yc,f=Math.floor(t+h),d=Math.floor(e+h),y=Math.floor(i+h),_=Math.floor(r+h),p=(f+d+y+_)*ot,m=f-p,g=d-p,v=y-p,S=_-p,x=t-m,b=e-g,T=i-v,w=r-S;let C=0,P=0,R=0,E=0;x>b?C++:P++,x>T?C++:R++,x>w?C++:E++,b>T?P++:R++,b>w?P++:E++,T>w?R++:E++;const A=C>=3?1:0,k=P>=3?1:0,z=R>=3?1:0,U=E>=3?1:0,L=C>=2?1:0,I=P>=2?1:0,X=R>=2?1:0,Z=E>=2?1:0,it=C>=1?1:0,K=P>=1?1:0,pt=R>=1?1:0,mt=E>=1?1:0,rt=x-A+ot,W=b-k+ot,j=T-z+ot,Ht=w-U+ot,Ft=x-L+2*ot,Lt=b-I+2*ot,Vt=T-X+2*ot,vt=w-Z+2*ot,At=x-it+3*ot,_t=b-K+3*ot,Yt=T-pt+3*ot,Zt=w-mt+3*ot,H=x-1+4*ot,Jt=b-1+4*ot,Qt=T-1+4*ot,ve=w-1+4*ot,Kt=f&255,te=d&255,ee=y&255,ie=_&255;let re=.6-x*x-b*b-T*T-w*w;if(re<0)a=0;else{const V=s[Kt+s[te+s[ee+s[ie]]]]%32*4;re*=re,a=re*re*(tt[V]*x+tt[V+1]*b+tt[V+2]*T+tt[V+3]*w)}let kt=.6-rt*rt-W*W-j*j-Ht*Ht;if(kt<0)o=0;else{const V=s[Kt+A+s[te+k+s[ee+z+s[ie+U]]]]%32*4;kt*=kt,o=kt*kt*(tt[V]*rt+tt[V+1]*W+tt[V+2]*j+tt[V+3]*Ht)}let zt=.6-Ft*Ft-Lt*Lt-Vt*Vt-vt*vt;if(zt<0)c=0;else{const V=s[Kt+L+s[te+I+s[ee+X+s[ie+Z]]]]%32*4;zt*=zt,c=zt*zt*(tt[V]*Ft+tt[V+1]*Lt+tt[V+2]*Vt+tt[V+3]*vt)}let Ot=.6-At*At-_t*_t-Yt*Yt-Zt*Zt;if(Ot<0)l=0;else{const V=s[Kt+it+s[te+K+s[ee+pt+s[ie+mt]]]]%32*4;Ot*=Ot,l=Ot*Ot*(tt[V]*At+tt[V+1]*_t+tt[V+2]*Yt+tt[V+3]*Zt)}let Bt=.6-H*H-Jt*Jt-Qt*Qt-ve*ve;if(Bt<0)u=0;else{const V=s[Kt+1+s[te+1+s[ee+1+s[ie+1]]]]%32*4;Bt*=Bt,u=Bt*Bt*(tt[V]*H+tt[V+1]*Jt+tt[V+2]*Qt+tt[V+3]*ve)}return 27*(a+o+c+l+u)}}function Zc(n){const t=new Uint8Array(256);for(let e=0;e<256;e++)t[e]=e;for(let e=0;e<255;e++){const i=e+~~(n()*(256-e)),r=t[e];t[e]=t[i],t[i]=r}return t}function Qc(n){let t=0,e=0,i=0,r=1;const s=Kc();return t=s(" "),e=s(" "),i=s(" "),t-=s(n),t<0&&(t+=1),e-=s(n),e<0&&(e+=1),i-=s(n),i<0&&(i+=1),function(){const a=2091639*t+r*23283064365386963e-26;return t=e,e=i,i=a-(r=a|0)}}function Kc(){let n=4022871197;return function(t){t=t.toString();for(let e=0;e<t.length;e++){n+=t.charCodeAt(e);let i=.02519603282416938*n;n=i>>>0,i-=n,i*=n,n=i>>>0,i-=n,n+=i*4294967296}return(n>>>0)*23283064365386963e-26}}class ji{constructor(t,e,i,r){this.scale=t,this.octaves=e,this.velocityMultiplier=i,this.timeScale=r,this.type="TurbulenceField",this.generator=new sa,this.timeOffset=new B,this.temp=new B,this.temp2=new B,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(t){}update(t,e){const i=t.position.x/this.scale.x,r=t.position.y/this.scale.y,s=t.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(i*a,r*a,s*a,this.timeOffset.x*a)/a,this.generator.noise4D(i*a,r*a,s*a,this.timeOffset.y*a)/a,this.generator.noise4D(i*a,r*a,s*a,this.timeOffset.z*a)/a),this.temp.add(this.temp2),a*=2;this.temp.multiply(this.velocityMultiplier),t.velocity.addScaledVector(this.temp,e)}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(t){this.timeOffset.x+=t*this.timeScale.x,this.timeOffset.y+=t*this.timeScale.y,this.timeOffset.z+=t*this.timeScale.z}static fromJSON(t){return new ji(new B(t.scale[0],t.scale[1],t.scale[2]),t.octaves,new B(t.velocityMultiplier[0],t.velocityMultiplier[1],t.velocityMultiplier[2]),new B(t.timeScale[0],t.timeScale[1],t.timeScale[2]))}clone(){return new ji(this.scale.clone(),this.octaves,this.velocityMultiplier.clone(),this.timeScale.clone())}reset(){}}const jt=[],ln=new B,un=new J;class $i{constructor(t,e,i=new D(1),r=new D(0)){if(this.frequency=t,this.power=e,this.positionAmount=i,this.rotationAmount=r,this.type="Noise",this.duration=0,jt.length===0)for(let s=0;s<100;s++)jt.push(new sa)}initialize(t){t.lastPosNoise=new B,typeof t.rotation=="number"?t.lastRotNoise=0:t.lastRotNoise=new J,t.generatorIndex=[or(0,100),or(0,100),or(0,100),or(0,100)],this.positionAmount.startGen(t.memory),this.rotationAmount.startGen(t.memory),this.frequency.startGen(t.memory),this.power.startGen(t.memory)}update(t,e){let i=this.frequency.genValue(t.memory,t.age/t.life),r=this.power.genValue(t.memory,t.age/t.life),s=this.positionAmount.genValue(t.memory,t.age/t.life),a=this.rotationAmount.genValue(t.memory,t.age/t.life);s>0&&t.lastPosNoise!==void 0&&(t.position.sub(t.lastPosNoise),ln.set(jt[t.generatorIndex[0]].noise2D(0,t.age*i)*r*s,jt[t.generatorIndex[1]].noise2D(0,t.age*i)*r*s,jt[t.generatorIndex[2]].noise2D(0,t.age*i)*r*s),t.position.add(ln),t.lastPosNoise.copy(ln)),a>0&&t.lastRotNoise!==void 0&&(typeof t.rotation=="number"?(t.rotation-=t.lastRotNoise,t.rotation+=jt[t.generatorIndex[3]].noise2D(0,t.age*i)*Math.PI*r*a):(t.lastRotNoise.invert(),t.rotation.multiply(t.lastRotNoise),un.set(jt[t.generatorIndex[0]].noise2D(0,t.age*i)*r*a,jt[t.generatorIndex[1]].noise2D(0,t.age*i)*r*a,jt[t.generatorIndex[2]].noise2D(0,t.age*i)*r*a,jt[t.generatorIndex[3]].noise2D(0,t.age*i)*r*a).normalize(),t.rotation.multiply(un),t.lastRotNoise.copy(un)))}toJSON(){return{type:this.type,frequency:this.frequency.toJSON(),power:this.power.toJSON(),positionAmount:this.positionAmount.toJSON(),rotationAmount:this.rotationAmount.toJSON()}}frameUpdate(t){this.duration+=t}static fromJSON(t){return new $i(N(t.frequency),N(t.power),N(t.positionAmount),N(t.rotationAmount))}clone(){return new $i(this.frequency.clone(),this.power.clone(),this.positionAmount.clone(),this.rotationAmount.clone())}reset(){}}class qi{constructor(t,e){this.color=t,this.speedRange=e,this.type="ColorBySpeed"}initialize(t){this.color.startGen(t.memory)}update(t,e){const i=(t.startSpeed-this.speedRange.a)/(this.speedRange.b-this.speedRange.a);this.color.genColor(t.memory,t.color,i),t.color.x*=t.startColor.x,t.color.y*=t.startColor.y,t.color.z*=t.startColor.z,t.color.w*=t.startColor.w}frameUpdate(t){}toJSON(){return{type:this.type,color:this.color.toJSON(),speedRange:this.speedRange.toJSON()}}static fromJSON(t){return new qi(Kn(t.color),Ae.fromJSON(t.speedRange))}clone(){return new qi(this.color.clone(),this.speedRange.clone())}reset(){}}class Xi{initialize(t){this.size.startGen(t.memory)}constructor(t,e){this.size=t,this.speedRange=e,this.type="SizeBySpeed"}update(t){const e=(t.startSpeed-this.speedRange.a)/(this.speedRange.b-this.speedRange.a);this.size instanceof ke?this.size.genValue(t.memory,t.size,e).multiply(t.startSize):t.size.copy(t.startSize).multiplyScalar(this.size.genValue(t.memory,e))}toJSON(){return{type:this.type,size:this.size.toJSON(),speedRange:this.speedRange.toJSON()}}static fromJSON(t){return new Xi(Ur(t.size),Ae.fromJSON(t.speedRange))}frameUpdate(t){}clone(){return new Xi(this.size.clone(),this.speedRange.clone())}reset(){}}class Wi{constructor(t,e){this.angularVelocity=t,this.speedRange=e,this.type="RotationBySpeed",this.tempQuat=new J}initialize(t){typeof t.rotation=="number"&&this.angularVelocity.startGen(t.memory)}update(t,e){if(typeof t.rotation=="number"){const i=(t.startSpeed-this.speedRange.a)/(this.speedRange.b-this.speedRange.a);t.rotation+=e*this.angularVelocity.genValue(t.memory,i)}}toJSON(){return{type:this.type,angularVelocity:this.angularVelocity.toJSON(),speedRange:this.speedRange.toJSON()}}static fromJSON(t){return new Wi(N(t.angularVelocity),Ae.fromJSON(t.speedRange))}frameUpdate(t){}clone(){return new Wi(this.angularVelocity.clone(),this.speedRange.clone())}reset(){}}class Hi{initialize(t){this.speed.startGen(t.memory)}constructor(t,e){this.speed=t,this.dampen=e,this.type="LimitSpeedOverLife"}update(t,e){let i=t.velocity.length(),r=this.speed.genValue(t.memory,t.age/t.life);if(i>r){const s=(i-r)/i;t.velocity.multiplyScalar(1-s*this.dampen*e*20)}}toJSON(){return{type:this.type,speed:this.speed.toJSON(),dampen:this.dampen}}static fromJSON(t){return new Hi(N(t.speed),t.dampen)}frameUpdate(t){}clone(){return new Hi(this.speed.clone(),this.dampen)}reset(){}}const Dr={ApplyForce:{type:"ApplyForce",constructor:Li,params:[["direction",["vec3"]],["magnitude",["value"]]],loadJSON:Li.fromJSON},Noise:{type:"Noise",constructor:$i,params:[["frequency",["value"]],["power",["value"]],["positionAmount",["value"]],["rotationAmount",["value"]]],loadJSON:$i.fromJSON},TurbulenceField:{type:"TurbulenceField",constructor:ji,params:[["scale",["vec3"]],["octaves",["number"]],["velocityMultiplier",["vec3"]],["timeScale",["vec3"]]],loadJSON:ji.fromJSON},GravityForce:{type:"GravityForce",constructor:Vi,params:[["center",["vec3"]],["magnitude",["number"]]],loadJSON:Vi.fromJSON},ColorOverLife:{type:"ColorOverLife",constructor:ki,params:[["color",["colorFunc"]]],loadJSON:ki.fromJSON},RotationOverLife:{type:"RotationOverLife",constructor:zi,params:[["angularVelocity",["value","valueFunc"]]],loadJSON:zi.fromJSON},Rotation3DOverLife:{type:"Rotation3DOverLife",constructor:Oi,params:[["angularVelocity",["rotationFunc"]]],loadJSON:Oi.fromJSON},SizeOverLife:{type:"SizeOverLife",constructor:Ii,params:[["size",["value","valueFunc","vec3Func"]]],loadJSON:Ii.fromJSON},ColorBySpeed:{type:"ColorBySpeed",constructor:qi,params:[["color",["colorFunc"]],["speedRange",["range"]]],loadJSON:qi.fromJSON},RotationBySpeed:{type:"RotationBySpeed",constructor:Wi,params:[["angularVelocity",["value","valueFunc"]],["speedRange",["range"]]],loadJSON:Wi.fromJSON},SizeBySpeed:{type:"SizeBySpeed",constructor:Xi,params:[["size",["value","valueFunc","vec3Func"]],["speedRange",["range"]]],loadJSON:Xi.fromJSON},SpeedOverLife:{type:"SpeedOverLife",constructor:Ui,params:[["speed",["value","valueFunc"]]],loadJSON:Ui.fromJSON},FrameOverLife:{type:"FrameOverLife",constructor:Ni,params:[["frame",["value","valueFunc"]]],loadJSON:Ni.fromJSON},ForceOverLife:{type:"ForceOverLife",constructor:Bi,params:[["x",["value","valueFunc"]],["y",["value","valueFunc"]],["z",["value","valueFunc"]]],loadJSON:Bi.fromJSON},OrbitOverLife:{type:"OrbitOverLife",constructor:Di,params:[["orbitSpeed",["value","valueFunc"]],["axis",["vec3"]]],loadJSON:Di.fromJSON},WidthOverLength:{type:"WidthOverLength",constructor:Fi,params:[["width",["value","valueFunc"]]],loadJSON:Fi.fromJSON},ChangeEmitDirection:{type:"ChangeEmitDirection",constructor:Ji,params:[["angle",["value"]]],loadJSON:Ji.fromJSON},EmitSubParticleSystem:{type:"EmitSubParticleSystem",constructor:Gi,params:[["particleSystem",["self"]],["useVelocityAsBasis",["boolean"]],["subParticleSystem",["particleSystem"]],["mode",["number"]],["emitProbability",["number"]]],loadJSON:Gi.fromJSON},LimitSpeedOverLife:{type:"LimitSpeedOverLife",constructor:Hi,params:[["speed",["value","valueFunc"]],["dampen",["number"]]],loadJSON:Hi.fromJSON}};function tl(n,t){return Dr[n.type]?Dr[n.type].loadJSON(n,t):null}const el=[];function il(n){if(!el.find(e=>e.id===n.id)){for(const e of n.emitterShapes)Un[e.type]||(Un[e.type]=e);for(const e of n.behaviors)Dr[e.type]||(Dr[e.type]=e)}}var rl=`
|
|
84
|
-
#ifdef SOFT_PARTICLES
|
|
85
|
-
|
|
86
|
-
/* #ifdef LOGDEPTH
|
|
87
|
-
float distSample = linearize_depth_log(sampleDepth, near, far);
|
|
88
|
-
#else
|
|
89
|
-
float distSample = ortho ? linearize_depth_ortho(sampleDepth, near, far) : linearize_depth(sampleDepth, near, far);
|
|
90
|
-
#endif */
|
|
91
|
-
|
|
92
|
-
vec2 p2 = projPosition.xy / projPosition.w;
|
|
93
|
-
|
|
94
|
-
p2 = 0.5 * p2 + 0.5;
|
|
95
|
-
|
|
96
|
-
float readDepth = texture2D(depthTexture, p2.xy).r;
|
|
97
|
-
float viewDepth = linearize_depth(readDepth);
|
|
98
|
-
|
|
99
|
-
float softParticlesFade = saturate(SOFT_INV_FADE_DISTANCE * ((viewDepth - SOFT_NEAR_FADE) - linearDepth));
|
|
100
|
-
|
|
101
|
-
gl_FragColor *= softParticlesFade;
|
|
102
|
-
|
|
103
|
-
//gl_FragColor = vec4(softParticlesFade , 0, 0, 1);
|
|
104
|
-
#endif
|
|
105
|
-
`,nl=`
|
|
106
|
-
#ifdef SOFT_PARTICLES
|
|
107
|
-
|
|
108
|
-
uniform sampler2D depthTexture;
|
|
109
|
-
uniform vec4 projParams;
|
|
110
|
-
uniform vec2 softParams;
|
|
111
|
-
|
|
112
|
-
varying vec4 projPosition;
|
|
113
|
-
varying float linearDepth;
|
|
114
|
-
|
|
115
|
-
#define SOFT_NEAR_FADE softParams.x
|
|
116
|
-
#define SOFT_INV_FADE_DISTANCE softParams.y
|
|
117
|
-
|
|
118
|
-
#define zNear projParams.x
|
|
119
|
-
#define zFar projParams.y
|
|
120
|
-
|
|
121
|
-
float linearize_depth(float d)
|
|
122
|
-
{
|
|
123
|
-
return (zFar * zNear) / (zFar - d * (zFar - zNear));
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
#endif
|
|
127
|
-
`,sl=`
|
|
128
|
-
#ifdef SOFT_PARTICLES
|
|
129
|
-
varying vec4 projPosition;
|
|
130
|
-
varying float linearDepth;
|
|
131
|
-
#endif
|
|
132
|
-
`,ol=`
|
|
133
|
-
#ifdef SOFT_PARTICLES
|
|
134
|
-
projPosition = gl_Position;
|
|
135
|
-
linearDepth = -mvPosition.z;
|
|
136
|
-
#endif
|
|
137
|
-
`,al=`
|
|
138
|
-
#ifdef USE_MAP
|
|
139
|
-
vec4 texelColor = texture2D( map, vUv);
|
|
140
|
-
#ifdef TILE_BLEND
|
|
141
|
-
texelColor = mix( texelColor, texture2D( map, vUvNext ), vUvBlend );
|
|
142
|
-
#endif
|
|
143
|
-
diffuseColor *= texelColor;
|
|
144
|
-
#endif
|
|
145
|
-
`,cl=`
|
|
146
|
-
#if defined( USE_UV ) || defined( USE_ANISOTROPY )
|
|
147
|
-
|
|
148
|
-
varying vec2 vUv;
|
|
149
|
-
#ifdef TILE_BLEND
|
|
150
|
-
varying vec2 vUvNext;
|
|
151
|
-
varying float vUvBlend;
|
|
152
|
-
#endif
|
|
153
|
-
|
|
154
|
-
#endif
|
|
155
|
-
#ifdef USE_MAP
|
|
156
|
-
|
|
157
|
-
uniform mat3 mapTransform;
|
|
158
|
-
varying vec2 vMapUv;
|
|
159
|
-
#ifdef TILE_BLEND
|
|
160
|
-
varying vec2 vMapUvNext;
|
|
161
|
-
#endif
|
|
162
|
-
|
|
163
|
-
#endif
|
|
164
|
-
#ifdef USE_ALPHAMAP
|
|
165
|
-
|
|
166
|
-
uniform mat3 alphaMapTransform;
|
|
167
|
-
varying vec2 vAlphaMapUv;
|
|
168
|
-
|
|
169
|
-
#endif
|
|
170
|
-
#ifdef USE_LIGHTMAP
|
|
171
|
-
|
|
172
|
-
uniform mat3 lightMapTransform;
|
|
173
|
-
varying vec2 vLightMapUv;
|
|
174
|
-
|
|
175
|
-
#endif
|
|
176
|
-
#ifdef USE_AOMAP
|
|
177
|
-
|
|
178
|
-
uniform mat3 aoMapTransform;
|
|
179
|
-
varying vec2 vAoMapUv;
|
|
180
|
-
|
|
181
|
-
#endif
|
|
182
|
-
#ifdef USE_BUMPMAP
|
|
183
|
-
|
|
184
|
-
uniform mat3 bumpMapTransform;
|
|
185
|
-
varying vec2 vBumpMapUv;
|
|
186
|
-
|
|
187
|
-
#endif
|
|
188
|
-
#ifdef USE_NORMALMAP
|
|
189
|
-
|
|
190
|
-
uniform mat3 normalMapTransform;
|
|
191
|
-
varying vec2 vNormalMapUv;
|
|
192
|
-
|
|
193
|
-
#endif
|
|
194
|
-
#ifdef USE_DISPLACEMENTMAP
|
|
195
|
-
|
|
196
|
-
uniform mat3 displacementMapTransform;
|
|
197
|
-
varying vec2 vDisplacementMapUv;
|
|
198
|
-
|
|
199
|
-
#endif
|
|
200
|
-
#ifdef USE_EMISSIVEMAP
|
|
201
|
-
|
|
202
|
-
uniform mat3 emissiveMapTransform;
|
|
203
|
-
varying vec2 vEmissiveMapUv;
|
|
204
|
-
|
|
205
|
-
#endif
|
|
206
|
-
#ifdef USE_METALNESSMAP
|
|
207
|
-
|
|
208
|
-
uniform mat3 metalnessMapTransform;
|
|
209
|
-
varying vec2 vMetalnessMapUv;
|
|
210
|
-
|
|
211
|
-
#endif
|
|
212
|
-
#ifdef USE_ROUGHNESSMAP
|
|
213
|
-
|
|
214
|
-
uniform mat3 roughnessMapTransform;
|
|
215
|
-
varying vec2 vRoughnessMapUv;
|
|
216
|
-
|
|
217
|
-
#endif
|
|
218
|
-
#ifdef USE_ANISOTROPYMAP
|
|
219
|
-
|
|
220
|
-
uniform mat3 anisotropyMapTransform;
|
|
221
|
-
varying vec2 vAnisotropyMapUv;
|
|
222
|
-
|
|
223
|
-
#endif
|
|
224
|
-
#ifdef USE_CLEARCOATMAP
|
|
225
|
-
|
|
226
|
-
uniform mat3 clearcoatMapTransform;
|
|
227
|
-
varying vec2 vClearcoatMapUv;
|
|
228
|
-
|
|
229
|
-
#endif
|
|
230
|
-
#ifdef USE_CLEARCOAT_NORMALMAP
|
|
231
|
-
|
|
232
|
-
uniform mat3 clearcoatNormalMapTransform;
|
|
233
|
-
varying vec2 vClearcoatNormalMapUv;
|
|
234
|
-
|
|
235
|
-
#endif
|
|
236
|
-
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
|
|
237
|
-
|
|
238
|
-
uniform mat3 clearcoatRoughnessMapTransform;
|
|
239
|
-
varying vec2 vClearcoatRoughnessMapUv;
|
|
240
|
-
|
|
241
|
-
#endif
|
|
242
|
-
#ifdef USE_SHEEN_COLORMAP
|
|
243
|
-
|
|
244
|
-
uniform mat3 sheenColorMapTransform;
|
|
245
|
-
varying vec2 vSheenColorMapUv;
|
|
246
|
-
|
|
247
|
-
#endif
|
|
248
|
-
#ifdef USE_SHEEN_ROUGHNESSMAP
|
|
249
|
-
|
|
250
|
-
uniform mat3 sheenRoughnessMapTransform;
|
|
251
|
-
varying vec2 vSheenRoughnessMapUv;
|
|
252
|
-
|
|
253
|
-
#endif
|
|
254
|
-
#ifdef USE_IRIDESCENCEMAP
|
|
255
|
-
|
|
256
|
-
uniform mat3 iridescenceMapTransform;
|
|
257
|
-
varying vec2 vIridescenceMapUv;
|
|
258
|
-
|
|
259
|
-
#endif
|
|
260
|
-
#ifdef USE_IRIDESCENCE_THICKNESSMAP
|
|
261
|
-
|
|
262
|
-
uniform mat3 iridescenceThicknessMapTransform;
|
|
263
|
-
varying vec2 vIridescenceThicknessMapUv;
|
|
264
|
-
|
|
265
|
-
#endif
|
|
266
|
-
#ifdef USE_SPECULARMAP
|
|
267
|
-
|
|
268
|
-
uniform mat3 specularMapTransform;
|
|
269
|
-
varying vec2 vSpecularMapUv;
|
|
270
|
-
|
|
271
|
-
#endif
|
|
272
|
-
#ifdef USE_SPECULAR_COLORMAP
|
|
273
|
-
|
|
274
|
-
uniform mat3 specularColorMapTransform;
|
|
275
|
-
varying vec2 vSpecularColorMapUv;
|
|
276
|
-
|
|
277
|
-
#endif
|
|
278
|
-
#ifdef USE_SPECULAR_INTENSITYMAP
|
|
279
|
-
|
|
280
|
-
uniform mat3 specularIntensityMapTransform;
|
|
281
|
-
varying vec2 vSpecularIntensityMapUv;
|
|
282
|
-
|
|
283
|
-
#endif
|
|
284
|
-
#ifdef USE_TRANSMISSIONMAP
|
|
285
|
-
|
|
286
|
-
uniform mat3 transmissionMapTransform;
|
|
287
|
-
varying vec2 vTransmissionMapUv;
|
|
288
|
-
|
|
289
|
-
#endif
|
|
290
|
-
#ifdef USE_THICKNESSMAP
|
|
291
|
-
|
|
292
|
-
uniform mat3 thicknessMapTransform;
|
|
293
|
-
varying vec2 vThicknessMapUv;
|
|
294
|
-
|
|
295
|
-
#endif
|
|
296
|
-
`,ll=`
|
|
297
|
-
#ifdef UV_TILE
|
|
298
|
-
attribute float uvTile;
|
|
299
|
-
uniform vec2 tileCount;
|
|
300
|
-
|
|
301
|
-
mat3 makeTileTransform(float uvTile) {
|
|
302
|
-
float col = mod(uvTile, tileCount.x);
|
|
303
|
-
float row = (tileCount.y - floor(uvTile / tileCount.x) - 1.0);
|
|
304
|
-
|
|
305
|
-
return mat3(
|
|
306
|
-
1.0 / tileCount.x, 0.0, 0.0,
|
|
307
|
-
0.0, 1.0 / tileCount.y, 0.0,
|
|
308
|
-
col / tileCount.x, row / tileCount.y, 1.0);
|
|
309
|
-
}
|
|
310
|
-
#else
|
|
311
|
-
mat3 makeTileTransform(float uvTile) {
|
|
312
|
-
return mat3(1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0);
|
|
313
|
-
}
|
|
314
|
-
#endif
|
|
315
|
-
|
|
316
|
-
#if defined( USE_UV ) || defined( USE_ANISOTROPY )
|
|
317
|
-
|
|
318
|
-
varying vec2 vUv;
|
|
319
|
-
#ifdef TILE_BLEND
|
|
320
|
-
varying vec2 vUvNext;
|
|
321
|
-
varying float vUvBlend;
|
|
322
|
-
#endif
|
|
323
|
-
|
|
324
|
-
#endif
|
|
325
|
-
#ifdef USE_MAP
|
|
326
|
-
|
|
327
|
-
uniform mat3 mapTransform;
|
|
328
|
-
varying vec2 vMapUv;
|
|
329
|
-
#ifdef TILE_BLEND
|
|
330
|
-
varying vec2 vMapUvNext;
|
|
331
|
-
#endif
|
|
332
|
-
|
|
333
|
-
#endif
|
|
334
|
-
#ifdef USE_ALPHAMAP
|
|
335
|
-
|
|
336
|
-
uniform mat3 alphaMapTransform;
|
|
337
|
-
varying vec2 vAlphaMapUv;
|
|
338
|
-
|
|
339
|
-
#endif
|
|
340
|
-
#ifdef USE_LIGHTMAP
|
|
341
|
-
|
|
342
|
-
uniform mat3 lightMapTransform;
|
|
343
|
-
varying vec2 vLightMapUv;
|
|
344
|
-
|
|
345
|
-
#endif
|
|
346
|
-
#ifdef USE_AOMAP
|
|
347
|
-
|
|
348
|
-
uniform mat3 aoMapTransform;
|
|
349
|
-
varying vec2 vAoMapUv;
|
|
350
|
-
|
|
351
|
-
#endif
|
|
352
|
-
#ifdef USE_BUMPMAP
|
|
353
|
-
|
|
354
|
-
uniform mat3 bumpMapTransform;
|
|
355
|
-
varying vec2 vBumpMapUv;
|
|
356
|
-
|
|
357
|
-
#endif
|
|
358
|
-
#ifdef USE_NORMALMAP
|
|
359
|
-
|
|
360
|
-
uniform mat3 normalMapTransform;
|
|
361
|
-
varying vec2 vNormalMapUv;
|
|
362
|
-
|
|
363
|
-
#endif
|
|
364
|
-
#ifdef USE_DISPLACEMENTMAP
|
|
365
|
-
|
|
366
|
-
uniform mat3 displacementMapTransform;
|
|
367
|
-
varying vec2 vDisplacementMapUv;
|
|
368
|
-
|
|
369
|
-
#endif
|
|
370
|
-
#ifdef USE_EMISSIVEMAP
|
|
371
|
-
|
|
372
|
-
uniform mat3 emissiveMapTransform;
|
|
373
|
-
varying vec2 vEmissiveMapUv;
|
|
374
|
-
|
|
375
|
-
#endif
|
|
376
|
-
#ifdef USE_METALNESSMAP
|
|
377
|
-
|
|
378
|
-
uniform mat3 metalnessMapTransform;
|
|
379
|
-
varying vec2 vMetalnessMapUv;
|
|
380
|
-
|
|
381
|
-
#endif
|
|
382
|
-
#ifdef USE_ROUGHNESSMAP
|
|
383
|
-
|
|
384
|
-
uniform mat3 roughnessMapTransform;
|
|
385
|
-
varying vec2 vRoughnessMapUv;
|
|
386
|
-
|
|
387
|
-
#endif
|
|
388
|
-
#ifdef USE_ANISOTROPYMAP
|
|
389
|
-
|
|
390
|
-
uniform mat3 anisotropyMapTransform;
|
|
391
|
-
varying vec2 vAnisotropyMapUv;
|
|
392
|
-
|
|
393
|
-
#endif
|
|
394
|
-
#ifdef USE_CLEARCOATMAP
|
|
395
|
-
|
|
396
|
-
uniform mat3 clearcoatMapTransform;
|
|
397
|
-
varying vec2 vClearcoatMapUv;
|
|
398
|
-
|
|
399
|
-
#endif
|
|
400
|
-
#ifdef USE_CLEARCOAT_NORMALMAP
|
|
401
|
-
|
|
402
|
-
uniform mat3 clearcoatNormalMapTransform;
|
|
403
|
-
varying vec2 vClearcoatNormalMapUv;
|
|
404
|
-
|
|
405
|
-
#endif
|
|
406
|
-
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
|
|
407
|
-
|
|
408
|
-
uniform mat3 clearcoatRoughnessMapTransform;
|
|
409
|
-
varying vec2 vClearcoatRoughnessMapUv;
|
|
410
|
-
|
|
411
|
-
#endif
|
|
412
|
-
#ifdef USE_SHEEN_COLORMAP
|
|
413
|
-
|
|
414
|
-
uniform mat3 sheenColorMapTransform;
|
|
415
|
-
varying vec2 vSheenColorMapUv;
|
|
416
|
-
|
|
417
|
-
#endif
|
|
418
|
-
#ifdef USE_SHEEN_ROUGHNESSMAP
|
|
419
|
-
|
|
420
|
-
uniform mat3 sheenRoughnessMapTransform;
|
|
421
|
-
varying vec2 vSheenRoughnessMapUv;
|
|
422
|
-
|
|
423
|
-
#endif
|
|
424
|
-
#ifdef USE_IRIDESCENCEMAP
|
|
425
|
-
|
|
426
|
-
uniform mat3 iridescenceMapTransform;
|
|
427
|
-
varying vec2 vIridescenceMapUv;
|
|
428
|
-
|
|
429
|
-
#endif
|
|
430
|
-
#ifdef USE_IRIDESCENCE_THICKNESSMAP
|
|
431
|
-
|
|
432
|
-
uniform mat3 iridescenceThicknessMapTransform;
|
|
433
|
-
varying vec2 vIridescenceThicknessMapUv;
|
|
434
|
-
|
|
435
|
-
#endif
|
|
436
|
-
#ifdef USE_SPECULARMAP
|
|
437
|
-
|
|
438
|
-
uniform mat3 specularMapTransform;
|
|
439
|
-
varying vec2 vSpecularMapUv;
|
|
440
|
-
|
|
441
|
-
#endif
|
|
442
|
-
#ifdef USE_SPECULAR_COLORMAP
|
|
443
|
-
|
|
444
|
-
uniform mat3 specularColorMapTransform;
|
|
445
|
-
varying vec2 vSpecularColorMapUv;
|
|
446
|
-
|
|
447
|
-
#endif
|
|
448
|
-
#ifdef USE_SPECULAR_INTENSITYMAP
|
|
449
|
-
|
|
450
|
-
uniform mat3 specularIntensityMapTransform;
|
|
451
|
-
varying vec2 vSpecularIntensityMapUv;
|
|
452
|
-
|
|
453
|
-
#endif
|
|
454
|
-
#ifdef USE_TRANSMISSIONMAP
|
|
455
|
-
|
|
456
|
-
uniform mat3 transmissionMapTransform;
|
|
457
|
-
varying vec2 vTransmissionMapUv;
|
|
458
|
-
|
|
459
|
-
#endif
|
|
460
|
-
#ifdef USE_THICKNESSMAP
|
|
461
|
-
|
|
462
|
-
uniform mat3 thicknessMapTransform;
|
|
463
|
-
varying vec2 vThicknessMapUv;
|
|
464
|
-
|
|
465
|
-
#endif
|
|
466
|
-
`,ul=`
|
|
467
|
-
#ifdef UV_TILE
|
|
468
|
-
mat3 tileTransform = makeTileTransform(floor(uvTile));
|
|
469
|
-
#ifdef TILE_BLEND
|
|
470
|
-
mat3 nextTileTransform = makeTileTransform(ceil(uvTile));
|
|
471
|
-
vUvBlend = fract(uvTile);
|
|
472
|
-
#endif
|
|
473
|
-
#else
|
|
474
|
-
mat3 tileTransform = makeTileTransform(0.0);
|
|
475
|
-
#endif
|
|
476
|
-
|
|
477
|
-
#if defined( USE_UV ) || defined( USE_ANISOTROPY )
|
|
478
|
-
|
|
479
|
-
vUv = (tileTransform *vec3( uv, 1 )).xy;
|
|
480
|
-
#if defined( TILE_BLEND ) && defined( UV_TILE )
|
|
481
|
-
vUvNext = (nextTileTransform *vec3( uv, 1 )).xy;
|
|
482
|
-
#endif
|
|
483
|
-
|
|
484
|
-
#endif
|
|
485
|
-
#ifdef USE_MAP
|
|
486
|
-
|
|
487
|
-
vMapUv = ( tileTransform * (mapTransform * vec3( MAP_UV, 1 ) )).xy;
|
|
488
|
-
#if defined( TILE_BLEND ) && defined( UV_TILE )
|
|
489
|
-
vMapUvNext = (nextTileTransform * (mapTransform * vec3( MAP_UV, 1 ))).xy;
|
|
490
|
-
#endif
|
|
491
|
-
|
|
492
|
-
#endif
|
|
493
|
-
#ifdef USE_ALPHAMAP
|
|
494
|
-
|
|
495
|
-
vAlphaMapUv = ( tileTransform * (alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) )).xy;
|
|
496
|
-
|
|
497
|
-
#endif
|
|
498
|
-
#ifdef USE_LIGHTMAP
|
|
499
|
-
|
|
500
|
-
vLightMapUv = ( tileTransform * (lightMapTransform * vec3( LIGHTMAP_UV, 1 ) )).xy;
|
|
501
|
-
|
|
502
|
-
#endif
|
|
503
|
-
#ifdef USE_AOMAP
|
|
504
|
-
|
|
505
|
-
vAoMapUv = ( tileTransform * (aoMapTransform * vec3( AOMAP_UV, 1 ) )).xy;
|
|
506
|
-
|
|
507
|
-
#endif
|
|
508
|
-
#ifdef USE_BUMPMAP
|
|
509
|
-
|
|
510
|
-
vBumpMapUv = ( tileTransform * (bumpMapTransform * vec3( BUMPMAP_UV, 1 ) )).xy;
|
|
511
|
-
|
|
512
|
-
#endif
|
|
513
|
-
#ifdef USE_NORMALMAP
|
|
514
|
-
|
|
515
|
-
vNormalMapUv = ( tileTransform * (normalMapTransform * vec3( NORMALMAP_UV, 1 ) )).xy;
|
|
516
|
-
|
|
517
|
-
#endif
|
|
518
|
-
#ifdef USE_DISPLACEMENTMAP
|
|
519
|
-
|
|
520
|
-
vDisplacementMapUv = ( tileTransform * (displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) )).xy;
|
|
521
|
-
|
|
522
|
-
#endif
|
|
523
|
-
#ifdef USE_EMISSIVEMAP
|
|
524
|
-
|
|
525
|
-
vEmissiveMapUv = ( tileTransform * (emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) )).xy;
|
|
526
|
-
|
|
527
|
-
#endif
|
|
528
|
-
#ifdef USE_METALNESSMAP
|
|
529
|
-
|
|
530
|
-
vMetalnessMapUv = ( tileTransform * (metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) )).xy;
|
|
531
|
-
|
|
532
|
-
#endif
|
|
533
|
-
#ifdef USE_ROUGHNESSMAP
|
|
534
|
-
|
|
535
|
-
vRoughnessMapUv = ( tileTransform * (roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) )).xy;
|
|
536
|
-
|
|
537
|
-
#endif
|
|
538
|
-
#ifdef USE_ANISOTROPYMAP
|
|
539
|
-
|
|
540
|
-
vAnisotropyMapUv = ( tileTransform * (anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) )).xy;
|
|
541
|
-
|
|
542
|
-
#endif
|
|
543
|
-
#ifdef USE_CLEARCOATMAP
|
|
544
|
-
|
|
545
|
-
vClearcoatMapUv = ( tileTransform * (clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) )).xy;
|
|
546
|
-
|
|
547
|
-
#endif
|
|
548
|
-
#ifdef USE_CLEARCOAT_NORMALMAP
|
|
549
|
-
|
|
550
|
-
vClearcoatNormalMapUv = ( tileTransform * (clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) )).xy;
|
|
551
|
-
|
|
552
|
-
#endif
|
|
553
|
-
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
|
|
554
|
-
|
|
555
|
-
vClearcoatRoughnessMapUv = ( tileTransform * (clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) )).xy;
|
|
556
|
-
|
|
557
|
-
#endif
|
|
558
|
-
#ifdef USE_IRIDESCENCEMAP
|
|
559
|
-
|
|
560
|
-
vIridescenceMapUv = ( tileTransform * (iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) )).xy;
|
|
561
|
-
|
|
562
|
-
#endif
|
|
563
|
-
#ifdef USE_IRIDESCENCE_THICKNESSMAP
|
|
564
|
-
|
|
565
|
-
vIridescenceThicknessMapUv = ( tileTransform * (iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) )).xy;
|
|
566
|
-
|
|
567
|
-
#endif
|
|
568
|
-
#ifdef USE_SHEEN_COLORMAP
|
|
569
|
-
|
|
570
|
-
vSheenColorMapUv = ( tileTransform * (sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) )).xy;
|
|
571
|
-
|
|
572
|
-
#endif
|
|
573
|
-
#ifdef USE_SHEEN_ROUGHNESSMAP
|
|
574
|
-
|
|
575
|
-
vSheenRoughnessMapUv = ( tileTransform * (sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) )).xy;
|
|
576
|
-
|
|
577
|
-
#endif
|
|
578
|
-
#ifdef USE_SPECULARMAP
|
|
579
|
-
|
|
580
|
-
vSpecularMapUv = ( tileTransform * (specularMapTransform * vec3( SPECULARMAP_UV, 1 ) )).xy;
|
|
581
|
-
|
|
582
|
-
#endif
|
|
583
|
-
#ifdef USE_SPECULAR_COLORMAP
|
|
584
|
-
|
|
585
|
-
vSpecularColorMapUv = ( tileTransform * (specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) )).xy;
|
|
586
|
-
|
|
587
|
-
#endif
|
|
588
|
-
#ifdef USE_SPECULAR_INTENSITYMAP
|
|
589
|
-
|
|
590
|
-
vSpecularIntensityMapUv = ( tileTransform * (specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) )).xy;
|
|
591
|
-
|
|
592
|
-
#endif
|
|
593
|
-
#ifdef USE_TRANSMISSIONMAP
|
|
594
|
-
|
|
595
|
-
vTransmissionMapUv = ( tileTransform * transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) )).xy;
|
|
596
|
-
|
|
597
|
-
#endif
|
|
598
|
-
#ifdef USE_THICKNESSMAP
|
|
599
|
-
|
|
600
|
-
vThicknessMapUv = ( tileTransform * thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) )).xy;
|
|
601
|
-
|
|
602
|
-
#endif
|
|
603
|
-
|
|
604
|
-
`;const he=M.ShaderChunk;function hl(){he.tile_pars_vertex=ll,he.tile_vertex=ul,he.tile_pars_fragment=cl,he.tile_fragment=al,he.soft_pars_vertex=sl,he.soft_vertex=ol,he.soft_pars_fragment=nl,he.soft_fragment=rl}class fl extends M.Object3D{constructor(t){super(),this.type="ParticleEmitter",this.system=t}clone(){const t=this.system.clone();return t.emitter.copy(this,!0),t.emitter}dispose(){}extractFromCache(t){const e=[];for(const i in t){const r=t[i];delete r.metadata,e.push(r)}return e}toJSON(t,e={}){const i=this.children;this.children=this.children.filter(s=>s.type!=="ParticleSystemPreview");const r=super.toJSON(t);return this.children=i,this.system!==null&&(r.object.ps=this.system.toJSON(t,e)),r}}exports.RenderMode=void 0;(function(n){n[n.BillBoard=0]="BillBoard",n[n.StretchedBillBoard=1]="StretchedBillBoard",n[n.Mesh=2]="Mesh",n[n.Trail=3]="Trail",n[n.HorizontalBillBoard=4]="HorizontalBillBoard",n[n.VerticalBillBoard=5]="VerticalBillBoard"})(exports.RenderMode||(exports.RenderMode={}));class oa extends M.Mesh{constructor(t){super(),this.type="VFXBatch",this.maxParticles=1e3,this.systems=new Set;const e=new M.Layers;e.mask=t.layers.mask;const i=t.material.clone();i.defines={},Object.assign(i.defines,t.material.defines),this.settings={instancingGeometry:t.instancingGeometry,renderMode:t.renderMode,renderOrder:t.renderOrder,material:i,uTileCount:t.uTileCount,vTileCount:t.vTileCount,blendTiles:t.blendTiles,softParticles:t.softParticles,softNearFade:t.softNearFade,softFarFade:t.softFarFade,layers:e},this.frustumCulled=!1,this.renderOrder=this.settings.renderOrder}addSystem(t){this.systems.add(t)}removeSystem(t){this.systems.delete(t)}applyDepthTexture(t){const e=this.material.uniforms.depthTexture;e&&e.value!==t&&(e.value=t,this.material.needsUpdate=!0)}}const dl=new B(0,0,1),hn=new J,pl=new B,ml=new B;new B;const js=60,yl=new M.PlaneGeometry(1,1,1,1);class Fr{set time(t){this.emissionState.time=t}get time(){return this.emissionState.time}get layers(){return this.rendererSettings.layers}get texture(){return this.rendererSettings.material.map}set texture(t){this.rendererSettings.material.map=t,this.neededToUpdateRender=!0}get material(){return this.rendererSettings.material}set material(t){this.rendererSettings.material=t,this.neededToUpdateRender=!0}get uTileCount(){return this.rendererSettings.uTileCount}set uTileCount(t){this.rendererSettings.uTileCount=t,this.neededToUpdateRender=!0}get vTileCount(){return this.rendererSettings.vTileCount}set vTileCount(t){this.rendererSettings.vTileCount=t,this.neededToUpdateRender=!0}get blendTiles(){return this.rendererSettings.blendTiles}set blendTiles(t){this.rendererSettings.blendTiles=t,this.neededToUpdateRender=!0}get softParticles(){return this.rendererSettings.softParticles}set softParticles(t){this.rendererSettings.softParticles=t,this.neededToUpdateRender=!0}get softNearFade(){return this.rendererSettings.softNearFade}set softNearFade(t){this.rendererSettings.softNearFade=t,this.neededToUpdateRender=!0}get softFarFade(){return this.rendererSettings.softFarFade}set softFarFade(t){this.rendererSettings.softFarFade=t,this.neededToUpdateRender=!0}get instancingGeometry(){return this.rendererSettings.instancingGeometry}set instancingGeometry(t){this.restart(),this.particles.length=0,this.rendererSettings.instancingGeometry=t,this.neededToUpdateRender=!0}get renderMode(){return this.rendererSettings.renderMode}set renderMode(t){if((this.rendererSettings.renderMode!=exports.RenderMode.Trail&&t===exports.RenderMode.Trail||this.rendererSettings.renderMode==exports.RenderMode.Trail&&t!==exports.RenderMode.Trail)&&(this.restart(),this.particles.length=0),this.rendererSettings.renderMode!==t)switch(t){case exports.RenderMode.Trail:this.rendererEmitterSettings={startLength:new D(30),followLocalOrigin:!1};break;case exports.RenderMode.Mesh:this.rendererEmitterSettings={geometry:new M.PlaneGeometry(1,1)},this.startRotation=new Mi(new B(0,1,0),new D(0));break;case exports.RenderMode.StretchedBillBoard:this.rendererEmitterSettings={speedFactor:0,lengthFactor:2},this.rendererSettings.renderMode===exports.RenderMode.Mesh&&(this.startRotation=new D(0));break;case exports.RenderMode.BillBoard:case exports.RenderMode.VerticalBillBoard:case exports.RenderMode.HorizontalBillBoard:this.rendererEmitterSettings={},this.rendererSettings.renderMode===exports.RenderMode.Mesh&&(this.startRotation=new D(0));break}this.rendererSettings.renderMode=t,this.neededToUpdateRender=!0}get renderOrder(){return this.rendererSettings.renderOrder}set renderOrder(t){this.rendererSettings.renderOrder=t,this.neededToUpdateRender=!0}get blending(){return this.rendererSettings.material.blending}set blending(t){this.rendererSettings.material.blending=t,this.neededToUpdateRender=!0}constructor(t){var e,i,r,s,a,o,c,l,u,h,f,d,y,_,p,m,g,v,S,x,b,T,w,C,P,R;if(this.temp=new B,this.travelDistance=0,this.normalMatrix=new Xt,this.memory=[],this.listeners={},this.firstTimeUpdate=!0,this.autoDestroy=t.autoDestroy===void 0?!1:t.autoDestroy,this.duration=(e=t.duration)!==null&&e!==void 0?e:1,this.looping=t.looping===void 0?!0:t.looping,this.prewarm=t.prewarm===void 0?!1:t.prewarm,this.startLife=(i=t.startLife)!==null&&i!==void 0?i:new D(5),this.startSpeed=(r=t.startSpeed)!==null&&r!==void 0?r:new D(0),this.startRotation=(s=t.startRotation)!==null&&s!==void 0?s:new D(0),this.startSize=(a=t.startSize)!==null&&a!==void 0?a:new D(1),this.startColor=(o=t.startColor)!==null&&o!==void 0?o:new Re(new bt(1,1,1,1)),this.emissionOverTime=(c=t.emissionOverTime)!==null&&c!==void 0?c:new D(10),this.emissionOverDistance=(l=t.emissionOverDistance)!==null&&l!==void 0?l:new D(0),this.emissionBursts=(u=t.emissionBursts)!==null&&u!==void 0?u:[],this.onlyUsedByOther=(h=t.onlyUsedByOther)!==null&&h!==void 0?h:!1,this.emitterShape=(f=t.shape)!==null&&f!==void 0?f:new je,this.behaviors=(d=t.behaviors)!==null&&d!==void 0?d:new Array,this.worldSpace=(y=t.worldSpace)!==null&&y!==void 0?y:!1,this.rendererEmitterSettings=(_=t.rendererEmitterSettings)!==null&&_!==void 0?_:{},t.renderMode===exports.RenderMode.StretchedBillBoard){const E=this.rendererEmitterSettings;t.speedFactor!==void 0&&(E.speedFactor=t.speedFactor),E.speedFactor=(p=E.speedFactor)!==null&&p!==void 0?p:0,E.lengthFactor=(m=E.lengthFactor)!==null&&m!==void 0?m:0}this.rendererSettings={instancingGeometry:(g=t.instancingGeometry)!==null&&g!==void 0?g:yl,renderMode:(v=t.renderMode)!==null&&v!==void 0?v:exports.RenderMode.BillBoard,renderOrder:(S=t.renderOrder)!==null&&S!==void 0?S:0,material:t.material,uTileCount:(x=t.uTileCount)!==null&&x!==void 0?x:1,vTileCount:(b=t.vTileCount)!==null&&b!==void 0?b:1,blendTiles:(T=t.blendTiles)!==null&&T!==void 0?T:!1,softParticles:(w=t.softParticles)!==null&&w!==void 0?w:!1,softNearFade:(C=t.softNearFade)!==null&&C!==void 0?C:0,softFarFade:(P=t.softFarFade)!==null&&P!==void 0?P:0,layers:(R=t.layers)!==null&&R!==void 0?R:new M.Layers},this.neededToUpdateRender=!0,this.particles=new Array,this.startTileIndex=t.startTileIndex||new D(0),this.emitter=new fl(this),this.paused=!1,this.particleNum=0,this.emissionState={isBursting:!1,burstParticleIndex:0,burstParticleCount:0,burstIndex:0,burstWaveIndex:0,time:0,waitEmiting:0,travelDistance:0},this.emissionBursts.forEach(E=>E.count.startGen(this.memory)),this.emissionOverDistance.startGen(this.memory),this.emitEnded=!1,this.markForDestroy=!1,this.prewarmed=!1}pause(){this.paused=!0}play(){this.paused=!1}stop(){this.restart(),this.pause()}spawn(t,e,i){hn.setFromRotationMatrix(i);const r=pl,s=hn,a=ml;i.decompose(r,s,a);for(let o=0;o<t;o++){for(e.burstParticleIndex=o,this.particleNum++;this.particles.length<this.particleNum;)this.rendererSettings.renderMode===exports.RenderMode.Trail?this.particles.push(new Nr):this.particles.push(new qc);const c=this.particles[this.particleNum-1];if(c.reset(),c.speedModifier=1,this.startColor.startGen(c.memory),this.startColor.genColor(c.memory,c.startColor,this.emissionState.time),c.color.copy(c.startColor),this.startSpeed.startGen(c.memory),c.startSpeed=this.startSpeed.genValue(c.memory,e.time/this.duration),this.startLife.startGen(c.memory),c.life=this.startLife.genValue(c.memory,e.time/this.duration),c.age=0,this.startSize.startGen(c.memory),this.startSize.type==="vec3function")this.startSize.genValue(c.memory,c.startSize,e.time/this.duration);else{const l=this.startSize.genValue(c.memory,e.time/this.duration);c.startSize.set(l,l,l)}if(this.startTileIndex.startGen(c.memory),c.uvTile=this.startTileIndex.genValue(c.memory),c.size.copy(c.startSize),this.rendererSettings.renderMode===exports.RenderMode.Mesh||this.rendererSettings.renderMode===exports.RenderMode.BillBoard||this.rendererSettings.renderMode===exports.RenderMode.VerticalBillBoard||this.rendererSettings.renderMode===exports.RenderMode.HorizontalBillBoard||this.rendererSettings.renderMode===exports.RenderMode.StretchedBillBoard){const l=c;this.startRotation.startGen(c.memory),this.rendererSettings.renderMode===exports.RenderMode.Mesh?(l.rotation instanceof J||(l.rotation=new J),this.startRotation.type==="rotation"?this.startRotation.genValue(c.memory,l.rotation,1,e.time/this.duration):l.rotation.setFromAxisAngle(dl,this.startRotation.genValue(l.memory,e.time/this.duration))):this.startRotation.type==="rotation"?l.rotation=0:l.rotation=this.startRotation.genValue(l.memory,e.time/this.duration)}else if(this.rendererSettings.renderMode===exports.RenderMode.Trail){const l=c;this.rendererEmitterSettings.startLength.startGen(l.memory),l.length=this.rendererEmitterSettings.startLength.genValue(l.memory,e.time/this.duration)}if(this.emitterShape.initialize(c,e),this.rendererSettings.renderMode===exports.RenderMode.Trail&&this.rendererEmitterSettings.followLocalOrigin){const l=c;l.localPosition=new B().copy(l.position)}this.worldSpace?(c.position.applyMatrix4(i),c.startSize.multiply(a).abs(),c.size.copy(c.startSize),c.velocity.multiply(a).applyMatrix3(this.normalMatrix),c.rotation&&c.rotation instanceof J&&c.rotation.multiplyQuaternions(hn,c.rotation)):this.onlyUsedByOther&&(c.parentMatrix=i);for(let l=0;l<this.behaviors.length;l++)this.behaviors[l].initialize(c,this)}}endEmit(){this.emitEnded=!0,this.autoDestroy&&(this.markForDestroy=!0),this.fire({type:"emitEnd",particleSystem:this})}dispose(){this._renderer&&this._renderer.deleteSystem(this),this.emitter.dispose(),this.emitter.parent&&this.emitter.parent.remove(this.emitter),this.fire({type:"destroy",particleSystem:this})}restart(){this.memory.length=0,this.paused=!1,this.particleNum=0,this.emissionState.isBursting=!1,this.emissionState.burstIndex=0,this.emissionState.burstWaveIndex=0,this.emissionState.time=0,this.emissionState.waitEmiting=0,this.behaviors.forEach(t=>{t.reset()}),this.emitEnded=!1,this.markForDestroy=!1,this.prewarmed=!1,this.emissionBursts.forEach(t=>t.count.startGen(this.memory)),this.emissionOverDistance.startGen(this.memory)}update(t){if(this.paused)return;let e=this.emitter;for(;e.parent;)e=e.parent;if(e.type!=="Scene"){this.dispose();return}if(this.firstTimeUpdate&&(this.firstTimeUpdate=!1,this.emitter.updateWorldMatrix(!0,!1)),this.emitEnded&&this.particleNum===0){this.markForDestroy&&this.emitter.parent&&this.dispose();return}if(this.looping&&this.prewarm&&!this.prewarmed){this.prewarmed=!0;for(let i=0;i<this.duration*js;i++)this.update(1/js)}t>.1&&(t=.1),this.neededToUpdateRender&&(this._renderer&&this._renderer.updateSystem(this),this.neededToUpdateRender=!1),this.onlyUsedByOther||this.emit(t,this.emissionState,this.emitter.matrixWorld),this.emitterShape.update(this,t);for(let i=0;i<this.behaviors.length;i++){this.behaviors[i].frameUpdate(t);for(let r=0;r<this.particleNum;r++)this.particles[r].died||this.behaviors[i].update(this.particles[r],t)}for(let i=0;i<this.particleNum;i++)this.rendererEmitterSettings.followLocalOrigin&&this.particles[i].localPosition?(this.particles[i].position.copy(this.particles[i].localPosition),this.particles[i].parentMatrix?this.particles[i].position.applyMatrix4(this.particles[i].parentMatrix):this.particles[i].position.applyMatrix4(this.emitter.matrixWorld)):this.particles[i].position.addScaledVector(this.particles[i].velocity,t*this.particles[i].speedModifier),this.particles[i].age+=t;if(this.rendererSettings.renderMode===exports.RenderMode.Trail)for(let i=0;i<this.particleNum;i++)this.particles[i].update();for(let i=0;i<this.particleNum;i++){const r=this.particles[i];r.died&&(!(r instanceof Nr)||r.previous.length===0)&&(this.particles[i]=this.particles[this.particleNum-1],this.particles[this.particleNum-1]=r,this.particleNum--,i--,this.fire({type:"particleDied",particleSystem:this,particle:r}))}}emit(t,e,i){e.time>this.duration&&(this.looping?(e.time-=this.duration,e.burstIndex=0,this.behaviors.forEach(s=>{s.reset()})):!this.emitEnded&&!this.onlyUsedByOther&&this.endEmit()),this.normalMatrix.getNormalMatrix(i);const r=Math.ceil(e.waitEmiting);for(this.spawn(r,e,i),e.waitEmiting-=r;e.burstIndex<this.emissionBursts.length&&this.emissionBursts[e.burstIndex].time<=e.time;){if(Math.random()<this.emissionBursts[e.burstIndex].probability){const s=this.emissionBursts[e.burstIndex].count.genValue(this.memory,this.time);e.isBursting=!0,e.burstParticleCount=s,this.spawn(s,e,i),e.isBursting=!1}e.burstIndex++}if(!this.emitEnded&&(e.waitEmiting+=t*this.emissionOverTime.genValue(this.memory,e.time/this.duration),e.previousWorldPos!=null)){this.temp.set(i.elements[12],i.elements[13],i.elements[14]),e.travelDistance+=e.previousWorldPos.distanceTo(this.temp);const s=this.emissionOverDistance.genValue(this.memory,e.time/this.duration);if(e.travelDistance*s>0){const a=Math.floor(e.travelDistance*s);e.travelDistance-=a/s,e.waitEmiting+=a}}e.previousWorldPos===void 0&&(e.previousWorldPos=new B),e.previousWorldPos.set(i.elements[12],i.elements[13],i.elements[14]),e.time+=t}toJSON(t,e={}){var i;if((t===void 0||typeof t=="string")&&(t={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}}),t.materials[this.rendererSettings.material.uuid]=this.rendererSettings.material.toJSON(t),e.useUrlForImage&&((i=this.texture)===null||i===void 0?void 0:i.source)!==void 0){const o=this.texture.source;t.images[o.uuid]={uuid:o.uuid,url:this.texture.image.url}}let s;this.renderMode===exports.RenderMode.Trail?s={startLength:this.rendererEmitterSettings.startLength.toJSON(),followLocalOrigin:this.rendererEmitterSettings.followLocalOrigin}:this.renderMode===exports.RenderMode.Mesh?s={}:this.renderMode===exports.RenderMode.StretchedBillBoard?s={speedFactor:this.rendererEmitterSettings.speedFactor,lengthFactor:this.rendererEmitterSettings.lengthFactor}:s={};const a=this.rendererSettings.instancingGeometry;return t.geometries&&!t.geometries[a.uuid]&&(t.geometries[a.uuid]=a.toJSON()),{version:"3.0",autoDestroy:this.autoDestroy,looping:this.looping,prewarm:this.prewarm,duration:this.duration,shape:this.emitterShape.toJSON(),startLife:this.startLife.toJSON(),startSpeed:this.startSpeed.toJSON(),startRotation:this.startRotation.toJSON(),startSize:this.startSize.toJSON(),startColor:this.startColor.toJSON(),emissionOverTime:this.emissionOverTime.toJSON(),emissionOverDistance:this.emissionOverDistance.toJSON(),emissionBursts:this.emissionBursts.map(o=>({time:o.time,count:o.count.toJSON(),probability:o.probability,interval:o.interval,cycle:o.cycle})),onlyUsedByOther:this.onlyUsedByOther,instancingGeometry:this.rendererSettings.instancingGeometry.uuid,renderOrder:this.renderOrder,renderMode:this.renderMode,rendererEmitterSettings:s,material:this.rendererSettings.material.uuid,layers:this.layers.mask,startTileIndex:this.startTileIndex.toJSON(),uTileCount:this.uTileCount,vTileCount:this.vTileCount,blendTiles:this.blendTiles,softParticles:this.rendererSettings.softParticles,softFarFade:this.rendererSettings.softFarFade,softNearFade:this.rendererSettings.softNearFade,behaviors:this.behaviors.map(o=>o.toJSON()),worldSpace:this.worldSpace}}static fromJSON(t,e,i){var r,s;const a=jc(t.shape,e);let o;if(t.renderMode===exports.RenderMode.Trail){const u=t.rendererEmitterSettings;o={startLength:u.startLength!=null?N(u.startLength):new D(30),followLocalOrigin:u.followLocalOrigin}}else t.renderMode===exports.RenderMode.Mesh?o={}:t.renderMode===exports.RenderMode.StretchedBillBoard?(o=t.rendererEmitterSettings,t.speedFactor!=null&&(o.speedFactor=t.speedFactor)):o={};const c=new M.Layers;t.layers&&(c.mask=t.layers);const l=new Fr({autoDestroy:t.autoDestroy,looping:t.looping,prewarm:t.prewarm,duration:t.duration,shape:a,startLife:N(t.startLife),startSpeed:N(t.startSpeed),startRotation:Ur(t.startRotation),startSize:Ur(t.startSize),startColor:Kn(t.startColor),emissionOverTime:N(t.emissionOverTime),emissionOverDistance:N(t.emissionOverDistance),emissionBursts:(r=t.emissionBursts)===null||r===void 0?void 0:r.map(u=>{var h,f,d;return{time:u.time,count:typeof u.count=="number"?new D(u.count):N(u.count),probability:(h=u.probability)!==null&&h!==void 0?h:1,interval:(f=u.interval)!==null&&f!==void 0?f:.1,cycle:(d=u.cycle)!==null&&d!==void 0?d:1}}),onlyUsedByOther:t.onlyUsedByOther,instancingGeometry:e.geometries[t.instancingGeometry],renderMode:t.renderMode,rendererEmitterSettings:o,renderOrder:t.renderOrder,layers:c,material:t.material?e.materials[t.material]:t.texture?new M.MeshBasicMaterial({map:e.textures[t.texture],transparent:(s=t.transparent)!==null&&s!==void 0?s:!0,blending:t.blending,side:M.DoubleSide}):new M.MeshBasicMaterial({color:16777215,transparent:!0,blending:M.AdditiveBlending,side:M.DoubleSide}),startTileIndex:typeof t.startTileIndex=="number"?new D(t.startTileIndex):N(t.startTileIndex),uTileCount:t.uTileCount,vTileCount:t.vTileCount,blendTiles:t.blendTiles,softParticles:t.softParticles,softFarFade:t.softFarFade,softNearFade:t.softNearFade,behaviors:[],worldSpace:t.worldSpace});return l.behaviors=t.behaviors.map(u=>{const h=tl(u,l);return h.type==="EmitSubParticleSystem"&&(i[u.subParticleSystem]=h),h}),l}addBehavior(t){this.behaviors.push(t)}getRendererSettings(){return this.rendererSettings}addEventListener(t,e){this.listeners[t]||(this.listeners[t]=[]),this.listeners[t].push(e)}removeAllEventListeners(t){this.listeners[t]&&(this.listeners[t]=[])}removeEventListener(t,e){if(this.listeners[t]){const i=this.listeners[t].indexOf(e);i!==-1&&this.listeners[t].splice(i,1)}}fire(t){this.listeners[t.type]&&this.listeners[t.type].forEach(e=>e(t))}clone(){const t=[];for(const s of this.emissionBursts){const a={};Object.assign(a,s),t.push(a)}const e=[];for(const s of this.behaviors)e.push(s.clone());let i;this.renderMode===exports.RenderMode.Trail?i={startLength:this.rendererEmitterSettings.startLength.clone(),followLocalOrigin:this.rendererEmitterSettings.followLocalOrigin}:this.renderMode===exports.RenderMode.StretchedBillBoard?i={lengthFactor:this.rendererEmitterSettings.lengthFactor,speedFactor:this.rendererEmitterSettings.speedFactor}:i={};const r=new M.Layers;return r.mask=this.layers.mask,new Fr({autoDestroy:this.autoDestroy,looping:this.looping,duration:this.duration,shape:this.emitterShape.clone(),startLife:this.startLife.clone(),startSpeed:this.startSpeed.clone(),startRotation:this.startRotation.clone(),startSize:this.startSize.clone(),startColor:this.startColor.clone(),emissionOverTime:this.emissionOverTime.clone(),emissionOverDistance:this.emissionOverDistance.clone(),emissionBursts:t,onlyUsedByOther:this.onlyUsedByOther,instancingGeometry:this.rendererSettings.instancingGeometry,renderMode:this.renderMode,renderOrder:this.renderOrder,rendererEmitterSettings:i,material:this.rendererSettings.material,startTileIndex:this.startTileIndex,uTileCount:this.uTileCount,vTileCount:this.vTileCount,blendTiles:this.blendTiles,softParticles:this.softParticles,softFarFade:this.softFarFade,softNearFade:this.softNearFade,behaviors:e,worldSpace:this.worldSpace,layers:r})}}var fn=`
|
|
605
|
-
|
|
606
|
-
#include <common>
|
|
607
|
-
#include <color_pars_fragment>
|
|
608
|
-
#include <map_pars_fragment>
|
|
609
|
-
#include <logdepthbuf_pars_fragment>
|
|
610
|
-
#include <clipping_planes_pars_fragment>
|
|
611
|
-
#include <alphatest_pars_fragment>
|
|
612
|
-
|
|
613
|
-
#include <tile_pars_fragment>
|
|
614
|
-
#include <soft_pars_fragment>
|
|
615
|
-
|
|
616
|
-
void main() {
|
|
617
|
-
|
|
618
|
-
#include <clipping_planes_fragment>
|
|
619
|
-
|
|
620
|
-
vec3 outgoingLight = vec3( 0.0 );
|
|
621
|
-
vec4 diffuseColor = vColor;
|
|
622
|
-
|
|
623
|
-
#include <logdepthbuf_fragment>
|
|
624
|
-
|
|
625
|
-
#include <tile_fragment>
|
|
626
|
-
#include <alphatest_fragment>
|
|
627
|
-
|
|
628
|
-
outgoingLight = diffuseColor.rgb;
|
|
629
|
-
|
|
630
|
-
#ifdef USE_COLOR_AS_ALPHA
|
|
631
|
-
gl_FragColor = vec4( outgoingLight, diffuseColor.r );
|
|
632
|
-
#else
|
|
633
|
-
gl_FragColor = vec4( outgoingLight, diffuseColor.a );
|
|
634
|
-
#endif
|
|
635
|
-
|
|
636
|
-
#include <soft_fragment>
|
|
637
|
-
#include <tonemapping_fragment>
|
|
638
|
-
}
|
|
639
|
-
`,ts=`
|
|
640
|
-
#define STANDARD
|
|
641
|
-
|
|
642
|
-
#ifdef PHYSICAL
|
|
643
|
-
#define IOR
|
|
644
|
-
#define USE_SPECULAR
|
|
645
|
-
#endif
|
|
646
|
-
|
|
647
|
-
uniform vec3 diffuse;
|
|
648
|
-
uniform vec3 emissive;
|
|
649
|
-
uniform float roughness;
|
|
650
|
-
uniform float metalness;
|
|
651
|
-
uniform float opacity;
|
|
652
|
-
|
|
653
|
-
#ifdef IOR
|
|
654
|
-
uniform float ior;
|
|
655
|
-
#endif
|
|
656
|
-
|
|
657
|
-
#ifdef USE_SPECULAR
|
|
658
|
-
uniform float specularIntensity;
|
|
659
|
-
uniform vec3 specularColor;
|
|
660
|
-
|
|
661
|
-
#ifdef USE_SPECULAR_COLORMAP
|
|
662
|
-
uniform sampler2D specularColorMap;
|
|
663
|
-
#endif
|
|
664
|
-
|
|
665
|
-
#ifdef USE_SPECULAR_INTENSITYMAP
|
|
666
|
-
uniform sampler2D specularIntensityMap;
|
|
667
|
-
#endif
|
|
668
|
-
#endif
|
|
669
|
-
|
|
670
|
-
#ifdef USE_CLEARCOAT
|
|
671
|
-
uniform float clearcoat;
|
|
672
|
-
uniform float clearcoatRoughness;
|
|
673
|
-
#endif
|
|
674
|
-
|
|
675
|
-
#ifdef USE_DISPERSION
|
|
676
|
-
uniform float dispersion;
|
|
677
|
-
#endif
|
|
678
|
-
|
|
679
|
-
#ifdef USE_IRIDESCENCE
|
|
680
|
-
uniform float iridescence;
|
|
681
|
-
uniform float iridescenceIOR;
|
|
682
|
-
uniform float iridescenceThicknessMinimum;
|
|
683
|
-
uniform float iridescenceThicknessMaximum;
|
|
684
|
-
#endif
|
|
685
|
-
|
|
686
|
-
#ifdef USE_SHEEN
|
|
687
|
-
uniform vec3 sheenColor;
|
|
688
|
-
uniform float sheenRoughness;
|
|
689
|
-
|
|
690
|
-
#ifdef USE_SHEEN_COLORMAP
|
|
691
|
-
uniform sampler2D sheenColorMap;
|
|
692
|
-
#endif
|
|
693
|
-
|
|
694
|
-
#ifdef USE_SHEEN_ROUGHNESSMAP
|
|
695
|
-
uniform sampler2D sheenRoughnessMap;
|
|
696
|
-
#endif
|
|
697
|
-
#endif
|
|
698
|
-
|
|
699
|
-
#ifdef USE_ANISOTROPY
|
|
700
|
-
uniform vec2 anisotropyVector;
|
|
701
|
-
|
|
702
|
-
#ifdef USE_ANISOTROPYMAP
|
|
703
|
-
uniform sampler2D anisotropyMap;
|
|
704
|
-
#endif
|
|
705
|
-
#endif
|
|
706
|
-
|
|
707
|
-
varying vec3 vViewPosition;
|
|
708
|
-
|
|
709
|
-
#include <common>
|
|
710
|
-
#include <packing>
|
|
711
|
-
#include <dithering_pars_fragment>
|
|
712
|
-
#include <color_pars_fragment>
|
|
713
|
-
#include <uv_pars_fragment>
|
|
714
|
-
#include <map_pars_fragment>
|
|
715
|
-
#include <alphamap_pars_fragment>
|
|
716
|
-
#include <alphatest_pars_fragment>
|
|
717
|
-
#include <alphahash_pars_fragment>
|
|
718
|
-
#include <aomap_pars_fragment>
|
|
719
|
-
#include <lightmap_pars_fragment>
|
|
720
|
-
#include <emissivemap_pars_fragment>
|
|
721
|
-
#include <iridescence_fragment>
|
|
722
|
-
#include <cube_uv_reflection_fragment>
|
|
723
|
-
#include <envmap_common_pars_fragment>
|
|
724
|
-
#include <envmap_physical_pars_fragment>
|
|
725
|
-
#include <fog_pars_fragment>
|
|
726
|
-
#include <lights_pars_begin>
|
|
727
|
-
#include <normal_pars_fragment>
|
|
728
|
-
#include <lights_physical_pars_fragment>
|
|
729
|
-
#include <transmission_pars_fragment>
|
|
730
|
-
#include <shadowmap_pars_fragment>
|
|
731
|
-
#include <bumpmap_pars_fragment>
|
|
732
|
-
#include <normalmap_pars_fragment>
|
|
733
|
-
#include <clearcoat_pars_fragment>
|
|
734
|
-
#include <iridescence_pars_fragment>
|
|
735
|
-
#include <roughnessmap_pars_fragment>
|
|
736
|
-
#include <metalnessmap_pars_fragment>
|
|
737
|
-
#include <logdepthbuf_pars_fragment>
|
|
738
|
-
#include <clipping_planes_pars_fragment>
|
|
739
|
-
|
|
740
|
-
void main() {
|
|
741
|
-
|
|
742
|
-
vec4 diffuseColor = vec4( diffuse, opacity );
|
|
743
|
-
#include <clipping_planes_fragment>
|
|
744
|
-
|
|
745
|
-
ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
|
|
746
|
-
vec3 totalEmissiveRadiance = emissive;
|
|
747
|
-
|
|
748
|
-
#include <logdepthbuf_fragment>
|
|
749
|
-
#include <map_fragment>
|
|
750
|
-
#include <color_fragment>
|
|
751
|
-
#include <alphamap_fragment>
|
|
752
|
-
#include <alphatest_fragment>
|
|
753
|
-
#include <alphahash_fragment>
|
|
754
|
-
#include <roughnessmap_fragment>
|
|
755
|
-
#include <metalnessmap_fragment>
|
|
756
|
-
#include <normal_fragment_begin>
|
|
757
|
-
#include <normal_fragment_maps>
|
|
758
|
-
#include <clearcoat_normal_fragment_begin>
|
|
759
|
-
#include <clearcoat_normal_fragment_maps>
|
|
760
|
-
#include <emissivemap_fragment>
|
|
761
|
-
|
|
762
|
-
// accumulation
|
|
763
|
-
#include <lights_physical_fragment>
|
|
764
|
-
#include <lights_fragment_begin>
|
|
765
|
-
#include <lights_fragment_maps>
|
|
766
|
-
#include <lights_fragment_end>
|
|
767
|
-
|
|
768
|
-
// modulation
|
|
769
|
-
#include <aomap_fragment>
|
|
770
|
-
|
|
771
|
-
vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;
|
|
772
|
-
vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;
|
|
773
|
-
|
|
774
|
-
#include <transmission_fragment>
|
|
775
|
-
|
|
776
|
-
vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;
|
|
777
|
-
|
|
778
|
-
#ifdef USE_SHEEN
|
|
779
|
-
|
|
780
|
-
// Sheen energy compensation approximation calculation can be found at the end of
|
|
781
|
-
// https://drive.google.com/file/d/1T0D1VSyR4AllqIJTQAraEIzjlb5h4FKH/view?usp=sharing
|
|
782
|
-
float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );
|
|
783
|
-
|
|
784
|
-
outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect;
|
|
785
|
-
|
|
786
|
-
#endif
|
|
787
|
-
|
|
788
|
-
#ifdef USE_CLEARCOAT
|
|
789
|
-
|
|
790
|
-
float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );
|
|
791
|
-
|
|
792
|
-
vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );
|
|
793
|
-
|
|
794
|
-
outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;
|
|
795
|
-
|
|
796
|
-
#endif
|
|
797
|
-
|
|
798
|
-
#include <opaque_fragment>
|
|
799
|
-
#include <tonemapping_fragment>
|
|
800
|
-
#include <colorspace_fragment>
|
|
801
|
-
#include <fog_fragment>
|
|
802
|
-
#include <premultiplied_alpha_fragment>
|
|
803
|
-
#include <dithering_fragment>
|
|
804
|
-
}`,gl=`
|
|
805
|
-
#include <common>
|
|
806
|
-
#include <color_pars_vertex>
|
|
807
|
-
#include <logdepthbuf_pars_vertex>
|
|
808
|
-
#include <clipping_planes_pars_vertex>
|
|
809
|
-
|
|
810
|
-
#include <tile_pars_vertex>
|
|
811
|
-
#include <soft_pars_vertex>
|
|
812
|
-
|
|
813
|
-
attribute vec3 offset;
|
|
814
|
-
attribute float rotation;
|
|
815
|
-
attribute vec3 size;
|
|
816
|
-
|
|
817
|
-
void main() {
|
|
818
|
-
|
|
819
|
-
vec2 alignedPosition = position.xy * size.xy;
|
|
820
|
-
|
|
821
|
-
vec2 rotatedPosition;
|
|
822
|
-
rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;
|
|
823
|
-
rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;
|
|
824
|
-
#ifdef HORIZONTAL
|
|
825
|
-
vec4 mvPosition = modelMatrix * vec4( offset, 1.0 );
|
|
826
|
-
mvPosition.x += rotatedPosition.x;
|
|
827
|
-
mvPosition.z -= rotatedPosition.y;
|
|
828
|
-
mvPosition = viewMatrix * mvPosition;
|
|
829
|
-
#elif defined(VERTICAL)
|
|
830
|
-
vec4 mvPosition = modelMatrix * vec4( offset, 1.0 );
|
|
831
|
-
mvPosition.y += rotatedPosition.y;
|
|
832
|
-
mvPosition = viewMatrix * mvPosition;
|
|
833
|
-
mvPosition.x += rotatedPosition.x;
|
|
834
|
-
#else
|
|
835
|
-
vec4 mvPosition = modelViewMatrix * vec4( offset, 1.0 );
|
|
836
|
-
mvPosition.xy += rotatedPosition;
|
|
837
|
-
#endif
|
|
838
|
-
|
|
839
|
-
vColor = color;
|
|
840
|
-
|
|
841
|
-
gl_Position = projectionMatrix * mvPosition;
|
|
842
|
-
|
|
843
|
-
#include <logdepthbuf_vertex>
|
|
844
|
-
|
|
845
|
-
#include <clipping_planes_vertex>
|
|
846
|
-
|
|
847
|
-
#include <tile_vertex>
|
|
848
|
-
#include <soft_vertex>
|
|
849
|
-
}
|
|
850
|
-
`,vl=`
|
|
851
|
-
#include <common>
|
|
852
|
-
#include <color_pars_vertex>
|
|
853
|
-
#include <logdepthbuf_pars_vertex>
|
|
854
|
-
#include <clipping_planes_pars_vertex>
|
|
855
|
-
#include <tile_pars_vertex>
|
|
856
|
-
#include <soft_pars_vertex>
|
|
857
|
-
|
|
858
|
-
attribute vec3 offset;
|
|
859
|
-
attribute vec4 rotation;
|
|
860
|
-
attribute vec3 size;
|
|
861
|
-
// attribute vec4 color;
|
|
862
|
-
|
|
863
|
-
void main() {
|
|
864
|
-
|
|
865
|
-
float x2 = rotation.x + rotation.x, y2 = rotation.y + rotation.y, z2 = rotation.z + rotation.z;
|
|
866
|
-
float xx = rotation.x * x2, xy = rotation.x * y2, xz = rotation.x * z2;
|
|
867
|
-
float yy = rotation.y * y2, yz = rotation.y * z2, zz = rotation.z * z2;
|
|
868
|
-
float wx = rotation.w * x2, wy = rotation.w * y2, wz = rotation.w * z2;
|
|
869
|
-
float sx = size.x, sy = size.y, sz = size.z;
|
|
870
|
-
|
|
871
|
-
mat4 matrix = mat4(( 1.0 - ( yy + zz ) ) * sx, ( xy + wz ) * sx, ( xz - wy ) * sx, 0.0, // 1. column
|
|
872
|
-
( xy - wz ) * sy, ( 1.0 - ( xx + zz ) ) * sy, ( yz + wx ) * sy, 0.0, // 2. column
|
|
873
|
-
( xz + wy ) * sz, ( yz - wx ) * sz, ( 1.0 - ( xx + yy ) ) * sz, 0.0, // 3. column
|
|
874
|
-
offset.x, offset.y, offset.z, 1.0);
|
|
875
|
-
|
|
876
|
-
vec4 mvPosition = modelViewMatrix * (matrix * vec4( position, 1.0 ));
|
|
877
|
-
|
|
878
|
-
vColor = color;
|
|
879
|
-
|
|
880
|
-
gl_Position = projectionMatrix * mvPosition;
|
|
881
|
-
|
|
882
|
-
#include <logdepthbuf_vertex>
|
|
883
|
-
#include <clipping_planes_vertex>
|
|
884
|
-
#include <tile_vertex>
|
|
885
|
-
#include <soft_vertex>
|
|
886
|
-
}
|
|
887
|
-
`,es=`
|
|
888
|
-
#define STANDARD
|
|
889
|
-
varying vec3 vViewPosition;
|
|
890
|
-
#ifdef USE_TRANSMISSION
|
|
891
|
-
varying vec3 vWorldPosition;
|
|
892
|
-
#endif
|
|
893
|
-
#include <common>
|
|
894
|
-
|
|
895
|
-
attribute vec3 offset;
|
|
896
|
-
attribute vec4 rotation;
|
|
897
|
-
attribute vec3 size;
|
|
898
|
-
#include <tile_pars_vertex>
|
|
899
|
-
#include <displacementmap_pars_vertex>
|
|
900
|
-
#include <color_pars_vertex>
|
|
901
|
-
#include <fog_pars_vertex>
|
|
902
|
-
#include <normal_pars_vertex>
|
|
903
|
-
#include <morphtarget_pars_vertex>
|
|
904
|
-
#include <skinning_pars_vertex>
|
|
905
|
-
#include <shadowmap_pars_vertex>
|
|
906
|
-
#include <logdepthbuf_pars_vertex>
|
|
907
|
-
#include <clipping_planes_pars_vertex>
|
|
908
|
-
|
|
909
|
-
void main() {
|
|
910
|
-
|
|
911
|
-
#include <tile_vertex>
|
|
912
|
-
float x2 = rotation.x + rotation.x, y2 = rotation.y + rotation.y, z2 = rotation.z + rotation.z;
|
|
913
|
-
float xx = rotation.x * x2, xy = rotation.x * y2, xz = rotation.x * z2;
|
|
914
|
-
float yy = rotation.y * y2, yz = rotation.y * z2, zz = rotation.z * z2;
|
|
915
|
-
float wx = rotation.w * x2, wy = rotation.w * y2, wz = rotation.w * z2;
|
|
916
|
-
float sx = size.x, sy = size.y, sz = size.z;
|
|
917
|
-
|
|
918
|
-
mat4 particleMatrix = mat4(( 1.0 - ( yy + zz ) ) * sx, ( xy + wz ) * sx, ( xz - wy ) * sx, 0.0, // 1. column
|
|
919
|
-
( xy - wz ) * sy, ( 1.0 - ( xx + zz ) ) * sy, ( yz + wx ) * sy, 0.0, // 2. column
|
|
920
|
-
( xz + wy ) * sz, ( yz - wx ) * sz, ( 1.0 - ( xx + yy ) ) * sz, 0.0, // 3. column
|
|
921
|
-
offset.x, offset.y, offset.z, 1.0);
|
|
922
|
-
|
|
923
|
-
#include <color_vertex>
|
|
924
|
-
#include <morphinstance_vertex>
|
|
925
|
-
#include <morphcolor_vertex>
|
|
926
|
-
#include <batching_vertex>
|
|
927
|
-
|
|
928
|
-
#include <beginnormal_vertex>
|
|
929
|
-
#include <morphnormal_vertex>
|
|
930
|
-
#include <skinbase_vertex>
|
|
931
|
-
#include <skinnormal_vertex>
|
|
932
|
-
|
|
933
|
-
// replace defaultnormal_vertex
|
|
934
|
-
vec3 transformedNormal = objectNormal;
|
|
935
|
-
mat3 m = mat3( particleMatrix );
|
|
936
|
-
transformedNormal /= vec3( dot( m[ 0 ], m[ 0 ] ), dot( m[ 1 ], m[ 1 ] ), dot( m[ 2 ], m[ 2 ] ) );
|
|
937
|
-
transformedNormal = m * transformedNormal;
|
|
938
|
-
transformedNormal = normalMatrix * transformedNormal;
|
|
939
|
-
#ifdef FLIP_SIDED
|
|
940
|
-
transformedNormal = - transformedNormal;
|
|
941
|
-
#endif
|
|
942
|
-
#ifdef USE_TANGENT
|
|
943
|
-
vec3 transformedTangent = ( modelViewMatrix * vec4( objectTangent, 0.0 ) ).xyz;
|
|
944
|
-
#ifdef FLIP_SIDED
|
|
945
|
-
transformedTangent = - transformedTangent;
|
|
946
|
-
#endif
|
|
947
|
-
#endif
|
|
948
|
-
|
|
949
|
-
#include <normal_vertex>
|
|
950
|
-
#include <begin_vertex>
|
|
951
|
-
#include <morphtarget_vertex>
|
|
952
|
-
#include <skinning_vertex>
|
|
953
|
-
#include <displacementmap_vertex>
|
|
954
|
-
|
|
955
|
-
// replace include <project_vertex>
|
|
956
|
-
vec4 mvPosition = vec4( transformed, 1.0 );
|
|
957
|
-
mvPosition = modelViewMatrix * (particleMatrix * mvPosition);
|
|
958
|
-
gl_Position = projectionMatrix * mvPosition;
|
|
959
|
-
|
|
960
|
-
#include <logdepthbuf_vertex>
|
|
961
|
-
#include <clipping_planes_vertex>
|
|
962
|
-
|
|
963
|
-
vViewPosition = - mvPosition.xyz;
|
|
964
|
-
|
|
965
|
-
#include <worldpos_vertex>
|
|
966
|
-
#include <shadowmap_vertex>
|
|
967
|
-
#include <fog_vertex>
|
|
968
|
-
#ifdef USE_TRANSMISSION
|
|
969
|
-
vWorldPosition = worldPosition.xyz;
|
|
970
|
-
#endif
|
|
971
|
-
}
|
|
972
|
-
`,_l=`
|
|
973
|
-
#include <common>
|
|
974
|
-
#include <color_pars_vertex>
|
|
975
|
-
#include <logdepthbuf_pars_vertex>
|
|
976
|
-
#include <clipping_planes_pars_vertex>
|
|
977
|
-
|
|
978
|
-
#include <tile_pars_vertex>
|
|
979
|
-
#include <soft_pars_vertex>
|
|
980
|
-
|
|
981
|
-
attribute vec3 offset;
|
|
982
|
-
attribute float rotation;
|
|
983
|
-
attribute vec3 size;
|
|
984
|
-
attribute vec4 velocity;
|
|
985
|
-
|
|
986
|
-
uniform float speedFactor;
|
|
987
|
-
|
|
988
|
-
void main() {
|
|
989
|
-
float lengthFactor = velocity.w;
|
|
990
|
-
float avgSize = (size.x + size.y) * 0.5;
|
|
991
|
-
#ifdef USE_SKEW
|
|
992
|
-
vec4 mvPosition = modelViewMatrix * vec4( offset, 1.0 );
|
|
993
|
-
vec3 viewVelocity = normalMatrix * velocity.xyz;
|
|
994
|
-
|
|
995
|
-
vec3 scaledPos = vec3(position.xy * size.xy, position.z);
|
|
996
|
-
float vlength = length(viewVelocity);
|
|
997
|
-
vec3 projVelocity = dot(scaledPos, viewVelocity) * viewVelocity / vlength;
|
|
998
|
-
mvPosition.xyz += scaledPos + projVelocity * (speedFactor / avgSize + lengthFactor / vlength);
|
|
999
|
-
#else
|
|
1000
|
-
vec4 mvPosition = modelViewMatrix * vec4( offset, 1.0 );
|
|
1001
|
-
vec3 viewVelocity = normalMatrix * velocity.xyz;
|
|
1002
|
-
float vlength = length(viewVelocity);
|
|
1003
|
-
mvPosition.xyz += position.y * normalize(cross(mvPosition.xyz, viewVelocity)) * avgSize; // switch the cross to match unity implementation
|
|
1004
|
-
mvPosition.xyz -= (position.x + 0.5) * viewVelocity * (1.0 + lengthFactor / vlength) * avgSize; // minus position.x to match unity implementation
|
|
1005
|
-
#endif
|
|
1006
|
-
vColor = color;
|
|
1007
|
-
gl_Position = projectionMatrix * mvPosition;
|
|
1008
|
-
#include <logdepthbuf_vertex>
|
|
1009
|
-
#include <clipping_planes_vertex>
|
|
1010
|
-
#include <tile_vertex>
|
|
1011
|
-
#include <soft_vertex>
|
|
1012
|
-
}
|
|
1013
|
-
`;function Nn(n){return n===0?"uv":`uv${n}`}class xl extends M.MeshStandardMaterial{constructor(t){super(t)}onBeforeCompile(t,e){super.onBeforeCompile(t,e),t.vertexShader=es,t.fragmentShader=ts}}class Sl extends M.MeshPhysicalMaterial{constructor(t){super(t)}onBeforeCompile(t,e){super.onBeforeCompile(t,e),t.vertexShader=es,t.fragmentShader=ts}}class bl extends oa{constructor(t){super(t),this.vector_=new B,this.vector2_=new B,this.vector3_=new B,this.quaternion_=new J,this.quaternion2_=new J,this.quaternion3_=new J,this.rotationMat_=new Xt,this.rotationMat2_=new Xt,this.maxParticles=1e3,this.setupBuffers(),this.rebuildMaterial()}buildExpandableBuffers(){this.offsetBuffer=new M.InstancedBufferAttribute(new Float32Array(this.maxParticles*3),3),this.offsetBuffer.setUsage(M.DynamicDrawUsage),this.geometry.setAttribute("offset",this.offsetBuffer),this.colorBuffer=new M.InstancedBufferAttribute(new Float32Array(this.maxParticles*4),4),this.colorBuffer.setUsage(M.DynamicDrawUsage),this.geometry.setAttribute("color",this.colorBuffer),this.settings.renderMode===exports.RenderMode.Mesh?(this.rotationBuffer=new M.InstancedBufferAttribute(new Float32Array(this.maxParticles*4),4),this.rotationBuffer.setUsage(M.DynamicDrawUsage),this.geometry.setAttribute("rotation",this.rotationBuffer)):(this.settings.renderMode===exports.RenderMode.BillBoard||this.settings.renderMode===exports.RenderMode.HorizontalBillBoard||this.settings.renderMode===exports.RenderMode.VerticalBillBoard||this.settings.renderMode===exports.RenderMode.StretchedBillBoard)&&(this.rotationBuffer=new M.InstancedBufferAttribute(new Float32Array(this.maxParticles),1),this.rotationBuffer.setUsage(M.DynamicDrawUsage),this.geometry.setAttribute("rotation",this.rotationBuffer)),this.sizeBuffer=new M.InstancedBufferAttribute(new Float32Array(this.maxParticles*3),3),this.sizeBuffer.setUsage(M.DynamicDrawUsage),this.geometry.setAttribute("size",this.sizeBuffer),this.uvTileBuffer=new M.InstancedBufferAttribute(new Float32Array(this.maxParticles),1),this.uvTileBuffer.setUsage(M.DynamicDrawUsage),this.geometry.setAttribute("uvTile",this.uvTileBuffer),this.settings.renderMode===exports.RenderMode.StretchedBillBoard&&(this.velocityBuffer=new M.InstancedBufferAttribute(new Float32Array(this.maxParticles*4),4),this.velocityBuffer.setUsage(M.DynamicDrawUsage),this.geometry.setAttribute("velocity",this.velocityBuffer))}setupBuffers(){this.geometry&&this.geometry.dispose(),this.geometry=new M.InstancedBufferGeometry,this.geometry.setIndex(this.settings.instancingGeometry.getIndex()),this.settings.instancingGeometry.hasAttribute("normal")&&this.geometry.setAttribute("normal",this.settings.instancingGeometry.getAttribute("normal")),this.geometry.setAttribute("position",this.settings.instancingGeometry.getAttribute("position")),this.geometry.setAttribute("uv",this.settings.instancingGeometry.getAttribute("uv")),this.buildExpandableBuffers()}expandBuffers(t){for(;t>=this.maxParticles;)this.maxParticles*=2;this.setupBuffers()}rebuildMaterial(){this.layers.mask=this.settings.layers.mask;const t={},e={};this.settings.material.type!=="MeshStandardMaterial"&&this.settings.material.type!=="MeshPhysicalMaterial"&&(t.map=new M.Uniform$1(this.settings.material.map)),this.settings.material.alphaTest&&(e.USE_ALPHATEST="",t.alphaTest=new M.Uniform$1(this.settings.material.alphaTest)),e.USE_UV="";const i=this.settings.uTileCount,r=this.settings.vTileCount;(i>1||r>1)&&(e.UV_TILE="",t.tileCount=new M.Uniform$1(new Je(i,r))),this.settings.material.defines&&this.settings.material.defines.USE_COLOR_AS_ALPHA!==void 0&&(e.USE_COLOR_AS_ALPHA=""),this.settings.material.normalMap&&(e.USE_NORMALMAP="",e.NORMALMAP_UV=Nn(this.settings.material.normalMap.channel),t.normalMapTransform=new M.Uniform$1(new Xt().copy(this.settings.material.normalMap.matrix))),this.settings.material.map&&(e.USE_MAP="",this.settings.blendTiles&&(e.TILE_BLEND=""),e.MAP_UV=Nn(this.settings.material.map.channel),t.mapTransform=new M.Uniform$1(new Xt().copy(this.settings.material.map.matrix))),e.USE_COLOR_ALPHA="";let s;if(this.settings.softParticles){e.SOFT_PARTICLES="";const o=this.settings.softNearFade,c=1/(this.settings.softFarFade-this.settings.softNearFade);t.softParams=new M.Uniform$1(new Je(o,c)),t.depthTexture=new M.Uniform$1(null);const l=t.projParams=new M.Uniform$1(new bt);s=(u,h,f)=>{l.value.set(f.near,f.far,0,0)}}let a=!1;if(this.settings.renderMode===exports.RenderMode.BillBoard||this.settings.renderMode===exports.RenderMode.VerticalBillBoard||this.settings.renderMode===exports.RenderMode.HorizontalBillBoard||this.settings.renderMode===exports.RenderMode.Mesh){let o,c;this.settings.renderMode===exports.RenderMode.Mesh?this.settings.material.type==="MeshStandardMaterial"||this.settings.material.type==="MeshPhysicalMaterial"?(e.USE_COLOR="",o=es,c=ts,a=!0):(o=vl,c=fn):(o=gl,c=fn),this.settings.renderMode===exports.RenderMode.VerticalBillBoard?e.VERTICAL="":this.settings.renderMode===exports.RenderMode.HorizontalBillBoard&&(e.HORIZONTAL="");let l=!1;this.settings.renderMode===exports.RenderMode.Mesh&&(this.settings.material.type==="MeshStandardMaterial"?(this.material=new xl({}),this.material.copy(this.settings.material),this.material.uniforms=t,this.material.defines=e,l=!0):this.settings.material.type==="MeshPhysicalMaterial"&&(this.material=new Sl({}),this.material.copy(this.settings.material),this.material.uniforms=t,this.material.defines=e,l=!0)),l||(this.material=new M.ShaderMaterial({uniforms:t,defines:e,vertexShader:o,fragmentShader:c,transparent:this.settings.material.transparent,depthWrite:!this.settings.material.transparent,blending:this.settings.material.blending,blendDst:this.settings.material.blendDst,blendSrc:this.settings.material.blendSrc,blendEquation:this.settings.material.blendEquation,premultipliedAlpha:this.settings.material.premultipliedAlpha,side:this.settings.material.side,alphaTest:this.settings.material.alphaTest,depthTest:this.settings.material.depthTest,lights:a}))}else if(this.settings.renderMode===exports.RenderMode.StretchedBillBoard)t.speedFactor=new M.Uniform$1(1),this.material=new M.ShaderMaterial({uniforms:t,defines:e,vertexShader:_l,fragmentShader:fn,transparent:this.settings.material.transparent,depthWrite:!this.settings.material.transparent,blending:this.settings.material.blending,blendDst:this.settings.material.blendDst,blendSrc:this.settings.material.blendSrc,blendEquation:this.settings.material.blendEquation,premultipliedAlpha:this.settings.material.premultipliedAlpha,side:this.settings.material.side,alphaTest:this.settings.material.alphaTest,depthTest:this.settings.material.depthTest});else throw new Error("render mode unavailable");this.material&&s&&(this.material.onBeforeRender=s)}update(){let t=0,e=0;this.systems.forEach(i=>{e+=i.particleNum}),e>this.maxParticles&&this.expandBuffers(e),this.systems.forEach(i=>{i.emitter.updateMatrixWorld&&(i.emitter.updateWorldMatrix(!0,!1),i.emitter.updateMatrixWorld(!0));const r=i.particles,s=i.particleNum,a=this.quaternion2_,o=this.vector2_,c=this.vector3_;i.emitter.matrixWorld.decompose(o,a,c),this.rotationMat_.setFromMatrix4(i.emitter.matrixWorld);for(let l=0;l<s;l++,t++){const u=r[l];if(this.settings.renderMode===exports.RenderMode.Mesh){let f;if(i.worldSpace)f=u.rotation;else{let d;u.parentMatrix?d=this.quaternion3_.setFromRotationMatrix(u.parentMatrix):d=a,f=this.quaternion_,f.copy(d).multiply(u.rotation)}this.rotationBuffer.setXYZW(t,f.x,f.y,f.z,f.w)}else(this.settings.renderMode===exports.RenderMode.StretchedBillBoard||this.settings.renderMode===exports.RenderMode.VerticalBillBoard||this.settings.renderMode===exports.RenderMode.HorizontalBillBoard||this.settings.renderMode===exports.RenderMode.BillBoard)&&this.rotationBuffer.setX(t,u.rotation);let h;if(i.worldSpace?h=u.position:(h=this.vector_,u.parentMatrix?h.copy(u.position).applyMatrix4(u.parentMatrix):h.copy(u.position).applyMatrix4(i.emitter.matrixWorld)),this.offsetBuffer.setXYZ(t,h.x,h.y,h.z),this.colorBuffer.setXYZW(t,u.color.x,u.color.y,u.color.z,u.color.w),i.worldSpace?this.sizeBuffer.setXYZ(t,u.size.x,u.size.y,u.size.z):u.parentMatrix?this.sizeBuffer.setXYZ(t,u.size.x,u.size.y,u.size.z):this.sizeBuffer.setXYZ(t,u.size.x*Math.abs(c.x),u.size.y*Math.abs(c.y),u.size.z*Math.abs(c.z)),this.uvTileBuffer.setX(t,u.uvTile),this.settings.renderMode===exports.RenderMode.StretchedBillBoard&&this.velocityBuffer){let f=i.rendererEmitterSettings.speedFactor;f===0&&(f=.001);const d=i.rendererEmitterSettings.lengthFactor;let y;i.worldSpace?y=u.velocity:(y=this.vector_,u.parentMatrix?(this.rotationMat2_.setFromMatrix4(u.parentMatrix),y.copy(u.velocity).applyMatrix3(this.rotationMat2_)):y.copy(u.velocity).applyMatrix3(this.rotationMat_)),this.velocityBuffer.setXYZW(t,y.x*f,y.y*f,y.z*f,d)}}}),this.geometry.instanceCount=t,t>0&&(this.offsetBuffer.clearUpdateRanges(),this.offsetBuffer.addUpdateRange(0,t*3),this.offsetBuffer.needsUpdate=!0,this.sizeBuffer.clearUpdateRanges(),this.sizeBuffer.addUpdateRange(0,t*3),this.sizeBuffer.needsUpdate=!0,this.colorBuffer.clearUpdateRanges(),this.colorBuffer.addUpdateRange(0,t*4),this.colorBuffer.needsUpdate=!0,this.uvTileBuffer.clearUpdateRanges(),this.uvTileBuffer.addUpdateRange(0,t),this.uvTileBuffer.needsUpdate=!0,this.settings.renderMode===exports.RenderMode.StretchedBillBoard&&this.velocityBuffer&&(this.velocityBuffer.clearUpdateRanges(),this.velocityBuffer.addUpdateRange(0,t*4),this.velocityBuffer.needsUpdate=!0),this.settings.renderMode===exports.RenderMode.Mesh?(this.rotationBuffer.clearUpdateRanges(),this.rotationBuffer.addUpdateRange(0,t*4),this.rotationBuffer.needsUpdate=!0):(this.settings.renderMode===exports.RenderMode.StretchedBillBoard||this.settings.renderMode===exports.RenderMode.HorizontalBillBoard||this.settings.renderMode===exports.RenderMode.VerticalBillBoard||this.settings.renderMode===exports.RenderMode.BillBoard)&&(this.rotationBuffer.clearUpdateRanges(),this.rotationBuffer.addUpdateRange(0,t),this.rotationBuffer.needsUpdate=!0))}dispose(){this.geometry.dispose()}}var Tl=`
|
|
1014
|
-
|
|
1015
|
-
#include <common>
|
|
1016
|
-
#include <tile_pars_fragment>
|
|
1017
|
-
#include <map_pars_fragment>
|
|
1018
|
-
#include <fog_pars_fragment>
|
|
1019
|
-
#include <logdepthbuf_pars_fragment>
|
|
1020
|
-
#include <clipping_planes_pars_fragment>
|
|
1021
|
-
|
|
1022
|
-
uniform sampler2D alphaMap;
|
|
1023
|
-
uniform float useAlphaMap;
|
|
1024
|
-
uniform float visibility;
|
|
1025
|
-
uniform float alphaTest;
|
|
1026
|
-
|
|
1027
|
-
varying vec4 vColor;
|
|
1028
|
-
|
|
1029
|
-
void main() {
|
|
1030
|
-
#include <clipping_planes_fragment>
|
|
1031
|
-
#include <logdepthbuf_fragment>
|
|
1032
|
-
|
|
1033
|
-
vec4 diffuseColor = vColor;
|
|
1034
|
-
|
|
1035
|
-
#ifdef USE_MAP
|
|
1036
|
-
#include <tile_fragment>
|
|
1037
|
-
#ifndef USE_COLOR_AS_ALPHA
|
|
1038
|
-
#endif
|
|
1039
|
-
#endif
|
|
1040
|
-
if( useAlphaMap == 1. ) diffuseColor.a *= texture2D( alphaMap, vUv).a;
|
|
1041
|
-
if( diffuseColor.a < alphaTest ) discard;
|
|
1042
|
-
gl_FragColor = diffuseColor;
|
|
1043
|
-
|
|
1044
|
-
#include <fog_fragment>
|
|
1045
|
-
#include <tonemapping_fragment>
|
|
1046
|
-
}`,Ml=`
|
|
1047
|
-
#include <common>
|
|
1048
|
-
#include <tile_pars_vertex>
|
|
1049
|
-
#include <color_pars_vertex>
|
|
1050
|
-
#include <clipping_planes_pars_vertex>
|
|
1051
|
-
#include <logdepthbuf_pars_vertex>
|
|
1052
|
-
#include <fog_pars_vertex>
|
|
1053
|
-
|
|
1054
|
-
attribute vec3 previous;
|
|
1055
|
-
attribute vec3 next;
|
|
1056
|
-
attribute float side;
|
|
1057
|
-
attribute float width;
|
|
1058
|
-
|
|
1059
|
-
uniform vec2 resolution;
|
|
1060
|
-
uniform float lineWidth;
|
|
1061
|
-
uniform float sizeAttenuation;
|
|
1062
|
-
|
|
1063
|
-
vec2 fix(vec4 i, float aspect) {
|
|
1064
|
-
vec2 res = i.xy / i.w;
|
|
1065
|
-
res.x *= aspect;
|
|
1066
|
-
return res;
|
|
1067
|
-
}
|
|
1068
|
-
|
|
1069
|
-
void main() {
|
|
1070
|
-
|
|
1071
|
-
#include <tile_vertex>
|
|
1072
|
-
|
|
1073
|
-
float aspect = resolution.x / resolution.y;
|
|
1074
|
-
|
|
1075
|
-
vColor = color;
|
|
1076
|
-
|
|
1077
|
-
mat4 m = projectionMatrix * modelViewMatrix;
|
|
1078
|
-
vec4 finalPosition = m * vec4( position, 1.0 );
|
|
1079
|
-
vec4 prevPos = m * vec4( previous, 1.0 );
|
|
1080
|
-
vec4 nextPos = m * vec4( next, 1.0 );
|
|
1081
|
-
|
|
1082
|
-
vec2 currentP = fix( finalPosition, aspect );
|
|
1083
|
-
vec2 prevP = fix( prevPos, aspect );
|
|
1084
|
-
vec2 nextP = fix( nextPos, aspect );
|
|
1085
|
-
|
|
1086
|
-
float w = lineWidth * width;
|
|
1087
|
-
|
|
1088
|
-
vec2 dir;
|
|
1089
|
-
if( nextP == currentP ) dir = normalize( currentP - prevP );
|
|
1090
|
-
else if( prevP == currentP ) dir = normalize( nextP - currentP );
|
|
1091
|
-
else {
|
|
1092
|
-
vec2 dir1 = normalize( currentP - prevP );
|
|
1093
|
-
vec2 dir2 = normalize( nextP - currentP );
|
|
1094
|
-
dir = normalize( dir1 + dir2 );
|
|
1095
|
-
|
|
1096
|
-
vec2 perp = vec2( -dir1.y, dir1.x );
|
|
1097
|
-
vec2 miter = vec2( -dir.y, dir.x );
|
|
1098
|
-
//w = clamp( w / dot( miter, perp ), 0., 4., * lineWidth * width );
|
|
1099
|
-
|
|
1100
|
-
}
|
|
1101
|
-
|
|
1102
|
-
//vec2 normal = ( cross( vec3( dir, 0. ) vec3( 0., 0., 1. ) ) ).xy;
|
|
1103
|
-
vec4 normal = vec4( -dir.y, dir.x, 0., 1. );
|
|
1104
|
-
normal.xy *= .5 * w;
|
|
1105
|
-
normal *= projectionMatrix;
|
|
1106
|
-
if( sizeAttenuation == 0. ) {
|
|
1107
|
-
normal.xy *= finalPosition.w;
|
|
1108
|
-
normal.xy /= ( vec4( resolution, 0., 1. ) * projectionMatrix ).xy;
|
|
1109
|
-
}
|
|
1110
|
-
|
|
1111
|
-
finalPosition.xy += normal.xy * side;
|
|
1112
|
-
|
|
1113
|
-
gl_Position = finalPosition;
|
|
1114
|
-
|
|
1115
|
-
#include <logdepthbuf_vertex>
|
|
1116
|
-
#include <clipping_planes_vertex>
|
|
1117
|
-
|
|
1118
|
-
vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );
|
|
1119
|
-
|
|
1120
|
-
#include <fog_vertex>
|
|
1121
|
-
}`;class Cl extends oa{constructor(t){super(t),this.vector_=new B,this.vector2_=new B,this.vector3_=new B,this.quaternion_=new J,this.maxParticles=1e4,this.setupBuffers(),this.rebuildMaterial()}setupBuffers(){this.geometry&&this.geometry.dispose(),this.geometry=new M.BufferGeometry,this.indexBuffer=new M.BufferAttribute(new Uint32Array(this.maxParticles*6),1),this.indexBuffer.setUsage(M.DynamicDrawUsage),this.geometry.setIndex(this.indexBuffer),this.positionBuffer=new M.BufferAttribute(new Float32Array(this.maxParticles*6),3),this.positionBuffer.setUsage(M.DynamicDrawUsage),this.geometry.setAttribute("position",this.positionBuffer),this.previousBuffer=new M.BufferAttribute(new Float32Array(this.maxParticles*6),3),this.previousBuffer.setUsage(M.DynamicDrawUsage),this.geometry.setAttribute("previous",this.previousBuffer),this.nextBuffer=new M.BufferAttribute(new Float32Array(this.maxParticles*6),3),this.nextBuffer.setUsage(M.DynamicDrawUsage),this.geometry.setAttribute("next",this.nextBuffer),this.widthBuffer=new M.BufferAttribute(new Float32Array(this.maxParticles*2),1),this.widthBuffer.setUsage(M.DynamicDrawUsage),this.geometry.setAttribute("width",this.widthBuffer),this.sideBuffer=new M.BufferAttribute(new Float32Array(this.maxParticles*2),1),this.sideBuffer.setUsage(M.DynamicDrawUsage),this.geometry.setAttribute("side",this.sideBuffer),this.uvBuffer=new M.BufferAttribute(new Float32Array(this.maxParticles*4),2),this.uvBuffer.setUsage(M.DynamicDrawUsage),this.geometry.setAttribute("uv",this.uvBuffer),this.colorBuffer=new M.BufferAttribute(new Float32Array(this.maxParticles*8),4),this.colorBuffer.setUsage(M.DynamicDrawUsage),this.geometry.setAttribute("color",this.colorBuffer)}expandBuffers(t){for(;t>=this.maxParticles;)this.maxParticles*=2;this.setupBuffers()}rebuildMaterial(){this.layers.mask=this.settings.layers.mask;const t={lineWidth:{value:1},map:{value:null},useMap:{value:0},alphaMap:{value:null},useAlphaMap:{value:0},resolution:{value:new Je(1,1)},sizeAttenuation:{value:1},visibility:{value:1},alphaTest:{value:0}},e={};if(e.USE_UV="",e.USE_COLOR_ALPHA="",this.settings.material.map&&(e.USE_MAP="",e.MAP_UV=Nn(this.settings.material.map.channel),t.map=new M.Uniform$1(this.settings.material.map),t.mapTransform=new M.Uniform$1(new Xt().copy(this.settings.material.map.matrix))),this.settings.material.defines&&this.settings.material.defines.USE_COLOR_AS_ALPHA!==void 0&&(e.USE_COLOR_AS_ALPHA=""),this.settings.renderMode===exports.RenderMode.Trail)this.material=new M.ShaderMaterial({uniforms:t,defines:e,vertexShader:Ml,fragmentShader:Tl,transparent:this.settings.material.transparent,depthWrite:!this.settings.material.transparent,side:this.settings.material.side,blending:this.settings.material.blending||M.AdditiveBlending,blendDst:this.settings.material.blendDst,blendSrc:this.settings.material.blendSrc,blendEquation:this.settings.material.blendEquation,premultipliedAlpha:this.settings.material.premultipliedAlpha});else throw new Error("render mode unavailable")}update(){let t=0,e=0,i=0;this.systems.forEach(r=>{for(let s=0;s<r.particleNum;s++)i+=r.particles[s].previous.length*2}),i>this.maxParticles&&this.expandBuffers(i),this.systems.forEach(r=>{r.emitter.updateMatrixWorld&&(r.emitter.updateWorldMatrix(!0,!1),r.emitter.updateMatrixWorld(!0));const s=this.quaternion_,a=this.vector2_,o=this.vector3_;r.emitter.matrixWorld.decompose(a,s,o);const c=r.particles,l=r.particleNum,u=this.settings.uTileCount,h=this.settings.vTileCount,f=1/u,d=1/h;for(let y=0;y<l;y++){const _=c[y],p=_.uvTile%h,m=Math.floor(_.uvTile/h+.001),g=_.previous.values();let v=g.next(),S=v.value,x=S;v.done||(v=g.next());let b;v.value!==void 0?b=v.value:b=x;for(let T=0;T<_.previous.length;T++,t+=2){if(this.positionBuffer.setXYZ(t,x.position.x,x.position.y,x.position.z),this.positionBuffer.setXYZ(t+1,x.position.x,x.position.y,x.position.z),r.worldSpace?(this.positionBuffer.setXYZ(t,x.position.x,x.position.y,x.position.z),this.positionBuffer.setXYZ(t+1,x.position.x,x.position.y,x.position.z)):(_.parentMatrix?this.vector_.copy(x.position).applyMatrix4(_.parentMatrix):this.vector_.copy(x.position).applyMatrix4(r.emitter.matrixWorld),this.positionBuffer.setXYZ(t,this.vector_.x,this.vector_.y,this.vector_.z),this.positionBuffer.setXYZ(t+1,this.vector_.x,this.vector_.y,this.vector_.z)),r.worldSpace?(this.previousBuffer.setXYZ(t,S.position.x,S.position.y,S.position.z),this.previousBuffer.setXYZ(t+1,S.position.x,S.position.y,S.position.z)):(_.parentMatrix?this.vector_.copy(S.position).applyMatrix4(_.parentMatrix):this.vector_.copy(S.position).applyMatrix4(r.emitter.matrixWorld),this.previousBuffer.setXYZ(t,this.vector_.x,this.vector_.y,this.vector_.z),this.previousBuffer.setXYZ(t+1,this.vector_.x,this.vector_.y,this.vector_.z)),r.worldSpace?(this.nextBuffer.setXYZ(t,b.position.x,b.position.y,b.position.z),this.nextBuffer.setXYZ(t+1,b.position.x,b.position.y,b.position.z)):(_.parentMatrix?this.vector_.copy(b.position).applyMatrix4(_.parentMatrix):this.vector_.copy(b.position).applyMatrix4(r.emitter.matrixWorld),this.nextBuffer.setXYZ(t,this.vector_.x,this.vector_.y,this.vector_.z),this.nextBuffer.setXYZ(t+1,this.vector_.x,this.vector_.y,this.vector_.z)),this.sideBuffer.setX(t,-1),this.sideBuffer.setX(t+1,1),r.worldSpace)this.widthBuffer.setX(t,x.size),this.widthBuffer.setX(t+1,x.size);else if(_.parentMatrix)this.widthBuffer.setX(t,x.size),this.widthBuffer.setX(t+1,x.size);else{const w=(Math.abs(o.x)+Math.abs(o.y)+Math.abs(o.z))/3;this.widthBuffer.setX(t,x.size*w),this.widthBuffer.setX(t+1,x.size*w)}this.uvBuffer.setXY(t,(T/_.previous.length+p)*f,(h-m-1)*d),this.uvBuffer.setXY(t+1,(T/_.previous.length+p)*f,(h-m)*d),this.colorBuffer.setXYZW(t,x.color.x,x.color.y,x.color.z,x.color.w),this.colorBuffer.setXYZW(t+1,x.color.x,x.color.y,x.color.z,x.color.w),T+1<_.previous.length&&(this.indexBuffer.setX(e*3,t),this.indexBuffer.setX(e*3+1,t+1),this.indexBuffer.setX(e*3+2,t+2),e++,this.indexBuffer.setX(e*3,t+2),this.indexBuffer.setX(e*3+1,t+1),this.indexBuffer.setX(e*3+2,t+3),e++),S=x,x=b,v.done||(v=g.next(),v.value!==void 0&&(b=v.value))}}}),this.positionBuffer.clearUpdateRanges(),this.positionBuffer.addUpdateRange(0,t*3),this.positionBuffer.needsUpdate=!0,this.previousBuffer.clearUpdateRanges(),this.previousBuffer.addUpdateRange(0,t*3),this.previousBuffer.needsUpdate=!0,this.nextBuffer.clearUpdateRanges(),this.nextBuffer.addUpdateRange(0,t*3),this.nextBuffer.needsUpdate=!0,this.sideBuffer.clearUpdateRanges(),this.sideBuffer.addUpdateRange(0,t),this.sideBuffer.needsUpdate=!0,this.widthBuffer.clearUpdateRanges(),this.widthBuffer.addUpdateRange(0,t),this.widthBuffer.needsUpdate=!0,this.uvBuffer.clearUpdateRanges(),this.uvBuffer.addUpdateRange(0,t*2),this.uvBuffer.needsUpdate=!0,this.colorBuffer.clearUpdateRanges(),this.colorBuffer.addUpdateRange(0,t*4),this.colorBuffer.needsUpdate=!0,this.indexBuffer.clearUpdateRanges(),this.indexBuffer.addUpdateRange(0,e*3),this.indexBuffer.needsUpdate=!0,this.geometry.setDrawRange(0,e*3)}dispose(){this.geometry.dispose()}}class Yi{get geometry(){return this._geometry}set geometry(t){if(this._geometry=t,t===void 0||typeof t=="string")return;const e=new M.Triangle;this._triangleIndexToArea.length=0;let i=0;if(!t.getIndex())return;const r=t.getIndex().array,s=r.length/3;this._triangleIndexToArea.push(0);for(let a=0;a<s;a++)e.setFromAttributeAndIndices(t.getAttribute("position"),r[a*3],r[a*3+1],r[a*3+2]),i+=e.getArea(),this._triangleIndexToArea.push(i);t.userData.triangleIndexToArea=this._triangleIndexToArea}constructor(t){this.type="mesh_surface",this._triangleIndexToArea=[],this._tempA=new M.Vector3,this._tempB=new M.Vector3,this._tempC=new M.Vector3,t&&(this.geometry=t)}initialize(t){const e=this._geometry;if(!e||e.getIndex()===null){t.position.set(0,0,0),t.velocity.set(0,0,1).multiplyScalar(t.startSpeed);return}const i=this._triangleIndexToArea.length-1;let r=0,s=i;const a=Math.random()*this._triangleIndexToArea[i];for(;r+1<s;){const d=Math.floor((r+s)/2);a<this._triangleIndexToArea[d]?s=d:r=d}let o=Math.random(),c=Math.random();o+c>1&&(o=1-o,c=1-c);const l=e.getIndex().array[r*3],u=e.getIndex().array[r*3+1],h=e.getIndex().array[r*3+2],f=e.getAttribute("position");this._tempA.fromBufferAttribute(f,l),this._tempB.fromBufferAttribute(f,u),this._tempC.fromBufferAttribute(f,h),this._tempB.sub(this._tempA),this._tempC.sub(this._tempA),this._tempA.addScaledVector(this._tempB,o).addScaledVector(this._tempC,c),t.position.copy(this._tempA),this._tempA.copy(this._tempB).cross(this._tempC).normalize(),t.velocity.copy(this._tempA).normalize().multiplyScalar(t.startSpeed)}toJSON(){return{type:"mesh_surface",mesh:this._geometry?this._geometry.uuid:""}}static fromJSON(t,e){return new Yi(e.geometries[t.geometry])}clone(){return new Yi(this._geometry)}update(t,e){}}il({id:"three.quarks",emitterShapes:[{type:"mesh_surface",params:[["geometry",["geometry"]]],constructor:Yi,loadJSON:Yi.fromJSON}],behaviors:[]});class is extends M.Object3D{constructor(){super(),this.batches=[],this.systemToBatchIndex=new Map,this.type="BatchedRenderer",this.depthTexture=null}static equals(t,e){return t.material.side===e.material.side&&t.material.blending===e.material.blending&&t.material.blendSrc===e.material.blendSrc&&t.material.blendDst===e.material.blendDst&&t.material.blendEquation===e.material.blendEquation&&t.material.premultipliedAlpha===e.material.premultipliedAlpha&&t.material.transparent===e.material.transparent&&t.material.depthTest===e.material.depthTest&&t.material.type===e.material.type&&t.material.alphaTest===e.material.alphaTest&&t.material.map===e.material.map&&t.renderMode===e.renderMode&&t.blendTiles===e.blendTiles&&t.softParticles===e.softParticles&&t.softFarFade===e.softFarFade&&t.softNearFade===e.softNearFade&&t.uTileCount===e.uTileCount&&t.vTileCount===e.vTileCount&&t.instancingGeometry===e.instancingGeometry&&t.renderOrder===e.renderOrder&&t.layers.mask===e.layers.mask}addSystem(t){t._renderer=this;const e=t.getRendererSettings();for(let r=0;r<this.batches.length;r++)if(is.equals(this.batches[r].settings,e)){this.batches[r].addSystem(t),this.systemToBatchIndex.set(t,r);return}let i;switch(e.renderMode){case exports.RenderMode.Trail:i=new Cl(e);break;case exports.RenderMode.Mesh:case exports.RenderMode.BillBoard:case exports.RenderMode.VerticalBillBoard:case exports.RenderMode.HorizontalBillBoard:case exports.RenderMode.StretchedBillBoard:i=new bl(e);break}this.depthTexture&&i.applyDepthTexture(this.depthTexture),i.addSystem(t),this.batches.push(i),this.systemToBatchIndex.set(t,this.batches.length-1),this.add(i)}deleteSystem(t){const e=this.systemToBatchIndex.get(t);e!=null&&(this.batches[e].removeSystem(t),this.systemToBatchIndex.delete(t))}setDepthTexture(t){this.depthTexture=t;for(const e of this.batches)e.applyDepthTexture(t)}updateSystem(t){this.deleteSystem(t),this.addSystem(t)}update(t){this.systemToBatchIndex.forEach((e,i)=>{i.update(t)});for(let e=0;e<this.batches.length;e++)this.batches[e].update()}}const Pl=is;hl();console.log("%c Particle system powered by three.quarks. https://quarks.art/","font-size: 14px; font-weight: bold;");const aa=Math.sqrt(5),wl=(aa-1)/4,at=(5-aa)/20,ar=n=>Math.floor(n)|0,cr=new Float64Array([0,1,1,1,0,1,1,-1,0,1,-1,1,0,1,-1,-1,0,-1,1,1,0,-1,1,-1,0,-1,-1,1,0,-1,-1,-1,1,0,1,1,1,0,1,-1,1,0,-1,1,1,0,-1,-1,-1,0,1,1,-1,0,1,-1,-1,0,-1,1,-1,0,-1,-1,1,1,0,1,1,1,0,-1,1,-1,0,1,1,-1,0,-1,-1,1,0,1,-1,1,0,-1,-1,-1,0,1,-1,-1,0,-1,1,1,1,0,1,1,-1,0,1,-1,1,0,1,-1,-1,0,-1,1,1,0,-1,1,-1,0,-1,-1,1,0,-1,-1,-1,0]);function El(n=Math.random){const t=Rl(n),e=new Float64Array(t).map(a=>cr[a%32*4]),i=new Float64Array(t).map(a=>cr[a%32*4+1]),r=new Float64Array(t).map(a=>cr[a%32*4+2]),s=new Float64Array(t).map(a=>cr[a%32*4+3]);return function(o,c,l,u){let h,f,d,y,_;const p=(o+c+l+u)*wl,m=ar(o+p),g=ar(c+p),v=ar(l+p),S=ar(u+p),x=(m+g+v+S)*at,b=m-x,T=g-x,w=v-x,C=S-x,P=o-b,R=c-T,E=l-w,A=u-C;let k=0,z=0,U=0,L=0;P>R?k++:z++,P>E?k++:U++,P>A?k++:L++,R>E?z++:U++,R>A?z++:L++,E>A?U++:L++;const I=k>=3?1:0,X=z>=3?1:0,Z=U>=3?1:0,it=L>=3?1:0,K=k>=2?1:0,pt=z>=2?1:0,mt=U>=2?1:0,rt=L>=2?1:0,W=k>=1?1:0,j=z>=1?1:0,Ht=U>=1?1:0,Ft=L>=1?1:0,Lt=P-I+at,Vt=R-X+at,vt=E-Z+at,At=A-it+at,_t=P-K+2*at,Yt=R-pt+2*at,Zt=E-mt+2*at,H=A-rt+2*at,Jt=P-W+3*at,Qt=R-j+3*at,ve=E-Ht+3*at,Kt=A-Ft+3*at,te=P-1+4*at,ee=R-1+4*at,ie=E-1+4*at,re=A-1+4*at,kt=m&255,zt=g&255,Ot=v&255,Bt=S&255;let V=.6-P*P-R*R-E*E-A*A;if(V<0)h=0;else{const q=kt+t[zt+t[Ot+t[Bt]]];V*=V,h=V*V*(e[q]*P+i[q]*R+r[q]*E+s[q]*A)}let We=.6-Lt*Lt-Vt*Vt-vt*vt-At*At;if(We<0)f=0;else{const q=kt+I+t[zt+X+t[Ot+Z+t[Bt+it]]];We*=We,f=We*We*(e[q]*Lt+i[q]*Vt+r[q]*vt+s[q]*At)}let He=.6-_t*_t-Yt*Yt-Zt*Zt-H*H;if(He<0)d=0;else{const q=kt+K+t[zt+pt+t[Ot+mt+t[Bt+rt]]];He*=He,d=He*He*(e[q]*_t+i[q]*Yt+r[q]*Zt+s[q]*H)}let Ye=.6-Jt*Jt-Qt*Qt-ve*ve-Kt*Kt;if(Ye<0)y=0;else{const q=kt+W+t[zt+j+t[Ot+Ht+t[Bt+Ft]]];Ye*=Ye,y=Ye*Ye*(e[q]*Jt+i[q]*Qt+r[q]*ve+s[q]*Kt)}let Ze=.6-te*te-ee*ee-ie*ie-re*re;if(Ze<0)_=0;else{const q=kt+1+t[zt+1+t[Ot+1+t[Bt+1]]];Ze*=Ze,_=Ze*Ze*(e[q]*te+i[q]*ee+r[q]*ie+s[q]*re)}return 27*(h+f+d+y+_)}}function Rl(n){const e=new Uint8Array(512);for(let i=0;i<512/2;i++)e[i]=i;for(let i=0;i<512/2-1;i++){const r=i+~~(n()*(256-i)),s=e[i];e[i]=e[r],e[r]=s}for(let i=256;i<512;i++)e[i]=e[i-256];return e}class Al{constructor(t,e){if(this._retries=0,!Number.isInteger(t)||t<0)throw new Error("Base must be a positive integer or zero");if(e!==void 0&&(!Number.isInteger(e)||e<0))throw new Error("ExpMax must be a undefined, a positive integer or zero");this.base=t,this.expMax=e,this.i=0}get retries(){return this._retries}get current(){return this.base*Math.pow(2,this.i)}next(){return this._retries++,this.i=this.expMax===void 0?this.i+1:Math.min(this.i+1,this.expMax),this.current}reset(){this._retries=0,this.i=0}}var G;(function(n){n.open="open",n.close="close",n.error="error",n.message="message",n.retry="retry",n.reconnect="reconnect"})(G||(G={}));class ca{constructor(t,e,i){var r,s,a,o,c,l,u,h,f,d,y,_,p,m,g;this._closedByUser=!1,this.handleOpenEvent=v=>this.handleEvent(G.open,v),this.handleErrorEvent=v=>this.handleEvent(G.error,v),this.handleCloseEvent=v=>this.handleEvent(G.close,v),this.handleMessageEvent=v=>this.handleEvent(G.message,v),this._url=t,this._protocols=e,this._options={buffer:i?.buffer,retry:{maxRetries:(r=i?.retry)===null||r===void 0?void 0:r.maxRetries,instantReconnect:(s=i?.retry)===null||s===void 0?void 0:s.instantReconnect,backoff:(a=i?.retry)===null||a===void 0?void 0:a.backoff},listeners:{open:[...(c=(o=i?.listeners)===null||o===void 0?void 0:o.open)!==null&&c!==void 0?c:[]],close:[...(u=(l=i?.listeners)===null||l===void 0?void 0:l.close)!==null&&u!==void 0?u:[]],error:[...(f=(h=i?.listeners)===null||h===void 0?void 0:h.error)!==null&&f!==void 0?f:[]],message:[...(y=(d=i?.listeners)===null||d===void 0?void 0:d.message)!==null&&y!==void 0?y:[]],retry:[...(p=(_=i?.listeners)===null||_===void 0?void 0:_.retry)!==null&&p!==void 0?p:[]],reconnect:[...(g=(m=i?.listeners)===null||m===void 0?void 0:m.reconnect)!==null&&g!==void 0?g:[]]}},this._underlyingWebsocket=this.tryConnect()}get url(){return this._url}get protocols(){return this._protocols}get buffer(){return this._options.buffer}get maxRetries(){return this._options.retry.maxRetries}get instantReconnect(){return this._options.retry.instantReconnect}get backoff(){return this._options.retry.backoff}get closedByUser(){return this._closedByUser}get lastConnection(){return this._lastConnection}get underlyingWebsocket(){return this._underlyingWebsocket}get readyState(){return this._underlyingWebsocket.readyState}get bufferedAmount(){return this._underlyingWebsocket.bufferedAmount}get extensions(){return this._underlyingWebsocket.extensions}get binaryType(){return this._underlyingWebsocket.binaryType}set binaryType(t){this._underlyingWebsocket.binaryType=t}send(t){this.closedByUser||(this._underlyingWebsocket.readyState===this._underlyingWebsocket.OPEN?this._underlyingWebsocket.send(t):this.buffer!==void 0&&this.buffer.add(t))}close(t,e){this.cancelScheduledConnectionRetry(),this._closedByUser=!0,this._underlyingWebsocket.close(t,e)}addEventListener(t,e,i){this._options.listeners[t].push({listener:e,options:i})}removeEventListener(t,e,i){const r=s=>s.listener!==e||s.options!==i;this._options.listeners[t]=this._options.listeners[t].filter(r)}tryConnect(){return this._underlyingWebsocket=new WebSocket(this.url,this.protocols),this._underlyingWebsocket.addEventListener(G.open,this.handleOpenEvent),this._underlyingWebsocket.addEventListener(G.close,this.handleCloseEvent),this._underlyingWebsocket.addEventListener(G.error,this.handleErrorEvent),this._underlyingWebsocket.addEventListener(G.message,this.handleMessageEvent),this._underlyingWebsocket}clearWebsocket(){this._underlyingWebsocket.removeEventListener(G.open,this.handleOpenEvent),this._underlyingWebsocket.removeEventListener(G.close,this.handleCloseEvent),this._underlyingWebsocket.removeEventListener(G.error,this.handleErrorEvent),this._underlyingWebsocket.removeEventListener(G.message,this.handleMessageEvent),this._underlyingWebsocket.close()}dispatchEvent(t,e){const i=this._options.listeners[t],r=[];i.forEach(({listener:s,options:a})=>{s(this,e),(a===void 0||a.once===void 0||!a.once)&&r.push({listener:s,options:a})}),this._options.listeners[t]=r}handleEvent(t,e){switch(t){case G.close:this.dispatchEvent(t,e),this.scheduleConnectionRetryIfNeeded();break;case G.open:if(this.backoff!==void 0&&this._lastConnection!==void 0){const i={retries:this.backoff.retries,lastConnection:new Date(this._lastConnection)},r=new CustomEvent(G.reconnect,{detail:i});this.dispatchEvent(G.reconnect,r),this.backoff.reset()}this._lastConnection=new Date,this.dispatchEvent(t,e),this.sendBufferedData();break;case G.retry:this.dispatchEvent(t,e),this.clearWebsocket(),this.tryConnect();break;default:this.dispatchEvent(t,e);break}}sendBufferedData(){if(this.buffer!==void 0)for(let t=this.buffer.read();t!==void 0;t=this.buffer.read())this.send(t)}scheduleConnectionRetryIfNeeded(){if(this.closedByUser||this.backoff===void 0)return;const t=i=>{const r=new CustomEvent(G.retry,{detail:i});this.handleEvent(G.retry,r)},e={backoff:this._options.retry.instantReconnect===!0?0:this.backoff.next(),retries:this._options.retry.instantReconnect===!0?0:this.backoff.retries,lastConnection:this._lastConnection};(this._options.retry.maxRetries===void 0||e.retries<=this._options.retry.maxRetries)&&(this.retryTimeout=globalThis.setTimeout(()=>t(e),e.backoff))}cancelScheduledConnectionRetry(){globalThis.clearTimeout(this.retryTimeout)}}class kl{constructor(t){this._url=t}get url(){return this._url}withProtocols(t){return this._protocols=t,this}get protocols(){return this._protocols}withMaxRetries(t){var e;return this._options=Object.assign(Object.assign({},this._options),{retry:Object.assign(Object.assign({},(e=this._options)===null||e===void 0?void 0:e.retry),{maxRetries:t})}),this}get maxRetries(){var t,e;return(e=(t=this._options)===null||t===void 0?void 0:t.retry)===null||e===void 0?void 0:e.maxRetries}withInstantReconnect(t){var e;return this._options=Object.assign(Object.assign({},this._options),{retry:Object.assign(Object.assign({},(e=this._options)===null||e===void 0?void 0:e.retry),{instantReconnect:t})}),this}get instantReconnect(){var t,e;return(e=(t=this._options)===null||t===void 0?void 0:t.retry)===null||e===void 0?void 0:e.instantReconnect}withBackoff(t){var e;return this._options=Object.assign(Object.assign({},this._options),{retry:Object.assign(Object.assign({},(e=this._options)===null||e===void 0?void 0:e.retry),{backoff:t})}),this}get backoff(){var t,e;return(e=(t=this._options)===null||t===void 0?void 0:t.retry)===null||e===void 0?void 0:e.backoff}withBuffer(t){return this._options=Object.assign(Object.assign({},this._options),{buffer:t}),this}get buffer(){var t;return(t=this._options)===null||t===void 0?void 0:t.buffer}onOpen(t,e){return this.addListener(G.open,t,e),this}onClose(t,e){return this.addListener(G.close,t,e),this}onError(t,e){return this.addListener(G.error,t,e),this}onMessage(t,e){return this.addListener(G.message,t,e),this}onRetry(t,e){return this.addListener(G.retry,t,e),this}onReconnect(t,e){return this.addListener(G.reconnect,t,e),this}build(){return new ca(this._url,this._protocols,this._options)}addListener(t,e,i){var r,s,a,o,c,l,u,h,f,d,y,_,p,m,g,v,S,x,b,T,w;return this._options=Object.assign(Object.assign({},this._options),{listeners:{open:(a=(s=(r=this._options)===null||r===void 0?void 0:r.listeners)===null||s===void 0?void 0:s.open)!==null&&a!==void 0?a:[],close:(l=(c=(o=this._options)===null||o===void 0?void 0:o.listeners)===null||c===void 0?void 0:c.close)!==null&&l!==void 0?l:[],error:(f=(h=(u=this._options)===null||u===void 0?void 0:u.listeners)===null||h===void 0?void 0:h.error)!==null&&f!==void 0?f:[],message:(_=(y=(d=this._options)===null||d===void 0?void 0:d.listeners)===null||y===void 0?void 0:y.message)!==null&&_!==void 0?_:[],retry:(g=(m=(p=this._options)===null||p===void 0?void 0:p.listeners)===null||m===void 0?void 0:m.retry)!==null&&g!==void 0?g:[],reconnect:(x=(S=(v=this._options)===null||v===void 0?void 0:v.listeners)===null||S===void 0?void 0:S.reconnect)!==null&&x!==void 0?x:[],[t]:[...(w=(T=(b=this._options)===null||b===void 0?void 0:b.listeners)===null||T===void 0?void 0:T[t])!==null&&w!==void 0?w:[],{listener:e,options:i}]}}),this}}const zl=Object.freeze(Object.defineProperty({__proto__:null,ExponentialBackoff:Al,Websocket:ca,WebsocketBuilder:kl,get WebsocketEvent(){return G}},Symbol.toStringTag,{value:"Module"})),rs=0,la=1,ua=2,Dn=2,dn=1.25,$s=1,mi=32,$r=65535,Ol=Math.pow(2,-24),pn=Symbol("SKIP_GENERATION");function Bl(n){return n.index?n.index.count:n.attributes.position.count}function Xe(n){return Bl(n)/3}function Il(n,t=ArrayBuffer){return n>65535?new Uint32Array(new t(4*n)):new Uint16Array(new t(2*n))}function Ul(n,t){if(!n.index){const e=n.attributes.position.count,i=t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,r=Il(e,i);n.setIndex(new M.BufferAttribute(r,1));for(let s=0;s<e;s++)r[s]=s}}function ha(n,t){const e=Xe(n),i=t||n.drawRange,r=i.start/3,s=(i.start+i.count)/3,a=Math.max(0,r),o=Math.min(e,s)-a;return[{offset:Math.floor(a),count:Math.floor(o)}]}function fa(n,t){if(!n.groups||!n.groups.length)return ha(n,t);const e=[],i=new Set,r=t||n.drawRange,s=r.start/3,a=(r.start+r.count)/3;for(const c of n.groups){const l=c.start/3,u=(c.start+c.count)/3;i.add(Math.max(s,l)),i.add(Math.min(a,u))}const o=Array.from(i.values()).sort((c,l)=>c-l);for(let c=0;c<o.length-1;c++){const l=o[c],u=o[c+1];e.push({offset:Math.floor(l),count:Math.floor(u-l)})}return e}function Nl(n,t){const e=Xe(n),i=fa(n,t).sort((a,o)=>a.offset-o.offset),r=i[i.length-1];r.count=Math.min(e-r.offset,r.count);let s=0;return i.forEach(({count:a})=>s+=a),e!==s}function mn(n,t,e,i,r){let s=1/0,a=1/0,o=1/0,c=-1/0,l=-1/0,u=-1/0,h=1/0,f=1/0,d=1/0,y=-1/0,_=-1/0,p=-1/0;for(let m=t*6,g=(t+e)*6;m<g;m+=6){const v=n[m+0],S=n[m+1],x=v-S,b=v+S;x<s&&(s=x),b>c&&(c=b),v<h&&(h=v),v>y&&(y=v);const T=n[m+2],w=n[m+3],C=T-w,P=T+w;C<a&&(a=C),P>l&&(l=P),T<f&&(f=T),T>_&&(_=T);const R=n[m+4],E=n[m+5],A=R-E,k=R+E;A<o&&(o=A),k>u&&(u=k),R<d&&(d=R),R>p&&(p=R)}i[0]=s,i[1]=a,i[2]=o,i[3]=c,i[4]=l,i[5]=u,r[0]=h,r[1]=f,r[2]=d,r[3]=y,r[4]=_,r[5]=p}function Dl(n,t=null,e=null,i=null){const r=n.attributes.position,s=n.index?n.index.array:null,a=Xe(n),o=r.normalized;let c;t===null?(c=new Float32Array(a*6),e=0,i=a):(c=t,e=e||0,i=i||a);const l=r.array,u=r.offset||0;let h=3;r.isInterleavedBufferAttribute&&(h=r.data.stride);const f=["getX","getY","getZ"];for(let d=e;d<e+i;d++){const y=d*3,_=d*6;let p=y+0,m=y+1,g=y+2;s&&(p=s[p],m=s[m],g=s[g]),o||(p=p*h+u,m=m*h+u,g=g*h+u);for(let v=0;v<3;v++){let S,x,b;o?(S=r[f[v]](p),x=r[f[v]](m),b=r[f[v]](g)):(S=l[p+v],x=l[m+v],b=l[g+v]);let T=S;x<T&&(T=x),b<T&&(T=b);let w=S;x>w&&(w=x),b>w&&(w=b);const C=(w-T)/2,P=v*2;c[_+P+0]=T+C,c[_+P+1]=C+(Math.abs(T)+C)*Ol}}return c}function Y(n,t,e){return e.min.x=t[n],e.min.y=t[n+1],e.min.z=t[n+2],e.max.x=t[n+3],e.max.y=t[n+4],e.max.z=t[n+5],e}function qs(n){let t=-1,e=-1/0;for(let i=0;i<3;i++){const r=n[i+3]-n[i];r>e&&(e=r,t=i)}return t}function Xs(n,t){t.set(n)}function Ws(n,t,e){let i,r;for(let s=0;s<3;s++){const a=s+3;i=n[s],r=t[s],e[s]=i<r?i:r,i=n[a],r=t[a],e[a]=i>r?i:r}}function lr(n,t,e){for(let i=0;i<3;i++){const r=t[n+2*i],s=t[n+2*i+1],a=r-s,o=r+s;a<e[i]&&(e[i]=a),o>e[i+3]&&(e[i+3]=o)}}function ei(n){const t=n[3]-n[0],e=n[4]-n[1],i=n[5]-n[2];return 2*(t*e+e*i+i*t)}const ne=32,Fl=(n,t)=>n.candidate-t.candidate,fe=new Array(ne).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),ur=new Float32Array(6);function Ll(n,t,e,i,r,s){let a=-1,o=0;if(s===rs)a=qs(t),a!==-1&&(o=(t[a]+t[a+3])/2);else if(s===la)a=qs(n),a!==-1&&(o=Vl(e,i,r,a));else if(s===ua){const c=ei(n);let l=dn*r;const u=i*6,h=(i+r)*6;for(let f=0;f<3;f++){const d=t[f],p=(t[f+3]-d)/ne;if(r<ne/4){const m=[...fe];m.length=r;let g=0;for(let S=u;S<h;S+=6,g++){const x=m[g];x.candidate=e[S+2*f],x.count=0;const{bounds:b,leftCacheBounds:T,rightCacheBounds:w}=x;for(let C=0;C<3;C++)w[C]=1/0,w[C+3]=-1/0,T[C]=1/0,T[C+3]=-1/0,b[C]=1/0,b[C+3]=-1/0;lr(S,e,b)}m.sort(Fl);let v=r;for(let S=0;S<v;S++){const x=m[S];for(;S+1<v&&m[S+1].candidate===x.candidate;)m.splice(S+1,1),v--}for(let S=u;S<h;S+=6){const x=e[S+2*f];for(let b=0;b<v;b++){const T=m[b];x>=T.candidate?lr(S,e,T.rightCacheBounds):(lr(S,e,T.leftCacheBounds),T.count++)}}for(let S=0;S<v;S++){const x=m[S],b=x.count,T=r-x.count,w=x.leftCacheBounds,C=x.rightCacheBounds;let P=0;b!==0&&(P=ei(w)/c);let R=0;T!==0&&(R=ei(C)/c);const E=$s+dn*(P*b+R*T);E<l&&(a=f,l=E,o=x.candidate)}}else{for(let v=0;v<ne;v++){const S=fe[v];S.count=0,S.candidate=d+p+v*p;const x=S.bounds;for(let b=0;b<3;b++)x[b]=1/0,x[b+3]=-1/0}for(let v=u;v<h;v+=6){let b=~~((e[v+2*f]-d)/p);b>=ne&&(b=ne-1);const T=fe[b];T.count++,lr(v,e,T.bounds)}const m=fe[ne-1];Xs(m.bounds,m.rightCacheBounds);for(let v=ne-2;v>=0;v--){const S=fe[v],x=fe[v+1];Ws(S.bounds,x.rightCacheBounds,S.rightCacheBounds)}let g=0;for(let v=0;v<ne-1;v++){const S=fe[v],x=S.count,b=S.bounds,w=fe[v+1].rightCacheBounds;x!==0&&(g===0?Xs(b,ur):Ws(b,ur,ur)),g+=x;let C=0,P=0;g!==0&&(C=ei(ur)/c);const R=r-g;R!==0&&(P=ei(w)/c);const E=$s+dn*(C*g+P*R);E<l&&(a=f,l=E,o=S.candidate)}}}}else console.warn(`MeshBVH: Invalid build strategy value ${s} used.`);return{axis:a,pos:o}}function Vl(n,t,e,i){let r=0;for(let s=t,a=t+e;s<a;s++)r+=n[s*6+i*2];return r/e}class yn{constructor(){this.boundingData=new Float32Array(6)}}function Jl(n,t,e,i,r,s){let a=i,o=i+r-1;const c=s.pos,l=s.axis*2;for(;;){for(;a<=o&&e[a*6+l]<c;)a++;for(;a<=o&&e[o*6+l]>=c;)o--;if(a<o){for(let u=0;u<3;u++){let h=t[a*3+u];t[a*3+u]=t[o*3+u],t[o*3+u]=h}for(let u=0;u<6;u++){let h=e[a*6+u];e[a*6+u]=e[o*6+u],e[o*6+u]=h}a++,o--}else return a}}function Gl(n,t,e,i,r,s){let a=i,o=i+r-1;const c=s.pos,l=s.axis*2;for(;;){for(;a<=o&&e[a*6+l]<c;)a++;for(;a<=o&&e[o*6+l]>=c;)o--;if(a<o){let u=n[a];n[a]=n[o],n[o]=u;for(let h=0;h<6;h++){let f=e[a*6+h];e[a*6+h]=e[o*6+h],e[o*6+h]=f}a++,o--}else return a}}function St(n,t){return t[n+15]===65535}function Mt(n,t){return t[n+6]}function Ct(n,t){return t[n+14]}function Pt(n){return n+8}function wt(n,t){return t[n+6]}function da(n,t){return t[n+7]}let pa,fi,Ar,ma;const jl=Math.pow(2,32);function Fn(n){return"count"in n?1:1+Fn(n.left)+Fn(n.right)}function $l(n,t,e){return pa=new Float32Array(e),fi=new Uint32Array(e),Ar=new Uint16Array(e),ma=new Uint8Array(e),Ln(n,t)}function Ln(n,t){const e=n/4,i=n/2,r="count"in t,s=t.boundingData;for(let a=0;a<6;a++)pa[e+a]=s[a];if(r)if(t.buffer){const a=t.buffer;ma.set(new Uint8Array(a),n);for(let o=n,c=n+a.byteLength;o<c;o+=mi){const l=o/2;St(l,Ar)||(fi[o/4+6]+=e)}return n+a.byteLength}else{const a=t.offset,o=t.count;return fi[e+6]=a,Ar[i+14]=o,Ar[i+15]=$r,n+mi}else{const a=t.left,o=t.right,c=t.splitAxis;let l;if(l=Ln(n+mi,a),l/4>jl)throw new Error("MeshBVH: Cannot store child pointer greater than 32 bits.");return fi[e+6]=l/4,l=Ln(l,o),fi[e+7]=c,l}}function ql(n,t){const e=(n.index?n.index.count:n.attributes.position.count)/3,i=e>2**16,r=i?4:2,s=t?new SharedArrayBuffer(e*r):new ArrayBuffer(e*r),a=i?new Uint32Array(s):new Uint16Array(s);for(let o=0,c=a.length;o<c;o++)a[o]=o;return a}function Xl(n,t,e,i,r){const{maxDepth:s,verbose:a,maxLeafTris:o,strategy:c,onProgress:l,indirect:u}=r,h=n._indirectBuffer,f=n.geometry,d=f.index?f.index.array:null,y=u?Gl:Jl,_=Xe(f),p=new Float32Array(6);let m=!1;const g=new yn;return mn(t,e,i,g.boundingData,p),S(g,e,i,p),g;function v(x){l&&l(x/_)}function S(x,b,T,w=null,C=0){if(!m&&C>=s&&(m=!0,a&&(console.warn(`MeshBVH: Max depth of ${s} reached when generating BVH. Consider increasing maxDepth.`),console.warn(f))),T<=o||C>=s)return v(b+T),x.offset=b,x.count=T,x;const P=Ll(x.boundingData,w,t,b,T,c);if(P.axis===-1)return v(b+T),x.offset=b,x.count=T,x;const R=y(h,d,t,b,T,P);if(R===b||R===b+T)v(b+T),x.offset=b,x.count=T;else{x.splitAxis=P.axis;const E=new yn,A=b,k=R-b;x.left=E,mn(t,A,k,E.boundingData,p),S(E,A,k,p,C+1);const z=new yn,U=R,L=T-k;x.right=z,mn(t,U,L,z.boundingData,p),S(z,U,L,p,C+1)}return x}}function Wl(n,t){const e=n.geometry;t.indirect&&(n._indirectBuffer=ql(e,t.useSharedArrayBuffer),Nl(e,t.range)&&!t.verbose&&console.warn('MeshBVH: Provided geometry contains groups or a range that do not fully span the vertex contents while using the "indirect" option. BVH may incorrectly report intersections on unrendered portions of the geometry.')),n._indirectBuffer||Ul(e,t);const i=t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,r=Dl(e),s=t.indirect?ha(e,t.range):fa(e,t.range);n._roots=s.map(a=>{const o=Xl(n,r,a.offset,a.count,t),c=Fn(o),l=new i(mi*c);return $l(0,o,l),l})}class le{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(t,e){let i=1/0,r=-1/0;for(let s=0,a=t.length;s<a;s++){const c=t[s][e];i=c<i?c:i,r=c>r?c:r}this.min=i,this.max=r}setFromPoints(t,e){let i=1/0,r=-1/0;for(let s=0,a=e.length;s<a;s++){const o=e[s],c=t.dot(o);i=c<i?c:i,r=c>r?c:r}this.min=i,this.max=r}isSeparated(t){return this.min>t.max||t.min>this.max}}le.prototype.setFromBox=(function(){const n=new M.Vector3;return function(e,i){const r=i.min,s=i.max;let a=1/0,o=-1/0;for(let c=0;c<=1;c++)for(let l=0;l<=1;l++)for(let u=0;u<=1;u++){n.x=r.x*c+s.x*(1-c),n.y=r.y*l+s.y*(1-l),n.z=r.z*u+s.z*(1-u);const h=e.dot(n);a=Math.min(h,a),o=Math.max(h,o)}this.min=a,this.max=o}})();const Hl=(function(){const n=new M.Vector3,t=new M.Vector3,e=new M.Vector3;return function(r,s,a){const o=r.start,c=n,l=s.start,u=t;e.subVectors(o,l),n.subVectors(r.end,r.start),t.subVectors(s.end,s.start);const h=e.dot(u),f=u.dot(c),d=u.dot(u),y=e.dot(c),p=c.dot(c)*d-f*f;let m,g;p!==0?m=(h*f-y*d)/p:m=0,g=(h+m*f)/d,a.x=m,a.y=g}})(),ns=(function(){const n=new M.Vector2,t=new M.Vector3,e=new M.Vector3;return function(r,s,a,o){Hl(r,s,n);let c=n.x,l=n.y;if(c>=0&&c<=1&&l>=0&&l<=1){r.at(c,a),s.at(l,o);return}else if(c>=0&&c<=1){l<0?s.at(0,o):s.at(1,o),r.closestPointToPoint(o,!0,a);return}else if(l>=0&&l<=1){c<0?r.at(0,a):r.at(1,a),s.closestPointToPoint(a,!0,o);return}else{let u;c<0?u=r.start:u=r.end;let h;l<0?h=s.start:h=s.end;const f=t,d=e;if(r.closestPointToPoint(h,!0,t),s.closestPointToPoint(u,!0,e),f.distanceToSquared(h)<=d.distanceToSquared(u)){a.copy(f),o.copy(h);return}else{a.copy(u),o.copy(d);return}}}})(),Yl=(function(){const n=new M.Vector3,t=new M.Vector3,e=new M.Plane,i=new M.Line3;return function(s,a){const{radius:o,center:c}=s,{a:l,b:u,c:h}=a;if(i.start=l,i.end=u,i.closestPointToPoint(c,!0,n).distanceTo(c)<=o||(i.start=l,i.end=h,i.closestPointToPoint(c,!0,n).distanceTo(c)<=o)||(i.start=u,i.end=h,i.closestPointToPoint(c,!0,n).distanceTo(c)<=o))return!0;const _=a.getPlane(e);if(Math.abs(_.distanceToPoint(c))<=o){const m=_.projectPoint(c,t);if(a.containsPoint(m))return!0}return!1}})(),Zl=1e-15;function gn(n){return Math.abs(n)<Zl}class Rt extends M.Triangle{constructor(...t){super(...t),this.isExtendedTriangle=!0,this.satAxes=new Array(4).fill().map(()=>new M.Vector3),this.satBounds=new Array(4).fill().map(()=>new le),this.points=[this.a,this.b,this.c],this.sphere=new M.Sphere,this.plane=new M.Plane,this.needsUpdate=!0}intersectsSphere(t){return Yl(t,this)}update(){const t=this.a,e=this.b,i=this.c,r=this.points,s=this.satAxes,a=this.satBounds,o=s[0],c=a[0];this.getNormal(o),c.setFromPoints(o,r);const l=s[1],u=a[1];l.subVectors(t,e),u.setFromPoints(l,r);const h=s[2],f=a[2];h.subVectors(e,i),f.setFromPoints(h,r);const d=s[3],y=a[3];d.subVectors(i,t),y.setFromPoints(d,r),this.sphere.setFromPoints(this.points),this.plane.setFromNormalAndCoplanarPoint(o,t),this.needsUpdate=!1}}Rt.prototype.closestPointToSegment=(function(){const n=new M.Vector3,t=new M.Vector3,e=new M.Line3;return function(r,s=null,a=null){const{start:o,end:c}=r,l=this.points;let u,h=1/0;for(let f=0;f<3;f++){const d=(f+1)%3;e.start.copy(l[f]),e.end.copy(l[d]),ns(e,r,n,t),u=n.distanceToSquared(t),u<h&&(h=u,s&&s.copy(n),a&&a.copy(t))}return this.closestPointToPoint(o,n),u=o.distanceToSquared(n),u<h&&(h=u,s&&s.copy(n),a&&a.copy(o)),this.closestPointToPoint(c,n),u=c.distanceToSquared(n),u<h&&(h=u,s&&s.copy(n),a&&a.copy(c)),Math.sqrt(h)}})();Rt.prototype.intersectsTriangle=(function(){const n=new Rt,t=new Array(3),e=new Array(3),i=new le,r=new le,s=new M.Vector3,a=new M.Vector3,o=new M.Vector3,c=new M.Vector3,l=new M.Vector3,u=new M.Line3,h=new M.Line3,f=new M.Line3,d=new M.Vector3;function y(_,p,m){const g=_.points;let v=0,S=-1;for(let x=0;x<3;x++){const{start:b,end:T}=u;b.copy(g[x]),T.copy(g[(x+1)%3]),u.delta(a);const w=gn(p.distanceToPoint(b));if(gn(p.normal.dot(a))&&w){m.copy(u),v=2;break}const C=p.intersectLine(u,d);if(!C&&w&&d.copy(b),(C||w)&&!gn(d.distanceTo(T))){if(v<=1)(v===1?m.start:m.end).copy(d),w&&(S=v);else if(v>=2){(S===1?m.start:m.end).copy(d),v=2;break}if(v++,v===2&&S===-1)break}}return v}return function(p,m=null,g=!1){this.needsUpdate&&this.update(),p.isExtendedTriangle?p.needsUpdate&&p.update():(n.copy(p),n.update(),p=n);const v=this.plane,S=p.plane;if(Math.abs(v.normal.dot(S.normal))>1-1e-10){const x=this.satBounds,b=this.satAxes;e[0]=p.a,e[1]=p.b,e[2]=p.c;for(let C=0;C<4;C++){const P=x[C],R=b[C];if(i.setFromPoints(R,e),P.isSeparated(i))return!1}const T=p.satBounds,w=p.satAxes;t[0]=this.a,t[1]=this.b,t[2]=this.c;for(let C=0;C<4;C++){const P=T[C],R=w[C];if(i.setFromPoints(R,t),P.isSeparated(i))return!1}for(let C=0;C<4;C++){const P=b[C];for(let R=0;R<4;R++){const E=w[R];if(s.crossVectors(P,E),i.setFromPoints(s,t),r.setFromPoints(s,e),i.isSeparated(r))return!1}}return m&&(g||console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."),m.start.set(0,0,0),m.end.set(0,0,0)),!0}else{const x=y(this,S,h);if(x===1&&p.containsPoint(h.end))return m&&(m.start.copy(h.end),m.end.copy(h.end)),!0;if(x!==2)return!1;const b=y(p,v,f);if(b===1&&this.containsPoint(f.end))return m&&(m.start.copy(f.end),m.end.copy(f.end)),!0;if(b!==2)return!1;if(h.delta(o),f.delta(c),o.dot(c)<0){let A=f.start;f.start=f.end,f.end=A}const T=h.start.dot(o),w=h.end.dot(o),C=f.start.dot(o),P=f.end.dot(o),R=w<C,E=T<P;return T!==P&&C!==w&&R===E?!1:(m&&(l.subVectors(h.start,f.start),l.dot(o)>0?m.start.copy(h.start):m.start.copy(f.start),l.subVectors(h.end,f.end),l.dot(o)<0?m.end.copy(h.end):m.end.copy(f.end)),!0)}}})();Rt.prototype.distanceToPoint=(function(){const n=new M.Vector3;return function(e){return this.closestPointToPoint(e,n),e.distanceTo(n)}})();Rt.prototype.distanceToTriangle=(function(){const n=new M.Vector3,t=new M.Vector3,e=["a","b","c"],i=new M.Line3,r=new M.Line3;return function(a,o=null,c=null){const l=o||c?i:null;if(this.intersectsTriangle(a,l))return(o||c)&&(o&&l.getCenter(o),c&&l.getCenter(c)),0;let u=1/0;for(let h=0;h<3;h++){let f;const d=e[h],y=a[d];this.closestPointToPoint(y,n),f=y.distanceToSquared(n),f<u&&(u=f,o&&o.copy(n),c&&c.copy(y));const _=this[d];a.closestPointToPoint(_,n),f=_.distanceToSquared(n),f<u&&(u=f,o&&o.copy(_),c&&c.copy(n))}for(let h=0;h<3;h++){const f=e[h],d=e[(h+1)%3];i.set(this[f],this[d]);for(let y=0;y<3;y++){const _=e[y],p=e[(y+1)%3];r.set(a[_],a[p]),ns(i,r,n,t);const m=n.distanceToSquared(t);m<u&&(u=m,o&&o.copy(n),c&&c.copy(t))}}return Math.sqrt(u)}})();class dt{constructor(t,e,i){this.isOrientedBox=!0,this.min=new M.Vector3,this.max=new M.Vector3,this.matrix=new M.Matrix4,this.invMatrix=new M.Matrix4,this.points=new Array(8).fill().map(()=>new M.Vector3),this.satAxes=new Array(3).fill().map(()=>new M.Vector3),this.satBounds=new Array(3).fill().map(()=>new le),this.alignedSatBounds=new Array(3).fill().map(()=>new le),this.needsUpdate=!1,t&&this.min.copy(t),e&&this.max.copy(e),i&&this.matrix.copy(i)}set(t,e,i){this.min.copy(t),this.max.copy(e),this.matrix.copy(i),this.needsUpdate=!0}copy(t){this.min.copy(t.min),this.max.copy(t.max),this.matrix.copy(t.matrix),this.needsUpdate=!0}}dt.prototype.update=(function(){return function(){const t=this.matrix,e=this.min,i=this.max,r=this.points;for(let l=0;l<=1;l++)for(let u=0;u<=1;u++)for(let h=0;h<=1;h++){const f=1*l|2*u|4*h,d=r[f];d.x=l?i.x:e.x,d.y=u?i.y:e.y,d.z=h?i.z:e.z,d.applyMatrix4(t)}const s=this.satBounds,a=this.satAxes,o=r[0];for(let l=0;l<3;l++){const u=a[l],h=s[l],f=1<<l,d=r[f];u.subVectors(o,d),h.setFromPoints(u,r)}const c=this.alignedSatBounds;c[0].setFromPointsField(r,"x"),c[1].setFromPointsField(r,"y"),c[2].setFromPointsField(r,"z"),this.invMatrix.copy(this.matrix).invert(),this.needsUpdate=!1}})();dt.prototype.intersectsBox=(function(){const n=new le;return function(e){this.needsUpdate&&this.update();const i=e.min,r=e.max,s=this.satBounds,a=this.satAxes,o=this.alignedSatBounds;if(n.min=i.x,n.max=r.x,o[0].isSeparated(n)||(n.min=i.y,n.max=r.y,o[1].isSeparated(n))||(n.min=i.z,n.max=r.z,o[2].isSeparated(n)))return!1;for(let c=0;c<3;c++){const l=a[c],u=s[c];if(n.setFromBox(l,e),u.isSeparated(n))return!1}return!0}})();dt.prototype.intersectsTriangle=(function(){const n=new Rt,t=new Array(3),e=new le,i=new le,r=new M.Vector3;return function(a){this.needsUpdate&&this.update(),a.isExtendedTriangle?a.needsUpdate&&a.update():(n.copy(a),n.update(),a=n);const o=this.satBounds,c=this.satAxes;t[0]=a.a,t[1]=a.b,t[2]=a.c;for(let f=0;f<3;f++){const d=o[f],y=c[f];if(e.setFromPoints(y,t),d.isSeparated(e))return!1}const l=a.satBounds,u=a.satAxes,h=this.points;for(let f=0;f<3;f++){const d=l[f],y=u[f];if(e.setFromPoints(y,h),d.isSeparated(e))return!1}for(let f=0;f<3;f++){const d=c[f];for(let y=0;y<4;y++){const _=u[y];if(r.crossVectors(d,_),e.setFromPoints(r,t),i.setFromPoints(r,h),e.isSeparated(i))return!1}}return!0}})();dt.prototype.closestPointToPoint=(function(){return function(t,e){return this.needsUpdate&&this.update(),e.copy(t).applyMatrix4(this.invMatrix).clamp(this.min,this.max).applyMatrix4(this.matrix),e}})();dt.prototype.distanceToPoint=(function(){const n=new M.Vector3;return function(e){return this.closestPointToPoint(e,n),e.distanceTo(n)}})();dt.prototype.distanceToBox=(function(){const n=["x","y","z"],t=new Array(12).fill().map(()=>new M.Line3),e=new Array(12).fill().map(()=>new M.Line3),i=new M.Vector3,r=new M.Vector3;return function(a,o=0,c=null,l=null){if(this.needsUpdate&&this.update(),this.intersectsBox(a))return(c||l)&&(a.getCenter(r),this.closestPointToPoint(r,i),a.closestPointToPoint(i,r),c&&c.copy(i),l&&l.copy(r)),0;const u=o*o,h=a.min,f=a.max,d=this.points;let y=1/0;for(let p=0;p<8;p++){const m=d[p];r.copy(m).clamp(h,f);const g=m.distanceToSquared(r);if(g<y&&(y=g,c&&c.copy(m),l&&l.copy(r),g<u))return Math.sqrt(g)}let _=0;for(let p=0;p<3;p++)for(let m=0;m<=1;m++)for(let g=0;g<=1;g++){const v=(p+1)%3,S=(p+2)%3,x=m<<v|g<<S,b=1<<p|m<<v|g<<S,T=d[x],w=d[b];t[_].set(T,w);const P=n[p],R=n[v],E=n[S],A=e[_],k=A.start,z=A.end;k[P]=h[P],k[R]=m?h[R]:f[R],k[E]=g?h[E]:f[R],z[P]=f[P],z[R]=m?h[R]:f[R],z[E]=g?h[E]:f[R],_++}for(let p=0;p<=1;p++)for(let m=0;m<=1;m++)for(let g=0;g<=1;g++){r.x=p?f.x:h.x,r.y=m?f.y:h.y,r.z=g?f.z:h.z,this.closestPointToPoint(r,i);const v=r.distanceToSquared(i);if(v<y&&(y=v,c&&c.copy(i),l&&l.copy(r),v<u))return Math.sqrt(v)}for(let p=0;p<12;p++){const m=t[p];for(let g=0;g<12;g++){const v=e[g];ns(m,v,i,r);const S=i.distanceToSquared(r);if(S<y&&(y=S,c&&c.copy(i),l&&l.copy(r),S<u))return Math.sqrt(S)}}return Math.sqrt(y)}})();class ss{constructor(t){this._getNewPrimitive=t,this._primitives=[]}getPrimitive(){const t=this._primitives;return t.length===0?this._getNewPrimitive():t.pop()}releasePrimitive(t){this._primitives.push(t)}}class Ql extends ss{constructor(){super(()=>new Rt)}}const Et=new Ql;class Kl{constructor(){this.float32Array=null,this.uint16Array=null,this.uint32Array=null;const t=[];let e=null;this.setBuffer=i=>{e&&t.push(e),e=i,this.float32Array=new Float32Array(i),this.uint16Array=new Uint16Array(i),this.uint32Array=new Uint32Array(i)},this.clearBuffer=()=>{e=null,this.float32Array=null,this.uint16Array=null,this.uint32Array=null,t.length!==0&&this.setBuffer(t.pop())}}}const $=new Kl;let ye,Ve;const Oe=[],hr=new ss(()=>new M.Box3);function tu(n,t,e,i,r,s){ye=hr.getPrimitive(),Ve=hr.getPrimitive(),Oe.push(ye,Ve),$.setBuffer(n._roots[t]);const a=Vn(0,n.geometry,e,i,r,s);$.clearBuffer(),hr.releasePrimitive(ye),hr.releasePrimitive(Ve),Oe.pop(),Oe.pop();const o=Oe.length;return o>0&&(Ve=Oe[o-1],ye=Oe[o-2]),a}function Vn(n,t,e,i,r=null,s=0,a=0){const{float32Array:o,uint16Array:c,uint32Array:l}=$;let u=n*2;if(St(u,c)){const f=Mt(n,l),d=Ct(u,c);return Y(n,o,ye),i(f,d,!1,a,s+n,ye)}else{let P=function(E){const{uint16Array:A,uint32Array:k}=$;let z=E*2;for(;!St(z,A);)E=Pt(E),z=E*2;return Mt(E,k)},R=function(E){const{uint16Array:A,uint32Array:k}=$;let z=E*2;for(;!St(z,A);)E=wt(E,k),z=E*2;return Mt(E,k)+Ct(z,A)};const f=Pt(n),d=wt(n,l);let y=f,_=d,p,m,g,v;if(r&&(g=ye,v=Ve,Y(y,o,g),Y(_,o,v),p=r(g),m=r(v),m<p)){y=d,_=f;const E=p;p=m,m=E,g=v}g||(g=ye,Y(y,o,g));const S=St(y*2,c),x=e(g,S,p,a+1,s+y);let b;if(x===Dn){const E=P(y),k=R(y)-E;b=i(E,k,!0,a+1,s+y,g)}else b=x&&Vn(y,t,e,i,r,s,a+1);if(b)return!0;v=Ve,Y(_,o,v);const T=St(_*2,c),w=e(v,T,m,a+1,s+_);let C;if(w===Dn){const E=P(_),k=R(_)-E;C=i(E,k,!0,a+1,s+_,v)}else C=w&&Vn(_,t,e,i,r,s,a+1);return!!C}}const ii=new M.Vector3,vn=new M.Vector3;function eu(n,t,e={},i=0,r=1/0){const s=i*i,a=r*r;let o=1/0,c=null;if(n.shapecast({boundsTraverseOrder:u=>(ii.copy(t).clamp(u.min,u.max),ii.distanceToSquared(t)),intersectsBounds:(u,h,f)=>f<o&&f<a,intersectsTriangle:(u,h)=>{u.closestPointToPoint(t,ii);const f=t.distanceToSquared(ii);return f<o&&(vn.copy(ii),o=f,c=h),f<s}}),o===1/0)return null;const l=Math.sqrt(o);return e.point?e.point.copy(vn):e.point=vn.clone(),e.distance=l,e.faceIndex=c,e}const iu=parseInt(M.REVISION)>=169,Se=new M.Vector3,be=new M.Vector3,Te=new M.Vector3,fr=new M.Vector2,dr=new M.Vector2,pr=new M.Vector2,Hs=new M.Vector3,Ys=new M.Vector3,Zs=new M.Vector3,ri=new M.Vector3;function ru(n,t,e,i,r,s,a,o){let c;if(s===M.BackSide?c=n.intersectTriangle(i,e,t,!0,r):c=n.intersectTriangle(t,e,i,s!==M.DoubleSide,r),c===null)return null;const l=n.origin.distanceTo(r);return l<a||l>o?null:{distance:l,point:r.clone()}}function nu(n,t,e,i,r,s,a,o,c,l,u){Se.fromBufferAttribute(t,s),be.fromBufferAttribute(t,a),Te.fromBufferAttribute(t,o);const h=ru(n,Se,be,Te,ri,c,l,u);if(h){const f=new M.Vector3;M.Triangle.getBarycoord(ri,Se,be,Te,f),i&&(fr.fromBufferAttribute(i,s),dr.fromBufferAttribute(i,a),pr.fromBufferAttribute(i,o),h.uv=M.Triangle.getInterpolation(ri,Se,be,Te,fr,dr,pr,new M.Vector2)),r&&(fr.fromBufferAttribute(r,s),dr.fromBufferAttribute(r,a),pr.fromBufferAttribute(r,o),h.uv1=M.Triangle.getInterpolation(ri,Se,be,Te,fr,dr,pr,new M.Vector2)),e&&(Hs.fromBufferAttribute(e,s),Ys.fromBufferAttribute(e,a),Zs.fromBufferAttribute(e,o),h.normal=M.Triangle.getInterpolation(ri,Se,be,Te,Hs,Ys,Zs,new M.Vector3),h.normal.dot(n.direction)>0&&h.normal.multiplyScalar(-1));const d={a:s,b:a,c:o,normal:new M.Vector3,materialIndex:0};M.Triangle.getNormal(Se,be,Te,d.normal),h.face=d,h.faceIndex=s,iu&&(h.barycoord=f)}return h}function qr(n,t,e,i,r,s,a){const o=i*3;let c=o+0,l=o+1,u=o+2;const h=n.index;n.index&&(c=h.getX(c),l=h.getX(l),u=h.getX(u));const{position:f,normal:d,uv:y,uv1:_}=n.attributes,p=nu(e,f,d,y,_,c,l,u,t,s,a);return p?(p.faceIndex=i,r&&r.push(p),p):null}function et(n,t,e,i){const r=n.a,s=n.b,a=n.c;let o=t,c=t+1,l=t+2;e&&(o=e.getX(o),c=e.getX(c),l=e.getX(l)),r.x=i.getX(o),r.y=i.getY(o),r.z=i.getZ(o),s.x=i.getX(c),s.y=i.getY(c),s.z=i.getZ(c),a.x=i.getX(l),a.y=i.getY(l),a.z=i.getZ(l)}function su(n,t,e,i,r,s,a,o){const{geometry:c,_indirectBuffer:l}=n;for(let u=i,h=i+r;u<h;u++)qr(c,t,e,u,s,a,o)}function ou(n,t,e,i,r,s,a){const{geometry:o,_indirectBuffer:c}=n;let l=1/0,u=null;for(let h=i,f=i+r;h<f;h++){let d;d=qr(o,t,e,h,null,s,a),d&&d.distance<l&&(u=d,l=d.distance)}return u}function au(n,t,e,i,r,s,a){const{geometry:o}=e,{index:c}=o,l=o.attributes.position;for(let u=n,h=t+n;u<h;u++){let f;if(f=u,et(a,f*3,c,l),a.needsUpdate=!0,i(a,f,r,s))return!0}return!1}function cu(n,t=null){t&&Array.isArray(t)&&(t=new Set(t));const e=n.geometry,i=e.index?e.index.array:null,r=e.attributes.position;let s,a,o,c,l=0;const u=n._roots;for(let f=0,d=u.length;f<d;f++)s=u[f],a=new Uint32Array(s),o=new Uint16Array(s),c=new Float32Array(s),h(0,l),l+=s.byteLength;function h(f,d,y=!1){const _=f*2;if(o[_+15]===$r){const m=a[f+6],g=o[_+14];let v=1/0,S=1/0,x=1/0,b=-1/0,T=-1/0,w=-1/0;for(let C=3*m,P=3*(m+g);C<P;C++){let R=i[C];const E=r.getX(R),A=r.getY(R),k=r.getZ(R);E<v&&(v=E),E>b&&(b=E),A<S&&(S=A),A>T&&(T=A),k<x&&(x=k),k>w&&(w=k)}return c[f+0]!==v||c[f+1]!==S||c[f+2]!==x||c[f+3]!==b||c[f+4]!==T||c[f+5]!==w?(c[f+0]=v,c[f+1]=S,c[f+2]=x,c[f+3]=b,c[f+4]=T,c[f+5]=w,!0):!1}else{const m=f+8,g=a[f+6],v=m+d,S=g+d;let x=y,b=!1,T=!1;t?x||(b=t.has(v),T=t.has(S),x=!b&&!T):(b=!0,T=!0);const w=x||b,C=x||T;let P=!1;w&&(P=h(m,d,x));let R=!1;C&&(R=h(g,d,x));const E=P||R;if(E)for(let A=0;A<3;A++){const k=m+A,z=g+A,U=c[k],L=c[k+3],I=c[z],X=c[z+3];c[f+A]=U<I?U:I,c[f+A+3]=L>X?L:X}return E}}}function ge(n,t,e,i,r){let s,a,o,c,l,u;const h=1/e.direction.x,f=1/e.direction.y,d=1/e.direction.z,y=e.origin.x,_=e.origin.y,p=e.origin.z;let m=t[n],g=t[n+3],v=t[n+1],S=t[n+3+1],x=t[n+2],b=t[n+3+2];return h>=0?(s=(m-y)*h,a=(g-y)*h):(s=(g-y)*h,a=(m-y)*h),f>=0?(o=(v-_)*f,c=(S-_)*f):(o=(S-_)*f,c=(v-_)*f),s>c||o>a||((o>s||isNaN(s))&&(s=o),(c<a||isNaN(a))&&(a=c),d>=0?(l=(x-p)*d,u=(b-p)*d):(l=(b-p)*d,u=(x-p)*d),s>u||l>a)?!1:((l>s||s!==s)&&(s=l),(u<a||a!==a)&&(a=u),s<=r&&a>=i)}function lu(n,t,e,i,r,s,a,o){const{geometry:c,_indirectBuffer:l}=n;for(let u=i,h=i+r;u<h;u++){let f=l?l[u]:u;qr(c,t,e,f,s,a,o)}}function uu(n,t,e,i,r,s,a){const{geometry:o,_indirectBuffer:c}=n;let l=1/0,u=null;for(let h=i,f=i+r;h<f;h++){let d;d=qr(o,t,e,c?c[h]:h,null,s,a),d&&d.distance<l&&(u=d,l=d.distance)}return u}function hu(n,t,e,i,r,s,a){const{geometry:o}=e,{index:c}=o,l=o.attributes.position;for(let u=n,h=t+n;u<h;u++){let f;if(f=e.resolveTriangleIndex(u),et(a,f*3,c,l),a.needsUpdate=!0,i(a,f,r,s))return!0}return!1}function fu(n,t,e,i,r,s,a){$.setBuffer(n._roots[t]),Jn(0,n,e,i,r,s,a),$.clearBuffer()}function Jn(n,t,e,i,r,s,a){const{float32Array:o,uint16Array:c,uint32Array:l}=$,u=n*2;if(St(u,c)){const f=Mt(n,l),d=Ct(u,c);su(t,e,i,f,d,r,s,a)}else{const f=Pt(n);ge(f,o,i,s,a)&&Jn(f,t,e,i,r,s,a);const d=wt(n,l);ge(d,o,i,s,a)&&Jn(d,t,e,i,r,s,a)}}const du=["x","y","z"];function pu(n,t,e,i,r,s){$.setBuffer(n._roots[t]);const a=Gn(0,n,e,i,r,s);return $.clearBuffer(),a}function Gn(n,t,e,i,r,s){const{float32Array:a,uint16Array:o,uint32Array:c}=$;let l=n*2;if(St(l,o)){const h=Mt(n,c),f=Ct(l,o);return ou(t,e,i,h,f,r,s)}else{const h=da(n,c),f=du[h],y=i.direction[f]>=0;let _,p;y?(_=Pt(n),p=wt(n,c)):(_=wt(n,c),p=Pt(n));const g=ge(_,a,i,r,s)?Gn(_,t,e,i,r,s):null;if(g){const x=g.point[f];if(y?x<=a[p+h]:x>=a[p+h+3])return g}const S=ge(p,a,i,r,s)?Gn(p,t,e,i,r,s):null;return g&&S?g.distance<=S.distance?g:S:g||S||null}}const mr=new M.Box3,Be=new Rt,Ie=new Rt,ni=new M.Matrix4,Qs=new dt,yr=new dt;function mu(n,t,e,i){$.setBuffer(n._roots[t]);const r=jn(0,n,e,i);return $.clearBuffer(),r}function jn(n,t,e,i,r=null){const{float32Array:s,uint16Array:a,uint32Array:o}=$;let c=n*2;if(r===null&&(e.boundingBox||e.computeBoundingBox(),Qs.set(e.boundingBox.min,e.boundingBox.max,i),r=Qs),St(c,a)){const u=t.geometry,h=u.index,f=u.attributes.position,d=e.index,y=e.attributes.position,_=Mt(n,o),p=Ct(c,a);if(ni.copy(i).invert(),e.boundsTree)return Y(n,s,yr),yr.matrix.copy(ni),yr.needsUpdate=!0,e.boundsTree.shapecast({intersectsBounds:g=>yr.intersectsBox(g),intersectsTriangle:g=>{g.a.applyMatrix4(i),g.b.applyMatrix4(i),g.c.applyMatrix4(i),g.needsUpdate=!0;for(let v=_*3,S=(p+_)*3;v<S;v+=3)if(et(Ie,v,h,f),Ie.needsUpdate=!0,g.intersectsTriangle(Ie))return!0;return!1}});for(let m=_*3,g=(p+_)*3;m<g;m+=3){et(Be,m,h,f),Be.a.applyMatrix4(ni),Be.b.applyMatrix4(ni),Be.c.applyMatrix4(ni),Be.needsUpdate=!0;for(let v=0,S=d.count;v<S;v+=3)if(et(Ie,v,d,y),Ie.needsUpdate=!0,Be.intersectsTriangle(Ie))return!0}}else{const u=n+8,h=o[n+6];return Y(u,s,mr),!!(r.intersectsBox(mr)&&jn(u,t,e,i,r)||(Y(h,s,mr),r.intersectsBox(mr)&&jn(h,t,e,i,r)))}}const gr=new M.Matrix4,_n=new dt,si=new dt,yu=new M.Vector3,gu=new M.Vector3,vu=new M.Vector3,_u=new M.Vector3;function xu(n,t,e,i={},r={},s=0,a=1/0){t.boundingBox||t.computeBoundingBox(),_n.set(t.boundingBox.min,t.boundingBox.max,e),_n.needsUpdate=!0;const o=n.geometry,c=o.attributes.position,l=o.index,u=t.attributes.position,h=t.index,f=Et.getPrimitive(),d=Et.getPrimitive();let y=yu,_=gu,p=null,m=null;r&&(p=vu,m=_u);let g=1/0,v=null,S=null;return gr.copy(e).invert(),si.matrix.copy(gr),n.shapecast({boundsTraverseOrder:x=>_n.distanceToBox(x),intersectsBounds:(x,b,T)=>T<g&&T<a?(b&&(si.min.copy(x.min),si.max.copy(x.max),si.needsUpdate=!0),!0):!1,intersectsRange:(x,b)=>{if(t.boundsTree)return t.boundsTree.shapecast({boundsTraverseOrder:w=>si.distanceToBox(w),intersectsBounds:(w,C,P)=>P<g&&P<a,intersectsRange:(w,C)=>{for(let P=w,R=w+C;P<R;P++){et(d,3*P,h,u),d.a.applyMatrix4(e),d.b.applyMatrix4(e),d.c.applyMatrix4(e),d.needsUpdate=!0;for(let E=x,A=x+b;E<A;E++){et(f,3*E,l,c),f.needsUpdate=!0;const k=f.distanceToTriangle(d,y,p);if(k<g&&(_.copy(y),m&&m.copy(p),g=k,v=E,S=P),k<s)return!0}}}});{const T=Xe(t);for(let w=0,C=T;w<C;w++){et(d,3*w,h,u),d.a.applyMatrix4(e),d.b.applyMatrix4(e),d.c.applyMatrix4(e),d.needsUpdate=!0;for(let P=x,R=x+b;P<R;P++){et(f,3*P,l,c),f.needsUpdate=!0;const E=f.distanceToTriangle(d,y,p);if(E<g&&(_.copy(y),m&&m.copy(p),g=E,v=P,S=w),E<s)return!0}}}}}),Et.releasePrimitive(f),Et.releasePrimitive(d),g===1/0?null:(i.point?i.point.copy(_):i.point=_.clone(),i.distance=g,i.faceIndex=v,r&&(r.point?r.point.copy(m):r.point=m.clone(),r.point.applyMatrix4(gr),_.applyMatrix4(gr),r.distance=_.sub(r.point).length(),r.faceIndex=S),i)}function Su(n,t=null){t&&Array.isArray(t)&&(t=new Set(t));const e=n.geometry,i=e.index?e.index.array:null,r=e.attributes.position;let s,a,o,c,l=0;const u=n._roots;for(let f=0,d=u.length;f<d;f++)s=u[f],a=new Uint32Array(s),o=new Uint16Array(s),c=new Float32Array(s),h(0,l),l+=s.byteLength;function h(f,d,y=!1){const _=f*2;if(o[_+15]===$r){const m=a[f+6],g=o[_+14];let v=1/0,S=1/0,x=1/0,b=-1/0,T=-1/0,w=-1/0;for(let C=m,P=m+g;C<P;C++){const R=3*n.resolveTriangleIndex(C);for(let E=0;E<3;E++){let A=R+E;A=i?i[A]:A;const k=r.getX(A),z=r.getY(A),U=r.getZ(A);k<v&&(v=k),k>b&&(b=k),z<S&&(S=z),z>T&&(T=z),U<x&&(x=U),U>w&&(w=U)}}return c[f+0]!==v||c[f+1]!==S||c[f+2]!==x||c[f+3]!==b||c[f+4]!==T||c[f+5]!==w?(c[f+0]=v,c[f+1]=S,c[f+2]=x,c[f+3]=b,c[f+4]=T,c[f+5]=w,!0):!1}else{const m=f+8,g=a[f+6],v=m+d,S=g+d;let x=y,b=!1,T=!1;t?x||(b=t.has(v),T=t.has(S),x=!b&&!T):(b=!0,T=!0);const w=x||b,C=x||T;let P=!1;w&&(P=h(m,d,x));let R=!1;C&&(R=h(g,d,x));const E=P||R;if(E)for(let A=0;A<3;A++){const k=m+A,z=g+A,U=c[k],L=c[k+3],I=c[z],X=c[z+3];c[f+A]=U<I?U:I,c[f+A+3]=L>X?L:X}return E}}}function bu(n,t,e,i,r,s,a){$.setBuffer(n._roots[t]),$n(0,n,e,i,r,s,a),$.clearBuffer()}function $n(n,t,e,i,r,s,a){const{float32Array:o,uint16Array:c,uint32Array:l}=$,u=n*2;if(St(u,c)){const f=Mt(n,l),d=Ct(u,c);lu(t,e,i,f,d,r,s,a)}else{const f=Pt(n);ge(f,o,i,s,a)&&$n(f,t,e,i,r,s,a);const d=wt(n,l);ge(d,o,i,s,a)&&$n(d,t,e,i,r,s,a)}}const Tu=["x","y","z"];function Mu(n,t,e,i,r,s){$.setBuffer(n._roots[t]);const a=qn(0,n,e,i,r,s);return $.clearBuffer(),a}function qn(n,t,e,i,r,s){const{float32Array:a,uint16Array:o,uint32Array:c}=$;let l=n*2;if(St(l,o)){const h=Mt(n,c),f=Ct(l,o);return uu(t,e,i,h,f,r,s)}else{const h=da(n,c),f=Tu[h],y=i.direction[f]>=0;let _,p;y?(_=Pt(n),p=wt(n,c)):(_=wt(n,c),p=Pt(n));const g=ge(_,a,i,r,s)?qn(_,t,e,i,r,s):null;if(g){const x=g.point[f];if(y?x<=a[p+h]:x>=a[p+h+3])return g}const S=ge(p,a,i,r,s)?qn(p,t,e,i,r,s):null;return g&&S?g.distance<=S.distance?g:S:g||S||null}}const vr=new M.Box3,Ue=new Rt,Ne=new Rt,oi=new M.Matrix4,Ks=new dt,_r=new dt;function Cu(n,t,e,i){$.setBuffer(n._roots[t]);const r=Xn(0,n,e,i);return $.clearBuffer(),r}function Xn(n,t,e,i,r=null){const{float32Array:s,uint16Array:a,uint32Array:o}=$;let c=n*2;if(r===null&&(e.boundingBox||e.computeBoundingBox(),Ks.set(e.boundingBox.min,e.boundingBox.max,i),r=Ks),St(c,a)){const u=t.geometry,h=u.index,f=u.attributes.position,d=e.index,y=e.attributes.position,_=Mt(n,o),p=Ct(c,a);if(oi.copy(i).invert(),e.boundsTree)return Y(n,s,_r),_r.matrix.copy(oi),_r.needsUpdate=!0,e.boundsTree.shapecast({intersectsBounds:g=>_r.intersectsBox(g),intersectsTriangle:g=>{g.a.applyMatrix4(i),g.b.applyMatrix4(i),g.c.applyMatrix4(i),g.needsUpdate=!0;for(let v=_,S=p+_;v<S;v++)if(et(Ne,3*t.resolveTriangleIndex(v),h,f),Ne.needsUpdate=!0,g.intersectsTriangle(Ne))return!0;return!1}});for(let m=_,g=p+_;m<g;m++){const v=t.resolveTriangleIndex(m);et(Ue,3*v,h,f),Ue.a.applyMatrix4(oi),Ue.b.applyMatrix4(oi),Ue.c.applyMatrix4(oi),Ue.needsUpdate=!0;for(let S=0,x=d.count;S<x;S+=3)if(et(Ne,S,d,y),Ne.needsUpdate=!0,Ue.intersectsTriangle(Ne))return!0}}else{const u=n+8,h=o[n+6];return Y(u,s,vr),!!(r.intersectsBox(vr)&&Xn(u,t,e,i,r)||(Y(h,s,vr),r.intersectsBox(vr)&&Xn(h,t,e,i,r)))}}const xr=new M.Matrix4,xn=new dt,ai=new dt,Pu=new M.Vector3,wu=new M.Vector3,Eu=new M.Vector3,Ru=new M.Vector3;function Au(n,t,e,i={},r={},s=0,a=1/0){t.boundingBox||t.computeBoundingBox(),xn.set(t.boundingBox.min,t.boundingBox.max,e),xn.needsUpdate=!0;const o=n.geometry,c=o.attributes.position,l=o.index,u=t.attributes.position,h=t.index,f=Et.getPrimitive(),d=Et.getPrimitive();let y=Pu,_=wu,p=null,m=null;r&&(p=Eu,m=Ru);let g=1/0,v=null,S=null;return xr.copy(e).invert(),ai.matrix.copy(xr),n.shapecast({boundsTraverseOrder:x=>xn.distanceToBox(x),intersectsBounds:(x,b,T)=>T<g&&T<a?(b&&(ai.min.copy(x.min),ai.max.copy(x.max),ai.needsUpdate=!0),!0):!1,intersectsRange:(x,b)=>{if(t.boundsTree){const T=t.boundsTree;return T.shapecast({boundsTraverseOrder:w=>ai.distanceToBox(w),intersectsBounds:(w,C,P)=>P<g&&P<a,intersectsRange:(w,C)=>{for(let P=w,R=w+C;P<R;P++){const E=T.resolveTriangleIndex(P);et(d,3*E,h,u),d.a.applyMatrix4(e),d.b.applyMatrix4(e),d.c.applyMatrix4(e),d.needsUpdate=!0;for(let A=x,k=x+b;A<k;A++){const z=n.resolveTriangleIndex(A);et(f,3*z,l,c),f.needsUpdate=!0;const U=f.distanceToTriangle(d,y,p);if(U<g&&(_.copy(y),m&&m.copy(p),g=U,v=A,S=P),U<s)return!0}}}})}else{const T=Xe(t);for(let w=0,C=T;w<C;w++){et(d,3*w,h,u),d.a.applyMatrix4(e),d.b.applyMatrix4(e),d.c.applyMatrix4(e),d.needsUpdate=!0;for(let P=x,R=x+b;P<R;P++){const E=n.resolveTriangleIndex(P);et(f,3*E,l,c),f.needsUpdate=!0;const A=f.distanceToTriangle(d,y,p);if(A<g&&(_.copy(y),m&&m.copy(p),g=A,v=P,S=w),A<s)return!0}}}}}),Et.releasePrimitive(f),Et.releasePrimitive(d),g===1/0?null:(i.point?i.point.copy(_):i.point=_.clone(),i.distance=g,i.faceIndex=v,r&&(r.point?r.point.copy(m):r.point=m.clone(),r.point.applyMatrix4(xr),_.applyMatrix4(xr),r.distance=_.sub(r.point).length(),r.faceIndex=S),i)}function ku(){return typeof SharedArrayBuffer<"u"}const yi=new $.constructor,Lr=new $.constructor,pe=new ss(()=>new M.Box3),De=new M.Box3,Fe=new M.Box3,Sn=new M.Box3,bn=new M.Box3;let Tn=!1;function zu(n,t,e,i){if(Tn)throw new Error("MeshBVH: Recursive calls to bvhcast not supported.");Tn=!0;const r=n._roots,s=t._roots;let a,o=0,c=0;const l=new M.Matrix4().copy(e).invert();for(let u=0,h=r.length;u<h;u++){yi.setBuffer(r[u]),c=0;const f=pe.getPrimitive();Y(0,yi.float32Array,f),f.applyMatrix4(l);for(let d=0,y=s.length;d<y&&(Lr.setBuffer(s[d]),a=Ut(0,0,e,l,i,o,c,0,0,f),Lr.clearBuffer(),c+=s[d].length,!a);d++);if(pe.releasePrimitive(f),yi.clearBuffer(),o+=r[u].length,a)break}return Tn=!1,a}function Ut(n,t,e,i,r,s=0,a=0,o=0,c=0,l=null,u=!1){let h,f;u?(h=Lr,f=yi):(h=yi,f=Lr);const d=h.float32Array,y=h.uint32Array,_=h.uint16Array,p=f.float32Array,m=f.uint32Array,g=f.uint16Array,v=n*2,S=t*2,x=St(v,_),b=St(S,g);let T=!1;if(b&&x)u?T=r(Mt(t,m),Ct(t*2,g),Mt(n,y),Ct(n*2,_),c,a+t,o,s+n):T=r(Mt(n,y),Ct(n*2,_),Mt(t,m),Ct(t*2,g),o,s+n,c,a+t);else if(b){const w=pe.getPrimitive();Y(t,p,w),w.applyMatrix4(e);const C=Pt(n),P=wt(n,y);Y(C,d,De),Y(P,d,Fe);const R=w.intersectsBox(De),E=w.intersectsBox(Fe);T=R&&Ut(t,C,i,e,r,a,s,c,o+1,w,!u)||E&&Ut(t,P,i,e,r,a,s,c,o+1,w,!u),pe.releasePrimitive(w)}else{const w=Pt(t),C=wt(t,m);Y(w,p,Sn),Y(C,p,bn);const P=l.intersectsBox(Sn),R=l.intersectsBox(bn);if(P&&R)T=Ut(n,w,e,i,r,s,a,o,c+1,l,u)||Ut(n,C,e,i,r,s,a,o,c+1,l,u);else if(P)if(x)T=Ut(n,w,e,i,r,s,a,o,c+1,l,u);else{const E=pe.getPrimitive();E.copy(Sn).applyMatrix4(e);const A=Pt(n),k=wt(n,y);Y(A,d,De),Y(k,d,Fe);const z=E.intersectsBox(De),U=E.intersectsBox(Fe);T=z&&Ut(w,A,i,e,r,a,s,c,o+1,E,!u)||U&&Ut(w,k,i,e,r,a,s,c,o+1,E,!u),pe.releasePrimitive(E)}else if(R)if(x)T=Ut(n,C,e,i,r,s,a,o,c+1,l,u);else{const E=pe.getPrimitive();E.copy(bn).applyMatrix4(e);const A=Pt(n),k=wt(n,y);Y(A,d,De),Y(k,d,Fe);const z=E.intersectsBox(De),U=E.intersectsBox(Fe);T=z&&Ut(C,A,i,e,r,a,s,c,o+1,E,!u)||U&&Ut(C,k,i,e,r,a,s,c,o+1,E,!u),pe.releasePrimitive(E)}}return T}const Sr=new dt,to=new M.Box3,Ou={strategy:rs,maxDepth:40,maxLeafTris:10,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,indirect:!1,verbose:!0,range:null};class Ki{static serialize(t,e={}){e={cloneBuffers:!0,...e};const i=t.geometry,r=t._roots,s=t._indirectBuffer,a=i.getIndex();let o;return e.cloneBuffers?o={roots:r.map(c=>c.slice()),index:a?a.array.slice():null,indirectBuffer:s?s.slice():null}:o={roots:r,index:a?a.array:null,indirectBuffer:s},o}static deserialize(t,e,i={}){i={setIndex:!0,indirect:!!t.indirectBuffer,...i};const{index:r,roots:s,indirectBuffer:a}=t,o=new Ki(e,{...i,[pn]:!0});if(o._roots=s,o._indirectBuffer=a||null,i.setIndex){const c=e.getIndex();if(c===null){const l=new M.BufferAttribute(t.index,1,!1);e.setIndex(l)}else c.array!==r&&(c.array.set(r),c.needsUpdate=!0)}return o}get indirect(){return!!this._indirectBuffer}constructor(t,e={}){if(t.isBufferGeometry){if(t.index&&t.index.isInterleavedBufferAttribute)throw new Error("MeshBVH: InterleavedBufferAttribute is not supported for the index attribute.")}else throw new Error("MeshBVH: Only BufferGeometries are supported.");if(e=Object.assign({...Ou,[pn]:!1},e),e.useSharedArrayBuffer&&!ku())throw new Error("MeshBVH: SharedArrayBuffer is not available.");this.geometry=t,this._roots=null,this._indirectBuffer=null,e[pn]||(Wl(this,e),!t.boundingBox&&e.setBoundingBox&&(t.boundingBox=this.getBoundingBox(new M.Box3))),this.resolveTriangleIndex=e.indirect?i=>this._indirectBuffer[i]:i=>i}refit(t=null){return(this.indirect?Su:cu)(this,t)}traverse(t,e=0){const i=this._roots[e],r=new Uint32Array(i),s=new Uint16Array(i);a(0);function a(o,c=0){const l=o*2,u=s[l+15]===$r;if(u){const h=r[o+6],f=s[l+14];t(c,u,new Float32Array(i,o*4,6),h,f)}else{const h=o+mi/4,f=r[o+6],d=r[o+7];t(c,u,new Float32Array(i,o*4,6),d)||(a(h,c+1),a(f,c+1))}}}raycast(t,e=M.FrontSide,i=0,r=1/0){const s=this._roots,a=this.geometry,o=[],c=e.isMaterial,l=Array.isArray(e),u=a.groups,h=c?e.side:e,f=this.indirect?bu:fu;for(let d=0,y=s.length;d<y;d++){const _=l?e[u[d].materialIndex].side:h,p=o.length;if(f(this,d,_,t,o,i,r),l){const m=u[d].materialIndex;for(let g=p,v=o.length;g<v;g++)o[g].face.materialIndex=m}}return o}raycastFirst(t,e=M.FrontSide,i=0,r=1/0){const s=this._roots,a=this.geometry,o=e.isMaterial,c=Array.isArray(e);let l=null;const u=a.groups,h=o?e.side:e,f=this.indirect?Mu:pu;for(let d=0,y=s.length;d<y;d++){const _=c?e[u[d].materialIndex].side:h,p=f(this,d,_,t,i,r);p!=null&&(l==null||p.distance<l.distance)&&(l=p,c&&(p.face.materialIndex=u[d].materialIndex))}return l}intersectsGeometry(t,e){let i=!1;const r=this._roots,s=this.indirect?Cu:mu;for(let a=0,o=r.length;a<o&&(i=s(this,a,t,e),!i);a++);return i}shapecast(t){const e=Et.getPrimitive(),i=this.indirect?hu:au;let{boundsTraverseOrder:r,intersectsBounds:s,intersectsRange:a,intersectsTriangle:o}=t;if(a&&o){const h=a;a=(f,d,y,_,p)=>h(f,d,y,_,p)?!0:i(f,d,this,o,y,_,e)}else a||(o?a=(h,f,d,y)=>i(h,f,this,o,d,y,e):a=(h,f,d)=>d);let c=!1,l=0;const u=this._roots;for(let h=0,f=u.length;h<f;h++){const d=u[h];if(c=tu(this,h,s,a,r,l),c)break;l+=d.byteLength}return Et.releasePrimitive(e),c}bvhcast(t,e,i){let{intersectsRanges:r,intersectsTriangles:s}=i;const a=Et.getPrimitive(),o=this.geometry.index,c=this.geometry.attributes.position,l=this.indirect?y=>{const _=this.resolveTriangleIndex(y);et(a,_*3,o,c)}:y=>{et(a,y*3,o,c)},u=Et.getPrimitive(),h=t.geometry.index,f=t.geometry.attributes.position,d=t.indirect?y=>{const _=t.resolveTriangleIndex(y);et(u,_*3,h,f)}:y=>{et(u,y*3,h,f)};if(s){const y=(_,p,m,g,v,S,x,b)=>{for(let T=m,w=m+g;T<w;T++){d(T),u.a.applyMatrix4(e),u.b.applyMatrix4(e),u.c.applyMatrix4(e),u.needsUpdate=!0;for(let C=_,P=_+p;C<P;C++)if(l(C),a.needsUpdate=!0,s(a,u,C,T,v,S,x,b))return!0}return!1};if(r){const _=r;r=function(p,m,g,v,S,x,b,T){return _(p,m,g,v,S,x,b,T)?!0:y(p,m,g,v,S,x,b,T)}}else r=y}return zu(this,t,e,r)}intersectsBox(t,e){return Sr.set(t.min,t.max,e),Sr.needsUpdate=!0,this.shapecast({intersectsBounds:i=>Sr.intersectsBox(i),intersectsTriangle:i=>Sr.intersectsTriangle(i)})}intersectsSphere(t){return this.shapecast({intersectsBounds:e=>t.intersectsBox(e),intersectsTriangle:e=>e.intersectsSphere(t)})}closestPointToGeometry(t,e,i={},r={},s=0,a=1/0){return(this.indirect?Au:xu)(this,t,e,i,r,s,a)}closestPointToPoint(t,e={},i=0,r=1/0){return eu(this,t,e,i,r)}getBoundingBox(t){return t.makeEmpty(),this._roots.forEach(i=>{Y(0,new Float32Array(i),to),t.union(to)}),t}}function eo(n,t,e){return n===null?null:(n.point.applyMatrix4(t.matrixWorld),n.distance=n.point.distanceTo(e.ray.origin),n.object=t,n)}const br=new M.Ray,io=new M.Vector3,ro=new M.Matrix4,Bu=M.Mesh.prototype.raycast,Iu=M.BatchedMesh.prototype.raycast,no=new M.Vector3,ct=new M.Mesh,Tr=[];function Uu(n,t){this.isBatchedMesh?Nu.call(this,n,t):Du.call(this,n,t)}function Nu(n,t){if(this.boundsTrees){const e=this.boundsTrees,i=this._drawInfo||this._instanceInfo,r=this._drawRanges||this._geometryInfo,s=this.matrixWorld;ct.material=this.material,ct.geometry=this.geometry;const a=ct.geometry.boundsTree,o=ct.geometry.drawRange;ct.geometry.boundingSphere===null&&(ct.geometry.boundingSphere=new M.Sphere);for(let c=0,l=i.length;c<l;c++){if(!this.getVisibleAt(c))continue;const u=i[c].geometryIndex;if(ct.geometry.boundsTree=e[u],this.getMatrixAt(c,ct.matrixWorld).premultiply(s),!ct.geometry.boundsTree){this.getBoundingBoxAt(u,ct.geometry.boundingBox),this.getBoundingSphereAt(u,ct.geometry.boundingSphere);const h=r[u];ct.geometry.setDrawRange(h.start,h.count)}ct.raycast(n,Tr);for(let h=0,f=Tr.length;h<f;h++){const d=Tr[h];d.object=this,d.batchId=c,t.push(d)}Tr.length=0}ct.geometry.boundsTree=a,ct.geometry.drawRange=o,ct.material=null,ct.geometry=null}else Iu.call(this,n,t)}function Du(n,t){if(this.geometry.boundsTree){if(this.material===void 0)return;ro.copy(this.matrixWorld).invert(),br.copy(n.ray).applyMatrix4(ro),no.setFromMatrixScale(this.matrixWorld),io.copy(br.direction).multiply(no);const e=io.length(),i=n.near/e,r=n.far/e,s=this.geometry.boundsTree;if(n.firstHitOnly===!0){const a=eo(s.raycastFirst(br,this.material,i,r),this,n);a&&t.push(a)}else{const a=s.raycast(br,this.material,i,r);for(let o=0,c=a.length;o<c;o++){const l=eo(a[o],this,n);l&&t.push(l)}}}else Bu.call(this,n,t)}function Fu(n={}){return this.boundsTree=new Ki(this,n),this.boundsTree}const Me=new M.Vector3,Ce=new M.Vector3,Pe=new M.Vector3,so=new M.Vector4,Mr=new M.Vector3,Mn=new M.Vector3,oo=new M.Vector4,ao=new M.Vector4,Cr=new M.Matrix4,co=new M.Matrix4;function ci(n,t){if(!n&&!t)return;const e=n.count===t.count,i=n.normalized===t.normalized,r=n.array.constructor===t.array.constructor,s=n.itemSize===t.itemSize;if(!e||!i||!r||!s)throw new Error}function di(n,t=null){const e=n.array.constructor,i=n.normalized,r=n.itemSize,s=t===null?n.count:t;return new M.BufferAttribute(new e(r*s),r,i)}function ya(n,t,e=0){if(n.isInterleavedBufferAttribute){const i=n.itemSize;for(let r=0,s=n.count;r<s;r++){const a=r+e;t.setX(a,n.getX(r)),i>=2&&t.setY(a,n.getY(r)),i>=3&&t.setZ(a,n.getZ(r)),i>=4&&t.setW(a,n.getW(r))}}else{const i=t.array,r=i.constructor,s=i.BYTES_PER_ELEMENT*n.itemSize*e;new r(i.buffer,s,n.array.length).set(n.array)}}function Lu(n,t,e){const i=n.elements,r=t.elements;for(let s=0,a=r.length;s<a;s++)i[s]+=r[s]*e}function lo(n,t,e){const i=n.skeleton,r=n.geometry,s=i.bones,a=i.boneInverses;oo.fromBufferAttribute(r.attributes.skinIndex,t),ao.fromBufferAttribute(r.attributes.skinWeight,t),Cr.elements.fill(0);for(let o=0;o<4;o++){const c=ao.getComponent(o);if(c!==0){const l=oo.getComponent(o);co.multiplyMatrices(s[l].matrixWorld,a[l]),Lu(Cr,co,c)}}return Cr.multiply(n.bindMatrix).premultiply(n.bindMatrixInverse),e.transformDirection(Cr),e}function Cn(n,t,e,i,r){Mr.set(0,0,0);for(let s=0,a=n.length;s<a;s++){const o=t[s],c=n[s];o!==0&&(Mn.fromBufferAttribute(c,i),e?Mr.addScaledVector(Mn,o):Mr.addScaledVector(Mn.sub(r),o))}r.add(Mr)}function Vu(n,t={useGroups:!1,updateIndex:!1,skipAttributes:[]},e=new M.BufferGeometry){const i=n[0].index!==null,{useGroups:r=!1,updateIndex:s=!1,skipAttributes:a=[]}=t,o=new Set(Object.keys(n[0].attributes)),c={};let l=0;e.clearGroups();for(let u=0;u<n.length;++u){const h=n[u];let f=0;if(i!==(h.index!==null))throw new Error("StaticGeometryGenerator: All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them.");for(const d in h.attributes){if(!o.has(d))throw new Error('StaticGeometryGenerator: All geometries must have compatible attributes; make sure "'+d+'" attribute exists among all geometries, or in none of them.');c[d]===void 0&&(c[d]=[]),c[d].push(h.attributes[d]),f++}if(f!==o.size)throw new Error("StaticGeometryGenerator: Make sure all geometries have the same number of attributes.");if(r){let d;if(i)d=h.index.count;else if(h.attributes.position!==void 0)d=h.attributes.position.count;else throw new Error("StaticGeometryGenerator: The geometry must have either an index or a position attribute");e.addGroup(l,d,u),l+=d}}if(i){let u=!1;if(!e.index){let h=0;for(let f=0;f<n.length;++f)h+=n[f].index.count;e.setIndex(new M.BufferAttribute(new Uint32Array(h),1,!1)),u=!0}if(s||u){const h=e.index;let f=0,d=0;for(let y=0;y<n.length;++y){const _=n[y],p=_.index;if(a[y]!==!0)for(let m=0;m<p.count;++m)h.setX(f,p.getX(m)+d),f++;d+=_.attributes.position.count}}}for(const u in c){const h=c[u];if(!(u in e.attributes)){let y=0;for(const _ in h)y+=h[_].count;e.setAttribute(u,di(c[u][0],y))}const f=e.attributes[u];let d=0;for(let y=0,_=h.length;y<_;y++){const p=h[y];a[y]!==!0&&ya(p,f,d),d+=p.count}}return e}function Ju(n,t){if(n===null||t===null)return n===t;if(n.length!==t.length)return!1;for(let e=0,i=n.length;e<i;e++)if(n[e]!==t[e])return!1;return!0}function Gu(n){const{index:t,attributes:e}=n;if(t)for(let i=0,r=t.count;i<r;i+=3){const s=t.getX(i),a=t.getX(i+2);t.setX(i,a),t.setX(i+2,s)}else for(const i in e){const r=e[i],s=r.itemSize;for(let a=0,o=r.count;a<o;a+=3)for(let c=0;c<s;c++){const l=r.getComponent(a,c),u=r.getComponent(a+2,c);r.setComponent(a,c,u),r.setComponent(a+2,c,l)}}return n}class ju{constructor(t){this.matrixWorld=new M.Matrix4,this.geometryHash=null,this.boneMatrices=null,this.primitiveCount=-1,this.mesh=t,this.update()}update(){const t=this.mesh,e=t.geometry,i=t.skeleton,r=(e.index?e.index.count:e.attributes.position.count)/3;if(this.matrixWorld.copy(t.matrixWorld),this.geometryHash=e.attributes.position.version,this.primitiveCount=r,i){i.boneTexture||i.computeBoneTexture(),i.update();const s=i.boneMatrices;!this.boneMatrices||this.boneMatrices.length!==s.length?this.boneMatrices=s.slice():this.boneMatrices.set(s)}else this.boneMatrices=null}didChange(){const t=this.mesh,e=t.geometry,i=(e.index?e.index.count:e.attributes.position.count)/3;return!(this.matrixWorld.equals(t.matrixWorld)&&this.geometryHash===e.attributes.position.version&&Ju(t.skeleton&&t.skeleton.boneMatrices||null,this.boneMatrices)&&this.primitiveCount===i)}}class $u{constructor(t){Array.isArray(t)||(t=[t]);const e=[];t.forEach(i=>{i.traverseVisible(r=>{r.isMesh&&e.push(r)})}),this.meshes=e,this.useGroups=!0,this.applyWorldTransforms=!0,this.attributes=["position","normal","color","tangent","uv","uv2"],this._intermediateGeometry=new Array(e.length).fill().map(()=>new M.BufferGeometry),this._diffMap=new WeakMap}getMaterials(){const t=[];return this.meshes.forEach(e=>{Array.isArray(e.material)?t.push(...e.material):t.push(e.material)}),t}generate(t=new M.BufferGeometry){let e=[];const{meshes:i,useGroups:r,_intermediateGeometry:s,_diffMap:a}=this;for(let o=0,c=i.length;o<c;o++){const l=i[o],u=s[o],h=a.get(l);!h||h.didChange(l)?(this._convertToStaticGeometry(l,u),e.push(!1),h?h.update():a.set(l,new ju(l))):e.push(!0)}if(s.length===0){t.setIndex(null);const o=t.attributes;for(const c in o)t.deleteAttribute(c);for(const c in this.attributes)t.setAttribute(this.attributes[c],new M.BufferAttribute(new Float32Array(0),4,!1))}else Vu(s,{useGroups:r,skipAttributes:e},t);for(const o in t.attributes)t.attributes[o].needsUpdate=!0;return t}_convertToStaticGeometry(t,e=new M.BufferGeometry){const i=t.geometry,r=this.applyWorldTransforms,s=this.attributes.includes("normal"),a=this.attributes.includes("tangent"),o=i.attributes,c=e.attributes;!e.index&&i.index&&(e.index=i.index.clone()),c.position||e.setAttribute("position",di(o.position)),s&&!c.normal&&o.normal&&e.setAttribute("normal",di(o.normal)),a&&!c.tangent&&o.tangent&&e.setAttribute("tangent",di(o.tangent)),ci(i.index,e.index),ci(o.position,c.position),s&&ci(o.normal,c.normal),a&&ci(o.tangent,c.tangent);const l=o.position,u=s?o.normal:null,h=a?o.tangent:null,f=i.morphAttributes.position,d=i.morphAttributes.normal,y=i.morphAttributes.tangent,_=i.morphTargetsRelative,p=t.morphTargetInfluences,m=new M.Matrix3;m.getNormalMatrix(t.matrixWorld),i.index&&e.index.array.set(i.index.array);for(let g=0,v=o.position.count;g<v;g++)Me.fromBufferAttribute(l,g),u&&Ce.fromBufferAttribute(u,g),h&&(so.fromBufferAttribute(h,g),Pe.fromBufferAttribute(h,g)),p&&(f&&Cn(f,p,_,g,Me),d&&Cn(d,p,_,g,Ce),y&&Cn(y,p,_,g,Pe)),t.isSkinnedMesh&&(t.applyBoneTransform(g,Me),u&&lo(t,g,Ce),h&&lo(t,g,Pe)),r&&Me.applyMatrix4(t.matrixWorld),c.position.setXYZ(g,Me.x,Me.y,Me.z),u&&(r&&Ce.applyNormalMatrix(m),c.normal.setXYZ(g,Ce.x,Ce.y,Ce.z)),h&&(r&&Pe.transformDirection(t.matrixWorld),c.tangent.setXYZW(g,Pe.x,Pe.y,Pe.z,so.w));for(const g in this.attributes){const v=this.attributes[g];v==="position"||v==="tangent"||v==="normal"||!(v in o)||(c[v]||e.setAttribute(v,di(o[v])),ci(o[v],c[v]),ya(o[v],c[v]))}return t.matrixWorld.determinant()<0&&Gu(e),e}}const qu=Object.freeze(Object.defineProperty({__proto__:null,AVERAGE:la,CENTER:rs,CONTAINED:Dn,ExtendedTriangle:Rt,MeshBVH:Ki,OrientedBox:dt,SAH:ua,StaticGeometryGenerator:$u,acceleratedRaycast:Uu,computeBoundsTree:Fu},Symbol.toStringTag,{value:"Module"}));class Xu{constructor(t){this.name="WorkerBase",this.running=!1,this.worker=t,this.worker.onerror=e=>{throw e.message?new Error(`${this.name}: Could not create Web Worker with error "${e.message}"`):new Error(`${this.name}: Could not create Web Worker.`)}}runTask(){}generate(...t){if(this.running)throw new Error("GenerateMeshBVHWorker: Already running job.");if(this.worker===null)throw new Error("GenerateMeshBVHWorker: Worker has been disposed.");this.running=!0;const e=this.runTask(this.worker,...t);return e.finally(()=>{this.running=!1}),e}dispose(){this.worker.terminate(),this.worker=null}}exports.$70d766613f57b014$export$2e2bcd8739ae039=Ko;exports.BatchedParticleRenderer=Pl;exports.Builder=Wn;exports.ByteBuffer=gi;exports.ConstantColor=Re;exports.ConstantValue=D;exports.Matrix4=Dt;exports.MeshBVH=Ki;exports.MotionController=Ta;exports.ParticleSystem=Fr;exports.SIZE_PREFIX_LENGTH=ho;exports.TrailParticle=Nr;exports.Vector4=bt;exports.WorkerBase=Xu;exports.bundler=ec;exports.createNoise4D=El;exports.fetchProfile=va;exports.index=zl;exports.index$1=qu;exports.md5=gc;exports.v5=fc;
|