/** * Copyright (c) 2016 SendBird DBA (Smile Family, Inc.) * SendBird Call JavaScript SDK v1.10.19 production */ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).SendBirdCall=t()}(this,(function(){"use strict";var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function t(e,t){return e(t={exports:{}},t.exports),t.exports}var n=function(e){return e&&e.Math==Math&&e},r=n("object"==typeof globalThis&&globalThis)||n("object"==typeof window&&window)||n("object"==typeof self&&self)||n("object"==typeof e&&e)||function(){return this}()||Function("return this")(),i=function(e){try{return!!e()}catch(e){return!0}},a=!i((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]})),o={}.propertyIsEnumerable,s=Object.getOwnPropertyDescriptor,c={f:s&&!o.call({1:2},1)?function(e){var t=s(this,e);return!!t&&t.enumerable}:o},u=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}},l={}.toString,d=function(e){return l.call(e).slice(8,-1)},h="".split,f=i((function(){return!Object("z").propertyIsEnumerable(0)}))?function(e){return"String"==d(e)?h.call(e,""):Object(e)}:Object,_=function(e){if(null==e)throw TypeError("Can't call method on "+e);return e},v=function(e){return f(_(e))},p=function(e){return"object"==typeof e?null!==e:"function"==typeof e},m=function(e,t){if(!p(e))return e;var n,r;if(t&&"function"==typeof(n=e.toString)&&!p(r=n.call(e)))return r;if("function"==typeof(n=e.valueOf)&&!p(r=n.call(e)))return r;if(!t&&"function"==typeof(n=e.toString)&&!p(r=n.call(e)))return r;throw TypeError("Can't convert object to primitive value")},y={}.hasOwnProperty,g=function(e,t){return y.call(e,t)},E=r.document,k=p(E)&&p(E.createElement),R=function(e){return k?E.createElement(e):{}},C=!a&&!i((function(){return 7!=Object.defineProperty(R("div"),"a",{get:function(){return 7}}).a})),I=Object.getOwnPropertyDescriptor,w={f:a?I:function(e,t){if(e=v(e),t=m(t,!0),C)try{return I(e,t)}catch(e){}if(g(e,t))return u(!c.f.call(e,t),e[t])}},A=function(e){if(!p(e))throw TypeError(String(e)+" is not an object");return e},b=Object.defineProperty,T={f:a?b:function(e,t,n){if(A(e),t=m(t,!0),A(n),C)try{return b(e,t,n)}catch(e){}if("get"in n||"set"in n)throw TypeError("Accessors not supported");return"value"in n&&(e[t]=n.value),e}},S=a?function(e,t,n){return T.f(e,t,u(1,n))}:function(e,t,n){return e[t]=n,e},O=function(e,t){try{S(r,e,t)}catch(n){r[e]=t}return t},D="__core-js_shared__",N=r[D]||O(D,{}),L=Function.toString;"function"!=typeof N.inspectSource&&(N.inspectSource=function(e){return L.call(e)});var P,x,M,U=N.inspectSource,V=r.WeakMap,F="function"==typeof V&&/native code/.test(U(V)),G=t((function(e){(e.exports=function(e,t){return N[e]||(N[e]=void 0!==t?t:{})})("versions",[]).push({version:"3.8.1",mode:"global",copyright:"© 2020 Denis Pushkarev (zloirock.ru)"})})),B=0,j=Math.random(),q=function(e){return"Symbol("+String(void 0===e?"":e)+")_"+(++B+j).toString(36)},H=G("keys"),z=function(e){return H[e]||(H[e]=q(e))},W={},K=r.WeakMap;if(F){var Y=N.state||(N.state=new K),Q=Y.get,Z=Y.has,X=Y.set;P=function(e,t){return t.facade=e,X.call(Y,e,t),t},x=function(e){return Q.call(Y,e)||{}},M=function(e){return Z.call(Y,e)}}else{var $=z("state");W[$]=!0,P=function(e,t){return t.facade=e,S(e,$,t),t},x=function(e){return g(e,$)?e[$]:{}},M=function(e){return g(e,$)}}var J={set:P,get:x,has:M,enforce:function(e){return M(e)?x(e):P(e,{})},getterFor:function(e){return function(t){var n;if(!p(t)||(n=x(t)).type!==e)throw TypeError("Incompatible receiver, "+e+" required");return n}}},ee=t((function(e){var t=J.get,n=J.enforce,i=String(String).split("String");(e.exports=function(e,t,a,o){var s,c=!!o&&!!o.unsafe,u=!!o&&!!o.enumerable,l=!!o&&!!o.noTargetGet;"function"==typeof a&&("string"!=typeof t||g(a,"name")||S(a,"name",t),(s=n(a)).source||(s.source=i.join("string"==typeof t?t:""))),e!==r?(c?!l&&e[t]&&(u=!0):delete e[t],u?e[t]=a:S(e,t,a)):u?e[t]=a:O(t,a)})(Function.prototype,"toString",(function(){return"function"==typeof this&&t(this).source||U(this)}))})),te=r,ne=function(e){return"function"==typeof e?e:void 0},re=function(e,t){return arguments.length<2?ne(te[e])||ne(r[e]):te[e]&&te[e][t]||r[e]&&r[e][t]},ie=Math.ceil,ae=Math.floor,oe=function(e){return isNaN(e=+e)?0:(e>0?ae:ie)(e)},se=Math.min,ce=function(e){return e>0?se(oe(e),9007199254740991):0},ue=Math.max,le=Math.min,de=function(e,t){var n=oe(e);return n<0?ue(n+t,0):le(n,t)},he=function(e){return function(t,n,r){var i,a=v(t),o=ce(a.length),s=de(r,o);if(e&&n!=n){for(;o>s;)if((i=a[s++])!=i)return!0}else for(;o>s;s++)if((e||s in a)&&a[s]===n)return e||s||0;return!e&&-1}},fe={includes:he(!0),indexOf:he(!1)},_e=fe.indexOf,ve=function(e,t){var n,r=v(e),i=0,a=[];for(n in r)!g(W,n)&&g(r,n)&&a.push(n);for(;t.length>i;)g(r,n=t[i++])&&(~_e(a,n)||a.push(n));return a},pe=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],me=pe.concat("length","prototype"),ye={f:Object.getOwnPropertyNames||function(e){return ve(e,me)}},ge={f:Object.getOwnPropertySymbols},Ee=re("Reflect","ownKeys")||function(e){var t=ye.f(A(e)),n=ge.f;return n?t.concat(n(e)):t},ke=function(e,t){for(var n=Ee(t),r=T.f,i=w.f,a=0;ag;g++)if((s||g in p)&&(_=m(h=p[g],g,v),e))if(t)k[g]=_;else if(_)switch(e){case 3:return!0;case 5:return h;case 6:return g;case 2:qe.call(k,h)}else switch(e){case 4:return!1;case 7:qe.call(k,h)}return a?-1:r||i?i:k}},ze={forEach:He(0),map:He(1),filter:He(2),some:He(3),every:He(4),find:He(5),findIndex:He(6),filterOut:He(7)},We=function(e,t){var n=[][e];return!!n&&i((function(){n.call(null,t||function(){throw 1},1)}))},Ke=Object.defineProperty,Ye={},Qe=function(e){throw e},Ze=function(e,t){if(g(Ye,e))return Ye[e];t||(t={});var n=[][e],r=!!g(t,"ACCESSORS")&&t.ACCESSORS,o=g(t,0)?t[0]:Qe,s=g(t,1)?t[1]:void 0;return Ye[e]=!!n&&!i((function(){if(r&&!a)return!0;var e={length:-1};r?Ke(e,1,{enumerable:!0,get:Qe}):e[1]=1,n.call(e,o,s)}))},Xe=ze.forEach,$e=We("forEach"),Je=Ze("forEach"),et=$e&&Je?[].forEach:function(e){return Xe(this,e,arguments.length>1?arguments[1]:void 0)};Oe({target:"Array",proto:!0,forced:[].forEach!=et},{forEach:et});var tt,nt=Object.keys||function(e){return ve(e,pe)},rt=a?Object.defineProperties:function(e,t){A(e);for(var n,r=nt(t),i=r.length,a=0;i>a;)T.f(e,n=r[a++],t[n]);return e},it=re("document","documentElement"),at="prototype",ot="script",st=z("IE_PROTO"),ct=function(){},ut=function(e){return"<"+ot+">"+e+""},lt=function(){try{tt=document.domain&&new ActiveXObject("htmlfile")}catch(e){}var e,t,n;lt=tt?function(e){e.write(ut("")),e.close();var t=e.parentWindow.Object;return e=null,t}(tt):(t=R("iframe"),n="java"+ot+":",t.style.display="none",it.appendChild(t),t.src=String(n),(e=t.contentWindow.document).open(),e.write(ut("document.F=Object")),e.close(),e.F);for(var r=pe.length;r--;)delete lt[at][pe[r]];return lt()};W[st]=!0;var dt=Object.create||function(e,t){var n;return null!==e?(ct[at]=A(e),n=new ct,ct[at]=null,n[st]=e):n=lt(),void 0===t?n:rt(n,t)},ht=Ge("unscopables"),ft=Array.prototype;null==ft[ht]&&T.f(ft,ht,{configurable:!0,value:dt(null)});var _t,vt,pt,mt=function(e){ft[ht][e]=!0},yt={},gt=!i((function(){function e(){}return e.prototype.constructor=null,Object.getPrototypeOf(new e)!==e.prototype})),Et=z("IE_PROTO"),kt=Object.prototype,Rt=gt?Object.getPrototypeOf:function(e){return e=Le(e),g(e,Et)?e[Et]:"function"==typeof e.constructor&&e instanceof e.constructor?e.constructor.prototype:e instanceof Object?kt:null},Ct=Ge("iterator"),It=!1;[].keys&&("next"in(pt=[].keys())?(vt=Rt(Rt(pt)))!==Object.prototype&&(_t=vt):It=!0),null==_t&&(_t={}),g(_t,Ct)||S(_t,Ct,(function(){return this}));var wt={IteratorPrototype:_t,BUGGY_SAFARI_ITERATORS:It},At=T.f,bt=Ge("toStringTag"),Tt=function(e,t,n){e&&!g(e=n?e:e.prototype,bt)&&At(e,bt,{configurable:!0,value:t})},St=wt.IteratorPrototype,Ot=function(){return this},Dt=function(e,t,n){var r=t+" Iterator";return e.prototype=dt(St,{next:u(1,n)}),Tt(e,r,!1),yt[r]=Ot,e},Nt=Object.setPrototypeOf||("__proto__"in{}?function(){var e,t=!1,n={};try{(e=Object.getOwnPropertyDescriptor(Object.prototype,"__proto__").set).call(n,[]),t=n instanceof Array}catch(e){}return function(n,r){return A(n),function(e){if(!p(e)&&null!==e)throw TypeError("Can't set "+String(e)+" as a prototype")}(r),t?e.call(n,r):n.__proto__=r,n}}():void 0),Lt=wt.IteratorPrototype,Pt=wt.BUGGY_SAFARI_ITERATORS,xt=Ge("iterator"),Mt="keys",Ut="values",Vt="entries",Ft=function(){return this},Gt=function(e,t,n,r,i,a,o){Dt(n,t,r);var s,c,u,l=function(e){if(e===i&&v)return v;if(!Pt&&e in f)return f[e];switch(e){case Mt:case Ut:case Vt:return function(){return new n(this,e)}}return function(){return new n(this)}},d=t+" Iterator",h=!1,f=e.prototype,_=f[xt]||f["@@iterator"]||i&&f[i],v=!Pt&&_||l(i),p="Array"==t&&f.entries||_;if(p&&(s=Rt(p.call(new e)),Lt!==Object.prototype&&s.next&&(Rt(s)!==Lt&&(Nt?Nt(s,Lt):"function"!=typeof s[xt]&&S(s,xt,Ft)),Tt(s,d,!0))),i==Ut&&_&&_.name!==Ut&&(h=!0,v=function(){return _.call(this)}),f[xt]!==v&&S(f,xt,v),yt[t]=v,i)if(c={values:l(Ut),keys:a?v:l(Mt),entries:l(Vt)},o)for(u in c)(Pt||h||!(u in f))&&ee(f,u,c[u]);else Oe({target:t,proto:!0,forced:Pt||h},c);return c},Bt="Array Iterator",jt=J.set,qt=J.getterFor(Bt),Ht=Gt(Array,"Array",(function(e,t){jt(this,{type:Bt,target:v(e),index:0,kind:t})}),(function(){var e=qt(this),t=e.target,n=e.kind,r=e.index++;return!t||r>=t.length?(e.target=void 0,{value:void 0,done:!0}):"keys"==n?{value:r,done:!1}:"values"==n?{value:t[r],done:!1}:{value:[r,t[r]],done:!1}}),"values");yt.Arguments=yt.Array,mt("keys"),mt("values"),mt("entries");var zt=!i((function(){return Object.isExtensible(Object.preventExtensions({}))})),Wt=t((function(e){var t=T.f,n=q("meta"),r=0,i=Object.isExtensible||function(){return!0},a=function(e){t(e,n,{value:{objectID:"O"+ ++r,weakData:{}}})},o=e.exports={REQUIRED:!1,fastKey:function(e,t){if(!p(e))return"symbol"==typeof e?e:("string"==typeof e?"S":"P")+e;if(!g(e,n)){if(!i(e))return"F";if(!t)return"E";a(e)}return e[n].objectID},getWeakData:function(e,t){if(!g(e,n)){if(!i(e))return!0;if(!t)return!1;a(e)}return e[n].weakData},onFreeze:function(e){return zt&&o.REQUIRED&&i(e)&&!g(e,n)&&a(e),e}};W[n]=!0})),Kt=(Wt.REQUIRED,Wt.fastKey,Wt.getWeakData,Wt.onFreeze,Ge("iterator")),Yt=Array.prototype,Qt=function(e){return void 0!==e&&(yt.Array===e||Yt[Kt]===e)},Zt={};Zt[Ge("toStringTag")]="z";var Xt="[object z]"===String(Zt),$t=Ge("toStringTag"),Jt="Arguments"==d(function(){return arguments}()),en=Xt?d:function(e){var t,n,r;return void 0===e?"Undefined":null===e?"Null":"string"==typeof(n=function(e,t){try{return e[t]}catch(e){}}(t=Object(e),$t))?n:Jt?d(t):"Object"==(r=d(t))&&"function"==typeof t.callee?"Arguments":r},tn=Ge("iterator"),nn=function(e){if(null!=e)return e[tn]||e["@@iterator"]||yt[en(e)]},rn=function(e){var t=e.return;if(void 0!==t)return A(t.call(e)).value},an=function(e,t){this.stopped=e,this.result=t},on=function(e,t,n){var r,i,a,o,s,c,u,l=n&&n.that,d=!(!n||!n.AS_ENTRIES),h=!(!n||!n.IS_ITERATOR),f=!(!n||!n.INTERRUPTED),_=Ne(t,l,1+d+f),v=function(e){return r&&rn(r),new an(!0,e)},p=function(e){return d?(A(e),f?_(e[0],e[1],v):_(e[0],e[1])):f?_(e,v):_(e)};if(h)r=e;else{if("function"!=typeof(i=nn(e)))throw TypeError("Target is not iterable");if(Qt(i)){for(a=0,o=ce(e.length);o>a;a++)if((s=p(e[a]))&&s instanceof an)return s;return new an(!1)}r=i.call(e)}for(c=r.next;!(u=c.call(r)).done;){try{s=p(u.value)}catch(e){throw rn(r),e}if("object"==typeof s&&s&&s instanceof an)return s}return new an(!1)},sn=function(e,t,n){if(!(e instanceof t))throw TypeError("Incorrect "+(n?n+" ":"")+"invocation");return e},cn=Ge("iterator"),un=!1;try{var ln=0,dn={next:function(){return{done:!!ln++}},return:function(){un=!0}};dn[cn]=function(){return this},Array.from(dn,(function(){throw 2}))}catch(e){}var hn=function(e,t){if(!t&&!un)return!1;var n=!1;try{var r={};r[cn]=function(){return{next:function(){return{done:n=!0}}}},e(r)}catch(e){}return n},fn=function(e,t,n){var r,i;return Nt&&"function"==typeof(r=t.constructor)&&r!==n&&p(i=r.prototype)&&i!==n.prototype&&Nt(e,i),e},_n=function(e,t,n){for(var r in t)ee(e,r,t[r],n);return e},vn=Ge("species"),pn=function(e){var t=re(e),n=T.f;a&&t&&!t[vn]&&n(t,vn,{configurable:!0,get:function(){return this}})},mn=T.f,yn=Wt.fastKey,gn=J.set,En=J.getterFor,kn={getConstructor:function(e,t,n,r){var i=e((function(e,o){sn(e,i,t),gn(e,{type:t,index:dt(null),first:void 0,last:void 0,size:0}),a||(e.size=0),null!=o&&on(o,e[r],{that:e,AS_ENTRIES:n})})),o=En(t),s=function(e,t,n){var r,i,s=o(e),u=c(e,t);return u?u.value=n:(s.last=u={index:i=yn(t,!0),key:t,value:n,previous:r=s.last,next:void 0,removed:!1},s.first||(s.first=u),r&&(r.next=u),a?s.size++:e.size++,"F"!==i&&(s.index[i]=u)),e},c=function(e,t){var n,r=o(e),i=yn(t);if("F"!==i)return r.index[i];for(n=r.first;n;n=n.next)if(n.key==t)return n};return _n(i.prototype,{clear:function(){for(var e=o(this),t=e.index,n=e.first;n;)n.removed=!0,n.previous&&(n.previous=n.previous.next=void 0),delete t[n.index],n=n.next;e.first=e.last=void 0,a?e.size=0:this.size=0},delete:function(e){var t=this,n=o(t),r=c(t,e);if(r){var i=r.next,s=r.previous;delete n.index[r.index],r.removed=!0,s&&(s.next=i),i&&(i.previous=s),n.first==r&&(n.first=i),n.last==r&&(n.last=s),a?n.size--:t.size--}return!!r},forEach:function(e){for(var t,n=o(this),r=Ne(e,arguments.length>1?arguments[1]:void 0,3);t=t?t.next:n.first;)for(r(t.value,t.key,this);t&&t.removed;)t=t.previous},has:function(e){return!!c(this,e)}}),_n(i.prototype,n?{get:function(e){var t=c(this,e);return t&&t.value},set:function(e,t){return s(this,0===e?0:e,t)}}:{add:function(e){return s(this,e=0===e?0:e,e)}}),a&&mn(i.prototype,"size",{get:function(){return o(this).size}}),i},setStrong:function(e,t,n){var r=t+" Iterator",i=En(t),a=En(r);Gt(e,t,(function(e,t){gn(this,{type:r,target:e,state:i(e),kind:t,last:void 0})}),(function(){for(var e=a(this),t=e.kind,n=e.last;n&&n.removed;)n=n.previous;return e.target&&(e.last=n=n?n.next:e.state.first)?"keys"==t?{value:n.key,done:!1}:"values"==t?{value:n.value,done:!1}:{value:[n.key,n.value],done:!1}:(e.target=void 0,{value:void 0,done:!0})}),n?"entries":"values",!n,!0),pn(t)}},Rn=(function(e,t,n){var a=-1!==e.indexOf("Map"),o=-1!==e.indexOf("Weak"),s=a?"set":"add",c=r[e],u=c&&c.prototype,l=c,d={},h=function(e){var t=u[e];ee(u,e,"add"==e?function(e){return t.call(this,0===e?0:e),this}:"delete"==e?function(e){return!(o&&!p(e))&&t.call(this,0===e?0:e)}:"get"==e?function(e){return o&&!p(e)?void 0:t.call(this,0===e?0:e)}:"has"==e?function(e){return!(o&&!p(e))&&t.call(this,0===e?0:e)}:function(e,n){return t.call(this,0===e?0:e,n),this})};if(Te(e,"function"!=typeof c||!(o||u.forEach&&!i((function(){(new c).entries().next()})))))l=n.getConstructor(t,e,a,s),Wt.REQUIRED=!0;else if(Te(e,!0)){var f=new l,_=f[s](o?{}:-0,1)!=f,v=i((function(){f.has(1)})),m=hn((function(e){new c(e)})),y=!o&&i((function(){for(var e=new c,t=5;t--;)e[s](t,t);return!e.has(-0)}));m||((l=t((function(t,n){sn(t,l,e);var r=fn(new c,t,l);return null!=n&&on(n,r[s],{that:r,AS_ENTRIES:a}),r}))).prototype=u,u.constructor=l),(v||y)&&(h("delete"),h("has"),a&&h("get")),(y||_)&&h(s),o&&u.clear&&delete u.clear}d[e]=l,Oe({global:!0,forced:l!=c},d),Tt(l,e),o||n.setStrong(l,e,a)}("Map",(function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}}),kn),Xt?{}.toString:function(){return"[object "+en(this)+"]"});Xt||ee(Object.prototype,"toString",Rn,{unsafe:!0});var Cn=function(e){return function(t,n){var r,i,a=String(_(t)),o=oe(n),s=a.length;return o<0||o>=s?e?"":void 0:(r=a.charCodeAt(o))<55296||r>56319||o+1===s||(i=a.charCodeAt(o+1))<56320||i>57343?e?a.charAt(o):r:e?a.slice(o,o+2):i-56320+(r-55296<<10)+65536}},In={codeAt:Cn(!1),charAt:Cn(!0)},wn=In.charAt,An="String Iterator",bn=J.set,Tn=J.getterFor(An);Gt(String,"String",(function(e){bn(this,{type:An,string:String(e),index:0})}),(function(){var e,t=Tn(this),n=t.string,r=t.index;return r>=n.length?{value:void 0,done:!0}:(e=wn(n,r),t.index+=e.length,{value:e,done:!1})}));var Sn={CSSRuleList:0,CSSStyleDeclaration:0,CSSValueList:0,ClientRectList:0,DOMRectList:0,DOMStringList:0,DOMTokenList:1,DataTransferItemList:0,FileList:0,HTMLAllCollection:0,HTMLCollection:0,HTMLFormElement:0,HTMLSelectElement:0,MediaList:0,MimeTypeArray:0,NamedNodeMap:0,NodeList:1,PaintRequestList:0,Plugin:0,PluginArray:0,SVGLengthList:0,SVGNumberList:0,SVGPathSegList:0,SVGPointList:0,SVGStringList:0,SVGTransformList:0,SourceBufferList:0,StyleSheetList:0,TextTrackCueList:0,TextTrackList:0,TouchList:0};for(var On in Sn){var Dn=r[On],Nn=Dn&&Dn.prototype;if(Nn&&Nn.forEach!==et)try{S(Nn,"forEach",et)}catch(e){Nn.forEach=et}}var Ln,Pn=Ge("iterator"),xn=Ge("toStringTag"),Mn=Ht.values;for(var Un in Sn){var Vn=r[Un],Fn=Vn&&Vn.prototype;if(Fn){if(Fn[Pn]!==Mn)try{S(Fn,Pn,Mn)}catch(e){Fn[Pn]=Mn}if(Fn[xn]||S(Fn,xn,Un),Sn[Un])for(var Gn in Ht)if(Fn[Gn]!==Ht[Gn])try{S(Fn,Gn,Ht[Gn])}catch(e){Fn[Gn]=Ht[Gn]}}}function Bn(e){return Bn="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Bn(e)}function jn(e,t,n,r,i,a,o){try{var s=e[a](o),c=s.value}catch(e){return void n(e)}s.done?t(c):Promise.resolve(c).then(r,i)}function qn(e){return function(){var t=this,n=arguments;return new Promise((function(r,i){var a=e.apply(t,n);function o(e){jn(a,r,i,o,s,"next",e)}function s(e){jn(a,r,i,o,s,"throw",e)}o(void 0)}))}}function Hn(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function zn(e,t){for(var n=0;n=0||(i[n]=e[n]);return i}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function rr(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function ir(e){var t=Jn();return function(){var n,r=Xn(e);if(t){var i=Xn(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return function(e,t){return!t||"object"!=typeof t&&"function"!=typeof t?rr(e):t}(this,n)}}function ar(e,t,n){return ar="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,n){var r=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=Xn(e)););return e}(e,t);if(r){var i=Object.getOwnPropertyDescriptor(r,t);return i.get?i.get.call(n):i.value}},ar(e,t,n||e)}function or(e,t){return cr(e)||function(e,t){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var n=[],r=!0,i=!1,a=void 0;try{for(var o,s=e[Symbol.iterator]();!(r=(o=s.next()).done)&&(n.push(o.value),!t||n.length!==t);r=!0);}catch(e){i=!0,a=e}finally{try{r||null==s.return||s.return()}finally{if(i)throw a}}return n}(e,t)||lr(e,t)||hr()}function sr(e){return function(e){if(Array.isArray(e))return dr(e)}(e)||ur(e)||lr(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function cr(e){if(Array.isArray(e))return e}function ur(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}function lr(e,t){if(e){if("string"==typeof e)return dr(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?dr(e,t):void 0}}function dr(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){n=e[Symbol.iterator]()},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw a}}}}function _r(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}function vr(e,t,n,r){var i=pr();if(r)for(var a=0;a=0;a--){var o=t[e.placement];o.splice(o.indexOf(e.key),1);var s=this.fromElementDescriptor(e),c=this.toElementFinisherExtras((0,i[a])(s)||s);e=c.element,this.addElementPlacement(e,t),c.finisher&&r.push(c.finisher);var u=c.extras;if(u){for(var l=0;l=0;r--){var i=this.fromClassDescriptor(e),a=this.toClassDescriptor((0,t[r])(i)||i);if(void 0!==a.finisher&&n.push(a.finisher),void 0!==a.elements){e=a.elements;for(var o=0;o1&&void 0!==arguments[1]?arguments[1]:{}).invalidParameter,n=void 0===t?"":t;switch(e){case Ln.DIAL_CANCELED:return"Call canceled before receiving a callback.";case Ln.MY_USER_ID_NOT_ALLOWED:return"The caller can't dial their own user ID.";case Ln.ERR_REQUEST_FAILED:return"The http request failed.";case Ln.ERR_WEBSOCKET_CONNECTION_NOT_OPENED:return"Websocket connection not established.";case Ln.ERR_WEBSOCKET_CONNECTION_FAILED:return"Websocket connection failed.";case Ln.ERR_NO_RESPONSE_DUE_TO_TIMEOUT:return"The request failed to receive a response due to timeout.";case Ln.ERR_REQUEST_FAILED_DUE_TO_WEBSOCKET_CONNECTION_LOST:return"The request failed because the websocket connection is lost.";case Ln.ERR_WRONG_RESPONSE:return"The response contains an unexpected object type of data.";case Ln.ERR_QUERY_IN_PROGRESS:return"The previous query is still in progress.";case Ln.INTERNAL_SERVER_ERROR:return"An internal server error has occurred.";case Ln.ERR_MALFORMED_DATA:return"The data format of the response is invalid.";case Ln.INVALID_PARAMETER_VALUE:return"".concat(n," is an invalid or empty value.");case Ln.INVALID_PARAMETER_TYPE:return"The data type of ".concat(n," is invalid.");case Ln.INSTANCE_NOT_INITIALIZED:return"SendBirdCall instance not initialized.";case Ln.USER_NOT_AUTHENTICATED:return"The user is not authenticated.";case Ln.CAMERA_ALREADY_SWITCHING:return"Camera is already switching.";case Ln.ERR_CAMERA_SWITCH:return"A camera switch error has occurred.";case Ln.ERR_CHANGING_AUDIO_DEVICE:return"An error occurred while changing audio device.";case Ln.ERR_CAPTURE_NOT_ALLOWED_ON_AUDIO_CALL:return"Capturing a video view isn't allowed while on an audio call.";case Ln.ERR_VIDEO_VIEW_NOT_READY:return"A video view isn't ready to be captured.";case Ln.ERR_VIDEO_CALL_NOT_CONNECTED_YET:return"A video call isn't connected yet therefore can't capture a video view.";case Ln.ERR_FAILED_TO_GET_IMAGE_FROM_VIDEO_STREAM:return"An error occurred while getting an image form the video stream.";case Ln.ERR_ROOM_MAX_PARTICIPANTS:return"The room has reached max participants.";case Ln.ERR_INVALID_ROOM_PARTICIPANT:return"The room participant argument is not valid.";case Ln.ERR_CLIENT_ALREADY_ENTERED:return"The given client is already entered.";case Ln.ERR_SEND_ENDPOINT_CANNOT_ATTACH:return"The send endpoint failed to attach.";case Ln.ERR_PARTICIPANT_ALREADY_HAS_SEND_ENDPOINT:return"The given participant already has send endpoint.";case Ln.ERR_CALL_NOT_CONNECTED_YET:return"A call isn’t connected yet therefore can’t start media recording.";case Ln.ERR_WRONG_RECORDING_TYPE_FOR_AUDIO_CALL:return"A wrong recording type is selected in an audio call.";case Ln.ERR_RECORDING_ALREADY_IN_PROGRESS:return"An ongoing recording session is already in progress.";case Ln.ERR_FAILED_TO_OPEN_FILE:return"Couldn't open a recording file due to an error.";case Ln.ERR_FAILED_TO_START_RECORDING:return"Couldn't start a recording session due to an error.";case Ln.ERR_FAILED_TO_STOP_RECORDING:return"Coudln't stop a recording session due to an error.";case Ln.ERR_NOT_SUPPORTED_BROWSER_FOR_RECORDING:return"The browser doesn't support media recording.";case Ln.ERR_INVALID_RECORDING_TYPE:return"Invalid recording type is selected.";case Ln.ERR_NOT_SUPPORTED_OS_VERSION_FOR_RECORDING:return"The operating system version doesn't support media recording.";case Ln.ERR_SCREEN_SHARE_RESTRICTED_FROM_AUDIO_CALL:return"Screen share is restricted from audio calls.";case Ln.ERR_SCREEN_SHARE_REQUEST_BEFORE_CALL_IS_CONNECTED:return"A call isn't connected yet, but the request for screen share has been made.";case Ln.ERR_SCREEN_SHARE_ALREADY_IN_PROGRESS:return"The user is trying to share the screen while the previous request is still in progress.";case Ln.ERR_MEDIA_STREAM_NOT_ALLOWED_ON_HOLD:return"Screen sharing or any other actions that need media streaming as well as capturing screen aren't allowed while a call is on hold.";case Ln.ERR_NOT_SUPPORTED_BROWSER_FOR_SCREEN_SHARE:return"The browser doesn't support screen share.";case Ln.ERR_SCREEN_SHARE_FAILED_DUE_TO_UNKNOWN_REASON:return"Screen share failed due to unknown reason.";case Ln.ERR_NOT_SUPPORTED_APP_STATE_FOR_SCREEN_SHARE:return"The application state isn't supported for screen share.";case Ln.ERR_PERMISSION_DENIED_FOR_SCREEN_SHARE:return"An access permission denied for screen share.";case Ln.ERR_SELECTED_CONTENT_NOT_EXIST:return"The selected content for screen share doesn't exist.";case Ln.ERR_SELECTED_CONTENT_INACCESSIBLE:return"The selected content for screen share is inaccessible by the system.";case Ln.ERR_PARTICIPANT_ALREADY_IN_ROOM:return"The participant is trying to enter the same room they're already in.";case Ln.ERR_ENTERING_ROOM_STILL_IN_PROGRESS:return"The participant is trying to enter the room while the previous request is still in progress.";case Ln.ERR_PARTICIPANT_NOT_IN_ROOM:return"The participant is not in the room and the request can't be processed.";case Ln.ERR_EXITING_ROOM_STILL_IN_PROGRESS:return"The participant is trying to exit the same room.";case Ln.ERR_FAILED_TO_ESTABLISH_CONNECTION_TO_SEND_STREAM:return"Couldn't establish a connection to send media streaming.";case Ln.ERR_FAILED_TO_ESTABLISH_CONNECTION_TO_RECEIVE_STREAM:return"Couldn't establish a connection to receive media streaming.";case Ln.ERR_LOCAL_PARTICIPANT_LOST_CONNECTION:return"The local participant exited the room due to lost connection.";case Ln.ERR_LOCAL_PARTICIPANT_KICKED_OUT:return"An existing participant has been disconnected from the room because a new participant entered with the same user ID.";case Ln.ERR_CALL_ALREADY_ON_HOLD:return"The call is already on hold.";case Ln.ERR_ACTIVE_CALL_IN_PROGRESS:return"The active call is in progress. Cannot remove the active call from a hold because the call is not on hold.";case Ln.ERR_ANOTHER_CALL_IN_PROGRESS:return"The active call is in progress. Cannot remove a hold from another call while there is an active call.";default:return""}}}]),e}(),wr=function(e,t,n){var r=m(t);r in e?T.f(e,r,u(0,n)):e[r]=n},Ar=re("navigator","userAgent")||"",br=r.process,Tr=br&&br.versions,Sr=Tr&&Tr.v8;Sr?Cr=(Rr=Sr.split("."))[0]+Rr[1]:Ar&&(!(Rr=Ar.match(/Edge\/(\d+)/))||Rr[1]>=74)&&(Rr=Ar.match(/Chrome\/(\d+)/))&&(Cr=Rr[1]);var Or=Cr&&+Cr,Dr=Ge("species"),Nr=function(e){return Or>=51||!i((function(){var t=[];return(t.constructor={})[Dr]=function(){return{foo:1}},1!==t[e](Boolean).foo}))},Lr=Ge("isConcatSpreadable"),Pr=9007199254740991,xr="Maximum allowed index exceeded",Mr=Or>=51||!i((function(){var e=[];return e[Lr]=!1,e.concat()[0]!==e})),Ur=Nr("concat"),Vr=function(e){if(!p(e))return!1;var t=e[Lr];return void 0!==t?!!t:Pe(e)};Oe({target:"Array",proto:!0,forced:!Mr||!Ur},{concat:function(e){var t,n,r,i,a,o=Le(this),s=je(o,0),c=0;for(t=-1,r=arguments.length;tPr)throw TypeError(xr);for(n=0;n=Pr)throw TypeError(xr);wr(s,c++,a)}return s.length=c,s}});var Fr=ze.map,Gr=Nr("map"),Br=Ze("map");Oe({target:"Array",proto:!0,forced:!Gr||!Br},{map:function(e){return Fr(this,e,arguments.length>1?arguments[1]:void 0)}});var jr=function(){var e=A(this),t="";return e.global&&(t+="g"),e.ignoreCase&&(t+="i"),e.multiline&&(t+="m"),e.dotAll&&(t+="s"),e.unicode&&(t+="u"),e.sticky&&(t+="y"),t},qr="toString",Hr=RegExp.prototype,zr=Hr[qr],Wr=i((function(){return"/a/b"!=zr.call({source:"a",flags:"b"})})),Kr=zr.name!=qr;(Wr||Kr)&&ee(RegExp.prototype,qr,(function(){var e=A(this),t=String(e.source),n=e.flags;return"/"+t+"/"+String(void 0===n&&e instanceof RegExp&&!("flags"in Hr)?jr.call(e):n)}),{unsafe:!0});var Yr,Qr="".repeat||function(e){var t=String(_(this)),n="",r=oe(e);if(r<0||r==1/0)throw RangeError("Wrong number of repetitions");for(;r>0;(r>>>=1)&&(t+=t))1&r&&(n+=t);return n},Zr=Math.ceil,Xr=function(e){return function(t,n,r){var i,a,o=String(_(t)),s=o.length,c=void 0===r?" ":String(r),u=ce(n);return u<=s||""==c?o:(i=u-s,(a=Qr.call(c,Zr(i/c.length))).length>i&&(a=a.slice(0,i)),e?o+a:a+o)}},$r={start:Xr(!1),end:Xr(!0)},Jr=/Version\/10\.\d+(\.\d+)?( Mobile\/\w+)? Safari\//.test(Ar),ei=$r.start;Oe({target:"String",proto:!0,forced:Jr},{padStart:function(e){return ei(this,e,arguments.length>1?arguments[1]:void 0)}}),function(e){e.VERBOSE="VERBOSE",e.DEBUG="DEBUG",e.INFO="INFO",e.WARNING="WARNING",e.ERROR="ERROR",e.NONE="NONE"}(Yr||(Yr={}));var ti={VERBOSE:{level:-1,name:Yr.VERBOSE,public:!1},DEBUG:{level:1,name:Yr.DEBUG,public:!1},INFO:{level:2,name:Yr.INFO,public:!0},WARNING:{level:3,name:Yr.WARNING,public:!0},ERROR:{level:4,name:Yr.ERROR,public:!0},NONE:{level:100,name:Yr.NONE,public:!0}},ni=ze.some,ri=We("some"),ii=Ze("some");Oe({target:"Array",proto:!0,forced:!ri||!ii},{some:function(e){return ni(this,e,arguments.length>1?arguments[1]:void 0)}});var ai=i((function(){nt(1)}));Oe({target:"Object",stat:!0,forced:ai},{keys:function(e){return nt(Le(e))}});var oi,si,ci,ui=r.Promise,li=Ge("species"),di=function(e,t){var n,r=A(e).constructor;return void 0===r||null==(n=A(r)[li])?t:De(n)},hi=/(iphone|ipod|ipad).*applewebkit/i.test(Ar),fi="process"==d(r.process),_i=r.location,vi=r.setImmediate,pi=r.clearImmediate,mi=r.process,yi=r.MessageChannel,gi=r.Dispatch,Ei=0,ki={},Ri="onreadystatechange",Ci=function(e){if(ki.hasOwnProperty(e)){var t=ki[e];delete ki[e],t()}},Ii=function(e){return function(){Ci(e)}},wi=function(e){Ci(e.data)},Ai=function(e){r.postMessage(e+"",_i.protocol+"//"+_i.host)};vi&&pi||(vi=function(e){for(var t=[],n=1;arguments.length>n;)t.push(arguments[n++]);return ki[++Ei]=function(){("function"==typeof e?e:Function(e)).apply(void 0,t)},oi(Ei),Ei},pi=function(e){delete ki[e]},fi?oi=function(e){mi.nextTick(Ii(e))}:gi&&gi.now?oi=function(e){gi.now(Ii(e))}:yi&&!hi?(ci=(si=new yi).port2,si.port1.onmessage=wi,oi=Ne(ci.postMessage,ci,1)):r.addEventListener&&"function"==typeof postMessage&&!r.importScripts&&_i&&"file:"!==_i.protocol&&!i(Ai)?(oi=Ai,r.addEventListener("message",wi,!1)):oi=Ri in R("script")?function(e){it.appendChild(R("script"))[Ri]=function(){it.removeChild(this),Ci(e)}}:function(e){setTimeout(Ii(e),0)});var bi,Ti,Si,Oi,Di,Ni,Li,Pi,xi={set:vi,clear:pi},Mi=w.f,Ui=xi.set,Vi=r.MutationObserver||r.WebKitMutationObserver,Fi=r.document,Gi=r.process,Bi=r.Promise,ji=Mi(r,"queueMicrotask"),qi=ji&&ji.value;qi||(bi=function(){var e,t;for(fi&&(e=Gi.domain)&&e.exit();Ti;){t=Ti.fn,Ti=Ti.next;try{t()}catch(e){throw Ti?Oi():Si=void 0,e}}Si=void 0,e&&e.enter()},!hi&&!fi&&Vi&&Fi?(Di=!0,Ni=Fi.createTextNode(""),new Vi(bi).observe(Ni,{characterData:!0}),Oi=function(){Ni.data=Di=!Di}):Bi&&Bi.resolve?(Li=Bi.resolve(void 0),Pi=Li.then,Oi=function(){Pi.call(Li,bi)}):Oi=fi?function(){Gi.nextTick(bi)}:function(){Ui.call(r,bi)});var Hi,zi,Wi,Ki,Yi=qi||function(e){var t={fn:e,next:void 0};Si&&(Si.next=t),Ti||(Ti=t,Oi()),Si=t},Qi=function(e){var t,n;this.promise=new e((function(e,r){if(void 0!==t||void 0!==n)throw TypeError("Bad Promise constructor");t=e,n=r})),this.resolve=De(t),this.reject=De(n)},Zi={f:function(e){return new Qi(e)}},Xi=function(e,t){if(A(e),p(t)&&t.constructor===e)return t;var n=Zi.f(e);return(0,n.resolve)(t),n.promise},$i=function(e){try{return{error:!1,value:e()}}catch(e){return{error:!0,value:e}}},Ji=xi.set,ea=Ge("species"),ta="Promise",na=J.get,ra=J.set,ia=J.getterFor(ta),aa=ui,oa=r.TypeError,sa=r.document,ca=r.process,ua=re("fetch"),la=Zi.f,da=la,ha=!!(sa&&sa.createEvent&&r.dispatchEvent),fa="function"==typeof PromiseRejectionEvent,_a="unhandledrejection",va=Te(ta,(function(){if(!(U(aa)!==String(aa))){if(66===Or)return!0;if(!fi&&!fa)return!0}if(Or>=51&&/native code/.test(aa))return!1;var e=aa.resolve(1),t=function(e){e((function(){}),(function(){}))};return(e.constructor={})[ea]=t,!(e.then((function(){}))instanceof t)})),pa=va||!hn((function(e){aa.all(e).catch((function(){}))})),ma=function(e){var t;return!(!p(e)||"function"!=typeof(t=e.then))&&t},ya=function(e,t){if(!e.notified){e.notified=!0;var n=e.reactions;Yi((function(){for(var r=e.value,i=1==e.state,a=0;n.length>a;){var o,s,c,u=n[a++],l=i?u.ok:u.fail,d=u.resolve,h=u.reject,f=u.domain;try{l?(i||(2===e.rejection&&Ra(e),e.rejection=1),!0===l?o=r:(f&&f.enter(),o=l(r),f&&(f.exit(),c=!0)),o===u.promise?h(oa("Promise-chain cycle")):(s=ma(o))?s.call(o,d,h):d(o)):h(r)}catch(e){f&&!c&&f.exit(),h(e)}}e.reactions=[],e.notified=!1,t&&!e.rejection&&Ea(e)}))}},ga=function(e,t,n){var i,a;ha?((i=sa.createEvent("Event")).promise=t,i.reason=n,i.initEvent(e,!1,!0),r.dispatchEvent(i)):i={promise:t,reason:n},!fa&&(a=r["on"+e])?a(i):e===_a&&function(e,t){var n=r.console;n&&n.error&&(1===arguments.length?n.error(e):n.error(e,t))}("Unhandled promise rejection",n)},Ea=function(e){Ji.call(r,(function(){var t,n=e.facade,r=e.value;if(ka(e)&&(t=$i((function(){fi?ca.emit("unhandledRejection",r,n):ga(_a,n,r)})),e.rejection=fi||ka(e)?2:1,t.error))throw t.value}))},ka=function(e){return 1!==e.rejection&&!e.parent},Ra=function(e){Ji.call(r,(function(){var t=e.facade;fi?ca.emit("rejectionHandled",t):ga("rejectionhandled",t,e.value)}))},Ca=function(e,t,n){return function(r){e(t,r,n)}},Ia=function(e,t,n){e.done||(e.done=!0,n&&(e=n),e.value=t,e.state=2,ya(e,!0))},wa=function(e,t,n){if(!e.done){e.done=!0,n&&(e=n);try{if(e.facade===t)throw oa("Promise can't be resolved itself");var r=ma(t);r?Yi((function(){var n={done:!1};try{r.call(t,Ca(wa,n,e),Ca(Ia,n,e))}catch(t){Ia(n,t,e)}})):(e.value=t,e.state=1,ya(e,!1))}catch(t){Ia({done:!1},t,e)}}};function Aa(e,t){return RegExp(e,t)}va&&(aa=function(e){sn(this,aa,ta),De(e),Hi.call(this);var t=na(this);try{e(Ca(wa,t),Ca(Ia,t))}catch(e){Ia(t,e)}},(Hi=function(e){ra(this,{type:ta,done:!1,notified:!1,parent:!1,reactions:[],rejection:!1,state:0,value:void 0})}).prototype=_n(aa.prototype,{then:function(e,t){var n=ia(this),r=la(di(this,aa));return r.ok="function"!=typeof e||e,r.fail="function"==typeof t&&t,r.domain=fi?ca.domain:void 0,n.parent=!0,n.reactions.push(r),0!=n.state&&ya(n,!1),r.promise},catch:function(e){return this.then(void 0,e)}}),zi=function(){var e=new Hi,t=na(e);this.promise=e,this.resolve=Ca(wa,t),this.reject=Ca(Ia,t)},Zi.f=la=function(e){return e===aa||e===Wi?new zi(e):da(e)},"function"==typeof ui&&(Ki=ui.prototype.then,ee(ui.prototype,"then",(function(e,t){var n=this;return new aa((function(e,t){Ki.call(n,e,t)})).then(e,t)}),{unsafe:!0}),"function"==typeof ua&&Oe({global:!0,enumerable:!0,forced:!0},{fetch:function(e){return Xi(aa,ua.apply(r,arguments))}}))),Oe({global:!0,wrap:!0,forced:va},{Promise:aa}),Tt(aa,ta,!1),pn(ta),Wi=re(ta),Oe({target:ta,stat:!0,forced:va},{reject:function(e){var t=la(this);return t.reject.call(void 0,e),t.promise}}),Oe({target:ta,stat:!0,forced:va},{resolve:function(e){return Xi(this,e)}}),Oe({target:ta,stat:!0,forced:pa},{all:function(e){var t=this,n=la(t),r=n.resolve,i=n.reject,a=$i((function(){var n=De(t.resolve),a=[],o=0,s=1;on(e,(function(e){var c=o++,u=!1;a.push(void 0),s++,n.call(t,e).then((function(e){u||(u=!0,a[c]=e,--s||r(a))}),i)})),--s||r(a)}));return a.error&&i(a.value),n.promise},race:function(e){var t=this,n=la(t),r=n.reject,i=$i((function(){var i=De(t.resolve);on(e,(function(e){i.call(t,e).then(n.resolve,r)}))}));return i.error&&r(i.value),n.promise}});var ba,Ta,Sa={UNSUPPORTED_Y:i((function(){var e=Aa("a","y");return e.lastIndex=2,null!=e.exec("abcd")})),BROKEN_CARET:i((function(){var e=Aa("^r","gy");return e.lastIndex=2,null!=e.exec("str")}))},Oa=RegExp.prototype.exec,Da=String.prototype.replace,Na=Oa,La=(ba=/a/,Ta=/b*/g,Oa.call(ba,"a"),Oa.call(Ta,"a"),0!==ba.lastIndex||0!==Ta.lastIndex),Pa=Sa.UNSUPPORTED_Y||Sa.BROKEN_CARET,xa=void 0!==/()??/.exec("")[1];(La||xa||Pa)&&(Na=function(e){var t,n,r,i,a=this,o=Pa&&a.sticky,s=jr.call(a),c=a.source,u=0,l=e;return o&&(-1===(s=s.replace("y","")).indexOf("g")&&(s+="g"),l=String(e).slice(a.lastIndex),a.lastIndex>0&&(!a.multiline||a.multiline&&"\n"!==e[a.lastIndex-1])&&(c="(?: "+c+")",l=" "+l,u++),n=new RegExp("^(?:"+c+")",s)),xa&&(n=new RegExp("^"+c+"$(?!\\s)",s)),La&&(t=a.lastIndex),r=Oa.call(o?n:a,l),o?r?(r.input=r.input.slice(u),r[0]=r[0].slice(u),r.index=a.lastIndex,a.lastIndex+=r[0].length):a.lastIndex=0:La&&r&&(a.lastIndex=a.global?r.index+r[0].length:t),xa&&r&&r.length>1&&Da.call(r[0],n,(function(){for(i=1;i")})),Fa="$0"==="a".replace(/./,"$0"),Ga=Ge("replace"),Ba=!!/./[Ga]&&""===/./[Ga]("a","$0"),ja=!i((function(){var e=/(?:)/,t=e.exec;e.exec=function(){return t.apply(this,arguments)};var n="ab".split(e);return 2!==n.length||"a"!==n[0]||"b"!==n[1]})),qa=function(e,t,n,r){var a=Ge(e),o=!i((function(){var t={};return t[a]=function(){return 7},7!=""[e](t)})),s=o&&!i((function(){var t=!1,n=/a/;return"split"===e&&((n={}).constructor={},n.constructor[Ua]=function(){return n},n.flags="",n[a]=/./[a]),n.exec=function(){return t=!0,null},n[a](""),!t}));if(!o||!s||"replace"===e&&(!Va||!Fa||Ba)||"split"===e&&!ja){var c=/./[a],u=n(a,""[e],(function(e,t,n,r,i){return t.exec===Ma?o&&!i?{done:!0,value:c.call(t,n,r)}:{done:!0,value:e.call(n,t,r)}:{done:!1}}),{REPLACE_KEEPS_$0:Fa,REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE:Ba}),l=u[0],d=u[1];ee(String.prototype,e,l),ee(RegExp.prototype,a,2==t?function(e,t){return d.call(e,this,t)}:function(e){return d.call(e,this)})}r&&S(RegExp.prototype[a],"sham",!0)},Ha=In.charAt,za=function(e,t,n){return t+(n?Ha(e,t).length:1)},Wa=function(e,t){var n=e.exec;if("function"==typeof n){var r=n.call(e,t);if("object"!=typeof r)throw TypeError("RegExp exec method returned something other than an Object or null");return r}if("RegExp"!==d(e))throw TypeError("RegExp#exec called on incompatible receiver");return Ma.call(e,t)};qa("match",1,(function(e,t,n){return[function(t){var n=_(this),r=null==t?void 0:t[e];return void 0!==r?r.call(t,n):new RegExp(t)[e](String(n))},function(e){var r=n(t,e,this);if(r.done)return r.value;var i=A(e),a=String(this);if(!i.global)return Wa(i,a);var o=i.unicode;i.lastIndex=0;for(var s,c=[],u=0;null!==(s=Wa(i,a));){var l=String(s[0]);c[u]=l,""===l&&(i.lastIndex=za(a,ce(i.lastIndex),o)),u++}return 0===u?null:c}]}));var Ka=Math.max,Ya=Math.min,Qa=Math.floor,Za=/\$([$&'`]|\d\d?|<[^>]*>)/g,Xa=/\$([$&'`]|\d\d?)/g;qa("replace",2,(function(e,t,n,r){var i=r.REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE,a=r.REPLACE_KEEPS_$0,o=i?"$":"$0";return[function(n,r){var i=_(this),a=null==n?void 0:n[e];return void 0!==a?a.call(n,i,r):t.call(String(i),n,r)},function(e,r){if(!i&&a||"string"==typeof r&&-1===r.indexOf(o)){var c=n(t,e,this,r);if(c.done)return c.value}var u=A(e),l=String(this),d="function"==typeof r;d||(r=String(r));var h=u.global;if(h){var f=u.unicode;u.lastIndex=0}for(var _=[];;){var v=Wa(u,l);if(null===v)break;if(_.push(v),!h)break;""===String(v[0])&&(u.lastIndex=za(l,ce(u.lastIndex),f))}for(var p,m="",y=0,g=0;g<_.length;g++){v=_[g];for(var E=String(v[0]),k=Ka(Ya(oe(v.index),l.length),0),R=[],C=1;C=y&&(m+=l.slice(y,k)+b,y=k+E.length)}return m+l.slice(y)}];function s(e,n,r,i,a,o){var s=r+e.length,c=i.length,u=Xa;return void 0!==a&&(a=Le(a),u=Za),t.call(o,u,(function(t,o){var u;switch(o.charAt(0)){case"$":return"$";case"&":return e;case"`":return n.slice(0,r);case"'":return n.slice(s);case"<":u=a[o.slice(1,-1)];break;default:var l=+o;if(0===l)return t;if(l>c){var d=Qa(l/10);return 0===d?t:d<=c?void 0===i[d-1]?o.charAt(1):i[d-1]+o.charAt(1):t}u=i[l-1]}return void 0===u?"":u}))}}));var $a=function(e){Zn(n,e);var t=ir(n);function n(e){var r,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a=i.message,o=i.error,s=nr(i,["message","error"]);Hn(this,n);var c=a||Ir.getErrorMessage(e,s);return(r=t.call(this,c)).code=e,r._error=o,r}return n}(tr(Error)),Ja=function(e){Zn(n,e);var t=ir(n);function n(){return Hn(this,n),t.apply(this,arguments)}return n}($a);function eo(e){return function(t){e.then((function(e){return t(e)}),(function(e){return t(null,e)}))}}var to,no,ro=function(e,t){if(Object.keys(e).some((function(t){return"string"!=typeof e[t]}))){var n=Promise.reject(new Ja(Ln.INVALID_PARAMETER_TYPE));return t&&eo(n)(t),[!1,n]}return[!0]},io=function(e,t){if(e.some((function(e){return"string"!=typeof e}))){var n=Promise.reject(new Ja(Ln.INVALID_PARAMETER_TYPE));return t&&eo(n)(t),[!1,n]}return[!0]},ao=function(e,t,n){var r=e.match(t);return r&&r.length>=n&&parseInt(r[n],10)},oo=function(){var e={browser:null,version:null};if("undefined"==typeof window||!window.navigator)return e.browser="Not a browser.",e;var t=window.navigator;if(t.mozGetUserMedia)e.browser="firefox",e.version=ao(t.userAgent,/Firefox\/(\d+)\./,1);else if(t.webkitGetUserMedia||!1===window.isSecureContext&&window.webkitRTCPeerConnection&&!window.RTCIceGatherer)e.browser="chrome",e.version=ao(t.userAgent,/Chrom(e|ium)\/(\d+)\./,2);else if(t.mediaDevices&&t.userAgent.match(/Edge\/(\d+).(\d+)$/))e.browser="edge",e.version=ao(t.userAgent,/Edge\/(\d+).(\d+)$/,2);else{if(!window.RTCPeerConnection||!t.userAgent.match(/AppleWebKit\/(\d+)\./))return e.browser="Not a supported browser.",e;e.browser="safari",e.version=ao(t.userAgent,/AppleWebKit\/(\d+)\./,1),e.supportsUnifiedPlan=window.RTCRtpTransceiver&&"currentDirection"in window.RTCRtpTransceiver.prototype}return e},so="safari"===oo().browser,co="firefox"===oo().browser,uo=function(e){return e.replace(/"access_token":".*?"/gm,'"access_token":"*************"').replace(/"password":".*?"/gm,'"password":"*************"').replace(/"sbcall_session_token":".*?"/gm,'"sbcall_session_token":"*************"').replace(/"turn_urls":\[".*?"\]/gm,'"turn_urls":"[*************]"').replace(/(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)/gm,"*************").replace(/((?:[0-9A-Fa-f]{1,4}))((?::[0-9A-Fa-f]{1,4}))*::((?:[0-9A-Fa-f]{1,4}))((?::[0-9A-Fa-f]{1,4}))*|((?:[0-9A-Fa-f]{1,4}))((?::[0-9A-Fa-f]{1,4})){7}/gm,"*************")},lo=function(e){return{userId:e.user_id,nickname:e.nickname,profileUrl:e.profile_url,metaData:e.metadata,isActive:e.is_active}},ho=function(){function e(){Hn(this,e),this.level=Yr.NONE}return Wn(e,[{key:"setLoggerLevel",value:function(e){var t;return null!==(t=ti[e])&&void 0!==t&&t.public&&(this.level=e),this.level}},{key:"verbose",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n1?r-1:0),a=1;ai;)for(var u,l=f(arguments[i++]),d=o?nt(l).concat(o(l)):nt(l),h=d.length,_=0;h>_;)u=d[_++],a&&!s.call(l,u)||(n[u]=l[u]);return n}:mo;Oe({target:"Object",stat:!0,forced:Object.assign!==go},{assign:go}),function(e){e.UNAVAILABLE="unavailable",e.POOR="poor",e.FAIR="fair",e.AVERAGE="average",e.GOOD="good",e.EXCELLENT="excellent"}(to||(to={})),function(e){e.FREQUENCY="frequency",e.CONNECTION_QUALITY_CHANGE="connectionQualityChange"}(no||(no={}));var Eo,ko,Ro=function(){function e(t){Hn(this,e),Object.assign(this,t)}return Wn(e,[{key:"connectionQuality",get:function(){var e=this.mos;return e?0<=e&&e<2?to.POOR:2<=e&&e<3?to.FAIR:3<=e&&e<3.6?to.AVERAGE:3.6<=e&&e<4.2?to.GOOD:e>=4.2?to.EXCELLENT:to.UNAVAILABLE:to.UNAVAILABLE}}]),e}();!function(e){e.NO_ANSWER="no_answer",e.CANCELED="canceled",e.DECLINED="declined",e.OTHER_DEVICE_ACCEPTED="other_device_accepted",e.COMPLETED="completed",e.CONNECTION_LOST="connection_lost",e.TIMED_OUT="timed_out",e.DIAL_FAILED="dial_failed",e.ACCEPT_FAILED="accept_failed",e.NOT_CONNECTED="not_connected",e.UNKNOWN="unknown"}(Eo||(Eo={})),function(e){e.CALLER="dc_caller",e.CALLEE="dc_callee"}(ko||(ko={}));var Co=Math.min,Io=[].lastIndexOf,wo=!!Io&&1/[1].lastIndexOf(1,-0)<0,Ao=We("lastIndexOf"),bo=Ze("indexOf",{ACCESSORS:!0,1:0}),To=wo||!Ao||!bo?function(e){if(wo)return Io.apply(this,arguments)||0;var t=v(this),n=ce(t.length),r=n-1;for(arguments.length>1&&(r=Co(r,oe(arguments[1]))),r<0&&(r=n+r);r>=0;r--)if(r in t&&t[r]===e)return r||0;return-1}:Io;Oe({target:"Array",proto:!0,forced:To!==[].lastIndexOf},{lastIndexOf:To});var So,Oo=Ge("match"),Do=function(e){var t;return p(e)&&(void 0!==(t=e[Oo])?!!t:"RegExp"==d(e))},No=[].push,Lo=Math.min,Po=4294967295,xo=!i((function(){return!RegExp(Po,"y")}));qa("split",2,(function(e,t,n){var r;return r="c"=="abbc".split(/(b)*/)[1]||4!="test".split(/(?:)/,-1).length||2!="ab".split(/(?:ab)*/).length||4!=".".split(/(.?)(.?)/).length||".".split(/()()/).length>1||"".split(/.?/).length?function(e,n){var r=String(_(this)),i=void 0===n?Po:n>>>0;if(0===i)return[];if(void 0===e)return[r];if(!Do(e))return t.call(r,e,i);for(var a,o,s,c=[],u=(e.ignoreCase?"i":"")+(e.multiline?"m":"")+(e.unicode?"u":"")+(e.sticky?"y":""),l=0,d=new RegExp(e.source,u+"g");(a=Ma.call(d,r))&&!((o=d.lastIndex)>l&&(c.push(r.slice(l,a.index)),a.length>1&&a.index=i));)d.lastIndex===a.index&&d.lastIndex++;return l===r.length?!s&&d.test("")||c.push(""):c.push(r.slice(l)),c.length>i?c.slice(0,i):c}:"0".split(void 0,0).length?function(e,n){return void 0===e&&0===n?[]:t.call(this,e,n)}:t,[function(t,n){var i=_(this),a=null==t?void 0:t[e];return void 0!==a?a.call(t,i,n):r.call(String(i),t,n)},function(e,i){var a=n(r,e,this,i,r!==t);if(a.done)return a.value;var o=A(e),s=String(this),c=di(o,RegExp),u=o.unicode,l=(o.ignoreCase?"i":"")+(o.multiline?"m":"")+(o.unicode?"u":"")+(xo?"y":"g"),d=new c(xo?o:"^(?:"+o.source+")",l),h=void 0===i?Po:i>>>0;if(0===h)return[];if(0===s.length)return null===Wa(d,s)?[s]:[];for(var f=0,_=0,v=[];_=0;--a){var o=this.tryEntries[a],s=o.completion;if("root"===o.tryLoc)return i("end");if(o.tryLoc<=this.prev){var c=r.call(o,"catchLoc"),u=r.call(o,"finallyLoc");if(c&&u){if(this.prev=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&r.call(i,"finallyLoc")&&this.prev=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),S(n),p}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var i=r.arg;S(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,n,r){return this.delegate={iterator:D(e),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=t),p}},e}(e.exports);try{regeneratorRuntime=t}catch(e){"object"==typeof globalThis?globalThis.regeneratorRuntime=t:Function("r","regeneratorRuntime = r")(t)}})),Nr("slice")),Vo=Ze("slice",{ACCESSORS:!0,0:0,1:2}),Fo=Ge("species"),Go=[].slice,Bo=Math.max;Oe({target:"Array",proto:!0,forced:!Uo||!Vo},{slice:function(e,t){var n,r,i,a=v(this),o=ce(a.length),s=de(e,o),c=de(void 0===t?o:t,o);if(Pe(a)&&("function"!=typeof(n=a.constructor)||n!==Array&&!Pe(n.prototype)?p(n)&&null===(n=n[Fo])&&(n=void 0):n=void 0,n===Array||void 0===n))return Go.call(a,s,c);for(r=new(void 0===n?Array:n)(Bo(c-s,0)),i=0;sWo)throw TypeError(Ko);for(i=je(c,r),a=0;au-r+n;a--)delete c[a-1]}else if(n>r)for(a=u-r;a>l;a--)s=a+n-1,(o=a+r-1)in c?c[s]=c[o]:delete c[s];for(a=0;a1?n-1:0),i=1;i0?{keys:this.customItemKeys}:{}}},{key:"getMethod",value:function(){return"DELETE"}},{key:"getSubPath",value:function(){return"/".concat(this.roomId,"/custom_items")}}]),n}(cs),gs=function(e){Zn(n,e);var t=ir(n);function n(e,r,i,a){var o;return Hn(this,n),Kn(rr(o=t.call(this,e)),"type",es.DETACH),o.participantId=r,o.endpointId=i,o.attachTo=a,o}return Wn(n,[{key:"getData",value:function(){return{attach_to:this.attachTo}}},{key:"getMethod",value:function(){return"DELETE"}},{key:"getSubPath",value:function(){return"/".concat(this.roomId,"/participants/").concat(this.participantId,"/endpoints/").concat(this.endpointId)}}]),n}(cs),Es=function(e){Zn(n,e);var t=ir(n);function n(e,r){var i;return Hn(this,n),Kn(rr(i=t.call(this,e)),"type",es.ENTER),i.params=r,i}return Wn(n,[{key:"getData",value:function(){return{is_audio_on:this.params.audioEnabled,is_video_on:this.params.videoEnabled,kick_siblings:this.params.kickSiblings}}},{key:"getMethod",value:function(){return"POST"}},{key:"getSubPath",value:function(){return"/".concat(this.roomId,"/participants")}}]),n}(cs),ks=function(e){Zn(n,e);var t=ir(n);function n(e,r){var i;return Hn(this,n),Kn(rr(i=t.call(this,e)),"type",es.EXIT),i.participantId=r,i}return Wn(n,[{key:"getData",value:function(){return{}}},{key:"getMethod",value:function(){return"DELETE"}},{key:"getSubPath",value:function(){return"/".concat(this.roomId,"/participants/").concat(this.participantId)}}]),n}(cs),Rs=function(e){Zn(n,e);var t=ir(n);function n(e){var r;return Hn(this,n),Kn(rr(r=t.call(this,e)),"type",es.CUSTOM_ITEMS_FETCH),r}return Wn(n,[{key:"getData",value:function(){}},{key:"getMethod",value:function(){return"GET"}},{key:"getSubPath",value:function(){return"/".concat(this.roomId,"/custom_items")}}]),n}(cs),Cs=function(e){Zn(n,e);var t=ir(n);function n(){var e;Hn(this,n);for(var r=arguments.length,i=new Array(r),a=0;a1?arguments[1]:void 0)}});var Ss=[].join,Os=f!=Object,Ds=We("join",",");Oe({target:"Array",proto:!0,forced:Os||!Ds},{join:function(e){return Ss.call(v(this),void 0===e?",":e)}});var Ns=function(){function e(){Hn(this,e)}return Wn(e,null,[{key:"createQuery",value:function(e){var t=this;return Object.keys(e).filter((function(t){return null!=e[t]})).map((function(n){return"".concat(encodeURIComponent(n),"=").concat(t.toQueryParam(e[n]))})).join("&")}},{key:"toQueryParam",value:function(e){return Array.isArray(e)?e.map((function(e){return encodeURIComponent(e.toString())})).join(","):encodeURIComponent(e.toString())}}]),e}(),Ls=function(e){Zn(n,e);var t=ir(n);function n(e,r,i){var a;return Hn(this,n),Kn(rr(a=t.call(this)),"type",es.QUERY),a.params=a._normalizeParams(e),a.prev=r,a.next=i,a}return Wn(n,[{key:"getData",value:function(){}},{key:"getSubPath",value:function(){return"?".concat(this._createQuery())}},{key:"getMethod",value:function(){return"GET"}},{key:"_normalizeParams",value:function(e){var t=e.type,n=e.limit,r=e.state,i=e.currentParticipantCount,a=e.createdByUserIds,o=e.roomIds,s=e.createdAt;return{type:t,limit:null!=n?Math.min(Math.max(1,n),100):void 0,state:r,currentParticipantCount:i,createdByUserIds:a,roomIds:o,createdAt:s}}},{key:"_createQuery",value:function(){var e,t,n,r;return Ns.createQuery({type:this.params.type,limit:this.params.limit,state:this.params.state,current_participant_range_gte:null===(e=this.params.currentParticipantCount)||void 0===e?void 0:e[0],current_participant_range_lte:null===(t=this.params.currentParticipantCount)||void 0===t?void 0:t[1],created_by_user_ids:this.params.createdByUserIds,room_ids:this.params.roomIds,created_at_start_date:null===(n=this.params.createdAt)||void 0===n?void 0:n[0],created_at_end_date:null===(r=this.params.createdAt)||void 0===r?void 0:r[1],prev:this.prev,next:this.next})}}]),n}(cs),Ps=function(e){Zn(n,e);var t=ir(n);function n(e,r,i){var a;return Hn(this,n),Kn(rr(a=t.call(this,e)),"type",es.CUSTOM_ITEMS_UPDATE),a.customItems=r,a.mode=i,a}return Wn(n,[{key:"getData",value:function(){return{custom_items:this.customItems,mode:this.mode}}},{key:"getMethod",value:function(){return"PUT"}},{key:"getSubPath",value:function(){return"/".concat(this.roomId,"/custom_items")}}]),n}(cs),xs=function(e){Zn(n,e);var t=ir(n);function n(e,r,i){var a;return Hn(this,n),Kn(rr(a=t.call(this,e)),"type",es.VIDEO),a.participantId=r,a.enabled=i,a}return Wn(n,[{key:"getData",value:function(){return{on:this.enabled}}},{key:"getMethod",value:function(){return"PUT"}},{key:"getSubPath",value:function(){return"/".concat(this.roomId,"/participants/").concat(this.participantId,"/video")}}]),n}(cs),Ms=function(e){Zn(n,e);var t=ir(n);function n(){var e;Hn(this,n);for(var r=arguments.length,i=new Array(r),a=0;a1?arguments[1]:void 0)}}),mt(nc);var ac=function(e){Zn(n,e);var t=ir(n);function n(){return Hn(this,n),t.apply(this,arguments)}return Wn(n,[{key:"parseData",value:function(e){return e.room.current_participants.find((function(t){return t.participant_id===e.me.participant_id})).is_local_participant=!0,e.me.is_local_participant=!0,{me:Vs.parseParticipant(e.me),room:Vs.parseRoom(e.room)}}}]),n}(ls),oc=function(e){Zn(n,e);var t=ir(n);function n(){return Hn(this,n),t.apply(this,arguments)}return Wn(n,[{key:"parseData",value:function(e){return{}}}]),n}(ls),sc=function(e){Zn(n,e);var t=ir(n);function n(){return Hn(this,n),t.apply(this,arguments)}return Wn(n,[{key:"parseData",value:function(e){return Vs.parseCustomItemsResult(e)}}]),n}(ls),cc=function(e){Zn(n,e);var t=ir(n);function n(){return Hn(this,n),t.apply(this,arguments)}return Wn(n,[{key:"parseData",value:function(e){return{room:Vs.parseRoom(e.room)}}}]),n}(ls),uc=function(e){Zn(n,e);var t=ir(n);function n(){return Hn(this,n),t.apply(this,arguments)}return Wn(n,[{key:"parseData",value:function(e){return{endpointId:e.endpoint_id,sdp:e.sdp}}}]),n}(ls),lc=function(e){Zn(n,e);var t=ir(n);function n(){return Hn(this,n),t.apply(this,arguments)}return Wn(n,[{key:"parseData",value:function(e){return{}}}]),n}(ls),dc=function(e){Zn(n,e);var t=ir(n);function n(){return Hn(this,n),t.apply(this,arguments)}return Wn(n,[{key:"parseData",value:function(e){return{rooms:e.rooms.map((function(e){return Vs.parseRoom(e)})),prev:e.prev,next:e.next}}}]),n}(ls),hc=function(e){Zn(n,e);var t=ir(n);function n(){return Hn(this,n),t.apply(this,arguments)}return Wn(n,[{key:"parseData",value:function(e){return Vs.parseCustomItemsResult(e)}}]),n}(ls),fc=function(e){Zn(n,e);var t=ir(n);function n(){return Hn(this,n),t.apply(this,arguments)}return Wn(n,[{key:"parseData",value:function(e){return{me:Vs.parseParticipant(e.me)}}}]),n}(ls),_c=function(e){Zn(n,e);var t=ir(n);function n(e,r){var i;return Hn(this,n),Kn(rr(i=t.call(this,e)),"type",es.INVITATION_ACCEPTED),i.inviterId=r,i}return Wn(n,[{key:"getData",value:function(){return{action:"accept",inviter_id:this.inviterId}}},{key:"getMethod",value:function(){return"PUT"}},{key:"getSubPath",value:function(){return"/".concat(this.roomId,"/invitation")}}]),n}(cs),vc=function(e){Zn(n,e);var t=ir(n);function n(e,r){var i;return Hn(this,n),Kn(rr(i=t.call(this,e)),"type",es.INVITATION_CANCELED),i.inviteeId=r,i}return Wn(n,[{key:"getData",value:function(){return{invitee_id:this.inviteeId}}},{key:"getMethod",value:function(){return"DELETE"}},{key:"getSubPath",value:function(){return"/".concat(this.roomId,"/invitation")}}]),n}(cs),pc=function(e){Zn(n,e);var t=ir(n);function n(e,r){var i;return Hn(this,n),Kn(rr(i=t.call(this,e)),"type",es.INVITATION_DECLINED),i.inviterId=r,i}return Wn(n,[{key:"getData",value:function(){return{action:"decline",inviter_id:this.inviterId}}},{key:"getMethod",value:function(){return"PUT"}},{key:"getSubPath",value:function(){return"/".concat(this.roomId,"/invitation")}}]),n}(cs),mc=function(e){Zn(n,e);var t=ir(n);function n(e){var r;return Hn(this,n),Kn(rr(r=t.call(this,void 0)),"type",es.ROOM_DELETED),r.roomId=e,r}return Wn(n,[{key:"getData",value:function(){return{}}},{key:"getMethod",value:function(){return"DELETE"}},{key:"getSubPath",value:function(){return"/".concat(this.roomId)}}]),n}(cs),yc=function(e){Zn(n,e);var t=ir(n);function n(e,r,i){var a;return Hn(this,n),Kn(rr(a=t.call(this,e)),"type",es.INVITATION_RECEIVED),a.inviterId=r,a.shortLivedToken=i,a}return Wn(n,[{key:"getHeaders",value:function(){return{"SBCall-Short-Lived-Token":this.shortLivedToken}}},{key:"getData",value:function(){return{action:"receive",inviter_id:this.inviterId}}},{key:"getMethod",value:function(){return"PUT"}},{key:"getSubPath",value:function(){return"/".concat(this.roomId,"/invitation")}}]),n}(cs),gc=function(e){Zn(n,e);var t=ir(n);function n(e,r){var i;return Hn(this,n),Kn(rr(i=t.call(this,e)),"type",es.INVITATION_SENT),i.inviteeId=r,i}return Wn(n,[{key:"getData",value:function(){return{invitee_id:this.inviteeId}}},{key:"getMethod",value:function(){return"POST"}},{key:"getSubPath",value:function(){return"/".concat(this.roomId,"/invitation")}}]),n}(cs),Ec=function(e){Zn(n,e);var t=ir(n);function n(){var e;Hn(this,n);for(var r=arguments.length,i=new Array(r),a=0;a1?arguments[1]:void 0,d=void 0!==l,h=nn(s),f=0;if(d&&(l=Ne(l,u>2?arguments[2]:void 0,2)),null==h||c==Array&&Qt(h))for(n=new c(t=ce(s.length));t>f;f++)o=d?l(s[f],f):s[f],wr(n,f,o);else for(a=(i=h.call(s)).next,n=new c;!(r=a.call(i)).done;f++)o=d?Tc(i,l,[r.value,f],!0):r.value,wr(n,f,o);return n.length=f,n},Oc=!hn((function(e){Array.from(e)}));Oe({target:"Array",stat:!0,forced:Oc},{from:Sc});for(var Dc=function(e,t){return e(t={exports:{}},t.exports),t.exports}((function(e){var t="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof window.msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto);if(t){var n=new Uint8Array(16);e.exports=function(){return t(n),n}}else{var r=new Array(16);e.exports=function(){for(var e,t=0;t<16;t++)0==(3&t)&&(e=4294967296*Math.random()),r[t]=e>>>((3&t)<<3)&255;return r}}})),Nc=[],Lc=0;Lc<256;++Lc)Nc[Lc]=(Lc+256).toString(16).substr(1);var Pc=function(e,t){var n=t||0,r=Nc;return[r[e[n++]],r[e[n++]],r[e[n++]],r[e[n++]],"-",r[e[n++]],r[e[n++]],"-",r[e[n++]],r[e[n++]],"-",r[e[n++]],r[e[n++]],"-",r[e[n++]],r[e[n++]],r[e[n++]],r[e[n++]],r[e[n++]],r[e[n++]]].join("")};var xc=function(e,t,n){var r=t&&n||0;"string"==typeof e&&(t="binary"===e?new Array(16):null,e=null);var i=(e=e||{}).random||(e.rng||Dc)();if(i[6]=15&i[6]|64,i[8]=63&i[8]|128,t)for(var a=0;a<16;++a)t[r+a]=i[a];return t||Pc(i)},Mc=fe.includes,Uc=Ze("indexOf",{ACCESSORS:!0,1:0});Oe({target:"Array",proto:!0,forced:!Uc},{includes:function(e){return Mc(this,e,arguments.length>1?arguments[1]:void 0)}}),mt("includes");var Vc=function(e){if(Do(e))throw TypeError("The method doesn't accept regular expressions");return e},Fc=Ge("match");Oe({target:"String",proto:!0,forced:!function(e){var t=/./;try{"/./"[e](t)}catch(n){try{return t[Fc]=!1,"/./"[e](t)}catch(e){}}return!1}("includes")},{includes:function(e){return!!~String(_(this)).indexOf(Vc(e),arguments.length>1?arguments[1]:void 0)}});var Gc="[\t\n\v\f\r                 \u2028\u2029\ufeff]",Bc=RegExp("^"+Gc+Gc+"*"),jc=RegExp(Gc+Gc+"*$"),qc=function(e){return function(t){var n=String(_(t));return 1&e&&(n=n.replace(Bc,"")),2&e&&(n=n.replace(jc,"")),n}},Hc={start:qc(1),end:qc(2),trim:qc(3)},zc=ye.f,Wc=w.f,Kc=T.f,Yc=Hc.trim,Qc="Number",Zc=r[Qc],Xc=Zc.prototype,$c=d(dt(Xc))==Qc,Jc=function(e){var t,n,r,i,a,o,s,c,u=m(e,!1);if("string"==typeof u&&u.length>2)if(43===(t=(u=Yc(u)).charCodeAt(0))||45===t){if(88===(n=u.charCodeAt(2))||120===n)return NaN}else if(48===t){switch(u.charCodeAt(1)){case 66:case 98:r=2,i=49;break;case 79:case 111:r=8,i=55;break;default:return+u}for(o=(a=u.slice(2)).length,s=0;si)return NaN;return parseInt(a,r)}return+u};if(Te(Qc,!Zc(" 0o1")||!Zc("0b1")||Zc("+0x1"))){for(var eu,tu=function(e){var t=arguments.length<1?0:e,n=this;return n instanceof tu&&($c?i((function(){Xc.valueOf.call(n)})):d(n)!=Qc)?fn(new Zc(Jc(t)),n,tu):Jc(t)},nu=a?zc(Zc):"MAX_VALUE,MIN_VALUE,NaN,NEGATIVE_INFINITY,POSITIVE_INFINITY,EPSILON,isFinite,isInteger,isNaN,isSafeInteger,MAX_SAFE_INTEGER,MIN_SAFE_INTEGER,parseFloat,parseInt,isInteger,fromString,range".split(","),ru=0;nu.length>ru;ru++)g(Zc,eu=nu[ru])&&!g(tu,eu)&&Kc(tu,eu,Wc(Zc,eu));tu.prototype=Xc,Xc.constructor=tu,ee(r,Qc,tu)}Oe({target:"Number",stat:!0},{isNaN:function(e){return e!=e}});var iu=function(e){return void 0===e||Number.isNaN(e)||""===e||e===[]},au=function(e){Object.keys(e).forEach((function(t){iu(e[t])&&delete e[t]}))};var ou,su=function(){var e=qn(regeneratorRuntime.mark((function e(t){var n,r,i,a,o,s,c,u,l,d,h,f,_;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t){e.next=2;break}throw new Error("'getCandidateInfo()' is called without rtcConnection");case 2:return e.next=4,t.getStats();case 4:n=e.sent,i=n.entries(),a=0;case 7:if(!(a=100&&(i=4.5),i<1&&(i=1),i>4.5&&(i=4.5),i}}(r.packets_lost,r.remote_jitter,r.remote_rtt)),n},hu=function(e,t){if(void 0!==e||void 0!==t)return(null!=e?e:0)+(null!=t?t:0)},fu=function(e,t,n){if(void 0!==e||void 0!==t)return(null!=e?e:0)*n+(null!=t?t:0)*(1-n)},_u=function(e,t){var n=lu(e);if(!t)return n;function r(e){return"audio"===e?function(e){n.audio[e]=hu(n.audio[e],t.audio[e])}:function(e){n.video[e]=hu(n.video[e],t.video[e])}}return r("audio")("total_packets_sent"),r("audio")("total_packets_received"),r("audio")("total_packets_lost"),r("audio")("retransmitted_packets_sent"),r("audio")("jitter_buffer_delay"),r("video")("outbound_fir_count"),r("video")("outbound_pli_count"),r("video")("outbound_nack_count"),r("video")("retransmitted_packets_sent"),r("video")("quality_limitation_resolution_changes"),"none"===n.video.quality_limitation_reason&&(n.video.quality_limitation_reason=t.video.quality_limitation_reason),r("video")("key_frames_decoded"),r("video")("total_decode_time"),r("video")("total_inter_frame_delay"),r("video")("total_squared_inter_frame_delay"),r("video")("total_packets_lost"),r("video")("total_packets_received"),r("video")("jitter_buffer_delay"),r("video")("jitter_buffer_emitted_count"),r("video")("frames_received"),r("video")("frames_decoded"),r("video")("freeze_count"),r("video")("pause_count"),r("video")("total_freezes_duration"),r("video")("total_pauses_duration"),n},vu=function(e,t,n){var r=lu(e);if(n<=1||!t)return r;var i=1/n,a=1/(n-1);function o(e){return"audio"===e?function(e){r.audio[e]=fu(r.audio[e],t.audio[e],["rtt","mos"].includes(e)?a:i)}:function(e){r.video[e]=fu(r.video[e],t.video[e],["rtt","mos"].includes(e)?a:i)}}function s(e){return"audio"===e?function(e){r.audio[e]=t.audio[e]}:function(e){r.video[e]=t.video[e]}}return s("audio")("codec"),o("audio")("remote_rtt"),o("audio")("packets_sent"),o("audio")("packets_received"),o("audio")("bytes_sent"),o("audio")("bytes_received"),o("audio")("retransmitted_packets_sent"),o("audio")("retransmitted_bytes_sent"),o("audio")("fec_packets_received"),o("audio")("samples_received"),o("audio")("concealed_samples"),o("audio")("silent_concealed_samples"),o("audio")("inserted_samples_for_deceleration"),o("audio")("removed_samples_for_acceleration"),o("audio")("target_bitrate"),o("audio")("remote_fraction_lost"),o("audio")("inbound_jitter"),o("audio")("remote_jitter"),o("audio")("packets_lost"),o("audio")("packets_lost_rate"),o("audio")("remote_packets_lost"),o("audio")("remote_packets_lost_rate"),o("audio")("mos"),s("video")("codec"),o("video")("remote_rtt"),o("video")("packets_sent"),o("video")("packets_received"),o("video")("packets_lost"),o("video")("bytes_sent"),o("video")("bytes_received"),o("video")("retransmitted_packets_sent"),o("video")("retransmitted_bytes_sent"),o("video")("packets_lost_rate"),o("video")("remote_packets_lost"),o("video")("remote_packets_lost_rate"),o("video")("frames_sent"),o("video")("frames_received"),o("video")("frames_encoded"),o("video")("key_frames_encoded"),o("video")("frames_decoded"),o("video")("key_frames_decoded"),o("video")("video_source_width"),o("video")("video_source_height"),o("video")("video_source_frames_per_second"),o("video")("received_frame_width"),o("video")("received_frame_height"),o("video")("sent_frame_width"),o("video")("sent_frame_height"),o("video")("target_bitrate"),o("video")("inbound_jitter"),o("video")("remote_jitter"),o("video")("remote_fraction_lost"),"none"===r.video.quality_limitation_reason&&(r.video.quality_limitation_reason=t.video.quality_limitation_reason),r},pu=function(e){Zn(n,e);var t=ir(n);function n(){return Hn(this,n),t.apply(this,arguments)}return n}(is);!function(e){e.OFFER="offer",e.ANSWER="answer",e.CANDIDATE="candidate"}(ou||(ou={}));var mu,yu=function(e){Zn(n,e);var t=ir(n);function n(e){var r;return Hn(this,n),Kn(rr(r=t.call(this,{payload:e})),"type",ou.ANSWER),r}return n}(pu),gu=function(e){Zn(n,e);var t=ir(n);function n(e){var r;return Hn(this,n),Kn(rr(r=t.call(this,{payload:e})),"type",ou.CANDIDATE),r}return n}(pu),Eu=function(e){Zn(n,e);var t=ir(n);function n(e){var r;return Hn(this,n),Kn(rr(r=t.call(this,{payload:e})),"type",ou.OFFER),r}return n}(pu),ku=function(){function e(){Hn(this,e)}return Wn(e,null,[{key:"createOffer",value:function(e,t){return new Eu({peerConnectionId:e,sdp:t})}},{key:"createAnswer",value:function(e,t){return new yu({peerConnectionId:e,sdp:t})}},{key:"createCandidate",value:function(e,t){return new gu({peerConnectionId:e,candidate:t})}}]),e}(),Ru=function(){function e(t){Hn(this,e),this._context=t}return Wn(e,[{key:"_changeState",value:function(e){this._state&&this._state.type===e.type?fo.error(new Error("self-transition is not allowed")):(fo.debug("[".concat(this.name,"] state: ").concat(this._state?this._state.type:"null"," -> ").concat(e.type)),this._state&&this._state.destroy(),this._state=e,this._state.context=this._context,this._state.start())}},{key:"state",get:function(){return this._state}}]),e}(),Cu=function(){function e(t){Hn(this,e),this._stateMutator=t}return Wn(e,[{key:"start",value:function(){this._onStart()}},{key:"destroy",value:function(){this._onDestroy()}},{key:"context",set:function(e){this._context=e}}]),e}(),Iu=function(){function e(t,n){Hn(this,e),this._context=t,this._stateMutator=n}return Wn(e,[{key:"state",get:function(){return this._stateMutator.state}}]),e}(),wu=function(e){Zn(n,e);var t=ir(n);function n(e){var r;return Hn(this,n),(r=t.call(this,e))._stateMutator=e,r}return n}(Cu);!function(e){e.IDLE="idle",e.OFFERING="offering",e.ANSWERING="answering",e.CONNECTED="connected",e.RECONNECTING="reconnecting",e.ICE_RESTART_OFFERING="iceRestartOffering",e.ICE_RESTART_ANSWERING="iceRestartAnswering",e.CLOSED="closed"}(mu||(mu={}));var Au,bu=function(e){Zn(r,e);var t,n=ir(r);function r(e,t){var i;return Hn(this,r),Kn(rr(i=n.call(this,e)),"type",mu.ANSWERING),i._stateMutator=e,i._offerCommand=t,i}return Wn(r,[{key:"_onStart",value:function(){this._context.dispatchEvent("answering"),this._context.createRTCConnection(),this._offerCommand&&this.onOfferReceived(this._offerCommand)}},{key:"_onDestroy",value:function(){}},{key:"onOfferReceived",value:(t=qn(regeneratorRuntime.mark((function e(t){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._context.setRemoteDescription("offer",t.payload.sdp);case 2:this._context.prepareSessionDescription(),this._context.sendAnswer().catch((function(e){return fo.debug(e)}));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})},{key:"onIceConnected",value:function(){this._stateMutator.toConnected(!1)}},{key:"onClose",value:function(){this._stateMutator.toClosed()}}]),r}(wu),Tu=function(e){Zn(n,e);var t=ir(n);function n(){var e;Hn(this,n);for(var r=arguments.length,i=new Array(r),a=0;a3&&void 0!==f[3]&&f[3],a=f.length>4&&void 0!==f[4]?f[4]:{count:0,deferred:new Vu},o=a.deferred,s=a.count,!i){e.next=6;break}return o.reject("retry is halted."),e.abrupt("return",o.promise);case 6:return e.prev=6,e.next=9,n();case 9:u=e.sent,s>0&&(null===(c=r.onRecover)||void 0===c||c.call(r)),o.resolve(u),e.next=23;break;case 14:if(e.prev=14,e.t0=e.catch(6),null===(l=r.onError)||void 0===l||l.call(r,e.t0),!((d=t.calcTimeout(s+1))>=0)){e.next=22;break}return null===(h=r.onRetrial)||void 0===h||h.call(r,s+1,e.t0),setTimeout((function(){Fu(t,n,r,i,{count:s+1,deferred:o})}),d),e.abrupt("return",o.promise);case 22:o.reject(e.t0);case 23:return e.abrupt("return",o.promise);case 24:case"end":return e.stop()}}),e,null,[[6,14]])})));return function(t,n,r){return e.apply(this,arguments)}}(),Gu=function(){function e(){Hn(this,e)}return Wn(e,[{key:"calcTimeout",value:function(e){switch(e){case 1:return 1e3;case 2:return 2e3;case 3:return 3e3;default:return-1}}}]),e}(),Bu=function(){function e(t,n,r){Hn(this,e),this.interval=t,this.noise=n,this.maxRetrial=r}return Wn(e,[{key:"calcTimeout",value:function(e){return e>this.maxRetrial?-1:this.interval+(Math.random()-.5)*this.noise*2}}]),e}(),ju=function(e){Zn(o,e);var t,n,r,i,a=ir(o);function o(e,t,n,r,i,s,c,u){var l;return Hn(this,o),(l=a.call(this))._ctx=e,l.id=t,l._signalingClient=n,l._localStream=r,l._isInitiator=i,l._turnCredential=s,l._mediaDirections=c,l._isDisposable=u,l._stateMachine=new Mu({dispatchEvent:l._dispatchEvent.bind(rr(l)),isInitiator:l._isInitiator,setRemoteDescription:l._setRemoteDescription.bind(rr(l)),sendAnswer:l._sendAnswer.bind(rr(l)),sendOffer:l._sendOffer.bind(rr(l)),createRTCConnection:l._createRTCConnection.bind(rr(l)),prepareSessionDescription:l._prepareSessionDescription.bind(rr(l)),isDisposable:l._isDisposable}),r&&r.on("streamChanged",(function(e){return l.onLocalStream(e)})),l._halts=[],l}return Wn(o,[{key:"onEvent",value:function(e){switch(e.type){case ou.CANDIDATE:return void this._receiveCandidate(e);case ou.OFFER:this._stateMachine.onOfferReceived(e);break;case ou.ANSWER:this._stateMachine.onAnswerReceived(e);break;default:fo.error(new Error("unhandled call event ".concat(e)))}}},{key:"createOffer",value:function(){this._stateMachine.createOffer()}},{key:"close",value:function(){this._halts.forEach((function(e){return e()})),this._closeRTCConnection(),this._stateMachine.onClose()}},{key:"onLocalStream",value:function(e){if(this._rtcConnection){var t,n=fr(e.getTracks());try{for(n.s();!(t=n.n()).done;){var r=t.value;this._replaceTrack(r)}}catch(e){n.e(e)}finally{n.f()}}}},{key:"getCandidateInfo",value:(i=qn(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",su(this.rtcConnection));case 1:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"getStatsLog",value:(r=qn(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",uu(this.rtcConnection));case 1:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"_replaceTrack",value:function(e){var t,n=fr(this._rtcConnection.getSenders());try{for(n.s();!(t=n.n()).done;){var r=t.value;r.track&&r.track.kind===e.kind&&r.replaceTrack(e)}}catch(e){n.e(e)}finally{n.f()}}},{key:"_createRTCConnection",value:function(){var e,t=this;this._turnCredential&&(e={iceServers:[{username:this._turnCredential.username,credential:this._turnCredential.password,urls:this._turnCredential.turnUrls}],iceTransportPolicy:this._turnCredential.transportPolicy||Au.ALL});var n=new RTCPeerConnection(e);n.onnegotiationneeded=function(){t._sendOffer(!1)},n.onicecandidate=function(e){var n,r;e.candidate&&(null===(n=(r=t._signalingClient).sendCandidate)||void 0===n||n.call(r,e.candidate))},n.onconnectionstatechange=function(){return t._handleConnectionStateChange(n)},n.oniceconnectionstatechange=function(){return t._handleIceConnectionStateChange(n)},n.ontrack=function(e){return t._onRemoteTrack(e)},this._rtcConnection=n}},{key:"_closeRTCConnection",value:function(){this._rtcConnection&&(this._rtcConnection.onnegotiationneeded=null,this._rtcConnection.onicecandidate=null,this._rtcConnection.oniceconnectionstatechange=null,this._rtcConnection.onconnectionstatechange=null,this._rtcConnection.close(),this._rtcConnection=null,delete this._remoteStream)}},{key:"_prepareSessionDescription",value:function(){var e=this._mediaDirections,t=e.audio,n=e.video,r={sendrecv:[],sendonly:[],recvonly:[],none:[]};r[t].push("audio"),r[n].push("video"),r.sendrecv.length&&this._addTracks(r.sendrecv),r.sendonly.length&&this._addSendOnlyTransceivers(r.sendonly),r.recvonly.length&&this._addReceiveOnlyTransceivers(r.recvonly)}},{key:"_addTracks",value:function(e){var t=this;fo.debug("_addTracks()");var n=this._localStream.localStream;n.getTracks().forEach((function(r){e.includes(r.kind)&&t._rtcConnection.addTrack(r,n)}))}},{key:"_addReceiveOnlyTransceivers",value:function(e){var t=this;e.forEach((function(e){t._rtcConnection.addTransceiver(e,{direction:"recvonly"})}))}},{key:"_addSendOnlyTransceivers",value:function(e){var t=this,n=this._localStream.localStream;e.forEach((function(e){n.getTracks().forEach((function(r){r.kind===e&&t._rtcConnection.addTransceiver(r,{direction:"sendonly",streams:[n]})}))}))}},{key:"_setRemoteDescription",value:function(e,t){var n=new RTCSessionDescription({type:e,sdp:t});return this._rtcConnection.setRemoteDescription(n)}},{key:"_sendOffer",value:(n=qn(regeneratorRuntime.mark((function e(t){var n,r,i,a,o=this;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n={iceRestart:t||!1},e.next=3,this._rtcConnection.createOffer(n);case 3:return r=e.sent,e.next=6,this._rtcConnection.setLocalDescription(r);case 6:return i=function(){return o._signalingClient.sendOfferSdp(o._rtcConnection.localDescription)},a=!1,this._halts.push((function(){a=!0})),e.abrupt("return",Fu(new Bu(2500,1e3,12),i,{onError:function(e){fo.warning("Failed to send offer command",e)}},a));case 10:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"_sendAnswer",value:(t=qn(regeneratorRuntime.mark((function e(){var t,n,r,i=this;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._rtcConnection.createAnswer();case 2:return(t=e.sent).sdp=t.sdp.replace("actpass","active"),e.next=6,this._rtcConnection.setLocalDescription(t);case 6:return n=function(){return i._signalingClient.sendAnswerSdp(i._rtcConnection.localDescription)},r=!1,this._halts.push((function(){r=!0})),e.abrupt("return",Fu(new Bu(2500,1e3,12),n,{onError:function(e){fo.warning("Failed to send answer command",e)}},r));case 10:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"_handleIceConnectionStateChange",value:function(e){switch(fo.verbose("[".concat(this._state.type,"] iceConnectionState ").concat(e.iceConnectionState)),e.iceConnectionState){case"connected":this._stateMachine.onIceConnected();break;case"disconnected":this._stateMachine.onIceDisconnected();break;case"failed":this._stateMachine.onIceFailed(),this._dispatchEvent("iceFailed")}}},{key:"_handleConnectionStateChange",value:function(e){if("failed"===e.connectionState)this._stateMachine.onIceFailed(),this._dispatchEvent("iceFailed")}},{key:"_receiveCandidate",value:function(e){var t=e.payload.candidate;this._rtcConnection.addIceCandidate({sdpMLineIndex:t.sdpMLineIndex,sdpMid:t.sdpMid,candidate:t.sdp}).catch((function(e){fo.error(e)}))}},{key:"_onRemoteTrack",value:function(e){this._remoteStream=e.streams[0],this._dispatchEvent("remoteStream",this._remoteStream)}},{key:"_state",get:function(){return this._stateMachine.state}},{key:"rtcConnection",get:function(){return this._rtcConnection}},{key:"remoteStream",get:function(){return this._remoteStream}},{key:"signalingClient",get:function(){return this._signalingClient}}]),o}(Yo),qu=function(){function e(){Hn(this,e)}var t;return Wn(e,[{key:"addStatsLog",value:function(e){this._accumulated=_u(e,this._accumulated)}},{key:"getAccumulatedStats",value:(t=qn(regeneratorRuntime.mark((function e(t){var n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.getStatsLog();case 2:return n=e.sent,e.abrupt("return",_u(n,this._accumulated));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})}]),e}(),Hu=function(e){Zn(r,e);var t,n=ir(r);function r(e,t){var i;return Hn(this,r),Kn(rr(i=n.call(this)),"_peerConnections",new Map),Kn(rr(i),"_unhandledCommands",[]),i._ctx=e,i._mediaDirections=t,i._statsLogAccumulator=new qu,i}return Wn(r,[{key:"_activePC",get:function(){return this._peerConnections.get(this._activePCId)},set:function(e){this._peerConnections.has(e.id)||this._addPC(e),this._activePCId=e.id}},{key:"_preparingPC",get:function(){return this._peerConnections.get(this._preparingPCId)},set:function(e){this._peerConnections.has(e.id)||this._addPC(e),this._preparingPCId=e.id}},{key:"activePeerConnection",get:function(){return this._activePC}}]),Wn(r,[{key:"createPeerConnection",value:function(e,t,n,r,i){fo.debug("Create new peer connection");var a=new ju(this._ctx,e,t,n,r,i,this._mediaDirections,!1);return this._activePC?(this._replacePreparing(a,r),this._dispatchUnhandledCommands(a),a):(this._activePC=a,this._dispatchEvent("initialized"),this._dispatchUnhandledCommands(a),a)}},{key:"createOffer",value:function(){this._activePC&&this._activePC.createOffer()}},{key:"close",value:function(){this._deactivatePreparing(),this._deactivateActive()}},{key:"onEvent",value:function(e){var t,n=null!==(t=e.payload.peerConnectionId)&&void 0!==t?t:void 0,r=this._peerConnections.get(n);this._isActive(n)||this._isPreparing(n)?r.onEvent(e):this._isInactive(n)||this._dispatchOnCreation(e)}},{key:"getStatsLog",value:(t=qn(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._activePC){e.next=2;break}return e.abrupt("return",void 0);case 2:return e.abrupt("return",this._statsLogAccumulator.getAccumulatedStats(this._activePC));case 3:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"_addPC",value:function(e){this._peerConnections.set(e.id,e)}},{key:"_isActive",value:function(e){return e===this._activePCId}},{key:"_isPreparing",value:function(e){return e===this._preparingPCId}},{key:"_isInactive",value:function(e){return!this._isActive(e)&&!this._isPreparing(e)&&!!this._peerConnections.get(e)}},{key:"_deactivateActive",value:function(){fo.debug("Close active pc if exist"),this._activePC&&(this._activePC.removeAllEventListeners(),this._activePC.close(),delete this._activePCId)}},{key:"_activatePreparing",value:function(){var e=this;if(fo.debug("Activate preparing pc if exist"),this._preparingPC){var t=this._activePC;this._activePC=this._preparingPC,delete this._preparingPCId,this._dispatchEvent("replaced"),t.removeAllEventListeners(),t.getStatsLog().then((function(n){e._statsLogAccumulator.addStatsLog(n),t.close()}))}}},{key:"_deactivatePreparing",value:function(){fo.debug("Close preparing pc if exist"),this._preparingPC&&(this._preparingPC.removeAllEventListeners(),this._preparingPC.close(),delete this._preparingPCId)}},{key:"_replacePreparing",value:function(e,t){var n=this;fo.debug("Create preparing peer connection"),this._deactivatePreparing(),this._preparingPC=e;this._preparingPC.once("connected",(function(){setTimeout((function(){n._activatePreparing()}),2e3)})),t&&this._preparingPC.createOffer()}},{key:"_dispatchUnhandledCommands",value:function(e){this._unhandledCommands.filter((function(t){return t.payload.peerConnectionId===e.id})).forEach((function(t){return e.onEvent(t)})),this._unhandledCommands=this._unhandledCommands.filter((function(t){return t.payload.peerConnectionId!==e.id}))}},{key:"_dispatchOnCreation",value:function(e){this._unhandledCommands.push(e)}}]),r}(Yo),zu=function(){function e(t){Hn(this,e),this._requests=new Map,this.timeoutTime=t}return Wn(e,[{key:"has",value:function(e){return this._requests.has(e)}},{key:"get",value:function(e){return this._requests.get(e)}},{key:"register",value:function(e){if(!e)throw new Error("invalid request id");if(this._requests.has(e))throw new Error("duplicate requests");var t=new Vu;return this._requests.set(e,{deferred:t,timer:this._createTimeoutTimer(e)}),t}},{key:"unregister",value:function(e){if(!this._requests.has(e))return null;var t=this._requests.get(e),n=t.timer,r=t.deferred;return clearTimeout(n),this._requests.delete(e),r}},{key:"_createTimeoutTimer",value:function(e){var t=this;return setTimeout((function(){t.unregister(e).reject(new Ja(Ln.ERR_NO_RESPONSE_DUE_TO_TIMEOUT))}),this._getTimeoutTime())}},{key:"rejectAll",value:function(e){var t,n=fr(this._requests.keys());try{for(n.s();!(t=n.n()).done;){var r=t.value,i=this._requests.get(r);clearTimeout(i.timer),i.deferred.reject(e)}}catch(e){n.e(e)}finally{n.f()}this._requests.clear()}},{key:"_getTimeoutTime",value:function(){return this.timeoutTime}}]),e}(),Wu=function(){function e(t,n,r,i){Hn(this,e),Kn(this,"_timeoutTime",6e4),this._ctx=t,this._participantId=n,this._mediaDirections=r,this._endpointId=i,this._requestMap=new zu(this._timeoutTime)}var t,n,r;return Wn(e,[{key:"sendOfferSdp",value:(r=qn(regeneratorRuntime.mark((function e(t){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._endpointId){e.next=5;break}return e.next=3,this._sendOfferAndUnregisterCreateEndpointRequest(t);case 3:e.next=7;break;case 5:return e.next=7,this._sendOfferAndUnregisterPutEndpointRequest(t);case 7:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"_sendOfferAndUnregisterCreateEndpointRequest",value:(n=qn(regeneratorRuntime.mark((function e(t){var n,r;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=this._requestMap.unregister("".concat(this._participantId,":create-endpoint-request")),e.prev=1,e.next=4,this._sendCreateEndpoint(t);case 4:return r=e.sent,n&&n.resolve(r),e.abrupt("return",r);case 9:throw e.prev=9,e.t0=e.catch(1),n&&n.reject(e.t0),e.t0;case 13:case"end":return e.stop()}}),e,this,[[1,9]])}))),function(e){return n.apply(this,arguments)})},{key:"_sendOfferAndUnregisterPutEndpointRequest",value:(t=qn(regeneratorRuntime.mark((function e(t){var n,r;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=this._requestMap.unregister("".concat(this._participantId,":put-endpoint-request")),e.prev=1,e.next=4,this._sendPutEndpoint(t);case 4:return r=e.sent,n&&n.resolve(r),e.abrupt("return",r);case 9:throw e.prev=9,e.t0=e.catch(1),n&&n.reject(e.t0),e.t0;case 13:case"end":return e.stop()}}),e,this,[[1,9]])}))),function(e){return t.apply(this,arguments)})},{key:"registerCreateEndpointRequest",value:function(){if(fo.debug("registerCreateEndpointRequest()"),this._endpointId)throw new Error("Cannot register create endpoint request on endpoint recycle");return this._requestMap.register("".concat(this._participantId,":create-endpoint-request"))}},{key:"registerPutEndpointRequest",value:function(){if(fo.debug("registerPutEndpointRequest()"),!this._endpointId)throw new Error("Cannot register put endpoint request without endpoint id");return this._requestMap.register("".concat(this._participantId,":put-endpoint-request"))}},{key:"_sendCreateEndpoint",value:function(e){var t=bc.createCreateEndpoint(this._ctx.roomId,this._participantId,e.sdp,this._mediaDirections);return this._ctx.sender.send(t)}},{key:"_sendPutEndpoint",value:function(e){var t=bc.createPutEndpoint(this._ctx.roomId,this._participantId,this._endpointId,e.sdp);return this._ctx.sender.send(t)}}]),e}(),Ku=function(e){Zn(n,e);var t=ir(n);function n(e){var r;return Hn(this,n),(r=t.call(this,e))._stateMutator=e,r}return n}(Cu);!function(e){e.IDLE="idle",e.OFFERING="offering",e.ESTABLISHED="established",e.CONNECTED="connected",e.DISCONNECTED="disconnected",e.RECONNECTING="reconnecting",e.RELEASING="releasing",e.CLOSED="closed"}(Uu||(Uu={}));var Yu=function(e){Zn(n,e);var t=ir(n);function n(){var e;Hn(this,n);for(var r=arguments.length,i=new Array(r),a=0;a0;this._context.dispatchEvent("connected",e)}},{key:"_onDestroy",value:function(){}},{key:"onICEFailed",value:function(){this._stateMutator.toDisconnected(!0)}},{key:"onAttach",value:function(){this._context.requestAttach()}},{key:"onRelease",value:function(){this._stateMutator.toReleasing()}},{key:"onExit",value:function(){this._stateMutator.toClosed()}}]),n}(Ku),Zu=function(e){Zn(n,e);var t=ir(n);function n(e,r,i){var a;return Hn(this,n),Kn(rr(a=t.call(this,e)),"type",Uu.ESTABLISHED),a._stateMutator=e,a._sdp=r,a._hasPendingAttach=i,a}return Wn(n,[{key:"_onStart",value:function(){this._context.dispatchEvent("established"),this._context.setRemoteDescription(this._sdp),this._hasPendingAttach&&this.onAttach()}},{key:"_onDestroy",value:function(){}},{key:"onPCConnected",value:function(){this._stateMutator.toConnected()}},{key:"onICEFailed",value:function(){this._stateMutator.toDisconnected(!1)}},{key:"onAttach",value:function(){this._context.requestAttach()}},{key:"onRelease",value:function(){this._stateMutator.toReleasing()}},{key:"onExit",value:function(){this._stateMutator.toClosed()}}]),n}(Ku),Xu=function(e){Zn(n,e);var t=ir(n);function n(){var e;Hn(this,n);for(var r=arguments.length,i=new Array(r),a=0;a1?arguments[1]:void 0)}});var _l=function(e){return function(t,n,r,i){De(n);var a=Le(t),o=f(a),s=ce(a.length),c=e?s-1:0,u=e?-1:1;if(r<2)for(;;){if(c in o){i=o[c],c+=u;break}if(c+=u,e?c<0:s<=c)throw TypeError("Reduce of empty array with no initial value")}for(;e?c>=0:s>c;c+=u)c in o&&(i=n(i,o[c],c,a));return i}},vl={left:_l(!1),right:_l(!0)}.left,pl=We("reduce"),ml=Ze("reduce",{1:0});Oe({target:"Array",proto:!0,forced:!pl||!ml||!fi&&Or>79&&Or<83},{reduce:function(e){return vl(this,e,arguments.length,arguments.length>1?arguments[1]:void 0)}});var yl,gl,El,kl,Rl,Cl,Il=function(e){Zn(n,e);var t=ir(n);function n(e,r){var i;return Hn(this,n),Kn(rr(i=t.call(this)),"hasVideoPermission",!1),i._streamManger=e,i.constraints=r,i}return Wn(n,[{key:"dispose",value:function(){var e;this.removeAllEventListeners(),null===(e=this.onDisposed)||void 0===e||e.call(this)}},{key:"streamChanged",value:function(e){this._dispatchEvent("streamChanged",e)}},{key:"audioOutputChanged",value:function(){this._dispatchEvent("audioOutputChanged")}},{key:"stream",get:function(){return this._streamManger.stream}}]),n}(Yo),wl=function(e,t){t.audio&&0===e.getAudioTracks().length&&e.addTrack(function(){yl||(yl=new(window.AudioContext||window.webkitAudioContext));var e=yl;gl=e.createOscillator();var t=e.createMediaStreamDestination(),n=e.createGain();return n.gain.setValueAtTime(0,e.currentTime),gl.connect(n).connect(t),gl.start(),Rl=t.stream.getAudioTracks()[0],t.stream.getAudioTracks()[0]}()),t.video&&0===e.getVideoTracks().length&&e.addTrack(function(e){var t=e.width,n=e.height,r=e.frameRate;El||(El=document.createElement("canvas")),El.width=t,El.height=n,El.getContext("2d").fillRect(0,0,t,n),kl||(kl=setInterval((function(){El.getContext("2d").fillRect(0,0,t,n)}),1e3));var i=El.captureStream(r);return Cl=i.getVideoTracks()[0],i.getVideoTracks()[0]}(Qn(Qn({},cl.value),{},{frameRate:24})))};function Al(){Rl&&Rl.stop(),Cl&&Cl.stop(),Rl=null,Cl=null,kl&&(clearInterval(kl),kl=null),gl&&(gl.onended=function(){gl.disconnect(),gl=null},gl.stop())}function bl(e){if(e){var t,n=fr(e.getTracks());try{for(n.s();!(t=n.n()).done;){t.value.stop()}}catch(e){n.e(e)}finally{n.f()}}}var Tl=function(){function e(t){Hn(this,e),this._deviceManager=t,this._updateQueued=!1}var t,n;return Wn(e,[{key:"_getUserMedia",value:(n=qn(regeneratorRuntime.mark((function e(t){var n,r,i,a;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,navigator.mediaDevices.getUserMedia(t);case 3:return n=e.sent,Al(),e.abrupt("return",n);case 8:return e.prev=8,e.t0=e.catch(0),fo.warning("Failed to first 'getUserMedia()' call Error[".concat(e.t0,"]")),r=new MediaStream,e.prev=12,e.next=15,navigator.mediaDevices.getUserMedia({audio:t.audio});case 15:i=e.sent,r.addTrack(i.getAudioTracks()[0]),e.next=22;break;case 19:e.prev=19,e.t1=e.catch(12),fo.warning("Failed to get local audio stream Error[".concat(e.t1,"]"));case 22:return e.prev=22,e.next=25,navigator.mediaDevices.getUserMedia({video:t.video});case 25:a=e.sent,r.addTrack(a.getVideoTracks()[0]),e.next=32;break;case 29:e.prev=29,e.t2=e.catch(22),fo.warning("Failed to get local video stream Error[".concat(e.t2,"]"));case 32:return e.abrupt("return",r);case 33:case"end":return e.stop()}}),e,null,[[0,8],[12,19],[22,29]])}))),function(e){return n.apply(this,arguments)})},{key:"updateStream",value:(t=qn(regeneratorRuntime.mark((function e(){var t,n,r,i,a,o,s,c,u,l;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._updateAt){e.next=3;break}return this._updateQueued=!0,e.abrupt("return");case 3:if(t=this._deviceManager.mediaAccesses.some((function(e){return e.constraints.audio})),n=this._deviceManager.mediaAccesses.some((function(e){return e.constraints.video})),t||n){e.next=9;break}return bl(this.stream),Al(),e.abrupt("return");case 9:return this._updateAt=Date.now(),(r=this.stream)||(i=new MediaStream,wl(i,{audio:t,video:n}),this.stream=i),so&&bl(r),e.next=15,this._deviceManager.getMediaConstraints({usingAudio:t,usingVideo:n});case 15:return a=e.sent,e.next=18,this._getUserMedia(a);case 18:if((o=e.sent).getVideoTracks().length>0){s=fr(this._deviceManager.mediaAccesses);try{for(s.s();!(c=s.n()).done;)c.value.hasVideoPermission=!0}catch(e){s.e(e)}finally{s.f()}}wl(o,{audio:t,video:n}),so||bl(r),this.stream=o,u=fr(this._deviceManager.mediaAccesses);try{for(u.s();!(l=u.n()).done;)l.value.streamChanged(this.stream)}catch(e){u.e(e)}finally{u.f()}delete this._updateAt,this._updateQueued?(this._updateQueued=!1,this.updateStream()):this._deviceManager.refreshMediaDevices({audio:t,video:n},!0);case 27:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})}]),e}();function Sl(e,t){return(null==e?void 0:e.deviceId)===(null==t?void 0:t.deviceId)&&(null==e?void 0:e.label)===(null==t?void 0:t.label)&&(null==e?void 0:e.groupId)===(null==t?void 0:t.groupId)}var Ol,Dl=function(){function e(){var t=this;Hn(this,e),this.mediaAccesses=[],this._availableMediaDevices={audioinput:[],audiooutput:[],videoinput:[]},this._currentMediaDevices={audioinput:void 0,audiooutput:void 0,videoinput:void 0},this._sendbirdCallListeners=new Map,this._streamManager=new Tl(this),navigator.mediaDevices.ondevicechange=function(){return t._onDeviceChanged()}}var t,n,r,i;return Wn(e,[{key:"_onDeviceChanged",value:function(){0!==this.mediaAccesses.length&&this.refreshMediaDevices({audio:this.mediaAccesses.some((function(e){return e.constraints.audio})),video:this.mediaAccesses.some((function(e){return e.constraints.video}))})}},{key:"addSendBirdCallListener",value:function(e,t){this._sendbirdCallListeners.set(e,t)}},{key:"removeSendBirdCallListener",value:function(e){this._sendbirdCallListeners.delete(e)}},{key:"removeAllSendBirdCallListener",value:function(){this._sendbirdCallListeners.clear()}},{key:"getCurrentAudioInputDevice",value:function(){return this._currentMediaDevices.audioinput}},{key:"getCurrentAudioOutputDevice",value:function(){return this._currentMediaDevices.audiooutput}},{key:"getCurrentVideoInputDevice",value:function(){return this._currentMediaDevices.videoinput}},{key:"getAvailableAudioInputDevices",value:function(){return this._availableMediaDevices.audioinput}},{key:"getAvailableAudioOutputDevices",value:function(){return this._availableMediaDevices.audiooutput}},{key:"getAvailableVideoInputDevices",value:function(){return this._availableMediaDevices.videoinput}},{key:"updateStream",value:(i=qn(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this._streamManager.updateStream());case 1:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"_registerMediaAccess",value:function(e){var t=this;this.mediaAccesses.push(e),e.onDisposed=function(){return t.stopMedia(e)}}},{key:"useMedia",value:function(e){if(e.audio||e.video){var t=new Il(this._streamManager,e);return this._registerMediaAccess(t),this.updateStream(),t}fo.error(new Error("you should set true for at least 1 media type."))}},{key:"stopMedia",value:function(e){this.mediaAccesses.splice(this.mediaAccesses.indexOf(e),1),this.updateStream()}},{key:"fetchMediaDevices",value:(r=qn(regeneratorRuntime.mark((function e(){var t;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,navigator.mediaDevices.enumerateDevices();case 2:return t=e.sent,e.abrupt("return",t.reduce((function(e,t){return e[t.kind].push(t),e}),{audioinput:[],audiooutput:[],videoinput:[]}));case 4:case"end":return e.stop()}}),e)}))),function(){return r.apply(this,arguments)})},{key:"getMediaConstraints",value:(n=qn(regeneratorRuntime.mark((function e(t){var n,r,i,a,o,s,c,u;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t.usingAudio,r=t.usingVideo,i={audio:!1,video:!1},e.next=4,this.fetchMediaDevices();case 4:return a=e.sent,o=a.audioinput,s=a.videoinput,n&&o.length&&(c=this.getCurrentAudioInputDevice(),i.audio={deviceId:null==c?void 0:c.deviceId}),r&&s.length&&(u=this.getCurrentVideoInputDevice(),i.video=Qn(Qn({deviceId:null==u?void 0:u.deviceId},cl.value),{},{frameRate:24})),e.abrupt("return",i);case 10:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"_updateCurrentMediaDevice",value:function(e,t){var n,r=this._availableMediaDevices[e],i=this._currentMediaDevices[e],a=r.find((function(e){return e.deviceId===(null==t?void 0:t.deviceId)}));a||(fo.warning("Selected device is unavailable. fallback to default device."),a=(null!==(n=a)&&void 0!==n?n:r.length>0)?r[0]:null);return this._currentMediaDevices[e]=a,!Sl(i,a)}},{key:"_onAudioOutputChanged",value:function(){var e,t=fr(this.mediaAccesses);try{for(t.s();!(e=t.n()).done;){var n=e.value;n.constraints.audio&&n.audioOutputChanged()}}catch(e){t.e(e)}finally{t.f()}}},{key:"selectDevice",value:function(e,t){t.kind===e?this._updateCurrentMediaDevice(e,t)&&("audioinput"!==e&&"videoinput"!==e||this.updateStream(),"audiooutput"===e&&this._onAudioOutputChanged()):fo.error(new Error("Tried to select invalid device of type"))}},{key:"_updateAvailableDevices",value:function(e,t){var n,r,i,a=this._currentMediaDevices[e],o=!function(e,t){if(e.length!==t.length)return!1;for(var n=0;n1&&void 0!==d[1]&&d[1],n||r){e.next=4;break}throw new Error("at least one of the audio or video must be true");case 4:return e.next=6,this.fetchMediaDevices();case 6:a=e.sent,o=a.audioinput,s=a.audiooutput,c=a.videoinput,u=!1,l=!1,n&&(u=this._updateAvailableDevices("audioinput",o),l=this._updateAvailableDevices("audiooutput",s)),r&&(u=this._updateAvailableDevices("videoinput",c)||u),!i&&u&&this.updateStream(),l&&this._onAudioOutputChanged();case 16:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})}]),e}(),Nl=function(){function e(t,n,r){var i=this;Hn(this,e),this._ctx=t,Object.assign(this,n),this._localStream=r,this._localStream.on("audioOutputChanged",(function(){i._onAudioOutputChanged()}))}var t,n,r;return Wn(e,[{key:"id",get:function(){return this.participantId}}]),Wn(e,[{key:"updateInfo",value:function(e){var t=this,n=new Map;return Object.keys(e).forEach((function(r){t[r]!==e[r]&&n.set(r,e[r])})),Object.assign(this,e),n}},{key:"setMediaView",value:(r=qn(regeneratorRuntime.mark((function e(t){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._mediaView!==t){e.next=2;break}return e.abrupt("return");case 2:if(this._mediaView&&(this._mediaView.srcObject=null),t){e.next=6;break}return delete this._mediaView,e.abrupt("return");case 6:return e.next=8,this._updateMediaViewStream(t,this.stream);case 8:this._mediaView=e.sent;case 9:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"_updateMediaViewStream",value:(n=qn(regeneratorRuntime.mark((function e(t,n){var r,i;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(r=this._ctx.deviceManager.getCurrentAudioOutputDevice())){e.next=4;break}return e.next=4,null===(i=t.setSinkId)||void 0===i?void 0:i.call(t,r.deviceId);case 4:return n&&(t.srcObject=n),e.abrupt("return",t);case 6:case"end":return e.stop()}}),e,this)}))),function(e,t){return n.apply(this,arguments)})},{key:"_onAudioOutputChanged",value:(t=qn(regeneratorRuntime.mark((function e(){var t,n,r;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._ctx.roomType!==xl.SMALL_ROOM_FOR_VIDEO&&this._ctx.roomType!==xl.SMALL_ROOM_FOR_AUDIO_ONLY){e.next=4;break}return r=this._ctx.deviceManager.getCurrentAudioOutputDevice(),e.next=4,null===(t=this._mediaView)||void 0===t||null===(n=t.setSinkId)||void 0===n?void 0:n.call(t,r.deviceId);case 4:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})}]),e}(),Ll=function(e){Zn(r,e);var t,n=ir(r);function r(e,t,i){var a;return Hn(this,r),Kn(rr(a=n.call(this,e,t,i)),"isLocalParticipant",!0),Kn(rr(a),"_resolution",sl._720P),a._localStream.on("streamChanged",(function(e){return a._onStream(e)})),a}return Wn(r,[{key:"stream",get:function(){var e;return null===(e=this._localStream)||void 0===e?void 0:e.localStream}},{key:"localStream",get:function(){return this._localStream}},{key:"masterEndpoint",get:function(){return this._masterEndpoint},set:function(e){this._masterEndpoint=e}}]),Wn(r,[{key:"exit",value:function(){this._release()}},{key:"setLocalMediaView",value:(t=qn(regeneratorRuntime.mark((function e(t){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.setMediaView(t));case 1:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})},{key:"muteMicrophone",value:function(){fo.info("muteMicrophone()"),this._toggleAudio(!1)}},{key:"unmuteMicrophone",value:function(){fo.info("unmuteMicrophone()"),this._toggleAudio(!0)}},{key:"startVideo",value:function(){fo.info("startVideo()"),this._toggleVideo(!0)}},{key:"stopVideo",value:function(){fo.info("stopVideo()"),this._toggleVideo(!1)}},{key:"updateResolution",value:function(e){this._resolution.equals(e)||(this._resolution=e,this._applyConstraints())}},{key:"_toggleAudio",value:function(e){this.isAudioEnabled!==e&&(this.stream.getAudioTracks().forEach((function(t){t.enabled=e})),this.isAudioEnabled=e,this._sendAudioCommand(e).catch((function(e){return fo.debug(e)})))}},{key:"_toggleVideo",value:function(e){this.isVideoEnabled!==e&&(this.stream.getVideoTracks().forEach((function(t){t.enabled=e})),this.isVideoEnabled=e,this._sendVideoCommand(e).catch((function(e){return fo.debug(e)})))}},{key:"_isMediaEnabled",value:function(e){switch(e){case"audio":return this.isAudioEnabled;case"video":return this.isVideoEnabled;default:return fo.error(new Error("unrecognized media type ".concat(e))),!1}}},{key:"_applyConstraints",value:function(){var e;if(fo.debug("_applyConstraints()"),this.stream&&null!==(e=this._localStream)&&void 0!==e&&e.hasVideoPermission){var t,n=fr(this.stream.getVideoTracks());try{for(n.s();!(t=n.n()).done;){var r=t.value,i=void 0;i=this._resolution.equals(sl._360P)&&co?{height:this._resolution.value.height}:this._resolution.value,r.applyConstraints(i).catch((function(e){return fo.error("Fail change local video resolution error = ",e)}))}}catch(e){n.e(e)}finally{n.f()}}}},{key:"_onStream",value:function(e){var t,n=fr(e.getTracks());try{for(n.s();!(t=n.n()).done;){var r=t.value;r.enabled=this._isMediaEnabled(r.kind)}}catch(e){n.e(e)}finally{n.f()}this._applyConstraints(),this._mediaView&&(this._mediaView.srcObject=e)}},{key:"_release",value:function(){this._localStream.release(),delete this._localStream}},{key:"_sendAudioCommand",value:function(e){var t=bc.createAudio(this._ctx.roomId,this.id,e);return this._ctx.sender.send(t)}},{key:"_sendVideoCommand",value:function(e){var t=bc.createVideo(this._ctx.roomId,this.id,e);return this._ctx.sender.send(t)}}]),r}(Nl),Pl=function(e){Zn(n,e);var t=ir(n);function n(){var e;Hn(this,n);for(var r=arguments.length,i=new Array(r),a=0;a=8||t.code===Ln.ERR_INVALID_ROOM_PARTICIPANT)&&e._dispatchEvent("aliveFailed")):e._dispatchEvent("deleted"))}))}),5e3),this._ctx.roomType){case"small_room_for_video":this._participantManager=new Ml(this._ctx,this._participantCollection);break;case"large_room_for_audio_only":this._participantManager=new Ul(this._ctx,this._participantCollection);break;default:throw new Error("Unsupported room type : ".concat(this._ctx.roomType))}this._registerEventListeners(),this._participantManager.onSelfEntered()}},{key:"exit",value:function(){clearInterval(this._keepAliveInterval),delete this._keepAliveInterval,this._participantManager.removeAllEventListeners(),this._participantManager.exit()}},{key:"setAudioForLargeRoom",value:(t=qn(regeneratorRuntime.mark((function e(t){var n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(fo.info("setAudioForLargeRoom()"),"large_room_for_audio_only"===this._ctx.roomType){e.next=5;break}throw n=new Error("Room type not audio mcu"),fo.error(n),n;case 5:return e.abrupt("return",this._participantManager.setMediaView(t));case 6:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})},{key:"_sendAlive",value:function(){var e=bc.createAlive(this._ctx.roomId,this._localParticipant.id);return this._ctx.sender.send(e)}},{key:"_registerEventListeners",value:function(){var e=this;this._participantManager.on("remoteParticipantStream",(function(t){e._dispatchEvent("remoteParticipantStream",t)})),this._participantManager.on("localParticipantConnected",(function(t,n){e._dispatchEvent("localParticipantConnected",t,n)})),this._participantManager.on("localParticipantDisconnected",(function(t){e._dispatchEvent("localParticipantDisconnected",t)}))}},{key:"_localParticipant",get:function(){return this._participantCollection.localParticipant}}]),r}(Yo),Fl=function(e){Zn(r,e);var t,n=ir(r);function r(){return Hn(this,r),n.call(this)}return Wn(r,[{key:"startStream",value:(t=qn(regeneratorRuntime.mark((function e(){var t,n,r=this;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,navigator.mediaDevices.getDisplayMedia({video:!0});case 3:t=e.sent,this._stream=t,this._stream.getVideoTracks()[0].onended=function(){r._releaseStream(),r._dispatchEvent("streamStopped")},e.next=23;break;case 8:e.prev=8,e.t0=e.catch(0),e.t1=e.t0.name,e.next="InvalidStateError"===e.t1?13:"NotAllowedError"===e.t1?15:"NotFoundError"===e.t1?17:"NotReadableError"===e.t1?19:21;break;case 13:return n=Ln.ERR_NOT_SUPPORTED_APP_STATE_FOR_SCREEN_SHARE,e.abrupt("break",22);case 15:return n=Ln.ERR_PERMISSION_DENIED_FOR_SCREEN_SHARE,e.abrupt("break",22);case 17:return n=Ln.ERR_SELECTED_CONTENT_NOT_EXIST,e.abrupt("break",22);case 19:return n=Ln.ERR_SELECTED_CONTENT_INACCESSIBLE,e.abrupt("break",22);case 21:n=Ln.ERR_SCREEN_SHARE_FAILED_DUE_TO_UNKNOWN_REASON;case 22:throw new Ja(n);case 23:case"end":return e.stop()}}),e,this,[[0,8]])}))),function(){return t.apply(this,arguments)})},{key:"stopStream",value:function(){this._releaseStream(),this._dispatchEvent("streamStopped")}},{key:"_releaseStream",value:function(){if(this._stream){var e,t=fr(this._stream.getTracks());try{for(t.s();!(e=t.n()).done;){e.value.stop()}}catch(e){t.e(e)}finally{t.f()}delete this._stream}}},{key:"stream",get:function(){return this._stream}},{key:"isSharing",get:function(){return!!this._stream}}]),r}(Yo),Gl=function(e){Zn(r,e);var t,n=ir(r);function r(e){var t,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{audio:!0,video:!0};return Hn(this,r),(t=n.call(this))._deviceManager=e,t._mediaConstraints=i,t._screenShare=new Fl,t._screenShare.on("streamStopped",(function(){t._releaseMergedStream(),t._dispatchEvent("screenShareStreamStopped")})),t}return Wn(r,[{key:"useScreenStream",value:(t=qn(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return _o(),e.next=3,this._screenShare.startStream();case 3:this._mergeScreenShareStream(),this._dispatchEvent("streamChanged",this.localStream);case 5:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"getLocalMediaStream",value:function(){return this._mediaAccess||this._grantMediaAccess(this._mediaConstraints),this._mediaAccess.stream}},{key:"stopScreenShare",value:function(){this._screenShare.isSharing&&this._screenShare.stopStream()}},{key:"revokeMediaAccess",value:function(){this._mediaAccess&&(this._mediaAccess.dispose(),this._mediaAccess=null)}},{key:"release",value:function(){this.stopScreenShare(),this.revokeMediaAccess()}},{key:"_grantMediaAccess",value:function(e){var t=this;this._mediaAccess=this._deviceManager.useMedia(e),this._mediaAccess.on("streamChanged",(function(){t._screenShare.isSharing&&t._mergeScreenShareStream(),t._dispatchEvent("streamChanged",t.localStream)})),this._mediaAccess.on("audioOutputChanged",(function(){return t._dispatchEvent("audioOutputChanged")}))}},{key:"_mergeScreenShareStream",value:function(){if(this._screenShare.isSharing){var e=new MediaStream;this._mediaAccess.stream&&this._mediaAccess.stream.getAudioTracks().length>0&&e.addTrack(this._mediaAccess.stream.getAudioTracks()[0]),e.addTrack(this.screenStream.getVideoTracks()[0]),this._mergedStream=e}}},{key:"_releaseMergedStream",value:function(){this._mergedStream&&(this._mergedStream.removeTrack(this._mergedStream.getAudioTracks()[0]),delete this._mergedStream,this._dispatchEvent("streamChanged",this.localStream))}},{key:"mediaConstraints",set:function(e){this._mediaConstraints=e}},{key:"hasVideoPermission",get:function(){var e;return null===(e=this._mediaAccess)||void 0===e?void 0:e.hasVideoPermission}},{key:"localStream",get:function(){return this.isScreenSharing?this._mergedStream:this.getLocalMediaStream()}},{key:"mergedStream",get:function(){return this._mergedStream}},{key:"screenStream",get:function(){return this._screenShare.stream}},{key:"isScreenSharing",get:function(){return this._screenShare.isSharing}}]),r}(Yo),Bl=function(e){Zn(n,e);var t=ir(n);function n(e){var r,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];return Hn(this,n),Kn(rr(r=t.call(this)),"_remoteParticipants",[]),r._ctx=e,r.initialize(i),r}return Wn(n,[{key:"_getMediaConstraints",value:function(){switch(this._ctx.roomType){case"large_room_for_audio_only":case"small_room_for_audio_only":return{audio:!0,video:!1};default:return{audio:!0,video:!0}}}},{key:"findRemoteById",value:function(e){return this._remoteParticipants.find((function(t){return t.participantId===e}))}},{key:"initialize",value:function(e){var t=this;fo.debug("initialize()",e),this._localStream=new Gl(this._ctx.deviceManager),this._localStream.mediaConstraints=this._getMediaConstraints(),e.forEach((function(e){e.isLocalParticipant?t._localParticipant=new Ll(t._ctx,e,t._localStream):t._remoteParticipants.push(new Pl(t._ctx,e,t._localStream))}))}},{key:"updateInfo",value:function(e){fo.debug("updateInfo()",e),this._stampLocalParticipant(e);var t=e.filter((function(e){return e.isLocalParticipant}))[0],n=e.filter((function(e){return!e.isLocalParticipant}));t&&this._upsertLocalParticipantInfo(t),this._updateRemoteParticipantsInfo(n)}},{key:"exit",value:function(){fo.debug("exit()"),this._localParticipant.exit(),delete this._localParticipant}},{key:"onEvent",value:function(e){switch(e.type){case es.PARTICIPANT_ENTERED:this._onEntered(e.payload.participant);break;case es.PARTICIPANT_CONNECTED:this._onConnected(e.payload.participant);break;case es.PARTICIPANT_EXITED:this._onExited(e.payload.participant);break;case es.PARTICIPANT_DISCONNECTED:this._onDisconnected(e.payload.participant,e.payload.reason);break;case es.PARTICIPANT_AUDIO_STATUS_CHANGED:this._onAudioSettingsChanged(e.payload.participant);break;case es.PARTICIPANT_VIDEO_STATUS_CHANGED:this._onVideoSettingsChanged(e.payload.participant)}}},{key:"_upsertLocalParticipantInfo",value:function(e){fo.debug("_upsertLocalParticipantInfo()"),this._localParticipant?this._localParticipant.updateInfo(e):this._localParticipant=new Ll(this._ctx,e,this._localStream)}},{key:"_updateRemoteParticipantsInfo",value:function(e){var t=this;fo.debug("_updateRemoteParticipantsInfo()"),e.forEach((function(e){return t._upsertParticipantInfo(e)})),this._remoteParticipants.filter((function(t){return!e.some((function(e){return e.participantId===t.id}))})).forEach((function(e){t._deleteParticipantInfo(e)}))}},{key:"_upsertParticipantInfo",value:function(e){fo.debug("_upsertParticipantInfo()");var t=this._updateParticipantInfo(e);return t||this._insertParticipantInfo(e)}},{key:"_insertParticipantInfo",value:function(e){fo.debug("_insertParticipantInfo()");var t=new Pl(this._ctx,e,this._localStream);return this._dispatchEventIfOnCall("entered",t),"connected"===t.state&&this._dispatchEventIfOnCall("connected",t),this._remoteParticipants.push(t),t}},{key:"_updateParticipantInfo",value:function(e){fo.debug("_updateParticipantInfo()");var t=this.findRemoteById(e.participantId);if(!t)return!1;var n,r=fr(t.updateInfo(e).entries());try{for(r.s();!(n=r.n()).done;){var i=or(n.value,2),a=i[0],o=i[1];switch(a){case"isAudioEnabled":this._dispatchEventIfOnCall("audioSettingsChanged",t);break;case"isVideoEnabled":this._dispatchEventIfOnCall("videoSettingsChanged",t);break;case"state":"connected"===o&&this._dispatchEventIfOnCall("connected",t);break;default:fo.debug("_updateParticipantInfo() => Ignore diff\nkey : ",a,"\nvalue : ",o)}}}catch(e){r.e(e)}finally{r.f()}return t}},{key:"_deleteParticipantInfo",value:function(e){fo.debug("_deleteParticipantInfo()");var t=this.findRemoteById(e.participantId);if(t){var n=this._remoteParticipants.indexOf(t);this._remoteParticipants.splice(n,1),this._dispatchEventIfOnCall("exited",t)}}},{key:"_stampLocalParticipant",value:function(e){var t=this;this._localParticipant&&(e.find((function(e){return e.participantId===t._localParticipant.participantId})).isLocalParticipant=!0)}},{key:"_onEntered",value:function(e){fo.debug("_onEntered()"),this._upsertParticipantInfo(e)}},{key:"_onConnected",value:function(e){fo.debug("_onConnected()"),this._upsertParticipantInfo(e)}},{key:"_onExited",value:function(e){fo.debug("_onExited()"),this._deleteParticipantInfo(e)}},{key:"_onDisconnected",value:function(e,t){fo.debug("_onDisconnected()"),this._localParticipant.participantId===e.participantId?this._dispatchEvent("selfDisconnected",t):this._deleteParticipantInfo(e)}},{key:"_onAudioSettingsChanged",value:function(e){fo.debug("_onAudioSettingsChanged()"),this._upsertParticipantInfo(e)}},{key:"_onVideoSettingsChanged",value:function(e){fo.debug("_onVideoSettingsChanged()"),this._upsertParticipantInfo(e)}},{key:"_dispatchEventIfOnCall",value:function(e){if(this._isOnCall){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;rthis._customItemsUpdatedAt&&(this._customItemsUpdatedAt=t,this.customItems=e||{},!0)}},{key:"_processEvent",value:function(e){switch(e.type){case es.CUSTOM_ITEMS_UPDATE:this._updateCustomItems(e);break;case es.CUSTOM_ITEMS_DELETE:this._deleteCustomItems(e);break;case es.ROOM_DELETED:this._dispatchEvent("deleted"),this._teardown();break;case es.INVITATION_DECLINED:this._dispatchEvent("invitationDeclined",new jl({sender:this._ctx.sender,room:this,inviter:e.payload.inviter,invitee:e.payload.invitee}));break;case es.INVITATION_ACCEPTED:this._dispatchEvent("invitationAccepted",new jl({sender:this._ctx.sender,room:this,inviter:e.payload.inviter,invitee:e.payload.invitee}));break;case es.INVITATION_CANCELED:this._dispatchEvent("invitationCanceled",new jl({sender:this._ctx.sender,room:this,inviter:e.payload.inviter,invitee:e.payload.invitee}));break;case es.PARTICIPANT_ENTERED:case es.PARTICIPANT_CONNECTED:case es.PARTICIPANT_EXITED:case es.PARTICIPANT_DISCONNECTED:case es.PARTICIPANT_AUDIO_STATUS_CHANGED:case es.PARTICIPANT_VIDEO_STATUS_CHANGED:this._passToCollection(e)}}},{key:"enter",value:(i=qn(regeneratorRuntime.mark((function e(t){var n,r;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(fo.info("enter()"),!this._session){e.next=5;break}throw n=new Ja(Ln.ERR_CLIENT_ALREADY_ENTERED),fo.debug(n),n;case 5:return e.next=7,this._enterLock.acquire();case 7:return e.prev=7,e.next=10,this._sendEnter(t);case 10:r=e.sent,e.next=18;break;case 13:throw e.prev=13,e.t0=e.catch(7),this._enterLock.release(),fo.error(e.t0),e.t0;case 18:this.updateInfo(r.payload.room),this._session=new Vl(this._ctx,this._participantCollection),this._registerSessionEventListeners(),this._session.onEntered(),this._enterLock.release();case 23:case"end":return e.stop()}}),e,this,[[7,13]])}))),function(e){return i.apply(this,arguments)})},{key:"exit",value:function(){fo.info("exit()"),this._validateEntered();var e=this.localParticipant.id;this._teardown(),this._sendExit(e).catch((function(e){fo.error("_sendExit() failed : ",e)}))}},{key:"setAudioForLargeRoom",value:(r=qn(regeneratorRuntime.mark((function e(t){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return fo.info("setAudioForLargeRoom()"),this._validateEntered(),e.abrupt("return",this._session.setAudioForLargeRoom(t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"sendInvitation",value:(n=qn(regeneratorRuntime.mark((function e(t){var n,r;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=bc.createSendInvitation(this.roomId,t),e.next=3,this._ctx.sender.send(n);case 3:return r=e.sent,e.abrupt("return",new jl({sender:this._ctx.sender,room:this,inviter:r.payload.inviter,invitee:r.payload.invitee}));case 5:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"delete",value:(t=qn(regeneratorRuntime.mark((function e(){var t;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._sendDelete(this.roomId);case 2:t=e.sent,this.updateInfo(t.payload.room),this._dispatchEvent("deleted");case 5:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"_validateEntered",value:function(){if(!this._session){var e=new Ja(Ln.ERR_PARTICIPANT_NOT_IN_ROOM);throw fo.debug(e),e}}},{key:"_registerSessionEventListeners",value:function(){var e=this;this._session.on("remoteParticipantStream",(function(t){e._dispatchEvent("remoteParticipantStreamStarted",t)})),this._session.on("localParticipantConnected",(function(t,n){n&&e._dispatchEvent("localParticipantReconnected",t)})),this._session.on("localParticipantDisconnected",(function(t){e._dispatchEvent("localParticipantDisconnected",t)})),this._session.on("aliveFailed",(function(){e._dispatchEvent("error",new Ja(Ln.ERR_LOCAL_PARTICIPANT_LOST_CONNECTION)),e._teardown()})),this._session.on("deleted",(function(){e._dispatchEvent("deleted"),e._teardown()}))}},{key:"_registerCollectionEventListeners",value:function(){var e=this;this._participantCollection.on("entered",(function(t){e._dispatchEvent("remoteParticipantEntered",t)})),this._participantCollection.on("connected",(function(t){e._dispatchEvent("remoteParticipantConnected",t)})),this._participantCollection.on("exited",(function(t){e._dispatchEvent("remoteParticipantExited",t)})),this._participantCollection.on("audioSettingsChanged",(function(t){e._dispatchEvent("remoteAudioSettingsChanged",t)})),this._participantCollection.on("videoSettingsChanged",(function(t){e._dispatchEvent("remoteVideoSettingsChanged",t)})),this._participantCollection.on("selfDisconnected",(function(t){if(e._teardown(),"sibling_kicked"===t)e._dispatchEvent("error",new Ja(Ln.ERR_LOCAL_PARTICIPANT_KICKED_OUT));else e._dispatchEvent("error",new Ja(Ln.ERR_LOCAL_PARTICIPANT_LOST_CONNECTION))}))}},{key:"_updateCustomItems",value:function(e){var t=e.payload,n=t.customItems,r=t.updated,i=t.affectedAt;this._setCustomItems(n,i)&&this._dispatchEvent("customItemsUpdated",n,r)}},{key:"_deleteCustomItems",value:function(e){var t=e.payload,n=t.customItems,r=t.deleted,i=t.affectedAt;this._setCustomItems(n,i)&&this._dispatchEvent("customItemsDeleted",n,r)}},{key:"_passToCollection",value:function(e){this._participantCollection.onEvent(e)}},{key:"_sendEnter",value:function(e){var t=bc.createEnter(this._ctx.roomId,e);return this._ctx.sender.send(t)}},{key:"_sendExit",value:function(e){var t=bc.createExit(this._ctx.roomId,e);return this._ctx.sender.send(t)}},{key:"_sendDelete",value:function(e){var t=bc.createDeleteRoom(e);return this._ctx.sender.send(t)}},{key:"_teardown",value:function(){this._session.removeAllEventListeners(),this._session.exit(),this._participantCollection.exit(),delete this._session}},{key:"participants",get:function(){return this._participantCollection.participants}},{key:"localParticipant",get:function(){return this._participantCollection.localParticipant}},{key:"remoteParticipants",get:function(){return this._participantCollection.remoteParticipants}},{key:"isOnCall",get:function(){return!!this._session}}]),o}(Yo);!function(e){e.OPEN="open",e.DELETED="deleted"}(ql||(ql={}));var zl,Wl=function(){function e(t){Hn(this,e),this._ctx=t}return Wn(e,[{key:"createRoom",value:function(e){return new Hl(this._ctx,e)}}]),e}(),Kl=function(){function e(t){Hn(this,e),this._ctx=t,this._factory=new Wl(t),this._rooms=new Map,this._sendbirdCallListeners=new Map}var t,n,r;return Wn(e,[{key:"_hasRoom",value:function(e){return this._rooms.has(e)}},{key:"onEvent",value:function(e){switch(e.type){case es.INVITATION_SENT:this._onInvitation(e);break;case es.CUSTOM_ITEMS_UPDATE:case es.CUSTOM_ITEMS_DELETE:case es.ROOM_DELETED:case es.PARTICIPANT_CONNECTED:case es.PARTICIPANT_ENTERED:case es.PARTICIPANT_EXITED:case es.PARTICIPANT_DISCONNECTED:case es.PARTICIPANT_AUDIO_STATUS_CHANGED:case es.PARTICIPANT_VIDEO_STATUS_CHANGED:case es.INVITATION_CANCELED:case es.INVITATION_ACCEPTED:case es.INVITATION_DECLINED:this._passToRoom(e);break;default:fo.error(new Error("unhandled room event ".concat(e.type)))}}},{key:"addListener",value:function(e,t){this._sendbirdCallListeners.set(e,t)}},{key:"removeListener",value:function(e){this._sendbirdCallListeners.delete(e)}},{key:"removeAllListeners",value:function(){this._sendbirdCallListeners.clear()}},{key:"_onInvitation",value:function(e){var t;this._sendInvitationReceiveCommand(e),(t=this._rooms.get(e.payload.room.roomId))||(t=this._factory.createRoom(e.payload.room),this._rooms.set(t.roomId,t));var n,r=new jl({sender:this._ctx.sender,room:t,inviter:e.payload.inviter,invitee:e.payload.invitee}),i=fr(this._sendbirdCallListeners.values());try{for(i.s();!(n=i.n()).done;){var a,o=n.value;null===(a=o.onInvitationReceived)||void 0===a||a.call(o,r)}}catch(e){i.e(e)}finally{i.f()}}},{key:"_sendInvitationReceiveCommand",value:function(e){var t=bc.createInvitationReceive(e.payload.room.roomId,e.payload.inviter.userId,e.payload.shortLivedToken);return this._ctx.sender.send(t).catch((function(){}))}},{key:"_passToRoom",value:function(e){this._hasRoom(e.getRoomId())?this._rooms.get(e.getRoomId()).onEvent(e):fo.debug("received command ".concat(e.type," for non-existing room ").concat(e.getRoomId()))}},{key:"createRoom",value:(r=qn(regeneratorRuntime.mark((function e(t){var n,r;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._sendCreate(t);case 2:return n=e.sent,r=this._factory.createRoom(n.payload.room),this._rooms.set(r.roomId,r),e.abrupt("return",r);case 6:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"deserializeRoom",value:(n=qn(regeneratorRuntime.mark((function e(t){var n,r,i;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=t.roomId,!(r=this._rooms.get(n))){e.next=5;break}return r.updateInfo(t),e.abrupt("return",r);case 5:return i=this._factory.createRoom(t),this._rooms.set(i.roomId,i),e.abrupt("return",i);case 8:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"getCachedRoomById",value:function(e){return this._rooms.get(e)}},{key:"fetchRoomById",value:(t=qn(regeneratorRuntime.mark((function e(t){var n,r,i;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._sendGetRoom(t);case 2:if(n=e.sent,!(r=this._rooms.get(t))){e.next=7;break}return r.updateInfo(n.payload.room),e.abrupt("return",r);case 7:return i=this._factory.createRoom(n.payload.room),this._rooms.set(i.roomId,i),e.abrupt("return",i);case 10:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})},{key:"_sendCreate",value:function(e){var t=bc.createCreate(e);return this._ctx.sender.send(t)}},{key:"_sendGetRoom",value:function(e){var t=bc.createGet(e);return this._ctx.sender.send(t)}},{key:"clear",value:function(){var e,t=fr(this._rooms.values());try{for(t.s();!(e=t.n()).done;){var n=e.value;n.isOnCall&&n.exit()}}catch(e){t.e(e)}finally{t.f()}this._rooms.clear()}}]),e}();!function(e){e.DIALING="DIALING",e.RINGING="RINGING",e.RECONNECTING="RECONNECTING",e.RECONNECTED="RECONNECTED"}(zl||(zl={}));var Yl,Ql,Zl,Xl=function(){function e(){Hn(this,e),this.audioElms=new Map}var t,n;return Wn(e,[{key:"loadSound",value:(n=qn(regeneratorRuntime.mark((function e(t,n){var r;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("string"==typeof n&&n){e.next=2;break}return e.abrupt("return",!1);case 2:return(r=this._createAudio(t)).src=n,r.volume=0,e.prev=5,e.next=8,r.play();case 8:r.pause(),r.currentTime=0,r.volume=1,this.audioElms.set(t,r),e.next=18;break;case 14:return e.prev=14,e.t0=e.catch(5),fo.error(e.t0),e.abrupt("return",!1);case 18:return e.abrupt("return",!0);case 19:case"end":return e.stop()}}),e,this,[[5,14]])}))),function(e,t){return n.apply(this,arguments)})},{key:"unloadSound",value:function(e){return!!this.audioElms.get(e)&&this.audioElms.delete(e)}},{key:"playSound",value:(t=qn(regeneratorRuntime.mark((function e(t){var n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=this.audioElms.get(t)){e.next=3;break}return e.abrupt("return",!1);case 3:return e.prev=3,n.currentTime=0,e.next=7,n.play();case 7:e.next=13;break;case 9:return e.prev=9,e.t0=e.catch(3),fo.error(e.t0),e.abrupt("return",!1);case 13:return e.abrupt("return",!0);case 14:case"end":return e.stop()}}),e,this,[[3,9]])}))),function(e){return t.apply(this,arguments)})},{key:"stopSound",value:function(e){var t=this.audioElms.get(e);return!!t&&t.pause()}},{key:"stopAllSound",value:function(){var e,t=fr(this.audioElms.values());try{for(t.s();!(e=t.n()).done;){e.value.pause()}}catch(e){t.e(e)}finally{t.f()}}},{key:"isPlaying",value:function(e){var t=this.audioElms.get(e);return t&&!t.paused}},{key:"_isLoop",value:function(e){return e===zl.DIALING||e===zl.RINGING}},{key:"_createAudio",value:function(e){var t=new Audio;return t.autoplay=!1,t.muted=!1,t.loop=this._isLoop(e),t}}]),e}();function $l(e){return function(t){var n=t.descriptor.value;return t.descriptor.value=function(){if($l.checkIE())throw new Error(null!=e?e:"Method ".concat(t.key," is not supported in Internet Explorer"));for(var r=arguments.length,i=new Array(r),a=0;a0||!!navigator.userAgent.match(/Trident.*rv:11\./))},$l.messages={CALL_IS_NOT_SUPPORTED:"Call is not supported in Internet Explorer"};var Jl,ed,td,nd,rd="1.10.19",id=function(e){Zn(n,e);var t=ir(n);function n(){return Hn(this,n),t.apply(this,arguments)}return n}($a),ad=function(e){Zn(n,e);var t=ir(n);function n(){return Hn(this,n),t.call(this)}return Wn(n,[{key:"getApiOption",value:function(){return{auth:this.getAuth(),path:this.getPath(),method:this.getMethod(),body:this.getData(),headers:this.getHeaders()}}},{key:"getAuth",value:function(){return!0}},{key:"getHeaders",value:function(){return{}}}]),n}(ns),od=function(e){Zn(n,e);var t=ir(n);function n(e){var r;return Hn(this,n),(r=t.call(this)).statsLog=e,r}return Wn(n,[{key:"getData",value:function(){return{log_group:"sdk_webrtc_statistics_v1.1",log_data:this.statsLog}}},{key:"getPath",value:function(){return"/v1/sdk/logs"}},{key:"getMethod",value:function(){return"POST"}}]),n}(ad),sd=function(e){Zn(n,e);var t=ir(n);function n(e,r){var i;return Hn(this,n),(i=t.call(this)).version=1,i.isOverflowLogs=r,i.logs=e,i}return Wn(n,[{key:"getData",value:function(){return{version:this.version,is_overflow_logs:this.isOverflowLogs,logs:this.getLogsData()}}},{key:"getPath",value:function(){return"/v1/sdk/debug_logs"}},{key:"getMethod",value:function(){return"POST"}},{key:"getLogsData",value:function(){return this.logs.map((function(e){return{log_dt:e.logDt,log_level:e.logLevel,log_message:e.logMessage}}))}}]),n}(ad),cd=function(e){Zn(n,e);var t=ir(n);function n(e,r,i){var a;return Hn(this,n),(a=t.call(this)).appId=e,a.userId=r,a.accessToken=i,a}return Wn(n,[{key:"getAuth",value:function(){return!1}},{key:"getData",value:function(){return{app_id:this.appId,user_id:this.userId,access_token:this.accessToken}}},{key:"getPath",value:function(){return"/v1/users/".concat(encodeURIComponent(this.userId),"/login")}},{key:"getMethod",value:function(){return"POST"}}]),n}(ad),ud=function(e){Zn(n,e);var t=ir(n);function n(e,r,i){var a;return Hn(this,n),(a=t.call(this)).userId=e,a.params=r,a.next=i,a}return Wn(n,[{key:"getData",value:function(){}},{key:"getPath",value:function(){return"/v1/users/".concat(encodeURIComponent(this.userId),"/calls?").concat(this._createQuery())}},{key:"getMethod",value:function(){return"GET"}},{key:"_createQuery",value:function(){var e;return Ns.createQuery({role:this.params.myRole,limit:this._applyLimitConstraints(null===(e=this.params)||void 0===e?void 0:e.limit),end_result:this.params.endResults,next:this.next})}},{key:"_applyLimitConstraints",value:function(e){return null!=e?Math.min(Math.max(e,10),100):void 0}}]),n}(ad),ld=function(e){Zn(n,e);var t=ir(n);function n(e,r,i){var a;return Hn(this,n),(a=t.call(this)).userId=e,a.pushToken=r,a.tokenType=i,a}return Wn(n,[{key:"getAuth",value:function(){return!0}},{key:"getData",value:function(){return{token:this.pushToken,is_unique:!0}}},{key:"getPath",value:function(){return"/v1/users/".concat(encodeURIComponent(this.userId),"/push/").concat(this.tokenType)}},{key:"getMethod",value:function(){return"POST"}}]),n}(ad),dd=function(e){Zn(n,e);var t=ir(n);function n(e,r,i){var a;return Hn(this,n),(a=t.call(this)).userId=e,a.pushToken=r,a.tokenType=i,a}return Wn(n,[{key:"getAuth",value:function(){return!0}},{key:"getData",value:function(){return{}}},{key:"getPath",value:function(){return"/v1/users/".concat(encodeURIComponent(this.userId),"/push/").concat(this.tokenType,"/").concat(this.pushToken)}},{key:"getMethod",value:function(){return"DELETE"}}]),n}(ad),hd=function(e){Zn(n,e);var t=ir(n);function n(e,r){var i;return Hn(this,n),(i=t.call(this)).userId=e,i.tokenType=r,i}return Wn(n,[{key:"getAuth",value:function(){return!0}},{key:"getData",value:function(){return{}}},{key:"getPath",value:function(){return"/v1/users/".concat(encodeURIComponent(this.userId),"/push/").concat(this.tokenType)}},{key:"getMethod",value:function(){return"DELETE"}}]),n}(ad),fd=function(e){Zn(n,e);var t=ir(n);function n(e){var r;return Hn(this,n),(r=t.call(this)).callId=e,r}return Wn(n,[{key:"getPath",value:function(){return"/v1/direct_calls".concat(this.getSubPath())}}]),n}(ad);!function(e){e.CALL="CALL",e.SGNL="SGNL",e.COMM="COMM",e.UTIL="UTIL"}(Jl||(Jl={})),function(e){e[e.WS=0]="WS",e[e.API=1]="API",e[e.BOTH=2]="BOTH"}(ed||(ed={})),function(e){e.API="api",e.CMD_RETRIEVING="cmd_retrieving",e.WEBHOOK="webhook",e.WS="ws",e.PUSH="push"}(td||(td={})),function(e){e.REMOTE_PUSH="remote_push",e.VOIP_PUSH="voip_push",e.WEBHOOK="webhook",e.WS="ws"}(nd||(nd={}));var _d,vd=function(e){Zn(n,e);var t=ir(n);function n(){var e;return Hn(this,n),(e=t.call(this)).version=1,e.requestId=xc(),e}return Wn(n,[{key:"getApiOption",value:function(){return{auth:!0,path:"/v1/action/direct_call",method:"POST",headers:this.getHeaders(),body:{version:this.version,request_id:this.requestId,cmd:this.getCMD(),type:this.getType(),payload:this.getData()}}}},{key:"serialize",value:function(){return JSON.stringify({version:this.version,request_id:this.requestId,cmd:this.getCMD(),type:this.getType(),payload:this.getData()})}},{key:"requireResponse",value:function(){return!1}},{key:"getHeaders",value:function(){return{}}},{key:"sendStrategy",get:function(){return ed.WS}}]),n}(ns),pd=function(e){Zn(n,e);var t=ir(n);function n(e){var r;return Hn(this,n),(r=t.call(this)).cmd=e.cmd,r.type=e.type,r.payload=e.payload||{},r}return n}(ns),md=function(e){Zn(n,e);var t=ir(n);function n(){return Hn(this,n),t.apply(this,arguments)}return Wn(n,[{key:"getCallId",value:function(){return this.payload.callId}}]),n}(pd),yd=function(e){Zn(n,e);var t=ir(n);function n(e){var r;return Hn(this,n),(r=t.call(this)).version=e.version,r.messageId=e.message_id,r.cmd=e.cmd,r.type=e.type,r.deliveryInfo=e.delivery_info,r.sequenceNumber=e.sequence_number,r.payload=r.parseData(e.payload),r}return Wn(n,[{key:"getCallId",value:function(){return this.payload.callId}},{key:"isSequential",value:function(){return"number"==typeof this.sequenceNumber}}]),n}(ns),gd=function(e){Zn(n,e);var t=ir(n);function n(e){var r;return Hn(this,n),(r=t.call(this)).version=e.version,r.requestId=e.request_id,r.cmd=e.cmd,r.type=e.type,r.deliveryInfo=e.delivery_info,r.sequenceNumber=e.sequence_number,r.payload=r.parseData(e.payload),r}return Wn(n,[{key:"getCallId",value:function(){return this.payload.callId}},{key:"isSequential",value:function(){return"number"==typeof this.sequenceNumber}}]),n}(ns),Ed=function(e){Zn(n,e);var t=ir(n);function n(e){var r;return Hn(this,n),(r=t.call(this)).version=e.version,r.messageId=e.message_id,r.cmd=e.cmd,r.type=e.type,r.deliveryInfo=e.delivery_info,r.sequenceNumber=e.sequence_number,r.payload=r.parseData(e.payload),r}return Wn(n,[{key:"isSequential",value:function(){return"number"==typeof this.sequenceNumber}}]),n}(ns),kd=function(e){Zn(n,e);var t=ir(n);function n(){return Hn(this,n),t.apply(this,arguments)}return Wn(n,[{key:"getCallId",value:function(){return this.payload.callId}}]),n}(Ed),Rd=function(e){Zn(n,e);var t=ir(n);function n(e){var r;return Hn(this,n),(r=t.call(this,null)).callIds=e,r}return Wn(n,[{key:"requireResponse",value:function(){return!0}},{key:"getData",value:function(){}},{key:"getSubPath",value:function(){var e=this.callIds.join(",");return"/missed_signal?call_ids=".concat(encodeURIComponent(e))}},{key:"getMethod",value:function(){return"GET"}}]),n}(fd),Cd=function(e){Zn(n,e);var t=ir(n);function n(){return Hn(this,n),t.apply(this,arguments)}return Wn(n,[{key:"getData",value:function(){return{}}},{key:"getSubPath",value:function(){return"/".concat(this.callId,"/custom_items")}},{key:"getMethod",value:function(){return"DELETE"}}]),n}(fd),Id=function(e){Zn(n,e);var t=ir(n);function n(e,r){var i;return Hn(this,n),(i=t.call(this,e)).keys=r,i}return Wn(n,[{key:"getData",value:function(){return{keys:this.keys}}},{key:"getSubPath",value:function(){return"/".concat(this.callId,"/custom_items")}},{key:"getMethod",value:function(){return"DELETE"}}]),n}(fd),wd=function(e){Zn(n,e);var t=ir(n);function n(e,r){var i;return Hn(this,n),(i=t.call(this,e)).customItems=r,i}return Wn(n,[{key:"getData",value:function(){return{custom_items:this.customItems,mode:"upsert"}}},{key:"getSubPath",value:function(){return"/".concat(this.callId,"/custom_items")}},{key:"getMethod",value:function(){return"PUT"}}]),n}(fd),Ad=function(e){Zn(n,e);var t=ir(n);function n(e,r,i){var a;return Hn(this,n),(a=t.call(this,e)).userRole=r,a.data=i,a}return Wn(n,[{key:"getData",value:function(){return{version:1,user_role:this.userRole,summary_data:this.data}}},{key:"getSubPath",value:function(){return"/".concat(this.callId,"/summary")}},{key:"getMethod",value:function(){return"POST"}}]),n}(fd);!function(e){e.DIAL="dial",e.DIAL_ACK="dial_ack",e.DIAL_RCV="dial_rcv",e.CANCEL="cancel",e.ACCEPT="accept",e.ACCEPT_ACK="accept_ack",e.OTHER_DEVICE_ACCEPTED="other_device_accepted",e.DECLINE="decline",e.DECLINE_ACK="decline_ack",e.OFFER="offer",e.ANSWER="answer",e.CANDIDATE="candidate",e.REMOVE_CANDIDATES="remove_candidates",e.AUDIO="audio",e.VIDEO="video",e.HOLD="hold",e.HOLD_ACK="hold_ack",e.CUSTOM_ITEMS_UPDATE="custom_items_update",e.CUSTOM_ITEMS_DELETE="custom_items_delete",e.RECORDING="recording",e.END="end",e.TIME_OUT="timeout",e.CONNECTION_LOST="connection_lost",e.UNKNOWN_END="unknown_end",e.ALIVE="alive",e.NO_ANSWER="no_answer",e.CANCEL_ACK="cancel_ack",e.END_ACK="end_ack",e.TIMEOUT_ACK="timeout_ack",e.NO_ANSWER_ACK="no_answer_ack",e.CONNECTION_LOST_ACK="connection_lost_ack",e.UNKNOWN_END_ACK="unknown_end_ack",e.ALIVE_ACK="alive_ack",e.CONNECTED="connected",e.SNAPSHOT="snapshot",e.TURN_CHANGED="turn_changed"}(_d||(_d={}));var bd=function(e){Zn(n,e);var t=ir(n);function n(e){var r;return Hn(this,n),Kn(rr(r=t.call(this,{type:_d.DECLINE_ACK,cmd:Jl.SGNL,payload:e})),"type",_d.DECLINE_ACK),r}return n}(md),Td=function(e){Zn(n,e);var t=ir(n);function n(e){var r;return Hn(this,n),Kn(rr(r=t.call(this,{type:_d.SNAPSHOT,cmd:Jl.SGNL,payload:e})),"type",_d.SNAPSHOT),r}return n}(md),Sd=function(e){Zn(n,e);var t=ir(n);function n(){var e;Hn(this,n);for(var r=arguments.length,i=new Array(r),a=0;a=0;)e[t]=0}var Ud=0,Vd=1,Fd=2,Gd=29,Bd=256,jd=Bd+1+Gd,qd=30,Hd=19,zd=2*jd+1,Wd=15,Kd=16,Yd=7,Qd=256,Zd=16,Xd=17,$d=18,Jd=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],eh=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],th=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],nh=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],rh=new Array(2*(jd+2));Md(rh);var ih=new Array(2*qd);Md(ih);var ah=new Array(512);Md(ah);var oh=new Array(256);Md(oh);var sh=new Array(Gd);Md(sh);var ch,uh,lh,dh=new Array(qd);function hh(e,t,n,r,i){this.static_tree=e,this.extra_bits=t,this.extra_base=n,this.elems=r,this.max_length=i,this.has_stree=e&&e.length}function fh(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}function _h(e){return e<256?ah[e]:ah[256+(e>>>7)]}function vh(e,t){e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255}function ph(e,t,n){e.bi_valid>Kd-n?(e.bi_buf|=t<>Kd-e.bi_valid,e.bi_valid+=n-Kd):(e.bi_buf|=t<>>=1,n<<=1}while(--t>0);return n>>>1}function gh(e,t,n){var r,i,a=new Array(Wd+1),o=0;for(r=1;r<=Wd;r++)a[r]=o=o+n[r-1]<<1;for(i=0;i<=t;i++){var s=e[2*i+1];0!==s&&(e[2*i]=yh(a[s]++,s))}}function Eh(e){var t;for(t=0;t8?vh(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0}function Rh(e,t,n,r){var i=2*t,a=2*n;return e[i]>1;n>=1;n--)Ch(e,a,n);i=c;do{n=e.heap[1],e.heap[1]=e.heap[e.heap_len--],Ch(e,a,1),r=e.heap[1],e.heap[--e.heap_max]=n,e.heap[--e.heap_max]=r,a[2*i]=a[2*n]+a[2*r],e.depth[i]=(e.depth[n]>=e.depth[r]?e.depth[n]:e.depth[r])+1,a[2*n+1]=a[2*r+1]=i,e.heap[1]=i++,Ch(e,a,1)}while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],function(e,t){var n,r,i,a,o,s,c=t.dyn_tree,u=t.max_code,l=t.stat_desc.static_tree,d=t.stat_desc.has_stree,h=t.stat_desc.extra_bits,f=t.stat_desc.extra_base,_=t.stat_desc.max_length,v=0;for(a=0;a<=Wd;a++)e.bl_count[a]=0;for(c[2*e.heap[e.heap_max]+1]=0,n=e.heap_max+1;n_&&(a=_,v++),c[2*r+1]=a,r>u||(e.bl_count[a]++,o=0,r>=f&&(o=h[r-f]),s=c[2*r],e.opt_len+=s*(a+o),d&&(e.static_len+=s*(l[2*r+1]+o)));if(0!==v){do{for(a=_-1;0===e.bl_count[a];)a--;e.bl_count[a]--,e.bl_count[a+1]+=2,e.bl_count[_]--,v-=2}while(v>0);for(a=_;0!==a;a--)for(r=e.bl_count[a];0!==r;)(i=e.heap[--n])>u||(c[2*i+1]!==a&&(e.opt_len+=(a-c[2*i+1])*c[2*i],c[2*i+1]=a),r--)}}(e,t),gh(a,u,e.bl_count)}function Ah(e,t,n){var r,i,a=-1,o=t[1],s=0,c=7,u=4;for(0===o&&(c=138,u=3),t[2*(n+1)+1]=65535,r=0;r<=n;r++)i=o,o=t[2*(r+1)+1],++s0?(e.strm.data_type===xd&&(e.strm.data_type=function(e){var t,n=4093624447;for(t=0;t<=31;t++,n>>>=1)if(1&n&&0!==e.dyn_ltree[2*t])return Ld;if(0!==e.dyn_ltree[18]||0!==e.dyn_ltree[20]||0!==e.dyn_ltree[26])return Pd;for(t=32;t=3&&0===e.bl_tree[2*nh[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t}(e),i=e.opt_len+3+7>>>3,(a=e.static_len+3+7>>>3)<=i&&(i=a)):i=a=n+5,n+4<=i&&-1!==t?Sh(e,t,n,r):e.strategy===Nd||a===i?(ph(e,(Vd<<1)+(r?1:0),3),Ih(e,rh,ih)):(ph(e,(Fd<<1)+(r?1:0),3),function(e,t,n,r){var i;for(ph(e,t-257,5),ph(e,n-1,5),ph(e,r-4,4),i=0;i>=7;r>>8&255,e.pending_buf[e.d_buf+2*e.last_lit+1]=255&t,e.pending_buf[e.l_buf+e.last_lit]=255&n,e.last_lit++,0===t?e.dyn_ltree[2*n]++:(e.matches++,t--,e.dyn_ltree[2*(oh[n]+Bd+1)]++,e.dyn_dtree[2*_h(t)]++),e.last_lit===e.lit_bufsize-1},_tr_align:function(e){ph(e,Vd<<1,3),mh(e,Qd,rh),function(e){16===e.bi_valid?(vh(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):e.bi_valid>=8&&(e.pending_buf[e.pending++]=255&e.bi_buf,e.bi_buf>>=8,e.bi_valid-=8)}(e)}};var Nh=function(e,t,n,r){for(var i=65535&e|0,a=e>>>16&65535|0,o=0;0!==n;){n-=o=n>2e3?2e3:n;do{a=a+(i=i+t[r++]|0)|0}while(--o);i%=65521,a%=65521}return i|a<<16|0};var Lh=function(){for(var e,t=[],n=0;n<256;n++){e=n;for(var r=0;r<8;r++)e=1&e?3988292384^e>>>1:e>>>1;t[n]=e}return t}();var Ph,xh=function(e,t,n,r){var i=Lh,a=r+n;e^=-1;for(var o=r;o>>8^i[255&(e^t[o])];return-1^e},Mh={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},Uh=0,Vh=1,Fh=3,Gh=4,Bh=5,jh=0,qh=1,Hh=-2,zh=-3,Wh=-5,Kh=-1,Yh=1,Qh=2,Zh=3,Xh=4,$h=0,Jh=2,ef=8,tf=9,nf=15,rf=8,af=286,of=30,sf=19,cf=2*af+1,uf=15,lf=3,df=258,hf=df+lf+1,ff=32,_f=42,vf=69,pf=73,mf=91,yf=103,gf=113,Ef=666,kf=1,Rf=2,Cf=3,If=4,wf=3;function Af(e,t){return e.msg=Mh[t],t}function bf(e){return(e<<1)-(e>4?9:0)}function Tf(e){for(var t=e.length;--t>=0;)e[t]=0}function Sf(e){var t=e.state,n=t.pending;n>e.avail_out&&(n=e.avail_out),0!==n&&(Dd.arraySet(e.output,t.pending_buf,t.pending_out,n,e.next_out),e.next_out+=n,t.pending_out+=n,e.total_out+=n,e.avail_out-=n,t.pending-=n,0===t.pending&&(t.pending_out=0))}function Of(e,t){Dh._tr_flush_block(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,Sf(e.strm)}function Df(e,t){e.pending_buf[e.pending++]=t}function Nf(e,t){e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t}function Lf(e,t){var n,r,i=e.max_chain_length,a=e.strstart,o=e.prev_length,s=e.nice_match,c=e.strstart>e.w_size-hf?e.strstart-(e.w_size-hf):0,u=e.window,l=e.w_mask,d=e.prev,h=e.strstart+df,f=u[a+o-1],_=u[a+o];e.prev_length>=e.good_match&&(i>>=2),s>e.lookahead&&(s=e.lookahead);do{if(u[(n=t)+o]===_&&u[n+o-1]===f&&u[n]===u[a]&&u[++n]===u[a+1]){a+=2,n++;do{}while(u[++a]===u[++n]&&u[++a]===u[++n]&&u[++a]===u[++n]&&u[++a]===u[++n]&&u[++a]===u[++n]&&u[++a]===u[++n]&&u[++a]===u[++n]&&u[++a]===u[++n]&&ao){if(e.match_start=t,o=r,r>=s)break;f=u[a+o-1],_=u[a+o]}}}while((t=d[t&l])>c&&0!=--i);return o<=e.lookahead?o:e.lookahead}function Pf(e){var t,n,r,i,a,o,s,c,u,l,d=e.w_size;do{if(i=e.window_size-e.lookahead-e.strstart,e.strstart>=d+(d-hf)){Dd.arraySet(e.window,e.window,d,d,0),e.match_start-=d,e.strstart-=d,e.block_start-=d,t=n=e.hash_size;do{r=e.head[--t],e.head[t]=r>=d?r-d:0}while(--n);t=n=d;do{r=e.prev[--t],e.prev[t]=r>=d?r-d:0}while(--n);i+=d}if(0===e.strm.avail_in)break;if(o=e.strm,s=e.window,c=e.strstart+e.lookahead,u=i,l=void 0,(l=o.avail_in)>u&&(l=u),n=0===l?0:(o.avail_in-=l,Dd.arraySet(s,o.input,o.next_in,l,c),1===o.state.wrap?o.adler=Nh(o.adler,s,l,c):2===o.state.wrap&&(o.adler=xh(o.adler,s,l,c)),o.next_in+=l,o.total_in+=l,l),e.lookahead+=n,e.lookahead+e.insert>=lf)for(a=e.strstart-e.insert,e.ins_h=e.window[a],e.ins_h=(e.ins_h<=lf&&(e.ins_h=(e.ins_h<=lf)if(r=Dh._tr_tally(e,e.strstart-e.match_start,e.match_length-lf),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=lf){e.match_length--;do{e.strstart++,e.ins_h=(e.ins_h<=lf&&(e.ins_h=(e.ins_h<4096)&&(e.match_length=lf-1)),e.prev_length>=lf&&e.match_length<=e.prev_length){i=e.strstart+e.lookahead-lf,r=Dh._tr_tally(e,e.strstart-1-e.prev_match,e.prev_length-lf),e.lookahead-=e.prev_length-1,e.prev_length-=2;do{++e.strstart<=i&&(e.ins_h=(e.ins_h<15&&(o=2,r-=16),i<1||i>tf||n!==ef||r<8||r>15||t<0||t>9||a<0||a>Xh)return Af(e,Hh);8===r&&(r=9);var s=new Vf;return e.state=s,s.strm=e,s.wrap=o,s.gzhead=null,s.w_bits=r,s.w_size=1<e.pending_buf_size-5&&(n=e.pending_buf_size-5);;){if(e.lookahead<=1){if(Pf(e),0===e.lookahead&&t===Uh)return kf;if(0===e.lookahead)break}e.strstart+=e.lookahead,e.lookahead=0;var r=e.block_start+n;if((0===e.strstart||e.strstart>=r)&&(e.lookahead=e.strstart-r,e.strstart=r,Of(e,!1),0===e.strm.avail_out))return kf;if(e.strstart-e.block_start>=e.w_size-hf&&(Of(e,!1),0===e.strm.avail_out))return kf}return e.insert=0,t===Gh?(Of(e,!0),0===e.strm.avail_out?Cf:If):(e.strstart>e.block_start&&(Of(e,!1),e.strm.avail_out),kf)})),new Uf(4,4,8,4,xf),new Uf(4,5,16,8,xf),new Uf(4,6,32,32,xf),new Uf(4,4,16,16,Mf),new Uf(8,16,32,32,Mf),new Uf(8,16,128,128,Mf),new Uf(8,32,128,256,Mf),new Uf(32,128,258,1024,Mf),new Uf(32,258,258,4096,Mf)];var jf=function(e,t){return e&&e.state?2!==e.state.wrap?Hh:(e.state.gzhead=t,jh):Hh},qf=function(e,t){var n,r,i,a;if(!e||!e.state||t>Bh||t<0)return e?Af(e,Hh):Hh;if(r=e.state,!e.output||!e.input&&0!==e.avail_in||r.status===Ef&&t!==Gh)return Af(e,0===e.avail_out?Wh:Hh);if(r.strm=e,n=r.last_flush,r.last_flush=t,r.status===_f)if(2===r.wrap)e.adler=0,Df(r,31),Df(r,139),Df(r,8),r.gzhead?(Df(r,(r.gzhead.text?1:0)+(r.gzhead.hcrc?2:0)+(r.gzhead.extra?4:0)+(r.gzhead.name?8:0)+(r.gzhead.comment?16:0)),Df(r,255&r.gzhead.time),Df(r,r.gzhead.time>>8&255),Df(r,r.gzhead.time>>16&255),Df(r,r.gzhead.time>>24&255),Df(r,9===r.level?2:r.strategy>=Qh||r.level<2?4:0),Df(r,255&r.gzhead.os),r.gzhead.extra&&r.gzhead.extra.length&&(Df(r,255&r.gzhead.extra.length),Df(r,r.gzhead.extra.length>>8&255)),r.gzhead.hcrc&&(e.adler=xh(e.adler,r.pending_buf,r.pending,0)),r.gzindex=0,r.status=vf):(Df(r,0),Df(r,0),Df(r,0),Df(r,0),Df(r,0),Df(r,9===r.level?2:r.strategy>=Qh||r.level<2?4:0),Df(r,wf),r.status=gf);else{var o=ef+(r.w_bits-8<<4)<<8;o|=(r.strategy>=Qh||r.level<2?0:r.level<6?1:6===r.level?2:3)<<6,0!==r.strstart&&(o|=ff),o+=31-o%31,r.status=gf,Nf(r,o),0!==r.strstart&&(Nf(r,e.adler>>>16),Nf(r,65535&e.adler)),e.adler=1}if(r.status===vf)if(r.gzhead.extra){for(i=r.pending;r.gzindex<(65535&r.gzhead.extra.length)&&(r.pending!==r.pending_buf_size||(r.gzhead.hcrc&&r.pending>i&&(e.adler=xh(e.adler,r.pending_buf,r.pending-i,i)),Sf(e),i=r.pending,r.pending!==r.pending_buf_size));)Df(r,255&r.gzhead.extra[r.gzindex]),r.gzindex++;r.gzhead.hcrc&&r.pending>i&&(e.adler=xh(e.adler,r.pending_buf,r.pending-i,i)),r.gzindex===r.gzhead.extra.length&&(r.gzindex=0,r.status=pf)}else r.status=pf;if(r.status===pf)if(r.gzhead.name){i=r.pending;do{if(r.pending===r.pending_buf_size&&(r.gzhead.hcrc&&r.pending>i&&(e.adler=xh(e.adler,r.pending_buf,r.pending-i,i)),Sf(e),i=r.pending,r.pending===r.pending_buf_size)){a=1;break}a=r.gzindexi&&(e.adler=xh(e.adler,r.pending_buf,r.pending-i,i)),0===a&&(r.gzindex=0,r.status=mf)}else r.status=mf;if(r.status===mf)if(r.gzhead.comment){i=r.pending;do{if(r.pending===r.pending_buf_size&&(r.gzhead.hcrc&&r.pending>i&&(e.adler=xh(e.adler,r.pending_buf,r.pending-i,i)),Sf(e),i=r.pending,r.pending===r.pending_buf_size)){a=1;break}a=r.gzindexi&&(e.adler=xh(e.adler,r.pending_buf,r.pending-i,i)),0===a&&(r.status=yf)}else r.status=yf;if(r.status===yf&&(r.gzhead.hcrc?(r.pending+2>r.pending_buf_size&&Sf(e),r.pending+2<=r.pending_buf_size&&(Df(r,255&e.adler),Df(r,e.adler>>8&255),e.adler=0,r.status=gf)):r.status=gf),0!==r.pending){if(Sf(e),0===e.avail_out)return r.last_flush=-1,jh}else if(0===e.avail_in&&bf(t)<=bf(n)&&t!==Gh)return Af(e,Wh);if(r.status===Ef&&0!==e.avail_in)return Af(e,Wh);if(0!==e.avail_in||0!==r.lookahead||t!==Uh&&r.status!==Ef){var s=r.strategy===Qh?function(e,t){for(var n;;){if(0===e.lookahead&&(Pf(e),0===e.lookahead)){if(t===Uh)return kf;break}if(e.match_length=0,n=Dh._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,n&&(Of(e,!1),0===e.strm.avail_out))return kf}return e.insert=0,t===Gh?(Of(e,!0),0===e.strm.avail_out?Cf:If):e.last_lit&&(Of(e,!1),0===e.strm.avail_out)?kf:Rf}(r,t):r.strategy===Zh?function(e,t){for(var n,r,i,a,o=e.window;;){if(e.lookahead<=df){if(Pf(e),e.lookahead<=df&&t===Uh)return kf;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=lf&&e.strstart>0&&(r=o[i=e.strstart-1])===o[++i]&&r===o[++i]&&r===o[++i]){a=e.strstart+df;do{}while(r===o[++i]&&r===o[++i]&&r===o[++i]&&r===o[++i]&&r===o[++i]&&r===o[++i]&&r===o[++i]&&r===o[++i]&&ie.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=lf?(n=Dh._tr_tally(e,1,e.match_length-lf),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(n=Dh._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),n&&(Of(e,!1),0===e.strm.avail_out))return kf}return e.insert=0,t===Gh?(Of(e,!0),0===e.strm.avail_out?Cf:If):e.last_lit&&(Of(e,!1),0===e.strm.avail_out)?kf:Rf}(r,t):Ph[r.level].func(r,t);if(s!==Cf&&s!==If||(r.status=Ef),s===kf||s===Cf)return 0===e.avail_out&&(r.last_flush=-1),jh;if(s===Rf&&(t===Vh?Dh._tr_align(r):t!==Bh&&(Dh._tr_stored_block(r,0,0,!1),t===Fh&&(Tf(r.head),0===r.lookahead&&(r.strstart=0,r.block_start=0,r.insert=0))),Sf(e),0===e.avail_out))return r.last_flush=-1,jh}return t!==Gh?jh:r.wrap<=0?qh:(2===r.wrap?(Df(r,255&e.adler),Df(r,e.adler>>8&255),Df(r,e.adler>>16&255),Df(r,e.adler>>24&255),Df(r,255&e.total_in),Df(r,e.total_in>>8&255),Df(r,e.total_in>>16&255),Df(r,e.total_in>>24&255)):(Nf(r,e.adler>>>16),Nf(r,65535&e.adler)),Sf(e),r.wrap>0&&(r.wrap=-r.wrap),0!==r.pending?jh:qh)},Hf={deflateInit:function(e,t){return Bf(e,t,ef,nf,rf,$h)},deflateInit2:Bf,deflateReset:Gf,deflateResetKeep:Ff,deflateSetHeader:jf,deflate:qf,deflateEnd:function(e){var t;return e&&e.state?(t=e.state.status)!==_f&&t!==vf&&t!==pf&&t!==mf&&t!==yf&&t!==gf&&t!==Ef?Af(e,Hh):(e.state=null,t===gf?Af(e,zh):jh):Hh},deflateSetDictionary:function(e,t){var n,r,i,a,o,s,c,u,l=t.length;if(!e||!e.state)return Hh;if(2===(a=(n=e.state).wrap)||1===a&&n.status!==_f||n.lookahead)return Hh;for(1===a&&(e.adler=Nh(e.adler,t,l,0)),n.wrap=0,l>=n.w_size&&(0===a&&(Tf(n.head),n.strstart=0,n.block_start=0,n.insert=0),u=new Dd.Buf8(n.w_size),Dd.arraySet(u,t,l-n.w_size,n.w_size,0),t=u,l=n.w_size),o=e.avail_in,s=e.next_in,c=e.input,e.avail_in=l,e.next_in=0,e.input=t,Pf(n);n.lookahead>=lf;){r=n.strstart,i=n.lookahead-(lf-1);do{n.ins_h=(n.ins_h<=252?6:Yf>=248?5:Yf>=240?4:Yf>=224?3:Yf>=192?2:1;Kf[254]=Kf[254]=1;function Qf(e,t){if(t<65534&&(e.subarray&&Wf||!e.subarray&&zf))return String.fromCharCode.apply(null,Dd.shrinkBuf(e,t));for(var n="",r=0;r>>6,t[a++]=128|63&n):n<65536?(t[a++]=224|n>>>12,t[a++]=128|n>>>6&63,t[a++]=128|63&n):(t[a++]=240|n>>>18,t[a++]=128|n>>>12&63,t[a++]=128|n>>>6&63,t[a++]=128|63&n);return t},buf2binstring:function(e){return Qf(e,e.length)},binstring2buf:function(e){for(var t=new Dd.Buf8(e.length),n=0,r=t.length;n4)s[r++]=65533,n+=a-1;else{for(i&=2===a?31:3===a?15:7;a>1&&n1?s[r++]=65533:i<65536?s[r++]=i:(i-=65536,s[r++]=55296|i>>10&1023,s[r++]=56320|1023&i)}return Qf(s,r)},utf8border:function(e,t){var n;for((t=t||e.length)>e.length&&(t=e.length),n=t-1;n>=0&&128==(192&e[n]);)n--;return n<0||0===n?t:n+Kf[e[n]]>t?n:t}};var Xf=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0},$f=Object.prototype.toString,Jf=0,e_=-1,t_=0,n_=8;function r_(e){if(!(this instanceof r_))return new r_(e);this.options=Dd.assign({level:e_,method:n_,chunkSize:16384,windowBits:15,memLevel:8,strategy:t_,to:""},e||{});var t=this.options;t.raw&&t.windowBits>0?t.windowBits=-t.windowBits:t.gzip&&t.windowBits>0&&t.windowBits<16&&(t.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Xf,this.strm.avail_out=0;var n=Hf.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(n!==Jf)throw new Error(Mh[n]);if(t.header&&Hf.deflateSetHeader(this.strm,t.header),t.dictionary){var r;if(r="string"==typeof t.dictionary?Zf.string2buf(t.dictionary):"[object ArrayBuffer]"===$f.call(t.dictionary)?new Uint8Array(t.dictionary):t.dictionary,(n=Hf.deflateSetDictionary(this.strm,r))!==Jf)throw new Error(Mh[n]);this._dict_set=!0}}function i_(e,t){var n=new r_(t);if(n.push(e,!0),n.err)throw n.msg||Mh[n.err];return n.result}r_.prototype.push=function(e,t){var n,r,i=this.strm,a=this.options.chunkSize;if(this.ended)return!1;r=t===~~t?t:!0===t?4:0,"string"==typeof e?i.input=Zf.string2buf(e):"[object ArrayBuffer]"===$f.call(e)?i.input=new Uint8Array(e):i.input=e,i.next_in=0,i.avail_in=i.input.length;do{if(0===i.avail_out&&(i.output=new Dd.Buf8(a),i.next_out=0,i.avail_out=a),1!==(n=Hf.deflate(i,r))&&n!==Jf)return this.onEnd(n),this.ended=!0,!1;0!==i.avail_out&&(0!==i.avail_in||4!==r&&2!==r)||("string"===this.options.to?this.onData(Zf.buf2binstring(Dd.shrinkBuf(i.output,i.next_out))):this.onData(Dd.shrinkBuf(i.output,i.next_out)))}while((i.avail_in>0||0===i.avail_out)&&1!==n);return 4===r?(n=Hf.deflateEnd(this.strm),this.onEnd(n),this.ended=!0,n===Jf):2!==r||(this.onEnd(Jf),i.avail_out=0,!0)},r_.prototype.onData=function(e){this.chunks.push(e)},r_.prototype.onEnd=function(e){e===Jf&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=Dd.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var a_={Deflate:r_,deflate:i_,deflateRaw:function(e,t){return(t=t||{}).raw=!0,i_(e,t)},gzip:function(e,t){return(t=t||{}).gzip=!0,i_(e,t)}},o_=function(e,t){var n,r,i,a,o,s,c,u,l,d,h,f,_,v,p,m,y,g,E,k,R,C,I,w,A;n=e.state,r=e.next_in,w=e.input,i=r+(e.avail_in-5),a=e.next_out,A=e.output,o=a-(t-e.avail_out),s=a+(e.avail_out-257),c=n.dmax,u=n.wsize,l=n.whave,d=n.wnext,h=n.window,f=n.hold,_=n.bits,v=n.lencode,p=n.distcode,m=(1<>>=E=g>>>24,_-=E,0===(E=g>>>16&255))A[a++]=65535&g;else{if(!(16&E)){if(0==(64&E)){g=v[(65535&g)+(f&(1<>>=E,_-=E),_<15&&(f+=w[r++]<<_,_+=8,f+=w[r++]<<_,_+=8),g=p[f&y];n:for(;;){if(f>>>=E=g>>>24,_-=E,!(16&(E=g>>>16&255))){if(0==(64&E)){g=p[(65535&g)+(f&(1<c){e.msg="invalid distance too far back",n.mode=30;break e}if(f>>>=E,_-=E,R>(E=a-o)){if((E=R-E)>l&&n.sane){e.msg="invalid distance too far back",n.mode=30;break e}if(C=0,I=h,0===d){if(C+=u-E,E2;)A[a++]=I[C++],A[a++]=I[C++],A[a++]=I[C++],k-=3;k&&(A[a++]=I[C++],k>1&&(A[a++]=I[C++]))}else{C=a-R;do{A[a++]=A[C++],A[a++]=A[C++],A[a++]=A[C++],k-=3}while(k>2);k&&(A[a++]=A[C++],k>1&&(A[a++]=A[C++]))}break}}break}}while(r>3,f&=(1<<(_-=k<<3))-1,e.next_in=r,e.next_out=a,e.avail_in=r=1&&0===O[k];k--);if(R>k&&(R=k),0===k)return i[a++]=20971520,i[a++]=20971520,s.bits=1,0;for(E=1;E0&&(0===e||1!==k))return-1;for(D[1]=0,y=1;y852||2===e&&A>592)return 1;for(;;){_=y-I,o[g]f?(v=N[L+o[g]],p=T[S+o[g]]):(v=96,p=0),c=1<>I)+(u-=c)]=_<<24|v<<16|p|0}while(0!==u);for(c=1<>=1;if(0!==c?(b&=c-1,b+=c):b=0,g++,0==--O[y]){if(y===k)break;y=t[n+o[g]]}if(y>R&&(b&d)!==l){for(0===I&&(I=R),h+=E,w=1<<(C=y-I);C+I852||2===e&&A>592)return 1;i[l=b&d]=R<<24|C<<16|h-a|0}}return 0!==b&&(i[h+b]=y-I<<24|64<<16|0),s.bits=R,0},f_=0,__=1,v_=2,p_=4,m_=5,y_=6,g_=0,E_=1,k_=2,R_=-2,C_=-3,I_=-4,w_=-5,A_=8,b_=1,T_=2,S_=3,O_=4,D_=5,N_=6,L_=7,P_=8,x_=9,M_=10,U_=11,V_=12,F_=13,G_=14,B_=15,j_=16,q_=17,H_=18,z_=19,W_=20,K_=21,Y_=22,Q_=23,Z_=24,X_=25,$_=26,J_=27,ev=28,tv=29,nv=30,rv=31,iv=852,av=592,ov=15;function sv(e){return(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24)}function cv(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Dd.Buf16(320),this.work=new Dd.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function uv(e){var t;return e&&e.state?(t=e.state,e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=1&t.wrap),t.mode=b_,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new Dd.Buf32(iv),t.distcode=t.distdyn=new Dd.Buf32(av),t.sane=1,t.back=-1,g_):R_}function lv(e){var t;return e&&e.state?((t=e.state).wsize=0,t.whave=0,t.wnext=0,uv(e)):R_}function dv(e,t){var n,r;return e&&e.state?(r=e.state,t<0?(n=0,t=-t):(n=1+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?R_:(null!==r.window&&r.wbits!==t&&(r.window=null),r.wrap=n,r.wbits=t,lv(e))):R_}function hv(e,t){var n,r;return e?(r=new cv,e.state=r,r.window=null,(n=dv(e,t))!==g_&&(e.state=null),n):R_}var fv,_v,vv=!0;function pv(e){if(vv){var t;for(fv=new Dd.Buf32(512),_v=new Dd.Buf32(32),t=0;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(h_(__,e.lens,0,288,fv,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;h_(v_,e.lens,0,32,_v,0,e.work,{bits:5}),vv=!1}e.lencode=fv,e.lenbits=9,e.distcode=_v,e.distbits=5}function mv(e,t,n,r){var i,a=e.state;return null===a.window&&(a.wsize=1<=a.wsize?(Dd.arraySet(a.window,t,n-a.wsize,a.wsize,0),a.wnext=0,a.whave=a.wsize):((i=a.wsize-a.wnext)>r&&(i=r),Dd.arraySet(a.window,t,n-r,i,a.wnext),(r-=i)?(Dd.arraySet(a.window,t,n-r,r,0),a.wnext=r,a.whave=a.wsize):(a.wnext+=i,a.wnext===a.wsize&&(a.wnext=0),a.whave>>8&255,n.check=xh(n.check,b,2,0),u=0,l=0,n.mode=T_;break}if(n.flags=0,n.head&&(n.head.done=!1),!(1&n.wrap)||(((255&u)<<8)+(u>>8))%31){e.msg="incorrect header check",n.mode=nv;break}if((15&u)!==A_){e.msg="unknown compression method",n.mode=nv;break}if(l-=4,R=8+(15&(u>>>=4)),0===n.wbits)n.wbits=R;else if(R>n.wbits){e.msg="invalid window size",n.mode=nv;break}n.dmax=1<>8&1),512&n.flags&&(b[0]=255&u,b[1]=u>>>8&255,n.check=xh(n.check,b,2,0)),u=0,l=0,n.mode=S_;case S_:for(;l<32;){if(0===s)break e;s--,u+=r[a++]<>>8&255,b[2]=u>>>16&255,b[3]=u>>>24&255,n.check=xh(n.check,b,4,0)),u=0,l=0,n.mode=O_;case O_:for(;l<16;){if(0===s)break e;s--,u+=r[a++]<>8),512&n.flags&&(b[0]=255&u,b[1]=u>>>8&255,n.check=xh(n.check,b,2,0)),u=0,l=0,n.mode=D_;case D_:if(1024&n.flags){for(;l<16;){if(0===s)break e;s--,u+=r[a++]<>>8&255,n.check=xh(n.check,b,2,0)),u=0,l=0}else n.head&&(n.head.extra=null);n.mode=N_;case N_:if(1024&n.flags&&((f=n.length)>s&&(f=s),f&&(n.head&&(R=n.head.extra_len-n.length,n.head.extra||(n.head.extra=new Array(n.head.extra_len)),Dd.arraySet(n.head.extra,r,a,f,R)),512&n.flags&&(n.check=xh(n.check,r,f,a)),s-=f,a+=f,n.length-=f),n.length))break e;n.length=0,n.mode=L_;case L_:if(2048&n.flags){if(0===s)break e;f=0;do{R=r[a+f++],n.head&&R&&n.length<65536&&(n.head.name+=String.fromCharCode(R))}while(R&&f>9&1,n.head.done=!0),e.adler=n.check=0,n.mode=V_;break;case M_:for(;l<32;){if(0===s)break e;s--,u+=r[a++]<>>=7&l,l-=7&l,n.mode=J_;break}for(;l<3;){if(0===s)break e;s--,u+=r[a++]<>>=1)){case 0:n.mode=G_;break;case 1:if(pv(n),n.mode=W_,t===y_){u>>>=2,l-=2;break e}break;case 2:n.mode=q_;break;case 3:e.msg="invalid block type",n.mode=nv}u>>>=2,l-=2;break;case G_:for(u>>>=7&l,l-=7&l;l<32;){if(0===s)break e;s--,u+=r[a++]<>>16^65535)){e.msg="invalid stored block lengths",n.mode=nv;break}if(n.length=65535&u,u=0,l=0,n.mode=B_,t===y_)break e;case B_:n.mode=j_;case j_:if(f=n.length){if(f>s&&(f=s),f>c&&(f=c),0===f)break e;Dd.arraySet(i,r,a,f,o),s-=f,a+=f,c-=f,o+=f,n.length-=f;break}n.mode=V_;break;case q_:for(;l<14;){if(0===s)break e;s--,u+=r[a++]<>>=5,l-=5,n.ndist=1+(31&u),u>>>=5,l-=5,n.ncode=4+(15&u),u>>>=4,l-=4,n.nlen>286||n.ndist>30){e.msg="too many length or distance symbols",n.mode=nv;break}n.have=0,n.mode=H_;case H_:for(;n.have>>=3,l-=3}for(;n.have<19;)n.lens[T[n.have++]]=0;if(n.lencode=n.lendyn,n.lenbits=7,I={bits:n.lenbits},C=h_(f_,n.lens,0,19,n.lencode,0,n.work,I),n.lenbits=I.bits,C){e.msg="invalid code lengths set",n.mode=nv;break}n.have=0,n.mode=z_;case z_:for(;n.have>>16&255,y=65535&A,!((p=A>>>24)<=l);){if(0===s)break e;s--,u+=r[a++]<>>=p,l-=p,n.lens[n.have++]=y;else{if(16===y){for(w=p+2;l>>=p,l-=p,0===n.have){e.msg="invalid bit length repeat",n.mode=nv;break}R=n.lens[n.have-1],f=3+(3&u),u>>>=2,l-=2}else if(17===y){for(w=p+3;l>>=p)),u>>>=3,l-=3}else{for(w=p+7;l>>=p)),u>>>=7,l-=7}if(n.have+f>n.nlen+n.ndist){e.msg="invalid bit length repeat",n.mode=nv;break}for(;f--;)n.lens[n.have++]=R}}if(n.mode===nv)break;if(0===n.lens[256]){e.msg="invalid code -- missing end-of-block",n.mode=nv;break}if(n.lenbits=9,I={bits:n.lenbits},C=h_(__,n.lens,0,n.nlen,n.lencode,0,n.work,I),n.lenbits=I.bits,C){e.msg="invalid literal/lengths set",n.mode=nv;break}if(n.distbits=6,n.distcode=n.distdyn,I={bits:n.distbits},C=h_(v_,n.lens,n.nlen,n.ndist,n.distcode,0,n.work,I),n.distbits=I.bits,C){e.msg="invalid distances set",n.mode=nv;break}if(n.mode=W_,t===y_)break e;case W_:n.mode=K_;case K_:if(s>=6&&c>=258){e.next_out=o,e.avail_out=c,e.next_in=a,e.avail_in=s,n.hold=u,n.bits=l,o_(e,h),o=e.next_out,i=e.output,c=e.avail_out,a=e.next_in,r=e.input,s=e.avail_in,u=n.hold,l=n.bits,n.mode===V_&&(n.back=-1);break}for(n.back=0;m=(A=n.lencode[u&(1<>>16&255,y=65535&A,!((p=A>>>24)<=l);){if(0===s)break e;s--,u+=r[a++]<>g)])>>>16&255,y=65535&A,!(g+(p=A>>>24)<=l);){if(0===s)break e;s--,u+=r[a++]<>>=g,l-=g,n.back+=g}if(u>>>=p,l-=p,n.back+=p,n.length=y,0===m){n.mode=$_;break}if(32&m){n.back=-1,n.mode=V_;break}if(64&m){e.msg="invalid literal/length code",n.mode=nv;break}n.extra=15&m,n.mode=Y_;case Y_:if(n.extra){for(w=n.extra;l>>=n.extra,l-=n.extra,n.back+=n.extra}n.was=n.length,n.mode=Q_;case Q_:for(;m=(A=n.distcode[u&(1<>>16&255,y=65535&A,!((p=A>>>24)<=l);){if(0===s)break e;s--,u+=r[a++]<>g)])>>>16&255,y=65535&A,!(g+(p=A>>>24)<=l);){if(0===s)break e;s--,u+=r[a++]<>>=g,l-=g,n.back+=g}if(u>>>=p,l-=p,n.back+=p,64&m){e.msg="invalid distance code",n.mode=nv;break}n.offset=y,n.extra=15&m,n.mode=Z_;case Z_:if(n.extra){for(w=n.extra;l>>=n.extra,l-=n.extra,n.back+=n.extra}if(n.offset>n.dmax){e.msg="invalid distance too far back",n.mode=nv;break}n.mode=X_;case X_:if(0===c)break e;if(f=h-c,n.offset>f){if((f=n.offset-f)>n.whave&&n.sane){e.msg="invalid distance too far back",n.mode=nv;break}f>n.wnext?(f-=n.wnext,_=n.wsize-f):_=n.wnext-f,f>n.length&&(f=n.length),v=n.window}else v=i,_=o-n.offset,f=n.length;f>c&&(f=c),c-=f,n.length-=f;do{i[o++]=v[_++]}while(--f);0===n.length&&(n.mode=K_);break;case $_:if(0===c)break e;i[o++]=n.length,c--,n.mode=K_;break;case J_:if(n.wrap){for(;l<32;){if(0===s)break e;s--,u|=r[a++]<=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,0===t.windowBits&&(t.windowBits=-15)),!(t.windowBits>=0&&t.windowBits<16)||e&&e.windowBits||(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&0==(15&t.windowBits)&&(t.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Xf,this.strm.avail_out=0;var n=Ev.inflateInit2(this.strm,t.windowBits);if(n!==kv.Z_OK)throw new Error(Mh[n]);if(this.header=new Rv,Ev.inflateGetHeader(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=Zf.string2buf(t.dictionary):"[object ArrayBuffer]"===Cv.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(n=Ev.inflateSetDictionary(this.strm,t.dictionary))!==kv.Z_OK))throw new Error(Mh[n])}function wv(e,t){var n=new Iv(t);if(n.push(e,!0),n.err)throw n.msg||Mh[n.err];return n.result}Iv.prototype.push=function(e,t){var n,r,i,a,o,s=this.strm,c=this.options.chunkSize,u=this.options.dictionary,l=!1;if(this.ended)return!1;r=t===~~t?t:!0===t?kv.Z_FINISH:kv.Z_NO_FLUSH,"string"==typeof e?s.input=Zf.binstring2buf(e):"[object ArrayBuffer]"===Cv.call(e)?s.input=new Uint8Array(e):s.input=e,s.next_in=0,s.avail_in=s.input.length;do{if(0===s.avail_out&&(s.output=new Dd.Buf8(c),s.next_out=0,s.avail_out=c),(n=Ev.inflate(s,kv.Z_NO_FLUSH))===kv.Z_NEED_DICT&&u&&(n=Ev.inflateSetDictionary(this.strm,u)),n===kv.Z_BUF_ERROR&&!0===l&&(n=kv.Z_OK,l=!1),n!==kv.Z_STREAM_END&&n!==kv.Z_OK)return this.onEnd(n),this.ended=!0,!1;s.next_out&&(0!==s.avail_out&&n!==kv.Z_STREAM_END&&(0!==s.avail_in||r!==kv.Z_FINISH&&r!==kv.Z_SYNC_FLUSH)||("string"===this.options.to?(i=Zf.utf8border(s.output,s.next_out),a=s.next_out-i,o=Zf.buf2string(s.output,i),s.next_out=a,s.avail_out=c-a,a&&Dd.arraySet(s.output,s.output,i,a,0),this.onData(o)):this.onData(Dd.shrinkBuf(s.output,s.next_out)))),0===s.avail_in&&0===s.avail_out&&(l=!0)}while((s.avail_in>0||0===s.avail_out)&&n!==kv.Z_STREAM_END);return n===kv.Z_STREAM_END&&(r=kv.Z_FINISH),r===kv.Z_FINISH?(n=Ev.inflateEnd(this.strm),this.onEnd(n),this.ended=!0,n===kv.Z_OK):r!==kv.Z_SYNC_FLUSH||(this.onEnd(kv.Z_OK),s.avail_out=0,!0)},Iv.prototype.onData=function(e){this.chunks.push(e)},Iv.prototype.onEnd=function(e){e===kv.Z_OK&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=Dd.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var Av={Inflate:Iv,inflate:wv,inflateRaw:function(e,t){return(t=t||{}).raw=!0,wv(e,t)},ungzip:wv},bv={};(0,Dd.assign)(bv,a_,Av,kv);var Tv,Sv=bv.gzip,Ov=bv.ungzip,Dv=function(){function e(){Hn(this,e)}return Wn(e,null,[{key:"encode",value:function(e){return btoa(e)}},{key:"decode",value:function(e){return atob(e)}}]),e}(),Nv=function(){function e(){Hn(this,e)}return Wn(e,null,[{key:"compress",value:function(e){var t=Sv(e,{to:"string"});return Dv.encode(t)}},{key:"decompress",value:function(e){var t=Dv.decode(e);return Ov(t,{to:"string"})}}]),e}(),Lv=function(e){Zn(n,e);var t=ir(n);function n(){var e;Hn(this,n);for(var r=arguments.length,i=new Array(r),a=0;a1&&void 0!==arguments[1]&&arguments[1];Hn(this,e),this.callId=t.call_id,this.isVideoCall=t.is_video_call,this._customItems=t.custom_items,this.userRole=t.user_role,this.startedAt=t.started_at,this.endedAt=t.ended_at,this._participants=t.participants.map((function(e){return new Uv(e)})),this.endedBy=this._participants.find((function(e){return e.userId===t.ended_by})),this.duration=t.duration,this.endResult=t.end_result_ex,this.callType=t.call_type,this._isFromServer=n}return Wn(e,[{key:"caller",get:function(){return this._participants.find((function(e){return e.role===ko.CALLER}))}},{key:"callee",get:function(){return this._participants.find((function(e){return e.role===ko.CALLEE}))}},{key:"customItems",get:function(){return Qn({},this._customItems)}},{key:"isFromServer",get:function(){return this._isFromServer}}]),e}(),Bv=function(e){Zn(n,e);var t=ir(n);function n(){return Hn(this,n),t.apply(this,arguments)}return Wn(n,[{key:"parseData",value:function(e){return{callId:e.call_id,endedCall:new Gv(e.ended_call)}}}]),n}(yd),jv=function(e){Zn(n,e);var t=ir(n);function n(){var e;Hn(this,n);for(var r=arguments.length,i=new Array(r),a=0;a=500&&(this._isOverflowLogs=!0,this._logs.shift()),this._logs.push(e)}},{key:"_flush",value:function(e){var t=this._logs.filter((function(t){return ti[t.logLevel].level>=ti[e].level})),n=Ip.createUploadLogsCommand(t,this._isOverflowLogs);this._isOverflowLogs=!1,this._logs=[],this._ctx.sender.send(n)}},{key:"onEvent",value:function(e){if(e.type===Tv.LOG)this._flush(e.payload.logLevel);else console.error("Cannot reach here")}}]),e}(),Ap=c.f,bp=function(e){return function(t){for(var n,r=v(t),i=nt(r),o=i.length,s=0,c=[];o>s;)n=i[s++],a&&!Ap.call(r,n)||c.push(e?[n,r[n]]:r[n]);return c}},Tp={entries:bp(!0),values:bp(!1)},Sp=Tp.values;Oe({target:"Object",stat:!0},{values:function(e){return Sp(e)}});var Op=Tp.entries;function Dp(e,t){var n=0,r=null;if("number"==typeof e){if(!t)throw new Error("'obj' parameter is required");n=e,r=t}else{if(!e||t)throw new Error("'obj' parameter is required");r=e}return function(e){var t=e.descriptor.value;return e.descriptor.value=function(){for(var e=arguments.length,i=new Array(e),a=0;a=0;)n+=s[t],s[t]=Pp(n/e),n=n%e*1e7},f=function(){for(var e=6,t="";--e>=0;)if(""!==t||0===e||0!==s[e]){var n=String(s[e]);t=""===t?n:t+Qr.call("0",7-n.length)+n}return t};if(o<0||o>20)throw RangeError("Incorrect fraction digits");if(a!=a)return"NaN";if(a<=-1e21||a>=1e21)return String(a);if(a<0&&(c="-",a=-a),a>1e-21)if(n=(t=function(e){for(var t=0,n=e;n>=4096;)t+=12,n/=4096;for(;n>=2;)t+=1,n/=2;return t}(a*xp(2,69,1))-69)<0?a*xp(2,-t,1):a/xp(2,t,1),n*=4503599627370496,(t=52-t)>0){for(l(0,n),r=o;r>=7;)l(1e7,0),r-=7;for(l(xp(10,r,1),0),r=t-1;r>=23;)h(1<<23),r-=23;h(1<0?c+((i=u.length)<=o?"0."+Qr.call("0",o-i)+u:u.slice(0,i-o)+"."+u.slice(i-o)):c+u}});var Up=function(){function e(t,n){Hn(this,e),Kn(this,"_count",0),this._call=t,this._statsInterval=n,this._init(),this._audioMosList=[]}return Wn(e,[{key:"_init",value:function(){this._reconnectionCount=0}},{key:"insertStatsLog",value:function(e){var t,n=this._accumulatedStatsLog;this._count+=1;var r=du(e,n);this._audioMosList.push(null!==(t=r.audio.mos)&&void 0!==t?t:0),this._accumulatedStatsLog=vu(r,this._accumulatedStatsLog,this._count)}},{key:"onDial",value:function(){this._dialSentAt=Date.now()}},{key:"onDialAck",value:function(){this._pdd=Date.now()-this._dialSentAt}},{key:"onAccept",value:function(){this._callSetupStartedAt=Date.now()}},{key:"onAcceptAck",value:function(){this._callSetupStartedAt=Date.now()}},{key:"onConnected",value:function(){this._setupTime=Date.now()-this._callSetupStartedAt}},{key:"increaseReconnectedCount",value:function(){this._reconnectionCount+=1}},{key:"getSummary",value:function(){var e={};if(e.pdd=this._pdd,e.setup_time=this._setupTime,e.reconnection_count=this._reconnectionCount,!this._accumulatedStatsLog)return e;var t=this._accumulatedStatsLog,n=t.transport_info,r=t.audio,i=t.video;return e.network_type=n.network_type,e.transport_info_candidate_type=n.candidate_type,e.audio_mos_list=this._audioMosList.map((function(e){return parseFloat(e.toFixed(1))})),e.stats_interval=this._statsInterval/1e3,e.audio_codec=r.codec,e.audio_mos=r.mos,e.audio_packets_lost_rate=r.packets_lost_rate,e.audio_rtt=r.remote_rtt,e.video_codec=i.codec,e.video_freeze_count=i.freeze_count,e.video_jitter_buffer_delay=i.jitter_buffer_delay,e.video_jitter_buffer_emitted_count=i.jitter_buffer_emitted_count,e.video_packets_lost_rate=i.packets_lost_rate,e.video_received_frame_height=i.received_frame_height,e.video_received_frame_width=i.received_frame_width,e.video_rtt=i.remote_rtt,e.video_sent_frame_height=i.sent_frame_height,e.video_sent_frame_width=i.sent_frame_width,e.video_total_decode_time=i.total_decode_time,e.video_total_freezes_duration=i.total_freezes_duration,e.video_total_inter_frame_delay=i.total_inter_frame_delay,e.video_source_frames_per_second=i.video_source_frames_per_second,e.video_source_height=i.video_source_height,e.video_source_width=i.video_source_width,e}}]),e}(),Vp=function(){function e(t,n){Hn(this,e),this._ctx=t,this._call=n,this._statsList=[],this._summary=new Up(n,this._interval)}return Wn(e,[{key:"_insertInfo",value:function(){var e=this._call;Object.assign(this._accumulated,{app_id:this._ctx.appId,browser_type:oo(),call_id:e.callId,device_timestamp:(new Date).getTime(),role:e.myRole,caller_id:e.caller.userId,callee_id:e.callee.userId,is_video_call:e.isVideoCall,metadata:{measure_count:e.options.statsIntervalValue/1e3,measure_interval:e.options.statsIntervalValue/1e3}})}},{key:"insertStatsLog",value:function(e){var t=this,n=du(e,this._prev);if(this._statsList.push(n),this._prev=n,this._statsList.length&&this._statsList.length%(this._interval/1e3)==0){var r,i=0;this._accumulated=this._statsList.reduce((function(e,n){return i+=1,vu(t._statsList[i-1],n,i)}),{}),this._statsList.length=0,null===(r=this._sendStatsLogCommand)||void 0===r||r.call(this,this._accumulated),this._summary.insertStatsLog(this._accumulated)}}},{key:"_sendStatsLogCommand",value:function(e){this._insertInfo();var t=Ip.createStatsLogCommand(e);this._ctx.sender.send(t).catch((function(e){return fo.warning("failed to send stats to server",e)}))}},{key:"summary",get:function(){return this._summary}},{key:"_interval",get:function(){return this._call.options.statsIntervalValue}}]),e}(),Fp=function(e){Zn(n,e);var t=ir(n);function n(){var e;return Hn(this,n),(e=t.call(this))._haveRetrievedValidStat=!1,e._updateCount=0,e._prevStats=null,e._prevMetrics=null,e}return Wn(n,[{key:"setMode",value:function(e){switch(this._stopDispatchInterval(),e){case no.FREQUENCY:this._startDispatchInterval();break;case no.CONNECTION_QUALITY_CHANGE:break;default:throw new vo(Ln.INVALID_PARAMETER_VALUE,{invalidParameter:"ConnectionQualityMonitoringMode"})}}},{key:"insertStatsLog",value:function(e){var t=this._prevStats,n=this._prevMetrics;if(this._updateCount+=1,!this._haveRetrievedValidStat&&null!=e&&e.audio.mos&&(this._haveRetrievedValidStat=!0),this._haveRetrievedValidStat||!(this._updateCount<=15)){var r,i;e?(r=du(e,t),i=new Ro({mos:r.audio.mos,packetsLostRate:r.audio.packets_lost_rate,rtt:r.audio.remote_rtt,jitter:r.audio.remote_jitter})):i=new Ro({mos:void 0,packetsLostRate:void 0,rtt:void 0,jitter:void 0});var a=null==n?void 0:n.connectionQuality;this._prevStats=r,this._prevMetrics=i,i.connectionQuality!==a&&this._dispatchIfExist()}}},{key:"onReconnecting",value:function(){this.insertStatsLog(void 0)}},{key:"onEnded",value:function(){this._stopDispatchInterval()}},{key:"_startDispatchInterval",value:function(){var e=this;this._dispatchIntervalId=setInterval((function(){e._dispatchIfExist()}),3e3)}},{key:"_stopDispatchInterval",value:function(){this._dispatchIntervalId&&(clearInterval(this._dispatchIntervalId),delete this._dispatchIntervalId)}},{key:"_dispatchIfExist",value:function(){var e=this._prevMetrics;e&&this._dispatchEvent("updated",e)}}]),n}(Yo),Gp=function(){function e(t,n){Hn(this,e),this._ctx=t,this._call=n,this._collector=new Vp(t,n),this._connectionQuality=new Fp}return Wn(e,[{key:"startGetWebRtcStats",value:function(e){var t=this;this._statsIntervalId||(this._statsIntervalId=setInterval((function(){e.getStatsLog().then((function(e){t._collector.insertStatsLog(e),t._connectionQuality.insertStatsLog(e)}))}),1e3))}},{key:"stopGetWebRtcStats",value:function(){this._statsIntervalId&&(clearInterval(this._statsIntervalId),delete this._statsIntervalId)}},{key:"getCallSummary",value:function(){return this.summary.getSummary()}},{key:"setConnectionQualityListener",value:function(e,t){this.removeConnectionQualityListener(),this._connectionQuality.on("updated",(function(e){t(e)})),this._connectionQuality.setMode(e)}},{key:"removeConnectionQualityListener",value:function(){this._connectionQuality.removeAllEventListeners()}},{key:"onReconnecting",value:function(){this._connectionQuality.onReconnecting()}},{key:"onEnded",value:function(){this._connectionQuality.onEnded()}},{key:"summary",get:function(){return this._collector.summary}}]),e}(),Bp=Ge("iterator"),jp=!i((function(){var e=new URL("b?a=1&b=2&c=3","http://a"),t=e.searchParams,n="";return e.pathname="c%20d",t.forEach((function(e,r){t.delete("b"),n+=r+e})),!t.sort||"http://a/c%20d?a=1&c=3"!==e.href||"3"!==t.get("c")||"a=1"!==String(new URLSearchParams("?a=1"))||!t[Bp]||"a"!==new URL("https://a@b").username||"b"!==new URLSearchParams(new URLSearchParams("a=b")).get("a")||"xn--e1aybc"!==new URL("http://тест").host||"#%D0%B1"!==new URL("http://a#б").hash||"a1c3"!==n||"x"!==new URL("http://x",void 0).host})),qp=2147483647,Hp=/[^\0-\u007E]/,zp=/[.\u3002\uFF0E\uFF61]/g,Wp="Overflow: input needs wider integers to process",Kp=Math.floor,Yp=String.fromCharCode,Qp=function(e){return e+22+75*(e<26)},Zp=function(e,t,n){var r=0;for(e=n?Kp(e/700):e>>1,e+=Kp(e/t);e>455;r+=36)e=Kp(e/35);return Kp(r+36*e/(e+38))},Xp=function(e){var t=[];e=function(e){for(var t=[],n=0,r=e.length;n=55296&&i<=56319&&n=a&&rKp((qp-o)/d))throw RangeError(Wp);for(o+=(l-a)*d,a=l,n=0;nqp)throw RangeError(Wp);if(r==a){for(var h=o,f=36;;f+=36){var _=f<=s?1:f>=s+26?26:f-s;if(h<_)break;var v=h-_,p=36-_;t.push(Yp(Qp(_+v%p))),h=Kp(v/p)}t.push(Yp(Qp(h))),s=Zp(o,d,u==c),o=0,++u}}++o,++a}return t.join("")},$p=function(e){var t=nn(e);if("function"!=typeof t)throw TypeError(String(e)+" is not iterable");return A(t.call(e))},Jp=re("fetch"),em=re("Headers"),tm=Ge("iterator"),nm="URLSearchParams",rm=nm+"Iterator",im=J.set,am=J.getterFor(nm),om=J.getterFor(rm),sm=/\+/g,cm=Array(4),um=function(e){return cm[e-1]||(cm[e-1]=RegExp("((?:%[\\da-f]{2}){"+e+"})","gi"))},lm=function(e){try{return decodeURIComponent(e)}catch(t){return e}},dm=function(e){var t=e.replace(sm," "),n=4;try{return decodeURIComponent(t)}catch(e){for(;n;)t=t.replace(um(n--),lm);return t}},hm=/[!'()~]|%20/g,fm={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+"},_m=function(e){return fm[e]},vm=function(e){return encodeURIComponent(e).replace(hm,_m)},pm=function(e,t){if(t)for(var n,r,i=t.split("&"),a=0;a0?arguments[0]:void 0,l=[];if(im(this,{type:nm,entries:l,updateURL:function(){},updateSearchParams:mm}),void 0!==u)if(p(u))if("function"==typeof(e=nn(u)))for(n=(t=e.call(u)).next;!(r=n.call(t)).done;){if((o=(a=(i=$p(A(r.value))).next).call(i)).done||(s=a.call(i)).done||!a.call(i).done)throw TypeError("Expected sequence with length 2");l.push({key:o.value+"",value:s.value+""})}else for(c in u)g(u,c)&&l.push({key:c,value:u[c]+""});else pm(l,"string"==typeof u?"?"===u.charAt(0)?u.slice(1):u:u+"")},km=Em.prototype;_n(km,{append:function(e,t){ym(arguments.length,2);var n=am(this);n.entries.push({key:e+"",value:t+""}),n.updateURL()},delete:function(e){ym(arguments.length,1);for(var t=am(this),n=t.entries,r=e+"",i=0;ie.key){i.splice(t,0,e);break}t===n&&i.push(e)}r.updateURL()},forEach:function(e){for(var t,n=am(this).entries,r=Ne(e,arguments.length>1?arguments[1]:void 0,3),i=0;i1&&(p(t=arguments[1])&&(n=t.body,en(n)===nm&&((r=t.headers?new em(t.headers):new em).has("content-type")||r.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"),t=dt(t,{body:u(0,String(n)),headers:u(0,r)}))),i.push(t)),Jp.apply(this,i)}});var Rm,Cm={URLSearchParams:Em,getState:am},Im=In.codeAt,wm=r.URL,Am=Cm.URLSearchParams,bm=Cm.getState,Tm=J.set,Sm=J.getterFor("URL"),Om=Math.floor,Dm=Math.pow,Nm="Invalid scheme",Lm="Invalid host",Pm="Invalid port",xm=/[A-Za-z]/,Mm=/[\d+-.A-Za-z]/,Um=/\d/,Vm=/^(0x|0X)/,Fm=/^[0-7]+$/,Gm=/^\d+$/,Bm=/^[\dA-Fa-f]+$/,jm=/[\u0000\u0009\u000A\u000D #%/:?@[\\]]/,qm=/[\u0000\u0009\u000A\u000D #/:?@[\\]]/,Hm=/^[\u0000-\u001F ]+|[\u0000-\u001F ]+$/g,zm=/[\u0009\u000A\u000D]/g,Wm=function(e,t){var n,r,i;if("["==t.charAt(0)){if("]"!=t.charAt(t.length-1))return Lm;if(!(n=Ym(t.slice(1,-1))))return Lm;e.host=n}else if(ny(e)){if(t=function(e){var t,n,r=[],i=e.toLowerCase().replace(zp,".").split(".");for(t=0;t4)return e;for(n=[],r=0;r1&&"0"==i.charAt(0)&&(a=Vm.test(i)?16:8,i=i.slice(8==a?1:2)),""===i)o=0;else{if(!(10==a?Gm:8==a?Fm:Bm).test(i))return e;o=parseInt(i,a)}n.push(o)}for(r=0;r=Dm(256,5-t))return null}else if(o>255)return null;for(s=n.pop(),r=0;r6)return;for(r=0;h();){if(i=null,r>0){if(!("."==h()&&r<4))return;d++}if(!Um.test(h()))return;for(;Um.test(h());){if(a=parseInt(h(),10),null===i)i=a;else{if(0==i)return;i=10*i+a}if(i>255)return;d++}c[u]=256*c[u]+i,2!=++r&&4!=r||u++}if(4!=r)return;break}if(":"==h()){if(d++,!h())return}else if(h())return;c[u++]=t}else{if(null!==l)return;d++,l=++u}}if(null!==l)for(o=u-l,u=7;0!=u&&o>0;)s=c[u],c[u--]=c[l+o-1],c[l+--o]=s;else if(8!=u)return;return c},Qm=function(e){var t,n,r,i;if("number"==typeof e){for(t=[],n=0;n<4;n++)t.unshift(e%256),e=Om(e/256);return t.join(".")}if("object"==typeof e){for(t="",r=function(e){for(var t=null,n=1,r=null,i=0,a=0;a<8;a++)0!==e[a]?(i>n&&(t=r,n=i),r=null,i=0):(null===r&&(r=a),++i);return i>n&&(t=r,n=i),t}(e),n=0;n<8;n++)i&&0===e[n]||(i&&(i=!1),r===n?(t+=n?":":"::",i=!0):(t+=e[n].toString(16),n<7&&(t+=":")));return"["+t+"]"}return e},Zm={},Xm=go({},Zm,{" ":1,'"':1,"<":1,">":1,"`":1}),$m=go({},Xm,{"#":1,"?":1,"{":1,"}":1}),Jm=go({},$m,{"/":1,":":1,";":1,"=":1,"@":1,"[":1,"\\":1,"]":1,"^":1,"|":1}),ey=function(e,t){var n=Im(e,0);return n>32&&n<127&&!g(t,e)?e:encodeURIComponent(e)},ty={ftp:21,file:null,http:80,https:443,ws:80,wss:443},ny=function(e){return g(ty,e.scheme)},ry=function(e){return""!=e.username||""!=e.password},iy=function(e){return!e.host||e.cannotBeABaseURL||"file"==e.scheme},ay=function(e,t){var n;return 2==e.length&&xm.test(e.charAt(0))&&(":"==(n=e.charAt(1))||!t&&"|"==n)},oy=function(e){var t;return e.length>1&&ay(e.slice(0,2))&&(2==e.length||"/"===(t=e.charAt(2))||"\\"===t||"?"===t||"#"===t)},sy=function(e){var t=e.path,n=t.length;!n||"file"==e.scheme&&1==n&&ay(t[0],!0)||t.pop()},cy=function(e){return"."===e||"%2e"===e.toLowerCase()},uy={},ly={},dy={},hy={},fy={},_y={},vy={},py={},my={},yy={},gy={},Ey={},ky={},Ry={},Cy={},Iy={},wy={},Ay={},by={},Ty={},Sy={},Oy=function(e,t,n,r){var i,a,o,s,c,u=n||uy,l=0,d="",h=!1,f=!1,_=!1;for(n||(e.scheme="",e.username="",e.password="",e.host=null,e.port=null,e.path=[],e.query=null,e.fragment=null,e.cannotBeABaseURL=!1,t=t.replace(Hm,"")),t=t.replace(zm,""),i=Sc(t);l<=i.length;){switch(a=i[l],u){case uy:if(!a||!xm.test(a)){if(n)return Nm;u=dy;continue}d+=a.toLowerCase(),u=ly;break;case ly:if(a&&(Mm.test(a)||"+"==a||"-"==a||"."==a))d+=a.toLowerCase();else{if(":"!=a){if(n)return Nm;d="",u=dy,l=0;continue}if(n&&(ny(e)!=g(ty,d)||"file"==d&&(ry(e)||null!==e.port)||"file"==e.scheme&&!e.host))return;if(e.scheme=d,n)return void(ny(e)&&ty[e.scheme]==e.port&&(e.port=null));d="","file"==e.scheme?u=Ry:ny(e)&&r&&r.scheme==e.scheme?u=hy:ny(e)?u=py:"/"==i[l+1]?(u=fy,l++):(e.cannotBeABaseURL=!0,e.path.push(""),u=by)}break;case dy:if(!r||r.cannotBeABaseURL&&"#"!=a)return Nm;if(r.cannotBeABaseURL&&"#"==a){e.scheme=r.scheme,e.path=r.path.slice(),e.query=r.query,e.fragment="",e.cannotBeABaseURL=!0,u=Sy;break}u="file"==r.scheme?Ry:_y;continue;case hy:if("/"!=a||"/"!=i[l+1]){u=_y;continue}u=my,l++;break;case fy:if("/"==a){u=yy;break}u=Ay;continue;case _y:if(e.scheme=r.scheme,a==Rm)e.username=r.username,e.password=r.password,e.host=r.host,e.port=r.port,e.path=r.path.slice(),e.query=r.query;else if("/"==a||"\\"==a&&ny(e))u=vy;else if("?"==a)e.username=r.username,e.password=r.password,e.host=r.host,e.port=r.port,e.path=r.path.slice(),e.query="",u=Ty;else{if("#"!=a){e.username=r.username,e.password=r.password,e.host=r.host,e.port=r.port,e.path=r.path.slice(),e.path.pop(),u=Ay;continue}e.username=r.username,e.password=r.password,e.host=r.host,e.port=r.port,e.path=r.path.slice(),e.query=r.query,e.fragment="",u=Sy}break;case vy:if(!ny(e)||"/"!=a&&"\\"!=a){if("/"!=a){e.username=r.username,e.password=r.password,e.host=r.host,e.port=r.port,u=Ay;continue}u=yy}else u=my;break;case py:if(u=my,"/"!=a||"/"!=d.charAt(l+1))continue;l++;break;case my:if("/"!=a&&"\\"!=a){u=yy;continue}break;case yy:if("@"==a){h&&(d="%40"+d),h=!0,o=Sc(d);for(var v=0;v65535)return Pm;e.port=ny(e)&&y===ty[e.scheme]?null:y,d=""}if(n)return;u=wy;continue}return Pm}d+=a;break;case Ry:if(e.scheme="file","/"==a||"\\"==a)u=Cy;else{if(!r||"file"!=r.scheme){u=Ay;continue}if(a==Rm)e.host=r.host,e.path=r.path.slice(),e.query=r.query;else if("?"==a)e.host=r.host,e.path=r.path.slice(),e.query="",u=Ty;else{if("#"!=a){oy(i.slice(l).join(""))||(e.host=r.host,e.path=r.path.slice(),sy(e)),u=Ay;continue}e.host=r.host,e.path=r.path.slice(),e.query=r.query,e.fragment="",u=Sy}}break;case Cy:if("/"==a||"\\"==a){u=Iy;break}r&&"file"==r.scheme&&!oy(i.slice(l).join(""))&&(ay(r.path[0],!0)?e.path.push(r.path[0]):e.host=r.host),u=Ay;continue;case Iy:if(a==Rm||"/"==a||"\\"==a||"?"==a||"#"==a){if(!n&&ay(d))u=Ay;else if(""==d){if(e.host="",n)return;u=wy}else{if(s=Wm(e,d))return s;if("localhost"==e.host&&(e.host=""),n)return;d="",u=wy}continue}d+=a;break;case wy:if(ny(e)){if(u=Ay,"/"!=a&&"\\"!=a)continue}else if(n||"?"!=a)if(n||"#"!=a){if(a!=Rm&&(u=Ay,"/"!=a))continue}else e.fragment="",u=Sy;else e.query="",u=Ty;break;case Ay:if(a==Rm||"/"==a||"\\"==a&&ny(e)||!n&&("?"==a||"#"==a)){if(".."===(c=(c=d).toLowerCase())||"%2e."===c||".%2e"===c||"%2e%2e"===c?(sy(e),"/"==a||"\\"==a&&ny(e)||e.path.push("")):cy(d)?"/"==a||"\\"==a&&ny(e)||e.path.push(""):("file"==e.scheme&&!e.path.length&&ay(d)&&(e.host&&(e.host=""),d=d.charAt(0)+":"),e.path.push(d)),d="","file"==e.scheme&&(a==Rm||"?"==a||"#"==a))for(;e.path.length>1&&""===e.path[0];)e.path.shift();"?"==a?(e.query="",u=Ty):"#"==a&&(e.fragment="",u=Sy)}else d+=ey(a,$m);break;case by:"?"==a?(e.query="",u=Ty):"#"==a?(e.fragment="",u=Sy):a!=Rm&&(e.path[0]+=ey(a,Zm));break;case Ty:n||"#"!=a?a!=Rm&&("'"==a&&ny(e)?e.query+="%27":e.query+="#"==a?"%23":ey(a,Zm)):(e.fragment="",u=Sy);break;case Sy:a!=Rm&&(e.fragment+=ey(a,Xm))}l++}},Dy=function(e){var t,n,r=sn(this,Dy,"URL"),i=arguments.length>1?arguments[1]:void 0,o=String(e),s=Tm(r,{type:"URL"});if(void 0!==i)if(i instanceof Dy)t=Sm(i);else if(n=Oy(t={},String(i)))throw TypeError(n);if(n=Oy(s,o,null,t))throw TypeError(n);var c=s.searchParams=new Am,u=bm(c);u.updateSearchParams(s.query),u.updateURL=function(){s.query=String(c)||null},a||(r.href=Ly.call(r),r.origin=Py.call(r),r.protocol=xy.call(r),r.username=My.call(r),r.password=Uy.call(r),r.host=Vy.call(r),r.hostname=Fy.call(r),r.port=Gy.call(r),r.pathname=By.call(r),r.search=jy.call(r),r.searchParams=qy.call(r),r.hash=Hy.call(r))},Ny=Dy.prototype,Ly=function(){var e=Sm(this),t=e.scheme,n=e.username,r=e.password,i=e.host,a=e.port,o=e.path,s=e.query,c=e.fragment,u=t+":";return null!==i?(u+="//",ry(e)&&(u+=n+(r?":"+r:"")+"@"),u+=Qm(i),null!==a&&(u+=":"+a)):"file"==t&&(u+="//"),u+=e.cannotBeABaseURL?o[0]:o.length?"/"+o.join("/"):"",null!==s&&(u+="?"+s),null!==c&&(u+="#"+c),u},Py=function(){var e=Sm(this),t=e.scheme,n=e.port;if("blob"==t)try{return new URL(t.path[0]).origin}catch(e){return"null"}return"file"!=t&&ny(e)?t+"://"+Qm(e.host)+(null!==n?":"+n:""):"null"},xy=function(){return Sm(this).scheme+":"},My=function(){return Sm(this).username},Uy=function(){return Sm(this).password},Vy=function(){var e=Sm(this),t=e.host,n=e.port;return null===t?"":null===n?Qm(t):Qm(t)+":"+n},Fy=function(){var e=Sm(this).host;return null===e?"":Qm(e)},Gy=function(){var e=Sm(this).port;return null===e?"":String(e)},By=function(){var e=Sm(this),t=e.path;return e.cannotBeABaseURL?t[0]:t.length?"/"+t.join("/"):""},jy=function(){var e=Sm(this).query;return e?"?"+e:""},qy=function(){return Sm(this).searchParams},Hy=function(){var e=Sm(this).fragment;return e?"#"+e:""},zy=function(e,t){return{get:e,set:t,configurable:!0,enumerable:!0}};if(a&&rt(Ny,{href:zy(Ly,(function(e){var t=Sm(this),n=String(e),r=Oy(t,n);if(r)throw TypeError(r);bm(t.searchParams).updateSearchParams(t.query)})),origin:zy(Py),protocol:zy(xy,(function(e){var t=Sm(this);Oy(t,String(e)+":",uy)})),username:zy(My,(function(e){var t=Sm(this),n=Sc(String(e));if(!iy(t)){t.username="";for(var r=0;rc||a>n)&&s.fillRect(0,0,r,i),a=n,o=c,c>t.height){var u=e.videoWidth/e.videoHeight;n=(c=t.height)*u}s.drawImage(e,t.width/2-n/2,t.height/2-c/2,n,c)}}),10);return{stream:t.captureStream(),cleanup:function(){return clearInterval(c)}}}}]),e}(),Xy=function(){function e(){Hn(this,e)}return Wn(e,null,[{key:"getRecorderMimeType",value:function(e){switch(e){case So.REMOTE_AUDIO_AND_VIDEO:case So.LOCAL_AUDIO_REMOTE_AUDIO_AND_VIDEO:case So.LOCAL_AUDIO_AND_VIDEO_REMOTE_AUDIO:return this.getVideoRecordFileMimeType();case So.REMOTE_AUDIO_ONLY:case So.LOCAL_REMOTE_AUDIOS:return this.getAudioRecordFileMimeType();default:return this.getVideoRecordFileMimeType()}}},{key:"getVideoRecordFileMimeType",value:function(){var e="video/mp4";return MediaRecorder.isTypeSupported(e)||(e="video/webm"),e}},{key:"getAudioRecordFileMimeType",value:function(){var e="audio/mp4";return MediaRecorder.isTypeSupported(e)||(e="audio/webm"),e}},{key:"createStream",value:function(e,t){var n={mimeType:this.getRecorderMimeType(t)},r=e.localMediaView.srcObject,i=e.remoteMediaView.srcObject;switch(t){case So.REMOTE_AUDIO_AND_VIDEO:return{stream:i,options:n};case So.REMOTE_AUDIO_ONLY:var a=new MediaStream;return a.addTrack(i.getAudioTracks()[0]),{stream:a,options:n};case So.LOCAL_REMOTE_AUDIOS:var o=new MediaStream,s=Zy.getMergedAudioStream(r.getAudioTracks()[0],i.getAudioTracks()[0]);return o.addTrack(s),{stream:o,options:n};case So.LOCAL_AUDIO_REMOTE_AUDIO_AND_VIDEO:var c=Zy.getVideoStream(e.remoteMediaView),u=c.stream,l=c.cleanup,d=Zy.getMergedAudioStream(r.getAudioTracks()[0],i.getAudioTracks()[0]);return u.addTrack(d),{stream:u,options:n,cleanup:l};case So.LOCAL_AUDIO_AND_VIDEO_REMOTE_AUDIO:var h=Zy.getVideoStream(e.localMediaView),f=h.stream,_=h.cleanup,v=Zy.getMergedAudioStream(r.getAudioTracks()[0],i.getAudioTracks()[0]);return f.addTrack(v),{stream:f,options:n,cleanup:_};default:return fo.error("Cannot reach here!"),{options:n}}}}]),e}(),$y=function(){function e(t,n){Hn(this,e),this.call=t,this.stateManager=n,this.timer=null}return Wn(e,[{key:"dialSent",value:function(){fo.verbose("[".concat(this.type,"] dialSent"))}},{key:"dialFailed",value:function(){fo.verbose("[".concat(this.type,"] dialFailed"))}},{key:"accept",value:function(e){fo.verbose("[".concat(this.type,"] accept"))}},{key:"acceptSent",value:function(e){fo.verbose("[".concat(this.type,"] acceptSent"))}},{key:"acceptFailed",value:function(){fo.verbose("[".concat(this.type,"] acceptFailed"))}},{key:"receiveAccept",value:function(){fo.verbose("[".concat(this.type,"] receiveAccept"))}},{key:"receiveAccepted",value:function(){fo.verbose("[".concat(this.type,"] receiveAccepted"))}},{key:"end",value:function(){fo.verbose("[".concat(this.type,"] end"))}},{key:"endSent",value:function(e){fo.verbose("[".concat(this.type,"] endSent"))}},{key:"receiveOffer",value:function(){fo.verbose("[".concat(this.type,"] receiveOffer"))}},{key:"receiveEnd",value:function(e){fo.verbose("[".concat(this.type,"] receiveEnd"))}},{key:"timeout",value:function(){fo.verbose("[".concat(this.type,"] timeout"))}},{key:"pcConnected",value:function(){fo.verbose("[".concat(this.type,"] pc connected"))}},{key:"pcReconnecting",value:function(){fo.verbose("[".concat(this.type,"] pc reconnecting"))}},{key:"closed",value:function(){fo.verbose("[".concat(this.type,"] closed"))}},{key:"onStart",value:function(){}},{key:"onDestroy",value:function(){}},{key:"fireTimeout",value:function(){}},{key:"toggleVideo",value:function(e){fo.verbose("[".concat(this.type,"] toggleVideo ").concat(e))}},{key:"toggleMicrophone",value:function(e){fo.verbose("[".concat(this.type,"] toggleMicrophone ").concat(e))}},{key:"_createTimer",value:function(e,t){var n=this;this.timer?fo.error("Only one timer allowed"):this.timer=setTimeout((function(){n._removeTimer(),e()}),t)}},{key:"_removeTimer",value:function(){this.timer&&(clearTimeout(this.timer),this.timer=null)}}]),e}();!function(e){e.IDLE="idle",e.DIALING="dialing",e.RINGING="ringing",e.ACCEPTING="accepting",e.ESTABLISHED="established",e.CONNECTED="connected",e.RECONNECTING="reconnecting",e.ICERESTART="icerestart",e.ENDED="ended",e.ABORTED="aborted",e.CLOSING="closing",e.ENDING="ending",e.CANCELED="canceled"}(Yy||(Yy={}));var Jy,eg=function(e){Zn(n,e);var t=ir(n);function n(){return Hn(this,n),t.apply(this,arguments)}return Wn(n,[{key:"onStart",value:function(){this.call.stopToSendAlive(),this.call.fireOnEnded()}},{key:"dialSent",value:function(){this.call.sendCancelCommand().catch((function(e){return fo.debug(e)}))}},{key:"dialFailed",value:function(){this.stateManager.toEnded()}},{key:"endSent",value:function(e){this.call.setEndInfo(e.payload.endedCall),this.stateManager.toEnded()}},{key:"receiveEnd",value:function(e){this.call.setEndInfo(e.payload.endedCall),this.stateManager.toEnded()}},{key:"type",get:function(){return Yy.ABORTED}}]),n}($y);!function(e){e.ACCEPTING="accepting_timeout",e.ANSWERING="answering_timeout",e.OFFERING="offering_timeout"}(Jy||(Jy={}));var tg=function(e){Zn(r,e);var t,n=ir(r);function r(){return Hn(this,r),n.apply(this,arguments)}return Wn(r,[{key:"onStart",value:function(){this.call.sendAcceptCommand().catch((function(e){return fo.debug(e)})),this.call.startCallConnectionTimer()}},{key:"acceptSent",value:function(){this.stateManager.toEstablished()}},{key:"receiveOffer",value:(t=qn(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.stateManager.toEstablished();case 1:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"acceptFailed",value:function(){this.call.setEndResult(Eo.ACCEPT_FAILED),this.stateManager.toClosing()}},{key:"end",value:function(){this.call.sendEndCommand().catch((function(e){return fo.debug(e)})),this.call.setEndResult(Eo.COMPLETED),this.stateManager.toClosing()}},{key:"fireTimeout",value:function(){this.call.sendTimeoutCommand(Jy.ACCEPTING).catch((function(e){return fo.debug(e)})),this.call.setEndResult(Eo.TIMED_OUT),this.stateManager.toClosing()}},{key:"receiveEnd",value:function(e){this.call.setEndResult(e.payload.endedCall.endResult),this.call.setEndInfo(e.payload.endedCall),this.stateManager.toClosing()}},{key:"toggleMicrophone",value:function(e){this.call.toggleMicrophone(e),this.call.sendAudioCommand().catch((function(e){return fo.debug(e)}))}},{key:"toggleVideo",value:function(e){this.call.toggleVideo(e),this.call.sendVideoCommand().catch((function(e){return fo.debug(e)}))}},{key:"type",get:function(){return Yy.ACCEPTING}}]),r}($y),ng=function(e){Zn(n,e);var t=ir(n);function n(){return Hn(this,n),t.apply(this,arguments)}return Wn(n,[{key:"onStart",value:function(){this.call.stopCallConnectionTimer(),this.call.fireOnRinging(),this.stateManager.toClosing()}},{key:"type",get:function(){return Yy.CANCELED}}]),n}($y),rg=function(e){Zn(n,e);var t=ir(n);function n(){return Hn(this,n),t.apply(this,arguments)}return Wn(n,[{key:"onStart",value:function(){this.call.stopGetWebRtcStats(),this.call.stopCallConnectionTimer(),this.call.stopToSendAlive(),this.call.stopCurrentRecording(),this.call.stopScreenShare(),this.call.closeRTCConnection(),this.closed()}},{key:"endSent",value:function(e){this.call.setEndInfo(e.payload.endedCall)}},{key:"closed",value:function(){this.stateManager.toEnding()}},{key:"type",get:function(){return Yy.CLOSING}}]),n}($y),ig=function(e){Zn(n,e);var t=ir(n);function n(e,r,i){var a;return Hn(this,n),(a=t.call(this,e,r)).isReconnected=i,a}return Wn(n,[{key:"onStart",value:function(){this.call.stopCallConnectionTimer(),this.call.startGetWebRtcStats(),this.call.sendConnectedInfo(),this.isReconnected?(this.call.setIsReconnected(!0),this.call.fireOnReconnected(),this.call.playSound(zl.RECONNECTED)):(this.call.calcCallSetupTime(),this.call.fireOnConnected())}},{key:"onDestroy",value:function(){this.isReconnected&&this.call.stopSound(zl.RECONNECTED)}},{key:"pcReconnecting",value:function(){this.stateManager.toReconnecting()}},{key:"end",value:function(){this.call.sendEndCommand().catch((function(e){return fo.debug(e)})),this.call.setEndResult(Eo.COMPLETED),this.stateManager.toClosing()}},{key:"receiveEnd",value:function(e){this.call.setEndResult(e.payload.endedCall.endResult),this.call.setEndInfo(e.payload.endedCall),this.stateManager.toClosing()}},{key:"toggleMicrophone",value:function(e){this.call.toggleMicrophone(e),this.call.sendAudioCommand().catch((function(e){return fo.debug(e)}))}},{key:"toggleVideo",value:function(e){this.call.toggleVideo(e),this.call.sendVideoCommand().catch((function(e){return fo.debug(e)}))}},{key:"type",get:function(){return Yy.CONNECTED}}]),n}($y),ag=function(e){Zn(n,e);var t=ir(n);function n(){return Hn(this,n),t.apply(this,arguments)}return Wn(n,[{key:"onStart",value:function(){var e=this;this._createTimer((function(){e._noAnswer()}),this._getTimeoutTime()),this.call.startToSendAlive(),this.call.playSound(zl.DIALING)}},{key:"onDestroy",value:function(){this._removeTimer(),this.call.stopSound(zl.DIALING)}},{key:"receiveAccept",value:function(){this.stateManager.toEstablished()}},{key:"end",value:function(){this.call.sendCancelCommand().catch((function(e){return fo.debug(e)})),this.call.setEndResult(Eo.CANCELED),this.stateManager.toClosing()}},{key:"receiveEnd",value:function(e){this.call.setEndResult(e.payload.endedCall.endResult),this.call.setEndInfo(e.payload.endedCall),this.stateManager.toClosing()}},{key:"_noAnswer",value:function(){this.call.sendNoAnswerCommand().catch((function(e){return fo.debug(e)})),this.call.setEndResult(Eo.NO_ANSWER),this.stateManager.toClosing()}},{key:"_getTimeoutTime",value:function(){return this.call.options.ringingTimeoutValue}},{key:"toggleMicrophone",value:function(e){this.call.toggleMicrophone(e),this.call.sendAudioCommand().catch((function(e){return fo.debug(e)}))}},{key:"toggleVideo",value:function(e){this.call.toggleVideo(e),this.call.sendVideoCommand().catch((function(e){return fo.debug(e)}))}},{key:"type",get:function(){return Yy.DIALING}}]),n}($y),og=function(e){Zn(n,e);var t=ir(n);function n(){return Hn(this,n),t.apply(this,arguments)}return Wn(n,[{key:"onStart",value:function(){this.call.stopAllSound()}},{key:"endSent",value:function(e){this.call.setEndInfo(e.payload.endedCall)}},{key:"type",get:function(){return Yy.ENDED}}]),n}($y),sg=function(e){Zn(n,e);var t=ir(n);function n(){return Hn(this,n),t.apply(this,arguments)}return Wn(n,[{key:"onStart",value:function(){this.call.sendCallSummary(),this.call.fireOnEnded(),this.stateManager.toEnded()}},{key:"type",get:function(){return Yy.ENDING}}]),n}($y),cg=function(e){Zn(n,e);var t=ir(n);function n(e,r){var i;return Hn(this,n),(i=t.call(this,e,r)).isInitiator=e.isCaller,i}return Wn(n,[{key:"onStart",value:function(){this.call.fireOnEstablished(),this.call.sendAudioCommand(),this.call.sendVideoCommand(),this.call.createPeerConnection(),this.isInitiator&&this.call.startCallConnectionTimer()}},{key:"onDestroy",value:function(){}},{key:"pcConnected",value:function(){this.stateManager.toConnected(!1)}},{key:"end",value:function(){this.call.sendEndCommand().catch((function(e){return fo.debug(e)})),this.call.setEndResult(Eo.COMPLETED),this.stateManager.toClosing()}},{key:"fireTimeout",value:function(){this.call.sendTimeoutCommand(this.isInitiator?Jy.OFFERING:Jy.ANSWERING).catch((function(e){return fo.debug(e)})),this.call.setEndResult(Eo.TIMED_OUT),this.stateManager.toClosing()}},{key:"receiveEnd",value:function(e){this.call.setEndResult(e.payload.endedCall.endResult),this.call.setEndInfo(e.payload.endedCall),this.stateManager.toClosing()}},{key:"toggleMicrophone",value:function(e){this.call.toggleMicrophone(e),this.call.sendAudioCommand().catch((function(e){return fo.debug(e)}))}},{key:"toggleVideo",value:function(e){this.call.toggleVideo(e),this.call.sendVideoCommand().catch((function(e){return fo.debug(e)}))}},{key:"type",get:function(){return Yy.ESTABLISHED}}]),n}($y),ug=function(e){Zn(n,e);var t=ir(n);function n(){return Hn(this,n),t.apply(this,arguments)}return Wn(n,[{key:"dialSent",value:function(){this.stateManager.toDialing()}},{key:"dialFailed",value:function(){this.call.setEndResult(Eo.DIAL_FAILED),this.stateManager.toClosing()}},{key:"end",value:function(){this.call.setEndResult(Eo.CANCELED),this.stateManager.toAborted()}},{key:"toggleMicrophone",value:function(e){this.call.toggleMicrophone(e)}},{key:"toggleVideo",value:function(e){this.call.toggleVideo(e)}},{key:"type",get:function(){return Yy.IDLE}}]),n}($y),lg=function(e){Zn(n,e);var t=ir(n);function n(e,r){return Hn(this,n),t.call(this,e,r)}return Wn(n,[{key:"onStart",value:function(){var e=this;this._createTimer((function(){e.call.sendConnectionLostCommand().catch((function(e){return fo.debug(e)}))}),this._getTimeoutTime()),this.call.fireOnReconnecting(),this.call.playSound(zl.RECONNECTING)}},{key:"onDestroy",value:function(){this._removeTimer(),this.call.stopSound(zl.RECONNECTING)}},{key:"pcConnected",value:function(){this.stateManager.toConnected(!0)}},{key:"end",value:function(){this.call.sendEndCommand().catch((function(e){return fo.debug(e)})),this.call.setEndResult(Eo.COMPLETED),this.stateManager.toClosing()}},{key:"endSent",value:function(e){this.call.setEndResult(Eo.CONNECTION_LOST),this.call.setEndInfo(e.payload.endedCall),this.stateManager.toClosing()}},{key:"receiveEnd",value:function(e){this.call.setEndResult(e.payload.endedCall.endResult),this.call.setEndInfo(e.payload.endedCall),this.stateManager.toClosing()}},{key:"_getTimeoutTime",value:function(){return 3e4}},{key:"toggleMicrophone",value:function(e){this.call.toggleMicrophone(e),this.call.sendAudioCommand().catch((function(e){return fo.debug(e)}))}},{key:"toggleVideo",value:function(e){this.call.toggleVideo(e),this.call.sendVideoCommand().catch((function(e){return fo.debug(e)}))}},{key:"type",get:function(){return Yy.RECONNECTING}}]),n}($y),dg=function(e){Zn(n,e);var t=ir(n);function n(){return Hn(this,n),t.apply(this,arguments)}return Wn(n,[{key:"onStart",value:function(){var e=this;this._createTimer((function(){e._noAnswer()}),this._getTimeoutTime()),this.call.startToSendAlive(),this.call.playSound(zl.RINGING),this.call.fireOnRinging()}},{key:"onDestroy",value:function(){this._removeTimer(),this.call.stopSound(zl.RINGING)}},{key:"accept",value:function(e){this.stateManager.toAccepting()}},{key:"receiveAccepted",value:function(){this.call.setEndResult(Eo.OTHER_DEVICE_ACCEPTED),this.stateManager.toClosing()}},{key:"end",value:function(){this.call.sendDeclineCommand().catch((function(e){return fo.debug(e)})),this.call.setEndResult(Eo.DECLINED),this.stateManager.toClosing()}},{key:"endSent",value:function(e){this.call.setEndResult(Eo.DECLINED),this.call.setEndInfo(e.payload.endedCall),this.stateManager.toClosing()}},{key:"receiveEnd",value:function(e){this.call.setEndResult(e.payload.endedCall.endResult),this.call.setEndInfo(e.payload.endedCall),this.stateManager.toClosing()}},{key:"toggleMicrophone",value:function(e){this.call.toggleMicrophone(e)}},{key:"toggleVideo",value:function(e){this.call.toggleVideo(e)}},{key:"_noAnswer",value:function(){this.call.sendNoAnswerCommand().catch((function(e){return fo.debug(e)})),this.call.setEndResult(Eo.NO_ANSWER),this.stateManager.toClosing()}},{key:"_getTimeoutTime",value:function(){return this.call.options.ringingTimeoutValue}},{key:"type",get:function(){return Yy.RINGING}}]),n}($y),hg=function(){function e(t){Hn(this,e),this.call=t,this._state=null}return Wn(e,[{key:"toAborted",value:function(){this._changeState(new eg(this.call,this))}},{key:"toAccepting",value:function(){this._changeState(new tg(this.call,this))}},{key:"toCanceled",value:function(){this._changeState(new ng(this.call,this))}},{key:"toClosing",value:function(){this._changeState(new rg(this.call,this))}},{key:"toConnected",value:function(e){this._changeState(new ig(this.call,this,e))}},{key:"toDialing",value:function(){this._changeState(new ag(this.call,this))}},{key:"toEnded",value:function(){this._changeState(new og(this.call,this))}},{key:"toEnding",value:function(){this._changeState(new sg(this.call,this))}},{key:"toEstablished",value:function(){this._changeState(new cg(this.call,this))}},{key:"toIdle",value:function(){this._changeState(new ug(this.call,this))}},{key:"toReconnecting",value:function(){this._changeState(new lg(this.call,this))}},{key:"toRinging",value:function(){this._changeState(new dg(this.call,this))}},{key:"_changeState",value:function(e){this._state&&this._state.type===e.type?fo.error(new Error("self-transition is not allowed")):(fo.debug("state: ".concat(this._state?this._state.type:"null"," -> ").concat(e.type)),this._state&&this._state.onDestroy(),this._state=e,this._state.onStart())}},{key:"state",get:function(){return this._state}}]),e}(),fg=function(){function e(t,n,r){Hn(this,e),this._ctx=t,this.peerConnectionId=n,this.callId=r}return Wn(e,[{key:"sendOfferSdp",value:function(e){var t=Ip.createOffer(this.callId,this.peerConnectionId,e.sdp);return this._ctx.sender.send(t)}},{key:"sendAnswerSdp",value:function(e){var t=Ip.createAnswer(this.callId,this.peerConnectionId,e.sdp);return this._ctx.sender.send(t)}},{key:"sendCandidate",value:function(e){var t=Ip.createCandidate(this.callId,this.peerConnectionId,e.candidate,e.sdpMLineIndex,e.sdpMid);return this._ctx.sender.send(t)}}]),e}(),_g=vr(null,(function(e,t){var n,r,i,a,o,s,c,u,l,d;return{F:function(t){Zn(r,t);var n=ir(r);function r(t,i){var a;return Hn(this,r),a=n.call(this),e(rr(a)),a._ctx=t,a._options=i,a._localMediaView=null,a._remoteMediaView=null,a._caller=null,a._callee=null,a._localConstraints={audio:!0,video:!0},a._remoteConstraints={audio:void 0,video:void 0},a._endResult=null,a._endInfo=null,a._customItems=null,a._webhook=null,a._remoteRecordingStatus=Ql.NONE,a._sendBirdChatOptions=null,a._holdedBy=[],a._wasRelayed=!1,a._logManager=new Gp(t,rr(a)),a._stateManager=new hg(rr(a)),a._isReconnected=!1,a._rotatablePeerConnection=new Hu(t,{audio:"sendrecv",video:"sendrecv"}),a._rotatablePeerConnection.once("initialized",(function(){a._onPeerConnectionInitialized()})),a._rotatablePeerConnection.on("replaced",(function(){a._onPeerConnectionReplaced()})),a._localStream=new Gl(t.deviceManager),a._localStream.on("streamChanged",(function(){a._onLocalStream()})),a._localStream.on("audioOutputChanged",(function(){a._onAudioOutputChanged()})),a._localStream.on("screenShareStreamStopped",(function(){a.onScreenShareStopped&&a.onScreenShareStopped(),a._dispatchEvent("onScreenShareStopped")})),a}return r}(t),d:[{kind:"field",key:"_wasCalleeDialReceivedProcessed",value:function(){return!1}},{kind:"field",key:"_remoteCapabilities",value:function(){return[]}},{kind:"get",key:"_pc",value:function(){return this._rotatablePeerConnection.activePeerConnection}},{kind:"get",key:"callId",value:function(){return this._callId}},{kind:"get",key:"isVideoCall",value:function(){return this._isVideoCall}},{kind:"get",key:"isCaller",value:function(){return this._isCaller}},{kind:"get",key:"caller",value:function(){return this._caller}},{kind:"get",key:"callee",value:function(){return this._callee}},{kind:"get",key:"localUser",value:function(){return this._isCaller?this.caller:this.callee}},{kind:"get",key:"remoteUser",value:function(){return this._isCaller?this.callee:this.caller}},{kind:"get",key:"isLocalAudioEnabled",value:function(){return this._localConstraints.audio}},{kind:"get",key:"isRemoteAudioEnabled",value:function(){return this._remoteConstraints.audio}},{kind:"get",key:"isLocalVideoEnabled",value:function(){return this._localConstraints.video}},{kind:"get",key:"isRemoteVideoEnabled",value:function(){return this._remoteConstraints.video}},{kind:"get",key:"localRecordingStatus",value:function(){var e,t;return null!==(e=null===(t=this._record)||void 0===t?void 0:t.recordingStatus)&&void 0!==e?e:Ql.NONE}},{kind:"get",key:"remoteRecordingStatus",value:function(){return this._remoteRecordingStatus}},{kind:"get",key:"localMediaView",value:function(){return this._localMediaView}},{kind:"get",key:"remoteMediaView",value:function(){return this._remoteMediaView}},{kind:"get",key:"myRole",value:function(){return this._isCaller?ko.CALLER:ko.CALLEE}},{kind:"get",key:"endedBy",value:function(){return this._endInfo?this._endInfo.endedBy:void 0}},{kind:"get",key:"options",value:function(){return this._options}},{kind:"get",key:"isOngoing",value:function(){return!this.isEnded}},{kind:"get",key:"isOnHold",value:function(){return this._holdedBy.length>0}},{kind:"get",key:"_isLocalOnHold",value:function(){return this._holdedBy.indexOf(this.localUser.userId)>-1}},{kind:"get",key:"isEnded",value:function(){return!!this._endResult}},{kind:"get",key:"endResult",value:function(){return this._endResult}},{kind:"get",key:"_state",value:function(){return this._stateManager.state}},{kind:"get",key:"customItems",value:function(){return Qn({},this._customItems)}},{kind:"get",key:"rtcConnection",value:function(){var e;return null===(e=this._pc)||void 0===e?void 0:e.rtcConnection}},{kind:"get",key:"callLog",value:function(){var e=this._state.type;if(e!==Yy.ENDING&&e!==Yy.ENDED)return null;var t=this._endInfo;return new Gv({call_id:t?t.callId:this.callId,is_video_call:t?t.isVideoCall:this.isVideoCall,custom_items:t?t.customItems:this._customItems,user_role:t?t.userRole:this.myRole,started_at:t?t.startedAt:this._startedAt||Date.now(),ended_at:t?t.endedAt:Date.now(),participants:t?t._participants:[this.caller,this.callee],ended_by:this.endedBy,duration:t?t.duration:this.getDuration(),end_result:t?t.endResult:this.endResult,call_type:t?t.callType:"direct"},!1)}},{kind:"get",key:"_record",value:function(){return this._ctx.recordingManager.getRecord(this._recordId)}},{kind:"get",key:"_isTurnChangedSupported",value:function(){return Yv.includes("turn_changed")&&this._remoteCapabilities.includes("turn_changed")}},{kind:"method",key:"setLocalMediaView",value:(d=qn(regeneratorRuntime.mark((function e(t){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._updateLocalMediaView(t);case 2:case"end":return e.stop()}}),e,this)}))),function(e){return d.apply(this,arguments)})},{kind:"method",key:"setRemoteMediaView",value:(l=qn(regeneratorRuntime.mark((function e(t){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._updateRemoteMediaView(t);case 2:case"end":return e.stop()}}),e,this)}))),function(e){return l.apply(this,arguments)})},{kind:"method",key:"startDuration",value:function(){void 0===this._startedAt&&(this._startedAt=Date.now())}},{kind:"method",key:"getDuration",value:function(){return this._endInfo?this._endInfo.duration:void 0===this._startedAt?0:Date.now()-this._startedAt}},{kind:"method",key:"_send",value:function(e){return this._ctx.sender.send(e)}},{kind:"method",decorators:[Dp({callOption:po})],key:"dial",value:function(e){var t=this,n=e.userId,r=e.isVideoCall,i=e.callOption,a=e.customItems,o=e.sendBirdChatOptions,s=e.webhook;this._isCaller=!0,this._stateManager.toIdle();var c=new Vu;return this._dialDeferred=c,this._isVideoCall=r,this._localStream.mediaConstraints={audio:!0,video:r},this._sendBirdChatOptions=o,this._webhook=s,this._setLocalOption(i),this._getLocalStream(),this._setCustomItems(a),this._logManager.summary.onDial(),this.sendDialCommand(n).then((function(){var e;null===(e=t._dialDeferred)||void 0===e||e.resolve(),delete t._dialDeferred})).catch((function(e){var n;null===(n=t._dialDeferred)||void 0===n||n.reject(e),delete t._dialDeferred})),c.promise}},{kind:"method",key:"_dialed",value:function(e){this._isCaller=!1;var t=e.payload;this._isVideoCall=t.isVideoCall,this._localStream.mediaConstraints={audio:!0,video:t.isVideoCall},this._remoteCapabilities=t.capabilities,this._initTurnCredential=t.turnCredential,this._isTurnChangedSupported&&(this._initTurnCredential.turnUrls=[this._initTurnCredential.turnUrls[0]]),this._setCallInfo(t.callId,t.caller,t.callee),this._setCustomItems(t.customItems),this._setRemoteOption(t.constraints),this._stateManager.toRinging()}},{kind:"method",key:"_dialSent",value:function(e){var t=e.payload;this._setCallInfo(t.callId,t.caller,t.callee),this._logManager.summary.onDialAck(),this._state.dialSent()}},{kind:"method",key:"_calleeDialReceived",value:function(e){var t;this._wasCalleeDialReceivedProcessed||(this._wasCalleeDialReceivedProcessed=!0,this._dispatchEvent("onCalleeDialReceived",this),null===(t=this.onCalleeDialReceived)||void 0===t||t.call(this,this))}},{kind:"method",decorators:[$l($l.messages.CALL_IS_NOT_SUPPORTED),Dp({callOption:po})],key:"accept",value:function(e){var t=e.callOption,n=e.holdActiveCall;fo.info("accept()"),n?this._ctx.callManager.holdExcept(this):this._ctx.callManager.endExcept(this),this._setLocalOption(t),this._getLocalStream(),this._logManager.summary.onAccept(),this._state.accept(t)}},{kind:"method",key:"_receiveAccept",value:function(e){var t=e.payload;this._remoteCapabilities=t.capabilities,this._initTurnCredential=t.turnCredential,this._isTurnChangedSupported&&(this._initTurnCredential.turnUrls=[this._initTurnCredential.turnUrls[0]]),this._setRemoteOption(t.constraints),this._logManager.summary.onAcceptAck(),this._state.receiveAccept()}},{kind:"method",key:"_canceled",value:function(e){var t=e.payload.endedCall;this._setCallInfo(t.callId,t.caller,t.callee),this._setCustomItems(t.customItems),this.setEndResult(t.endResult),this.setEndInfo(t),this._stateManager.toCanceled()}},{kind:"method",key:"end",value:function(){fo.info("end()"),this._dialDeferred&&(this._dialDeferred.reject(new id(Ln.DIAL_CANCELED)),delete this._dialDeferred),this._state.end()}},{kind:"method",key:"_setLocalOption",value:function(e){this._updateLocalMediaView(e.localMediaView),this._updateRemoteMediaView(e.remoteMediaView),this._localConstraints.audio=e.audioEnabled,this._localConstraints.video=e.videoEnabled}},{kind:"method",key:"_setRemoteOption",value:function(e){this._remoteConstraints=e}},{kind:"method",key:"_setCallInfo",value:function(e,t,n){this._callId=e,this._caller=t,this._callee=n}},{kind:"method",key:"setEndResult",value:function(e){e&&(Object.values(Eo).includes(e)?this._endResult=e:this._endResult=Eo.UNKNOWN)}},{kind:"method",key:"setEndInfo",value:function(e){this._endInfo=e}},{kind:"method",key:"_setRemoteAudioEnabled",value:function(e){var t,n=this._remoteConstraints.audio;(this._remoteConstraints.audio=e,n!==e)&&(this._dispatchEvent("onRemoteAudioSettingsChanged",this),null===(t=this.onRemoteAudioSettingsChanged)||void 0===t||t.call(this,this))}},{kind:"method",key:"_setRemoteVideoEnabled",value:function(e){var t,n=this._remoteConstraints.video;(this._remoteConstraints.video=e,n!==e)&&(this._dispatchEvent("onRemoteVideoSettingsChanged",this),null===(t=this.onRemoteVideoSettingsChanged)||void 0===t||t.call(this,this))}},{kind:"method",key:"_setHoldInfo",value:function(e,t,n){var r,i=t?this.localUser:this.remoteUser;if(this._wasRelayed)if(n){this._holdedBy.indexOf(i.userId)<0&&this._holdedBy.push(i.userId)}else{var a=this._holdedBy.indexOf(i.userId);a>-1&&this._holdedBy.splice(a,1)}else this._holdedBy=e;this._updateStreamByHoldStream(),this._dispatchEvent("onUserHoldStatusChanged",this,t,n),null===(r=this.onUserHoldStatusChanged)||void 0===r||r.call(this,this,t,n)}},{kind:"method",key:"_setCustomItems",value:function(e){this._customItems=e||{}}},{kind:"method",key:"_setRemoteRecordingStatus",value:function(e){var t,n=this._remoteRecordingStatus;(this._remoteRecordingStatus=e,e!==n)&&(this._dispatchEvent("onRemoteRecordingStatusChanged",this),null===(t=this.onRemoteRecordingStatusChanged)||void 0===t||t.call(this,this))}},{kind:"method",key:"closeRTCConnection",value:function(){this._releaseLocalStream(),this._rotatablePeerConnection.removeAllEventListeners(),this._rotatablePeerConnection.close()}},{kind:"method",key:"startVideo",value:function(){fo.info("startVideo()"),this._state.toggleVideo(!0)}},{kind:"method",key:"stopVideo",value:function(){fo.info("stopVideo()"),this._state.toggleVideo(!1)}},{kind:"method",key:"hold",value:(u=qn(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(fo.info("hold()"),!this._isLocalOnHold){e.next=3;break}throw new Ja(Ln.ERR_CALL_ALREADY_ON_HOLD);case 3:return e.next=5,this.sendHoldCommand(!0,this._wasRelayed);case 5:case"end":return e.stop()}}),e,this)}))),function(){return u.apply(this,arguments)})},{kind:"method",key:"unhold",value:(c=qn(regeneratorRuntime.mark((function e(t){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(fo.info("unhold()"),this._isLocalOnHold){e.next=3;break}throw new Ja(Ln.ERR_ACTIVE_CALL_IN_PROGRESS);case 3:if(t&&this._ctx.callManager.endExcept(this),!(this._ctx.callManager.getActiveCallCount()>0)){e.next=6;break}throw new Ja(Ln.ERR_ANOTHER_CALL_IN_PROGRESS);case 6:return e.next=8,this.sendHoldCommand(!1,this._wasRelayed);case 8:case"end":return e.stop()}}),e,this)}))),function(e){return c.apply(this,arguments)})},{kind:"method",key:"_holdSent",value:function(e,t){var n=e.payload;n.isRelayed&&(this._wasRelayed=!0),this._setHoldInfo(n.holdedBy,!0,t)}},{kind:"method",key:"_updateStreamByHoldStream",value:function(){var e=this;this.stopScreenShare();var t=this._getLocalStream();t&&(t.getAudioTracks().forEach((function(t){t.enabled=e._isMediaEnabled("audio")})),t.getVideoTracks().forEach((function(t){t.enabled=e._isMediaEnabled("video")}))),this._pc.remoteStream&&(this._pc.remoteStream.getAudioTracks().forEach((function(t){t.enabled=!e.isOnHold})),this._pc.remoteStream.getVideoTracks().forEach((function(t){t.enabled=!e.isOnHold})))}},{kind:"method",key:"_checkRecordingCondition",value:function(e){return this._state.type!==Yy.CONNECTED?(fo.error(Ir.getErrorMessage(Ln.ERR_CALL_NOT_CONNECTED_YET)),!1):!(!this.isVideoCall&&e.isVideo)||(fo.error(Ir.getErrorMessage(Ln.ERR_WRONG_RECORDING_TYPE_FOR_AUDIO_CALL)),!1)}},{kind:"method",key:"startRecording",value:function(e){var t=this,n=new Mo(e);if(!Object.values(So).includes(n.recordingType))return fo.error(Ir.getErrorMessage(Ln.ERR_INVALID_RECORDING_TYPE)),!1;try{!function(){if(!window.MediaRecorder){var e=Ir.getErrorMessage(Ln.ERR_NOT_SUPPORTED_BROWSER_FOR_RECORDING);throw fo.error(e),e}}()}catch(e){return}if(this._checkRecordingCondition(n))if(this._recordId)fo.error(Ir.getErrorMessage(Ln.ERR_RECORDING_ALREADY_IN_PROGRESS));else{var r=Xy.createStream(this,n.recordingType),i=r.stream,a=r.options,o=r.cleanup,s=this._ctx.recordingManager.startRecording(i,a,Qn(Qn({},n),{},{callId:this.callId}));if(s){var c=function(){t.sendRecordingCommand(s.recordId,e.recordingType,s.recordingStatus)};return s.on("start",(function(){return c()})),s.on("stop",(function(){o&&o(),c()})),s.on("pause",(function(){return c()})),s.on("resume",(function(){return c()})),s.on("error",(function(){return c()})),this._recordId=s.recordId,s.recordId}}}},{kind:"method",key:"stopRecording",value:function(e){return e&&this._recordId===e?(this._ctx.recordingManager.stopRecording(e),delete this._recordId,!0):(fo.error(Ir.getErrorMessage(Ln.ERR_FAILED_TO_STOP_RECORDING)),!1)}},{kind:"method",key:"stopCurrentRecording",value:function(){return!!this._recordId&&this.stopRecording(this._recordId)}},{kind:"method",key:"toggleVideo",value:function(e){var t=this;if(this._localConstraints.video!==e){this._localConstraints.video=e;var n=this._getLocalStream();n&&n.getVideoTracks().forEach((function(e){e.enabled=t._isMediaEnabled("video")}))}}},{kind:"method",key:"muteMicrophone",value:function(){fo.info("muteMicrophone()"),this._state.toggleMicrophone(!1)}},{kind:"method",key:"unmuteMicrophone",value:function(){fo.info("unmuteMicrophone()"),this._state.toggleMicrophone(!0)}},{kind:"method",key:"toggleMicrophone",value:function(e){var t=this;if(this._localConstraints.audio!==e){this._localConstraints.audio=e;var n=this._getLocalStream();n&&n.getAudioTracks().forEach((function(e){e.enabled=t._isMediaEnabled("audio")}))}}},{kind:"method",key:"_validateScreenShareAvailability",value:function(){if(this._state.type!==Yy.CONNECTED&&this._state.type!==Yy.RECONNECTING)throw new Ja(Ln.ERR_SCREEN_SHARE_REQUEST_BEFORE_CALL_IS_CONNECTED);if(!this.isVideoCall)throw new Ja(Ln.ERR_SCREEN_SHARE_RESTRICTED_FROM_AUDIO_CALL);if(this.isLocalScreenShareEnabled)throw new Ja(Ln.ERR_SCREEN_SHARE_ALREADY_IN_PROGRESS);if(this.isOnHold)throw new Ja(Ln.ERR_MEDIA_STREAM_NOT_ALLOWED_ON_HOLD)}},{kind:"get",key:"isLocalScreenShareEnabled",value:function(){return this._localStream.isScreenSharing}},{kind:"method",key:"startScreenShare",value:(s=qn(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._validateScreenShareAvailability(),e.next=3,this._localStream.useScreenStream();case 3:case"end":return e.stop()}}),e,this)}))),function(){return s.apply(this,arguments)})},{kind:"method",key:"stopScreenShare",value:function(){this.isLocalScreenShareEnabled&&this._localStream.stopScreenShare()}},{kind:"method",key:"_validateCaptureAvailability",value:function(e){if(this._state.type!==Yy.CONNECTED)throw new Ja(Ln.ERR_VIDEO_CALL_NOT_CONNECTED_YET);if(!this.isVideoCall)throw new Ja(Ln.ERR_CAPTURE_NOT_ALLOWED_ON_AUDIO_CALL);if(e instanceof HTMLAudioElement)throw new Ja(Ln.ERR_VIDEO_VIEW_NOT_READY);if(null==e||!e.srcObject)throw new Ja(Ln.ERR_VIDEO_VIEW_NOT_READY);if(this.isOnHold)throw new Ja(Ln.ERR_MEDIA_STREAM_NOT_ALLOWED_ON_HOLD)}},{kind:"method",key:"captureLocalVideoView",value:function(e){var t=this,n=new Promise((function(e,n){t._validateCaptureAvailability(t._localMediaView),e(t._captureVideoView(t._localMediaView))}));return e&&eo(n)(e),n}},{kind:"method",key:"captureRemoteVideoView",value:function(e){var t=this,n=new Promise((function(e,n){t._validateCaptureAvailability(t.remoteMediaView),e(t._captureVideoView(t._remoteMediaView))}));return e&&eo(n)(e),n}},{kind:"method",key:"_captureVideoView",value:function(e){try{var t,n,r=document.createElement("canvas"),i=r.getContext("2d"),a=e;r.width=null!==(t=a.videoWidth)&&void 0!==t?t:640,r.height=null!==(n=a.videoHeight)&&void 0!==n?n:360,i.drawImage(a,0,0);var o={width:r.width,height:r.height,data:r.toDataURL("image/jpeg",1)};return r.remove(),o}catch(e){throw fo.error(e),new Ja(Ln.ERR_FAILED_TO_GET_IMAGE_FROM_VIDEO_STREAM)}}},{kind:"method",key:"updateCustomItems",value:function(e,t){var n=this,r=or(ro(e,t),2)[1];if(r)return r;var i=Ip.createUpdateCustomItems(this.callId,e),a=this._send(i).then((function(e){return n._setCustomItems(e.custom_items),{customItems:e.custom_items,affectedKeys:e.updated}})).catch((function(e){throw fo.error("failed to update customItems"),e}));return t&&eo(a)(t),a}},{kind:"method",key:"deleteCustomItems",value:function(e,t){var n=this,r=or(io(e,t),2)[1];if(r)return r;var i=Ip.createDeleteCustomItems(this.callId,e),a=this._send(i).then((function(e){return n._setCustomItems(e.custom_items),{customItems:e.custom_items,affectedKeys:e.deleted}})).catch((function(e){throw fo.error("failed to delete customItems"),e}));return t&&eo(a)(t),a}},{kind:"method",key:"deleteAllCustomItems",value:function(e){var t=this,n=Ip.createDeleteAllCustomItems(this.callId),r=this._send(n).then((function(e){return t._setCustomItems(e.custom_items),{customItems:e.custom_items,affectedKeys:e.deleted}})).catch((function(e){throw fo.error("failed to delete all customItems"),e}));return e&&eo(r)(e),r}},{kind:"method",key:"setConnectionQualityListener",value:function(e,t){this._logManager.setConnectionQualityListener(e,t)}},{kind:"method",key:"removeConnectionQualityListener",value:function(){this._logManager.removeConnectionQualityListener()}},{kind:"method",key:"fireOnRinging",value:function(){fo.info("onRinging"),this.onRinging&&this.onRinging()}},{kind:"method",key:"fireOnEstablished",value:function(){var e;fo.info("onEstablished"),this._dispatchEvent("onEstablished",this),null===(e=this.onEstablished)||void 0===e||e.call(this,this)}},{kind:"method",key:"fireOnEnded",value:function(){var e;switch(this.endResult){case Eo.NO_ANSWER:case Eo.CANCELED:case Eo.DECLINED:case Eo.OTHER_DEVICE_ACCEPTED:case Eo.COMPLETED:fo.info("onEnded");break;case Eo.TIMED_OUT:fo.warning("onEnded");break;case Eo.CONNECTION_LOST:case Eo.DIAL_FAILED:case Eo.ACCEPT_FAILED:case Eo.UNKNOWN:fo.error("onEnded");break;default:fo.info("onEnded")}this._logManager.onEnded(),this._dispatchEvent("onEnded",this),null===(e=this.onEnded)||void 0===e||e.call(this,this)}},{kind:"method",key:"fireOnConnected",value:function(){var e;fo.info("onConnected"),this._dispatchEvent("onConnected",this),null===(e=this.onConnected)||void 0===e||e.call(this,this)}},{kind:"method",key:"fireOnReconnecting",value:function(){var e;fo.info("onReconnecting"),this._logManager.onReconnecting(),this._dispatchEvent("onReconnecting",this),null===(e=this.onReconnecting)||void 0===e||e.call(this,this)}},{kind:"method",key:"fireOnReconnected",value:function(){var e;fo.info("onReconnected"),this._dispatchEvent("onReconnected",this),null===(e=this.onReconnected)||void 0===e||e.call(this,this)}},{kind:"method",key:"sendDialCommand",value:function(e){var t=this,n=Ip.createDial(e,this._isVideoCall,this._customItems,this._sendBirdChatOptions,this._localConstraints,this._webhook);return this._send(n).then((function(e){t.onEvent(e)})).catch((function(e){throw t._state.dialFailed(),e}))}},{kind:"method",key:"sendAcceptCommand",value:function(){var e=this,t=Ip.createAccept(this.callId,this._localConstraints);return this._send(t).then((function(t){e.onEvent(t)})).catch((function(t){throw e._state.acceptFailed(),t}))}},{kind:"method",key:"sendCancelCommand",value:function(){var e=this,t=Ip.createCancel(this.callId);return this._send(t).then((function(t){e.onEvent(t)}))}},{kind:"method",key:"sendDeclineCommand",value:function(){var e=this,t=Ip.createDecline(this.callId);return this._send(t).then((function(t){e.onEvent(t)}))}},{kind:"method",key:"sendEndCommand",value:function(){var e=this,t=Ip.createEnd(this.callId);return this._send(t).then((function(t){e.onEvent(t)}))}},{kind:"method",key:"sendTimeoutCommand",value:function(e){var t=this,n=Ip.createTimeout(this.callId,e);return this._send(n).then((function(e){t.onEvent(e)}))}},{kind:"method",key:"sendConnectionLostCommand",value:function(){var e=this,t=Ip.createConnectionLost(this.callId);return this._send(t).then((function(t){e.onEvent(t)}))}},{kind:"method",key:"sendNoAnswerCommand",value:function(){var e=this,t=Ip.createNoAnswer(this.callId);return this._send(t).then((function(t){e.onEvent(t)}))}},{kind:"method",key:"sendAliveCommand",value:function(){var e=Ip.createAlive(this.callId);return this._send(e)}},{kind:"method",key:"sendAudioCommand",value:function(){var e=Ip.createAudio(this.callId,this._localConstraints.audio);return this._send(e)}},{kind:"method",key:"sendVideoCommand",value:function(){var e=Ip.createVideo(this.callId,this._localConstraints.video);return this._send(e)}},{kind:"method",key:"sendCallSummaryCommand",value:function(e){var t=Ip.createCallSummaryCommand(this._callId,this.myRole,e);return this._send(t)}},{kind:"method",key:"sendConnectedCommand",value:function(e,t,n){var r=Ip.createConnected(e,t,n);return this._send(r)}},{kind:"method",key:"sendRecordingCommand",value:function(e,t,n){var r=Ip.createRecording(this.callId,e,t,n);return this._send(r)}},{kind:"method",key:"sendHoldCommand",value:function(e,t){var n=this,r=Ip.createHoldCommand(this.callId,e,t);return this._send(r).then((function(t){n._holdSent(t,e)}))}},{kind:"method",key:"startToSendAlive",value:function(){var e=this;this._aliveIntervalId=setInterval((function(){e.sendAliveCommand().catch((function(e){return fo.debug(e)}))}),3e4)}},{kind:"method",key:"stopToSendAlive",value:function(){this._aliveIntervalId&&(clearInterval(this._aliveIntervalId),delete this._aliveIntervalId)}},{kind:"method",key:"startGetWebRtcStats",value:function(){this._logManager.startGetWebRtcStats(this._rotatablePeerConnection)}},{kind:"method",key:"stopGetWebRtcStats",value:function(){this._logManager.stopGetWebRtcStats()}},{kind:"method",key:"sendConnectedInfo",value:function(){var e=this;this._pc.getCandidateInfo().then((function(t){t&&e.sendConnectedCommand(e.callId,t,e._isReconnected)}))}},{kind:"method",key:"sendCallSummary",value:function(){if(this.callId&&this.endResult!==Eo.OTHER_DEVICE_ACCEPTED){var e=this._logManager.getCallSummary();this.sendCallSummaryCommand(e).catch((function(e){return fo.error("failed to send call summary to server",e)}))}}},{kind:"method",key:"startCallConnectionTimer",value:function(){var e=this;this._callConnectionTimer=setTimeout((function(){e._state.fireTimeout()}),this._options.callConnectionTimeoutValue)}},{kind:"method",key:"stopCallConnectionTimer",value:function(){this._callConnectionTimer&&(clearTimeout(this._callConnectionTimer),delete this._callConnectionTimer)}},{kind:"method",key:"playSound",value:(o=qn(regeneratorRuntime.mark((function e(t){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this._ctx.soundManager.playSound(t));case 1:case"end":return e.stop()}}),e,this)}))),function(e){return o.apply(this,arguments)})},{kind:"method",key:"stopSound",value:function(e){return this._ctx.soundManager.stopSound(e)}},{kind:"method",key:"stopAllSound",value:function(){return this._ctx.soundManager.stopAllSound()}},{kind:"method",key:"_receiveAudio",value:function(e){this._setRemoteAudioEnabled(e.payload.isEnabled)}},{kind:"method",key:"_receiveVideo",value:function(e){this._setRemoteVideoEnabled(e.payload.isEnabled)}},{kind:"method",key:"_receiveHold",value:function(e){e.payload.isRelayed&&(this._wasRelayed=!0),this._setHoldInfo(e.payload.holdedBy,!1,e.payload.isPeerOnHold)}},{kind:"method",key:"_receiveCustomItemsUpdate",value:function(e){var t;this._setCustomItems(e.payload.customItems),this._dispatchEvent("onCustomItemsUpdated",this,e.payload.updated),null===(t=this.onCustomItemsUpdated)||void 0===t||t.call(this,this,e.payload.updated)}},{kind:"method",key:"_receiveCustomItemsDelete",value:function(e){var t;this._setCustomItems(e.payload.customItems),this._dispatchEvent("onCustomItemsDeleted",this,e.payload.deleted),null===(t=this.onCustomItemsDeleted)||void 0===t||t.call(this,this,e.payload.deleted)}},{kind:"method",key:"_receiveRecording",value:function(e){this._setRemoteRecordingStatus(e.payload.recordingStatus)}},{kind:"method",key:"_receiveTurnChanged",value:function(e){if(this._isTurnChangedSupported){var t=e.payload,n=t.turnCredential,r=t.eventId;this.createPeerConnection(r,n)}}},{kind:"method",key:"_registerPCListeners",value:function(){var e=this,t=this._pc;t.on("connected",(function(){e._onPeerConnectionConnected()})),t.on("reconnecting",(function(){e._onPeerConnectionReconnecting()})),t.on("remoteStream",(function(){e._onRemoteStream()}))}},{kind:"method",key:"createPeerConnection",value:function(e,t){var n=new fg(this._ctx,e,this.callId),r=this._rotatablePeerConnection.createPeerConnection(e,n,this._localStream,this._isCaller,e?t:this._initTurnCredential);return this.isCaller&&r.createOffer(),r}},{kind:"method",key:"_onPeerConnectionConnected",value:function(){this._state.pcConnected()}},{kind:"method",key:"_onPeerConnectionReconnecting",value:function(){this._state.pcReconnecting()}},{kind:"method",key:"_onPeerConnectionInitialized",value:function(){this._registerPCListeners(),this._onRemoteStream()}},{kind:"method",key:"_onPeerConnectionReplaced",value:function(){this._onPeerConnectionInitialized(),this._onPeerConnectionConnected()}},{kind:"method",key:"_receiveSnapshot",value:function(e){fo.verbose("snapshot is received");var t=e.payload,n=t.audioEnabled,r=t.videoEnabled,i=t.customItems,a=t.recording;if("boolean"==typeof n&&this._setRemoteAudioEnabled(n),"boolean"==typeof r&&this._setRemoteVideoEnabled(r),a?this._setRemoteRecordingStatus(Ql.RECORDING):this._setRemoteRecordingStatus(Ql.NONE),i){var o,s,c=i,u=Object.keys(c),l=this._customItems,d=Object.keys(l),h=u.filter((function(e){return!d.includes(e)||c[e]!==l[e]})),f=d.filter((function(e){return!u.includes(e)}));if(this._setCustomItems(i),h.length>0)this._dispatchEvent("onCustomItemsUpdated",this,h),null===(o=this.onCustomItemsUpdated)||void 0===o||o.call(this,this,h);if(f.length>0)this._dispatchEvent("onCustomItemsDeleted",this,f),null===(s=this.onCustomItemsDeleted)||void 0===s||s.call(this,this,f)}}},{kind:"method",key:"_passToPeerConnection",value:function(e){switch(e.type){case _d.CANDIDATE:var t=ku.createCandidate(e.payload.peerConnectionId,e.payload.candidate);this._rotatablePeerConnection.onEvent(t);break;case _d.OFFER:var n=ku.createOffer(e.payload.peerConnectionId,e.payload.sdp);this._rotatablePeerConnection.onEvent(n);break;case _d.ANSWER:var r=ku.createAnswer(e.payload.peerConnectionId,e.payload.sdp);this._rotatablePeerConnection.onEvent(r)}}},{kind:"method",key:"onEvent",value:function(e){switch(fo.verbose("'onEvent' on ".concat(e.constructor.name)),e.type){case _d.DIAL:this._dialed(e);break;case _d.DIAL_ACK:this._dialSent(e);break;case _d.DIAL_RCV:this._calleeDialReceived(e);break;case _d.ACCEPT:this._receiveAccept(e);break;case _d.ACCEPT_ACK:this._state.acceptSent(e);break;case _d.OTHER_DEVICE_ACCEPTED:this._state.receiveAccepted();break;case _d.CANCEL:this._canceled(e);break;case _d.DECLINE:case _d.END:case _d.TIME_OUT:case _d.NO_ANSWER:case _d.CONNECTION_LOST:case _d.UNKNOWN_END:this._state.receiveEnd(e);break;case _d.CANCEL_ACK:case _d.DECLINE_ACK:case _d.END_ACK:case _d.TIMEOUT_ACK:case _d.NO_ANSWER_ACK:case _d.CONNECTION_LOST_ACK:case _d.UNKNOWN_END_ACK:this._state.endSent(e);break;case _d.REMOVE_CANDIDATES:break;case _d.AUDIO:this._receiveAudio(e);break;case _d.VIDEO:this._receiveVideo(e);break;case _d.HOLD:this._receiveHold(e);break;case _d.CUSTOM_ITEMS_UPDATE:this._receiveCustomItemsUpdate(e);break;case _d.CUSTOM_ITEMS_DELETE:this._receiveCustomItemsDelete(e);break;case _d.RECORDING:this._receiveRecording(e);break;case _d.TURN_CHANGED:this._receiveTurnChanged(e);break;case _d.SNAPSHOT:this._receiveSnapshot(e);break;case _d.CANDIDATE:this._passToPeerConnection(e);break;case _d.OFFER:this._passToPeerConnection(e),"accepting"===this._state.type&&this._state.receiveOffer(),this._startedAt||this.startDuration();break;case _d.ANSWER:this._passToPeerConnection(e),this._startedAt||this.startDuration();break;default:fo.error(new Error("unhandled call event ".concat(e.type)))}}},{kind:"method",key:"_onAudioOutputChanged",value:(a=qn(regeneratorRuntime.mark((function e(){var t,n,r,i,a;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=this._ctx.deviceManager.getCurrentAudioOutputDevice(),e.next=3,null===(t=this._localMediaView)||void 0===t||null===(n=t.setSinkId)||void 0===n?void 0:n.call(t,a.deviceId);case 3:return e.next=5,null===(r=this._remoteMediaView)||void 0===r||null===(i=r.setSinkId)||void 0===i?void 0:i.call(r,a.deviceId);case 5:case"end":return e.stop()}}),e,this)}))),function(){return a.apply(this,arguments)})},{kind:"method",key:"_onLocalStream",value:function(){var e=this._getLocalStream();this._localMediaView&&(this._localMediaView.srcObject=e);var t,n=fr(e.getTracks());try{for(n.s();!(t=n.n()).done;){var r,i=t.value;i.enabled=null===(r=this._isMediaEnabled)||void 0===r?void 0:r.call(this,i.kind)}}catch(e){n.e(e)}finally{n.f()}}},{kind:"method",key:"_onRemoteStream",value:function(){this._remoteMediaView&&(this._remoteMediaView.srcObject=this._pc.remoteStream)}},{kind:"method",key:"calcCallSetupTime",value:function(){this._logManager.summary.onConnected()}},{kind:"method",key:"setIsReconnected",value:function(e){this._isReconnected=e,this._logManager.summary.increaseReconnectedCount()}},{kind:"method",key:"_isMediaEnabled",value:function(e){switch(e){case"audio":return this._localConstraints.audio&&!this.isOnHold;case"video":return this._localConstraints.video&&!this.isOnHold;default:return fo.error(new Error("unrecognized media type ".concat(e))),!1}}},{kind:"method",key:"_updateLocalMediaView",value:(i=qn(regeneratorRuntime.mark((function e(t){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._localMediaView!==t){e.next=2;break}return e.abrupt("return");case 2:if(this._localMediaView&&(this._localMediaView.srcObject=null),t){e.next=6;break}return this._localMediaView=null,e.abrupt("return");case 6:return e.next=8,this._updateMediaView(t,this._getLocalStream());case 8:this._localMediaView=e.sent;case 9:case"end":return e.stop()}}),e,this)}))),function(e){return i.apply(this,arguments)})},{kind:"method",key:"_updateRemoteMediaView",value:(r=qn(regeneratorRuntime.mark((function e(t){var n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._remoteMediaView!==t){e.next=2;break}return e.abrupt("return");case 2:if(this._remoteMediaView&&(this._remoteMediaView.srcObject=null),t){e.next=6;break}return this._remoteMediaView=null,e.abrupt("return");case 6:return e.next=8,this._updateMediaView(t,null===(n=this._pc)||void 0===n?void 0:n.remoteStream);case 8:this._remoteMediaView=e.sent;case 9:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{kind:"method",key:"_updateMediaView",value:(n=qn(regeneratorRuntime.mark((function e(t,n){var r,i;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(r=this._ctx.deviceManager.getCurrentAudioOutputDevice())){e.next=4;break}return e.next=4,null===(i=t.setSinkId)||void 0===i?void 0:i.call(t,r.deviceId);case 4:return n&&(t.srcObject=n),e.abrupt("return",t);case 6:case"end":return e.stop()}}),e,this)}))),function(e,t){return n.apply(this,arguments)})},{kind:"method",key:"_getLocalStream",value:function(){return this._localStream.localStream}},{kind:"method",key:"_releaseLocalStream",value:function(){this._localStream&&(this._localStream.removeAllEventListeners(),this._localStream.release())}}]}}),Np),vg=function(){function e(t){var n=t.ringingTimeout,r=t.callConnectionTimeout,i=t.statsInterval;Hn(this,e),this._ringingTimeout=n,this._callConnectionTimeout=r,this._statsInterval=i}return Wn(e,[{key:"ringingTimeoutValue",get:function(){return this._ringingTimeout}},{key:"callConnectionTimeoutValue",get:function(){return this._callConnectionTimeout}},{key:"statsIntervalValue",get:function(){return this._statsInterval}}]),e}(),pg=function(){function e(t){Hn(this,e),this._ctx=t,this.options={ringingTimeout:6e4,callConnectionTimeout:6e4,statsInterval:3e3}}return Wn(e,[{key:"createDirectCall",value:function(){return new _g(this._ctx,new vg(this.options))}},{key:"setRingingTimeout",value:function(e){"number"==typeof e&&e>0&&(this.options.ringingTimeout=1e3*e)}},{key:"setStatsInterval",value:function(e){if("number"==typeof e){var t=e;t<1&&(t=1),t>60&&(t=60),this.options.statsInterval=1e3*t}}},{key:"setCallConnectionTimeout",value:function(e){"number"==typeof e&&e>0&&(this.options.callConnectionTimeout=1e3*e)}}]),e}(),mg=function e(t){var n;Hn(this,e),this.audioEnabled=t.is_audio_enabled,this.videoEnabled=t.is_video_enabled,this.customItems=null===(n=t.custom_items)||void 0===n?void 0:n.custom_items},yg=function(){function e(t){Hn(this,e),this.callId=t.call_id,this.callType=t.call_type,this.userRole=t.user_role,this.callerClientId=t.caller_client_id,this.calleeClientId=t.callee_client_id,this.signalSeq=t.signal_seq.map(Ip.parse).filter((function(e){return!!e})),this.signalSnapshot=new mg(t.signal_snapshot)}return Wn(e,[{key:"getAcceptResponse",value:function(){return this.signalSeq.find((function(e){return e.type===_d.ACCEPT_ACK}))}},{key:"getDeclineResponse",value:function(){return this.signalSeq.find((function(e){return e.type===_d.DECLINE_ACK}))}},{key:"commands",get:function(){return this.signalSeq}},{key:"snapshot",get:function(){return this.signalSnapshot}}]),e}(),gg=function(){function e(t){Hn(this,e),this._ctx=t,this._callFactory=new pg(t),this._calls=new Map,this.dialListeners=new Map}return Wn(e,[{key:"setRingingTimeout",value:function(e){this._callFactory.setRingingTimeout(e)}},{key:"setStatsInterval",value:function(e){this._callFactory.setStatsInterval(e)}},{key:"setCallConnectionTimeout",value:function(e){this._callFactory.setCallConnectionTimeout(e)}},{key:"getCall",value:function(e){return this._calls.get(e)}},{key:"_hasCall",value:function(e){return this._calls.has(e)}},{key:"getOngoingCalls",value:function(){return sr(this._calls.values())}},{key:"getOngoingCallCount",value:function(){return sr(this._calls.values()).reduce((function(e,t){return t.isOngoing?e+1:e}),0)}},{key:"getActiveCallCount",value:function(){return sr(this._calls.values()).reduce((function(e,t){return t.isOnHold?e:e+1}),0)}},{key:"dial",value:function(e,t){var n=this,r=this._callFactory.createDirectCall();e.holdActiveCall?this.holdExcept(r):this.endExcept(r);var i=r.dial(e).then((function(){return n._register(r.callId,r),r})).catch((function(e){throw fo.error(e),e}));return t&&eo(i)(t),r}},{key:"holdExcept",value:function(e){var t,n=fr(this._calls.values());try{for(n.s();!(t=n.n()).done;){var r=t.value;r.callId===e.callId||r.isOnHold||r.hold()}}catch(e){n.e(e)}finally{n.f()}}},{key:"endExcept",value:function(e){var t,n=fr(this._calls.values());try{for(n.s();!(t=n.n()).done;){var r=t.value;r.callId!==e.callId&&r.end()}}catch(e){n.e(e)}finally{n.f()}}},{key:"onEvent",value:function(e){switch(e.type){case _d.DIAL:this._onCallDialed(e);break;case _d.CANCEL:this._hasCall(e.getCallId())?this._passToCall(e):this._onCallCanceled(e);break;case Ep.CONNECTED:this._requestCommandLists();break;default:this._passToCall(e)}}},{key:"addListener",value:function(e,t){this.dialListeners.set(e,t)}},{key:"removeListener",value:function(e){this.dialListeners.delete(e)}},{key:"removeAllListeners",value:function(){this.dialListeners.clear()}},{key:"clear",value:function(){var e,t=fr(this._calls.values());try{for(t.s();!(e=t.n()).done;){var n=e.value;try{n.end()}catch(e){fo.error("failed to clear call.")}}}catch(e){t.e(e)}finally{t.f()}this._calls.clear()}},{key:"_register",value:function(e,t){if(!e)throw new Error("call id is not set in call");if(!t)throw new Error("call is null");this._calls.set(e,t)}},{key:"_sendDialReceiveCommand",value:function(e){var t=Ip.createDialReceive(e.getCallId(),e.deliveryInfo,e.receivedType,e.payload.shortLivedToken);return this._ctx.sender.send(t).catch((function(){}))}},{key:"_onCallDialed",value:function(e){var t=this,n=this._callFactory.createDirectCall();this._sendDialReceiveCommand(e),this._register(e.getCallId(),n),n.onRinging=function(){return t._onCallRinging(n)},this._passToCall(e)}},{key:"_onCallCanceled",value:function(e){var t=this,n=this._callFactory.createDirectCall();this._register(e.getCallId(),n),n.onRinging=function(){return t._onCallRinging(n)},this._passToCall(e)}},{key:"_onCallRinging",value:function(e){var t,n=fr(this.dialListeners.values());try{for(n.s();!(t=n.n()).done;){var r=t.value;r.onRinging&&r.onRinging(e)}}catch(e){n.e(e)}finally{n.f()}}},{key:"_requestCommandLists",value:function(){var e=this;fo.verbose("request command list");var t=Array.from(this._calls.keys()).filter((function(t){return!e._calls.get(t).isEnded})),n=Ip.createCommandList(t);this._retrieveCommands(n)}},{key:"_retrieveCommands",value:function(e){var t=this;return this._ctx.sender.send(e).then((function(e){fo.verbose("commandLists is received.");var n=e.call_signal.map((function(e){return new yg(e)}));t._ctx.sender.processCommandLists(n)})).catch((function(e){fo.debug("failed to get commandLists",e)}))}},{key:"_passToCall",value:function(e){this._hasCall(e.getCallId())?this._calls.get(e.getCallId()).onEvent(e):fo.debug("received command ".concat(e.type," for non-existing call ").concat(e.getCallId()))}}]),e}(),Eg="undefined"!=typeof globalThis&&globalThis||"undefined"!=typeof self&&self||void 0!==Eg&&Eg,kg={searchParams:"URLSearchParams"in Eg,iterable:"Symbol"in Eg&&"iterator"in Symbol,blob:"FileReader"in Eg&&"Blob"in Eg&&function(){try{return new Blob,!0}catch(e){return!1}}(),formData:"FormData"in Eg,arrayBuffer:"ArrayBuffer"in Eg};if(kg.arrayBuffer)var Rg=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],Cg=ArrayBuffer.isView||function(e){return e&&Rg.indexOf(Object.prototype.toString.call(e))>-1};function Ig(e){if("string"!=typeof e&&(e=String(e)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(e)||""===e)throw new TypeError("Invalid character in header field name");return e.toLowerCase()}function wg(e){return"string"!=typeof e&&(e=String(e)),e}function Ag(e){var t={next:function(){var t=e.shift();return{done:void 0===t,value:t}}};return kg.iterable&&(t[Symbol.iterator]=function(){return t}),t}function bg(e){this.map={},e instanceof bg?e.forEach((function(e,t){this.append(t,e)}),this):Array.isArray(e)?e.forEach((function(e){this.append(e[0],e[1])}),this):e&&Object.getOwnPropertyNames(e).forEach((function(t){this.append(t,e[t])}),this)}function Tg(e){if(e.bodyUsed)return Promise.reject(new TypeError("Already read"));e.bodyUsed=!0}function Sg(e){return new Promise((function(t,n){e.onload=function(){t(e.result)},e.onerror=function(){n(e.error)}}))}function Og(e){var t=new FileReader,n=Sg(t);return t.readAsArrayBuffer(e),n}function Dg(e){if(e.slice)return e.slice(0);var t=new Uint8Array(e.byteLength);return t.set(new Uint8Array(e)),t.buffer}function Ng(){return this.bodyUsed=!1,this._initBody=function(e){var t;this.bodyUsed=this.bodyUsed,this._bodyInit=e,e?"string"==typeof e?this._bodyText=e:kg.blob&&Blob.prototype.isPrototypeOf(e)?this._bodyBlob=e:kg.formData&&FormData.prototype.isPrototypeOf(e)?this._bodyFormData=e:kg.searchParams&&URLSearchParams.prototype.isPrototypeOf(e)?this._bodyText=e.toString():kg.arrayBuffer&&kg.blob&&((t=e)&&DataView.prototype.isPrototypeOf(t))?(this._bodyArrayBuffer=Dg(e.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):kg.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(e)||Cg(e))?this._bodyArrayBuffer=Dg(e):this._bodyText=e=Object.prototype.toString.call(e):this._bodyText="",this.headers.get("content-type")||("string"==typeof e?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):kg.searchParams&&URLSearchParams.prototype.isPrototypeOf(e)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},kg.blob&&(this.blob=function(){var e=Tg(this);if(e)return e;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){if(this._bodyArrayBuffer){var e=Tg(this);return e||(ArrayBuffer.isView(this._bodyArrayBuffer)?Promise.resolve(this._bodyArrayBuffer.buffer.slice(this._bodyArrayBuffer.byteOffset,this._bodyArrayBuffer.byteOffset+this._bodyArrayBuffer.byteLength)):Promise.resolve(this._bodyArrayBuffer))}return this.blob().then(Og)}),this.text=function(){var e=Tg(this);if(e)return e;if(this._bodyBlob)return function(e){var t=new FileReader,n=Sg(t);return t.readAsText(e),n}(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(function(e){for(var t=new Uint8Array(e),n=new Array(t.length),r=0;r-1?r:n),this.mode=t.mode||this.mode||null,this.signal=t.signal||this.signal,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&i)throw new TypeError("Body not allowed for GET or HEAD requests");if(this._initBody(i),!("GET"!==this.method&&"HEAD"!==this.method||"no-store"!==t.cache&&"no-cache"!==t.cache)){var a=/([?&])_=[^&]*/;if(a.test(this.url))this.url=this.url.replace(a,"$1_="+(new Date).getTime());else{this.url+=(/\?/.test(this.url)?"&":"?")+"_="+(new Date).getTime()}}}function xg(e){var t=new FormData;return e.trim().split("&").forEach((function(e){if(e){var n=e.split("="),r=n.shift().replace(/\+/g," "),i=n.join("=").replace(/\+/g," ");t.append(decodeURIComponent(r),decodeURIComponent(i))}})),t}function Mg(e,t){if(!(this instanceof Mg))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');t||(t={}),this.type="default",this.status=void 0===t.status?200:t.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in t?t.statusText:"",this.headers=new bg(t.headers),this.url=t.url||"",this._initBody(e)}Pg.prototype.clone=function(){return new Pg(this,{body:this._bodyInit})},Ng.call(Pg.prototype),Ng.call(Mg.prototype),Mg.prototype.clone=function(){return new Mg(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new bg(this.headers),url:this.url})},Mg.error=function(){var e=new Mg(null,{status:0,statusText:""});return e.type="error",e};var Ug=[301,302,303,307,308];Mg.redirect=function(e,t){if(-1===Ug.indexOf(t))throw new RangeError("Invalid status code");return new Mg(null,{status:t,headers:{location:e}})};var Vg=Eg.DOMException;try{new Vg}catch(Af){(Vg=function(e,t){this.message=e,this.name=t;var n=Error(e);this.stack=n.stack}).prototype=Object.create(Error.prototype),Vg.prototype.constructor=Vg}function Fg(e,t){return new Promise((function(n,r){var i=new Pg(e,t);if(i.signal&&i.signal.aborted)return r(new Vg("Aborted","AbortError"));var a=new XMLHttpRequest;function o(){a.abort()}a.onload=function(){var e,t,r={status:a.status,statusText:a.statusText,headers:(e=a.getAllResponseHeaders()||"",t=new bg,e.replace(/\r?\n[\t ]+/g," ").split("\r").map((function(e){return 0===e.indexOf("\n")?e.substr(1,e.length):e})).forEach((function(e){var n=e.split(":"),r=n.shift().trim();if(r){var i=n.join(":").trim();t.append(r,i)}})),t)};r.url="responseURL"in a?a.responseURL:r.headers.get("X-Request-URL");var i="response"in a?a.response:a.responseText;setTimeout((function(){n(new Mg(i,r))}),0)},a.onerror=function(){setTimeout((function(){r(new TypeError("Network request failed"))}),0)},a.ontimeout=function(){setTimeout((function(){r(new TypeError("Network request failed"))}),0)},a.onabort=function(){setTimeout((function(){r(new Vg("Aborted","AbortError"))}),0)},a.open(i.method,function(e){try{return""===e&&Eg.location.href?Eg.location.href:e}catch(t){return e}}(i.url),!0),"include"===i.credentials?a.withCredentials=!0:"omit"===i.credentials&&(a.withCredentials=!1),"responseType"in a&&(kg.blob?a.responseType="blob":kg.arrayBuffer&&i.headers.get("Content-Type")&&-1!==i.headers.get("Content-Type").indexOf("application/octet-stream")&&(a.responseType="arraybuffer")),!t||"object"!=typeof t.headers||t.headers instanceof bg?i.headers.forEach((function(e,t){a.setRequestHeader(t,e)})):Object.getOwnPropertyNames(t.headers).forEach((function(e){a.setRequestHeader(e,wg(t.headers[e]))})),i.signal&&(i.signal.addEventListener("abort",o),a.onreadystatechange=function(){4===a.readyState&&i.signal.removeEventListener("abort",o)}),a.send(void 0===i._bodyInit?null:i._bodyInit)}))}Fg.polyfill=!0,Eg.fetch||(Eg.fetch=Fg,Eg.Headers=bg,Eg.Request=Pg,Eg.Response=Mg);var Gg=function(){var e,t;return null!==(e=window)&&void 0!==e&&e.fetch?(t=window).fetch.apply(t,arguments):Fg.apply(void 0,arguments)},Bg=function(){function e(){Hn(this,e)}return Wn(e,null,[{key:"getOsVersion",value:function(){return"undefined"!=typeof navigator&&navigator.userAgent?navigator.userAgent.replace(/,/g,"."):"undefined"}}]),e}(),jg=function(e){Zn(n,e);var t=ir(n);function n(){return Hn(this,n),t.apply(this,arguments)}return n}($a),qg=function(){function e(t){var n;Hn(this,e),this._ctx=t,this._fetch=Gg,this._sessionKey=null,this._hostUrl=null!==(n=this._ctx.apiHost)&&void 0!==n?n:"https://api-IDENTIFIER.calls.sendbird.com".replace("IDENTIFIER",this._ctx.appId)}var t;return Wn(e,[{key:"setSessionKey",value:function(e){this._sessionKey=e}},{key:"clearSessionKey",value:function(){this._sessionKey=null}},{key:"send",value:(t=qn(regeneratorRuntime.mark((function e(t){var n,r,i,a,o,s,c;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t.getApiOption){e.next=2;break}throw new Error("invalid api request ".concat(JSON.stringify(t)));case 2:if(!(n=t.getApiOption()).auth||this._sessionKey){e.next=5;break}throw new Error("tried to call private api without auth");case 5:return(r=Qn({"Content-Type":"application/json"},n.headers)).SendBird="JS,".concat(Bg.getOsVersion(),",").concat(rd),r["SBCall-Client-Id"]=this._ctx.clientId,this._sessionKey&&(r["SBCall-Session-Token"]=this._sessionKey),e.next=11,this._fetch("".concat(this._getHost()).concat(n.path),{method:n.method,body:JSON.stringify(n.body),headers:r});case 11:return i=e.sent,e.next=14,i.text();case 14:a=e.sent,o=null,e.prev=16,o=JSON.parse(a),e.next=23;break;case 20:throw e.prev=20,e.t0=e.catch(16),new Ja(Ln.ERR_MALFORMED_DATA);case 23:if(i.ok){e.next=33;break}if(!o.error){e.next=28;break}throw new jg(o.code,{message:o.message});case 28:if(500!==i.status){e.next=30;break}throw new Ja(Ln.INTERNAL_SERVER_ERROR);case 30:if(!(i.status>=300&&i.status<400)){e.next=32;break}throw new Ja(Ln.ERR_MALFORMED_DATA);case 32:throw new Ja(Ln.ERR_REQUEST_FAILED);case 33:if(!(t instanceof cs)){e.next=36;break}return s=bc.parseResponse(t.type,o),e.abrupt("return",s);case 36:if(!o.cmd){e.next=39;break}return c=Ip.parse(o),e.abrupt("return",c);case 39:return e.abrupt("return",o);case 40:case"end":return e.stop()}}),e,this,[[16,20]])}))),function(e){return t.apply(this,arguments)})},{key:"_getHost",value:function(){return this._hostUrl}}]),e}(),Hg=function(){function e(){Hn(this,e)}return Wn(e,[{key:"parseToJson",value:function(e){try{return JSON.parse(e)}catch(e){return fo.error("failed to parse JSON message",e),{}}}},{key:"validate",value:function(e){var t=e.cmd,n=e.request_id,r=e.call_type;return!!(n||t||r)}},{key:"parseCommand",value:function(e){return e.error?{isValid:!0,error:{requestId:e.request_id,message:e.message,code:e.code}}:"room"===e.call_type?{isValid:!0,command:bc.parse(e)}:{isValid:!0,command:Ip.parse(e)}}},{key:"parse",value:function(e){var t=this.parseToJson(e);return this.validate(t)?this.parseCommand(t):{isValid:!1}}}]),e}(),zg=function(){function e(t){var n;Hn(this,e),this._ctx=t,this._ws=null,this._retryTimer=null,this._closed=!0,this._sessionKey=null,this._requestMap=new zu(this._getTimeoutTime()),this._messageParser=new Hg,this._hostUrl=null!==(n=this._ctx.websocketHost)&&void 0!==n?n:"wss://ws-IDENTIFIER.calls.sendbird.com".replace("IDENTIFIER",this._ctx.appId)}return Wn(e,[{key:"connect",value:function(){var e=this;return new Promise((function(t,n){var r;e._sessionKey||n(new Error("tried to connect to websocket server without auth")),0===(null===(r=e._ws)||void 0===r?void 0:r.readyState)&&n(new Error("websocket is reconnecting already")),e._disconnect(),e._ws=e._createWebSocket(),e._closed=!1,e._ws.onopen=function(){e._onOpen(),t(null)},e._ws.onmessage=function(t){var n=e._messageParser.parse(t.data),r=n.isValid,i=n.error,a=n.command;r&&(i?e._processError(i):e.processCommand(a))},e._ws.onerror=function(t){return e._onError(t)},e._ws.onclose=function(){e._onClose(),n(new Ja(Ln.ERR_WEBSOCKET_CONNECTION_FAILED))}}))}},{key:"_processError",value:function(e){var t=e.requestId,n=e.code,r=e.message,i=this._requestMap.unregister(t);i&&(fo.debug(t,e.message),i.reject(new jg(n,{message:r})))}},{key:"processCommand",value:function(e){var t=this._ctx.router;if(e instanceof yd)t.routeDirectCallPeerCommand(e,nd.WS);else if(e instanceof gd){var n=this._requestMap.unregister(e.requestId);if(!n)return;t.routeDirectCallResponseCommand(e,n)}else e instanceof kd?t.routeDirectCallServerCommand(e,nd.WS):e instanceof gp?t.routeLogServerCommand(e):e instanceof ss?t.routeServerCommand(e):e instanceof as&&t.routePeerCommand(e)}},{key:"setSessionKey",value:function(e){this._sessionKey=e}},{key:"clearSessionKey",value:function(){this._disconnect(),this._sessionKey=null}},{key:"_disconnect",value:function(){this._ws&&(this._closed=!0,this._removeRetryTimer(),this._ws.onopen=null,this._ws.onmessage=null,this._ws.onerror=null,this._ws.onclose=null,this._ws.close(),this._requestMap.rejectAll(new Ja(Ln.ERR_REQUEST_FAILED_DUE_TO_WEBSOCKET_CONNECTION_LOST)),this._ws=null)}},{key:"send",value:function(e){var t=e.requireResponse()?this._requestMap.register(e.requestId).promise:Promise.resolve(),n=e.serialize();return this._ws.send("".concat(n,"\n")),t}},{key:"_onOpen",value:function(){this._ctx.router.routeWebSocketInternalCommand(Ip.createWebSocketConnectedCommand())}},{key:"_onError",value:function(e){fo.error(e)}},{key:"_onClose",value:function(){this.startToReconnect()}},{key:"_createWebSocket",value:function(){var e="/?sbcall_session_token=".concat(encodeURIComponent(this._sessionKey),"&sbcall_client_id=").concat(encodeURIComponent(this._ctx.clientId),"&sendbird=").concat(encodeURIComponent(this._getVersion()));return new WebSocket(this._getHost()+e)}},{key:"_getVersion",value:function(){return"JS,".concat(Bg.getOsVersion(),",").concat(rd)}},{key:"_getHost",value:function(){return this._hostUrl}},{key:"startToReconnect",value:function(){this._closed||this._retryTimer||(this._retryTimer=setTimeout(this._reconnect.bind(this),this._getRetryTime()))}},{key:"_reconnect",value:function(){var e=this;this._removeRetryTimer();Fu(new Bu(5e3,1e3,void 0),(function(){return e.connect()}),{onError:function(e){fo.error("Fail reconnect WebSocket ErrorCode = ".concat(e.code))}})}},{key:"_removeRetryTimer",value:function(){this._retryTimer&&(clearTimeout(this._retryTimer),this._retryTimer=null)}},{key:"_getTimeoutTime",value:function(){return 6e4}},{key:"_getRetryTime",value:function(){return 2e3}},{key:"isConnected",get:function(){return!!this._ws&&1===this._ws.readyState}}]),e}(),Wg=function(){function e(t){Hn(this,e),this._ctx=t,this.wsClient=new zg(t),this.apiClient=new qg(t)}var t,n;return Wn(e,[{key:"connectWs",value:function(){return this.wsClient.connect()}},{key:"reconnectWs",value:function(){return this.wsClient.startToReconnect()}},{key:"sendAPI",value:function(e){return this.apiClient.send(e)}},{key:"sendWs",value:function(e){return this.wsClient.send(e)}},{key:"send",value:(n=qn(regeneratorRuntime.mark((function e(t){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(t instanceof vd)){e.next=11;break}if(t.sendStrategy!==ed.API){e.next=3;break}return e.abrupt("return",this.sendAPI(t));case 3:if(t.sendStrategy!==ed.WS){e.next=7;break}if(!this.wsClient.isConnected){e.next=6;break}return e.abrupt("return",this.sendWs(t));case 6:throw new Ja(Ln.ERR_WEBSOCKET_CONNECTION_NOT_OPENED);case 7:if(t.sendStrategy!==ed.BOTH){e.next=11;break}if(!this.wsClient.isConnected){e.next=10;break}return e.abrupt("return",this.sendWs(t));case 10:case 11:return e.abrupt("return",this.sendAPI(t));case 12:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"sendWithRetry",value:(t=qn(regeneratorRuntime.mark((function e(t){var n,r,i,a,o,s,c=this,u=arguments;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=u.length>1&&void 0!==u[1]?u[1]:new Gu,r=u.length>2&&void 0!==u[2]?u[2]:{count:0,deferred:new Vu},i=r.deferred,a=r.count,e.prev=3,e.next=6,this.send(t);case 6:o=e.sent,i.resolve(o),e.next=14;break;case 10:e.prev=10,e.t0=e.catch(3),(s=n.calcTimeout(a))>0?setTimeout((function(){c.sendWithRetry(t,n,{count:a+1,deferred:i})}),s):i.reject(e.t0);case 14:return e.abrupt("return",i.promise);case 15:case"end":return e.stop()}}),e,this,[[3,10]])}))),function(e){return t.apply(this,arguments)})},{key:"_setSessionKey",value:function(e){this.apiClient.setSessionKey(e),this.wsClient.setSessionKey(e)}},{key:"authenticate",value:function(e){var t=this,n=e.userId,r=e.accessToken,i=Ip.createAuthRequest(this._ctx.appId,n,r);return this.send(i).then((function(e){t._setSessionKey(e.sbcall_session_token);var n=lo(e.user);return{user:new Us(n),statsInterval:e.stats_interval}})).catch((function(e){throw fo.error("failed to authenticate user ".concat(n)),e}))}},{key:"deauthenticate",value:function(){this.apiClient.clearSessionKey(),this.wsClient.clearSessionKey()}},{key:"processCommandLists",value:function(e){var t,n=fr(e);try{for(n.s();!(t=n.n()).done;){var r=t.value;if(r.userRole!==ko.CALLER||this._ctx.clientId===r.callerClientId){if(r.userRole===ko.CALLEE&&this._ctx.clientId!==r.calleeClientId){var i=r.getAcceptResponse();if(i){var a=i.payload.callId,o=Ip.createAccepted(a);this._ctx.router.routeDirectCallPeerCommand(o,nd.WS);continue}var s=r.getDeclineResponse();if(s){var c=s.payload,u=c.callId,l=c.endedCall,d=Ip.createDeclined(u,l);this._ctx.router.routeDirectCallInternalCommand(d)}}var h=r.commands,f=r.snapshot;fo.verbose("process commandList. length: ".concat(h.length));var _,v=fr(h);try{for(v.s();!(_=v.n()).done;){var p=_.value;this.wsClient.processCommand(p)}}catch(e){v.e(e)}finally{v.f()}var m=Ip.createSnapshot(r.callId,f);this._ctx.router.routeDirectCallInternalCommand(m)}}}catch(e){n.e(e)}finally{n.f()}}}]),e}(),Kg=function(e){Zn(n,e);var t=ir(n);function n(e,r){var i;return Hn(this,n),(i=t.call(this))._recordId=xc(),i._blobs=[],i._mediaRecorder=new MediaRecorder(e,r),i._mediaRecorder.ondataavailable=function(e){e.data&&e.data.size>0&&i._blobs.push(e.data)},i._mediaRecorder.onstart=function(){return i._onStart()},i._mediaRecorder.onstop=function(){return i._onStop()},i._mediaRecorder.onpause=function(){return i._onPause()},i._mediaRecorder.onresume=function(){return i._onResume()},i._mediaRecorder.onerror=function(){return i._onError()},i}return Wn(n,[{key:"startRecording",value:function(){try{this._mediaRecorder.start()}catch(e){return fo.error("start recording failed with error : ",e),!1}return!0}},{key:"stopRecording",value:function(){try{this._mediaRecorder.stop()}catch(e){return fo.error("stop recording failed with error : ",e),!1}return!0}},{key:"_onStart",value:function(){this._dispatchEvent("start")}},{key:"_onStop",value:function(){this._dispatchEvent("stop"),this._onRecordingSucceeded(new Blob(this._blobs))}},{key:"_onPause",value:function(){this._dispatchEvent("pause")}},{key:"_onResume",value:function(){this._dispatchEvent("resume")}},{key:"_onError",value:function(){this._dispatchEvent("error"),this._onRecordingFailed(new Ja(Ln.ERR_FAILED_TO_STOP_RECORDING))}},{key:"_onRecordingSucceeded",value:function(e){this._dispatchEvent("succeeded",e)}},{key:"_onRecordingFailed",value:function(e){this._dispatchEvent("failed",e)}},{key:"recordId",get:function(){return this._recordId}},{key:"recordingStatus",get:function(){return"recording"===this._mediaRecorder.state?Ql.RECORDING:Ql.NONE}}]),n}(Yo),Yg=function(){function e(){Hn(this,e),this._listeners=new Map,this._recorders=new Map}return Wn(e,[{key:"getRecord",value:function(e){return this._recorders.get(e)}},{key:"addListener",value:function(e,t){this._listeners.set(e,t)}},{key:"removeListener",value:function(e){this._listeners.delete(e)}},{key:"removeAllListeners",value:function(){this._listeners.clear()}},{key:"_fireOnSucceeded",value:function(e,t){this._listeners.forEach((function(n){n.onRecordingSucceeded&&n.onRecordingSucceeded(t.callId,e,t.recordingOptions,t.fileName)}))}},{key:"_fireOnFailed",value:function(e,t,n){this._listeners.forEach((function(r){r.onRecordingFailed&&r.onRecordingFailed(t.callId,e,n)}))}},{key:"startRecording",value:function(e,t,n){var r=this,i=new Kg(e,t);if(i.startRecording())return this._recorders.set(i.recordId,i),i.on("succeeded",(function(e){Zy.downloadRecordedFile(e,n.fileName),r._fireOnSucceeded(i.recordId,n)})),i.on("failed",(function(e){r._fireOnFailed(i.recordId,n,e)})),i}},{key:"stopRecording",value:function(e){if(this._recorders.size>0){var t=this._recorders.get(e);return!!t&&t.stopRecording()}return!1}},{key:"listeners",get:function(){return this._listeners}}]),e}(),Qg=function(){function e(){Hn(this,e),this.processed=new Map}return Wn(e,[{key:"process",value:function(e){return!e.messageId||(this._isProcessed(e)?(this.processed.delete(e.messageId),!1):(this._setProcessed(e),!0))}},{key:"_isProcessed",value:function(e){return this.processed.has(e.messageId)}},{key:"_setProcessed",value:function(e){this.processed.set(e.messageId,!0)}}]),e}(),Zg=function(){function e(){Hn(this,e),this.lastSeqNumber=-1,this.queue=new Map}var t,n;return Wn(e,[{key:"insert",value:(n=qn(regeneratorRuntime.mark((function e(t,n){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(this.lastSeqNumber>=t.sequenceNumber)){e.next=2;break}return e.abrupt("return");case 2:return this.queue.set(t.sequenceNumber,{command:t,handler:n}),fo.verbose("".concat(t.constructor.name," is inserted")),e.next=6,this.flush();case 6:case"end":return e.stop()}}),e,this)}))),function(e,t){return n.apply(this,arguments)})},{key:"flush",value:(t=qn(regeneratorRuntime.mark((function e(){var t,n,r,i;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:fo.verbose("try flushing sequence queue"),t=this.next();case 2:if(!t){e.next=10;break}return r=(n=t).command,i=n.handler,fo.verbose("flush ".concat(r.constructor.name)),e.next=7,i(r);case 7:t=this.next(),e.next=2;break;case 10:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"next",value:function(){var e=this.lastSeqNumber+1;if(this.queue.has(e)){var t=this.queue.get(e),n=t.command,r=t.handler;return this.queue.delete(e),this.lastSeqNumber=e,{command:n,handler:r}}return null}}]),e}(),Xg=function(){function e(){Hn(this,e),this.sequences=new Map,this.lock=new ts}var t;return Wn(e,[{key:"insert",value:(t=qn(regeneratorRuntime.mark((function e(t,n){var r,i,a;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.lock.acquire();case 2:if(e.prev=2,fo.verbose("try to insert in SequenceManager with ".concat(t.constructor.name)),r=t.getCallId(),t.isSequential()&&r){e.next=10;break}return fo.verbose("not sequential; immediately flush ".concat(t.constructor.name)),this.lock.release(),n(t),e.abrupt("return");case 10:if(!this.sequences.has(r)){e.next=16;break}return i=this.sequences.get(r),e.next=14,i.insert(t,n);case 14:e.next=20;break;case 16:return a=new Zg,this.sequences.set(r,a),e.next=20,a.insert(t,n);case 20:e.next=25;break;case 22:e.prev=22,e.t0=e.catch(2),fo.warning("failed to SequenceManager.insert()",e.t0);case 25:return e.prev=25,this.lock.release(),e.finish(25);case 28:case"end":return e.stop()}}),e,this,[[2,22,25,28]])}))),function(e,n){return t.apply(this,arguments)})}]),e}(),$g=function(e){Zn(n,e);var t=ir(n);function n(){var e;return Hn(this,n),(e=t.call(this))._sequenceManager=new Xg,e._eventDeduplicator=new Qg,e}return Wn(n,[{key:"routeWebSocketInternalCommand",value:function(e){this._dispatchEvent("webSocketInternal",e)}},{key:"routeLogServerCommand",value:function(e){this._dispatchEvent("logServer",e)}},{key:"routeDirectCallInternalCommand",value:function(e){this._dispatchEvent("directCallInternal",e)}},{key:"routeDirectCallPeerCommand",value:function(e,t){var n=this;this._eventDeduplicator.process(e)&&(e.receivedType=t,this._sequenceManager.insert(e,(function(e){n._dispatchEvent("directCallPeer",e)})))}},{key:"routeDirectCallResponseCommand",value:function(e,t){this._sequenceManager.insert(e,function(){var e=qn(regeneratorRuntime.mark((function e(n){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t.resolve(n),e.abrupt("return",t.promise);case 2:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}())}},{key:"routeDirectCallServerCommand",value:function(e,t){var n=this;this._eventDeduplicator.process(e)&&(e.receivedType=t,this._sequenceManager.insert(e,(function(e){n._dispatchEvent("directCallServer",e)})))}},{key:"routeServerCommand",value:function(e){e instanceof ds&&this._dispatchEvent("roomServer",e)}},{key:"routePeerCommand",value:function(e){e instanceof us&&this._dispatchEvent("roomPeer",e)}}]),n}(Yo),Jg=function(){function e(t,n,r){Hn(this,e),this.isLoading=!1,this.hasNext=!0,this.userId=t,this.params=n,this.sender=r,this.nextToken=null}var t;return Wn(e,[{key:"next",value:(t=qn(regeneratorRuntime.mark((function e(t){var n,r=this;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.isLoading){e.next=2;break}throw new Ja(Ln.ERR_QUERY_IN_PROGRESS);case 2:if(this.hasNext){e.next=4;break}return e.abrupt("return",[]);case 4:return this.isLoading=!0,n=this.sender.send(this._createCommand()).then((function(e){return r.nextToken=e.next,r.hasNext=e.has_next,r.isLoading=!1,e.calls.map((function(e){return new Gv(e,!0)}))})),t&&eo(n)(t),e.abrupt("return",n);case 8:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})},{key:"_createCommand",value:function(){return new ud(this.userId,this.params,this.nextToken)}}]),e}(),eE=function(){function e(t,n,r){Hn(this,e),this.isLoading=!1,this.params=t,this.sender=n,this.roomManager=r,this.prevToken=null,this.nextToken=null}var t,n,r;return Wn(e,[{key:"next",value:(r=qn(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.isLoading){e.next=2;break}throw new Ja(Ln.ERR_QUERY_IN_PROGRESS);case 2:if(this.hasNext){e.next=4;break}return e.abrupt("return",[]);case 4:return e.abrupt("return",this._sendQueryCommand(null,this.nextToken));case 5:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"prev",value:(n=qn(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.isLoading){e.next=2;break}throw new Ja(Ln.ERR_QUERY_IN_PROGRESS);case 2:if(this.hasPrev){e.next=4;break}return e.abrupt("return",[]);case 4:return e.abrupt("return",this._sendQueryCommand(this.prevToken,null));case 5:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"_sendQueryCommand",value:(t=qn(regeneratorRuntime.mark((function e(t,n){var r,i,a,o=this;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t||!n){e.next=2;break}throw new Error("internal error while creating RoomListQueryCommand");case 2:return r=bc.createRoomListQuery(this.params,t,n),e.next=5,this.sender.send(r);case 5:return i=e.sent,a=i.payload,this.isLoading=!0,this.prevToken=a.prev,this.nextToken=a.next,this.isLoading=!1,e.prev=11,e.abrupt("return",Promise.all(a.rooms.map((function(e){return o.roomManager.deserializeRoom(e)}))));case 15:return e.prev=15,e.t0=e.catch(11),e.abrupt("return",a.rooms);case 18:case"end":return e.stop()}}),e,this,[[11,15]])}))),function(e,n){return t.apply(this,arguments)})},{key:"hasPrev",get:function(){return!!this.prevToken}},{key:"hasNext",get:function(){return!this.prevToken&&!this.nextToken||!!this.nextToken}}]),e}(),tE="active",nE="passive",rE="hidden",iE="frozen",aE="terminated",oE=function(){return"undefined"!=typeof window&&"object"===Bn(window.safari)&&window.safari.pushNotification},sE=function(){return["focus","blur","visibilitychange","freeze","resume","pageshow","onpageshow"in window?"pagehide":"unload"]},cE=[[tE,nE,rE,aE],[tE,nE,rE,iE],[rE,nE,tE],[iE,rE],[iE,tE],[iE,nE]].map((function(e){return e.reduce((function(e,t,n){return e[t]=n,e}),{})})),uE=function(){return"undefined"==typeof document?nE:document.visibilityState===rE?rE:document.hasFocus()?tE:nE},lE=function(e){Zn(n,e);var t=ir(n);function n(){var e;return Hn(this,n),(e=t.call(this))._state=uE(),e._handleEvents=e._handleEvents.bind(rr(e)),sE().forEach((function(t){return addEventListener(t,e._handleEvents,!0)})),oE()&&addEventListener("beforeunload",(function(t){e._safariBeforeUnloadTimeout=setTimeout((function(){t.defaultPrevented||t.returnValue.length>0||e._dispatchChangesIfNeeded(t,rE)}),0)})),e}return Wn(n,[{key:"_dispatchChangesIfNeeded",value:function(e,t){if(t!==this._state)for(var n=function(e,t){for(var n,r=0;n=cE[r];++r){var i=n[e],a=n[t];if(i>=0&&a>=0&&a>i)return Object.keys(n).slice(i,a+1)}return[]}(this._state,t),r=0;r