@needle-tools/engine
Version:
Needle Engine is a web-based runtime for 3D apps. It runs on your machine for development with great integrations into editors like Unity or Blender - and can be deployed onto any device! It is flexible, extensible and networking and XR are built-in
11 lines • 701 kB
JavaScript
"use strict";const X=require("./three.light.umd.cjs"),ot={Handedness:Object.freeze({NONE:"none",LEFT:"left",RIGHT:"right"}),ComponentState:Object.freeze({DEFAULT:"default",TOUCHED:"touched",PRESSED:"pressed"}),ComponentProperty:Object.freeze({BUTTON:"button",X_AXIS:"xAxis",Y_AXIS:"yAxis",STATE:"state"}),ComponentType:Object.freeze({TRIGGER:"trigger",SQUEEZE:"squeeze",TOUCHPAD:"touchpad",THUMBSTICK:"thumbstick",BUTTON:"button"}),ButtonTouchThreshold:.05,AxisTouchThreshold:.1,VisualResponseProperty:Object.freeze({TRANSFORM:"transform",VISIBILITY:"visibility"})};async function Vr(s){const t=await fetch(s);if(t.ok)return t.json();throw new Error(t.statusText)}async function Fc(s){if(!s)throw new Error("No basePath supplied");return await Vr(`${s}/profilesList.json`)}async function Qc(s,t,e=null,i=!0){if(!s)throw new Error("No xrInputSource supplied");if(!t)throw new Error("No basePath supplied");const n=await Fc(t);let o;if(s.profiles.some(c=>{const a=n[c];return a&&(o={profileId:c,profilePath:`${t}/${a.path}`,deprecated:!!a.deprecated}),!!o}),!o){if(!e)throw new Error("No matching profile name found");const c=n[e];if(!c)throw new Error(`No matching profile name found and default profile "${e}" missing.`);o={profileId:e,profilePath:`${t}/${c.path}`,deprecated:!!c.deprecated}}const r=await Vr(o.profilePath);let l;if(i){let c;if(s.handedness==="any"?c=r.layouts[Object.keys(r.layouts)[0]]:c=r.layouts[s.handedness],!c)throw new Error(`No matching handedness, ${s.handedness}, in profile ${o.profileId}`);c.assetPath&&(l=o.profilePath.replace("profile.json",c.assetPath))}return{profile:r,assetPath:l}}const wc={xAxis:0,yAxis:0,button:0,state:ot.ComponentState.DEFAULT};function Bc(s=0,t=0){let e=s,i=t;if(Math.sqrt(s*s+t*t)>1){const r=Math.atan2(t,s);e=Math.cos(r),i=Math.sin(r)}return{normalizedXAxis:e*.5+.5,normalizedYAxis:i*.5+.5}}class Ec{constructor(t){this.componentProperty=t.componentProperty,this.states=t.states,this.valueNodeName=t.valueNodeName,this.valueNodeProperty=t.valueNodeProperty,this.valueNodeProperty===ot.VisualResponseProperty.TRANSFORM&&(this.minNodeName=t.minNodeName,this.maxNodeName=t.maxNodeName),this.value=0,this.updateFromComponent(wc)}updateFromComponent({xAxis:t,yAxis:e,button:i,state:n}){const{normalizedXAxis:o,normalizedYAxis:r}=Bc(t,e);switch(this.componentProperty){case ot.ComponentProperty.X_AXIS:this.value=this.states.includes(n)?o:.5;break;case ot.ComponentProperty.Y_AXIS:this.value=this.states.includes(n)?r:.5;break;case ot.ComponentProperty.BUTTON:this.value=this.states.includes(n)?i:0;break;case ot.ComponentProperty.STATE:this.valueNodeProperty===ot.VisualResponseProperty.VISIBILITY?this.value=this.states.includes(n):this.value=this.states.includes(n)?1:0;break;default:throw new Error(`Unexpected visualResponse componentProperty ${this.componentProperty}`)}}}class jc{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 n=new Ec(e.visualResponses[i]);this.visualResponses[i]=n}),this.gamepadIndices=Object.assign({},e.gamepadIndices),this.values={state:ot.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=ot.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=ot.ComponentState.PRESSED:(e.touched||this.values.button>ot.ButtonTouchThreshold)&&(this.values.state=ot.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===ot.ComponentState.DEFAULT&&Math.abs(this.values.xAxis)>ot.AxisTouchThreshold&&(this.values.state=ot.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===ot.ComponentState.DEFAULT&&Math.abs(this.values.yAxis)>ot.AxisTouchThreshold&&(this.values.state=ot.ComponentState.TOUCHED)),Object.values(this.visualResponses).forEach(e=>{e.updateFromComponent(this.values)})}}class Oc{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(n=>{const o=this.layoutDescription.components[n];this.components[n]=new jc(n,o)}),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 rn=2,wt=4,ee=4,Rr=4,ae=new Int32Array(2),bo=new Float32Array(ae.buffer),yo=new Float64Array(ae.buffer),as=new Uint16Array(new Uint8Array([1,0]).buffer)[0]===1;class se{constructor(t,e){this.low=t|0,this.high=e|0}static create(t,e){return t==0&&e==0?se.ZERO:new se(t,e)}toFloat64(){return(this.low>>>0)+this.high*4294967296}equals(t){return this.low==t.low&&this.high==t.high}}se.ZERO=new se(0,0);var vn;(function(s){s[s.UTF8_BYTES=1]="UTF8_BYTES",s[s.UTF16_STRING=2]="UTF16_STRING"})(vn||(vn={}));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 se(this.readInt32(t),this.readInt32(t+4))}readUint64(t){return new se(this.readUint32(t),this.readUint32(t+4))}readFloat32(t){return ae[0]=this.readInt32(t),bo[0]}readFloat64(t){return ae[as?0:1]=this.readInt32(t),ae[as?1:0]=this.readInt32(t+4),yo[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){bo[0]=e,this.writeInt32(t,ae[0])}writeFloat64(t,e){yo[0]=e,this.writeInt32(t,ae[as?0:1]),this.writeInt32(t+4,ae[as?1:0])}getBufferIdentifier(){if(this.bytes_.length<this.position_+wt+ee)throw new Error("FlatBuffers: ByteBuffer is too short to contain an identifier.");let t="";for(let e=0;e<ee;e++)t+=String.fromCharCode(this.readInt8(this.position_+wt+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 n="",o=0;if(t+=wt,e===vn.UTF8_BYTES)return this.bytes_.subarray(t,t+i);for(;o<i;){let r;const l=this.readUint8(t+o++);if(l<192)r=l;else{const c=this.readUint8(t+o++);if(l<224)r=(l&31)<<6|c&63;else{const a=this.readUint8(t+o++);if(l<240)r=(l&15)<<12|(c&63)<<6|a&63;else{const d=this.readUint8(t+o++);r=(l&7)<<18|(c&63)<<12|(a&63)<<6|d&63}}}r<65536?n+=String.fromCharCode(r):(r-=65536,n+=String.fromCharCode((r>>10)+55296,(r&1024-1)+56320))}return n}__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)+wt}__vector_len(t){return this.readInt32(t+this.readInt32(t))}__has_identifier(t){if(t.length!=ee)throw new Error("FlatBuffers: file identifier must be length "+ee);for(let e=0;e<ee;e++)if(t.charCodeAt(e)!=this.readInt8(this.position()+wt+e))return!1;return!0}createLong(t,e){return se.create(t,e)}createScalarList(t,e){const i=[];for(let n=0;n<e;++n)t(n)!==null&&i.push(t(n));return i}createObjList(t,e){const i=[];for(let n=0;n<e;++n){const o=t(n);o!==null&&i.push(o.unpack())}return i}}class to{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 n=this.bb.capacity();this.bb=to.growByteBuffer(this.bb),this.space+=this.bb.capacity()-n}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,n=gi.allocate(i);return n.setPosition(i-e),n.bytes().set(t.bytes(),i-e),n}addOffset(t){this.prep(wt,0),this.writeInt32(this.offset()-t+wt)}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 n=2;this.addInt16(t-this.object_start);const o=(i+n)*rn;this.addInt16(o);let r=0;const l=this.space;t:for(e=0;e<this.vtables.length;e++){const c=this.bb.capacity()-this.vtables[e];if(o==this.bb.readInt16(c)){for(let a=rn;a<o;a+=rn)if(this.bb.readInt16(l+a)!=this.bb.readInt16(c+a))continue t;r=this.vtables[e];break}}return r?(this.space=this.bb.capacity()-t,this.bb.writeInt32(this.space,r-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 n=i?Rr:0;if(e){const o=e;if(this.prep(this.minalign,wt+ee+n),o.length!=ee)throw new Error("FlatBuffers: file identifier must be length "+ee);for(let r=ee-1;r>=0;r--)this.writeInt8(o.charCodeAt(r))}this.prep(this.minalign,wt+n),this.addOffset(t),n&&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,n=i-this.bb.readInt32(i);if(!(this.bb.readInt16(n+e)!=0))throw new Error("FlatBuffers: field "+e+" must be set")}startVector(t,e,i){this.notNested(),this.vector_num_elems=e,this.prep(wt,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 n;const o=t.charCodeAt(i++);if(o<55296||o>=56320)n=o;else{const r=t.charCodeAt(i++);n=(o<<10)+r+(65536-56623104-56320)}n<128?e.push(n):(n<2048?e.push(n>>6&31|192):(n<65536?e.push(n>>12&15|224):e.push(n>>18&7|240,n>>12&63|128),e.push(n>>6&63|128)),e.push(n&63|128))}}this.addInt8(0),this.startVector(1,e.length,1),this.bb.setPosition(this.space-=e.length);for(let i=0,n=this.space,o=this.bb.bytes();i<e.length;i++)o[n++]=e[i];return this.endVector()}createLong(t,e){return se.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 n=t[i];if(n!==null)e.push(this.createObjectOffset(n));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 qs(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}var xr={exports:{}};(function(s){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}}(),s.exports.binaryFeatures=t;var e=s.exports.BlobBuilder;typeof window<"u"&&(e=s.exports.BlobBuilder=window.WebKitBlobBuilder||window.MozBlobBuilder||window.MSBlobBuilder||window.BlobBuilder);function i(){this._pieces=[],this._parts=[]}i.prototype.append=function(n){typeof n=="number"?this._pieces.push(n):(this.flush(),this._parts.push(n))},i.prototype.flush=function(){if(this._pieces.length>0){var n=new Uint8Array(this._pieces);t.useArrayBufferView||(n=n.buffer),this._parts.push(n),this._pieces=[]}},i.prototype.getBuffer=function(){if(this.flush(),t.useBlobBuilder){for(var n=new e,o=0,r=this._parts.length;o<r;o++)n.append(this._parts[o]);return n.getBlob()}else return new Blob(this._parts)},s.exports.BufferBuilder=i})(xr);var Lr=xr.exports,Dc=Lr.BufferBuilder,Go=Lr.binaryFeatures,_c={unpack:function(s){var t=new ht(s);return t.unpack()},pack:function(s){var t=new ut;t.pack(s);var e=t.getBuffer();return e}},Ac=_c;function ht(s){this.index=0,this.dataBuffer=s,this.dataView=new Uint8Array(this.dataBuffer),this.length=this.dataBuffer.byteLength}ht.prototype.unpack=function(){var s=this.unpack_uint8();if(s<128)return s;if((s^224)<32)return(s^224)-32;var t;if((t=s^160)<=15)return this.unpack_raw(t);if((t=s^176)<=15)return this.unpack_string(t);if((t=s^144)<=15)return this.unpack_array(t);if((t=s^128)<=15)return this.unpack_map(t);switch(s){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 t=this.unpack_uint16(),this.unpack_string(t);case 217:return t=this.unpack_uint32(),this.unpack_string(t);case 218:return t=this.unpack_uint16(),this.unpack_raw(t);case 219:return t=this.unpack_uint32(),this.unpack_raw(t);case 220:return t=this.unpack_uint16(),this.unpack_array(t);case 221:return t=this.unpack_uint32(),this.unpack_array(t);case 222:return t=this.unpack_uint16(),this.unpack_map(t);case 223:return t=this.unpack_uint32(),this.unpack_map(t)}};ht.prototype.unpack_uint8=function(){var s=this.dataView[this.index]&255;return this.index++,s};ht.prototype.unpack_uint16=function(){var s=this.read(2),t=(s[0]&255)*256+(s[1]&255);return this.index+=2,t};ht.prototype.unpack_uint32=function(){var s=this.read(4),t=((s[0]*256+s[1])*256+s[2])*256+s[3];return this.index+=4,t};ht.prototype.unpack_uint64=function(){var s=this.read(8),t=((((((s[0]*256+s[1])*256+s[2])*256+s[3])*256+s[4])*256+s[5])*256+s[6])*256+s[7];return this.index+=8,t};ht.prototype.unpack_int8=function(){var s=this.unpack_uint8();return s<128?s:s-256};ht.prototype.unpack_int16=function(){var s=this.unpack_uint16();return s<32768?s:s-65536};ht.prototype.unpack_int32=function(){var s=this.unpack_uint32();return s<Math.pow(2,31)?s:s-Math.pow(2,32)};ht.prototype.unpack_int64=function(){var s=this.unpack_uint64();return s<Math.pow(2,63)?s:s-Math.pow(2,64)};ht.prototype.unpack_raw=function(s){if(this.length<this.index+s)throw new Error("BinaryPackFailure: index is out of range "+this.index+" "+s+" "+this.length);var t=this.dataBuffer.slice(this.index,this.index+s);return this.index+=s,t};ht.prototype.unpack_string=function(s){for(var t=this.read(s),e=0,i="",n,o;e<s;)n=t[e],n<128?(i+=String.fromCharCode(n),e++):(n^192)<32?(o=(n^192)<<6|t[e+1]&63,i+=String.fromCharCode(o),e+=2):(o=(n&15)<<12|(t[e+1]&63)<<6|t[e+2]&63,i+=String.fromCharCode(o),e+=3);return this.index+=s,i};ht.prototype.unpack_array=function(s){for(var t=new Array(s),e=0;e<s;e++)t[e]=this.unpack();return t};ht.prototype.unpack_map=function(s){for(var t={},e=0;e<s;e++){var i=this.unpack(),n=this.unpack();t[i]=n}return t};ht.prototype.unpack_float=function(){var s=this.unpack_uint32(),t=s>>31,e=(s>>23&255)-127,i=s&8388607|8388608;return(t===0?1:-1)*i*Math.pow(2,e-23)};ht.prototype.unpack_double=function(){var s=this.unpack_uint32(),t=this.unpack_uint32(),e=s>>31,i=(s>>20&2047)-1023,n=s&1048575|1048576,o=n*Math.pow(2,i-20)+t*Math.pow(2,i-52);return(e===0?1:-1)*o};ht.prototype.read=function(s){var t=this.index;if(t+s<=this.length)return this.dataView.subarray(t,t+s);throw new Error("BinaryPackFailure: read index out of range")};function ut(){this.bufferBuilder=new Dc}ut.prototype.getBuffer=function(){return this.bufferBuilder.getBuffer()};ut.prototype.pack=function(s){var t=typeof s;if(t==="string")this.pack_string(s);else if(t==="number")Math.floor(s)===s?this.pack_integer(s):this.pack_double(s);else if(t==="boolean")s===!0?this.bufferBuilder.append(195):s===!1&&this.bufferBuilder.append(194);else if(t==="undefined")this.bufferBuilder.append(192);else if(t==="object")if(s===null)this.bufferBuilder.append(192);else{var e=s.constructor;if(e==Array)this.pack_array(s);else if(e==Blob||e==File||s instanceof Blob||s instanceof File)this.pack_bin(s);else if(e==ArrayBuffer)Go.useArrayBufferView?this.pack_bin(new Uint8Array(s)):this.pack_bin(s);else if("BYTES_PER_ELEMENT"in s)Go.useArrayBufferView?this.pack_bin(new Uint8Array(s.buffer)):this.pack_bin(s.buffer);else if(e==Object||e.toString().startsWith("class"))this.pack_object(s);else if(e==Date)this.pack_string(s.toString());else if(typeof s.toBinaryPack=="function")this.bufferBuilder.append(s.toBinaryPack());else throw new Error('Type "'+e.toString()+'" not yet supported')}else throw new Error('Type "'+t+'" not yet supported');this.bufferBuilder.flush()};ut.prototype.pack_bin=function(s){var t=s.length||s.byteLength||s.size;if(t<=15)this.pack_uint8(160+t);else if(t<=65535)this.bufferBuilder.append(218),this.pack_uint16(t);else if(t<=4294967295)this.bufferBuilder.append(219),this.pack_uint32(t);else throw new Error("Invalid length");this.bufferBuilder.append(s)};ut.prototype.pack_string=function(s){var t=$c(s);if(t<=15)this.pack_uint8(176+t);else if(t<=65535)this.bufferBuilder.append(216),this.pack_uint16(t);else if(t<=4294967295)this.bufferBuilder.append(217),this.pack_uint32(t);else throw new Error("Invalid length");this.bufferBuilder.append(s)};ut.prototype.pack_array=function(s){var t=s.length;if(t<=15)this.pack_uint8(144+t);else if(t<=65535)this.bufferBuilder.append(220),this.pack_uint16(t);else if(t<=4294967295)this.bufferBuilder.append(221),this.pack_uint32(t);else throw new Error("Invalid length");for(var e=0;e<t;e++)this.pack(s[e])};ut.prototype.pack_integer=function(s){if(s>=-32&&s<=127)this.bufferBuilder.append(s&255);else if(s>=0&&s<=255)this.bufferBuilder.append(204),this.pack_uint8(s);else if(s>=-128&&s<=127)this.bufferBuilder.append(208),this.pack_int8(s);else if(s>=0&&s<=65535)this.bufferBuilder.append(205),this.pack_uint16(s);else if(s>=-32768&&s<=32767)this.bufferBuilder.append(209),this.pack_int16(s);else if(s>=0&&s<=4294967295)this.bufferBuilder.append(206),this.pack_uint32(s);else if(s>=-2147483648&&s<=2147483647)this.bufferBuilder.append(210),this.pack_int32(s);else if(s>=-9223372036854776e3&&s<=9223372036854776e3)this.bufferBuilder.append(211),this.pack_int64(s);else if(s>=0&&s<=18446744073709552e3)this.bufferBuilder.append(207),this.pack_uint64(s);else throw new Error("Invalid integer")};ut.prototype.pack_double=function(s){var t=0;s<0&&(t=1,s=-s);var e=Math.floor(Math.log(s)/Math.LN2),i=s/Math.pow(2,e)-1,n=Math.floor(i*Math.pow(2,52)),o=Math.pow(2,32),r=t<<31|e+1023<<20|n/o&1048575,l=n%o;this.bufferBuilder.append(203),this.pack_int32(r),this.pack_int32(l)};ut.prototype.pack_object=function(s){var t=Object.keys(s),e=t.length;if(e<=15)this.pack_uint8(128+e);else if(e<=65535)this.bufferBuilder.append(222),this.pack_uint16(e);else if(e<=4294967295)this.bufferBuilder.append(223),this.pack_uint32(e);else throw new Error("Invalid length");for(var i in s)s.hasOwnProperty(i)&&(this.pack(i),this.pack(s[i]))};ut.prototype.pack_uint8=function(s){this.bufferBuilder.append(s)};ut.prototype.pack_uint16=function(s){this.bufferBuilder.append(s>>8),this.bufferBuilder.append(s&255)};ut.prototype.pack_uint32=function(s){var t=s&4294967295;this.bufferBuilder.append((t&4278190080)>>>24),this.bufferBuilder.append((t&16711680)>>>16),this.bufferBuilder.append((t&65280)>>>8),this.bufferBuilder.append(t&255)};ut.prototype.pack_uint64=function(s){var t=s/Math.pow(2,32),e=s%Math.pow(2,32);this.bufferBuilder.append((t&4278190080)>>>24),this.bufferBuilder.append((t&16711680)>>>16),this.bufferBuilder.append((t&65280)>>>8),this.bufferBuilder.append(t&255),this.bufferBuilder.append((e&4278190080)>>>24),this.bufferBuilder.append((e&16711680)>>>16),this.bufferBuilder.append((e&65280)>>>8),this.bufferBuilder.append(e&255)};ut.prototype.pack_int8=function(s){this.bufferBuilder.append(s&255)};ut.prototype.pack_int16=function(s){this.bufferBuilder.append((s&65280)>>8),this.bufferBuilder.append(s&255)};ut.prototype.pack_int32=function(s){this.bufferBuilder.append(s>>>24&255),this.bufferBuilder.append((s&16711680)>>>16),this.bufferBuilder.append((s&65280)>>>8),this.bufferBuilder.append(s&255)};ut.prototype.pack_int64=function(s){var t=Math.floor(s/Math.pow(2,32)),e=s%Math.pow(2,32);this.bufferBuilder.append((t&4278190080)>>>24),this.bufferBuilder.append((t&16711680)>>>16),this.bufferBuilder.append((t&65280)>>>8),this.bufferBuilder.append(t&255),this.bufferBuilder.append((e&4278190080)>>>24),this.bufferBuilder.append((e&16711680)>>>16),this.bufferBuilder.append((e&65280)>>>8),this.bufferBuilder.append(e&255)};function qc(s){var t=s.charCodeAt(0);return t<=2047?"00":t<=65535?"000":t<=2097151?"0000":t<=67108863?"00000":"000000"}function $c(s){return s.length>600?new Blob([s]).size:s.replace(/[^\u0000-\u007F]/g,qc).length}const Zo=qs(Ac);let Sr=!0,Wr=!0;function fi(s,t,e){const i=s.match(t);return i&&i.length>=e&&parseInt(i[e],10)}function qe(s,t,e){if(!s.RTCPeerConnection)return;const i=s.RTCPeerConnection.prototype,n=i.addEventListener;i.addEventListener=function(r,l){if(r!==t)return n.apply(this,arguments);const c=a=>{const d=e(a);d&&(l.handleEvent?l.handleEvent(d):l(d))};return this._eventMap=this._eventMap||{},this._eventMap[t]||(this._eventMap[t]=new Map),this._eventMap[t].set(l,c),n.apply(this,[r,c])};const o=i.removeEventListener;i.removeEventListener=function(r,l){if(r!==t||!this._eventMap||!this._eventMap[t])return o.apply(this,arguments);if(!this._eventMap[t].has(l))return o.apply(this,arguments);const c=this._eventMap[t].get(l);return this._eventMap[t].delete(l),this._eventMap[t].size===0&&delete this._eventMap[t],Object.keys(this._eventMap).length===0&&delete this._eventMap,o.apply(this,[r,c])},Object.defineProperty(i,"on"+t,{get(){return this["_on"+t]},set(r){this["_on"+t]&&(this.removeEventListener(t,this["_on"+t]),delete this["_on"+t]),r&&this.addEventListener(t,this["_on"+t]=r)},enumerable:!0,configurable:!0})}function tl(s){return typeof s!="boolean"?new Error("Argument type: "+typeof s+". Please use a boolean."):(Sr=s,s?"adapter.js logging disabled":"adapter.js logging enabled")}function el(s){return typeof s!="boolean"?new Error("Argument type: "+typeof s+". Please use a boolean."):(Wr=!s,"adapter.js deprecation warnings "+(s?"disabled":"enabled"))}function eo(){if(typeof window=="object"){if(Sr)return;typeof console<"u"&&typeof console.log=="function"&&console.log.apply(console,arguments)}}function $s(s,t){Wr&&console.warn(s+" is deprecated, please use "+t+" instead.")}function il(s){const t={browser:null,version:null};if(typeof s>"u"||!s.navigator)return t.browser="Not a browser.",t;const{navigator:e}=s;if(e.mozGetUserMedia)t.browser="firefox",t.version=fi(e.userAgent,/Firefox\/(\d+)\./,1);else if(e.webkitGetUserMedia||s.isSecureContext===!1&&s.webkitRTCPeerConnection&&!s.RTCIceGatherer)t.browser="chrome",t.version=fi(e.userAgent,/Chrom(e|ium)\/(\d+)\./,2);else if(e.mediaDevices&&e.userAgent.match(/Edge\/(\d+).(\d+)$/))t.browser="edge",t.version=fi(e.userAgent,/Edge\/(\d+).(\d+)$/,2);else if(s.RTCPeerConnection&&e.userAgent.match(/AppleWebKit\/(\d+)\./))t.browser="safari",t.version=fi(e.userAgent,/AppleWebKit\/(\d+)\./,1),t.supportsUnifiedPlan=s.RTCRtpTransceiver&&"currentDirection"in s.RTCRtpTransceiver.prototype;else return t.browser="Not a supported browser.",t;return t}function Xo(s){return Object.prototype.toString.call(s)==="[object Object]"}function gr(s){return Xo(s)?Object.keys(s).reduce(function(t,e){const i=Xo(s[e]),n=i?gr(s[e]):s[e],o=i&&!Object.keys(n).length;return n===void 0||o?t:Object.assign(t,{[e]:n})},{}):s}function Kn(s,t,e){!t||e.has(t.id)||(e.set(t.id,t),Object.keys(t).forEach(i=>{i.endsWith("Id")?Kn(s,s.get(t[i]),e):i.endsWith("Ids")&&t[i].forEach(n=>{Kn(s,s.get(n),e)})}))}function fo(s,t,e){const i=e?"outbound-rtp":"inbound-rtp",n=new Map;if(t===null)return n;const o=[];return s.forEach(r=>{r.type==="track"&&r.trackIdentifier===t.id&&o.push(r)}),o.forEach(r=>{s.forEach(l=>{l.type===i&&l.trackId===r.id&&Kn(s,l,n)})}),n}const Vo=eo;function Cr(s,t){const e=s&&s.navigator;if(!e.mediaDevices)return;const i=function(l){if(typeof l!="object"||l.mandatory||l.optional)return l;const c={};return Object.keys(l).forEach(a=>{if(a==="require"||a==="advanced"||a==="mediaSource")return;const d=typeof l[a]=="object"?l[a]:{ideal:l[a]};d.exact!==void 0&&typeof d.exact=="number"&&(d.min=d.max=d.exact);const h=function(u,p){return u?u+p.charAt(0).toUpperCase()+p.slice(1):p==="deviceId"?"sourceId":p};if(d.ideal!==void 0){c.optional=c.optional||[];let u={};typeof d.ideal=="number"?(u[h("min",a)]=d.ideal,c.optional.push(u),u={},u[h("max",a)]=d.ideal,c.optional.push(u)):(u[h("",a)]=d.ideal,c.optional.push(u))}d.exact!==void 0&&typeof d.exact!="number"?(c.mandatory=c.mandatory||{},c.mandatory[h("",a)]=d.exact):["min","max"].forEach(u=>{d[u]!==void 0&&(c.mandatory=c.mandatory||{},c.mandatory[h(u,a)]=d[u])})}),l.advanced&&(c.optional=(c.optional||[]).concat(l.advanced)),c},n=function(l,c){if(t.version>=61)return c(l);if(l=JSON.parse(JSON.stringify(l)),l&&typeof l.audio=="object"){const a=function(d,h,u){h in d&&!(u in d)&&(d[u]=d[h],delete d[h])};l=JSON.parse(JSON.stringify(l)),a(l.audio,"autoGainControl","googAutoGainControl"),a(l.audio,"noiseSuppression","googNoiseSuppression"),l.audio=i(l.audio)}if(l&&typeof l.video=="object"){let a=l.video.facingMode;a=a&&(typeof a=="object"?a:{ideal:a});const d=t.version<66;if(a&&(a.exact==="user"||a.exact==="environment"||a.ideal==="user"||a.ideal==="environment")&&!(e.mediaDevices.getSupportedConstraints&&e.mediaDevices.getSupportedConstraints().facingMode&&!d)){delete l.video.facingMode;let h;if(a.exact==="environment"||a.ideal==="environment"?h=["back","rear"]:(a.exact==="user"||a.ideal==="user")&&(h=["front"]),h)return e.mediaDevices.enumerateDevices().then(u=>{u=u.filter(m=>m.kind==="videoinput");let p=u.find(m=>h.some(b=>m.label.toLowerCase().includes(b)));return!p&&u.length&&h.includes("back")&&(p=u[u.length-1]),p&&(l.video.deviceId=a.exact?{exact:p.deviceId}:{ideal:p.deviceId}),l.video=i(l.video),Vo("chrome: "+JSON.stringify(l)),c(l)})}l.video=i(l.video)}return Vo("chrome: "+JSON.stringify(l)),c(l)},o=function(l){return t.version>=64?l:{name:{PermissionDeniedError:"NotAllowedError",PermissionDismissedError:"NotAllowedError",InvalidStateError:"NotAllowedError",DevicesNotFoundError:"NotFoundError",ConstraintNotSatisfiedError:"OverconstrainedError",TrackStartError:"NotReadableError",MediaDeviceFailedDueToShutdown:"NotAllowedError",MediaDeviceKillSwitchOn:"NotAllowedError",TabCaptureError:"AbortError",ScreenCaptureError:"AbortError",DeviceCaptureError:"AbortError"}[l.name]||l.name,message:l.message,constraint:l.constraint||l.constraintName,toString(){return this.name+(this.message&&": ")+this.message}}},r=function(l,c,a){n(l,d=>{e.webkitGetUserMedia(d,c,h=>{a&&a(o(h))})})};if(e.getUserMedia=r.bind(e),e.mediaDevices.getUserMedia){const l=e.mediaDevices.getUserMedia.bind(e.mediaDevices);e.mediaDevices.getUserMedia=function(c){return n(c,a=>l(a).then(d=>{if(a.audio&&!d.getAudioTracks().length||a.video&&!d.getVideoTracks().length)throw d.getTracks().forEach(h=>{h.stop()}),new DOMException("","NotFoundError");return d},d=>Promise.reject(o(d))))}}}function sl(s,t){if(!(s.navigator.mediaDevices&&"getDisplayMedia"in s.navigator.mediaDevices)&&s.navigator.mediaDevices){if(typeof t!="function"){console.error("shimGetDisplayMedia: getSourceId argument is not a function");return}s.navigator.mediaDevices.getDisplayMedia=function(i){return t(i).then(n=>{const o=i.video&&i.video.width,r=i.video&&i.video.height,l=i.video&&i.video.frameRate;return i.video={mandatory:{chromeMediaSource:"desktop",chromeMediaSourceId:n,maxFrameRate:l||3}},o&&(i.video.mandatory.maxWidth=o),r&&(i.video.mandatory.maxHeight=r),s.navigator.mediaDevices.getUserMedia(i)})}}}function zr(s){s.MediaStream=s.MediaStream||s.webkitMediaStream}function vr(s){if(typeof s=="object"&&s.RTCPeerConnection&&!("ontrack"in s.RTCPeerConnection.prototype)){Object.defineProperty(s.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=s.RTCPeerConnection.prototype.setRemoteDescription;s.RTCPeerConnection.prototype.setRemoteDescription=function(){return this._ontrackpoly||(this._ontrackpoly=i=>{i.stream.addEventListener("addtrack",n=>{let o;s.RTCPeerConnection.prototype.getReceivers?o=this.getReceivers().find(l=>l.track&&l.track.id===n.track.id):o={track:n.track};const r=new Event("track");r.track=n.track,r.receiver=o,r.transceiver={receiver:o},r.streams=[i.stream],this.dispatchEvent(r)}),i.stream.getTracks().forEach(n=>{let o;s.RTCPeerConnection.prototype.getReceivers?o=this.getReceivers().find(l=>l.track&&l.track.id===n.id):o={track:n};const r=new Event("track");r.track=n,r.receiver=o,r.transceiver={receiver:o},r.streams=[i.stream],this.dispatchEvent(r)})},this.addEventListener("addstream",this._ontrackpoly)),t.apply(this,arguments)}}else qe(s,"track",t=>(t.transceiver||Object.defineProperty(t,"transceiver",{value:{receiver:t.receiver}}),t))}function Kr(s){if(typeof s=="object"&&s.RTCPeerConnection&&!("getSenders"in s.RTCPeerConnection.prototype)&&"createDTMFSender"in s.RTCPeerConnection.prototype){const t=function(n,o){return{track:o,get dtmf(){return this._dtmf===void 0&&(o.kind==="audio"?this._dtmf=n.createDTMFSender(o):this._dtmf=null),this._dtmf},_pc:n}};if(!s.RTCPeerConnection.prototype.getSenders){s.RTCPeerConnection.prototype.getSenders=function(){return this._senders=this._senders||[],this._senders.slice()};const n=s.RTCPeerConnection.prototype.addTrack;s.RTCPeerConnection.prototype.addTrack=function(l,c){let a=n.apply(this,arguments);return a||(a=t(this,l),this._senders.push(a)),a};const o=s.RTCPeerConnection.prototype.removeTrack;s.RTCPeerConnection.prototype.removeTrack=function(l){o.apply(this,arguments);const c=this._senders.indexOf(l);c!==-1&&this._senders.splice(c,1)}}const e=s.RTCPeerConnection.prototype.addStream;s.RTCPeerConnection.prototype.addStream=function(o){this._senders=this._senders||[],e.apply(this,[o]),o.getTracks().forEach(r=>{this._senders.push(t(this,r))})};const i=s.RTCPeerConnection.prototype.removeStream;s.RTCPeerConnection.prototype.removeStream=function(o){this._senders=this._senders||[],i.apply(this,[o]),o.getTracks().forEach(r=>{const l=this._senders.find(c=>c.track===r);l&&this._senders.splice(this._senders.indexOf(l),1)})}}else if(typeof s=="object"&&s.RTCPeerConnection&&"getSenders"in s.RTCPeerConnection.prototype&&"createDTMFSender"in s.RTCPeerConnection.prototype&&s.RTCRtpSender&&!("dtmf"in s.RTCRtpSender.prototype)){const t=s.RTCPeerConnection.prototype.getSenders;s.RTCPeerConnection.prototype.getSenders=function(){const i=t.apply(this,[]);return i.forEach(n=>n._pc=this),i},Object.defineProperty(s.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 Tr(s){if(!s.RTCPeerConnection)return;const t=s.RTCPeerConnection.prototype.getStats;s.RTCPeerConnection.prototype.getStats=function(){const[i,n,o]=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 r=function(c){const a={};return c.result().forEach(h=>{const u={id:h.id,timestamp:h.timestamp,type:{localcandidate:"local-candidate",remotecandidate:"remote-candidate"}[h.type]||h.type};h.names().forEach(p=>{u[p]=h.stat(p)}),a[u.id]=u}),a},l=function(c){return new Map(Object.keys(c).map(a=>[a,c[a]]))};if(arguments.length>=2){const c=function(a){n(l(r(a)))};return t.apply(this,[c,i])}return new Promise((c,a)=>{t.apply(this,[function(d){c(l(r(d)))},a])}).then(n,o)}}function Mr(s){if(!(typeof s=="object"&&s.RTCPeerConnection&&s.RTCRtpSender&&s.RTCRtpReceiver))return;if(!("getStats"in s.RTCRtpSender.prototype)){const e=s.RTCPeerConnection.prototype.getSenders;e&&(s.RTCPeerConnection.prototype.getSenders=function(){const o=e.apply(this,[]);return o.forEach(r=>r._pc=this),o});const i=s.RTCPeerConnection.prototype.addTrack;i&&(s.RTCPeerConnection.prototype.addTrack=function(){const o=i.apply(this,arguments);return o._pc=this,o}),s.RTCRtpSender.prototype.getStats=function(){const o=this;return this._pc.getStats().then(r=>fo(r,o.track,!0))}}if(!("getStats"in s.RTCRtpReceiver.prototype)){const e=s.RTCPeerConnection.prototype.getReceivers;e&&(s.RTCPeerConnection.prototype.getReceivers=function(){const n=e.apply(this,[]);return n.forEach(o=>o._pc=this),n}),qe(s,"track",i=>(i.receiver._pc=i.srcElement,i)),s.RTCRtpReceiver.prototype.getStats=function(){const n=this;return this._pc.getStats().then(o=>fo(o,n.track,!1))}}if(!("getStats"in s.RTCRtpSender.prototype&&"getStats"in s.RTCRtpReceiver.prototype))return;const t=s.RTCPeerConnection.prototype.getStats;s.RTCPeerConnection.prototype.getStats=function(){if(arguments.length>0&&arguments[0]instanceof s.MediaStreamTrack){const i=arguments[0];let n,o,r;return this.getSenders().forEach(l=>{l.track===i&&(n?r=!0:n=l)}),this.getReceivers().forEach(l=>(l.track===i&&(o?r=!0:o=l),l.track===i)),r||n&&o?Promise.reject(new DOMException("There are more than one sender or receiver for the track.","InvalidAccessError")):n?n.getStats():o?o.getStats():Promise.reject(new DOMException("There is no sender or receiver for the track.","InvalidAccessError"))}return t.apply(this,arguments)}}function Yr(s){s.RTCPeerConnection.prototype.getLocalStreams=function(){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},Object.keys(this._shimmedLocalStreams).map(r=>this._shimmedLocalStreams[r][0])};const t=s.RTCPeerConnection.prototype.addTrack;s.RTCPeerConnection.prototype.addTrack=function(r,l){if(!l)return t.apply(this,arguments);this._shimmedLocalStreams=this._shimmedLocalStreams||{};const c=t.apply(this,arguments);return this._shimmedLocalStreams[l.id]?this._shimmedLocalStreams[l.id].indexOf(c)===-1&&this._shimmedLocalStreams[l.id].push(c):this._shimmedLocalStreams[l.id]=[l,c],c};const e=s.RTCPeerConnection.prototype.addStream;s.RTCPeerConnection.prototype.addStream=function(r){this._shimmedLocalStreams=this._shimmedLocalStreams||{},r.getTracks().forEach(a=>{if(this.getSenders().find(h=>h.track===a))throw new DOMException("Track already exists.","InvalidAccessError")});const l=this.getSenders();e.apply(this,arguments);const c=this.getSenders().filter(a=>l.indexOf(a)===-1);this._shimmedLocalStreams[r.id]=[r].concat(c)};const i=s.RTCPeerConnection.prototype.removeStream;s.RTCPeerConnection.prototype.removeStream=function(r){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},delete this._shimmedLocalStreams[r.id],i.apply(this,arguments)};const n=s.RTCPeerConnection.prototype.removeTrack;s.RTCPeerConnection.prototype.removeTrack=function(r){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},r&&Object.keys(this._shimmedLocalStreams).forEach(l=>{const c=this._shimmedLocalStreams[l].indexOf(r);c!==-1&&this._shimmedLocalStreams[l].splice(c,1),this._shimmedLocalStreams[l].length===1&&delete this._shimmedLocalStreams[l]}),n.apply(this,arguments)}}function kr(s,t){if(!s.RTCPeerConnection)return;if(s.RTCPeerConnection.prototype.addTrack&&t.version>=65)return Yr(s);const e=s.RTCPeerConnection.prototype.getLocalStreams;s.RTCPeerConnection.prototype.getLocalStreams=function(){const d=e.apply(this);return this._reverseStreams=this._reverseStreams||{},d.map(h=>this._reverseStreams[h.id])};const i=s.RTCPeerConnection.prototype.addStream;s.RTCPeerConnection.prototype.addStream=function(d){if(this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},d.getTracks().forEach(h=>{if(this.getSenders().find(p=>p.track===h))throw new DOMException("Track already exists.","InvalidAccessError")}),!this._reverseStreams[d.id]){const h=new s.MediaStream(d.getTracks());this._streams[d.id]=h,this._reverseStreams[h.id]=d,d=h}i.apply(this,[d])};const n=s.RTCPeerConnection.prototype.removeStream;s.RTCPeerConnection.prototype.removeStream=function(d){this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},n.apply(this,[this._streams[d.id]||d]),delete this._reverseStreams[this._streams[d.id]?this._streams[d.id].id:d.id],delete this._streams[d.id]},s.RTCPeerConnection.prototype.addTrack=function(d,h){if(this.signalingState==="closed")throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");const u=[].slice.call(arguments,1);if(u.length!==1||!u[0].getTracks().find(b=>b===d))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(b=>b.track===d))throw new DOMException("Track already exists.","InvalidAccessError");this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{};const m=this._streams[h.id];if(m)m.addTrack(d),Promise.resolve().then(()=>{this.dispatchEvent(new Event("negotiationneeded"))});else{const b=new s.MediaStream([d]);this._streams[h.id]=b,this._reverseStreams[b.id]=h,this.addStream(b)}return this.getSenders().find(b=>b.track===d)};function o(a,d){let h=d.sdp;return Object.keys(a._reverseStreams||[]).forEach(u=>{const p=a._reverseStreams[u],m=a._streams[p.id];h=h.replace(new RegExp(m.id,"g"),p.id)}),new RTCSessionDescription({type:d.type,sdp:h})}function r(a,d){let h=d.sdp;return Object.keys(a._reverseStreams||[]).forEach(u=>{const p=a._reverseStreams[u],m=a._streams[p.id];h=h.replace(new RegExp(p.id,"g"),m.id)}),new RTCSessionDescription({type:d.type,sdp:h})}["createOffer","createAnswer"].forEach(function(a){const d=s.RTCPeerConnection.prototype[a],h={[a](){const u=arguments;return arguments.length&&typeof arguments[0]=="function"?d.apply(this,[m=>{const b=o(this,m);u[0].apply(null,[b])},m=>{u[1]&&u[1].apply(null,m)},arguments[2]]):d.apply(this,arguments).then(m=>o(this,m))}};s.RTCPeerConnection.prototype[a]=h[a]});const l=s.RTCPeerConnection.prototype.setLocalDescription;s.RTCPeerConnection.prototype.setLocalDescription=function(){return!arguments.length||!arguments[0].type?l.apply(this,arguments):(arguments[0]=r(this,arguments[0]),l.apply(this,arguments))};const c=Object.getOwnPropertyDescriptor(s.RTCPeerConnection.prototype,"localDescription");Object.defineProperty(s.RTCPeerConnection.prototype,"localDescription",{get(){const a=c.get.apply(this);return a.type===""?a:o(this,a)}}),s.RTCPeerConnection.prototype.removeTrack=function(d){if(this.signalingState==="closed")throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");if(!d._pc)throw new DOMException("Argument 1 of RTCPeerConnection.removeTrack does not implement interface RTCRtpSender.","TypeError");if(!(d._pc===this))throw new DOMException("Sender was not created by this connection.","InvalidAccessError");this._streams=this._streams||{};let u;Object.keys(this._streams).forEach(p=>{this._streams[p].getTracks().find(b=>d.track===b)&&(u=this._streams[p])}),u&&(u.getTracks().length===1?this.removeStream(this._reverseStreams[u.id]):u.removeTrack(d.track),this.dispatchEvent(new Event("negotiationneeded")))}}function Tn(s,t){!s.RTCPeerConnection&&s.webkitRTCPeerConnection&&(s.RTCPeerConnection=s.webkitRTCPeerConnection),s.RTCPeerConnection&&t.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach(function(e){const i=s.RTCPeerConnection.prototype[e],n={[e](){return arguments[0]=new(e==="addIceCandidate"?s.RTCIceCandidate:s.RTCSessionDescription)(arguments[0]),i.apply(this,arguments)}};s.RTCPeerConnection.prototype[e]=n[e]})}function Hr(s,t){qe(s,"negotiationneeded",e=>{const i=e.target;if(!((t.version<72||i.getConfiguration&&i.getConfiguration().sdpSemantics==="plan-b")&&i.signalingState!=="stable"))return e})}const Ro=Object.freeze(Object.defineProperty({__proto__:null,fixNegotiationNeeded:Hr,shimAddTrackRemoveTrack:kr,shimAddTrackRemoveTrackWithNative:Yr,shimGetDisplayMedia:sl,shimGetSendersWithDtmf:Kr,shimGetStats:Tr,shimGetUserMedia:Cr,shimMediaStream:zr,shimOnTrack:vr,shimPeerConnection:Tn,shimSenderReceiverGetStats:Mr},Symbol.toStringTag,{value:"Module"}));function nl(s,t){let e=!1;return s=JSON.parse(JSON.stringify(s)),s.filter(i=>{if(i&&(i.urls||i.url)){let n=i.urls||i.url;i.url&&!i.urls&&$s("RTCIceServer.url","RTCIceServer.urls");const o=typeof n=="string";return o&&(n=[n]),n=n.filter(r=>{if(r.indexOf("stun:")===0)return!1;const l=r.startsWith("turn")&&!r.startsWith("turn:[")&&r.includes("transport=udp");return l&&!e?(e=!0,!0):l&&!e}),delete i.url,i.urls=o?n[0]:n,!!n.length}})}var Nr={exports:{}};(function(s){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(`
`).map(function(i){return i.trim()})},t.splitSections=function(e){var i=e.split(`
m=`);return i.map(function(n,o){return(o>0?"m="+n:n).trim()+`\r
`})},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(n){return n.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 n={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]},o=8;o<i.length;o+=2)switch(i[o]){case"raddr":n.relatedAddress=i[o+1];break;case"rport":n.relatedPort=parseInt(i[o+1],10);break;case"tcptype":n.tcpType=i[o+1];break;case"ufrag":n.ufrag=i[o+1],n.usernameFragment=i[o+1];break;default:n[i[o]]=i[o+1];break}return n},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 n=e.type;return i.push("typ"),i.push(n),n!=="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(" "),n={payloadType:parseInt(i.shift(),10)};return i=i[0].split("/"),n.name=i[0],n.clockRate=parseInt(i[1],10),n.channels=i.length===3?parseInt(i[2],10):1,n.numChannels=n.channels,n},t.writeRtpMap=function(e){var i=e.payloadType;e.preferredPayloadType!==void 0&&(i=e.preferredPayloadType);var n=e.channels||e.numChannels||1;return"a=rtpmap:"+i+" "+e.name+"/"+e.clockRate+(n!==1?"/"+n:"")+`\r
`},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
`},t.parseFmtp=function(e){for(var i={},n,o=e.substr(e.indexOf(" ")+1).split(";"),r=0;r<o.length;r++)n=o[r].trim().split("="),i[n[0].trim()]=n[1];return i},t.writeFmtp=function(e){var i="",n=e.payloadType;if(e.preferredPayloadType!==void 0&&(n=e.preferredPayloadType),e.parameters&&Object.keys(e.parameters).length){var o=[];Object.keys(e.parameters).forEach(function(r){e.parameters[r]?o.push(r+"="+e.parameters[r]):o.push(r)}),i+="a=fmtp:"+n+" "+o.join(";")+`\r
`}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="",n=e.payloadType;return e.preferredPayloadType!==void 0&&(n=e.preferredPayloadType),e.rtcpFeedback&&e.rtcpFeedback.length&&e.rtcpFeedback.forEach(function(o){i+="a=rtcp-fb:"+n+" "+o.type+(o.parameter&&o.parameter.length?" "+o.parameter:"")+`\r
`}),i},t.parseSsrcMedia=function(e){var i=e.indexOf(" "),n={ssrc:parseInt(e.substr(7,i-7),10)},o=e.indexOf(":",i);return o>-1?(n.attribute=e.substr(i+1,o-i-1),n.value=e.substr(o+1)):n.attribute=e.substr(i+1),n},t.parseSsrcGroup=function(e){var i=e.substr(13).split(" ");return{semantics:i.shift(),ssrcs:i.map(function(n){return parseInt(n,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 n=t.matchPrefix(e+i,"a=fingerprint:");return{role:"auto",fingerprints:n.map(t.parseFingerprint)}},t.writeDtlsParameters=function(e,i){var n="a=setup:"+i+`\r
`;return e.fingerprints.forEach(function(o){n+="a=fingerprint:"+o.algorithm+" "+o.value+`\r
`}),n},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
`},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 n=t.matchPrefix(e+i,"a=crypto:");return n.map(t.parseC