react-sip-kit
Version:
A modern **React SIP.js toolkit** for building web softphones and SIP clients. Supports **audio/video calls**, **call recording**, **screen sharing**, and **device management**, all with a clean, extensible, TypeScript-first architecture.
1 lines • 292 kB
JavaScript
import e,{useMemo as t,useRef as s}from"react";import{jsx as i}from"react/jsx-runtime";const r=e=>{let t;const s=new Set,i=(e,i)=>{const r="function"==typeof e?e(t):e;if(!Object.is(r,t)){const e=t;t=(null!=i?i:"object"!=typeof r||null===r)?r:Object.assign({},t,r),s.forEach(s=>s(t,e))}},r=()=>t,n={setState:i,getState:r,getInitialState:()=>o,subscribe:e=>(s.add(e),()=>s.delete(e))},o=t=e(i,r,n);return n},n=e=>e;const o=t=>{const s=(e=>e?r(e):r)(t),i=t=>function(t,s=n){const i=e.useSyncExternalStore(t.subscribe,()=>s(t.getState()),()=>s(t.getInitialState()));return e.useDebugValue(i),i}(s,t);return Object.assign(i,s),i};let a=0;const c=(d=(e,t)=>({configs:null,statuses:null,userAgents:void 0,devicesInfo:{hasVideoDevice:!1,hasAudioDevice:!1,hasSpeakerDevice:!1,audioInputDevices:[],videoInputDevices:[],speakerDevices:[]},lines:{},usernamesByLineKey:{},lineKeyByRemoteNumber:{},setSipStore:t=>e(e=>({...e,...t})),setConfig:(t,s)=>{e(e=>({...e,configs:{...e.configs,[t]:s}}))},setUserAgent:(t,s)=>{e(e=>({...e,userAgents:{...e.userAgents,[t]:s}}))},addLine:t=>{const s=t.username;e(e=>({...e,lines:{...e.lines,[s]:{...e.lines?.[s],[t.lineKey]:t}},usernamesByLineKey:{...e.usernamesByLineKey,[t.lineKey]:s},lineKeyByRemoteNumber:{...e.usernamesByLineKey,[t.remoteNumber]:t.lineKey}}))},updateLine:t=>{const s=t.username;if(!s)return null;e(e=>e.lines?.[s]?.[t.lineKey]?{...e,lines:{...e.lines,[s]:{...e.lines?.[s],[t.lineKey]:t}}}:e)},removeLine:s=>{const i=t().getUsernameByLineKey(s),r=t().findLineByLineKey(s);if(!i)return null;const n=r?.sipSession?.data.remoteNumber??"";e(e=>{if(!e.lines?.[i]?.[s])return e;const{[s]:t,...r}=e.lines[i],{[s]:o,...a}=e.usernamesByLineKey,{[n]:c,...d}=e.lineKeyByRemoteNumber;return{...e,lines:{...e.lines,[i]:{...r}},usernamesByLineKey:{...a},lineKeyByRemoteNumber:{...d}}})},remove:t=>{if(!t)return null;e(e=>{if(!e.lines?.[t]?.[a])return e;const{[t]:s,...i}=e.lines,{[t]:r,...n}=e.configs,{[t]:o,...c}=e.userAgents,{[t]:d,...h}=e.statuses;return{...e,lines:{...i},configs:{...n},userAgents:{...c},statuses:{...h}}})},removeAll:()=>{e(e=>({...e,lines:{},configs:{},userAgents:{},statuses:{}}))},findLineByLineKey:e=>{const s=t().getUsernameByLineKey(e);return s?t().lines?.[s]?.[e]??null:null},getSessionByLineKey:e=>{const s=t().getUsernameByLineKey(e);return s?t().lines?.[s]?.[e]?.sipSession??null:null},getUsernameByLineKey:e=>t().usernamesByLineKey[e]??null,getUsernameByRemoteNumber:e=>{const s=t().getLineKeyByRemoteNumber(e)??null;return s?t().getUsernameByLineKey(s):null},getLineKeyByRemoteNumber:e=>t().lineKeyByRemoteNumber[e]??null,getLineByRemoteNumber:e=>{const s=t().lineKeyByRemoteNumber[e]??null;return t().findLineByLineKey(s)},getNewLineKey:()=>++a}))?o(d):o;var d;const h=e=>{c.setState(t=>({...t,...e}))},l=()=>c.getState(),u=e=>c.getState()?.userAgents?.[e]??null,g=e=>c?.getState()?.configs?.[e]??null;function p({username:e}){return()=>{const s=c(t=>e&&t.lines?.[e]?Object.keys(t.lines?.[e]).length:0),i=c.getState().lines?.[e]??{},r=t(()=>Object.values(i),[s]);return{status:c(t=>t?.statuses?.[e])??"connecting",lines:r}}}var f="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function m(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var v,w={exports:{}};var y=(v||(v=1,function(e,t){var s="__lodash_hash_undefined__",i=9007199254740991,r="[object Arguments]",n="[object Array]",o="[object Boolean]",a="[object Date]",c="[object Error]",d="[object Function]",h="[object Map]",l="[object Number]",u="[object Object]",g="[object Promise]",p="[object RegExp]",m="[object Set]",v="[object String]",w="[object Symbol]",y="[object WeakMap]",b="[object ArrayBuffer]",S="[object DataView]",T=/^\[object .+?Constructor\]$/,$=/^(?:0|[1-9]\d*)$/,E={};E["[object Float32Array]"]=E["[object Float64Array]"]=E["[object Int8Array]"]=E["[object Int16Array]"]=E["[object Int32Array]"]=E["[object Uint8Array]"]=E["[object Uint8ClampedArray]"]=E["[object Uint16Array]"]=E["[object Uint32Array]"]=!0,E[r]=E[n]=E[b]=E[o]=E[S]=E[a]=E[c]=E[d]=E[h]=E[l]=E[u]=E[p]=E[m]=E[v]=E[y]=!1;var R="object"==typeof f&&f&&f.Object===Object&&f,I="object"==typeof self&&self&&self.Object===Object&&self,C=R||I||Function("return this")(),D=t&&!t.nodeType&&t,A=D&&e&&!e.nodeType&&e,_=A&&A.exports===D,k=_&&R.process,H=function(){try{return k&&k.binding&&k.binding("util")}catch(e){}}(),x=H&&H.isTypedArray;function P(e,t){for(var s=-1,i=null==e?0:e.length;++s<i;)if(t(e[s],s,e))return!0;return!1}function O(e){var t=-1,s=Array(e.size);return e.forEach(function(e,i){s[++t]=[i,e]}),s}function q(e){var t=-1,s=Array(e.size);return e.forEach(function(e){s[++t]=e}),s}var M,N,j,L=Array.prototype,F=Function.prototype,U=Object.prototype,B=C["__core-js_shared__"],G=F.toString,V=U.hasOwnProperty,K=(M=/[^.]+$/.exec(B&&B.keys&&B.keys.IE_PROTO||""))?"Symbol(src)_1."+M:"",Y=U.toString,W=RegExp("^"+G.call(V).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),J=_?C.Buffer:void 0,Z=C.Symbol,z=C.Uint8Array,X=U.propertyIsEnumerable,Q=L.splice,ee=Z?Z.toStringTag:void 0,te=Object.getOwnPropertySymbols,se=J?J.isBuffer:void 0,ie=(N=Object.keys,j=Object,function(e){return N(j(e))}),re=He(C,"DataView"),ne=He(C,"Map"),oe=He(C,"Promise"),ae=He(C,"Set"),ce=He(C,"WeakMap"),de=He(Object,"create"),he=qe(re),le=qe(ne),ue=qe(oe),ge=qe(ae),pe=qe(ce),fe=Z?Z.prototype:void 0,me=fe?fe.valueOf:void 0;function ve(e){var t=-1,s=null==e?0:e.length;for(this.clear();++t<s;){var i=e[t];this.set(i[0],i[1])}}function we(e){var t=-1,s=null==e?0:e.length;for(this.clear();++t<s;){var i=e[t];this.set(i[0],i[1])}}function ye(e){var t=-1,s=null==e?0:e.length;for(this.clear();++t<s;){var i=e[t];this.set(i[0],i[1])}}function be(e){var t=-1,s=null==e?0:e.length;for(this.__data__=new ye;++t<s;)this.add(e[t])}function Se(e){var t=this.__data__=new we(e);this.size=t.size}function Te(e,t){var s=je(e),i=!s&&Ne(e),r=!s&&!i&&Le(e),n=!s&&!i&&!r&&Ve(e),o=s||i||r||n,a=o?function(e,t){for(var s=-1,i=Array(e);++s<e;)i[s]=t(s);return i}(e.length,String):[],c=a.length;for(var d in e)!V.call(e,d)||o&&("length"==d||r&&("offset"==d||"parent"==d)||n&&("buffer"==d||"byteLength"==d||"byteOffset"==d)||Oe(d,c))||a.push(d);return a}function $e(e,t){for(var s=e.length;s--;)if(Me(e[s][0],t))return s;return-1}function Ee(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":ee&&ee in Object(e)?function(e){var t=V.call(e,ee),s=e[ee];try{e[ee]=void 0;var i=!0}catch(e){}var r=Y.call(e);return i&&(t?e[ee]=s:delete e[ee]),r}(e):function(e){return Y.call(e)}(e)}function Re(e){return Ge(e)&&Ee(e)==r}function Ie(e,t,s,i,d){return e===t||(null==e||null==t||!Ge(e)&&!Ge(t)?e!=e&&t!=t:function(e,t,s,i,d,g){var f=je(e),y=je(t),T=f?n:Pe(e),$=y?n:Pe(t),E=(T=T==r?u:T)==u,R=($=$==r?u:$)==u,I=T==$;if(I&&Le(e)){if(!Le(t))return!1;f=!0,E=!1}if(I&&!E)return g||(g=new Se),f||Ve(e)?Ae(e,t,s,i,d,g):function(e,t,s,i,r,n,d){switch(s){case S:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case b:return!(e.byteLength!=t.byteLength||!n(new z(e),new z(t)));case o:case a:case l:return Me(+e,+t);case c:return e.name==t.name&&e.message==t.message;case p:case v:return e==t+"";case h:var u=O;case m:var g=1&i;if(u||(u=q),e.size!=t.size&&!g)return!1;var f=d.get(e);if(f)return f==t;i|=2,d.set(e,t);var y=Ae(u(e),u(t),i,r,n,d);return d.delete(e),y;case w:if(me)return me.call(e)==me.call(t)}return!1}(e,t,T,s,i,d,g);if(!(1&s)){var C=E&&V.call(e,"__wrapped__"),D=R&&V.call(t,"__wrapped__");if(C||D){var A=C?e.value():e,_=D?t.value():t;return g||(g=new Se),d(A,_,s,i,g)}}return!!I&&(g||(g=new Se),function(e,t,s,i,r,n){var o=1&s,a=_e(e),c=a.length,d=_e(t),h=d.length;if(c!=h&&!o)return!1;for(var l=c;l--;){var u=a[l];if(!(o?u in t:V.call(t,u)))return!1}var g=n.get(e);if(g&&n.get(t))return g==t;var p=!0;n.set(e,t),n.set(t,e);for(var f=o;++l<c;){var m=e[u=a[l]],v=t[u];if(i)var w=o?i(v,m,u,t,e,n):i(m,v,u,e,t,n);if(!(void 0===w?m===v||r(m,v,s,i,n):w)){p=!1;break}f||(f="constructor"==u)}if(p&&!f){var y=e.constructor,b=t.constructor;y==b||!("constructor"in e)||!("constructor"in t)||"function"==typeof y&&y instanceof y&&"function"==typeof b&&b instanceof b||(p=!1)}return n.delete(e),n.delete(t),p}(e,t,s,i,d,g))}(e,t,s,i,Ie,d))}function Ce(e){return!(!Be(e)||function(e){return!!K&&K in e}(e))&&(Fe(e)?W:T).test(qe(e))}function De(e){if(s=(t=e)&&t.constructor,i="function"==typeof s&&s.prototype||U,t!==i)return ie(e);var t,s,i,r=[];for(var n in Object(e))V.call(e,n)&&"constructor"!=n&&r.push(n);return r}function Ae(e,t,s,i,r,n){var o=1&s,a=e.length,c=t.length;if(a!=c&&!(o&&c>a))return!1;var d=n.get(e);if(d&&n.get(t))return d==t;var h=-1,l=!0,u=2&s?new be:void 0;for(n.set(e,t),n.set(t,e);++h<a;){var g=e[h],p=t[h];if(i)var f=o?i(p,g,h,t,e,n):i(g,p,h,e,t,n);if(void 0!==f){if(f)continue;l=!1;break}if(u){if(!P(t,function(e,t){if(o=t,!u.has(o)&&(g===e||r(g,e,s,i,n)))return u.push(t);var o})){l=!1;break}}else if(g!==p&&!r(g,p,s,i,n)){l=!1;break}}return n.delete(e),n.delete(t),l}function _e(e){return function(e,t,s){var i=t(e);return je(e)?i:function(e,t){for(var s=-1,i=t.length,r=e.length;++s<i;)e[r+s]=t[s];return e}(i,s(e))}(e,Ke,xe)}function ke(e,t){var s,i,r=e.__data__;return("string"==(i=typeof(s=t))||"number"==i||"symbol"==i||"boolean"==i?"__proto__"!==s:null===s)?r["string"==typeof t?"string":"hash"]:r.map}function He(e,t){var s=function(e,t){return null==e?void 0:e[t]}(e,t);return Ce(s)?s:void 0}ve.prototype.clear=function(){this.__data__=de?de(null):{},this.size=0},ve.prototype.delete=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t},ve.prototype.get=function(e){var t=this.__data__;if(de){var i=t[e];return i===s?void 0:i}return V.call(t,e)?t[e]:void 0},ve.prototype.has=function(e){var t=this.__data__;return de?void 0!==t[e]:V.call(t,e)},ve.prototype.set=function(e,t){var i=this.__data__;return this.size+=this.has(e)?0:1,i[e]=de&&void 0===t?s:t,this},we.prototype.clear=function(){this.__data__=[],this.size=0},we.prototype.delete=function(e){var t=this.__data__,s=$e(t,e);return!(s<0||(s==t.length-1?t.pop():Q.call(t,s,1),--this.size,0))},we.prototype.get=function(e){var t=this.__data__,s=$e(t,e);return s<0?void 0:t[s][1]},we.prototype.has=function(e){return $e(this.__data__,e)>-1},we.prototype.set=function(e,t){var s=this.__data__,i=$e(s,e);return i<0?(++this.size,s.push([e,t])):s[i][1]=t,this},ye.prototype.clear=function(){this.size=0,this.__data__={hash:new ve,map:new(ne||we),string:new ve}},ye.prototype.delete=function(e){var t=ke(this,e).delete(e);return this.size-=t?1:0,t},ye.prototype.get=function(e){return ke(this,e).get(e)},ye.prototype.has=function(e){return ke(this,e).has(e)},ye.prototype.set=function(e,t){var s=ke(this,e),i=s.size;return s.set(e,t),this.size+=s.size==i?0:1,this},be.prototype.add=be.prototype.push=function(e){return this.__data__.set(e,s),this},be.prototype.has=function(e){return this.__data__.has(e)},Se.prototype.clear=function(){this.__data__=new we,this.size=0},Se.prototype.delete=function(e){var t=this.__data__,s=t.delete(e);return this.size=t.size,s},Se.prototype.get=function(e){return this.__data__.get(e)},Se.prototype.has=function(e){return this.__data__.has(e)},Se.prototype.set=function(e,t){var s=this.__data__;if(s instanceof we){var i=s.__data__;if(!ne||i.length<199)return i.push([e,t]),this.size=++s.size,this;s=this.__data__=new ye(i)}return s.set(e,t),this.size=s.size,this};var xe=te?function(e){return null==e?[]:(e=Object(e),function(e,t){for(var s=-1,i=null==e?0:e.length,r=0,n=[];++s<i;){var o=e[s];t(o,s,e)&&(n[r++]=o)}return n}(te(e),function(t){return X.call(e,t)}))}:function(){return[]},Pe=Ee;function Oe(e,t){return!!(t=null==t?i:t)&&("number"==typeof e||$.test(e))&&e>-1&&e%1==0&&e<t}function qe(e){if(null!=e){try{return G.call(e)}catch(e){}try{return e+""}catch(e){}}return""}function Me(e,t){return e===t||e!=e&&t!=t}(re&&Pe(new re(new ArrayBuffer(1)))!=S||ne&&Pe(new ne)!=h||oe&&Pe(oe.resolve())!=g||ae&&Pe(new ae)!=m||ce&&Pe(new ce)!=y)&&(Pe=function(e){var t=Ee(e),s=t==u?e.constructor:void 0,i=s?qe(s):"";if(i)switch(i){case he:return S;case le:return h;case ue:return g;case ge:return m;case pe:return y}return t});var Ne=Re(function(){return arguments}())?Re:function(e){return Ge(e)&&V.call(e,"callee")&&!X.call(e,"callee")},je=Array.isArray,Le=se||function(){return!1};function Fe(e){if(!Be(e))return!1;var t=Ee(e);return t==d||"[object GeneratorFunction]"==t||"[object AsyncFunction]"==t||"[object Proxy]"==t}function Ue(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=i}function Be(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}function Ge(e){return null!=e&&"object"==typeof e}var Ve=x?function(e){return function(t){return e(t)}}(x):function(e){return Ge(e)&&Ue(e.length)&&!!E[Ee(e)]};function Ke(e){return null!=(t=e)&&Ue(t.length)&&!Fe(t)?Te(e):De(e);var t}e.exports=function(e,t){return Ie(e,t)}}(w,w.exports)),w.exports),b=m(y);function S(e){const t=s(),i=s();return s=>{const r=e(s),n=T(r);return void 0!==i.current&&b(i.current,n)||(i.current=n,t.current=$(r)),t.current}}function T(e,t=new WeakMap){if(null===e||"object"!=typeof e)return e;if("function"==typeof e)return"__fn__";if(t.has(e))return"__circular__";if(t.set(e,!0),Array.isArray(e))return e.map(e=>T(e,t));if(Object.getPrototypeOf(e)!==Object.prototype)return`__${Object.prototype.toString.call(e)}__`;const s={};for(const i in e)try{s[i]=T(e[i],t)}catch{s[i]="__unclonable__"}return s}function $(e,t=new WeakMap){if(null===e||"object"!=typeof e)return e;if(t.has(e))return t.get(e);if("function"==typeof e)return e;if(Array.isArray(e)){const s=[];t.set(e,s);for(const i of e)s.push($(i,t));return s}if(Object.getPrototypeOf(e)!==Object.prototype)return e;const s={};t.set(e,s);for(const i in e)s[i]=$(e[i],t);return s}function E(e,t){return t.split(".").reduce((e,t)=>e?.[t],e)}function R({key:e,name:t}){const s=l(),i="lineKey"in e?e.lineKey:s.getLineKeyByRemoteNumber(e.remoteNumber);if(!i)return;const r=s.getUsernameByLineKey(i);return c(S(e=>{try{const s=r?e.lines?.[r]?.[i]:null,n=s?.sipSession?.data;if(!n)return;return Array.isArray(t)?t.map(e=>E(n,e)):"string"==typeof t?E(n,t):n}catch(e){}}))}const I={account:{username:"",password:"",domain:"",wssServer:"",webSocketPort:7443,serverPath:"/ws"},features:{enableVideo:!0,enableRingtone:!0,enableTextMessaging:!0,enableTransfer:!0,enableConference:!0,enableTextExpressions:!1,enableTextDictate:!1,enableAlphanumericDial:!0,enableAccountSettings:!0,enableAppearanceSettings:!0,enableNotificationSettings:!0},media:{audioInputDeviceId:"default",audioOutputDeviceId:"default",videoInputDeviceId:"default",ringerOutputDeviceId:"default",maxFrameRate:30,videoHeight:720,videoAspectRatio:1.777,autoGainControl:!0,echoCancellation:!0,noiseSuppression:!0,mirrorVideo:"auto",maxVideoBandwidth:2048,startVideoFullScreen:!1},policy:{autoAnswerPolicy:"manual",doNotDisturbPolicy:"off",callWaitingPolicy:"on",callRecordingPolicy:"manual",intercomPolicy:"off"},registration:{transportConnectionTimeout:15e3,transportReconnectionAttempts:999,transportReconnectionTimeout:3e3,registerExpires:3600,registerExtraHeaders:"",registerExtraContactParams:"",registerContactParams:"",wssInTransport:!0,ipInContact:!1,bundlePolicy:"balanced",iceStunServerJson:"",iceStunCheckTimeout:5e3,subscribeToYourself:!1,voiceMailSubscribe:!1,voicemailDid:"",subscribeVoicemailExpires:3600,inviteExtraHeaders:"",noAnswerTimeout:120},storage:{streamBuffer:50,maxDataStoreDays:0,posterJpegQuality:80},recording:{videoResampleSize:"HD",recordingVideoSize:"HD",recordingVideoFps:12,recordingLayout:"grid"},advanced:{didLength:4,maxDidLength:8,singleInstance:!0,chatEngine:"default"},xmpp:{server:"",websocketPort:"",websocketPath:"",domain:"",profileUser:"",realm:"",realmSeparator:"",chatGroupService:""},permissions:{enableSendFiles:!0,enableSendImages:!0,enableAudioRecording:!0,enableVideoRecording:!0,enableSms:!1,enableFax:!1,enableEmail:!1}};function C(e,t=u(e)){if(!t)return;if(t?.registering)return;if(t.isRegistered())return;t.registering=!0,t.registerer.register({requestDelegate:{onReject(t){!function(e){const t=u(e);if(!t)return;t.registering=!1;const{userAgents:s,statuses:i}=l();h({userAgents:{...s,[e]:t},statuses:{...i,[e]:"disconnected"}})}(e,t.message.reasonPhrase,t.message.statusCode)}}});const{userAgents:s}=l();h({userAgents:{...s,[e]:t}})}function D(e,t=u(e)){if(!t)return;t.isReRegister=!1,t.transport.attemptingReconnection=!1,t.transport.reconnectionAttempts=I.registration.transportReconnectionAttempts,t.transport.attemptingReconnection||t.registering||window.setTimeout(function(){C(e,t)},500);const{userAgents:s,statuses:i}=l();h({userAgents:{...s,[e]:t},statuses:{...i,[e]:"connecting"}})}function A(e,t,s=u(t)){if(!s)return;s.isReRegister=!1;try{s.registerer.unregister()}catch(e){}_(t,s);const{userAgents:i,statuses:r}=l();h({userAgents:{...i,[t]:s},statuses:{...r,[t]:"disconnected"}})}function _(e,t=u(e)){if(!t)return;if(t.registering=!1,t.transport&&t.transport.isConnected())return void D(e,t);setTimeout(function(){t.transport&&t.transport.isConnected()?D(e,t):t.transport.reconnectionAttempts>0&&(t.transport.attemptingReconnection=!0,t.reconnect().catch(function(s){t.transport.attemptingReconnection=!1,_(e,t)}))},g(e)?.registration.transportReconnectionTimeout),t.transport.reconnectionAttempts=t.transport.reconnectionAttempts-1;const{userAgents:s,statuses:i}=l();h({userAgents:{...s,[e]:t},statuses:{...i,[e]:"connecting"}})}class k{lineKey;remoteNumber;username;sipSession;localSoundMeter;remoteSoundMeter;constructor(e,t,s){this.lineKey=t,this.remoteNumber=s,this.username=e,this.sipSession=null,this.localSoundMeter=null,this.remoteSoundMeter=null}}var H;!function(e){e.SOUND_TOGGLE="SOUND_TOGGLE",e.VIDEO_TOGGLE="VIDEO_TOGGLE",e.SCREEN_SHARE_TOGGLE="SCREEN_SHARE_TOGGLE",e.VIDEO_TOGGLE_ACK="VIDEO_TOGGLE_ACK"}(H||(H={}));var x,P={exports:{}};var O,q=(x||(x=1,P.exports=function(){var e=1e3,t=6e4,s=36e5,i="millisecond",r="second",n="minute",o="hour",a="day",c="week",d="month",h="quarter",l="year",u="date",g="Invalid Date",p=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,f=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,m={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(e){var t=["th","st","nd","rd"],s=e%100;return"["+e+(t[(s-20)%10]||t[s]||t[0])+"]"}},v=function(e,t,s){var i=String(e);return!i||i.length>=t?e:""+Array(t+1-i.length).join(s)+e},w={s:v,z:function(e){var t=-e.utcOffset(),s=Math.abs(t),i=Math.floor(s/60),r=s%60;return(t<=0?"+":"-")+v(i,2,"0")+":"+v(r,2,"0")},m:function e(t,s){if(t.date()<s.date())return-e(s,t);var i=12*(s.year()-t.year())+(s.month()-t.month()),r=t.clone().add(i,d),n=s-r<0,o=t.clone().add(i+(n?-1:1),d);return+(-(i+(s-r)/(n?r-o:o-r))||0)},a:function(e){return e<0?Math.ceil(e)||0:Math.floor(e)},p:function(e){return{M:d,y:l,w:c,d:a,D:u,h:o,m:n,s:r,ms:i,Q:h}[e]||String(e||"").toLowerCase().replace(/s$/,"")},u:function(e){return void 0===e}},y="en",b={};b[y]=m;var S="$isDayjsObject",T=function(e){return e instanceof I||!(!e||!e[S])},$=function e(t,s,i){var r;if(!t)return y;if("string"==typeof t){var n=t.toLowerCase();b[n]&&(r=n),s&&(b[n]=s,r=n);var o=t.split("-");if(!r&&o.length>1)return e(o[0])}else{var a=t.name;b[a]=t,r=a}return!i&&r&&(y=r),r||!i&&y},E=function(e,t){if(T(e))return e.clone();var s="object"==typeof t?t:{};return s.date=e,s.args=arguments,new I(s)},R=w;R.l=$,R.i=T,R.w=function(e,t){return E(e,{locale:t.$L,utc:t.$u,x:t.$x,$offset:t.$offset})};var I=function(){function m(e){this.$L=$(e.locale,null,!0),this.parse(e),this.$x=this.$x||e.x||{},this[S]=!0}var v=m.prototype;return v.parse=function(e){this.$d=function(e){var t=e.date,s=e.utc;if(null===t)return new Date(NaN);if(R.u(t))return new Date;if(t instanceof Date)return new Date(t);if("string"==typeof t&&!/Z$/i.test(t)){var i=t.match(p);if(i){var r=i[2]-1||0,n=(i[7]||"0").substring(0,3);return s?new Date(Date.UTC(i[1],r,i[3]||1,i[4]||0,i[5]||0,i[6]||0,n)):new Date(i[1],r,i[3]||1,i[4]||0,i[5]||0,i[6]||0,n)}}return new Date(t)}(e),this.init()},v.init=function(){var e=this.$d;this.$y=e.getFullYear(),this.$M=e.getMonth(),this.$D=e.getDate(),this.$W=e.getDay(),this.$H=e.getHours(),this.$m=e.getMinutes(),this.$s=e.getSeconds(),this.$ms=e.getMilliseconds()},v.$utils=function(){return R},v.isValid=function(){return!(this.$d.toString()===g)},v.isSame=function(e,t){var s=E(e);return this.startOf(t)<=s&&s<=this.endOf(t)},v.isAfter=function(e,t){return E(e)<this.startOf(t)},v.isBefore=function(e,t){return this.endOf(t)<E(e)},v.$g=function(e,t,s){return R.u(e)?this[t]:this.set(s,e)},v.unix=function(){return Math.floor(this.valueOf()/1e3)},v.valueOf=function(){return this.$d.getTime()},v.startOf=function(e,t){var s=this,i=!!R.u(t)||t,h=R.p(e),g=function(e,t){var r=R.w(s.$u?Date.UTC(s.$y,t,e):new Date(s.$y,t,e),s);return i?r:r.endOf(a)},p=function(e,t){return R.w(s.toDate()[e].apply(s.toDate("s"),(i?[0,0,0,0]:[23,59,59,999]).slice(t)),s)},f=this.$W,m=this.$M,v=this.$D,w="set"+(this.$u?"UTC":"");switch(h){case l:return i?g(1,0):g(31,11);case d:return i?g(1,m):g(0,m+1);case c:var y=this.$locale().weekStart||0,b=(f<y?f+7:f)-y;return g(i?v-b:v+(6-b),m);case a:case u:return p(w+"Hours",0);case o:return p(w+"Minutes",1);case n:return p(w+"Seconds",2);case r:return p(w+"Milliseconds",3);default:return this.clone()}},v.endOf=function(e){return this.startOf(e,!1)},v.$set=function(e,t){var s,c=R.p(e),h="set"+(this.$u?"UTC":""),g=(s={},s[a]=h+"Date",s[u]=h+"Date",s[d]=h+"Month",s[l]=h+"FullYear",s[o]=h+"Hours",s[n]=h+"Minutes",s[r]=h+"Seconds",s[i]=h+"Milliseconds",s)[c],p=c===a?this.$D+(t-this.$W):t;if(c===d||c===l){var f=this.clone().set(u,1);f.$d[g](p),f.init(),this.$d=f.set(u,Math.min(this.$D,f.daysInMonth())).$d}else g&&this.$d[g](p);return this.init(),this},v.set=function(e,t){return this.clone().$set(e,t)},v.get=function(e){return this[R.p(e)]()},v.add=function(i,h){var u,g=this;i=Number(i);var p=R.p(h),f=function(e){var t=E(g);return R.w(t.date(t.date()+Math.round(e*i)),g)};if(p===d)return this.set(d,this.$M+i);if(p===l)return this.set(l,this.$y+i);if(p===a)return f(1);if(p===c)return f(7);var m=(u={},u[n]=t,u[o]=s,u[r]=e,u)[p]||1,v=this.$d.getTime()+i*m;return R.w(v,this)},v.subtract=function(e,t){return this.add(-1*e,t)},v.format=function(e){var t=this,s=this.$locale();if(!this.isValid())return s.invalidDate||g;var i=e||"YYYY-MM-DDTHH:mm:ssZ",r=R.z(this),n=this.$H,o=this.$m,a=this.$M,c=s.weekdays,d=s.months,h=s.meridiem,l=function(e,s,r,n){return e&&(e[s]||e(t,i))||r[s].slice(0,n)},u=function(e){return R.s(n%12||12,e,"0")},p=h||function(e,t,s){var i=e<12?"AM":"PM";return s?i.toLowerCase():i};return i.replace(f,function(e,i){return i||function(e){switch(e){case"YY":return String(t.$y).slice(-2);case"YYYY":return R.s(t.$y,4,"0");case"M":return a+1;case"MM":return R.s(a+1,2,"0");case"MMM":return l(s.monthsShort,a,d,3);case"MMMM":return l(d,a);case"D":return t.$D;case"DD":return R.s(t.$D,2,"0");case"d":return String(t.$W);case"dd":return l(s.weekdaysMin,t.$W,c,2);case"ddd":return l(s.weekdaysShort,t.$W,c,3);case"dddd":return c[t.$W];case"H":return String(n);case"HH":return R.s(n,2,"0");case"h":return u(1);case"hh":return u(2);case"a":return p(n,o,!0);case"A":return p(n,o,!1);case"m":return String(o);case"mm":return R.s(o,2,"0");case"s":return String(t.$s);case"ss":return R.s(t.$s,2,"0");case"SSS":return R.s(t.$ms,3,"0");case"Z":return r}return null}(e)||r.replace(":","")})},v.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},v.diff=function(i,u,g){var p,f=this,m=R.p(u),v=E(i),w=(v.utcOffset()-this.utcOffset())*t,y=this-v,b=function(){return R.m(f,v)};switch(m){case l:p=b()/12;break;case d:p=b();break;case h:p=b()/3;break;case c:p=(y-w)/6048e5;break;case a:p=(y-w)/864e5;break;case o:p=y/s;break;case n:p=y/t;break;case r:p=y/e;break;default:p=y}return g?p:R.a(p)},v.daysInMonth=function(){return this.endOf(d).$D},v.$locale=function(){return b[this.$L]},v.locale=function(e,t){if(!e)return this.$L;var s=this.clone(),i=$(e,t,!0);return i&&(s.$L=i),s},v.clone=function(){return R.w(this.$d,this)},v.toDate=function(){return new Date(this.valueOf())},v.toJSON=function(){return this.isValid()?this.toISOString():null},v.toISOString=function(){return this.$d.toISOString()},v.toString=function(){return this.$d.toUTCString()},m}(),C=I.prototype;return E.prototype=C,[["$ms",i],["$s",r],["$m",n],["$H",o],["$W",a],["$M",d],["$y",l],["$D",u]].forEach(function(e){C[e[1]]=function(t){return this.$g(t,e[0],e[1])}}),E.extend=function(e,t){return e.$i||(e(t,I,E),e.$i=!0),E},E.locale=$,E.isDayjs=T,E.unix=function(e){return E(1e3*e)},E.en=b[y],E.Ls=b,E.p={},E}()),P.exports),M=m(q),N={exports:{}};var j,L,F,U,B,G,V,K,Y,W,J,Z,z,X,Q,ee,te,se,ie,re,ne=(O||(O=1,N.exports=(V=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,W=/^(-|\+)?P(?:([-+]?[0-9,.]*)Y)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)W)?(?:([-+]?[0-9,.]*)D)?(?:T(?:([-+]?[0-9,.]*)H)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)S)?)?$/,J={years:K=31536e6,months:Y=2628e6,days:G=864e5,hours:B=36e5,minutes:U=6e4,seconds:F=1e3,milliseconds:1,weeks:6048e5},Z=function(e){return e instanceof ie},z=function(e,t,s){return new ie(e,s,t.$l)},X=function(e){return L.p(e)+"s"},Q=function(e){return e<0},ee=function(e){return Q(e)?Math.ceil(e):Math.floor(e)},te=function(e){return Math.abs(e)},se=function(e,t){return e?Q(e)?{negative:!0,format:""+te(e)+t}:{negative:!1,format:""+e+t}:{negative:!1,format:""}},ie=function(){function e(e,t,s){var i=this;if(this.$d={},this.$l=s,void 0===e&&(this.$ms=0,this.parseFromMilliseconds()),t)return z(e*J[X(t)],this);if("number"==typeof e)return this.$ms=e,this.parseFromMilliseconds(),this;if("object"==typeof e)return Object.keys(e).forEach(function(t){i.$d[X(t)]=e[t]}),this.calMilliseconds(),this;if("string"==typeof e){var r=e.match(W);if(r){var n=r.slice(2).map(function(e){return null!=e?Number(e):0});return this.$d.years=n[0],this.$d.months=n[1],this.$d.weeks=n[2],this.$d.days=n[3],this.$d.hours=n[4],this.$d.minutes=n[5],this.$d.seconds=n[6],this.calMilliseconds(),this}}return this}var t=e.prototype;return t.calMilliseconds=function(){var e=this;this.$ms=Object.keys(this.$d).reduce(function(t,s){return t+(e.$d[s]||0)*J[s]},0)},t.parseFromMilliseconds=function(){var e=this.$ms;this.$d.years=ee(e/K),e%=K,this.$d.months=ee(e/Y),e%=Y,this.$d.days=ee(e/G),e%=G,this.$d.hours=ee(e/B),e%=B,this.$d.minutes=ee(e/U),e%=U,this.$d.seconds=ee(e/F),e%=F,this.$d.milliseconds=e},t.toISOString=function(){var e=se(this.$d.years,"Y"),t=se(this.$d.months,"M"),s=+this.$d.days||0;this.$d.weeks&&(s+=7*this.$d.weeks);var i=se(s,"D"),r=se(this.$d.hours,"H"),n=se(this.$d.minutes,"M"),o=this.$d.seconds||0;this.$d.milliseconds&&(o+=this.$d.milliseconds/1e3,o=Math.round(1e3*o)/1e3);var a=se(o,"S"),c=e.negative||t.negative||i.negative||r.negative||n.negative||a.negative,d=r.format||n.format||a.format?"T":"",h=(c?"-":"")+"P"+e.format+t.format+i.format+d+r.format+n.format+a.format;return"P"===h||"-P"===h?"P0D":h},t.toJSON=function(){return this.toISOString()},t.format=function(e){var t=e||"YYYY-MM-DDTHH:mm:ss",s={Y:this.$d.years,YY:L.s(this.$d.years,2,"0"),YYYY:L.s(this.$d.years,4,"0"),M:this.$d.months,MM:L.s(this.$d.months,2,"0"),D:this.$d.days,DD:L.s(this.$d.days,2,"0"),H:this.$d.hours,HH:L.s(this.$d.hours,2,"0"),m:this.$d.minutes,mm:L.s(this.$d.minutes,2,"0"),s:this.$d.seconds,ss:L.s(this.$d.seconds,2,"0"),SSS:L.s(this.$d.milliseconds,3,"0")};return t.replace(V,function(e,t){return t||String(s[e])})},t.as=function(e){return this.$ms/J[X(e)]},t.get=function(e){var t=this.$ms,s=X(e);return"milliseconds"===s?t%=1e3:t="weeks"===s?ee(t/J[s]):this.$d[s],t||0},t.add=function(e,t,s){var i;return i=t?e*J[X(t)]:Z(e)?e.$ms:z(e,this).$ms,z(this.$ms+i*(s?-1:1),this)},t.subtract=function(e,t){return this.add(e,t,!0)},t.locale=function(e){var t=this.clone();return t.$l=e,t},t.clone=function(){return z(this.$ms,this)},t.humanize=function(e){return j().add(this.$ms,"ms").locale(this.$l).fromNow(!e)},t.valueOf=function(){return this.asMilliseconds()},t.milliseconds=function(){return this.get("milliseconds")},t.asMilliseconds=function(){return this.as("milliseconds")},t.seconds=function(){return this.get("seconds")},t.asSeconds=function(){return this.as("seconds")},t.minutes=function(){return this.get("minutes")},t.asMinutes=function(){return this.as("minutes")},t.hours=function(){return this.get("hours")},t.asHours=function(){return this.as("hours")},t.days=function(){return this.get("days")},t.asDays=function(){return this.as("days")},t.weeks=function(){return this.get("weeks")},t.asWeeks=function(){return this.as("weeks")},t.months=function(){return this.get("months")},t.asMonths=function(){return this.as("months")},t.years=function(){return this.get("years")},t.asYears=function(){return this.as("years")},e}(),re=function(e,t,s){return e.add(t.years()*s,"y").add(t.months()*s,"M").add(t.days()*s,"d").add(t.hours()*s,"h").add(t.minutes()*s,"m").add(t.seconds()*s,"s").add(t.milliseconds()*s,"ms")},function(e,t,s){j=s,L=s().$utils(),s.duration=function(e,t){var i=s.locale();return z(e,{$l:i},t)},s.isDuration=Z;var i=t.prototype.add,r=t.prototype.subtract;t.prototype.add=function(e,t){return Z(e)?re(this,e,1):i.bind(this)(e,t)},t.prototype.subtract=function(e,t){return Z(e)?re(this,e,-1):r.bind(this)(e,t)}})),N.exports),oe=m(ne);M.extend(oe);var ae,ce={exports:{}};var de=(ae||(ae=1,ce.exports=function(){var e="minute",t=/[+-]\d\d(?::?\d\d)?/g,s=/([+-]|\d\d)/g;return function(i,r,n){var o=r.prototype;n.utc=function(e){return new r({date:e,utc:!0,args:arguments})},o.utc=function(t){var s=n(this.toDate(),{locale:this.$L,utc:!0});return t?s.add(this.utcOffset(),e):s},o.local=function(){return n(this.toDate(),{locale:this.$L,utc:!1})};var a=o.parse;o.parse=function(e){e.utc&&(this.$u=!0),this.$utils().u(e.$offset)||(this.$offset=e.$offset),a.call(this,e)};var c=o.init;o.init=function(){if(this.$u){var e=this.$d;this.$y=e.getUTCFullYear(),this.$M=e.getUTCMonth(),this.$D=e.getUTCDate(),this.$W=e.getUTCDay(),this.$H=e.getUTCHours(),this.$m=e.getUTCMinutes(),this.$s=e.getUTCSeconds(),this.$ms=e.getUTCMilliseconds()}else c.call(this)};var d=o.utcOffset;o.utcOffset=function(i,r){var n=this.$utils().u;if(n(i))return this.$u?0:n(this.$offset)?d.call(this):this.$offset;if("string"==typeof i&&(i=function(e){void 0===e&&(e="");var i=e.match(t);if(!i)return null;var r=(""+i[0]).match(s)||["-",0,0],n=r[0],o=60*+r[1]+ +r[2];return 0===o?0:"+"===n?o:-o}(i),null===i))return this;var o=Math.abs(i)<=16?60*i:i,a=this;if(r)return a.$offset=o,a.$u=0===i,a;if(0!==i){var c=this.$u?this.toDate().getTimezoneOffset():-1*this.utcOffset();(a=this.local().add(o+c,e)).$offset=o,a.$x.$localOffset=c}else a=this.utc();return a};var h=o.format;o.format=function(e){var t=e||(this.$u?"YYYY-MM-DDTHH:mm:ss[Z]":"");return h.call(this,t)},o.valueOf=function(){var e=this.$utils().u(this.$offset)?0:this.$offset+(this.$x.$localOffset||this.$d.getTimezoneOffset());return this.$d.valueOf()-6e4*e},o.isUTC=function(){return!!this.$u},o.toISOString=function(){return this.toDate().toISOString()},o.toString=function(){return this.toDate().toUTCString()};var l=o.toDate;o.toDate=function(e){return"s"===e&&this.$offset?n(this.format("YYYY-MM-DD HH:mm:ss:SSS")).toDate():l.call(this)};var u=o.diff;o.diff=function(e,t,s){if(e&&this.$u===e.$u)return u.call(this,e,t,s);var i=this.local(),r=n(e).local();return u.call(i,r,t,s)}}}()),ce.exports),he=m(de);M.extend(oe),M.extend(he);const le=M;function ue(e,t){const s={...e};if(e&&"object"==typeof e&&t&&"object"==typeof t)for(const e in t)if(Object.prototype.hasOwnProperty.call(t,e)){const i=t[e],r=s[e];i&&"object"==typeof i&&!Array.isArray(i)&&r&&"object"==typeof r&&!Array.isArray(r)?s[e]=ue(r,i):void 0!==i&&(s[e]=i)}return s}function ge(){return le().utc().toISOString()}const pe=async e=>async function(){return await navigator.mediaDevices.enumerateDevices()}().then(t=>{let s=!1,i=[],r=!1,n=[],o=!1,a=[];if(t)for(let c=0;c<t.length;++c)if("audioinput"===t[c].kind)s=!0,i.push(t[c]);else if("audiooutput"===t[c].kind)r=!0,n.push(t[c]);else if("videoinput"===t[c].kind){const s=g(e)?.features?.enableVideo;s&&(o=!0,a.push(t[c]))}return{hasAudioDevice:s,audioInputDevices:i,hasSpeakerDevice:r,speakerDevices:n,hasVideoDevice:o,videoInputDevices:a}}),fe=({username:e})=>{const{audioInputDevices:t,videoInputDevices:s}=l().devicesInfo,{media:{audioInputDeviceId:i,videoInputDeviceId:r,autoGainControl:n,maxFrameRate:o,noiseSuppression:a,videoAspectRatio:c,videoHeight:d,echoCancellation:h},registration:{inviteExtraHeaders:u}}=l().configs?.[e]??I,g=()=>navigator.mediaDevices.getSupportedConstraints(),p={answerAudioSpdOptions:function({option:e}={}){const s=e??{sessionDescriptionHandlerOptions:{constraints:{audio:{deviceId:{exact:"default"}},video:!1}}},r=g(),o=i;if("object"==typeof s.sessionDescriptionHandlerOptions.constraints.audio){if("default"!=o){let e=(e=>{let s=!1;for(let i=0;i<t.length;++i)if(e==t[i].deviceId){s=!0;break}return s})(o);e&&(s.sessionDescriptionHandlerOptions.constraints.audio.deviceId={exact:o})}return r.autoGainControl&&(s.sessionDescriptionHandlerOptions.constraints.audio.autoGainControl=n),r.echoCancellation&&(s.sessionDescriptionHandlerOptions.constraints.audio.echoCancellation=h),r.noiseSuppression&&(s.sessionDescriptionHandlerOptions.constraints.audio.noiseSuppression=a),s}},makeAudioSpdOptions:function({extraHeaders:e}){let t={earlyMedia:!0,sessionDescriptionHandlerOptions:{constraints:{audio:{deviceId:"default"},video:!1}}};if(t.extraHeaders=e||[],p.answerAudioSpdOptions({option:t}),u&&""!==u&&"{}"!==u)try{for(const[e,s]of Object.entries(JSON.parse(u)))""==s||t?.extraHeaders?.push(e+": "+s)}catch(e){}return t},answerVideoSpdOptions:function({option:e}={}){const t=e??{sessionDescriptionHandlerOptions:{constraints:{audio:{deviceId:"default"},video:{deviceId:"default"}}}},i=g();p.answerAudioSpdOptions({option:t});const n=r;if("object"==typeof t.sessionDescriptionHandlerOptions.constraints.video){if("default"!=n){let e=(e=>{let t=!1;for(let i=0;i<s.length;++i)if(e===s[i].deviceId){t=!0;break}return t})(n);e&&(t.sessionDescriptionHandlerOptions.constraints.video.deviceId={exact:n})}return i.frameRate&&o&&(t.sessionDescriptionHandlerOptions.constraints.video.frameRate=String(o)),i.height&&d&&(t.sessionDescriptionHandlerOptions.constraints.video.height=String(d)),i.aspectRatio&&c&&(t.sessionDescriptionHandlerOptions.constraints.video.aspectRatio=String(c)),t}},makeVideoSpdOptions:function({extraHeaders:e}){const t={earlyMedia:!0,sessionDescriptionHandlerOptions:{constraints:{audio:{deviceId:"default"},video:{deviceId:"default"}}}};if(p.answerVideoSpdOptions({option:t}),t.extraHeaders=e||[],u&&""!==u&&"{}"!==u)try{for(const[e,s]of Object.entries(JSON.parse(u)))""==s||t.extraHeaders.push(e+": "+s)}catch(e){}return t}};return p};class me extends Error{constructor(e){super(e),Object.setPrototypeOf(this,new.target.prototype)}}class ve extends me{constructor(e){super(e||"Unsupported content type.")}}class we extends me{constructor(e){super(e||"Request pending.")}}class ye extends me{constructor(e){super(e||"Unspecified session description handler error.")}}class be extends me{constructor(){super("The session has terminated.")}}class Se extends me{constructor(e){super(e||"An error occurred during state transition.")}}class Te{constructor(e){this.incomingAckRequest=e}get request(){return this.incomingAckRequest.message}}class $e{constructor(e){this.incomingByeRequest=e}get request(){return this.incomingByeRequest.message}accept(e){return this.incomingByeRequest.accept(e),Promise.resolve()}reject(e){return this.incomingByeRequest.reject(e),Promise.resolve()}}class Ee{constructor(e){this.incomingCancelRequest=e}get request(){return this.incomingCancelRequest}}class Re{constructor(){this.listeners=new Array}addListener(e,t){const s=t=>{this.removeListener(s),e(t)};!0===(null==t?void 0:t.once)?this.listeners.push(s):this.listeners.push(e)}emit(e){this.listeners.slice().forEach(t=>t(e))}removeAllListeners(){this.listeners=[]}removeListener(e){this.listeners=this.listeners.filter(t=>t!==e)}on(e){return this.addListener(e)}off(e){return this.removeListener(e)}once(e){return this.addListener(e,{once:!0})}}class Ie{constructor(e){this.incomingInfoRequest=e}get request(){return this.incomingInfoRequest.message}accept(e){return this.incomingInfoRequest.accept(e),Promise.resolve()}reject(e){return this.incomingInfoRequest.reject(e),Promise.resolve()}}class Ce{constructor(e){this.parameters={};for(const t in e)e.hasOwnProperty(t)&&this.setParam(t,e[t])}setParam(e,t){e&&(this.parameters[e.toLowerCase()]=null==t?null:t.toString())}getParam(e){if(e)return this.parameters[e.toLowerCase()]}hasParam(e){return!(!e||void 0===this.parameters[e.toLowerCase()])}deleteParam(e){if(e=e.toLowerCase(),this.hasParam(e)){const t=this.parameters[e];return delete this.parameters[e],t}}clearParams(){this.parameters={}}}class De extends Ce{constructor(e,t,s){super(s),this.uri=e,this._displayName=t}get friendlyName(){return this.displayName||this.uri.aor}get displayName(){return this._displayName}set displayName(e){this._displayName=e}clone(){return new De(this.uri.clone(),this._displayName,JSON.parse(JSON.stringify(this.parameters)))}toString(){let e=this.displayName||"0"===this.displayName?'"'+this.displayName+'" ':"";e+="<"+this.uri.toString()+">";for(const t in this.parameters)this.parameters.hasOwnProperty(t)&&(e+=";"+t,null!==this.parameters[t]&&(e+="="+this.parameters[t]));return e}}class Ae extends Ce{constructor(e="sip",t,s,i,r,n){if(super(r||{}),this.headers={},!s)throw new TypeError('missing or invalid "host" parameter');for(const e in n)n.hasOwnProperty(e)&&this.setHeader(e,n[e]);this.raw={scheme:e,user:t,host:s,port:i},this.normal={scheme:e.toLowerCase(),user:t,host:s.toLowerCase(),port:i}}get scheme(){return this.normal.scheme}set scheme(e){this.raw.scheme=e,this.normal.scheme=e.toLowerCase()}get user(){return this.normal.user}set user(e){this.normal.user=this.raw.user=e}get host(){return this.normal.host}set host(e){this.raw.host=e,this.normal.host=e.toLowerCase()}get aor(){return this.normal.user+"@"+this.normal.host}get port(){return this.normal.port}set port(e){this.normal.port=this.raw.port=e}setHeader(e,t){this.headers[this.headerize(e)]=t instanceof Array?t:[t]}getHeader(e){if(e)return this.headers[this.headerize(e)]}hasHeader(e){return!!e&&!!this.headers.hasOwnProperty(this.headerize(e))}deleteHeader(e){if(e=this.headerize(e),this.headers.hasOwnProperty(e)){const t=this.headers[e];return delete this.headers[e],t}}clearHeaders(){this.headers={}}clone(){return new Ae(this._raw.scheme,this._raw.user||"",this._raw.host,this._raw.port,JSON.parse(JSON.stringify(this.parameters)),JSON.parse(JSON.stringify(this.headers)))}toRaw(){return this._toString(this._raw)}toString(){return this._toString(this._normal)}get _normal(){return this.normal}get _raw(){return this.raw}_toString(e){let t=e.scheme+":";e.scheme.toLowerCase().match("^sips?$")||(t+="//"),e.user&&(t+=this.escapeUser(e.user)+"@"),t+=e.host,(e.port||0===e.port)&&(t+=":"+e.port);for(const e in this.parameters)this.parameters.hasOwnProperty(e)&&(t+=";"+e,null!==this.parameters[e]&&(t+="="+this.parameters[e]));const s=[];for(const e in this.headers)if(this.headers.hasOwnProperty(e))for(const t in this.headers[e])this.headers[e].hasOwnProperty(t)&&s.push(e+"="+this.headers[e][t]);return s.length>0&&(t+="?"+s.join("&")),t}escapeUser(e){let t;try{t=decodeURIComponent(e)}catch(e){throw e}return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%2B/gi,"+").replace(/%3F/gi,"?").replace(/%2F/gi,"/")}headerize(e){const t={"Call-Id":"Call-ID",Cseq:"CSeq","Min-Se":"Min-SE",Rack:"RAck",Rseq:"RSeq","Www-Authenticate":"WWW-Authenticate"},s=e.toLowerCase().replace(/_/g,"-").split("-"),i=s.length;let r="";for(let e=0;e<i;e++)0!==e&&(r+="-"),r+=s[e].charAt(0).toUpperCase()+s[e].substring(1);return t[r]&&(r=t[r]),r}}function _e(e,t){if(e.scheme!==t.scheme)return!1;if(e.user!==t.user||e.host!==t.host||e.port!==t.port)return!1;if(!function(e,t){const s=Object.keys(e.parameters),i=Object.keys(t.parameters);return!!s.filter(e=>i.includes(e)).every(s=>e.parameters[s]===t.parameters[s])&&(!!["user","ttl","method","transport"].every(s=>e.hasParam(s)&&t.hasParam(s)||!e.hasParam(s)&&!t.hasParam(s))&&!!["maddr"].every(s=>e.hasParam(s)&&t.hasParam(s)||!e.hasParam(s)&&!t.hasParam(s)))}(e,t))return!1;const s=Object.keys(e.headers),i=Object.keys(t.headers);if(0!==s.length||0!==i.length){if(s.length!==i.length)return!1;const r=s.filter(e=>i.includes(e));if(r.length!==i.length)return!1;if(!r.every(s=>e.headers[s].length&&t.headers[s].length&&e.headers[s][0]===t.headers[s][0]))return!1}return!0}function ke(e,t,s){return s=s||" ",e.length>t?e:(t-=e.length,e+(s+=s.repeat(t)).slice(0,t))}class He extends Error{constructor(e,t,s,i){super(),this.message=e,this.expected=t,this.found=s,this.location=i,this.name="SyntaxError","function"==typeof Object.setPrototypeOf?Object.setPrototypeOf(this,He.prototype):this.__proto__=He.prototype,"function"==typeof Error.captureStackTrace&&Error.captureStackTrace(this,He)}static buildMessage(e,t){function s(e){return e.charCodeAt(0).toString(16).toUpperCase()}function i(e){return e.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,e=>"\\x0"+s(e)).replace(/[\x10-\x1F\x7F-\x9F]/g,e=>"\\x"+s(e))}function r(e){return e.replace(/\\/g,"\\\\").replace(/\]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,e=>"\\x0"+s(e)).replace(/[\x10-\x1F\x7F-\x9F]/g,e=>"\\x"+s(e))}function n(e){switch(e.type){case"literal":return'"'+i(e.text)+'"';case"class":const t=e.parts.map(e=>Array.isArray(e)?r(e[0])+"-"+r(e[1]):r(e));return"["+(e.inverted?"^":"")+t+"]";case"any":return"any character";case"end":return"end of input";case"other":return e.description}}return"Expected "+function(e){const t=e.map(n);let s,i;if(t.sort(),t.length>0){for(s=1,i=1;s<t.length;s++)t[s-1]!==t[s]&&(t[i]=t[s],i++);t.length=i}switch(t.length){case 1:return t[0];case 2:return t[0]+" or "+t[1];default:return t.slice(0,-1).join(", ")+", or "+t[t.length-1]}}(e)+" but "+(((o=t)?'"'+i(o)+'"':"end of input")+" found.");var o}format(e){let t="Error: "+this.message;if(this.location){let s,i=null;for(s=0;s<e.length;s++)if(e[s].source===this.location.source){i=e[s].text.split(/\r\n|\n|\r/g);break}let r=this.location.start,n=this.location.source+":"+r.line+":"+r.column;if(i){let e=this.location.end,s=ke("",r.line.toString().length," "),o=i[r.line-1],a=r.line===e.line?e.column:o.length+1;t+="\n --\x3e "+n+"\n"+s+" |\n"+r.line+" | "+o+"\n"+s+" | "+ke("",r.column-1," ")+ke("",a-r.column,"^")}else t+="\n at "+n}return t}}const xe=function(e,t){const s={},i=(t=void 0!==t?t:{}).grammarSource,r={Contact:119,Name_Addr_Header:156,Record_Route:176,Request_Response:81,SIP_URI:45,Subscription_State:186,Supported:191,Require:182,Via:194,absoluteURI:84,Call_ID:118,Content_Disposition:130,Content_Length:135,Content_Type:136,CSeq:146,displayName:122,Event:149,From:151,host:52,Max_Forwards:154,Min_SE:213,Proxy_Authenticate:157,quoted_string:40,Refer_To:178,Replaces:179,Session_Expires:210,stun_URI:217,To:192,turn_URI:223,uuid:226,WWW_Authenticate:209,challenge:158,sipfrag:230,Referred_By:231};let n=119;const o=["\r\n",v("\r\n",!1),/^[0-9]/,w([["0","9"]],!1,!1),/^[a-zA-Z]/,w([["a","z"],["A","Z"]],!1,!1),/^[0-9a-fA-F]/,w([["0","9"],["a","f"],["A","F"]],!1,!1),/^[\0-\xFF]/,w([["\0","ÿ"]],!1,!1),/^["]/,w(['"'],!1,!1)," ",v(" ",!1),"\t",v("\t",!1),/^[a-zA-Z0-9]/,w([["a","z"],["A","Z"],["0","9"]],!1,!1),";",v(";",!1),"/",v("/",!1),"?",v("?",!1),":",v(":",!1),"@",v("@",!1),"&",v("&",!1),"=",v("=",!1),"+",v("+",!1),"$",v("$",!1),",",v(",",!1),"-",v("-",!1),"_",v("_",!1),".",v(".",!1),"!",v("!",!1),"~",v("~",!1),"*",v("*",!1),"'",v("'",!1),"(",v("(",!1),")",v(")",!1),"%",v("%",!1),function(){return" "},function(){return":"},/^[!-~]/,w([["!","~"]],!1,!1),/^[\x80-\uFFFF]/,w([["",""]],!1,!1),/^[\x80-\xBF]/,w([["","¿"]],!1,!1),/^[a-f]/,w([["a","f"]],!1,!1),"`",v("`",!1),"<",v("<",!1),">",v(">",!1),"\\",v("\\",!1),"[",v("[",!1),"]",v("]",!1),"{",v("{",!1),"}",v("}",!1),function(){return"*"},function(){return"/"},function(){return"="},function(){return"("},function(){return")"},function(){return">"},function(){return"<"},function(){return","},function(){return";"},function(){return":"},function(){return'"'},/^[!-']/,w([["!","'"]],!1,!1),/^[*-[]/,w([["*","["]],!1,!1),/^[\]-~]/,w([["]","~"]],!1,!1),function(e){return e},/^[#-[]/,w([["#","["]],!1,!1),/^[\0-\t]/,w([["\0","\t"]],!1,!1),/^[\v-\f]/,w([["\v","\f"]],!1,!1),/^[\x0E-\x7F]/,w([["",""]],!1,!1),function(){(t=t||{data:{}}).data.uri=new Ae(t.data.scheme,t.data.user,t.data.host,t.data.port),delete t.data.scheme,delete t.data.user,delete t.data.host,delete t.data.host_type,delete t.data.port},function(){(t=t||{data:{}}).data.uri=new Ae(t.data.scheme,t.data.user,t.data.host,t.data.port,t.data.uri_params,t.data.uri_headers),delete t.data.scheme,delete t.data.user,delete t.data.host,delete t.data.host_type,delete t.data.port,delete t.data.uri_params,"SIP_URI"===t.startRule&&(t.data=t.data.uri)},"sips",v("sips",!0),"sip",v("sip",!0),function(e){(t=t||{data:{}}).data.scheme=e},function(){(t=t||{data:{}}).data.user=decodeURIComponent(f().slice(0,-1))},function(){(t=t||{data:{}}).data.password=f()},function(){return(t=t||{data:{}}).data.host=f(),t.data.host},function(){return(t=t||{data:{}}).data.host_type="domain",f()},/^[a-zA-Z0-9_\-]/,w([["a","z"],["A","Z"],["0","9"],"_","-"],!1,!1),/^[a-zA-Z0-9\-]/,w([["a","z"],["A","Z"],["0","9"],"-"],!1,!1),function(){return(t=t||{data:{}}).data.host_type="IPv6",f()},"::",v("::",!1),function(){return(t=t||{data:{}}).data.host_type="IPv6",f()},function(){return(t=t||{data:{}}).data.host_type="IPv4",f()},"25",v("25",!1),/^[0-5]/,w([["0","5"]],!1,!1),"2",v("2",!1),/^[0-4]/,w([["0","4"]],!1,!1),"1",v("1",!1),/^[1-9]/,w([["1","9"]],!1,!1),function(e){return t=t||{data:{}},e=parseInt(e.join("")),t.data.port=e,e},"transport=",v("transport=",!0),"udp",v("udp",!0),"tcp",v("tcp",!0),"sctp",v("sctp",!0),"tls",v("tls",!0),function(e){(t=t||{data:{}}).data.uri_params||(t.data.uri_params={}),t.data.uri_params.transport=e.toLowerCase()},"user=",v("user=",!0),"phone",v("phone",!0),"ip",v("ip",!0),function(e){(t=t||{data:{}}).data.uri_params||(t.data.uri_params={}),t.data.uri_params.user=e.toLowerCase()},"method=",v("method=",!0),function(e){(t=t||{data:{}}).data.uri_params||(t.data.uri_params={}),t.data.uri_params.method=e},"ttl=",v("ttl=",!0),function(e){(t=t||{data:{}}).data.params||(t.data.params={}),t.data.params.ttl=e},"maddr=",v("maddr=",!0),function(e){(t=t||{data:{}}).data.uri_params||(t.data.uri_params={}),t.data.uri_params.maddr=e},"lr",v("lr",!0),function(){(t=t||{data:{}}).data.uri_params||(t.data.uri_params={}),t.data.uri_params.lr=void 0},function(e,s){(t=t||{data:{}}).data.uri_params||(t.data.uri_params={}),s=null===s?void 0:s[1],t.data.uri_params[e.toLowerCase()]=s},function(e,s){e=e.join("").toLowerCase(),s=s.join(""),(t=t||{data:{}}).data.uri_headers||(t.data.uri_headers={}),t.data.uri_headers[e]?t.data.uri_headers[e].push(s):t.data.uri_headers[e]=[s]},function(){"Refer_To"===(t=t||{data:{}}).startRule&&(t.data.uri=new Ae(t.data.scheme,t.data.user,t.data.host,t.data.port,t.data.uri_params,t.data.uri_headers),delete t.data.scheme,delete t.data.user,delete t.data.host,delete t.data.host_type,delete t.data.port,delete t.data.uri_params)},"//",v("//",!1),function(){(t=t||{data:{}}).data.scheme=f()},v("SIP",!0),function(){(t=t||{data:{}}).data.sip_version=f()},"INVITE",v("INVITE",!1),"ACK",v("ACK",!1),"VXACH",v("VXACH",!1),"OPTIONS",v("OPTIONS",!1),"BYE",v("BYE",!1),"CANCEL",v("CANCEL",!1),"REGISTER",v("REGISTER",!1),"SUBSCRIBE",v("SUBSCRIBE",!1),"NOTIFY",v("NOTIFY",!1),"REFER",v("REFER",!1),"PUBLISH",v("PUBLISH",!1),function(){return(t=t||{data:{}}).data.method=f(),t.data.method},function(e){(t=t||{data:{}}).data.status_code=parseInt(e.join(""))},function(){(t=t||{data:{}}).data.reason_phrase=f()},function(){(t=t||{data:{}}).data=f()},function(){var e,s;for(s=(t=t||{data:{}}).data.multi_header.length,e=0;e<s;e++)if(null===t.data.multi_header[e].parsed){t.data=null;break}null!==t.data?t.data=t.data.multi_header:t.data=-1},function(){var e;(t=t||{data:{}}).data.multi_header||(t.data.multi_header=[]);try{e=new De(t.data.uri,t.data.displayName,t.data.params),delete t.data.uri,delete t.data.displayName,delete t.data.params}catch(t){e=null}t.data.multi_header.push({position:c,offset:m().start.offset,parsed:e})},function(e){'"'===(e=f().trim())[0]&&(e=e.substring(1,e.length-1)),(t=t||{data:{}}).data.displayName=e},"q",v("q",!0),function(e){(t=t||{data:{}}).data.params||(t.data.params={}),t.data.params.q=e},"expires",v("expires",!0),function(e){(t=t||{data:{}}).data.params||(t.data.params={}),t.data.params.expires=e},function(e){return parseInt(e.join(""))},"0",v("0",!1),function(){return parseFloat(f())},function(e,s){(t=t||{data:{}}).data.params||(t.data.params={}),s=null===s?void 0:s[1],t.data.params[e.toLowerCase()]=s},"render",v("render",!0),"session",v("session",!0),"icon",v("icon",!0),"alert",v("alert",!0),function(){"Content_Disposition"===(t=t||{data:{}}).startRule&&(t.data.type=f().toLowerCase())},"handling",v("handling",!0),"optional",v("optional",!0),"required",v("required",!0),function(e){(t=t||{data:{}}).data=parseInt(e.join(""))},function(){(t=t||{data:{}}).data=f()},"text",v("text",!0),"image",v("image",!0),"audio",v("audio",!0),"video",v("video",!0),"application",v("ap